Skip to content

Commit f9232d4

Browse files
authored
feat(formatter): display loaded skill name in skill tool calls (#388)
1 parent a139cbf commit f9232d4

4 files changed

Lines changed: 57 additions & 0 deletions

File tree

lua/opencode/ui/formatter/tools/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ return {
1010
webfetch = require('opencode.ui.formatter.tools.webfetch'),
1111
list = require('opencode.ui.formatter.tools.list'),
1212
question = require('opencode.ui.formatter.tools.question'),
13+
skill = require('opencode.ui.formatter.tools.skill'),
1314
task = require('opencode.ui.formatter.tools.task'),
1415
tool = require('opencode.ui.formatter.tools.tool'),
1516
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
local icons = require('opencode.ui.icons')
2+
local utils = require('opencode.ui.formatter.utils')
3+
4+
local M = {}
5+
6+
---@param output Output
7+
---@param part OpencodeMessagePart
8+
function M.format(output, part)
9+
local input = part.state and part.state.input or {}
10+
utils.format_action(output, icons.get('skill'), 'skill', input.name or '', utils.get_duration_text(part))
11+
end
12+
13+
---@param _ OpencodeMessagePart
14+
---@param input table
15+
---@return string, string, string
16+
function M.summary(_, input)
17+
return icons.get('skill'), 'skill', input.name or ''
18+
end
19+
20+
return M

lua/opencode/ui/icons.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ local presets = {
1919
web = '󰖟 ',
2020
list = '',
2121
tool = '',
22+
skill = '󰐱 ',
2223
snapshot = '󰻛 ',
2324
restore_point = '󱗚 ',
2425
file = '',
@@ -64,6 +65,7 @@ local presets = {
6465
web = '::',
6566
list = '::',
6667
tool = '::',
68+
skill = '::',
6769
snapshot = '::',
6870
restore_point = '::',
6971
file = '@',

tests/unit/formatter_spec.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,40 @@ describe('formatter', function()
202202
assert.is_true(found)
203203
end)
204204

205+
it('renders loaded skill name for skill tool calls', function()
206+
local message = {
207+
info = {
208+
id = 'msg_1',
209+
role = 'assistant',
210+
sessionID = 'ses_1',
211+
},
212+
parts = {},
213+
}
214+
215+
local part = {
216+
id = 'prt_1',
217+
type = 'tool',
218+
tool = 'skill',
219+
messageID = 'msg_1',
220+
sessionID = 'ses_1',
221+
state = {
222+
status = 'completed',
223+
input = {
224+
name = 'context7-cli',
225+
},
226+
time = {
227+
start = 1,
228+
['end'] = 2,
229+
},
230+
},
231+
}
232+
233+
local output = formatter.format_part(part, message, true)
234+
235+
assert.is_truthy(output.lines[1]:find('skill', 1, true))
236+
assert.is_truthy(output.lines[1]:find('context7%-cli'))
237+
end)
238+
205239
it('renders directory reads with trailing slash', function()
206240
local message = {
207241
info = {

0 commit comments

Comments
 (0)