Agent Sandbox Registry

agent-sandbox

Decision: Plain-language hint for an invalid shortcut target

无中文版

.agents/notes/implemented/feature/2026-09-30-shortcut-target-hint.md

Decision: Plain-language hint for an invalid shortcut target

Status: implemented Implemented: 2026-09-30 Related: 2026-09-30-configurable-cli-shortcuts.md

Problem

abx config set shortcuts.<name> "<target>" stores a command path, not a full invocation. The first attempt is usually the command the user already types, including the abx prefix:

abx config set shortcuts.aaaaa "abx template init"

The rejection was a single comma-separated list of every legal target. It did not say why "abx template init" was wrong, so the corrected form ("template init") had to be inferred from the list. The unknown-command hint made the same mistake: it told the user to pass "<target>" without showing a path that omits abx.

Decision

The target stays a command path. A value that starts with abx is still rejected; the message names the mistake and, when the remainder is a real target, prints the command to copy.

Invalid shortcut target: 'abx template init'
  Suggestion: Drop the leading "abx". The target is the command path only, for example "template init".
              Try: abx config set shortcuts.aaaaa "template init"

Rules, implemented by _describe_invalid_shortcut_target in src/agent_sandbox/cli/main.py:

  1. Collapse internal whitespace, then treat a first token of abx (any case) as the prefix to drop.
  2. If what remains is in _SHORTCUT_TARGET_MAP, the hint is only the rule plus Try: abx config set shortcuts.<alias> "<path>". The full target list is omitted.
  3. Otherwise the hint states the same rule (and, when a prefix was present, that the remainder is still not a path) and lists targets grouped by their first word: deploy, sandbox: connect, create, …, template: build, init, ….
  4. Text mode indents the continuation under Suggestion:. JSON keeps the unindented hint in suggestion.
  5. A shortcut already stored with a bad target (including a leading abx) gets the same explanation on stderr at startup and is ignored.
  6. The unknown-command hint uses a concrete example with no prefix: abx config set shortcuts.NAME "template init".

The value is not rewritten in place. The file changes only when the user sets a path the map accepts.

API Design

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

_describe_invalid_shortcut_target(target: str, *, alias: str | None = None) -> str

abx config set prints that text as the error suggestion. LazyGroup prints it under the existing "Invalid shortcut ignored" warning when a stored target cannot be loaded.

Alternatives considered

Dependencies

src/agent_sandbox/cli/main.py (_SHORTCUT_TARGET_MAP, LazyGroup) and src/agent_sandbox/cli/commands/config_cmd.py (_set_shortcut). No new packages.

Test Strategy

The user-facing copy is the CLI tutorial, the CLI reference, the configuration reference, troubleshooting, and the CLI design doc (English and Chinese).

Acceptance criteria

Files changed