@zero2webmaster/starter-kit 0.36.0 → 0.39.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 +2 -2
- package/dist/descriptor.d.ts +8 -2
- package/dist/descriptor.js +8 -6
- package/dist/index.d.ts +21 -0
- package/dist/index.js +2 -0
- package/dist/portfolio.d.ts +38 -0
- package/dist/portfolio.js +88 -0
- package/dist/scaffolders/common.d.ts +1 -0
- package/dist/scaffolders/common.js +21 -13
- package/dist/scaffolders/nextjs.js +54 -1
- package/dist/standard.d.ts +56 -0
- package/dist/standard.js +160 -0
- package/dist/standards.js +3 -1
- package/dist/writer.js +10 -0
- package/package.json +2 -1
- package/scripts/check-conformance.mjs +35 -40
- package/scripts/check-descriptor.mjs +90 -7
- package/scripts/deliver-standard.mjs +201 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 0.
|
|
3
|
+
**Version:** 0.39.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.
|
|
138
|
+
*Version: 0.39.0 | Last Updated: 2026-09-24*
|
package/dist/descriptor.d.ts
CHANGED
|
@@ -75,17 +75,23 @@ export interface ProjectDescriptor {
|
|
|
75
75
|
generatedBy: string;
|
|
76
76
|
generatedOn: string;
|
|
77
77
|
stack: {
|
|
78
|
-
|
|
78
|
+
/** `"unknown"` only in a BACKFILLED descriptor, where nothing on disk said;
|
|
79
|
+
* a scaffold always knows its runtime. `"none"` is a claim (a protocol repo). */
|
|
80
|
+
runtime: "node" | "python" | "php" | "static" | "none" | "unknown";
|
|
79
81
|
database: string;
|
|
80
82
|
hasWebUi: boolean;
|
|
81
83
|
hasCron: boolean;
|
|
82
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* `null` when the owner is not known: a backfilled repo with no `git remote`,
|
|
87
|
+
* or a scaffold made with `repoOwnerUnknown: true`. Never a guessed org.
|
|
88
|
+
*/
|
|
83
89
|
repo: {
|
|
84
90
|
host: "github";
|
|
85
91
|
org: string;
|
|
86
92
|
name: string;
|
|
87
93
|
url: string;
|
|
88
|
-
};
|
|
94
|
+
} | null;
|
|
89
95
|
deploy: {
|
|
90
96
|
/** `null` where the scaffold genuinely does not determine one. */
|
|
91
97
|
target: string | null;
|
package/dist/descriptor.js
CHANGED
|
@@ -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
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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,8 @@ 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";
|
|
438
|
+
export { portfolioRoots, listPortfolio, writeSafe, describeRoots } from "./portfolio.js";
|
|
439
|
+
export type { Portfolio, PortfolioRepo } from "./portfolio.js";
|
|
419
440
|
export type { ScaffoldFile, ScaffolderOptions } from "./scaffolders/common.js";
|
package/dist/index.js
CHANGED
|
@@ -182,3 +182,5 @@ 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";
|
|
186
|
+
export { portfolioRoots, listPortfolio, writeSafe, describeRoots } from "./portfolio.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Top-level folders that hold Z2W project repos, in scan order. */
|
|
2
|
+
export declare function portfolioRoots(env?: NodeJS.ProcessEnv): string[];
|
|
3
|
+
export interface PortfolioRepo {
|
|
4
|
+
/** The path as found under its root (what a caller should pass on). */
|
|
5
|
+
path: string;
|
|
6
|
+
/** The root it was found under. */
|
|
7
|
+
root: string;
|
|
8
|
+
/** True when the top-level entry is a symlink. The Desktop
|
|
9
|
+
* `z2w-agent-coordination` entry is one, into the SHARED bulletin clone —
|
|
10
|
+
* a sweep that WRITES must not touch it (see `writeSafe`). */
|
|
11
|
+
viaSymlink: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface Portfolio {
|
|
14
|
+
roots: Array<{
|
|
15
|
+
path: string;
|
|
16
|
+
present: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
repos: PortfolioRepo[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Every git repo directly under every present root, deduplicated by real path.
|
|
22
|
+
* Missing roots are REPORTED in `roots`, never silently dropped — a machine
|
|
23
|
+
* without the VideoMigrator folder should say so, not print a smaller total as
|
|
24
|
+
* if it were the whole portfolio.
|
|
25
|
+
*/
|
|
26
|
+
export declare function listPortfolio(env?: NodeJS.ProcessEnv): Portfolio;
|
|
27
|
+
/**
|
|
28
|
+
* Repos a WRITING sweep may touch. A symlinked entry is excluded: today the only
|
|
29
|
+
* one is the shared bulletin clone, where an untracked file written by a sweep
|
|
30
|
+
* blocked every agent's fast-forward on 2026-09-19. Run such a repo from a
|
|
31
|
+
* worktree instead.
|
|
32
|
+
*/
|
|
33
|
+
export declare function writeSafe(p: Portfolio): {
|
|
34
|
+
repos: PortfolioRepo[];
|
|
35
|
+
excluded: PortfolioRepo[];
|
|
36
|
+
};
|
|
37
|
+
/** One human-readable line per root, for the top of a sweep's output. */
|
|
38
|
+
export declare function describeRoots(p: Portfolio): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// THE PORTFOLIO IS MORE THAN ONE FOLDER — the one list of where Z2W repos live.
|
|
2
|
+
//
|
|
3
|
+
// Every sweep this repo runs (`check-conformance.mjs`, `deliver-standard.mjs`,
|
|
4
|
+
// `check-descriptor.mjs`) was driven by a shell glob over ONE folder,
|
|
5
|
+
// `~/Desktop/Zero2Webmaster/AI/Cursor Projects/`. Three repos live elsewhere —
|
|
6
|
+
// `videomigrator-engine` and `videomigrator-website` under
|
|
7
|
+
// `~/Desktop/VideoMigrator/Cursor Projects/`, `investing-kk` under
|
|
8
|
+
// `~/Desktop/KERRY KRIGER/Cursor Projects/` — so the 2026-09-19 descriptor
|
|
9
|
+
// backfill reported "57 of 57" and the 2026-09-22 delivery sweep reported "46
|
|
10
|
+
// repos" having never looked at them. Not as failures: as nothing. A glob cannot
|
|
11
|
+
// forget one project, but pointed at the wrong universe it forgets a whole folder
|
|
12
|
+
// at once, and every denominator it prints is confidently wrong.
|
|
13
|
+
//
|
|
14
|
+
// `z2w-agent-coordination` hit the same thing on 2026-09-18 and fixed its drift
|
|
15
|
+
// sweep with this same three-root list (`scripts/check-fingerprint-drift.sh`).
|
|
16
|
+
// Keep the two in step: when Kerry starts a new top-level Cursor Projects
|
|
17
|
+
// folder, add it HERE and THERE. [[zero-is-not-a-pass]]
|
|
18
|
+
import { existsSync, lstatSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
19
|
+
import { homedir } from "node:os";
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
/** Top-level folders that hold Z2W project repos, in scan order. */
|
|
22
|
+
export function portfolioRoots(env = process.env) {
|
|
23
|
+
// A single pinned root, for tests and one-off runs. Same variable name as the
|
|
24
|
+
// bulletin's drift sweep, so one setting aims both.
|
|
25
|
+
if (env.Z2W_PORTFOLIO_DIR)
|
|
26
|
+
return [env.Z2W_PORTFOLIO_DIR];
|
|
27
|
+
const desktop = join(env.HOME ?? homedir(), "Desktop");
|
|
28
|
+
return [
|
|
29
|
+
join(desktop, "Zero2Webmaster", "AI", "Cursor Projects"),
|
|
30
|
+
join(desktop, "VideoMigrator", "Cursor Projects"),
|
|
31
|
+
join(desktop, "KERRY KRIGER", "Cursor Projects"),
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Every git repo directly under every present root, deduplicated by real path.
|
|
36
|
+
* Missing roots are REPORTED in `roots`, never silently dropped — a machine
|
|
37
|
+
* without the VideoMigrator folder should say so, not print a smaller total as
|
|
38
|
+
* if it were the whole portfolio.
|
|
39
|
+
*/
|
|
40
|
+
export function listPortfolio(env = process.env) {
|
|
41
|
+
const roots = portfolioRoots(env).map((path) => ({ path, present: isDir(path) }));
|
|
42
|
+
const seen = new Set();
|
|
43
|
+
const repos = [];
|
|
44
|
+
for (const { path: root, present } of roots) {
|
|
45
|
+
if (!present)
|
|
46
|
+
continue;
|
|
47
|
+
for (const name of readdirSync(root).sort()) {
|
|
48
|
+
if (name.startsWith("."))
|
|
49
|
+
continue;
|
|
50
|
+
const path = join(root, name);
|
|
51
|
+
if (!isDir(path) || !existsSync(join(path, ".git")))
|
|
52
|
+
continue;
|
|
53
|
+
const real = realpathSync(path);
|
|
54
|
+
if (seen.has(real))
|
|
55
|
+
continue;
|
|
56
|
+
seen.add(real);
|
|
57
|
+
repos.push({ path, root, viaSymlink: lstatSync(path).isSymbolicLink() });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { roots, repos };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Repos a WRITING sweep may touch. A symlinked entry is excluded: today the only
|
|
64
|
+
* one is the shared bulletin clone, where an untracked file written by a sweep
|
|
65
|
+
* blocked every agent's fast-forward on 2026-09-19. Run such a repo from a
|
|
66
|
+
* worktree instead.
|
|
67
|
+
*/
|
|
68
|
+
export function writeSafe(p) {
|
|
69
|
+
return {
|
|
70
|
+
repos: p.repos.filter((r) => !r.viaSymlink),
|
|
71
|
+
excluded: p.repos.filter((r) => r.viaSymlink),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** One human-readable line per root, for the top of a sweep's output. */
|
|
75
|
+
export function describeRoots(p) {
|
|
76
|
+
return p.roots
|
|
77
|
+
.map((r) => ` ${r.present ? "✓" : "✗ ABSENT"} ${r.path}` +
|
|
78
|
+
(r.present ? ` (${p.repos.filter((x) => x.root === r.path).length} repo(s))` : ""))
|
|
79
|
+
.join("\n");
|
|
80
|
+
}
|
|
81
|
+
function isDir(p) {
|
|
82
|
+
try {
|
|
83
|
+
return statSync(p).isDirectory();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -75,6 +75,7 @@ export declare function commonHandoff(inputs: ScaffoldInputs, opts: ScaffolderOp
|
|
|
75
75
|
* CLAUDE.md is validated for leftover markers — see writer.ts).
|
|
76
76
|
*/
|
|
77
77
|
export declare function commonProjectBrief(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile | null;
|
|
78
|
+
export declare const COORDINATION_ONBOARDING_TEMPLATE = "# Coordination Onboarding \u2014 {{slug}}\n\n> **Read this first if you're a fresh agent on `{{slug}}`.** This is a short\n> pointer, not the full guide. `{{slug}}` participates in the Z2W cross-project\n> coordination bulletin, and the canonical, always-current onboarding primer lives\n> in the bulletin repo \u2014 **not here** \u2014 so there is a single source of truth.\n\n## Where the canonical primer lives\n\nRead **`COORDINATION_ONBOARDING.md`** at the root of the coordination bulletin repo\n(`zero2webmaster/z2w-agent-coordination`). There is ONE local clone, at\n`~/.cache/z2w-coordination` \u2014 the Desktop path\n`~/Desktop/Zero2Webmaster/AI/Cursor Projects/z2w-agent-coordination/` is a symlink to it.\n\n\uD83D\uDD34 **Never `git pull` or edit in that shared clone.** Take a private workspace\nfirst \u2014 from the clone, `WS=\"$(bash scripts/agent-workspace.sh {{slug}})\"` then\n`cd \"$WS\"` \u2014 and read and write only there. The `## Agent Coordination` section of\nthis project's `CLAUDE.md` has the exact steps; where it and the primer disagree,\nthe live `AGENT_PROTOCOL.md` wins.\n\nThe primer orients you to the three core Z2W systems (the coordination bulletin,\nthe Skill Vault, and the starter-kit + Templates) and walks you through joining\nthe bulletin as `{{slug}}`.\n\n## The one rule that must not drift\n\nThe `## Agent Coordination` section of this project's `CLAUDE.md` / `AGENTS.md` is\neither a short **pointer** to the live `AGENT_PROTOCOL.md` (preferred) or a\n**verbatim** copy of it carrying the current\n`<!-- z2w-agent-coordination canonical-block vX.Y.Z -->` fingerprint. **Never\nparaphrase it**, and never copy a version-frozen block from another project or\nfrom a primer snapshot \u2014 that is exactly how canonical-block drift happens.\n\n## Your bulletin file\n\nThis project's bulletin file is `projects/{{slug}}.md`. Read it in protocol order at\nsession start (`## Incidents` \u2192 `## Inbox from Kerry` \u2192 `## Open questions` \u2192\n`## Heads-ups`), then `global.md`. Rewrite `## Current focus` at session end.\n\n---\n\n*Pointer emitted at scaffold time by `@zero2webmaster/starter-kit` (mirrors\n[[instantiate-z2w-project]]). The canonical primer it links is owned by\n`z2w-agent-coordination` \u2014 improve it THERE, never fork a per-project copy.*\n";
|
|
78
79
|
/**
|
|
79
80
|
* Emit the short coordination-onboarding pointer — but ONLY for a project that
|
|
80
81
|
* participates in the bulletin. Returns null otherwise (a non-participating
|
|
@@ -825,7 +825,10 @@ export function commonProjectBrief(inputs, opts, spec) {
|
|
|
825
825
|
// scaffolder already uses to stamp the Agent Coordination block from the live
|
|
826
826
|
// AGENT_PROTOCOL.md fingerprint rather than a paraphrase. Keep this file to one
|
|
827
827
|
// screen; the depth lives in the canonical primer it links.
|
|
828
|
-
|
|
828
|
+
//
|
|
829
|
+
// Exported so `src/skill-mirror.test.ts` can hold the skill's copy of it (in
|
|
830
|
+
// `references/inline-templates.md`, which says "byte-identical") to that claim.
|
|
831
|
+
export const COORDINATION_ONBOARDING_TEMPLATE = `# Coordination Onboarding — {{slug}}
|
|
829
832
|
|
|
830
833
|
> **Read this first if you're a fresh agent on \`{{slug}}\`.** This is a short
|
|
831
834
|
> pointer, not the full guide. \`{{slug}}\` participates in the Z2W cross-project
|
|
@@ -835,23 +838,28 @@ const COORDINATION_ONBOARDING_TEMPLATE = `# Coordination Onboarding — {{slug}}
|
|
|
835
838
|
## Where the canonical primer lives
|
|
836
839
|
|
|
837
840
|
Read **\`COORDINATION_ONBOARDING.md\`** at the root of the coordination bulletin repo
|
|
838
|
-
(\`zero2webmaster/z2w-agent-coordination\`)
|
|
841
|
+
(\`zero2webmaster/z2w-agent-coordination\`). There is ONE local clone, at
|
|
842
|
+
\`~/.cache/z2w-coordination\` — the Desktop path
|
|
843
|
+
\`~/Desktop/Zero2Webmaster/AI/Cursor Projects/z2w-agent-coordination/\` is a symlink to it.
|
|
839
844
|
|
|
840
|
-
|
|
841
|
-
|
|
845
|
+
🔴 **Never \`git pull\` or edit in that shared clone.** Take a private workspace
|
|
846
|
+
first — from the clone, \`WS="$(bash scripts/agent-workspace.sh {{slug}})"\` then
|
|
847
|
+
\`cd "$WS"\` — and read and write only there. The \`## Agent Coordination\` section of
|
|
848
|
+
this project's \`CLAUDE.md\` has the exact steps; where it and the primer disagree,
|
|
849
|
+
the live \`AGENT_PROTOCOL.md\` wins.
|
|
842
850
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
851
|
+
The primer orients you to the three core Z2W systems (the coordination bulletin,
|
|
852
|
+
the Skill Vault, and the starter-kit + Templates) and walks you through joining
|
|
853
|
+
the bulletin as \`{{slug}}\`.
|
|
846
854
|
|
|
847
855
|
## The one rule that must not drift
|
|
848
856
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
\`<!-- z2w-agent-coordination canonical-block vX.Y.Z -->\` fingerprint. **Never
|
|
853
|
-
version-frozen block from another project or
|
|
854
|
-
how canonical-block drift happens.
|
|
857
|
+
The \`## Agent Coordination\` section of this project's \`CLAUDE.md\` / \`AGENTS.md\` is
|
|
858
|
+
either a short **pointer** to the live \`AGENT_PROTOCOL.md\` (preferred) or a
|
|
859
|
+
**verbatim** copy of it carrying the current
|
|
860
|
+
\`<!-- z2w-agent-coordination canonical-block vX.Y.Z -->\` fingerprint. **Never
|
|
861
|
+
paraphrase it**, and never copy a version-frozen block from another project or
|
|
862
|
+
from a primer snapshot — that is exactly how canonical-block drift happens.
|
|
855
863
|
|
|
856
864
|
## Your bulletin file
|
|
857
865
|
|
|
@@ -5356,6 +5356,58 @@ 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
|
+
`;
|
|
5359
5411
|
/**
|
|
5360
5412
|
* Vercel's Ignored Build Step, committed in-repo so it is reviewable and
|
|
5361
5413
|
* survives a re-import (a dashboard setting is neither). Filed by
|
|
@@ -5520,6 +5572,7 @@ export function scaffoldNextjs(inputs, opts) {
|
|
|
5520
5572
|
if (usesNeonDb) {
|
|
5521
5573
|
packageJson = withExtraDeps(packageJson, NEON_DB_LAYER_DEPS);
|
|
5522
5574
|
packageJson = withExtraDevDeps(packageJson, NEON_DB_LAYER_DEV_DEPS);
|
|
5575
|
+
packageJson = withExtraScripts(packageJson, NEON_DB_SCRIPTS);
|
|
5523
5576
|
}
|
|
5524
5577
|
else if (durableLimit) {
|
|
5525
5578
|
packageJson = withExtraDeps(packageJson, NEON_DRIVER_DEP);
|
|
@@ -5686,7 +5739,7 @@ export function scaffoldNextjs(inputs, opts) {
|
|
|
5686
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) }, {
|
|
5687
5740
|
path: "db/pool-errors.test.ts",
|
|
5688
5741
|
content: sub(DB_POOL_ERRORS_TEST_TEMPLATE, inputs, opts, spec),
|
|
5689
|
-
}, { 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) });
|
|
5690
5743
|
}
|
|
5691
5744
|
return [...base, ...typeSpecific];
|
|
5692
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[];
|
package/dist/standard.js
ADDED
|
@@ -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
|
+
}
|
package/dist/standards.js
CHANGED
|
@@ -706,7 +706,9 @@ const TEST_COUNT_BODY = `### Test-count reporting (always — at session end)
|
|
|
706
706
|
>
|
|
707
707
|
> 1. **\`Tests:\` is for YOUR OWN count only.** If your entry mentions another project's suite — one you scaffolded, audited, or depend on — describe it in prose, never with the literal token: \`Scaffolded audit-engine (its suite: none yet). Tests: 720 passing.\` A newest-wins reader takes the first \`Tests:\` it finds, so a second project's count in your entry gets filed as yours. This is exactly how the portfolio's largest suite was once recorded as having no tests.
|
|
708
708
|
> 2. **\`Tests: none\` and \`Tests: none run\` mean different things.** \`none\` (or \`none yet\`) = this repo has no suite. \`none run\` = a suite exists but this session didn't run it, so a reader should keep looking back rather than record a zero — \`Tests: none run (docs-only)\` is the established form. Never report \`none\` for a session that merely skipped the tests: that turns a real suite into a zero.
|
|
709
|
-
> 3. **Always include the literal \`Tests:\` token, even on a multi-suite line.** Write \`Tests: 156 pytest / 289 Vitest / build clean\`, not \`156 pytest / 289 Vitest\`. Dropping the token makes the tally fall back to an older entry, so a project reporting MORE work gets counted for LESS — the worst-shaped failure of the three, because nothing looks wrong
|
|
709
|
+
> 3. **Always include the literal \`Tests:\` token, even on a multi-suite line.** Write \`Tests: 156 pytest / 289 Vitest / build clean\`, not \`156 pytest / 289 Vitest\`. Dropping the token makes the tally fall back to an older entry, so a project reporting MORE work gets counted for LESS — the worst-shaped failure of the three, because nothing looks wrong.
|
|
710
|
+
>
|
|
711
|
+
> **Optional: say what KINDS of test those are** (agreed with \`z2w-agent-command-center\` 2026-09-24, so its \`/tests\` page can show types). Add a bracketed breakdown after \`passing\`, using only these words: \`unit\`, \`integration\`, \`e2e\`, \`canary\`, \`contract\`. Example: \`Tests: 1152 passing (unit 1140 · canary 12)\`. The parts must add up to the total. Leave out lint, typecheck and build: they pass or fail as a whole and have no count, so write them in prose after the bracket (\`… (unit 1140 · canary 12), build clean\`). If you leave the bracket out, or it does not add up, the leading number is still read exactly as before.`;
|
|
710
712
|
const BODIES = {
|
|
711
713
|
"skill-vault": SKILL_VAULT_BODY,
|
|
712
714
|
"portable-stack": PORTABLE_STACK_BODY,
|
package/dist/writer.js
CHANGED
|
@@ -561,6 +561,16 @@ export function parseScaffoldInputs(json) {
|
|
|
561
561
|
}
|
|
562
562
|
inputs.hasObservability = obj["hasObservability"];
|
|
563
563
|
}
|
|
564
|
+
// Optional: the caller does not know who will own the GitHub repo, so
|
|
565
|
+
// `githubOrg` is only a stand-in and the descriptor records `repo: null`.
|
|
566
|
+
// Omitted means githubOrg is the real owner (v0.38.0, for project-creator's
|
|
567
|
+
// download path).
|
|
568
|
+
if (obj["repoOwnerUnknown"] !== undefined) {
|
|
569
|
+
if (typeof obj["repoOwnerUnknown"] !== "boolean") {
|
|
570
|
+
throw new WriterError(`--input field "repoOwnerUnknown" must be a boolean, got ${typeof obj["repoOwnerUnknown"]}.`);
|
|
571
|
+
}
|
|
572
|
+
inputs.repoOwnerUnknown = obj["repoOwnerUnknown"];
|
|
573
|
+
}
|
|
564
574
|
// Optional: whether this project has a PUBLIC SURFACE — pages meant for the
|
|
565
575
|
// general public and therefore for search engines — as opposed to an internal
|
|
566
576
|
// console or staff tool.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zero2webmaster/starter-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Dr. Kerry Kriger",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"scripts/rollup-integrations.mjs",
|
|
28
28
|
"scripts/check-descriptor.mjs",
|
|
29
29
|
"scripts/check-conformance.mjs",
|
|
30
|
+
"scripts/deliver-standard.mjs",
|
|
30
31
|
"README.md",
|
|
31
32
|
"LICENSE"
|
|
32
33
|
],
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// node scripts/check-conformance.mjs <project-dir> [<project-dir> …]
|
|
7
7
|
// node scripts/check-conformance.mjs --strict <project-dir> # non-zero on any gap
|
|
8
8
|
// node scripts/check-conformance.mjs --denominator # print the standard, examine nothing
|
|
9
|
+
// node scripts/check-conformance.mjs --portfolio # every repo under every portfolio root
|
|
9
10
|
//
|
|
10
11
|
// WHY THIS EXISTS, and it is a routing answer as much as a tool.
|
|
11
12
|
//
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
53
54
|
import { join, resolve, basename } from "node:path";
|
|
54
55
|
|
|
55
|
-
const KNOWN_FLAGS = ["--strict", "--denominator", "--json", "--help"];
|
|
56
|
+
const KNOWN_FLAGS = ["--strict", "--denominator", "--json", "--portfolio", "--help"];
|
|
56
57
|
|
|
57
58
|
const argv = process.argv.slice(2);
|
|
58
59
|
const unknown = argv.filter((a) => a.startsWith("--") && !KNOWN_FLAGS.includes(a.split("=")[0]));
|
|
@@ -71,7 +72,7 @@ const args = {
|
|
|
71
72
|
denominatorOnly: argv.includes("--denominator"),
|
|
72
73
|
json: argv.includes("--json"),
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
+
let targets = argv.filter((a) => !a.startsWith("--"));
|
|
75
76
|
|
|
76
77
|
if (argv.includes("--help")) {
|
|
77
78
|
console.log(readFileSync(new URL(import.meta.url), "utf8").split("\n").slice(1)
|
|
@@ -81,32 +82,14 @@ if (argv.includes("--help")) {
|
|
|
81
82
|
|
|
82
83
|
// ── The standard, DERIVED ────────────────────────────────────────────────────
|
|
83
84
|
|
|
84
|
-
const { scaffoldByType, PROJECT_TYPES } = await import("../dist/index.js");
|
|
85
|
-
|
|
86
|
-
/** Probe inputs for one project type. Neutral on every optional axis, so the
|
|
87
|
-
* emitted set is the floor for that type rather than one configuration of it. */
|
|
88
|
-
function probeInputs(projectType, over = {}) {
|
|
89
|
-
return {
|
|
90
|
-
// The slug is a PARAMETER, not a constant, because several scaffolders put
|
|
91
|
-
// it inside the paths they emit (`src/<slug>/main.py`). Probing with a
|
|
92
|
-
// throwaway slug reports `src/conformance-probe/main.py` as absent from
|
|
93
|
-
// every repo on earth — a finding that is 100% false positive and trains
|
|
94
|
-
// the reader to skip the whole type-specific section. Callers pass the
|
|
95
|
-
// repo's REAL slug so the derived paths are the ones that repo would have.
|
|
96
|
-
slug: "conformance-probe",
|
|
97
|
-
description: "A throwaway project used to derive the project standard.",
|
|
98
|
-
projectType,
|
|
99
|
-
brand: "zero2webmaster",
|
|
100
|
-
githubOrg: "zero2webmaster",
|
|
101
|
-
targetPath: "/tmp/conformance-probe",
|
|
102
|
-
dbStrategy: "none",
|
|
103
|
-
hasWebUi: false,
|
|
104
|
-
hasCron: false,
|
|
105
|
-
participateInBulletin: true,
|
|
106
|
-
...over,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
85
|
+
const { scaffoldByType, PROJECT_TYPES, deriveStandard, probeInputs } = await import("../dist/index.js");
|
|
109
86
|
|
|
87
|
+
// The derivation lives in `src/standard.ts`, shared with `deliver-standard.mjs`,
|
|
88
|
+
// so the tool that MEASURES a gap and the tool that CLOSES it cannot disagree
|
|
89
|
+
// about what the standard is. The slug is a parameter of the probe, not a
|
|
90
|
+
// constant, because several scaffolders put it inside the paths they emit
|
|
91
|
+
// (`src/<slug>/main.py`); callers pass the repo's REAL slug for the
|
|
92
|
+
// type-specific half.
|
|
110
93
|
function emittedPaths(projectType, over = {}) {
|
|
111
94
|
return new Set(
|
|
112
95
|
scaffoldByType(probeInputs(projectType, over), {
|
|
@@ -116,16 +99,15 @@ function emittedPaths(projectType, over = {}) {
|
|
|
116
99
|
);
|
|
117
100
|
}
|
|
118
101
|
|
|
119
|
-
/** THE STANDARD: paths every project type is given. Intersection, not a list.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
102
|
+
/** THE STANDARD: paths every project type is given. Intersection, not a list.
|
|
103
|
+
* A project that does not participate in the bulletin is never given
|
|
104
|
+
* COORDINATION_ONBOARDING.md, so it is measured against that narrower set —
|
|
105
|
+
* otherwise a correct non-participant reports a gap that is not one. */
|
|
106
|
+
function deriveUniversal(participates = true) {
|
|
107
|
+
const universal = deriveStandard({ participates });
|
|
126
108
|
// A guard against the vacuous denominator: an empty standard would pass every
|
|
127
109
|
// repo on earth, and an empty PROJECT_TYPES would produce one silently.
|
|
128
|
-
if (
|
|
110
|
+
if (universal.length === 0) {
|
|
129
111
|
console.error(
|
|
130
112
|
"❌ Derived an EMPTY project standard from the scaffolder. Refusing to run:\n" +
|
|
131
113
|
" an empty standard reports every repo as fully conformant, which is the\n" +
|
|
@@ -133,7 +115,7 @@ function deriveUniversal() {
|
|
|
133
115
|
);
|
|
134
116
|
process.exit(2);
|
|
135
117
|
}
|
|
136
|
-
return
|
|
118
|
+
return universal;
|
|
137
119
|
}
|
|
138
120
|
|
|
139
121
|
/** Paths emitted for THIS project's declared shape, beyond the universal set. */
|
|
@@ -161,6 +143,7 @@ function deriveTypeSpecific(descriptor, slug) {
|
|
|
161
143
|
}
|
|
162
144
|
|
|
163
145
|
const UNIVERSAL = deriveUniversal();
|
|
146
|
+
const UNIVERSAL_NON_PARTICIPANT = deriveUniversal(false);
|
|
164
147
|
|
|
165
148
|
if (args.denominatorOnly) {
|
|
166
149
|
console.log(`The Z2W project standard is ${UNIVERSAL.length} files — every path emitted by`);
|
|
@@ -170,6 +153,16 @@ if (args.denominatorOnly) {
|
|
|
170
153
|
process.exit(0);
|
|
171
154
|
}
|
|
172
155
|
|
|
156
|
+
// --portfolio: the whole portfolio, from the ONE root list in src/portfolio.ts.
|
|
157
|
+
// A hand-typed glob over one folder missed three repos for weeks. Read-only, so
|
|
158
|
+
// the symlinked bulletin clone is included.
|
|
159
|
+
if (argv.includes("--portfolio")) {
|
|
160
|
+
const { listPortfolio, describeRoots } = await import("../dist/index.js");
|
|
161
|
+
const p = listPortfolio();
|
|
162
|
+
if (!args.json) console.log(`Portfolio roots:\n${describeRoots(p)}\n`);
|
|
163
|
+
targets = [...targets, ...p.repos.map((r) => r.path)];
|
|
164
|
+
}
|
|
165
|
+
|
|
173
166
|
if (targets.length === 0) {
|
|
174
167
|
console.error(
|
|
175
168
|
"❌ No project directory given, so nothing was examined.\n" +
|
|
@@ -210,8 +203,10 @@ for (const raw of targets) {
|
|
|
210
203
|
}
|
|
211
204
|
}
|
|
212
205
|
|
|
213
|
-
|
|
214
|
-
const
|
|
206
|
+
// Only a MEASURED "does not participate" narrows the standard; unmeasured is not "no".
|
|
207
|
+
const standard = descriptor?.coordination?.participates === false ? UNIVERSAL_NON_PARTICIPANT : UNIVERSAL;
|
|
208
|
+
const missing = standard.filter((p) => !existsSync(join(dir, p)));
|
|
209
|
+
const present = standard.length - missing.length;
|
|
215
210
|
|
|
216
211
|
// AGENTS.md / GEMINI.md are mirrors, not standard files — the scaffolder never
|
|
217
212
|
// emits them and CLAUDE.md says never to create them just to hold a block. So
|
|
@@ -220,12 +215,12 @@ for (const raw of targets) {
|
|
|
220
215
|
|
|
221
216
|
const typeSpec = deriveTypeSpecific(descriptor, descriptor?.slug ?? name);
|
|
222
217
|
const typeMissing = typeSpec
|
|
223
|
-
? typeSpec.paths.filter((p) => !
|
|
218
|
+
? typeSpec.paths.filter((p) => !standard.includes(p) && !existsSync(join(dir, p)))
|
|
224
219
|
: null;
|
|
225
220
|
|
|
226
221
|
results.push({
|
|
227
222
|
name, dir, outcome: missing.length === 0 ? "CONFORMS" : "GAPS",
|
|
228
|
-
present, total:
|
|
223
|
+
present, total: standard.length, missing, mirrors,
|
|
229
224
|
descriptorState, projectType: descriptor?.projectType ?? null,
|
|
230
225
|
typeMissing, typeTotal: typeSpec ? typeSpec.paths.length : null,
|
|
231
226
|
});
|
|
@@ -257,15 +257,64 @@ export function detectProjectType(dir, pkg) {
|
|
|
257
257
|
return null;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
/**
|
|
261
|
+
* The runtime a LANGUAGE MANIFEST on disk declares, or null when there is none.
|
|
262
|
+
* A manifest is a fact about the tree, so this half is authoritative.
|
|
263
|
+
*
|
|
264
|
+
* 🔴 `requirements.txt` was missing until 2026-09-24, and the fallback below said
|
|
265
|
+
* `"none"` — so 12 Python repos (`contest-management`, `z2w-forms`,
|
|
266
|
+
* `videomigrator-engine`, …) were described as having NO runtime, a claim the
|
|
267
|
+
* generator never measured. Same class as the v0.33.0 falsy-boolean fix.
|
|
268
|
+
*/
|
|
269
|
+
export function detectManifestRuntime(dir, pkg) {
|
|
270
|
+
// `package.json` is NEVER authoritative: it is build tooling in WordPress
|
|
271
|
+
// plugins (`z2w-ai-suite` has one and no composer.json) and it sits beside a
|
|
272
|
+
// `requirements.txt` in Next.js apps (`leaderboard`). With one present, the
|
|
273
|
+
// runtime is a question, and the inference below answers it as before.
|
|
274
|
+
if (pkg.ok || hasNestedPackageJson(dir)) return null;
|
|
275
|
+
const kinds = new Set();
|
|
276
|
+
for (const f of ["pyproject.toml", "requirements.txt", "setup.py", "Pipfile"]) {
|
|
277
|
+
if (existsSync(join(dir, f))) kinds.add("python");
|
|
278
|
+
}
|
|
279
|
+
if (existsSync(join(dir, "composer.json"))) kinds.add("php");
|
|
280
|
+
return kinds.size === 1 ? [...kinds][0] : null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** A `package.json` one or two levels down (`contest-management/app/`, a
|
|
284
|
+
* Worker subfolder): the repo is mixed, so its root manifest is not the answer. */
|
|
285
|
+
function hasNestedPackageJson(dir) {
|
|
286
|
+
const skip = new Set(["node_modules", ".git", "venv", ".venv", "dist", ".next"]);
|
|
287
|
+
const walk = (d, depth) => {
|
|
288
|
+
if (depth > 2) return false;
|
|
289
|
+
let entries;
|
|
290
|
+
try { entries = readdirSync(d, { withFileTypes: true }); } catch { return false; }
|
|
291
|
+
for (const e of entries) {
|
|
292
|
+
if (!e.isDirectory() || skip.has(e.name) || e.name.startsWith(".")) continue;
|
|
293
|
+
if (existsSync(join(d, e.name, "package.json"))) return true;
|
|
294
|
+
if (walk(join(d, e.name), depth + 1)) return true;
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
};
|
|
298
|
+
return walk(dir, 1);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** The recorded runtime, minus the one value the pre-2026-09-24 backfill wrote
|
|
302
|
+
* WITHOUT measuring: `"none"` in a backfilled descriptor was its fallback. */
|
|
303
|
+
function recordedRuntime(existing) {
|
|
304
|
+
const r = existing?.stack?.runtime;
|
|
305
|
+
return existing?.backfilled === true && r === "none" ? null : r;
|
|
306
|
+
}
|
|
307
|
+
|
|
260
308
|
export function detectRuntime(dir, projectType, pkg) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
309
|
+
const manifest = detectManifestRuntime(dir, pkg);
|
|
310
|
+
if (manifest) return manifest;
|
|
311
|
+
if (projectType === "python-service" || existsSync(join(dir, "pyproject.toml"))) return "python";
|
|
264
312
|
if (projectType === "wp-plugin") return "php";
|
|
265
313
|
if (projectType === "protocol-repo") return "none";
|
|
266
314
|
if (pkg.ok) return "node";
|
|
267
315
|
if (projectType === "cf-pages") return "static";
|
|
268
|
-
|
|
316
|
+
// Nothing on disk says. "none" would be a CLAIM that the project runs nothing.
|
|
317
|
+
return "unknown";
|
|
269
318
|
}
|
|
270
319
|
|
|
271
320
|
/**
|
|
@@ -517,6 +566,13 @@ function findDrift(dir, descriptor) {
|
|
|
517
566
|
// usually a human having corrected a guess, and reporting it as drift would
|
|
518
567
|
// train people to stop correcting the file.
|
|
519
568
|
const comparisons = [
|
|
569
|
+
// Only the MANIFEST half of runtime is authoritative; null (no manifest) is skipped.
|
|
570
|
+
[
|
|
571
|
+
"stack.runtime",
|
|
572
|
+
has(descriptor.stack, "runtime"),
|
|
573
|
+
descriptor.stack?.runtime,
|
|
574
|
+
detectManifestRuntime(dir, pkg) ?? null,
|
|
575
|
+
],
|
|
520
576
|
["stack.hasWebUi", has(descriptor.stack, "hasWebUi"), descriptor.stack?.hasWebUi, detectHasWebUi(dir)],
|
|
521
577
|
["stack.hasCron", has(descriptor.stack, "hasCron"), descriptor.stack?.hasCron, detectHasCron(dir)],
|
|
522
578
|
[
|
|
@@ -541,6 +597,17 @@ function findDrift(dir, descriptor) {
|
|
|
541
597
|
);
|
|
542
598
|
}
|
|
543
599
|
|
|
600
|
+
// The old backfill's "none" was never measured. The loop above cannot see it
|
|
601
|
+
// when the honest answer is "unknown" (it skips unmeasured values by design),
|
|
602
|
+
// so it is reported here — otherwise `--write` would leave the claim standing.
|
|
603
|
+
if (recordedRuntime(descriptor) === null && descriptor.stack?.runtime === "none"
|
|
604
|
+
&& !problems.some((x) => x.startsWith("stack.runtime"))) {
|
|
605
|
+
const now = detectRuntime(dir, projectType, pkg);
|
|
606
|
+
if (now !== "none") {
|
|
607
|
+
problems.push(`stack.runtime says "none", the pre-2026-09-24 backfill's unmeasured default; it now reads as ${JSON.stringify(now)}`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
544
611
|
return problems;
|
|
545
612
|
}
|
|
546
613
|
|
|
@@ -636,7 +703,11 @@ export function backfill(dir, existing) {
|
|
|
636
703
|
// runtime is derived FROM projectType, so it inherits that field's
|
|
637
704
|
// uncertainty. database is read from declared dependencies, which is
|
|
638
705
|
// circumstantial — a dependency is not a connection.
|
|
639
|
-
|
|
706
|
+
// A language manifest is a fact and beats any recorded value (including the
|
|
707
|
+
// "none" the pre-2026-09-24 generator wrote for Python repos). Without one,
|
|
708
|
+
// the value is inferred from projectType, so a recorded one stands.
|
|
709
|
+
runtime: detectManifestRuntime(dir, pkg)
|
|
710
|
+
?? bestGuess(recordedRuntime(existing), detectRuntime(dir, projectType, pkg)),
|
|
640
711
|
database: bestGuess(existing?.stack?.database, detectDatabase(dir, projectType, pkg)),
|
|
641
712
|
// Booleans are positive detections over the tree, so they are always
|
|
642
713
|
// re-measured — a project that gained a cron must stop saying it has none.
|
|
@@ -655,10 +726,22 @@ export function backfill(dir, existing) {
|
|
|
655
726
|
};
|
|
656
727
|
}
|
|
657
728
|
|
|
658
|
-
export function main(argv = process.argv.slice(2)) {
|
|
729
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
659
730
|
const write = argv.includes("--write");
|
|
660
731
|
const strict = argv.includes("--strict");
|
|
661
732
|
const dirs = argv.filter((a) => !a.startsWith("--"));
|
|
733
|
+
// --portfolio: every repo under every root in src/portfolio.ts. With --write,
|
|
734
|
+
// symlinked entries (the shared bulletin clone) are excluded and NAMED — a
|
|
735
|
+
// backfill into it blocked every agent's fast-forward on 2026-09-19.
|
|
736
|
+
if (argv.includes("--portfolio")) {
|
|
737
|
+
const { listPortfolio, writeSafe, describeRoots } = await import("../dist/index.js");
|
|
738
|
+
const p = listPortfolio();
|
|
739
|
+
console.log(`Portfolio roots:\n${describeRoots(p)}`);
|
|
740
|
+
const chosen = write ? writeSafe(p) : { repos: p.repos, excluded: [] };
|
|
741
|
+
for (const r of chosen.excluded) console.log(` ⚪ excluded (symlink — run it from a worktree): ${r.path}`);
|
|
742
|
+
console.log("");
|
|
743
|
+
dirs.push(...chosen.repos.map((r) => r.path));
|
|
744
|
+
}
|
|
662
745
|
|
|
663
746
|
if (dirs.length === 0) {
|
|
664
747
|
console.error(
|
|
@@ -739,5 +822,5 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
739
822
|
// Run only when invoked as a command. Importable as a module so the test suite
|
|
740
823
|
// can pin the shared vocabulary tables against `src/descriptor.ts`.
|
|
741
824
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
742
|
-
main();
|
|
825
|
+
await main();
|
|
743
826
|
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//
|
|
3
|
+
// Add the MISSING Z2W project-standard files to existing repos — never
|
|
4
|
+
// overwriting, and never writing a file whose stub would be false there.
|
|
5
|
+
//
|
|
6
|
+
// node scripts/deliver-standard.mjs <project-dir> [<project-dir> …] # dry run (default)
|
|
7
|
+
// node scripts/deliver-standard.mjs --write <project-dir> [<project-dir> …] # create the files
|
|
8
|
+
// node scripts/deliver-standard.mjs --json <project-dir> … # machine-readable plan
|
|
9
|
+
// node scripts/deliver-standard.mjs --portfolio [--write] # every writable portfolio repo
|
|
10
|
+
//
|
|
11
|
+
// WHY THIS EXISTS. `check-conformance.mjs` measured the gap on 2026-09-20:
|
|
12
|
+
// 48 of 57 repos lacked at least one standard file, because the standard grew
|
|
13
|
+
// from ~11 files to 16 and nothing delivered an addition to repos scaffolded
|
|
14
|
+
// before it. The checker MEASURES; this is the other half, and Kerry authorised
|
|
15
|
+
// the first sweep on 2026-09-22.
|
|
16
|
+
//
|
|
17
|
+
// WHAT IT WILL AND WILL NOT WRITE. The rules live in `src/standard.ts`
|
|
18
|
+
// (`DELIVERY_CLASS`, `planDelivery`) so that this script and the checker share
|
|
19
|
+
// one derivation of the standard. In short:
|
|
20
|
+
//
|
|
21
|
+
// · Only paths classed `deliverable` — stubs that are true at any age
|
|
22
|
+
// (BACKUPS.md, marketing.md, an empty TROUBLESHOOTING.md …). ROADMAP.md,
|
|
23
|
+
// STATUS.md, HANDOFF.md, CHANGELOG.md, VERSION, README.md and CLAUDE.md are
|
|
24
|
+
// REPORTED, never written: their scaffold-time content says "v0.1.0" and
|
|
25
|
+
// "begin Step 1", which is false in a repo with history.
|
|
26
|
+
// · Content is generated from the repo's own `z2w-project.json` (real slug,
|
|
27
|
+
// description, org). Where content would depend on something the repo does
|
|
28
|
+
// not record — the brand always, the type sometimes — every value is tried,
|
|
29
|
+
// and the file is written only if all of them produce identical bytes.
|
|
30
|
+
// · COORDINATION_ONBOARDING.md only for a project that participates.
|
|
31
|
+
// Participation that was never measured (`null`) is not "yes".
|
|
32
|
+
// · Every Markdown file carries a banner saying it is an unfilled stub.
|
|
33
|
+
// · Created with an exclusive open, so a file that appears between the plan
|
|
34
|
+
// and the write is left alone rather than overwritten.
|
|
35
|
+
// · A path the repo's .gitignore excludes is reported, not written — a file
|
|
36
|
+
// git cannot see is not delivered, it is just left lying there.
|
|
37
|
+
//
|
|
38
|
+
// It does NOT commit or push. Writing files is the whole side effect; the
|
|
39
|
+
// caller decides what reaches a remote. [[zero-is-not-a-pass]]
|
|
40
|
+
//
|
|
41
|
+
import { execFileSync } from "node:child_process";
|
|
42
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
43
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
44
|
+
|
|
45
|
+
const KNOWN_FLAGS = ["--write", "--json", "--portfolio", "--help"];
|
|
46
|
+
const argv = process.argv.slice(2);
|
|
47
|
+
const unknown = argv.filter((a) => a.startsWith("--") && !KNOWN_FLAGS.includes(a));
|
|
48
|
+
if (unknown.length) {
|
|
49
|
+
console.error(
|
|
50
|
+
`❌ Unrecognised flag(s): ${unknown.join(", ")}\n` +
|
|
51
|
+
` Known: ${KNOWN_FLAGS.join(", ")}\n` +
|
|
52
|
+
` Refusing to run. A script that WRITES must never guess what it was asked to do.`,
|
|
53
|
+
);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if (argv.includes("--help")) {
|
|
57
|
+
console.log(readFileSync(new URL(import.meta.url), "utf8").split("\n").slice(1)
|
|
58
|
+
.filter((l) => l.startsWith("//")).map((l) => l.replace(/^\/\/ ?/, "")).join("\n"));
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
const WRITE = argv.includes("--write");
|
|
62
|
+
const JSON_OUT = argv.includes("--json");
|
|
63
|
+
let targets = argv.filter((a) => !a.startsWith("--"));
|
|
64
|
+
// --portfolio: every repo under every root in src/portfolio.ts, MINUS symlinked
|
|
65
|
+
// entries (the shared bulletin clone) — this script writes. Named, not dropped.
|
|
66
|
+
const portfolioExcluded = [];
|
|
67
|
+
if (argv.includes("--portfolio")) {
|
|
68
|
+
const { listPortfolio, writeSafe, describeRoots } = await import("../dist/index.js");
|
|
69
|
+
const p = listPortfolio();
|
|
70
|
+
const safe = writeSafe(p);
|
|
71
|
+
if (!JSON_OUT) {
|
|
72
|
+
console.log(`Portfolio roots:\n${describeRoots(p)}`);
|
|
73
|
+
for (const r of safe.excluded) console.log(` ⚪ excluded (symlink — run it from a worktree): ${r.path}`);
|
|
74
|
+
console.log("");
|
|
75
|
+
}
|
|
76
|
+
portfolioExcluded.push(...safe.excluded.map((r) => r.path));
|
|
77
|
+
targets = [...targets, ...safe.repos.map((r) => r.path)];
|
|
78
|
+
}
|
|
79
|
+
if (targets.length === 0) {
|
|
80
|
+
console.error("❌ No project directory given, so nothing was examined.\n" +
|
|
81
|
+
" Usage: node scripts/deliver-standard.mjs [--write] <project-dir> [<project-dir> …]");
|
|
82
|
+
process.exit(2);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { planDelivery, PROJECT_TYPES, version: cliVersion } = await import("../dist/index.js");
|
|
86
|
+
// LOCAL date, not UTC: in the evening in the US, UTC is already tomorrow.
|
|
87
|
+
const date = new Date().toLocaleDateString("en-CA");
|
|
88
|
+
|
|
89
|
+
function isIgnored(dir, path) {
|
|
90
|
+
try {
|
|
91
|
+
execFileSync("git", ["-C", dir, "check-ignore", "-q", "--", path], { stdio: "ignore" });
|
|
92
|
+
return true; // exit 0 = ignored
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const results = [];
|
|
99
|
+
for (const raw of targets) {
|
|
100
|
+
const dir = resolve(raw);
|
|
101
|
+
const name = basename(dir);
|
|
102
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory()) {
|
|
103
|
+
results.push({ name, dir, outcome: "UNREADABLE", reason: "not a directory that exists" });
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!existsSync(join(dir, ".git"))) {
|
|
107
|
+
results.push({ name, dir, outcome: "SKIPPED", reason: "no .git — not a project repo" });
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const descPath = join(dir, "z2w-project.json");
|
|
111
|
+
let d;
|
|
112
|
+
try {
|
|
113
|
+
d = JSON.parse(readFileSync(descPath, "utf8"));
|
|
114
|
+
} catch {
|
|
115
|
+
results.push({ name, dir, outcome: "SKIPPED",
|
|
116
|
+
reason: "no readable z2w-project.json — run scripts/check-descriptor.mjs --write first; delivery never guesses a slug" });
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (!d.slug || !d.description) {
|
|
120
|
+
results.push({ name, dir, outcome: "SKIPPED", reason: "descriptor lacks a slug or description" });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const participation = d.coordination?.participates;
|
|
124
|
+
const facts = {
|
|
125
|
+
slug: d.slug,
|
|
126
|
+
description: d.description,
|
|
127
|
+
githubOrg: d.repo?.org ?? "zero2webmaster",
|
|
128
|
+
projectType: PROJECT_TYPES.includes(d.projectType) ? d.projectType : null,
|
|
129
|
+
participates: participation === true,
|
|
130
|
+
version: existsSync(join(dir, "VERSION")) ? readFileSync(join(dir, "VERSION"), "utf8").trim() || null : null,
|
|
131
|
+
directives: existsSync(join(dir, "directives"))
|
|
132
|
+
? readdirSync(join(dir, "directives")).filter((f) => f.endsWith(".md"))
|
|
133
|
+
: [],
|
|
134
|
+
};
|
|
135
|
+
const present = new Set();
|
|
136
|
+
// planDelivery only asks about standard paths, so probe exactly those.
|
|
137
|
+
const plan0 = planDelivery(facts, new Set(), { date, cliVersion });
|
|
138
|
+
for (const p of plan0.map((i) => i.path)) if (existsSync(join(dir, p))) present.add(p);
|
|
139
|
+
const plan = planDelivery(facts, present, { date, cliVersion });
|
|
140
|
+
// `participates: false` plans without the onboarding file, which is right for
|
|
141
|
+
// a measured "no" and wrong to leave silent for an unmeasured one.
|
|
142
|
+
if (participation !== true && participation !== false && !existsSync(join(dir, "COORDINATION_ONBOARDING.md"))) {
|
|
143
|
+
plan.push({ path: "COORDINATION_ONBOARDING.md", action: "report",
|
|
144
|
+
reason: "descriptor does not record whether this project participates — not assumed" });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const written = [];
|
|
148
|
+
for (const item of plan) {
|
|
149
|
+
if (item.action !== "write") continue;
|
|
150
|
+
if (isIgnored(dir, item.path)) {
|
|
151
|
+
item.action = "report";
|
|
152
|
+
item.reason = "this repo's .gitignore excludes it — a file git cannot see is not delivered";
|
|
153
|
+
delete item.content;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (WRITE) {
|
|
157
|
+
const full = join(dir, item.path);
|
|
158
|
+
mkdirSync(dirname(full), { recursive: true });
|
|
159
|
+
try {
|
|
160
|
+
writeFileSync(full, item.content, { encoding: "utf8", flag: "wx" });
|
|
161
|
+
written.push(item.path);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
item.action = "report";
|
|
164
|
+
item.reason = e.code === "EEXIST" ? "appeared before the write — left untouched" : `write failed: ${e.code ?? e.message}`;
|
|
165
|
+
}
|
|
166
|
+
delete item.content;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
results.push({
|
|
170
|
+
name, dir, outcome: "EXAMINED", slug: facts.slug,
|
|
171
|
+
toWrite: plan.filter((i) => i.action === "write").map((i) => i.path),
|
|
172
|
+
written,
|
|
173
|
+
reported: plan.filter((i) => i.action === "report").map(({ path, reason }) => ({ path, reason })),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (JSON_OUT) {
|
|
178
|
+
console.log(JSON.stringify({ mode: WRITE ? "write" : "dry-run", date, cliVersion, portfolioExcluded, results }, null, 2));
|
|
179
|
+
} else {
|
|
180
|
+
console.log(`${WRITE ? "WRITING" : "DRY RUN — nothing written (pass --write)"}: Z2W standard delivery, ${date}\n`);
|
|
181
|
+
for (const r of results) {
|
|
182
|
+
if (r.outcome !== "EXAMINED") {
|
|
183
|
+
console.log(`⚪ ${r.name} — ${r.outcome}: ${r.reason}\n`);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const files = WRITE ? r.written : r.toWrite;
|
|
187
|
+
console.log(`${files.length ? "📦" : "✅"} ${r.name} — ${files.length} file(s) ${WRITE ? "written" : "would be written"}` +
|
|
188
|
+
(files.length ? `: ${files.join(", ")}` : ""));
|
|
189
|
+
for (const x of r.reported) console.log(` not written: ${x.path} — ${x.reason}`);
|
|
190
|
+
console.log("");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const examined = results.filter((r) => r.outcome === "EXAMINED").length;
|
|
194
|
+
if (!JSON_OUT) {
|
|
195
|
+
const n = results.reduce((a, r) => a + (WRITE ? r.written?.length ?? 0 : r.toWrite?.length ?? 0), 0);
|
|
196
|
+
console.log(`Examined ${examined} of ${results.length} target(s); ${n} file(s) ${WRITE ? "written" : "planned"}.`);
|
|
197
|
+
}
|
|
198
|
+
if (examined === 0) {
|
|
199
|
+
console.error(`❌ Examined 0 of ${results.length} target(s) — nothing was delivered, and that is not a success.`);
|
|
200
|
+
process.exit(2);
|
|
201
|
+
}
|