prizmkit 1.1.154 → 1.1.156

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 (164) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/codex/skill-adapter.js +1 -1
  3. package/bundled/adapters/pi/skill-adapter.js +2 -1
  4. package/bundled/dev-pipeline/.env.example +2 -6
  5. package/bundled/dev-pipeline/README.md +21 -27
  6. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +341 -15
  7. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +0 -3
  8. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +1 -15
  9. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +48 -14
  10. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +50 -2
  11. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -9
  12. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +3 -3
  13. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +120 -22
  14. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +482 -0
  15. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +64 -11
  16. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +145 -367
  17. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +91 -62
  18. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +105 -69
  19. package/bundled/dev-pipeline/scripts/prompt_framework.py +36 -41
  20. package/bundled/dev-pipeline/scripts/update-bug-status.py +1 -4
  21. package/bundled/dev-pipeline/scripts/update-checkpoint.py +61 -13
  22. package/bundled/dev-pipeline/scripts/update-feature-status.py +1 -4
  23. package/bundled/dev-pipeline/scripts/update-refactor-status.py +1 -4
  24. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +22 -27
  25. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +71 -104
  26. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +59 -111
  27. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +37 -72
  28. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +39 -0
  29. package/bundled/dev-pipeline/templates/sections/bugfix-critical-paths.md +3 -1
  30. package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +8 -25
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +3 -3
  32. package/bundled/dev-pipeline/templates/sections/bugfix-phase-implement.md +2 -2
  33. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +3 -3
  34. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -2
  35. package/bundled/dev-pipeline/templates/sections/bugfix-reminders.md +4 -4
  36. package/bundled/dev-pipeline/templates/sections/bugfix-session-context.md +0 -1
  37. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +7 -4
  38. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +14 -27
  39. package/bundled/dev-pipeline/templates/sections/feature-completion-summary.md +20 -0
  40. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +8 -71
  41. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +7 -7
  42. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +3 -3
  43. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +4 -4
  44. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +5 -17
  45. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +3 -1
  46. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +10 -23
  47. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +2 -2
  48. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +2 -2
  49. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +3 -3
  50. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +2 -2
  51. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +7 -7
  52. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -1
  53. package/bundled/dev-pipeline/templates/sections/retrospective.md +12 -0
  54. package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +35 -0
  55. package/bundled/dev-pipeline/templates/session-status-schema.json +45 -62
  56. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +469 -18
  57. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +262 -175
  58. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +62 -23
  59. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +76 -28
  60. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +168 -18
  61. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +111 -0
  62. package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -2
  63. package/bundled/dev-pipeline/tests/test_runtime_commit.py +608 -0
  64. package/bundled/dev-pipeline/tests/test_unified_cli.py +167 -25
  65. package/bundled/skills/_metadata.json +9 -9
  66. package/bundled/skills/app-planner/SKILL.md +3 -3
  67. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
  68. package/bundled/skills/app-planner/references/rules/backend/derivation-rules.md +56 -64
  69. package/bundled/skills/app-planner/references/rules/backend/fixed-rules.md +85 -240
  70. package/bundled/skills/app-planner/references/rules/backend/question-bank.md +25 -25
  71. package/bundled/skills/app-planner/references/rules/backend/question-manifest.json +16 -7
  72. package/bundled/skills/app-planner/references/rules/backend/template.md +74 -92
  73. package/bundled/skills/app-planner/references/rules/database/derivation-rules.md +93 -93
  74. package/bundled/skills/app-planner/references/rules/database/fixed-rules.md +66 -173
  75. package/bundled/skills/app-planner/references/rules/database/question-bank.md +31 -26
  76. package/bundled/skills/app-planner/references/rules/database/question-manifest.json +13 -4
  77. package/bundled/skills/app-planner/references/rules/database/template.md +76 -98
  78. package/bundled/skills/app-planner/references/rules/frontend/derivation-rules.md +68 -95
  79. package/bundled/skills/app-planner/references/rules/frontend/fixed-rules.md +93 -166
  80. package/bundled/skills/app-planner/references/rules/frontend/question-bank.md +46 -36
  81. package/bundled/skills/app-planner/references/rules/frontend/question-manifest.json +11 -2
  82. package/bundled/skills/app-planner/references/rules/frontend/template.md +79 -257
  83. package/bundled/skills/app-planner/references/rules/mobile/derivation-rules.md +91 -99
  84. package/bundled/skills/app-planner/references/rules/mobile/fixed-rules.md +73 -246
  85. package/bundled/skills/app-planner/references/rules/mobile/question-bank.md +17 -17
  86. package/bundled/skills/app-planner/references/rules/mobile/question-manifest.json +17 -2
  87. package/bundled/skills/app-planner/references/rules/mobile/template.md +73 -85
  88. package/bundled/skills/app-planner/references/rules-configuration.md +133 -65
  89. package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +291 -0
  90. package/bundled/skills/prizmkit/SKILL.md +17 -18
  91. package/bundled/skills/prizmkit/references/workflow-state-protocol.md +22 -18
  92. package/bundled/skills/prizmkit-code-review/SKILL.md +22 -58
  93. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +6 -6
  94. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +2 -2
  95. package/bundled/skills/prizmkit-committer/SKILL.md +82 -132
  96. package/bundled/skills/prizmkit-deploy/SKILL.md +27 -11
  97. package/bundled/skills/prizmkit-deploy/assets/deploy-document-template.md +89 -0
  98. package/bundled/skills/prizmkit-deploy/references/ci-cd-workflows.md +44 -14
  99. package/bundled/skills/prizmkit-deploy/references/cloud-platform-deploy.md +19 -3
  100. package/bundled/skills/prizmkit-deploy/references/database-setup.md +22 -12
  101. package/bundled/skills/prizmkit-deploy/references/deploy-config-schema.md +3 -1
  102. package/bundled/skills/prizmkit-deploy/references/deploy-history-schema.md +22 -6
  103. package/bundled/skills/prizmkit-deploy/references/deploy-metadata-schema.json +49 -0
  104. package/bundled/skills/prizmkit-deploy/references/live-validation-notes.md +1 -1
  105. package/bundled/skills/prizmkit-deploy/references/pending-input-schema.json +164 -0
  106. package/bundled/skills/prizmkit-deploy/references/ssh-adapter-flow.md +9 -8
  107. package/bundled/skills/prizmkit-deploy/references/ssh-execution-flow.md +6 -6
  108. package/bundled/skills/prizmkit-implement/SKILL.md +30 -66
  109. package/bundled/skills/prizmkit-implement/references/implementation-subagent-procedure.md +4 -4
  110. package/bundled/skills/prizmkit-init/SKILL.md +4 -0
  111. package/bundled/skills/prizmkit-plan/SKILL.md +21 -64
  112. package/bundled/skills/prizmkit-plan/references/artifact-identity.md +38 -0
  113. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +4 -4
  114. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +5 -5
  115. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +75 -11
  116. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +191 -56
  117. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +18 -18
  118. package/bundled/skills/prizmkit-prizm-docs/references/op-rebuild.md +14 -8
  119. package/bundled/skills/prizmkit-prizm-docs/references/op-status.md +12 -5
  120. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +23 -12
  121. package/bundled/skills/prizmkit-prizm-docs/references/op-validate.md +13 -9
  122. package/bundled/skills/prizmkit-retrospective/SKILL.md +94 -97
  123. package/bundled/skills/prizmkit-retrospective/references/knowledge-injection-steps.md +79 -37
  124. package/bundled/skills/prizmkit-retrospective/references/retrospective-result-schema.json +138 -0
  125. package/bundled/skills/prizmkit-retrospective/references/structural-sync-steps.md +111 -54
  126. package/bundled/skills/prizmkit-test/SKILL.md +64 -51
  127. package/bundled/skills/prizmkit-test/references/boundary-contract-and-test-double-guidance.md +206 -0
  128. package/bundled/skills/prizmkit-test/references/independent-test-review.md +17 -9
  129. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +45 -21
  130. package/bundled/skills/prizmkit-test/references/test-report-template.md +20 -13
  131. package/bundled/skills/prizmkit-workflow/SKILL.md +35 -37
  132. package/bundled/skills/prizmkit-workflow/references/artifact-identity.md +34 -0
  133. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +22 -18
  134. package/bundled/skills/recovery-workflow/SKILL.md +2 -1
  135. package/bundled/skills/recovery-workflow/references/detection.md +4 -3
  136. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +15 -5
  137. package/bundled/templates/hooks/validate-prizm-docs.py +124 -12
  138. package/package.json +1 -1
  139. package/src/scaffold.js +33 -22
  140. package/bundled/dev-pipeline/templates/sections/bugfix-artifacts.md +0 -16
  141. package/bundled/dev-pipeline/templates/sections/bugfix-session-status.md +0 -31
  142. package/bundled/dev-pipeline/templates/sections/critical-paths-agent.md +0 -7
  143. package/bundled/dev-pipeline/templates/sections/critical-paths-lite.md +0 -7
  144. package/bundled/dev-pipeline/templates/sections/directory-convention-agent.md +0 -9
  145. package/bundled/dev-pipeline/templates/sections/directory-convention-lite.md +0 -6
  146. package/bundled/dev-pipeline/templates/sections/headless-commit-authorization.md +0 -15
  147. package/bundled/dev-pipeline/templates/sections/phase-commit.md +0 -61
  148. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +0 -24
  149. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +0 -12
  150. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +0 -44
  151. package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +0 -25
  152. package/bundled/dev-pipeline/templates/sections/phase-plan-agent.md +0 -20
  153. package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +0 -20
  154. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +0 -20
  155. package/bundled/dev-pipeline/templates/sections/refactor-artifacts.md +0 -17
  156. package/bundled/dev-pipeline/templates/sections/refactor-session-status.md +0 -28
  157. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-agent.md +0 -52
  158. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-lite.md +0 -52
  159. package/bundled/skills/prizmkit-code-review/references/workflow-state-protocol.md +0 -174
  160. package/bundled/skills/prizmkit-committer/references/workflow-state-protocol.md +0 -174
  161. package/bundled/skills/prizmkit-implement/references/workflow-state-protocol.md +0 -174
  162. package/bundled/skills/prizmkit-plan/references/workflow-state-protocol.md +0 -174
  163. package/bundled/skills/prizmkit-retrospective/references/workflow-state-protocol.md +0 -174
  164. package/bundled/skills/prizmkit-test/references/external-contract-mock-guidance.md +0 -119
@@ -37,10 +37,16 @@ CORE_PRINCIPLES:
37
37
  - Self-updating (docs stay fresh via commit-time hooks)
38
38
  - Universal (language and framework agnostic)
39
39
  - Durable project knowledge over auxiliary history (decisions, traps, interfaces, dependencies)
40
+ - Value-gated retention: before keeping a candidate fact, ask `Could a future AI that lacks this fact make an incorrect modification?`; retain it only when yes, current, durable, non-obvious, and owned at this level
41
+ - Protected critical knowledge: preserve still-valid public/wire contracts, cross-module constraints, non-obvious dependencies, traps, decisions with necessary rationale, likely-to-recur rejected alternatives and reasons, side effects, and security/data-integrity/concurrency/transaction/compatibility rules
42
+ - Rejected low-value material: omit source-derivable structure, task/change history, test inventories, temporary conclusions, stale statements, duplicate meanings, long procedures, low-value file lists, and child-owned behavioral detail copied into parents
43
+ - Cleanup in place: Update and Rebuild read existing targets, update equivalent meanings in place, merge synonyms, remove stale/duplicate/derivable/parent-copied content, and add only genuinely new durable knowledge
40
44
  - Memory hygiene over traceability noise (no CHANGELOG sections/files, UPDATED/date metadata, feature/bug/refactor/task/session/run/pipeline/workflow IDs, branch names, absolute worktree paths, or `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths)
41
- - Size-enforced (hard limits per level prevent bloat)
42
- - Lazy L2 generation (detail docs created on first modification or deep read, not during init)
45
+ - Size-enforced (hard limits per level prevent bloat; no project-size override)
46
+ - Capacity-aware (raw UTF-8 byte bands drive warnings and safe remediation; critical knowledge is never deleted merely to meet a check)
47
+ - Lazy L2 generation (detail docs created when durable knowledge exists, not as placeholders during init)
43
48
  - Rules hierarchy (root.prizm RULES are authoritative, module RULES supplement only)
49
+ - Three levels only (semantic concern documents are L2, never a fourth level or memory state machine)
44
50
 
45
51
  ---
46
52
 
@@ -49,18 +55,20 @@ CORE_PRINCIPLES:
49
55
  ## 2.1 Progressive Loading Levels
50
56
 
51
57
  LEVELS:
52
- - L0: Root index. ALWAYS loaded at session start. Max 4KB.
58
+ - L0: Root index. ALWAYS loaded at session start. Hard limit 4096 raw UTF-8 bytes.
53
59
  FILE: .prizmkit/prizm-docs/root.prizm
54
- CONTAINS: project meta, module index with pointers, build commands, tech stack, top rules
60
+ CONTAINS: concise project meta, module summaries with pointers, build commands, tech stack, top rules
61
+ DOES NOT CONTAIN: child-owned interfaces, data flow, TRAPS, DECISIONS, full rules, or copied behavioral detail
55
62
 
56
- - L1: Structural index. Loaded ON DEMAND when AI works in a module area. Max 4KB each.
63
+ - L1: Structural index. Loaded ON DEMAND when AI works in a module area. Hard limit 4096 raw UTF-8 bytes each.
57
64
  FILE: .prizmkit/prizm-docs/<mirrored-path>.prizm (mirrors source directory structure)
58
- CONTAINS: module responsibility, subdirs with pointers, key files, dependency graph, critical rules summary (1-3 only)
59
- DOES NOT CONTAIN: interface signatures, data flow, TRAPS, DECISIONS (those belong in L2)
65
+ CONTAINS: concise module responsibility, source submodule pointers, semantic detail pointers, key navigation files, dependency summary, critical rules summary (1-3 only)
66
+ DOES NOT CONTAIN: interface signatures, data flow, TRAPS, DECISIONS, full rules, or content already complete in L2
60
67
 
61
- - L2: Behavioral detail. Loaded when AI modifies files in that module OR needs deep understanding. Max 5KB each.
62
- FILE: .prizmkit/prizm-docs/<mirrored-path>/<submodule>.prizm
63
- CONTAINS: interface signatures, data flow, full rules, TRAPS, DECISIONS, domain-specific sections, rejected approaches
68
+ - L2: Behavioral detail. Loaded when AI modifies files in that module OR needs deep understanding. Hard limit 5120 raw UTF-8 bytes each.
69
+ FILE: mirrored source submodule at .prizmkit/prizm-docs/<module>/<submodule>.prizm, or semantic concern at .prizmkit/prizm-docs/<module>/<concern-slug>.prizm for an eligible flat module
70
+ CONTAINS: Value-Gate-qualified public interfaces, data flow, rules, TRAPS, DECISIONS, domain-specific sections, and rejected approaches
71
+ IDENTITY: a real source submodule path takes precedence; a semantic concern remains an L2 document and never adds a level
64
72
 
65
73
  ## 2.2 Directory Layout
66
74
 
@@ -114,6 +122,33 @@ EXAMPLE (Python project):
114
122
  COMMIT: .prizmkit/prizm-docs/ MUST be committed to git alongside source code
115
123
  RATIONALE: .prizmkit/prizm-docs/ is shared project knowledge that all team members (human and AI) benefit from.
116
124
 
125
+ ## 2.4 Capacity Classification and Remediation
126
+
127
+ MEASUREMENT: exact raw UTF-8 bytes; never characters, lines, rounded kilobytes, or locale-dependent encoding
128
+ LEVEL_LIMITS:
129
+ - L0: exact `.prizmkit/prizm-docs/root.prizm` -> 4096B
130
+ - L1: direct `.prizm` child of `.prizmkit/prizm-docs/` -> 4096B
131
+ - L2: nested `.prizm` document -> 5120B, including mirrored and semantic concern details
132
+ BANDS:
133
+ - normal: size * 100 < limit * 80
134
+ - warning: size * 100 >= limit * 80 and size * 100 < limit * 90
135
+ - strong-warning: size * 100 >= limit * 90 and size <= limit
136
+ - error: size > limit
137
+ TARGET_RANGE:
138
+ - L0/L1 automatic remediation: 3277–3686B (80% to below 90%)
139
+ - L2 automatic remediation: 4096–4607B (80% to below 90%)
140
+ - Content naturally below 80% remains normal and is never padded to the target
141
+ ACTION_ORDER:
142
+ 1. trim stale, derivable, procedural, historical, and low-value wording
143
+ 2. deduplicate repeated meanings and merge synonyms
144
+ 3. move child-owned behavior out of L0/L1 to a resolving child pointer
145
+ 4. semantic-split an eligible flat module's unrelated stable concerns into deterministic L2 documents
146
+ PRESERVATION: establish protected critical knowledge before remediation; never remove still-valid contracts, constraints, dependencies, traps, decisions, side effects, or safety/integrity rules merely to reduce bytes
147
+ COMPLETION: after automatic cleanup or split, measure every affected parent and child; each stays within its hard limit and remediation aims for the target range without padding naturally concise output; warning-range targets remain valid and visible; unresolved hard-limit errors fail validation
148
+ REPORT_ORDER: non-normal entries sort by exact descending utilization using integer ratio comparison, then repository-relative path ascending for ties
149
+ REPORT_FIELDS: path, level, current raw bytes, hard limit, utilization band, target range, and actionable trim, deduplicate, move-to-child, or semantic-split guidance
150
+ EXIT: warning and strong-warning diagnostics alone do not fail Validate; hard-limit or format errors fail and cannot be downgraded
151
+
117
152
  ---
118
153
 
119
154
  # SECTION 3: DOCUMENT FORMAT SPECIFICATION
@@ -165,7 +200,7 @@ TEMPLATE:
165
200
  - REJECTED: <rejected approach + why>
166
201
 
167
202
  CONSTRAINTS:
168
- - Max 4KB (roughly 100 lines)
203
+ - Hard limit 4096 raw UTF-8 bytes; project size never raises it
169
204
  - Every line must be a KEY: value pair or a list item
170
205
  - MODULE_INDEX must have arrow pointer (->) for every entry
171
206
  - MODULE_INDEX may list entries at any depth needed for efficient navigation (no hard depth limit)
@@ -173,9 +208,9 @@ CONSTRAINTS:
173
208
  - No prose paragraphs
174
209
  - root.prizm RULES are AUTHORITATIVE: they override any conflicting L1/L2 RULES
175
210
 
176
- ### MODULE_GROUPS (alternative to MODULE_INDEX for projects with 15+ modules)
211
+ ### MODULE_GROUPS (capacity-safe alternative to MODULE_INDEX)
177
212
 
178
- When MODULE_INDEX would exceed 15 entries, replace it with MODULE_GROUPS to stay within the 4KB limit. Group modules by functional domain:
213
+ When MODULE_INDEX cannot retain the required concise module map within the L0 4096B hard limit, replace it with MODULE_GROUPS. More than 15 modules is a mandatory grouping trigger, but measured L0 capacity may require grouping earlier. Group modules by stable functional domain; never raise the L0 limit or add a project-size override:
179
214
 
180
215
  MODULE_GROUPS:
181
216
  <domain-name>:
@@ -186,6 +221,7 @@ When MODULE_INDEX would exceed 15 entries, replace it with MODULE_GROUPS to stay
186
221
 
187
222
  CONSTRAINTS for MODULE_GROUPS:
188
223
  - Exactly ONE of MODULE_INDEX or MODULE_GROUPS must be present in root.prizm (not both)
224
+ - Grouping changes navigation shape only; L0 remains a concise summary/pointer map and the 4096B hard limit is unchanged
189
225
  - Domain names: lowercase, descriptive (e.g., api, frontend, infrastructure, shared, data)
190
226
  - 3-8 domains is the ideal range
191
227
  - Each module appears in exactly one domain
@@ -212,7 +248,11 @@ TEMPLATE:
212
248
  RESPONSIBILITY: <one-line>
213
249
 
214
250
  SUBDIRS:
215
- - <name>/: <one-line description>. -> .prizmkit/prizm-docs/<child-path>.prizm
251
+ - <name>/: <one-line source-submodule summary>. -> .prizmkit/prizm-docs/<child-path>.prizm
252
+
253
+ DETAILS:
254
+ - <concern-slug>: <one-line stable behavior summary> -> .prizmkit/prizm-docs/<module>/<concern-slug>.prizm
255
+ (DETAILS is present only for semantic concern L2 documents in a flat module. SUBDIRS owns real source-submodule pointers.)
216
256
 
217
257
  KEY_FILES:
218
258
  - <filename>: <role/purpose>
@@ -226,13 +266,16 @@ TEMPLATE:
226
266
  - MUST: <1-3 most critical module-specific rules only — full list in L2>
227
267
 
228
268
  CONSTRAINTS:
229
- - Max 4KB
269
+ - Hard limit 4096 raw UTF-8 bytes; project size never raises it
230
270
  - L1 is a STRUCTURAL INDEX — it answers "what exists here" not "how it works"
231
- - DOES NOT CONTAIN: INTERFACES, DATA_FLOW, TRAPS, DECISIONS (those belong in L2)
271
+ - DOES NOT CONTAIN: INTERFACES, DATA_FLOW, TRAPS, DECISIONS, full RULES, or copied L2 behavioral content
232
272
  - RULES: summary only, max 3 entries of the most critical constraints. Full rules in L2.
233
273
  - DEPENDENCIES has 3 sub-categories (imports, imported-by, external)
234
- - SUBDIRS entries must have arrow pointer (->) if child doc exists
235
- - KEY_FILES lists only the most important files (max 10-15)
274
+ - SUBDIRS entries point only to mirrored real source-submodule details; each pointer must resolve
275
+ - DETAILS entries use exactly `- <concern-slug>: <one-line stable behavior summary> -> .prizmkit/prizm-docs/<module>/<concern-slug>.prizm`; each pointer must resolve to one semantic L2 whose MODULE and CONCERN match
276
+ - A real source-submodule path takes precedence over the same semantic slug; ambiguity or collision blocks semantic detail creation
277
+ - KEY_FILES lists only navigation-critical files that pass the Value Gate (max 10-15, often fewer); never use it as a file inventory
278
+ - If a child L2 contains the complete rule, interface, trap, decision, or data flow, L1 keeps only the shortest useful summary and pointer
236
279
  - RULES may only SUPPLEMENT root.prizm RULES with module-specific exceptions, never contradict them
237
280
 
238
281
  TRAPS_FORMAT_REFERENCE (spec-only — do NOT include this block in generated .prizm files):
@@ -245,63 +288,79 @@ TRAPS_FORMAT_REFERENCE (spec-only — do NOT include this block in generated .pr
245
288
 
246
289
  ## 3.3 L2: detail.prizm (Behavioral Detail)
247
290
 
248
- TEMPLATE:
291
+ COMMON_TEMPLATE:
249
292
 
250
- MODULE: <source-path>
251
- FILES: <comma-separated list of all files>
252
- RESPONSIBILITY: <one-line>
293
+ MODULE: <source-submodule path for mirrored detail, or flat parent module path for semantic detail>
294
+ CONCERN: <stable concern identity> | SLUG: <concern-slug>
295
+ (CONCERN is required only for semantic concern details and prohibited on mirrored source-submodule details.)
296
+ FILES: <comma-separated repository-relative source files owned by this detail>
297
+ RESPONSIBILITY: <one-line durable behavior boundary>
253
298
 
254
299
  INTERFACES:
255
- - <function/method signature>: <what it does>
300
+ - <non-obvious public/exported signature or wire contract>: <modification consequence>
256
301
 
257
302
  DATA_FLOW:
258
- - <numbered step describing how data moves through this module>
303
+ - <numbered non-obvious step, side effect, transaction, or cross-boundary flow>
259
304
 
260
305
  <DOMAIN-SPECIFIC SECTIONS>
261
- (AI generates these based on what the module does. Examples below.)
306
+ (AI generates these only when entries pass the Value Gate.)
262
307
 
263
308
  KEY_FILES:
264
- - <filename>: <detailed description, line count, complexity notes>
309
+ - <repository-relative source file>: <why a future modification needs this navigation pointer>
265
310
 
266
311
  DEPENDENCIES:
267
- - uses: <external lib>: <why/how used>
268
- - imports: <internal module>: <which interfaces consumed>
312
+ - uses: <external dependency>: <non-obvious contract or constraint>
313
+ - imports: <internal module>: <consumed public contract or coupling>
269
314
 
270
315
  RULES:
271
316
  - MUST: <module-specific mandatory rule>
272
317
  - NEVER: <module-specific prohibition>
273
318
  - PREFER: <module-specific preference>
274
- (Full rules list — L1 only has a 1-3 item summary of these)
275
319
 
276
320
  TRAPS:
277
- - [CRITICAL|HIGH|LOW] <gotcha: something that looks correct but is wrong or dangerous> | FIX: <correct approach>
278
- - [CRITICAL|HIGH|LOW] <non-obvious coupling, race condition, or side effect> | FIX: <approach>
321
+ - [CRITICAL|HIGH|LOW] <incorrect-looking-safe change or non-obvious side effect> | FIX: <correct approach>
279
322
 
280
323
  DECISIONS:
281
- - <decision made within this module> <rationale>
282
- - REJECTED: <approach that was tried/considered and abandoned + why>
324
+ - <durable decision> <only the rationale needed to preserve it>
325
+ - REJECTED: <alternative future sessions are likely to propose again> — <why it remains rejected>
326
+
327
+ REQUIRED_FIELDS:
328
+ - Mirrored source-submodule L2: MODULE, FILES, RESPONSIBILITY, INTERFACES, KEY_FILES, DEPENDENCIES, TRAPS. DATA_FLOW, RULES, DECISIONS, and domain-specific sections are present only when facts pass the Value Gate, preserving existing mirrored-document compatibility.
329
+ - Semantic concern L2 complete terminal shape: MODULE, CONCERN, FILES, RESPONSIBILITY, INTERFACES, DATA_FLOW, KEY_FILES, DEPENDENCIES, RULES, TRAPS, DECISIONS
330
+ - In a semantic concern L2, if a required behavioral section has no fact that passes the Value Gate, render the section as `<SECTION>: none`; never invent filler to populate it
331
+ - DOMAIN-SPECIFIC sections are optional and contain only Value-Gate-qualified facts
332
+
333
+ SEMANTIC_CONCERN_TERMINAL_SHAPE:
334
+ - Eligibility: a flat source module has multiple stable behavior concerns and required protected knowledge cannot fit one L2 within 5120B after Value/Cleanup filtering
335
+ - Path: `.prizmkit/prizm-docs/<module>/<concern-slug>.prizm`; it is L2, not a new documentation level
336
+ - MODULE: exact flat source module path
337
+ - CONCERN: stable source-evidenced product/domain behavior name plus its deterministic slug
338
+ - FILES: non-empty exhaustive list of repository-relative source files owned by this concern
339
+ - Ownership: sibling semantic concerns have explicit non-overlapping FILES; unclear or overlapping ownership blocks automatic creation
340
+ - Parent: exactly one L1 DETAILS entry using the Section 3.2 grammar resolves to the semantic file; the slug, path, MODULE, and CONCERN must agree
341
+ - Mirrored precedence: if a real source submodule maps to the same path, the mirrored submodule owns it and semantic creation is blocked pending a different unambiguous concern identity
342
+ - Terminal outcomes: write the complete required shape, or report the ambiguity/collision/ownership blocker and required manual decision; never emit a partial semantic file
283
343
 
284
344
  DOMAIN_SPECIFIC_SECTION_EXAMPLES:
285
- - For state machines: STATES, TRIGGERS, TRANSITIONS
345
+ - For state transition logic: STATES, TRIGGERS, TRANSITIONS
286
346
  - For API handlers: ENDPOINTS, REQUEST_FORMAT, RESPONSE_FORMAT, ERROR_CODES
287
347
  - For data stores: TABLES, QUERIES, INDEXES, CACHE_KEYS
288
348
  - For config modules: CONFIG_KEYS, ENV_VARS, DEFAULTS
289
349
  - For UI components: PROPS, EVENTS, SLOTS, STYLES
290
350
 
291
351
  CONSTRAINTS:
292
- - Max 5KB
293
- - L2 is the BEHAVIORAL DETAIL — it answers "how it works, what can go wrong, what was decided"
294
- - INTERFACES: lists only PUBLIC/EXPORTED signatures (moved here from L1 in V4)
295
- - DATA_FLOW: describes how data moves through the module (moved here from L1 in V4)
296
- - RULES: full module-specific rules list (L1 only has a 1-3 item summary)
297
- - DOMAIN-SPECIFIC SECTIONS are flexible, not prescribed
298
- - DECISIONS records durable rationale only; update or remove stale entries in place when code reality changes
299
- - TRAPS section is CRITICAL for preventing AI from making known mistakes
300
- - TRAPS entries MUST have severity prefix ([CRITICAL], [HIGH], or [LOW]). [REVIEW] may precede severity as a temporary staleness marker.
352
+ - Hard limit 5120 raw UTF-8 bytes; project size never raises it
353
+ - L2 is the BEHAVIORAL DETAIL — it answers only non-obvious "how it works, what can go wrong, what was decided" questions that pass the Value Gate
354
+ - INTERFACES lists only non-obvious PUBLIC/EXPORTED or wire contracts; omit source-derivable signatures as `INTERFACES: none`
355
+ - DATA_FLOW records only flows or side effects whose absence could cause an incorrect modification
356
+ - RULES contains the full retained module-specific rules list; L1 has at most a short summary
357
+ - DECISIONS records durable rationale only; keep it current by updating equivalent decisions in place and removing stale ones
358
+ - TRAPS entries MUST have severity prefix ([CRITICAL], [HIGH], or [LOW]); [REVIEW] may precede severity as a temporary staleness marker
301
359
  - TRAPS optional fields: append `| REF: <7-char-hash>` for traceability, `| STALE_IF: <glob>` for auto-expiry detection
302
360
  - TRAPS severity: CRITICAL = data loss/security/financial/crash, HIGH = functional failure/silent error, LOW = naming/minor quality (see TRAPS_FORMAT_REFERENCE in Section 3.2)
303
- - REJECTED entries prevent AI from re-proposing failed approaches
304
- - FILES lists all files, not just key ones
361
+ - REJECTED entries exist only for alternatives likely to recur and include the durable reason
362
+ - FILES is an ownership list, not a low-value repository inventory; mirrored details list files in their source boundary and semantic details list their explicitly owned files
363
+ - KEY_FILES contains only navigation-critical files and never line counts, complexity inventories, or derivable descriptions
305
364
  - RULES may only SUPPLEMENT root.prizm RULES with module-specific exceptions, never contradict them
306
365
 
307
366
  ## 3.4 Metadata Policy
@@ -349,8 +408,40 @@ app/services/ .prizmkit/prizm-docs/app/services.prizm
349
408
  FOR any source file at path P:
350
409
  1. Walk up directory tree to find the first ancestor D where .prizmkit/prizm-docs/<D>.prizm exists
351
410
  2. That file is the L1 doc for this source file
352
- 3. If P is inside a subdirectory S of D, check if .prizmkit/prizm-docs/<D>/<S>.prizm exists for L2
353
- 4. If no .prizm doc found, the module is undocumented (may need retrospective after development or prizmkit-prizm-docs Update for out-of-band repair)
411
+ 3. If P is inside a source subdirectory S of D, check `.prizmkit/prizm-docs/<D>/<S>.prizm` first; mirrored source-submodule identity has precedence
412
+ 4. For a flat module, resolve each L1 DETAILS pointer and select the one semantic L2 whose FILES ownership contains P
413
+ 5. If semantic FILES ownership is absent, overlaps, or disagrees with its parent pointer, report ambiguity instead of guessing
414
+ 6. If no .prizm doc found, the module is undocumented (may need retrospective after development or prizmkit-prizm-docs Update for out-of-band repair)
415
+
416
+ ## 5.4 Deterministic Semantic Concern Identity
417
+
418
+ ELIGIBILITY:
419
+ - The source module is flat: the concern is not already a real source submodule that can use mirrored identity
420
+ - Current source proves multiple stable product/domain behavior boundaries
421
+ - Required protected knowledge cannot fit one 5120B L2 after the Value Gate, Cleanup Gate, deduplication, and concise wording
422
+
423
+ SLUG_ALGORITHM:
424
+ 1. Choose one concise stable product/domain behavior concern name evidenced by current source responsibility; task, feature, bug, session, workflow, branch, temporary initiative, and file-count labels are invalid identities.
425
+ 2. Normalize the identity with Unicode NFKC.
426
+ 3. Apply Unicode lowercase.
427
+ 4. Replace each maximal run of characters that is neither a Unicode letter nor a Unicode decimal digit with one ASCII hyphen.
428
+ 5. Trim leading and trailing hyphens. The result must be non-empty, lowercase kebab-case and map unambiguously to exactly one stable concern.
429
+ 6. Compare the result with every sibling semantic CONCERN slug, sibling DETAILS entry, and mirrored source-submodule path before creating a file.
430
+
431
+ OWNERSHIP_RULES:
432
+ - FILES uses normalized repository-relative source paths and is non-empty.
433
+ - Each owned file belongs to exactly one sibling semantic concern. Do not silently duplicate or overlap ownership.
434
+ - Source files outside the flat module, unclear multi-concern files, unstable behavior boundaries, empty slugs, and one slug mapping to multiple concern meanings require a manual ownership/identity decision.
435
+
436
+ COLLISION_OUTCOME:
437
+ - If normalized identities collide, a semantic slug collides with a mirrored source-submodule path, or concern/FILES ownership is ambiguous, do not create or rename a detail arbitrarily.
438
+ - Report the candidate identities, colliding path or overlapping files, and the manual decision required.
439
+ - Never use task IDs, numeric suffixes (`-2`, `-003`), timestamps, branch names, or silent overlapping documents to resolve the collision.
440
+
441
+ POINTER_RESOLUTION:
442
+ - Semantic path = `.prizmkit/prizm-docs/<module>/<concern-slug>.prizm`.
443
+ - Parent L1 contains exactly one matching DETAILS entry; the target exists; target MODULE equals `<module>`; target CONCERN slug equals `<concern-slug>`; target FILES satisfies ownership rules.
444
+ - A semantic concern remains at L2. Do not create L3, a fourth level, a memory state machine, or a scoring system.
354
445
 
355
446
  ---
356
447
 
@@ -365,6 +456,7 @@ ON_SESSION_START:
365
456
  ON_TASK_RECEIVED:
366
457
  IF task references specific file or directory:
367
458
  LOAD: L1 for the containing module (structural index: files, deps, key rules)
459
+ RESOLVE: a mirrored SUBDIRS pointer first; for a flat module, use the one DETAILS pointer whose semantic L2 FILES ownership contains the source file
368
460
  IF task is broad (e.g., "refactor auth", "improve performance"):
369
461
  LOAD: L1 for all matching modules from MODULE_INDEX
370
462
  IF task is exploratory (e.g., "explain the codebase", "how does X work"):
@@ -399,7 +491,7 @@ BUDGET: Typical task should consume 3000-5000 tokens of prizm docs total
399
491
 
400
492
  ## 6.3 L2 Targeted Loading Protocol
401
493
 
402
- L2 docs can be up to 5KB. Loading them in full defeats the purpose of progressive loading.
494
+ L2 docs can be up to 5120 raw UTF-8 bytes. Loading them in full defeats the purpose of progressive loading.
403
495
  Use targeted grep to extract only the sections relevant to your current task:
404
496
 
405
497
  COMMAND_PATTERN:
@@ -421,13 +513,46 @@ EXAMPLES:
421
513
  WHEN: During normal development, run `/prizmkit-retrospective` before commits when structure, interfaces, dependencies, behavior, or durable project knowledge changed. Use `prizmkit-prizm-docs Update` only for out-of-band repair/resync after docs drifted outside the normal development loop.
422
514
  GOAL: Keep prizm docs synchronized with source code without creating multiple competing docs writers.
423
515
 
424
- ## 7.2 Update Decision Logic
425
-
426
- SUMMARY: For normal development, `/prizmkit-retrospective` gets changed files → maps modules → classifies (A/D/M/R) → updates docs bottom-up (L2→L1→L0) → skips if no structural or durable-knowledge impact → enforces size limits → stages. For out-of-band drift, `prizmkit-prizm-docs Update` runs the same repair shape after confirming the drift source.
516
+ ## 7.2 Value Gate
517
+
518
+ QUESTION: Before retaining a candidate fact, ask `Could a future AI that lacks this fact make an incorrect modification?`
519
+ PASS: yes, and the fact is current, durable, non-obvious, actionable for a future modification, and placed at the lowest owning level
520
+ KEEP:
521
+ - non-obvious public/exported interfaces and wire contracts
522
+ - cross-module constraints and non-obvious dependencies
523
+ - traps, side effects, and failure boundaries
524
+ - durable decisions with necessary rationale
525
+ - rejected alternatives likely to recur, with the reason they remain rejected
526
+ - security, data-integrity, concurrency, transaction, and compatibility rules
527
+ REJECT:
528
+ - structure/signatures directly and safely derivable from source
529
+ - task/change/session history and test inventories
530
+ - temporary investigation conclusions and future plans
531
+ - stale statements, duplicated meanings, and synonyms already represented
532
+ - long procedures, generic advice, low-value file lists, line counts, and complexity inventories
533
+ - behavioral content already complete in a child L2
534
+ APPLIES: Init, Update, Rebuild, and Migrate evaluate every candidate through this same gate
535
+
536
+ ## 7.3 Cleanup Gate
537
+
538
+ TRIGGER: Before Update or Rebuild writes an existing target
539
+ STEPS:
540
+ 1. Read the current target and its parent/child pointers; never use append-only synchronization or delete-first regeneration.
541
+ 2. Verify every current fact against source and build the protected set of still-valid contracts, constraints, dependencies, traps, decisions, side effects, and safety/integrity rules.
542
+ 3. Match candidate and existing facts by semantic meaning. Update one equivalent entry in place and merge synonyms instead of appending alternate wording.
543
+ 4. Remove stale, duplicate, source-derivable, low-value, and parent-copied material.
544
+ 5. Add only genuinely new durable facts that pass the Value Gate and have no equivalent entry.
545
+ 6. Reconcile bottom-up: L2 owns behavior; L1 owns concise structure and SUBDIRS/DETAILS pointers; L0 owns the concise project map.
546
+ 7. Measure raw UTF-8 capacity. If automatic remediation is required, follow Section 2.4 and preserve the protected set.
547
+ BLOCK: If protected knowledge cannot fit after safe movement or an unambiguous semantic split, report the blocker and required manual decision; never delete it for capacity.
548
+
549
+ ## 7.4 Update Decision Logic
550
+
551
+ SUMMARY: For normal development, `/prizmkit-retrospective` gets changed files → maps modules → classifies (A/D/M/R) → applies value-aware bottom-up reconciliation (L2→L1→L0) → skips if no structural or durable-knowledge impact → enforces capacity. For out-of-band drift, `prizmkit-prizm-docs Update` applies the governing Value and Cleanup Gates after confirming the drift source.
427
552
 
428
553
  DETAILED_STEPS: → ${SKILL_DIR}/references/op-update.md
429
554
 
430
- ## 7.3 Auxiliary Metadata Policy
555
+ ## 7.5 Auxiliary Metadata Policy
431
556
 
432
557
  NEVER: Add CHANGELOG sections or changelog.prizm during doc sync.
433
558
  NEVER: Add UPDATED/date/time fields to .prizm files.
@@ -444,6 +569,9 @@ NEVER: Prose paragraphs or explanatory text (use KEY: value or bullet lists)
444
569
  NEVER: Code snippets longer than 1 line (reference file_path:line_number instead)
445
570
  NEVER: Human-readable formatting (emoji, ASCII art, markdown tables, horizontal rules)
446
571
  NEVER: Duplicate information across levels (L0 summarizes, L1 indexes structure, L2 details behavior)
572
+ NEVER: Copy complete L2 interfaces, data flow, TRAPS, DECISIONS, or full RULES into L0/L1; keep a concise parent summary and resolving pointer
573
+ NEVER: Retain a candidate fact that fails the future-incorrect-modification Value Gate
574
+ NEVER: Append synonymous entries instead of updating one semantic meaning in place
447
575
  NEVER: Implementation details or behavioral detail in L0 or L1 (INTERFACES, DATA_FLOW, TRAPS, DECISIONS belong in L2 only)
448
576
  NEVER: Stale information (update or delete, never leave outdated entries)
449
577
  NEVER: Full file contents or large code blocks (summarize purpose and interfaces)
@@ -454,6 +582,10 @@ NEVER: CHANGELOG sections, changelog.prizm, or update-history sections
454
582
  NEVER: Flowcharts, diagrams, mermaid blocks, or ASCII art (wastes tokens, AI cannot parse visually)
455
583
  NEVER: Markdown headers (## / ###) inside .prizm files (use ALL CAPS KEY: format instead)
456
584
  NEVER: Rewrite entire .prizm files on update (modify only affected sections)
585
+ NEVER: Delete still-valid critical knowledge merely to cross a capacity threshold
586
+ NEVER: Raise 4096B/4096B/5120B hard limits for project size or trim only to one byte below a limit when automatic remediation is required
587
+ NEVER: Create task-named, numbered, timestamped, colliding, ambiguous, or silently overlapping semantic concern documents
588
+ NEVER: Add L3, a fourth documentation level, a memory state machine, or a fact scoring system
457
589
  NEVER: TRAPS entries without severity prefix ([CRITICAL], [HIGH], or [LOW])
458
590
 
459
591
  ---
@@ -468,7 +600,7 @@ PRECONDITION: No .prizmkit/prizm-docs/ directory exists (or user confirms overwr
468
600
  INPUT: Project root directory
469
601
  OUTPUT: .prizmkit/prizm-docs/ with root.prizm and L1 docs for discovered modules
470
602
 
471
- SUMMARY: Detect project type → discover modules (MODULE_DISCOVERY_CRITERIA) → create mirrored directory structure → generate root.prizm (L0) generate L1 docs → skip L2 (lazy) → configure hook → validate → report.
603
+ SUMMARY: Detect project type → discover modules (MODULE_DISCOVERY_CRITERIA) → apply Value Gate to every candidate → create mirrored directory structure → generate concise root.prizm (L0) and L1 pointer indexes → skip placeholder L2 (lazy) → configure hook → validate format/capacity/pointers → report.
472
604
 
473
605
  DETAILED_STEPS: → ${SKILL_DIR}/references/op-init.md
474
606
 
@@ -485,7 +617,9 @@ A directory does NOT qualify if ALL of the following are true:
485
617
  - Contains only vendored/third-party code
486
618
  - Is in the EXCLUDE list
487
619
 
488
- HIERARCHY RULE: if directory X lives inside top-level module M, X is a sub-module of M — NOT a separate top-level module.
620
+ HIERARCHY RULE: if directory X lives inside top-level module M, X is a sub-module of M — NOT a separate top-level module. Its durable behavioral detail uses the mirrored L2 path. Semantic concern identity is considered only for a flat module under Section 5.4.
621
+
622
+ CAPACITY RULE: use MODULE_GROUPS whenever MODULE_INDEX cannot fit L0 within 4096B. Do not change hard limits for project size. Init does not create semantic or mirrored L2 placeholders; later Update/Rebuild/Migrate may create complete L2 documents when durable knowledge and unambiguous identity exist.
489
623
 
490
624
  EXCLUDE: .git/, node_modules/, vendor/, build/, dist/, __pycache__/, target/, bin/, .claude/, .codebuddy/, .prizmkit/, .prizmkit/prizm-docs/, dev-pipeline/
491
625
 
@@ -499,8 +633,9 @@ ON_MODIFY trigger:
499
633
  AI reads the relevant L2 sections.
500
634
  ELSE:
501
635
  AI reads the target source files as fallback and proceeds with the modification.
502
- - After the change, `/prizmkit-retrospective` creates L2 if the changed files contain meaningful interfaces, data flow, traps, or decisions worth preserving.
503
- - This keeps initialization lightweight while still capturing L2 depth when real change context exists.
636
+ - After the change, `/prizmkit-retrospective` creates L2 only when candidate interfaces, data flow, traps, or decisions pass the Value Gate.
637
+ - Real source submodules retain mirrored paths. A flat-module semantic detail follows Sections 3.3 and 5.4 and blocks on ambiguous concern identity, slug collision, or overlapping ownership.
638
+ - This keeps initialization lightweight while still capturing L2 depth when real durable context exists.
504
639
 
505
640
  ON_DEEP_READ trigger:
506
641
  - When AI needs to deeply understand a module but not modify it (e.g., code review, architecture analysis, dependency tracing, explaining complex logic):
@@ -9,24 +9,23 @@ STEPS:
9
9
  2. Discover modules using MODULE_DISCOVERY_CRITERIA:
10
10
  - A directory qualifies as a module if it contains source files forming a logical unit, contains entry/config/interface files, contains qualifying sub-modules, or is referenced by multiple modules as a dependency.
11
11
  - TOP-LEVEL modules: directories directly under project root (or under src/ for src-based layouts) that qualify.
12
- - SUB-MODULES: directories INSIDE a top-level module that qualify. Listed in the parent L1 doc's SUBDIRS section.
13
- - HIERARCHY RULE: directory X inside top-level module M maps to .prizmkit/prizm-docs/<M>/<X>.prizm, never to .prizmkit/prizm-docs/<X>.prizm.
12
+ - SUB-MODULES: directories INSIDE a top-level module that qualify. Record them as source structure in the parent L1; if durable L2 is created later, its path mirrors the sub-module.
13
+ - HIERARCHY RULE: directory X inside top-level module M maps to `.prizmkit/prizm-docs/<M>/<X>.prizm`, never to `.prizmkit/prizm-docs/<X>.prizm`.
14
14
  - Exclude .git/, node_modules/, vendor/, build/, dist/, __pycache__/, target/, bin/, .claude/, .codebuddy/, .prizmkit/, .prizmkit/prizm-docs/, dev-pipeline/. If total module count > 30, ask user for include/exclude patterns.
15
- 3. Create .prizmkit/prizm-docs/ directory structure mirroring the source tree exactly. For each top-level module M that has sub-modules, create the subdirectory .prizmkit/prizm-docs/<M>/.
16
- 4. Generate root.prizm (L0) with PROJECT, LANG, FRAMEWORK, BUILD, TEST, ENTRY, MODULE_INDEX with multi-level entries as needed for efficient navigation (constrained by 4KB limit), RULES extracted from user-facing main memory files (AGENTS.md, CLAUDE.md, CODEBUDDY.md), README, and linter configs. Do not extract RULES from AGENTS.private.md, CLAUDE.private.md, or CODEBUDDY.private.md because those files contain PrizmKit framework protocol text. Include PATTERNS and CROSS_CUTTING (cross-module concerns spanning 2+ modules). Set PRIZM_VERSION: 4. Max 4KB. No CHANGELOG sections/files, UPDATED/date metadata, feature/bug/refactor/task/session/run/pipeline/workflow IDs, branch names, absolute worktree paths, or `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths — git tracks history.
17
- - If `.prizmkit/plans/project-brief.md` exists: add `PROJECT_BRIEF: .prizmkit/plans/project-brief.md` to root.prizm (generated by prizmkit-init). If not present, skip prizmkit-init Phase 7 will add it later.
18
- - If module count > 15: use MODULE_GROUPS format instead of MODULE_INDEX — group modules by functional domain (3-8 domains, inferred from directory structure and module responsibilities). See prizm-docs-format.md for MODULE_GROUPS format.
19
- - For each module entry, auto-generate 3-6 keyword tags by scanning the module's key source files for: exported function/class names, imported library names, domain-specific terms in file/directory names. Add tags in square brackets after the module name (e.g., `- auth [login, session, jwt]: ...`). Tags are optional but recommended for projects with 10+ modules.
20
- 5. Generate L1 .prizm files (structural index only) for ALL modules, each at its correct mirrored path:
21
- - Top-level module M → write .prizmkit/prizm-docs/<M>.prizm (include SUBDIRS section with pointers to sub-module docs)
22
- - Sub-module S inside M write .prizmkit/prizm-docs/<M>/<S>.prizm
23
- Each L1 includes MODULE (full relative path), FILES count, RESPONSIBILITY, SUBDIRS with pointers, KEY_FILES (5-10 most important), DEPENDENCIES (imports, imported-by, external), RULES (1-3 most critical only). L1 does NOT include INTERFACES, DATA_FLOW, TRAPS, or DECISIONS (those are L2, generated lazily). Max 4KB each.
24
- 6. Skip L2 docs during init L2 docs are created after real context exists, not as placeholders. During implementation, if relevant L2 is missing, the implementing skill reads target source files as fallback and proceeds. `/prizmkit-retrospective` creates or updates L2 after the change only when durable structure, behavior, dependencies, interfaces, or TRAPS exist. Explicit `/prizmkit-prizm-docs` repair/rebuild may also create L2 when fixing out-of-band doc drift.
25
- 7. Configure UserPromptSubmit hook in platform settings per ${SKILL_DIR}/assets/prizm-docs-format.md Section 11.
26
- 8. Validate all generated docs: size limits (L0 <= 4KB, L1 <= 4KB), pointer resolution (every -> reference resolves), no circular dependencies, KEY: value format compliance, no anti-patterns (prose, code blocks, markdown headers), L1 does not contain INTERFACES/DATA_FLOW/TRAPS/DECISIONS, no CHANGELOG sections/files, no UPDATED/date metadata, no feature/bug/refactor/task/session/run/pipeline/workflow IDs, no branch names, no absolute worktree paths, and no `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths.
27
- 9. Report summary: modules discovered, L1 docs generated, files excluded, warnings.
28
-
29
- OUTPUT: List of generated files, module count, and validation results.
15
+ 3. Apply the Value Gate from SKILL.md and the format specification to every metadata, rule, pattern, dependency, file, and summary candidate. Keep navigational structure only when needed to locate ownership. Reject source-derivable signatures, history, test inventories, temporary conclusions, stale/duplicate meanings, procedures, and low-value file lists.
16
+ 4. Create `.prizmkit/prizm-docs/` and only the mirrored directories needed by documents that will exist. Do not create placeholder detail files.
17
+ 5. Generate `root.prizm` (L0) with concise PROJECT, LANG, FRAMEWORK, BUILD, TEST, ENTRY, navigation pointers, and only Value-Gate-qualified global RULES/PATTERNS/CROSS_CUTTING facts. Set `PRIZM_VERSION: 4`. Keep L0 a summary/pointer map; never copy child interfaces, data flow, traps, decisions, or full rules. No CHANGELOG sections/files, UPDATED/date metadata, feature/bug/refactor/task/session/run/pipeline/workflow IDs, branch names, absolute worktree paths, or `.prizmkit/specs` / `.prizmkit/dev-pipeline` artifact paths.
18
+ - If `.prizmkit/plans/project-brief.md` exists, add `PROJECT_BRIEF: .prizmkit/plans/project-brief.md`; otherwise skip it.
19
+ - Use MODULE_GROUPS whenever MODULE_INDEX cannot fit the required map within 4096B. More than 15 modules is a mandatory grouping trigger. Use 3-8 stable functional domains; never raise the L0 limit for project size.
20
+ - Generate only high-value intent-matching keyword tags; do not copy exported names or imports mechanically when they add no navigation value.
21
+ 6. Generate one direct-child L1 structural index for each discovered top-level source module at `.prizmkit/prizm-docs/<module>.prizm`. Include concise MODULE, FILES navigation summary, RESPONSIBILITY, SUBDIRS, KEY_FILES, DEPENDENCIES, and at most three critical RULES. A SUBDIRS arrow is emitted only when its mirrored L2 exists, so every arrow resolves. Do not include INTERFACES, DATA_FLOW, TRAPS, DECISIONS, full rules, or a low-value file inventory.
22
+ 7. Skip all L2 creation during Init. Init has no behavioral context requiring placeholder mirrored or semantic details. Later `/prizmkit-retrospective`, Update, Rebuild, or Migrate may create a complete L2 only when facts pass the Value Gate. Real source submodules use mirrored identity. Flat-module semantic details use the deterministic CONCERN/FILES/DETAILS contract and block on unstable boundaries, overlapping ownership, empty slugs, or collisions; task-named and numbered shards are prohibited.
23
+ 8. Measure every generated file with the canonical raw UTF-8 capacity classifier: L0/L1 4096B, L2 5120B. Report warning-range files without failing. If a generated L0/L1 reaches 90% or above, clean or reorganize it toward 3277-3686B without deleting protected knowledge. Any unresolved hard-limit error blocks Init.
24
+ 9. Configure UserPromptSubmit hook in platform settings per `${SKILL_DIR}/assets/prizm-docs-format.md` Section 11.
25
+ 10. Validate all generated docs: Value Gate, size/band reporting, pointer resolution, no circular dependencies, KEY: value format, parent-summary boundary, no anti-patterns, and no prohibited metadata. Warning-only capacity results pass; hard-limit or format errors fail.
26
+ 11. Report modules discovered, L1 docs generated, files/categories omitted by the Value Gate, files excluded, capacity diagnostics in descending utilization, and any required manual decisions.
27
+
28
+ OUTPUT: List of generated files, module count, Value-Gate omissions by category, capacity results, and validation results.
30
29
 
31
30
  ## Post-Init Behavior
32
31
 
@@ -35,7 +34,8 @@ After initialization, L2 docs are created only when durable context exists:
35
34
  ON_MODIFY behavior:
36
35
  - When an AI modifies a file in sub-module S within module M and `.prizmkit/prizm-docs/<M>/<S>.prizm` does not exist, the implementation reads the source files in S as fallback context and proceeds.
37
36
  - Do not block implementation only to create a placeholder L2 doc.
38
- - After the change, run `/prizmkit-retrospective` when structure, interfaces, dependencies, behavior, or durable TRAPS changed; retrospective creates or updates L2 then.
37
+ - After the change, run `/prizmkit-retrospective` when structure, interfaces, dependencies, behavior, or durable TRAPS changed; retrospective creates or updates L2 then only for facts that pass the future-incorrect-modification Value Gate.
38
+ - Preserve the mirrored source-submodule path. For a flat module with multiple stable concerns under repeated L2 capacity pressure, use deterministic semantic L2 identity and explicit non-overlapping FILES ownership; block ambiguous creation.
39
39
 
40
40
  ON_DEEP_READ behavior:
41
41
  - When an AI needs deep understanding but L2 is absent, read the relevant source files directly as fallback context.
@@ -5,11 +5,17 @@ Regenerate docs for a specific module from scratch. Requires a module path argum
5
5
  PRECONDITION: .prizmkit/prizm-docs/ exists. Module path is valid.
6
6
 
7
7
  STEPS:
8
- 1. Delete existing L1 and all L2 docs for the specified module.
9
- 2. Re-scan the module directory for files, interfaces, dependencies, subdirectories.
10
- 3. Generate fresh L1 doc with full module analysis.
11
- 4. Generate L2 docs for all sub-modules immediately (unlike init, rebuild generates L2 right away to capture current state).
12
- 5. Update MODULE_INDEX (or MODULE_GROUPS) in root.prizm with new file counts and pointers. Re-evaluate grouping: if total module count > 15 and currently using MODULE_INDEX, convert to MODULE_GROUPS. Regenerate keyword tags for rebuilt modules. **Preserve** any `PROJECT_BRIEF:` line in root.prizm.
13
- 6. Validate regenerated docs against size limits and format rules.
14
-
15
- OUTPUT: Regenerated doc summary with before/after comparison.
8
+ 1. Read the existing module L1, every pointed L2, and the relevant root entry before changing anything. Do not delete first. Snapshot semantic meanings, pointers, paths, and a protected set of still-valid public/wire contracts, cross-module constraints, non-obvious dependencies, traps, decisions with necessary rationale, likely-to-recur rejected alternatives, side effects, and security/data-integrity/concurrency/transaction/compatibility rules.
9
+ 2. Re-scan the current module source for files, public/wire behavior, dependencies, flows, stable concerns, and real source submodules. Treat each observation and each old entry as a candidate under the future-incorrect-modification Value Gate; source-derived, transient, historical, test-inventory, stale, duplicate, procedural, and low-value material is omitted.
10
+ 3. Reconstruct the module map in memory, then apply the Cleanup Gate to each existing target: update equivalent meanings in place, merge synonyms, remove stale/derivable/parent-copied content, and add only genuinely new durable knowledge. Append-only growth and delete-first regeneration are prohibited.
11
+ 4. Reconcile detail identity:
12
+ - real source submodules preserve mirrored `.prizmkit/prizm-docs/<module>/<submodule>.prizm` paths
13
+ - a flat module may gain deterministic semantic `.prizmkit/prizm-docs/<module>/<concern-slug>.prizm` L2 documents only when multiple stable behavior concerns cannot retain protected knowledge in one 5120B L2 after cleanup
14
+ - each semantic L2 has the complete CONCERN terminal shape, explicit non-empty/non-overlapping FILES ownership, and one resolving L1 DETAILS pointer
15
+ - unstable concern boundaries, empty normalized slugs, sibling or mirrored-path collisions, and overlapping ownership block arbitrary creation; report the required manual identity/ownership decision instead of task names or numeric suffixes
16
+ 5. Rewrite the existing L1 as a concise structural summary and pointer index only. Preserve SUBDIRS pointers for real source-submodule L2 and DETAILS pointers for semantic L2. Never copy child interfaces, data flow, traps, decisions, or full rules into L1. Remove an obsolete detail only after all still-valid protected knowledge has been preserved in its current owner and its source/concern identity no longer exists.
17
+ 6. Update only the equivalent root MODULE_INDEX or MODULE_GROUPS entry in place. Preserve concise pointer-only parent behavior, existing project-wide knowledge, and `PROJECT_BRIEF:`. Use MODULE_GROUPS whenever MODULE_INDEX cannot fit within the unchanged 4096B L0 limit; more than 15 modules is a mandatory grouping trigger, not permission for a larger root.
18
+ 7. Measure exact raw UTF-8 bytes using hard limits L0/L1 4096B and L2 5120B. Report warning-range results without failing. For any rewritten target at 90% or above, trim low-value material, deduplicate, move child-owned behavior, or safely semantic-split toward 3277-3686B for L0/L1 or 4096-4607B for L2. Never delete protected knowledge for size; unresolved hard-limit or unsafe-split pressure blocks Rebuild.
19
+ 8. Validate Value/Cleanup compliance, complete semantic fields, FILES ownership, pointer resolution, hierarchy, parent-summary boundaries, capacity, and format. Warning-only results pass; hard-limit or format errors fail.
20
+
21
+ OUTPUT: Rebuilt-document before/after summary listing entries updated in place, merged, removed, added, and protected; sorted capacity diagnostics; semantic identity/ownership decisions; and any blocking ambiguity.
@@ -5,10 +5,17 @@ Check freshness of all .prizm docs.
5
5
  PRECONDITION: .prizmkit/prizm-docs/ exists with root.prizm.
6
6
 
7
7
  STEPS:
8
- 1. Get last git modification time of root.prizm via `git log -1 --format="%ai" -- .prizmkit/prizm-docs/root.prizm`.
8
+ 1. Get the last git modification time of `root.prizm` via `git log -1 --format="%ai" -- .prizmkit/prizm-docs/root.prizm`. If history is unavailable, use filesystem timestamps and report reduced freshness accuracy.
9
9
  2. Count commits since that time via `git log --since="<timestamp>" --oneline | wc -l`.
10
- 3. For each L1/L2 doc, compare git modification time of the .prizm file (`git log -1 --format="%ai" -- <prizm-file>`) against latest git modification of source files in that module (`git log -1 --format="%ai" -- <module-path>/`).
11
- 4. Classify each doc as: FRESH (prizm file updated after latest source change), STALE (source changed more recently than prizm file), MISSING (module exists but no .prizm doc).
12
- 5. Flag any docs exceeding size limits.
10
+ 3. For each L1/L2 document, compare its git modification time with the latest source modification in its mapped module. Resolve real source submodules through SUBDIRS and flat semantic concerns through DETAILS plus their authoritative FILES ownership.
11
+ 4. Classify freshness as FRESH (doc updated after source), STALE (source newer), or MISSING (durable module/concern exists without a document). An absent placeholder with no Value-Gate-qualified knowledge is not MISSING.
12
+ 5. Measure every `.prizm` file from its actual raw UTF-8 bytes and classify the exact path: only `.prizmkit/prizm-docs/root.prizm` is L0 with 4096B; direct children are L1 with 4096B; nested mirrored or semantic documents are L2 with 5120B. Never infer capacity from project size, line count, character count, or filename alone.
13
+ 6. Classify capacity as normal (<80%), warning (80% to <90%), strong-warning (90% through 100%), or error (>100%). Sort every non-normal capacity entry by exact descending utilization using integer ratio comparison, then repository-relative path ascending for ties.
14
+ 7. For each non-normal entry report `DOC_PATH | LEVEL | BYTES | LIMIT | BAND | TARGET_RANGE | ACTIONS`. Target is 3277-3686B for L0/L1 or 4096-4607B for L2. ACTIONS must include concrete level-appropriate trim, deduplicate, move-to-child, and semantic-split guidance consistent with the canonical F-063 classifier.
15
+ 8. Status is read-only. A warning or strong warning is not "oversize" and does not force a split. An error is over the hard limit. Recommend semantic split only for an eligible flat module with multiple stable concerns after Value/Cleanup filtering; otherwise recommend the applicable non-destructive actions or manual decision.
16
+ 9. When inspecting representative or named documents, use their current measured bytes and detected level. Do not special-case paths or repeat stale measurements in guidance.
13
17
 
14
- OUTPUT: Freshness report table with columns: DOC_PATH | LEVEL | STATUS | PRIZM_LAST_MOD | SOURCE_LAST_MOD.
18
+ OUTPUT:
19
+ - Freshness table: `DOC_PATH | LEVEL | STATUS | PRIZM_LAST_MOD | SOURCE_LAST_MOD`.
20
+ - Capacity table: non-normal entries in descending utilization with `DOC_PATH | LEVEL | BYTES | LIMIT | BAND | TARGET_RANGE | ACTIONS`.
21
+ - Summary counts for normal, warning, strong-warning, and error. Status reports errors but does not mutate documents.