Class: ClaudeMemory::Commands::AuditCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ClaudeMemory::Commands::AuditCommand
- Defined in:
- lib/claude_memory/commands/audit_command.rb
Overview
Runs the memory health audit and prints findings. Exits non-zero when error-severity findings are present (unless –no-exit is given). JSON output is the stable surface — humans should not script against the text output.
Constant Summary collapse
- SEVERITY_RANK =
{info: 0, warn: 1, error: 2}.freeze
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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/claude_memory/commands/audit_command.rb', line 15 def call(args) opts = parse_opts(args) return 1 if opts.nil? manager = Store::StoreManager.new result = Audit::Runner.new(manager: manager).run filtered = filter_by_severity(result.findings, opts[:severity]) if opts[:json] stdout.puts JSON.pretty_generate(payload(result, filtered)) else render_text(result, filtered) end manager.close opts[:no_exit] ? 0 : result.exit_code end |
#filter_by_severity(findings, threshold) ⇒ Object
33 34 35 36 37 |
# File 'lib/claude_memory/commands/audit_command.rb', line 33 def filter_by_severity(findings, threshold) return findings if threshold.nil? floor = SEVERITY_RANK.fetch(threshold) { return findings } findings.select { |f| SEVERITY_RANK[f.severity] >= floor } end |