Documentation
¶
Overview ¶
Package cli defines the suga command tree; cmd/suga only assembles and runs it.
Index ¶
- Constants
- Variables
- func ErrorText(err error, tr i18n.Translator) string
- func ExitCode(err error) int
- func New(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer, build Build) *capp.App
- func NewPersonalCommand(ctx context.Context, mode string, stdin io.Reader, stdout, stderr io.Writer) *capp.Cmd
- func NormalizeArgs(args []string) []string
- func RunArgs(app *capp.App, args []string) error
- func RunPersonalACP(ctx context.Context, input io.Reader, output io.Writer) error
- func RunPersonalCLI(ctx context.Context, mode string, args []string, stdin io.Reader, ...) error
- func RunPersonalChat(ctx context.Context, args []string) error
- func Translator() i18n.Translator
- type Build
Constants ¶
const ( LintDuplicate = "duplicate" // same text after normalization, or nearly the same LintConflict = "conflict" // same title, different content: the two may contradict each other LintStale = "stale" // not updated for a long time )
Candidate kinds reported by `suga memory lint`.
const ( LintActionMerge = "merge" LintActionDelete = "delete" LintActionReview = "review" )
Suggested actions attached to a candidate; the command never executes them.
const ( // DefaultVerifyRounds is how many fix rounds a failing check gets when // --verify-rounds is not given (the first check does not count). DefaultVerifyRounds = 2 // MaxVerifyRounds caps --verify-rounds: an unbounded loop would just burn // tokens on a command the model cannot fix. MaxVerifyRounds = 5 // DefaultVerifyTimeout bounds one verify command (--verify-timeout). DefaultVerifyTimeout = 10 * time.Minute )
The --verify delivery check (design docs/design/2026-10-21-run-verify-design.md): after a normally finished turn the caller's command decides whether the delivery is done; a failure is handed back to the model as an injected turn.
Variables ¶
var ErrInputRequired = errors.New("turn requires more input")
var ErrOutputContract = errors.New("回答不符合调用方的输出契约")
ErrOutputContract ends a run with exit code 6: after one correction round the answer still does not satisfy the caller's schema. It is kept apart from ErrVerifyFailed (5): "the delivery did not pass its check" is not the same failure as "the answer's shape is wrong".
var ErrVerifyFailed = errors.New("验证未通过")
ErrVerifyFailed ends a run with exit code 5: the --verify command never passed within --verify-rounds fix rounds. Its value stays the sentinel text: errors.Is answers it, machine lines keep reading it (verifyFailedError).
Functions ¶
func ErrorText ¶
func ErrorText(err error, tr i18n.Translator) string
ErrorText is the line text mode prints for err: the localized rendering when the error has one, else err.Error(). A nil translator keeps err.Error(), so a caller without a catalog never loses the message.
func ExitCode ¶
ExitCode maps a command error to the process exit code: the error's own ExitCode() when it has one, else 1.
func NewPersonalCommand ¶
func NewPersonalCommand(ctx context.Context, mode string, stdin io.Reader, stdout, stderr io.Writer) *capp.Cmd
NewPersonalCommand owns the flags and validation shared by direct CLI calls and the root command registry.
func NormalizeArgs ¶
NormalizeArgs turns an invocation whose first argument is a chat option into the explicit `suga chat …` form (design D6). Old top-level commands are left alone: they fail as unknown commands, see RunArgs.
func RunArgs ¶
RunArgs runs the command tree with args. A pre-v0.36 top-level command form (removed in v0.38) fails as an ordinary unknown command; the returned error then also names the new spelling, so the user is not left guessing.
func RunPersonalACP ¶
RunPersonalACP serves the same persistent personal runner used by CLI over stdio.
func RunPersonalCLI ¶
func RunPersonalCLI(ctx context.Context, mode string, args []string, stdin io.Reader, stdout, stderr io.Writer) error
RunPersonalCLI is the shared headless and interactive entry, independent of the old Web host.
func RunPersonalChat ¶
RunPersonalChat gives the terminal REPL the same persistent session engine as run mode.
func Translator ¶
func Translator() i18n.Translator
Translator resolves the startup language for the process itself: commands that do not assemble a wiring.Runtime and cmd/suga's closing error line use it.
Types ¶
Source Files
¶
- acp.go
- backup_restore.go
- chat.go
- compact.go
- config.go
- cwdcheck.go
- data_gc.go
- data_maintenance.go
- data_toolbody.go
- data_usage.go
- errors.go
- export.go
- gc_maintenance.go
- gc_spill.go
- i18n.go
- init.go
- legacy_args.go
- manifest.go
- memory.go
- memory_lint.go
- memory_lint_scan.go
- models.go
- nudge.go
- ps.go
- root.go
- rules_inspect.go
- run.go
- run_image.go
- schema.go
- send.go
- send_image.go
- sessions.go
- stats.go
- trace.go
- undo.go
- verify.go
- version.go