yorishiro 0.1.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 +7 -0
- data/.yorishirorc.sample +90 -0
- data/CHANGELOG.md +16 -0
- data/LICENSE.txt +21 -0
- data/README.md +270 -0
- data/Rakefile +12 -0
- data/docs/en/README.md +268 -0
- data/docs/ja/README.md +271 -0
- data/exe/yorishiro +6 -0
- data/lib/yorishiro/cli.rb +344 -0
- data/lib/yorishiro/configuration.rb +109 -0
- data/lib/yorishiro/conversation.rb +63 -0
- data/lib/yorishiro/mcp/server_manager.rb +59 -0
- data/lib/yorishiro/mcp/stdio_transport.rb +85 -0
- data/lib/yorishiro/mcp/tool.rb +41 -0
- data/lib/yorishiro/provider/anthropic.rb +143 -0
- data/lib/yorishiro/provider/base.rb +121 -0
- data/lib/yorishiro/provider/ollama.rb +151 -0
- data/lib/yorishiro/provider/open_ai.rb +135 -0
- data/lib/yorishiro/skill.rb +17 -0
- data/lib/yorishiro/tool.rb +41 -0
- data/lib/yorishiro/tools/execute_command.rb +70 -0
- data/lib/yorishiro/tools/list_files.rb +46 -0
- data/lib/yorishiro/tools/read_file.rb +50 -0
- data/lib/yorishiro/tools/write_file.rb +41 -0
- data/lib/yorishiro/version.rb +5 -0
- data/lib/yorishiro.rb +51 -0
- data/sig/yorishiro.rbs +4 -0
- metadata +146 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 84093e44e7e9ae3d6e590164028c1f95cb6b3938f3d8a7b063800312380897de
|
|
4
|
+
data.tar.gz: 4db18617aeb5fd5c71f3e749ef2f7ecf179fe43842474341d6d42a24b8762a7f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b01657cfa3ed4aeac756cc632dcf3a4d58eb2f1ec3a77b67aba0bd6f4caa3b795f3e9bead5e64222a0268cd91dfb412e24c13b9932fd451f97a0f144d4e89171
|
|
7
|
+
data.tar.gz: 497799e8401c11e066a600954acf3467722722da4f43d86db5ed81567680426ecb872c8aa0a3bc1a1f7d872b025a1f9ee6fc60d9cb6ae126215dccd9e15523cb
|
data/.yorishirorc.sample
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Yorishiro Configuration
|
|
2
|
+
#
|
|
3
|
+
# Copy this file to ~/.yorishirorc (global) or .lyorishirorc (project-local)
|
|
4
|
+
# and customize to your needs.
|
|
5
|
+
|
|
6
|
+
# ============================================================
|
|
7
|
+
# Provider
|
|
8
|
+
# ============================================================
|
|
9
|
+
|
|
10
|
+
# Anthropic (Claude)
|
|
11
|
+
use provider: :anthropic,
|
|
12
|
+
api_key: ENV["ANTHROPIC_API_KEY"],
|
|
13
|
+
model: "claude-sonnet-4-20250514"
|
|
14
|
+
|
|
15
|
+
# OpenAI (ChatGPT)
|
|
16
|
+
# use provider: :open_ai,
|
|
17
|
+
# api_key: ENV["OPENAI_API_KEY"],
|
|
18
|
+
# model: "gpt-4o"
|
|
19
|
+
|
|
20
|
+
# Ollama (Local)
|
|
21
|
+
# use provider: :ollama,
|
|
22
|
+
# model: "llama3.1"
|
|
23
|
+
|
|
24
|
+
# ============================================================
|
|
25
|
+
# System Prompt
|
|
26
|
+
# ============================================================
|
|
27
|
+
|
|
28
|
+
system_prompt <<~PROMPT
|
|
29
|
+
You are a helpful coding assistant.
|
|
30
|
+
When modifying files, always explain what you're changing and why.
|
|
31
|
+
PROMPT
|
|
32
|
+
|
|
33
|
+
# ============================================================
|
|
34
|
+
# Plan Mode
|
|
35
|
+
# ============================================================
|
|
36
|
+
|
|
37
|
+
# Set to true to start in plan mode by default
|
|
38
|
+
plan_mode false
|
|
39
|
+
|
|
40
|
+
# ============================================================
|
|
41
|
+
# Built-in Tools
|
|
42
|
+
# ============================================================
|
|
43
|
+
|
|
44
|
+
# File reading (no permission required)
|
|
45
|
+
allow_tool Yorishiro::Tools::ReadFile.new
|
|
46
|
+
|
|
47
|
+
# File writing (permission required every time)
|
|
48
|
+
allow_tool Yorishiro::Tools::WriteFile.new
|
|
49
|
+
|
|
50
|
+
# File listing / glob (no permission required)
|
|
51
|
+
allow_tool Yorishiro::Tools::ListFiles.new
|
|
52
|
+
|
|
53
|
+
# Command execution (pattern-based permission)
|
|
54
|
+
# Commands matching allow_commands patterns run automatically.
|
|
55
|
+
# Other commands prompt for permission: [y] once, [a] always, [n] deny.
|
|
56
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
57
|
+
allow_commands: [
|
|
58
|
+
"ls *",
|
|
59
|
+
"cat *",
|
|
60
|
+
"git *",
|
|
61
|
+
"bundle exec *",
|
|
62
|
+
"ruby *"
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
# ============================================================
|
|
66
|
+
# MCP Servers
|
|
67
|
+
# ============================================================
|
|
68
|
+
|
|
69
|
+
# Filesystem MCP server
|
|
70
|
+
# mcp_server "filesystem",
|
|
71
|
+
# command: "npx",
|
|
72
|
+
# args: ["-y", "@modelcontextprotocol/server-filesystem", Dir.pwd]
|
|
73
|
+
|
|
74
|
+
# GitHub MCP server
|
|
75
|
+
# mcp_server "github",
|
|
76
|
+
# command: "gh",
|
|
77
|
+
# args: ["mcp"],
|
|
78
|
+
# env: { "GITHUB_TOKEN" => ENV["GITHUB_TOKEN"] }
|
|
79
|
+
|
|
80
|
+
# ============================================================
|
|
81
|
+
# Custom Skills (Slash Commands)
|
|
82
|
+
# ============================================================
|
|
83
|
+
|
|
84
|
+
# class GitStatusSkill < Yorishiro::Skill
|
|
85
|
+
# def name = "git_status"
|
|
86
|
+
# def description = "Show git status"
|
|
87
|
+
# def execute(_context) = `git status`
|
|
88
|
+
# end
|
|
89
|
+
#
|
|
90
|
+
# skill GitStatusSkill.new
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-03-18
|
|
4
|
+
|
|
5
|
+
- Initial release
|
|
6
|
+
- CLI REPL with Reline (multi-line input, Enter twice to send)
|
|
7
|
+
- Multiple LLM provider support (Anthropic, OpenAI, Ollama)
|
|
8
|
+
- SSE/NDJSON streaming for real-time response display
|
|
9
|
+
- Tool execution loop (LLM requests tool -> execute -> return result -> continue)
|
|
10
|
+
- Built-in tools: read_file, write_file, list_files, execute_command
|
|
11
|
+
- Pattern-based command permission model (allow_commands glob patterns)
|
|
12
|
+
- 3-tier permission: pre-approved / allow once / always allow / deny
|
|
13
|
+
- MCP (Model Context Protocol) server integration via mcp gem
|
|
14
|
+
- Plan mode (plan -> approve -> execute)
|
|
15
|
+
- Ruby DSL configuration (.yorishirorc / .lyorishirorc)
|
|
16
|
+
- Custom skills (slash commands)
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 S-H-GAMELINKS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Yorishiro(依代)
|
|
2
|
+
|
|
3
|
+
A CLI-based LLM agent written in Ruby. Supports multiple LLM providers (Anthropic / OpenAI / Ollama), built-in tools for file operations and command execution, MCP server integration, and plan mode.
|
|
4
|
+
|
|
5
|
+
[Japanese documentation / 日本語ドキュメント](docs/ja/README.md)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gem install yorishiro
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or add to your Gemfile:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
gem "yorishiro"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### 1. Create a configuration file
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Global configuration
|
|
25
|
+
vi ~/.yorishirorc
|
|
26
|
+
|
|
27
|
+
# Or project-local configuration
|
|
28
|
+
vi .lyorishirorc
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
# ~/.yorishirorc
|
|
33
|
+
use provider: :anthropic, api_key: ENV["ANTHROPIC_API_KEY"], model: "claude-sonnet-4-20250514"
|
|
34
|
+
|
|
35
|
+
allow_tool Yorishiro::Tools::ReadFile.new
|
|
36
|
+
allow_tool Yorishiro::Tools::WriteFile.new
|
|
37
|
+
allow_tool Yorishiro::Tools::ListFiles.new
|
|
38
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
39
|
+
allow_commands: ["ls", "git *", "bundle exec *", "cat *"]
|
|
40
|
+
|
|
41
|
+
system_prompt "You are a helpful coding assistant."
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Launch
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
yorishiro
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Yorishiro v0.1.0 (anthropic:claude-sonnet-4-20250514)
|
|
52
|
+
Type your message (Enter twice to send, /help for commands)
|
|
53
|
+
|
|
54
|
+
you> Hello!
|
|
55
|
+
|
|
56
|
+
assistant> Hi! How can I help you today?
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
### Basic Operations
|
|
62
|
+
|
|
63
|
+
- Type your message and press **Enter twice** to send
|
|
64
|
+
- `Ctrl+C` or `/exit` to quit
|
|
65
|
+
|
|
66
|
+
### Slash Commands
|
|
67
|
+
|
|
68
|
+
| Command | Description |
|
|
69
|
+
|---------|-------------|
|
|
70
|
+
| `/plan` | Toggle plan mode |
|
|
71
|
+
| `/clear` | Clear conversation history |
|
|
72
|
+
| `/tools` | List registered tools |
|
|
73
|
+
| `/skills` | List registered skills |
|
|
74
|
+
| `/exit` | Exit yorishiro |
|
|
75
|
+
| `/help` | Show help |
|
|
76
|
+
|
|
77
|
+
### CLI Options
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
yorishiro --provider anthropic # Select provider
|
|
81
|
+
yorishiro --model gpt-4o # Override model
|
|
82
|
+
yorishiro --plan # Start in plan mode
|
|
83
|
+
yorishiro --version # Show version
|
|
84
|
+
yorishiro --help # Show help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Configuration
|
|
88
|
+
|
|
89
|
+
Configuration files use a Ruby DSL. Loading order (later overrides earlier):
|
|
90
|
+
|
|
91
|
+
1. `~/.yorishirorc` (global)
|
|
92
|
+
2. `./.lyorishirorc` (project-local, overrides global)
|
|
93
|
+
3. CLI options (highest priority)
|
|
94
|
+
|
|
95
|
+
### Provider Settings
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
# Anthropic (Claude)
|
|
99
|
+
use provider: :anthropic, api_key: ENV["ANTHROPIC_API_KEY"], model: "claude-sonnet-4-20250514"
|
|
100
|
+
|
|
101
|
+
# OpenAI (ChatGPT)
|
|
102
|
+
use provider: :open_ai, api_key: ENV["OPENAI_API_KEY"], model: "gpt-4o"
|
|
103
|
+
|
|
104
|
+
# Ollama (Local)
|
|
105
|
+
use provider: :ollama, model: "llama3.1"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Supported Models
|
|
109
|
+
|
|
110
|
+
| Provider | Models |
|
|
111
|
+
|----------|--------|
|
|
112
|
+
| Anthropic | claude-opus-4-20250514, claude-sonnet-4-20250514, claude-haiku-4-20250414, claude-3-5-sonnet-20241022, claude-3-5-haiku-20241022 |
|
|
113
|
+
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4, gpt-3.5-turbo, o1, o1-mini, o3-mini |
|
|
114
|
+
| Ollama | Any model available on your Ollama instance (dynamically fetched) |
|
|
115
|
+
|
|
116
|
+
### Tool Settings
|
|
117
|
+
|
|
118
|
+
```ruby
|
|
119
|
+
# Read-only tools (no permission required)
|
|
120
|
+
allow_tool Yorishiro::Tools::ReadFile.new
|
|
121
|
+
allow_tool Yorishiro::Tools::ListFiles.new
|
|
122
|
+
|
|
123
|
+
# Write tool (permission required every time)
|
|
124
|
+
allow_tool Yorishiro::Tools::WriteFile.new
|
|
125
|
+
|
|
126
|
+
# Command execution (pattern-based permission)
|
|
127
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
128
|
+
allow_commands: ["ls", "git *", "bundle exec *"]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Command Execution Permission Model
|
|
132
|
+
|
|
133
|
+
The `execute_command` tool uses a 3-tier permission model:
|
|
134
|
+
|
|
135
|
+
**Tier 1: Pre-approved via config** — Commands matching `allow_commands` glob patterns run automatically
|
|
136
|
+
|
|
137
|
+
```ruby
|
|
138
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
139
|
+
allow_commands: ["ls", "git *", "bundle exec *"]
|
|
140
|
+
# ls → auto-approved
|
|
141
|
+
# git status → auto-approved
|
|
142
|
+
# rm -rf / → permission prompt
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Tier 2: Runtime approval** — Commands not matching any pattern trigger a permission prompt
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
[Permission] execute_command: command: rm -rf /tmp/cache
|
|
149
|
+
[y] Allow once [a] Always allow [n] Deny:
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- `y` — Allow this execution only
|
|
153
|
+
- `a` — Add to session allow list (auto-approved for the rest of the session)
|
|
154
|
+
- `n` — Deny
|
|
155
|
+
|
|
156
|
+
**Tier 3: Default deny** — Tools not registered with `allow_tool` are unavailable to the LLM
|
|
157
|
+
|
|
158
|
+
### MCP Server Integration
|
|
159
|
+
|
|
160
|
+
Connect to [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) servers to use external tools.
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
mcp_server "filesystem",
|
|
164
|
+
command: "npx",
|
|
165
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
|
|
166
|
+
|
|
167
|
+
mcp_server "github",
|
|
168
|
+
command: "gh",
|
|
169
|
+
args: ["mcp"],
|
|
170
|
+
env: { "GITHUB_TOKEN" => ENV["GITHUB_TOKEN"] }
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
MCP server tools are automatically discovered and registered on startup.
|
|
174
|
+
|
|
175
|
+
### System Prompt
|
|
176
|
+
|
|
177
|
+
```ruby
|
|
178
|
+
system_prompt "You are a helpful coding assistant. Always explain your reasoning."
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Plan Mode
|
|
182
|
+
|
|
183
|
+
```ruby
|
|
184
|
+
# Enable plan mode by default
|
|
185
|
+
plan_mode true
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
In plan mode:
|
|
189
|
+
1. The LLM creates a plan first (no tool execution)
|
|
190
|
+
2. The plan is displayed for user approval
|
|
191
|
+
3. After approval, the plan is executed with tools enabled
|
|
192
|
+
|
|
193
|
+
### Skills (Custom Slash Commands)
|
|
194
|
+
|
|
195
|
+
```ruby
|
|
196
|
+
class GitStatusSkill < Yorishiro::Skill
|
|
197
|
+
def name = "git_status"
|
|
198
|
+
def description = "Show git status"
|
|
199
|
+
|
|
200
|
+
def execute(_context)
|
|
201
|
+
`git status`
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
skill GitStatusSkill.new
|
|
206
|
+
# => Available as /git_status
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Full Configuration Example
|
|
210
|
+
|
|
211
|
+
```ruby
|
|
212
|
+
# ~/.yorishirorc
|
|
213
|
+
|
|
214
|
+
use provider: :anthropic,
|
|
215
|
+
api_key: ENV["ANTHROPIC_API_KEY"],
|
|
216
|
+
model: "claude-sonnet-4-20250514"
|
|
217
|
+
|
|
218
|
+
system_prompt <<~PROMPT
|
|
219
|
+
You are a helpful coding assistant.
|
|
220
|
+
When modifying files, always explain what you're changing and why.
|
|
221
|
+
PROMPT
|
|
222
|
+
|
|
223
|
+
plan_mode false
|
|
224
|
+
|
|
225
|
+
# Built-in tools
|
|
226
|
+
allow_tool Yorishiro::Tools::ReadFile.new
|
|
227
|
+
allow_tool Yorishiro::Tools::WriteFile.new
|
|
228
|
+
allow_tool Yorishiro::Tools::ListFiles.new
|
|
229
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
230
|
+
allow_commands: [
|
|
231
|
+
"ls *",
|
|
232
|
+
"cat *",
|
|
233
|
+
"git *",
|
|
234
|
+
"bundle exec *",
|
|
235
|
+
"ruby *"
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
# MCP servers
|
|
239
|
+
mcp_server "filesystem",
|
|
240
|
+
command: "npx",
|
|
241
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", Dir.pwd]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Built-in Tools
|
|
245
|
+
|
|
246
|
+
| Tool | Class | Description | Permission |
|
|
247
|
+
|------|-------|-------------|------------|
|
|
248
|
+
| `read_file` | `Yorishiro::Tools::ReadFile` | Read file contents | Not required |
|
|
249
|
+
| `write_file` | `Yorishiro::Tools::WriteFile` | Write to a file | Required every time |
|
|
250
|
+
| `list_files` | `Yorishiro::Tools::ListFiles` | List directory / glob search | Not required |
|
|
251
|
+
| `execute_command` | `Yorishiro::Tools::ExecuteCommand` | Execute shell commands | Pattern-based |
|
|
252
|
+
|
|
253
|
+
## Development
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
git clone https://github.com/S-H-GAMELINKS/yorishiro.git
|
|
257
|
+
cd yorishiro
|
|
258
|
+
bin/setup
|
|
259
|
+
bundle exec rake test # Run tests
|
|
260
|
+
bundle exec rubocop # Code style check
|
|
261
|
+
bin/console # Interactive console
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Contributing
|
|
265
|
+
|
|
266
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/S-H-GAMELINKS/yorishiro.
|
|
267
|
+
|
|
268
|
+
## License
|
|
269
|
+
|
|
270
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/docs/en/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# Yorishiro(依代)
|
|
2
|
+
|
|
3
|
+
A CLI-based LLM agent written in Ruby. Supports multiple LLM providers (Anthropic / OpenAI / Ollama), built-in tools for file operations and command execution, MCP server integration, and plan mode.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gem install yorishiro
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or add to your Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem "yorishiro"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Create a configuration file
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Global configuration
|
|
23
|
+
vi ~/.yorishirorc
|
|
24
|
+
|
|
25
|
+
# Or project-local configuration
|
|
26
|
+
vi .lyorishirorc
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
# ~/.yorishirorc
|
|
31
|
+
use provider: :anthropic, api_key: ENV["ANTHROPIC_API_KEY"], model: "claude-sonnet-4-20250514"
|
|
32
|
+
|
|
33
|
+
allow_tool Yorishiro::Tools::ReadFile.new
|
|
34
|
+
allow_tool Yorishiro::Tools::WriteFile.new
|
|
35
|
+
allow_tool Yorishiro::Tools::ListFiles.new
|
|
36
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
37
|
+
allow_commands: ["ls", "git *", "bundle exec *", "cat *"]
|
|
38
|
+
|
|
39
|
+
system_prompt "You are a helpful coding assistant."
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Launch
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
yorishiro
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Yorishiro v0.1.0 (anthropic:claude-sonnet-4-20250514)
|
|
50
|
+
Type your message (Enter twice to send, /help for commands)
|
|
51
|
+
|
|
52
|
+
you> Hello!
|
|
53
|
+
|
|
54
|
+
assistant> Hi! How can I help you today?
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
### Basic Operations
|
|
60
|
+
|
|
61
|
+
- Type your message and press **Enter twice** to send
|
|
62
|
+
- `Ctrl+C` or `/exit` to quit
|
|
63
|
+
|
|
64
|
+
### Slash Commands
|
|
65
|
+
|
|
66
|
+
| Command | Description |
|
|
67
|
+
|---------|-------------|
|
|
68
|
+
| `/plan` | Toggle plan mode |
|
|
69
|
+
| `/clear` | Clear conversation history |
|
|
70
|
+
| `/tools` | List registered tools |
|
|
71
|
+
| `/skills` | List registered skills |
|
|
72
|
+
| `/exit` | Exit yorishiro |
|
|
73
|
+
| `/help` | Show help |
|
|
74
|
+
|
|
75
|
+
### CLI Options
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
yorishiro --provider anthropic # Select provider
|
|
79
|
+
yorishiro --model gpt-4o # Override model
|
|
80
|
+
yorishiro --plan # Start in plan mode
|
|
81
|
+
yorishiro --version # Show version
|
|
82
|
+
yorishiro --help # Show help
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
Configuration files use a Ruby DSL. Loading order (later overrides earlier):
|
|
88
|
+
|
|
89
|
+
1. `~/.yorishirorc` (global)
|
|
90
|
+
2. `./.lyorishirorc` (project-local, overrides global)
|
|
91
|
+
3. CLI options (highest priority)
|
|
92
|
+
|
|
93
|
+
### Provider Settings
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
# Anthropic (Claude)
|
|
97
|
+
use provider: :anthropic, api_key: ENV["ANTHROPIC_API_KEY"], model: "claude-sonnet-4-20250514"
|
|
98
|
+
|
|
99
|
+
# OpenAI (ChatGPT)
|
|
100
|
+
use provider: :open_ai, api_key: ENV["OPENAI_API_KEY"], model: "gpt-4o"
|
|
101
|
+
|
|
102
|
+
# Ollama (Local)
|
|
103
|
+
use provider: :ollama, model: "llama3.1"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Supported Models
|
|
107
|
+
|
|
108
|
+
| Provider | Models |
|
|
109
|
+
|----------|--------|
|
|
110
|
+
| Anthropic | claude-opus-4-20250514, claude-sonnet-4-20250514, claude-haiku-4-20250414, claude-3-5-sonnet-20241022, claude-3-5-haiku-20241022 |
|
|
111
|
+
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4, gpt-3.5-turbo, o1, o1-mini, o3-mini |
|
|
112
|
+
| Ollama | Any model available on your Ollama instance (dynamically fetched) |
|
|
113
|
+
|
|
114
|
+
### Tool Settings
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
# Read-only tools (no permission required)
|
|
118
|
+
allow_tool Yorishiro::Tools::ReadFile.new
|
|
119
|
+
allow_tool Yorishiro::Tools::ListFiles.new
|
|
120
|
+
|
|
121
|
+
# Write tool (permission required every time)
|
|
122
|
+
allow_tool Yorishiro::Tools::WriteFile.new
|
|
123
|
+
|
|
124
|
+
# Command execution (pattern-based permission)
|
|
125
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
126
|
+
allow_commands: ["ls", "git *", "bundle exec *"]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Command Execution Permission Model
|
|
130
|
+
|
|
131
|
+
The `execute_command` tool uses a 3-tier permission model:
|
|
132
|
+
|
|
133
|
+
**Tier 1: Pre-approved via config** — Commands matching `allow_commands` glob patterns run automatically
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
137
|
+
allow_commands: ["ls", "git *", "bundle exec *"]
|
|
138
|
+
# ls → auto-approved
|
|
139
|
+
# git status → auto-approved
|
|
140
|
+
# rm -rf / → permission prompt
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Tier 2: Runtime approval** — Commands not matching any pattern trigger a permission prompt
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
[Permission] execute_command: command: rm -rf /tmp/cache
|
|
147
|
+
[y] Allow once [a] Always allow [n] Deny:
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- `y` — Allow this execution only
|
|
151
|
+
- `a` — Add to session allow list (auto-approved for the rest of the session)
|
|
152
|
+
- `n` — Deny
|
|
153
|
+
|
|
154
|
+
**Tier 3: Default deny** — Tools not registered with `allow_tool` are unavailable to the LLM
|
|
155
|
+
|
|
156
|
+
### MCP Server Integration
|
|
157
|
+
|
|
158
|
+
Connect to [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) servers to use external tools.
|
|
159
|
+
|
|
160
|
+
```ruby
|
|
161
|
+
mcp_server "filesystem",
|
|
162
|
+
command: "npx",
|
|
163
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
|
|
164
|
+
|
|
165
|
+
mcp_server "github",
|
|
166
|
+
command: "gh",
|
|
167
|
+
args: ["mcp"],
|
|
168
|
+
env: { "GITHUB_TOKEN" => ENV["GITHUB_TOKEN"] }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
MCP server tools are automatically discovered and registered on startup.
|
|
172
|
+
|
|
173
|
+
### System Prompt
|
|
174
|
+
|
|
175
|
+
```ruby
|
|
176
|
+
system_prompt "You are a helpful coding assistant. Always explain your reasoning."
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Plan Mode
|
|
180
|
+
|
|
181
|
+
```ruby
|
|
182
|
+
# Enable plan mode by default
|
|
183
|
+
plan_mode true
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
In plan mode:
|
|
187
|
+
1. The LLM creates a plan first (no tool execution)
|
|
188
|
+
2. The plan is displayed for user approval
|
|
189
|
+
3. After approval, the plan is executed with tools enabled
|
|
190
|
+
|
|
191
|
+
### Skills (Custom Slash Commands)
|
|
192
|
+
|
|
193
|
+
```ruby
|
|
194
|
+
class GitStatusSkill < Yorishiro::Skill
|
|
195
|
+
def name = "git_status"
|
|
196
|
+
def description = "Show git status"
|
|
197
|
+
|
|
198
|
+
def execute(_context)
|
|
199
|
+
`git status`
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
skill GitStatusSkill.new
|
|
204
|
+
# => Available as /git_status
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Full Configuration Example
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
# ~/.yorishirorc
|
|
211
|
+
|
|
212
|
+
use provider: :anthropic,
|
|
213
|
+
api_key: ENV["ANTHROPIC_API_KEY"],
|
|
214
|
+
model: "claude-sonnet-4-20250514"
|
|
215
|
+
|
|
216
|
+
system_prompt <<~PROMPT
|
|
217
|
+
You are a helpful coding assistant.
|
|
218
|
+
When modifying files, always explain what you're changing and why.
|
|
219
|
+
PROMPT
|
|
220
|
+
|
|
221
|
+
plan_mode false
|
|
222
|
+
|
|
223
|
+
# Built-in tools
|
|
224
|
+
allow_tool Yorishiro::Tools::ReadFile.new
|
|
225
|
+
allow_tool Yorishiro::Tools::WriteFile.new
|
|
226
|
+
allow_tool Yorishiro::Tools::ListFiles.new
|
|
227
|
+
allow_tool Yorishiro::Tools::ExecuteCommand.new,
|
|
228
|
+
allow_commands: [
|
|
229
|
+
"ls *",
|
|
230
|
+
"cat *",
|
|
231
|
+
"git *",
|
|
232
|
+
"bundle exec *",
|
|
233
|
+
"ruby *"
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
# MCP servers
|
|
237
|
+
mcp_server "filesystem",
|
|
238
|
+
command: "npx",
|
|
239
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", Dir.pwd]
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Built-in Tools
|
|
243
|
+
|
|
244
|
+
| Tool | Class | Description | Permission |
|
|
245
|
+
|------|-------|-------------|------------|
|
|
246
|
+
| `read_file` | `Yorishiro::Tools::ReadFile` | Read file contents | Not required |
|
|
247
|
+
| `write_file` | `Yorishiro::Tools::WriteFile` | Write to a file | Required every time |
|
|
248
|
+
| `list_files` | `Yorishiro::Tools::ListFiles` | List directory / glob search | Not required |
|
|
249
|
+
| `execute_command` | `Yorishiro::Tools::ExecuteCommand` | Execute shell commands | Pattern-based |
|
|
250
|
+
|
|
251
|
+
## Development
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
git clone https://github.com/S-H-GAMELINKS/yorishiro.git
|
|
255
|
+
cd yorishiro
|
|
256
|
+
bin/setup
|
|
257
|
+
bundle exec rake test # Run tests
|
|
258
|
+
bundle exec rubocop # Code style check
|
|
259
|
+
bin/console # Interactive console
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Contributing
|
|
263
|
+
|
|
264
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/S-H-GAMELINKS/yorishiro.
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|