claude-flow-novice 2.18.29 → 2.18.30
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 +174 -300
- package/package.json +1 -1
|
@@ -4,423 +4,297 @@ argument-hint: "<language> [--max-parallel=5] [--max-cycles=10]"
|
|
|
4
4
|
allowed-tools: ["Task", "TaskOutput", "TodoWrite", "Read", "Bash"]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# CFN Fix Errors - Coordination Mode
|
|
7
|
+
# CFN Fix Errors - Agent Coordination Mode
|
|
8
8
|
|
|
9
|
-
**Version:** 1.
|
|
9
|
+
**Version:** 1.1.0 | **Date:** 2025-12-21 | **Status:** Production Ready
|
|
10
10
|
|
|
11
11
|
## Quick Overview
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Main chat coordinates up to 5 background agents to fix compilation errors in parallel. Each agent works on one file using Cerebras acceleration and post-edit validation.
|
|
14
14
|
|
|
15
15
|
### Key Features
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **Post-
|
|
20
|
-
- **Cerebras
|
|
21
|
-
- **
|
|
22
|
-
- **Continuous Spawning:** New agent launches immediately when slot opens
|
|
16
|
+
- **Max 5 parallel agents** with continuous spawning
|
|
17
|
+
- **Single-file focus** - each agent fixes one file only
|
|
18
|
+
- **2-attempt retry** logic per file before deferring to Phase 2
|
|
19
|
+
- **Post-edit validation** confirms fixes are correct
|
|
20
|
+
- **Cerebras gates** prevent semantic changes (12 structural validations)
|
|
21
|
+
- **Automatic Phase 2** transition at <40 errors
|
|
23
22
|
|
|
24
23
|
### When to Use
|
|
25
24
|
- 20+ compilation errors
|
|
26
|
-
-
|
|
27
|
-
- Errors are mostly mechanical (type mismatches, imports, syntax)
|
|
25
|
+
- Errors are mostly mechanical (imports, types, syntax)
|
|
28
26
|
- Want visibility into agent progress
|
|
27
|
+
- Need fast bulk error reduction
|
|
29
28
|
|
|
30
29
|
---
|
|
31
30
|
|
|
32
|
-
## Execution Instructions (
|
|
31
|
+
## Execution Instructions (Follow These Steps)
|
|
33
32
|
|
|
34
|
-
### Step 1: Parse Arguments
|
|
33
|
+
### Step 1: Parse Arguments and Initialize
|
|
34
|
+
|
|
35
|
+
**YOU SHOULD:** Parse the command arguments and set up session tracking.
|
|
35
36
|
|
|
36
37
|
```bash
|
|
37
|
-
#
|
|
38
|
-
LANGUAGE="
|
|
39
|
-
LANGUAGE=$(echo "$LANGUAGE" | sed 's/--max-parallel[[:space:]]*[0-9]*//' | sed 's/--max-cycles[[:space:]]*[0-9]*//' | xargs)
|
|
38
|
+
# Extract language from arguments (first word before any flags)
|
|
39
|
+
LANGUAGE="typescript" # or "rust" from user's command
|
|
40
40
|
|
|
41
|
+
# Parse optional flags (use defaults if not provided)
|
|
41
42
|
MAX_PARALLEL=5
|
|
42
43
|
MAX_CYCLES=10
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
--max-parallel=*) MAX_PARALLEL="${arg#*=}" ;;
|
|
47
|
-
--max-cycles=*) MAX_CYCLES="${arg#*=}" ;;
|
|
48
|
-
esac
|
|
49
|
-
done
|
|
50
|
-
|
|
51
|
-
# Validate language
|
|
52
|
-
if [[ ! "$LANGUAGE" =~ ^(rust|typescript|ts)$ ]]; then
|
|
53
|
-
echo "ERROR: Language must be: rust, typescript, ts"
|
|
54
|
-
exit 1
|
|
55
|
-
fi
|
|
56
|
-
|
|
57
|
-
# Normalize typescript
|
|
58
|
-
if [[ "$LANGUAGE" == "ts" ]]; then
|
|
59
|
-
LANGUAGE="typescript"
|
|
60
|
-
fi
|
|
61
|
-
|
|
62
|
-
SESSION_ID="cfn-fix-$(date +%s%N | tail -c 7)-${RANDOM}"
|
|
45
|
+
# Generate unique session ID
|
|
46
|
+
SESSION_ID="cfn-fix-$(date +%s | tail -c 6)-${RANDOM}"
|
|
63
47
|
echo "Session ID: $SESSION_ID | Language: $LANGUAGE | Max Parallel: $MAX_PARALLEL"
|
|
64
48
|
```
|
|
65
49
|
|
|
66
|
-
|
|
50
|
+
**VALIDATE:** Language must be "rust", "typescript", or "ts"
|
|
67
51
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
attempts: number;
|
|
72
|
-
status: 'queued' | 'in_progress' | 'success' | 'defer_to_phase2';
|
|
73
|
-
agentId: string | null;
|
|
74
|
-
lastError: string | null;
|
|
75
|
-
}>();
|
|
76
|
-
|
|
77
|
-
const activeAgents = new Map<string, {
|
|
78
|
-
file: string;
|
|
79
|
-
agentId: string;
|
|
80
|
-
taskId: string;
|
|
81
|
-
}>();
|
|
82
|
-
|
|
83
|
-
const phase2Queue: string[] = [];
|
|
84
|
-
let currentCycle = 0;
|
|
85
|
-
```
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Step 2: Get Error Files
|
|
86
55
|
|
|
87
|
-
|
|
56
|
+
**YOU SHOULD:** Run the appropriate type checker and get files with errors.
|
|
88
57
|
|
|
58
|
+
**For Rust:**
|
|
89
59
|
```bash
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
grep "^error\[" | \
|
|
94
|
-
awk -F':' '{print $1}' | \
|
|
95
|
-
sort | uniq -c | sort -rn | \
|
|
96
|
-
awk '{print $2}')
|
|
60
|
+
cd [PROJECT_ROOT]
|
|
61
|
+
SQLX_OFFLINE=true cargo check 2>&1 | grep "^error\[" | awk -F':' '{print $1}' | sort | uniq -c | sort -rn
|
|
62
|
+
```
|
|
97
63
|
|
|
98
|
-
|
|
99
|
-
|
|
64
|
+
**For TypeScript:**
|
|
65
|
+
```bash
|
|
66
|
+
cd [PROJECT_ROOT]
|
|
67
|
+
# Try common script names: typecheck, type-check, or tsc
|
|
68
|
+
npm run typecheck 2>&1 | grep "error TS" | awk -F'(' '{print $1}' | sort | uniq -c | sort -rn
|
|
69
|
+
```
|
|
100
70
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
sort | uniq -c | sort -rn | \
|
|
107
|
-
awk '{print $2}')
|
|
108
|
-
|
|
109
|
-
TOTAL_ERRORS=$(npm run type-check 2>&1 | grep -c "error TS")
|
|
110
|
-
fi
|
|
111
|
-
|
|
112
|
-
echo "Found $TOTAL_ERRORS errors across $(echo "$ERROR_FILES" | wc -l) files"
|
|
113
|
-
|
|
114
|
-
# Initialize file state
|
|
115
|
-
for file in $ERROR_FILES; do
|
|
116
|
-
fileState.set(file, {
|
|
117
|
-
attempts: 0,
|
|
118
|
-
status: 'queued',
|
|
119
|
-
agentId: null,
|
|
120
|
-
lastError: null
|
|
121
|
-
});
|
|
122
|
-
done
|
|
71
|
+
**OUTPUT FORMAT:**
|
|
72
|
+
```
|
|
73
|
+
45 src/api/handler.ts
|
|
74
|
+
32 src/db/models.ts
|
|
75
|
+
18 src/utils/helpers.ts
|
|
123
76
|
```
|
|
124
77
|
|
|
125
|
-
|
|
78
|
+
**YOU SHOULD:** Store this list and track state for each file:
|
|
79
|
+
- `attempts`: 0-2 (retry counter)
|
|
80
|
+
- `status`: "queued" | "in_progress" | "success" | "defer"
|
|
81
|
+
- `agentId`: null | "agent-session-file"
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### Step 3: Spawn Agents (Continuous Loop)
|
|
86
|
+
|
|
87
|
+
**YOU SHOULD:** Spawn agents continuously, maintaining exactly 5 active agents at any time.
|
|
88
|
+
|
|
89
|
+
**Agent Spawn Pattern:**
|
|
126
90
|
|
|
127
91
|
```typescript
|
|
128
|
-
//
|
|
129
|
-
while (fileQueue.length > 0 || activeAgents.
|
|
92
|
+
// While there are files to process OR active agents running:
|
|
93
|
+
while (fileQueue.length > 0 || activeAgents.length > 0) {
|
|
130
94
|
|
|
131
|
-
// Spawn
|
|
132
|
-
while (activeAgents.
|
|
95
|
+
// Spawn up to 5 agents
|
|
96
|
+
while (activeAgents.length < MAX_PARALLEL && fileQueue.length > 0) {
|
|
133
97
|
const file = fileQueue.shift();
|
|
134
|
-
const
|
|
98
|
+
const agentId = `${LANGUAGE}-fixer-${SESSION_ID}-${sanitize(file)}`;
|
|
99
|
+
|
|
100
|
+
// Use Task tool with background=true
|
|
101
|
+
const taskId = Task("rust-developer" OR "typescript-specialist",
|
|
102
|
+
`[SEE AGENT PROMPT BELOW]`,
|
|
103
|
+
{run_in_background: true}
|
|
104
|
+
);
|
|
135
105
|
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
106
|
+
// Track this agent
|
|
107
|
+
activeAgents.push({file, agentId, taskId, attempts: 1});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Monitor agents (non-blocking check)
|
|
111
|
+
for each activeAgent {
|
|
112
|
+
const result = TaskOutput(agent.taskId, {block: false, timeout: 0});
|
|
113
|
+
|
|
114
|
+
if (result.status === 'completed') {
|
|
115
|
+
// Parse result: SUCCESS | RETRY | DEFER
|
|
116
|
+
if (result.output.includes('SUCCESS')) {
|
|
117
|
+
// File fixed! Remove from queue
|
|
118
|
+
} else if (agent.attempts < 2) {
|
|
119
|
+
// Retry: add back to queue, increment attempts
|
|
120
|
+
fileQueue.push(file);
|
|
121
|
+
fileState[file].attempts++;
|
|
122
|
+
} else {
|
|
123
|
+
// 2 attempts failed: defer to Phase 2
|
|
124
|
+
phase2Queue.push(file);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Remove from active agents (frees slot for next file)
|
|
128
|
+
activeAgents.remove(agent);
|
|
139
129
|
}
|
|
130
|
+
}
|
|
140
131
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
state.agentId = agentId;
|
|
132
|
+
// Small delay to prevent tight loop
|
|
133
|
+
sleep(1 second);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
146
136
|
|
|
147
|
-
|
|
137
|
+
**AGENT PROMPT TEMPLATE:**
|
|
148
138
|
|
|
149
|
-
|
|
139
|
+
Use this exact prompt structure for spawned agents:
|
|
140
|
+
|
|
141
|
+
```
|
|
150
142
|
AGENT_ID="${agentId}"
|
|
151
143
|
FILE_PATH="${file}"
|
|
152
144
|
SESSION_ID="${SESSION_ID}"
|
|
153
|
-
ATTEMPT=${
|
|
145
|
+
ATTEMPT=${attempts}/2
|
|
154
146
|
|
|
155
|
-
TASK: Fix compilation errors in a single file using Cerebras acceleration
|
|
147
|
+
TASK: Fix compilation errors in a single file using Cerebras acceleration.
|
|
156
148
|
|
|
157
149
|
WORKFLOW:
|
|
158
150
|
1. Read file: ${file}
|
|
159
151
|
|
|
160
|
-
2. Call single-file
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
152
|
+
2. Call Cerebras single-file fixer:
|
|
153
|
+
[FOR RUST]
|
|
154
|
+
npx tsx /path/to/cerebras-gated-fixer-v2.ts --file="${file}" --agent-id="${agentId}"
|
|
155
|
+
|
|
156
|
+
[FOR TYPESCRIPT]
|
|
157
|
+
npx tsx /path/to/typescript-gated-fixer-v2.ts --file="${file}" --agent-id="${agentId}"
|
|
164
158
|
|
|
165
159
|
3. Validate with post-edit pipeline:
|
|
166
|
-
./.claude/hooks/cfn-invoke-post-edit.sh "${
|
|
160
|
+
./.claude/hooks/cfn-invoke-post-edit.sh "${file}" --agent-id "${agentId}"
|
|
167
161
|
|
|
168
162
|
4. Return status:
|
|
169
163
|
- If post-edit validation PASSES (exit 0): Return "SUCCESS"
|
|
170
|
-
- If post-edit validation FAILS (exit 1): Return "RETRY" (
|
|
164
|
+
- If post-edit validation FAILS (exit 1): Return "RETRY" (attempt 1) or "DEFER" (attempt 2)
|
|
171
165
|
|
|
172
|
-
CEREBRAS GATES
|
|
166
|
+
CEREBRAS GATES:
|
|
173
167
|
- Phase 1a: Cerebras generates fix
|
|
174
|
-
- Phase 1b:
|
|
175
|
-
- Up to 3 retries
|
|
168
|
+
- Phase 1b: 12 gates validate (LineCount, FnSignature, ImportDup, BraceBalance, SemanticDiff, OrphanedCode, ImportPath, PatternDup, ImplLocation, TypeCast, MatchArm, Regression)
|
|
169
|
+
- Up to 3 retries per gate rejection
|
|
176
170
|
|
|
177
171
|
CRITICAL RESTRICTIONS:
|
|
178
|
-
- DO NOT run eslint, cargo clippy, cargo
|
|
179
|
-
- DO NOT run cargo check on the entire project
|
|
180
|
-
- DO NOT run npm run type-check on the entire project
|
|
172
|
+
- DO NOT run eslint, cargo clippy, cargo check, or npm run typecheck on ENTIRE codebase
|
|
181
173
|
- Work ONLY on file: ${file}
|
|
182
|
-
- Use Cerebras
|
|
174
|
+
- Use Cerebras for speed
|
|
183
175
|
- Post-edit validation runs on this file only
|
|
184
176
|
|
|
185
|
-
POST-EDIT VALIDATION (MANDATORY):
|
|
186
|
-
After Cerebras applies fixes, run:
|
|
187
|
-
./.claude/hooks/cfn-invoke-post-edit.sh "${FILE_PATH}" --agent-id "${AGENT_ID}"
|
|
188
|
-
|
|
189
177
|
SUCCESS CRITERIA:
|
|
190
178
|
Post-edit pipeline returns exit code 0
|
|
191
179
|
|
|
192
|
-
RETURN
|
|
193
|
-
{
|
|
194
|
-
"status": "SUCCESS" | "RETRY" | "DEFER",
|
|
195
|
-
"file": "${file}",
|
|
196
|
-
"attempts": ${state.attempts},
|
|
197
|
-
"errors_fixed": <number>,
|
|
198
|
-
"validation_passed": <boolean>
|
|
199
|
-
}
|
|
200
|
-
`, {run_in_background: true});
|
|
201
|
-
|
|
202
|
-
// Track active agent
|
|
203
|
-
activeAgents.set(taskId, {
|
|
204
|
-
file,
|
|
205
|
-
agentId,
|
|
206
|
-
taskId
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
echo(`Spawned agent ${agentId} for ${file} (attempt ${state.attempts}/2)`);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Monitor active agents (continuous)
|
|
213
|
-
if (activeAgents.size > 0) {
|
|
214
|
-
// Check for completed agents (non-blocking)
|
|
215
|
-
for (const [taskId, agent] of activeAgents.entries()) {
|
|
216
|
-
const result = TaskOutput(taskId, {block: false, timeout: 0});
|
|
217
|
-
|
|
218
|
-
if (result.status === 'completed') {
|
|
219
|
-
const state = fileState.get(agent.file);
|
|
220
|
-
|
|
221
|
-
// Parse result
|
|
222
|
-
if (result.output.includes('SUCCESS')) {
|
|
223
|
-
state.status = 'success';
|
|
224
|
-
echo(`✓ ${agent.file} - Fixed successfully`);
|
|
225
|
-
} else if (result.output.includes('DEFER') || state.attempts >= 2) {
|
|
226
|
-
state.status = 'defer_to_phase2';
|
|
227
|
-
phase2Queue.push(agent.file);
|
|
228
|
-
echo(`→ ${agent.file} - Deferred to Phase 2 (${state.attempts} attempts)`);
|
|
229
|
-
} else {
|
|
230
|
-
// Retry
|
|
231
|
-
state.status = 'queued';
|
|
232
|
-
fileQueue.push(agent.file);
|
|
233
|
-
echo(`↻ ${agent.file} - Retrying (attempt ${state.attempts + 1}/2)`);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Remove from active agents
|
|
237
|
-
activeAgents.delete(taskId);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Small delay to prevent tight loop
|
|
242
|
-
await sleep(1000);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
180
|
+
RETURN: Print "SUCCESS" or "DEFER" clearly in your final output.
|
|
245
181
|
```
|
|
246
182
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
```bash
|
|
250
|
-
# Wait for all agents to complete
|
|
251
|
-
echo "Waiting for all agents to complete cycle $currentCycle..."
|
|
252
|
-
|
|
253
|
-
while activeAgents.size > 0; do
|
|
254
|
-
# Block until any agent completes
|
|
255
|
-
for (const [taskId, agent] of activeAgents.entries()) {
|
|
256
|
-
const result = TaskOutput(taskId, {block: true, timeout: 30000});
|
|
257
|
-
|
|
258
|
-
if (result.status === 'completed') {
|
|
259
|
-
// Process result (same as Step 4)
|
|
260
|
-
activeAgents.delete(taskId);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
done
|
|
265
|
-
|
|
266
|
-
# Rerun error check
|
|
267
|
-
echo "Cycle $currentCycle complete. Rechecking errors..."
|
|
268
|
-
|
|
269
|
-
if [[ "$LANGUAGE" == "rust" ]]; then
|
|
270
|
-
NEW_ERROR_COUNT=$(SQLX_OFFLINE=true cargo check 2>&1 | grep -c "^error\[")
|
|
271
|
-
else
|
|
272
|
-
NEW_ERROR_COUNT=$(npm run type-check 2>&1 | grep -c "error TS")
|
|
273
|
-
fi
|
|
183
|
+
---
|
|
274
184
|
|
|
275
|
-
|
|
185
|
+
### Step 4: Cycle Completion and Phase Transition
|
|
276
186
|
|
|
277
|
-
|
|
278
|
-
PREV_ERROR_COUNT=$TOTAL_ERRORS
|
|
279
|
-
TOTAL_ERRORS=$NEW_ERROR_COUNT
|
|
280
|
-
currentCycle=$((currentCycle + 1))
|
|
281
|
-
```
|
|
187
|
+
**YOU SHOULD:** After all agents complete (activeAgents.length === 0), check if Phase 2 is needed.
|
|
282
188
|
|
|
283
|
-
|
|
189
|
+
**Recheck Error Count:**
|
|
284
190
|
|
|
285
191
|
```bash
|
|
286
|
-
#
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
# Condition 1: Error count below threshold
|
|
290
|
-
if [ $TOTAL_ERRORS -lt 40 ]; then
|
|
291
|
-
echo "Error count below 40 - proceeding to Phase 2"
|
|
292
|
-
PROCEED_TO_PHASE2=true
|
|
293
|
-
fi
|
|
294
|
-
|
|
295
|
-
# Condition 2: No progress made
|
|
296
|
-
if [ $TOTAL_ERRORS -eq $PREV_ERROR_COUNT ] && [ $currentCycle -gt 1 ]; then
|
|
297
|
-
echo "No progress made - proceeding to Phase 2"
|
|
298
|
-
PROCEED_TO_PHASE2=true
|
|
299
|
-
fi
|
|
300
|
-
|
|
301
|
-
# Condition 3: Max cycles reached
|
|
302
|
-
if [ $currentCycle -ge $MAX_CYCLES ]; then
|
|
303
|
-
echo "Max cycles reached - proceeding to Phase 2"
|
|
304
|
-
PROCEED_TO_PHASE2=true
|
|
305
|
-
fi
|
|
306
|
-
|
|
307
|
-
# Condition 4: All files processed
|
|
308
|
-
if [ ${#fileQueue[@]} -eq 0 ] && [ ${#phase2Queue[@]} -eq 0 ]; then
|
|
309
|
-
echo "All files processed successfully!"
|
|
310
|
-
PROCEED_TO_PHASE2=false
|
|
311
|
-
fi
|
|
312
|
-
|
|
313
|
-
if [ "$PROCEED_TO_PHASE2" = true ]; then
|
|
314
|
-
# Proceed to Phase 2
|
|
315
|
-
echo "=== PHASE 2: Dedicated Agent Cleanup ==="
|
|
316
|
-
else
|
|
317
|
-
# Continue next cycle
|
|
318
|
-
echo "=== Continuing Phase 1: Cycle $currentCycle ==="
|
|
319
|
-
# Go back to Step 3 (get new error files)
|
|
320
|
-
fi
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### Step 7: Phase 2 (Dedicated Agent Cleanup)
|
|
192
|
+
# Rust
|
|
193
|
+
SQLX_OFFLINE=true cargo check 2>&1 | grep -c "^error\["
|
|
324
194
|
|
|
325
|
-
|
|
326
|
-
|
|
195
|
+
# TypeScript
|
|
196
|
+
npm run typecheck 2>&1 | grep -c "error TS"
|
|
197
|
+
```
|
|
327
198
|
|
|
328
|
-
|
|
199
|
+
**Phase 2 Triggers:**
|
|
200
|
+
- Error count < 40
|
|
201
|
+
- No progress made (same error count as before)
|
|
202
|
+
- Max cycles reached
|
|
203
|
+
- All files processed (queue empty, no deferrals)
|
|
329
204
|
|
|
330
|
-
|
|
331
|
-
PHASE2_FILES=$(echo "$ERROR_FILES" | head -20)
|
|
205
|
+
**IF Phase 2 needed:**
|
|
332
206
|
|
|
333
|
-
|
|
334
|
-
|
|
207
|
+
```typescript
|
|
208
|
+
// Spawn dedicated cleanup agent (NOT background - visible)
|
|
209
|
+
Task("rust-developer" OR "typescript-specialist", `
|
|
335
210
|
AGENT_ID="${LANGUAGE}-phase2-${SESSION_ID}"
|
|
336
211
|
|
|
337
212
|
TASK: Fix remaining compilation errors after Phase 1 bulk processing.
|
|
338
213
|
|
|
339
214
|
CONTEXT:
|
|
340
|
-
- Phase 1
|
|
341
|
-
-
|
|
342
|
-
-
|
|
215
|
+
- Phase 1 processed files with Cerebras acceleration
|
|
216
|
+
- ${ERROR_COUNT} errors remaining
|
|
217
|
+
- Errors require context-aware fixes
|
|
343
218
|
|
|
344
|
-
WORKING DIRECTORY:
|
|
345
|
-
${LANGUAGE === 'rust' ? 'RUST_PROJECT_PATH' : 'TYPESCRIPT_PROJECT_PATH'}
|
|
219
|
+
WORKING DIRECTORY: [PROJECT_ROOT]
|
|
346
220
|
|
|
347
|
-
STEP 1: Get
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
: 'npm run type-check 2>&1 | grep -E "error TS" | sort | uniq -c | sort -rn'}
|
|
221
|
+
STEP 1: Get error locations
|
|
222
|
+
[RUST] SQLX_OFFLINE=true cargo check 2>&1 | grep -E "^error\\[E" | sort | uniq -c
|
|
223
|
+
[TYPESCRIPT] npm run typecheck 2>&1 | grep -E "error TS" | sort | uniq -c
|
|
351
224
|
|
|
352
|
-
STEP 2: Fix each
|
|
225
|
+
STEP 2: Fix each file
|
|
353
226
|
1. Read FULL file for context
|
|
354
|
-
2. Identify root cause (not
|
|
355
|
-
3. Apply minimal fix
|
|
227
|
+
2. Identify root cause (not symptom)
|
|
228
|
+
3. Apply minimal fix
|
|
356
229
|
4. Run post-edit validation:
|
|
357
|
-
./.claude/hooks/cfn-invoke-post-edit.sh "
|
|
230
|
+
./.claude/hooks/cfn-invoke-post-edit.sh "$FILE" --agent-id "${AGENT_ID}"
|
|
358
231
|
5. Verify with compiler after EACH file
|
|
359
232
|
|
|
360
233
|
RULES:
|
|
361
234
|
- Read FULL file before editing
|
|
362
|
-
- Preserve ALL existing imports
|
|
363
|
-
-
|
|
364
|
-
- Fix root causes first (cascading errors will resolve)
|
|
235
|
+
- Preserve ALL existing imports
|
|
236
|
+
- Fix root causes first
|
|
365
237
|
- Verify after EACH file
|
|
366
238
|
- Run post-edit pipeline after EACH edit
|
|
367
239
|
|
|
368
240
|
RESTRICTIONS:
|
|
369
|
-
- DO NOT run
|
|
241
|
+
- DO NOT run linters on entire codebase
|
|
370
242
|
- Work on one file at a time
|
|
371
|
-
- Validate each fix before moving to next
|
|
372
|
-
|
|
373
|
-
COMMON ERROR TYPES:
|
|
374
|
-
${LANGUAGE === 'rust'
|
|
375
|
-
? '- E0308 (type mismatch): Add explicit casts or fix generics\n- E0412/E0433/E0425 (missing type/import): Add use statements\n- E0599 (wrong method): Fix method chain\n- E0277 (trait not implemented): Add trait implementations\n- E0382 (borrow checker): Fix ownership issues'
|
|
376
|
-
: '- TS2307 (module not found): Fix import paths\n- TS2322 (type mismatch): Add type annotations\n- TS2339 (property not exists): Add interface definitions\n- TS7006 (implicit any): Add explicit types\n- TS2688 (cannot find type): Install @types packages'}
|
|
377
243
|
|
|
378
244
|
Report final error count when done.
|
|
379
245
|
`)
|
|
380
|
-
|
|
381
|
-
fi
|
|
382
246
|
```
|
|
383
247
|
|
|
384
248
|
---
|
|
385
249
|
|
|
386
|
-
##
|
|
250
|
+
## Important Notes
|
|
251
|
+
|
|
252
|
+
### State Tracking
|
|
387
253
|
|
|
388
|
-
|
|
254
|
+
**YOU SHOULD** maintain these data structures in memory:
|
|
389
255
|
|
|
390
256
|
```typescript
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
lastError: string | null; // Last error message
|
|
257
|
+
// File state
|
|
258
|
+
fileState = {
|
|
259
|
+
"src/api.ts": {attempts: 1, status: "in_progress", agentId: "ts-fixer-123-api"},
|
|
260
|
+
"src/db.ts": {attempts: 2, status: "defer", agentId: null}
|
|
396
261
|
}
|
|
397
262
|
|
|
398
|
-
|
|
263
|
+
// Active agents
|
|
264
|
+
activeAgents = [
|
|
265
|
+
{file: "src/api.ts", agentId: "ts-fixer-123-api", taskId: "abc123", attempts: 1}
|
|
266
|
+
]
|
|
267
|
+
|
|
268
|
+
// Phase 2 queue
|
|
269
|
+
phase2Queue = ["src/db.ts", "src/models.ts"]
|
|
399
270
|
```
|
|
400
271
|
|
|
401
|
-
###
|
|
272
|
+
### Error Handling
|
|
402
273
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
agentId: string; // Agent identifier
|
|
407
|
-
taskId: string; // TaskOutput ID for monitoring
|
|
408
|
-
}
|
|
274
|
+
- If agent fails to spawn: Log error, skip file, continue
|
|
275
|
+
- If TaskOutput times out: Treat as DEFER, add to Phase 2
|
|
276
|
+
- If post-edit hook missing: Warn user, continue without validation
|
|
409
277
|
|
|
410
|
-
|
|
411
|
-
|
|
278
|
+
### Progress Reporting
|
|
279
|
+
|
|
280
|
+
**YOU SHOULD** periodically report progress to user:
|
|
281
|
+
- "Spawned agent 3/5 for src/api.ts (attempt 1/2)"
|
|
282
|
+
- "Agent completed: src/utils.ts - SUCCESS"
|
|
283
|
+
- "Agent completed: src/db.ts - DEFER (2 attempts failed)"
|
|
284
|
+
- "Cycle 1 complete: 45 → 23 errors (-22)"
|
|
412
285
|
|
|
413
286
|
---
|
|
414
287
|
|
|
415
288
|
## Related Documentation
|
|
416
289
|
|
|
417
|
-
- **
|
|
290
|
+
- **Cerebras Rust Fixer**: `.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts`
|
|
291
|
+
- **Cerebras TypeScript Fixer**: `.claude/skills/cfn-compilation-error-fixer/lib/fixer/typescript-gated-fixer-v2.ts`
|
|
418
292
|
- **Post-Edit Pipeline**: `.claude/hooks/cfn-invoke-post-edit.sh`
|
|
419
|
-
- **Cerebras Gated Fixer (Rust)**: `.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts`
|
|
420
|
-
- **Cerebras Gated Fixer (TypeScript)**: `.claude/skills/cfn-compilation-error-fixer/lib/fixer/typescript-gated-fixer-v2.ts`
|
|
421
293
|
- **Task Mode Reference**: `.claude/commands/cfn-loop-task.md`
|
|
422
294
|
|
|
423
295
|
---
|
|
424
296
|
|
|
425
|
-
|
|
297
|
+
## Version History
|
|
298
|
+
|
|
299
|
+
- v1.1.0 (2025-12-21) - Clarified instructions, removed pseudocode confusion
|
|
426
300
|
- v1.0.0 (2025-12-21) - Initial coordination mode 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.30",
|
|
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",
|