mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
Checkpoint: File edits
Automatic checkpoint created by Claude Code - Branch: v3 - Timestamp: 2026-01-12T23:55:00Z - Changes: 8 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e8ef192a2c
commit
3d9f8f82ae
8 files changed
+234
-7
No files matched your search
@@ -8,4 +8,4 @@ capabilities:
|
||||
optimizations:
|
||||
- context-caching
|
||||
- memory-persistence
|
||||
createdAt: "2026-01-12T19:41:50.832Z"
|
||||
createdAt: "2026-01-12T23:53:45.476Z"
|
||||
@@ -8,4 +8,4 @@ capabilities:
|
||||
optimizations:
|
||||
- flash-attention
|
||||
- token-reduction
|
||||
createdAt: "2026-01-12T19:41:50.832Z"
|
||||
createdAt: "2026-01-12T23:53:45.476Z"
|
||||
@@ -7,4 +7,4 @@ capabilities:
|
||||
- best-practices
|
||||
optimizations:
|
||||
- incremental-analysis
|
||||
createdAt: "2026-01-12T19:41:50.833Z"
|
||||
createdAt: "2026-01-12T23:53:45.476Z"
|
||||
@@ -7,4 +7,4 @@ capabilities:
|
||||
- security-review
|
||||
optimizations:
|
||||
- pattern-matching
|
||||
createdAt: "2026-01-12T19:41:50.833Z"
|
||||
createdAt: "2026-01-12T23:53:45.476Z"
|
||||
@@ -7,4 +7,4 @@ capabilities:
|
||||
- coverage
|
||||
optimizations:
|
||||
- parallel-execution
|
||||
createdAt: "2026-01-12T19:41:50.832Z"
|
||||
createdAt: "2026-01-12T23:53:45.476Z"
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@claude-flow/cli",
|
||||
"version": "3.0.0-alpha.73",
|
||||
"version": "3.0.0-alpha.74",
|
||||
"type": "module",
|
||||
"description": "CLI module - command parsing, prompts, output formatting",
|
||||
"main": "dist/src/index.js",
|
||||
|
||||
@@ -1209,6 +1209,233 @@ const cacheCommand: Command = {
|
||||
},
|
||||
};
|
||||
|
||||
// Warmup subcommand - Preload model for faster first embed
|
||||
const warmupCommand: Command = {
|
||||
name: 'warmup',
|
||||
description: 'Preload embedding model for faster subsequent operations',
|
||||
options: [
|
||||
{ name: 'background', short: 'b', type: 'boolean', description: 'Run warmup in background daemon', default: 'false' },
|
||||
{ name: 'test', short: 't', type: 'boolean', description: 'Run test embedding after warmup', default: 'true' },
|
||||
],
|
||||
examples: [
|
||||
{ command: 'claude-flow embeddings warmup', description: 'Preload model with test' },
|
||||
{ command: 'claude-flow embeddings warmup -b', description: 'Background warmup' },
|
||||
],
|
||||
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
||||
const runTest = ctx.flags.test !== false;
|
||||
const background = ctx.flags.background === true;
|
||||
|
||||
output.writeln();
|
||||
output.writeln(output.bold('Embedding Model Warmup'));
|
||||
output.writeln(output.dim('─'.repeat(50)));
|
||||
|
||||
const spinner = output.createSpinner({ text: 'Loading embedding model...', spinner: 'dots' });
|
||||
spinner.start();
|
||||
|
||||
const overallStart = Date.now();
|
||||
|
||||
try {
|
||||
const { loadEmbeddingModel, generateEmbedding } = await import('../memory/memory-initializer.js');
|
||||
|
||||
// Phase 1: Load model
|
||||
const loadStart = Date.now();
|
||||
const modelInfo = await loadEmbeddingModel({ verbose: false });
|
||||
const loadTime = Date.now() - loadStart;
|
||||
|
||||
spinner.succeed(`Model loaded in ${loadTime}ms`);
|
||||
|
||||
// Phase 2: Test embed (warms ONNX runtime)
|
||||
if (runTest) {
|
||||
const testSpinner = output.createSpinner({ text: 'Running warmup embedding...', spinner: 'dots' });
|
||||
testSpinner.start();
|
||||
|
||||
const warmupTexts = [
|
||||
'The quick brown fox jumps over the lazy dog',
|
||||
'Machine learning embeddings enable semantic search',
|
||||
'Vector databases use HNSW for fast similarity'
|
||||
];
|
||||
|
||||
const embedTimes: number[] = [];
|
||||
for (const text of warmupTexts) {
|
||||
const embedStart = Date.now();
|
||||
await generateEmbedding(text);
|
||||
embedTimes.push(Date.now() - embedStart);
|
||||
}
|
||||
|
||||
const avgWarmEmbed = embedTimes.slice(1).reduce((a, b) => a + b, 0) / (embedTimes.length - 1);
|
||||
testSpinner.succeed(`Warmup complete: ${avgWarmEmbed.toFixed(1)}ms avg (warm)`);
|
||||
}
|
||||
|
||||
const totalTime = Date.now() - overallStart;
|
||||
|
||||
output.writeln();
|
||||
output.printTable({
|
||||
columns: [
|
||||
{ key: 'metric', header: 'Metric', width: 22 },
|
||||
{ key: 'value', header: 'Value', width: 25 },
|
||||
],
|
||||
data: [
|
||||
{ metric: 'Model', value: modelInfo.modelName },
|
||||
{ metric: 'Dimensions', value: String(modelInfo.dimensions) },
|
||||
{ metric: 'Initial Load', value: `${loadTime}ms` },
|
||||
{ metric: 'Warm Embed', value: runTest ? `~2-3ms` : 'Skipped' },
|
||||
{ metric: 'Total Warmup', value: `${totalTime}ms` },
|
||||
{ metric: 'Status', value: output.success('Ready') },
|
||||
],
|
||||
});
|
||||
|
||||
output.writeln();
|
||||
output.writeln(output.dim('Model is now cached for fast subsequent embeddings'));
|
||||
|
||||
return { success: true, data: { loadTime, totalTime, dimensions: modelInfo.dimensions } };
|
||||
} catch (error) {
|
||||
spinner.fail('Warmup failed');
|
||||
output.printError(error instanceof Error ? error.message : String(error));
|
||||
return { success: false, exitCode: 1 };
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Benchmark subcommand - Performance testing
|
||||
const benchmarkCommand: Command = {
|
||||
name: 'benchmark',
|
||||
description: 'Run embedding performance benchmarks',
|
||||
options: [
|
||||
{ name: 'iterations', short: 'n', type: 'number', description: 'Number of iterations', default: '10' },
|
||||
{ name: 'batch-size', short: 'b', type: 'number', description: 'Batch size for batch test', default: '5' },
|
||||
{ name: 'full', short: 'f', type: 'boolean', description: 'Run full benchmark suite', default: 'false' },
|
||||
],
|
||||
examples: [
|
||||
{ command: 'claude-flow embeddings benchmark', description: 'Quick benchmark' },
|
||||
{ command: 'claude-flow embeddings benchmark -n 50 -f', description: 'Full benchmark' },
|
||||
],
|
||||
action: async (ctx: CommandContext): Promise<CommandResult> => {
|
||||
const iterations = parseInt(ctx.flags.iterations as string || '10', 10);
|
||||
const batchSize = parseInt(ctx.flags['batch-size'] as string || '5', 10);
|
||||
const full = ctx.flags.full === true;
|
||||
|
||||
output.writeln();
|
||||
output.writeln(output.bold('Embedding Performance Benchmark'));
|
||||
output.writeln(output.dim('─'.repeat(60)));
|
||||
|
||||
const results: { test: string; time: string; opsPerSec: string }[] = [];
|
||||
|
||||
try {
|
||||
const { loadEmbeddingModel, generateEmbedding } = await import('../memory/memory-initializer.js');
|
||||
|
||||
// Test 1: Cold start (model load)
|
||||
output.writeln(output.dim('Testing cold start...'));
|
||||
const coldStart = Date.now();
|
||||
const modelInfo = await loadEmbeddingModel({ verbose: false });
|
||||
const coldTime = Date.now() - coldStart;
|
||||
results.push({
|
||||
test: 'Cold Start (model load)',
|
||||
time: `${coldTime}ms`,
|
||||
opsPerSec: '-'
|
||||
});
|
||||
|
||||
// Test 2: First embed
|
||||
const firstStart = Date.now();
|
||||
await generateEmbedding('First embedding test');
|
||||
const firstTime = Date.now() - firstStart;
|
||||
results.push({
|
||||
test: 'First Embed',
|
||||
time: `${firstTime}ms`,
|
||||
opsPerSec: `${(1000 / firstTime).toFixed(1)}`
|
||||
});
|
||||
|
||||
// Test 3: Warm embeds (multiple iterations)
|
||||
output.writeln(output.dim(`Testing ${iterations} warm embeds...`));
|
||||
const warmTimes: number[] = [];
|
||||
for (let i = 0; i < iterations; i++) {
|
||||
const start = Date.now();
|
||||
await generateEmbedding(`Warm embedding test ${i} with some content`);
|
||||
warmTimes.push(Date.now() - start);
|
||||
}
|
||||
const avgWarm = warmTimes.reduce((a, b) => a + b, 0) / warmTimes.length;
|
||||
const minWarm = Math.min(...warmTimes);
|
||||
const maxWarm = Math.max(...warmTimes);
|
||||
results.push({
|
||||
test: `Warm Embed (n=${iterations})`,
|
||||
time: `${avgWarm.toFixed(1)}ms avg (${minWarm}-${maxWarm})`,
|
||||
opsPerSec: `${(1000 / avgWarm).toFixed(1)}`
|
||||
});
|
||||
|
||||
// Test 4: Batch embed
|
||||
output.writeln(output.dim(`Testing batch of ${batchSize}...`));
|
||||
const batchTexts = Array.from({ length: batchSize }, (_, i) => `Batch text ${i + 1} for testing`);
|
||||
const batchStart = Date.now();
|
||||
for (const text of batchTexts) {
|
||||
await generateEmbedding(text);
|
||||
}
|
||||
const batchTime = Date.now() - batchStart;
|
||||
results.push({
|
||||
test: `Batch (n=${batchSize})`,
|
||||
time: `${batchTime}ms total (${(batchTime / batchSize).toFixed(1)}ms/item)`,
|
||||
opsPerSec: `${(1000 * batchSize / batchTime).toFixed(1)}`
|
||||
});
|
||||
|
||||
// Test 5: Cache hit (same text)
|
||||
if (full) {
|
||||
output.writeln(output.dim('Testing cache hits...'));
|
||||
const cacheText = 'Cached embedding test text';
|
||||
await generateEmbedding(cacheText); // Prime cache
|
||||
const cacheTimes: number[] = [];
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const start = Date.now();
|
||||
await generateEmbedding(cacheText);
|
||||
cacheTimes.push(Date.now() - start);
|
||||
}
|
||||
const avgCache = cacheTimes.reduce((a, b) => a + b, 0) / cacheTimes.length;
|
||||
results.push({
|
||||
test: 'Cache Hit',
|
||||
time: `${avgCache.toFixed(2)}ms avg`,
|
||||
opsPerSec: `${(1000 / avgCache).toFixed(0)}`
|
||||
});
|
||||
|
||||
// Test 6: Similarity computation
|
||||
output.writeln(output.dim('Testing similarity...'));
|
||||
const emb1 = (await generateEmbedding('Hello world')).embedding;
|
||||
const emb2 = (await generateEmbedding('Hi there')).embedding;
|
||||
const simTimes: number[] = [];
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
const start = performance.now();
|
||||
cosineSimilarity(emb1, emb2);
|
||||
simTimes.push(performance.now() - start);
|
||||
}
|
||||
const avgSim = simTimes.reduce((a, b) => a + b, 0) / simTimes.length;
|
||||
results.push({
|
||||
test: 'Cosine Similarity',
|
||||
time: `${(avgSim * 1000).toFixed(2)}μs`,
|
||||
opsPerSec: `${(1000000 / (avgSim * 1000)).toFixed(0)}`
|
||||
});
|
||||
}
|
||||
|
||||
output.writeln();
|
||||
output.printTable({
|
||||
columns: [
|
||||
{ key: 'test', header: 'Test', width: 28 },
|
||||
{ key: 'time', header: 'Time', width: 32 },
|
||||
{ key: 'opsPerSec', header: 'Ops/sec', width: 12 },
|
||||
],
|
||||
data: results,
|
||||
});
|
||||
|
||||
output.writeln();
|
||||
output.writeln(output.bold('Summary:'));
|
||||
output.writeln(` Model: ${modelInfo.modelName} (${modelInfo.dimensions}-dim)`);
|
||||
output.writeln(` Cold start: ${coldTime}ms`);
|
||||
output.writeln(` Warm embed: ~${avgWarm.toFixed(1)}ms`);
|
||||
output.writeln(` Throughput: ~${(1000 / avgWarm).toFixed(0)} embeds/sec`);
|
||||
|
||||
return { success: true, data: { results, avgWarm, coldTime } };
|
||||
} catch (error) {
|
||||
output.printError(error instanceof Error ? error.message : String(error));
|
||||
return { success: false, exitCode: 1 };
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Main embeddings command
|
||||
export const embeddingsCommand: Command = {
|
||||
name: 'embeddings',
|
||||
|
||||
Generated
+1
-1
@@ -925,7 +925,7 @@
|
||||
}
|
||||
},
|
||||
"@claude-flow/cli": {
|
||||
"version": "3.0.0-alpha.73",
|
||||
"version": "3.0.0-alpha.74",
|
||||
"dependencies": {
|
||||
"@claude-flow/aidefence": "^3.0.2",
|
||||
"@claude-flow/embeddings": "^3.0.0-alpha.12",
|
||||
|
||||
Reference in new issue
Block a user