ollama_chat 0.0.141 → 0.0.143
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 +63 -0
- data/lib/ollama_chat/database/models/app_state.rb +17 -2
- data/lib/ollama_chat/information.rb +1 -1
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +6 -3
- data/lib/ollama_chat/prompt_handling.rb +15 -0
- data/lib/ollama_chat/prompt_management.rb +75 -18
- data/lib/ollama_chat/tools/execute_jira_twg.rb +3 -4
- data/lib/ollama_chat/version.rb +1 -1
- data/ollama_chat.gemspec +3 -3
- data/spec/ollama_chat/prompt_handling_spec.rb +3 -3
- data/spec/ollama_chat/prompt_management_spec.rb +2 -2
- data/spec/ollama_chat/tools/execute_jira_twg_spec.rb +89 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bcd32949a2267da25e4106d1c9a4eea74e11a0822d328a88bfd4848c1ba5bd7b
|
|
4
|
+
data.tar.gz: 6eaa4fcb585bb23425da25e48d38f1e6c066c12149c54033b782835148315db0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8919a0efaced88d859bb0c003c1e5a21516c582c5e6ae540e3b766eeeca9150fa1a1f0ecd88631dea11247908704ba40e3724cbb2496e83c259010dbccf94ff1
|
|
7
|
+
data.tar.gz: cbdbb312c30ee11c5a5c093c13078b9947298cf1bd612659c2da49b8a6f288f1b96702686546dc1f7b058917cf9356a52422c8d3b4bc9a6b9772c965d7d9179d
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-11-11 v0.0.143
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Scoped `AppState.acknowledge` to a single prompt context to prevent `/prompt
|
|
8
|
+
sync -c <context>` from clearing the drift warning (`⚠`) for unrelated
|
|
9
|
+
contexts (e.g., `report`, `compaction`).
|
|
10
|
+
- `AppState.acknowledge` now accepts an optional `context:` keyword argument.
|
|
11
|
+
When provided, it surgically updates only the hashes for that specific
|
|
12
|
+
context, preserving the stored hashes for all other contexts.
|
|
13
|
+
|
|
14
|
+
### Improvements
|
|
15
|
+
|
|
16
|
+
- `prompt_sync` now passes its `context:` argument through to
|
|
17
|
+
`AppState.acknowledge`, ensuring that only the resolved context's nagging
|
|
18
|
+
state is cleared.
|
|
19
|
+
|
|
20
|
+
## 2026-11-11 v0.0.142
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
- Added status markers to the prompt context chooser (`choose_prompt_context`)
|
|
25
|
+
to indicate drift status: `⚠` when shipped config changed since last
|
|
26
|
+
acknowledge, `📌` when drifted but shipped config is unchanged, and no marker
|
|
27
|
+
when in sync.
|
|
28
|
+
- Updated `list_prompts` to display a trailing `📝` marker for user variants,
|
|
29
|
+
while default prompts remain unmarked.
|
|
30
|
+
|
|
31
|
+
### Fixes
|
|
32
|
+
|
|
33
|
+
- Fixed `execute_jira_twg` to replace bare braces (`{` or `[`) in the first
|
|
34
|
+
line of pretty-printed JSON output with `(structured result)`, preventing
|
|
35
|
+
confusing single-character messages.
|
|
36
|
+
- Resolved false positives in `prompt_sync` drift detection by normalizing
|
|
37
|
+
trailing newlines on both shipped and database-stored prompt content using
|
|
38
|
+
`ensure_trailing_newline`.
|
|
39
|
+
|
|
40
|
+
### Improvements
|
|
41
|
+
|
|
42
|
+
- Relocated `current_directory` from `static_runtime_information_values` to
|
|
43
|
+
`dynamic_runtime_information_values` in `information.rb` to maintain a
|
|
44
|
+
byte-stable system prompt prefix across repository switches, preserving LLM
|
|
45
|
+
engine prefix cache efficiency.
|
|
46
|
+
- Extracted drift and orphan computation logic into a private `context_drift`
|
|
47
|
+
method and added `context_shipped_changed?` to share code paths between the
|
|
48
|
+
prompt chooser and `prompt_sync`.
|
|
49
|
+
- Added `ensure_trailing_newline` to `prompt_handling.rb` to canonicalize
|
|
50
|
+
prompt content as if written with a YAML block scalar, ensuring consistent
|
|
51
|
+
newline termination for all DB-stored prompts.
|
|
52
|
+
- Updated `default_config.yml` to add `**Environment**:` and `**State**:`
|
|
53
|
+
headings to the `static_runtime_info` and `dynamic_runtime_info` templates,
|
|
54
|
+
respectively.
|
|
55
|
+
|
|
56
|
+
### Testing
|
|
57
|
+
|
|
58
|
+
- Added specs for `execute_jira_twg` covering pretty-printed JSON, JSON arrays,
|
|
59
|
+
and plain-text output scenarios.
|
|
60
|
+
- Updated `choose_prompt_context` spec to mock `choose_entry` returning a
|
|
61
|
+
`SearchUI::Wrapper`.
|
|
62
|
+
- Updated spec assertions in `prompt_handling_spec.rb` and
|
|
63
|
+
`prompt_management_spec.rb` to expect canonical trailing newlines in prompt
|
|
64
|
+
content.
|
|
65
|
+
|
|
3
66
|
## 2026-11-06 v0.0.141
|
|
4
67
|
|
|
5
68
|
### Improvements
|
|
@@ -101,9 +101,24 @@ class OllamaChat::Database::Models::AppState < Sequel::Model(OllamaChat::DB)
|
|
|
101
101
|
# drift notification. Called after `/prompt sync` so the user is not
|
|
102
102
|
# nagged again on the next launch.
|
|
103
103
|
#
|
|
104
|
+
# When a specific `context` is given, only that context's hashes are
|
|
105
|
+
# refreshed; the remaining contexts keep their stored hashes so their
|
|
106
|
+
# ⚠ marker persists until they are individually synced.
|
|
107
|
+
#
|
|
104
108
|
# @param chat [OllamaChat::Chat] the chat instance providing the config
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
# @param context [String, nil] optionally scope the acknowledge to a
|
|
110
|
+
# single prompt context
|
|
111
|
+
def self.acknowledge(chat, context: nil)
|
|
112
|
+
hashes = compute_hashes(chat.config.prompts)
|
|
113
|
+
|
|
114
|
+
if context
|
|
115
|
+
prefix = "#{context}/"
|
|
116
|
+
stored = get(:prompt_defaults_fingerprint)
|
|
117
|
+
existing = stored&.dig('hashes') || {}
|
|
118
|
+
hashes = existing.reject { |k, _| k.start_with?(prefix) }
|
|
119
|
+
.merge(hashes.select { |k, _| k.start_with?(prefix) })
|
|
120
|
+
end
|
|
121
|
+
|
|
107
122
|
fingerprint = fingerprint_from(hashes)
|
|
108
123
|
store_fingerprint(fingerprint, hashes)
|
|
109
124
|
end
|
|
@@ -339,7 +339,6 @@ module OllamaChat::Information
|
|
|
339
339
|
def static_runtime_information_values
|
|
340
340
|
{
|
|
341
341
|
client: ,
|
|
342
|
-
current_directory: Pathname.pwd.expand_path.to_path,
|
|
343
342
|
languages: config.languages * ', ',
|
|
344
343
|
location: location.on?.full? { location_description } || 'n/a',
|
|
345
344
|
machine: machine_profile || 'n/a',
|
|
@@ -385,6 +384,7 @@ module OllamaChat::Information
|
|
|
385
384
|
def dynamic_runtime_information_values
|
|
386
385
|
now = Time.now
|
|
387
386
|
{
|
|
387
|
+
current_directory: Pathname.pwd.expand_path.to_path,
|
|
388
388
|
git_current_branch: `git rev-parse --abbrev-ref HEAD 2>/dev/null`.chomp.full? || 'n/a',
|
|
389
389
|
git_remote_origin: `git remote get-url origin 2>/dev/null`.chomp.full? || 'n/a',
|
|
390
390
|
git_sha: `git rev-parse HEAD 2>/dev/null`.chomp.full? || 'n/a',
|
|
@@ -51,16 +51,19 @@ prompts:
|
|
|
51
51
|
%{results}
|
|
52
52
|
location: You are at %{location_name}, %{location_decimal_degrees}, preferring %{units}
|
|
53
53
|
static_runtime_info: |
|
|
54
|
+
**Environment**:
|
|
54
55
|
- Name of the chat user: %{user}
|
|
55
56
|
- Languages the user prefers: %{languages}
|
|
56
57
|
- Location: %{location}
|
|
57
|
-
- Current directory is "%{current_directory}"
|
|
58
58
|
- Client is %{client}.
|
|
59
59
|
- Machine: %{machine}
|
|
60
60
|
dynamic_runtime_info: |
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
**State**:
|
|
62
|
+
|
|
63
|
+
There is usually no reason to mention this state information to the user
|
|
64
|
+
unless asked about it.
|
|
63
65
|
|
|
66
|
+
- Current directory is "%{current_directory}"
|
|
64
67
|
- Current time is %{weekday}, %{time}
|
|
65
68
|
- **Git**:
|
|
66
69
|
- Current branch is %{git_current_branch}
|
|
@@ -66,6 +66,7 @@ module OllamaChat::PromptHandling
|
|
|
66
66
|
# @return [OllamaChat::Database::Models::Prompt] the created or updated
|
|
67
67
|
# prompt model instance
|
|
68
68
|
def write_prompt(name, content, context: nil)
|
|
69
|
+
content = ensure_trailing_newline(content)
|
|
69
70
|
context = (context || 'prompt').to_s
|
|
70
71
|
obj = nil
|
|
71
72
|
if found = models::Prompt.where(context:, name: name.to_s).first
|
|
@@ -95,5 +96,19 @@ module OllamaChat::PromptHandling
|
|
|
95
96
|
content
|
|
96
97
|
end
|
|
97
98
|
|
|
99
|
+
private
|
|
98
100
|
|
|
101
|
+
# Normalizes prompt content to the canonical trailing-newline form, i.e.
|
|
102
|
+
# as if the value were always written with a `|` block scalar in YAML
|
|
103
|
+
# (which always carries a final newline). Plain-scalar YAML prompts (no
|
|
104
|
+
# trailing newline) and block-scalar ones then compare equal, and diff
|
|
105
|
+
# tooling that preserves final newlines stays consistent.
|
|
106
|
+
#
|
|
107
|
+
# Non-destructive: content already ending in a newline is returned as-is.
|
|
108
|
+
#
|
|
109
|
+
# @param str [String, nil] the prompt content
|
|
110
|
+
# @return [String, nil] the content, guaranteed to end with a newline
|
|
111
|
+
def ensure_trailing_newline(str)
|
|
112
|
+
str&.sub(/\n?\z/, ?\n)
|
|
113
|
+
end
|
|
99
114
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'tmpdir'
|
|
2
|
+
require 'digest'
|
|
2
3
|
|
|
3
4
|
# Provides administrative and interactive management for
|
|
4
5
|
# prompt templates stored in the database.
|
|
@@ -26,23 +27,42 @@ module OllamaChat::PromptManagement
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
# The choose_prompt_context method presents a menu of available prompt
|
|
29
|
-
# contexts for selection.
|
|
30
|
-
#
|
|
30
|
+
# contexts for selection. A context is suffixed with a status marker only
|
|
31
|
+
# when it differs from the shipped defaults:
|
|
32
|
+
#
|
|
33
|
+
# ⚠ drifted and shipped config changed since last acknowledge
|
|
34
|
+
# 📌 drifted but shipped config unchanged (your variant)
|
|
35
|
+
#
|
|
36
|
+
# (no marker) in sync with shipped defaults
|
|
31
37
|
#
|
|
32
38
|
# @return [String, nil] the selected context name, or nil if the user
|
|
33
39
|
# cancels the selection.
|
|
34
40
|
def choose_prompt_context
|
|
35
|
-
contexts = models::Prompt
|
|
36
|
-
|
|
41
|
+
contexts = models::Prompt
|
|
42
|
+
.group(:context).order(:context).pluck(:context)
|
|
43
|
+
|
|
44
|
+
entries = contexts.map do |ctx|
|
|
45
|
+
drifted, orphans, _ = context_drift(ctx)
|
|
46
|
+
marker = if drifted.empty? && orphans.empty?
|
|
47
|
+
''
|
|
48
|
+
elsif context_shipped_changed?(ctx)
|
|
49
|
+
" \u26A0"
|
|
50
|
+
else
|
|
51
|
+
" \u{1F4CC}"
|
|
52
|
+
end
|
|
53
|
+
SearchUI::Wrapper.new(ctx, display: "#{ctx}#{marker}")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
entries.unshift('[EXIT]')
|
|
37
57
|
case chosen = choose_entry(
|
|
38
|
-
|
|
58
|
+
entries,
|
|
39
59
|
prompt: '📝 Which prompt context shall we work in? %s'
|
|
40
60
|
)
|
|
41
61
|
when '[EXIT]', nil
|
|
42
62
|
feedback("Exiting chooser.")
|
|
43
63
|
return
|
|
44
|
-
|
|
45
|
-
chosen
|
|
64
|
+
when SearchUI::Wrapper
|
|
65
|
+
chosen.value
|
|
46
66
|
end
|
|
47
67
|
end
|
|
48
68
|
|
|
@@ -377,8 +397,8 @@ module OllamaChat::PromptManagement
|
|
|
377
397
|
context ||= 'prompt'
|
|
378
398
|
favs = all_favourited(context)
|
|
379
399
|
each_prompt(context:).sort_by(&:name).map do |p|
|
|
380
|
-
default = p.metadata['default'] ? '
|
|
381
|
-
start =
|
|
400
|
+
default = p.metadata['default'] ? '' : " \u{1F4DD}"
|
|
401
|
+
start = [ bold { p.name }, default ] * ''
|
|
382
402
|
start = prefix_favourite(start, favs[p.name])
|
|
383
403
|
content = p.to_s.inspect[1..-2]
|
|
384
404
|
content = truncate(
|
|
@@ -468,14 +488,7 @@ module OllamaChat::PromptManagement
|
|
|
468
488
|
# @return [self, nil] self on success, nil if no drift was found
|
|
469
489
|
def prompt_sync(context: nil)
|
|
470
490
|
context ||= 'prompt'
|
|
471
|
-
shipped
|
|
472
|
-
db_prompts = each_prompt(context:, default: true).to_a
|
|
473
|
-
|
|
474
|
-
drifted = db_prompts.select do |p|
|
|
475
|
-
shipped.key?(p.name) && shipped[p.name].to_s != p.to_s
|
|
476
|
-
end
|
|
477
|
-
|
|
478
|
-
orphans = db_prompts.select { |p| !shipped.key?(p.name) }
|
|
491
|
+
drifted, orphans, shipped = context_drift(context)
|
|
479
492
|
|
|
480
493
|
if drifted.empty? && orphans.empty?
|
|
481
494
|
feedback("All prompts in context #{bold{context}} are in sync. ✨", type: :success)
|
|
@@ -519,12 +532,56 @@ module OllamaChat::PromptManagement
|
|
|
519
532
|
end
|
|
520
533
|
end
|
|
521
534
|
|
|
522
|
-
models::AppState.acknowledge(self)
|
|
535
|
+
models::AppState.acknowledge(self, context:)
|
|
523
536
|
self
|
|
524
537
|
end
|
|
525
538
|
|
|
526
539
|
private
|
|
527
540
|
|
|
541
|
+
# Computes drift (content differences) and orphans (DB prompts missing
|
|
542
|
+
# from shipped config) for a single context.
|
|
543
|
+
#
|
|
544
|
+
# @param context [String] the prompt context
|
|
545
|
+
# @return [Array] [drifted, orphans, shipped] where drifted/orphans are
|
|
546
|
+
# arrays of Prompt models and shipped is the config hash
|
|
547
|
+
def context_drift(context)
|
|
548
|
+
shipped = config.prompts[context]&.to_h&.stringify_keys_recursive || {}
|
|
549
|
+
db_prompts = each_prompt(context:, default: true).to_a
|
|
550
|
+
|
|
551
|
+
drifted = db_prompts.select do |p|
|
|
552
|
+
shipped.key?(p.name) &&
|
|
553
|
+
ensure_trailing_newline(shipped[p.name].to_s) !=
|
|
554
|
+
ensure_trailing_newline(p.to_s)
|
|
555
|
+
end
|
|
556
|
+
orphans = db_prompts.select { |p| !shipped.key?(p.name) }
|
|
557
|
+
[drifted, orphans, shipped]
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
# Returns true if the shipped config for a context differs from the
|
|
561
|
+
# last-acknowledged state (i.e. the app shipped new or changed prompts
|
|
562
|
+
# since the user last saw the boot notification or ran /prompt sync).
|
|
563
|
+
#
|
|
564
|
+
# @param context [String] the prompt context
|
|
565
|
+
# @return [Boolean] true if shipped content changed
|
|
566
|
+
def context_shipped_changed?(context)
|
|
567
|
+
stored = models::AppState
|
|
568
|
+
.get(:prompt_defaults_fingerprint)&.dig('hashes') || {}
|
|
569
|
+
shipped = config.prompts[context]&.to_h&.stringify_keys_recursive || {}
|
|
570
|
+
prefix = "#{context}/"
|
|
571
|
+
|
|
572
|
+
current_keys = shipped.keys.map { |n| "#{prefix}#{n}" }
|
|
573
|
+
stored_keys = stored.keys.select { |k| k.start_with?(prefix) }
|
|
574
|
+
|
|
575
|
+
return true if (current_keys - stored_keys).any?
|
|
576
|
+
return true if (stored_keys - current_keys).any?
|
|
577
|
+
|
|
578
|
+
shipped.any? do |name, content|
|
|
579
|
+
key = "#{prefix}#{name}"
|
|
580
|
+
stored.key?(key) &&
|
|
581
|
+
stored[key] != Digest::SHA256.hexdigest(content.to_s)
|
|
582
|
+
end
|
|
583
|
+
end
|
|
584
|
+
|
|
528
585
|
# Helper to wrap a prompt name with its favourite status for the UI.
|
|
529
586
|
#
|
|
530
587
|
# @param name [String] the name of the prompt
|
|
@@ -69,10 +69,9 @@ class OllamaChat::Tools::ExecuteJIRATWG
|
|
|
69
69
|
"twg #{command} exited with code #{status}:\n#{result}"
|
|
70
70
|
end
|
|
71
71
|
chat.log(:info, 'TWG executed', data: { tool: name, command: })
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
72
|
+
first = result.lines.map(&:strip).reject(&:empty?).first
|
|
73
|
+
first = '(structured result)' if first =~ /^[\[\{]$/
|
|
74
|
+
message = Kramdown::ANSI::Width.truncate(first || '(empty)', percentage: 90)
|
|
76
75
|
{ cmd:, result:, message: }.to_json
|
|
77
76
|
rescue => e
|
|
78
77
|
chat.log(:error, e, data: { tool: name, command: })
|
data/lib/ollama_chat/version.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# by hand; it is rewritten on every `rake version` invocation.
|
|
6
6
|
module OllamaChat
|
|
7
7
|
# The current version of the OllamaChat gem as a String.
|
|
8
|
-
VERSION = '0.0.
|
|
8
|
+
VERSION = '0.0.143'
|
|
9
9
|
VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
|
|
10
10
|
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
|
11
11
|
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.
|
|
2
|
+
# stub: ollama_chat 0.0.143 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.143".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]
|
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
|
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
|
-
s.rubygems_version = "4.0.
|
|
21
|
+
s.rubygems_version = "4.0.24".freeze
|
|
22
22
|
s.summary = "A command-line interface (CLI) for interacting with an Ollama AI model.".freeze
|
|
23
23
|
s.test_files = ["spec/assets/example.rb".freeze, "spec/ollama_chat/asr_spec.rb".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/collection_search_spec.rb".freeze, "spec/ollama_chat/command_concern_spec.rb".freeze, "spec/ollama_chat/commands_spec.rb".freeze, "spec/ollama_chat/compaction_spec.rb".freeze, "spec/ollama_chat/config_handling_spec.rb".freeze, "spec/ollama_chat/context_usage_spec.rb".freeze, "spec/ollama_chat/conversation_spec.rb".freeze, "spec/ollama_chat/database/models/favourite_spec.rb".freeze, "spec/ollama_chat/favourites_management_spec.rb".freeze, "spec/ollama_chat/file_editing_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/history_spec.rb".freeze, "spec/ollama_chat/http_handling_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/invidious_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/message_spec.rb".freeze, "spec/ollama_chat/model_handling/model_cache_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/personae_management_spec.rb".freeze, "spec/ollama_chat/prompt_handling_spec.rb".freeze, "spec/ollama_chat/prompt_management_spec.rb".freeze, "spec/ollama_chat/rag_handling_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/session_management_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/speaker_spec.rb".freeze, "spec/ollama_chat/state_selectors_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/system_prompt_management_spec.rb".freeze, "spec/ollama_chat/think_control_spec.rb".freeze, "spec/ollama_chat/token_estimator_spec.rb".freeze, "spec/ollama_chat/tool_call_processor_spec.rb".freeze, "spec/ollama_chat/tool_calling_spec.rb".freeze, "spec/ollama_chat/tools/browse_spec.rb".freeze, "spec/ollama_chat/tools/compute_bmi_spec.rb".freeze, "spec/ollama_chat/tools/concern_spec.rb".freeze, "spec/ollama_chat/tools/copy_to_clipboard_spec.rb".freeze, "spec/ollama_chat/tools/delete_file_spec.rb".freeze, "spec/ollama_chat/tools/execute_grep_spec.rb".freeze, "spec/ollama_chat/tools/execute_jira_twg_spec.rb".freeze, "spec/ollama_chat/tools/execute_ri_spec.rb".freeze, "spec/ollama_chat/tools/execute_shell_spec.rb".freeze, "spec/ollama_chat/tools/forget_spec.rb".freeze, "spec/ollama_chat/tools/generate_image_spec.rb".freeze, "spec/ollama_chat/tools/generate_password_spec.rb".freeze, "spec/ollama_chat/tools/get_current_weather_spec.rb".freeze, "spec/ollama_chat/tools/get_cve_spec.rb".freeze, "spec/ollama_chat/tools/get_endoflife_spec.rb".freeze, "spec/ollama_chat/tools/get_ghr_spec.rb".freeze, "spec/ollama_chat/tools/get_jira_issue_spec.rb".freeze, "spec/ollama_chat/tools/get_location_spec.rb".freeze, "spec/ollama_chat/tools/get_rfc_spec.rb".freeze, "spec/ollama_chat/tools/get_time_spec.rb".freeze, "spec/ollama_chat/tools/get_url_spec.rb".freeze, "spec/ollama_chat/tools/list_directory_spec.rb".freeze, "spec/ollama_chat/tools/lookup_gem_path_spec.rb".freeze, "spec/ollama_chat/tools/lookup_group_spec.rb".freeze, "spec/ollama_chat/tools/memorize_spec.rb".freeze, "spec/ollama_chat/tools/move_file_spec.rb".freeze, "spec/ollama_chat/tools/open_file_in_editor_spec.rb".freeze, "spec/ollama_chat/tools/paste_from_clipboard_spec.rb".freeze, "spec/ollama_chat/tools/paste_into_editor_spec.rb".freeze, "spec/ollama_chat/tools/patch_file_spec.rb".freeze, "spec/ollama_chat/tools/read_file_spec.rb".freeze, "spec/ollama_chat/tools/resolve_tag_spec.rb".freeze, "spec/ollama_chat/tools/roll_dice_spec.rb".freeze, "spec/ollama_chat/tools/run_tests_spec.rb".freeze, "spec/ollama_chat/tools/search_knowledge_spec.rb".freeze, "spec/ollama_chat/tools/search_web_spec.rb".freeze, "spec/ollama_chat/tools/write_file_spec.rb".freeze, "spec/ollama_chat/tts_spec.rb".freeze, "spec/ollama_chat/utils/analyze_directory_spec.rb".freeze, "spec/ollama_chat/utils/audio_player_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/excon_logger_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/log_rotation_spec.rb".freeze, "spec/ollama_chat/utils/log_viewer_spec.rb".freeze, "spec/ollama_chat/utils/ordered_queue_spec.rb".freeze, "spec/ollama_chat/utils/path_completer_spec.rb".freeze, "spec/ollama_chat/utils/png_metadata_extractor_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
|
|
|
@@ -114,7 +114,7 @@ describe OllamaChat::PromptHandling do
|
|
|
114
114
|
|
|
115
115
|
obj = prompt_model.where(name: 'zz_store', context: 'prompt').first
|
|
116
116
|
expect(obj).not_to be_nil
|
|
117
|
-
expect(obj.metadata['content']).to eq(
|
|
117
|
+
expect(obj.metadata['content']).to eq("content-here\n")
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
it 'respects a custom context' do
|
|
@@ -131,7 +131,7 @@ describe OllamaChat::PromptHandling do
|
|
|
131
131
|
|
|
132
132
|
expect(obj.name).to eq('zz_write')
|
|
133
133
|
expect(obj.metadata['default']).to be false
|
|
134
|
-
expect(obj.metadata['content']).to eq(
|
|
134
|
+
expect(obj.metadata['content']).to eq("initial\n")
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it 'updates content on an existing prompt' do
|
|
@@ -139,7 +139,7 @@ describe OllamaChat::PromptHandling do
|
|
|
139
139
|
updated = chat.write_prompt('zz_upd', 'v2')
|
|
140
140
|
|
|
141
141
|
expect(prompt_model.where(name: 'zz_upd').count).to eq(1)
|
|
142
|
-
expect(updated.metadata['content']).to eq(
|
|
142
|
+
expect(updated.metadata['content']).to eq("v2\n")
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
|
|
@@ -53,7 +53,7 @@ describe OllamaChat::PromptManagement do
|
|
|
53
53
|
prompt_model.create(context: 'prompt', name: 'p', metadata: { default: false, content: 'x' })
|
|
54
54
|
prompt_model.create(context: 'system', name: 's', metadata: { default: false, content: 'y' })
|
|
55
55
|
|
|
56
|
-
expect(chat).to receive(:choose_entry).and_return('system')
|
|
56
|
+
expect(chat).to receive(:choose_entry).and_return(wrapper.('system'))
|
|
57
57
|
expect(chat.choose_prompt_context).to eq('system')
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -406,7 +406,7 @@ describe OllamaChat::PromptManagement do
|
|
|
406
406
|
.and_return('reset_me' => 'original content')
|
|
407
407
|
|
|
408
408
|
expect(chat.reset_prompt_to_default('reset_me')).to be true
|
|
409
|
-
expect(chat.prompt('reset_me').reload.metadata['content']).to eq(
|
|
409
|
+
expect(chat.prompt('reset_me').reload.metadata['content']).to eq("original content\n")
|
|
410
410
|
end
|
|
411
411
|
|
|
412
412
|
it 'returns nil when no default found in config' do
|
|
@@ -48,6 +48,95 @@ describe OllamaChat::Tools::ExecuteJIRATWG do
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
context 'when twg returns pretty-printed JSON' do
|
|
52
|
+
let(:command) { 'jira workitem get DEV-29042' }
|
|
53
|
+
|
|
54
|
+
before do
|
|
55
|
+
expect(OC::OLLAMA::CHAT::TOOLS::JIRA).to receive(:TWG?).and_return('true')
|
|
56
|
+
system('true') # reset $? to exit 0
|
|
57
|
+
expect(OllamaChat::Utils::Fetcher).to receive(:execute)
|
|
58
|
+
.with(%w[true jira workitem get DEV-29042])
|
|
59
|
+
.and_return(<<~EOT)
|
|
60
|
+
{
|
|
61
|
+
"key": "DEV-29042"
|
|
62
|
+
}
|
|
63
|
+
EOT
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'reports (structured result) instead of a bare brace' do
|
|
67
|
+
tool_call = double(
|
|
68
|
+
'ToolCall',
|
|
69
|
+
function: double(
|
|
70
|
+
name: 'execute_jira_twg',
|
|
71
|
+
arguments: double(command:)
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
result = described_class.new(chat).execute(tool_call)
|
|
76
|
+
|
|
77
|
+
json = json_object(result)
|
|
78
|
+
expect(json.message).to eq '(structured result)'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context 'when twg returns a JSON array on its own first line' do
|
|
83
|
+
let(:command) { 'jira workitem query --jql "project = DEV"' }
|
|
84
|
+
|
|
85
|
+
before do
|
|
86
|
+
expect(OC::OLLAMA::CHAT::TOOLS::JIRA).to receive(:TWG?).and_return('true')
|
|
87
|
+
system('true') # reset $? to exit 0
|
|
88
|
+
expect(OllamaChat::Utils::Fetcher).to receive(:execute)
|
|
89
|
+
.with(['true', 'jira', 'workitem', 'query', '--jql', 'project = DEV'])
|
|
90
|
+
.and_return(<<~EOT)
|
|
91
|
+
[
|
|
92
|
+
{ "id": "DEV-1" }
|
|
93
|
+
]
|
|
94
|
+
EOT
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'reports (structured result) instead of a bare bracket' do
|
|
98
|
+
tool_call = double(
|
|
99
|
+
'ToolCall',
|
|
100
|
+
function: double(
|
|
101
|
+
name: 'execute_jira_twg',
|
|
102
|
+
arguments: double(command:)
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
result = described_class.new(chat).execute(tool_call)
|
|
107
|
+
|
|
108
|
+
json = json_object(result)
|
|
109
|
+
expect(json.message).to eq '(structured result)'
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
context 'when twg returns plain-text output' do
|
|
114
|
+
let(:command) { 'user get' }
|
|
115
|
+
|
|
116
|
+
before do
|
|
117
|
+
expect(OC::OLLAMA::CHAT::TOOLS::JIRA).to receive(:TWG?).and_return('true')
|
|
118
|
+
system('true') # reset $? to exit 0
|
|
119
|
+
expect(OllamaChat::Utils::Fetcher).to receive(:execute)
|
|
120
|
+
.with(%w[true user get])
|
|
121
|
+
.and_return("flori: Florian Frank\nflori2: Someone Else\n")
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'uses the first line as the message' do
|
|
125
|
+
tool_call = double(
|
|
126
|
+
'ToolCall',
|
|
127
|
+
function: double(
|
|
128
|
+
name: 'execute_jira_twg',
|
|
129
|
+
arguments: double(command:)
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
result = described_class.new(chat).execute(tool_call)
|
|
134
|
+
|
|
135
|
+
json = json_object(result)
|
|
136
|
+
expect(json.message).to eq 'flori: Florian Frank'
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
51
140
|
context 'when command contains quoted arguments' do
|
|
52
141
|
let(:command) { 'jira workitem query --jql "project = DEV AND status != Done"' }
|
|
53
142
|
|
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.143
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -922,7 +922,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
922
922
|
- !ruby/object:Gem::Version
|
|
923
923
|
version: '0'
|
|
924
924
|
requirements: []
|
|
925
|
-
rubygems_version: 4.0.
|
|
925
|
+
rubygems_version: 4.0.24
|
|
926
926
|
specification_version: 4
|
|
927
927
|
summary: A command-line interface (CLI) for interacting with an Ollama AI model.
|
|
928
928
|
test_files:
|