@zero2webmaster/starter-kit 0.31.0 → 0.36.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 +2 -2
- package/dist/audience.js +23 -0
- package/dist/descriptor.d.ts +131 -0
- package/dist/descriptor.js +278 -0
- package/dist/index.d.ts +20 -1
- package/dist/index.js +21 -1
- package/dist/scaffolders/index.js +16 -1
- package/dist/scaffolders/nextjs.d.ts +24 -0
- package/dist/scaffolders/nextjs.js +125 -1
- package/package.json +5 -2
- package/scripts/check-conformance.mjs +332 -0
- package/scripts/check-descriptor.mjs +743 -0
- package/scripts/rollup-integrations.mjs +97 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 0.
|
|
3
|
+
**Version:** 0.36.0 | **Framework:** 2.19.0
|
|
4
4
|
|
|
5
5
|
> Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
|
|
6
6
|
|
|
@@ -135,4 +135,4 @@ Inquiries: kerry@zero2webmaster.com.
|
|
|
135
135
|
---
|
|
136
136
|
|
|
137
137
|
*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.*
|
|
138
|
-
*Version: 0.
|
|
138
|
+
*Version: 0.36.0 | Last Updated: 2026-09-22*
|
package/dist/audience.js
CHANGED
|
@@ -169,6 +169,29 @@ const PRIVATE_RESOURCES = [
|
|
|
169
169
|
{ resource: "Skill Vault", re: /\bSkill Vault\b/ },
|
|
170
170
|
{ resource: "the coordination bulletin repo", re: /zero2webmaster\/z2w-agent-coordination/ },
|
|
171
171
|
{ resource: "the local skills symlink tree", re: /[~.]\/\.(claude|cursor)\/skills/ },
|
|
172
|
+
// 🔴 A NAMED Vault skill, which the three entries above cannot see. Added
|
|
173
|
+
// 2026-09-19 after `cursor-project-templates` asked (via `grantor`'s
|
|
174
|
+
// in-app-user-guide filing) whether the canonical body may carry
|
|
175
|
+
// *"See the `in-app-user-guide` skill."* to external customers.
|
|
176
|
+
//
|
|
177
|
+
// Measured before answering, and the answer was not the obvious one: that
|
|
178
|
+
// sentence names a resource an outside reader cannot open, is phrased as an
|
|
179
|
+
// instruction, and **fired none of the checks above** — it contains neither
|
|
180
|
+
// the words "Skill Vault", nor the bulletin repo, nor a symlink path. So the
|
|
181
|
+
// guard that exists to catch exactly this class was blind to the most natural
|
|
182
|
+
// way of writing it. `stripVaultPointers` does not save it either: it
|
|
183
|
+
// downgrades `[[slug]]` to bare prose, which leaves the instruction intact and
|
|
184
|
+
// merely un-linked.
|
|
185
|
+
//
|
|
186
|
+
// Matches a skill referenced by slug in either notation — `[[slug]]` or
|
|
187
|
+
// `` `slug` `` — immediately followed by the word "skill", which is how every
|
|
188
|
+
// such pointer in this ecosystem is written. Narrow on purpose: it needs BOTH
|
|
189
|
+
// the slug notation AND the following noun, so ordinary prose about "a skill"
|
|
190
|
+
// does not fire it.
|
|
191
|
+
{
|
|
192
|
+
resource: "a private Skill Vault skill, named as an instruction",
|
|
193
|
+
re: /(\[\[[a-z0-9][a-z0-9-]*\]\]|`[a-z0-9][a-z0-9-]*`)\s+skill\b/i,
|
|
194
|
+
},
|
|
172
195
|
];
|
|
173
196
|
/**
|
|
174
197
|
* Verbs that turn a mention into an instruction. Without this the check fires on
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { ProjectType, ScaffoldInputs } from "./index.js";
|
|
2
|
+
import type { ScaffoldFile } from "./scaffolders/common.js";
|
|
3
|
+
/**
|
|
4
|
+
* Schema version of the descriptor document itself. Bump on any BREAKING change
|
|
5
|
+
* to the shape (a removed field, a renamed field, a changed meaning). Adding an
|
|
6
|
+
* optional field is not breaking and does not bump it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DESCRIPTOR_VERSION = 1;
|
|
9
|
+
/** The emitted file's path, relative to the project root. */
|
|
10
|
+
export declare const DESCRIPTOR_PATH = "z2w-project.json";
|
|
11
|
+
/**
|
|
12
|
+
* The CLOSED task vocabulary. See design rule 2 above.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately at the repo root and NOT under a dotfolder: Finder hides
|
|
15
|
+
* dotfolders, and this ecosystem has already lost time to exactly that (Kerry
|
|
16
|
+
* could not open `~/.cache/z2w-coordination`, which is why the bulletin clone
|
|
17
|
+
* grew a visible Desktop symlink). A descriptor a human cannot see is a
|
|
18
|
+
* descriptor a human cannot correct.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TASK_VERBS: readonly ["dev", "build", "test", "typecheck", "lint", "deploy", "migrate", "seed"];
|
|
21
|
+
export type TaskVerb = (typeof TASK_VERBS)[number];
|
|
22
|
+
/**
|
|
23
|
+
* How dangerous running the task is, for an autonomy classifier that must decide
|
|
24
|
+
* whether to run it unattended.
|
|
25
|
+
*
|
|
26
|
+
* - `read-only` — inspects the tree and writes nothing an operator would miss.
|
|
27
|
+
* - `local-write` — writes to the working tree or binds a local port. Reversible
|
|
28
|
+
* with `git checkout` / killing a process.
|
|
29
|
+
* - `remote-write`— reaches a system outside this machine: a production deploy,
|
|
30
|
+
* a live database, a third-party API. NOT reversible by the
|
|
31
|
+
* agent that ran it.
|
|
32
|
+
*
|
|
33
|
+
* 🔴 Classified CONSERVATIVELY, and the asymmetry is deliberate. Understating a
|
|
34
|
+
* class is the error that costs something irreversible; overstating it costs one
|
|
35
|
+
* confirmation prompt. So `test` is `local-write` rather than `read-only` even
|
|
36
|
+
* though most suites touch nothing, and `migrate` is `remote-write` even when it
|
|
37
|
+
* is pointed at a dev branch. [[unknown-means-denied]]
|
|
38
|
+
*/
|
|
39
|
+
export declare const SAFETY_CLASSES: readonly ["read-only", "local-write", "remote-write"];
|
|
40
|
+
export type SafetyClass = (typeof SAFETY_CLASSES)[number];
|
|
41
|
+
/**
|
|
42
|
+
* The safety class of each verb. A property of the VERB, which is the whole
|
|
43
|
+
* reason the vocabulary is closed — an open vocabulary could not have this table.
|
|
44
|
+
*/
|
|
45
|
+
export declare const VERB_SAFETY: Readonly<Record<TaskVerb, SafetyClass>>;
|
|
46
|
+
export interface ProjectTask {
|
|
47
|
+
/** The exact command to run, from the project root. */
|
|
48
|
+
command: string;
|
|
49
|
+
/** How dangerous it is — see {@link SafetyClass}. */
|
|
50
|
+
safety: SafetyClass;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* How the `tasks` map was derived. Present so a consumer can tell "this project
|
|
54
|
+
* genuinely has no runnable tasks" from "nothing looked". See design rule 3.
|
|
55
|
+
*/
|
|
56
|
+
export type TaskSource = "package.json-scripts" | "pyproject" | "static-site" | "none";
|
|
57
|
+
export interface ProjectDescriptor {
|
|
58
|
+
descriptorVersion: number;
|
|
59
|
+
slug: string;
|
|
60
|
+
description: string;
|
|
61
|
+
projectType: ProjectType;
|
|
62
|
+
/**
|
|
63
|
+
* Present and `true` only on a descriptor REVERSE-ENGINEERED from an existing
|
|
64
|
+
* repo by `scripts/check-descriptor.mjs --write`, rather than emitted here at
|
|
65
|
+
* scaffold time from authoritative inputs. Absent on a scaffolded descriptor.
|
|
66
|
+
*
|
|
67
|
+
* It exists because the two are otherwise indistinguishable, and they do not
|
|
68
|
+
* deserve the same confidence: a scaffolded descriptor's `projectType` and
|
|
69
|
+
* `dbStrategy` were STATED by the person creating the project, whereas a
|
|
70
|
+
* backfilled one's were INFERRED from files. A consumer deciding whether to
|
|
71
|
+
* run a `remote-write` task unattended should be able to see the difference.
|
|
72
|
+
*/
|
|
73
|
+
backfilled?: boolean;
|
|
74
|
+
/** Who produced this file, and when. Both are needed to judge staleness. */
|
|
75
|
+
generatedBy: string;
|
|
76
|
+
generatedOn: string;
|
|
77
|
+
stack: {
|
|
78
|
+
runtime: "node" | "python" | "php" | "static" | "none";
|
|
79
|
+
database: string;
|
|
80
|
+
hasWebUi: boolean;
|
|
81
|
+
hasCron: boolean;
|
|
82
|
+
};
|
|
83
|
+
repo: {
|
|
84
|
+
host: "github";
|
|
85
|
+
org: string;
|
|
86
|
+
name: string;
|
|
87
|
+
url: string;
|
|
88
|
+
};
|
|
89
|
+
deploy: {
|
|
90
|
+
/** `null` where the scaffold genuinely does not determine one. */
|
|
91
|
+
target: string | null;
|
|
92
|
+
};
|
|
93
|
+
coordination: {
|
|
94
|
+
participates: boolean;
|
|
95
|
+
/** `null` when this project does not participate in the bulletin. */
|
|
96
|
+
bulletinRepo: string | null;
|
|
97
|
+
bulletinFile: string | null;
|
|
98
|
+
agentIdentifier: string | null;
|
|
99
|
+
};
|
|
100
|
+
taskSource: TaskSource;
|
|
101
|
+
tasks: Partial<Record<TaskVerb, ProjectTask>>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Map the npm scripts a scaffold actually emitted onto the closed vocabulary.
|
|
105
|
+
*
|
|
106
|
+
* The left side of each pair is the VERB; the right side is the list of script
|
|
107
|
+
* names that legitimately implement it, most-preferred first. A verb with no
|
|
108
|
+
* matching script yields NO task — see design rule 3.
|
|
109
|
+
*
|
|
110
|
+
* `db:push` implements `migrate` because it is the command that APPLIES schema
|
|
111
|
+
* to a database. `db:generate` deliberately maps to nothing: it writes migration
|
|
112
|
+
* files locally and is a different act with a different safety class, and a
|
|
113
|
+
* closed vocabulary drops what does not fit rather than bending a verb to cover it.
|
|
114
|
+
*/
|
|
115
|
+
export declare const NPM_SCRIPT_FOR_VERB: Readonly<Record<TaskVerb, readonly string[]>>;
|
|
116
|
+
/**
|
|
117
|
+
* Compose the descriptor for a completed scaffold.
|
|
118
|
+
*
|
|
119
|
+
* `files` must be the FULL emitted file list — the derivation reads it, so
|
|
120
|
+
* calling this before the type-specific files are appended would silently
|
|
121
|
+
* produce an empty `tasks` map.
|
|
122
|
+
*/
|
|
123
|
+
export declare function buildProjectDescriptor(inputs: ScaffoldInputs, files: readonly ScaffoldFile[], opts?: {
|
|
124
|
+
date?: string;
|
|
125
|
+
cliVersion?: string;
|
|
126
|
+
}): ProjectDescriptor;
|
|
127
|
+
/** The descriptor as an emittable {@link ScaffoldFile}. */
|
|
128
|
+
export declare function descriptorFile(inputs: ScaffoldInputs, files: readonly ScaffoldFile[], opts?: {
|
|
129
|
+
date?: string;
|
|
130
|
+
cliVersion?: string;
|
|
131
|
+
}): ScaffoldFile;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
// The machine-readable PROJECT DESCRIPTOR.
|
|
2
|
+
//
|
|
3
|
+
// One file, emitted at scaffold time into every project this CLI creates, so a
|
|
4
|
+
// surface that is NOT Cursor — a launcher, `project-creator`, an agent runner,
|
|
5
|
+
// a dashboard — can answer two questions about a Z2W project without a human
|
|
6
|
+
// reading its README:
|
|
7
|
+
//
|
|
8
|
+
// 1. WHAT IS THIS? slug, type, stack, repo, deploy target, bulletin file.
|
|
9
|
+
// 2. WHAT MAY I DO IN IT, AND HOW DANGEROUS IS IT? a `tasks` map over a
|
|
10
|
+
// CLOSED verb vocabulary, each task carrying a SAFETY CLASS.
|
|
11
|
+
//
|
|
12
|
+
// Scope ruled on the coordination bulletin 2026-09-13 (the three-way IDE split):
|
|
13
|
+
// `z2w-agent-command-center` owns the RANKING — *which* project to work on next.
|
|
14
|
+
// This descriptor answers the other half — *what may be done in that project*.
|
|
15
|
+
// The two are deliberately separate artifacts owned by separate projects.
|
|
16
|
+
//
|
|
17
|
+
// ─────────────────────────── THREE DESIGN RULES ───────────────────────────
|
|
18
|
+
//
|
|
19
|
+
// **1. The safety class lives ON the task, never in a parallel manifest.**
|
|
20
|
+
// A second list drifts from the first, and the drift is silent because both
|
|
21
|
+
// halves stay internally consistent. One task, one command, one class.
|
|
22
|
+
//
|
|
23
|
+
// **2. The vocabulary is CLOSED.** Eight verbs, fixed below. A project that does
|
|
24
|
+
// something outside them does not get a ninth verb invented for it — it gets no
|
|
25
|
+
// task, and the consumer falls back to a human. An open vocabulary would make
|
|
26
|
+
// the safety classification unbounded, which defeats the point: a classifier
|
|
27
|
+
// cannot reason about a verb it has never seen.
|
|
28
|
+
//
|
|
29
|
+
// **3. A task is emitted ONLY when the scaffold actually provides the command.**
|
|
30
|
+
// The tasks are DERIVED from the emitted file list — package.json `scripts` for
|
|
31
|
+
// the Node types, the known entry points for python — never from a per-type
|
|
32
|
+
// table written from memory. A descriptor claiming `npm run lint` for a project
|
|
33
|
+
// with no lint script is worse than a descriptor with no lint task at all: the
|
|
34
|
+
// consumer runs it, gets `npm ERR! Missing script`, and learns to distrust the
|
|
35
|
+
// whole file. This is the same discipline as [[zero-is-not-a-pass]] — "no task"
|
|
36
|
+
// and "not measured" must not be the same value, which is why `tasks` is always
|
|
37
|
+
// present (possibly empty) and `taskSource` always says how it was derived.
|
|
38
|
+
/**
|
|
39
|
+
* Schema version of the descriptor document itself. Bump on any BREAKING change
|
|
40
|
+
* to the shape (a removed field, a renamed field, a changed meaning). Adding an
|
|
41
|
+
* optional field is not breaking and does not bump it.
|
|
42
|
+
*/
|
|
43
|
+
export const DESCRIPTOR_VERSION = 1;
|
|
44
|
+
/** The emitted file's path, relative to the project root. */
|
|
45
|
+
export const DESCRIPTOR_PATH = "z2w-project.json";
|
|
46
|
+
/**
|
|
47
|
+
* The CLOSED task vocabulary. See design rule 2 above.
|
|
48
|
+
*
|
|
49
|
+
* Deliberately at the repo root and NOT under a dotfolder: Finder hides
|
|
50
|
+
* dotfolders, and this ecosystem has already lost time to exactly that (Kerry
|
|
51
|
+
* could not open `~/.cache/z2w-coordination`, which is why the bulletin clone
|
|
52
|
+
* grew a visible Desktop symlink). A descriptor a human cannot see is a
|
|
53
|
+
* descriptor a human cannot correct.
|
|
54
|
+
*/
|
|
55
|
+
export const TASK_VERBS = [
|
|
56
|
+
"dev",
|
|
57
|
+
"build",
|
|
58
|
+
"test",
|
|
59
|
+
"typecheck",
|
|
60
|
+
"lint",
|
|
61
|
+
"deploy",
|
|
62
|
+
"migrate",
|
|
63
|
+
"seed",
|
|
64
|
+
];
|
|
65
|
+
/**
|
|
66
|
+
* How dangerous running the task is, for an autonomy classifier that must decide
|
|
67
|
+
* whether to run it unattended.
|
|
68
|
+
*
|
|
69
|
+
* - `read-only` — inspects the tree and writes nothing an operator would miss.
|
|
70
|
+
* - `local-write` — writes to the working tree or binds a local port. Reversible
|
|
71
|
+
* with `git checkout` / killing a process.
|
|
72
|
+
* - `remote-write`— reaches a system outside this machine: a production deploy,
|
|
73
|
+
* a live database, a third-party API. NOT reversible by the
|
|
74
|
+
* agent that ran it.
|
|
75
|
+
*
|
|
76
|
+
* 🔴 Classified CONSERVATIVELY, and the asymmetry is deliberate. Understating a
|
|
77
|
+
* class is the error that costs something irreversible; overstating it costs one
|
|
78
|
+
* confirmation prompt. So `test` is `local-write` rather than `read-only` even
|
|
79
|
+
* though most suites touch nothing, and `migrate` is `remote-write` even when it
|
|
80
|
+
* is pointed at a dev branch. [[unknown-means-denied]]
|
|
81
|
+
*/
|
|
82
|
+
export const SAFETY_CLASSES = ["read-only", "local-write", "remote-write"];
|
|
83
|
+
/**
|
|
84
|
+
* The safety class of each verb. A property of the VERB, which is the whole
|
|
85
|
+
* reason the vocabulary is closed — an open vocabulary could not have this table.
|
|
86
|
+
*/
|
|
87
|
+
export const VERB_SAFETY = {
|
|
88
|
+
typecheck: "read-only",
|
|
89
|
+
lint: "read-only",
|
|
90
|
+
build: "local-write",
|
|
91
|
+
test: "local-write",
|
|
92
|
+
dev: "local-write",
|
|
93
|
+
deploy: "remote-write",
|
|
94
|
+
migrate: "remote-write",
|
|
95
|
+
seed: "remote-write",
|
|
96
|
+
};
|
|
97
|
+
/** Build a task entry, taking the safety class from the verb table. */
|
|
98
|
+
function task(verb, command) {
|
|
99
|
+
return { command, safety: VERB_SAFETY[verb] };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Map the npm scripts a scaffold actually emitted onto the closed vocabulary.
|
|
103
|
+
*
|
|
104
|
+
* The left side of each pair is the VERB; the right side is the list of script
|
|
105
|
+
* names that legitimately implement it, most-preferred first. A verb with no
|
|
106
|
+
* matching script yields NO task — see design rule 3.
|
|
107
|
+
*
|
|
108
|
+
* `db:push` implements `migrate` because it is the command that APPLIES schema
|
|
109
|
+
* to a database. `db:generate` deliberately maps to nothing: it writes migration
|
|
110
|
+
* files locally and is a different act with a different safety class, and a
|
|
111
|
+
* closed vocabulary drops what does not fit rather than bending a verb to cover it.
|
|
112
|
+
*/
|
|
113
|
+
export const NPM_SCRIPT_FOR_VERB = {
|
|
114
|
+
dev: ["dev"],
|
|
115
|
+
build: ["build"],
|
|
116
|
+
test: ["test"],
|
|
117
|
+
typecheck: ["typecheck"],
|
|
118
|
+
lint: ["lint"],
|
|
119
|
+
deploy: ["deploy"],
|
|
120
|
+
migrate: ["db:push", "migrate", "db:migrate"],
|
|
121
|
+
seed: ["db:seed", "seed"],
|
|
122
|
+
};
|
|
123
|
+
function tasksFromPackageJson(content) {
|
|
124
|
+
let scripts = {};
|
|
125
|
+
try {
|
|
126
|
+
const parsed = JSON.parse(content);
|
|
127
|
+
scripts = parsed.scripts ?? {};
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// An unparseable package.json is a real possibility (a template escaping
|
|
131
|
+
// slip has shipped from this repo before — see CLAUDE.md § "a green test
|
|
132
|
+
// suite is NOT evidence that a scaffold is correct"). Report "none" rather
|
|
133
|
+
// than guessing, so the descriptor never claims a task it could not read.
|
|
134
|
+
return { source: "none", tasks: {} };
|
|
135
|
+
}
|
|
136
|
+
const tasks = {};
|
|
137
|
+
for (const verb of TASK_VERBS) {
|
|
138
|
+
const candidates = NPM_SCRIPT_FOR_VERB[verb];
|
|
139
|
+
const hit = candidates.find((name) => typeof scripts[name] === "string");
|
|
140
|
+
if (hit === undefined)
|
|
141
|
+
continue;
|
|
142
|
+
// `npm test` is the built-in alias; everything else needs `run`.
|
|
143
|
+
tasks[verb] = task(verb, hit === "test" ? "npm test" : `npm run ${hit}`);
|
|
144
|
+
}
|
|
145
|
+
return { source: "package.json-scripts", tasks };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Python has no scripts table, so the commands come from what the scaffolder
|
|
149
|
+
* demonstrably emits: a FastAPI app under `src/<slug_under>/main.py` (run with
|
|
150
|
+
* uvicorn, exactly as the emitted README documents it) and pytest as a declared
|
|
151
|
+
* dev dependency with a real `tests/` tree.
|
|
152
|
+
*
|
|
153
|
+
* Both are checked against the file list rather than assumed — if the python
|
|
154
|
+
* scaffolder stops emitting `main.py`, the `dev` task disappears instead of
|
|
155
|
+
* becoming a lie.
|
|
156
|
+
*/
|
|
157
|
+
function tasksFromPyproject(inputs, paths) {
|
|
158
|
+
const tasks = {};
|
|
159
|
+
const pkg = inputs.slug.replace(/-/g, "_");
|
|
160
|
+
if (paths.has(`src/${pkg}/main.py`)) {
|
|
161
|
+
tasks.dev = task("dev", `uvicorn ${pkg}.main:app --reload`);
|
|
162
|
+
}
|
|
163
|
+
if ([...paths].some((p) => p.startsWith("tests/"))) {
|
|
164
|
+
tasks.test = task("test", "pytest");
|
|
165
|
+
}
|
|
166
|
+
return { source: "pyproject", tasks };
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A static Cloudflare Pages site has no package.json at all. Its two real
|
|
170
|
+
* commands are the wrangler invocations the emitted README documents.
|
|
171
|
+
*/
|
|
172
|
+
function tasksForStaticSite() {
|
|
173
|
+
return {
|
|
174
|
+
source: "static-site",
|
|
175
|
+
tasks: {
|
|
176
|
+
dev: task("dev", "npx wrangler pages dev ."),
|
|
177
|
+
deploy: task("deploy", "npx wrangler pages deploy ."),
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Derive the deploy target from the files the scaffold actually emitted, not
|
|
183
|
+
* from a per-type table. `null` means "this scaffold does not determine one" —
|
|
184
|
+
* which is the honest answer for a WordPress plugin (the target is whatever site
|
|
185
|
+
* installs it) and a protocol repo (nothing deploys).
|
|
186
|
+
*/
|
|
187
|
+
function deployTarget(projectType, paths) {
|
|
188
|
+
if (paths.has("wrangler.jsonc") || paths.has("wrangler.toml")) {
|
|
189
|
+
return "cloudflare-workers";
|
|
190
|
+
}
|
|
191
|
+
if (projectType === "cf-pages")
|
|
192
|
+
return "cloudflare-pages";
|
|
193
|
+
if (projectType === "nextjs")
|
|
194
|
+
return "vercel";
|
|
195
|
+
if (paths.has("Dockerfile"))
|
|
196
|
+
return "container";
|
|
197
|
+
if (projectType === "library")
|
|
198
|
+
return "npm";
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
function runtimeFor(projectType) {
|
|
202
|
+
switch (projectType) {
|
|
203
|
+
case "python-service":
|
|
204
|
+
return "python";
|
|
205
|
+
case "wp-plugin":
|
|
206
|
+
return "php";
|
|
207
|
+
case "cf-pages":
|
|
208
|
+
return "static";
|
|
209
|
+
case "protocol-repo":
|
|
210
|
+
return "none";
|
|
211
|
+
default:
|
|
212
|
+
return "node";
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Compose the descriptor for a completed scaffold.
|
|
217
|
+
*
|
|
218
|
+
* `files` must be the FULL emitted file list — the derivation reads it, so
|
|
219
|
+
* calling this before the type-specific files are appended would silently
|
|
220
|
+
* produce an empty `tasks` map.
|
|
221
|
+
*/
|
|
222
|
+
export function buildProjectDescriptor(inputs, files, opts) {
|
|
223
|
+
const paths = new Set(files.map((f) => f.path));
|
|
224
|
+
const pkg = files.find((f) => f.path === "package.json");
|
|
225
|
+
let derived;
|
|
226
|
+
if (pkg) {
|
|
227
|
+
derived = tasksFromPackageJson(pkg.content);
|
|
228
|
+
}
|
|
229
|
+
else if (paths.has("pyproject.toml")) {
|
|
230
|
+
derived = tasksFromPyproject(inputs, paths);
|
|
231
|
+
}
|
|
232
|
+
else if (inputs.projectType === "cf-pages") {
|
|
233
|
+
derived = tasksForStaticSite();
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
// wp-plugin and protocol-repo genuinely have no runnable commands. `none`
|
|
237
|
+
// is a measured answer, not a failure to look.
|
|
238
|
+
derived = { source: "none", tasks: {} };
|
|
239
|
+
}
|
|
240
|
+
const participates = inputs.participateInBulletin;
|
|
241
|
+
return {
|
|
242
|
+
descriptorVersion: DESCRIPTOR_VERSION,
|
|
243
|
+
slug: inputs.slug,
|
|
244
|
+
description: inputs.description,
|
|
245
|
+
projectType: inputs.projectType,
|
|
246
|
+
generatedBy: `@zero2webmaster/starter-kit@${opts?.cliVersion ?? "unknown"}`,
|
|
247
|
+
generatedOn: opts?.date ?? new Date().toISOString().slice(0, 10),
|
|
248
|
+
stack: {
|
|
249
|
+
runtime: runtimeFor(inputs.projectType),
|
|
250
|
+
database: inputs.dbStrategy,
|
|
251
|
+
hasWebUi: inputs.hasWebUi,
|
|
252
|
+
hasCron: inputs.hasCron,
|
|
253
|
+
},
|
|
254
|
+
repo: {
|
|
255
|
+
host: "github",
|
|
256
|
+
org: inputs.githubOrg,
|
|
257
|
+
name: inputs.slug,
|
|
258
|
+
url: `https://github.com/${inputs.githubOrg}/${inputs.slug}`,
|
|
259
|
+
},
|
|
260
|
+
deploy: { target: deployTarget(inputs.projectType, paths) },
|
|
261
|
+
coordination: {
|
|
262
|
+
participates,
|
|
263
|
+
bulletinRepo: participates ? "zero2webmaster/z2w-agent-coordination" : null,
|
|
264
|
+
bulletinFile: participates ? `projects/${inputs.slug}.md` : null,
|
|
265
|
+
agentIdentifier: participates ? inputs.slug : null,
|
|
266
|
+
},
|
|
267
|
+
taskSource: derived.source,
|
|
268
|
+
tasks: derived.tasks,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/** The descriptor as an emittable {@link ScaffoldFile}. */
|
|
272
|
+
export function descriptorFile(inputs, files, opts) {
|
|
273
|
+
const descriptor = buildProjectDescriptor(inputs, files, opts);
|
|
274
|
+
return {
|
|
275
|
+
path: DESCRIPTOR_PATH,
|
|
276
|
+
content: `${JSON.stringify(descriptor, null, 2)}\n`,
|
|
277
|
+
};
|
|
278
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,26 @@ import { writeScaffold } from "./writer.js";
|
|
|
2
2
|
import type { AudienceGateReport } from "./writer.js";
|
|
3
3
|
import type { ScaffoldFile } from "./scaffolders/common.js";
|
|
4
4
|
import type { StandardDecision } from "./standards.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* This package's version, READ FROM `package.json` at load time rather than
|
|
7
|
+
* written here by hand.
|
|
8
|
+
*
|
|
9
|
+
* 🔴 It was a hand-maintained literal until 2026-09-19, and it had drifted to
|
|
10
|
+
* `0.6.0` while the package was `0.31.0` — twenty-five minor versions, and it
|
|
11
|
+
* was PUBLISHED that way, so `npx @zero2webmaster/starter-kit --version`
|
|
12
|
+
* answered `0.6.0` for months. Nothing could have caught it: the constant was
|
|
13
|
+
* internally consistent, every test that used it asserted against itself, and
|
|
14
|
+
* the version-bump checklist in CLAUDE.md greps for the OLD version string —
|
|
15
|
+
* which by then appeared nowhere near this line.
|
|
16
|
+
*
|
|
17
|
+
* Deriving it removes the class rather than the instance. `../package.json`
|
|
18
|
+
* resolves correctly from both `src/` (vitest) and `dist/` (the built CLI and
|
|
19
|
+
* the published tarball, where the layout is `package/dist/` + `package/package.json`).
|
|
20
|
+
* `src/index.test.ts` additionally asserts the two agree, so a packaging change
|
|
21
|
+
* that broke the path would fail loudly instead of silently reintroducing a
|
|
22
|
+
* stale literal.
|
|
23
|
+
*/
|
|
24
|
+
export declare const version: string;
|
|
6
25
|
export type ProjectType = "wp-plugin" | "cf-worker" | "cf-pages" | "nextjs" | "python-service" | "node-service" | "library" | "protocol-repo";
|
|
7
26
|
export type BrandPreset = "save-the-frogs" | "bansuri-bliss" | "zero2webmaster" | "custom";
|
|
8
27
|
/**
|
package/dist/index.js
CHANGED
|
@@ -17,11 +17,31 @@
|
|
|
17
17
|
// `resolveStandards`, `scaffoldByType`, `parseScaffoldInputs`, …) so consumers
|
|
18
18
|
// import from the package root instead of deep-importing dist internals.
|
|
19
19
|
//
|
|
20
|
+
import { createRequire } from "node:module";
|
|
20
21
|
import * as path from "node:path";
|
|
21
22
|
import { Writable } from "node:stream";
|
|
22
23
|
import { isValidSlug } from "./parse-brief.js";
|
|
23
24
|
import { writeScaffold } from "./writer.js";
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* This package's version, READ FROM `package.json` at load time rather than
|
|
27
|
+
* written here by hand.
|
|
28
|
+
*
|
|
29
|
+
* 🔴 It was a hand-maintained literal until 2026-09-19, and it had drifted to
|
|
30
|
+
* `0.6.0` while the package was `0.31.0` — twenty-five minor versions, and it
|
|
31
|
+
* was PUBLISHED that way, so `npx @zero2webmaster/starter-kit --version`
|
|
32
|
+
* answered `0.6.0` for months. Nothing could have caught it: the constant was
|
|
33
|
+
* internally consistent, every test that used it asserted against itself, and
|
|
34
|
+
* the version-bump checklist in CLAUDE.md greps for the OLD version string —
|
|
35
|
+
* which by then appeared nowhere near this line.
|
|
36
|
+
*
|
|
37
|
+
* Deriving it removes the class rather than the instance. `../package.json`
|
|
38
|
+
* resolves correctly from both `src/` (vitest) and `dist/` (the built CLI and
|
|
39
|
+
* the published tarball, where the layout is `package/dist/` + `package/package.json`).
|
|
40
|
+
* `src/index.test.ts` additionally asserts the two agree, so a packaging change
|
|
41
|
+
* that broke the path would fail loudly instead of silently reintroducing a
|
|
42
|
+
* stale literal.
|
|
43
|
+
*/
|
|
44
|
+
export const version = createRequire(import.meta.url)("../package.json").version;
|
|
25
45
|
// Canonical enum value-arrays. These live here, next to the type unions they
|
|
26
46
|
// enumerate, so both the CLI's confirm/wizard flows (which re-export them) and
|
|
27
47
|
// the programmatic `validateScaffoldInputs` share one source of truth. Keep
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// Used by the writer (ROADMAP Step 6) which performs the actual filesystem
|
|
6
6
|
// writes; pure-functional today so Step 4 tests can snapshot output without
|
|
7
7
|
// any FS dependency.
|
|
8
|
+
import { version as cliVersion } from "../index.js";
|
|
9
|
+
import { descriptorFile } from "../descriptor.js";
|
|
8
10
|
import { scaffoldCfPages } from "./cf-pages.js";
|
|
9
11
|
import { scaffoldCfWorker } from "./cf-worker.js";
|
|
10
12
|
import { scaffoldLibrary } from "./library.js";
|
|
@@ -38,5 +40,18 @@ export function scaffoldByType(inputs, opts) {
|
|
|
38
40
|
"wp-plugin": scaffoldWpPlugin,
|
|
39
41
|
"protocol-repo": scaffoldProtocolRepo,
|
|
40
42
|
};
|
|
41
|
-
|
|
43
|
+
const files = dispatch[inputs.projectType](inputs, opts);
|
|
44
|
+
// The machine-readable project descriptor, appended HERE rather than inside
|
|
45
|
+
// each per-type scaffolder, for two reasons that are both load-bearing:
|
|
46
|
+
//
|
|
47
|
+
// 1. ENROLMENT. Every type reaches this function, so a new project type
|
|
48
|
+
// cannot ship without a descriptor by forgetting to opt in. Emitting it
|
|
49
|
+
// per-type would repeat the capture-learnings enrolment bug — where the
|
|
50
|
+
// step was correct but 25 of 41 projects never got it.
|
|
51
|
+
// 2. DERIVATION. `descriptorFile` reads the COMPLETED file list to work out
|
|
52
|
+
// which tasks the project really provides. Inside a scaffolder the
|
|
53
|
+
// type-specific files (package.json above all) do not exist yet, so the
|
|
54
|
+
// derivation would silently see nothing and emit an empty `tasks` map.
|
|
55
|
+
files.push(descriptorFile(inputs, files, { date: opts?.date, cliVersion }));
|
|
56
|
+
return files;
|
|
42
57
|
}
|
|
@@ -13,6 +13,30 @@ export declare function withPwaWiring(layout: string): string;
|
|
|
13
13
|
* restating four paths per assertion — same job as NEXTJS_SEO_BASELINE_PATHS.
|
|
14
14
|
*/
|
|
15
15
|
export declare const NEXTJS_PWA_PATHS: readonly ["public/manifest.json", "public/icon.svg", "public/sw.js", "components/ServiceWorker.tsx"];
|
|
16
|
+
/**
|
|
17
|
+
* Vercel's Ignored Build Step, committed in-repo so it is reviewable and
|
|
18
|
+
* survives a re-import (a dashboard setting is neither). Filed by
|
|
19
|
+
* `audit-engine` 2026-09-22: across 19 Z2W Vercel projects, 35.6% of commits to
|
|
20
|
+
* `main` changed no application code, and build CPU was 71% of the bill.
|
|
21
|
+
*
|
|
22
|
+
* 🔴 Vercel's exit codes are INVERTED — `0` SKIPS the build, anything else
|
|
23
|
+
* builds. Every branch below that is not "provably prose-only" exits 1, so a
|
|
24
|
+
* wrong rule costs a build and never a deploy:
|
|
25
|
+
*
|
|
26
|
+
* - The base is `VERCEL_GIT_PREVIOUS_SHA`, the last SUCCESSFUL deploy — never
|
|
27
|
+
* `HEAD^`, which sees only the last commit of a push. A code commit followed
|
|
28
|
+
* by a docs commit, pushed together (every Z2W session end), would otherwise
|
|
29
|
+
* skip the code. A canceled deploy is not "successful", so skipped pushes
|
|
30
|
+
* accumulate against the same base until one real change builds them all.
|
|
31
|
+
* - An EMPTY base BUILDS. `audit-engine`'s dashboard rule falls back to
|
|
32
|
+
* `HEAD^` there, which is fine for a long-deployed `main` but wrong for a new
|
|
33
|
+
* scaffold: a repo with history is linked to Vercel later, and its first
|
|
34
|
+
* deploy must not be skipped because the newest commit was a STATUS.md edit.
|
|
35
|
+
* - A base missing from Vercel's shallow clone fails `cat-file` → builds.
|
|
36
|
+
*
|
|
37
|
+
* Must stay ≤ 256 characters (the vercel.json schema's `maxLength`).
|
|
38
|
+
*/
|
|
39
|
+
export declare const VERCEL_IGNORE_COMMAND: string;
|
|
16
40
|
export declare function scaffoldNextjs(inputs: ScaffoldInputs, opts?: ScaffolderOptions): ScaffoldFile[];
|
|
17
41
|
/**
|
|
18
42
|
* Exported for tests + the eventual standards-conflict resolver in Step 5 so
|