Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/roast/cogs/agent/providers/claude/tool_use.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ def format_todowrite
summary.empty? ? base : "#{base} (#{summary})"
end

# Formats a Skill tool-use line.
#
# Input fields:
# :skill (String) – name of the skill to invoke [required]
# :args (String) – arguments passed to the skill [optional]
#
# Output: "SKILL <skill>", with " (<args>)" appended when :args is
# present. :args is truncated to TRUNCATE_LIMIT chars; :skill is not.
#
# Examples:
# SKILL pr-description (draft for the auth changes)
# SKILL pr-description
#
#: () -> String
def format_skill
skill, args = input.values_at(:skill, :args)
args ? "SKILL #{skill} (#{truncate(args)})" : "SKILL #{skill}"
end

#: () -> String
def format_unknown
"UNKNOWN [#{name}] #{input.inspect}"
Expand Down
28 changes: 28 additions & 0 deletions test/roast/cogs/agent/providers/claude/tool_use_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,34 @@ class ToolUseTest < ActiveSupport::TestCase
assert_equal "TODOWRITE 3 todos (1 pending · 2 completed)", output
end

# format_skill

test "format_skill renders the skill name alone when no args given" do
tool_use = ToolUse.new(name: :skill, input: { skill: "pr-description" })

output = tool_use.format

assert_equal "SKILL pr-description", output
end

test "format_skill appends args in parentheses" do
tool_use = ToolUse.new(name: :skill, input: { skill: "pr-description", args: "draft for auth" })

output = tool_use.format

assert_equal "SKILL pr-description (draft for auth)", output
end

test "format_skill truncates args but not the skill name" do
long = "a" * (ToolUse::TRUNCATE_LIMIT + 10)
truncated = "#{"a" * (ToolUse::TRUNCATE_LIMIT - 3)}..."
tool_use = ToolUse.new(name: :skill, input: { skill: long, args: long })

output = tool_use.format

assert_equal "SKILL #{long} (#{truncated})", output
end

test "format calls format_unknown for unknown tool" do
tool_use = ToolUse.new(name: :unknown_tool, input: { arg: "value" })

Expand Down
Loading