Align CLI help/grouping and flag semantics for command consistency#41727
Align CLI help/grouping and flag semantics for command consistency#41727Copilot wants to merge 4 commits into
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #41727 does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (49 additions detected, threshold is 100). |
|
✅ PR Code Quality Reviewer completed the code quality review. |
|
✅ Test Quality Sentinel completed test quality analysis. |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ |
There was a problem hiding this comment.
Pull request overview
This PR tightens gh aw CLI consistency by aligning command grouping in root help, normalizing high-impact flag/shorthand semantics, and updating docs/tests to match the intended UX patterns across commands.
Changes:
- Re-group analysis commands (including
outcomes) and refresh root “Common Tasks” wording forstatus/audit. - Normalize/clarify flag semantics and help text (notably: add
compile -f/-l, addenv --repo/-r, remove shorthand forlogs --engine, removetrial --repoalias). - Update docs and extend tests to lock in grouping + shorthand behavior.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/upgrade_command.go | Minor help-text hyphenation consistency for --pre-releases. |
| pkg/cli/trial_command.go | Removes --repo alias for --host-repo and clarifies --dry-run/--timeout descriptions. |
| pkg/cli/logs_filtering_test.go | Updates expectations to ensure logs --engine has no shorthand. |
| pkg/cli/logs_command.go | Aligns logs short description with artifacts-focused behavior. |
| pkg/cli/logs_command_test.go | Updates logs help assertions; adds explicit shorthand check for --engine. |
| pkg/cli/forecast_command.go | Normalizes [EXPERIMENTAL] short description wording/format. |
| pkg/cli/flags.go | Removes shorthand from engine filter flag helper (now --engine only). |
| pkg/cli/flags_test.go | Adds/updates shorthand consistency tests (including compile -f/-l and logs engine no-shorthand). |
| pkg/cli/fix_command.go | Clarifies --disable-codemod help text to match intended flow. |
| pkg/cli/env_command.go | Adds -r shorthand for env get/update --repo and clarifies defaulting behavior. |
| pkg/cli/env_command_test.go | Verifies env get/update --repo shorthand is -r. |
| docs/src/content/docs/setup/cli.md | Updates docs to reflect new semantics/shorthands and clearer examples. |
| cmd/gh-aw/main.go | Moves/normalizes analysis group assignments and adds status to “Common Tasks”; adds compile -f/-l. |
| cmd/gh-aw/compile_flags_test.go | Adds a targeted test ensuring compile --force/-f and --logical-repo/-l exist. |
| cmd/gh-aw/command_groups_test.go | Extends grouping tests to ensure outcomes is in the analysis group. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 15/15 changed files
- Comments generated: 2
- Review effort level: Low
| // addEngineFilterFlag adds the --engine/-e flag to a command for filtering. | ||
| // This flag allows filtering results by AI engine type. |
| @@ -20,7 +20,7 @@ The `gh aw` CLI extension enables developers to create, manage, and execute AI-p | |||
| | [`gh aw run`](#run) | Execute workflows immediately in GitHub Actions | | |||
| | [`gh aw status`](#status) | Check current state of all workflows | | |||
| | [`gh aw logs`](#logs) | Download and analyze workflow logs | | |||
🧪 Test Quality Sentinel Report✅ Test Quality Score: 85/100 — Excellent
📊 Metrics & Test Classification (6 tests analyzed)
Go: 6 (
|
There was a problem hiding this comment.
REQUEST_CHANGES — one blocking issue, one non-blocking concern
Blocking: trial --repo was a hidden but working alias for --host-repo. This PR removes it outright, causing unknown flag: --repo for any script or pipeline that relied on it. The cobra MarkDeprecated path (keep-flag + print warning) is a one-line fix and gives users a migration window.
Non-blocking observations
- Dropped
--timeout 0concern: The description change ('set to 0 to disable timeout') is actually correct —PollWithSignalHandlingexplicitly checksoptions.Timeout > 0before applying the deadline, so passing 0 polls indefinitely. No issue there. compile_flags_test.godesign: Tests the package-globalcompileCmddirectly, whileflags_test.goalready covers the same flags viacreateCompileCommandStub(). Both files need updating on every shorthand change. Consider a factory function to enable isolated testing, but this is not blocking.- The shorthand additions (
-f,-lon compile;-ron env get/update), grouping changes, and help text cleanups are well-structured and the test coverage is appropriate.
🔎 Code quality review by PR Code Quality Reviewer · 102.6 AIC · ⌖ 7.04 AIC · ⊞ 5.2K
| @@ -117,13 +111,11 @@ Trial results are saved both locally (in trials/ directory) and in the host repo | |||
| cmd.Flags().String("clone-repo", "", "Clone the contents of the specified repository into the host repository before execution (useful for testing against actual repository state)") | |||
|
|
|||
| cmd.Flags().String("host-repo", "", "Custom host repository slug (defaults to '<username>/gh-aw-trial'). Use '.' for current repository") | |||
There was a problem hiding this comment.
Silent removal of hidden --repo alias breaks scripts without a deprecation warning.
The --repo flag was a working alias for --host-repo — hidden, but still functional. Removing it outright causes gh aw trial ... --repo myorg/myrepo to fail with unknown flag: --repo rather than guiding users to the correct flag.
💡 Suggested fix
Use MarkDeprecated to preserve compatibility while discouraging use — cobra prints a warning on stderr but the flag still works:
cmd.Flags().String("repo", "", "Alias for --host-repo")
_ = cmd.Flags().MarkHidden("repo")
_ = cmd.Flags().MarkDeprecated("repo", "use --host-repo instead")This gives users a migration window without a silent break in automation scripts or CI pipelines that relied on the hidden alias.
| import "testing" | ||
|
|
||
| func TestCompileCommandShortFlags(t *testing.T) { | ||
| forceFlag := compileCmd.Flags().Lookup("force") |
There was a problem hiding this comment.
Testing the real compileCmd global duplicates assertions already in flags_test.go and couples tests to shared init state.
The new entries in flags_test.go already verify --force/-f and --logical-repo/-l via createCompileCommandStub(). This file then re-tests the same properties against the package-global compileCmd — two different mechanisms asserting the same invariant means two files that must be updated together on every shorthand change.
💡 Details
The two-layer approach (stub for pattern consistency + real command for registration correctness) is reasonable in principle, but the implementation has a subtle risk: compileCmd is shared mutable global state initialized by init(). Any test in package main that registers or removes a flag on compileCmd (even in a t.Cleanup) would silently corrupt this test's expectations.
A safer approach is to extract command construction into a factory function:
// in main.go
func newCompileCommand() *cobra.Command { ... }That lets both this test and the stub test use an isolated instance with no shared-state risk. Non-blocking, but worth addressing before the pattern spreads to other command tests.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /improve-codebase-architecture, /tdd, /zoom-out, and /grill-with-docs — observations only, no blocking issues.
📋 Key Themes & Highlights
Key Themes
- Stale comment (
flags.go):addEngineFilterFlagdoc-comment still says--engine/-eafter-ewas removed — a 1-line fix. - Missing regression test: The
trial --repoalias removal has no corresponding "flag is absent" test; easy to add and documents the API contract. - Stub drift risk:
createCompileCommandStubinflags_test.gonow needs to be manually kept in sync with the realcompileCmdin two places. A clarifying comment would help. - Description precision:
logsShort drops"aggregated metrics"— worth confirming whether that capability should remain discoverable.
Positive Highlights
- ✅ Clean split of
addEngineFlag(override, keeps-e) vsaddEngineFilterFlag(filter-only, no shorthand) — the semantic distinction is now enforced at the type level, not just by convention. - ✅
trial --reporemoval is surgical: the hidden alias, its conditional logic, and the mutual-exclusion constraint are all cleaned up together. - ✅ New shorthand parity (
-f,-l,-r) is well-covered by both stub-based consistency tests and a direct real-command test incompile_flags_test.go. - ✅
outcomesgrouping fix (analysis instead of Additional Commands) is a small change with good UX impact. - ✅ PR description is thorough — clearly explains every change category and why.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 103.7 AIC · ⌖ 7.24 AIC · ⊞ 6.5K
| @@ -17,7 +17,7 @@ func addEngineFlag(cmd *cobra.Command) { | |||
| // addEngineFilterFlag adds the --engine/-e flag to a command for filtering. | |||
There was a problem hiding this comment.
[/improve-codebase-architecture] Stale comment: addEngineFilterFlag now registers --engine without a shorthand, but the doc-comment on line 17 still says --engine/-e. This directly contradicts the implementation after the PR removes -e.
💡 Suggested fix
Change line 17 from:
// addEngineFilterFlag adds the --engine/-e flag to a command for filtering.to:
// addEngineFilterFlag adds the --engine flag (no shorthand) to a command for filtering.The intent to distinguish filter-only from override-style flags is clear in the implementation — the comment just needs to match.
| cmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompts") | ||
| cmd.Flags().Bool("dry-run", false, "Show what would be done without making any changes") | ||
| cmd.Flags().Int("timeout", 30, "Execution timeout in minutes") | ||
| cmd.Flags().Bool("dry-run", false, "Preview trial execution without applying any changes") |
There was a problem hiding this comment.
[/tdd] Missing regression test for --repo flag removal. The --repo alias was deliberately removed to eliminate cross-command semantic ambiguity — there's no test asserting the flag is absent, so it could be silently re-introduced.
💡 Suggested test addition
Add to pkg/cli/trial_command_test.go (or a new test file):
func TestTrialCommandRepoFlagRemoved(t *testing.T) {
cmd := NewTrialCommand()
if cmd.Flags().Lookup("repo") != nil {
t.Error("trial command should not have --repo flag (semantic conflict with other commands)")
}
}This is a deliberate API contract: trial uses --host-repo, not --repo. A regression test documents that intent and prevents accidental re-introduction.
| @@ -233,8 +257,10 @@ func TestShortFlagConsistency(t *testing.T) { | |||
| func createCompileCommandStub() *cobra.Command { | |||
There was a problem hiding this comment.
[/zoom-out] createCompileCommandStub manually mirrors the real compileCmd flag set. With -f and -l added here AND tested directly against the real compileCmd in cmd/gh-aw/compile_flags_test.go, there are now two places to update when compile flags change. If the stub drifts (e.g. a new shorthand is added to the real command but not the stub), the consistency tests in this file can report a false pass.
💡 Consideration
The stub exists because pkg/cli tests can't import cmd/gh-aw. That's a valid constraint. But it's worth adding a comment near the stub noting it must be kept in sync with cmd/gh-aw/main.go, and that compile_flags_test.go is the authoritative test for the real command:
// createCompileCommandStub mirrors the shorthand flags defined on compileCmd
// in cmd/gh-aw/main.go. Keep this in sync when adding new shorthands.
// The authoritative test for the real command is cmd/gh-aw/compile_flags_test.go.
func createCompileCommandStub() *cobra.Command {| logsCmd := &cobra.Command{ | ||
| Use: "logs [workflow]", | ||
| Short: "Download and analyze agentic workflow logs with aggregated metrics", | ||
| Short: "Download and analyze agentic workflow logs and artifacts", |
There was a problem hiding this comment.
[/grill-with-docs] The new short description "Download and analyze agentic workflow logs and artifacts" drops "with aggregated metrics". If the command still surfaces aggregated metrics (token counts, cost summaries, latency), users searching for that capability won't find it via --help or tab-completion. Consider keeping the analytics signal:
"Download and analyze agentic workflow logs, artifacts, and metrics"
If artifacts is the key new capability being highlighted, leading with it rather than appending and artifacts might make it clearer why the description changed.
|
@copilot run pr-finisher |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done. Addressed the two reviewer findings in commit
|
CLI consistency review found drift between
gh aw --help, command flag behavior, and setup docs (group placement, shorthand collisions, and inconsistent wording/default semantics). This PR tightens command grouping and normalizes high-impact flag/help inconsistencies to match established CLI patterns.Command grouping + root help alignment
outcomesto theanalysisgroup so it no longer appears under “Additional Commands”.status/listanalysis assignments into the analysis section inmain.go(code organization consistency).statusand improvesaudittask wording to reflect broader audit/diff use.Flag semantics and shorthand normalization
compile --force→-fcompile --logical-repo→-lenv get/update --repo→-rtrial --repoalias (host-repo alias with conflicting meaning) to eliminate cross-command--reposemantic ambiguity.-eshorthand fromlogs --engine(filter-only flag) to avoid collision with override-style--engine/-eused by mutating commands.Help text consistency cleanup
forecastshort description format/terminology ([EXPERIMENTAL], AIC wording)logsshort/long description alignmentcompile --allow-action-refswording alignment with validation languageupgrade --pre-releaseshyphenationfix --disable-codemodwording alignment with upgrade flowtrial --dry-run/--timeoutphrasing clarity.Docs + focused test updates
docs/src/content/docs/setup/cli.mdto match actual CLI output/options (including shorthand changes and correctedadd --direxample).outcomes(and hidden-but-grouped analysis command pattern),logs --engineno-shorthand behavior,env --repo/-r,compile --force/-fand--logical-repo/-l.