feat(specs): OpenPkg 1.0 Draft, the open format behind W3BS Package Manager

Adds docs/openpkg.md, a registry entry in the process family next to
OpenInstall, a /openpkg landing page and a contract test that keeps the
page's tables in step with the spec.

The spec is written from the w3bs reference implementation: package
identity grammar, TUF repository profile 1 with first-use trust by root
fingerprint, the package index, channel index, release manifest and curl
catalog documents, the catalog listing rule, client lifecycle rules,
receipts, the JSON result object and exit codes 0/1/2/3/4/5/130.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-10-13 00:01:40 +00:00
parent 0f5c479e2f
commit 79155cbbec
5 changed files with 706 additions and 1 deletions

View file

@ -0,0 +1,65 @@
import { describe, expect, it, vi } from "vitest";
import { familyOfSpec } from "../src/lib/specs";
import { listDocs, readDoc } from "../src/lib/docs";
import { GET as llms } from "../src/app/llms.txt/route";
import { GET as llmsFull } from "../src/app/llms-full.txt/route";
import sitemap from "../src/app/sitemap";
import { EXIT_CODES, TARGETS } from "../src/app/openpkg/data";
// Spec discovery must work even when the optional blog database is offline.
vi.mock("../src/lib/supabase", () => ({ publicClient: () => { throw new Error("offline"); } }));
const doc = readDoc("openpkg") ?? "";
/** The first-column `code` cells of the table under a heading line. */
function tableKeys(heading: string): string[] {
const start = doc.indexOf(`\n${heading}\n`);
expect(start, `docs/openpkg.md has a ${heading} section`).toBeGreaterThan(-1);
const next = doc.indexOf("\n#", start + 1);
const section = doc.slice(start, next === -1 ? undefined : next);
return section
.split("\n")
.map((line) => line.match(/^\| `([^`]+)` \|/))
.filter((m): m is RegExpMatchArray => m !== null)
.map((m) => m[1]);
}
describe("OpenPkg public discovery", () => {
it("is registered in the process family with a 1.0 Draft specification", () => {
expect(familyOfSpec("openpkg")?.slug).toBe("process");
expect(listDocs()).toContainEqual(expect.objectContaining({ slug: "openpkg", title: "OpenPkg" }));
expect(doc).toMatch(/Status: \*\*1\.0 Draft\*\*/);
});
it("is in the LLM feeds and the sitemap", async () => {
const text = await llms().text();
expect(text).toMatch(/\[OpenPkg\]\(https:\/\/[^)]+\/(docs\/)?openpkg\)/);
expect(text).toContain("/docs/openpkg");
expect(await llmsFull().text()).toContain(doc.trim());
const entries = await sitemap();
expect(entries.some((entry) => new URL(entry.url).pathname === "/docs/openpkg")).toBe(true);
});
});
describe("OpenPkg: the spec and its landing page agree", () => {
it("lists the same exit codes", () => {
expect(EXIT_CODES.map(([code]) => code)).toEqual(tableKeys("### 6.2 Exit codes"));
expect(tableKeys("### 6.2 Exit codes")).toEqual(["0", "1", "2", "3", "4", "5", "130"]);
});
it("defines every target document the page lists, in order", () => {
const headings = [...doc.matchAll(/^### 3\.\d .*?: `([^`]+)`$/gm)].map((m) => m[1]);
expect(TARGETS.map(([path]) => path)).toEqual(headings);
});
it("names the reference implementation and the guide", () => {
expect(doc).toContain("https://github.com/profullstack/w3bs.org/tree/main/package-manager");
expect(doc).toContain("https://w3bs.org/docs/package-manager.md");
expect(doc).toContain("without permission");
});
it("has no em dashes", () => {
expect(doc).not.toContain(String.fromCharCode(0x2014));
expect(readDoc("openpkg")).toBeTruthy();
});
});