script: PR-A.4 — promote translator from internal/ to pkg/script/#14
Merged
Conversation
Makes the translator importable from outside the agentscript module so
loom can depend on it. Go's internal/ rule confines
internal/agentscript/script/ to the agentscript module; loom is a
separate module and cannot import it. This moves the whole translator
package to pkg/script/, matching the repo's existing pkg/ convention
for importable code.
Pure move + import-path rewrite — no logic changes:
- git mv internal/agentscript/script -> pkg/script (carries ast/,
registry/, resolved/ sub-packages and all phase files).
- Rewrote every import of
.../internal/agentscript/script -> .../pkg/script across the
package's own cross-imports, the tests, and cmd/agentscript-run.
The legacy in-process runtime (grammar.go, runtime.go, conditional.go,
loop.go, translator.go, registry.go, emoji_style.go) stays in
internal/agentscript/ — it's the old DSL evaluator, not part of the
public translator surface, and correctly remains module-private.
Public surface now available at github.com/vinodhalaharvi/agentscript/pkg/script:
- Compile(ctx, registry, Source) (sibyl.Plan, error) — source to
validated Plan, no submission.
- Submit / SubmitWith / Run — start the Plan as a Sibyl PlanWorkflow.
- DefaultRegistry() / EchoSpec() — the builtin registry; front ends
extend it. registry.Names() lists builtins (for an LLM prompt).
- Parse / Resolve / ResolveWith / Lower / Finalize / Validate — the
individual phases, for callers that want finer control.
- Typed errors (UnknownBuiltinError, ArityError, ArgTypeError) so a
caller can distinguish 'bad DSL' from 'execution failure'.
Docs updated to the new path and current status:
- docs/dsl-to-sibyl-translator.md: status line now 'Translator MVP
complete'; the phase table marks Lower/Finalize/Validate/Submit
Merged at pkg/script/ and notes the lowering target is Sibyl's
serializable Plan (not the removed in-process DAG).
- README.md: the two internal/agentscript/script/ path references
corrected to pkg/script/.
Verified after the move: build clean, pkg/script tests pass, and the
demo still compiles identically — agentscript-run --dry-run
examples/translator-echo.as produces the same two-node Plan (n1
requires n0).
All CI steps pass: go mod tidy (no change — pure move), go vet
-structtag=false, gofmt, staticcheck, go test -race ./..., go build
./....
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.
What
Makes the translator importable from outside the agentscript module so loom can depend on it. Go's
internal/rule confinesinternal/agentscript/script/to the agentscript module; loom is a separate module and can't import it. This moves the whole translator package topkg/script/, matching the repo's existingpkg/convention.Pure move + import-path rewrite — no logic changes.
git mv internal/agentscript/script → pkg/script(carriesast/,registry/,resolved/sub-packages and all phase files).../internal/agentscript/script→.../pkg/scriptacross the package's cross-imports, tests, andcmd/agentscript-runThe legacy in-process runtime (
grammar.go,runtime.go,translator.go, …) stays ininternal/agentscript/— it's the old DSL evaluator, correctly module-private.Public surface now at
github.com/vinodhalaharvi/agentscript/pkg/scriptThis is exactly what loom will call:
Compile(ctx, registry, Source) → (sibyl.Plan, error)— source to validated Plan, no submissionSubmit/SubmitWith/Run— start the Plan as a SibylPlanWorkflowDefaultRegistry()/EchoSpec()— the builtin registry;registry.Names()lists builtins (for an LLM prompt)Parse/Resolve/Lower/Finalize/Validate— individual phases, for finer controlUnknownBuiltinError,ArityError,ArgTypeError) so a caller distinguishes bad DSL from execution failure — the safety net around an LLM that emits DSLDocs updated
docs/dsl-to-sibyl-translator.md: status → Translator MVP complete; phase table marks Lower/Finalize/Validate/Submit Merged atpkg/script/, notes the lowering target is Sibyl's serializablePlanREADME.md: the twointernal/agentscript/script/path references correctedVerified
Build clean,
pkg/scripttests pass, and the demo compiles identically —agentscript-run --dry-run examples/translator-echo.asproduces the same two-node Plan (n1requiresn0).go mod tidy(+ diff)go vet -structtag=false ./...gofmt -l .staticcheck ./...go test -race ./...go build ./...Next
loom PR-3 — depend on
agentscript/pkg/script, add the prose→DSL LLM step: Slack message → LLM emits AgentScript →script.Compilevalidates it →script.Submitruns it on Sibyl. The translator is the serialization layer; loom's LLM becomes its author.