Class: ClaudeMemory::Commands::SweepCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ClaudeMemory::Commands::SweepCommand
- Defined in:
- lib/claude_memory/commands/sweep_command.rb
Overview
Runs maintenance and pruning on 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 |
# File 'lib/claude_memory/commands/sweep_command.rb', line 7 def call(args) opts = (args, {budget: 5, scope: "project"}) do |o| OptionParser.new do |parser| parser.on("--budget SECONDS", Integer, "Time budget in seconds") { |v| o[:budget] = v } parser.on("--scope SCOPE", "Scope: project or global") { |v| o[:scope] = v } end end return 1 if opts.nil? manager = ClaudeMemory::Store::StoreManager.new store = manager.store_for_scope(opts[:scope]) sweeper = ClaudeMemory::Sweep::Sweeper.new(store) stdout.puts "Running sweep on #{opts[:scope]} database with #{opts[:budget]}s budget..." stats = sweeper.run!(budget_seconds: opts[:budget]) stdout.puts "Sweep complete:" stdout.puts " Proposed facts expired: #{stats[:proposed_facts_expired]}" stdout.puts " Disputed facts expired: #{stats[:disputed_facts_expired]}" stdout.puts " Orphaned provenance deleted: #{stats[:orphaned_provenance_deleted]}" stdout.puts " Old content pruned: #{stats[:old_content_pruned]}" stdout.puts " Elapsed: #{stats[:elapsed_seconds].round(2)}s" stdout.puts " Budget honored: #{stats[:budget_honored]}" manager.close 0 end |