@zero2webmaster/starter-kit 0.2.0 → 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.
- package/README.md +4 -3
- package/dist/brief.d.ts +2 -2
- package/dist/brief.js +11 -4
- package/dist/cli.js +186 -11
- package/dist/confirm.d.ts +11 -0
- package/dist/confirm.js +27 -5
- package/dist/index.d.ts +20 -1
- package/dist/index.js +1 -1
- package/dist/license.d.ts +97 -0
- package/dist/license.js +472 -0
- package/dist/parse-brief.d.ts +19 -1
- package/dist/parse-brief.js +213 -20
- package/dist/scaffolders/common.d.ts +13 -1
- package/dist/scaffolders/common.js +217 -11
- package/dist/scaffolders/nextjs.js +6 -2
- package/dist/scaffolders/pro-seo-extension.d.ts +11 -0
- package/dist/scaffolders/pro-seo-extension.js +782 -0
- package/dist/scaffolders/python-service.js +6 -1
- package/dist/scaffolders/wp-plugin.js +8 -8
- package/dist/standards.d.ts +1 -1
- package/dist/standards.js +41 -2
- package/dist/substitute.d.ts +8 -0
- package/dist/substitute.js +11 -0
- package/dist/summary.js +4 -3
- package/dist/with-init.d.ts +16 -0
- package/dist/with-init.js +82 -0
- package/dist/writer.d.ts +10 -1
- package/dist/writer.js +31 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 0.2.
|
|
3
|
+
**Version:** 0.2.1 | **Framework:** 2.13.0
|
|
4
4
|
|
|
5
5
|
> Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
|
|
6
6
|
|
|
@@ -85,7 +85,8 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
|
|
|
85
85
|
|
|
86
86
|
## Status
|
|
87
87
|
|
|
88
|
-
- **v0.2.
|
|
88
|
+
- **v0.2.1** is a buyer-experience polish pass over v0.2.0's free-on-any-machine CLI (hosted Templates mirror at [`templates.z2w.us`](https://templates.z2w.us)). It lands the brief-first hardening slice (secret-safe `.gitignore`, brief parser fixes, cancel-safe confirm, cd-safe git next-actions) plus: a scannable `--dry-run` file list (`--show-contents` for the full dump), Fathom correctly skipped for WordPress plugins, UPPER_SNAKE PHP constants, a scaffolded `.env.local`/`.env`, brief planning sections flowing into `ROADMAP.md`, and a populated README Overview + per-type Quick start.
|
|
89
|
+
- **v0.2.0** shipped as a fully-free CLI that works on **any machine** — the hosted Templates mirror makes the CLI usable without a local Templates folder.
|
|
89
90
|
- The runtime license-validation Worker and the first paid features (`--with-init`, Pro SEO baseline) per the project brief are a separate **v0.3.x** track, gated on a marketing/distribution plan session.
|
|
90
91
|
|
|
91
92
|
## License
|
|
@@ -100,4 +101,4 @@ For licensing inquiries: kerry@zero2webmaster.com.
|
|
|
100
101
|
---
|
|
101
102
|
|
|
102
103
|
*Scaffolded 2026-05-28 via the [[instantiate-z2w-project]] Claude Code skill v1; reconciled against the consolidated skill v1.1.0 (brief-first + Agent Coordination block) on 2026-05-29.*
|
|
103
|
-
*Version: 0.2.
|
|
104
|
+
*Version: 0.2.1 | Last Updated: 2026-06-15*
|
package/dist/brief.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export interface GatherBriefOptions {
|
|
|
8
8
|
/** Test seam: when supplied, lines are read from here instead of `input`. */
|
|
9
9
|
lines?: AsyncIterable<string>;
|
|
10
10
|
}
|
|
11
|
-
export declare const BRIEF_PROMPT = "Paste your project instantiation prompt. End with a line containing only
|
|
12
|
-
export declare const BRIEF_SENTINEL = "
|
|
11
|
+
export declare const BRIEF_PROMPT = "Paste your project instantiation prompt. End with a line containing only `<<END>>` (or press Ctrl+D) to signal done. Type `skip` to fall through to wizard mode.";
|
|
12
|
+
export declare const BRIEF_SENTINEL = "<<END>>";
|
|
13
13
|
export declare function gatherBrief(opts?: GatherBriefOptions): Promise<BriefResult>;
|
package/dist/brief.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
// z2w-starter-kit brief gatherer.
|
|
2
2
|
//
|
|
3
3
|
// Reads a pasted project-instantiation brief from stdin until a line
|
|
4
|
-
// containing only
|
|
4
|
+
// containing only `<<END>>` (the sentinel) or end-of-stream. A first line of
|
|
5
5
|
// `skip` (case-insensitive) short-circuits to wizard-fallback mode.
|
|
6
6
|
//
|
|
7
|
+
// The sentinel is deliberately NOT `---`: that is the most common markdown
|
|
8
|
+
// section separator and appears many times in any real brief. v0.2.0 used
|
|
9
|
+
// `---`, which truncated pasted briefs at their first section break (the
|
|
10
|
+
// 2026-06-03 z2w-crowdcommerce dogfood P0). `<<END>>` cannot occur in normal
|
|
11
|
+
// prose. When the brief is piped (`cat brief.md | ... init`), end-of-stream
|
|
12
|
+
// terminates the read on its own — no sentinel line is needed at all.
|
|
13
|
+
//
|
|
7
14
|
// Implemented over a node:readline interface rather than @inquirer/prompts
|
|
8
15
|
// because briefs are multi-line pastes — inquirer's `input` is single-line and
|
|
9
16
|
// `editor` opens $EDITOR, neither of which fits "paste from the clipboard."
|
|
10
17
|
// The seam takes an optional async-iterable line source so tests can drive it
|
|
11
18
|
// without spawning a real TTY.
|
|
12
19
|
import { createInterface } from "node:readline";
|
|
13
|
-
export const BRIEF_PROMPT = "Paste your project instantiation prompt. End with a line containing only
|
|
14
|
-
export const BRIEF_SENTINEL = "
|
|
20
|
+
export const BRIEF_PROMPT = "Paste your project instantiation prompt. End with a line containing only `<<END>>` (or press Ctrl+D) to signal done. Type `skip` to fall through to wizard mode.";
|
|
21
|
+
export const BRIEF_SENTINEL = "<<END>>";
|
|
15
22
|
async function* linesFromStream(input) {
|
|
16
23
|
const rl = createInterface({ input, crlfDelay: Infinity });
|
|
17
24
|
for await (const line of rl) {
|
|
@@ -34,7 +41,7 @@ export async function gatherBrief(opts = {}) {
|
|
|
34
41
|
}
|
|
35
42
|
firstNonEmptySeen = true;
|
|
36
43
|
}
|
|
37
|
-
if (trimmed === BRIEF_SENTINEL)
|
|
44
|
+
if (trimmed.toLowerCase() === BRIEF_SENTINEL.toLowerCase())
|
|
38
45
|
break;
|
|
39
46
|
buffer.push(line);
|
|
40
47
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// z2w-starter-kit CLI entry point.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
// confirmation loop; `--wizard` runs the 8-question fallback;
|
|
6
|
-
// bypasses both and reads a JSON `ScaffoldInputs` from stdin
|
|
7
|
-
// path for non-interactive CI / testing use. `--dry-run`
|
|
8
|
-
// + contents to stdout without touching disk.
|
|
9
|
-
// interactive (a) inline / (b) promote-into-
|
|
4
|
+
// `init` command: brief-first input flow + Step 6 writer. The CLI defaults to
|
|
5
|
+
// the brief-paste confirmation loop; `--wizard` runs the 8-question fallback;
|
|
6
|
+
// `--input <src>` bypasses both and reads a JSON `ScaffoldInputs` from stdin
|
|
7
|
+
// (`-`) or a file path for non-interactive CI / testing use. `--dry-run`
|
|
8
|
+
// prints the file list + contents to stdout without touching disk.
|
|
9
|
+
// `--promote-standards` runs the interactive (a) inline / (b) promote-into-
|
|
10
|
+
// Templates dialog before write.
|
|
11
|
+
//
|
|
12
|
+
// `license set|status|refresh|deactivate` subcommands (v0.3.0+): manage the
|
|
13
|
+
// runtime license that gates paid features. See directives/license-check.md.
|
|
14
|
+
//
|
|
15
|
+
// `--with-init` (v0.3.0+, paid feature): after a successful scaffold, run
|
|
16
|
+
// `git init` + first commit + `gh repo create {githubOrg}/{slug} --private`
|
|
17
|
+
// + initial push. Gated by a runtime license check.
|
|
18
|
+
//
|
|
19
|
+
// `--with-pro-seo` (v0.3.0+, paid feature; nextjs/cf-pages only): layers the
|
|
20
|
+
// Pro SEO baseline extension files on top of the base scaffold. Gated by a
|
|
21
|
+
// runtime license check.
|
|
10
22
|
import { Command } from "commander";
|
|
11
23
|
import { input as inquirerInput } from "@inquirer/prompts";
|
|
12
24
|
import { gatherBrief } from "./brief.js";
|
|
13
|
-
import { confirmInputs } from "./confirm.js";
|
|
14
|
-
import {
|
|
25
|
+
import { confirmInputs, ConfirmCancelledError } from "./confirm.js";
|
|
26
|
+
import { activateLicense, checkLicense, clearLicenseState, deactivateLicense, evaluateLicense, isValidLicenseKey, LicenseError, loadLicenseState, maskKey, runtimeLicenseCheck, } from "./license.js";
|
|
27
|
+
import { expandHome, parseBrief } from "./parse-brief.js";
|
|
28
|
+
import { runWithInit, WithInitError } from "./with-init.js";
|
|
15
29
|
import { runWizard } from "./wizard.js";
|
|
16
30
|
import { version } from "./index.js";
|
|
17
31
|
import { renderSummary } from "./summary.js";
|
|
@@ -29,20 +43,54 @@ async function gatherInputs(flags) {
|
|
|
29
43
|
return runWizard({ prompter: inquirerPrompter });
|
|
30
44
|
}
|
|
31
45
|
const parsed = parseBrief(brief);
|
|
46
|
+
// Pre-fill the target path from the --target-path flag so the confirm
|
|
47
|
+
// screen shows it as set (and editable) rather than [unset] — the
|
|
48
|
+
// 2026-06-03 dogfood finding #4, where the flag was honored at write time
|
|
49
|
+
// but ignored by the confirm screen.
|
|
50
|
+
if (flags.targetPath) {
|
|
51
|
+
parsed.targetPath = expandHome(flags.targetPath);
|
|
52
|
+
}
|
|
32
53
|
return confirmInputs(parsed, { prompter: inquirerPrompter });
|
|
33
54
|
}
|
|
55
|
+
async function gatePaidFeatures(flags, stderr = process.stderr) {
|
|
56
|
+
if (!flags.withInit && !flags.withProSeo)
|
|
57
|
+
return;
|
|
58
|
+
const evaluation = await runtimeLicenseCheck();
|
|
59
|
+
if (evaluation.allowPaidFeatures) {
|
|
60
|
+
if (evaluation.warning) {
|
|
61
|
+
stderr.write(`\nlicense: ${evaluation.warning}\n`);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const reason = evaluation.warning ?? "Paid features are not currently allowed.";
|
|
66
|
+
throw new LicenseError(reason);
|
|
67
|
+
}
|
|
34
68
|
async function runInit(flags) {
|
|
69
|
+
await gatePaidFeatures(flags);
|
|
35
70
|
const inputs = await gatherInputs(flags);
|
|
36
|
-
const targetPath = flags.targetPath
|
|
71
|
+
const targetPath = flags.targetPath
|
|
72
|
+
? expandHome(flags.targetPath)
|
|
73
|
+
: inputs.targetPath;
|
|
37
74
|
const result = await writeScaffold(inputs, targetPath, {
|
|
38
75
|
dryRun: flags.dryRun === true,
|
|
76
|
+
showContents: flags.showContents === true,
|
|
39
77
|
refuseNonEmpty: flags.refuseNonEmpty !== false,
|
|
40
78
|
templatesPath: flags.templatesPath,
|
|
41
79
|
refreshTemplates: flags.refreshTemplates === true,
|
|
42
80
|
promoteStandards: flags.promoteStandards === true,
|
|
43
81
|
prompter: flags.promoteStandards ? inquirerPrompter : undefined,
|
|
82
|
+
withProSeo: flags.withProSeo === true,
|
|
44
83
|
});
|
|
45
84
|
renderSummary(inputs, result, { noColor: flags.noColor === true });
|
|
85
|
+
if (flags.withInit && !flags.dryRun) {
|
|
86
|
+
await runWithInit(inputs, targetPath, {
|
|
87
|
+
stdout: process.stdout,
|
|
88
|
+
stderr: process.stderr,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else if (flags.withInit && flags.dryRun) {
|
|
92
|
+
process.stdout.write("\n(--with-init skipped in --dry-run mode; would run git init + commit + gh repo create + push)\n");
|
|
93
|
+
}
|
|
46
94
|
}
|
|
47
95
|
const program = new Command();
|
|
48
96
|
program
|
|
@@ -53,7 +101,8 @@ program
|
|
|
53
101
|
.command("init")
|
|
54
102
|
.description("Scaffold a new project (brief-first; --wizard for fallback; --input for non-interactive)")
|
|
55
103
|
.option("--wizard", "skip the brief prompt and run the 8-question wizard")
|
|
56
|
-
.option("--dry-run", "print the file list
|
|
104
|
+
.option("--dry-run", "print the file list (with byte sizes) without writing to disk")
|
|
105
|
+
.option("--show-contents", "in --dry-run mode, also print every file's full content")
|
|
57
106
|
.option("--input <source>", "load ScaffoldInputs JSON from a file path, or '-' for stdin (bypasses brief/wizard)")
|
|
58
107
|
.option("--target-path <path>", "absolute path to scaffold into (defaults to inputs.targetPath)")
|
|
59
108
|
.option("--templates-path <path>", "absolute path to the Templates folder (default: ~/Desktop/Zero2Webmaster/AI/Templates, falls back to https://templates.z2w.us)")
|
|
@@ -61,11 +110,14 @@ program
|
|
|
61
110
|
.option("--promote-standards", "run the (a) inline / (b) promote-into-Templates dialog per applicable standard")
|
|
62
111
|
.option("--allow-non-empty", "allow writes into a non-empty target directory (default: refuse)")
|
|
63
112
|
.option("--no-color", "disable colored output (default: auto-detect TTY)")
|
|
113
|
+
.option("--with-init", "(paid) after scaffold, run `git init` + first commit + `gh repo create {githubOrg}/{slug} --private` + initial push")
|
|
114
|
+
.option("--with-pro-seo", "(paid; nextjs/cf-pages) layer the Pro SEO baseline extension on top of the base scaffold")
|
|
64
115
|
.action(async (opts) => {
|
|
65
116
|
try {
|
|
66
117
|
await runInit({
|
|
67
118
|
wizard: opts["wizard"] === true,
|
|
68
119
|
dryRun: opts["dryRun"] === true,
|
|
120
|
+
showContents: opts["showContents"] === true,
|
|
69
121
|
input: typeof opts["input"] === "string" ? opts["input"] : undefined,
|
|
70
122
|
targetPath: typeof opts["targetPath"] === "string" ? opts["targetPath"] : undefined,
|
|
71
123
|
templatesPath: typeof opts["templatesPath"] === "string" ? opts["templatesPath"] : undefined,
|
|
@@ -73,12 +125,135 @@ program
|
|
|
73
125
|
promoteStandards: opts["promoteStandards"] === true,
|
|
74
126
|
refuseNonEmpty: opts["allowNonEmpty"] !== true,
|
|
75
127
|
noColor: opts["color"] === false,
|
|
128
|
+
withInit: opts["withInit"] === true,
|
|
129
|
+
withProSeo: opts["withProSeo"] === true,
|
|
76
130
|
});
|
|
77
131
|
}
|
|
78
132
|
catch (err) {
|
|
79
|
-
|
|
133
|
+
if (err instanceof ConfirmCancelledError) {
|
|
134
|
+
// User-initiated exit, not a failure. Exit 130 to mirror Ctrl+C
|
|
135
|
+
// (SIGINT) semantics — no "error:" prefix, no files written.
|
|
136
|
+
process.stderr.write("\nCancelled — no files were written.\n");
|
|
137
|
+
process.exit(130);
|
|
138
|
+
}
|
|
139
|
+
const message = err instanceof WriterError || err instanceof LicenseError || err instanceof WithInitError
|
|
140
|
+
? err.message
|
|
141
|
+
: err.message;
|
|
80
142
|
process.stderr.write(`\nerror: ${message}\n`);
|
|
81
143
|
process.exit(1);
|
|
82
144
|
}
|
|
83
145
|
});
|
|
146
|
+
const licenseCommand = program
|
|
147
|
+
.command("license")
|
|
148
|
+
.description("Manage the runtime license that gates paid features (see directives/license-check.md)");
|
|
149
|
+
licenseCommand
|
|
150
|
+
.command("set <key>")
|
|
151
|
+
.description("Activate this machine against the supplied license key")
|
|
152
|
+
.action(async (key) => {
|
|
153
|
+
if (typeof key !== "string" || key.length === 0) {
|
|
154
|
+
process.stderr.write("\nerror: license key is required\n");
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
if (!isValidLicenseKey(key)) {
|
|
158
|
+
process.stderr.write(`\nerror: license key "${key}" does not match the expected format ` +
|
|
159
|
+
`(Z2W-XXXX-XXXX-XXXX-XXXX...). Double-check the key in your FluentCRM ` +
|
|
160
|
+
"welcome email.\n");
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
const { state, status } = await activateLicense(key);
|
|
165
|
+
process.stdout.write(`\nLicense activated.\n` +
|
|
166
|
+
` key: ${maskKey(state.key)}\n` +
|
|
167
|
+
` product: ${state.productSlug}\n` +
|
|
168
|
+
` machine ID: ${state.machineId}\n` +
|
|
169
|
+
` status: ${status}${state.cachedExpiresAt ? ` (expires ${state.cachedExpiresAt})` : ""}\n`);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
const message = err instanceof LicenseError ? err.message : err.message;
|
|
173
|
+
process.stderr.write(`\nerror: ${message}\n`);
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
licenseCommand
|
|
178
|
+
.command("status")
|
|
179
|
+
.description("Print the current license state (no network call)")
|
|
180
|
+
.action(async () => {
|
|
181
|
+
const state = await loadLicenseState();
|
|
182
|
+
if (state === null) {
|
|
183
|
+
process.stdout.write("\nNo license configured.\n" +
|
|
184
|
+
"Run `z2w-starter-kit license set <key>` to activate, or purchase a license at\n" +
|
|
185
|
+
"https://zero2webmaster.com.\n");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const evaluation = evaluateLicense(state);
|
|
189
|
+
process.stdout.write(`\nLicense status:\n` +
|
|
190
|
+
` key: ${maskKey(state.key)}\n` +
|
|
191
|
+
` product: ${state.productSlug}\n` +
|
|
192
|
+
` machine ID: ${state.machineId}\n` +
|
|
193
|
+
` cached status: ${state.cachedStatus ?? "(unknown)"}\n` +
|
|
194
|
+
` expires at: ${state.cachedExpiresAt ?? "(unknown)"}\n` +
|
|
195
|
+
` last successful: ${state.lastSuccessfulCheck ?? "(never)"}\n` +
|
|
196
|
+
` last attempt: ${state.lastCheckAttempt ?? "(never)"}\n` +
|
|
197
|
+
` days since last: ${evaluation.daysSinceLastCheck ?? "(n/a)"}\n` +
|
|
198
|
+
` paid features: ${evaluation.allowPaidFeatures ? "allowed" : "DECLINED"}\n` +
|
|
199
|
+
` templates updates: ${evaluation.allowTemplatesUpdates ? "allowed" : "declined"}\n` +
|
|
200
|
+
` reason: ${evaluation.reason}\n` +
|
|
201
|
+
(evaluation.warning ? ` warning: ${evaluation.warning}\n` : "") +
|
|
202
|
+
(state.retryAfter ? ` retry-after: ${state.retryAfter}\n` : ""));
|
|
203
|
+
});
|
|
204
|
+
licenseCommand
|
|
205
|
+
.command("refresh")
|
|
206
|
+
.description("Force a re-check against zero2webmaster.com (bypasses the 24h local cache)")
|
|
207
|
+
.action(async () => {
|
|
208
|
+
const existing = await loadLicenseState();
|
|
209
|
+
if (existing === null) {
|
|
210
|
+
process.stderr.write("\nNo license configured. Run `z2w-starter-kit license set <key>` first.\n");
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const result = await checkLicense();
|
|
215
|
+
const evaluation = evaluateLicense(result.state);
|
|
216
|
+
if (result.networkOk) {
|
|
217
|
+
process.stdout.write(`\nLicense refresh succeeded.\n` +
|
|
218
|
+
` status: ${result.status}\n` +
|
|
219
|
+
` paid features: ${evaluation.allowPaidFeatures ? "allowed" : "DECLINED"}\n` +
|
|
220
|
+
` templates: ${evaluation.allowTemplatesUpdates ? "allowed" : "declined"}\n` +
|
|
221
|
+
` reason: ${evaluation.reason}\n` +
|
|
222
|
+
(evaluation.warning ? ` warning: ${evaluation.warning}\n` : ""));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
process.stderr.write(`\nLicense refresh failed.\n` +
|
|
226
|
+
` message: ${result.message ?? "(no detail)"}\n` +
|
|
227
|
+
` cached status: ${result.status ?? "(unknown)"}\n` +
|
|
228
|
+
` paid features: ${evaluation.allowPaidFeatures ? "allowed (within grace window)" : "DECLINED"}\n` +
|
|
229
|
+
(evaluation.warning ? ` warning: ${evaluation.warning}\n` : ""));
|
|
230
|
+
if (!evaluation.allowPaidFeatures) {
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
const message = err instanceof LicenseError ? err.message : err.message;
|
|
236
|
+
process.stderr.write(`\nerror: ${message}\n`);
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
licenseCommand
|
|
241
|
+
.command("deactivate")
|
|
242
|
+
.description("Deactivate this machine and clear the local license file")
|
|
243
|
+
.action(async () => {
|
|
244
|
+
try {
|
|
245
|
+
await deactivateLicense();
|
|
246
|
+
process.stdout.write("\nLicense deactivated and local state cleared.\n");
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
if (err instanceof LicenseError) {
|
|
250
|
+
process.stderr.write(`\n${err.message}\n`);
|
|
251
|
+
// Best-effort clear in case state exists but server call failed mysteriously.
|
|
252
|
+
await clearLicenseState();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
process.stderr.write(`\nerror: ${err.message}\n`);
|
|
256
|
+
process.exit(1);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
84
259
|
program.parseAsync(process.argv);
|
package/dist/confirm.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { ParsedBrief } from "./parse-brief.js";
|
|
2
2
|
import type { BrandPreset, CustomBrandInputs, DbStrategy, ProjectType, ScaffoldInputs } from "./index.js";
|
|
3
3
|
export type Prompter = (message: string, defaultValue?: string) => Promise<string>;
|
|
4
|
+
/**
|
|
5
|
+
* Thrown when the user types an exit keyword (`cancel` / `abort` / `quit` /
|
|
6
|
+
* `q`) at the confirmation prompt. Before v0.2.1 the only escape from the
|
|
7
|
+
* confirm loop was Ctrl+C (the 2026-06-03 dogfood finding #3). The CLI catches
|
|
8
|
+
* this and exits cleanly without writing any files.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ConfirmCancelledError extends Error {
|
|
11
|
+
constructor(message?: string);
|
|
12
|
+
}
|
|
13
|
+
/** Exit keywords accepted at the confirmation prompt (case-insensitive). */
|
|
14
|
+
export declare const CONFIRM_CANCEL_KEYWORDS: readonly ["cancel", "abort", "quit", "q"];
|
|
4
15
|
export interface ConfirmOptions {
|
|
5
16
|
prompter: Prompter;
|
|
6
17
|
output?: NodeJS.WritableStream;
|
package/dist/confirm.js
CHANGED
|
@@ -8,8 +8,22 @@
|
|
|
8
8
|
// wires it to @inquirer/prompts' input() in src/cli.ts.
|
|
9
9
|
import * as path from "node:path";
|
|
10
10
|
import { promises as fs } from "node:fs";
|
|
11
|
-
import { githubOrgForBrand, isValidSlug, kebabCase, } from "./parse-brief.js";
|
|
11
|
+
import { expandHome, githubOrgForBrand, isValidSlug, kebabCase, } from "./parse-brief.js";
|
|
12
12
|
import { isHexColor } from "./brand.js";
|
|
13
|
+
/**
|
|
14
|
+
* Thrown when the user types an exit keyword (`cancel` / `abort` / `quit` /
|
|
15
|
+
* `q`) at the confirmation prompt. Before v0.2.1 the only escape from the
|
|
16
|
+
* confirm loop was Ctrl+C (the 2026-06-03 dogfood finding #3). The CLI catches
|
|
17
|
+
* this and exits cleanly without writing any files.
|
|
18
|
+
*/
|
|
19
|
+
export class ConfirmCancelledError extends Error {
|
|
20
|
+
constructor(message = "Cancelled at the confirmation screen.") {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "ConfirmCancelledError";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Exit keywords accepted at the confirmation prompt (case-insensitive). */
|
|
26
|
+
export const CONFIRM_CANCEL_KEYWORDS = ["cancel", "abort", "quit", "q"];
|
|
13
27
|
export const PROJECT_TYPES = [
|
|
14
28
|
"wp-plugin",
|
|
15
29
|
"cf-worker",
|
|
@@ -96,11 +110,11 @@ function parseBoolean(raw, label) {
|
|
|
96
110
|
};
|
|
97
111
|
}
|
|
98
112
|
async function parseTargetPath(raw, skipFsChecks) {
|
|
99
|
-
const trimmed = raw.trim();
|
|
113
|
+
const trimmed = expandHome(raw.trim());
|
|
100
114
|
if (!path.isAbsolute(trimmed)) {
|
|
101
115
|
return {
|
|
102
116
|
ok: false,
|
|
103
|
-
error: `Target path must be absolute (start with /). Got: "${trimmed}".`,
|
|
117
|
+
error: `Target path must be absolute (start with / or ~). Got: "${trimmed}".`,
|
|
104
118
|
};
|
|
105
119
|
}
|
|
106
120
|
if (skipFsChecks)
|
|
@@ -338,9 +352,12 @@ export async function confirmInputs(parsed, opts) {
|
|
|
338
352
|
output.write(`\nInferred inputs from your brief:\n\n${renderDraft(draft)}\n\n`);
|
|
339
353
|
const complete = isComplete(draft);
|
|
340
354
|
const prompt = complete
|
|
341
|
-
? "Press Enter to accept,
|
|
342
|
-
: "Type a line number (1-10) to fill or edit. Every field must be set before accepting.";
|
|
355
|
+
? "Press Enter to accept, a line number (1-10) to edit, or 'cancel' to exit (Ctrl+C also works):"
|
|
356
|
+
: "Type a line number (1-10) to fill or edit, or 'cancel' to exit (Ctrl+C also works). Every field must be set before accepting.";
|
|
343
357
|
const reply = (await opts.prompter(prompt)).trim();
|
|
358
|
+
if (CONFIRM_CANCEL_KEYWORDS.includes(reply.toLowerCase())) {
|
|
359
|
+
throw new ConfirmCancelledError();
|
|
360
|
+
}
|
|
344
361
|
if (reply.length === 0) {
|
|
345
362
|
if (complete)
|
|
346
363
|
break;
|
|
@@ -377,5 +394,10 @@ export async function confirmInputs(parsed, opts) {
|
|
|
377
394
|
if (draft.brand === "custom" && draft.customBrand !== null) {
|
|
378
395
|
result.customBrand = draft.customBrand;
|
|
379
396
|
}
|
|
397
|
+
// Brief planning sections aren't user-editable on the confirm screen; carry
|
|
398
|
+
// them straight through so they flow into ROADMAP.md + README.md downstream.
|
|
399
|
+
if (parsed.briefSections !== undefined) {
|
|
400
|
+
result.briefSections = parsed.briefSections;
|
|
401
|
+
}
|
|
380
402
|
return result;
|
|
381
403
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const version = "0.2.
|
|
1
|
+
export declare const version = "0.2.1";
|
|
2
2
|
export type ProjectType = "wp-plugin" | "cf-worker" | "cf-pages" | "nextjs" | "python-service" | "library" | "protocol-repo";
|
|
3
3
|
export type BrandPreset = "save-the-frogs" | "bansuri-bliss" | "zero2webmaster" | "custom";
|
|
4
4
|
export type DbStrategy = "none" | "neon-postgres" | "supabase" | "sqlite" | "mysql-wp" | "other";
|
|
@@ -14,6 +14,23 @@ export interface CustomBrandInputs {
|
|
|
14
14
|
primaryColor: string;
|
|
15
15
|
accentColor: string;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Free-text sections lifted verbatim from a pasted project brief. Every field
|
|
19
|
+
* is optional — only the sections the brief actually contained are populated.
|
|
20
|
+
* Carried through to the scaffolder so the brief's planning content flows into
|
|
21
|
+
* the generated ROADMAP.md + README.md rather than being discarded after
|
|
22
|
+
* field inference (per [[instantiate-z2w-project]] SKILL Step 1a.4). Absent
|
|
23
|
+
* for the `--wizard` and `--input` paths, which have no brief.
|
|
24
|
+
*/
|
|
25
|
+
export interface BriefSections {
|
|
26
|
+
purpose?: string;
|
|
27
|
+
keyApis?: string;
|
|
28
|
+
dataSources?: string;
|
|
29
|
+
expectedOutputs?: string;
|
|
30
|
+
edgeCases?: string;
|
|
31
|
+
roadmap?: string;
|
|
32
|
+
futureImprovements?: string;
|
|
33
|
+
}
|
|
17
34
|
export interface ScaffoldInputs {
|
|
18
35
|
slug: string;
|
|
19
36
|
description: string;
|
|
@@ -27,5 +44,7 @@ export interface ScaffoldInputs {
|
|
|
27
44
|
participateInBulletin: boolean;
|
|
28
45
|
/** Present only when `brand === "custom"`. */
|
|
29
46
|
customBrand?: CustomBrandInputs;
|
|
47
|
+
/** Present only when scaffolding from a pasted brief that had these sections. */
|
|
48
|
+
briefSections?: BriefSections;
|
|
30
49
|
}
|
|
31
50
|
export declare function scaffold(_inputs: ScaffoldInputs): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// (e.g., the future Tier B SaaS, integration tests, or other Z2W tools) can
|
|
5
5
|
// invoke it without spawning a subprocess.
|
|
6
6
|
//
|
|
7
|
-
export const version = "0.2.
|
|
7
|
+
export const version = "0.2.1";
|
|
8
8
|
export async function scaffold(_inputs) {
|
|
9
9
|
throw new Error("scaffold() is not yet implemented. See ROADMAP.md (Step 3+).");
|
|
10
10
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare const DEFAULT_LICENSE_API_BASE: string;
|
|
2
|
+
export declare const PRODUCT_SLUG = "z2w-starter-kit";
|
|
3
|
+
export declare const DEFAULT_CONFIG_DIR: string;
|
|
4
|
+
export declare const LICENSE_FILE_NAME = "license";
|
|
5
|
+
/** 24h local cache: skip /license/check if last attempt is within this window. */
|
|
6
|
+
export declare const CACHE_TTL_MS: number;
|
|
7
|
+
/** Past this many days of consecutive check failures, the CLI declines paid features. */
|
|
8
|
+
export declare const N_DAY_CEILING = 14;
|
|
9
|
+
/** Past this many days of consecutive check failures, the CLI warns (but still allows). */
|
|
10
|
+
export declare const N_DAY_WARN_THRESHOLD: number;
|
|
11
|
+
export type ServerStatus = "active" | "expired" | "suspended" | "revoked";
|
|
12
|
+
export interface LicenseState {
|
|
13
|
+
version: 1;
|
|
14
|
+
key: string;
|
|
15
|
+
productSlug: string;
|
|
16
|
+
machineId: string;
|
|
17
|
+
lastSuccessfulCheck: string | null;
|
|
18
|
+
lastCheckAttempt: string | null;
|
|
19
|
+
cachedStatus: ServerStatus | null;
|
|
20
|
+
cachedExpiresAt: string | null;
|
|
21
|
+
retryAfter: string | null;
|
|
22
|
+
}
|
|
23
|
+
export type LicenseEvaluationReason = "active" | "expired-snapshot-only" | "suspended-snapshot-only" | "revoked-blocked" | "check-failing-within-grace" | "check-failing-past-warn" | "check-failing-past-ceiling" | "never-checked" | "no-license";
|
|
24
|
+
export interface LicenseEvaluation {
|
|
25
|
+
allowPaidFeatures: boolean;
|
|
26
|
+
allowTemplatesUpdates: boolean;
|
|
27
|
+
reason: LicenseEvaluationReason;
|
|
28
|
+
warning: string | null;
|
|
29
|
+
daysSinceLastCheck: number | null;
|
|
30
|
+
}
|
|
31
|
+
export interface RuntimeOptions {
|
|
32
|
+
/** Override the config directory (tests). Default {@link DEFAULT_CONFIG_DIR}. */
|
|
33
|
+
configDir?: string;
|
|
34
|
+
/** Override the API base URL (tests). Default {@link DEFAULT_LICENSE_API_BASE}. */
|
|
35
|
+
licenseApiBase?: string;
|
|
36
|
+
/** Override the fetch implementation (tests). Default global `fetch`. */
|
|
37
|
+
fetchImpl?: typeof fetch;
|
|
38
|
+
/** Override the clock (tests). Default `() => Date.now()`. */
|
|
39
|
+
now?: () => number;
|
|
40
|
+
/** Override UUID generation (tests). Default `() => crypto.randomUUID()`. */
|
|
41
|
+
uuid?: () => string;
|
|
42
|
+
}
|
|
43
|
+
export declare class LicenseError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Maps stored license state + current time to a paid-feature decision. Pure
|
|
48
|
+
* function — no I/O, no side effects. The runtime check writes new state to
|
|
49
|
+
* disk first and THEN calls this; the unit tests pin every row in the
|
|
50
|
+
* directive §8 failure matrix against this function alone.
|
|
51
|
+
*/
|
|
52
|
+
export declare function evaluateLicense(state: LicenseState | null, now?: number): LicenseEvaluation;
|
|
53
|
+
export declare function loadLicenseState(opts?: RuntimeOptions): Promise<LicenseState | null>;
|
|
54
|
+
export declare function saveLicenseState(state: LicenseState, opts?: RuntimeOptions): Promise<void>;
|
|
55
|
+
export declare function clearLicenseState(opts?: RuntimeOptions): Promise<void>;
|
|
56
|
+
export declare function isValidLicenseKey(key: string): boolean;
|
|
57
|
+
/** Masks a license key for diagnostic display: "Z2W-ABCD-...-WXYZ". */
|
|
58
|
+
export declare function maskKey(key: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Activates a license on this machine. On 2xx, persists state including a
|
|
61
|
+
* fresh `lastSuccessfulCheck`. On error, throws LicenseError without writing.
|
|
62
|
+
*/
|
|
63
|
+
export declare function activateLicense(key: string, opts?: RuntimeOptions): Promise<{
|
|
64
|
+
state: LicenseState;
|
|
65
|
+
status: ServerStatus;
|
|
66
|
+
}>;
|
|
67
|
+
export interface CheckResult {
|
|
68
|
+
state: LicenseState;
|
|
69
|
+
status: ServerStatus | null;
|
|
70
|
+
networkOk: boolean;
|
|
71
|
+
message: string | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Calls /license/check and updates state accordingly. Never throws on network
|
|
75
|
+
* failure / 5xx / 429 — bumps `lastCheckAttempt`, persists `retryAfter` if
|
|
76
|
+
* the server sent one, and returns `networkOk: false`. Throws only when no
|
|
77
|
+
* license is configured (callers should handle that ahead of time).
|
|
78
|
+
*
|
|
79
|
+
* Honors a previously-persisted Retry-After by short-circuiting the network
|
|
80
|
+
* call until the persisted deadline passes.
|
|
81
|
+
*/
|
|
82
|
+
export declare function checkLicense(opts?: RuntimeOptions): Promise<CheckResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Deactivates the local license. Attempts to notify the server (so the
|
|
85
|
+
* activation slot frees up) but clears local state even if the server call
|
|
86
|
+
* fails — the user has decided to deactivate, and a stuck server-side
|
|
87
|
+
* activation isn't a reason to block them.
|
|
88
|
+
*/
|
|
89
|
+
export declare function deactivateLicense(opts?: RuntimeOptions): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* The orchestrator paid-feature gates call. Reads stored state; if cache is
|
|
92
|
+
* stale (>24h since last attempt), phones home; runs the pure evaluator
|
|
93
|
+
* against whatever state ends up persisted. Never throws — returns a
|
|
94
|
+
* well-formed evaluation in every case so call sites can switch on
|
|
95
|
+
* `allowPaidFeatures` cleanly.
|
|
96
|
+
*/
|
|
97
|
+
export declare function runtimeLicenseCheck(opts?: RuntimeOptions): Promise<LicenseEvaluation>;
|