ollama_chat 0.0.80 → 0.0.82

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +141 -91
  3. data/Rakefile +2 -2
  4. data/lib/ollama_chat/chat.rb +18 -6
  5. data/lib/ollama_chat/config_handling.rb +3 -3
  6. data/lib/ollama_chat/conversation.rb +1 -1
  7. data/lib/ollama_chat/dialog.rb +2 -2
  8. data/lib/ollama_chat/follow_chat.rb +8 -4
  9. data/lib/ollama_chat/http_handling.rb +63 -0
  10. data/lib/ollama_chat/information.rb +1 -0
  11. data/lib/ollama_chat/message_output.rb +1 -1
  12. data/lib/ollama_chat/oc.rb +5 -0
  13. data/lib/ollama_chat/ollama_chat_config/default_config.yml +1 -0
  14. data/lib/ollama_chat/personae_management.rb +2 -2
  15. data/lib/ollama_chat/server_socket.rb +1 -1
  16. data/lib/ollama_chat/source_fetching.rb +1 -28
  17. data/lib/ollama_chat/tools/concern.rb +2 -0
  18. data/lib/ollama_chat/tools/copy_to_clipboard.rb +0 -1
  19. data/lib/ollama_chat/tools/directory_structure.rb +1 -1
  20. data/lib/ollama_chat/tools/execute_grep.rb +3 -3
  21. data/lib/ollama_chat/tools/file_context.rb +2 -2
  22. data/lib/ollama_chat/tools/generate_password.rb +2 -3
  23. data/lib/ollama_chat/tools/get_current_weather.rb +6 -11
  24. data/lib/ollama_chat/tools/get_cve.rb +9 -13
  25. data/lib/ollama_chat/tools/get_endoflife.rb +4 -4
  26. data/lib/ollama_chat/tools/get_jira_issue.rb +1 -1
  27. data/lib/ollama_chat/tools/get_rfc.rb +4 -4
  28. data/lib/ollama_chat/tools/get_url.rb +4 -7
  29. data/lib/ollama_chat/tools/paste_from_clipboard.rb +1 -1
  30. data/lib/ollama_chat/tools/paste_into_editor.rb +4 -5
  31. data/lib/ollama_chat/tools/patch_file.rb +3 -3
  32. data/lib/ollama_chat/tools/read_file.rb +2 -2
  33. data/lib/ollama_chat/tools/resolve_tag.rb +1 -1
  34. data/lib/ollama_chat/tools/run_tests.rb +1 -1
  35. data/lib/ollama_chat/tools/search_web.rb +3 -3
  36. data/lib/ollama_chat/tools/write_file.rb +3 -3
  37. data/lib/ollama_chat/utils/path_completer.rb +62 -0
  38. data/lib/ollama_chat/utils/tag_resolver.rb +14 -7
  39. data/lib/ollama_chat/utils.rb +1 -0
  40. data/lib/ollama_chat/version.rb +1 -1
  41. data/lib/ollama_chat/web_searching.rb +2 -10
  42. data/lib/ollama_chat.rb +1 -0
  43. data/ollama_chat.gemspec +8 -8
  44. data/spec/ollama_chat/chat_spec.rb +3 -0
  45. data/spec/ollama_chat/tools/browse_spec.rb +4 -8
  46. data/spec/ollama_chat/tools/copy_to_clipboard_spec.rb +0 -4
  47. data/spec/ollama_chat/tools/directory_structure_spec.rb +3 -7
  48. data/spec/ollama_chat/tools/execute_grep_spec.rb +7 -7
  49. data/spec/ollama_chat/tools/file_context_spec.rb +2 -6
  50. data/spec/ollama_chat/tools/generate_password_spec.rb +5 -9
  51. data/spec/ollama_chat/tools/get_current_weather_spec.rb +2 -2
  52. data/spec/ollama_chat/tools/get_cve_spec.rb +2 -2
  53. data/spec/ollama_chat/tools/get_endoflife_spec.rb +2 -2
  54. data/spec/ollama_chat/tools/get_rfc_spec.rb +2 -2
  55. data/spec/ollama_chat/tools/get_url_spec.rb +3 -7
  56. data/spec/ollama_chat/tools/open_file_in_editor_spec.rb +0 -4
  57. data/spec/ollama_chat/tools/paste_from_clipboard_spec.rb +0 -4
  58. data/spec/ollama_chat/tools/paste_into_editor_spec.rb +5 -9
  59. data/spec/ollama_chat/tools/patch_file_spec.rb +5 -9
  60. data/spec/ollama_chat/tools/read_file_spec.rb +3 -7
  61. data/spec/ollama_chat/tools/resolve_tag_spec.rb +6 -0
  62. data/spec/ollama_chat/tools/run_tests_spec.rb +4 -8
  63. data/spec/ollama_chat/tools/search_web_spec.rb +3 -7
  64. data/spec/ollama_chat/tools/write_file_spec.rb +5 -9
  65. data/spec/ollama_chat/utils/path_completer_spec.rb +34 -0
  66. metadata +12 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5116e552c78df5d85138b112ef43b4a80bbb7e2ce03fd5cbd5e58f7adbde948d
4
- data.tar.gz: 22ff0f77807fa3560ce394a0e840ea367770596f2a261cddb650c24eaf362d01
3
+ metadata.gz: 4dfcb462fdb59e2b4cf31ef8d489627982e71c88cfc9dea8c89597607311e95d
4
+ data.tar.gz: 1fed1ad543d810ddf0b54b5390b8a031cf3108bd67d56a9a91b5917fc2cdd219
5
5
  SHA512:
6
- metadata.gz: ad573ad4cfdd39455f2720e2283e4487afaae6d17dbb451580289afdfef77b433fb426bb2cc516225db514365d788b8441efeb11ab9b0f2916accc5817d619a1
7
- data.tar.gz: 583cb266287eaad72e28543e34003da6b72f072f1c45b751327b6218b9ed842c35639759d8f37a0fd8051167fcbd735a3c32c4b0c9443a5c4cf2074ace755a03
6
+ metadata.gz: fe1384443f22e5890a784be50a632c9a4d15e8fbf72f0084acf99016aa46a741320af818a72d3797007bced8f0f47155001a12e0103be3ac35f2fb6beba8db6d
7
+ data.tar.gz: e79cd80f16e97778f6e61451b7aefbbfdf44a1a08cdce5029a21e050f78461fcf11e198ae04e9e0845d2ed9426057c5616333a09bc9d8eaf391be7a3b8c4d290
data/CHANGES.md CHANGED
@@ -1,169 +1,219 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-03-21 v0.0.82
4
+
5
+ - Add a `before` block setting `OC::OLLAMA::CHAT::TOOLS::CTAGS_TOOL` to `ctags`
6
+ in the `resolve_tag` spec.
7
+ - Updated `OllamaChat::Tools::PasteIntoEditor` description to use `text`
8
+ instead of `string` and clarified that no file or line is required when
9
+ pasting into the editor.
10
+ - Added bell and question mark emojis to various `confirm?` and `ask?` prompts
11
+ across multiple modules for clearer UX.
12
+ - Updated prompt string to `⏎ Press …` for better display.
13
+ - Enhanced `OllamaChat::Tools::ResolveTag` and `OllamaChat::Utils::TagResolver`
14
+ with a new `kinds` method, updated `kind` parameter description, refactored
15
+ `kind_of`, and fixed tag‑parsing regex to capture all columns.
16
+
17
+ ## 2026-03-20 v0.0.81
18
+
19
+ - Added `http_handling.rb` and `path_completer.rb` to gemspec
20
+ `s.extra_rdoc_files`, `s.files`, and `s.test_files` lists, ensuring these
21
+ modules are documented and packaged.
22
+ - Updated `http_options` to build SSL and proxy settings.
23
+ - Completed `get_url` to merge headers, pass cache, debug, and reraise flags.
24
+ - Updated YARD comments with parameter and return details.
25
+ - Fixed `config.request_headers` usage and added `merge`.
26
+ - Declared `proxy` variable in options hash.
27
+ - Added `debug` flag from `config` to fetcher call.
28
+ - Added `PathCompleter` utility in `lib/ollama_chat/utils/path_completer.rb`
29
+ that expands `./` and `~/` paths using `Dir.glob` and `File.expand_path`.
30
+ - Updated `lib/ollama_chat/utils.rb` to require the new helper.
31
+ - Replaced inline path completion logic in `lib/ollama_chat/chat.rb` with
32
+ `OllamaChat::Utils::PathCompleter.new(pre, input).complete`.
33
+ - Added tests for `PathCompleter` in
34
+ `spec/ollama_chat/utils/path_completer_spec.rb`, stubbing `expand_path` for
35
+ home‑directory case.
36
+ - Added duration metric to tool call results: recorded `start = Time.now`
37
+ before each tool call, stored `tools_used[name]` as a hash with `size` and
38
+ `duration` keys, calculated `duration` with `Time.now - start` and formatted
39
+ as `Tins::Duration.new(...).to_s`, kept size formatting using
40
+ `Tins::Unit.format(..., unit: ?B, prefix: 1024, format: '%.1f %U')`.
41
+ - Added `./` file path completion to Reline: updated
42
+ `OllamaChat::Chat#enable_command_completion` to add `./` path completion,
43
+ replaced old `RELINE` completion proc with a new `case before` block that
44
+ checks for `^/` and `./` patterns, ensuring file path completions are only
45
+ offered when the user starts with `./`.
46
+ - Added user name to runtime info and prompts: added `OC::USER` config variable
47
+ with default from `ENV['USER']`, included `user` in the hash returned by
48
+ `runtime_information_values`, extended default prompts in
49
+ `lib/ollama_chat/ollama_chat_config/default_config.yml` to show “Name of the
50
+ chat user: %{user}”, updated tests in `spec/ollama_chat/chat_spec.rb` to set
51
+ `OC::PAGER` to `nil` for cleaner output.
52
+
3
53
  ## 2026-03-18 v0.0.80
4
54
 
5
55
  ### Output & Paging
6
56
 
7
- - Remove the automatic `info` call from the main flow
8
- - Wrap all output handling inside a `use_pager do |output|` block
57
+ - Remove the automatic `info` call from the main flow
58
+ - Wrap all output handling inside a `use_pager do |output|` block
9
59
  - Pass the `output:` keyword to sub‑methods (`collection_stats`,
10
- `Switches.show`, etc.)
11
- - Adjust `Pager` to use a local `buffer` variable and `output.puts buffer`
60
+ `Switches.show`, etc.)
61
+ - Adjust `Pager` to use a local `buffer` variable and `output.puts buffer`
12
62
  - Update `StateSelectors.show` and `Switches.show` to accept `output: STDOUT`
13
- and use `output.puts`
63
+ and use `output.puts`
14
64
  - Modify `Switches.set` to accept `output: STDOUT` and call
15
65
  `self.show(output:)`
16
66
 
17
67
  ### Collection & Runtime Info
18
68
 
19
69
  - Change `collection_stats` signature to `output: STDOUT` and replace
20
- `STDOUT.puts` with `output.puts`
21
- - Show runtime‑information only when `runtime_info.on? && content` is true
70
+ `STDOUT.puts` with `output.puts`
71
+ - Show runtime‑information only when `runtime_info.on? && content` is true
22
72
  - Append a JSON line for runtime‑info instead of a plain‑text list
23
73
 
24
74
  ### Tool Call Handling
25
75
 
26
- - Initialize `tools_used` hash in `OllamaChat::FollowChat#handle_tool_calls`
27
- - Store the formatted size of each tool result using `Tins::Unit.format`
76
+ - Initialize `tools_used` hash in `OllamaChat::FollowChat#handle_tool_calls`
77
+ - Store the formatted size of each tool result using `Tins::Unit.format`
28
78
  - Replace the non‑existent `full?` check with `size ==
29
- response.message.tool_calls.size`
79
+ response.message.tool_calls.size`
30
80
  - Show a summary of tool call results and pause for user confirmation
31
81
 
32
82
  ### Confirmation Prompt
33
83
 
34
84
  - Add `confirm?` method to `OllamaChat::Dialog` for single‑character
35
- confirmation prompts
85
+ confirmation prompts
36
86
  - Replace all `ask?` calls with `confirm?`
37
87
 
38
88
  ### Command DSL
39
89
 
40
- - Add a `command` DSL in `command_concern.rb` for registering chat commands
90
+ - Add a `command` DSL in `command_concern.rb` for registering chat commands
41
91
  - Include `OllamaChat::CommandConcern` in `chat.rb` and drop the old
42
- `handle_input` logic
92
+ `handle_input` logic
43
93
  - Replace hard‑coded command handling with the new DSL (e.g., `/toggle`,
44
94
  `/input`, `/revise`, etc.)
45
95
 
46
96
  ### Documentation & README
47
97
 
48
98
  - Update `README.md` to show the new `/toggle` syntax and expanded command
49
- table
99
+ table
50
100
  - Update `bin/ollama_chat_send` help text to reflect the renamed `/input`
51
101
  command
52
102
 
53
103
  ### Utility Helpers
54
104
 
55
- - Add `go_command` helper in `dialog.rb` for parsing command‑line options
105
+ - Add `go_command` helper in `dialog.rb` for parsing command‑line options
56
106
  - Add `file_set_each`, `all_file_set`, and `provide_file_set_content` to
57
- `input_content.rb`
58
- - Update `context_spook` to use `file_set_each` and accept an `all` flag
59
- - Add `strip_internal_json_markers` helper in `chat.rb`
107
+ `input_content.rb`
108
+ - Update `context_spook` to use `file_set_each` and accept an `all` flag
109
+ - Add `strip_internal_json_markers` helper in `chat.rb`
60
110
  - Add `choose_file_set` helper in `OllamaChat::Dialog` returning a `Set` of
61
111
  expanded `Pathname` objects
62
112
 
63
113
  ### Source Fetching & Links
64
114
 
65
- - Refactor `source_fetching.rb` to coerce sources to string
115
+ - Refactor `source_fetching.rb` to coerce sources to string
66
116
  - Add a lazy `links` method and remove the old `links` method from `Chat`
67
117
 
68
118
  ### Retrieval Snippets
69
119
 
70
120
  - Update retrieval‑snippet injection to use a JSON block instead of a
71
- plain‑text list
121
+ plain‑text list
72
122
  - Use `strip_internal_json_markers` for `:ollama_chat_retrieval_snippets` and
73
- `:ollama_chat_runtime_information`
123
+ `:ollama_chat_runtime_information`
74
124
  - Truncate user query to `config.embedding.model.context_length` before calling
75
125
  `@documents.find_where`
76
126
 
77
127
  ### Directory Structure Tool
78
128
 
79
- - Add `suffix` parameter to `directory_structure` function
129
+ - Add `suffix` parameter to `directory_structure` function
80
130
  - Update `OllamaChat::Utils::AnalyzeDirectory.generate_structure` to accept a
81
- `suffix:` argument and filter files accordingly
131
+ `suffix:` argument and filter files accordingly
82
132
  - Ensure only files matching the given extension are included; hidden files and
83
133
  symlinks remain excluded
84
134
 
85
135
  ### Persona Management
86
136
 
87
- - Update persona option labels to `keep`, `reload_default`, `choose_different`
88
- - Add interactive persona reload options via a menu in `reload_default_persona`
89
- - Use `SearchUI::Wrapper` and `OllamaChat::Utils::Chooser` for selection
137
+ - Update persona option labels to `keep`, `reload_default`, `choose_different`
138
+ - Add interactive persona reload options via a menu in `reload_default_persona`
139
+ - Use `SearchUI::Wrapper` and `OllamaChat::Utils::Chooser` for selection
90
140
  - Update `@default_persona` when selecting “load_new”
91
141
 
92
142
  ### Path Validation
93
143
 
94
- - Add `check_file` flag to `path_validator.rb` method signature
95
- - Guard against non‑directory parents and file existence when `check_file:true`
144
+ - Add `check_file` flag to `path_validator.rb` method signature
145
+ - Guard against non‑directory parents and file existence when `check_file:true`
96
146
  - Propagate `check_file` flag in calls from `file_context`, `patch_file`, and
97
147
  `read_file`
98
148
 
99
149
  ### Tests & Specs
100
150
 
101
151
  - Adjust specs to stub `OC::PAGER`, expect `use_pager` yielding a `StringIO`,
102
- and verify `STDOUT.puts` calls
103
- - Update test expectations for new command handling and help output
152
+ and verify `STDOUT.puts` calls
153
+ - Update test expectations for new command handling and help output
104
154
  - Expect `OllamaChat::InvalidPathError` instead of `Errno::ENOENT` in relevant
105
- specs
155
+ specs
106
156
  - Add `asset_pathname` helper in `spec_helper.rb`
107
157
 
108
158
  ### Miscellaneous
109
159
 
110
- - Add `reline` gem to `.utilsrc` dependency list
160
+ - Add `reline` gem to `.utilsrc` dependency list
111
161
  - Consider `-c` flag to skip persona setup when loading an existing
112
- conversation
162
+ conversation
113
163
  - Standardize `register_name` method comments to `@return [String] the
114
- registered name for this tool`
164
+ registered name for this tool`
115
165
 
116
166
  ## 2026-03-13 v0.0.79
117
167
 
118
- - Added `tmp/*` to Rakefile ignore list for cleaner builds.
119
- - Updated gemspec: changed `s.rubygems_version` to **3.6.9**.
120
- - Added `logging.rb` to `extra_rdoc_files` and `files` in gemspec.
121
- - Adjusted gemspec file list to reflect new structure.
122
- - Removed `Runtime Directory` (`-d`) explanation from `README.md`.
123
- - Updated URL in `README.md`.
168
+ - Added `tmp/*` to Rakefile ignore list for cleaner builds.
169
+ - Updated gemspec: changed `s.rubygems_version` to **3.6.9**.
170
+ - Added `logging.rb` to `extra_rdoc_files` and `files` in gemspec.
171
+ - Adjusted gemspec file list to reflect new structure.
172
+ - Removed `Runtime Directory` (`-d`) explanation from `README.md`.
173
+ - Updated URL in `README.md`.
124
174
  - Added explicit check that `args.path.full?` is true before calling
125
175
  `assert_valid_path`, raising `ArgumentError` with message `'require path to
126
- file to be patched'`.
176
+ file to be patched'`.
127
177
  - Updated path assignment to first validate presence, then assert validity
128
- against `config.tools.functions.patch_file.allowed?`.
178
+ against `config.tools.functions.patch_file.allowed?`.
129
179
  - Updated `OllamaChat::Tools::ExecuteGrep` to accept new options `before`,
130
- `after`, and `context`.
131
- - Added helper method `normalize_number` for optional integer arguments.
180
+ `after`, and `context`.
181
+ - Added helper method `normalize_number` for optional integer arguments.
132
182
  - Adjusted command template in `default_config.yml` to include `-B`, `-A`, and
133
- `-C` flags based on provided values.
183
+ `-C` flags based on provided values.
134
184
  - Refactored logging: replaced `logger.error` / `logger.warn` calls with
135
- `log(:error, …)` or `log(:warn, …)` across multiple files.
185
+ `log(:error, …)` or `log(:warn, …)` across multiple files.
136
186
  - Added optional `warn: true` flag to new helper so that critical errors also
137
187
  trigger a user‑visible warning output while still being written to the log
138
- file.
188
+ file.
139
189
  - Implemented `OllamaChat::Logging#log(severity, msg, warn:)` in `logging.rb`;
140
190
  it formats exceptions with backtraces and forwards messages to the underlying
141
- Ruby `Logger`.
191
+ Ruby `Logger`.
142
192
  - Updated `spec_helper.rb` by adding a global `config.before` hook that sets
143
193
  temporary paths for `OC::OLLAMA::CHAT::HISTORY` and `LOGFILE` so all specs
144
- run against isolated files.
145
- - Added `tmp/*` to `.gitignore`.
194
+ run against isolated files.
195
+ - Added `tmp/*` to `.gitignore`.
146
196
  - Created new module `OllamaChat::Logging` that lazily builds a Logger writing
147
- to the file defined by `OC::OLLAMA::CHAT::LOGFILE` in XDG STATE.
197
+ to the file defined by `OC::OLLAMA::CHAT::LOGFILE` in XDG STATE.
148
198
  - Required this logging module in `lib/ollama_chat.rb` and included it in
149
- `class OllamaChat::Chat` so every chat instance has access to `logger`.
199
+ `class OllamaChat::Chat` so every chat instance has access to `logger`.
150
200
  - Logged connection messages via `@chat.logger.info` before printing the
151
- “Connecting …” line in `OllamaChat::Dialog#connect_message`.
201
+ “Connecting …” line in `OllamaChat::Dialog#connect_message`.
152
202
  - Centralized tool‑call error handling: log unconfigured, unregistered or
153
203
  disabled tools with `@chat.logger.error`, and record each executed function
154
- payload using `JSON.pretty_generate`.
204
+ payload using `JSON.pretty_generate`.
155
205
  - Introduced an explicit vs implicit confirmation flow (`:explicit`,
156
206
  `:implicite`, `:denied`) in `OllamaChat::FollowChat#follow_chat` and log the
157
- outcome accordingly.
207
+ outcome accordingly.
158
208
  - Switched chat history storage from XDG CACHE to XDG STATE by updating
159
209
  `OC::OLLAMA::CHAT::HISTORY` path, adjusting file operations in
160
210
  `lib/ollama_chat/history.rb`, and adding a new config entry for `LOGFILE`
161
- under state home in `oc.rb`.
211
+ under state home in `oc.rb`.
162
212
  - Enhanced PatchFile tool: updated documentation to specify `unified diff
163
- format` and `JSON response`.
164
- - Added private method `digest` that returns `MD5` of a file path.
213
+ format` and `JSON response`.
214
+ - Added private method `digest` that returns `MD5` of a file path.
165
215
  - Modified `apply_patch` to compute old digest, run patch command, compare
166
- digests, set `success` flag accordingly.
216
+ digests, set `success` flag accordingly.
167
217
  - Improved error handling: now includes `success`, clearer messages, empty
168
218
  result on failure.
169
219
 
@@ -193,64 +243,64 @@
193
243
  inserted `%{time}` placeholder into prompts section of `default_config.yml`;
194
244
  added Git placeholders (`%{git_current_branch}`, `%{git_remote_origin}`)
195
245
  under **Git** key; reformatted terminal info under a single **Terminal**
196
- heading with height and width.
246
+ heading with height and width.
197
247
  - Extend weather tool to include six‑day forecast: updated `GetCurrentWeather`
198
248
  description to mention a six‑day forecast; functionality unchanged; tool
199
- still requires no arguments.
249
+ still requires no arguments.
200
250
  - Rename `insert_into_editor` tool to `paste_into_editor`: updated
201
251
  `lib/ollama_chat/tools.rb` to require `paste_into_editor`; renamed and
202
252
  updated class from `InsertIntoEditor` to `PasteIntoEditor` in
203
253
  `paste_into_editor.rb`, changing its register name, description text, and
204
254
  method logic; switched default config key in `default_config.yml` from
205
255
  `insert_into_editor` to `paste_into_editor`; refactored spec files; adjusted
206
- all internal references.
256
+ all internal references.
207
257
 
208
258
  ## 2026-03-09 v0.0.76
209
259
 
210
260
  - Added `client:` and `current_directory:` keys to `runtime_info_values` in
211
- `chat.rb`.
261
+ `chat.rb`.
212
262
  - Implemented `#client` method returning `"progname **0.0.75**"` in
213
- `information.rb`.
214
- - Introduced helper `location_description?` in `location_handling.rb`.
263
+ `information.rb`.
264
+ - Introduced helper `location_description?` in `location_handling.rb`.
215
265
  - Simplified `MessageList#to_ary` to return a duplicate of the internal array,
216
- removing automatic system prompt + location injection.
266
+ removing automatic system prompt + location injection.
217
267
  - Updated default config placeholders for `%{client}` and
218
- `%{current_directory}` in `default_config.yml`.
268
+ `%{current_directory}` in `default_config.yml`.
219
269
  - Adjusted web searching logic to use `location_description?` instead of
220
- deprecated methods.
270
+ deprecated methods.
221
271
  - Removed tests that expected location‑augmented system prompts from
222
- `spec/ollama_chat/message_list_spec.rb`.
272
+ `spec/ollama_chat/message_list_spec.rb`.
223
273
  - Standardized JSON output formatting across tools: aligned JSON keys, added
224
274
  spaces after commas, and added trailing commas in tool responses such as
225
275
  `copy_to_clipboard`, `gem_path_lookup`, `generate_password`, `get_endoflife`,
226
276
  `get_rfc`, `insert_into_editor`, `open_file_in_editor`,
227
- `paste_from_clipboard`, and `search_web`.
277
+ `paste_from_clipboard`, and `search_web`.
228
278
  - Added trailing commas to JSON objects for consistency and easier future
229
- edits.
279
+ edits.
230
280
  - Standardized error field formatting, ensuring each error block includes a
231
- space after the colon and a trailing comma where appropriate.
281
+ space after the colon and a trailing comma where appropriate.
232
282
  - Added helper `disable_content_parsing` in `chat.rb` that sets `@parse_content
233
- = false`.
283
+ = false`.
234
284
  - Refactored command handlers to call `disable_content_parsing` instead of
235
- assigning directly to `@parse_content`.
285
+ assigning directly to `@parse_content`.
236
286
  - Updated persona setup logic so that a returned persona result triggers
237
287
  `disable_content_parsing`; otherwise parsing is enabled with
238
- `enable_command_completion`.
239
- - Added explanatory comments around the new helper for clarity.
288
+ `enable_command_completion`.
289
+ - Added explanatory comments around the new helper for clarity.
240
290
  - Improved clean flow: captured return value of `clean` and set `@parse_content
241
- = true` when a persona profile is returned.
291
+ = true` when a persona profile is returned.
242
292
  - Replaced old flag `@persona_setup` with `@default_persona`; ensured it
243
- defaults to `:none` in an `ensure` block after setup.
293
+ defaults to `:none` in an `ensure` block after setup.
244
294
  - Added new method `reload_default_persona` that prompts for confirmation
245
- before reloading the default persona file if one exists.
295
+ before reloading the default persona file if one exists.
246
296
  - Modified `clean(what)` to return the result of `reload_default_persona`,
247
- enabling the caller to react to a reload.
297
+ enabling the caller to react to a reload.
248
298
  - Adjusted `/clear` command handling in the chat loop to use the returned value
249
- from `clean` and only proceed when nothing is returned.
299
+ from `clean` and only proceed when nothing is returned.
250
300
  - Renamed local variable `runtime_info` to `runtime_info_values` in `chat.rb`
251
- for clarity.
301
+ for clarity.
252
302
  - Updated runtime info prompt interpolation to use `runtime_info_values`
253
- instead of `runtime_info`.
303
+ instead of `runtime_info`.
254
304
  - Updated `/.utilsrc` by adding gems to the `code_indexer` configuration:
255
305
  `all_images`, `const_conf`, `context_spook`, `csv`, `fileutils`, `gem_hadar`,
256
306
  `infobar`, `irb`, `kramdown`, and `kramdown-parser-gfm`.
@@ -262,28 +312,28 @@
262
312
  prompt, and normalizing tool name handling.
263
313
  - Added new tool `OllamaChat::Tools::ResolveTag` with utility
264
314
  `OllamaChat::Utils::TagResolver` to parse tag files; enabled in
265
- `default_config.yml` and added corresponding tests.
315
+ `default_config.yml` and added corresponding tests.
266
316
  - Introduced `runtime_info` switch in `OllamaChat::Switches`; added
267
317
  `/runtime_info` command handling in `chat.rb`, runtime info block injection,
268
318
  and display via `information.rb`; added `prompts/runtime_info` template and
269
319
  `languages:` array; added `runtime_info.toggle`, `runtime_info.show`,
270
- `runtime_info.on?`, `runtime_info.enabled` support.
320
+ `runtime_info.on?`, `runtime_info.enabled` support.
271
321
  - Updated `OllamaChat::Tools::DirectoryStructure` description to note it can
272
- locate one or multiple files, referencing `max_depth`.
322
+ locate one or multiple files, referencing `max_depth`.
273
323
  - Clarified usage of `browse`, `copy_to_clipboard`, `open_file_in_editor`,
274
324
  `insert_into_editor` tools in documentation strings; fixed double‑negative
275
- typo in `insert_into_editor.rb`.
325
+ typo in `insert_into_editor.rb`.
276
326
  - Renamed `import_url` tool to `get_url`: updated config key, tool
277
327
  registration, class name `OllamaChat::Tools::GetURL`, spec file names, method
278
328
  calls to `config.tools.functions.get_url.schemes?`, replaced all
279
- `chat.import` with `OllamaChat::Utils::Fetcher.get`.
329
+ `chat.import` with `OllamaChat::Utils::Fetcher.get`.
280
330
  - Added path validation and error handling to `OllamaChat::Tools::RunTests`:
281
331
  new private method `check_path(path)` prevents using `"./"` and validates
282
332
  existence; wrapped execution in rescue block returning JSON with `error:` and
283
- `message:`; updated function description accordingly.
284
- - Refined and unified tool descriptions with consistent punctuation.
333
+ `message:`; updated function description accordingly.
334
+ - Refined and unified tool descriptions with consistent punctuation.
285
335
  - Added explicit persona loading verification when editing: confirmation step
286
- before applying edited personality configurations.
336
+ before applying edited personality configurations.
287
337
  - Improved persona loading and prompt formatting: updated
288
338
  `setup_persona_from_opts`, `info_persona`, `load_persona_file` to return
289
339
  `[pathname, content]`, added newline in `play_persona_prompt`, adjusted
data/Rakefile CHANGED
@@ -41,7 +41,7 @@ GemHadar do
41
41
  )
42
42
 
43
43
  dependency 'excon', '~> 1.0'
44
- dependency 'ollama-ruby', '~> 1.18'
44
+ dependency 'ollama-ruby', '~> 1.21'
45
45
  dependency 'documentrix', '>= 0.0.4'
46
46
  dependency 'unix_socks', '~> 0.3'
47
47
  dependency 'rss', '~> 0.3'
@@ -49,7 +49,7 @@ GemHadar do
49
49
  dependency 'redis', '~> 5.0'
50
50
  dependency 'mime-types', '~> 3.0'
51
51
  dependency 'reverse_markdown', '~> 3.0'
52
- dependency 'kramdown-ansi', '~> 0.3'
52
+ dependency 'kramdown-ansi', '~> 0.5'
53
53
  dependency 'complex_config', '~> 0.22', '>= 0.22.2'
54
54
  dependency 'tins', '~> 1.52'
55
55
  dependency 'search_ui', '~> 0.1'
@@ -33,6 +33,7 @@ require 'context_spook'
33
33
  class OllamaChat::Chat
34
34
  include Tins::GO
35
35
  include Term::ANSIColor
36
+ include OllamaChat::HTTPHandling
36
37
  include OllamaChat::CommandConcern
37
38
  include OllamaChat::Logging
38
39
  include OllamaChat::DocumentCache
@@ -157,6 +158,11 @@ class OllamaChat::Chat
157
158
  # messages associated with this instance
158
159
  attr_reader :messages
159
160
 
161
+ # Provides read-only access to the cache instance used by the object
162
+ #
163
+ # @attr_reader [Cache] the cache instance
164
+ attr_reader :cache
165
+
160
166
  # The start method initializes the chat session by displaying information,
161
167
  # then prompts the user for input to begin interacting with the chat.
162
168
  def start
@@ -486,7 +492,7 @@ class OllamaChat::Chat
486
492
  STDOUT.puts "Exiting chooser."
487
493
  break
488
494
  when '[ALL]'
489
- if confirm?(prompt: 'Are you sure? (y/n) ') =~ /y/i
495
+ if confirm?(prompt: '🔔 Are you sure? (y/n) ') =~ /y/i
490
496
  @documents.clear
491
497
  STDOUT.puts "Cleared collection #{bold{@documents.collection}}."
492
498
  break
@@ -531,7 +537,7 @@ class OllamaChat::Chat
531
537
  end
532
538
  when 'edit'
533
539
  if result = edit_persona and
534
- confirm?(prompt: 'Load new persona profile? (y/n) ') =~ /y/i
540
+ confirm?(prompt: '🔔 Load new persona profile? (y/n) ') =~ /y/i
535
541
  then
536
542
  result
537
543
  else
@@ -862,7 +868,7 @@ class OllamaChat::Chat
862
868
  STDOUT.puts "Exiting chooser."
863
869
  break
864
870
  when '[ALL]'
865
- if confirm?(prompt: 'Are you sure? (y/n) ') =~ /y/i
871
+ if confirm?(prompt: '🔔 Are you sure? (y/n) ') =~ /y/i
866
872
  links.clear
867
873
  STDOUT.puts "Cleared all links in list."
868
874
  break
@@ -910,7 +916,7 @@ class OllamaChat::Chat
910
916
  @documents.clear
911
917
  STDOUT.puts "Cleared all tags."
912
918
  when 'all'
913
- if confirm?(prompt: 'Are you sure to clear messages and collection? (y/n) ') =~ /y/i
919
+ if confirm?(prompt: '🔔 Are you sure to clear messages and collection? (y/n) ') =~ /y/i
914
920
  messages.clear
915
921
  @documents.clear
916
922
  links.clear
@@ -1248,8 +1254,14 @@ class OllamaChat::Chat
1248
1254
  old = Reline.completion_proc
1249
1255
  Reline.autocompletion = true
1250
1256
  Reline.completion_proc = -> input, pre {
1251
- start = [ pre, input ].join(' ').strip.gsub(/\s+/, ' ')
1252
- command_completions.select { _1.start_with?(start) }
1257
+ before = [ pre, input ].join
1258
+ case before
1259
+ when %r(^/)
1260
+ start = [ pre, input ].join(' ').strip.gsub(/\s+/, ' ')
1261
+ command_completions.select { _1.start_with?(start) }
1262
+ when %r((./\S*))
1263
+ OllamaChat::Utils::PathCompleter.new(pre, input).complete
1264
+ end
1253
1265
  }
1254
1266
  block.()
1255
1267
  ensure
@@ -58,7 +58,7 @@ module OllamaChat::ConfigHandling
58
58
  unless diff_tool = OC::DIFF_TOOL?
59
59
  exit 1
60
60
  end
61
- if confirm?(prompt: 'Do you want to fix the config? (y/n) ') =~ /y/i
61
+ if confirm?(prompt: '🔔 Do you want to fix the config? (y/n) ') =~ /y/i
62
62
  system Shellwords.join([
63
63
  diff_tool,
64
64
  @ollama_chat_config.filename,
@@ -84,7 +84,7 @@ module OllamaChat::ConfigHandling
84
84
  # `ollama_chat` if desired.
85
85
  def edit_config
86
86
  if result = edit_file(@ollama_chat_config.filename)
87
- if confirm?(prompt: "Do you want to restart #{progname}? (y/n) ") =~ /y/i
87
+ if confirm?(prompt: "🔔 Do you want to restart #{progname}? (y/n) ") =~ /y/i
88
88
  save_conversation(OC::XDG_CACHE_HOME + 'backup.json')
89
89
  save_history
90
90
  exec($0, *ARGV)
@@ -101,7 +101,7 @@ module OllamaChat::ConfigHandling
101
101
  # @example Restarting the app after confirmation
102
102
  # config.reload_config # => restarts if user answers "y"
103
103
  def reload_config
104
- if confirm?(prompt: "Do you want to restart #{progname}? (y/n) ") =~ /y/i
104
+ if confirm?(prompt: "🔔 Do you want to restart #{progname}? (y/n) ") =~ /y/i
105
105
  save_conversation(OC::XDG_CACHE_HOME + 'backup.json')
106
106
  save_history
107
107
  exec($0, *ARGV)
@@ -27,7 +27,7 @@ module OllamaChat::Conversation
27
27
  # chat.save_conversation('conversations/2023-10-15_my_session.json')
28
28
  def save_conversation(filename)
29
29
  File.exist?(filename) &&
30
- confirm?(prompt: "File #{filename.to_s.inspect} already exists, overwrite? (y/n) ") !~ /y/i and
30
+ confirm?(prompt: "🔔 File #{filename.to_s.inspect} already exists, overwrite? (y/n) ") !~ /y/i and
31
31
  return
32
32
  if messages.save_conversation(filename)
33
33
  STDOUT.puts "Saved conversation to #{filename.to_s.inspect}."
@@ -84,7 +84,7 @@ module OllamaChat::Dialog
84
84
  collection = OllamaChat::Utils::Chooser.choose(collections) || current_collection
85
85
  case collection
86
86
  when '[NEW]'
87
- @documents.collection = ask?(prompt: "Enter name of the new collection: ")
87
+ @documents.collection = ask?(prompt: "Enter name of the new collection: ")
88
88
  when nil, '[EXIT]'
89
89
  STDOUT.puts "Exiting chooser."
90
90
  when /./
@@ -122,7 +122,7 @@ module OllamaChat::Dialog
122
122
  system =
123
123
  case chosen
124
124
  when '[NEW]'
125
- ask?(prompt: "Enter new system prompt to use: ")
125
+ ask?(prompt: "Enter new system prompt to use: ")
126
126
  when '[EXIT]'
127
127
  STDOUT.puts "Exiting chooser."
128
128
  return
@@ -123,7 +123,7 @@ class OllamaChat::FollowChat
123
123
  function = JSON.pretty_generate(tool_call.function)
124
124
  @chat.log(:info, function)
125
125
  if @chat.tool_function(name).require_confirmation?
126
- prompt = "I want to execute tool %s\n%s\nConfirm? (y/n) " % [
126
+ prompt = "🔔 I want to execute tool %s\n%s\nConfirm? (y/n) " % [
127
127
  bold { name },
128
128
  italic { function },
129
129
  ]
@@ -138,6 +138,7 @@ class OllamaChat::FollowChat
138
138
  italic { function },
139
139
  ]
140
140
  end
141
+ start = Time.now
141
142
  result = nil
142
143
  case confirmed
143
144
  when :denied
@@ -155,7 +156,7 @@ class OllamaChat::FollowChat
155
156
  "\n%s Execution of tool %s confirmed.\n\n", symbol, bold { name }
156
157
  )
157
158
  result = OllamaChat::Tools.registered[name].
158
- execute(tool_call, chat: @chat, config: @chat.config)
159
+ execute(tool_call, chat: @chat)
159
160
  if confirmed == :explicit
160
161
  @chat.log(:info, "Execution of tool %s was explicitly confirmed." % name)
161
162
  else
@@ -169,14 +170,17 @@ class OllamaChat::FollowChat
169
170
  @chat.log(:info, result)
170
171
  end
171
172
  @chat.tool_call_results[name] = result
172
- tools_used[name] = Tins::Unit.format(result.to_s.size, unit: ?B, prefix: 1024, format: '%.1f %U')
173
+ tools_used[name] = {
174
+ 'size' => Tins::Unit.format(result.to_s.size, unit: ?B, prefix: 1024, format: '%.1f %U'),
175
+ 'duration' => Tins::Duration.new(Time.now - start).to_s,
176
+ }
173
177
  end
174
178
 
175
179
  if tools_used.full?
176
180
  infobar.reset
177
181
  puts "🔧 Tool functions returned result:",
178
182
  tools_used.to_yaml.sub(/\A---\s*\n/, '').gsub(/^/, ' '), ""
179
- @chat.confirm?(prompt: 'Press any key to continue.')
183
+ @chat.confirm?(prompt: 'Press any key to continue. ')
180
184
  end
181
185
  end
182
186