@zero2webmaster/starter-kit 0.1.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/LICENSE +38 -0
- package/README.md +89 -0
- package/dist/brand.d.ts +72 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +198 -0
- package/dist/brand.js.map +1 -0
- package/dist/brief.d.ts +14 -0
- package/dist/brief.d.ts.map +1 -0
- package/dist/brief.js +47 -0
- package/dist/brief.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +82 -0
- package/dist/cli.js.map +1 -0
- package/dist/confirm.d.ts +45 -0
- package/dist/confirm.d.ts.map +1 -0
- package/dist/confirm.js +382 -0
- package/dist/confirm.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/parse-brief.d.ts +32 -0
- package/dist/parse-brief.d.ts.map +1 -0
- package/dist/parse-brief.js +298 -0
- package/dist/parse-brief.js.map +1 -0
- package/dist/scaffolders/cf-pages.d.ts +9 -0
- package/dist/scaffolders/cf-pages.d.ts.map +1 -0
- package/dist/scaffolders/cf-pages.js +259 -0
- package/dist/scaffolders/cf-pages.js.map +1 -0
- package/dist/scaffolders/cf-worker.d.ts +4 -0
- package/dist/scaffolders/cf-worker.d.ts.map +1 -0
- package/dist/scaffolders/cf-worker.js +112 -0
- package/dist/scaffolders/cf-worker.js.map +1 -0
- package/dist/scaffolders/common.d.ts +39 -0
- package/dist/scaffolders/common.d.ts.map +1 -0
- package/dist/scaffolders/common.js +441 -0
- package/dist/scaffolders/common.js.map +1 -0
- package/dist/scaffolders/index.d.ts +18 -0
- package/dist/scaffolders/index.d.ts.map +1 -0
- package/dist/scaffolders/index.js +40 -0
- package/dist/scaffolders/index.js.map +1 -0
- package/dist/scaffolders/library.d.ts +4 -0
- package/dist/scaffolders/library.d.ts.map +1 -0
- package/dist/scaffolders/library.js +122 -0
- package/dist/scaffolders/library.js.map +1 -0
- package/dist/scaffolders/nextjs.d.ts +10 -0
- package/dist/scaffolders/nextjs.d.ts.map +1 -0
- package/dist/scaffolders/nextjs.js +395 -0
- package/dist/scaffolders/nextjs.js.map +1 -0
- package/dist/scaffolders/protocol-repo.d.ts +4 -0
- package/dist/scaffolders/protocol-repo.d.ts.map +1 -0
- package/dist/scaffolders/protocol-repo.js +162 -0
- package/dist/scaffolders/protocol-repo.js.map +1 -0
- package/dist/scaffolders/python-service.d.ts +4 -0
- package/dist/scaffolders/python-service.d.ts.map +1 -0
- package/dist/scaffolders/python-service.js +144 -0
- package/dist/scaffolders/python-service.js.map +1 -0
- package/dist/scaffolders/wp-plugin.d.ts +4 -0
- package/dist/scaffolders/wp-plugin.d.ts.map +1 -0
- package/dist/scaffolders/wp-plugin.js +268 -0
- package/dist/scaffolders/wp-plugin.js.map +1 -0
- package/dist/standards.d.ts +65 -0
- package/dist/standards.d.ts.map +1 -0
- package/dist/standards.js +335 -0
- package/dist/standards.js.map +1 -0
- package/dist/substitute.d.ts +37 -0
- package/dist/substitute.d.ts.map +1 -0
- package/dist/substitute.js +98 -0
- package/dist/substitute.js.map +1 -0
- package/dist/summary.d.ts +20 -0
- package/dist/summary.d.ts.map +1 -0
- package/dist/summary.js +191 -0
- package/dist/summary.js.map +1 -0
- package/dist/templates.d.ts +30 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +123 -0
- package/dist/templates.js.map +1 -0
- package/dist/wizard.d.ts +12 -0
- package/dist/wizard.d.ts.map +1 -0
- package/dist/wizard.js +158 -0
- package/dist/wizard.js.map +1 -0
- package/dist/writer.d.ts +62 -0
- package/dist/writer.d.ts.map +1 -0
- package/dist/writer.js +367 -0
- package/dist/writer.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// z2w-starter-kit standards-conflict resolver.
|
|
2
|
+
//
|
|
3
|
+
// Pure function that resolves which organization-wide standards apply to a
|
|
4
|
+
// scaffolded project and renders the standards markdown body. The body
|
|
5
|
+
// replaces the `<!-- STANDARDS_BLOCK -->` marker that the Step 4 scaffolders
|
|
6
|
+
// emit inside the generated CLAUDE.md. Mirrors the conditional logic in the
|
|
7
|
+
// [[instantiate-z2w-project]] skill v1.1.0 Step 6.
|
|
8
|
+
//
|
|
9
|
+
// Standards covered (per skill v1.1.0, including the 2026-05-30 SEO baseline
|
|
10
|
+
// + email-service-router additions):
|
|
11
|
+
//
|
|
12
|
+
// - portable-stack — always for non-WP types
|
|
13
|
+
// - fathom — if hasWebUi=true
|
|
14
|
+
// - uptime-kuma — any deploy target (cf-worker, cf-pages, nextjs, python-service)
|
|
15
|
+
// - neon-careful — if dbStrategy=neon-postgres
|
|
16
|
+
// - agent-coordination — if participateInBulletin=true
|
|
17
|
+
// - seo-baseline — non-WP web UI with indexable surface (nextjs, cf-pages)
|
|
18
|
+
// - email-service — every project that may send mail (skip library + protocol-repo)
|
|
19
|
+
// - text-size — always (Z2W standing org rule)
|
|
20
|
+
//
|
|
21
|
+
// Pure-functional: no filesystem reads, no template lookups, no side effects.
|
|
22
|
+
// The Step 6 writer composes this resolver's output with the per-type scaffolder
|
|
23
|
+
// output by `.replace()`ing the marker.
|
|
24
|
+
import { applySubstitutions } from "./substitute.js";
|
|
25
|
+
/** Order standards appear in the rendered body + the decisions log. */
|
|
26
|
+
const STANDARD_ORDER = [
|
|
27
|
+
"portable-stack",
|
|
28
|
+
"fathom",
|
|
29
|
+
"uptime-kuma",
|
|
30
|
+
"neon-careful",
|
|
31
|
+
"agent-coordination",
|
|
32
|
+
"seo-baseline",
|
|
33
|
+
"email-service",
|
|
34
|
+
"text-size",
|
|
35
|
+
];
|
|
36
|
+
const TITLES = {
|
|
37
|
+
"portable-stack": "Portable-stack defaults (non-WP)",
|
|
38
|
+
fathom: "Fathom analytics",
|
|
39
|
+
"uptime-kuma": "Uptime Kuma monitor",
|
|
40
|
+
"neon-careful": "Neon-careful (Neon Postgres)",
|
|
41
|
+
"agent-coordination": "Agent Coordination (cross-project bulletin)",
|
|
42
|
+
"seo-baseline": "SEO baseline (non-WP web UI)",
|
|
43
|
+
"email-service": "Email service selection",
|
|
44
|
+
"text-size": "Text size (readability)",
|
|
45
|
+
};
|
|
46
|
+
const DEPLOY_TARGETS = [
|
|
47
|
+
"cf-worker",
|
|
48
|
+
"cf-pages",
|
|
49
|
+
"nextjs",
|
|
50
|
+
"python-service",
|
|
51
|
+
];
|
|
52
|
+
const SEO_BASELINE_TYPES = ["nextjs", "cf-pages"];
|
|
53
|
+
const NO_EMAIL_TYPES = ["library", "protocol-repo"];
|
|
54
|
+
function checkPortableStack(inputs) {
|
|
55
|
+
if (inputs.projectType === "wp-plugin") {
|
|
56
|
+
return {
|
|
57
|
+
applies: false,
|
|
58
|
+
reason: "wp-plugin uses WordPress conventions, not the portable-stack posture",
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
applies: true,
|
|
63
|
+
reason: `non-WP type (${inputs.projectType}) — portable-stack posture applies`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function checkFathom(inputs) {
|
|
67
|
+
if (!inputs.hasWebUi) {
|
|
68
|
+
return { applies: false, reason: "hasWebUi=false — no analytics surface" };
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
applies: true,
|
|
72
|
+
reason: `hasWebUi=true — Fathom env var: ${fathomEnvVarFor(inputs.projectType)}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function checkUptimeKuma(inputs) {
|
|
76
|
+
if (!DEPLOY_TARGETS.includes(inputs.projectType)) {
|
|
77
|
+
return {
|
|
78
|
+
applies: false,
|
|
79
|
+
reason: `${inputs.projectType} has no deploy target — no /health to monitor`,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
applies: true,
|
|
84
|
+
reason: `${inputs.projectType} is a deploy target — Kuma monitor needed post-deploy`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function checkNeonCareful(inputs) {
|
|
88
|
+
if (inputs.dbStrategy !== "neon-postgres") {
|
|
89
|
+
return {
|
|
90
|
+
applies: false,
|
|
91
|
+
reason: `dbStrategy=${inputs.dbStrategy} — Neon-careful discipline N/A`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
applies: true,
|
|
96
|
+
reason: "dbStrategy=neon-postgres — /health must stay DB-free; pool size 1",
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function checkAgentCoordination(inputs) {
|
|
100
|
+
if (!inputs.participateInBulletin) {
|
|
101
|
+
return {
|
|
102
|
+
applies: false,
|
|
103
|
+
reason: "participateInBulletin=false — project not on the bulletin",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
applies: true,
|
|
108
|
+
reason: "participateInBulletin=true — canonical block stamped verbatim",
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function checkSeoBaseline(inputs) {
|
|
112
|
+
if (!SEO_BASELINE_TYPES.includes(inputs.projectType)) {
|
|
113
|
+
return {
|
|
114
|
+
applies: false,
|
|
115
|
+
reason: `${inputs.projectType} has no public indexable HTML surface`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (!inputs.hasWebUi) {
|
|
119
|
+
return {
|
|
120
|
+
applies: false,
|
|
121
|
+
reason: `${inputs.projectType} but hasWebUi=false — no indexable pages`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
applies: true,
|
|
126
|
+
reason: `${inputs.projectType} with hasWebUi=true — full 7-item baseline per 2026-05-30 standing org requirement`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function checkEmailService(inputs) {
|
|
130
|
+
if (NO_EMAIL_TYPES.includes(inputs.projectType)) {
|
|
131
|
+
return {
|
|
132
|
+
applies: false,
|
|
133
|
+
reason: `${inputs.projectType} won't send mail — router pointer unnecessary`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
applies: true,
|
|
138
|
+
reason: "any type that may send mail — route through [[email-service-router]]",
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function checkTextSize() {
|
|
142
|
+
return { applies: true, reason: "Z2W standing org rule — applies to every project" };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Fathom env var name per framework. Mirrors skill v1.1.0's Step 6 conditional
|
|
146
|
+
* wording: `NEXT_PUBLIC_FATHOM_SITE_ID` for Next.js, hard-coded inline for
|
|
147
|
+
* cf-pages static HTML, `PUBLIC_FATHOM_SITE_ID` for the Vite/SvelteKit/Astro
|
|
148
|
+
* family — the safe default for anything else with `has_web_ui=true`.
|
|
149
|
+
*/
|
|
150
|
+
export function fathomEnvVarFor(projectType) {
|
|
151
|
+
if (projectType === "nextjs")
|
|
152
|
+
return "NEXT_PUBLIC_FATHOM_SITE_ID";
|
|
153
|
+
if (projectType === "cf-pages") {
|
|
154
|
+
return "inline `<script>` in `index.html` (no env var; static HTML)";
|
|
155
|
+
}
|
|
156
|
+
return "PUBLIC_FATHOM_SITE_ID";
|
|
157
|
+
}
|
|
158
|
+
// ── Canonical bodies ────────────────────────────────────────────────────────
|
|
159
|
+
// Each body mirrors the corresponding subsection of the
|
|
160
|
+
// [[instantiate-z2w-project]] skill v1.1.0 → "Standards block reference".
|
|
161
|
+
// Bodies use `{{placeholder}}` tokens where substitution is needed; everything
|
|
162
|
+
// else is verbatim from the skill.
|
|
163
|
+
const PORTABLE_STACK_BODY = `### Portable-stack defaults (non-WP)
|
|
164
|
+
|
|
165
|
+
> **Portability posture:** standard Postgres (not Neon Auth / Supabase Edge Functions / Vercel Postgres / Cloudflare D1 / branded SQL); S3-compatible storage (not Vercel Blob / Supabase Storage); Node runtime over Edge unless required; dotenv-style config (not UI-only secrets); written exit plan from day one. See [[portable-stack]] for the full posture.`;
|
|
166
|
+
const FATHOM_BODY = `### Fathom analytics (web UI)
|
|
167
|
+
|
|
168
|
+
> **Analytics:** Fathom Analytics is the single source of truth for this project. Env var name: {{fathom_env_var}}. SPA pattern: \`data-auto="false"\` on the Fathom script, then manual \`trackPageview()\` on route change. One Fathom site = one deployment. See [[fathom-analytics]] for details.`;
|
|
169
|
+
const UPTIME_KUMA_BODY = `### Uptime Kuma monitor (deploy target)
|
|
170
|
+
|
|
171
|
+
> **Uptime monitoring:** Add an HTTP(s)-Keyword monitor in Kerry's self-hosted Uptime Kuma after first deploy. Defaults: 60s heartbeat, 2 retries, 60s retry interval, 48s timeout, accepted status 200-299. Point at \`/health\` — never the main URL. See [[uptime-kuma-monitor]] for the form-by-form walkthrough.`;
|
|
172
|
+
const NEON_CAREFUL_BODY = `### Neon-careful (Neon Postgres)
|
|
173
|
+
|
|
174
|
+
> **Neon discipline:** \`/health\` must NOT touch the database (Neon Free has a 100 CU-hour monthly quota; routine probes burn through it). Pool size 1 for monitoring contexts. No scheduled jobs querying DB more than absolutely necessary. See [[neon-postgres]] for the full discipline.`;
|
|
175
|
+
const AGENT_COORDINATION_BODY = `### Agent Coordination (cross-project bulletin participation)
|
|
176
|
+
|
|
177
|
+
> **Cross-project coordination:** This project participates in the Z2W cross-project coordination bulletin at \`zero2webmaster/z2w-agent-coordination\`. The canonical protocol body lives in that repo's \`AGENT_PROTOCOL.md\` — read it at session start for the current version and section list. Reference conventions by NAME — the §-numbers below are parenthetical breadcrumbs that may renumber upstream.
|
|
178
|
+
>
|
|
179
|
+
> **Agent identifier:** This agent identifies as \`{{slug}} agent\` per the inter-agent identifier convention (see §8.2). Optional \` #{N}\` chat-number suffix when Kerry has labeled the chat. Opaque tags only when disambiguating multiple anonymous parallel sessions. §8.2 specifies the verbatim formats for three contexts: bulletin "Active sessions" entries, bulletin reply markers (\`↳ ({reply-at}, {agent-name}):\`), and commit messages (\`{{slug}}: {summary}\`). Defer to AGENT_PROTOCOL.md for those formats — do not paraphrase.
|
|
180
|
+
>
|
|
181
|
+
> **Inter-agent message header convention:** every inter-agent message Kerry couriers (chat-to-chat relay) MUST begin with a \`To:\` / \`From:\` / \`Re:\` header so Kerry can route by reading the To: line alone (see §8.4). Bulletin-posted replies keep their concise inline format (the \`[→ {their-project}]\` prefix on the question + the \`↳ (..., {agent-name}):\` marker on the reply) — the header convention is courier-mode only.
|
|
182
|
+
>
|
|
183
|
+
> **At session start:**
|
|
184
|
+
> 1. Resolve the bulletin clone location per the 3-step rule (see §8.3):
|
|
185
|
+
> - If \`~/.cache/z2w-coordination/\` OR \`~/Desktop/Zero2Webmaster/AI/Cursor Projects/z2w-agent-coordination/\` exists, use it (\`cd\` there + \`git pull --ff-only\`).
|
|
186
|
+
> - Otherwise clone to \`~/.cache/z2w-coordination\`.
|
|
187
|
+
> - If \`~/.cache/\` isn't writable in this sandbox, fall back to \`~/.claude/coordination/\` and document the deviation.
|
|
188
|
+
> 2. Read \`projects/{{slug}}.md\` — surface to Kerry anything in "Open questions" tagged for this project, any "Heads-ups" not yet ACK'd, and any other-session entries in "Active sessions".
|
|
189
|
+
> 3. Read \`global.md\` — surface cross-project heads-ups.
|
|
190
|
+
>
|
|
191
|
+
> **During session:**
|
|
192
|
+
> - If a coordination need surfaces, append to the relevant section in memory and persist at session end.
|
|
193
|
+
> - Questions to another project's agent go in THEIR project file's "Open questions" section with \`[→ {their-project}]\` prefix.
|
|
194
|
+
> - **Replies belong under the original question in the asker's project file** — do NOT mirror-and-reply in your own file (that fragments discovery).
|
|
195
|
+
>
|
|
196
|
+
> **At session end:**
|
|
197
|
+
> - Update "Active sessions" (your entry, or mark complete).
|
|
198
|
+
> - Update "Recent commits" if this session shipped.
|
|
199
|
+
> - Append any new heads-ups, open questions, or follow-ups.
|
|
200
|
+
> - Commit with the \`{{slug}}: {summary}\` format (see §8.2) and \`git push\`.
|
|
201
|
+
> - **Auto-push hook race:** if this project has a post-commit hook that auto-pushes the bulletin clone, expect it to race your explicit \`git push\` and grab the ref lock first. The commit still lands — verify with \`git log origin/main\` rather than re-pushing.
|
|
202
|
+
>
|
|
203
|
+
> **Hard rules (read first):**
|
|
204
|
+
> - **No secrets, ever.** Operational metadata only. Detect-and-redact on \`sk_*\`, \`pk_*\`, \`rk_*\`, \`whsec_*\`, \`xoxb-*\`, \`tbl[A-Za-z0-9]{14}\`, \`pat_*\`, etc.
|
|
205
|
+
> - **Private repo only.** The bulletin must remain \`--visibility private\`.
|
|
206
|
+
> - **Never edit another project's file directly.** Cross-project signaling goes through \`[→ {their-project}]\` prefixes in the target's "Open questions" section.
|
|
207
|
+
> - **Append-only within sections.** Trimming expired entries is a separate operation flagged in the commit message.
|
|
208
|
+
>
|
|
209
|
+
> See \`~/Desktop/Zero2Webmaster/AI/Cursor Projects/z2w-agent-coordination/AGENT_PROTOCOL.md\` for the canonical protocol body.`;
|
|
210
|
+
const SEO_BASELINE_BODY = `### SEO baseline (non-WP web UI)
|
|
211
|
+
|
|
212
|
+
> **SEO is non-negotiable from v1 (standing org requirement 2026-05-30).** WordPress sites get SEO from RankMath; non-WP web apps have no equivalent — every element must be built in deliberately at instantiation. SEO is NOT a later task.
|
|
213
|
+
>
|
|
214
|
+
> **The 7 requirements (every indexable page must satisfy all of them):**
|
|
215
|
+
>
|
|
216
|
+
> 1. **Server-rendered HTML (highest priority).** Primary content present in the initial HTML response via SSR or SSG. NOT client-only rendering. If the content isn't in "View Source," it's a defect. Default to SSG for static content, SSR for dynamic content; reserve client rendering for genuinely interactive, non-indexable UI.
|
|
217
|
+
> 2. **Per-page metadata via the framework's Metadata API** (Next.js \`metadata\` / \`generateMetadata\` — not hand-rolled \`<head>\` tags). Unique intentional title (not just brand name repeated), unique meta description, canonical URL, Open Graph and Twitter Card tags (title + description + image). Never inherit a generic default. Dynamic pages generate metadata from their content.
|
|
218
|
+
> 3. **On-page structure.** Exactly one \`<h1>\` stating the page's primary topic. Logical heading hierarchy (H1 → H2 → H3, no skipped levels, no headings used for styling). Semantic HTML (\`<main>\`, \`<nav>\`, \`<article>\`, \`<header>\`, \`<footer>\`).
|
|
219
|
+
> 4. **Images.** Descriptive contextual alt text on every meaningful image (not the filename, not "image"). Decorative images use \`alt=""\`. Use Next.js \`<Image>\` for proper sizing + lazy loading.
|
|
220
|
+
> 5. **Structured data (JSON-LD).** Include where content type warrants it: \`Organization\`, \`Article\`, \`Event\`, \`Product\`, \`BreadcrumbList\`. Match schema type to the actual content.
|
|
221
|
+
> 6. **Site-level.** \`sitemap.xml\` (Next.js: \`app/sitemap.ts\`) lists all indexable pages. \`robots.txt\` (Next.js: \`app/robots.ts\`) references the sitemap. Production indexable; staging/preview **MUST emit \`noindex\`** (gate on \`VERCEL_ENV !== 'production'\` / \`CF_PAGES_BRANCH !== 'main'\`).
|
|
222
|
+
> 7. **Analytics.** Fathom snippet present and firing (per [[fathom-analytics]]). NOT GA, NOT Plausible, NOT PostHog.
|
|
223
|
+
>
|
|
224
|
+
> **Scaffolded at instantiation** (already shipped in {{slug}}'s file tree): \`app/layout.tsx\` (root \`metadata\`), \`app/page.tsx\` (per-page \`metadata\`), \`app/sitemap.ts\`, \`app/robots.ts\`, OG image, \`SEO-CHECKLIST.md\`, Fathom env var wired. The \`SEO-CHECKLIST.md\` documents the per-page workflow so adding a new page forces title / description / H1 / image alt text rather than letting them be forgotten.
|
|
225
|
+
>
|
|
226
|
+
> **Pre-launch audit (run before any go-live):**
|
|
227
|
+
> - [ ] Indexable pages render primary content in the RAW HTML response (verify with \`curl\`, not the rendered DOM)
|
|
228
|
+
> - [ ] Every page has a unique intentional title + meta description (no duplicates, no defaults)
|
|
229
|
+
> - [ ] Exactly one \`<h1>\` per page; heading hierarchy logical, no skipped levels
|
|
230
|
+
> - [ ] Canonical URL set on every page
|
|
231
|
+
> - [ ] OG + Twitter Card tags present, image resolves
|
|
232
|
+
> - [ ] Meaningful images have descriptive alt text; decorative images have \`alt=""\`
|
|
233
|
+
> - [ ] JSON-LD present where warranted, validates in Google Rich Results test
|
|
234
|
+
> - [ ] \`sitemap.xml\` generates correctly; \`robots.txt\` references it
|
|
235
|
+
> - [ ] Production indexable; preview/staging NOT indexable
|
|
236
|
+
> - [ ] Fathom snippet firing (verified in Fathom dashboard with a test pageview)
|
|
237
|
+
> - [ ] Core Web Vitals reasonable (no obvious CLS, oversized images, render-blocking — see [[web-perf]])
|
|
238
|
+
>
|
|
239
|
+
> **Scope:** applies to every Z2W non-WP web app with a public indexable surface. Does NOT apply to: WordPress sites (RankMath), API-only services with no HTML surface, CLI libraries, protocol repos, Cloudflare Workers without a public HTML response.`;
|
|
240
|
+
const EMAIL_SERVICE_BODY = `### Email service selection (any project that will send mail)
|
|
241
|
+
|
|
242
|
+
> **Email service:** Kerry's portfolio has FOUR sanctioned email services covering distinct sweet spots — FluentCRM (WP marketing/CRM), Amazon SES (cheap high-volume transactional), Resend (developer-friendly transactional + NextAuth magic links + React Email), Cloudflare Email Service (Workers-native send/receive). Before wiring any email feature in this project — magic-link auth, transactional notification, marketing broadcast, anything — load [[email-service-router]] and walk the decision matrix. Do NOT introduce a fifth service (SendGrid, Mailgun, Postmark, Mailchimp, MailerSend, Brevo/Sendinblue, etc.) — the router skill explains why and routes to the right one of the four.`;
|
|
243
|
+
const TEXT_SIZE_BODY = `### Text size (always)
|
|
244
|
+
|
|
245
|
+
> **Readability:** per Z2W standing org rule, all public-facing pages and documents use large, easy-to-read type. Body text 18px+ baseline; headings proportionally larger; line-height ≥ 1.5.`;
|
|
246
|
+
const BODIES = {
|
|
247
|
+
"portable-stack": PORTABLE_STACK_BODY,
|
|
248
|
+
fathom: FATHOM_BODY,
|
|
249
|
+
"uptime-kuma": UPTIME_KUMA_BODY,
|
|
250
|
+
"neon-careful": NEON_CAREFUL_BODY,
|
|
251
|
+
"agent-coordination": AGENT_COORDINATION_BODY,
|
|
252
|
+
"seo-baseline": SEO_BASELINE_BODY,
|
|
253
|
+
"email-service": EMAIL_SERVICE_BODY,
|
|
254
|
+
"text-size": TEXT_SIZE_BODY,
|
|
255
|
+
};
|
|
256
|
+
const APPLICABILITY = {
|
|
257
|
+
"portable-stack": checkPortableStack,
|
|
258
|
+
fathom: checkFathom,
|
|
259
|
+
"uptime-kuma": checkUptimeKuma,
|
|
260
|
+
"neon-careful": checkNeonCareful,
|
|
261
|
+
"agent-coordination": checkAgentCoordination,
|
|
262
|
+
"seo-baseline": checkSeoBaseline,
|
|
263
|
+
"email-service": checkEmailService,
|
|
264
|
+
"text-size": checkTextSize,
|
|
265
|
+
};
|
|
266
|
+
const PREAMBLE = `The following organization standards apply to {{slug}}. Each was selected at instantiation per the conditional rules in [[instantiate-z2w-project]] v1.1.0 Step 6. See each standard's wiki-style link for the full discipline; the inline summaries below are the binding contract for this project.`;
|
|
267
|
+
const NO_APPLICABLE_FALLBACK = `*(No conditional standards apply to this project.)*`;
|
|
268
|
+
/**
|
|
269
|
+
* Render one standard's body with substitutions applied. The `fathom_env_var`
|
|
270
|
+
* extra is folded into the substitution map only for that one body since it's
|
|
271
|
+
* derived from `projectType` and isn't part of the general substitution map.
|
|
272
|
+
*/
|
|
273
|
+
function renderStandardBody(key, inputs, opts) {
|
|
274
|
+
const template = BODIES[key];
|
|
275
|
+
let body = applySubstitutions(template, inputs, opts);
|
|
276
|
+
if (key === "fathom") {
|
|
277
|
+
body = body.replace(/\{\{fathom_env_var\}\}/g, fathomEnvVarFor(inputs.projectType));
|
|
278
|
+
}
|
|
279
|
+
return body;
|
|
280
|
+
}
|
|
281
|
+
function renderPreamble(inputs, opts) {
|
|
282
|
+
return applySubstitutions(PREAMBLE, inputs, opts);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Resolve which standards apply to `inputs` and render the standards markdown
|
|
286
|
+
* body suitable for `.replace()`-ing into the `<!-- STANDARDS_BLOCK -->`
|
|
287
|
+
* marker that the Step 4 scaffolders emit inside CLAUDE.md.
|
|
288
|
+
*
|
|
289
|
+
* Pure function: no filesystem reads, no time-of-day dependencies (date can
|
|
290
|
+
* be pinned via {@link ResolveStandardsOptions.date} for snapshot tests).
|
|
291
|
+
*/
|
|
292
|
+
export function resolveStandards(inputs, opts = {}) {
|
|
293
|
+
const decisions = [];
|
|
294
|
+
const inserted = [];
|
|
295
|
+
for (const key of STANDARD_ORDER) {
|
|
296
|
+
const result = APPLICABILITY[key](inputs);
|
|
297
|
+
if (result.applies) {
|
|
298
|
+
decisions.push({
|
|
299
|
+
key,
|
|
300
|
+
title: TITLES[key],
|
|
301
|
+
state: "inserted-inline",
|
|
302
|
+
reason: result.reason,
|
|
303
|
+
});
|
|
304
|
+
inserted.push(renderStandardBody(key, inputs, opts));
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
decisions.push({
|
|
308
|
+
key,
|
|
309
|
+
title: TITLES[key],
|
|
310
|
+
state: "skipped-not-applicable",
|
|
311
|
+
reason: result.reason,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const sections = inserted.length === 0 ? NO_APPLICABLE_FALLBACK : inserted.join("\n\n");
|
|
316
|
+
const body = `${renderPreamble(inputs, opts)}\n\n${sections}\n`;
|
|
317
|
+
return {
|
|
318
|
+
body,
|
|
319
|
+
decisions,
|
|
320
|
+
promotePending: opts.promoteStandards === true,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Convenience: take the CLAUDE.md content emitted by a Step 4 scaffolder and
|
|
325
|
+
* replace the `<!-- STANDARDS_BLOCK -->` marker with the resolver's body.
|
|
326
|
+
* Callers that compose the standards body with the rest of the writer pipeline
|
|
327
|
+
* can use this directly; tests use it to verify the full integration end-to-end.
|
|
328
|
+
*
|
|
329
|
+
* Returns the input verbatim if the marker isn't present (so this is safe to
|
|
330
|
+
* call on any file).
|
|
331
|
+
*/
|
|
332
|
+
export function applyStandardsBlock(claudeMd, resolution) {
|
|
333
|
+
return claudeMd.replace(/<!-- STANDARDS_BLOCK -->/g, resolution.body.trimEnd());
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=standards.js.map
|
|
@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AAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzE,MAAM,IAAI,GAAG,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,QAAQ,IAAI,CAAC;IAEhE,OAAO;QACL,IAAI;QACJ,SAAS;QACT,cAAc,EAAE,IAAI,CAAC,gBAAgB,KAAK,IAAI;KAC/C,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,UAA+B;IAE/B,OAAO,QAAQ,CAAC,OAAO,CAAC,2BAA2B,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BrandPresetSpec } from "./brand.js";
|
|
2
|
+
import type { ProjectType, ScaffoldInputs } from "./index.js";
|
|
3
|
+
export declare const SCAFFOLD_VERSION = "0.1.0";
|
|
4
|
+
export interface SubstitutionOptions {
|
|
5
|
+
/**
|
|
6
|
+
* ISO date string `YYYY-MM-DD`. When omitted, defaults to today's date
|
|
7
|
+
* (system clock). Tests should pin this for deterministic snapshots.
|
|
8
|
+
*/
|
|
9
|
+
date?: string;
|
|
10
|
+
/** Override the brand spec resolution (used by tests + callers that already resolved it). */
|
|
11
|
+
brandSpec?: BrandPresetSpec;
|
|
12
|
+
}
|
|
13
|
+
/** Today's date as `YYYY-MM-DD` in the local timezone. */
|
|
14
|
+
export declare function todayISODate(): string;
|
|
15
|
+
/** `my-tool` -> `my_tool` (for Python module names). */
|
|
16
|
+
export declare function underscoredSlug(slug: string): string;
|
|
17
|
+
/** `my-tool` -> `MyTool` (for PHP class names). */
|
|
18
|
+
export declare function pascalCaseFromSlug(slug: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Framework version embedded in the scaffolded CLAUDE.md header. WordPress
|
|
21
|
+
* plugins inherit from the WP AGENTS template (v3.1.0); everything else
|
|
22
|
+
* inherits from the generic AGENTS template (v2.13.0).
|
|
23
|
+
*/
|
|
24
|
+
export declare function frameworkVersionForType(projectType: ProjectType): string;
|
|
25
|
+
/**
|
|
26
|
+
* Build the placeholder → value map for a set of inputs. Exposed (not just
|
|
27
|
+
* used internally by applySubstitutions) so callers can inspect or extend
|
|
28
|
+
* the map before substituting.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildSubstitutionMap(inputs: ScaffoldInputs, opts?: SubstitutionOptions): Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Substitute every `{{placeholder}}` token in `template` with the value
|
|
33
|
+
* resolved from `inputs`. Unknown placeholders are left intact verbatim so
|
|
34
|
+
* the caller can detect drift between templates and the substitution map.
|
|
35
|
+
*/
|
|
36
|
+
export declare function applySubstitutions(template: string, inputs: ScaffoldInputs, opts?: SubstitutionOptions): string;
|
|
37
|
+
//# sourceMappingURL=substitute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"substitute.d.ts","sourceRoot":"","sources":["../src/substitute.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK9D,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6FAA6F;IAC7F,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAExE;AAqBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,EACtB,IAAI,GAAE,mBAAwB,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBxB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE,mBAAmB,GACzB,MAAM,CAQR"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// z2w-starter-kit substitution engine.
|
|
2
|
+
//
|
|
3
|
+
// Replaces `{{placeholder}}` tokens in template strings with values resolved
|
|
4
|
+
// from the user's ScaffoldInputs + the brand preset spec. Mirrors the
|
|
5
|
+
// substitution map documented in the [[instantiate-z2w-project]] skill's
|
|
6
|
+
// "Substitutions reference" section.
|
|
7
|
+
//
|
|
8
|
+
// Unknown placeholders are left intact so the caller can spot drift between
|
|
9
|
+
// templates and the substitution map. Date defaults to today (read from the
|
|
10
|
+
// system clock per CLAUDE.md Operating Principle #5), but tests can pin it
|
|
11
|
+
// via {@link SubstitutionOptions.date} for deterministic snapshots.
|
|
12
|
+
import { getBrandSpec } from "./brand.js";
|
|
13
|
+
const PLACEHOLDER_RE = /\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g;
|
|
14
|
+
const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
15
|
+
export const SCAFFOLD_VERSION = "0.1.0";
|
|
16
|
+
/** Today's date as `YYYY-MM-DD` in the local timezone. */
|
|
17
|
+
export function todayISODate() {
|
|
18
|
+
const now = new Date();
|
|
19
|
+
const year = now.getFullYear();
|
|
20
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
21
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
22
|
+
return `${year}-${month}-${day}`;
|
|
23
|
+
}
|
|
24
|
+
/** `my-tool` -> `my_tool` (for Python module names). */
|
|
25
|
+
export function underscoredSlug(slug) {
|
|
26
|
+
return slug.replace(/-/g, "_");
|
|
27
|
+
}
|
|
28
|
+
/** `my-tool` -> `MyTool` (for PHP class names). */
|
|
29
|
+
export function pascalCaseFromSlug(slug) {
|
|
30
|
+
return slug
|
|
31
|
+
.split("-")
|
|
32
|
+
.filter((part) => part.length > 0)
|
|
33
|
+
.map((part) => part[0].toUpperCase() + part.slice(1))
|
|
34
|
+
.join("");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Framework version embedded in the scaffolded CLAUDE.md header. WordPress
|
|
38
|
+
* plugins inherit from the WP AGENTS template (v3.1.0); everything else
|
|
39
|
+
* inherits from the generic AGENTS template (v2.13.0).
|
|
40
|
+
*/
|
|
41
|
+
export function frameworkVersionForType(projectType) {
|
|
42
|
+
return projectType === "wp-plugin" ? "3.1.0" : "2.13.0";
|
|
43
|
+
}
|
|
44
|
+
function resolveDate(opts) {
|
|
45
|
+
const supplied = opts.date;
|
|
46
|
+
if (supplied === undefined)
|
|
47
|
+
return todayISODate();
|
|
48
|
+
if (!ISO_DATE_RE.test(supplied)) {
|
|
49
|
+
throw new Error(`SubstitutionOptions.date must be ISO 'YYYY-MM-DD'. Got: ${JSON.stringify(supplied)}.`);
|
|
50
|
+
}
|
|
51
|
+
return supplied;
|
|
52
|
+
}
|
|
53
|
+
function resolveBrandSpec(inputs, opts) {
|
|
54
|
+
if (opts.brandSpec)
|
|
55
|
+
return opts.brandSpec;
|
|
56
|
+
return getBrandSpec(inputs.brand, inputs.customBrand, inputs.githubOrg);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build the placeholder → value map for a set of inputs. Exposed (not just
|
|
60
|
+
* used internally by applySubstitutions) so callers can inspect or extend
|
|
61
|
+
* the map before substituting.
|
|
62
|
+
*/
|
|
63
|
+
export function buildSubstitutionMap(inputs, opts = {}) {
|
|
64
|
+
const date = resolveDate(opts);
|
|
65
|
+
const spec = resolveBrandSpec(inputs, opts);
|
|
66
|
+
return {
|
|
67
|
+
slug: inputs.slug,
|
|
68
|
+
slug_under: underscoredSlug(inputs.slug),
|
|
69
|
+
slug_camel: pascalCaseFromSlug(inputs.slug),
|
|
70
|
+
description: inputs.description,
|
|
71
|
+
brand_name: spec.brandName,
|
|
72
|
+
brand_name_rule: spec.brandNameRule,
|
|
73
|
+
primary_color: spec.primaryColor,
|
|
74
|
+
accent_color: spec.accentColor,
|
|
75
|
+
author: spec.author,
|
|
76
|
+
author_url: spec.authorUrl,
|
|
77
|
+
github_org: inputs.githubOrg,
|
|
78
|
+
date,
|
|
79
|
+
year: date.slice(0, 4),
|
|
80
|
+
version: SCAFFOLD_VERSION,
|
|
81
|
+
framework_version: frameworkVersionForType(inputs.projectType),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Substitute every `{{placeholder}}` token in `template` with the value
|
|
86
|
+
* resolved from `inputs`. Unknown placeholders are left intact verbatim so
|
|
87
|
+
* the caller can detect drift between templates and the substitution map.
|
|
88
|
+
*/
|
|
89
|
+
export function applySubstitutions(template, inputs, opts) {
|
|
90
|
+
const map = buildSubstitutionMap(inputs, opts);
|
|
91
|
+
return template.replace(PLACEHOLDER_RE, (match, key) => {
|
|
92
|
+
if (Object.prototype.hasOwnProperty.call(map, key)) {
|
|
93
|
+
return map[key];
|
|
94
|
+
}
|
|
95
|
+
return match;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=substitute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"substitute.js","sourceRoot":"","sources":["../src/substitute.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,EAAE;AACF,6EAA6E;AAC7E,sEAAsE;AACtE,yEAAyE;AACzE,qCAAqC;AACrC,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,oEAAoE;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,cAAc,GAAG,yCAAyC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AI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,EAAE,gBAAgB;QACzB,iBAAiB,EAAE,uBAAuB,CAAC,MAAM,CAAC,WAAW,CAAC;KAC/D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,MAAsB,EACtB,IAA0B;IAE1B,MAAM,GAAG,GAAG,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,OAAO,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE;QAC7D,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;YACnD,OAAO,GAAG,CAAC,GAAG,CAAE,CAAC;QACnB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ScaffoldInputs } from "./index.js";
|
|
2
|
+
import type { WriteScaffoldResult } from "./writer.js";
|
|
3
|
+
export interface SummaryOptions {
|
|
4
|
+
/** Disable colors regardless of TTY detection. */
|
|
5
|
+
noColor?: boolean;
|
|
6
|
+
/** Force colors on (TrueColor) regardless of TTY detection. Used by tests + piped consumers that want color anyway. */
|
|
7
|
+
forceColor?: boolean;
|
|
8
|
+
/** Where to write the summary. Defaults to {@link process.stdout}. */
|
|
9
|
+
output?: NodeJS.WritableStream;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Render the post-scaffold summary block.
|
|
13
|
+
*
|
|
14
|
+
* Pure rendering — does not touch disk, does not mutate `inputs` or `result`.
|
|
15
|
+
* The full block is written to `opts.output` (defaults to `process.stdout`)
|
|
16
|
+
* via a single `.write()` call so consumers piping to `tee` get one chunk
|
|
17
|
+
* rather than interleaved partials.
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderSummary(inputs: ScaffoldInputs, result: WriteScaffoldResult, opts?: SummaryOptions): void;
|
|
20
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../src/summary.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uHAAuH;IACvH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AA8MD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,mBAAmB,EAC3B,IAAI,GAAE,cAAmB,GACxB,IAAI,CAgBN"}
|