Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUv7c83ac1d5b04
diff --git a/agents/architect.yaml b/agents/architect.yaml
index 39cd6766b4..a967e80de9 100644
--- a/agents/architect.yaml
+++ b/agents/architect.yaml
@@ -8,4 +8,4 @@ capabilities:
optimizations:
- context-caching
- memory-persistence
-createdAt: "2026-01-27T16:12:18.204Z"
+createdAt: "2026-01-27T18:17:06.296Z"
diff --git a/agents/coder.yaml b/agents/coder.yaml
index 09992aa4c6..c0e2e54d6e 100644
--- a/agents/coder.yaml
+++ b/agents/coder.yaml
@@ -8,4 +8,4 @@ capabilities:
optimizations:
- flash-attention
- token-reduction
-createdAt: "2026-01-27T16:12:18.203Z"
+createdAt: "2026-01-27T18:17:06.296Z"
diff --git a/agents/reviewer.yaml b/agents/reviewer.yaml
index 8fb6ce6a5f..67175b701c 100644
--- a/agents/reviewer.yaml
+++ b/agents/reviewer.yaml
@@ -7,4 +7,4 @@ capabilities:
- best-practices
optimizations:
- incremental-analysis
-createdAt: "2026-01-27T16:12:18.204Z"
+createdAt: "2026-01-27T18:17:06.296Z"
diff --git a/agents/security-architect.yaml b/agents/security-architect.yaml
index d0c5665f42..72a0abb08b 100644
--- a/agents/security-architect.yaml
+++ b/agents/security-architect.yaml
@@ -7,4 +7,4 @@ capabilities:
- security-review
optimizations:
- pattern-matching
-createdAt: "2026-01-27T16:12:18.204Z"
+createdAt: "2026-01-27T18:17:06.296Z"
diff --git a/agents/tester.yaml b/agents/tester.yaml
index e57e7791ff..d23b99f803 100644
--- a/agents/tester.yaml
+++ b/agents/tester.yaml
@@ -7,4 +7,4 @@ capabilities:
- coverage
optimizations:
- parallel-execution
-createdAt: "2026-01-27T16:12:18.204Z"
+createdAt: "2026-01-27T18:17:06.296Z"
diff --git a/v3/@claude-flow/cli/src/commands/benchmark.ts b/v3/@claude-flow/cli/src/commands/benchmark.ts
new file mode 100644
index 0000000000..3dd1b99021
--- /dev/null
+++ b/v3/@claude-flow/cli/src/commands/benchmark.ts
@@ -0,0 +1,499 @@
+/**
+ * V3 CLI Benchmark Command
+ * Comprehensive benchmarking for self-learning, pre-training, and neural systems
+ *
+ * @module v3/cli/commands/benchmark
+ */
+
+import type { Command, CommandContext, CommandResult } from '../types.js';
+import { output } from '../output.js';
+import { writeFileSync, existsSync, mkdirSync } from 'node:fs';
+import { join } from 'node:path';
+
+// ============================================================================
+// Pretrain Benchmark Subcommand
+// ============================================================================
+
+const pretrainCommand: Command = {
+ name: 'pretrain',
+ description: 'Benchmark self-learning pre-training system (SONA, EWC++, MoE)',
+ options: [
+ { name: 'iterations', short: 'i', type: 'number', description: 'Benchmark iterations', default: '100' },
+ { name: 'warmup', short: 'w', type: 'number', description: 'Warmup iterations', default: '10' },
+ { name: 'output', short: 'o', type: 'string', description: 'Output format: text, json', default: 'text' },
+ { name: 'save', short: 's', type: 'string', description: 'Save results to file' },
+ { name: 'verbose', short: 'v', type: 'boolean', description: 'Verbose output', default: 'false' },
+ ],
+ examples: [
+ { command: 'claude-flow benchmark pretrain', description: 'Run pre-training benchmarks' },
+ { command: 'claude-flow benchmark pretrain -i 500 --save results.json', description: 'Extended benchmark with results saved' },
+ { command: 'claude-flow benchmark pretrain -o json', description: 'Output results as JSON' },
+ ],
+ action: async (ctx: CommandContext): Promise<CommandResult> => {
+ const iterations = parseInt(ctx.flags.iterations as string || '100', 10);
+ const warmup = parseInt(ctx.flags.warmup as string || '10', 10);
+ const outputFormat = ctx.flags.output as string || 'text';
+ const saveFile = ctx.flags.save as string | undefined;
+ const verbose = ctx.flags.verbose === true;
+
+ try {
+ // Dynamically import benchmark suite
+ const { runPretrainBenchmarkSuite } = await import('../benchmarks/pretrain/index.js');
+
+ const results = await runPretrainBenchmarkSuite({
+ iterations,
+ warmupIterations: warmup,
+ verbose,
+ });
+
+ // Output as JSON if requested
+ if (outputFormat === 'json') {
+ output.writeln(JSON.stringify(results, null, 2));
+ }
+
+ // Save to file if requested
+ if (saveFile) {
+ const resultsDir = join(process.cwd(), '.claude-flow', 'benchmarks');
+ if (!existsSync(resultsDir)) {
+ mkdirSync(resultsDir, { recursive: true });
+ }
+ const savePath = saveFile.startsWith('/') ? saveFile : join(resultsDir, saveFile);
+ writeFileSync(savePath, JSON.stringify(results, null, 2));
+ output.writeln(output.success(`Results saved to ${savePath}`));
+ }
+
+ const allPassed = results.results.every(r => r.targetMet);
+ return {
+ success: true,
+ message: allPassed
+ ? 'All benchmark targets met!'
+ : `${results.results.filter(r => r.targetMet).length}/${results.results.length} targets met`,
+ };
+ } catch (error) {
+ return {
+ success: false,
+ error: `Benchmark failed: ${error instanceof Error ? error.message : String(error)}`,
+ };
+ }
+ },
+};
+
+// ============================================================================
+// Neural Benchmark Subcommand
+// ============================================================================
+
+const neuralCommand: Command = {
+ name: 'neural',
+ description: 'Benchmark neural operations (embeddings, WASM, Flash Attention)',
+ options: [
+ { name: 'iterations', short: 'i', type: 'number', description: 'Benchmark iterations', default: '100' },
+ { name: 'dimension', short: 'd', type: 'number', description: 'Embedding dimension', default: '384' },
+ { name: 'vectors', short: 'n', type: 'number', description: 'Number of test vectors', default: '1000' },
+ { name: 'output', short: 'o', type: 'string', description: 'Output format: text, json', default: 'text' },
+ ],
+ examples: [
+ { command: 'claude-flow benchmark neural', description: 'Run neural benchmarks' },
+ { command: 'claude-flow benchmark neural -d 768 -n 5000', description: 'Higher dimension, more vectors' },
+ ],
+ action: async (ctx: CommandContext): Promise<CommandResult> => {
+ const iterations = parseInt(ctx.flags.iterations as string || '100', 10);
+ const dimension = parseInt(ctx.flags.dimension as string || '384', 10);
+ const numVectors = parseInt(ctx.flags.vectors as string || '1000', 10);
+ const outputFormat = ctx.flags.output as string || 'text';
+
+ output.writeln();
+ output.writeln(output.bold('Neural Operations Benchmark'));
+ output.writeln(output.dim('─'.repeat(60)));
+ output.writeln(`Iterations: ${iterations} | Dimension: ${dimension} | Vectors: ${numVectors}`);
+ output.writeln();
+
+ const spinner = output.createSpinner({ text: 'Running neural benchmarks...', spinner: 'dots' });
+ spinner.start();
+
+ try {
+ const { performance } = await import('node:perf_hooks');
+
+ // Helper functions
+ const percentile = (sorted: number[], p: number) => {
+ const idx = Math.ceil((p / 100) * sorted.length) - 1;
+ return sorted[Math.max(0, idx)];
+ };
+
+ const results: { name: string; mean: number; p95: number; p99: number; target: number; met: boolean }[] = [];
+
+ // 1. Embedding Generation
+ spinner.setText('Benchmarking embedding generation...');
+ let generateEmbedding: (text: string) => Promise<Float32Array>;
+ try {
+ const memory = await import('../memory/memory-initializer.js');
+ generateEmbedding = memory.generateEmbedding;
+ } catch {
+ generateEmbedding = async (text: string) => {
+ const emb = new Float32Array(dimension);
+ for (let i = 0; i < dimension; i++) {
+ emb[i] = Math.sin(text.charCodeAt(i % text.length) * (i + 1));
+ }
+ return emb;
+ };
+ }
+
+ const embedTimes: number[] = [];
+ for (let i = 0; i < iterations; i++) {
+ const start = performance.now();
+ await generateEmbedding(`benchmark text ${i}`);
+ embedTimes.push(performance.now() - start);
+ }
+ const embedMean = embedTimes.reduce((a, b) => a + b, 0) / embedTimes.length;
+ const embedSorted = [...embedTimes].sort((a, b) => a - b);
+ results.push({
+ name: 'Embedding Generation',
+ mean: embedMean,
+ p95: percentile(embedSorted, 95),
+ p99: percentile(embedSorted, 99),
+ target: 5.0,
+ met: embedMean <= 5.0,
+ });
+
+ // 2. Batch Cosine Similarity
+ spinner.setText('Benchmarking batch cosine similarity...');
+ let batchCosineSim: (query: Float32Array, vectors: Float32Array[]) => Float32Array;
+ try {
+ const memory = await import('../memory/memory-initializer.js');
+ batchCosineSim = memory.batchCosineSim;
+ } catch {
+ batchCosineSim = (query: Float32Array, vectors: Float32Array[]) => {
+ const results = new Float32Array(vectors.length);
+ for (let i = 0; i < vectors.length; i++) {
+ let dot = 0, nQ = 0, nV = 0;
+ for (let j = 0; j < query.length; j++) {
+ dot += query[j] * vectors[i][j];
+ nQ += query[j] * query[j];
+ nV += vectors[i][j] * vectors[i][j];
+ }
+ results[i] = dot / (Math.sqrt(nQ) * Math.sqrt(nV));
+ }
+ return results;
+ };
+ }
+
+ const query = new Float32Array(dimension).map(() => Math.random());
+ const vectors = Array.from({ length: numVectors }, () =>
+ new Float32Array(dimension).map(() => Math.random())
+ );
+
+ const cosineTimes: number[] = [];
+ for (let i = 0; i < Math.min(iterations, 50); i++) {
+ const start = performance.now();
+ batchCosineSim(query, vectors);
+ cosineTimes.push(performance.now() - start);
+ }
+ const cosineMean = cosineTimes.reduce((a, b) => a + b, 0) / cosineTimes.length;
+ const cosineSorted = [...cosineTimes].sort((a, b) => a - b);
+ results.push({
+ name: `Batch Cosine (${numVectors} vectors)`,
+ mean: cosineMean,
+ p95: percentile(cosineSorted, 95),
+ p99: percentile(cosineSorted, 99),
+ target: 5.0,
+ met: cosineMean <= 5.0,
+ });
+
+ // 3. Flash Attention Search (if available)
+ spinner.setText('Benchmarking flash attention search...');
+ let flashTimes: number[] = [];
+ try {
+ const memory = await import('../memory/memory-initializer.js');
+ if (memory.flashAttentionSearch) {
+ for (let i = 0; i < Math.min(iterations, 50); i++) {
+ const start = performance.now();
+ memory.flashAttentionSearch(query, vectors, 10);
+ flashTimes.push(performance.now() - start);
+ }
+ }
+ } catch {
+ // Flash attention not available
+ }
+
+ if (flashTimes.length > 0) {
+ const flashMean = flashTimes.reduce((a, b) => a + b, 0) / flashTimes.length;
+ const flashSorted = [...flashTimes].sort((a, b) => a - b);
+ results.push({
+ name: 'Flash Attention Search',
+ mean: flashMean,
+ p95: percentile(flashSorted, 95),
+ p99: percentile(flashSorted, 99),
+ target: 2.0,
+ met: flashMean <= 2.0,
+ });
+ }
+
+ spinner.stop();
+
+ // Display results
+ output.writeln();
+ output.writeln(output.bold('Results'));
+ output.writeln(output.dim('─'.repeat(60)));
+
+ for (const r of results) {
+ const status = r.met ? output.success('βœ“') : output.error('βœ—');
+ output.writeln(`${status} ${r.name}`);
+ output.writeln(` Mean: ${r.mean.toFixed(3)}ms | p95: ${r.p95.toFixed(3)}ms | p99: ${r.p99.toFixed(3)}ms`);
+ output.writeln(` Target: ${r.target}ms | Status: ${r.met ? 'Met' : 'Not met'}`);
+ output.writeln();
+ }
+
+ if (outputFormat === 'json') {
+ output.writeln(JSON.stringify(results, null, 2));
+ }
+
+ const allPassed = results.every(r => r.met);
+ return {
+ success: true,
+ message: allPassed ? 'All neural benchmarks passed!' : 'Some benchmarks below target',
+ };
+ } catch (error) {
+ spinner.stop();
+ return {
+ success: false,
+ error: `Neural benchmark failed: ${error instanceof Error ? error.message : String(error)}`,
+ };
+ }
+ },
+};
+
+// ============================================================================
+// Memory Benchmark Subcommand
+// ============================================================================
+
+const memoryCommand: Command = {
+ name: 'memory',
+ description: 'Benchmark memory operations (HNSW search, store, retrieve)',
+ options: [
+ { name: 'iterations', short: 'i', type: 'number', description: 'Benchmark iterations', default: '100' },
+ { name: 'output', short: 'o', type: 'string', description: 'Output format: text, json', default: 'text' },
+ ],
+ examples: [
+ { command: 'claude-flow benchmark memory', description: 'Run memory benchmarks' },
+ ],
+ action: async (ctx: CommandContext): Promise<CommandResult> => {
+ const iterations = parseInt(ctx.flags.iterations as string || '100', 10);
+ const outputFormat = ctx.flags.output as string || 'text';
+
+ output.writeln();
+ output.writeln(output.bold('Memory Operations Benchmark'));
+ output.writeln(output.dim('─'.repeat(60)));
+
+ const spinner = output.createSpinner({ text: 'Running memory benchmarks...', spinner: 'dots' });
+ spinner.start();
+
+ try {
+ const { performance } = await import('node:perf_hooks');
+
+ const percentile = (sorted: number[], p: number) => {
+ const idx = Math.ceil((p / 100) * sorted.length) - 1;
+ return sorted[Math.max(0, idx)];
+ };
+
+ const results: { name: string; mean: number; p95: number; target: number; met: boolean }[] = [];
+
+ // Import memory functions
+ let storeEntry: (opts: { key: string; value: string; namespace?: string }) => Promise<{ success: boolean }>;
+ let searchEntries: (opts: { query: string; namespace?: string; limit?: number }) => Promise<{ results: unknown[]; searchTime: number }>;
+
+ try {
+ const memory = await import('../memory/memory-initializer.js');
+ storeEntry = memory.storeEntry;
+ searchEntries = memory.searchEntries;
+ } catch {
+ storeEntry = async () => ({ success: true });
+ searchEntries = async () => ({ results: [], searchTime: 0.5 });
+ }
+
+ // 1. Store benchmark
+ spinner.setText('Benchmarking memory store...');
+ const storeTimes: number[] = [];
+ for (let i = 0; i < iterations; i++) {
+ const start = performance.now();
+ await storeEntry({
+ key: `bench-key-${i}`,
+ value: `Benchmark value ${i} with some additional content`,
+ namespace: 'benchmark',
+ });
+ storeTimes.push(performance.now() - start);
+ }
+ const storeMean = storeTimes.reduce((a, b) => a + b, 0) / storeTimes.length;
+ results.push({
+ name: 'Memory Store',
+ mean: storeMean,
+ p95: percentile([...storeTimes].sort((a, b) => a - b), 95),
+ target: 10.0,
+ met: storeMean <= 10.0,
+ });
+
+ // 2. Search benchmark
+ spinner.setText('Benchmarking memory search...');
+ const queries = [
+ 'authentication patterns',
+ 'error handling best practices',
+ 'performance optimization',
+ 'testing strategies',
+ 'security vulnerabilities',
+ ];
+ const searchTimes: number[] = [];
+ for (let i = 0; i < iterations; i++) {
+ const start = performance.now();
+ await searchEntries({
+ query: queries[i % queries.length],
+ namespace: 'benchmark',
+ limit: 10,
+ });
+ searchTimes.push(performance.now() - start);
+ }
+ const searchMean = searchTimes.reduce((a, b) => a + b, 0) / searchTimes.length;
+ results.push({
+ name: 'Memory Search (HNSW)',
+ mean: searchMean,
+ p95: percentile([...searchTimes].sort((a, b) => a - b), 95),
+ target: 10.0,
+ met: searchMean <= 10.0,
+ });
+
+ spinner.stop();
+
+ // Display results
+ output.writeln();
+ output.writeln(output.bold('Results'));
+ output.writeln(output.dim('─'.repeat(60)));
+
+ for (const r of results) {
+ const status = r.met ? output.success('βœ“') : output.error('βœ—');
+ output.writeln(`${status} ${r.name}`);
+ output.writeln(` Mean: ${r.mean.toFixed(3)}ms | p95: ${r.p95.toFixed(3)}ms | Target: ${r.target}ms`);
+ output.writeln();
+ }
+
+ if (outputFormat === 'json') {
+ output.writeln(JSON.stringify(results, null, 2));
+ }
+
+ return { success: true, message: 'Memory benchmarks complete' };
+ } catch (error) {
+ spinner.stop();
+ return {
+ success: false,
+ error: `Memory benchmark failed: ${error instanceof Error ? error.message : String(error)}`,
+ };
+ }
+ },
+};
+
+// ============================================================================
+// Full Suite Benchmark Subcommand
+// ============================================================================
+
+const allCommand: Command = {
+ name: 'all',
+ description: 'Run all benchmark suites',
+ options: [
+ { name: 'iterations', short: 'i', type: 'number', description: 'Benchmark iterations', default: '50' },
+ { name: 'output', short: 'o', type: 'string', description: 'Output format: text, json', default: 'text' },
+ { name: 'save', short: 's', type: 'string', description: 'Save results to file' },
+ ],
+ examples: [
+ { command: 'claude-flow benchmark all', description: 'Run all benchmarks' },
+ { command: 'claude-flow benchmark all --save full-results.json', description: 'Run all and save results' },
+ ],
+ action: async (ctx: CommandContext): Promise<CommandResult> => {
+ output.writeln();
+ output.writeln(output.bold(output.highlight('═'.repeat(65))));
+ output.writeln(output.bold(' Claude Flow V3 - Full Benchmark Suite'));
+ output.writeln(output.bold(output.highlight('═'.repeat(65))));
+
+ const startTime = Date.now();
+ const allResults: Record<string, unknown> = {};
+
+ // Run pretrain benchmarks
+ output.writeln();
+ output.writeln(output.bold('β–Έ Pre-Training Benchmarks'));
+ const pretrainResult = await pretrainCommand.action(ctx);
+ allResults.pretrain = pretrainResult;
+
+ // Run neural benchmarks
+ output.writeln();
+ output.writeln(output.bold('β–Έ Neural Benchmarks'));
+ const neuralResult = await neuralCommand.action(ctx);
+ allResults.neural = neuralResult;
+
+ // Run memory benchmarks
+ output.writeln();
+ output.writeln(output.bold('β–Έ Memory Benchmarks'));
+ const memoryResult = await memoryCommand.action(ctx);
+ allResults.memory = memoryResult;
+
+ const totalDuration = Date.now() - startTime;
+
+ output.writeln();
+ output.writeln(output.bold(output.highlight('═'.repeat(65))));
+ output.writeln(` Total Duration: ${(totalDuration / 1000).toFixed(2)}s`);
+ output.writeln(output.bold(output.highlight('═'.repeat(65))));
+
+ // Save if requested
+ const saveFile = ctx.flags.save as string | undefined;
+ if (saveFile) {
+ const resultsDir = join(process.cwd(), '.claude-flow', 'benchmarks');
+ if (!existsSync(resultsDir)) {
+ mkdirSync(resultsDir, { recursive: true });
+ }
+ const savePath = saveFile.startsWith('/') ? saveFile : join(resultsDir, saveFile);
+ writeFileSync(savePath, JSON.stringify({
+ timestamp: new Date().toISOString(),
+ duration: totalDuration,
+ results: allResults,
+ }, null, 2));
+ output.writeln(output.success(`Results saved to ${savePath}`));
+ }
+
+ return { success: true, message: 'All benchmarks complete' };
+ },
+};
+
+// ============================================================================
+// Main Benchmark Command
+// ============================================================================
+
+export const benchmarkCommand: Command = {
+ name: 'benchmark',
+ description: 'Performance benchmarking for self-learning and neural systems',
+ subcommands: [
+ pretrainCommand,
+ neuralCommand,
+ memoryCommand,
+ allCommand,
+ ],
+ examples: [
+ { command: 'claude-flow benchmark pretrain', description: 'Benchmark pre-training system' },
+ { command: 'claude-flow benchmark neural', description: 'Benchmark neural operations' },
+ { command: 'claude-flow benchmark memory', description: 'Benchmark memory operations' },
+ { command: 'claude-flow benchmark all', description: 'Run all benchmarks' },
+ ],
+ action: async (_ctx: CommandContext): Promise<CommandResult> => {
+ output.writeln();
+ output.writeln(output.bold('Claude Flow V3 Benchmark Suite'));
+ output.writeln(output.dim('─'.repeat(50)));
+ output.writeln();
+ output.writeln('Available subcommands:');
+ output.writeln(` ${output.highlight('pretrain')} - Benchmark self-learning pre-training (SONA, EWC++, MoE)`);
+ output.writeln(` ${output.highlight('neural')} - Benchmark neural operations (embeddings, WASM)`);
+ output.writeln(` ${output.highlight('memory')} - Benchmark memory operations (HNSW, store, search)`);
+ output.writeln(` ${output.highlight('all')} - Run all benchmark suites`);
+ output.writeln();
+ output.writeln('Examples:');
+ output.writeln(' claude-flow benchmark pretrain -i 200');
+ output.writeln(' claude-flow benchmark all --save results.json');
+ output.writeln();
+
+ return { success: true, message: 'Use a subcommand to run benchmarks' };
+ },
+};
+
+export default benchmarkCommand;