ollama_chat 0.0.111 → 0.0.113

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: 54b2bf70b7f843ad09b5de5f0881bf810ec78a08c79c5e1cd93d86aa75b68696
4
- data.tar.gz: 33e475ea5e115609e02ba6b92cdf6a9b1b1dc6eccbfde6978fc80623daa3040b
3
+ metadata.gz: e618b797bf1b5fa84728816e06b83fe3540424b48256ba107deb29c2beb8a219
4
+ data.tar.gz: f5abee2701f3fc6d7ba09513f0b0bd5133c7ec10ddb511ee5ea4238c14f9988e
5
5
  SHA512:
6
- metadata.gz: e7dad8f668a54b9c1e89937a445894eeb9872e1541d54dfc36fcf136d5c759bde7e0c21c9b818ce2e8ffa3bd7274163ada6b18553590dc812f3e89bdae839a27
7
- data.tar.gz: 8bbd695f1eacc33c6928f8a382acdb8ed68b57348a0ce5199a9203bd7070df59f71a7a37e2862297c6c7dbc12e0d00aa9c46ef90f6392fc7579b87c8de438b7d
6
+ metadata.gz: 2f2172cc90da0a8b8c1b7f2306abbc8480db92abeb3629e20b2471e88fdd79ca2d18c209c05690167b564b6911685222dce48496e9825330e43500ff520aab74
7
+ data.tar.gz: da6e5e8583b11cb7d766ff0745e97070f2a39ac8f1ca6314a4bcb93d8e9a6c3ec9ef087a055b7c9844317f831fc4a6a590e11f80eaf6b6c80980143ab8385771
data/CHANGES.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-08-25 v0.0.113
4
+
5
+ * Simplified hash syntax by replacing `text: text` with `text:` etc.
6
+ * Removed the `/conversation compact` stub, including its regexp,
7
+ completion list, help text, handler logic, and associated specs.
8
+ * Added specs for `/config edit`, `/config reload`, and `/config diff` in
9
+ `commands_spec.rb`, verifying the ordered sequence of `diff_config`
10
+ followed by the new `reload_config` for the diff command.
11
+ * Removed the unused `collection_descriptions: {}` entry from the
12
+ `embedding:` section in `default_config.yml`.
13
+
14
+ ## 2026-08-25 v0.0.112
15
+
16
+ * Added a `diff` subcommand to the `/config` command, including updated
17
+ regexp, completion, and help text.
18
+ * Extracted a `diff_config` method in `OllamaChat::ConfigHandling` that
19
+ resolves `OC::DIFF_TOOL` and launches a diff against
20
+ `@ollama_chat_config.filename` and
21
+ `@ollama_chat_config.default_config_path`.
22
+ * Simplified `fix_config` to delegate the diff invocation to `diff_config`.
23
+ * Added `#diff_config` specs covering both the missing-diff-tool path (STDERR
24
+ + `nil`) and the successful `system` invocation.
25
+
3
26
  ## 2026-08-25 v0.0.111
4
27
 
5
28
  ### Added
@@ -114,7 +114,7 @@ module OllamaChat::Clipboard
114
114
  # @return [TrueClass] if the copying has been performed successfully.
115
115
  def copy_to_clipboard(edit: false)
116
116
  text = last_message_content(content: false)
117
- perform_copy_to_clipboard(text: text, edit:)
117
+ perform_copy_to_clipboard(text:, edit:)
118
118
  log(:info, "Copied to clipboard", data: { bytes: format_bytes(text.bytesize) }) if text
119
119
  STDOUT.puts "The last response has been successfully copied to the system clipboard."
120
120
  true
@@ -62,11 +62,11 @@ module OllamaChat::Commands
62
62
 
63
63
  command(
64
64
  name: :config,
65
- regexp: %r(^/config(?:\s+(edit|reload))?$),
66
- complete: [ 'config', %w[ edit reload ] ],
65
+ regexp: %r(^/config(?:\s+(edit|reload|diff))?$),
66
+ complete: [ 'config', %w[ edit reload diff ] ],
67
67
  optional: true,
68
68
  help: <<~EOT
69
- \u2699\uFE0F View, edit, or reload configuration
69
+ \u2699\uFE0F View, edit, diff, or reload configuration
70
70
  EOT
71
71
  ) do |subcommand|
72
72
  case subcommand
@@ -74,9 +74,13 @@ module OllamaChat::Commands
74
74
  edit_config
75
75
  when 'reload'
76
76
  reload_config
77
+ when 'diff'
78
+ diff_config
79
+ reload_config
77
80
  else
78
81
  display_config
79
82
  end
83
+
80
84
  :next
81
85
  end
82
86
 
@@ -594,15 +598,14 @@ module OllamaChat::Commands
594
598
 
595
599
  command(
596
600
  name: :conversation,
597
- regexp: %r(^/conversation\s+(clean|compact|save|load)(\s+-c)?(?:\s+([^-].*\.jsonl?))?$),
598
- complete: [ 'conversation', %w[ save load clean compact ] ],
601
+ regexp: %r(^/conversation\s+(clean|save|load)(\s+-c)?(?:\s+([^-].*\.jsonl?))?$),
602
+ complete: [ 'conversation', %w[ save load clean ] ],
599
603
  options: '[-c] [FILENAME]',
600
604
  help: <<~EOT
601
605
  💾 Save/Load conversation state
602
606
  (-c to clean before saving)
603
607
  FILENAME ends with .json or .jsonl
604
608
  Or clean inplace (removes tool content, images, and thinking)
605
- Or compact (summarize old messages, keep recent)
606
609
  EOT
607
610
  ) do |subcommand,opts,path|
608
611
  if %w[ save load ].include?(subcommand) && path.blank?
@@ -628,18 +631,6 @@ module OllamaChat::Commands
628
631
  else
629
632
  STDOUT.puts 'Cancelled.'
630
633
  end
631
- when 'compact'
632
- if confirm?(
633
- prompt: '🔔 Compact conversation? Old messages will be summarized. (y/n) ',
634
- yes: /\Ay/i
635
- )
636
- then
637
- messages.compact!
638
- session_sync
639
- STDOUT.puts "Conversation compacted."
640
- else
641
- STDOUT.puts 'Cancelled.'
642
- end
643
634
  end
644
635
  :next
645
636
  end
@@ -44,6 +44,22 @@ module OllamaChat::ConfigHandling
44
44
  end
45
45
  end
46
46
 
47
+ # Opens a diff tool to compare the current config file with the
48
+ # default config, allowing the user to visually inspect differences.
49
+ #
50
+ # @return [Boolean, nil] the result of +system+ if a diff tool was
51
+ # found, or +nil+ if no diff tool is configured.
52
+ def diff_config
53
+ diff_tool = OC::DIFF_TOOL? or
54
+ return STDERR.puts 'No diff tool configured (OC::DIFF_TOOL).'
55
+ cmd = [
56
+ diff_tool,
57
+ @ollama_chat_config.filename,
58
+ @ollama_chat_config.default_config_path,
59
+ ].map(&:to_s)
60
+ system(*cmd)
61
+ end
62
+
47
63
  # The fix_config method handles configuration file errors by informing the
48
64
  # user about the exception and prompting them to fix it. It then executes a
49
65
  # diff tool to compare the current config file with the default one.
@@ -52,9 +68,9 @@ module OllamaChat::ConfigHandling
52
68
  # @param exception [Exception] the exception that occurred while reading
53
69
  # the config file
54
70
  def fix_config(exception)
55
- STDOUT.puts "When reading the config file, a #{exception.class} "\
71
+ STDOUT.puts "When reading the config file, a #{exception.class} " \
56
72
  "exception was caught: #{exception.message.inspect}"
57
- unless diff_tool = OC::DIFF_TOOL?
73
+ unless OC::DIFF_TOOL?
58
74
  exit 1
59
75
  end
60
76
  if confirm?(
@@ -62,18 +78,14 @@ module OllamaChat::ConfigHandling
62
78
  yes: /\Ay/i
63
79
  )
64
80
  then
65
- cmd = [
66
- diff_tool,
67
- @ollama_chat_config.filename,
68
- @ollama_chat_config.default_config_path,
69
- ].map(&:to_s)
70
- system(*cmd)
81
+ diff_config
71
82
  exit 0
72
83
  else
73
84
  exit 1
74
85
  end
75
86
  end
76
87
 
88
+
77
89
  # Adjusts the command-line argument array to ensure the current session is
78
90
  # explicitly reloaded by injecting the `-l <session_id>` flag.
79
91
  #
@@ -378,7 +378,6 @@ embedding:
378
378
  batch_size: 100
379
379
  database_filename: null # ':memory:'
380
380
  collection: <%= OC::OLLAMA::CHAT::COLLECTION %>
381
- collection_descriptions: {}
382
381
  found_texts_size: 16384
383
382
  found_texts_count: 10
384
383
  splitter:
@@ -267,7 +267,7 @@ module OllamaChat::RAGHandling
267
267
  update_collection(name.to_s)
268
268
  end
269
269
  STDOUT.puts "✅ Created collection '#{name}'."
270
- log(:info, "Collection created", data: { name: name, description:, patterns: })
270
+ log(:info, "Collection created", data: { name:, description:, patterns: })
271
271
  rescue Sequel::UniqueConstraintViolation
272
272
  STDERR.puts "❌ Collection #{name.inspect} already exists."
273
273
  rescue Sequel::Error => e
@@ -170,7 +170,7 @@ class OllamaChat::Tools::PatchFile
170
170
 
171
171
  (result | {
172
172
  path: path.to_s,
173
- message: message,
173
+ message: ,
174
174
  mtime: ,
175
175
  checksum: ,
176
176
  }).to_json
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.111'
3
+ VERSION = '0.0.113'
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.111 ruby lib
2
+ # stub: ollama_chat 0.0.113 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama_chat".freeze
6
- s.version = "0.0.111".freeze
6
+ s.version = "0.0.113".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]
@@ -532,18 +532,6 @@ describe OllamaChat::Commands, protect_env: true do
532
532
  expect(chat).to receive(:confirm?).and_return false
533
533
  expect(chat.handle_input("/conversation clean")).to eq :next
534
534
  end
535
-
536
- it 'returns :next when input is "/conversation compact"' do
537
- expect(chat).to receive(:confirm?).and_return true
538
- expect(chat.messages).to receive(:compact!)
539
- expect(chat).to receive(:session_sync)
540
- expect(chat.handle_input("/conversation compact")).to eq :next
541
- end
542
-
543
- it 'returns :next when input is "/conversation compact" and user cancels' do
544
- expect(chat).to receive(:confirm?).and_return false
545
- expect(chat.handle_input("/conversation compact")).to eq :next
546
- end
547
535
  end
548
536
 
549
537
  describe 'tools' do
@@ -568,6 +556,22 @@ describe OllamaChat::Commands, protect_env: true do
568
556
  expect(chat).to receive(:display_config)
569
557
  expect(chat.handle_input("/config")).to eq :next
570
558
  end
559
+
560
+ it 'returns :next when input is "/config edit"' do
561
+ expect(chat).to receive(:edit_config)
562
+ expect(chat.handle_input("/config edit")).to eq :next
563
+ end
564
+
565
+ it 'returns :next when input is "/config reload"' do
566
+ expect(chat).to receive(:reload_config)
567
+ expect(chat.handle_input("/config reload")).to eq :next
568
+ end
569
+
570
+ it 'returns :next when input is "/config diff"' do
571
+ expect(chat).to receive(:diff_config)
572
+ expect(chat).to receive(:reload_config)
573
+ expect(chat.handle_input("/config diff")).to eq :next
574
+ end
571
575
  end
572
576
 
573
577
  describe '/quit' do
@@ -110,6 +110,36 @@ describe OllamaChat::ConfigHandling do
110
110
  end
111
111
  end
112
112
 
113
+ describe '#diff_config' do
114
+ context 'without a diff tool' do
115
+ before do
116
+ expect(OC).to receive(:DIFF_TOOL?).and_return(nil)
117
+ end
118
+
119
+ it 'prints an error to STDERR and returns nil' do
120
+ expect(STDERR).to receive(:puts).with(/No diff tool configured/)
121
+ expect(chat.diff_config).to be_nil
122
+ end
123
+ end
124
+
125
+ context 'with a diff tool' do
126
+ before { const_conf_as('OC::DIFF_TOOL' => 'vimdiff') }
127
+
128
+ it 'launches the diff tool with config and default paths' do
129
+ expect(chat.instance_variable_get(:@ollama_chat_config))
130
+ .to receive(:filename).and_return('/cfg.yml')
131
+ .ordered
132
+ expect(chat.instance_variable_get(:@ollama_chat_config))
133
+ .to receive(:default_config_path).and_return('/default.yml')
134
+ .ordered
135
+ expect(chat).to receive(:system)
136
+ .with('vimdiff', '/cfg.yml', '/default.yml')
137
+ .and_return(true)
138
+ expect(chat.diff_config).to be true
139
+ end
140
+ end
141
+ end
142
+
113
143
  describe '#edit_config' do
114
144
  it 'edits the config and restarts on confirmation' do
115
145
  expect(chat).to receive(:edit_file).and_return(true)
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.111
4
+ version: 0.0.113
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank