Skip to content
Merged
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
16 changes: 16 additions & 0 deletions packages/core/src/skills/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ describe('skillsProvider advertising', () => {
expect(prompt).not.toContain('Read the table, then run convert.');
});

it('distinguishes the two script argument shapes in the default prompt', async () => {
const contribution = await runProvider(skillsProvider([unitConverter]));

const prompt = contribution.instructions.join('\n');
const scriptGuidance = prompt.split('\n').filter((line) => line.includes('script'));
// Named arguments go as a JSON object — inline scripts included — while file-based scripts
// documenting CLI-style positional arguments take a string array.
expect(
scriptGuidance.some((line) => line.includes('JSON object') && line.includes('inline scripts')),
).toBe(true);
expect(
scriptGuidance.some((line) => line.includes('array of strings') && line.includes('file-based scripts')),
).toBe(true);
expect(prompt).toContain('not as top-level tool parameters');
});

it('escapes skill metadata so a crafted description cannot close the element', async () => {
const injected = inlineSkill({
name: 'crafted',
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/skills/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ const RESOURCE_INSTRUCTIONS =

const SCRIPT_INSTRUCTIONS =
'- Use `run_skill_script` to run referenced scripts, using the name exactly as listed.\n' +
'- Pass script arguments inside `args` as a JSON object' +
' (e.g. `args: {"length": 24}`), not as top-level tool parameters.\n';
'- Pass named script arguments inside `args` as a JSON object, including for inline scripts' +
' (e.g. `args: {"length": 24}`), not as top-level tool parameters.\n' +
'- For file-based scripts that document CLI-style positional arguments, pass `args` as an array of strings' +
' (e.g. `args: ["input.docx", "--output", "result.idx"]`).\n';

/**
* Advertises skills to the model and gives it the tools to pull them in.
Expand Down