Class: ClaudeMemory::Commands::CompactCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ClaudeMemory::Commands::CompactCommand
- Defined in:
- lib/claude_memory/commands/compact_command.rb
Overview
Runs SQLite VACUUM and optional integrity check on memory databases. Reclaims space from deleted/superseded facts and defragments storage.
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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/claude_memory/commands/compact_command.rb', line 8 def call(args) opts = (args, {scope: "all", check: false}) do |o| OptionParser.new do |parser| parser. = "Usage: claude-memory compact [options]" parser.on("--scope SCOPE", %w[all global project], "Scope: all (default), global, or project") { |v| o[:scope] = v } parser.on("--check", "Run integrity check before compacting") { o[:check] = true } end end return 1 if opts.nil? manager = ClaudeMemory::Store::StoreManager.new if opts[:scope] == "all" || opts[:scope] == "global" compact_database("global", manager.global_db_path, check: opts[:check]) end if opts[:scope] == "all" || opts[:scope] == "project" compact_database("project", manager.project_db_path, check: opts[:check]) end manager.close 0 end |