@zero2webmaster/starter-kit 0.38.0 → 0.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # z2w-starter-kit
2
2
 
3
- **Version:** 0.38.0 | **Framework:** 2.19.0
3
+ **Version:** 0.39.1 | **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.38.0 | Last Updated: 2026-09-23*
138
+ *Version: 0.39.1 | Last Updated: 2026-09-24*
@@ -75,7 +75,9 @@ export interface ProjectDescriptor {
75
75
  generatedBy: string;
76
76
  generatedOn: string;
77
77
  stack: {
78
- runtime: "node" | "python" | "php" | "static" | "none";
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;
package/dist/index.d.ts CHANGED
@@ -435,4 +435,6 @@ export type { StandardKey, StandardDecision, StandardDecisionState, StandardsRes
435
435
  export { scaffoldByType } from "./scaffolders/index.js";
436
436
  export { deriveStandard, planDelivery, deliveryBanner, probeInputs, DELIVERY_CLASS, } from "./standard.js";
437
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";
438
440
  export type { ScaffoldFile, ScaffolderOptions } from "./scaffolders/common.js";
package/dist/index.js CHANGED
@@ -183,3 +183,4 @@ export { parseScaffoldInputs, loadScaffoldInputs, WriterError } from "./writer.j
183
183
  export { resolveStandards, applyStandardsBlock, fathomEnvVarFor } from "./standards.js";
184
184
  export { scaffoldByType } from "./scaffolders/index.js";
185
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
- const COORDINATION_ONBOARDING_TEMPLATE = `# Coordination Onboarding — {{slug}}
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
@@ -32,9 +32,18 @@ export declare const NEXTJS_PWA_PATHS: readonly ["public/manifest.json", "public
32
32
  * `HEAD^` there, which is fine for a long-deployed `main` but wrong for a new
33
33
  * scaffold: a repo with history is linked to Vercel later, and its first
34
34
  * deploy must not be skipped because the newest commit was a STATUS.md edit.
35
+ * - A base EQUAL to the commit being deployed BUILDS. That is a Redeploy of
36
+ * the live commit, and the usual reason to click Redeploy is to pick up a
37
+ * changed env var — the diff is empty by definition, so without this guard
38
+ * the new value never reaches production and only a CANCELED badge says so
39
+ * (`org-hq` measured it 2026-09-23; `audit-engine` filed it here 2026-09-24).
40
+ * A push never deploys the SHA that is already live, so pushes are unaffected.
41
+ * Not covered, because no diff can see an env var: redeploying a NEWER,
42
+ * canceled, prose-only commit. Redeploy the READY deployment instead.
35
43
  * - A base missing from Vercel's shallow clone fails `cat-file` → builds.
36
44
  *
37
- * Must stay ≤ 256 characters (the vercel.json schema's `maxLength`).
45
+ * Must stay ≤ 256 characters (the vercel.json schema's `maxLength`), which is
46
+ * why the empty and redeploy guards share one clause.
38
47
  */
39
48
  export declare const VERCEL_IGNORE_COMMAND: string;
40
49
  export declare function scaffoldNextjs(inputs: ScaffoldInputs, opts?: ScaffolderOptions): ScaffoldFile[];
@@ -5427,13 +5427,22 @@ export default defineConfig({
5427
5427
  * `HEAD^` there, which is fine for a long-deployed `main` but wrong for a new
5428
5428
  * scaffold: a repo with history is linked to Vercel later, and its first
5429
5429
  * deploy must not be skipped because the newest commit was a STATUS.md edit.
5430
+ * - A base EQUAL to the commit being deployed BUILDS. That is a Redeploy of
5431
+ * the live commit, and the usual reason to click Redeploy is to pick up a
5432
+ * changed env var — the diff is empty by definition, so without this guard
5433
+ * the new value never reaches production and only a CANCELED badge says so
5434
+ * (`org-hq` measured it 2026-09-23; `audit-engine` filed it here 2026-09-24).
5435
+ * A push never deploys the SHA that is already live, so pushes are unaffected.
5436
+ * Not covered, because no diff can see an env var: redeploying a NEWER,
5437
+ * canceled, prose-only commit. Redeploy the READY deployment instead.
5430
5438
  * - A base missing from Vercel's shallow clone fails `cat-file` → builds.
5431
5439
  *
5432
- * Must stay ≤ 256 characters (the vercel.json schema's `maxLength`).
5440
+ * Must stay ≤ 256 characters (the vercel.json schema's `maxLength`), which is
5441
+ * why the empty and redeploy guards share one clause.
5433
5442
  */
5434
5443
  export const VERCEL_IGNORE_COMMAND = [
5435
5444
  'B="$VERCEL_GIT_PREVIOUS_SHA"',
5436
- '[ -n "$B" ] || exit 1',
5445
+ '[ -n "$B" ] && [ "$B" != "$VERCEL_GIT_COMMIT_SHA" ] || exit 1',
5437
5446
  'git cat-file -e "$B^{commit}" 2>/dev/null || exit 1',
5438
5447
  `git diff --quiet "$B" HEAD -- . ':(exclude)*.md' ':(exclude)docs/' ':(exclude)drafts/' || exit 1`,
5439
5448
  "exit 0",
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero2webmaster/starter-kit",
3
- "version": "0.38.0",
3
+ "version": "0.39.1",
4
4
  "description": "Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.",
5
5
  "author": {
6
6
  "name": "Dr. Kerry Kriger",
@@ -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
- const targets = argv.filter((a) => !a.startsWith("--"));
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)
@@ -152,6 +153,16 @@ if (args.denominatorOnly) {
152
153
  process.exit(0);
153
154
  }
154
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
+
155
166
  if (targets.length === 0) {
156
167
  console.error(
157
168
  "❌ No project directory given, so nothing was examined.\n" +
@@ -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
- if (projectType === "python-service" || existsSync(join(dir, "pyproject.toml"))) {
262
- return "python";
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
- return "none";
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
- runtime: bestGuess(existing?.stack?.runtime, detectRuntime(dir, projectType, pkg)),
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
  }
@@ -6,6 +6,7 @@
6
6
  // node scripts/deliver-standard.mjs <project-dir> [<project-dir> …] # dry run (default)
7
7
  // node scripts/deliver-standard.mjs --write <project-dir> [<project-dir> …] # create the files
8
8
  // node scripts/deliver-standard.mjs --json <project-dir> … # machine-readable plan
9
+ // node scripts/deliver-standard.mjs --portfolio [--write] # every writable portfolio repo
9
10
  //
10
11
  // WHY THIS EXISTS. `check-conformance.mjs` measured the gap on 2026-09-20:
11
12
  // 48 of 57 repos lacked at least one standard file, because the standard grew
@@ -41,7 +42,7 @@ import { execFileSync } from "node:child_process";
41
42
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
42
43
  import { basename, dirname, join, resolve } from "node:path";
43
44
 
44
- const KNOWN_FLAGS = ["--write", "--json", "--help"];
45
+ const KNOWN_FLAGS = ["--write", "--json", "--portfolio", "--help"];
45
46
  const argv = process.argv.slice(2);
46
47
  const unknown = argv.filter((a) => a.startsWith("--") && !KNOWN_FLAGS.includes(a));
47
48
  if (unknown.length) {
@@ -59,7 +60,22 @@ if (argv.includes("--help")) {
59
60
  }
60
61
  const WRITE = argv.includes("--write");
61
62
  const JSON_OUT = argv.includes("--json");
62
- const targets = argv.filter((a) => !a.startsWith("--"));
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
+ }
63
79
  if (targets.length === 0) {
64
80
  console.error("❌ No project directory given, so nothing was examined.\n" +
65
81
  " Usage: node scripts/deliver-standard.mjs [--write] <project-dir> [<project-dir> …]");
@@ -159,7 +175,7 @@ for (const raw of targets) {
159
175
  }
160
176
 
161
177
  if (JSON_OUT) {
162
- console.log(JSON.stringify({ mode: WRITE ? "write" : "dry-run", date, cliVersion, results }, null, 2));
178
+ console.log(JSON.stringify({ mode: WRITE ? "write" : "dry-run", date, cliVersion, portfolioExcluded, results }, null, 2));
163
179
  } else {
164
180
  console.log(`${WRITE ? "WRITING" : "DRY RUN — nothing written (pass --write)"}: Z2W standard delivery, ${date}\n`);
165
181
  for (const r of results) {