summaryrefslogtreecommitdiff
path: root/lib/dslkeywords
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-14 10:50:58 +0200
committerPaul Buetow <paul@buetow.org>2026-03-14 10:50:58 +0200
commit2b4c2d4bbb47b59fb8bf7fec027efd36b1352857 (patch)
treecb45c69664461df14b90c47f2dd55ef4107e5e91 /lib/dslkeywords
parent8a641ff347d0584ea1ddc16a6ef81a8c16ab172d (diff)
Validate agent configs during dry runs
Diffstat (limited to 'lib/dslkeywords')
-rw-r--r--lib/dslkeywords/file.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb
index 81f5f29..08f8f48 100644
--- a/lib/dslkeywords/file.rb
+++ b/lib/dslkeywords/file.rb
@@ -221,13 +221,15 @@ module RCM
def evaluate_agent_processing!
raise MissingAgentInput, "File #{@file_path} does not exist for agent processing" unless ::File.file?(@file_path)
+ agent_definition, prompt_definition = agent_configuration!
+
if option :dry
info "Processing #{@file_path} with agent #{@agent_name} and prompt #{@prompt_name} - dry run!"
return
end
input = ::File.read(@file_path)
- output = run_agent!(input)
+ output = run_agent!(input, agent_definition, prompt_definition)
create_parent_directory! unless ::File.directory?(::File.dirname(@file_path))
write!(output)
end
@@ -261,12 +263,7 @@ module RCM
# rubocop:enable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
- def run_agent!(input)
- agent_definition = dsl.object!(AgentDefinition, @agent_name,
- error_class: DSL::NoSuchAgentDefinition, kind: 'agent')
- prompt_definition = dsl.object!(PromptDefinition, @prompt_name,
- error_class: DSL::NoSuchPromptDefinition, kind: 'prompt')
-
+ def run_agent!(input, agent_definition, prompt_definition)
Tempfile.create(['rcm-agent-input', '.txt']) do |tmp|
tmp.write(input)
tmp.flush
@@ -285,6 +282,13 @@ module RCM
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
+ def agent_configuration!
+ [
+ dsl.object!(AgentDefinition, @agent_name, error_class: DSL::NoSuchAgentDefinition, kind: 'agent'),
+ dsl.object!(PromptDefinition, @prompt_name, error_class: DSL::NoSuchPromptDefinition, kind: 'prompt')
+ ]
+ end
+
def render_agent_command(template, prompt_text, input_path)
command = template.dup
command.gsub!(/\bINPUT\b/, Shellwords.escape(input_path))