Skip to content

refactor(cli): use incur natively (single root, built-in skills + mcp)#19

Open
douglance wants to merge 1 commit into
mainfrom
refactor/cli-incur-native
Open

refactor(cli): use incur natively (single root, built-in skills + mcp)#19
douglance wants to merge 1 commit into
mainfrom
refactor/cli-incur-native

Conversation

@douglance

Copy link
Copy Markdown
Collaborator

What

Replaces the hand-rolled CLI scaffolding — a custom root dispatcher, a command registry, two separate Cli builders (start-cli.ts / local-cli.ts), custom --help/--version formatting, and a custom skills merger — with a single idiomatic incur root Cli.

All commands now mount on one root:

Cli.create("testnode", { description, version, sync, mcp })
  .command(startCli).command(initCli)
  .serve();

So skills add, mcp add, --help, --version, and --llms all 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 crash testnode start. So everything got split + lazily import()ed behind a custom dispatcher.

The fix: make project-root resolution lazy (resolved inside run() via a memoized projectRoot()), so all commands can be eagerly registered on one root.

Changes

  • Delete commands/registry.ts, start-cli.ts, local-cli.ts, commands/skills.ts.
  • Rewrite index.ts to the single-root incur pattern with sync (skills) + mcp options.
  • Lazy projectRoot() in project-root.ts; the 6 local commands resolve paths in run() (no behavior/output change).
  • Version now read from package.json (was hardcoded "0.1.0" → now 0.2.5).
  • Net −107 lines.

Supersedes #18

Skills now come from incur's built-in skills add (the sync option), so this replaces the custom skills.ts from #18. Closing #18 in favor of this.

Verification

  • pnpm validate / pnpm test:run green (161 tests, incl. updated skills.test.ts).
  • testnode --help lists all commands + skills add / mcp add.
  • testnode skills add → syncs 7 skills; testnode mcp add → registers MCP server.
  • testnode snapshot --help → subcommands preserved.
  • Key invariant: testnode start --help from a non-repo dir does not throw a project-root error (lazy resolution; eager-importing @arbitrum/testnode-core is import-safe).
  • No behavior/output changes to existing commands.

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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant