claude-flow-novice 2.18.36 → 2.18.37
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/.claude/commands/cfn-fix-errors.md +145 -392
- package/package.json +1 -1
|
@@ -6,483 +6,236 @@ allowed-tools: ["Task", "TaskOutput", "TodoWrite", "Read", "Bash"]
|
|
|
6
6
|
|
|
7
7
|
# CFN Fix Errors - Agent Coordination Mode
|
|
8
8
|
|
|
9
|
-
**Version:**
|
|
9
|
+
**Version:** 3.1.0 | **Date:** 2025-12-21 | **Status:** Production Ready
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
## QUICK REFERENCE
|
|
13
|
+
## QUICK REFERENCE
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Get Errors (with caching for speed)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
5. **Monitor** → Use `TaskOutput(taskId, {block: false})` to check agent status
|
|
22
|
-
6. **Respawn** → When an agent completes, IMMEDIATELY spawn next agent for next file
|
|
23
|
-
7. **Commit** → Every 20 files fixed, commit changes to git
|
|
24
|
-
8. **Commit** → After Phase 1 completes, commit remaining changes
|
|
25
|
-
9. **Phase 2** → When <40 errors remain, spawn cleanup agent
|
|
26
|
-
10. **Commit** → After Phase 2 completes, final commit
|
|
27
|
-
|
|
28
|
-
### Critical Rules:
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
AGENTS: Always spawn with run_in_background: true (max 5 concurrent)
|
|
32
|
-
RESPAWN: When TaskOutput shows "completed", spawn next agent immediately
|
|
33
|
-
COMMITS: git add && git commit:
|
|
34
|
-
- After Phase 0 completes
|
|
35
|
-
- Every 20 files fixed in Phase 1
|
|
36
|
-
- After Phase 1 completes
|
|
37
|
-
- After Phase 2 completes
|
|
38
|
-
NO FULL CHECKS: Agents must NOT run eslint ./cargo check on full project
|
|
39
|
-
SINGLE FILE: Each agent fixes ONE file only, then exits
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Agent Spawn Template:
|
|
43
|
-
```typescript
|
|
44
|
-
Task("typescript-specialist", // or "rust-developer"
|
|
45
|
-
`Fix errors in: [FILE_PATH]
|
|
46
|
-
PROJECT: [ROOT]
|
|
47
|
-
Read errors from /tmp/[errors].txt
|
|
48
|
-
Fix file, run post-edit validation, report results.`,
|
|
49
|
-
{run_in_background: true}
|
|
50
|
-
);
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Monitor & Respawn Loop:
|
|
54
|
-
```typescript
|
|
55
|
-
// Check all active agents (non-blocking)
|
|
56
|
-
for (const agent of activeAgents) {
|
|
57
|
-
const result = TaskOutput(agent.taskId, {block: false});
|
|
58
|
-
if (result.status === "completed") {
|
|
59
|
-
filesFixed++;
|
|
60
|
-
removeFromActive(agent);
|
|
61
|
-
// IMMEDIATELY spawn next agent
|
|
62
|
-
if (fileQueue.length > 0) spawnNextAgent();
|
|
63
|
-
// Commit every 20 files
|
|
64
|
-
if (filesFixed % 20 === 0) gitCommit();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
17
|
+
**TypeScript (tsc) - use incremental:**
|
|
18
|
+
```bash
|
|
19
|
+
npm run typecheck 2>&1 | tee /tmp/tsc-errors.txt
|
|
20
|
+
# Ensure tsconfig.json has: "incremental": true, "tsBuildInfoFile": ".tsbuildinfo"
|
|
67
21
|
```
|
|
68
22
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## Quick Overview
|
|
72
|
-
|
|
73
|
-
Main chat coordinates error fixing in two phases:
|
|
74
|
-
- **Phase 0**: Fix strategic root-cause files first (prevents cascading errors)
|
|
75
|
-
- **Phase 1**: Parallel agents fix remaining files (up to 5 concurrent)
|
|
76
|
-
- **Phase 2**: Cleanup of cross-file errors
|
|
77
|
-
|
|
78
|
-
### Key Features
|
|
79
|
-
- **Phase 0 strategic fixes** - identify and fix root-cause files first
|
|
80
|
-
- **Max 5 parallel agents** with continuous spawning in Phase 1
|
|
81
|
-
- **Single-file focus** - each agent fixes one file only
|
|
82
|
-
- **Post-edit validation** confirms fixes are correct
|
|
83
|
-
- **Agents solve independently** - no external tools, just expertise
|
|
84
|
-
- **Automatic Phase 2** transition at <40 errors
|
|
85
|
-
|
|
86
|
-
### When to Use
|
|
87
|
-
- 20+ compilation errors
|
|
88
|
-
- Errors may have cascading dependencies
|
|
89
|
-
- Want visibility into agent progress
|
|
90
|
-
- Need systematic error reduction
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## Execution Instructions (Follow These Steps)
|
|
95
|
-
|
|
96
|
-
### Step 1: Parse Arguments and Initialize
|
|
97
|
-
|
|
98
|
-
**YOU SHOULD:** Parse the command arguments and set up session tracking.
|
|
99
|
-
|
|
23
|
+
**TypeScript (ESLint) - use cache:**
|
|
100
24
|
```bash
|
|
101
|
-
|
|
102
|
-
LANGUAGE="typescript" # or "rust" from user's command
|
|
103
|
-
|
|
104
|
-
# Parse optional flags (use defaults if not provided)
|
|
105
|
-
MAX_PARALLEL=5
|
|
106
|
-
MAX_CYCLES=10
|
|
107
|
-
|
|
108
|
-
# Generate unique session ID
|
|
109
|
-
SESSION_ID="cfn-fix-$(date +%s | tail -c 6)-${RANDOM}"
|
|
110
|
-
echo "Session ID: $SESSION_ID | Language: $LANGUAGE | Max Parallel: $MAX_PARALLEL"
|
|
25
|
+
npx eslint . --ext .ts,.tsx --cache --cache-location /tmp/.eslintcache 2>&1 | tee /tmp/eslint-errors.txt
|
|
111
26
|
```
|
|
112
27
|
|
|
113
|
-
**
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
### Step 2: Get Error Files and Analyze
|
|
118
|
-
|
|
119
|
-
**YOU SHOULD:** Run the appropriate type checker and get files with errors.
|
|
120
|
-
|
|
121
|
-
**For Rust:**
|
|
28
|
+
**Rust (incremental by default):**
|
|
122
29
|
```bash
|
|
123
|
-
|
|
124
|
-
# Cargo errors: file paths are on lines starting with "-->"
|
|
125
|
-
SQLX_OFFLINE=true cargo check 2>&1 | tee /tmp/cargo-errors.txt | grep "^\s*-->" | awk '{print $2}' | awk -F':' '{print $1}' | sort | uniq -c | sort -rn
|
|
30
|
+
SQLX_OFFLINE=true cargo check 2>&1 | tee /tmp/cargo-errors.txt
|
|
126
31
|
```
|
|
127
32
|
|
|
128
|
-
|
|
33
|
+
### Find Files with Most Errors
|
|
34
|
+
|
|
35
|
+
**TypeScript (tsc):**
|
|
129
36
|
```bash
|
|
130
|
-
|
|
131
|
-
npm run typecheck 2>&1 | tee /tmp/tsc-errors.txt | grep "error TS" | awk -F'(' '{print $1}' | sort | uniq -c | sort -rn
|
|
37
|
+
grep "error TS" /tmp/tsc-errors.txt | awk -F'(' '{print $1}' | sort | uniq -c | sort -rn | head -20
|
|
132
38
|
```
|
|
133
39
|
|
|
134
|
-
**
|
|
40
|
+
**TypeScript (ESLint):**
|
|
135
41
|
```bash
|
|
136
|
-
|
|
137
|
-
npm run lint 2>&1 > /tmp/eslint-output.txt
|
|
138
|
-
grep -B1 "error" /tmp/eslint-output.txt | grep -v "error\|--" | grep "\.tsx\?$" | sort | uniq -c | sort -rn
|
|
42
|
+
grep -B1 "error" /tmp/eslint-errors.txt | grep "\.tsx\?$" | sort | uniq -c | sort -rn | head -20
|
|
139
43
|
```
|
|
140
44
|
|
|
141
|
-
**
|
|
45
|
+
**Rust:**
|
|
142
46
|
```bash
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
python3 << 'PARSE_SCRIPT'
|
|
146
|
-
import re
|
|
147
|
-
from collections import defaultdict
|
|
148
|
-
|
|
149
|
-
error_counts = defaultdict(int)
|
|
150
|
-
current_file = None
|
|
151
|
-
|
|
152
|
-
with open('/tmp/lint-output.txt', 'r') as f:
|
|
153
|
-
for line in f:
|
|
154
|
-
if line.strip().endswith('.ts') or line.strip().endswith('.tsx'):
|
|
155
|
-
current_file = line.strip()
|
|
156
|
-
elif re.search(r'^\s+\d+:\d+\s+(error|warning)', line) and current_file:
|
|
157
|
-
error_counts[current_file] += 1
|
|
158
|
-
elif match := re.match(r'^(.+\.tsx?)\(\d+,\d+\):\s+error', line):
|
|
159
|
-
error_counts[match.group(1)] += 1
|
|
160
|
-
|
|
161
|
-
for file, count in sorted(error_counts.items(), key=lambda x: -x[1])[:30]:
|
|
162
|
-
print(f"{count:6d} {file}")
|
|
163
|
-
PARSE_SCRIPT
|
|
47
|
+
grep "^\s*-->" /tmp/cargo-errors.txt | awk '{print $2}' | awk -F':' '{print $1}' | sort | uniq -c | sort -rn | head -20
|
|
164
48
|
```
|
|
165
49
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
### Step 3: Phase 0 - Identify Strategic Root-Cause Files
|
|
169
|
-
|
|
170
|
-
**YOU SHOULD:** Analyze the error output to identify files that should be fixed FIRST because they cause cascading errors.
|
|
50
|
+
Output: files sorted by error count (fix highest counts first)
|
|
171
51
|
|
|
172
|
-
|
|
52
|
+
### Three-Phase Execution
|
|
173
53
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
54
|
+
| Phase | Files | Mode | Rule |
|
|
55
|
+
|-------|-------|------|------|
|
|
56
|
+
| 0 | Strategic root-causes | Sequential | `run_in_background: false` |
|
|
57
|
+
| 1 | Remaining files | Up to 5 parallel | `run_in_background: true` |
|
|
58
|
+
| 2 | Cross-file errors | Sequential | `run_in_background: false` |
|
|
179
59
|
|
|
180
|
-
2
|
|
181
|
-
- `index.ts` files that re-export many modules
|
|
182
|
-
- Files imported by 5+ other error files
|
|
183
|
-
- Base classes/interfaces extended by other files
|
|
60
|
+
**Triggers:** Phase 0 completes → Phase 1 spawns → <40 errors remain → Phase 2 spawns
|
|
184
61
|
|
|
185
|
-
|
|
186
|
-
- `config.ts`, `constants.ts`
|
|
187
|
-
- Environment/settings files
|
|
62
|
+
### Critical Rules
|
|
188
63
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
64
|
+
- **Background ONLY for Phase 1:** Agents restart chat when done. Spawn next immediately.
|
|
65
|
+
- **Single file per agent:** Each agent fixes one file, validates, then exits.
|
|
66
|
+
- **Commits via background agent:** Spawn commit agent every 20 files / after each phase.
|
|
67
|
+
- **Refresh errors at 15 files:** After 15 fixes, spawn background agent to re-run error gathering.
|
|
68
|
+
- **No full checks:** Agents forbidden: `eslint .` `cargo check` `npm run lint` `npm run typecheck` (full project)
|
|
69
|
+
- **Report facts only:** Files fixed, errors remaining. No CFN effectiveness commentary.
|
|
193
70
|
|
|
194
|
-
|
|
71
|
+
### Spawn Templates
|
|
195
72
|
|
|
196
|
-
**
|
|
73
|
+
**Phase 0 & 2 (blocking):**
|
|
74
|
+
```typescript
|
|
75
|
+
Task("typescript-specialist" /* or "rust-developer" */,
|
|
76
|
+
`Fix errors in: [FILE_PATH]
|
|
77
|
+
PROJECT: [ROOT]
|
|
78
|
+
Read errors from /tmp/[errors].txt
|
|
79
|
+
Context: Phase [0|2] strategic work.
|
|
80
|
+
Report: fixes made, remaining errors.`,
|
|
81
|
+
{run_in_background: false}
|
|
82
|
+
);
|
|
197
83
|
```
|
|
198
|
-
ERROR ANALYSIS:
|
|
199
|
-
- 15 files have "Cannot find module './types/api'"
|
|
200
|
-
→ Fix: src/types/api.ts FIRST (root cause)
|
|
201
|
-
|
|
202
|
-
- 8 files have "Type 'UserData' is not assignable"
|
|
203
|
-
→ Fix: src/models/user.ts FIRST (type definition issue)
|
|
204
84
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
85
|
+
**Phase 1 (background):**
|
|
86
|
+
```typescript
|
|
87
|
+
Task("typescript-specialist" /* or "rust-developer" */,
|
|
88
|
+
`Fix errors in: [FILE_PATH]
|
|
89
|
+
PROJECT: [ROOT]
|
|
90
|
+
Read errors from /tmp/[errors].txt
|
|
91
|
+
Validate: .claude/hooks/cfn-invoke-post-edit.sh [FILE_PATH] --agent-id [ID]
|
|
92
|
+
Report: SUMMARY, FIXES APPLIED, ERRORS FIXED, VALIDATION, REMAINING ERRORS.`,
|
|
93
|
+
{run_in_background: true}
|
|
94
|
+
);
|
|
212
95
|
```
|
|
213
96
|
|
|
214
97
|
---
|
|
215
98
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
**YOU SHOULD:** Fix Phase 0 files ONE AT A TIME with full cross-file context.
|
|
219
|
-
|
|
220
|
-
**For EACH file in Phase 0 queue:**
|
|
99
|
+
## Setup
|
|
221
100
|
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
Task("rust-developer" OR "typescript-specialist",
|
|
225
|
-
`Fix errors in: [FILE_PATH]
|
|
226
|
-
|
|
227
|
-
PROJECT: [PROJECT_ROOT]
|
|
228
|
-
CONTEXT: This is a Phase 0 strategic file that other files depend on.
|
|
229
|
-
|
|
230
|
-
YOUR TASK:
|
|
231
|
-
1. Read the file and understand its purpose
|
|
232
|
-
2. Check the error output in /tmp/[cargo-errors|tsc-errors|eslint-output].txt
|
|
233
|
-
3. Fix ALL errors in this file
|
|
234
|
-
4. Consider how your fixes affect files that import/use this file
|
|
235
|
-
5. Run post-edit validation: .claude/hooks/cfn-invoke-post-edit.sh [FILE_PATH]
|
|
236
|
-
6. If validation fails, adjust your fix
|
|
237
|
-
|
|
238
|
-
IMPORTANT:
|
|
239
|
-
- This file is a root cause - other files depend on it
|
|
240
|
-
- Ensure exports/types remain compatible
|
|
241
|
-
- Do NOT change the public API unless necessary to fix errors
|
|
242
|
-
- Focus on type correctness and import resolution
|
|
243
|
-
|
|
244
|
-
Report: List of fixes made and any breaking changes.`,
|
|
245
|
-
{run_in_background: false} // BLOCKING - wait for completion
|
|
246
|
-
);
|
|
247
|
-
```
|
|
101
|
+
### Parse Arguments
|
|
248
102
|
|
|
249
|
-
2. **After each Phase 0 fix, recheck errors:**
|
|
250
103
|
```bash
|
|
251
|
-
#
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
104
|
+
LANGUAGE="${1:-typescript}" # typescript|rust
|
|
105
|
+
MAX_PARALLEL="${2:-5}"
|
|
106
|
+
MAX_CYCLES="${3:-10}"
|
|
107
|
+
SESSION_ID="cfn-fix-$(date +%s | tail -c 6)-${RANDOM}"
|
|
255
108
|
```
|
|
256
109
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
**PHASE 0 COMPLETE when:** All strategic files are fixed.
|
|
110
|
+
Validate: language ∈ {rust, typescript, ts}
|
|
260
111
|
|
|
261
112
|
---
|
|
262
113
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
**YOU SHOULD:** Spawn agents continuously, maintaining exactly 5 active agents at any time.
|
|
266
|
-
|
|
267
|
-
**Agent Spawn Pattern:**
|
|
268
|
-
|
|
269
|
-
```typescript
|
|
270
|
-
// While there are files to process OR active agents running:
|
|
271
|
-
while (fileQueue.length > 0 || activeAgents.length > 0) {
|
|
272
|
-
|
|
273
|
-
// Spawn up to 5 agents
|
|
274
|
-
while (activeAgents.length < MAX_PARALLEL && fileQueue.length > 0) {
|
|
275
|
-
const file = fileQueue.shift();
|
|
276
|
-
const agentId = `${LANGUAGE}-fixer-${SESSION_ID}-${sanitize(file)}`;
|
|
277
|
-
|
|
278
|
-
// Use Task tool with background=true
|
|
279
|
-
const taskId = Task("rust-developer" OR "typescript-specialist",
|
|
280
|
-
`[SEE AGENT PROMPT BELOW]`,
|
|
281
|
-
{run_in_background: true}
|
|
282
|
-
);
|
|
283
|
-
|
|
284
|
-
// Track this agent
|
|
285
|
-
activeAgents.push({file, agentId, taskId, attempts: 1});
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// Monitor agents (non-blocking check)
|
|
289
|
-
for (const agent of activeAgents) {
|
|
290
|
-
const result = TaskOutput(agent.taskId, {block: false, timeout: 0});
|
|
291
|
-
|
|
292
|
-
if (result.status === "completed") {
|
|
293
|
-
if (result.success) {
|
|
294
|
-
markFileComplete(agent.file);
|
|
295
|
-
} else if (agent.attempts < 2) {
|
|
296
|
-
// Retry once
|
|
297
|
-
agent.attempts++;
|
|
298
|
-
requeue(agent.file);
|
|
299
|
-
} else {
|
|
300
|
-
// Defer to Phase 2
|
|
301
|
-
markFileDeferred(agent.file);
|
|
302
|
-
}
|
|
303
|
-
removeFromActive(agent);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Brief pause before next check
|
|
308
|
-
sleep(2000);
|
|
309
|
-
}
|
|
310
|
-
```
|
|
114
|
+
## Phase 0: Identify Root-Cause Files
|
|
311
115
|
|
|
312
|
-
|
|
116
|
+
Analyze errors to find files that block others:
|
|
313
117
|
|
|
314
|
-
|
|
118
|
+
**Priority indicators:**
|
|
119
|
+
1. **Type definitions:** `*.d.ts`, `types.ts`, `types/*.ts`, `interfaces.ts`, `models.ts`
|
|
120
|
+
2. **Core modules:** `index.ts` with re-exports, imported by 5+ error files
|
|
121
|
+
3. **Config files:** `config.ts`, `constants.ts`
|
|
122
|
+
4. **Error patterns:** "Cannot find module './X'" (fix X first) / "Type 'X' not assignable" (fix definition) / "Property missing on type 'Y'" (fix Y)
|
|
315
123
|
|
|
316
|
-
**
|
|
124
|
+
**Build Phase 0 queue** (3-8 files, in dependency order):
|
|
317
125
|
|
|
318
126
|
```
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
LANGUAGE: [typescript|rust]
|
|
323
|
-
AGENT_ID: [GENERATED_AGENT_ID]
|
|
324
|
-
|
|
325
|
-
YOUR TASK:
|
|
326
|
-
1. Read the file to understand context
|
|
327
|
-
2. Identify all errors in this file from the type checker output
|
|
328
|
-
3. Fix each error using your expertise
|
|
329
|
-
4. Run post-edit validation after fixes
|
|
330
|
-
|
|
331
|
-
WORKFLOW:
|
|
332
|
-
1. Read the file: cat [FILE_PATH]
|
|
333
|
-
2. Get specific errors for this file from /tmp/[tsc-errors|cargo-errors|eslint-output].txt
|
|
334
|
-
3. Make targeted fixes - edit only what's needed
|
|
335
|
-
4. Validate: .claude/hooks/cfn-invoke-post-edit.sh [FILE_PATH] --agent-id [AGENT_ID]
|
|
336
|
-
5. If validation shows new errors, adjust
|
|
337
|
-
|
|
338
|
-
CONSTRAINTS:
|
|
339
|
-
- Fix ONLY errors in [FILE_PATH] - do not modify other files
|
|
340
|
-
- Do NOT run linters/checkers on the entire codebase:
|
|
341
|
-
- `eslint .` is FORBIDDEN
|
|
342
|
-
- `cargo check` (full project) is FORBIDDEN
|
|
343
|
-
- `npm run lint` (full project) is FORBIDDEN
|
|
344
|
-
- `npm run typecheck` (full project) is FORBIDDEN
|
|
345
|
-
- Use errors from /tmp/ output files - do NOT regenerate them
|
|
346
|
-
- Do NOT add unnecessary dependencies
|
|
347
|
-
- Preserve existing functionality
|
|
348
|
-
- Keep fixes minimal and targeted
|
|
349
|
-
|
|
350
|
-
COMMON FIX PATTERNS:
|
|
351
|
-
- Missing imports: Add the import statement
|
|
352
|
-
- Type errors: Add proper type annotations
|
|
353
|
-
- Unused variables: Prefix with _ or remove if truly unused
|
|
354
|
-
- Missing exports: Add export keyword
|
|
355
|
-
- Null checks: Add optional chaining or null guards
|
|
356
|
-
|
|
357
|
-
REPORT FORMAT:
|
|
127
|
+
- src/types/api.ts (15 files blocked by this)
|
|
128
|
+
- src/models/user.ts (8 files blocked)
|
|
129
|
+
- src/utils/index.ts (12 files blocked)
|
|
358
130
|
```
|
|
359
|
-
SUMMARY: [2 sentence summary of what was fixed and outcome]
|
|
360
131
|
|
|
361
|
-
|
|
362
|
-
- Line X: [description of fix]
|
|
363
|
-
- Line Y: [description of fix]
|
|
132
|
+
### Execute Phase 0
|
|
364
133
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
134
|
+
For each file:
|
|
135
|
+
1. Spawn agent (blocking mode)
|
|
136
|
+
2. Agent reads file, checks `/tmp/[errors].txt`, fixes ALL errors in file
|
|
137
|
+
3. Agent runs: `.claude/hooks/cfn-invoke-post-edit.sh [FILE_PATH]`
|
|
138
|
+
4. Recheck total error count to see cascading improvements
|
|
139
|
+
5. Remove from queue if no more errors
|
|
140
|
+
|
|
141
|
+
**Commit after Phase 0 completes.**
|
|
372
142
|
|
|
373
143
|
---
|
|
374
144
|
|
|
375
|
-
|
|
145
|
+
## Phase 1: Parallel Fixes
|
|
146
|
+
|
|
147
|
+
Spawn continuous waves (max 5 concurrent):
|
|
148
|
+
1. Spawn agent with background mode
|
|
149
|
+
2. Agent fixes [FILE_PATH], validates, exits → chat restarts
|
|
150
|
+
3. Check which agent finished, spawn next file immediately
|
|
151
|
+
4. Continue until file queue empty
|
|
376
152
|
|
|
377
|
-
**
|
|
153
|
+
**Continuous Error Tracking (no full recheck needed):**
|
|
378
154
|
|
|
379
|
-
|
|
155
|
+
Each agent's post-edit hook updates `/tmp/error-tracker.json`:
|
|
380
156
|
```bash
|
|
381
|
-
#
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
157
|
+
# Post-edit hook appends per-file error count
|
|
158
|
+
# Query anytime: jq '.totalErrors' /tmp/error-tracker.json
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Background tasks during Phase 1:**
|
|
162
|
+
```
|
|
163
|
+
Every 5 files → Query error tracker (instant, no recheck):
|
|
164
|
+
ERRORS=$(jq '.totalErrors' /tmp/error-tracker.json)
|
|
165
|
+
|
|
166
|
+
At 15 files → Spawn background agent for incremental recheck (uses cache, ~5-10s):
|
|
167
|
+
Task("general-purpose",
|
|
168
|
+
`Run incremental typecheck (cached): npm run typecheck 2>&1 > /tmp/tsc-errors-refresh.txt
|
|
169
|
+
Update /tmp/error-tracker.json with actual count
|
|
170
|
+
Report: synced error count`,
|
|
171
|
+
{run_in_background: true});
|
|
172
|
+
|
|
173
|
+
At 20 files → Spawn background commit agent:
|
|
174
|
+
Task("general-purpose",
|
|
175
|
+
`Run: git add -A && git commit -m "fix: batch of 20 error fixes"
|
|
176
|
+
Report: commit hash`,
|
|
177
|
+
{run_in_background: true});
|
|
385
178
|
```
|
|
386
179
|
|
|
387
|
-
**
|
|
388
|
-
-
|
|
389
|
-
-
|
|
390
|
-
-
|
|
391
|
-
- Remaining errors require cross-file coordination
|
|
180
|
+
**Benefits of incremental + cache:**
|
|
181
|
+
- First full check: 30-60s
|
|
182
|
+
- Cached incremental check (15 files changed): 5-10s (80%+ faster)
|
|
183
|
+
- Error tracker query: <0.1s (instant)
|
|
392
184
|
|
|
393
185
|
---
|
|
394
186
|
|
|
395
|
-
|
|
187
|
+
## Phase 2: Cross-File Cleanup
|
|
396
188
|
|
|
397
|
-
|
|
189
|
+
Trigger when: error count <40 OR 3 cycles no improvement OR all files attempted twice
|
|
398
190
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
PROJECT: [PROJECT_ROOT]
|
|
404
|
-
REMAINING_ERRORS: [error count]
|
|
405
|
-
DEFERRED_FILES: [list of files that couldn't be fixed in Phase 1]
|
|
406
|
-
|
|
407
|
-
CONTEXT:
|
|
408
|
-
Phase 0 fixed strategic root-cause files.
|
|
409
|
-
Phase 1 fixed [X] files with single-file errors.
|
|
410
|
-
Now fix remaining errors that require cross-file understanding.
|
|
411
|
-
|
|
412
|
-
YOUR TASK:
|
|
413
|
-
1. Run full type check to get current errors
|
|
414
|
-
2. Analyze error patterns across files
|
|
415
|
-
3. Fix errors that span multiple files
|
|
416
|
-
4. Ensure type consistency across modules
|
|
417
|
-
|
|
418
|
-
APPROACH:
|
|
419
|
-
- Group related errors by type/module
|
|
420
|
-
- Fix shared types/interfaces first
|
|
421
|
-
- Then fix usage sites
|
|
422
|
-
- Run validation after each group of fixes
|
|
423
|
-
|
|
424
|
-
REPORT: Summary of remaining errors and fixes applied.`,
|
|
425
|
-
{run_in_background: false}
|
|
426
|
-
);
|
|
427
|
-
```
|
|
191
|
+
1. Spawn single cleanup agent (blocking mode)
|
|
192
|
+
2. Agent analyzes remaining errors across files
|
|
193
|
+
3. Groups errors by type/module, fixes shared types first, then usage sites
|
|
194
|
+
4. Commit after completion
|
|
428
195
|
|
|
429
196
|
---
|
|
430
197
|
|
|
431
|
-
## State
|
|
198
|
+
## State Tracking (Optional)
|
|
432
199
|
|
|
433
|
-
|
|
200
|
+
Maintain `/tmp/phase-state.json`:
|
|
434
201
|
|
|
435
202
|
```json
|
|
436
203
|
{
|
|
437
|
-
"sessionId": "cfn-fix-123456
|
|
204
|
+
"sessionId": "cfn-fix-123456",
|
|
438
205
|
"language": "typescript",
|
|
439
|
-
"
|
|
206
|
+
"phase": "1",
|
|
440
207
|
"initialErrors": 150,
|
|
441
208
|
"currentErrors": 45,
|
|
442
|
-
"
|
|
443
|
-
"
|
|
444
|
-
{"file": "src/types/api.ts", "status": "completed", "dependents": 15}
|
|
445
|
-
],
|
|
446
|
-
"phase1Files": [
|
|
447
|
-
{"file": "src/api/handler.ts", "attempts": 1, "status": "in_progress", "agentId": "abc123"}
|
|
448
|
-
],
|
|
449
|
-
"deferredFiles": [],
|
|
450
|
-
"activeAgents": ["abc123", "def456"]
|
|
209
|
+
"phase0Files": [{"file": "src/types/api.ts", "status": "completed"}],
|
|
210
|
+
"activeAgents": ["abc123"]
|
|
451
211
|
}
|
|
452
212
|
```
|
|
453
213
|
|
|
454
214
|
---
|
|
455
215
|
|
|
456
|
-
##
|
|
457
|
-
|
|
458
|
-
| Phase | Purpose | Execution | Agent Count |
|
|
459
|
-
|-------|---------|-----------|-------------|
|
|
460
|
-
| 0 | Root-cause files | Sequential | 1 at a time |
|
|
461
|
-
| 1 | Parallel fixes | Continuous spawn | Up to 5 |
|
|
462
|
-
| 2 | Cross-file cleanup | Sequential | 1 dedicated |
|
|
216
|
+
## Reference
|
|
463
217
|
|
|
464
|
-
**
|
|
465
|
-
- Rust: `rust-developer`
|
|
466
|
-
- TypeScript: `typescript-specialist`
|
|
467
|
-
|
|
468
|
-
**Validation Hook:**
|
|
218
|
+
**Post-edit validation:**
|
|
469
219
|
```bash
|
|
470
220
|
.claude/hooks/cfn-invoke-post-edit.sh [FILE] --agent-id [ID]
|
|
471
221
|
```
|
|
472
222
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
-
|
|
478
|
-
|
|
479
|
-
|
|
223
|
+
**Agent report format:**
|
|
224
|
+
```
|
|
225
|
+
SUMMARY: [2 sentences: what was fixed, outcome]
|
|
226
|
+
FIXES APPLIED: [count]
|
|
227
|
+
- Line X: [fix description]
|
|
228
|
+
ERRORS FIXED: [count]
|
|
229
|
+
VALIDATION: [PASS/FAIL]
|
|
230
|
+
REMAINING ERRORS: [count or "none"]
|
|
231
|
+
```
|
|
480
232
|
|
|
481
233
|
---
|
|
482
234
|
|
|
483
235
|
## Version History
|
|
484
|
-
-
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
-
|
|
488
|
-
-
|
|
236
|
+
- v3.1.0 (2025-12-21) - Continuous error tracking, incremental/cached builds, background commits
|
|
237
|
+
- v3.0.0 (2025-12-21) - Sparse rewrite: removed 200 lines, consolidated duplicates, moved quick reference to top
|
|
238
|
+
- v2.2.0 (2025-12-21) - Clarified background mode (Phase 1 only), no manual monitoring
|
|
239
|
+
- v2.1.0 (2025-12-21) - Added quick reference, commit every 20 files
|
|
240
|
+
- v2.0.0 (2025-12-21) - Added Phase 0 strategic root-cause files
|
|
241
|
+
- v1.0.0 (2025-12-21) - Initial implementation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow-novice",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.37",
|
|
4
4
|
"description": "Claude Flow Novice - Advanced orchestration platform for multi-agent AI workflows with CFN Loop architecture\n\nIncludes Local RuVector Accelerator and all CFN skills for complete functionality.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|