prizmkit 1.1.130 → 1.1.134

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 (119) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/claude/command-adapter.js +0 -2
  3. package/bundled/dev-pipeline/.env.example +1 -1
  4. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +11 -6
  5. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +445 -8
  6. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +2 -9
  7. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +21 -1
  8. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +87 -66
  9. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +53 -3
  10. package/bundled/dev-pipeline/prizmkit_runtime/runner_recovery.py +55 -25
  11. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +4 -0
  12. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +119 -18
  13. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +3 -2
  14. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +411 -17
  15. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +57 -14
  16. package/bundled/dev-pipeline/scripts/generate-recovery-prompt.py +5 -4
  17. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +55 -2
  18. package/bundled/dev-pipeline/scripts/prompt_framework.py +152 -1
  19. package/bundled/dev-pipeline/scripts/update-bug-status.py +53 -0
  20. package/bundled/dev-pipeline/scripts/update-checkpoint.py +294 -69
  21. package/bundled/dev-pipeline/scripts/update-feature-status.py +57 -0
  22. package/bundled/dev-pipeline/scripts/update-refactor-status.py +53 -0
  23. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +5 -5
  24. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +28 -22
  25. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +24 -10
  26. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +20 -2
  27. package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +2 -2
  28. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +1 -1
  29. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +5 -10
  30. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +9 -19
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +21 -0
  32. package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +1 -1
  33. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +10 -10
  34. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +1 -1
  35. package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +15 -0
  36. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +2 -2
  37. package/bundled/dev-pipeline/templates/sections/phase-commit.md +2 -2
  38. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +26 -23
  39. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +5 -5
  40. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +15 -11
  41. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +1 -1
  42. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +6 -6
  43. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +21 -0
  44. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +1 -1
  45. package/bundled/dev-pipeline/templates/sections/subagent-timeout-recovery.md +1 -1
  46. package/bundled/dev-pipeline/templates/sections/task-contract.md +4 -0
  47. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +362 -3
  48. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +349 -48
  49. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +129 -0
  50. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +91 -0
  51. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +567 -23
  52. package/bundled/dev-pipeline/tests/test_unified_cli.py +37 -10
  53. package/bundled/skills/_metadata.json +63 -26
  54. package/bundled/skills/app-planner/SKILL.md +4 -3
  55. package/bundled/skills/bug-fix-workflow/SKILL.md +89 -180
  56. package/bundled/skills/bug-planner/SKILL.md +12 -27
  57. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +131 -220
  58. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +36 -90
  59. package/bundled/skills/feature-pipeline-launcher/SKILL.md +129 -271
  60. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +35 -76
  61. package/bundled/skills/feature-planner/SKILL.md +27 -22
  62. package/bundled/skills/feature-planner/assets/planning-guide.md +4 -4
  63. package/bundled/skills/feature-workflow/SKILL.md +94 -121
  64. package/bundled/skills/prizmkit/SKILL.md +130 -94
  65. package/bundled/skills/prizmkit/references/workflow-state-protocol.md +181 -0
  66. package/bundled/skills/prizmkit-code-review/SKILL.md +132 -86
  67. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +243 -0
  68. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +42 -1
  69. package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +181 -0
  70. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +93 -1
  71. package/bundled/skills/prizmkit-committer/SKILL.md +125 -48
  72. package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +181 -0
  73. package/bundled/skills/prizmkit-implement/SKILL.md +99 -73
  74. package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +1 -1
  75. package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +181 -0
  76. package/bundled/skills/prizmkit-init/SKILL.md +5 -5
  77. package/bundled/skills/prizmkit-plan/SKILL.md +146 -105
  78. package/bundled/skills/prizmkit-plan/assets/plan-template.md +18 -0
  79. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +242 -0
  80. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +4 -4
  81. package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +181 -0
  82. package/bundled/skills/prizmkit-retrospective/SKILL.md +111 -53
  83. package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +7 -6
  84. package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +5 -4
  85. package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +181 -0
  86. package/bundled/skills/prizmkit-test/SKILL.md +52 -6
  87. package/bundled/skills/prizmkit-test/assets/authoritative-records.schema.json +63 -12
  88. package/bundled/skills/prizmkit-test/assets/evidence-manifest.schema.json +1 -1
  89. package/bundled/skills/prizmkit-test/assets/evidence-package-template.json +13 -0
  90. package/bundled/skills/prizmkit-test/references/evidence-protocol.md +6 -1
  91. package/bundled/skills/prizmkit-test/references/evidence-request-protocol.md +8 -1
  92. package/bundled/skills/prizmkit-test/references/examples.md +1 -1
  93. package/bundled/skills/prizmkit-test/references/test-generation-steps.md +4 -1
  94. package/bundled/skills/prizmkit-test/references/test-report-template.md +1 -1
  95. package/bundled/skills/prizmkit-test/references/trusted-evidence-execution.md +15 -0
  96. package/bundled/skills/prizmkit-test/references/workflow-state-protocol.md +181 -0
  97. package/bundled/skills/prizmkit-test/scripts/build_test_evidence.py +744 -23
  98. package/bundled/skills/prizmkit-test/scripts/validate_test_evidence.py +194 -15
  99. package/bundled/skills/prizmkit-workflow/SKILL.md +266 -0
  100. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +181 -0
  101. package/bundled/skills/recovery-workflow/SKILL.md +62 -241
  102. package/bundled/skills/recovery-workflow/evals/evals.json +17 -33
  103. package/bundled/skills/recovery-workflow/references/detection.md +28 -52
  104. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +105 -439
  105. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +136 -275
  106. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +53 -88
  107. package/bundled/skills/refactor-planner/SKILL.md +12 -57
  108. package/bundled/skills/refactor-planner/references/behavior-preservation.md +111 -230
  109. package/bundled/skills/refactor-planner/references/error-recovery.md +37 -0
  110. package/bundled/skills/refactor-planner/references/planning-phases.md +11 -17
  111. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +1 -1
  112. package/bundled/skills/refactor-workflow/SKILL.md +98 -139
  113. package/bundled/templates/project-memory-template.md +4 -4
  114. package/package.json +1 -1
  115. package/src/index.js +4 -0
  116. package/src/prompts.js +10 -3
  117. package/src/scaffold.js +1 -1
  118. package/bundled/dev-pipeline/tests/test-deploy-safety.sh +0 -223
  119. 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
161
+ → committer verifies gates and commits automatically
162
+ → no question or wait is permitted
163
+ ```
164
+
165
+ A self-declared or otherwise untrusted headless context does not authorize a commit. Remote publication remains a separate host-runtime decision.
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,102 +1,128 @@
1
1
  ---
2
2
  name: "prizmkit-implement"
3
- description: "Execute plan.md tasks with a TDD-oriented approach. Respects task ordering, checkpoints, and dependencies for Fast path or Full path change artifacts. Reads Prizm docs before editing; optional inline implementation subagent delegation uses this skill's references and active-checkout/no-worktree constraints. Use after /prizmkit-plan. Trigger on: 'implement', 'build', 'code it', 'start coding', 'execute', 'write the code'. (project)"
3
+ description: "Execute the reviewed plan for a formal PrizmKit requirement, update task checkpoints, preserve the shared workflow artifact directory, and hand off to prizmkit-code-review. Use after prizmkit-plan or when resuming implementation repair. (project)"
4
4
  ---
5
5
 
6
6
  # PrizmKit Implement
7
7
 
8
- ### When to Use
9
- - After `/prizmkit-plan` when ready to write code
10
- - Fast path or Full path has a `plan.md` with unchecked tasks
11
- - User says "implement", "build", "code it", "start coding", "develop", or "execute"
8
+ `/prizmkit-implement` executes the tasks in one formal requirement's `plan.md`. It is the implementation stage, including implementation repairs requested by code review or testing.
12
9
 
13
- ### When NOT to Use
14
- - No `plan.md` exists and the task is not a Direct edit — run `/prizmkit-plan` first
15
- - All tasks in `plan.md` are checked off
16
- - Direct edit: typo, pure formatting, small docs edit, or tiny config tweak with no behavior impact
17
- - User is still asking for design/planning rather than implementation
10
+ ## When to Use
18
11
 
19
- ## Preconditions
12
+ - After `/prizmkit-plan` reports `PLAN_READY`.
13
+ - When workflow state routes a review or test repair back to implementation.
14
+ - When `plan.md` contains unchecked tasks for the active requirement.
15
+ - User says "implement", "build", "code it", "start coding", "develop", or "execute".
20
16
 
21
- | Required Artifact | Check | If Missing |
17
+ ## When NOT to Use
18
+
19
+ - No `spec.md` and `plan.md` exist for the formal requirement.
20
+ - All planned tasks are complete and no repair scope is recorded.
21
+ - The user is still deciding scope or asking for planning.
22
+ - The request is a direct low-risk edit outside the formal requirement lifecycle.
23
+
24
+ ## Preconditions and Artifact Identity
25
+
26
+ | Required artifact | Check | If missing |
22
27
  |---|---|---|
23
- | `plan.md` with Tasks section | File exists and has unchecked tasks | Run `/prizmkit-plan` |
24
- | `spec.md` | File exists in same artifact directory | Run `/prizmkit-plan` |
28
+ | `plan.md` with Tasks | Exists and contains incomplete or explicitly repairable work | Return `IMPLEMENT_BLOCKED` and direct the user to `/prizmkit-plan`. |
29
+ | `spec.md` | Exists in the same artifact directory | Return `IMPLEMENT_BLOCKED` and direct the user to `/prizmkit-plan`. |
30
+ | Workflow state | Reusable or reconstructable | Reconstruct from artifacts and report the result when absent or stale. |
25
31
 
26
- Artifact directory: accept `artifact_dir` from caller. If not provided, scan `.prizmkit/` subdirectories for the most recently modified `plan.md` with unchecked tasks. When invoked as a handoff step, reuse the previous skill's `artifact_dir`; re-detection can select the wrong change artifact in a multi-task workspace.
32
+ Accept `artifact_dir` from the preceding skill or workflow state. Do not scan for a different most-recent plan when invoked as a handoff. A single requirement must reuse the same `artifact_dir` throughout all stages.
27
33
 
28
34
  ## Context Loading
29
35
 
30
- Before implementation, load context once:
36
+ Before editing:
31
37
 
32
- 1. **Task context**: read `plan.md` and `spec.md`. If companion documents exist in the artifact directory, read only those relevant to the change.
33
- 2. **Architecture context**:
34
- - Read `.prizmkit/prizm-docs/root.prizm`.
35
- - Read relevant L1 docs for affected modules.
36
- - Read relevant L2 docs when they exist, especially INTERFACES, TRAPS, and DECISIONS.
37
- - If a relevant L2 doc does not exist, read the target source files as fallback and note that no L2 was available. Do not stop implementation only because L2 is missing; `/prizmkit-retrospective` can create L2 after the change if durable detail exists.
38
- 3. **Dev rules**: if root Prizm docs reference `.prizmkit/rules/<layer>-rules.md`, read the relevant rule files. If a referenced rule file is missing, skip it and continue.
38
+ 1. Read `plan.md`, `spec.md`, and only relevant companion artifacts.
39
+ 2. Read `.prizmkit/prizm-docs/root.prizm` when present.
40
+ 3. Read relevant L1 docs and relevant L2 docs when present.
41
+ 4. If an affected L2 doc is missing, read the target source files as fallback and record that no L2 context was available. Do not create L2 merely because it was read; retrospective decides whether durable knowledge warrants it.
42
+ 5. Read referenced layer rules when present. If a rule conflicts with the plan, stop and ask the user unless the plan clearly supersedes the rule.
39
43
 
40
- If a dev rule conflicts with `plan.md`, call out the conflict and ask the user unless the plan clearly supersedes the rule.
44
+ ## Optional Inline Delegation
41
45
 
42
- ## Optional Inline Implementation Subagent Delegation
46
+ The default is direct Main-Agent implementation. If a narrow slice is delegated, use `prompt_reference: ${SKILL_DIR}/references/implementation-subagent-procedure.md` and follow its active-checkout/no-worktree constraints. Delegation is optional implementation detail and does not alter lifecycle handoff or ownership.
43
47
 
44
- The default execution mode is direct Main Agent implementation. If delegation is useful for a narrow implementation slice, use only this skill's local reference:
48
+ ## Atomic Stage Boundary
45
49
 
46
- ```yaml
47
- prompt_reference: ${SKILL_DIR}/references/implementation-subagent-procedure.md
48
- isolation: current-workspace / active-checkout / no-worktree
49
- subagent_kind: inline implementation prompt, not a platform-installed named agent
50
- ```
50
+ `prizmkit-implement` owns only execution of plan tasks and implementation repairs. It writes its truthful terminal result and `next_stage`, then returns control. When an external orchestrator is active, it must not invoke code review or test itself. The active orchestrator owns the next-stage invocation.
51
51
 
52
- Delegation rules:
53
- - Read `${SKILL_DIR}/references/implementation-subagent-procedure.md` before preparing the subagent prompt.
54
- - Pass the expected active checkout git top-level and the exact delegated task/file scope.
55
- - Do not use worktree isolation, copied checkouts, remote isolated checkouts, branch switching, or a platform-installed named implementation agent.
56
- - If active-checkout/no-worktree launch cannot be satisfied, stop with:
52
+ ## Execution
57
53
 
58
- ```text
59
- Cannot delegate /prizmkit-implement because this platform cannot start an inline implementation subagent in the active checkout without worktree, copy, remote, or branch isolation.
60
- ```
54
+ For each unchecked or explicitly repair-scoped task, in plan order:
61
55
 
62
- ## Execution
56
+ 1. Confirm the target scope and relevant context.
57
+ 2. Apply TDD when appropriate:
58
+ - add or update a failing test first for behavior changes;
59
+ - use the smallest meaningful verification for docs, configuration, UI-only, or mechanical changes.
60
+ 3. Cover relevant happy paths, domain edges, and errors without inventing meaningless tests.
61
+ 4. Avoid unrelated edits and preserve the requirement's artifact identity.
62
+ 5. Mark a task complete immediately after its implementation is complete.
63
+ 6. Stop dependent tasks on failure; run `[P]` tasks in parallel only when safe.
64
+ 7. Execute only local implementation verification here. The mandatory full lifecycle code review follows implementation and the mandatory auditable test stage follows code review.
65
+
66
+ ### Repair Scope
67
+
68
+ When routed from a failed test or review, read `repair_scope` from workflow state and constrain edits accordingly:
63
69
 
64
- For each unchecked task in `plan.md`, in order:
65
-
66
- 1. Confirm relevant context for the target files is loaded: L1, L2 when present, or source fallback when L2 is absent.
67
- 2. Apply TDD where applicable:
68
- - Write or update a failing test first for behavior changes.
69
- - For UI-only, docs, configuration, or mechanical refactors where test-first does not apply, use the smallest meaningful verification instead.
70
- 3. Follow internal ID hygiene: do not place PrizmKit feature/bug/refactor IDs, task IDs, session/run IDs, branch names, absolute worktree paths, or `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths in `.prizmkit/prizm-docs/`, user-visible UI text, API responses, emails, notifications, or tests that assert visible product copy.
71
- 4. Cover relevant paths for changed logic:
72
- - happy path
73
- - domain-specific edge cases
74
- - error conditions
75
- Do not force meaningless edge/error tests when the function has none.
76
- 5. Avoid redundant tests. Check existing coverage before adding a new test; each new test should exercise a distinct behavior or boundary.
77
- 6. Test your own code and integration points, not framework internals, third-party library internals, or language built-ins.
78
- 7. Mark the task as `[x]` immediately after completion. Immediate marking makes interrupted sessions resumable.
79
- 8. Respect task semantics:
80
- - Sequential tasks stop on failure when later tasks depend on them.
81
- - `[P]` tasks may run in parallel within the same safe group.
82
- - `CP:` checkpoint tasks require build/tests/verification specified by the plan before continuing.
83
- 9. After all tasks complete, run the verification appropriate to the chosen path and risk. Full test orchestration via `/prizmkit-test` is risk-triggered, not mandatory for every change.
70
+ - `production`, `runtime`, `schema`, `dependency`, or `public-interface`: production-affecting changes. Completion must hand off to `prizmkit-code-review`.
71
+ - `test-infrastructure`: tests, fixtures, test runner configuration, or evidence setup only. Completion may hand off directly to `prizmkit-test`.
72
+ - `unknown`: stop and ask the user; do not guess which downstream gates can be skipped.
84
73
 
85
74
  ## Recovery
86
75
 
87
- If a session is interrupted:
76
+ If interrupted:
77
+
78
+ - Reuse completed task markers and the same `artifact_dir`.
79
+ - Inspect any partially edited files before continuing.
80
+ - Reconcile workflow state with the plan and current diff.
81
+ - Never report `IMPLEMENTED` when incomplete tasks or unresolved repair work remain.
82
+
83
+ ## Workflow State
84
+
85
+ Before reading or updating workflow state, read `${SKILL_DIR}/references/workflow-state-protocol.md`.
88
86
 
89
- - Completed tasks should already be marked `[x]`.
90
- - Re-run `/prizmkit-implement`; it resumes from the first unchecked task.
91
- - If partially edited files exist without a completed task marker, inspect the diff and either finish the task or revert incomplete work before continuing.
87
+ On successful implementation, update `.prizmkit/state/workflows/<requirement-slug>.json` with:
92
88
 
93
- ## Output
89
+ ```json
90
+ {
91
+ "stage": "implement",
92
+ "status": "IMPLEMENTED",
93
+ "completed_stages": ["plan", "implement"],
94
+ "repair_round": 0,
95
+ "repair_scope": null,
96
+ "next_stage": "code-review",
97
+ "resume_from": "prizmkit-code-review"
98
+ }
99
+ ```
100
+
101
+ For a repair, increment `repair_round`, set `status` to `IMPLEMENT_REPAIR`, preserve the triggering failure in the state, and select the next stage according to `repair_scope`. The outer workflow permits at most three repair rounds; the implementation stage must return a blocked result rather than start a fourth round.
102
+
103
+ ## Output and Handoff
104
+
105
+ Report:
106
+
107
+ - implementation summary;
108
+ - completed and remaining tasks;
109
+ - files changed;
110
+ - local verification performed;
111
+ - workflow state path and status;
112
+ - exact next stage.
113
+
114
+ On initial implementation or a production-affecting repair:
115
+
116
+ ```text
117
+ IMPLEMENTED
118
+ → /prizmkit-code-review
119
+ ```
120
+
121
+ On a test-infrastructure-only repair:
122
+
123
+ ```text
124
+ IMPLEMENTED
125
+ → /prizmkit-test
126
+ ```
94
127
 
95
- - Code files created/modified as specified in `plan.md`
96
- - `plan.md` Tasks section updated with `[x]` markers
97
- - Implementation summary
98
- - Suggested next step:
99
- - Full path or review-triggered risk: `/prizmkit-code-review`
100
- - Risk-triggered testing: `/prizmkit-test`
101
- - Docs/durable knowledge changed: `/prizmkit-retrospective`
102
- - Otherwise: `/prizmkit-committer`
128
+ If workflow state names an active `orchestrator`, return the terminal result, state path, and selected next stage to it; do not invoke another stage independently. For direct stage use, provide the deterministic next invocation with the same `artifact_dir`; a host may perform that semantic handoff on the user's behalf.
@@ -10,7 +10,7 @@ The Main Agent must provide:
10
10
  - The exact plan tasks or files delegated.
11
11
  - Any loaded Prizm docs traps/rules relevant to the delegated files.
12
12
 
13
- The implementation subagent must run in the same active checkout as the Main Agent.
13
+ The implementation subagent must run in the same active checkout as the Main Agent. This is an inline subagent constraint, not a permission to create an isolated execution unit or worktree.
14
14
 
15
15
  ## Active Checkout Guard
16
16
 
@@ -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
161
+ → committer verifies gates and commits automatically
162
+ → no question or wait is permitted
163
+ ```
164
+
165
+ A self-declared or otherwise untrusted headless context does not authorize a commit. Remote publication remains a separate host-runtime decision.
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