feat(cli): render command hints with a wrapper-passed tool name - #983
Conversation
Every pasteable command hint the CLI prints starts with the bare binary name, so when the CLI runs behind a wrapper, pasting a hint invokes an unconfigured binary that can't reach the server. A wrapper now passes its own invocation on every call via a hidden global --cli-name flag; every hint site and kong's usage text render through the new cliname package, so printed commands work as pasted. The flag is scanned from the raw args because kong's usage name must be fixed before parsing; an absent flag keeps the default name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR makes CLI-printed “pasteable” command hints wrapper-aware by introducing a hidden global --cli-name flag that can supply the wrapper invocation (e.g. --cli-name "wrapper schemabot"). The CLI scans this flag from raw args before kong.Parse so kong’s usage header and all runtime hints consistently render the wrapper’s tool name, while preserving the default schemabot behavior when the flag is absent.
Changes:
- Add
pkg/cmd/internal/clinameto store and resolve the rendered CLI name and to pre-scan--cli-namefrom raw args. - Wire
cliname.Name()intokong.Name(...)and replace hard-codedschemabot ...hints across templates and commands. - Declare a hidden global kong flag (
cli-name) so the flag is accepted at any position.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/main.go | Pre-scan --cli-name and feed wrapper-aware name into kong usage (kong.Name(cliname.Name())). |
| pkg/cmd/internal/templates/progress.go | Replace hard-coded schemabot hints with cliname.Name() in progress/status-related output. |
| pkg/cmd/internal/templates/plan.go | Render “re-run with --allow-unsafe” hint using cliname.Name(). |
| pkg/cmd/internal/templates/locks.go | Render unlock hints using cliname.Name() so wrapper users can paste commands. |
| pkg/cmd/internal/cliname/cliname.go | New package providing global CLI name resolution and raw-args scanning for --cli-name. |
| pkg/cmd/internal/cliname/cliname_test.go | Unit tests covering name lifecycle and --cli-name arg scanning behavior. |
| pkg/cmd/commands/watch_tui.go | Make TUI exit/context command hint wrapper-aware via cliname.Name(). |
| pkg/cmd/commands/watch_tui_view.go | Update various TUI footer/reattach/proceed hints to use cliname.Name(). |
| pkg/cmd/commands/progress.go | Update validation error message to point at wrapper-aware status command. |
| pkg/cmd/commands/plan.go | Update “no endpoint configured” guidance to use wrapper-aware configure command. |
| pkg/cmd/commands/login.go | Update profile/endpoint configuration guidance to use wrapper-aware configure command. |
| pkg/cmd/commands/fixlint.go | Update follow-up hint (plan) to use wrapper-aware command name. |
| pkg/cmd/commands/configure.go | Update post-configure example commands to use wrapper-aware invocation. |
| pkg/cmd/commands/common.go | Declare hidden global cli-name flag and update several printed hints to use cliname.Name(). |
| pkg/cmd/commands/apply.go | Update apply preflight messaging and revert-window hint to use wrapper-aware commands. |
| pkg/cmd/client/config.go | Update token refresh/login guidance to use wrapper-aware login command. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A wrapper that embeds the command packages in its own kong CLI (rather than exec'ing the binary) must call cliname.Set before parsing, which an internal/ package forbids from another module. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
305adee to
55a2c71
Compare
The unlock command requires -d, so the pasteable hint must carry it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
🤖 Review findings - created by Kiran's code review agent - for pull/983, 67527d3. Verdict: 7 findings — 0 blocking; 4 non-blocking (live sweep gaps + hygiene), 3 suggestions. CI is fully green (32/32); merges cleanly with current main. Non-blocking
General suggestions
The one thing that could have broken, verifiedHand-scanning raw argv with a second, independent parser of the same flag kong declares — then baking the result into kong's own usage name before kong parses. If Verified correct
This review was generated by Claude Code (claude-fable-5). |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Close the hint surfaces the first sweep missed: the preview usage/error hints, the demo narration lines in preview templates (so a wrapper-invoked demo no longer mixes tool names), and the kong help tags that embed command hints — now interpolated via a cli_name kong var. FromArgs skips hyphen-leading space-form values so it accepts exactly what kong's own scanner accepts, and a parse test pins the kong flag declaration and the raw-args scan to the same spelling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
🤖 Thanks — all addressed in a5acfc7 except the commit-message nit (that commit is now in approved history, so leaving it rather than rewriting): preview usage/error hints and the preview-template demo narration render through This reply was generated by Claude Code (Fable 5). |
Every pasteable command hint the CLI prints (
Force unlock: schemabot unlock ...,use 'schemabot status ...') starts with the bare binary name. When the CLI runs behind a wrapper command, pasting a hint invokes an unconfigured bare binary that can't reach the server instead of the wrapper the operator actually uses.A wrapper can now supply its own invocation: an exec-style wrapper passes a hidden global
--cli-nameflag (e.g.--cli-name "acme schemabot"), and a wrapper that embeds the command packages callscliname.Setbefore parsing. All hint sites render through the newpkg/cmd/clinamepackage (exported so embedders can use it), and kong's usage text picks up the name too, so printed commands work as pasted. When neither is used the plainschemabotdefault keeps direct use unchanged.The flag is scanned from the raw args before
kong.Parsebecause it feeds kong's usage name; kong still declares the flag (hidden) so it's accepted at any position, a parse test pins the two spellings to each other, and the scan accepts exactly what kong's scanner accepts. Kong help tags that embed command hints interpolate the name via acli_namekong var, and the preview usage/error/demo surfaces render throughclinametoo.The companion CLI client guide (
docs/cli.md, including how to wrap the CLI with--cli-name) is split out into #984.🤖 Generated with Claude Code