Agent Sandbox Registry

agent-sandbox

Decision: Configurable CLI Shortcuts via config.toml

无中文版

.agents/notes/implemented/feature/2026-09-30-configurable-cli-shortcuts.md

Decision: Configurable CLI Shortcuts via config.toml

Status: implemented Implemented: 2026-09-30 Supersedes (partial): 2026-09-29-init-restore-and-create-explicit-error.md — the rejected alternative "Implement config.toml [shortcuts]" (lines 68–71 of that ADR) is reversed by an explicit project-lead decision. The original design sketch is .agents/design/2026-09-23-cli-final-design.md §2.2–§2.4. Related: 2026-09-30-shortcut-target-hint.md — an invalid target is explained in plain language, and a leading abx is answered with the command to retry.

Problem

Built-in top-level shortcuts (create, list, info, kill, exec, connect, run, upload, download, deploy, install, init) were hard-coded in the LazyGroup(lazy_subcommands=...) map in src/agent_sandbox/cli/main.py. Users had no supported way to add their own short aliases (e.g. abx ps for abx sandbox process list) or to see the shortcut set as configuration.

ADR 2026-09-29-init-restore-and-create-explicit-error.md rejected the config.toml [shortcuts] draft on the grounds that custom_commands and the SandboxServer registry already covered the extension need. That argument conflated two different layers:

There was therefore no user-facing mechanism at the CLI routing layer at all, while the demand for one (shorter names for deep subcommand paths) was real.

Decision

Implement user-configurable CLI command aliases in the [shortcuts] section of ~/.abx/config.toml. The project lead decided to proceed; the layering objection is resolved by scoping: shortcuts stay a pure CLI-routing concern and do not compete with in-sandbox named commands.

  1. Configuration format — [shortcuts] maps an alias name to a target command path (space-separated subcommand path):

```toml [shortcuts] # Factory defaults — every built-in top-level shortcut (see table below) create = "sandbox create" list = "sandbox list" # … install = "template install" init = "template init"

# User-defined aliases — any existing command path ps = "sandbox process list" sysinfo = "sandbox system info" files = "sandbox files list" ```

  1. Default aliases enabled out of the box — all existing top-level shortcuts are factory presets, so behaviour is unchanged without any config file:
Default alias Target
create sandbox create
list sandbox list
info sandbox info
kill sandbox kill
exec sandbox exec
connect sandbox connect
run sandbox run
upload sandbox upload
download sandbox download
deploy deploy
install template install
init template init
  1. Single-layer resolution — an alias resolves to exactly one existing command path. Aliases never chain to other aliases and never rewrite or inject arguments; everything after the alias name is passed through unchanged.

  2. Reserved commands cannot be overridden — the command group names (sandbox, template, config, mcp) and other reserved top-level names cannot be shadowed, redirected, or deleted by a [shortcuts] entry. A conflicting entry is reported and ignored rather than silently taking effect.

  3. Corrupt-config fallback — if ~/.abx/config.toml cannot be parsed (TOML syntax error, wrong value types), the CLI warns on stderr and disables all shortcuts for that session; the core command groups (sandbox / config / mcp / template) keep working, so a broken shortcuts config never bricks the CLI.

  4. config init generates a complete template — abx config init writes a full [shortcuts] block listing all available commands (ready to edit); abx config init --reset-shortcuts restores the factory defaults.

Management surface (documented in docs/*/reference/cli-reference.md):

abx config set shortcuts.<name> "<target>"   # add / modify an alias
abx config set shortcuts.<name> ""           # delete an alias
abx config get shortcuts                     # view all aliases
abx config init --reset-shortcuts            # reset shortcuts to defaults

Unknown-command hints (difflib Did you mean '…'?, cutoff 0.6; fallback pointing to custom_commands + abx run) keep working on the root group unchanged.

API Design

N/A — this decision does not involve SDK API changes. The surface is CLI-only:

Alternatives considered

Dependencies

Test Strategy

Consequences

Acceptance criteria