@zero2webmaster/starter-kit 0.36.0 → 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 +2 -2
- package/dist/descriptor.d.ts +5 -1
- package/dist/descriptor.js +8 -6
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1 -0
- package/dist/scaffolders/common.js +17 -12
- package/dist/scaffolders/nextjs.js +54 -1
- package/dist/standard.d.ts +56 -0
- package/dist/standard.js +160 -0
- package/dist/writer.js +10 -0
- package/package.json +2 -1
- package/scripts/check-conformance.mjs +22 -38
- package/scripts/deliver-standard.mjs +185 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 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.
|
|
138
|
+
*Version: 0.38.0 | Last Updated: 2026-09-23*
|
package/dist/descriptor.d.ts
CHANGED
|
@@ -80,12 +80,16 @@ export interface ProjectDescriptor {
|
|
|
80
80
|
hasWebUi: boolean;
|
|
81
81
|
hasCron: boolean;
|
|
82
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
|
+
*/
|
|
83
87
|
repo: {
|
|
84
88
|
host: "github";
|
|
85
89
|
org: string;
|
|
86
90
|
name: string;
|
|
87
91
|
url: string;
|
|
88
|
-
};
|
|
92
|
+
} | null;
|
|
89
93
|
deploy: {
|
|
90
94
|
/** `null` where the scaffold genuinely does not determine one. */
|
|
91
95
|
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,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\`)
|
|
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
|
-
|
|
841
|
-
|
|
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
|
-
|
|
844
|
-
|
|
845
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
|
@@ -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/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.38.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
|
],
|
|
@@ -81,32 +81,14 @@ if (argv.includes("--help")) {
|
|
|
81
81
|
|
|
82
82
|
// ── The standard, DERIVED ────────────────────────────────────────────────────
|
|
83
83
|
|
|
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
|
-
}
|
|
84
|
+
const { scaffoldByType, PROJECT_TYPES, deriveStandard, probeInputs } = await import("../dist/index.js");
|
|
109
85
|
|
|
86
|
+
// The derivation lives in `src/standard.ts`, shared with `deliver-standard.mjs`,
|
|
87
|
+
// so the tool that MEASURES a gap and the tool that CLOSES it cannot disagree
|
|
88
|
+
// about what the standard is. The slug is a parameter of the probe, not a
|
|
89
|
+
// constant, because several scaffolders put it inside the paths they emit
|
|
90
|
+
// (`src/<slug>/main.py`); callers pass the repo's REAL slug for the
|
|
91
|
+
// type-specific half.
|
|
110
92
|
function emittedPaths(projectType, over = {}) {
|
|
111
93
|
return new Set(
|
|
112
94
|
scaffoldByType(probeInputs(projectType, over), {
|
|
@@ -116,16 +98,15 @@ function emittedPaths(projectType, over = {}) {
|
|
|
116
98
|
);
|
|
117
99
|
}
|
|
118
100
|
|
|
119
|
-
/** THE STANDARD: paths every project type is given. Intersection, not a list.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
101
|
+
/** THE STANDARD: paths every project type is given. Intersection, not a list.
|
|
102
|
+
* A project that does not participate in the bulletin is never given
|
|
103
|
+
* COORDINATION_ONBOARDING.md, so it is measured against that narrower set —
|
|
104
|
+
* otherwise a correct non-participant reports a gap that is not one. */
|
|
105
|
+
function deriveUniversal(participates = true) {
|
|
106
|
+
const universal = deriveStandard({ participates });
|
|
126
107
|
// A guard against the vacuous denominator: an empty standard would pass every
|
|
127
108
|
// repo on earth, and an empty PROJECT_TYPES would produce one silently.
|
|
128
|
-
if (
|
|
109
|
+
if (universal.length === 0) {
|
|
129
110
|
console.error(
|
|
130
111
|
"❌ Derived an EMPTY project standard from the scaffolder. Refusing to run:\n" +
|
|
131
112
|
" an empty standard reports every repo as fully conformant, which is the\n" +
|
|
@@ -133,7 +114,7 @@ function deriveUniversal() {
|
|
|
133
114
|
);
|
|
134
115
|
process.exit(2);
|
|
135
116
|
}
|
|
136
|
-
return
|
|
117
|
+
return universal;
|
|
137
118
|
}
|
|
138
119
|
|
|
139
120
|
/** Paths emitted for THIS project's declared shape, beyond the universal set. */
|
|
@@ -161,6 +142,7 @@ function deriveTypeSpecific(descriptor, slug) {
|
|
|
161
142
|
}
|
|
162
143
|
|
|
163
144
|
const UNIVERSAL = deriveUniversal();
|
|
145
|
+
const UNIVERSAL_NON_PARTICIPANT = deriveUniversal(false);
|
|
164
146
|
|
|
165
147
|
if (args.denominatorOnly) {
|
|
166
148
|
console.log(`The Z2W project standard is ${UNIVERSAL.length} files — every path emitted by`);
|
|
@@ -210,8 +192,10 @@ for (const raw of targets) {
|
|
|
210
192
|
}
|
|
211
193
|
}
|
|
212
194
|
|
|
213
|
-
|
|
214
|
-
const
|
|
195
|
+
// Only a MEASURED "does not participate" narrows the standard; unmeasured is not "no".
|
|
196
|
+
const standard = descriptor?.coordination?.participates === false ? UNIVERSAL_NON_PARTICIPANT : UNIVERSAL;
|
|
197
|
+
const missing = standard.filter((p) => !existsSync(join(dir, p)));
|
|
198
|
+
const present = standard.length - missing.length;
|
|
215
199
|
|
|
216
200
|
// AGENTS.md / GEMINI.md are mirrors, not standard files — the scaffolder never
|
|
217
201
|
// emits them and CLAUDE.md says never to create them just to hold a block. So
|
|
@@ -220,12 +204,12 @@ for (const raw of targets) {
|
|
|
220
204
|
|
|
221
205
|
const typeSpec = deriveTypeSpecific(descriptor, descriptor?.slug ?? name);
|
|
222
206
|
const typeMissing = typeSpec
|
|
223
|
-
? typeSpec.paths.filter((p) => !
|
|
207
|
+
? typeSpec.paths.filter((p) => !standard.includes(p) && !existsSync(join(dir, p)))
|
|
224
208
|
: null;
|
|
225
209
|
|
|
226
210
|
results.push({
|
|
227
211
|
name, dir, outcome: missing.length === 0 ? "CONFORMS" : "GAPS",
|
|
228
|
-
present, total:
|
|
212
|
+
present, total: standard.length, missing, mirrors,
|
|
229
213
|
descriptorState, projectType: descriptor?.projectType ?? null,
|
|
230
214
|
typeMissing, typeTotal: typeSpec ? typeSpec.paths.length : null,
|
|
231
215
|
});
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
//
|
|
10
|
+
// WHY THIS EXISTS. `check-conformance.mjs` measured the gap on 2026-09-20:
|
|
11
|
+
// 48 of 57 repos lacked at least one standard file, because the standard grew
|
|
12
|
+
// from ~11 files to 16 and nothing delivered an addition to repos scaffolded
|
|
13
|
+
// before it. The checker MEASURES; this is the other half, and Kerry authorised
|
|
14
|
+
// the first sweep on 2026-09-22.
|
|
15
|
+
//
|
|
16
|
+
// WHAT IT WILL AND WILL NOT WRITE. The rules live in `src/standard.ts`
|
|
17
|
+
// (`DELIVERY_CLASS`, `planDelivery`) so that this script and the checker share
|
|
18
|
+
// one derivation of the standard. In short:
|
|
19
|
+
//
|
|
20
|
+
// · Only paths classed `deliverable` — stubs that are true at any age
|
|
21
|
+
// (BACKUPS.md, marketing.md, an empty TROUBLESHOOTING.md …). ROADMAP.md,
|
|
22
|
+
// STATUS.md, HANDOFF.md, CHANGELOG.md, VERSION, README.md and CLAUDE.md are
|
|
23
|
+
// REPORTED, never written: their scaffold-time content says "v0.1.0" and
|
|
24
|
+
// "begin Step 1", which is false in a repo with history.
|
|
25
|
+
// · Content is generated from the repo's own `z2w-project.json` (real slug,
|
|
26
|
+
// description, org). Where content would depend on something the repo does
|
|
27
|
+
// not record — the brand always, the type sometimes — every value is tried,
|
|
28
|
+
// and the file is written only if all of them produce identical bytes.
|
|
29
|
+
// · COORDINATION_ONBOARDING.md only for a project that participates.
|
|
30
|
+
// Participation that was never measured (`null`) is not "yes".
|
|
31
|
+
// · Every Markdown file carries a banner saying it is an unfilled stub.
|
|
32
|
+
// · Created with an exclusive open, so a file that appears between the plan
|
|
33
|
+
// and the write is left alone rather than overwritten.
|
|
34
|
+
// · A path the repo's .gitignore excludes is reported, not written — a file
|
|
35
|
+
// git cannot see is not delivered, it is just left lying there.
|
|
36
|
+
//
|
|
37
|
+
// It does NOT commit or push. Writing files is the whole side effect; the
|
|
38
|
+
// caller decides what reaches a remote. [[zero-is-not-a-pass]]
|
|
39
|
+
//
|
|
40
|
+
import { execFileSync } from "node:child_process";
|
|
41
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
42
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
43
|
+
|
|
44
|
+
const KNOWN_FLAGS = ["--write", "--json", "--help"];
|
|
45
|
+
const argv = process.argv.slice(2);
|
|
46
|
+
const unknown = argv.filter((a) => a.startsWith("--") && !KNOWN_FLAGS.includes(a));
|
|
47
|
+
if (unknown.length) {
|
|
48
|
+
console.error(
|
|
49
|
+
`❌ Unrecognised flag(s): ${unknown.join(", ")}\n` +
|
|
50
|
+
` Known: ${KNOWN_FLAGS.join(", ")}\n` +
|
|
51
|
+
` Refusing to run. A script that WRITES must never guess what it was asked to do.`,
|
|
52
|
+
);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
if (argv.includes("--help")) {
|
|
56
|
+
console.log(readFileSync(new URL(import.meta.url), "utf8").split("\n").slice(1)
|
|
57
|
+
.filter((l) => l.startsWith("//")).map((l) => l.replace(/^\/\/ ?/, "")).join("\n"));
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
const WRITE = argv.includes("--write");
|
|
61
|
+
const JSON_OUT = argv.includes("--json");
|
|
62
|
+
const targets = argv.filter((a) => !a.startsWith("--"));
|
|
63
|
+
if (targets.length === 0) {
|
|
64
|
+
console.error("❌ No project directory given, so nothing was examined.\n" +
|
|
65
|
+
" Usage: node scripts/deliver-standard.mjs [--write] <project-dir> [<project-dir> …]");
|
|
66
|
+
process.exit(2);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { planDelivery, PROJECT_TYPES, version: cliVersion } = await import("../dist/index.js");
|
|
70
|
+
// LOCAL date, not UTC: in the evening in the US, UTC is already tomorrow.
|
|
71
|
+
const date = new Date().toLocaleDateString("en-CA");
|
|
72
|
+
|
|
73
|
+
function isIgnored(dir, path) {
|
|
74
|
+
try {
|
|
75
|
+
execFileSync("git", ["-C", dir, "check-ignore", "-q", "--", path], { stdio: "ignore" });
|
|
76
|
+
return true; // exit 0 = ignored
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const results = [];
|
|
83
|
+
for (const raw of targets) {
|
|
84
|
+
const dir = resolve(raw);
|
|
85
|
+
const name = basename(dir);
|
|
86
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory()) {
|
|
87
|
+
results.push({ name, dir, outcome: "UNREADABLE", reason: "not a directory that exists" });
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (!existsSync(join(dir, ".git"))) {
|
|
91
|
+
results.push({ name, dir, outcome: "SKIPPED", reason: "no .git — not a project repo" });
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const descPath = join(dir, "z2w-project.json");
|
|
95
|
+
let d;
|
|
96
|
+
try {
|
|
97
|
+
d = JSON.parse(readFileSync(descPath, "utf8"));
|
|
98
|
+
} catch {
|
|
99
|
+
results.push({ name, dir, outcome: "SKIPPED",
|
|
100
|
+
reason: "no readable z2w-project.json — run scripts/check-descriptor.mjs --write first; delivery never guesses a slug" });
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!d.slug || !d.description) {
|
|
104
|
+
results.push({ name, dir, outcome: "SKIPPED", reason: "descriptor lacks a slug or description" });
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const participation = d.coordination?.participates;
|
|
108
|
+
const facts = {
|
|
109
|
+
slug: d.slug,
|
|
110
|
+
description: d.description,
|
|
111
|
+
githubOrg: d.repo?.org ?? "zero2webmaster",
|
|
112
|
+
projectType: PROJECT_TYPES.includes(d.projectType) ? d.projectType : null,
|
|
113
|
+
participates: participation === true,
|
|
114
|
+
version: existsSync(join(dir, "VERSION")) ? readFileSync(join(dir, "VERSION"), "utf8").trim() || null : null,
|
|
115
|
+
directives: existsSync(join(dir, "directives"))
|
|
116
|
+
? readdirSync(join(dir, "directives")).filter((f) => f.endsWith(".md"))
|
|
117
|
+
: [],
|
|
118
|
+
};
|
|
119
|
+
const present = new Set();
|
|
120
|
+
// planDelivery only asks about standard paths, so probe exactly those.
|
|
121
|
+
const plan0 = planDelivery(facts, new Set(), { date, cliVersion });
|
|
122
|
+
for (const p of plan0.map((i) => i.path)) if (existsSync(join(dir, p))) present.add(p);
|
|
123
|
+
const plan = planDelivery(facts, present, { date, cliVersion });
|
|
124
|
+
// `participates: false` plans without the onboarding file, which is right for
|
|
125
|
+
// a measured "no" and wrong to leave silent for an unmeasured one.
|
|
126
|
+
if (participation !== true && participation !== false && !existsSync(join(dir, "COORDINATION_ONBOARDING.md"))) {
|
|
127
|
+
plan.push({ path: "COORDINATION_ONBOARDING.md", action: "report",
|
|
128
|
+
reason: "descriptor does not record whether this project participates — not assumed" });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const written = [];
|
|
132
|
+
for (const item of plan) {
|
|
133
|
+
if (item.action !== "write") continue;
|
|
134
|
+
if (isIgnored(dir, item.path)) {
|
|
135
|
+
item.action = "report";
|
|
136
|
+
item.reason = "this repo's .gitignore excludes it — a file git cannot see is not delivered";
|
|
137
|
+
delete item.content;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (WRITE) {
|
|
141
|
+
const full = join(dir, item.path);
|
|
142
|
+
mkdirSync(dirname(full), { recursive: true });
|
|
143
|
+
try {
|
|
144
|
+
writeFileSync(full, item.content, { encoding: "utf8", flag: "wx" });
|
|
145
|
+
written.push(item.path);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
item.action = "report";
|
|
148
|
+
item.reason = e.code === "EEXIST" ? "appeared before the write — left untouched" : `write failed: ${e.code ?? e.message}`;
|
|
149
|
+
}
|
|
150
|
+
delete item.content;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
results.push({
|
|
154
|
+
name, dir, outcome: "EXAMINED", slug: facts.slug,
|
|
155
|
+
toWrite: plan.filter((i) => i.action === "write").map((i) => i.path),
|
|
156
|
+
written,
|
|
157
|
+
reported: plan.filter((i) => i.action === "report").map(({ path, reason }) => ({ path, reason })),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (JSON_OUT) {
|
|
162
|
+
console.log(JSON.stringify({ mode: WRITE ? "write" : "dry-run", date, cliVersion, results }, null, 2));
|
|
163
|
+
} else {
|
|
164
|
+
console.log(`${WRITE ? "WRITING" : "DRY RUN — nothing written (pass --write)"}: Z2W standard delivery, ${date}\n`);
|
|
165
|
+
for (const r of results) {
|
|
166
|
+
if (r.outcome !== "EXAMINED") {
|
|
167
|
+
console.log(`⚪ ${r.name} — ${r.outcome}: ${r.reason}\n`);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const files = WRITE ? r.written : r.toWrite;
|
|
171
|
+
console.log(`${files.length ? "📦" : "✅"} ${r.name} — ${files.length} file(s) ${WRITE ? "written" : "would be written"}` +
|
|
172
|
+
(files.length ? `: ${files.join(", ")}` : ""));
|
|
173
|
+
for (const x of r.reported) console.log(` not written: ${x.path} — ${x.reason}`);
|
|
174
|
+
console.log("");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const examined = results.filter((r) => r.outcome === "EXAMINED").length;
|
|
178
|
+
if (!JSON_OUT) {
|
|
179
|
+
const n = results.reduce((a, r) => a + (WRITE ? r.written?.length ?? 0 : r.toWrite?.length ?? 0), 0);
|
|
180
|
+
console.log(`Examined ${examined} of ${results.length} target(s); ${n} file(s) ${WRITE ? "written" : "planned"}.`);
|
|
181
|
+
}
|
|
182
|
+
if (examined === 0) {
|
|
183
|
+
console.error(`❌ Examined 0 of ${results.length} target(s) — nothing was delivered, and that is not a success.`);
|
|
184
|
+
process.exit(2);
|
|
185
|
+
}
|