Agent Sandbox Registry

agent-sandbox

Decision: Restore the top-level abx init shortcut, make bare abx create an explicit error, and add unknown-command hints

无中文版

.agents/notes/implemented/feature/2026-09-29-init-restore-and-create-explicit-error.md

Decision: Restore the top-level abx init shortcut, make bare abx create an explicit error, and add unknown-command hints

Status: implemented Implemented: 2026-09-29 Supersedes (partial): 2026-09-29-init-create-semantics.md — decision item 1 (delete abx init) is reversed; the create routing row "abx create → base template, direct create" is replaced by an explicit usage error.

Problem

The earlier init/create convergence (ADR 2026-09-29-init-create-semantics.md) removed the top-level abx init alias and let bare abx create silently launch the base template. Follow-up review (tasks 206/210/211/218) surfaced three issues:

  1. The alias removal hurt real usage patterns. abx init maps naturally to "scaffold my project", the most common first action after install. The alias costs nothing (it is the same click command object) and its earlier confusion is better solved by help text than by removal.
  2. Bare abx create still silently chose a path. The convergence made DESCRIPTION + --template explicit but kept the implicit base default for the no-argument case — inconsistent with the fail-loud convention.
  3. Unknown top-level commands gave no guidance. Typos produced a bare No such command 'x'., and users who expected abx <their-command> to work (template custom_commands, SandboxServer registry commands) were not pointed at abx run.

Decision

  1. Restore the top-level abx init shortcut.
  2. src/agent_sandbox/cli/main.py: register "init": "agent_sandbox.cli.commands.template:init" in lazy_subcommands.
  3. It is the same command object as abx template init — option surface, TTY picker, and scaffolding logic are shared; nothing is duplicated.
  4. The three entry points stay distinct: abx config init (credentials), abx create (cloud sandbox), abx init / abx template init (scaffold).

  5. Bare abx create is now an explicit usage error (exit code 2) listing the three valid routes: --template base, --template <NAME>, "<DESCRIPTION>". No config read, AI generation, or network call happens.

  6. Unknown top-level commands get targeted hints (root group only): difflib.get_close_matches (cutoff 0.6) over root commands yields a Did you mean '…'? suggestion; with no plausible candidate the error points to template custom_commands (declared in template.yaml) invoked via abx run COMMAND. Click UsageError semantics are preserved: exit code 2, message on stderr; nested groups keep the stock message.

  7. Registration semantics clarified (docs, not code change):

  8. The LazyGroup(lazy_subcommands=...) map in main.py is the project-maintainer registration point for built-in top-level shortcuts. It is not a user-facing extension mechanism.
  9. User-defined commands live in template.yaml custom_commands or the SandboxServer @registry.command registry and run via abx run.
  10. The config.toml [shortcuts] section from the original CLI design draft (.agents/design/2026-09-23-cli-final-design.md §2.2) was never implemented; it must not be described as a current capability.

  11. Evidence / docs sync: error-init-removed evidence case replaced by error-create-noargs, error-unknown-suggestion, error-unknown-custom-hint, and help-init-alias; golden snapshots and .agents/evidence/cli/* regenerated; cli-reference, cli-design, cli-tutorial (incl. new bilingual "top-level shortcuts vs custom commands" advanced-usage section), e2e-template-workflow and CHANGELOG updated (en+zh).

Alternatives considered

Dependencies

Test Strategy

Files changed

Acceptance criteria