Skip to content

refactor: centralize known CLI command checks - #1057

Merged
thymikee merged 2 commits into
mainfrom
codex/known-cli-command-source
Jul 3, 2026
Merged

refactor: centralize known CLI command checks#1057
thymikee merged 2 commits into
mainfrom
codex/known-cli-command-source

Conversation

@thymikee

@thymikee thymikee commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Centralizes known CLI command detection in the command catalog and reuses it from parser unknown-command handling and the CLI defensive fall-through.

Adds regression coverage for catalog/help/internal command recognition plus an AST-backed drift test that fails when cli.ts dispatch checks mention a command the parser does not recognize.

Closes #1043

Touched files: 4. Scope stayed within CLI command recognition/parser/dispatch contracts.

Validation

Focused parser/help coverage passed: pnpm exec vitest run src/utils/tests/args.test.ts src/tests/cli-help.test.ts --project unit.

Static quick checks passed: pnpm check:quick.

Formatting passed: pnpm format.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.5 MB 1.5 MB +282 B
JS gzip 483.6 kB 483.8 kB +113 B
npm tarball 585.4 kB 585.5 kB +94 B
npm unpacked 2.1 MB 2.1 MB +282 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.9 ms 26.9 ms +0.0 ms
CLI --help 47.0 ms 47.2 ms +0.2 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/cli.js +134 B +69 B
dist/src/1986.js +148 B +44 B

@thymikee

thymikee commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Review pass: no actionable blockers found. This matches #1043 by moving known-command recognition into the command catalog and using the shared predicate from parser unknown-command handling plus the CLI fall-through. The AST-backed drift test covers cli.ts command comparisons, including property-access forms, so it should fail if dispatch learns a literal command the parser does not know. Checks are green. I marked this ready-for-human. Note: #1055 appears to be a duplicate solution for the same issue; prefer this PR unless maintainers choose otherwise.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 3, 2026

@thymikee thymikee left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: LGTM — preferred over #1055, which it supersedes. 155/155 parser/CLI tests locally, typecheck clean.

This one wins the duplicate resolution on design: the known-but-unhandled fall-through gets a distinct user-facing message ("Command is registered but no CLI handler accepted it"), so the #1043 drift bug self-describes at the moment someone hits it, instead of masquerading as a user typo. The type-predicate export (isKnownCliCommandName) consumed by both the parser early-check and cli.ts is exactly the single-source-of-truth the issue asked for.

I folded #1055's one advantage into this branch (160f418): the fall-through now also emits a cli_known_command_unhandled error-level diagnostic, so the drift is visible in telemetry, not only to the unlucky user. With that, #1055 is fully subsumed and should close.

@thymikee
thymikee force-pushed the codex/known-cli-command-source branch from 160f418 to 4b54e86 Compare July 3, 2026 10:09
thymikee added 2 commits July 3, 2026 12:21
Folds #1055's telemetry into this branch: known-command fall-through now
emits cli_known_command_unhandled at error level alongside the distinct
user-facing message, so catalog/dispatch drift is visible in diagnostics
as well as to the user who hits it.
@thymikee
thymikee force-pushed the codex/known-cli-command-source branch from 4b54e86 to e8f23fa Compare July 3, 2026 10:21
@thymikee
thymikee merged commit db07c20 into main Jul 3, 2026
21 checks passed
@thymikee
thymikee deleted the codex/known-cli-command-source branch July 3, 2026 10:32
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-03 10:33 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single source of truth for 'is this a known CLI command'

1 participant