refactor(cli): use incur natively (single root, built-in skills + mcp)#19
Open
douglance wants to merge 1 commit into
Open
refactor(cli): use incur natively (single root, built-in skills + mcp)#19douglance wants to merge 1 commit into
douglance wants to merge 1 commit into
Conversation
Replace the bespoke root dispatcher, command registry, two `Cli`
builders, and custom skills wiring with a single idiomatic incur root
`Cli`. Every command mounts on one `Cli.create("testnode", { sync, mcp
}).serve()`, so `skills add`, `mcp add`, `--help`, `--version`, and
`--llms` come built in.
The scaffolding only existed to avoid importing the local commands,
which resolved the project root at module-load time and threw when run
outside the repo. Project-root resolution is now lazy (inside `run()`),
so all commands can be eagerly registered on one root.
- delete registry.ts, start-cli.ts, local-cli.ts, commands/skills.ts
- add memoized lazy `projectRoot()`; local commands resolve in `run()`
- read version from package.json (was hardcoded "0.1.0")
Supersedes #18: skills now come from incur's built-in `skills add`.
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
Replaces the hand-rolled CLI scaffolding — a custom root dispatcher, a command registry, two separate
Clibuilders (start-cli.ts/local-cli.ts), custom--help/--versionformatting, and a custom skills merger — with a single idiomatic incur rootCli.All commands now mount on one root:
So
skills add,mcp add,--help,--version, and--llmsall come built in from incur — no bespoke wiring.Why it was tangled
Every "local" command (
init,logs,snapshot,status,stop,clean) resolved the project root at module-load time (const PROJECT_ROOT = findProjectRoot()), which throws when run outside the repo. That single import-time side effect is the only reason the commands couldn't share one root — importing them eagerly would crashtestnode start. So everything got split + lazilyimport()ed behind a custom dispatcher.The fix: make project-root resolution lazy (resolved inside
run()via a memoizedprojectRoot()), so all commands can be eagerly registered on one root.Changes
commands/registry.ts,start-cli.ts,local-cli.ts,commands/skills.ts.index.tsto the single-root incur pattern withsync(skills) +mcpoptions.projectRoot()inproject-root.ts; the 6 local commands resolve paths inrun()(no behavior/output change).package.json(was hardcoded"0.1.0"→ now0.2.5).Supersedes #18
Skills now come from incur's built-in
skills add(thesyncoption), so this replaces the customskills.tsfrom #18. Closing #18 in favor of this.Verification
pnpm validate/pnpm test:rungreen (161 tests, incl. updatedskills.test.ts).testnode --helplists all commands +skills add/mcp add.testnode skills add→ syncs 7 skills;testnode mcp add→ registers MCP server.testnode snapshot --help→ subcommands preserved.testnode start --helpfrom a non-repo dir does not throw a project-root error (lazy resolution; eager-importing@arbitrum/testnode-coreis import-safe).