Skip to content

feat(compat): surface dynamic-command flag aliases in --help#418

Open
jackjin1997 wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
jackjin1997:feat/help-show-flag-aliases-371
Open

feat(compat): surface dynamic-command flag aliases in --help#418
jackjin1997 wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
jackjin1997:feat/help-show-flag-aliases-371

Conversation

@jackjin1997
Copy link
Copy Markdown

Summary

  • What changed? Dynamic commands built from envelope overlays now show their declared flag aliases in --help. After schema enrichment, each visible primary flag whose override declares aliases gets a [别名: --x, --y] suffix on its usage text.

    Before:

    --find string   搜索文本 (必填)
    

    After:

    --find string   搜索文本 (必填) [别名: --query]
    
  • Why? Envelope alias + aliases are registered as hidden cobra flags (per CLIFlagOverride.Aliases docs). They work at runtime but never appear in --help, so users — and especially AI agents probing capability via --help — cannot self-discover them and must read the source JSON. This was the secondary ask split out of [suggest] dws sheet find: 加 --query 兼容别名 (wukong 主名 / 跨版本一致性) #280.

Closes #371

Verification

  • make build
  • make lintgo vet passes; staticcheck not installed in my local env (CI covers it)
  • go test ./internal/compat/ (incl. new TestAliasUsageHint, TestBuildDynamicCommands_AliasesShownInHelp; existing ..._MultipleAliases_Dedup still green)
  • make policy
  • ./scripts/policy/check-generated-drift.sh
  • ./scripts/policy/check-command-surface.sh --strict

Notes

  • Placement: the annotation runs as a post-pass after buildFlagsFromDetailSchema, not inside ApplyBindings. The detail-schema enrichment fills a flag's usage only when usage == paramName; baking the alias hint earlier would change that string and could suppress the description fill. Running last keeps the final usage text intact and just appends the hint.
  • The hint is deduped against the primary flag name and reserved names (json, params) and is idempotent (guarded by the [别名: marker). Alias flags themselves stay hidden — only the hint surfaces them.
  • Label 别名 is hardcoded Chinese to match the issue spec and the surrounding overlay copy (which is itself Chinese); happy to wrap it in i18n.T if you prefer.

Envelope overlays can declare flag aliases (alias + aliases), which the
dynamic command builder registers as hidden cobra flags. They work at runtime
but never appear in --help, so users and agents inspecting `--help` cannot
self-discover them and must read the source JSON.

After schema enrichment, annotate each visible primary flag whose envelope
override declares aliases with a " [别名: --x, --y]" suffix. Aliases stay
hidden; the hint is deduped against the primary and reserved names (json,
params) and is idempotent. Running post-enrichment avoids clobbering the
detail-schema usage-fill (which keys off usage == paramName).

Closes DingTalk-Real-AI#371
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.

enhancement: dynamic-command help 渲染自动透出 flag aliases

1 participant