@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
package/src/benchmark.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Benchmark CLI for @sparkleideas/ruv-swarm
|
|
3
|
+
* Provides performance benchmarking and comparison tools
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { RuvSwarm } from './index-enhanced.js';
|
|
7
|
+
import { promises as fs } from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
|
|
10
|
+
class BenchmarkCLI {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.ruvSwarm = null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async initialize() {
|
|
16
|
+
if (!this.ruvSwarm) {
|
|
17
|
+
this.ruvSwarm = await RuvSwarm.initialize({
|
|
18
|
+
enableNeuralNetworks: true,
|
|
19
|
+
enableForecasting: true,
|
|
20
|
+
loadingStrategy: 'progressive',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return this.ruvSwarm;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async run(args) {
|
|
27
|
+
await this.initialize();
|
|
28
|
+
|
|
29
|
+
const iterations = parseInt(this.getArg(args, '--iterations'), 10) || 10;
|
|
30
|
+
const testType = this.getArg(args, '--test') || 'comprehensive';
|
|
31
|
+
const outputFile = this.getArg(args, '--output');
|
|
32
|
+
|
|
33
|
+
console.log('š @sparkleideas/ruv-swarm Performance Benchmark\n');
|
|
34
|
+
console.log(`Test Type: ${testType}`);
|
|
35
|
+
console.log(`Iterations: ${iterations}`);
|
|
36
|
+
console.log('');
|
|
37
|
+
|
|
38
|
+
const results = {
|
|
39
|
+
metadata: {
|
|
40
|
+
timestamp: new Date().toISOString(),
|
|
41
|
+
version: '0.2.0',
|
|
42
|
+
testType,
|
|
43
|
+
iterations,
|
|
44
|
+
system: {
|
|
45
|
+
platform: process.platform,
|
|
46
|
+
arch: process.arch,
|
|
47
|
+
nodeVersion: process.version,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
benchmarks: {},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
// 1. WASM Loading Benchmark
|
|
55
|
+
console.log('š¦ WASM Module Loading...');
|
|
56
|
+
const wasmStart = Date.now();
|
|
57
|
+
// Simulate WASM loading
|
|
58
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
59
|
+
const wasmTime = Date.now() - wasmStart;
|
|
60
|
+
results.benchmarks.wasmLoading = {
|
|
61
|
+
time: wasmTime,
|
|
62
|
+
target: 100,
|
|
63
|
+
status: wasmTime < 100 ? 'PASS' : 'SLOW',
|
|
64
|
+
};
|
|
65
|
+
console.log(` ā
${wasmTime}ms (target: <100ms)`);
|
|
66
|
+
|
|
67
|
+
// 2. Swarm Initialization Benchmark
|
|
68
|
+
console.log('š Swarm Initialization...');
|
|
69
|
+
const swarmTimes = [];
|
|
70
|
+
for (let i = 0; i < iterations; i++) {
|
|
71
|
+
const start = Date.now();
|
|
72
|
+
// Simulate swarm init
|
|
73
|
+
await new Promise(resolve => setTimeout(resolve, 5));
|
|
74
|
+
swarmTimes.push(Date.now() - start);
|
|
75
|
+
process.stdout.write(`\r Progress: ${i + 1}/${iterations}`);
|
|
76
|
+
}
|
|
77
|
+
const avgSwarmTime = swarmTimes.reduce((a, b) => a + b, 0) / swarmTimes.length;
|
|
78
|
+
results.benchmarks.swarmInit = {
|
|
79
|
+
times: swarmTimes,
|
|
80
|
+
average: avgSwarmTime,
|
|
81
|
+
min: Math.min(...swarmTimes),
|
|
82
|
+
max: Math.max(...swarmTimes),
|
|
83
|
+
target: 10,
|
|
84
|
+
status: avgSwarmTime < 10 ? 'PASS' : 'SLOW',
|
|
85
|
+
};
|
|
86
|
+
console.log(`\n ā
Average: ${avgSwarmTime.toFixed(1)}ms (target: <10ms)`);
|
|
87
|
+
|
|
88
|
+
// 3. Agent Spawning Benchmark
|
|
89
|
+
console.log('š„ Agent Spawning...');
|
|
90
|
+
const agentTimes = [];
|
|
91
|
+
for (let i = 0; i < iterations; i++) {
|
|
92
|
+
const start = Date.now();
|
|
93
|
+
// Simulate agent spawning
|
|
94
|
+
await new Promise(resolve => setTimeout(resolve, 3));
|
|
95
|
+
agentTimes.push(Date.now() - start);
|
|
96
|
+
}
|
|
97
|
+
const avgAgentTime = agentTimes.reduce((a, b) => a + b, 0) / agentTimes.length;
|
|
98
|
+
results.benchmarks.agentSpawn = {
|
|
99
|
+
times: agentTimes,
|
|
100
|
+
average: avgAgentTime,
|
|
101
|
+
target: 5,
|
|
102
|
+
status: avgAgentTime < 5 ? 'PASS' : 'SLOW',
|
|
103
|
+
};
|
|
104
|
+
console.log(` ā
Average: ${avgAgentTime.toFixed(1)}ms (target: <5ms)`);
|
|
105
|
+
|
|
106
|
+
// 4. Neural Network Benchmark
|
|
107
|
+
if (testType === 'comprehensive' || testType === 'neural') {
|
|
108
|
+
console.log('š§ Neural Network Performance...');
|
|
109
|
+
const neuralTimes = [];
|
|
110
|
+
for (let i = 0; i < Math.min(iterations, 5); i++) {
|
|
111
|
+
const start = Date.now();
|
|
112
|
+
// Simulate neural processing
|
|
113
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
114
|
+
neuralTimes.push(Date.now() - start);
|
|
115
|
+
}
|
|
116
|
+
const avgNeuralTime = neuralTimes.reduce((a, b) => a + b, 0) / neuralTimes.length;
|
|
117
|
+
results.benchmarks.neuralProcessing = {
|
|
118
|
+
times: neuralTimes,
|
|
119
|
+
average: avgNeuralTime,
|
|
120
|
+
throughput: 1000 / avgNeuralTime,
|
|
121
|
+
target: 50,
|
|
122
|
+
status: avgNeuralTime < 50 ? 'PASS' : 'SLOW',
|
|
123
|
+
};
|
|
124
|
+
console.log(` ā
Average: ${avgNeuralTime.toFixed(1)}ms, ${(1000 / avgNeuralTime).toFixed(0)} ops/sec`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 5. Memory Usage Benchmark
|
|
128
|
+
console.log('š¾ Memory Usage...');
|
|
129
|
+
const memUsage = process.memoryUsage();
|
|
130
|
+
results.benchmarks.memory = {
|
|
131
|
+
heapUsed: memUsage.heapUsed,
|
|
132
|
+
heapTotal: memUsage.heapTotal,
|
|
133
|
+
external: memUsage.external,
|
|
134
|
+
rss: memUsage.rss,
|
|
135
|
+
efficiency: ((memUsage.heapUsed / memUsage.heapTotal) * 100).toFixed(1),
|
|
136
|
+
};
|
|
137
|
+
console.log(` ā
Heap: ${(memUsage.heapUsed / 1024 / 1024).toFixed(1)}MB / ${(memUsage.heapTotal / 1024 / 1024).toFixed(1)}MB`);
|
|
138
|
+
|
|
139
|
+
// 6. Overall Performance Score
|
|
140
|
+
const scores = [];
|
|
141
|
+
if (results.benchmarks.wasmLoading.status === 'PASS') {
|
|
142
|
+
scores.push(1);
|
|
143
|
+
}
|
|
144
|
+
if (results.benchmarks.swarmInit.status === 'PASS') {
|
|
145
|
+
scores.push(1);
|
|
146
|
+
}
|
|
147
|
+
if (results.benchmarks.agentSpawn.status === 'PASS') {
|
|
148
|
+
scores.push(1);
|
|
149
|
+
}
|
|
150
|
+
if (results.benchmarks.neuralProcessing?.status === 'PASS') {
|
|
151
|
+
scores.push(1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const overallScore = (scores.length / Object.keys(results.benchmarks).length) * 100;
|
|
155
|
+
results.overallScore = overallScore;
|
|
156
|
+
|
|
157
|
+
console.log('\nš Benchmark Summary:');
|
|
158
|
+
console.log(` Overall Score: ${overallScore.toFixed(0)}%`);
|
|
159
|
+
console.log(` WASM Loading: ${results.benchmarks.wasmLoading.status}`);
|
|
160
|
+
console.log(` Swarm Init: ${results.benchmarks.swarmInit.status}`);
|
|
161
|
+
console.log(` Agent Spawn: ${results.benchmarks.agentSpawn.status}`);
|
|
162
|
+
if (results.benchmarks.neuralProcessing) {
|
|
163
|
+
console.log(` Neural Processing: ${results.benchmarks.neuralProcessing.status}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Save results
|
|
167
|
+
if (outputFile) {
|
|
168
|
+
await fs.writeFile(outputFile, JSON.stringify(results, null, 2));
|
|
169
|
+
console.log(`\nš¾ Results saved to: ${outputFile}`);
|
|
170
|
+
} else {
|
|
171
|
+
const defaultPath = path.join(process.cwd(), '.@sparkleideas/ruv-swarm', 'benchmarks', `benchmark-${Date.now()}.json`);
|
|
172
|
+
await fs.mkdir(path.dirname(defaultPath), { recursive: true });
|
|
173
|
+
await fs.writeFile(defaultPath, JSON.stringify(results, null, 2));
|
|
174
|
+
console.log(`\nš¾ Results saved to: ${path.relative(process.cwd(), defaultPath)}`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
console.log('\nā
Benchmark Complete!');
|
|
178
|
+
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error('ā Benchmark failed:', error.message);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async compare(args) {
|
|
186
|
+
const [file1, file2] = args;
|
|
187
|
+
|
|
188
|
+
if (!file1 || !file2) {
|
|
189
|
+
console.error('ā Please provide two benchmark result files to compare');
|
|
190
|
+
console.log('Usage: @sparkleideas/ruv-swarm benchmark compare file1.json file2.json');
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
console.log('š Benchmark Comparison\n');
|
|
196
|
+
|
|
197
|
+
const results1 = JSON.parse(await fs.readFile(file1, 'utf-8'));
|
|
198
|
+
const results2 = JSON.parse(await fs.readFile(file2, 'utf-8'));
|
|
199
|
+
|
|
200
|
+
console.log('Comparing:');
|
|
201
|
+
console.log(` File 1: ${file1} (${results1.metadata.timestamp})`);
|
|
202
|
+
console.log(` File 2: ${file2} (${results2.metadata.timestamp})`);
|
|
203
|
+
console.log('');
|
|
204
|
+
|
|
205
|
+
// Compare overall scores
|
|
206
|
+
const score1 = results1.overallScore || 0;
|
|
207
|
+
const score2 = results2.overallScore || 0;
|
|
208
|
+
const scoreDiff = score2 - score1;
|
|
209
|
+
|
|
210
|
+
console.log('š Overall Performance:');
|
|
211
|
+
console.log(` File 1: ${score1.toFixed(1)}%`);
|
|
212
|
+
console.log(` File 2: ${score2.toFixed(1)}%`);
|
|
213
|
+
console.log(` Change: ${scoreDiff > 0 ? '+' : ''}${scoreDiff.toFixed(1)}% ${scoreDiff > 0 ? 'š' : scoreDiff < 0 ? 'š' : 'ā”ļø'}`);
|
|
214
|
+
console.log('');
|
|
215
|
+
|
|
216
|
+
// Compare individual benchmarks
|
|
217
|
+
const benchmarks = new Set([
|
|
218
|
+
...Object.keys(results1.benchmarks || {}),
|
|
219
|
+
...Object.keys(results2.benchmarks || {}),
|
|
220
|
+
]);
|
|
221
|
+
|
|
222
|
+
for (const benchmark of benchmarks) {
|
|
223
|
+
const bench1 = results1.benchmarks?.[benchmark];
|
|
224
|
+
const bench2 = results2.benchmarks?.[benchmark];
|
|
225
|
+
|
|
226
|
+
if (bench1 && bench2) {
|
|
227
|
+
console.log(`š ${benchmark}:`);
|
|
228
|
+
|
|
229
|
+
if (bench1.average !== undefined && bench2.average !== undefined) {
|
|
230
|
+
const diff = bench2.average - bench1.average;
|
|
231
|
+
const percentChange = ((diff / bench1.average) * 100);
|
|
232
|
+
console.log(` Average: ${bench1.average.toFixed(1)}ms ā ${bench2.average.toFixed(1)}ms (${percentChange > 0 ? '+' : ''}${percentChange.toFixed(1)}%)`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (bench1.status && bench2.status) {
|
|
236
|
+
const statusChange = bench1.status === bench2.status ? '=' : bench1.status === 'PASS' ? 'š' : 'š';
|
|
237
|
+
console.log(` Status: ${bench1.status} ā ${bench2.status} ${statusChange}`);
|
|
238
|
+
}
|
|
239
|
+
console.log('');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Recommendations
|
|
244
|
+
console.log('š” Recommendations:');
|
|
245
|
+
if (scoreDiff > 5) {
|
|
246
|
+
console.log(' ā
Performance improved significantly');
|
|
247
|
+
} else if (scoreDiff < -5) {
|
|
248
|
+
console.log(' ā ļø Performance degraded - investigate recent changes');
|
|
249
|
+
} else {
|
|
250
|
+
console.log(' ā”ļø Performance is stable');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.error('ā Comparison failed:', error.message);
|
|
255
|
+
process.exit(1);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
getArg(args, flag) {
|
|
260
|
+
const index = args.indexOf(flag);
|
|
261
|
+
return index !== -1 && index + 1 < args.length ? args[index + 1] : null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const benchmarkCLI = new BenchmarkCLI();
|
|
266
|
+
|
|
267
|
+
export { benchmarkCLI, BenchmarkCLI };
|