prizmkit 1.0.0 → 1.0.1

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 (89) hide show
  1. package/bundled/VERSION.json +5 -0
  2. package/bundled/adapters/claude/agent-adapter.js +108 -0
  3. package/bundled/adapters/claude/command-adapter.js +104 -0
  4. package/bundled/adapters/claude/paths.js +35 -0
  5. package/bundled/adapters/claude/rules-adapter.js +77 -0
  6. package/bundled/adapters/claude/settings-adapter.js +73 -0
  7. package/bundled/adapters/claude/team-adapter.js +183 -0
  8. package/bundled/adapters/codebuddy/agent-adapter.js +43 -0
  9. package/bundled/adapters/codebuddy/paths.js +29 -0
  10. package/bundled/adapters/codebuddy/settings-adapter.js +47 -0
  11. package/bundled/adapters/codebuddy/skill-adapter.js +68 -0
  12. package/bundled/adapters/codebuddy/team-adapter.js +46 -0
  13. package/bundled/adapters/shared/frontmatter.js +77 -0
  14. package/bundled/agents/prizm-dev-team-coordinator.md +142 -0
  15. package/bundled/agents/prizm-dev-team-dev.md +99 -0
  16. package/bundled/agents/prizm-dev-team-pm.md +114 -0
  17. package/bundled/agents/prizm-dev-team-reviewer.md +119 -0
  18. package/bundled/dev-pipeline/README.md +482 -0
  19. package/bundled/dev-pipeline/assets/feature-list-example.json +147 -0
  20. package/bundled/dev-pipeline/assets/prizm-dev-team-integration.md +138 -0
  21. package/bundled/dev-pipeline/launch-bugfix-daemon.sh +425 -0
  22. package/bundled/dev-pipeline/launch-daemon.sh +549 -0
  23. package/bundled/dev-pipeline/reset-feature.sh +209 -0
  24. package/bundled/dev-pipeline/retry-bug.sh +344 -0
  25. package/bundled/dev-pipeline/retry-feature.sh +338 -0
  26. package/bundled/dev-pipeline/run-bugfix.sh +638 -0
  27. package/bundled/dev-pipeline/run.sh +845 -0
  28. package/bundled/dev-pipeline/scripts/check-session-status.py +158 -0
  29. package/bundled/dev-pipeline/scripts/detect-stuck.py +385 -0
  30. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +598 -0
  31. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +402 -0
  32. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +294 -0
  33. package/bundled/dev-pipeline/scripts/init-dev-team.py +134 -0
  34. package/bundled/dev-pipeline/scripts/init-pipeline.py +335 -0
  35. package/bundled/dev-pipeline/scripts/update-bug-status.py +748 -0
  36. package/bundled/dev-pipeline/scripts/update-feature-status.py +1076 -0
  37. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +262 -0
  38. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +159 -0
  39. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +291 -0
  40. package/bundled/dev-pipeline/templates/feature-list-schema.json +112 -0
  41. package/bundled/dev-pipeline/templates/session-status-schema.json +77 -0
  42. package/bundled/skills/_metadata.json +267 -0
  43. package/bundled/skills/app-planner/SKILL.md +580 -0
  44. package/bundled/skills/app-planner/assets/planning-guide.md +313 -0
  45. package/bundled/skills/app-planner/scripts/validate-and-generate.py +758 -0
  46. package/bundled/skills/bug-planner/SKILL.md +235 -0
  47. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +252 -0
  48. package/bundled/skills/dev-pipeline-launcher/SKILL.md +223 -0
  49. package/bundled/skills/prizm-kit/SKILL.md +151 -0
  50. package/bundled/skills/prizm-kit/assets/claude-md-template.md +38 -0
  51. package/bundled/skills/prizm-kit/assets/codebuddy-md-template.md +35 -0
  52. package/bundled/skills/prizm-kit/assets/hooks/prizm-commit-hook.json +15 -0
  53. package/bundled/skills/prizmkit-adr-manager/SKILL.md +68 -0
  54. package/bundled/skills/prizmkit-adr-manager/assets/adr-template.md +26 -0
  55. package/bundled/skills/prizmkit-analyze/SKILL.md +194 -0
  56. package/bundled/skills/prizmkit-api-doc-generator/SKILL.md +56 -0
  57. package/bundled/skills/prizmkit-bug-fix-workflow/SKILL.md +351 -0
  58. package/bundled/skills/prizmkit-bug-reproducer/SKILL.md +62 -0
  59. package/bundled/skills/prizmkit-ci-cd-generator/SKILL.md +54 -0
  60. package/bundled/skills/prizmkit-clarify/SKILL.md +52 -0
  61. package/bundled/skills/prizmkit-code-review/SKILL.md +70 -0
  62. package/bundled/skills/prizmkit-committer/SKILL.md +117 -0
  63. package/bundled/skills/prizmkit-db-migration/SKILL.md +65 -0
  64. package/bundled/skills/prizmkit-dependency-health/SKILL.md +123 -0
  65. package/bundled/skills/prizmkit-deployment-strategy/SKILL.md +58 -0
  66. package/bundled/skills/prizmkit-error-triage/SKILL.md +55 -0
  67. package/bundled/skills/prizmkit-implement/SKILL.md +47 -0
  68. package/bundled/skills/prizmkit-init/SKILL.md +156 -0
  69. package/bundled/skills/prizmkit-log-analyzer/SKILL.md +55 -0
  70. package/bundled/skills/prizmkit-monitoring-setup/SKILL.md +75 -0
  71. package/bundled/skills/prizmkit-onboarding-generator/SKILL.md +70 -0
  72. package/bundled/skills/prizmkit-perf-profiler/SKILL.md +55 -0
  73. package/bundled/skills/prizmkit-plan/SKILL.md +54 -0
  74. package/bundled/skills/prizmkit-plan/assets/plan-template.md +37 -0
  75. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +140 -0
  76. package/bundled/skills/prizmkit-prizm-docs/assets/PRIZM-SPEC.md +943 -0
  77. package/bundled/skills/prizmkit-retrospective/SKILL.md +79 -0
  78. package/bundled/skills/prizmkit-security-audit/SKILL.md +130 -0
  79. package/bundled/skills/prizmkit-specify/SKILL.md +52 -0
  80. package/bundled/skills/prizmkit-specify/assets/spec-template.md +37 -0
  81. package/bundled/skills/prizmkit-summarize/SKILL.md +51 -0
  82. package/bundled/skills/prizmkit-summarize/assets/registry-template.md +18 -0
  83. package/bundled/skills/prizmkit-tasks/SKILL.md +50 -0
  84. package/bundled/skills/prizmkit-tasks/assets/tasks-template.md +21 -0
  85. package/bundled/skills/prizmkit-tech-debt-tracker/SKILL.md +139 -0
  86. package/bundled/team/prizm-dev-team.json +47 -0
  87. package/bundled/templates/claude-md-template.md +38 -0
  88. package/bundled/templates/codebuddy-md-template.md +35 -0
  89. package/package.json +2 -1
@@ -0,0 +1,943 @@
1
+ PRIZM_SPEC_VERSION: 2
2
+ PURPOSE: AI-only documentation framework for vibe coding projects
3
+ AUDIENCE: AI agents (not humans)
4
+ FORMAT: KEY: value pairs, ALL CAPS section headers, arrow pointers
5
+ FILE_EXT: .prizm
6
+ DOC_ROOT: .prizm-docs/
7
+ LICENSE: MIT
8
+
9
+ ---
10
+
11
+ # SECTION 1: OVERVIEW
12
+
13
+ WHAT: Prizm is a self-maintaining documentation system where AI reads, generates, updates, and loads project context progressively.
14
+ WHY: Reduce AI hallucinations, minimize token waste, ensure AI has accurate project knowledge at all times.
15
+ HOW: Three-level progressive loading (L0 -> L1 -> L2) with auto-update before every commit.
16
+
17
+ CORE_PRINCIPLES:
18
+ - Token efficiency over human readability
19
+ - Progressive disclosure (load only what is needed)
20
+ - Self-updating (docs stay fresh via commit-time hooks)
21
+ - Universal (language and framework agnostic)
22
+ - Append-only history (decisions and changelog never lose information)
23
+ - Size-enforced (hard limits per level prevent bloat)
24
+ - Lazy L2 generation (detail docs created on first modification or deep read, not during init)
25
+ - Rules hierarchy (root.prizm RULES are authoritative, module RULES supplement only)
26
+
27
+ ---
28
+
29
+ # SECTION 2: ARCHITECTURE
30
+
31
+ ## 2.1 Progressive Loading Levels
32
+
33
+ LEVELS:
34
+ - L0: Root index. ALWAYS loaded at session start. Max 4KB.
35
+ FILE: .prizm-docs/root.prizm
36
+ CONTAINS: project meta, module index with pointers, build commands, tech stack, top rules
37
+
38
+ - L1: Module index. Loaded ON DEMAND when AI works in a module area. Max 3KB each.
39
+ FILE: .prizm-docs/<mirrored-path>.prizm (mirrors source directory structure)
40
+ CONTAINS: module responsibility, subdirs with pointers, key files, interfaces, dependencies, rules
41
+
42
+ - L2: Detail doc. Loaded when AI modifies files in that sub-module OR needs deep understanding. Max 5KB each.
43
+ FILE: .prizm-docs/<mirrored-path>/<submodule>.prizm
44
+ CONTAINS: full file inventory, domain-specific sections, decisions log, traps, rejected approaches
45
+
46
+ - Changelog: Append-only change log. Loaded at L0. No size limit but keep last 50 entries.
47
+ FILE: .prizm-docs/changelog.prizm
48
+
49
+ ## 2.2 Directory Layout
50
+
51
+ STRUCTURE: Mirrors source tree under .prizm-docs/
52
+
53
+ EXAMPLE (Go project):
54
+ .prizm-docs/
55
+ root.prizm # L0
56
+ changelog.prizm # L0
57
+ internal/
58
+ logic.prizm # L1 for internal/logic/
59
+ model.prizm # L1 for internal/model/
60
+ repo.prizm # L1 for internal/repo/
61
+ service.prizm # L1 for internal/service/
62
+ common.prizm # L1 for internal/common/
63
+ logic/
64
+ statemachine.prizm # L2 for internal/logic/statemachine/
65
+ session.prizm # L2 for internal/logic/session/
66
+ ivr.prizm # L2 for internal/logic/ivr/
67
+ repo/
68
+ rpc.prizm # L2 for internal/repo/rpc/
69
+ store.prizm # L2 for internal/repo/store/
70
+ service/
71
+ http.prizm # L2 for internal/service/http/
72
+ sso.prizm # L2 for internal/service/sso/
73
+
74
+ EXAMPLE (JS/TS project):
75
+ .prizm-docs/
76
+ root.prizm # L0
77
+ changelog.prizm # L0
78
+ src/
79
+ components.prizm # L1 for src/components/
80
+ hooks.prizm # L1 for src/hooks/
81
+ services.prizm # L1 for src/services/
82
+ components/
83
+ auth.prizm # L2 for src/components/auth/
84
+ dashboard.prizm # L2 for src/components/dashboard/
85
+
86
+ EXAMPLE (Python project):
87
+ .prizm-docs/
88
+ root.prizm # L0
89
+ changelog.prizm # L0
90
+ app/
91
+ models.prizm # L1 for app/models/
92
+ views.prizm # L1 for app/views/
93
+ services.prizm # L1 for app/services/
94
+ services/
95
+ payment.prizm # L2 for app/services/payment/
96
+
97
+ ## 2.3 Git Configuration
98
+
99
+ COMMIT: .prizm-docs/ MUST be committed to git alongside source code
100
+ RATIONALE: .prizm-docs/ is shared project knowledge that all team members (human and AI) benefit from.
101
+
102
+ ---
103
+
104
+ # SECTION 3: DOCUMENT FORMAT SPECIFICATION
105
+
106
+ ## 3.1 L0: root.prizm
107
+
108
+ TEMPLATE:
109
+
110
+ PRIZM_VERSION: 2
111
+ PROJECT: <name>
112
+ LANG: <primary language>
113
+ FRAMEWORK: <primary framework or "none">
114
+ BUILD: <build command>
115
+ TEST: <test command>
116
+ ENTRY: <entry point file(s)>
117
+ UPDATED: <YYYY-MM-DD>
118
+
119
+ ARCHITECTURE: <layer1> -> <layer2> -> <layer3> -> ...
120
+ LAYERS:
121
+ - <layer-name>: <one-line description>
122
+
123
+ TECH_STACK:
124
+ - runtime: <list>
125
+ - deps: <key external dependencies>
126
+ - infra: <infrastructure: databases, queues, caches, etc.>
127
+
128
+ MODULE_INDEX:
129
+ - <source-path>: <file-count> files. <one-line description>. -> .prizm-docs/<mirrored-path>.prizm
130
+
131
+ ENTRY_POINTS:
132
+ - <name>: <file-path> (<protocol/port if applicable>)
133
+
134
+ RULES:
135
+ - MUST: <project-wide mandatory rule>
136
+ - NEVER: <project-wide prohibition>
137
+ - PREFER: <project-wide preference>
138
+
139
+ PATTERNS:
140
+ - <pattern-name>: <one-line description of code pattern used across project>
141
+
142
+ DECISIONS:
143
+ - [YYYY-MM-DD] <project-level architectural decision and rationale>
144
+ - REJECTED: <rejected approach + why>
145
+
146
+ CONSTRAINTS:
147
+ - Max 4KB (roughly 100 lines)
148
+ - Every line must be a KEY: value pair or a list item
149
+ - MODULE_INDEX must have arrow pointer (->) for every entry
150
+ - RULES limited to 5-10 most critical conventions
151
+ - No prose paragraphs
152
+ - root.prizm RULES are AUTHORITATIVE: they override any conflicting L1/L2 RULES
153
+
154
+ ## 3.2 L1: module.prizm
155
+
156
+ TEMPLATE:
157
+
158
+ MODULE: <source-path>
159
+ FILES: <count>
160
+ RESPONSIBILITY: <one-line>
161
+ UPDATED: <YYYY-MM-DD>
162
+
163
+ SUBDIRS:
164
+ - <name>/: <one-line description>. -> .prizm-docs/<child-path>.prizm
165
+
166
+ KEY_FILES:
167
+ - <filename>: <role/purpose>
168
+
169
+ INTERFACES:
170
+ - <function/method signature>: <what it does>
171
+
172
+ DEPENDENCIES:
173
+ - imports: <internal modules this module uses>
174
+ - imported-by: <internal modules that depend on this>
175
+ - external: <third-party packages used>
176
+
177
+ RULES:
178
+ - MUST: <module-specific mandatory rule>
179
+ - NEVER: <module-specific prohibition>
180
+ - PREFER: <module-specific preference>
181
+
182
+ DATA_FLOW:
183
+ - <numbered step describing how data moves through this module>
184
+
185
+ CONSTRAINTS:
186
+ - Max 3KB
187
+ - INTERFACES lists only PUBLIC/EXPORTED signatures
188
+ - DEPENDENCIES has 3 sub-categories (imports, imported-by, external)
189
+ - SUBDIRS entries must have arrow pointer (->) if L2 doc exists
190
+ - KEY_FILES lists only the most important files (max 10-15)
191
+ - RULES may only SUPPLEMENT root.prizm RULES with module-specific exceptions, never contradict them
192
+
193
+ ## 3.3 L2: detail.prizm
194
+
195
+ TEMPLATE:
196
+
197
+ MODULE: <source-path>
198
+ FILES: <comma-separated list of all files>
199
+ RESPONSIBILITY: <one-line>
200
+ UPDATED: <YYYY-MM-DD>
201
+
202
+ <DOMAIN-SPECIFIC SECTIONS>
203
+ (AI generates these based on what the module does. Examples below.)
204
+
205
+ KEY_FILES:
206
+ - <filename>: <detailed description, line count, complexity notes>
207
+
208
+ DEPENDENCIES:
209
+ - uses: <external lib>: <why/how used>
210
+ - imports: <internal module>: <which interfaces consumed>
211
+
212
+ DECISIONS:
213
+ - [YYYY-MM-DD] <decision made within this module and rationale>
214
+ - REJECTED: <approach that was tried/considered and abandoned + why>
215
+
216
+ TRAPS:
217
+ - <gotcha: something that looks correct but is wrong or dangerous>
218
+ - <non-obvious coupling, race condition, or side effect>
219
+
220
+ CHANGELOG:
221
+ - YYYY-MM-DD | <verb>: <description of recent change to this module>
222
+
223
+ DOMAIN_SPECIFIC_SECTION_EXAMPLES:
224
+ - For state machines: STATES, TRIGGERS, TRANSITIONS
225
+ - For API handlers: ENDPOINTS, REQUEST_FORMAT, RESPONSE_FORMAT, ERROR_CODES
226
+ - For data stores: TABLES, QUERIES, INDEXES, CACHE_KEYS
227
+ - For config modules: CONFIG_KEYS, ENV_VARS, DEFAULTS
228
+ - For UI components: PROPS, EVENTS, SLOTS, STYLES
229
+
230
+ CONSTRAINTS:
231
+ - Max 5KB
232
+ - DOMAIN-SPECIFIC SECTIONS are flexible, not prescribed
233
+ - DECISIONS is append-only (never delete, archive if >20 entries)
234
+ - TRAPS section is CRITICAL for preventing AI from making known mistakes
235
+ - REJECTED entries prevent AI from re-proposing failed approaches
236
+ - FILES lists all files, not just key ones
237
+ - RULES may only SUPPLEMENT root.prizm RULES with module-specific exceptions, never contradict them
238
+
239
+ ## 3.4 changelog.prizm
240
+
241
+ TEMPLATE:
242
+
243
+ CHANGELOG:
244
+ - YYYY-MM-DD | <module-path> | <verb>: <one-line description>
245
+
246
+ VERBS: add, update, fix, remove, refactor, rename, deprecate
247
+ RETENTION: Keep last 50 entries. Archive older entries to changelog-archive.prizm if needed.
248
+
249
+ EXAMPLE:
250
+ CHANGELOG:
251
+ - 2026-03-02 | internal/logic/timer | add: retry logic with exponential backoff
252
+ - 2026-03-01 | internal/service/sso | update: create_robot handler validates chatbot config
253
+ - 2026-02-28 | internal/model/chatbot | add: DeepSeek provider model definition
254
+ - 2026-02-27 | internal/repo/rpc | fix: Hunyuan API timeout not respected
255
+
256
+ ---
257
+
258
+ # SECTION 4: FORMAT CONVENTIONS
259
+
260
+ HEADERS: ALL CAPS followed by colon (MODULE:, FILES:, RESPONSIBILITY:, etc.)
261
+ VALUES: Single space after colon, value on same line (KEY: value)
262
+ LISTS: Dash-space prefix for items within a section (- item)
263
+ POINTERS: Arrow notation (->) to reference other .prizm files
264
+ DATES: [YYYY-MM-DD] in square brackets for timestamps
265
+ CHANGELOG_SEPARATOR: Pipe (|) between date, module, and description
266
+ NESTING: Indent 2 spaces for sub-keys within a section
267
+ COMMENTS: None. Every line carries information. No comments in .prizm files.
268
+
269
+ ---
270
+
271
+ # SECTION 5: PATH MAPPING RULES
272
+
273
+ ## 5.1 Mapping Algorithm
274
+
275
+ RULE: Mirror the source directory tree under .prizm-docs/
276
+ RULE: L1 file for directory D = .prizm-docs/<D>.prizm
277
+ RULE: L2 file for subdirectory D/S = .prizm-docs/<D>/<S>.prizm
278
+ RULE: Root index = .prizm-docs/root.prizm (always)
279
+ RULE: Changelog = .prizm-docs/changelog.prizm (always)
280
+
281
+ ## 5.2 Examples
282
+
283
+ SOURCE_PATH L1_PRIZM_FILE L2_PRIZM_FILES
284
+ internal/logic/ .prizm-docs/internal/logic.prizm .prizm-docs/internal/logic/*.prizm
285
+ internal/logic/session/ (described in L1 logic.prizm SUBDIRS) .prizm-docs/internal/logic/session.prizm
286
+ internal/repo/store/ (described in L1 repo.prizm SUBDIRS) .prizm-docs/internal/repo/store.prizm
287
+ src/components/ .prizm-docs/src/components.prizm .prizm-docs/src/components/*.prizm
288
+ src/components/auth/ (described in L1 components.prizm) .prizm-docs/src/components/auth.prizm
289
+ app/services/ .prizm-docs/app/services.prizm .prizm-docs/app/services/*.prizm
290
+
291
+ ## 5.3 Discovery Rule
292
+
293
+ FOR any source file at path P:
294
+ 1. Walk up directory tree to find the first ancestor D where .prizm-docs/<D>.prizm exists
295
+ 2. That file is the L1 doc for this source file
296
+ 3. If P is inside a subdirectory S of D, check if .prizm-docs/<D>/<S>.prizm exists for L2
297
+ 4. If no .prizm doc found, the module is undocumented (may need prizmkit.doc.update)
298
+
299
+ ---
300
+
301
+ # SECTION 6: PROGRESSIVE LOADING PROTOCOL
302
+
303
+ ## 6.1 When to Load
304
+
305
+ ON_SESSION_START:
306
+ ALWAYS: Read .prizm-docs/root.prizm (L0) if it exists
307
+ PURPOSE: Get the project map, understand architecture, know where to look
308
+
309
+ ON_TASK_RECEIVED:
310
+ IF task references specific file or directory:
311
+ LOAD: L1 for the containing module
312
+ IF task is broad (e.g., "refactor auth", "improve performance"):
313
+ LOAD: L1 for all matching modules from MODULE_INDEX
314
+ IF task is exploratory (e.g., "explain the codebase", "how does X work"):
315
+ LOAD: L0 only, then navigate via pointers as needed
316
+ IF task is cross-cutting (e.g., "add logging everywhere"):
317
+ LOAD: L1 for affected modules, check DEPENDENCIES.imported-by
318
+
319
+ ON_FILE_MODIFICATION:
320
+ BEFORE editing any source file:
321
+ LOAD: L2 for the containing sub-module (if exists and not already loaded)
322
+ READ: TRAPS section (prevent known mistakes)
323
+ READ: DECISIONS section (understand prior choices)
324
+ READ: REJECTED entries (avoid re-proposing failed approaches)
325
+
326
+ ON_DEEP_READ:
327
+ WHEN AI needs deep understanding of a module WITHOUT modifying it:
328
+ LOAD: L2 for the containing sub-module (if exists)
329
+ IF L2 does not exist: GENERATE L2 from source code analysis, then load it
330
+ USE_CASES: code review, architecture analysis, dependency tracing, explaining complex logic
331
+ RATIONALE: Deep reads benefit from the same structured context as modifications
332
+
333
+ ## 6.2 Loading Rules
334
+
335
+ NEVER: Load all L1 and L2 docs at session start (defeats progressive loading)
336
+ NEVER: Load L2 for modules not being modified or deeply analyzed (wastes context window)
337
+ NEVER: Skip L0 (it is the map for everything else)
338
+ PREFER: Load L1 before L2 (understand module context before diving into details)
339
+ PREFER: Load minimum docs needed for the task
340
+ BUDGET: Typical task should consume 3000-5000 tokens of prizm docs total
341
+
342
+ ---
343
+
344
+ # SECTION 7: AUTO-UPDATE PROTOCOL
345
+
346
+ ## 7.1 Trigger
347
+
348
+ WHEN: Before every commit (detected automatically via hook, or manually via prizmkit.doc.update)
349
+ GOAL: Keep prizm docs synchronized with source code
350
+
351
+ ## 7.2 Update Decision Logic
352
+
353
+ ALGORITHM: prizm_update
354
+
355
+ 1. GET_CHANGES:
356
+ Run: git diff --cached --name-status
357
+ If nothing staged: Run: git diff --name-status
358
+ Result: List of (status, file_path) pairs
359
+
360
+ 2. MAP_TO_MODULES:
361
+ FOR EACH changed file:
362
+ Find its module by matching against MODULE_INDEX in root.prizm
363
+ Group changes by module
364
+
365
+ 3. CLASSIFY_CHANGES:
366
+ FOR EACH changed file:
367
+ A (added): May need new entries in KEY_FILES, INTERFACES
368
+ D (deleted): Remove from KEY_FILES, update FILES count
369
+ M (modified): Check if public interfaces or dependencies changed
370
+ R (renamed): Update all path references in affected docs
371
+
372
+ 4. UPDATE_DOCS:
373
+ FOR EACH affected module:
374
+ a. IF L2 doc exists for this module:
375
+ UPDATE: KEY_FILES (add/remove/modify)
376
+ UPDATE: INTERFACES (if signatures changed)
377
+ UPDATE: DEPENDENCIES (if imports changed)
378
+ APPEND: CHANGELOG entry
379
+ UPDATE: UPDATED timestamp
380
+ b. IF L1 doc exists:
381
+ UPDATE: FILES count
382
+ UPDATE: KEY_FILES (if major files added/removed)
383
+ UPDATE: INTERFACES (if public API changed)
384
+ UPDATE: DEPENDENCIES (if module-level deps changed)
385
+ UPDATE: UPDATED timestamp
386
+ c. UPDATE root.prizm (L0):
387
+ UPDATE: MODULE_INDEX file counts
388
+ ONLY IF: module added, removed, or project-wide structural change
389
+ UPDATE: UPDATED timestamp
390
+
391
+ 5. SKIP_CONDITIONS:
392
+ SKIP if: Only internal implementation changed (no interface/dependency change)
393
+ SKIP if: Only comments, whitespace, or formatting changed
394
+ SKIP if: Only test files changed (unless test patterns doc exists)
395
+ SKIP if: Only .prizm files changed (avoid circular updates)
396
+
397
+ 6. CREATE_NEW_DOCS:
398
+ IF new directory with 3+ source files appears AND matches no existing module:
399
+ CREATE: L1 doc immediately
400
+ ADD: entry to MODULE_INDEX in root.prizm
401
+ DEFER: L2 creation to first modification or deep read
402
+
403
+ 7. SIZE_ENFORCEMENT:
404
+ AFTER each update, check file sizes:
405
+ L0 > 4KB: Consolidate MODULE_INDEX entries, remove lowest-value RULES
406
+ L1 > 3KB: Move implementation details to L2, keep only signatures in INTERFACES
407
+ L2 > 5KB: Split into sub-module docs or archive old CHANGELOG entries
408
+
409
+ 8. STAGE_DOCS:
410
+ Run: git add .prizm-docs/
411
+ (Prizm docs are committed alongside source code changes)
412
+
413
+ ## 7.3 Changelog Update
414
+
415
+ ALWAYS append to .prizm-docs/changelog.prizm after any doc update.
416
+ FORMAT: - YYYY-MM-DD | <module-path> | <verb>: <one-line description>
417
+ VERBS: add, update, fix, remove, refactor, rename, deprecate
418
+
419
+ ---
420
+
421
+ # SECTION 8: ANTI-PATTERNS
422
+
423
+ WHAT_NOT_TO_PUT_IN_PRIZM_DOCS:
424
+
425
+ NEVER: Prose paragraphs or explanatory text (use KEY: value or bullet lists)
426
+ NEVER: Code snippets longer than 1 line (reference file_path:line_number instead)
427
+ NEVER: Human-readable formatting (emoji, ASCII art, markdown tables, horizontal rules)
428
+ NEVER: Duplicate information across levels (L0 summarizes, L1 details, L2 deep-dives)
429
+ NEVER: Implementation details in L0 or L1 (those belong in L2 only)
430
+ NEVER: Stale information (update or delete, never leave outdated entries)
431
+ NEVER: Full file contents or large code blocks (summarize purpose and interfaces)
432
+ NEVER: TODO items or future plans (those belong in issue trackers)
433
+ NEVER: Session-specific context or conversation history (docs are session-independent)
434
+ NEVER: Flowcharts, diagrams, mermaid blocks, or ASCII art (wastes tokens, AI cannot parse visually)
435
+ NEVER: Markdown headers (## / ###) inside .prizm files (use ALL CAPS KEY: format instead)
436
+ NEVER: Rewrite entire .prizm files on update (modify only affected sections)
437
+
438
+ ---
439
+
440
+ # SECTION 9: INITIALIZATION PROCEDURE
441
+
442
+ ## 9.1 Algorithm
443
+
444
+ COMMAND: prizmkit.doc.init
445
+ PRECONDITION: No .prizm-docs/ directory exists (or user confirms overwrite)
446
+
447
+ ALGORITHM: prizm_init
448
+
449
+ INPUT: Project root directory
450
+ OUTPUT: .prizm-docs/ with root.prizm, changelog.prizm, and L1 docs for discovered modules
451
+
452
+ STEPS:
453
+
454
+ 1. DETECT_PROJECT:
455
+ SCAN project root for build system files:
456
+ - go.mod -> Go
457
+ - package.json -> JavaScript/TypeScript
458
+ - requirements.txt, pyproject.toml, setup.py -> Python
459
+ - Cargo.toml -> Rust
460
+ - pom.xml, build.gradle -> Java
461
+ - *.csproj, *.sln -> C#
462
+ IDENTIFY: primary language, framework, build command, test command
463
+ FIND: entry points by convention:
464
+ - Go: main.go, cmd/*/main.go
465
+ - JS/TS: package.json "main"/"bin", index.ts, index.js
466
+ - Python: __main__.py, manage.py, app.py
467
+ - Rust: main.rs, lib.rs
468
+ - Java: *Application.java, Main.java
469
+
470
+ 2. DISCOVER_MODULES:
471
+ SCAN source directories:
472
+ - Find directories containing 3+ source files of the primary language
473
+ - Recognize common patterns: controllers/, services/, models/, components/, hooks/, utils/, lib/, pkg/, internal/, cmd/, api/, routes/, middleware/
474
+ - Each qualifying directory = one module candidate
475
+ - EXCLUDE: vendor/, node_modules/, .git/, build/, dist/, __pycache__/, target/, bin/
476
+ IF module count > 30: ASK user for include/exclude patterns
477
+
478
+ 3. CREATE_DIRECTORY_STRUCTURE:
479
+ Create .prizm-docs/ directory
480
+ Create subdirectories mirroring source module tree
481
+
482
+ 4. GENERATE_ROOT (L0):
483
+ Fill: PROJECT, LANG, FRAMEWORK, BUILD, TEST, ENTRY from step 1
484
+ Build: MODULE_INDEX from step 2 (one entry per module with file count and pointer)
485
+ Extract: RULES from existing CODEBUDDY.md, README, .editorconfig, linter configs
486
+ Extract: PATTERNS from common code patterns observed in step 2
487
+ Set: PRIZM_VERSION: 2, UPDATED: today's date
488
+
489
+ 5. GENERATE_L1_DOCS:
490
+ FOR EACH module in MODULE_INDEX:
491
+ SCAN module directory:
492
+ - Count all source files
493
+ - Identify exported/public interfaces (language-specific: exported funcs in Go, export in JS/TS, public in Java, pub in Rust)
494
+ - Trace import/require/use statements for DEPENDENCIES
495
+ - Identify subdirectories for SUBDIRS
496
+ - Identify 5-10 most important files for KEY_FILES
497
+ WRITE: .prizm-docs/<mirrored-path>.prizm
498
+
499
+ 6. SKIP_L2:
500
+ DO NOT generate L2 docs during initialization.
501
+ RATIONALE: L2 requires deep code understanding. Generating shallow L2 docs during init would produce misleading content and create false confidence. L2 docs are generated lazily when AI first modifies files in a sub-module or performs a deep read (ON_DEEP_READ trigger).
502
+
503
+ 7. CREATE_CHANGELOG:
504
+ Write .prizm-docs/changelog.prizm with single entry:
505
+ - YYYY-MM-DD | root | add: initialized prizm documentation framework
506
+
507
+ 8. VALIDATE:
508
+ CHECK: All generated files are within size limits (L0 <= 4KB, L1 <= 3KB)
509
+ CHECK: Every MODULE_INDEX pointer resolves to an existing .prizm file
510
+ CHECK: No circular dependencies in DEPENDENCIES sections
511
+ CHECK: UPDATED timestamps are set on all files
512
+ CHECK: KEY: value format compliance (no prose, no code blocks, no markdown headers)
513
+ CHECK: No anti-patterns per Section 8
514
+
515
+ 9. CONFIGURE_HOOK:
516
+ Add UserPromptSubmit hook to .codebuddy/settings.json (see Section 11)
517
+
518
+ 10. UPDATE_CODEBUDDY_MD:
519
+ Append Prizm protocol section to CODEBUDDY.md (see Section 12)
520
+
521
+ 11. REPORT:
522
+ Output summary: modules discovered, L1 docs generated, files excluded, warnings
523
+
524
+ ## 9.2 Post-Init Behavior
525
+
526
+ After initialization, L2 docs are created incrementally:
527
+
528
+ ON_MODIFY trigger:
529
+ - First time AI modifies a file in sub-module S within module M:
530
+ IF .prizm-docs/<M>/<S>.prizm does not exist:
531
+ AI reads the source files in S, generates L2 doc, then proceeds with modification
532
+ - This ensures L2 docs have real depth, written when AI has actual context
533
+
534
+ ON_DEEP_READ trigger:
535
+ - When AI needs to deeply understand a module but not modify it (e.g., code review, architecture analysis, dependency tracing, explaining complex logic):
536
+ IF .prizm-docs/<M>/<S>.prizm does not exist:
537
+ AI reads the source files in S, generates L2 doc for future reference
538
+ - This ensures L2 docs are available for read-heavy analysis tasks, not just modifications
539
+ - RATIONALE: Some tasks require deep understanding without editing (reviewing PRs, answering architecture questions, tracing bugs). Generating L2 during these tasks captures valuable context.
540
+
541
+ ---
542
+
543
+ # SECTION 10: SKILL DEFINITION
544
+
545
+ ## 10.1 SKILL.md Reference
546
+
547
+ The Prizm skill is defined at: ${SKILL_DIR}/SKILL.md
548
+
549
+ COMMANDS:
550
+
551
+ prizmkit.doc.init - Bootstrap .prizm-docs/ for a new project (Section 9)
552
+ prizmkit.doc.update - Sync docs with code changes (Section 7)
553
+ prizmkit.doc.status - Check freshness of all docs
554
+ prizmkit.doc.rebuild - Regenerate docs for a specific module
555
+ prizmkit.doc.validate - Check format compliance and consistency (Section 10.2)
556
+ prizmkit.doc.migrate - Convert existing docs to .prizm-docs/ format (Section 10.3)
557
+
558
+ ## 10.2 prizmkit.doc.validate
559
+
560
+ COMMAND: prizmkit.doc.validate
561
+ PRECONDITION: .prizm-docs/ directory exists
562
+
563
+ ALGORITHM: prizm_validate
564
+
565
+ STEPS:
566
+
567
+ 1. FORMAT_CHECK:
568
+ FOR EACH .prizm file:
569
+ VERIFY: All content uses KEY: value format or dash-prefixed list items
570
+ FLAG: Prose paragraphs (lines without KEY: prefix or - prefix)
571
+ FLAG: Code blocks (``` markers)
572
+ FLAG: Markdown headers (## / ### markers)
573
+ FLAG: Emoji, ASCII art, horizontal rules
574
+ FLAG: Markdown tables
575
+
576
+ 2. SIZE_CHECK:
577
+ VERIFY: root.prizm <= 4KB
578
+ VERIFY: All L1 files <= 3KB
579
+ VERIFY: All L2 files <= 5KB
580
+ REPORT: Files exceeding limits with current size and limit
581
+
582
+ 3. POINTER_CHECK:
583
+ FOR EACH arrow pointer (->) in all .prizm files:
584
+ VERIFY: Target file exists on disk
585
+ REPORT: Broken pointers with source file, line, and missing target
586
+
587
+ 4. TIMESTAMP_CHECK:
588
+ FOR EACH .prizm file:
589
+ VERIFY: UPDATED field exists
590
+ FLAG: Docs with UPDATED older than 30 days as potentially stale
591
+ COMPARE: UPDATED against git log for corresponding source directory
592
+
593
+ 5. COMPLETENESS_CHECK:
594
+ root.prizm MUST have: PRIZM_VERSION, PROJECT, LANG, MODULE_INDEX, RULES
595
+ L1 docs MUST have: MODULE, FILES, RESPONSIBILITY, INTERFACES, DEPENDENCIES
596
+ L2 docs MUST have: MODULE, FILES, KEY_FILES, DEPENDENCIES, TRAPS
597
+ REPORT: Missing required fields per file
598
+
599
+ 6. ANTI_PATTERN_CHECK:
600
+ FLAG: Duplicate information across levels (same content in L0 and L1)
601
+ FLAG: Implementation details in L0 or L1 (belong in L2 only)
602
+ FLAG: TODO items or future plans in any .prizm file
603
+ FLAG: Session-specific context or conversation history
604
+
605
+ 7. RULES_HIERARCHY_CHECK:
606
+ EXTRACT: RULES from root.prizm (authoritative)
607
+ FOR EACH L1/L2 doc with RULES section:
608
+ CHECK: No contradiction with root.prizm RULES
609
+ VERIFY: L1/L2 RULES only add module-specific exceptions
610
+ FLAG: Direct contradictions with root.prizm RULES
611
+
612
+ OUTPUT: Validation report with PASS/FAIL per check category, issue list with file paths and line references, suggested fixes for common problems.
613
+
614
+ ## 10.3 prizmkit.doc.migrate
615
+
616
+ COMMAND: prizmkit.doc.migrate
617
+ PRECONDITION: Existing documentation (docs/, docs/AI_CONTEXT/, README.md, ARCHITECTURE.md, etc.). No .prizm-docs/ directory (or user confirms overwrite).
618
+
619
+ ALGORITHM: prizm_migrate
620
+
621
+ STEPS:
622
+
623
+ 1. DISCOVER_EXISTING_DOCS:
624
+ SCAN for: docs/, docs/AI_CONTEXT/, README.md, ARCHITECTURE.md, CONTRIBUTING.md, API docs
625
+ CATALOG: List all found documentation files with sizes and types
626
+
627
+ 2. EXTRACT_INFORMATION:
628
+ FROM each doc, extract:
629
+ - Project metadata (name, language, framework, build/test commands)
630
+ - Module descriptions and responsibilities
631
+ - Architecture patterns and layers
632
+ - Rules, conventions, and constraints
633
+ - Decisions and their rationale
634
+ - Dependencies and relationships
635
+ - Known issues and traps
636
+
637
+ 3. MAP_TO_PRIZM_LEVELS:
638
+ Project-wide info -> root.prizm (L0): PROJECT, LANG, FRAMEWORK, RULES, PATTERNS, DECISIONS
639
+ Module-level info -> L1 docs: MODULE, RESPONSIBILITY, INTERFACES, DEPENDENCIES
640
+ Detailed module info -> L2 docs: KEY_FILES, TRAPS, domain-specific sections, DECISIONS
641
+
642
+ 4. CONVERT_FORMAT:
643
+ Strip markdown formatting (headers, tables, horizontal rules, emphasis)
644
+ Convert prose to KEY: value pairs
645
+ Convert lists to dash-prefixed items
646
+ Convert code blocks to file_path:line_number references
647
+ Condense multi-sentence explanations to single-line values
648
+
649
+ 5. GENERATE_PRIZM_DOCS:
650
+ Follow standard init procedure (Section 9) but seed with extracted information
651
+ Merge source-code-scanned data with documentation-extracted data
652
+ Prefer documentation-extracted RULES and DECISIONS (they capture rationale)
653
+ Prefer source-code-scanned INTERFACES and DEPENDENCIES (they are current)
654
+
655
+ 6. VALIDATE:
656
+ Run full validation per Section 10.2
657
+ Flag any content that could not be automatically converted
658
+
659
+ 7. REPORT:
660
+ Output: Source files processed, .prizm files generated, content successfully migrated, content requiring manual review, warnings
661
+
662
+ ---
663
+
664
+ # SECTION 11: HOOK CONFIGURATION
665
+
666
+ ## 11.1 Mechanism
667
+
668
+ HOOK_TYPE: prompt (LLM-evaluated, not script-based)
669
+ EVENT: UserPromptSubmit
670
+ BEHAVIOR: Detects commit intent in user prompt, injects doc update reminder
671
+ ALWAYS_RETURNS: ok: true (never blocks the user prompt)
672
+ INJECTION: When commit intent detected, "reason" field carries update instructions that AI sees as additional context
673
+
674
+ ## 11.2 Configuration Template
675
+
676
+ Place in: .codebuddy/settings.json (project-level)
677
+
678
+ JSON:
679
+ {
680
+ "hooks": {
681
+ "UserPromptSubmit": [
682
+ {
683
+ "hooks": [
684
+ {
685
+ "type": "prompt",
686
+ "prompt": "You are a commit-intent detector for the Prizm documentation framework. Analyze the user prompt and determine if the user intends to COMMIT, PUSH, FINISH, SHIP, MERGE, or create a PULL REQUEST.\n\nUser prompt: $ARGUMENTS\n\nIF commit intent detected, respond with:\n{\"ok\": true, \"reason\": \"PRIZM_UPDATE_REQUIRED: Before committing, you MUST update .prizm-docs/. Steps: 1) Run git diff --cached --name-status. 2) Map changed files to modules via root.prizm MODULE_INDEX. 3) Read and update affected .prizm files (only changed sections). 4) Append to changelog.prizm. 5) Stage .prizm files. 6) Then commit. RULES: Never rewrite entire files. Never add prose. Only update affected sections.\"}\n\nIF no commit intent, respond with:\n{\"ok\": true}\n\nJSON only.",
687
+ "timeout": 10
688
+ }
689
+ ]
690
+ }
691
+ ]
692
+ }
693
+ }
694
+
695
+ ## 11.3 How It Works
696
+
697
+ FLOW:
698
+ 1. User types prompt (e.g., "commit these changes" or "push to main")
699
+ 2. UserPromptSubmit hook fires before AI processes the prompt
700
+ 3. Fast LLM (Haiku) evaluates the prompt against commit-intent keywords
701
+ 4. IF commit intent: Returns {ok: true, reason: "PRIZM_UPDATE_REQUIRED: ..."}
702
+ - The "reason" content is injected into AI's context as additional instructions
703
+ - AI sees the update instructions and executes them before committing
704
+ 5. IF no commit intent: Returns {ok: true} with no reason
705
+ - AI proceeds normally, no extra context injected
706
+
707
+ KEYWORDS_DETECTED: commit, push, finish, done, ship, merge, PR, pull request, /commit, save changes
708
+
709
+ ## 11.4 Adapting for Other AI Tools
710
+
711
+ The hook configuration above is specific to CodeBuddy Code.
712
+ For other AI coding assistants:
713
+ - Cursor: Use .cursorrules file to add the auto-update protocol as a rule
714
+ - Aider: Use .aider.conf.yml conventions section
715
+ - Continue: Use .continue/config.json customInstructions
716
+ - Generic: Add the auto-update protocol text to whatever system prompt or rules file the tool supports
717
+
718
+ The core requirement is: before any commit operation, AI must update affected .prizm-docs/ files.
719
+
720
+ ---
721
+
722
+ # SECTION 12: CODEBUDDY.MD TEMPLATE
723
+
724
+ ## 12.1 Template Section
725
+
726
+ Append the following to any project's CODEBUDDY.md during prizmkit.doc.init:
727
+
728
+ TEXT:
729
+
730
+ ## Prizm Documentation Framework
731
+
732
+ This project uses Prizm for AI-optimized, progressive context loading.
733
+ Full specification: ${SKILL_DIR}/assets/PRIZM-SPEC.md
734
+
735
+ ### Progressive Loading Protocol
736
+ - ON SESSION START: Always read .prizm-docs/root.prizm first
737
+ - ON TASK: Read L1 (.prizm-docs/<module>.prizm) for relevant modules referenced in MODULE_INDEX
738
+ - ON FILE EDIT: Read L2 (.prizm-docs/<module>/<submodule>.prizm) before modifying files. Pay attention to TRAPS and DECISIONS.
739
+ - ON DEEP READ: If you need deep understanding of a module without modifying it, generate L2 if it does not exist.
740
+ - NEVER load all .prizm docs at once. Load only what is needed for the current task.
741
+
742
+ ### Auto-Update Protocol
743
+ - BEFORE EVERY COMMIT: Update affected .prizm-docs/ files per PRIZM-SPEC.md Section 7
744
+ - The UserPromptSubmit hook will remind you automatically
745
+ - If hook is not active, you MUST still follow the update protocol manually
746
+
747
+ ### Doc Format Rules
748
+ - All .prizm files use KEY: value format, not prose
749
+ - Size limits: L0 = 4KB, L1 = 3KB, L2 = 5KB
750
+ - Arrow notation (->) indicates load pointers to other .prizm docs
751
+ - DECISIONS and CHANGELOG are append-only (never delete entries)
752
+
753
+ ### RULES Hierarchy
754
+ - root.prizm RULES are authoritative and apply project-wide
755
+ - L1/L2 RULES only supplement with module-specific exceptions
756
+ - If L1/L2 contradict root.prizm, root.prizm takes precedence
757
+
758
+ ### Creating New L2 Docs
759
+ - When you first modify files in a sub-module that has no L2 doc:
760
+ 1. Read the source files in that sub-module
761
+ 2. Generate a new L2 .prizm file following PRIZM-SPEC.md Section 3.3
762
+ 3. Add a pointer in the parent L1 doc's SUBDIRS section
763
+ - Also generate L2 when performing deep read analysis of undocumented sub-modules
764
+
765
+ ---
766
+
767
+ # SECTION 13: LANGUAGE-SPECIFIC INITIALIZATION HINTS
768
+
769
+ ## 13.1 Module Boundary Detection
770
+
771
+ LANGUAGE MODULE_BOUNDARY ENTRY_POINT_DETECTION
772
+ Go Directories with .go files main.go, cmd/**/main.go
773
+ JavaScript/TS Directories with index.ts/js/tsx/jsx package.json main/bin
774
+ Python Directories with __init__.py __main__.py, manage.py, app.py, wsgi.py
775
+ Rust Directories with mod.rs main.rs, lib.rs
776
+ Java src/main/java/* package directories *Application.java, Main.java
777
+ C# Directories with *.cs files Program.cs, Startup.cs
778
+
779
+ ## 13.2 Interface Detection
780
+
781
+ LANGUAGE EXPORTED_INTERFACE_PATTERN
782
+ Go Capitalized function/type names (func Foo, type Bar)
783
+ JavaScript/TS export/export default declarations
784
+ Python Functions/classes without underscore prefix
785
+ Rust pub fn, pub struct, pub enum, pub trait
786
+ Java public class, public interface, public method
787
+ C# public class, public interface, public method
788
+
789
+ ## 13.3 Dependency Detection
790
+
791
+ LANGUAGE IMPORT_PATTERN
792
+ Go import "path/to/package"
793
+ JavaScript/TS import ... from "...", require("...")
794
+ Python import ..., from ... import ...
795
+ Rust use crate::..., use super::..., extern crate
796
+ Java import package.Class
797
+ C# using Namespace
798
+
799
+ ---
800
+
801
+ # SECTION 14: MINIMAL VIABLE PRIZM
802
+
803
+ For any project, the minimum viable Prizm setup is:
804
+
805
+ FILES:
806
+ .prizm-docs/root.prizm # Project meta + module index (L0)
807
+ .prizm-docs/changelog.prizm # Change log
808
+
809
+ This is enough to give AI a project overview and track changes.
810
+ L1 and L2 docs can be added incrementally as AI works in specific areas.
811
+
812
+ BOOTSTRAP_COMMAND:
813
+ prizmkit.doc.init
814
+
815
+ Or manually create these two files following the templates in Section 3.
816
+
817
+ ---
818
+
819
+ # SECTION 15: VERSION HISTORY
820
+
821
+ V1 (2026-03-02): Initial specification
822
+ - 3-level progressive loading (L0, L1, L2)
823
+ - KEY: value format, AI-only audience
824
+ - UserPromptSubmit hook with type: prompt for auto-update
825
+ - Mirrored directory structure under .prizm-docs/
826
+ - Lazy L2 generation strategy
827
+ - Universal language support
828
+
829
+ V2 (2026-03-02): Enhanced specification
830
+ - Added ON_DEEP_READ trigger for L2 generation (L2 created during deep analysis, not just modifications)
831
+ - Added prizmkit.doc.validate command for format compliance and consistency checking
832
+ - Added prizmkit.doc.migrate command for converting existing docs to .prizm-docs/ format
833
+ - Added RULES hierarchy: root.prizm RULES authoritative, L1/L2 supplement only with module-specific exceptions
834
+ - Added Section 16: Conflict Resolution for multi-person collaboration merge strategies
835
+ - Added Section 17: Version Migration for upgrading between spec versions
836
+ - Changed fixed skill path to ${SKILL_DIR} convention for cross-IDE compatibility
837
+ - Enhanced Section 9.1 with ON_DEEP_READ trigger alongside ON_MODIFY
838
+ - Updated PRIZM_SPEC_VERSION to 2
839
+
840
+ ---
841
+
842
+ # SECTION 16: CONFLICT RESOLUTION
843
+
844
+ ## 16.1 Multi-Person Collaboration
845
+
846
+ CONTEXT: When multiple developers (human or AI) work on the same project, .prizm-docs/ files may have merge conflicts since they are committed to git.
847
+
848
+ ## 16.2 Merge Strategies by Section Type
849
+
850
+ APPEND_ONLY_SECTIONS:
851
+ - changelog.prizm: Append-only. Use standard git merge. Both sides' entries are kept. Sort by date descending after merge.
852
+ - DECISIONS (in any .prizm file): Append-only. Keep all entries from both sides. Never discard decisions.
853
+ - REJECTED (in any .prizm file): Append-only. Keep all entries from both sides.
854
+ - CHANGELOG (in L2 docs): Append-only. Keep all entries from both sides.
855
+
856
+ LATEST_WINS_SECTIONS:
857
+ - UPDATED: Take the more recent timestamp
858
+ - FILES: Take the higher count (or recount from source)
859
+ - KEY_FILES: Take the version from the branch with more recent UPDATED timestamp
860
+ - INTERFACES: Take the version from the branch with more recent UPDATED timestamp
861
+ - DEPENDENCIES: Take the version from the branch with more recent UPDATED timestamp
862
+ - MODULE_INDEX: Merge entries from both sides, take latest counts, keep all pointers
863
+ - RULES: Take the version from the branch with more recent UPDATED timestamp
864
+ - TRAPS: Union of both sides (traps are safety-critical, never discard)
865
+
866
+ ## 16.3 Conflict Resolution Algorithm
867
+
868
+ ALGORITHM: prizm_merge_conflict
869
+
870
+ 1. DETECT: Identify conflicted .prizm files from git merge markers (<<<<<<<, =======, >>>>>>>)
871
+
872
+ 2. FOR EACH conflicted file:
873
+ a. PARSE both versions (ours and theirs) into sections by ALL CAPS KEY
874
+ b. FOR EACH section:
875
+ IF section is APPEND_ONLY (DECISIONS, REJECTED, CHANGELOG):
876
+ MERGE: Concatenate entries from both versions, deduplicate by content, sort by date
877
+ IF section is LATEST_WINS:
878
+ COMPARE: UPDATED timestamps from both versions
879
+ TAKE: Version with more recent UPDATED timestamp
880
+ IF section is TRAPS:
881
+ UNION: Keep all entries from both versions, deduplicate by content
882
+ c. REASSEMBLE: Write merged sections back to file
883
+ d. VALIDATE: Check size limits and format compliance
884
+
885
+ 3. STAGE: git add resolved .prizm files
886
+
887
+ 4. IF manual intervention needed:
888
+ FLAG: Sections where both versions modified the same KEY: value line with different values
889
+ REPORT: List conflicted keys for human review
890
+
891
+ ## 16.4 Prevention
892
+
893
+ BEST_PRACTICE: Run prizmkit.doc.update immediately before committing to minimize drift
894
+ BEST_PRACTICE: Keep .prizm doc changes small and focused (section-level, not file-level rewrites)
895
+ BEST_PRACTICE: Coordinate on MODULE_INDEX changes (adding/removing modules) to avoid structural conflicts
896
+
897
+ ---
898
+
899
+ # SECTION 17: VERSION MIGRATION
900
+
901
+ ## 17.1 Migration Principles
902
+
903
+ BACKWARD_COMPATIBLE: V2 can read V1 docs without modification
904
+ FORWARD_COMPATIBLE: V1 tools will ignore V2-only fields they do not recognize
905
+ MIGRATION_TRIGGER: AI detects PRIZM_VERSION in root.prizm and applies migration if needed
906
+
907
+ ## 17.2 V1 to V2 Migration
908
+
909
+ COMMAND: Automatic on first prizmkit.doc.update or prizmkit.doc.validate after spec upgrade
910
+
911
+ ALGORITHM: prizm_migrate_v1_to_v2
912
+
913
+ 1. UPDATE_VERSION:
914
+ Change: PRIZM_VERSION: 1 -> PRIZM_VERSION: 2
915
+ In: root.prizm
916
+
917
+ 2. ADD_RULES_HIERARCHY:
918
+ VERIFY: root.prizm has RULES section
919
+ ADD comment-free note: root.prizm RULES are authoritative
920
+ SCAN: L1/L2 docs for RULES sections
921
+ FLAG: Any L1/L2 RULES that contradict root.prizm RULES for manual review
922
+
923
+ 3. VALIDATE:
924
+ Run full prizmkit.doc.validate
925
+ REPORT: Migration results and any issues found
926
+
927
+ 4. UPDATE_CHANGELOG:
928
+ APPEND: - YYYY-MM-DD | root | update: migrated from PRIZM_VERSION 1 to 2
929
+
930
+ ## 17.3 Future Version Migration Pattern
931
+
932
+ FOR any future version N to N+1:
933
+
934
+ 1. READ: root.prizm PRIZM_VERSION
935
+ 2. IF version < target: Apply migration steps sequentially (V1->V2, V2->V3, etc.)
936
+ 3. EACH migration step:
937
+ a. Update PRIZM_VERSION
938
+ b. Add new required fields with sensible defaults
939
+ c. Transform existing fields if format changed
940
+ d. Validate result
941
+ e. Append migration entry to changelog
942
+ 4. NEVER: Delete existing fields during migration (only add or transform)
943
+ 5. ALWAYS: Keep backward compatibility (old tools should still parse new format)