Repository navigation
fix: help lists only applicable flags, groups question commands, states exit codes - #189
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…es exit codes Three help-surface fixes found by an unauthenticated agent driving the binary with no docs: Per-command --help no longer appends every persistent presentation flag. help_flags.go classifies the dci persistent flags by what they act on, using the signals the pipeline already keys on: report/query result shape (--chart, --pivot, --flat, --rollup, --max-rows, --rows, --include-empty-rows, --drop-unlabeled-rows, --heatmap), the file-shaped exports (--for-reimport, --output-file inline), page-token paging (--all), list responses (--search), the list-insights view (--include-dismissed), and a resolvable positional argument (--id/--name). The agent-contract flags stay inline everywhere; the table flags that apply to every command fold into one "Output flags" pointer line; --help-full lists all of them. Flags are hidden only while help renders and restored after, so `dci commands --json` is unchanged and every flag is still accepted everywhere. A spec-gated test keeps the report-shaped and file-shaped sets in step with the live description. anomalies-recent and budgets-at-risk now list under the group of the operation they wrap, right after list-anomalies/list-budgets, instead of under "Additional Commands". Root help carries the exit-code and error-envelope contract from error_contract.go in a four-line paragraph, and `dci docs` points at it and the Help Center table. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
Beyond the inline findings, I also checked whether marking a command as --search-eligible (helpCommandIsList, help_flags.go:192-201) could point at flags that silently do nothing: applyListSearch's shape detector (listWrapperRows, output_contract.go:268) accepts any single array-of-objects field or a results/items key with list metadata, which covers the list/search/paging/question-command shapes this classifier targets, so that concern is ruled out.
Extended reasoning...
The diff adds a help-text/UX chapter (help_flags.go) that classifies and folds persistent flags per command, plus question-command group adoption; it touches no auth/crypto/permission logic, only CLI help rendering and classification heuristics. Three confirmed findings already identified real edge-case inaccuracies in the flag-visibility classifier (report-shaped detection, error-path pointer line, multi-path-arg resolution fallback), so approval is not warranted. I additionally traced the ruled-out --search concern through applyListSearch/listWrapperRows to confirm it is not a live bug, which is the one piece of independent verification worth surfacing beyond the existing inline comments.
Findings marked 🟡 are optional suggestions and need no follow-up push.
…s, and multi-argument commands Review follow-ups on the per-command flag visibility: - The beta subtree names the async results operation get-report-results (x-cli-name), not get-async-operation-results, so its help hid the report flags that act on it. reportResultOperations now carries both spellings, and the spec-gated test unions the embedded beta spec's response shapes (with an offline beta-only check). - The "Output flags" pointer line renders only while the flags it stands in for are actually folded. The usage template is shared with cobra's usage dump on a flag-parse error, where nothing is hidden. - The --id/--name fallback requires exactly one positional argument, the only arity name resolution ever covers. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Summary
Three help-surface fixes found by an unauthenticated AI agent driving the built binary with no docs.
--helplists only the flags that can act on the command. Every dci persistent flag used to render under every command, burying the command's own flags under ~30 inert ones (invite-user --helpshowed--chart,--pivot,--for-reimport,--all, …). New chapterhelp_flags.goclassifies the flags by the signals the pipeline already keys on: report/query result shape (chart, pivot, flat, rollup, max-rows, rows, include-empty-rows, drop-unlabeled-rows, heatmap), the file-shaped exports (for-reimport; output-file inline there), page-token paging (--all), list responses (--search), the list-insights view (--include-dismissed), and a resolvable positional argument (--id/--name). The agent-contract flags (--output,--fields,--exclude,--full,--dry-run,--yes,--agent,--no-agent,-D) stay inline everywhere; the table flags that apply to every command fold into oneOutput flags (… add --help-full to list them)line;--help-fulllists every flag. Flags are hidden only while help renders and restored afterwards, so every flag is still accepted everywhere anddci commands --jsonis unchanged.anomalies-recentandbudgets-at-risktake the group of the operation they wrap and render right afterlist-anomalies/list-budgetsinstead of under "Additional Commands".--help. Root help gains a four-line "Exit codes" paragraph (codes 0/1/2/10/11/20/21/30/40/41/50, the stderr JSON envelope in agent mode, the Help Center link), anddci docsgains an "Exit codes and errors" entry.Also: the skill text now says
--help-fulllists every flag, and a stray gofmt nit inhelp_context_test.gois fixed (separatechore:commit).Not acted on: the
commands --searchranking ofopenfor "invite a teammate to the console" is expected keyword behaviour; the right command ranked first.Before / after
dci invite-user --help(agent mode): 36 inherited flag lines → 10 flag lines plus the two-line output-flags pointer.dci --help:Tests
help_flags_test.go: scope coverage of every persistent flag, placement per command shape, restore after render (catalog unaffected),--help-full, the pointer line, rendered help through the template, question-command group adoption and ordering, and a spec-gated check (DCI_COMMAND_DOCS_SPEC, fetched in CI) that the report-shaped and file-shaped operation sets match the live description.main_test.goTestHelpRendersWithoutCredentials: the hermetic spec now has one operation of each shape; new subtests for per-command flag visibility (four commands plus--help-full), root-help grouping, and the exit-code paragraph.docs_command_test.goand the pty suite (TestE2EDefaultHelpRoutesBareInvocation,TestE2EAPICommandHelpRendersWithoutCredentials) assert the new lines.gofmt -l .,go vet ./...,go test -skip TestE2E . ./tools/...(with the production spec),go test -run TestE2E .all pass; verified by hand with a freshDCI_CONFIG_DIRforinvite-user --help,anomalies-recent --help, and--help.🤖 Generated with Claude Code