girb 0.2.0 → 0.3.0
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 +42 -1
- data/README.md +271 -154
- data/README_ja.md +268 -151
- data/lib/girb/ai_client.rb +18 -4
- data/lib/girb/auto_continue.rb +1 -1
- data/lib/girb/debug_integration.rb +138 -10
- data/lib/girb/debug_prompt_builder.rb +25 -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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fb74de93bd206f42859682f712f57bf0603c2348e665775b6c19833af65fd1f
|
|
4
|
+
data.tar.gz: af6f430afff9ca6123bddfc4a87820956cbff3fda65721d86f39f5ad688cdea5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8998f2942d8cf0ed23012c65dbede91b88231a0e26e31ed2b808c8cc513dc69bf162fb709320768880f59536ab5a5e1031fac0f8ac5cfdb096281d0abcae3b49
|
|
7
|
+
data.tar.gz: 1fda60427ec07042e05d2840f4ef99ba0740552e3735b10012d46c990ba62deeb653c21fc19c5653ae03e60150af9083fa3869deace3c7b3e0780632a0cbaa59
|
data/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0] - 2026-02-07
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Session persistence**: Persist AI conversation history across sessions
|
|
8
|
+
- Enable with `Girb.debug_session = "session_name"`
|
|
9
|
+
- `qq session status/list/clear` commands for session management
|
|
10
|
+
- Sessions saved to `.girb/sessions/<session_id>.json`
|
|
11
|
+
- Auto-cleanup of sessions inactive for 7+ days
|
|
12
|
+
- Works in both IRB and debug modes
|
|
13
|
+
- **Persisted conversations in `get_session_history` tool**
|
|
14
|
+
- Access previous session's AI conversations
|
|
15
|
+
- **`run_debug_command` tool for IRB mode**
|
|
16
|
+
- AI can now execute debug commands (next, step, continue, etc.) in `binding.girb`
|
|
17
|
+
- Enables autonomous step-by-step debugging in IRB sessions
|
|
18
|
+
- **Seamless `binding.girb` to debug mode transition**
|
|
19
|
+
- When AI executes debug commands (next, step, etc.) in `binding.girb`, automatically transitions to debug mode
|
|
20
|
+
- Original user instruction is preserved and passed to debug mode for continuous execution
|
|
21
|
+
- AI can autonomously step through code with `auto_continue: true`
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Debug mode AI command changed from `ai` to `qq` (consistent with IRB mode)
|
|
26
|
+
- Separate prompts for different modes (auto-detected):
|
|
27
|
+
- Breakpoint mode (`binding.girb`): Focus on actual code in file
|
|
28
|
+
- Interactive mode (`girb` command): Focus on session history
|
|
29
|
+
- Rails mode (`rails console`): Rails-specific guidance
|
|
30
|
+
- Debug commands in IRB mode are now injected via `ReadmultilinePatch` to ensure proper execution at IRB's top level
|
|
31
|
+
- Improved debug prompt to prefer conditional breakpoints for loops (efficient) over repeated stepping (slow)
|
|
32
|
+
- Continuation message now warns AI not to re-execute already-run commands
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- Exclude forwardable from exception capture (false SyntaxError detection)
|
|
37
|
+
- Exclude rubygems from exception capture (false LoadError during gem activation)
|
|
38
|
+
- Fix `binding.girb` Ctrl+Space keybinding registration
|
|
39
|
+
- Fix `binding.girb` not loading `.girbrc` (provider configuration missing)
|
|
40
|
+
- Fix `binding.girb` to properly pass binding context (debug commands now work on user's script)
|
|
41
|
+
- Fix deadlock when making API calls in debug mode by temporarily disabling Ruby's `Timeout` module
|
|
42
|
+
- Fix `GIRB_DIR` constant scope for proper frame filtering in debugger
|
|
43
|
+
|
|
3
44
|
## [0.2.0] - 2026-02-05
|
|
4
45
|
|
|
5
46
|
### Added
|
|
6
47
|
|
|
7
48
|
- **Debug gem (rdbg) integration**: AI assistant for step-through debugging
|
|
8
|
-
- `
|
|
49
|
+
- `qq <question>` command in debugger
|
|
9
50
|
- Ctrl+Space to send input to AI
|
|
10
51
|
- Auto-routing of non-ASCII (Japanese) input to AI
|
|
11
52
|
- `run_debug_command` tool for AI to execute debugger commands (step, next, continue, break, etc.)
|
data/README.md
CHANGED
|
@@ -1,40 +1,77 @@
|
|
|
1
1
|
# girb (Generative IRB)
|
|
2
2
|
|
|
3
|
-
An AI assistant
|
|
3
|
+
An AI assistant for Ruby development. Works with IRB, Rails console, and the debug gem.
|
|
4
4
|
|
|
5
5
|
[日本語版 README](README_ja.md)
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- **Context Awareness**:
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **Debug Gem Integration**: Use with Ruby's debug gem for step-through debugging with AI assistance
|
|
15
|
-
- **Multi-language Support**: Detects user's language and responds in the same language
|
|
16
|
-
- **Customizable**: Add custom prompts for project-specific instructions
|
|
17
|
-
- **Provider Agnostic**: Use any LLM provider or implement your own
|
|
9
|
+
- **Context Awareness**: Understands local variables, instance variables, and runtime state
|
|
10
|
+
- **Tool Execution**: AI autonomously executes code, inspects objects, and reads files
|
|
11
|
+
- **Autonomous Investigation**: AI loops through investigate-execute-analyze cycles
|
|
12
|
+
- **Multi-environment Support**: Works with IRB, Rails console, and debug gem (rdbg)
|
|
13
|
+
- **Provider Agnostic**: Use any LLM (OpenAI, Anthropic, Gemini, Ollama, etc.)
|
|
18
14
|
|
|
19
|
-
##
|
|
15
|
+
## Quick Start
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
```bash
|
|
18
|
+
# 1. Install
|
|
19
|
+
gem install girb girb-ruby_llm
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
# 2. Set your API key
|
|
22
|
+
export GEMINI_API_KEY="your-api-key" # or OPENAI_API_KEY, ANTHROPIC_API_KEY
|
|
24
23
|
|
|
24
|
+
# 3. Create ~/.girbrc
|
|
25
25
|
```ruby
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
require 'girb-ruby_llm'
|
|
27
|
+
Girb.configure do |c|
|
|
28
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
28
29
|
end
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
# 4. Run
|
|
33
|
+
girb
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then type a question and press **Ctrl+Space**, or use `qq <question>`.
|
|
37
|
+
|
|
38
|
+
## Table of Contents
|
|
39
|
+
|
|
40
|
+
1. [Configuration](#1-configuration) - Common setup for all environments
|
|
41
|
+
2. [Ruby Scripts (IRB)](#2-ruby-scripts-irb) - Using with pure Ruby
|
|
42
|
+
3. [Rails](#3-rails) - Using with Rails console
|
|
43
|
+
4. [Debug Gem (rdbg)](#4-debug-gem-rdbg) - Step-through debugging with AI
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 1. Configuration
|
|
48
|
+
|
|
49
|
+
### Installation
|
|
32
50
|
|
|
33
51
|
```bash
|
|
34
|
-
|
|
52
|
+
gem install girb girb-ruby_llm
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Available provider gems:
|
|
56
|
+
- [girb-ruby_llm](https://github.com/rira100000000/girb-ruby_llm) - OpenAI, Anthropic, Gemini, Ollama, etc. (Recommended)
|
|
57
|
+
- [girb-gemini](https://github.com/rira100000000/girb-gemini) - Google Gemini only
|
|
58
|
+
|
|
59
|
+
### API Keys
|
|
60
|
+
|
|
61
|
+
Set the API key for your chosen LLM provider as an environment variable:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
export GEMINI_API_KEY="your-api-key"
|
|
65
|
+
# or OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.
|
|
35
66
|
```
|
|
36
67
|
|
|
37
|
-
|
|
68
|
+
For detailed setup instructions (Ollama, other providers, advanced options), see the provider gem documentation:
|
|
69
|
+
- [girb-ruby_llm](https://github.com/rira100000000/girb-ruby_llm)
|
|
70
|
+
- [girb-gemini](https://github.com/rira100000000/girb-gemini)
|
|
71
|
+
|
|
72
|
+
### Create .girbrc
|
|
73
|
+
|
|
74
|
+
Create a `.girbrc` file in your project root (or home directory for global config):
|
|
38
75
|
|
|
39
76
|
```ruby
|
|
40
77
|
# .girbrc
|
|
@@ -45,70 +82,104 @@ Girb.configure do |c|
|
|
|
45
82
|
end
|
|
46
83
|
```
|
|
47
84
|
|
|
48
|
-
|
|
85
|
+
girb searches for `.girbrc` in this order:
|
|
86
|
+
1. Current directory → parent directories (up to root)
|
|
87
|
+
2. `~/.girbrc` as fallback
|
|
49
88
|
|
|
50
|
-
###
|
|
89
|
+
### Model Examples
|
|
51
90
|
|
|
52
|
-
|
|
91
|
+
```ruby
|
|
92
|
+
# Google Gemini
|
|
93
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
53
94
|
|
|
54
|
-
|
|
55
|
-
|
|
95
|
+
# OpenAI
|
|
96
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gpt-5.2-2025-12-11')
|
|
97
|
+
|
|
98
|
+
# Anthropic
|
|
99
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'claude-opus-4-5')
|
|
56
100
|
```
|
|
57
101
|
|
|
58
|
-
|
|
102
|
+
### Configuration Options
|
|
59
103
|
|
|
60
104
|
```ruby
|
|
61
|
-
# .girbrc
|
|
62
|
-
require 'girb-ruby_llm'
|
|
63
|
-
|
|
64
105
|
Girb.configure do |c|
|
|
106
|
+
# Required: LLM provider
|
|
65
107
|
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
108
|
+
|
|
109
|
+
# Optional: Debug output
|
|
110
|
+
c.debug = true
|
|
111
|
+
|
|
112
|
+
# Optional: Custom system prompt
|
|
113
|
+
c.custom_prompt = <<~PROMPT
|
|
114
|
+
This is production. Always confirm before destructive operations.
|
|
115
|
+
PROMPT
|
|
66
116
|
end
|
|
67
117
|
```
|
|
68
118
|
|
|
69
|
-
|
|
119
|
+
### Environment Variables (Fallback)
|
|
70
120
|
|
|
71
|
-
|
|
121
|
+
Used when provider is not configured in `.girbrc`:
|
|
72
122
|
|
|
73
|
-
|
|
123
|
+
| Variable | Description |
|
|
124
|
+
|----------|-------------|
|
|
125
|
+
| `GIRB_PROVIDER` | Provider gem (e.g., `girb-ruby_llm`) |
|
|
126
|
+
| `GIRB_MODEL` | Model name (e.g., `gemini-2.5-flash`) |
|
|
127
|
+
| `GIRB_DEBUG` | Set to `1` for debug output |
|
|
74
128
|
|
|
75
|
-
|
|
76
|
-
|
|
129
|
+
### Session Persistence (Optional)
|
|
130
|
+
|
|
131
|
+
Persist AI conversation history across sessions. Only enabled when you explicitly set a session ID.
|
|
77
132
|
|
|
78
|
-
|
|
133
|
+
#### Enable
|
|
79
134
|
|
|
80
|
-
|
|
81
|
-
- **Shared settings**: Place `.girbrc` in a parent directory (e.g., `~/work/.girbrc` for all work projects)
|
|
82
|
-
- **Global default**: Place `.girbrc` in your home directory
|
|
135
|
+
Set a session ID in `.girbrc`:
|
|
83
136
|
|
|
84
|
-
|
|
137
|
+
```ruby
|
|
138
|
+
Girb.configure do |c|
|
|
139
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
140
|
+
end
|
|
85
141
|
|
|
86
|
-
|
|
142
|
+
# Enable session persistence (optional)
|
|
143
|
+
Girb.debug_session = "my-project"
|
|
144
|
+
```
|
|
87
145
|
|
|
88
|
-
|
|
89
|
-
- [girb-gemini](https://github.com/rira100000000/girb-gemini) - Google Gemini
|
|
146
|
+
Or set dynamically in code:
|
|
90
147
|
|
|
91
|
-
|
|
148
|
+
```ruby
|
|
149
|
+
Girb.debug_session = "debug-user-auth"
|
|
150
|
+
debugger # Conversations in this session will be saved
|
|
151
|
+
```
|
|
92
152
|
|
|
93
|
-
|
|
153
|
+
#### Session Management Commands
|
|
94
154
|
|
|
95
|
-
|
|
155
|
+
Use in IRB or debug mode:
|
|
96
156
|
|
|
97
|
-
```bash
|
|
98
|
-
rails console
|
|
99
157
|
```
|
|
158
|
+
qq session status # Show current session status
|
|
159
|
+
qq session list # List saved sessions
|
|
160
|
+
qq session clear # Clear current session
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Behavior
|
|
100
164
|
|
|
101
|
-
|
|
165
|
+
- Sessions are saved to `.girb/sessions/<session_id>.json`
|
|
166
|
+
- Sessions inactive for 7+ days are automatically deleted
|
|
167
|
+
- Resuming with the same session ID continues the previous conversation
|
|
168
|
+
- Use `get_session_history` tool to reference past conversations
|
|
102
169
|
|
|
103
|
-
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 2. Ruby Scripts (IRB)
|
|
173
|
+
|
|
174
|
+
### Usage
|
|
175
|
+
|
|
176
|
+
Use `girb` command instead of `irb`:
|
|
104
177
|
|
|
105
178
|
```bash
|
|
106
179
|
girb
|
|
107
180
|
```
|
|
108
181
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Insert `binding.girb` in your code:
|
|
182
|
+
Or insert `binding.girb` in your code:
|
|
112
183
|
|
|
113
184
|
```ruby
|
|
114
185
|
def problematic_method
|
|
@@ -118,111 +189,192 @@ def problematic_method
|
|
|
118
189
|
end
|
|
119
190
|
```
|
|
120
191
|
|
|
121
|
-
###
|
|
192
|
+
### How to Ask AI
|
|
122
193
|
|
|
123
|
-
|
|
194
|
+
**Ctrl+Space**: Press after typing your question
|
|
124
195
|
|
|
125
|
-
```
|
|
126
|
-
|
|
196
|
+
```
|
|
197
|
+
irb(main):001> Why did this fail?[Ctrl+Space]
|
|
198
|
+
```
|
|
127
199
|
|
|
128
|
-
|
|
129
|
-
result = some_calculation
|
|
130
|
-
result
|
|
131
|
-
end
|
|
200
|
+
**qq command**: Use the qq method
|
|
132
201
|
|
|
133
|
-
problematic_method
|
|
134
202
|
```
|
|
203
|
+
irb(main):001> qq How do I use this method?
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Available Tools (IRB)
|
|
207
|
+
|
|
208
|
+
| Tool | Description |
|
|
209
|
+
|------|-------------|
|
|
210
|
+
| `evaluate_code` | Execute Ruby code |
|
|
211
|
+
| `inspect_object` | Inspect object details |
|
|
212
|
+
| `get_source` | Get method/class source code |
|
|
213
|
+
| `list_methods` | List methods of an object |
|
|
214
|
+
| `find_file` | Search for files |
|
|
215
|
+
| `read_file` | Read file contents |
|
|
216
|
+
| `get_session_history` | Get IRB session history |
|
|
217
|
+
| `continue_analysis` | Request context refresh for autonomous investigation |
|
|
218
|
+
|
|
219
|
+
### Example
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
irb(main):001> x = [1, 2, 3]
|
|
223
|
+
irb(main):002> What methods can I use to find the sum?[Ctrl+Space]
|
|
224
|
+
You can use `x.sum` which returns 6. Alternatively, `x.reduce(:+)` or `x.inject(0, :+)`.
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 3. Rails
|
|
230
|
+
|
|
231
|
+
### Installation
|
|
232
|
+
|
|
233
|
+
Add to your Gemfile:
|
|
135
234
|
|
|
136
|
-
|
|
235
|
+
```ruby
|
|
236
|
+
group :development do
|
|
237
|
+
gem 'girb'
|
|
238
|
+
gem 'girb-ruby_llm'
|
|
239
|
+
end
|
|
240
|
+
```
|
|
137
241
|
|
|
138
242
|
```bash
|
|
139
|
-
|
|
243
|
+
bundle install
|
|
140
244
|
```
|
|
141
245
|
|
|
142
|
-
|
|
143
|
-
- `ai <question>` - Ask AI a question
|
|
144
|
-
- `Ctrl+Space` - Send current input to AI
|
|
145
|
-
- Natural language (non-ASCII) input is automatically routed to AI
|
|
246
|
+
### Configuration
|
|
146
247
|
|
|
147
|
-
|
|
248
|
+
Create `.girbrc` in your Rails project root. See [Configuration](#1-configuration) for details.
|
|
148
249
|
|
|
149
|
-
###
|
|
250
|
+
### Usage
|
|
150
251
|
|
|
151
|
-
|
|
252
|
+
Just run `rails console` - girb loads automatically via Railtie:
|
|
152
253
|
|
|
153
|
-
|
|
254
|
+
```bash
|
|
255
|
+
rails console
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Additional Tools (Rails)
|
|
259
|
+
|
|
260
|
+
| Tool | Description |
|
|
261
|
+
|------|-------------|
|
|
262
|
+
| `query_model` | Execute ActiveRecord queries |
|
|
263
|
+
| `model_info` | Get model schema information |
|
|
264
|
+
|
|
265
|
+
### Example
|
|
154
266
|
|
|
155
267
|
```
|
|
156
|
-
irb(main):001>
|
|
268
|
+
irb(main):001> user = User.find(1)
|
|
269
|
+
irb(main):002> user.update(name: "test")
|
|
270
|
+
=> false
|
|
271
|
+
irb(main):003> Why did the update fail?[Ctrl+Space]
|
|
272
|
+
Checking `user.errors.full_messages` shows:
|
|
273
|
+
- "Email can't be blank"
|
|
274
|
+
The email attribute is being cleared during the update.
|
|
157
275
|
```
|
|
158
276
|
|
|
159
|
-
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## 4. Debug Gem (rdbg)
|
|
160
280
|
|
|
281
|
+
Step-through debugging with AI assistance.
|
|
282
|
+
|
|
283
|
+
### Configuration
|
|
284
|
+
|
|
285
|
+
Same `.girbrc` as above.
|
|
286
|
+
|
|
287
|
+
### For Standalone Ruby Scripts
|
|
288
|
+
|
|
289
|
+
Add `require "debug"` and `require "girb"`, then use `debugger` statement:
|
|
290
|
+
|
|
291
|
+
**Note:** `require "debug"` must come before `require "girb"`.
|
|
292
|
+
|
|
293
|
+
```ruby
|
|
294
|
+
require "debug"
|
|
295
|
+
require "girb"
|
|
296
|
+
|
|
297
|
+
def calculate(x)
|
|
298
|
+
result = x * 2
|
|
299
|
+
debugger # Stops here with AI assistance
|
|
300
|
+
result + 1
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
calculate(5)
|
|
161
304
|
```
|
|
162
|
-
|
|
305
|
+
|
|
306
|
+
Run with ruby:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
ruby your_script.rb
|
|
163
310
|
```
|
|
164
311
|
|
|
165
|
-
|
|
312
|
+
### For Rails
|
|
166
313
|
|
|
167
|
-
|
|
314
|
+
Create an initializer to load girb after debug gem:
|
|
168
315
|
|
|
169
316
|
```ruby
|
|
170
|
-
|
|
317
|
+
# config/initializers/girb.rb
|
|
318
|
+
require "girb" if Rails.env.development? || Rails.env.test?
|
|
319
|
+
```
|
|
171
320
|
|
|
172
|
-
|
|
173
|
-
# Debug output (default: false)
|
|
174
|
-
c.debug = true
|
|
321
|
+
Then use `debugger` statement in your code:
|
|
175
322
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
323
|
+
```ruby
|
|
324
|
+
def show
|
|
325
|
+
@user = User.find(params[:id])
|
|
326
|
+
debugger # Stops here with AI assistance
|
|
180
327
|
end
|
|
181
328
|
```
|
|
182
329
|
|
|
183
|
-
###
|
|
330
|
+
### How to Ask AI (Debug Mode)
|
|
184
331
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
332
|
+
- **`qq <question>`** - Ask AI a question
|
|
333
|
+
- **Ctrl+Space** - Send current input to AI
|
|
334
|
+
- **Natural language** - Non-ASCII input (e.g., Japanese) automatically routes to AI
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
(rdbg) qq What is the value of result here?
|
|
338
|
+
(rdbg) 次の行に進んで[Ctrl+Space]
|
|
189
339
|
```
|
|
190
340
|
|
|
191
|
-
###
|
|
341
|
+
### AI Can Execute Debug Commands
|
|
192
342
|
|
|
193
|
-
|
|
343
|
+
The AI can run debugger commands for you:
|
|
194
344
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
345
|
+
```
|
|
346
|
+
(rdbg) qq Step through this loop and tell me when x becomes 1
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
The AI will use `step`, `next`, `continue`, `break`, etc. automatically.
|
|
350
|
+
|
|
351
|
+
### Ctrl+C to Interrupt
|
|
200
352
|
|
|
201
|
-
|
|
353
|
+
Press Ctrl+C to interrupt long-running AI operations. The AI will summarize progress.
|
|
354
|
+
|
|
355
|
+
### Available Tools (Debug Mode)
|
|
202
356
|
|
|
203
357
|
| Tool | Description |
|
|
204
358
|
|------|-------------|
|
|
205
|
-
| `evaluate_code` | Execute Ruby code in
|
|
359
|
+
| `evaluate_code` | Execute Ruby code in current context |
|
|
206
360
|
| `inspect_object` | Inspect object details |
|
|
207
|
-
| `get_source` | Get source code
|
|
208
|
-
| `
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `session_history` | Get IRB session history |
|
|
212
|
-
| `continue_analysis` | Request context refresh for autonomous investigation |
|
|
361
|
+
| `get_source` | Get method/class source code |
|
|
362
|
+
| `read_file` | Read source files |
|
|
363
|
+
| `run_debug_command` | Execute debugger commands |
|
|
364
|
+
| `get_session_history` | Get debug session history |
|
|
213
365
|
|
|
214
|
-
###
|
|
366
|
+
### Example: Variable Tracking
|
|
215
367
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
| `query_model` | Execute queries on ActiveRecord models |
|
|
219
|
-
| `model_info` | Get model schema information |
|
|
368
|
+
```
|
|
369
|
+
(rdbg) qq Track all values of x through this loop and report when done
|
|
220
370
|
|
|
221
|
-
|
|
371
|
+
[AI sets breakpoints, runs continue, collects values]
|
|
222
372
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
373
|
+
Tracked values of x: [7, 66, 85, 11, 53, 42, 99, 23]
|
|
374
|
+
Loop completed.
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
226
378
|
|
|
227
379
|
## Custom Providers
|
|
228
380
|
|
|
@@ -234,61 +386,26 @@ class MyProvider < Girb::Providers::Base
|
|
|
234
386
|
@api_key = api_key
|
|
235
387
|
end
|
|
236
388
|
|
|
237
|
-
def chat(messages:, system_prompt:, tools:)
|
|
238
|
-
#
|
|
239
|
-
# tools: Array of { name: "...", description: "...", parameters: {...} }
|
|
240
|
-
|
|
241
|
-
# Call your LLM API here
|
|
389
|
+
def chat(messages:, system_prompt:, tools:, binding: nil)
|
|
390
|
+
# Call your LLM API
|
|
242
391
|
response = call_my_llm(messages, system_prompt, tools)
|
|
243
392
|
|
|
244
|
-
# Return a Response object
|
|
245
393
|
Girb::Providers::Base::Response.new(
|
|
246
394
|
text: response.text,
|
|
247
395
|
function_calls: response.tool_calls&.map { |tc| { name: tc.name, args: tc.args } }
|
|
248
396
|
)
|
|
249
397
|
end
|
|
250
398
|
end
|
|
251
|
-
|
|
252
|
-
Girb.configure do |c|
|
|
253
|
-
c.provider = MyProvider.new(api_key: ENV['MY_API_KEY'])
|
|
254
|
-
end
|
|
255
399
|
```
|
|
256
400
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
### Debugging Assistance
|
|
260
|
-
|
|
261
|
-
```
|
|
262
|
-
irb(main):001> user = User.find(1)
|
|
263
|
-
irb(main):002> user.update(name: "test")
|
|
264
|
-
=> false
|
|
265
|
-
irb(main):003> Why did the update fail?[Ctrl+Space]
|
|
266
|
-
Checking `user.errors.full_messages` shows validation errors:
|
|
267
|
-
- "Email can't be blank"
|
|
268
|
-
The email might be getting cleared when updating the name.
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### Code Understanding
|
|
272
|
-
|
|
273
|
-
```
|
|
274
|
-
irb(main):001> Where is the User model defined in this project?[Ctrl+Space]
|
|
275
|
-
It's defined in app/models/user.rb.
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### Pattern Recognition
|
|
279
|
-
|
|
280
|
-
```
|
|
281
|
-
irb(main):001> a = 1
|
|
282
|
-
irb(main):002> b = 2
|
|
283
|
-
irb(main):003> What would z be if I continue with c = 3 and beyond?[Ctrl+Space]
|
|
284
|
-
Following the pattern a=1, b=2, c=3..., z would be 26.
|
|
285
|
-
```
|
|
401
|
+
---
|
|
286
402
|
|
|
287
403
|
## Requirements
|
|
288
404
|
|
|
289
|
-
- Ruby 3.2.0
|
|
290
|
-
- IRB 1.6.0
|
|
291
|
-
-
|
|
405
|
+
- Ruby 3.2.0+
|
|
406
|
+
- IRB 1.6.0+ (for IRB/Rails usage)
|
|
407
|
+
- debug gem (for rdbg usage)
|
|
408
|
+
- An LLM provider gem
|
|
292
409
|
|
|
293
410
|
## License
|
|
294
411
|
|
|
@@ -296,4 +413,4 @@ MIT License
|
|
|
296
413
|
|
|
297
414
|
## Contributing
|
|
298
415
|
|
|
299
|
-
Bug reports and feature requests
|
|
416
|
+
Bug reports and feature requests welcome at [GitHub Issues](https://github.com/rira100000000/girb/issues).
|