Class: Girb::Tools::SessionHistoryTool

Inherits:
Base
  • Object
show all
Defined in:
lib/girb/tools/session_history_tool.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

to_gemini_tool, tool_name

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/girb/tools/session_history_tool.rb', line 21

def available?
  # Only available in IRB mode, not in debug mode
  !defined?(DEBUGGER__)
end

.descriptionObject



16
17
18
19
# File 'lib/girb/tools/session_history_tool.rb', line 16

def description
  "Get IRB session history including AI conversations from previous sessions (if persisted). " \
  "Can retrieve specific lines, line ranges, method definitions, AI conversation details, or full history."
end

.nameObject



12
13
14
# File 'lib/girb/tools/session_history_tool.rb', line 12

def name
  "get_session_history"
end

.parametersObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/girb/tools/session_history_tool.rb', line 26

def parameters
  {
    type: "object",
    properties: {
      action: {
        type: "string",
        enum: %w[get_line get_range get_method list_methods full_history list_ai_conversations get_ai_detail],
        description: "Action to perform: get_line (single line), get_range (line range), get_method (method source), list_methods (list defined methods), full_history (all history), list_ai_conversations (list AI Q&A), get_ai_detail (get AI response with reasoning)"
      },
      line: {
        type: "integer",
        description: "Line number for get_line action"
      },
      start_line: {
        type: "integer",
        description: "Start line for get_range action"
      },
      end_line: {
        type: "integer",
        description: "End line for get_range action"
      },
      method_name: {
        type: "string",
        description: "Method name for get_method action"
      }
    },
    required: ["action"]
  }
end

Instance Method Details

#execute(_binding, action:, line: nil, start_line: nil, end_line: nil, method_name: nil) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/girb/tools/session_history_tool.rb', line 57

def execute(_binding, action:, line: nil, start_line: nil, end_line: nil, method_name: nil)
  case action
  when "get_line"
    get_single_line(line)
  when "get_range"
    get_line_range(start_line, end_line)
  when "get_method"
    get_method_source(method_name)
  when "list_methods"
    list_defined_methods
  when "full_history"
    get_full_history
  when "list_ai_conversations"
    list_ai_conversations
  when "get_ai_detail"
    get_ai_detail(line)
  else
    { error: "Unknown action: #{action}" }
  end
rescue StandardError => e
  { error: "#{e.class}: #{e.message}" }
end