Class: ClaudeMemory::Ingest::ToolExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_memory/ingest/tool_extractor.rb

Overview

Extracts tool usage information from JSONL transcript messages Tracks which tools were called during a session

Instance Method Summary collapse

Instance Method Details

#extract(raw_text) ⇒ Array<Hash>

Extract tool calls from raw transcript text

Parameters:

  • raw_text (String)

    the raw JSONL transcript content

Returns:

  • (Array<Hash>)

    array of tool call hashes



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/claude_memory/ingest/tool_extractor.rb', line 13

def extract(raw_text)
  return [] if raw_text.nil? || raw_text.empty?

  tools = []

  raw_text.lines.each do |line|
    next unless line.strip.start_with?("{")

    message = parse_message(line)
    next unless message

    extract_tools_from_message(message, tools)
  end

  tools
rescue JSON::ParserError
  # If we encounter any parsing errors, return what we've collected so far
  tools
end