|
| 1 | +# Zoo Code CLI |
| 2 | + |
| 3 | +The `zoo` executable runs the production Zoo Code extension in a private supervised host. It does not contain a second agent loop. Existing `.roo`, `.roomodes`, `.rooignore`, `AGENTS.md`, rules, skills, custom tools, and MCP configuration keep their extension semantics. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +Zoo CLI requires Node.js 22.23.1. Supported release artifacts are macOS ARM64, Linux x64, and Linux ARM64. |
| 8 | + |
| 9 | +```sh |
| 10 | +npm install --global @zoo-code/cli |
| 11 | +zoo --version |
| 12 | +``` |
| 13 | + |
| 14 | +Platform tarballs contain `bin/zoo`; add that directory to `PATH`. Windows, macOS x64, Linux musl, and older CPU baseline packages are not currently supported. |
| 15 | + |
| 16 | +## Quick Start |
| 17 | + |
| 18 | +Start the interactive terminal UI in the current workspace: |
| 19 | + |
| 20 | +```sh |
| 21 | +zoo |
| 22 | +zoo "explain this repository" |
| 23 | +``` |
| 24 | + |
| 25 | +Run explicit automation: |
| 26 | + |
| 27 | +```sh |
| 28 | +zoo run "run the focused tests" --approval safe |
| 29 | +zoo run "summarize the project" --format json |
| 30 | +zoo run "fix the reported bug" --format stream-json > events.ndjson |
| 31 | +printf '%s\n' "review this workspace" | zoo run --format text |
| 32 | +``` |
| 33 | + |
| 34 | +Resume and inspect workspace-scoped history: |
| 35 | + |
| 36 | +```sh |
| 37 | +zoo sessions list |
| 38 | +zoo sessions list --format json -C ./project |
| 39 | +zoo resume |
| 40 | +zoo resume 019abc --format json |
| 41 | +``` |
| 42 | + |
| 43 | +Run `zoo --help`, `zoo run --help`, or `zoo resume --help` for live option reference. A positional prompt and piped prompt cannot be combined. Root `zoo` always requires TTY stdin and stdout; redirection never changes approval policy. |
| 44 | + |
| 45 | +## Selection And Credentials |
| 46 | + |
| 47 | +Run selections are invocation-local: |
| 48 | + |
| 49 | +```sh |
| 50 | +zoo run "investigate" --provider anthropic --model claude-sonnet-4-20250514 --mode debug |
| 51 | +zoo run "review" --profile work --reasoning-effort high |
| 52 | +``` |
| 53 | + |
| 54 | +`--provider` conflicts with `--profile`. Explicit invalid providers, profiles, models, modes, sessions, workspaces, and durations fail instead of falling back. |
| 55 | + |
| 56 | +Automation can read provider credentials from the provider's documented environment variable. Persisted credentials are accessed only through the operating-system vault adapter: macOS Keychain or Linux Secret Service. Secrets are never written to shim JSON, accepted as command-line flags, or included in events and diagnostics. Unsupported OAuth flows must be completed through a supported environment or vault setup. |
| 57 | + |
| 58 | +Precedence is invocation override, invocation environment credential, selected vault profile, canonical project configuration, CLI state, then product default. CLI state is under `~/.zoo`; VS Code and inherited Roo CLI storage are not imported implicitly. |
| 59 | + |
| 60 | +## Approvals And Threat Model |
| 61 | + |
| 62 | +| Mode | Use | Unresolved `ask` | |
| 63 | +| ------------- | ---------------------------- | -------------------------------------- | |
| 64 | +| `interactive` | TTY UI | Prompt the user | |
| 65 | +| `safe` | Default automation | Return resumable `needs_input`, exit 3 | |
| 66 | +| `auto` | Explicit unattended autonomy | Approve eligible asks only | |
| 67 | + |
| 68 | +`auto` is powerful and should only run in a workspace and account you trust. It never overrides explicit command denials, protected-file policy, outside-workspace restrictions, organization policy, destructive-command boundaries, mode restrictions, or MCP restrictions. Follow-up questions are not answered with invented text. |
| 69 | + |
| 70 | +Tool arguments, terminal output, MCP payloads, errors, debug diagnostics, and final content pass through bounded redaction before rendering. Project files cannot expand access beyond canonical trust boundaries. |
| 71 | + |
| 72 | +## Output Contracts |
| 73 | + |
| 74 | +### Text |
| 75 | + |
| 76 | +`--format text` is append-only and suitable for logs. It shows initialization, assistant/reasoning activity, tools, approvals, terminal and MCP activity, delegation, warnings, and the final result. `--quiet` emits only the final content or failure. |
| 77 | + |
| 78 | +### Final JSON |
| 79 | + |
| 80 | +`--format json` writes exactly one compact `zoo-run-result` object to stdout. Diagnostics go to stderr. Important fields are `schemaVersion`, `success`, `outcome`, root/current task IDs, workspace, resumability, content or stable error, usage/cost, elapsed time, and changed files. |
| 81 | + |
| 82 | +### Streaming JSON |
| 83 | + |
| 84 | +`--format stream-json` writes newline-delimited `zoo-stream` v1 records. The first record is `system.init`; each record has a monotonic `seq`, timestamp, and host identity. Deltas reconstruct ordered output. Exactly one authoritative-root `task.result` is terminal. stdout contains no ANSI or human diagnostics. `--quiet` is intentionally incompatible. |
| 85 | + |
| 86 | +Breaking machine-schema changes increment the major schema version. Additive optional fields retain it. Unknown visible activity is represented generically rather than silently discarded. |
| 87 | + |
| 88 | +## Outcomes And Exit Codes |
| 89 | + |
| 90 | +| Outcome | Exit | |
| 91 | +| ---------------------------------- | ---: | |
| 92 | +| Completed | 0 | |
| 93 | +| Usage or configuration | 2 | |
| 94 | +| Needs input | 3 | |
| 95 | +| Explicit cancellation | 4 | |
| 96 | +| Provider failure | 10 | |
| 97 | +| Runtime, host, or protocol failure | 70 | |
| 98 | +| Timeout | 124 | |
| 99 | +| SIGINT | 130 | |
| 100 | +| SIGTERM | 143 | |
| 101 | + |
| 102 | +Stable errors include invalid selection/workspace/session, missing credentials, permission denial, provider failure, host startup/crash, incompatible protocol, sequence gap, cancellation failure, cleanup timeout, task timeout, and closed output. |
| 103 | + |
| 104 | +## Sessions, Signals, And Ephemeral Runs |
| 105 | + |
| 106 | +Sessions are scoped to the canonical real path of `-C/--cwd`. `zoo resume` selects the latest root for that workspace; an ID must belong to the same workspace. Delegated histories retain root/current identity. |
| 107 | + |
| 108 | +The first Ctrl+C requests canonical cancellation and waits for interrupted history to settle. A second Ctrl+C escalates cleanup. SIGTERM follows bounded graceful cancellation. `--timeout 10m` is a parent-owned whole-invocation deadline covering startup, history, acceptance, execution, cancellation, flush, and shutdown. Broken stdout triggers cancellation without a stack trace. |
| 109 | + |
| 110 | +`--ephemeral` creates isolated temporary storage and removes it after success, error, signal, or timeout. Its session cannot be resumed after exit. It does not weaken project rules or approvals. |
| 111 | + |
| 112 | +## Supported And Unsupported Capabilities |
| 113 | + |
| 114 | +The CLI preserves canonical modes, rules, `.rooignore`, instructions, tools, MCP startup, histories, delegation, cancellation, terminal execution, and accepted root completion. Editor tabs, selections, decorations, diff UI, terminal panels, browser automation, and checkpoints are unavailable. The CLI does not expose config/profile mutation, auth management, MCP management, session mutation/import/export, cloud/daemon/remote control, worktrees, schedules, or a public long-lived stdin protocol. |
| 115 | + |
| 116 | +`modes list` and `models list` are also withheld in this release: the current canonical queries activate mutable extension services, so they do not yet meet the side-effect-free metadata requirement. |
| 117 | + |
| 118 | +## Coexistence With `roo` |
| 119 | + |
| 120 | +The inherited `roo` executable remains intact during migration. `zoo` uses `~/.zoo`; it does not read or mutate inherited CLI state. Project `.roo*` files remain canonical and are shared by design. No history or plaintext-secret migration occurs automatically. |
| 121 | + |
| 122 | +## Troubleshooting |
| 123 | + |
| 124 | +- Run `zoo --version` to report the client/build contract. |
| 125 | +- Use `--debug` for bounded redacted host diagnostics on stderr. |
| 126 | +- Verify the effective `-C` workspace when a session is not found. |
| 127 | +- A `needs_input` result is expected under safe approval; resume interactively to answer it. |
| 128 | +- A host/protocol failure exits 70 and never contaminates JSON stdout. |
| 129 | +- Timeout or signal cleanup is bounded; no host, shell, MCP, index, terminal, or watcher should survive. |
| 130 | +- If vault access fails, verify Keychain or Secret Service availability, or use an invocation environment credential. |
0 commit comments