@zero2webmaster/starter-kit 0.32.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.32.1",
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",
@@ -26,6 +26,8 @@
26
26
  "dist/**/*.d.ts",
27
27
  "scripts/rollup-integrations.mjs",
28
28
  "scripts/check-descriptor.mjs",
29
+ "scripts/check-conformance.mjs",
30
+ "scripts/deliver-standard.mjs",
29
31
  "README.md",
30
32
  "LICENSE"
31
33
  ],
@@ -0,0 +1,316 @@
1
+ #!/usr/bin/env node
2
+ //
3
+ // Check a repo against the Z2W PROJECT STANDARD — the files every scaffolded
4
+ // project is given, whoever built it and whenever.
5
+ //
6
+ // node scripts/check-conformance.mjs <project-dir> [<project-dir> …]
7
+ // node scripts/check-conformance.mjs --strict <project-dir> # non-zero on any gap
8
+ // node scripts/check-conformance.mjs --denominator # print the standard, examine nothing
9
+ //
10
+ // WHY THIS EXISTS, and it is a routing answer as much as a tool.
11
+ //
12
+ // Three projects have now asked, in three weeks, for the same thing in three
13
+ // different words: `ebooks` ("this repo was never scaffolded — the standard is
14
+ // N things, which ones have I never heard of?"), `audit-engine` ("who audits
15
+ // the auditor? a self-audit can only measure against a standard the auditor
16
+ // already holds"), and Kerry ("ensure you have everything we expect our
17
+ // projects to have, such as roadmap, status, handoff files etc."). The third
18
+ // request for one dimension is the signal that it should be a tool rather than
19
+ // a session — a hand-run audit answers one repo once, and the next asker
20
+ // re-derives it from somebody's memory of the standard.
21
+ //
22
+ // 🔴 THE DENOMINATOR IS DERIVED FROM THE EMITTER, NOT WRITTEN DOWN HERE.
23
+ // A hand-maintained list of "the standard files" is a second copy of a fact the
24
+ // scaffolder already holds, and this repo has measured what happens to those:
25
+ // `--version` reported `0.6.0` for twenty-five published releases because a
26
+ // constant nobody bumped stayed perfectly self-consistent. So the standard is
27
+ // computed, every run, as the INTERSECTION of what `scaffoldByType()` emits for
28
+ // all eight project types. A file is part of the standard if and only if every
29
+ // kind of Z2W project is given it. Change the scaffolder and this check changes
30
+ // with it, in the same commit, with nothing to remember.
31
+ //
32
+ // WHAT IT DELIBERATELY DOES NOT DO.
33
+ //
34
+ // · It never compares CONTENT. Every mature project has rewritten its README;
35
+ // that is the project working, not drifting. Presence is the only claim a
36
+ // structural standard can honestly make.
37
+ // · It never grades. "You are missing 3 of 16" is a measurement; "you fail"
38
+ // is a judgement that belongs to the project, which may have a reason. Some
39
+ // of these files are recent additions the standard gained after a repo was
40
+ // built, and this check cannot know that.
41
+ // · It reports TYPE-SPECIFIC expectations separately and advisorily, because
42
+ // a mature repo legitimately restructures its own source tree.
43
+ //
44
+ // WHAT IT REFUSES TO DO. It will not report a pass over a directory it could
45
+ // not read, and it exits 2 rather than printing a clean sweep when it examined
46
+ // nothing. `PRESENT` / `MISSING` / `UNREADABLE` / `SKIPPED` are four distinct
47
+ // outcomes and none of them is silence. It also fails closed on an unrecognised
48
+ // flag: a check that can be AIMED must never be silently misaimed, or it
49
+ // examines the wrong thing thoroughly and reports a green pass for somewhere
50
+ // else. [[zero-is-not-a-pass]]
51
+ //
52
+ import { existsSync, readFileSync, statSync } from "node:fs";
53
+ import { join, resolve, basename } from "node:path";
54
+
55
+ const KNOWN_FLAGS = ["--strict", "--denominator", "--json", "--help"];
56
+
57
+ const argv = process.argv.slice(2);
58
+ const unknown = argv.filter((a) => a.startsWith("--") && !KNOWN_FLAGS.includes(a.split("=")[0]));
59
+ if (unknown.length) {
60
+ console.error(
61
+ `❌ Unrecognised flag(s): ${unknown.join(", ")}\n` +
62
+ ` Known: ${KNOWN_FLAGS.join(", ")}\n` +
63
+ ` Refusing to run. An ignored flag would silently change what this examines\n` +
64
+ ` and report a confident result about the wrong thing.`,
65
+ );
66
+ process.exit(1);
67
+ }
68
+
69
+ const args = {
70
+ strict: argv.includes("--strict"),
71
+ denominatorOnly: argv.includes("--denominator"),
72
+ json: argv.includes("--json"),
73
+ };
74
+ const targets = argv.filter((a) => !a.startsWith("--"));
75
+
76
+ if (argv.includes("--help")) {
77
+ console.log(readFileSync(new URL(import.meta.url), "utf8").split("\n").slice(1)
78
+ .filter((l) => l.startsWith("//")).map((l) => l.replace(/^\/\/ ?/, "")).join("\n"));
79
+ process.exit(0);
80
+ }
81
+
82
+ // ── The standard, DERIVED ────────────────────────────────────────────────────
83
+
84
+ const { scaffoldByType, PROJECT_TYPES, deriveStandard, probeInputs } = await import("../dist/index.js");
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.
92
+ function emittedPaths(projectType, over = {}) {
93
+ return new Set(
94
+ scaffoldByType(probeInputs(projectType, over), {
95
+ date: new Date().toISOString().slice(0, 10),
96
+ frameworkVersion: "0.0.0",
97
+ }).map((f) => f.path),
98
+ );
99
+ }
100
+
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 });
107
+ // A guard against the vacuous denominator: an empty standard would pass every
108
+ // repo on earth, and an empty PROJECT_TYPES would produce one silently.
109
+ if (universal.length === 0) {
110
+ console.error(
111
+ "❌ Derived an EMPTY project standard from the scaffolder. Refusing to run:\n" +
112
+ " an empty standard reports every repo as fully conformant, which is the\n" +
113
+ " exact false pass this check exists to prevent.",
114
+ );
115
+ process.exit(2);
116
+ }
117
+ return universal;
118
+ }
119
+
120
+ /** Paths emitted for THIS project's declared shape, beyond the universal set. */
121
+ function deriveTypeSpecific(descriptor, slug) {
122
+ const t = descriptor?.projectType;
123
+ if (!t || !PROJECT_TYPES.includes(t)) return null; // cannot evaluate — not a guess
124
+ const over = {};
125
+ // A slug the scaffolder will accept. Python packages cannot hold a hyphen, and
126
+ // an invalid slug would throw and silently cost the whole type-specific half.
127
+ if (/^[a-z][a-z0-9-]{2,49}$/.test(slug)) over.slug = slug;
128
+ if (descriptor?.stack?.hasWebUi === true) over.hasWebUi = true;
129
+ if (descriptor?.stack?.hasCron === true) over.hasCron = true;
130
+ if (descriptor?.stack?.database && descriptor.stack.database !== "unknown"
131
+ && descriptor.stack.database !== "none") {
132
+ over.dbStrategy = descriptor.stack.database;
133
+ }
134
+ if (descriptor?.coordination?.participates === false) over.participateInBulletin = false;
135
+ let set;
136
+ try {
137
+ set = emittedPaths(t, over);
138
+ } catch {
139
+ set = emittedPaths(t); // an unsupported dbStrategy must not abort the whole run
140
+ }
141
+ return { paths: [...set].sort(), applied: over };
142
+ }
143
+
144
+ const UNIVERSAL = deriveUniversal();
145
+ const UNIVERSAL_NON_PARTICIPANT = deriveUniversal(false);
146
+
147
+ if (args.denominatorOnly) {
148
+ console.log(`The Z2W project standard is ${UNIVERSAL.length} files — every path emitted by`);
149
+ console.log(`ALL ${PROJECT_TYPES.length} project types (${PROJECT_TYPES.join(", ")}).`);
150
+ console.log(`Derived from this repo's own scaffolder at run time, never from a list.\n`);
151
+ for (const p of UNIVERSAL) console.log(` ${p}`);
152
+ process.exit(0);
153
+ }
154
+
155
+ if (targets.length === 0) {
156
+ console.error(
157
+ "❌ No project directory given, so nothing was examined.\n" +
158
+ " Usage: node scripts/check-conformance.mjs <project-dir> [<project-dir> …]\n" +
159
+ " Run with --denominator to print the standard without examining anything.",
160
+ );
161
+ process.exit(2);
162
+ }
163
+
164
+ // ── Examine ──────────────────────────────────────────────────────────────────
165
+
166
+ const results = [];
167
+
168
+ for (const raw of targets) {
169
+ const dir = resolve(raw);
170
+ const name = basename(dir);
171
+
172
+ if (!existsSync(dir) || !statSync(dir).isDirectory()) {
173
+ results.push({ name, dir, outcome: "UNREADABLE", reason: "not a directory that exists" });
174
+ continue;
175
+ }
176
+ // A repo is the unit. A directory that is not one is SKIPPED with a reason,
177
+ // never counted as a clean pass.
178
+ if (!existsSync(join(dir, ".git"))) {
179
+ results.push({ name, dir, outcome: "SKIPPED", reason: "no .git — not a project repo" });
180
+ continue;
181
+ }
182
+
183
+ let descriptor = null;
184
+ let descriptorState = "absent";
185
+ const descPath = join(dir, "z2w-project.json");
186
+ if (existsSync(descPath)) {
187
+ try {
188
+ descriptor = JSON.parse(readFileSync(descPath, "utf8"));
189
+ descriptorState = descriptor?.backfilled === true ? "backfilled" : "declared";
190
+ } catch {
191
+ descriptorState = "unparseable";
192
+ }
193
+ }
194
+
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;
199
+
200
+ // AGENTS.md / GEMINI.md are mirrors, not standard files — the scaffolder never
201
+ // emits them and CLAUDE.md says never to create them just to hold a block. So
202
+ // they are reported as an observation, never as a gap.
203
+ const mirrors = ["AGENTS.md", "GEMINI.md"].filter((f) => existsSync(join(dir, f)));
204
+
205
+ const typeSpec = deriveTypeSpecific(descriptor, descriptor?.slug ?? name);
206
+ const typeMissing = typeSpec
207
+ ? typeSpec.paths.filter((p) => !standard.includes(p) && !existsSync(join(dir, p)))
208
+ : null;
209
+
210
+ results.push({
211
+ name, dir, outcome: missing.length === 0 ? "CONFORMS" : "GAPS",
212
+ present, total: standard.length, missing, mirrors,
213
+ descriptorState, projectType: descriptor?.projectType ?? null,
214
+ typeMissing, typeTotal: typeSpec ? typeSpec.paths.length : null,
215
+ });
216
+ }
217
+
218
+ // ── Report ───────────────────────────────────────────────────────────────────
219
+
220
+ // 🔴 PEER RARITY — the half that makes a gap READABLE, and the half a single-repo
221
+ // audit structurally cannot produce.
222
+ //
223
+ // "You are missing BACKUPS.md" invites the reading "you were built wrong". The
224
+ // portfolio says otherwise: 37 of 57 repos lack it, which is not 37 mistakes —
225
+ // it is a standard that GREW, with no mechanism to deliver an addition to the
226
+ // repos scaffolded before it existed. That is the capture-learnings enrolment
227
+ // bug again (the step was right; 25 of 41 projects never received it), and it
228
+ // belongs to THIS project, not to the repo being measured.
229
+ //
230
+ // So a gap shared with most peers and a gap unique to one repo are different
231
+ // findings with different owners, and they must not print the same line.
232
+ const peerCount = {};
233
+ const examinedRepos = results.filter((r) => r.outcome === "CONFORMS" || r.outcome === "GAPS");
234
+ for (const r of examinedRepos) for (const m of r.missing) peerCount[m] = (peerCount[m] ?? 0) + 1;
235
+ const N = examinedRepos.length;
236
+ /** A gap is SHARED once most examined peers have it too — but only when enough
237
+ * peers were examined to say so. With one repo there is no peer set, and the
238
+ * honest answer is "not measured", never "unique to you". */
239
+ function rarity(path) {
240
+ if (N < 5) return null;
241
+ const n = peerCount[path] ?? 0;
242
+ return { n, of: N, shared: n > N / 2 };
243
+ }
244
+
245
+ if (args.json) {
246
+ console.log(JSON.stringify({ standard: UNIVERSAL, peerCount, examined: N, results }, null, 2));
247
+ } else {
248
+ console.log(`The Z2W project standard is ${UNIVERSAL.length} files, derived from this repo's`);
249
+ console.log(`scaffolder as the intersection of all ${PROJECT_TYPES.length} project types.\n`);
250
+
251
+ for (const r of results) {
252
+ if (r.outcome === "UNREADABLE" || r.outcome === "SKIPPED") {
253
+ console.log(`⚪ ${r.name} — ${r.outcome}: ${r.reason}`);
254
+ console.log(` ${r.dir}\n`);
255
+ continue;
256
+ }
257
+ const icon = r.outcome === "CONFORMS" ? "✅" : "🟠";
258
+ console.log(`${icon} ${r.name} — ${r.present} of ${r.total} standard files present`);
259
+ console.log(` ${r.dir}`);
260
+ if (r.missing.length) {
261
+ const yours = r.missing.filter((m) => !rarity(m)?.shared);
262
+ const common = r.missing.filter((m) => rarity(m)?.shared);
263
+ if (N < 5) {
264
+ console.log(` MISSING: ${r.missing.join(", ")}`);
265
+ console.log(` ⓘ only ${N} repo(s) examined — too few to say whether peers share these gaps.`);
266
+ } else {
267
+ if (yours.length) console.log(` MISSING, and rare among peers: ` +
268
+ yours.map((m) => `${m} (${rarity(m).n}/${N})`).join(", "));
269
+ if (common.length) console.log(` MISSING, but so are most peers — a DELIVERY gap, not this repo's: ` +
270
+ common.map((m) => `${m} (${rarity(m).n}/${N})`).join(", "));
271
+ }
272
+ }
273
+ if (r.mirrors.length) console.log(` also keeps (not standard, a mirror): ${r.mirrors.join(", ")}`);
274
+ if (r.descriptorState === "absent") {
275
+ console.log(` ⓘ no z2w-project.json, so the TYPE-SPECIFIC half could not be evaluated`);
276
+ } else if (r.descriptorState === "unparseable") {
277
+ console.log(` ⚠ z2w-project.json is unparseable — type-specific half NOT evaluated`);
278
+ } else if (!r.projectType) {
279
+ console.log(` ⓘ descriptor declares no projectType — type-specific half NOT evaluated`);
280
+ } else {
281
+ const inferred = r.descriptorState === "backfilled" ? " (INFERRED, backfilled)" : "";
282
+ console.log(` type ${r.projectType}${inferred}: ${r.typeMissing.length} of ` +
283
+ `${r.typeTotal - r.total} type-specific paths absent` +
284
+ (r.typeMissing.length ? ` — ${r.typeMissing.slice(0, 8).join(", ")}` +
285
+ (r.typeMissing.length > 8 ? `, +${r.typeMissing.length - 8} more` : "") : ""));
286
+ console.log(` ⓘ type-specific absences are ADVISORY — a mature repo restructures its own source tree.`);
287
+ }
288
+ console.log("");
289
+ }
290
+
291
+ const examined = results.filter((r) => r.outcome === "CONFORMS" || r.outcome === "GAPS").length;
292
+ const conforms = results.filter((r) => r.outcome === "CONFORMS").length;
293
+ const skipped = results.filter((r) => r.outcome === "SKIPPED").length;
294
+ const unreadable = results.filter((r) => r.outcome === "UNREADABLE").length;
295
+
296
+ console.log(`Examined ${examined} of ${results.length} target(s) against a ${UNIVERSAL.length}-file standard.`);
297
+ console.log(` fully conformant: ${conforms}`);
298
+ console.log(` with gaps: ${examined - conforms}`);
299
+ console.log(` skipped: ${skipped} (not a repo)`);
300
+ console.log(` unreadable: ${unreadable}`);
301
+ if (N >= 5) {
302
+ const shared = Object.entries(peerCount).filter(([p]) => rarity(p).shared)
303
+ .sort((a, b) => b[1] - a[1]);
304
+ if (shared.length) {
305
+ console.log(`\n🔴 ${shared.length} standard file(s) are absent from MOST of the ${N} repos examined.`);
306
+ console.log(` That is a DELIVERY gap owned by the scaffolder, not ${shared.length} misbuilt projects:`);
307
+ for (const [p, n] of shared) console.log(` ${String(n).padStart(3)} / ${N} ${p}`);
308
+ }
309
+ }
310
+ if (examined === 0) {
311
+ console.error(`\n❌ Examined 0 of ${results.length} target(s). This is NOT a clean sweep —\n` +
312
+ ` nothing was examined, and a zero here says nothing about conformance.`);
313
+ process.exit(2);
314
+ }
315
+ if (args.strict && examined - conforms > 0) process.exit(1);
316
+ }