greprag 5.60.4 → 5.60.6

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 (100) hide show
  1. package/dist/codex-chip-hooks.d.ts +2 -7
  2. package/dist/codex-chip-hooks.js +29 -153
  3. package/dist/codex-chip-hooks.js.map +1 -1
  4. package/dist/codex-steering.d.ts +2 -1
  5. package/dist/codex-steering.js +8 -5
  6. package/dist/codex-steering.js.map +1 -1
  7. package/dist/commands/codex-chip/bootstrap.d.ts +12 -0
  8. package/dist/commands/codex-chip/bootstrap.js +114 -0
  9. package/dist/commands/codex-chip/bootstrap.js.map +1 -0
  10. package/dist/commands/codex-chip/breakthrough-command.js +0 -7
  11. package/dist/commands/codex-chip/breakthrough-command.js.map +1 -1
  12. package/dist/commands/codex-chip/cleanup-command.js +21 -11
  13. package/dist/commands/codex-chip/cleanup-command.js.map +1 -1
  14. package/dist/commands/codex-chip/command.js +27 -49
  15. package/dist/commands/codex-chip/command.js.map +1 -1
  16. package/dist/commands/codex-chip/git.d.ts +19 -4
  17. package/dist/commands/codex-chip/git.js +82 -14
  18. package/dist/commands/codex-chip/git.js.map +1 -1
  19. package/dist/commands/codex-chip/goals.d.ts +9 -9
  20. package/dist/commands/codex-chip/goals.js +33 -73
  21. package/dist/commands/codex-chip/goals.js.map +1 -1
  22. package/dist/commands/codex-chip/help.d.ts +1 -1
  23. package/dist/commands/codex-chip/help.js +14 -25
  24. package/dist/commands/codex-chip/help.js.map +1 -1
  25. package/dist/commands/codex-chip/lifecycle.d.ts +4 -1
  26. package/dist/commands/codex-chip/lifecycle.js +14 -3
  27. package/dist/commands/codex-chip/lifecycle.js.map +1 -1
  28. package/dist/commands/codex-chip/model.d.ts +5 -1
  29. package/dist/commands/codex-chip/model.js.map +1 -1
  30. package/dist/commands/codex-chip/naming.js +4 -10
  31. package/dist/commands/codex-chip/naming.js.map +1 -1
  32. package/dist/commands/codex-chip/native.js +11 -19
  33. package/dist/commands/codex-chip/native.js.map +1 -1
  34. package/dist/commands/codex-chip/prompt.d.ts +2 -1
  35. package/dist/commands/codex-chip/prompt.js +20 -57
  36. package/dist/commands/codex-chip/prompt.js.map +1 -1
  37. package/dist/commands/codex-chip/resume-command.js +1 -4
  38. package/dist/commands/codex-chip/resume-command.js.map +1 -1
  39. package/dist/commands/codex-chip/selection.js +14 -55
  40. package/dist/commands/codex-chip/selection.js.map +1 -1
  41. package/dist/commands/codex-chip/worker.js +114 -44
  42. package/dist/commands/codex-chip/worker.js.map +1 -1
  43. package/dist/commands/codex-delivery.d.ts +32 -7
  44. package/dist/commands/codex-delivery.js +76 -92
  45. package/dist/commands/codex-delivery.js.map +1 -1
  46. package/dist/commands/codex-startup.js +1 -1
  47. package/dist/commands/codex-startup.js.map +1 -1
  48. package/dist/commands/codex-watch-health.d.ts +11 -0
  49. package/dist/commands/codex-watch-health.js +54 -0
  50. package/dist/commands/codex-watch-health.js.map +1 -1
  51. package/dist/commands/codex.js +39 -33
  52. package/dist/commands/codex.js.map +1 -1
  53. package/dist/commands/friction-reminder.d.ts +9 -9
  54. package/dist/commands/friction-reminder.js +12 -17
  55. package/dist/commands/friction-reminder.js.map +1 -1
  56. package/dist/commands/inbox-primer-reminder.js +3 -3
  57. package/dist/commands/inbox-primer-reminder.js.map +1 -1
  58. package/dist/commands/init.js +7 -5
  59. package/dist/commands/init.js.map +1 -1
  60. package/dist/commands/load-primer-reminder.js +2 -2
  61. package/dist/commands/load-primer-reminder.js.map +1 -1
  62. package/dist/commands/load.js +28 -27
  63. package/dist/commands/load.js.map +1 -1
  64. package/dist/commands/mechanic-spawn.d.ts +10 -0
  65. package/dist/commands/mechanic-spawn.js +67 -0
  66. package/dist/commands/mechanic-spawn.js.map +1 -0
  67. package/dist/commands/mechanic.js +6 -0
  68. package/dist/commands/mechanic.js.map +1 -1
  69. package/dist/commands/opencode-chip-lifecycle.d.ts +2 -0
  70. package/dist/commands/opencode-chip-lifecycle.js +137 -0
  71. package/dist/commands/opencode-chip-lifecycle.js.map +1 -0
  72. package/dist/commands/opencode-chip-mission.js +19 -0
  73. package/dist/commands/opencode-chip-mission.js.map +1 -1
  74. package/dist/commands/opencode-chip-store.d.ts +19 -1
  75. package/dist/commands/opencode-chip-store.js.map +1 -1
  76. package/dist/commands/opencode-chip.js +30 -13
  77. package/dist/commands/opencode-chip.js.map +1 -1
  78. package/dist/commands/opencode-goals.d.ts +5 -0
  79. package/dist/commands/opencode-goals.js +83 -0
  80. package/dist/commands/opencode-goals.js.map +1 -0
  81. package/dist/hook.js +8 -3
  82. package/dist/hook.js.map +1 -1
  83. package/dist/index.js +5 -90
  84. package/dist/index.js.map +1 -1
  85. package/dist/opencode-plugin.bundle.js +9 -11
  86. package/package.json +1 -1
  87. package/skill/greprag/SKILL.md +2 -2
  88. package/skill/greprag/docs/codex-chip.md +20 -64
  89. package/skill/greprag/docs/setup.md +15 -21
  90. package/skill/mechanic/SKILL.md +24 -0
  91. package/skill/templates/chip-bootloader.md +15 -10
  92. package/skill/templates/chip-leader-opencode.md +64 -50
  93. package/skill/templates/chip-leader.md +81 -221
  94. package/skill/templates/codex-chip-spawn.md +150 -174
  95. package/skill/templates/codex-subagent-spawn.md +32 -0
  96. package/dist/commands/codex-native-delivery.d.ts +0 -70
  97. package/dist/commands/codex-native-delivery.js +0 -285
  98. package/dist/commands/codex-native-delivery.js.map +0 -1
  99. package/skill/templates/reflex-chip.md +0 -58
  100. package/skill/templates/workshop-chip.md +0 -46
@@ -56,21 +56,17 @@ but turns are not saving, the most likely cause is untrusted hooks or an old
56
56
  session that started before trust. Tell the user to open Codex Desktop Settings
57
57
  -> Settings -> Hooks, trust the GrepRAG commands, and restart Codex.
58
58
 
59
- Codex live inbox delivery requires the sidecar. Public installs should use the
60
- startup helper above. For foreground/manual testing:
59
+ Codex live inbox delivery uses the startup watcher. Public installs should use
60
+ the startup helper above. For foreground/manual testing:
61
61
 
62
62
  ```bash
63
63
  greprag codex watch --session <8hex-or-full-codex-session-id>
64
64
  ```
65
65
 
66
66
  If `--session` is omitted, it uses the latest Codex session recorded in
67
- `~/.codex/session_index.jsonl`. The sidecar stays attached to GrepRAG inbox SSE
68
- and routes agent-visible control through the nonce-bound BREAKTHROUGH protocol.
69
- Private app-server continuation may create the target turn, but success requires
70
- visible `BREAKTHROUGH_ACK:<nonce>` output; persisted history or an empty turn is
71
- not delivery. `codex exec resume <session> -` can append to Codex's thread store,
72
- but it is not a reliable visible wake in the active Desktop pane and must be
73
- treated as fallback/diagnostic only.
67
+ `~/.codex/session_index.jsonl`. `greprag send` persists messages; the startup
68
+ watcher drains unread messages + SSE and performs target-local task delivery.
69
+ Turn hooks surface stored unread messages at Codex turn/tool/session boundaries.
74
70
  Use `greprag codex startup status` to inspect the login entry and
75
71
  `greprag codex startup remove` to uninstall it.
76
72
 
@@ -83,18 +79,16 @@ On Windows, the watcher should run hidden. If the user sees a persistent
83
79
  `greprag codex startup install` to replace it with the hidden launcher. Logs
84
80
  live at `~/.greprag/logs/codex-watch.log`.
85
81
 
86
- `codex-notify` and `codex-inbox` remain fallback steering. If the sidecar is not
87
- running, messages are stored and can surface on the next user prompt or after a
88
- later tool call, but they do not wake idle Codex.
89
-
90
- Visible wake and live action are different checks. The sidecar may deliver a
91
- visible delegated turn to Codex, while that turn still fails to run commands if
92
- the local Codex sandbox is unhealthy. On native Windows, this can appear as
93
- `windows sandbox: spawn setup refresh`. If `greprag codex doctor --wake-test`
94
- reports only CLI-resume fallback or wake action as unsupported, describe live
95
- push as unconfirmed/non-visible and rely on turn-bound inbox steering until the
96
- app-layer path is available. Do not enable unsafe sandbox bypass as a public
97
- default.
82
+ `codex-notify` and `codex-inbox` remain turn-boundary steering. `greprag send`
83
+ always stores the ordinary message first. If the recipient task is live, use
84
+ native Codex task messaging to wake it and have that peer read/reply; if it is
85
+ not live, the row remains available for the next prompt. Only the recipient's
86
+ actual peer response proves delivery.
87
+
88
+ Target-local task delivery and command execution are separate checks. The
89
+ watcher can deliver stored work while the local Codex sandbox is unhealthy. On
90
+ native Windows, this can appear as `windows sandbox: spawn setup refresh`. Do
91
+ not enable unsafe sandbox bypass as a public default.
98
92
 
99
93
  ## claude-code
100
94
 
@@ -61,6 +61,30 @@ Same gate the hourly compactor applies at write-time — Mechanic and compactor
61
61
  - **Cross-project carve-out.** Default to the current project (resolved via `greprag fix list`). The Phase 0 census MAY read sibling queues to show where fixes piled up; *draining* one requires the operator to name it, and every `add`/`delete` against it MUST carry `--project <that-project>`. Never touch a sibling silently.
62
62
  - **Harness scope is mandatory.** Friction carries its source harness (`claude-code`, `codex`, `opencode`). Repairs to hooks/skills/watchers must target that harness with `greprag mechanic install ... --harness <name>`. In a Codex session, default to `--harness codex`; use `--harness all` only for deliberately portable mechanisms.
63
63
 
64
+ ## Codex Mechanic chip handoff
65
+
66
+ When this method is loaded inside a Codex task whose visible title is
67
+ `MECHANIC: <Mission>`, the harness is **Codex** and the task is already a
68
+ visible, ordinary writable Mechanic chip. Its scope is root-cause repair in the
69
+ Codex-provided checkout: inspect the live hooks/CLI, implement the reusable
70
+ repair, test it, commit it, and report DONE or BLOCKED to the parent. Do not
71
+ create another child or use an internal subagent unless the parent explicitly
72
+ changes that assignment.
73
+
74
+ The Codex control points are: native task/thread identity; the Codex-provided
75
+ worktree and cwd; the initial UserPromptSubmit binding; SessionStart/PostToolUse
76
+ context; and native parent-child completion. Preserve those boundaries while
77
+ repairing them--never silently turn the chip into a same-session subagent.
78
+
79
+ ABOUT TO dispatch or replace a visible Codex chip? STOP — load
80
+ `codex-chip-spawn` first and create the child with Codex Desktop's native
81
+ `codex_app__create_thread` project worktree target. For 1–2 children the current
82
+ task is the implicit LEAD; for more than two children or shared seams, load
83
+ `chip-leader` and create a separate `LEAD: <Mission>` that dispatches exact
84
+ `Chip A/B/C: <Specific Purview>` tasks.
85
+ `multi_agent_v1__spawn_agent` is only an ephemeral same-session subagent and
86
+ never satisfies a visible-chip requirement.
87
+
64
88
  ## Phase 0 — Fix digestion
65
89
 
66
90
  A fix is a raw, undigested signal. Auto-detected friction fixes carry a type; hand-dropped ones are freeform. Digestion does two jobs per fix — **repair** the mechanism and/or **record** the durable gotcha — and runs FIRST.
@@ -2,27 +2,32 @@
2
2
 
3
3
  No `spawn_task`? Use OpenCode Desktop HTTP spawn (preferred) or manual paste.
4
4
 
5
- ## Preferred: machine spawn
5
+ ## Preferred: quick chip (path A)
6
+
7
+ Initiator is LEAD — no separate LEAD session:
6
8
 
7
9
  ```bash
10
+ greprag opencode chip goal create \
11
+ --objective "…" --final-state "…" \
12
+ --criterion ship:… \
13
+ --owner-session <this-8hex> --owner-role leader
14
+
8
15
  greprag opencode chip spawn \
9
16
  --title "Purview Name" --role worker --label A \
10
- --goal-id <id> --covers <criterion> \
17
+ --goal-id <id> --covers ship \
11
18
  --task "…" \
12
19
  --parent-session <ses_…> --parent-greprag <8hex> \
13
20
  --model deepseek/deepseek-chat \
14
21
  --opencode-url http://127.0.0.1:<port> \
15
22
  --dispatch
16
- # → "Chip A: Purview Name" (multi: --label B, C…)
17
- # close: greprag opencode chip close <id|ses_> --summary "…"
23
+ # → "Chip A: Purview Name"
24
+ # close: report → goal accept → greprag opencode chip close <id|ses_>
18
25
  ```
19
26
 
20
- Full multi-chip roles: `greprag load chip-leader-opencode`.
21
- Fallback paste body + isolation notes: [docs/chip-bootloader-opencode.md](../../../docs/chip-bootloader-opencode.md)
22
-
23
- ## Multi-chip?
27
+ ## Multi-chip mission (path B)?
24
28
 
25
- ≥2 chips at one objective → STOP → `greprag load chip-leader-opencode` first.
29
+ ≥2 chips at one objective → STOP → `greprag load chip-leader-opencode`
30
+ (PLANNER → LEAD → nested goal → Chip A/B).
26
31
 
27
32
  ## Manual paste (API down only)
28
33
 
@@ -41,4 +46,4 @@ greprag send "DONE: … | commit=<sha> | checks=…" --to travis@greprag.com/<pa
41
46
  # or BLOCKED: …
42
47
  ```
43
48
 
44
- `--model` required. Report-back is greprag inbox, not the parent OpenCode chat transcript.
49
+ Workers always `--label A|B|C…`. `--model` required. Report-back is greprag inbox.
@@ -1,32 +1,53 @@
1
- # Chip Leader — OpenCode multi-chip (PLANNER → LEAD → workers)
1
+ # Chip Leader — OpenCode multi-chip (path B)
2
2
 
3
- > Loaded via `greprag load chip-leader-opencode`. One chip → `greprag load chip-bootloader` or `greprag opencode chip spawn`. ≥2 chips at one objective → plan here first.
3
+ > Loaded via `greprag load chip-leader-opencode` when ≥2 chips share one objective.
4
+ > **One chip (or two independent ones)?** Skip this — use the **quick path** in
5
+ > `chip-bootloader` / `greprag opencode chip --help` (initiator is LEAD).
4
6
 
5
- OpenCode has **no** `spawn_task`. Spawn is:
7
+ ## Two paths (both first-class)
6
8
 
7
- ```
8
- POST /session { parentID?, title } # Desktop HTTP API
9
- POST /session/{id}/prompt_async # mission + model
10
- greprag send → parent inbox # IN-FLIGHT / DONE / BLOCKED
11
- ```
9
+ | | **A — Quick** | **B — Mission (this doc)** |
10
+ |---|---|---|
11
+ | When | 1 chip, or independent jobs | ≥2 chips, seams, one objective |
12
+ | Who is LEAD | **Initiator** (this session) | Explicit `LEAD:` chip |
13
+ | Goal | `goal create --owner-role leader` owned by this 8-hex | PLANNER goal → nested LEAD goal |
14
+ | Spawn | `worker --label A` (solo = A) | LEAD dispatches Chip A/B… |
15
+ | Close | Parent accept + `close` | LEAD reconciles → accept → close |
12
16
 
13
- Wrapped by: **`greprag opencode chip spawn`** (prepare or `--dispatch`).
17
+ **Hard fire for B:** about to spawn the **2nd chip at one objective** → stop and plan here.
14
18
 
15
- ## Role ladder (same contracts as Codex)
19
+ ## Path A — Quick (default)
16
20
 
17
- | Title | Role | Job |
18
- |-------|------|-----|
19
- | `PLANNER: <Mission>` | planner | Creates mission goal + acceptance criteria; launches one LEAD; read-only |
20
- | `LEAD: <Mission>` | leader | Decomposition, child dispatch, integration, goal accept, closeout |
21
- | `Chip A: <Purview>` | worker | **Always** letter-titled (`--label A`); multi-chip uses A,B,C… never bare `Chip:` |
22
- | `ADVISOR: <Purview>` | advisor | Read-only; fundamental blocker only |
23
- | `MECHANIC: <Purview>` | mechanic | Live friction; not routine execution |
21
+ ```bash
22
+ greprag opencode chip goal create \
23
+ --objective "…" --final-state "…" \
24
+ --criterion ship:… \
25
+ --owner-session <this-greprag-8hex> \
26
+ --owner-role leader
24
27
 
25
- ## Mission flow
28
+ greprag opencode chip spawn \
29
+ --title "Purview" --role worker --label A \
30
+ --goal-id <id> --covers ship \
31
+ --task "…" \
32
+ --parent-session <this-ses_…> \
33
+ --parent-greprag <this-8hex> \
34
+ --model deepseek/deepseek-chat \
35
+ --opencode-url http://127.0.0.1:<port> \
36
+ --dispatch
37
+
38
+ # later:
39
+ greprag opencode chip report <chip> --summary "…" --evidence ship:…
40
+ greprag opencode chip goal accept <id> --owner-session <this-8hex> --summary "…"
41
+ greprag opencode chip close <chip> --summary "…"
42
+ ```
43
+
44
+ No separate LEAD chip. No bind-lead. Initiator owns the goal and closeout.
45
+
46
+ ## Path B — Mission flow
26
47
 
27
48
  1. **PLANNER** creates the mission goal (`--owner-role planner`).
28
- 2. Spawn **one LEAD** under that goal (`--role leader --covers …`). LEAD is write-capable.
29
- 3. LEAD creates a **nested** goal:
49
+ 2. Spawn **one LEAD** under that goal (`--role leader --covers …`).
50
+ 3. LEAD creates a **nested** goal + bind:
30
51
  ```bash
31
52
  greprag opencode chip goal create \
32
53
  --objective "…" --final-state "…" \
@@ -40,25 +61,24 @@ Wrapped by: **`greprag opencode chip spawn`** (prepare or `--dispatch`).
40
61
  ```
41
62
  4. LEAD spawns workers against the **nested** goal:
42
63
  `--role worker --label A --title "…" --goal-id <nested> --covers ship --parent-greprag <lead-8hex>`.
43
- 5. Workers: `IN-FLIGHT` → work → `DONE`/`BLOCKED`. Parent records evidence:
44
- `greprag opencode chip report <chip> --summary "…" --evidence ship:…`
45
- 6. Accept nested goal, then planner goal:
46
- `greprag opencode chip goal accept <id> --owner-session … --summary "…"`
47
- 7. Close chips (accept-gated):
48
- `greprag opencode chip close <chip|ses_> --summary "…"`
49
- (`--force` / `--keep-open-goal` escape hatches; `--keep-session` leaves Desktop tab)
64
+ 5. Workers: `IN-FLIGHT` → work → `DONE`/`BLOCKED`. Parent: `report --evidence …`.
65
+ 6. Accept nested goal, then planner goal; then `close` chips.
66
+
67
+ ## Role titles (exact)
68
+
69
+ `PLANNER: …` · `LEAD: …` · `Chip A: …` / `Chip B: …` · `ADVISOR: …` · `MECHANIC: …`
50
70
 
51
- ## Mode A vs Mode B (topology — still required)
71
+ Workers **always** `--label A|B|C…` (solo = A). Never bare `Chip:`.
52
72
 
53
- | | **Mode A — Mission** | **Mode B — Orchestrator** |
73
+ ## Mode A vs Mode B topology (still for path B)
74
+
75
+ | | **Mission topology** | **Orchestrator topology** |
54
76
  |---|---|---|
55
77
  | When | ≥2 chips, one objective | Independent issues |
56
- | Branch | Integration branch; chips merge into it | Per-chip / per-repo |
78
+ | Branch | Integration branch | Per-chip / per-repo |
57
79
  | Gate | One reviewed merge to master | Per-chip verify |
58
80
 
59
- **Hard fire:** about to spawn the 2nd chip → stop and plan.
60
-
61
- ## Spawn command (canonical)
81
+ ## Spawn flags (canonical)
62
82
 
63
83
  ```bash
64
84
  greprag opencode chip spawn \
@@ -69,31 +89,25 @@ greprag opencode chip spawn \
69
89
  --parent-session <ses_…> \
70
90
  --parent-greprag <8hex> \
71
91
  --model deepseek/deepseek-chat \
72
- --opencode-url http://127.0.0.1:<desktop-port> \
92
+ --opencode-url http://127.0.0.1:<port> \
73
93
  --dispatch
74
- # title becomes: Chip A: Auth Middleware
75
- # multi-chip: --multi-chip --label B --title "Other Purview" → Chip B: …
94
+ # → "Chip A: Auth Middleware"
76
95
  ```
77
96
 
78
- Close when done (deletes OpenCode session + archives record):
79
- ```bash
80
- greprag opencode chip close <chipId|ses_…> --summary "merged + verified"
81
- # --keep-session to leave the Desktop session
82
- ```
97
+ Close: `greprag opencode chip close <chipId|ses_> --summary "…"`
98
+ (`--keep-session` · `--force` · `--keep-open-goal`)
83
99
 
84
- - **Workers always `--label A|B|C…`** (solo = A). No bare `Chip:` titles.
85
- - **`--model` is required** (Desktop defaults can 401).
86
- - **`--top-level`** if you need a session list entry without nesting under parent.
87
- - Desktop **does not auto-focus** API-created sessions — open session list / cycle children after spawn.
88
- - Auth: `OPENCODE_SERVER_USERNAME` + `OPENCODE_SERVER_PASSWORD`.
100
+ - **`--model` required** (Desktop defaults can 401).
101
+ - **`--top-level`** if you need a session-list entry without nesting.
102
+ - Desktop **does not auto-focus** API-created sessions.
89
103
 
90
104
  ## Isolation
91
105
 
92
- Prefer a dedicated `chip/<slug>` branch per chip. Worktrees optional. Leases/manifests for OpenCode live under `~/.greprag/opencode-chips/` (v1 record). Goals share `~/.greprag/chip-goals/`.
106
+ Prefer `chip/<slug>` branch per chip. Records: `~/.greprag/opencode-chips/`. Goals: `~/.greprag/chip-goals/`.
93
107
 
94
108
  ## Do not
95
109
 
96
- - Paste bootloader by hand when `opencode chip spawn` is available.
97
- - Dispatch workers from a planner-owned goal (LEAD nested goal required).
110
+ - Force path B for a single chip — use path A.
111
+ - Dispatch workers from a **planner** goal (planner accepts LEAD only).
98
112
  - Skip IN-FLIGHT or end without DONE/BLOCKED.
99
- - Use Codex `create_thread` / Block 1-2 `spawn_task` here — wrong harness.
113
+ - Use Codex `create_thread` / Claude `spawn_task` here — wrong harness.
@@ -1,223 +1,83 @@
1
- # Chip Leader — plan a MULTI-CHIP mission before the first spawn
2
-
3
- > Loaded via `greprag load chip-leader` — usually from *within* `greprag load
4
- > chip-spawn` (its "Part of a multi-chip mission?" gate), the moment you realize
5
- > ≥2 chips aim at one objective, or you're about to spawn a 2nd chip. A single
6
- > chip → straight to `greprag load chip-spawn`. Two or more → STOP, pick a mode
7
- > below, and plan first.
8
-
9
- `chip-spawn` launches one worker correctly; **chip-leader is the commander** who
10
- plans the whole mission *before* any worker deploys and reconciles them *after*.
11
- Topology is a planning decision, not an execution afterthought — draw the map
12
- before mobilizing the troops.
13
-
14
- ## Codex Desktop standard
15
-
16
- For Codex, the `PLANNER: <Mission>` first creates one durable mission goal with
17
- objective, observable final state, and criterion IDs, then launches exactly one
18
- `LEAD: <Mission>` at `gpt-5.6-luna/xhigh`. The LEAD owns decomposition, child
19
- dispatch, integration, checks, release proof, and immediate child closeout.
20
- Before dispatch it assigns each workstream a unique letter and human
21
- purview—`Chip A: <Specific Purview>`, `Chip B: ...`—plus disjoint leases and
22
- explicit `--covers` criteria. Every worker spawn uses `--multi-chip`, its
23
- `--label`, and its proper `--title`; workers stay Luna/xhigh. `ADVISOR:` is a
24
- read-only Sol/high escape hatch only for a documented fundamental blocker.
25
-
26
- Dispatch uses the native-v4 `createRequest` exactly once. It contains the real
27
- mission, the parent-selected model/effort, and native worktree setup; never send
28
- a bootstrap prompt or a second assignment. The initial hook binds before tool
29
- use, the leader applies the exact task title as soon as the resolved task ID is
30
- available, attach emits `IN-FLIGHT`, and the child reports evidence through the
31
- parent's breakthrough inbox.
32
-
33
- Closeout is parent-owned and immediate: review each report and commit, integrate
34
- it, verify the whole mission, explicitly accept the goal, then follow each
35
- returned closeout entry (archive the native task first; run its cleanup command).
36
- A report is not acceptance, cleanup never implies
37
- acceptance, and an accepted/integrated child should not remain in the active
38
- task list. These rules supersede any Claude `spawn_task`, Block 1/Block 2, or
39
- manual worktree instructions later in this shared template when operating in
40
- Codex.
41
-
42
- After an interruption, resume only attached nonterminal chips and require their
43
- nonce-bound breakthrough acknowledgment. A terminal/invalid launch cannot
44
- respond: archive/stop it, durably `goal exclude` it with a concrete reason, and
45
- spawn a replacement under the same goal. Excluded evidence never counts. If the
46
- mission itself is abandoned, stop every chip and `goal cancel`; cancellation
47
- permits cleanup but never masquerades as acceptance.
48
-
49
- **Hard fire:** the moment you're about to spawn the **2nd chip**, stop and plan.
50
- Spawn-then-plan is the exact failure this prevents.
51
-
52
- ## Two modes — pick ONE before planning
53
-
54
- Forks on one question: **do the chips share one objective, or are they independent?**
55
-
56
- | | **Mode A — Mission** | **Mode B — Orchestrator** |
57
- |---|---|---|
58
- | **When** | ≥2 chips at ONE objective, usually ONE repo | N independent issues, often DIFFERENT repos |
59
- | **Relationship** | chips have seams — shared files, data contracts, ordering | disjoint by construction — no seams |
60
- | **Branching** | one integration branch `feature/<slug>`; chips base off it, merge into it | each chip self-contained in its OWN repo; no integration branch |
61
- | **Merge** | leader reconciles all → ONE reviewed merge to master | each chip merges to ITS OWN repo's default, independently |
62
- | **Gate** | whole feature run end-to-end on the integration worktree | per-chip verification; no cross-chip gate |
63
- | **Leader's core job** | merge-reconciliation across seams | **dispatch + completion judgment** — chips report back, you adjudicate |
64
-
65
- Both modes share decompose, dispatch (via `greprag load chip-spawn`), the label
66
- discipline, and the single-watcher rule. They diverge on topology and the back
67
- half (reconcile vs. adjudicate).
68
-
69
- ## Mode A — Mission
70
-
71
- ### The invariant that drives everything
72
-
73
- `master` is the production trunk — `git push origin master` deploys. So:
74
- - **Merged = ships on the next deploy.** A flag gates *behavior*, not *startup
75
- code*: schema/migration statements and import-time side effects run regardless
76
- of any feature flag. "Flag-gated" ≠ "inert on master."
77
- - **Chips NEVER merge directly to master.** They reconcile on a feature
78
- integration branch. Master only ever holds verified, deployable work.
79
- - One objective → **one integration branch** → **one reviewed merge to master**.
80
-
81
- ### Phase 1 — Decompose
82
-
83
- Break the objective into workstreams (one per chip). For each, name:
84
- - **Label** — a stable letter (`A`, `B`, `C`…). It becomes the chip's title prefix
85
- (`Chip A: <verb>`) and the one handle you *and* the chip use end-to-end (title,
86
- report-back self-ID, merge log). Letters, not numbers — workstream IDs, not an
87
- execution order.
88
- - **Parallel or sequential** — can it run independently, or need another's output?
89
- - **Seams** — every place two workstreams touch: *shared file* (both edit the same
90
- module → serialize at merge), *data contract* (one produces what another consumes
91
- → producer merges first), *ordering dependency* (B meaningless until A lands).
92
- - Disjoint workstreams (no shared file, no contract) → merge in any order.
93
-
94
- Output the plan explicitly and **confirm it with the user before dispatching.**
95
-
96
- ### Phase 2 — Topology
97
-
98
- Detect the default branch first (`git -C <main> symbolic-ref refs/remotes/origin/HEAD`
99
- → strip prefix; fallback `master`), then:
100
-
101
- ```bash
102
- git -C <main> worktree add .claude/worktrees/feature-<slug> -b feature/<slug> <default>
1
+ # Leader Mission
2
+
3
+ Load this method when the work needs a dedicated orchestrator: more than the
4
+ quick 1–2 visible chips, shared files or contracts, ordering, integration, or
5
+ another coordination seam.
6
+
7
+ ## Identity first
8
+
9
+ Before any child is created, the orchestrating task becomes the dedicated
10
+ leader by renaming itself exactly:
11
+
12
+ ```text
13
+ LEAD: <Mission>
14
+ ```
15
+
16
+ Children use the exact ordinal discoverability schema:
17
+
18
+ ```text
19
+ Chip A: <Specific Purview>
20
+ Chip B: <Specific Purview>
21
+ Chip C: <Specific Purview>
22
+ ```
23
+
24
+ Naming identifies the workstream and makes the task legible. It does not grant
25
+ execution authority; every child remains an ordinary writable chip.
26
+
27
+ ## Quick versus Leader
28
+
29
+ - **Quick:** the current task renames itself `LEAD: <Mission>` and directly
30
+ spawns 1–2 children. No separate leader task is created.
31
+ - **Leader:** the initiator creates a separate `LEAD: <Mission>` task. That
32
+ dedicated task owns decomposition, child dispatch, seam reconciliation,
33
+ checks, integration, parent messaging, and cleanup.
34
+
35
+ This template is for the second shape. If the mission fits the quick shape,
36
+ load `greprag load codex-chip-spawn` and keep the initiator as the implicit
37
+ LEAD.
38
+
39
+ ## Mission worksheet
40
+
41
+ Before dispatch, record:
42
+
43
+ ```text
44
+ Mission: <observable outcome>
45
+ Integration target: <branch/worktree or parent review point>
46
+ Chip A: <Specific Purview> — <dependency/seam>
47
+ Chip B: <Specific Purview> — <dependency/seam>
48
+ Chip C: <Specific Purview> — <dependency/seam>
49
+ Order: <parallel work, then required reconciliation order>
50
+ Checks: <whole-mission verification>
51
+ Closeout: <who integrates and cleans each worktree>
103
52
  ```
104
53
 
105
- Decide + write down: each chip's **base branch** = `feature/<slug>` (not master);
106
- each chip's **merge target** = `feature/<slug>` (never master); **merge order**
107
- (seam-sharers serialize, producer/base first; disjoint chips free); **test gate**
108
- (the `feature-<slug>` worktree is where the whole feature runs end-to-end).
109
-
110
- ### Phase 3 — Dispatch
111
-
112
- Spawn each chip via `greprag load chip-spawn`, and in each brief include the four
113
- things the plan decided:
114
- 1. **Its seam** — which files/contracts it shares, and what to leave clean.
115
- 2. **Its base branch** — branch off `feature/<slug>` (adjust chip-spawn's Block 1
116
- `git worktree add ... <base>`).
117
- 3. **Its merge target** — `feature/<slug>`, never master. Chips commit to their own
118
- branch + report back; the leader does the merges.
119
- 4. **Its label** — three places (spawn title alone does NOT reach FleetView's
120
- watcher registry, which is auto-generated):
121
- - **Spawn title** — `Chip <Label>: <verb phrase>`.
122
- - **Registry retitle (Block 1)** — give the chip a line to run right after
123
- worktree setup: `greprag session retitle <its-own-8hex> "Chip <Label> — <workstream>"`.
124
- - **Report-back self-ID** — open its report with its label ("Chip B — DONE: …").
125
-
126
- Arm ONE inbox watcher for all the chips' reports (never double-arm).
127
-
128
- **Spawning is a commitment.** A `spawn_task` is not a draft: launching creates a
129
- worktree + branch, and even a queued chip occupies its slug. Finalize the brief
130
- before you spawn; to change/replace a chip, **cancel the old one FIRST** (dismiss
131
- if queued; for a launched one, stop the session, then `git worktree remove` +
132
- `git branch -D`), then spawn. Same-slug collision → spawn the replacement under a
133
- fresh slug rather than fighting an OS file lock.
134
-
135
- ### Phase 4 — Reconcile + integrate
136
-
137
- As chips report `DONE`:
138
- 1. **Merge into `feature/<slug>` in the planned order** (`--no-ff`, from the
139
- integration worktree). Seam-sharers: base first, then the dependent.
140
- 2. **On conflict at a seam** — expected; resolve it (you mapped it in Phase 1). On
141
- an *unexpected* conflict, stop and re-examine the decomposition.
142
- 3. **Recommend closing the chip out** as soon as its commits are reconciled (or
143
- even just committed + reported) — the branch survives the session; you need the
144
- branch, not the live session, to merge later. Don't wait to be asked.
145
- 4. **Run the full feature end-to-end on the integration worktree** — the gate.
146
- 5. **One reviewed merge to master, then clean up.** Only after the gate passes:
147
- `feature/<slug>` → master, then deploy. Then sweep the worktrees (the cleanup
148
- skill keys on "merged into master," so it won't remove chips until then).
149
-
150
- **PRUNE AT THE MERGE (HARD RULE).** Each chip's *worktree* dies the moment its
151
- branch merges into its target — same breath, never batched. The *branch* is the
152
- safety net and lives until the master merge. Stale worktrees pile up precisely
153
- because cleanup was deferred.
154
-
155
- ## Mode B — Orchestrator (independent fan-out, cross-repo)
156
-
157
- A list of independent issues, each self-contained in its own repo. Nothing to
158
- integrate — every chip lives and ships on its own. Your job is **dispatch +
159
- completion judgment**: each chip reports back because you hold the "done"
160
- criterion.
161
-
162
- ### B1 — Decompose AND screen
163
-
164
- One chip per issue — but **screen each candidate first; not every issue is a
165
- chip.** A chip must be a self-contained coding task in a clean git repo. Drop the
166
- rest and say why: interactive-with-operator (needs his login/judgment), ops/comms
167
- (submissions, third-party coordination, email), cross-repo config writes (e.g.
168
- editing a skill under `~/.claude` — not a clean worktree target; do inline),
169
- operator-owned manual tasks. (Reporting "none of these are chips" is a correct,
170
- useful result.)
171
-
172
- For each survivor record: **Label** (`A`/`B`/`C`…), **Target repo** (its root,
173
- from `~/.greprag/projects.json` → becomes the chip's `cwd`), **Completion
174
- criterion** (what "done" means, in YOUR words — you'll judge against it).
175
-
176
- Output the screened plan (chips + dropped non-chips with reasons); confirm before
177
- dispatch.
178
-
179
- ### B2 — Topology: none shared
180
-
181
- No integration branch. Each chip: **cwd** = its own repo root; **base branch** =
182
- that repo's own default (detect per-repo); **merge target** = that repo's default,
183
- or hold-for-review (default to hold so you adjudicate before anything ships).
184
-
185
- ### B3 — Dispatch
186
-
187
- Spawn each via `greprag load chip-spawn` with: `cwd` set; Block 1 worktree off the
188
- repo's default; the label discipline; Block 2 reporting to **your** session; the
189
- **completion criterion embedded in the brief**. Arm ONE watcher. Re-dispatch
190
- discipline (cancel-before-respawn) identical to Mode A.
191
-
192
- ### B4 — Adjudicate (replaces reconcile)
193
-
194
- As each chip reports `DONE`: **verify against the criterion** (read the diff, run
195
- it if needed — don't take "DONE" on faith); **decide per chip** (merge to its own
196
- repo's default + deploy, or send back with specifics); **surface close-out per
197
- chip** as it lands. No single end-of-mission master merge — N independent ones.
198
-
199
- ## Safety rules
200
-
201
- - **Never spawn the 2nd chip without picking a mode + planning.** Mode A for one
202
- shared objective; Mode B for independent issues.
203
- - **Mode B: screen before you spawn.** Interactive, ops/comms, cross-repo-config,
204
- operator-owned tasks are NOT chips.
205
- - **Never spawn a chip while a stale one for the same workstream is in flight —
206
- CANCEL first.** `spawn_task` is a stateful commitment.
207
- - **Mode A: never merge a chip branch to master.** Integration branch only.
208
- - **Never let "it's flag-gated" justify merging untested work to master.**
209
- Migrations and startup code ignore feature flags.
210
- - **Confirm the decomposition with the user before dispatch.** Wrong seams =
211
- painful merges.
212
- - **Surface close-out proactively** as each chip reconciles.
213
-
214
- ## Execution depth (advanced)
215
-
216
- Orthogonal to mode: each workstream also picks a *vehicle* — bare subagent, a
217
- leader-direct workflow, a simple chip, or an **orchestrator chip** (a lean chip
218
- running an inner workflow swarm in its own worktree, for mixed-model missions
219
- needing isolation + a human gate). Mixed-model work cannot be a simple chip
220
- (`spawn_task` has no model param → chips are session-locked). Don't over-stack: a
221
- one-file fix gets a subagent, not a three-tier hierarchy. If you need the
222
- orchestrator-chip brief addendum or the recovery recipe for a chip mistakenly
223
- merged to master, ask the operator — those live in the chip-leader skill docs.
54
+ Give each child one clear purview. Explain shared files, contracts, and
55
+ ordering in the brief rather than relying on hidden coordination metadata.
56
+
57
+ ## Dispatch and closeout
58
+
59
+ 1. Rename the leader task before the first child spawn.
60
+ 2. Spawn each `Chip A/B/C: <Specific Purview>` with its own visible worktree
61
+ and the mission context it needs.
62
+ A child titled exactly `MECHANIC: <Mission>` must make `greprag load mechanic`
63
+ its first Setup action before diagnosis or edits.
64
+ 3. Keep children writable and let them investigate, edit, test, and commit
65
+ within their worktrees.
66
+ 4. Require each child to return `DONE` or `BLOCKED` through the native
67
+ parent-child task result, including the commit, checks, and caveats. Use
68
+ `greprag send` only for explicit cross-harness or peer messaging:
69
+
70
+ ```bash
71
+ greprag send "Chip A update — <commit> — <checks/caveats>" \
72
+ --to <handle>@greprag.com/<parent-session> \
73
+ --from-session <child-session>
74
+ ```
75
+
76
+ 5. Review reports, reconcile seams in the planned order, run the whole-mission
77
+ checks, and send the parent a concise closeout.
78
+ 6. The parent owns integration and cleanup. Do not silently delete a child
79
+ worktree or treat a report as acceptance.
80
+
81
+ Do not introduce a separate read-only, lease, nested-goal, or delivery-proof
82
+ layer just to make the mission look formal. The durable boundaries are the
83
+ visible names, isolated worktrees, reports, `greprag send`, and cleanup.