prizmkit 1.1.129 → 1.1.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/dev-pipeline/.env.example +1 -1
  3. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +445 -8
  4. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +87 -66
  5. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +53 -3
  6. package/bundled/dev-pipeline/prizmkit_runtime/runner_recovery.py +55 -25
  7. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +4 -0
  8. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +15 -1
  9. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +398 -6
  10. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +61 -3
  11. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +64 -4
  12. package/bundled/dev-pipeline/scripts/prompt_framework.py +156 -7
  13. package/bundled/dev-pipeline/scripts/update-bug-status.py +53 -0
  14. package/bundled/dev-pipeline/scripts/update-checkpoint.py +294 -69
  15. package/bundled/dev-pipeline/scripts/update-feature-status.py +57 -0
  16. package/bundled/dev-pipeline/scripts/update-refactor-status.py +53 -0
  17. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +2 -2
  18. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +20 -14
  19. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +21 -4
  20. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +18 -0
  21. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +1 -1
  22. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +5 -15
  23. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +21 -0
  24. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +10 -10
  25. package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +16 -0
  26. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +26 -23
  27. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +12 -8
  28. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +1 -1
  29. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +21 -0
  30. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +362 -3
  31. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +404 -24
  32. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +132 -0
  33. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +91 -0
  34. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +411 -18
  35. package/bundled/dev-pipeline/tests/test_unified_cli.py +3 -3
  36. package/bundled/skills/_metadata.json +62 -25
  37. package/bundled/skills/app-planner/SKILL.md +4 -3
  38. package/bundled/skills/bug-fix-workflow/SKILL.md +89 -180
  39. package/bundled/skills/bug-planner/SKILL.md +12 -27
  40. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +131 -220
  41. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +36 -90
  42. package/bundled/skills/feature-pipeline-launcher/SKILL.md +129 -271
  43. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +35 -76
  44. package/bundled/skills/feature-planner/SKILL.md +27 -22
  45. package/bundled/skills/feature-planner/assets/planning-guide.md +4 -4
  46. package/bundled/skills/feature-workflow/SKILL.md +94 -121
  47. package/bundled/skills/prizmkit/SKILL.md +130 -94
  48. package/bundled/skills/prizmkit/references/workflow-state-protocol.md +181 -0
  49. package/bundled/skills/prizmkit-code-review/SKILL.md +114 -84
  50. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +1 -1
  51. package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +181 -0
  52. package/bundled/skills/prizmkit-committer/SKILL.md +131 -47
  53. package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +181 -0
  54. package/bundled/skills/prizmkit-implement/SKILL.md +99 -73
  55. package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +1 -1
  56. package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +181 -0
  57. package/bundled/skills/prizmkit-init/SKILL.md +5 -5
  58. package/bundled/skills/prizmkit-plan/SKILL.md +132 -105
  59. package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +181 -0
  60. package/bundled/skills/prizmkit-retrospective/SKILL.md +111 -53
  61. package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +7 -6
  62. package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +5 -4
  63. package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +181 -0
  64. package/bundled/skills/prizmkit-test/SKILL.md +28 -6
  65. package/bundled/skills/prizmkit-test/references/examples.md +1 -1
  66. package/bundled/skills/prizmkit-test/references/test-report-template.md +1 -1
  67. package/bundled/skills/prizmkit-test/references/workflow-state-protocol.md +181 -0
  68. package/bundled/skills/prizmkit-workflow/SKILL.md +266 -0
  69. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +181 -0
  70. package/bundled/skills/recovery-workflow/SKILL.md +62 -241
  71. package/bundled/skills/recovery-workflow/evals/evals.json +17 -33
  72. package/bundled/skills/recovery-workflow/references/detection.md +28 -52
  73. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +105 -439
  74. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +136 -275
  75. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +53 -88
  76. package/bundled/skills/refactor-planner/SKILL.md +12 -57
  77. package/bundled/skills/refactor-planner/references/behavior-preservation.md +111 -230
  78. package/bundled/skills/refactor-planner/references/error-recovery.md +37 -0
  79. package/bundled/skills/refactor-planner/references/planning-phases.md +11 -17
  80. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +1 -1
  81. package/bundled/skills/refactor-workflow/SKILL.md +98 -139
  82. package/bundled/templates/project-memory-template.md +4 -4
  83. package/package.json +1 -1
  84. package/src/index.js +4 -0
  85. package/src/prompts.js +10 -3
  86. package/src/scaffold.js +1 -1
  87. package/bundled/dev-pipeline/tests/test-deploy-safety.sh +0 -223
  88. package/bundled/skills/feature-pipeline-launcher/scripts/preflight-check.py +0 -462
@@ -0,0 +1,181 @@
1
+ # PrizmKit Workflow State Protocol
2
+
3
+ `workflow-state.json` is lifecycle runtime metadata for one formal requirement. It preserves stage handoff, repair routing, orchestrator ownership, and resume information without replacing authoritative artifacts or any host-owned execution checkpoint.
4
+
5
+ ## Location and Identity
6
+
7
+ ```text
8
+ .prizmkit/state/workflows/<requirement-slug>.json
9
+ ```
10
+
11
+ The state file is created only when a lifecycle runs. The active `artifact_dir` is the generic requirement artifact root and must be preserved exactly across every stage:
12
+
13
+ ```text
14
+ .prizmkit/specs/<requirement-slug>/
15
+ .prizmkit/bugfix/<bug-id>/
16
+ .prizmkit/refactor/<refactor-id>/
17
+ ```
18
+
19
+ Never select a different most-recent plan when resuming or handing off. Any execution checkpoint maintained by an external host remains separate from this lifecycle state. Never merge, substitute, or infer one schema from the other. The target project controls whether generated `.prizmkit/` files are committed, ignored, or shared.
20
+
21
+ ## Authority
22
+
23
+ The state file is an index, not the authority for stage completion:
24
+
25
+ | Information | Authority |
26
+ |---|---|
27
+ | Requirement goals and acceptance criteria | `{artifact_dir}/spec.md` |
28
+ | Implementation tasks and completion | `{artifact_dir}/plan.md` plus current workspace |
29
+ | Review findings and verdict | `{artifact_dir}/review-report.md` final result |
30
+ | Test execution, verdict, and repair scope | Validated evidence package and authoritative `verdict.json` |
31
+ | Test report presentation | `{artifact_dir}/test-report.md` as a derived view only |
32
+ | Retrospective completion and result | `{artifact_dir}/retrospective-result.json` |
33
+ | Durable architecture knowledge | `.prizmkit/prizm-docs/` |
34
+ | Local commit | Git history and confirmed or authorized commit identity |
35
+ | Current stage, orchestrator, and resume entry | Workflow state |
36
+ | External orchestration progress | The external host's own checkpoint, never this state |
37
+
38
+ Every consumer compares workflow state with authoritative artifacts and the current workspace. Missing or stale state is reconstructed from those sources and is never accepted as success by itself.
39
+
40
+ ## Schema
41
+
42
+ ```json
43
+ {
44
+ "schema_version": 1,
45
+ "artifact_dir": ".prizmkit/specs/example",
46
+ "orchestrator": "prizmkit-workflow",
47
+ "stage": "test",
48
+ "status": "TEST_PASS",
49
+ "stage_result": "TEST_PASS",
50
+ "completed_stages": ["plan", "implement", "code-review", "test"],
51
+ "repair_scope": null,
52
+ "repair_round": 0,
53
+ "next_stage": "retrospective",
54
+ "resume_from": "prizmkit-retrospective"
55
+ }
56
+ ```
57
+
58
+ ### Fields
59
+
60
+ | Field | Meaning |
61
+ |---|---|
62
+ | `schema_version` | State schema version. Current value is `1`. |
63
+ | `artifact_dir` | The single generic requirement artifact root reused by every stage. |
64
+ | `orchestrator` | `prizmkit-workflow`, another semantic coordinator identifier, or `null` for direct stage use. |
65
+ | `stage` | The stage that most recently wrote state. |
66
+ | `status` | Lifecycle progression status, distinct from the domain `stage_result`. |
67
+ | `stage_result` | Domain result such as `PASS`, `NEEDS_FIXES`, `TEST_*`, `DOCS_UPDATED`, or `NO_DOC_CHANGE`. |
68
+ | `completed_stages` | Ordered stages completed for this requirement. |
69
+ | `repair_scope` | `null`, `test-infrastructure`, `production`, `runtime`, `schema`, `dependency`, `public-interface`, or `unknown`. |
70
+ | `repair_round` | Outer cross-stage repair round, from `0` through `3`. |
71
+ | `next_stage` | Next semantic stage, or `null` after commit. |
72
+ | `resume_from` | Exact atomic skill that can resume, or `null` after commit. |
73
+
74
+ ## Lifecycle and Verdict Mappings
75
+
76
+ The mandatory formal lifecycle is:
77
+
78
+ ```text
79
+ PLAN_READY
80
+ → IMPLEMENTED
81
+ → REVIEW_PASS
82
+ → TEST_PASS
83
+ → RETRO_COMPLETE
84
+ → COMMIT_PENDING
85
+ → COMMITTED
86
+ ```
87
+
88
+ No formal stage is silently optional. Domain evidence maps as follows:
89
+
90
+ ```text
91
+ review-report final PASS → status=REVIEW_PASS, stage_result=PASS
92
+ review-report final NEEDS_FIXES → status=REVIEW_NEEDS_FIXES, stage_result=NEEDS_FIXES
93
+ validated verdict TEST_PASS → status=TEST_PASS, stage_result=TEST_PASS
94
+ validated verdict TEST_FAIL → status=TEST_FAIL, stage_result=TEST_FAIL
95
+ validated verdict TEST_BLOCKED → status=TEST_BLOCKED, stage_result=TEST_BLOCKED
96
+ retrospective result DOCS_UPDATED → status=RETRO_COMPLETE, stage_result=DOCS_UPDATED
97
+ retrospective result NO_DOC_CHANGE → status=RETRO_COMPLETE, stage_result=NO_DOC_CHANGE
98
+ ```
99
+
100
+ `RETRO_COMPLETE` is the stable completion status. `DOCS_UPDATED` and `NO_DOC_CHANGE` are mutually exclusive retrospective results, not substitute statuses. A derived Markdown test report never establishes a `TEST_*` status without validated authoritative evidence.
101
+
102
+ ## Repair Routing
103
+
104
+ ```text
105
+ REVIEW_NEEDS_FIXES
106
+ → implement
107
+ → code-review
108
+ → test
109
+
110
+ TEST_FAIL with repair_scope=test-infrastructure
111
+ → implement
112
+ → test
113
+
114
+ TEST_FAIL with repair_scope=production|runtime|schema|dependency|public-interface
115
+ → implement
116
+ → code-review
117
+ → test
118
+
119
+ TEST_FAIL with repair_scope=unknown
120
+ → conservative production route only when safe
121
+ → otherwise WORKFLOW_BLOCKED
122
+
123
+ TEST_BLOCKED
124
+ → never make speculative production edits
125
+ → interactive execution stops with a prizmkit-test resume entry
126
+ → a trusted headless host may perform bounded environment recovery, then records WORKFLOW_BLOCKED if unresolved
127
+
128
+ RETRO_BLOCKED
129
+ → WORKFLOW_BLOCKED
130
+ WORKFLOW_BLOCKED
131
+ → resume only after the recorded blocker is resolved
132
+ ```
133
+
134
+ The outer workflow permits at most three automatic repair rounds. These are cross-stage rounds (`repair_round` `0` through `3`). The code-review internal loop permits at most ten completed review rounds and is separate; review-internal repairs do not increment the outer counter.
135
+
136
+ ## Orchestrator Ownership and Handoff
137
+
138
+ 1. An atomic stage performs only its own stage, writes the truthful terminal result and `next_stage`, and returns control.
139
+ 2. When `orchestrator` is non-null, only that orchestrator invokes the next skill. The atomic stage must not auto-invoke it again.
140
+ 3. Direct stage use may report one deterministic next invocation but does not claim the next stage ran.
141
+ 4. Every handoff preserves the same `artifact_dir`.
142
+ 5. External automation invokes atomic stages directly and does not invoke `prizmkit-workflow` as a nested coordinator.
143
+ 6. Workflow state never replaces or absorbs an external host's checkpoint.
144
+
145
+ ## Commit Authorization
146
+
147
+ Interactive execution:
148
+
149
+ ```text
150
+ committer previews intended files and message
151
+ → waits for explicit confirmation from the current user
152
+ → creates the local commit
153
+ ```
154
+
155
+ Trusted headless execution:
156
+
157
+ ```text
158
+ a trusted host explicitly authorizes the current local task commit
159
+ → host injects mode=<host-defined-headless-mode>, owner=<trusted-host-identifier>,
160
+ local_commit_authorized=true, push_authorized=false
161
+ → committer verifies gates and commits automatically
162
+ → no question, wait, or push is permitted
163
+ ```
164
+
165
+ A self-declared or otherwise untrusted headless context does not authorize a commit. Push is never implied by either mode.
166
+
167
+ ## Recovery
168
+
169
+ When state is missing, stale, or inconsistent:
170
+
171
+ 1. Read `spec.md` and `plan.md` from `artifact_dir` only when they are not already available in current context.
172
+ 2. Inspect task markers and the current workspace.
173
+ 3. Read the latest review report and final result when needed to establish review authority.
174
+ 4. Validate authoritative test evidence and `repair_scope`.
175
+ 5. Validate `retrospective-result.json` when retrospective is claimed complete.
176
+ 6. Verify the commit when commit is claimed complete.
177
+ 7. When an external host is active, let that host validate its own checkpoint independently; never merge the schemas.
178
+ 8. Reconstruct the latest safe predecessor and report the reconstruction.
179
+ 9. Continue only from the first incomplete or invalid stage.
180
+
181
+ Stale state never bypasses review, testing, retrospective, commit authorization, or external host checkpoint enforcement.
@@ -1,17 +1,17 @@
1
1
  ---
2
2
  name: "prizmkit-init"
3
- description: "Project takeover and bootstrap. Scans any project, generates Prizm docs and project brief. Use this skill whenever a user opens a new project for the first time, says 'initialize', 'set up PrizmKit', 'take over this project', 'bootstrap', 'scan this codebase', 'init', or when .prizmkit/prizm-docs/ doesn't exist yet. Also use when PrizmKit was just installed via npx but not yet initialized. (project)"
3
+ description: "Recommended one-time project initialization for PrizmKit. Scans greenfield or brownfield projects, generates Prizm docs and a project brief, and prepares optional context for the formal requirement lifecycle. Use for initialize, bootstrap, take over this project, or first-time setup requests. (project)"
4
4
  ---
5
5
 
6
6
  # PrizmKit Init
7
7
 
8
- Project takeover and bootstrap skill. Scans any project (brownfield or greenfield), generates Prizm documentation and project brief. Supports Codex, Claude Code, CodeBuddy, and multi-platform installations.
8
+ Recommended project initialization skill. Scans any brownfield or greenfield project, generates Prizm documentation and a project brief, and adapts to the current AI coding host when platform-specific instruction files are present.
9
9
 
10
10
  ### When to Use
11
11
  - Taking over a new project (brownfield or greenfield)
12
12
  - User says "initialize PrizmKit", "set up PrizmKit", "take over this project"
13
13
  - First time using PrizmKit on a project
14
- - After `npx prizmkit install` when project has no `.prizmkit/prizm-docs/`
14
+ - After the PrizmKit skills are installed (for example with `npx skills add`) when the project has no `.prizmkit/prizm-docs/`
15
15
 
16
16
  ### When NOT to Use
17
17
  - All artifacts exist and are up to date → skip init; use `/prizmkit-prizm-docs` Status/Validate for health checks
@@ -26,7 +26,7 @@ Project takeover and bootstrap skill. Scans any project (brownfield or greenfiel
26
26
  ## Execution Steps
27
27
 
28
28
  **Phase 1: Platform Detection**
29
- 1. Detect which platform is running (Codex, Claude Code, or CodeBuddy) via AI CLI environment.
29
+ 1. Detect the current AI coding host through available environment signals. Platform-specific files such as `AGENTS.md`, `CLAUDE.md`, or `CODEBUDDY.md` are non-exhaustive examples, not protocol identifiers.
30
30
  2. Hold detected platform value in memory — written to disk in Phase 6 along with other config fields.
31
31
 
32
32
  **Phase 2: Mode Detection**
@@ -140,7 +140,7 @@ Detect database and deployment signals, then ask 1-2 brief questions. This phase
140
140
  - If "SaaS platform": follow up with platform selection (Vercel / Railway / Fly.io / Cloudflare / AWS / Other)
141
141
 
142
142
  3. **Write results**:
143
- - Append `### Infrastructure` section to the detected **main** platform instruction file (`AGENTS.md` for Codex, `CLAUDE.md` for Claude Code, `CODEBUDDY.md` for CodeBuddy). Do not write Infrastructure to `AGENTS.private.md`, `CLAUDE.private.md`, or `CODEBUDDY.private.md`; private files are reserved for PrizmKit framework protocol imports. Format:
143
+ - Append `### Infrastructure` to the detected host's main instruction file when that file exists. Use the host's conventional main instruction file; examples include `AGENTS.md`, `CLAUDE.md`, and `CODEBUDDY.md`. Do not write Infrastructure to private instruction files reserved for framework protocol imports. Format:
144
144
  ```markdown
145
145
  ### Infrastructure
146
146
 
@@ -1,131 +1,158 @@
1
1
  ---
2
2
  name: "prizmkit-plan"
3
- description: "Specify and plan development tasks: natural language change artifact with spec.md and plan.md. Works for features, bug fixes, refactors, migrations, and other non-trivial changes. Use before /prizmkit-implement when the task needs written scope, design, or executable tasks; use simplified planning for Fast path changes and full planning for high-risk or multi-module work. Trigger on: 'specify', 'plan', 'new task', 'I want to add/build...', 'architect', 'design', 'break it down', 'create tasks'. (project)"
3
+ description: "Start the formal PrizmKit requirement lifecycle by turning a natural-language change into reviewed spec.md and plan.md artifacts, initializing workflow state, and handing off to prizmkit-implement. Works for features, bug fixes, refactors, migrations, tests, and other formal requirements. (project)"
4
4
  ---
5
5
 
6
6
  # PrizmKit Plan
7
7
 
8
- A universal spec + plan generator. It turns a natural-language development task into a **change artifact**: `spec.md` (WHAT/WHY) and `plan.md` (HOW + Tasks).
8
+ `/prizmkit-plan` is the entry point for one formal requirement. It converts a natural-language change into a reviewed change artifact: `spec.md` defines WHAT and WHY; `plan.md` defines HOW and executable tasks.
9
9
 
10
- A change artifact is not feature-only. It can describe a feature, bug fix, refactor, migration, test improvement, or other scoped change.
10
+ A change artifact can describe a feature, bug fix, refactor, migration, test improvement, or another scoped requirement.
11
11
 
12
- ### When to Use
13
- - Any non-trivial development task that benefits from written scope and task breakdown
14
- - Before `/prizmkit-implement` when no suitable `plan.md` exists
15
- - Fast path changes that still need a simplified plan and resumable Tasks section
16
- - Full path changes involving multiple files/modules, public interfaces, data models, architecture, security, or unclear requirements
17
- - User says "specify", "plan", "new task", "I want to add...", "architect", "design", or "break it down"
12
+ ## When to Use
18
13
 
19
- ### When NOT to Use
20
- - Direct edit: typo, pure formatting, small docs edit, or tiny config tweak with no behavior impact
21
- - User explicitly asks for a one-off direct edit and the risk is low
22
- - A current artifact directory already has an adequate `spec.md` + `plan.md` for the requested work
14
+ - Starting any formal software requirement.
15
+ - A non-trivial change benefits from written scope, acceptance criteria, and task breakdown.
16
+ - No adequate current `spec.md` and `plan.md` exist for the requested work.
17
+ - User says "specify", "plan", "new task", "I want to add...", "architect", "design", or "break it down".
23
18
 
24
- ## Path Selection
19
+ ## When NOT to Use
25
20
 
26
- Choose the lightest planning depth that protects correctness:
21
+ - Direct edit: typo, pure formatting, small documentation edit, or another explicitly low-risk non-requirement change.
22
+ - The active artifact directory already has an adequate reviewed `spec.md` and `plan.md`; resume from the workflow state instead.
27
23
 
28
- | Path | Planning behavior |
29
- |---|---|
30
- | Direct edit | Skip `/prizmkit-plan`; edit directly and verify the specific change. |
31
- | Fast path | Create a concise `spec.md` and simplified `plan.md` with a Tasks section. |
32
- | Full path | Create full `spec.md` and `plan.md` with architecture, risks, tests, and executable tasks. |
24
+ ## Formal Lifecycle
33
25
 
34
- Use Full path for high-risk, multi-module, public API, data model, security, permission, payment, deployment-impacting, or ambiguous work. Use Fast path for small scoped behavior changes. Explain the chosen path briefly.
26
+ A successful plan starts this fixed lifecycle:
27
+
28
+ ```text
29
+ plan → implement → code-review → test → retrospective → committer
30
+ ```
31
+
32
+ Planning depth may be concise or comprehensive, but no later formal lifecycle stage may be silently skipped.
35
33
 
36
34
  ## Input
37
35
 
38
36
  | Parameter | Required | Description |
39
- |-----------|----------|-------------|
40
- | `description` | Yes | Natural-language description of the task |
41
- | `artifact_dir` | No | Directory to write the change artifact into. If omitted, auto-generates under `.prizmkit/specs/` using a numbered slug. |
42
-
43
- ## Execution
44
-
45
- ### Phase 0: Specify (`spec.md`)
46
-
47
- Skip this phase if `spec.md` already exists in the artifact directory and still matches the requested change.
48
-
49
- Steps:
50
-
51
- 1. Gather the task description. If missing and interactive, ask the user; otherwise abort with a clear error.
52
- 2. Determine artifact directory:
53
- - If `artifact_dir` is provided, use it directly.
54
- - If omitted, scan `.prizmkit/specs/` for existing numbered directories and create `.prizmkit/specs/###-task-slug/`.
55
- - The `.prizmkit/specs/` path is a generic change-artifact location; it is not limited to features.
56
- 3. Load project context: read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs. If L2 is missing for an affected module, use relevant source files as fallback context.
57
- 4. Generate `spec.md` from `${SKILL_DIR}/assets/spec-template.md`:
58
- - Focus on WHAT and WHY, not HOW.
59
- - Include only relevant sections.
60
- - Every goal needs acceptance criteria.
61
- - Mark genuine ambiguity with `[NEEDS CLARIFICATION]`.
62
- 5. If changes involve persistence, add a Data Model section. Read existing schema files to learn naming conventions, ID strategy, constraints, and migration patterns.
63
- 6. Resolve `[NEEDS CLARIFICATION]` markers:
64
- - Interactive: ask targeted questions using `${SKILL_DIR}/references/clarify-guide.md`.
65
- - Non-interactive: choose conservative defaults and annotate the decision.
66
-
67
- Internal ID hygiene: PrizmKit IDs, task IDs, session/run IDs, branch names, absolute worktree paths, and `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths are internal metadata. They may appear in change artifacts, but do not write them into `.prizmkit/prizm-docs/`, product UI copy, API responses, emails, notifications, or expected user-visible test strings.
68
-
69
- ### Phase 1: Design (`plan.md`)
70
-
71
- Precondition: `spec.md` exists.
72
-
73
- Steps:
74
-
75
- 1. Read `spec.md`.
76
- 2. Load project context if not already loaded: root Prizm doc, relevant L1/L2 docs, and source fallback for missing L2 docs.
77
- 3. Resolve any remaining clarification markers.
78
- 4. Generate `plan.md` from `${SKILL_DIR}/assets/plan-template.md`:
79
- - Change approach
80
- - Component/file changes
81
- - Data model changes and migration approach when relevant
82
- - Interface/API contract design when relevant
83
- - Testing strategy, using risk-triggered `/prizmkit-test` criteria
84
- - Risk assessment
85
- - Behavior preservation strategy for refactors or behavior-adjacent changes
86
- 5. Cross-check every spec goal maps to a plan component.
87
- 6. Check alignment with `.prizmkit/prizm-docs/root.prizm` RULES.
88
-
89
- ### Phase 2: Task Generation
90
-
91
- 1. Choose task strategy: MVP-first, incremental, or parallel. Ask in interactive mode when the choice affects execution; otherwise infer from risk and dependencies.
92
- 2. Append `## Tasks` to `plan.md` using `${SKILL_DIR}/assets/plan-template.md`:
93
- - Setup tasks
94
- - Foundation tasks
95
- - Core tasks mapped to goals or logical units
96
- - Polish tasks when needed
97
- - Checkpoint tasks between phases when integration risk exists
98
- 3. Mark parallel tasks with `[P]` only when they can safely run independently.
99
- 4. Run the verification checklist from `${SKILL_DIR}/references/verification-checklist.md` and fix issues before the planning quality gate.
100
-
101
- ### Phase 3: Plan/Spec Review Loop
102
-
103
- Run this phase every time `spec.md` and `plan.md` are created or updated, before reporting the plan or handing off to implementation.
104
-
105
- 1. Explicitly read `${SKILL_DIR}/references/review-plan-spec-loop.md`.
106
- 2. Execute that guide against the current `spec.md` and `plan.md`.
107
- 3. Apply all resolvable `BLOCKER` fixes and accepted `SHOULD_FIX` fixes directly to `spec.md` and/or `plan.md`.
37
+ |---|---|---|
38
+ | `description` | Yes | Natural-language description of the requirement. |
39
+ | `artifact_dir` | No | Directory for the change artifact. If omitted, create a numbered slug under `.prizmkit/specs/`. |
40
+
41
+ ## Atomic Stage Boundary
42
+
43
+ `prizmkit-plan` owns only specification, plan, task generation, and planning-quality review. It writes its truthful terminal result and `next_stage`, then returns control. It must not invoke `prizmkit-implement` itself, including when an external orchestrator is active. The active orchestrator owns the next-stage invocation.
44
+
45
+ ## Phase 0: Initialization Check and Context
46
+
47
+ 1. Check whether project context such as `.prizmkit/prizm-docs/root.prizm`, `.prizmkit/config.json`, or a project brief exists.
48
+ 2. If initialization context is missing:
49
+ - recommend `/prizmkit-init` and explain that it improves project context and cross-session continuity;
50
+ - do not block planning;
51
+ - if the user continues, load the README, manifests, project instruction files, source structure, and relevant source files as fallback.
52
+ 3. If Prizm docs exist, read `root.prizm`, relevant L1 docs, relevant L2 docs when present, and source fallback when L2 is absent.
53
+ 4. Resolve `artifact_dir` once and reuse it for every later lifecycle handoff. Do not re-detect another artifact during the same requirement.
54
+
55
+ ## Phase 1: Specify (`spec.md`)
56
+
57
+ Skip regeneration when `spec.md` already exists and still matches the requested requirement.
58
+
59
+ 1. Gather the requirement description. If it is missing in an interactive run, ask the user; otherwise return a clear blocked result.
60
+ 2. Determine the artifact directory:
61
+ - use the caller-provided `artifact_dir` when present;
62
+ - otherwise scan `.prizmkit/specs/` for existing numbered directories and create `.prizmkit/specs/###-task-slug/`.
63
+ 3. Generate `spec.md` from `${SKILL_DIR}/assets/spec-template.md`:
64
+ - focus on WHAT and WHY, not HOW;
65
+ - include only relevant sections;
66
+ - give every goal acceptance criteria;
67
+ - mark genuine ambiguity with `[NEEDS CLARIFICATION]`.
68
+ 4. For persistence changes, inspect existing schemas and add a Data Model section using project conventions.
69
+ 5. Resolve clarification markers:
70
+ - interactive: use `${SKILL_DIR}/references/clarify-guide.md` and ask targeted questions;
71
+ - non-interactive: choose conservative defaults, annotate them, and block when a safe default is impossible.
72
+
73
+ Internal ID hygiene: PrizmKit IDs, task/session/run IDs, branch names, absolute worktree paths, and internal artifact paths may exist in change artifacts but must not leak into `.prizmkit/prizm-docs/`, product UI copy, API responses, emails, notifications, or expected user-visible test strings.
74
+
75
+ ## Phase 2: Design (`plan.md`)
76
+
77
+ Precondition: `spec.md` exists with no unresolved blocker.
78
+
79
+ 1. Read `spec.md` and relevant project context.
80
+ 2. Resolve remaining clarification markers.
81
+ 3. Choose a planning depth appropriate to the requirement:
82
+ - concise for small, well-scoped formal requirements;
83
+ - comprehensive for multi-module, public API, data model, security, permission, payment, deployment-impacting, or ambiguous requirements.
84
+ 4. Generate `plan.md` from `${SKILL_DIR}/assets/plan-template.md` with:
85
+ - change approach;
86
+ - component and file changes;
87
+ - data migration approach when relevant;
88
+ - interface/API contract design when relevant;
89
+ - test strategy for the mandatory `/prizmkit-test` stage;
90
+ - risks and mitigations;
91
+ - behavior-preservation strategy for refactors.
92
+ 5. Cross-check every spec goal against the plan.
93
+ 6. Check alignment with project rules and available Prizm documentation.
94
+
95
+ ## Phase 3: Task Generation
96
+
97
+ 1. Choose an MVP-first, incremental, or safe parallel task strategy.
98
+ 2. Append `## Tasks` to `plan.md` using `${SKILL_DIR}/assets/plan-template.md`.
99
+ 3. Include setup, foundation, core, polish, and checkpoint tasks only when applicable.
100
+ 4. Mark `[P]` only for tasks that can safely execute independently.
101
+ 5. Include implementation-local verification where useful, while preserving the later full code-review and test stages.
102
+ 6. Run `${SKILL_DIR}/references/verification-checklist.md` and repair plan defects.
103
+
104
+ ## Phase 4: Plan/Spec Review Loop
105
+
106
+ Run every time `spec.md` or `plan.md` is created or changed.
107
+
108
+ 1. Read `${SKILL_DIR}/references/review-plan-spec-loop.md`.
109
+ 2. Review the current artifacts against the requirement and project context.
110
+ 3. Apply all resolvable `BLOCKER` fixes and accepted `SHOULD_FIX` fixes.
108
111
  4. Treat `OPTIONAL` findings as non-blocking.
109
- 5. Rerun the review once when fixes were applied, respecting the guide's maximum of 2 total rounds.
110
- 6. If unresolved `BLOCKER` findings remain, stop and ask targeted clarification questions in interactive mode; in non-interactive mode, record the blocker and stop. Do not escalate to a Critic agent.
111
- 7. Only proceed to `/prizmkit-implement` handoff after the loop has no unresolved blockers.
112
+ 5. Rerun once when fixes were applied, with a maximum of two planning-review rounds.
113
+ 6. If a `BLOCKER` remains, ask targeted questions in interactive mode; otherwise record `PLAN_BLOCKED` and stop.
114
+ 7. Continue only when no unresolved blocker remains.
115
+
116
+ The planning review must not implement code, run the full test stage, or launch external orchestration.
117
+
118
+ ## Phase 5: Workflow State and Handoff
119
+
120
+ Read `${SKILL_DIR}/references/workflow-state-protocol.md` and create or update:
121
+
122
+ ```text
123
+ .prizmkit/state/workflows/<requirement-slug>.json
124
+ ```
125
+
126
+ Follow the bundled protocol. At minimum record:
127
+
128
+ ```json
129
+ {
130
+ "schema_version": 1,
131
+ "artifact_dir": ".prizmkit/specs/001-example",
132
+ "stage": "plan",
133
+ "status": "PLAN_READY",
134
+ "completed_stages": ["plan"],
135
+ "repair_round": 0,
136
+ "repair_scope": null,
137
+ "next_stage": "implement",
138
+ "resume_from": "prizmkit-implement"
139
+ }
140
+ ```
112
141
 
113
- The review loop is planning-only. It must not start implementation, run tests/builds, launch a pipeline, create a separate skill, or require a Critic agent.
142
+ The state file is runtime metadata. Do not change the target project's Git or ignore policy.
114
143
 
115
144
  ## Output
116
145
 
117
- | Directory | Files |
118
- |---|---|
119
- | `artifact_dir` or auto-generated `.prizmkit/specs/###-slug/` | `spec.md` + `plan.md` |
146
+ - `spec.md` and `plan.md` in the resolved artifact directory.
147
+ - Workflow state with `PLAN_READY` or a truthful blocked result.
148
+ - Planning depth, key decisions, task count, and checkpoint summary.
149
+ - The same `artifact_dir` for every downstream stage.
120
150
 
121
- Report:
122
- - artifact directory
123
- - chosen path: Fast path or Full path
124
- - key decisions
125
- - task count and checkpoint summary
151
+ ## Handoff
126
152
 
127
- **HANDOFF:** `/prizmkit-implement`
153
+ On `PLAN_READY`:
128
154
 
129
- ## Examples
155
+ 1. If workflow state names an active `orchestrator`, return `PLAN_READY`, `stage_result=PLAN_READY`, `next_stage=implement`, the state path, and the same `artifact_dir` to that orchestrator; do not invoke the next stage independently.
156
+ 2. For direct stage use with no active orchestrator, report exactly one deterministic next action: `/prizmkit-implement`, with `stage_result=PLAN_READY`, the state-file path, and `artifact_dir`; a host may perform that semantic handoff on the user's behalf.
130
157
 
131
- Read `${SKILL_DIR}/references/examples.md` for worked examples of feature, refactoring, and bug fix planning.
158
+ Read `${SKILL_DIR}/references/examples.md` only when a worked planning example is needed.