Skip to content

fix: reject unknown help commands and shorten usage errors - #146

Merged
petebacondarwin merged 8 commits into
mainfrom
investigate/issue-100
Nov 4, 2026
Merged

petebacondarwin merged 8 commits into
mainfrom
investigate/issue-100

Conversation

@penalosa

@penalosa penalosa commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Reject unknown top-level and nested commands even with --help or -h. Usage errors show the error followed by an italic hint to the nearest valid help command; unknown root flags also list visible global flags.

Count declared required and optional positionals when validating automatic help, and allow variadic arguments. Preserve handler-rendered AI/registrar schema help, lazy command loading, and current command-resolution telemetry, including sanitized failure detail for invalid help requests.

Rebased onto main a0eed39e2e506c3a55060060f0871460015434b0. The issue remains present on that base. Includes a patch changeset.

Validation

  • 265 focused tests passed: command recommendations, AI run, registrar create, and telemetry errors.

  • Exact root pnpm check passed (generation, builds, workspace types, formatting, lint).

  • Eight built CLI smoke checks passed, covering unknown commands with help, surplus positionals, unknown global/leaf flags, and valid help; invalid invocations exited 1 with empty stdout.

  • Generated artifacts have no diff; git diff --check passed.

  • CI passed on the latest head, including Linux, macOS, Windows, and Wrangler tests. Startup benchmark, prerelease, and CodeQL also passed.

  • AI review returned LGTM for 27daf3969e62733045859873e275390000e46d91. All six earlier inline threads are addressed and resolved; no scope deferrals.

Fixes #100

@pkg-pr-new

pkg-pr-new Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/cf@146

commit: 27daf39

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

cf --help startup

mean stddev min max
PR 278.4 ms 3.3 ms 274.3 ms 287.0 ms
base 278.4 ms 2.8 ms 272.8 ms 283.4 ms

Δ (PR vs base): — -0.1 ms (-0.0%)

Measured with hyperfine on ubuntu-latest (3 warmup runs, 20 timed runs). CI numbers carry ±a few ms of runner jitter; treat small deltas as noise.

Comment thread packages/cli/src/index.ts Resolved
@ask-bonk

ask-bonk Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted 1 inline suggestion.

github run

@ask-bonk

ask-bonk Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

Comment thread packages/cli/src/index.ts Resolved
Comment thread packages/cli/src/index.ts Resolved
@ask-bonk

ask-bonk Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted one actionable finding with three inline suggestions. Focused tests could not run because pnpm is unavailable.

github run

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🤖 I've done a thorough review of your PR.

Summary: Refines CLI usage-error output and help handling with regression coverage.

  1. Warning packages/cli/src/index.ts:749: isLeafCommand() accepts arbitrary extra positionals for every leaf under --help, bypassing strict validation. Updated the existing inline suggestions with a positional-aware fix and regression test.

github run

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@ask-bonk

ask-bonk Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@petebacondarwin
petebacondarwin requested review from a team and dario-piotrowicz and removed request for a team October 23, 2026 13:00
Comment thread packages/cli/src/index.ts Resolved
Comment thread packages/cli/src/index.ts Resolved
@ask-bonk

ask-bonk Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted 1 actionable finding in 2 inline suggestions.

github run

@ask-bonk

ask-bonk Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@petebacondarwin
petebacondarwin marked this pull request as ready for review November 4, 2026 14:09

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — No issues found in code quality, security, performance, documentation or the changeset. Handler-rendered help, lazy loading and resolution telemetry are preserved, and tests cover them.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Risk: Low. The patch changeset matches the scope of this fix.


🔒 Security: ✅ LGTM

No security concerns. Unknown command tokens are sanitized before they reach telemetry.


📖 AGENTS.md: ✅ LGTM

The change follows the repository's conventions: strict yargs still handles unknown-option validation, and a patch changeset is included.


📋 Code Quality: ✅ LGTM

  • Root-flag check: Aliases and the built-in help/version flags are handled. Parsed camelCase keys are converted back to kebab-case before they are looked up in the global option names.
  • Handler-rendered help: The new unknown-command check only runs on the yargs-driven help path, so handlers that render their own help (ai run, registrar registrations create) still work. Tests cover both.
  • Usage errors: Full help is no longer printed before usage errors; a short hint follows the error message. The tests assert this, so the change is deliberate.
  • Telemetry: Tests check that unknown tokens are sanitized in failure details, on both the --help and -h paths.

⚡ Performance: ✅ LGTM

The new work happens only on the help and error paths and is small and constant-time. Startup cost and lazy root loading are unchanged.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 27daf396

@petebacondarwin
petebacondarwin added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit 5b21733 Nov 4, 2026
13 checks passed
@petebacondarwin
petebacondarwin deleted the investigate/issue-100 branch November 4, 2026 16:16
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.

cf <unknown> --help exits 0, and usage errors print the whole help before the error

2 participants