fix: strip frontmatter from injected skill content and share parser from src
This commit is contained in:
1 parent
023e012eda
commit
d301ef5a62
7 files changed
+108
-43
No files matched your search
+20
-10
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, readdirSync } from "node:fs"
|
||||
import path from "node:path"
|
||||
import { test } from "node:test"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { parseFrontmatter } from "../scripts/frontmatter.ts"
|
||||
import { parseFrontmatter } from "../src/frontmatter.ts"
|
||||
import { loadClassification } from "../scripts/generate.ts"
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||
@@ -61,9 +61,9 @@ test("every skill an agent names still exists in the upstream snapshot", () => {
|
||||
|
||||
test("worker may only load model-invoked vendored skills", () => {
|
||||
const worker = readFileSync(path.join(root, "agents/pocock-worker.md"), "utf8")
|
||||
const allowed = [...worker.matchAll(/action:\s*skill,\s*resource:\s*"([^"]+)",\s*effect:\s*allow/g)].map(
|
||||
(m) => m[1],
|
||||
)
|
||||
const allowed = [
|
||||
...worker.matchAll(/action:\s*skill,\s*resource:\s*"([^"]+)",\s*effect:\s*allow/g),
|
||||
].map((m) => m[1])
|
||||
assert.ok(allowed.length >= 3, "worker skill allow-list parsed")
|
||||
const userInvoked = new Set(entries.filter((e) => e.user_invoked).map((e) => e.name))
|
||||
const vendoredNames = new Set(vendored.map((e) => e.name))
|
||||
@@ -80,16 +80,20 @@ test("reviewer is read-only: edit/subagent denied, only code-review allowed", ()
|
||||
const reviewer = readFileSync(path.join(root, "agents/pocock-reviewer.md"), "utf8")
|
||||
assert.match(reviewer, /action:\s*edit,\s*resource:\s*"\*",\s*effect:\s*deny/)
|
||||
assert.match(reviewer, /action:\s*subagent,\s*resource:\s*"\*",\s*effect:\s*deny/)
|
||||
const allowedSkills = [...reviewer.matchAll(/action:\s*skill,\s*resource:\s*"([^"]+)",\s*effect:\s*allow/g)].map(
|
||||
(m) => m[1],
|
||||
)
|
||||
const allowedSkills = [
|
||||
...reviewer.matchAll(/action:\s*skill,\s*resource:\s*"([^"]+)",\s*effect:\s*allow/g),
|
||||
].map((m) => m[1])
|
||||
assert.deepEqual(allowedSkills, ["code-review"])
|
||||
})
|
||||
|
||||
test("worker and reviewer cannot spawn subagents (no circular delegation)", () => {
|
||||
for (const file of ["pocock-worker.md", "pocock-reviewer.md"]) {
|
||||
const body = readFileSync(path.join(root, "agents", file), "utf8")
|
||||
assert.match(body, /action:\s*subagent,\s*resource:\s*"\*",\s*effect:\s*deny/, `${file}: subagent deny`)
|
||||
assert.match(
|
||||
body,
|
||||
/action:\s*subagent,\s*resource:\s*"\*",\s*effect:\s*deny/,
|
||||
`${file}: subagent deny`,
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -106,9 +110,15 @@ test("classification is fully reviewed and matches the generated tree", () => {
|
||||
vendored.map((e) => e.name).sort(),
|
||||
)
|
||||
for (const e of vendored) {
|
||||
assert.ok(existsSync(path.join(root, "skills", e.name, "SKILL.md")), `skills/${e.name} generated`)
|
||||
assert.ok(
|
||||
existsSync(path.join(root, "skills", e.name, "SKILL.md")),
|
||||
`skills/${e.name} generated`,
|
||||
)
|
||||
}
|
||||
for (const e of entries.filter((x) => x.artifacts.includes("excluded"))) {
|
||||
assert.ok(!existsSync(path.join(root, "skills", e.name)), `excluded skill ${e.name} must not ship`)
|
||||
assert.ok(
|
||||
!existsSync(path.join(root, "skills", e.name)),
|
||||
`excluded skill ${e.name} must not ship`,
|
||||
)
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user