@zero2webmaster/starter-kit 0.8.0 → 0.9.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 +10 -5
- package/dist/scaffolders/common.d.ts +29 -1
- package/dist/scaffolders/common.js +53 -1
- package/dist/scaffolders/nextjs.js +519 -11
- package/dist/standards.d.ts +1 -1
- package/dist/standards.js +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 0.
|
|
3
|
+
**Version:** 0.9.0 | **Framework:** 2.13.0
|
|
4
4
|
|
|
5
5
|
> Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
|
|
6
6
|
|
|
@@ -83,9 +83,14 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
|
|
|
83
83
|
|
|
84
84
|
## Status
|
|
85
85
|
|
|
86
|
-
- **v0.
|
|
87
|
-
- **v0.
|
|
88
|
-
-
|
|
86
|
+
- **v0.9.0 (current, unpublished)** 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
|
+
- **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
|
+
- **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
|
+
- **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.
|
|
90
|
+
- Automatic **GitHub repo creation is a free default**: after a scaffold the CLI runs `git init` + first commit + `gh repo create --private` + push, with `--no-repo` to opt out. It is skipped for `--dry-run` and for the non-interactive `--input` CI path, and it warns rather than failing if `gh` is unavailable.
|
|
91
|
+
- The runtime license-validation Worker and the paid `--with-pro-seo` baseline remain a **v0.3.x** track and are **not built**. Their future is currently an open business decision, so no licensing machinery is being added in the meantime.
|
|
92
|
+
|
|
93
|
+
> **Note on the hosted Templates mirror:** earlier releases (v0.2.0 / v0.2.1) shipped a hosted mirror at `templates.z2w.us` that let the CLI run without a local Templates folder. **That mirror was retired on 2026-06-23** and the CLI now reads canonical content from the local Templates folder only — see *Templates resolution* above.
|
|
89
94
|
|
|
90
95
|
## License
|
|
91
96
|
|
|
@@ -99,4 +104,4 @@ For licensing inquiries: kerry@zero2webmaster.com.
|
|
|
99
104
|
---
|
|
100
105
|
|
|
101
106
|
*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.*
|
|
102
|
-
*Version: 0.
|
|
107
|
+
*Version: 0.9.0 | Last Updated: 2026-07-30*
|
|
@@ -14,6 +14,26 @@ export declare const CAPTURE_LEARNINGS_BLOCK_MARKER = "<!-- CAPTURE_LEARNINGS_BL
|
|
|
14
14
|
export declare const AGENTS_BODY_MARKER = "<!-- AGENTS_BODY -->";
|
|
15
15
|
export declare function resolveBrandSpec(inputs: ScaffoldInputs): BrandPresetSpec;
|
|
16
16
|
export declare function sub(template: string, inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): string;
|
|
17
|
+
/** WCAG 2.1 relative luminance of an `#rgb` / `#rrggbb` color. */
|
|
18
|
+
export declare function relativeLuminance(hex: string): number;
|
|
19
|
+
/** WCAG 2.1 contrast ratio between two `#rgb` / `#rrggbb` colors. */
|
|
20
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
21
|
+
/** Near-black ink, used wherever a light fill needs dark text. */
|
|
22
|
+
export declare const INK_DARK = "#1a1a1a";
|
|
23
|
+
/** Pure white ink, used wherever a dark fill needs light text. */
|
|
24
|
+
export declare const INK_LIGHT = "#ffffff";
|
|
25
|
+
/**
|
|
26
|
+
* Pick the ink color that reads on `background`.
|
|
27
|
+
*
|
|
28
|
+
* This exists because the emitted CSS paints small UI glyphs ON a brand fill,
|
|
29
|
+
* and brand primaries vary wildly across presets — `#82C92B` (Z2W green) and
|
|
30
|
+
* `#72af43` (STF green) both want dark ink, while a dark custom primary wants
|
|
31
|
+
* white. Hardcoding either one ships an unreadable glyph to half the brands,
|
|
32
|
+
* and it is the kind of defect nobody reports because it looks *deliberate*.
|
|
33
|
+
* Deciding it at scaffold time from the actual hex is deterministic, testable,
|
|
34
|
+
* and costs the emitted project nothing at runtime.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readableInkOn(background: string): string;
|
|
17
37
|
export declare function buildClaudeMd(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec, perTypeNarrative: string): ScaffoldFile;
|
|
18
38
|
export declare function commonReadme(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
19
39
|
export declare function commonRoadmap(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
@@ -82,9 +102,17 @@ export declare const EMAIL_ENV_BLOCK = "\n# \u2500\u2500 Transactional / auth em
|
|
|
82
102
|
* Build the email-wiring files for a scaffold that sends email. \`layout\`
|
|
83
103
|
* selects the file paths + whether a vitest test is emitted:
|
|
84
104
|
* - "nextjs" → \`lib/email/mailer.ts\` (imported via the \`@/*\` alias); no
|
|
85
|
-
* test file
|
|
105
|
+
* test file.
|
|
86
106
|
* - "node-service" → \`src/lib/email/mailer.ts\` + \`src/lib/email/mailer.test.ts\`
|
|
87
107
|
* (vitest picks up \`src/**\/*.test.ts\`).
|
|
88
108
|
* The directive is emitted for both.
|
|
109
|
+
*
|
|
110
|
+
* NOTE: the nextjs scaffold DOES ship a vitest runner as of v0.9.0 (it emits
|
|
111
|
+
* \`test/form-standards.test.ts\`), so the historical reason for skipping the
|
|
112
|
+
* mailer test there is gone. It stays skipped pending verification only: the
|
|
113
|
+
* test body imports \`./mailer.js\` for NodeNext resolution, and the nextjs
|
|
114
|
+
* tsconfig uses \`"moduleResolution": "Bundler"\`. Emit it once that import has
|
|
115
|
+
* been run — under a REAL \`npm test\` in a scaffolded project, not asserted from
|
|
116
|
+
* a template string.
|
|
89
117
|
*/
|
|
90
118
|
export declare function emailFiles(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec, layout: "nextjs" | "node-service"): ScaffoldFile[];
|
|
@@ -25,6 +25,50 @@ export function resolveBrandSpec(inputs) {
|
|
|
25
25
|
export function sub(template, inputs, opts, spec) {
|
|
26
26
|
return applySubstitutions(template, inputs, { ...opts, brandSpec: spec });
|
|
27
27
|
}
|
|
28
|
+
/** WCAG 2.1 relative luminance of an `#rgb` / `#rrggbb` color. */
|
|
29
|
+
export function relativeLuminance(hex) {
|
|
30
|
+
const h = hex.trim().replace(/^#/, "");
|
|
31
|
+
const full = h.length === 3
|
|
32
|
+
? h
|
|
33
|
+
.split("")
|
|
34
|
+
.map((c) => c + c)
|
|
35
|
+
.join("")
|
|
36
|
+
: h;
|
|
37
|
+
const channel = (pair) => {
|
|
38
|
+
const srgb = parseInt(pair, 16) / 255;
|
|
39
|
+
return srgb <= 0.03928 ? srgb / 12.92 : ((srgb + 0.055) / 1.055) ** 2.4;
|
|
40
|
+
};
|
|
41
|
+
return (0.2126 * channel(full.slice(0, 2)) +
|
|
42
|
+
0.7152 * channel(full.slice(2, 4)) +
|
|
43
|
+
0.0722 * channel(full.slice(4, 6)));
|
|
44
|
+
}
|
|
45
|
+
/** WCAG 2.1 contrast ratio between two `#rgb` / `#rrggbb` colors. */
|
|
46
|
+
export function contrastRatio(a, b) {
|
|
47
|
+
const la = relativeLuminance(a);
|
|
48
|
+
const lb = relativeLuminance(b);
|
|
49
|
+
const [hi, lo] = la > lb ? [la, lb] : [lb, la];
|
|
50
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
51
|
+
}
|
|
52
|
+
/** Near-black ink, used wherever a light fill needs dark text. */
|
|
53
|
+
export const INK_DARK = "#1a1a1a";
|
|
54
|
+
/** Pure white ink, used wherever a dark fill needs light text. */
|
|
55
|
+
export const INK_LIGHT = "#ffffff";
|
|
56
|
+
/**
|
|
57
|
+
* Pick the ink color that reads on `background`.
|
|
58
|
+
*
|
|
59
|
+
* This exists because the emitted CSS paints small UI glyphs ON a brand fill,
|
|
60
|
+
* and brand primaries vary wildly across presets — `#82C92B` (Z2W green) and
|
|
61
|
+
* `#72af43` (STF green) both want dark ink, while a dark custom primary wants
|
|
62
|
+
* white. Hardcoding either one ships an unreadable glyph to half the brands,
|
|
63
|
+
* and it is the kind of defect nobody reports because it looks *deliberate*.
|
|
64
|
+
* Deciding it at scaffold time from the actual hex is deterministic, testable,
|
|
65
|
+
* and costs the emitted project nothing at runtime.
|
|
66
|
+
*/
|
|
67
|
+
export function readableInkOn(background) {
|
|
68
|
+
return contrastRatio(background, INK_DARK) >= contrastRatio(background, INK_LIGHT)
|
|
69
|
+
? INK_DARK
|
|
70
|
+
: INK_LIGHT;
|
|
71
|
+
}
|
|
28
72
|
const README_TEMPLATE = `# {{slug}}
|
|
29
73
|
|
|
30
74
|
**Version:** {{version}} | **Framework:** {{framework_version}}
|
|
@@ -1292,10 +1336,18 @@ URL ([[uptime-kuma-monitor]] / [[neon-postgres]]).
|
|
|
1292
1336
|
* Build the email-wiring files for a scaffold that sends email. \`layout\`
|
|
1293
1337
|
* selects the file paths + whether a vitest test is emitted:
|
|
1294
1338
|
* - "nextjs" → \`lib/email/mailer.ts\` (imported via the \`@/*\` alias); no
|
|
1295
|
-
* test file
|
|
1339
|
+
* test file.
|
|
1296
1340
|
* - "node-service" → \`src/lib/email/mailer.ts\` + \`src/lib/email/mailer.test.ts\`
|
|
1297
1341
|
* (vitest picks up \`src/**\/*.test.ts\`).
|
|
1298
1342
|
* The directive is emitted for both.
|
|
1343
|
+
*
|
|
1344
|
+
* NOTE: the nextjs scaffold DOES ship a vitest runner as of v0.9.0 (it emits
|
|
1345
|
+
* \`test/form-standards.test.ts\`), so the historical reason for skipping the
|
|
1346
|
+
* mailer test there is gone. It stays skipped pending verification only: the
|
|
1347
|
+
* test body imports \`./mailer.js\` for NodeNext resolution, and the nextjs
|
|
1348
|
+
* tsconfig uses \`"moduleResolution": "Bundler"\`. Emit it once that import has
|
|
1349
|
+
* been run — under a REAL \`npm test\` in a scaffolded project, not asserted from
|
|
1350
|
+
* a template string.
|
|
1299
1351
|
*/
|
|
1300
1352
|
export function emailFiles(inputs, opts, spec, layout) {
|
|
1301
1353
|
const dir = layout === "nextjs" ? "lib/email" : "src/lib/email";
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
// allowlist stub in `.env.example`. This CLI emits no auth code, so it plants the
|
|
47
47
|
// seam + the pointer at [[z2w-magic-link-auth]] §0 rule 2b rather than a check —
|
|
48
48
|
// see CANONICAL_HOSTS_ENV_BLOCK for why that is the honest half.
|
|
49
|
-
import { commonBaseFiles, EMAIL_DEPS, EMAIL_ENV_BLOCK, emailFiles, localEnvFrom, resolveBrandSpec, sub, } from "./common.js";
|
|
49
|
+
import { commonBaseFiles, EMAIL_DEPS, EMAIL_ENV_BLOCK, emailFiles, localEnvFrom, readableInkOn, resolveBrandSpec, sub, } from "./common.js";
|
|
50
50
|
const NARRATIVE = `## What this is
|
|
51
51
|
|
|
52
52
|
\`{{slug}}\` is a Next.js App Router project scaffolded under the {{brand_name}} brand. The 7-item SEO baseline (per Z2W standing org requirement 2026-05-30) is wired in at instantiation.
|
|
@@ -58,8 +58,21 @@ npm install
|
|
|
58
58
|
# .env.local was scaffolded for you — fill in NEXT_PUBLIC_FATHOM_SITE_ID + NEXT_PUBLIC_SITE_URL
|
|
59
59
|
npm run dev # http://localhost:3000
|
|
60
60
|
npm run build && npm start # production build
|
|
61
|
+
npm test # vitest — includes the form-standards checks
|
|
61
62
|
\`\`\`
|
|
62
63
|
|
|
64
|
+
**Forms — use the emitted primitives:**
|
|
65
|
+
|
|
66
|
+
\`components/FormBits.tsx\` exports \`<Field>\`, \`<Required />\` and \`<InfoHint>\`, which encode the {{brand_name}} form standards so you don't have to remember them:
|
|
67
|
+
|
|
68
|
+
- **Optional is the default** — never label a field "(optional)". Mark the required ones: \`<Field required>\`.
|
|
69
|
+
- **Help text is never a placeholder** — placeholder text vanishes the moment someone types. Pass \`help={...}\` and it stays on screen.
|
|
70
|
+
- **Input borders are visible** — the emitted border clears the 3:1 WCAG non-text-contrast minimum.
|
|
71
|
+
|
|
72
|
+
\`test/form-standards.test.ts\` fails on the next form that breaks one of these, so the rules survive the person who wrote them. Run it with \`npm test\`.
|
|
73
|
+
|
|
74
|
+
The components carry **no** \`"use client"\` on purpose, so a Server Component can render a \`<Field>\` directly. Adding the directive breaks nothing visibly — it just ships them to the browser as JavaScript for no reason, which is why a test guards it.
|
|
75
|
+
|
|
63
76
|
**SEO baseline (wired in):**
|
|
64
77
|
|
|
65
78
|
- \`app/layout.tsx\` — root \`metadata\` with \`title.template\`, \`title.default\`, \`description\`, \`openGraph\`, \`twitter\`, \`metadataBase\`; mounts \`<Analytics />\`; JSON-LD Organization schema.
|
|
@@ -87,7 +100,8 @@ const PACKAGE_JSON_TEMPLATE = `{
|
|
|
87
100
|
"build": "next build",
|
|
88
101
|
"start": "next start",
|
|
89
102
|
"lint": "next lint",
|
|
90
|
-
"typecheck": "tsc --noEmit"
|
|
103
|
+
"typecheck": "tsc --noEmit",
|
|
104
|
+
"test": "vitest run"
|
|
91
105
|
},
|
|
92
106
|
"dependencies": {
|
|
93
107
|
"next": "^15.0.0",
|
|
@@ -98,7 +112,8 @@ const PACKAGE_JSON_TEMPLATE = `{
|
|
|
98
112
|
"@types/node": "^20.0.0",
|
|
99
113
|
"@types/react": "^19.0.0",
|
|
100
114
|
"@types/react-dom": "^19.0.0",
|
|
101
|
-
"typescript": "^5.4.0"
|
|
115
|
+
"typescript": "^5.4.0",
|
|
116
|
+
"vitest": "^4.0.0"
|
|
102
117
|
},
|
|
103
118
|
"homepage": "https://github.com/{{github_org}}/{{slug}}"
|
|
104
119
|
}
|
|
@@ -446,6 +461,494 @@ const TSCONFIG_TEMPLATE = `{
|
|
|
446
461
|
"exclude": ["node_modules"]
|
|
447
462
|
}
|
|
448
463
|
`;
|
|
464
|
+
/**
|
|
465
|
+
* Accessible form primitives, emitted into every Next.js scaffold.
|
|
466
|
+
*
|
|
467
|
+
* Ported from `zero2webmaster/grantor` @ `285118d`, where these rules were
|
|
468
|
+
* settled with Kerry on 2026-07-28 and then enforced as tests because a style
|
|
469
|
+
* guide nobody re-reads is not enforcement. Zero dependencies, no hooks.
|
|
470
|
+
*
|
|
471
|
+
* The `"use client"` absence is deliberate and commented as such in the emitted
|
|
472
|
+
* file.
|
|
473
|
+
*
|
|
474
|
+
* ⚠️ grantor reported that a client directive here "500s every server page that
|
|
475
|
+
* renders the component while typecheck and next build both pass clean." That
|
|
476
|
+
* did NOT reproduce on a clean scaffold (2026-07-30): with the directive added,
|
|
477
|
+
* typecheck passed, `next build` passed, and every page still served 200 with
|
|
478
|
+
* correct markup. The only measurable effect was route JS growing 143 B → 498 B
|
|
479
|
+
* as the components got pushed into the client bundle. grantor's failure was
|
|
480
|
+
* almost certainly specific to their own code — their comment cites
|
|
481
|
+
* `toCommentItems`, a plain helper rather than a component, and calling a
|
|
482
|
+
* function exported from a client module during a server render is a genuinely
|
|
483
|
+
* different fault.
|
|
484
|
+
*
|
|
485
|
+
* The rule survives the correction (the directive is still unnecessary and still
|
|
486
|
+
* costs bundle size) but the STATED CONSEQUENCE was wrong, so the emitted
|
|
487
|
+
* comment says what was actually measured. Reported back to grantor.
|
|
488
|
+
*/
|
|
489
|
+
const FORM_BITS_TEMPLATE = `/**
|
|
490
|
+
* Shared form primitives that encode the {{brand_name}} form standards.
|
|
491
|
+
*
|
|
492
|
+
* These exist as components, not as a style guide someone has to remember:
|
|
493
|
+
*
|
|
494
|
+
* 1. **Never label a field "(optional)".** Optional is the default — say
|
|
495
|
+
* nothing. Mark the REQUIRED ones, with a bright asterisk. A form where
|
|
496
|
+
* most fields say "(optional)" trains the eye to skip the parenthetical,
|
|
497
|
+
* which is exactly where the one required field's marker would live.
|
|
498
|
+
*
|
|
499
|
+
* 2. **Help text is never a placeholder.** Placeholder text vanishes the
|
|
500
|
+
* moment someone types, so guidance is gone precisely when they're trying
|
|
501
|
+
* to follow it — and greyed-out placeholder text reads as a filled field
|
|
502
|
+
* to a screen reader user and as low-contrast noise to everyone else.
|
|
503
|
+
* Guidance goes in a click-to-open info box that stays available.
|
|
504
|
+
*
|
|
505
|
+
* 3. **Input borders must be clearly visible.** A field whose edges the user
|
|
506
|
+
* cannot see is a field they don't know is editable. The emitted border
|
|
507
|
+
* clears the 3:1 WCAG non-text-contrast minimum; \`#ccc\` on white is
|
|
508
|
+
* ~1.6:1 and does not.
|
|
509
|
+
*
|
|
510
|
+
* These rules are enforced by \`test/form-standards.test.ts\` — source-level
|
|
511
|
+
* greps that fail the build on the next form that breaks one, not just on the
|
|
512
|
+
* forms that existed when this was written.
|
|
513
|
+
*
|
|
514
|
+
* ⚠️ NO \`"use client"\` here, ON PURPOSE. These are pure presentational
|
|
515
|
+
* components with no hooks, so Server Components and client forms can both
|
|
516
|
+
* import them.
|
|
517
|
+
*
|
|
518
|
+
* What adding the directive actually costs, measured on a real build rather
|
|
519
|
+
* than asserted: nothing fails. \`tsc --noEmit\` passes, \`next build\` passes,
|
|
520
|
+
* the page still returns 200 with correct markup. The only effect is that these
|
|
521
|
+
* components — and everything they pull in — get shipped to the browser as
|
|
522
|
+
* JavaScript for no reason (a page rendering one went 143 B → 498 B of route
|
|
523
|
+
* JS). That is precisely why it needs a comment and a test: a change with no
|
|
524
|
+
* symptom is the kind that survives review and never gets reverted.
|
|
525
|
+
*
|
|
526
|
+
* Do not add the directive "for consistency". Add it to the form that needs
|
|
527
|
+
* interactivity, and let these stay renderable from both sides.
|
|
528
|
+
*/
|
|
529
|
+
import type { ReactNode } from "react";
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* The required marker.
|
|
533
|
+
*
|
|
534
|
+
* Red rather than the brand accent: as a small glyph on white, most brand
|
|
535
|
+
* accents (orange, gold) sit under 3:1 and fail WCAG AA, so the one mark that
|
|
536
|
+
* MUST be noticed would be the least legible thing on the form. \`#c0392b\`
|
|
537
|
+
* clears 5:1 on white and still reads as "bright/alarming".
|
|
538
|
+
*
|
|
539
|
+
* \`<abbr>\` + the visually-hidden word keeps it meaningful to a screen reader,
|
|
540
|
+
* which announces a bare "*" as nothing useful.
|
|
541
|
+
*/
|
|
542
|
+
export function Required() {
|
|
543
|
+
return (
|
|
544
|
+
<abbr className="req-mark" title="required">
|
|
545
|
+
{" "}
|
|
546
|
+
*<span className="sr-only"> (required)</span>
|
|
547
|
+
</abbr>
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Click-to-open help for a field. Collapsed by default so the form stays
|
|
553
|
+
* scannable; the guidance is one click away and STAYS on screen while typing,
|
|
554
|
+
* which is the whole point of not being a placeholder.
|
|
555
|
+
*
|
|
556
|
+
* A native \`<details>\` — no JS, no hydration, works in a Server Component.
|
|
557
|
+
*/
|
|
558
|
+
export function InfoHint({
|
|
559
|
+
label = "What goes here?",
|
|
560
|
+
children,
|
|
561
|
+
}: {
|
|
562
|
+
label?: string;
|
|
563
|
+
children: ReactNode;
|
|
564
|
+
}) {
|
|
565
|
+
return (
|
|
566
|
+
<details className="info-hint">
|
|
567
|
+
<summary>
|
|
568
|
+
<span className="info-hint-icon" aria-hidden="true">
|
|
569
|
+
i
|
|
570
|
+
</span>
|
|
571
|
+
{label}
|
|
572
|
+
</summary>
|
|
573
|
+
<div className="info-hint-body">{children}</div>
|
|
574
|
+
</details>
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* A form field wrapper: label (+ required marker) and optional help.
|
|
580
|
+
*
|
|
581
|
+
* \`htmlFor\`/\`id\` is the caller's job — this component cannot know the
|
|
582
|
+
* control's id, and a label that isn't wired to its input is worse than no
|
|
583
|
+
* label. Pass the SAME id to the control you render as \`children\`.
|
|
584
|
+
*
|
|
585
|
+
* \`\`\`tsx
|
|
586
|
+
* <Field id="email" label="Email address" required help={<>We only use this to reply.</>}>
|
|
587
|
+
* <input id="email" name="email" type="email" required />
|
|
588
|
+
* </Field>
|
|
589
|
+
* \`\`\`
|
|
590
|
+
*/
|
|
591
|
+
export function Field({
|
|
592
|
+
id,
|
|
593
|
+
label,
|
|
594
|
+
required = false,
|
|
595
|
+
help,
|
|
596
|
+
helpLabel,
|
|
597
|
+
children,
|
|
598
|
+
}: {
|
|
599
|
+
id: string;
|
|
600
|
+
label: string;
|
|
601
|
+
required?: boolean;
|
|
602
|
+
help?: ReactNode;
|
|
603
|
+
helpLabel?: string;
|
|
604
|
+
children: ReactNode;
|
|
605
|
+
}) {
|
|
606
|
+
return (
|
|
607
|
+
<div className="form-field">
|
|
608
|
+
<label htmlFor={id}>
|
|
609
|
+
{label}
|
|
610
|
+
{required && <Required />}
|
|
611
|
+
</label>
|
|
612
|
+
{children}
|
|
613
|
+
{help && <InfoHint label={helpLabel}>{help}</InfoHint>}
|
|
614
|
+
</div>
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
`;
|
|
618
|
+
/**
|
|
619
|
+
* Global stylesheet. Built by a function rather than substituted from a flat
|
|
620
|
+
* template because ONE value has to be computed from the brand hex rather than
|
|
621
|
+
* interpolated: the ink painted on the brand-primary fill (see `readableInkOn`).
|
|
622
|
+
*
|
|
623
|
+
* What is deliberately NOT interpolated here is as load-bearing as what is:
|
|
624
|
+
* the required marker and the info-hint summary use FIXED accessible colors,
|
|
625
|
+
* never `{{accent_color}}`. Z2W gold (`#FFD700`) is ~1.1:1 on white and STF
|
|
626
|
+
* orange (`#f5821f`) ~2.3:1 — using the brand accent as small text ships an
|
|
627
|
+
* illegible glyph under a brand-consistency rationale.
|
|
628
|
+
*/
|
|
629
|
+
function globalsCss(primaryColor) {
|
|
630
|
+
const onPrimary = readableInkOn(primaryColor);
|
|
631
|
+
return `/* Global styles.
|
|
632
|
+
*
|
|
633
|
+
* Body typography lives here, not as an inline style on <body>, so there is ONE
|
|
634
|
+
* home for it. Per the standing Zero2Webmaster organization rule, public-facing
|
|
635
|
+
* text is large and easy to read: body 18px+, line-height >= 1.5.
|
|
636
|
+
*/
|
|
637
|
+
|
|
638
|
+
:root {
|
|
639
|
+
--brand-primary: ${primaryColor};
|
|
640
|
+
/* Ink that reads ON the brand primary fill. Computed from the brand hex at
|
|
641
|
+
scaffold time — do not hand-edit to match a sibling project, whose primary
|
|
642
|
+
may sit on the other side of the luminance threshold. */
|
|
643
|
+
--brand-on-primary: ${onPrimary};
|
|
644
|
+
--brand-ink: #3f3c36;
|
|
645
|
+
/* Input border. #ccc on white is ~1.6:1, below the 3:1 WCAG 2.1 minimum for a
|
|
646
|
+
UI component boundary — i.e. the edge of the box is genuinely not visible,
|
|
647
|
+
not merely subtle. #8f8b81 clears 3:1. */
|
|
648
|
+
--field-border: #8f8b81;
|
|
649
|
+
--field-border-hover: #6f6b62;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
html {
|
|
653
|
+
box-sizing: border-box;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
*,
|
|
657
|
+
*::before,
|
|
658
|
+
*::after {
|
|
659
|
+
box-sizing: inherit;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
body {
|
|
663
|
+
margin: 0;
|
|
664
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
665
|
+
font-size: 18px;
|
|
666
|
+
line-height: 1.5;
|
|
667
|
+
color: var(--brand-ink);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/* --- Visually-hidden text ---------------------------------------------------
|
|
671
|
+
* Available to screen readers, invisible on screen. Used by <Required /> to
|
|
672
|
+
* announce the word "required" behind the "*", which is otherwise announced as
|
|
673
|
+
* nothing useful. Not \`display: none\`, which removes it from the a11y tree too.
|
|
674
|
+
*/
|
|
675
|
+
.sr-only {
|
|
676
|
+
position: absolute;
|
|
677
|
+
width: 1px;
|
|
678
|
+
height: 1px;
|
|
679
|
+
padding: 0;
|
|
680
|
+
margin: -1px;
|
|
681
|
+
overflow: hidden;
|
|
682
|
+
clip: rect(0, 0, 0, 0);
|
|
683
|
+
white-space: nowrap;
|
|
684
|
+
border: 0;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/* --- Form primitives (components/FormBits.tsx) ------------------------------ */
|
|
688
|
+
|
|
689
|
+
.form-field {
|
|
690
|
+
display: flex;
|
|
691
|
+
flex-direction: column;
|
|
692
|
+
gap: 4px;
|
|
693
|
+
margin-bottom: 12px;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/* Labels stay near-black rather than brand-colored: a form whose every label is
|
|
697
|
+
the brand color competes with the heading above it. The fix for "small, grey,
|
|
698
|
+
hard to read" is SIZE + INK, not color. */
|
|
699
|
+
.form-field label {
|
|
700
|
+
font-size: 16px;
|
|
701
|
+
font-weight: 700;
|
|
702
|
+
color: var(--brand-ink);
|
|
703
|
+
line-height: 1.4;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.form-field input,
|
|
707
|
+
.form-field textarea,
|
|
708
|
+
.form-field select {
|
|
709
|
+
font-size: 16px;
|
|
710
|
+
padding: 9px 11px;
|
|
711
|
+
border: 1.5px solid var(--field-border);
|
|
712
|
+
border-radius: 8px;
|
|
713
|
+
background: #fff;
|
|
714
|
+
color: var(--brand-ink);
|
|
715
|
+
font-family: inherit;
|
|
716
|
+
width: 100%;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.form-field input:hover,
|
|
720
|
+
.form-field textarea:hover,
|
|
721
|
+
.form-field select:hover {
|
|
722
|
+
border-color: var(--field-border-hover);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/* A 2px focus ring so keyboard position stays obvious against the now-darker
|
|
726
|
+
resting edge. */
|
|
727
|
+
.form-field input:focus-visible,
|
|
728
|
+
.form-field textarea:focus-visible,
|
|
729
|
+
.form-field select:focus-visible {
|
|
730
|
+
outline: 2px solid var(--brand-primary);
|
|
731
|
+
outline-offset: 1px;
|
|
732
|
+
border-color: var(--brand-primary);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.form-field input:disabled,
|
|
736
|
+
.form-field textarea:disabled,
|
|
737
|
+
.form-field select:disabled {
|
|
738
|
+
background: #f4f2ec;
|
|
739
|
+
border-color: #c7c3b8;
|
|
740
|
+
color: #6b6860;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/* The required marker. FIXED #c0392b (>5:1 on white), never the brand accent —
|
|
744
|
+
see the note in components/FormBits.tsx. */
|
|
745
|
+
.req-mark {
|
|
746
|
+
color: #c0392b;
|
|
747
|
+
font-weight: 800;
|
|
748
|
+
text-decoration: none;
|
|
749
|
+
border: 0; /* some user agents underline <abbr title> by default */
|
|
750
|
+
cursor: help;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/* --- Click-to-open field help (never a placeholder) ------------------------- */
|
|
754
|
+
|
|
755
|
+
.info-hint {
|
|
756
|
+
margin: 6px 0 0;
|
|
757
|
+
font-size: 15px;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/* FIXED #8a4b08 rather than the brand accent: this is small text on white, and
|
|
761
|
+
most brand accents fail AA at this size. */
|
|
762
|
+
.info-hint > summary {
|
|
763
|
+
display: inline-flex;
|
|
764
|
+
align-items: center;
|
|
765
|
+
gap: 7px;
|
|
766
|
+
cursor: pointer;
|
|
767
|
+
color: #8a4b08;
|
|
768
|
+
font-weight: 600;
|
|
769
|
+
list-style: none;
|
|
770
|
+
padding: 2px 0;
|
|
771
|
+
width: fit-content;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
.info-hint > summary::-webkit-details-marker {
|
|
775
|
+
display: none;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
.info-hint > summary:hover,
|
|
779
|
+
.info-hint > summary:focus-visible {
|
|
780
|
+
text-decoration: underline;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.info-hint-icon {
|
|
784
|
+
display: inline-flex;
|
|
785
|
+
align-items: center;
|
|
786
|
+
justify-content: center;
|
|
787
|
+
width: 20px;
|
|
788
|
+
height: 20px;
|
|
789
|
+
flex: 0 0 20px;
|
|
790
|
+
border-radius: 50%;
|
|
791
|
+
background: var(--brand-primary);
|
|
792
|
+
color: var(--brand-on-primary);
|
|
793
|
+
font-size: 13px;
|
|
794
|
+
font-weight: 800;
|
|
795
|
+
font-style: italic;
|
|
796
|
+
line-height: 1;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.info-hint-body {
|
|
800
|
+
margin-top: 8px;
|
|
801
|
+
padding: 12px 14px;
|
|
802
|
+
border: 1px solid #dcd9d1;
|
|
803
|
+
border-left: 4px solid var(--brand-primary);
|
|
804
|
+
border-radius: 8px;
|
|
805
|
+
background: #fbfdf8;
|
|
806
|
+
color: var(--brand-ink);
|
|
807
|
+
font-size: 16px;
|
|
808
|
+
line-height: 1.55;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
.info-hint-body code {
|
|
812
|
+
background: #eef2e8;
|
|
813
|
+
padding: 1px 5px;
|
|
814
|
+
border-radius: 4px;
|
|
815
|
+
font-size: 15px;
|
|
816
|
+
}
|
|
817
|
+
`;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Vitest config for the scaffolded project.
|
|
821
|
+
*
|
|
822
|
+
* Emitted for ONE reason that is not optional: vitest's default `exclude` covers
|
|
823
|
+
* `node_modules` / `dist` but NOT `.next`, so after the first `next build` the
|
|
824
|
+
* runner starts walking build output. It also pins `include` to the project's
|
|
825
|
+
* own source rather than everything on disk.
|
|
826
|
+
*/
|
|
827
|
+
const VITEST_CONFIG_TEMPLATE = `import { defineConfig } from "vitest/config";
|
|
828
|
+
|
|
829
|
+
export default defineConfig({
|
|
830
|
+
test: {
|
|
831
|
+
include: ["test/**/*.test.ts", "{app,components,lib}/**/*.test.ts"],
|
|
832
|
+
// .next is NOT in vitest's default exclude list — without this, the runner
|
|
833
|
+
// walks build output after the first \`next build\`.
|
|
834
|
+
exclude: ["node_modules/**", ".next/**", "dist/**"],
|
|
835
|
+
},
|
|
836
|
+
});
|
|
837
|
+
`;
|
|
838
|
+
/**
|
|
839
|
+
* The emitted enforcement half of the form standards.
|
|
840
|
+
*
|
|
841
|
+
* This is the part that survives contact with a future agent: `FormBits.tsx`
|
|
842
|
+
* makes the right thing easy, but only a test fails the build on the next form
|
|
843
|
+
* that hand-rolls a label. Source-level greps on purpose — the rules are about
|
|
844
|
+
* what the markup SAYS, and a render test would only cover the components it
|
|
845
|
+
* happens to mount.
|
|
846
|
+
*
|
|
847
|
+
* ⚠️ `__dirname` is NOT available here. The scaffolded package.json is
|
|
848
|
+
* `"type": "module"`, so the emitted test resolves its own directory via
|
|
849
|
+
* `fileURLToPath(import.meta.url)`. grantor's original used `__dirname` because
|
|
850
|
+
* that project is CommonJS; copying it verbatim would throw at run time.
|
|
851
|
+
*/
|
|
852
|
+
const FORM_STANDARDS_TEST_TEMPLATE = `/**
|
|
853
|
+
* {{brand_name}} form standards, enforced as tests rather than as a convention
|
|
854
|
+
* someone has to remember:
|
|
855
|
+
*
|
|
856
|
+
* - Optional is the DEFAULT. Never label a field "(optional)"; mark the
|
|
857
|
+
* required ones with a bright asterisk instead.
|
|
858
|
+
* - Help text is never a placeholder — it vanishes exactly when the user is
|
|
859
|
+
* trying to follow it. Use <Field help={...}> instead.
|
|
860
|
+
* - Input borders must clear the 3:1 WCAG non-text-contrast minimum.
|
|
861
|
+
*
|
|
862
|
+
* The primitives that make this easy live in components/FormBits.tsx. These
|
|
863
|
+
* greps are what catches the NEXT form someone adds by hand.
|
|
864
|
+
*/
|
|
865
|
+
import { describe, it, expect } from "vitest";
|
|
866
|
+
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
|
867
|
+
import { join, dirname } from "node:path";
|
|
868
|
+
import { fileURLToPath } from "node:url";
|
|
869
|
+
|
|
870
|
+
// NOT \`__dirname\` — this package is "type": "module", where it is undefined.
|
|
871
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
872
|
+
|
|
873
|
+
/** Every .tsx file under the project's own source directories. */
|
|
874
|
+
function sourceFiles(dir: string): string[] {
|
|
875
|
+
const abs = join(ROOT, dir);
|
|
876
|
+
if (!existsSync(abs)) return [];
|
|
877
|
+
const out: string[] = [];
|
|
878
|
+
for (const e of readdirSync(abs, { withFileTypes: true })) {
|
|
879
|
+
if (e.name === "node_modules" || e.name.startsWith(".")) continue;
|
|
880
|
+
const rel = join(dir, e.name);
|
|
881
|
+
if (e.isDirectory()) out.push(...sourceFiles(rel));
|
|
882
|
+
else if (e.name.endsWith(".tsx")) out.push(rel);
|
|
883
|
+
}
|
|
884
|
+
return out;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
const TSX = [...sourceFiles("app"), ...sourceFiles("components"), ...sourceFiles("lib")];
|
|
888
|
+
const read = (f: string) => readFileSync(join(ROOT, f), "utf8");
|
|
889
|
+
const css = () => read("app/globals.css");
|
|
890
|
+
|
|
891
|
+
// A scaffold starts with no forms, so an empty TSX list would make every grep
|
|
892
|
+
// below vacuously green. Fail loudly instead — "I examined nothing" is not a
|
|
893
|
+
// pass ([[zero-is-not-a-pass]]).
|
|
894
|
+
describe("form standards", () => {
|
|
895
|
+
it("actually has source files to check", () => {
|
|
896
|
+
expect(TSX.length).toBeGreaterThan(0);
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
it("no form label says '(optional)' — optional is the default, so say nothing", () => {
|
|
900
|
+
const offenders = TSX.filter((f) => {
|
|
901
|
+
if (f.endsWith("FormBits.tsx")) return false; // documents the rule
|
|
902
|
+
return /\\(optional\\)/i.test(read(f));
|
|
903
|
+
});
|
|
904
|
+
expect(offenders).toEqual([]);
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
it("no form marks required with a bare, uncoloured '*' in the label text", () => {
|
|
908
|
+
// \`Your name *</label>\` is invisible to a screen reader and the same colour
|
|
909
|
+
// as everything else. Use <Field required> / <Required /> instead.
|
|
910
|
+
const offenders = TSX.filter((f) => / \\*<\\/label>/.test(read(f)));
|
|
911
|
+
expect(offenders).toEqual([]);
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
it("no help text is smuggled in as a placeholder", () => {
|
|
915
|
+
// Placeholder text disappears the moment someone types. Put guidance in
|
|
916
|
+
// <Field help={...}>, which stays on screen while they fill the field.
|
|
917
|
+
const offenders = TSX.filter((f) => read(f).includes("placeholder="));
|
|
918
|
+
expect(offenders).toEqual([]);
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
it("the required marker is red and carries the word 'required' for screen readers", () => {
|
|
922
|
+
expect(css()).toMatch(/\\.req-mark\\s*\\{[^}]*color:\\s*#c0392b/);
|
|
923
|
+
|
|
924
|
+
const bits = read("components/FormBits.tsx");
|
|
925
|
+
expect(bits).toContain('title="required"');
|
|
926
|
+
expect(bits).toContain("(required)"); // the sr-only word behind the "*"
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
it("FormBits stays server-renderable — no 'use client'", () => {
|
|
930
|
+
// Adding the directive breaks NOTHING visibly — typecheck passes, the build
|
|
931
|
+
// passes, the page still returns 200. It just ships these components to the
|
|
932
|
+
// browser as JS for no reason. A change with no symptom is exactly the kind
|
|
933
|
+
// a test has to catch, because review won't.
|
|
934
|
+
expect(read("components/FormBits.tsx")).not.toMatch(/^\\s*["']use client["']/m);
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
it("input borders clear the 3:1 non-text contrast minimum", () => {
|
|
938
|
+
// #ccc on white is ~1.6:1 — the edge of the box genuinely isn't visible.
|
|
939
|
+
expect(css()).toMatch(/--field-border:\\s*#8f8b81/);
|
|
940
|
+
expect(css()).not.toMatch(/\\.form-field[^{]*\\{[^}]*border:\\s*1(\\.5)?px solid #ccc/);
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
it("the visually-hidden helper exists and does not use display:none", () => {
|
|
944
|
+
// display:none removes it from the accessibility tree too, which defeats
|
|
945
|
+
// the entire point of the sr-only word behind the required marker.
|
|
946
|
+
const block = css().slice(css().indexOf(".sr-only"));
|
|
947
|
+
expect(block).toContain("clip: rect(0, 0, 0, 0)");
|
|
948
|
+
expect(block.slice(0, block.indexOf("}"))).not.toContain("display: none");
|
|
949
|
+
});
|
|
950
|
+
});
|
|
951
|
+
`;
|
|
449
952
|
const APP_LAYOUT_TEMPLATE = `// Root layout — SEO baseline wiring per Z2W standing org requirement
|
|
450
953
|
// 2026-05-30. Every indexable page MUST export its own \`metadata\`; do not
|
|
451
954
|
// rely on these defaults to fill in per-page values.
|
|
@@ -458,6 +961,11 @@ const APP_LAYOUT_TEMPLATE = `// Root layout — SEO baseline wiring per Z2W stan
|
|
|
458
961
|
import type { Metadata, Viewport } from "next";
|
|
459
962
|
import { Analytics } from "@/lib/analytics/Analytics";
|
|
460
963
|
|
|
964
|
+
// Global styles. Body typography (18px / 1.5, per the standing Zero2Webmaster
|
|
965
|
+
// readability rule) lives in this file, NOT as an inline style on <body>, so
|
|
966
|
+
// there is one home for it rather than two that can drift.
|
|
967
|
+
import "./globals.css";
|
|
968
|
+
|
|
461
969
|
// Use \`||\` (not \`??\`) so a present-but-EMPTY env value falls back too. The
|
|
462
970
|
// scaffolded .env.local seeds NEXT_PUBLIC_SITE_URL="" until you fill it in,
|
|
463
971
|
// and \`"" ?? fallback\` keeps the empty string — which makes \`new URL("")\`
|
|
@@ -511,14 +1019,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|
|
511
1019
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(organizationJsonLd) }}
|
|
512
1020
|
/>
|
|
513
1021
|
</head>
|
|
514
|
-
<body
|
|
515
|
-
style={{
|
|
516
|
-
fontSize: "18px",
|
|
517
|
-
lineHeight: 1.5,
|
|
518
|
-
margin: 0,
|
|
519
|
-
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
520
|
-
}}
|
|
521
|
-
>
|
|
1022
|
+
<body>
|
|
522
1023
|
{children}
|
|
523
1024
|
{/* Fathom analytics (per [[fathom-analytics]]). \`<Analytics />\` renders
|
|
524
1025
|
the loader AND the RouteTracker that fires trackPageview() on every
|
|
@@ -963,6 +1464,13 @@ export function scaffoldNextjs(inputs, opts) {
|
|
|
963
1464
|
content: sub(PAGE_METADATA_MODULE_TEMPLATE, inputs, opts, spec),
|
|
964
1465
|
},
|
|
965
1466
|
{ path: "tsconfig.json", content: sub(TSCONFIG_TEMPLATE, inputs, opts, spec) },
|
|
1467
|
+
{ path: "vitest.config.ts", content: VITEST_CONFIG_TEMPLATE },
|
|
1468
|
+
{ path: "app/globals.css", content: globalsCss(spec.primaryColor) },
|
|
1469
|
+
{ path: "components/FormBits.tsx", content: sub(FORM_BITS_TEMPLATE, inputs, opts, spec) },
|
|
1470
|
+
{
|
|
1471
|
+
path: "test/form-standards.test.ts",
|
|
1472
|
+
content: sub(FORM_STANDARDS_TEST_TEMPLATE, inputs, opts, spec),
|
|
1473
|
+
},
|
|
966
1474
|
{ path: "app/layout.tsx", content: sub(APP_LAYOUT_TEMPLATE, inputs, opts, spec) },
|
|
967
1475
|
{ path: "app/page.tsx", content: sub(APP_PAGE_TEMPLATE, inputs, opts, spec) },
|
|
968
1476
|
{ path: "lib/analytics/utm.ts", content: sub(ANALYTICS_UTM_TEMPLATE, inputs, opts, spec) },
|
package/dist/standards.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface StandardsResolution {
|
|
|
51
51
|
* family — the safe default for anything else with `has_web_ui=true`.
|
|
52
52
|
*/
|
|
53
53
|
export declare function fathomEnvVarFor(projectType: ProjectType): string;
|
|
54
|
-
export declare const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.
|
|
54
|
+
export declare const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.19";
|
|
55
55
|
/**
|
|
56
56
|
* The canonical **Capture Learnings** block, emitted VERBATIM into every
|
|
57
57
|
* scaffolded `CLAUDE.md`.
|
package/dist/standards.js
CHANGED
|
@@ -326,7 +326,7 @@ const NEON_CAREFUL_BODY = `### Neon-careful (Neon Postgres)
|
|
|
326
326
|
// `zero2webmaster/z2w-agent-coordination`'s AGENT_PROTOCOL.md when the embedded
|
|
327
327
|
// block's mechanics change (drift-detection Signal A greps for this exact token).
|
|
328
328
|
// When you sync a newer canonical block below, bump this to match its comment.
|
|
329
|
-
export const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.
|
|
329
|
+
export const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.19";
|
|
330
330
|
/**
|
|
331
331
|
* The canonical **Capture Learnings** block, emitted VERBATIM into every
|
|
332
332
|
* scaffolded `CLAUDE.md`.
|
|
@@ -385,14 +385,14 @@ Full routing rubric, worked examples, and the Skill Vault's own commit conventio
|
|
|
385
385
|
*/
|
|
386
386
|
const AGENT_COORDINATION_BODY = `## Agent Coordination
|
|
387
387
|
|
|
388
|
-
<!-- z2w-agent-coordination canonical-block
|
|
388
|
+
<!-- z2w-agent-coordination canonical-block v0.1.19 -->
|
|
389
389
|
|
|
390
390
|
*(↓ copy this section, including this heading AND the HTML fingerprint comment above, into each participating project's \`CLAUDE.md\` and \`AGENTS.md\`. The fingerprint lets \`grep\` detect drift across projects.)*
|
|
391
391
|
|
|
392
392
|
This project participates in the Z2W cross-project coordination bulletin.
|
|
393
393
|
|
|
394
394
|
**At session start:**
|
|
395
|
-
1.
|
|
395
|
+
1. **Get a PRIVATE workspace — never do session work in the shared clone (v0.1.17).** If a clone exists at \`~/.cache/z2w-coordination\` OR at \`~/Desktop/Zero2Webmaster/AI/Cursor Projects/z2w-agent-coordination/\`, \`cd\` there; otherwise \`git clone --depth 1 git@github.com:zero2webmaster/z2w-agent-coordination.git ~/.cache/z2w-coordination\` (see §8.3). Then, from that clone, take a workspace of your own — \`WS="$(bash scripts/agent-workspace.sh {this-project-slug})"\` and \`cd "$WS"\`. **Do every read and write of this session inside \`$WS\`**, and publish at session end with \`bash scripts/publish-from-workspace.sh "{slug}: session {id} — {one-line summary}"\` (it commits, prints \`git show --numstat HEAD\` before publishing, then pushes \`HEAD:main\`, rebasing and retrying if another agent pushed first). **Why:** two shared working trees were serving ~40 agents, and one shared git index produced **seven concurrent-write sweeps in six weeks** — an agent's work published inside another project's commit, or silently reverted, with the victim's commit sometimes gone entirely. Staging narrowly does not prevent it and neither does intending to exclude a file (occurrence #7 said so in its own commit message and swept the file anyway); a worktree has its own index, so the failure class is gone rather than mitigated. Costs ~0.1 s and ~8 MB, shares the object store, no re-download. \`agent-workspace.sh\` also runs \`set-bulletin-commit-identity.sh\` for you (bot identity, set locally per clone, so bulletin commits don't skew Kerry's personal GitHub contribution graph) and arms a \`pre-commit\` guard that makes the shared tree **refuse** commits — if you see that refusal, follow the three commands it prints. **Inside \`$WS\`, \`git add -A\` is safe** (your index contains nothing but your own edits), which is what \`publish-from-workspace.sh\` uses.
|
|
396
396
|
2. Read \`projects/{this-project-slug}.md\` IN THIS ORDER:
|
|
397
397
|
a0. **\`## 📥 Needs attention\`** — the triage index, if the section exists (v0.1.15). It is pinned at the very top of the file and carries **one line per still-unhandled item addressed to this project**, each pointing at the section the full item lives in. Read it first as your routing table: it tells you *what* is waiting and *where*, so you don't have to scan several long sections hoping to spot an ask aimed at you. Handle \`ACTION\` items before \`Q\` before \`FYI\`. **As you handle each item, delete its line** — the block is a queue, not a log (the full item + your \`↳\` reply stay in their own section; git keeps the history). Absent or empty section = nothing addressed to you is outstanding. Schema in §8.11. *(An open incident in \`## Incidents\` still outranks everything here — see a. next.)*
|
|
398
398
|
a. **\`## Incidents\`** — if the section exists (v0.1.13). Any incident whose latest status line is \`open\` (i.e. no \`↳ resolved\` under it) means something is broken in production RIGHT NOW. Surface every open incident to Kerry before anything else, and prefer triaging it over new feature work — **a production incident outranks Kerry's inbox.** If the section is absent, there are no incidents; move on. (Incidents are written by the observability bridge or by an agent that spots a live problem — see §8.8 for the schema, dedup key, status lifecycle, and PII-strip rule.)
|
|
@@ -447,13 +447,17 @@ This project participates in the Z2W cross-project coordination bulletin.
|
|
|
447
447
|
- **Re-check \`## Open questions\` for new \`[→ this-project]\` entries that arrived since session start (v0.1.10).** A *dedicated message from another agent* lands here — the cross-agent analogue of Kerry's inbox dispatch. It's in your OWN already-loaded project file, so the cost is near-zero. Reply (\`↳\` under the question) and, if the ask needs more than this session has room for, move it into \`## Open follow-ups owned by this project\` so it survives. (You do NOT need to re-read \`global.md\` at session end — broadcast heads-ups are a session-*start* read; this end-of-session check is deliberately scoped to your own lean project file, not the large shared \`global.md\`.)
|
|
448
448
|
- **Updating the bulletin at session end is a MANDATORY standing wrap step — never a question you put to Kerry (v0.1.11).** It ranks with committing your code, not with optional extras. Do NOT end a session by asking *"want me to update the bulletin too?"* or *"that wasn't in your wrap list — say the word"* — decide with the two tiers below and just do it. The one and only time you skip is a purely read-only / conversational session that changed no files and no project state — and even then you **skip silently, you do not ask**. (Kerry, 2026-07-05: *"they should know to either do it or not do it"* — this rule is that decision, made once, so no agent defers it back to him.)
|
|
449
449
|
- **Tier 1 — ALWAYS (any session that did real work on this project):** rewrite \`## Current focus\` in place — one short paragraph (or 1–3 bullets) of what this project is working on right now, stamped with the current date + session id — and add/close your \`## Active sessions\` entry. Cheap, and it is the field the \`agents.z2w.us\` dashboard reads: a stale timestamp signals "agent ran but said nothing," which reads differently from "no agent ran," and an empty/stale Current focus erodes Kerry's trust in the dashboard.
|
|
450
|
+
> ⚠️ **Anchor the rewrite on the heading as a whole LINE (\`^## Current focus$\`), never on the bare substring.** Section names are quoted inline in prose all the time — a substring match will find a neighbouring bullet's mention of \`## Current focus\`, which sits above the real heading, and replacing from there silently deletes the heading and truncates that bullet. The fingerprint of this having happened is a **pair**: a missing H2 and a sentence cut mid-clause just above where it should be.
|
|
451
|
+
>
|
|
452
|
+
> *Filed by \`site-control\` 2026-07-30, after this silently emptied their card on \`agents.z2w.us\` while the file itself still parsed and read fine — then reproduced it once more while fixing it, with the mechanism already in front of them. \`## Current focus\` is simultaneously the most-quoted section name and the only one written by full replacement, which makes it the most exposed section in the schema. **Now asserted:** \`scripts/check-file-sizes.sh\` fails the push if any participating \`projects/*.md\` is missing a required H2 as a line-anchored heading.*
|
|
453
|
+
|
|
450
454
|
- **Tier 2 — ADDITIONALLY, whenever the session produced anything another agent or Kerry would act on:** add a \`## Recent commits\` entry (if you shipped) and append any new heads-ups / \`[→ {project}]\` / \`[→ Kerry]\` items — plus the \`## 📥 Needs attention\` line in each recipient's file.
|
|
451
455
|
**The trigger is "carries cross-project signal," NOT "committed code" (v0.1.15).** A decision, a heads-up, a capability→home mapping, a naming or scope change, a new build-target, an answered question, a discovered gotcha — all qualify, and **synthesis, audit, and planning sessions routinely commit zero code yet carry the highest cross-project value.** An agent that gates Tier 2 on \`git log\` says nothing exactly when it has the most to say. Skip Tier 2 only when the session genuinely produced nothing anyone else would act on (pure local exploration with no outcome) — and Tier 1 still runs even then. *(Adopted 2026-07-25 from \`z2w-starter-kit\`'s 2026-07-11 ask on Kerry's instruction, after a zero-commit \`z2w-forms\` extraction audit generated a new build-target, a Kerry decision, a delivery model, a naming fix, and heads-ups landing on three other projects — none of which a code-gated wrap-up would have published.)*
|
|
452
456
|
- **Keep \`## Integrations\` + your Live status current — a never-ask standing step, exactly like \`## Current focus\` (v0.1.14).** If this session changed how this project relates to another Z2W app — it started consuming an engine/service, stopped using one, or became a provider another app now depends on — update your file's \`## Integrations\` edges. If the project's lifecycle changed — scaffolded → live in prod, went dormant, retired — update the **Live status** line and its date. This is the capture mechanism behind the ecosystem dependency map + live-status badges on \`agents.z2w.us\`; a stale edge or status silently misleads every other agent (real 2026-07-20 miss: an audit called a LIVE engine "unbuilt" because no single place recorded its status). Decide and do it — do not ask. Absent section = nothing to report yet; create it lazily the first time you have an edge or a status to record. Schema + conventions in §8.10.
|
|
453
457
|
- **Size discipline (v0.1.11):** before appending, if \`projects/{this-project}.md\` is approaching ~200 KB (the point where agents can no longer \`Read\` it in one call), trim FIRST — archive old \`## Active sessions\` and \`## Recent commits\` entries and resolved \`## Open questions\` threads into \`projects/{this-project}-archive.md\` (a separate, commit-flagged operation). Keep your live file readable whole. \`## Current focus\` is rewritten in place (never appended), which is the main thing that keeps a project file from growing without bound — never let a single field accumulate a multi-session history.
|
|
454
458
|
- **Your project file is a COORDINATION SURFACE, not a log (v0.1.22).** The test, and it is a good one: **"would another agent load this file to answer a question?"** Session recaps, npm publish state, test counts, defect post-mortems and build narrative all fail it — that is \`STATUS.md\` / \`CHANGELOG.md\` content in your own repo, and duplicating it here makes ~40 other agents pay for it on every read while approximately none of them need it. Two bright lines:
|
|
455
459
|
1. **\`## Current focus\` and \`## Active sessions\` answer "what is this project doing, and is it alive" — nothing more.** Current focus ≲1.5 KB (it renders on Kerry's phone); each Active-sessions entry ≲400 bytes — one line: what shipped, the test count, a commit SHA. The narrative goes in your own repo, where you are already writing it.
|
|
456
|
-
2. **Archive a thread in the same commit that resolves it.** Not in a later sweep. If you post a closing \`↳\`, you move the thread. This is the only self-enforcing rule of the set, because the agent that knows a thread is done is the agent closing it. *(Do NOT auto-archive on "reply older than N days" — a reply is not a resolution, and several of the longest-running live threads in this bulletin have replies. Resolution is a judgment, so the action belongs at the moment of judgment.)* **"Resolved" means BOTH parties are done
|
|
460
|
+
2. **Archive a thread in the same commit that resolves it.** Not in a later sweep. If you post a closing \`↳\`, you move the thread. This is the only self-enforcing rule of the set, because the agent that knows a thread is done is the agent closing it. *(Do NOT auto-archive on "reply older than N days" — a reply is not a resolution, and several of the longest-running live threads in this bulletin have replies. Resolution is a judgment, so the action belongs at the moment of judgment.)* **"Resolved" means BOTH parties are done. The test is mechanical: never archive a thread that has a live \`## 📥 Needs attention\` line pointing at it — in your file or in anyone else's.** A live queue line *is* the definition of an unresolved item, so if one references the section, the thread stays. Note what this asks of you: **check the queue, not your memory of the conversation.** An agent mid-trim is optimising for bytes and reading thread bodies for signs of resolution, and the evidence of live-ness is usually hundreds of lines away in a queue block — or in a file you cannot see at all. *(Two findings, three days apart, from the same project. 2026-07-29: \`z2w-starter-kit\`'s careful trim — which explicitly spared every thread with a live queue line — archived the very thread carrying its own unanswered proposal, because the waiting line was in the maintainer's queue. 2026-07-30, three days after proposing the original asker-side rule: the same trim archived \`z2w-observability-bridge\`'s open question, where starter-kit was the **askee**. That direction is quieter, not louder — **the asker cannot read your file at all**, so nothing anywhere signals it; the bridge would have waited indefinitely, and the only reason it did not is that someone went looking for the body in order to answer it. The role-free wording is \`z2w-starter-kit\`'s, adopted verbatim.)* **Corollary — the missing line is the symmetric failure.** This rule makes the queue block load-bearing for archiving, which raises the cost of a thread that has **no** queue line: \`event-engine\`'s 2026-07-14 registry ask carried none and sat 16 days. A line without a body and a body without a line are the same defect seen from two sides, so file the line when you file the thread.
|
|
457
461
|
|
|
458
462
|
**Enforced at push, not by good intentions:** \`.github/workflows/file-size-check.yml\` runs \`scripts/check-file-sizes.sh\` on every push touching \`projects/**.md\` or \`global.md\` — hard-fail over 256 KB, warning over 200 KB, \`*-archive.md\` exempt by design. *(Adopted 2026-07-29 from \`z2w-starter-kit\`'s 2026-07-27 proposal, made after it trimmed its own file three times in one month and re-grew it ~70 KB in a single session. Its rule 3 — a per-session soft byte budget — is deliberately NOT adopted: it fails for exactly the reason the v0.1.11 rule above fails, namely that it asks an agent to measure mid-task, and agents do not measure mid-task. Push is the one moment measurement is automatic and free. The check belongs to the repo it guards, so the maintainer wrote it rather than handing the offer back.)*
|
|
459
463
|
- \`git commit -m "{this-project}: {summary}"\` (see §8.2 for agent-identifier format in commit messages and session entries) and \`git push\`.
|