@zero2webmaster/starter-kit 0.2.1 → 0.3.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 +12 -14
- package/dist/airtable.d.ts +119 -0
- package/dist/airtable.js +273 -0
- package/dist/cli.js +116 -18
- package/dist/confirm.d.ts +5 -4
- package/dist/confirm.js +41 -29
- package/dist/index.d.ts +179 -6
- package/dist/index.js +155 -6
- package/dist/inventory.d.ts +137 -0
- package/dist/inventory.js +258 -0
- package/dist/license.js +8 -6
- package/dist/parse-brief.d.ts +28 -2
- package/dist/parse-brief.js +151 -16
- package/dist/scaffolders/common.d.ts +30 -1
- package/dist/scaffolders/common.js +538 -21
- package/dist/scaffolders/index.d.ts +1 -0
- package/dist/scaffolders/index.js +3 -0
- package/dist/scaffolders/library.js +26 -2
- package/dist/scaffolders/nextjs.d.ts +1 -1
- package/dist/scaffolders/nextjs.js +250 -24
- package/dist/scaffolders/node-service.d.ts +3 -0
- package/dist/scaffolders/node-service.js +320 -0
- package/dist/scaffolders/pro-seo-extension.js +1 -1
- package/dist/scaffolders/python-service.js +5 -2
- package/dist/standards.d.ts +1 -1
- package/dist/standards.js +123 -3
- package/dist/substitute.d.ts +14 -3
- package/dist/substitute.js +8 -5
- package/dist/summary.d.ts +9 -0
- package/dist/summary.js +27 -10
- package/dist/templates.d.ts +43 -57
- package/dist/templates.js +108 -175
- package/dist/with-init.d.ts +18 -2
- package/dist/with-init.js +105 -16
- package/dist/wizard.js +21 -0
- package/dist/writer.d.ts +3 -5
- package/dist/writer.js +88 -15
- package/package.json +2 -1
package/dist/parse-brief.js
CHANGED
|
@@ -192,6 +192,7 @@ const PROJECT_TYPE_VALUES = [
|
|
|
192
192
|
"cf-pages",
|
|
193
193
|
"nextjs",
|
|
194
194
|
"python-service",
|
|
195
|
+
"node-service",
|
|
195
196
|
"library",
|
|
196
197
|
"protocol-repo",
|
|
197
198
|
];
|
|
@@ -223,6 +224,14 @@ function matchProjectTypeProse(text) {
|
|
|
223
224
|
{ pattern: /\bnext\.?js\b/, type: "nextjs" },
|
|
224
225
|
{ pattern: /\b(fastapi|flask|django)\b/, type: "python-service" },
|
|
225
226
|
{ pattern: /\bpython\s+(service|app|api|backend)\b/, type: "python-service" },
|
|
227
|
+
// Node API services (Hono / Express / a plain Node backend on Cloud Run,
|
|
228
|
+
// Fly, Render, etc.). These run BEFORE the library rules so "Node service /
|
|
229
|
+
// API / backend" resolves to node-service, while "node cli" / "cli tool"
|
|
230
|
+
// still fall through to library (those require the cli wording, which the
|
|
231
|
+
// patterns here deliberately don't match). Hono is unambiguous.
|
|
232
|
+
{ pattern: /\bhono\b/, type: "node-service" },
|
|
233
|
+
{ pattern: /\bnode(\.?js)?\s+(service|api|backend|server|microservice)\b/, type: "node-service" },
|
|
234
|
+
{ pattern: /\bexpress(\.?js)?\s+(service|api|app|backend|server)\b/, type: "node-service" },
|
|
226
235
|
{ pattern: /\bprotocol\s+repo\b/, type: "protocol-repo" },
|
|
227
236
|
{ pattern: /\bnpm\s+package\b/, type: "library" },
|
|
228
237
|
{ pattern: /\bnode\s+cli\b/, type: "library" },
|
|
@@ -382,6 +391,7 @@ function inferHasWebUi(brief, projectType) {
|
|
|
382
391
|
return true;
|
|
383
392
|
if (projectType === "library" ||
|
|
384
393
|
projectType === "cf-worker" ||
|
|
394
|
+
projectType === "node-service" ||
|
|
385
395
|
projectType === "protocol-repo") {
|
|
386
396
|
return false;
|
|
387
397
|
}
|
|
@@ -404,6 +414,66 @@ function inferHasCron(brief) {
|
|
|
404
414
|
return false;
|
|
405
415
|
return null;
|
|
406
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Infer whether the project sends transactional / auth email. Returns `false`
|
|
419
|
+
* (not null) when there's no signal — the safe default, since the mailer pulls
|
|
420
|
+
* in the AWS/Resend SDKs. Conservative on keywords: bare "email" is far too
|
|
421
|
+
* common (an "email address" field, a contact email), so we require a phrase
|
|
422
|
+
* that actually implies *sending* mail.
|
|
423
|
+
*/
|
|
424
|
+
function inferSendsEmail(brief) {
|
|
425
|
+
const explicit = explicitBoolean(brief, [
|
|
426
|
+
"sends transactional / auth email",
|
|
427
|
+
"sends transactional email",
|
|
428
|
+
"sends email",
|
|
429
|
+
"transactional email",
|
|
430
|
+
]);
|
|
431
|
+
if (explicit !== null)
|
|
432
|
+
return explicit;
|
|
433
|
+
const text = brief.toLowerCase();
|
|
434
|
+
return /\bmagic[\s-]?link\b|\bpasswordless\b|\btransactional email\b|\bauth email\b|\bconfirmation email\b|\bemail (notification|confirmation|receipt|reminder|verification)\b|\bsends?\s+(an?\s+)?emails?\b|\bemails?\s+(the\s+)?(user|customer|applicant|donor|subscriber|author|admin|member|client|team|them)s?\b|\bamazon ses\b|\bresend\b/.test(text);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Infer whether the project accepts user-generated content (UGC). Returns
|
|
438
|
+
* `false` (not null) when there's no signal — the safe default, since the
|
|
439
|
+
* moderation standard is only relevant for apps whose users post content others
|
|
440
|
+
* see. Conservative on keywords: requires a phrase that actually implies a
|
|
441
|
+
* multi-user content surface, not just "user" or "content" in isolation.
|
|
442
|
+
*/
|
|
443
|
+
function inferHasUserContent(brief) {
|
|
444
|
+
const explicit = explicitBoolean(brief, [
|
|
445
|
+
"accepts user-generated content",
|
|
446
|
+
"user-generated content",
|
|
447
|
+
"user generated content",
|
|
448
|
+
"has user content",
|
|
449
|
+
]);
|
|
450
|
+
if (explicit !== null)
|
|
451
|
+
return explicit;
|
|
452
|
+
const text = brief.toLowerCase();
|
|
453
|
+
return /\bugc\b|\buser[\s-]generated\b|\buser[\s-]submitted\b|\b(community|forum|comments?|discussion|message board|social (network|platform|feed)|marketplace|listings?)\b|\bpost(s|ing|ed)?\b(?=.*\b(user|member|visitor|public|other)s?\b)|\bmembers?\s+(can\s+)?(post|comment|upload|submit|share|message)\b|\bdirect messag|\bprofiles?\s+(that\s+)?(others?|members?|users?)\b|\bmoderation\b/.test(text);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Infer whether to wire Sentry runtime-error/APM observability. Unlike
|
|
457
|
+
* {@link inferSendsEmail} / {@link inferHasUserContent} (which default OFF), this
|
|
458
|
+
* defaults ON for customer-facing web apps — Sentry's free tier is generous and
|
|
459
|
+
* the whole point of the ask is default-on for Next.js / CF-Pages apps with real
|
|
460
|
+
* users. An explicit mention flips it either way; absent any signal, ON iff the
|
|
461
|
+
* type is nextjs / cf-pages AND the app has a web UI (the same customer-facing
|
|
462
|
+
* proxy the SEO baseline uses). The confirm screen still lets a human veto it.
|
|
463
|
+
*/
|
|
464
|
+
function inferHasObservability(brief, projectType, hasWebUi) {
|
|
465
|
+
const explicit = explicitBoolean(brief, [
|
|
466
|
+
"wire sentry",
|
|
467
|
+
"sentry",
|
|
468
|
+
"runtime error tracking",
|
|
469
|
+
"error tracking",
|
|
470
|
+
"observability",
|
|
471
|
+
]);
|
|
472
|
+
if (explicit !== null)
|
|
473
|
+
return explicit;
|
|
474
|
+
const isWebAppType = projectType === "nextjs" || projectType === "cf-pages";
|
|
475
|
+
return isWebAppType && hasWebUi === true;
|
|
476
|
+
}
|
|
407
477
|
function inferParticipateInBulletin(brief, brand) {
|
|
408
478
|
const text = brief.toLowerCase();
|
|
409
479
|
if (/\bagent\s+coordination\b|\bbulletin\b/.test(text))
|
|
@@ -414,29 +484,87 @@ function inferParticipateInBulletin(brief, brand) {
|
|
|
414
484
|
return false;
|
|
415
485
|
return null;
|
|
416
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Heading-text aliases for each planning section. A brief heading is classified
|
|
489
|
+
* to a canonical field when its normalized text contains any of these phrases
|
|
490
|
+
* as a whole-word substring (so "Governing purpose" → purpose and
|
|
491
|
+
* "Phasing & rough timeline" → roadmap).
|
|
492
|
+
*
|
|
493
|
+
* This is the fix for the silent-miss defect (found 2026-06-28 on backup-engine,
|
|
494
|
+
* whose richly-named brief headings — "Governing purpose", "Phasing & rough
|
|
495
|
+
* timeline" — matched NONE of the original exact-prefix vocabulary, so ROADMAP.md
|
|
496
|
+
* and the README overview silently fell back to placeholders). Order matters:
|
|
497
|
+
* the first matching field wins per heading, and the first heading wins per
|
|
498
|
+
* field. Kept deliberately conservative — a heading that matches nothing here is
|
|
499
|
+
* simply skipped (its text is still preserved verbatim in PROJECT_BRIEF.md).
|
|
500
|
+
*/
|
|
501
|
+
const SECTION_ALIASES = [
|
|
502
|
+
["purpose", ["purpose", "overview", "objective", "mission", "what this is"]],
|
|
503
|
+
["keyApis", ["key apis", "apis", "integrations"]],
|
|
504
|
+
["dataSources", ["data sources", "data source", "sources"]],
|
|
505
|
+
["expectedOutputs", ["expected outputs", "outputs", "deliverables"]],
|
|
506
|
+
["edgeCases", [
|
|
507
|
+
"edge cases",
|
|
508
|
+
"gotchas",
|
|
509
|
+
"critical design requirements",
|
|
510
|
+
"design requirements",
|
|
511
|
+
"constraints",
|
|
512
|
+
]],
|
|
513
|
+
["roadmap", ["roadmap", "phasing", "phases", "timeline", "milestones"]],
|
|
514
|
+
["futureImprovements", ["future improvements", "future work", "out of scope", "beyond"]],
|
|
515
|
+
];
|
|
516
|
+
/** True when `phrase` appears in `haystack` on whole-word boundaries. */
|
|
517
|
+
function headingContainsPhrase(haystack, phrase) {
|
|
518
|
+
const re = new RegExp(`(?:^|[^a-z0-9])${escapeRegExp(phrase)}(?:[^a-z0-9]|$)`, "i");
|
|
519
|
+
return re.test(haystack);
|
|
520
|
+
}
|
|
521
|
+
/** Map a raw heading text to a canonical section field, or null if none fit. */
|
|
522
|
+
function classifyHeading(headingText) {
|
|
523
|
+
const norm = headingText.toLowerCase();
|
|
524
|
+
for (const [field, phrases] of SECTION_ALIASES) {
|
|
525
|
+
for (const phrase of phrases) {
|
|
526
|
+
if (headingContainsPhrase(norm, phrase))
|
|
527
|
+
return field;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
417
532
|
/**
|
|
418
533
|
* Lift the free-text planning sections out of the brief so they can flow into
|
|
419
534
|
* the scaffolded ROADMAP.md + README.md (per [[instantiate-z2w-project]]
|
|
420
|
-
* SKILL Step 1a.4) instead of being discarded after field inference.
|
|
421
|
-
*
|
|
535
|
+
* SKILL Step 1a.4) instead of being discarded after field inference.
|
|
536
|
+
*
|
|
537
|
+
* Scans EVERY markdown heading (ATX `## Foo` and standalone bold `**Foo**`),
|
|
538
|
+
* classifies each by alias keyword, and bounds a section's body at the next
|
|
539
|
+
* heading of ANY kind. This tolerates real-world brief heading vocabulary
|
|
540
|
+
* rather than demanding the exact canonical words, and prevents one section's
|
|
541
|
+
* body from bleeding into the next when an unrecognized heading sits between
|
|
542
|
+
* them. Only sections actually present appear in the result; returns
|
|
422
543
|
* `undefined` when none are found (the wizard/`--input` shape).
|
|
423
544
|
*/
|
|
424
545
|
export function extractBriefSections(brief) {
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
["
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
546
|
+
const headingRe = /^[ \t]*(?:#{1,6}[ \t]+(.+?)|\*\*(.+?)\*\*[ \t]*:?)[ \t]*$/gm;
|
|
547
|
+
const headings = [];
|
|
548
|
+
let m;
|
|
549
|
+
while ((m = headingRe.exec(brief)) !== null) {
|
|
550
|
+
const text = (m[1] ?? m[2] ?? "").replace(/:\s*$/, "").trim();
|
|
551
|
+
headings.push({
|
|
552
|
+
matchStart: m.index,
|
|
553
|
+
bodyStart: m.index + m[0].length,
|
|
554
|
+
field: classifyHeading(text),
|
|
555
|
+
});
|
|
556
|
+
}
|
|
434
557
|
const sections = {};
|
|
435
558
|
let found = false;
|
|
436
|
-
for (
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
559
|
+
for (let i = 0; i < headings.length; i++) {
|
|
560
|
+
const h = headings[i];
|
|
561
|
+
// First heading wins per field — skip a field already captured.
|
|
562
|
+
if (h.field === null || sections[h.field] !== undefined)
|
|
563
|
+
continue;
|
|
564
|
+
const end = i + 1 < headings.length ? headings[i + 1].matchStart : brief.length;
|
|
565
|
+
const body = brief.slice(h.bodyStart, end).trim();
|
|
566
|
+
if (body.length > 0) {
|
|
567
|
+
sections[h.field] = body;
|
|
440
568
|
found = true;
|
|
441
569
|
}
|
|
442
570
|
}
|
|
@@ -467,12 +595,16 @@ export function parseBrief(brief) {
|
|
|
467
595
|
hasWebUi: null,
|
|
468
596
|
hasCron: null,
|
|
469
597
|
participateInBulletin: null,
|
|
598
|
+
sendsEmail: false,
|
|
599
|
+
hasUserContent: false,
|
|
600
|
+
hasObservability: false,
|
|
470
601
|
briefSections: undefined,
|
|
471
602
|
raw: brief,
|
|
472
603
|
};
|
|
473
604
|
}
|
|
474
605
|
const brand = inferBrand(trimmed);
|
|
475
606
|
const projectType = inferProjectType(trimmed);
|
|
607
|
+
const hasWebUi = inferHasWebUi(trimmed, projectType);
|
|
476
608
|
return {
|
|
477
609
|
slug: inferSlug(trimmed),
|
|
478
610
|
description: inferDescription(trimmed),
|
|
@@ -481,9 +613,12 @@ export function parseBrief(brief) {
|
|
|
481
613
|
githubOrg: inferGithubOrg(trimmed, brand),
|
|
482
614
|
targetPath: inferTargetPath(trimmed),
|
|
483
615
|
dbStrategy: inferDbStrategy(trimmed),
|
|
484
|
-
hasWebUi
|
|
616
|
+
hasWebUi,
|
|
485
617
|
hasCron: inferHasCron(trimmed),
|
|
486
618
|
participateInBulletin: inferParticipateInBulletin(trimmed, brand),
|
|
619
|
+
sendsEmail: inferSendsEmail(trimmed),
|
|
620
|
+
hasUserContent: inferHasUserContent(trimmed),
|
|
621
|
+
hasObservability: inferHasObservability(trimmed, projectType, hasWebUi),
|
|
487
622
|
briefSections: extractBriefSections(trimmed),
|
|
488
623
|
raw: brief,
|
|
489
624
|
};
|
|
@@ -16,8 +16,19 @@ export declare function commonReadme(inputs: ScaffoldInputs, opts: ScaffolderOpt
|
|
|
16
16
|
export declare function commonRoadmap(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
17
17
|
export declare function commonStatus(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
18
18
|
export declare function commonHandoff(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
19
|
+
/**
|
|
20
|
+
* Persist the verbatim instantiation brief into the repo at
|
|
21
|
+
* directives/PROJECT_BRIEF.md. Returns null for the wizard / `--input` paths
|
|
22
|
+
* that carry no brief text (nothing to persist). The body is the raw brief and
|
|
23
|
+
* is intentionally NOT run through the placeholder substituter, so a brief that
|
|
24
|
+
* happens to contain `{{token}}`-looking text is preserved exactly (only
|
|
25
|
+
* CLAUDE.md is validated for leftover markers — see writer.ts).
|
|
26
|
+
*/
|
|
27
|
+
export declare function commonProjectBrief(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile | null;
|
|
19
28
|
export declare function commonTroubleshooting(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
20
29
|
export declare function commonChangelog(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
30
|
+
export declare function commonMarketing(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
31
|
+
export declare function commonBackups(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
21
32
|
export declare function commonVersion(): ScaffoldFile;
|
|
22
33
|
export declare function commonCursorignore(): ScaffoldFile;
|
|
23
34
|
export declare function commonDirective(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec): ScaffoldFile;
|
|
@@ -37,7 +48,7 @@ export declare function gitignoreFor(projectType: ScaffoldInputs["projectType"])
|
|
|
37
48
|
* rather than requiring a manual `cp .env.example .env.local` — closes the
|
|
38
49
|
* z2w-agent-command-center 2026-06-01 Open question.
|
|
39
50
|
*/
|
|
40
|
-
export declare function localEnvFrom(exampleContent: string, filename: string): string;
|
|
51
|
+
export declare function localEnvFrom(exampleContent: string, filename: string, slug: string): string;
|
|
41
52
|
/**
|
|
42
53
|
* Common base files every scaffolded project gets — CLAUDE.md, README.md,
|
|
43
54
|
* ROADMAP.md, STATUS.md, HANDOFF.md, TROUBLESHOOTING.md, CHANGELOG.md,
|
|
@@ -48,3 +59,21 @@ export declare function localEnvFrom(exampleContent: string, filename: string):
|
|
|
48
59
|
* etc.) are appended by the per-type scaffolder.
|
|
49
60
|
*/
|
|
50
61
|
export declare function commonBaseFiles(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, perTypeNarrative: string): ScaffoldFile[];
|
|
62
|
+
/** npm deps the mailer requires; merged into the scaffolded package.json. */
|
|
63
|
+
export declare const EMAIL_DEPS: Readonly<Record<string, string>>;
|
|
64
|
+
/**
|
|
65
|
+
* The env-var block appended to a scaffolded `.env.example` when the project
|
|
66
|
+
* sends email. Both providers' vars are stubbed so switching is a one-line env
|
|
67
|
+
* change with no code edit.
|
|
68
|
+
*/
|
|
69
|
+
export declare const EMAIL_ENV_BLOCK = "\n# \u2500\u2500 Transactional / auth email (lib/email/mailer.ts) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n# Provider router. Default: Amazon SES. Set to \"resend\" to use Resend instead \u2014\n# no code change. See directives/email-setup.md + [[email-service-router]].\nEMAIL_PROVIDER=ses\n\n# Amazon SES (default). Custom SES_ prefix + explicit creds is deliberate: on\n# Vercel/Lambda the platform injects its own AWS_* that would shadow the default\n# credential chain. SES_REGION MUST equal the region the sender domain is\n# verified in, or sends fail with \"Email address is not verified\".\nSES_REGION=\nSES_ACCESS_KEY_ID=\nSES_SECRET_ACCESS_KEY=\n# From address. A domain-verified identity can send from any local-part.\n# Format: \"Brand Name <sender@yourdomain.com>\". Never noreply@.\nAWS_SES_FROM=\n\n# Resend (swappable alternative \u2014 only read when EMAIL_PROVIDER=resend).\n# RESEND_FROM must be on a Resend-verified domain.\nRESEND_API_KEY=\nRESEND_FROM=\n";
|
|
70
|
+
/**
|
|
71
|
+
* Build the email-wiring files for a scaffold that sends email. \`layout\`
|
|
72
|
+
* selects the file paths + whether a vitest test is emitted:
|
|
73
|
+
* - "nextjs" → \`lib/email/mailer.ts\` (imported via the \`@/*\` alias); no
|
|
74
|
+
* test file (the nextjs scaffold ships no test runner).
|
|
75
|
+
* - "node-service" → \`src/lib/email/mailer.ts\` + \`src/lib/email/mailer.test.ts\`
|
|
76
|
+
* (vitest picks up \`src/**\/*.test.ts\`).
|
|
77
|
+
* The directive is emitted for both.
|
|
78
|
+
*/
|
|
79
|
+
export declare function emailFiles(inputs: ScaffoldInputs, opts: ScaffolderOptions | undefined, spec: BrandPresetSpec, layout: "nextjs" | "node-service"): ScaffoldFile[];
|