ask-coding-providers 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/README.md +65 -0
- data/lib/ask/coding_providers/acp/adapter.rb +30 -2
- data/lib/ask/coding_providers/ask_agent/adapter.rb +7 -7
- data/lib/ask/coding_providers/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7da8871d69c29d381c81338b07d851ec66d0030189aa9a8580352b363679630
|
|
4
|
+
data.tar.gz: 17f28c8a082971b3240b259081ecf97a913b9a093bb92d870887d610adb41859
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77bc28345e275bd0999fe412c42593b191f6fd28386faf699780ababbad3e10ef0d40f018c5724a85da1487afa1c35baa85270f464fce809b1ce238095030ac1
|
|
7
|
+
data.tar.gz: 7650675be24e6c7653779b533cde463b219499f5d1fcfce733b04f881019489ee7ca7f64dd62be077b220bcb9070bf61dfc44f199cd3ad2509a48bc54ab630a5
|
data/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# ask-coding-providers
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/ask-coding-providers)
|
|
4
|
+
|
|
5
|
+
A registry of coding agent adapters for the ask-rb ecosystem. It provides a
|
|
6
|
+
uniform interface for driving AI coding agents (Claude Code, Codex, ACP-based
|
|
7
|
+
agents, ask_agent) and a read-only helper for reading ZCode's session store.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem "ask-coding-providers"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
require "ask-coding-providers"
|
|
19
|
+
|
|
20
|
+
# Build an adapter by registered name
|
|
21
|
+
adapter = Ask::CodingProviders.build_adapter("acp", workspace_path: Dir.pwd)
|
|
22
|
+
adapter = Ask::CodingProviders.build_adapter("ask_agent", model: "deepseek-v4-flash")
|
|
23
|
+
|
|
24
|
+
# The environment variable selects the adapter when none is given
|
|
25
|
+
# (see Ask::CodingProviders.resolve_adapter)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Key entry points
|
|
29
|
+
|
|
30
|
+
- `Ask::CodingProviders.register_adapter(name, klass)` - register an adapter
|
|
31
|
+
class under a name. Adapters register themselves when loaded.
|
|
32
|
+
- `Ask::CodingProviders.resolve_adapter(name)` - look up an adapter class.
|
|
33
|
+
Raises `ConfigurationError` for unknown names and suggests setting the
|
|
34
|
+
`CODING_PROVIDER` environment variable.
|
|
35
|
+
- `Ask::CodingProviders.build_adapter(name, **config)` - build an adapter
|
|
36
|
+
instance, passing config options to the adapter's `.from_config`.
|
|
37
|
+
- Registered adapters: `:acp`, `:ask_agent`, `:claude`, `:codex`. There is no
|
|
38
|
+
`:zcode` adapter.
|
|
39
|
+
- Adapter interface (`Ask::CodingProviders::Adapter`): `create_session`,
|
|
40
|
+
`resume_session`, `list_sessions`, `subscribe`, `send_message`,
|
|
41
|
+
`send_and_stream`, `get_events`, `respond`, `get_workspace_state`.
|
|
42
|
+
- `Ask::CodingProviders::ZCode::ZCodeDB` - read-only helper for querying
|
|
43
|
+
ZCode's SQLite session store at `~/.zcode/cli/db/db.sqlite`. Methods
|
|
44
|
+
(`list_projects`, `find_sessions`, `session_history`, `recent_sessions`,
|
|
45
|
+
and others) return `nil` or empty arrays on error, never raising.
|
|
46
|
+
- `Ask::CodingProviders::Error`, `ConfigurationError`, `ConnectionError`, and
|
|
47
|
+
`TimeoutError` - errors raised by the registry and adapters.
|
|
48
|
+
|
|
49
|
+
## Full documentation
|
|
50
|
+
|
|
51
|
+
The full ask-rb documentation lives at https://ask-rb.github.io/ask-docs.
|
|
52
|
+
[Reference: Gem Index](https://ask-rb.github.io/ask-docs/reference/gems)
|
|
53
|
+
covers ask-coding-providers in depth. API reference:
|
|
54
|
+
https://ask-rb.github.io/ask-docs/reference/api.
|
|
55
|
+
|
|
56
|
+
## Development
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
bundle install
|
|
60
|
+
bundle exec rake test
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
|
@@ -32,19 +32,24 @@ module Ask
|
|
|
32
32
|
# @param command [Array<String>] the command to spawn the ACP agent
|
|
33
33
|
# @param cwd [String] working directory
|
|
34
34
|
# @param request_timeout [Float] timeout for ACP requests
|
|
35
|
-
def initialize(command
|
|
35
|
+
def initialize(command: nil, cwd: ".", request_timeout: 60.0, replay: nil)
|
|
36
36
|
require "ask/acp"
|
|
37
37
|
|
|
38
38
|
@command = command
|
|
39
39
|
@cwd = cwd
|
|
40
40
|
@request_timeout = request_timeout
|
|
41
|
+
@replay = replay
|
|
41
42
|
@client = nil
|
|
42
43
|
@sessions = {}
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
def start
|
|
46
47
|
return if @client
|
|
47
|
-
|
|
48
|
+
if @replay
|
|
49
|
+
@client = Ask::ACP::ReplayClient.new(fixture_path: @replay)
|
|
50
|
+
else
|
|
51
|
+
@client = Ask::ACP::Client.new(command: @command, request_timeout: @request_timeout)
|
|
52
|
+
end
|
|
48
53
|
@client.start
|
|
49
54
|
@client.initialize!(client_name: "askoda", client_version: "0.1.0")
|
|
50
55
|
end
|
|
@@ -101,6 +106,29 @@ module Ask
|
|
|
101
106
|
type: "model.streaming", seq: 2,
|
|
102
107
|
payload: { "delta" => delta, "sessionId" => session_id }
|
|
103
108
|
}) unless delta.empty?
|
|
109
|
+
when "session/update"
|
|
110
|
+
update = event.dig(:params, "update") || {}
|
|
111
|
+
case update["sessionUpdate"]
|
|
112
|
+
when "tool_call"
|
|
113
|
+
kind = update["kind"] || "unknown"
|
|
114
|
+
block.call({
|
|
115
|
+
type: "tool.use", seq: 2,
|
|
116
|
+
payload: {
|
|
117
|
+
"sessionId" => session_id,
|
|
118
|
+
"toolName" => kind,
|
|
119
|
+
"input" => update["content"]
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
when "tool_call_update"
|
|
123
|
+
block.call({
|
|
124
|
+
type: "tool.result", seq: 2,
|
|
125
|
+
payload: {
|
|
126
|
+
"sessionId" => session_id,
|
|
127
|
+
"toolName" => event.dig(:params, "kind") || "unknown",
|
|
128
|
+
"output" => update["content"]
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
end
|
|
104
132
|
when "turn_complete"
|
|
105
133
|
block.call({
|
|
106
134
|
type: "turn.completed", seq: 3,
|
|
@@ -77,15 +77,15 @@ module Ask
|
|
|
77
77
|
{ "eventSeq" => 0 }
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
def send_message(session_id, content)
|
|
80
|
+
def send_message(session_id, content, attachments: nil)
|
|
81
81
|
ensure_started
|
|
82
82
|
# Run synchronously — returns when done
|
|
83
|
-
result = run_session(session_id, content)
|
|
83
|
+
result = run_session(session_id, content, attachments: attachments)
|
|
84
84
|
{ "response" => result }
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
def send_and_stream(session_id, content, turn_timeout: 600.0, &block)
|
|
88
|
-
return enum_for(:send_and_stream, session_id, content, turn_timeout: turn_timeout) unless block
|
|
87
|
+
def send_and_stream(session_id, content, turn_timeout: 600.0, attachments: nil, &block)
|
|
88
|
+
return enum_for(:send_and_stream, session_id, content, turn_timeout: turn_timeout, attachments: attachments) unless block
|
|
89
89
|
ensure_started
|
|
90
90
|
|
|
91
91
|
# Build the ask-agent chat with our pre-configured provider
|
|
@@ -111,7 +111,7 @@ module Ask
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
begin
|
|
114
|
-
result = session.run(content)
|
|
114
|
+
result = session.run(content, attachments: attachments)
|
|
115
115
|
block.call({
|
|
116
116
|
type: "turn.completed", seq: 3,
|
|
117
117
|
payload: { "response" => result, "sessionId" => session_id,
|
|
@@ -165,14 +165,14 @@ module Ask
|
|
|
165
165
|
chat
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
-
def run_session(session_id, content)
|
|
168
|
+
def run_session(session_id, content, attachments: nil)
|
|
169
169
|
chat = build_chat
|
|
170
170
|
session = Ask::Agent::Session.new(
|
|
171
171
|
model: chat,
|
|
172
172
|
max_turns: @max_turns,
|
|
173
173
|
**@session_opts
|
|
174
174
|
)
|
|
175
|
-
session.run(content)
|
|
175
|
+
session.run(content, attachments: attachments)
|
|
176
176
|
end
|
|
177
177
|
end
|
|
178
178
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ask-coding-providers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaka Ruto
|
|
@@ -73,6 +73,7 @@ executables: []
|
|
|
73
73
|
extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
|
75
75
|
files:
|
|
76
|
+
- README.md
|
|
76
77
|
- lib/ask-coding-providers.rb
|
|
77
78
|
- lib/ask/coding_providers.rb
|
|
78
79
|
- lib/ask/coding_providers/acp.rb
|