Skip to content

Commit 505b0d8

Browse files
authored
refactor(skills): add $ARGUMENTS placeholder to skill templates (#35)
Add <user-request> wrapper with $ARGUMENTS for dynamic parameter injection and remove duplicate tests from config-handler.test.ts.
1 parent 4bac76d commit 505b0d8

2 files changed

Lines changed: 5 additions & 79 deletions

File tree

src/lib/skill-loader.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ Base directory for this skill: ${skillDir}/
4040
File references (@path) in this skill are relative to this directory.
4141
4242
${body.trim()}
43-
</skill-instruction>`
43+
</skill-instruction>
44+
45+
<user-request>
46+
$ARGUMENTS
47+
</user-request>`
4448
}
4549

4650
export function extractSkillBody(wrappedTemplate: string): string {

tests/unit/config-handler.test.ts

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import os from 'node:os'
44
import path from 'node:path'
55
import type { Config } from '@opencode-ai/sdk'
66
import { createConfigHandler } from '../../src/lib/config-handler.ts'
7-
import {
8-
formatSkillCommandName,
9-
formatSkillDescription,
10-
wrapSkillTemplate,
11-
} from '../../src/lib/skill-loader.ts'
127

138
describe('config-handler', () => {
149
let testDir: string
@@ -224,76 +219,3 @@ Command template for ${name}.`,
224219
})
225220
})
226221
})
227-
228-
describe('formatSkillCommandName', () => {
229-
test('adds systematic: prefix to plain name', () => {
230-
expect(formatSkillCommandName('brainstorming')).toBe(
231-
'systematic:brainstorming',
232-
)
233-
})
234-
235-
test('does not double-prefix already prefixed name', () => {
236-
expect(formatSkillCommandName('systematic:brainstorming')).toBe(
237-
'systematic:brainstorming',
238-
)
239-
})
240-
241-
test('handles empty string', () => {
242-
expect(formatSkillCommandName('')).toBe('systematic:')
243-
})
244-
})
245-
246-
describe('formatSkillDescription', () => {
247-
test('adds (systematic - Skill) prefix to description', () => {
248-
expect(formatSkillDescription('A test skill', 'test')).toBe(
249-
'(systematic - Skill) A test skill',
250-
)
251-
})
252-
253-
test('does not double-prefix already prefixed description', () => {
254-
expect(
255-
formatSkillDescription('(systematic - Skill) A test skill', 'test'),
256-
).toBe('(systematic - Skill) A test skill')
257-
})
258-
259-
test('uses fallback name when description is empty', () => {
260-
expect(formatSkillDescription('', 'my-skill')).toBe(
261-
'(systematic - Skill) my-skill skill',
262-
)
263-
})
264-
})
265-
266-
describe('wrapSkillTemplate', () => {
267-
test('wraps content in skill-instruction tags', () => {
268-
const result = wrapSkillTemplate('/path/to/skill/SKILL.md', '# Skill Body')
269-
expect(result).toContain('<skill-instruction>')
270-
expect(result).toContain('</skill-instruction>')
271-
expect(result).toContain('# Skill Body')
272-
})
273-
274-
test('includes base directory from skill path', () => {
275-
const result = wrapSkillTemplate(
276-
'/bundled/skills/brainstorming/SKILL.md',
277-
'# Content',
278-
)
279-
expect(result).toContain(
280-
'Base directory for this skill: /bundled/skills/brainstorming/',
281-
)
282-
})
283-
284-
test('includes file reference note', () => {
285-
const result = wrapSkillTemplate('/path/to/skill/SKILL.md', '# Content')
286-
expect(result).toContain(
287-
'File references (@path) in this skill are relative to this directory',
288-
)
289-
})
290-
291-
test('trims body content', () => {
292-
const result = wrapSkillTemplate(
293-
'/path/to/skill/SKILL.md',
294-
' \n# Skill Body\n ',
295-
)
296-
expect(result).toContain('# Skill Body')
297-
expect(result).not.toMatch(/\n\s+\n<\/skill-instruction>/)
298-
})
299-
})

0 commit comments

Comments
 (0)