claude-prism 0.2.1 → 0.3.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.
@@ -34,23 +34,31 @@ export const debugLoop = {
34
34
  writeJsonState(stateDir, logKey, editLog);
35
35
 
36
36
  const name = filePath.split('/').pop();
37
+ const pattern = count >= config.warnAt ? analyzePattern(editLog) : null;
37
38
 
38
- if (count === config.warnAt) {
39
- const pattern = analyzePattern(editLog);
40
- const hint = pattern === 'divergent'
41
- ? ' Pattern: DIVERGENT — same area edited repeatedly.'
42
- : '';
39
+ if (count >= config.blockAt) {
40
+ // Divergent pattern block; convergent (different areas) → downgrade to warn
41
+ if (pattern === 'divergent') {
42
+ return {
43
+ type: 'block',
44
+ message: `🌈 Prism ✋ Debug Loop blocked: ${name} edited ${count} times on same area. Discuss approach with user before continuing.`
45
+ };
46
+ }
43
47
  return {
44
48
  type: 'warn',
45
- message: `🌈 Prism > Debug Loop: ${name} edited ${count} times.${hint} Stop and investigate root cause.`
49
+ message: `🌈 Prism > Debug Loop: ${name} edited ${count} times (different areas). Consider if this is expected.`
46
50
  };
47
51
  }
48
52
 
49
- if (count >= config.blockAt) {
50
- return {
51
- type: 'block',
52
- message: `🌈 Prism ✋ Debug Loop blocked: ${name} edited ${count} times. Discuss approach with user before continuing.`
53
- };
53
+ if (count >= config.warnAt) {
54
+ // Only warn on divergent pattern (same area edited repeatedly)
55
+ if (pattern === 'divergent') {
56
+ return {
57
+ type: 'warn',
58
+ message: `🌈 Prism > Debug Loop: ${name} edited ${count} times on same area. Stop and investigate root cause.`
59
+ };
60
+ }
61
+ // Convergent edits (different areas) = normal progressive work → pass
54
62
  }
55
63
 
56
64
  return { type: 'pass' };
@@ -16,10 +16,10 @@ export const scopeGuard = {
16
16
  const filePath = ctx.filePath;
17
17
  if (!filePath) return { type: 'pass' };
18
18
 
19
- // Plan file created → reset scope (user is decomposing properly)
19
+ // Plan file created → mark plan as active (thresholds will be doubled)
20
20
  if (PLAN_PATTERN.test(filePath)) {
21
- writeJsonState(stateDir, 'scope-files', []);
22
- return { type: 'pass', message: '🌈 Prism 📋 Plan file detected. Scope counter reset.' };
21
+ writeJsonState(stateDir, 'scope-has-plan', true);
22
+ return { type: 'pass', message: '🌈 Prism 📋 Plan file detected. Scope thresholds raised.' };
23
23
  }
24
24
 
25
25
  // Only track source files
@@ -39,8 +39,15 @@ export const scopeGuard = {
39
39
 
40
40
  // Agent-aware thresholds: sub-agents get higher limits
41
41
  const isAgent = ctx.agentId && ctx.agentId !== '' && ctx.agentId !== 'default';
42
- const warnAt = isAgent ? (config.agentWarnAt || 8) : (config.warnAt || 4);
43
- const blockAt = isAgent ? (config.agentBlockAt || 12) : (config.blockAt || 7);
42
+ let warnAt = isAgent ? (config.agentWarnAt || 8) : (config.warnAt || 4);
43
+ let blockAt = isAgent ? (config.agentBlockAt || 12) : (config.blockAt || 7);
44
+
45
+ // Active plan → double thresholds (planned work is expected to touch many files)
46
+ const hasPlan = readJsonState(stateDir, 'scope-has-plan');
47
+ if (hasPlan) {
48
+ warnAt *= 2;
49
+ blockAt *= 2;
50
+ }
44
51
 
45
52
  if (count >= blockAt) {
46
53
  return {
package/lib/installer.mjs CHANGED
@@ -30,7 +30,7 @@ export async function init(projectDir, options = {}) {
30
30
  const nsCommandsDir = join(claudeDir, 'commands', 'claude-prism');
31
31
  mkdirSync(nsCommandsDir, { recursive: true });
32
32
 
33
- const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md'];
33
+ const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md'];
34
34
  for (const cmd of commandFiles) {
35
35
  copyFileSync(
36
36
  join(TEMPLATES_DIR, 'commands', 'claude-prism', cmd),
@@ -241,7 +241,7 @@ export function doctor(projectDir, options = {}) {
241
241
 
242
242
  // Check namespaced commands
243
243
  const nsCommandsDir = join(claudeDir, 'commands', 'claude-prism');
244
- const expectedCommands = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md'];
244
+ const expectedCommands = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md'];
245
245
  for (const cmd of expectedCommands) {
246
246
  if (!existsSync(join(nsCommandsDir, cmd))) {
247
247
  issues.push(`Missing command: claude-prism/${cmd}`);
@@ -386,7 +386,7 @@ export function initGlobal(options = {}) {
386
386
  const commandsDir = join(claudeDir, 'commands', 'claude-prism');
387
387
  mkdirSync(commandsDir, { recursive: true });
388
388
 
389
- const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md'];
389
+ const commandFiles = ['prism.md', 'checkpoint.md', 'plan.md', 'doctor.md', 'stats.md', 'help.md', 'update.md'];
390
390
  for (const cmd of commandFiles) {
391
391
  copyFileSync(
392
392
  join(TEMPLATES_DIR, 'commands', 'claude-prism', cmd),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-prism",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "AI coding problem decomposition tool — Understand, Decompose, Execute, Checkpoint.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -47,8 +47,14 @@ When this command is invoked, follow the UDEC framework strictly:
47
47
 
48
48
  ## E — EXECUTE
49
49
 
50
- 11. Execute one batch at a time (3-4 tasks per batch)
51
- 12. Follow TDD: write failing test implement → verify → commit
50
+ 11. Execute in adaptive batches:
51
+ - Simple changes (imports, types, config): 5-8 per batch
52
+ - Standard changes (feature add/modify): 3-4 per batch
53
+ - Complex changes (new module, architecture): 1-2 per batch
54
+ 12. Apply context-aware verification:
55
+ - `lib/`, `utils/`, `store/`, `hooks/`, `services/` → TDD (failing test → implement → verify)
56
+ - `components/`, `pages/`, `views/` → Build verification (escalate to TDD if complex logic)
57
+ - `config/`, `styles/`, `types/` → Build/lint only
52
58
  13. **Scope Guard**: Before each change, ask: "Was this requested?" If no → don't do it
53
59
  14. **Self-correction triggers**:
54
60
  - Same file edited 3+ times **on the same region/logic** → stop, investigate root cause (progressive edits across different regions — imports, logic, JSX — are normal)
@@ -0,0 +1,36 @@
1
+ # /claude-prism:update — Update Prism
2
+
3
+ When this command is invoked, update claude-prism to the latest version.
4
+
5
+ ## Steps
6
+
7
+ 1. **Run the update command**:
8
+ ```bash
9
+ npx claude-prism@latest update
10
+ ```
11
+
12
+ 2. **If `--global` argument is provided**, update global installation instead:
13
+ ```bash
14
+ npx claude-prism@latest update --global
15
+ ```
16
+
17
+ 3. **Report the result** using this format:
18
+
19
+ ```
20
+ 🌈 claude-prism updated
21
+
22
+ ✅ Rules updated → CLAUDE.md
23
+ ✅ Commands updated → /claude-prism:*
24
+ ✅ Hooks updated → commit-guard, debug-loop, test-tracker, scope-guard
25
+ ```
26
+
27
+ Or for global:
28
+
29
+ ```
30
+ 🌈 claude-prism updated (global)
31
+
32
+ ✅ Commands updated → ~/.claude/commands/claude-prism/
33
+ ✅ OMC skill updated → ~/.claude/skills/prism/
34
+ ```
35
+
36
+ 4. **Verify** by running `prism check` (local) or checking file existence (global).
@@ -124,17 +124,29 @@ Tech stack, key decisions, 2-3 sentences max.
124
124
 
125
125
  ### 3-1. Batch Execution + Checkpoints
126
126
 
127
- 1. **Batch size**: 3-4 tasks per batch
127
+ 1. **Adaptive batch size**:
128
+ - Simple changes (imports, types, config): 5-8 per batch
129
+ - Standard changes (feature add/modify): 3-4 per batch
130
+ - Complex changes (new module, architecture): 1-2 per batch
128
131
  2. **Checkpoint**: report results after each batch + wait for user feedback
129
132
  3. **Report content**: what was done / verification results / next batch preview
130
133
  4. **On blockers**: stop immediately and report (do not guess)
131
134
 
132
- ### 3-2. TDD Iron Law
135
+ ### 3-2. Verification Strategy (Context-Aware)
133
136
 
134
- 1. Write a failing test first
135
- 2. Write minimal code to pass the test
136
- 3. Never commit without tests
137
- 4. Never claim completion without fresh verification evidence
137
+ Choose verification method by file location:
138
+
139
+ | Path Pattern | Strategy | When to Escalate to TDD |
140
+ |---|---|---|
141
+ | `lib/`, `utils/`, `store/`, `hooks/`, `services/` | **TDD required** — failing test → implement → verify | Always |
142
+ | `components/`, `pages/`, `views/` | **Build verification** — build passes + visual check | When component has complex logic (state machines, calculations) |
143
+ | `config/`, `styles/`, `types/`, `*.json` | **Build only** — build/lint passes | Never |
144
+
145
+ **Core Rules (apply to all):**
146
+ 1. Never claim completion without fresh verification evidence
147
+ 2. Never commit code that doesn't build
148
+ 3. For TDD paths: write failing test first → minimal code to pass → verify
149
+ 4. For build paths: run build/lint after changes → confirm no regressions
138
150
 
139
151
  ### 3-3. Systematic Debugging
140
152
 
@@ -177,6 +189,17 @@ Before modifying any code, pass this filter:
177
189
 
178
190
  **If tempted:** Note the improvement for the user. Ask: "I noticed X could be improved. Want me to address it after the current task?"
179
191
 
192
+ ### 3-6. Agent Delegation Verification
193
+
194
+ When delegating work to sub-agents (OMC executor, etc.):
195
+
196
+ 1. **Clear instructions**: specify expected output, files to modify, pass criteria
197
+ 2. **Read actual files** after agent completes — never trust the agent's report alone
198
+ 3. **Run build/test** to verify the agent's changes work
199
+ 4. **Fix or retry** if incomplete: complete remaining work directly, or re-delegate with clearer instructions
200
+
201
+ **Never mark a delegated task as complete without reading the actual file state.**
202
+
180
203
  ---
181
204
 
182
205
  ## 4. CHECKPOINT — Confirmation Protocol
@@ -124,17 +124,29 @@ DECOMPOSEに進む前に確認:
124
124
 
125
125
  ### 3-1. バッチ実行 + チェックポイント
126
126
 
127
- 1. **バッチサイズ**: バッチあたり3-4タスク
127
+ 1. **バッチサイズ(変更の複雑さに応じて調整)**:
128
+ - 単純な変更(import、型定義、設定ファイル): 1バッチあたり5-8タスク
129
+ - 標準的な変更(機能追加・修正): 1バッチあたり3-4タスク
130
+ - 複雑な変更(新規モジュール、アーキテクチャ変更): 1バッチあたり1-2タスク
128
131
  2. **チェックポイント**: 各バッチ後に結果を報告 + ユーザーフィードバックを待つ
129
132
  3. **報告内容**: 実施内容 / 検証結果 / 次のバッチのプレビュー
130
133
  4. **ブロッカー発生時**: 即座に停止して報告 (推測しない)
131
134
 
132
- ### 3-2. TDD Iron Law
135
+ ### 3-2. 検証戦略(コンテキスト対応)
133
136
 
134
- 1. まず失敗するテストを書く
135
- 2. テストを通過する最小限のコードを書く
136
- 3. テストなしでコミットしない
137
- 4. 新鮮な検証証拠なしで完了を宣言しない
137
+ ファイルの配置場所に応じて検証方法を選択する:
138
+
139
+ | パスパターン | 戦略 | TDDに昇格するタイミング |
140
+ |---|---|---|
141
+ | `lib/`, `utils/`, `store/`, `hooks/`, `services/` | **TDD必須** — 失敗テスト作成 → 実装 → 検証 | 常に |
142
+ | `components/`, `pages/`, `views/` | **ビルド検証** — ビルド通過 + 動作確認 | コンポーネントに複雑なロジックがある場合(ステートマシン、計算処理) |
143
+ | `config/`, `styles/`, `types/`, `*.json` | **ビルドのみ** — ビルド/lint通過 | 不要 |
144
+
145
+ **全パスに適用する基本ルール:**
146
+ 1. 新鮮な検証証拠なしに完了を宣言しない
147
+ 2. ビルドが通らないコードをコミットしない
148
+ 3. TDDパスでは: まず失敗テストを書く → 通過させる最小限のコードを書く → 検証する
149
+ 4. ビルドパスでは: 変更後にビルド/lintを実行 → リグレッションがないことを確認する
138
150
 
139
151
  ### 3-3. 体系的デバッグ
140
152
 
@@ -177,6 +189,17 @@ DECOMPOSEに進む前に確認:
177
189
 
178
190
  **誘惑を感じたら:** ユーザーにメモとして残せ。「Xを改善できそうです。現在のタスク完了後に対応しますか?」
179
191
 
192
+ ### 3-6. エージェント委任の検証
193
+
194
+ サブエージェント(OMC executor等)に作業を委任する場合:
195
+
196
+ 1. **明確な指示**: 期待する出力、変更するファイル、合格基準を具体的に指定する
197
+ 2. **実際のファイルを確認**: エージェント完了後は実際のファイルを読む — エージェントの報告だけを信用しない
198
+ 3. **ビルド/テストを実行**: エージェントの変更が正しく動作するか検証する
199
+ 4. **不完全なら修正または再委任**: 残作業を直接完了させるか、より明確な指示で再委任する
200
+
201
+ **委任したタスクは、実際のファイル状態を確認せずに完了とマークしない。**
202
+
180
203
  ---
181
204
 
182
205
  ## 4. CHECKPOINT (確認) — 確認プロトコル
@@ -124,17 +124,29 @@ DECOMPOSE로 넘어가기 전 확인:
124
124
 
125
125
  ### 3-1. 배치 실행 + 체크포인트
126
126
 
127
- 1. **배치 단위**: 3-4개 태스크씩 실행
127
+ 1. **적응형 배치 크기**:
128
+ - 단순 변경 (import, 타입, 설정): 5-8개/배치
129
+ - 일반 변경 (기능 추가/수정): 3-4개/배치
130
+ - 복잡 변경 (새 모듈, 아키텍처): 1-2개/배치
128
131
  2. **체크포인트**: 배치 완료 후 결과 보고 + 사용자 피드백 대기
129
132
  3. **보고 내용**: 구현된 것 / 검증 결과 / 다음 배치 미리보기
130
133
  4. **블로커 발생 시**: 즉시 멈추고 보고 (추측하지 않음)
131
134
 
132
- ### 3-2. TDD Iron Law
135
+ ### 3-2. 검증 전략 (컨텍스트별 분류)
133
136
 
134
- 1. 실패하는 테스트를 먼저 작성한다
135
- 2. 테스트를 통과하는 최소 코드를 작성한다
136
- 3. 테스트 없이 커밋하지 않는다
137
- 4. 검증 없이 완료를 선언하지 않는다
137
+ 파일 위치에 따라 검증 방법을 선택하라:
138
+
139
+ | 경로 패턴 | 전략 | TDD로 격상하는 조건 |
140
+ |---|---|---|
141
+ | `lib/`, `utils/`, `store/`, `hooks/`, `services/` | **TDD 필수** — 실패 테스트 → 구현 → 검증 | 항상 |
142
+ | `components/`, `pages/`, `views/` | **빌드 검증** — 빌드 통과 + 시각적 확인 | 컴포넌트에 복잡한 로직이 있을 때 (상태 머신, 계산 등) |
143
+ | `config/`, `styles/`, `types/`, `*.json` | **빌드만** — 빌드/린트 통과 | 불필요 |
144
+
145
+ **핵심 규칙 (모든 경로에 적용):**
146
+ 1. 검증 없이 완료를 선언하지 않는다
147
+ 2. 빌드가 깨진 코드를 커밋하지 않는다
148
+ 3. TDD 경로: 실패 테스트 → 최소 코드 → 검증
149
+ 4. 빌드 경로: 변경 후 빌드/린트 실행 → 회귀 없음 확인
138
150
 
139
151
  ### 3-3. 체계적 디버깅
140
152
 
@@ -177,6 +189,17 @@ DECOMPOSE로 넘어가기 전 확인:
177
189
 
178
190
  **유혹을 느끼면:** 사용자에게 메모로 남겨라. "X를 개선할 수 있을 것 같습니다. 현재 작업 완료 후 다룰까요?"
179
191
 
192
+ ### 3-6. 에이전트 위임 검증
193
+
194
+ 서브 에이전트(OMC executor 등)에 작업을 위임할 때:
195
+
196
+ 1. **명확한 지시**: 예상 결과물, 수정할 파일, 통과 기준 명시
197
+ 2. **실제 파일 읽기**: 에이전트 완료 후 보고서만 믿지 말고 실제 파일 상태 확인
198
+ 3. **빌드/테스트 실행**: 에이전트의 변경사항이 작동하는지 검증
199
+ 4. **보완 또는 재시도**: 미완성이면 직접 보완하거나, 더 명확한 지시로 재위임
200
+
201
+ **위임된 작업은 실제 파일 상태를 읽지 않고 완료 처리하지 마라.**
202
+
180
203
  ---
181
204
 
182
205
  ## 4. CHECKPOINT — 확인 프로토콜
@@ -124,17 +124,29 @@
124
124
 
125
125
  ### 3-1. 批次执行 + 检查点
126
126
 
127
- 1. **批次大小**:每批 3-4 个任务
127
+ 1. **批次大小(根据变更复杂度调整)**:
128
+ - 简单变更(import、类型定义、配置文件):每批 5-8 个任务
129
+ - 标准变更(功能新增/修改):每批 3-4 个任务
130
+ - 复杂变更(新模块、架构调整):每批 1-2 个任务
128
131
  2. **检查点**:每批后报告结果 + 等待用户反馈
129
132
  3. **报告内容**:完成了什么 / 验证结果 / 下一批预览
130
133
  4. **遇到阻塞时**:立即停止并报告(不要猜测)
131
134
 
132
- ### 3-2. TDD Iron Law
135
+ ### 3-2. 验证策略(上下文感知)
133
136
 
134
- 1. 先写一个失败的测试
135
- 2. 写最少的代码来通过测试
136
- 3. 没有测试不提交
137
- 4. 没有新鲜验证证据不声明完成
137
+ 根据文件所在位置选择验证方式:
138
+
139
+ | 路径模式 | 策略 | 何时升级为 TDD |
140
+ |---|---|---|
141
+ | `lib/`, `utils/`, `store/`, `hooks/`, `services/` | **必须 TDD** — 先写失败测试 → 实现 → 验证 | 始终 |
142
+ | `components/`, `pages/`, `views/` | **构建验证** — 构建通过 + 视觉确认 | 组件含复杂逻辑时(状态机、计算逻辑) |
143
+ | `config/`, `styles/`, `types/`, `*.json` | **仅构建** — 构建/lint 通过 | 不需要 |
144
+
145
+ **适用于所有路径的核心规则:**
146
+ 1. 没有新鲜验证证据不声明完成
147
+ 2. 不提交无法构建的代码
148
+ 3. TDD 路径:先写失败测试 → 写最少代码通过 → 验证
149
+ 4. 构建路径:变更后运行构建/lint → 确认无回归
138
150
 
139
151
  ### 3-3. 系统化调试
140
152
 
@@ -177,6 +189,17 @@
177
189
 
178
190
  **感到诱惑时:** 给用户留个备注。"我注意到 X 可以改进。当前任务完成后要处理吗?"
179
191
 
192
+ ### 3-6. 代理委托验证
193
+
194
+ 将工作委托给子代理(OMC executor 等)时:
195
+
196
+ 1. **明确指令**:具体说明预期输出、要修改的文件、通过标准
197
+ 2. **读取实际文件**:代理完成后亲自读取文件 — 不要只相信代理的报告
198
+ 3. **运行构建/测试**:验证代理的变更是否正常工作
199
+ 4. **不完整则修复或重新委托**:直接补全剩余工作,或提供更明确的指令重新委托
200
+
201
+ **委托的任务,必须确认实际文件状态后才能标记为完成。**
202
+
180
203
  ---
181
204
 
182
205
  ## 4. CHECKPOINT (检查点) — 确认协议
@@ -76,17 +76,23 @@ AI agents optimize for speed, not correctness. Without structure, they skip unde
76
76
 
77
77
  ## E — EXECUTE
78
78
 
79
- 11. Execute one batch at a time (3-4 tasks per batch)
80
- 12. Follow TDD: write failing test implement → verify → commit
79
+ 11. Execute in adaptive batches:
80
+ - Simple changes (imports, types, config): 5-8 per batch
81
+ - Standard changes (feature add/modify): 3-4 per batch
82
+ - Complex changes (new module, architecture): 1-2 per batch
83
+ 12. Apply context-aware verification:
84
+ - `lib/`, `utils/`, `store/`, `hooks/`, `services/` → TDD (failing test → implement → verify)
85
+ - `components/`, `pages/`, `views/` → Build verification (escalate to TDD if complex logic)
86
+ - `config/`, `styles/`, `types/` → Build/lint only
81
87
  13. **Scope Guard**: Before each change, ask: "Was this requested?" If no → don't do it
82
88
  14. **Self-correction triggers**:
83
- - Same file edited 3+ times on the same region/logic → stop, investigate root cause
89
+ - Same file edited 3+ times **on the same region/logic** → stop, investigate root cause (progressive edits across different regions — imports, logic, JSX — are normal)
84
90
  - File not in plan → pause, ask about scope change
85
91
  - 3 consecutive test failures → stop, reconsider approach
86
92
  - New package needed → ask user first
87
93
  - 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:
94
+ 15. **Verification scoping**: When running build checks (tsc, lint, etc.), filter output to only changed files. Pre-existing errors in other files are not your concern. Example: `tsc --noEmit 2>&1 | grep -i "<changed-file>"`
95
+ 16. **Agent failure recovery**: If a delegated agent partially fails or produces incomplete results:
90
96
  1. Verify actual file state (read the file, not just the agent's report)
91
97
  2. If partially correct → complete the remaining work directly
92
98
  3. If fully wrong → retry with clearer instructions or execute directly
@@ -110,5 +116,6 @@ If oh-my-claudecode is detected in this environment:
110
116
  - Use `architect` agent for complex decomposition decisions
111
117
  - Use `executor` agents for parallel batch execution when tasks are independent
112
118
  - Use `verifier` agent for checkpoint verification
119
+ - Scope Guard thresholds are automatically raised for sub-agents (8 warn / 12 block vs 4/7)
113
120
 
114
121
  </Steps>