feat(ego-browser): align runtime CLI input with the nodejs dispatcher and add a script-file form - #226
feat(ego-browser): align runtime CLI input with the nodejs dispatcher and add a script-file form#226Hotragn wants to merge 1 commit into
Conversation
|
Freshness check: the gap is still present on the active line.
So the divergence this PR closes — the app's Still green and conflict-free against |
|
Rebased onto the active line and re-verified. A v2-ready branch is pushed: https://github.com/Hotragn/ego-lite/tree/beta/cli-input-v2 (branched from I could not open a PR for it — |
Summary
Two things this PR still provides:
src/run.ts— the entry CONTRIBUTING documents for direct local debugging (node dist/out/index.js, and anything loading the bundle via--sdk-path) — rejects the-e/--evalflags the app dispatcher accepts, and the repo's--help/usage text documents stdin only. After this PR the open runtime accepts the same inline form, through the same execution path.ego-browser nodejs task.js), which the dispatcher's help does not list. On Windows PowerShell there is no<input redirection, piping re-encodes through$OutputEncoding(ASCII by default on 5.1), and-eis bounded by the ~32K process command-line limit — a file argument is the one form that stays lossless at any script size, which matters for the long single-invocation scripts SKILL.md teaches once a Windows build exists ([Feature]: Add Windows support for ego lite #203).stdin remains the default and is byte-identical in behavior.
Related issue
#225 — see the maintainer correction there; this PR now tracks the narrowed scope. If stdin + dispatcher-level
-eis considered sufficient coverage, closing both costs nothing.Changes
src/run.ts— after the existing flag handling,runMainresolves code from one of three sources:-e <code>/--eval <code>(matching the dispatcher's flag names), a single positional script file (read as UTF-8; unreadable file reportscannot read script file ...and exits 1), or stdin as before. Wrong arity and unknown flags keep the existing usage-error contract (exit 2); the empty-input check covers all three forms uniformly.HELP/USAGEtext documents the forms.src/run-cli-input.test.mjs— 11 tests: file execution (including a non-ASCII literal round-trip), unreadable file,-e/--evalexecution, arity/unknown-flag rejections, stdin regression,--debug-clickscomposition, and help-text coverage.package/ego-browser/README.md,CONTRIBUTING.md— document the input forms next to the existing stdin examples.Deliberately untouched:
skills/ego-browser/SKILL.mdstill teaches the heredoc flow — the skill is versioned against the shipped app runtime, so its guidance should change when an app build that documents these forms ships, not before.Verification
Run from
package/ego-browser(Windows 11, Node 24; also exercised via Git Bash for the heredoc form):Behavior spot-checks against the built bundle (
node dist/out/index.js):Impact
Additive CLI surface on the open runtime only; stdin/heredoc invocations are byte-identical in behavior (covered by the stdin regression test and the untouched output-sink suite).
-esemantics follow the dispatcher's existing contract, so no drift is introduced for users who already useego-browser nodejs -e. One edge previously accepted-as-usage-error now works: a single positional argument executes as a file instead of printing usage. Composes with #161 (argv mutation) — this change parses after the--debug-clicksblock it touches and can rebase either way.Checklist
devfor normal changes; onlydevmay targetmain).feat).