@zero2webmaster/starter-kit 0.9.2 → 0.9.4

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.9.2 | **Framework:** 2.13.0
3
+ **Version:** 0.9.4 | **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,9 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
83
83
 
84
84
  ## Status
85
85
 
86
- - **v0.9.2 (current)** 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 `*`.
86
+ - **v0.9.4 (current)** 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`.
87
+ - **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.
88
+ - **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 `*`.
87
89
  - **v0.8.0 (published)** emits the canonical Capture Learnings block into every scaffolded `CLAUDE.md`, so the session-end "should this become a skill?" step actually reaches the agent working in the new project.
88
90
  - **v0.7.0** added `lib/seo/page-metadata.ts` — a `pageMetadata()` helper that returns a complete `openGraph` + `twitter` object every time. Next.js merges metadata *shallowly per top-level key*, so a page that hand-writes a partial `openGraph` silently drops `og:type`, `og:site_name` and `og:image` and downgrades its Twitter card.
89
91
  - **v0.6.0** shipped the magic-link `CANONICAL_HOSTS` seam, a shared `lib/seo/canonical-host.mjs` so `robots.ts` and the Vercel alias redirect cannot disagree, and a `404`-on-unmapped-Host guard for Host-routed multi-tenant apps.
@@ -109,4 +111,4 @@ Inquiries: kerry@zero2webmaster.com.
109
111
  ---
110
112
 
111
113
  *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.*
112
- *Version: 0.9.2 | Last Updated: 2026-08-02*
114
+ *Version: 0.9.4 | Last Updated: 2026-08-03*
package/dist/brand.d.ts CHANGED
@@ -16,11 +16,28 @@ export interface BrandPresetSpec {
16
16
  typographyRule: string;
17
17
  domains: readonly string[];
18
18
  /**
19
- * Default GitHub org for `gh repo create`. `null` for `custom` (caller must
20
- * supply explicitly). Internal Z2W brands map to `zero2webmaster`; STF maps
21
- * to `savethefrogs`; Bansuri Bliss maps to `bansuribliss`.
19
+ * Default GitHub repo OWNER for `gh repo create`. `null` for `custom` (caller
20
+ * must supply explicitly). Internal Z2W brands map to `zero2webmaster`; STF
21
+ * maps to `savethefrogs`; Bansuri Bliss maps to `bansuribliss`.
22
+ *
23
+ * Named `githubOrg` for backward compatibility with existing briefs and
24
+ * `--input` files, which spell the field `GitHub org:`. **The value is an
25
+ * account name, not necessarily an Organization** — see `accountType`.
22
26
  */
23
27
  githubOrg: string | null;
28
+ /**
29
+ * Whether `githubOrg` names a GitHub **User** account or an **Organization**.
30
+ *
31
+ * Load-bearing, not trivia. Every account in Kerry's portfolio is a `User`
32
+ * (verified 2026-08-02: `gh api users/<name> --jq .type` returns `User` for
33
+ * `zero2webmaster`, `savethefrogs`, `bansuribliss` and `kerrykriger`, and
34
+ * `gh api user/orgs` is empty — there is no Organization anywhere). The
35
+ * emitted brand block used to say "GitHub org default", which sent two
36
+ * different agents to `/organizations/...` 404s inside five days while
37
+ * setting up a GitHub App and a webhook. `"unknown"` is the honest answer
38
+ * for a caller-supplied owner we have not checked.
39
+ */
40
+ accountType: "user" | "organization" | "unknown";
24
41
  author: string;
25
42
  authorUrl: string;
26
43
  /** Additional brand colors beyond primary + accent (purple, gold, ...). */
@@ -50,8 +67,12 @@ export declare const BRAND_PRESETS: Readonly<Record<Exclude<BrandPreset, "custom
50
67
  *
51
68
  * Per [[instantiate-z2w-project]] SKILL.md, `custom` is never persisted back
52
69
  * into the skill — one-offs aren't presets. The typography rule defaults to
53
- * the Z2W standing org rule, and GitHub org defaults to `null` (caller must
54
- * set it explicitly via the GitHub org input).
70
+ * the Z2W standing org rule, and the GitHub owner defaults to `null` (caller
71
+ * must set it explicitly via the GitHub owner input).
72
+ *
73
+ * `accountType` is deliberately `"unknown"`: a caller-supplied owner has not
74
+ * been checked, and claiming either type would be a guess the emitted docs
75
+ * would then state as fact. The emitted block tells the reader how to check.
55
76
  */
56
77
  export declare function buildCustomBrandSpec(inputs: CustomBrandInputs, githubOrg?: string | null): BrandPresetSpec;
57
78
  /**
package/dist/brand.js CHANGED
@@ -32,6 +32,7 @@ export const SAVE_THE_FROGS_PRESET = {
32
32
  "amphibianweek.org",
33
33
  ],
34
34
  githubOrg: "savethefrogs",
35
+ accountType: "user",
35
36
  author: DEFAULT_AUTHOR,
36
37
  authorUrl: DEFAULT_AUTHOR_URL,
37
38
  extras: [
@@ -57,6 +58,7 @@ export const BANSURI_BLISS_PRESET = {
57
58
  typographyRule: "",
58
59
  domains: ["bansuribliss.com"],
59
60
  githubOrg: "bansuribliss",
61
+ accountType: "user",
60
62
  author: DEFAULT_AUTHOR,
61
63
  authorUrl: DEFAULT_AUTHOR_URL,
62
64
  extras: [],
@@ -74,6 +76,7 @@ export const ZERO2WEBMASTER_PRESET = {
74
76
  typographyRule: "Large, easy-to-read type per Z2W standing organization instruction (body 18px+, line-height >= 1.5).",
75
77
  domains: ["zero2webmaster.com"],
76
78
  githubOrg: "zero2webmaster",
79
+ accountType: "user",
77
80
  author: DEFAULT_AUTHOR,
78
81
  authorUrl: DEFAULT_AUTHOR_URL,
79
82
  extras: [
@@ -89,7 +92,7 @@ export const ZERO2WEBMASTER_PRESET = {
89
92
  },
90
93
  ],
91
94
  notes: [
92
- "Applies to Z2W internal tools, Z2W-branded WP plugins, Z2W cross-project infrastructure, and the Z2W product line. All ship under the zero2webmaster GitHub org, NEVER under kerrykriger personal.",
95
+ "Applies to Z2W internal tools, Z2W-branded WP plugins, Z2W cross-project infrastructure, and the Z2W product line. All ship under the `zero2webmaster` GitHub account, NEVER under `kerrykriger`. Both are GitHub **User** accounts, so the rule is about which account owns the repo — it is NOT a personal-vs-organization distinction.",
93
96
  ],
94
97
  isStub: false,
95
98
  };
@@ -103,8 +106,12 @@ export const BRAND_PRESETS = {
103
106
  *
104
107
  * Per [[instantiate-z2w-project]] SKILL.md, `custom` is never persisted back
105
108
  * into the skill — one-offs aren't presets. The typography rule defaults to
106
- * the Z2W standing org rule, and GitHub org defaults to `null` (caller must
107
- * set it explicitly via the GitHub org input).
109
+ * the Z2W standing org rule, and the GitHub owner defaults to `null` (caller
110
+ * must set it explicitly via the GitHub owner input).
111
+ *
112
+ * `accountType` is deliberately `"unknown"`: a caller-supplied owner has not
113
+ * been checked, and claiming either type would be a guess the emitted docs
114
+ * would then state as fact. The emitted block tells the reader how to check.
108
115
  */
109
116
  export function buildCustomBrandSpec(inputs, githubOrg = null) {
110
117
  return {
@@ -116,6 +123,7 @@ export function buildCustomBrandSpec(inputs, githubOrg = null) {
116
123
  typographyRule: DEFAULT_TYPOGRAPHY_RULE,
117
124
  domains: [],
118
125
  githubOrg,
126
+ accountType: "unknown",
119
127
  author: DEFAULT_AUTHOR,
120
128
  authorUrl: DEFAULT_AUTHOR_URL,
121
129
  extras: [],
@@ -140,6 +148,43 @@ function valueOrTodo(value) {
140
148
  const trimmed = value.trim();
141
149
  return trimmed.length > 0 ? trimmed : "_TODO — fill in_";
142
150
  }
151
+ /**
152
+ * The account-type clause that follows the GitHub owner in the brand block.
153
+ *
154
+ * This exists because the emitted wording was previously "GitHub org default",
155
+ * which is a factual claim and a false one: every account in the portfolio is
156
+ * a GitHub `User`. Two agents built org-scoped URLs from that line and hit
157
+ * `/organizations/...` 404s within five days (a GitHub App setup on
158
+ * 2026-07-26, a webhook on 2026-07-31 — the latter published into four docs
159
+ * before it was caught). So the clause names the type AND names the org-only
160
+ * surfaces that do not exist for a User account, because "owner" alone still
161
+ * leaves a reader free to assume Organization.
162
+ *
163
+ * For an unverified owner it states that it is unverified and gives the
164
+ * one-command check, rather than guessing a type the docs would then assert.
165
+ */
166
+ function renderAccountTypeNote(spec) {
167
+ const owner = spec.githubOrg ?? "";
168
+ if (spec.accountType === "user") {
169
+ return (`a GitHub **User** account, NOT an Organization. Repos live at ` +
170
+ `\`github.com/${owner}/{repo}\`. Organization-only URLs and APIs do ` +
171
+ `not exist for it — \`/organizations/...\`, \`gh api orgs/${owner}\`, ` +
172
+ `and Settings → Organizations all 404.`);
173
+ }
174
+ if (spec.accountType === "organization") {
175
+ return "a GitHub **Organization**, so organization-scoped URLs and APIs apply.";
176
+ }
177
+ // Deliberately NOT a `switch` with three cases and no default. `tsconfig`
178
+ // EXCLUDES `**/*.test.ts` from typecheck, so a spec literal missing
179
+ // `accountType` compiles and only shows up at run time — an exhaustive
180
+ // switch would return `undefined` and emit the literal text "undefined"
181
+ // into a scaffolded CLAUDE.md. Anything unrecognised falls through to the
182
+ // verify-first wording, which is never wrong for any account.
183
+ return (`account type NOT verified. Check it with \`gh api users/${owner} ` +
184
+ `--jq .type\` before using any Organization-only URL or API ` +
185
+ `(\`/organizations/...\`, \`gh api orgs/...\`), which 404 for a User ` +
186
+ `account.`);
187
+ }
143
188
  /**
144
189
  * Render a brand spec as a self-contained markdown block suitable for
145
190
  * prepending to a scaffolded project's CLAUDE.md (per the skill's Step 5).
@@ -155,7 +200,7 @@ export function renderBrandBlock(spec) {
155
200
  lines.push(`- **Brand name:** \`${spec.brandName}\` — ${spec.brandNameRule}`);
156
201
  lines.push(`- **Author:** ${spec.author} (${spec.authorUrl})`);
157
202
  if (spec.githubOrg) {
158
- lines.push(`- **GitHub org default:** \`${spec.githubOrg}\``);
203
+ lines.push(`- **GitHub owner:** \`${spec.githubOrg}\` — ${renderAccountTypeNote(spec)}`);
159
204
  }
160
205
  lines.push("");
161
206
  lines.push("**Color palette:**");
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 org ..................... ${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)}`);
58
58
  return lines.join("\n");
59
59
  }
60
60
  export function parseSlug(raw) {
@@ -253,10 +253,10 @@ async function editField(draft, fieldNumber, opts) {
253
253
  return null;
254
254
  }
255
255
  case 5: {
256
- const raw = await opts.prompter("GitHub org:", draft.githubOrg ?? "");
256
+ const raw = await opts.prompter("GitHub owner (user or org account):", draft.githubOrg ?? "");
257
257
  const trimmed = raw.trim().replace(/^@/, "");
258
258
  if (trimmed.length === 0)
259
- return "GitHub org cannot be empty.";
259
+ return "GitHub owner cannot be empty.";
260
260
  draft.githubOrg = trimmed;
261
261
  return null;
262
262
  }
@@ -36,12 +36,27 @@ export interface BuildProjectRowOptions {
36
36
  * licensing, notes, research_url, …) are intentionally omitted so the UPSERT's
37
37
  * DO UPDATE never clobbers Kerry's hand-entered values.
38
38
  *
39
- * Difference from the Airtable mapper: `project_type` IS written here (the Neon
39
+ * Difference from the Airtable mapper: the scaffold type IS written here (the Neon
40
40
  * column is plain text and the CLI knows the value, so it earns its place per the
41
41
  * column-audit principle "a column earns its place only if the CLI can auto-fill
42
42
  * it"). The Airtable mapper omitted it only because that base's Project Type is a
43
43
  * single-select whose option names could 422 on first use. `skill_vault_aware` is
44
44
  * a real boolean here (Neon column type), not the Airtable "Yes" string.
45
+ *
46
+ * 🛑 **`project_type` is SUPERSEDED as of 2026-08-02 and this mapper no longer
47
+ * writes it.** It had been carrying three questions in one column: an audience
48
+ * label a human typed into Airtable years ago, a stack slug THIS function
49
+ * emitted, and 20 NULLs — so `GROUP BY project_type` returned a clean-looking
50
+ * result that meant nothing. This CLI was the source of the second vocabulary,
51
+ * which makes the split ours to perform. Kerry ruled the field "out of date,
52
+ * needs a review and/or should be replaced" (2026-07-30) and ratified the
53
+ * replacement on 2026-08-02: `stack` (how it is built — this enum) and
54
+ * `audience` (who it is for — internal | client | personal).
55
+ *
56
+ * `audience` is deliberately NOT written here. The CLI cannot know it: every
57
+ * value is a judgement about who the project serves, and a scaffolder guessing
58
+ * `internal` for every new repo would recreate exactly the unvalidated
59
+ * categorisation Kerry just retired. It stays a human/agent field.
45
60
  */
46
61
  export declare function buildProjectRow(inputs: ScaffoldInputs, opts?: BuildProjectRowOptions): ProjectRow;
47
62
  /**
package/dist/inventory.js CHANGED
@@ -53,12 +53,27 @@ export function resolveInventoryConfig(env = process.env) {
53
53
  * licensing, notes, research_url, …) are intentionally omitted so the UPSERT's
54
54
  * DO UPDATE never clobbers Kerry's hand-entered values.
55
55
  *
56
- * Difference from the Airtable mapper: `project_type` IS written here (the Neon
56
+ * Difference from the Airtable mapper: the scaffold type IS written here (the Neon
57
57
  * column is plain text and the CLI knows the value, so it earns its place per the
58
58
  * column-audit principle "a column earns its place only if the CLI can auto-fill
59
59
  * it"). The Airtable mapper omitted it only because that base's Project Type is a
60
60
  * single-select whose option names could 422 on first use. `skill_vault_aware` is
61
61
  * a real boolean here (Neon column type), not the Airtable "Yes" string.
62
+ *
63
+ * 🛑 **`project_type` is SUPERSEDED as of 2026-08-02 and this mapper no longer
64
+ * writes it.** It had been carrying three questions in one column: an audience
65
+ * label a human typed into Airtable years ago, a stack slug THIS function
66
+ * emitted, and 20 NULLs — so `GROUP BY project_type` returned a clean-looking
67
+ * result that meant nothing. This CLI was the source of the second vocabulary,
68
+ * which makes the split ours to perform. Kerry ruled the field "out of date,
69
+ * needs a review and/or should be replaced" (2026-07-30) and ratified the
70
+ * replacement on 2026-08-02: `stack` (how it is built — this enum) and
71
+ * `audience` (who it is for — internal | client | personal).
72
+ *
73
+ * `audience` is deliberately NOT written here. The CLI cannot know it: every
74
+ * value is a judgement about who the project serves, and a scaffolder guessing
75
+ * `internal` for every new repo would recreate exactly the unvalidated
76
+ * categorisation Kerry just retired. It stays a human/agent field.
62
77
  */
63
78
  export function buildProjectRow(inputs, opts = {}) {
64
79
  const row = {
@@ -66,7 +81,7 @@ export function buildProjectRow(inputs, opts = {}) {
66
81
  project_name: displayNameFromSlug(inputs.slug),
67
82
  status: "Active",
68
83
  creation_method: "Z2W Starter Kit",
69
- project_type: inputs.projectType,
84
+ stack: inputs.projectType,
70
85
  // Write the conventional URL even if `gh repo create` is deferred — the
71
86
  // inventory's slug-resolution needs it.
72
87
  github_url: `https://github.com/${inputs.githubOrg}/${inputs.slug}`,
@@ -285,7 +285,14 @@ export function githubOrgForBrand(brand) {
285
285
  }
286
286
  }
287
287
  function inferGithubOrg(brief, brand) {
288
+ // "github owner"/"github account" are the accurate spellings (every Z2W
289
+ // account is a GitHub User, not an Organization). "github org"/"github
290
+ // organization"/"org" stay accepted for the many existing briefs and
291
+ // `--input` files that already use them — dropping them would silently fall
292
+ // back to the brand default instead of erroring.
288
293
  const explicit = findExplicitField(brief, [
294
+ "github owner",
295
+ "github account",
289
296
  "github org",
290
297
  "github organization",
291
298
  "org",
@@ -88,6 +88,32 @@ export declare function resolveStandards(inputs: ScaffoldInputs, opts?: ResolveS
88
88
  * call on any file).
89
89
  */
90
90
  export declare function applyStandardsBlock(claudeMd: string, resolution: StandardsResolution): string;
91
+ /**
92
+ * Wrap a replacement so `String.replace()` inserts it LITERALLY.
93
+ *
94
+ * 🔴 Never pass canonical prose to `.replace()` as a replacement *string*. JS
95
+ * interprets `$&`, `` $` ``, `$'`, `$1` and `$$` inside a replacement string as
96
+ * special patterns, and the bodies spliced by this module are hand-written
97
+ * markdown from upstream sources we do not control — so any of those sequences
98
+ * can appear at any time without warning.
99
+ *
100
+ * This is not hypothetical. Protocol v0.1.25 / block v0.1.18 (2026-07-30) added
101
+ * the sentence ``Anchor the rewrite on the heading as a whole LINE (`^## Current
102
+ * focus$`)`` — whose `$` + closing backtick form the two-byte sequence `` $` ``,
103
+ * meaning "everything in the subject string BEFORE the match". Every scaffold
104
+ * emitted after that date spliced its own ENTIRE document head back into the
105
+ * middle of the coordination block: `marketing-engine`'s committed `CLAUDE.md`
106
+ * came out at 1522 lines with two `# Agent Instructions` headings, and the
107
+ * sentence carrying the `$` was truncated mid-clause.
108
+ *
109
+ * It was silent in every channel that could have caught it. The byte-diff test
110
+ * compares the CONSTANT against `AGENT_PROTOCOL.md` and passed — the constant
111
+ * was always correct; the *emission* was corrupt. Nothing reads a scaffolded
112
+ * `CLAUDE.md` as part of a build, so there was no downstream error either. A
113
+ * replacer FUNCTION's return value is used verbatim, with no `$` interpretation
114
+ * at all, which is why this is the fix rather than escaping `$$`.
115
+ */
116
+ export declare function literalReplacement(text: string): () => string;
91
117
  /**
92
118
  * Fill the `<!-- AGENT_COORDINATION_BLOCK -->` marker with the verbatim
93
119
  * canonical Agent Coordination section (or remove it, leaving a clean seam,
package/dist/standards.js CHANGED
@@ -307,10 +307,20 @@ const SENTRY_BODY = `### Sentry runtime-error tracking (customer-facing web app)
307
307
  >
308
308
  > 1. **Wire via the wizard, once:** \`npx @sentry/wizard@latest -i nextjs\` (add \`--saas --org <z2w-org> --project {{slug}}\` to skip prompts). It writes the client/server/edge config, the \`instrumentation.ts\` hook, and the build-time source-map upload.
309
309
  > 2. **DSN lives in config, NOT an env var.** The DSN is a publishable identifier (not a secret) — hard-code it in the Sentry config files the wizard generates; do NOT introduce a \`NEXT_PUBLIC_SENTRY_DSN\`. The one real secret is \`SENTRY_AUTH_TOKEN\` (build-time source-map upload) — scope it **Production-only** in Vercel and keep it out of the client bundle.
310
- > 3. **Feature-flag defaults:** Tracing sample rate 1.0 (100%) at Z2W volume; Session Replay 10% of sessions / 100% of sessions-with-errors; Logs on; \`sendDefaultPii: true\` — with the caveat that a Sentry payload then carries user IP + request headers, so never forward it verbatim into a shared surface (e.g. the bulletin \`## Incidents\` pipe strips to summary + link + timestamp).
311
- > 4. **Smoke it, then delete the smoke.** Add a throwaway auth-gated server-throw route (\`/api/boom\` style), confirm the error + replay land in Sentry and the alert email fires, then DELETE the route and the wizard's noisy example page (it's a honeypot that inflates your error count). Ship this cleanup as its own small commit.
312
- > 5. **The wizard writes \`silent: !process.env.CI\`, so a missing \`SENTRY_AUTH_TOKEN\` is SILENT LOCALLY and LOUD ON CI.** Quiet on your machine is by configuration, not by design — \`CI\` is unset locally and Vercel sets \`CI=1\`, where the plugin warns **three times, once per runtime**. So do NOT conclude from a clean local build that source-map upload emits nothing: **grep the deployed build log for \`No auth token provided\`** — a free check that beats a manual dashboard visit. (Reported by \`site-control\` 2026-07-30 after documenting the opposite in five places from a local measurement. The general shape, which is worth more than the Sentry detail: **a fact established under one configuration silently changes meaning under another** — so print or fetch what actually resolved, in the environment that will run it.)
313
- > 6. **2025 Sentry-UI quirks that waste time:** issue **alert rules** live at \`/alerts/rules/\` (NOT \`/monitors/alerts/\`); the "Test Notification" button does NOT auto-save the rule (save explicitly or it evaporates); the wizard's example page throws on every load until you remove it.
310
+ > 3. **Feature-flag defaults:** Tracing sample rate 1.0 (100%) at Z2W volume; Session Replay 10% of sessions / 100% of sessions-with-errors; Logs on.
311
+ >
312
+ > 4. **🔴 PII: do NOT set \`sendDefaultPii: true\`, and do NOT write a PARTIAL \`dataCollection\` block. Name every axis.** This bullet replaces a shorter one that said \`sendDefaultPii: true\` was fine because it "carries user IP + request headers." **That was a serious understatement and it shipped in this standard.** Verified 2026-08-02 by reading \`@sentry/core\` 10.69.0's own \`defaultPiiToCollectionOptions()\` rather than the docs — \`sendDefaultPii: true\` resolves **ten** axes on, including **\`httpBodies\` in all four directions** (incoming/outgoing request *and* response), **\`genAI: { inputs: true, outputs: true }\` — the user's PROMPT and the model's COMPLETION**, \`databaseQueryData: true\`, \`graphQL.variables: true\`, and \`stackFrameVariables: true\` (local variable values captured off the stack).
313
+ >
314
+ > **Two traps, both counter-intuitive, both measured:**
315
+ > - **Writing a \`dataCollection\` block AT ALL flips the baseline to all-on**, so every axis you do not name is enabled. \`{ httpBodies: [] }\` alone turns four other axes ON. An omitted key is not "leave as default" — it is an opt-in.
316
+ > - **\`stackFrameVariables: true\` is on in BOTH branches**, so \`sendDefaultPii: false\` does not turn it off. Only an explicit \`dataCollection\` block can. Local variables on an error path can hold a token, a decrypted payload, or a whole user record.
317
+ >
318
+ > **So: write ONE complete \`dataCollection\` block naming every axis, and pin it with a test that asserts what \`resolveDataCollectionOptions()\` RESOLVED — not what you typed.** A test that reads your own config object back to itself proves you typed what you meant and nothing about what the SDK did with it; that is exactly the gap that let a partial block sit unnoticed in three Z2W repos. \`[[sentry-runtime-errors]]\` carries the current block, the resolver one-liner, and the per-repo audit — **and because a hardcoded axis list in any doc goes stale silently and in the unsafe direction every time the SDK adds a collector, the binding instruction is the resolver check, not the snippet.** Re-run it on every SDK upgrade.
319
+ >
320
+ > Whatever you end up collecting, never forward a Sentry payload verbatim into a shared surface (the bulletin \`## Incidents\` pipe strips to summary + link + timestamp).
321
+ > 5. **Smoke it, then delete the smoke.** Add a throwaway auth-gated server-throw route (\`/api/boom\` style), confirm the error + replay land in Sentry and the alert email fires, then DELETE the route and the wizard's noisy example page (it's a honeypot that inflates your error count). Ship this cleanup as its own small commit.
322
+ > 6. **The wizard writes \`silent: !process.env.CI\`, so a missing \`SENTRY_AUTH_TOKEN\` is SILENT LOCALLY and LOUD ON CI.** Quiet on your machine is by configuration, not by design — \`CI\` is unset locally and Vercel sets \`CI=1\`, where the plugin warns **three times, once per runtime**. So do NOT conclude from a clean local build that source-map upload emits nothing: **grep the deployed build log for \`No auth token provided\`** — a free check that beats a manual dashboard visit. (Reported by \`site-control\` 2026-07-30 after documenting the opposite in five places from a local measurement. The general shape, which is worth more than the Sentry detail: **a fact established under one configuration silently changes meaning under another** — so print or fetch what actually resolved, in the environment that will run it.)
323
+ > 7. **2025 Sentry-UI quirks that waste time:** issue **alert rules** live at \`/alerts/rules/\` (NOT \`/monitors/alerts/\`); the "Test Notification" button does NOT auto-save the rule (save explicitly or it evaporates); the wizard's example page throws on every load until you remove it.
314
324
  >
315
325
  > **When to SKIP (do not wire Sentry):** WordPress sites (error tracking via Z2W Admin Suite Diagnostics + FluentSMTP logs); CLI libraries and protocol repos (no request surface); Cloudflare Workers / node-service / python-service that are API-only (the \`-i nextjs\` wizard doesn't fit — revisit per-runtime later); internal-only admin tools with a single operator who sees errors directly. The rule of thumb: wire it for any public-or-customer-facing Next.js / CF-Pages app that will have real users.
316
326
  >
@@ -652,7 +662,35 @@ export function resolveStandards(inputs, opts = {}) {
652
662
  * call on any file).
653
663
  */
654
664
  export function applyStandardsBlock(claudeMd, resolution) {
655
- return claudeMd.replace(/<!-- STANDARDS_BLOCK -->/g, resolution.body.trimEnd());
665
+ return claudeMd.replace(/<!-- STANDARDS_BLOCK -->/g, literalReplacement(resolution.body.trimEnd()));
666
+ }
667
+ /**
668
+ * Wrap a replacement so `String.replace()` inserts it LITERALLY.
669
+ *
670
+ * 🔴 Never pass canonical prose to `.replace()` as a replacement *string*. JS
671
+ * interprets `$&`, `` $` ``, `$'`, `$1` and `$$` inside a replacement string as
672
+ * special patterns, and the bodies spliced by this module are hand-written
673
+ * markdown from upstream sources we do not control — so any of those sequences
674
+ * can appear at any time without warning.
675
+ *
676
+ * This is not hypothetical. Protocol v0.1.25 / block v0.1.18 (2026-07-30) added
677
+ * the sentence ``Anchor the rewrite on the heading as a whole LINE (`^## Current
678
+ * focus$`)`` — whose `$` + closing backtick form the two-byte sequence `` $` ``,
679
+ * meaning "everything in the subject string BEFORE the match". Every scaffold
680
+ * emitted after that date spliced its own ENTIRE document head back into the
681
+ * middle of the coordination block: `marketing-engine`'s committed `CLAUDE.md`
682
+ * came out at 1522 lines with two `# Agent Instructions` headings, and the
683
+ * sentence carrying the `$` was truncated mid-clause.
684
+ *
685
+ * It was silent in every channel that could have caught it. The byte-diff test
686
+ * compares the CONSTANT against `AGENT_PROTOCOL.md` and passed — the constant
687
+ * was always correct; the *emission* was corrupt. Nothing reads a scaffolded
688
+ * `CLAUDE.md` as part of a build, so there was no downstream error either. A
689
+ * replacer FUNCTION's return value is used verbatim, with no `$` interpretation
690
+ * at all, which is why this is the fix rather than escaping `$$`.
691
+ */
692
+ export function literalReplacement(text) {
693
+ return () => text;
656
694
  }
657
695
  /**
658
696
  * Fill the `<!-- AGENT_COORDINATION_BLOCK -->` marker with the verbatim
@@ -669,7 +707,7 @@ export function applyAgentCoordinationBlock(claudeMd, resolution) {
669
707
  if (section === "") {
670
708
  return claudeMd.replace(marker, "");
671
709
  }
672
- return claudeMd.replace(marker, `${section}\n\n---\n\n`);
710
+ return claudeMd.replace(marker, literalReplacement(`${section}\n\n---\n\n`));
673
711
  }
674
712
  /**
675
713
  * Fill the `<!-- CAPTURE_LEARNINGS_BLOCK -->` marker with the verbatim canonical
@@ -680,7 +718,7 @@ export function applyAgentCoordinationBlock(claudeMd, resolution) {
680
718
  * top-level `##` section, so it sits outside `## Standards block`.
681
719
  */
682
720
  export function applyCaptureLearningsBlock(claudeMd) {
683
- const filled = claudeMd.replace(/<!-- CAPTURE_LEARNINGS_BLOCK -->/g, `${CAPTURE_LEARNINGS_BODY.trimEnd()}\n\n---\n\n`);
721
+ const filled = claudeMd.replace(/<!-- CAPTURE_LEARNINGS_BLOCK -->/g, literalReplacement(`${CAPTURE_LEARNINGS_BODY.trimEnd()}\n\n---\n\n`));
684
722
  // DEDUPE, and this is why the call happens AFTER the AGENTS body is spliced
685
723
  // in: the canonical framework body (AGENTS_v2.17.0+) carries this same block,
686
724
  // which would leave the scaffold with TWO copies. Two is a real failure, not
package/dist/wizard.js CHANGED
@@ -122,7 +122,7 @@ export async function runWizard(opts) {
122
122
  const brand = await askValidated(prompter, `4. Brand preset (${BRANDS.join(" / ")}):`, parseEnumValue(BRANDS, "Brand preset"), undefined, out);
123
123
  const customBrand = brand === "custom" ? await askCustomBrand(prompter, out) : undefined;
124
124
  const githubOrgDefault = githubOrgForBrand(brand) ?? "";
125
- const githubOrg = await askValidated(prompter, "5. GitHub org:", parseNonEmpty("GitHub org"), githubOrgDefault, out);
125
+ const githubOrg = await askValidated(prompter, "5. GitHub owner (user or org account):", parseNonEmpty("GitHub owner"), githubOrgDefault, out);
126
126
  const targetPathParser = makeTargetPathParser(skipFs);
127
127
  let targetPath;
128
128
  while (true) {
package/dist/writer.js CHANGED
@@ -26,7 +26,7 @@ import fsExtra from "fs-extra";
26
26
  import { AGENT_COORDINATION_BLOCK_MARKER, AGENTS_BODY_MARKER, STANDARDS_BLOCK_MARKER, } from "./scaffolders/common.js";
27
27
  import { buildProSeoExtension, proSeoApplies, } from "./scaffolders/pro-seo-extension.js";
28
28
  import { scaffoldByType } from "./scaffolders/index.js";
29
- import { applyAgentCoordinationBlock, applyCaptureLearningsBlock, applyStandardsBlock, resolveStandards, } from "./standards.js";
29
+ import { applyAgentCoordinationBlock, applyCaptureLearningsBlock, applyStandardsBlock, literalReplacement, resolveStandards, } from "./standards.js";
30
30
  import { resolveAgentsTemplate, } from "./templates.js";
31
31
  export class WriterError extends Error {
32
32
  constructor(message) {
@@ -224,7 +224,13 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
224
224
  const claudeFile = files[claudeIdx];
225
225
  let claudeContent = applyStandardsBlock(claudeFile.content, resolution);
226
226
  claudeContent = applyAgentCoordinationBlock(claudeContent, resolution);
227
- claudeContent = claudeContent.replace(AGENTS_BODY_MARKER, agentsBody);
227
+ // `literalReplacement` is mandatory here, not defensive styling: `agentsBody`
228
+ // is the canonical `AGENTS_v*.md` framework body read fresh from Templates on
229
+ // every run, so it is prose this repo does not control and cannot review
230
+ // before splicing. A bare `$&`/`` $` ``/`$'` anywhere in it would silently
231
+ // duplicate or drop part of the emitted CLAUDE.md. See the helper's docblock
232
+ // for the 2026-07-30 incident that proved this is a live hazard.
233
+ claudeContent = claudeContent.replace(AGENTS_BODY_MARKER, literalReplacement(agentsBody));
228
234
  // Always-on: applies to every project type, bulletin participant or not.
229
235
  // MUST run AFTER the AGENTS body splice — the canonical framework body carries
230
236
  // this same block, and this call is what dedupes it down to one.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero2webmaster/starter-kit",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.",
5
5
  "author": {
6
6
  "name": "Dr. Kerry Kriger",