ollama_chat 0.0.131 → 0.0.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e7543207de9d23c4731b5c8b1e768ad28559f57a4d767bfcabaaf25dc7f4541
4
- data.tar.gz: 7a3a03b47e077f2c0b6fa7d042a910d8dab32d30bcd0253c0e706f105d0a4e86
3
+ metadata.gz: 57100c5a17ee0794ecbbb0e468caf3c5ec176d83c89afc80a0cfb8a494a01914
4
+ data.tar.gz: 9233a943fb0ad3f7d319e4b2312d63ec5f0b00959d9800dc651f0b039c8a8f59
5
5
  SHA512:
6
- metadata.gz: d585ff38e8daeb72ddccedf4eb0ef1711c35f843fb3028f73c00bad1df84045ba5228b82916dec834bb4c2d518a15c198a5f009eb5bc541bd46eca0513458542
7
- data.tar.gz: 291074810f529cf30873946a74e52a83de45461808ce0cb8aff4f366ef17c8cb70a5fccefc1b98c1b6e0a234dd2d67419788e59ad5da22ea64d1c1e04982b171
6
+ metadata.gz: 5c29e1b8ba010a29f6f6a7d502cbe9b6cae7e101aba823f104b71e32575e5dccc5cb998dd385b7b6d16872b6ca3bd0935de04d6357576d8d27877d475e814723
7
+ data.tar.gz: 50a98b4ad252faf970fd68774d9d234224d6ff3e4539ab69ab52a6939095ea1d413ceeb2031d8cee767b40a00c383be86e47226e1f2e4a0fe744d04fbfe5a3f9
data/CHANGES.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-10-12 v0.0.132
4
+
5
+ * `collection` now returns `@documents.collection.to_s`, making the return
6
+ type strictly `[String]`
7
+ * `clear_whole_collection` replaces the y/n `confirm?` with an `ask?` prompt
8
+ that requires typing the full collection name before clearing
9
+ * Log message includes `target.inspect` for greppability
10
+ * `commands_spec.rb`: `:default` → `'default'` in `rename_collection` and
11
+ `update_collection` expectations
12
+ * `rag_handling_spec.rb`: both `clear_whole_collection` specs rewritten to
13
+ stub `ask?` + `switch_history` instead of the removed `confirm?`
14
+ * Updated the `tins` runtime dependency constraint from `~> 1.60`, `>=
15
+ 1.60.1` to `~> 1.61` in `Rakefile` and `ollama_chat.gemspec`
16
+ * `feedback` gains a `timeout:` kwarg; when set, calls `chat.confirm?` with a
17
+ "press any key to continue (timeout in Xs)" prompt so the message doesn't
18
+ flash by
19
+ * `clear_tag_records` and `clear_collection_sources` in `rag_handling.rb`
20
+ pass `timeout: 3`
21
+ * `dialog.rb` adds `IOError` to the `STDIN.raw` exception rescue list
22
+ * `rag_handling_spec.rb` updated with `timeout: 3` in four `feedback`
23
+ expectations
24
+
3
25
  ## 2026-10-10 v0.0.131
4
26
 
5
27
  * Extracted ANSI, emoji, and formatting logic from `Information` into a new
data/Rakefile CHANGED
@@ -49,7 +49,7 @@ GemHadar do
49
49
  dependency 'reverse_markdown', '~> 3.0'
50
50
  dependency 'kramdown-ansi', '~> 0.5'
51
51
  dependency 'complex_config', '~> 0.22', '>= 0.22.2'
52
- dependency 'tins', '~> 1.60', '>= 1.60.1'
52
+ dependency 'tins', '~> 1.61'
53
53
  dependency 'search_ui', '>= 0.2'
54
54
  dependency 'amatch', '~> 0.4'
55
55
  dependency 'pdf-reader', '~> 2.0'
@@ -73,7 +73,7 @@ module OllamaChat::Dialog
73
73
  min = 0
74
74
  time = timeout
75
75
  end
76
- exceptions = [ (IRB::Abort if defined? IRB), Interrupt ].compact
76
+ exceptions = [ (IRB::Abort if defined? IRB), Interrupt, IOError ].compact
77
77
  begin
78
78
  keypress = STDIN.raw(min:, time:, intr: true) do |io|
79
79
  io.getc
@@ -33,9 +33,12 @@ module OllamaChat::Feedback
33
33
  # message ends with exactly one newline before writing.
34
34
  # Set to false for mid-line or no-trailing-newline output.
35
35
  # @return [nil]
36
- def feedback(msg, type: nil, output: STDOUT, newline: true)
36
+ def feedback(msg, type: nil, output: STDOUT, newline: true, timeout: nil)
37
37
  prefix = PREFIXES[type&.to_sym]&.+(' ')
38
38
  newline and msg = msg.sub(/(?<!\n)\z/, ?\n)
39
39
  output.print(prefix.to_s + msg)
40
+ timeout.nil? and return
41
+ chat.confirm?(prompt: '⏎ Press any key to continue (%s). ', timeout:)
42
+ nil
40
43
  end
41
44
  end
@@ -63,9 +63,9 @@ module OllamaChat::RAGHandling
63
63
 
64
64
  # Returns the name of the currently active document collection.
65
65
  #
66
- # @return [String, Symbol] the name of the current collection
66
+ # @return [String] the name of the current collection
67
67
  def collection
68
- @documents.collection
68
+ @documents.collection.to_s
69
69
  end
70
70
 
71
71
  # Sets the documents collection to collection.
@@ -246,9 +246,15 @@ module OllamaChat::RAGHandling
246
246
  # @return [ nil, OllamaChat::Chat ] when the user declines the confirmation
247
247
  # prompt, self otherwise.
248
248
  def clear_whole_collection
249
- if confirm?(prompt: '🔔 Really delete the whole collection? Are you sure? (y/n) ', yes: /\Ay/i)
249
+ target = collection
250
+ prompt = "🔥 This will incinerate every record in #{target.inspect}. " \
251
+ "Type the name to confirm (C-c ⇒ cancel): "
252
+ typed = switch_history(:collection_name) do
253
+ ask?(prompt:, prefill: target).full?(:strip)
254
+ end
255
+ if typed == target
250
256
  @documents.clear
251
- log(:info, "Collection cleared", data: { collection: })
257
+ log(:info, "Collection #{target.inspect} cleared", data: { collection: })
252
258
  feedback("Cleared collection #{bold{collection}}.", type: :info)
253
259
  self
254
260
  else
@@ -350,7 +356,8 @@ module OllamaChat::RAGHandling
350
356
  data: { collection:, tag:, source: })
351
357
  feedback(
352
358
  "Cleared tag #{tag} from collection #{bold{collection}}.",
353
- type: :info
359
+ type: :info,
360
+ timeout: 3,
354
361
  )
355
362
  end
356
363
 
@@ -411,7 +418,8 @@ module OllamaChat::RAGHandling
411
418
  data: { collection:, source: })
412
419
  feedback(
413
420
  "Removed source #{source} from collection #{bold{collection}}.",
414
- type: :info
421
+ type: :info,
422
+ timeout: 3,
415
423
  )
416
424
  end
417
425
  end
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.131'
3
+ VERSION = '0.0.132'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/ollama_chat.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ollama_chat 0.0.131 ruby lib
2
+ # stub: ollama_chat 0.0.132 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama_chat".freeze
6
- s.version = "0.0.131".freeze
6
+ s.version = "0.0.132".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  s.add_runtime_dependency(%q<reverse_markdown>.freeze, ["~> 3.0".freeze])
44
44
  s.add_runtime_dependency(%q<kramdown-ansi>.freeze, ["~> 0.5".freeze])
45
45
  s.add_runtime_dependency(%q<complex_config>.freeze, ["~> 0.22".freeze, ">= 0.22.2".freeze])
46
- s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.60".freeze, ">= 1.60.1".freeze])
46
+ s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.61".freeze])
47
47
  s.add_runtime_dependency(%q<search_ui>.freeze, [">= 0.2".freeze])
48
48
  s.add_runtime_dependency(%q<amatch>.freeze, ["~> 0.4".freeze])
49
49
  s.add_runtime_dependency(%q<pdf-reader>.freeze, ["~> 2.0".freeze])
@@ -357,7 +357,7 @@ describe OllamaChat::Commands, protect_env: true do
357
357
  expect(chat.handle_input("/collection change")).to eq :next
358
358
  expect(STDOUT).to receive(:puts).with(/default/)
359
359
  expect(chat.handle_input("/collection list")).to eq :next
360
- expect(chat).to receive(:rename_collection).with(:default)
360
+ expect(chat).to receive(:rename_collection).with('default')
361
361
  expect(chat.handle_input("/collection rename")).to eq :next
362
362
  end
363
363
 
@@ -391,13 +391,13 @@ describe OllamaChat::Commands, protect_env: true do
391
391
  end
392
392
 
393
393
  it 'returns :next when "/collection update" has no changes' do
394
- expect(chat).to receive(:update_collection).with(:default)
394
+ expect(chat).to receive(:update_collection).with('default')
395
395
  .and_return nil
396
396
  expect(chat.handle_input("/collection update")).to eq :next
397
397
  end
398
398
 
399
399
  it 'returns results when "/collection update" has content' do
400
- expect(chat).to receive(:update_collection).with(:default)
400
+ expect(chat).to receive(:update_collection).with('default')
401
401
  .and_return 'updated 3'
402
402
  expect(chat.handle_input("/collection update")).to eq 'updated 3'
403
403
  end
@@ -90,17 +90,20 @@ describe OllamaChat::RAGHandling do
90
90
  end
91
91
 
92
92
  describe '#clear_whole_collection' do
93
- it 'clears all documents and returns self when confirmed' do
94
- expect(chat).to receive(:confirm?).and_return(true)
95
- expect(docs).to receive(:collection).twice.and_return('default')
93
+ it 'clears all documents and returns self when name is typed' do
94
+ expect(docs).to receive(:collection).and_return('default').at_least(:once)
95
+ expect(chat).to receive(:switch_history) { |*, &blk| blk.call }
96
+ expect(chat).to receive(:ask?).and_return('default')
96
97
  expect(docs).to receive(:clear)
97
98
  expect(chat).to receive(:feedback)
98
99
  .with(a_string_including('Cleared collection'), type: :info)
99
100
  expect(chat.clear_whole_collection).to eq chat
100
101
  end
101
102
 
102
- it 'returns nil and reports denied when declined' do
103
- expect(chat).to receive(:confirm?).and_return(false)
103
+ it 'returns nil and reports denied when name does not match' do
104
+ expect(docs).to receive(:collection).and_return('default')
105
+ expect(chat).to receive(:switch_history) { |*, &blk| blk.call }
106
+ expect(chat).to receive(:ask?).and_return('other')
104
107
  expect(docs).not_to receive(:clear)
105
108
  expect(chat).to receive(:feedback).with('Denied.', type: :denied)
106
109
  expect(chat.clear_whole_collection).to be_nil
@@ -147,7 +150,7 @@ describe OllamaChat::RAGHandling do
147
150
  expect(docs).to receive(:clear).with(tags: [ 'mem' ])
148
151
  expect(chat).to receive(:log)
149
152
  expect(chat).to receive(:feedback)
150
- .with(a_string_including('Cleared tag mem'), type: :info)
153
+ .with(a_string_including('Cleared tag mem'), type: :info, timeout: 3)
151
154
  expect(chat).to receive(:feedback).with('Exiting chooser.')
152
155
  chat.clear_collection_tags
153
156
  expect(buf.string).to include('hello world')
@@ -192,7 +195,7 @@ describe OllamaChat::RAGHandling do
192
195
  expect(docs).to receive(:source_remove).with('a.rb')
193
196
  expect(chat).to receive(:log)
194
197
  expect(chat).to receive(:feedback)
195
- .with(a_string_including('Cleared tag t1'), type: :info)
198
+ .with(a_string_including('Cleared tag t1'), type: :info, timeout: 3)
196
199
  expect(chat).to receive(:feedback).with('Exiting chooser.')
197
200
  chat.clear_collection_tags
198
201
  expect(buf.string).to include('hello')
@@ -220,7 +223,7 @@ describe OllamaChat::RAGHandling do
220
223
  expect(docs).to receive(:source_remove).with('a.rb')
221
224
  expect(chat).to receive(:log)
222
225
  expect(chat).to receive(:feedback)
223
- .with(a_string_including('Cleared tag t1'), type: :info)
226
+ .with(a_string_including('Cleared tag t1'), type: :info, timeout: 3)
224
227
  expect(chat).to receive(:feedback).with('Exiting chooser.')
225
228
  chat.clear_collection_tags
226
229
  end
@@ -269,7 +272,7 @@ describe OllamaChat::RAGHandling do
269
272
  expect(docs).to receive(:source_remove).with('a.rb')
270
273
  expect(chat).to receive(:log)
271
274
  expect(chat).to receive(:feedback)
272
- .with(a_string_including('Removed source a.rb'), type: :info)
275
+ .with(a_string_including('Removed source a.rb'), type: :info, timeout: 3)
273
276
  expect(chat).to receive(:feedback).with('Exiting chooser.')
274
277
  chat.clear_collection_sources
275
278
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ollama_chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.131
4
+ version: 0.0.132
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -287,20 +287,14 @@ dependencies:
287
287
  requirements:
288
288
  - - "~>"
289
289
  - !ruby/object:Gem::Version
290
- version: '1.60'
291
- - - ">="
292
- - !ruby/object:Gem::Version
293
- version: 1.60.1
290
+ version: '1.61'
294
291
  type: :runtime
295
292
  prerelease: false
296
293
  version_requirements: !ruby/object:Gem::Requirement
297
294
  requirements:
298
295
  - - "~>"
299
296
  - !ruby/object:Gem::Version
300
- version: '1.60'
301
- - - ">="
302
- - !ruby/object:Gem::Version
303
- version: 1.60.1
297
+ version: '1.61'
304
298
  - !ruby/object:Gem::Dependency
305
299
  name: search_ui
306
300
  requirement: !ruby/object:Gem::Requirement