@zero2webmaster/starter-kit 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # z2w-starter-kit
2
2
 
3
- **Version:** 0.26.0 | **Framework:** 2.19.0
3
+ **Version:** 0.27.0 | **Framework:** 2.19.0
4
4
 
5
5
  > Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
6
6
 
@@ -83,7 +83,8 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
83
83
 
84
84
  ## Status
85
85
 
86
- - **v0.26.0 (current)** releases two things. First, the **per-service Uptime Kuma health keyword**, built on 2026-08-21 but never released or written down until now: every deploy target's health document serves `{"status":"ok","service":"<slug>","keyword":"<slug>-health-ok"}`, and the emitted standards block tells the reader to match the full keyword. **The old portfolio-wide `"status":"ok"` was worthless as a check** — byte-identical across every Z2W service, so a monitor with a mistyped URL, one copied from a sibling project, or one left pointing at a decommissioned host still went green, which is the exact failure a keyword exists to catch; a portfolio audit found **12 of 23 monitors** keyed on it. The value is DERIVED from the slug via `healthKeyword()`, which is the load-bearing half — a shared constant would rebuild the same trap with extra steps. Second, a fix in `rollup-integrations.mjs`: **a comma in an author's prose is not an edge separator.** Stripping parentheticals before splitting handled the `(why…)` note form and did nothing for the canonical form's `— why` note, which runs to end of line, so `- consumes: contact-registry — people, tags, entitlements.` was about to write **`tags`** into the Project Registry as a dependency of `commerce-engine`, and `audit-engine`'s trailing sentence was about to write **`live-status`**. Both had been PRINTED on every run under `ⓘ not registry slugs (external, or prose noise — check)` — a line that reports and does not filter, so **a reported artifact that is still written is not a caught one**. A comma-part is now an edge only when it is a known registry slug or carries a `:qualifier`, with the first part exempt because that is where the author names the edge and the only position a legitimate non-registry backend occupies. The same work uncovered the inverse defect — a MISS: prose left attached to the last inline item swallowed its slug, so `z2w-observability-bridge`'s section yielded **only `Vercel`**, an external its own sentence had just disclaimed, while its real edge went unread. **1233 of 1233 passing.**
86
+ - **v0.27.0 (current)** answers `org-hq`'s two scaffold defects, ten days after they were filed. The headline: **`app/robots.ts` was asking the wrong question.** Its gate required a production deployment AND a real custom domain — and an internal admin console satisfies **both** while still being wrong to index, so `org-hq` served `Allow: /` on a branded public subdomain for a month with every check it had passing, because none of them asked. Indexability now takes a third condition, `hasPublicSurface`, baked in at scaffold time rather than read from the environment, because it is a fact about what an app IS and not about where a copy of it is running. **It fails CLOSED** — omitted reads as "no public surface" — which is the opposite default from every other optional input here and is deliberate: a public site wrongly withheld is one field and a redeploy with nothing having escaped, while an internal console wrongly published is silent, slow to undo, and has already happened by the time anyone notices. The wizard and brief-first flows ask, and the CLI's final summary now **states the posture out loud in both directions**, since a silent default is how the original defect survived. `cf-pages` is fixed in the same release — it published `Allow: /` unconditionally — because shipping the fix only in the type that was reported would have left its sibling quietly broken. The second defect: the `*.vercel.app` alias redirect now **excludes `/api/*`**, whose SEO rationale never applied and whose 308 breaks every server-to-server caller that does not follow redirects. **And re-measuring the report changed it:** the companion claim — that adding the exclusion would silently stop redirecting `/`, because a `:path` param cannot match the empty string — **did not reproduce.** On Next.js 15.5.23 a CUSTOM param pattern supplies its own `.*`, which matches empty, so the wildcard alone still redirected the root; the explicit root rule ships anyway as insurance against a path-to-regexp detail that is not a documented guarantee, described as insurance rather than as a repair. Verified per tier 1 on two real scaffolds from the built `dist/` — `npm install`, a real `next build`, and `curl` with forged `Host` headers against both the shipped form and a control build with the root rule removed. **1241 of 1241 passing.**
87
+ - **v0.26.0** releases two things. First, the **per-service Uptime Kuma health keyword**, built on 2026-08-21 but never released or written down until now: every deploy target's health document serves `{"status":"ok","service":"<slug>","keyword":"<slug>-health-ok"}`, and the emitted standards block tells the reader to match the full keyword. **The old portfolio-wide `"status":"ok"` was worthless as a check** — byte-identical across every Z2W service, so a monitor with a mistyped URL, one copied from a sibling project, or one left pointing at a decommissioned host still went green, which is the exact failure a keyword exists to catch; a portfolio audit found **12 of 23 monitors** keyed on it. The value is DERIVED from the slug via `healthKeyword()`, which is the load-bearing half — a shared constant would rebuild the same trap with extra steps. Second, a fix in `rollup-integrations.mjs`: **a comma in an author's prose is not an edge separator.** Stripping parentheticals before splitting handled the `(why…)` note form and did nothing for the canonical form's `— why` note, which runs to end of line, so `- consumes: contact-registry — people, tags, entitlements.` was about to write **`tags`** into the Project Registry as a dependency of `commerce-engine`, and `audit-engine`'s trailing sentence was about to write **`live-status`**. Both had been PRINTED on every run under `ⓘ not registry slugs (external, or prose noise — check)` — a line that reports and does not filter, so **a reported artifact that is still written is not a caught one**. A comma-part is now an edge only when it is a known registry slug or carries a `:qualifier`, with the first part exempt because that is where the author names the edge and the only position a legitimate non-registry backend occupies. The same work uncovered the inverse defect — a MISS: prose left attached to the last inline item swallowed its slug, so `z2w-observability-bridge`'s section yielded **only `Vercel`**, an external its own sentence had just disclaimed, while its real edge went unread. **1233 of 1233 passing.**
87
88
  - **v0.25.0** adds `scripts/reconcile-production-url.mjs`, which reconciles the Project Registry's `production_url` column against the Vercel API — and **measuring the real API showed the 2026-08-17 design sketch was wrong in three separate ways.** The sketch said "read `domains[]`, filter out `*.vercel.app`, never take `domains[0]`." Measured across all 23 Zero2Webmaster Vercel projects: **position carries no information at all** (`z2w-social`'s correct domain is the first survivor, `org-hq`'s is the second), so no positional rule can exist; **filtering the aliases out blanks five Live rows** whose only public surface *is* a `.vercel.app` alias, so aliases are a lower-priority tier rather than noise; and **multiple custom domains are the common case, not an edge** — 6 of 19 resolvable projects have more than one, `file-server` has four. The reconciler therefore returns a *verdict object* rather than a URL, so "there is one" and "I picked one of four" cannot print the same way, and it writes only into a NULL — a recorded value that disagrees is reported as drift and never overwritten, because it may be a human's deliberate choice. **It found a real one on its first live run:** the registry's `z2w-social` URL 308-redirects to `frogspace.savethefrogs.com`. Live redirect evidence is used only to *eliminate* a candidate that points at another candidate — both `leaderboard` domains 307 to `/bansuri`, a tenant path, so "follow redirects and take the final URL" would have written a tenant-scoped URL as a project's production URL. A coverage ledger accounts for every row asserting a public surface, and a completeness check makes an unexplained row loud instead of absent. Also re-syncs the canonical Agent Coordination block to **v0.1.27**, which brings the previously-red conformance test back to green — **1199 of 1199 passing.**
88
89
  - **v0.24.0** makes contrast a measured property of a PAIR rather than a taste call about a swatch. Every `nextjs` scaffold now emits `lib/a11y/contrast.ts` and `test/contrast.test.ts`, a table of **SURFACE x TEXT-ROLE x THRESHOLD** rows measured against the stylesheet the project actually ships — thirteen pairs across six surfaces, with `--brand-ink` measured four separate times because it is painted on four different backgrounds. The candidate came from `static-sites` and its lesson is one line: *contrast is per-surface, not per-palette* — a validator that checks each swatch against white passes cleanly while shipping unreadable text, because the swatch is rendered on the tint panel three components down. **Writing that check found two real defects in this scaffold's own CSS, both invisible to every brand preset.** The keyboard focus ring was painted in `--brand-primary`, which measures 2.03:1 on white in Z2W green and 1.40:1 in Z2W gold — so focusing a field made its boundary *less* visible than at rest, in Zero2Webmaster's and Save The Frogs' own colors. And `readableInkOn()` picked the better of near-black and white without checking that the winner cleared anything, which put a 4.41:1 glyph on any mid-tone brand fill. Fixed with a derived `--brand-focus` (same hue, darkened only as far as 3:1 requires) and an escalation to pure black, which provably clears 4.5:1 on every possible background. **Verified by running the scaffold's own vitest, plus four canaries that each reproduce a defect on demand** — including the one that matters most: an ink that stays green on white and fails at 4.06:1 on the code tint.
89
90
  - **v0.23.0** makes every scaffolded web app defend its own head. `audit-engine` measured 26 reachable Z2W surfaces on 2026-08-20: **22 carried none of the five baseline security headers**, while `leaderboard` carried five of five — so this was a lift from a passing in-house implementation rather than a design exercise. Every `nextjs` scaffold now emits `lib/security-headers.mjs`, applied to every route by a new `async headers()` in **both** `next.config.mjs` variants, and `cf-pages` goes from two of five to five of five. **The CSP is assembled from the origins the scaffold actually loads**, each gated on the input that ships the feature: Fathom unconditionally, Turnstile in `script-src` *and* `frame-src` when the project takes cards (the widget is an iframe, so allowing only the script leaves an uncompletable card path), Sentry in `connect-src` alone when observability is on. **It ships enforcing rather than Report-Only** — a considered deviation from the retrofit-oriented rule, reasoned in the emitted comments, because a scaffold has no live traffic to break and a header that blocks nothing is just a note asking someone to finish later. Alongside it, `lib/json-ld.ts` closes the `JSON.stringify`-into-a-`<script>` sink: not because the scaffold's own JSON-LD was exploitable (it holds a brand name and an env URL) but because the Pro-SEO extension's *documented example* fed a post title — database content — straight into it, which is the exact stored XSS found live in `z2w-social`. **A scaffold's examples are copied more often than its code is read.** Verified on the artifact: real `next build`, all six headers `curl`-confirmed on a home page, a child page and an API route, and headless Chrome reporting zero CSP violations — with a positive control proving the detector fires.
@@ -134,4 +135,4 @@ Inquiries: kerry@zero2webmaster.com.
134
135
  ---
135
136
 
136
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.*
137
- *Version: 0.26.0 | Last Updated: 2026-08-24*
138
+ *Version: 0.27.0 | Last Updated: 2026-08-25*
package/dist/confirm.d.ts CHANGED
@@ -43,6 +43,7 @@ interface Draft {
43
43
  hasUserContent: boolean;
44
44
  hasObservability: boolean;
45
45
  acceptsCards: boolean;
46
+ hasPublicSurface: boolean;
46
47
  customBrand: CustomBrandInputs | null;
47
48
  }
48
49
  export declare function renderDraft(draft: Draft): string;
package/dist/confirm.js CHANGED
@@ -54,7 +54,7 @@ export function renderDraft(draft) {
54
54
  const cb = draft.customBrand;
55
55
  lines.push(` 4a. Brand name ................ ${fmtCustom(cb?.brandName)}`, ` 4b. Capitalization rule ....... ${fmtCustom(cb?.brandNameRule)}`, ` 4c. Primary hex color ......... ${fmtCustom(cb?.primaryColor)}`, ` 4d. Accent hex color .......... ${fmtCustom(cb?.accentColor)}`);
56
56
  }
57
- lines.push(` 5. GitHub owner ................... ${fmt(draft.githubOrg)}`, ` 6. Target path .................... ${fmt(draft.targetPath)}`, ` 7. Database strategy .............. ${fmt(draft.dbStrategy)}`, ` 8. Has web UI ..................... ${fmt(draft.hasWebUi)}`, ` 9. Has cron / scheduled jobs ...... ${fmt(draft.hasCron)}`, ` 10. Participate in agent bulletin .. ${fmt(draft.participateInBulletin)}`, ` 11. Sends transactional/auth email . ${fmt(draft.sendsEmail)}`, ` 12. Accepts user-generated content ${fmt(draft.hasUserContent)}`, ` 13. Wire Sentry error tracking ..... ${fmt(draft.hasObservability)}`, ` 14. Will accept credit cards ....... ${fmt(draft.acceptsCards)}`);
57
+ lines.push(` 5. GitHub owner ................... ${fmt(draft.githubOrg)}`, ` 6. Target path .................... ${fmt(draft.targetPath)}`, ` 7. Database strategy .............. ${fmt(draft.dbStrategy)}`, ` 8. Has web UI ..................... ${fmt(draft.hasWebUi)}`, ` 9. Has cron / scheduled jobs ...... ${fmt(draft.hasCron)}`, ` 10. Participate in agent bulletin .. ${fmt(draft.participateInBulletin)}`, ` 11. Sends transactional/auth email . ${fmt(draft.sendsEmail)}`, ` 12. Accepts user-generated content ${fmt(draft.hasUserContent)}`, ` 13. Wire Sentry error tracking ..... ${fmt(draft.hasObservability)}`, ` 14. Will accept credit cards ....... ${fmt(draft.acceptsCards)}`, ` 15. Public surface (search-indexable) ${fmt(draft.hasPublicSurface)}`);
58
58
  return lines.join("\n");
59
59
  }
60
60
  export function parseSlug(raw) {
@@ -336,8 +336,16 @@ async function editField(draft, fieldNumber, opts) {
336
336
  draft.acceptsCards = result.value;
337
337
  return null;
338
338
  }
339
+ case 15: {
340
+ const raw = await opts.prompter("Public surface — should search engines index this (yes/no):", draft.hasPublicSurface ? "yes" : "no");
341
+ const result = parseBoolean(raw, "Public surface");
342
+ if (!result.ok)
343
+ return result.error;
344
+ draft.hasPublicSurface = result.value;
345
+ return null;
346
+ }
339
347
  default:
340
- return `Field number must be between 1 and 14. Got: ${fieldNumber}.`;
348
+ return `Field number must be between 1 and 15. Got: ${fieldNumber}.`;
341
349
  }
342
350
  }
343
351
  /**
@@ -364,14 +372,15 @@ export async function confirmInputs(parsed, opts) {
364
372
  hasUserContent: parsed.hasUserContent,
365
373
  hasObservability: parsed.hasObservability,
366
374
  acceptsCards: parsed.acceptsCards,
375
+ hasPublicSurface: parsed.hasPublicSurface,
367
376
  customBrand: null,
368
377
  };
369
378
  while (true) {
370
379
  output.write(`\nInferred inputs from your brief:\n\n${renderDraft(draft)}\n\n`);
371
380
  const complete = isComplete(draft);
372
381
  const prompt = complete
373
- ? "Press Enter to accept, a line number (1-14) to edit, or 'cancel' to exit (Ctrl+C also works):"
374
- : "Type a line number (1-14) to fill or edit, or 'cancel' to exit (Ctrl+C also works). Every field must be set before accepting.";
382
+ ? "Press Enter to accept, a line number (1-15) to edit, or 'cancel' to exit (Ctrl+C also works):"
383
+ : "Type a line number (1-15) to fill or edit, or 'cancel' to exit (Ctrl+C also works). Every field must be set before accepting.";
375
384
  const reply = (await opts.prompter(prompt)).trim();
376
385
  if (CONFIRM_CANCEL_KEYWORDS.includes(reply.toLowerCase())) {
377
386
  throw new ConfirmCancelledError();
@@ -388,8 +397,8 @@ export async function confirmInputs(parsed, opts) {
388
397
  continue;
389
398
  }
390
399
  const fieldNumber = Number(reply);
391
- if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber > 14) {
392
- output.write(`\n ✗ "${reply}" is not a line number (1-14).\n`);
400
+ if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber > 15) {
401
+ output.write(`\n ✗ "${reply}" is not a line number (1-15).\n`);
393
402
  continue;
394
403
  }
395
404
  const error = await editField(draft, fieldNumber, opts);
@@ -412,6 +421,7 @@ export async function confirmInputs(parsed, opts) {
412
421
  hasUserContent: draft.hasUserContent,
413
422
  hasObservability: draft.hasObservability,
414
423
  acceptsCards: draft.acceptsCards,
424
+ hasPublicSurface: draft.hasPublicSurface,
415
425
  };
416
426
  if (draft.brand === "custom" && draft.customBrand !== null) {
417
427
  result.customBrand = draft.customBrand;
package/dist/index.d.ts CHANGED
@@ -164,6 +164,45 @@ export interface ScaffoldInputs {
164
164
  * failed silently" surface.
165
165
  */
166
166
  hasObservability?: boolean;
167
+ /**
168
+ * Whether this project has a PUBLIC SURFACE — pages meant for the general
169
+ * public and therefore for search engines — as opposed to an internal
170
+ * console, staff tool, or admin dashboard whose entire audience arrives
171
+ * already knowing the URL.
172
+ *
173
+ * This is the question `app/robots.ts` actually needs answered, and it is NOT
174
+ * the question the indexability gate asked before v0.27.0. That gate asked
175
+ * *"is this a production deployment on a real custom domain?"* — and an
176
+ * internal admin console satisfies **both** conditions while still being
177
+ * wrong to index. The two facts come apart for every console this CLI emits.
178
+ * Reported by `org-hq` on 2026-08-14 after serving `Allow: /` on a branded
179
+ * public subdomain for a month.
180
+ *
181
+ * When `false`, the emitted `isIndexableDeployment()` returns `false` in every
182
+ * environment, so `robots.txt` is `Disallow: /` permanently rather than
183
+ * conditionally. The rest of the SEO baseline (metadata, canonical host,
184
+ * sitemap, OG image, the alias redirect) is untouched — an internal tool still
185
+ * wants a canonical domain and a working share card; it just does not want a
186
+ * crawler.
187
+ *
188
+ * 🔴 **Optional, and OMITTED READS AS `false` — this fails CLOSED**, which is
189
+ * the opposite default from every other optional boolean here and is
190
+ * deliberate. The two errors are not symmetric:
191
+ *
192
+ * - Wrongly non-indexable public app: one field, one redeploy, and the crawler
193
+ * comes back. Nothing has escaped.
194
+ * - Wrongly indexable internal console: admin URLs, staff names and internal
195
+ * tooling are crawled and cached. Getting them back out is slow, awkward,
196
+ * and the exposure has already happened.
197
+ *
198
+ * That asymmetry is the same argument the two-condition gate was built on in
199
+ * the first place — fail toward the visible error ([[unknown-means-denied]]).
200
+ * The wizard and brief-first flows ASK, so an interactive run never relies on
201
+ * the default; the `--input` and programmatic paths must pass it explicitly.
202
+ * Honored by the `nextjs` and `cf-pages` types, which are the two that emit a
203
+ * robots document.
204
+ */
205
+ hasPublicSurface?: boolean;
167
206
  /**
168
207
  * Whether the incoming `Host` header selects the tenant — a HOST-ROUTED
169
208
  * multi-tenant app, where each tenant has its own front door (its own custom
@@ -36,6 +36,19 @@ export interface ParsedBrief {
36
36
  * bot-protection standard and, for `nextjs`, the protected-endpoint shape.
37
37
  */
38
38
  acceptsCards: boolean;
39
+ /**
40
+ * Whether the project has a PUBLIC SURFACE — pages meant for the general
41
+ * public and therefore for search engines. Not nullable; absent signal means
42
+ * `false`.
43
+ *
44
+ * 🔴 Unlike every other inference here, "no signal" resolves to the
45
+ * RESTRICTIVE answer rather than the common one. A brief for a public site
46
+ * nearly always says so (marketing, landing page, visitors, SEO, blog), while
47
+ * a brief for an internal console often just describes the work without ever
48
+ * using the word "internal" — so absence of evidence is far weaker evidence of
49
+ * "public" than it looks. A human confirms on line 15 either way.
50
+ */
51
+ hasPublicSurface: boolean;
39
52
  /** Free-text planning sections lifted verbatim from the brief, if any. */
40
53
  briefSections: BriefSections | undefined;
41
54
  raw: string;
@@ -481,6 +481,80 @@ function inferHasObservability(brief, projectType, hasWebUi) {
481
481
  const isWebAppType = projectType === "nextjs" || projectType === "cf-pages";
482
482
  return isWebAppType && hasWebUi === true;
483
483
  }
484
+ /**
485
+ * Infer whether the project has a PUBLIC SURFACE — pages meant for the general
486
+ * public, and therefore for search engines.
487
+ *
488
+ * This is NOT "does it have a web UI". Every internal console has a web UI. The
489
+ * question is who the pages are for, and it is the question `app/robots.ts`
490
+ * actually needs answered — `org-hq` (2026-08-14) served `Allow: /` on a
491
+ * branded production subdomain for a month because the gate it had asked "is
492
+ * this deployment live and configured?", which an internal console answers yes.
493
+ *
494
+ * 🔴 Defaults to `false`, which is the opposite of how the other inferences
495
+ * here resolve an absent signal, and the asymmetry is the whole reason: a
496
+ * public site wrongly withheld from crawlers is one toggle and a redeploy, with
497
+ * nothing having escaped; an internal console wrongly published is silent, slow
498
+ * to undo, and has already happened by the time anyone notices
499
+ * ([[unknown-means-denied]]). The operator confirms on line 15.
500
+ *
501
+ * The NEGATIVE signals are listed first and win, because a brief that says both
502
+ * "admin dashboard" and "landing page" is describing a tool with a marketing
503
+ * page in front of it — and the tool is the thing being scaffolded here.
504
+ */
505
+ function inferHasPublicSurface(brief, projectType) {
506
+ const explicit = explicitBoolean(brief, [
507
+ "public surface",
508
+ "search engine",
509
+ "search-indexable",
510
+ "indexable",
511
+ "seo",
512
+ ]);
513
+ if (explicit !== null)
514
+ return explicit;
515
+ const lower = brief.toLowerCase();
516
+ // Only the two types that emit a robots document can have a public surface in
517
+ // the sense this flag governs; everything else is moot and stays false.
518
+ if (projectType !== "nextjs" && projectType !== "cf-pages")
519
+ return false;
520
+ const internalSignals = [
521
+ "internal tool",
522
+ "internal console",
523
+ "internal dashboard",
524
+ "internal app",
525
+ "admin console",
526
+ "admin dashboard",
527
+ "admin panel",
528
+ "staff tool",
529
+ "staff console",
530
+ "back office",
531
+ "back-office",
532
+ "not public",
533
+ "behind a login",
534
+ "login-only",
535
+ "logged-in only",
536
+ ];
537
+ if (internalSignals.some((s) => lower.includes(s)))
538
+ return false;
539
+ const publicSignals = [
540
+ "marketing site",
541
+ "marketing page",
542
+ "landing page",
543
+ "public site",
544
+ "public website",
545
+ "public-facing",
546
+ "public facing",
547
+ "brochure site",
548
+ "static site",
549
+ "blog",
550
+ "documentation site",
551
+ "docs site",
552
+ "visitors",
553
+ "search traffic",
554
+ "organic traffic",
555
+ ];
556
+ return publicSignals.some((s) => lower.includes(s));
557
+ }
484
558
  /**
485
559
  * Infer whether the project will accept credit cards. Defaults OFF like
486
560
  * {@link inferSendsEmail} — emitting a Turnstile verifier, a widget and an
@@ -631,6 +705,7 @@ export function parseBrief(brief) {
631
705
  hasUserContent: false,
632
706
  hasObservability: false,
633
707
  acceptsCards: false,
708
+ hasPublicSurface: false,
634
709
  briefSections: undefined,
635
710
  raw: brief,
636
711
  };
@@ -653,6 +728,7 @@ export function parseBrief(brief) {
653
728
  hasUserContent: inferHasUserContent(trimmed),
654
729
  hasObservability: inferHasObservability(trimmed, projectType, hasWebUi),
655
730
  acceptsCards: inferAcceptsCards(trimmed),
731
+ hasPublicSurface: inferHasPublicSurface(trimmed, projectType),
656
732
  briefSections: extractBriefSections(trimmed),
657
733
  raw: brief,
658
734
  };
@@ -135,7 +135,14 @@ const INDEX_HTML_TEMPLATE = `<!DOCTYPE html>
135
135
  </body>
136
136
  </html>
137
137
  `;
138
+ /**
139
+ * The `robots.txt` for a site that HAS a public surface.
140
+ *
141
+ * Chosen by `hasPublicSurface`, not by deployment environment — see
142
+ * ROBOTS_TXT_INTERNAL_TEMPLATE for why those are different questions.
143
+ */
138
144
  const ROBOTS_TXT_TEMPLATE = `# robots.txt for {{slug}}.
145
+ # This site HAS a public surface, so the production deploy is crawlable.
139
146
  # Preview deploys are blocked via the \`X-Robots-Tag: noindex\` header rule
140
147
  # in \`_headers\` (gated to non-production CF Pages branches). This file
141
148
  # applies to the production deploy.
@@ -145,6 +152,38 @@ Allow: /
145
152
 
146
153
  Sitemap: __SITE_URL__/sitemap.xml
147
154
  `;
155
+ /**
156
+ * The `robots.txt` for a site with NO public surface — an internal console,
157
+ * staff tool or admin dashboard.
158
+ *
159
+ * 🔴 This exists because "is this deploy live and configured?" and "is this for
160
+ * the public?" are different questions that every console scaffold makes come
161
+ * apart. The previous single template published `Allow: /` unconditionally, so
162
+ * an internal tool on a branded production domain advertised itself to every
163
+ * crawler and passed every check it had — none of them asked. Reported against
164
+ * the `nextjs` sibling by `org-hq` on 2026-08-14 after a month of exposure;
165
+ * fixed here at the same time because emitting the fix in one of the two types
166
+ * that serve a robots document would leave the other quietly broken.
167
+ *
168
+ * Deliberately NOT gated on the CF Pages branch: there is no deployment of an
169
+ * internal console that should be crawled, so this is unconditional.
170
+ */
171
+ const ROBOTS_TXT_INTERNAL_TEMPLATE = `# robots.txt for {{slug}}.
172
+ # This site has NO public surface — it is an internal tool, so nothing here is
173
+ # meant for a search engine. Scaffolded with hasPublicSurface=false.
174
+ #
175
+ # Unconditional on purpose. An internal console in production on its own real
176
+ # domain satisfies every "is this live?" test and is still wrong to index.
177
+ #
178
+ # ⚠️ robots.txt is ADVISORY, never access control. It asks well-behaved crawlers
179
+ # not to index; it stops nobody from reading a page. Anything that must not be
180
+ # read by a stranger needs authentication.
181
+ #
182
+ # There is no Sitemap: line here on purpose — a sitemap is an invitation.
183
+
184
+ User-agent: *
185
+ Disallow: /
186
+ `;
148
187
  const SITEMAP_XML_TEMPLATE = `<?xml version="1.0" encoding="UTF-8"?>
149
188
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
150
189
  <url>
@@ -293,7 +332,12 @@ export function scaffoldCfPages(inputs, opts) {
293
332
  const base = commonBaseFiles(inputs, opts, NARRATIVE);
294
333
  const typeSpecific = [
295
334
  { path: "index.html", content: sub(INDEX_HTML_TEMPLATE, inputs, opts, spec) },
296
- { path: "robots.txt", content: sub(ROBOTS_TXT_TEMPLATE, inputs, opts, spec) },
335
+ {
336
+ path: "robots.txt",
337
+ content: sub(inputs.hasPublicSurface === true
338
+ ? ROBOTS_TXT_TEMPLATE
339
+ : ROBOTS_TXT_INTERNAL_TEMPLATE, inputs, opts, spec),
340
+ },
297
341
  { path: "sitemap.xml", content: sub(SITEMAP_XML_TEMPLATE, inputs, opts, spec) },
298
342
  { path: "_headers", content: sub(HEADERS_TEMPLATE, inputs, opts, spec) },
299
343
  { path: "_redirects", content: sub(REDIRECTS_TEMPLATE, inputs, opts, spec) },
@@ -132,6 +132,11 @@ const PACKAGE_JSON_TEMPLATE = `{
132
132
  const CANONICAL_HOST_MODULE_TEMPLATE = `// Shared canonical-host predicate. Imported by BOTH next.config.mjs (alias
133
133
  // redirect) and app/robots.ts (indexability gate) so the two can never disagree.
134
134
  //
135
+ // isIndexableDeployment() adds ONE further condition that the redirect does not
136
+ // read: HAS_PUBLIC_SURFACE. That cannot reintroduce the drift this shared module
137
+ // exists to prevent, because the extra condition only ever makes robots MORE
138
+ // restrictive — it can turn "index me" into "do not", never the reverse.
139
+ //
135
140
  // Emitted as .mjs deliberately: next.config.mjs is plain ESM loaded before any
136
141
  // TypeScript exists and cannot import a .ts module. tsconfig.json sets
137
142
  // \`allowJs: true\`, so app/robots.ts type-checks this file too.
@@ -167,21 +172,56 @@ export function canonicalHost(rawSiteUrl) {
167
172
  }
168
173
  }
169
174
 
175
+ /**
176
+ * Whether this app has a PUBLIC SURFACE at all — pages meant for the general
177
+ * public, and therefore for search engines — as opposed to an internal console,
178
+ * staff tool or admin dashboard whose entire audience arrives already knowing
179
+ * the URL.
180
+ *
181
+ * Baked in at scaffold time from the \`hasPublicSurface\` answer, NOT read from
182
+ * the environment, because it is a fact about what this app IS rather than about
183
+ * where this copy of it is running. There is no deployment of an internal
184
+ * console that should be crawled.
185
+ *
186
+ * ⚠️ Changing this to \`true\` is a deliberate act with a consequence: it
187
+ * publishes this app to search engines the moment it is on a real domain in
188
+ * production. Change it when the app grows a genuinely public surface, not to
189
+ * quiet a robots.txt that looks wrong.
190
+ */
191
+ export const HAS_PUBLIC_SURFACE = {{has_public_surface}};
192
+
170
193
  /**
171
194
  * Whether this deployment may be indexed by search engines.
172
195
  *
173
- * Requires BOTH a production deployment AND a real canonical domain. Gating on
174
- * VERCEL_ENV alone means the FIRST production deploy publishes \`Allow: /\` plus a
175
- * sitemap of placeholder URLs, because NEXT_PUBLIC_SITE_URL is unset on day one
176
- * and the fallback is a domain this project does not own. Getting placeholder
177
- * URLs back out of a search index is slow and awkward, so this fails toward the
178
- * visible error: a misconfigured deploy stays \`Disallow: /\`, which one \`curl\`
179
- * reveals and one env var fixes.
196
+ * THREE conditions, and the first one is the one people leave out.
197
+ *
198
+ * 1. **The app has a public surface at all.** An internal admin console in
199
+ * production on its own branded domain satisfies conditions 2 and 3
200
+ * completely and is still wrong to index. "Is this live?" and "is this for
201
+ * the public?" are different questions, and every console scaffold is where
202
+ * they come apart. (Reported by \`org-hq\` 2026-08-14, which served
203
+ * \`Allow: /\` on a branded public subdomain for a month — every check it had
204
+ * was passing, because none of them asked this.)
205
+ * 2. **A production deployment**, and
206
+ * 3. **a real canonical domain.** Gating on VERCEL_ENV alone means the FIRST
207
+ * production deploy publishes \`Allow: /\` plus a sitemap of placeholder URLs,
208
+ * because NEXT_PUBLIC_SITE_URL is unset on day one and the fallback is a
209
+ * domain this project does not own.
210
+ *
211
+ * All three fail toward the VISIBLE error: a misconfigured deploy stays
212
+ * \`Disallow: /\`, which one \`curl\` reveals and one env var fixes. The opposite
213
+ * error — indexed when it should not be — is silent, slow to undo, and has
214
+ * already happened by the time anyone notices.
215
+ *
216
+ * 🔴 \`Disallow: /\` IS NOT ACCESS CONTROL. It asks well-behaved crawlers not to
217
+ * index; it stops nobody from reading the page. Anything that must not be read
218
+ * by a stranger needs authentication, not a robots rule.
180
219
  *
181
220
  * @param {Record<string, string | undefined>} [env] defaults to process.env
182
221
  * @returns {boolean}
183
222
  */
184
223
  export function isIndexableDeployment(env = process.env) {
224
+ if (!HAS_PUBLIC_SURFACE) return false;
185
225
  return env.VERCEL_ENV === "production" && canonicalHost(env.NEXT_PUBLIC_SITE_URL) !== "";
186
226
  }
187
227
  `;
@@ -702,12 +742,48 @@ const nextConfig = {
702
742
  const host = canonicalHost(process.env.NEXT_PUBLIC_SITE_URL);
703
743
  // Only in production, and only once a real custom domain is configured.
704
744
  if (!host || !isVercelProduction) return [];
745
+ // Match ANY *.vercel.app host — covers every production alias at once.
746
+ const onAliasHost = [{ type: "host", value: "(?<alias>.*\\\\.vercel\\\\.app)" }];
705
747
  return [
748
+ // An EXPLICIT rule for the root, kept deliberately even though it is
749
+ // redundant today — and the honest reason is worth the four lines.
750
+ //
751
+ // \`org-hq\` reported (2026-08-14) that adding the /api/ exclusion below
752
+ // would silently stop redirecting \`/\`, because a \`:path\` param cannot
753
+ // match the empty string. That is true of a BARE \`:path\` (whose default
754
+ // pattern is one-or-more), and it did NOT reproduce for the form used
755
+ // here: measured on Next.js 15.5.23, \`/:path((?!api/).*)\` compiles to
756
+ // \`^(?!/_next)(?:/((?!api\\/).*))(?:/)?\$\`, and \`.*\` inside a CUSTOM
757
+ // pattern happily matches empty — so the wildcard alone did redirect the
758
+ // root. Verified by building both forms and curling them with forged Host
759
+ // headers, not by reading either config.
760
+ //
761
+ // It stays because that behaviour is an artifact of how path-to-regexp
762
+ // compiles a custom param pattern, not a documented Next.js guarantee,
763
+ // and \`/\` is the most-linked URL this site has. One extra rule object
764
+ // pins it. If you remove it, re-measure — do not reason about it.
706
765
  {
707
- source: "/:path*",
708
- // Match ANY *.vercel.app host — covers every production alias at once.
709
- has: [{ type: "host", value: "(?<alias>.*\\\\.vercel\\\\.app)" }],
710
- destination: \`https://\${host}/:path*\`,
766
+ source: "/",
767
+ has: onAliasHost,
768
+ destination: \`https://\${host}/\`,
769
+ permanent: true,
770
+ },
771
+ {
772
+ // Everything EXCEPT /api/*. This redirect exists for SEO — so an alias
773
+ // is not crawled as a duplicate of the whole site — and that rationale
774
+ // does not reach API routes, which no crawler indexes. What it DOES
775
+ // reach is every server-to-server caller that was handed an alias URL:
776
+ // a bare \`curl\` without \`-L\`, a \`fetch\` with \`redirect: "error"\`, a
777
+ // webhook sender that treats 3xx as failure. Those break, and a
778
+ // redirect in a network log looks like it worked, so the diagnosis is
779
+ // slow. Excluding them costs no SEO and removes the whole class.
780
+ //
781
+ // (The right long-term fix is still not to hand out an alias URL as an
782
+ // API endpoint. But a config that silently breaks the caller is the
783
+ // worse half of that mistake, and it is the half this file owns.)
784
+ source: "/:path((?!api/).*)",
785
+ has: onAliasHost,
786
+ destination: \`https://\${host}/:path\`,
711
787
  permanent: true,
712
788
  },
713
789
  ];
@@ -4318,11 +4394,25 @@ export default function sitemap(): MetadataRoute.Sitemap {
4318
4394
  ];
4319
4395
  }
4320
4396
  `;
4321
- const APP_ROBOTS_TEMPLATE = `// Robots generator — indexable ONLY on a production deployment that also has a
4322
- // real canonical domain. Everything else (preview, staging, and a production
4323
- // deploy still on the placeholder domain) emits \`Disallow: /\`.
4397
+ const APP_ROBOTS_TEMPLATE = `// Robots generator — indexable ONLY when this app HAS A PUBLIC SURFACE and is on
4398
+ // a production deployment that also has a real canonical domain. Everything else
4399
+ // (an internal console, a preview, a staging deploy, and a production deploy
4400
+ // still on the placeholder domain) emits \`Disallow: /\`.
4401
+ //
4402
+ // 🔴 THE FIRST CONDITION IS THE ONE THAT GETS LEFT OUT, and it is not an
4403
+ // environment fact. An internal admin console running in production on its own
4404
+ // branded domain passes every "is this live and configured?" check and is still
4405
+ // wrong to index. It is set by \`HAS_PUBLIC_SURFACE\` in
4406
+ // lib/seo/canonical-host.mjs — baked in from the scaffold answer, deliberately
4407
+ // NOT an env var, because it is a property of what this app IS rather than of
4408
+ // where this copy of it is running. (\`org-hq\` served \`Allow: /\` on a branded
4409
+ // public subdomain for a month before anyone looked, 2026-08-14.)
4410
+ //
4411
+ // ⚠️ And \`Disallow: /\` is ADVISORY, never access control — it asks well-behaved
4412
+ // crawlers not to index, and stops nobody at all from reading the page. Anything
4413
+ // that must not be read by a stranger needs authentication.
4324
4414
  //
4325
- // Two conditions, not one. Gating on \`VERCEL_ENV\` ALONE means the very first
4415
+ // Three conditions, not one. Gating on \`VERCEL_ENV\` ALONE means the very first
4326
4416
  // \`vercel --prod\` — or the first push after connecting the repo, since
4327
4417
  // auto-deploy is on by default — publishes \`Allow: /\` advertising a sitemap of
4328
4418
  // \`{{slug}}.example.com\` URLs, a domain this project does not own.
@@ -131,6 +131,16 @@ export function buildSubstitutionMap(inputs, opts = {}) {
131
131
  slug_camel: pascalCaseFromSlug(inputs.slug),
132
132
  slug_const: upperSnakeFromSlug(inputs.slug),
133
133
  health_keyword: healthKeyword(inputs.slug),
134
+ // The `HAS_PUBLIC_SURFACE` constant baked into the emitted
135
+ // lib/seo/canonical-host.mjs. A STRING here because it is interpolated into
136
+ // a source file as a JS literal, not used as a condition in this process.
137
+ //
138
+ // 🔴 Omitted reads as FALSE (see `hasPublicSurface` in src/index.ts): an
139
+ // internal console wrongly indexed is a slow, awkward, already-happened
140
+ // exposure, while a public app wrongly non-indexable is one field and a
141
+ // redeploy. The wizard and brief-first flows always ask, so this default
142
+ // only governs the `--input` / programmatic paths.
143
+ has_public_surface: inputs.hasPublicSurface === true ? "true" : "false",
134
144
  description: inputs.description,
135
145
  brand_name: spec.brandName,
136
146
  brand_name_rule: spec.brandNameRule,
package/dist/summary.js CHANGED
@@ -133,6 +133,25 @@ function buildNextActions(inputs, result, repoAutoCreated) {
133
133
  note: "battle-tested across z2w-social + event-engine — do not hand-roll per-content-type; see [[moderation-system]] for the data model + verification checklist",
134
134
  });
135
135
  }
136
+ // 🔴 STATE THE INDEXABILITY POSTURE OUT LOUD, both ways.
137
+ //
138
+ // `hasPublicSurface` fails closed, which is the right default and a silent
139
+ // one — and a silent default is how the defect this fixes survived a month in
140
+ // the first place. So the summary names the answer that was applied rather
141
+ // than leaving the operator to discover it from a robots.txt nobody curls.
142
+ // Both branches print: "not indexable" needs saying because it is surprising,
143
+ // and "indexable" needs saying because it is the consequential one.
144
+ if (inputs.projectType === "nextjs" || inputs.projectType === "cf-pages") {
145
+ actions.push(inputs.hasPublicSurface === true
146
+ ? {
147
+ label: `Search engines WILL index this once it is in production on a real custom domain (hasPublicSurface=true)`,
148
+ note: "robots.txt serves `Allow: /` plus a sitemap. If this is an internal console or staff tool, re-scaffold with hasPublicSurface=false — an internal app that gets crawled is slow and awkward to pull back out of a search index.",
149
+ }
150
+ : {
151
+ label: `Search engines will NOT index this in any environment (hasPublicSurface=false — the default)`,
152
+ note: "robots.txt serves `Disallow: /` unconditionally. If this app IS meant for the public, set hasPublicSurface=true (nextjs: also flip HAS_PUBLIC_SURFACE in lib/seo/canonical-host.mjs) and redeploy — robots.txt is prerendered at build time, so an env change alone does nothing. And note robots.txt is advisory, never access control: anything that must stay unread needs authentication.",
153
+ });
154
+ }
136
155
  if (inputs.projectType === "wp-plugin") {
137
156
  actions.push({
138
157
  label: `Symlink the plugin folder into Local by Flywheel (ln -s ...)`,
package/dist/wizard.js CHANGED
@@ -162,6 +162,20 @@ export async function runWizard(opts) {
162
162
  // card-path shape rather than leaving the first payment route bare — which is
163
163
  // only cheap BEFORE the code exists ([[stripe-elements-confirm-path]] §8).
164
164
  const acceptsCards = await askValidated(prompter, "8g. Will this project accept credit cards — checkout, donations, save-a-card (yes/no):", parseYesNo, "no", out);
165
+ // 🔴 Default NO, and this is the one question here where the default is
166
+ // deliberately not the common answer.
167
+ //
168
+ // It is NOT "does this have a web UI" — every internal console has one. It is
169
+ // "are these pages for the general public", which is what app/robots.ts needs
170
+ // and what the old gate never asked: an internal admin console in production
171
+ // on its own branded domain satisfied every "is this live and configured?"
172
+ // condition and shipped `Allow: /` (`org-hq`, 2026-08-14, a month of it).
173
+ //
174
+ // Answering NO costs a public site one redeploy once someone notices it is
175
+ // not in Google. Answering YES wrongly puts an internal tool's URLs into a
176
+ // search index, which is slow to undo and has already happened by then. So
177
+ // the operator must say yes on purpose.
178
+ const hasPublicSurface = await askValidated(prompter, "8h. Public surface — should search engines index this, or is it an internal/staff tool (yes/no):", parseYesNo, "no", out);
165
179
  const result = {
166
180
  slug,
167
181
  description,
@@ -177,6 +191,7 @@ export async function runWizard(opts) {
177
191
  hasUserContent,
178
192
  hasObservability,
179
193
  acceptsCards,
194
+ hasPublicSurface,
180
195
  };
181
196
  if (customBrand) {
182
197
  result.customBrand = customBrand;
package/dist/writer.js CHANGED
@@ -561,6 +561,23 @@ export function parseScaffoldInputs(json) {
561
561
  }
562
562
  inputs.hasObservability = obj["hasObservability"];
563
563
  }
564
+ // Optional: whether this project has a PUBLIC SURFACE — pages meant for the
565
+ // general public and therefore for search engines — as opposed to an internal
566
+ // console or staff tool.
567
+ //
568
+ // 🔴 Defaults to FALSE, i.e. NOT indexable, which is the opposite default from
569
+ // every other optional boolean on this path and is deliberate. A programmatic
570
+ // caller that forgets this field gets a site that is not crawled — one field
571
+ // and a redeploy to fix, nothing escaped. The other error, an internal console
572
+ // published to search engines, is silent and already-happened by the time
573
+ // anyone notices ([[unknown-means-denied]]). The interactive flows ask, so
574
+ // this default only governs --input and the programmatic API.
575
+ if (obj["hasPublicSurface"] !== undefined) {
576
+ if (typeof obj["hasPublicSurface"] !== "boolean") {
577
+ throw new WriterError(`--input field "hasPublicSurface" must be a boolean, got ${typeof obj["hasPublicSurface"]}.`);
578
+ }
579
+ inputs.hasPublicSurface = obj["hasPublicSurface"];
580
+ }
564
581
  // Optional: whether the incoming Host selects the tenant (a HOST-ROUTED
565
582
  // multi-tenant app). Defaults to false (single-tenant). When true, the nextjs
566
583
  // scaffolder omits the single-destination *.vercel.app alias redirect — wrong
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero2webmaster/starter-kit",
3
- "version": "0.26.0",
3
+ "version": "0.27.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",