repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by admin
extensions/the-system/__tests__/workflow-skills.test.ts
Rawimport assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import path from "node:path";
import { describe, it } from "vitest";
import { systemPromptFor } from "../system-prompts.ts";
const root = path.resolve(import.meta.dirname, "..");
const packageJson = () =>
JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")) as {
pi?: { extensions?: string[]; prompts?: string[]; skills?: string[] };
};
const repositoryPackage = () =>
JSON.parse(
readFileSync(path.join(root, "../..", "package.json"), "utf8"),
) as {
pi?: { extensions?: string[]; prompts?: string[]; skills?: string[] };
};
describe("the-system internal prompt model", () => {
it("ships conditional System format skills without exporting them statically", () => {
const extension = packageJson();
assert.deepEqual(extension.pi, { extensions: ["index.ts"] });
const repository = repositoryPackage();
assert.ok(!repository.pi?.skills?.includes("extensions/the-system/skills"));
assert.ok(
!repository.pi?.prompts?.includes("extensions/the-system/prompts"),
);
for (const name of [
"the-system-gfm",
"the-system-tex",
"the-system-mermaid",
]) {
const skill = readFileSync(
path.join(root, "skills", name, "SKILL.md"),
"utf8",
);
assert.match(skill, new RegExp(`name: ${name}`));
assert.match(skill, /description: Use when /);
assert.doesNotMatch(
skill,
/Apply the active System contracts|create another System bundle|board state|stage progression/,
);
assert.doesNotMatch(
skill.split("---", 3)[1] ?? "",
/System Markdown contract|already been selected|bundle|create|author/,
);
}
});
it("ships a generally invocable vertical-slices skill", () => {
const skill = readFileSync(
path.join(root, "skills", "vertical-slices", "SKILL.md"),
"utf8",
);
assert.match(skill, /name: vertical-slices/);
assert.match(
skill,
/description: "Use when planning or implementing vertical slices, walking skeletons, or thin end-to-end increments\."/,
);
assert.match(
skill,
/A slice is complete only when its behavior is integrated, observable, tested, and freshly verified/,
);
assert.match(
skill,
/A plan defines the required outcome, not the implementation order/,
);
assert.match(skill, /slice boundaries are not human approval points/);
assert.doesNotMatch(skill, /The System|\.system/);
});
it("ships the governing contracts as project-scoped skills", () => {
const skill = (name: string) =>
readFileSync(path.join(root, "skills", name, "SKILL.md"), "utf8");
const documents = skill("the-system-documents");
assert.match(documents, /name: the-system-documents/);
assert.match(
documents,
/description: "Use before creating, editing, or reviewing any file under \.system\//,
);
assert.match(documents, /never auto-chain/);
assert.match(documents, /\/system view <ID>/);
const markdown = skill("the-system-markdown");
assert.match(markdown, /name: the-system-markdown/);
assert.match(markdown, /load its matching `the-system-\*` skill/);
assert.match(
markdown,
/Task lists contain only static checkable criteria and remain unchecked/,
);
assert.match(
markdown,
/Never diagram `\/system` stage progression or plan, spec, issue, or board progress/,
);
assert.match(markdown, /Replace or remove obsolete canonical text/);
assert.match(markdown, /use absolute HTTPS links for external sources/);
const board = skill("the-system-board");
assert.match(board, /name: the-system-board/);
assert.match(board, /Assessment proposes board changes for human review/);
const exec = skill("the-system-exec");
assert.match(exec, /name: the-system-exec/);
assert.match(exec, /call `system_board_update` exactly once/);
});
it("keeps stage messages free of the contracts and of a Human instructions header", () => {
const prompts = readFileSync(path.join(root, "system-prompts.ts"), "utf8");
assert.doesNotMatch(prompts, /The System document contract/);
assert.doesNotMatch(prompts, /The System Markdown contract/);
assert.doesNotMatch(prompts, /Human instructions/);
assert.match(prompts, /When no instructions were supplied/);
for (const stage of [
"research",
"spec",
"spec-verify",
"assess",
"phase",
"plan",
"issue",
"exec",
]) {
assert.match(
systemPromptFor(stage, ""),
/When no instructions were supplied, infer intent/,
);
}
assert.doesNotMatch(
systemPromptFor("init", ""),
/When no instructions were supplied/,
);
});
});