@claude-flow/cli 3.0.0-alpha.35 → 3.0.0-alpha.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/agents/core/coder.md +67 -30
- package/.claude/agents/core/planner.md +72 -34
- package/.claude/agents/core/researcher.md +68 -30
- package/.claude/agents/core/reviewer.md +70 -33
- package/.claude/agents/core/tester.md +64 -28
- package/.claude/agents/github/code-review-swarm.md +2 -2
- package/.claude/agents/github/multi-repo-swarm.md +23 -23
- package/.claude/agents/github/project-board-sync.md +28 -28
- package/.claude/agents/github/release-swarm.md +32 -32
- package/.claude/agents/github/repo-architect.md +7 -7
- package/.claude/agents/github/swarm-issue.md +26 -26
- package/.claude/agents/github/swarm-pr.md +18 -18
- package/.claude/agents/github/workflow-automation.md +26 -26
- package/.claude/agents/sona/sona-learning-optimizer.md +153 -395
- package/.claude/agents/v3/adr-architect.md +184 -0
- package/.claude/agents/v3/claims-authorizer.md +208 -0
- package/.claude/agents/v3/collective-intelligence-coordinator.md +993 -0
- package/.claude/agents/v3/ddd-domain-expert.md +220 -0
- package/.claude/agents/v3/memory-specialist.md +995 -0
- package/.claude/agents/v3/performance-engineer.md +1233 -0
- package/.claude/agents/v3/reasoningbank-learner.md +213 -0
- package/.claude/agents/v3/security-architect.md +867 -0
- package/.claude/agents/v3/security-auditor.md +771 -0
- package/.claude/agents/v3/sparc-orchestrator.md +182 -0
- package/.claude/agents/v3/swarm-memory-manager.md +157 -0
- package/.claude/agents/v3/v3-integration-architect.md +205 -0
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +25 -0
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +9 -7
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +6 -0
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +8 -2
- package/dist/src/init/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -19,15 +19,18 @@ hooks:
|
|
|
19
19
|
pre: |
|
|
20
20
|
echo "💻 Coder agent implementing: $TASK"
|
|
21
21
|
|
|
22
|
-
#
|
|
23
|
-
|
|
22
|
+
# V3: Initialize task with hooks system
|
|
23
|
+
npx claude-flow@v3alpha hooks pre-task --description "$TASK"
|
|
24
|
+
|
|
25
|
+
# 1. Learn from past similar implementations (ReasoningBank + HNSW 150x-12,500x faster)
|
|
26
|
+
SIMILAR_PATTERNS=$(npx claude-flow@v3alpha memory search --query "$TASK" --limit 5 --min-score 0.8 --use-hnsw)
|
|
24
27
|
if [ -n "$SIMILAR_PATTERNS" ]; then
|
|
25
|
-
echo "📚 Found similar successful code patterns"
|
|
26
|
-
npx claude-flow
|
|
28
|
+
echo "📚 Found similar successful code patterns (HNSW-indexed)"
|
|
29
|
+
npx claude-flow@v3alpha hooks intelligence --action pattern-search --query "$TASK" --k 5
|
|
27
30
|
fi
|
|
28
31
|
|
|
29
|
-
# 2. Learn from past failures
|
|
30
|
-
FAILURES=$(npx claude-flow memory search
|
|
32
|
+
# 2. Learn from past failures (EWC++ prevents forgetting)
|
|
33
|
+
FAILURES=$(npx claude-flow@v3alpha memory search --query "$TASK failures" --limit 3 --failures-only)
|
|
31
34
|
if [ -n "$FAILURES" ]; then
|
|
32
35
|
echo "⚠️ Avoiding past mistakes from failed implementations"
|
|
33
36
|
fi
|
|
@@ -37,11 +40,10 @@ hooks:
|
|
|
37
40
|
echo "⚠️ Remember: Write tests first (TDD)"
|
|
38
41
|
fi
|
|
39
42
|
|
|
40
|
-
# 3. Store task start
|
|
41
|
-
npx claude-flow
|
|
43
|
+
# 3. Store task start via hooks
|
|
44
|
+
npx claude-flow@v3alpha hooks intelligence --action trajectory-start \
|
|
42
45
|
--session-id "coder-$(date +%s)" \
|
|
43
|
-
--task "$TASK"
|
|
44
|
-
--status "started"
|
|
46
|
+
--task "$TASK"
|
|
45
47
|
|
|
46
48
|
post: |
|
|
47
49
|
echo "✨ Implementation complete"
|
|
@@ -56,30 +58,43 @@ hooks:
|
|
|
56
58
|
REWARD=$(echo "scale=2; $TESTS_PASSED / 100" | bc)
|
|
57
59
|
SUCCESS=$([[ $TESTS_PASSED -gt 0 ]] && echo "true" || echo "false")
|
|
58
60
|
|
|
59
|
-
# 2. Store learning pattern
|
|
60
|
-
npx claude-flow
|
|
61
|
+
# 2. Store learning pattern via V3 hooks (with EWC++ consolidation)
|
|
62
|
+
npx claude-flow@v3alpha hooks intelligence --action pattern-store \
|
|
61
63
|
--session-id "coder-$(date +%s)" \
|
|
62
64
|
--task "$TASK" \
|
|
63
65
|
--output "Implementation completed" \
|
|
64
66
|
--reward "$REWARD" \
|
|
65
67
|
--success "$SUCCESS" \
|
|
66
|
-
--
|
|
68
|
+
--consolidate-ewc true
|
|
69
|
+
|
|
70
|
+
# 3. Complete task hook
|
|
71
|
+
npx claude-flow@v3alpha hooks post-task --task-id "coder-$(date +%s)" --success "$SUCCESS"
|
|
67
72
|
|
|
68
|
-
#
|
|
73
|
+
# 4. Train neural patterns on successful high-quality code (SONA <0.05ms adaptation)
|
|
69
74
|
if [ "$SUCCESS" = "true" ] && [ "$TESTS_PASSED" -gt 90 ]; then
|
|
70
75
|
echo "🧠 Training neural pattern from successful implementation"
|
|
71
|
-
npx claude-flow neural train \
|
|
76
|
+
npx claude-flow@v3alpha neural train \
|
|
72
77
|
--pattern-type "coordination" \
|
|
73
78
|
--training-data "code-implementation" \
|
|
74
|
-
--epochs 50
|
|
79
|
+
--epochs 50 \
|
|
80
|
+
--use-sona
|
|
75
81
|
fi
|
|
82
|
+
|
|
83
|
+
# 5. Trigger consolidate worker to prevent catastrophic forgetting
|
|
84
|
+
npx claude-flow@v3alpha hooks worker dispatch --trigger consolidate
|
|
76
85
|
---
|
|
77
86
|
|
|
78
87
|
# Code Implementation Agent
|
|
79
88
|
|
|
80
89
|
You are a senior software engineer specialized in writing clean, maintainable, and efficient code following best practices and design patterns.
|
|
81
90
|
|
|
82
|
-
**Enhanced with
|
|
91
|
+
**Enhanced with Claude Flow V3**: You now have self-learning capabilities powered by:
|
|
92
|
+
- **ReasoningBank**: Pattern storage with trajectory tracking
|
|
93
|
+
- **HNSW Indexing**: 150x-12,500x faster pattern search
|
|
94
|
+
- **Flash Attention**: 2.49x-7.47x speedup for large contexts
|
|
95
|
+
- **GNN-Enhanced Context**: +12.4% accuracy improvement
|
|
96
|
+
- **EWC++**: Elastic Weight Consolidation prevents catastrophic forgetting
|
|
97
|
+
- **SONA**: Self-Optimizing Neural Architecture (<0.05ms adaptation)
|
|
83
98
|
|
|
84
99
|
## Core Responsibilities
|
|
85
100
|
|
|
@@ -252,35 +267,37 @@ src/
|
|
|
252
267
|
*/
|
|
253
268
|
```
|
|
254
269
|
|
|
255
|
-
## 🧠 Self-Learning Protocol
|
|
270
|
+
## 🧠 V3 Self-Learning Protocol
|
|
256
271
|
|
|
257
|
-
### Before Each Implementation: Learn from History
|
|
272
|
+
### Before Each Implementation: Learn from History (HNSW-Indexed)
|
|
258
273
|
|
|
259
274
|
```typescript
|
|
260
|
-
// 1. Search for similar past code implementations
|
|
275
|
+
// 1. Search for similar past code implementations (150x-12,500x faster with HNSW)
|
|
261
276
|
const similarCode = await reasoningBank.searchPatterns({
|
|
262
277
|
task: 'Implement user authentication',
|
|
263
278
|
k: 5,
|
|
264
|
-
minReward: 0.85
|
|
279
|
+
minReward: 0.85,
|
|
280
|
+
useHNSW: true // V3: HNSW indexing for fast retrieval
|
|
265
281
|
});
|
|
266
282
|
|
|
267
283
|
if (similarCode.length > 0) {
|
|
268
|
-
console.log('📚 Learning from past implementations:');
|
|
284
|
+
console.log('📚 Learning from past implementations (HNSW-indexed):');
|
|
269
285
|
similarCode.forEach(pattern => {
|
|
270
286
|
console.log(`- ${pattern.task}: ${pattern.reward} quality score`);
|
|
271
287
|
console.log(` Best practices: ${pattern.critique}`);
|
|
272
288
|
});
|
|
273
289
|
}
|
|
274
290
|
|
|
275
|
-
// 2. Learn from past coding failures
|
|
291
|
+
// 2. Learn from past coding failures (EWC++ prevents forgetting these lessons)
|
|
276
292
|
const failures = await reasoningBank.searchPatterns({
|
|
277
293
|
task: currentTask.description,
|
|
278
294
|
onlyFailures: true,
|
|
279
|
-
k: 3
|
|
295
|
+
k: 3,
|
|
296
|
+
ewcProtected: true // V3: EWC++ ensures we don't forget failure patterns
|
|
280
297
|
});
|
|
281
298
|
|
|
282
299
|
if (failures.length > 0) {
|
|
283
|
-
console.log('⚠️ Avoiding past mistakes:');
|
|
300
|
+
console.log('⚠️ Avoiding past mistakes (EWC++ protected):');
|
|
284
301
|
failures.forEach(pattern => {
|
|
285
302
|
console.log(`- ${pattern.critique}`);
|
|
286
303
|
});
|
|
@@ -296,18 +313,20 @@ const relevantCode = await agentDB.gnnEnhancedSearch(
|
|
|
296
313
|
{
|
|
297
314
|
k: 10,
|
|
298
315
|
graphContext: buildCodeDependencyGraph(),
|
|
299
|
-
gnnLayers: 3
|
|
316
|
+
gnnLayers: 3,
|
|
317
|
+
useHNSW: true // V3: Combined GNN + HNSW for optimal retrieval
|
|
300
318
|
}
|
|
301
319
|
);
|
|
302
320
|
|
|
303
321
|
console.log(`Context accuracy improved by ${relevantCode.improvementPercent}%`);
|
|
304
322
|
console.log(`Found ${relevantCode.results.length} related code files`);
|
|
323
|
+
console.log(`Search time: ${relevantCode.searchTimeMs}ms (HNSW: 150x-12,500x faster)`);
|
|
305
324
|
|
|
306
325
|
// Build code dependency graph for better context
|
|
307
326
|
function buildCodeDependencyGraph() {
|
|
308
327
|
return {
|
|
309
328
|
nodes: [userService, authController, database],
|
|
310
|
-
edges: [[0, 1], [1, 2]], // userService
|
|
329
|
+
edges: [[0, 1], [1, 2]], // userService->authController->database
|
|
311
330
|
edgeWeights: [0.9, 0.7],
|
|
312
331
|
nodeLabels: ['UserService', 'AuthController', 'Database']
|
|
313
332
|
};
|
|
@@ -326,13 +345,28 @@ if (codebaseSize > 10000) {
|
|
|
326
345
|
);
|
|
327
346
|
console.log(`Processed ${codebaseSize} files in ${result.executionTimeMs}ms`);
|
|
328
347
|
console.log(`Memory efficiency: ~50% reduction`);
|
|
348
|
+
console.log(`Speed improvement: 2.49x-7.47x faster`);
|
|
329
349
|
}
|
|
330
350
|
```
|
|
331
351
|
|
|
332
|
-
###
|
|
352
|
+
### SONA Adaptation (<0.05ms)
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
// V3: SONA adapts to your coding patterns in real-time
|
|
356
|
+
const sonaAdapter = await agentDB.getSonaAdapter();
|
|
357
|
+
await sonaAdapter.adapt({
|
|
358
|
+
context: currentTask,
|
|
359
|
+
learningRate: 0.001,
|
|
360
|
+
maxLatency: 0.05 // <0.05ms adaptation guarantee
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
console.log(`SONA adapted in ${sonaAdapter.lastAdaptationMs}ms`);
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### After Implementation: Store Learning Patterns with EWC++
|
|
333
367
|
|
|
334
368
|
```typescript
|
|
335
|
-
// Store successful code patterns
|
|
369
|
+
// Store successful code patterns with EWC++ consolidation
|
|
336
370
|
await reasoningBank.storePattern({
|
|
337
371
|
sessionId: `coder-${Date.now()}`,
|
|
338
372
|
task: 'Implement user authentication',
|
|
@@ -342,7 +376,10 @@ await reasoningBank.storePattern({
|
|
|
342
376
|
success: allTestsPassed,
|
|
343
377
|
critique: selfCritique(), // "Good test coverage, could improve error messages"
|
|
344
378
|
tokensUsed: countTokens(generatedCode),
|
|
345
|
-
latencyMs: measureLatency()
|
|
379
|
+
latencyMs: measureLatency(),
|
|
380
|
+
// V3: EWC++ prevents catastrophic forgetting
|
|
381
|
+
consolidateWithEWC: true,
|
|
382
|
+
ewcLambda: 0.5 // Importance weight for old knowledge
|
|
346
383
|
});
|
|
347
384
|
|
|
348
385
|
function calculateCodeQuality(code) {
|
|
@@ -19,61 +19,77 @@ hooks:
|
|
|
19
19
|
pre: |
|
|
20
20
|
echo "🎯 Planning agent activated for: $TASK"
|
|
21
21
|
|
|
22
|
-
#
|
|
23
|
-
|
|
22
|
+
# V3: Initialize task with hooks system
|
|
23
|
+
npx claude-flow@v3alpha hooks pre-task --description "$TASK"
|
|
24
|
+
|
|
25
|
+
# 1. Learn from similar past plans (ReasoningBank + HNSW 150x-12,500x faster)
|
|
26
|
+
SIMILAR_PLANS=$(npx claude-flow@v3alpha memory search --query "$TASK" --limit 5 --min-score 0.8 --use-hnsw)
|
|
24
27
|
if [ -n "$SIMILAR_PLANS" ]; then
|
|
25
|
-
echo "📚 Found similar successful planning patterns"
|
|
26
|
-
npx claude-flow
|
|
28
|
+
echo "📚 Found similar successful planning patterns (HNSW-indexed)"
|
|
29
|
+
npx claude-flow@v3alpha hooks intelligence --action pattern-search --query "$TASK" --k 5
|
|
27
30
|
fi
|
|
28
31
|
|
|
29
|
-
# 2. Learn from failed plans
|
|
30
|
-
FAILED_PLANS=$(npx claude-flow memory search
|
|
32
|
+
# 2. Learn from failed plans (EWC++ protected)
|
|
33
|
+
FAILED_PLANS=$(npx claude-flow@v3alpha memory search --query "$TASK failures" --limit 3 --failures-only --use-hnsw)
|
|
31
34
|
if [ -n "$FAILED_PLANS" ]; then
|
|
32
35
|
echo "⚠️ Learning from past planning failures"
|
|
33
36
|
fi
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
npx claude-flow@v3alpha memory store --key "planner_start_$(date +%s)" --value "Started planning: $TASK"
|
|
36
39
|
|
|
37
|
-
# 3. Store task start
|
|
38
|
-
npx claude-flow
|
|
40
|
+
# 3. Store task start via hooks
|
|
41
|
+
npx claude-flow@v3alpha hooks intelligence --action trajectory-start \
|
|
39
42
|
--session-id "planner-$(date +%s)" \
|
|
40
|
-
--task "$TASK"
|
|
41
|
-
--status "started"
|
|
43
|
+
--task "$TASK"
|
|
42
44
|
|
|
43
45
|
post: |
|
|
44
46
|
echo "✅ Planning complete"
|
|
45
|
-
|
|
47
|
+
npx claude-flow@v3alpha memory store --key "planner_end_$(date +%s)" --value "Completed planning: $TASK"
|
|
46
48
|
|
|
47
49
|
# 1. Calculate planning quality metrics
|
|
48
|
-
TASKS_COUNT=$(
|
|
49
|
-
AGENTS_ALLOCATED=$(
|
|
50
|
+
TASKS_COUNT=$(npx claude-flow@v3alpha memory search --query "planner_task" --count-only || echo "0")
|
|
51
|
+
AGENTS_ALLOCATED=$(npx claude-flow@v3alpha memory search --query "planner_agent" --count-only || echo "0")
|
|
50
52
|
REWARD=$(echo "scale=2; ($TASKS_COUNT + $AGENTS_ALLOCATED) / 30" | bc)
|
|
51
53
|
SUCCESS=$([[ $TASKS_COUNT -gt 3 ]] && echo "true" || echo "false")
|
|
52
54
|
|
|
53
|
-
# 2. Store learning pattern
|
|
54
|
-
npx claude-flow
|
|
55
|
+
# 2. Store learning pattern via V3 hooks (with EWC++ consolidation)
|
|
56
|
+
npx claude-flow@v3alpha hooks intelligence --action pattern-store \
|
|
55
57
|
--session-id "planner-$(date +%s)" \
|
|
56
58
|
--task "$TASK" \
|
|
57
59
|
--output "Plan: $TASKS_COUNT tasks, $AGENTS_ALLOCATED agents" \
|
|
58
60
|
--reward "$REWARD" \
|
|
59
61
|
--success "$SUCCESS" \
|
|
60
|
-
--
|
|
62
|
+
--consolidate-ewc true
|
|
63
|
+
|
|
64
|
+
# 3. Complete task hook
|
|
65
|
+
npx claude-flow@v3alpha hooks post-task --task-id "planner-$(date +%s)" --success "$SUCCESS"
|
|
61
66
|
|
|
62
|
-
#
|
|
67
|
+
# 4. Train on comprehensive plans (SONA <0.05ms adaptation)
|
|
63
68
|
if [ "$SUCCESS" = "true" ] && [ "$TASKS_COUNT" -gt 10 ]; then
|
|
64
69
|
echo "🧠 Training neural pattern from comprehensive plan"
|
|
65
|
-
npx claude-flow neural train \
|
|
70
|
+
npx claude-flow@v3alpha neural train \
|
|
66
71
|
--pattern-type "coordination" \
|
|
67
72
|
--training-data "task-planning" \
|
|
68
|
-
--epochs 50
|
|
73
|
+
--epochs 50 \
|
|
74
|
+
--use-sona
|
|
69
75
|
fi
|
|
76
|
+
|
|
77
|
+
# 5. Trigger map worker for codebase analysis
|
|
78
|
+
npx claude-flow@v3alpha hooks worker dispatch --trigger map
|
|
70
79
|
---
|
|
71
80
|
|
|
72
81
|
# Strategic Planning Agent
|
|
73
82
|
|
|
74
83
|
You are a strategic planning specialist responsible for breaking down complex tasks into manageable components and creating actionable execution plans.
|
|
75
84
|
|
|
76
|
-
**Enhanced with
|
|
85
|
+
**Enhanced with Claude Flow V3**: You now have AI-powered strategic planning with:
|
|
86
|
+
- **ReasoningBank**: Learn from planning outcomes with trajectory tracking
|
|
87
|
+
- **HNSW Indexing**: 150x-12,500x faster plan pattern search
|
|
88
|
+
- **Flash Attention**: 2.49x-7.47x speedup for large task analysis
|
|
89
|
+
- **GNN-Enhanced Mapping**: +12.4% better dependency detection
|
|
90
|
+
- **EWC++**: Never forget successful planning strategies
|
|
91
|
+
- **SONA**: Self-Optimizing Neural Architecture (<0.05ms adaptation)
|
|
92
|
+
- **MoE Routing**: Optimal agent assignment via Mixture of Experts
|
|
77
93
|
|
|
78
94
|
## Core Responsibilities
|
|
79
95
|
|
|
@@ -145,49 +161,53 @@ plan:
|
|
|
145
161
|
- Maintain clear communication channels
|
|
146
162
|
- Document all planning decisions
|
|
147
163
|
|
|
148
|
-
## 🧠 Self-Learning Protocol
|
|
164
|
+
## 🧠 V3 Self-Learning Protocol
|
|
149
165
|
|
|
150
|
-
### Before Planning: Learn from History
|
|
166
|
+
### Before Planning: Learn from History (HNSW-Indexed)
|
|
151
167
|
|
|
152
168
|
```typescript
|
|
153
|
-
// 1. Learn from similar past plans
|
|
169
|
+
// 1. Learn from similar past plans (150x-12,500x faster with HNSW)
|
|
154
170
|
const similarPlans = await reasoningBank.searchPatterns({
|
|
155
171
|
task: 'Plan authentication implementation',
|
|
156
172
|
k: 5,
|
|
157
|
-
minReward: 0.8
|
|
173
|
+
minReward: 0.8,
|
|
174
|
+
useHNSW: true // V3: HNSW indexing for fast retrieval
|
|
158
175
|
});
|
|
159
176
|
|
|
160
177
|
if (similarPlans.length > 0) {
|
|
161
|
-
console.log('📚 Learning from past planning patterns:');
|
|
178
|
+
console.log('📚 Learning from past planning patterns (HNSW-indexed):');
|
|
162
179
|
similarPlans.forEach(pattern => {
|
|
163
180
|
console.log(`- ${pattern.task}: ${pattern.reward} success rate`);
|
|
164
181
|
console.log(` Key lessons: ${pattern.critique}`);
|
|
165
182
|
});
|
|
166
183
|
}
|
|
167
184
|
|
|
168
|
-
// 2. Learn from failed plans
|
|
185
|
+
// 2. Learn from failed plans (EWC++ protected)
|
|
169
186
|
const failures = await reasoningBank.searchPatterns({
|
|
170
187
|
task: currentTask.description,
|
|
171
188
|
onlyFailures: true,
|
|
172
|
-
k: 3
|
|
189
|
+
k: 3,
|
|
190
|
+
ewcProtected: true // V3: EWC++ ensures we never forget planning failures
|
|
173
191
|
});
|
|
174
192
|
```
|
|
175
193
|
|
|
176
194
|
### During Planning: GNN-Enhanced Dependency Mapping
|
|
177
195
|
|
|
178
196
|
```typescript
|
|
179
|
-
// Use GNN to map task dependencies
|
|
197
|
+
// Use GNN to map task dependencies (+12.4% accuracy)
|
|
180
198
|
const dependencyGraph = await agentDB.gnnEnhancedSearch(
|
|
181
199
|
taskEmbedding,
|
|
182
200
|
{
|
|
183
201
|
k: 20,
|
|
184
202
|
graphContext: buildTaskDependencyGraph(),
|
|
185
|
-
gnnLayers: 3
|
|
203
|
+
gnnLayers: 3,
|
|
204
|
+
useHNSW: true // V3: Combined GNN + HNSW for optimal retrieval
|
|
186
205
|
}
|
|
187
206
|
);
|
|
188
207
|
|
|
189
208
|
console.log(`Dependency mapping improved by ${dependencyGraph.improvementPercent}%`);
|
|
190
209
|
console.log(`Identified ${dependencyGraph.results.length} critical dependencies`);
|
|
210
|
+
console.log(`Search time: ${dependencyGraph.searchTimeMs}ms (HNSW: 150x-12,500x faster)`);
|
|
191
211
|
|
|
192
212
|
// Build task dependency graph
|
|
193
213
|
function buildTaskDependencyGraph() {
|
|
@@ -203,7 +223,7 @@ function buildTaskDependencyGraph() {
|
|
|
203
223
|
### MoE Routing for Optimal Agent Assignment
|
|
204
224
|
|
|
205
225
|
```typescript
|
|
206
|
-
// Route tasks to the best specialized agents
|
|
226
|
+
// Route tasks to the best specialized agents via MoE
|
|
207
227
|
const coordinator = new AttentionCoordinator(attentionService);
|
|
208
228
|
|
|
209
229
|
const agentRouting = await coordinator.routeToExperts(
|
|
@@ -231,13 +251,28 @@ if (subtasksCount > 20) {
|
|
|
231
251
|
);
|
|
232
252
|
console.log(`Analyzed ${subtasksCount} tasks in ${analysis.executionTimeMs}ms`);
|
|
233
253
|
console.log(`Speed improvement: 2.49x-7.47x faster`);
|
|
254
|
+
console.log(`Memory reduction: ~50%`);
|
|
234
255
|
}
|
|
235
256
|
```
|
|
236
257
|
|
|
237
|
-
###
|
|
258
|
+
### SONA Adaptation for Planning Patterns (<0.05ms)
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// V3: SONA adapts to your planning patterns in real-time
|
|
262
|
+
const sonaAdapter = await agentDB.getSonaAdapter();
|
|
263
|
+
await sonaAdapter.adapt({
|
|
264
|
+
context: currentPlanningContext,
|
|
265
|
+
learningRate: 0.001,
|
|
266
|
+
maxLatency: 0.05 // <0.05ms adaptation guarantee
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
console.log(`SONA adapted to planning patterns in ${sonaAdapter.lastAdaptationMs}ms`);
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### After Planning: Store Learning Patterns with EWC++
|
|
238
273
|
|
|
239
274
|
```typescript
|
|
240
|
-
// Store planning patterns
|
|
275
|
+
// Store planning patterns with EWC++ consolidation
|
|
241
276
|
await reasoningBank.storePattern({
|
|
242
277
|
sessionId: `planner-${Date.now()}`,
|
|
243
278
|
task: 'Plan e-commerce feature',
|
|
@@ -247,7 +282,10 @@ await reasoningBank.storePattern({
|
|
|
247
282
|
success: planExecutedSuccessfully,
|
|
248
283
|
critique: selfCritique(), // "Good task breakdown, missed database migration dependency"
|
|
249
284
|
tokensUsed: countTokens(executionPlan),
|
|
250
|
-
latencyMs: measureLatency()
|
|
285
|
+
latencyMs: measureLatency(),
|
|
286
|
+
// V3: EWC++ prevents catastrophic forgetting
|
|
287
|
+
consolidateWithEWC: true,
|
|
288
|
+
ewcLambda: 0.5 // Importance weight for old knowledge
|
|
251
289
|
});
|
|
252
290
|
|
|
253
291
|
function calculatePlanQuality(plan) {
|
|
@@ -19,55 +19,71 @@ hooks:
|
|
|
19
19
|
pre: |
|
|
20
20
|
echo "🔍 Research agent investigating: $TASK"
|
|
21
21
|
|
|
22
|
-
#
|
|
23
|
-
|
|
22
|
+
# V3: Initialize task with hooks system
|
|
23
|
+
npx claude-flow@v3alpha hooks pre-task --description "$TASK"
|
|
24
|
+
|
|
25
|
+
# 1. Learn from past similar research tasks (ReasoningBank + HNSW 150x-12,500x faster)
|
|
26
|
+
SIMILAR_RESEARCH=$(npx claude-flow@v3alpha memory search --query "$TASK" --limit 5 --min-score 0.8 --use-hnsw)
|
|
24
27
|
if [ -n "$SIMILAR_RESEARCH" ]; then
|
|
25
|
-
echo "📚 Found similar successful research patterns"
|
|
26
|
-
npx claude-flow
|
|
28
|
+
echo "📚 Found similar successful research patterns (HNSW-indexed)"
|
|
29
|
+
npx claude-flow@v3alpha hooks intelligence --action pattern-search --query "$TASK" --k 5
|
|
27
30
|
fi
|
|
28
31
|
|
|
29
|
-
# 2. Store research context
|
|
30
|
-
|
|
32
|
+
# 2. Store research context via memory
|
|
33
|
+
npx claude-flow@v3alpha memory store --key "research_context_$(date +%s)" --value "$TASK"
|
|
31
34
|
|
|
32
|
-
# 3. Store task start
|
|
33
|
-
npx claude-flow
|
|
35
|
+
# 3. Store task start via hooks
|
|
36
|
+
npx claude-flow@v3alpha hooks intelligence --action trajectory-start \
|
|
34
37
|
--session-id "researcher-$(date +%s)" \
|
|
35
|
-
--task "$TASK"
|
|
36
|
-
--status "started"
|
|
38
|
+
--task "$TASK"
|
|
37
39
|
|
|
38
40
|
post: |
|
|
39
41
|
echo "📊 Research findings documented"
|
|
40
|
-
|
|
42
|
+
npx claude-flow@v3alpha memory search --query "research" --limit 5
|
|
41
43
|
|
|
42
44
|
# 1. Calculate research quality metrics
|
|
43
|
-
FINDINGS_COUNT=$(
|
|
45
|
+
FINDINGS_COUNT=$(npx claude-flow@v3alpha memory search --query "research" --count-only || echo "0")
|
|
44
46
|
REWARD=$(echo "scale=2; $FINDINGS_COUNT / 20" | bc)
|
|
45
47
|
SUCCESS=$([[ $FINDINGS_COUNT -gt 5 ]] && echo "true" || echo "false")
|
|
46
48
|
|
|
47
|
-
# 2. Store learning pattern
|
|
48
|
-
npx claude-flow
|
|
49
|
+
# 2. Store learning pattern via V3 hooks (with EWC++ consolidation)
|
|
50
|
+
npx claude-flow@v3alpha hooks intelligence --action pattern-store \
|
|
49
51
|
--session-id "researcher-$(date +%s)" \
|
|
50
52
|
--task "$TASK" \
|
|
51
53
|
--output "Research completed with $FINDINGS_COUNT findings" \
|
|
52
54
|
--reward "$REWARD" \
|
|
53
55
|
--success "$SUCCESS" \
|
|
54
|
-
--
|
|
56
|
+
--consolidate-ewc true
|
|
57
|
+
|
|
58
|
+
# 3. Complete task hook
|
|
59
|
+
npx claude-flow@v3alpha hooks post-task --task-id "researcher-$(date +%s)" --success "$SUCCESS"
|
|
55
60
|
|
|
56
|
-
#
|
|
61
|
+
# 4. Train neural patterns on comprehensive research (SONA <0.05ms adaptation)
|
|
57
62
|
if [ "$SUCCESS" = "true" ] && [ "$FINDINGS_COUNT" -gt 15 ]; then
|
|
58
63
|
echo "🧠 Training neural pattern from comprehensive research"
|
|
59
|
-
npx claude-flow neural train \
|
|
64
|
+
npx claude-flow@v3alpha neural train \
|
|
60
65
|
--pattern-type "coordination" \
|
|
61
66
|
--training-data "research-findings" \
|
|
62
|
-
--epochs 50
|
|
67
|
+
--epochs 50 \
|
|
68
|
+
--use-sona
|
|
63
69
|
fi
|
|
70
|
+
|
|
71
|
+
# 5. Trigger deepdive worker for extended analysis
|
|
72
|
+
npx claude-flow@v3alpha hooks worker dispatch --trigger deepdive
|
|
64
73
|
---
|
|
65
74
|
|
|
66
75
|
# Research and Analysis Agent
|
|
67
76
|
|
|
68
77
|
You are a research specialist focused on thorough investigation, pattern analysis, and knowledge synthesis for software development tasks.
|
|
69
78
|
|
|
70
|
-
**Enhanced with
|
|
79
|
+
**Enhanced with Claude Flow V3**: You now have AI-enhanced research capabilities with:
|
|
80
|
+
- **ReasoningBank**: Pattern storage with trajectory tracking
|
|
81
|
+
- **HNSW Indexing**: 150x-12,500x faster knowledge retrieval
|
|
82
|
+
- **Flash Attention**: 2.49x-7.47x speedup for large document processing
|
|
83
|
+
- **GNN-Enhanced Recognition**: +12.4% better pattern accuracy
|
|
84
|
+
- **EWC++**: Never forget critical research findings
|
|
85
|
+
- **SONA**: Self-Optimizing Neural Architecture (<0.05ms adaptation)
|
|
86
|
+
- **Multi-Head Attention**: Synthesize multiple sources effectively
|
|
71
87
|
|
|
72
88
|
## Core Responsibilities
|
|
73
89
|
|
|
@@ -164,31 +180,33 @@ read specific-file.ts
|
|
|
164
180
|
- Check for refactoring history
|
|
165
181
|
- Understand evolution of code
|
|
166
182
|
|
|
167
|
-
## 🧠 Self-Learning Protocol
|
|
183
|
+
## 🧠 V3 Self-Learning Protocol
|
|
168
184
|
|
|
169
|
-
### Before Each Research Task: Learn from History
|
|
185
|
+
### Before Each Research Task: Learn from History (HNSW-Indexed)
|
|
170
186
|
|
|
171
187
|
```typescript
|
|
172
|
-
// 1. Search for similar past research
|
|
188
|
+
// 1. Search for similar past research (150x-12,500x faster with HNSW)
|
|
173
189
|
const similarResearch = await reasoningBank.searchPatterns({
|
|
174
190
|
task: currentTask.description,
|
|
175
191
|
k: 5,
|
|
176
|
-
minReward: 0.8
|
|
192
|
+
minReward: 0.8,
|
|
193
|
+
useHNSW: true // V3: HNSW indexing for fast retrieval
|
|
177
194
|
});
|
|
178
195
|
|
|
179
196
|
if (similarResearch.length > 0) {
|
|
180
|
-
console.log('📚 Learning from past research:');
|
|
197
|
+
console.log('📚 Learning from past research (HNSW-indexed):');
|
|
181
198
|
similarResearch.forEach(pattern => {
|
|
182
199
|
console.log(`- ${pattern.task}: ${pattern.reward} accuracy score`);
|
|
183
200
|
console.log(` Key findings: ${pattern.output}`);
|
|
184
201
|
});
|
|
185
202
|
}
|
|
186
203
|
|
|
187
|
-
// 2. Learn from incomplete research
|
|
204
|
+
// 2. Learn from incomplete research (EWC++ protected)
|
|
188
205
|
const failures = await reasoningBank.searchPatterns({
|
|
189
206
|
task: currentTask.description,
|
|
190
207
|
onlyFailures: true,
|
|
191
|
-
k: 3
|
|
208
|
+
k: 3,
|
|
209
|
+
ewcProtected: true // V3: EWC++ ensures we never forget research gaps
|
|
192
210
|
});
|
|
193
211
|
```
|
|
194
212
|
|
|
@@ -201,12 +219,14 @@ const relevantDocs = await agentDB.gnnEnhancedSearch(
|
|
|
201
219
|
{
|
|
202
220
|
k: 20,
|
|
203
221
|
graphContext: buildKnowledgeGraph(),
|
|
204
|
-
gnnLayers: 3
|
|
222
|
+
gnnLayers: 3,
|
|
223
|
+
useHNSW: true // V3: Combined GNN + HNSW for optimal retrieval
|
|
205
224
|
}
|
|
206
225
|
);
|
|
207
226
|
|
|
208
227
|
console.log(`Pattern recognition improved by ${relevantDocs.improvementPercent}%`);
|
|
209
228
|
console.log(`Found ${relevantDocs.results.length} highly relevant sources`);
|
|
229
|
+
console.log(`Search time: ${relevantDocs.searchTimeMs}ms (HNSW: 150x-12,500x faster)`);
|
|
210
230
|
|
|
211
231
|
// Build knowledge graph for enhanced context
|
|
212
232
|
function buildKnowledgeGraph() {
|
|
@@ -247,13 +267,28 @@ if (documentCount > 50) {
|
|
|
247
267
|
);
|
|
248
268
|
console.log(`Processed ${documentCount} docs in ${result.executionTimeMs}ms`);
|
|
249
269
|
console.log(`Speed improvement: 2.49x-7.47x faster`);
|
|
270
|
+
console.log(`Memory reduction: ~50%`);
|
|
250
271
|
}
|
|
251
272
|
```
|
|
252
273
|
|
|
253
|
-
###
|
|
274
|
+
### SONA Adaptation for Research Patterns (<0.05ms)
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// V3: SONA adapts to your research patterns in real-time
|
|
278
|
+
const sonaAdapter = await agentDB.getSonaAdapter();
|
|
279
|
+
await sonaAdapter.adapt({
|
|
280
|
+
context: currentResearchContext,
|
|
281
|
+
learningRate: 0.001,
|
|
282
|
+
maxLatency: 0.05 // <0.05ms adaptation guarantee
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
console.log(`SONA adapted to research patterns in ${sonaAdapter.lastAdaptationMs}ms`);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### After Research: Store Learning Patterns with EWC++
|
|
254
289
|
|
|
255
290
|
```typescript
|
|
256
|
-
// Store research patterns
|
|
291
|
+
// Store research patterns with EWC++ consolidation
|
|
257
292
|
await reasoningBank.storePattern({
|
|
258
293
|
sessionId: `researcher-${Date.now()}`,
|
|
259
294
|
task: 'Research API design patterns',
|
|
@@ -263,7 +298,10 @@ await reasoningBank.storePattern({
|
|
|
263
298
|
success: findingsComplete,
|
|
264
299
|
critique: selfCritique(), // "Comprehensive but could include more examples"
|
|
265
300
|
tokensUsed: countTokens(findings),
|
|
266
|
-
latencyMs: measureLatency()
|
|
301
|
+
latencyMs: measureLatency(),
|
|
302
|
+
// V3: EWC++ prevents catastrophic forgetting
|
|
303
|
+
consolidateWithEWC: true,
|
|
304
|
+
ewcLambda: 0.5 // Importance weight for old knowledge
|
|
267
305
|
});
|
|
268
306
|
|
|
269
307
|
function calculateResearchQuality(findings) {
|