Module: OllamaAgent::ExternalAgents::ArgvInterp

Defined in:
lib/ollama_agent/external_agents/argv_interp.rb

Overview

Expands %name placeholders in argv templates (no shell).

Class Method Summary collapse

Class Method Details

.expand(tokens, subs) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/ollama_agent/external_agents/argv_interp.rb', line 8

def expand(tokens, subs)
  return [] unless tokens.is_a?(Array)

  tokens.map do |tok|
    tok.to_s.gsub(/%\{(\w+)\}/) do
      k = Regexp.last_match(1)
      subs[k] || subs[k.to_sym]&.to_s || ""
    end
  end
end