forge-cc 0.1.40 → 1.0.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.
- package/README.md +454 -338
- package/dist/cli.js +194 -906
- package/dist/cli.js.map +1 -1
- package/dist/config/loader.d.ts +1 -1
- package/dist/config/loader.js +49 -56
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +37 -125
- package/dist/config/schema.js +13 -28
- package/dist/config/schema.js.map +1 -1
- package/dist/doctor.d.ts +10 -0
- package/dist/doctor.js +148 -0
- package/dist/doctor.js.map +1 -0
- package/dist/gates/index.d.ts +14 -12
- package/dist/gates/index.js +53 -105
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/lint-gate.d.ts +2 -2
- package/dist/gates/lint-gate.js +60 -66
- package/dist/gates/lint-gate.js.map +1 -1
- package/dist/gates/tests-gate.d.ts +2 -4
- package/dist/gates/tests-gate.js +75 -203
- package/dist/gates/tests-gate.js.map +1 -1
- package/dist/gates/types-gate.d.ts +2 -2
- package/dist/gates/types-gate.js +53 -59
- package/dist/gates/types-gate.js.map +1 -1
- package/dist/go/linear-sync-cli.js +13 -4
- package/dist/go/linear-sync-cli.js.map +1 -1
- package/dist/go/linear-sync.d.ts +1 -0
- package/dist/go/linear-sync.js +67 -4
- package/dist/go/linear-sync.js.map +1 -1
- package/dist/linear/client.d.ts +34 -105
- package/dist/linear/client.js +85 -365
- package/dist/linear/client.js.map +1 -1
- package/dist/linear/issues.d.ts +3 -1
- package/dist/linear/issues.js +14 -2
- package/dist/linear/issues.js.map +1 -1
- package/dist/linear/projects.js +3 -2
- package/dist/linear/projects.js.map +1 -1
- package/dist/linear/sync.d.ts +15 -0
- package/dist/linear/sync.js +102 -0
- package/dist/linear/sync.js.map +1 -0
- package/dist/runner/loop.d.ts +4 -0
- package/dist/runner/loop.js +168 -0
- package/dist/runner/loop.js.map +1 -0
- package/dist/runner/prompt.d.ts +14 -0
- package/dist/runner/prompt.js +59 -0
- package/dist/runner/prompt.js.map +1 -0
- package/dist/runner/update.d.ts +1 -0
- package/dist/runner/update.js +72 -0
- package/dist/runner/update.js.map +1 -0
- package/dist/server.d.ts +6 -2
- package/dist/server.js +43 -101
- package/dist/server.js.map +1 -1
- package/dist/setup.d.ts +5 -0
- package/dist/setup.js +208 -0
- package/dist/setup.js.map +1 -0
- package/dist/state/cache.d.ts +3 -0
- package/dist/state/cache.js +23 -0
- package/dist/state/cache.js.map +1 -0
- package/dist/state/status.d.ts +66 -0
- package/dist/state/status.js +96 -0
- package/dist/state/status.js.map +1 -0
- package/dist/types.d.ts +46 -114
- package/dist/worktree/manager.d.ts +6 -103
- package/dist/worktree/manager.js +25 -296
- package/dist/worktree/manager.js.map +1 -1
- package/hooks/pre-commit-verify.js +109 -109
- package/package.json +3 -2
- package/skills/forge-go.md +583 -575
- package/skills/forge-setup.md +149 -388
- package/skills/forge-spec.md +367 -342
- package/skills/forge-triage.md +179 -133
- package/skills/forge-update.md +87 -93
package/skills/forge-go.md
CHANGED
|
@@ -1,575 +1,583 @@
|
|
|
1
|
-
# /forge:go — Execute Milestones with Wave-Based Agent Teams
|
|
2
|
-
|
|
3
|
-
Execute milestones from your PRD with real agent teams (TeamCreate/SendMessage), consensus-based review, self-healing verification, and automatic state management.
|
|
4
|
-
|
|
5
|
-
## Instructions
|
|
6
|
-
|
|
7
|
-
Follow these steps exactly.
|
|
8
|
-
|
|
9
|
-
### Step 1 — Orient + Choose Mode
|
|
10
|
-
|
|
11
|
-
**This step has two parts. Complete BOTH before moving to Step 2. Do NOT read any other files, do NOT start pre-flight checks, do NOT read the PRD until both parts are done.**
|
|
12
|
-
|
|
13
|
-
**Part A — Read state (only these files, nothing else):**
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
Read these files in parallel:
|
|
17
|
-
- CLAUDE.md
|
|
18
|
-
- .planning/status/*.json (scan for PRD status files)
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
From the status files, determine:
|
|
22
|
-
- **Available PRDs** with pending milestones
|
|
23
|
-
- If `--prd <slug>` was passed as an argument: select that specific PRD (no picker needed)
|
|
24
|
-
- If only one PRD: auto-select it
|
|
25
|
-
- If multiple PRDs: present a picker using AskUserQuestion with each PRD as an option showing its name, branch, and pending milestone count
|
|
26
|
-
- **Current milestone number** — the lowest-numbered pending milestone for the selected PRD
|
|
27
|
-
- **Branch** — from the status file's `branch` field
|
|
28
|
-
- **Active PRD path** — `.planning/prds/<slug>.md`
|
|
29
|
-
|
|
30
|
-
If no PRD status files exist:
|
|
31
|
-
|
|
32
|
-
> No PRD status files found. Run `/forge:spec` first to create a PRD with milestones.
|
|
33
|
-
|
|
34
|
-
If all milestones are complete across all PRDs:
|
|
35
|
-
|
|
36
|
-
> All milestones complete! Create a PR with `gh pr create` or run `/forge:spec` to start a new project.
|
|
37
|
-
|
|
38
|
-
**Part B — Ask execution mode (MANDATORY — do this IMMEDIATELY after Part A):**
|
|
39
|
-
|
|
40
|
-
If `--auto` was passed as an argument, set mode to auto and skip the prompt.
|
|
41
|
-
|
|
42
|
-
If `--single` was passed as an argument, set mode to single and skip the prompt.
|
|
43
|
-
|
|
44
|
-
Otherwise: **your very next tool call MUST be AskUserQuestion.** No file reads, no git commands, no exploration — ask the user first. Use exactly these parameters:
|
|
45
|
-
|
|
46
|
-
- question: "How should this project be executed?"
|
|
47
|
-
- header: "Mode"
|
|
48
|
-
- options:
|
|
49
|
-
- label: "Single milestone", description: "Execute the next pending milestone, then stop. Good for reviewing progress between milestones."
|
|
50
|
-
- label: "Auto (all milestones)", description: "Chain all remaining milestones with fresh context between each. After each milestone, prints a continuation prompt for the next session."
|
|
51
|
-
- multiSelect: false
|
|
52
|
-
|
|
53
|
-
**Wait for the user's response before continuing.** Do not proceed to Step 2 until you have their answer. Store the choice for Step 8 (Route Next).
|
|
54
|
-
|
|
55
|
-
### Step 2 — Pre-flight Checks
|
|
56
|
-
|
|
57
|
-
**Print progress immediately** — before running any checks, output: `## Step 2 — Pre-flight Checks`
|
|
58
|
-
|
|
59
|
-
Verify the execution environment is ready:
|
|
60
|
-
|
|
61
|
-
1. **Branch check:** Confirm you are on the correct feature branch (from the status file's `branch` field). If on `main`/`master`, warn and abort:
|
|
62
|
-
|
|
63
|
-
> You're on the main branch. Switch to your feature branch first: `git checkout {branch}`
|
|
64
|
-
|
|
65
|
-
2. **Milestone exists:** Read ONLY the current milestone section from the PRD (progressive disclosure — NOT the full PRD).
|
|
66
|
-
|
|
67
|
-
3. **Not already complete:** Check the status file to confirm this milestone is not already marked complete. If it is, advance to the next pending milestone.
|
|
68
|
-
|
|
69
|
-
4. **Clean state:** Run `git status` to check for uncommitted changes. If dirty, warn:
|
|
70
|
-
|
|
71
|
-
> You have uncommitted changes. Commit or stash them before running /forge:go.
|
|
72
|
-
|
|
73
|
-
5. **Milestone size:** Count waves and agents in the milestone. If >3 waves or >6 total agents, warn:
|
|
74
|
-
|
|
75
|
-
> Warning: This milestone has {N} waves and {M} agents. Large milestones risk context overflow. Consider splitting before execution.
|
|
76
|
-
|
|
77
|
-
This is a pre-flight warning, not a hard abort — the user can choose to proceed. But the warning should be prominent so they can split the milestone first if needed.
|
|
78
|
-
|
|
79
|
-
Print the pre-flight summary:
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
## Pre-flight Check
|
|
83
|
-
|
|
84
|
-
- Branch: feat/forge-build (OK)
|
|
85
|
-
- Milestone: 4 — Execution Engine (go) (Pending)
|
|
86
|
-
- PRD: .planning/prds/forge-build.md (found)
|
|
87
|
-
- Working tree: clean
|
|
88
|
-
|
|
89
|
-
Ready to execute Milestone 4.
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**Visual baseline (if visual gate enabled):**
|
|
93
|
-
|
|
94
|
-
If `.forge.json` includes `visual` in gates or specifies a `devServerUrl`, capture before screenshots:
|
|
95
|
-
|
|
96
|
-
1. Start the dev server (from `.forge.json` devServerUrl or `npm run dev`)
|
|
97
|
-
2. Run `npx forge verify --gate visual --before-only` (or manually call the screenshot capture)
|
|
98
|
-
3. Screenshots save to `.forge/screenshots/before/`
|
|
99
|
-
4. Stop the dev server
|
|
100
|
-
|
|
101
|
-
This establishes the visual baseline for regression detection.
|
|
102
|
-
|
|
103
|
-
**The visual gate MUST run if configured — do not skip based on your assessment of whether changes affect the UI.** Parser changes, data fixes, and test-only changes can surface unexpected visual regressions. The only valid reason to skip is: `.forge.json` does NOT include `visual` in gates AND does NOT specify a `devServerUrl`.
|
|
104
|
-
|
|
105
|
-
### Step 2.5 — Session Isolation (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
**
|
|
110
|
-
1. A worktree is created at `../.forge-wt/<repo>/<session-id>/` based on the feature branch
|
|
111
|
-
2. A session is registered in `.forge/sessions.json`
|
|
112
|
-
3. All wave execution happens inside the worktree directory
|
|
113
|
-
4. After completion, changes are merged back to the feature branch
|
|
114
|
-
5. The worktree and session are cleaned up
|
|
115
|
-
|
|
116
|
-
**Why:** Multiple users or terminals can run `/forge:go` simultaneously without corrupting each other's work. Each session gets an isolated copy of the codebase.
|
|
117
|
-
|
|
118
|
-
**
|
|
119
|
-
|
|
120
|
-
### Step 3 — Create Agent Team + Execute Waves
|
|
121
|
-
|
|
122
|
-
**Print progress:** `## Step 3 — Executing Waves`
|
|
123
|
-
|
|
124
|
-
#### 3a. Create the Agent Team
|
|
125
|
-
|
|
126
|
-
Use TeamCreate to establish the milestone's agent team:
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
TeamCreate:
|
|
130
|
-
team_name: "{slug}-m{N}"
|
|
131
|
-
description: "Milestone {N}: {milestone name}"
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
The team follows a **3-tier hierarchy:**
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
Executive (you — the /forge:go orchestrator)
|
|
138
|
-
├── Builder Agent 1 (Opus, full-capability)
|
|
139
|
-
│ ├── Research Subagent (Explore — read-only, for codebase research)
|
|
140
|
-
│ └── Implementation Subagent (general-purpose — for grunt work)
|
|
141
|
-
├── Builder Agent 2 (Opus, full-capability)
|
|
142
|
-
├── ...Builder Agent N
|
|
143
|
-
├── Reviewer Agent (Opus, persistent team member — reviews after each wave)
|
|
144
|
-
└── Notetaker Agent (Opus, optional — spawned when 3+ waves or 4+ agents per wave)
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
**Notetaker decision:** Spawn a notetaker agent when the milestone has 3+ waves OR any single wave has 4+ agents. The notetaker tracks decisions, file ownership, and cross-agent dependencies via SendMessage updates.
|
|
148
|
-
|
|
149
|
-
#### 3b. Parse Waves from PRD
|
|
150
|
-
|
|
151
|
-
Parse the milestone section from the PRD. Each milestone contains waves with agent definitions:
|
|
152
|
-
|
|
153
|
-
```
|
|
154
|
-
**Wave N (M agents parallel):**
|
|
155
|
-
1. **agent-name**: task description
|
|
156
|
-
- Creates: file1, file2
|
|
157
|
-
- Modifies: file3
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
If verification **
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
- The **
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
- The
|
|
255
|
-
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
-
|
|
264
|
-
-
|
|
265
|
-
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
-
|
|
290
|
-
-
|
|
291
|
-
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
- The
|
|
311
|
-
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
git
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
**
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
```
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
If
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
If
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
- **
|
|
571
|
-
- **
|
|
572
|
-
- **
|
|
573
|
-
- **
|
|
574
|
-
- **
|
|
575
|
-
- **
|
|
1
|
+
# /forge:go — Execute Milestones with Wave-Based Agent Teams
|
|
2
|
+
|
|
3
|
+
Execute milestones from your PRD with real agent teams (TeamCreate/SendMessage), consensus-based review, self-healing verification, and automatic state management.
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
|
|
7
|
+
Follow these steps exactly. This skill drives the full agent orchestration — there is no backing TypeScript engine. The forge CLI provides verification (`forge verify`), state management (`forge status`), and Linear sync (`forge linear-sync`) as deterministic commands.
|
|
8
|
+
|
|
9
|
+
### Step 1 — Orient + Choose Mode
|
|
10
|
+
|
|
11
|
+
**This step has two parts. Complete BOTH before moving to Step 2. Do NOT read any other files, do NOT start pre-flight checks, do NOT read the PRD until both parts are done.**
|
|
12
|
+
|
|
13
|
+
**Part A — Read state (only these files, nothing else):**
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Read these files in parallel:
|
|
17
|
+
- CLAUDE.md
|
|
18
|
+
- .planning/status/*.json (scan for PRD status files)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
From the status files, determine:
|
|
22
|
+
- **Available PRDs** with pending milestones
|
|
23
|
+
- If `--prd <slug>` was passed as an argument: select that specific PRD (no picker needed)
|
|
24
|
+
- If only one PRD: auto-select it
|
|
25
|
+
- If multiple PRDs: present a picker using AskUserQuestion with each PRD as an option showing its name, branch, and pending milestone count
|
|
26
|
+
- **Current milestone number** — the lowest-numbered pending milestone for the selected PRD
|
|
27
|
+
- **Branch** — from the status file's `branch` field
|
|
28
|
+
- **Active PRD path** — `.planning/prds/<slug>.md`
|
|
29
|
+
|
|
30
|
+
If no PRD status files exist:
|
|
31
|
+
|
|
32
|
+
> No PRD status files found. Run `/forge:spec` first to create a PRD with milestones.
|
|
33
|
+
|
|
34
|
+
If all milestones are complete across all PRDs:
|
|
35
|
+
|
|
36
|
+
> All milestones complete! Create a PR with `gh pr create` or run `/forge:spec` to start a new project.
|
|
37
|
+
|
|
38
|
+
**Part B — Ask execution mode (MANDATORY — do this IMMEDIATELY after Part A):**
|
|
39
|
+
|
|
40
|
+
If `--auto` was passed as an argument, set mode to auto and skip the prompt.
|
|
41
|
+
|
|
42
|
+
If `--single` was passed as an argument, set mode to single and skip the prompt.
|
|
43
|
+
|
|
44
|
+
Otherwise: **your very next tool call MUST be AskUserQuestion.** No file reads, no git commands, no exploration — ask the user first. Use exactly these parameters:
|
|
45
|
+
|
|
46
|
+
- question: "How should this project be executed?"
|
|
47
|
+
- header: "Mode"
|
|
48
|
+
- options:
|
|
49
|
+
- label: "Single milestone", description: "Execute the next pending milestone, then stop. Good for reviewing progress between milestones."
|
|
50
|
+
- label: "Auto (all milestones)", description: "Chain all remaining milestones with fresh context between each. After each milestone, prints a continuation prompt for the next session."
|
|
51
|
+
- multiSelect: false
|
|
52
|
+
|
|
53
|
+
**Wait for the user's response before continuing.** Do not proceed to Step 2 until you have their answer. Store the choice for Step 8 (Route Next).
|
|
54
|
+
|
|
55
|
+
### Step 2 — Pre-flight Checks
|
|
56
|
+
|
|
57
|
+
**Print progress immediately** — before running any checks, output: `## Step 2 — Pre-flight Checks`
|
|
58
|
+
|
|
59
|
+
Verify the execution environment is ready:
|
|
60
|
+
|
|
61
|
+
1. **Branch check:** Confirm you are on the correct feature branch (from the status file's `branch` field). If on `main`/`master`, warn and abort:
|
|
62
|
+
|
|
63
|
+
> You're on the main branch. Switch to your feature branch first: `git checkout {branch}`
|
|
64
|
+
|
|
65
|
+
2. **Milestone exists:** Read ONLY the current milestone section from the PRD (progressive disclosure — NOT the full PRD). Match the `### Milestone N:` header and extract until the next milestone header.
|
|
66
|
+
|
|
67
|
+
3. **Not already complete:** Check the status file to confirm this milestone is not already marked complete. If it is, advance to the next pending milestone.
|
|
68
|
+
|
|
69
|
+
4. **Clean state:** Run `git status` to check for uncommitted changes. If dirty, warn:
|
|
70
|
+
|
|
71
|
+
> You have uncommitted changes. Commit or stash them before running /forge:go.
|
|
72
|
+
|
|
73
|
+
5. **Milestone size:** Count waves and agents in the milestone. If >3 waves or >6 total agents, warn:
|
|
74
|
+
|
|
75
|
+
> Warning: This milestone has {N} waves and {M} agents. Large milestones risk context overflow. Consider splitting before execution.
|
|
76
|
+
|
|
77
|
+
This is a pre-flight warning, not a hard abort — the user can choose to proceed. But the warning should be prominent so they can split the milestone first if needed.
|
|
78
|
+
|
|
79
|
+
Print the pre-flight summary:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
## Pre-flight Check
|
|
83
|
+
|
|
84
|
+
- Branch: feat/forge-build (OK)
|
|
85
|
+
- Milestone: 4 — Execution Engine (go) (Pending)
|
|
86
|
+
- PRD: .planning/prds/forge-build.md (found)
|
|
87
|
+
- Working tree: clean
|
|
88
|
+
|
|
89
|
+
Ready to execute Milestone 4.
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Visual baseline (if visual gate enabled):**
|
|
93
|
+
|
|
94
|
+
If `.forge.json` includes `visual` in gates or specifies a `devServerUrl`, capture before screenshots:
|
|
95
|
+
|
|
96
|
+
1. Start the dev server (from `.forge.json` devServerUrl or `npm run dev`)
|
|
97
|
+
2. Run `npx forge verify --gate visual --before-only` (or manually call the screenshot capture)
|
|
98
|
+
3. Screenshots save to `.forge/screenshots/before/`
|
|
99
|
+
4. Stop the dev server
|
|
100
|
+
|
|
101
|
+
This establishes the visual baseline for regression detection.
|
|
102
|
+
|
|
103
|
+
**The visual gate MUST run if configured — do not skip based on your assessment of whether changes affect the UI.** Parser changes, data fixes, and test-only changes can surface unexpected visual regressions. The only valid reason to skip is: `.forge.json` does NOT include `visual` in gates AND does NOT specify a `devServerUrl`.
|
|
104
|
+
|
|
105
|
+
### Step 2.5 — Session Isolation (Future Enhancement)
|
|
106
|
+
|
|
107
|
+
> **Note:** Session isolation via git worktrees is not yet implemented in the skill flow. The current implementation runs in the main working directory. The design below describes the planned behavior for a future version.
|
|
108
|
+
|
|
109
|
+
**Planned behavior:**
|
|
110
|
+
1. A worktree is created at `../.forge-wt/<repo>/<session-id>/` based on the feature branch
|
|
111
|
+
2. A session is registered in `.forge/sessions.json`
|
|
112
|
+
3. All wave execution happens inside the worktree directory
|
|
113
|
+
4. After completion, changes are merged back to the feature branch
|
|
114
|
+
5. The worktree and session are cleaned up
|
|
115
|
+
|
|
116
|
+
**Why (when implemented):** Multiple users or terminals can run `/forge:go` simultaneously without corrupting each other's work. Each session gets an isolated copy of the codebase.
|
|
117
|
+
|
|
118
|
+
**Current behavior:** Execution runs in the main working directory. Avoid running multiple `/forge:go` sessions concurrently until worktree isolation is implemented.
|
|
119
|
+
|
|
120
|
+
### Step 3 — Create Agent Team + Execute Waves
|
|
121
|
+
|
|
122
|
+
**Print progress:** `## Step 3 — Executing Waves`
|
|
123
|
+
|
|
124
|
+
#### 3a. Create the Agent Team
|
|
125
|
+
|
|
126
|
+
Use TeamCreate to establish the milestone's agent team:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
TeamCreate:
|
|
130
|
+
team_name: "{slug}-m{N}"
|
|
131
|
+
description: "Milestone {N}: {milestone name}"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The team follows a **3-tier hierarchy:**
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Executive (you — the /forge:go orchestrator)
|
|
138
|
+
├── Builder Agent 1 (Opus, full-capability)
|
|
139
|
+
│ ├── Research Subagent (Explore — read-only, for codebase research)
|
|
140
|
+
│ └── Implementation Subagent (general-purpose — for grunt work)
|
|
141
|
+
├── Builder Agent 2 (Opus, full-capability)
|
|
142
|
+
├── ...Builder Agent N
|
|
143
|
+
├── Reviewer Agent (Opus, persistent team member — reviews after each wave)
|
|
144
|
+
└── Notetaker Agent (Opus, optional — spawned when 3+ waves or 4+ agents per wave)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Notetaker decision:** Spawn a notetaker agent when the milestone has 3+ waves OR any single wave has 4+ agents. The notetaker tracks decisions, file ownership, and cross-agent dependencies via SendMessage updates.
|
|
148
|
+
|
|
149
|
+
#### 3b. Parse Waves from PRD
|
|
150
|
+
|
|
151
|
+
Parse the milestone section from the PRD. Each milestone contains waves with agent definitions:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
**Wave N (M agents parallel):**
|
|
155
|
+
1. **agent-name**: task description
|
|
156
|
+
- Creates: file1, file2
|
|
157
|
+
- Modifies: file3
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**If no wave definitions exist:** For milestones with fewer than 3 issues, treat the entire milestone as a single wave with one agent. For milestones with 3+ distinct issues, design waves that group related issues and respect dependencies (e.g., foundational work in Wave 1, dependent work in Wave 2, integration/testing in Wave 3).
|
|
161
|
+
|
|
162
|
+
#### 3c. Execute Each Wave
|
|
163
|
+
|
|
164
|
+
For each wave, in order:
|
|
165
|
+
|
|
166
|
+
**Build Agent Prompts:**
|
|
167
|
+
|
|
168
|
+
For each agent in the wave, construct a prompt that includes **ALL 10 items below — do not skip any.** Items 9 and 10 are mandatory context that prevent repeated mistakes and ensure consistent agent behavior:
|
|
169
|
+
|
|
170
|
+
1. **Agent identity:** "You are **{agent-name}** working on Milestone {N}: {name}."
|
|
171
|
+
2. **Team context:** "You are part of team `{slug}-m{N}`. Use SendMessage to communicate with the executive and other builders."
|
|
172
|
+
3. **Milestone goal:** The `**Goal:**` line from the milestone section.
|
|
173
|
+
4. **Agent task:** The specific task description from the wave definition.
|
|
174
|
+
5. **Files to create/modify:** The explicit file list from the agent's definition.
|
|
175
|
+
6. **Existing code context:** Read the actual contents of files the agent depends on (imports, types, utilities). **Inline the actual code** — never reference files by path alone. This is critical for agents that run in isolated contexts.
|
|
176
|
+
7. **Subagent guidance:** "You may spawn subagents for research (Explore type — read-only) or implementation grunt work (general-purpose type). Use subagents for tasks that don't require team coordination."
|
|
177
|
+
8. **Conflict avoidance:** "Do NOT modify files outside your assignment. If you discover a need to change a file owned by another agent, send a message to the executive describing the conflict instead of making the change."
|
|
178
|
+
9. **Lessons (MANDATORY):** Read `tasks/lessons.md` and include the full text of all active lessons in the prompt. These are hard-won fixes for recurring mistakes — omitting them causes agents to repeat known errors.
|
|
179
|
+
10. **Rules (MANDATORY):** Include these rules verbatim in every agent prompt:
|
|
180
|
+
- Use ES module imports with `.js` extension in import paths
|
|
181
|
+
- Stage only your files (never `git add .` or `git add -A`)
|
|
182
|
+
- Run `npx tsc --noEmit` after creating files to verify compilation
|
|
183
|
+
- Do NOT commit — the orchestrator handles commits
|
|
184
|
+
- Send a message to the executive when your work is complete
|
|
185
|
+
|
|
186
|
+
**Spawn Builder Agents in Parallel:**
|
|
187
|
+
|
|
188
|
+
**Print progress before each wave:** `### Wave {N} — Spawning {M} agents: {agent-name-1}, {agent-name-2}, ...`
|
|
189
|
+
|
|
190
|
+
Spawn all builder agents for the current wave as team members:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
For each agent in the wave, use the Task tool with:
|
|
194
|
+
- team_name: "{slug}-m{N}"
|
|
195
|
+
- name: "{agent-name}"
|
|
196
|
+
- The constructed prompt as the task description
|
|
197
|
+
- subagent_type: full-capability agent (Opus — builders need SendMessage + subagent spawning)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Wait for ALL builder agents in the wave to report completion via SendMessage before moving to the next step.
|
|
201
|
+
|
|
202
|
+
#### 3d. Restage Files at Wave Boundary
|
|
203
|
+
|
|
204
|
+
**IMPORTANT:** Parallel agents can disrupt each other's git index. After all agents in a wave complete, restage all files:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
git add {all files from this wave's agents}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
This is a learned lesson — always restage at wave boundaries.
|
|
211
|
+
|
|
212
|
+
#### 3e. Run Mechanical Verification
|
|
213
|
+
|
|
214
|
+
After each wave completes, run mechanical verification gates:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npx tsc --noEmit
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
If the project has additional verification configured (tests, lint), also run:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npx forge verify
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**CRITICAL: NEVER remove a gate from `.forge.json` or modify CLAUDE.md to make verification pass.** If a gate fails due to missing prerequisites (no dev server, no PRD), that is an environment issue — not a code error. Fix only code errors; skip or note environment-dependent failures.
|
|
227
|
+
|
|
228
|
+
If verification **fails**: proceed to Step 4 (self-healing loop).
|
|
229
|
+
|
|
230
|
+
If verification **passes**: capture after screenshots (if visual gate configured), then proceed to reviewer.
|
|
231
|
+
|
|
232
|
+
#### 3e-vis. Capture After Screenshots (If Visual Gate Configured)
|
|
233
|
+
|
|
234
|
+
If `.forge.json` includes `visual` in gates or specifies a `devServerUrl`, capture after screenshots:
|
|
235
|
+
|
|
236
|
+
1. Start the dev server (from `.forge.json` devServerUrl or `npm run dev`)
|
|
237
|
+
2. Run `npx forge verify --gate visual --after-only` (or manually call the screenshot capture)
|
|
238
|
+
3. Screenshots save to `.forge/screenshots/after/`
|
|
239
|
+
4. Stop the dev server
|
|
240
|
+
|
|
241
|
+
**This step is mandatory when the visual gate is configured — same rule as Step 2.** The reviewer needs both before and after screenshots to detect visual regressions.
|
|
242
|
+
|
|
243
|
+
#### 3f. Reviewer Consensus Protocol
|
|
244
|
+
|
|
245
|
+
**MANDATORY: Do NOT proceed to the next wave or Step 5 until the reviewer has completed its review. This is the real quality gate — not tests.**
|
|
246
|
+
|
|
247
|
+
After mechanical gates pass, engage the reviewer agent:
|
|
248
|
+
|
|
249
|
+
1. **Send diff to reviewer:** Use SendMessage to send **ALL of the following** to the reviewer agent. Do not send partial context — the reviewer cannot do its job without every item:
|
|
250
|
+
- The PRD milestone section including:
|
|
251
|
+
- The **Goal** line (what this milestone delivers)
|
|
252
|
+
- All `- [ ]` checklist items from the milestone (these are the acceptance criteria)
|
|
253
|
+
- The **User Stories** section from the PRD (for context on what users expect)
|
|
254
|
+
- The full git diff for the wave (run `git diff --cached` or `git diff HEAD` — do not summarize or truncate)
|
|
255
|
+
- CLAUDE.md rules and architecture decisions
|
|
256
|
+
- The list of files changed and their ownership (which agent created/modified which files)
|
|
257
|
+
- If the visual gate ran, include the screenshot file paths:
|
|
258
|
+
- Before: `.forge/screenshots/before/*.png` (if captured in Step 2)
|
|
259
|
+
- After: `.forge/screenshots/after/*.png`
|
|
260
|
+
- Tell the reviewer: "Use the Read tool to view these screenshots. Compare the rendered UI against the PRD's acceptance criteria and user stories. Check for: layout correctness, missing UI elements, visual regressions from the before state, responsive behavior across viewports (desktop 1280x800, tablet 768x1024, mobile 390x844)."
|
|
261
|
+
|
|
262
|
+
2. **Reviewer analyzes diff:** The reviewer examines the changes for:
|
|
263
|
+
- Does the code achieve the milestone's **Goal** line?
|
|
264
|
+
- Does it handle the acceptance criteria from the PRD? (Check each `- [ ]` item)
|
|
265
|
+
- Are there logic errors, missing error handling, or dead code paths?
|
|
266
|
+
- Would `npx forge verify` catch this, or is this a semantic issue only a reviewer would find?
|
|
267
|
+
- **If screenshots provided:** Does the rendered UI match the PRD's described behavior? Are there visual issues (broken layouts, missing elements, incorrect spacing) across any viewport?
|
|
268
|
+
|
|
269
|
+
3. **Reviewer sends findings:** The reviewer sends structured findings to the orchestrator (you). **Print each finding to the terminal** so the user sees them:
|
|
270
|
+
```
|
|
271
|
+
Finding: {description}
|
|
272
|
+
Severity: error | warning
|
|
273
|
+
File: {path}
|
|
274
|
+
Line: {number}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
4. **Fix findings:** Spawn a fix agent to address all findings. The fix agent receives:
|
|
278
|
+
- The specific findings to fix
|
|
279
|
+
- The files to modify
|
|
280
|
+
- "Fix ONLY the listed findings. Do not refactor or add features. NEVER modify .forge.json, CLAUDE.md, or tasks/lessons.md to resolve verification errors."
|
|
281
|
+
|
|
282
|
+
5. **Re-verify:** Restage files and re-run mechanical gates after fixes.
|
|
283
|
+
|
|
284
|
+
If no findings (or all findings resolved): print wave completion summary and proceed to the next wave.
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
## Wave {N} Complete
|
|
288
|
+
|
|
289
|
+
- agent-1: OK (created file1.ts, file2.ts)
|
|
290
|
+
- agent-2: OK (modified file3.ts)
|
|
291
|
+
- Mechanical verification: PASSED
|
|
292
|
+
- Visual gate: PASSED (3 viewports captured) | SKIPPED (not in .forge.json gates)
|
|
293
|
+
- Reviewer: {N} findings, {M} resolved, 0 outstanding
|
|
294
|
+
|
|
295
|
+
Proceeding to Wave {N+1}...
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Step 4 — Self-Healing Verify Loop
|
|
299
|
+
|
|
300
|
+
**Print progress:** `## Step 4 — Self-Healing (attempt {N}/{max})`
|
|
301
|
+
|
|
302
|
+
When mechanical verification fails after a wave (or after reviewer fixes):
|
|
303
|
+
|
|
304
|
+
1. Parse the verification errors into structured feedback. Include:
|
|
305
|
+
- Gate name (types, lint, tests)
|
|
306
|
+
- Error messages with file paths and line numbers
|
|
307
|
+
- Remediation hints if available
|
|
308
|
+
|
|
309
|
+
2. Spawn a **fix agent** (as a team member) with a prompt that includes:
|
|
310
|
+
- The specific errors to fix
|
|
311
|
+
- The files that need modification
|
|
312
|
+
- The original task context
|
|
313
|
+
- "Fix ONLY the errors listed. Do not refactor or add features. NEVER modify .forge.json, CLAUDE.md, or tasks/lessons.md to resolve verification errors."
|
|
314
|
+
|
|
315
|
+
3. After the fix agent completes, restage files and re-run verification.
|
|
316
|
+
|
|
317
|
+
4. Repeat up to `maxIterations` (default: 5, configurable via `.forge.json`).
|
|
318
|
+
|
|
319
|
+
5. If max iterations reached without passing:
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
## Verification Failed After {N} Iterations
|
|
323
|
+
|
|
324
|
+
### Remaining Errors:
|
|
325
|
+
- types: src/gates/types.ts:42 — Type 'string' is not assignable to type 'number'
|
|
326
|
+
- lint: src/gates/lint.ts:55 — Unused variable 'foo'
|
|
327
|
+
|
|
328
|
+
The self-healing loop could not resolve all errors.
|
|
329
|
+
Please fix the remaining issues manually, then run `/forge:go` again.
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Stop execution.** Do not proceed to the next wave or milestone. Shut down the agent team (TeamDelete).
|
|
333
|
+
|
|
334
|
+
### Step 5 — Commit
|
|
335
|
+
|
|
336
|
+
**Print progress:** `## Step 5 — Committing`
|
|
337
|
+
|
|
338
|
+
After ALL waves pass verification (mechanical + reviewer):
|
|
339
|
+
|
|
340
|
+
1. Stage all files created/modified across all waves:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
git add {all files from all waves}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
2. Commit with a structured message:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
git commit -m "feat: {Milestone Name} (Milestone {N})"
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
3. Push to the remote branch:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
git push origin {branch}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Step 6 — Update State
|
|
359
|
+
|
|
360
|
+
**Print progress:** `## Step 6 — Updating State`
|
|
361
|
+
|
|
362
|
+
Update the PRD status file:
|
|
363
|
+
|
|
364
|
+
1. **Status JSON:** Update `.planning/status/<slug>.json` — mark the completed milestone's status as `complete` with today's date.
|
|
365
|
+
|
|
366
|
+
2. Commit the status update:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
git add .planning/status/<slug>.json
|
|
370
|
+
git commit -m "docs: mark Milestone {N} complete"
|
|
371
|
+
git push origin {branch}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### Step 7 — Linear Sync (If Configured)
|
|
375
|
+
|
|
376
|
+
Check for the Linear project ID in this priority order:
|
|
377
|
+
1. `linearProjectId` field in `.planning/status/<slug>.json` (written by `/forge:spec`)
|
|
378
|
+
2. `linearProject` field in `.forge.json` (manual fallback)
|
|
379
|
+
|
|
380
|
+
If a Linear project ID is found:
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
npx forge linear-sync complete --slug {slug} --milestone {number} [--last] [--pr-url {url}]
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Pass `--last` if this is the last milestone. Pass `--pr-url {url}` if a PR was created. This command:
|
|
387
|
+
- If NOT last milestone: adds progress comments to milestone issues
|
|
388
|
+
- If last milestone: transitions all project issues and the project to "In Review", adds PR link comments
|
|
389
|
+
|
|
390
|
+
The CLI prints informational output about what it did or why it skipped:
|
|
391
|
+
- Missing API key: `[forge] LINEAR_API_KEY not set, skipping Linear sync`
|
|
392
|
+
- Missing teamId: `[forge] No linearTeamId in status file, skipping Linear sync`
|
|
393
|
+
- On success: `[forge] Transitioning N issues to {state}`, `[forge] Updated project {id} to {state}`
|
|
394
|
+
|
|
395
|
+
These messages are informational, not errors. The skill should continue execution regardless of the output.
|
|
396
|
+
|
|
397
|
+
If no Linear project ID is found in either location, skip this step silently.
|
|
398
|
+
|
|
399
|
+
### Step 8 — Route Next
|
|
400
|
+
|
|
401
|
+
After milestone completion, determine the next action:
|
|
402
|
+
|
|
403
|
+
#### If this is NOT the last milestone:
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
## Milestone {N} Complete
|
|
407
|
+
|
|
408
|
+
**{Milestone Name}** completed successfully.
|
|
409
|
+
|
|
410
|
+
- Files created: {count}
|
|
411
|
+
- Files modified: {count}
|
|
412
|
+
- Verification: PASSED (mechanical + reviewer)
|
|
413
|
+
- Branch: {branch} (pushed)
|
|
414
|
+
|
|
415
|
+
**Next:** Run `/clear` then `/forge:go` for Milestone {N+1}, or exit and run `npx forge run` to auto-chain all remaining milestones.
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Shut down the agent team:
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
Send shutdown_request to all team members via SendMessage.
|
|
422
|
+
Wait for shutdown confirmations.
|
|
423
|
+
TeamDelete to clean up team resources.
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
#### If this IS the last milestone:
|
|
427
|
+
|
|
428
|
+
**Fetch Linear issue identifiers** (if Linear is configured):
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
npx forge linear-sync list-issues --slug {slug}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
This outputs a JSON array of identifiers (e.g., `["MSIG-123", "MSIG-124"]`). If the command returns identifiers, include them in the PR body as a `Closes` line. If no Linear project ID is configured or the command returns nothing, omit the "Linear Issues" section.
|
|
435
|
+
|
|
436
|
+
Create a pull request:
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
gh pr create --title "feat: {Project Name}" --body "$(cat <<'EOF'
|
|
440
|
+
## Summary
|
|
441
|
+
{Brief description from PRD overview}
|
|
442
|
+
|
|
443
|
+
## Milestones Completed
|
|
444
|
+
- [x] Milestone 1: {name}
|
|
445
|
+
- [x] Milestone 2: {name}
|
|
446
|
+
...
|
|
447
|
+
|
|
448
|
+
## Linear Issues
|
|
449
|
+
|
|
450
|
+
Closes {TEAM-1}, {TEAM-2}, ...
|
|
451
|
+
|
|
452
|
+
## Verification
|
|
453
|
+
All milestones passed forge verification (types, lint, tests) and agent team review.
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
Generated by forge-cc
|
|
457
|
+
EOF
|
|
458
|
+
)"
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
The "Linear Issues" section with `Closes` keywords enables Linear's GitHub integration to auto-close the linked issues when the PR is merged. Omit this section entirely if no identifiers were found.
|
|
462
|
+
|
|
463
|
+
**Codex Review Gate:**
|
|
464
|
+
|
|
465
|
+
After `gh pr create` succeeds, poll for Codex review comments using the deterministic CLI command:
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
npx forge codex-poll --owner {owner} --repo {repo} --pr {pr_number}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
This command polls every 60 seconds for up to 8 minutes (8 checks) and outputs a JSON array of comments to stdout. Progress is printed to stderr.
|
|
472
|
+
|
|
473
|
+
1. **Run the command** — it blocks until comments are found or all 8 polls are exhausted.
|
|
474
|
+
|
|
475
|
+
2. **Parse the JSON output.** If the array is non-empty, for each comment:
|
|
476
|
+
- Spawn a fix agent (team member) with the comment text, file path, and line number
|
|
477
|
+
- The fix agent either makes the code fix or posts a justified reply explaining why the current code is correct
|
|
478
|
+
- After fixes are pushed, run `npx forge codex-poll` one more cycle for new comments from re-review
|
|
479
|
+
|
|
480
|
+
3. **Completion criteria:** The milestone completes when the PR has 0 unresolved review comments.
|
|
481
|
+
|
|
482
|
+
4. **Empty array:** If no Codex comments appear after 8 minutes, proceed — Codex may not be configured for this repository.
|
|
483
|
+
|
|
484
|
+
Then shut down the agent team and print:
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
## All Milestones Complete!
|
|
488
|
+
|
|
489
|
+
**PR:** {PR URL}
|
|
490
|
+
|
|
491
|
+
- {N} milestones completed
|
|
492
|
+
- {total files} files created/modified
|
|
493
|
+
- All verification gates passed
|
|
494
|
+
- Codex review: {resolved/no comments/not configured}
|
|
495
|
+
|
|
496
|
+
The PR is ready for review.
|
|
497
|
+
|
|
498
|
+
**After the PR is merged:** Run `npx forge linear-sync done --slug {slug}` to transition all issues and the project to "Done" in Linear. Or add this to your CI merge pipeline.
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**IMPORTANT:** Do NOT merge the PR automatically. Merging is a hard-to-reverse action that requires explicit user confirmation. Always stop here and let the user decide when to merge.
|
|
502
|
+
|
|
503
|
+
```
|
|
504
|
+
Send shutdown_request to all team members via SendMessage.
|
|
505
|
+
Wait for shutdown confirmations.
|
|
506
|
+
TeamDelete to clean up team resources.
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Auto Mode
|
|
510
|
+
|
|
511
|
+
When the user selects "Auto (all milestones)" in Step 1 Part B or invokes with `--auto` (e.g., `/forge:go --auto`):
|
|
512
|
+
|
|
513
|
+
Print the following instructions and then **stop** (do not execute a milestone):
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
## Auto Mode — Fresh Context Execution
|
|
517
|
+
|
|
518
|
+
Auto mode runs each milestone in a fresh Claude session for maximum quality.
|
|
519
|
+
|
|
520
|
+
**To start:** Exit this Claude session (Ctrl+C), then run in your terminal:
|
|
521
|
+
|
|
522
|
+
npx forge run --prd {slug}
|
|
523
|
+
|
|
524
|
+
**What happens:**
|
|
525
|
+
- Each milestone gets a fresh Claude session (no context rot)
|
|
526
|
+
- Output streams inline to your terminal
|
|
527
|
+
- Stops on completion, failure, or stall
|
|
528
|
+
- Resume after failure: fix the issue, run `npx forge run --prd {slug}` again
|
|
529
|
+
|
|
530
|
+
**Requires:** claude CLI on PATH, --dangerously-skip-permissions (automatic)
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
**IMPORTANT:** Auto mode does NOT execute milestones in the current session. It redirects the user to `npx forge run --prd {slug}`, which handles spawning fresh Claude sessions per milestone via the Ralph Loop pattern.
|
|
534
|
+
|
|
535
|
+
### Parallel Milestones (dependsOn)
|
|
536
|
+
|
|
537
|
+
When milestones specify `dependsOn` fields in the PRD, the scheduler can identify which milestones are independent and run them in parallel:
|
|
538
|
+
|
|
539
|
+
- Milestones with no `dependsOn` (or `dependsOn: []`) can run in the first wave
|
|
540
|
+
- Milestones that depend on completed milestones become ready as dependencies finish
|
|
541
|
+
- The scheduler builds a DAG and groups milestones into execution waves
|
|
542
|
+
|
|
543
|
+
Example PRD milestone with dependencies:
|
|
544
|
+
```
|
|
545
|
+
### Milestone 3: Integration Layer
|
|
546
|
+
**dependsOn:** 1, 2
|
|
547
|
+
**Goal:** Combine components from M1 and M2...
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
If no `dependsOn` fields are present, milestones execute sequentially (backward compatible).
|
|
551
|
+
|
|
552
|
+
### Step 9 — Linear Issue Start (On Milestone Begin)
|
|
553
|
+
|
|
554
|
+
At the START of milestone execution (between Step 2 and Step 3), check for the Linear project ID using the same priority as Step 7:
|
|
555
|
+
1. `linearProjectId` field in `.planning/status/<slug>.json`
|
|
556
|
+
2. `linearProject` field in `.forge.json`
|
|
557
|
+
|
|
558
|
+
If a Linear project ID is found:
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
npx forge linear-sync start --slug {slug} --milestone {number}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
This command programmatically transitions milestone issues to "In Progress" and the project to "In Progress". The CLI prints informational output (e.g., `[forge] Transitioning N issues to In Progress` or `[forge] LINEAR_API_KEY not set, skipping Linear sync`). These are informational messages, not errors — continue execution regardless.
|
|
565
|
+
|
|
566
|
+
If no Linear project ID is found, skip silently.
|
|
567
|
+
|
|
568
|
+
## Edge Cases
|
|
569
|
+
|
|
570
|
+
- **No PRD:** Abort with message to run `/forge:spec` first.
|
|
571
|
+
- **No status files:** Same as no PRD — abort with message to run `/forge:spec` first.
|
|
572
|
+
- **No waves in milestone:** The milestone section may not have structured wave definitions (e.g., it was written by hand without the spec engine). For milestones with fewer than 3 issues, treat the entire milestone as a single wave with one agent whose task is the milestone's goal. For milestones with 3+ distinct issues, design waves that group related issues and respect dependencies.
|
|
573
|
+
- **Agent failure:** If an agent in a wave fails (exits with error, times out), record the failure, include the error in the wave result, and proceed to verification. The self-healing loop may fix the issue.
|
|
574
|
+
- **Branch diverged:** If `git push` fails due to divergence, attempt `git pull --rebase` first. If that fails, stop and ask the user.
|
|
575
|
+
- **Interrupted execution:** If execution is interrupted mid-wave, the status files are NOT updated. Running `/forge:go` again will retry the same milestone from the beginning. Completed agents' work will be in the working tree — the new run's verification will detect what's already working. Shut down any remaining team members before retrying.
|
|
576
|
+
- **Empty milestone section:** If the PRD has a milestone header but no content, abort with:
|
|
577
|
+
> Milestone {N} has no wave definitions. Update the PRD with agent assignments before running /forge:go.
|
|
578
|
+
- **Already on correct milestone:** If the status file's current milestone matches the target, proceed normally (this is the expected case).
|
|
579
|
+
- **Worktree conflict (future):** When session isolation is implemented, if the worktree directory already exists (e.g., from a crashed session), run `npx forge cleanup` first. If that fails, fall back to main directory execution.
|
|
580
|
+
- **Linear auth fails:** Warn but continue execution. Linear sync is not blocking — the milestone should still execute and complete without Linear.
|
|
581
|
+
- **Team creation fails:** If TeamCreate fails, fall back to the legacy Task-based agent spawning (fire-and-forget without SendMessage). Log a warning that review and consensus will be skipped.
|
|
582
|
+
- **Reviewer timeout:** If the reviewer does not respond within 5 minutes, log a warning and proceed without review findings. Do not block wave progression on a stalled reviewer.
|
|
583
|
+
- **Codex gate timeout:** If Codex does not post comments within 8 minutes, proceed — Codex may not be configured. This is not a failure.
|