@zero2webmaster/starter-kit 0.17.2 → 0.18.3
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 +8 -3
- package/dist/audience.d.ts +135 -0
- package/dist/audience.js +206 -0
- package/dist/brand.d.ts +10 -0
- package/dist/brand.js +32 -4
- package/dist/index.d.ts +69 -1
- package/dist/index.js +6 -1
- package/dist/scaffolders/common.js +27 -10
- package/dist/standards.d.ts +1 -1
- package/dist/standards.js +1 -1
- package/dist/substitute.js +30 -0
- package/dist/writer.d.ts +36 -0
- package/dist/writer.js +81 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# z2w-starter-kit
|
|
2
2
|
|
|
3
|
-
**Version:** 0.
|
|
3
|
+
**Version:** 0.18.3 | **Framework:** 2.18.0
|
|
4
4
|
|
|
5
5
|
> Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
|
|
6
6
|
|
|
@@ -83,7 +83,12 @@ The Claude Code skill at `~/.claude/skills/instantiate-z2w-project/SKILL.md` and
|
|
|
83
83
|
|
|
84
84
|
## Status
|
|
85
85
|
|
|
86
|
-
- **v0.
|
|
86
|
+
- **v0.18.3 (current)** makes every emitted `.gitignore` refuse a downloaded cloud service-account key. The Google Cloud console names a private key `<project-id>-<12 hex>.json`, which matched nothing in the scaffolded ignore file and, unlike a stray `.env.production`, carries no hint in its filename that it is a credential. Found when a live Gmail delegation key for two SAVE THE FROGS! mailboxes landed in a repo this CLI had emitted.
|
|
87
|
+
- **v0.18.2** bumps the emitted Agent Coordination fingerprint to **v0.1.26**, matching what `z2w-agent-coordination` currently publishes. Every scaffold emitted while the constant said `v0.1.25` carries a stale fingerprint, which is precisely the drift the fingerprint exists to detect.
|
|
88
|
+
- **v0.18.1** returns the audience gate's findings as **data** (`ScaffoldResult.audienceGate`) rather than only printing them. v0.18.0 wrote its dangling-reference warning to the terminal, but `previewScaffold()` discards its output stream by design — and that is the entry point a web UI uses — so the report had no receiver on the one path where an external audience actually occurs. No emitted file changes by a byte.
|
|
89
|
+
- **v0.18.0** implements **Kerry's 2026-08-14 ruling — Option A: "ship the artifact, not the doctrine."** A new `audience` input (`internal` | `external`, defaulting to `internal`) gates what an outside customer's scaffold contains. The emitted **code is untouched** — that is the value a customer is buying — but the ~40 KB prose corpus explaining which internal rulings produced it is not emitted: `Standards block`, `Z2W Portfolio Standards`, `Capture Learnings`, `Keeping This Framework Current`, `Common Name & Terminology Glossary` and `Agent Coordination` are dropped as **whole `##` sections**, and surviving `[[skill]]` Vault pointers are unwrapped to plain text. Measured on a real customer scaffold: **CLAUDE.md 85,702 → 44,848 B, a 47.7% reduction, 0 Vault pointers, 0 bulletin-repo mentions**; the internal control is byte-for-byte unchanged. **Whole sections, never edited sentences** — omitting a fingerprinted block makes no identity claim, whereas editing one ships a modified body under an unmodified fingerprint and an emitter mints that lie forever. The gate **refuses to emit** when a section it must drop cannot be found (a renamed heading would otherwise re-leak it silently), and **reports** surviving back-references to dropped sections rather than editing the canonical body to fix them.
|
|
90
|
+
**Also fixes a defect that was wrong under every option and had nothing to do with the ruling:** `buildCustomBrandSpec()` hardcoded `author: DEFAULT_AUTHOR` and `CustomBrandInputs` had no author field, so **every outside-customer scaffold emitted `© 2026 Dr. Kerry Kriger` into the customer's own `README.md` and page footer** — the inverse of an IP leak, a false ownership claim on someone else's repo, live on the `project-creator` path. A custom brand now supplies its own `author`/`authorUrl` and falls back to its **own brand name**, the README's hardcoded `, Zero2Webmaster` is empty for custom brands, and the typography rule no longer cites a "Z2W standing organization instruction" at somebody else's organisation. The `marketing.md` / `BACKUPS.md` instructions to mirror status into the **private** Project Registry are omitted for external audiences. Tests **983 → 1,009**.
|
|
91
|
+
- **v0.17.2** closes the gap v0.17.1 left open and stated: the file selection behind that denominator was still an inline chain of filters in `main()`, so **nothing could execute it** without a live database and a full run — the same untestable-inline shape v0.16.2 had just fixed for `--strict`, in the same file, for a second decision. `selectBulletinFiles()` and `describeSelection()` are now pure exported functions with 13 tests, canary-verified by replanting the v0.17.0 bug. Two things came out of the extraction: the selection now **partitions** its input (four disjoint buckets that always sum to the entry count, so a file cannot leave the denominator without changing a number somebody prints), which surfaced two exclusion classes the report had never mentioned; and `main()` now **refuses a run that selected zero files** instead of printing `scanned: 0 / rows that WOULD change: 0` — a summary byte-identical to a healthy, fully-in-sync run. That is this script's own founding failure, relocated one layer up from the parse into the file selection. Real-corpus figure unchanged at **52**, so the refactor is behaviour-preserving.
|
|
87
92
|
- **v0.17.1** stops `scripts/rollup-integrations.mjs` counting its own `*-archive.md` spill files in the "Bulletin files scanned" denominator (72 -> 52), and STATES the exclusion rather than silently shrinking the number.
|
|
88
93
|
- **v0.17.0** makes the **Cloud-Run-vs-Fly.io host choice a standard** for `python-service` / `node-service` scaffolds, so a long-running service's platform is decided by one test — *does it need a persistent volume?* — rather than per project by whoever is in the chair. Cloud Run for stateless request/response that scales to zero with the database elsewhere; Fly.io for stateful always-on needing a disk that survives a restart, which Cloud Run structurally cannot hold. It is a ruling rather than a preference because `z2w-multi-lingual-api` costed it on a live service (~13 req/hr inside a $2/month budget, because Cloud Run genuinely idles at zero), and it carries the half a new project would not think to ask for: **do not re-litigate this as a migration** — every real incident there traced to Neon's CU-hour cap or to secret hygiene, both external to *both* platforms. Deliberately NOT inserted for `cf-worker` / `cf-pages` / `nextjs`, whose host the project type already settles.
|
|
89
94
|
- **v0.16.2** fixes `--strict` so it judges only what the invocation actually reconciled, unblocking `z2w-agent-coordination`'s Project Registry reconciler cron.
|
|
@@ -119,4 +124,4 @@ Inquiries: kerry@zero2webmaster.com.
|
|
|
119
124
|
---
|
|
120
125
|
|
|
121
126
|
*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.*
|
|
122
|
-
*Version: 0.
|
|
127
|
+
*Version: 0.18.3 | Last Updated: 2026-08-15*
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audience gating for the emitted `CLAUDE.md`.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this module exists
|
|
5
|
+
*
|
|
6
|
+
* `project-creator` scaffolds for outside customers on their own GitHub
|
|
7
|
+
* accounts, so framework bytes already leave the building. Measured on a real
|
|
8
|
+
* customer-shaped scaffold (2026-08-14, session `-20260814b`), the emitted
|
|
9
|
+
* `CLAUDE.md` was **80.6 KB** and partitioned:
|
|
10
|
+
*
|
|
11
|
+
* | bucket | bytes | share |
|
|
12
|
+
* |---|---|---|
|
|
13
|
+
* | genuinely proprietary (the ruling set + the Vault index) | 40,251 | 50% |
|
|
14
|
+
* | the framework's method (3-layer, the session ceremony) | 19,213 | 24% |
|
|
15
|
+
* | generic scaffolding (semver, tool notes) | 20,542 | 26% |
|
|
16
|
+
*
|
|
17
|
+
* **Kerry ruled Option A on 2026-08-14: "ship the artifact, not the doctrine."**
|
|
18
|
+
* The emitted *code* is the value a customer buys and is untouched by this
|
|
19
|
+
* module. The prose corpus explaining which internal rulings produced that code
|
|
20
|
+
* is what a competitor would need, and it is not emitted to `external`.
|
|
21
|
+
*
|
|
22
|
+
* Full pros/cons and the measurement: `DECISION-BRIEF-2026-08-14.md`.
|
|
23
|
+
*
|
|
24
|
+
* ## Why whole SECTIONS, and never edited sentences
|
|
25
|
+
*
|
|
26
|
+
* **Omitting a fingerprinted block is legitimate where EDITING one is not.**
|
|
27
|
+
* A section that is never emitted makes no identity claim. A section that is
|
|
28
|
+
* emitted with four sentences quietly removed still carries a fingerprint
|
|
29
|
+
* asserting it is canonical, which lies to every drift checker downstream — and
|
|
30
|
+
* an emitter mints that lie into every future project rather than being one bad
|
|
31
|
+
* file. That is why v0.16.0 refused to redact private repo names in place, and
|
|
32
|
+
* why this module only ever removes whole `## ` sections.
|
|
33
|
+
*
|
|
34
|
+
* The one exception is {@link stripVaultPointers}, which rewrites `[[skill]]`
|
|
35
|
+
* link syntax into plain text *inside the sections that survive*. That is safe
|
|
36
|
+
* for the same reason the section drop is: it removes a pointer the reader
|
|
37
|
+
* cannot follow, and it runs only on blocks this repo itself generates
|
|
38
|
+
* (`src/standards.ts`), never on a fingerprinted body embedded from
|
|
39
|
+
* `cursor-project-templates`.
|
|
40
|
+
*/
|
|
41
|
+
import type { Audience, ScaffoldInputs } from "./index.js";
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the audience for a set of inputs. Centralised so the default lives in
|
|
44
|
+
* exactly one place — every call site reads `internal` for an omitted value, and
|
|
45
|
+
* a future change of default is a one-line edit rather than a grep.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveAudience(inputs: Pick<ScaffoldInputs, "audience">): Audience;
|
|
48
|
+
/**
|
|
49
|
+
* The `## ` sections dropped when `audience === "external"`, each with the
|
|
50
|
+
* reason it is doctrine rather than deliverable.
|
|
51
|
+
*
|
|
52
|
+
* Headings are matched on the text AFTER `## `, case-sensitively, ignoring any
|
|
53
|
+
* trailing qualifier — so `## Standards block (inserted inline per skill v1.1.0)`
|
|
54
|
+
* matches the `Standards block` entry. Matching a prefix rather than the whole
|
|
55
|
+
* line is deliberate: these headings carry version qualifiers that move, and a
|
|
56
|
+
* gate that silently stops matching on a version bump would re-leak the section
|
|
57
|
+
* with nothing going red.
|
|
58
|
+
*/
|
|
59
|
+
export declare const EXTERNAL_DROPPED_SECTIONS: readonly {
|
|
60
|
+
readonly heading: string;
|
|
61
|
+
readonly why: string;
|
|
62
|
+
/**
|
|
63
|
+
* True when this section is only CONDITIONALLY emitted upstream, so its
|
|
64
|
+
* absence is a legitimate state rather than evidence of a renamed heading.
|
|
65
|
+
*
|
|
66
|
+
* Only such sections are exempt from the not-found refusal. Everything else
|
|
67
|
+
* must be found, because for an unconditionally-emitted section "absent" can
|
|
68
|
+
* only mean the gate stopped matching — and a gate that stopped matching
|
|
69
|
+
* produces a customer scaffold still carrying the doctrine, with every signal
|
|
70
|
+
* green. Caught by tier-1 verification on a real scaffold, not by the unit
|
|
71
|
+
* suite, whose fixture contained all six sections (2026-08-14).
|
|
72
|
+
*/
|
|
73
|
+
readonly conditionallyPresent?: boolean;
|
|
74
|
+
}[];
|
|
75
|
+
/** What {@link gateSectionsForAudience} did, so callers can report rather than guess. */
|
|
76
|
+
export interface AudienceGateResult {
|
|
77
|
+
/** The gated document. */
|
|
78
|
+
readonly content: string;
|
|
79
|
+
/** Headings actually removed, in document order. */
|
|
80
|
+
readonly dropped: readonly string[];
|
|
81
|
+
/**
|
|
82
|
+
* Configured headings that were NOT found in the document.
|
|
83
|
+
*
|
|
84
|
+
* **Never silently empty-passes.** A section this gate is supposed to drop
|
|
85
|
+
* but cannot find means either the heading was renamed upstream or the body
|
|
86
|
+
* changed shape — in both cases the section is still being emitted and the
|
|
87
|
+
* gate believes it did its job. Callers surface this; `writeScaffold` refuses.
|
|
88
|
+
*/
|
|
89
|
+
readonly notFound: readonly string[];
|
|
90
|
+
/** Bytes removed. */
|
|
91
|
+
readonly bytesDropped: number;
|
|
92
|
+
/**
|
|
93
|
+
* Surviving lines that still refer to a section this gate removed — e.g. the
|
|
94
|
+
* framework body's *"run the routing decision in the `## Capture Learnings
|
|
95
|
+
* (session end)` block below"*, when that block is no longer below.
|
|
96
|
+
*
|
|
97
|
+
* **Reported, never auto-edited.** Rewriting a sentence inside the canonical
|
|
98
|
+
* AGENTS body is precisely the modification this module refuses to do: a body
|
|
99
|
+
* emitted with sentences quietly altered still carries a fingerprint claiming
|
|
100
|
+
* it is canonical. So the honest handling is to surface the incoherence and
|
|
101
|
+
* let a human decide, rather than either fixing it invisibly or shipping an
|
|
102
|
+
* external scaffold that points at sections it does not contain and saying
|
|
103
|
+
* nothing.
|
|
104
|
+
*/
|
|
105
|
+
readonly danglingReferences: readonly {
|
|
106
|
+
readonly heading: string;
|
|
107
|
+
/** 1-indexed line number in the GATED document. */
|
|
108
|
+
readonly line: number;
|
|
109
|
+
}[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Remove whole `## ` sections from an assembled `CLAUDE.md` for an external
|
|
113
|
+
* audience. A no-op for `internal`, byte-for-byte.
|
|
114
|
+
*
|
|
115
|
+
* A section runs from its `## ` heading to the next `## ` heading (or EOF).
|
|
116
|
+
* `###`/`####` subheadings belong to their parent section and travel with it.
|
|
117
|
+
*
|
|
118
|
+
* Fenced code blocks are respected: a ```` ``` ```` fence can legitimately
|
|
119
|
+
* contain a line starting with `## ` (a markdown example), and treating that as
|
|
120
|
+
* a section boundary would truncate the wrong span. Same fence-blindness bug
|
|
121
|
+
* `z2w-agent-coordination` hit in their own section tooling on 2026-08-13.
|
|
122
|
+
*/
|
|
123
|
+
export declare function gateSectionsForAudience(content: string, audience: Audience): AudienceGateResult;
|
|
124
|
+
/**
|
|
125
|
+
* Rewrite `[[skill-name]]` Vault pointers into plain text.
|
|
126
|
+
*
|
|
127
|
+
* An outside reader cannot open the Skill Vault, so a `[[…]]` link is at best
|
|
128
|
+
* noise and at worst an invitation to go looking for something private. The
|
|
129
|
+
* skill NAME is left visible as ordinary prose rather than deleted, because the
|
|
130
|
+
* surrounding sentence is often written around it and removing the token
|
|
131
|
+
* outright produces broken grammar.
|
|
132
|
+
*
|
|
133
|
+
* A no-op for `internal`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function stripVaultPointers(content: string, audience: Audience): string;
|
package/dist/audience.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audience gating for the emitted `CLAUDE.md`.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this module exists
|
|
5
|
+
*
|
|
6
|
+
* `project-creator` scaffolds for outside customers on their own GitHub
|
|
7
|
+
* accounts, so framework bytes already leave the building. Measured on a real
|
|
8
|
+
* customer-shaped scaffold (2026-08-14, session `-20260814b`), the emitted
|
|
9
|
+
* `CLAUDE.md` was **80.6 KB** and partitioned:
|
|
10
|
+
*
|
|
11
|
+
* | bucket | bytes | share |
|
|
12
|
+
* |---|---|---|
|
|
13
|
+
* | genuinely proprietary (the ruling set + the Vault index) | 40,251 | 50% |
|
|
14
|
+
* | the framework's method (3-layer, the session ceremony) | 19,213 | 24% |
|
|
15
|
+
* | generic scaffolding (semver, tool notes) | 20,542 | 26% |
|
|
16
|
+
*
|
|
17
|
+
* **Kerry ruled Option A on 2026-08-14: "ship the artifact, not the doctrine."**
|
|
18
|
+
* The emitted *code* is the value a customer buys and is untouched by this
|
|
19
|
+
* module. The prose corpus explaining which internal rulings produced that code
|
|
20
|
+
* is what a competitor would need, and it is not emitted to `external`.
|
|
21
|
+
*
|
|
22
|
+
* Full pros/cons and the measurement: `DECISION-BRIEF-2026-08-14.md`.
|
|
23
|
+
*
|
|
24
|
+
* ## Why whole SECTIONS, and never edited sentences
|
|
25
|
+
*
|
|
26
|
+
* **Omitting a fingerprinted block is legitimate where EDITING one is not.**
|
|
27
|
+
* A section that is never emitted makes no identity claim. A section that is
|
|
28
|
+
* emitted with four sentences quietly removed still carries a fingerprint
|
|
29
|
+
* asserting it is canonical, which lies to every drift checker downstream — and
|
|
30
|
+
* an emitter mints that lie into every future project rather than being one bad
|
|
31
|
+
* file. That is why v0.16.0 refused to redact private repo names in place, and
|
|
32
|
+
* why this module only ever removes whole `## ` sections.
|
|
33
|
+
*
|
|
34
|
+
* The one exception is {@link stripVaultPointers}, which rewrites `[[skill]]`
|
|
35
|
+
* link syntax into plain text *inside the sections that survive*. That is safe
|
|
36
|
+
* for the same reason the section drop is: it removes a pointer the reader
|
|
37
|
+
* cannot follow, and it runs only on blocks this repo itself generates
|
|
38
|
+
* (`src/standards.ts`), never on a fingerprinted body embedded from
|
|
39
|
+
* `cursor-project-templates`.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the audience for a set of inputs. Centralised so the default lives in
|
|
43
|
+
* exactly one place — every call site reads `internal` for an omitted value, and
|
|
44
|
+
* a future change of default is a one-line edit rather than a grep.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveAudience(inputs) {
|
|
47
|
+
return inputs.audience ?? "internal";
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The `## ` sections dropped when `audience === "external"`, each with the
|
|
51
|
+
* reason it is doctrine rather than deliverable.
|
|
52
|
+
*
|
|
53
|
+
* Headings are matched on the text AFTER `## `, case-sensitively, ignoring any
|
|
54
|
+
* trailing qualifier — so `## Standards block (inserted inline per skill v1.1.0)`
|
|
55
|
+
* matches the `Standards block` entry. Matching a prefix rather than the whole
|
|
56
|
+
* line is deliberate: these headings carry version qualifiers that move, and a
|
|
57
|
+
* gate that silently stops matching on a version bump would re-leak the section
|
|
58
|
+
* with nothing going red.
|
|
59
|
+
*/
|
|
60
|
+
export const EXTERNAL_DROPPED_SECTIONS = [
|
|
61
|
+
{
|
|
62
|
+
heading: "Z2W Portfolio Standards",
|
|
63
|
+
why: "a pointer index into a private Skill Vault the reader cannot open",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
heading: "Standards block",
|
|
67
|
+
why: "the curated, conflict-resolved ruling set — 28% of the file and the single most valuable section in it",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
heading: "Capture Learnings",
|
|
71
|
+
why: "routes the reader into the private Vault and names private Z2W repos",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
heading: "Keeping This Framework Current",
|
|
75
|
+
why: "a fingerprint-currency table naming private Z2W repos, meaningless outside the ecosystem",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
heading: "Common Name & Terminology Glossary",
|
|
79
|
+
why: "internal vocabulary and Z2W brand spellings; reseeded from the customer's own brandNameRule instead",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
heading: "Agent Coordination",
|
|
83
|
+
why: "the cross-project bulletin protocol; names the private bulletin repo",
|
|
84
|
+
// Emitted only when `participateInBulletin` is true, so an external scaffold
|
|
85
|
+
// with that flag false legitimately has no such section to drop.
|
|
86
|
+
conditionallyPresent: true,
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
/** Normalise a `## ` heading line to its comparable text. */
|
|
90
|
+
function headingText(line) {
|
|
91
|
+
return line.replace(/^##\s+/, "").trim();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* True iff `line` is a `## ` heading whose text begins with `heading`.
|
|
95
|
+
*
|
|
96
|
+
* Prefix rather than equality so a trailing qualifier — `(inserted inline per
|
|
97
|
+
* skill v1.1.0)`, `(session end)` — does not de-match the gate when it moves.
|
|
98
|
+
*/
|
|
99
|
+
function matchesHeading(line, heading) {
|
|
100
|
+
if (!line.startsWith("## "))
|
|
101
|
+
return false;
|
|
102
|
+
const text = headingText(line);
|
|
103
|
+
return text === heading || text.startsWith(heading + " ") || text.startsWith(heading + " (");
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Remove whole `## ` sections from an assembled `CLAUDE.md` for an external
|
|
107
|
+
* audience. A no-op for `internal`, byte-for-byte.
|
|
108
|
+
*
|
|
109
|
+
* A section runs from its `## ` heading to the next `## ` heading (or EOF).
|
|
110
|
+
* `###`/`####` subheadings belong to their parent section and travel with it.
|
|
111
|
+
*
|
|
112
|
+
* Fenced code blocks are respected: a ```` ``` ```` fence can legitimately
|
|
113
|
+
* contain a line starting with `## ` (a markdown example), and treating that as
|
|
114
|
+
* a section boundary would truncate the wrong span. Same fence-blindness bug
|
|
115
|
+
* `z2w-agent-coordination` hit in their own section tooling on 2026-08-13.
|
|
116
|
+
*/
|
|
117
|
+
export function gateSectionsForAudience(content, audience) {
|
|
118
|
+
if (audience !== "external") {
|
|
119
|
+
return {
|
|
120
|
+
content,
|
|
121
|
+
dropped: [],
|
|
122
|
+
notFound: [],
|
|
123
|
+
bytesDropped: 0,
|
|
124
|
+
danglingReferences: [],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const lines = content.split("\n");
|
|
128
|
+
const keep = [];
|
|
129
|
+
const dropped = [];
|
|
130
|
+
const seen = new Set();
|
|
131
|
+
let inFence = false;
|
|
132
|
+
let droppingUnder = null;
|
|
133
|
+
for (const line of lines) {
|
|
134
|
+
// Track fences FIRST — a heading inside a fence is an example, not a section.
|
|
135
|
+
if (/^\s*(```|~~~)/.test(line)) {
|
|
136
|
+
inFence = !inFence;
|
|
137
|
+
if (droppingUnder === null)
|
|
138
|
+
keep.push(line);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (!inFence && line.startsWith("## ")) {
|
|
142
|
+
const hit = EXTERNAL_DROPPED_SECTIONS.find((s) => matchesHeading(line, s.heading));
|
|
143
|
+
if (hit) {
|
|
144
|
+
droppingUnder = hit.heading;
|
|
145
|
+
if (!seen.has(hit.heading)) {
|
|
146
|
+
seen.add(hit.heading);
|
|
147
|
+
dropped.push(hit.heading);
|
|
148
|
+
}
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
// A non-dropped `## ` heading ends any drop in progress.
|
|
152
|
+
droppingUnder = null;
|
|
153
|
+
}
|
|
154
|
+
if (droppingUnder === null)
|
|
155
|
+
keep.push(line);
|
|
156
|
+
}
|
|
157
|
+
const out = keep.join("\n");
|
|
158
|
+
// Only UNCONDITIONALLY-emitted sections count as not-found. A conditionally
|
|
159
|
+
// emitted one (see `conditionallyPresent`) is legitimately absent whenever the
|
|
160
|
+
// condition is false, and reporting it would cry wolf on every non-
|
|
161
|
+
// participating project — which is most external scaffolds, i.e. exactly the
|
|
162
|
+
// case this gate exists for. A check that fires on correct input gets
|
|
163
|
+
// switched off within a week.
|
|
164
|
+
const notFound = EXTERNAL_DROPPED_SECTIONS.filter((s) => !seen.has(s.heading) && s.conditionallyPresent !== true).map((s) => s.heading);
|
|
165
|
+
// Scan what SURVIVED for prose still pointing at a section that did not.
|
|
166
|
+
// Line-anchored on `## <heading>` appearing anywhere in the line (these are
|
|
167
|
+
// inline back-references like "the `## Capture Learnings` block below"), but
|
|
168
|
+
// NOT counting real headings — those are gone by construction at this point.
|
|
169
|
+
const danglingReferences = [];
|
|
170
|
+
const outLines = out.split("\n");
|
|
171
|
+
for (let i = 0; i < outLines.length; i++) {
|
|
172
|
+
const line = outLines[i];
|
|
173
|
+
if (line.startsWith("## "))
|
|
174
|
+
continue;
|
|
175
|
+
for (const { heading } of EXTERNAL_DROPPED_SECTIONS) {
|
|
176
|
+
if (!seen.has(heading))
|
|
177
|
+
continue;
|
|
178
|
+
if (line.includes(`## ${heading}`)) {
|
|
179
|
+
danglingReferences.push({ heading, line: i + 1 });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
content: out,
|
|
185
|
+
dropped,
|
|
186
|
+
notFound,
|
|
187
|
+
bytesDropped: content.length - out.length,
|
|
188
|
+
danglingReferences,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Rewrite `[[skill-name]]` Vault pointers into plain text.
|
|
193
|
+
*
|
|
194
|
+
* An outside reader cannot open the Skill Vault, so a `[[…]]` link is at best
|
|
195
|
+
* noise and at worst an invitation to go looking for something private. The
|
|
196
|
+
* skill NAME is left visible as ordinary prose rather than deleted, because the
|
|
197
|
+
* surrounding sentence is often written around it and removing the token
|
|
198
|
+
* outright produces broken grammar.
|
|
199
|
+
*
|
|
200
|
+
* A no-op for `internal`.
|
|
201
|
+
*/
|
|
202
|
+
export function stripVaultPointers(content, audience) {
|
|
203
|
+
if (audience !== "external")
|
|
204
|
+
return content;
|
|
205
|
+
return content.replace(/\[\[([a-z0-9][a-z0-9-]*)\]\]/g, "$1");
|
|
206
|
+
}
|
package/dist/brand.d.ts
CHANGED
|
@@ -56,6 +56,16 @@ export interface BrandPresetSpec {
|
|
|
56
56
|
export declare const DEFAULT_AUTHOR = "Dr. Kerry Kriger";
|
|
57
57
|
export declare const DEFAULT_AUTHOR_URL = "https://zero2webmaster.com/kerry-kriger";
|
|
58
58
|
export declare const DEFAULT_TYPOGRAPHY_RULE = "Large, easy-to-read type per Z2W standing organization instruction (body 18px+, line-height >= 1.5).";
|
|
59
|
+
/**
|
|
60
|
+
* The typography rule emitted for a `custom` brand.
|
|
61
|
+
*
|
|
62
|
+
* Same substance as {@link DEFAULT_TYPOGRAPHY_RULE} — it is good practice for
|
|
63
|
+
* anyone — but stated WITHOUT attributing it to a "Z2W standing organization
|
|
64
|
+
* instruction". A custom brand is by definition somebody else's organisation,
|
|
65
|
+
* and telling them their type rule comes from Zero2Webmaster is both wrong and
|
|
66
|
+
* a small piece of the same false-attribution defect as the copyright line.
|
|
67
|
+
*/
|
|
68
|
+
export declare const CUSTOM_TYPOGRAPHY_RULE = "Large, easy-to-read type (body 18px+, line-height >= 1.5).";
|
|
59
69
|
/** True iff `s` is a `#RGB` or `#RRGGBB` hex color literal. */
|
|
60
70
|
export declare function isHexColor(s: string): boolean;
|
|
61
71
|
export declare const SAVE_THE_FROGS_PRESET: BrandPresetSpec;
|
package/dist/brand.js
CHANGED
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
export const DEFAULT_AUTHOR = "Dr. Kerry Kriger";
|
|
14
14
|
export const DEFAULT_AUTHOR_URL = "https://zero2webmaster.com/kerry-kriger";
|
|
15
15
|
export const DEFAULT_TYPOGRAPHY_RULE = "Large, easy-to-read type per Z2W standing organization instruction (body 18px+, line-height >= 1.5).";
|
|
16
|
+
/**
|
|
17
|
+
* The typography rule emitted for a `custom` brand.
|
|
18
|
+
*
|
|
19
|
+
* Same substance as {@link DEFAULT_TYPOGRAPHY_RULE} — it is good practice for
|
|
20
|
+
* anyone — but stated WITHOUT attributing it to a "Z2W standing organization
|
|
21
|
+
* instruction". A custom brand is by definition somebody else's organisation,
|
|
22
|
+
* and telling them their type rule comes from Zero2Webmaster is both wrong and
|
|
23
|
+
* a small piece of the same false-attribution defect as the copyright line.
|
|
24
|
+
*/
|
|
25
|
+
export const CUSTOM_TYPOGRAPHY_RULE = "Large, easy-to-read type (body 18px+, line-height >= 1.5).";
|
|
16
26
|
const HEX_COLOR_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
17
27
|
/** True iff `s` is a `#RGB` or `#RRGGBB` hex color literal. */
|
|
18
28
|
export function isHexColor(s) {
|
|
@@ -120,12 +130,25 @@ export function buildCustomBrandSpec(inputs, githubOrg = null) {
|
|
|
120
130
|
brandNameRule: inputs.brandNameRule,
|
|
121
131
|
primaryColor: inputs.primaryColor,
|
|
122
132
|
accentColor: inputs.accentColor,
|
|
123
|
-
typographyRule:
|
|
133
|
+
typographyRule: CUSTOM_TYPOGRAPHY_RULE,
|
|
124
134
|
domains: [],
|
|
125
135
|
githubOrg,
|
|
126
136
|
accountType: "unknown",
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
// 🔴 Fall back to the CUSTOM BRAND'S OWN NAME, never to DEFAULT_AUTHOR.
|
|
138
|
+
//
|
|
139
|
+
// Until v0.18.0 this line read `author: DEFAULT_AUTHOR`, and
|
|
140
|
+
// `CustomBrandInputs` had no author field — so there was no way for a
|
|
141
|
+
// custom brand to own its own work. Every outside-customer scaffold emitted
|
|
142
|
+
// `© 2026 Dr. Kerry Kriger` into the CUSTOMER's `README.md` and, for web
|
|
143
|
+
// types, their page footer. That is the inverse of an IP leak: a false
|
|
144
|
+
// ownership claim landing on somebody else's repo. `custom` is the only
|
|
145
|
+
// brand an outside customer can express (verified in `project-creator`'s
|
|
146
|
+
// own form code), so this was live on the real customer path.
|
|
147
|
+
//
|
|
148
|
+
// Falling back to `brandName` is correct rather than merely safe: for a
|
|
149
|
+
// custom brand the organisation IS the author absent better information.
|
|
150
|
+
author: inputs.author ?? inputs.brandName,
|
|
151
|
+
authorUrl: inputs.authorUrl ?? "",
|
|
129
152
|
extras: [],
|
|
130
153
|
isStub: false,
|
|
131
154
|
};
|
|
@@ -198,7 +221,12 @@ export function renderBrandBlock(spec) {
|
|
|
198
221
|
lines.push(`## Brand: ${spec.brandName}`);
|
|
199
222
|
lines.push("");
|
|
200
223
|
lines.push(`- **Brand name:** \`${spec.brandName}\` — ${spec.brandNameRule}`);
|
|
201
|
-
|
|
224
|
+
// Omit the parenthetical entirely when there is no author URL. A custom brand
|
|
225
|
+
// that supplied no URL would otherwise render `- **Author:** Acme ()`, which
|
|
226
|
+
// reads as a template that failed to fill rather than a field left blank.
|
|
227
|
+
lines.push(spec.authorUrl
|
|
228
|
+
? `- **Author:** ${spec.author} (${spec.authorUrl})`
|
|
229
|
+
: `- **Author:** ${spec.author}`);
|
|
202
230
|
if (spec.githubOrg) {
|
|
203
231
|
lines.push(`- **GitHub owner:** \`${spec.githubOrg}\` — ${renderAccountTypeNote(spec)}`);
|
|
204
232
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import { writeScaffold } from "./writer.js";
|
|
2
|
+
import type { AudienceGateReport } from "./writer.js";
|
|
2
3
|
import type { ScaffoldFile } from "./scaffolders/common.js";
|
|
3
4
|
import type { StandardDecision } from "./standards.js";
|
|
4
5
|
export declare const version = "0.6.0";
|
|
5
6
|
export type ProjectType = "wp-plugin" | "cf-worker" | "cf-pages" | "nextjs" | "python-service" | "node-service" | "library" | "protocol-repo";
|
|
6
7
|
export type BrandPreset = "save-the-frogs" | "bansuri-bliss" | "zero2webmaster" | "custom";
|
|
8
|
+
/**
|
|
9
|
+
* Who will READ the scaffolded project's agent files.
|
|
10
|
+
*
|
|
11
|
+
* `internal` — a Zero2Webmaster project. The full framework body is emitted:
|
|
12
|
+
* the standards block with its rationale, the Skill Vault pointers, the
|
|
13
|
+
* glossary, the capture-learnings routing, the framework-currency table.
|
|
14
|
+
*
|
|
15
|
+
* `external` — an outside customer, on their own GitHub account (the path
|
|
16
|
+
* `project-creator` serves). Per **Kerry's 2026-08-14 ruling (Option A):
|
|
17
|
+
* ship the artifact, not the doctrine.** The emitted CODE is unchanged —
|
|
18
|
+
* that is the value the customer is buying — but the ~40 KB prose corpus
|
|
19
|
+
* explaining which internal rulings produced it is NOT emitted.
|
|
20
|
+
*
|
|
21
|
+
* **This is deliberately NOT derived from `participateInBulletin`.** That flag
|
|
22
|
+
* answers *"does this project post to the coordination bulletin"*, which is a
|
|
23
|
+
* different fact from *"is the reader an outside customer"* — an internal
|
|
24
|
+
* non-participating project would silently lose its own glossary. The
|
|
25
|
+
* distinction was ruled on 2026-08-14 and the reasoning is in
|
|
26
|
+
* `DECISION-BRIEF-2026-08-14.md`.
|
|
27
|
+
*
|
|
28
|
+
* Optional and defaults to `internal`, so every existing caller — the CI
|
|
29
|
+
* `--input` path, the programmatic API, and every Z2W project scaffolded to
|
|
30
|
+
* date — is byte-for-byte unchanged.
|
|
31
|
+
*/
|
|
32
|
+
export type Audience = "internal" | "external";
|
|
7
33
|
export type DbStrategy = "none" | "neon-postgres" | "supabase" | "sqlite" | "mysql-wp" | "other";
|
|
8
34
|
export declare const PROJECT_TYPES: readonly ProjectType[];
|
|
9
35
|
export declare const BRANDS: readonly BrandPreset[];
|
|
@@ -19,6 +45,23 @@ export interface CustomBrandInputs {
|
|
|
19
45
|
brandNameRule: string;
|
|
20
46
|
primaryColor: string;
|
|
21
47
|
accentColor: string;
|
|
48
|
+
/**
|
|
49
|
+
* Who owns the scaffolded project's work — the name that appears in the
|
|
50
|
+
* emitted `README.md` copyright line and, for web types, the page footer.
|
|
51
|
+
*
|
|
52
|
+
* **Optional, and when omitted it falls back to `brandName` — NOT to
|
|
53
|
+
* `DEFAULT_AUTHOR`.** Before v0.18.0 there was no way to supply this at all,
|
|
54
|
+
* so `buildCustomBrandSpec()` hardcoded `Dr. Kerry Kriger` and every
|
|
55
|
+
* outside-customer scaffold emitted `© 2026 Dr. Kerry Kriger` into the
|
|
56
|
+
* CUSTOMER's own README and page footer — a false ownership claim on someone
|
|
57
|
+
* else's repo, live on the `project-creator` path, found 2026-08-14.
|
|
58
|
+
*
|
|
59
|
+
* `custom` is the only brand an outside customer can express, so this field
|
|
60
|
+
* is the one that matters most and was the one missing.
|
|
61
|
+
*/
|
|
62
|
+
author?: string;
|
|
63
|
+
/** Optional URL for {@link author}. Omitted emits no author link. */
|
|
64
|
+
authorUrl?: string;
|
|
22
65
|
}
|
|
23
66
|
/**
|
|
24
67
|
* Free-text sections lifted verbatim from a pasted project brief. Every field
|
|
@@ -51,6 +94,15 @@ export interface ScaffoldInputs {
|
|
|
51
94
|
hasWebUi: boolean;
|
|
52
95
|
hasCron: boolean;
|
|
53
96
|
participateInBulletin: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Who will read the emitted agent files — see {@link Audience}. Optional;
|
|
99
|
+
* omitted reads as `"internal"`, which emits the full framework body exactly
|
|
100
|
+
* as every release before v0.18.0 did.
|
|
101
|
+
*
|
|
102
|
+
* `"external"` implements Kerry's 2026-08-14 Option A ruling: the emitted
|
|
103
|
+
* code is untouched, the doctrine is not emitted.
|
|
104
|
+
*/
|
|
105
|
+
audience?: Audience;
|
|
54
106
|
/**
|
|
55
107
|
* Whether this project sends transactional / auth email (magic links,
|
|
56
108
|
* confirmations, notifications). When `true`, the `nextjs` and `node-service`
|
|
@@ -240,6 +292,22 @@ export interface ScaffoldResult {
|
|
|
240
292
|
files: ScaffoldFile[];
|
|
241
293
|
decisions: StandardDecision[];
|
|
242
294
|
targetPath: string;
|
|
295
|
+
/**
|
|
296
|
+
* What the audience gate did, present only for `audience: "external"`.
|
|
297
|
+
*
|
|
298
|
+
* **Check `danglingReferences` and show it to whoever asked for the
|
|
299
|
+
* scaffold.** A non-empty list means the emitted `CLAUDE.md` still contains
|
|
300
|
+
* prose pointing at sections the gate removed — the scaffold is usable, but
|
|
301
|
+
* a human should decide what to do about the incoherence. The gate refuses to
|
|
302
|
+
* rewrite those sentences itself, because a canonical body emitted with
|
|
303
|
+
* sentences quietly altered still carries a fingerprint claiming it is
|
|
304
|
+
* canonical.
|
|
305
|
+
*
|
|
306
|
+
* Added in v0.18.1 because v0.18.0 wrote this finding to the terminal only,
|
|
307
|
+
* and {@link previewScaffold} discards its output stream by design — so the
|
|
308
|
+
* one consumer that scaffolds for outside customers could not receive it.
|
|
309
|
+
*/
|
|
310
|
+
audienceGate?: AudienceGateReport;
|
|
243
311
|
}
|
|
244
312
|
/**
|
|
245
313
|
* Scaffold a full project to disk and return the composed result.
|
|
@@ -286,7 +354,7 @@ export interface ScaffoldInputValidation {
|
|
|
286
354
|
export declare function validateScaffoldInputs(inputs: ScaffoldInputs): ScaffoldInputValidation;
|
|
287
355
|
export { writeScaffold };
|
|
288
356
|
export { parseScaffoldInputs, loadScaffoldInputs, WriterError } from "./writer.js";
|
|
289
|
-
export type { WriteScaffoldOptions, WriteScaffoldResult, PromotionDecision, } from "./writer.js";
|
|
357
|
+
export type { AudienceGateReport, WriteScaffoldOptions, WriteScaffoldResult, PromotionDecision, } from "./writer.js";
|
|
290
358
|
export { resolveStandards, applyStandardsBlock, fathomEnvVarFor } from "./standards.js";
|
|
291
359
|
export type { StandardKey, StandardDecision, StandardDecisionState, StandardsResolution, } from "./standards.js";
|
|
292
360
|
export { scaffoldByType } from "./scaffolders/index.js";
|
package/dist/index.js
CHANGED
|
@@ -51,7 +51,12 @@ export const DB_STRATEGIES = [
|
|
|
51
51
|
"other",
|
|
52
52
|
];
|
|
53
53
|
function toResult(r) {
|
|
54
|
-
return {
|
|
54
|
+
return {
|
|
55
|
+
files: r.filesWritten,
|
|
56
|
+
decisions: r.decisions,
|
|
57
|
+
targetPath: r.targetPath,
|
|
58
|
+
...(r.audienceGate ? { audienceGate: r.audienceGate } : {}),
|
|
59
|
+
};
|
|
55
60
|
}
|
|
56
61
|
/**
|
|
57
62
|
* Scaffold a full project to disk and return the composed result.
|
|
@@ -87,7 +87,7 @@ const README_TEMPLATE = `# {{slug}}
|
|
|
87
87
|
|
|
88
88
|
## License
|
|
89
89
|
|
|
90
|
-
Proprietary — © {{year}} {{author}}
|
|
90
|
+
Proprietary — © {{year}} {{author}}{{license_org}}. All rights reserved.
|
|
91
91
|
|
|
92
92
|
---
|
|
93
93
|
|
|
@@ -261,11 +261,7 @@ const MARKETING_TEMPLATE = `# Marketing Plan — {{slug}}
|
|
|
261
261
|
|
|
262
262
|
---
|
|
263
263
|
|
|
264
|
-
## Status tracking
|
|
265
|
-
|
|
266
|
-
Mirror the high-level state to the project inventory's \`marketing_plan\` field
|
|
267
|
-
(\`None\` / \`Stub\` / \`Drafted\` / \`Active\`). This file is the detail; the
|
|
268
|
-
inventory is the at-a-glance status the command center reads.
|
|
264
|
+
## Status tracking{{marketing_inventory_note}}
|
|
269
265
|
|
|
270
266
|
---
|
|
271
267
|
|
|
@@ -311,10 +307,7 @@ time a restore was actually exercised:
|
|
|
311
307
|
|
|
312
308
|
---
|
|
313
309
|
|
|
314
|
-
## Status tracking
|
|
315
|
-
|
|
316
|
-
Mirror the high-level state to the project inventory's \`backup_plan\` field. The
|
|
317
|
-
command center can then surface each project's backup status / last-completed.
|
|
310
|
+
## Status tracking{{backups_inventory_note}}
|
|
318
311
|
|
|
319
312
|
---
|
|
320
313
|
|
|
@@ -962,6 +955,30 @@ const GITIGNORE_SECRET_SCRATCH_BLOCK = `
|
|
|
962
955
|
# \`.env.example\` is re-allowed: it carries variable NAMES only, never values.
|
|
963
956
|
.env.*
|
|
964
957
|
!.env.example
|
|
958
|
+
# Cloud provider service-account / credential keys, which the \`.env\` family
|
|
959
|
+
# above does NOT match. The Google Cloud console downloads a service-account
|
|
960
|
+
# private key as \`<project>-<keyid>.json\` — a filename that looks like ordinary
|
|
961
|
+
# project config and gives no hint it is a credential, so it survives the glance
|
|
962
|
+
# that catches a stray \`.env.production\`. Broadened to the family rather than
|
|
963
|
+
# pinned, because nothing matching these names should ever be tracked.
|
|
964
|
+
# (support-desk, 2026-08-15: a live Gmail delegation key landed in a repo where
|
|
965
|
+
# NONE of the patterns above matched it.)
|
|
966
|
+
*-sa.json
|
|
967
|
+
*service-account*.json
|
|
968
|
+
*-serviceaccount*.json
|
|
969
|
+
gcp-*.json
|
|
970
|
+
gcloud-*.json
|
|
971
|
+
credentials.json
|
|
972
|
+
client_secret*.json
|
|
973
|
+
# ...and the shape the console ACTUALLY produces, which none of the readable
|
|
974
|
+
# patterns above catch: \`<gcp-project-id>-<first 12 hex of the key id>.json\`,
|
|
975
|
+
# e.g. \`stf-support-desk-5e7d167d1199.json\`. The project id is arbitrary, so
|
|
976
|
+
# the only stable part is the 12-hex suffix. Verified with real
|
|
977
|
+
# \`git check-ignore\` against both key shapes AND against package.json /
|
|
978
|
+
# tsconfig.json / components.json / wrangler.json / vercel.json /
|
|
979
|
+
# tailwind.config.json / en-US.json / 2026-08-15.json, none of which it
|
|
980
|
+
# swallows — see the test in scaffolders.test.ts.
|
|
981
|
+
*-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].json
|
|
965
982
|
`;
|
|
966
983
|
/**
|
|
967
984
|
* Per-type `.gitignore` body. Sources: skill's "Inline mini-templates"
|
package/dist/standards.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface StandardsResolution {
|
|
|
51
51
|
* family — the safe default for anything else with `has_web_ui=true`.
|
|
52
52
|
*/
|
|
53
53
|
export declare function fathomEnvVarFor(projectType: ProjectType): string;
|
|
54
|
-
export declare const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.
|
|
54
|
+
export declare const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.26";
|
|
55
55
|
/**
|
|
56
56
|
* The canonical **Capture Learnings** block, emitted VERBATIM into every
|
|
57
57
|
* scaffolded `CLAUDE.md`.
|
package/dist/standards.js
CHANGED
|
@@ -447,7 +447,7 @@ const NEON_CAREFUL_BODY = `### Neon-careful (Neon Postgres)
|
|
|
447
447
|
// Two consecutive handoffs compared this constant against the DOCUMENT version
|
|
448
448
|
// and reported a "15-version gap" that did not exist — the real gap was 4. Read
|
|
449
449
|
// the `<!-- ... canonical-block vX.Y.Z -->` comment, never the `**Version:**` line.
|
|
450
|
-
export const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.
|
|
450
|
+
export const CANONICAL_COORDINATION_BLOCK_VERSION = "v0.1.26";
|
|
451
451
|
/**
|
|
452
452
|
* The canonical **Capture Learnings** block, emitted VERBATIM into every
|
|
453
453
|
* scaffolded `CLAUDE.md`.
|
package/dist/substitute.js
CHANGED
|
@@ -105,6 +105,36 @@ export function buildSubstitutionMap(inputs, opts = {}) {
|
|
|
105
105
|
accent_color: spec.accentColor,
|
|
106
106
|
author: spec.author,
|
|
107
107
|
author_url: spec.authorUrl,
|
|
108
|
+
// The organisation named alongside the author in the emitted LICENSE /
|
|
109
|
+
// README copyright line, ALREADY comma-prefixed — or empty.
|
|
110
|
+
//
|
|
111
|
+
// 🔴 Empty for a `custom` brand. That line used to hardcode
|
|
112
|
+
// ", Zero2Webmaster", so a customer's own README read
|
|
113
|
+
// "© 2026 Acme Manufacturing, Zero2Webmaster. All rights reserved." —
|
|
114
|
+
// asserting a Z2W interest in someone else's work. Same false-attribution
|
|
115
|
+
// defect as the author fallback, one line further down the file
|
|
116
|
+
// (2026-08-14). The three Z2W presets are unchanged, byte for byte.
|
|
117
|
+
license_org: spec.preset === "custom" ? "" : ", Zero2Webmaster",
|
|
118
|
+
// The "mirror this status into the Project Registry" sentences in the
|
|
119
|
+
// emitted marketing.md / BACKUPS.md.
|
|
120
|
+
//
|
|
121
|
+
// 🔴 Empty for an EXTERNAL audience. The Project Registry is a private Neon
|
|
122
|
+
// database an outside customer cannot reach, so those files were telling
|
|
123
|
+
// them to update a system they have no access to (2026-08-14, defect 2 of
|
|
124
|
+
// the decision brief). Internal scaffolds are unchanged, byte for byte.
|
|
125
|
+
// NOTE: these reproduce the ORIGINAL line wrapping exactly, so an internal
|
|
126
|
+
// scaffold is byte-for-byte identical to every release before v0.18.0. The
|
|
127
|
+
// first cut rewrapped them onto one line and silently dropped a clause from
|
|
128
|
+
// BACKUPS.md — caught by the golden snapshots, which is what they are for.
|
|
129
|
+
marketing_inventory_note: (inputs.audience ?? "internal") === "external"
|
|
130
|
+
? ""
|
|
131
|
+
: "\n\nMirror the high-level state to the project inventory's `marketing_plan` field\n" +
|
|
132
|
+
"(`None` / `Stub` / `Drafted` / `Active`). This file is the detail; the\n" +
|
|
133
|
+
"inventory is the at-a-glance status the command center reads.",
|
|
134
|
+
backups_inventory_note: (inputs.audience ?? "internal") === "external"
|
|
135
|
+
? ""
|
|
136
|
+
: "\n\nMirror the high-level state to the project inventory's `backup_plan` field. The\n" +
|
|
137
|
+
"command center can then surface each project's backup status / last-completed.",
|
|
108
138
|
github_org: inputs.githubOrg,
|
|
109
139
|
date,
|
|
110
140
|
year: date.slice(0, 4),
|
package/dist/writer.d.ts
CHANGED
|
@@ -47,6 +47,42 @@ export interface WriteScaffoldResult {
|
|
|
47
47
|
targetPath: string;
|
|
48
48
|
/** Mirrors `opts.dryRun`. */
|
|
49
49
|
dryRun: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* What the audience gate did — `undefined` for `audience="internal"`, where
|
|
52
|
+
* the gate is a byte-for-byte no-op and there is nothing to report.
|
|
53
|
+
*
|
|
54
|
+
* 🔴 **This exists because the warning had no receiver on the path that
|
|
55
|
+
* matters.** The dangling-reference finding was written to `output` only,
|
|
56
|
+
* and `previewScaffold()` — the entry point a web UI uses, and the one
|
|
57
|
+
* `project-creator` runs for every outside-customer scaffold — pipes `output`
|
|
58
|
+
* into a discarding sink by design, so it can return files as data instead of
|
|
59
|
+
* printing. The result was a report nobody could receive: the gate correctly
|
|
60
|
+
* refused to auto-edit the canonical body, said so, and said it into
|
|
61
|
+
* `/dev/null`. Returning it as DATA is what makes "report, never auto-edit"
|
|
62
|
+
* true for a programmatic consumer rather than only for a terminal.
|
|
63
|
+
*/
|
|
64
|
+
audienceGate?: AudienceGateReport;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The audience gate's findings, returned as data so a programmatic consumer can
|
|
68
|
+
* surface them. Mirrors the fields of `AudienceGateResult` that a caller can
|
|
69
|
+
* act on; the gated content itself is already in `filesWritten`.
|
|
70
|
+
*/
|
|
71
|
+
export interface AudienceGateReport {
|
|
72
|
+
/** `## ` headings actually removed, in document order. */
|
|
73
|
+
readonly dropped: readonly string[];
|
|
74
|
+
/** Bytes removed from `CLAUDE.md`. */
|
|
75
|
+
readonly bytesDropped: number;
|
|
76
|
+
/**
|
|
77
|
+
* Surviving lines that still point at a dropped section. Non-empty means the
|
|
78
|
+
* emitted `CLAUDE.md` is internally incoherent in a way a human should see —
|
|
79
|
+
* NOT that the scaffold failed. A caller that ignores this ships a customer a
|
|
80
|
+
* file referring to sections it does not contain.
|
|
81
|
+
*/
|
|
82
|
+
readonly danglingReferences: readonly {
|
|
83
|
+
readonly heading: string;
|
|
84
|
+
readonly line: number;
|
|
85
|
+
}[];
|
|
50
86
|
}
|
|
51
87
|
export declare class WriterError extends Error {
|
|
52
88
|
constructor(message: string);
|
package/dist/writer.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
import { promises as fs } from "node:fs";
|
|
24
24
|
import * as path from "node:path";
|
|
25
25
|
import fsExtra from "fs-extra";
|
|
26
|
+
import { EXTERNAL_DROPPED_SECTIONS, gateSectionsForAudience, resolveAudience, stripVaultPointers, } from "./audience.js";
|
|
26
27
|
import { AGENT_COORDINATION_BLOCK_MARKER, AGENTS_BODY_MARKER, STANDARDS_BLOCK_MARKER, } from "./scaffolders/common.js";
|
|
27
28
|
import { buildProSeoExtension, proSeoApplies, } from "./scaffolders/pro-seo-extension.js";
|
|
28
29
|
import { scaffoldByType } from "./scaffolders/index.js";
|
|
@@ -235,6 +236,54 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
|
|
|
235
236
|
// MUST run AFTER the AGENTS body splice — the canonical framework body carries
|
|
236
237
|
// this same block, and this call is what dedupes it down to one.
|
|
237
238
|
claudeContent = applyCaptureLearningsBlock(claudeContent);
|
|
239
|
+
// Audience gate — Kerry's 2026-08-14 Option A ruling ("ship the artifact, not
|
|
240
|
+
// the doctrine"). MUST run LAST of the CLAUDE.md passes: it drops whole `## `
|
|
241
|
+
// sections, and the capture-learnings and AGENTS-body splices above both ADD
|
|
242
|
+
// sections it is responsible for dropping. Running it earlier would gate a
|
|
243
|
+
// document that had not been fully assembled yet, and the re-added sections
|
|
244
|
+
// would sail straight through.
|
|
245
|
+
const audience = resolveAudience(inputs);
|
|
246
|
+
const gate = gateSectionsForAudience(claudeContent, audience);
|
|
247
|
+
if (audience === "external" && gate.notFound.length > 0) {
|
|
248
|
+
// Refuse rather than emit. A configured section the gate could not FIND is
|
|
249
|
+
// indistinguishable, in the output, from one it successfully removed — the
|
|
250
|
+
// no-silent-zero shape this repo has now hit three times. If a heading is
|
|
251
|
+
// renamed upstream the section is still being emitted, and the customer
|
|
252
|
+
// scaffold ships the doctrine while every signal reports success.
|
|
253
|
+
throw new WriterError(`Audience gate could not find ${gate.notFound.length} of ` +
|
|
254
|
+
`${EXTERNAL_DROPPED_SECTIONS.length} section(s) it must drop for ` +
|
|
255
|
+
`audience="external": ${gate.notFound.join(", ")}. ` +
|
|
256
|
+
`Refusing to emit a customer scaffold that may still contain them. ` +
|
|
257
|
+
`A heading was probably renamed upstream in Templates — update ` +
|
|
258
|
+
`EXTERNAL_DROPPED_SECTIONS in src/audience.ts to match.`);
|
|
259
|
+
}
|
|
260
|
+
if (audience === "external" && gate.danglingReferences.length > 0) {
|
|
261
|
+
// Report, never auto-edit — rewriting a sentence inside the canonical
|
|
262
|
+
// AGENTS body would emit a modified block under an unmodified fingerprint.
|
|
263
|
+
// Surfacing it is the honest middle: the scaffold is usable, and nobody
|
|
264
|
+
// discovers the incoherence by reading it in a customer's repo.
|
|
265
|
+
const uniq = [...new Set(gate.danglingReferences.map((d) => d.heading))];
|
|
266
|
+
output.write(`\n⚠️ audience="external": ${gate.danglingReferences.length} surviving ` +
|
|
267
|
+
`line(s) still refer to ${uniq.length} dropped section(s): ` +
|
|
268
|
+
`${uniq.join(", ")}.\n` +
|
|
269
|
+
` These are back-references inside the canonical framework body, which ` +
|
|
270
|
+
`this CLI does not edit\n` +
|
|
271
|
+
` (a modified body under an unmodified fingerprint lies to every drift ` +
|
|
272
|
+
`checker downstream).\n` +
|
|
273
|
+
` Lines: ${gate.danglingReferences.map((d) => d.line).join(", ")} of ` +
|
|
274
|
+
`the emitted CLAUDE.md.\n`);
|
|
275
|
+
}
|
|
276
|
+
// Capture the gate's findings for the RETURN VALUE as well as the terminal —
|
|
277
|
+
// see the `audienceGate` docblock. Built here rather than at the return site
|
|
278
|
+
// so it cannot drift from the `gate` that was actually applied.
|
|
279
|
+
const audienceGate = audience === "external"
|
|
280
|
+
? {
|
|
281
|
+
dropped: gate.dropped,
|
|
282
|
+
bytesDropped: gate.bytesDropped,
|
|
283
|
+
danglingReferences: gate.danglingReferences,
|
|
284
|
+
}
|
|
285
|
+
: undefined;
|
|
286
|
+
claudeContent = stripVaultPointers(gate.content, audience);
|
|
238
287
|
checkNoUnfilledMarkers(claudeContent, "CLAUDE.md");
|
|
239
288
|
files[claudeIdx] = { path: claudeFile.path, content: claudeContent };
|
|
240
289
|
// Append promotions follow-up file if any standard was promoted.
|
|
@@ -284,6 +333,10 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
|
|
|
284
333
|
promotions,
|
|
285
334
|
targetPath: resolvedTarget,
|
|
286
335
|
dryRun: true,
|
|
336
|
+
// The dry-run branch is the one `previewScaffold()` takes, i.e. the path
|
|
337
|
+
// a web UI actually runs — so this is the return site that MATTERS for
|
|
338
|
+
// the gate report, not an afterthought copy of the one below.
|
|
339
|
+
...(audienceGate ? { audienceGate } : {}),
|
|
287
340
|
};
|
|
288
341
|
}
|
|
289
342
|
if (refuseNonEmpty && !(await isDirectoryEmptyOrAbsent(resolvedTarget))) {
|
|
@@ -302,6 +355,7 @@ export async function writeScaffold(inputs, targetPath, opts = {}) {
|
|
|
302
355
|
promotions,
|
|
303
356
|
targetPath: resolvedTarget,
|
|
304
357
|
dryRun: false,
|
|
358
|
+
...(audienceGate ? { audienceGate } : {}),
|
|
305
359
|
};
|
|
306
360
|
}
|
|
307
361
|
// ── Non-interactive --input parser ──────────────────────────────────────────
|
|
@@ -381,13 +435,40 @@ export function parseScaffoldInputs(json) {
|
|
|
381
435
|
throw new WriterError(`--input customBrand.${key} must be a string, got ${typeof cbo[key]}.`);
|
|
382
436
|
}
|
|
383
437
|
}
|
|
438
|
+
// Optional author/authorUrl. Omitted falls back to brandName downstream in
|
|
439
|
+
// buildCustomBrandSpec() — NEVER to DEFAULT_AUTHOR. Validated (not silently
|
|
440
|
+
// coerced) for the same reason every other optional input is: a dropped
|
|
441
|
+
// field here produces a plausible scaffold with the wrong copyright and
|
|
442
|
+
// nothing goes red. See the CustomBrandInputs docblock for the 2026-08-14
|
|
443
|
+
// false-attribution defect this closes.
|
|
444
|
+
for (const key of ["author", "authorUrl"]) {
|
|
445
|
+
if (cbo[key] !== undefined && typeof cbo[key] !== "string") {
|
|
446
|
+
throw new WriterError(`--input customBrand.${key} must be a string, got ${typeof cbo[key]}.`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
384
449
|
inputs.customBrand = {
|
|
385
450
|
brandName: cbo["brandName"],
|
|
386
451
|
brandNameRule: cbo["brandNameRule"],
|
|
387
452
|
primaryColor: cbo["primaryColor"],
|
|
388
453
|
accentColor: cbo["accentColor"],
|
|
454
|
+
...(typeof cbo["author"] === "string" ? { author: cbo["author"] } : {}),
|
|
455
|
+
...(typeof cbo["authorUrl"] === "string" ? { authorUrl: cbo["authorUrl"] } : {}),
|
|
389
456
|
};
|
|
390
457
|
}
|
|
458
|
+
// Optional: WHO reads the emitted agent files. Defaults to "internal", which
|
|
459
|
+
// emits the full framework body exactly as every release before v0.18.0 did,
|
|
460
|
+
// so no existing caller changes. "external" applies Kerry's 2026-08-14
|
|
461
|
+
// Option A ruling — the code is untouched, the doctrine is not emitted.
|
|
462
|
+
// NOT a boolean, so it is validated here rather than by the boolean
|
|
463
|
+
// enumerator, and it has its own round-trip test in src/writer.test.ts.
|
|
464
|
+
if (obj["audience"] !== undefined) {
|
|
465
|
+
const a = obj["audience"];
|
|
466
|
+
if (a !== "internal" && a !== "external") {
|
|
467
|
+
throw new WriterError(`--input field "audience" must be "internal" or "external", got ` +
|
|
468
|
+
`${JSON.stringify(a)}.`);
|
|
469
|
+
}
|
|
470
|
+
inputs.audience = a;
|
|
471
|
+
}
|
|
391
472
|
// Optional: whether this project sends transactional / auth email. Defaults
|
|
392
473
|
// to false (no mailer). Honored only by nextjs / node-service scaffolders.
|
|
393
474
|
if (obj["sendsEmail"] !== undefined) {
|