cli: run single-fn files, list multi-fn files, gate AST dump behind --ast#223
Merged
Conversation
…-ast ilo file.ilo with no func arg used to dump raw AST JSON. New behaviour: single-fn file auto-runs, multi-fn file prints a friendly listing and exits 1, AST dump moves behind explicit --ast. Inline-no-func AST dump (PR #178 contract) preserved for tooling.
Eleven regression tests pinning single-fn auto-run, multi-fn listing, --ast in leading and trailing positions, --ast on inline code, and the legacy inline-no-func AST dump. Retarget the one existing test that asserted the old behaviour at --ast.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The pre-scan loop strips --ast from argv before the positional mode-flag match runs, so the dedicated arm here was dead. Removes it.
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.
Summary
`ilo file.ilo` with no function name has dumped raw AST JSON since the early days, which is a first-touch surprise the assessment doc has caught at least six times (lines 527, 623, 816, 839, 936, 1045). It looks like silent success: the program ran, here is some output, except none of it is the program's output. Personas burn 1-3 retries before they figure out they need to pass a function name.
New behaviour:
'` inline-no-funcThe `--ast` flag works in leading, trailing, or any-position - it is extracted in a pre-scan like the engine flags from PR #175. AST dump still skips verify so partial/exploratory snippets work.
Manifesto framing: every retry costs tokens. The current behaviour costs tokens on first contact and disproportionately hits agents that lean on natural-language intuitions about "how to run a file". This change makes the most common case Just Work and reserves the inspection path for an explicit flag.
Repro
Before:
```
$ ilo file.ilo
{ "declarations": [ ... ] } # looks like success, no fn was run
```
After:
```
$ ilo single-fn.ilo
42 # runs
$ ilo multi-fn.ilo
error: multi-fn.ilo defines multiple functions, please specify one.
available functions:
foo
bar
baz
ilo multi-fn.ilo [args...] run a function
ilo --ast multi-fn.ilo dump the parsed AST as JSON
$ ilo --ast file.ilo
{ "declarations": [ ... ] }
```
What's in the diff
Test plan
Follow-ups