Class: ClaudeMemory::Commands::IndexCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ClaudeMemory::Commands::IndexCommand
- Defined in:
- lib/claude_memory/commands/index_command.rb
Overview
Generates embeddings for facts that don’t have them yet
Constant Summary collapse
- SCOPE_ALL =
"all"- SCOPE_GLOBAL =
"global"- SCOPE_PROJECT =
"project"
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
Constructor Details
This class inherits a constructor from ClaudeMemory::Commands::BaseCommand
Instance Method Details
#call(args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/claude_memory/commands/index_command.rb', line 11 def call(args) opts = (args, {scope: SCOPE_ALL, batch_size: 100, force: false, vec: false, provider: nil}) do |o| OptionParser.new do |parser| parser. = "Usage: claude-memory index [options]" parser.on("--scope SCOPE", "Scope: global, project, or all (default: all)") { |v| o[:scope] = v } parser.on("--batch-size SIZE", Integer, "Batch size (default: 100)") { |v| o[:batch_size] = v } parser.on("--force", "Re-index facts that already have embeddings") { o[:force] = true } parser.on("--vec", "Backfill vec0 index from existing embeddings (no regeneration)") { o[:vec] = true } parser.on("--provider NAME", "Embedding provider: tfidf, fastembed, api") { |v| o[:provider] = v } end end return 1 if opts.nil? unless valid_scope?(opts[:scope]) stderr.puts "Invalid scope: #{opts[:scope]}" stderr.puts "Valid scopes: global, project, all" return 1 end if opts[:vec] return vec_backfill(opts) end generator = Embeddings.resolve(opts[:provider]) scopes_for(opts[:scope]).each do |label, db_path| index_database(label, db_path, generator, opts) end 0 end |