claude-prism 0.1.0 ā 0.2.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/bin/cli.mjs +23 -2
- package/lib/installer.mjs +48 -1
- package/package.json +1 -1
- package/templates/skills/prism/SKILL.md +114 -0
package/bin/cli.mjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* prism update
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { init, check, uninstall, update, doctor, stats, reset } from '../lib/installer.mjs';
|
|
14
|
+
import { init, check, uninstall, update, doctor, stats, reset, initGlobal, uninstallGlobal } from '../lib/installer.mjs';
|
|
15
15
|
|
|
16
16
|
const args = process.argv.slice(2);
|
|
17
17
|
const command = args[0];
|
|
@@ -37,6 +37,15 @@ const cwd = process.cwd();
|
|
|
37
37
|
|
|
38
38
|
switch (command) {
|
|
39
39
|
case 'init': {
|
|
40
|
+
if (hasFlag('global')) {
|
|
41
|
+
console.log('š claude-prism init --global\n');
|
|
42
|
+
initGlobal();
|
|
43
|
+
console.log('ā
Commands installed ā ~/.claude/commands/claude-prism/');
|
|
44
|
+
console.log('ā
OMC skill installed ā ~/.claude/skills/prism/');
|
|
45
|
+
console.log('\nš Done. /claude-prism:prism available in all projects.');
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
const language = getFlag('lang') || 'en';
|
|
41
50
|
const hooks = !hasFlag('no-hooks');
|
|
42
51
|
|
|
@@ -117,6 +126,15 @@ switch (command) {
|
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
case 'uninstall': {
|
|
129
|
+
if (hasFlag('global')) {
|
|
130
|
+
console.log('š claude-prism uninstall --global\n');
|
|
131
|
+
uninstallGlobal();
|
|
132
|
+
console.log('ā
Global commands removed');
|
|
133
|
+
console.log('ā
OMC skill removed');
|
|
134
|
+
console.log('\nš Global prism uninstalled.');
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
120
138
|
console.log('š claude-prism uninstall\n');
|
|
121
139
|
uninstall(cwd);
|
|
122
140
|
console.log('ā
Rules removed from CLAUDE.md');
|
|
@@ -142,16 +160,19 @@ switch (command) {
|
|
|
142
160
|
|
|
143
161
|
Usage:
|
|
144
162
|
prism init [--lang=XX] [--no-hooks] Install prism in current project
|
|
163
|
+
prism init --global Install globally (~/.claude/) + OMC skill
|
|
145
164
|
prism check [--ci] Verify installation
|
|
146
165
|
prism doctor Diagnose issues with fix suggestions
|
|
147
166
|
prism stats Show installation summary
|
|
148
167
|
prism reset Clear hook state (edit counters, etc.)
|
|
149
168
|
prism update Re-install using current config
|
|
150
|
-
prism uninstall Remove prism
|
|
169
|
+
prism uninstall Remove prism from current project
|
|
170
|
+
prism uninstall --global Remove global commands + OMC skill
|
|
151
171
|
|
|
152
172
|
Options:
|
|
153
173
|
--lang=XX Language: en (default), ko, ja, zh
|
|
154
174
|
--no-hooks Skip enforcement hooks
|
|
175
|
+
--global Install/uninstall globally (all projects)
|
|
155
176
|
--ci Output JSON for CI integration
|
|
156
177
|
--version Show version`);
|
|
157
178
|
}
|
package/lib/installer.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync, rmSync, readdirSync, renameSync } from 'fs';
|
|
7
7
|
import { join, dirname } from 'path';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
|
-
import { tmpdir } from 'os';
|
|
9
|
+
import { tmpdir, homedir } from 'os';
|
|
10
10
|
import { detectOmc } from './omc.mjs';
|
|
11
11
|
|
|
12
12
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -372,6 +372,53 @@ export function reset() {
|
|
|
372
372
|
return true;
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Install prism globally (slash commands + OMC skill)
|
|
377
|
+
* Target: ~/.claude/commands/claude-prism/ and ~/.claude/skills/prism/
|
|
378
|
+
* @param {Object} [options]
|
|
379
|
+
* @param {string} [options.homeDir] - Override home dir (for testing)
|
|
380
|
+
*/
|
|
381
|
+
export function initGlobal(options = {}) {
|
|
382
|
+
const home = options.homeDir || homedir();
|
|
383
|
+
const claudeDir = join(home, '.claude');
|
|
384
|
+
|
|
385
|
+
// 1. Install slash commands globally
|
|
386
|
+
const commandsDir = join(claudeDir, 'commands', 'claude-prism');
|
|
387
|
+
mkdirSync(commandsDir, { recursive: true });
|
|
388
|
+
|
|
389
|
+
const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md'];
|
|
390
|
+
for (const cmd of commandFiles) {
|
|
391
|
+
copyFileSync(
|
|
392
|
+
join(TEMPLATES_DIR, 'commands', 'claude-prism', cmd),
|
|
393
|
+
join(commandsDir, cmd)
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// 2. Install OMC skill
|
|
398
|
+
const skillDir = join(claudeDir, 'skills', 'prism');
|
|
399
|
+
mkdirSync(skillDir, { recursive: true });
|
|
400
|
+
copyFileSync(
|
|
401
|
+
join(TEMPLATES_DIR, 'skills', 'prism', 'SKILL.md'),
|
|
402
|
+
join(skillDir, 'SKILL.md')
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Uninstall global prism (slash commands + OMC skill)
|
|
408
|
+
* @param {Object} [options]
|
|
409
|
+
* @param {string} [options.homeDir] - Override home dir (for testing)
|
|
410
|
+
*/
|
|
411
|
+
export function uninstallGlobal(options = {}) {
|
|
412
|
+
const home = options.homeDir || homedir();
|
|
413
|
+
const claudeDir = join(home, '.claude');
|
|
414
|
+
|
|
415
|
+
const commandsDir = join(claudeDir, 'commands', 'claude-prism');
|
|
416
|
+
if (existsSync(commandsDir)) rmSync(commandsDir, { recursive: true });
|
|
417
|
+
|
|
418
|
+
const skillDir = join(claudeDir, 'skills', 'prism');
|
|
419
|
+
if (existsSync(skillDir)) rmSync(skillDir, { recursive: true });
|
|
420
|
+
}
|
|
421
|
+
|
|
375
422
|
// āāā internal helpers āāā
|
|
376
423
|
|
|
377
424
|
function injectRules(projectDir, language) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prism
|
|
3
|
+
description: AI coding problem decomposition tool ā UDEC methodology
|
|
4
|
+
triggers:
|
|
5
|
+
- "prism"
|
|
6
|
+
- "decompose"
|
|
7
|
+
- "udec"
|
|
8
|
+
argument-hint: "[task description]"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<Purpose>
|
|
12
|
+
Prism applies the UDEC methodology (Understand, Decompose, Execute, Checkpoint) to any coding task. It prevents the biggest AI coding failure mode: building the wrong thing by skipping understanding and decomposition.
|
|
13
|
+
</Purpose>
|
|
14
|
+
|
|
15
|
+
<Use_When>
|
|
16
|
+
- User says "prism", "decompose", or "udec"
|
|
17
|
+
- Complex task requiring structured approach (3+ files, unclear scope)
|
|
18
|
+
- Vague request that needs clarification before implementation
|
|
19
|
+
- User wants disciplined, checkpoint-based execution
|
|
20
|
+
</Use_When>
|
|
21
|
+
|
|
22
|
+
<Do_Not_Use_When>
|
|
23
|
+
- Single-file trivial fix (typo, one-line change)
|
|
24
|
+
- User explicitly says "just do it" for a clearly defined small task
|
|
25
|
+
- Pure research/analysis with no code changes needed
|
|
26
|
+
</Do_Not_Use_When>
|
|
27
|
+
|
|
28
|
+
<Why_This_Exists>
|
|
29
|
+
AI agents optimize for speed, not correctness. Without structure, they skip understanding, skip decomposition, and run autonomously for 30 minutes producing something nobody wanted. Prism enforces the discipline that makes AI-assisted coding reliable.
|
|
30
|
+
</Why_This_Exists>
|
|
31
|
+
|
|
32
|
+
<Steps>
|
|
33
|
+
|
|
34
|
+
## U ā UNDERSTAND
|
|
35
|
+
|
|
36
|
+
1. **Explore first**: Read package.json, project structure, related files before asking anything
|
|
37
|
+
2. **Assess information sufficiency**:
|
|
38
|
+
- [Sufficient] Specific file, function, symptom mentioned ā skip to DECOMPOSE
|
|
39
|
+
- [Partial] Direction clear but details missing ā explore then ask 1-2 questions
|
|
40
|
+
- [Insufficient] Abstract, vague, multiple interpretations ā must ask questions first
|
|
41
|
+
3. **Check for hidden assumptions** (Red Flag Detection):
|
|
42
|
+
|
|
43
|
+
| Red Flag | Question to Ask Yourself |
|
|
44
|
+
|----------|-------------------------|
|
|
45
|
+
| "Obviously they want X" | Did they actually say X? Or is it my inference? |
|
|
46
|
+
| "Similar to Y" | What are the differences? Similar ā identical |
|
|
47
|
+
| "Standard approach is..." | Is this what the user wants, or my default? |
|
|
48
|
+
| "Simple fix" | Did I read surrounding code? What could break? |
|
|
49
|
+
| Request < 2 sentences | Likely missing context. Explore first. |
|
|
50
|
+
| No file/function names | [Insufficient]. Must ask. |
|
|
51
|
+
| "just", "simply" | Complexity being underestimated |
|
|
52
|
+
|
|
53
|
+
4. **Question rules** (if questions needed):
|
|
54
|
+
- One question at a time
|
|
55
|
+
- Multiple choice with 2-3 options + recommendation
|
|
56
|
+
- Include reasoning based on code exploration
|
|
57
|
+
- Maximum 3 rounds of questions
|
|
58
|
+
5. **Confirm alignment**: Summarize goal in one sentence, get user approval
|
|
59
|
+
6. **Analysis-only requests**: If no code change is needed, report findings and ask: "Further action needed?" Do NOT proceed to D/E/C unless the user requests implementation.
|
|
60
|
+
|
|
61
|
+
## D ā DECOMPOSE
|
|
62
|
+
|
|
63
|
+
7. **Assess complexity** (consider BOTH file count AND logic complexity):
|
|
64
|
+
- [Simple] 1-2 files, minor changes (<50 LOC) ā execute directly, no decomposition needed
|
|
65
|
+
- [Medium] 3-5 files, OR 1-2 files with significant logic changes (50-150 LOC) ā 2-3 batches
|
|
66
|
+
- [Complex] 6+ files, OR substantial architectural changes ā 5+ batches, must create plan file
|
|
67
|
+
- [Complex system] Unclear scope ā reduce scope first, then decompose
|
|
68
|
+
8. **Create batches** following the 5 principles:
|
|
69
|
+
- Unit size: 2-5 minutes each (test/implement/verify as separate steps)
|
|
70
|
+
- Test first: test before implementation in each unit
|
|
71
|
+
- Independent verification: each unit has a pass criterion
|
|
72
|
+
- Files specified: list files to create/modify per unit
|
|
73
|
+
- Dependencies noted: mark if unit depends on a previous one
|
|
74
|
+
9. **Save plan** to `docs/plans/YYYY-MM-DD-<topic>.md`
|
|
75
|
+
10. **Get approval**: "Proceed with this plan?"
|
|
76
|
+
|
|
77
|
+
## E ā EXECUTE
|
|
78
|
+
|
|
79
|
+
11. Execute one batch at a time (3-4 tasks per batch)
|
|
80
|
+
12. Follow TDD: write failing test ā implement ā verify ā commit
|
|
81
|
+
13. **Scope Guard**: Before each change, ask: "Was this requested?" If no ā don't do it
|
|
82
|
+
14. **Self-correction triggers**:
|
|
83
|
+
- Same file edited 3+ times on the same region/logic ā stop, investigate root cause
|
|
84
|
+
- File not in plan ā pause, ask about scope change
|
|
85
|
+
- 3 consecutive test failures ā stop, reconsider approach
|
|
86
|
+
- New package needed ā ask user first
|
|
87
|
+
- Adding workarounds on workarounds ā design problem, step back
|
|
88
|
+
15. **Verification scoping**: When running build checks, filter output to only changed files.
|
|
89
|
+
16. **Agent failure recovery**: If a delegated agent partially fails:
|
|
90
|
+
1. Verify actual file state (read the file, not just the agent's report)
|
|
91
|
+
2. If partially correct ā complete the remaining work directly
|
|
92
|
+
3. If fully wrong ā retry with clearer instructions or execute directly
|
|
93
|
+
|
|
94
|
+
## C ā CHECKPOINT
|
|
95
|
+
|
|
96
|
+
17. After each batch, report using this format:
|
|
97
|
+
|
|
98
|
+
| Item | Before | After |
|
|
99
|
+
|------|--------|-------|
|
|
100
|
+
| [what changed] | [old behavior] | [new behavior] |
|
|
101
|
+
|
|
102
|
+
18. Include: verification results, files modified, tests status
|
|
103
|
+
19. Ask: "Continue to next batch?"
|
|
104
|
+
20. User can redirect, adjust scope, or stop at any checkpoint
|
|
105
|
+
|
|
106
|
+
## OMC Integration
|
|
107
|
+
|
|
108
|
+
If oh-my-claudecode is detected in this environment:
|
|
109
|
+
- Use `explore` agent for codebase exploration in the UNDERSTAND phase
|
|
110
|
+
- Use `architect` agent for complex decomposition decisions
|
|
111
|
+
- Use `executor` agents for parallel batch execution when tasks are independent
|
|
112
|
+
- Use `verifier` agent for checkpoint verification
|
|
113
|
+
|
|
114
|
+
</Steps>
|