ollama_chat 0.0.145 → 0.0.147

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +97 -0
  3. data/Gemfile +0 -2
  4. data/Rakefile +6 -4
  5. data/lib/ollama_chat/chat.rb +2 -2
  6. data/lib/ollama_chat/commands.rb +23 -22
  7. data/lib/ollama_chat/compaction.rb +2 -2
  8. data/lib/ollama_chat/conversation.rb +9 -28
  9. data/lib/ollama_chat/dialog.rb +16 -13
  10. data/lib/ollama_chat/favourites_management.rb +35 -51
  11. data/lib/ollama_chat/input_content.rb +2 -2
  12. data/lib/ollama_chat/message_list.rb +2 -0
  13. data/lib/ollama_chat/model_handling.rb +9 -11
  14. data/lib/ollama_chat/ollama_chat_config/default_config.yml +1 -0
  15. data/lib/ollama_chat/personae_management.rb +29 -17
  16. data/lib/ollama_chat/prompt_management.rb +1 -1
  17. data/lib/ollama_chat/rag_handling.rb +30 -54
  18. data/lib/ollama_chat/session_management.rb +1 -1
  19. data/lib/ollama_chat/source_fetching.rb +9 -2
  20. data/lib/ollama_chat/tool_calling.rb +36 -76
  21. data/lib/ollama_chat/tools/memorize.rb +1 -1
  22. data/lib/ollama_chat/tools/search_knowledge.rb +6 -4
  23. data/lib/ollama_chat/utils/chooser.rb +66 -1
  24. data/lib/ollama_chat/utils/fetcher.rb +4 -0
  25. data/lib/ollama_chat/utils/strip_ansi.rb +1 -1
  26. data/lib/ollama_chat/version.rb +1 -1
  27. data/lib/ollama_chat/web_searching.rb +16 -24
  28. data/lib/ollama_chat.rb +1 -0
  29. data/ollama_chat.gemspec +9 -7
  30. data/spec/ollama_chat/commands_spec.rb +11 -20
  31. data/spec/ollama_chat/conversation_spec.rb +7 -17
  32. data/spec/ollama_chat/favourites_management_spec.rb +19 -60
  33. data/spec/ollama_chat/input_content_spec.rb +7 -18
  34. data/spec/ollama_chat/model_handling_spec.rb +3 -3
  35. data/spec/ollama_chat/prompt_management_spec.rb +3 -3
  36. data/spec/ollama_chat/rag_handling_spec.rb +14 -18
  37. data/spec/ollama_chat/system_prompt_management_spec.rb +3 -3
  38. data/spec/ollama_chat/tool_calling_spec.rb +25 -64
  39. metadata +39 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e716f767311601aaacead9a9a5cddebaa97236e6a24ca5e6937431bbf421ad0
4
- data.tar.gz: e7ca2ef80988b4ed6754e75ab491c8c74ce6314e94f12e026fb31f313aa12051
3
+ metadata.gz: c88561e1d4f3443a63e9cc410b7c43893029c1f3051474d1f592051578f3b7ca
4
+ data.tar.gz: 49005ac04370d403fcd5b41ac996fa526f5b3f19c772cd820691f11504aef364
5
5
  SHA512:
6
- metadata.gz: 8514366fa439e66195e7ca0ad2e29191c0cde6624c892a194ad1313ddbafa6633bd17e14f869d290738a9a85b97ef45015d7e31b77c23493f1795718f4e5b332
7
- data.tar.gz: fd5847c16bcf409600524231d4dedc15244e88e85fc9a7d6d1e13a90bbbf32bc081b1bef649957cf1b3259023db74d3404d14fefdbb2e4e8d8576d618a532683
6
+ metadata.gz: f278a4f5559cc4fdc51f4961e8c9574ff412c7d8db03285ce1581e2fa3b55b7d53ea30156652fedf0478c88d23a0ee4840eb2a7f8e2dadd39b40102bca37d6aa
7
+ data.tar.gz: 67f9ed49399c796d11ea87b93aab73fc7a162a93584f9703259e8d8278018bb0e62d874ced85db940fb62906e1c541cbace82f7c37613ec55b83cd40fb511329
data/CHANGES.md CHANGED
@@ -1,5 +1,102 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-11-18 v0.0.147
4
+
5
+ ### Improvements
6
+
7
+ - Added `require 'json/generic_object'` in `lib/ollama_chat.rb` to ensure
8
+ `JSON::GenericObject` is loaded before API response parsing, serving as a
9
+ forward-compatibility bridge for the extraction of `JSON::GenericObject` in
10
+ `json` **3.0**.
11
+
12
+ ### Build & CI
13
+
14
+ - Bumped `ollama-ruby` dependency from `~> 1.26, >= 1.26.4` to `~> 1.27`.
15
+ - Added `json ~> 2.0` runtime dependency to pin the standard library gem to
16
+ **2.x**.
17
+ - Added `json-generic_object >= 0.2.0` runtime dependency to provide
18
+ `JSON::GenericObject` once `json` **3.0** drops it.
19
+ - Bumped `gem_hadar` development dependency to `>= 2.24.1`.
20
+
21
+ ## 2026-11-18 v0.0.146
22
+
23
+ ### Features
24
+
25
+ - Added `/restart` command to reload configuration and continue the session.
26
+ - Added `compaction.think` configuration option to control thinking mode during
27
+ context compaction; defaults to `'auto'` (delegates to `ThinkControl#think`),
28
+ with `'never'` forcing `false`.
29
+ - Introduced `choose_multi` utility for interactive multi-selection with
30
+ `[ALL]`/`[NONE]` sentinels, replacing legacy sentinel-loop pickers across the
31
+ codebase.
32
+ - Added `text` field to the `memorize` tool result to echo stored content back
33
+ to the LLM.
34
+
35
+ ### Fixes
36
+
37
+ - Fixed `NoMethodError` in `ollama-ruby` `Progress` when the server transmits
38
+ `success` before a progress bar exists (cached-model path) by bumping
39
+ dependency to **~> 1.27**.
40
+ - Resolved ghost-bar clobbering in `ollama_update` pull output by bumping
41
+ `ollama-ruby` to **1.26.3** and `infobar` to **0.16.0**.
42
+ - Ensured `infobar.finish` is called on all exit paths in `fetcher.rb`
43
+ (`fetch_url` and `fetch_streaming`) to release saved cursor positions and
44
+ render final frames.
45
+ - Cleared `infobar` after message list and last output in `message_list.rb` to
46
+ prevent ghost-bar artifacts before subsequent `output.puts` calls.
47
+ - Handled invalid UTF-8 bytes in `strip_ansi` by encoding input with `invalid:
48
+ :replace` and `undef: :replace`.
49
+ - Prevented stale history entries from surfacing during collection incineration
50
+ confirmation by clearing `Reline::HISTORY` and removing prefill.
51
+
52
+ ### Improvements
53
+
54
+ - Migrated all interactive multi-select pickers (tools, favourites, personae,
55
+ links, conversations, files, models, memory collections) to use
56
+ `choose_multi` for consistent UX and reduced code complexity.
57
+ - Replaced `⚪`/`⚫` circle icons with `☑`/`🔳` box glyphs in `load_personae`
58
+ to visually distinguish pick state from favourited markers.
59
+ - Updated favourite icons from `❤`/`🩶` to `⭐`/`⚫` for better visual
60
+ consistency.
61
+ - Silenced `infobar` during parallel embedding in `bulk_embed_sources` and
62
+ added user-visible feedback lines for sequential and parallel embed paths.
63
+ - Improved `/update all` feedback wording with bold collection names and
64
+ explicit type values.
65
+ - Delegated editorial thinking to `ThinkControl` in `compaction.rb`,
66
+ `session_management.rb`, `personae_management.rb`, and `prompt_management.rb`
67
+ to respect global `think_mode` settings.
68
+ - Added `think:` value to log data in `chat.rb` `generate` for better
69
+ observability at info level.
70
+ - Updated `SearchKnowledge` tool descriptions to guide the model toward using
71
+ natural language queries.
72
+ - Simplified `source_modified?` guard in `rag_handling.rb` by removing
73
+ redundant `infobar.puts`.
74
+
75
+ ### Build & CI
76
+
77
+ - Bumped `ollama-ruby` dependency to **~> 1.27**.
78
+ - Added `json ~> 2.0` and `json-generic_object >= 0.2.0` runtime dependencies;
79
+ `require 'json/generic_object'` in `lib/ollama_chat.rb` as a forward-compat
80
+ bridge for the json 3.0 extraction of `JSON::GenericObject`.
81
+ - Bumped `documentrix` dependency to **0.8.1** to pick up `ensure
82
+ infobar.finish` fix.
83
+ - Bumped `infobar` dependency to **0.16.0**.
84
+ - Bumped `search_ui` dependency to **0.4**.
85
+ - Bumped `gem_hadar` development dependency to **2.24.1**.
86
+ - Removed vim modeline configuration from `Gemfile`.
87
+
88
+ ### Testing
89
+
90
+ - Updated specs to stub `docs.collection` in `update_collection` tests.
91
+ - Converted mock returns in specs from sentinel strings to arrays to match new
92
+ `choose_multi` API.
93
+ - Added spec for `/restart` command.
94
+ - Updated favourite icon assertions in specs to reflect new `⭐`/`⚫` glyphs.
95
+
96
+ ### Documentation
97
+
98
+ - Updated YARD documentation context to omit `@return void` clauses.
99
+
3
100
  ## 2026-11-13 v0.0.145
4
101
 
5
102
  ### Fix
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
- # vim: set filetype=ruby et sw=2 ts=2:
2
-
3
1
  source 'https://rubygems.org'
4
2
 
5
3
  gemspec
data/Rakefile CHANGED
@@ -38,9 +38,11 @@ GemHadar do
38
38
  'static.yml' => {}
39
39
  )
40
40
 
41
+ dependency 'json', '~> 2.0'
42
+ dependency 'json-generic_object', '>= 0.2.0'
41
43
  dependency 'excon', '~> 1.0'
42
- dependency 'ollama-ruby', '~> 1.26', '>= 1.26.1'
43
- dependency 'documentrix', '>= 0.8.0'
44
+ dependency 'ollama-ruby', '~> 1.27'
45
+ dependency 'documentrix', '>= 0.8.1'
44
46
  dependency 'unix_socks', '>= 0.4'
45
47
  dependency 'rss', '~> 0.3'
46
48
  dependency 'term-ansicolor', '~> 1.11'
@@ -50,14 +52,14 @@ GemHadar do
50
52
  dependency 'kramdown-ansi', '~> 0.9'
51
53
  dependency 'complex_config', '~> 0.22', '>= 0.22.2'
52
54
  dependency 'tins', '~> 1.62'
53
- dependency 'search_ui', '>= 0.2'
55
+ dependency 'search_ui', '>= 0.4'
54
56
  dependency 'amatch', '~> 0.4'
55
57
  dependency 'pdf-reader', '~> 2.0'
56
58
  dependency 'bigdecimal', '~> 3.1'
57
59
  dependency 'csv', '~> 3.0'
58
60
  dependency 'const_conf', '~> 0.9'
59
61
  dependency 'context_spook', '~> 1.7'
60
- dependency 'infobar', '>= 0.13.1'
62
+ dependency 'infobar', '>= 0.16.0'
61
63
  dependency 'rubyzip', '~> 3.0'
62
64
  dependency 'sequel', '~> 5.0'
63
65
  dependency 'file-tail', '~> 1.4'
@@ -296,9 +296,9 @@ class OllamaChat::Chat
296
296
  )&.message&.content.to_s
297
297
 
298
298
  if content.empty?
299
- log(:warn, "LLM generation returned empty content", data: { prompt: })
299
+ log(:warn, "LLM generation returned empty content", data: { prompt:, think: })
300
300
  else
301
- log(:info, "LLM generation successful", data: { prompt:, content: })
301
+ log(:info, "LLM generation successful", data: { prompt:, content:, think: })
302
302
  end
303
303
 
304
304
  content
@@ -93,19 +93,14 @@ module OllamaChat::Commands
93
93
 
94
94
  command(
95
95
  name: :favourite,
96
- regexp: %r(^/favourite(?:\s+(add|delete))?(?:\s+(model|prompt|system|persona|suggest))$),
97
- complete: [ 'favourite', %w[ add delete ].product(%w[ model prompt system persona suggest ]) ],
96
+ regexp: %r(^/favourite\s+(model|prompt|system|persona|suggest)$),
97
+ complete: [ 'favourite', %w[ model prompt system persona suggest ] ],
98
98
  help: <<~EOT
99
- \u2B50 Manage favorites (add/delete models,
99
+ \u2B50 Manage favorites (toggle models,
100
100
  prompts, personae)
101
101
  EOT
102
- ) do |subcommand, type|
103
- case subcommand
104
- when 'add'
105
- add_favourite(type)
106
- when 'delete'
107
- delete_favourite(type)
108
- end
102
+ ) do |type|
103
+ choose_favourite(type)
109
104
  :next
110
105
  end
111
106
 
@@ -199,27 +194,22 @@ module OllamaChat::Commands
199
194
 
200
195
  command(
201
196
  name: :tools,
202
- regexp: %r(^/tools(?:\s+(on|off|enable|disable))?),
203
- complete: [ 'tools', %w[ on off enable disable ] ],
197
+ regexp: %r(^/tools(?:\s+(on|off))?),
198
+ complete: [ 'tools', %w[ on off ] ],
204
199
  optional: true,
205
200
  help: <<~EOT
206
201
  🛠 Manage tools:
207
- - (no subcommand): List available tools
202
+ - (no subcommand): Interactively choose tools
208
203
  - on/off: Activate/Deactivate globally
209
- - enable/disable: Interactively toggle specific
210
204
  EOT
211
205
  ) do |subcommand|
212
206
  case subcommand
213
- when nil
214
- list_tools
215
- when 'enable'
216
- enable_tool
217
- when 'disable'
218
- disable_tool
219
207
  when 'on'
220
208
  tools_support.set(true, show: true)
221
209
  when 'off'
222
210
  tools_support.set(false, show: true)
211
+ else
212
+ choose_tools
223
213
  end
224
214
  :next
225
215
  end
@@ -655,9 +645,9 @@ module OllamaChat::Commands
655
645
  when 'update all'
656
646
  results = ''
657
647
  all_collections.pluck(:name).each do |collection|
658
- feedback("📝 Updating collection #{collection.inspect}…")
648
+ feedback("Starting to update collection #{bold{collection}}", type: :info)
659
649
  results << update_collection(collection) << ?\n
660
- feedback("Done.", type: :success)
650
+ feedback("Collection #{bold{collection}} was updated.", type: :success)
661
651
  end
662
652
  results.full? and next results
663
653
  when 'update'
@@ -1064,6 +1054,17 @@ module OllamaChat::Commands
1064
1054
  quit_app
1065
1055
  end
1066
1056
 
1057
+ command(
1058
+ name: :restart,
1059
+ regexp: %r(^/restart$),
1060
+ help: <<~EOT
1061
+ 🔄 Restart application
1062
+ EOT
1063
+ ) do
1064
+ reload_config
1065
+ :next
1066
+ end
1067
+
1067
1068
  category :Information
1068
1069
 
1069
1070
  command(
@@ -230,13 +230,13 @@ module OllamaChat::Compaction
230
230
  es = OllamaChat::TokenEstimator.estimate(prompt)
231
231
  log(:info, "Compaction: sending prompt " \
232
232
  "#{es.tokens_formatted} (#{es.bytes_formatted}) to #{@model}")
233
-
233
+ think = config.compaction.think == 'auto' ? self.think : false
234
234
  response = Infobar.busy(
235
235
  label: 'Compacting context…',
236
236
  frames: :braille7,
237
237
  output: STDOUT,
238
238
  ) do
239
- generate(system:, prompt:, think: true).strip
239
+ generate(system:, prompt:, think:).strip
240
240
  end
241
241
 
242
242
  if response.empty?
@@ -66,42 +66,23 @@ module OllamaChat::Conversation
66
66
 
67
67
  # Selectively cleans parts of the current conversation.
68
68
  #
69
- # Presents an accumulating chooser of cleanable targets:
69
+ # Presents a multi-select chooser of cleanable targets:
70
70
  # tool content, images, thinking, messages, history, links.
71
- # The user picks one or more (or [ALL]), confirms, and the
71
+ # The user toggles one or more items and confirms; the
72
72
  # selected items are cleared.
73
73
  def conversation_clean
74
74
  options = %w[ tools images thinking messages history links ]
75
-
76
- selected = Set.new
77
- choose_with_state do
78
- loop do
79
- remaining = options - selected.to_a
80
- entries = (remaining.empty? ? [] : ['[ALL]'] + remaining) + ['[DONE]']
81
- choice = choose_entry(entries, prompt: 'What to clean from conversation? %s')
82
- case choice
83
- when nil, '[DONE]'
84
- break
85
- when '[ALL]'
86
- selected.merge(remaining)
87
- break
88
- else
89
- selected << choice
90
- end
91
- end
92
- end
93
-
75
+ selected = choose_multi(
76
+ %w[ [ALL] [NONE] ] + options,
77
+ all: '[ALL]',
78
+ none: '[NONE]',
79
+ prompt: 'What to clean from conversation? %s ' \
80
+ '[Tab=toggle, Enter=apply, C-c=abort]'
81
+ ) or return feedback('Cancelled, nothing selected.', type: :cancel)
94
82
  return feedback('Cancelled, nothing selected.', type: :cancel) if selected.empty?
95
83
 
96
84
  what = selected.map { |s| bold{s} }.to_a
97
85
 
98
- unless confirm?(
99
- prompt: "🔔 Clean #{what * ', '} from conversation? (y/n) ",
100
- yes: /\Ay/i
101
- )
102
- return feedback('Denied.', type: :denied)
103
- end
104
-
105
86
  field_options = %w[ tools images thinking ].select { selected.include?(_1) }
106
87
  messages.clear if selected.include?('messages')
107
88
  messages.clean_messages!(what: field_options.map(&:to_sym)) unless field_options.empty?
@@ -112,26 +112,29 @@ module OllamaChat::Dialog
112
112
 
113
113
  private
114
114
 
115
- # The choose_file_set method aggregates all files matching the given patterns
116
- # by repeatedly invoking choose_filename and collecting their expanded paths
117
- # into a Set.
115
+ # The choose_multiple_filenames method presents a multi-select picker of
116
+ # all files matching the given glob patterns. The user toggles files with
117
+ # Tab and confirms with Enter.
118
118
  #
119
119
  # @param patterns [ Array<String> ] optional glob patterns to match; defaults
120
120
  # to '**/*'.
121
121
  #
122
122
  # @return [ Set<Pathname> ] a set of expanded Pathname objects for each
123
- # selected file.
123
+ # selected file (empty set on abort).
124
124
  #
125
- def choose_file_set(patterns)
125
+ def choose_multiple_filenames(patterns)
126
126
  patterns ||= '**/*'
127
- patterns = Array(patterns).map { Pathname.new(_1).expand_path }
128
- files = Set[]
129
- choose_with_state do
130
- while filename = choose_filename(patterns, chosen: files)
131
- files << filename.expand_path
132
- end
133
- end
134
- files
127
+ patterns = Array(patterns).map { Pathname.new(_1).expand_path }
128
+ files = patterns.flat_map { Pathname.glob(_1) }
129
+ files = files.select { _1.file? }.uniq
130
+ result = choose_multi(
131
+ %w[ [ALL] [NONE] ] + files,
132
+ all: '[ALL]',
133
+ none: '[NONE]',
134
+ prompt: 'Select files to import: %s ' \
135
+ '[Tab=toggle, Enter=apply, C-c=abort]'
136
+ )
137
+ (result || []).to_set
135
138
  end
136
139
 
137
140
  # Displays an info-level feedback message indicating that a connection
@@ -11,7 +11,7 @@ module OllamaChat::FavouritesManagement
11
11
  # @param favourited [Boolean] whether the item is a favourite
12
12
  # @return [String] the decorated string
13
13
  def prefix_favourite(string, favourited)
14
- fav = favourited ? "\u2764" : '🩶'
14
+ fav = favourited ? '⭐' : '⚫'
15
15
  "%s %s" % [ fav, string ]
16
16
  end
17
17
 
@@ -29,61 +29,45 @@ module OllamaChat::FavouritesManagement
29
29
  end.to_a
30
30
  end
31
31
 
32
- # The add_favourite method adds a favourite item of a specified type. It
33
- # iterates through available favourites and allows the user to select
34
- # from items that haven't been favourited yet.
32
+ # The choose_favourite method opens an interactive multi-select picker
33
+ # showing all available items of the given type with their current
34
+ # favourite state (⭐ / ⚫). The user toggles items with Tab and
35
+ # applies changes with Enter.
35
36
  #
36
37
  # @param type [ String ] the context type for the favourite
37
38
  #
38
- # @note This method uses a chooser to present options and handles user input
39
- # for adding new favourites to the database.
40
- def add_favourite(type)
41
- all_things = favourite_all_things(type)
42
- choose_with_state do
43
- loop do
44
- selected = models::Favourite.where(context: type).map(&:name)
45
- to_select = all_things - selected
46
- if to_select.empty?
47
- feedback("All items are already favourited.", type: :info)
48
- return
49
- end
50
- to_select.unshift('[EXIT]')
51
- case chosen = choose_entry(to_select, prompt: 'Select an item to mark as favourite: %s')
52
- when '[EXIT]', nil
53
- feedback("Cancelled.", type: :cancel)
54
- return
55
- when SearchUI::Wrapper
56
- models::Favourite.create(context: type, name: chosen.value)
57
- log(:info, "Favourite added", data: { context: type, name: chosen.value })
58
- end
59
- end
39
+ # @note This method uses a multi-select chooser to present options and
40
+ # handles user input for adding/removing favourites in one pass.
41
+ def choose_favourite(type)
42
+ all_things = favourite_all_things(type).map(&:value)
43
+ current = all_favourited(type)
44
+ picked = all_things.select { current.include?(_1) }
45
+
46
+ result = choose_multi(
47
+ all_things,
48
+ prompt: "Choose favourites (#{type}): %s "\
49
+ "[Tab=toggle, Enter=apply, C-c=abort]",
50
+ picked: picked,
51
+ picked_icon: '⭐',
52
+ unpicked_icon: '⚫'
53
+ ) or return feedback('Aborted.', type: :cancel)
54
+
55
+ to_add = result - current.keys
56
+ to_remove = current.keys - result
57
+
58
+ to_add.each do |name|
59
+ models::Favourite.create(context: type, name:)
60
+ log(:info, 'Favourite added', data: { context: type, name: })
61
+ end
62
+ to_remove.each do |name|
63
+ models::Favourite.where(context: type, name:).destroy
64
+ log(:info, 'Favourite removed', data: { context: type, name: })
60
65
  end
61
- end
62
66
 
63
- # The delete_favourite method removes favourite items from the database.
64
- # It iterates through current favourites and allows the user to select
65
- # items for removal in a loop, maintaining search state between selections.
66
- #
67
- # @param type [ String ] the context type of the favourite to delete
68
- #
69
- # @note This method uses a chooser to present options and handles user input
70
- # for removing favourites from the database.
71
- def delete_favourite(type)
72
- all_things = favourite_all_things(type)
73
- choose_with_state do
74
- loop do
75
- to_select = models::Favourite.where(context: type).map(&:name)
76
- to_select = all_things.select { to_select.member?(_1.value) }
77
- to_select = [ '[EXIT]' ] + to_select
78
- case chosen = choose_entry(to_select, prompt: 'Select a favourite to remove: %s')
79
- when '[EXIT]', nil
80
- feedback("Cancelled.", type: :cancel)
81
- return
82
- when SearchUI::Wrapper
83
- models::Favourite.where(context: type, name: chosen.value).destroy
84
- log(:info, "Favourite removed", data: { context: type, name: chosen.value })
85
- end
86
- end
67
+ unless (to_add + to_remove).empty?
68
+ feedback(
69
+ "Added: %s | Removed: %s" % [ to_add.joined, to_remove.joined ]
70
+ )
87
71
  end
88
72
  end
89
73
 
@@ -18,7 +18,7 @@ module OllamaChat::InputContent
18
18
  # @yield [file] yields each file to the supplied block
19
19
  # @return [Array<File>] the array of files that were processed
20
20
  def file_set_each(patterns, all: false, &block)
21
- files = all ? all_file_set(patterns) : choose_file_set(patterns)
21
+ files = all ? all_file_set(patterns) : choose_multiple_filenames(patterns)
22
22
  block and files.each(&block)
23
23
  files
24
24
  end
@@ -35,7 +35,7 @@ module OllamaChat::InputContent
35
35
  #
36
36
  # @return [String] a concatenated string of file contents with filenames as headers
37
37
  def input(patterns)
38
- files = choose_file_set(patterns)
38
+ files = choose_multiple_filenames(patterns)
39
39
  files.each_with_object('') do |filename, result|
40
40
  result << ("%s:\n\n%s\n\n" % [ filename, filename.read ])
41
41
  end.full?
@@ -458,6 +458,7 @@ class OllamaChat::MessageList
458
458
  output.puts message_text_for(message, think_loud:)
459
459
  +infobar
460
460
  end
461
+ infobar.clear
461
462
  end
462
463
  self
463
464
  end
@@ -494,6 +495,7 @@ class OllamaChat::MessageList
494
495
  output.puts message_text_for(message, think_loud:)
495
496
  +infobar
496
497
  end
498
+ infobar.clear
497
499
  ensure
498
500
  if last_message_user_message
499
501
  message_content = Kramdown::ANSI::Width.truncate(
@@ -343,17 +343,15 @@ module OllamaChat::ModelHandling
343
343
 
344
344
  # Let user pick models if more than one
345
345
  if data.size > 1
346
- options = (['[ALL]'] + data.map { |d| d['model_name'] } + ['[EXIT]'])
347
- chosen = choose_entry(options, prompt: 'Which model(s) to import? %s')
348
- case chosen
349
- when '[EXIT]', nil
350
- feedback("Cancelled.", type: :cancel)
351
- return
352
- when '[ALL]'
353
- selected = data
354
- else
355
- selected = data.select { |d| d['model_name'] == chosen }
356
- end
346
+ names = data.map { |d| d['model_name'] }
347
+ chosen = choose_multi(
348
+ %w[ [ALL] [NONE] ] + names,
349
+ all: '[ALL]',
350
+ none: '[NONE]',
351
+ prompt: 'Which model(s) to import? %s [Tab=toggle, Enter=apply, C-c=abort]'
352
+ ) or return feedback('Cancelled.', type: :cancel)
353
+ return feedback('Cancelled.', type: :cancel) if chosen.empty?
354
+ selected = data.select { |d| chosen.include?(d['model_name']) }
357
355
  else
358
356
  selected = data
359
357
  end
@@ -514,6 +514,7 @@ context:
514
514
  manifest: false
515
515
  compaction:
516
516
  enabled: true
517
+ think: 'auto' # 'never'
517
518
  reserve:
518
519
  ratio: 0.60
519
520
  min_tokens: 4096
@@ -448,23 +448,37 @@ module OllamaChat::PersonaeManagement
448
448
 
449
449
  # Interactive method to load multiple personae for use.
450
450
  #
451
- # Allows sequential selection of multiple personae. Returns JSON results for
452
- # each loaded persona.
451
+ # Presents a multi-select picker with `[ALL]`/`[NONE]` sentinels.
452
+ # Returns a compiled
453
+ # description string for all picked personae.
454
+ #
455
+ # @return [String, nil] A string containing all descriptions, or nil if
456
+ # the selection was cancelled or no persona was chosen.
453
457
  def load_personae
454
- chosen = Set[]
455
- choose_with_state do
456
- while persona = choose_persona(chosen:, prompt: 'Who else should join the conversation? %s')
457
- persona == :none and next
458
- chosen << persona
459
- end
458
+ personae = available_personae_names
459
+ if personae.empty?
460
+ feedback("No personae defined.", type: :warn)
461
+ return
460
462
  end
461
463
 
462
- if chosen.empty?
464
+ entries = %w[ [ALL] [NONE] ] + personae
465
+
466
+ picked = choose_multi(
467
+ entries,
468
+ prompt: 'Who should join? %s [Tab=toggle, Enter=apply, C-c=abort]',
469
+ all: '[ALL]',
470
+ none: '[NONE]',
471
+ picked_icon: '☑ ',
472
+ unpicked_icon: '🔳'
473
+ ) or return
474
+ names = picked.map(&:value)
475
+
476
+ if names.empty?
463
477
  feedback("No persona loaded.", type: :info)
464
478
  return
465
479
  end
466
480
 
467
- personae_result(chosen)
481
+ personae_result(names)
468
482
  end
469
483
 
470
484
  # Compiles the descriptions for one or more personae into a single string.
@@ -637,13 +651,11 @@ module OllamaChat::PersonaeManagement
637
651
  frames: :braille7,
638
652
  output: STDOUT,
639
653
  ) do
640
- generate(
641
- prompt: prompt(:persona_architect).to_s.
642
- named_placeholders_interpolate(
643
- { character:,
644
- persona_template: prompt(:persona).to_s }
645
- )
646
- ).gsub(/{{user}}/i, '%{user}').gsub(/{{char}}/i, persona_name)
654
+ prompt = prompt(:persona_architect).to_s.named_placeholders_interpolate(
655
+ { character:, persona_template: prompt(:persona).to_s }
656
+ )
657
+ generate(prompt:, think:).
658
+ gsub(/{{user}}/i, '%{user}').gsub(/{{char}}/i, persona_name)
647
659
  end
648
660
  end
649
661
 
@@ -382,7 +382,7 @@ module OllamaChat::PromptManagement
382
382
  frames: :braille7,
383
383
  output: STDOUT,
384
384
  ) do
385
- generate(prompt: full_prompt)
385
+ generate(prompt: full_prompt, think:)
386
386
  end
387
387
 
388
388
  # Pass the AI's suggestions through the editor for final refinement