Class: Rubino::Commands::Handlers::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/commands/handlers/memory.rb

Overview

The ‘/memory` in-chat read/manage view over the active memory backend, extracted from Commands::Executor (batch B) — the same store the agent loop, the `rubino memory` CLI (#94) and the HTTP `/v1/memory` ops resolve via `Memory::Backends.build`. The agent’s MemoryTool does autonomous writes; this is the human’s window into it.

/memory                  → backend + count + recent facts
/memory --all            → recent facts INCLUDING retired, marked (#184)
/memory <query>          → substring search over content
/memory search <query>   → same search, explicit subcommand
/memory show <id>        → one fact in full, with the temporal chain (#184)
/memory forget <id>      → delete a fact
/memory backend          → active + available backends (#184)

Instance Method Summary collapse

Constructor Details

#initialize(ui:) ⇒ Memory

Returns a new instance of Memory.



20
21
22
# File 'lib/rubino/commands/handlers/memory.rb', line 20

def initialize(ui:)
  @ui = ui
end

Instance Method Details

#handle_memory(arguments) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rubino/commands/handlers/memory.rb', line 24

def handle_memory(arguments)
  args = arguments.to_s.strip

  if args.empty?
    show_memory_summary
  elsif args == "--all"
    show_memory_summary(include_retired: true)
  elsif args.match?(/\Ashow\b/)
    id = args[/\Ashow\s+(\S+)\z/, 1]
    id ? show_memory(id) : @ui.info("Usage: /memory show <id>")
  elsif args.match?(/\Abackend\b/)
    show_memory_backend(args[/\Abackend\s+(\S+)\z/, 1])
  elsif args.match?(/\Aforget\b/)
    id = args[/\Aforget\s+(\S+)\z/, 1]
    id ? forget_memory(id) : @ui.info("Usage: /memory forget <id>")
  elsif args.match?(/\Asearch\b/)
    # `search` is a subcommand token, not a query term (#59): bare
    # `/memory search` falls back to the summary instead of searching
    # for the literal word "search".
    query = args[/\Asearch\s+(.+)\z/, 1]
    query ? search_memory(query) : show_memory_summary
  else
    search_memory(args)
  end
end