Skip to content

Commit ea1f06a

Browse files
committed
feat(cli): add autonomous orchestrator draft
1 parent 1ceb4e6 commit ea1f06a

22 files changed

Lines changed: 1153 additions & 120 deletions

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ Prefer the narrowest test layer that proves the behavior. This follows standard
1515
- Use `apps/vscode-e2e` only when the behavior depends on the real VS Code extension host, VS Code workspace APIs, extension activation, webview/extension messaging, file watcher behavior, or a complete user workflow.
1616
- Keep e2e tests focused on high-value smoke coverage across boundaries. Avoid placing detailed protocol, parsing, storage, retry, or edge-case assertions in e2e when they can be covered reliably at a lower layer.
1717
- When fixing a regression, add the regression test at the lowest layer that would have failed for the bug. Add an e2e test only if lower-level tests cannot represent the failure mode.
18+
19+
## Maintaining this file
20+
21+
Keep this file for knowledge useful to almost every future agent session in this project.
22+
Do not repeat what the codebase already shows; point to the authoritative file or command instead.
23+
Prefer rewriting or pruning existing entries over appending new ones.
24+
When updating this file, preserve this bar for all agents and keep entries concise.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

apps/cli/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,68 @@ roo --print "Summarize this repository"
118118
roo --print --create-with-session-id 018f7fc8-7c96-7f7c-98aa-2ec4ff7f6d87 "Summarize this repository"
119119
```
120120

121+
### Autonomous Orchestrator Draft (`--autonomous`)
122+
123+
> **Danger:** This profile gives the agent unrestricted authority to read and write inside or outside the workspace, modify protected configuration, execute any command, call any configured MCP tool, switch child modes, create subtasks, and accept completion. Run it only in an environment where the selected workspace, configuration, commands, MCP servers, and provider are fully trusted. It does not change VS Code or normal interactive CLI approval behavior.
124+
125+
Every new autonomous root starts in the effective `orchestrator` mode. A project `.roomodes` definition with the `orchestrator` slug overrides the global custom definition, which overrides the built-in definition, following normal Zoo Code precedence. `--mode` and `--require-approval` are rejected for autonomous roots. Child mode selection remains available to the existing `new_task` engine.
126+
127+
```bash
128+
export OPENROUTER_API_KEY=sk-or-v1-...
129+
130+
roo --autonomous --print \
131+
--workspace /absolute/path/to/project \
132+
--timeout 3600 \
133+
--output-format stream-json \
134+
"Implement the task and verify it"
135+
```
136+
137+
`--workspace` and `--timeout` are required. The workspace is resolved to its canonical filesystem path before activation. One process owns one root task tree; stdin multi-root stream mode is intentionally unavailable with this profile.
138+
139+
The real extension bundle remains the agent engine:
140+
141+
- `switch_mode` changes the mode in the same task and preserves its conversation.
142+
- `new_task` persists the parent and creates a fresh child context.
143+
- Child completion resumes the original parent with the child result and does not exit the process.
144+
- Only an accepted `attempt_completion` event for the root task exits successfully. No implicit validation command is added.
145+
- `--session-id` and `--continue` use persisted task history. A resumed task retains its persisted mode and context; a newly created autonomous root always starts as Orchestrator.
146+
- The first `SIGINT` or `SIGTERM` cooperatively aborts and settles persistence. A second signal force-terminates.
147+
148+
#### Portable Configuration
149+
150+
The selected workspace is used by the existing runtime to load `.roomodes`, `.roo/mcp.json`, `.roo/rules*`, legacy rule fallbacks, and root `AGENTS.md`/`AGENT.md` plus `AGENTS.local.md`. Global rules remain under `~/.roo/rules*`. Shim-backed global custom modes and MCP settings use `~/.vscode-mock/global-storage/settings/custom_modes.yaml` and `~/.vscode-mock/global-storage/settings/mcp_settings.json`; project definitions take precedence where Zoo Code normally gives them precedence. Configuration is loaded before the first task starts. Long-running file-watcher reloads are not supported by the shim, so restart the process after changing these files.
151+
152+
Credentials must be supplied with `--api-key` or the provider environment variable. This standalone process does not inspect or import native VS Code settings databases, profiles, OAuth state, or encrypted `SecretStorage`. Its own persisted history and shim state can contain sensitive prompts, outputs, and settings and should be protected accordingly.
153+
154+
#### Headless Capability Boundary
155+
156+
Headless filesystem reads/writes, protected-file edits, command execution through Execa, ripgrep search, configured MCP transports, mode switching, subtasks, persistence, and provider HTTP streams are supported. There is no interactive VS Code window. Editor selections/tabs, live diagnostics, visual diff UI, VS Code terminal shell integration, VS Code Language Models, native VS Code authentication/URI callbacks, clipboard UI, and reliable VS Code file-watcher semantics are unsupported. Required questions without a defined automatic answer terminate instead of selecting a suggestion or sending an empty answer.
157+
158+
#### Terminal Outcomes
159+
160+
Machine-readable modes emit exactly one final `result` with `subtype: "terminal"`, `state`, `exitCode`, and the root task ID when available. Progress remains NDJSON in `stream-json`; extension debug logs do not go to stdout.
161+
162+
| State | Exit | Meaning |
163+
| --------------------- | ---: | ----------------------------------------------------------- |
164+
| `completed` | 0 | Accepted root completion after descendant resumption |
165+
| `needs_input` | 2 | A question has no defined autonomous answer |
166+
| `provider_failed` | 4 | Provider request failed or retry would require intervention |
167+
| `tool_failed` | 5 | A host/tool failure prevents continuation |
168+
| `cancelled` | 6 | Explicit non-signal cancellation |
169+
| `cancelled` | 130 | `SIGINT` after cooperative persistence settlement |
170+
| `cancelled` | 143 | `SIGTERM` after cooperative persistence settlement |
171+
| `timed_out` | 124 | Root-tree wall-clock timeout |
172+
| `configuration_error` | 78 | Invalid workspace, flags, credentials, or configuration |
173+
| `crashed` | 70 | Unexpected internal failure |
174+
175+
The non-billable process smoke starts a local fake OpenRouter-compatible server and disposable workspaces. It verifies custom Orchestrator/rule precedence, mode switching, delegation/resumption, questions, provider failure, timeout, cancellation, and parseable terminal output:
176+
177+
```bash
178+
pnpm --filter ./src bundle
179+
pnpm --filter @roo-code/cli build
180+
pnpm --filter @roo-code/cli test:autonomous-process
181+
```
182+
121183
### Stdin Stream Mode (`--stdin-prompt-stream`)
122184

123185
For programmatic control (one process, multiple prompts), use `--stdin-prompt-stream` with `--print`.
@@ -159,8 +221,11 @@ If you never used Roo Code Router, you can ignore this section entirely.
159221
| `-e, --extension <path>` | Path to the extension bundle directory | Auto-detected |
160222
| `-d, --debug` | Enable debug output (includes detailed debug information, prompts, paths, etc) | `false` |
161223
| `-a, --require-approval` | Require manual approval before actions execute | `false` |
224+
| `--autonomous` | Dangerous unrestricted headless Orchestrator profile (requires `--print`) | `false` |
225+
| `--timeout <seconds>` | Required wall-clock deadline for an autonomous root tree | None |
162226
| `-k, --api-key <key>` | API key for the LLM provider | From env var |
163227
| `--provider <provider>` | API provider (anthropic, openai-native, gemini, openrouter, vercel-ai-gateway) | `openrouter` |
228+
| `--provider-base-url <url>` | OpenRouter-compatible endpoint override | Provider default |
164229
| `-m, --model <model>` | Model to use | `anthropic/claude-opus-4.6` |
165230
| `--mode <mode>` | Mode to start in (code, architect, ask, debug, etc.) | `code` |
166231
| `--terminal-shell <path>` | Absolute shell path for inline terminal command execution | Auto-detected shell |

apps/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"test": "vitest run",
1616
"test:coverage": "vitest run --coverage",
1717
"test:integration": "tsx scripts/integration/run.ts",
18+
"test:autonomous-process": "tsx scripts/autonomous-smoke.ts",
1819
"build": "tsup",
1920
"build:extension": "pnpm --filter ./src bundle",
2021
"dev": "ROO_AUTH_BASE_URL=https://app.roocode.com ROO_SDK_BASE_URL=https://cloud-api.roocode.com ROO_CODE_PROVIDER_URL=https://api.roocode.com/proxy tsx src/index.ts",

0 commit comments

Comments
 (0)