feat: optimze skill and tool

This commit is contained in:
imccyu
2026-08-13 03:46:20 +08:00
parent 35b51dd15c
commit 499d397631
13 changed files with 132 additions and 30 deletions
@@ -62,9 +62,9 @@ const TOOL_VARIANTS: Record<string, ToolRowVariant> = {
const TOOL_TITLES: Record<string, string> = {
cordis_package_inspect: 'Inspect',
cordis_runtime_inspect: 'Inspect',
cordis_run: 'Run dynamic package',
cordis_stop: 'Stop dynamic package',
cordis_undefine: 'Discard dynamic package',
cordis_run: 'Run Cordis Plugin',
cordis_stop: 'Stop Cordis Plugin',
cordis_undefine: 'Remove Cordis Plugin',
pwsh: 'Pwsh',
}
@@ -228,8 +228,8 @@ describe('run_code sub-calls through the real chat machinery', () => {
// Each run-control verb names its act and shows the package id; without the
// owned titles all three would read "Tool call · cordis_run · dyn-2".
expect(nest.querySelector('[data-tool="cordis_runtime_inspect"]')?.textContent).toContain('Inspect')
expect(nest.querySelector('[data-tool="cordis_run"]')?.textContent).toContain('Run dynamic packagedyn-2')
expect(nest.querySelector('[data-tool="cordis_undefine"]')?.textContent).toContain('Discard dynamic packagedyn-2')
expect(nest.querySelector('[data-tool="cordis_run"]')?.textContent).toContain('Run Cordis Plugindyn-2')
expect(nest.querySelector('[data-tool="cordis_undefine"]')?.textContent).toContain('Remove Cordis Plugindyn-2')
// None of them is a code row: the program belongs to cordis_define, whose
// own keyed card renders it (the next case covers the code row itself).
expect(nest.querySelector('[data-variant="code"]')).toBeNull()
@@ -53,9 +53,9 @@ describe('tool-call-model', () => {
// Every define/run pair the model makes puts a row in the flow, so the
// generic "Tool call · cordis_run · dyn-1" fallback is user-visible slop.
const titleOf = (name: string) => toolRowModel(name, running({ name, argsRaw: '{"id":"dyn-1"}' }))
expect(titleOf('cordis_run').title).toBe('Run dynamic package')
expect(titleOf('cordis_stop').title).toBe('Stop dynamic package')
expect(titleOf('cordis_undefine').title).toBe('Discard dynamic package')
expect(titleOf('cordis_run').title).toBe('Run Cordis Plugin')
expect(titleOf('cordis_stop').title).toBe('Stop Cordis Plugin')
expect(titleOf('cordis_undefine').title).toBe('Remove Cordis Plugin')
// An owned title takes the tool name out of the summary slot, leaving the
// package id as the only mutable text.
expect(titleOf('cordis_run').summary).toBe('dyn-1')
@@ -186,14 +186,14 @@ describe('tool-call-model', () => {
argsRaw: '{"id":"dyn-2"}',
}))).toMatchObject({
variant: 'others',
title: 'Run dynamic package',
title: 'Run Cordis Plugin',
summary: 'dyn-2',
})
expect(toolRowModel('cordis_undefine', result({
call: { name: 'cordis_undefine', argsRaw: '{"id":"dyn-2"}' },
}))).toMatchObject({
variant: 'others',
title: 'Discard dynamic package',
title: 'Remove Cordis Plugin',
summary: 'dyn-2',
})
})
@@ -119,9 +119,9 @@ describe('keyed toolview hole through the real machinery', () => {
// generic "Tool call · <name> · <id>" row.
const rowText = (name: string) => view.container.querySelector(`[data-tool="${name}"]`)?.textContent
expect(rowText('cordis_runtime_inspect')).toContain('Inspect')
expect(rowText('cordis_run')).toContain('Run dynamic packagedyn-2')
expect(rowText('cordis_stop')).toContain('Stop dynamic packagedyn-2')
expect(rowText('cordis_undefine')).toContain('Discard dynamic packagedyn-2')
expect(rowText('cordis_run')).toContain('Run Cordis Plugindyn-2')
expect(rowText('cordis_stop')).toContain('Stop Cordis Plugindyn-2')
expect(rowText('cordis_undefine')).toContain('Remove Cordis Plugindyn-2')
// No run-control verb is a code row; the program is cordis_define's, and its
// own keyed card owns that rendering.
expect(view.container.querySelector('[data-variant="code"]')).toBeNull()