@zero2webmaster/starter-kit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +14 -15
  2. package/dist/airtable.d.ts +119 -0
  3. package/dist/airtable.js +273 -0
  4. package/dist/brief.d.ts +2 -2
  5. package/dist/brief.js +11 -4
  6. package/dist/cli.js +290 -17
  7. package/dist/confirm.d.ts +16 -4
  8. package/dist/confirm.js +66 -32
  9. package/dist/index.d.ts +195 -3
  10. package/dist/index.js +155 -6
  11. package/dist/inventory.d.ts +137 -0
  12. package/dist/inventory.js +258 -0
  13. package/dist/license.d.ts +97 -0
  14. package/dist/license.js +474 -0
  15. package/dist/parse-brief.d.ts +45 -1
  16. package/dist/parse-brief.js +349 -21
  17. package/dist/scaffolders/common.d.ts +42 -1
  18. package/dist/scaffolders/common.js +753 -30
  19. package/dist/scaffolders/index.d.ts +1 -0
  20. package/dist/scaffolders/index.js +3 -0
  21. package/dist/scaffolders/library.js +26 -2
  22. package/dist/scaffolders/nextjs.d.ts +1 -1
  23. package/dist/scaffolders/nextjs.js +254 -24
  24. package/dist/scaffolders/node-service.d.ts +3 -0
  25. package/dist/scaffolders/node-service.js +320 -0
  26. package/dist/scaffolders/pro-seo-extension.d.ts +11 -0
  27. package/dist/scaffolders/pro-seo-extension.js +782 -0
  28. package/dist/scaffolders/python-service.js +10 -2
  29. package/dist/scaffolders/wp-plugin.js +8 -8
  30. package/dist/standards.d.ts +1 -1
  31. package/dist/standards.js +164 -5
  32. package/dist/substitute.d.ts +22 -3
  33. package/dist/substitute.js +19 -5
  34. package/dist/summary.d.ts +9 -0
  35. package/dist/summary.js +31 -13
  36. package/dist/templates.d.ts +43 -57
  37. package/dist/templates.js +108 -175
  38. package/dist/with-init.d.ts +32 -0
  39. package/dist/with-init.js +171 -0
  40. package/dist/wizard.js +21 -0
  41. package/dist/writer.d.ts +13 -6
  42. package/dist/writer.js +119 -21
  43. package/package.json +2 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # z2w-starter-kit
2
2
 
3
- **Version:** 0.2.0 | **Framework:** 2.13.0
3
+ **Version:** 0.3.0 | **Framework:** 2.13.0
4
4
 
5
5
  > Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
6
6
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## Overview
12
12
 
13
- `z2w-starter-kit` is a command-line scaffolder for [Zero2Webmaster](https://zero2webmaster.com) projects. It reads canonical content from the master Templates folder (`AGENTS_WP_v3.1.0.md`, `AGENTS_v2.13.0.md`, `Resources/*`), parses a pasted project brief OR walks an 8-question fallback wizard, applies brand presets, layers the current Z2W standards block (portable-stack, Fathom analytics, Uptime Kuma, Neon-careful, Agent Coordination, SEO baseline, email-service, text-size), substitutes placeholders, and writes a complete project skeleton atomically into the target path.
13
+ `z2w-starter-kit` is a command-line scaffolder for [Zero2Webmaster](https://zero2webmaster.com) projects. It reads canonical content from the master Templates folder — the AGENTS body is discovered by glob (`AGENTS_v*.md` for general projects, `AGENTS_WP_v*.md` for WordPress) plus the matching `SETUP_GUIDE_*` and `Resources/*`, so an upstream framework-version bump flows through with no code change. It parses a pasted project brief OR walks an 8-question fallback wizard, applies brand presets, layers the current Z2W standards block (portable-stack, Fathom analytics, Uptime Kuma, Neon-careful, Agent Coordination, SEO baseline, email-service, moderation, text-size), substitutes placeholders, and writes a complete project skeleton atomically into the target path.
14
14
 
15
15
  It is the Node/npm sibling of the `instantiate-z2w-project` Claude Code skill — the same orchestration logic, packaged so any developer can run it without Claude Code installed. When standards drift, both must be updated together.
16
16
 
@@ -50,8 +50,7 @@ Brand presets: `save-the-frogs`, `bansuri-bliss`, `zero2webmaster`, `custom`.
50
50
  | `--input <source>` | Non-interactive mode. `--input <path>` reads `ScaffoldInputs` JSON from a file; `--input -` reads from stdin. Bypasses brief / confirm / wizard entirely. For CI use |
51
51
  | `--dry-run` | Print the file list + contents that would be written, without touching disk |
52
52
  | `--target-path <path>` | Override the target path from inputs |
53
- | `--templates-path <path>` | Point at a Templates folder other than `~/Desktop/Zero2Webmaster/AI/Templates/`. Strict — when set, the hosted-mirror fallback is bypassed |
54
- | `--refresh-templates` | Force-bypass the local `~/.cache/z2w-templates/` cache and re-fetch from the hosted mirror at `https://templates.z2w.us`. Use after a Templates upstream change |
53
+ | `--templates-path <path>` | Point at a Templates folder other than `~/Desktop/Zero2Webmaster/AI/Templates/`. Strict — only that exact folder is consulted |
55
54
  | `--promote-standards` | Run the interactive (a) inline / (b) promote-into-Templates dialog per applicable standard. Promoted standards are captured in `STANDARDS_PROMOTIONS.md` alongside the scaffold (the Templates-folder write itself is a v0.3.x concern) |
56
55
  | `--allow-non-empty` | Write into a non-empty target directory. Off by default — the CLI refuses to scaffold over existing content unless explicitly opted in |
57
56
  | `--no-color` | Suppress ANSI color in the final summary output. Honored regardless of terminal capability, per POSIX `NO_COLOR` convention |
@@ -68,16 +67,15 @@ For non-WP web apps (`nextjs`, `cf-pages` with `hasWebUi`), the CLI emits the fu
68
67
 
69
68
  ## Templates resolution
70
69
 
71
- The CLI resolves canonical template content (AGENTS bodies + Resources/) through a five-step fallback chain. The first source that has the file wins:
70
+ The CLI resolves canonical template content (AGENTS bodies + Resources/) from the **local Templates folder only**:
72
71
 
73
- 1. **`--templates-path <path>`** if set — strict use of that exact location; no fallback.
74
- 2. **Local Templates folder** at `~/Desktop/Zero2Webmaster/AI/Templates/` if present.
75
- 3. **Fresh local cache** at `~/.cache/z2w-templates/` (mtime < 24h).
76
- 4. **Hosted mirror** at `https://templates.z2w.us` — fetched, cached, returned.
77
- 5. **Stale local cache** with a warning (when the mirror is unreachable but a cached copy exists).
78
- 6. Hard fail with a clear `--templates-path <path>` hint.
72
+ 1. **`--templates-path <path>`** if set — strict use of that exact location.
73
+ 2. **Local Templates folder** at `~/Desktop/Zero2Webmaster/AI/Templates/`.
74
+ 3. Otherwise, hard fail with a clear `--templates-path <path>` hint.
79
75
 
80
- Pass `--refresh-templates` to force a fresh fetch from the mirror, skipping step 3. This is the right call after an upstream Templates change you want to pull immediately.
76
+ The CLI reads the folder fresh on every run (nothing is cached or embedded), so an upstream Templates edit is picked up the next time you run `init`.
77
+
78
+ > **Note:** the v0.2.0 hosted-mirror fallback (`templates.z2w.us` + a 24h local cache) was **retired 2026-06-23** to protect the framework IP — the public mirror was taken down. The CLI is therefore back to requiring a local Templates folder (or `--templates-path`), the same as v0.1.x. A license-gated content channel may return as part of the Layer 2 (paid MCP skill server) track.
81
79
 
82
80
  ## Relationship to the Claude Code skill
83
81
 
@@ -85,8 +83,9 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
85
83
 
86
84
  ## Status
87
85
 
88
- - **v0.2.0** ships as a fully-free CLI that works on **any machine** — the hosted Templates mirror at [`templates.z2w.us`](https://templates.z2w.us) (FREE infrastructure) makes the CLI usable without a local Templates folder. Tarball is now 45 files / 64 kB packed (down from 87 / 82 kB in v0.1.1).
89
- - 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.
86
+ - **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.
87
+ - **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.
88
+ - Automatic GitHub repo creation is a **free default** (in the v0.3.x line, working tree): after a scaffold the CLI runs `git init` + first commit + `gh repo create --private` + push, with `--no-repo` to opt out (skipped for `--dry-run` and the `--input` CI path; warn-and-proceed if `gh` is unavailable). The runtime license-validation Worker and the remaining paid feature (`--with-pro-seo` baseline) per the project brief are part of that same **v0.3.x** track, gated on a marketing/distribution plan session; the deeper paid value lives in the Layer 2 MCP skill server.
90
89
 
91
90
  ## License
92
91
 
@@ -100,4 +99,4 @@ For licensing inquiries: kerry@zero2webmaster.com.
100
99
  ---
101
100
 
102
101
  *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.0 | Last Updated: 2026-06-01*
102
+ *Version: 0.3.0 | Last Updated: 2026-07-13*
@@ -0,0 +1,119 @@
1
+ import { type ScaffoldInputs } from "./index.js";
2
+ /** Airtable REST API root. */
3
+ export declare const AIRTABLE_API_BASE = "https://api.airtable.com/v0";
4
+ /**
5
+ * The marker the scaffolder actually writes when the agent-coordination
6
+ * standard applies — the heading of `AGENT_COORDINATION_BODY` (src/standards.ts),
7
+ * with the body's lead sentence as a fallback. We grep-verify against THIS,
8
+ * not the literal `canonical-block` token: the scaffolded files do NOT carry
9
+ * the `<!-- z2w-agent-coordination canonical-block vX.Y.Z -->` HTML fingerprint
10
+ * comment — that fingerprint lives only in this CLI's own CLAUDE.md for
11
+ * cross-project drift detection. Verify against what the scaffolder emits.
12
+ */
13
+ export declare const COORDINATION_BLOCK_MARKER: RegExp;
14
+ /**
15
+ * "Verify, don't assert" (mirrors [[github-readme-and-version-integrity]]).
16
+ * Read the freshly-written scaffold and report whether it actually carries the
17
+ * agent-coordination block, so the Airtable write only claims
18
+ * `Agent Coordination = Registered` when the block is really present.
19
+ *
20
+ * The standards block (including the coordination body) is inserted into
21
+ * CLAUDE.md; AGENTS.md is checked as a fallback (it mirrors CLAUDE.md). Safe
22
+ * failure mode: a missing/unreadable scaffold returns `false`, which leaves the
23
+ * column blank for Kerry rather than asserting a state we couldn't confirm.
24
+ */
25
+ export declare function scaffoldCarriesCoordinationBlock(targetPath: string, opts?: {
26
+ readFileImpl?: (path: string) => Promise<string>;
27
+ }): Promise<boolean>;
28
+ /** "Cursor Projects" base. Override with AIRTABLE_INVENTORY_BASE_ID. */
29
+ export declare const DEFAULT_INVENTORY_BASE_ID = "appomsRpbA3oOlcaW";
30
+ /**
31
+ * "Projects" table — the table ID (not the display name) so the code survives
32
+ * a table rename. Override with AIRTABLE_INVENTORY_TABLE.
33
+ */
34
+ export declare const DEFAULT_INVENTORY_TABLE = "tblRoXwwu8wzvfqVY";
35
+ export interface AirtableConfig {
36
+ pat: string;
37
+ baseId: string;
38
+ table: string;
39
+ }
40
+ /**
41
+ * Resolve Airtable config from the environment. Returns null when no
42
+ * AIRTABLE_WRITE_PAT is set — the signal that auto-registration is disabled
43
+ * for this caller (every CLI user who isn't Kerry). The base/table fall back
44
+ * to the live "Cursor Projects" defaults when not overridden.
45
+ */
46
+ export declare function resolveAirtableConfig(env?: NodeJS.ProcessEnv): AirtableConfig | null;
47
+ /**
48
+ * Derive a human-friendly project display name from a slug.
49
+ * `z2w-crowdcommerce` → "Z2W Crowdcommerce". Best-effort — Kerry can refine
50
+ * the row's `Project` field by hand afterward.
51
+ */
52
+ export declare function displayNameFromSlug(slug: string): string;
53
+ export type AirtableFields = Record<string, string>;
54
+ export interface BuildProjectFieldsOptions {
55
+ /**
56
+ * Whether the freshly-written scaffold was confirmed to carry the
57
+ * coordination block (see `scaffoldCarriesCoordinationBlock`). When this is a
58
+ * boolean, it gates the `Agent Coordination = Registered` assertion — "verify,
59
+ * don't assert". When `undefined` (the caller couldn't verify — e.g. a
60
+ * dry-run with nothing on disk, or a direct unit-test call), we fall back to
61
+ * the `participateInBulletin` input flag alone.
62
+ */
63
+ coordinationVerified?: boolean;
64
+ }
65
+ /**
66
+ * Pure mapping from ScaffoldInputs to the Airtable "Projects" row fields.
67
+ * Column names confirmed by Kerry 2026-06-03 / 2026-06-16. Columns left empty
68
+ * for Kerry (WordPress Agents File, Framework Version, Plan, Project Type, …)
69
+ * are intentionally omitted.
70
+ */
71
+ export declare function buildProjectFields(inputs: ScaffoldInputs, opts?: BuildProjectFieldsOptions): AirtableFields;
72
+ export type RegisterOutcome = "created" | "dry-run" | "skipped" | "failed";
73
+ export interface RegisterResult {
74
+ outcome: RegisterOutcome;
75
+ /** The fields that were (or would be) written. */
76
+ fields: AirtableFields;
77
+ /** Created Airtable record id, when outcome === "created". */
78
+ recordId?: string;
79
+ /** The POST target URL (never contains the token). */
80
+ url?: string;
81
+ /** Human-readable, secret-free line for the CLI to surface. */
82
+ message: string;
83
+ /**
84
+ * Result of the on-disk coordination-block check, when it ran (i.e. a
85
+ * participating scaffold with a `targetPath`, not a dry-run). `undefined`
86
+ * when verification was not attempted.
87
+ */
88
+ coordinationVerified?: boolean;
89
+ }
90
+ export interface RegisterOptions {
91
+ env?: NodeJS.ProcessEnv;
92
+ /** Test/override seam for the HTTP client. Defaults to global fetch. */
93
+ fetchImpl?: typeof fetch;
94
+ /** Build the request but do not POST — for `init --dry-run`. */
95
+ dryRun?: boolean;
96
+ /**
97
+ * Override config explicitly (tests). When provided (including `null`),
98
+ * bypasses env resolution. `null` forces the "skipped" path.
99
+ */
100
+ config?: AirtableConfig | null;
101
+ /**
102
+ * Absolute path to the freshly-written scaffold. When provided (and not a
103
+ * dry-run) for a participating project, the coordination block is
104
+ * grep-verified on disk before `Agent Coordination = Registered` is asserted.
105
+ */
106
+ targetPath?: string;
107
+ /** Test seam for the filesystem read used by coordination verification. */
108
+ readFileImpl?: (path: string) => Promise<string>;
109
+ }
110
+ /**
111
+ * Create the inventory row for a freshly-scaffolded project. Warn-and-proceed:
112
+ * always resolves (never rejects); the CLI surfaces `message` and continues.
113
+ *
114
+ * - No AIRTABLE_WRITE_PAT → outcome "skipped" (silent for normal users).
115
+ * - opts.dryRun → outcome "dry-run" (prints the would-be request).
116
+ * - 2xx → outcome "created" (+ recordId).
117
+ * - non-2xx / network err → outcome "failed" (+ a diagnostic; row NOT created).
118
+ */
119
+ export declare function registerProjectRow(inputs: ScaffoldInputs, opts?: RegisterOptions): Promise<RegisterResult>;
@@ -0,0 +1,273 @@
1
+ // z2w-starter-kit Airtable inventory auto-registration (ROADMAP Step 16).
2
+ //
3
+ // When a project is scaffolded, optionally CREATE its row in Kerry's Airtable
4
+ // "Cursor Projects" inventory so the z2w-agent-coordination drift/gap cron
5
+ // sees it without a manual "remember to add the Airtable row" step. Answers
6
+ // the 2026-06-03 [→ z2w-starter-kit] WRITE-PAT Open question.
7
+ //
8
+ // SAFETY / public-distribution posture: this is a PUBLIC npm package; the
9
+ // inventory base is Kerry's PRIVATE Airtable. The write is gated entirely on
10
+ // the presence of AIRTABLE_WRITE_PAT in the environment — a customer who has
11
+ // no PAT never writes anything (resolveAirtableConfig returns null → outcome
12
+ // "skipped", silent). The call NEVER blocks or fails a scaffold
13
+ // (warn-and-proceed): the row can always be added by hand later, and the
14
+ // READ-side cron picks it up on its next sweep regardless.
15
+ //
16
+ // Two-PAT least-privilege design (ROADMAP Step 16): the CREATE-only PAT used
17
+ // here is SEPARATE from (a) the read-only PAT the coordination cron uses and
18
+ // (b) the data.records:write PAT the cron's column-flip path will use. Never
19
+ // collapse them into one broad token. The token value is never printed.
20
+ //
21
+ // Patterns mirror src/license.ts: a pure mapper (buildProjectFields), an env
22
+ // resolver (resolveAirtableConfig), and an orchestrator (registerProjectRow)
23
+ // with a fetchImpl / config test seam that never throws.
24
+ import { readFile } from "node:fs/promises";
25
+ import { join } from "node:path";
26
+ import { version } from "./index.js";
27
+ /** Airtable REST API root. */
28
+ export const AIRTABLE_API_BASE = "https://api.airtable.com/v0";
29
+ /**
30
+ * The marker the scaffolder actually writes when the agent-coordination
31
+ * standard applies — the heading of `AGENT_COORDINATION_BODY` (src/standards.ts),
32
+ * with the body's lead sentence as a fallback. We grep-verify against THIS,
33
+ * not the literal `canonical-block` token: the scaffolded files do NOT carry
34
+ * the `<!-- z2w-agent-coordination canonical-block vX.Y.Z -->` HTML fingerprint
35
+ * comment — that fingerprint lives only in this CLI's own CLAUDE.md for
36
+ * cross-project drift detection. Verify against what the scaffolder emits.
37
+ */
38
+ export const COORDINATION_BLOCK_MARKER = /Agent Coordination \(cross-project bulletin participation\)|participates in the Z2W cross-project coordination bulletin/;
39
+ /**
40
+ * "Verify, don't assert" (mirrors [[github-readme-and-version-integrity]]).
41
+ * Read the freshly-written scaffold and report whether it actually carries the
42
+ * agent-coordination block, so the Airtable write only claims
43
+ * `Agent Coordination = Registered` when the block is really present.
44
+ *
45
+ * The standards block (including the coordination body) is inserted into
46
+ * CLAUDE.md; AGENTS.md is checked as a fallback (it mirrors CLAUDE.md). Safe
47
+ * failure mode: a missing/unreadable scaffold returns `false`, which leaves the
48
+ * column blank for Kerry rather than asserting a state we couldn't confirm.
49
+ */
50
+ export async function scaffoldCarriesCoordinationBlock(targetPath, opts = {}) {
51
+ const read = opts.readFileImpl ?? ((p) => readFile(p, "utf8"));
52
+ for (const name of ["CLAUDE.md", "AGENTS.md"]) {
53
+ try {
54
+ const text = await read(join(targetPath, name));
55
+ if (COORDINATION_BLOCK_MARKER.test(text))
56
+ return true;
57
+ }
58
+ catch {
59
+ // Unreadable/missing candidate — try the next, then fall through to false.
60
+ }
61
+ }
62
+ return false;
63
+ }
64
+ /** "Cursor Projects" base. Override with AIRTABLE_INVENTORY_BASE_ID. */
65
+ export const DEFAULT_INVENTORY_BASE_ID = "appomsRpbA3oOlcaW";
66
+ /**
67
+ * "Projects" table — the table ID (not the display name) so the code survives
68
+ * a table rename. Override with AIRTABLE_INVENTORY_TABLE.
69
+ */
70
+ export const DEFAULT_INVENTORY_TABLE = "tblRoXwwu8wzvfqVY";
71
+ const REQUEST_TIMEOUT_MS = 30_000;
72
+ /**
73
+ * Resolve Airtable config from the environment. Returns null when no
74
+ * AIRTABLE_WRITE_PAT is set — the signal that auto-registration is disabled
75
+ * for this caller (every CLI user who isn't Kerry). The base/table fall back
76
+ * to the live "Cursor Projects" defaults when not overridden.
77
+ */
78
+ export function resolveAirtableConfig(env = process.env) {
79
+ const pat = (env["AIRTABLE_WRITE_PAT"] ?? "").trim();
80
+ if (!pat)
81
+ return null;
82
+ const baseId = (env["AIRTABLE_INVENTORY_BASE_ID"] ?? "").trim() || DEFAULT_INVENTORY_BASE_ID;
83
+ const table = (env["AIRTABLE_INVENTORY_TABLE"] ?? "").trim() || DEFAULT_INVENTORY_TABLE;
84
+ return { pat, baseId, table };
85
+ }
86
+ /**
87
+ * Derive a human-friendly project display name from a slug.
88
+ * `z2w-crowdcommerce` → "Z2W Crowdcommerce". Best-effort — Kerry can refine
89
+ * the row's `Project` field by hand afterward.
90
+ */
91
+ export function displayNameFromSlug(slug) {
92
+ return slug
93
+ .split("-")
94
+ .filter(Boolean)
95
+ .map((part) => part.toLowerCase() === "z2w"
96
+ ? "Z2W"
97
+ : part.charAt(0).toUpperCase() + part.slice(1))
98
+ .join(" ");
99
+ }
100
+ /**
101
+ * Pure mapping from ScaffoldInputs to the Airtable "Projects" row fields.
102
+ * Column names confirmed by Kerry 2026-06-03 / 2026-06-16. Columns left empty
103
+ * for Kerry (WordPress Agents File, Framework Version, Plan, Project Type, …)
104
+ * are intentionally omitted.
105
+ */
106
+ export function buildProjectFields(inputs, opts = {}) {
107
+ const fields = {
108
+ Project: displayNameFromSlug(inputs.slug),
109
+ Status: "Active",
110
+ "Creation Method": "Z2W Starter Kit",
111
+ // Must match the eventual projects/{slug}.md filename (the cron keys on it).
112
+ "Project Folder Title": inputs.slug,
113
+ // Write the conventional URL even if `gh repo create` is deferred — the
114
+ // inventory script's slug-resolution chain needs it.
115
+ "Github URL": `https://github.com/${inputs.githubOrg}/${inputs.slug}`,
116
+ // skill-vault is an always-on standard in every scaffold (ROADMAP Step 15).
117
+ "Skill Vault Aware": "Yes",
118
+ };
119
+ // Only assert Agent Coordination = Registered when the scaffold actually
120
+ // carries the coordination block; otherwise leave it blank for Kerry. When
121
+ // the caller verified the scaffold on disk (coordinationVerified is a
122
+ // boolean), honor it; when it couldn't (undefined), trust the input flag.
123
+ if (inputs.participateInBulletin && (opts.coordinationVerified ?? true)) {
124
+ fields["Agent Coordination"] = "Registered";
125
+ }
126
+ // Kerry's standing rule: every inventory row carries its instantiation prompt.
127
+ // The brief-first flow captures the raw pasted brief; the --input path may
128
+ // supply it. When absent (wizard / --input without it) the column is left
129
+ // blank and registerProjectRow reminds the agent to add it by hand.
130
+ const prompt = inputs.instantiationPrompt?.trim();
131
+ if (prompt) {
132
+ fields["Project Instantiation Prompt"] = prompt;
133
+ }
134
+ return fields;
135
+ }
136
+ function hintForStatus(status) {
137
+ switch (status) {
138
+ case 401:
139
+ return "PAT invalid or revoked.";
140
+ case 403:
141
+ return "PAT lacks data.records:write on this base.";
142
+ case 404:
143
+ return "Base ID or table not found — check AIRTABLE_INVENTORY_BASE_ID / _TABLE.";
144
+ case 406:
145
+ return "Airtable WAF blocked the request (User-Agent heuristic).";
146
+ case 422:
147
+ return "Request rejected — a field name or select option may not exist on the base.";
148
+ case 429:
149
+ return "Rate limited (5 req/sec/base) — retry shortly.";
150
+ default:
151
+ return "";
152
+ }
153
+ }
154
+ async function safeText(res) {
155
+ try {
156
+ return (await res.text()).slice(0, 300);
157
+ }
158
+ catch {
159
+ return "";
160
+ }
161
+ }
162
+ /**
163
+ * Create the inventory row for a freshly-scaffolded project. Warn-and-proceed:
164
+ * always resolves (never rejects); the CLI surfaces `message` and continues.
165
+ *
166
+ * - No AIRTABLE_WRITE_PAT → outcome "skipped" (silent for normal users).
167
+ * - opts.dryRun → outcome "dry-run" (prints the would-be request).
168
+ * - 2xx → outcome "created" (+ recordId).
169
+ * - non-2xx / network err → outcome "failed" (+ a diagnostic; row NOT created).
170
+ */
171
+ export async function registerProjectRow(inputs, opts = {}) {
172
+ // "Verify, don't assert": for a participating project with a real scaffold on
173
+ // disk, confirm the coordination block is actually present before claiming
174
+ // `Agent Coordination = Registered`. Skipped for dry-runs (nothing written)
175
+ // and when no targetPath is supplied (falls back to the input flag).
176
+ let coordinationVerified;
177
+ if (inputs.participateInBulletin && opts.targetPath && !opts.dryRun) {
178
+ coordinationVerified = await scaffoldCarriesCoordinationBlock(opts.targetPath, {
179
+ readFileImpl: opts.readFileImpl,
180
+ });
181
+ }
182
+ const fields = buildProjectFields(inputs, { coordinationVerified });
183
+ // Note appended when the block was expected but not found on disk.
184
+ const coordNote = coordinationVerified === false
185
+ ? " Note: the coordination block was not found in the scaffold, so " +
186
+ "Agent Coordination was left blank for you to set by hand."
187
+ : "";
188
+ // Reminder when no instantiation prompt was captured (wizard / --input
189
+ // without one). Kerry's standing rule is that every inventory row carries
190
+ // its Project Instantiation Prompt — surface a nudge so the agent adds it.
191
+ const promptNote = fields["Project Instantiation Prompt"]
192
+ ? ""
193
+ : " Note: no Project Instantiation Prompt was captured for this project — " +
194
+ "add it to the row's \"Project Instantiation Prompt\" column by hand " +
195
+ "(every inventory row should carry its instantiation prompt).";
196
+ const config = opts.config !== undefined ? opts.config : resolveAirtableConfig(opts.env);
197
+ if (config === null) {
198
+ return {
199
+ outcome: "skipped",
200
+ fields,
201
+ coordinationVerified,
202
+ message: "Airtable auto-registration skipped (no AIRTABLE_WRITE_PAT set).",
203
+ };
204
+ }
205
+ const url = `${AIRTABLE_API_BASE}/${config.baseId}/${encodeURIComponent(config.table)}`;
206
+ if (opts.dryRun) {
207
+ return {
208
+ outcome: "dry-run",
209
+ fields,
210
+ url,
211
+ coordinationVerified,
212
+ message: `Airtable auto-registration (dry-run): would POST 1 row to ${url}`,
213
+ };
214
+ }
215
+ const fetchImpl = opts.fetchImpl ?? fetch;
216
+ const controller = new AbortController();
217
+ const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
218
+ try {
219
+ const res = await fetchImpl(url, {
220
+ method: "POST",
221
+ headers: {
222
+ Authorization: `Bearer ${config.pat}`,
223
+ "Content-Type": "application/json",
224
+ Accept: "application/json",
225
+ // Identify the client — Airtable's WAF 406-blocks the stock UA from
226
+ // datacenter IPs (lesson from the coordination READ build, v0.1.44).
227
+ "User-Agent": `z2w-starter-kit/${version} (+https://github.com/zero2webmaster/z2w-starter-kit)`,
228
+ },
229
+ // typecast lets Airtable coerce select-option strings (e.g. a new
230
+ // "Creation Method" option) rather than 422-ing on first use.
231
+ body: JSON.stringify({ fields, typecast: true }),
232
+ signal: controller.signal,
233
+ });
234
+ if (!res.ok) {
235
+ const body = await safeText(res);
236
+ const hint = hintForStatus(res.status);
237
+ return {
238
+ outcome: "failed",
239
+ fields,
240
+ url,
241
+ coordinationVerified,
242
+ message: `Airtable auto-registration failed (HTTP ${res.status}); the row was ` +
243
+ `NOT created — add it by hand or re-run later.` +
244
+ (hint ? ` ${hint}` : "") +
245
+ (body ? ` Response: ${body}` : ""),
246
+ };
247
+ }
248
+ const data = (await res.json().catch(() => null));
249
+ return {
250
+ outcome: "created",
251
+ fields,
252
+ url,
253
+ recordId: data?.id,
254
+ coordinationVerified,
255
+ message: `Airtable inventory row created${data?.id ? ` (${data.id})` : ""}.` +
256
+ coordNote +
257
+ promptNote,
258
+ };
259
+ }
260
+ catch (err) {
261
+ return {
262
+ outcome: "failed",
263
+ fields,
264
+ url,
265
+ coordinationVerified,
266
+ message: `Airtable auto-registration failed (${err.message}); the row ` +
267
+ `was NOT created. Scaffold completed normally — add the row by hand if needed.`,
268
+ };
269
+ }
270
+ finally {
271
+ clearTimeout(timer);
272
+ }
273
+ }
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 `---` to signal done. Type `skip` to fall through to wizard mode.";
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 `---` (the sentinel) or end-of-stream. A first line of
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 `---` to signal done. Type `skip` to fall through to wizard mode.";
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
  }