mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 05:47:47 +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>
166 lines
6.2 KiB
JavaScript
166 lines
6.2 KiB
JavaScript
import { readFileSync, existsSync } from "node:fs";
|
|
import { resolve, dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dependencyIdentity } from "./package-rollout-gate.mjs";
|
|
import { measure, overCeiling } from "./experience-audit.mjs";
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
export function auditComposition(
|
|
dir,
|
|
baseline = JSON.parse(
|
|
readFileSync(join(root, "registers/product-building-blocks.json"), "utf8"),
|
|
),
|
|
) {
|
|
const findings = [];
|
|
const read = (file) => readFileSync(resolve(dir, file), "utf8");
|
|
if (!existsSync(resolve(dir, "package-plan.json")))
|
|
return [
|
|
"Missing package-plan.json: inventory shared building blocks before implementation.",
|
|
];
|
|
let plan, manifest;
|
|
try {
|
|
plan = JSON.parse(read("package-plan.json"));
|
|
manifest = JSON.parse(read("package.json"));
|
|
} catch {
|
|
return ["Package plan and package manifest must be valid JSON."];
|
|
}
|
|
const deps = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
const decisions = {
|
|
...Object.fromEntries(
|
|
Object.entries(plan.blocks ?? {}).map(([key, entry]) => [
|
|
key,
|
|
{ package: entry.package },
|
|
]),
|
|
),
|
|
...baseline,
|
|
};
|
|
for (const [feature, required] of Object.entries(decisions)) {
|
|
const entry = plan.blocks?.[feature];
|
|
if (!entry) {
|
|
findings.push(`${feature}: missing building-block decision`);
|
|
continue;
|
|
}
|
|
if (entry.exception) {
|
|
if (
|
|
typeof entry.exception !== "string" ||
|
|
entry.exception.trim().length < 40
|
|
)
|
|
findings.push(
|
|
`${feature}: explain the actual incompatibility or why the feature is absent`,
|
|
);
|
|
continue;
|
|
}
|
|
if (entry.package !== required.package)
|
|
findings.push(
|
|
`${feature}: expected ${required.package}, or document the specific exception`,
|
|
);
|
|
const installedNames = Object.entries(deps)
|
|
.filter(
|
|
([name, spec]) => dependencyIdentity(name, spec) === entry.package,
|
|
)
|
|
.map(([name]) => name);
|
|
if (!installedNames.length)
|
|
findings.push(`${feature}: ${entry.package} is not installed`);
|
|
if (!Array.isArray(entry.bindings) || entry.bindings.length === 0) {
|
|
findings.push(`${feature}: no rendered/runtime binding declared`);
|
|
continue;
|
|
}
|
|
for (const binding of entry.bindings) {
|
|
if (
|
|
!binding.file ||
|
|
resolve(dir, binding.file).startsWith(resolve(dir) + "/") === false ||
|
|
!existsSync(resolve(dir, binding.file))
|
|
) {
|
|
findings.push(
|
|
`${feature}: binding file is missing or outside this repository`,
|
|
);
|
|
continue;
|
|
}
|
|
const source = read(binding.file);
|
|
// `via`: the block reaches the product through another shared package
|
|
// that wraps it (account mail is mail-kit through accountkit's
|
|
// createAuthMailer). The wrapper must be installed and imported here.
|
|
const via = typeof binding.via === "string" ? binding.via : null;
|
|
const viaNames = via
|
|
? Object.entries(deps)
|
|
.filter(([name, spec]) => dependencyIdentity(name, spec) === via)
|
|
.map(([name]) => name)
|
|
: [];
|
|
if (via && !viaNames.length)
|
|
findings.push(`${feature}: ${via} (via) is not installed`);
|
|
const importNames = [entry.package, ...installedNames, ...viaNames].map((name) =>
|
|
name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
);
|
|
const importsPackage = importNames.some((name) =>
|
|
new RegExp(`(?:from\\s*|import\\s*)['"]${name}(?:/[^'"]*)?['"]`).test(
|
|
source,
|
|
),
|
|
);
|
|
if (!importsPackage)
|
|
findings.push(
|
|
`${feature}: ${binding.file} does not import its declared package`,
|
|
);
|
|
const usageSources = [];
|
|
for (const file of binding.usageFiles ?? []) {
|
|
if (
|
|
!file ||
|
|
file.startsWith("/") ||
|
|
file.split("/").includes("..") ||
|
|
!existsSync(resolve(dir, file))
|
|
) {
|
|
findings.push(`${feature}: usage file is missing or outside this repository`);
|
|
continue;
|
|
}
|
|
usageSources.push(read(file));
|
|
}
|
|
const bindingSources = [source, ...usageSources];
|
|
for (const symbol of binding.symbols ?? []) {
|
|
const escaped = String(symbol).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
const used = new RegExp(`(?:<${escaped}\\b|\\b${escaped}\\s*\\()`);
|
|
if (!bindingSources.some((content) => used.test(content)))
|
|
findings.push(`${feature}: ${symbol} is not used in ${binding.file}`);
|
|
}
|
|
}
|
|
for (const surface of entry.surfaces ?? []) {
|
|
if (
|
|
!surface ||
|
|
surface.startsWith("/") ||
|
|
surface.split("/").includes("..") ||
|
|
!existsSync(resolve(dir, surface))
|
|
)
|
|
findings.push(`${feature}: required product surface is missing or unsafe: ${surface}`);
|
|
}
|
|
}
|
|
if (
|
|
!existsSync(resolve(dir, ".github/dependabot.yml")) ||
|
|
!/package-ecosystem:\s*["']?npm/.test(read(".github/dependabot.yml"))
|
|
)
|
|
findings.push(
|
|
"No npm dependency-update path: shared releases cannot propagate.",
|
|
);
|
|
if (!existsSync(resolve(dir, ".github/workflows/auto-merge.yml")))
|
|
findings.push("No checked merge path for shared dependency updates.");
|
|
if (!existsSync(resolve(dir, ".github/workflows/deploy.yml")))
|
|
findings.push("No deployment path for merged shared dependency updates.");
|
|
// The experience: a product that sets `experience.ceiling` in its plan may
|
|
// not ship more files that stand where a package owns the behaviour
|
|
// (bare text fields, its own chrome, composers, comments, article editors).
|
|
// Without a ceiling it is only reported by experience-audit.mjs.
|
|
findings.push(...overCeiling(measure(dir).counts, plan));
|
|
return findings;
|
|
}
|
|
if (
|
|
process.argv[1] &&
|
|
resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
|
) {
|
|
const at = process.argv.indexOf("--dir");
|
|
const dir = resolve(at >= 0 ? process.argv[at + 1] : ".");
|
|
const findings = auditComposition(dir);
|
|
if (findings.length) {
|
|
for (const finding of findings) process.stderr.write(finding + "\n");
|
|
process.exitCode = 1;
|
|
} else
|
|
process.stdout.write(
|
|
"Shared building blocks are installed and wired; dependency updates are configured.\n",
|
|
);
|
|
}
|