yorishiro 0.1.0 → 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/.yorishirorc.sample +51 -0
- data/CHANGELOG.md +41 -0
- data/README.md +134 -8
- data/docs/en/README.md +97 -2
- data/docs/ja/README.md +97 -2
- data/docs/ja/how_to_create_skills.md +0 -0
- data/docs/ja/ollama_setup.md +148 -0
- data/lib/yorishiro/cli.rb +474 -93
- data/lib/yorishiro/compactor.rb +53 -0
- data/lib/yorishiro/configuration.rb +69 -1
- data/lib/yorishiro/conversation.rb +117 -0
- data/lib/yorishiro/diff.rb +92 -0
- data/lib/yorishiro/hooks.rb +64 -0
- data/lib/yorishiro/input_history.rb +49 -0
- data/lib/yorishiro/mcp/server_manager.rb +4 -4
- data/lib/yorishiro/provider/anthropic.rb +37 -8
- data/lib/yorishiro/provider/base.rb +20 -4
- data/lib/yorishiro/provider/ollama.rb +70 -45
- data/lib/yorishiro/provider/open_ai.rb +21 -5
- data/lib/yorishiro/session_resume.rb +73 -0
- data/lib/yorishiro/session_store.rb +168 -0
- data/lib/yorishiro/skill.rb +11 -0
- data/lib/yorishiro/skill_loader.rb +53 -0
- data/lib/yorishiro/sub_agent.rb +143 -0
- data/lib/yorishiro/tool.rb +7 -0
- data/lib/yorishiro/tool_result_cap.rb +31 -0
- data/lib/yorishiro/tools/edit_file.rb +87 -0
- data/lib/yorishiro/tools/execute_command.rb +8 -0
- data/lib/yorishiro/tools/exit_plan_mode.rb +41 -0
- data/lib/yorishiro/tools/grep.rb +118 -0
- data/lib/yorishiro/tools/list_files.rb +10 -8
- data/lib/yorishiro/tools/read_file.rb +27 -9
- data/lib/yorishiro/tools/task.rb +74 -0
- data/lib/yorishiro/tools/write_file.rb +9 -0
- data/lib/yorishiro/version.rb +1 -1
- data/lib/yorishiro.rb +13 -1
- metadata +33 -5
- data/lib/yorishiro/mcp/stdio_transport.rb +0 -85
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "open3"
|
|
4
|
-
require "json"
|
|
5
|
-
require "securerandom"
|
|
6
|
-
|
|
7
|
-
module Yorishiro
|
|
8
|
-
module MCP
|
|
9
|
-
class StdioTransport
|
|
10
|
-
def initialize(command:, args: [], env: {})
|
|
11
|
-
@command = command
|
|
12
|
-
@args = args
|
|
13
|
-
@env = env
|
|
14
|
-
@stdin = nil
|
|
15
|
-
@stdout = nil
|
|
16
|
-
@stderr = nil
|
|
17
|
-
@wait_thread = nil
|
|
18
|
-
@mutex = Mutex.new
|
|
19
|
-
@started = false
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def start
|
|
23
|
-
@stdin, @stdout, @stderr, @wait_thread = Open3.popen3(@env, @command, *@args)
|
|
24
|
-
@stdin.set_encoding("UTF-8")
|
|
25
|
-
@stdout.set_encoding("UTF-8")
|
|
26
|
-
@started = true
|
|
27
|
-
send_initialize
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def stop
|
|
31
|
-
return unless @started
|
|
32
|
-
|
|
33
|
-
@stdin&.close
|
|
34
|
-
@stdout&.close
|
|
35
|
-
@stderr&.close
|
|
36
|
-
@wait_thread&.value
|
|
37
|
-
@started = false
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def started?
|
|
41
|
-
@started
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def send_request(request:)
|
|
45
|
-
@mutex.synchronize do
|
|
46
|
-
json = JSON.generate(request)
|
|
47
|
-
@stdin.puts(json)
|
|
48
|
-
@stdin.flush
|
|
49
|
-
|
|
50
|
-
line = read_with_timeout(30)
|
|
51
|
-
raise "MCP server closed connection" unless line
|
|
52
|
-
|
|
53
|
-
JSON.parse(line)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
|
|
59
|
-
def send_initialize
|
|
60
|
-
response = send_request(request: {
|
|
61
|
-
jsonrpc: "2.0",
|
|
62
|
-
id: SecureRandom.uuid,
|
|
63
|
-
method: "initialize",
|
|
64
|
-
params: {
|
|
65
|
-
protocolVersion: "2025-03-26",
|
|
66
|
-
capabilities: {},
|
|
67
|
-
clientInfo: { name: "yorishiro", version: Yorishiro::VERSION }
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
notification = JSON.generate({ jsonrpc: "2.0", method: "notifications/initialized" })
|
|
72
|
-
@stdin.puts(notification)
|
|
73
|
-
@stdin.flush
|
|
74
|
-
|
|
75
|
-
response
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def read_with_timeout(timeout_seconds)
|
|
79
|
-
raise "MCP server response timeout (#{timeout_seconds}s)" unless @stdout.wait_readable(timeout_seconds)
|
|
80
|
-
|
|
81
|
-
@stdout.gets
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|