refactor(cli): align command surface with gh CLI conventions (ADR-3)
Audited the v0.0~v0.2 21-command surface against gh / kubectl / cargo /
npm / git / docker / flyctl / vercel / supabase / brew. WeKnora was
cherry-picking from multiple heritages, producing an inconsistent feel:
the kb subtree mixed gh verbs (create / delete / list) with a kubectl
verb (get); confirmation flag duplicated --force (docker/kubectl) with
global -y/--yes (gh/vercel/npm); the --agent flag stretched Stripe's
telemetry-tag pattern into a behavior-mode switch that no mainstream
CLI does.
ADR-3 picks gh as the primary north star. Documented deviations remain
for project-link (vercel/cargo), chat (openai-cli), context (kubectl-
light), and doctor (brew/flutter). The decision and its deviations are
documented self-contained in cli/AGENTS.md.
Surface changes:
- kb get → kb view (gh repo view convention); "get" kept as cobra Alias
for v0.0/v0.1 callers — see https://cli.github.com/manual/gh_repo_view.
- kb delete --force / doc delete --force removed in favor of the global
-y/--yes persistent flag (gh repo delete --yes convention). One
mechanism skips destructive prompts; ConfirmDestructive's parameter
renamed `force` → `yes` to match.
- --agent omnibus mode-switch removed. Stripe's DetectAIAgent (the
cited inspiration) only tags User-Agent for telemetry, never flips
behavior; gh / kubectl / aws / docker / flyctl all decline this kind
of flag. The 7-env auto-detect list is reduced to the two entries
Stripe also recognizes (CLAUDECODE, CURSOR_AGENT) — the other five
had no agent-documented source. ApplyAgentSugar / ShouldUseAgentMode
and the dead --no-interactive / --no-progress globals are deleted
entirely.
- DetectAIAgent and SetAgentHelp annotations are kept: env detection
now only triggers AGENT-targeted help text rendering (no behavior
change), matching Stripe's narrower scope.
Tests: 27 cli packages green (acceptance/contract still pins kb get
golden; the alias keeps it valid).
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
// Package agent handles AI agent integration: --agent flag sugar, env detection,
|
||||
// and per-command help annotations.
|
||||
// Package agent handles AI agent integration: env-based detection (used to
|
||||
// trigger AGENT-targeted help text) and per-command help annotations.
|
||||
//
|
||||
// v0.2: removed the omnibus `--agent` flag + ApplyAgentSugar mode-switch
|
||||
// (audited as over-design — see docs/superpowers/specs/2026-05-09 ADR-3).
|
||||
// Mainstream CLIs (gh / kubectl / aws / docker / flyctl) deliberately don't
|
||||
// have a single mode-switch flag; per-command --json + TTY auto-detect cover
|
||||
// 95% of cases. WeKnora now follows that convention.
|
||||
//
|
||||
// What remains here: a small env-detect for known coding agents, used purely
|
||||
// to render the AGENT-targeted help section (no behavior change). Patterned
|
||||
// after Stripe's DetectAIAgent (https://github.com/stripe/stripe-cli/tree/master/pkg/useragent),
|
||||
// which Stripe uses only for User-Agent telemetry tagging.
|
||||
package agent
|
||||
|
||||
import "os"
|
||||
@@ -9,18 +20,18 @@ import "os"
|
||||
type AIAgentName string
|
||||
|
||||
// aiAgentEnvs maps environment variable presence to a coding agent name.
|
||||
// Modeled on Stripe's pkg/useragent/useragent.go DetectAIAgent.
|
||||
// Cropped to the entries the Stripe CLI also recognizes (verified against
|
||||
// stripe-cli/pkg/useragent/useragent.go). The earlier 7-entry list (CODEX_*,
|
||||
// AIDER_PROMPT, CONTINUE_GLOBAL_DIR, OPENCODE_RUNNING, GEMINICODER_PROFILE)
|
||||
// did not have official agent docs backing those env names; removed in v0.2
|
||||
// to avoid maintaining an unverified hardcoded list. New entries should
|
||||
// document the source URL.
|
||||
var aiAgentEnvs = []struct {
|
||||
env string
|
||||
name AIAgentName
|
||||
}{
|
||||
{"CLAUDECODE", "claude-code"},
|
||||
{"CURSOR_AGENT", "cursor"},
|
||||
{"CODEX_PROMPT_HOSTNAME", "codex"},
|
||||
{"AIDER_PROMPT", "aider"},
|
||||
{"CONTINUE_GLOBAL_DIR", "continue"},
|
||||
{"OPENCODE_RUNNING", "opencode"},
|
||||
{"GEMINICODER_PROFILE", "gemini-coder"},
|
||||
}
|
||||
|
||||
// DetectAIAgent returns the first known agent name whose env var is set to a
|
||||
|
||||
Reference in New Issue
Block a user