@zero2webmaster/starter-kit 0.1.1 → 0.2.1

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.
Files changed (92) hide show
  1. package/README.md +22 -7
  2. package/dist/brand.d.ts +0 -1
  3. package/dist/brand.js +0 -1
  4. package/dist/brief.d.ts +2 -3
  5. package/dist/brief.js +11 -5
  6. package/dist/cli.d.ts +0 -1
  7. package/dist/cli.js +190 -13
  8. package/dist/confirm.d.ts +11 -1
  9. package/dist/confirm.js +27 -6
  10. package/dist/index.d.ts +20 -2
  11. package/dist/index.js +1 -3
  12. package/dist/license.d.ts +97 -0
  13. package/dist/license.js +472 -0
  14. package/dist/parse-brief.d.ts +19 -2
  15. package/dist/parse-brief.js +213 -21
  16. package/dist/scaffolders/cf-pages.d.ts +0 -1
  17. package/dist/scaffolders/cf-pages.js +0 -1
  18. package/dist/scaffolders/cf-worker.d.ts +0 -1
  19. package/dist/scaffolders/cf-worker.js +0 -1
  20. package/dist/scaffolders/common.d.ts +13 -2
  21. package/dist/scaffolders/common.js +217 -12
  22. package/dist/scaffolders/index.d.ts +0 -1
  23. package/dist/scaffolders/index.js +0 -1
  24. package/dist/scaffolders/library.d.ts +0 -1
  25. package/dist/scaffolders/library.js +0 -1
  26. package/dist/scaffolders/nextjs.d.ts +0 -1
  27. package/dist/scaffolders/nextjs.js +6 -3
  28. package/dist/scaffolders/pro-seo-extension.d.ts +11 -0
  29. package/dist/scaffolders/pro-seo-extension.js +782 -0
  30. package/dist/scaffolders/protocol-repo.d.ts +0 -1
  31. package/dist/scaffolders/protocol-repo.js +0 -1
  32. package/dist/scaffolders/python-service.d.ts +0 -1
  33. package/dist/scaffolders/python-service.js +6 -2
  34. package/dist/scaffolders/wp-plugin.d.ts +0 -1
  35. package/dist/scaffolders/wp-plugin.js +8 -9
  36. package/dist/standards.d.ts +1 -2
  37. package/dist/standards.js +41 -3
  38. package/dist/substitute.d.ts +8 -1
  39. package/dist/substitute.js +11 -1
  40. package/dist/summary.d.ts +0 -1
  41. package/dist/summary.js +4 -4
  42. package/dist/templates.d.ts +73 -1
  43. package/dist/templates.js +174 -3
  44. package/dist/with-init.d.ts +16 -0
  45. package/dist/with-init.js +82 -0
  46. package/dist/wizard.d.ts +0 -1
  47. package/dist/wizard.js +0 -1
  48. package/dist/writer.d.ts +16 -3
  49. package/dist/writer.js +38 -10
  50. package/package.json +4 -3
  51. package/dist/brand.d.ts.map +0 -1
  52. package/dist/brand.js.map +0 -1
  53. package/dist/brief.d.ts.map +0 -1
  54. package/dist/brief.js.map +0 -1
  55. package/dist/cli.d.ts.map +0 -1
  56. package/dist/cli.js.map +0 -1
  57. package/dist/confirm.d.ts.map +0 -1
  58. package/dist/confirm.js.map +0 -1
  59. package/dist/index.d.ts.map +0 -1
  60. package/dist/index.js.map +0 -1
  61. package/dist/parse-brief.d.ts.map +0 -1
  62. package/dist/parse-brief.js.map +0 -1
  63. package/dist/scaffolders/cf-pages.d.ts.map +0 -1
  64. package/dist/scaffolders/cf-pages.js.map +0 -1
  65. package/dist/scaffolders/cf-worker.d.ts.map +0 -1
  66. package/dist/scaffolders/cf-worker.js.map +0 -1
  67. package/dist/scaffolders/common.d.ts.map +0 -1
  68. package/dist/scaffolders/common.js.map +0 -1
  69. package/dist/scaffolders/index.d.ts.map +0 -1
  70. package/dist/scaffolders/index.js.map +0 -1
  71. package/dist/scaffolders/library.d.ts.map +0 -1
  72. package/dist/scaffolders/library.js.map +0 -1
  73. package/dist/scaffolders/nextjs.d.ts.map +0 -1
  74. package/dist/scaffolders/nextjs.js.map +0 -1
  75. package/dist/scaffolders/protocol-repo.d.ts.map +0 -1
  76. package/dist/scaffolders/protocol-repo.js.map +0 -1
  77. package/dist/scaffolders/python-service.d.ts.map +0 -1
  78. package/dist/scaffolders/python-service.js.map +0 -1
  79. package/dist/scaffolders/wp-plugin.d.ts.map +0 -1
  80. package/dist/scaffolders/wp-plugin.js.map +0 -1
  81. package/dist/standards.d.ts.map +0 -1
  82. package/dist/standards.js.map +0 -1
  83. package/dist/substitute.d.ts.map +0 -1
  84. package/dist/substitute.js.map +0 -1
  85. package/dist/summary.d.ts.map +0 -1
  86. package/dist/summary.js.map +0 -1
  87. package/dist/templates.d.ts.map +0 -1
  88. package/dist/templates.js.map +0 -1
  89. package/dist/wizard.d.ts.map +0 -1
  90. package/dist/wizard.js.map +0 -1
  91. package/dist/writer.d.ts.map +0 -1
  92. package/dist/writer.js.map +0 -1
@@ -8,6 +8,8 @@
8
8
  // The parser is intentionally conservative — it only sets a field when the
9
9
  // signal is unambiguous. False-positive inferences erode trust in the
10
10
  // confirmation screen; false-negatives merely require the user to type.
11
+ import * as os from "node:os";
12
+ import * as path from "node:path";
11
13
  const SECTION_NAMES = [
12
14
  "purpose",
13
15
  "key apis",
@@ -18,6 +20,7 @@ const SECTION_NAMES = [
18
20
  "future improvements",
19
21
  "project name",
20
22
  "slug",
23
+ "description",
21
24
  "brand",
22
25
  "github org",
23
26
  "target path",
@@ -80,6 +83,49 @@ function findInlineField(brief, key) {
80
83
  const value = match[1].trim().replace(/^\*\*|\*\*$/g, "").trim();
81
84
  return value.length > 0 ? value : null;
82
85
  }
86
+ /**
87
+ * Find an explicit value for a field. Tries the inline form first
88
+ * (`Key: Value` on one line), then the heading-style form
89
+ * (`## Key\nValue` with the value on the next line). The heading-style
90
+ * lookup takes the first non-empty line of the extracted section body —
91
+ * suitable for single-value fields like slug, brand, target path.
92
+ *
93
+ * Multi-line fields (Description, Purpose) should not use this; they need
94
+ * the full section body via `extractSection`.
95
+ */
96
+ function findExplicitField(brief, keys) {
97
+ for (const key of keys) {
98
+ const inline = findInlineField(brief, key);
99
+ if (inline)
100
+ return inline;
101
+ }
102
+ for (const key of keys) {
103
+ const body = extractSection(brief, key);
104
+ if (body) {
105
+ const firstLine = body
106
+ .split("\n")
107
+ .map((l) => l.trim())
108
+ .find((l) => l.length > 0);
109
+ if (firstLine)
110
+ return firstLine;
111
+ }
112
+ }
113
+ return null;
114
+ }
115
+ /**
116
+ * Expand a leading `~` / `~/` to the user's home directory. Briefs and
117
+ * confirm-screen entries routinely carry `~/Desktop/...` paths, which the
118
+ * shell would expand on a command line but which arrive literal here. Without
119
+ * this, `inferTargetPath` rejected every tilde path as non-absolute (a
120
+ * contributor to the 2026-06-03 "Target path [unset]" dogfood finding).
121
+ */
122
+ export function expandHome(p) {
123
+ if (p === "~")
124
+ return os.homedir();
125
+ if (p.startsWith("~/"))
126
+ return path.join(os.homedir(), p.slice(2));
127
+ return p;
128
+ }
83
129
  const SLUG_RE = /^[a-z][a-z0-9-]{2,49}$/;
84
130
  const SLUG_VERSION_SUFFIX_RE = /-v\d+$/;
85
131
  export function kebabCase(input) {
@@ -94,10 +140,12 @@ export function isValidSlug(slug) {
94
140
  return SLUG_RE.test(slug) && !SLUG_VERSION_SUFFIX_RE.test(slug);
95
141
  }
96
142
  function inferSlug(brief) {
97
- const explicit = findInlineField(brief, "project slug") ??
98
- findInlineField(brief, "slug") ??
99
- findInlineField(brief, "project name") ??
100
- findInlineField(brief, "name");
143
+ const explicit = findExplicitField(brief, [
144
+ "project slug",
145
+ "slug",
146
+ "project name",
147
+ "name",
148
+ ]);
101
149
  if (explicit) {
102
150
  const candidate = kebabCase(explicit);
103
151
  if (isValidSlug(candidate))
@@ -116,10 +164,19 @@ function inferSlug(brief) {
116
164
  return null;
117
165
  }
118
166
  function inferDescription(brief) {
119
- const explicit = findInlineField(brief, "description") ??
167
+ const inline = findInlineField(brief, "description") ??
120
168
  findInlineField(brief, "summary");
121
- if (explicit)
122
- return explicit;
169
+ if (inline)
170
+ return inline;
171
+ for (const key of ["description", "summary"]) {
172
+ const body = extractSection(brief, key);
173
+ if (body) {
174
+ const firstSentence = body.split(/(?<=[.?!])\s+/)[0] ?? body;
175
+ const trimmed = firstSentence.trim();
176
+ if (trimmed.length > 0)
177
+ return trimmed.slice(0, 280);
178
+ }
179
+ }
123
180
  const purpose = extractSection(brief, "purpose");
124
181
  if (purpose) {
125
182
  const firstSentence = purpose.split(/(?<=[.?!])\s+/)[0] ?? purpose;
@@ -129,8 +186,33 @@ function inferDescription(brief) {
129
186
  }
130
187
  return null;
131
188
  }
189
+ const PROJECT_TYPE_VALUES = [
190
+ "wp-plugin",
191
+ "cf-worker",
192
+ "cf-pages",
193
+ "nextjs",
194
+ "python-service",
195
+ "library",
196
+ "protocol-repo",
197
+ ];
132
198
  function inferProjectType(brief) {
133
- const text = brief.toLowerCase();
199
+ // An explicit `Project type:` / `- **Project type**: <value>` field is
200
+ // authoritative — match the canonical enum value directly first (catches
201
+ // hyphenated values like `protocol-repo` that the prose rules below miss),
202
+ // then fall back to running the prose rules against just the field value.
203
+ const explicit = findExplicitField(brief, ["project type", "type"]);
204
+ if (explicit) {
205
+ const normalized = explicit.toLowerCase().trim();
206
+ const exact = PROJECT_TYPE_VALUES.find((t) => t === normalized);
207
+ if (exact)
208
+ return exact;
209
+ const fromProse = matchProjectTypeProse(normalized);
210
+ if (fromProse)
211
+ return fromProse;
212
+ }
213
+ return matchProjectTypeProse(brief.toLowerCase());
214
+ }
215
+ function matchProjectTypeProse(text) {
134
216
  const rules = [
135
217
  { pattern: /\b(wordpress|wp)\s+plugin\b/, type: "wp-plugin" },
136
218
  { pattern: /\bcloudflare\s+pages\b|\bcf[-\s]?pages\b/, type: "cf-pages" },
@@ -154,6 +236,24 @@ function inferProjectType(brief) {
154
236
  return null;
155
237
  }
156
238
  function inferBrand(brief) {
239
+ const explicit = findExplicitField(brief, ["brand", "brand preset"]);
240
+ if (explicit) {
241
+ const value = explicit.toLowerCase().trim();
242
+ if (value === "zero2webmaster" || value === "z2w")
243
+ return "zero2webmaster";
244
+ if (value === "save-the-frogs" ||
245
+ value === "save the frogs" ||
246
+ value === "save the frogs!" ||
247
+ value === "savethefrogs" ||
248
+ value === "stf") {
249
+ return "save-the-frogs";
250
+ }
251
+ if (value === "bansuri-bliss" || value === "bansuri bliss") {
252
+ return "bansuri-bliss";
253
+ }
254
+ if (value === "custom")
255
+ return "custom";
256
+ }
157
257
  const text = brief.toLowerCase();
158
258
  if (/\bsave\s*the\s*frogs\b|\bstf\b/.test(text))
159
259
  return "save-the-frogs";
@@ -176,9 +276,11 @@ export function githubOrgForBrand(brand) {
176
276
  }
177
277
  }
178
278
  function inferGithubOrg(brief, brand) {
179
- const explicit = findInlineField(brief, "github org") ??
180
- findInlineField(brief, "github organization") ??
181
- findInlineField(brief, "org");
279
+ const explicit = findExplicitField(brief, [
280
+ "github org",
281
+ "github organization",
282
+ "org",
283
+ ]);
182
284
  if (explicit) {
183
285
  const cleaned = explicit.replace(/^@/, "").trim();
184
286
  if (cleaned.length > 0)
@@ -189,16 +291,25 @@ function inferGithubOrg(brief, brand) {
189
291
  return null;
190
292
  }
191
293
  function inferTargetPath(brief) {
192
- const explicit = findInlineField(brief, "target path") ??
193
- findInlineField(brief, "target") ??
194
- findInlineField(brief, "path");
195
- if (explicit && explicit.startsWith("/"))
196
- return explicit;
197
- return null;
294
+ const explicit = findExplicitField(brief, [
295
+ "target path",
296
+ "target",
297
+ "path",
298
+ ]);
299
+ if (!explicit)
300
+ return null;
301
+ const expanded = expandHome(explicit);
302
+ return path.isAbsolute(expanded) ? expanded : null;
198
303
  }
199
- function inferDbStrategy(brief) {
200
- const dataSources = extractSection(brief, "data sources") ?? "";
201
- const haystack = (dataSources + "\n" + brief).toLowerCase();
304
+ const DB_STRATEGY_VALUES = [
305
+ "none",
306
+ "neon-postgres",
307
+ "supabase",
308
+ "sqlite",
309
+ "mysql-wp",
310
+ "other",
311
+ ];
312
+ function matchDbProse(haystack) {
202
313
  if (/\bneon\b/.test(haystack))
203
314
  return "neon-postgres";
204
315
  if (/\bsupabase\b/.test(haystack))
@@ -214,7 +325,51 @@ function inferDbStrategy(brief) {
214
325
  return "none";
215
326
  return null;
216
327
  }
328
+ function inferDbStrategy(brief) {
329
+ // Explicit `DB strategy:` / `- **Database strategy**: <value>` wins — match
330
+ // the canonical enum value first, then prose-match the field value.
331
+ const explicit = findExplicitField(brief, [
332
+ "db strategy",
333
+ "database strategy",
334
+ "database",
335
+ "db",
336
+ ]);
337
+ if (explicit) {
338
+ const normalized = explicit.toLowerCase().trim();
339
+ const exact = DB_STRATEGY_VALUES.find((s) => s === normalized);
340
+ if (exact)
341
+ return exact;
342
+ const fromProse = matchDbProse(normalized);
343
+ if (fromProse)
344
+ return fromProse;
345
+ }
346
+ const dataSources = extractSection(brief, "data sources") ?? "";
347
+ return matchDbProse((dataSources + "\n" + brief).toLowerCase());
348
+ }
349
+ /**
350
+ * Read an explicit yes/no field value if present. Returns `null` when the
351
+ * field is absent or its value isn't a recognizable boolean — the caller then
352
+ * falls back to prose inference.
353
+ */
354
+ function explicitBoolean(brief, keys) {
355
+ const explicit = findExplicitField(brief, keys);
356
+ if (!explicit)
357
+ return null;
358
+ const v = explicit.toLowerCase().trim();
359
+ if (["yes", "y", "true", "1"].includes(v))
360
+ return true;
361
+ if (["no", "n", "false", "0"].includes(v))
362
+ return false;
363
+ return null;
364
+ }
217
365
  function inferHasWebUi(brief, projectType) {
366
+ const explicit = explicitBoolean(brief, [
367
+ "has web ui",
368
+ "web ui",
369
+ "has webui",
370
+ ]);
371
+ if (explicit !== null)
372
+ return explicit;
218
373
  const text = brief.toLowerCase();
219
374
  if (/\bno\s+(web\s+)?ui\b|\bno\s+frontend\b/.test(text))
220
375
  return false;
@@ -233,6 +388,14 @@ function inferHasWebUi(brief, projectType) {
233
388
  return null;
234
389
  }
235
390
  function inferHasCron(brief) {
391
+ const explicit = explicitBoolean(brief, [
392
+ "has cron",
393
+ "has cron / scheduled jobs",
394
+ "cron",
395
+ "scheduled jobs",
396
+ ]);
397
+ if (explicit !== null)
398
+ return explicit;
236
399
  const text = brief.toLowerCase();
237
400
  if (/\bcron\b|\bscheduled\b|\bdaily\b|\bweekly\b|\bhourly\b|\bnightly\b|\bevery\s+\d+\s+(minute|hour|day)s?\b/.test(text)) {
238
401
  return true;
@@ -251,6 +414,34 @@ function inferParticipateInBulletin(brief, brand) {
251
414
  return false;
252
415
  return null;
253
416
  }
417
+ /**
418
+ * Lift the free-text planning sections out of the brief so they can flow into
419
+ * the scaffolded ROADMAP.md + README.md (per [[instantiate-z2w-project]]
420
+ * SKILL Step 1a.4) instead of being discarded after field inference. Only
421
+ * sections actually present in the brief appear in the result; returns
422
+ * `undefined` when none are found (the wizard/`--input` shape).
423
+ */
424
+ export function extractBriefSections(brief) {
425
+ const map = [
426
+ ["purpose", "purpose"],
427
+ ["keyApis", "key apis"],
428
+ ["dataSources", "data sources"],
429
+ ["expectedOutputs", "expected outputs"],
430
+ ["edgeCases", "edge cases"],
431
+ ["roadmap", "roadmap"],
432
+ ["futureImprovements", "future improvements"],
433
+ ];
434
+ const sections = {};
435
+ let found = false;
436
+ for (const [field, heading] of map) {
437
+ const body = extractSection(brief, heading);
438
+ if (body) {
439
+ sections[field] = body;
440
+ found = true;
441
+ }
442
+ }
443
+ return found ? sections : undefined;
444
+ }
254
445
  /**
255
446
  * Parse a pasted project-instantiation brief into a ParsedBrief. Every field
256
447
  * that cannot be inferred deterministically is left as `null` — the
@@ -276,6 +467,7 @@ export function parseBrief(brief) {
276
467
  hasWebUi: null,
277
468
  hasCron: null,
278
469
  participateInBulletin: null,
470
+ briefSections: undefined,
279
471
  raw: brief,
280
472
  };
281
473
  }
@@ -292,7 +484,7 @@ export function parseBrief(brief) {
292
484
  hasWebUi: inferHasWebUi(trimmed, projectType),
293
485
  hasCron: inferHasCron(trimmed),
294
486
  participateInBulletin: inferParticipateInBulletin(trimmed, brand),
487
+ briefSections: extractBriefSections(trimmed),
295
488
  raw: brief,
296
489
  };
297
490
  }
298
- //# sourceMappingURL=parse-brief.js.map
@@ -6,4 +6,3 @@ export declare function scaffoldCfPages(inputs: ScaffoldInputs, opts?: Scaffolde
6
6
  * Step 5 standards resolver.
7
7
  */
8
8
  export declare const CF_PAGES_SEO_BASELINE_PATHS: readonly ["index.html", "robots.txt", "sitemap.xml", "_headers", "SEO-CHECKLIST.md"];
9
- //# sourceMappingURL=cf-pages.d.ts.map
@@ -256,4 +256,3 @@ export const CF_PAGES_SEO_BASELINE_PATHS = [
256
256
  "_headers",
257
257
  "SEO-CHECKLIST.md",
258
258
  ];
259
- //# sourceMappingURL=cf-pages.js.map
@@ -1,4 +1,3 @@
1
1
  import type { ScaffoldInputs } from "../index.js";
2
2
  import { type ScaffoldFile, type ScaffolderOptions } from "./common.js";
3
3
  export declare function scaffoldCfWorker(inputs: ScaffoldInputs, opts?: ScaffolderOptions): ScaffoldFile[];
4
- //# sourceMappingURL=cf-worker.d.ts.map
@@ -109,4 +109,3 @@ export function scaffoldCfWorker(inputs, opts) {
109
109
  ];
110
110
  return [...base, ...typeSpecific];
111
111
  }
112
- //# sourceMappingURL=cf-worker.js.map
@@ -23,9 +23,21 @@ export declare function commonCursorignore(): ScaffoldFile;
23
23
  export declare function commonDirective(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
24
24
  /**
25
25
  * Per-type `.gitignore` body. Sources: skill's "Inline mini-templates"
26
- * section. Each variant is the verbatim block from there.
26
+ * section. Each variant is the verbatim block from there, plus the shared
27
+ * `GITIGNORE_SECRET_SCRATCH_BLOCK` appended to every type (so `.tmp/` and
28
+ * `.specstory/` are guaranteed present — see that constant's doc comment).
27
29
  */
28
30
  export declare function gitignoreFor(projectType: ScaffoldInputs["projectType"]): ScaffoldFile;
31
+ /**
32
+ * Derive a gitignored local env file (`.env.local` for nextjs, `.env` for
33
+ * python-service) from an already-substituted `.env.example` body. Keeps every
34
+ * key and its inline doc comments, clears assigned values so the user fills
35
+ * real ones, and swaps the example banner for a local-file banner. Emitted
36
+ * alongside `.env.example` so a fresh clone has the local file ready to fill
37
+ * rather than requiring a manual `cp .env.example .env.local` — closes the
38
+ * z2w-agent-command-center 2026-06-01 Open question.
39
+ */
40
+ export declare function localEnvFrom(exampleContent: string, filename: string): string;
29
41
  /**
30
42
  * Common base files every scaffolded project gets — CLAUDE.md, README.md,
31
43
  * ROADMAP.md, STATUS.md, HANDOFF.md, TROUBLESHOOTING.md, CHANGELOG.md,
@@ -36,4 +48,3 @@ export declare function gitignoreFor(projectType: ScaffoldInputs["projectType"])
36
48
  * etc.) are appended by the per-type scaffolder.
37
49
  */
38
50
  export declare function commonBaseFiles(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, perTypeNarrative: string): ScaffoldFile[];
39
- //# sourceMappingURL=common.d.ts.map
@@ -31,11 +31,11 @@ const README_TEMPLATE = `# {{slug}}
31
31
 
32
32
  ## Overview
33
33
 
34
- [1-2 paragraph project description — fill in after scaffold]
34
+ {{overview}}
35
35
 
36
36
  ## Quick start
37
37
 
38
- [Per project type — fill in after scaffold]
38
+ {{quick_start}}
39
39
 
40
40
  ## License
41
41
 
@@ -45,6 +45,83 @@ Proprietary — © {{year}} {{author}}, Zero2Webmaster. All rights reserved.
45
45
 
46
46
  *Scaffolded {{date}} via [[instantiate-z2w-project]] v1 — mirrored by \`@zero2webmaster/starter-kit\`.*
47
47
  `;
48
+ /**
49
+ * Per-type Quick-start block for the README. Mirrors the "Quick start for
50
+ * contributors" command sequence each per-type scaffolder puts in CLAUDE.md,
51
+ * so the README (the file a first-time reader opens) isn't a `[fill in]` stub
52
+ * (2026-06-03 dogfood + z2w-member-match 2026-06-11 findings).
53
+ */
54
+ function quickStartFor(inputs) {
55
+ const slugUnder = inputs.slug.replace(/-/g, "_");
56
+ switch (inputs.projectType) {
57
+ case "wp-plugin":
58
+ return [
59
+ "```bash",
60
+ "# Symlink (or copy) the plugin folder into a Local by Flywheel site:",
61
+ `# wp-content/plugins/${inputs.slug}`,
62
+ "# See [[symlink-safety]] before symlinking — WP Admin Delete follows symlinks.",
63
+ "composer install # only if the plugin uses Composer; otherwise skip",
64
+ "```",
65
+ "",
66
+ "Then activate via **WP Admin → Plugins**.",
67
+ ].join("\n");
68
+ case "cf-worker":
69
+ return [
70
+ "```bash",
71
+ "npm install",
72
+ "npm run dev # local wrangler dev server",
73
+ "npm run deploy # wrangler deploy",
74
+ "```",
75
+ ].join("\n");
76
+ case "cf-pages":
77
+ return [
78
+ "```bash",
79
+ "npm install",
80
+ "npm run dev # local dev server",
81
+ "npm run build # production build (deploys via Cloudflare Pages)",
82
+ "```",
83
+ ].join("\n");
84
+ case "nextjs":
85
+ return [
86
+ "```bash",
87
+ "npm install",
88
+ "# .env.local was scaffolded for you — fill in the values it lists",
89
+ "npm run dev # http://localhost:3000",
90
+ "npm run build && npm start # production build",
91
+ "```",
92
+ ].join("\n");
93
+ case "python-service":
94
+ return [
95
+ "```bash",
96
+ "python3 -m venv .venv",
97
+ "source .venv/bin/activate",
98
+ "pip install -e .[dev] # or: pip install -r requirements.txt",
99
+ `uvicorn ${slugUnder}.main:app --reload`,
100
+ "```",
101
+ ].join("\n");
102
+ case "library":
103
+ return [
104
+ "```bash",
105
+ "npm install",
106
+ "npm test",
107
+ "npm run build",
108
+ "```",
109
+ ].join("\n");
110
+ case "protocol-repo":
111
+ return "This is a documentation / protocol repository — there is no build step. Read the files in repository order.";
112
+ }
113
+ }
114
+ /**
115
+ * README Overview paragraph. Prefers the brief's Purpose section (verbatim)
116
+ * when scaffolding from a pasted brief; otherwise falls back to the one-line
117
+ * description plus a fill-in nudge.
118
+ */
119
+ function readmeOverview(inputs) {
120
+ const purpose = inputs.briefSections?.purpose?.trim();
121
+ if (purpose && purpose.length > 0)
122
+ return purpose;
123
+ return `${inputs.description}\n\n_(Expand this overview after scaffold.)_`;
124
+ }
48
125
  const TROUBLESHOOTING_TEMPLATE = `# Troubleshooting
49
126
 
50
127
  Living document for {{slug}}. Add an entry whenever a problem takes >15 minutes to solve.
@@ -308,13 +385,91 @@ ${AGENTS_BODY_MARKER}
308
385
  };
309
386
  }
310
387
  export function commonReadme(inputs, opts, spec) {
311
- return { path: "README.md", content: sub(README_TEMPLATE, inputs, opts, spec) };
388
+ // sub() fills the standard tokens; {{overview}} + {{quick_start}} are unknown
389
+ // to the substitution map, so they survive to be filled here (the values are
390
+ // free text that may contain `$`, so use replacer functions).
391
+ const content = sub(README_TEMPLATE, inputs, opts, spec)
392
+ .replace("{{overview}}", () => readmeOverview(inputs))
393
+ .replace("{{quick_start}}", () => quickStartFor(inputs));
394
+ return { path: "README.md", content };
312
395
  }
396
+ const ROADMAP_HEADER_TEMPLATE = `# Project Roadmap
397
+
398
+ **Project:** {{slug}}
399
+ **Goal:** {{description}}
400
+ **Created:** {{date}}
401
+ **Last Updated:** {{date}}
402
+
403
+ ---
404
+
405
+ ## Overview
406
+
407
+ This roadmap breaks the v{{version}} ship into atomic, testable steps. Each step should be completable in a single focused chat session.
408
+
409
+ The sections below were lifted from the project brief used to scaffold {{slug}}. Refine the brief's planning notes into concrete, verifiable steps as the project takes shape.
410
+ `;
411
+ const ROADMAP_PLACEHOLDER_STEPS = `## Step 1: First milestone (placeholder)
412
+
413
+ **Goal:** Replace this with your first concrete deliverable.
414
+
415
+ **Tasks:**
416
+ - [ ] [Task 1]
417
+
418
+ **Verification:**
419
+ - [ ] [How will you know it's done?]
420
+
421
+ **Status:** 📋 Pending
422
+ `;
423
+ const ROADMAP_FOOTER = `## Status Indicators
424
+
425
+ - 📋 **Pending** - Not started yet
426
+ - ⏳ **In Progress** - Currently working on
427
+ - ✅ **Complete** - Verified and working
428
+ - 🚫 **Blocked** - Cannot proceed (see STATUS.md for details)
429
+
430
+ ---
431
+
432
+ *This roadmap is a living document. Update it as the project evolves.*
433
+ `;
434
+ /** Brief context sections rendered under "## Project context (from brief)". */
435
+ const ROADMAP_CONTEXT_FIELDS = [
436
+ ["purpose", "Purpose"],
437
+ ["keyApis", "Key APIs"],
438
+ ["dataSources", "Data sources"],
439
+ ["expectedOutputs", "Expected outputs"],
440
+ ["edgeCases", "Edge cases"],
441
+ ];
313
442
  export function commonRoadmap(inputs, opts, spec) {
314
- return {
315
- path: "ROADMAP.md",
316
- content: sub(ROADMAP_TEMPLATE, inputs, opts, spec),
317
- };
443
+ const sections = inputs.briefSections;
444
+ // No brief (wizard / --input path): emit the placeholder template verbatim.
445
+ if (sections === undefined) {
446
+ return {
447
+ path: "ROADMAP.md",
448
+ content: sub(ROADMAP_TEMPLATE, inputs, opts, spec),
449
+ };
450
+ }
451
+ // Brief path: flow the brief's planning sections into ROADMAP.md per
452
+ // [[instantiate-z2w-project]] SKILL Step 1a.4.
453
+ const parts = [sub(ROADMAP_HEADER_TEMPLATE, inputs, opts, spec)];
454
+ const contextChunks = [];
455
+ for (const [field, label] of ROADMAP_CONTEXT_FIELDS) {
456
+ const body = sections[field]?.trim();
457
+ if (body)
458
+ contextChunks.push(`### ${label}\n\n${body}`);
459
+ }
460
+ if (contextChunks.length > 0) {
461
+ parts.push(`---\n\n## Project context (from brief)\n\n${contextChunks.join("\n\n")}\n`);
462
+ }
463
+ const roadmapBody = sections.roadmap?.trim();
464
+ parts.push(roadmapBody
465
+ ? `---\n\n## Roadmap (from brief)\n\n${roadmapBody}\n`
466
+ : `---\n\n${ROADMAP_PLACEHOLDER_STEPS}`);
467
+ const future = sections.futureImprovements?.trim();
468
+ if (future) {
469
+ parts.push(`---\n\n## Future improvements (from brief)\n\n${future}\n`);
470
+ }
471
+ parts.push(`---\n\n${ROADMAP_FOOTER}`);
472
+ return { path: "ROADMAP.md", content: parts.join("\n") };
318
473
  }
319
474
  export function commonStatus(inputs, opts, spec) {
320
475
  return {
@@ -352,14 +507,37 @@ export function commonDirective(inputs, opts, spec) {
352
507
  content: sub(DIRECTIVE_TEMPLATE, inputs, opts, spec),
353
508
  };
354
509
  }
510
+ /**
511
+ * Trailing block appended to every `.gitignore` regardless of project type.
512
+ *
513
+ * Two entries that MUST be present from line one of any Z2W repo:
514
+ * - `.tmp/` — the Z2W scratch/intermediates convention; can hold tokens
515
+ * (dev-server logs with magic-link URLs, etc.).
516
+ * - `.specstory/` — SpecStory chat transcripts. These archive *pasted* values
517
+ * from past sessions; in the field they have contained live
518
+ * DATABASE_URLs (with password) and API keys. A fresh repo's
519
+ * first `git add -A` silently stages them otherwise.
520
+ *
521
+ * Per the 2026-06-11 z2w-member-match near-miss (live DATABASE_URL +
522
+ * RESEND_API_KEY staged on a fresh repo) and matching asks from
523
+ * videomigrator-dashboard (2026-06-07). Centralized here so no per-type body
524
+ * can ever omit it.
525
+ */
526
+ const GITIGNORE_SECRET_SCRATCH_BLOCK = `
527
+ # Scratch / intermediates (Z2W convention) — never commit
528
+ .tmp/
529
+ # SpecStory chat transcripts — local only; can contain pasted secrets
530
+ .specstory/
531
+ `;
355
532
  /**
356
533
  * Per-type `.gitignore` body. Sources: skill's "Inline mini-templates"
357
- * section. Each variant is the verbatim block from there.
534
+ * section. Each variant is the verbatim block from there, plus the shared
535
+ * `GITIGNORE_SECRET_SCRATCH_BLOCK` appended to every type (so `.tmp/` and
536
+ * `.specstory/` are guaranteed present — see that constant's doc comment).
358
537
  */
359
538
  export function gitignoreFor(projectType) {
360
539
  const base = {
361
540
  "wp-plugin": `.DS_Store
362
- .tmp/
363
541
  *.zip
364
542
  node_modules/
365
543
  vendor/
@@ -406,12 +584,40 @@ dist/
406
584
  .env
407
585
  `,
408
586
  "protocol-repo": `.DS_Store
409
- .tmp/
410
587
  .env
411
588
  node_modules/
412
589
  `,
413
590
  }[projectType];
414
- return { path: ".gitignore", content: base };
591
+ return { path: ".gitignore", content: base + GITIGNORE_SECRET_SCRATCH_BLOCK };
592
+ }
593
+ /**
594
+ * Derive a gitignored local env file (`.env.local` for nextjs, `.env` for
595
+ * python-service) from an already-substituted `.env.example` body. Keeps every
596
+ * key and its inline doc comments, clears assigned values so the user fills
597
+ * real ones, and swaps the example banner for a local-file banner. Emitted
598
+ * alongside `.env.example` so a fresh clone has the local file ready to fill
599
+ * rather than requiring a manual `cp .env.example .env.local` — closes the
600
+ * z2w-agent-command-center 2026-06-01 Open question.
601
+ */
602
+ export function localEnvFrom(exampleContent, filename) {
603
+ const lines = exampleContent.split("\n");
604
+ // Drop the leading banner block (consecutive comment lines + blank lines at
605
+ // the top) — the per-key doc comments further down are kept verbatim.
606
+ let start = 0;
607
+ while (start < lines.length && lines[start].startsWith("#"))
608
+ start++;
609
+ while (start < lines.length && lines[start].trim() === "")
610
+ start++;
611
+ const body = lines
612
+ .slice(start)
613
+ .map((line) => {
614
+ const m = /^(\s*)([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.exec(line);
615
+ return m ? `${m[1]}${m[2]}=` : line;
616
+ })
617
+ .join("\n");
618
+ const banner = `# ${filename} — local environment values (gitignored; never committed).\n` +
619
+ `# Generated from .env.example at scaffold time; fill in real values below.\n\n`;
620
+ return banner + body;
415
621
  }
416
622
  /**
417
623
  * Common base files every scaffolded project gets — CLAUDE.md, README.md,
@@ -438,4 +644,3 @@ export function commonBaseFiles(inputs, opts, perTypeNarrative) {
438
644
  commonDirective(inputs, opts, spec),
439
645
  ];
440
646
  }
441
- //# sourceMappingURL=common.js.map
@@ -15,4 +15,3 @@ import type { ScaffoldFile, ScaffolderOptions } from "./common.js";
15
15
  * snapshot the full file list per project type without any FS dependency.
16
16
  */
17
17
  export declare function scaffoldByType(inputs: ScaffoldInputs, opts?: ScaffolderOptions): ScaffoldFile[];
18
- //# sourceMappingURL=index.d.ts.map
@@ -37,4 +37,3 @@ export function scaffoldByType(inputs, opts) {
37
37
  };
38
38
  return dispatch[inputs.projectType](inputs, opts);
39
39
  }
40
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,3 @@
1
1
  import type { ScaffoldInputs } from "../index.js";
2
2
  import { type ScaffoldFile, type ScaffolderOptions } from "./common.js";
3
3
  export declare function scaffoldLibrary(inputs: ScaffoldInputs, opts?: ScaffolderOptions): ScaffoldFile[];
4
- //# sourceMappingURL=library.d.ts.map