girb 0.1.1 → 0.2.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 +52 -0
- data/README.md +84 -56
- data/README_ja.md +84 -56
- data/exe/girb +16 -9
- data/lib/girb/ai_client.rb +195 -28
- 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 +298 -0
- data/lib/girb/debug_prompt_builder.rb +227 -0
- data/lib/girb/debug_session_history.rb +121 -0
- data/lib/girb/girbrc_loader.rb +52 -0
- data/lib/girb/irb_integration.rb +1 -1
- data/lib/girb/prompt_builder.rb +39 -6
- data/lib/girb/providers/base.rb +2 -1
- data/lib/girb/railtie.rb +11 -0
- data/lib/girb/tools/continue_analysis.rb +45 -0
- data/lib/girb/tools/debug_session_history_tool.rb +89 -0
- data/lib/girb/tools/environment_tools.rb +31 -0
- data/lib/girb/tools/evaluate_code.rb +24 -3
- data/lib/girb/tools/rails_tools.rb +58 -0
- data/lib/girb/tools/run_debug_command.rb +49 -0
- data/lib/girb/tools/session_history_tool.rb +5 -0
- data/lib/girb/tools.rb +26 -4
- data/lib/girb/version.rb +1 -1
- data/lib/girb.rb +12 -0
- data/lib/irb/command/qq.rb +7 -6
- metadata +12 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '048b4dc3910c2afaa9bb1bd2a1f2f33f51b631b74405368daabec4cbf1ef1e2a'
|
|
4
|
+
data.tar.gz: d5b46f5c7c0f809053c8b38fd15f9af6709338c62cb2374f0a64b25f283b1807
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e064f6e9a5dcd1ea6af090ccfc9aff2acc476fcafff772aed594ff15ecb95cfe6513e8e7facccbea490d82d691b9e495d4134fe418f8fb2d0b7bfab0e40fe25
|
|
7
|
+
data.tar.gz: 3287871b7937ea1234fdb18c6e551b96da944b12a57305b3e6c5fe5e63d2d602afa04aedc88192331176b70062ad4efc1bcfeb5c7bf3285ce603a3e090a1f005
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2026-02-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Debug gem (rdbg) integration**: AI assistant for step-through debugging
|
|
8
|
+
- `ai <question>` command in debugger
|
|
9
|
+
- Ctrl+Space to send input to AI
|
|
10
|
+
- Auto-routing of non-ASCII (Japanese) input to AI
|
|
11
|
+
- `run_debug_command` tool for AI to execute debugger commands (step, next, continue, break, etc.)
|
|
12
|
+
- **Auto-continue for autonomous AI investigation**
|
|
13
|
+
- `continue_analysis` tool for IRB mode context refresh
|
|
14
|
+
- AI can loop through investigate-execute-analyze cycles
|
|
15
|
+
- Configurable iteration limits (MAX_ITERATIONS = 20)
|
|
16
|
+
- **Ctrl+C interrupt support** for both IRB and debug modes
|
|
17
|
+
- Graceful interruption of long-running AI operations
|
|
18
|
+
- AI summarizes progress when interrupted
|
|
19
|
+
- **Debug session history tracking**
|
|
20
|
+
- Track debugger commands and AI conversations
|
|
21
|
+
- `get_session_history` tool for debug mode
|
|
22
|
+
- **Efficient variable tracking** with silent breakpoints
|
|
23
|
+
- `break file:line if: ($var << x; false)` pattern for recording without stopping
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Separate tool sets for IRB and debug modes
|
|
28
|
+
- SHARED_TOOLS: Common tools for both modes
|
|
29
|
+
- IRB_TOOLS: SessionHistoryTool, ContinueAnalysis
|
|
30
|
+
- DEBUG_TOOLS: DebugSessionHistoryTool, RunDebugCommand
|
|
31
|
+
- Improved prompts for debug mode
|
|
32
|
+
- Guidance on variable persistence across frames
|
|
33
|
+
- Instructions for efficient breakpoint usage
|
|
34
|
+
- Context-aware investigation (don't use tools for greetings)
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- Tool calls now include IDs for proper conversation history
|
|
39
|
+
- Auto-continue loop properly exits when debug commands are queued
|
|
40
|
+
|
|
41
|
+
## [0.1.2] - 2026-02-03
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- `.girbrc` configuration file support with directory traversal
|
|
46
|
+
- Railtie for automatic Rails console integration
|
|
47
|
+
- GirbrcLoader utility for finding and loading `.girbrc` files
|
|
48
|
+
- `get_current_directory` tool for non-Rails environments
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- Recommend `.girbrc` configuration instead of `~/.irbrc`
|
|
53
|
+
- `girb` command now loads `.girbrc` before falling back to environment variables
|
|
54
|
+
|
|
3
55
|
## [0.1.1] - 2026-02-03
|
|
4
56
|
|
|
5
57
|
### Changed
|
data/README.md
CHANGED
|
@@ -10,17 +10,22 @@ An AI assistant embedded in your IRB session. It understands your runtime contex
|
|
|
10
10
|
- **Exception Capture**: Automatically captures recent exceptions - just ask "why did this fail?" after an error
|
|
11
11
|
- **Session History Understanding**: Tracks IRB input history and understands conversation flow
|
|
12
12
|
- **Tool Execution**: AI autonomously executes code, inspects objects, and retrieves source code
|
|
13
|
+
- **Autonomous Investigation**: AI can loop through investigate-execute-analyze cycles using `continue_analysis`
|
|
14
|
+
- **Debug Gem Integration**: Use with Ruby's debug gem for step-through debugging with AI assistance
|
|
13
15
|
- **Multi-language Support**: Detects user's language and responds in the same language
|
|
14
16
|
- **Customizable**: Add custom prompts for project-specific instructions
|
|
15
17
|
- **Provider Agnostic**: Use any LLM provider or implement your own
|
|
16
18
|
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
21
|
+
### For Rails Projects
|
|
22
|
+
|
|
19
23
|
Add to your Gemfile:
|
|
20
24
|
|
|
21
25
|
```ruby
|
|
22
|
-
|
|
23
|
-
gem 'girb-ruby_llm' # or girb-gemini
|
|
26
|
+
group :development do
|
|
27
|
+
gem 'girb-ruby_llm' # or girb-gemini
|
|
28
|
+
end
|
|
24
29
|
```
|
|
25
30
|
|
|
26
31
|
Then run:
|
|
@@ -29,84 +34,76 @@ Then run:
|
|
|
29
34
|
bundle install
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
Create a `.girbrc` file in your project root:
|
|
33
38
|
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Set the provider via environment variable:
|
|
39
|
+
```ruby
|
|
40
|
+
# .girbrc
|
|
41
|
+
require 'girb-ruby_llm'
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
Girb.configure do |c|
|
|
44
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
45
|
+
end
|
|
42
46
|
```
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
Now `rails console` will automatically load girb!
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
### For Non-Rails Projects
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
- [girb-gemini](https://github.com/rira100000000/girb-gemini) - Google Gemini
|
|
50
|
-
|
|
51
|
-
You can also [create your own provider](#custom-providers).
|
|
52
|
-
|
|
53
|
-
## Setup
|
|
54
|
-
|
|
55
|
-
### Using girb-ruby_llm (Recommended)
|
|
56
|
-
|
|
57
|
-
girb-ruby_llm supports multiple LLM providers through RubyLLM.
|
|
52
|
+
Install globally:
|
|
58
53
|
|
|
59
54
|
```bash
|
|
60
55
|
gem install girb girb-ruby_llm
|
|
61
56
|
```
|
|
62
57
|
|
|
63
|
-
|
|
58
|
+
Create a `.girbrc` file in your project directory:
|
|
64
59
|
|
|
65
60
|
```ruby
|
|
61
|
+
# .girbrc
|
|
66
62
|
require 'girb-ruby_llm'
|
|
67
63
|
|
|
68
|
-
RubyLLM.configure do |config|
|
|
69
|
-
config.gemini_api_key = 'your-api-key'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
64
|
Girb.configure do |c|
|
|
73
65
|
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
74
66
|
end
|
|
75
67
|
```
|
|
76
68
|
|
|
77
|
-
|
|
69
|
+
Then use `girb` command instead of `irb`.
|
|
78
70
|
|
|
79
|
-
|
|
71
|
+
## How .girbrc Works
|
|
80
72
|
|
|
81
|
-
|
|
82
|
-
gem install girb girb-gemini
|
|
83
|
-
```
|
|
73
|
+
girb searches for `.girbrc` in the following order:
|
|
84
74
|
|
|
85
|
-
|
|
75
|
+
1. Current directory, then parent directories (up to root)
|
|
76
|
+
2. `~/.girbrc` as fallback
|
|
86
77
|
|
|
87
|
-
|
|
88
|
-
require 'girb-gemini'
|
|
78
|
+
This allows you to:
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
- **Project-specific settings**: Place `.girbrc` in your project root
|
|
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
|
|
83
|
+
|
|
84
|
+
## Providers
|
|
85
|
+
|
|
86
|
+
Currently available providers:
|
|
87
|
+
|
|
88
|
+
- [girb-ruby_llm](https://github.com/rira100000000/girb-ruby_llm) - Multiple providers via RubyLLM (OpenAI, Anthropic, Gemini, Ollama, etc.)
|
|
89
|
+
- [girb-gemini](https://github.com/rira100000000/girb-gemini) - Google Gemini
|
|
90
|
+
|
|
91
|
+
You can also [create your own provider](#custom-providers).
|
|
97
92
|
|
|
98
93
|
## Usage
|
|
99
94
|
|
|
100
|
-
###
|
|
95
|
+
### For Rails Projects
|
|
101
96
|
|
|
102
97
|
```bash
|
|
103
|
-
|
|
98
|
+
rails console
|
|
104
99
|
```
|
|
105
100
|
|
|
106
|
-
|
|
101
|
+
girb is automatically loaded via Railtie.
|
|
107
102
|
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
### For Non-Rails Projects
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
girb
|
|
110
107
|
```
|
|
111
108
|
|
|
112
109
|
### Debug with binding.girb
|
|
@@ -121,6 +118,34 @@ def problematic_method
|
|
|
121
118
|
end
|
|
122
119
|
```
|
|
123
120
|
|
|
121
|
+
### Debug with debug gem (rdbg)
|
|
122
|
+
|
|
123
|
+
For step-through debugging with AI assistance, add `require "girb"` to your script:
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
require "girb"
|
|
127
|
+
|
|
128
|
+
def problematic_method
|
|
129
|
+
result = some_calculation
|
|
130
|
+
result
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
problematic_method
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Then run with rdbg:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
rdbg your_script.rb
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
In the debugger, use:
|
|
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
|
|
146
|
+
|
|
147
|
+
The AI can execute debugger commands like `step`, `next`, `continue`, and set breakpoints for you.
|
|
148
|
+
|
|
124
149
|
### How to Ask AI
|
|
125
150
|
|
|
126
151
|
#### Method 1: Ctrl+Space
|
|
@@ -139,7 +164,7 @@ irb(main):001> qq "How do I use this method?"
|
|
|
139
164
|
|
|
140
165
|
## Configuration Options
|
|
141
166
|
|
|
142
|
-
Add to your
|
|
167
|
+
Add to your `.girbrc`:
|
|
143
168
|
|
|
144
169
|
```ruby
|
|
145
170
|
require 'girb-ruby_llm'
|
|
@@ -165,10 +190,12 @@ girb --help # Show help
|
|
|
165
190
|
|
|
166
191
|
### Environment Variables
|
|
167
192
|
|
|
193
|
+
For `girb` command, you can also configure via environment variables (used when no `.girbrc` is found):
|
|
194
|
+
|
|
168
195
|
| Variable | Description |
|
|
169
196
|
|----------|-------------|
|
|
170
|
-
| `GIRB_PROVIDER` |
|
|
171
|
-
| `GIRB_MODEL` | Model to use (e.g., `gemini-2.5-flash`, `gpt-4o`)
|
|
197
|
+
| `GIRB_PROVIDER` | Provider gem to load (e.g., `girb-ruby_llm`, `girb-gemini`) |
|
|
198
|
+
| `GIRB_MODEL` | Model to use (e.g., `gemini-2.5-flash`, `gpt-4o`) |
|
|
172
199
|
| `GIRB_DEBUG` | Set to `1` to enable debug output |
|
|
173
200
|
|
|
174
201
|
## Available Tools
|
|
@@ -182,6 +209,7 @@ girb --help # Show help
|
|
|
182
209
|
| `find_file` | Search for files in the project |
|
|
183
210
|
| `read_file` | Read file contents |
|
|
184
211
|
| `session_history` | Get IRB session history |
|
|
212
|
+
| `continue_analysis` | Request context refresh for autonomous investigation |
|
|
185
213
|
|
|
186
214
|
### Additional Tools in Rails Environment
|
|
187
215
|
|
|
@@ -190,6 +218,12 @@ girb --help # Show help
|
|
|
190
218
|
| `query_model` | Execute queries on ActiveRecord models |
|
|
191
219
|
| `model_info` | Get model schema information |
|
|
192
220
|
|
|
221
|
+
### Additional Tools in Debug Mode (rdbg)
|
|
222
|
+
|
|
223
|
+
| Tool | Description |
|
|
224
|
+
|------|-------------|
|
|
225
|
+
| `run_debug_command` | Execute debugger commands (step, next, continue, break, etc.) |
|
|
226
|
+
|
|
193
227
|
## Custom Providers
|
|
194
228
|
|
|
195
229
|
Implement your own LLM provider:
|
|
@@ -220,12 +254,6 @@ Girb.configure do |c|
|
|
|
220
254
|
end
|
|
221
255
|
```
|
|
222
256
|
|
|
223
|
-
Then run with:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
GIRB_PROVIDER=my_provider girb
|
|
227
|
-
```
|
|
228
|
-
|
|
229
257
|
## Examples
|
|
230
258
|
|
|
231
259
|
### Debugging Assistance
|
data/README_ja.md
CHANGED
|
@@ -8,17 +8,22 @@ IRBセッションに組み込まれたAIアシスタント。実行中のコン
|
|
|
8
8
|
- **例外キャプチャ**: 直前の例外を自動キャプチャ - エラー後に「なぜ失敗した?」と聞くだけでOK
|
|
9
9
|
- **セッション履歴の理解**: IRBでの入力履歴を追跡し、会話の流れを理解
|
|
10
10
|
- **ツール実行**: コードの実行、オブジェクトの検査、ソースコードの取得などをAIが自律的に実行
|
|
11
|
+
- **自律的な調査**: `continue_analysis`を使って、調査→実行→分析のサイクルをAIが自律的にループ可能
|
|
12
|
+
- **debug gem統合**: Rubyのdebug gemと連携し、AIアシスタント付きのステップ実行デバッグが可能
|
|
11
13
|
- **多言語対応**: ユーザーの言語を検出し、同じ言語で応答
|
|
12
14
|
- **カスタマイズ可能**: 独自のプロンプトを追加して、プロジェクト固有の指示を設定可能
|
|
13
15
|
- **プロバイダー非依存**: 任意のLLMプロバイダーを使用、または独自実装が可能
|
|
14
16
|
|
|
15
17
|
## インストール
|
|
16
18
|
|
|
19
|
+
### Railsプロジェクトの場合
|
|
20
|
+
|
|
17
21
|
Gemfileに追加:
|
|
18
22
|
|
|
19
23
|
```ruby
|
|
20
|
-
|
|
21
|
-
gem 'girb-ruby_llm' # または girb-gemini
|
|
24
|
+
group :development do
|
|
25
|
+
gem 'girb-ruby_llm' # または girb-gemini
|
|
26
|
+
end
|
|
22
27
|
```
|
|
23
28
|
|
|
24
29
|
そして実行:
|
|
@@ -27,84 +32,76 @@ gem 'girb-ruby_llm' # または girb-gemini
|
|
|
27
32
|
bundle install
|
|
28
33
|
```
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
プロジェクトルートに `.girbrc` ファイルを作成:
|
|
31
36
|
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
環境変数でプロバイダーを設定:
|
|
37
|
+
```ruby
|
|
38
|
+
# .girbrc
|
|
39
|
+
require 'girb-ruby_llm'
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
Girb.configure do |c|
|
|
42
|
+
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
43
|
+
end
|
|
40
44
|
```
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
これで `rails console` が自動的にgirbを読み込みます!
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
### 非Railsプロジェクトの場合
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
- [girb-gemini](https://github.com/rira100000000/girb-gemini) - Google Gemini
|
|
48
|
-
|
|
49
|
-
[独自プロバイダーの作成](#カスタムプロバイダー)も可能です。
|
|
50
|
-
|
|
51
|
-
## セットアップ
|
|
52
|
-
|
|
53
|
-
### girb-ruby_llmを使用する場合(推奨)
|
|
54
|
-
|
|
55
|
-
girb-ruby_llmはRubyLLMを通じて複数のLLMプロバイダーをサポートしています。
|
|
50
|
+
グローバルにインストール:
|
|
56
51
|
|
|
57
52
|
```bash
|
|
58
53
|
gem install girb girb-ruby_llm
|
|
59
54
|
```
|
|
60
55
|
|
|
61
|
-
|
|
56
|
+
プロジェクトディレクトリに `.girbrc` ファイルを作成:
|
|
62
57
|
|
|
63
58
|
```ruby
|
|
59
|
+
# .girbrc
|
|
64
60
|
require 'girb-ruby_llm'
|
|
65
61
|
|
|
66
|
-
RubyLLM.configure do |config|
|
|
67
|
-
config.gemini_api_key = 'your-api-key'
|
|
68
|
-
end
|
|
69
|
-
|
|
70
62
|
Girb.configure do |c|
|
|
71
63
|
c.provider = Girb::Providers::RubyLlm.new(model: 'gemini-2.5-flash')
|
|
72
64
|
end
|
|
73
65
|
```
|
|
74
66
|
|
|
75
|
-
|
|
67
|
+
`irb` の代わりに `girb` コマンドを使用します。
|
|
76
68
|
|
|
77
|
-
|
|
69
|
+
## .girbrc の仕組み
|
|
78
70
|
|
|
79
|
-
|
|
80
|
-
gem install girb girb-gemini
|
|
81
|
-
```
|
|
71
|
+
girbは以下の順序で `.girbrc` を探します:
|
|
82
72
|
|
|
83
|
-
|
|
73
|
+
1. カレントディレクトリから親ディレクトリを遡って探索(ルートまで)
|
|
74
|
+
2. `~/.girbrc` にフォールバック
|
|
84
75
|
|
|
85
|
-
|
|
86
|
-
require 'girb-gemini'
|
|
76
|
+
これにより:
|
|
87
77
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
- **プロジェクト固有の設定**: プロジェクトルートに `.girbrc` を配置
|
|
79
|
+
- **共有設定**: 親ディレクトリに `.girbrc` を配置(例: `~/work/.girbrc` で仕事用プロジェクト全体に適用)
|
|
80
|
+
- **グローバルデフォルト**: ホームディレクトリに `.girbrc` を配置
|
|
81
|
+
|
|
82
|
+
## プロバイダー
|
|
83
|
+
|
|
84
|
+
現在利用可能なプロバイダー:
|
|
85
|
+
|
|
86
|
+
- [girb-ruby_llm](https://github.com/rira100000000/girb-ruby_llm) - RubyLLM経由で複数プロバイダー対応(OpenAI、Anthropic、Gemini、Ollama等)
|
|
87
|
+
- [girb-gemini](https://github.com/rira100000000/girb-gemini) - Google Gemini
|
|
88
|
+
|
|
89
|
+
[独自プロバイダーの作成](#カスタムプロバイダー)も可能です。
|
|
95
90
|
|
|
96
91
|
## 使い方
|
|
97
92
|
|
|
98
|
-
###
|
|
93
|
+
### Railsプロジェクトの場合
|
|
99
94
|
|
|
100
95
|
```bash
|
|
101
|
-
|
|
96
|
+
rails console
|
|
102
97
|
```
|
|
103
98
|
|
|
104
|
-
|
|
99
|
+
Railtieにより自動的にgirbが読み込まれます。
|
|
105
100
|
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
### 非Railsプロジェクトの場合
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
girb
|
|
108
105
|
```
|
|
109
106
|
|
|
110
107
|
### binding.girbでデバッグ
|
|
@@ -119,6 +116,34 @@ def problematic_method
|
|
|
119
116
|
end
|
|
120
117
|
```
|
|
121
118
|
|
|
119
|
+
### debug gem (rdbg) でデバッグ
|
|
120
|
+
|
|
121
|
+
AIアシスタント付きのステップ実行デバッグを行うには、スクリプトに `require "girb"` を追加:
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
require "girb"
|
|
125
|
+
|
|
126
|
+
def problematic_method
|
|
127
|
+
result = some_calculation
|
|
128
|
+
result
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
problematic_method
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
rdbgで起動:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
rdbg your_script.rb
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
デバッガ内では以下の方法でAIに質問できます:
|
|
141
|
+
- `ai <質問>` - AIに質問
|
|
142
|
+
- `Ctrl+Space` - 入力内容をAIに送信
|
|
143
|
+
- 日本語(非ASCII文字)の入力は自動的にAIにルーティング
|
|
144
|
+
|
|
145
|
+
AIは `step`、`next`、`continue` などのデバッガコマンドを実行したり、ブレークポイントを設定することもできます。
|
|
146
|
+
|
|
122
147
|
### AIへの質問方法
|
|
123
148
|
|
|
124
149
|
#### 方法1: Ctrl+Space
|
|
@@ -137,7 +162,7 @@ irb(main):001> qq "このメソッドの使い方を教えて"
|
|
|
137
162
|
|
|
138
163
|
## 設定オプション
|
|
139
164
|
|
|
140
|
-
|
|
165
|
+
`.girbrc` に追加:
|
|
141
166
|
|
|
142
167
|
```ruby
|
|
143
168
|
require 'girb-ruby_llm'
|
|
@@ -163,10 +188,12 @@ girb --help # ヘルプを表示
|
|
|
163
188
|
|
|
164
189
|
### 環境変数
|
|
165
190
|
|
|
191
|
+
`girb` コマンドでは、`.girbrc` が見つからない場合に環境変数で設定することもできます:
|
|
192
|
+
|
|
166
193
|
| 変数 | 説明 |
|
|
167
194
|
|------|------|
|
|
168
|
-
| `GIRB_PROVIDER` |
|
|
169
|
-
| `GIRB_MODEL` | 使用するモデル(例: `gemini-2.5-flash`、`gpt-4o
|
|
195
|
+
| `GIRB_PROVIDER` | 読み込むプロバイダーgem(例: `girb-ruby_llm`、`girb-gemini`) |
|
|
196
|
+
| `GIRB_MODEL` | 使用するモデル(例: `gemini-2.5-flash`、`gpt-4o`) |
|
|
170
197
|
| `GIRB_DEBUG` | `1`に設定するとデバッグ出力を有効化 |
|
|
171
198
|
|
|
172
199
|
## AIが使用できるツール
|
|
@@ -180,6 +207,7 @@ girb --help # ヘルプを表示
|
|
|
180
207
|
| `find_file` | プロジェクト内のファイルを検索 |
|
|
181
208
|
| `read_file` | ファイルの内容を読み取り |
|
|
182
209
|
| `session_history` | IRBセッションの履歴を取得 |
|
|
210
|
+
| `continue_analysis` | 自律調査のためのコンテキスト更新をリクエスト |
|
|
183
211
|
|
|
184
212
|
### Rails環境での追加ツール
|
|
185
213
|
|
|
@@ -188,6 +216,12 @@ girb --help # ヘルプを表示
|
|
|
188
216
|
| `query_model` | ActiveRecordモデルへのクエリ実行 |
|
|
189
217
|
| `model_info` | モデルのスキーマ情報を取得 |
|
|
190
218
|
|
|
219
|
+
### デバッグモード (rdbg) での追加ツール
|
|
220
|
+
|
|
221
|
+
| ツール | 説明 |
|
|
222
|
+
|--------|------|
|
|
223
|
+
| `run_debug_command` | デバッガコマンドを実行(step、next、continue、breakなど) |
|
|
224
|
+
|
|
191
225
|
## カスタムプロバイダー
|
|
192
226
|
|
|
193
227
|
独自のLLMプロバイダーを実装:
|
|
@@ -218,12 +252,6 @@ Girb.configure do |c|
|
|
|
218
252
|
end
|
|
219
253
|
```
|
|
220
254
|
|
|
221
|
-
実行:
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
GIRB_PROVIDER=my_provider girb
|
|
225
|
-
```
|
|
226
|
-
|
|
227
255
|
## 使用例
|
|
228
256
|
|
|
229
257
|
### デバッグ支援
|
data/exe/girb
CHANGED
|
@@ -21,18 +21,25 @@ ENV["GIRB_DEBUG"] = "1" if options[:debug]
|
|
|
21
21
|
|
|
22
22
|
require "irb"
|
|
23
23
|
|
|
24
|
-
# Load girb
|
|
24
|
+
# Load girb
|
|
25
25
|
require "girb"
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
# Load .girbrc (searches from current directory up to root, then ~/.girbrc)
|
|
28
|
+
girbrc_loaded = Girb::GirbrcLoader.load_girbrc
|
|
29
|
+
|
|
30
|
+
# If no .girbrc found, try environment variable based configuration
|
|
31
|
+
unless girbrc_loaded
|
|
32
|
+
if ENV["GIRB_PROVIDER"]
|
|
33
|
+
begin
|
|
34
|
+
require ENV["GIRB_PROVIDER"]
|
|
35
|
+
rescue LoadError
|
|
36
|
+
warn "[girb] Failed to load provider: #{ENV["GIRB_PROVIDER"]}"
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
warn "[girb] No .girbrc found and GIRB_PROVIDER not set."
|
|
40
|
+
warn "[girb] Create a .girbrc file or set GIRB_PROVIDER environment variable."
|
|
41
|
+
warn "[girb] Example: GIRB_PROVIDER=girb-ruby_llm girb"
|
|
32
42
|
end
|
|
33
|
-
else
|
|
34
|
-
warn "[girb] No provider specified. Set GIRB_PROVIDER environment variable."
|
|
35
|
-
warn "[girb] Example: GIRB_PROVIDER=girb-ruby_llm girb"
|
|
36
43
|
end
|
|
37
44
|
|
|
38
45
|
IRB.start
|