feat: add rego-deparser package for OPA Rego AST to text conversion #55
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)