ollama_chat 0.0.74 → 0.0.75

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +35 -0
  3. data/README.md +1 -0
  4. data/lib/ollama_chat/chat.rb +20 -1
  5. data/lib/ollama_chat/information.rb +2 -0
  6. data/lib/ollama_chat/oc.rb +12 -0
  7. data/lib/ollama_chat/ollama_chat_config/default_config.yml +34 -7
  8. data/lib/ollama_chat/personae_management.rb +15 -8
  9. data/lib/ollama_chat/switches.rb +14 -0
  10. data/lib/ollama_chat/tool_calling.rb +13 -1
  11. data/lib/ollama_chat/tools/browse.rb +4 -4
  12. data/lib/ollama_chat/tools/copy_to_clipboard.rb +4 -3
  13. data/lib/ollama_chat/tools/directory_structure.rb +3 -2
  14. data/lib/ollama_chat/tools/execute_grep.rb +5 -1
  15. data/lib/ollama_chat/tools/execute_ri.rb +5 -1
  16. data/lib/ollama_chat/tools/file_context.rb +3 -4
  17. data/lib/ollama_chat/tools/gem_path_lookup.rb +5 -1
  18. data/lib/ollama_chat/tools/get_current_weather.rb +5 -1
  19. data/lib/ollama_chat/tools/get_cve.rb +4 -1
  20. data/lib/ollama_chat/tools/get_endoflife.rb +5 -1
  21. data/lib/ollama_chat/tools/get_rfc.rb +4 -1
  22. data/lib/ollama_chat/tools/get_time.rb +4 -1
  23. data/lib/ollama_chat/tools/{import_url.rb → get_url.rb} +12 -13
  24. data/lib/ollama_chat/tools/insert_into_editor.rb +5 -5
  25. data/lib/ollama_chat/tools/open_file_in_editor.rb +5 -1
  26. data/lib/ollama_chat/tools/paste_from_clipboard.rb +5 -1
  27. data/lib/ollama_chat/tools/read_file.rb +5 -1
  28. data/lib/ollama_chat/tools/resolve_tag.rb +81 -0
  29. data/lib/ollama_chat/tools/run_tests.rb +34 -8
  30. data/lib/ollama_chat/tools/search_web.rb +5 -1
  31. data/lib/ollama_chat/tools/write_file.rb +4 -1
  32. data/lib/ollama_chat/tools.rb +3 -2
  33. data/lib/ollama_chat/utils/tag_resolver.rb +117 -0
  34. data/lib/ollama_chat/utils.rb +1 -0
  35. data/lib/ollama_chat/version.rb +1 -1
  36. data/ollama_chat.gemspec +5 -5
  37. data/spec/ollama_chat/chat_spec.rb +7 -1
  38. data/spec/ollama_chat/tools/{import_url_spec.rb → get_url_spec.rb} +9 -7
  39. data/spec/ollama_chat/tools/resolve_tag_spec.rb +86 -0
  40. data/spec/ollama_chat/tools/run_tests_spec.rb +5 -6
  41. metadata +11 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cf8d81848dd2c573db23ac8182a092822bc273ba1d224307e756ab7e6741698
4
- data.tar.gz: ce5219be13b5293b477a89a9d1b187ec78dd06322b0e96275d7316f006d4828b
3
+ metadata.gz: c1597a5d9efa0d021f589cd739c294a46825a4fcef81fef2c547e6201f24b8a5
4
+ data.tar.gz: ac9f19eaaa069ae0b5efc0dbc242cc77eeefda9229fcf0ccb136a6d9c5094054
5
5
  SHA512:
6
- metadata.gz: a010b8f1cc2ce2eed10d873ec28b5c3c60af9f9f025af0d6db21c3103d7247cd433ea638b9ce78efb5659e5515ef8e15f7136e193c3470d5f87183f1939adc8e
7
- data.tar.gz: e2e0d34db7b81234f97e10e6e20e0747640ad15ac087c36c430c6d47540489414241c965a2759f31b3cf9bd9c6477c1d363793cb67f14c2769c03156f3ab2411
6
+ metadata.gz: 8d3a68f7eb97563c823f8accdfe7eb749505d9925ef28af4f9f772cd7411d73fdfb5fcf31e337f4930d861a65c3e9918f9b60e2299ca835d8f6c2ba9a573f16b
7
+ data.tar.gz: 1231d962eba2313ea44d2fe319a7adfb3cce35dcbe10a9909fc37be3bd27dcf9672dc65083cbe8b46cb6e04c5a10c9162586d9b45936e8a8df51eace20ca8b60
data/CHANGES.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-03-08 v0.0.75
4
+
5
+
6
+ - Added runtime reporting of tool allowed paths by introducing
7
+ `tool_paths_allowed` method and including it in chat output, updating config
8
+ prompt, and normalizing tool name handling.
9
+ - Added new tool `OllamaChat::Tools::ResolveTag` with utility
10
+ `OllamaChat::Utils::TagResolver` to parse tag files; enabled in
11
+ `default_config.yml` and added corresponding tests.
12
+ - Introduced `runtime_info` switch in `OllamaChat::Switches`; added
13
+ `/runtime_info` command handling in `chat.rb`, runtime info block injection,
14
+ and display via `information.rb`; added `prompts/runtime_info` template and
15
+ `languages:` array; added `runtime_info.toggle`, `runtime_info.show`,
16
+ `runtime_info.on?`, `runtime_info.enabled` support.
17
+ - Updated `OllamaChat::Tools::DirectoryStructure` description to note it can
18
+ locate one or multiple files, referencing `max_depth`.
19
+ - Clarified usage of `browse`, `copy_to_clipboard`, `open_file_in_editor`,
20
+ `insert_into_editor` tools in documentation strings; fixed double‑negative
21
+ typo in `insert_into_editor.rb`.
22
+ - Renamed `import_url` tool to `get_url`: updated config key, tool
23
+ registration, class name `OllamaChat::Tools::GetURL`, spec file names, method
24
+ calls to `config.tools.functions.get_url.schemes?`, replaced all
25
+ `chat.import` with `OllamaChat::Utils::Fetcher.get`.
26
+ - Added path validation and error handling to `OllamaChat::Tools::RunTests`:
27
+ new private method `check_path(path)` prevents using `"./"` and validates
28
+ existence; wrapped execution in rescue block returning JSON with `error:` and
29
+ `message:`; updated function description accordingly.
30
+ - Refined and unified tool descriptions with consistent punctuation.
31
+ - Added explicit persona loading verification when editing: confirmation step
32
+ before applying edited personality configurations.
33
+ - Improved persona loading and prompt formatting: updated
34
+ `setup_persona_from_opts`, `info_persona`, `load_persona_file` to return
35
+ `[pathname, content]`, added newline in `play_persona_prompt`, adjusted
36
+ `play_persona` to handle new return value.
37
+
3
38
  ## 2026-03-06 v0.0.74
4
39
 
5
40
  - Added new tool `ExecuteRI` in `lib/ollama_chat/tools/execute_ri.rb` that
data/README.md CHANGED
@@ -158,6 +158,7 @@ The following commands can be given inside the chat, if prefixed by a `/`:
158
158
  /markdown toggle markdown output
159
159
  /stream toggle stream output
160
160
  /location toggle location submission
161
+ /runtime_info toggle runtime information in prompts
161
162
  /voice [change] toggle voice output or change the voice
162
163
  /last [n] show the last n / 1 system/assistant message
163
164
  /list [n] list the last n / all conversation exchanges
@@ -219,6 +219,9 @@ class OllamaChat::Chat
219
219
  when %r(^/location$)
220
220
  location.toggle
221
221
  :next
222
+ when %r(^/runtime_info$)
223
+ runtime_info.toggle
224
+ :next
222
225
  when %r(^/voice(?:\s+(change))?$)
223
226
  if $1 == 'change'
224
227
  change_voice
@@ -408,7 +411,9 @@ class OllamaChat::Chat
408
411
  :next
409
412
  end
410
413
  when 'edit'
411
- if result = edit_persona
414
+ if result = edit_persona and
415
+ ask?(prompt: 'Load new persona profile? (y/n) ') =~ /\Ay/i
416
+ then
412
417
  result
413
418
  else
414
419
  :next
@@ -685,6 +690,20 @@ class OllamaChat::Chat
685
690
  end
686
691
  end
687
692
 
693
+ if runtime_info.on? && content
694
+ runtime_info = {
695
+ languages: config.languages * ', ',
696
+ location: location.on? ? location_description.inspect : 'n/a',
697
+ terminal_rows: Tins::Terminal.rows,
698
+ terminal_cols: Tins::Terminal.cols,
699
+ time: Time.now.iso8601,
700
+ voice: voice.on? ? 'enabled' : 'disabled',
701
+ markdown: markdown.on? ? 'enabled' : 'disabled',
702
+ tool_paths_allowed: JSON(tool_paths_allowed),
703
+ }
704
+ content << config.prompts.runtime_info % runtime_info
705
+ end
706
+
688
707
  messages << Ollama::Message.new(role: 'user', content:, images: @images.dup)
689
708
  @images.clear
690
709
  handler = OllamaChat::FollowChat.new(
@@ -103,6 +103,7 @@ module OllamaChat::Information
103
103
  think_mode.show
104
104
  think_loud.show
105
105
  location.show
106
+ runtime_info.show
106
107
  voice.show
107
108
  @voice.on? and @voices.show
108
109
  tools_support.show
@@ -124,6 +125,7 @@ module OllamaChat::Information
124
125
  /markdown toggle markdown output
125
126
  /stream toggle stream output
126
127
  /location toggle location submission
128
+ /runtime_info toggle runtime information in prompts
127
129
  /voice [change] toggle voice output or change the voice
128
130
  /last [n] show the last n / 1 system/assistant message
129
131
  /list [n] list the last n / all conversation exchanges
@@ -150,6 +150,18 @@ module OC
150
150
  description 'Pirate Weather API key'
151
151
  end
152
152
 
153
+ CTAGS_TOOL = set do
154
+ description 'Tools ctags path'
155
+ default { `which ctags`.full?(:chomp) }
156
+ check { value.blank? || File.exist?(value) }
157
+ end
158
+
159
+ TAGS_FILE = set do
160
+ description 'Tag file location'
161
+ default './tags'
162
+ decode { Pathname.new(_1).expand_path }
163
+ end
164
+
153
165
  module JIRA
154
166
  description 'Jira tool configuration'
155
167
 
@@ -8,11 +8,15 @@ timeouts:
8
8
  connect_timeout: null
9
9
  read_timeout: 300
10
10
  write_timeout: 300
11
+ languages:
12
+ - en-US
11
13
  location:
12
14
  enabled: false
13
15
  name: Berlin
14
16
  decimal_degrees: [ 52.514127, 13.475211 ]
15
17
  units: SI (International System of Units) # or USCS (United States Customary System)
18
+ runtime_info:
19
+ enabled: true
16
20
  prompts:
17
21
  embed: "This source was now embedded: %{source}"
18
22
  summarize: |
@@ -31,14 +35,35 @@ prompts:
31
35
 
32
36
  %{results}
33
37
  location: You are at %{location_name}, %{location_decimal_degrees}, preferring %{units}
38
+ runtime_info: |
39
+
40
+ ---
41
+
42
+ **Runtime Information**
43
+
44
+ There is usually no reason to mention this information to the user unless
45
+ asked about it.
46
+
47
+ - Languages the user prefers: %{languages}.
48
+ - Location is %{location}.
49
+ - Terminal has %{terminal_rows} rows.
50
+ - Terminal width is %{terminal_cols} columns. **Always** aim to stay within
51
+ 80%% of this width in your output of responses, especially when using
52
+ markdown tables.
53
+ - Current time is %{time}.
54
+ - Markdown output is %{markdown}. **Never** output markdown as your
55
+ responses if it is disabled.
56
+ - Voice output is %{voice}. Speak naturally and short if voice
57
+ output is enabled.
58
+ - These tools have access to these allowed paths: %{tool_paths_allowed}
34
59
  help: |
35
- Wait for the user to ask questions about the usage of chat commands. Just
36
- list the command names separated by spaces (no descriptions yet) and
37
- offer to answer any questions about any of them. Interactively help the
38
- user by answering questions about the following
39
- chat commands:
60
+ Wait for the user to ask questions about the usage of chat commands. Just
61
+ list the command names separated by spaces (no descriptions yet) and
62
+ offer to answer any questions about any of them. Interactively help the
63
+ user by answering questions about the following
64
+ chat commands:
40
65
 
41
- %{commands}
66
+ %{commands}
42
67
  persona: |
43
68
  # Persona
44
69
 
@@ -173,7 +198,7 @@ tools:
173
198
  default: true
174
199
  require_confirmation: true
175
200
  max_results: 25
176
- import_url:
201
+ get_url:
177
202
  default: true
178
203
  require_confirmation: true
179
204
  schemes:
@@ -203,3 +228,5 @@ tools:
203
228
  default: true
204
229
  execute_ri:
205
230
  default: true
231
+ resolve_tag:
232
+ default: true
@@ -35,6 +35,9 @@ module OllamaChat::PersonaeManagement
35
35
  FileUtils.mkdir_p personae_backup_directory
36
36
  end
37
37
 
38
+ # The setup_persona_from_opts method initializes persona setup by checking
39
+ # for a provided persona option, determining the appropriate file path, and
40
+ # playing the persona file if it exists.
38
41
  def setup_persona_from_opts
39
42
  @persona_setup and return
40
43
  @persona_setup = true
@@ -160,7 +163,7 @@ module OllamaChat::PersonaeManagement
160
163
  # Shows the persona's profile using kramdown formatting with ansi parsing.
161
164
  def info_persona
162
165
  if persona = choose_persona
163
- persona_profile = load_persona_file(persona)
166
+ _persona, persona_profile = load_persona_file(persona)
164
167
  use_pager do |output|
165
168
  output.puts kramdown_ansi_parse(<<~EOT)
166
169
  # Persona #{persona.sub_ext('')}
@@ -247,13 +250,17 @@ module OllamaChat::PersonaeManagement
247
250
  result.to_json
248
251
  end
249
252
 
250
- # Reads and returns the content of a persona file.
253
+ # Loads a persona file from disk.
251
254
  #
252
- # @param persona [String] The persona filename to read
253
- # @return [String] The content of the persona file
255
+ # @param persona [String] The basename of the persona (without extension)
256
+ #
257
+ # @return [Array<Pathname, String>] Returns the pathname and its content as a
258
+ # string
254
259
  def load_persona_file(persona)
255
260
  pathname = personae_directory + persona
256
- pathname.read if pathname.exist?
261
+ if pathname.exist?
262
+ return pathname, pathname.read
263
+ end
257
264
  end
258
265
 
259
266
  # Generates the roleplay prompt string for a persona.
@@ -265,7 +272,7 @@ module OllamaChat::PersonaeManagement
265
272
  # @return [String] Formatted roleplay prompt
266
273
  def play_persona_prompt(persona:, persona_profile:)
267
274
  persona_name = persona.basename.sub_ext('')
268
- "Roleplay as persona %{persona_name} loaded from %{persona}\n%{persona_profile}" % {
275
+ "Roleplay as persona %{persona_name} loaded from %{persona}\n\n%{persona_profile}" % {
269
276
  persona_name:, persona:, persona_profile:
270
277
  }
271
278
  end
@@ -275,8 +282,8 @@ module OllamaChat::PersonaeManagement
275
282
  # Uses the persona selection and loading methods to generate the
276
283
  # appropriate roleplay prompt.
277
284
  def play_persona(pathname: nil)
278
- persona = choose_persona or return
279
- persona_profile = load_persona_file(persona)
285
+ persona = choose_persona or return
286
+ persona, persona_profile = load_persona_file(persona)
280
287
  play_persona_prompt(persona:, persona_profile:)
281
288
  end
282
289
 
@@ -171,6 +171,13 @@ module OllamaChat::Switches
171
171
  # @return [ OllamaChat::Switches::Switch ] the location setting object
172
172
  attr_reader :location
173
173
 
174
+ # Provides access to the runtime_info switch controlling the visibility of
175
+ # runtime information in the chat
176
+ #
177
+ # @attr_reader [ Switches::Switch ] a Switch instance that manages runtime
178
+ # info visibility
179
+ attr_reader :runtime_info
180
+
174
181
  # Switch tools support on/off (off → skip all, on → honour per‑tool state)
175
182
  #
176
183
  # @return [OllamaChat::Switch] the tools_support setting object
@@ -250,6 +257,13 @@ module OllamaChat::Switches
250
257
  }
251
258
  )
252
259
 
260
+ @runtime_info = Switch.new(
261
+ value: config.runtime_info.enabled,
262
+ msg: {
263
+ true => "Runtime Information enabled.",
264
+ false => "Runtime Information disabled.",
265
+ }
266
+ )
253
267
  @tools_support = Switch.new(
254
268
  value: config.tools.enabled,
255
269
  msg: {
@@ -42,7 +42,7 @@ module OllamaChat::ToolCalling
42
42
  # @param [String] name the name of the tool
43
43
  # @return [true, false] true if the tool is enabled
44
44
  def tool_enabled?(name)
45
- enabled_tools.member?(name)
45
+ enabled_tools.member?(name.to_s)
46
46
  end
47
47
 
48
48
  # The tools reader returns the registered tools for the chat session.
@@ -153,6 +153,18 @@ module OllamaChat::ToolCalling
153
153
  end
154
154
  end
155
155
 
156
+ # The tool_paths_allowed method returns a hash mapping each enabled tool name
157
+ # to its list of allowed paths or patterns. @return [Hash] a hash where keys
158
+ # are tool names and values are the allowed path lists
159
+ def tool_paths_allowed
160
+ config.tools.functions.to_h.
161
+ select { |name, value| tool_enabled?(name) && value[:allowed].present? }.
162
+ sort_by(&:first).
163
+ each_with_object({}) { |(name, value), hash|
164
+ hash[name] = value[:allowed].map { Pathname.new(_1).expand_path.to_s }
165
+ }
166
+ end
167
+
156
168
  private
157
169
 
158
170
  # The handle_tool_call_results? method processes and returns results from
@@ -25,8 +25,9 @@ class OllamaChat::Tools::Browse
25
25
  function: Tool::Function.new(
26
26
  name:,
27
27
  description: <<~EOT,
28
- Open a URL or file in the user\'s default browser application so they
29
- can view the content directly
28
+ Launch external viewer Opens an HTTP/HTTPS link (or local file) in
29
+ the system’s web/browser app. Use when you want to hand off a page
30
+ for human inspection; no return value is expected.
30
31
  EOT
31
32
  parameters: Tool::Function::Parameters.new(
32
33
  type: 'object',
@@ -34,8 +35,7 @@ class OllamaChat::Tools::Browse
34
35
  url: Tool::Function::Parameters::Property.new(
35
36
  type: 'string',
36
37
  description: <<~EOT,
37
- The URL or file to open in the user\'s browser for them to view
38
- directly
38
+ The URL or file to open in the the system’s web/browser app.
39
39
  EOT
40
40
  ),
41
41
  },
@@ -20,15 +20,16 @@ class OllamaChat::Tools::CopyToClipboard
20
20
  function: Tool::Function.new(
21
21
  name:,
22
22
  description: <<~EOT,
23
- Copy a text to the clipboard (either the parameter text or the last
24
- response of the assistant)
23
+ Clipboard helper Copies supplied string (or last assistant reply if
24
+ omitted) into the OS clipboard, enabling quick pasting elsewhere. No
25
+ output.
25
26
  EOT
26
27
  parameters: Tool::Function::Parameters.new(
27
28
  type: 'object',
28
29
  properties: {
29
30
  text: Tool::Function::Parameters::Property.new(
30
31
  type: 'string',
31
- description: 'Text to copy to the clipboard (nil = last response)'
32
+ description: 'Text to copy to the clipboard (nil = last assistant reply)'
32
33
  )
33
34
  },
34
35
  required: []
@@ -25,8 +25,9 @@ class OllamaChat::Tools::DirectoryStructure
25
25
  function: Tool::Function.new(
26
26
  name:,
27
27
  description: <<~EOT,
28
- Retrieve the directory structure and file hierarchy for a given path,
29
- for depth of max_depth (if given).
28
+ Tree viewer Returns JSON describing files/folders under path up to
29
+ max_depth. Handy for locating resources or presenting a project
30
+ layout.
30
31
  EOT
31
32
  parameters: Tool::Function::Parameters.new(
32
33
  type: 'object',
@@ -19,7 +19,11 @@ class OllamaChat::Tools::ExecuteGrep
19
19
  type: 'function',
20
20
  function: Tool::Function.new(
21
21
  name:,
22
- description: 'Search for a pattern in files using grep',
22
+ description: <<~EOT,
23
+ Pattern searcher – Runs a regex against all files at path, optionally
24
+ case‑insensitive, returning matches (up to max_results). Useful for
25
+ quick codebase queries or finding config values.
26
+ EOT
23
27
  parameters: Tool::Function::Parameters.new(
24
28
  type: 'object',
25
29
  properties: {
@@ -17,7 +17,11 @@ class OllamaChat::Tools::ExecuteRI
17
17
  type: 'function',
18
18
  function: Tool::Function.new(
19
19
  name:,
20
- description: 'Look up Ruby documentation for classes, modules and methods using the `ri` command.',
20
+ description: <<~EOT,
21
+ Lookup Ruby docs using the `ri` command – Returns help text for a
22
+ given topic like class/module/method (Array, String#split). Good when
23
+ you need method signatures without leaving the chat.
24
+ EOT
21
25
  parameters: Tool::Function::Parameters.new(
22
26
  type: 'object',
23
27
  properties: {
@@ -26,10 +26,9 @@ class OllamaChat::Tools::FileContext
26
26
  function: Tool::Function.new(
27
27
  name:,
28
28
  description: <<~EOT,
29
- Create a context that provides information about files and their
30
- semantic content in order to give more accurate answers for a query.
31
- You can query (maybe) multiple files by using a glob pattern
32
- argument.
29
+ Semantic file snapshot Gathers AST‑style info (e.g., classes,
30
+ methods) from all matching files (pattern) in directory. Useful for
31
+ LLMs to reason about code structure
33
32
  EOT
34
33
  parameters: Tool::Function::Parameters.new(
35
34
  type: 'object',
@@ -23,7 +23,11 @@ class OllamaChat::Tools::GemPathLookup
23
23
  type: 'function',
24
24
  function: Tool::Function.new(
25
25
  name:,
26
- description: 'Look up the installation path of a Ruby gem',
26
+ description: <<~EOT,
27
+ Gem locator – Returns absolute filesystem location where a named gem
28
+ is installed (e.g., "rails"). Handy when you need file paths inside
29
+ gems.
30
+ EOT
27
31
  parameters: Tool::Function::Parameters.new(
28
32
  type: 'object',
29
33
  properties: {
@@ -24,7 +24,11 @@ class OllamaChat::Tools::GetCurrentWeather
24
24
  type: 'function',
25
25
  function: Tool::Function.new(
26
26
  name:,
27
- description: 'Get the current weather for the configured location',
27
+ description: <<~EOT,
28
+ Weather fetcher – Retrieves a short report of local meteorological
29
+ conditions based on your preset location coordinates. No arguments
30
+ needed.
31
+ EOT
28
32
  parameters: Tool::Function::Parameters.new(
29
33
  type: 'object',
30
34
  properties: {},
@@ -20,7 +20,10 @@ class OllamaChat::Tools::GetCVE
20
20
  type: 'function',
21
21
  function: Tool::Function.new(
22
22
  name:,
23
- description: 'Get the CVE for id as JSON',
23
+ description: <<~EOT,
24
+ CVE lookup – Returns detailed vulnerability data (JSON) for a given
25
+ cve_id ("CVE-2023‑1234"). Useful when assessing security risks.
26
+ EOT
24
27
  parameters: Tool::Function::Parameters.new(
25
28
  type: 'object',
26
29
  properties: {
@@ -20,7 +20,11 @@ class OllamaChat::Tools::GetEndoflife
20
20
  type: 'function',
21
21
  function: Tool::Function.new(
22
22
  name:,
23
- description: 'Get the endoflife information for a product as JSON',
23
+ description: <<~EOT,
24
+ EOL checker – Provides lifecycle status of software (product) in
25
+ machine‑readable form (JSON). Handy for compliance or upgrade
26
+ planning.
27
+ EOT
24
28
  parameters: Tool::Function::Parameters.new(
25
29
  type: 'object',
26
30
  properties: {
@@ -20,7 +20,10 @@ class OllamaChat::Tools::GetRFC
20
20
  type: 'function',
21
21
  function: Tool::Function.new(
22
22
  name:,
23
- description: 'Get the RFC for id as text',
23
+ description: <<~EOT,
24
+ RFC fetcher – Downloads the full plain‑text of an Internet Standard
25
+ (e.g., "rfc-2616"). No arguments beyond rfc_id.
26
+ EOT
24
27
  parameters: Tool::Function::Parameters.new(
25
28
  type: 'object',
26
29
  properties: {
@@ -28,7 +28,10 @@ class OllamaChat::Tools::GetTime
28
28
  type: 'function',
29
29
  function: Tool::Function.new(
30
30
  name:,
31
- description: 'Get the current time as an ISO8601 string',
31
+ description: <<~EOT,
32
+ Timestamp provider – Returns UTC/ISO 8601 formatted datetime for now.
33
+ Useful in logs or timestamps.
34
+ EOT
32
35
  parameters: Tool::Function::Parameters.new(
33
36
  type: 'object',
34
37
  properties: {},
@@ -3,10 +3,10 @@
3
3
  # This tool allows the chat client to retrieve content from a specified URL.
4
4
  # It integrates with the Ollama tool calling system to provide web content
5
5
  # fetching capabilities to the language model.
6
- class OllamaChat::Tools::ImportURL
6
+ class OllamaChat::Tools::GetURL
7
7
  include OllamaChat::Tools::Concern
8
8
 
9
- def self.register_name = 'import_url'
9
+ def self.register_name = 'get_url'
10
10
 
11
11
  # Creates and returns a tool definition for fetching content from URLs.
12
12
  #
@@ -21,11 +21,9 @@ class OllamaChat::Tools::ImportURL
21
21
  function: Tool::Function.new(
22
22
  name:,
23
23
  description: <<~EOT,
24
- Fetch content from a URL and import it into the chat session. This
25
- tool retrieves web content from the specified URL and makes it
26
- available for the language model to reference and use in responses.
27
- It supports various content types including HTML, Markdown, and plain
28
- text, and integrates with the chat's document processing pipeline.
24
+ Web fetcher Downloads any web resource (HTML, Markdown, plain text)
25
+ at url and makes its contents available to the model. Good for pulling
26
+ documentation snippets.
29
27
  EOT
30
28
  parameters: Tool::Function::Parameters.new(
31
29
  type: 'object',
@@ -33,7 +31,7 @@ class OllamaChat::Tools::ImportURL
33
31
  url: Tool::Function::Parameters::Property.new(
34
32
  type: 'string',
35
33
  description: <<~EOT,
36
- The URL to fetch content from. This can be any valid HTTP or
34
+ The URL to get content from. This can be any valid HTTP or
37
35
  HTTPS URL pointing to a web resource that can be retrieved and
38
36
  processed by the chat system. The tool handles the HTTP request
39
37
  and returns the content.
@@ -57,12 +55,11 @@ class OllamaChat::Tools::ImportURL
57
55
  # @return [String] the fetched content as a JSON string
58
56
  # @raise [StandardError] if there's an issue with the HTTP request or content fetching
59
57
  def execute(tool_call, **opts)
60
- chat = opts[:chat]
61
58
  config = opts[:config]
62
59
  args = tool_call.function.arguments
63
60
  url = args.url.to_s
64
61
 
65
- allowed_schemes = Array(config.tools.functions.import_url.schemes?).map(&:to_s)
62
+ allowed_schemes = Array(config.tools.functions.get_url.schemes?).map(&:to_s)
66
63
 
67
64
  uri = URI.parse(args.url.to_s)
68
65
  unless allowed_schemes.include?(uri.scheme)
@@ -70,9 +67,11 @@ class OllamaChat::Tools::ImportURL
70
67
  "(allowed: #{allowed_schemes.join(', ')})"
71
68
  end
72
69
 
73
- chat.import(url).full? do |c|
74
- return c.ask_and_send_or_self(:read)
75
- end
70
+ OllamaChat::Utils::Fetcher.get(
71
+ url,
72
+ debug: OC::OLLAMA::CHAT::DEBUG,
73
+ reraise: true,
74
+ &:read)
76
75
  rescue => e
77
76
  { error: e.class, message: e.message, url: }.to_json
78
77
  end
@@ -15,11 +15,11 @@ class OllamaChat::Tools::InsertIntoEditor
15
15
  function: Tool::Function.new(
16
16
  name:,
17
17
  description: <<~EOT,
18
- Insert the provided text into your editor (Vim). If no
19
- `text` is supplied, the tool will automatically use the last
20
- assistant response. This function is intended for quick code
21
- snippets or edits that you want to push directly into a running
22
- editor session without leaving OllamaChat.
18
+ Editor helper Sends a string (or last reply if omitted) straight
19
+ into the User’s editor buffer, optionally in insert mode.
20
+ If no `text` is supplied, the tool will automatically use the last assistant
21
+ response. No output; Do not not call this tool function unless
22
+ explicitly requested by the user.
23
23
  EOT
24
24
  parameters: Tool::Function::Parameters.new(
25
25
  type: 'object',
@@ -20,7 +20,11 @@ class OllamaChat::Tools::OpenFileInEditor
20
20
  type: 'function',
21
21
  function: Tool::Function.new(
22
22
  name:,
23
- description: 'Open a file in the vim editor at a specific line or range',
23
+ description: <<~EOT,
24
+ Open a file in the user's editor, jumping to start_line (and
25
+ optionally ending at end_line). No return value; Do not call this
26
+ tool function unless explicitly requested by the user.
27
+ EOT
24
28
  parameters: Tool::Function::Parameters.new(
25
29
  type: 'object',
26
30
  properties: {
@@ -17,7 +17,11 @@ class OllamaChat::Tools::PasteFromClipboard
17
17
  type: 'function',
18
18
  function: Tool::Function.new(
19
19
  name:,
20
- description: 'Paste content from the system clipboard into the chat session',
20
+ description: <<~EOT,
21
+ Clipboard reader – Inserts whatever is currently in your OS clipboard
22
+ as a new message to the assistant, enabling quick transfer of
23
+ external snippets.
24
+ EOT
21
25
  parameters: Tool::Function::Parameters.new(
22
26
  type: 'object',
23
27
  properties: {},
@@ -24,7 +24,11 @@ class OllamaChat::Tools::ReadFile
24
24
  type: 'function',
25
25
  function: Tool::Function.new(
26
26
  name: 'read_file',
27
- description: 'Reads file content safely (path validated like write_file)',
27
+ description: <<~EOT,
28
+ File reader – Returns raw text from path if it’s within allowed
29
+ directories. No side effects; useful for inspecting config or source
30
+ files.
31
+ EOT
28
32
  parameters: Tool::Function::Parameters.new(
29
33
  type: 'object',
30
34
  properties: {