@zero2webmaster/starter-kit 0.13.0 → 0.14.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.13.0 | **Framework:** 2.13.0
3
+ **Version:** 0.14.0 | **Framework:** 2.13.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.9.5 (current)** gives the Project Registry a **write path for the events it describes**. `z2w-agent-command-center` reported two stale `production_status` rows and asked for a writer; investigating found two different causes wearing one face. `site-control`'s row would have been fixed by the reconciler that already exists — nothing ever ran it. `email-engine`'s row **could not** be fixed, because `scripts/rollup-integrations.mjs` allowed a backtick before the status value but not an asterisk, so every project that **bolded** its Live status parsed as null and vanished from the report — indistinguishable from a row already in sync. That was 3 of the 15 sections declaring a status (20%), two of which said LIVE. The parser now reads the forms agents actually write, and reports declared-but-unreadable separately from never-declared, at zero as well as non-zero. Six rows reconciled. Also: the `command_center` role (scoped to the two approval columns), a CHECK that makes `summary_state = 'approved'` unreachable without them, and `status_qualifier` for the projects that kept writing a sixth value into a five-value enum.
86
+ - **v0.14.0 (current)** makes card-path bot protection a scaffold standard, and fixes a defect that made **every** Next.js scaffold's server modules impossible to unit-test. A new `acceptsCards` input inserts a standard pointing at [[stripe-elements-confirm-path]] §8 for every project type that has a runtime request surface, and — for Next.js — emits the protected endpoint shape rather than a bare one: a Turnstile verifier whose verdict is five-valued and **fails open**, an abuse policy sized for card entry (30 per 10 minutes per source, no global cap) rather than copied from order submission, the browser widget with `appearance: "interaction-only"` and every failure callback wired, and an emitted test that greps the consuming project's own `app/` and fails the next card path added bare. The enumeration grep ships *with* the standard, because a rule that says "protect the card path" without saying how to enumerate card paths passes review and misses a route. Separately: `import "server-only"` is a build-time poison pill that made every server module in every scaffold fail to LOAD under vitest — while `next build`, `tsc --noEmit` and the emitted suite all passed — so scaffolds now emit a `server-only` test stub plus the `@/*` alias that mirrors `tsconfig.json`.
87
+ - **v0.9.5** gives the Project Registry a **write path for the events it describes**. `z2w-agent-command-center` reported two stale `production_status` rows and asked for a writer; investigating found two different causes wearing one face. `site-control`'s row would have been fixed by the reconciler that already exists — nothing ever ran it. `email-engine`'s row **could not** be fixed, because `scripts/rollup-integrations.mjs` allowed a backtick before the status value but not an asterisk, so every project that **bolded** its Live status parsed as null and vanished from the report — indistinguishable from a row already in sync. That was 3 of the 15 sections declaring a status (20%), two of which said LIVE. The parser now reads the forms agents actually write, and reports declared-but-unreadable separately from never-declared, at zero as well as non-zero. Six rows reconciled. Also: the `command_center` role (scoped to the two approval columns), a CHECK that makes `summary_state = 'approved'` unreachable without them, and `status_qualifier` for the projects that kept writing a sixth value into a five-value enum.
87
88
  - **v0.9.4** corrects a **privacy understatement in the emitted Sentry standard**. It had told every scaffolded web app to set `sendDefaultPii: true` and described the consequence as *"user IP + request headers"*. Verified against `@sentry/core` 10.69.0's own `defaultPiiToCollectionOptions()`, that flag resolves **ten** axes on — including `httpBodies` in all four directions, `databaseQueryData`, `stackFrameVariables` (local variable values), and `genAI: { inputs: true, outputs: true }`, which is the user's prompt and the model's completion. The standard now prescribes one complete `dataCollection` block, carries both counter-intuitive traps (a partial block flips the baseline to all-on; `stackFrameVariables` is on in *both* branches so `sendDefaultPii: false` cannot reach it), and makes the **resolver** the binding check rather than any list in a doc. Also retires the registry's `project_type` column in favour of `stack` + `audience`.
88
89
  - **v0.9.3** fixes a scaffold-corrupting splice bug and the "GitHub org" wording. The canonical Agent Coordination block contains the anchor `` (`^## Current focus$`) ``, whose `$` and closing backtick form `` $` `` — a `String.replace()` special pattern meaning *"everything before the match"*. Because the block was passed as a replacement **string**, every scaffold emitted since 2026-07-30 pasted its own entire document head into the middle of that sentence. All four canonical-body splices now use a replacer **function**, whose return value is never pattern-interpreted. Separately, the brand block now reads `- **GitHub owner:**` and states the account type: `zero2webmaster` is a GitHub **User**, not an Organization, so `/organizations/...` URLs 404 — wording that had sent two agents to those 404s.
89
90
  - **v0.9.2** re-syncs the emitted Capture Learnings block to canonical **v1.1.0** (the `AGENTS.md`/`GEMINI.md` mirror is now conditional). **v0.9.1** republishes v0.9.0 with the corrected LICENSE + README. The 0.9.0 tarball shipped the old text by accident — see CHANGELOG. **v0.9.0** gives every Next.js scaffold accessible form primitives — `components/FormBits.tsx` (`<Field>` / `<Required>` / `<InfoHint>`), the `app/globals.css` they need, a vitest runner, and an *emitted* `test/form-standards.test.ts` that fails on the next hand-rolled form which labels a field "(optional)", hides help text in a placeholder, or marks required with a bare `*`.
@@ -112,4 +113,4 @@ Inquiries: kerry@zero2webmaster.com.
112
113
  ---
113
114
 
114
115
  *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.*
115
- *Version: 0.13.0 | Last Updated: 2026-08-05*
116
+ *Version: 0.14.0 | Last Updated: 2026-08-08*
package/dist/confirm.d.ts CHANGED
@@ -42,6 +42,7 @@ interface Draft {
42
42
  sendsEmail: boolean;
43
43
  hasUserContent: boolean;
44
44
  hasObservability: boolean;
45
+ acceptsCards: boolean;
45
46
  customBrand: CustomBrandInputs | null;
46
47
  }
47
48
  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)}`);
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)}`);
58
58
  return lines.join("\n");
59
59
  }
60
60
  export function parseSlug(raw) {
@@ -328,8 +328,16 @@ async function editField(draft, fieldNumber, opts) {
328
328
  draft.hasObservability = result.value;
329
329
  return null;
330
330
  }
331
+ case 14: {
332
+ const raw = await opts.prompter("Will accept credit cards (yes/no):", draft.acceptsCards ? "yes" : "no");
333
+ const result = parseBoolean(raw, "Will accept credit cards");
334
+ if (!result.ok)
335
+ return result.error;
336
+ draft.acceptsCards = result.value;
337
+ return null;
338
+ }
331
339
  default:
332
- return `Field number must be between 1 and 13. Got: ${fieldNumber}.`;
340
+ return `Field number must be between 1 and 14. Got: ${fieldNumber}.`;
333
341
  }
334
342
  }
335
343
  /**
@@ -355,14 +363,15 @@ export async function confirmInputs(parsed, opts) {
355
363
  sendsEmail: parsed.sendsEmail,
356
364
  hasUserContent: parsed.hasUserContent,
357
365
  hasObservability: parsed.hasObservability,
366
+ acceptsCards: parsed.acceptsCards,
358
367
  customBrand: null,
359
368
  };
360
369
  while (true) {
361
370
  output.write(`\nInferred inputs from your brief:\n\n${renderDraft(draft)}\n\n`);
362
371
  const complete = isComplete(draft);
363
372
  const prompt = complete
364
- ? "Press Enter to accept, a line number (1-13) to edit, or 'cancel' to exit (Ctrl+C also works):"
365
- : "Type a line number (1-13) to fill or edit, or 'cancel' to exit (Ctrl+C also works). Every field must be set before accepting.";
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.";
366
375
  const reply = (await opts.prompter(prompt)).trim();
367
376
  if (CONFIRM_CANCEL_KEYWORDS.includes(reply.toLowerCase())) {
368
377
  throw new ConfirmCancelledError();
@@ -379,8 +388,8 @@ export async function confirmInputs(parsed, opts) {
379
388
  continue;
380
389
  }
381
390
  const fieldNumber = Number(reply);
382
- if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber > 13) {
383
- output.write(`\n ✗ "${reply}" is not a line number (1-13).\n`);
391
+ if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber > 14) {
392
+ output.write(`\n ✗ "${reply}" is not a line number (1-14).\n`);
384
393
  continue;
385
394
  }
386
395
  const error = await editField(draft, fieldNumber, opts);
@@ -402,6 +411,7 @@ export async function confirmInputs(parsed, opts) {
402
411
  sendsEmail: draft.sendsEmail,
403
412
  hasUserContent: draft.hasUserContent,
404
413
  hasObservability: draft.hasObservability,
414
+ acceptsCards: draft.acceptsCards,
405
415
  };
406
416
  if (draft.brand === "custom" && draft.customBrand !== null) {
407
417
  result.customBrand = draft.customBrand;
package/dist/index.d.ts CHANGED
@@ -139,6 +139,49 @@ export interface ScaffoldInputs {
139
139
  * an existing caller's output is unchanged.
140
140
  */
141
141
  hostRoutedTenancy?: boolean;
142
+ /**
143
+ * Whether this project will accept credit cards — a checkout, a donation
144
+ * form, a save-a-card / update-a-card surface, a subscription signup. Any
145
+ * project that will call `paymentIntents.create` or `setupIntents.create`,
146
+ * or confirm either in the browser.
147
+ *
148
+ * When `true` AND the type is `nextjs`, the scaffolder emits the card-path
149
+ * bot-protection shape rather than a bare endpoint: a Cloudflare Turnstile
150
+ * verifier, an abuse policy sized for card entry, the browser widget, and an
151
+ * emitted test that fails on the next unprotected card path. The standards
152
+ * resolver also inserts the "Card-path bot protection" standard pointing at
153
+ * [[stripe-elements-confirm-path]] §8.
154
+ *
155
+ * FOUR decisions are baked into what gets emitted, none of them cosmetic —
156
+ * settled 2026-08-07 with `z2w-seller-suite` on the coordination bulletin,
157
+ * against `z2w-crowdcommerce` v0.7.0 as the reference implementation:
158
+ *
159
+ * 1. **Invisible unless needed** (`appearance: "interaction-only"`). A
160
+ * scaffold that emits a *visible* challenge by default is actively
161
+ * harmful on a donation form — Kerry's explicit constraint.
162
+ * 2. **Limits sized for card entry, and no global cap.** 30 per 10 minutes
163
+ * per source, not the checkout's 5/60s: thirty people giving over one
164
+ * wifi NAT at a fundraising dinner is a good night, not an attack. A
165
+ * site-wide ceiling would convert going viral into an outage.
166
+ * 3. **A five-valued verdict that fails OPEN.** A boolean silently collapses
167
+ * "Cloudflare rejected this" into "we could not reach Cloudflare". This
168
+ * is the deliberate *opposite* of [[webhook-fail-closed]], and the two get
169
+ * conflated because they share the word "verify".
170
+ * 4. **The enumeration grep ships with the standard.** A standard that says
171
+ * "protect the card path" without saying how to *enumerate* card paths
172
+ * passes review and misses a route — `z2w-seller-suite` found 2 of 3 card
173
+ * paths bare in its own gateway by running exactly that grep.
174
+ *
175
+ * Kerry's directive, 2026-08-06: *"let's ensure that anywhere credit cards
176
+ * are accepted in our system we have turnstile enabled"* — widened by him
177
+ * the same day beyond any one plugin or project.
178
+ *
179
+ * Optional and defaults to `false` (nothing emitted). Honored only by the
180
+ * `nextjs` type today; the standard itself is inserted for any type that
181
+ * could plausibly take a card, so a Worker or WP plugin still gets told the
182
+ * rule even though this CLI cannot emit its code.
183
+ */
184
+ acceptsCards?: boolean;
142
185
  /** Present only when `brand === "custom"`. */
143
186
  customBrand?: CustomBrandInputs;
144
187
  /**
@@ -30,6 +30,12 @@ export interface ParsedBrief {
30
30
  * nextjs / cf-pages types downstream.
31
31
  */
32
32
  hasObservability: boolean;
33
+ /**
34
+ * Whether the project will accept credit cards. Not nullable — absent signal
35
+ * means `false` (nothing emitted), the safe default. Gates the card-path
36
+ * bot-protection standard and, for `nextjs`, the protected-endpoint shape.
37
+ */
38
+ acceptsCards: boolean;
33
39
  /** Free-text planning sections lifted verbatim from the brief, if any. */
34
40
  briefSections: BriefSections | undefined;
35
41
  raw: string;
@@ -481,6 +481,31 @@ 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 will accept credit cards. Defaults OFF like
486
+ * {@link inferSendsEmail} — emitting a Turnstile verifier, a widget and an
487
+ * enforcement test into a project that will never touch a card is noise.
488
+ *
489
+ * The positive signals are deliberately the PAYMENT PRIMITIVES rather than
490
+ * commerce vocabulary. "Store", "shop" and "products" describe a catalogue,
491
+ * which a project can have while checkout lives somewhere else entirely —
492
+ * exactly the `site-control` / `commerce-engine` split. What actually predicts
493
+ * a card path is a payment processor, a checkout/donation surface, or a
494
+ * subscription. A human still confirms on line 14.
495
+ */
496
+ function inferAcceptsCards(brief) {
497
+ const explicit = explicitBoolean(brief, [
498
+ "accepts credit cards",
499
+ "accept credit cards",
500
+ "accepts cards",
501
+ "accepts payments",
502
+ "takes payments",
503
+ ]);
504
+ if (explicit !== null)
505
+ return explicit;
506
+ const text = brief.toLowerCase();
507
+ return /\bstripe\b|\bpayment\s?intent|\bsetup\s?intent|\bcheckout\b|\bcredit\s?cards?\b|\bdonation|\bdonate\b|\bsubscription billing\b|\brecurring (payments?|billing|giving)\b|\bpaypal\b|\bpayment (gateway|processor|element)\b/.test(text);
508
+ }
484
509
  function inferParticipateInBulletin(brief, brand) {
485
510
  const text = brief.toLowerCase();
486
511
  if (/\bagent\s+coordination\b|\bbulletin\b/.test(text))
@@ -605,6 +630,7 @@ export function parseBrief(brief) {
605
630
  sendsEmail: false,
606
631
  hasUserContent: false,
607
632
  hasObservability: false,
633
+ acceptsCards: false,
608
634
  briefSections: undefined,
609
635
  raw: brief,
610
636
  };
@@ -626,6 +652,7 @@ export function parseBrief(brief) {
626
652
  sendsEmail: inferSendsEmail(trimmed),
627
653
  hasUserContent: inferHasUserContent(trimmed),
628
654
  hasObservability: inferHasObservability(trimmed, projectType, hasWebUi),
655
+ acceptsCards: inferAcceptsCards(trimmed),
629
656
  briefSections: extractBriefSections(trimmed),
630
657
  raw: brief,
631
658
  };
@@ -111,6 +111,17 @@ export declare const EMAIL_DEPS: Readonly<Record<string, string>>;
111
111
  * rather than trusting this comment.
112
112
  */
113
113
  export declare const SENTRY_DEPS: Readonly<Record<string, string>>;
114
+ /**
115
+ * The Neon serverless driver, added when a card-accepting project also has
116
+ * Postgres and therefore gets the shared-store rate limiter.
117
+ *
118
+ * The emitted limiter names this package directly rather than importing a
119
+ * `lib/db` the scaffold does not create — the Next.js scaffold ships no database
120
+ * layer at all, so a `@/lib/db` import would simply not compile. Bringing its own
121
+ * thin client also keeps the limiter working whichever ORM the project adopts
122
+ * later, since it never has to agree with one.
123
+ */
124
+ export declare const NEON_DRIVER_DEP: Readonly<Record<string, string>>;
114
125
  /**
115
126
  * The env-var block appended to a scaffolded `.env.example` when the project
116
127
  * sends email. Both providers' vars are stubbed so switching is a one-line env
@@ -1091,6 +1091,19 @@ export const SENTRY_DEPS = {
1091
1091
  "@sentry/core": "^10.69.0",
1092
1092
  "@sentry/nextjs": "^10.69.0",
1093
1093
  };
1094
+ /**
1095
+ * The Neon serverless driver, added when a card-accepting project also has
1096
+ * Postgres and therefore gets the shared-store rate limiter.
1097
+ *
1098
+ * The emitted limiter names this package directly rather than importing a
1099
+ * `lib/db` the scaffold does not create — the Next.js scaffold ships no database
1100
+ * layer at all, so a `@/lib/db` import would simply not compile. Bringing its own
1101
+ * thin client also keeps the limiter working whichever ORM the project adopts
1102
+ * later, since it never has to agree with one.
1103
+ */
1104
+ export const NEON_DRIVER_DEP = {
1105
+ "@neondatabase/serverless": "^1.0.2",
1106
+ };
1094
1107
  const EMAIL_MAILER_BODY = `// Transactional / auth email — provider router. Default provider: Amazon SES;
1095
1108
  // Resend is a swappable alternative selected with EMAIL_PROVIDER=resend.
1096
1109
  //