Class: ClaudeMemory::Commands::DigestCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/claude_memory/commands/digest_command.rb

Overview

Weekly digest — a markdown summary of what memory did over the last N days. Sections (in order): Activity, Context cost, Quality, New knowledge, Utilization, Conflicts, Feedback. The Context cost and Quality sections (added 0.11.0) read from ‘Dashboard::Trust#token_budget` and `#quality_score` so users see the cost/pollution side-by-side with the value side without needing to visit the dashboard.

The data it aggregates all already exists (activity_events, facts, conflicts, moment_feedback); this command only shapes it into a report.

Instance Attribute Summary

Attributes inherited from BaseCommand

#stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Constructor Details

This class inherits a constructor from ClaudeMemory::Commands::BaseCommand

Instance Method Details

#call(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/claude_memory/commands/digest_command.rb', line 17

def call(args)
  opts = parse_options(args, {since_days: 7, output: nil}) do |o|
    OptionParser.new do |parser|
      parser.banner = "Usage: claude-memory digest [options]"
      parser.on("--since DAYS", Integer, "Coverage window in days (default: 7)") { |v| o[:since_days] = v }
      parser.on("--output FILE", "Write to file instead of stdout") { |v| o[:output] = v }
    end
  end
  return 1 if opts.nil?
  return failure("--since must be positive") if opts[:since_days] <= 0

  manager = Store::StoreManager.new
  report = render_report(manager, opts[:since_days])
  manager.close

  if opts[:output]
    File.write(opts[:output], report)
    stderr.puts "Wrote digest to #{opts[:output]}"
  else
    stdout.puts report
  end

  0
end