Skip to content

refactor(cli-schema): derive the flag tail of usage synopses - #2456

Merged
thymikee merged 1 commit into
mainfrom
claude/2444-usage-flag-tail
Sep 10, 2026
Merged

refactor(cli-schema): derive the flag tail of usage synopses#2456
thymikee merged 1 commit into
mainfrom
claude/2444-usage-flag-tail

Conversation

@thymikee

@thymikee thymikee commented Sep 10, 2026

Copy link
Copy Markdown
Member

Summary

A --help synopsis restated the options its command already declared. #2421 made the flag declaration own the option; this removes the last copy.

A synopsis is now grammar plus a generated [label] tail, and the two rendering rules sit on the declaration: the tail names an option with its declared usageLabel, alias included — the token Command flags: already shows; and usageHidden: true keeps a cross-cutting opt-in out of every synopsis (--record today, still documented under Command flags:).

usageFlags is the one addition a command may state: the options its synopsis names, defaulting to allowedFlags, [] when the synopsis is pure grammar or writes its own mutually-exclusive brackets. So adding an option updates --help on its own unless that command said its synopsis stays short — the curation is now a declaration instead of an unstated property of a prose string.

$ agent-device snapshot --help
Usage:
  agent-device snapshot [--diff] [-i] [--depth, -d <depth>] [--scope, -s <scope>] [--raw] [--actions] [--force-full] [--timeout <ms>]

snapshot and proxy drop their usageOverride; five more drop only the flag brackets. is loses [--record]; the other 67 synopses are byte-identical, verified by generating all of them before and after. commands.md moves to the generated line and its byte-for-byte doc test stays green. 27 files. Closes #2444.

Validation

pnpm check:affected --run green on 7240ef1db9 (format, lint, typecheck, layering, fallow, build, related Vitest, command-docs, agent-guidance); check:fallow --base origin/main clean. Replay, web-smoke and device lanes stay GitHub-authoritative: only synopsis strings changed.

Guards verified by planting: a forgotten usageFlags: [] renders [--settle] [--settle] and fails; a tail naming an unaccepted option fails; an added option reaches snapshot and prepare with no override edit; a terse synopsis keeps it in Command flags: only.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-10 14:32 UTC

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 4.53 MB 4.53 MB +100 B
Package (unpacked) 4.53 MB 4.53 MB +100 B
Package (download) 1.34 MB 1.34 MB -57 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.5 ms 28.1 ms +0.6 ms
CLI --help 75.9 ms 76.4 ms +0.5 ms

A command that hand-wrote its synopsis had to restate every option it
accepts inside that string, which is the last restatement left on the help
surface after #2421 made the flag declaration own the option itself.

A synopsis is now grammar plus a generated `[label]` tail, and the two
rendering rules live on the declaration rather than per command:

- the tail names an option with its declared `usageLabel`, alias included,
  the token the `Command flags:` section already shows;
- `usageHidden: true` keeps a cross-cutting opt-in out of every synopsis;
  `--record` is the one today, and it stays under `Command flags:`.

`usageFlags` is where a command states that its synopsis names fewer options
than it accepts: `[]` for a synopsis that is pure grammar or writes its own
mutually-exclusive brackets, otherwise the subset it names. `Command flags:`
still documents everything in `allowedFlags`. Adding an option to a command
therefore updates `--help` on its own, except where the command said its
synopsis stays short.

`snapshot` and `proxy` drop their override; `daemon`, `device`, `doctor`,
`prepare`, `tv-remote`, `scroll` and `artifacts` drop the flag brackets from
theirs. Guards fail a tail that names an option the command does not accept,
or one the hand-written grammar already wrote.

Every synopsis except `snapshot` and `is` is byte-identical; those two move
exactly per the rules above, and the canonical `snapshot` docs line follows
the generator.

Closes #2444
@thymikee
thymikee force-pushed the claude/2444-usage-flag-tail branch from 61f0954 to 7240ef1 Compare September 10, 2026 13:24
@thymikee

Copy link
Copy Markdown
Member Author

Rebased onto main (805ffb4690) and simplified the design in 7240ef1db9. No review comments had landed, so this is self-inflicted.

The first shape added deriveUsageFlagTail and kept the 19 hand-written synopses that show only some options honest through a guard table listing ~90 flag keys per command. That table was itself a restatement of the option lists — the thing this change exists to delete — and it reconstructed per-command facts inside a test.

The new shape states them where the parser and help already read them: usageFlags (default allowedFlags) is the option set a synopsis names, so the tail is always generated and the ~23 commands that keep a terse synopsis say usageFlags: [] at their own descriptor. Removed: deriveUsageFlagTail, the waiver table, and the prose-matching that had to guess whether a synopsis "mentioned" a flag. Two guards remain, both structural: a tail may not name an option outside allowedFlags, and a generated tail may not repeat a bracket the grammar already wrote. Diff is 224 added lines against 492.

Behaviour is unchanged from the previous head: all 69 synopses regenerate byte-identically, still only snapshot and is moving.

@thymikee

Copy link
Copy Markdown
Member Author

No code findings at 7240ef1. The shared renderer derives the flag tail, keeps intentional short forms explicit, and preserves the documented help output apart from the declared alias and record changes. Current checks are green; package growth is 100 B.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Sep 10, 2026
@thymikee
thymikee merged commit dbfebd4 into main Sep 10, 2026
21 checks passed
@thymikee
thymikee deleted the claude/2444-usage-flag-tail branch September 10, 2026 14:31
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.

refactor(cli-schema): derive the flag tail of usage synopses so an option addition never edits usageOverride

1 participant