repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/the-system/__tests__/workflow-skills.test.ts

Raw
File outline
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import path from "node:path";
import { describe, it } from "vitest";

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,
				/current instructions contain The System Markdown contract/,
			);
			assert.match(skill, /already been selected/);
			assert.doesNotMatch(
				skill.split("---", 3)[1] ?? "",
				/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,
			/vertical slices, vertical slicing, a walking skeleton/,
		);
		assert.match(
			skill,
			/complete observable increments across required layers/,
		);
		assert.doesNotMatch(skill, /The System|\.system/);
	});

	it("keeps System instructions internal to the /system command", () => {
		const prompts = readFileSync(path.join(root, "system-prompts.ts"), "utf8");
		assert.match(prompts, /The System document contract/);
		assert.match(prompts, /The System Markdown contract/);
		assert.match(prompts, /load its matching the-system-\* skill/);
		assert.match(prompts, /No instructions were supplied/);
		assert.match(prompts, /\/system view <ID>/);
	});
});