Class: ClaudeMemory::Commands::SetupVectorsCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ClaudeMemory::Commands::SetupVectorsCommand
- Defined in:
- lib/claude_memory/commands/setup_vectors_command.rb
Overview
Guides the user through opting into vector recall with fastembed (or another provider). fastembed stays a dev/test gem dependency by design; this command is the documented opt-in path for end users.
Steps:
1. Verify the chosen provider is loadable. For fastembed, surface
a clear install command if the gem isn't on $LOAD_PATH.
2. Persist CLAUDE_MEMORY_EMBEDDING_PROVIDER (and optional model)
into the project's .claude/settings.json env block, the same
mechanism Claude Code uses for OTel env (see OTel::SettingsWriter).
3. Re-embed existing facts under the new provider (unless --no-reindex).
4. Report the final state — provider, dimensions, stored alignment.
Constant Summary collapse
- OWNED_KEYS =
%w[ CLAUDE_MEMORY_EMBEDDING_PROVIDER CLAUDE_MEMORY_EMBEDDING_MODEL ].freeze
- FASTEMBED_INSTALL_HINT =
<<~HINT fastembed is not installed. claude-memory keeps fastembed as a dev/test dependency so the default gem install stays light. To enable it, install the gem and re-run setup-vectors: gem install fastembed claude-memory setup-vectors Or if you bundle, add to your Gemfile: gem "fastembed" Then `bundle install` and re-run setup-vectors. The first run downloads the BAAI/bge-small-en-v1.5 ONNX model (~75MB). HINT
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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/claude_memory/commands/setup_vectors_command.rb', line 43 def call(args) opts = parse_opts(args) return 1 if opts.nil? return print_status if opts[:status] provider_name = opts[:provider] unless verify_provider_loadable(provider_name) return 1 end if opts[:dry_run] stdout.puts "Would write to #{settings_path}:" stdout.puts " CLAUDE_MEMORY_EMBEDDING_PROVIDER=#{provider_name}" stdout.puts " CLAUDE_MEMORY_EMBEDDING_MODEL=#{opts[:model]}" if opts[:model] stdout.puts(opts[:reindex] ? "Would re-index facts under the new provider" : "Would skip re-index (--no-reindex)") return 0 end write_settings(provider_name, opts[:model]) if opts[:reindex] reindex_result = reindex(provider_name) return 1 if reindex_result != 0 else stdout.puts "Skipped re-index (--no-reindex). Run 'claude-memory index --force --provider=#{provider_name}' when ready." end report_final_state(provider_name) 0 end |