@hegemonart/get-design-done 1.25.0 → 1.27.0

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.
Files changed (58) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +96 -0
  4. package/README.md +12 -6
  5. package/SKILL.md +3 -0
  6. package/agents/README.md +89 -0
  7. package/agents/design-reflector.md +43 -0
  8. package/agents/gdd-intel-updater.md +34 -1
  9. package/hooks/budget-enforcer.ts +143 -4
  10. package/package.json +1 -1
  11. package/reference/model-prices.md +40 -19
  12. package/reference/peer-cli-capabilities.md +151 -0
  13. package/reference/peer-protocols.md +266 -0
  14. package/reference/prices/antigravity.md +21 -0
  15. package/reference/prices/augment.md +21 -0
  16. package/reference/prices/claude.md +42 -0
  17. package/reference/prices/cline.md +23 -0
  18. package/reference/prices/codebuddy.md +21 -0
  19. package/reference/prices/codex.md +25 -0
  20. package/reference/prices/copilot.md +21 -0
  21. package/reference/prices/cursor.md +21 -0
  22. package/reference/prices/gemini.md +25 -0
  23. package/reference/prices/kilo.md +21 -0
  24. package/reference/prices/opencode.md +23 -0
  25. package/reference/prices/qwen.md +25 -0
  26. package/reference/prices/trae.md +23 -0
  27. package/reference/prices/windsurf.md +21 -0
  28. package/reference/registry.json +121 -1
  29. package/reference/runtime-models.md +446 -0
  30. package/reference/schemas/runtime-models.schema.json +123 -0
  31. package/scripts/install.cjs +8 -0
  32. package/scripts/lib/bandit-router.cjs +214 -7
  33. package/scripts/lib/budget-enforcer.cjs +514 -0
  34. package/scripts/lib/cost-arbitrage.cjs +294 -0
  35. package/scripts/lib/event-stream/index.ts +14 -1
  36. package/scripts/lib/event-stream/types.ts +125 -1
  37. package/scripts/lib/install/installer.cjs +188 -11
  38. package/scripts/lib/install/parse-runtime-models.cjs +267 -0
  39. package/scripts/lib/install/runtimes.cjs +101 -0
  40. package/scripts/lib/peer-cli/acp-client.cjs +375 -0
  41. package/scripts/lib/peer-cli/adapters/codex.cjs +101 -0
  42. package/scripts/lib/peer-cli/adapters/copilot.cjs +79 -0
  43. package/scripts/lib/peer-cli/adapters/cursor.cjs +78 -0
  44. package/scripts/lib/peer-cli/adapters/gemini.cjs +81 -0
  45. package/scripts/lib/peer-cli/adapters/qwen.cjs +72 -0
  46. package/scripts/lib/peer-cli/asp-client.cjs +587 -0
  47. package/scripts/lib/peer-cli/broker-lifecycle.cjs +406 -0
  48. package/scripts/lib/peer-cli/registry.cjs +434 -0
  49. package/scripts/lib/peer-cli/spawn-cmd.cjs +149 -0
  50. package/scripts/lib/runtime-detect.cjs +96 -0
  51. package/scripts/lib/session-runner/index.ts +215 -0
  52. package/scripts/lib/session-runner/types.ts +60 -0
  53. package/scripts/lib/tier-resolver.cjs +311 -0
  54. package/scripts/validate-frontmatter.ts +297 -2
  55. package/skills/peer-cli-add/SKILL.md +170 -0
  56. package/skills/peer-cli-customize/SKILL.md +110 -0
  57. package/skills/peers/SKILL.md +101 -0
  58. package/skills/router/SKILL.md +51 -2
@@ -1,25 +1,35 @@
1
- # Model Prices — Static Price Table
1
+ # Model Prices — Router
2
2
 
3
- **Source of truth for `est_cost_usd` calculations** in the router (`skills/router/SKILL.md`) and budget-enforcer hook (`hooks/budget-enforcer.js`). Anthropic-only pricing. Update the table here when prices change downstream calculators read this file.
3
+ **Phase 26 D-08 router.** This file used to carry a single Anthropic-only price table. As of v1.26.0 it links to per-runtime sub-tables — one file per runtime under `reference/prices/`. Budget-enforcer + cost-aggregator load the sub-table for the active runtime (resolved via `scripts/lib/runtime-detect.cjs`) and tag every `events.jsonl` cost row with the runtime ID.
4
4
 
5
- ## Pricing (USD per 1M tokens)
5
+ For the model→tier mapping (which model name corresponds to opus/sonnet/haiku per runtime), see `reference/runtime-models.md`.
6
6
 
7
- | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
8
- |-------|------|--------------|---------------|----------------------|
9
- | claude-haiku-4-5 | haiku | 1.00 | 5.00 | 0.10 |
10
- | claude-sonnet-4-7 | sonnet | 3.00 | 15.00 | 0.30 |
11
- | claude-opus-4-7 | opus | 15.00 | 75.00 | 1.50 |
7
+ ## Per-runtime sub-tables
8
+
9
+ | Runtime | Path | Status |
10
+ |---------|------|--------|
11
+ | Claude Code | [`reference/prices/claude.md`](./prices/claude.md) | canonical (v1.26.0) |
12
+ | OpenAI Codex CLI | [`reference/prices/codex.md`](./prices/codex.md) | seed (v1.26.0; provenance `<TODO>`) |
13
+ | Google Gemini CLI | [`reference/prices/gemini.md`](./prices/gemini.md) | seed (v1.26.0; provenance `<TODO>`) |
14
+ | Alibaba Qwen CLI | [`reference/prices/qwen.md`](./prices/qwen.md) | seed (v1.26.0; provenance `<TODO>`) |
15
+ | Kilo Code | [`reference/prices/kilo.md`](./prices/kilo.md) | stub |
16
+ | GitHub Copilot CLI | [`reference/prices/copilot.md`](./prices/copilot.md) | stub |
17
+ | Cursor | [`reference/prices/cursor.md`](./prices/cursor.md) | stub |
18
+ | Windsurf | [`reference/prices/windsurf.md`](./prices/windsurf.md) | stub |
19
+ | Antigravity | [`reference/prices/antigravity.md`](./prices/antigravity.md) | stub |
20
+ | Augment Code | [`reference/prices/augment.md`](./prices/augment.md) | stub |
21
+ | Trae | [`reference/prices/trae.md`](./prices/trae.md) | stub |
22
+ | CodeBuddy | [`reference/prices/codebuddy.md`](./prices/codebuddy.md) | stub |
23
+ | Cline | [`reference/prices/cline.md`](./prices/cline.md) | stub |
24
+ | OpenCode | [`reference/prices/opencode.md`](./prices/opencode.md) | stub |
12
25
 
13
- ## size_budget conservative token ranges
26
+ **Sub-table format:** every file under `reference/prices/` carries the same canonical header row:
14
27
 
15
- Agent frontmatter carries `size_budget: S|M|L|XL`. The router uses these conservative token ranges to compute a pre-spawn `est_cost_usd` without a live model call:
28
+ ```
29
+ | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
30
+ ```
16
31
 
17
- | size_budget | input_tokens (conservative max) | output_tokens (conservative max) |
18
- |-------------|----------------------------------|-----------------------------------|
19
- | S | 4000 | 1000 |
20
- | M | 10000 | 2500 |
21
- | L | 25000 | 6000 |
22
- | XL | 60000 | 15000 |
32
+ Extra columns may be appended at the right edge by runtime adapter authors without breaking the parser (forward-compatible).
23
33
 
24
34
  ## Estimator formula
25
35
 
@@ -29,9 +39,20 @@ est_cost_usd =
29
39
  + (output_tokens / 1_000_000) * output_per_1m
30
40
  ```
31
41
 
32
- When `cache_hit: true` (see D-08), the hook re-runs the formula with `cached_input_per_1m` in place of `input_per_1m` for the input portion.
42
+ When `cache_hit: true`, the formula re-runs with `cached_input_per_1m` in place of `input_per_1m` for the input portion. See `skills/router/SKILL.md` (D-08) for the cache-hit semantics.
43
+
44
+ ## Fallback chain (D-08)
45
+
46
+ When a cost lookup misses (model not present in the runtime's sub-table, or runtime sub-table is a stub), `scripts/lib/budget-enforcer.cjs` falls back to `reference/prices/claude.md` and emits a `cost_lookup_fallback` event. This keeps the pipeline running on stub runtimes while authority-watcher (Phase 13.2) flags drift for follow-up.
47
+
48
+ If `claude.md` ALSO misses the model, the spawn proceeds with `cost_usd: null` and a `cost_lookup_failed` event — the existing fail-open contract from Phase 20-13.
49
+
50
+ ## Transitional fallback (v1.25 and earlier)
51
+
52
+ For v1.25.x and earlier the single Anthropic price table lived inline in this file. That table is preserved at `reference/prices/claude.md` byte-for-byte (as of the v1.26.0 split, modulo the surrounding prose). Hooks/skills that pinned to specific row strings should rebase those references to the new path.
33
53
 
34
54
  ## Update protocol
35
55
 
36
- 1. Pricing change: update the table above; commit as `chore(reference): update Anthropic pricing YYYY-MM-DD`.
37
- 2. size_budget revision: requires a Phase 11 reflector proposal under `[FRONTMATTER]` scope; do not hand-edit agent ranges.
56
+ 1. Pricing change for a single runtime: edit only that runtime's file in `reference/prices/`. Commit as `chore(reference/prices/<runtime>): update <runtime> pricing YYYY-MM-DD`.
57
+ 2. New runtime added to the 14-runtime map (`scripts/lib/install/runtimes.cjs` + `reference/runtime-models.md`): create `reference/prices/<runtime>.md`, add a row to the table above, and add a `reference/registry.json` entry under `type: "data"`.
58
+ 3. size_budget revisions: requires a Phase 11 reflector proposal under `[FRONTMATTER]` scope. Token ranges are runtime-neutral and live in `reference/prices/claude.md` as the canonical reference.
@@ -0,0 +1,151 @@
1
+ # Peer-CLI Capabilities
2
+
3
+ Last verified: 2026-04-29
4
+
5
+ Authoritative capability matrix for the peer-CLI delegation layer (Phase 27).
6
+ The registry at `scripts/lib/peer-cli/registry.cjs` reads this map (encoded as
7
+ data in the `.cjs` source — this doc is the human-readable mirror) to decide
8
+ which peer-CLI claims which agent role and which protocol to speak.
9
+
10
+ If you change this matrix, you MUST also change `CAPABILITY_MATRIX` in
11
+ `scripts/lib/peer-cli/registry.cjs` and re-run `tests/peer-cli-registry.test.cjs`.
12
+ The two are version-locked by Phase 27 D-05.
13
+
14
+ ## Capability matrix
15
+
16
+ Each peer claims a fixed set of agent roles. The registry refuses to dispatch
17
+ a role to a peer that does not claim it — this prevents accidental
18
+ mis-delegations like "let's try `design-auditor` against Qwen" that produce
19
+ garbage output (Phase 27 CONTEXT D-05).
20
+
21
+ | Peer | Protocol | Claimed roles | Slash commands (within peer CLI) |
22
+ | --- | --- | --- | --- |
23
+ | `codex` | ASP | `execute` | `/exec` |
24
+ | `copilot` | ACP | `review`, `research` | `/review`, `/search` |
25
+ | `cursor` | ACP | `debug`, `plan` | `/debug`, `/plan` |
26
+ | `gemini` | ACP | `research`, `exploration` | `/search`, `/explore` |
27
+ | `qwen` | ACP | `write` | `/write` |
28
+
29
+ Slash-command translation lives in each per-peer adapter
30
+ (`scripts/lib/peer-cli/adapters/<peer>.cjs`, landed by Plan 27-04). The
31
+ registry never invokes slash commands directly — it routes the role and
32
+ delegates prompt-prefixing + slash translation to the adapter.
33
+
34
+ ## Tie-breaking when two peers claim the same role
35
+
36
+ `research` is claimed by both `gemini` and `copilot`. When the registry's
37
+ `findPeerFor('research', tier)` runs, it walks peers in alphabetical order
38
+ of peer ID — `codex` < `copilot` < `cursor` < `gemini` < `qwen` — and
39
+ returns the first one that passes the health probe. So `copilot` wins
40
+ `research` over `gemini` when both are installed and allowlisted.
41
+
42
+ Users can override this by removing one of the two from
43
+ `.design/config.json#peer_cli.enabled_peers` — the unlisted peer is treated
44
+ as absent regardless of installation status (Phase 27 D-11 opt-in gating).
45
+
46
+ ## Opt-in gating (D-11)
47
+
48
+ A peer is dispatched to ONLY when:
49
+
50
+ 1. The peer ID appears in `.design/config.json#peer_cli.enabled_peers`
51
+ (an array of allowlisted peer IDs). Default: `[]` — empty, nothing
52
+ dispatches.
53
+ 2. The peer's adapter module loads at `scripts/lib/peer-cli/adapters/<peer>.cjs`.
54
+ 3. The adapter's `peerBinary()` resolver returns a path that exists on disk.
55
+
56
+ Failure on any of the three → registry returns `null` and the caller
57
+ (session-runner, Plan 27-06) falls back to the local Anthropic SDK call.
58
+ This is the **transparent-fallback** contract from Phase 27 D-07: a missing
59
+ or broken peer must never break the cycle.
60
+
61
+ ## Per-peer notes
62
+
63
+ ### `codex` (ASP)
64
+
65
+ OpenAI Codex CLI invoked as `codex app-server`. Speaks the App Server
66
+ Protocol — thread-oriented, supports resume across calls (currently unused;
67
+ v1.27 always starts fresh threads).
68
+
69
+ - **Provenance:** runtime entry in `scripts/lib/install/runtimes.cjs` (`id: 'codex'`).
70
+ - **Example invocation:** registry routes `(role='execute', tier='opus', text='apply this diff')`
71
+ through `adapters/codex.cjs`, which in turn drives `asp-client.cjs`.
72
+ - **Known limitations:** Codex' app-server cold start is ~1-2s on macOS;
73
+ the broker (Plan 27-03) keeps the session warm across cycles to amortize.
74
+
75
+ ### `gemini` (ACP)
76
+
77
+ Google Gemini CLI invoked in ACP mode. One-shot prompt per call from the
78
+ host's perspective, but the adapter may multiplex many calls onto a single
79
+ broker session.
80
+
81
+ - **Provenance:** runtime entry in `scripts/lib/install/runtimes.cjs` (`id: 'gemini'`).
82
+ - **Example invocation:** registry routes `(role='research', tier='sonnet', text='find prior art for X')`
83
+ through `adapters/gemini.cjs`.
84
+ - **Known limitations:** rate-limit headers vary by Gemini auth tier. The
85
+ adapter surfaces a 429 as a peer-error → registry returns null → caller
86
+ falls back. No retry logic at the registry level.
87
+
88
+ ### `cursor` (ACP)
89
+
90
+ Cursor's `cursor` CLI in ACP mode. Strong on `debug` and `plan` roles
91
+ because Cursor's editor-side context tracking transfers well to those
92
+ workflows.
93
+
94
+ - **Provenance:** runtime entry in `scripts/lib/install/runtimes.cjs` (`id: 'cursor'`).
95
+ - **Known limitations:** Cursor' ACP mode requires an active Cursor login
96
+ on the host; an unauthenticated session surfaces as a connect-time error.
97
+
98
+ ### `copilot` (ACP)
99
+
100
+ GitHub Copilot CLI in ACP mode. Claims `review` and `research`. Tends to
101
+ win `research` against `gemini` on alphabetical tie-break — users who
102
+ prefer Gemini for research should remove `copilot` from `enabled_peers`.
103
+
104
+ - **Provenance:** runtime entry in `scripts/lib/install/runtimes.cjs` (`id: 'copilot'`).
105
+ - **Known limitations:** Copilot's `review` role expects a diff in the
106
+ prompt; the adapter handles the framing.
107
+
108
+ ### `qwen` (ACP)
109
+
110
+ Alibaba Qwen Code CLI in ACP mode. Claims `write` only. Useful when the
111
+ session-runner wants a long-form code-generation pass and the host runtime
112
+ is on a low tier.
113
+
114
+ - **Provenance:** runtime entry in `scripts/lib/install/runtimes.cjs` (`id: 'qwen'`).
115
+ - **Known limitations:** Qwen's ACP implementation is the newest of the
116
+ five; expect occasional protocol-version drift. The adapter pins
117
+ `protocolVersion: '2025-06-18'` per `acp-client.cjs` defaults.
118
+
119
+ ## Adding a new peer
120
+
121
+ To add a new peer-CLI to the matrix:
122
+
123
+ 1. Run the guided ladder in `skills/peer-cli-add/SKILL.md` (lands with
124
+ Plan 27-10). It walks the protocol-fit check, the role-claim audit, the
125
+ adapter scaffold, and the test coverage required.
126
+ 2. Append the peer to `CAPABILITY_MATRIX` in `scripts/lib/peer-cli/registry.cjs`
127
+ AND to the table at the top of this file. The two MUST stay in sync —
128
+ the test suite (`tests/peer-cli-registry.test.cjs`) asserts the matrix
129
+ shape.
130
+ 3. Add a `<peer>.cjs` adapter under `scripts/lib/peer-cli/adapters/`.
131
+ 4. Add a `peerBinary?: string` field on the corresponding entry in
132
+ `scripts/lib/install/runtimes.cjs` (Plan 27-11 introduces the field;
133
+ new peers added after that plan ships must include it).
134
+ 5. Update `tests/peer-cli-registry.test.cjs` and the phase-20 baseline locks.
135
+
136
+ To temporarily disable a peer without removing the adapter, drop the peer
137
+ ID from `.design/config.json#peer_cli.enabled_peers`. To permanently remove
138
+ a peer, reverse the steps above plus update `tests/phase-27-baseline.test.cjs`.
139
+
140
+ ## Cross-references
141
+
142
+ - `scripts/lib/peer-cli/registry.cjs` — central dispatch, single source of
143
+ truth for the capability matrix as code.
144
+ - `scripts/lib/peer-cli/adapters/*.cjs` — per-peer thin adapters
145
+ (Plan 27-04).
146
+ - `scripts/lib/peer-cli/{acp,asp}-client.cjs` — protocol clients
147
+ (Plans 27-01 / 27-02).
148
+ - `scripts/lib/peer-cli/broker-lifecycle.cjs` — long-lived session per
149
+ `(peer, workspace)` (Plan 27-03).
150
+ - Phase 27 CONTEXT.md — decision log including D-05 (this matrix),
151
+ D-07 (transparent fallback), D-11 (opt-in gating).
@@ -0,0 +1,266 @@
1
+ # Peer-CLI Protocols — ACP + ASP Cheat Sheet
2
+
3
+ **Phase 27 (v1.27.0).** This file is the protocol-level reference for gdd's peer-CLI delegation layer. If you're authoring a new peer adapter or debugging a protocol-level issue, start here.
4
+
5
+ For ops-level guidance (when delegation fires, how to enable/disable, fallback diagnostics), see `docs/PEER-DELEGATION.md`.
6
+
7
+ Protocol shapes are adapted from [`greenpolo/cc-multi-cli`](https://github.com/greenpolo/cc-multi-cli) under Apache 2.0 — see `NOTICE` for full attribution.
8
+
9
+ ---
10
+
11
+ ## Two protocols, two transports
12
+
13
+ | Protocol | Used by | Transport | Lifecycle |
14
+ |----------|---------|-----------|-----------|
15
+ | **ACP** (Agent Client Protocol) | Gemini, Cursor, Copilot, Qwen | Line-delimited JSON-RPC over stdio | Per-prompt request/response |
16
+ | **ASP** (App Server Protocol) | Codex | Line-delimited JSON-RPC over stdio | Thread-oriented, multi-turn |
17
+
18
+ Both protocols use the same line-delimited JSON-RPC framing (one JSON message per `\n`-terminated line on stdin/stdout). Both can be wrapped by gdd's broker (`scripts/lib/peer-cli/broker-lifecycle.cjs`) for long-lived sessions per `(peer, workspace)`.
19
+
20
+ Line-buffer overflow guard: 16 MiB per line (both clients reject lines longer than this with a structured error).
21
+
22
+ ---
23
+
24
+ ## ACP — Agent Client Protocol
25
+
26
+ ### Initialize handshake
27
+
28
+ Client → server, first message after spawn:
29
+
30
+ ```json
31
+ {
32
+ "id": 1,
33
+ "jsonrpc": "2.0",
34
+ "method": "initialize",
35
+ "params": {
36
+ "protocolVersion": "2025-06-18",
37
+ "clientCapabilities": {}
38
+ }
39
+ }
40
+ ```
41
+
42
+ Server → client (reply correlated by `id`):
43
+
44
+ ```json
45
+ {
46
+ "id": 1,
47
+ "jsonrpc": "2.0",
48
+ "result": {
49
+ "protocolVersion": "2025-06-18",
50
+ "serverCapabilities": { "...": "..." }
51
+ }
52
+ }
53
+ ```
54
+
55
+ If `serverCapabilities.protocolVersion` does not match the client's, the client logs a `protocol_mismatch` event and aborts the session.
56
+
57
+ ### Prompt method
58
+
59
+ Client → server:
60
+
61
+ ```json
62
+ {
63
+ "id": 2,
64
+ "jsonrpc": "2.0",
65
+ "method": "prompt",
66
+ "params": {
67
+ "text": "Research best React state libs"
68
+ }
69
+ }
70
+ ```
71
+
72
+ Server → client streams notifications (no `id`, no `result`) until the final `result` for the prompt's `id`:
73
+
74
+ ```json
75
+ { "jsonrpc": "2.0", "method": "agent_message_chunk", "params": { "text": "..." } }
76
+ { "jsonrpc": "2.0", "method": "tool_call", "params": { "tool": "...", "input": "..." } }
77
+ { "jsonrpc": "2.0", "method": "file_change", "params": { "path": "...", "diff": "..." } }
78
+ { "id": 2, "jsonrpc": "2.0", "result": { "content": "...", "finish_reason": "stop", "usage": { "input_tokens": 1234, "output_tokens": 5678 } } }
79
+ ```
80
+
81
+ Notifications are surfaced via the `onNotification` callback the gdd caller passes:
82
+
83
+ ```js
84
+ const result = await acpClient.prompt('Research ...', {
85
+ onNotification: (n) => console.log(n.method, n.params),
86
+ });
87
+ ```
88
+
89
+ ### Per-peer ACP entry points
90
+
91
+ Each peer documents its own way to enter ACP mode:
92
+
93
+ - **Gemini**: `gemini acp` (subcommand).
94
+ - **Cursor**: `cursor-agent acp` (subcommand on the CLI binary, not the IDE).
95
+ - **Copilot**: `copilot --acp` (flag).
96
+ - **Qwen**: `qwen acp` (subcommand).
97
+
98
+ Verify via the `peer-cli-add` skill's verification ladder (Step 1) before adding a new peer.
99
+
100
+ ---
101
+
102
+ ## ASP — App Server Protocol (Codex)
103
+
104
+ ### Service identification
105
+
106
+ Client → server, declared during initial communication:
107
+
108
+ - `service_name = "gdd_peer_delegation"` (the canonical service identifier gdd uses)
109
+ - `experimentalRawEvents = false` (we don't want raw model-token events; just structured turn output)
110
+
111
+ These fields appear in both `threadStart` params and (where relevant) in handshake metadata.
112
+
113
+ ### Thread lifecycle
114
+
115
+ ASP is thread-oriented. Each conversation has a `threadId`; turns happen within a thread.
116
+
117
+ #### threadStart
118
+
119
+ Client → server:
120
+
121
+ ```json
122
+ {
123
+ "id": 1,
124
+ "jsonrpc": "2.0",
125
+ "method": "threadStart",
126
+ "params": {
127
+ "service_name": "gdd_peer_delegation",
128
+ "experimentalRawEvents": false
129
+ }
130
+ }
131
+ ```
132
+
133
+ Server → client:
134
+
135
+ ```json
136
+ {
137
+ "id": 1,
138
+ "jsonrpc": "2.0",
139
+ "result": {
140
+ "threadId": "thread-abc123"
141
+ }
142
+ }
143
+ ```
144
+
145
+ #### threadResume
146
+
147
+ Useful for cross-cycle conversation continuity (out of scope for v1.27.0 — gdd always creates fresh threads per delegated call — but the API surface exists):
148
+
149
+ ```json
150
+ {
151
+ "id": 2,
152
+ "jsonrpc": "2.0",
153
+ "method": "threadResume",
154
+ "params": { "threadId": "thread-abc123" }
155
+ }
156
+ ```
157
+
158
+ Server replies with the thread's current state (turn history, last-known result).
159
+
160
+ #### turn
161
+
162
+ Client → server:
163
+
164
+ ```json
165
+ {
166
+ "id": 3,
167
+ "jsonrpc": "2.0",
168
+ "method": "turn",
169
+ "params": {
170
+ "threadId": "thread-abc123",
171
+ "text": "Execute the build command"
172
+ }
173
+ }
174
+ ```
175
+
176
+ Server streams turn-progress notifications, ends with a structured result:
177
+
178
+ **Completion path:**
179
+
180
+ ```json
181
+ {
182
+ "id": 3,
183
+ "jsonrpc": "2.0",
184
+ "result": {
185
+ "threadId": "thread-abc123",
186
+ "turnId": "turn-xyz",
187
+ "status": "complete",
188
+ "content": "...",
189
+ "usage": { "input_tokens": 1234, "output_tokens": 5678 }
190
+ }
191
+ }
192
+ ```
193
+
194
+ **Error path** (does NOT throw on the client side — resolves with the error structure):
195
+
196
+ ```json
197
+ {
198
+ "id": 3,
199
+ "jsonrpc": "2.0",
200
+ "result": {
201
+ "threadId": "thread-abc123",
202
+ "turnId": "turn-xyz",
203
+ "status": "error",
204
+ "error": {
205
+ "code": "rate_limit",
206
+ "message": "Rate limit exceeded for thread-abc123"
207
+ }
208
+ }
209
+ }
210
+ ```
211
+
212
+ The caller decides retry vs fallback per session-runner contract — gdd's session-runner falls back to local Anthropic on `status: "error"` per D-07.
213
+
214
+ ### Codex ASP entry point
215
+
216
+ `codex app-server` (subcommand on the Codex CLI binary).
217
+
218
+ ---
219
+
220
+ ## Common framing rules (both protocols)
221
+
222
+ ### Line-delimited JSON-RPC
223
+
224
+ - Each message is a single JSON object on stdin/stdout, terminated by `\n`.
225
+ - Multiple messages may arrive in one chunk → client buffers until `\n`.
226
+ - One message may split across chunks → client buffers until `\n`.
227
+ - Lines longer than **16 MiB** are rejected with a structured error (the line buffer overflows, the client tears down and rejects all pending promises).
228
+
229
+ ### Request/response correlation
230
+
231
+ - Requests carry `id` (monotonic integer per session).
232
+ - Responses carry the same `id` in `result` or `error`.
233
+ - Notifications have no `id` and no `result` — they are routed to the active request's `onNotification` callback (each protocol allows only one "active" request at a time per session — half-duplex).
234
+
235
+ ### Process lifecycle
236
+
237
+ - The peer process is spawned via `scripts/lib/peer-cli/spawn-cmd.cjs` (handles Windows `.cmd` EINVAL workaround per D-04).
238
+ - The client connects directly OR through gdd's broker (`broker-lifecycle.cjs`) — both surfaces present the same `{initialize, prompt, close}` (ACP) or `{threadStart, threadResume, turn, close}` (ASP) API.
239
+ - On process death mid-request, the client rejects the in-flight promise with a structured `{error_class: "process_exited"}` event for telemetry.
240
+
241
+ ---
242
+
243
+ ## Adding a new protocol
244
+
245
+ gdd v1.27.0 ships only ACP and ASP. If a new peer speaks neither (e.g., a future REST-only or HTTP/2-streaming protocol), the path forward is:
246
+
247
+ 1. Document the gap in `.design/RESEARCH.md` for a future phase to scope a new protocol layer.
248
+ 2. Do **not** stretch ACP/ASP to fit — they're documented contracts, not generalist multiplexers.
249
+ 3. The `peer-cli-add` skill (Step 1's verification ladder) refuses to scaffold a peer that doesn't speak ACP or ASP — by design.
250
+
251
+ A future phase may add a new `scripts/lib/peer-cli/<protocol>-client.cjs` mirror following the same shape (line-buffer + JSON-RPC framing if applicable, or whatever the new protocol natively uses).
252
+
253
+ ---
254
+
255
+ ## Cross-references
256
+
257
+ - `scripts/lib/peer-cli/acp-client.cjs` — ACP client implementation.
258
+ - `scripts/lib/peer-cli/asp-client.cjs` — ASP client implementation.
259
+ - `scripts/lib/peer-cli/spawn-cmd.cjs` — Windows `.cmd` EINVAL workaround.
260
+ - `scripts/lib/peer-cli/broker-lifecycle.cjs` — long-lived broker.
261
+ - `scripts/lib/peer-cli/adapters/*.cjs` — per-peer thin wrappers.
262
+ - `scripts/lib/peer-cli/registry.cjs` — central dispatch.
263
+ - `tests/peer-cli-{acp,asp,spawn,registry,adapters}.test.cjs` — protocol-level tests.
264
+ - `docs/PEER-DELEGATION.md` — ops guide.
265
+ - `NOTICE` — Apache 2.0 attribution for cc-multi-cli.
266
+ - `.planning/phases/27-peer-cli-delegation/CONTEXT.md` — decision lineage (D-01, D-02, D-03, D-04).
@@ -0,0 +1,21 @@
1
+ # Antigravity — Price Table (stub)
2
+
3
+ **Runtime:** `antigravity` (Antigravity)
4
+ **Phase 26 D-08 sub-table — STUB.** Placeholder so the price-table router (`reference/model-prices.md`) has a complete link list for all 14 runtimes. Runtime adapter authors fill this in with provenance citations in a later cycle.
5
+
6
+ **Provenance:** `<TODO: confirm at https://antigravity.google/docs>` — pending.
7
+
8
+ ## Pricing (USD per 1M tokens)
9
+
10
+ | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
11
+ |-------|------|--------------|---------------|----------------------|
12
+ | _TBD_ | opus | <TODO> | <TODO> | <TODO> |
13
+ | _TBD_ | sonnet | <TODO> | <TODO> | <TODO> |
14
+ | _TBD_ | haiku | <TODO> | <TODO> | <TODO> |
15
+
16
+ The budget-enforcer treats unparseable rows as missing and falls back to `reference/prices/claude.md` per the D-08 fallback chain.
17
+
18
+ ## Update protocol
19
+
20
+ 1. Confirm authoritative numbers at the runtime author's pricing docs and update; remove `<TODO>` tags.
21
+ 2. Add provenance citation matching the `reference/runtime-models.md` row for `id: "antigravity"`.
@@ -0,0 +1,21 @@
1
+ # Augment Code — Price Table (stub)
2
+
3
+ **Runtime:** `augment` (Augment Code)
4
+ **Phase 26 D-08 sub-table — STUB.** Placeholder so the price-table router (`reference/model-prices.md`) has a complete link list for all 14 runtimes. Runtime adapter authors fill this in with provenance citations in a later cycle.
5
+
6
+ **Provenance:** `<TODO: confirm at https://docs.augmentcode.com>` — pending.
7
+
8
+ ## Pricing (USD per 1M tokens)
9
+
10
+ | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
11
+ |-------|------|--------------|---------------|----------------------|
12
+ | _TBD_ | opus | <TODO> | <TODO> | <TODO> |
13
+ | _TBD_ | sonnet | <TODO> | <TODO> | <TODO> |
14
+ | _TBD_ | haiku | <TODO> | <TODO> | <TODO> |
15
+
16
+ The budget-enforcer treats unparseable rows as missing and falls back to `reference/prices/claude.md` per the D-08 fallback chain.
17
+
18
+ ## Update protocol
19
+
20
+ 1. Confirm authoritative numbers at the runtime author's pricing docs and update; remove `<TODO>` tags.
21
+ 2. Add provenance citation matching the `reference/runtime-models.md` row for `id: "augment"`.
@@ -0,0 +1,42 @@
1
+ # Anthropic — Claude Code Price Table
2
+
3
+ **Runtime:** `claude` (Claude Code)
4
+ **Phase 26 D-08 sub-table.** Authoritative pricing for the Anthropic models referenced in `reference/runtime-models.md` under `id: "claude"`. Read by `scripts/lib/budget-enforcer.cjs` (and indirectly by `hooks/budget-enforcer.ts`) to compute `est_cost_usd` per spawn.
5
+
6
+ **Provenance:** https://docs.anthropic.com/en/docs/about-claude/pricing — retrieved 2026-04-29, cycle `2026-04-29-v1.26`.
7
+
8
+ ## Pricing (USD per 1M tokens)
9
+
10
+ | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
11
+ |-------|------|--------------|---------------|----------------------|
12
+ | claude-haiku-4-5 | haiku | 1.00 | 5.00 | 0.10 |
13
+ | claude-sonnet-4-7 | sonnet | 3.00 | 15.00 | 0.30 |
14
+ | claude-sonnet-4-6 | sonnet | 3.00 | 15.00 | 0.30 |
15
+ | claude-opus-4-7 | opus | 15.00 | 75.00 | 1.50 |
16
+
17
+ ## size_budget → conservative token ranges
18
+
19
+ Agent frontmatter carries `size_budget: S|M|L|XL`. The router uses these conservative token ranges to compute a pre-spawn `est_cost_usd` without a live model call:
20
+
21
+ | size_budget | input_tokens (conservative max) | output_tokens (conservative max) |
22
+ |-------------|----------------------------------|-----------------------------------|
23
+ | S | 4000 | 1000 |
24
+ | M | 10000 | 2500 |
25
+ | L | 25000 | 6000 |
26
+ | XL | 60000 | 15000 |
27
+
28
+ ## Estimator formula
29
+
30
+ ```
31
+ est_cost_usd =
32
+ (input_tokens / 1_000_000) * input_per_1m
33
+ + (output_tokens / 1_000_000) * output_per_1m
34
+ ```
35
+
36
+ When `cache_hit: true`, the formula re-runs with `cached_input_per_1m` in place of `input_per_1m` for the input portion.
37
+
38
+ ## Update protocol
39
+
40
+ 1. Pricing change: update the table above; commit as `chore(reference/prices): update Anthropic pricing YYYY-MM-DD`.
41
+ 2. New model name added to `reference/runtime-models.md` under `id: "claude"`: add a row here with the same model string in the `Model` column. Tier comes from the canonical `tier_to_model` mapping.
42
+ 3. size_budget revision: requires a Phase 11 reflector proposal under `[FRONTMATTER]` scope; do not hand-edit agent ranges.
@@ -0,0 +1,23 @@
1
+ # Cline — Price Table (stub)
2
+
3
+ **Runtime:** `cline` (Cline)
4
+ **Phase 26 D-08 sub-table — STUB.** Placeholder so the price-table router (`reference/model-prices.md`) has a complete link list for all 14 runtimes. Runtime adapter authors fill this in with provenance citations in a later cycle.
5
+
6
+ **Provenance:** `<TODO: confirm at https://docs.cline.bot>` — pending.
7
+
8
+ **Note:** Cline is a BYO-API-key runtime — actual pricing is determined by whichever provider key the user supplies. The `tier_to_model` row in `reference/runtime-models.md` chooses a default model per tier; this table prices that default. Users of other providers should override locally.
9
+
10
+ ## Pricing (USD per 1M tokens)
11
+
12
+ | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
13
+ |-------|------|--------------|---------------|----------------------|
14
+ | _TBD_ | opus | <TODO> | <TODO> | <TODO> |
15
+ | _TBD_ | sonnet | <TODO> | <TODO> | <TODO> |
16
+ | _TBD_ | haiku | <TODO> | <TODO> | <TODO> |
17
+
18
+ The budget-enforcer treats unparseable rows as missing and falls back to `reference/prices/claude.md` per the D-08 fallback chain.
19
+
20
+ ## Update protocol
21
+
22
+ 1. Confirm authoritative numbers at the runtime author's pricing docs and update; remove `<TODO>` tags.
23
+ 2. Add provenance citation matching the `reference/runtime-models.md` row for `id: "cline"`.
@@ -0,0 +1,21 @@
1
+ # CodeBuddy — Price Table (stub)
2
+
3
+ **Runtime:** `codebuddy` (Tencent CodeBuddy)
4
+ **Phase 26 D-08 sub-table — STUB.** Placeholder so the price-table router (`reference/model-prices.md`) has a complete link list for all 14 runtimes. Runtime adapter authors fill this in with provenance citations in a later cycle.
5
+
6
+ **Provenance:** `<TODO: confirm at https://copilot.tencent.com>` — pending.
7
+
8
+ ## Pricing (USD per 1M tokens)
9
+
10
+ | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
11
+ |-------|------|--------------|---------------|----------------------|
12
+ | _TBD_ | opus | <TODO> | <TODO> | <TODO> |
13
+ | _TBD_ | sonnet | <TODO> | <TODO> | <TODO> |
14
+ | _TBD_ | haiku | <TODO> | <TODO> | <TODO> |
15
+
16
+ The budget-enforcer treats unparseable rows as missing and falls back to `reference/prices/claude.md` per the D-08 fallback chain.
17
+
18
+ ## Update protocol
19
+
20
+ 1. Confirm authoritative numbers at the runtime author's pricing docs and update; remove `<TODO>` tags.
21
+ 2. Add provenance citation matching the `reference/runtime-models.md` row for `id: "codebuddy"`.
@@ -0,0 +1,25 @@
1
+ # OpenAI — Codex CLI Price Table
2
+
3
+ **Runtime:** `codex` (OpenAI Codex CLI)
4
+ **Phase 26 D-08 sub-table.** Pricing for the OpenAI Codex tier referenced in `reference/runtime-models.md` under `id: "codex"`.
5
+
6
+ **Provenance:** `<TODO: confirm at https://openai.com/api/pricing/>` — retrieved 2026-04-29 (placeholder — v1.26.0 ships with seed numbers; runtime adapter authors confirm and PR before v1.27).
7
+
8
+ **Status:** placeholder values are taken from public OpenAI tier-positioning at the time of v1.26.0 ship. The cost-aggregator will surface drift if measured spend per spawn diverges from these figures by more than 20% after 10+ cycles.
9
+
10
+ ## Pricing (USD per 1M tokens)
11
+
12
+ | Model | Tier | input_per_1m | output_per_1m | cached_input_per_1m |
13
+ |-------|------|--------------|---------------|----------------------|
14
+ | gpt-5 | opus | 1.25 | 10.00 | 0.13 |
15
+ | gpt-5-mini | sonnet | 0.25 | 2.00 | 0.03 |
16
+ | gpt-5-nano | haiku | 0.05 | 0.40 | 0.01 |
17
+
18
+ ## Estimator formula
19
+
20
+ Same shape as `reference/prices/claude.md`; see that file for the formula and `size_budget` ranges. Token ranges are runtime-neutral.
21
+
22
+ ## Update protocol
23
+
24
+ 1. Confirm authoritative numbers at https://openai.com/api/pricing/ and update the table; remove the `<TODO>` provenance tag.
25
+ 2. New model added to `reference/runtime-models.md` under `id: "codex"`: add a row here with the matching model string and tier.