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

+15 -15
View File
@@ -1,6 +1,12 @@
import assert from "node:assert/strict"
import { test } from "node:test"
import { encodeName, ensureLinked, ensureTag, isPublished, publishBody } from "../scripts/release.ts"
import {
encodeName,
ensureLinked,
ensureTag,
isPublished,
publishBody,
} from "../scripts/release.ts"
import { buildEntry, bumpMinor, insertEntry, latestVersion } from "../scripts/version.ts"
const CHANGELOG = `# Changelog
@@ -66,7 +72,10 @@ test("publish helpers: name encoding, published check, body hashes", () => {
assert.equal(isPublished({ versions: {} }, "1.0.0"), false)
assert.equal(isPublished({}, "1.0.0"), false)
const body = publishBody({ name: "@haylan/opencode-pocock", version: "1.0.0" }, Buffer.from("tar")) as {
const body = publishBody(
{ name: "@haylan/opencode-pocock", version: "1.0.0" },
Buffer.from("tar"),
) as {
"dist-tags": Record<string, string>
versions: Record<string, { dist: { shasum: string; integrity: string } }>
_attachments: Record<string, { data: string; length: number }>
@@ -79,18 +88,6 @@ test("publish helpers: name encoding, published check, body hashes", () => {
assert.equal(att.length, 3)
})
function fakeFetch(routes: Record<string, { status: number; body?: unknown }>, seen: string[]) {
return (async (url: string | URL | Request, init?: RequestInit) => {
const u = String(url)
seen.push(`${init?.method ?? "GET"} ${u}`)
const match = Object.entries(routes).find(([suffix]) => u.endsWith(suffix))
const route = match?.[1] ?? { status: 404 }
return new Response(route.body !== undefined ? JSON.stringify(route.body) : null, {
status: route.status,
})
}) as typeof fetch
}
test("ensureTag: creates on 404, no-ops when it exists, fails loudly otherwise", async () => {
const base = "https://gitea.test/api/v1"
const creating = {
@@ -130,5 +127,8 @@ test("ensureLinked: links once, then reports already linked", async () => {
}) as typeof fetch
const api = { base: "https://gitea.test/api/v1", headers: {}, fetchFn }
assert.equal(await ensureLinked(api, "haylan", "@haylan/opencode-pocock", "0.2.0", "r"), "linked")
assert.equal(await ensureLinked(api, "haylan", "@haylan/opencode-pocock", "0.2.0", "r"), "already linked")
assert.equal(
await ensureLinked(api, "haylan", "@haylan/opencode-pocock", "0.2.0", "r"),
"already linked",
)
})