ask-tools 0.2.0 → 0.2.1
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 +40 -0
- data/lib/ask/tools/result.rb +9 -0
- data/lib/ask/tools/tool.rb +8 -8
- data/lib/ask/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11f1c3c00fd6ac3f248ef34d23c4073110d6918669103a90bc2aeaacc1d2a622
|
|
4
|
+
data.tar.gz: d2e1d7153711d7415482956b428542b00514120a066754aa4c9570a77e065f3b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af1f45a7d1ef8aa089304a43a0196243441b31344fdcf47f45ff05c2265e506b1aa8072e82c7c8d8891f4dae17012fd2259a60e801b0b0371f178fb5151b92b8
|
|
7
|
+
data.tar.gz: 38df1b93e7a8be8f9b9ffac741db0e5a08f68529a450fd832d1f8b100b7713753c8816f51e36ee2d2fe4b0798bd2a0276de8a5b0efdc36827143b97a44432a39
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## [0.2.0] - 2026-06-21
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- Gemspec metadata for Rubygems discovery
|
|
6
|
+
- CHANGELOG.md included in gem files list
|
|
7
|
+
|
|
8
|
+
# Changelog
|
|
9
|
+
|
|
10
|
+
All notable changes to this project will be documented in this file.
|
|
11
|
+
|
|
12
|
+
## [0.1.0] - 2026-06-09
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `Ask::Tool` base class with DSL for declaring `description` and `param`
|
|
17
|
+
- Auto-derived tool names from class names (CamelCase → snake_case, strips `_tool`)
|
|
18
|
+
- `Ask::Result` value object with `ok?`, `output`, `error`, `metadata` and factory methods `ok(data:)`, `error(message:)`
|
|
19
|
+
- JSON Schema generation via `params_schema` and `tool_definition` for LLM function-calling APIs
|
|
20
|
+
- `Ask::Tools` module for tool registration, auto-discovery via `ObjectSpace`, and name-based lookup
|
|
21
|
+
- `Ask::Tool::Halt` for stopping conversation loops
|
|
22
|
+
- `Ask::Tool::Parameter` value object for parameter metadata
|
|
23
|
+
- Comprehensive test suite with 54+ tests using Minitest and Mocha
|
|
24
|
+
- Zero runtime dependencies — stdlib only
|
|
25
|
+
|
|
26
|
+
## [0.1.3] - 2026-06-18
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Class-level `params_schema` method mirroring the instance method. `ToolDef.from_tool`
|
|
31
|
+
calls `tool.params_schema` on the object it receives, which may be a Class (not an
|
|
32
|
+
instance). The instance method existed but there was no class-level equivalent,
|
|
33
|
+
causing `NoMethodError: undefined method 'params_schema' for class` when dynamic
|
|
34
|
+
tool classes were passed directly to `ToolDef.from_tool`.
|
|
35
|
+
|
|
36
|
+
### Tests
|
|
37
|
+
|
|
38
|
+
- Added `tool_schema_test.rb` (8 tests, 27 assertions) covering class-level
|
|
39
|
+
`params_schema` for the params DSL, hash schema, empty schema, instance/class
|
|
40
|
+
equivalence, dynamic tool classes, and parameter metadata.
|
data/lib/ask/tools/result.rb
CHANGED
|
@@ -40,6 +40,15 @@ module Ask
|
|
|
40
40
|
new(ok: true, output: data, error: nil, metadata: metadata)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
# Create a failed result (positional message form, used by Tool#call).
|
|
44
|
+
#
|
|
45
|
+
# @param message [String] description of the failure
|
|
46
|
+
# @param metadata [Hash] optional metadata
|
|
47
|
+
# @return [Ask::Result]
|
|
48
|
+
def self.failure(message, metadata: {})
|
|
49
|
+
new(ok: false, output: nil, error: message, metadata: metadata)
|
|
50
|
+
end
|
|
51
|
+
|
|
43
52
|
# Create a failed result.
|
|
44
53
|
#
|
|
45
54
|
# @param message [String] description of the failure
|
data/lib/ask/tools/tool.rb
CHANGED
|
@@ -114,7 +114,7 @@ module Ask
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def name
|
|
117
|
-
klass_name = self.class.name.to_s || ""
|
|
117
|
+
klass_name = self.class.name.to_s.split("::").last || ""
|
|
118
118
|
normalized = klass_name.dup.force_encoding("UTF-8").unicode_normalize(:nfkd)
|
|
119
119
|
normalized.encode("ASCII", replace: "")
|
|
120
120
|
.gsub(/[^a-zA-Z0-9_-]/, "-")
|
|
@@ -138,15 +138,15 @@ module Ask
|
|
|
138
138
|
return Ask::Result.failure(validation) if validation
|
|
139
139
|
normalized[:_abort_controller] = abort_controller if abort_controller
|
|
140
140
|
execute(**normalized)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
rescue Halt => e
|
|
142
|
+
Ask::Result.ok(data: e.content, metadata: { halted: true })
|
|
143
|
+
rescue StandardError => e
|
|
144
|
+
Ask::Result.failure("#{self.class.name.split('::').last} raised #{e.class}: #{e.message}")
|
|
145
|
+
end
|
|
146
146
|
|
|
147
147
|
def execute(**args)
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
raise NotImplementedError, "#{self.class} must implement #execute(**args)"
|
|
149
|
+
end
|
|
150
150
|
|
|
151
151
|
def params_schema
|
|
152
152
|
return @params_schema if defined?(@params_schema)
|
data/lib/ask/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ask-tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaka Ruto
|
|
@@ -59,6 +59,7 @@ executables: []
|
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
+
- CHANGELOG.md
|
|
62
63
|
- LICENSE
|
|
63
64
|
- README.md
|
|
64
65
|
- lib/ask-tools.rb
|
|
@@ -69,7 +70,10 @@ files:
|
|
|
69
70
|
homepage: https://github.com/ask-rb/ask-tools
|
|
70
71
|
licenses:
|
|
71
72
|
- MIT
|
|
72
|
-
metadata:
|
|
73
|
+
metadata:
|
|
74
|
+
homepage_uri: https://github.com/ask-rb/ask-tools
|
|
75
|
+
source_code_uri: https://github.com/ask-rb/ask-tools
|
|
76
|
+
changelog_uri: https://github.com/ask-rb/ask-tools/blob/master/CHANGELOG.md
|
|
73
77
|
rdoc_options: []
|
|
74
78
|
require_paths:
|
|
75
79
|
- lib
|