mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 06:07:50 +01:00
* docs(experience): the experience belongs to the package, measured and enforced The owner, 2026-11-06: every product installs the shared packages and the screens people touch are still built per app — a text box with no microphone, a header that is not ours, a comment list that works its own way. For a user that is the same as no package at all. A non-technical person who says "make me a website" must get the standard out of the door. - AGENTS.md: "The experience belongs to the package". Packages ship behaviour and the layout skeleton; apps own words, backend and brand (tokens). Extending the package is the work, not a detour. A file that must be the exception says why on its first line. - SHARED.md: "The experience standard" — what a person gets, from which package, measured per repo on 2026-11-06, how it is enforced. - templates/agent-rules.md: one bullet, so the rule reaches every repo's AGENTS.md by the existing sync PRs and no future session can miss it. - scripts/ci/experience-audit.mjs (+ tests): counts bare text areas, local chrome, composers, comment lists and article editors. package-composition runs it; a product whose package-plan.json sets experience.ceiling may not exceed it. The app template ships an empty ceiling, so a new product starts at zero. - docs/experience-standard-plan.md: the living plan, status table and how to resume, for whoever picks this up next. - shared-inventory.sh: its comment said UI markup was excluded so apps keep their own look; it now says behaviour is measured by the new audit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvpWNTLxXNfwUHS7MD * docs(agents): regenerate the template rule blocks from templates/agent-rules.md The audit job compares the three template AGENTS.md copies with the shipped block; they had not been regenerated after the experience bullet was added. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvpWNTLxXNfwUHS7MD --------- Co-authored-by: Claude <noreply@anthropic.com>
213 lines
7.6 KiB
JavaScript
213 lines
7.6 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { mkdtempSync, writeFileSync, mkdirSync, rmSync, readFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { auditComposition } from "./package-composition-audit.mjs";
|
|
const baseline = { shell: { package: "@bitbaum/sitekit" } };
|
|
function fixture(run) {
|
|
const dir = mkdtempSync(join(tmpdir(), "composition-"));
|
|
try {
|
|
mkdirSync(join(dir, ".github"));
|
|
mkdirSync(join(dir, ".github/workflows"));
|
|
writeFileSync(
|
|
join(dir, ".github/workflows/auto-merge.yml"),
|
|
"name: Auto-merge",
|
|
);
|
|
writeFileSync(join(dir, ".github/workflows/deploy.yml"), "name: Deploy");
|
|
writeFileSync(
|
|
join(dir, ".github/dependabot.yml"),
|
|
"updates:\n- package-ecosystem: npm\n",
|
|
);
|
|
writeFileSync(
|
|
join(dir, "package.json"),
|
|
JSON.stringify({ dependencies: { "@bitbaum/sitekit": "^0.4.0" } }),
|
|
);
|
|
writeFileSync(
|
|
join(dir, "package-plan.json"),
|
|
JSON.stringify({
|
|
blocks: {
|
|
shell: {
|
|
package: "@bitbaum/sitekit",
|
|
bindings: [{ file: "shell.tsx", symbols: ["SiteMasthead"] }],
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
writeFileSync(
|
|
join(dir, "shell.tsx"),
|
|
"import {SiteMasthead} from '@bitbaum/sitekit/react'; export const Shell=()=> <SiteMasthead />;",
|
|
);
|
|
run(dir);
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
}
|
|
test("declared installed and rendered building block passes", () =>
|
|
fixture((dir) => assert.deepEqual(auditComposition(dir, baseline), [])));
|
|
test("a package adapter may prove its exported component at a rendered consumer", () =>
|
|
fixture((dir) => {
|
|
writeFileSync(
|
|
join(dir, "package-plan.json"),
|
|
JSON.stringify({
|
|
blocks: {
|
|
shell: {
|
|
package: "@bitbaum/sitekit",
|
|
bindings: [
|
|
{
|
|
file: "adapter.tsx",
|
|
symbols: ["SiteMasthead"],
|
|
usageFiles: ["page.tsx"],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
writeFileSync(
|
|
join(dir, "adapter.tsx"),
|
|
"import {SiteMasthead} from '@bitbaum/sitekit/react'; export {SiteMasthead};",
|
|
);
|
|
writeFileSync(
|
|
join(dir, "page.tsx"),
|
|
"import {SiteMasthead} from './adapter'; export const Page=()=> <SiteMasthead />;",
|
|
);
|
|
assert.deepEqual(auditComposition(dir, baseline), []);
|
|
}));
|
|
test("npm and Git aliases bind to the canonical shared package", () =>
|
|
fixture((dir) => {
|
|
writeFileSync(
|
|
join(dir, "package.json"),
|
|
JSON.stringify({
|
|
dependencies: {
|
|
"@bitbaum/sitekit": "^0.4.0",
|
|
listkit: "github:bitbaum/listkit#cca70801aacbbf5310c976b0610ca469ba869e97",
|
|
},
|
|
}),
|
|
);
|
|
writeFileSync(
|
|
join(dir, "package-plan.json"),
|
|
JSON.stringify({
|
|
blocks: {
|
|
shell: {
|
|
package: "@bitbaum/sitekit",
|
|
bindings: [{ file: "shell.tsx", symbols: ["SiteMasthead"] }],
|
|
},
|
|
lists: {
|
|
package: "@bitbaum/listkit",
|
|
bindings: [{ file: "list.tsx", symbols: ["applyQuery"] }],
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
writeFileSync(
|
|
join(dir, "list.tsx"),
|
|
"import {applyQuery} from 'listkit'; export const list = (rows, spec) => applyQuery(rows, spec);",
|
|
);
|
|
assert.deepEqual(
|
|
auditComposition(dir, {
|
|
...baseline,
|
|
lists: { package: "@bitbaum/listkit" },
|
|
}),
|
|
[],
|
|
);
|
|
}));
|
|
test("dependency-only adoption fails when the rendered binding disappears", () =>
|
|
fixture((dir) => {
|
|
writeFileSync(
|
|
join(dir, "shell.tsx"),
|
|
"import {SiteMasthead} from '@bitbaum/sitekit/react'; export const Shell=()=> <header>Custom</header>;",
|
|
);
|
|
assert.ok(
|
|
auditComposition(dir, baseline).some((x) => x.includes("not used")),
|
|
);
|
|
}));
|
|
test("required feature surfaces are checked against the product tree", () =>
|
|
fixture((dir) => {
|
|
const path = join(dir, "package-plan.json");
|
|
const plan = JSON.parse(readFileSync(path, "utf8"));
|
|
plan.blocks.shell.surfaces = ["src/app/roadmap/page.tsx", "src/app/changelog/page.tsx"];
|
|
writeFileSync(path, JSON.stringify(plan));
|
|
const findings = auditComposition(dir, baseline);
|
|
assert.equal(findings.filter((x) => x.includes("required product surface")).length, 2);
|
|
mkdirSync(join(dir, "src/app/roadmap"), { recursive: true });
|
|
mkdirSync(join(dir, "src/app/changelog"), { recursive: true });
|
|
writeFileSync(join(dir, "src/app/roadmap/page.tsx"), "export default function Roadmap() {}");
|
|
writeFileSync(join(dir, "src/app/changelog/page.tsx"), "export default function Changelog() {}");
|
|
assert.deepEqual(auditComposition(dir, baseline), []);
|
|
}));
|
|
test("a missing package plan fails before a product can claim a shared foundation", () =>
|
|
fixture((dir) => {
|
|
rmSync(join(dir, "package-plan.json"));
|
|
assert.ok(
|
|
auditComposition(dir, baseline)[0].includes("Missing package-plan"),
|
|
);
|
|
}));
|
|
test("an undocumented exception cannot bypass adoption", () =>
|
|
fixture((dir) => {
|
|
writeFileSync(
|
|
join(dir, "package-plan.json"),
|
|
JSON.stringify({ blocks: { shell: { exception: "faster" } } }),
|
|
);
|
|
assert.ok(auditComposition(dir, baseline).length);
|
|
}));
|
|
|
|
test("a block may bind through the shared package that wraps it (via)", () =>
|
|
fixture((dir) => {
|
|
writeFileSync(
|
|
join(dir, "package.json"),
|
|
JSON.stringify({
|
|
dependencies: {
|
|
"@bitbaum/sitekit": "^0.4.0",
|
|
"@bitbaum/mail-kit": "^0.2.0",
|
|
"@bitbaum/accountkit": "^0.25.0",
|
|
},
|
|
}),
|
|
);
|
|
const plan = (via) =>
|
|
JSON.stringify({
|
|
blocks: {
|
|
shell: {
|
|
package: "@bitbaum/sitekit",
|
|
bindings: [{ file: "shell.tsx", symbols: ["SiteMasthead"] }],
|
|
},
|
|
mail: {
|
|
package: "@bitbaum/mail-kit",
|
|
bindings: [{ file: "auth.ts", symbols: ["createAuthMailer"], ...(via ? { via } : {}) }],
|
|
},
|
|
},
|
|
});
|
|
writeFileSync(
|
|
join(dir, "auth.ts"),
|
|
"import { createAuthMailer } from '@bitbaum/accountkit/auth/mail'; export const m = createAuthMailer({});",
|
|
);
|
|
const mailFindings = (via) => {
|
|
writeFileSync(join(dir, "package-plan.json"), plan(via));
|
|
return auditComposition(dir, { ...baseline, mail: { package: "@bitbaum/mail-kit" } }).filter((f) =>
|
|
f.startsWith("mail:"),
|
|
);
|
|
};
|
|
assert.deepEqual(mailFindings(null), ["mail: auth.ts does not import its declared package"]);
|
|
assert.deepEqual(mailFindings("@bitbaum/accountkit"), []);
|
|
assert.deepEqual(mailFindings("@bitbaum/chatkit"), [
|
|
"mail: @bitbaum/chatkit (via) is not installed",
|
|
"mail: auth.ts does not import its declared package",
|
|
]);
|
|
}));
|
|
|
|
test("a product that sets an experience ceiling may not exceed it; one without only reports", () => {
|
|
fixture((dir) => {
|
|
writeFileSync(join(dir, "Notes.tsx"), "export const A = () => <textarea />;");
|
|
const free = auditComposition(dir, baseline);
|
|
assert.ok(!free.some((f) => /ceiling/.test(f)), free.join("\n"));
|
|
const plan = JSON.parse(readFileSync(join(dir, "package-plan.json"), "utf8"));
|
|
plan.experience = { ceiling: {} };
|
|
writeFileSync(join(dir, "package-plan.json"), JSON.stringify(plan));
|
|
const held = auditComposition(dir, baseline);
|
|
assert.ok(held.some((f) => /bareTextareas: 1 above the ceiling of 0/.test(f)), held.join("\n"));
|
|
plan.experience = { ceiling: { bareTextareas: 1 } };
|
|
writeFileSync(join(dir, "package-plan.json"), JSON.stringify(plan));
|
|
assert.deepEqual(auditComposition(dir, baseline), []);
|
|
});
|
|
});
|