fix: strip frontmatter from injected skill content and share parser from src

This commit is contained in:
haylan committed 2026-10-14 12:34:56 +02:00
1 parent 023e012eda
commit d301ef5a62
7 files changed
+108 -43

No files matched your search

+9 -3
View File
@@ -9,7 +9,10 @@ import { blockedPattern, resolveOptions } from "../src/guardrails.ts"
const manifest = loadManifest()
function fakeCtx(options: Record<string, unknown>, opts: { agents?: { id: string }[]; dir?: string } = {}) {
function fakeCtx(
options: Record<string, unknown>,
opts: { agents?: { id: string }[]; dir?: string } = {},
) {
const added: Record<string, unknown>[] = []
const hooks: { name: string; fn: (event: unknown) => void }[] = []
const warns: string[] = []
@@ -23,7 +26,10 @@ function fakeCtx(options: Record<string, unknown>, opts: { agents?: { id: string
const ctx = {
options,
location: { directory: opts.dir ?? tmpdir() },
skill: { transform: async (fn: (e: { add: (s: unknown) => void }) => void) => fn({ add: (s) => added.push(s) }) },
skill: {
transform: async (fn: (e: { add: (s: unknown) => void }) => void) =>
fn({ add: (s) => added.push(s) }),
},
tool: { hook: async (name: string, fn: (event: unknown) => void) => hooks.push({ name, fn }) },
agent: { transform: async (fn: (e: typeof agentEditor) => void) => fn(agentEditor) },
}
@@ -55,8 +61,8 @@ test("setup injects every manifest skill with absolute existing paths and autoin
assert.ok(path.isAbsolute(skill.path as string), `${skill.id}: absolute path`)
assert.ok(existsSync(skill.path as string), `${skill.id}: file exists`)
assert.ok((skill.content as string).length > 0, `${skill.id}: content loaded`)
assert.ok(!(skill.content as string).startsWith("---"), `${skill.id}: frontmatter stripped`)
const entry = manifest.find((m) => m.id === skill.id)!
assert.equal(skill.content, readFileSync(skill.path as string, "utf8"))
assert.equal(skill.description, entry.description)
}
const toSpec = f.added.find((s) => s.id === "to-spec")!