feat(shared-skills): extract builtin skill prompts

This commit is contained in:
YeonGyu-Kim
2026-05-26 20:33:42 +09:00
parent 3ccbe2fd4f
commit cdb923a329
4 changed files with 812 additions and 0 deletions
@@ -0,0 +1,60 @@
import { describe, expect, test } from "bun:test"
import type { BuiltinSkill } from "./types"
const TARGET_SKILLS = ["ai-slop-remover", "review-work", "frontend-ui-ux"] as const
type TargetSkill = (typeof TARGET_SKILLS)[number]
type SkillSource = {
readonly name: TargetSkill
readonly description: string
readonly template: string
}
function getRequiredMatch(source: string, pattern: RegExp, label: string): RegExpMatchArray {
const match = source.match(pattern)
if (!match) {
throw new Error(`missing ${label}`)
}
return match
}
async function readSkillSource(name: TargetSkill): Promise<SkillSource> {
let skill: BuiltinSkill
switch (name) {
case "ai-slop-remover":
skill = (await import("./skills/ai-slop-remover")).aiSlopRemoverSkill
break
case "review-work":
skill = (await import("./skills/review-work")).reviewWorkSkill
break
case "frontend-ui-ux":
skill = (await import("./skills/frontend-ui-ux")).frontendUiUxSkill
break
}
return { name, description: skill.description, template: skill.template }
}
async function readSharedSkill(name: TargetSkill): Promise<{ readonly frontmatter: string; readonly body: string }> {
const content = await Bun.file(`packages/shared-skills/skills/${name}/SKILL.md`).text()
const match = getRequiredMatch(content, /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/, `${name} frontmatter`)
return { frontmatter: match[1], body: match[2] }
}
describe("shared builtin skill extraction", () => {
test("#given extracted builtin skill markdown #when compared to TS sources #then bodies and metadata stay byte-equivalent", async () => {
// given
const sources = await Promise.all(TARGET_SKILLS.map(readSkillSource))
// when
const sharedSkills = await Promise.all(TARGET_SKILLS.map(readSharedSkill))
// then
for (const [index, source] of sources.entries()) {
const sharedSkill = sharedSkills[index]
expect(sharedSkill.frontmatter).toContain(`name: ${source.name}`)
expect(sharedSkill.frontmatter).toContain(`description: ${JSON.stringify(source.description)}`)
expect(sharedSkill.body).toBe(source.template)
}
})
})