claude-prism 0.7.2 → 0.8.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-prism",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "UDEC methodology framework for AI coding agents — Understand, Decompose, Execute, Checkpoint.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,8 +3,12 @@
3
3
  When this command is invoked:
4
4
 
5
5
  1. **Read the plan file** from `docs/plans/` (most recent matching file)
6
- 2. **Check completed tasks** (marked with [x] in the plan)
7
- 3. **Report current status** using this standard format:
6
+ 2. **Auto-count progress** by running:
7
+ - `grep -c '\- \[x\]' <plan-file>` completed count
8
+ - `grep -c '\- \[ \]' <plan-file>` → remaining count
9
+ - Calculate percentage: completed / (completed + remaining)
10
+ 3. **Freshness check**: grep for plan's change targets to verify they still exist in codebase
11
+ 4. **Report current status** using this standard format:
8
12
 
9
13
  ### Changes
10
14
 
@@ -45,7 +45,16 @@ Before acting on any request, assess first:
45
45
  4. **Maximum 3 rounds** — Round 1: direction (what) / Round 2: constraints (how) / Round 3: scope
46
46
  5. **Explore first** — check package.json, existing structure before asking
47
47
 
48
- ### 2-3. Alignment Confirmation
48
+ ### 2-3. Environment Validation
49
+
50
+ Before any implementation, verify:
51
+ - Project builds from current state (no pre-existing failures)
52
+ - Declared dependencies match lock file versions
53
+ - Environment-specific config identified (env vars, local services, deploy targets)
54
+
55
+ If any of these fail → resolve first. Do not implement on a broken baseline.
56
+
57
+ ### 2-4. Alignment Confirmation
49
58
 
50
59
  Before moving to DECOMPOSE:
51
60
  - Goal summarized in one sentence
@@ -80,9 +89,9 @@ Before moving to DECOMPOSE:
80
89
  | Task Type | Trigger | Action |
81
90
  |-----------|---------|--------|
82
91
  | **Bugfix** | — | Skip decomposition. Go straight to locate → fix → verify. |
83
- | **Feature** | 3+ files affected | Decompose into batches. Plan file if 6+ files. |
92
+ | **Feature** | 3+ files affected (advisory: 2+ in tightly-coupled legacy, 5+ in well-tested modular) | Decompose into batches. Plan file if 6+ files or 3+ modules. |
84
93
  | **Migration** | — | Define pattern + file list. No per-file decomposition. |
85
- | **Refactor** | 3+ files affected | Decompose into batches. Plan file if 6+ files. |
94
+ | **Refactor** | 3+ files affected (same advisory as Feature) | Decompose into batches. Plan file if 6+ files or 3+ modules. |
86
95
  | **Investigation** | — | Skip decomposition. Define exploration scope. |
87
96
 
88
97
  ### 3-2. Decomposition Principles (Feature/Refactor only)
@@ -97,7 +106,10 @@ Before moving to DECOMPOSE:
97
106
  - **[M]** Medium: 30-100 LOC, feature implementation, component creation
98
107
  - **[L]** Large: >100 LOC, multi-file rewrite, new module/architecture
99
108
 
100
- **Batch composition**: S+S+M = 1 batch, L = 1 batch alone, S+S+S+S = 1 batch
109
+ **Batch composition**:
110
+ - Mixed: S+S+M = 1 batch, L = 1 batch alone
111
+ - **[S]-only: up to 8 per batch** (independent small changes can be batched aggressively)
112
+ - Aligns with 4-1 adaptive batch size (simple/mechanical: 5-10 per batch)
101
113
 
102
114
  ### 3-3. Plan File Persistence
103
115
 
@@ -111,13 +123,24 @@ One sentence: what we're building and why.
111
123
  ## Architecture
112
124
  Tech stack, key decisions, 2-3 sentences max.
113
125
 
126
+ ## Related Plans
127
+ - Depends on: `YYYY-MM-DD-<prior-plan>.md` (status: complete/in-progress)
128
+ - Shared files: list files that overlap with other active plans
129
+ - (Omit this section if no other plans exist)
130
+
131
+ ## Codebase Audit
132
+ - Audit date: YYYY-MM-DD
133
+ - Targets remaining: N files (verified by grep/search)
134
+ - Already completed: N items (by prior work or other branches)
135
+ - Evidence: `grep -r "pattern" --include="*.ext" | wc -l` → N
136
+
114
137
  ## Files in Scope
115
138
  - `path/to/file1.ts` — [what changes]
116
139
  - `path/to/file2.ts` — [what changes]
117
140
 
118
141
  ## Batch 1: [Name]
119
- - [ ] Task 1.1: [S] [description] | Verify: [method]
120
- - [ ] Task 1.2: [M] [description] | Verify: [method]
142
+ - [ ] Task 1.1: [S] [description] | Verify: [auto: build/test/lint]
143
+ - [ ] Task 1.2: [M] [description] | Verify: [auto: test] [manual: visual check]
121
144
  - Prerequisite: Task 1.1
122
145
 
123
146
  ## Risks / Open Questions
@@ -127,10 +150,24 @@ Tech stack, key decisions, 2-3 sentences max.
127
150
  ### 3-4. Pre-Decomposition Check
128
151
 
129
152
  Before creating the plan:
153
+ - [ ] **Codebase audit**: grep/search to verify targets actually exist in code (don't trust assumptions from prior sessions)
154
+ - [ ] **Cross-plan check**: if other plans exist in `docs/plans/`, identify overlapping files and note dependencies
130
155
  - [ ] Required types/interfaces have the necessary fields?
131
156
  - [ ] External package APIs behave as expected?
132
157
  - [ ] Cross-package dependencies identified?
133
158
 
159
+ **Staleness prevention**: If plan targets (files to change, patterns to replace) no longer exist in the codebase, mark them as "already completed" before starting execution. Never start a plan without verifying its targets are real.
160
+
161
+ ### 3-5. Quality Gate: DECOMPOSE → EXECUTE
162
+
163
+ Before starting execution, all must pass:
164
+ - [ ] Plan file exists and targets verified against codebase
165
+ - [ ] Project builds from current state (no pre-existing failures)
166
+ - [ ] Dependencies resolved (lock file matches, no missing packages)
167
+ - [ ] Environment validated (required env vars, services, configs present)
168
+
169
+ If any gate fails → resolve before executing. Do not start implementation on a broken baseline.
170
+
134
171
  ---
135
172
 
136
173
  ## UDEC 3. EXECUTE — Execution Protocol
@@ -141,25 +178,48 @@ Before creating the plan:
141
178
  - Simple/mechanical changes (imports, types, config, migration): 5-10 per batch
142
179
  - Standard changes (feature add/modify): 3-4 per batch
143
180
  - Complex changes (new module, architecture): 1-2 per batch
144
- 2. **Checkpoint**: report results after each batch + wait for user feedback
145
- 3. **Report content**: what was done / verification results / next batch preview
146
- 4. **On blockers**: stop immediately and report (do not guess)
181
+ 2. **Git-as-Memory**: commit after each completed batch as a rollback point. Use `git diff` summaries to maintain context in long sessions.
182
+ 3. **Checkpoint**: report results after each batch + wait for user feedback
183
+ 4. **Report content**: what was done / verification results / next batch preview
184
+ 5. **On blockers**: stop immediately and report (do not guess)
147
185
 
148
186
  ### 4-2. Verification Strategy (Risk-Based)
149
187
 
150
188
  Choose verification proportional to the **risk of the change**, not the file path:
151
189
 
152
- | Risk Level | When | Verification |
153
- |------------|------|-------------|
154
- | **High** | Business logic, data mutation, auth, state machines, calculations | TDD required: failing test → implement → pass |
155
- | **Medium** | New components with logic, API integration, config that affects behavior | Build + runtime check (dev server, API call, etc.) |
156
- | **Low** | Imports, types, style/layout, renaming, mechanical migration | Build/lint passes |
190
+ | Risk Level | When | Auto Verification | Manual (recommend only) |
191
+ |------------|------|-------------------|----------------------|
192
+ | **High** | Business logic, data mutation, auth, state machines, calculations | TDD: failing test → implement → pass | — |
193
+ | **Medium** | New components with logic, API integration, config that affects behavior | Build + lint pass | Visual/runtime spot-check |
194
+ | **Low** | Imports, types, style/layout, renaming, mechanical migration | Build/lint passes | — |
195
+ | **No test infra** | No test framework, no CI/CD, manual deploy (legacy PHP, WordPress, etc.) | Grep-based static check + syntax validation | Browser/manual verification |
196
+
197
+ **Auto vs Manual separation:**
198
+ - **Auto** (required): build, test, lint — must pass before claiming completion
199
+ - **Manual** (recommended, not required): visual checks, browser testing, UX review — note as "manual check recommended" in plan, don't list as a gate
200
+
201
+ **Verifiability modifier**: Some changes are hard to verify automatically (UI layout, business rule nuances, security boundaries). For hard-to-verify + high-risk changes, require **human approval before commit** regardless of test results.
202
+
203
+ **Verification Fallback Ladder** (use highest available level):
204
+
205
+ | Level | Method | Tools Required |
206
+ |-------|--------|---------------|
207
+ | 1. Automated Tests | TDD / unit / integration | Test runner |
208
+ | 2. Approval Testing | Capture output before, diff after | diff, shell |
209
+ | 3. Build Verification | Compiles without errors | Build tool |
210
+ | 4. Lint/Static Analysis | No new warnings | Linter |
211
+ | 5. Smoke Check | App starts, key routes respond | curl, browser |
212
+ | 6. Manual Diff Review | `git diff` reviewed for regressions | git |
213
+
214
+ **Every change must have SOME verification.** If no tooling exists, `git diff` review is the minimum.
157
215
 
158
216
  **Core Rules:**
159
- 1. Never claim completion without fresh verification evidence
217
+ 1. Never claim completion without fresh **auto** verification evidence
160
218
  2. Never commit code that doesn't build
161
219
  3. For high-risk: write failing test first → minimal code to pass → verify
162
- 4. For medium/low: run build/lint after changes confirm no regressions
220
+ 4. For high-risk: write at least one **negative test** (what should this code NOT do? what input should it reject?)
221
+ 5. For medium/low: run build/lint after changes → confirm no regressions
222
+ 6. Never list manual verification as a pass criterion — it won't be enforced consistently
163
223
 
164
224
  ### 4-3. Systematic Debugging (Bugfix path)
165
225
 
@@ -181,6 +241,16 @@ Choose verification proportional to the **risk of the change**, not the file pat
181
241
  - 5 turns autonomous → "Report progress before continuing"
182
242
  - Adding workarounds to fix workarounds → "Design problem. Step back."
183
243
  - Copy-pasting similar code 3+ times → "Need abstraction? Ask user."
244
+ - Dependency version mismatch detected → "Resolve before continuing."
245
+
246
+ **Goal Recitation** (prevents drift in long sessions):
247
+ - At every batch boundary, re-read the plan file and confirm: "Current work aligns with: [original goal]"
248
+ - If current work does not serve the original goal → STOP, report drift, return to plan
249
+
250
+ **Thrashing Detector** (beyond simple edit counting):
251
+ - Successive edits reverting previous changes (oscillation) → "Reverting own work. Wrong approach."
252
+ - Scope of changes expanding beyond plan → "Scope creep. Return to DECOMPOSE."
253
+ - Error messages changing type across fixes → "Chasing symptoms, not root cause. Back to UNDERSTAND."
184
254
 
185
255
  ### 4-5. Scope Guard
186
256
 
@@ -197,25 +267,53 @@ Choose verification proportional to the **risk of the change**, not the file pat
197
267
 
198
268
  When delegating work to sub-agents:
199
269
 
200
- 1. **Clear instructions**: specify expected output, files to modify, pass criteria
201
- 2. **Read actual files** after agent completes never trust the agent's report alone
202
- 3. **Run build/test** to verify the agent's changes work
203
- 4. **Fix or retry** if incomplete
270
+ 1. **Clear instructions**: specify inputs, expected outputs, invariants, and pass criteria
271
+ 2. **Resource ownership**: each file/module has exactly one agent writing at a time define non-overlapping scopes upfront
272
+ 3. **Read actual files** after agent completes — never trust the agent's report alone
273
+ 4. **Run build/test** to verify the agent's changes work
274
+ 5. **Fix or retry** if incomplete
204
275
 
205
276
  **Never mark a delegated task as complete without reading the actual file state.**
206
277
 
278
+ ### 4-7. Project-Type Verification Examples
279
+
280
+ | Project Type | Syntax Check | Smoke Test | Approval Test |
281
+ |-------------|-------------|------------|---------------|
282
+ | **PHP/WordPress** | `php -l file.php` | `curl` key pages, `wp-cli` commands | Capture page output before/after, diff |
283
+ | **Static Sites** | Build completes | Link checker, visual diff of HTML | Compare output directory before/after |
284
+ | **Scripts/CLI** | Language syntax check | Run with known inputs, compare outputs | Capture stdout before/after |
285
+ | **Infra/Config** | `terraform plan`, `docker build` | Dry-run deploy | Compare plan output before/after |
286
+
207
287
  ---
208
288
 
209
289
  ## UDEC 4. CHECKPOINT — Confirmation Protocol
210
290
 
291
+ ### Quality Gate: EXECUTE → CHECKPOINT
292
+
293
+ Before reporting completion of a phase:
294
+ - [ ] All batch tasks reach terminal state (done or explicitly skipped with reason)
295
+ - [ ] Build passes with zero new errors
296
+ - [ ] No uncommitted changes left unstaged
297
+ - [ ] Plan file updated with current `[x]` status
298
+
299
+ If any gate fails → continue in EXECUTE, do not report completion.
300
+
211
301
  ### 5-1. Batch Checkpoint
212
302
 
213
303
  After each batch:
214
304
  - Report what was completed
215
305
  - Report verification results (with evidence)
306
+ - **Freshness check**: verify remaining plan targets still exist in codebase (quick grep)
307
+ - Update plan file: mark completed tasks `[x]`, note any targets already done
216
308
  - Preview next batch
217
309
  - "Continue?"
218
310
 
311
+ **Plan-Reality sync** (run at every checkpoint):
312
+ 1. Grep for plan's change targets (patterns, files, functions to modify)
313
+ 2. If target no longer exists → mark task as "already completed (prior work)"
314
+ 3. If new targets discovered → add to plan's "Risks / Open Questions"
315
+ 4. Update plan file's `Codebase Audit` section with fresh counts
316
+
219
317
  **Checkpoint frequency:**
220
318
  - **Phase boundary**: always stop (mandatory)
221
319
  - **Batch boundary**: stop by default → after 3 consecutive approvals, increase batch size for the remainder
@@ -225,6 +323,7 @@ After each batch:
225
323
  ```
226
324
  Phase: [phase] | Batch: [N/M] | Tasks: [done/total] ([%])
227
325
  [████████░░] 80% — Next: [next batch name]
326
+ Plan freshness: verified [date] | Remaining targets: [N] confirmed in code
228
327
  ```
229
328
 
230
329
  ### 5-2. Direction Change
@@ -263,12 +362,36 @@ Create `docs/HANDOFF.md` with:
263
362
  [Anything broken or incomplete]
264
363
  ```
265
364
 
266
- ### 6-3. Resuming from Handoff
365
+ ### 6-3. Project Memory (persistent across all sessions)
366
+
367
+ Maintain `docs/PROJECT-MEMORY.md` — cumulative knowledge that survives session transitions:
368
+
369
+ ```markdown
370
+ ## Architectural Decisions
371
+ - [date] [decision] — [rationale]
372
+
373
+ ## Conventions
374
+ - [naming, patterns, file structure rules discovered/established]
375
+
376
+ ## Environment Gotchas
377
+ - [quirks, workarounds, version constraints and why]
378
+
379
+ ## Package Constraints
380
+ - [package@version — why pinned, what breaks if upgraded]
381
+ ```
382
+
383
+ **Rules:**
384
+ - HANDOFF.md is session-scoped (overwritten each session transition)
385
+ - PROJECT-MEMORY.md is permanent (append-only, never overwrite)
386
+ - On session start: read PROJECT-MEMORY.md first, then HANDOFF.md if it exists
387
+
388
+ ### 6-4. Resuming from Handoff
267
389
 
268
- When a session starts and `docs/HANDOFF.md` exists:
269
- 1. Read it first
270
- 2. Verify the described state matches reality (git status, file contents)
271
- 3. Continue from "Next Steps"
390
+ When a session starts:
391
+ 1. Read `docs/PROJECT-MEMORY.md` if it exists (persistent context)
392
+ 2. Read `docs/HANDOFF.md` if it exists (session context)
393
+ 3. Verify the described state matches reality (git status, file contents)
394
+ 4. Continue from "Next Steps"
272
395
 
273
396
  ---
274
397
 
@@ -288,6 +411,10 @@ If any of these excuses come to mind, **that's a warning signal**. Stop and retu
288
411
  | "This is close enough" | Close ≠ correct. Verify precisely |
289
412
  | "It worked in my head" | Run the test. Thought experiments don't count |
290
413
  | "The existing code is messy anyway" | Fix what was asked. Note the rest for later |
414
+ | "The plan says 0% so we start fresh" | Grep the codebase. Prior work may already exist |
415
+ | "Other plans won't conflict" | Check `docs/plans/` for overlapping files |
416
+ | "Tests pass, so it must be correct" | Passing tests only prove what you tested. Check edge cases and negative cases |
417
+ | "3 files is too few to decompose" | Depends on coupling. 2 files in a tightly-coupled legacy system may need decomposition |
291
418
 
292
419
  ## 8. Completion Declaration Rules
293
420