Commit 25a7e97
Changed files (2)
lib
elelem
lib/elelem/agent.rb
@@ -63,9 +63,9 @@ module Elelem
def process(tool_call)
name, args = tool_call[:name], tool_call[:arguments]
- terminal.say format_tool_display(name, args)
+ terminal.say toolbox.header(name, args)
toolbox.run(name.to_s, args).tap do |result|
- terminal.say format_tool_result(name, result)
+ terminal.say toolbox.format_result(name, result)
end
end
@@ -85,19 +85,6 @@ module Elelem
[nil, []]
end
- def format_tool_display(name, args)
- "\n+ #{name.to_s.then { _1.empty? ? "?" : _1 }}(#{args})"
- end
-
- def format_tool_result(name, result)
- return if result[:exit_status]
-
- text = result[:content] || result[:error] || ""
- return if text.strip.empty?
-
- result[:error] ? " ! #{text.lines.first&.strip}" : text
- end
-
def system_prompt
prompt = "Terminal agent. Be concise. Act directly, verify your work. Use markdown.\npwd: #{Dir.pwd}"
prompt += "\n\n#{File.read("AGENTS.md")}" if File.exist?("AGENTS.md")
lib/elelem/toolbox.rb
@@ -48,6 +48,10 @@ module Elelem
end
end
+ def header(name, args)
+ "\n+ #{name.to_s.then { _1.empty? ? "?" : _1 }}(#{args})"
+ end
+
def run(name, args)
name = ALIASES.fetch(name, name)
tool = tools[name]
@@ -57,5 +61,14 @@ module Elelem
rescue => e
{ error: e.message }
end
+
+ def format_result(name, result)
+ return if result[:exit_status]
+
+ text = result[:content] || result[:error] || ""
+ return if text.strip.empty?
+
+ result[:error] ? " ! #{text.lines.first&.strip}" : text
+ end
end
end