Class: Llmemory::Cli::Commands::Procedural

Inherits:
Base
  • Object
show all
Defined in:
lib/llmemory/cli/commands/procedural.rb

Instance Method Summary collapse

Methods inherited from Base

#parse_options, #run

Instance Method Details

#execute(argv, _opts) ⇒ Object



14
15
16
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/llmemory/cli/commands/procedural.rb', line 14

def execute(argv, _opts)
  user_id = argv.first
  unless user_id
    $stderr.puts "Usage: llmemory skills USER_ID [--limit N] [--store TYPE]"
    exit 1
  end

  storage = procedural_storage(@store_type)
  skills = storage.list_skills(user_id, limit: @limit)

  if skills.empty?
    puts "No skills for user #{user_id}."
    return
  end

  skills.each do |s|
    id = s[:id] || s["id"]
    name = s[:name] || s["name"]
    kind = s[:kind] || s["kind"]
    version = s[:version] || s["version"]
    succ = (s[:success_count] || s["success_count"] || 0).to_i
    fail = (s[:failure_count] || s["failure_count"] || 0).to_i
    total = succ + fail
    rate = total.zero? ? "n/a" : format("%.2f", succ.to_f / total)
    puts "[#{id}] #{name} v#{version} (#{kind}) — success rate: #{rate} (#{succ}/#{total})"
  end
end

#option_parser(parser) ⇒ Object



9
10
11
12
# File 'lib/llmemory/cli/commands/procedural.rb', line 9

def option_parser(parser)
  parser.on("--limit N", Integer, "Max number of skills (newest first)") { |v| @limit = v }
  parser.on("--store TYPE", "Storage type (memory|file|postgres|active_record)") { |v| @store_type = v }
end