f2e8e3f56c
Survey of 10 mainstream CLIs (gh, lark, stripe, vercel, supabase, aws, azure, gcloud, openai/codex, github-copilot-cli) showed env-gated per-command --help blurbs are a Stripe-only pattern; gh uses env detect for telemetry only, and lark relies on installed agent Skills + MCP. Our cmd/mcp/serve already covers the dominant 2025/26 path, so internal/aiclient/ (136 LOC + 38 callsites) is net maintenance burden without precedent. - Drop internal/aiclient/ entirely (annotations + detect + tests) - Remove 38 SetAgentHelp callsites + agentAwareHelpFunc / SetHelpFunc wiring in cmd/root.go - Migrate 4 command-level rules to standard Long help (visible to all, not env-gated): doc upload mode mutex, kb edit at-least-one, kb pin idempotent, search chunks channel mutex - Rewrite AGENTS.md as a developer guide (gh-style 6 H2 / 167 lines): audience preamble + Build / Architecture / Command Structure / Testing / Code Style / Error Handling. Drops sections absent in surveyed projects (Commit & PR Conventions, Who Uses This CLI) - Clean 14 internal doc refs (ADR-N, spec §X, v0.X) in source comments and docs that pointed at docs/superpowers/ — that directory is local-only / uncommitted, so refs are dead for outside readers - Drop forward-looking "once v0.2 ships" from README
32 lines
1.5 KiB
Go
32 lines
1.5 KiB
Go
// Package prompt defines the interactive-input abstraction. Production
|
|
// uses charmbracelet/huh (TTYPrompter) for password input; non-TTY
|
|
// contexts get AgentPrompter, which rejects every interactive call with
|
|
// ErrAgentNoPrompt so commands can map it to a typed missing-flag error.
|
|
package prompt
|
|
|
|
import "errors"
|
|
|
|
// ErrAgentNoPrompt is returned by any Prompter call made when the CLI is in
|
|
// agent / non-interactive mode. Commands should map this to a "missing flag"
|
|
// user error before returning to cobra.
|
|
var ErrAgentNoPrompt = errors.New("prompt: interactive input not available in agent/non-interactive mode")
|
|
|
|
// Prompter is the small abstraction the auth login flow needs. Tests inject
|
|
// scripted responses; production wires charmbracelet/huh.
|
|
type Prompter interface {
|
|
// Input collects free-form text input from the user.
|
|
Input(label, defaultValue string) (string, error)
|
|
// Password collects a secret without echoing.
|
|
Password(label string) (string, error)
|
|
// Confirm asks for yes/no confirmation, used by destructive commands.
|
|
Confirm(label string, defaultValue bool) (bool, error)
|
|
}
|
|
|
|
// AgentPrompter rejects all interactive calls. Use it as the Factory.Prompter
|
|
// closure result whenever agent mode is detected.
|
|
type AgentPrompter struct{}
|
|
|
|
func (AgentPrompter) Input(string, string) (string, error) { return "", ErrAgentNoPrompt }
|
|
func (AgentPrompter) Password(string) (string, error) { return "", ErrAgentNoPrompt }
|
|
func (AgentPrompter) Confirm(string, bool) (bool, error) { return false, ErrAgentNoPrompt }
|