@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 +4 -3
- package/dist/confirm.d.ts +1 -0
- package/dist/confirm.js +16 -6
- package/dist/index.d.ts +43 -0
- package/dist/parse-brief.d.ts +6 -0
- package/dist/parse-brief.js +27 -0
- package/dist/scaffolders/common.d.ts +11 -0
- package/dist/scaffolders/common.js +13 -0
- package/dist/scaffolders/nextjs.js +1123 -6
- package/dist/standards.d.ts +1 -1
- package/dist/standards.js +73 -0
- package/dist/wizard.js +7 -0
- package/dist/writer.js +13 -0
- package/package.json +1 -1
package/dist/standards.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProjectType, ScaffoldInputs } from "./index.js";
|
|
2
2
|
import { type SubstitutionOptions } from "./substitute.js";
|
|
3
|
-
export type StandardKey = "skill-vault" | "portable-stack" | "fathom" | "uptime-kuma" | "sentry" | "neon-careful" | "temp-files" | "agent-coordination" | "seo-baseline" | "email-service" | "moderation" | "text-size" | "test-count";
|
|
3
|
+
export type StandardKey = "skill-vault" | "portable-stack" | "fathom" | "uptime-kuma" | "sentry" | "neon-careful" | "temp-files" | "agent-coordination" | "seo-baseline" | "email-service" | "moderation" | "card-path-bot-protection" | "text-size" | "test-count";
|
|
4
4
|
export type StandardDecisionState = "inserted-inline" | "skipped-not-applicable";
|
|
5
5
|
export interface StandardDecision {
|
|
6
6
|
key: StandardKey;
|
package/dist/standards.js
CHANGED
|
@@ -56,6 +56,7 @@ const STANDARD_ORDER = [
|
|
|
56
56
|
"seo-baseline",
|
|
57
57
|
"email-service",
|
|
58
58
|
"moderation",
|
|
59
|
+
"card-path-bot-protection",
|
|
59
60
|
"text-size",
|
|
60
61
|
"test-count",
|
|
61
62
|
];
|
|
@@ -71,6 +72,7 @@ const TITLES = {
|
|
|
71
72
|
"seo-baseline": "SEO baseline (non-WP web UI)",
|
|
72
73
|
"email-service": "Email service selection",
|
|
73
74
|
moderation: "Moderation baseline (user-generated content)",
|
|
75
|
+
"card-path-bot-protection": "Card-path bot protection (accepts credit cards)",
|
|
74
76
|
"text-size": "Text size (readability)",
|
|
75
77
|
"test-count": "Test-count reporting (session end)",
|
|
76
78
|
};
|
|
@@ -99,6 +101,12 @@ const NO_MODERATION_TYPES = [
|
|
|
99
101
|
"library",
|
|
100
102
|
"protocol-repo",
|
|
101
103
|
];
|
|
104
|
+
// Types with no runtime request surface, so no card-accepting endpoint can
|
|
105
|
+
// exist. Deliberately much SMALLER than the sets above: wp-plugin, cf-worker,
|
|
106
|
+
// cf-pages, node-service and python-service can all take a card, and the whole
|
|
107
|
+
// point of the standard is to reach the projects whose agents have not yet
|
|
108
|
+
// thought about payments. Only a CLI library and a spec repo are exempt.
|
|
109
|
+
const NO_CARD_PATH_TYPES = ["library", "protocol-repo"];
|
|
102
110
|
function checkPortableStack(inputs) {
|
|
103
111
|
if (inputs.projectType === "wp-plugin") {
|
|
104
112
|
return {
|
|
@@ -235,6 +243,39 @@ function checkModeration(inputs) {
|
|
|
235
243
|
reason: `hasUserContent=true on ${inputs.projectType} — two-layer moderation baseline per [[moderation-system]]`,
|
|
236
244
|
};
|
|
237
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* The card-path bot-protection standard applies on `acceptsCards`, and applies
|
|
248
|
+
* to EVERY project type — deliberately wider than the set this CLI can emit
|
|
249
|
+
* code for.
|
|
250
|
+
*
|
|
251
|
+
* A WordPress gateway and a Cloudflare Worker take cards too; `z2w-seller-suite`
|
|
252
|
+
* is the WP plugin whose retrofit produced the 2-of-3 measurement the body
|
|
253
|
+
* cites. Restricting the standard to `nextjs` (the only type whose protected
|
|
254
|
+
* shape we can scaffold) would mean the projects that most need to be told the
|
|
255
|
+
* rule are the ones never told it. The prose is the standard; the emitted code
|
|
256
|
+
* is a convenience `nextjs` happens to get.
|
|
257
|
+
*
|
|
258
|
+
* `library` and `protocol-repo` are excluded — no runtime request surface, so
|
|
259
|
+
* there is no endpoint to protect.
|
|
260
|
+
*/
|
|
261
|
+
function checkCardPathBotProtection(inputs) {
|
|
262
|
+
if (!inputs.acceptsCards) {
|
|
263
|
+
return {
|
|
264
|
+
applies: false,
|
|
265
|
+
reason: "acceptsCards=false — no card-accepting endpoint to protect",
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
if (NO_CARD_PATH_TYPES.includes(inputs.projectType)) {
|
|
269
|
+
return {
|
|
270
|
+
applies: false,
|
|
271
|
+
reason: `${inputs.projectType} has no runtime request surface — no card path to protect`,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
applies: true,
|
|
276
|
+
reason: `acceptsCards=true on ${inputs.projectType} — bot check + own rate limit on every card path per [[stripe-elements-confirm-path]] §8`,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
238
279
|
function checkTextSize() {
|
|
239
280
|
return { applies: true, reason: "Z2W standing org rule — applies to every project" };
|
|
240
281
|
}
|
|
@@ -586,6 +627,36 @@ const MODERATION_BODY = `### Moderation baseline (user-generated content)
|
|
|
586
627
|
> 5. **Optional pre-publish gate.** For content with a \`draft → published\` lifecycle, an unresolved flag blocks publish — turning the AI scan into a mandatory pre-publication gate.
|
|
587
628
|
>
|
|
588
629
|
> **Cross-app note:** for a future shared moderation package, map the tenant key at the boundary (event-engine keys on \`org_id\`, z2w-social on \`tenant_id\` — same idea, rename where they meet). See [[moderation-system]] for the data model, the coalescing pattern, the entity-resolver seam, and the verification checklist. Companion skills: [[async-action-feedback]] (the Report button + dashboard feedback), [[neon-postgres]] (run the scan out-of-band so it doesn't pin compute), [[per-tenant-credential-vault]] (where the scan API key lives long-term).`;
|
|
630
|
+
const CARD_PATH_BOT_PROTECTION_BODY = `### Card-path bot protection (accepts credit cards)
|
|
631
|
+
|
|
632
|
+
> **This project will accept credit cards, so every card-accepting endpoint carries a bot check AND its own rate limit — from the first one, not from the first incident.** Load [[stripe-elements-confirm-path]] §8 before writing any payment code. Cloudflare Turnstile is the sanctioned bot mitigation for the Z2W stack; never Akismet. Kerry's directive, 2026-08-06: *"let's ensure that anywhere credit cards are accepted in our system we have turnstile enabled"* — explicitly widened by him beyond any one project.
|
|
633
|
+
>
|
|
634
|
+
> **First, ENUMERATE the card paths by grep — never by eye.** This is the step that gets skipped, and skipping it is what a passing review looks like:
|
|
635
|
+
>
|
|
636
|
+
> \`\`\`
|
|
637
|
+
> paymentIntents.create setupIntents.create
|
|
638
|
+
> confirmSetup( confirmPayment(
|
|
639
|
+
> /payment_intents /setup_intents
|
|
640
|
+
> \`\`\`
|
|
641
|
+
>
|
|
642
|
+
> For each hit, assert that **both** a bot check and a rate limit exist **in that handler**. Measured 2026-08-06: a Z2W WooCommerce gateway had \`verify_turnstile()\` and \`is_rate_limited()\` implemented and called in **exactly one of three** card-accepting paths. The two bare ones were authenticated, nonce'd and ownership-checked — **none of which limits volume.** Authentication answers *who*, not *how many*. And the save-a-card path is the one that gets forgotten: \`setupIntents.create\` validates a card **without charging it**, which is precisely the primitive card-testing wants, and it leaves no failed-charge trail to notice.
|
|
643
|
+
>
|
|
644
|
+
> **On Next.js, a page-level gate does not cover a Server Action.** A Server Action is a publicly addressable POST endpoint, invocable without ever loading its page, and a route-shaped scan cannot even see an actions file. Each exported action re-takes its own checks — [[server-actions-are-public-endpoints]].
|
|
645
|
+
>
|
|
646
|
+
> **The pass condition is NOT "has a captcha".** A visible challenge on a checkout or donation form costs real conversions, so an audit that rewards mere presence makes things worse. Require all four:
|
|
647
|
+
>
|
|
648
|
+
> 1. **Invisible unless needed** — \`appearance: "interaction-only"\`. A bare \`<div class="cf-turnstile">\` renders a visible widget to every buyer. (The standalone "Invisible" widget *type* is deprecated; Managed vs Non-interactive is a Cloudflare dashboard setting, not markup.)
|
|
649
|
+
> 2. **Legible failure** — wire the \`error\` / \`timeout\` / \`expired\` callbacks. Left unwired, the widget silently never mints a token and the user gets a baffling refusal at submit with nothing to act on. Report them where someone will see them (Sentry on a non-WP app; an admin-visible counter on a WordPress checkout — do not load a third-party SDK onto the page where card details are entered).
|
|
650
|
+
> 3. **A limit SIZED for card entry, and no global cap.** Do not copy the checkout's limit: a budget tuned for order submission blocks a customer legitimately retrying a mistyped card. The reference default is **30 per 10 minutes per source** — because thirty people giving over one wifi NAT at a fundraising dinner is a good night, not an attack, and a per-minute limit turns the moment the campaign works into a wall of 429s. **No site-wide ceiling on a giving path**: it converts going viral into an outage. (Opposite call to a magic-link limiter, where a global cap *is* right — every send costs money and no burst of them is ever good news.)
|
|
651
|
+
> 4. **🔴 Fail OPEN, with a verdict that is not a boolean.** A captcha-provider outage must never stop payments. Keep \`pass\` / \`fail\` / \`degraded\` / \`no-token\` / \`unconfigured\` distinct: a boolean silently collapses *"Cloudflare rejected this"* into *"we could not reach Cloudflare"*, and only the first is evidence of a bot ([[zero-is-not-a-pass]]). Pair a non-\`pass\` verdict with a **tighter budget**, not a refusal — a **missing** token throttles harder than a failed one, because "no token → allow" makes the check optional at the attacker's discretion while "no token → refuse" hands a Cloudflare outage the power to stop your checkout. Your own rotated or typo'd secret must degrade too: that is the most tempting place to fail closed and the most wrong, since your mistake would refuse every payment with a message blaming the customer.
|
|
652
|
+
>
|
|
653
|
+
> **🔴 Point 4 is the deliberate OPPOSITE of [[webhook-fail-closed]], and the two get conflated because they share the word "verify".** A webhook signature governs **inbound authenticity** — an unsigned request is provably not from Stripe, so fail **closed**. A bot check governs **friction on a human** — an unreachable third party is not evidence of abuse, so fail **open**. Same word, opposite correct answer. Write that reasoning next to the code, or someone will "fix" one into the other, and a payment path that fails closed on a Cloudflare blip is an outage you inflicted on yourself.
|
|
654
|
+
>
|
|
655
|
+
> **An in-memory rate limiter's real ceiling is \`limit × instances\`.** On a serverless host that is not good enough for a money path — card-testing fans out, which is exactly what defeats per-instance state. Back the limit with a shared store ([[z2w-magic-link-auth]] §8.6.1). The shared store must **also** fail open and loudly: a limiter outage must not become a payment outage, but the caller has to be able to tell "checked, under the limit" from "could not check."
|
|
656
|
+
>
|
|
657
|
+
> **Turnstile tokens are SINGLE-USE** — siteverify consumes them — so reset the widget after every attempt, or the customer's second try comes back \`timeout-or-duplicate\` and reads as a bot. Tokens also expire after ~5 minutes, which any customer reading a page before paying will cross: refresh on \`expired\`, don't fail at submit.
|
|
658
|
+
>
|
|
659
|
+
> *Reference implementation: \`z2w-crowdcommerce\` v0.7.0 (2026-08-06), which has the reasoning written next to the code. Standard settled 2026-08-07 with \`z2w-seller-suite\`, whose own retrofit supplied the 2-of-3 measurement above.*`;
|
|
589
660
|
const TEXT_SIZE_BODY = `### Text size (always)
|
|
590
661
|
|
|
591
662
|
> **Readability:** per Z2W standing org rule, all public-facing pages and documents use large, easy-to-read type. Body text 18px+ baseline; headings proportionally larger; line-height ≥ 1.5.`;
|
|
@@ -610,6 +681,7 @@ const BODIES = {
|
|
|
610
681
|
"seo-baseline": SEO_BASELINE_BODY,
|
|
611
682
|
"email-service": EMAIL_SERVICE_BODY,
|
|
612
683
|
moderation: MODERATION_BODY,
|
|
684
|
+
"card-path-bot-protection": CARD_PATH_BOT_PROTECTION_BODY,
|
|
613
685
|
"text-size": TEXT_SIZE_BODY,
|
|
614
686
|
"test-count": TEST_COUNT_BODY,
|
|
615
687
|
};
|
|
@@ -625,6 +697,7 @@ const APPLICABILITY = {
|
|
|
625
697
|
"seo-baseline": checkSeoBaseline,
|
|
626
698
|
"email-service": checkEmailService,
|
|
627
699
|
moderation: checkModeration,
|
|
700
|
+
"card-path-bot-protection": checkCardPathBotProtection,
|
|
628
701
|
"text-size": checkTextSize,
|
|
629
702
|
"test-count": checkTestCount,
|
|
630
703
|
};
|
package/dist/wizard.js
CHANGED
|
@@ -156,6 +156,12 @@ export async function runWizard(opts) {
|
|
|
156
156
|
? "yes"
|
|
157
157
|
: "no";
|
|
158
158
|
const hasObservability = await askValidated(prompter, "8f. Wire Sentry runtime-error tracking (yes/no):", parseYesNo, observabilityDefault, out);
|
|
159
|
+
// Default NO. Unlike Sentry there is no type-based smart default worth
|
|
160
|
+
// guessing: "will this take a card" is a product decision the operator knows
|
|
161
|
+
// and the project type does not predict. Answering yes emits the protected
|
|
162
|
+
// card-path shape rather than leaving the first payment route bare — which is
|
|
163
|
+
// only cheap BEFORE the code exists ([[stripe-elements-confirm-path]] §8).
|
|
164
|
+
const acceptsCards = await askValidated(prompter, "8g. Will this project accept credit cards — checkout, donations, save-a-card (yes/no):", parseYesNo, "no", out);
|
|
159
165
|
const result = {
|
|
160
166
|
slug,
|
|
161
167
|
description,
|
|
@@ -170,6 +176,7 @@ export async function runWizard(opts) {
|
|
|
170
176
|
sendsEmail,
|
|
171
177
|
hasUserContent,
|
|
172
178
|
hasObservability,
|
|
179
|
+
acceptsCards,
|
|
173
180
|
};
|
|
174
181
|
if (customBrand) {
|
|
175
182
|
result.customBrand = customBrand;
|
package/dist/writer.js
CHANGED
|
@@ -427,6 +427,19 @@ export function parseScaffoldInputs(json) {
|
|
|
427
427
|
}
|
|
428
428
|
inputs.hostRoutedTenancy = obj["hostRoutedTenancy"];
|
|
429
429
|
}
|
|
430
|
+
// Optional: whether this project will accept credit cards. Defaults to false.
|
|
431
|
+
// When true, the nextjs scaffolder emits the protected card-path shape
|
|
432
|
+
// (Turnstile verifier + an abuse policy sized for card entry + the widget +
|
|
433
|
+
// an enforcement test) instead of leaving the first payment route bare, and
|
|
434
|
+
// the standards resolver inserts the card-path bot-protection standard.
|
|
435
|
+
// Kerry's 2026-08-06 directive; four design decisions settled with
|
|
436
|
+
// z2w-seller-suite on 2026-08-07. See [[stripe-elements-confirm-path]] §8.
|
|
437
|
+
if (obj["acceptsCards"] !== undefined) {
|
|
438
|
+
if (typeof obj["acceptsCards"] !== "boolean") {
|
|
439
|
+
throw new WriterError(`--input field "acceptsCards" must be a boolean, got ${typeof obj["acceptsCards"]}.`);
|
|
440
|
+
}
|
|
441
|
+
inputs.acceptsCards = obj["acceptsCards"];
|
|
442
|
+
}
|
|
430
443
|
// Optional: the verbatim instantiation prompt, recorded on the Airtable row.
|
|
431
444
|
// The --input path has no brief to capture, so callers may supply it here;
|
|
432
445
|
// when omitted, the Airtable write reminds the agent to add it by hand.
|