greprag 5.60.3 → 5.60.5

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 (101) hide show
  1. package/dist/codex-chip-hooks.d.ts +2 -7
  2. package/dist/codex-chip-hooks.js +25 -159
  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 +8 -0
  8. package/dist/commands/codex-chip/bootstrap.js +103 -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 +1 -9
  13. package/dist/commands/codex-chip/cleanup-command.js.map +1 -1
  14. package/dist/commands/codex-chip/command.js +5 -63
  15. package/dist/commands/codex-chip/command.js.map +1 -1
  16. package/dist/commands/codex-chip/git.d.ts +0 -1
  17. package/dist/commands/codex-chip/git.js +0 -2
  18. package/dist/commands/codex-chip/git.js.map +1 -1
  19. package/dist/commands/codex-chip/goals.d.ts +9 -0
  20. package/dist/commands/codex-chip/goals.js +54 -7
  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 +13 -24
  24. package/dist/commands/codex-chip/help.js.map +1 -1
  25. package/dist/commands/codex-chip/model.d.ts +2 -4
  26. package/dist/commands/codex-chip/model.js +1 -1
  27. package/dist/commands/codex-chip/model.js.map +1 -1
  28. package/dist/commands/codex-chip/naming.js +4 -10
  29. package/dist/commands/codex-chip/naming.js.map +1 -1
  30. package/dist/commands/codex-chip/native.js +11 -15
  31. package/dist/commands/codex-chip/native.js.map +1 -1
  32. package/dist/commands/codex-chip/prompt.d.ts +2 -1
  33. package/dist/commands/codex-chip/prompt.js +15 -59
  34. package/dist/commands/codex-chip/prompt.js.map +1 -1
  35. package/dist/commands/codex-chip/resume-command.js +0 -3
  36. package/dist/commands/codex-chip/resume-command.js.map +1 -1
  37. package/dist/commands/codex-chip/selection.d.ts +1 -1
  38. package/dist/commands/codex-chip/selection.js +15 -59
  39. package/dist/commands/codex-chip/selection.js.map +1 -1
  40. package/dist/commands/codex-chip/worker.js +60 -122
  41. package/dist/commands/codex-chip/worker.js.map +1 -1
  42. package/dist/commands/codex-delivery.d.ts +32 -7
  43. package/dist/commands/codex-delivery.js +76 -92
  44. package/dist/commands/codex-delivery.js.map +1 -1
  45. package/dist/commands/codex-startup.js +1 -1
  46. package/dist/commands/codex-startup.js.map +1 -1
  47. package/dist/commands/codex.js +36 -34
  48. package/dist/commands/codex.js.map +1 -1
  49. package/dist/commands/friction-reminder.d.ts +9 -9
  50. package/dist/commands/friction-reminder.js +12 -17
  51. package/dist/commands/friction-reminder.js.map +1 -1
  52. package/dist/commands/inbox-primer-reminder.js +3 -3
  53. package/dist/commands/inbox-primer-reminder.js.map +1 -1
  54. package/dist/commands/init.js +7 -5
  55. package/dist/commands/init.js.map +1 -1
  56. package/dist/commands/load-primer-reminder.js +2 -2
  57. package/dist/commands/load-primer-reminder.js.map +1 -1
  58. package/dist/commands/load.js +28 -27
  59. package/dist/commands/load.js.map +1 -1
  60. package/dist/commands/mechanic-spawn.d.ts +10 -0
  61. package/dist/commands/mechanic-spawn.js +67 -0
  62. package/dist/commands/mechanic-spawn.js.map +1 -0
  63. package/dist/commands/mechanic.js +6 -0
  64. package/dist/commands/mechanic.js.map +1 -1
  65. package/dist/commands/opencode-chip-client.d.ts +8 -0
  66. package/dist/commands/opencode-chip-client.js +45 -0
  67. package/dist/commands/opencode-chip-client.js.map +1 -0
  68. package/dist/commands/opencode-chip-lifecycle.d.ts +2 -0
  69. package/dist/commands/opencode-chip-lifecycle.js +137 -0
  70. package/dist/commands/opencode-chip-lifecycle.js.map +1 -0
  71. package/dist/commands/opencode-chip-mission.d.ts +22 -0
  72. package/dist/commands/opencode-chip-mission.js +105 -0
  73. package/dist/commands/opencode-chip-mission.js.map +1 -0
  74. package/dist/commands/opencode-chip-store.d.ts +72 -0
  75. package/dist/commands/opencode-chip-store.js +141 -0
  76. package/dist/commands/opencode-chip-store.js.map +1 -0
  77. package/dist/commands/opencode-chip.d.ts +3 -0
  78. package/dist/commands/opencode-chip.js +488 -0
  79. package/dist/commands/opencode-chip.js.map +1 -0
  80. package/dist/commands/opencode-goals.d.ts +5 -0
  81. package/dist/commands/opencode-goals.js +83 -0
  82. package/dist/commands/opencode-goals.js.map +1 -0
  83. package/dist/hook.js +8 -3
  84. package/dist/hook.js.map +1 -1
  85. package/dist/index.js +11 -90
  86. package/dist/index.js.map +1 -1
  87. package/dist/opencode-plugin.bundle.js +9 -11
  88. package/package.json +1 -1
  89. package/skill/greprag/SKILL.md +2 -2
  90. package/skill/greprag/docs/codex-chip.md +20 -59
  91. package/skill/greprag/docs/setup.md +15 -21
  92. package/skill/templates/chip-bootloader.md +33 -91
  93. package/skill/templates/chip-leader-opencode.md +90 -75
  94. package/skill/templates/chip-leader.md +81 -221
  95. package/skill/templates/codex-chip-spawn.md +129 -173
  96. package/skill/templates/codex-subagent-spawn.md +32 -0
  97. package/dist/commands/codex-native-delivery.d.ts +0 -70
  98. package/dist/commands/codex-native-delivery.js +0 -285
  99. package/dist/commands/codex-native-delivery.js.map +0 -1
  100. package/skill/templates/reflex-chip.md +0 -58
  101. package/skill/templates/workshop-chip.md +0 -46
@@ -1,107 +1,49 @@
1
1
  # Chip Bootloader
2
2
 
3
- No `spawn_task`? The lead creates a git worktree, the user opens a new session
4
- there, and the bootloader takes over. greprag inbox is the back-channel.
3
+ No `spawn_task`? Use OpenCode Desktop HTTP spawn (preferred) or manual paste.
5
4
 
6
- ## Multi-chip?
5
+ ## Preferred: quick chip (path A)
7
6
 
8
- If this task needs ≥2 chips, STOP and run `greprag load chip-leader-opencode` FIRST.
9
- The leader plans the integration branch, labels, seams, and merge order before
10
- any chip launches. A lone chip proceeds directly below.
11
-
12
- ---
13
- ## Lead: before presenting the bootloader
14
-
15
- ```bash
16
- if [ -d "C:\chip-<slug>" ]; then
17
- cd "C:\chip-<slug>"
18
- current=$(git branch --show-current)
19
- if [ "$current" = "chip/<slug>" ]; then
20
- echo "Worktree already exists on correct branch — reusing"
21
- else
22
- echo "ERROR: Worktree dir exists but branch is '$current', not 'chip/<slug>'. Remove and retry." >&2
23
- exit 1
24
- fi
25
- else
26
- git worktree add C:\chip-<slug> -b chip/<slug>
27
- fi
28
- ```
29
-
30
- The worktree IS the isolation — same pattern as Claude Code's `spawn_task` worktree
31
- landing. Branch already exists, directory already isolated. Now present the
32
- bootloader below and tell the user: **"Open a new session here: C:\chip-<slug>"**
33
-
34
- ## After chip reports DONE
35
-
36
- ```bash
37
- git checkout <target-branch> # main or integration branch
38
- git merge chip/<slug>
39
- git worktree remove C:\chip-<slug>
40
- git branch -d chip/<slug>
41
- ```
42
-
43
- ---
44
- ## Bootloader template
45
-
46
- Substitute the bracketed placeholders and present as a copyable code block.
47
-
48
- ````
49
- Chip <Label>: <verb-phrase>
50
-
51
- You are inside C:\chip-<slug> — a git worktree on branch chip/<slug>,
52
- created for you by the lead. Verify:
7
+ Initiator is LEAD — no separate LEAD session:
53
8
 
54
9
  ```bash
55
- git branch --show-current # should output: chip/<slug>
10
+ greprag opencode chip goal create \
11
+ --objective "…" --final-state "…" \
12
+ --criterion ship:… \
13
+ --owner-session <this-8hex> --owner-role leader
14
+
15
+ greprag opencode chip spawn \
16
+ --title "Purview Name" --role worker --label A \
17
+ --goal-id <id> --covers ship \
18
+ --task "…" \
19
+ --parent-session <ses_…> --parent-greprag <8hex> \
20
+ --model deepseek/deepseek-chat \
21
+ --opencode-url http://127.0.0.1:<port> \
22
+ --dispatch
23
+ # → "Chip A: Purview Name"
24
+ # close: report → goal accept → greprag opencode chip close <id|ses_>
56
25
  ```
57
26
 
58
- ---
59
- ## Block 1 — Setup
60
-
61
- 1. Get your session ID:
62
- ```bash
63
- greprag status 2>&1 | grep -oP '(?<=greprag session id: )[0-9a-f]+'
64
- ```
27
+ ## Multi-chip mission (path B)?
65
28
 
66
- 2. Announce you're alive:
67
- ```bash
68
- greprag send "IN-FLIGHT: chip/<slug> launched — <task-summary>" \
69
- --to <handle>@greprag.com/<parent-8hex> \
70
- --from-session <your-8hex>
71
- ```
29
+ ≥2 chips at one objective → STOP → `greprag load chip-leader-opencode`
30
+ (PLANNER → LEAD → nested goal → Chip A/B).
72
31
 
73
- IN-FLIGHT ping is mandatory. No ping = lead assumes chip never launched.
32
+ ## Manual paste (API down only)
74
33
 
75
- ---
76
- ## Task
34
+ ### Block 1 — Setup
35
+ 1. `greprag status` → 8-hex
36
+ 2. `greprag send "IN-FLIGHT: <title>" --to travis@greprag.com/<parent-8hex>`
37
+ 3. Branch `chip/<slug>`
38
+ 4. Each turn: `greprag inbox --peek`
77
39
 
78
- <your instructions here>
79
-
80
- Commit milestones on chip/<slug>. At each turn start, run
81
- `greprag inbox --peek` — the lead may send new instructions.
82
-
83
- ---
84
- ## Block 2 — Report when done
40
+ ### Task
41
+ \<work — include goal id + covers\>
85
42
 
43
+ ### Block 2 — Report
86
44
  ```bash
87
- greprag send "<status>: <result>" \
88
- --to <handle>@greprag.com/<parent-8hex> \
89
- --from-session <your-8hex>
45
+ greprag send "DONE: … | commit=<sha> | checks=…" --to travis@greprag.com/<parent-8hex>
46
+ # or BLOCKED: …
90
47
  ```
91
48
 
92
- After reporting, wait for the lead — there may be follow-up.
93
- The lead will merge chip/<slug> and remove this worktree when finished.
94
- ````
95
-
96
- ### Placeholder reference
97
-
98
- | Placeholder | Substitute |
99
- |---|---|
100
- | `<Label>` | Single-letter (A, B...) or omit for single-chip |
101
- | `<verb-phrase>` | Short name, e.g. `Fix synthesis loop` |
102
- | `<slug>` | Slugified — `fix-synthesis-loop` |
103
- | `<parent-8hex>` | Your own session id (first 8 hex) |
104
- | `<handle>` | Operator's greprag handle |
105
- | `<task-summary>` | One-liner for the IN-FLIGHT ping |
106
- | `<status>` | `DONE`, `BLOCKED`, `PARTIAL` |
107
- | `<result>` | Summary of what was done |
49
+ Workers always `--label A|B|C…`. `--model` required. Report-back is greprag inbox.
@@ -1,98 +1,113 @@
1
- # Chip Leader — plan a MULTI-CHIP mission (OpenCode)
1
+ # Chip Leader — OpenCode multi-chip (path B)
2
2
 
3
- > Loaded via `greprag load chip-leader-opencode` — run this when your task
4
- > needs ≥2 chips. A single chip → `greprag load chip-bootloader`. Two or more
5
- > → STOP, pick a mode below, and plan 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).
6
6
 
7
- `chip-bootloader` launches one worker correctly; **chip-leader is the commander**
8
- who plans the whole mission *before* any worker deploys and reconciles them
9
- *after*. Topology is a planning decision, not an execution afterthought — draw
10
- the map before mobilizing the troops.
7
+ ## Two paths (both first-class)
11
8
 
12
- **Hard fire:** the moment you're about to launch the **2nd chip**, stop and plan.
13
- Launch-then-plan is the exact failure this prevents.
14
-
15
- ## Two modes — pick ONE before planning
16
-
17
- Forks on one question: **do the chips share one objective, or are they independent?**
18
-
19
- | | **Mode A — Mission** | **Mode B — Orchestrator** |
9
+ | | **A — Quick** | **B — Mission (this doc)** |
20
10
  |---|---|---|
21
- | **When** | ≥2 chips at ONE objective, usually ONE repo | N independent issues, often DIFFERENT repos |
22
- | **Relationship** | chips have seams — shared files, data contracts, ordering | disjoint by construction — no seams |
23
- | **Branching** | one integration branch `feature/<slug>`; chips base off it, merge into it | each chip self-contained in its OWN repo; no integration branch |
24
- | **Merge** | leader reconciles all → ONE reviewed merge to master | each chip merges to ITS OWN repo independently |
25
- | **Leader's core job** | merge-reconciliation across seams | dispatch + completion judgment — chips report back, you adjudicate |
26
-
27
- Both modes share decompose, dispatch via bootloader, the label system, and the
28
- merge discipline below.
29
-
30
- ## Phase 1 — Decompose
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 |
31
16
 
32
- Break the objective into independent workstreams. Each workstream = one chip.
33
- Assign each a **Label** (A, B, C...). The label is the shared handle the leader
34
- and chip both use end-to-end: bootloader title → IN-FLIGHT ping → report-back
35
- self-ID → merge references.
17
+ **Hard fire for B:** about to spawn the **2nd chip at one objective** → stop and plan here.
36
18
 
37
- ## Phase 2 — Assign integration branch (Mode A only)
19
+ ## Path A — Quick (default)
38
20
 
39
- Create one branch off the default branch that all Mode A chips merge INTO:
40
21
  ```bash
41
- git checkout -b feature/<slug>
42
- git push origin feature/<slug>
22
+ greprag opencode chip goal create \
23
+ --objective "…" --final-state "…" \
24
+ --criterion ship:… \
25
+ --owner-session <this-greprag-8hex> \
26
+ --owner-role leader
27
+
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 "…"
43
42
  ```
44
43
 
45
- Each chip's bootloader sets `git checkout -b chip/<slug>` based off this
46
- integration branch. When the chip reports DONE, its work is ON `chip/<slug>`,
47
- ready to merge into `feature/<slug>`.
44
+ No separate LEAD chip. No bind-lead. Initiator owns the goal and closeout.
48
45
 
49
- ## Phase 3 — Pre-launch & dispatch each chip
46
+ ## Path B — Mission flow
50
47
 
51
- For each workstream:
52
-
53
- 1. **Create the worktree:**
48
+ 1. **PLANNER** creates the mission goal (`--owner-role planner`).
49
+ 2. Spawn **one LEAD** under that goal (`--role leader --covers …`).
50
+ 3. LEAD creates a **nested** goal + bind:
54
51
  ```bash
55
- git worktree add C:\\chip-<slug> -b chip/<slug>
52
+ greprag opencode chip goal create \
53
+ --objective "…" --final-state "…" \
54
+ --criterion ship:… \
55
+ --owner-session <lead-child-greprag-8hex> \
56
+ --owner-role leader \
57
+ --parent-goal-id <planner-goal-id>
58
+ greprag opencode chip bind-lead <lead-chip-id> \
59
+ --goal-id <nested-goal-id> \
60
+ --owner-session <lead-child-greprag-8hex>
56
61
  ```
62
+ 4. LEAD spawns workers against the **nested** goal:
63
+ `--role worker --label A --title "…" --goal-id <nested> --covers ship --parent-greprag <lead-8hex>`.
64
+ 5. Workers: `IN-FLIGHT` → work → `DONE`/`BLOCKED`. Parent: `report --evidence …`.
65
+ 6. Accept nested goal, then planner goal; then `close` chips.
57
66
 
58
- 2. **Write the bootloader** (from `greprag load chip-bootloader`):
59
- - Label: `Chip A: <verb-phrase>`
60
- - Integration branch name in the task (Mode A)
61
- - One clear, self-contained task per chip
67
+ ## Role titles (exact)
62
68
 
63
- 3. **Present the bootloader** and tell the user:
64
- > Open a new session here: C:\\chip-<slug>
69
+ `PLANNER: …` · `LEAD: …` · `Chip A: …` / `Chip B: …` · `ADVISOR: …` · `MECHANIC: …`
65
70
 
66
- The user starts a new session in the worktree, pastes the bootloader.
71
+ Workers **always** `--label A|B|C…` (solo = A). Never bare `Chip:`.
67
72
 
68
- ## Phase 4 — Reconcile & merge (Mode A)
73
+ ## Mode A vs Mode B topology (still for path B)
69
74
 
70
- 1. As each chip reports DONE, merge its branch into `feature/<slug>`:
71
- ```bash
72
- git checkout feature/<slug>
73
- git merge chip/<slug>
74
- ```
75
- 2. Resolve any seam conflicts between chips
76
- 3. Run the full feature end-to-end on `feature/<slug>`
77
- 4. One reviewed merge to master, then prune:
78
- ```bash
79
- git checkout master
80
- git merge feature/<slug>
81
- git branch -d feature/<slug>
82
- # for each chip:
83
- git worktree remove C:\\chip-<chip-slug>
84
- git branch -d chip/<chip-slug>
85
- ```
75
+ | | **Mission topology** | **Orchestrator topology** |
76
+ |---|---|---|
77
+ | When | ≥2 chips, one objective | Independent issues |
78
+ | Branch | Integration branch | Per-chip / per-repo |
79
+ | Gate | One reviewed merge to master | Per-chip verify |
86
80
 
87
- ## Phase 4 (Mode B) — Adjudicate
81
+ ## Spawn flags (canonical)
88
82
 
89
- Each chip runs in its own repo. As each reports DONE, verify and close
90
- independently. No integration gate.
83
+ ```bash
84
+ greprag opencode chip spawn \
85
+ --title "Auth Middleware" \
86
+ --role worker --label A \
87
+ --goal-id <id> --covers ship \
88
+ --task "…" \
89
+ --parent-session <ses_…> \
90
+ --parent-greprag <8hex> \
91
+ --model deepseek/deepseek-chat \
92
+ --opencode-url http://127.0.0.1:<port> \
93
+ --dispatch
94
+ # → "Chip A: Auth Middleware"
95
+ ```
91
96
 
92
- ## Key difference from Claude Code chip-leader
97
+ Close: `greprag opencode chip close <chipId|ses_> --summary "…"`
98
+ (`--keep-session` · `--force` · `--keep-open-goal`)
93
99
 
94
- | Feature | Claude Code | OpenCode |
95
- |---|---|---|
96
- | Dispatch | `greprag load chip-spawn` (spawn_task) | `greprag load chip-bootloader` (copyable block) |
97
- | Isolation | git worktree per chip | git branch per chip |
98
- | Validator | PreToolUse hook validates prompt blocks | No validator — bootloader is manual |
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.
103
+
104
+ ## Isolation
105
+
106
+ Prefer `chip/<slug>` branch per chip. Records: `~/.greprag/opencode-chips/`. Goals: `~/.greprag/chip-goals/`.
107
+
108
+ ## Do not
109
+
110
+ - Force path B for a single chip — use path A.
111
+ - Dispatch workers from a **planner** goal (planner accepts LEAD only).
112
+ - Skip IN-FLIGHT or end without DONE/BLOCKED.
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.