ollama_chat 0.0.33 → 0.0.34

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: 7f2ffa19191743f1d9b41bfb72893dba9ca6e1e26836ed4c553a52b1c13f29ca
4
- data.tar.gz: 83bc423d7f4daf9cda26a69c05858a300957c82cc74071285ee05c4afc734281
3
+ metadata.gz: 1285d76eebf4b0382986bb3bcf9d3d3df08bbf95e2d8b7fd5bf82c60baf82e79
4
+ data.tar.gz: '0384dce9df4bbb3ebe371dedb09fb8ef8697950f8b0b2e3960038e93fc0a67b6'
5
5
  SHA512:
6
- metadata.gz: 9064c4a0b0ada0f57b2fca76c1665296f60607ec284a93f9e172aa83e6c36876a025caaec37dc84aa95ca1ad00e29a19bd93e93046bd8b07d21d54c31cfa5d7e
7
- data.tar.gz: 37f74dfca1c4bee0946f56136d00b098303b69fe735bd84f9e3a6d1bb3f6ff59c4d1f03be9de7b451714b4909ece0a769cf9931c46b7c89d87bf0c3b53ebc98e
6
+ metadata.gz: d161dba8d86bdd135395b4b5949dd721544b4bdb475904cb2642733762c5aee00a0176399048582b304aa02140aa9317f2c7a78cae0df8082b4776d146105ebb
7
+ data.tar.gz: ac519d43fb532ac993fe396c9afbdd71e65fef7fd4ac42b4be9f04067ae6df684b8cbd0574d409ebe3388ce9d5603abbbc725a2ae323ce8725200efab3f8f539
data/CHANGES.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changes
2
2
 
3
+ ## 2025-09-17 v0.0.34
4
+
5
+ - Modified `-d` flag semantics to use working directory instead of runtime
6
+ directory for socket path derivation
7
+ - Updated `send_to_server_socket` and `create_socket_server` methods to accept
8
+ `working_dir` parameter
9
+ - Changed argument parsing in `ollama_chat_send` binary to utilize
10
+ `working_dir` instead of `runtime_dir`
11
+ - Updated documentation and help text to reflect new `-d` option semantics
12
+ - Added tests covering new `working_dir` functionality with default fallback to
13
+ current directory
14
+ - Maintained backward compatibility by preserving existing `runtime_dir`
15
+ behavior when specified
16
+ - Modified method signatures to support both old and new parameter styles
17
+
3
18
  ## 2025-09-15 v0.0.33
4
19
 
5
20
  - Enhanced `CONTENT_REGEXP` to support escaped spaces in file paths using
data/README.md CHANGED
@@ -228,6 +228,16 @@ The `ollama_chat_send` command now supports additional parameters to enhance fun
228
228
  $ echo "Visit https://example.com for more info" | ollama_chat_send -p
229
229
  ```
230
230
 
231
+ - **Working Directory (`-d`)**: Specifies the working directory used to derive
232
+ the Unix socket file path. When the ollama chat configuration is set to use a
233
+ working directory dependent socket (via `working_dir_dependent_socket: true`),
234
+ this option determines the base path for socket naming. If not specified, the
235
+ current working directory is assumed.
236
+
237
+ ```bash
238
+ $ echo "Hello world" | ollama_chat_send -d /tmp/my_working_dir -r
239
+ ```
240
+
231
241
  - **Runtime Directory (`-d`)**: Specifies the directory where the Unix socket
232
242
  file of `ollama_chat` was created, if you want to send to a specific
233
243
  `ollama_chat`.
data/bin/ollama_chat_send CHANGED
@@ -4,9 +4,15 @@ require 'ollama_chat'
4
4
  require 'tins/go'
5
5
  include Tins::GO
6
6
 
7
-
8
7
  opts = go 'f:d:rtph', ARGV
9
8
 
9
+ # Displays the usage information for the ollama_chat_send command.
10
+ #
11
+ # This method outputs a formatted help message that describes the available
12
+ # options and usage of the ollama_chat_send command, including details about
13
+ # sending input to a running Ollama Chat client.
14
+ #
15
+ # @param rc [ Integer ] the exit code to use when exiting the program
10
16
  def usage(rc = 0)
11
17
  puts <<~EOT
12
18
  Usage: #{File.basename($0)} [OPTIONS]
@@ -16,7 +22,7 @@ def usage(rc = 0)
16
22
  -t Send input as terminal input including commands, e. g. /import
17
23
  -p Send input with source parsing enabled (defaults to disabled)
18
24
  -f CONFIG file to read
19
- -d DIR the runtime directory to look for the socket file
25
+ -d DIR the working directory to derive the socket file from
20
26
  -h Show this help message
21
27
 
22
28
  Send data to a running Ollame Chat client via standard input.
@@ -36,8 +42,8 @@ begin
36
42
  STDIN.read,
37
43
  type:,
38
44
  config:,
39
- runtime_dir: opts[?d],
40
- parse: !!opts[?p]
45
+ working_dir: opts[?d],
46
+ parse: !!opts[?p]
41
47
  )
42
48
  type == :socket_input_with_response and puts response.content
43
49
  rescue => e
@@ -38,12 +38,13 @@ module OllamaChat::ServerSocket
38
38
  # @param config [ ComplexConfig::Settings ] the configuration object containing server settings
39
39
  # @param type [ Symbol ] the type of message transmission, defaults to :socket_input
40
40
  # @param runtime_dir [ String ] pathname to runtime_dir of socket file
41
+ # @param working_dir [ String ] pathname to working_dir used for deriving socket file
41
42
  # @param parse [ TrueClass, FalseClass ] whether to parse the response, defaults to false
42
43
  #
43
44
  # @return [ UnixSocks::Message, nil ] the response from transmit_with_response if type
44
45
  # is :socket_input_with_response, otherwise nil
45
- def send_to_server_socket(content, config:, type: :socket_input, runtime_dir: nil, parse: false)
46
- server = create_socket_server(config:, runtime_dir:)
46
+ def send_to_server_socket(content, config:, type: :socket_input, runtime_dir: nil, working_dir: nil, parse: false)
47
+ server = create_socket_server(config:, runtime_dir:, working_dir:)
47
48
  message = { content:, type:, parse: }
48
49
  if type.to_sym == :socket_input_with_response
49
50
  server.transmit_with_response(message)
@@ -65,15 +66,18 @@ module OllamaChat::ServerSocket
65
66
  #
66
67
  # @param config [ComplexConfig::Settings] the configuration object
67
68
  # containing server settings
69
+ # @param runtime_dir [ String ] pathname to runtime_dir of socket file
70
+ # @param working_dir [ String ] pathname to working_dir used for deriving socket file
68
71
  #
69
72
  # @return [UnixSocks::Server] a configured Unix domain socket server
70
73
  # instance ready to receive messages
71
- def create_socket_server(config:, runtime_dir: nil)
74
+ def create_socket_server(config:, runtime_dir: nil, working_dir: nil)
75
+ working_dir ||= Dir.pwd
72
76
  if runtime_dir
73
77
  return UnixSocks::Server.new(socket_name: 'ollama_chat.sock', runtime_dir:)
74
78
  end
75
79
  if config.working_dir_dependent_socket
76
- path = File.expand_path(Dir.pwd)
80
+ path = File.expand_path(working_dir)
77
81
  digest = Digest::MD5.hexdigest(path)
78
82
  UnixSocks::Server.new(socket_name: "ollama_chat-#{digest}.sock")
79
83
  else
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.33'
3
+ VERSION = '0.0.34'
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.33 ruby lib
2
+ # stub: ollama_chat 0.0.34 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama_chat".freeze
6
- s.version = "0.0.33".freeze
6
+ s.version = "0.0.34".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,7 +13,7 @@ describe OllamaChat::ServerSocket do
13
13
 
14
14
  before do
15
15
  expect(OllamaChat::ServerSocket).to receive(:create_socket_server).
16
- with(config: config, runtime_dir: nil).and_return(server)
16
+ with(config: config, runtime_dir: nil, working_dir: nil).and_return(server)
17
17
  end
18
18
 
19
19
  context 'with default parameters' do
@@ -50,7 +50,8 @@ describe OllamaChat::ServerSocket do
50
50
  message = { content: 'test', type: :socket_input_with_response, parse: false }
51
51
  response = double('Response')
52
52
 
53
- expect(server).to receive(:transmit_with_response).with(message).and_return(response)
53
+ expect(server).to receive(:transmit_with_response).with(message).
54
+ and_return(response)
54
55
 
55
56
  result = OllamaChat::ServerSocket.send_to_server_socket(
56
57
  'test',
@@ -68,7 +69,8 @@ describe OllamaChat::ServerSocket do
68
69
  message = { content: 'test', type: :socket_input_with_response, parse: true }
69
70
  response = double('Response')
70
71
 
71
- expect(server).to receive(:transmit_with_response).with(message).and_return(response)
72
+ expect(server).to receive(:transmit_with_response).with(message).
73
+ and_return(response)
72
74
 
73
75
  result = OllamaChat::ServerSocket.send_to_server_socket(
74
76
  'test',
@@ -82,10 +84,32 @@ describe OllamaChat::ServerSocket do
82
84
  end
83
85
  end
84
86
 
87
+ context 'with working_dir' do
88
+ before do
89
+ expect(OllamaChat::ServerSocket).to receive(:create_socket_server).
90
+ with(config: config, runtime_dir: nil, working_dir: 'foo/path').
91
+ and_return(server)
92
+ end
93
+
94
+ context 'with working_dir parameter' do
95
+ it 'uses correct parameter' do
96
+ message = { content: 'test', type: :socket_input, parse: false }
97
+ expect(server).to receive(:transmit).with(message).and_return(nil)
98
+
99
+ result = OllamaChat::ServerSocket.send_to_server_socket(
100
+ 'test', config: config, working_dir: 'foo/path'
101
+ )
102
+
103
+ expect(result).to be_nil
104
+ end
105
+ end
106
+ end
107
+
85
108
  context 'with runtime_dir parameter' do
86
109
  before do
87
110
  expect(OllamaChat::ServerSocket).to receive(:create_socket_server).
88
- with(config: config, runtime_dir: '/foo/bar').and_return(server)
111
+ with(config: config, runtime_dir: '/foo/bar', working_dir: nil).
112
+ and_return(server)
89
113
  end
90
114
 
91
115
  it 'uses correct defaults' do
@@ -94,7 +118,9 @@ describe OllamaChat::ServerSocket do
94
118
  expect(server).to receive(:transmit).with(message).and_return(nil)
95
119
 
96
120
 
97
- result = OllamaChat::ServerSocket.send_to_server_socket('test', config: config, runtime_dir: '/foo/bar')
121
+ result = OllamaChat::ServerSocket.send_to_server_socket(
122
+ 'test', config: config, runtime_dir: '/foo/bar'
123
+ )
98
124
 
99
125
  expect(result).to be_nil
100
126
  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.33
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank