@zero2webmaster/starter-kit 0.2.1 → 0.3.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.
- 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/cf-worker.js +2 -2
- 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/cli.js
CHANGED
|
@@ -12,15 +12,35 @@
|
|
|
12
12
|
// `license set|status|refresh|deactivate` subcommands (v0.3.0+): manage the
|
|
13
13
|
// runtime license that gates paid features. See directives/license-check.md.
|
|
14
14
|
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// +
|
|
15
|
+
// GitHub repo creation (default-ON, private; Track D decision 2026-06-16):
|
|
16
|
+
// after a successful scaffold the CLI runs `git init` + repo-local
|
|
17
|
+
// `user.email` + first commit + `gh repo create {githubOrg}/{slug} --private`
|
|
18
|
+
// + topics + initial push. `--no-repo` opts out. SKIPPED for --dry-run and for
|
|
19
|
+
// the non-interactive --input (CI) path — both only print the would-be
|
|
20
|
+
// commands. Warn-and-proceed: a failed repo setup never fails the scaffold (the
|
|
21
|
+
// files are already written). This is the documented override of Operating
|
|
22
|
+
// Principle #3 for repo creation; every other side-effect stays surfaced-only.
|
|
18
23
|
//
|
|
19
24
|
// `--with-pro-seo` (v0.3.0+, paid feature; nextjs/cf-pages only): layers the
|
|
20
25
|
// Pro SEO baseline extension files on top of the base scaffold. Gated by a
|
|
21
26
|
// runtime license check.
|
|
27
|
+
//
|
|
28
|
+
// Airtable inventory auto-registration (ROADMAP Step 16): after a successful
|
|
29
|
+
// scaffold, when AIRTABLE_WRITE_PAT is set in the environment, create the
|
|
30
|
+
// project's row in Kerry's "Cursor Projects" inventory. Gated entirely on the
|
|
31
|
+
// PAT's presence (no PAT → silent no-op, the case for every normal user) and
|
|
32
|
+
// warn-and-proceed (never blocks the scaffold). `--no-airtable-row` opts out.
|
|
33
|
+
//
|
|
34
|
+
// Neon inventory write (project-inventory migration P3): the inventory is
|
|
35
|
+
// migrating off Airtable onto Neon Postgres. After a scaffold, when
|
|
36
|
+
// Z2W_INVENTORY_DATABASE_URL is set, UPSERT the project's row into the Neon
|
|
37
|
+
// `projects` table — DUAL-WRITE alongside Airtable during the transition (the
|
|
38
|
+
// Airtable write is dropped at P6). Same gate + warn-and-proceed posture as the
|
|
39
|
+
// Airtable path; no URL → silent no-op. `--no-inventory-row` opts out.
|
|
22
40
|
import { Command } from "commander";
|
|
23
41
|
import { input as inquirerInput } from "@inquirer/prompts";
|
|
42
|
+
import { registerProjectRow } from "./airtable.js";
|
|
43
|
+
import { registerProjectRowNeon } from "./inventory.js";
|
|
24
44
|
import { gatherBrief } from "./brief.js";
|
|
25
45
|
import { confirmInputs, ConfirmCancelledError } from "./confirm.js";
|
|
26
46
|
import { activateLicense, checkLicense, clearLicenseState, deactivateLicense, evaluateLicense, isValidLicenseKey, LicenseError, loadLicenseState, maskKey, runtimeLicenseCheck, } from "./license.js";
|
|
@@ -43,6 +63,18 @@ async function gatherInputs(flags) {
|
|
|
43
63
|
return runWizard({ prompter: inquirerPrompter });
|
|
44
64
|
}
|
|
45
65
|
const parsed = parseBrief(brief);
|
|
66
|
+
// Fail LOUD, not silent: a pasted brief whose headings match none of the
|
|
67
|
+
// recognized planning sections produces a placeholder ROADMAP.md + a
|
|
68
|
+
// placeholder README overview. Before 2026-06-28 that happened with zero
|
|
69
|
+
// warning (the backup-engine silent-miss). Surface it so the user can rename
|
|
70
|
+
// a heading or accept the placeholders knowingly.
|
|
71
|
+
if (parsed.briefSections === undefined) {
|
|
72
|
+
process.stderr.write("\n⚠️ No planning sections detected in your brief — ROADMAP.md and the " +
|
|
73
|
+
"README overview will be placeholders.\n" +
|
|
74
|
+
" I look for headings about: Purpose / Key APIs / Data sources / " +
|
|
75
|
+
"Expected outputs / Edge cases / Roadmap (or Phasing) / Future improvements.\n" +
|
|
76
|
+
" The full brief is still saved verbatim to directives/PROJECT_BRIEF.md.\n\n");
|
|
77
|
+
}
|
|
46
78
|
// Pre-fill the target path from the --target-path flag so the confirm
|
|
47
79
|
// screen shows it as set (and editable) rather than [unset] — the
|
|
48
80
|
// 2026-06-03 dogfood finding #4, where the flag was honored at write time
|
|
@@ -50,10 +82,15 @@ async function gatherInputs(flags) {
|
|
|
50
82
|
if (flags.targetPath) {
|
|
51
83
|
parsed.targetPath = expandHome(flags.targetPath);
|
|
52
84
|
}
|
|
53
|
-
|
|
85
|
+
const inputs = await confirmInputs(parsed, { prompter: inquirerPrompter });
|
|
86
|
+
// Capture the verbatim pasted brief as the project's instantiation prompt so
|
|
87
|
+
// the Airtable inventory write records it (Kerry's standing rule: every
|
|
88
|
+
// inventory row carries its Project Instantiation Prompt).
|
|
89
|
+
inputs.instantiationPrompt = brief;
|
|
90
|
+
return inputs;
|
|
54
91
|
}
|
|
55
92
|
async function gatePaidFeatures(flags, stderr = process.stderr) {
|
|
56
|
-
if (!flags.
|
|
93
|
+
if (!flags.withProSeo)
|
|
57
94
|
return;
|
|
58
95
|
const evaluation = await runtimeLicenseCheck();
|
|
59
96
|
if (evaluation.allowPaidFeatures) {
|
|
@@ -76,20 +113,79 @@ async function runInit(flags) {
|
|
|
76
113
|
showContents: flags.showContents === true,
|
|
77
114
|
refuseNonEmpty: flags.refuseNonEmpty !== false,
|
|
78
115
|
templatesPath: flags.templatesPath,
|
|
79
|
-
refreshTemplates: flags.refreshTemplates === true,
|
|
80
116
|
promoteStandards: flags.promoteStandards === true,
|
|
81
117
|
prompter: flags.promoteStandards ? inquirerPrompter : undefined,
|
|
82
118
|
withProSeo: flags.withProSeo === true,
|
|
83
119
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
120
|
+
// GitHub repo creation is a DEFAULT side-effect for the interactive flows
|
|
121
|
+
// (Track D decision 2026-06-16). It is skipped — and only the would-be
|
|
122
|
+
// commands are surfaced — for --dry-run (nothing written) and for the
|
|
123
|
+
// non-interactive --input/CI path (auto-creating a repo from CI would be
|
|
124
|
+
// surprising and dangerous). `--no-repo` opts out explicitly.
|
|
125
|
+
const createRepo = flags.dryRun !== true && flags.input === undefined && flags.repo !== false;
|
|
126
|
+
renderSummary(inputs, result, {
|
|
127
|
+
noColor: flags.noColor === true,
|
|
128
|
+
repoAutoCreated: createRepo,
|
|
129
|
+
});
|
|
130
|
+
if (createRepo) {
|
|
131
|
+
// Warn-and-proceed: the files are already written, so a failed repo setup
|
|
132
|
+
// must not fail the scaffold. Surface the manual fallback commands instead.
|
|
133
|
+
try {
|
|
134
|
+
await runWithInit(inputs, targetPath, {
|
|
135
|
+
stdout: process.stdout,
|
|
136
|
+
stderr: process.stderr,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
const detail = err instanceof WithInitError ? err.message : err.message;
|
|
141
|
+
process.stderr.write(`\nwarning: automatic GitHub repo setup did not complete (${detail}).\n` +
|
|
142
|
+
" Your files are written and intact. To finish manually:\n" +
|
|
143
|
+
` cd ${targetPath} && git init -b main && git config user.email "kerry@zero2webmaster.com" && git add . && git commit -m "Initial scaffold"\n` +
|
|
144
|
+
` gh repo create ${inputs.githubOrg}/${inputs.slug} --private --source=. --push\n`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (flags.dryRun === true) {
|
|
148
|
+
process.stdout.write("\n(repo creation skipped in --dry-run mode; would run git init + commit + gh repo create --private --push)\n");
|
|
149
|
+
}
|
|
150
|
+
else if (flags.input !== undefined) {
|
|
151
|
+
process.stdout.write("\n(repo creation skipped for the non-interactive --input path; run the git/gh commands under Next actions to create the repo)\n");
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// --no-repo
|
|
155
|
+
process.stdout.write("\n(--no-repo: automatic GitHub repo creation skipped; the git/gh commands are under Next actions above)\n");
|
|
156
|
+
}
|
|
157
|
+
// Airtable inventory auto-registration (ROADMAP Step 16). No-op unless
|
|
158
|
+
// AIRTABLE_WRITE_PAT is set (so it never fires for normal users) and never
|
|
159
|
+
// blocks the scaffold — warn-and-proceed. `--no-airtable-row` opts out.
|
|
160
|
+
if (flags.airtableRow !== false) {
|
|
161
|
+
const reg = await registerProjectRow(inputs, {
|
|
162
|
+
dryRun: flags.dryRun === true,
|
|
163
|
+
// Verify the coordination block on disk before asserting Registered.
|
|
164
|
+
targetPath,
|
|
89
165
|
});
|
|
166
|
+
if (reg.outcome === "failed") {
|
|
167
|
+
process.stderr.write(`\n${reg.message}\n`);
|
|
168
|
+
}
|
|
169
|
+
else if (reg.outcome !== "skipped") {
|
|
170
|
+
process.stdout.write(`\n${reg.message}\n`);
|
|
171
|
+
}
|
|
90
172
|
}
|
|
91
|
-
|
|
92
|
-
|
|
173
|
+
// Neon inventory write (project-inventory migration P3 — DUAL-WRITE alongside
|
|
174
|
+
// Airtable during the transition; Airtable is dropped at P6). No-op unless
|
|
175
|
+
// Z2W_INVENTORY_DATABASE_URL is set (so it never fires for normal users) and
|
|
176
|
+
// never blocks the scaffold — warn-and-proceed. `--no-inventory-row` opts out.
|
|
177
|
+
if (flags.inventoryRow !== false) {
|
|
178
|
+
const reg = await registerProjectRowNeon(inputs, {
|
|
179
|
+
dryRun: flags.dryRun === true,
|
|
180
|
+
// Verify the coordination block on disk before asserting Registered.
|
|
181
|
+
targetPath,
|
|
182
|
+
});
|
|
183
|
+
if (reg.outcome === "failed") {
|
|
184
|
+
process.stderr.write(`\n${reg.message}\n`);
|
|
185
|
+
}
|
|
186
|
+
else if (reg.outcome !== "skipped") {
|
|
187
|
+
process.stdout.write(`\n${reg.message}\n`);
|
|
188
|
+
}
|
|
93
189
|
}
|
|
94
190
|
}
|
|
95
191
|
const program = new Command();
|
|
@@ -105,13 +201,14 @@ program
|
|
|
105
201
|
.option("--show-contents", "in --dry-run mode, also print every file's full content")
|
|
106
202
|
.option("--input <source>", "load ScaffoldInputs JSON from a file path, or '-' for stdin (bypasses brief/wizard)")
|
|
107
203
|
.option("--target-path <path>", "absolute path to scaffold into (defaults to inputs.targetPath)")
|
|
108
|
-
.option("--templates-path <path>", "absolute path to the Templates folder (default: ~/Desktop/Zero2Webmaster/AI/Templates
|
|
109
|
-
.option("--refresh-templates", "force-refresh the local Templates cache (~/.cache/z2w-templates/) from the mirror")
|
|
204
|
+
.option("--templates-path <path>", "absolute path to the Templates folder (default: ~/Desktop/Zero2Webmaster/AI/Templates)")
|
|
110
205
|
.option("--promote-standards", "run the (a) inline / (b) promote-into-Templates dialog per applicable standard")
|
|
111
206
|
.option("--allow-non-empty", "allow writes into a non-empty target directory (default: refuse)")
|
|
112
207
|
.option("--no-color", "disable colored output (default: auto-detect TTY)")
|
|
113
|
-
.option("--
|
|
208
|
+
.option("--no-repo", "skip the default creation of the private GitHub repo (git init + first commit + `gh repo create {githubOrg}/{slug} --private` + push)")
|
|
114
209
|
.option("--with-pro-seo", "(paid; nextjs/cf-pages) layer the Pro SEO baseline extension on top of the base scaffold")
|
|
210
|
+
.option("--no-airtable-row", "skip Airtable inventory auto-registration (only fires when AIRTABLE_WRITE_PAT is set; internal)")
|
|
211
|
+
.option("--no-inventory-row", "skip the Neon inventory write (only fires when Z2W_INVENTORY_DATABASE_URL is set; internal)")
|
|
115
212
|
.action(async (opts) => {
|
|
116
213
|
try {
|
|
117
214
|
await runInit({
|
|
@@ -121,12 +218,13 @@ program
|
|
|
121
218
|
input: typeof opts["input"] === "string" ? opts["input"] : undefined,
|
|
122
219
|
targetPath: typeof opts["targetPath"] === "string" ? opts["targetPath"] : undefined,
|
|
123
220
|
templatesPath: typeof opts["templatesPath"] === "string" ? opts["templatesPath"] : undefined,
|
|
124
|
-
refreshTemplates: opts["refreshTemplates"] === true,
|
|
125
221
|
promoteStandards: opts["promoteStandards"] === true,
|
|
126
222
|
refuseNonEmpty: opts["allowNonEmpty"] !== true,
|
|
127
223
|
noColor: opts["color"] === false,
|
|
128
|
-
|
|
224
|
+
repo: opts["repo"] !== false,
|
|
129
225
|
withProSeo: opts["withProSeo"] === true,
|
|
226
|
+
airtableRow: opts["airtableRow"] !== false,
|
|
227
|
+
inventoryRow: opts["inventoryRow"] !== false,
|
|
130
228
|
});
|
|
131
229
|
}
|
|
132
230
|
catch (err) {
|
package/dist/confirm.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ParsedBrief } from "./parse-brief.js";
|
|
2
2
|
import type { BrandPreset, CustomBrandInputs, DbStrategy, ProjectType, ScaffoldInputs } from "./index.js";
|
|
3
|
+
import { BRANDS, DB_STRATEGIES, PROJECT_TYPES } from "./index.js";
|
|
3
4
|
export type Prompter = (message: string, defaultValue?: string) => Promise<string>;
|
|
4
5
|
/**
|
|
5
6
|
* Thrown when the user types an exit keyword (`cancel` / `abort` / `quit` /
|
|
@@ -18,9 +19,7 @@ export interface ConfirmOptions {
|
|
|
18
19
|
/** Skips on-disk checks for the target path; tests set this to true. */
|
|
19
20
|
skipFsChecks?: boolean;
|
|
20
21
|
}
|
|
21
|
-
export
|
|
22
|
-
export declare const BRANDS: readonly BrandPreset[];
|
|
23
|
-
export declare const DB_STRATEGIES: readonly DbStrategy[];
|
|
22
|
+
export { BRANDS, DB_STRATEGIES, PROJECT_TYPES };
|
|
24
23
|
export declare const UNSET_PLACEHOLDER = "[unset \u2014 please type]";
|
|
25
24
|
type ParseResult<T> = {
|
|
26
25
|
ok: true;
|
|
@@ -40,6 +39,9 @@ interface Draft {
|
|
|
40
39
|
hasWebUi: boolean | null;
|
|
41
40
|
hasCron: boolean | null;
|
|
42
41
|
participateInBulletin: boolean | null;
|
|
42
|
+
sendsEmail: boolean;
|
|
43
|
+
hasUserContent: boolean;
|
|
44
|
+
hasObservability: boolean;
|
|
43
45
|
customBrand: CustomBrandInputs | null;
|
|
44
46
|
}
|
|
45
47
|
export declare function renderDraft(draft: Draft): string;
|
|
@@ -52,4 +54,3 @@ export declare function parseSlug(raw: string): ParseResult<string>;
|
|
|
52
54
|
* refuses to accept while any field is still `[unset — please type]`.
|
|
53
55
|
*/
|
|
54
56
|
export declare function confirmInputs(parsed: ParsedBrief, opts: ConfirmOptions): Promise<ScaffoldInputs>;
|
|
55
|
-
export {};
|
package/dist/confirm.js
CHANGED
|
@@ -10,6 +10,7 @@ import * as path from "node:path";
|
|
|
10
10
|
import { promises as fs } from "node:fs";
|
|
11
11
|
import { expandHome, githubOrgForBrand, isValidSlug, kebabCase, } from "./parse-brief.js";
|
|
12
12
|
import { isHexColor } from "./brand.js";
|
|
13
|
+
import { BRANDS, DB_STRATEGIES, PROJECT_TYPES } from "./index.js";
|
|
13
14
|
/**
|
|
14
15
|
* Thrown when the user types an exit keyword (`cancel` / `abort` / `quit` /
|
|
15
16
|
* `q`) at the confirmation prompt. Before v0.2.1 the only escape from the
|
|
@@ -24,29 +25,10 @@ export class ConfirmCancelledError extends Error {
|
|
|
24
25
|
}
|
|
25
26
|
/** Exit keywords accepted at the confirmation prompt (case-insensitive). */
|
|
26
27
|
export const CONFIRM_CANCEL_KEYWORDS = ["cancel", "abort", "quit", "q"];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"nextjs",
|
|
32
|
-
"python-service",
|
|
33
|
-
"library",
|
|
34
|
-
"protocol-repo",
|
|
35
|
-
];
|
|
36
|
-
export const BRANDS = [
|
|
37
|
-
"save-the-frogs",
|
|
38
|
-
"bansuri-bliss",
|
|
39
|
-
"zero2webmaster",
|
|
40
|
-
"custom",
|
|
41
|
-
];
|
|
42
|
-
export const DB_STRATEGIES = [
|
|
43
|
-
"none",
|
|
44
|
-
"neon-postgres",
|
|
45
|
-
"supabase",
|
|
46
|
-
"sqlite",
|
|
47
|
-
"mysql-wp",
|
|
48
|
-
"other",
|
|
49
|
-
];
|
|
28
|
+
// The canonical enum value-arrays now live in index.ts (next to the type
|
|
29
|
+
// unions they enumerate); re-exported here so the confirm/wizard flows and
|
|
30
|
+
// their tests keep importing them from confirm unchanged.
|
|
31
|
+
export { BRANDS, DB_STRATEGIES, PROJECT_TYPES };
|
|
50
32
|
export const UNSET_PLACEHOLDER = "[unset — please type]";
|
|
51
33
|
function fmt(value) {
|
|
52
34
|
if (value === null || value === undefined)
|
|
@@ -72,7 +54,7 @@ export function renderDraft(draft) {
|
|
|
72
54
|
const cb = draft.customBrand;
|
|
73
55
|
lines.push(` 4a. Brand name ................ ${fmtCustom(cb?.brandName)}`, ` 4b. Capitalization rule ....... ${fmtCustom(cb?.brandNameRule)}`, ` 4c. Primary hex color ......... ${fmtCustom(cb?.primaryColor)}`, ` 4d. Accent hex color .......... ${fmtCustom(cb?.accentColor)}`);
|
|
74
56
|
}
|
|
75
|
-
lines.push(` 5. GitHub org ..................... ${fmt(draft.githubOrg)}`, ` 6. Target path .................... ${fmt(draft.targetPath)}`, ` 7. Database strategy .............. ${fmt(draft.dbStrategy)}`, ` 8. Has web UI ..................... ${fmt(draft.hasWebUi)}`, ` 9. Has cron / scheduled jobs ...... ${fmt(draft.hasCron)}`, ` 10. Participate in agent bulletin .. ${fmt(draft.participateInBulletin)}`);
|
|
57
|
+
lines.push(` 5. GitHub org ..................... ${fmt(draft.githubOrg)}`, ` 6. Target path .................... ${fmt(draft.targetPath)}`, ` 7. Database strategy .............. ${fmt(draft.dbStrategy)}`, ` 8. Has web UI ..................... ${fmt(draft.hasWebUi)}`, ` 9. Has cron / scheduled jobs ...... ${fmt(draft.hasCron)}`, ` 10. Participate in agent bulletin .. ${fmt(draft.participateInBulletin)}`, ` 11. Sends transactional/auth email . ${fmt(draft.sendsEmail)}`, ` 12. Accepts user-generated content ${fmt(draft.hasUserContent)}`, ` 13. Wire Sentry error tracking ..... ${fmt(draft.hasObservability)}`);
|
|
76
58
|
return lines.join("\n");
|
|
77
59
|
}
|
|
78
60
|
export function parseSlug(raw) {
|
|
@@ -322,8 +304,32 @@ async function editField(draft, fieldNumber, opts) {
|
|
|
322
304
|
draft.participateInBulletin = result.value;
|
|
323
305
|
return null;
|
|
324
306
|
}
|
|
307
|
+
case 11: {
|
|
308
|
+
const raw = await opts.prompter("Sends transactional / auth email (yes/no):", draft.sendsEmail ? "yes" : "no");
|
|
309
|
+
const result = parseBoolean(raw, "Sends transactional / auth email");
|
|
310
|
+
if (!result.ok)
|
|
311
|
+
return result.error;
|
|
312
|
+
draft.sendsEmail = result.value;
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
case 12: {
|
|
316
|
+
const raw = await opts.prompter("Accepts user-generated content (yes/no):", draft.hasUserContent ? "yes" : "no");
|
|
317
|
+
const result = parseBoolean(raw, "Accepts user-generated content");
|
|
318
|
+
if (!result.ok)
|
|
319
|
+
return result.error;
|
|
320
|
+
draft.hasUserContent = result.value;
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
case 13: {
|
|
324
|
+
const raw = await opts.prompter("Wire Sentry runtime-error tracking (yes/no):", draft.hasObservability ? "yes" : "no");
|
|
325
|
+
const result = parseBoolean(raw, "Wire Sentry runtime-error tracking");
|
|
326
|
+
if (!result.ok)
|
|
327
|
+
return result.error;
|
|
328
|
+
draft.hasObservability = result.value;
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
325
331
|
default:
|
|
326
|
-
return `Field number must be between 1 and
|
|
332
|
+
return `Field number must be between 1 and 13. Got: ${fieldNumber}.`;
|
|
327
333
|
}
|
|
328
334
|
}
|
|
329
335
|
/**
|
|
@@ -346,14 +352,17 @@ export async function confirmInputs(parsed, opts) {
|
|
|
346
352
|
hasWebUi: parsed.hasWebUi,
|
|
347
353
|
hasCron: parsed.hasCron,
|
|
348
354
|
participateInBulletin: parsed.participateInBulletin,
|
|
355
|
+
sendsEmail: parsed.sendsEmail,
|
|
356
|
+
hasUserContent: parsed.hasUserContent,
|
|
357
|
+
hasObservability: parsed.hasObservability,
|
|
349
358
|
customBrand: null,
|
|
350
359
|
};
|
|
351
360
|
while (true) {
|
|
352
361
|
output.write(`\nInferred inputs from your brief:\n\n${renderDraft(draft)}\n\n`);
|
|
353
362
|
const complete = isComplete(draft);
|
|
354
363
|
const prompt = complete
|
|
355
|
-
? "Press Enter to accept, a line number (1-
|
|
356
|
-
: "Type a line number (1-
|
|
364
|
+
? "Press Enter to accept, a line number (1-13) to edit, or 'cancel' to exit (Ctrl+C also works):"
|
|
365
|
+
: "Type a line number (1-13) to fill or edit, or 'cancel' to exit (Ctrl+C also works). Every field must be set before accepting.";
|
|
357
366
|
const reply = (await opts.prompter(prompt)).trim();
|
|
358
367
|
if (CONFIRM_CANCEL_KEYWORDS.includes(reply.toLowerCase())) {
|
|
359
368
|
throw new ConfirmCancelledError();
|
|
@@ -370,8 +379,8 @@ export async function confirmInputs(parsed, opts) {
|
|
|
370
379
|
continue;
|
|
371
380
|
}
|
|
372
381
|
const fieldNumber = Number(reply);
|
|
373
|
-
if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber >
|
|
374
|
-
output.write(`\n ✗ "${reply}" is not a line number (1-
|
|
382
|
+
if (!Number.isInteger(fieldNumber) || fieldNumber < 1 || fieldNumber > 13) {
|
|
383
|
+
output.write(`\n ✗ "${reply}" is not a line number (1-13).\n`);
|
|
375
384
|
continue;
|
|
376
385
|
}
|
|
377
386
|
const error = await editField(draft, fieldNumber, opts);
|
|
@@ -390,6 +399,9 @@ export async function confirmInputs(parsed, opts) {
|
|
|
390
399
|
hasWebUi: draft.hasWebUi,
|
|
391
400
|
hasCron: draft.hasCron,
|
|
392
401
|
participateInBulletin: draft.participateInBulletin,
|
|
402
|
+
sendsEmail: draft.sendsEmail,
|
|
403
|
+
hasUserContent: draft.hasUserContent,
|
|
404
|
+
hasObservability: draft.hasObservability,
|
|
393
405
|
};
|
|
394
406
|
if (draft.brand === "custom" && draft.customBrand !== null) {
|
|
395
407
|
result.customBrand = draft.customBrand;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { writeScaffold } from "./writer.js";
|
|
2
|
+
import type { ScaffoldFile } from "./scaffolders/common.js";
|
|
3
|
+
import type { StandardDecision } from "./standards.js";
|
|
4
|
+
export declare const version = "0.3.1";
|
|
5
|
+
export type ProjectType = "wp-plugin" | "cf-worker" | "cf-pages" | "nextjs" | "python-service" | "node-service" | "library" | "protocol-repo";
|
|
3
6
|
export type BrandPreset = "save-the-frogs" | "bansuri-bliss" | "zero2webmaster" | "custom";
|
|
4
7
|
export type DbStrategy = "none" | "neon-postgres" | "supabase" | "sqlite" | "mysql-wp" | "other";
|
|
8
|
+
export declare const PROJECT_TYPES: readonly ProjectType[];
|
|
9
|
+
export declare const BRANDS: readonly BrandPreset[];
|
|
10
|
+
export declare const DB_STRATEGIES: readonly DbStrategy[];
|
|
5
11
|
/**
|
|
6
12
|
* Follow-up details a user supplies when `brand` is `"custom"`. Carries the
|
|
7
13
|
* four fields the confirmation / wizard flows ask for: brand name, the
|
|
@@ -19,8 +25,11 @@ export interface CustomBrandInputs {
|
|
|
19
25
|
* is optional — only the sections the brief actually contained are populated.
|
|
20
26
|
* Carried through to the scaffolder so the brief's planning content flows into
|
|
21
27
|
* the generated ROADMAP.md + README.md rather than being discarded after
|
|
22
|
-
* field inference (per [[instantiate-z2w-project]] SKILL Step 1a.4).
|
|
23
|
-
*
|
|
28
|
+
* field inference (per [[instantiate-z2w-project]] SKILL Step 1a.4). Populated
|
|
29
|
+
* automatically by the brief-first flow; absent for `--wizard`. The `--input`
|
|
30
|
+
* path has no brief to parse, but a caller that already has the sections may
|
|
31
|
+
* supply them in the input JSON (`parseScaffoldInputs` reads them) so an
|
|
32
|
+
* `--input` scaffold still gets a concrete ROADMAP instead of a placeholder.
|
|
24
33
|
*/
|
|
25
34
|
export interface BriefSections {
|
|
26
35
|
purpose?: string;
|
|
@@ -42,9 +51,173 @@ export interface ScaffoldInputs {
|
|
|
42
51
|
hasWebUi: boolean;
|
|
43
52
|
hasCron: boolean;
|
|
44
53
|
participateInBulletin: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether this project sends transactional / auth email (magic links,
|
|
56
|
+
* confirmations, notifications). When `true`, the `nextjs` and `node-service`
|
|
57
|
+
* scaffolders emit a provider-router mailer (`sendEmail()` with a stable,
|
|
58
|
+
* provider-agnostic signature) defaulting to Amazon SES with Resend as a
|
|
59
|
+
* one-env-var swappable alternative (`EMAIL_PROVIDER=resend`), plus both
|
|
60
|
+
* providers' env stubs and a `directives/email-setup.md` setup runbook. Per
|
|
61
|
+
* the 2026-06-28 email-default decision (event-engine, on Kerry's steer): when
|
|
62
|
+
* a stack already runs SES in production (STF / BB / Z2W), default to SES —
|
|
63
|
+
* zero new vendor, no domain warmup, cheap at volume — and keep Resend as the
|
|
64
|
+
* easier-DX alternative for non-developer clients. See [[email-service-router]].
|
|
65
|
+
*
|
|
66
|
+
* Optional and defaults to `false` (no mailer emitted). Honored ONLY by the
|
|
67
|
+
* `nextjs` and `node-service` types — WordPress uses FluentSMTP, Cloudflare
|
|
68
|
+
* Workers use the Cloudflare Email Service ([[cloudflare-email-service]]), and
|
|
69
|
+
* `python-service` is a different language, so those types ignore this flag.
|
|
70
|
+
*/
|
|
71
|
+
sendsEmail?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether this project accepts user-generated content (UGC) — a community
|
|
74
|
+
* platform, events app with public listings, marketplace, comments/forum,
|
|
75
|
+
* profiles, direct messages, or any surface where one user's input is shown
|
|
76
|
+
* to others. When `true`, the standards resolver inserts the "Moderation
|
|
77
|
+
* baseline (user-generated content)" standard pointing at [[moderation-system]]
|
|
78
|
+
* — the entity-agnostic report→queue model, reporting-as-a-safety-action,
|
|
79
|
+
* enforcement-that-reuses-existing-gates, the fail-open AI-scan seam, the
|
|
80
|
+
* public/anonymous-reporter variant, and the optional pre-publish gate — so a
|
|
81
|
+
* new UGC app treats moderation as an at-instantiation decision (like the SEO
|
|
82
|
+
* baseline for public web UIs) rather than a Phase-8 afterthought. Requested
|
|
83
|
+
* by the event-engine agent on the bulletin (2026-07-08), which built the
|
|
84
|
+
* second reference implementation of the pattern.
|
|
85
|
+
*
|
|
86
|
+
* Optional and defaults to `false` (no standard emitted). Skipped for the
|
|
87
|
+
* `wp-plugin` type (WordPress moderates comments natively / via Akismet), and
|
|
88
|
+
* for `library` / `protocol-repo` (no content surface).
|
|
89
|
+
*/
|
|
90
|
+
hasUserContent?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Whether this project should wire runtime error / APM observability
|
|
93
|
+
* (Sentry) at instantiation. When `true` AND the type is a Next.js / CF-Pages
|
|
94
|
+
* web app, the standards resolver inserts the "Sentry runtime-error tracking"
|
|
95
|
+
* standard pointing at [[sentry-runtime-errors]] — the `npx @sentry/wizard`
|
|
96
|
+
* invocation, DSN-in-config posture, `SENTRY_AUTH_TOKEN` Production-only
|
|
97
|
+
* scope, the tracing/replay feature-flag defaults, the smoke-route pattern,
|
|
98
|
+
* and the 2025 Sentry-UI quirks — so a customer-facing app treats runtime
|
|
99
|
+
* error capture as an at-instantiation decision (like Fathom for analytics and
|
|
100
|
+
* Uptime Kuma for liveness) rather than a post-incident afterthought. Sentry
|
|
101
|
+
* fills the gap uptime monitoring can't: a per-user 500 that `/health` never
|
|
102
|
+
* sees. Requested by the videomigrator-dashboard agent on the bulletin
|
|
103
|
+
* (2026-06-11) after wiring Sentry there; see [[sentry-runtime-errors]].
|
|
104
|
+
*
|
|
105
|
+
* Optional. Omitted (undefined) reads as `false` in the standards resolver —
|
|
106
|
+
* so the programmatic API and `--input` paths stay explicit/opt-in — while the
|
|
107
|
+
* interactive brief-first and wizard flows apply a smart default of ON for
|
|
108
|
+
* customer-facing Next.js / CF-Pages apps (a human can veto at the confirm
|
|
109
|
+
* screen). Skipped for every type except `nextjs` / `cf-pages`: WordPress
|
|
110
|
+
* gets error tracking via Admin Suite Diagnostics; CLI libraries, protocol
|
|
111
|
+
* repos, Workers, and API-only services have no "individual user request
|
|
112
|
+
* failed silently" surface.
|
|
113
|
+
*/
|
|
114
|
+
hasObservability?: boolean;
|
|
45
115
|
/** Present only when `brand === "custom"`. */
|
|
46
116
|
customBrand?: CustomBrandInputs;
|
|
47
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Present when scaffolding from a pasted brief that had these sections (the
|
|
119
|
+
* brief-first flow), or when an `--input` payload supplies them explicitly.
|
|
120
|
+
*/
|
|
48
121
|
briefSections?: BriefSections;
|
|
122
|
+
/**
|
|
123
|
+
* The verbatim project-instantiation brief/prompt this project was scaffolded
|
|
124
|
+
* from. Captured automatically by the brief-first flow (the raw pasted brief);
|
|
125
|
+
* may be supplied on the `--input` JSON. Written to the Airtable inventory
|
|
126
|
+
* row's "Project Instantiation Prompt" column (Kerry's standing rule that
|
|
127
|
+
* every inventory row carries its instantiation prompt). Absent for the
|
|
128
|
+
* wizard path and `--input` payloads that omit it — in which case the agent
|
|
129
|
+
* is reminded to add it to the row by hand.
|
|
130
|
+
*/
|
|
131
|
+
instantiationPrompt?: string;
|
|
49
132
|
}
|
|
50
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Options for the programmatic {@link scaffold} / {@link previewScaffold} entry
|
|
135
|
+
* points. A deliberately small subset of {@link WriteScaffoldOptions} — the
|
|
136
|
+
* interactive-only knobs (`promoteStandards`, `prompter`, `output`,
|
|
137
|
+
* `showContents`) are omitted because a programmatic caller neither prompts nor
|
|
138
|
+
* prints. Reach for `writeScaffold` directly if you need those.
|
|
139
|
+
*/
|
|
140
|
+
export interface ScaffoldOptions {
|
|
141
|
+
/** Absolute target directory. Defaults to `inputs.targetPath`. */
|
|
142
|
+
targetPath?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Pin the scaffold date as `YYYY-MM-DD` for deterministic output (tests,
|
|
145
|
+
* reproducible builds). Defaults to today from the OS clock.
|
|
146
|
+
*/
|
|
147
|
+
date?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Override the canonical Templates folder location. Defaults to the standard
|
|
150
|
+
* local resolution (`~/Desktop/Zero2Webmaster/AI/Templates/`). A server
|
|
151
|
+
* consumer bundles/mounts Templates and points this at it — the folder is
|
|
152
|
+
* read server-side and never delivered to the client.
|
|
153
|
+
*/
|
|
154
|
+
templatesPath?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Refuse to write into a non-empty directory. Defaults to `true`. Ignored by
|
|
157
|
+
* {@link previewScaffold} (which never touches disk).
|
|
158
|
+
*/
|
|
159
|
+
refuseNonEmpty?: boolean;
|
|
160
|
+
/** Layer the paid Pro SEO baseline extension (nextjs / cf-pages + hasWebUi only). */
|
|
161
|
+
withProSeo?: boolean;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The result of a scaffold or preview: the composed file list, the standards
|
|
165
|
+
* decision log, and the resolved absolute target path. For {@link scaffold}
|
|
166
|
+
* these are the files that WERE written; for {@link previewScaffold} they are
|
|
167
|
+
* the files that WOULD be written.
|
|
168
|
+
*/
|
|
169
|
+
export interface ScaffoldResult {
|
|
170
|
+
files: ScaffoldFile[];
|
|
171
|
+
decisions: StandardDecision[];
|
|
172
|
+
targetPath: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Scaffold a full project to disk and return the composed result.
|
|
176
|
+
*
|
|
177
|
+
* The high-level programmatic equivalent of `npx @zero2webmaster/starter-kit
|
|
178
|
+
* init` for a caller that already has validated {@link ScaffoldInputs} (e.g.
|
|
179
|
+
* from {@link parseScaffoldInputs} + {@link validateScaffoldInputs}). Delegates
|
|
180
|
+
* to {@link writeScaffold}; the canonical AGENTS body + standards are read and
|
|
181
|
+
* composed exactly as the CLI does. Throws `WriterError` on a non-absolute or
|
|
182
|
+
* (by default) non-empty target, or if any template marker / `{{placeholder}}`
|
|
183
|
+
* survives composition.
|
|
184
|
+
*/
|
|
185
|
+
export declare function scaffold(inputs: ScaffoldInputs, opts?: ScaffoldOptions): Promise<ScaffoldResult>;
|
|
186
|
+
/**
|
|
187
|
+
* Compose the exact same file list {@link scaffold} would write, but WITHOUT
|
|
188
|
+
* touching the filesystem and without printing anything — the files are
|
|
189
|
+
* returned as data. This is the entry point a web UI / server consumer wants:
|
|
190
|
+
* show the user what they'll get (file tree, standards inserted) before they
|
|
191
|
+
* commit to creating a repo.
|
|
192
|
+
*
|
|
193
|
+
* The only I/O is reading the Templates folder (needed to fill the AGENTS
|
|
194
|
+
* body). `inputs.targetPath` (or `opts.targetPath`) must still be an absolute
|
|
195
|
+
* path — it's used only to validate that every generated file resolves inside
|
|
196
|
+
* it; nothing is created there. `refuseNonEmpty` is not consulted.
|
|
197
|
+
*/
|
|
198
|
+
export declare function previewScaffold(inputs: ScaffoldInputs, opts?: ScaffoldOptions): Promise<ScaffoldResult>;
|
|
199
|
+
/** Outcome of {@link validateScaffoldInputs}: `ok` plus every error found. */
|
|
200
|
+
export interface ScaffoldInputValidation {
|
|
201
|
+
ok: boolean;
|
|
202
|
+
errors: string[];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Structurally validate a {@link ScaffoldInputs} without touching the
|
|
206
|
+
* filesystem, collecting ALL problems (not just the first). Complements
|
|
207
|
+
* {@link parseScaffoldInputs}, which checks primitive types + required-field
|
|
208
|
+
* presence but deliberately does NOT check the slug regex, enum membership, or
|
|
209
|
+
* that `targetPath` is absolute — this does, so a server can reject a bad form
|
|
210
|
+
* submission with a complete error list before attempting a scaffold.
|
|
211
|
+
*
|
|
212
|
+
* Note: does not check that `targetPath` is empty/writable on disk — that's an
|
|
213
|
+
* async filesystem concern the CLI's confirm flow owns, and `scaffold` enforces
|
|
214
|
+
* it at write time via `refuseNonEmpty`.
|
|
215
|
+
*/
|
|
216
|
+
export declare function validateScaffoldInputs(inputs: ScaffoldInputs): ScaffoldInputValidation;
|
|
217
|
+
export { writeScaffold };
|
|
218
|
+
export { parseScaffoldInputs, loadScaffoldInputs, WriterError } from "./writer.js";
|
|
219
|
+
export type { WriteScaffoldOptions, WriteScaffoldResult, PromotionDecision, } from "./writer.js";
|
|
220
|
+
export { resolveStandards, applyStandardsBlock, fathomEnvVarFor } from "./standards.js";
|
|
221
|
+
export type { StandardKey, StandardDecision, StandardDecisionState, StandardsResolution, } from "./standards.js";
|
|
222
|
+
export { scaffoldByType } from "./scaffolders/index.js";
|
|
223
|
+
export type { ScaffoldFile, ScaffolderOptions } from "./scaffolders/common.js";
|