takt 0.1.5 → 0.1.7

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 (59) hide show
  1. package/dist/agents/runner.d.ts +1 -1
  2. package/dist/agents/runner.d.ts.map +1 -1
  3. package/dist/agents/runner.js +13 -34
  4. package/dist/agents/runner.js.map +1 -1
  5. package/dist/cli.d.ts +2 -3
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +5 -8
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands/help.d.ts.map +1 -1
  10. package/dist/commands/help.js +4 -8
  11. package/dist/commands/help.js.map +1 -1
  12. package/dist/commands/index.d.ts +1 -1
  13. package/dist/commands/index.d.ts.map +1 -1
  14. package/dist/commands/index.js.map +1 -1
  15. package/dist/commands/taskExecution.d.ts +1 -6
  16. package/dist/commands/taskExecution.d.ts.map +1 -1
  17. package/dist/commands/taskExecution.js +2 -6
  18. package/dist/commands/taskExecution.js.map +1 -1
  19. package/dist/commands/workflowExecution.d.ts +0 -2
  20. package/dist/commands/workflowExecution.d.ts.map +1 -1
  21. package/dist/commands/workflowExecution.js +9 -11
  22. package/dist/commands/workflowExecution.js.map +1 -1
  23. package/dist/mock/client.d.ts +27 -0
  24. package/dist/mock/client.d.ts.map +1 -0
  25. package/dist/mock/client.js +56 -0
  26. package/dist/mock/client.js.map +1 -0
  27. package/dist/models/schemas.d.ts +6 -0
  28. package/dist/models/schemas.d.ts.map +1 -1
  29. package/dist/models/schemas.js +9 -9
  30. package/dist/models/schemas.js.map +1 -1
  31. package/dist/models/types.d.ts +4 -4
  32. package/dist/models/types.d.ts.map +1 -1
  33. package/dist/providers/claude.d.ts +11 -0
  34. package/dist/providers/claude.d.ts.map +1 -0
  35. package/dist/providers/claude.js +37 -0
  36. package/dist/providers/claude.js.map +1 -0
  37. package/dist/providers/codex.d.ts +11 -0
  38. package/dist/providers/codex.d.ts.map +1 -0
  39. package/dist/providers/codex.js +29 -0
  40. package/dist/providers/codex.js.map +1 -0
  41. package/dist/providers/index.d.ts +39 -0
  42. package/dist/providers/index.d.ts.map +1 -0
  43. package/dist/providers/index.js +32 -0
  44. package/dist/providers/index.js.map +1 -0
  45. package/dist/providers/mock.d.ts +11 -0
  46. package/dist/providers/mock.d.ts.map +1 -0
  47. package/dist/providers/mock.js +24 -0
  48. package/dist/providers/mock.js.map +1 -0
  49. package/package.json +1 -1
  50. package/resources/global/en/agents/default/architect.md +67 -6
  51. package/resources/global/en/agents/default/coder.md +155 -1
  52. package/resources/global/en/workflows/expert-review.yaml +1 -1
  53. package/resources/global/en/workflows/simple.yaml +594 -0
  54. package/resources/global/ja/agents/default/architect.md +62 -1
  55. package/resources/global/ja/agents/default/coder.md +156 -2
  56. package/resources/global/ja/agents/expert-review/cqrs-es-reviewer.md +328 -8
  57. package/resources/global/ja/agents/expert-review/frontend-reviewer.md +303 -33
  58. package/resources/global/ja/workflows/expert-review.yaml +1 -1
  59. package/resources/global/ja/workflows/simple.yaml +594 -0
@@ -0,0 +1,594 @@
1
+ # Simple TAKT Workflow
2
+ # Plan -> Coder -> Architect Review -> AI Review -> Supervisor Approval
3
+ # (Simplified version of default - removed improve, fix, ai_fix, security_review, security_fix)
4
+ #
5
+ # Template Variables:
6
+ # {iteration} - Workflow-wide turn count (total steps executed across all agents)
7
+ # {max_iterations} - Maximum iterations allowed for the workflow
8
+ # {step_iteration} - Per-step iteration count (how many times THIS step has been executed)
9
+ # {task} - Original user request
10
+ # {previous_response} - Output from the previous step
11
+ # {git_diff} - Current uncommitted changes (git diff)
12
+ # {user_inputs} - Accumulated user inputs during workflow
13
+ # {report_dir} - Report directory name (e.g., "20250126-143052-task-summary")
14
+
15
+ name: simple
16
+ description: Simplified development workflow (plan -> implement -> review -> ai_review -> supervise)
17
+
18
+ max_iterations: 20
19
+
20
+ initial_step: plan
21
+
22
+ steps:
23
+ - name: plan
24
+ agent: ~/.takt/agents/default/planner.md
25
+ allowed_tools:
26
+ - Read
27
+ - Glob
28
+ - Grep
29
+ - Bash
30
+ - WebSearch
31
+ - WebFetch
32
+ status_rules_prompt: |
33
+ # ⚠️ REQUIRED: Status Output Rules ⚠️
34
+
35
+ **Without this tag, the workflow will stop.**
36
+ Your final output MUST include a status tag following the rules below.
37
+
38
+ ## Judgment Criteria
39
+
40
+ | Situation | Judgment |
41
+ |-----------|----------|
42
+ | Requirements clear and implementable | DONE |
43
+ | Requirements unclear, insufficient info | BLOCKED |
44
+
45
+ ## Output Format
46
+
47
+ | Situation | Tag |
48
+ |-----------|-----|
49
+ | Analysis complete | `[PLANNER:DONE]` |
50
+ | Insufficient info | `[PLANNER:BLOCKED]` |
51
+
52
+ ### Output Examples
53
+
54
+ **DONE case:**
55
+ ```
56
+ [PLANNER:DONE]
57
+ ```
58
+
59
+ **BLOCKED case:**
60
+ ```
61
+ [PLANNER:BLOCKED]
62
+
63
+ Clarifications needed:
64
+ - {Question 1}
65
+ - {Question 2}
66
+ ```
67
+ instruction_template: |
68
+ ## Workflow Context
69
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
70
+ - Step Iteration: {step_iteration} (times this step has run)
71
+ - Step: plan (Task Analysis)
72
+ - Report Directory: .takt/reports/{report_dir}/
73
+ - Report File: .takt/reports/{report_dir}/00-plan.md
74
+
75
+ ## User Request
76
+ {task}
77
+
78
+ ## Previous Response (when returned from implement)
79
+ {previous_response}
80
+
81
+ ## Instructions
82
+ Analyze the task and create an implementation plan.
83
+
84
+ **Note:** If returned from implement step (Previous Response exists),
85
+ review and revise the plan based on that feedback (replan).
86
+
87
+ **Tasks:**
88
+ 1. Understand the requirements
89
+ 2. Identify impact scope
90
+ 3. Decide implementation approach
91
+
92
+ **Report output:** Output to the `Report File` specified above.
93
+ - If file does not exist: Create new file
94
+ - If file exists: Append with `## Iteration {step_iteration}` section
95
+
96
+ **Report format:**
97
+ ```markdown
98
+ # Task Plan
99
+
100
+ ## Original Request
101
+ {User's request as-is}
102
+
103
+ ## Analysis Results
104
+
105
+ ### Objective
106
+ {What needs to be achieved}
107
+
108
+ ### Scope
109
+ {Impact scope}
110
+
111
+ ### Implementation Approach
112
+ {How to proceed}
113
+
114
+ ## Clarifications Needed (if any)
115
+ - {Unclear points or items requiring confirmation}
116
+ ```
117
+ pass_previous_response: true
118
+ transitions:
119
+ - condition: done
120
+ next_step: implement
121
+ - condition: blocked
122
+ next_step: ABORT
123
+
124
+ - name: implement
125
+ agent: ~/.takt/agents/default/coder.md
126
+ allowed_tools:
127
+ - Read
128
+ - Glob
129
+ - Grep
130
+ - Edit
131
+ - Write
132
+ - Bash
133
+ - WebSearch
134
+ - WebFetch
135
+ status_rules_prompt: |
136
+ # ⚠️ REQUIRED: Status Output Rules ⚠️
137
+
138
+ **Without this tag, the workflow will stop.**
139
+ Your final output MUST include a status tag following the rules below.
140
+
141
+ ## Output Format
142
+
143
+ | Situation | Tag |
144
+ |-----------|-----|
145
+ | Implementation complete | `[CODER:DONE]` |
146
+ | Cannot decide/insufficient info | `[CODER:BLOCKED]` |
147
+
148
+ **Important**: When in doubt, `[BLOCKED]`. Don't decide on your own.
149
+
150
+ ### Output Examples
151
+
152
+ **DONE case:**
153
+ ```
154
+ Implementation complete.
155
+ - Created: `src/auth/service.ts`, `tests/auth.test.ts`
156
+ - Modified: `src/routes.ts`
157
+
158
+ [CODER:DONE]
159
+ ```
160
+
161
+ **BLOCKED case:**
162
+ ```
163
+ [CODER:BLOCKED]
164
+
165
+ Reason: DB schema is undefined, cannot implement
166
+ Required info: users table structure
167
+ ```
168
+ instruction_template: |
169
+ ## Workflow Context
170
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
171
+ - Step Iteration: {step_iteration} (times this step has run)
172
+ - Step: implement
173
+ - Report Directory: .takt/reports/{report_dir}/
174
+ - Report Files:
175
+ - Scope: .takt/reports/{report_dir}/01-coder-scope.md
176
+ - Decisions: .takt/reports/{report_dir}/02-coder-decisions.md
177
+
178
+ ## User Request
179
+ {task}
180
+
181
+ ## Additional User Inputs
182
+ {user_inputs}
183
+
184
+ ## Instructions
185
+ Follow the plan from the plan step and implement.
186
+ Refer to the plan report (00-plan.md) and proceed with implementation.
187
+
188
+ **Report output:** Output to the `Report Files` specified above.
189
+ - If file does not exist: Create new file
190
+ - If file exists: Append with `## Iteration {step_iteration}` section
191
+
192
+ **Scope report format (create at implementation start):**
193
+ ```markdown
194
+ # Change Scope Declaration
195
+
196
+ ## Task
197
+ {One-line task summary}
198
+
199
+ ## Planned Changes
200
+ | Type | File |
201
+ |------|------|
202
+ | Create | `src/example.ts` |
203
+ | Modify | `src/routes.ts` |
204
+
205
+ ## Estimated Size
206
+ Small / Medium / Large
207
+
208
+ ## Impact Scope
209
+ - {Affected modules or features}
210
+ ```
211
+
212
+ **Decisions report format (on completion, only if decisions were made):**
213
+ ```markdown
214
+ # Decision Log
215
+
216
+ ## 1. {Decision Content}
217
+ - **Background**: {Why the decision was needed}
218
+ - **Options Considered**: {List of options}
219
+ - **Reason**: {Why this option was chosen}
220
+ ```
221
+ transitions:
222
+ - condition: done
223
+ next_step: review
224
+ - condition: blocked
225
+ next_step: plan
226
+
227
+ - name: review
228
+ agent: ~/.takt/agents/default/architect.md
229
+ allowed_tools:
230
+ - Read
231
+ - Glob
232
+ - Grep
233
+ - WebSearch
234
+ - WebFetch
235
+ status_rules_prompt: |
236
+ # ⚠️ REQUIRED: Status Output Rules ⚠️
237
+
238
+ **Without this tag, the workflow will stop.**
239
+ Your final output MUST include a status tag following the rules below.
240
+
241
+ ## Judgment Criteria
242
+
243
+ | Situation | Judgment |
244
+ |-----------|----------|
245
+ | Structural issues | REJECT |
246
+ | Design principle violations | REJECT |
247
+ | Security issues | REJECT |
248
+ | Insufficient tests | REJECT |
249
+ | No issues | APPROVE |
250
+
251
+ **Note:** In simple workflow, IMPROVE is not used.
252
+ If there are minor suggestions, use APPROVE + comments.
253
+
254
+ ## Output Format
255
+
256
+ | Situation | Tag |
257
+ |-----------|-----|
258
+ | No issues | `[ARCHITECT:APPROVE]` |
259
+ | Structural changes required | `[ARCHITECT:REJECT]` |
260
+
261
+ ### Output Examples
262
+
263
+ **APPROVE case:**
264
+ ```
265
+ [ARCHITECT:APPROVE]
266
+
267
+ Positive points:
268
+ - Appropriate module organization
269
+ - Single responsibility maintained
270
+ ```
271
+
272
+ **REJECT case:**
273
+ ```
274
+ [ARCHITECT:REJECT]
275
+
276
+ Issues:
277
+ 1. File size exceeded
278
+ - Location: `src/services/user.ts` (523 lines)
279
+ - Fix: Split into 3 files
280
+ ```
281
+ instruction_template: |
282
+ ## Workflow Context
283
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
284
+ - Step Iteration: {step_iteration} (times this step has run)
285
+ - Step: review (Architecture Review)
286
+ - Report Directory: .takt/reports/{report_dir}/
287
+ - Report File: .takt/reports/{report_dir}/03-architect-review.md
288
+
289
+ ## Original User Request (Initial request from workflow start)
290
+ {task}
291
+
292
+ ## Git Diff
293
+ ```diff
294
+ {git_diff}
295
+ ```
296
+
297
+ ## Instructions
298
+ Focus on **architecture and design** review. Do NOT review AI-specific issues (that's the next step).
299
+
300
+ Review the changes and provide feedback.
301
+
302
+ **Note:** In simple workflow, IMPROVE judgment is not used.
303
+ If there are minor suggestions, use APPROVE + comments.
304
+
305
+ **Report output:** Output to the `Report File` specified above.
306
+ - If file does not exist: Create new file
307
+ - If file exists: Append with `## Iteration {step_iteration}` section
308
+
309
+ **Report format:**
310
+ ```markdown
311
+ # Architecture Review
312
+
313
+ ## Result: APPROVE / REJECT
314
+
315
+ ## Summary
316
+ {1-2 sentences summarizing result}
317
+
318
+ ## Reviewed Perspectives
319
+ - [x] Structure & Design
320
+ - [x] Code Quality
321
+ - [x] Change Scope
322
+
323
+ ## Issues (if REJECT)
324
+ | # | Location | Issue | Fix |
325
+ |---|----------|-------|-----|
326
+ | 1 | `src/file.ts:42` | Issue description | Fix method |
327
+
328
+ ## Improvement Suggestions (optional, non-blocking)
329
+ - {Future improvement suggestions}
330
+ ```
331
+
332
+ **Cognitive load reduction rules:**
333
+ - APPROVE + no issues → Summary only (5 lines or less)
334
+ - APPROVE + minor suggestions → Summary + suggestions (15 lines or less)
335
+ - REJECT → Issues in table format (30 lines or less)
336
+ transitions:
337
+ - condition: approved
338
+ next_step: ai_review
339
+ - condition: rejected
340
+ next_step: plan
341
+
342
+ - name: ai_review
343
+ agent: ~/.takt/agents/default/ai-reviewer.md
344
+ allowed_tools:
345
+ - Read
346
+ - Glob
347
+ - Grep
348
+ - WebSearch
349
+ - WebFetch
350
+ status_rules_prompt: |
351
+ # ⚠️ REQUIRED: Status Output Rules ⚠️
352
+
353
+ **Without this tag, the workflow will stop.**
354
+ Your final output MUST include a status tag following the rules below.
355
+
356
+ ## Judgment Criteria
357
+
358
+ | Situation | Judgment |
359
+ |-----------|----------|
360
+ | Incorrect assumptions (affecting behavior) | REJECT |
361
+ | Plausible-but-wrong code | REJECT |
362
+ | Significant context mismatch with codebase | REJECT |
363
+ | Scope creep | APPROVE (with warning noted) |
364
+ | Minor style deviations only | APPROVE |
365
+ | Code fits context and works | APPROVE |
366
+
367
+ **Note:** Scope creep is noted as a warning but doesn't warrant REJECT alone.
368
+
369
+ ## Output Format
370
+
371
+ | Situation | Tag |
372
+ |-----------|-----|
373
+ | No AI-specific issues | `[AI_REVIEW:APPROVE]` |
374
+ | Issues found | `[AI_REVIEW:REJECT]` |
375
+
376
+ ### Output Examples
377
+
378
+ **APPROVE case:**
379
+ ```
380
+ [AI_REVIEW:APPROVE]
381
+
382
+ Verification result: No issues
383
+ ```
384
+
385
+ **REJECT case:**
386
+ ```
387
+ [AI_REVIEW:REJECT]
388
+
389
+ Issues:
390
+ 1. Non-existent API used: `fetch.json()` → `response.json()`
391
+ ```
392
+ instruction_template: |
393
+ ## Workflow Context
394
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
395
+ - Step Iteration: {step_iteration} (times this step has run)
396
+ - Step: ai_review (AI-Generated Code Review)
397
+ - Report Directory: .takt/reports/{report_dir}/
398
+ - Report File: .takt/reports/{report_dir}/04-ai-review.md
399
+
400
+ ## Original User Request (Initial request from workflow start)
401
+ {task}
402
+
403
+ ## Git Diff
404
+ ```diff
405
+ {git_diff}
406
+ ```
407
+
408
+ ## Instructions
409
+ Review the code for AI-specific issues:
410
+ - Assumption validation
411
+ - Plausible but wrong patterns
412
+ - Context fit with existing codebase
413
+ - Scope creep detection
414
+
415
+ **Report output:** Output to the `Report File` specified above.
416
+ - If file does not exist: Create new file
417
+ - If file exists: Append with `## Iteration {step_iteration}` section
418
+
419
+ **Report format:**
420
+ ```markdown
421
+ # AI-Generated Code Review
422
+
423
+ ## Result: APPROVE / REJECT
424
+
425
+ ## Summary
426
+ {One sentence summarizing result}
427
+
428
+ ## Verified Items
429
+ | Aspect | Result | Notes |
430
+ |--------|--------|-------|
431
+ | Assumption validity | ✅ | - |
432
+ | API/Library existence | ✅ | - |
433
+ | Context fit | ✅ | - |
434
+ | Scope | ✅ | - |
435
+
436
+ ## Issues (if REJECT)
437
+ | # | Category | Location | Issue |
438
+ |---|----------|----------|-------|
439
+ | 1 | Hallucinated API | `src/file.ts:23` | Non-existent method |
440
+ ```
441
+
442
+ **Cognitive load reduction rules:**
443
+ - No issues → Summary 1 line + check table only (10 lines or less)
444
+ - Issues found → + Issues in table format (25 lines or less)
445
+ transitions:
446
+ - condition: approved
447
+ next_step: supervise
448
+ - condition: rejected
449
+ next_step: plan
450
+
451
+ - name: supervise
452
+ agent: ~/.takt/agents/default/supervisor.md
453
+ allowed_tools:
454
+ - Read
455
+ - Glob
456
+ - Grep
457
+ - Bash
458
+ - WebSearch
459
+ - WebFetch
460
+ status_rules_prompt: |
461
+ # ⚠️ REQUIRED: Status Output Rules ⚠️
462
+
463
+ **Without this tag, the workflow will stop.**
464
+ Your final output MUST include a status tag following the rules below.
465
+
466
+ ## Judgment Criteria
467
+
468
+ | Situation | Judgment |
469
+ |-----------|----------|
470
+ | Requirements not met | REJECT |
471
+ | Tests failing | REJECT |
472
+ | Build fails | REJECT |
473
+ | Workarounds remaining | REJECT |
474
+ | All OK | APPROVE |
475
+
476
+ **Principle**: When in doubt, REJECT. Don't give ambiguous approval.
477
+
478
+ ## Output Format
479
+
480
+ | Situation | Tag |
481
+ |-----------|-----|
482
+ | Final approval | `[SUPERVISOR:APPROVE]` |
483
+ | Return for fixes | `[SUPERVISOR:REJECT]` |
484
+
485
+ ### Output Examples
486
+
487
+ **APPROVE case:**
488
+ ```
489
+ [SUPERVISOR:APPROVE]
490
+
491
+ Verification results:
492
+ - Tests: ✅ All passed
493
+ - Build: ✅ Succeeded
494
+ - Requirements met: ✅
495
+ ```
496
+
497
+ **REJECT case:**
498
+ ```
499
+ [SUPERVISOR:REJECT]
500
+
501
+ Issues:
502
+ 1. Tests failing: `npm test` - 2 failures
503
+ 2. Requirements not met: Login feature not implemented
504
+ ```
505
+ instruction_template: |
506
+ ## Workflow Context
507
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
508
+ - Step Iteration: {step_iteration} (times this step has run)
509
+ - Step: supervise (final verification)
510
+ - Report Directory: .takt/reports/{report_dir}/
511
+ - Report Files:
512
+ - Validation: .takt/reports/{report_dir}/05-supervisor-validation.md
513
+ - Summary: .takt/reports/{report_dir}/summary.md
514
+
515
+ ## Original User Request
516
+ {task}
517
+
518
+ ## Git Diff
519
+ ```diff
520
+ {git_diff}
521
+ ```
522
+
523
+ ## Instructions
524
+ Run tests, verify the build, and perform final approval.
525
+
526
+ **Workflow Overall Review:**
527
+ 1. Does the implementation match the plan (00-plan.md)?
528
+ 2. Were all review step issues addressed?
529
+ 3. Was the original task objective achieved?
530
+
531
+ **Review Reports:** Read all reports in Report Directory and
532
+ check for any unaddressed improvement suggestions.
533
+
534
+ **Report output:** Output to the `Report Files` specified above.
535
+ - If file does not exist: Create new file
536
+ - If file exists: Append with `## Iteration {step_iteration}` section
537
+
538
+ **Validation report format:**
539
+ ```markdown
540
+ # Final Validation Results
541
+
542
+ ## Result: APPROVE / REJECT
543
+
544
+ ## Validation Summary
545
+ | Item | Status | Verification Method |
546
+ |------|--------|---------------------|
547
+ | Requirements met | ✅ | Matched against requirements list |
548
+ | Tests | ✅ | `npm test` (N passed) |
549
+ | Build | ✅ | `npm run build` succeeded |
550
+ | Functional check | ✅ | Main flows verified |
551
+
552
+ ## Deliverables
553
+ - Created: {Created files}
554
+ - Modified: {Modified files}
555
+
556
+ ## Incomplete Items (if REJECT)
557
+ | # | Item | Reason |
558
+ |---|------|--------|
559
+ | 1 | {Item} | {Reason} |
560
+ ```
561
+
562
+ **Summary report format (only if APPROVE):**
563
+ ```markdown
564
+ # Task Completion Summary
565
+
566
+ ## Task
567
+ {Original request in 1-2 sentences}
568
+
569
+ ## Result
570
+ ✅ Complete
571
+
572
+ ## Changes
573
+ | Type | File | Summary |
574
+ |------|------|---------|
575
+ | Create | `src/file.ts` | Summary description |
576
+
577
+ ## Review Results
578
+ | Review | Result |
579
+ |--------|--------|
580
+ | Architect | ✅ APPROVE |
581
+ | AI Review | ✅ APPROVE |
582
+ | Supervisor | ✅ APPROVE |
583
+
584
+ ## Verification Commands
585
+ ```bash
586
+ npm test
587
+ npm run build
588
+ ```
589
+ ```
590
+ transitions:
591
+ - condition: approved
592
+ next_step: COMPLETE
593
+ - condition: rejected
594
+ next_step: plan
@@ -159,7 +159,68 @@ Vertical Slice の判定基準:
159
159
  | 隠れた依存 | 子コンポーネントが暗黙的にAPIを呼ぶ等 |
160
160
  | 非イディオマティック | 言語・FWの作法を無視した独自実装 |
161
161
 
162
- ### 6. 不要な後方互換コードの検出
162
+ ### 6. 抽象化レベルの評価
163
+
164
+ **条件分岐の肥大化検出:**
165
+
166
+ | パターン | 判定 |
167
+ |---------|------|
168
+ | 同じif-elseパターンが3箇所以上 | ポリモーフィズムで抽象化 → **REJECT** |
169
+ | switch/caseが5分岐以上 | Strategy/Mapパターンを検討 |
170
+ | フラグ引数で挙動を変える | 別関数に分割 → **REJECT** |
171
+ | 型による分岐(instanceof/typeof) | ポリモーフィズムに置換 → **REJECT** |
172
+ | ネストした条件分岐(3段以上) | 早期リターンまたは抽出 → **REJECT** |
173
+
174
+ **抽象度の不一致検出:**
175
+
176
+ | パターン | 問題 | 修正案 |
177
+ |---------|------|--------|
178
+ | 高レベル処理の中に低レベル詳細 | 読みにくい | 詳細を関数に抽出 |
179
+ | 1関数内で抽象度が混在 | 認知負荷 | 同じ粒度に揃える |
180
+ | ビジネスロジックにDB操作が混在 | 責務違反 | Repository層に分離 |
181
+ | 設定値と処理ロジックが混在 | 変更困難 | 設定を外部化 |
182
+
183
+ **良い抽象化の例:**
184
+
185
+ ```typescript
186
+ // ❌ 条件分岐の肥大化
187
+ function process(type: string) {
188
+ if (type === 'A') { /* 処理A */ }
189
+ else if (type === 'B') { /* 処理B */ }
190
+ else if (type === 'C') { /* 処理C */ }
191
+ // ...続く
192
+ }
193
+
194
+ // ✅ Mapパターンで抽象化
195
+ const processors: Record<string, () => void> = {
196
+ A: processA,
197
+ B: processB,
198
+ C: processC,
199
+ };
200
+ function process(type: string) {
201
+ processors[type]?.();
202
+ }
203
+ ```
204
+
205
+ ```typescript
206
+ // ❌ 抽象度の混在
207
+ function createUser(data: UserData) {
208
+ // 高レベル: ビジネスロジック
209
+ validateUser(data);
210
+ // 低レベル: DB操作の詳細
211
+ const conn = await pool.getConnection();
212
+ await conn.query('INSERT INTO users...');
213
+ conn.release();
214
+ }
215
+
216
+ // ✅ 抽象度を揃える
217
+ function createUser(data: UserData) {
218
+ validateUser(data);
219
+ await userRepository.save(data); // 詳細は隠蔽
220
+ }
221
+ ```
222
+
223
+ ### 7. 不要な後方互換コードの検出
163
224
 
164
225
  **AIは「後方互換のために」不要なコードを残しがちである。これを見逃さない。**
165
226