ollama_chat 0.0.93 → 0.0.95

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +117 -42
  3. data/LICENSE +21 -0
  4. data/README.md +10 -6
  5. data/lib/ollama_chat/chat.rb +1 -0
  6. data/lib/ollama_chat/commands.rb +156 -38
  7. data/lib/ollama_chat/information.rb +0 -4
  8. data/lib/ollama_chat/input_content.rb +1 -1
  9. data/lib/ollama_chat/oc.rb +0 -7
  10. data/lib/ollama_chat/ollama_chat_config/default_config.yml +1 -1
  11. data/lib/ollama_chat/parsing.rb +50 -21
  12. data/lib/ollama_chat/personae_management.rb +4 -4
  13. data/lib/ollama_chat/rag_handling.rb +2 -2
  14. data/lib/ollama_chat/session_management.rb +1 -3
  15. data/lib/ollama_chat/state_selectors.rb +1 -1
  16. data/lib/ollama_chat/tool_calling.rb +2 -2
  17. data/lib/ollama_chat/tools/compute_bmi.rb +0 -2
  18. data/lib/ollama_chat/tools/roll_dice.rb +10 -1
  19. data/lib/ollama_chat/utils/chooser.rb +2 -2
  20. data/lib/ollama_chat/utils/png_metadata_extractor.rb +111 -0
  21. data/lib/ollama_chat/utils/utf8_converter.rb +13 -0
  22. data/lib/ollama_chat/utils.rb +2 -1
  23. data/lib/ollama_chat/version.rb +1 -1
  24. data/lib/ollama_chat/web_searching.rb +4 -1
  25. data/ollama_chat.gemspec +5 -5
  26. data/spec/assets/miyu.png +0 -0
  27. data/spec/ollama_chat/parsing_spec.rb +1 -1
  28. data/spec/ollama_chat/state_selectors_spec.rb +1 -1
  29. data/spec/ollama_chat/tool_calling_spec.rb +202 -0
  30. data/spec/ollama_chat/tools/directory_structure_spec.rb +1 -1
  31. data/spec/ollama_chat/tools/roll_dice_spec.rb +6 -1
  32. data/spec/ollama_chat/utils/png_metadata_extractor_spec.rb +122 -0
  33. metadata +11 -5
  34. data/lib/ollama_chat/utils/png_character_extractor.rb +0 -65
  35. data/spec/ollama_chat/utils/png_character_extractor_spec.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62fe4c92342045e9f11d60bd00e7772b8fee264c5c6736e967ce9fc8f09307c5
4
- data.tar.gz: 07761b8ba1abdb1af75a9611e1191d9456e986d2af36304e7bf3b3c3a1840c58
3
+ metadata.gz: a5ae8b473c0dfaba1476f7890f8d1e04244db7f19c9dd9d563a845d9a5798a5f
4
+ data.tar.gz: 6e0f053ce8c5f9bbe97d5e04d3819fbee2ef9857f6b4c9d6bc4d76fe7e12dffa
5
5
  SHA512:
6
- metadata.gz: 88cf61861b63250453b049b33fc3d0db341f73512be7a7f12d054259f9f530d7752850141a2a89d9050199cf78b4e4b531bf01f5cc072e53a790efbdf0d187cf
7
- data.tar.gz: ad0a856f65ce7696bf2479ef544e3e7ceac757087e4b139152a8c3d13f5ece9b44ee503fa689005976cdc0f12a76ea2d3cf6aa43dbfd3a9e39f5830ec18f0d07
6
+ metadata.gz: 9e514fe65a9e3ccddef894cfe92fdff0e17a1c9ca639994ab54edcd573b219cca6c50774640cd966e8adc4d3232071abacc193c8dd795f9ed6be6460109b62df
7
+ data.tar.gz: 681c439ba46ee38cce5201696e40dda4dc6f6d2291c505e420c7fa2d63899ffd0e82068e94c6f8509f170e6843480924c969730c328a3c6a92b00702115de994
data/CHANGES.md CHANGED
@@ -1,5 +1,80 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-06-29 v0.0.95
4
+
5
+ ### New Features & Enhancements
6
+
7
+ - **PNG Metadata Extraction**:
8
+ - Implemented `OllamaChat::Utils::PNGMetadataExtractor` to support
9
+ extraction of characters, prompts, and workflows from `tEXt` chunks.
10
+ - Added support for Automatic1111 Stable Diffusion WebUI parameters via
11
+ `parse_a1111_parameters`.
12
+ - Consolidated metadata extraction logic into a new `parse_png` method
13
+ within `OllamaChat::Parsing`.
14
+ - Introduced `OllamaChat::Utils::UTF8Converter` to ensure safe UTF-8
15
+ encoding across the system.
16
+ - **Tool Improvements**:
17
+ - Enhanced the `roll_dice` tool by adding a human-readable `message` field
18
+ to its JSON output and increasing the `result_display_timeout` in
19
+ `default_config.yml`.
20
+ - **Command Interface**:
21
+ - Overhauled help texts for numerous commands (including `/model`,
22
+ `/system`, `/tools`, `/session`, `/prompt`, and `/persona`) using
23
+ squiggly heredocs for better formatting and clarity.
24
+ - Added comprehensive YARD documentation to the `OllamaChat::Commands`
25
+ module.
26
+
27
+ ### Bug Fixes & Refactoring
28
+
29
+ - **Stability & Logic**:
30
+ - Updated `OllamaChat::InputContent#all_file_set` to filter out directories
31
+ using `.select(&:file?)` and return a `Set`.
32
+ - Improved session name validation in
33
+ `lib/ollama_chat/session_management.rb` by replacing `.nil?` with
34
+ `.blank?`.
35
+ - Added `io.rewind` within an `ensure` block in the PNG extraction logic to
36
+ prevent read errors.
37
+ - **Cleanup**:
38
+ - Removed the unused `json` dependency from `compute_bmi`.
39
+ - Removed the `PATCH_TOOL` definition and its corresponding documentation
40
+ in `README.md`.
41
+ - Pruned redundant convenience methods `extract_prompt` and
42
+ `extract_workflow` from `OllamaChat::Utils::PNGMetadataExtractor`.
43
+
44
+ ### Documentation & CI
45
+
46
+ - **README Updates**:
47
+ - Expanded the available tools table to include `delete_file`, `move_file`,
48
+ `eval_ruby`, `get_ghr`, and `get_jira_issue`.
49
+ - Refined descriptions for the **Knowledge** category, specifically
50
+ distinguishing between `retrieve_document_snippets` and `file_context`.
51
+ - **CI/CD**:
52
+ - Optimized dependency installation in `.all_images.yml` by replacing
53
+ `getconf _NPROCESSORS_ONLN` with `nproc` for better parallel job
54
+ compatibility.
55
+
56
+ ## 2026-06-22 v0.0.94
57
+
58
+ ### Added
59
+
60
+ - Created a `LICENSE` file and updated the `README.md` to include a link to the
61
+ MIT license.
62
+ - Added comprehensive test coverage for tool calling in
63
+ `spec/ollama_chat/tool_calling_spec.rb`.
64
+
65
+ ### Changed
66
+
67
+ - Improved tool calling logic by utilizing the `tools_support` reader and
68
+ ensuring allowed paths are indexed by string keys via `.to_s`.
69
+ - Synchronized search feedback prompts across
70
+ `lib/ollama_chat/web_searching.rb`, `lib/ollama_chat/rag_handling.rb`, and
71
+ `lib/ollama_chat/state_selectors.rb` using the `%s` format specifier.
72
+ - Updated usage examples in `lib/ollama_chat/utils/chooser.rb` to include the
73
+ `%s` specifier.
74
+ - Updated prompt expectations in `spec/ollama_chat/state_selectors_spec.rb`.
75
+ - Added `LICENSE` and `spec/ollama_chat/tool_calling_spec.rb` to the gem
76
+ specification files.
77
+
3
78
  ## 2026-06-21 v0.0.93
4
79
 
5
80
  ### Added
@@ -88,7 +163,7 @@
88
163
 
89
164
  - **Model Option Profiles**: Added support for model option profiles, including
90
165
  a new `profile` column in the database with a composite unique index on
91
- `[:model_name, :profile]`.
166
+ `[:model_name, :profile]`.
92
167
  - Enhanced `OllamaChat::ModelHandling` methods (`get_stored_model_options`,
93
168
  `store_model_options`) to support a `profile` parameter.
94
169
  - Implemented `choose_profile_for_model` for interactive profile selection.
@@ -104,20 +179,20 @@
104
179
 
105
180
  ### Enhancements & Refactoring
106
181
 
107
- - **Command Standardization**:
182
+ - **Command Standardization**:
108
183
  - Standardized the use of the `-e` flag for editing across multiple
109
184
  commands: `/input`, `/regenerate`, `/pipe`, `/output`, `/copy`, and
110
185
  `/paste`.
111
186
  - Replaced "Flags:" with "Options:" in help text for several chat commands.
112
187
  - Added a specific editor hook using `edit_text` for the `/input` command
113
188
  to allow editing imported content.
114
- - **Code Architecture**:
189
+ - **Code Architecture**:
115
190
  - Extracted all chat command definitions into a new separate module
116
191
  `OllamaChat::Commands` located in `lib/ollama_chat/commands.rb`.
117
192
  - Updated `OllamaChat::Chat` and the main library entry point to utilize
118
193
  this new module instead of inline definitions or
119
194
  `OllamaChat::CommandConcern`.
120
- - **Message Output**:
195
+ - **Message Output**:
121
196
  - Enhanced `OllamaChat::MessageOutput#pipe` and `#output` to accept an
122
197
  `edit` parameter.
123
198
  - Refactored `OllamaChat::MessageOutput#attempt_to_write_file` to receive
@@ -260,42 +335,42 @@
260
335
  ## 2026-04-02 v0.0.86
261
336
 
262
337
  - Updated `play_persona_prompt` in `lib/ollama_chat/personae_management.rb` to
263
- include “(no need to read the file)” in the roleplay prompt template string.
264
- - Added `optional: true` to the `/links` command in `lib/ollama_chat/chat.rb`.
338
+ include “(no need to read the file)” in the roleplay prompt template string.
339
+ - Added `optional: true` to the `/links` command in `lib/ollama_chat/chat.rb`.
265
340
  - Made the `edit` subcommand of `/revise` optional by adding `optional: true`
266
- to its command definition in `lib/ollama_chat/chat.rb`.
267
- - Added a `backup` subcommand for persona management:
341
+ to its command definition in `lib/ollama_chat/chat.rb`.
342
+ - Added a `backup` subcommand for persona management:
268
343
  - Updated the `:persona` command regex and completion options in
269
- `lib/ollama_chat/chat.rb`.
270
- - Added a case handler to invoke the new `backup_persona` method.
344
+ `lib/ollama_chat/chat.rb`.
345
+ - Added a case handler to invoke the new `backup_persona` method.
271
346
  - Implemented `backup_persona` in `lib/ollama_chat/personae_management.rb`
272
- with YARD documentation.
273
- - Removed the redundant assignment `persona = persona` in `edit_persona`.
347
+ with YARD documentation.
348
+ - Removed the redundant assignment `persona = persona` in `edit_persona`.
274
349
  - Fixed the rescue exception class name in the `use_model` block of
275
350
  `lib/ollama_chat/chat.rb`, changing from `OllamaChatError::UnknownModelError`
276
- to `OllamaChat::UnknownModelError`.
351
+ to `OllamaChat::UnknownModelError`.
277
352
  - Ensured float division for duration calculations in `FollowChat` by
278
353
  converting operands to float in the `eval_stats` method of
279
- `lib/ollama_chat/follow_chat.rb`.
354
+ `lib/ollama_chat/follow_chat.rb`.
280
355
  - Used `Pathname.new(file).expand_path.directory?` for tilde expansion in
281
- directory checks in `lib/ollama_chat/parsing.rb`.
282
- - Refactored command registration formatting in `lib/ollama_chat/chat.rb`.
356
+ directory checks in `lib/ollama_chat/parsing.rb`.
357
+ - Refactored command registration formatting in `lib/ollama_chat/chat.rb`.
283
358
  - Added YARD documentation to the `OllamaChat::CommandConcern::Command` class
284
- in `lib/ollama_chat/command_concern.rb`.
359
+ in `lib/ollama_chat/command_concern.rb`.
285
360
  - Removed the deprecated `-d` flag from the `/input` command in
286
- `lib/ollama_chat/chat.rb`.
287
- - Removed tag support from `parse_content`:
361
+ `lib/ollama_chat/chat.rb`.
362
+ - Removed tag support from `parse_content`:
288
363
  - Updated `OllamaChat::Chat` to call `parse_content` without expecting a
289
- `tags` array.
290
- - Simplified handling of `@parse_content`.
291
- - Removed tag recognition logic from `OllamaChat::Parsing`.
292
- - Changed `parse_content` to return a single `String`.
293
- - Deleted tag‑specific example from the spec.
294
- - Updated the `file_context` tool description for accuracy.
295
- - Added an interactive loop to enable/disable tools:
364
+ `tags` array.
365
+ - Simplified handling of `@parse_content`.
366
+ - Removed tag recognition logic from `OllamaChat::Parsing`.
367
+ - Changed `parse_content` to return a single `String`.
368
+ - Deleted tag‑specific example from the spec.
369
+ - Updated the `file_context` tool description for accuracy.
370
+ - Added an interactive loop to enable/disable tools:
296
371
  - Wrapped `enable_tool` and `disable_tool` in a `loop do` in
297
- `lib/ollama_chat/tool_calling.rb`.
298
- - Modified `select_tools` to place `[EXIT]` at the start.
372
+ `lib/ollama_chat/tool_calling.rb`.
373
+ - Modified `select_tools` to place `[EXIT]` at the start.
299
374
  - Handled user choice with `choose(select_tools)`
300
375
  and exited on `[EXIT]` or `nil`.
301
376
 
@@ -326,24 +401,24 @@
326
401
  ## 2026-03-26 v0.0.84
327
402
 
328
403
  - Added `OllamaChat::Utils::ValueFormatter` with helper `format_bytes` in
329
- `lib/ollama_chat/utils/value_formatter.rb`.
330
- - Added `require 'ollama_chat/utils/value_formatter'` where needed.
404
+ `lib/ollama_chat/utils/value_formatter.rb`.
405
+ - Added `require 'ollama_chat/utils/value_formatter'` where needed.
331
406
  - Updated `write_file`, `patch_file`, `paste_from_clipboard` to use
332
- `format_bytes` for byte‑size messages.
407
+ `format_bytes` for byte‑size messages.
333
408
  - Implemented new tool `RetrieveDocumentSnippets` in
334
409
  `lib/ollama_chat/tools/retrieve_document_snippets.rb` and its spec
335
- `spec/ollama_chat/tools/retrieve_document_snippets_spec.rb`.
410
+ `spec/ollama_chat/tools/retrieve_document_snippets_spec.rb`.
336
411
  - Updated `default_config.yml` to enable `retrieve_document_snippets` by
337
- default.
412
+ default.
338
413
  - Rewrote tool payloads to include a `message` key for `browse`, `search_web`,
339
- `paste_from_clipboard`, `resolve_tag`, and others.
340
- - `browse` now returns `"Opened \"<url>\" in browser."` or a failure message.
414
+ `paste_from_clipboard`, `resolve_tag`, and others.
415
+ - `browse` now returns `"Opened \"<url>\" in browser."` or a failure message.
341
416
  - Refactored `confirm?` in `lib/ollama_chat/dialog.rb` to accept keyword `yes:`
342
417
  for a confirmation regex and display a coloured emoji matching the response
343
- or timeout/default.
344
- - Updated all calls to `confirm?` to use `yes: /\Ay/i` syntax.
418
+ or timeout/default.
419
+ - Updated all calls to `confirm?` to use `yes: /\Ay/i` syntax.
345
420
  - Updated `lib/ollama_chat/message_output.rb` to add `yes:` keyword to
346
- `confirm?` calls and refine the emoji shown when a file already exists.
421
+ `confirm?` calls and refine the emoji shown when a file already exists.
347
422
 
348
423
  ## 2026-03-24 v0.0.83
349
424
 
@@ -365,13 +440,13 @@
365
440
  ## 2026-03-21 v0.0.82
366
441
 
367
442
  - Add a `before` block setting `OC::OLLAMA::CHAT::TOOLS::CTAGS_TOOL` to `ctags`
368
- in the `resolve_tag` spec.
443
+ in the `resolve_tag` spec.
369
444
  - Updated `OllamaChat::Tools::PasteIntoEditor` description to use `text`
370
445
  instead of `string` and clarified that no file or line is required when
371
- pasting into the editor.
446
+ pasting into the editor.
372
447
  - Added bell and question mark emojis to various `confirm?` and `ask?` prompts
373
- across multiple modules for clearer UX.
374
- - Updated prompt string to `⏎ Press …` for better display.
448
+ across multiple modules for clearer UX.
449
+ - Updated prompt string to `⏎ Press …` for better display.
375
450
  - Enhanced `OllamaChat::Tools::ResolveTag` and `OllamaChat::Utils::TagResolver`
376
451
  with a new `kinds` method, updated `kind` parameter description, refactored
377
452
  `kind_of`, and fixed tag‑parsing regex to capture all columns.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Florian Frank
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -42,7 +42,6 @@ The following environment variables can be used to configure behavior:
42
42
  - `OLLAMA_CHAT_TOOLS_TEST_RUNNER` - Configured test runner for `run_tests` (default: `rspec`)
43
43
  - `OLLAMA_CHAT_TOOLS_CTAGS_TOOL` - Path to the ctags tool
44
44
  - `OLLAMA_CHAT_TOOLS_TAGS_FILE` - Location of the tags file
45
- - `OLLAMA_CHAT_TOOLS_PATCH_TOOL` - Patch tool to use
46
45
  - `OLLAMA_CHAT_TOOLS_JIRA_URL` - Base URL for Jira instance
47
46
  - `OLLAMA_CHAT_TOOLS_JIRA_USER` - Username for Jira authentication
48
47
  - `OLLAMA_CHAT_TOOLS_JIRA_API_TOKEN` - API token for Jira authentication
@@ -253,14 +252,19 @@ context, manipulate files, and retrieve external information.
253
252
 
254
253
  | Category | Tools | Description |
255
254
  | :--- | :--- | :--- |
256
- | **Filesystem** | `read_file`, `write_file`, `patch_file`, `directory_structure`, `execute_grep` | Read, write, and search files within allowed directories. |
257
- | **Ruby/Dev** | `resolve_tag`, `execute_ri`, `gem_path_lookup`, `run_tests` | Introspect Ruby code, check documentation, and run test suites. |
258
- | **Web/External** | `search_web`, `get_url`, `browse`, `get_rfc`, `get_cve`, `get_endoflife` | Access the internet, fetch specific URLs, and look up technical standards. |
255
+ | **Filesystem** | `read_file`, `write_file`, `patch_file`, `delete_file`, `move_file`, `directory_structure`, `execute_grep` | Read, write, and search files within allowed directories. |
256
+ | **Ruby/Dev** | `resolve_tag`, `execute_ri`, `gem_path_lookup`, `run_tests`, `eval_ruby` | Introspect Ruby code, check documentation, and run test suites. |
257
+ | **Web/External** | `search_web`, `get_url`, `browse`, `get_rfc`, `get_cve`, `get_endoflife`, `get_ghr`, `get_jira_issue` | Access the internet, fetch specific URLs, and look up technical standards. |
259
258
  | **System/Util** | `get_time`, `get_location`, `get_current_weather`, `generate_password`, `compute_bmi`, `roll_dice` | General utility functions for time, location, and simple calculations. |
260
259
  | **Editor/Clip** | `copy_to_clipboard`, `paste_from_clipboard`, `paste_into_editor`, `open_file_in_editor` | Bridge the gap between the chat and the system clipboard or editor. |
261
- | **Knowledge** | `retrieve_document_snippets` | Search through project-specific documentation collections. |
260
+ | **Knowledge** | `retrieve_document_snippets`, `file_context` | Semantic search for specific snippets vs. broad retrieval of structured project context. |
262
261
  | **Multimodal** | `generate_image` | Generate images via a local ComfyUI server. |
263
262
 
263
+ ***Note on Knowledge Tools**: Use `retrieve_document_snippets` for precise,
264
+ low-token semantic discovery and `file_context` for a comprehensive view of
265
+ modules or patterns. Be cautious with broad patterns in `file_context`, as
266
+ importing too many files can exceed the LLM's context window.*
267
+
264
268
  ## Download
265
269
 
266
270
  The homepage of this app is located at
@@ -273,4 +277,4 @@ The homepage of this app is located at
273
277
 
274
278
  ## License
275
279
 
276
- This software is licensed under the <i>MIT</i> license.
280
+ This software is licensed under the [MIT License](./LICENSE).
@@ -69,6 +69,7 @@ class OllamaChat::Chat
69
69
  include OllamaChat::PromptManagement
70
70
  include OllamaChat::Utils::Chooser
71
71
  include OllamaChat::Utils::ValueFormatter
72
+ include OllamaChat::Utils::UTF8Converter
72
73
 
73
74
  # Initializes a new OllamaChat::Chat instance with the given command-line
74
75
  # arguments.
@@ -1,5 +1,24 @@
1
1
  require 'ollama_chat/command_concern'
2
2
 
3
+ # Namespace for all available slash commands within the Ollama Chat
4
+ # application.
5
+ #
6
+ # This module acts as a central repository where various functional commands
7
+ # are declared using the DSL provided by {OllamaChat::CommandConcern}. Each
8
+ # command definition includes a unique name, a triggering regular expression,
9
+ # and a help string for documentation.
10
+ #
11
+ # The commands are categorized into several areas:
12
+ # - Clipboard management (/copy, /paste)
13
+ # - Application settings (/config, /document policy, /toggle)
14
+ # - Model & System Prompt configuration (/model, /system, /think)
15
+ # - Tooling support (/tools)
16
+ # - Session management (/session)
17
+ # - Conversation history and manipulation (/list, /last, /drop, /clear, /regenerate)
18
+ # - RAG collection management (/collection)
19
+ # - Persona & Character roleplay (/persona, /character)
20
+ # - Input/Output operations (/compose, /web, /input, /pipe, /vim, /output)
21
+ # - System actions and info (/reconnect, /quit, /info, /help)
3
22
  module OllamaChat::Commands
4
23
  include OllamaChat::CommandConcern
5
24
 
@@ -65,7 +84,11 @@ module OllamaChat::Commands
65
84
  name: :toggle,
66
85
  regexp: %r(^/toggle(?:\s+(markdown|stream|location|runtime_info|voice|think_loud|think_strip))?$),
67
86
  complete: [ 'toggle', %w[ markdown stream location runtime_info voice think_loud think_strip embedding ] ],
68
- help: 'Toggle feature switches (markdown, stream, location, runtime_info, voice, think_loud, think_strip, embedding)'
87
+ help: <<~EOT
88
+ Toggle feature switches
89
+ (markdown, stream, location, runtime_info,
90
+ voice, think_loud, think_strip, embedding)
91
+ EOT
69
92
  ) do |toggle_name|
70
93
  if toggle_name
71
94
  send(toggle_name).toggle
@@ -90,7 +113,10 @@ module OllamaChat::Commands
90
113
  name: :favourite,
91
114
  regexp: %r(^/favourite(?:\s+(add|delete))?(?:\s+(model|prompt|system_prompt|persona))$),
92
115
  complete: [ 'favourite', %w[ add delete ], %w[ model prompt system_prompt persona ] ],
93
- help: 'Manage favorites for models, prompts, and personas (add, delete)'
116
+ help: <<~EOT
117
+ Manage favorites for models, prompts,
118
+ and personae (add, delete)
119
+ EOT
94
120
  ) do |subcommand, type|
95
121
  case subcommand
96
122
  when 'add'
@@ -106,8 +132,18 @@ module OllamaChat::Commands
106
132
  regexp: %r(^/model(?:\s+(change|options|options from session|options to session))(?:\s+(-p\s*\w+))?$),
107
133
  complete: [ 'model', %w[ change options options\ from\ session options\ to\ session ] ],
108
134
  help: <<~EOT
109
- Change the model or manage model options (change, options, options from
110
- session, options to session)
135
+ Manage AI models and configurations:
136
+ - change: Switch the active model
137
+ (-p [profile] for specific
138
+ settings)
139
+ - options: Edit the configuration
140
+ of a saved profile
141
+ - options from session: Save current
142
+ live settings into a profile
143
+ (Live → Saved)
144
+ - options to session: Apply a saved
145
+ profile's settings to this
146
+ session (Saved → Live)
111
147
  EOT
112
148
  ) do |subcommand, opts|
113
149
  case subcommand
@@ -138,8 +174,18 @@ module OllamaChat::Commands
138
174
  complete: [ 'system', %w[ change info edit add delete list duplicate export import reset ] ],
139
175
  optional: true,
140
176
  help: <<~EOT
141
- Manage the system prompt (change, info, edit, add, delete, list, duplicate,
142
- export, import, reset)
177
+ Manage the system prompt and its
178
+ configurations.
179
+ Subcommands: add, change, delete,
180
+ duplicate, edit, export, import,
181
+ info, list, reset.
182
+ Note: 'duplicate' allows you to clone
183
+ an existing system prompt as a
184
+ template for further modification,
185
+ while 'export' and 'import' handle
186
+ portability via external files. Use
187
+ 'reset' to restore the default
188
+ system prompt settings.
143
189
  EOT
144
190
  ) do |subcommand, filename|
145
191
  case subcommand
@@ -193,7 +239,14 @@ module OllamaChat::Commands
193
239
  regexp: %r(^/tools(?:\s+(on|off|enable|disable))?),
194
240
  complete: [ 'tools', %w[ on off enable disable ] ],
195
241
  optional: true,
196
- help: 'Manage tool support and enabled tools (on, off, enable, disable)'
242
+ help: <<~EOT
243
+ Manage tool support:
244
+ - (no subcommand): List all available tools
245
+ - on: Activate tool support globally
246
+ - off: Deactivate tool support globally
247
+ - enable: Interactively enable a specific tool
248
+ - disable: Interactively disable a specific tool
249
+ EOT
197
250
  ) do |subcommand|
198
251
  case subcommand
199
252
  when nil
@@ -226,11 +279,26 @@ module OllamaChat::Commands
226
279
  regexp: %r(^/session(?:\s+(change|previous|list|new|duplicate|rename|summarize|delete|model options change|model options))?((?:\s+-(?:[sf]|p\s*\w+))*)(?:\s+(.+))?$),
227
280
  complete: [ 'session', %w[ change previous list new duplicate rename summarize delete model\ options\ change model\ options ] ],
228
281
  optional: true,
229
- options: '[-s|-f|-p profile] [name]',
282
+ options: "[-s|-f|-p profile]\n[name]",
230
283
  help: <<~EOT
231
- Manage chat sessions (change, previous, list, new, duplicate, rename, summarize,
232
- delete, model options).
233
- For summarize: -s (single sentence), -f (output to markdown file)
284
+ Manage chat sessions:
285
+ - list: List all available sessions
286
+ - new: Create a new session
287
+ - delete: Delete a session
288
+ - rename: Rename a session
289
+ - duplicate: Duplicate a session
290
+ - change [name]: Switch to a specific
291
+ session
292
+ - previous: Return to the previous
293
+ session
294
+ - summarize: Create a conversation
295
+ summary with
296
+ - -s: Output as single sentence
297
+ - -f: Save output to markdown file
298
+ - model options: Edit AI settings
299
+ for the current session
300
+ - model options change: Update session
301
+ settings from a profile
234
302
  EOT
235
303
  ) do |subcommand, opts, name|
236
304
  case subcommand
@@ -309,7 +377,9 @@ module OllamaChat::Commands
309
377
  options: '[-t|-s|n=1]',
310
378
  help: <<~EOT
311
379
  List the last n or all conversation exchanges.
312
- Options: -t (force show thinking), -s (suppress thinking).
380
+ Options:
381
+ -t (force show thinking),
382
+ -s (suppress thinking).
313
383
  EOT
314
384
  ) do |opts,number|
315
385
  opts = go_command('ts', opts.to_s)
@@ -330,9 +400,11 @@ module OllamaChat::Commands
330
400
  regexp: %r(^/last((?:\s+(?:-[pts]))*)(?:\s+(\d*))?$),
331
401
  options: '[-p|-t|-s|n=1]',
332
402
  help: <<~EOT
333
- Show the last n or the most recent system/assistant message.
334
- Options: -p (plain output, no pager), -t (force show thinking),
335
- -s (suppress thinking).
403
+ Show the last n or the most recent
404
+ system/assistant message.
405
+ Options: -p (plain output, no pager),
406
+ -t (force show thinking),
407
+ -s (suppress thinking).
336
408
  EOT
337
409
  ) do |opts,number|
338
410
  opts = go_command('pts', opts.to_s)
@@ -390,7 +462,8 @@ module OllamaChat::Commands
390
462
  regexp: %r(^/regenerate(\s+-e)?\s*$),
391
463
  help: <<~EOT
392
464
  Regenerate the last response.
393
- Options: -e to edit the user message before regenerating.
465
+ Options: -e to edit the user message
466
+ before regenerating.
394
467
  EOT
395
468
  ) do |opts|
396
469
  opts = go_command('e', opts)
@@ -412,9 +485,15 @@ module OllamaChat::Commands
412
485
  complete: [ 'prompt', %w[ edit info add delete list duplicate import export reset suggest ] ],
413
486
  optional: true,
414
487
  help: <<~EOT,
415
- Manage preset prompt templates or prefill the prompt (edit, info, add,
416
- delete, list, duplicate, import, export, reset, suggest)
417
- Options: -e to edit the next prompt instead of prefilling
488
+ Manage preset prompt templates or prefill the prompt.
489
+ Subcommands: edit, info, add, delete, list, duplicate,
490
+ import, export, reset.
491
+ Special: 'suggest' uses session history and a strategy
492
+ to AI-generate tailored prompts for you to refine, see
493
+ prompts `suggest_coding` or `suggest_roleplaying` for
494
+ predefined examples.
495
+ Options: -e to edit the next prompt
496
+ instead of prefilling
418
497
  EOT
419
498
  ) do |opts, subcommand, filename|
420
499
  case subcommand
@@ -477,7 +556,10 @@ module OllamaChat::Commands
477
556
  regexp: %r(^/conversation\s+(save|load)((?:\s+-(?:[c]))*)\s+(.+)$),
478
557
  complete: [ 'conversation', %w[ save load ] ],
479
558
  options: '[-c]',
480
- help: 'Load conversations or save conversations (-c to clean first)'
559
+ help: <<~EOT
560
+ Load conversations or
561
+ save conversations (-c to clean first)
562
+ EOT
481
563
  ) do |subcommand,opts,path|
482
564
  opts = go_command('c', opts.to_s)
483
565
  case subcommand
@@ -497,8 +579,10 @@ module OllamaChat::Commands
497
579
  complete: [ 'collection', %w[ change clear list rename update ] ],
498
580
  optional: true,
499
581
  help: <<~EOT
500
- Manage the current RAG document collection: change, clear, list,
501
- rename, update and show
582
+ Manage the current RAG document collection:
583
+ - change, clear, list, rename: Basic management
584
+ - update: Re-index only modified documents
585
+ - (no subcommand): Show current collection stats
502
586
  EOT
503
587
  ) do |subcommand|
504
588
  case subcommand
@@ -526,8 +610,23 @@ module OllamaChat::Commands
526
610
  complete: [ 'persona', %w[ play load edit info list add delete backup import export duplicate ] ],
527
611
  optional: true,
528
612
  help: <<~EOT,
529
- Manage and activate personas for roleplay (play, load, edit, info, list,
530
- add, delete, backup, import, export, duplicate)
613
+ Manage and activate personae for roleplay:
614
+ - Activation:
615
+ - play: Set the default persona
616
+ and start roleplaying
617
+ - load: Load a specific persona
618
+ into session
619
+ - Management:
620
+ - add: Create a new persona
621
+ - edit: Modify an existing persona
622
+ - delete: Remove a persona
623
+ - duplicate: Create a copy of a persona
624
+ - list: Browse all available personae
625
+ - info: View details of a specific persona
626
+ - Portability:
627
+ - backup: Save current personae to disk
628
+ - export: Export a specific persona to file
629
+ - import: Load a persona from a markdown file
531
630
  EOT
532
631
  ) do |subcommand|
533
632
  disable_content_parsing
@@ -581,7 +680,10 @@ module OllamaChat::Commands
581
680
  name: :character,
582
681
  regexp: %r(^/character(?:\s+(info|load|import))(?:\s+(\S+))?$),
583
682
  complete: [ 'character', %w[ info load import ] ],
584
- help: 'Display character info, load or import a character from JSON/PNG as persona'
683
+ help: <<~EOT
684
+ Display character info, load or import a character
685
+ from JSON/PNG as persona
686
+ EOT
585
687
  ) do |subcommand, path|
586
688
  path = if path
587
689
  Pathname.new(path)
@@ -601,7 +703,7 @@ module OllamaChat::Commands
601
703
  path.read
602
704
  when '.png'
603
705
  path.open do |io|
604
- OllamaChat::Utils::PNGCharacterExtractor.extract_character_json(io)
706
+ OllamaChat::Utils::PNGMetadataExtractor.extract_character(io)
605
707
  end
606
708
  else
607
709
  STDERR.puts "Only json and png characters are supported!"
@@ -659,17 +761,24 @@ module OllamaChat::Commands
659
761
  complete: [ 'input', %w[ path context embedding summary ] ],
660
762
  options: "[\n -w|-a|-p|-e|\n -c <collection>|\n -t <tags>\n]\n[arg…]",
661
763
  help: <<~EOT
662
- Import content from files, URLs, or globs into the context
663
- Use subcommands: path, context, embedding, summary,
664
- import (the default).
764
+ Import content from files, URLs,
765
+ or globs into the context
766
+ Use subcommands: path, context, embedding,
767
+ summary, import (the default).
665
768
  Options:
666
- -p enable pattern mode to allow using globs/wildcards)
667
- -w <words> summary subcommand only (default 100)
668
- -a pattern mode only, include all files for patterns
669
- -c <collection> use this collection (embedding subcommand only)
670
- -t <tag1,tag2,…> the custom tags to appy (embedding subcommand only)
671
- -e edit content before importing, only standard command and path with
672
- single source are supported.
769
+ -p enable pattern mode to allow
770
+ using globs/wildcards
771
+ -w <words> summary subcommand only
772
+ (default 100)
773
+ -a pattern mode only,
774
+ include all files for patterns
775
+ -c <collection> use this collection
776
+ (embedding subcommand only)
777
+ -t <tag1,tag2,…> the custom tags
778
+ to apply (embedding subcommand only)
779
+ -e edit content before importing,
780
+ only standard command and path
781
+ with single source are supported.
673
782
  EOT
674
783
  ) do |input_mode,opts,arg|
675
784
  disable_content_parsing
@@ -834,7 +943,13 @@ module OllamaChat::Commands
834
943
  regexp: %r(^/info(?:\s+(session|model|runtime|rag))?$),
835
944
  complete: [ 'info', %w[ session model runtime rag ] ],
836
945
  optional: true,
837
- help: 'Show info about the session, model, runtime, or RAG',
946
+ help: <<~EOT,
947
+ Show info:
948
+ - session: Details of the current chat session
949
+ - model: Information about the active AI model
950
+ - runtime: System and environmental data
951
+ - rag: Status of the RAG document system
952
+ EOT
838
953
  ) do |subcommand|
839
954
  use_pager do |output|
840
955
  case subcommand
@@ -858,7 +973,10 @@ module OllamaChat::Commands
858
973
  regexp: %r(^/help(?:\s+(\S+))?$),
859
974
  optional: true,
860
975
  complete: [ 'help', %w[ me ] ],
861
- help: 'View the help menu (use \'me\' for AI help or a pattern to filter)'
976
+ help: <<~EOT
977
+ View the help menu
978
+ (use 'me' for AI help or a pattern to filter)
979
+ EOT
862
980
  ) do |subcommand|
863
981
  case subcommand
864
982
  when 'me'
@@ -180,8 +180,6 @@ module OllamaChat::Information
180
180
  # ollama_chat instance.
181
181
  #
182
182
  # @param output [IO] the output stream to write the information to, defaults to STDOUT
183
- # @return [ nil ] This method does not return a value; it outputs information
184
- # directly to standard output.
185
183
  def info(output: STDOUT)
186
184
  output.puts "💎 Running ollama_chat version: #{bold{OllamaChat::VERSION}}"
187
185
  output.puts "🔌 Connected to ollama server version: #{bold{server_version}} on: #{bold{server_url}}"
@@ -205,8 +203,6 @@ module OllamaChat::Information
205
203
  #
206
204
  # @param pattern [String, Regexp, nil] An optional pattern to filter
207
205
  # the commands displayed in the help message.
208
- # @return [ nil ] This method always returns nil after printing the help
209
- # message.
210
206
  def display_chat_help(pattern = nil)
211
207
  use_pager do |output|
212
208
  output.puts help_message(pattern)
@@ -127,7 +127,7 @@ module OllamaChat::InputContent
127
127
  end
128
128
  files.merge(Pathname.glob(pattern))
129
129
  end
130
- files.map(&:expand_path)
130
+ files.map(&:expand_path).select(&:file?).to_set
131
131
  end
132
132
 
133
133
  # The provide_file_set_content method collects content from a set of files