ai-fob 1.9.7 → 1.9.8
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/assets/pi/prompts/build-feature.md +597 -0
- package/manifest.json +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Orchestrate a full multi-phase feature build with Pi build-phase runner monitoring
|
|
3
|
+
argument-hint: "<path to HL plan spec>"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build Feature
|
|
7
|
+
|
|
8
|
+
Orchestrate a full multi-phase feature build by launching the Pi build-phase runner once and monitoring it from a distance.
|
|
9
|
+
|
|
10
|
+
The key architecture: **the build-feature agent is an observer/monitor/doctor, not the direct phase controller**. The deterministic phase loop runs in `.pi/scripts/build-phase-runner.sh`; this prompt launches that script in the background, polls durable files on disk, diagnoses stalls, applies bounded interventions when a known recovery playbook matches, audits high-level success criteria, writes a durable learnings file, and presents a final feature-level report.
|
|
11
|
+
|
|
12
|
+
Use careful, evidence-grounded reasoning for diagnosis and intervention decisions. Do not rewrite phase artifacts on behalf of phase agents.
|
|
13
|
+
|
|
14
|
+
## Required skill
|
|
15
|
+
|
|
16
|
+
Before reading or interpreting `STATE.md`, load and follow the `FOB-state-context` skill.
|
|
17
|
+
|
|
18
|
+
## Arguments
|
|
19
|
+
|
|
20
|
+
Raw arguments: `$ARGUMENTS`
|
|
21
|
+
|
|
22
|
+
Parse into:
|
|
23
|
+
|
|
24
|
+
- `HL_PLAN_PATH`: first argument
|
|
25
|
+
|
|
26
|
+
If missing, stop with:
|
|
27
|
+
|
|
28
|
+
```txt
|
|
29
|
+
Usage: /build-feature <path to HL plan spec>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Variables
|
|
33
|
+
|
|
34
|
+
Derived in Step 0:
|
|
35
|
+
|
|
36
|
+
- `HL_PLAN_PATH`: absolute path to high-level plan markdown file
|
|
37
|
+
- `SPEC_DIR`: parent directory of `HL_PLAN_PATH`
|
|
38
|
+
- `PROJECT_ROOT`: nearest ancestor containing `.pi/prompts/build-phase.md`
|
|
39
|
+
- `TASK_NAME`: `task:` from HL plan YAML frontmatter
|
|
40
|
+
- `TOTAL_PHASES`: `phases:` from HL plan YAML frontmatter
|
|
41
|
+
- `LEARNINGS_FILE`: `{SPEC_DIR}/build-feature-learnings.md`
|
|
42
|
+
- `RUNNER_SCRIPT`: `{PROJECT_ROOT}/.pi/scripts/build-phase-runner.sh`
|
|
43
|
+
- `HL_CRITERIA`: map of phase number to original HL success criteria strings
|
|
44
|
+
|
|
45
|
+
Monitoring state:
|
|
46
|
+
|
|
47
|
+
- `BUILD_PID`: PID of backgrounded runner process
|
|
48
|
+
- `BUILD_START_TIME`: epoch seconds when launched
|
|
49
|
+
- `CURRENT_PHASE`: phase currently active from `STATE.md`
|
|
50
|
+
- `CURRENT_STEP`: step currently active from `STATE.md`
|
|
51
|
+
- `LAST_POLL_PHASE`: phase from previous poll
|
|
52
|
+
- `LAST_POLL_STEP`: step from previous poll
|
|
53
|
+
- `STALL_SUSPECTED`: false until one no-progress poll, true until confirmed/resolved
|
|
54
|
+
- `INTERVENTION_COUNTS`: per-phase intervention counter, max 2
|
|
55
|
+
- `VERIFIED_PHASES`: phases whose success criteria have already been audited
|
|
56
|
+
- `POLL_NUMBER`: incremented each poll
|
|
57
|
+
|
|
58
|
+
## Status vocabulary
|
|
59
|
+
|
|
60
|
+
Use Claude-compatible feature-level status names in the final report:
|
|
61
|
+
|
|
62
|
+
```txt
|
|
63
|
+
completed -> all required phases reached status: complete and criteria audit is acceptable
|
|
64
|
+
partial -> at least one phase completed, but the run stopped on blocked/failed/incomplete phase
|
|
65
|
+
aborted -> monitor aborted due to unrecoverable stall, process failure, invalid setup, or manual stop
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Use Pi phase-level statuses exactly as reported in `phase_completion_report.md`:
|
|
69
|
+
|
|
70
|
+
```txt
|
|
71
|
+
complete -> phase succeeded; runner may continue
|
|
72
|
+
blocked -> external/environment/human-action blocker; stop by default unless explicitly accepted
|
|
73
|
+
failed/fail -> validation/build failure after internal recovery loops; stop
|
|
74
|
+
missing/invalid report -> orchestration/artifact failure; stop
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Blocked is not failed, but blocked must not be silently ignored.
|
|
78
|
+
|
|
79
|
+
## Workflow
|
|
80
|
+
|
|
81
|
+
### Step 0: Parse and validate inputs
|
|
82
|
+
|
|
83
|
+
1. Parse `HL_PLAN_PATH` from `$ARGUMENTS`. Trim whitespace.
|
|
84
|
+
2. Resolve it to an absolute path.
|
|
85
|
+
3. Verify it exists and ends in `.md`.
|
|
86
|
+
4. Read the HL plan.
|
|
87
|
+
5. Parse YAML frontmatter between the first pair of `---` delimiters:
|
|
88
|
+
- `task:` -> `TASK_NAME`; if missing/empty, abort.
|
|
89
|
+
- `phases:` -> `TOTAL_PHASES`; if missing/not positive integer, abort.
|
|
90
|
+
6. Set `SPEC_DIR` to the parent directory of `HL_PLAN_PATH`.
|
|
91
|
+
7. Derive `PROJECT_ROOT` by walking upward from `SPEC_DIR` until finding `.pi/prompts/build-phase.md`. If not found, abort.
|
|
92
|
+
8. Set `RUNNER_SCRIPT` to `{PROJECT_ROOT}/.pi/scripts/build-phase-runner.sh`; verify it exists and is executable.
|
|
93
|
+
9. Set `LEARNINGS_FILE` to `{SPEC_DIR}/build-feature-learnings.md`.
|
|
94
|
+
10. Load `FOB-state-context` before reading `STATE.md`.
|
|
95
|
+
11. Extract original high-level success criteria per phase:
|
|
96
|
+
- Find phase sections such as `### Phase N: ...`.
|
|
97
|
+
- Within each phase section, find `**Success Criteria**:` or equivalent success criteria block.
|
|
98
|
+
- Extract checkbox items beginning `- [ ]` or `- [x]`.
|
|
99
|
+
- Store exact criterion text in `HL_CRITERIA[N]`.
|
|
100
|
+
- If no criteria are found for a phase, store an empty list and log a warning.
|
|
101
|
+
|
|
102
|
+
### Step 1: Initialize durable learnings file
|
|
103
|
+
|
|
104
|
+
If `LEARNINGS_FILE` does not exist, write:
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
# Build Feature Learnings: {TASK_NAME}
|
|
108
|
+
|
|
109
|
+
Spec: {HL_PLAN_PATH}
|
|
110
|
+
Project Root: {PROJECT_ROOT}
|
|
111
|
+
Total Phases: {TOTAL_PHASES}
|
|
112
|
+
Started: {ISO-8601 timestamp}
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
If it exists, append a restart section:
|
|
118
|
+
|
|
119
|
+
```markdown
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
# Build Feature Restart: {TASK_NAME}
|
|
124
|
+
|
|
125
|
+
Restarted: {ISO-8601 timestamp}
|
|
126
|
+
Spec: {HL_PLAN_PATH}
|
|
127
|
+
Project Root: {PROJECT_ROOT}
|
|
128
|
+
Total Phases: {TOTAL_PHASES}
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Always read the current file first, append in memory, then write the full updated content.
|
|
134
|
+
|
|
135
|
+
### Step 2: Pre-flight checks
|
|
136
|
+
|
|
137
|
+
Run and log these checks before launch. Accumulate results and append one `## Pre-Flight Checks` section to `LEARNINGS_FILE`.
|
|
138
|
+
|
|
139
|
+
#### 2.1 Lock file check
|
|
140
|
+
|
|
141
|
+
Lock file:
|
|
142
|
+
|
|
143
|
+
```txt
|
|
144
|
+
{SPEC_DIR}/.build-phase.lock
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
If it exists:
|
|
148
|
+
|
|
149
|
+
1. Read PID.
|
|
150
|
+
2. If PID is running, abort with a clear message: another build is active.
|
|
151
|
+
3. If PID is dead, remove the stale lock and log it.
|
|
152
|
+
|
|
153
|
+
#### 2.2 Port check
|
|
154
|
+
|
|
155
|
+
Check port 3000 for existing processes:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
lsof -ti:3000 2>/dev/null
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
If occupied, kill those PIDs before launch and log the action. This matches current test-project behavior. Future versions may read the configured dev port from `testing-and-validation`.
|
|
162
|
+
|
|
163
|
+
#### 2.3 Git status check
|
|
164
|
+
|
|
165
|
+
Run from `PROJECT_ROOT`:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
git status --porcelain 2>/dev/null || echo GIT_UNAVAILABLE
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Log clean/dirty/unavailable. Do not abort on dirty state.
|
|
172
|
+
|
|
173
|
+
#### 2.4 STATE.md check
|
|
174
|
+
|
|
175
|
+
Read `{SPEC_DIR}/../STATE.md` if present, or the nearest `specs/STATE.md` according to `FOB-state-context` conventions.
|
|
176
|
+
|
|
177
|
+
Log whether `TASK_NAME` exists and which phases are already marked `[x]`.
|
|
178
|
+
|
|
179
|
+
#### 2.5 Runner sanity check
|
|
180
|
+
|
|
181
|
+
Run:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
bash -n "{RUNNER_SCRIPT}"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Abort if syntax check fails.
|
|
188
|
+
|
|
189
|
+
#### 2.6 Write pre-flight section
|
|
190
|
+
|
|
191
|
+
Append:
|
|
192
|
+
|
|
193
|
+
```markdown
|
|
194
|
+
## Pre-Flight Checks
|
|
195
|
+
Timestamp: {ISO-8601 timestamp}
|
|
196
|
+
|
|
197
|
+
- Lock file: {clean | stale lock removed PID | active lock abort}
|
|
198
|
+
- Port 3000: {clean | killed PIDs}
|
|
199
|
+
- Git status: {clean | N uncommitted changes | unavailable}
|
|
200
|
+
- STATE.md: {task found, completed phases ... | task not found}
|
|
201
|
+
- Runner syntax: {pass | fail}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Step 3: Launch runner once
|
|
205
|
+
|
|
206
|
+
1. Append to `LEARNINGS_FILE`:
|
|
207
|
+
|
|
208
|
+
```markdown
|
|
209
|
+
## Build Launch
|
|
210
|
+
Started: {ISO-8601 timestamp}
|
|
211
|
+
Phase spec: all ({TOTAL_PHASES} total phases)
|
|
212
|
+
Runner: {RUNNER_SCRIPT}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
2. Initialize monitoring state:
|
|
216
|
+
- `INTERVENTION_COUNTS = {}`
|
|
217
|
+
- `VERIFIED_PHASES = {}`
|
|
218
|
+
- `LAST_POLL_PHASE = null`
|
|
219
|
+
- `LAST_POLL_STEP = null`
|
|
220
|
+
- `STALL_SUSPECTED = false`
|
|
221
|
+
- `POLL_NUMBER = 0`
|
|
222
|
+
|
|
223
|
+
3. Launch the runner using shell-level backgrounding in one Bash call:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
cd "{PROJECT_ROOT}" && "{RUNNER_SCRIPT}" "{HL_PLAN_PATH}" all > /tmp/build-feature.log 2>&1 &
|
|
227
|
+
echo $!
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Important: use shell `&`. Do not attempt to keep the build loop inside the agent. Capture stdout PID as `BUILD_PID`.
|
|
231
|
+
|
|
232
|
+
4. Append `Build PID: {BUILD_PID}` to `LEARNINGS_FILE`.
|
|
233
|
+
5. Set `BUILD_START_TIME` using `date +%s`.
|
|
234
|
+
6. Create freshness marker:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
touch /tmp/build-feature-lastpoll
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Step 4: Monitoring loop
|
|
241
|
+
|
|
242
|
+
Poll until the runner exits or the monitor aborts.
|
|
243
|
+
|
|
244
|
+
Default polling interval: 15 minutes, matching Claude Code vocabulary. During initial testing, a user may ask for a shorter interval, but the prompt default is 15 minutes.
|
|
245
|
+
|
|
246
|
+
Each poll:
|
|
247
|
+
|
|
248
|
+
1. Sleep:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
sleep 900
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
2. Increment `POLL_NUMBER`.
|
|
255
|
+
3. Check runner process:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
kill -0 {BUILD_PID} 2>/dev/null && echo ALIVE || echo EXITED
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
If exited, proceed to Step 7 Completion Assessment.
|
|
262
|
+
|
|
263
|
+
4. Read `STATE.md` and determine:
|
|
264
|
+
- active phase with any step `[~]`
|
|
265
|
+
- active step number/name
|
|
266
|
+
- completed phases whose Step 1-6 are `[x]`
|
|
267
|
+
- between-phase state, if no `[~]` but next phase not started
|
|
268
|
+
|
|
269
|
+
5. Detect phase transition:
|
|
270
|
+
- If `CURRENT_PHASE` differs from `LAST_POLL_PHASE` and `LAST_POLL_PHASE` is not null, log transition.
|
|
271
|
+
- Audit the just-completed phase using Step 6.
|
|
272
|
+
- Run between-phase cleanup (Step 5).
|
|
273
|
+
- Reset `STALL_SUSPECTED=false`.
|
|
274
|
+
|
|
275
|
+
6. Check for new artifacts since last poll:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
NEW_FILES=""
|
|
279
|
+
for dir in $(find "{SPEC_DIR}" -maxdepth 1 -type d -name "phase*_*" 2>/dev/null); do
|
|
280
|
+
FILES=$(find "$dir" -newer /tmp/build-feature-lastpoll -type f 2>/dev/null | head -5)
|
|
281
|
+
if [ -n "$FILES" ]; then
|
|
282
|
+
NEW_FILES="${NEW_FILES}${FILES}\n"
|
|
283
|
+
fi
|
|
284
|
+
done
|
|
285
|
+
if [ -n "$NEW_FILES" ]; then
|
|
286
|
+
echo "NEW_ARTIFACTS:"
|
|
287
|
+
echo -e "$NEW_FILES"
|
|
288
|
+
else
|
|
289
|
+
echo "NO_NEW_ARTIFACTS"
|
|
290
|
+
fi
|
|
291
|
+
touch /tmp/build-feature-lastpoll
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
7. Tail runner log for context:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
tail -80 /tmp/build-feature.log 2>/dev/null || true
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
8. Stall detection:
|
|
301
|
+
- Phase changed -> progress.
|
|
302
|
+
- Step changed -> progress.
|
|
303
|
+
- Same step but new artifacts -> progress.
|
|
304
|
+
- Same step and no new artifacts for one poll -> set `STALL_SUSPECTED=true`, log warning.
|
|
305
|
+
- Same step and no new artifacts for two consecutive polls -> confirmed stall; proceed to Step 8 Diagnosis and Intervention.
|
|
306
|
+
|
|
307
|
+
9. Append poll section to `LEARNINGS_FILE`:
|
|
308
|
+
|
|
309
|
+
```markdown
|
|
310
|
+
### Poll {POLL_NUMBER} ({elapsed_minutes}m)
|
|
311
|
+
- Process alive: yes
|
|
312
|
+
- Current phase: Phase {CURRENT_PHASE}
|
|
313
|
+
- Current step: Step {CURRENT_STEP} - {step_name}
|
|
314
|
+
- Phases completed: {list}
|
|
315
|
+
- New artifacts since last poll: {list or none}
|
|
316
|
+
- Runner log tail: summarized / see /tmp/build-feature.log
|
|
317
|
+
- Progress status: {progress | possible stall | confirmed stall}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
10. Continue polling.
|
|
321
|
+
|
|
322
|
+
### Step 5: Between-phase cleanup
|
|
323
|
+
|
|
324
|
+
On phase transition only, while runner is still alive:
|
|
325
|
+
|
|
326
|
+
1. Clear port 3000:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
lsof -ti:3000 | xargs kill -9 2>/dev/null; echo "Port cleanup done"
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
2. Append:
|
|
333
|
+
|
|
334
|
+
```markdown
|
|
335
|
+
### Between-Phase Cleanup (Phase {LAST_POLL_PHASE} -> Phase {CURRENT_PHASE})
|
|
336
|
+
- Port 3000: cleared
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Do not remove `.build-phase.lock` during normal between-phase cleanup; the runner owns it.
|
|
340
|
+
|
|
341
|
+
### Step 6: Success criteria verification for a phase
|
|
342
|
+
|
|
343
|
+
Run this when a phase transition is observed and again during final completion assessment for any phases not already verified.
|
|
344
|
+
|
|
345
|
+
For phase `N`:
|
|
346
|
+
|
|
347
|
+
1. Resolve phase directory:
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
find "{SPEC_DIR}" -maxdepth 1 -type d -name "phase{N}_*" 2>/dev/null | head -1
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
2. Read `{PHASE_DIR}/phase_completion_report.md`.
|
|
354
|
+
3. Parse YAML frontmatter:
|
|
355
|
+
- `status:`
|
|
356
|
+
- `validation-result:`
|
|
357
|
+
- `checks-passed:`
|
|
358
|
+
- `checks-blocked:`
|
|
359
|
+
- `fix-cycles:`
|
|
360
|
+
4. Find the report's `## HL Success Criteria Results` or `## HL Plan Success Criteria Results` section.
|
|
361
|
+
5. Parse table rows into:
|
|
362
|
+
- criterion text
|
|
363
|
+
- result: `PASS`, `FAIL`, `BLOCKED`
|
|
364
|
+
- evidence
|
|
365
|
+
6. Cross-reference against `HL_CRITERIA[N]` from the original HL plan:
|
|
366
|
+
- matching row with `PASS` -> `complete`
|
|
367
|
+
- matching row with `FAIL` -> `incomplete`
|
|
368
|
+
- matching row with `BLOCKED` -> `blocked`
|
|
369
|
+
- no matching row -> `dropped`
|
|
370
|
+
7. Flag extra report rows not present in original HL criteria as `extra`.
|
|
371
|
+
8. Append:
|
|
372
|
+
|
|
373
|
+
```markdown
|
|
374
|
+
### Success Criteria Verification: Phase {N}
|
|
375
|
+
Timestamp: {ISO-8601 timestamp}
|
|
376
|
+
Source: phase_completion_report.md vs HL plan
|
|
377
|
+
Phase status: {status}
|
|
378
|
+
Validation result: {validation-result}
|
|
379
|
+
|
|
380
|
+
| # | Criterion | Status | Evidence |
|
|
381
|
+
|---|-----------|--------|----------|
|
|
382
|
+
| 1 | {criterion text} | {complete/incomplete/blocked/dropped} | {evidence} |
|
|
383
|
+
|
|
384
|
+
Summary: {complete}/{total} criteria complete; {blocked} blocked; {dropped} dropped; {extra} extra.
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
This verification is observational. Do not modify phase reports.
|
|
388
|
+
|
|
389
|
+
### Step 7: Completion assessment
|
|
390
|
+
|
|
391
|
+
When the runner exits:
|
|
392
|
+
|
|
393
|
+
1. Try to collect exit code:
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
wait {BUILD_PID} 2>/dev/null; echo $?
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
If unavailable because process was already reaped, record `unknown`.
|
|
400
|
+
|
|
401
|
+
2. Read final `STATE.md`.
|
|
402
|
+
3. For each phase `1..TOTAL_PHASES`:
|
|
403
|
+
- resolve phase directory,
|
|
404
|
+
- read `phase_completion_report.md`,
|
|
405
|
+
- parse frontmatter status,
|
|
406
|
+
- count completed Step 1-6 markers,
|
|
407
|
+
- compute per-phase result.
|
|
408
|
+
4. Audit success criteria for any phase not in `VERIFIED_PHASES` using Step 6.
|
|
409
|
+
5. Compute:
|
|
410
|
+
- total phases attempted,
|
|
411
|
+
- total phases complete,
|
|
412
|
+
- blocked phases,
|
|
413
|
+
- failed phases,
|
|
414
|
+
- incomplete/missing-report phases,
|
|
415
|
+
- total criteria,
|
|
416
|
+
- criteria complete,
|
|
417
|
+
- criteria incomplete,
|
|
418
|
+
- criteria blocked,
|
|
419
|
+
- criteria dropped,
|
|
420
|
+
- total interventions,
|
|
421
|
+
- total duration.
|
|
422
|
+
6. Determine feature status:
|
|
423
|
+
|
|
424
|
+
```txt
|
|
425
|
+
all phases complete and no monitor abort -> completed
|
|
426
|
+
some phases complete but blocked/failed/incomplete exist -> partial
|
|
427
|
+
monitor aborted or unrecoverable stall/process issue -> aborted
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
7. Append to `LEARNINGS_FILE`:
|
|
431
|
+
|
|
432
|
+
```markdown
|
|
433
|
+
## Build Process Exited
|
|
434
|
+
Timestamp: {ISO-8601 timestamp}
|
|
435
|
+
Exit code: {code}
|
|
436
|
+
Duration: {minutes}m
|
|
437
|
+
|
|
438
|
+
### Per-Phase Results
|
|
439
|
+
| Phase | Steps Completed | Status | Validation | Interventions |
|
|
440
|
+
|-------|-----------------|--------|------------|---------------|
|
|
441
|
+
| 1 | {count}/6 | {status} | {validation-result} | {count} |
|
|
442
|
+
|
|
443
|
+
## Success Criteria Audit: Full Build
|
|
444
|
+
Timestamp: {ISO-8601 timestamp}
|
|
445
|
+
|
|
446
|
+
| Phase | Total Criteria | Complete | Incomplete | Blocked | Dropped |
|
|
447
|
+
|-------|----------------|----------|------------|---------|---------|
|
|
448
|
+
| 1 | {total} | {complete} | {incomplete} | {blocked} | {dropped} |
|
|
449
|
+
| TOTAL | {total} | {complete} | {incomplete} | {blocked} | {dropped} |
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
Proceed to Step 9 Final Report.
|
|
453
|
+
|
|
454
|
+
### Step 8: Diagnosis and intervention
|
|
455
|
+
|
|
456
|
+
Run only after confirmed stall: two consecutive polls with same phase/step and no new artifacts.
|
|
457
|
+
|
|
458
|
+
#### 8.1 Diagnosis
|
|
459
|
+
|
|
460
|
+
Collect:
|
|
461
|
+
|
|
462
|
+
```bash
|
|
463
|
+
echo "=== Main process ==="
|
|
464
|
+
ps -o pid,ppid,stat,%cpu,command -p {BUILD_PID} 2>/dev/null || true
|
|
465
|
+
|
|
466
|
+
echo "=== Child processes ==="
|
|
467
|
+
pgrep -P {BUILD_PID} 2>/dev/null | xargs ps -o pid,ppid,stat,%cpu,command -p 2>/dev/null || true
|
|
468
|
+
|
|
469
|
+
echo "=== Grandchild processes ==="
|
|
470
|
+
for child in $(pgrep -P {BUILD_PID} 2>/dev/null); do
|
|
471
|
+
pgrep -P "$child" 2>/dev/null | xargs ps -o pid,ppid,stat,%cpu,command -p 2>/dev/null
|
|
472
|
+
done 2>/dev/null || true
|
|
473
|
+
|
|
474
|
+
echo "=== Dev server processes ==="
|
|
475
|
+
pgrep -f 'dev\.sh|bun.*dev|next dev|vite' 2>/dev/null | while read pid; do
|
|
476
|
+
ps -o pid,%cpu,command -p "$pid" 2>/dev/null
|
|
477
|
+
done
|
|
478
|
+
|
|
479
|
+
echo "=== Port 3000 ==="
|
|
480
|
+
lsof -ti:3000 2>/dev/null || echo PORT_FREE
|
|
481
|
+
|
|
482
|
+
echo "=== Runner log tail ==="
|
|
483
|
+
tail -120 /tmp/build-feature.log 2>/dev/null || true
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
Append full diagnosis to `LEARNINGS_FILE`.
|
|
487
|
+
|
|
488
|
+
#### 8.2 Known Error Playbook: Dev Server Foreground Hang
|
|
489
|
+
|
|
490
|
+
Match if all are true:
|
|
491
|
+
|
|
492
|
+
1. `STUCK_STEP` is Step 5 Validate Build.
|
|
493
|
+
2. Dev server processes exist, port 3000 is occupied, or Step 5 has had no artifacts for 30+ minutes.
|
|
494
|
+
3. `INTERVENTION_COUNTS[STUCK_PHASE] < 2`.
|
|
495
|
+
|
|
496
|
+
Fix:
|
|
497
|
+
|
|
498
|
+
1. Kill port 3000 processes.
|
|
499
|
+
2. Kill `dev.sh`, `bun dev`, `next dev`, and `vite` processes.
|
|
500
|
+
3. Kill runner process tree: grandchildren, children, then main PID.
|
|
501
|
+
4. Sleep 5.
|
|
502
|
+
5. Remove stale lock: `{SPEC_DIR}/.build-phase.lock`.
|
|
503
|
+
6. Increment `INTERVENTION_COUNTS[STUCK_PHASE]`.
|
|
504
|
+
7. Append an `### Intervention` entry to `LEARNINGS_FILE`.
|
|
505
|
+
8. Relaunch the runner with `all`:
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
cd "{PROJECT_ROOT}" && "{RUNNER_SCRIPT}" "{HL_PLAN_PATH}" all > /tmp/build-feature.log 2>&1 &
|
|
509
|
+
echo $!
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
9. Update `BUILD_PID`, reset `STALL_SUSPECTED=false`, touch `/tmp/build-feature-lastpoll`, and return to Step 4.
|
|
513
|
+
|
|
514
|
+
Why `all`: the runner iterates all phases, and `build-phase` resumes/skips completed work from `STATE.md` and artifacts.
|
|
515
|
+
|
|
516
|
+
#### 8.3 Unknown stall
|
|
517
|
+
|
|
518
|
+
If no playbook matches:
|
|
519
|
+
|
|
520
|
+
1. Append `### Unrecognized Stall` to `LEARNINGS_FILE`.
|
|
521
|
+
2. Kill runner process tree and port 3000 to avoid orphans.
|
|
522
|
+
3. Mark feature status `aborted`.
|
|
523
|
+
4. Proceed to Step 9 Final Report.
|
|
524
|
+
|
|
525
|
+
### Step 9: Final Build Feature Report
|
|
526
|
+
|
|
527
|
+
Present the final results using this exact vocabulary and structure.
|
|
528
|
+
|
|
529
|
+
```markdown
|
|
530
|
+
## Build Feature Report
|
|
531
|
+
|
|
532
|
+
**Feature:** {TASK_NAME}
|
|
533
|
+
**Spec:** {HL_PLAN_PATH}
|
|
534
|
+
**Status:** {completed | partial | aborted}
|
|
535
|
+
**Duration:** {total minutes}m
|
|
536
|
+
**Phases:** {completed_count}/{TOTAL_PHASES}
|
|
537
|
+
**Criteria:** {complete_count}/{total_criteria_count} verified complete
|
|
538
|
+
|
|
539
|
+
### Phase Results
|
|
540
|
+
| Phase | Name | Status | Duration | Interventions | Criteria |
|
|
541
|
+
|-------|------|--------|----------|---------------|----------|
|
|
542
|
+
| 1 | {phase_name} | {status} | {duration}m | {count} | {complete}/{total} |
|
|
543
|
+
|
|
544
|
+
### Criteria Issues
|
|
545
|
+
| Phase | Criterion | Status | Detail |
|
|
546
|
+
|-------|-----------|--------|--------|
|
|
547
|
+
| {N} | {criterion text} | {incomplete/blocked/dropped} | {evidence or reason} |
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
Omit `### Criteria Issues` only if there are no incomplete, blocked, or dropped criteria.
|
|
551
|
+
|
|
552
|
+
Continue:
|
|
553
|
+
|
|
554
|
+
```markdown
|
|
555
|
+
### Interventions
|
|
556
|
+
{total_count} total interventions applied.
|
|
557
|
+
|
|
558
|
+
{If total_count > 0: list each intervention with phase number, step, error type, and outcome.}
|
|
559
|
+
{If total_count == 0: No interventions were needed. All phases completed without monitor intervention.}
|
|
560
|
+
|
|
561
|
+
### Learnings File
|
|
562
|
+
Full build log saved to: {LEARNINGS_FILE}
|
|
563
|
+
Runner log: /tmp/build-feature.log
|
|
564
|
+
|
|
565
|
+
### Next Steps
|
|
566
|
+
- {If completed and all criteria complete: All phases built successfully and all success criteria verified. Review STATE.md and phase completion reports for details.}
|
|
567
|
+
- {If completed but criteria issues exist: All phases completed, but {count} success criteria were not fully met. Review Criteria Issues and the learnings file.}
|
|
568
|
+
- {If partial: Phases {list} completed. Phase {N} stopped with status {status}. Review the learnings file and phase completion report. To retry: /build-feature {HL_PLAN_PATH}}
|
|
569
|
+
- {If aborted: Build aborted due to {reason}. See learnings file for diagnosis. After resolving the issue, retry with: /build-feature {HL_PLAN_PATH}}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### Step 10: Cleanup
|
|
573
|
+
|
|
574
|
+
After final report, clean temporary monitor files unless the user asks to preserve them:
|
|
575
|
+
|
|
576
|
+
```bash
|
|
577
|
+
rm -f /tmp/build-feature-lastpoll
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
Do not delete `LEARNINGS_FILE`.
|
|
581
|
+
|
|
582
|
+
Do not delete phase artifacts.
|
|
583
|
+
|
|
584
|
+
If the build is still running because of an abort/intervention failure, kill the runner process tree and clear port 3000 before exiting.
|
|
585
|
+
|
|
586
|
+
## Edge cases
|
|
587
|
+
|
|
588
|
+
1. **Already-completed phases**: runner invokes `build-phase` for each selected phase; `build-phase` resume logic should detect complete artifacts/state and exit quickly.
|
|
589
|
+
2. **Partial phases**: `build-phase` resumes from incomplete step according to `STATE.md` and artifact validity.
|
|
590
|
+
3. **Blocked phase**: runner stops by default; monitor reports `partial` unless an explicit accepted-blocker policy is later added.
|
|
591
|
+
4. **Accepted blockers**: future version may support explicit blocker override via prompt argument, HL metadata, or sidecar config. Do not silently continue through blocked phases in v1.
|
|
592
|
+
5. **Max interventions**: max 2 per phase. After that, abort.
|
|
593
|
+
6. **Concurrent runs**: active `.build-phase.lock` aborts preflight.
|
|
594
|
+
7. **Context compaction**: `build-feature-learnings.md` is the durable source of truth.
|
|
595
|
+
8. **Build continues independently**: monitor is observer, not controller. The runner process owns the phase loop.
|
|
596
|
+
9. **Restart uses `all`**: this is intentional because `build-phase` resume logic handles skipped/completed work.
|
|
597
|
+
10. **No macOS `open`**: browser validation remains owned by `build-phase` and must use `agent-browser` through existing skills.
|
package/manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.9.
|
|
2
|
+
"version": "1.9.8",
|
|
3
3
|
"presets": {
|
|
4
4
|
"coding": {
|
|
5
5
|
"description": "Research-driven coding workflow",
|
|
@@ -99,7 +99,8 @@
|
|
|
99
99
|
],
|
|
100
100
|
"prompts": [
|
|
101
101
|
"explore-codebase",
|
|
102
|
-
"build-phase"
|
|
102
|
+
"build-phase",
|
|
103
|
+
"build-feature"
|
|
103
104
|
],
|
|
104
105
|
"extensions": [
|
|
105
106
|
"pinned-response",
|