@luhtech/site-template 0.2.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # @luhtech/site-template
2
+
3
+ One Astro component library renders every LuhTech venture marketing site from
4
+ its own `content/page.schema.json` + `content/site.schema.json` instances.
5
+ Copy is a derived surface -- the instances are the authored source, this
6
+ package is the renderer, and it validates on every build so an invalid
7
+ instance fails the build instead of shipping.
8
+
9
+ ```
10
+ npm install @luhtech/site-template
11
+ ```
12
+
13
+ Published to npmjs.com (public, Apache-2.0) via trusted publishing (GitHub
14
+ OIDC) -- no `NPM_TOKEN`, no read token, nothing for a consumer to configure
15
+ at build time. Superseded the 0.2.0 GitHub Packages artifact under
16
+ `@luh-tech/site-template`, which required a `LUHTECH_PKG_READ` token at
17
+ every consumer's install step and broke Cloudflare Workers Build for any
18
+ site with no way to supply one (GTM-L3 G1.4-R, 2026-09-08).
19
+
20
+ ## The contract
21
+
22
+ - **`loadSite(path)`** / **`loadPage(path)`** (`@luhtech/site-template/content`)
23
+ read a JSON file and ajv-validate it against the live, version-pinned
24
+ schema (`package.json`'s `luhtech.schemaPins`) plus its real `$ref` chain.
25
+ Throws on any validation failure.
26
+ - **`<SiteLayout site={site} page={page}>`** (`@luhtech/site-template/layouts/SiteLayout.astro`)
27
+ renders nav from `site.nav`, footer from `site.footer.legalLine` +
28
+ `parentHref`, and `<head>` from `page.seo` (title, description, og:\*,
29
+ twitter:\*). `og:image`'s "must not be a staging host" rule is enforced by
30
+ the schema itself, not this layout.
31
+ - **`<Section section={s} />`** (`@luhtech/site-template/components/Section.astro`)
32
+ dispatches on `sectionKind` to one component per kind: `Hero`, `Problem`,
33
+ `Approach`, `Proof`, `Audiences`, `Open`, `Status`, `Sources`, `Cta`,
34
+ `Legal` (all under `components/sections/`). `blocks[]` render by
35
+ `blockType` via the shared `Block` component; `figures[]` render with
36
+ `provenance.sourceRef` (in `Sources`); `crossLinks[]` render as name +
37
+ relationshipLine + href -- the one schema-legal way a page names a
38
+ sibling brand.
39
+ - **`loadBrand(path)`** (`@luhtech/site-template/content`) reads a
40
+ `content/brand/<venture>.json` file and ajv-validates it against the live,
41
+ version-pinned `portfolio/brand-identity.schema.json`. Mirrors
42
+ `loadPage`/`loadSite`.
43
+ - **`applyBrandDefaults(page, brand)`** (`@luhtech/site-template/content`) --
44
+ GTM-L3 G1.1/G1.2: on the page whose `route` is `/`, returns a copy of
45
+ `page` with `sections[hero].heading` replaced by `brand.identity.tagline`,
46
+ the hero's `lede` block replaced by `brand.identity.oneLiner`, and
47
+ `seo.title`/`seo.description` replaced by the brand-derived pair
48
+ (`"<brand.name> -- <identity.oneLiner>"` / `identity.oneLiner`). Any
49
+ authored value it overrides logs a build warning naming the field.
50
+ Interior pages (`route !== '/'`) pass through unchanged -- they keep their
51
+ own heading and `seo`; the `"<page heading> -- <brand.name>"` title
52
+ pattern for interior pages is a content-authoring convention for the page
53
+ instance itself, not a runtime override (`seo.title`/`seo.description`
54
+ are schema-required non-empty strings, so there is no "empty" state for
55
+ either route kind to default from).
56
+ - `SiteLayout` also appends `{ label: "LuhTech Holdings", href:
57
+ "https://luh.tech" }` as the last nav item on every site whose
58
+ `ventureRef !== "luhtech-business"`, unless the site's own `nav[]` already
59
+ has an entry pointing at that href.
60
+ - **`<LeadCaptureForm leadCapture={site.leadCapture} />`** -- the real
61
+ contact-form pattern (originally Replique's own form/script) parameterised
62
+ off `site.leadCapture`: `destination` is a schema const shared by every
63
+ site, `source`/`ventureField`/`honeypotField`/`minSubmitMs` vary per site.
64
+ - **`luhtech-tokens <brand.json> <output.css>`** (bin) generates
65
+ `tokens.generated.css` from a `content/brand/<brand>.json` instance
66
+ (display Sora / body Inter / mono JetBrains Mono) -- run this in your
67
+ `predev`/`prebuild` script, the same place every venture repo already
68
+ calls its own `generate-tokens.mjs`.
69
+ - **`luhtech-page-lexicon <page.json> <brand.json> [luhtech-business-brand.json]`**
70
+ (bin) -- RULE-CONTENT-PAGE-LEXICON-PROHIBITED-1: fails if any text-bearing
71
+ field contains a term from the brand's (or LuhTech-Business's)
72
+ `voice.lexicon.prohibited[]`. `crossLinks[].relationshipLine` is exempt.
73
+ - **`luhtech-page-claims <page.json>`** (bin) -- RULE-CONTENT-PAGE-CLAIM-CEILING-1:
74
+ fails if any `kind=built` claim's `sourcedStatus` exceeds the real feature's
75
+ status on the ladder `concept < planned < partial < operational`.
76
+ Resolves `featureRef` against `.roadmap/roadmap.json`'s `features[]` (via
77
+ the GitHub contents API at each venture's own `main`), except venture
78
+ `ectropy`, which has no `features[]` array and resolves instead against
79
+ `.roadmap/features/<id>/FEATURE.json` in `Ectropy-Business` -- the same
80
+ file `eb-agent` reads under the hood, since this bin runs in plain CI with
81
+ no MCP access. `kind=method` claims describe design intent regardless of
82
+ status and are reported, never failed.
83
+
84
+ ## A known, out-of-scope gap
85
+
86
+ `content/capability-claim.schema.json` 404s at both its bare and
87
+ version-pinned live URLs (a schema-registry publish-pipeline issue, not
88
+ something this package can fix). `loadPage`'s validator falls back to a
89
+ vendored local copy (`src/content/_vendored-schema-fallback/`, fetched from
90
+ the real schema-registry source, not fabricated) only for this one schema,
91
+ and logs a warning when it does. Every other schema fetch failure is a hard
92
+ error.
93
+
94
+ ## Migrating a venture site
95
+
96
+ A migration is: author `content/site.<venture>.json` + `content/pages/*.json`
97
+ (the content, not new copy -- lift the current live text verbatim into
98
+ sections), add one template dependency (`@luhtech/site-template`), and
99
+ replace the site's inline `index.astro` with a call into `SiteLayout` +
100
+ `Section`:
101
+
102
+ ```astro
103
+ ---
104
+ import { loadSite, loadPage, loadBrand, applyBrandDefaults } from '@luhtech/site-template/content';
105
+ import SiteLayout from '@luhtech/site-template/layouts/SiteLayout.astro';
106
+ import Section from '@luhtech/site-template/components/Section.astro';
107
+
108
+ const site = await loadSite('content/sites/<venture>.json');
109
+ const brand = await loadBrand('content/brand/<venture>.json');
110
+ const page = applyBrandDefaults(await loadPage('content/pages/home.json'), brand);
111
+ ---
112
+ <SiteLayout site={site} page={page}>
113
+ {page.sections.map((s) => <Section section={s} site={site} />)}
114
+ </SiteLayout>
115
+ ```
116
+
117
+ Every route calls `loadPage` + `applyBrandDefaults` this way, not just `/` --
118
+ the function is a no-op on interior routes and keeps the call site uniform.
119
+
120
+ `site` is passed through to every `<Section>` call but only actually used by
121
+ the `cta` sectionKind, which embeds the real `LeadCaptureForm` directly
122
+ (matching the schema's own description of `cta`: "lead-capture"). Don't also
123
+ render a standalone `<LeadCaptureForm>` when the page has a `cta` section --
124
+ the two would duplicate the heading and produce a dead-end button ahead of
125
+ the real form (found live during Replique's migration, GTM-L2 C3). A page
126
+ with no `cta` section can still render `<LeadCaptureForm leadCapture=
127
+ {site.leadCapture} />` directly wherever it needs one.
128
+
129
+ Run `luhtech-tokens content/brand/<brand>.json src/styles/tokens.generated.css`
130
+ in `predev`/`prebuild` as before. Run both check bins in CI against every
131
+ `content/pages/*.json` the repo carries.
132
+
133
+ ## Peer dependencies
134
+
135
+ `astro ^7.2`, `tailwindcss ^4`.
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RULE-CONTENT-PAGE-CLAIM-CEILING-1: kind=built claims must be backed by
4
+ * real feature status at or above sourcedStatus on the ladder
5
+ * concept < planned < partial < operational
6
+ * kind=method claims describe design intent regardless of status -- no
7
+ * ceiling check, reported but never failed.
8
+ *
9
+ * Resolver: a claim's featureRef (urn:luhtech:<venture>:feature:<id>) is
10
+ * resolved against .roadmap/roadmap.json's features[] (fetched from the
11
+ * venture's own repo at origin/main via the GitHub REST contents API), or
12
+ * -- for venture "ectropy" specifically, which resolves features via
13
+ * eb-agent, not a roadmap.json features array (confirmed repeatedly: no
14
+ * features[] array exists for ectropy) -- .roadmap/features/<id>/FEATURE.json
15
+ * in luh-tech/Ectropy-Business, the same file eb-agent itself reads under
16
+ * the hood. This bin runs in plain CI (no MCP access), so it reads the real
17
+ * file directly rather than trying to invoke eb-agent.
18
+ *
19
+ * Usage: luhtech-page-claims <path-to-page.json>
20
+ * Exit 0: every built claim's sourcedStatus <= real feature status (or null,
21
+ * which skips the ceiling but still requires featureRef to resolve).
22
+ * Exit 1: any built claim exceeds real status, or featureRef is dangling.
23
+ */
24
+ import { readFileSync } from 'node:fs';
25
+
26
+ const REPO_BY_VENTURE = {
27
+ jobsitecontrol: 'JobsiteControl',
28
+ qullqa: 'Qullqa',
29
+ viiva: 'Viiva',
30
+ siltana: 'Siltana-Business',
31
+ ohjaus: 'Ohjaus',
32
+ raizal: 'Raizal',
33
+ hilja: 'Hilja',
34
+ replique: 'Replique',
35
+ 'luhtech-business': 'LuhTech-Business',
36
+ };
37
+
38
+ const LADDER = ['concept', 'planned', 'partial', 'operational'];
39
+
40
+ // Real roadmap.json feature-status vocabulary -> the ladder (established
41
+ // convention used consistently across this portfolio's own claim-ceiling
42
+ // passes): concept/planned map 1:1; in-progress/prototype are "partial"
43
+ // (exists, not complete); complete/production are "operational".
44
+ const ROADMAP_STATUS_TO_LADDER = {
45
+ concept: 'concept',
46
+ planned: 'planned',
47
+ 'in-progress': 'partial',
48
+ prototype: 'partial',
49
+ complete: 'operational',
50
+ production: 'operational',
51
+ };
52
+
53
+ // Ectropy FEATURE.json's own status vocabulary (UPPER_CASE, distinct from
54
+ // roadmap.json's lowercase convention -- confirmed: PLANNED, BETA,
55
+ // PRODUCTION, etc.) -> the same ladder.
56
+ const FEATURE_JSON_STATUS_TO_LADDER = {
57
+ PLANNED: 'planned',
58
+ BETA: 'partial',
59
+ PRODUCTION: 'operational',
60
+ };
61
+
62
+ const [, , pagePath] = process.argv;
63
+ if (!pagePath) {
64
+ console.error('Usage: luhtech-page-claims <path-to-page.json>');
65
+ process.exit(1);
66
+ }
67
+
68
+ const GH_API = 'https://api.github.com';
69
+ const ghHeaders = () => {
70
+ const h = { Accept: 'application/vnd.github.v3+json' };
71
+ const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
72
+ if (token) h.Authorization = `Bearer ${token}`;
73
+ return h;
74
+ };
75
+
76
+ async function ghContents(repo, path) {
77
+ const url = `${GH_API}/repos/luh-tech/${repo}/contents/${path}?ref=main`;
78
+ const res = await fetch(url, { headers: ghHeaders() });
79
+ if (!res.ok) {
80
+ throw new Error(`GitHub contents fetch failed for ${repo}/${path}: HTTP ${res.status}`);
81
+ }
82
+ const body = await res.json();
83
+ return JSON.parse(Buffer.from(body.content, 'base64').toString('utf-8'));
84
+ }
85
+
86
+ async function resolveFeatureStatus(featureRef) {
87
+ const m = featureRef.match(/^urn:luhtech:([a-z0-9-]+):feature:([a-z0-9-]+)$/);
88
+ if (!m) throw new Error(`Malformed featureRef: ${featureRef}`);
89
+ const [, venture, featureId] = m;
90
+
91
+ if (venture === 'ectropy') {
92
+ const doc = await ghContents('Ectropy-Business', `.roadmap/features/${featureId}/FEATURE.json`);
93
+ const rung = FEATURE_JSON_STATUS_TO_LADDER[doc.status];
94
+ if (!rung) throw new Error(`Ectropy feature ${featureId}: unrecognized status "${doc.status}"`);
95
+ return rung;
96
+ }
97
+
98
+ const repo = REPO_BY_VENTURE[venture];
99
+ if (!repo) throw new Error(`No repo mapping for venture "${venture}" (featureRef ${featureRef})`);
100
+ const doc = await ghContents(repo, '.roadmap/roadmap.json');
101
+ const feature = (doc.features ?? []).find((f) => f.id === featureId);
102
+ if (!feature) throw new Error(`${repo}: no feature "${featureId}" in .roadmap/roadmap.json features[]`);
103
+ const rung = ROADMAP_STATUS_TO_LADDER[feature.status];
104
+ if (!rung) throw new Error(`${repo} feature ${featureId}: unrecognized status "${feature.status}"`);
105
+ return rung;
106
+ }
107
+
108
+ function ladderIndex(rung) {
109
+ const i = LADDER.indexOf(rung);
110
+ if (i === -1) throw new Error(`Unknown ladder rung: ${rung}`);
111
+ return i;
112
+ }
113
+
114
+ async function main() {
115
+ const page = JSON.parse(readFileSync(pagePath, 'utf-8'));
116
+ const claims = (page.sections ?? []).flatMap((s) => (s.claims ?? []).map((c) => ({ ...c, sectionId: s.sectionId })));
117
+
118
+ let violations = 0;
119
+ let checked = 0;
120
+
121
+ for (const claim of claims) {
122
+ if (claim.kind === 'method') {
123
+ console.log(`[method, no ceiling] ${claim.sectionId}/${claim.claimId}: "${claim.text}"`);
124
+ continue;
125
+ }
126
+ // kind === 'built'
127
+ if (!claim.featureRef) {
128
+ console.error(`[VIOLATION] ${claim.sectionId}/${claim.claimId}: kind=built with no featureRef (schema should have rejected this)`);
129
+ violations++;
130
+ continue;
131
+ }
132
+ checked++;
133
+ let realStatus;
134
+ try {
135
+ realStatus = await resolveFeatureStatus(claim.featureRef);
136
+ } catch (err) {
137
+ console.error(`[VIOLATION] ${claim.sectionId}/${claim.claimId}: ${err.message}`);
138
+ violations++;
139
+ continue;
140
+ }
141
+ if (claim.sourcedStatus == null) {
142
+ console.log(`[built, no sourcedStatus ceiling] ${claim.sectionId}/${claim.claimId}: featureRef resolved, real status = ${realStatus}`);
143
+ continue;
144
+ }
145
+ if (ladderIndex(claim.sourcedStatus) > ladderIndex(realStatus)) {
146
+ console.error(
147
+ `[VIOLATION] ${claim.sectionId}/${claim.claimId}: claims sourcedStatus="${claim.sourcedStatus}" but real feature status is "${realStatus}" (${claim.featureRef})`
148
+ );
149
+ violations++;
150
+ } else {
151
+ console.log(`[ok] ${claim.sectionId}/${claim.claimId}: sourcedStatus="${claim.sourcedStatus}" <= real "${realStatus}"`);
152
+ }
153
+ }
154
+
155
+ console.log(`\nluhtech-page-claims: ${claims.length} claim(s), ${checked} built-claim(s) resolved, ${violations} violation(s).`);
156
+ if (violations > 0) process.exit(1);
157
+ }
158
+
159
+ main().catch((err) => {
160
+ console.error(`luhtech-page-claims failed: ${err.message}`);
161
+ process.exit(1);
162
+ });
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RULE-CONTENT-PAGE-LEXICON-PROHIBITED-1: a page's text-bearing fields must
4
+ * not contain any term from its own brand's voice.lexicon.prohibited[] or
5
+ * from luhtech-business's (the common portfolio-wide list is already merged
6
+ * into every venture's own list by convention, but this checks both
7
+ * explicitly rather than assuming that merge always holds).
8
+ *
9
+ * Whole-word, case-insensitive match, Markdown syntax stripped from the
10
+ * text before matching (so *emphasis* or [links](url) don't themselves
11
+ * trip a match on their own punctuation). crossLinks[].relationshipLine is
12
+ * exempt -- it is the one schema-legal place a sibling brand name may
13
+ * appear (RULE-CONTENT-PAGE-LEXICON-PROHIBITED-1's own carve-out).
14
+ *
15
+ * Usage: luhtech-page-lexicon <path-to-page.json> <path-to-brand-identity.json> [path-to-luhtech-business-brand-identity.json]
16
+ * Exit 0: clean. Exit 1: any prohibited term found, reported per field.
17
+ */
18
+ import { readFileSync } from 'node:fs';
19
+
20
+ export function stripMarkdown(text) {
21
+ return text
22
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // [label](url) -> label
23
+ .replace(/[*_`]+/g, ''); // bold/italic/code markers
24
+ }
25
+
26
+ function escapeRegExp(s) {
27
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
28
+ }
29
+
30
+ export function findViolations(text, terms) {
31
+ const stripped = stripMarkdown(text);
32
+ const hits = [];
33
+ for (const term of terms) {
34
+ // Whole-word: term may itself contain spaces (multi-word phrases like
35
+ // "forks Ectropy"), so \b only anchors the first/last word, not each
36
+ // internal boundary -- correct for phrase matching.
37
+ const re = new RegExp(`\\b${escapeRegExp(term)}\\b`, 'i');
38
+ if (re.test(stripped)) hits.push(term);
39
+ }
40
+ return hits;
41
+ }
42
+
43
+ export function collectTextFields(page) {
44
+ const fields = [];
45
+ if (page.seo?.title) fields.push({ path: 'seo.title', text: page.seo.title });
46
+ if (page.seo?.description) fields.push({ path: 'seo.description', text: page.seo.description });
47
+ for (const section of page.sections ?? []) {
48
+ const base = `sections[${section.sectionId}]`;
49
+ if (section.eyebrow) fields.push({ path: `${base}.eyebrow`, text: section.eyebrow });
50
+ if (section.heading) fields.push({ path: `${base}.heading`, text: section.heading });
51
+ if (section.subheading) fields.push({ path: `${base}.subheading`, text: section.subheading });
52
+ for (const [i, block] of (section.blocks ?? []).entries()) {
53
+ fields.push({ path: `${base}.blocks[${i}].text`, text: block.text });
54
+ if (block.label) fields.push({ path: `${base}.blocks[${i}].label`, text: block.label });
55
+ }
56
+ for (const [i, cta] of (section.ctas ?? []).entries()) {
57
+ fields.push({ path: `${base}.ctas[${i}].label`, text: cta.label });
58
+ }
59
+ for (const [i, claim] of (section.claims ?? []).entries()) {
60
+ fields.push({ path: `${base}.claims[${i}].text`, text: claim.text });
61
+ }
62
+ // crossLinks[].relationshipLine is deliberately NOT included -- exempt
63
+ // per RULE-CONTENT-PAGE-LEXICON-PROHIBITED-1's own carve-out.
64
+ }
65
+ return fields;
66
+ }
67
+
68
+ /**
69
+ * Merges a brand's own prohibited list with luhtech-business's, then drops
70
+ * the current brand's own name/id from the result -- LuhTech-Business's
71
+ * list legitimately names every OTHER venture as a sibling, including,
72
+ * from its perspective, this page's own venture. A page obviously mentions
73
+ * its own name constantly (seo.title alone guarantees it); that must never
74
+ * be a violation regardless of which source list it came from.
75
+ */
76
+ export function buildProhibitedTerms(brand, luhtechBrand) {
77
+ const terms = new Set([
78
+ ...(brand.voice?.lexicon?.prohibited ?? []),
79
+ ...(luhtechBrand?.voice?.lexicon?.prohibited ?? []),
80
+ ]);
81
+ const ownNames = [brand.brandId, brand.identity?.name].filter(Boolean);
82
+ for (const own of ownNames) {
83
+ for (const t of [...terms]) {
84
+ if (t.toLowerCase() === own.toLowerCase()) terms.delete(t);
85
+ }
86
+ }
87
+ return terms;
88
+ }
89
+
90
+ function main() {
91
+ const [, , pagePath, brandPath, luhtechBrandPath] = process.argv;
92
+ if (!pagePath || !brandPath) {
93
+ console.error('Usage: luhtech-page-lexicon <path-to-page.json> <path-to-brand-identity.json> [path-to-luhtech-business-brand-identity.json]');
94
+ process.exit(1);
95
+ }
96
+
97
+ const page = JSON.parse(readFileSync(pagePath, 'utf-8'));
98
+ const brand = JSON.parse(readFileSync(brandPath, 'utf-8'));
99
+ const luhtechBrand = luhtechBrandPath ? JSON.parse(readFileSync(luhtechBrandPath, 'utf-8')) : null;
100
+
101
+ const terms = buildProhibitedTerms(brand, luhtechBrand);
102
+
103
+ if (terms.size === 0) {
104
+ console.log('luhtech-page-lexicon: no prohibited terms found on the brand instance(s) -- nothing to check (voice not yet authored?).');
105
+ return;
106
+ }
107
+
108
+ const fields = collectTextFields(page);
109
+ let violationCount = 0;
110
+
111
+ for (const field of fields) {
112
+ const hits = findViolations(field.text, terms);
113
+ if (hits.length > 0) {
114
+ violationCount += hits.length;
115
+ console.error(`[VIOLATION] ${field.path}: contains prohibited term(s) [${hits.join(', ')}] -- "${field.text}"`);
116
+ }
117
+ }
118
+
119
+ console.log(`\nluhtech-page-lexicon: ${fields.length} field(s) checked against ${terms.size} prohibited term(s), ${violationCount} violation(s).`);
120
+ if (violationCount > 0) process.exit(1);
121
+ }
122
+
123
+ // Only run as a CLI when invoked directly (not when imported for tests).
124
+ if (import.meta.url === `file://${process.argv[1]}`) {
125
+ main();
126
+ }