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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7672f4d067288ae4d37530eb3884b818355d6a3aeaaefc14594224e7c4794b9d
4
- data.tar.gz: fe3d5ba56939e98775c4e80edec495d40d14fb8bd6d71b2d594d9a3484fc0d13
3
+ metadata.gz: 11f1c3c00fd6ac3f248ef34d23c4073110d6918669103a90bc2aeaacc1d2a622
4
+ data.tar.gz: d2e1d7153711d7415482956b428542b00514120a066754aa4c9570a77e065f3b
5
5
  SHA512:
6
- metadata.gz: '08a09910d9ace8bbdb32640e3049e30bbefb8fd6a18ea4594f000441b71029815ad0bf9ef22e2ef0c9da727de29f2f1ee3d3aa99f6ac1162a6a7987270384b2e'
7
- data.tar.gz: dc70926d230847a1a6d114986c8042cc8a91fc7f9ce448b0354d19f6d613906287ff0fd777d0dd737ade6e5fcf693376a8ab4125e6b7102c703bc681a24ede35
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.
@@ -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
@@ -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
- 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
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
- raise NotImplementedError, "#{self.class} must implement #execute(**args)"
149
- end
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Tools
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
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.0
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