girb 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +56 -1
- data/README.md +271 -154
- data/README_ja.md +268 -151
- data/lib/girb/ai_client.rb +23 -5
- data/lib/girb/auto_continue.rb +1 -1
- data/lib/girb/conversation_history.rb +12 -7
- data/lib/girb/debug_integration.rb +158 -10
- data/lib/girb/debug_prompt_builder.rb +71 -11
- data/lib/girb/exception_capture.rb +4 -0
- data/lib/girb/irb_integration.rb +232 -0
- data/lib/girb/prompt_builder.rb +128 -51
- data/lib/girb/session_persistence.rb +170 -0
- data/lib/girb/tools/debug_session_history_tool.rb +61 -18
- data/lib/girb/tools/run_irb_debug_command.rb +58 -0
- data/lib/girb/tools/session_history_tool.rb +41 -8
- data/lib/girb/tools.rb +2 -1
- data/lib/girb/version.rb +1 -1
- data/lib/girb.rb +16 -7
- data/lib/irb/command/qq.rb +41 -0
- metadata +3 -1
data/lib/girb/tools.rb
CHANGED
|
@@ -11,6 +11,7 @@ require_relative "tools/session_history_tool"
|
|
|
11
11
|
require_relative "tools/debug_session_history_tool"
|
|
12
12
|
require_relative "tools/environment_tools"
|
|
13
13
|
require_relative "tools/continue_analysis"
|
|
14
|
+
require_relative "tools/run_irb_debug_command"
|
|
14
15
|
|
|
15
16
|
module Girb
|
|
16
17
|
module Tools
|
|
@@ -18,7 +19,7 @@ module Girb
|
|
|
18
19
|
SHARED_TOOLS = [InspectObject, GetSource, ListMethods, EvaluateCode, ReadFile, FindFile, GetCurrentDirectory].freeze
|
|
19
20
|
|
|
20
21
|
# IRB-only tools
|
|
21
|
-
IRB_TOOLS = [SessionHistoryTool, ContinueAnalysis].freeze
|
|
22
|
+
IRB_TOOLS = [SessionHistoryTool, ContinueAnalysis, RunIrbDebugCommand].freeze
|
|
22
23
|
|
|
23
24
|
# Debug-only tools (RunDebugCommand is registered separately in DebugIntegration)
|
|
24
25
|
DEBUG_TOOLS = [DebugSessionHistoryTool].freeze
|
data/lib/girb/version.rb
CHANGED
data/lib/girb.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Girb
|
|
|
17
17
|
class ApiError < Error; end
|
|
18
18
|
|
|
19
19
|
class << self
|
|
20
|
-
attr_accessor :configuration
|
|
20
|
+
attr_accessor :configuration, :debug_session
|
|
21
21
|
|
|
22
22
|
def configure
|
|
23
23
|
self.configuration ||= Configuration.new
|
|
@@ -51,15 +51,24 @@ end
|
|
|
51
51
|
|
|
52
52
|
# binding.girb サポート
|
|
53
53
|
class Binding
|
|
54
|
-
def girb
|
|
54
|
+
def girb(show_code: true)
|
|
55
55
|
require "irb"
|
|
56
56
|
Girb.setup! unless defined?(IRB::Command::Qq)
|
|
57
57
|
|
|
58
|
-
#
|
|
59
|
-
|
|
58
|
+
# .girbrcを読み込む(プロバイダー設定)
|
|
59
|
+
Girb::GirbrcLoader.load_girbrc unless Girb.configuration&.provider
|
|
60
|
+
|
|
61
|
+
# キーバインドを再設定(IRBセッション開始前に確実に設定)
|
|
62
|
+
Girb::IrbIntegration.install_ai_keybinding
|
|
63
|
+
|
|
64
|
+
# 標準のbinding.irbと同じ方法でIRBを起動
|
|
65
|
+
IRB.setup(source_location[0], argv: []) unless IRB.initialized?
|
|
60
66
|
workspace = IRB::WorkSpace.new(self)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
STDOUT.print(workspace.code_around_binding) if show_code
|
|
68
|
+
|
|
69
|
+
binding_irb = IRB::Irb.new(workspace, from_binding: true)
|
|
70
|
+
binding_irb.context.irb_path = File.expand_path(source_location[0])
|
|
71
|
+
binding_irb.run(IRB.conf)
|
|
72
|
+
binding_irb.debug_break
|
|
64
73
|
end
|
|
65
74
|
end
|
data/lib/irb/command/qq.rb
CHANGED
|
@@ -12,6 +12,14 @@ module IRB
|
|
|
12
12
|
question = question.to_s.strip
|
|
13
13
|
if question.empty?
|
|
14
14
|
puts "[girb] Usage: qq \"your question here\""
|
|
15
|
+
puts "[girb] qq session clear - Clear current session"
|
|
16
|
+
puts "[girb] qq session list - List saved sessions"
|
|
17
|
+
return
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# セッション管理コマンド
|
|
21
|
+
if question.start_with?("session ")
|
|
22
|
+
handle_session_command(question.sub(/^session\s+/, ""))
|
|
15
23
|
return
|
|
16
24
|
end
|
|
17
25
|
|
|
@@ -24,6 +32,9 @@ module IRB
|
|
|
24
32
|
return
|
|
25
33
|
end
|
|
26
34
|
|
|
35
|
+
# セッションが有効なら開始
|
|
36
|
+
Girb::IrbIntegration.start_session! if Girb::SessionPersistence.enabled?
|
|
37
|
+
|
|
27
38
|
current_binding = irb_context.workspace.binding
|
|
28
39
|
|
|
29
40
|
# AI質問を履歴に記録
|
|
@@ -49,6 +60,36 @@ module IRB
|
|
|
49
60
|
puts "[girb] Error: #{e.message}"
|
|
50
61
|
puts e.backtrace.first(5).join("\n") if Girb.configuration&.debug
|
|
51
62
|
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def handle_session_command(cmd)
|
|
67
|
+
case cmd.strip
|
|
68
|
+
when "clear"
|
|
69
|
+
Girb::SessionPersistence.clear_session
|
|
70
|
+
when "list"
|
|
71
|
+
sessions = Girb::SessionPersistence.list_sessions
|
|
72
|
+
if sessions.empty?
|
|
73
|
+
puts "[girb] No saved sessions"
|
|
74
|
+
else
|
|
75
|
+
puts "[girb] Saved sessions:"
|
|
76
|
+
sessions.each do |s|
|
|
77
|
+
puts " - #{s[:id]} (#{s[:message_count]} messages, saved: #{s[:saved_at]})"
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
when "status"
|
|
81
|
+
if Girb::SessionPersistence.current_session_id
|
|
82
|
+
puts "[girb] Current session: #{Girb::SessionPersistence.current_session_id}"
|
|
83
|
+
elsif Girb.debug_session
|
|
84
|
+
puts "[girb] Session configured: #{Girb.debug_session} (not started)"
|
|
85
|
+
else
|
|
86
|
+
puts "[girb] No session configured (use Girb.debug_session = 'name' to enable)"
|
|
87
|
+
end
|
|
88
|
+
else
|
|
89
|
+
puts "[girb] Unknown session command: #{cmd}"
|
|
90
|
+
puts "[girb] Available: clear, list, status"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
52
93
|
end
|
|
53
94
|
end
|
|
54
95
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: girb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- rira100000000
|
|
@@ -99,6 +99,7 @@ files:
|
|
|
99
99
|
- lib/girb/providers/base.rb
|
|
100
100
|
- lib/girb/railtie.rb
|
|
101
101
|
- lib/girb/session_history.rb
|
|
102
|
+
- lib/girb/session_persistence.rb
|
|
102
103
|
- lib/girb/tools.rb
|
|
103
104
|
- lib/girb/tools/base.rb
|
|
104
105
|
- lib/girb/tools/continue_analysis.rb
|
|
@@ -112,6 +113,7 @@ files:
|
|
|
112
113
|
- lib/girb/tools/rails_tools.rb
|
|
113
114
|
- lib/girb/tools/read_file.rb
|
|
114
115
|
- lib/girb/tools/run_debug_command.rb
|
|
116
|
+
- lib/girb/tools/run_irb_debug_command.rb
|
|
115
117
|
- lib/girb/tools/session_history_tool.rb
|
|
116
118
|
- lib/girb/version.rb
|
|
117
119
|
- lib/irb/command/qq.rb
|