prizmkit 1.0.76 → 1.0.78

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.
@@ -1,13 +1,14 @@
1
1
  # dev-pipeline
2
2
 
3
- Autonomous development pipeline that drives the `prizm-dev-team` multi-agent team through iterative CodeBuddy CLI sessions, implementing a complete app feature-by-feature from a `feature-list.json` specification.
3
+ Autonomous development pipeline that drives the `prizm-dev-team` multi-agent team through iterative AI CLI sessions, implementing a complete app feature-by-feature from a `feature-list.json` specification. Includes a parallel bug-fix pipeline for `bug-fix-list.json`.
4
4
 
5
5
  ## Prerequisites
6
6
 
7
7
  - Python 3.8+
8
8
  - [jq](https://jqlang.github.io/jq/) (`brew install jq`)
9
9
  - AI CLI in PATH: CodeBuddy (`cbc`) or Claude Code (`claude`)
10
- - `feature-list.json` generated by the `app-planner` skill
10
+ - `feature-list.json` generated by the `app-planner` skill (for feature pipeline)
11
+ - `bug-fix-list.json` generated by the `bug-planner` skill (for bug pipeline)
11
12
 
12
13
  ## Quick Start
13
14
 
@@ -25,143 +26,638 @@ python3 dev-pipeline/scripts/init-pipeline.py \
25
26
 
26
27
  # 4. Check progress at any time (from another terminal)
27
28
  ./dev-pipeline/run.sh status feature-list.json
29
+
30
+ # 5. Or run as a background daemon
31
+ ./dev-pipeline/launch-daemon.sh start feature-list.json
28
32
  ```
29
33
 
30
- ## Commands
34
+ ---
35
+
36
+ ## Shell Scripts Reference
31
37
 
32
- | Command | Description |
33
- |---------|-------------|
34
- | `./run.sh run [feature-list.json] [options]` | Start or resume the pipeline. Processes features sequentially by dependency order. |
35
- | `./run.sh status [feature-list.json]` | Display current pipeline status: completed, pending, blocked, failed features. |
36
- | `./run.sh test-cli` | Test AI CLI detection: show detected CLI, version, platform, and query the AI model identity. |
37
- | `./run.sh reset` | Clear all runtime state in `state/`. Pipeline starts fresh on next `run`. |
38
- | `./run.sh help` | Show usage help. |
39
- | `./retry-feature.sh <feature-id> [feature-list.json]` | Retry a single failed feature. Runs one session then exits. |
40
- | `./reset-feature.sh <feature-id> [--clean] [--run]` | Reset a feature to pending. `--clean` deletes artifacts, `--run` auto-retries. |
38
+ ### `run.sh` Feature Pipeline Runner
41
39
 
42
- `run.sh` 常用 options:`--resume-phase N`、`--max-retries N`、`--timeout SEC`、`--ai-cli CMD`、`--dry-run`、`--no-reset`。
40
+ Main entry point. Drives the full feature development pipeline.
41
+
42
+ ```bash
43
+ ./run.sh run [feature-list.json] # Run all features
44
+ ./run.sh run <feature-id> [options] # Run a single feature (F-NNN)
45
+ ./run.sh status [feature-list.json] # Show pipeline status
46
+ ./run.sh reset # Clear all state in state/
47
+ ./run.sh test-cli # Test AI CLI detection
48
+ ./run.sh help # Show usage help
49
+ ```
43
50
 
44
- If `feature-list.json` path is omitted, defaults to `.dev-pipeline/feature-list.json` (run.sh) or `feature-list.json` (retry-feature.sh).
51
+ **Single-feature options:**
45
52
 
46
- ### Retrying a Failed Feature
53
+ | Option | Description |
54
+ |--------|-------------|
55
+ | `--dry-run` | Generate bootstrap prompt only, don't spawn AI session |
56
+ | `--timeout N` | Override `SESSION_TIMEOUT` for this run (seconds) |
57
+ | `--resume-phase N` | Resume from specific phase number |
58
+ | `--no-reset` | Don't reset feature artifacts before running |
47
59
 
48
- When a feature fails after max retries, use `retry-feature.sh` to run a single retry session:
60
+ **Examples:**
49
61
 
50
62
  ```bash
51
- # Retry F-007
52
- ./dev-pipeline/retry-feature.sh F-007
63
+ # Run all features
64
+ ./dev-pipeline/run.sh run feature-list.json
53
65
 
54
- # With custom feature list
55
- ./dev-pipeline/retry-feature.sh F-007 feature-list.json
66
+ # Run a single feature
67
+ ./dev-pipeline/run.sh run F-007
56
68
 
57
- # With timeout (default: no limit)
58
- SESSION_TIMEOUT=7200 ./dev-pipeline/retry-feature.sh F-007
69
+ # Dry run inspect the generated prompt without spawning a session
70
+ ./dev-pipeline/run.sh run F-007 --dry-run
71
+
72
+ # Resume from Phase 6 (implementation)
73
+ ./dev-pipeline/run.sh run feature-list.json --resume-phase 6
74
+
75
+ # With timeout per session
76
+ SESSION_TIMEOUT=7200 ./dev-pipeline/run.sh run feature-list.json
59
77
  ```
60
78
 
61
- The script will:
62
- 1. Reset the feature status to allow retry
63
- 2. Generate a fresh bootstrap prompt
64
- 3. Run exactly one AI CLI session with heartbeat monitoring
65
- 4. Update feature status based on the result
66
- 5. Exit (does not continue to other features)
79
+ If `feature-list.json` path is omitted, defaults to `feature-list.json` in the project root.
80
+
81
+ ---
67
82
 
68
- ### Resetting a Failed Feature
83
+ ### `retry-feature.sh` Retry Single Failed Feature
69
84
 
70
- When a feature is stuck (e.g. retry count exceeded, bad artifacts), use `reset-feature.sh` to wipe its state:
85
+ Runs exactly ONE AI CLI session for a specified feature, then exits.
71
86
 
72
87
  ```bash
73
- # Reset status only (retry_count → 0, status → pending)
74
- ./dev-pipeline/reset-feature.sh F-007
88
+ ./retry-feature.sh <feature-id> [feature-list.json]
89
+ ```
75
90
 
76
- # Reset + delete all session history and .prizmkit artifacts
77
- ./dev-pipeline/reset-feature.sh F-007 --clean
91
+ **What it does:**
92
+ 1. Cleans feature artifacts for a fresh restart
93
+ 2. Generates a fresh bootstrap prompt
94
+ 3. Runs exactly one AI CLI session with heartbeat monitoring
95
+ 4. Updates feature status based on the result
96
+ 5. Exits (does not continue to other features)
78
97
 
79
- # Reset + clean + immediately retry
80
- ./dev-pipeline/reset-feature.sh F-007 --clean --run
98
+ **Examples:**
81
99
 
82
- # With custom feature list
83
- ./dev-pipeline/reset-feature.sh F-007 --clean my-features.json
100
+ ```bash
101
+ ./dev-pipeline/retry-feature.sh F-007
102
+ ./dev-pipeline/retry-feature.sh F-007 feature-list.json
103
+ SESSION_TIMEOUT=7200 ./dev-pipeline/retry-feature.sh F-007
104
+ MODEL=claude-opus-4.6 ./dev-pipeline/retry-feature.sh F-007
84
105
  ```
85
106
 
86
- What gets cleaned with `--clean`:
107
+ ---
108
+
109
+ ### `reset-feature.sh` — Reset Failed/Stuck Feature
110
+
111
+ Resets a feature's state so it can be re-executed from scratch.
112
+
113
+ ```bash
114
+ ./reset-feature.sh <feature-id> [--clean] [--run] [feature-list.json]
115
+ ```
116
+
117
+ | Flag | Description |
118
+ |------|-------------|
119
+ | `--clean` | Delete session history + `.prizmkit/specs/{slug}/` artifacts |
120
+ | `--run` | Immediately retry after reset (calls `retry-feature.sh`) |
121
+
122
+ **What gets cleaned with `--clean`:**
87
123
  - `state/features/F-XXX/sessions/` — all session logs and prompts
88
- - `.prizmkit/specs/{feature-slug}/` — spec.md, plan.md (with Tasks section), contracts/
124
+ - `.prizmkit/specs/{feature-slug}/` — spec.md, plan.md, context-snapshot.md
89
125
 
90
- What is always reset (with or without `--clean`):
126
+ **What is always reset (with or without `--clean`):**
91
127
  - `status.json` — status → pending, retry_count → 0
92
128
  - `feature-list.json` — feature status → pending
93
129
 
94
- ## Environment Variables
130
+ **Examples:**
131
+
132
+ ```bash
133
+ ./dev-pipeline/reset-feature.sh F-007 # Reset status only
134
+ ./dev-pipeline/reset-feature.sh F-007 --clean # Reset + delete artifacts
135
+ ./dev-pipeline/reset-feature.sh F-007 --clean --run # Reset + clean + retry
136
+ ./dev-pipeline/reset-feature.sh F-007 --clean my-features.json
137
+ ```
138
+
139
+ ---
95
140
 
96
- | Variable | Default | Description |
97
- |----------|---------|-------------|
98
- | `MAX_RETRIES` | `3` | Maximum retry attempts per feature before marking as failed. |
99
- | `SESSION_TIMEOUT` | `0` (no limit) | Timeout in seconds per AI CLI session. 0 = no timeout. |
100
- | `AI_CLI` | auto-detect | AI CLI command name. Auto-detects `cbc` or `claude`. Set to override. |
101
- | `MODEL` | (none) | AI model ID for the session. Passed as `--model` to the CLI. See [Model Selection](#model-selection). |
102
- | `CODEBUDDY_CLI` | (deprecated) | Legacy alias for `AI_CLI`. Prefer `AI_CLI`. |
103
- | `VERBOSE` | `0` | Set to `1` to enable `--verbose` on AI CLI (shows subagent output). |
104
- | `HEARTBEAT_INTERVAL` | `30` | Seconds between heartbeat log output while a session is running. |
105
- | `HEARTBEAT_STALE_THRESHOLD` | `600` | Seconds before a session is considered stale/stuck. |
106
- | `LOG_CLEANUP_ENABLED` | `1` | Run log cleanup before pipeline execution (`1`=enabled, `0`=disabled). |
107
- | `LOG_RETENTION_DAYS` | `14` | Delete logs older than N days. |
108
- | `LOG_MAX_TOTAL_MB` | `1024` | Keep total log size under N MB by deleting oldest logs first. |
141
+ ### `launch-daemon.sh` Feature Pipeline Daemon
109
142
 
110
- Example with custom config:
143
+ Manages `run.sh` as a background daemon process with PID tracking and log consolidation. Designed for invocation from AI skill sessions.
111
144
 
112
145
  ```bash
113
- MAX_RETRIES=5 ./dev-pipeline/run.sh run feature-list.json
146
+ ./launch-daemon.sh start [feature-list.json] [--mode <mode>] [--env "KEY=VAL ..."]
147
+ ./launch-daemon.sh stop
148
+ ./launch-daemon.sh status
149
+ ./launch-daemon.sh logs [--lines N] [--follow]
150
+ ./launch-daemon.sh restart [feature-list.json] [--mode <mode>] [--env "KEY=VAL ..."]
151
+ ./launch-daemon.sh help
152
+ ```
114
153
 
115
- # With 2-hour timeout per session
116
- SESSION_TIMEOUT=7200 ./dev-pipeline/run.sh run feature-list.json
154
+ | Subcommand | Description |
155
+ |------------|-------------|
156
+ | `start` | Launch pipeline in background. Stores PID in `state/.pipeline.pid` |
157
+ | `stop` | Gracefully stop (SIGTERM, waits 30s, then SIGKILL) |
158
+ | `status` | Check if running; outputs JSON + formatted progress to stderr |
159
+ | `logs` | View pipeline logs. `--follow` for live tail, `--lines N` for last N lines |
160
+ | `restart` | Stop + start |
161
+
162
+ **`--mode` options:** `lite`, `standard`, `full`, `self-evolve`
117
163
 
118
- # Keep only recent logs and cap total log size
119
- LOG_RETENTION_DAYS=7 LOG_MAX_TOTAL_MB=512 ./dev-pipeline/run.sh run feature-list.json
164
+ **`--env` format:** Pass environment variables as a quoted string:
165
+
166
+ ```bash
167
+ ./dev-pipeline/launch-daemon.sh start feature-list.json \
168
+ --mode standard \
169
+ --env "MAX_RETRIES=5 SESSION_TIMEOUT=3600 MODEL=claude-sonnet-4.6"
120
170
  ```
121
171
 
122
- ### AI CLI Configuration
172
+ **Output (JSON on stdout for programmatic consumption):**
123
173
 
124
- The pipeline auto-detects which AI CLI to use. Detection priority:
174
+ ```json
175
+ {
176
+ "success": true,
177
+ "pid": 12345,
178
+ "log_file": "state/pipeline-daemon.log",
179
+ "started_at": "2026-03-21T12:00:00Z",
180
+ "progress": {
181
+ "total": 10, "completed": 3, "in_progress": 1,
182
+ "failed": 0, "pending": 6, "percent": 30.0
183
+ }
184
+ }
185
+ ```
125
186
 
126
- 1. `AI_CLI` environment variable (highest)
127
- 2. `.prizmkit/config.json` `ai_cli` field
128
- 3. `CODEBUDDY_CLI` environment variable (legacy)
129
- 4. Auto-detect: `cbc` in PATH `claude` in PATH (lowest)
187
+ **Key behaviors:**
188
+ - Log stored at `state/pipeline-daemon.log` (50MB rotation)
189
+ - Metadata at `state/.pipeline-meta.json`
190
+ - Unsets `CLAUDECODE` env to prevent nested session errors
191
+
192
+ ---
130
193
 
131
- To permanently configure a project to use a specific CLI, create `.prizmkit/config.json`:
194
+ ### `run-bugfix.sh` Bug-Fix Pipeline Runner
195
+
196
+ Equivalent to `run.sh` but for the bug-fix pipeline.
197
+
198
+ ```bash
199
+ ./run-bugfix.sh run [bug-fix-list.json] # Run all bugs
200
+ ./run-bugfix.sh run <bug-id> [options] # Run single bug (B-NNN)
201
+ ./run-bugfix.sh status [bug-fix-list.json] # Show status
202
+ ./run-bugfix.sh reset # Clear all bugfix state
203
+ ./run-bugfix.sh help
204
+ ```
205
+
206
+ **Single-bug options:** `--dry-run`, `--timeout N` (same as `run.sh`)
207
+
208
+ Processes bugs by: **severity** (critical > high > medium > low) then **priority** number.
209
+
210
+ ---
211
+
212
+ ### `retry-bug.sh` — Retry Single Failed Bug
213
+
214
+ ```bash
215
+ ./retry-bug.sh <bug-id> [bug-fix-list.json]
216
+ ```
217
+
218
+ Same behavior as `retry-feature.sh` but for bugs. Cleans bug artifacts, generates bugfix prompt, runs one session, updates status.
219
+
220
+ ---
221
+
222
+ ### `launch-bugfix-daemon.sh` — Bug-Fix Pipeline Daemon
223
+
224
+ Identical interface to `launch-daemon.sh` but manages `run-bugfix.sh` in background.
225
+
226
+ ```bash
227
+ ./launch-bugfix-daemon.sh start [bug-fix-list.json] [--env "KEY=VAL ..."]
228
+ ./launch-bugfix-daemon.sh stop
229
+ ./launch-bugfix-daemon.sh status
230
+ ./launch-bugfix-daemon.sh logs [--lines N] [--follow]
231
+ ./launch-bugfix-daemon.sh restart [bug-fix-list.json] [--env "KEY=VAL ..."]
232
+ ```
233
+
234
+ Uses `bugfix-state/` instead of `state/`.
235
+
236
+ ---
237
+
238
+ ## Python Scripts Reference
239
+
240
+ ### `scripts/init-pipeline.py` — Initialize Feature Pipeline State
241
+
242
+ Validates `feature-list.json` schema and creates the `state/` directory structure.
243
+
244
+ ```bash
245
+ python3 scripts/init-pipeline.py \
246
+ --feature-list <path> \
247
+ --state-dir <path>
248
+ ```
249
+
250
+ **Validation checks:**
251
+ - Schema: `$schema == "dev-pipeline-feature-list-v1"`
252
+ - Required fields: `app_name` (string), `features` (non-empty array)
253
+ - Per-feature: `id` (F-NNN), `title`, `description`, `priority` (int), `dependencies` (array of F-NNN), `acceptance_criteria` (array), `status`
254
+ - Dependency DAG cycle detection (Kahn's algorithm)
255
+
256
+ **Output (JSON to stdout):**
257
+
258
+ ```json
259
+ { "valid": true, "features_count": 10, "state_dir": "/absolute/path/state" }
260
+ ```
261
+
262
+ **Created files:**
263
+ - `state/pipeline.json` — Pipeline metadata (run_id, created_at, total_features)
264
+ - `state/features/{F-NNN}/status.json` — Per-feature status
265
+ - `state/features/{F-NNN}/sessions/` — Session history directory
266
+
267
+ ---
268
+
269
+ ### `scripts/init-bugfix-pipeline.py` — Initialize Bug-Fix Pipeline State
270
+
271
+ ```bash
272
+ python3 scripts/init-bugfix-pipeline.py \
273
+ --bug-list <path> \
274
+ --state-dir <path>
275
+ ```
276
+
277
+ **Validation:** Schema `dev-pipeline-bug-fix-list-v1`, required fields per bug: `id` (B-NNN), `title`, `description`, `severity` (critical|high|medium|low), `error_source`, `verification_type`, `acceptance_criteria`, `status`.
278
+
279
+ ---
280
+
281
+ ### `scripts/init-dev-team.py` — Initialize PrizmKit Directories
282
+
283
+ Creates per-feature directory structure for PrizmKit agent artifacts.
284
+
285
+ ```bash
286
+ python3 scripts/init-dev-team.py \
287
+ --project-root <path> \
288
+ [--feature-id <id>] \
289
+ [--feature-slug <slug>]
290
+ ```
291
+
292
+ **Creates:** `.prizmkit/specs/{feature-slug}/` directory.
293
+
294
+ ---
295
+
296
+ ### `scripts/generate-bootstrap-prompt.py` — Generate Feature Session Prompt
297
+
298
+ Renders a session-specific bootstrap prompt from a tier template and feature-list.json.
299
+
300
+ ```bash
301
+ python3 scripts/generate-bootstrap-prompt.py \
302
+ --feature-list <path> \
303
+ --feature-id <id> \
304
+ --session-id <id> \
305
+ --run-id <id> \
306
+ --retry-count <n> \
307
+ --resume-phase <n|null> \
308
+ --output <path> \
309
+ [--state-dir <path>] \
310
+ [--template <path>] \
311
+ [--mode lite|standard|full|self-evolve]
312
+ ```
313
+
314
+ **Template auto-selection by complexity:**
315
+
316
+ | `estimated_complexity` | Pipeline Mode | Template |
317
+ |------------------------|--------------|----------|
318
+ | `low` | lite | `bootstrap-tier1.md` (single agent) |
319
+ | `medium` | standard | `bootstrap-tier2.md` (dual agent) |
320
+ | `high` / `critical` | full | `bootstrap-tier3.md` (full team) |
321
+ | (override) | self-evolve | `bootstrap-tier3.md` + framework guardrails |
322
+
323
+ **Output (JSON to stdout):**
324
+
325
+ ```json
326
+ { "success": true, "output_path": "/absolute/path/prompt.md", "model": "claude-sonnet-4.6" }
327
+ ```
328
+
329
+ The `model` field is extracted from the feature's `"model"` field in feature-list.json (empty string if not specified). Used by `run.sh` and `retry-feature.sh` to set `--model` on the AI CLI.
330
+
331
+ **Conditional blocks resolved:**
332
+ - `{{IF_RESUME}}` / `{{IF_FRESH_START}}` — Resume vs fresh start
333
+ - `{{IF_INIT_NEEDED}}` / `{{IF_INIT_DONE}}` — PrizmKit init status
334
+ - `{{IF_MODE_LITE}}` / `{{IF_MODE_STANDARD}}` / `{{IF_MODE_FULL}}` / `{{IF_MODE_SELF_EVOLVE}}` — Pipeline mode blocks
335
+
336
+ ---
337
+
338
+ ### `scripts/generate-bugfix-prompt.py` — Generate Bug-Fix Session Prompt
339
+
340
+ ```bash
341
+ python3 scripts/generate-bugfix-prompt.py \
342
+ --bug-list <path> \
343
+ --bug-id <id> \
344
+ --session-id <id> \
345
+ --run-id <id> \
346
+ --retry-count <n> \
347
+ --resume-phase <n|null> \
348
+ --state-dir <path> \
349
+ --output <path> \
350
+ [--template <path>]
351
+ ```
352
+
353
+ Resolves `{{BUG_ID}}`, `{{BUG_TITLE}}`, `{{SEVERITY}}`, `{{VERIFICATION_TYPE}}`, `{{ERROR_SOURCE}}`, etc.
354
+
355
+ ---
356
+
357
+ ### `scripts/update-feature-status.py` — Feature State Machine
358
+
359
+ Core state management for features. Supports 8 actions.
360
+
361
+ ```bash
362
+ python3 scripts/update-feature-status.py \
363
+ --feature-list <path> \
364
+ --state-dir <path> \
365
+ --action <action> \
366
+ [options]
367
+ ```
368
+
369
+ | Action | Required Args | Description |
370
+ |--------|--------------|-------------|
371
+ | `get_next` | — | Find next runnable feature (pending + deps met). Returns `PIPELINE_COMPLETE` or `PIPELINE_BLOCKED` if none. |
372
+ | `start` | `--feature-id` | Mark feature as in_progress |
373
+ | `update` | `--feature-id --session-status <status> [--session-id] [--max-retries N]` | Update after session completes |
374
+ | `status` | — | Pretty-print pipeline status (progress bar, ETA, per-feature breakdown) |
375
+ | `reset` | `--feature-id` | Reset to pending, retry_count → 0 |
376
+ | `clean` | `--feature-id --feature-slug --project-root` | Reset + delete all session history and .prizmkit artifacts |
377
+ | `pause` | — | Save state for graceful shutdown |
378
+ | `complete` | `--feature-id` | Shortcut for manually marking completed |
379
+
380
+ **Session status values (for `--session-status`):**
381
+ `success`, `partial_resumable`, `partial_not_resumable`, `failed`, `crashed`, `timed_out`, `commit_missing`, `docs_missing`, `merge_conflict`
382
+
383
+ **Output (JSON to stdout):**
132
384
 
133
385
  ```json
134
386
  {
135
- "ai_cli": "claude-internal",
136
- "platform": "claude"
387
+ "action": "update", "feature_id": "F-007",
388
+ "session_status": "success", "new_status": "completed",
389
+ "retry_count": 0, "updated_at": "2026-03-21T12:34:56Z"
137
390
  }
138
391
  ```
139
392
 
140
- Or override per-invocation:
393
+ ---
394
+
395
+ ### `scripts/update-bug-status.py` — Bug State Machine
396
+
397
+ Same interface as `update-feature-status.py` but for bugs.
141
398
 
142
399
  ```bash
143
- AI_CLI=claude-internal ./dev-pipeline/run.sh run feature-list.json
400
+ python3 scripts/update-bug-status.py \
401
+ --bug-list <path> \
402
+ --state-dir <path> \
403
+ --action <action> \
404
+ [options]
144
405
  ```
145
406
 
146
- ### Model Selection
407
+ **Actions:** `get_next`, `update`, `status`, `pause`, `reset`, `clean`
147
408
 
148
- Use the `MODEL` environment variable to specify which AI model to use. The value is passed as `--model <id>` to the CLI.
409
+ **Priority order:** severity (critical > high > medium > low), then priority number.
410
+
411
+ ---
412
+
413
+ ### `scripts/check-session-status.py` — Parse Session Outcome
414
+
415
+ Reads the `session-status.json` written by the AI agent and determines outcome.
149
416
 
150
417
  ```bash
151
- # Run pipeline with Sonnet (faster, cheaper)
152
- MODEL=claude-sonnet-4.6 ./dev-pipeline/run.sh run feature-list.json
418
+ python3 scripts/check-session-status.py --status-file <path>
419
+ ```
420
+
421
+ **Output (single line to stdout):**
422
+ `success` | `partial_resumable` | `partial_not_resumable` | `failed` | `crashed` | `commit_missing` | `docs_missing` | `merge_conflict`
423
+
424
+ **Detail report (JSON to stderr):**
425
+
426
+ ```json
427
+ {
428
+ "status": "success", "feature_id": "F-007",
429
+ "completed_phases": [...], "error_count": 0, "can_resume": false
430
+ }
431
+ ```
432
+
433
+ ---
434
+
435
+ ### `scripts/detect-stuck.py` — Detect Stuck/Stale Features
436
+
437
+ Identifies features that are blocked or stuck in the pipeline.
438
+
439
+ ```bash
440
+ python3 scripts/detect-stuck.py \
441
+ --state-dir <path> \
442
+ [--feature-id <id>] \
443
+ [--max-retries <n>] \
444
+ [--stale-threshold <seconds>]
445
+ ```
446
+
447
+ **Checks performed:**
448
+ 1. Max retries exceeded
449
+ 2. Stuck at same checkpoint for 3 consecutive sessions
450
+ 3. Stale heartbeat (in_progress with no recent activity)
451
+ 4. Dependency deadlock (depends on a failed feature)
452
+
453
+ **Output (JSON):**
454
+
455
+ ```json
456
+ {
457
+ "stuck_features": [
458
+ { "feature_id": "F-007", "reason": "max_retries_exceeded", "suggestion": "..." }
459
+ ],
460
+ "total_checked": 10, "stuck_count": 1
461
+ }
462
+ ```
463
+
464
+ **Exit code:** 0 if none stuck, 1 if any stuck.
465
+
466
+ ---
467
+
468
+ ### `scripts/cleanup-logs.py` — Log File Cleanup
469
+
470
+ Manages log file size by age and total size thresholds.
471
+
472
+ ```bash
473
+ python3 scripts/cleanup-logs.py \
474
+ --state-dir <path> \
475
+ [--retention-days <n>] \
476
+ [--max-total-mb <n>] \
477
+ [--dry-run]
478
+ ```
479
+
480
+ | Option | Default | Description |
481
+ |--------|---------|-------------|
482
+ | `--retention-days` | 14 | Delete files older than N days |
483
+ | `--max-total-mb` | 1024 | If total > N MB, remove oldest first |
484
+ | `--dry-run` | false | Show what would be deleted without deleting |
485
+
486
+ ---
153
487
 
154
- # Run pipeline with Opus (most capable)
155
- MODEL=claude-opus-4.6 ./dev-pipeline/run.sh run feature-list.json
488
+ ### `scripts/parse-stream-progress.py` Real-Time Progress Parser
156
489
 
157
- # Retry a feature with a specific model
490
+ Reads AI CLI `stream-json` output and extracts progress metrics.
491
+
492
+ ```bash
493
+ python3 scripts/parse-stream-progress.py \
494
+ --session-log <path> \
495
+ --progress-file <path>
496
+ ```
497
+
498
+ **Runs as a background process** (spawned by `lib/heartbeat.sh`). Reads JSONL from session log, writes progress to `progress.json` (atomic writes).
499
+
500
+ **Phase detection (monotonic):** specify → plan → analyze → implement → code-review → retrospective → commit
501
+
502
+ **Output (progress.json):**
503
+
504
+ ```json
505
+ {
506
+ "updated_at": "2026-03-21T12:34:56Z",
507
+ "message_count": 42,
508
+ "current_tool": "bash",
509
+ "current_tool_input_summary": "npm test | head -20",
510
+ "current_phase": "implement",
511
+ "detected_phases": ["specify", "plan", "implement"],
512
+ "total_tool_calls": 23,
513
+ "is_active": true
514
+ }
515
+ ```
516
+
517
+ ---
518
+
519
+ ### `scripts/utils.py` — Shared Python Utilities
520
+
521
+ Imported by all Python scripts. Provides:
522
+
523
+ | Function | Description |
524
+ |----------|-------------|
525
+ | `load_json_file(path)` | Returns `(data, error_string)` |
526
+ | `write_json_file(path, data)` | Returns `error_string` or `None` |
527
+ | `setup_logging(name, level)` | Configure logger with stderr output |
528
+ | `error_out(message, code)` | Print error JSON + exit |
529
+ | `pad_right(text, width)` | Pad accounting for ANSI escape codes |
530
+
531
+ ---
532
+
533
+ ## Shell Libraries
534
+
535
+ ### `lib/common.sh` — CLI Detection & Shared Helpers
536
+
537
+ Sourced by daemon and runner scripts. Provides:
538
+
539
+ | Function | Description |
540
+ |----------|-------------|
541
+ | `prizm_detect_cli_and_platform()` | Sets `CLI_CMD` and `PLATFORM`. Priority: `AI_CLI` env > `config.json` > `CODEBUDDY_CLI` > auto-detect |
542
+ | `prizm_check_common_dependencies(cli_cmd)` | Verifies jq, python3, and CLI are installed |
543
+
544
+ Also exports: `log_info`, `log_warn`, `log_error`, `log_success` (with timestamps), and color constants.
545
+
546
+ ### `lib/branch.sh` — Git Branch Lifecycle
547
+
548
+ | Function | Description |
549
+ |----------|-------------|
550
+ | `branch_create(project_root, branch_name, source_branch)` | Create & checkout feature branch. Reuses if exists. Returns 0/1. |
551
+ | `branch_return(project_root, original_branch)` | Checkout back to original branch |
552
+
553
+ ### `lib/heartbeat.sh` — Heartbeat & Progress Monitoring
554
+
555
+ | Function | Description |
556
+ |----------|-------------|
557
+ | `start_heartbeat(cli_pid, session_log, progress_json, interval)` | Start background heartbeat monitor. Sets `_HEARTBEAT_PID`. |
558
+ | `stop_heartbeat(heartbeat_pid)` | Kill heartbeat process |
559
+ | `start_progress_parser(session_log, progress_json, scripts_dir)` | Spawn `parse-stream-progress.py` if stream-json supported. Sets `_PARSER_PID`. |
560
+ | `stop_progress_parser(parser_pid)` | Kill parser process |
561
+ | `detect_stream_json_support(cli_cmd)` | Sets `USE_STREAM_JSON=true\|false` |
562
+
563
+ ---
564
+
565
+ ## Environment Variables
566
+
567
+ ### Pipeline Control
568
+
569
+ | Variable | Default | Used By | Description |
570
+ |----------|---------|---------|-------------|
571
+ | `MAX_RETRIES` | `3` | run.sh | Max retry attempts per feature before marking as failed |
572
+ | `SESSION_TIMEOUT` | `0` (none) | run.sh, retry-feature.sh, run-bugfix.sh, retry-bug.sh | Timeout in seconds per AI CLI session. 0 = no timeout |
573
+ | `PIPELINE_MODE` | (auto) | run.sh, launch-daemon.sh | Override mode for all features: `lite\|standard\|full\|self-evolve` |
574
+ | `DEV_BRANCH` | auto-generated | run.sh | Custom git branch name (default: `dev/{feature-id}-{timestamp}`) |
575
+ | `AUTO_PUSH` | `0` | run.sh | Set to `1` to auto-push branch to remote after successful session |
576
+
577
+ ### AI CLI Configuration
578
+
579
+ | Variable | Default | Used By | Description |
580
+ |----------|---------|---------|-------------|
581
+ | `AI_CLI` | auto-detect | all shell scripts | AI CLI command name. Auto-detects `cbc` or `claude` |
582
+ | `PRIZMKIT_PLATFORM` | auto-detect | all shell scripts | Force platform: `codebuddy` or `claude` |
583
+ | `MODEL` | (none) | run.sh, retry-feature.sh, run-bugfix.sh, retry-bug.sh | AI model fallback. Overridden by per-feature `model` field. See [Model Selection](#model-selection) |
584
+ | `CODEBUDDY_CLI` | (deprecated) | all shell scripts | Legacy alias for `AI_CLI`. Prefer `AI_CLI` |
585
+ | `VERBOSE` | `0` | run.sh, retry-feature.sh | Set to `1` to enable `--verbose` on AI CLI |
586
+
587
+ ### Monitoring & Logging
588
+
589
+ | Variable | Default | Used By | Description |
590
+ |----------|---------|---------|-------------|
591
+ | `HEARTBEAT_INTERVAL` | `30` | run.sh, retry-feature.sh | Seconds between heartbeat log output |
592
+ | `HEARTBEAT_STALE_THRESHOLD` | `600` | run.sh | Seconds before a session is considered stale/stuck |
593
+ | `LOG_CLEANUP_ENABLED` | `1` | run.sh | Run log cleanup before pipeline execution |
594
+ | `LOG_RETENTION_DAYS` | `14` | run.sh | Delete logs older than N days |
595
+ | `LOG_MAX_TOTAL_MB` | `1024` | run.sh | Keep total log size under N MB |
596
+
597
+ **Examples:**
598
+
599
+ ```bash
600
+ # All env vars in one invocation
601
+ MAX_RETRIES=5 SESSION_TIMEOUT=7200 MODEL=claude-sonnet-4.6 VERBOSE=1 \
602
+ ./dev-pipeline/run.sh run feature-list.json
603
+
604
+ # Via daemon with --env
605
+ ./dev-pipeline/launch-daemon.sh start feature-list.json \
606
+ --mode standard \
607
+ --env "MAX_RETRIES=5 SESSION_TIMEOUT=3600 AUTO_PUSH=1"
608
+ ```
609
+
610
+ ---
611
+
612
+ ## Model Selection
613
+
614
+ Model is resolved with this priority chain (highest first):
615
+
616
+ 1. **Per-feature `model` field** in `feature-list.json`
617
+ 2. **`MODEL` environment variable**
618
+ 3. **No `--model` flag** (CLI uses its default)
619
+
620
+ ### Per-Feature Model
621
+
622
+ Specify a model for individual features in `feature-list.json`:
623
+
624
+ ```json
625
+ {
626
+ "features": [
627
+ { "id": "F-017", "title": "Complex Feature", "model": "claude-opus-4.6" },
628
+ { "id": "F-018", "title": "Simple Feature", "model": "claude-sonnet-4.6" },
629
+ { "id": "F-019", "title": "Use Default", "...": "..." }
630
+ ]
631
+ }
632
+ ```
633
+
634
+ - `F-017` will use `claude-opus-4.6` regardless of `$MODEL` env
635
+ - `F-018` will use `claude-sonnet-4.6` regardless of `$MODEL` env
636
+ - `F-019` will fall back to `$MODEL` env, or CLI default if `MODEL` is unset
637
+
638
+ ### Global Model via Environment
639
+
640
+ ```bash
641
+ # All features without a per-feature model use Sonnet
642
+ MODEL=claude-sonnet-4.6 ./dev-pipeline/run.sh run feature-list.json
643
+
644
+ # Retry with Opus
158
645
  MODEL=claude-opus-4.6 ./dev-pipeline/retry-feature.sh F-007
159
646
 
160
647
  # Test which model the CLI is using
161
648
  MODEL=claude-sonnet-4.6 ./dev-pipeline/run.sh test-cli
162
649
  ```
163
650
 
164
- Common model IDs (for `cbc`):
651
+ ### Dry-Run Model Verification
652
+
653
+ Use `--dry-run` to verify which model will be used without spawning a session:
654
+
655
+ ```bash
656
+ ./dev-pipeline/run.sh run F-017 --dry-run
657
+ # Output includes: "Feature Model: claude-opus-4.6"
658
+ ```
659
+
660
+ ### Common Model IDs
165
661
 
166
662
  | Model ID | Description |
167
663
  |----------|-------------|
@@ -169,153 +665,163 @@ Common model IDs (for `cbc`):
169
665
  | `claude-sonnet-4.6` | Balanced speed/capability (recommended for pipeline) |
170
666
  | `claude-haiku-4.5` | Fastest, cheapest, less capable |
171
667
 
172
- > **Note**: `--model` support depends on the CLI. `cbc` fully supports it. `claude-internal` does not support `--model` in headless mode (only interactive `/model` command). If `MODEL` is set but the CLI doesn't support it, the flag is silently ignored.
668
+ > **Note**: `--model` support depends on the CLI. `claude` and `cbc` fully support it. If the CLI doesn't support it, the flag is silently ignored.
173
669
 
174
- ### Testing AI CLI (`test-cli`)
670
+ ### Auto-Detection of Available Models
175
671
 
176
- Use `test-cli` to verify which CLI, version, and model the pipeline will use:
672
+ The pipeline automatically detects which AI models are available for your CLI:
177
673
 
178
674
  ```bash
179
- # Basic test — uses auto-detected CLI and default model
180
- ./dev-pipeline/run.sh test-cli
675
+ # Manual detection
676
+ ./dev-pipeline/scripts/detect-models.sh
181
677
 
182
- # Test with a specific model
183
- MODEL=claude-sonnet-4.6 ./dev-pipeline/run.sh test-cli
184
-
185
- # Test with a specific CLI
186
- AI_CLI=cbc ./dev-pipeline/run.sh test-cli
678
+ # Results saved to
679
+ cat .prizmkit/available-models.json
187
680
  ```
188
681
 
189
- Example output:
682
+ Detection methods vary by platform:
683
+
684
+ - **CodeBuddy (cbc)**: Probes the CLI backend for the full list of supported models
685
+ - **Claude Code**: Self-reports the default model (model switching not available)
686
+
687
+ The pipeline runs detection automatically on:
688
+
689
+ - `./run.sh run` — before processing features
690
+ - `./retry-feature.sh` — before retrying
691
+ - `git pull` — via post-merge hook (background, non-blocking)
692
+
693
+ ### Model Validation
694
+
695
+ When `available-models.json` exists, the pipeline validates feature model fields:
696
+
697
+ - Warns if a specified model is not in the available list
698
+ - Warns if the CLI doesn't support `--model` switching
699
+ - **Never blocks** — validation is advisory only
700
+
701
+ ---
702
+
703
+ ## AI CLI Configuration
704
+
705
+ The pipeline auto-detects which AI CLI to use. Detection priority:
706
+
707
+ 1. `AI_CLI` environment variable (highest)
708
+ 2. `.prizmkit/config.json` → `ai_cli` field
709
+ 3. `CODEBUDDY_CLI` environment variable (legacy)
710
+ 4. Auto-detect: `cbc` in PATH → `claude` in PATH (lowest)
190
711
 
712
+ To permanently configure, create `.prizmkit/config.json`:
713
+
714
+ ```json
715
+ {
716
+ "ai_cli": "claude",
717
+ "platform": "claude"
718
+ }
191
719
  ```
192
- ============================================
193
- Dev-Pipeline AI CLI Test
194
- ============================================
195
720
 
196
- Detected CLI: cbc
197
- Platform: codebuddy
198
- CLI Version: 2.62.1
721
+ Or override per-invocation:
199
722
 
200
- Querying AI model (headless mode)...
723
+ ```bash
724
+ AI_CLI=claude ./dev-pipeline/run.sh run feature-list.json
725
+ ```
201
726
 
202
- AI Response: I'm CodeBuddy, running Claude Opus 4.6
727
+ ### Testing AI CLI (`test-cli`)
203
728
 
204
- ============================================
729
+ ```bash
730
+ ./dev-pipeline/run.sh test-cli
731
+ MODEL=claude-sonnet-4.6 ./dev-pipeline/run.sh test-cli
732
+ AI_CLI=cbc ./dev-pipeline/run.sh test-cli
205
733
  ```
206
734
 
207
- The test sends a one-line prompt asking the AI to identify itself, with a 30-second timeout. If the CLI requires authentication or is unavailable, it shows a fallback message.
735
+ ---
208
736
 
209
737
  ## How It Works
210
738
 
211
- ### Execution Flow
739
+ ### Feature Pipeline Execution Flow
212
740
 
213
741
  ```
214
742
  run.sh main loop
215
-
216
- ├─ detect-stuck.py # Check for stale/stuck sessions
217
- ├─ update-feature-status.py # get_next: find next runnable feature (pending + deps met)
218
-
219
- ├─ generate-bootstrap-prompt.py # Build prompt with feature details + context
220
-
221
- ├─ AI CLI session # cbc --print -y < prompt (CodeBuddy)
222
- │ │ # claude --print -p "$(cat prompt)" --yes (Claude Code)
223
- └─ prizm-dev-team # Multi-agent team implements the feature
224
- │ ├─ Orchestrator # Main agent: init, plan, schedule, retrospective, commit
225
- ├─ Dev x N # Implementation with TDD
226
- └─ Reviewer # Analyze + code review
227
-
228
- ├─ check-session-status.py # Parse session outcome
229
- ├─ update-feature-status.py # Update feature state (completed/failed/retry)
230
-
231
- └─ loop → next feature
232
- ```
233
-
234
- ### 10-Phase Pipeline (per feature session)
235
-
236
- Each AI CLI session drives the prizm-dev-team through these phases. **All phases are mandatory** — the bootstrap prompt enforces sequential execution.
237
-
238
- > **Note**: The bootstrap prompt adapts these phases based on complexity mode (lite/standard/full). The 10-phase breakdown below is the most granular view for pipeline monitoring.
239
-
240
- | Phase | Name | Agent | PrizmKit Skills | Artifacts |
241
- |-------|------|-------|----------------|-----------|
242
- | 0 | Init | Orchestrator | `prizmkit-init` | `.prizm-docs/root.prizm`, `.prizmkit/config.json` |
243
- | 1 | Specify | Orchestrator | `prizmkit-specify`, `prizmkit-clarify` | `.prizmkit/specs/spec.md` |
244
- | 2 | Plan + Tasks | Orchestrator | `prizmkit-plan` | `.prizmkit/specs/plan.md` (含 Tasks section) |
245
- | 3 | Analyze | Reviewer | `prizmkit-analyze` | Analysis report (no CRITICAL issues) |
246
- | 4 | Schedule | Orchestrator | — | TaskList entries assigned |
247
- | 5 | Implement | Dev x N | `prizmkit-implement` | Code + tests, plan.md Tasks marked `[x]` |
248
- | 6 | Review | Reviewer | `prizmkit-code-review` | Integration tests, review report |
249
- | 7 | Fix Loop | Dev | — | Max 3 rounds of fixes |
250
- | 8 | Retrospective & Commit | Orchestrator | `prizmkit-retrospective`, `prizmkit-committer` | .prizm-docs/ synced + enriched, git commit |
743
+ |
744
+ +- detect-stuck.py # Check for stale/stuck sessions
745
+ +- update-feature-status.py # get_next: find next runnable feature
746
+ |
747
+ +- generate-bootstrap-prompt.py # Build prompt from template + feature
748
+ | # Returns JSON with model field
749
+ |
750
+ +- AI CLI session # claude -p "$(cat prompt)" --dangerously-skip-permissions
751
+ | | # cbc --print -y < prompt
752
+ | +- prizm-dev-team # Multi-agent team implements the feature
753
+ | +- Orchestrator # Main: init, context, plan, retrospective, commit
754
+ | +- Dev x N # Implementation with TDD
755
+ | +- Reviewer # Analyze + code review
756
+ |
757
+ +- check-session-status.py # Parse session outcome
758
+ +- update-feature-status.py # Update feature state (completed/failed/retry)
759
+ |
760
+ +- loop -> next feature
761
+ ```
762
+
763
+ ### Tiered Execution (per feature session)
764
+
765
+ The bootstrap prompt adapts based on feature complexity:
766
+
767
+ | Tier | Template | Agents | Use Case |
768
+ |------|----------|--------|----------|
769
+ | Tier 1 (lite) | `bootstrap-tier1.md` | Single agent handles everything | Low complexity features |
770
+ | Tier 2 (standard) | `bootstrap-tier2.md` | Orchestrator + Dev + Reviewer subagents | Medium complexity |
771
+ | Tier 3 (full) | `bootstrap-tier3.md` | Full team with spec/plan/analyze/implement/review phases | High/critical complexity |
772
+
773
+ **Self-evolve mode:** Uses Tier 3 template with additional framework guardrails for developing the PrizmKit framework itself.
251
774
 
252
775
  ### Feature Dependency Resolution
253
776
 
254
- Features are executed in dependency order. The pipeline uses a DAG (Directed Acyclic Graph) to determine which features are runnable:
777
+ Features are executed in dependency order via DAG:
255
778
 
256
- - A feature is **runnable** if status is `pending` and all dependencies are `completed`.
257
- - A feature is **blocked** if any dependency is not yet `completed`.
258
- - Features with no remaining runnable features and incomplete blocked features enter a 60s retry wait.
779
+ - **Runnable**: status is `pending` and all dependencies are `completed`
780
+ - **Blocked**: any dependency is not yet `completed`
781
+ - **Pipeline blocked**: no runnable features remain 60s retry wait
259
782
 
260
783
  ### Session Lifecycle
261
784
 
262
- 1. **Bootstrap prompt** is generated from the feature spec, tech stack context, and acceptance criteria.
263
- 2. The AI CLI is spawned as a background process:
264
- - **CodeBuddy**: `cbc --print -y < prompt` (prompt via stdin)
265
- - **Claude Code**: `claude --print -p "$(cat prompt)" --yes` (prompt via `-p` argument)
266
- 3. A **timeout watchdog** runs in parallel if `SESSION_TIMEOUT > 0`; kills the session if it exceeds the limit.
267
- 4. A **heartbeat monitor** prints progress every `HEARTBEAT_INTERVAL` seconds (default 30s).
268
- 5. On completion, the script checks for `session-status.json` to determine success/failure.
269
- 6. Feature status is updated. On failure, retry count increments. After `MAX_RETRIES`, the feature is marked failed.
785
+ 1. **Bootstrap prompt** generated from feature spec, context, and acceptance criteria
786
+ 2. AI CLI spawned as background process with optional `--model` flag
787
+ 3. **Timeout watchdog** runs in parallel if `SESSION_TIMEOUT > 0`
788
+ 4. **Heartbeat monitor** prints progress every `HEARTBEAT_INTERVAL` seconds
789
+ 5. **Progress parser** (if stream-json supported) extracts phase/tool metrics
790
+ 6. On completion, `session-status.json` determines success/failure
791
+ 7. Feature status updated; on failure, retry count increments
270
792
 
271
793
  ### Heartbeat Output
272
794
 
273
- While an AI CLI session is running, the pipeline outputs periodic heartbeat lines:
274
-
275
795
  ```
276
- [HEARTBEAT] 1m30s elapsed | log: 245KB (+12480B) | Creating team prizm-dev-team-F-001...
277
- [HEARTBEAT] 2m0s elapsed | log: 389KB (+147456B) | Generating spec.md for feature...
278
- [HEARTBEAT] 2m30s elapsed | log: 389KB (+0B) | (waiting for AI response)
796
+ > [HEARTBEAT] 1m30s elapsed | log: 245KB (+12480B) | Creating team prizm-dev-team-F-001...
797
+ > [HEARTBEAT] 2m0s elapsed | log: 389KB (+147456B) | Generating spec.md for feature...
798
+ @ [HEARTBEAT] 2m30s elapsed | log: 389KB (+0B) | (waiting for AI response)
279
799
  ```
280
800
 
281
- - `▶` (green): log is growing — session is actively producing output
282
- - `⏸` (yellow): log unchanged since last check — session may be waiting or stuck
283
- - Shows elapsed time, log file size, growth since last heartbeat, and last log line
801
+ - `>` (green): log is growing — session is actively producing output
802
+ - `@` (yellow): log unchanged — session may be waiting or stuck
284
803
 
285
804
  ### Monitoring Session Logs
286
805
 
287
- Each AI CLI session 的完整输出(tool 调用、文件读写、代码生成、AI 思考过程)都记录在 session log 中。开一个新终端实时查看:
288
-
289
806
  ```bash
290
- # 实时跟踪当前正在执行的 session 日志
807
+ # Live tail current session
291
808
  tail -f dev-pipeline/state/features/F-*/sessions/*/logs/session.log
292
809
 
293
- # 如果知道具体 feature ID,可以更精确
810
+ # Specific feature
294
811
  tail -f dev-pipeline/state/features/F-003/sessions/*/logs/session.log
295
- ```
296
-
297
- 通过日志可以判断:
298
- - session 当前在执行哪个 phase
299
- - 是否在读正确的文件
300
- - 是否出现幻觉或方向错误
301
- - 具体卡在什么步骤
302
812
 
303
- session 结束后查看完整日志:
304
-
305
- ```bash
813
+ # Review completed session
306
814
  cat dev-pipeline/state/features/F-003/sessions/F-003-*/logs/session.log | less
307
815
  ```
308
816
 
309
817
  ### Pause & Resume
310
818
 
311
- - **Ctrl+C** during execution triggers graceful shutdown — current state is saved.
312
- - **Re-running** `./run.sh run feature-list.json` resumes from where it left off. Completed features are skipped.
313
- - 如需强制从某一阶段继续,可使用:`./run.sh run feature-list.json --resume-phase 6`(例如直接进入实现阶段)。
819
+ - **Ctrl+C** triggers graceful shutdown — current state is saved
820
+ - **Re-running** `./run.sh run` resumes from where it left off (completed features skipped)
821
+ - Force resume from a phase: `./run.sh run feature-list.json --resume-phase 6`
314
822
 
315
823
  ### Manual Intervention
316
824
 
317
- If a feature fails after max retries, the pipeline blocks. To resolve:
318
-
319
825
  ```bash
320
826
  # Check what failed
321
827
  ./dev-pipeline/run.sh status feature-list.json
@@ -323,256 +829,202 @@ If a feature fails after max retries, the pipeline blocks. To resolve:
323
829
  # Review session logs
324
830
  cat dev-pipeline/state/features/F-XXX/sessions/*/logs/session.log
325
831
 
326
- # Option A: Fix manually and mark as complete
832
+ # Option A: Fix manually and mark complete
327
833
  python3 dev-pipeline/scripts/update-feature-status.py \
328
834
  --feature-list feature-list.json \
329
835
  --state-dir dev-pipeline/state \
330
836
  --feature-id F-XXX --action complete
331
837
 
332
- # Option B: Reset the feature for retry
838
+ # Option B: Reset for retry
333
839
  python3 dev-pipeline/scripts/update-feature-status.py \
334
840
  --feature-list feature-list.json \
335
841
  --state-dir dev-pipeline/state \
336
842
  --feature-id F-XXX --action reset
337
843
 
338
- # Resume pipeline
844
+ # Resume
339
845
  ./dev-pipeline/run.sh run feature-list.json
340
846
  ```
341
847
 
342
- ## Directory Structure
343
-
344
- ```
345
- dev-pipeline/
346
- ├── run.sh # Main entry point — full pipeline loop
347
- ├── retry-feature.sh # Retry a single failed feature
348
- ├── reset-feature.sh # Reset/clean a feature for fresh re-execution
349
- ├── README.md # This file
350
- ├── .gitignore # Ignores state/ and __pycache__/
351
- ├── scripts/
352
- │ ├── init-pipeline.py # Initialize state/ from feature-list.json
353
- │ ├── init-dev-team.py # Initialize .dev-team/ and .prizmkit/ directories
354
- │ ├── generate-bootstrap-prompt.py # Build per-feature prompt for AI CLI session
355
- │ ├── check-session-status.py # Parse session-status.json for outcome
356
- │ ├── update-feature-status.py # Update feature state + get_next + status display
357
- │ └── detect-stuck.py # Detect stuck/stale sessions by heartbeat
358
- ├── templates/
359
- │ ├── bootstrap-prompt.md # Prompt template for AI CLI sessions
360
- │ ├── feature-list-schema.json # JSON schema for feature-list.json
361
- │ └── session-status-schema.json # JSON schema for session output
362
- ├── assets/
363
- │ ├── feature-list-example.json # Example feature list (TaskFlow app)
364
- │ └── prizm-dev-team-integration.md # How pipeline integrates with prizm-dev-team
365
- └── state/ # Runtime state (gitignored, auto-generated)
366
- ├── pipeline.json # Pipeline run metadata
367
- ├── current-session.json # Currently executing session
368
- └── features/
369
- └── F-XXX/
370
- ├── status.json # Feature status, retry count, session history
371
- └── sessions/
372
- └── F-XXX-YYYYMMDDHHMMSS/
373
- ├── bootstrap-prompt.md # Generated prompt for this session
374
- └── logs/
375
- │ └── session.log # Full AI CLI session output
376
- ```
377
-
378
- ### PrizmKit Artifact Structure (per-feature)
379
-
380
- Each feature generates artifacts in a dedicated subdirectory under `.prizmkit/specs/`:
381
-
382
- ```
383
- .prizmkit/
384
- ├── config.json # PrizmKit configuration
385
- └── specs/
386
- ├── 001-project-infrastructure-setup/
387
- │ ├── spec.md # Phase 1: Feature specification
388
- │ ├── checklists/
389
- │ │ └── requirements.md # Phase 1: Spec quality checklist
390
- │ ├── plan.md # Phase 2: Implementation plan
391
- │ ├── data-model.md # Phase 2: Data model (if applicable)
392
- │ └── contracts/ # Phase 2: API contracts (if applicable)
393
- ├── 002-core-encryption-vault/
394
- │ └── ...
395
- └── ...
396
- ```
397
-
398
- ## macOS Compatibility Notes
399
-
400
- The original `run.sh` used GNU `timeout` which is not available on macOS by default. The current implementation uses a background process + watchdog pattern instead, which works on both macOS and Linux without additional dependencies.
401
-
402
- Key adaptations:
403
- - The AI CLI is run as a background process with `&`
404
- - A separate watchdog subshell handles timeout via `sleep + kill`
405
- - A heartbeat monitor subshell prints periodic progress to the terminal
406
- - SIGTERM (exit code 143) is mapped to exit code 124 (GNU timeout convention)
407
- - All cleanup commands use `|| true` to prevent `set -e` from causing silent exits
408
-
409
- ## Troubleshooting
410
-
411
- ### Pipeline stops after completing one feature
412
-
413
- Check if `set -e` is causing a silent exit. All python script invocations in the main loop should have `|| true` guards. Review `run.sh` for any unguarded commands that might return non-zero.
414
-
415
- ### Session log is empty
848
+ ---
416
849
 
417
- The AI CLI session didn't produce any output. Verify:
418
- - Your CLI is in PATH and functional:
419
- - CodeBuddy: `echo "test" | cbc --print -y`
420
- - Claude Code: `claude --print -p "test" --yes`
421
- - The bootstrap prompt file was generated: check `state/features/F-XXX/sessions/*/bootstrap-prompt.md`
850
+ ## Bug Fix Pipeline
422
851
 
423
- ### "PIPELINE_BLOCKED" message loops
852
+ The bug fix pipeline provides the same autonomous outer-loop as the feature pipeline, tailored for `bug-fix-list.json`.
424
853
 
425
- All remaining features have unmet dependencies. Check `status` to find which features failed:
854
+ ### Quick Start
426
855
 
427
856
  ```bash
428
- ./dev-pipeline/run.sh status feature-list.json
857
+ # 1. Generate bug fix list (via bug-planner skill)
858
+ # 2. Run foreground
859
+ ./dev-pipeline/run-bugfix.sh run bug-fix-list.json
860
+ # 3. Or as daemon
861
+ ./dev-pipeline/launch-bugfix-daemon.sh start bug-fix-list.json
862
+ # 4. Check progress
863
+ ./dev-pipeline/run-bugfix.sh status bug-fix-list.json
429
864
  ```
430
865
 
431
- Then manually complete or reset the blocking feature.
432
-
433
- ### Feature marked as "crashed"
434
-
435
- The AI CLI session exited without producing a `session-status.json`. This typically means the session crashed or the agent didn't write a completion status. The pipeline will retry up to `MAX_RETRIES` times.
436
-
437
- ### .prizmkit/specs/ is empty after feature completion
438
-
439
- The session skipped the PrizmKit artifact generation phases (spec.md, plan.md). This can happen if:
440
-
441
- 1. **Agent definitions not found**: Check that agent definition files exist
442
- - CodeBuddy: `.codebuddy/agents/prizm-dev-team-*.md`
443
- - Claude Code: `.claude/agents/prizm-dev-team-*.md`
444
- 2. **Team config missing**: Check that team configuration exists
445
- - CodeBuddy: `~/.codebuddy/teams/prizm-dev-team/config.json`
446
- - Claude Code: `.claude/team-info.json`
447
- 3. **Session took shortcuts**: The AI CLI session implemented the feature directly without following the 10-phase pipeline
448
-
449
- To fix, ensure the agent definitions and team configs are properly installed per the Prizm-Kit-Construct-Guide.md.
866
+ ### Bug Fix Execution Flow
450
867
 
451
- ## Agent and Team Configuration
868
+ ```
869
+ run-bugfix.sh main loop
870
+ |
871
+ +- update-bug-status.py # get_next (severity -> priority order)
872
+ +- generate-bugfix-prompt.py # Build prompt from template
873
+ +- AI CLI session
874
+ | +- Phase 1: Triage (classify, assess, write fix-plan.md)
875
+ | +- Phase 2: Reproduce (create failing reproduction test)
876
+ | +- Phase 3: Fix (TDD — make reproduction test pass)
877
+ | +- Phase 4: Verify (code review + regression tests)
878
+ | +- Phase 5: Commit (commit, TRAPS update, fix-report.md)
879
+ +- check-session-status.py
880
+ +- update-bug-status.py
881
+ +- loop -> next bug
882
+ ```
452
883
 
453
- The pipeline expects:
884
+ ### Bug Fix Artifacts
454
885
 
455
- **CodeBuddy (CBC):**
886
+ ```
887
+ .prizmkit/bugfix/B-001/
888
+ +-- fix-plan.md <- Phase 1 output
889
+ +-- fix-report.md <- Phase 5 output
890
+ ```
456
891
 
457
- | Resource | Location | Description |
458
- |----------|----------|-------------|
459
- | Agent Definitions | `.codebuddy/agents/prizm-dev-team-*.md` | 2 agent types: dev, reviewer |
460
- | Team Config | `~/.codebuddy/teams/prizm-dev-team/config.json` | Team runtime configuration |
461
- | Team Inboxes | `~/.codebuddy/teams/prizm-dev-team/inboxes/` | Agent message inboxes |
892
+ ### Bug Fix State Directory
462
893
 
463
- **Claude Code (CC):**
894
+ ```
895
+ dev-pipeline/bugfix-state/ # Runtime state (gitignored)
896
+ +-- pipeline.json
897
+ +-- current-session.json
898
+ +-- bugs/B-XXX/
899
+ +-- status.json
900
+ +-- sessions/B-XXX-YYYYMMDDHHMMSS/
901
+ +-- bootstrap-prompt.md
902
+ +-- logs/session.log
903
+ ```
464
904
 
465
- | Resource | Location | Description |
466
- |----------|----------|-------------|
467
- | Agent Definitions | `.claude/agents/prizm-dev-team-*.md` | 2 agent types: dev, reviewer |
468
- | Team Config | `.claude/team-info.json` | Team runtime configuration (project-level) |
905
+ ### Pipeline Comparison
469
906
 
470
- The `generate-bootstrap-prompt.py` script resolves these paths automatically. If paths are incorrect, check the `build_replacements()` function in that script.
907
+ | Aspect | Feature Pipeline | Bug Fix Pipeline |
908
+ |--------|-----------------|------------------|
909
+ | Input file | `feature-list.json` | `bug-fix-list.json` |
910
+ | ID format | `F-NNN` | `B-NNN` |
911
+ | State dir | `state/` | `bugfix-state/` |
912
+ | Ordering | Dependencies DAG + priority | Severity + priority (no deps) |
913
+ | Phases | Tiered (3-10 phases) | 5-phase (triage-reproduce-fix-verify-commit) |
914
+ | Commit prefix | `feat(<scope>):` | `fix(<scope>):` |
915
+ | Test strategy | TDD per task | Reproduction test |
471
916
 
472
917
  ---
473
918
 
474
- ## Bug Fix Pipeline (Outer Automation)
919
+ ## Directory Structure
475
920
 
476
- The bug fix pipeline provides the same autonomous outer-loop automation as the feature pipeline, but tailored for bug fixes from a `bug-fix-list.json`.
921
+ ```
922
+ dev-pipeline/
923
+ +-- run.sh # Main pipeline runner (features)
924
+ +-- retry-feature.sh # Retry single failed feature
925
+ +-- reset-feature.sh # Reset/clean feature for re-execution
926
+ +-- launch-daemon.sh # Background daemon for feature pipeline
927
+ +-- run-bugfix.sh # Bug-fix pipeline runner
928
+ +-- retry-bug.sh # Retry single failed bug
929
+ +-- launch-bugfix-daemon.sh # Background daemon for bugfix pipeline
930
+ +-- README.md # This file
931
+ +-- .gitignore # Ignores state/, bugfix-state/, __pycache__/
932
+ |
933
+ +-- lib/
934
+ | +-- common.sh # CLI detection, deps check, logging helpers
935
+ | +-- branch.sh # Git branch create/return lifecycle
936
+ | +-- heartbeat.sh # Heartbeat monitor + progress parser management
937
+ |
938
+ +-- scripts/
939
+ | +-- utils.py # Shared Python utilities (JSON I/O, logging)
940
+ | +-- init-pipeline.py # Validate feature-list.json + create state/
941
+ | +-- init-bugfix-pipeline.py # Validate bug-fix-list.json + create bugfix-state/
942
+ | +-- init-dev-team.py # Create .prizmkit/specs/{slug}/ directories
943
+ | +-- generate-bootstrap-prompt.py # Render feature session prompt from template
944
+ | +-- generate-bugfix-prompt.py # Render bugfix session prompt from template
945
+ | +-- check-session-status.py # Parse session-status.json outcome
946
+ | +-- update-feature-status.py # Feature state machine (8 actions)
947
+ | +-- update-bug-status.py # Bug state machine (6 actions)
948
+ | +-- detect-stuck.py # Detect stuck/stale features
949
+ | +-- cleanup-logs.py # Age/size-based log cleanup
950
+ | +-- parse-stream-progress.py # Real-time stream-json progress parser
951
+ |
952
+ +-- templates/
953
+ | +-- bootstrap-tier1.md # Tier 1 prompt template (single agent, lite)
954
+ | +-- bootstrap-tier2.md # Tier 2 prompt template (dual agent, standard)
955
+ | +-- bootstrap-tier3.md # Tier 3 prompt template (full team, full/self-evolve)
956
+ | +-- bootstrap-prompt.md # Legacy monolithic template (fallback)
957
+ | +-- bugfix-bootstrap-prompt.md # Bug-fix session prompt template
958
+ | +-- agent-knowledge-template.md # Template for agent knowledge docs
959
+ | +-- feature-list-schema.json # JSON schema for feature-list.json
960
+ | +-- bug-fix-list-schema.json # JSON schema for bug-fix-list.json
961
+ | +-- session-status-schema.json # JSON schema for session-status.json
962
+ |
963
+ +-- assets/
964
+ | +-- feature-list-example.json # Example feature list
965
+ | +-- prizm-dev-team-integration.md # Pipeline + prizm-dev-team integration docs
966
+ |
967
+ +-- tests/
968
+ | +-- conftest.py # Pytest configuration
969
+ | +-- test_generate_bootstrap_prompt.py # Tests for prompt generation
970
+ | +-- test_generate_bugfix_prompt.py # Tests for bugfix prompt generation
971
+ | +-- test_utils.py # Tests for shared utilities
972
+ |
973
+ +-- state/ # Feature pipeline runtime state (gitignored)
974
+ | +-- pipeline.json
975
+ | +-- current-session.json
976
+ | +-- .pipeline.pid # Daemon PID file
977
+ | +-- .pipeline-meta.json # Daemon metadata
978
+ | +-- pipeline-daemon.log # Daemon log (50MB rotation)
979
+ | +-- features/F-XXX/
980
+ | +-- status.json
981
+ | +-- sessions/F-XXX-YYYYMMDDHHMMSS/
982
+ | +-- bootstrap-prompt.md
983
+ | +-- logs/session.log
984
+ |
985
+ +-- bugfix-state/ # Bug pipeline runtime state (gitignored)
986
+ +-- (same structure as state/ but with bugs/B-XXX/)
987
+ ```
477
988
 
478
- ### Quick Start
989
+ ---
479
990
 
480
- ```bash
481
- # 1. Generate bug fix list (via bug-planner skill in an AI CLI session)
482
- # Output: bug-fix-list.json in project root
991
+ ## Agent and Team Configuration
483
992
 
484
- # 2. Run the bugfix pipeline (foreground)
485
- ./dev-pipeline/run-bugfix.sh run bug-fix-list.json
993
+ | Platform | Agent Definitions | Team Config |
994
+ |----------|------------------|-------------|
995
+ | Claude Code | `.claude/agents/prizm-dev-team-*.md` | `.claude/team-info.json` |
996
+ | CodeBuddy | `.codebuddy/agents/prizm-dev-team-*.md` | `~/.codebuddy/teams/prizm-dev-team/config.json` |
486
997
 
487
- # 3. Or run as a background daemon
488
- ./dev-pipeline/launch-bugfix-daemon.sh start bug-fix-list.json
998
+ Agent files are 2 types: `prizm-dev-team-dev.md` (implementation) and `prizm-dev-team-reviewer.md` (review). Paths are auto-resolved by `generate-bootstrap-prompt.py`.
489
999
 
490
- # 4. Check progress
491
- ./dev-pipeline/run-bugfix.sh status bug-fix-list.json
492
- ```
1000
+ ---
493
1001
 
494
- ### Bug Fix Commands
1002
+ ## macOS Compatibility
495
1003
 
496
- | Command | Description |
497
- |---------|-------------|
498
- | `./run-bugfix.sh run [bug-fix-list.json]` | Run all bugs by severity/priority order |
499
- | `./run-bugfix.sh run <bug-id> [options]` | Run a single bug fix |
500
- | `./run-bugfix.sh status [bug-fix-list.json]` | Display bug fix pipeline status |
501
- | `./run-bugfix.sh reset` | Clear all bugfix runtime state |
502
- | `./retry-bug.sh <bug-id> [bug-fix-list.json]` | Retry a single failed bug fix |
503
- | `./launch-bugfix-daemon.sh start [bug-fix-list.json]` | Start bugfix pipeline in background |
504
- | `./launch-bugfix-daemon.sh stop` | Gracefully stop the bugfix daemon |
505
- | `./launch-bugfix-daemon.sh status` | Check daemon status with progress JSON |
506
- | `./launch-bugfix-daemon.sh logs --follow` | Live tail daemon logs |
1004
+ Uses a background process + watchdog pattern instead of GNU `timeout`:
1005
+ - AI CLI runs as `&` background process
1006
+ - Watchdog subshell handles timeout via `sleep + kill`
1007
+ - SIGTERM (exit 143) mapped to exit 124 (GNU timeout convention)
1008
+ - All cleanup uses `|| true` to prevent `set -e` issues
507
1009
 
508
- ### Bug Fix Execution Flow
1010
+ ---
509
1011
 
510
- ```
511
- run-bugfix.sh main loop
512
-
513
- ├─ update-bug-status.py # get_next: find next bug (by severity → priority)
514
-
515
- ├─ generate-bugfix-prompt.py # Build prompt from bugfix-bootstrap-prompt.md template
516
-
517
- ├─ AI CLI session # cbc --print -y < prompt (CBC)
518
- │ │ # claude --print -p "$(cat prompt)" --yes (CC)
519
- │ └─ bugfix 5-phase workflow
520
- │ ├─ Phase 1: Triage (Dev agent: classify, assess impact, write fix-plan.md)
521
- │ ├─ Phase 2: Reproduce (Dev agent: create failing reproduction test)
522
- │ ├─ Phase 3: Fix (Dev agent: TDD — make reproduction test pass)
523
- │ ├─ Phase 4: Verify (Reviewer agent: code review + regression tests)
524
- │ └─ Phase 5: Commit (Dev agent: commit, update TRAPS, write fix-report.md)
525
-
526
- ├─ check-session-status.py # Parse session outcome
527
- ├─ update-bug-status.py # Update bug state (completed/failed/retry)
528
-
529
- └─ loop → next bug
530
- ```
531
-
532
- ### Bug Priority Resolution
533
-
534
- Bugs are processed in this order:
535
- 1. **Severity** first: `critical` > `high` > `medium` > `low`
536
- 2. **Priority field** second: lower number = higher priority
537
- 3. **In-progress** bugs (interrupted sessions) are resumed before pending bugs
1012
+ ## Troubleshooting
538
1013
 
539
- ### Bug Fix Artifacts
1014
+ ### Pipeline stops after one feature
1015
+ Check `set -e` interactions. All python invocations in the main loop should have `|| true` guards.
540
1016
 
541
- Each bug fix produces exactly 2 artifacts:
1017
+ ### Session log is empty
1018
+ Verify CLI is functional: `claude -p "test" --dangerously-skip-permissions` or `echo "test" | cbc --print -y`
542
1019
 
543
- ```
544
- .prizmkit/bugfix/B-001/
545
- ├── fix-plan.md ← Phase 1 output
546
- └── fix-report.md ← Phase 5 output
547
- ```
1020
+ ### "PIPELINE_BLOCKED" loops
1021
+ All remaining features have unmet dependencies. Use `./run.sh status` to find the blocking feature, then reset or manually complete it.
548
1022
 
549
- ### Bug Fix State Directory
1023
+ ### Feature marked as "crashed"
1024
+ Session exited without `session-status.json`. Pipeline retries up to `MAX_RETRIES` times automatically.
550
1025
 
551
- ```
552
- dev-pipeline/bugfix-state/ # Runtime state (gitignored)
553
- ├── pipeline.json # Pipeline run metadata
554
- ├── current-session.json # Currently executing session
555
- └── bugs/
556
- └── B-XXX/
557
- ├── status.json # Bug status, retry count, session history
558
- └── sessions/
559
- └── B-XXX-YYYYMMDDHHMMSS/
560
- ├── bootstrap-prompt.md # Generated prompt for this session
561
- └── logs/
562
- └── session.log # Full session output
563
- ```
564
-
565
- ### Differences Between Pipelines
566
-
567
- | Aspect | Feature Pipeline | Refactor Workflow | Bug Fix Pipeline |
568
- |--------|-----------------|-------------------|------------------|
569
- | Input file | `feature-list.json` | N/A (conversation trigger) | `bug-fix-list.json` |
570
- | ID format | `F-NNN` | `<refactor-slug>` | `B-NNN` |
571
- | State dir | `state/` | N/A (in-session) | `bugfix-state/` |
572
- | Ordering | Dependencies DAG → priority | N/A (single refactor per session) | Severity → priority (no dependencies) |
573
- | Phases | 10-phase (specify → plan → tasks → implement → review) | 6-phase (analyze → plan → tasks → implement → review → commit) | 5-phase (triage → reproduce → fix → verify → commit) |
574
- | Agents | Orchestrator + Dev + Reviewer | Dev + Reviewer only | Dev + Reviewer only |
575
- | Artifacts | spec.md, plan.md (with Tasks section) | refactor-analysis.md, plan.md (with Tasks section) | fix-plan.md, fix-report.md only |
576
- | Commit prefix | `feat(<scope>):` | `refactor(<scope>):` | `fix(<scope>):` |
577
- | Scope Guard | N/A | ✅ (behavior change → STOP) | N/A |
578
- | Test Strategy | TDD per task | Full suite after EVERY task | Reproduction test |
1026
+ ### Context window exhaustion (session crash mid-implementation)
1027
+ The bootstrap templates include Context Budget Rules to minimize context consumption. If crashes persist:
1028
+ 1. Set a per-feature model with larger context: `"model": "claude-opus-4.6"`
1029
+ 2. Reduce feature scope / split into smaller features
1030
+ 3. Check session log for unnecessary file reads or large tool outputs