claude-prism 0.1.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/README.md ADDED
@@ -0,0 +1,500 @@
1
+ ```
2
+ ╱╲
3
+ ━━━━━━━━━▶ ╱ ╲ ──── U Understand
4
+ complex ╱ ╲ ──── D Decompose
5
+ problem ╱ PRISM╲──── E Execute
6
+ ╱________╲─── C Checkpoint
7
+ spectrum
8
+ ```
9
+
10
+ # claude-prism
11
+
12
+ An AI coding problem decomposition tool for Claude Code. Installs the **UDEC** methodology — Understand, Decompose, Execute, Checkpoint — directly into your project's Claude Code environment.
13
+
14
+ **The biggest failure mode of AI coding isn't bad code — it's building the wrong thing.** AI agents skip understanding, skip decomposition, and run autonomously for 30 minutes only to produce something nobody wanted. Prism fixes this by injecting discipline into how Claude thinks.
15
+
16
+ **Core philosophy:** Never implement what you haven't understood. Never execute what you haven't decomposed.
17
+
18
+ - Zero dependencies
19
+ - Node >= 18
20
+ - MIT License
21
+ - Repository: https://github.com/lazysaturday91/claude-prism
22
+
23
+ ## The Problem
24
+
25
+ Without structure, Claude does this:
26
+
27
+ | Without Prism | With Prism |
28
+ |---|---|
29
+ | Reads request → assumes understanding | Reads request → assesses sufficiency |
30
+ | Starts coding immediately | Asks 1-2 clarifying questions first |
31
+ | Builds one 30-minute mega-feature | Decomposes into 2-5 minute verifiable units |
32
+ | Runs autonomously (no checkpoints) | Batches execution: 3-4 tasks → checkpoint → ask permission |
33
+ | Produces working code that's wrong | Produces code that's correct *and* wanted |
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ npx claude-prism init # English, with hooks
39
+ npx claude-prism init --lang=ko # Korean
40
+ npx claude-prism init --lang=ja # Japanese
41
+ npx claude-prism init --lang=zh # Chinese
42
+ npx claude-prism init --no-hooks # Rules only, no hooks
43
+ prism check # Verify installation
44
+ ```
45
+
46
+ ### What Gets Installed
47
+
48
+ After running `prism init`, your project gains:
49
+
50
+ **UDEC Rules** — Injected into `CLAUDE.md` between `PRISM:START` and `PRISM:END` markers. Explains the four-phase methodology:
51
+ - **U** — Assess information sufficiency before acting. Ask one question at a time, multiple choice, max 3 rounds.
52
+ - **D** — Decompose complex problems into 2-5 minute units with TDD. Create a plan file for 6+ file changes.
53
+ - **E** — Execute in batches (3-4 tasks per batch). Apply TDD Iron Law: failing test → implementation → verify → commit.
54
+ - **C** — Checkpoint after each batch. Report progress, show next batch preview, get confirmation before continuing.
55
+
56
+ **Slash Commands** — Added to `.claude/commands/claude-prism/`:
57
+ - `/claude-prism:prism` — Full UDEC workflow (understand → decompose → execute → checkpoint). Also handles analysis-only requests.
58
+ - `/claude-prism:checkpoint` — Check batch progress, show next batch preview
59
+ - `/claude-prism:plan` — List, create, or view plan files
60
+ - `/claude-prism:doctor` — Diagnose installation health via Claude
61
+ - `/claude-prism:stats` — Show project statistics, hook status, and plan progress
62
+ - `/claude-prism:help` — Command reference
63
+
64
+ **Hooks** (optional, unless `--no-hooks` is set) — Four CLI guards that enforce discipline:
65
+ - `commit-guard` — Prevents commits when tests haven't run recently
66
+ - `debug-loop` — Warns at 3 edits, blocks at 5 edits to same file (catches infinite debugging loops)
67
+ - `test-tracker` — Detects test command execution (npm test, jest, vitest, pytest, etc.) and records pass/fail state
68
+ - `scope-guard` — Warns at 4 unique files modified, blocks at 7 (agent-aware: warns at 8, blocks at 12)
69
+
70
+ **Configuration** — `.prism.json` stores language preference and hook settings. Includes OMC (oh-my-claudecode) detection.
71
+
72
+ ## File Structure After Installation
73
+
74
+ ```
75
+ your-project/
76
+ ├── CLAUDE.md # (modified) UDEC rules injected
77
+ ├── .claude-prism.json # claude-prism config
78
+ ├── .claude/
79
+ │ ├── commands/
80
+ │ │ └── claude-prism/ # Namespaced commands
81
+ │ │ ├── prism.md # /claude-prism:prism
82
+ │ │ ├── checkpoint.md # /claude-prism:checkpoint
83
+ │ │ ├── plan.md # /claude-prism:plan
84
+ │ │ ├── doctor.md # /claude-prism:doctor
85
+ │ │ ├── stats.md # /claude-prism:stats
86
+ │ │ └── help.md # /claude-prism:help
87
+ │ ├── hooks/ # (optional, if --no-hooks not set)
88
+ │ │ ├── commit-guard.mjs
89
+ │ │ ├── debug-loop.mjs
90
+ │ │ ├── test-tracker.mjs
91
+ │ │ └── scope-guard.mjs
92
+ │ ├── rules/ # Hook logic modules
93
+ │ │ ├── commit-guard.mjs
94
+ │ │ ├── debug-loop.mjs
95
+ │ │ ├── test-tracker.mjs
96
+ │ │ └── scope-guard.mjs
97
+ │ ├── lib/ # Hook dependencies
98
+ │ │ ├── adapter.mjs
99
+ │ │ ├── state.mjs
100
+ │ │ ├── config.mjs
101
+ │ │ └── utils.mjs
102
+ │ └── settings.json # Claude Code hook registration
103
+ └── docs/plans/
104
+ └── YYYY-MM-DD-topic.md # Plan files (created during /claude-prism:prism execution)
105
+ ```
106
+
107
+ ## The UDEC Cycle
108
+
109
+ ```
110
+ START
111
+ |
112
+ v
113
+ [ UNDERSTAND ] ← Assess sufficiency, ask clarifying questions
114
+ |
115
+ v
116
+ [ DECOMPOSE ] ← Break into 2-5 min units, create plan file
117
+ |
118
+ v
119
+ [ EXECUTE ] ← Run batch (3-4 tasks), TDD each unit
120
+ |
121
+ v
122
+ [ CHECKPOINT ] ← Report, show next batch, ask to continue
123
+ |
124
+ [LOOP or STOP]
125
+ ```
126
+
127
+ ## Commands
128
+
129
+ ### Command Reference
130
+
131
+ | Command | When to Use | Purpose |
132
+ |---------|-------------|---------|
133
+ | `/claude-prism:prism` | Any task (code or analysis) | Run full UDEC cycle; stops at U phase for analysis-only requests |
134
+ | `/claude-prism:plan` | Manage plan files | List, create, or view plans |
135
+ | `/claude-prism:checkpoint` | Mid-project | Check batch progress, preview next batch |
136
+ | `/claude-prism:doctor` | Installation issues | Diagnose health, suggest fixes |
137
+ | `/claude-prism:stats` | Check current state | Version, hooks, language, plan progress |
138
+ | `/claude-prism:help` | Forgot commands | Quick reference |
139
+
140
+ ### Workflow
141
+
142
+ ```
143
+ User request arrives
144
+
145
+
146
+ Vague? ──Yes──▶ /claude-prism:prism (U phase clarifies, then proceeds or stops)
147
+
148
+ No
149
+
150
+ Complex? ──Yes──▶ /claude-prism:prism (full UDEC cycle)
151
+
152
+ No
153
+
154
+ Just execute
155
+
156
+
157
+ Mid-check ──────▶ /claude-prism:checkpoint (between batches)
158
+
159
+
160
+ Plan mgmt ──────▶ /claude-prism:plan (list/create)
161
+ ```
162
+
163
+ ### Use Case Patterns
164
+
165
+ **Pattern 1: Feature Implementation**
166
+ ```
167
+ /claude-prism:prism → "Add login functionality"
168
+ → Claude asks: "JWT or sessions?" "OAuth needed?"
169
+ → Plan created: docs/plans/2026-02-16-auth.md
170
+ → Batch 1 executes (3 tasks)
171
+ /claude-prism:checkpoint → "Batch 1 done. Continue to batch 2?"
172
+ ```
173
+
174
+ **Pattern 2: Clarify a Vague Request**
175
+ ```
176
+ /claude-prism:prism → "Improve performance"
177
+ → Claude: [Insufficient] "What kind?"
178
+ 1. Build time (next build)
179
+ 2. Runtime (page load/render)
180
+ 3. Bundle size (recommended)
181
+ → Agreement reached → proceeds to D/E/C or stops if analysis-only
182
+ → /claude-prism:prism to start execution
183
+ ```
184
+
185
+ **Pattern 3: Resume Previous Work**
186
+ ```
187
+ /claude-prism:plan → List existing plans, show progress
188
+ /claude-prism:checkpoint → "Plan X: 5/12 tasks done. Batch 3 next."
189
+ → "Continue" → Resume execution
190
+ ```
191
+
192
+ **Pattern 4: Quick Troubleshooting**
193
+ ```
194
+ /claude-prism:doctor → Check installation health
195
+ /claude-prism:stats → Verify hooks, language, OMC status
196
+ ```
197
+
198
+ ### Before & After
199
+
200
+ **Before (AI agent's default behavior)**
201
+ 1. User: "Refactor auth module"
202
+ 2. AI: (no thinking) 30 minutes autonomous execution
203
+ 3. Result: Completed structure nobody wanted
204
+
205
+ **After (Prism applied)**
206
+ 1. User: "Refactor auth module"
207
+ 2. Claude (automatic questions):
208
+ - "Goal: Keep existing API and only improve internal structure? (Yes/No)"
209
+ - "Scope: Authentication/authorization both? Or authentication only?"
210
+ - "Tests: Keep existing tests as-is?"
211
+ 3. User confirms → decomposition starts
212
+ 4. Result: Completed as intended
213
+
214
+ ## Hooks
215
+
216
+ Hooks are optional CLI guards that enforce discipline during development. Install with `prism init`, skip with `--no-hooks`.
217
+
218
+ ### commit-guard
219
+
220
+ Blocks commits if tests haven't been run in the last 5 minutes (configurable via `maxTestAge` in `.claude-prism.json`). Works with `test-tracker` to know when tests last ran.
221
+
222
+ ```json
223
+ {
224
+ "hooks": {
225
+ "commit-guard": {
226
+ "enabled": true,
227
+ "maxTestAge": 300
228
+ }
229
+ }
230
+ }
231
+ ```
232
+
233
+ **Behavior:**
234
+ - Detects test run via `test-tracker`
235
+ - Blocks commit if: (current time - last test run) > maxTestAge
236
+ - Prevents shipping untested code
237
+
238
+ ### debug-loop
239
+
240
+ Warns when the same file is edited 3 times in a row, blocks at 5 edits. Catches infinite debugging cycles.
241
+
242
+ ```json
243
+ {
244
+ "hooks": {
245
+ "debug-loop": {
246
+ "enabled": true,
247
+ "warnAt": 3,
248
+ "blockAt": 5
249
+ }
250
+ }
251
+ }
252
+ ```
253
+
254
+ **Behavior:**
255
+ - Tracks consecutive edits to same file within a session
256
+ - Warns at 3 edits: "Consider stepping back to understand the problem"
257
+ - Blocks at 5 edits: Forces reassessment before continuing
258
+
259
+ ### test-tracker
260
+
261
+ Detects test command execution and records the timestamp and pass/fail state. Used by `commit-guard` to verify tests ran recently.
262
+
263
+ **Detects:**
264
+ - `npm test`, `npm run test`
265
+ - `jest`, `vitest`
266
+ - `node --test`
267
+ - `npx mocha`, `mocha`
268
+ - `pytest`
269
+ - `cargo test`
270
+ - `go test`
271
+ - `make test`
272
+
273
+ **Configuration:**
274
+ ```json
275
+ {
276
+ "hooks": {
277
+ "test-tracker": {
278
+ "enabled": true
279
+ }
280
+ }
281
+ }
282
+ ```
283
+
284
+ **Behavior:**
285
+ - Runs on every Bash command
286
+ - If command matches test pattern, records timestamp
287
+ - Records result (pass/fail based on exit code)
288
+ - `commit-guard` reads this state to allow/block commits
289
+
290
+ ### scope-guard
291
+
292
+ Tracks unique source files modified per session. Warns when scope grows without a plan (catches scope creep). Agent-aware: sub-agents get higher thresholds.
293
+
294
+ ```json
295
+ {
296
+ "hooks": {
297
+ "scope-guard": {
298
+ "enabled": true,
299
+ "warnAt": 4,
300
+ "blockAt": 7,
301
+ "agentWarnAt": 8,
302
+ "agentBlockAt": 12
303
+ }
304
+ }
305
+ }
306
+ ```
307
+
308
+ **Behavior:**
309
+ - Tracks unique source files (`.ts`, `.tsx`, `.js`, `.jsx`, `.py`, `.go`, `.rs`, `.java`, `.c`, `.cpp`, `.h`, `.svelte`, `.vue`)
310
+ - Excludes test files (`.test.`, `.spec.`, `_test.`)
311
+ - Standard thresholds: warns at 4 files, blocks at 7
312
+ - Agent thresholds (when OMC sub-agents running): warns at 8, blocks at 12
313
+ - Warning: "Consider running /claude-prism:prism to decompose the task"
314
+ - Block: "Run /claude-prism:prism to decompose before continuing"
315
+
316
+ ## Configuration
317
+
318
+ Edit `.claude-prism.json` to customize behavior:
319
+
320
+ ```json
321
+ {
322
+ "language": "en",
323
+ "hooks": {
324
+ "commit-guard": { "enabled": true, "maxTestAge": 300 },
325
+ "debug-loop": { "enabled": true, "warnAt": 3, "blockAt": 5 },
326
+ "test-tracker": { "enabled": true },
327
+ "scope-guard": { "enabled": true, "warnAt": 4, "blockAt": 7, "agentWarnAt": 8, "agentBlockAt": 12 }
328
+ }
329
+ }
330
+ ```
331
+
332
+ **Settings:**
333
+ - `language` — Rule language: `en` (English), `ko` (Korean), `ja` (Japanese), `zh` (Chinese)
334
+ - `hooks.*` — Enable/disable individual hooks or customize thresholds
335
+ - `hooks.commit-guard.maxTestAge` — Seconds before test is considered stale (default: 300)
336
+ - `hooks.debug-loop.warnAt/blockAt` — Edit counts that trigger warnings/blocks
337
+ - `hooks.scope-guard.warnAt/blockAt` — File counts for standard mode
338
+ - `hooks.scope-guard.agentWarnAt/agentBlockAt` — File counts for OMC agent mode
339
+
340
+ ## CLI Commands
341
+
342
+ ### prism check
343
+
344
+ Verify installation after `prism init`:
345
+
346
+ ```bash
347
+ prism check
348
+ ```
349
+
350
+ Output:
351
+ ```
352
+ Commands: ✅
353
+ Rules: ✅
354
+ Hooks: ✅
355
+ Config: ✅
356
+
357
+ Status: ✅ All good
358
+ ```
359
+
360
+ For CI integration, use `--ci` flag for JSON output:
361
+
362
+ ```bash
363
+ prism check --ci
364
+ ```
365
+
366
+ ### prism doctor
367
+
368
+ Diagnose installation issues with actionable fix suggestions. Also detects oh-my-claudecode (OMC) presence.
369
+
370
+ ```bash
371
+ prism doctor
372
+ ```
373
+
374
+ Output:
375
+ ```
376
+ ✅ Installation is healthy. No issues found.
377
+
378
+ OMC: ✅ v4.1.1
379
+ ```
380
+
381
+ If issues are found:
382
+ ```
383
+ Issues found:
384
+
385
+ ❌ CLAUDE.md rules not found
386
+ ❌ /claude-prism:prism command not installed
387
+
388
+ Suggested fixes:
389
+
390
+ 💡 Run: npx claude-prism init
391
+ 💡 Check: .claude/commands/claude-prism/prism.md exists
392
+ ```
393
+
394
+ ### prism stats
395
+
396
+ Show installation summary including version, language, hook status, plan file count, and OMC detection:
397
+
398
+ ```bash
399
+ prism stats
400
+ ```
401
+
402
+ Output:
403
+ ```
404
+ Version: v0.1.0
405
+ Language: en
406
+ Plans: 2 file(s)
407
+ OMC: ✅ v4.1.1
408
+ Hooks:
409
+ ✅ commit-guard
410
+ ✅ debug-loop
411
+ ✅ test-tracker
412
+ ✅ scope-guard
413
+ ```
414
+
415
+ ### prism reset
416
+
417
+ Clear all hook state (edit counters, test timestamps, scope tracking). Use when starting a fresh task or after major refactor:
418
+
419
+ ```bash
420
+ prism reset
421
+ ```
422
+
423
+ Output:
424
+ ```
425
+ ✅ Hook state cleared (edit counters, test timestamps)
426
+
427
+ 🌈 Fresh start. All hooks reset.
428
+ ```
429
+
430
+ ## Uninstall
431
+
432
+ ```bash
433
+ npx claude-prism uninstall
434
+ ```
435
+
436
+ This removes CLAUDE.md rules, slash commands, and hooks.
437
+
438
+ ## Languages
439
+
440
+ Supported languages for UDEC rules:
441
+
442
+ - **en** — English (default)
443
+ - **ko** — Korean
444
+ - **ja** — Japanese
445
+ - **zh** — Chinese
446
+
447
+ Change language (or re-install with different language):
448
+
449
+ ```bash
450
+ npx claude-prism init --lang=ko # Install Korean rules
451
+ npx claude-prism init --lang=ja # Install Japanese rules
452
+ npx claude-prism init --lang=zh # Install Chinese rules
453
+ ```
454
+
455
+ ## OMC (oh-my-claudecode) Integration
456
+
457
+ Prism auto-detects if [oh-my-claudecode](https://github.com/raidenppl/oh-my-claudecode) is installed in your environment. When OMC is present:
458
+
459
+ - **Higher scope thresholds for agents** — Sub-agents get `agentWarnAt: 8, agentBlockAt: 12` instead of standard `warnAt: 4, blockAt: 7`
460
+ - **Visible in status commands** — `prism stats` and `prism doctor` show OMC detection with version
461
+ - **No configuration needed** — Detection happens automatically
462
+
463
+ Check OMC status:
464
+
465
+ ```bash
466
+ prism stats # Shows "OMC: ✅ v4.1.1" or "OMC: ⏭️ not detected"
467
+ prism doctor # Shows OMC detection in diagnostics
468
+ ```
469
+
470
+ This allows OMC agents (executor, architect, etc.) to modify more files per task without triggering scope warnings, recognizing that coordinated multi-agent work has different constraints than single-agent development.
471
+
472
+ ## TDD Iron Law
473
+
474
+ Every task in the EXECUTE phase follows:
475
+
476
+ 1. Write a failing test
477
+ 2. Write minimum code to pass
478
+ 3. Verify the test passes
479
+ 4. Commit
480
+
481
+ Never execute without this cycle.
482
+
483
+ ## Design Philosophy
484
+
485
+ Prism is built on the insight that **AI needs structure more than humans do.** Humans naturally ask clarifying questions and break problems down. AI doesn't — it optimizes for speed. Prism enforces the discipline that makes AI-assisted coding reliable:
486
+
487
+ - Explicit understanding phase (no assumptions)
488
+ - Enforced decomposition (no mega-tasks)
489
+ - Batched execution with checkpoints (human in the loop)
490
+ - TDD for every unit (verified, not assumed)
491
+
492
+ The prism metaphor: white light (complex problem) enters from one side and decomposes into a spectrum of colors (manageable units). Each color (unit) is individually verified, then recombined into a working whole.
493
+
494
+ ## License
495
+
496
+ MIT
497
+
498
+ ## Author
499
+
500
+ lazysaturday91
package/bin/cli.mjs ADDED
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * claude-prism CLI
5
+ * Usage: prism init [--lang=ko] [--no-hooks]
6
+ * prism check [--ci]
7
+ * prism doctor
8
+ * prism stats
9
+ * prism reset
10
+ * prism uninstall
11
+ * prism update
12
+ */
13
+
14
+ import { init, check, uninstall, update, doctor, stats, reset } from '../lib/installer.mjs';
15
+
16
+ const args = process.argv.slice(2);
17
+ const command = args[0];
18
+
19
+ function getFlag(name) {
20
+ const flag = args.find(a => a.startsWith(`--${name}=`));
21
+ return flag ? flag.split('=')[1] : null;
22
+ }
23
+
24
+ function hasFlag(name) {
25
+ return args.includes(`--${name}`) || args.includes(`-${name}`);
26
+ }
27
+
28
+ // --version / -v
29
+ if (hasFlag('version') || hasFlag('v')) {
30
+ const { stats: getStats } = await import('../lib/installer.mjs');
31
+ const s = getStats(process.cwd());
32
+ console.log(`claude-prism v${s.version}`);
33
+ process.exit(0);
34
+ }
35
+
36
+ const cwd = process.cwd();
37
+
38
+ switch (command) {
39
+ case 'init': {
40
+ const language = getFlag('lang') || 'en';
41
+ const hooks = !hasFlag('no-hooks');
42
+
43
+ console.log('🌈 claude-prism init\n');
44
+ await init(cwd, { language, hooks });
45
+
46
+ console.log('✅ Rules injected → CLAUDE.md');
47
+ console.log('✅ Commands installed → /prism, /checkpoint');
48
+ if (hooks) {
49
+ console.log('✅ Hooks installed → commit-guard, debug-loop, test-tracker, scope-guard');
50
+ } else {
51
+ console.log('⏭️ Hooks skipped (use --no-hooks to skip)');
52
+ }
53
+ console.log('\n🌈 Done. Use /prism before complex tasks.');
54
+ break;
55
+ }
56
+
57
+ case 'check': {
58
+ const result = check(cwd);
59
+ const ci = hasFlag('ci');
60
+
61
+ if (ci) {
62
+ console.log(JSON.stringify(result));
63
+ process.exit(result.ok ? 0 : 1);
64
+ }
65
+
66
+ console.log('🌈 claude-prism check\n');
67
+ console.log(` Commands: ${result.commands ? '✅' : '❌'}`);
68
+ console.log(` Rules: ${result.rules ? '✅' : '❌'}`);
69
+ console.log(` Hooks: ${result.hooks ? '✅' : '⏭️ (optional)'}`);
70
+ console.log(` Config: ${result.config ? '✅' : '❌'}`);
71
+ console.log(`\n Status: ${result.ok ? '✅ All good' : '❌ Issues found'}`);
72
+ process.exit(result.ok ? 0 : 1);
73
+ break;
74
+ }
75
+
76
+ case 'doctor': {
77
+ console.log('🌈 claude-prism doctor\n');
78
+ const result = doctor(cwd);
79
+
80
+ if (result.healthy) {
81
+ console.log(' ✅ Installation is healthy. No issues found.');
82
+ } else {
83
+ console.log(' Issues found:\n');
84
+ for (const issue of result.issues) {
85
+ console.log(` ❌ ${issue}`);
86
+ }
87
+ console.log('\n Suggested fixes:\n');
88
+ for (const fix of result.fixes) {
89
+ console.log(` 💡 ${fix}`);
90
+ }
91
+ }
92
+ console.log(`\n OMC: ${result.omc.detected ? `✅ v${result.omc.version || 'unknown'}` : '⏭️ not detected'}`);
93
+ process.exit(result.healthy ? 0 : 1);
94
+ break;
95
+ }
96
+
97
+ case 'stats': {
98
+ const result = stats(cwd);
99
+ console.log('🌈 claude-prism stats\n');
100
+ console.log(` Version: v${result.version}`);
101
+ console.log(` Language: ${result.language}`);
102
+ console.log(` Plans: ${result.planFiles} file(s)`);
103
+ console.log(` OMC: ${result.omc.detected ? `✅ v${result.omc.version || 'unknown'}` : '⏭️ not detected'}`);
104
+ console.log(' Hooks:');
105
+ for (const [name, enabled] of Object.entries(result.hooks)) {
106
+ console.log(` ${enabled ? '✅' : '⏭️ '} ${name}`);
107
+ }
108
+ break;
109
+ }
110
+
111
+ case 'reset': {
112
+ console.log('🌈 claude-prism reset\n');
113
+ reset();
114
+ console.log('✅ Hook state cleared (edit counters, test timestamps)');
115
+ console.log('\n🌈 Fresh start. All hooks reset.');
116
+ break;
117
+ }
118
+
119
+ case 'uninstall': {
120
+ console.log('🌈 claude-prism uninstall\n');
121
+ uninstall(cwd);
122
+ console.log('✅ Rules removed from CLAUDE.md');
123
+ console.log('✅ Commands removed');
124
+ console.log('✅ Hooks removed');
125
+ console.log('✅ Config removed');
126
+ console.log('\n🌈 Prism uninstalled.');
127
+ break;
128
+ }
129
+
130
+ case 'update': {
131
+ console.log('🌈 claude-prism update\n');
132
+ await update(cwd);
133
+ console.log('✅ Rules updated');
134
+ console.log('✅ Commands updated');
135
+ console.log('✅ Hooks updated');
136
+ console.log('\n🌈 Prism updated to latest.');
137
+ break;
138
+ }
139
+
140
+ default: {
141
+ console.log(`🌈 claude-prism — AI coding problem decomposition tool
142
+
143
+ Usage:
144
+ prism init [--lang=XX] [--no-hooks] Install prism in current project
145
+ prism check [--ci] Verify installation
146
+ prism doctor Diagnose issues with fix suggestions
147
+ prism stats Show installation summary
148
+ prism reset Clear hook state (edit counters, etc.)
149
+ prism update Re-install using current config
150
+ prism uninstall Remove prism
151
+
152
+ Options:
153
+ --lang=XX Language: en (default), ko, ja, zh
154
+ --no-hooks Skip enforcement hooks
155
+ --ci Output JSON for CI integration
156
+ --version Show version`);
157
+ }
158
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * claude-prism — Commit Guard
3
+ * Blocks commits when tests failed or haven't been run
4
+ */
5
+
6
+ import { readState } from '../lib/state.mjs';
7
+
8
+ export const commitGuard = {
9
+ name: 'commit-guard',
10
+
11
+ evaluate(ctx, config, stateDir) {
12
+ const command = ctx.command || '';
13
+
14
+ if (!command.includes('git commit')) return { type: 'pass' };
15
+ if (command.includes('--allow-empty')) return { type: 'pass' };
16
+
17
+ // Hard block: last test failed
18
+ const testResult = readState(stateDir, 'last-test-result');
19
+ if (testResult !== null && testResult.trim() === 'fail') {
20
+ return {
21
+ type: 'block',
22
+ message: '🌈 Prism ✋ Commit blocked: last test run FAILED. Fix tests before committing.'
23
+ };
24
+ }
25
+
26
+ // Soft warn: no test run recorded
27
+ const lastTestRaw = readState(stateDir, 'last-test-run');
28
+ if (lastTestRaw === null) {
29
+ return {
30
+ type: 'warn',
31
+ message: '🌈 Prism > No test run detected this session. Run tests before committing.'
32
+ };
33
+ }
34
+
35
+ // Soft warn: test run is stale
36
+ const lastTest = parseInt(lastTestRaw, 10);
37
+ const now = Math.floor(Date.now() / 1000);
38
+ const diff = now - lastTest;
39
+ if (diff > (config.maxTestAge || 300)) {
40
+ return {
41
+ type: 'warn',
42
+ message: `🌈 Prism > Last test run was ${Math.floor(diff / 60)}min ago. Run tests before committing.`
43
+ };
44
+ }
45
+
46
+ return { type: 'pass' };
47
+ }
48
+ };