Class: ClaudeMemory::Commands::IngestCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ClaudeMemory::Commands::IngestCommand
- Defined in:
- lib/claude_memory/commands/ingest_command.rb
Overview
Ingests transcript delta into memory database
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
7 8 9 10 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 42 43 44 |
# File 'lib/claude_memory/commands/ingest_command.rb', line 7 def call(args) opts = (args, {source: "claude_code", db: ClaudeMemory.project_db_path}) do |o| OptionParser.new do |parser| parser. = "Usage: claude-memory ingest [options]" parser.on("--source SOURCE", "Source identifier (default: claude_code)") { |v| o[:source] = v } parser.on("--session-id ID", "Session identifier (required)") { |v| o[:session_id] = v } parser.on("--transcript-path PATH", "Path to transcript file (required)") { |v| o[:transcript_path] = v } parser.on("--db PATH", "Database path") { |v| o[:db] = v } end end unless opts && opts[:session_id] && opts[:transcript_path] stderr.puts "\nError: --session-id and --transcript-path are required" return 1 end store = ClaudeMemory::Store::SQLiteStore.new(opts[:db]) ingester = ClaudeMemory::Ingest::Ingester.new(store) result = ingester.ingest( source: opts[:source], session_id: opts[:session_id], transcript_path: opts[:transcript_path] ) case result[:status] when :ingested stdout.puts "Ingested #{result[:bytes_read]} bytes (content_id: #{result[:content_id]})" when :no_change, :skipped stdout.puts "No new content to ingest" end store.close 0 rescue ClaudeMemory::Ingest::TranscriptReader::FileNotFoundError => e stderr.puts "Error: #{e.}" 1 end |