Make the One CLI exportable for a downstream dev CLI#137
Open
siddharth-bhansali wants to merge 2 commits into
Open
Make the One CLI exportable for a downstream dev CLI#137siddharth-bhansali wants to merge 2 commits into
siddharth-bhansali wants to merge 2 commits into
Conversation
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>
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
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.ts→src/cli.ts: builds and exportsprogram, no longer calls.parse(); dropped the now-irrelevant shebangsrc/index.ts: thin package entry that re-exportsprogrambin/cli.js: importsprogramand calls.parse()— the only place argv is parsedpackage.json: addedexportsmap (types+import→dist/index.*) so the package is importable; version bumped1.43.4→1.43.5tsup.config.tsunchanged — entry stayssrc/index.ts,cli.tsis bundled in transitively,dts: truealready emitsdist/index.d.tsAlso bundled: a
fix:commit resolving 4 pre-existingtsc --noEmiterrors (flow-runner.ts,actions.ts,config.ts,logout.ts) sonpm run typecheckis green. All four are behavior-preserving (TS-only casts / annotation / aBoolean()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 buildsucceeds;dist/index.d.tsemitsdeclare const program: Command; export { program }npm run typecheck— 0 errorsnpm test— 98/98 unit tests pass--version,whoami,config path(+--agentJSON),logout --help,actions search(live),platforms(live),guide, nested subcommand dispatch, and a realflow validate+flow execute --dry-run🤖 Generated with Claude Code