Skip to content

Make the One CLI exportable for a downstream dev CLI#137

Open
siddharth-bhansali wants to merge 2 commits into
mainfrom
feature/int-2574-make-the-one-cli-exportable
Open

Make the One CLI exportable for a downstream dev CLI#137
siddharth-bhansali wants to merge 2 commits into
mainfrom
feature/int-2574-make-the-one-cli-exportable

Conversation

@siddharth-bhansali
Copy link
Copy Markdown
Collaborator

@siddharth-bhansali siddharth-bhansali commented May 15, 2026

Summary

Splits building the Commander program from parsing argv so a private dev CLI can import { program } from '@withone/cli', register its own commands, and parse — without this package running on import.

  • src/index.tssrc/cli.ts: builds and exports program, no longer calls .parse(); dropped the now-irrelevant shebang
  • new src/index.ts: thin package entry that re-exports program
  • bin/cli.js: imports program and calls .parse() — the only place argv is parsed
  • package.json: added exports map (types + importdist/index.*) so the package is importable; version bumped 1.43.41.43.5
  • tsup.config.ts unchanged — entry stays src/index.ts, cli.ts is bundled in transitively, dts: true already emits dist/index.d.ts

Also bundled: a fix: commit resolving 4 pre-existing tsc --noEmit errors (flow-runner.ts, actions.ts, config.ts, logout.ts) so npm run typecheck is green. All four are behavior-preserving (TS-only casts / annotation / a Boolean() wrap). Logically separate from the refactor — happy to split into its own PR if preferred.

No user-facing command or help text changed, so the guide / SKILL.md / README need no updates.

Test plan

  • npm run build succeeds; dist/index.d.ts emits declare const program: Command; export { program }
  • npm run typecheck — 0 errors
  • npm test — 98/98 unit tests pass
  • Functional smoke test of the rebuilt CLI: --version, whoami, config path (+ --agent JSON), logout --help, actions search (live), platforms (live), guide, nested subcommand dispatch, and a real flow validate + flow execute --dry-run
  • Unknown-command error path behaves correctly

🤖 Generated with Claude Code

siddharth-bhansali and others added 2 commits May 15, 2026 16:27
Split building the Commander program from parsing argv so a private dev
CLI can `import { program } from '@withone/cli'`, register its own
commands, and parse — without this package running on import.

- src/index.ts -> src/cli.ts: builds and exports `program`, no longer
  calls `.parse()`; dropped the now-irrelevant shebang
- new src/index.ts: thin package entry that re-exports `program`
- bin/cli.js: imports `program` and calls `.parse()` — the only place
  argv is parsed
- package.json: add `exports` map (types + import -> dist/index.*) so
  the package is importable; bump version 1.43.4 -> 1.43.5

No behavior change: verified build, --version, --help, nested
subcommand dispatch, --agent JSON mode, network GETs (whoami,
platforms), and the unknown-command error path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`npm run typecheck` had four genuine type errors (unrelated to any
single feature — fixing them so the typecheck is green):

- flow-runner.ts: `step as Record<string, unknown>` rejected — FlowStep
  has no string index signature; double-cast via `unknown`
- actions.ts: parallel-segment `data` is `unknown`; cast to
  `Record<string, unknown> | undefined` at the validateActionInput call
  (the single-execute call site at L408 was already correctly typed)
- config.ts: `validateApiKey()` returns `WhoAmIResponse | false`, not
  `boolean`; wrap both call sites in `Boolean(...)` for the `isValid`
  flag. Return type left as-is — init.ts consumes the WhoAmIResponse.
- logout.ts: `typeof import('picocolors').default` is invalid in type
  position for a CJS `export =` module; use `typeof import('picocolors')`

The other 9 errors were missing optionalDependencies / @types in a
partial local install — resolved by a full `npm install`, no code change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@siddharth-bhansali siddharth-bhansali added the enhancement New feature or request label May 15, 2026
@siddharth-bhansali siddharth-bhansali self-assigned this May 15, 2026
@siddharth-bhansali siddharth-bhansali requested a review from paulkr May 15, 2026 11:31
@linear
Copy link
Copy Markdown

linear Bot commented May 15, 2026

INT-2574

@siddharth-bhansali siddharth-bhansali added the bug Something isn't working label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant