Restructured AGENTS.md from a 588-line catch-all into a lean reference of essential rules by offloading deep guidance into five new/expanded doc files: agents.md, architecture.md, dashboard-guide.md, settings-reference.md, and testing.md. Also restored a missing FN-5345 lifecycle invariant in self-h Fusion-Task-Id: FN-5339 Fusion-Task-Lineage: e1a2dc4f-ae50-46f4-acd3-8f2c3673feb4
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { existsSync, readFileSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import test from "node:test";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const rootDir = resolve(__dirname, "../..");
|
|
const agentsPath = resolve(rootDir, "AGENTS.md");
|
|
const agents = readFileSync(agentsPath, "utf8");
|
|
|
|
const requiredAnchors = [
|
|
"STANDING DIRECTIVE: Buttons Are Frozen",
|
|
"Buttons Are Frozen (2026-05-13)",
|
|
"Port 4040",
|
|
"pnpm release --yes",
|
|
"@runfusion/fusion",
|
|
'engineModule = "@fusion/engine"',
|
|
"superviseSpawn",
|
|
"Fusion-Task-Id",
|
|
"Merging Branches Into Main",
|
|
"autoMerge: false",
|
|
"File-Scope invariant",
|
|
"git add -f",
|
|
];
|
|
|
|
test("AGENTS.md keeps non-negotiable invariant anchors", () => {
|
|
for (const anchor of requiredAnchors) {
|
|
assert.ok(agents.includes(anchor), `Missing required anchor: ${anchor}`);
|
|
}
|
|
});
|
|
|
|
test("Merging section retains at least 10 numbered rules", () => {
|
|
const heading = "### Merging Branches Into Main";
|
|
const start = agents.indexOf(heading);
|
|
assert.notEqual(start, -1, "Merging section heading missing");
|
|
|
|
const afterStart = agents.slice(start + heading.length);
|
|
const nextSection = afterStart.indexOf("\n### ");
|
|
const section = nextSection === -1 ? afterStart : afterStart.slice(0, nextSection);
|
|
|
|
const rules = section.match(/^\d+\.\s+/gm) ?? [];
|
|
assert.ok(rules.length >= 10, `Expected >= 10 numbered rules, found ${rules.length}`);
|
|
});
|
|
|
|
test("All ./docs/*.md links in AGENTS.md resolve", () => {
|
|
const matches = [...agents.matchAll(/\.\/docs\/[A-Za-z0-9._-]+\.md/g)].map((m) => m[0]);
|
|
const links = [...new Set(matches)];
|
|
assert.ok(links.length > 0, "No ./docs/*.md links found");
|
|
|
|
for (const link of links) {
|
|
const target = resolve(rootDir, link);
|
|
assert.ok(existsSync(target), `Broken docs link in AGENTS.md: ${link}`);
|
|
}
|
|
});
|