| 4 | import type { Skill } from "./types" |
| 5 | |
| 6 | function formatSkill(skill: Skill.Info): string { |
| 7 | const lines = [`<skill name="${skill.name}">`] |
| 8 | |
| 9 | if (skill.description) { |
| 10 | lines.push(`<description>${skill.description}</description>`) |
| 11 | } |
| 12 | |
| 13 | if (skill.allowedTools && skill.allowedTools.length > 0) { |
| 14 | lines.push(`<allowed-tools>${skill.allowedTools.join(", ")}</allowed-tools>`) |
| 15 | } |
| 16 | |
| 17 | if (skill.argumentHint && skill.argumentHint.length > 0) { |
| 18 | lines.push(`<argument-hint>${skill.argumentHint.join(", ")}</argument-hint>`) |
| 19 | } |
| 20 | |
| 21 | lines.push(`<content>`) |
| 22 | lines.push(skill.content) |
| 23 | lines.push(`</content>`) |
| 24 | lines.push(`</skill>`) |
| 25 | |
| 26 | return lines.join("\n") |
| 27 | } |
| 28 | |
| 29 | export const SkillUseTool = Tool.define("skill_use", { |
| 30 | description: `Load one or more skills by name. Skills provide specialized instructions and context for specific tasks. Use skill_find to discover available skills first.`, |