ollama_chat 0.0.54 → 0.0.55
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 +4 -4
- data/CHANGES.md +25 -0
- data/README.md +1 -0
- data/bin/ollama_chat_send +1 -1
- data/lib/ollama_chat/information.rb +1 -0
- data/lib/ollama_chat/input_content.rb +1 -1
- data/lib/ollama_chat/version.rb +1 -1
- data/lib/ollama_chat/vim.rb +23 -1
- data/ollama_chat.gemspec +4 -4
- data/spec/ollama_chat/input_content_spec.rb +1 -1
- data/spec/ollama_chat/think_control_spec.rb +154 -0
- data/spec/ollama_chat/vim_spec.rb +88 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b2e00c933dc3118c04db47cbe4361fadcc500004a4f5ddd5aded07cea3bf6119
|
|
4
|
+
data.tar.gz: 5b959cdf55031620153e8176f69aaa1bb815872a03d8e1ae172fcc0e4b3d2977
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba54894c682fec7e4c3756d6875eb0644b0104a8affcb95b6b55d15416998ffdf667e8e308c21fb04a5191a67a646d7c4d11a2a0516fa20d122e25d825f00d62
|
|
7
|
+
data.tar.gz: e0590805be446b6512ff0fbe3e44e960360be18681e9cd557de20bda2f2c8b44cd59e96059a62bdca4db311a6dcdcf3cb7c0e710e3e56570ba980e3e20dc7948
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-01-08 v0.0.55
|
|
4
|
+
|
|
5
|
+
- Added `OllamaChat::Vim` class for inserting text into Vim buffers using the
|
|
6
|
+
clientserver protocol
|
|
7
|
+
- Implemented `server_name` and `clientserver` attribute readers for the
|
|
8
|
+
`OllamaChat::Vim` class
|
|
9
|
+
- Enhanced error message for missing vim server to include the specific server
|
|
10
|
+
name being used
|
|
11
|
+
- Added error handling to the `insert` method with fallback to `STDERR` output
|
|
12
|
+
when vim command fails
|
|
13
|
+
- Added comprehensive specs for `OllamaChat::Vim` module with **100%** coverage
|
|
14
|
+
- Fixed typo in help text for `ollama_chat_send` command ("reqired" →
|
|
15
|
+
"required")
|
|
16
|
+
- Added comprehensive tests for `ThinkControl` module with **100%** coverage
|
|
17
|
+
- Updated `README.md` and `OllamaChat::Information` to document the new
|
|
18
|
+
`/revise_last` command
|
|
19
|
+
- Improved test coverage for Vim integration
|
|
20
|
+
- Ensured proper state management and no side effects during selection in
|
|
21
|
+
`ThinkControl` tests
|
|
22
|
+
- All tests use `connect_to_ollama_server` for proper setup
|
|
23
|
+
- Fixed edge cases including exit conditions and nil selections in
|
|
24
|
+
`ThinkControl` tests
|
|
25
|
+
- Included tests for combined logic with `think_loud` switch in `ThinkControl`
|
|
26
|
+
tests
|
|
27
|
+
|
|
3
28
|
## 2026-01-08 v0.0.54
|
|
4
29
|
|
|
5
30
|
### New Features
|
data/README.md
CHANGED
|
@@ -183,6 +183,7 @@ The following commands can be given inside the chat, if prefixed by a `/`:
|
|
|
183
183
|
/compose compose content using an EDITOR
|
|
184
184
|
/input [pattern] select and read content from a file (default: **/*)
|
|
185
185
|
/context [pattern...] collect context with glob patterns
|
|
186
|
+
/revise_last edit the last response in an external editor
|
|
186
187
|
/output filename save last response to filename
|
|
187
188
|
/pipe command write last response to command's stdin
|
|
188
189
|
/vim insert the last message into a vim server
|
data/bin/ollama_chat_send
CHANGED
|
@@ -25,7 +25,7 @@ def usage(rc = 0)
|
|
|
25
25
|
-d DIR the working directory to derive the socket file from
|
|
26
26
|
-h Show this help message
|
|
27
27
|
|
|
28
|
-
Send data to a running
|
|
28
|
+
Send data to a running Ollama Chat client via standard input.
|
|
29
29
|
EOT
|
|
30
30
|
exit rc
|
|
31
31
|
end
|
|
@@ -150,6 +150,7 @@ module OllamaChat::Information
|
|
|
150
150
|
/compose compose content using an EDITOR
|
|
151
151
|
/input [pattern] select and read content from a file (default: **/*)
|
|
152
152
|
/context [pattern...] collect context with glob patterns
|
|
153
|
+
/revise_last edit the last response in an external editor
|
|
153
154
|
/output filename save last response to filename
|
|
154
155
|
/pipe command write last response to command's stdin
|
|
155
156
|
/vim insert the last message into a vim server
|
|
@@ -102,7 +102,7 @@ module OllamaChat::InputContent
|
|
|
102
102
|
# @return [ String, nil ] the composed content if successful, nil otherwise
|
|
103
103
|
def compose
|
|
104
104
|
unless editor = OllamaChat::EnvConfig::EDITOR?
|
|
105
|
-
STDERR.puts "Editor
|
|
105
|
+
STDERR.puts "Editor required for compose, set env var "\
|
|
106
106
|
"#{OllamaChat::EnvConfig::EDITOR!.env_var.inspect}."
|
|
107
107
|
return
|
|
108
108
|
end
|
data/lib/ollama_chat/version.rb
CHANGED
data/lib/ollama_chat/vim.rb
CHANGED
|
@@ -27,6 +27,18 @@ class OllamaChat::Vim
|
|
|
27
27
|
@clientserver = clientserver || 'socket'
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
# The server_name attribute reader returns the name of the Vim server to
|
|
31
|
+
# connect to.
|
|
32
|
+
#
|
|
33
|
+
# @return [ String ] the name of the Vim server
|
|
34
|
+
attr_reader :server_name
|
|
35
|
+
|
|
36
|
+
# The clientserver attribute reader returns the clientserver protocol to be
|
|
37
|
+
# used.
|
|
38
|
+
#
|
|
39
|
+
# @return [ String ] the clientserver protocol identifier
|
|
40
|
+
attr_reader :clientserver
|
|
41
|
+
|
|
30
42
|
# The default_server_name method generates a standardized server name
|
|
31
43
|
# based on a given name or the current working directory.
|
|
32
44
|
#
|
|
@@ -54,14 +66,24 @@ class OllamaChat::Vim
|
|
|
54
66
|
# The text is automatically indented to match the current column position.
|
|
55
67
|
#
|
|
56
68
|
# @param text [String] The text to be inserted into the Vim buffer
|
|
69
|
+
# @return [OllamaChat::Vim, nil] Returns self if successful or nil.
|
|
57
70
|
def insert(text)
|
|
58
71
|
spaces = (col - 1).clamp(0..)
|
|
59
72
|
text = text.gsub(/^/, ' ' * spaces)
|
|
60
73
|
Tempfile.open do |tmp|
|
|
61
74
|
tmp.write(text)
|
|
62
75
|
tmp.flush
|
|
63
|
-
system %{
|
|
76
|
+
result = system %{
|
|
77
|
+
vim --clientserver "#@clientserver" --servername "#@server_name" --remote-send "<ESC>:r #{tmp.path}<CR>"
|
|
78
|
+
}
|
|
79
|
+
unless result
|
|
80
|
+
STDERR.puts <<~EOT
|
|
81
|
+
Failed! vim is required in path and running with server name "#@server_name".
|
|
82
|
+
EOT
|
|
83
|
+
return
|
|
84
|
+
end
|
|
64
85
|
end
|
|
86
|
+
self
|
|
65
87
|
end
|
|
66
88
|
|
|
67
89
|
# Returns the current column position of the cursor in the Vim server
|
data/ollama_chat.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: ollama_chat 0.0.
|
|
2
|
+
# stub: ollama_chat 0.0.55 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "ollama_chat".freeze
|
|
6
|
-
s.version = "0.0.
|
|
6
|
+
s.version = "0.0.55".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]
|
|
@@ -13,14 +13,14 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["ollama_chat".freeze, "ollama_chat_send".freeze]
|
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/message_editing.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze]
|
|
16
|
-
s.files = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_chat".freeze, "bin/ollama_chat_send".freeze, "config/searxng/settings.yml".freeze, "docker-compose.yml".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/message_editing.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/ollama_chat_config/default_config.yml".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze, "ollama_chat.gemspec".freeze, "redis/redis.conf".freeze, "spec/assets/api_show.json".freeze, "spec/assets/api_tags.json".freeze, "spec/assets/api_version.json".freeze, "spec/assets/conversation.json".freeze, "spec/assets/duckduckgo.html".freeze, "spec/assets/example.atom".freeze, "spec/assets/example.csv".freeze, "spec/assets/example.html".freeze, "spec/assets/example.pdf".freeze, "spec/assets/example.ps".freeze, "spec/assets/example.rb".freeze, "spec/assets/example.rss".freeze, "spec/assets/example.xml".freeze, "spec/assets/example_with_quote.html".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/prompt.txt".freeze, "spec/assets/searxng.json".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
|
|
16
|
+
s.files = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_chat".freeze, "bin/ollama_chat_send".freeze, "config/searxng/settings.yml".freeze, "docker-compose.yml".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/message_editing.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/ollama_chat_config/default_config.yml".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze, "ollama_chat.gemspec".freeze, "redis/redis.conf".freeze, "spec/assets/api_show.json".freeze, "spec/assets/api_tags.json".freeze, "spec/assets/api_version.json".freeze, "spec/assets/conversation.json".freeze, "spec/assets/duckduckgo.html".freeze, "spec/assets/example.atom".freeze, "spec/assets/example.csv".freeze, "spec/assets/example.html".freeze, "spec/assets/example.pdf".freeze, "spec/assets/example.ps".freeze, "spec/assets/example.rb".freeze, "spec/assets/example.rss".freeze, "spec/assets/example.xml".freeze, "spec/assets/example_with_quote.html".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/prompt.txt".freeze, "spec/assets/searxng.json".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/vim_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
|
|
17
17
|
s.homepage = "https://github.com/flori/ollama_chat".freeze
|
|
18
18
|
s.licenses = ["MIT".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "OllamaChat - A command-line interface (CLI) for interacting with an Ollama AI model.".freeze, "--main".freeze, "README.md".freeze]
|
|
20
20
|
s.required_ruby_version = Gem::Requirement.new(">= 3.2".freeze)
|
|
21
21
|
s.rubygems_version = "4.0.2".freeze
|
|
22
22
|
s.summary = "A command-line interface (CLI) for interacting with an Ollama AI model.".freeze
|
|
23
|
-
s.test_files = ["spec/assets/example.rb".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
23
|
+
s.test_files = ["spec/assets/example.rb".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/vim_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
24
24
|
|
|
25
25
|
s.specification_version = 4
|
|
26
26
|
|
|
@@ -108,7 +108,7 @@ describe OllamaChat::InputContent do
|
|
|
108
108
|
it 'handles missing editor gracefully' do
|
|
109
109
|
const_conf_as('OllamaChat::EnvConfig::EDITOR' => nil)
|
|
110
110
|
|
|
111
|
-
expect(STDERR).to receive(:puts).with(/Editor
|
|
111
|
+
expect(STDERR).to receive(:puts).with(/Editor required for compose/)
|
|
112
112
|
expect(chat.compose).to be_nil
|
|
113
113
|
end
|
|
114
114
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe OllamaChat::ThinkControl do
|
|
4
|
+
let :chat do
|
|
5
|
+
OllamaChat::Chat.new(
|
|
6
|
+
argv: %w[ -f lib/ollama_chat/ollama_chat_config/default_config.yml ]
|
|
7
|
+
)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
connect_to_ollama_server
|
|
11
|
+
|
|
12
|
+
describe '#think' do
|
|
13
|
+
it 'returns the current think mode state' do
|
|
14
|
+
expect(chat.think).to be false
|
|
15
|
+
chat.instance_variable_set(:@think, true)
|
|
16
|
+
expect(chat.think).to be true
|
|
17
|
+
chat.instance_variable_set(:@think, false)
|
|
18
|
+
expect(chat.think).to be false
|
|
19
|
+
chat.instance_variable_set(:@think, 'low')
|
|
20
|
+
expect(chat.think).to eq 'low'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe '#think?' do
|
|
25
|
+
it 'returns true when think mode is enabled (boolean true)' do
|
|
26
|
+
chat.instance_variable_set(:@think, true)
|
|
27
|
+
expect(chat.think?).to be true
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'returns true when think mode is enabled (string value)' do
|
|
31
|
+
chat.instance_variable_set(:@think, 'high')
|
|
32
|
+
expect(chat.think?).to be true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'returns false when think mode is disabled (boolean false)' do
|
|
36
|
+
chat.instance_variable_set(:@think, false)
|
|
37
|
+
expect(chat.think?).to be false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'returns false when think mode is nil' do
|
|
41
|
+
chat.instance_variable_set(:@think, nil)
|
|
42
|
+
expect(chat.think?).to be false
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#think_mode' do
|
|
47
|
+
it 'returns "enabled" when think is true' do
|
|
48
|
+
chat.instance_variable_set(:@think, true)
|
|
49
|
+
expect(chat.think_mode).to eq 'enabled'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'returns the think value when it is a string' do
|
|
53
|
+
chat.instance_variable_set(:@think, 'medium')
|
|
54
|
+
expect(chat.think_mode).to eq 'medium'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'returns "disabled" when think is false' do
|
|
58
|
+
chat.instance_variable_set(:@think, false)
|
|
59
|
+
expect(chat.think_mode).to eq 'disabled'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'returns "disabled" when think is nil' do
|
|
63
|
+
chat.instance_variable_set(:@think, nil)
|
|
64
|
+
expect(chat.think_mode).to eq 'disabled'
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#think_show' do
|
|
69
|
+
it 'displays the current think mode status' do
|
|
70
|
+
chat.instance_variable_set(:@think, true)
|
|
71
|
+
expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1menabled\e\[0m\./)
|
|
72
|
+
chat.think_show
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'displays the think mode level when set to string' do
|
|
76
|
+
chat.instance_variable_set(:@think, 'high')
|
|
77
|
+
expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mhigh\e\[0m\./)
|
|
78
|
+
chat.think_show
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'displays "disabled" when think is false' do
|
|
82
|
+
chat.instance_variable_set(:@think, false)
|
|
83
|
+
expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mdisabled\e\[0m\./)
|
|
84
|
+
chat.think_show
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'displays "disabled" when think is nil' do
|
|
88
|
+
chat.instance_variable_set(:@think, nil)
|
|
89
|
+
expect(STDOUT).to receive(:puts).with(/Think mode is \e\[1mdisabled\e\[0m\./)
|
|
90
|
+
chat.think_show
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe '#think_loud?' do
|
|
95
|
+
it 'returns false when think is disabled' do
|
|
96
|
+
chat.instance_variable_set(:@think, false)
|
|
97
|
+
expect(chat.think_loud?).to be false
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'returns false when think_loud is off' do
|
|
101
|
+
chat.instance_variable_set(:@think, true)
|
|
102
|
+
allow(chat).to receive(:think_loud).and_return(double(on?: false))
|
|
103
|
+
expect(chat.think_loud?).to be false
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'returns true when both think and think_loud are enabled' do
|
|
107
|
+
chat.instance_variable_set(:@think, true)
|
|
108
|
+
allow(chat).to receive(:think_loud).and_return(double(on?: true))
|
|
109
|
+
expect(chat.think_loud?).to be true
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe '#choose_think_mode' do
|
|
114
|
+
it 'can select "off" mode' do
|
|
115
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('off')
|
|
116
|
+
chat.choose_think_mode
|
|
117
|
+
expect(chat.think).to be false
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'can select "on" mode' do
|
|
121
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('on')
|
|
122
|
+
chat.choose_think_mode
|
|
123
|
+
expect(chat.think).to be true
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'can select "low" mode' do
|
|
127
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('low')
|
|
128
|
+
chat.choose_think_mode
|
|
129
|
+
expect(chat.think).to eq 'low'
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'can select "medium" mode' do
|
|
133
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('medium')
|
|
134
|
+
chat.choose_think_mode
|
|
135
|
+
expect(chat.think).to eq 'medium'
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it 'can select "high" mode' do
|
|
139
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('high')
|
|
140
|
+
chat.choose_think_mode
|
|
141
|
+
expect(chat.think).to eq 'high'
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'can exit selection' do
|
|
145
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return('[EXIT]')
|
|
146
|
+
expect { chat.choose_think_mode }.not_to change { chat.think }
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'can handle nil selection' do
|
|
150
|
+
expect(OllamaChat::Utils::Chooser).to receive(:choose).and_return(nil)
|
|
151
|
+
expect { chat.choose_think_mode }.not_to change { chat.think }
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe OllamaChat::Vim do
|
|
4
|
+
let(:server_name) { 'TEST_SERVER' }
|
|
5
|
+
let(:vim) { described_class.new(server_name) }
|
|
6
|
+
|
|
7
|
+
describe '#initialize' do
|
|
8
|
+
it 'can be initialized with a server name' do
|
|
9
|
+
expect(vim.server_name).to eq server_name
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'can be initialized without a server name' do
|
|
13
|
+
vim_without_name = described_class.new(nil)
|
|
14
|
+
expect(vim_without_name.server_name).to be_a(String)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'uses socket as default clientserver protocol' do
|
|
18
|
+
expect(vim.clientserver).to eq 'socket'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'can specify clientserver protocol' do
|
|
22
|
+
vim_with_protocol = described_class.new(server_name, clientserver: 'pipe')
|
|
23
|
+
expect(vim_with_protocol.clientserver).to eq 'pipe'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '.default_server_name' do
|
|
28
|
+
it 'generates a standardized server name from a directory' do
|
|
29
|
+
name = described_class.default_server_name('/path/to/project')
|
|
30
|
+
expect(name).to match(/\A[A-Z0-9]+-[A-Z0-9]+\z/)
|
|
31
|
+
expect(name).to include('PROJECT')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'handles current working directory' do
|
|
35
|
+
name = described_class.default_server_name
|
|
36
|
+
expect(name).to be_a(String)
|
|
37
|
+
expect(name).to_not be_empty
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'generates consistent names for same path' do
|
|
41
|
+
name1 = described_class.default_server_name('/tmp/test')
|
|
42
|
+
name2 = described_class.default_server_name('/tmp/test')
|
|
43
|
+
expect(name1).to eq name2
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '#insert' do
|
|
48
|
+
it 'can insert text into vim' do
|
|
49
|
+
expect(vim).to receive(:`).with(
|
|
50
|
+
/vim.*--remote-expr.*col\('\.'\)/
|
|
51
|
+
).and_return("5\n")
|
|
52
|
+
# Mock the system call to avoid actual vim interaction
|
|
53
|
+
expect(vim).to receive(:system).with(
|
|
54
|
+
/vim.*--servername.*#{server_name}.*--remote-send/
|
|
55
|
+
)
|
|
56
|
+
vim.insert('test content')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'handles text indentation' do
|
|
60
|
+
# Mock the col method to return a specific column
|
|
61
|
+
expect(vim).to receive(:`).with(
|
|
62
|
+
/vim.*--remote-expr.*col\('\.'\)/).and_return("5\n"
|
|
63
|
+
)
|
|
64
|
+
tmp = double('Tempfile', flush: true, path: '/tmp/test')
|
|
65
|
+
expect(Tempfile).to receive(:open).and_yield(tmp)
|
|
66
|
+
expect(tmp).to receive(:write).with(' test content')
|
|
67
|
+
expect(vim).to receive(:system).with(
|
|
68
|
+
/vim --clientserver.*--servername.*--remote-send.*\/tmp\/test/
|
|
69
|
+
).and_return true
|
|
70
|
+
vim.insert('test content')
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe '#col' do
|
|
75
|
+
it 'can get current column position' do
|
|
76
|
+
# Mock the system call to return a specific column
|
|
77
|
+
expect(vim).to receive(:`).with(
|
|
78
|
+
/vim.*--remote-expr.*col\('\.'\)/
|
|
79
|
+
).and_return("5\n")
|
|
80
|
+
expect(vim.col).to eq 5
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'handles empty response' do
|
|
84
|
+
expect(vim).to receive(:`).and_return("\n")
|
|
85
|
+
expect(vim.col).to eq 0
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
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.
|
|
4
|
+
version: 0.0.55
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -517,9 +517,11 @@ files:
|
|
|
517
517
|
- spec/ollama_chat/server_socket_spec.rb
|
|
518
518
|
- spec/ollama_chat/source_fetching_spec.rb
|
|
519
519
|
- spec/ollama_chat/switches_spec.rb
|
|
520
|
+
- spec/ollama_chat/think_control_spec.rb
|
|
520
521
|
- spec/ollama_chat/utils/cache_fetcher_spec.rb
|
|
521
522
|
- spec/ollama_chat/utils/fetcher_spec.rb
|
|
522
523
|
- spec/ollama_chat/utils/file_argument_spec.rb
|
|
524
|
+
- spec/ollama_chat/vim_spec.rb
|
|
523
525
|
- spec/ollama_chat/web_searching_spec.rb
|
|
524
526
|
- spec/spec_helper.rb
|
|
525
527
|
- tmp/.keep
|
|
@@ -565,8 +567,10 @@ test_files:
|
|
|
565
567
|
- spec/ollama_chat/server_socket_spec.rb
|
|
566
568
|
- spec/ollama_chat/source_fetching_spec.rb
|
|
567
569
|
- spec/ollama_chat/switches_spec.rb
|
|
570
|
+
- spec/ollama_chat/think_control_spec.rb
|
|
568
571
|
- spec/ollama_chat/utils/cache_fetcher_spec.rb
|
|
569
572
|
- spec/ollama_chat/utils/fetcher_spec.rb
|
|
570
573
|
- spec/ollama_chat/utils/file_argument_spec.rb
|
|
574
|
+
- spec/ollama_chat/vim_spec.rb
|
|
571
575
|
- spec/ollama_chat/web_searching_spec.rb
|
|
572
576
|
- spec/spec_helper.rb
|