refactor(tools): decompose skill/tools.ts into focused tool creators

This commit is contained in:
YeonGyu-Kim
2026-04-03 19:17:03 +09:00
parent 3ce1f30310
commit 3689ecd5b0
7 changed files with 336 additions and 266 deletions
+26
View File
@@ -0,0 +1,26 @@
import type { LoadedSkill } from "../../features/opencode-skill-loader"
import { extractSkillTemplate } from "../../features/opencode-skill-loader/skill-content"
const SKILL_INSTRUCTION_PATTERN = /<skill-instruction>([\s\S]*?)<\/skill-instruction>/
function trimSkillInstruction(template: string): string {
const templateMatch = template.match(SKILL_INSTRUCTION_PATTERN)
return templateMatch ? templateMatch[1].trim() : template
}
export async function extractSkillBody(skill: LoadedSkill): Promise<string> {
if (skill.lazyContent) {
const fullTemplate = await skill.lazyContent.load()
return trimSkillInstruction(fullTemplate)
}
if (skill.scope === "config" && skill.definition.template) {
return trimSkillInstruction(skill.definition.template)
}
if (skill.path) {
return extractSkillTemplate(skill)
}
return trimSkillInstruction(skill.definition.template || "")
}