Repository navigation
fix(cli): sample only cobra command files for terminal UX - #5343
Merged
Merged
Conversation
*_test.go files and helpers with no cobra.Command literal were filling the five-file description and example sample, so a correct CLI lost points it could not earn back. Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
Contributor
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 require-ready-label-and-ci
🟢 🚦 Auto-queueWhen all merge protections are satisfied and these conditions match, this pull request will be queued automatically.
|
Contributor
[Medium impact] The PR appears safe to merge; the previous alias issue is fixed and no new blocking issues were found. SummaryThe PR limits command samples to non-test files containing a Cobra command literal. The latest update resolves the imported package rather than assuming its name is
Reviews (2) · Last reviewed commit: "fix(cli): resolve cobra command literals..." · Reviewed by Greptile |
sampleCommandFiles matched the selector name cobra instead of the github.com/spf13/cobra import, so an aliased import was skipped and a different package imported as cobra was counted. Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
59 of 96 tasks
Contributor
✅ Merged into
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
terminal_uxsampled the wrong files, so a correct CLI lost description and example points with no fix that did not make the CLI worse.Closes #4278
Approach
sampleCommandFilesnow skips*_test.goand keeps a file only when it contains acobra.Commandcomposite literal. The check usesgo/parser, so a comment, a string, a*cobra.Commandsignature, or another package'sCommandtype does not count.infraAllFilesskips are unchanged. Description and example thresholds are unchanged.The same helper also feeds path validity, type fidelity, and the agent-native prompt/example scan, so those callers now see command files only. On a fresh golden-api print, those dimension scores did not move. Unit fixtures that scored flags or paths in a file with no command literal now include one, so they still exercise the original assertions.
Already fixed:
mcp_token_efficiencyThe other half of #4278 is already on main and was left alone.
estimateMCPTokensininternal/pipeline/mcp_size.gocounts string literals only inside eachmcplib.NewTool(...)registration, bounded bymcpNewToolCallEnd, not handler bodies. That landed in #4686 (fix(cli): count only NewTool catalog text for MCP tokens).TestEstimateMCPTokens_IgnoresHandlerLiteralspins a 4000-character handler string at 10/10, and the golden-api scorecard already recordsmcp_token_efficiency: 10when the registration-region average is inside the <=80 tokens/tool band.Scope
Primary area: scorer (
internal/pipeline/scorecard.go)Why this belongs in this repo: the sample is taken from every printed CLI. An early
*_test.goand a non-command helper such asauto_refresh.gowere universal, so the lost point was not API-specific.Risk
A bounded sample can now reach later command files, so
terminal_uxrises when the previous sample was filled by tests or non-commands. The golden-api scorecard movesterminal_uxfrom 9 to 10. The normalized total stays 97. Path validity, type fidelity, and agent-native scores on that print did not change.Output Contract
Scorecard JSON for the golden-api fixture:
terminal_ux9 → 10. No template or generated Go changes.Verification
go test ./internal/pipeline/passedGOOS=linux,GOOS=darwin, andGOOS=windowsgo buildandgo vetof./internal/pipeline/passedterminal_uxSelf-review gate
Ran before opening this PR:
terminal_ux9 → 10). Templates were not touched.*_test.go, require acobra.Commandcomposite, keep infra skips, parse failure, empty directory, comment-only mention, string literal,*cobra.Commandsignature, and a different package'sCommandtype. Positive case: five well-described command files score the full description band (+2) even when test files and non-command files sort first. Negative cases: one-wordShort:fields lose the description points (score 3, examples only); three described files stay on the partial band (score 2); one command file scores 0.AI / Automation Disclosure