prizmkit 1.0.122 → 1.0.124

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.
@@ -31,38 +31,6 @@ You are the **session orchestrator**. Implement Feature {{FEATURE_ID}}: "{{FEATU
31
31
 
32
32
  {{GLOBAL_CONTEXT}}
33
33
 
34
- {{IF_MODE_SELF_EVOLVE}}
35
- ## Framework Self-Development Context
36
-
37
- **You are developing the PrizmKit framework itself.** This is NOT a regular project — you are modifying the tool that powers this pipeline. Extra guardrails apply.
38
-
39
- ### Framework Structure
40
-
41
- ```
42
- core/skills/ — Skill definitions (each has _metadata.json)
43
- core/agents/ — Agent .md definitions (YAML frontmatter required)
44
- core/team/ — Team config (dev repo only, NOT installed)
45
- dev-pipeline/ — Pipeline scripts + templates (installed with --pipeline)
46
- templates/ — Bootstrap prompt templates (tier1/2/3)
47
- scripts/ — Python/bash pipeline scripts
48
- create-prizmkit/ — npm package / CLI installer
49
- bundled/ — Pre-bundled assets (auto-generated, NEVER edit directly)
50
- tests/ — Validation + unit tests
51
- ```
52
-
53
- ### 5 Key Invariants (MUST be preserved)
54
-
55
- 1. **Skill ↔ _metadata.json 1:1 mapping**: Every directory in `core/skills/` MUST have a `_metadata.json`. Every `_metadata.json` must reference an existing skill directory.
56
- 2. **Template variables resolve completely**: All `{{PLACEHOLDER}}` in `dev-pipeline/templates/` must be resolvable by `generate-bootstrap-prompt.py`. No unresolved placeholders in output.
57
- 3. **Agent YAML frontmatter is valid**: Every `.md` in `core/agents/` must have valid YAML frontmatter with required fields (name, description, tools).
58
- 4. **Bundle is generated, never hand-edited**: `create-prizmkit/bundled/` is auto-generated by `scripts/bundle.js`. Manual edits will be overwritten.
59
- 5. **CI must pass**: `npm run ci` (validate-all + bundle + verify-bundle + eslint + vitest) must pass after every change.
60
-
61
- ### Version Isolation
62
-
63
- LLM context is frozen at prompt time. Modifying a skill source file during this session will NOT change the behavior of that skill within this session. The real risk is structural inconsistency.
64
- {{END_IF_MODE_SELF_EVOLVE}}
65
-
66
34
  ## ⚠️ Context Budget Rules (CRITICAL — read before any phase)
67
35
 
68
36
  You are running in headless mode with a FINITE context window. Exceeding it will crash the session and lose all work. Follow these rules strictly:
@@ -165,9 +133,9 @@ ls .prizmkit/specs/{{FEATURE_SLUG}}/ 2>/dev/null
165
133
  - `context-snapshot.md` exists → use it directly, skip Phase 1
166
134
  - Some missing → generate only missing files
167
135
 
168
- Before planning, check whether feature code already exists in the project:
136
+ Before planning, check whether feature code already exists in the project (search in source directories identified from `root.prizm` or the project tree scan):
169
137
  ```bash
170
- grep -r "{{FEATURE_SLUG}}" src/ --include="*.js" --include="*.ts" -l 2>/dev/null | head -20
138
+ grep -r "{{FEATURE_SLUG}}" . --include="*.js" --include="*.ts" --include="*.py" --include="*.go" --include="*.java" --include="*.rb" --include="*.rs" -l --exclude-dir=node_modules --exclude-dir=.git --exclude-dir=dist --exclude-dir=build --exclude-dir=vendor --exclude-dir=.prizmkit 2>/dev/null | head -20
171
139
  ```
172
140
 
173
141
  Record result as `EXISTING_CODE` (list of files, or empty).
@@ -177,8 +145,13 @@ If `EXISTING_CODE` is non-empty: your spec/plan/tasks must reflect this existing
177
145
  **Step A — Build Context Snapshot** (skip if `context-snapshot.md` already exists):
178
146
 
179
147
  1. Read `.prizm-docs/root.prizm` and relevant L1/L2 prizm docs
180
- 2. Scan `src/` for files related to this feature; read each one
181
- 3. Write `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`:
148
+ 2. Detect source code directories: read KEY_FILES and STRUCTURE sections from `root.prizm` to identify where source code lives (e.g. `src/`, `app/`, `lib/`, `cmd/`, `packages/`, or project root). If `root.prizm` is missing, scan the project tree:
149
+ ```bash
150
+ find . -maxdepth 2 -type f \( -name "*.js" -o -name "*.ts" -o -name "*.py" -o -name "*.go" -o -name "*.java" -o -name "*.rb" -o -name "*.rs" \) -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/build/*' -not -path '*/vendor/*' | head -30
151
+ ```
152
+ Identify the top-level source directories from the results.
153
+ 3. Scan the detected source directories for files related to this feature; read each one
154
+ 4. Write `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`:
182
155
  - **Section 1 — Feature Brief**: feature description + acceptance criteria (copy from above)
183
156
  - **Section 2 — Project Structure**: run the following to get a visual directory tree, then paste output:
184
157
  ```bash
@@ -189,12 +162,12 @@ If `EXISTING_CODE` is non-empty: your spec/plan/tasks must reflect this existing
189
162
  ### Files to Modify
190
163
  | File | Why Needed | Key Interfaces |
191
164
  |------|-----------|----------------|
192
- | `src/config.js` | Add runtime config layer | `config` (Zod object), `configSchema` |
165
+ | `<source-dir>/config.js` | Add runtime config layer | `config` (Zod object), `configSchema` |
193
166
 
194
167
  ### Files for Reference
195
168
  | File | Why Needed | Key Interfaces |
196
169
  |------|-----------|----------------|
197
- | `src/security/permission-guard.js` | Permission check integration | `checkCommandPermission(userId, cmd)` |
170
+ | `<source-dir>/security/permission-guard.js` | Permission check integration | `checkCommandPermission(userId, cmd)` |
198
171
 
199
172
  ### Known TRAPS (from .prizm-docs/)
200
173
  - <trap entries extracted from L1/L2 docs>
@@ -214,6 +187,13 @@ ls .prizmkit/specs/{{FEATURE_SLUG}}/spec.md .prizmkit/specs/{{FEATURE_SLUG}}/pla
214
187
 
215
188
  > All files go under `.prizmkit/specs/{{FEATURE_SLUG}}/`. Confirm each with `ls` after writing.
216
189
 
190
+ **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
191
+ Before proceeding past CP-1, verify:
192
+ 1. Plan.md Data Model section references existing schema/model files (scan for `*.prisma`, `*.sql`, `migrations/`, `models/`, `*.entity.*` files; read them if not already in context-snapshot)
193
+ 2. All new tables/fields follow existing naming conventions, ID strategy, timestamp patterns, and constraint style
194
+ 3. No `[NEEDS CLARIFICATION]` remains in Data Model section — resolve by reading existing code and making a conservative choice that matches existing patterns. Document the resolution in plan.md.
195
+ 4. If a DB design decision genuinely cannot be resolved from existing code alone, document the assumption made and flag it in the Implementation Log for user review.
196
+
217
197
  **CP-1**: Both spec.md and plan.md exist.
218
198
 
219
199
  ### Phase 3: Analyze — Reviewer Agent
@@ -232,6 +212,54 @@ Wait for Reviewer to return.
232
212
 
233
213
  **CP-2**: No CRITICAL issues.
234
214
 
215
+ {{IF_CRITIC_ENABLED}}
216
+ ### Phase 3.5: Plan Challenge — Critic Agent(s)
217
+
218
+ **Guard**: Verify critic agent file exists before spawning:
219
+ ```bash
220
+ ls {{CRITIC_SUBAGENT_PATH}} 2>/dev/null && echo "CRITIC:READY" || echo "CRITIC:MISSING"
221
+ ```
222
+ If CRITIC:MISSING — skip Phase 3.5 entirely and proceed to Phase 4. Log: "Critic agent not installed — skipping Plan Challenge."
223
+
224
+ **Choose ONE path based on `{{CRITIC_COUNT}}`:**
225
+
226
+ **If {{CRITIC_COUNT}} = 1 → Single Critic** (skip to CP-2.5 after this):
227
+
228
+ Spawn Critic agent (Agent tool, subagent_type="prizm-dev-team-critic", run_in_background=false).
229
+
230
+ Prompt:
231
+ > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
232
+ > **MODE: Plan Challenge**
233
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has project context, Section 4 has file manifest.
234
+ > 2. Read `.prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
235
+ > 3. Read existing source files in the modules this plan touches.
236
+ > 4. Challenge plan.md against the project's existing architecture, patterns, and style.
237
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report.md` with findings (or 'No significant challenges')."
238
+
239
+ **If {{CRITIC_COUNT}} = 3 → Multi-Critic Voting** (skip Single Critic above):
240
+
241
+ Spawn 3 Critic agents sequentially (each with run_in_background=false), each with a different focus lens:
242
+
243
+ Critic-A prompt (append to base prompt above):
244
+ > "**Focus Lens: Architecture & Scalability.** Prioritize: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
245
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-A.md`."
246
+
247
+ Critic-B prompt (append to base prompt above):
248
+ > "**Focus Lens: Data Model & Edge Cases.** Prioritize: data model design fit, entity relationships, edge cases in business logic, missing boundary conditions.
249
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-B.md`."
250
+
251
+ Critic-C prompt (append to base prompt above):
252
+ > "**Focus Lens: Security & Performance.** Prioritize: security attack surface, authentication/authorization gaps, performance bottlenecks, resource leaks.
253
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-C.md`."
254
+
255
+ After all critics return, read all 3 reports:
256
+ - Challenge raised by **2/3 or more** critics → **must respond** (adjust plan or justify why not)
257
+ - Challenge raised by **1/3 only** → logged in context-snapshot but not blocking
258
+ - Max 1 plan revision round.
259
+
260
+ **CP-2.5**: Plan challenges reviewed and resolved.
261
+ {{END_IF_CRITIC_ENABLED}}
262
+
235
263
  ### Phase 4: Implement — Dev Agent
236
264
 
237
265
  **Build artifacts rule** (passed to Dev): After any build/compile command (`go build`, `npm run build`, `tsc`, etc.), ensure the output binary or build directory is in `.gitignore`. Never commit compiled binaries, build output, or generated artifacts.
@@ -245,17 +273,6 @@ grep -c '^\- \[ \]' .prizmkit/specs/{{FEATURE_SLUG}}/plan.md 2>/dev/null || echo
245
273
 
246
274
  Spawn Dev agent (Agent tool, subagent_type="prizm-dev-team-dev", run_in_background=false).
247
275
 
248
- {{IF_MODE_SELF_EVOLVE}}
249
- **Framework Self-Evolve — Dev Extra Instructions**:
250
- Append the following to the Dev agent prompt:
251
- > "FRAMEWORK RULES (self-evolve mode):
252
- > - If you modify any file in `core/skills/`, also update `_metadata.json` in the same skill directory.
253
- > - If you modify `dev-pipeline/templates/*.md`, verify all `{{PLACEHOLDER}}` markers have matching entries in `generate-bootstrap-prompt.py`.
254
- > - Before marking implementation complete, run `node tests/validate-all.js` and fix any failures.
255
- > - NEVER directly modify files in `create-prizmkit/bundled/` — those are auto-generated by `scripts/bundle.js`.
256
- > - If you modify any file in `dev-pipeline/scripts/` or `dev-pipeline/templates/` or `core/skills/` that this pipeline uses, note this in your Implementation Log for reload_needed tracking."
257
- {{END_IF_MODE_SELF_EVOLVE}}
258
-
259
276
  Prompt:
260
277
  > "Read {{DEV_SUBAGENT_PATH}}. Implement feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}) using TDD.
261
278
  > **IMPORTANT**: Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST.
@@ -294,22 +311,37 @@ Wait for Dev to return. **If Dev times out before all tasks are `[x]`**:
294
311
 
295
312
  All tasks `[x]`, tests pass.
296
313
 
314
+ {{IF_CRITIC_ENABLED}}
315
+ ### Phase 4.5: Code Challenge — Critic Agent
316
+
317
+ **Guard**: Verify critic agent file exists before spawning:
318
+ ```bash
319
+ ls {{CRITIC_SUBAGENT_PATH}} 2>/dev/null && echo "CRITIC:READY" || echo "CRITIC:MISSING"
320
+ ```
321
+ If CRITIC:MISSING — skip Phase 4.5 entirely and proceed to Phase 5. Log: "Critic agent not installed — skipping Code Challenge."
322
+
323
+ Spawn Critic agent (Agent tool, subagent_type="prizm-dev-team-critic", run_in_background=false).
324
+
325
+ Prompt:
326
+ > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
327
+ > **MODE: Code Challenge**
328
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` — Implementation Log section shows what Dev changed.
329
+ > 2. Read `.prizm-docs/root.prizm` and relevant module docs for RULES/PATTERNS.
330
+ > 3. Read the actual source files changed (from Implementation Log).
331
+ > 4. Read comparable existing source files in the same module for style comparison.
332
+ > 5. Challenge code integration quality: style fit, robustness, existing code cohesion, hidden impact.
333
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report.md` (overwrite) with findings (or 'No significant challenges')."
334
+
335
+ Wait for Critic to return.
336
+ - Read challenge-report.md. For items marked CRITICAL/HIGH: spawn Dev to fix, then proceed to Review.
337
+
338
+ **CP-3.5**: Code challenges reviewed and resolved.
339
+ {{END_IF_CRITIC_ENABLED}}
340
+
297
341
  ### Phase 5: Review + Test — Reviewer Agent
298
342
 
299
343
  Spawn Reviewer agent (Agent tool, subagent_type="prizm-dev-team-reviewer", run_in_background=false).
300
344
 
301
- {{IF_MODE_SELF_EVOLVE}}
302
- **Framework Self-Evolve — Reviewer Extra Instructions**:
303
- Append the following to the Reviewer agent prompt:
304
- > "FRAMEWORK REVIEW DIMENSIONS (self-evolve mode):
305
- > In addition to standard code review, check:
306
- > 1. **Structural integrity**: Every `core/skills/*/` must have `_metadata.json`. Run `node tests/validate-all.js` to verify.
307
- > 2. **Template safety**: If any `dev-pipeline/templates/*.md` was modified, check that all `{{PLACEHOLDER}}` markers are properly balanced (open/close) and resolvable.
308
- > 3. **Agent frontmatter**: If any `core/agents/*.md` was modified, validate YAML frontmatter has required fields (name, description, tools).
309
- > 4. **CI gate**: Run `npm run ci` and report the result. Any failure is CRITICAL.
310
- > 5. **Bundle safety**: Verify no files in `create-prizmkit/bundled/` were directly modified (check `git diff --name-only` for bundled/ changes)."
311
- {{END_IF_MODE_SELF_EVOLVE}}
312
-
313
345
  Prompt:
314
346
  > "Read {{REVIEWER_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
315
347
  > **IMPORTANT**: Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST.
@@ -346,20 +378,6 @@ If GATE:MISSING — send message to Reviewer (re-spawn if needed): "Write the '#
346
378
 
347
379
  ### Phase 6: Retrospective & Commit (SINGLE COMMIT) — DO NOT SKIP
348
380
 
349
- {{IF_MODE_SELF_EVOLVE}}
350
- **Framework Validation Gate (self-evolve mode)**:
351
-
352
- Before proceeding with commit, run the full framework CI pipeline:
353
-
354
- ```bash
355
- bash {{VALIDATOR_SCRIPTS_DIR}}/validate-framework.sh
356
- ```
357
-
358
- - If ALL steps pass → proceed with commit below.
359
- - If any step fails → fix the issue and re-run. Maximum 2 fix-and-retry rounds.
360
- - After 2 failed rounds → exit and let the pipeline runner handle the failure.
361
- {{END_IF_MODE_SELF_EVOLVE}}
362
-
363
381
  **For bug fixes**: run `/prizmkit-retrospective` for structural sync only (skip knowledge injection unless a new TRAPS was discovered). Use `fix(<scope>):` commit prefix.
364
382
 
365
383
  **6a.** Check if feature already committed:
@@ -403,6 +421,9 @@ Working tree MUST be clean after this step. If any feature-related files remain,
403
421
  | Team Config | `{{TEAM_CONFIG_PATH}}` |
404
422
  | Dev Agent Def | {{DEV_SUBAGENT_PATH}} |
405
423
  | Reviewer Agent Def | {{REVIEWER_SUBAGENT_PATH}} |
424
+ {{IF_CRITIC_ENABLED}}
425
+ | Critic Agent Def | {{CRITIC_SUBAGENT_PATH}} |
426
+ {{END_IF_CRITIC_ENABLED}}
406
427
  | Project Root | {{PROJECT_ROOT}} |
407
428
  | Feature List Path | {{FEATURE_LIST_PATH}} |
408
429
 
@@ -100,6 +100,16 @@
100
100
  "model": {
101
101
  "type": "string",
102
102
  "description": "AI model ID for this feature. Overrides $MODEL env var."
103
+ },
104
+ "critic": {
105
+ "type": "boolean",
106
+ "description": "Enable adversarial critic review for this feature. Default: false.",
107
+ "default": false
108
+ },
109
+ "critic_count": {
110
+ "type": "integer",
111
+ "description": "Number of parallel critic agents. 1 = single critic, 3 = multi-critic voting. Default: 1.",
112
+ "enum": [1, 3]
103
113
  }
104
114
  }
105
115
  }
@@ -192,16 +192,20 @@ class TestProcessModeBlocks:
192
192
  result = process_mode_blocks(tpl, "standard", init_done=False)
193
193
  assert "need init" in result
194
194
 
195
- def test_self_evolve_keeps_self_evolve_and_full(self):
196
- tpl = (
197
- "{{IF_MODE_SELF_EVOLVE}}se content{{END_IF_MODE_SELF_EVOLVE}}"
198
- "{{IF_MODE_FULL}}full content{{END_IF_MODE_FULL}}"
199
- )
200
- result = process_mode_blocks(tpl, "self-evolve", init_done=True)
201
- assert "se content" in result
202
- assert "full content" in result
203
-
204
- def test_self_evolve_removes_lite(self):
205
- tpl = "{{IF_MODE_LITE}}lite content{{END_IF_MODE_LITE}}"
206
- result = process_mode_blocks(tpl, "self-evolve", init_done=True)
207
- assert "lite content" not in result
195
+ def test_critic_enabled_keeps_critic_block(self):
196
+ tpl = "before\n{{IF_CRITIC_ENABLED}}\ncritic content\n{{END_IF_CRITIC_ENABLED}}\nafter"
197
+ result = process_mode_blocks(tpl, "standard", init_done=True, critic_enabled=True)
198
+ assert "critic content" in result
199
+ assert "IF_CRITIC_ENABLED" not in result
200
+
201
+ def test_critic_disabled_removes_critic_block(self):
202
+ tpl = "before\n{{IF_CRITIC_ENABLED}}\ncritic content\n{{END_IF_CRITIC_ENABLED}}\nafter"
203
+ result = process_mode_blocks(tpl, "standard", init_done=True, critic_enabled=False)
204
+ assert "critic content" not in result
205
+ assert "before" in result
206
+ assert "after" in result
207
+
208
+ def test_critic_default_is_disabled(self):
209
+ tpl = "{{IF_CRITIC_ENABLED}}critic{{END_IF_CRITIC_ENABLED}}"
210
+ result = process_mode_blocks(tpl, "standard", init_done=True)
211
+ assert "critic" not in result
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.122",
2
+ "version": "1.0.124",
3
3
  "skills": {
4
4
  "prizm-kit": {
5
5
  "description": "Full-lifecycle dev toolkit. Covers spec-driven development, Prizm context docs, code quality, debugging, deployment, and knowledge management.",
@@ -137,8 +137,9 @@ Execute the selected scenario workflow in conversation mode with mandatory check
137
137
  4. refine descriptions and acceptance criteria
138
138
  5. verify DAG/order/priorities
139
139
  6. build or append `feature-list.json`
140
- 7. validate and fix until pass
141
- 8. summarize final feature table
140
+ 7. ask whether to enable adversarial critic review for high/critical features
141
+ 8. validate and fix until pass
142
+ 9. summarize final feature table
142
143
 
143
144
  ### Checkpoints (Mandatory Gates)
144
145
 
@@ -150,8 +151,9 @@ Checkpoints catch cascading errors early — skipping one means the next phase b
150
151
  | **CP-AP-1** | Vision Summary | Goal/users/differentiators confirmed by user | 1-2 |
151
152
  | **CP-AP-2** | Feature Proposals | Feature set with titles+deps identified (pre-validation) | 3-5 |
152
153
  | **CP-AP-3** | DAG Validity | No cycles, dependencies resolved (validation dry-run) | 6 |
153
- | **CP-AP-4** | `feature-list.json` Generated | Schema validates, all required keys present | 6 |
154
- | **CP-AP-5** | Final Validation Pass | Python script returns `"valid": true` with zero errors | 7 |
154
+ | **CP-AP-3.5** | Critic Decision | User decided on critic review for high/critical features | 7 |
155
+ | **CP-AP-4** | `feature-list.json` Generated | Schema validates, all required keys present | 6-7 |
156
+ | **CP-AP-5** | Final Validation Pass | Python script returns `"valid": true` with zero errors | 8 |
155
157
 
156
158
  **Resume Detection**: See §Resume Support for checkpoint-based resumption.
157
159
 
@@ -252,6 +254,8 @@ AI: "Ready to proceed to dev-pipeline."
252
254
  - new items default `status: "pending"`
253
255
  - English feature titles for stable slug generation
254
256
  - `model` field is optional — omitting it means the pipeline uses $MODEL env or CLI default
257
+ - `critic` field is optional (boolean). If user requested adversarial critic review during planning, set `"critic": true` for relevant features. Omitting defaults to `false`.
258
+ - `critic_count` field is optional (integer, 1 or 3). If omitted, defaults to 1 (single critic). Set to 3 for multi-critic voting mode on critical features.
255
259
  - **descriptions must be implementation-ready** — minimum 15 words (error), recommended 30/50/80 words for low/medium/high complexity (warning). See `planning-guide.md` §4 for what to include.
256
260
 
257
261
  ## Next-Step Execution Policy (after planning)
@@ -15,9 +15,9 @@ npm run skill:review -- \
15
15
  --workspace /.codebuddy/skill-evals/app-planner-workspace \
16
16
  --iteration iteration-N \
17
17
  --skill-name app-planner \
18
- --skill-path /core/skills/app-planner \
18
+ --skill-path ${SKILL_DIR} \
19
19
  --runs 3 \
20
- --grader-cmd "python3 /core/skills/app-planner/scripts/validate-and-generate.py grade --workspace {workspace} --iteration {iteration}"
20
+ --grader-cmd "python3 ${SKILL_DIR}/scripts/validate-and-generate.py grade --workspace {workspace} --iteration {iteration}"
21
21
  ```
22
22
 
23
23
  Produces:
@@ -320,6 +320,18 @@ def validate_feature_list(data, planning_mode="new"):
320
320
 
321
321
  # -- Sub-features --
322
322
  subs = feat.get("sub_features")
323
+
324
+ # -- Critic fields (optional but validated if present) --
325
+ critic = feat.get("critic")
326
+ if critic is not None and not isinstance(critic, bool):
327
+ errors.append(
328
+ "{}: 'critic' must be a boolean, got {}".format(label, type(critic).__name__)
329
+ )
330
+ critic_count = feat.get("critic_count")
331
+ if critic_count is not None and critic_count not in (1, 3):
332
+ errors.append(
333
+ "{}: 'critic_count' must be 1 or 3, got {}".format(label, critic_count)
334
+ )
323
335
  if isinstance(subs, list):
324
336
  for sidx, sub in enumerate(subs):
325
337
  sub_label = "{}->sub_features[{}]".format(label, sidx)
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: "bug-fix-workflow"
3
3
  tier: companion
4
- description: "Interactive single-bug fix in current session. Guides through triage → reproduce → fix → review → commit without the background pipeline. Use this skill when the user wants to fix one specific bug right now, interactively. Trigger on: 'fix this bug', 'debug this', 'fix B-001', 'help me fix', 'let me fix this bug myself', 'fix this bug', 'interactive fix', 'manually fix bug'. (project)"
4
+ description: "Interactive single-bug fix in current session. Guides through deep diagnosis Q&A → triage → reproduce → fix → review → commit without the background pipeline. Use this skill when the user wants to fix one specific bug right now, interactively. Trigger on: 'fix this bug', 'debug this', 'fix B-001', 'help me fix', 'let me fix this bug myself', 'fix this bug', 'interactive fix', 'manually fix bug'. (project)"
5
5
  ---
6
6
 
7
7
  # Bug Fix Workflow
@@ -79,17 +79,82 @@ For trivial bugs with clear root cause and minimal scope:
79
79
 
80
80
  ---
81
81
 
82
- ### Phase 1: Triage
82
+ ### Phase 1: Deep Bug Diagnosis — Interactive Q&A
83
83
 
84
- **Goal**: Understand the bug, locate affected code, classify severity.
84
+ **Goal**: Fully understand the bug before touching any code. Vague bug reports lead to incorrect fixes that mask the real issue or introduce new bugs.
85
85
 
86
- 1. **Gather bug info**:
87
- - If bug ID given (e.g. B-001): read entry from `bug-fix-list.json`
88
- - If raw error: extract error message, stack trace, affected files
89
- - If description: ask clarifying questions to narrow down the issue
90
- 2. **Read project context**: `.prizm-docs/root.prizm` relevant L1/L2 docs for affected modules
91
- 3. **Locate affected code**: read the files mentioned in the error/stack trace
92
- 4. **Check known issues**: search `.prizm-docs/` TRAPS sections for matching patterns
86
+ **CRITICAL RULE**: Ask as many questions as needed until the bug is fully understood. Do NOT rush into code. A misdiagnosed bug leads to a wrong fix, which is worse than no fix.
87
+
88
+ #### Step 1.1: Initial Bug Information Gathering
89
+
90
+ - If bug ID given (e.g. B-001): read entry from `bug-fix-list.json` but DO NOT assume the description is complete
91
+ - If raw error/stack trace: extract error message, affected files, line numbers
92
+ - If natural language description: start the deep-dive Q&A below
93
+
94
+ #### Step 1.2: Systematic Bug Clarification
95
+
96
+ Ask questions across these dimensions until every aspect is clear. **Adapt to what the user has already provided** — skip questions that are already answered.
97
+
98
+ **Reproduction Conditions:**
99
+ - What exact steps trigger the bug? (step-by-step)
100
+ - Which environment/browser/OS/version?
101
+ - Is it reproducible every time, or intermittent?
102
+ - When did it first appear? (after a specific change/deploy?)
103
+ - Does it happen for all users or only specific accounts/roles/data?
104
+
105
+ **Expected vs Actual Behavior:**
106
+ - What should happen? (the correct behavior)
107
+ - What actually happens? (the buggy behavior)
108
+ - Is there partial functionality (e.g., works for some inputs but not others)?
109
+
110
+ **Scope and Impact:**
111
+ - Which features/pages/modules are affected?
112
+ - Are there workarounds users are currently using?
113
+ - Is this blocking other work?
114
+ - Are there related symptoms elsewhere?
115
+
116
+ **Data and State:**
117
+ - What data/state triggers the issue? (specific input values, DB state, user session state)
118
+ - Does the bug involve data corruption or just incorrect display/behavior?
119
+ - If database-related: which tables/records are affected?
120
+
121
+ **Error Details** (if not already provided):
122
+ - Full error message and stack trace?
123
+ - Browser console errors?
124
+ - Server-side logs?
125
+ - Network request/response details?
126
+
127
+ #### Step 1.3: Confirmation Before Triage
128
+
129
+ Summarize the bug understanding:
130
+
131
+ ```
132
+ Bug Summary:
133
+ - Symptom: [what happens]
134
+ - Reproduction: [exact steps]
135
+ - Environment: [where it occurs]
136
+ - Expected: [correct behavior]
137
+ - Impact: [who/what is affected]
138
+ - Data trigger: [what data/state causes it]
139
+ ```
140
+
141
+ Ask the user: "Is this summary accurate? Any details to add?"
142
+
143
+ **CHECKPOINT CP-BFW-1**: Bug fully understood and confirmed by user.
144
+
145
+ ---
146
+
147
+ ### Phase 2: Triage
148
+
149
+ **Goal**: Locate affected code, identify root cause, classify severity.
150
+
151
+ 1. **Read project context**: `.prizm-docs/root.prizm` → relevant L1/L2 docs for affected modules
152
+ 2. **Locate affected code**: read the files mentioned in the error/stack trace or identified during diagnosis
153
+ 3. **Check known issues**: search `.prizm-docs/` TRAPS sections for matching patterns
154
+ 4. **If database-related**: read existing schema/model files to understand the data layer
155
+ ```bash
156
+ find . -maxdepth 4 -type f \( -name "*.prisma" -o -name "*.sql" -o -path "*/migrations/*" -o -path "*/models/*" -o -name "schema.*" -o -name "*.entity.*" \) -not -path '*/node_modules/*' -not -path '*/.git/*' | head -20
157
+ ```
93
158
  5. **Classify**: root cause (confirmed/suspected), blast radius, fix complexity
94
159
  6. **Present diagnosis to user**:
95
160
  ```
@@ -100,7 +165,7 @@ For trivial bugs with clear root cause and minimal scope:
100
165
  ```
101
166
  Ask: "Does this diagnosis look right? Should I proceed with the fix?"
102
167
 
103
- ### Phase 2: Reproduce
168
+ ### Phase 3: Reproduce
104
169
 
105
170
  **Goal**: Create a failing test that proves the bug exists.
106
171
 
@@ -113,9 +178,9 @@ For trivial bugs with clear root cause and minimal scope:
113
178
  If the bug is hard to reproduce automatically (e.g. environment-specific):
114
179
  - Ask the user for reproduction steps
115
180
  - Write a manual reproduction checklist instead
116
- - Proceed to Phase 3 with the manual checklist
181
+ - Proceed to Phase 4 with the manual checklist
117
182
 
118
- ### Phase 3: Fix
183
+ ### Phase 4: Fix
119
184
 
120
185
  **Goal**: Implement the minimal fix. Red test → green.
121
186
 
@@ -123,6 +188,7 @@ If the bug is hard to reproduce automatically (e.g. environment-specific):
123
188
  - Change the minimum amount of code to fix the root cause
124
189
  - Do NOT refactor or add unrelated improvements — fix the bug only
125
190
  - Follow existing code conventions (read from `.prizm-docs/` RULES/PATTERNS)
191
+ - If the fix involves database changes: read existing schema first, follow existing naming/constraint conventions
126
192
  2. **Run the reproduction test** → must **pass** (green)
127
193
  3. **Run the full module test suite** → must pass (no regressions)
128
194
  4. **Show the fix to user**:
@@ -135,7 +201,7 @@ If the fix causes test regressions:
135
201
  - Revise the fix (max 3 attempts)
136
202
  - If still failing after 3 attempts, escalate to user with analysis
137
203
 
138
- ### Phase 4: Review
204
+ ### Phase 5: Review
139
205
 
140
206
  **Goal**: Verify fix quality before committing.
141
207
 
@@ -156,7 +222,7 @@ If the fix causes test regressions:
156
222
  Ready to commit.
157
223
  ```
158
224
 
159
- ### Phase 5: User Verification
225
+ ### Phase 6: User Verification
160
226
 
161
227
  **Goal**: Let the user verify the fix works as expected before committing.
162
228
 
@@ -166,15 +232,15 @@ If the fix causes test regressions:
166
232
  - **(c) Skip verification** — Proceed directly to commit (automated tests already pass)
167
233
  2. **If (a)**: Detect and suggest dev server command (e.g. `npm run dev`, `python manage.py runserver`), start it, wait for user confirmation: "Fix verified? (yes/no)"
168
234
  3. **If (b)**: Run the specified command, show results, ask confirmation
169
- 4. **If (c)**: Proceed to Phase 6
235
+ 4. **If (c)**: Proceed to Phase 7
170
236
 
171
237
  If user reports the fix is NOT working:
172
- - Return to Phase 3 (max 2 more attempts)
238
+ - Return to Phase 4 (max 2 more attempts)
173
239
  - If still failing: escalate with analysis
174
240
 
175
241
  ---
176
242
 
177
- ### Phase 6: Commit & Merge
243
+ ### Phase 7: Commit & Merge
178
244
 
179
245
  **Goal**: Commit the fix and offer to merge back to the original branch.
180
246
 
@@ -215,11 +281,11 @@ The workflow supports resuming from the last completed phase by detecting existi
215
281
  | Artifact Found | Resume From |
216
282
  |---------------|------------|
217
283
  | (nothing) | Phase 0: Branch Setup |
218
- | On `fix/<BUG_ID>-*` branch, no artifacts | Phase 1: Triage |
219
- | `fix-plan.md` only | Phase 3: Fix |
220
- | `fix-plan.md` + code changes exist | Phase 4: Review |
221
- | All docs + review passed | Phase 5: User Verification |
222
- | All docs + committed | Phase 6: Merge decision |
284
+ | On `fix/<BUG_ID>-*` branch, no artifacts | Phase 1: Deep Bug Diagnosis |
285
+ | `fix-plan.md` only | Phase 4: Fix |
286
+ | `fix-plan.md` + code changes exist | Phase 5: Review |
287
+ | All docs + review passed | Phase 6: User Verification |
288
+ | All docs + committed | Phase 7: Merge decision |
223
289
 
224
290
  **Resume**: If `<BUG_ID>` matches an existing `.prizmkit/bugfix/<BUG_ID>/` directory, resume instead of starting fresh.
225
291
 
@@ -236,12 +302,13 @@ Only 2 artifact files per bug, consistent with the pipeline convention.
236
302
  ## Comparison with Pipeline Bug Fix
237
303
 
238
304
  | Dimension | bug-fix-workflow (this skill) | bugfix-pipeline-launcher |
239
- |-----------|-------------------------------|--------------------------|
305
+ |-----------|-------------------------------|-----------------------------|
240
306
  | Scope | One bug at a time | All bugs in batch |
241
307
  | Execution | Interactive, in-session | Foreground or background daemon |
308
+ | Diagnosis | Deep interactive Q&A with user | Automated from bug description |
242
309
  | Branch | Creates `fix/<BUG_ID>-*` branch | Pipeline manages branches |
243
310
  | Visibility | Full user interaction at each phase | Async, check status periodically |
244
- | User verification | Yes (Phase 5) | No (automated) |
311
+ | User verification | Yes (Phase 6) | No (automated) |
245
312
  | Best for | Complex bugs needing user input | Batch of well-defined bugs |
246
313
  | Artifacts | Same (fix-plan.md + fix-report.md) | Same |
247
314
  | Commit prefix | `fix(<scope>):` | `fix(<scope>):` |
@@ -251,6 +318,7 @@ Only 2 artifact files per bug, consistent with the pipeline convention.
251
318
  | Scenario | Action |
252
319
  |----------|--------|
253
320
  | Bug ID not found in bug-fix-list.json | Ask user to provide bug details directly |
321
+ | User's bug description is too vague | Ask systematic clarification questions (Phase 1) |
254
322
  | Cannot reproduce the bug | Ask for more context, try alternative reproduction |
255
323
  | Fix causes regressions | Revert, analyze, retry (max 3 rounds) |
256
324
  | Root cause unclear after investigation | Present findings, ask user for guidance |
@@ -264,7 +332,7 @@ Only 2 artifact files per bug, consistent with the pipeline convention.
264
332
  | `bug-planner` | **this skill** | User picks one bug to fix interactively |
265
333
  | `bugfix-pipeline-launcher` | **this skill** | User wants to fix a stuck/complex bug manually |
266
334
  | **this skill** | `bugfix-pipeline-launcher` | After fixing, user wants to continue with remaining bugs |
267
- | **this skill** | `prizmkit-committer` | Built into Phase 6 (pure commit, no doc sync) |
335
+ | **this skill** | `prizmkit-committer` | Built into Phase 7 (pure commit, no doc sync) |
268
336
 
269
337
  ## Output
270
338
 
@@ -144,28 +144,37 @@ Detect user intent from their message, then follow the corresponding workflow:
144
144
  dev-pipeline/run.sh status feature-list.json
145
145
  ```
146
146
 
147
- 5. **Ask user to confirm**: "Ready to launch the pipeline? It will process N features."
147
+ 5. **Ask whether to enable Critic Agent** (adversarial review):
148
+ Present the choice:
149
+ - **(a) No — standard pipeline (default)**: No adversarial review. Faster execution, lower token cost.
150
+ - **(b) Yes — enable Critic review**: Adds adversarial challenge after planning and implementation. Challenges plan fitness and code integration quality. Increases pipeline time by ~5-10 minutes per feature.
148
151
 
149
- 6. **Launch** (based on chosen mode from step 4):
150
- - Foreground: `dev-pipeline/run.sh run feature-list.json`
151
- - Background: `dev-pipeline/launch-daemon.sh start feature-list.json`
152
+ Default to (a). Only suggest (b) if features have `estimated_complexity: "high"` or above.
153
+
154
+ If user chooses (b), add `--critic` flag to the launch command in step 6.
155
+
156
+ 6. **Ask user to confirm**: "Ready to launch the pipeline? It will process N features."
157
+
158
+ 7. **Launch** (based on chosen mode from step 4, with `--critic` if chosen in step 5):
159
+ - Foreground: `dev-pipeline/run.sh run feature-list.json [--critic]`
160
+ - Background: `dev-pipeline/launch-daemon.sh start feature-list.json [--critic]`
152
161
  - If user specified environment overrides:
153
162
  ```bash
154
163
  dev-pipeline/launch-daemon.sh start feature-list.json --env "SESSION_TIMEOUT=7200 MAX_RETRIES=5"
155
164
  ```
156
165
 
157
- 7. **Verify launch**:
166
+ 8. **Verify launch**:
158
167
  ```bash
159
168
  dev-pipeline/launch-daemon.sh status
160
169
  ```
161
170
 
162
- 8. **Start log monitoring** -- Use the Bash tool with `run_in_background: true`:
171
+ 9. **Start log monitoring** -- Use the Bash tool with `run_in_background: true`:
163
172
  ```bash
164
173
  tail -f dev-pipeline/state/pipeline-daemon.log
165
174
  ```
166
175
  This runs in background so you can continue interacting with the user.
167
176
 
168
- 9. **Report to user**:
177
+ 10. **Report to user**:
169
178
  - Pipeline PID
170
179
  - Log file location
171
180
  - "You can ask me 'pipeline status' or 'show logs' at any time"
@@ -250,6 +259,7 @@ When user specifies custom settings, map to environment variables:
250
259
  | "max 5 retries" | `MAX_RETRIES=5` |
251
260
  | "verbose mode" | `VERBOSE=1` |
252
261
  | "heartbeat every 60s" | `HEARTBEAT_INTERVAL=60` |
262
+ | "enable critic review" | `--critic` flag |
253
263
 
254
264
  Pass via `--env`:
255
265
  ```bash