@sparkleideas/ruv-swarm 1.0.18-patch.1
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/README.md +1565 -0
- package/bin/ruv-swarm-clean.js +1872 -0
- package/bin/ruv-swarm-memory.js +119 -0
- package/bin/ruv-swarm-secure-heartbeat.js +1549 -0
- package/bin/ruv-swarm-secure.js +1689 -0
- package/package.json +221 -0
- package/src/agent.ts +342 -0
- package/src/benchmark.js +267 -0
- package/src/claude-flow-enhanced.js +839 -0
- package/src/claude-integration/advanced-commands.js +561 -0
- package/src/claude-integration/core.js +112 -0
- package/src/claude-integration/docs.js +1548 -0
- package/src/claude-integration/env-template.js +39 -0
- package/src/claude-integration/index.js +209 -0
- package/src/claude-integration/remote.js +408 -0
- package/src/cli-diagnostics.js +364 -0
- package/src/cognitive-pattern-evolution.js +1317 -0
- package/src/daa-cognition.js +977 -0
- package/src/daa-service.d.ts +298 -0
- package/src/daa-service.js +1116 -0
- package/src/diagnostics.js +533 -0
- package/src/errors.js +528 -0
- package/src/github-coordinator/README.md +193 -0
- package/src/github-coordinator/claude-hooks.js +162 -0
- package/src/github-coordinator/gh-cli-coordinator.js +260 -0
- package/src/hooks/cli.js +82 -0
- package/src/hooks/index.js +1900 -0
- package/src/index-enhanced.d.ts +371 -0
- package/src/index-enhanced.js +734 -0
- package/src/index.d.ts +287 -0
- package/src/index.js +405 -0
- package/src/index.ts +457 -0
- package/src/logger.js +182 -0
- package/src/logging-config.js +179 -0
- package/src/mcp-daa-tools.js +735 -0
- package/src/mcp-tools-benchmarks.js +328 -0
- package/src/mcp-tools-enhanced.js +2863 -0
- package/src/memory-config.js +42 -0
- package/src/meta-learning-framework.js +1359 -0
- package/src/neural-agent.js +830 -0
- package/src/neural-coordination-protocol.js +1363 -0
- package/src/neural-models/README.md +118 -0
- package/src/neural-models/autoencoder.js +543 -0
- package/src/neural-models/base.js +269 -0
- package/src/neural-models/cnn.js +497 -0
- package/src/neural-models/gnn.js +447 -0
- package/src/neural-models/gru.js +536 -0
- package/src/neural-models/index.js +273 -0
- package/src/neural-models/lstm.js +551 -0
- package/src/neural-models/neural-presets-complete.js +1306 -0
- package/src/neural-models/presets/graph.js +392 -0
- package/src/neural-models/presets/index.js +279 -0
- package/src/neural-models/presets/nlp.js +328 -0
- package/src/neural-models/presets/timeseries.js +368 -0
- package/src/neural-models/presets/vision.js +387 -0
- package/src/neural-models/resnet.js +534 -0
- package/src/neural-models/transformer.js +515 -0
- package/src/neural-models/vae.js +489 -0
- package/src/neural-network-manager.js +1938 -0
- package/src/neural-network.ts +296 -0
- package/src/neural.js +574 -0
- package/src/performance-benchmarks.js +898 -0
- package/src/performance.js +458 -0
- package/src/persistence-pooled.js +695 -0
- package/src/persistence.js +480 -0
- package/src/schemas.js +864 -0
- package/src/security.js +218 -0
- package/src/singleton-container.js +183 -0
- package/src/sqlite-pool.js +587 -0
- package/src/sqlite-worker.js +141 -0
- package/src/types.ts +164 -0
- package/src/utils.ts +286 -0
- package/src/wasm-loader.js +601 -0
- package/src/wasm-loader2.js +404 -0
- package/src/wasm-memory-optimizer.js +783 -0
- package/src/wasm-types.d.ts +63 -0
- package/wasm/README.md +347 -0
- package/wasm/neuro-divergent.wasm +0 -0
- package/wasm/package.json +18 -0
- package/wasm/ruv-fann.wasm +0 -0
- package/wasm/ruv_swarm_simd.wasm +0 -0
- package/wasm/ruv_swarm_wasm.d.ts +391 -0
- package/wasm/ruv_swarm_wasm.js +2164 -0
- package/wasm/ruv_swarm_wasm_bg.wasm +0 -0
- package/wasm/ruv_swarm_wasm_bg.wasm.d.ts +123 -0
- package/wasm/wasm-bindings-loader.mjs +435 -0
- package/wasm/wasm-updates.md +684 -0
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced command documentation for enhanced swarm optimization
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
|
|
8
|
+
class AdvancedCommandsGenerator {
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this.workingDir = options.workingDir || process.cwd();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generate advanced optimization command documentation
|
|
15
|
+
*/
|
|
16
|
+
async generateAdvancedCommands() {
|
|
17
|
+
const commandsDir = path.join(this.workingDir, '.claude', 'commands');
|
|
18
|
+
|
|
19
|
+
// Create subdirectories
|
|
20
|
+
const subdirs = ['optimization', 'analysis', 'training', 'automation'];
|
|
21
|
+
for (const subdir of subdirs) {
|
|
22
|
+
await fs.mkdir(path.join(commandsDir, subdir), { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const commands = {
|
|
26
|
+
// Optimization commands
|
|
27
|
+
'optimization/auto-topology.md': {
|
|
28
|
+
title: 'Automatic Topology Selection',
|
|
29
|
+
content: `# Automatic Topology Selection
|
|
30
|
+
|
|
31
|
+
## Purpose
|
|
32
|
+
Automatically select the optimal swarm topology based on task complexity analysis.
|
|
33
|
+
|
|
34
|
+
## How It Works
|
|
35
|
+
|
|
36
|
+
### 1. Task Analysis
|
|
37
|
+
The system analyzes your task description to determine:
|
|
38
|
+
- Complexity level (simple/medium/complex)
|
|
39
|
+
- Required agent types
|
|
40
|
+
- Estimated duration
|
|
41
|
+
- Resource requirements
|
|
42
|
+
|
|
43
|
+
### 2. Topology Selection
|
|
44
|
+
Based on analysis, it selects:
|
|
45
|
+
- **Star**: For simple, centralized tasks
|
|
46
|
+
- **Mesh**: For medium complexity with flexibility needs
|
|
47
|
+
- **Hierarchical**: For complex tasks requiring structure
|
|
48
|
+
- **Ring**: For sequential processing workflows
|
|
49
|
+
|
|
50
|
+
### 3. Example Usage
|
|
51
|
+
|
|
52
|
+
**Simple Task:**
|
|
53
|
+
\`\`\`
|
|
54
|
+
Tool: mcp__ruv-swarm__task_orchestrate
|
|
55
|
+
Parameters: {"task": "Fix typo in README.md"}
|
|
56
|
+
Result: Automatically uses star topology with single agent
|
|
57
|
+
\`\`\`
|
|
58
|
+
|
|
59
|
+
**Complex Task:**
|
|
60
|
+
\`\`\`
|
|
61
|
+
Tool: mcp__ruv-swarm__task_orchestrate
|
|
62
|
+
Parameters: {"task": "Refactor authentication system with JWT, add tests, update documentation"}
|
|
63
|
+
Result: Automatically uses hierarchical topology with architect, coder, and tester agents
|
|
64
|
+
\`\`\`
|
|
65
|
+
|
|
66
|
+
## Benefits
|
|
67
|
+
- đ¯ Optimal performance for each task type
|
|
68
|
+
- đ¤ Automatic agent assignment
|
|
69
|
+
- ⥠Reduced setup time
|
|
70
|
+
- đ Better resource utilization
|
|
71
|
+
|
|
72
|
+
## Hook Configuration
|
|
73
|
+
The pre-task hook automatically handles topology selection:
|
|
74
|
+
\`\`\`json
|
|
75
|
+
{
|
|
76
|
+
"command": "npx @sparkleideas/ruv-swarm hook pre-task --auto-spawn-agents --optimize-topology"
|
|
77
|
+
}
|
|
78
|
+
\`\`\``,
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
'optimization/parallel-execution.md': {
|
|
82
|
+
title: 'Parallel Task Execution',
|
|
83
|
+
content: `# Parallel Task Execution
|
|
84
|
+
|
|
85
|
+
## Purpose
|
|
86
|
+
Execute independent subtasks in parallel for maximum efficiency.
|
|
87
|
+
|
|
88
|
+
## Coordination Strategy
|
|
89
|
+
|
|
90
|
+
### 1. Task Decomposition
|
|
91
|
+
\`\`\`
|
|
92
|
+
Tool: mcp__ruv-swarm__task_orchestrate
|
|
93
|
+
Parameters: {
|
|
94
|
+
"task": "Build complete REST API with auth, CRUD operations, and tests",
|
|
95
|
+
"strategy": "parallel",
|
|
96
|
+
"maxAgents": 8
|
|
97
|
+
}
|
|
98
|
+
\`\`\`
|
|
99
|
+
|
|
100
|
+
### 2. Parallel Workflows
|
|
101
|
+
The system automatically:
|
|
102
|
+
- Identifies independent components
|
|
103
|
+
- Assigns specialized agents
|
|
104
|
+
- Executes in parallel where possible
|
|
105
|
+
- Synchronizes at dependency points
|
|
106
|
+
|
|
107
|
+
### 3. Example Breakdown
|
|
108
|
+
For the REST API task:
|
|
109
|
+
- **Agent 1 (Architect)**: Design API structure
|
|
110
|
+
- **Agent 2-3 (Coders)**: Implement auth & CRUD in parallel
|
|
111
|
+
- **Agent 4 (Tester)**: Write tests as features complete
|
|
112
|
+
- **Agent 5 (Documenter)**: Update docs continuously
|
|
113
|
+
|
|
114
|
+
## Performance Gains
|
|
115
|
+
- đ 2.8-4.4x faster execution
|
|
116
|
+
- đĒ Optimal CPU utilization
|
|
117
|
+
- đ Automatic load balancing
|
|
118
|
+
- đ Linear scalability with agents
|
|
119
|
+
|
|
120
|
+
## Monitoring
|
|
121
|
+
\`\`\`
|
|
122
|
+
Tool: mcp__ruv-swarm__swarm_monitor
|
|
123
|
+
Parameters: {"interval": 1, "duration": 10}
|
|
124
|
+
\`\`\`
|
|
125
|
+
|
|
126
|
+
Watch real-time parallel execution progress!`,
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
// Analysis commands
|
|
130
|
+
'analysis/performance-bottlenecks.md': {
|
|
131
|
+
title: 'Performance Bottleneck Analysis',
|
|
132
|
+
content: `# Performance Bottleneck Analysis
|
|
133
|
+
|
|
134
|
+
## Purpose
|
|
135
|
+
Identify and resolve performance bottlenecks in your development workflow.
|
|
136
|
+
|
|
137
|
+
## Automated Analysis
|
|
138
|
+
|
|
139
|
+
### 1. Real-time Detection
|
|
140
|
+
The post-task hook automatically analyzes:
|
|
141
|
+
- Execution time vs. complexity
|
|
142
|
+
- Agent utilization rates
|
|
143
|
+
- Resource constraints
|
|
144
|
+
- Operation patterns
|
|
145
|
+
|
|
146
|
+
### 2. Common Bottlenecks
|
|
147
|
+
|
|
148
|
+
**Time Bottlenecks:**
|
|
149
|
+
- Tasks taking > 5 minutes
|
|
150
|
+
- Sequential operations that could parallelize
|
|
151
|
+
- Redundant file operations
|
|
152
|
+
|
|
153
|
+
**Coordination Bottlenecks:**
|
|
154
|
+
- Single agent for complex tasks
|
|
155
|
+
- Unbalanced agent workloads
|
|
156
|
+
- Poor topology selection
|
|
157
|
+
|
|
158
|
+
**Resource Bottlenecks:**
|
|
159
|
+
- High operation count (> 100)
|
|
160
|
+
- Memory constraints
|
|
161
|
+
- I/O limitations
|
|
162
|
+
|
|
163
|
+
### 3. Improvement Suggestions
|
|
164
|
+
|
|
165
|
+
\`\`\`
|
|
166
|
+
Tool: mcp__ruv-swarm__task_results
|
|
167
|
+
Parameters: {"taskId": "task-123", "format": "detailed"}
|
|
168
|
+
|
|
169
|
+
Result includes:
|
|
170
|
+
{
|
|
171
|
+
"bottlenecks": [
|
|
172
|
+
{
|
|
173
|
+
"type": "coordination",
|
|
174
|
+
"severity": "high",
|
|
175
|
+
"description": "Single agent used for complex task",
|
|
176
|
+
"recommendation": "Spawn specialized agents for parallel work"
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"improvements": [
|
|
180
|
+
{
|
|
181
|
+
"area": "execution_time",
|
|
182
|
+
"suggestion": "Use parallel task execution",
|
|
183
|
+
"expectedImprovement": "30-50% time reduction"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
\`\`\`
|
|
188
|
+
|
|
189
|
+
## Continuous Optimization
|
|
190
|
+
The system learns from each task to prevent future bottlenecks!`,
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
'analysis/token-efficiency.md': {
|
|
194
|
+
title: 'Token Usage Optimization',
|
|
195
|
+
content: `# Token Usage Optimization
|
|
196
|
+
|
|
197
|
+
## Purpose
|
|
198
|
+
Reduce token consumption while maintaining quality through intelligent coordination.
|
|
199
|
+
|
|
200
|
+
## Optimization Strategies
|
|
201
|
+
|
|
202
|
+
### 1. Smart Caching
|
|
203
|
+
- Search results cached for 5 minutes
|
|
204
|
+
- File content cached during session
|
|
205
|
+
- Pattern recognition reduces redundant searches
|
|
206
|
+
|
|
207
|
+
### 2. Efficient Coordination
|
|
208
|
+
- Agents share context automatically
|
|
209
|
+
- Avoid duplicate file reads
|
|
210
|
+
- Batch related operations
|
|
211
|
+
|
|
212
|
+
### 3. Measurement & Tracking
|
|
213
|
+
|
|
214
|
+
\`\`\`bash
|
|
215
|
+
# Check token savings after session
|
|
216
|
+
npx @sparkleideas/ruv-swarm hook session-end --export-metrics
|
|
217
|
+
|
|
218
|
+
# Result shows:
|
|
219
|
+
{
|
|
220
|
+
"metrics": {
|
|
221
|
+
"tokensSaved": 15420,
|
|
222
|
+
"operations": 45,
|
|
223
|
+
"efficiency": "343 tokens/operation"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
\`\`\`
|
|
227
|
+
|
|
228
|
+
## Best Practices
|
|
229
|
+
1. **Use Task tool** for complex searches
|
|
230
|
+
2. **Enable caching** in pre-search hooks
|
|
231
|
+
3. **Batch operations** when possible
|
|
232
|
+
4. **Review session summaries** for insights
|
|
233
|
+
|
|
234
|
+
## Token Reduction Results
|
|
235
|
+
- đ 32.3% average token reduction
|
|
236
|
+
- đ¯ More focused operations
|
|
237
|
+
- đ Intelligent result reuse
|
|
238
|
+
- đ Cumulative improvements`,
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
// Training commands
|
|
242
|
+
'training/neural-patterns.md': {
|
|
243
|
+
title: 'Neural Pattern Training',
|
|
244
|
+
content: `# Neural Pattern Training
|
|
245
|
+
|
|
246
|
+
## Purpose
|
|
247
|
+
Continuously improve coordination through neural network learning.
|
|
248
|
+
|
|
249
|
+
## How Training Works
|
|
250
|
+
|
|
251
|
+
### 1. Automatic Learning
|
|
252
|
+
Every successful operation trains the neural networks:
|
|
253
|
+
- Edit patterns for different file types
|
|
254
|
+
- Search strategies that find results faster
|
|
255
|
+
- Task decomposition approaches
|
|
256
|
+
- Agent coordination patterns
|
|
257
|
+
|
|
258
|
+
### 2. Manual Training
|
|
259
|
+
\`\`\`
|
|
260
|
+
Tool: mcp__ruv-swarm__neural_train
|
|
261
|
+
Parameters: {"iterations": 20}
|
|
262
|
+
\`\`\`
|
|
263
|
+
|
|
264
|
+
### 3. Pattern Types
|
|
265
|
+
|
|
266
|
+
**Cognitive Patterns:**
|
|
267
|
+
- Convergent: Focused problem-solving
|
|
268
|
+
- Divergent: Creative exploration
|
|
269
|
+
- Lateral: Alternative approaches
|
|
270
|
+
- Systems: Holistic thinking
|
|
271
|
+
- Critical: Analytical evaluation
|
|
272
|
+
- Abstract: High-level design
|
|
273
|
+
|
|
274
|
+
### 4. Improvement Tracking
|
|
275
|
+
\`\`\`
|
|
276
|
+
Tool: mcp__ruv-swarm__neural_status
|
|
277
|
+
Result: {
|
|
278
|
+
"patterns": {
|
|
279
|
+
"convergent": 0.92,
|
|
280
|
+
"divergent": 0.87,
|
|
281
|
+
"lateral": 0.85
|
|
282
|
+
},
|
|
283
|
+
"improvement": "5.3% since last session",
|
|
284
|
+
"confidence": 0.89
|
|
285
|
+
}
|
|
286
|
+
\`\`\`
|
|
287
|
+
|
|
288
|
+
## Benefits
|
|
289
|
+
- đ§ Learns your coding style
|
|
290
|
+
- đ Improves with each use
|
|
291
|
+
- đ¯ Better task predictions
|
|
292
|
+
- ⥠Faster coordination`,
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
'training/specialization.md': {
|
|
296
|
+
title: 'Agent Specialization Training',
|
|
297
|
+
content: `# Agent Specialization Training
|
|
298
|
+
|
|
299
|
+
## Purpose
|
|
300
|
+
Train agents to become experts in specific domains for better performance.
|
|
301
|
+
|
|
302
|
+
## Specialization Areas
|
|
303
|
+
|
|
304
|
+
### 1. By File Type
|
|
305
|
+
Agents automatically specialize based on file extensions:
|
|
306
|
+
- **.js/.ts**: Modern JavaScript patterns
|
|
307
|
+
- **.py**: Pythonic idioms
|
|
308
|
+
- **.go**: Go best practices
|
|
309
|
+
- **.rs**: Rust safety patterns
|
|
310
|
+
|
|
311
|
+
### 2. By Task Type
|
|
312
|
+
\`\`\`
|
|
313
|
+
Tool: mcp__ruv-swarm__agent_spawn
|
|
314
|
+
Parameters: {
|
|
315
|
+
"type": "coder",
|
|
316
|
+
"capabilities": ["react", "typescript", "testing"]
|
|
317
|
+
}
|
|
318
|
+
\`\`\`
|
|
319
|
+
|
|
320
|
+
### 3. Training Process
|
|
321
|
+
The system trains through:
|
|
322
|
+
- Successful edit operations
|
|
323
|
+
- Code review patterns
|
|
324
|
+
- Error fix approaches
|
|
325
|
+
- Performance optimizations
|
|
326
|
+
|
|
327
|
+
### 4. Specialization Benefits
|
|
328
|
+
\`\`\`
|
|
329
|
+
# Check agent specializations
|
|
330
|
+
Tool: mcp__ruv-swarm__agent_list
|
|
331
|
+
Parameters: {"filter": "active"}
|
|
332
|
+
|
|
333
|
+
Result shows expertise levels:
|
|
334
|
+
{
|
|
335
|
+
"agents": [
|
|
336
|
+
{
|
|
337
|
+
"id": "coder-123",
|
|
338
|
+
"specializations": {
|
|
339
|
+
"javascript": 0.95,
|
|
340
|
+
"react": 0.88,
|
|
341
|
+
"testing": 0.82
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
\`\`\`
|
|
347
|
+
|
|
348
|
+
## Continuous Improvement
|
|
349
|
+
Agents share learnings across sessions for cumulative expertise!`,
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
// Automation commands
|
|
353
|
+
'automation/smart-agents.md': {
|
|
354
|
+
title: 'Smart Agent Auto-Spawning',
|
|
355
|
+
content: `# Smart Agent Auto-Spawning
|
|
356
|
+
|
|
357
|
+
## Purpose
|
|
358
|
+
Automatically spawn the right agents at the right time without manual intervention.
|
|
359
|
+
|
|
360
|
+
## Auto-Spawning Triggers
|
|
361
|
+
|
|
362
|
+
### 1. File Type Detection
|
|
363
|
+
When editing files, agents auto-spawn:
|
|
364
|
+
- **JavaScript/TypeScript**: Coder agent
|
|
365
|
+
- **Markdown**: Researcher agent
|
|
366
|
+
- **JSON/YAML**: Analyst agent
|
|
367
|
+
- **Multiple files**: Coordinator agent
|
|
368
|
+
|
|
369
|
+
### 2. Task Complexity
|
|
370
|
+
\`\`\`
|
|
371
|
+
Simple task: "Fix typo"
|
|
372
|
+
â Single coordinator agent
|
|
373
|
+
|
|
374
|
+
Complex task: "Implement OAuth with Google"
|
|
375
|
+
â Architect + Coder + Tester + Researcher
|
|
376
|
+
\`\`\`
|
|
377
|
+
|
|
378
|
+
### 3. Dynamic Scaling
|
|
379
|
+
The system monitors workload and spawns additional agents when:
|
|
380
|
+
- Task queue grows
|
|
381
|
+
- Complexity increases
|
|
382
|
+
- Parallel opportunities exist
|
|
383
|
+
|
|
384
|
+
## Configuration
|
|
385
|
+
Already enabled in settings.json:
|
|
386
|
+
\`\`\`json
|
|
387
|
+
{
|
|
388
|
+
"hooks": [{
|
|
389
|
+
"matcher": "^Task$",
|
|
390
|
+
"command": "npx @sparkleideas/ruv-swarm hook pre-task --auto-spawn-agents"
|
|
391
|
+
}]
|
|
392
|
+
}
|
|
393
|
+
\`\`\`
|
|
394
|
+
|
|
395
|
+
## Benefits
|
|
396
|
+
- đ¤ Zero manual agent management
|
|
397
|
+
- đ¯ Perfect agent selection
|
|
398
|
+
- đ Dynamic scaling
|
|
399
|
+
- đž Resource efficiency`,
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
'automation/self-healing.md': {
|
|
403
|
+
title: 'Self-Healing Workflows',
|
|
404
|
+
content: `# Self-Healing Workflows
|
|
405
|
+
|
|
406
|
+
## Purpose
|
|
407
|
+
Automatically detect and recover from errors without interrupting your flow.
|
|
408
|
+
|
|
409
|
+
## Self-Healing Features
|
|
410
|
+
|
|
411
|
+
### 1. Error Detection
|
|
412
|
+
Monitors for:
|
|
413
|
+
- Failed commands
|
|
414
|
+
- Syntax errors
|
|
415
|
+
- Missing dependencies
|
|
416
|
+
- Broken tests
|
|
417
|
+
|
|
418
|
+
### 2. Automatic Recovery
|
|
419
|
+
|
|
420
|
+
**Missing Dependencies:**
|
|
421
|
+
\`\`\`
|
|
422
|
+
Error: Cannot find module 'express'
|
|
423
|
+
â Automatically runs: npm install express
|
|
424
|
+
â Retries original command
|
|
425
|
+
\`\`\`
|
|
426
|
+
|
|
427
|
+
**Syntax Errors:**
|
|
428
|
+
\`\`\`
|
|
429
|
+
Error: Unexpected token
|
|
430
|
+
â Analyzes error location
|
|
431
|
+
â Suggests fix through analyzer agent
|
|
432
|
+
â Applies fix with confirmation
|
|
433
|
+
\`\`\`
|
|
434
|
+
|
|
435
|
+
**Test Failures:**
|
|
436
|
+
\`\`\`
|
|
437
|
+
Test failed: "user authentication"
|
|
438
|
+
â Spawns debugger agent
|
|
439
|
+
â Analyzes failure cause
|
|
440
|
+
â Implements fix
|
|
441
|
+
â Re-runs tests
|
|
442
|
+
\`\`\`
|
|
443
|
+
|
|
444
|
+
### 3. Learning from Failures
|
|
445
|
+
Each recovery improves future prevention:
|
|
446
|
+
- Patterns saved to knowledge base
|
|
447
|
+
- Similar errors prevented proactively
|
|
448
|
+
- Recovery strategies optimized
|
|
449
|
+
|
|
450
|
+
## Hook Integration
|
|
451
|
+
\`\`\`json
|
|
452
|
+
{
|
|
453
|
+
"PostToolUse": [{
|
|
454
|
+
"matcher": "^Bash$",
|
|
455
|
+
"command": "npx @sparkleideas/ruv-swarm hook post-bash --exit-code '\${tool.result.exitCode}' --auto-recover"
|
|
456
|
+
}]
|
|
457
|
+
}
|
|
458
|
+
\`\`\`
|
|
459
|
+
|
|
460
|
+
## Benefits
|
|
461
|
+
- đĄī¸ Resilient workflows
|
|
462
|
+
- đ Automatic recovery
|
|
463
|
+
- đ Learns from errors
|
|
464
|
+
- âąī¸ Saves debugging time`,
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
'automation/session-memory.md': {
|
|
468
|
+
title: 'Cross-Session Memory',
|
|
469
|
+
content: `# Cross-Session Memory
|
|
470
|
+
|
|
471
|
+
## Purpose
|
|
472
|
+
Maintain context and learnings across Claude Code sessions for continuous improvement.
|
|
473
|
+
|
|
474
|
+
## Memory Features
|
|
475
|
+
|
|
476
|
+
### 1. Automatic State Persistence
|
|
477
|
+
At session end, automatically saves:
|
|
478
|
+
- Active agents and specializations
|
|
479
|
+
- Task history and patterns
|
|
480
|
+
- Performance metrics
|
|
481
|
+
- Neural network weights
|
|
482
|
+
- Knowledge base updates
|
|
483
|
+
|
|
484
|
+
### 2. Session Restoration
|
|
485
|
+
\`\`\`bash
|
|
486
|
+
# New session automatically loads previous state
|
|
487
|
+
claude "Continue where we left off"
|
|
488
|
+
|
|
489
|
+
# Or manually restore specific session
|
|
490
|
+
npx @sparkleideas/ruv-swarm hook session-restore --session-id "sess-123"
|
|
491
|
+
\`\`\`
|
|
492
|
+
|
|
493
|
+
### 3. Memory Types
|
|
494
|
+
|
|
495
|
+
**Project Memory:**
|
|
496
|
+
- File relationships
|
|
497
|
+
- Common edit patterns
|
|
498
|
+
- Testing approaches
|
|
499
|
+
- Build configurations
|
|
500
|
+
|
|
501
|
+
**Agent Memory:**
|
|
502
|
+
- Specialization levels
|
|
503
|
+
- Task success rates
|
|
504
|
+
- Optimization strategies
|
|
505
|
+
- Error patterns
|
|
506
|
+
|
|
507
|
+
**Performance Memory:**
|
|
508
|
+
- Bottleneck history
|
|
509
|
+
- Optimization results
|
|
510
|
+
- Token usage patterns
|
|
511
|
+
- Efficiency trends
|
|
512
|
+
|
|
513
|
+
### 4. Privacy & Control
|
|
514
|
+
\`\`\`bash
|
|
515
|
+
# View stored memory
|
|
516
|
+
ls .@sparkleideas/ruv-swarm/
|
|
517
|
+
|
|
518
|
+
# Clear specific memory
|
|
519
|
+
rm .@sparkleideas/ruv-swarm/session-*.json
|
|
520
|
+
|
|
521
|
+
# Disable memory
|
|
522
|
+
export RUV_SWARM_MEMORY_PERSIST=false
|
|
523
|
+
\`\`\`
|
|
524
|
+
|
|
525
|
+
## Benefits
|
|
526
|
+
- đ§ Contextual awareness
|
|
527
|
+
- đ Cumulative learning
|
|
528
|
+
- ⥠Faster task completion
|
|
529
|
+
- đ¯ Personalized optimization`,
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
const createdFiles = [];
|
|
534
|
+
|
|
535
|
+
// Generate command files
|
|
536
|
+
for (const [filepath, config] of Object.entries(commands)) {
|
|
537
|
+
const content = config.content || this.generateCommandContent(config);
|
|
538
|
+
const filePath = path.join(commandsDir, filepath);
|
|
539
|
+
await fs.writeFile(filePath, content);
|
|
540
|
+
createdFiles.push(filepath);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return { files: createdFiles, success: true };
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
generateCommandContent(config) {
|
|
547
|
+
return `# ${config.title}
|
|
548
|
+
|
|
549
|
+
## đ¯ Key Features
|
|
550
|
+
${config.description || 'Advanced swarm optimization capability'}
|
|
551
|
+
|
|
552
|
+
## Usage
|
|
553
|
+
${config.usage || 'See main documentation for details'}
|
|
554
|
+
|
|
555
|
+
## Benefits
|
|
556
|
+
${config.benefits || '- Improved performance\n- Automated workflows\n- Intelligent coordination'}
|
|
557
|
+
`;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export { AdvancedCommandsGenerator };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Claude Code integration module
|
|
3
|
+
* Handles MCP server setup and basic integration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
import { promises as fs } from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
|
|
10
|
+
class ClaudeIntegrationCore {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.autoSetup = options.autoSetup || false;
|
|
13
|
+
this.forceSetup = options.forceSetup || false;
|
|
14
|
+
this.workingDir = options.workingDir || process.cwd();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check if Claude CLI is available
|
|
19
|
+
*/
|
|
20
|
+
async isClaudeAvailable() {
|
|
21
|
+
try {
|
|
22
|
+
execSync('claude --version', { stdio: 'ignore' });
|
|
23
|
+
return true;
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Add @sparkleideas/ruv-swarm MCP server to Claude Code
|
|
31
|
+
*/
|
|
32
|
+
async addMcpServer() {
|
|
33
|
+
if (!await this.isClaudeAvailable()) {
|
|
34
|
+
throw new Error('Claude Code CLI not found. Install with: npm install -g @anthropic-ai/claude-code');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
// Add @sparkleideas/ruv-swarm MCP server using stdio (no port needed)
|
|
39
|
+
const mcpCommand = 'claude mcp add @sparkleideas/ruv-swarm npx @sparkleideas/ruv-swarm mcp start';
|
|
40
|
+
execSync(mcpCommand, { stdio: 'inherit', cwd: this.workingDir });
|
|
41
|
+
return { success: true, message: 'Added @sparkleideas/ruv-swarm MCP server to Claude Code (stdio)' };
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new Error(`Failed to add MCP server: ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check if integration files already exist
|
|
49
|
+
*/
|
|
50
|
+
async checkExistingFiles() {
|
|
51
|
+
try {
|
|
52
|
+
await fs.access(path.join(this.workingDir, 'claude.md'));
|
|
53
|
+
await fs.access(path.join(this.workingDir, '.claude/commands'));
|
|
54
|
+
return true;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Initialize Claude integration
|
|
62
|
+
*/
|
|
63
|
+
async initialize() {
|
|
64
|
+
console.log('đ§ Initializing Claude Code integration...');
|
|
65
|
+
|
|
66
|
+
// Check if files exist (unless force setup)
|
|
67
|
+
if (!this.forceSetup && await this.checkExistingFiles()) {
|
|
68
|
+
console.log(' âšī¸ Claude integration files already exist (use --force to regenerate)');
|
|
69
|
+
return { success: true, message: 'Integration files already exist' };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const results = {
|
|
74
|
+
core: await this.addMcpServer(),
|
|
75
|
+
success: true,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
console.log('â
Claude integration initialized successfully');
|
|
79
|
+
return results;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error('â Failed to initialize Claude integration:', error.message);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Invoke Claude with a prompt (supports both secure and legacy modes)
|
|
88
|
+
*/
|
|
89
|
+
async invokeClaudeWithPrompt(prompt, options = {}) {
|
|
90
|
+
if (!prompt || !prompt.trim()) {
|
|
91
|
+
throw new Error('No prompt provided');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!await this.isClaudeAvailable()) {
|
|
95
|
+
throw new Error('Claude Code CLI not found');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Default behavior for backward compatibility (legacy mode)
|
|
99
|
+
const addPermissions = options.secure !== true;
|
|
100
|
+
const permissions = addPermissions ? ' --dangerously-skip-permissions' : '';
|
|
101
|
+
const claudeCommand = `claude "${prompt.trim()}"${permissions}`;
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
execSync(claudeCommand, { stdio: 'inherit', cwd: this.workingDir });
|
|
105
|
+
return { success: true, message: 'Claude invocation completed' };
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new Error(`Claude invocation failed: ${error.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { ClaudeIntegrationCore };
|