@andorra-labs/code 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/account-presentation.js +3 -3
- package/dist/src/agent-execution.d.ts +2 -0
- package/dist/src/agent-execution.js +526 -41
- package/dist/src/agent-mcp-catalog.d.ts +21 -0
- package/dist/src/agent-mcp-catalog.js +40 -0
- package/dist/src/agent-mcp.d.ts +36 -3
- package/dist/src/agent-mcp.js +114 -45
- package/dist/src/app-server/protocol.d.ts +57 -5
- package/dist/src/app-server/protocol.js +18 -1
- package/dist/src/app-server/workspace.d.ts +9 -1
- package/dist/src/app-server/workspace.js +50 -3
- package/dist/src/app-server.d.ts +115 -41
- package/dist/src/app-server.js +1316 -221
- package/dist/src/auth/AuthManager.d.ts +33 -1
- package/dist/src/auth/AuthManager.js +138 -10
- package/dist/src/auth/callback-page.d.ts +4 -0
- package/dist/src/auth/callback-page.js +70 -0
- package/dist/src/auth/callback.d.ts +39 -0
- package/dist/src/auth/callback.js +146 -22
- package/dist/src/auth/index.d.ts +10 -6
- package/dist/src/auth/index.js +2 -2
- package/dist/src/auth/store.d.ts +142 -3
- package/dist/src/auth/store.js +334 -13
- package/dist/src/auth/types.d.ts +17 -1
- package/dist/src/auth-commands.d.ts +11 -2
- package/dist/src/auth-commands.js +14 -7
- package/dist/src/automation-runner.d.ts +9 -0
- package/dist/src/automation-runner.js +22 -1
- package/dist/src/automation-tool.js +18 -3
- package/dist/src/automations.d.ts +5 -0
- package/dist/src/automations.js +11 -1
- package/dist/src/browser-captcha-tool.d.ts +54 -0
- package/dist/src/browser-captcha-tool.js +374 -0
- package/dist/src/browser-panel-tool.d.ts +7 -0
- package/dist/src/browser-panel-tool.js +74 -3
- package/dist/src/browser-runner.js +19 -4
- package/dist/src/browser-server.js +21 -1
- package/dist/src/browser-session.d.ts +16 -0
- package/dist/src/browser-session.js +35 -0
- package/dist/src/browser-ui/app.js +193 -3
- package/dist/src/browser-ui/style.css +15 -1
- package/dist/src/browser-view.d.ts +72 -4
- package/dist/src/browser-view.js +229 -17
- package/dist/src/capabilities.d.ts +9 -3
- package/dist/src/capabilities.js +20 -5
- package/dist/src/capsolver.d.ts +60 -0
- package/dist/src/capsolver.js +101 -0
- package/dist/src/claude-provider.d.ts +6 -0
- package/dist/src/claude-provider.js +34 -3
- package/dist/src/cli-executable.d.ts +33 -0
- package/dist/src/cli-executable.js +64 -0
- package/dist/src/cli-process.d.ts +47 -0
- package/dist/src/cli-process.js +113 -0
- package/dist/src/cli-sign-in.d.ts +68 -0
- package/dist/src/cli-sign-in.js +224 -0
- package/dist/src/cli.js +84 -26
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
- package/dist/src/codex-provider.js +12 -0
- package/dist/src/coding-tools.d.ts +5 -0
- package/dist/src/coding-tools.js +98 -53
- package/dist/src/command-output-tap.d.ts +16 -0
- package/dist/src/command-output-tap.js +45 -0
- package/dist/src/command-screens.js +3 -3
- package/dist/src/commands.d.ts +15 -2
- package/dist/src/commands.js +14 -13
- package/dist/src/completion.d.ts +23 -5
- package/dist/src/completion.js +380 -17
- package/dist/src/config.d.ts +61 -0
- package/dist/src/config.js +276 -12
- package/dist/src/context-budget.d.ts +7 -0
- package/dist/src/context-budget.js +18 -1
- package/dist/src/deadline.js +6 -0
- package/dist/src/decision/FactContinuations.d.ts +41 -6
- package/dist/src/decision/FactContinuations.js +211 -64
- package/dist/src/decision/PreparedSteps.js +3 -1
- package/dist/src/decision/checks.d.ts +25 -0
- package/dist/src/decision/checks.js +77 -6
- package/dist/src/delegation-changes.d.ts +109 -0
- package/dist/src/delegation-changes.js +431 -0
- package/dist/src/extensions.d.ts +1 -0
- package/dist/src/extensions.js +16 -3
- package/dist/src/graph-provider-portability.js +2 -2
- package/dist/src/graph-quota.d.ts +1 -1
- package/dist/src/graph-quota.js +1 -1
- package/dist/src/graph-runner.js +35 -21
- package/dist/src/graph-selection.d.ts +6 -0
- package/dist/src/graph-selection.js +10 -0
- package/dist/src/graph-server.d.ts +8 -0
- package/dist/src/graph-server.js +76 -6
- package/dist/src/graph-sync.d.ts +65 -0
- package/dist/src/graph-sync.js +433 -13
- package/dist/src/graph-tool.d.ts +52 -0
- package/dist/src/graph-tool.js +136 -0
- package/dist/src/graph-ui/app.js +272 -50
- package/dist/src/graph-ui/controls.js +6 -0
- package/dist/src/graph-ui/drafts.js +39 -0
- package/dist/src/graph-ui/embed.js +1 -1
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/skill-picker.js +242 -0
- package/dist/src/graph-ui/studio.css +7 -5
- package/dist/src/graph-ui/style.css +65 -12
- package/dist/src/graphs.d.ts +60 -5
- package/dist/src/graphs.js +191 -37
- package/dist/src/grok-provider.d.ts +50 -0
- package/dist/src/grok-provider.js +186 -0
- package/dist/src/handoffs.d.ts +13 -0
- package/dist/src/handoffs.js +31 -1
- package/dist/src/hardened-runtime.d.ts +4 -4
- package/dist/src/hardened-runtime.js +109 -9
- package/dist/src/managed-sign-in.d.ts +38 -0
- package/dist/src/managed-sign-in.js +169 -0
- package/dist/src/markdown.d.ts +5 -0
- package/dist/src/markdown.js +5 -2
- package/dist/src/mcp.js +11 -0
- package/dist/src/membership.d.ts +8 -1
- package/dist/src/membership.js +15 -5
- package/dist/src/model-metadata.js +14 -2
- package/dist/src/model-override.d.ts +10 -0
- package/dist/src/model-override.js +20 -0
- package/dist/src/opencode-cli-provider.d.ts +122 -0
- package/dist/src/opencode-cli-provider.js +415 -0
- package/dist/src/opencode-provider.js +23 -8
- package/dist/src/palette.d.ts +2 -0
- package/dist/src/palette.js +2 -0
- package/dist/src/permissions.d.ts +19 -1
- package/dist/src/permissions.js +30 -1
- package/dist/src/powershell-pool.d.ts +11 -2
- package/dist/src/powershell-pool.js +34 -5
- package/dist/src/provider-connection.js +36 -0
- package/dist/src/provider-engine.d.ts +2 -1
- package/dist/src/provider-engine.js +64 -13
- package/dist/src/provider-import.js +6 -1
- package/dist/src/provider-keys.d.ts +48 -0
- package/dist/src/provider-keys.js +121 -0
- package/dist/src/provider-settings.js +22 -3
- package/dist/src/providers.d.ts +12 -1
- package/dist/src/providers.js +27 -8
- package/dist/src/pull-requests.d.ts +123 -20
- package/dist/src/pull-requests.js +334 -84
- package/dist/src/qa/qa-authorize.js +9 -1
- package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
- package/dist/src/qa/runtime/ProcessManager.js +16 -0
- package/dist/src/react-runtime.js +106 -7
- package/dist/src/read-image.d.ts +30 -0
- package/dist/src/read-image.js +97 -0
- package/dist/src/remote/engine-pool.js +1 -1
- package/dist/src/run-progress.js +6 -1
- package/dist/src/run-records.d.ts +133 -27
- package/dist/src/run-records.js +320 -40
- package/dist/src/runtime.d.ts +38 -1
- package/dist/src/runtime.js +27 -4
- package/dist/src/save-lock.d.ts +11 -0
- package/dist/src/save-lock.js +29 -2
- package/dist/src/secret-redaction.d.ts +13 -0
- package/dist/src/secret-redaction.js +71 -0
- package/dist/src/session-summary.d.ts +10 -4
- package/dist/src/session-summary.js +14 -7
- package/dist/src/sessions.js +8 -2
- package/dist/src/shell.js +4 -1
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +1 -1
- package/dist/src/skill-commands.d.ts +2 -0
- package/dist/src/skill-commands.js +2 -0
- package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
- package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +100 -0
- package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
- package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
- package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
- package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
- package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
- package/dist/src/skills/bundled/provenance.json +50 -0
- package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
- package/dist/src/skills/invocable-skills.d.ts +41 -0
- package/dist/src/skills/invocable-skills.js +49 -0
- package/dist/src/skills/prompt-skills.d.ts +1 -0
- package/dist/src/skills/prompt-skills.js +33 -0
- package/dist/src/skills/runtime-skills.d.ts +4 -0
- package/dist/src/skills/runtime-skills.js +21 -0
- package/dist/src/structured-step.d.ts +55 -0
- package/dist/src/structured-step.js +85 -0
- package/dist/src/subagent-run.d.ts +1 -1
- package/dist/src/subagent-run.js +29 -33
- package/dist/src/telemetry/schema.d.ts +2 -2
- package/dist/src/telemetry/schema.js +3 -2
- package/dist/src/terminal-ui.d.ts +38 -0
- package/dist/src/terminal-ui.js +126 -28
- package/dist/src/timers.d.ts +21 -2
- package/dist/src/timers.js +12 -4
- package/dist/src/tool-dependencies.js +4 -0
- package/dist/src/tool-names.d.ts +18 -0
- package/dist/src/tool-names.js +26 -0
- package/dist/src/tools.d.ts +9 -0
- package/dist/src/tools.js +159 -20
- package/dist/src/trajectory.js +32 -12
- package/dist/src/transcript.js +5 -0
- package/dist/src/types.d.ts +36 -0
- package/dist/src/web-search.d.ts +59 -0
- package/dist/src/web-search.js +216 -0
- package/docs/agents/README.md +2 -2
- package/docs/agents/mcp-server.md +28 -3
- package/docs/agents/subagent-mode.md +7 -4
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/security.md +4 -2
- package/docs/getting-started/accounts.md +15 -4
- package/docs/getting-started/configure-providers.md +30 -3
- package/docs/guides/README.md +1 -0
- package/docs/guides/browser.md +12 -0
- package/docs/guides/desktop-app.md +11 -4
- package/docs/guides/graph-builder.md +9 -1
- package/docs/guides/web-search.md +47 -0
- package/docs/reference/cli.md +4 -3
- package/docs/reference/config.md +4 -4
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
- package/package.json +1 -1
- package/tests/permissions-test-plan.md +2 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Web search
|
|
2
|
+
|
|
3
|
+
Agents can search the web with the built-in `web_search` tool. It sends one query to a search service you choose and returns up to 10 results: the title, the URL and a short snippet for each. To read a page in full, the agent then opens the result with a browser tool.
|
|
4
|
+
|
|
5
|
+
Andorra does not run a search index of its own, so the tool needs one of these services:
|
|
6
|
+
|
|
7
|
+
| Service | What you enter | Environment fallback |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| [Brave Search](https://brave.com/search/api/) | API key | `BRAVE_API_KEY` |
|
|
10
|
+
| [Tavily](https://tavily.com/) | API key (`tvly-…`) | `TAVILY_API_KEY` |
|
|
11
|
+
| [Exa](https://exa.ai/) | API key | `EXA_API_KEY` |
|
|
12
|
+
| [Serper](https://serper.dev/) (Google results) | API key | `SERPER_API_KEY` |
|
|
13
|
+
| [Google Programmable Search](https://developers.google.com/custom-search/v1/overview) | API key and search engine ID (`cx`) | `GOOGLE_SEARCH_API_KEY`, `GOOGLE_SEARCH_ENGINE_ID` |
|
|
14
|
+
| [SearXNG](https://docs.searxng.org/) | Instance URL, such as `http://localhost:8080` | `SEARXNG_URL` |
|
|
15
|
+
|
|
16
|
+
The keyed services have their own sign-up, free allowance and pricing. SearXNG is free and needs no key, but you have to run an instance yourself, for example with the `searxng/searxng` Docker image. It also has to allow JSON output: add `json` to `search.formats` in its `settings.yml`. Otherwise it answers HTTP 403, and the tool says so.
|
|
17
|
+
|
|
18
|
+
## Configure it
|
|
19
|
+
|
|
20
|
+
In the desktop app, open **Settings → Web Search**:
|
|
21
|
+
|
|
22
|
+
- **Search with** picks the default service. **Automatic** uses the first configured service, in the order of the table above. If you choose a service that is not configured, searches fail with a message saying so. They do not quietly switch to another service.
|
|
23
|
+
- Under **Search services**, paste a key and choose **Save**. A saved key is never shown again. To change it, paste a new one and choose **Replace**; to delete it, choose **Remove**. The Google search engine ID and the SearXNG URL are not secrets, so they stay visible and you can edit them.
|
|
24
|
+
|
|
25
|
+
Each row shows which value is in use: the saved one, or the environment variable when nothing is saved. A saved value always wins over the environment.
|
|
26
|
+
|
|
27
|
+
Without the desktop app, edit `~/.andorracode/config.json` (or `$ANDORRACODE_HOME/config.json`):
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"webSearch": {
|
|
32
|
+
"defaultProvider": "brave",
|
|
33
|
+
"braveApiKey": "<key>",
|
|
34
|
+
"searxngUrl": "http://localhost:8080"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The fields are `defaultProvider` (`brave`, `tavily`, `exa`, `serper`, `google` or `searxng`), `braveApiKey`, `tavilyApiKey`, `exaApiKey`, `serperApiKey`, `googleApiKey`, `googleSearchEngineId` and `searxngUrl`. Keys are kept in the configuration file, like the CapSolver key and provider keys.
|
|
40
|
+
|
|
41
|
+
## Who can use it
|
|
42
|
+
|
|
43
|
+
`web_search` is in the `web` tool family and follows the node's **browser** capability: an agent or subagent role with the browser disabled does not get it. It is read-only, so it needs no approval, and it also works in Plan mode. With Jev on, the tool catalog offers it only to tasks that mention the web, documentation, URLs or looking something up.
|
|
44
|
+
|
|
45
|
+
## Privacy
|
|
46
|
+
|
|
47
|
+
Every query goes to the service you configured, under that service's privacy policy. The key goes only in the request to that service. It never appears in the tool's output, in error messages, or in what the engine reports to the desktop app.
|
package/docs/reference/cli.md
CHANGED
|
@@ -20,8 +20,8 @@ andorra remote serve [--port N] [--insecure-http] [--rotate-cert]
|
|
|
20
20
|
andorra remote workspaces | andorra remote unpair <workspace-id>
|
|
21
21
|
andorra remote rotate-cert
|
|
22
22
|
andorra update [--break-lock]
|
|
23
|
-
andorra login
|
|
24
|
-
andorra logout
|
|
23
|
+
andorra login [--no-browser]
|
|
24
|
+
andorra logout [--all]
|
|
25
25
|
andorra auth status
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -55,8 +55,9 @@ andorra auth status
|
|
|
55
55
|
| `andorra app-server --stdio` | Run the JSON-lines app server that drives the desktop client. Not for humans; see [Desktop client](../guides/desktop-app.md). |
|
|
56
56
|
| `andorra remote <subcommand>` | Remote workspace pairing and sharing — `serve`, `status`, `code`, `devices`, `revoke <device-id>`, `share <path>`, `unshare <share-id>`, `pair <pairing-code>`, `workspaces`, `unpair <workspace-id>`, `rotate-cert`, with the flags shown in the usage above. See [Remote workspace](../guides/desktop-app.md#remote-workspace). |
|
|
57
57
|
| `andorra update [--break-lock]` | Install the latest npm release of `@andorra-labs/code` into the global npm installation; a source checkout is refused. `--break-lock` replaces a leftover updater lock; see [Update](../guides/update.md#an-interrupted-update). |
|
|
58
|
-
| `andorra login` | Open the browser to sign in to (or create) an Andorra account. |
|
|
58
|
+
| `andorra login [--no-browser]` | Open the browser to sign in to (or create) an Andorra account. Over SSH, without a display, or with `--no-browser`, it prints the address to open on another device and accepts the callback address pasted back (or an `ssh -L 43187:localhost:43187` forward). |
|
|
59
59
|
| `andorra logout` | Remove this machine's saved Andorra account session and revoke its refresh token. |
|
|
60
|
+
| `andorra logout --all` | Also delete every other Andorra sign-in saved in this machine's OS credential store (other `ANDORRACODE_HOME`s, other deployments), revoking their refresh tokens where the account service accepts it. Saved provider API keys are not touched. |
|
|
60
61
|
| `andorra auth status` | Show the saved Andorra account session and membership. |
|
|
61
62
|
|
|
62
63
|
## Headless exit codes
|
package/docs/reference/config.md
CHANGED
|
@@ -41,11 +41,11 @@ One exception to the configuration home: **trajectory journals** — the detaile
|
|
|
41
41
|
}
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Provider entries support `id`, `type` (`openai-compatible` \| `anthropic` \| `codex` \| `claude` \| `opencode-go`), `baseUrl`, `apiKey` (
|
|
44
|
+
Provider entries support `id`, `type` (`openai-compatible` \| `anthropic` \| `codex` \| `claude` \| `grok` \| `opencode` \| `opencode-go`), `baseUrl`, `apiKey` (kept in the OS credential store, with `"providerKeys": "keyring"` in the file; plaintext in the file only without a credential store or with `ANDORRA_CREDENTIAL_STORE=file`), `apiKeyEnv` (a saved key takes precedence), `model`, `models[]`, and `modelContextWindows` (a map from model id to its token limit, used when the endpoint does not report one), plus per-provider HTTP request bounds `requestTimeoutMs` and `streamIdleTimeoutMs`.
|
|
45
45
|
|
|
46
46
|
An `anthropic` provider may set `anthropicAuth: "console"` to authenticate with the Claude Console login that `ant auth login` stored in `<config home>/anthropic-accounts/<provider id>` instead of an API key. Such a provider must use `baseUrl: "https://api.anthropic.com/v1"` and may not carry `apiKey` or `apiKeyEnv`; two signed-in providers may not have ids that differ only by case. See [Configure providers](../getting-started/configure-providers.md#claude-console-sign-in).
|
|
47
47
|
|
|
48
|
-
`claude` uses the installed Claude Code CLI's managed subscription sign-in, with fixed `baseUrl: "https://api.anthropic.com"`. Like `codex`, it rejects API keys, environment-key overrides, and HTTP timeout fields. `opencode-go` uses `baseUrl: "https://opencode.ai/inference/go"` and selects each model's supported API automatically. Other endpoints retain their existing protocol behavior.
|
|
48
|
+
`claude` uses the installed Claude Code CLI's managed subscription sign-in, with fixed `baseUrl: "https://api.anthropic.com"`. Like `codex`, it rejects API keys, environment-key overrides, and HTTP timeout fields. `grok` uses the installed Grok CLI's sign-in, with fixed `baseUrl: "https://api.x.ai"`; `opencode` uses the installed OpenCode CLI's connected providers, with fixed `baseUrl: "https://opencode.ai"` and every model named `provider/model`. Both reject API keys, environment-key overrides, and HTTP timeout fields, like `codex` and `claude`. `opencode-go` uses `baseUrl: "https://opencode.ai/inference/go"` and selects each model's supported API automatically. Other endpoints retain their existing protocol behavior.
|
|
49
49
|
|
|
50
50
|
OpenAI-compatible and OpenCode Go entries also accept `reasoningEffort` (`none`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`). Omitting it uses the provider default. Go checks the selected level against the model's verified catalog options before inference.
|
|
51
51
|
|
|
@@ -80,6 +80,6 @@ On Windows, automatic Codex provider discovery checks `%LOCALAPPDATA%\Programs\O
|
|
|
80
80
|
|
|
81
81
|
## Security notes
|
|
82
82
|
|
|
83
|
-
- Saved API keys are
|
|
83
|
+
- Saved API keys are kept in the operating system credential store, one entry per provider in each Andorra home, and read back when the configuration loads; `config.json` holds `"providerKeys": "keyring"` in their place. Moving or copying the Andorra home does not carry the keys: save them again there. When a removed key cannot be deleted from the store (it is locked), `config.json` lists its provider in `providerKeysPendingDeletion` and the next save deletes it. Without a credential store (Linux without Secret Service) or with `ANDORRA_CREDENTIAL_STORE=file`, keys stay in `config.json`; keep the file private and do not commit or share it.
|
|
84
84
|
- Shell tools execute as your OS user with an allowlisted environment that excludes provider credential variables — but shell commands can still access credential files on disk.
|
|
85
|
-
- Andorra account tokens are stored in the operating system credential store, never in `config.json
|
|
85
|
+
- Andorra account tokens are stored in the operating system credential store, never in `config.json`. Where Linux or another Unix system has no usable credential store, they go to an owner-only `credentials-<id>.json` in the Andorra home instead. `ANDORRA_CREDENTIAL_STORE=file|keyring` forces one store.
|
|
@@ -6,7 +6,7 @@ Slash commands run inside the interactive TUI. Type `/` as the first character t
|
|
|
6
6
|
| --- | --- |
|
|
7
7
|
| `/browser` | Open the browser workspace (CLI stays available). See [Browser workspace](../guides/browser.md). |
|
|
8
8
|
| `/session` | Browse and resume saved sessions (newest first). |
|
|
9
|
-
| `/login` | Open browser sign-in or create an Andorra account. |
|
|
9
|
+
| `/login [--no-browser]` | Open browser sign-in or create an Andorra account. Over SSH or with `--no-browser`, prints the address to open on another device and asks for the callback address. |
|
|
10
10
|
| `/auth logout` | Remove this machine's saved Andorra account session. |
|
|
11
11
|
| `/auth status` | Show Andorra account session status and membership. |
|
|
12
12
|
| `/model [model-id]` | Open model selection or select a model directly; with a graph that pins node models, asks whether to override them. |
|
|
@@ -27,6 +27,7 @@ Slash commands run inside the interactive TUI. Type `/` as the first character t
|
|
|
27
27
|
| `/plugins` | List, install, enable, disable or remove plugins. See [Extensions](../guides/extensions.md). |
|
|
28
28
|
| `/mcp` | Add, edit, enable, disable or delete MCP servers. See [Extensions](../guides/extensions.md). |
|
|
29
29
|
| `/logout` | Sign out of your Andorra account on this machine (same as `/auth logout`). Run `/login` afterwards to sign in, or to switch to another account. |
|
|
30
|
+
| `/logout --all` | Sign out, and delete every other Andorra sign-in saved in this machine's OS credential store (other Andorra homes or deployments). |
|
|
30
31
|
| `/logout codex` | Sign out of every configured Codex (ChatGPT) account and exit. Provider settings are kept. |
|
|
31
32
|
| `/status` | Show workspace and current settings. |
|
|
32
33
|
| `/clear` | Clear the conversation on screen and the retained context (session usage is retained). |
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Graph soft delete Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** The graph MCP server can soft-delete and restore a graph; a deleted graph is hidden from every listing and refused for new runs, while sessions that already ran it keep resuming.
|
|
6
|
+
|
|
7
|
+
**Architecture:** A deletion is a new immutable revision whose `metadata.deletedAt` is set (Part 1 of `docs/superpowers/specs/2026-11-06-bundled-skills-design.md`). `isDeletedGraph` in `src/graphs.ts` is the one test. Listing surfaces filter deleted graphs after quota is computed (the quota keeps counting them, matching the hosted free-graph pin). `loadAccessibleGraph` refuses a deleted graph unless the caller is resuming.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** TypeScript (Node 22), `node:test`, the MCP SDK server in `src/agent-mcp.ts`.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## File map
|
|
14
|
+
|
|
15
|
+
- `src/graphs.ts` — `isDeletedGraph`, `withoutDeletedGraphs`, `GraphDeletedError`.
|
|
16
|
+
- `src/agent-mcp.ts` — `andorra_graph_delete`, `andorra_graph_restore`, `includeDeleted` on `andorra_graphs_list`, `deletedAt` on `andorra_graph_get`, `GRAPH_DELETED` on `andorra_graph_begin mode=edit`, guide text.
|
|
17
|
+
- `src/membership.ts` — `loadAccessibleGraph` option `allowDeleted`, refusal otherwise.
|
|
18
|
+
- `src/app-server.ts` — resume passes `allowDeleted`; `graphs.list` hides deleted graphs and reports `default` as selected when the saved one is deleted.
|
|
19
|
+
- `src/cli.ts` — `GraphDeletedError` falls back to Default with a notice, like a membership refusal.
|
|
20
|
+
- `src/command-screens.ts`, `src/graph-server.ts` — hide deleted graphs.
|
|
21
|
+
- `test/graph-soft-delete.test.ts` — new tests for all of the above.
|
|
22
|
+
- `tests/graph-soft-delete-test-plan.md` — QA plan.
|
|
23
|
+
- `docs/agents/mcp-server.md` — document the two tools.
|
|
24
|
+
|
|
25
|
+
Quota note: `readGraphQuota(directory, graphs)` callers pass the full `listGraphs` result. Filtering happens after that call at each surface, so `listGraphs` itself is unchanged.
|
|
26
|
+
|
|
27
|
+
### Task 1: Deleted-graph helpers
|
|
28
|
+
|
|
29
|
+
**Files:** Modify `src/graphs.ts` (after `GraphConflictError`); Test `test/graph-soft-delete.test.ts`
|
|
30
|
+
|
|
31
|
+
- [ ] **Step 1: Write the failing test**
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import assert from 'node:assert/strict';
|
|
35
|
+
import test from 'node:test';
|
|
36
|
+
import { isDeletedGraph, withoutDeletedGraphs, GraphDeletedError, type Graph } from '../src/graphs.js';
|
|
37
|
+
|
|
38
|
+
const graph = (id: string, deletedAt?: string): Graph => ({ schemaVersion: 3, id, name: id, revision: 1, entry: 'a',
|
|
39
|
+
nodes: { a: { id: 'a', name: 'A', type: 'end' } as Graph['nodes'][string] }, edges: [],
|
|
40
|
+
...(deletedAt ? { metadata: { deletedAt } } : {}) });
|
|
41
|
+
|
|
42
|
+
test('isDeletedGraph reads only a nonempty metadata.deletedAt string', () => {
|
|
43
|
+
assert.equal(isDeletedGraph(graph('x')), false);
|
|
44
|
+
assert.equal(isDeletedGraph(graph('x', '2026-11-06T00:00:00.000Z')), true);
|
|
45
|
+
assert.equal(isDeletedGraph({ ...graph('x'), metadata: { deletedAt: '' } }), false);
|
|
46
|
+
assert.deepEqual(withoutDeletedGraphs([graph('a'), graph('b', '2026-11-06T00:00:00.000Z')]).map(g => g.id), ['a']);
|
|
47
|
+
assert.match(new GraphDeletedError('Review loop').message, /Graph Review loop was deleted\. Restore it before running it\./);
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- [ ] **Step 2: Run it and see it fail** — `npm run build && node scripts/run-tests.mjs dist/test/graph-soft-delete.test.js` → fails: `isDeletedGraph` is not exported.
|
|
52
|
+
- [ ] **Step 3: Implement**
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
/** A soft-deleted graph: its latest revision carries `metadata.deletedAt`. Every revision stays stored. */
|
|
56
|
+
export function isDeletedGraph(graph: Pick<Graph, 'metadata'>): boolean {
|
|
57
|
+
return typeof graph.metadata?.deletedAt === 'string' && graph.metadata.deletedAt.length > 0;
|
|
58
|
+
}
|
|
59
|
+
export function withoutDeletedGraphs<T extends Pick<Graph, 'metadata'>>(graphs: T[]): T[] { return graphs.filter(graph => !isDeletedGraph(graph)); }
|
|
60
|
+
/** A new run named a deleted graph. Resuming a session that already ran it is still allowed. */
|
|
61
|
+
export class GraphDeletedError extends Error {
|
|
62
|
+
readonly code = 'GRAPH_DELETED';
|
|
63
|
+
constructor(name: string) { super(`Graph ${name} was deleted. Restore it before running it.`); this.name = 'GraphDeletedError'; }
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- [ ] **Step 4: Run the test; it passes.**
|
|
68
|
+
- [ ] **Step 5: Commit** — `git commit -m "Add the deleted-graph marker helpers"`
|
|
69
|
+
|
|
70
|
+
### Task 2: `andorra_graph_delete` and `andorra_graph_restore`
|
|
71
|
+
|
|
72
|
+
**Files:** Modify `src/agent-mcp.ts` (dispatch after `andorra_graph_get`; catalog; guide); Test `test/graph-soft-delete.test.ts`
|
|
73
|
+
|
|
74
|
+
Both tools: require `id` (safe id), `expectedRevision` (positive integer); refuse `default` (`DEFAULT_GRAPH`) and any id containing `:`; read latest with `readGraph`; `expectedRevision !== latest.revision` → `GraphConflictError` (the server already maps it); then `sync()`, re-check access like publish, and save `{ ...latest, metadata }` through `saveFreeTierGraph` (free) or `saveGraph` with `expectedRevision = latest.revision`; then `void this.sync?.sync()`.
|
|
75
|
+
|
|
76
|
+
Delete only: `confirm !== id` → `CONFIRMATION_MISMATCH`; already deleted → `GRAPH_DELETED`; automations from `new AutomationStore(this.directory).list()` whose `execution?.graph === id` → `GRAPH_IN_USE` with `automations: [{ id, name }]`; delete every draft whose `graph.id === id` and `directory === access.directory`; reply `{ id, revision, deletedAt, note }` where the note says cloud sync may be pending and, for a free account, that the deleted graph still holds the free allowance and can be restored.
|
|
77
|
+
|
|
78
|
+
Restore only: not deleted → `GRAPH_NOT_DELETED`; save with `deletedAt` removed; reply `{ id, revision }`.
|
|
79
|
+
|
|
80
|
+
`andorra_graphs_list { includeDeleted?: boolean }`: filter with `withoutDeletedGraphs` unless `includeDeleted === true`; listed entries add `deleted: true, deletedAt` when deleted. `andorra_graph_begin mode=edit` on a deleted graph → `GRAPH_DELETED` naming `andorra_graph_restore`.
|
|
81
|
+
|
|
82
|
+
- [ ] **Step 1: Write the failing tests** (in `test/graph-soft-delete.test.ts`, reusing the `fixture` shape from `test/agent-mcp.test.ts`: a temp home, `saveConfig` with one `local` provider, `new AgentMcpBackend({ directory: home, graphAccess: async () => ({ directory: home }) })`, and a published two-node graph `review-loop`):
|
|
83
|
+
- delete refuses `default` (`DEFAULT_GRAPH`), a wrong `confirm` (`CONFIRMATION_MISMATCH`), a stale `expectedRevision` (conflict), and a graph an automation names (`GRAPH_IN_USE`, listing it);
|
|
84
|
+
- delete succeeds: reply revision is 2, `loadGraph('review-loop')` has `metadata.deletedAt`, revision 1 still loads, `andorra_graphs_list` omits it, `includeDeleted: true` lists it with `deleted: true`, an open draft of it is gone (`DRAFT_NOT_FOUND`), and `andorra_graph_begin mode=edit` answers `GRAPH_DELETED`;
|
|
85
|
+
- deleting twice answers `GRAPH_DELETED`; restoring a live graph answers `GRAPH_NOT_DELETED`;
|
|
86
|
+
- restore succeeds: revision 3 without `deletedAt`, listed again.
|
|
87
|
+
- [ ] **Step 2: Run; they fail with `UNKNOWN_TOOL`.**
|
|
88
|
+
- [ ] **Step 3: Implement** the dispatch branches, catalog entries and guide lines:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
{ name: 'andorra_graph_delete', description: 'Soft-delete a graph after the user confirms in chat: publishes a revision marked deleted, hides it from listings and new runs, keeps every revision. confirm must repeat the id.', inputSchema: obj({ id: str, expectedRevision: { type: 'integer', minimum: 1 }, confirm: str }, ['id','expectedRevision','confirm']) },
|
|
92
|
+
{ name: 'andorra_graph_restore', description: 'Restore a soft-deleted graph by publishing a revision without the deleted marker.', inputSchema: obj({ id: str, expectedRevision: { type: 'integer', minimum: 1 } }, ['id','expectedRevision']) },
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Guide section `## Deleting and restoring` names both tools, the five codes and the free-allowance note.
|
|
96
|
+
- [ ] **Step 4: Run; they pass. Run `dist/test/agent-mcp.test.js` too; it still passes.**
|
|
97
|
+
- [ ] **Step 5: Commit** — `git commit -m "Soft-delete and restore graphs through the graph MCP server"`
|
|
98
|
+
|
|
99
|
+
### Task 3: Refuse new runs, allow resume
|
|
100
|
+
|
|
101
|
+
**Files:** Modify `src/membership.ts` (`loadAccessibleGraph`), `src/app-server.ts` (resume load), `src/cli.ts` (`graphFallbackReason` and both fallback sites); Test `test/graph-soft-delete.test.ts`
|
|
102
|
+
|
|
103
|
+
- [ ] **Step 1: Failing tests** — `loadAccessibleGraph('review-loop', undefined, async () => ({ paid: true, subject: 'sub-1' }))` on a deleted graph rejects with `GraphDeletedError`; with `{ allowDeleted: true }` it resolves. (Point `ANDORRACODE_HOME` at the temp home for this test and restore it in `t.after`.)
|
|
104
|
+
- [ ] **Step 2: Run; fails.**
|
|
105
|
+
- [ ] **Step 3: Implement** — options become `{ bindProviders?: boolean; allowDeleted?: boolean }`; after loading, `if (!options.allowDeleted && isDeletedGraph(graph)) throw new GraphDeletedError(graph.name);`. In `app-server.ts` the resume load (`resumedFrom !== undefined` branch) passes `allowDeleted: true`. In `cli.ts`, `graphFallbackReason` returns `${error.message} Starting with the local Default graph.` for `GraphDeletedError`, and both fallback conditions accept `error instanceof GraphDeletedError` alongside `PaidMembershipRequiredError` (an explicit `--graph` still fails).
|
|
106
|
+
- [ ] **Step 4: Run; passes.**
|
|
107
|
+
- [ ] **Step 5: Commit** — `git commit -m "Refuse new runs of a deleted graph and keep resuming the ones that ran it"`
|
|
108
|
+
|
|
109
|
+
### Task 4: Hide deleted graphs from listings
|
|
110
|
+
|
|
111
|
+
**Files:** Modify `src/app-server.ts` (`listGraphs`), `src/command-screens.ts` (`/graph`), `src/graph-server.ts` (`/api/bootstrap`); Test `test/graph-soft-delete.test.ts`
|
|
112
|
+
|
|
113
|
+
- [ ] **Step 1: Failing test** — an `AppServer` `graphs.list` over a home with one live and one deleted graph lists only the live one, and `selected` is `default` when the saved selection names the deleted graph. (Use the app-server test harness pattern from `test/app-server.test.ts`.)
|
|
114
|
+
- [ ] **Step 2: Run; fails.**
|
|
115
|
+
- [ ] **Step 3: Implement** — each surface keeps passing the full list to `readGraphQuota`, and iterates `withoutDeletedGraphs(saved)` for what it shows. `graphs.list` computes `selected` and replaces it with `'default'` when it names a deleted graph.
|
|
116
|
+
- [ ] **Step 4: Run; passes.**
|
|
117
|
+
- [ ] **Step 5: Commit** — `git commit -m "Hide deleted graphs from the desktop, /graph and the graph editor"`
|
|
118
|
+
|
|
119
|
+
### Task 5: Docs, QA plan, verification
|
|
120
|
+
|
|
121
|
+
- [ ] Document both tools in `docs/agents/mcp-server.md`.
|
|
122
|
+
- [ ] Write `tests/graph-soft-delete-test-plan.md` (scope, how to use, cases with expected results, edge cases, gaps, evidence).
|
|
123
|
+
- [ ] Run the touched suites: `node scripts/run-tests.mjs dist/test/graph-soft-delete.test.js dist/test/agent-mcp.test.js dist/test/graphs.test.js dist/test/graph-quota.test.js dist/test/membership.test.js`.
|
|
124
|
+
- [ ] Run verification: build, then drive `node dist/src/cli.js mcp-server --stdio` over stdin with a throwaway `ANDORRACODE_HOME` (create, publish, delete, list, restore) and record the replies.
|
|
125
|
+
- [ ] Commit, push, open the PR from `.github/PULL_REQUEST_TEMPLATE.md`, then run the Codex review loop and merge once Codex signs off on the current head.
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Orchestrator Delegation Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Let an Orchestrator node delegate implementation to writing subagents, each in its own Git worktree with a shell, review their diffs and test reports, land accepted changes into the working folder, and finish on a new `delivered` outcome, without the Orchestrator itself ever writing code.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Graph validation learns a "delegating Orchestrator" (spawning on and at least one writing role) with two capability ceilings and a `delivered` output port. A new `src/delegation-changes.ts` module owns every Git operation: snapshot the working folder, create a worktree from the snapshot, collect a child's change, three-way land it with `git merge-tree`, and clean up. `executeAgentNode` wires those into `spawn_subagent`, adds `accept_change` / `discard_change`, and guards the `delivered` completion. The graph builder and desktop view gain the matching port, copy and change states.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** TypeScript (Node ESM), `node:test` via `scripts/run-tests.mjs` for engine tests, Vitest for `desktop/`, Git CLI ≥ 2.40.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Existing graphs, including `DEFAULT_HARNESS`, `DEFAULT_HARNESS_REVISION_1..5` and every saved graph, load, validate and run exactly as before.
|
|
16
|
+
- `createOrchestratorNode()` must return exactly what it returns today (revision 5 and the default harness are built from it at load time).
|
|
17
|
+
- With delegation inactive (no writing role, spawning off, or no `delivered` edge in `options.graph`), `executeAgentNode` behaves byte-for-byte as today, including the existing refusal "Subagent capabilities exceed its parent".
|
|
18
|
+
- The Orchestrator's own capabilities stay `intakeCapabilities(node)` in every mode. It never gets `Write`, `Edit`, a shell, or a Git write tool.
|
|
19
|
+
- Only writing roles of a delegating Orchestrator, running in `workspace: 'worktree'`, may get command tools. Every other child keeps `canRunCommands === false`.
|
|
20
|
+
- Accepted changes land as uncommitted working-folder edits. The user's index, refs, stash and branches are never modified.
|
|
21
|
+
- Every Git invocation uses `-c core.hooksPath= -c core.fsmonitor=false`, `windowsHide: true`, a timeout, and the run's abort signal, as the existing worktree code does.
|
|
22
|
+
- Delegated writing requires Git ≥ 2.40 (`git merge-tree --write-tree --merge-base`). Older Git fails the first writing spawn with: `Delegated writing needs Git 2.40 or newer.`
|
|
23
|
+
- The Orchestrator remains Premium (`src/graph-quota.ts` unchanged).
|
|
24
|
+
- Build with `npm run build`. Run engine tests one file at a time with `node scripts/run-tests.mjs dist/test/<name>.test.js`; never bare `node --test`, and do not run the whole suite (AGENTS.md).
|
|
25
|
+
- Ships with `tests/orchestrator-delegation-test-plan.md` (AGENTS.md QA plan rules).
|
|
26
|
+
|
|
27
|
+
## Review Focus
|
|
28
|
+
|
|
29
|
+
1. **Ignored dependency folders are missing in a worktree** (for example `node_modules`). A child that runs `npm test` must not fail confusingly. Designer's call: nothing is linked into the worktree, because a link would let a child mutate the user's dependencies. Instead, the child's task text carries a notice. Pinned in Task 3.
|
|
30
|
+
2. **The user edits the working folder while subagents run.** `accept_change` merges three ways against the folder as it is now. A conflict writes nothing. Pinned in Task 2.
|
|
31
|
+
3. **Deletes, renames, binary files and paths with spaces in a change** must land exactly. Pinned in Task 2.
|
|
32
|
+
4. **Cancel or wall-time while children are running.** Every worktree is removed, nothing partial lands, and changes already accepted stay. Pinned in Task 4.
|
|
33
|
+
5. **The workspace is not a Git repository, or has no commit yet.** The first writing spawn fails with a clear message, and no directory or worktree is created. Pinned in Task 2 (message) and Task 3 (no side effects).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## File Structure
|
|
38
|
+
|
|
39
|
+
| File | Change | Responsibility |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| `src/graphs.ts` | modify | `isWritingRole`, `delegatesWriting`, `DELIVERED_OUTCOME`, `CommandScope`; ceilings, outcomes and validation |
|
|
42
|
+
| `src/capabilities.ts` | modify | `capabilityTools` accepts `CommandScope` |
|
|
43
|
+
| `src/delegation-changes.ts` | create | All Git work: snapshot, worktree, collect, land, remove |
|
|
44
|
+
| `src/agent-execution.ts` | modify | Activation, writing spawns, change registry, `accept_change` / `discard_change`, `delivered` guard, cleanup |
|
|
45
|
+
| `src/tools.ts`, `src/types.ts` | modify | `ToolContext.delegationRoots` trusted for reads |
|
|
46
|
+
| `src/graph-ui/app.js` | modify | `delivered` port, help copy, worktree requirement |
|
|
47
|
+
| `desktop/src/engine/rows.ts`, `desktop/src/engine/workflow.ts`, `desktop/src/components/WorkflowView.tsx` | modify | Change state on subagent entries |
|
|
48
|
+
| `test/orchestrator-delegation-graph.test.ts` | create | Validation and outcomes |
|
|
49
|
+
| `test/delegation-changes.test.ts` | create | Git module against real temp repos |
|
|
50
|
+
| `test/orchestrator-delegation-runtime.test.ts` | create | Runtime against a real temp repo with stub adapters |
|
|
51
|
+
| `test/orchestrator-role-ceiling.test.ts` | modify | Expectations that change for writing roles |
|
|
52
|
+
| `tests/orchestrator-delegation-test-plan.md` | create | QA plan |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### Task 1: Graph model — delegating Orchestrator, ceilings, `delivered` port, child command scope
|
|
57
|
+
|
|
58
|
+
**Files:**
|
|
59
|
+
- Modify: `src/graphs.ts` (`canRunCommands` / `permitsBuiltInTool` ~233-249, `nodeOutcomes` ~257, subagent validation ~575-610, required-route check ~673, Orchestrator checks ~704-720)
|
|
60
|
+
- Modify: `src/capabilities.ts:12` (`capabilityTools`)
|
|
61
|
+
- Create: `test/orchestrator-delegation-graph.test.ts`
|
|
62
|
+
- Modify: `test/orchestrator-role-ceiling.test.ts`
|
|
63
|
+
|
|
64
|
+
**Interfaces:**
|
|
65
|
+
- Produces (in `src/graphs.ts`):
|
|
66
|
+
- `export const DELIVERED_OUTCOME = 'delivered'`
|
|
67
|
+
- `export type CommandScope = boolean | 'delegated-worktree'` (`false` = primary agent, `true` = ordinary child, `'delegated-worktree'` = writing child of a delegating Orchestrator)
|
|
68
|
+
- `export function isWritingRole(role: SubagentRole): boolean`: `role.capabilities?.filesystem === 'read-write' || role.capabilities?.git === 'write'`
|
|
69
|
+
- `export function delegatesWriting(node: GraphNode): boolean`: `node.type === 'agent' && node.agentRole === 'orchestrator' && node.subagents?.enabled === true && node.maxSubagents !== 0 && (node.subagents.roles ?? []).some(isWritingRole)`
|
|
70
|
+
- `permitsBuiltInTool(node, name, child: CommandScope = false)`. Command and QA tools are allowed when `child !== true` and the existing policy test holds.
|
|
71
|
+
- `nodeOutcomes(node)` returns `[node.completion?.outcome ?? 'completed', DELIVERED_OUTCOME]` when `delegatesWriting(node)`
|
|
72
|
+
- Produces (in `src/capabilities.ts`): `capabilityTools(node: GraphNode, tools: Tool[], child: CommandScope = false)`. The external-MCP exclusion applies to any truthy `child`.
|
|
73
|
+
|
|
74
|
+
- [ ] **Step 1: Write the failing tests** in `test/orchestrator-delegation-graph.test.ts`. Build fixtures from `structuredClone(DEFAULT_HARNESS)` with `orchestrator.capabilities = { filesystem: 'read-write', shell: 'allowed', git: 'write', github: 'none', browser: 'disabled', deployment: 'none' }`, `subagents = { enabled: true, workspace: 'worktree', maxConcurrent: 2, maxTotal: 6, roles: [{ id: 'coder', name: 'Coder', instruction: 'Implement', capabilities: { ...thatPolicy } }] }`.
|
|
75
|
+
- `delegating Orchestrator validates and exposes completed and delivered ports`: `validateGraph` does not throw, and `nodeOutcomes(orchestrator)` deep-equals `['completed', 'delivered']`.
|
|
76
|
+
- `delivered needs no route`: the fixture has no `delivered` edge and validates.
|
|
77
|
+
- `an edge may route delivered`: add `{ id: 'o-done', source: 'orchestrator', target: 'done', outcome: 'delivered' }`, and it validates.
|
|
78
|
+
- `writing roles require separate worktrees`: `workspace: 'shared-write', maxConcurrent: 1` throws `/writing roles on an Orchestrator require separate worktrees/`.
|
|
79
|
+
- `delegation requires single completion`: `completion = { mode: 'outcomes', outcomes: ['a', 'b'] }` throws `/delegation needs a single completion outcome/`.
|
|
80
|
+
- `writing role is checked against the node ceiling, not intake`: role `{ ...policy }` passes. A role with `deployment: 'allowed'` throws `/capability exceeds parent/`.
|
|
81
|
+
- `read-only roles on a delegating Orchestrator keep the intake ceiling`: a role `{ filesystem: 'read', shell: 'allowed', git: 'read', ... }` throws `/intake read-only ceiling/`.
|
|
82
|
+
- `spawning off keeps today's behavior`: `subagents.enabled = false` with a writing role means `delegatesWriting` is false, `nodeOutcomes` is `['completed']`, and it validates as today.
|
|
83
|
+
- `command tools only for delegated worktree children`: for `{ capabilities: policy }`, `permitsBuiltInTool(n, 'Bash', true) === false`, `permitsBuiltInTool(n, 'Bash', 'delegated-worktree') === true`, `permitsBuiltInTool(n, 'qa.test', 'delegated-worktree') === true`, and `permitsBuiltInTool({ capabilities: { ...policy, git: 'read' } }, 'Bash', 'delegated-worktree') === false`.
|
|
84
|
+
- `frozen and default graphs are unchanged`: for `DEFAULT_HARNESS` and each `DEFAULT_HARNESS_REVISION_*` that has an Orchestrator, `delegatesWriting(orchestrator) === false`, `nodeOutcomes(orchestrator)` deep-equals `['completed']`, and `createOrchestratorNode()` deep-equals the JSON snapshot `test/fixtures/orchestrator-preset.json`. Write that snapshot in Step 1 from the unmodified `createOrchestratorNode()`, before touching `src/graphs.ts`.
|
|
85
|
+
- `minimum tool calls ignore an unrouted delivered port`: `minimumGraphToolCalls(fixture)` equals `minimumGraphToolCalls` of the same graph with spawning disabled.
|
|
86
|
+
|
|
87
|
+
- [ ] **Step 2: Update `test/orchestrator-role-ceiling.test.ts`.** In the first test, the `{ filesystem: 'read-write' }` and `{ git: 'write' }` cases now make the node delegating with `workspace: 'shared-write'`, so they assert `/writing roles on an Orchestrator require separate worktrees/`. The `shell`, `github` and `deployment` cases keep `/intake read-only ceiling/`.
|
|
88
|
+
|
|
89
|
+
- [ ] **Step 3: Build and run, expect failures.** Run: `npm run build && node scripts/run-tests.mjs dist/test/orchestrator-delegation-graph.test.js dist/test/orchestrator-role-ceiling.test.js`. Expected: FAIL (`delegatesWriting` is not exported).
|
|
90
|
+
|
|
91
|
+
- [ ] **Step 4: Implement** the Interfaces above.
|
|
92
|
+
- Validation, inside the subagent block: when `delegatesWriting(node)`, validate writing roles against `effectiveCapabilities(node)` and other roles against `intakeCapabilities(node)`. Require `(s.workspace ?? 'shared-read-only') === 'worktree'` (message: `${label}: writing roles on an Orchestrator require separate worktrees; select Separate Git worktree`). Require `node.completion?.mode !== 'outcomes'` (message: `${label}: Orchestrator delegation needs a single completion outcome; remove declared outcomes or the writing roles`).
|
|
93
|
+
- Validate writing-role `tools` with `permitsBuiltInTool({capabilities: child}, t, 'delegated-worktree')`.
|
|
94
|
+
- Exclude `DELIVERED_OUTCOME` of a delegating node from the required-route check, and from `guaranteedGraphInvocations` alternatives when it has no route.
|
|
95
|
+
- Update the "custom Orchestrator delegation … rejects explicit writer roles" runtime test only if it breaks. It should not, because its node is validated nowhere and has no graph.
|
|
96
|
+
|
|
97
|
+
- [ ] **Step 5: Run tests and the neighbors.** Run: `npm run build && node scripts/run-tests.mjs dist/test/orchestrator-delegation-graph.test.js dist/test/orchestrator-role-ceiling.test.js dist/test/graphs.test.js dist/test/graph-policy-validation.test.js dist/test/orchestrator-schema.test.js dist/test/graph-quota.test.js`. Expected: PASS, apart from failures already listed in memory as baseline.
|
|
98
|
+
|
|
99
|
+
- [ ] **Step 6: Commit** `feat(graphs): delegating Orchestrator ceilings and delivered outcome`.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Task 2: Git change module
|
|
104
|
+
|
|
105
|
+
**Files:**
|
|
106
|
+
- Create: `src/delegation-changes.ts`
|
|
107
|
+
- Create: `test/delegation-changes.test.ts`
|
|
108
|
+
|
|
109
|
+
**Interfaces:**
|
|
110
|
+
- Produces:
|
|
111
|
+
- `export const DELEGATION_DIFF_LIMIT = 20_000` (characters of diff inlined into an observation)
|
|
112
|
+
- `export async function assertDelegationGit(workspace: string, signal: AbortSignal): Promise<void>`. Throws `Delegated writing needs Git 2.40 or newer.`, `Delegated writing needs the workspace to be a Git repository.`, or `Delegated writing needs a Git repository with at least one commit.`
|
|
113
|
+
- `export async function snapshotWorkspace(workspace: string, signal: AbortSignal): Promise<string>` returns a commit id. Its tree is the working folder's tracked plus untracked non-ignored files, and its parent is `HEAD`. It uses a temporary `GIT_INDEX_FILE` and `git add -A`, `git write-tree`, `git commit-tree`. It never touches the real index, refs or stash.
|
|
114
|
+
- `export async function addChangeWorktree(workspace: string, commit: string, signal: AbortSignal): Promise<string>` returns the worktree path, created with `mkdtemp(join(tmpdir(), 'andorra-subagent-'))` + `/worktree` and `git worktree add --detach <path> <commit>`.
|
|
115
|
+
- `export interface CollectedChange { tree: string; files: { path: string; status: 'A' | 'M' | 'D' | 'R' }[]; diff: string }`
|
|
116
|
+
- `export async function collectChange(worktree: string, base: string, signal: AbortSignal): Promise<CollectedChange>`. Snapshots the worktree's final files with a temporary index (commits made inside the worktree don't matter). `diff` is `git diff --binary -M <base>^{tree} <tree>`. `files` comes from `--name-status -M`.
|
|
117
|
+
- `export type LandResult = { landed: true; files: string[] } | { landed: false; conflicts: string[]; detail: string }`
|
|
118
|
+
- `export async function landChange(workspace: string, base: string, tree: string, signal: AbortSignal): Promise<LandResult>`. `ours = snapshotWorkspace(workspace)^{tree}`, then `git merge-tree --write-tree --merge-base <base> <ours> <tree>`. On a clean merge, apply `git diff --binary <ours> <merged>` to the working tree with `git apply` (no `--index`). On a conflict, write nothing and return the conflicted paths.
|
|
119
|
+
- `export async function removeChangeWorktree(workspace: string, worktree: string): Promise<void>`. Best effort and never throws: `git worktree remove --force`, then `rm -rf` of the `mkdtemp` parent, then `git worktree prune`.
|
|
120
|
+
|
|
121
|
+
- [ ] **Step 1: Write the failing tests** in `test/delegation-changes.test.ts`. Each test creates a real temp repo with `mkdtemp`, `git init`, a committed `README.md` and `src/a.txt`, and `t.after` removal. Set `git config user.email/name` locally in the repo.
|
|
122
|
+
- `snapshot includes uncommitted and untracked files and leaves index and refs alone`: modify `src/a.txt`, add untracked `new file.txt`, and add `ignored.log` with `.gitignore` containing `*.log`. After `snapshotWorkspace`, `git ls-tree -r --name-only <commit>` contains `new file.txt` and not `ignored.log`. `git status --porcelain`, `git rev-parse HEAD` and `git stash list` are byte-identical before and after.
|
|
123
|
+
- `worktree starts from the snapshot`: `addChangeWorktree(ws, commit)` contains the modified `src/a.txt` content and `new file.txt`.
|
|
124
|
+
- `collect reports adds, edits, deletes, renames and binary`: in the worktree, edit `src/a.txt`, delete `README.md`, rename `src/b.txt` (committed in setup) to `src/c.txt`, add `img.bin` with bytes `[0, 255, 1]`, then `git commit -am x` inside the worktree. `files` maps to statuses M, D, R (`src/c.txt`) and A, and `diff` contains `GIT binary patch`.
|
|
125
|
+
- `land applies a clean change as uncommitted edits`: after `landChange`, the working folder has the worktree's file contents (byte-equal for `img.bin`), `git diff --cached --quiet` exits 0, and `HEAD` is unchanged.
|
|
126
|
+
- `land merges with edits the user made meanwhile`: the user edits line 1 of `src/a.txt` in the workspace after spawn, and the child edits line 3. The result is `landed: true` and both edits are present.
|
|
127
|
+
- `land conflict writes nothing`: the user and the child both edit line 2 differently. The result is `{ landed: false }` with `conflicts` containing `src/a.txt`, and the workspace bytes are identical to before the call.
|
|
128
|
+
- `paths with spaces land`: the child adds `docs/my notes.md`, and it lands.
|
|
129
|
+
- `remove cleans the worktree and the temp directory`: after `removeChangeWorktree`, the path does not exist and `git worktree list` no longer lists it. A second call does not throw.
|
|
130
|
+
- `refuses non-repositories and unborn repositories`: an empty dir rejects with `/must be a Git repository|needs the workspace to be a Git repository/`. `git init` without a commit rejects with `/at least one commit/`.
|
|
131
|
+
|
|
132
|
+
- [ ] **Step 2: Run, expect failure.** Run: `npm run build && node scripts/run-tests.mjs dist/test/delegation-changes.test.js`. Expected: FAIL (module not found).
|
|
133
|
+
|
|
134
|
+
- [ ] **Step 3: Implement `src/delegation-changes.ts`** per the Interfaces. Run Git through `promisify(execFile)` with the hardened `-c` flags from the Global Constraints. Pass `GIT_INDEX_FILE` via `env: { ...process.env, GIT_INDEX_FILE }`, pointing at a file inside a `mkdtemp` directory that is removed in `finally`. For `assertDelegationGit`, parse `git --version` and compare major.minor ≥ 2.40.
|
|
135
|
+
|
|
136
|
+
- [ ] **Step 4: Run tests.** Same command. Expected: PASS.
|
|
137
|
+
|
|
138
|
+
- [ ] **Step 5: Commit** `feat: Git snapshot, worktree and three-way landing for delegated changes`.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### Task 3: Runtime — activation, writing spawns, review record, child shell
|
|
143
|
+
|
|
144
|
+
**Files:**
|
|
145
|
+
- Modify: `src/agent-execution.ts` (instructions ~54, tool filter ~298, `spawn_subagent` ~357-470, approvals ~440-462)
|
|
146
|
+
- Modify: `src/types.ts:125` (add `delegationRoots?: readonly string[]` next to `attachmentRoots`), `src/tools.ts:40` (`trustedAttachment` also consults `delegationRoots`, which is cleared wherever `attachmentRoots` is cleared for mutations)
|
|
147
|
+
- Create: `test/orchestrator-delegation-runtime.test.ts`
|
|
148
|
+
|
|
149
|
+
**Interfaces:**
|
|
150
|
+
- Consumes: Task 1 (`delegatesWriting`, `isWritingRole`, `DELIVERED_OUTCOME`, `CommandScope`, `capabilityTools`), Task 2 (all exports).
|
|
151
|
+
- Produces (module-internal to `executeAgentNode`, used by Task 4):
|
|
152
|
+
- `const delegationActive: boolean` = `orchestrator && delegatesWriting(node) && !!options.graph?.edges.some(e => e.source === node.id && e.outcome === DELIVERED_OUTCOME)`
|
|
153
|
+
- `interface ChangeRecord { id: string; subagentId: string; role: string; worktree: string; base: string; tree?: string; files: CollectedChange['files']; state: 'pending' | 'landed' | 'discarded' | 'conflict'; diffArtifact?: ArtifactRef }`
|
|
154
|
+
- `const changes = new Map<string, ChangeRecord>()`, scoped to the node visit, next to `active` / `total`
|
|
155
|
+
- Event `subagent.change` with data `{ subagentId, changeId, state, files?: string[] }`
|
|
156
|
+
- The writing spawn's observation JSON adds `change: { id, files, diff, truncated: boolean, diffArtifact }` and `tests: string[]` (from `result.completion?.tests ?? []`)
|
|
157
|
+
|
|
158
|
+
- [ ] **Step 1: Write the failing tests** in `test/orchestrator-delegation-runtime.test.ts`. Reuse the harness style of `test/orchestrator-runtime.test.ts` (`tool()`, `plan()`, `read()`, `ask()`, `createTools()`), plus a real temp Git repo fixture from Task 2. The graph is `DEFAULT_HARNESS` with the Task 1 delegating Orchestrator and an edge `orchestrator → done` on `delivered`. Call `executeAgentNode(node, { ...opts, graph })` with `context.permissions = 'full-access'` unless stated.
|
|
159
|
+
- `inactive without a delivered route`: same node, `graph` without the edge. Spawning `coder` returns an observation matching `/capabilities exceed its parent/` and no worktree is created (`git worktree list` has one entry).
|
|
160
|
+
- `writing child gets a shell and works in its worktree`: the stub child adapter's first request has a tool whose `canonicalToolName` is `Bash` or `PowerShell`, and `Write`/`Edit` tools. Replace the shell tool with a stub that records `ctx.workspace`; the recorded workspace is not the repo root and starts with `join(tmpdir(), 'andorra-subagent-')`.
|
|
161
|
+
- `child task notes missing ignored files`: the child's first user message contains `Files ignored by Git (for example node_modules) are not in this worktree`.
|
|
162
|
+
- `review record reaches the Orchestrator`: the child writes `src/a.txt` and completes with `tests: ['npm test: 3 passed']`. The parent's next request has a tool observation whose JSON has `change.files` `[{ path: 'src/a.txt', status: 'M' }]`, `change.diff` containing the edit, `truncated: false`, and `tests` `['npm test: 3 passed']`. The repo's working folder is unchanged at that point.
|
|
163
|
+
- `large diffs are truncated with an artifact`: the child writes 30,000 characters, so `change.diff.length <= 20_000`, `truncated === true`, and `diffArtifact.ref` is readable with `read_artifact` and contains the full diff.
|
|
164
|
+
- `Orchestrator can read inside a child's worktree without prompts`: in `ask-for-approval` with `approve` counting calls, the parent calls `read_file` with the absolute worktree path of the changed file. It returns the new content with zero `approve` calls for that read.
|
|
165
|
+
- `worktree approval is asked once per visit`: in `ask-for-approval` with `approve` returning `true`, two writing spawns produce exactly one `approve` call named `spawn_subagent.worktree`.
|
|
166
|
+
- `failed child yields no change`: a child completing with a failure status means the observation has no `change`, and the worktree path no longer exists.
|
|
167
|
+
- `not a repository fails before side effects`: the workspace is a plain temp dir. The spawn observation matches `/needs the workspace to be a Git repository/`, and `fs.readdir(tmpdir())` shows no new `andorra-subagent-*` entry created by this test (compare before and after).
|
|
168
|
+
- `the Orchestrator still has no write or shell tools`: in every parent request, no tool's canonical name is `Write`, `Edit`, `Bash` or `PowerShell`.
|
|
169
|
+
- `writing spawn waits for clarification`: a writing spawn after `update_todos` but before a successful `ask_user` returns an observation matching `/Ask the user to confirm the design before starting writing subagents/`, and no worktree is created. Read-only research spawns keep today's rule (plan only).
|
|
170
|
+
|
|
171
|
+
- [ ] **Step 2: Run, expect failure.** Run: `npm run build && node scripts/run-tests.mjs dist/test/orchestrator-delegation-runtime.test.js`. Expected: FAIL.
|
|
172
|
+
|
|
173
|
+
- [ ] **Step 3: Implement.**
|
|
174
|
+
- Compute `delegationActive`. When it is false, change nothing.
|
|
175
|
+
- In `spawn_subagent`, for a writing role when `delegationActive`:
|
|
176
|
+
- Refuse with the clarification message from the test while `clarified` is false.
|
|
177
|
+
- Take `parentCapabilities` from `effectiveCapabilities(node)` (the configured ceiling), not the intake-clamped `configured`.
|
|
178
|
+
- Build `available` from `capabilityTools({ ...node, capabilities: parentCapabilities, tools: undefined }, options.tools, 'delegated-worktree')` minus `browser.panel`.
|
|
179
|
+
- Default `childToolNames` for a writing role with no `tools` is all of `available`.
|
|
180
|
+
- Run `assertDelegationGit` before any approval or mkdtemp.
|
|
181
|
+
- Replace the clean-tree `git status` check and `HEAD` base with `snapshotWorkspace` + `addChangeWorktree`.
|
|
182
|
+
- Hoist the worktree approval state (`audited`, `explicitlyApproved`) to the node-visit scope so one grant covers the visit, while keeping its live-mode recheck.
|
|
183
|
+
- Pass a new `commandScope: CommandScope` argument through `run` → `runWithinDeadline` and into `capabilityTools`/`permitsBuiltInTool` (default `depth > 0`). Writing delegated children get `'delegated-worktree'`.
|
|
184
|
+
- Append the ignored-files notice (exact text from the test, followed by: `Install what you need inside this worktree if a build or test requires it.`) to the child task.
|
|
185
|
+
- After the child returns `succeeded`, call `collectChange`. When `files` is empty, remove the worktree and add no change. Otherwise register a `pending` `ChangeRecord`, put the full diff in the `ArtifactStore` as type `delegation-diff`, emit `subagent.change`, and add `worktree` to the parent context's `delegationRoots`.
|
|
186
|
+
- When the child does not succeed, remove the worktree.
|
|
187
|
+
- Append `DELEGATION_INSTRUCTIONS` to the Orchestrator's instructions only when `delegationActive`. It covers: the two paths (`completed` handoff or `delivered`); clarify first; spawn writing roles in parallel; review each `change` and `tests` report; `accept_change` / `discard_change`; spawn fixes with findings; complete `delivered` only when every change is decided; never write code.
|
|
188
|
+
|
|
189
|
+
- [ ] **Step 4: Run tests** plus `dist/test/subagent-worktree-permissions.test.js` and `dist/test/orchestrator-runtime.test.js`. Expected: PASS, apart from known baseline failures.
|
|
190
|
+
|
|
191
|
+
- [ ] **Step 5: Commit** `feat(runtime): writing subagents for a delegating Orchestrator`.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### Task 4: Landing tools, `delivered` completion, cleanup, end-to-end routing
|
|
196
|
+
|
|
197
|
+
**Files:**
|
|
198
|
+
- Modify: `src/agent-execution.ts` (tool registration next to `spawn_subagent`, `completionGuard` ~1074, `completionPolicy` ~1079, node `finish`/`finally`)
|
|
199
|
+
- Modify: `test/orchestrator-delegation-runtime.test.ts`
|
|
200
|
+
|
|
201
|
+
**Interfaces:**
|
|
202
|
+
- Consumes: Task 3 `changes`, `ChangeRecord`, `delegationActive`. Task 2 `landChange`, `removeChangeWorktree`.
|
|
203
|
+
- Produces:
|
|
204
|
+
- Tool `accept_change` with `{ id: string }`, returning `{"state":"landed","files":[...]}` or `{"state":"conflict","conflicts":[...],"detail":"..."}`. Allowed from `pending` or `conflict`.
|
|
205
|
+
- Tool `discard_change` with `{ id: string }`, returning `{"state":"discarded"}`. Allowed from `pending` or `conflict`.
|
|
206
|
+
- Both refuse unknown ids (`Unknown change`) and finished changes (`Change already landed` / `Change already discarded`), and both are `executionMode: 'sequential'`.
|
|
207
|
+
- Completion policy when `delegationActive`: `{ mode: 'outcomes', outcomes: [configured completion outcome ?? 'completed', 'delivered'] }`.
|
|
208
|
+
|
|
209
|
+
- [ ] **Step 1: Write the failing tests** (append to the runtime test file):
|
|
210
|
+
- `accept lands and discard removes`: two writing children. `accept_change(c1)` → the working folder has c1's edit, the state is `landed`, and the `subagent.change` event has `state: 'landed'`. `discard_change(c2)` → c2's worktree path is gone and the folder lacks c2's edit.
|
|
211
|
+
- `accept conflict writes nothing and can be retried or discarded`: the user edit conflicts, so the result is `state: 'conflict'` and the folder bytes are unchanged. After the test reverts the user edit, `accept_change` again → `landed`.
|
|
212
|
+
- `landing does not prompt where a workspace edit would not`: in `ask-for-approval` and `approve-for-me`, `accept_change` makes zero `approve` calls. In `read-only`, one `approve` call named `accept_change`, and the change lands only when it returns `true`.
|
|
213
|
+
- `delivered requires every change decided`: completing `delivered` with a `pending` change gets a repair message matching `/Accept or discard every change before completing as delivered/`. With nothing landed, `/Land at least one accepted change before completing as delivered/`. After a decision, it succeeds.
|
|
214
|
+
- `delivered uses the handoff schema`: `delivered` without `taskInstruction` gets the existing handoff repair message.
|
|
215
|
+
- `delivered output references the delivery record`: `result.completion.artifacts` contains one ref of type `delegation-record` whose content lists each change's `role`, `files` and `state`.
|
|
216
|
+
- `runGraph routes delivered`: graph `orchestrator →(completed) engineer`, `orchestrator →(delivered) done`. A delivered run finishes without the engineer adapter being called, and `result.nodeResults.orchestrator.outcome === 'delivered'`.
|
|
217
|
+
- `cancel removes every worktree and keeps accepted changes`: accept c1, then abort `context` while c2's child adapter is awaiting. The run is `cancelled`, the folder has c1's edit and not c2's, and `git worktree list` shows only the main worktree.
|
|
218
|
+
- `undecided changes are discarded at node end`: after a `completed` (handoff) completion with a `pending` change, its worktree is removed and a `subagent.change` `discarded` event fires.
|
|
219
|
+
- `cannot pass content through landing tools`: `accept_change` with an extra `patch` argument is refused by schema validation (`additionalProperties: false`).
|
|
220
|
+
|
|
221
|
+
- [ ] **Step 2: Run, expect failure.** Run: `npm run build && node scripts/run-tests.mjs dist/test/orchestrator-delegation-runtime.test.js`.
|
|
222
|
+
|
|
223
|
+
- [ ] **Step 3: Implement.**
|
|
224
|
+
- Register both tools only when `delegationActive`.
|
|
225
|
+
- Landing approval: call `assertPlanMutationAllowed`. Skip approval when `permissionMode(ctx)` is `full-access`, `ask-for-approval` or `approve-for-me`. Otherwise call `approveOperation(ctx, 'accept_change', { id, files })`.
|
|
226
|
+
- Extend `completionGuard`: when `completion.outcome === 'delivered'`, after the existing handoff checks, require `active === 0`, at least one `landed`, and no `pending`/`conflict` change, using the exact messages from the tests. Then `put` a `delegation-record` artifact and add its ref to the completion's artifacts.
|
|
227
|
+
- In the node's `finally`, for each change not `landed`/`discarded`: run `removeChangeWorktree`, set `discarded`, and emit the event. Also remove worktrees of landed or discarded changes not yet removed.
|
|
228
|
+
|
|
229
|
+
- [ ] **Step 4: Run tests** plus `dist/test/orchestrator-runtime.test.js`, `dist/test/orchestrator-outcome-routing.test.js` and `dist/test/graph-runner.test.js`. Expected: PASS, apart from known baseline failures.
|
|
230
|
+
|
|
231
|
+
- [ ] **Step 5: Commit** `feat(runtime): land, discard and deliver delegated changes`.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### Task 5: Graph builder
|
|
236
|
+
|
|
237
|
+
**Files:**
|
|
238
|
+
- Modify: `src/graph-ui/app.js` (`outcomes` ~168, `renderSubagents` ~1126-1160)
|
|
239
|
+
- Modify: `test/graph-ui.test.ts` (or a new `test/graph-ui-delegation.test.ts` using the same vm fixture as `test/graph-ui-orchestrator-reuse.test.ts`)
|
|
240
|
+
|
|
241
|
+
**Interfaces:**
|
|
242
|
+
- Produces in `app.js`: `function delegatesWriting(node)`, mirroring Task 1 exactly. `outcomes(node)` appends `'delivered'` when it is true.
|
|
243
|
+
|
|
244
|
+
- [ ] **Step 1: Write the failing tests:**
|
|
245
|
+
- `outcomes(node)` for the Task 1 fixture deep-equals `['completed', 'delivered']`, and for `DEFAULT_HARNESS.nodes.orchestrator` deep-equals `['completed']`.
|
|
246
|
+
- With the delegating fixture rendered, the subagent help text contains `Writing roles of an Orchestrator run in their own Git worktree with a shell` and does not contain `Subagents never receive the unsandboxed host shell, including in worktrees`.
|
|
247
|
+
- Adding a writing role to an Orchestrator whose workspace is `shared-read-only` sets `policy.workspace` to `worktree`.
|
|
248
|
+
|
|
249
|
+
- [ ] **Step 2: Run, expect failure.** Run: `npm run build && node scripts/run-tests.mjs dist/test/graph-ui-delegation.test.js`.
|
|
250
|
+
|
|
251
|
+
- [ ] **Step 3: Implement.** Help text for a delegating Orchestrator, exactly: `Writing roles of an Orchestrator run in their own Git worktree with a shell. The shell is not sandboxed and follows your permission mode. The Orchestrator reviews each change and lands the ones it accepts into your working folder; it never writes code itself.` Other nodes get today's copy with the "never receive the unsandboxed host shell" sentence changed to `Subagents of ordinary agents never receive the unsandboxed host shell.`
|
|
252
|
+
|
|
253
|
+
- [ ] **Step 4: Run tests** plus `dist/test/graph-ui.test.js` and `dist/test/graph-ui-orchestrator-reuse.test.js`. Expected: PASS.
|
|
254
|
+
|
|
255
|
+
- [ ] **Step 5: Commit** `feat(graph-ui): delivered port and delegation settings`.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### Task 6: Desktop change states
|
|
260
|
+
|
|
261
|
+
**Files:**
|
|
262
|
+
- Modify: `desktop/src/engine/rows.ts` (`SubagentItem` ~145, fold `case 'subagent.change'` next to ~2158)
|
|
263
|
+
- Modify: `desktop/src/engine/workflow.ts` (`subagentStatusLabel` ~62)
|
|
264
|
+
- Modify: `desktop/src/components/WorkflowView.tsx` (~183)
|
|
265
|
+
- Test: `desktop/src/engine/rows.test.ts`, `desktop/src/engine/workflow.test.ts`
|
|
266
|
+
|
|
267
|
+
**Interfaces:**
|
|
268
|
+
- Produces: `SubagentItem.change?: 'pending' | 'landed' | 'discarded' | 'conflict'`. `export function subagentChangeLabel(item: SubagentItem): string | undefined` returns `Awaiting review`, `Landed`, `Discarded` or `Conflict`, or `undefined` when there is no change.
|
|
269
|
+
|
|
270
|
+
- [ ] **Step 1: Write failing tests:**
|
|
271
|
+
- `rows.test.ts`: folding `subagent.started` then `subagent.change { subagentId, state: 'pending' }` then `{ state: 'landed' }` leaves `state.subagents[0].change === 'landed'`. A `subagent.change` for an unknown id is ignored.
|
|
272
|
+
- `workflow.test.ts`: `subagentChangeLabel` maps all four states, and `undefined` for an item without `change`.
|
|
273
|
+
|
|
274
|
+
- [ ] **Step 2: Run, expect failure.** Run: `npm test --prefix desktop -- rows workflow`.
|
|
275
|
+
|
|
276
|
+
- [ ] **Step 3: Implement.** The fold replaces the item immutably, like the existing cases. `WorkflowView` renders the label after the status in a `workflow-agent-change` span.
|
|
277
|
+
|
|
278
|
+
- [ ] **Step 4: Run tests and typecheck.** Run: `npm test --prefix desktop -- rows workflow WorkflowView && npm run check --prefix desktop`. Expected: PASS.
|
|
279
|
+
|
|
280
|
+
- [ ] **Step 5: Commit** `feat(desktop): show delegated change state on subagents`.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Task 7: QA plan, run verification, pull request
|
|
285
|
+
|
|
286
|
+
**Files:**
|
|
287
|
+
- Create: `tests/orchestrator-delegation-test-plan.md`
|
|
288
|
+
|
|
289
|
+
- [ ] **Step 1: Write the QA plan** to the AGENTS.md outline. Cover: scope and prerequisites (Premium account, Git ≥ 2.40, two providers), how to configure the graph in the builder, and cases for each spec goal, the five Review Focus items, each permission mode, Windows paths with spaces, and the no-`delivered`-route fallback. Include gaps and limitations, and validation evidence (only what was actually run).
|
|
290
|
+
|
|
291
|
+
- [ ] **Step 2: Run verification with the built CLI.** `npm run build`. Then, in a throwaway home (`home=$(mktemp -d) || exit 1; export ANDORRACODE_HOME="$home"`, removed in the same invocation), drive `node dist/src/cli.js app-server --stdio` against a temp Git repo and a local stub provider (see memory "Verify desktop renderer headless"). Run a delegating graph through: clarify, two writing spawns, accept one, discard one, deliver. Observe: the folder has the accepted change only, `git worktree list` is clean, `git diff --cached` is empty, and the run ends on `delivered`. Record the commands and output for the PR.
|
|
292
|
+
|
|
293
|
+
- [ ] **Step 3: Confirm nothing is left behind.** `git status --short` shows only intended changes, and no `andorra-subagent-*` directory from the run remains in `tmpdir()`.
|
|
294
|
+
|
|
295
|
+
- [ ] **Step 4: Commit, push and open the PR** to `main` using `.github/PULL_REQUEST_TEMPLATE.md`. List the exact tests run and the verification above in Validation, linking the QA plan. Then follow the Codex review loop in AGENTS.md.
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Status: approved 2026-11-01.
|
|
4
4
|
|
|
5
|
+
Amended 2026-11-07: **Auto-archive on merge or close was removed**, from the menu, the protocol and the
|
|
6
|
+
`pull_request` tool (the engine still sends `autoArchive: false` so older desktops keep showing the section).
|
|
7
|
+
**Auto-fix now stops with the PR**: it switches itself off once the PR is merged or closed, and the engine reads
|
|
8
|
+
the PR from GitHub right before each Auto-fix prompt is delivered, so a PR merged by hand since the last poll gets
|
|
9
|
+
no prompt. The Auto-archive parts below describe the original design; `tests/pr-section-test-plan.md` describes
|
|
10
|
+
the current behavior.
|
|
11
|
+
|
|
5
12
|
## Goal
|
|
6
13
|
|
|
7
14
|
After the agent opens a pull request, the session's Plan card shows a **Pull request** section with the PR's link
|