@zero2webmaster/starter-kit 0.19.1 → 0.23.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 +8 -4
- package/dist/audience.d.ts +108 -0
- package/dist/audience.js +132 -0
- package/dist/scaffolders/cf-pages.js +29 -1
- package/dist/scaffolders/common.d.ts +1 -1
- package/dist/scaffolders/common.js +20 -12
- package/dist/scaffolders/nextjs.js +733 -15
- package/dist/scaffolders/node-service.js +10 -7
- package/dist/scaffolders/pro-seo-extension.js +46 -4
- package/dist/scaffolders/python-service.js +3 -2
- package/dist/standards.d.ts +28 -1
- package/dist/summary.js +45 -2
- package/dist/writer.d.ts +14 -0
- package/dist/writer.js +53 -7
- package/package.json +1 -1
- package/scripts/rollup-integrations.mjs +107 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 0.
|
|
3
|
+
**Version:** 0.23.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,11 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
|
|
|
83
83
|
|
|
84
84
|
## Status
|
|
85
85
|
|
|
86
|
-
- **v0.
|
|
86
|
+
- **v0.23.0 (current)** 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.
|
|
87
|
+
- **v0.22.0** reshapes every emitted `.env.example` / `.env.local` so the line you came to fill in is the one you see. Kerry, 2026-08-16: the `# ── Database (Neon Postgres) ─────…` ruler *"is usually too long and therefore doesn't look like anything useful"*, and eighteen lines of explanation sat between the header and `DATABASE_URL=`. Headers are now a plain `# Database (Neon Postgres)`, and each block leads with its assignments and carries its prose directly underneath. **Per block rather than per file, which was Kerry's call between two readings of his own note** — collecting every variable at the top of the file would put the pooled-connection warning a screen away from the person about to paste the wrong connection string, and that warning only works where it is read. **Not a trim: every explanatory sentence survives, reworded and moved**, and there is a control test that unwraps the comment prose and asserts the load-bearing warnings are all still present, because a layout change is exactly where a paragraph goes missing unnoticed. Verified by loading the emitted file with Node's real dotenv parser — all 13 variables read back — not by grepping the template.
|
|
88
|
+
- **v0.21.0** makes the external audience gate say what actually went wrong. Its refusal named exactly one cause — *"a heading was probably renamed upstream"* — for a state that has two, and `project-creator`, the only consumer that resolves Templates from a version-**pinned** package rather than from Kerry's disk, hits the other one every time: at AGENTS v2.15.0 the `## Keeping This Framework Current` section simply did not exist yet, so every outside-brand scaffold refused in their production while they hunted a rename that never happened. Each gated section now declares the Templates version that first shipped it, the gate derives a minimum from those declarations, and the error distinguishes **version skew** (upgrade Templates) from **unexplained** (fix the section list). The throw is deliberately not softened. Same release: the standards decision log is now gate-aware — a standard whose whole section the gate removed reports `removed-by-audience-gate` instead of `inserted-inline`, because the old log let a preview UI tell an outside customer it had "Skill Vault awareness" in a file that no longer mentioned it; and a new `privateReferences` finding separates a surviving line that *instructs* the reader into the private Skill Vault from one that merely points at a missing section — one hit at Templates v2.18.0 and zero at v2.19.0, which removed that sentence upstream during the same session, demoting the finding into the milder dangling-reference class rather than making the check inert. No emitted file changes by a byte.
|
|
89
|
+
- **v0.20.0** emits `lib/csv-export.ts` and an enforcing `test/csv-export.test.ts` into **every** Next.js scaffold, with no capability flag. A CSV cell beginning `=`, `+`, `-` or `@` is evaluated as a formula by Excel and Google Sheets, so an unguarded export is code execution on the machine of whoever opens it — arriving through a file the app itself told them to download. A survey of 53 Z2W repos found 1 pass and 12 fail, and all 12 grew their export months after the project was scaffolded, which is why this one ships unconditionally rather than behind a flag: "this app will export CSV" is not knowable at scaffold time the way "this app takes cards" is. The emitted test greps for any file serving `text/csv` that skips the helper, so the guard survives the next person who adds an export. Same release: `scripts/rollup-integrations.mjs` now reads markdown tables and `**We CONSUME:**` headings, recovering 18 real dependency edges the ecosystem map had been missing, with none lost.
|
|
90
|
+
- **v0.19.1** emits a `:disabled` rule for **buttons** in `app/globals.css`, so a disabled button still looks disabled after the author gives buttons a brand fill. The scaffold ships no button styling of its own, so today the browser's grey rendering still applies — the trap opens on the author's first `background`/`color`, which overrides that grey and leaves `:disabled` a state with no appearance: the button looks pressable, the click does nothing, and the user concludes the app is broken. A sibling Z2W app shipped exactly that across ~50 screens behind a clean typecheck, a green build and 1,051 passing tests, because it is a rendered-pixel property no unit test holds. Includes the `:hover` cancel people forget — a `filter: brightness()` hover happily re-brightens a dimmed button at the moment the user is deciding to click. Verified on real pixels via CDP with `:hover` forced, and canary-verified by stripping the rule from a live scaffold.
|
|
87
91
|
- **v0.19.0** emits the **PWA baseline** for `nextjs` projects with a web UI — `public/manifest.json`, `public/icon.svg`, `public/sw.js` and `components/ServiceWorker.tsx`, wired into `app/layout.tsx` — so a scaffolded app installs on a phone. Three decisions run against the original design note and are documented in place: `app/icon.svg` is NOT emitted (a static icon file in that segment would silently retire the generated `app/icon.tsx` favicon), `theme_color` comes from the brand primary so it agrees with the layout's `viewport.themeColor`, and the glyph is a path rather than text because no font is guaranteed where the OS rasterises an icon. The service worker is network-first, never caches `/api/`, and evicts only its own cache prefix — that last clause fixed a real defect found by **executing** the emitted worker in tests rather than grepping it: an origin-wide sweep meant one Z2W app's deploy wiped a neighbouring app's offline cache under `/path` routing.
|
|
88
92
|
- **v0.18.4** points the writer's cross-cutting placeholder check at EVERY emitted file. It had run against `CLAUDE.md` alone since Step 6 — one of the ~42 files a Next.js scaffold emits — so `sentry.shared.ts` shipped a literal `{{project_name}}`, a key that has never existed in the substitution map. Found by dogfooding a real scaffold, not by the suite. A per-project-type sweep now covers all eight types.
|
|
89
93
|
- **v0.18.3** makes every emitted `.gitignore` refuse a downloaded cloud service-account key. The Google Cloud console names a private key `<project-id>-<12 hex>.json`, which matched nothing in the scaffolded ignore file and, unlike a stray `.env.production`, carries no hint in its filename that it is a credential. Found when a live Gmail delegation key for two SAVE THE FROGS! mailboxes landed in a repo this CLI had emitted.
|
|
@@ -95,7 +99,7 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
|
|
|
95
99
|
- **v0.17.1** stops `scripts/rollup-integrations.mjs` counting its own `*-archive.md` spill files in the "Bulletin files scanned" denominator (72 -> 52), and STATES the exclusion rather than silently shrinking the number.
|
|
96
100
|
- **v0.17.0** makes the **Cloud-Run-vs-Fly.io host choice a standard** for `python-service` / `node-service` scaffolds, so a long-running service's platform is decided by one test — *does it need a persistent volume?* — rather than per project by whoever is in the chair. Cloud Run for stateless request/response that scales to zero with the database elsewhere; Fly.io for stateful always-on needing a disk that survives a restart, which Cloud Run structurally cannot hold. It is a ruling rather than a preference because `z2w-multi-lingual-api` costed it on a live service (~13 req/hr inside a $2/month budget, because Cloud Run genuinely idles at zero), and it carries the half a new project would not think to ask for: **do not re-litigate this as a migration** — every real incident there traced to Neon's CU-hour cap or to secret hygiene, both external to *both* platforms. Deliberately NOT inserted for `cf-worker` / `cf-pages` / `nextjs`, whose host the project type already settles.
|
|
97
101
|
- **v0.16.2** fixes `--strict` so it judges only what the invocation actually reconciled, unblocking `z2w-agent-coordination`'s Project Registry reconciler cron.
|
|
98
|
-
- **v0.15.1
|
|
102
|
+
- **v0.15.1** ships `scripts/rollup-integrations.mjs` **in the npm tarball**, which is the one thing standing between the Project Registry reconciler and a schedule. `z2w-agent-coordination` accepted this project's proposal to host it on a cron and built the workflow, then found neither delivery route worked: a checkout of this private repo needs a PAT that could read every private repo in the org, and although the package *is* published, the tarball shipped **no `scripts/` at all** — `files` listed `dist/**` + README + LICENSE and the reconciler matched none of those globs. *"It is published"* and *"the script is reachable"* were two different facts. A runner can now `npm i @zero2webmaster/starter-kit@latest` and get it with **zero credentials**. Guarded by `src/package-contents.test.ts`, which runs `npm pack --dry-run --json` and asserts on the **artifact** rather than the glob — nothing here could previously tell a shipped file from an unshipped one.
|
|
99
103
|
- **v0.15.0** deletes the embedded Agent Coordination block in favour of a **pointer**, because this CLI is an *emitter* and a stale copy here is minted into every new Z2W project. `z2w-agent-coordination` measured currency across the ecosystem on 2026-08-07 and found **0 of 37 files at canonical** — 34 stale, 3 frozen paraphrases — and named "delete the copy, keep a pointer" its preferred remedy; the block had grown 4,274 B → 34,515 B in ten weeks, so every bump re-asked ~21 projects for a bigger paste. Scaffolded `CLAUDE.md` files now carry heading + fingerprint + session-start steps 1 and 1b (read the live block; it wins) + the Hard rules, and drop ~24 KB of auto-loaded context each. **The Hard rules stay embedded on purpose** — a leaked secret or an overwritten neighbour is irreversible, so those must hold even when the clone is unreachable. The old byte-diff guard was replaced rather than dropped (pointer conformance + an anti-regrowth byte ceiling, both canary-verified), and a real defect in it was fixed: it read a local bulletin checkout without ever checking that the checkout was current, and that clone was **215 commits behind**, so it compared against stale canon while reporting a shrinking gap.
|
|
100
104
|
- **v0.14.0** 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`.
|
|
101
105
|
- **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.
|
|
@@ -127,4 +131,4 @@ Inquiries: kerry@zero2webmaster.com.
|
|
|
127
131
|
---
|
|
128
132
|
|
|
129
133
|
*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.*
|
|
130
|
-
*Version: 0.
|
|
134
|
+
*Version: 0.23.0 | Last Updated: 2026-08-20*
|
package/dist/audience.d.ts
CHANGED
|
@@ -71,7 +71,66 @@ export declare const EXTERNAL_DROPPED_SECTIONS: readonly {
|
|
|
71
71
|
* suite, whose fixture contained all six sections (2026-08-14).
|
|
72
72
|
*/
|
|
73
73
|
readonly conditionallyPresent?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The canonical AGENTS body version that FIRST shipped this heading, for
|
|
76
|
+
* sections sourced from Templates rather than generated by this CLI.
|
|
77
|
+
*
|
|
78
|
+
* 🔴 **This exists because "absent" had two causes and the error named only
|
|
79
|
+
* one of them.** `project-creator` resolves Templates from a version-PINNED
|
|
80
|
+
* package while this CLI resolves it from Kerry's disk, so this repo never
|
|
81
|
+
* sees version skew and its first real consumer sees nothing else. Pinned at
|
|
82
|
+
* AGENTS v2.15.0, `## Keeping This Framework Current` simply did not exist
|
|
83
|
+
* yet — the gate threw, said *"a heading was probably renamed upstream"*, and
|
|
84
|
+
* sent them hunting a rename that never happened while every outside-brand
|
|
85
|
+
* scaffold refused in their production (filed 2026-08-19).
|
|
86
|
+
*
|
|
87
|
+
* Omitted for sections this CLI itself emits (`Standards block`,
|
|
88
|
+
* `Capture Learnings`, `Agent Coordination`) — those are spliced in from
|
|
89
|
+
* `src/standards.ts` markers and are present at every Templates version, so
|
|
90
|
+
* for them "absent" really can only mean the gate stopped matching.
|
|
91
|
+
*
|
|
92
|
+
* The throw is deliberately NOT softened. A section missing because the
|
|
93
|
+
* Templates source predates it is genuinely safe — the doctrine is not in the
|
|
94
|
+
* document to leak — but "safe" is not the same as "supported", and shipping a
|
|
95
|
+
* customer scaffold from a Templates version this gate was never written
|
|
96
|
+
* against is a claim nobody verified. It still refuses; it just now refuses
|
|
97
|
+
* with the true cause and an actionable fix.
|
|
98
|
+
*/
|
|
99
|
+
readonly sinceTemplatesVersion?: string;
|
|
74
100
|
}[];
|
|
101
|
+
/**
|
|
102
|
+
* The lowest canonical AGENTS body version this gate can serve — the highest
|
|
103
|
+
* `sinceTemplatesVersion` among the sections it must drop.
|
|
104
|
+
*
|
|
105
|
+
* Derived, never hand-written: adding a section sourced from a newer Templates
|
|
106
|
+
* body raises this automatically, so the declared floor cannot drift from the
|
|
107
|
+
* list it describes.
|
|
108
|
+
*/
|
|
109
|
+
export declare const GATE_MIN_TEMPLATES_VERSION: string;
|
|
110
|
+
/** Why a section the gate must drop was not found in the document. */
|
|
111
|
+
export type NotFoundCause = "version-skew" | "unexplained";
|
|
112
|
+
/** A section the gate had to drop and could not find, with the likely cause. */
|
|
113
|
+
export interface UnfoundSection {
|
|
114
|
+
readonly heading: string;
|
|
115
|
+
/**
|
|
116
|
+
* `version-skew` — the Templates body in use predates the heading, so the
|
|
117
|
+
* section is legitimately absent and the fix is upgrading the Templates
|
|
118
|
+
* source. `unexplained` — the heading should be there, so it was renamed
|
|
119
|
+
* upstream or the body changed shape, and the fix is `EXTERNAL_DROPPED_SECTIONS`.
|
|
120
|
+
*/
|
|
121
|
+
readonly cause: NotFoundCause;
|
|
122
|
+
/** Present only for `version-skew`: the version that first shipped the heading. */
|
|
123
|
+
readonly sinceTemplatesVersion?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Classify each not-found heading against the resolved Templates version.
|
|
127
|
+
*
|
|
128
|
+
* `templatesVersion` is the `X.Y.Z` parsed off the canonical `AGENTS_v*.md`
|
|
129
|
+
* filename — the same value that fills `{{framework_version}}`. Pass `undefined`
|
|
130
|
+
* when it genuinely is not known; every finding then reads `unexplained`, which
|
|
131
|
+
* is the pre-existing behaviour and the safe direction to fail in.
|
|
132
|
+
*/
|
|
133
|
+
export declare function classifyUnfoundSections(notFound: readonly string[], templatesVersion: string | undefined): UnfoundSection[];
|
|
75
134
|
/** What {@link gateSectionsForAudience} did, so callers can report rather than guess. */
|
|
76
135
|
export interface AudienceGateResult {
|
|
77
136
|
/** The gated document. */
|
|
@@ -107,6 +166,37 @@ export interface AudienceGateResult {
|
|
|
107
166
|
/** 1-indexed line number in the GATED document. */
|
|
108
167
|
readonly line: number;
|
|
109
168
|
}[];
|
|
169
|
+
/**
|
|
170
|
+
* Surviving lines that INSTRUCT the reader to use a private Z2W resource.
|
|
171
|
+
*
|
|
172
|
+
* 🔴 **A different class from {@link danglingReferences}, and worse.** A
|
|
173
|
+
* dangling reference points at a section that is not there — the reader
|
|
174
|
+
* follows it, finds nothing, shrugs. A private reference tells them to *go do
|
|
175
|
+
* something* in a library they cannot open: `## Self-annealing loop` still
|
|
176
|
+
* says *"capture it in the Skill Vault"*, which is the same class as the
|
|
177
|
+
* private-bulletin-repo leak v0.16.0 fixed rather than mere disclosure.
|
|
178
|
+
* Naming a skill in passing is the accepted posture; instructing someone into
|
|
179
|
+
* the Vault is not. (Filed by `project-creator` 2026-08-19, who ranked this
|
|
180
|
+
* the one worth prioritising out of 12 residual files.)
|
|
181
|
+
*
|
|
182
|
+
* **Reported, never auto-edited**, for the same reason as the rest of this
|
|
183
|
+
* module: the sentence lives inside the canonical AGENTS body, and a body
|
|
184
|
+
* emitted with sentences quietly altered still carries a fingerprint claiming
|
|
185
|
+
* it is canonical. The durable fix is upstream in `cursor-project-templates`;
|
|
186
|
+
* this makes the residual visible instead of silent in the meantime.
|
|
187
|
+
*
|
|
188
|
+
* Measured on a real customer-shaped `nextjs` scaffold against Templates
|
|
189
|
+
* v2.18.0 (2026-08-20): **exactly one hit across all 42 emitted files**, so
|
|
190
|
+
* this does not cry wolf.
|
|
191
|
+
*/
|
|
192
|
+
readonly privateReferences: readonly {
|
|
193
|
+
/** The private resource named, e.g. `"Skill Vault"`. */
|
|
194
|
+
readonly resource: string;
|
|
195
|
+
/** 1-indexed line number in the GATED document. */
|
|
196
|
+
readonly line: number;
|
|
197
|
+
/** The surviving line, trimmed, so a consumer can show it without re-reading the file. */
|
|
198
|
+
readonly text: string;
|
|
199
|
+
}[];
|
|
110
200
|
}
|
|
111
201
|
/**
|
|
112
202
|
* Remove whole `## ` sections from an assembled `CLAUDE.md` for an external
|
|
@@ -121,6 +211,24 @@ export interface AudienceGateResult {
|
|
|
121
211
|
* `z2w-agent-coordination` hit in their own section tooling on 2026-08-13.
|
|
122
212
|
*/
|
|
123
213
|
export declare function gateSectionsForAudience(content: string, audience: Audience): AudienceGateResult;
|
|
214
|
+
/**
|
|
215
|
+
* Re-state the standards decision log against what the audience gate actually
|
|
216
|
+
* removed, so a consumer rendering that log cannot claim a standard is in a
|
|
217
|
+
* file the gate emptied of it.
|
|
218
|
+
*
|
|
219
|
+
* Driven by the gate's own `dropped` array rather than by `audience` — if the
|
|
220
|
+
* gate did not remove the section (an external scaffold with
|
|
221
|
+
* `participateInBulletin: false` never has an `## Agent Coordination` section
|
|
222
|
+
* to drop), the decision is left exactly as the resolver wrote it.
|
|
223
|
+
*
|
|
224
|
+
* Pure and total: returns a new array, never mutates, and is a no-op when
|
|
225
|
+
* `dropped` is empty — which is every `internal` scaffold.
|
|
226
|
+
*/
|
|
227
|
+
export declare function applyGateToDecisions<D extends {
|
|
228
|
+
key: string;
|
|
229
|
+
state: string;
|
|
230
|
+
reason: string;
|
|
231
|
+
}>(decisions: readonly D[], dropped: readonly string[]): D[];
|
|
124
232
|
/**
|
|
125
233
|
* Rewrite `[[skill-name]]` Vault pointers into plain text.
|
|
126
234
|
*
|
package/dist/audience.js
CHANGED
|
@@ -61,6 +61,8 @@ export const EXTERNAL_DROPPED_SECTIONS = [
|
|
|
61
61
|
{
|
|
62
62
|
heading: "Z2W Portfolio Standards",
|
|
63
63
|
why: "a pointer index into a private Skill Vault the reader cannot open",
|
|
64
|
+
// Folded into the general + WP bodies 2026-06-23 (FRAMEWORK_HISTORY #28).
|
|
65
|
+
sinceTemplatesVersion: "2.13.0",
|
|
64
66
|
},
|
|
65
67
|
{
|
|
66
68
|
heading: "Standards block",
|
|
@@ -73,10 +75,15 @@ export const EXTERNAL_DROPPED_SECTIONS = [
|
|
|
73
75
|
{
|
|
74
76
|
heading: "Keeping This Framework Current",
|
|
75
77
|
why: "a fingerprint-currency table naming private Z2W repos, meaningless outside the ecosystem",
|
|
78
|
+
// Introduced by AGENTS v2.17.0 / WP v3.5.0 (Templates `2b33d45`). This is
|
|
79
|
+
// the entry that sets GATE_MIN_TEMPLATES_VERSION.
|
|
80
|
+
sinceTemplatesVersion: "2.17.0",
|
|
76
81
|
},
|
|
77
82
|
{
|
|
78
83
|
heading: "Common Name & Terminology Glossary",
|
|
79
84
|
why: "internal vocabulary and Z2W brand spellings; reseeded from the customer's own brandNameRule instead",
|
|
85
|
+
// Added by AGENTS v2.6.0 (Templates `8a34391`).
|
|
86
|
+
sinceTemplatesVersion: "2.6.0",
|
|
80
87
|
},
|
|
81
88
|
{
|
|
82
89
|
heading: "Agent Coordination",
|
|
@@ -86,6 +93,53 @@ export const EXTERNAL_DROPPED_SECTIONS = [
|
|
|
86
93
|
conditionallyPresent: true,
|
|
87
94
|
},
|
|
88
95
|
];
|
|
96
|
+
/**
|
|
97
|
+
* Compare two `X.Y.Z` strings numerically. Returns <0, 0, >0 like a comparator.
|
|
98
|
+
*
|
|
99
|
+
* Numeric per component, never lexicographic: `"2.9.0" > "2.17.0"` is true as
|
|
100
|
+
* strings and false as versions, and this gate's whole job hinges on getting
|
|
101
|
+
* that comparison right.
|
|
102
|
+
*/
|
|
103
|
+
function compareSemver(a, b) {
|
|
104
|
+
const pa = a.split(".").map((n) => Number.parseInt(n, 10));
|
|
105
|
+
const pb = b.split(".").map((n) => Number.parseInt(n, 10));
|
|
106
|
+
for (let i = 0; i < 3; i++) {
|
|
107
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
108
|
+
if (d !== 0)
|
|
109
|
+
return d;
|
|
110
|
+
}
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The lowest canonical AGENTS body version this gate can serve — the highest
|
|
115
|
+
* `sinceTemplatesVersion` among the sections it must drop.
|
|
116
|
+
*
|
|
117
|
+
* Derived, never hand-written: adding a section sourced from a newer Templates
|
|
118
|
+
* body raises this automatically, so the declared floor cannot drift from the
|
|
119
|
+
* list it describes.
|
|
120
|
+
*/
|
|
121
|
+
export const GATE_MIN_TEMPLATES_VERSION = EXTERNAL_DROPPED_SECTIONS.reduce((max, s) => s.sinceTemplatesVersion && compareSemver(s.sinceTemplatesVersion, max) > 0
|
|
122
|
+
? s.sinceTemplatesVersion
|
|
123
|
+
: max, "0.0.0");
|
|
124
|
+
/**
|
|
125
|
+
* Classify each not-found heading against the resolved Templates version.
|
|
126
|
+
*
|
|
127
|
+
* `templatesVersion` is the `X.Y.Z` parsed off the canonical `AGENTS_v*.md`
|
|
128
|
+
* filename — the same value that fills `{{framework_version}}`. Pass `undefined`
|
|
129
|
+
* when it genuinely is not known; every finding then reads `unexplained`, which
|
|
130
|
+
* is the pre-existing behaviour and the safe direction to fail in.
|
|
131
|
+
*/
|
|
132
|
+
export function classifyUnfoundSections(notFound, templatesVersion) {
|
|
133
|
+
return notFound.map((heading) => {
|
|
134
|
+
const since = EXTERNAL_DROPPED_SECTIONS.find((s) => s.heading === heading)?.sinceTemplatesVersion;
|
|
135
|
+
if (since !== undefined &&
|
|
136
|
+
templatesVersion !== undefined &&
|
|
137
|
+
compareSemver(templatesVersion, since) < 0) {
|
|
138
|
+
return { heading, cause: "version-skew", sinceTemplatesVersion: since };
|
|
139
|
+
}
|
|
140
|
+
return { heading, cause: "unexplained" };
|
|
141
|
+
});
|
|
142
|
+
}
|
|
89
143
|
/** Normalise a `## ` heading line to its comparable text. */
|
|
90
144
|
function headingText(line) {
|
|
91
145
|
return line.replace(/^##\s+/, "").trim();
|
|
@@ -102,6 +156,26 @@ function matchesHeading(line, heading) {
|
|
|
102
156
|
const text = headingText(line);
|
|
103
157
|
return text === heading || text.startsWith(heading + " ") || text.startsWith(heading + " (");
|
|
104
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Private Z2W resources whose NAME surviving is disclosure (accepted) but whose
|
|
161
|
+
* appearance in an INSTRUCTION is a leak (reported).
|
|
162
|
+
*
|
|
163
|
+
* Deliberately a short, closed list of things an outside reader genuinely
|
|
164
|
+
* cannot reach. It is not a general secret-scanner — the emitted `.env.example`
|
|
165
|
+
* and the CSV guard both mention plenty of internal-sounding names that are
|
|
166
|
+
* simply names.
|
|
167
|
+
*/
|
|
168
|
+
const PRIVATE_RESOURCES = [
|
|
169
|
+
{ resource: "Skill Vault", re: /\bSkill Vault\b/ },
|
|
170
|
+
{ resource: "the coordination bulletin repo", re: /zero2webmaster\/z2w-agent-coordination/ },
|
|
171
|
+
{ resource: "the local skills symlink tree", re: /[~.]\/\.(claude|cursor)\/skills/ },
|
|
172
|
+
];
|
|
173
|
+
/**
|
|
174
|
+
* Verbs that turn a mention into an instruction. Without this the check fires on
|
|
175
|
+
* the `## Z2W Portfolio Standards` preamble's *"the canonical text lives in the
|
|
176
|
+
* Skill Vault"* — a statement of fact, and a section the gate drops anyway.
|
|
177
|
+
*/
|
|
178
|
+
const INSTRUCTION_RE = /\b(capture|add|extend|load|open|read|check|update|see|consult|follow|put|write|file|store) (it|them|this|the|a|an|your|into|in) /i;
|
|
105
179
|
/**
|
|
106
180
|
* Remove whole `## ` sections from an assembled `CLAUDE.md` for an external
|
|
107
181
|
* audience. A no-op for `internal`, byte-for-byte.
|
|
@@ -122,6 +196,7 @@ export function gateSectionsForAudience(content, audience) {
|
|
|
122
196
|
notFound: [],
|
|
123
197
|
bytesDropped: 0,
|
|
124
198
|
danglingReferences: [],
|
|
199
|
+
privateReferences: [],
|
|
125
200
|
};
|
|
126
201
|
}
|
|
127
202
|
const lines = content.split("\n");
|
|
@@ -180,14 +255,71 @@ export function gateSectionsForAudience(content, audience) {
|
|
|
180
255
|
}
|
|
181
256
|
}
|
|
182
257
|
}
|
|
258
|
+
// Scan what SURVIVED for INSTRUCTIONS into a private Z2W resource — a
|
|
259
|
+
// separate, worse class than a dangling reference (see `privateReferences`).
|
|
260
|
+
const privateReferences = [];
|
|
261
|
+
for (let i = 0; i < outLines.length; i++) {
|
|
262
|
+
const line = outLines[i];
|
|
263
|
+
if (!INSTRUCTION_RE.test(line))
|
|
264
|
+
continue;
|
|
265
|
+
for (const { resource, re } of PRIVATE_RESOURCES) {
|
|
266
|
+
if (re.test(line)) {
|
|
267
|
+
privateReferences.push({ resource, line: i + 1, text: line.trim() });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
183
271
|
return {
|
|
184
272
|
content: out,
|
|
185
273
|
dropped,
|
|
186
274
|
notFound,
|
|
187
275
|
bytesDropped: content.length - out.length,
|
|
188
276
|
danglingReferences,
|
|
277
|
+
privateReferences,
|
|
189
278
|
};
|
|
190
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* The `## ` section each standard's rendered text ends up inside.
|
|
282
|
+
*
|
|
283
|
+
* Mirrors `resolveStandards()`: `agent-coordination` is spliced into its own
|
|
284
|
+
* top-level section via a separate marker so it can carry the canonical
|
|
285
|
+
* fingerprint verbatim; every other standard lands inline in `## Standards
|
|
286
|
+
* block`. Two destinations, both of which the external gate drops.
|
|
287
|
+
*/
|
|
288
|
+
function sectionHoldingStandard(key) {
|
|
289
|
+
return key === "agent-coordination" ? "Agent Coordination" : "Standards block";
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Re-state the standards decision log against what the audience gate actually
|
|
293
|
+
* removed, so a consumer rendering that log cannot claim a standard is in a
|
|
294
|
+
* file the gate emptied of it.
|
|
295
|
+
*
|
|
296
|
+
* Driven by the gate's own `dropped` array rather than by `audience` — if the
|
|
297
|
+
* gate did not remove the section (an external scaffold with
|
|
298
|
+
* `participateInBulletin: false` never has an `## Agent Coordination` section
|
|
299
|
+
* to drop), the decision is left exactly as the resolver wrote it.
|
|
300
|
+
*
|
|
301
|
+
* Pure and total: returns a new array, never mutates, and is a no-op when
|
|
302
|
+
* `dropped` is empty — which is every `internal` scaffold.
|
|
303
|
+
*/
|
|
304
|
+
export function applyGateToDecisions(decisions, dropped) {
|
|
305
|
+
if (dropped.length === 0)
|
|
306
|
+
return [...decisions];
|
|
307
|
+
const droppedSet = new Set(dropped);
|
|
308
|
+
return decisions.map((d) => {
|
|
309
|
+
if (d.state !== "inserted-inline")
|
|
310
|
+
return { ...d };
|
|
311
|
+
const section = sectionHoldingStandard(d.key);
|
|
312
|
+
if (!droppedSet.has(section))
|
|
313
|
+
return { ...d };
|
|
314
|
+
return {
|
|
315
|
+
...d,
|
|
316
|
+
state: "removed-by-audience-gate",
|
|
317
|
+
reason: `${d.reason} — then removed: audience="external" drops the whole ` +
|
|
318
|
+
`\`## ${section}\` section, so this standard's text is NOT in the emitted CLAUDE.md.`,
|
|
319
|
+
removedFromSection: section,
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
}
|
|
191
323
|
/**
|
|
192
324
|
* Rewrite `[[skill-name]]` Vault pointers into plain text.
|
|
193
325
|
*
|
|
@@ -166,9 +166,37 @@ const HEADERS_TEMPLATE = `# Cloudflare Pages headers for {{slug}}.
|
|
|
166
166
|
# Production (live domain): no special header — sitemap + robots.txt govern.
|
|
167
167
|
# Preview deploys (*.pages.dev): noindex.
|
|
168
168
|
|
|
169
|
+
# ── The five-header baseline ─────────────────────────────────────────────
|
|
170
|
+
# Measured by \`audit-engine\` on 2026-08-20: 22 of 26 reachable Z2W surfaces
|
|
171
|
+
# carried NONE of these. They are config-only and none of them can break
|
|
172
|
+
# rendering, so there is no reason for a new site to ship without them.
|
|
173
|
+
#
|
|
174
|
+
# X-Frame-Options is DENY here, not SAMEORIGIN. A brochure site has no reason
|
|
175
|
+
# to frame itself, and DENY is what pairs with \`frame-ancestors 'none'\` below
|
|
176
|
+
# — the two say the same thing to two generations of browser, and shipping one
|
|
177
|
+
# without the other is a silent downgrade on whichever half you dropped. If
|
|
178
|
+
# this site genuinely needs to be embedded, change BOTH.
|
|
179
|
+
#
|
|
180
|
+
# The CSP is ENFORCING rather than Report-Only, which is a deliberate
|
|
181
|
+
# deviation from [[web-security-headers]]. That skill's two-wave rule protects
|
|
182
|
+
# a LIVE app being retrofitted, where a wrong directive is an outage. This site
|
|
183
|
+
# has never been deployed and every origin below is one this scaffold actually
|
|
184
|
+
# emits: Fathom's script, and nothing else. \`'unsafe-inline'\` covers the inline
|
|
185
|
+
# <style> block and the inline JSON-LD block that index.html ships.
|
|
186
|
+
#
|
|
187
|
+
# 🔴 If you add an external script, font, style or beacon, the browser console
|
|
188
|
+
# names the directive that blocked it — add the origin here rather than
|
|
189
|
+
# deleting the policy. To debug a stubborn one, temporarily rename the header
|
|
190
|
+
# to Content-Security-Policy-Report-Only, reproduce, read the console, and put
|
|
191
|
+
# it back. Verify a deploy at https://securityheaders.com.
|
|
192
|
+
|
|
169
193
|
/*
|
|
170
|
-
|
|
194
|
+
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
|
|
195
|
+
X-Content-Type-Options: nosniff
|
|
196
|
+
X-Frame-Options: DENY
|
|
171
197
|
Referrer-Policy: strict-origin-when-cross-origin
|
|
198
|
+
Permissions-Policy: camera=(), microphone=(), geolocation=(), interest-cohort=()
|
|
199
|
+
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.usefathom.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'self' https://cdn.usefathom.com; form-action 'self'; frame-ancestors 'none'; base-uri 'self'; object-src 'none'
|
|
172
200
|
|
|
173
201
|
https://*.pages.dev/*
|
|
174
202
|
X-Robots-Tag: noindex, nofollow
|
|
@@ -133,7 +133,7 @@ export declare const NEON_DRIVER_DEP: Readonly<Record<string, string>>;
|
|
|
133
133
|
* sends email. Both providers' vars are stubbed so switching is a one-line env
|
|
134
134
|
* change with no code edit.
|
|
135
135
|
*/
|
|
136
|
-
export declare const EMAIL_ENV_BLOCK = "\n#
|
|
136
|
+
export declare const EMAIL_ENV_BLOCK = "\n# Transactional / auth email\n\nEMAIL_PROVIDER=ses\nSES_REGION=\nSES_ACCESS_KEY_ID=\nSES_SECRET_ACCESS_KEY=\nAWS_SES_FROM=\n\n# Only read when EMAIL_PROVIDER=resend:\nRESEND_API_KEY=\nRESEND_FROM=\n\n# Wiring: lib/email/mailer.ts. Setup: directives/email-setup.md +\n# [[email-service-router]]. Until the four SES_ vars are set every send is a\n# logged no-op, so the app works and only delivery is deferred.\n#\n# EMAIL_PROVIDER \u2014 \"ses\" (default) or \"resend\". Switching is this one line; no\n# code change at any call site.\n#\n# SES_* \u2014 the custom prefix and the explicit credentials are deliberate. On\n# Vercel/Lambda the platform injects its own AWS_* vars, which would shadow the\n# default credential chain. SES_REGION MUST equal the region the sender domain\n# is verified in, or sends fail with \"Email address is not verified\".\n#\n# AWS_SES_FROM \u2014 a domain-verified identity can send from any local-part.\n# Format: \"Brand Name <sender@yourdomain.com>\". Never noreply@.\n#\n# RESEND_FROM \u2014 must be on a Resend-verified domain.\n";
|
|
137
137
|
/**
|
|
138
138
|
* Build the email-wiring files for a scaffold that sends email. \`layout\`
|
|
139
139
|
* selects the file paths + whether a vitest test is emitted:
|
|
@@ -1377,26 +1377,34 @@ describe("selectProvider", () => {
|
|
|
1377
1377
|
* change with no code edit.
|
|
1378
1378
|
*/
|
|
1379
1379
|
export const EMAIL_ENV_BLOCK = `
|
|
1380
|
-
#
|
|
1381
|
-
# Provider router. Default: Amazon SES. Set to "resend" to use Resend instead —
|
|
1382
|
-
# no code change. See directives/email-setup.md + [[email-service-router]].
|
|
1383
|
-
EMAIL_PROVIDER=ses
|
|
1380
|
+
# Transactional / auth email
|
|
1384
1381
|
|
|
1385
|
-
|
|
1386
|
-
# Vercel/Lambda the platform injects its own AWS_* that would shadow the default
|
|
1387
|
-
# credential chain. SES_REGION MUST equal the region the sender domain is
|
|
1388
|
-
# verified in, or sends fail with "Email address is not verified".
|
|
1382
|
+
EMAIL_PROVIDER=ses
|
|
1389
1383
|
SES_REGION=
|
|
1390
1384
|
SES_ACCESS_KEY_ID=
|
|
1391
1385
|
SES_SECRET_ACCESS_KEY=
|
|
1392
|
-
# From address. A domain-verified identity can send from any local-part.
|
|
1393
|
-
# Format: "Brand Name <sender@yourdomain.com>". Never noreply@.
|
|
1394
1386
|
AWS_SES_FROM=
|
|
1395
1387
|
|
|
1396
|
-
#
|
|
1397
|
-
# RESEND_FROM must be on a Resend-verified domain.
|
|
1388
|
+
# Only read when EMAIL_PROVIDER=resend:
|
|
1398
1389
|
RESEND_API_KEY=
|
|
1399
1390
|
RESEND_FROM=
|
|
1391
|
+
|
|
1392
|
+
# Wiring: lib/email/mailer.ts. Setup: directives/email-setup.md +
|
|
1393
|
+
# [[email-service-router]]. Until the four SES_ vars are set every send is a
|
|
1394
|
+
# logged no-op, so the app works and only delivery is deferred.
|
|
1395
|
+
#
|
|
1396
|
+
# EMAIL_PROVIDER — "ses" (default) or "resend". Switching is this one line; no
|
|
1397
|
+
# code change at any call site.
|
|
1398
|
+
#
|
|
1399
|
+
# SES_* — the custom prefix and the explicit credentials are deliberate. On
|
|
1400
|
+
# Vercel/Lambda the platform injects its own AWS_* vars, which would shadow the
|
|
1401
|
+
# default credential chain. SES_REGION MUST equal the region the sender domain
|
|
1402
|
+
# is verified in, or sends fail with "Email address is not verified".
|
|
1403
|
+
#
|
|
1404
|
+
# AWS_SES_FROM — a domain-verified identity can send from any local-part.
|
|
1405
|
+
# Format: "Brand Name <sender@yourdomain.com>". Never noreply@.
|
|
1406
|
+
#
|
|
1407
|
+
# RESEND_FROM — must be on a Resend-verified domain.
|
|
1400
1408
|
`;
|
|
1401
1409
|
const EMAIL_SETUP_DIRECTIVE = `# Directive — Wire transactional / auth email for {{slug}}
|
|
1402
1410
|
|