ask-coding-providers 0.3.5 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d085b1481b659a565ab9842b4d01f3b40d137bc42c4c2ff48b7f8c6365f3804e
4
- data.tar.gz: 133c09956ea2c6bdf6ff1fa122cbf227b1eebb95c0837b30bc7f38d5007db570
3
+ metadata.gz: 9a9bceeaeb150f93011b4ae4579f38785da28c602aad7b0e7481d28ae6f4e524
4
+ data.tar.gz: 3d9a6028ccbee66c43f133fe054f54202616930e4f213f651a194a01bf8606f2
5
5
  SHA512:
6
- metadata.gz: e8f0448c7baa7b1e777431ccc3fa734f1503015b770bf0f9685f34a8d8b911cc704d1412a412e8e7019edd60f2764fef1c16f2e5a12d82648b768e8e246a3cef
7
- data.tar.gz: 7ce2091d32619c309e231145d2d9f30deceb568d223545b15899471711bd8f2034518b8090bb2ec3b771c7c0d96e3f91f2b9a71e62909cf42356c5be2dc6cbfc
6
+ metadata.gz: 55fea7d85deb5021ff668f1381c3372ce55fcce605a867b26cc206b62d7e87e2896381a0d2448b8149c415c31c8ccd458040d6e8d16004922533bf4b3f888047
7
+ data.tar.gz: 3edc8ade5699fa8f1d18f73491f57d2dd7f15b925c254d62097cd5c73bfa7c8b2b660f3cbe7c029c7300a74bfd92c34231657e1a506e1dbb67040f23d6b6e652
data/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.4.0] - 2026-09-23
6
+
7
+ ### Added
8
+
9
+ - **Approval scopes on the AskAgent adapter.** `approve_action` and
10
+ `approve_all` accept `scope: :once | :session` (default `:once`) and
11
+ pass it through to `Ask::Permissions::ApprovalQueue#approve` /
12
+ `#approve_all`. `:session` records a session grant — applied by
13
+ `Ask::Agent::Session` before the approved action runs — so matching
14
+ actions later in the session are auto-approved; `:once` stays
15
+ one-shot. `:project` raises `ArgumentError` in this adapter: project
16
+ grants are never injected here, so accepting it would be a silent
17
+ no-op.
18
+ ## [0.3.5] - 2026-09-23
19
+
5
20
  ### Changed
6
21
 
7
22
  - **Approval queue extracted to `ask-permissions`.** The AskAgent adapter's
data/README.md CHANGED
@@ -39,6 +39,13 @@ adapter = Ask::CodingProviders.build_adapter("ask_agent", model: "deepseek-v4-fl
39
39
  - Adapter interface (`Ask::CodingProviders::Adapter`): `create_session`,
40
40
  `resume_session`, `list_sessions`, `subscribe`, `send_message`,
41
41
  `send_and_stream`, `get_events`, `respond`, `get_workspace_state`.
42
+ - AskAgent approval scopes: `approve_action(session_id, action_id, scope:
43
+ :once | :session)` and `approve_all(session_id, scope: ...)` pass the
44
+ scope through to `Ask::Permissions::ApprovalQueue#approve` /
45
+ `#approve_all`. `:once` (default) approves only the named action;
46
+ `:session` records a session grant (applied by `Ask::Agent::Session`)
47
+ so matching actions later in the session are auto-approved. `:project`
48
+ raises `ArgumentError` — this adapter never injects project grants.
42
49
  - `Ask::CodingProviders::ZCode::ZCodeDB` - read-only helper for querying
43
50
  ZCode's SQLite session store at `~/.zcode/cli/db/db.sqlite`. Methods
44
51
  (`list_projects`, `find_sessions`, `session_history`, `recent_sessions`,
@@ -46,13 +46,15 @@ module Ask
46
46
 
47
47
  private
48
48
 
49
- def apply(action)
49
+ # The base queue passes an extra argument (approval scope) to these
50
+ # hooks; forward everything to super and only observe the result.
51
+ def apply(action, ...)
50
52
  result = super
51
53
  @on_status&.call(action.with(status: :approved))
52
54
  result
53
55
  end
54
56
 
55
- def reject_action(action)
57
+ def reject_action(action, ...)
56
58
  result = super
57
59
  @on_status&.call(action.with(status: :rejected))
58
60
  result
@@ -88,6 +90,14 @@ module Ask
88
90
  APPROVAL_AUTO = :auto
89
91
  APPROVAL_MODES = [APPROVAL_OFF, APPROVAL_REQUIRE, APPROVAL_AUTO].freeze
90
92
 
93
+ # Approval scopes this adapter accepts. :once approves only the
94
+ # named action; :session records a session grant (applied by
95
+ # Ask::Agent::Session before the approved action runs) so matching
96
+ # actions later in the session are auto-approved. :project is
97
+ # deliberately excluded: this adapter never injects project grants
98
+ # into the queue, so accepting it would be a silent no-op.
99
+ APPROVAL_SCOPES = %i[once session].freeze
100
+
91
101
  # How long a turn stays settled before it is considered complete
92
102
  # (protects against follow-up turns starting right after the queue
93
103
  # drains).
@@ -270,10 +280,15 @@ module Ask
270
280
  # Approve one queued tool action. Continues the turn (follow-up
271
281
  # turns run in this thread and stream to active subscribers).
272
282
  #
283
+ # @param scope [Symbol] :once (default) approves only this action;
284
+ # :session records a session grant for matching later actions.
285
+ # :project raises ArgumentError (no project grants injected).
286
+ # @raise [ArgumentError] for :project or unknown scopes
273
287
  # @return [Array<Ask::Permissions::Action>]
274
- def approve_action(session_id, action_id)
288
+ def approve_action(session_id, action_id, scope: :once)
289
+ validate_approval_scope!(scope)
275
290
  queue = approval_queue(session_id)
276
- queue ? queue.approve(action_id) : []
291
+ queue ? queue.approve(action_id, scope: scope) : []
277
292
  end
278
293
 
279
294
  def reject_action(session_id, action_id)
@@ -282,9 +297,13 @@ module Ask
282
297
  end
283
298
 
284
299
  # Approve all pending tool actions.
285
- def approve_all(session_id)
300
+ #
301
+ # @param scope [Symbol] see {#approve_action}
302
+ # @raise [ArgumentError] for :project or unknown scopes
303
+ def approve_all(session_id, scope: :once)
304
+ validate_approval_scope!(scope)
286
305
  queue = approval_queue(session_id)
287
- queue ? queue.approve_all : []
306
+ queue ? queue.approve_all(scope: scope) : []
288
307
  end
289
308
 
290
309
  def reject_all(session_id)
@@ -379,6 +398,21 @@ module Ask
379
398
  session_entry(session_id)[:session]&.approval_queue
380
399
  end
381
400
 
401
+ # Scope validation runs before the session/queue lookup so :project
402
+ # (and unknown scopes) raise even when no queue exists — never a
403
+ # silent no-op.
404
+ def validate_approval_scope!(scope)
405
+ return scope if APPROVAL_SCOPES.include?(scope)
406
+ if scope == :project
407
+ raise ArgumentError,
408
+ "approval scope :project is not supported by the AskAgent adapter " \
409
+ "(project grants are not injected here; use :once or :session)"
410
+ end
411
+ raise ArgumentError,
412
+ "approval scope must be one of #{APPROVAL_SCOPES.inspect} " \
413
+ "(this adapter does not support :project), got #{scope.inspect}"
414
+ end
415
+
382
416
  # ── Session construction ──
383
417
 
384
418
  def build_session(entry)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module CodingProviders
5
- VERSION = "0.3.5"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  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.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.1.0
18
+ version: 0.2.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.1.0
25
+ version: 0.2.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: minitest
28
28
  requirement: !ruby/object:Gem::Requirement