diff --git a/v3/@claude-flow/cli/src/commands/embeddings.ts b/v3/@claude-flow/cli/src/commands/embeddings.ts index 98eabac314..e792e9c067 100644 --- a/v3/@claude-flow/cli/src/commands/embeddings.ts +++ b/v3/@claude-flow/cli/src/commands/embeddings.ts @@ -529,29 +529,36 @@ const initCommand: Command = { options: [ { name: 'model', short: 'm', type: 'string', description: 'ONNX model ID', default: 'all-MiniLM-L6-v2' }, { name: 'hyperbolic', type: 'boolean', description: 'Enable hyperbolic (Poincaré ball) embeddings', default: 'true' }, - { name: 'curvature', short: 'c', type: 'number', description: 'Poincaré ball curvature (negative)', default: '-1' }, + { name: 'curvature', short: 'c', type: 'string', description: 'Poincaré ball curvature (use --curvature=-1 for negative)', default: '-1' }, { name: 'download', short: 'd', type: 'boolean', description: 'Download model during init', default: 'true' }, - { name: 'cache-size', type: 'number', description: 'LRU cache entries', default: '256' }, + { name: 'cache-size', type: 'string', description: 'LRU cache entries', default: '256' }, + { name: 'force', short: 'f', type: 'boolean', description: 'Overwrite existing configuration', default: 'false' }, ], examples: [ { command: 'claude-flow embeddings init', description: 'Initialize with defaults' }, { command: 'claude-flow embeddings init --model all-mpnet-base-v2', description: 'Use higher quality model' }, { command: 'claude-flow embeddings init --no-hyperbolic', description: 'Euclidean only' }, + { command: 'claude-flow embeddings init --curvature=-0.5', description: 'Custom curvature (use = for negative)' }, + { command: 'claude-flow embeddings init --force', description: 'Overwrite existing config' }, ], action: async (ctx: CommandContext): Promise => { const model = ctx.flags.model as string || 'all-MiniLM-L6-v2'; const hyperbolic = ctx.flags.hyperbolic !== false; - const curvature = parseFloat(ctx.flags.curvature as string || '-1'); const download = ctx.flags.download !== false; - const cacheSize = parseInt(ctx.flags['cache-size'] as string || '256', 10); + const force = ctx.flags.force === true; + + // Parse curvature - handle both kebab-case and direct value + const curvatureRaw = ctx.flags.curvature as string || '-1'; + const curvature = parseFloat(curvatureRaw); + + // Parse cache-size - check both kebab-case and camelCase + const cacheSizeRaw = (ctx.flags['cache-size'] || ctx.flags.cacheSize || '256') as string; + const cacheSize = parseInt(cacheSizeRaw, 10); output.writeln(); output.writeln(output.bold('Initialize Embedding Subsystem')); output.writeln(output.dim('─'.repeat(55))); - const spinner = output.createSpinner({ text: 'Initializing...', spinner: 'dots' }); - spinner.start(); - try { const fs = await import('fs'); const path = await import('path'); @@ -559,6 +566,19 @@ const initCommand: Command = { // Create directories const configDir = path.join(process.cwd(), '.claude-flow'); const modelDir = path.join(configDir, 'models'); + const configPath = path.join(configDir, 'embeddings.json'); + + // Check for existing config + if (fs.existsSync(configPath) && !force) { + output.printWarning('Embeddings already initialized'); + output.printInfo(`Config exists: ${configPath}`); + output.writeln(); + output.writeln(output.dim('Use --force to overwrite existing configuration')); + return { success: false, exitCode: 1 }; + } + + const spinner = output.createSpinner({ text: 'Initializing...', spinner: 'dots' }); + spinner.start(); if (!fs.existsSync(configDir)) { fs.mkdirSync(configDir, { recursive: true });