Class: ClaudeMemory::Commands::ImportAutoMemoryCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ClaudeMemory::Commands::ImportAutoMemoryCommand
- Defined in:
- lib/claude_memory/commands/import_auto_memory_command.rb
Overview
Imports Claude Code auto-memory files (~/.claude/projects/<slug>/memory/*.md) into the project database as durable facts. Before this command, those markdown files were only surfaced transiently via ‘Hook::AutoMemoryMirror` at SessionStart — they were invisible to `memory.recall` and the shortcut tools. Importing them as facts (predicate=convention for gotcha/feedback/project files, predicate=reference for reference type) makes that knowledge first-class queryable knowledge.
Idempotent on object_literal prefix: re-running skips files whose body text is already present.
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
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/claude_memory/commands/import_auto_memory_command.rb', line 19 def call(args) opts = parse_opts(args) return 1 if opts.nil? auto_dir = resolve_auto_dir files = list_files(auto_dir) if files.empty? stdout.puts "No auto-memory files found in #{auto_dir}" return 0 end manager = Store::StoreManager.new manager.ensure_project! store = manager.project_store imported = 0 skipped = 0 files.each do |path| fact_data = parse_file(path) next if fact_data.nil? if already_imported?(store, fact_data[:object_literal]) skipped += 1 next end if opts[:dry_run] stdout.puts "[DRY] #{File.basename(path)} → #{fact_data[:predicate]}" else insert(store, fact_data, path) stdout.puts "Imported: #{File.basename(path)} → #{fact_data[:predicate]}" end imported += 1 end stdout.puts "" verb = opts[:dry_run] ? "Would import" : "Imported" stdout.puts "#{verb}: #{imported} Skipped (already present): #{skipped}" manager.close 0 end |