(filepath: string)
| 38 | }) |
| 39 | |
| 40 | async function parseSkill(filepath: string): Promise<Skill.Info | null> { |
| 41 | const template = await Bun.file(filepath) |
| 42 | .text() |
| 43 | .catch(() => null) |
| 44 | if (!template) return null |
| 45 | |
| 46 | const md = matter(template) |
| 47 | const frontmatter = Skill.Frontmatter.safeParse(md.data) |
| 48 | if (!frontmatter.success) { |
| 49 | log.warn("invalid skill frontmatter", { |
| 50 | path: filepath, |
| 51 | issues: frontmatter.error.issues, |
| 52 | }) |
| 53 | return null |
| 54 | } |
| 55 | |
| 56 | const data = frontmatter.data |
| 57 | |
| 58 | return { |
| 59 | name: data.name, |
| 60 | description: data.description, |
| 61 | content: md.content.trim(), |
| 62 | path: filepath, |
| 63 | license: data.license, |
| 64 | compatibility: normalizeArray(data.compatibility), |
| 65 | metadata: data.metadata, |
| 66 | argumentHint: normalizeArray(data["argument-hint"]), |
| 67 | disableModelInvocation: data["disable-model-invocation"], |
| 68 | allowedTools: normalizeArray(data["allowed-tools"]), |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | function normalizeArray(value: string | string[] | undefined): string[] | undefined { |
| 73 | if (!value) return undefined |
no test coverage detected