@zero2webmaster/starter-kit 0.32.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # z2w-starter-kit
2
2
 
3
- **Version:** 0.32.1 | **Framework:** 2.19.0
3
+ **Version:** 0.38.0 | **Framework:** 2.19.0
4
4
 
5
5
  > Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
6
6
 
@@ -135,4 +135,4 @@ Inquiries: kerry@zero2webmaster.com.
135
135
  ---
136
136
 
137
137
  *Scaffolded 2026-05-28 via the [[instantiate-z2w-project]] Claude Code skill v1; reconciled against the consolidated skill v1.1.0 (brief-first + Agent Coordination block) on 2026-05-29.*
138
- *Version: 0.32.1 | Last Updated: 2026-09-19*
138
+ *Version: 0.38.0 | Last Updated: 2026-09-23*
@@ -59,6 +59,18 @@ export interface ProjectDescriptor {
59
59
  slug: string;
60
60
  description: string;
61
61
  projectType: ProjectType;
62
+ /**
63
+ * Present and `true` only on a descriptor REVERSE-ENGINEERED from an existing
64
+ * repo by `scripts/check-descriptor.mjs --write`, rather than emitted here at
65
+ * scaffold time from authoritative inputs. Absent on a scaffolded descriptor.
66
+ *
67
+ * It exists because the two are otherwise indistinguishable, and they do not
68
+ * deserve the same confidence: a scaffolded descriptor's `projectType` and
69
+ * `dbStrategy` were STATED by the person creating the project, whereas a
70
+ * backfilled one's were INFERRED from files. A consumer deciding whether to
71
+ * run a `remote-write` task unattended should be able to see the difference.
72
+ */
73
+ backfilled?: boolean;
62
74
  /** Who produced this file, and when. Both are needed to judge staleness. */
63
75
  generatedBy: string;
64
76
  generatedOn: string;
@@ -68,12 +80,16 @@ export interface ProjectDescriptor {
68
80
  hasWebUi: boolean;
69
81
  hasCron: boolean;
70
82
  };
83
+ /**
84
+ * `null` when the owner is not known: a backfilled repo with no `git remote`,
85
+ * or a scaffold made with `repoOwnerUnknown: true`. Never a guessed org.
86
+ */
71
87
  repo: {
72
88
  host: "github";
73
89
  org: string;
74
90
  name: string;
75
91
  url: string;
76
- };
92
+ } | null;
77
93
  deploy: {
78
94
  /** `null` where the scaffold genuinely does not determine one. */
79
95
  target: string | null;
@@ -88,6 +104,19 @@ export interface ProjectDescriptor {
88
104
  taskSource: TaskSource;
89
105
  tasks: Partial<Record<TaskVerb, ProjectTask>>;
90
106
  }
107
+ /**
108
+ * Map the npm scripts a scaffold actually emitted onto the closed vocabulary.
109
+ *
110
+ * The left side of each pair is the VERB; the right side is the list of script
111
+ * names that legitimately implement it, most-preferred first. A verb with no
112
+ * matching script yields NO task — see design rule 3.
113
+ *
114
+ * `db:push` implements `migrate` because it is the command that APPLIES schema
115
+ * to a database. `db:generate` deliberately maps to nothing: it writes migration
116
+ * files locally and is a different act with a different safety class, and a
117
+ * closed vocabulary drops what does not fit rather than bending a verb to cover it.
118
+ */
119
+ export declare const NPM_SCRIPT_FOR_VERB: Readonly<Record<TaskVerb, readonly string[]>>;
91
120
  /**
92
121
  * Compose the descriptor for a completed scaffold.
93
122
  *
@@ -110,7 +110,7 @@ function task(verb, command) {
110
110
  * files locally and is a different act with a different safety class, and a
111
111
  * closed vocabulary drops what does not fit rather than bending a verb to cover it.
112
112
  */
113
- const NPM_SCRIPT_FOR_VERB = {
113
+ export const NPM_SCRIPT_FOR_VERB = {
114
114
  dev: ["dev"],
115
115
  build: ["build"],
116
116
  test: ["test"],
@@ -251,12 +251,14 @@ export function buildProjectDescriptor(inputs, files, opts) {
251
251
  hasWebUi: inputs.hasWebUi,
252
252
  hasCron: inputs.hasCron,
253
253
  },
254
- repo: {
255
- host: "github",
256
- org: inputs.githubOrg,
257
- name: inputs.slug,
258
- url: `https://github.com/${inputs.githubOrg}/${inputs.slug}`,
259
- },
254
+ repo: inputs.repoOwnerUnknown === true
255
+ ? null
256
+ : {
257
+ host: "github",
258
+ org: inputs.githubOrg,
259
+ name: inputs.slug,
260
+ url: `https://github.com/${inputs.githubOrg}/${inputs.slug}`,
261
+ },
260
262
  deploy: { target: deployTarget(inputs.projectType, paths) },
261
263
  coordination: {
262
264
  participates,
package/dist/index.d.ts CHANGED
@@ -108,6 +108,23 @@ export interface ScaffoldInputs {
108
108
  projectType: ProjectType;
109
109
  brand: BrandPreset;
110
110
  githubOrg: string;
111
+ /**
112
+ * `true` when the caller does NOT know who will own the GitHub repo, so
113
+ * `githubOrg` is only a stand-in. The descriptor then records `repo: null`
114
+ * instead of `github.com/{githubOrg}/{slug}`. Added v0.38.0 at
115
+ * `project-creator`'s request: its download path has no knowable owner, and
116
+ * without this an outside customer's file claimed a `zero2webmaster` repo.
117
+ *
118
+ * Optional; omitted means `githubOrg` is the real owner, which is what every
119
+ * caller before v0.38.0 meant. Programmatic and `--input` only: the wizard
120
+ * asks for the org, so an interactive run always knows it. The null heals
121
+ * itself: once the project has a `git remote`, `check-descriptor.mjs --write`
122
+ * fills `repo` in from it.
123
+ *
124
+ * It affects ONLY the descriptor. Other emitted files that name the org
125
+ * (README clone lines, the AGENTS body) still use `githubOrg`.
126
+ */
127
+ repoOwnerUnknown?: boolean;
111
128
  targetPath: string;
112
129
  dbStrategy: DbStrategy;
113
130
  hasWebUi: boolean;
@@ -416,4 +433,6 @@ export type { AudienceGateReport, WriteScaffoldOptions, WriteScaffoldResult, Pro
416
433
  export { resolveStandards, applyStandardsBlock, fathomEnvVarFor } from "./standards.js";
417
434
  export type { StandardKey, StandardDecision, StandardDecisionState, StandardsResolution, } from "./standards.js";
418
435
  export { scaffoldByType } from "./scaffolders/index.js";
436
+ export { deriveStandard, planDelivery, deliveryBanner, probeInputs, DELIVERY_CLASS, } from "./standard.js";
437
+ export type { DeliveryClass, DeliveryPlanItem, RepoFacts } from "./standard.js";
419
438
  export type { ScaffoldFile, ScaffolderOptions } from "./scaffolders/common.js";
package/dist/index.js CHANGED
@@ -182,3 +182,4 @@ export { writeScaffold };
182
182
  export { parseScaffoldInputs, loadScaffoldInputs, WriterError } from "./writer.js";
183
183
  export { resolveStandards, applyStandardsBlock, fathomEnvVarFor } from "./standards.js";
184
184
  export { scaffoldByType } from "./scaffolders/index.js";
185
+ export { deriveStandard, planDelivery, deliveryBanner, probeInputs, DELIVERY_CLASS, } from "./standard.js";
@@ -835,23 +835,28 @@ const COORDINATION_ONBOARDING_TEMPLATE = `# Coordination Onboarding — {{slug}}
835
835
  ## Where the canonical primer lives
836
836
 
837
837
  Read **\`COORDINATION_ONBOARDING.md\`** at the root of the coordination bulletin repo
838
- (\`zero2webmaster/z2w-agent-coordination\`), cloned locally at one of:
838
+ (\`zero2webmaster/z2w-agent-coordination\`). There is ONE local clone, at
839
+ \`~/.cache/z2w-coordination\` — the Desktop path
840
+ \`~/Desktop/Zero2Webmaster/AI/Cursor Projects/z2w-agent-coordination/\` is a symlink to it.
839
841
 
840
- - \`~/Desktop/Zero2Webmaster/AI/Cursor Projects/z2w-agent-coordination/COORDINATION_ONBOARDING.md\` (primary), or
841
- - \`~/.cache/z2w-coordination/COORDINATION_ONBOARDING.md\` (fallback clone)
842
+ 🔴 **Never \`git pull\` or edit in that shared clone.** Take a private workspace
843
+ first — from the clone, \`WS="$(bash scripts/agent-workspace.sh {{slug}})"\` then
844
+ \`cd "$WS"\` — and read and write only there. The \`## Agent Coordination\` section of
845
+ this project's \`CLAUDE.md\` has the exact steps; where it and the primer disagree,
846
+ the live \`AGENT_PROTOCOL.md\` wins.
842
847
 
843
- \`git pull --ff-only\` first, then read it. It orients you to the three core Z2W
844
- systems (the coordination bulletin, the Skill Vault, and the starter-kit + Templates)
845
- and walks you through joining the bulletin as \`{{slug}}\`.
848
+ The primer orients you to the three core Z2W systems (the coordination bulletin,
849
+ the Skill Vault, and the starter-kit + Templates) and walks you through joining
850
+ the bulletin as \`{{slug}}\`.
846
851
 
847
852
  ## The one rule that must not drift
848
853
 
849
- When you install the \`## Agent Coordination\` participation block into this project's
850
- \`CLAUDE.md\` / \`AGENTS.md\`, **always copy it verbatim from the live \`AGENT_PROTOCOL.md\`**
851
- in the bulletin repo — it carries the current
852
- \`<!-- z2w-agent-coordination canonical-block vX.Y.Z -->\` fingerprint. **Never** copy a
853
- version-frozen block from another project or from a primer snapshot; that is exactly
854
- how canonical-block drift happens.
854
+ The \`## Agent Coordination\` section of this project's \`CLAUDE.md\` / \`AGENTS.md\` is
855
+ either a short **pointer** to the live \`AGENT_PROTOCOL.md\` (preferred) or a
856
+ **verbatim** copy of it carrying the current
857
+ \`<!-- z2w-agent-coordination canonical-block vX.Y.Z -->\` fingerprint. **Never
858
+ paraphrase it**, and never copy a version-frozen block from another project or
859
+ from a primer snapshot — that is exactly how canonical-block drift happens.
855
860
 
856
861
  ## Your bulletin file
857
862
 
@@ -13,6 +13,30 @@ export declare function withPwaWiring(layout: string): string;
13
13
  * restating four paths per assertion — same job as NEXTJS_SEO_BASELINE_PATHS.
14
14
  */
15
15
  export declare const NEXTJS_PWA_PATHS: readonly ["public/manifest.json", "public/icon.svg", "public/sw.js", "components/ServiceWorker.tsx"];
16
+ /**
17
+ * Vercel's Ignored Build Step, committed in-repo so it is reviewable and
18
+ * survives a re-import (a dashboard setting is neither). Filed by
19
+ * `audit-engine` 2026-09-22: across 19 Z2W Vercel projects, 35.6% of commits to
20
+ * `main` changed no application code, and build CPU was 71% of the bill.
21
+ *
22
+ * 🔴 Vercel's exit codes are INVERTED — `0` SKIPS the build, anything else
23
+ * builds. Every branch below that is not "provably prose-only" exits 1, so a
24
+ * wrong rule costs a build and never a deploy:
25
+ *
26
+ * - The base is `VERCEL_GIT_PREVIOUS_SHA`, the last SUCCESSFUL deploy — never
27
+ * `HEAD^`, which sees only the last commit of a push. A code commit followed
28
+ * by a docs commit, pushed together (every Z2W session end), would otherwise
29
+ * skip the code. A canceled deploy is not "successful", so skipped pushes
30
+ * accumulate against the same base until one real change builds them all.
31
+ * - An EMPTY base BUILDS. `audit-engine`'s dashboard rule falls back to
32
+ * `HEAD^` there, which is fine for a long-deployed `main` but wrong for a new
33
+ * scaffold: a repo with history is linked to Vercel later, and its first
34
+ * deploy must not be skipped because the newest commit was a STATUS.md edit.
35
+ * - A base missing from Vercel's shallow clone fails `cat-file` → builds.
36
+ *
37
+ * Must stay ≤ 256 characters (the vercel.json schema's `maxLength`).
38
+ */
39
+ export declare const VERCEL_IGNORE_COMMAND: string;
16
40
  export declare function scaffoldNextjs(inputs: ScaffoldInputs, opts?: ScaffolderOptions): ScaffoldFile[];
17
41
  /**
18
42
  * Exported for tests + the eventual standards-conflict resolver in Step 5 so
@@ -2994,7 +2994,7 @@ import {
2994
2994
  type ContrastRole,
2995
2995
  } from "../lib/a11y/contrast";
2996
2996
 
2997
- // NOT \\\`__dirname\\\` — this package is "type": "module", where it is undefined.
2997
+ // NOT \`__dirname\` — this package is "type": "module", where it is undefined.
2998
2998
  const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
2999
2999
  const CSS_RAW = readFileSync(join(ROOT, "app/globals.css"), "utf8");
3000
3000
 
@@ -5356,6 +5356,178 @@ function withExtraDevDeps(pkgJson, extra) {
5356
5356
  obj.devDependencies = { ...obj.devDependencies, ...extra };
5357
5357
  return JSON.stringify(obj, null, 2) + "\n";
5358
5358
  }
5359
+ function withExtraScripts(pkgJson, extra) {
5360
+ const obj = JSON.parse(pkgJson);
5361
+ obj.scripts = { ...obj.scripts, ...extra };
5362
+ return JSON.stringify(obj, null, 2) + "\n";
5363
+ }
5364
+ /**
5365
+ * The migration half of the Neon data layer. Until v0.38.0 a neon-postgres
5366
+ * Next.js scaffold installed `drizzle-kit` and emitted `db/schema.ts` but no
5367
+ * config and no script, so there was no wired way to apply the schema — and the
5368
+ * descriptor, correctly, listed no `migrate` task. Found by `project-creator`
5369
+ * (2026-09-22) as the first programmatic consumer of the descriptor.
5370
+ * `node-service` has always emitted both; this brings `nextjs` level with it.
5371
+ */
5372
+ const NEON_DB_SCRIPTS = {
5373
+ "db:generate": "drizzle-kit generate",
5374
+ "db:push": "drizzle-kit push",
5375
+ };
5376
+ const DRIZZLE_CONFIG_TEMPLATE = `// drizzle-kit config for {{slug}}.
5377
+ //
5378
+ // \`npm run db:generate\` writes SQL migrations from db/schema.ts into ./drizzle
5379
+ // (no database needed). \`npm run db:push\` applies the schema to DATABASE_URL.
5380
+ // Before pushing to a database that already has rows, read the
5381
+ // [[drizzle-migration-safety]] skill.
5382
+
5383
+ import { defineConfig } from "drizzle-kit";
5384
+
5385
+ // drizzle-kit does not read Next.js's .env.local on its own. Load it when it is
5386
+ // there (local dev). In CI or on a host the file is absent and DATABASE_URL
5387
+ // comes from the real environment.
5388
+ try {
5389
+ process.loadEnvFile(".env.local");
5390
+ } catch {
5391
+ // No .env.local here, so use the environment as it is.
5392
+ }
5393
+
5394
+ // \`generate\` never connects, so it must work with no DATABASE_URL at all.
5395
+ // Every other command does connect, and an empty URL fails with an error that
5396
+ // never mentions the variable. Name it instead.
5397
+ const url = process.env.DATABASE_URL ?? "";
5398
+ if (url === "" && !process.argv.includes("generate")) {
5399
+ throw new Error(
5400
+ "DATABASE_URL is not set. Set it in .env.local (local) or in the environment, then run the db:* script again.",
5401
+ );
5402
+ }
5403
+
5404
+ export default defineConfig({
5405
+ schema: "./db/schema.ts",
5406
+ out: "./drizzle",
5407
+ dialect: "postgresql",
5408
+ dbCredentials: { url },
5409
+ });
5410
+ `;
5411
+ /**
5412
+ * Vercel's Ignored Build Step, committed in-repo so it is reviewable and
5413
+ * survives a re-import (a dashboard setting is neither). Filed by
5414
+ * `audit-engine` 2026-09-22: across 19 Z2W Vercel projects, 35.6% of commits to
5415
+ * `main` changed no application code, and build CPU was 71% of the bill.
5416
+ *
5417
+ * 🔴 Vercel's exit codes are INVERTED — `0` SKIPS the build, anything else
5418
+ * builds. Every branch below that is not "provably prose-only" exits 1, so a
5419
+ * wrong rule costs a build and never a deploy:
5420
+ *
5421
+ * - The base is `VERCEL_GIT_PREVIOUS_SHA`, the last SUCCESSFUL deploy — never
5422
+ * `HEAD^`, which sees only the last commit of a push. A code commit followed
5423
+ * by a docs commit, pushed together (every Z2W session end), would otherwise
5424
+ * skip the code. A canceled deploy is not "successful", so skipped pushes
5425
+ * accumulate against the same base until one real change builds them all.
5426
+ * - An EMPTY base BUILDS. `audit-engine`'s dashboard rule falls back to
5427
+ * `HEAD^` there, which is fine for a long-deployed `main` but wrong for a new
5428
+ * scaffold: a repo with history is linked to Vercel later, and its first
5429
+ * deploy must not be skipped because the newest commit was a STATUS.md edit.
5430
+ * - A base missing from Vercel's shallow clone fails `cat-file` → builds.
5431
+ *
5432
+ * Must stay ≤ 256 characters (the vercel.json schema's `maxLength`).
5433
+ */
5434
+ export const VERCEL_IGNORE_COMMAND = [
5435
+ 'B="$VERCEL_GIT_PREVIOUS_SHA"',
5436
+ '[ -n "$B" ] || exit 1',
5437
+ 'git cat-file -e "$B^{commit}" 2>/dev/null || exit 1',
5438
+ `git diff --quiet "$B" HEAD -- . ':(exclude)*.md' ':(exclude)docs/' ':(exclude)drafts/' || exit 1`,
5439
+ "exit 0",
5440
+ ].join("; ");
5441
+ const VERCEL_JSON = JSON.stringify({ $schema: "https://openapi.vercel.sh/vercel.json", ignoreCommand: VERCEL_IGNORE_COMMAND }, null, 2) + "\n";
5442
+ // The consumer-side guard. The one way the rule above loses a real deploy is a
5443
+ // project that later starts building pages FROM Markdown — so the check has to
5444
+ // live in the project, where that change happens, not in this CLI.
5445
+ const VERCEL_IGNORE_TEST_TEMPLATE = `/**
5446
+ * vercel.json carries an Ignored Build Step: a push that changes nothing but
5447
+ * Markdown (STATUS.md, HANDOFF.md, CHANGELOG.md, ...) does NOT rebuild the site.
5448
+ * Measured 2026-09-22 across 19 Zero2Webmaster Vercel projects: 35.6% of commits
5449
+ * to main changed no application code, and build CPU was 71% of the Vercel bill.
5450
+ *
5451
+ * Vercel's exit codes are INVERTED: exit 0 SKIPS the build, anything else builds.
5452
+ * Every failure path in the rule exits 1, so a broken rule costs a build, never
5453
+ * a deploy. The diff base is VERCEL_GIT_PREVIOUS_SHA (the last SUCCESSFUL
5454
+ * deploy), never HEAD^ — HEAD^ sees only the last commit of a push, so a code
5455
+ * commit and a docs commit pushed together would skip the code.
5456
+ *
5457
+ * THE ONE WAY THIS RULE LOSES A REAL DEPLOY: this project starts building pages
5458
+ * FROM Markdown. A content edit then changes only *.md files, and never ships.
5459
+ * The last test below fails the moment that becomes possible. When it does,
5460
+ * remove ':(exclude)*.md' from vercel.json — or delete the ignoreCommand.
5461
+ */
5462
+ import { describe, it, expect } from "vitest";
5463
+ import { readFileSync, readdirSync, existsSync } from "node:fs";
5464
+ import { join, dirname } from "node:path";
5465
+ import { fileURLToPath } from "node:url";
5466
+
5467
+ // NOT \`__dirname\` — this package is "type": "module", where it is undefined.
5468
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
5469
+
5470
+ const TOOLCHAIN_EXACT = [
5471
+ "@next/mdx",
5472
+ "next-mdx-remote",
5473
+ "gray-matter",
5474
+ "velite",
5475
+ "markdown-it",
5476
+ "marked",
5477
+ "react-markdown",
5478
+ ];
5479
+ const TOOLCHAIN_PREFIX = ["@mdx-js/", "contentlayer", "fumadocs", "remark", "rehype"];
5480
+
5481
+ function isMarkdownToolchain(name: string): boolean {
5482
+ return TOOLCHAIN_EXACT.includes(name) || TOOLCHAIN_PREFIX.some((p) => name.startsWith(p));
5483
+ }
5484
+
5485
+ function markdownUnder(dir: string): string[] {
5486
+ const abs = join(ROOT, dir);
5487
+ if (!existsSync(abs)) return [];
5488
+ const out: string[] = [];
5489
+ for (const e of readdirSync(abs, { withFileTypes: true })) {
5490
+ if (e.name === "node_modules" || e.name.startsWith(".")) continue;
5491
+ const rel = join(dir, e.name);
5492
+ if (e.isDirectory()) out.push(...markdownUnder(rel));
5493
+ else if (e.name.endsWith(".md")) out.push(rel);
5494
+ }
5495
+ return out;
5496
+ }
5497
+
5498
+ const vercelPath = join(ROOT, "vercel.json");
5499
+ const rule: string = existsSync(vercelPath)
5500
+ ? (JSON.parse(readFileSync(vercelPath, "utf8")).ignoreCommand ?? "")
5501
+ : "";
5502
+
5503
+ describe("vercel.json Ignored Build Step", () => {
5504
+ it("fits the 256-character limit in Vercel's vercel.json schema", () => {
5505
+ expect(rule.length).toBeLessThanOrEqual(256);
5506
+ });
5507
+
5508
+ it("diffs against the last successful deploy, never against HEAD^", () => {
5509
+ if (!rule) return; // no rule at all is a sanctioned choice
5510
+ expect(rule).toContain("VERCEL_GIT_PREVIOUS_SHA");
5511
+ expect(rule).not.toContain("HEAD^");
5512
+ });
5513
+
5514
+ it("does not skip Markdown-only pushes in a project that builds pages from Markdown", () => {
5515
+ if (!rule.includes("*.md")) return;
5516
+ const pkg = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8"));
5517
+ const deps = Object.keys({ ...pkg.dependencies, ...pkg.devDependencies });
5518
+ const found = [
5519
+ ...deps.filter(isMarkdownToolchain),
5520
+ ...["app", "content", "posts"].flatMap(markdownUnder),
5521
+ ];
5522
+ expect(
5523
+ found,
5524
+ "This project can now build pages from Markdown, but vercel.json skips builds " +
5525
+ "when only *.md files change — so a content edit would never deploy. " +
5526
+ "Remove ':(exclude)*.md' from the ignoreCommand in vercel.json.",
5527
+ ).toEqual([]);
5528
+ });
5529
+ });
5530
+ `;
5359
5531
  export function scaffoldNextjs(inputs, opts) {
5360
5532
  const spec = resolveBrandSpec(inputs);
5361
5533
  const base = commonBaseFiles(inputs, opts, NARRATIVE);
@@ -5400,6 +5572,7 @@ export function scaffoldNextjs(inputs, opts) {
5400
5572
  if (usesNeonDb) {
5401
5573
  packageJson = withExtraDeps(packageJson, NEON_DB_LAYER_DEPS);
5402
5574
  packageJson = withExtraDevDeps(packageJson, NEON_DB_LAYER_DEV_DEPS);
5575
+ packageJson = withExtraScripts(packageJson, NEON_DB_SCRIPTS);
5403
5576
  }
5404
5577
  else if (durableLimit) {
5405
5578
  packageJson = withExtraDeps(packageJson, NEON_DRIVER_DEP);
@@ -5440,6 +5613,10 @@ export function scaffoldNextjs(inputs, opts) {
5440
5613
  },
5441
5614
  { path: "tsconfig.json", content: sub(TSCONFIG_TEMPLATE, inputs, opts, spec) },
5442
5615
  { path: "vitest.config.ts", content: VITEST_CONFIG_TEMPLATE },
5616
+ // Skip Vercel builds for prose-only pushes; the test guards the one case
5617
+ // where that would lose a deploy (a project that builds pages from Markdown).
5618
+ { path: "vercel.json", content: VERCEL_JSON },
5619
+ { path: "test/vercel-ignore.test.ts", content: VERCEL_IGNORE_TEST_TEMPLATE },
5443
5620
  { path: "test/server-only.stub.ts", content: SERVER_ONLY_STUB_TEMPLATE },
5444
5621
  { path: "app/globals.css", content: globalsCss(spec.primaryColor) },
5445
5622
  { path: "components/FormBits.tsx", content: sub(FORM_BITS_TEMPLATE, inputs, opts, spec) },
@@ -5562,7 +5739,7 @@ export function scaffoldNextjs(inputs, opts) {
5562
5739
  typeSpecific.push({ path: "db/client.ts", content: sub(DB_CLIENT_TEMPLATE, inputs, opts, spec) }, { path: "db/pool-errors.ts", content: sub(DB_POOL_ERRORS_TEMPLATE, inputs, opts, spec) }, {
5563
5740
  path: "db/pool-errors.test.ts",
5564
5741
  content: sub(DB_POOL_ERRORS_TEST_TEMPLATE, inputs, opts, spec),
5565
- }, { path: "db/schema.ts", content: sub(DB_SCHEMA_TEMPLATE, inputs, opts, spec) }, { path: "db/client.test.ts", content: sub(DB_CLIENT_TEST_TEMPLATE, inputs, opts, spec) });
5742
+ }, { path: "db/schema.ts", content: sub(DB_SCHEMA_TEMPLATE, inputs, opts, spec) }, { path: "db/client.test.ts", content: sub(DB_CLIENT_TEST_TEMPLATE, inputs, opts, spec) }, { path: "drizzle.config.ts", content: sub(DRIZZLE_CONFIG_TEMPLATE, inputs, opts, spec) });
5566
5743
  }
5567
5744
  return [...base, ...typeSpecific];
5568
5745
  }
@@ -0,0 +1,56 @@
1
+ import type { ProjectType, ScaffoldInputs } from "./index.js";
2
+ /** Why a standard path is or is not safe to add to an EXISTING repo. */
3
+ export type DeliveryClass =
4
+ /** The stub is true for a repo of any age. Safe to add where absent. */
5
+ "deliverable"
6
+ /** Scaffold-time content asserts a newborn project. The project's own agent
7
+ * must write it; delivery reports it and writes nothing. */
8
+ | "birth-only"
9
+ /** Has its own purpose-built tool, which delivery defers to. */
10
+ | "own-tool";
11
+ export declare const DELIVERY_CLASS: Readonly<Record<string, DeliveryClass>>;
12
+ /** Neutral probe inputs: the floor for a type, not one configuration of it. */
13
+ export declare function probeInputs(projectType: ProjectType, over?: Partial<ScaffoldInputs>): ScaffoldInputs;
14
+ /**
15
+ * THE STANDARD: paths every project type is given, for a project that does
16
+ * (default) or does not participate in the coordination bulletin. A
17
+ * non-participant is never given COORDINATION_ONBOARDING.md, so measuring it
18
+ * against the participant standard reports a gap that is not one.
19
+ */
20
+ export declare function deriveStandard(opts?: {
21
+ participates?: boolean;
22
+ date?: string;
23
+ }): string[];
24
+ /** What delivery knows about a repo, read from its `z2w-project.json`. */
25
+ export interface RepoFacts {
26
+ slug: string;
27
+ description: string;
28
+ githubOrg: string;
29
+ /** null when the descriptor declares none — content must then be proven
30
+ * identical across every type before it may be written. */
31
+ projectType: ProjectType | null;
32
+ participates: boolean;
33
+ /** The repo's own VERSION file, or null. */
34
+ version: string | null;
35
+ /** Files already in the repo's `directives/`, so the delivered architecture
36
+ * directive lists what is really there instead of claiming it is alone. */
37
+ directives?: readonly string[];
38
+ }
39
+ export interface DeliveryPlanItem {
40
+ path: string;
41
+ action: "write" | "report";
42
+ /** Why a path was not written, when action is "report". */
43
+ reason?: string;
44
+ content?: string;
45
+ }
46
+ /** The first-line banner placed under a delivered Markdown file's H1. */
47
+ export declare function deliveryBanner(date: string, cliVersion: string, kind?: "stub" | "complete"): string;
48
+ /**
49
+ * Plan what to add to one repo. PURE — takes the set of paths already present
50
+ * and returns content; the script does all file I/O. Never plans a write over
51
+ * a path that exists.
52
+ */
53
+ export declare function planDelivery(facts: RepoFacts, present: ReadonlySet<string>, opts: {
54
+ date: string;
55
+ cliVersion: string;
56
+ }): DeliveryPlanItem[];
@@ -0,0 +1,160 @@
1
+ // THE Z2W PROJECT STANDARD — derived, classified, and deliverable.
2
+ //
3
+ // Two scripts read this module: `scripts/check-conformance.mjs` MEASURES which
4
+ // standard files a repo lacks, and `scripts/deliver-standard.mjs` ADDS the ones
5
+ // that can be added honestly. They share one derivation so the two can never
6
+ // disagree about what "the standard" is — a second copy of a fact the
7
+ // scaffolder already holds is exactly what this repo keeps measuring drift in.
8
+ //
9
+ // 🔴 WHY DELIVERY IS A SUBSET, NOT THE WHOLE STANDARD (2026-09-22).
10
+ // The standard grew from ~11 files to 16 with no mechanism to reach repos built
11
+ // before each addition, so 48 of 57 repos had gaps. But the scaffolder writes
12
+ // every file for a project that is ZERO SECONDS OLD. Some of that content is
13
+ // true at any age ("here is an empty troubleshooting log"); some is true only
14
+ // at birth ("v0.1.0", "begin ROADMAP Step 1", a first-session kickoff prompt).
15
+ // Writing the second kind into a two-year-old repo is not delivering a
16
+ // standard — it is emitting a false document with a confident header. So every
17
+ // standard path is classified below, and a path added to the scaffolder with
18
+ // no classification FAILS the test suite until someone decides which it is.
19
+ import { scaffoldByType } from "./scaffolders/index.js";
20
+ import { BRANDS, PROJECT_TYPES } from "./index.js";
21
+ export const DELIVERY_CLASS = {
22
+ "BACKUPS.md": "deliverable",
23
+ "marketing.md": "deliverable",
24
+ "TROUBLESHOOTING.md": "deliverable",
25
+ "COORDINATION_ONBOARDING.md": "deliverable",
26
+ "directives/system-architecture.md": "deliverable",
27
+ ".cursorignore": "deliverable",
28
+ ".cursorindexingignore": "deliverable",
29
+ // Birth-only: each would tell a mature repo it is v0.1.0 / has no history /
30
+ // should start at Step 1, or (CLAUDE.md) would shadow the project's own brain.
31
+ "CLAUDE.md": "birth-only",
32
+ "README.md": "birth-only",
33
+ "ROADMAP.md": "birth-only",
34
+ "STATUS.md": "birth-only",
35
+ "HANDOFF.md": "birth-only",
36
+ "CHANGELOG.md": "birth-only",
37
+ "VERSION": "birth-only",
38
+ // Type-specific, and a repo that lacks it needs a MERGE, not a file.
39
+ ".gitignore": "birth-only",
40
+ "z2w-project.json": "own-tool", // scripts/check-descriptor.mjs --write
41
+ };
42
+ /** Neutral probe inputs: the floor for a type, not one configuration of it. */
43
+ export function probeInputs(projectType, over = {}) {
44
+ return {
45
+ slug: "conformance-probe",
46
+ description: "A throwaway project used to derive the project standard.",
47
+ projectType,
48
+ brand: "zero2webmaster",
49
+ githubOrg: "zero2webmaster",
50
+ targetPath: "/tmp/conformance-probe",
51
+ dbStrategy: "none",
52
+ hasWebUi: false,
53
+ hasCron: false,
54
+ participateInBulletin: true,
55
+ ...over,
56
+ };
57
+ }
58
+ function emit(projectType, over, date) {
59
+ return scaffoldByType(probeInputs(projectType, over), { date, frameworkVersion: "0.0.0" });
60
+ }
61
+ /**
62
+ * THE STANDARD: paths every project type is given, for a project that does
63
+ * (default) or does not participate in the coordination bulletin. A
64
+ * non-participant is never given COORDINATION_ONBOARDING.md, so measuring it
65
+ * against the participant standard reports a gap that is not one.
66
+ */
67
+ export function deriveStandard(opts = {}) {
68
+ const date = opts.date ?? new Date().toISOString().slice(0, 10);
69
+ const sets = PROJECT_TYPES.map((t) => new Set(emit(t, { participateInBulletin: opts.participates !== false }, date).map((f) => f.path)));
70
+ const [first, ...rest] = sets;
71
+ return [...(first ?? [])].filter((p) => rest.every((s) => s.has(p))).sort();
72
+ }
73
+ /** Delivered files that are complete as written — a pointer, a config — and
74
+ * must not be labelled "fill this in". */
75
+ const COMPLETE_AS_WRITTEN = new Set(["COORDINATION_ONBOARDING.md"]);
76
+ /** The first-line banner placed under a delivered Markdown file's H1. */
77
+ export function deliveryBanner(date, cliVersion, kind = "stub") {
78
+ const head = `> 📦 **Delivered ${date} by \`z2w-starter-kit\` v${cliVersion}** to a repo scaffolded before this\n` +
79
+ `> file joined the Z2W project standard.`;
80
+ return kind === "complete"
81
+ ? `${head} It is a pointer and needs no editing.`
82
+ : `${head} It is an **unfilled stub** — nothing in it was\n` +
83
+ `> measured from this repo. Fill it in, or mark it N/A and say why.`;
84
+ }
85
+ function withBanner(path, content, banner) {
86
+ if (!path.endsWith(".md"))
87
+ return content;
88
+ const lines = content.split("\n");
89
+ const h1 = lines.findIndex((l) => l.startsWith("# "));
90
+ if (h1 === -1)
91
+ return `${banner}\n\n${content}`;
92
+ lines.splice(h1 + 1, 0, "", banner);
93
+ return lines.join("\n");
94
+ }
95
+ /** Replace the scaffold-time version with the repo's real one, or drop it. */
96
+ function fixDirectiveVersion(content, version) {
97
+ return content.replace(/^\*\*Version:\*\* [^|]+\| /m, version ? `**Version:** ${version} | ` : "");
98
+ }
99
+ /** The scaffold says this file is the only directive; in an old repo it rarely is. */
100
+ function listRealDirectives(content, existing) {
101
+ const names = [...new Set([...existing, "system-architecture.md"])].sort();
102
+ const list = names
103
+ .map((n) => (n === "system-architecture.md" ? `- \`${n}\` (this file)` : `- \`${n}\``))
104
+ .join("\n");
105
+ return content.replace(/- `system-architecture\.md` \(this file\)/, list);
106
+ }
107
+ /**
108
+ * Plan what to add to one repo. PURE — takes the set of paths already present
109
+ * and returns content; the script does all file I/O. Never plans a write over
110
+ * a path that exists.
111
+ */
112
+ export function planDelivery(facts, present, opts) {
113
+ const standard = deriveStandard({ participates: facts.participates, date: opts.date });
114
+ const missing = standard.filter((p) => !present.has(p));
115
+ const plan = [];
116
+ const over = {
117
+ slug: facts.slug,
118
+ description: facts.description,
119
+ githubOrg: facts.githubOrg,
120
+ participateInBulletin: facts.participates,
121
+ };
122
+ // Content is only trusted if it does not depend on an input we do not know.
123
+ // The brand is never recorded in a descriptor, and the type sometimes is not,
124
+ // so every unknown axis is VARIED and the output must come out identical.
125
+ const types = facts.projectType ? [facts.projectType] : PROJECT_TYPES;
126
+ const variants = [];
127
+ for (const t of types) {
128
+ for (const b of BRANDS.filter((x) => x !== "custom")) {
129
+ variants.push(new Map(emit(t, { ...over, brand: b }, opts.date).map((f) => [f.path, f.content])));
130
+ }
131
+ }
132
+ for (const path of missing) {
133
+ const cls = DELIVERY_CLASS[path];
134
+ if (cls === undefined) {
135
+ plan.push({ path, action: "report", reason: "UNCLASSIFIED — add it to DELIVERY_CLASS in src/standard.ts" });
136
+ continue;
137
+ }
138
+ if (cls === "birth-only") {
139
+ plan.push({ path, action: "report", reason: "scaffold-time content describes a newborn project — this project's agent should write it" });
140
+ continue;
141
+ }
142
+ if (cls === "own-tool") {
143
+ plan.push({ path, action: "report", reason: "run scripts/check-descriptor.mjs --write" });
144
+ continue;
145
+ }
146
+ const contents = new Set(variants.map((v) => v.get(path)));
147
+ if (contents.size !== 1 || contents.has(undefined)) {
148
+ plan.push({ path, action: "report", reason: "content depends on an input this repo does not record (type or brand) — not guessed" });
149
+ continue;
150
+ }
151
+ let content = [...contents][0];
152
+ if (path === "directives/system-architecture.md") {
153
+ content = fixDirectiveVersion(content, facts.version);
154
+ content = listRealDirectives(content, facts.directives ?? []);
155
+ }
156
+ const banner = deliveryBanner(opts.date, opts.cliVersion, COMPLETE_AS_WRITTEN.has(path) ? "complete" : "stub");
157
+ plan.push({ path, action: "write", content: withBanner(path, content, banner) });
158
+ }
159
+ return plan;
160
+ }