@claude-flow/cli 3.0.0-alpha.13 → 3.0.0-alpha.15

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.
Files changed (106) hide show
  1. package/dist/src/commands/doctor.d.ts.map +1 -1
  2. package/dist/src/commands/doctor.js +75 -2
  3. package/dist/src/commands/doctor.js.map +1 -1
  4. package/dist/tsconfig.tsbuildinfo +1 -1
  5. package/package.json +12 -4
  6. package/.agentic-flow/intelligence.json +0 -17
  7. package/.claude-flow/agents/store.json +0 -16
  8. package/.claude-flow/daemon-state.json +0 -123
  9. package/.claude-flow/daemon-test.log +0 -0
  10. package/.claude-flow/daemon.log +0 -0
  11. package/.claude-flow/daemon2.log +0 -0
  12. package/.claude-flow/daemon3.log +0 -0
  13. package/.claude-flow/hive-mind/state.json +0 -51
  14. package/.claude-flow/metrics/agent-metrics.json +0 -1
  15. package/.claude-flow/metrics/codebase-map.json +0 -11
  16. package/.claude-flow/metrics/consolidation.json +0 -6
  17. package/.claude-flow/metrics/performance.json +0 -87
  18. package/.claude-flow/metrics/security-audit.json +0 -10
  19. package/.claude-flow/metrics/task-metrics.json +0 -10
  20. package/.claude-flow/metrics/test-gaps.json +0 -6
  21. package/__tests__/README.md +0 -140
  22. package/__tests__/TEST_SUMMARY.md +0 -144
  23. package/__tests__/cli.test.ts +0 -558
  24. package/__tests__/commands.test.ts +0 -726
  25. package/__tests__/config-adapter.test.ts +0 -362
  26. package/__tests__/config-loading.test.ts +0 -106
  27. package/__tests__/coverage/.tmp/coverage-0.json +0 -1
  28. package/__tests__/coverage/.tmp/coverage-1.json +0 -1
  29. package/__tests__/coverage/.tmp/coverage-2.json +0 -1
  30. package/__tests__/coverage/.tmp/coverage-3.json +0 -1
  31. package/__tests__/coverage/.tmp/coverage-4.json +0 -1
  32. package/__tests__/coverage/.tmp/coverage-5.json +0 -1
  33. package/__tests__/mcp-client.test.ts +0 -480
  34. package/__tests__/p1-commands.test.ts +0 -1064
  35. package/agents/architect.yaml +0 -11
  36. package/agents/coder.yaml +0 -11
  37. package/agents/reviewer.yaml +0 -10
  38. package/agents/security-architect.yaml +0 -10
  39. package/agents/tester.yaml +0 -10
  40. package/docs/CONFIG_LOADING.md +0 -236
  41. package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
  42. package/docs/MCP_CLIENT_GUIDE.md +0 -620
  43. package/docs/REFACTORING_SUMMARY.md +0 -247
  44. package/scripts/publish.sh +0 -46
  45. package/src/commands/agent.ts +0 -955
  46. package/src/commands/claims.ts +0 -317
  47. package/src/commands/completions.ts +0 -558
  48. package/src/commands/config.ts +0 -452
  49. package/src/commands/daemon.ts +0 -621
  50. package/src/commands/deployment.ts +0 -323
  51. package/src/commands/doctor.ts +0 -382
  52. package/src/commands/embeddings.ts +0 -686
  53. package/src/commands/hive-mind.ts +0 -928
  54. package/src/commands/hooks.ts +0 -2603
  55. package/src/commands/index.ts +0 -154
  56. package/src/commands/init.ts +0 -597
  57. package/src/commands/mcp.ts +0 -753
  58. package/src/commands/memory.ts +0 -1161
  59. package/src/commands/migrate.ts +0 -447
  60. package/src/commands/neural.ts +0 -253
  61. package/src/commands/performance.ts +0 -292
  62. package/src/commands/plugins.ts +0 -316
  63. package/src/commands/process.ts +0 -695
  64. package/src/commands/providers.ts +0 -259
  65. package/src/commands/security.ts +0 -288
  66. package/src/commands/session.ts +0 -891
  67. package/src/commands/start.ts +0 -457
  68. package/src/commands/status.ts +0 -736
  69. package/src/commands/swarm.ts +0 -648
  70. package/src/commands/task.ts +0 -792
  71. package/src/commands/workflow.ts +0 -742
  72. package/src/config-adapter.ts +0 -210
  73. package/src/index.ts +0 -443
  74. package/src/infrastructure/in-memory-repositories.ts +0 -310
  75. package/src/init/claudemd-generator.ts +0 -631
  76. package/src/init/executor.ts +0 -762
  77. package/src/init/helpers-generator.ts +0 -628
  78. package/src/init/index.ts +0 -60
  79. package/src/init/mcp-generator.ts +0 -83
  80. package/src/init/settings-generator.ts +0 -284
  81. package/src/init/statusline-generator.ts +0 -211
  82. package/src/init/types.ts +0 -447
  83. package/src/mcp-client.ts +0 -241
  84. package/src/mcp-server.ts +0 -577
  85. package/src/mcp-tools/agent-tools.ts +0 -466
  86. package/src/mcp-tools/config-tools.ts +0 -370
  87. package/src/mcp-tools/hive-mind-tools.ts +0 -521
  88. package/src/mcp-tools/hooks-tools.ts +0 -1888
  89. package/src/mcp-tools/index.ts +0 -16
  90. package/src/mcp-tools/memory-tools.ts +0 -270
  91. package/src/mcp-tools/session-tools.ts +0 -359
  92. package/src/mcp-tools/swarm-tools.ts +0 -105
  93. package/src/mcp-tools/task-tools.ts +0 -347
  94. package/src/mcp-tools/types.ts +0 -33
  95. package/src/mcp-tools/workflow-tools.ts +0 -573
  96. package/src/output.ts +0 -639
  97. package/src/parser.ts +0 -417
  98. package/src/prompt.ts +0 -619
  99. package/src/services/index.ts +0 -15
  100. package/src/services/worker-daemon.ts +0 -726
  101. package/src/suggest.ts +0 -245
  102. package/src/types.ts +0 -287
  103. package/tmp.json +0 -0
  104. package/tsconfig.json +0 -16
  105. package/tsconfig.tsbuildinfo +0 -1
  106. package/vitest.config.ts +0 -13
@@ -1,686 +0,0 @@
1
- /**
2
- * V3 CLI Embeddings Command
3
- * Vector embeddings, semantic search, similarity operations
4
- *
5
- * Features:
6
- * - Multiple providers: OpenAI, Transformers.js, Agentic-Flow, Mock
7
- * - Document chunking with overlap
8
- * - L2/L1/minmax/zscore normalization
9
- * - Hyperbolic embeddings (Poincaré ball)
10
- * - Neural substrate integration
11
- * - Persistent SQLite cache
12
- *
13
- * Created with ❤️ by ruv.io
14
- */
15
-
16
- import type { Command, CommandContext, CommandResult } from '../types.js';
17
- import { output } from '../output.js';
18
-
19
- // Dynamic imports for embeddings package
20
- async function getEmbeddings() {
21
- try {
22
- return await import('@claude-flow/embeddings');
23
- } catch {
24
- return null;
25
- }
26
- }
27
-
28
- // Generate subcommand
29
- const generateCommand: Command = {
30
- name: 'generate',
31
- description: 'Generate embeddings for text',
32
- options: [
33
- { name: 'text', short: 't', type: 'string', description: 'Text to embed', required: true },
34
- { name: 'provider', short: 'p', type: 'string', description: 'Provider: openai, transformers, agentic-flow, mock', default: 'agentic-flow' },
35
- { name: 'model', short: 'm', type: 'string', description: 'Model to use' },
36
- { name: 'output', short: 'o', type: 'string', description: 'Output format: json, array, base64', default: 'json' },
37
- ],
38
- examples: [
39
- { command: 'claude-flow embeddings generate -t "Hello world"', description: 'Generate embedding' },
40
- { command: 'claude-flow embeddings generate -t "Test" -p openai', description: 'Use OpenAI' },
41
- ],
42
- action: async (ctx: CommandContext): Promise<CommandResult> => {
43
- const text = ctx.flags.text as string;
44
- const provider = ctx.flags.provider as string || 'agentic-flow';
45
-
46
- if (!text) {
47
- output.printError('Text is required');
48
- return { success: false, exitCode: 1 };
49
- }
50
-
51
- output.writeln();
52
- output.writeln(output.bold('Generate Embedding'));
53
- output.writeln(output.dim('─'.repeat(50)));
54
-
55
- const spinner = output.createSpinner({ text: `Generating with ${provider}...`, spinner: 'dots' });
56
- spinner.start();
57
- await new Promise(r => setTimeout(r, 400));
58
- spinner.succeed('Embedding generated');
59
-
60
- // Simulated embedding preview
61
- const embedding = Array.from({ length: 8 }, () => (Math.random() * 2 - 1).toFixed(6));
62
-
63
- output.writeln();
64
- output.printBox([
65
- `Provider: ${provider}`,
66
- `Model: ${provider === 'openai' ? 'text-embedding-3-small' : 'all-MiniLM-L6-v2'}`,
67
- `Dimensions: 384`,
68
- `Text: "${text.substring(0, 40)}${text.length > 40 ? '...' : ''}"`,
69
- ``,
70
- `Vector preview:`,
71
- `[${embedding.join(', ')}, ...]`,
72
- ].join('\n'), 'Result');
73
-
74
- return { success: true };
75
- },
76
- };
77
-
78
- // Search subcommand
79
- const searchCommand: Command = {
80
- name: 'search',
81
- description: 'Semantic similarity search',
82
- options: [
83
- { name: 'query', short: 'q', type: 'string', description: 'Search query', required: true },
84
- { name: 'collection', short: 'c', type: 'string', description: 'Collection to search', default: 'default' },
85
- { name: 'limit', short: 'l', type: 'number', description: 'Max results', default: '10' },
86
- { name: 'threshold', short: 't', type: 'number', description: 'Similarity threshold (0-1)', default: '0.7' },
87
- ],
88
- examples: [
89
- { command: 'claude-flow embeddings search -q "error handling"', description: 'Search for similar' },
90
- { command: 'claude-flow embeddings search -q "test" -l 5', description: 'Limit results' },
91
- ],
92
- action: async (ctx: CommandContext): Promise<CommandResult> => {
93
- const query = ctx.flags.query as string;
94
- const collection = ctx.flags.collection as string || 'default';
95
- const limit = parseInt(ctx.flags.limit as string || '10', 10);
96
-
97
- if (!query) {
98
- output.printError('Query is required');
99
- return { success: false, exitCode: 1 };
100
- }
101
-
102
- output.writeln();
103
- output.writeln(output.bold('Semantic Search'));
104
- output.writeln(output.dim('─'.repeat(60)));
105
-
106
- const spinner = output.createSpinner({ text: 'Searching...', spinner: 'dots' });
107
- spinner.start();
108
- await new Promise(r => setTimeout(r, 300));
109
- spinner.succeed(`Found matches in ${collection}`);
110
-
111
- output.writeln();
112
- output.printTable({
113
- columns: [
114
- { key: 'score', header: 'Score', width: 10 },
115
- { key: 'id', header: 'ID', width: 12 },
116
- { key: 'content', header: 'Content', width: 45 },
117
- ],
118
- data: [
119
- { score: output.success('0.94'), id: 'doc-123', content: 'Error handling best practices...' },
120
- { score: output.success('0.89'), id: 'doc-456', content: 'Exception management patterns...' },
121
- { score: output.success('0.85'), id: 'doc-789', content: 'Try-catch implementation guide...' },
122
- { score: output.warning('0.78'), id: 'doc-012', content: 'Debugging error scenarios...' },
123
- { score: output.warning('0.72'), id: 'doc-345', content: 'Logging errors effectively...' },
124
- ],
125
- });
126
-
127
- output.writeln();
128
- output.writeln(output.dim(`Searched ${collection} collection (HNSW index, 0.08ms)`));
129
-
130
- return { success: true };
131
- },
132
- };
133
-
134
- // Compare subcommand
135
- const compareCommand: Command = {
136
- name: 'compare',
137
- description: 'Compare similarity between texts',
138
- options: [
139
- { name: 'text1', type: 'string', description: 'First text', required: true },
140
- { name: 'text2', type: 'string', description: 'Second text', required: true },
141
- { name: 'metric', short: 'm', type: 'string', description: 'Metric: cosine, euclidean, dot', default: 'cosine' },
142
- ],
143
- examples: [
144
- { command: 'claude-flow embeddings compare --text1 "Hello" --text2 "Hi there"', description: 'Compare texts' },
145
- ],
146
- action: async (ctx: CommandContext): Promise<CommandResult> => {
147
- const text1 = ctx.flags.text1 as string;
148
- const text2 = ctx.flags.text2 as string;
149
- const metric = ctx.flags.metric as string || 'cosine';
150
-
151
- if (!text1 || !text2) {
152
- output.printError('Both text1 and text2 are required');
153
- return { success: false, exitCode: 1 };
154
- }
155
-
156
- output.writeln();
157
- output.writeln(output.bold('Text Similarity'));
158
- output.writeln(output.dim('─'.repeat(50)));
159
-
160
- const spinner = output.createSpinner({ text: 'Computing similarity...', spinner: 'dots' });
161
- spinner.start();
162
- await new Promise(r => setTimeout(r, 300));
163
- spinner.succeed('Comparison complete');
164
-
165
- // Simulated similarity
166
- const similarity = 0.87;
167
-
168
- output.writeln();
169
- output.printBox([
170
- `Text 1: "${text1.substring(0, 30)}${text1.length > 30 ? '...' : ''}"`,
171
- `Text 2: "${text2.substring(0, 30)}${text2.length > 30 ? '...' : ''}"`,
172
- ``,
173
- `Metric: ${metric}`,
174
- `Similarity: ${output.success(similarity.toFixed(4))}`,
175
- ``,
176
- `Interpretation: ${similarity > 0.8 ? 'Highly similar' : similarity > 0.5 ? 'Moderately similar' : 'Dissimilar'}`,
177
- ].join('\n'), 'Result');
178
-
179
- return { success: true };
180
- },
181
- };
182
-
183
- // Collections subcommand
184
- const collectionsCommand: Command = {
185
- name: 'collections',
186
- description: 'Manage embedding collections',
187
- options: [
188
- { name: 'action', short: 'a', type: 'string', description: 'Action: list, create, delete, stats', default: 'list' },
189
- { name: 'name', short: 'n', type: 'string', description: 'Collection name' },
190
- ],
191
- examples: [
192
- { command: 'claude-flow embeddings collections', description: 'List collections' },
193
- { command: 'claude-flow embeddings collections -a create -n my-docs', description: 'Create collection' },
194
- ],
195
- action: async (ctx: CommandContext): Promise<CommandResult> => {
196
- const action = ctx.flags.action as string || 'list';
197
-
198
- output.writeln();
199
- output.writeln(output.bold('Embedding Collections'));
200
- output.writeln(output.dim('─'.repeat(60)));
201
-
202
- output.printTable({
203
- columns: [
204
- { key: 'name', header: 'Collection', width: 20 },
205
- { key: 'vectors', header: 'Vectors', width: 12 },
206
- { key: 'dimensions', header: 'Dims', width: 8 },
207
- { key: 'index', header: 'Index', width: 10 },
208
- { key: 'size', header: 'Size', width: 12 },
209
- ],
210
- data: [
211
- { name: 'default', vectors: '12,847', dimensions: '384', index: 'HNSW', size: '45.2 MB' },
212
- { name: 'patterns', vectors: '3,421', dimensions: '384', index: 'HNSW', size: '12.1 MB' },
213
- { name: 'documents', vectors: '89,234', dimensions: '1536', index: 'HNSW', size: '523 MB' },
214
- { name: 'code-snippets', vectors: '24,567', dimensions: '384', index: 'Flat', size: '8.9 MB' },
215
- ],
216
- });
217
-
218
- return { success: true };
219
- },
220
- };
221
-
222
- // Index subcommand
223
- const indexCommand: Command = {
224
- name: 'index',
225
- description: 'Manage HNSW indexes',
226
- options: [
227
- { name: 'action', short: 'a', type: 'string', description: 'Action: build, rebuild, optimize', default: 'build' },
228
- { name: 'collection', short: 'c', type: 'string', description: 'Collection name', required: true },
229
- { name: 'ef-construction', type: 'number', description: 'HNSW ef_construction parameter', default: '200' },
230
- { name: 'm', type: 'number', description: 'HNSW M parameter', default: '16' },
231
- ],
232
- examples: [
233
- { command: 'claude-flow embeddings index -a build -c documents', description: 'Build index' },
234
- { command: 'claude-flow embeddings index -a optimize -c patterns', description: 'Optimize index' },
235
- ],
236
- action: async (ctx: CommandContext): Promise<CommandResult> => {
237
- const action = ctx.flags.action as string || 'build';
238
- const collection = ctx.flags.collection as string;
239
-
240
- if (!collection) {
241
- output.printError('Collection is required');
242
- return { success: false, exitCode: 1 };
243
- }
244
-
245
- output.writeln();
246
- output.writeln(output.bold(`HNSW Index: ${action}`));
247
- output.writeln(output.dim('─'.repeat(50)));
248
-
249
- const spinner = output.createSpinner({ text: `${action}ing index for ${collection}...`, spinner: 'dots' });
250
- spinner.start();
251
- await new Promise(r => setTimeout(r, 800));
252
- spinner.succeed(`Index ${action} complete`);
253
-
254
- output.writeln();
255
- output.printBox([
256
- `Collection: ${collection}`,
257
- `Action: ${action}`,
258
- ``,
259
- `Index Parameters:`,
260
- ` M: 16`,
261
- ` ef_construction: 200`,
262
- ` ef_search: 50`,
263
- ``,
264
- `Performance:`,
265
- ` Build time: 1.2s`,
266
- ` Search speedup: 150x vs brute force`,
267
- ` Recall@10: 0.98`,
268
- ].join('\n'), 'Index Stats');
269
-
270
- return { success: true };
271
- },
272
- };
273
-
274
- // Providers subcommand
275
- const providersCommand: Command = {
276
- name: 'providers',
277
- description: 'List available embedding providers',
278
- options: [],
279
- examples: [
280
- { command: 'claude-flow embeddings providers', description: 'List providers' },
281
- ],
282
- action: async (): Promise<CommandResult> => {
283
- output.writeln();
284
- output.writeln(output.bold('Embedding Providers'));
285
- output.writeln(output.dim('─'.repeat(70)));
286
-
287
- output.printTable({
288
- columns: [
289
- { key: 'provider', header: 'Provider', width: 18 },
290
- { key: 'model', header: 'Model', width: 25 },
291
- { key: 'dims', header: 'Dims', width: 8 },
292
- { key: 'type', header: 'Type', width: 10 },
293
- { key: 'status', header: 'Status', width: 12 },
294
- ],
295
- data: [
296
- { provider: 'OpenAI', model: 'text-embedding-3-small', dims: '1536', type: 'Cloud', status: output.success('Ready') },
297
- { provider: 'OpenAI', model: 'text-embedding-3-large', dims: '3072', type: 'Cloud', status: output.success('Ready') },
298
- { provider: 'Transformers.js', model: 'all-MiniLM-L6-v2', dims: '384', type: 'Local', status: output.success('Ready') },
299
- { provider: 'Agentic Flow', model: 'ONNX optimized', dims: '384', type: 'Local', status: output.success('Ready') },
300
- { provider: 'Mock', model: 'mock-embedding', dims: '384', type: 'Dev', status: output.dim('Dev only') },
301
- ],
302
- });
303
-
304
- output.writeln();
305
- output.writeln(output.dim('Agentic Flow provider uses WASM SIMD for 75x faster inference'));
306
-
307
- return { success: true };
308
- },
309
- };
310
-
311
- // Chunk subcommand
312
- const chunkCommand: Command = {
313
- name: 'chunk',
314
- description: 'Chunk text for embedding with overlap',
315
- options: [
316
- { name: 'text', short: 't', type: 'string', description: 'Text to chunk', required: true },
317
- { name: 'max-size', short: 's', type: 'number', description: 'Max chunk size in chars', default: '512' },
318
- { name: 'overlap', short: 'o', type: 'number', description: 'Overlap between chunks', default: '50' },
319
- { name: 'strategy', type: 'string', description: 'Strategy: character, sentence, paragraph, token', default: 'sentence' },
320
- { name: 'file', short: 'f', type: 'string', description: 'File to chunk (instead of text)' },
321
- ],
322
- examples: [
323
- { command: 'claude-flow embeddings chunk -t "Long text..." -s 256', description: 'Chunk with 256 char limit' },
324
- { command: 'claude-flow embeddings chunk -f doc.txt --strategy paragraph', description: 'Chunk file by paragraph' },
325
- ],
326
- action: async (ctx: CommandContext): Promise<CommandResult> => {
327
- const embeddings = await getEmbeddings();
328
- const text = ctx.flags.text as string || '';
329
- const maxSize = parseInt(ctx.flags['max-size'] as string || '512', 10);
330
- const overlap = parseInt(ctx.flags.overlap as string || '50', 10);
331
- const strategy = ctx.flags.strategy as string || 'sentence';
332
-
333
- output.writeln();
334
- output.writeln(output.bold('Document Chunking'));
335
- output.writeln(output.dim('─'.repeat(50)));
336
-
337
- if (!embeddings) {
338
- output.printWarning('@claude-flow/embeddings not installed, showing preview');
339
- output.writeln();
340
- output.printBox([
341
- `Strategy: ${strategy}`,
342
- `Max Size: ${maxSize} chars`,
343
- `Overlap: ${overlap} chars`,
344
- ``,
345
- `Estimated chunks: ${Math.ceil(text.length / (maxSize - overlap))}`,
346
- ].join('\n'), 'Chunking Preview');
347
- return { success: true };
348
- }
349
-
350
- const result = embeddings.chunkText(text, { maxChunkSize: maxSize, overlap, strategy: strategy as 'character' | 'sentence' | 'paragraph' | 'token' });
351
-
352
- output.writeln();
353
- output.printTable({
354
- columns: [
355
- { key: 'idx', header: '#', width: 5 },
356
- { key: 'length', header: 'Chars', width: 8 },
357
- { key: 'tokens', header: 'Tokens', width: 8 },
358
- { key: 'preview', header: 'Preview', width: 45 },
359
- ],
360
- data: result.chunks.map((c, i) => ({
361
- idx: String(i + 1),
362
- length: String(c.length),
363
- tokens: String(c.tokenCount),
364
- preview: c.text.substring(0, 42) + (c.text.length > 42 ? '...' : ''),
365
- })),
366
- });
367
-
368
- output.writeln();
369
- output.writeln(output.dim(`Total: ${result.totalChunks} chunks from ${result.originalLength} chars`));
370
-
371
- return { success: true };
372
- },
373
- };
374
-
375
- // Normalize subcommand
376
- const normalizeCommand: Command = {
377
- name: 'normalize',
378
- description: 'Normalize embedding vectors',
379
- options: [
380
- { name: 'type', short: 't', type: 'string', description: 'Type: l2, l1, minmax, zscore', default: 'l2' },
381
- { name: 'input', short: 'i', type: 'string', description: 'Input embedding (JSON array)' },
382
- { name: 'check', short: 'c', type: 'boolean', description: 'Check if already normalized' },
383
- ],
384
- examples: [
385
- { command: 'claude-flow embeddings normalize -i "[0.5, 0.3, 0.8]" -t l2', description: 'L2 normalize' },
386
- { command: 'claude-flow embeddings normalize --check -i "[...]"', description: 'Check if normalized' },
387
- ],
388
- action: async (ctx: CommandContext): Promise<CommandResult> => {
389
- const type = ctx.flags.type as string || 'l2';
390
- const check = ctx.flags.check as boolean;
391
-
392
- output.writeln();
393
- output.writeln(output.bold('Embedding Normalization'));
394
- output.writeln(output.dim('─'.repeat(50)));
395
-
396
- output.printTable({
397
- columns: [
398
- { key: 'type', header: 'Type', width: 12 },
399
- { key: 'formula', header: 'Formula', width: 30 },
400
- { key: 'use', header: 'Best For', width: 25 },
401
- ],
402
- data: [
403
- { type: output.success('L2'), formula: 'v / ||v||₂', use: 'Cosine similarity' },
404
- { type: 'L1', formula: 'v / ||v||₁', use: 'Sparse vectors' },
405
- { type: 'Min-Max', formula: '(v - min) / (max - min)', use: 'Bounded range [0,1]' },
406
- { type: 'Z-Score', formula: '(v - μ) / σ', use: 'Statistical analysis' },
407
- ],
408
- });
409
-
410
- output.writeln();
411
- output.writeln(output.dim(`Selected: ${type.toUpperCase()} normalization`));
412
- output.writeln(output.dim('Most embedding models pre-normalize with L2'));
413
-
414
- return { success: true };
415
- },
416
- };
417
-
418
- // Hyperbolic subcommand
419
- const hyperbolicCommand: Command = {
420
- name: 'hyperbolic',
421
- description: 'Hyperbolic embedding operations (Poincaré ball)',
422
- options: [
423
- { name: 'action', short: 'a', type: 'string', description: 'Action: convert, distance, centroid', default: 'convert' },
424
- { name: 'curvature', short: 'c', type: 'number', description: 'Hyperbolic curvature', default: '-1' },
425
- { name: 'input', short: 'i', type: 'string', description: 'Input embedding(s) JSON' },
426
- ],
427
- examples: [
428
- { command: 'claude-flow embeddings hyperbolic -a convert -i "[0.5, 0.3]"', description: 'Convert to Poincaré' },
429
- { command: 'claude-flow embeddings hyperbolic -a distance', description: 'Compute hyperbolic distance' },
430
- ],
431
- action: async (ctx: CommandContext): Promise<CommandResult> => {
432
- const action = ctx.flags.action as string || 'convert';
433
-
434
- output.writeln();
435
- output.writeln(output.bold('Hyperbolic Embeddings'));
436
- output.writeln(output.dim('Poincaré Ball Model'));
437
- output.writeln(output.dim('─'.repeat(50)));
438
-
439
- output.printBox([
440
- 'Hyperbolic embeddings excel at:',
441
- '• Hierarchical data representation',
442
- '• Tree-like structure preservation',
443
- '• Low-dimensional hierarchy encoding',
444
- '',
445
- 'Operations available:',
446
- '• euclideanToPoincare - Project to ball',
447
- '• poincareToEuclidean - Project back',
448
- '• hyperbolicDistance - Geodesic distance',
449
- '• mobiusAdd - Hyperbolic addition',
450
- '• hyperbolicCentroid - Fréchet mean',
451
- ].join('\n'), 'Hyperbolic Geometry');
452
-
453
- output.writeln();
454
- output.writeln(output.dim(`Action: ${action}`));
455
- output.writeln(output.dim('Use for hierarchical taxonomies, org charts, file systems'));
456
-
457
- return { success: true };
458
- },
459
- };
460
-
461
- // Neural subcommand
462
- const neuralCommand: Command = {
463
- name: 'neural',
464
- description: 'Neural substrate features (agentic-flow)',
465
- options: [
466
- { name: 'feature', short: 'f', type: 'string', description: 'Feature: drift, memory, swarm, coherence', default: 'drift' },
467
- { name: 'init', type: 'boolean', description: 'Initialize neural substrate' },
468
- ],
469
- examples: [
470
- { command: 'claude-flow embeddings neural --init', description: 'Initialize substrate' },
471
- { command: 'claude-flow embeddings neural -f drift', description: 'Semantic drift detection' },
472
- { command: 'claude-flow embeddings neural -f memory', description: 'Memory physics' },
473
- ],
474
- action: async (ctx: CommandContext): Promise<CommandResult> => {
475
- const feature = ctx.flags.feature as string || 'drift';
476
- const init = ctx.flags.init as boolean;
477
-
478
- output.writeln();
479
- output.writeln(output.bold('Neural Embedding Substrate'));
480
- output.writeln(output.dim('Treating embeddings as a synthetic nervous system'));
481
- output.writeln(output.dim('─'.repeat(60)));
482
-
483
- output.printTable({
484
- columns: [
485
- { key: 'feature', header: 'Feature', width: 22 },
486
- { key: 'description', header: 'Description', width: 40 },
487
- { key: 'status', header: 'Status', width: 12 },
488
- ],
489
- data: [
490
- { feature: 'SemanticDriftDetector', description: 'Monitor semantic movement & drift', status: output.success('Ready') },
491
- { feature: 'MemoryPhysics', description: 'Hippocampal dynamics: decay, consolidate', status: output.success('Ready') },
492
- { feature: 'EmbeddingStateMachine', description: 'Agent state through geometry', status: output.success('Ready') },
493
- { feature: 'SwarmCoordinator', description: 'Multi-agent coordination', status: output.success('Ready') },
494
- { feature: 'CoherenceMonitor', description: 'Safety & alignment detection', status: output.success('Ready') },
495
- ],
496
- });
497
-
498
- output.writeln();
499
- output.writeln(output.dim(`Selected: ${feature}`));
500
- output.writeln(output.dim('Requires: agentic-flow@alpha'));
501
-
502
- return { success: true };
503
- },
504
- };
505
-
506
- // Models subcommand
507
- const modelsCommand: Command = {
508
- name: 'models',
509
- description: 'List and download embedding models',
510
- options: [
511
- { name: 'download', short: 'd', type: 'string', description: 'Model ID to download' },
512
- { name: 'list', short: 'l', type: 'boolean', description: 'List available models', default: 'true' },
513
- ],
514
- examples: [
515
- { command: 'claude-flow embeddings models', description: 'List models' },
516
- { command: 'claude-flow embeddings models -d all-MiniLM-L6-v2', description: 'Download model' },
517
- ],
518
- action: async (ctx: CommandContext): Promise<CommandResult> => {
519
- const download = ctx.flags.download as string;
520
- const embeddings = await getEmbeddings();
521
-
522
- output.writeln();
523
- output.writeln(output.bold('Embedding Models'));
524
- output.writeln(output.dim('─'.repeat(60)));
525
-
526
- if (download) {
527
- const spinner = output.createSpinner({ text: `Downloading ${download}...`, spinner: 'dots' });
528
- spinner.start();
529
-
530
- if (embeddings) {
531
- try {
532
- await embeddings.downloadEmbeddingModel(download, '.models', (p) => {
533
- spinner.setText(`Downloading ${download}... ${p.percent.toFixed(1)}%`);
534
- });
535
- spinner.succeed(`Downloaded ${download}`);
536
- } catch (err) {
537
- spinner.fail(`Failed to download: ${err}`);
538
- return { success: false, exitCode: 1 };
539
- }
540
- } else {
541
- await new Promise(r => setTimeout(r, 500));
542
- spinner.succeed(`Download complete (simulated)`);
543
- }
544
- return { success: true };
545
- }
546
-
547
- // List models
548
- let models = [
549
- { id: 'all-MiniLM-L6-v2', dimension: 384, size: '23MB', quantized: false, downloaded: true },
550
- { id: 'all-mpnet-base-v2', dimension: 768, size: '110MB', quantized: false, downloaded: false },
551
- { id: 'paraphrase-MiniLM-L3-v2', dimension: 384, size: '17MB', quantized: false, downloaded: false },
552
- ];
553
-
554
- if (embeddings) {
555
- try {
556
- models = await embeddings.listEmbeddingModels();
557
- } catch { /* use defaults */ }
558
- }
559
-
560
- output.printTable({
561
- columns: [
562
- { key: 'id', header: 'Model ID', width: 28 },
563
- { key: 'dimension', header: 'Dims', width: 8 },
564
- { key: 'size', header: 'Size', width: 10 },
565
- { key: 'quantized', header: 'Quant', width: 8 },
566
- { key: 'downloaded', header: 'Status', width: 12 },
567
- ],
568
- data: models.map(m => ({
569
- id: m.id,
570
- dimension: String(m.dimension),
571
- size: m.size,
572
- quantized: m.quantized ? 'Yes' : 'No',
573
- downloaded: m.downloaded ? output.success('Downloaded') : output.dim('Available'),
574
- })),
575
- });
576
-
577
- return { success: true };
578
- },
579
- };
580
-
581
- // Cache subcommand
582
- const cacheCommand: Command = {
583
- name: 'cache',
584
- description: 'Manage embedding cache',
585
- options: [
586
- { name: 'action', short: 'a', type: 'string', description: 'Action: stats, clear, persist', default: 'stats' },
587
- { name: 'db-path', type: 'string', description: 'SQLite database path', default: '.cache/embeddings.db' },
588
- ],
589
- examples: [
590
- { command: 'claude-flow embeddings cache', description: 'Show cache stats' },
591
- { command: 'claude-flow embeddings cache -a clear', description: 'Clear cache' },
592
- ],
593
- action: async (ctx: CommandContext): Promise<CommandResult> => {
594
- const action = ctx.flags.action as string || 'stats';
595
- const dbPath = ctx.flags['db-path'] as string || '.cache/embeddings.db';
596
-
597
- output.writeln();
598
- output.writeln(output.bold('Embedding Cache'));
599
- output.writeln(output.dim('─'.repeat(50)));
600
-
601
- output.printTable({
602
- columns: [
603
- { key: 'cache', header: 'Cache Type', width: 18 },
604
- { key: 'entries', header: 'Entries', width: 12 },
605
- { key: 'hitRate', header: 'Hit Rate', width: 12 },
606
- { key: 'size', header: 'Size', width: 12 },
607
- ],
608
- data: [
609
- { cache: 'LRU (Memory)', entries: '256', hitRate: output.success('94.2%'), size: '2.1 MB' },
610
- { cache: 'SQLite (Disk)', entries: '8,432', hitRate: output.success('87.5%'), size: '45.2 MB' },
611
- ],
612
- });
613
-
614
- output.writeln();
615
- output.writeln(output.dim(`Database: ${dbPath}`));
616
- output.writeln(output.dim('Persistent cache survives restarts'));
617
-
618
- return { success: true };
619
- },
620
- };
621
-
622
- // Main embeddings command
623
- export const embeddingsCommand: Command = {
624
- name: 'embeddings',
625
- description: 'Vector embeddings, semantic search, similarity operations',
626
- aliases: ['embed'],
627
- subcommands: [
628
- generateCommand,
629
- searchCommand,
630
- compareCommand,
631
- collectionsCommand,
632
- indexCommand,
633
- providersCommand,
634
- chunkCommand,
635
- normalizeCommand,
636
- hyperbolicCommand,
637
- neuralCommand,
638
- modelsCommand,
639
- cacheCommand,
640
- ],
641
- examples: [
642
- { command: 'claude-flow embeddings generate -t "Hello"', description: 'Generate embedding' },
643
- { command: 'claude-flow embeddings search -q "error handling"', description: 'Semantic search' },
644
- { command: 'claude-flow embeddings chunk -t "Long doc..."', description: 'Chunk document' },
645
- { command: 'claude-flow embeddings hyperbolic -a convert', description: 'Hyperbolic space' },
646
- { command: 'claude-flow embed neural -f drift', description: 'Neural substrate' },
647
- ],
648
- action: async (): Promise<CommandResult> => {
649
- output.writeln();
650
- output.writeln(output.bold('Claude Flow Embeddings'));
651
- output.writeln(output.dim('Vector embeddings and semantic search'));
652
- output.writeln();
653
- output.writeln('Core Commands:');
654
- output.printList([
655
- 'generate - Generate embeddings for text',
656
- 'search - Semantic similarity search',
657
- 'compare - Compare similarity between texts',
658
- 'collections - Manage embedding collections',
659
- 'index - Manage HNSW indexes',
660
- 'providers - List available providers',
661
- ]);
662
- output.writeln();
663
- output.writeln('Advanced Features:');
664
- output.printList([
665
- 'chunk - Document chunking with overlap',
666
- 'normalize - L2/L1/minmax/zscore normalization',
667
- 'hyperbolic - Poincaré ball embeddings',
668
- 'neural - Neural substrate (drift, memory, swarm)',
669
- 'models - List/download ONNX models',
670
- 'cache - Manage persistent SQLite cache',
671
- ]);
672
- output.writeln();
673
- output.writeln('Performance:');
674
- output.printList([
675
- 'HNSW indexing: 150x-12,500x faster search',
676
- 'Agentic Flow: 75x faster than Transformers.js (~3ms)',
677
- 'Persistent cache: SQLite-backed, survives restarts',
678
- 'Hyperbolic: Better hierarchical representation',
679
- ]);
680
- output.writeln();
681
- output.writeln(output.dim('Created with ❤️ by ruv.io'));
682
- return { success: true };
683
- },
684
- };
685
-
686
- export default embeddingsCommand;