girb 0.1.2 → 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 +80 -0
- data/README.md +283 -129
- data/README_ja.md +280 -126
- data/lib/girb/ai_client.rb +209 -29
- data/lib/girb/auto_continue.rb +33 -0
- data/lib/girb/conversation_history.rb +8 -7
- data/lib/girb/debug_context_builder.rb +113 -0
- data/lib/girb/debug_integration.rb +426 -0
- data/lib/girb/debug_prompt_builder.rb +241 -0
- data/lib/girb/debug_session_history.rb +121 -0
- data/lib/girb/exception_capture.rb +4 -0
- data/lib/girb/girbrc_loader.rb +15 -9
- data/lib/girb/irb_integration.rb +233 -1
- data/lib/girb/prompt_builder.rb +156 -46
- data/lib/girb/session_persistence.rb +170 -0
- data/lib/girb/tools/continue_analysis.rb +45 -0
- data/lib/girb/tools/debug_session_history_tool.rb +132 -0
- data/lib/girb/tools/evaluate_code.rb +24 -3
- data/lib/girb/tools/run_debug_command.rb +49 -0
- data/lib/girb/tools/run_irb_debug_command.rb +58 -0
- data/lib/girb/tools/session_history_tool.rb +46 -8
- data/lib/girb/tools.rb +23 -2
- data/lib/girb/version.rb +1 -1
- data/lib/girb.rb +24 -7
- data/lib/irb/command/qq.rb +48 -6
- metadata +11 -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,5 +1,84 @@
|
|
|
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
|
+
|
|
44
|
+
## [0.2.0] - 2026-02-05
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
- **Debug gem (rdbg) integration**: AI assistant for step-through debugging
|
|
49
|
+
- `qq <question>` command in debugger
|
|
50
|
+
- Ctrl+Space to send input to AI
|
|
51
|
+
- Auto-routing of non-ASCII (Japanese) input to AI
|
|
52
|
+
- `run_debug_command` tool for AI to execute debugger commands (step, next, continue, break, etc.)
|
|
53
|
+
- **Auto-continue for autonomous AI investigation**
|
|
54
|
+
- `continue_analysis` tool for IRB mode context refresh
|
|
55
|
+
- AI can loop through investigate-execute-analyze cycles
|
|
56
|
+
- Configurable iteration limits (MAX_ITERATIONS = 20)
|
|
57
|
+
- **Ctrl+C interrupt support** for both IRB and debug modes
|
|
58
|
+
- Graceful interruption of long-running AI operations
|
|
59
|
+
- AI summarizes progress when interrupted
|
|
60
|
+
- **Debug session history tracking**
|
|
61
|
+
- Track debugger commands and AI conversations
|
|
62
|
+
- `get_session_history` tool for debug mode
|
|
63
|
+
- **Efficient variable tracking** with silent breakpoints
|
|
64
|
+
- `break file:line if: ($var << x; false)` pattern for recording without stopping
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- Separate tool sets for IRB and debug modes
|
|
69
|
+
- SHARED_TOOLS: Common tools for both modes
|
|
70
|
+
- IRB_TOOLS: SessionHistoryTool, ContinueAnalysis
|
|
71
|
+
- DEBUG_TOOLS: DebugSessionHistoryTool, RunDebugCommand
|
|
72
|
+
- Improved prompts for debug mode
|
|
73
|
+
- Guidance on variable persistence across frames
|
|
74
|
+
- Instructions for efficient breakpoint usage
|
|
75
|
+
- Context-aware investigation (don't use tools for greetings)
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- Tool calls now include IDs for proper conversation history
|
|
80
|
+
- Auto-continue loop properly exits when debug commands are queued
|
|
81
|
+
|
|
3
82
|
## [0.1.2] - 2026-02-03
|
|
4
83
|
|
|
5
84
|
### Added
|
|
@@ -7,6 +86,7 @@
|
|
|
7
86
|
- `.girbrc` configuration file support with directory traversal
|
|
8
87
|
- Railtie for automatic Rails console integration
|
|
9
88
|
- GirbrcLoader utility for finding and loading `.girbrc` files
|
|
89
|
+
- `get_current_directory` tool for non-Rails environments
|
|
10
90
|
|
|
11
91
|
### Changed
|
|
12
92
|
|
data/README.md
CHANGED
|
@@ -1,38 +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
|
-
- **Customizable**: Add custom prompts for project-specific instructions
|
|
15
|
-
- **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.)
|
|
16
14
|
|
|
17
|
-
##
|
|
15
|
+
## Quick Start
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
```bash
|
|
18
|
+
# 1. Install
|
|
19
|
+
gem install girb girb-ruby_llm
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
# 2. Set your API key
|
|
22
|
+
export GEMINI_API_KEY="your-api-key" # or OPENAI_API_KEY, ANTHROPIC_API_KEY
|
|
22
23
|
|
|
24
|
+
# 3. Create ~/.girbrc
|
|
23
25
|
```ruby
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
require 'girb-ruby_llm'
|
|
27
|
+
Girb.configure do |c|
|
|
28
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
26
29
|
end
|
|
27
30
|
```
|
|
28
31
|
|
|
29
|
-
|
|
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
|
|
30
50
|
|
|
31
51
|
```bash
|
|
32
|
-
|
|
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.
|
|
33
66
|
```
|
|
34
67
|
|
|
35
|
-
|
|
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):
|
|
36
75
|
|
|
37
76
|
```ruby
|
|
38
77
|
# .girbrc
|
|
@@ -43,70 +82,104 @@ Girb.configure do |c|
|
|
|
43
82
|
end
|
|
44
83
|
```
|
|
45
84
|
|
|
46
|
-
|
|
85
|
+
girb searches for `.girbrc` in this order:
|
|
86
|
+
1. Current directory → parent directories (up to root)
|
|
87
|
+
2. `~/.girbrc` as fallback
|
|
47
88
|
|
|
48
|
-
###
|
|
89
|
+
### Model Examples
|
|
49
90
|
|
|
50
|
-
|
|
91
|
+
```ruby
|
|
92
|
+
# Google Gemini
|
|
93
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
51
94
|
|
|
52
|
-
|
|
53
|
-
|
|
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')
|
|
54
100
|
```
|
|
55
101
|
|
|
56
|
-
|
|
102
|
+
### Configuration Options
|
|
57
103
|
|
|
58
104
|
```ruby
|
|
59
|
-
# .girbrc
|
|
60
|
-
require 'girb-ruby_llm'
|
|
61
|
-
|
|
62
105
|
Girb.configure do |c|
|
|
106
|
+
# Required: LLM provider
|
|
63
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
|
|
64
116
|
end
|
|
65
117
|
```
|
|
66
118
|
|
|
67
|
-
|
|
119
|
+
### Environment Variables (Fallback)
|
|
68
120
|
|
|
69
|
-
|
|
121
|
+
Used when provider is not configured in `.girbrc`:
|
|
70
122
|
|
|
71
|
-
|
|
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 |
|
|
72
128
|
|
|
73
|
-
|
|
74
|
-
|
|
129
|
+
### Session Persistence (Optional)
|
|
130
|
+
|
|
131
|
+
Persist AI conversation history across sessions. Only enabled when you explicitly set a session ID.
|
|
75
132
|
|
|
76
|
-
|
|
133
|
+
#### Enable
|
|
77
134
|
|
|
78
|
-
|
|
79
|
-
- **Shared settings**: Place `.girbrc` in a parent directory (e.g., `~/work/.girbrc` for all work projects)
|
|
80
|
-
- **Global default**: Place `.girbrc` in your home directory
|
|
135
|
+
Set a session ID in `.girbrc`:
|
|
81
136
|
|
|
82
|
-
|
|
137
|
+
```ruby
|
|
138
|
+
Girb.configure do |c|
|
|
139
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
140
|
+
end
|
|
83
141
|
|
|
84
|
-
|
|
142
|
+
# Enable session persistence (optional)
|
|
143
|
+
Girb.debug_session = "my-project"
|
|
144
|
+
```
|
|
85
145
|
|
|
86
|
-
|
|
87
|
-
- [girb-gemini](https://github.com/rira100000000/girb-gemini) - Google Gemini
|
|
146
|
+
Or set dynamically in code:
|
|
88
147
|
|
|
89
|
-
|
|
148
|
+
```ruby
|
|
149
|
+
Girb.debug_session = "debug-user-auth"
|
|
150
|
+
debugger # Conversations in this session will be saved
|
|
151
|
+
```
|
|
90
152
|
|
|
91
|
-
|
|
153
|
+
#### Session Management Commands
|
|
92
154
|
|
|
93
|
-
|
|
155
|
+
Use in IRB or debug mode:
|
|
94
156
|
|
|
95
|
-
```bash
|
|
96
|
-
rails console
|
|
97
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
|
|
98
164
|
|
|
99
|
-
|
|
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
|
|
100
169
|
|
|
101
|
-
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 2. Ruby Scripts (IRB)
|
|
173
|
+
|
|
174
|
+
### Usage
|
|
175
|
+
|
|
176
|
+
Use `girb` command instead of `irb`:
|
|
102
177
|
|
|
103
178
|
```bash
|
|
104
179
|
girb
|
|
105
180
|
```
|
|
106
181
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
Insert `binding.girb` in your code:
|
|
182
|
+
Or insert `binding.girb` in your code:
|
|
110
183
|
|
|
111
184
|
```ruby
|
|
112
185
|
def problematic_method
|
|
@@ -118,140 +191,221 @@ end
|
|
|
118
191
|
|
|
119
192
|
### How to Ask AI
|
|
120
193
|
|
|
121
|
-
|
|
194
|
+
**Ctrl+Space**: Press after typing your question
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
irb(main):001> Why did this fail?[Ctrl+Space]
|
|
198
|
+
```
|
|
122
199
|
|
|
123
|
-
|
|
200
|
+
**qq command**: Use the qq method
|
|
124
201
|
|
|
125
202
|
```
|
|
126
|
-
irb(main):001>
|
|
203
|
+
irb(main):001> qq How do I use this method?
|
|
127
204
|
```
|
|
128
205
|
|
|
129
|
-
|
|
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
|
|
130
220
|
|
|
131
221
|
```
|
|
132
|
-
irb(main):001>
|
|
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, :+)`.
|
|
133
225
|
```
|
|
134
226
|
|
|
135
|
-
|
|
227
|
+
---
|
|
136
228
|
|
|
137
|
-
|
|
229
|
+
## 3. Rails
|
|
138
230
|
|
|
139
|
-
|
|
140
|
-
require 'girb-ruby_llm'
|
|
231
|
+
### Installation
|
|
141
232
|
|
|
142
|
-
|
|
143
|
-
# Debug output (default: false)
|
|
144
|
-
c.debug = true
|
|
233
|
+
Add to your Gemfile:
|
|
145
234
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
235
|
+
```ruby
|
|
236
|
+
group :development do
|
|
237
|
+
gem 'girb'
|
|
238
|
+
gem 'girb-ruby_llm'
|
|
150
239
|
end
|
|
151
240
|
```
|
|
152
241
|
|
|
153
|
-
### Command Line Options
|
|
154
|
-
|
|
155
242
|
```bash
|
|
156
|
-
|
|
157
|
-
girb -d # Same as above
|
|
158
|
-
girb --help # Show help
|
|
243
|
+
bundle install
|
|
159
244
|
```
|
|
160
245
|
|
|
161
|
-
###
|
|
246
|
+
### Configuration
|
|
162
247
|
|
|
163
|
-
|
|
248
|
+
Create `.girbrc` in your Rails project root. See [Configuration](#1-configuration) for details.
|
|
164
249
|
|
|
165
|
-
|
|
166
|
-
|----------|-------------|
|
|
167
|
-
| `GIRB_PROVIDER` | Provider gem to load (e.g., `girb-ruby_llm`, `girb-gemini`) |
|
|
168
|
-
| `GIRB_MODEL` | Model to use (e.g., `gemini-2.5-flash`, `gpt-4o`) |
|
|
169
|
-
| `GIRB_DEBUG` | Set to `1` to enable debug output |
|
|
250
|
+
### Usage
|
|
170
251
|
|
|
171
|
-
|
|
252
|
+
Just run `rails console` - girb loads automatically via Railtie:
|
|
172
253
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
| `inspect_object` | Inspect object details |
|
|
177
|
-
| `get_source` | Get source code of methods or classes |
|
|
178
|
-
| `list_methods` | List methods of an object |
|
|
179
|
-
| `find_file` | Search for files in the project |
|
|
180
|
-
| `read_file` | Read file contents |
|
|
181
|
-
| `session_history` | Get IRB session history |
|
|
254
|
+
```bash
|
|
255
|
+
rails console
|
|
256
|
+
```
|
|
182
257
|
|
|
183
|
-
### Additional Tools
|
|
258
|
+
### Additional Tools (Rails)
|
|
184
259
|
|
|
185
260
|
| Tool | Description |
|
|
186
261
|
|------|-------------|
|
|
187
|
-
| `query_model` | Execute
|
|
262
|
+
| `query_model` | Execute ActiveRecord queries |
|
|
188
263
|
| `model_info` | Get model schema information |
|
|
189
264
|
|
|
190
|
-
|
|
265
|
+
### Example
|
|
191
266
|
|
|
192
|
-
|
|
267
|
+
```
|
|
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.
|
|
275
|
+
```
|
|
193
276
|
|
|
194
|
-
|
|
195
|
-
class MyProvider < Girb::Providers::Base
|
|
196
|
-
def initialize(api_key:)
|
|
197
|
-
@api_key = api_key
|
|
198
|
-
end
|
|
277
|
+
---
|
|
199
278
|
|
|
200
|
-
|
|
201
|
-
# messages: Array of { role: :user/:assistant/:tool_call/:tool_result, content: "..." }
|
|
202
|
-
# tools: Array of { name: "...", description: "...", parameters: {...} }
|
|
279
|
+
## 4. Debug Gem (rdbg)
|
|
203
280
|
|
|
204
|
-
|
|
205
|
-
response = call_my_llm(messages, system_prompt, tools)
|
|
281
|
+
Step-through debugging with AI assistance.
|
|
206
282
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
|
213
301
|
end
|
|
214
302
|
|
|
215
|
-
|
|
216
|
-
|
|
303
|
+
calculate(5)
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Run with ruby:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
ruby your_script.rb
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### For Rails
|
|
313
|
+
|
|
314
|
+
Create an initializer to load girb after debug gem:
|
|
315
|
+
|
|
316
|
+
```ruby
|
|
317
|
+
# config/initializers/girb.rb
|
|
318
|
+
require "girb" if Rails.env.development? || Rails.env.test?
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Then use `debugger` statement in your code:
|
|
322
|
+
|
|
323
|
+
```ruby
|
|
324
|
+
def show
|
|
325
|
+
@user = User.find(params[:id])
|
|
326
|
+
debugger # Stops here with AI assistance
|
|
217
327
|
end
|
|
218
328
|
```
|
|
219
329
|
|
|
220
|
-
|
|
330
|
+
### How to Ask AI (Debug Mode)
|
|
221
331
|
|
|
222
|
-
|
|
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
|
|
223
335
|
|
|
224
336
|
```
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
=> false
|
|
228
|
-
irb(main):003> Why did the update fail?[Ctrl+Space]
|
|
229
|
-
Checking `user.errors.full_messages` shows validation errors:
|
|
230
|
-
- "Email can't be blank"
|
|
231
|
-
The email might be getting cleared when updating the name.
|
|
337
|
+
(rdbg) qq What is the value of result here?
|
|
338
|
+
(rdbg) 次の行に進んで[Ctrl+Space]
|
|
232
339
|
```
|
|
233
340
|
|
|
234
|
-
###
|
|
341
|
+
### AI Can Execute Debug Commands
|
|
342
|
+
|
|
343
|
+
The AI can run debugger commands for you:
|
|
235
344
|
|
|
236
345
|
```
|
|
237
|
-
|
|
238
|
-
It's defined in app/models/user.rb.
|
|
346
|
+
(rdbg) qq Step through this loop and tell me when x becomes 1
|
|
239
347
|
```
|
|
240
348
|
|
|
241
|
-
|
|
349
|
+
The AI will use `step`, `next`, `continue`, `break`, etc. automatically.
|
|
350
|
+
|
|
351
|
+
### Ctrl+C to Interrupt
|
|
352
|
+
|
|
353
|
+
Press Ctrl+C to interrupt long-running AI operations. The AI will summarize progress.
|
|
354
|
+
|
|
355
|
+
### Available Tools (Debug Mode)
|
|
356
|
+
|
|
357
|
+
| Tool | Description |
|
|
358
|
+
|------|-------------|
|
|
359
|
+
| `evaluate_code` | Execute Ruby code in current context |
|
|
360
|
+
| `inspect_object` | Inspect object details |
|
|
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 |
|
|
365
|
+
|
|
366
|
+
### Example: Variable Tracking
|
|
242
367
|
|
|
243
368
|
```
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
369
|
+
(rdbg) qq Track all values of x through this loop and report when done
|
|
370
|
+
|
|
371
|
+
[AI sets breakpoints, runs continue, collects values]
|
|
372
|
+
|
|
373
|
+
Tracked values of x: [7, 66, 85, 11, 53, 42, 99, 23]
|
|
374
|
+
Loop completed.
|
|
248
375
|
```
|
|
249
376
|
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Custom Providers
|
|
380
|
+
|
|
381
|
+
Implement your own LLM provider:
|
|
382
|
+
|
|
383
|
+
```ruby
|
|
384
|
+
class MyProvider < Girb::Providers::Base
|
|
385
|
+
def initialize(api_key:)
|
|
386
|
+
@api_key = api_key
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
def chat(messages:, system_prompt:, tools:, binding: nil)
|
|
390
|
+
# Call your LLM API
|
|
391
|
+
response = call_my_llm(messages, system_prompt, tools)
|
|
392
|
+
|
|
393
|
+
Girb::Providers::Base::Response.new(
|
|
394
|
+
text: response.text,
|
|
395
|
+
function_calls: response.tool_calls&.map { |tc| { name: tc.name, args: tc.args } }
|
|
396
|
+
)
|
|
397
|
+
end
|
|
398
|
+
end
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
250
403
|
## Requirements
|
|
251
404
|
|
|
252
|
-
- Ruby 3.2.0
|
|
253
|
-
- IRB 1.6.0
|
|
254
|
-
-
|
|
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
|
|
255
409
|
|
|
256
410
|
## License
|
|
257
411
|
|
|
@@ -259,4 +413,4 @@ MIT License
|
|
|
259
413
|
|
|
260
414
|
## Contributing
|
|
261
415
|
|
|
262
|
-
Bug reports and feature requests
|
|
416
|
+
Bug reports and feature requests welcome at [GitHub Issues](https://github.com/rira100000000/girb/issues).
|