feat: add rego-deparser package for OPA Rego AST to text conversion#55
Merged
pyramation merged 1 commit intomainfrom Jan 6, 2026
Merged
feat: add rego-deparser package for OPA Rego AST to text conversion#55pyramation merged 1 commit intomainfrom
pyramation merged 1 commit intomainfrom
Conversation
- Add TypeScript types for Rego AST nodes (Module, Rule, Expr, Term, etc.) - Implement deparser that converts Rego AST to valid Rego source code - Support all major Rego constructs: packages, imports, rules, expressions - Handle infix operators, comprehensions, references, and literals - Add comprehensive test suite with 47 tests - Follow cel-proto-parser patterns for consistency
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add rego-deparser package for OPA Rego AST to text conversion
Summary
Adds a new
rego-deparserpackage to the dev-utils monorepo, positioned alongsidecel-proto-parser. This package provides TypeScript types for OPA's Rego Abstract Syntax Tree and a deparser that converts AST back to valid Rego source code.The package supports:
This is part of the broader effort to add OPA capabilities to the stack for a unified policy engine.
Review & Testing Checklist for Human
src/types.tswere created from OPA documentation research. Test with real OPA-generated AST JSON (viaopa parse --format json) to confirm the types are accurateInfixOperatorsmap insrc/types.tsassumes specific operator names from OPA (e.g.,assign→:=,eq→=). Verify these match OPA's actual AST representationsomekeyword declarations, raw strings, certaineveryexpression patterns).github/workflows/ci.ymlSuggested test plan:
opa parse --format json policy.regoto get ASTopa fmtfor canonical comparison)Notes
Link to Devin run: https://app.devin.ai/sessions/c053d7e3447a47959bc24118acd8b30c
Requested by: Dan Lynch (@pyramation)