aia 1.1.0 → 1.1.1

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: d72af72c970719f5d9508d14fc7903e46b7b751028d75cb045c8c23418151b44
4
- data.tar.gz: 7a2b43f842f38d7e2f94f2118c85f087a4f97b944958b7a63c5d2798bab05cb9
3
+ metadata.gz: c8f6a82b1c6cc29b4245e51ed43a325a835a921a0da5c2818dbdfbdeeeb97c40
4
+ data.tar.gz: ff0cff98ed30d391970a11a44519cb9ea95082bfae2a08e5ebf03b71eeefac15
5
5
  SHA512:
6
- metadata.gz: a27344680f0eb4ac9f1a9535982b53b102bb2face18b66f293918996a9b27e6d29aea2c46480671c2abecbb9a7e4f8c1400c84d5f157f7083c357a8766b399da
7
- data.tar.gz: 3b740188dc4b8a74873fca77112fde35737574bd47c2a2c7f3e888cc831b669fb520b3e5e212b6124960ca0afe09ebe5fa004bf8e18f8507e32f5ea58afb5ae5
6
+ metadata.gz: ec35e9ae94d6c74ad6ecf87ad6a8511de29407d1bac99db1ff1266b7072ac078746bf9fcabb45f6aeed1858198b318ff2906e8858b74185de8107cfdcf48bfca
7
+ data.tar.gz: 7ee21fda6bdf851e2418d739450f2b8d6ffd8580e5aaaef7b84e5c16c83ded0eefb83e6c8a943ffa5bbe09960463eb8617c44adf9a66f6ad87b460edc50ed6b7
data/.version CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
data/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
  # Changelog
2
+ ## [1.1.1] - 2026-05-01
3
+
4
+ ### Bug Fixes
5
+ - **Conversation context lost on Ollama model pipeline steps (Issue #152)**: `maybe_change_model` was unconditionally replacing the adapter whenever the configured model name (e.g. `ollama/qwen3`) did not literally appear in the resolved model ID (`qwen3`). Fixed by stripping the provider prefix before comparison and by never replacing the adapter when conversation messages exist in any chat instance — preserving all history across pipeline steps and role changes
6
+ - **Role file front matter overwriting active model config**: `ChatLoop#process_role_context` was allowing `fetch_role` (which calls `apply_metadata_config`) to overwrite `AIA.config.models` with any `model:` key in the role file's YAML front matter. The active model is now saved before `fetch_role` and restored afterward, so a role's front matter cannot trigger a false mismatch in `maybe_change_model`
7
+ - **Custom `--tools` directives not available in ERB prompts**: `AIA::Directive` subclasses defined in files loaded via `--tools` were required too late — after `PromptHandler.new` had already called `register_pm_directives`. Added `require_tool_files` as the first step in `ConfigValidator#tailor` so custom directive classes are defined and registered into `PM.directives` before `PromptHandler.new` runs; `<%= timestamp %>` and other custom ERB helpers now expand correctly
8
+ - **Demo example path resolution**: `examples/prompts_dir/project_summary` referenced `../../*.gemspec` and `../../lib/aia/*.rb`, resolving two levels above the repo root from the `examples/` working directory; corrected to `../`
9
+
10
+ ### Improvements
11
+ - **Demo scripts use develop-branch binary**: `examples/common.sh` now prepends `../bin` to `PATH` when the local `bin/aia` is executable, ensuring all demo scripts exercise working-tree changes rather than the installed gem
12
+
13
+ ### Testing
14
+ - Added `test/aia/chat_loop_test.rb` — 6 tests covering `process_role_context`: early-return when no role configured, system message injection into chats, skipping chats that already have a system message, and model restoration after `fetch_role` side effects (Issue #152 regression tests)
15
+ - Expanded `test/aia/chat_processor_service_test.rb` with 7 additional tests: provider-prefix stripping before model comparison, full-ID alias resolution (e.g. `claude-sonnet-4` vs `claude-sonnet-4-20250514`), adapter preservation when any chat has history, adapter replacement allowed when no history exists, and the exact Issue #152 regression scenario (OpenAI model active, role front matter specifies a Claude model)
16
+
2
17
  ## [1.1.0] - 2026-04-23
3
18
 
4
19
  ### New Features
data/examples/common.sh CHANGED
@@ -18,3 +18,10 @@ while IFS= read -r var; do
18
18
  done < <(env | grep '^AIA_' | cut -d= -f1)
19
19
 
20
20
  CONFIG="aia_config.yml"
21
+
22
+ # When running from the develop branch, prefer the local bin/aia over any
23
+ # installed gem so that uncommitted working-tree changes are exercised.
24
+ LOCAL_AIA="${SCRIPT_DIR}/../bin/aia"
25
+ if [[ -x "${LOCAL_AIA}" ]]; then
26
+ export PATH="${SCRIPT_DIR}/../bin:${PATH}"
27
+ fi
@@ -4,9 +4,9 @@ temperature: 0.3
4
4
  ---
5
5
  Summarize this project based on the following information:
6
6
 
7
- Gemspec name: <%= `grep 'spec.name' ../../*.gemspec 2>/dev/null`.strip %>
7
+ Gemspec name: <%= `grep 'spec.name' ../*.gemspec 2>/dev/null`.strip %>
8
8
  Ruby version: <%= RUBY_VERSION %>
9
9
  Current directory: $(pwd)
10
- Files in lib/: $(ls ../../lib/aia/*.rb 2>/dev/null | wc -l | tr -d ' ')
10
+ Files in lib/: $(ls ../lib/aia/*.rb 2>/dev/null | wc -l | tr -d ' ')
11
11
 
12
12
  Provide a three-sentence overview.
data/lib/aia/chat_loop.rb CHANGED
@@ -48,7 +48,14 @@ module AIA
48
48
  return if role.nil? || role.empty?
49
49
 
50
50
  prompt_handler = AIA::PromptHandler.new
51
+
52
+ # fetch_role applies the role file's metadata (including any model: key) to
53
+ # AIA.config. Preserve the user's chosen model so the chat session keeps
54
+ # using the model from the CLI, not one embedded in the role file.
55
+ saved_models = AIA.config.models
51
56
  role_parsed = prompt_handler.fetch_role(role)
57
+ AIA.config.models = saved_models
58
+
52
59
  return if role_parsed.nil?
53
60
 
54
61
  role_content = role_parsed.to_s
@@ -99,9 +99,23 @@ module AIA
99
99
  model_name = first_model.respond_to?(:name) ? first_model.name : first_model.to_s
100
100
 
101
101
  # client_model is the full resolved ID (e.g. "claude-sonnet-4-20250514"),
102
- # model_name is the configured alias (e.g. "claude-sonnet-4").
103
- # The alias is always a prefix/substring of the resolved ID, so check that way.
104
- unless client_model.downcase.include?(model_name.downcase)
102
+ # model_name is the configured alias (e.g. "claude-sonnet-4") or a
103
+ # provider-prefixed name (e.g. "ollama/qwen3").
104
+ #
105
+ # The adapter strips provider prefixes when creating the RubyLLM chat
106
+ # (e.g. "ollama/qwen3" → model: "qwen3"), so client_model has no prefix.
107
+ # Strip the prefix from model_name before comparing so that
108
+ # "qwen3".include?("qwen3") → true (was: "qwen3".include?("ollama/qwen3") → false).
109
+ comparable_name = model_name.sub(%r{\A[^/]+/}, '')
110
+ unless client_model.downcase.include?(comparable_name.downcase)
111
+ # Never replace the adapter when conversation history exists — doing so
112
+ # destroys all prior context. Role/prompt files can change AIA.config.models
113
+ # via front matter metadata, but that must not evict an active chat session.
114
+ if AIA.client.respond_to?(:chats) &&
115
+ AIA.client.chats.values.any? { |chat| chat.messages.any? }
116
+ warn "Warning: Model config changed to '#{model_name}' but keeping '#{client_model}' to preserve conversation history."
117
+ return
118
+ end
105
119
  AIA.client = AIA.client.class.new
106
120
  end
107
121
  end
@@ -24,6 +24,10 @@ module AIA
24
24
  stdin_content = process_stdin_content
25
25
  config.stdin_content = stdin_content if stdin_content && !stdin_content.strip.empty?
26
26
 
27
+ # Require tool files early so AIA::Directive subclasses defined in them
28
+ # are registered into PM.directives before PromptHandler.new is called.
29
+ require_tool_files(config)
30
+
27
31
  # Process arguments and validate
28
32
  process_prompt_id_from_args(config, remaining_args)
29
33
  validate_and_set_context_files(config, remaining_args)
@@ -361,6 +365,19 @@ module AIA
361
365
  !Array(config.mcp_use).empty? || !Array(config.mcp_skip).empty?
362
366
  end
363
367
 
368
+ def require_tool_files(config)
369
+ Array(config.tools&.paths).each do |path|
370
+ expanded = File.expand_path(path)
371
+ if File.exist?(expanded)
372
+ require expanded
373
+ else
374
+ warn "Warning: Tool file not found: #{path}"
375
+ end
376
+ rescue LoadError, StandardError => e
377
+ warn "Warning: Failed to load tool '#{path}': #{e.message}"
378
+ end
379
+ end
380
+
364
381
  def load_local_tools(config)
365
382
  # Load required libraries (with gem activation and lazy-load triggering)
366
383
  Array(config.require_libs).each do |lib|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer