monoforge 0.0.0-stage → 1.0.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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -2
  3. package/bin/forge.mjs +98 -0
  4. package/package.json +56 -4
  5. package/packs/README.md +62 -0
  6. package/packs/public/forge-shapes/index.mjs +161 -0
  7. package/packs/public/forge-shapes/pack.json +13 -0
  8. package/packs/public/forge-shapes/test/fixtures/bad-publish/.github/workflows/publish.yml +11 -0
  9. package/packs/public/forge-shapes/test/fixtures/bad-publish/.monoforge-stamp.json +12 -0
  10. package/packs/public/forge-shapes/test/fixtures/bad-publish/README.md +3 -0
  11. package/packs/public/forge-shapes/test/fixtures/bad-publish/bin/probe.mjs +2 -0
  12. package/packs/public/forge-shapes/test/fixtures/bad-publish/package.json +14 -0
  13. package/packs/public/forge-shapes/test/fixtures/clean/.github/workflows/publish.yml +12 -0
  14. package/packs/public/forge-shapes/test/fixtures/clean/.monoforge-stamp.json +12 -0
  15. package/packs/public/forge-shapes/test/fixtures/clean/README.md +3 -0
  16. package/packs/public/forge-shapes/test/fixtures/clean/bin/probe.mjs +2 -0
  17. package/packs/public/forge-shapes/test/fixtures/clean/package.json +14 -0
  18. package/packs/public/forge-shapes/test/fixtures/missing-file/.github/workflows/publish.yml +12 -0
  19. package/packs/public/forge-shapes/test/fixtures/missing-file/.monoforge-stamp.json +13 -0
  20. package/packs/public/forge-shapes/test/fixtures/missing-file/README.md +3 -0
  21. package/packs/public/forge-shapes/test/fixtures/missing-file/bin/probe.mjs +2 -0
  22. package/packs/public/forge-shapes/test/fixtures/missing-file/package.json +14 -0
  23. package/packs/public/forge-shapes/test/fixtures/token/.github/workflows/publish.yml +12 -0
  24. package/packs/public/forge-shapes/test/fixtures/token/.monoforge-stamp.json +12 -0
  25. package/packs/public/forge-shapes/test/fixtures/token/README.md +3 -0
  26. package/packs/public/forge-shapes/test/fixtures/token/bin/probe.mjs +2 -0
  27. package/packs/public/forge-shapes/test/fixtures/token/package.json +14 -0
  28. package/packs/public/forge-shapes/test/fixtures/unfilled/.github/workflows/publish.yml +12 -0
  29. package/packs/public/forge-shapes/test/fixtures/unfilled/.monoforge-stamp.json +12 -0
  30. package/packs/public/forge-shapes/test/fixtures/unfilled/README.md +3 -0
  31. package/packs/public/forge-shapes/test/fixtures/unfilled/bin/probe.mjs +2 -0
  32. package/packs/public/forge-shapes/test/fixtures/unfilled/package.json +14 -0
  33. package/packs/public/forge-shapes/test/run.mjs +67 -0
  34. package/spec/refusals.json +35 -0
  35. package/src/cut.mjs +244 -0
  36. package/src/doctor.mjs +253 -0
  37. package/src/fs-adapter.mjs +143 -0
  38. package/src/fs-node.mjs +15 -0
  39. package/src/harness.mjs +118 -0
  40. package/src/index.mjs +19 -0
  41. package/src/lint-packs.mjs +77 -0
  42. package/src/lock.mjs +37 -0
  43. package/src/packs.mjs +200 -0
  44. package/src/paths.mjs +48 -0
  45. package/src/refusals.mjs +45 -0
  46. package/src/sha256.mjs +61 -0
  47. package/src/stamp.mjs +215 -0
  48. package/src/templates.mjs +147 -0
  49. package/src/workers.mjs +16 -0
  50. package/templates/monoforge/AGENTS.md +30 -0
  51. package/templates/monoforge/CHANGELOG.md +19 -0
  52. package/templates/monoforge/DEPLOY.md +53 -0
  53. package/templates/monoforge/LICENSE +21 -0
  54. package/templates/monoforge/README.md +16 -0
  55. package/templates/monoforge/TEMPLATE.md +19 -0
  56. package/templates/monoforge/docs/Gemfile +5 -0
  57. package/templates/monoforge/docs/_config.yml +36 -0
  58. package/templates/monoforge/docs/_layouts/default.html +29 -0
  59. package/templates/monoforge/docs/assets/css/style.css +14 -0
  60. package/templates/monoforge/docs/freestruct.config.yml +7 -0
  61. package/templates/monoforge/docs/index.md +27 -0
  62. package/templates/monoforge/docs/search.md +28 -0
  63. package/templates/monoforge/functions/api/health.js +10 -0
  64. package/templates/monoforge/gitignore.tmpl +9 -0
  65. package/templates/monoforge/horcrux/HORCRUX.md +7 -0
  66. package/templates/monoforge/labs/.eyes/ledger.json +1 -0
  67. package/templates/monoforge/labs/.eyes/manifest.yml +5 -0
  68. package/templates/monoforge/labs/TASKS.md +11 -0
  69. package/templates/monoforge/scripts/build-docs.sh +12 -0
  70. package/templates/monoforge/scripts/check-docs-frontmatter.cjs +112 -0
  71. package/templates/monoforge/scripts/check-docs-links.cjs +81 -0
  72. package/templates/monoforge/scripts/check-docs-style.cjs +79 -0
  73. package/templates/monoforge/scripts/check-fiction-signatures.cjs +69 -0
  74. package/templates/monoforge/scripts/check-jekyll-filters.cjs +62 -0
  75. package/templates/monoforge/scripts/check-language.cjs +171 -0
  76. package/templates/monoforge/site/robots.txt +4 -0
  77. package/templates/monoforge/wrangler.toml +11 -0
  78. package/templates/monoforge-headless/.github/workflows/docs.yml +102 -0
  79. package/templates/monoforge-headless/.github/workflows/publish.yml +141 -0
  80. package/templates/monoforge-headless/.github/workflows/staging-ff-sync.yml +44 -0
  81. package/templates/monoforge-headless/.github/workflows/test.yml +21 -0
  82. package/templates/monoforge-headless/TEMPLATE.md +17 -0
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Docs frontmatter gate (pass 153).
4
+ *
5
+ * docs/advanced/style.md requires every page to carry all 5 frontmatter
6
+ * fields (version, permalink, layout, title, nav_order) -- but until now
7
+ * NOTHING enforced it, and pass 151 found 2 of 118 pages missing
8
+ * `layout:` with a real consequence: docs/_config.yml has no `defaults`
9
+ * block, so Jekyll renders a layout-less page as raw HTML with no site
10
+ * chrome. Silent breakage, invisible to every regex gate until now.
11
+ *
12
+ * Checks every markdown page under docs/:
13
+ * - all 5 style.md-required fields present and non-empty
14
+ * - permalink is absolute-ish (starts with /) -- the site links by it
15
+ * - nav_order is an integer
16
+ * - every field value is a VALID YAML scalar. A regex scan for `key: value`
17
+ * says nothing about whether YAML parses: an unquoted value carrying a
18
+ * colon-space (`description: slots: generated by the factory`) is a YAML
19
+ * error, and Jekyll then drops the WHOLE frontmatter block -- no layout,
20
+ * no head injection, a page that renders without its own chrome. That bug
21
+ * bit monoforge's docs/index.md and shipped green (rule #3: caught twice,
22
+ * it becomes a gate). Dependency-free on purpose: a stamped repo has no
23
+ * install step for this gate to lean on.
24
+ *
25
+ * NOTE: the version field is PRESENCE-only. style.md defines it as
26
+ * "version introduced", which legitimately differs from package.json
27
+ * (e.g. "0.8.5" pages on a 0.8.6 package); equality would be a false
28
+ * positive. Drift of the *current* version is caught in judgment reads.
29
+ *
30
+ * Exit 1 on any violation, evidence inline.
31
+ */
32
+ const fs = require('fs');
33
+ const path = require('path');
34
+
35
+ // --root <dir> checks a tree other than this one (tests + adopters),
36
+ // the family gate convention (flowforge lib/root.cjs).
37
+ const rootArg = process.argv.indexOf('--root');
38
+ const ROOT = rootArg !== -1 ? path.resolve(process.argv[rootArg + 1]) : path.resolve(__dirname, '..');
39
+ const DOCS = path.join(ROOT, 'docs');
40
+
41
+ const REQUIRED = ['version', 'permalink', 'layout', 'title', 'nav_order'];
42
+
43
+ const problems = [];
44
+ let pages = 0;
45
+
46
+ // Is a frontmatter scalar valid plain YAML (the subset Jekyll's frontmatter
47
+ // parser accepts for these fields)? Quoted and block scalars are always
48
+ // fine; an unquoted scalar must not open a nested mapping (`: `), start a
49
+ // comment (` #`), or begin with an indicator that changes its type. This is
50
+ // the dependency-free stand-in for a YAML parse -- enough to catch the exact
51
+ // class that shipped: an unquoted value carrying a colon-space.
52
+ function scalarProblem(raw) {
53
+ const v = raw.trim();
54
+ if (!v) return 'is empty';
55
+ const q = v[0];
56
+ if (q === '"' || q === "'") {
57
+ if (v.length < 2 || v[v.length - 1] !== q) return 'has an unterminated quote';
58
+ return null;
59
+ }
60
+ if (/^[|>]/.test(v)) return null; // block scalar
61
+ if (/:\s/.test(v)) return 'is unquoted and contains a colon-space, which YAML reads as a nested mapping (quote it, or fold the value)';
62
+ if (/\s#/.test(v)) return 'is unquoted and contains " #", which YAML reads as a comment (quote it)';
63
+ if (/^[&*?,[\]{}%!@`>|]/.test(v)) return `starts with a YAML indicator (${v[0]}); quote it`;
64
+ return null;
65
+ }
66
+ (function walk(d) {
67
+ for (const f of fs.readdirSync(d, { withFileTypes: true })) {
68
+ const p = d + '/' + f.name;
69
+ if (f.isDirectory() && f.name !== '_data' && f.name !== '_layouts' && f.name !== '_plugins') walk(p);
70
+ else if (f.name.endsWith('.md')) {
71
+ pages++;
72
+ const rel = path.relative(ROOT, p);
73
+ const text = fs.readFileSync(p, 'utf8');
74
+ const fm = text.match(/^---\n([\s\S]*?)\n---/);
75
+ if (!fm) { problems.push(`${rel}: no frontmatter block`); continue; }
76
+ const block = fm[1];
77
+ for (const field of REQUIRED) {
78
+ const m = block.match(new RegExp(`^${field}:\\s*(.*\\S)`, 'm'));
79
+ if (!m) { problems.push(`${rel}: missing frontmatter field "${field}"`); continue; }
80
+ const val = m[1].trim();
81
+ if (!val || val === '""' || val === "''") {
82
+ problems.push(`${rel}: frontmatter field "${field}" is empty`);
83
+ continue;
84
+ }
85
+ if (field === 'permalink' && !val.startsWith('/')) {
86
+ problems.push(`${rel}: permalink "${val}" should start with / (site links by it)`);
87
+ }
88
+ if (field === 'nav_order' && !/^-?\d+$/.test(val)) {
89
+ problems.push(`${rel}: nav_order "${val}" is not an integer`);
90
+ }
91
+ }
92
+ // Scalar validity across EVERY top-level field, not only the
93
+ // required ones: monoforge's bug landed in `description`, which a
94
+ // variant gate that did not require it would have scanned past.
95
+ // Required-ness must not gate this check.
96
+ for (const line of block.split('\n')) {
97
+ if (/^\s/.test(line)) continue; // nested value or continuation
98
+ const mm = line.match(/^([A-Za-z_][\w-]*):\s*(.*\S)\s*$/);
99
+ if (!mm) continue;
100
+ const err = scalarProblem(mm[2]);
101
+ if (err) problems.push(`${rel}: frontmatter field "${mm[1]}" ${err}`);
102
+ }
103
+ }
104
+ }
105
+ })(DOCS);
106
+
107
+ if (problems.length) {
108
+ console.error(`FRONTMATTER: FAIL (${problems.length} issue${problems.length === 1 ? '' : 's'} in ${pages} pages)`);
109
+ for (const p of problems) console.error(' ' + p);
110
+ process.exit(1);
111
+ }
112
+ console.log(`FRONTMATTER: PASS (${pages} pages, all ${REQUIRED.length} fields + format checks)`);
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Docs link checker (ported from dhaupin/vant scripts/check-docs-links.js).
4
+ * Validates every markdown link in docs/:
5
+ * - /prestruct/<permalink> links must match a real frontmatter permalink
6
+ * - other absolute links must match a permalink or resolve under docs/
7
+ * - relative links must resolve on disk
8
+ * Skips code fences, inline code, external URLs, and pure anchors.
9
+ * Exit 1 on any broken link.
10
+ */
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+ const DOCS = path.resolve(__dirname, '..', 'docs');
14
+
15
+ // normalize: leading slash, no trailing slash ('' -> '/')
16
+ const norm = (s) => {
17
+ s = '/' + String(s).replace(/^\/+|\/+$/g, '');
18
+ return s === '/' ? '/' : s;
19
+ };
20
+
21
+ const files = [];
22
+ (function walk(d) {
23
+ for (const f of fs.readdirSync(d, { withFileTypes: true })) {
24
+ const p = d + '/' + f.name;
25
+ if (f.isDirectory() && f.name !== '_data' && f.name !== '_layouts' && f.name !== '_plugins') walk(p);
26
+ else if (f.name.endsWith('.md')) files.push(p);
27
+ }
28
+ })(DOCS);
29
+
30
+ const perm = new Set();
31
+ for (const f of files) {
32
+ const t = fs.readFileSync(f, 'utf8');
33
+ const m = t.match(/^permalink: (\S+)/m);
34
+ if (m) perm.add(norm(m[1]));
35
+ }
36
+
37
+ let broken = 0;
38
+ for (const f of files) {
39
+ const lines = fs.readFileSync(f, 'utf8').split('\n');
40
+ let inFence = false;
41
+ for (const line of lines) {
42
+ if (/^\s*```/.test(line)) { inFence = !inFence; continue; }
43
+ if (inFence) continue;
44
+ const parts = line.split('`');
45
+ for (let s = 0; s < parts.length; s += 2) { // outside inline code only
46
+ for (const m of parts[s].matchAll(/\]\(([^)\s]+)\)/g)) {
47
+ let u = m[1];
48
+ if (/^(https?:|mailto:)/.test(u)) continue;
49
+ const anchor = u.includes('#') ? u.slice(u.indexOf('#')) : '';
50
+ u = anchor ? u.slice(0, u.length - anchor.length) : u;
51
+ if (!u) continue; // pure anchor
52
+ const rel = f.replace(DOCS + '/', '');
53
+ if (u.startsWith('/prestruct/') || u === '/prestruct') {
54
+ const key = norm(u.replace(/^\/prestruct\/?/, ''));
55
+ if (!perm.has(key)) {
56
+ console.log('BROKEN (bad /prestruct/ permalink) in', rel, '->', m[1]);
57
+ broken++;
58
+ }
59
+ continue;
60
+ }
61
+ if (u.startsWith('/')) {
62
+ const key = norm(u);
63
+ if (!perm.has(key) && !fs.existsSync(path.join(DOCS, u))) {
64
+ console.log('BROKEN (abs) in', rel, '->', m[1]);
65
+ broken++;
66
+ }
67
+ continue;
68
+ }
69
+ const p = path.resolve(path.dirname(f), u.replace(/\.md$/, ''));
70
+ if (fs.existsSync(p + '.md') || fs.existsSync(path.join(p, 'index.md')) || fs.existsSync(p)) continue;
71
+ console.log('BROKEN (rel) in', rel, '->', m[1]);
72
+ broken++;
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ console.log(broken === 0
79
+ ? 'DOCS LINKS: PASS (' + files.length + ' files)'
80
+ : 'DOCS LINKS: FAIL (' + broken + ' broken)');
81
+ process.exit(broken === 0 ? 0 : 1);
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Docs style linter for the QC pass. Checks every docs/*.md file:
4
+ * - every opening code fence carries a language tag (closing fences exempt)
5
+ * - no heading level skips (h1 -> h3)
6
+ * - no trailing whitespace
7
+ * - no tabs in prose (frontmatter/markdown)
8
+ * - no em/en dashes in prose (voice rule; use hyphen). CHANGELOG exempt.
9
+ * - no emoji/dingbat glyphs in prose. CHANGELOG exempt.
10
+ * - pipe-table shape: lines starting with | must end with |; no pipes
11
+ * in headings; no bullets ending with | (broken-table residue)
12
+ * Exit 1 on findings.
13
+ */
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+ const DOCS = path.resolve(__dirname, '..', 'docs');
17
+
18
+ // Voice-rule exempt file: historical changelog entries keep their punctuation.
19
+ const VOICE_EXEMPT = /CHANGELOG\.md$/;
20
+
21
+ const files = [];
22
+ (function walk(d) {
23
+ for (const f of fs.readdirSync(d, { withFileTypes: true })) {
24
+ const p = d + '/' + f.name;
25
+ if (f.isDirectory() && f.name !== '_data' && f.name !== '_layouts' && f.name !== '_plugins') walk(p);
26
+ else if (f.name.endsWith('.md')) files.push(p);
27
+ }
28
+ })(DOCS);
29
+
30
+ let issues = 0;
31
+ for (const f of files) {
32
+ const rel = f.replace(DOCS + '/', '');
33
+ const lines = fs.readFileSync(f, 'utf8').split('\n');
34
+ let inFence = false;
35
+ let lastHeading = 0;
36
+ for (let i = 0; i < lines.length; i++) {
37
+ const line = lines[i];
38
+ const n = i + 1;
39
+ if (/^\s*```/.test(line)) {
40
+ if (!inFence && /^```\s*$/.test(line)) {
41
+ console.log(`${rel}:${n} opening fence missing language tag`);
42
+ issues++;
43
+ }
44
+ inFence = !inFence;
45
+ continue;
46
+ }
47
+ if (inFence) continue;
48
+ if (/[ \t]+$/.test(line)) { console.log(`${rel}:${n} trailing whitespace`); issues++; }
49
+ if (/\t/.test(line)) { console.log(`${rel}:${n} tab character`); issues++; }
50
+ if (!VOICE_EXEMPT.test(rel)) {
51
+ if (/[\u2013\u2014]/.test(line)) { console.log(`${rel}:${n} em/en dash (use hyphen)`); issues++; }
52
+ // Arrows, dingbats, emoji blocks, variation selectors. Math symbols
53
+ // (U+2200-22FF) are allowed: >= and infinity are technical notation.
54
+ // Glyphs inside inline-code spans are literal data values (e.g. theme
55
+ // icon tables), not prose decoration, so strip spans before checking.
56
+ const prose = line.replace(/`[^`]*`/g, '');
57
+ if (/[\u2190-\u21FF\u2300-\u23FF\u25A0-\u25FF\u2600-\u27BF\uFE0F]|\uD83C[\uDF00-\uDFFF]|\uD83E[\uDD00-\uDDFF]/.test(prose)) { console.log(`${rel}:${n} emoji/glyph in prose`); issues++; }
58
+ }
59
+ // Broken pipe-table residue (earlier automated pass exploded rows):
60
+ // "| a" newline "- b |" pattern and headings that swallowed cells.
61
+ if (/^\|.*[^|\s]\s*$/.test(line) && !/^\|[\s|:-]*$/.test(line)) { console.log(`${rel}:${n} pipe line does not end with | (broken table)`); issues++; }
62
+ if (/^- .*\|\s*$/.test(line)) { console.log(`${rel}:${n} bullet ends with | (broken table)`); issues++; }
63
+ if (/^#{1,6}\s.*\|/.test(line)) { console.log(`${rel}:${n} pipe character in heading (broken table)`); issues++; }
64
+ const h = line.match(/^(#{1,6})\s/);
65
+ if (h) {
66
+ const level = h[1].length;
67
+ if (lastHeading && level > lastHeading + 1) {
68
+ console.log(`${rel}:${n} heading skips h${lastHeading} to h${level}`);
69
+ issues++;
70
+ }
71
+ lastHeading = level;
72
+ }
73
+ }
74
+ }
75
+
76
+ console.log(issues === 0
77
+ ? 'DOCS STYLE: PASS (' + files.length + ' files)'
78
+ : 'DOCS STYLE: FAIL (' + issues + ' issues)');
79
+ process.exit(issues === 0 ? 0 : 1);
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Fiction-signature gate - the flowforge shell edition (same scanner logic
4
+ * the struct-family repos run; the seed signatures below are GENERIC, and
5
+ * the shell house law is:
6
+ *
7
+ * seed your own signatures the moment a fiction is caught twice;
8
+ * anything caught twice becomes a gate, not a memory.
9
+ *
10
+ * A signature is [regex, human explanation]. Exit 1 on any hit outside the
11
+ * allow-list (a debunking line counts - NEGATION below).
12
+ */
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const ROOT = path.resolve(__dirname, '..');
16
+ // signature: [regex, human explanation] -- GENERIC seeds; replace/add yours
17
+ const SIGNATURES = [
18
+ [/(artificial\s+)?intelligence\s+(will|is\s+going\s+to)\s+(change|revolution)/i,
19
+ 'hype claim - describe what the product DOES, not what it would do someday'],
20
+ [/fastest|blazingly|lightning[- ]fast[^.]{0,40}(fastest|ever|world)/i,
21
+ 'superlative performance claims need a receipt (benchmark, file:line) or they are fiction'],
22
+ [/100%\s+(secure|safe|guaranteed)|unhackable/i,
23
+ 'absolute security claims are fiction on any surface'],
24
+ [/(enterprise[- ]grade|world[- ]class|cutting[- ]edge)\b/i,
25
+ 'banned hype vocabulary (house style: plain verbs, shown not told)'],
26
+ ];
27
+ // a line that admits the fiction (docs explaining the rule) is not a hit
28
+ const NEGATION = /do not|never|must not|fiction|example|placeholder|e\.g\.|rule/;
29
+ // text extensions + allow-list
30
+ const TEXT_EXT = new Set(['.md', '.txt', '.html', '.js', '.mjs', '.cjs', '.yml', '.css']);
31
+ const ALLOW = new Set(['scripts/check-fiction-signatures.cjs', 'scripts/check-docs-style.cjs', 'templates/monoforge/scripts/check-fiction-signatures.cjs', 'templates/monoforge/scripts/check-docs-style.cjs']);
32
+ const hits = [];
33
+ let scanned = 0;
34
+
35
+ (function walk(dir, relRoot) {
36
+ for (const f of fs.readdirSync(dir, { withFileTypes: true })) {
37
+ const rel = path.join(relRoot, f.name);
38
+ const p = path.join(dir, f.name);
39
+ if (f.isDirectory()) {
40
+ if (['node_modules', '_site', '.git', 'dist'].includes(f.name)) continue;
41
+ walk(p, rel);
42
+ continue;
43
+ }
44
+ if (ALLOW.has(rel)) continue;
45
+ if (!TEXT_EXT.has(path.extname(f.name))) continue;
46
+ let text;
47
+ try { text = fs.readFileSync(p, 'utf8'); } catch (e) { continue; }
48
+ scanned++;
49
+ const lines = text.split('\n');
50
+ for (const [re, why] of SIGNATURES) {
51
+ let hitLine = -1;
52
+ for (let i = 0; i < lines.length; i++) {
53
+ if (re.test(lines[i])) { hitLine = i; break; }
54
+ }
55
+ if (hitLine === -1) continue;
56
+ const line = lines[hitLine];
57
+ const context = (lines[hitLine - 1] || '') + '\n' + line;
58
+ if (NEGATION.test(context)) continue; // debunk line, not a regression
59
+ hits.push(`${rel}:${hitLine + 1}: "${line.trim().slice(0, 120)}" - ${why}`);
60
+ }
61
+ }
62
+ })(ROOT, '');
63
+ if (hits.length) {
64
+ console.error(`FICTION SIGNATURES: FAIL (${hits.length} hit${hits.length === 1 ? '' : 's'} in ${scanned} files)`);
65
+ for (const h of hits) console.error(' ' + h);
66
+ console.error(' (fix the text, or if the signature is stale, update the signature here AND your house ledger)');
67
+ process.exit(1);
68
+ }
69
+ console.log(`FICTION SIGNATURES: PASS (${scanned} files scanned, ${SIGNATURES.length} signatures)`);
@@ -0,0 +1,62 @@
1
+ // check-jekyll-filters.cjs - the two-argument Liquid filter trap (crashtest#23).
2
+ //
3
+ // Liquid string filters like `remove`, `remove_first`, `append`, `prepend`,
4
+ // `split`, and `join` take exactly ONE argument. A second argument is not a
5
+ // write-time error - it throws "wrong number of arguments (given 3, expected
6
+ // 2)" at BUILD time and kills the whole Jekyll build (found live in
7
+ // packstruct's CI on 2026-10-24: `| remove: '/x', ''` took down the docs
8
+ // deploy). This pass refuses such a call in docs/ source so the failure is
9
+ // named in lint:docs with a file:line, instead of in Jekyll's stack trace.
10
+ //
11
+ // Why not a regex in check-docs-style: that script enforces PROSE rules; this
12
+ // is a structural template check, so it lives in its own pass in the chain.
13
+ // Two-arg filters that are LEGAL in Liquid (replace / split on regex covers
14
+ // one arg only) are simply not in the refuse list.
15
+
16
+ const fs = require('node:fs');
17
+ const path = require('node:path');
18
+
19
+ const ROOT = path.join(__dirname, '..');
20
+ const DOCS = path.join(ROOT, 'docs');
21
+ const SKIP_DIRS = new Set(['_site', 'node_modules', 'vendor', '.bundle', '.jekyll-cache']);
22
+ const EXTS = new Set(['.html', '.md', '.yml', '.txt']);
23
+
24
+ // Single-argument Liquid string filters (a second argument is always a bug).
25
+ const SINGLE_ARG = ['remove_first', 'remove', 'append', 'prepend', 'newline_to_br'];
26
+
27
+ const violations = [];
28
+
29
+ // Root is overridable for testing: `node scripts/check-jekyll-filters.cjs <dir>`.
30
+ // CI/lint:docs call it with no argument and get the repo's docs/.
31
+ const scanRoot = process.argv[2] ? path.resolve(process.argv[2]) : DOCS;
32
+
33
+ function walk(dir) {
34
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
35
+ if (entry.isDirectory()) {
36
+ if (!SKIP_DIRS.has(entry.name)) walk(path.join(dir, entry.name));
37
+ continue;
38
+ }
39
+ if (!EXTS.has(path.extname(entry.name))) continue;
40
+ const file = path.relative(scanRoot, path.join(dir, entry.name));
41
+ const lines = fs.readFileSync(path.join(dir, entry.name), 'utf8').split('\n');
42
+ lines.forEach((line, i) => {
43
+ for (const filter of SINGLE_ARG) {
44
+ // {{ x | remove: 'a', '' }} - one quoted arg, a comma, then a second one.
45
+ // (single/single quotes both accepted; the second argument is the crime)
46
+ const re = new RegExp("\\|[ ]*-?[ ]*" + filter + "\\s*:\\s*(?:'([^']*)'|\"([^\"]*)\")\\s*,");
47
+ const m = re.exec(line);
48
+ if (m) violations.push(`${file}:${i + 1} Liquid "${filter}" takes exactly one argument (the two-arg form kills the Jekyll build - crashtest#23): \`${line.trim()}\``);
49
+ }
50
+ });
51
+ }
52
+ }
53
+
54
+ if (!fs.existsSync(scanRoot)) process.exit(0);
55
+ walk(scanRoot);
56
+
57
+ if (violations.length > 0) {
58
+ console.error(`JEKYLL FILTERS: FAIL (${violations.length} two-argument single-arg filter call(s))`);
59
+ for (const v of violations) console.error(' ' + v);
60
+ process.exit(1);
61
+ }
62
+ console.log('JEKYLL FILTERS: PASS (single-arg string filters only)');
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Language gate (issue #184): contributor-facing prose is English-only.
4
+ *
5
+ * Why: two org agents drifted into Chinese mid-session on 2026-10-11 from
6
+ * an English conversation; committed artifacts can drift the same way via
7
+ * scripted agents. Committed prose a HUMAN reads must be readable by every
8
+ * nationality -- English is what the OSS landscape runs on.
9
+ *
10
+ * Contract (distilled from the gistory reference implementation):
11
+ * 1. SCAN SCOPE: committed files a human reads as prose - docs/, labs/,
12
+ * any markdown under .github/ (workflows, any depth) plus the root
13
+ * meta set: every root-level README / AGENTS / CHANGELOG /
14
+ * CONTRIBUTING / LEGAL / DEPLOY / ROADMAP / SECURITY /
15
+ * CODE_OF_CONDUCT markdown file.
16
+ * Code comments are OUT of scope (PR-review matter, false-positives on
17
+ * identifiers/library names).
18
+ * 2. DETECTION = Unicode script-block longest run, not a word blocklist.
19
+ * For each Han/Hiragana/Katakana/Hangul/Cyrillic/Arabic/Hebrew/
20
+ * Devanagari/Thai/Greek block, compute the longest contiguous run per
21
+ * line; flag when a run is >= MIN_RUN (2 can be a transliterated name;
22
+ * 3 reads as writing). Threshold + block list are DATA at the top --
23
+ * tuned in <30 lines.
24
+ * 3. ALLOWLIST BY CONSTRUCTION, not intervention: URL-bearing lines,
25
+ * import/export/require lines, base64-ish blobs, and the
26
+ * LINT_LANGUAGE_ALLOW_RE env regex so intentional bilingual docs opt
27
+ * out WITHOUT editing the checker.
28
+ * 4. FAILURE CONTRACT: exit 1 with `path:line <script-block-name> (N chars):
29
+ * <trimmed line>`; PASS prints
30
+ * `LANGUAGE GATE: PASS (English-only) -- N prose files scanned`.
31
+ *
32
+ * Inside fenced code blocks and inline-code spans are literal DATA, not
33
+ * prose -- exempt (same posture as check-docs-style.js).
34
+ */
35
+ const fs = require('fs');
36
+ const path = require('path');
37
+
38
+ const ROOT = path.resolve(__dirname, '..');
39
+
40
+ // ---- DATA: tune here -------------------------------------------------
41
+ const MIN_RUN = 3;
42
+ const SCAN_DIRS = ['docs', 'labs']; // prose trees
43
+ const SCAN_GLOBS_DIR = '.github'; // workflows' *.md
44
+ const SCAN_ROOT_META =
45
+ /^(README|AGENTS|CHANGELOG|CONTRIBUTING|LEGAL|DEPLOY|ROADMAP|SECURITY|CODE_OF_CONDUCT).*\.md$/;
46
+
47
+ // Non-Latin script blocks. Each is (testFn, name). Longest-run per line.
48
+ // Han covers CJK ideographs; Hiragana/Katakana separate (Japanese kana
49
+ // mixed with Han is caught by either).
50
+ const SCRIPT_BLOCKS = [
51
+ [/\p{Script=Han}[\p{Script=Han}]/u, 'Han'],
52
+ [/\p{Script=Hiragana}/u, 'Hiragana'],
53
+ [/\p{Script=Katakana}/u, 'Katakana'],
54
+ [/\p{Script=Hangul}/u, 'Hangul'],
55
+ [/\p{Script=Cyrillic}/u, 'Cyrillic'],
56
+ [/\p{Script=Arabic}/u, 'Arabic'],
57
+ [/\p{Script=Hebrew}/u, 'Hebrew'],
58
+ [/\p{Script=Devanagari}/u, 'Devanagari'],
59
+ [/\p{Script=Thai}/u, 'Thai'],
60
+ [/\p{Script=Greek}[\p{Script=Greek}]/u, 'Greek'],
61
+ ];
62
+ // Extend beyond the core list with a data-driven pass: longest run of
63
+ // consecutive code points of the same script.
64
+ function longestRun(line, scriptName, re) {
65
+ // Single pass over the line collecting runs from the regex's same-script class.
66
+ let max = 0;
67
+ let cur = 0;
68
+ for (const ch of line) {
69
+ if (ch.trim() === '') { cur = 0; continue; }
70
+ if (re.test(ch)) { cur++; if (cur > max) max = cur; }
71
+ else cur = 0;
72
+ }
73
+ return { name: scriptName, run: max };
74
+ }
75
+
76
+ // The per-script run function is per-character-class; build a char-level
77
+ // matcher from each block's regex via the string-prototype.
78
+ const CHAR_TESTS = {
79
+ Han: (c) => /\p{Script=Han}/u.test(c),
80
+ Hiragana: (c) => /\p{Script=Hiragana}/u.test(c),
81
+ Katakana: (c) => /\p{Script=Katakana}/u.test(c),
82
+ Hangul: (c) => /\p{Script=Hangul}/u.test(c),
83
+ Cyrillic: (c) => /\p{Script=Cyrillic}/u.test(c),
84
+ Arabic: (c) => /\p{Script=Arabic}/u.test(c),
85
+ Hebrew: (c) => /\p{Script=Hebrew}/u.test(c),
86
+ Devanagari: (c) => /\p{Script=Devanagari}/u.test(c),
87
+ Thai: (c) => /\p{Script=Thai}/u.test(c),
88
+ Greek: (c) => /\p{Script=Greek}/u.test(c),
89
+ };
90
+
91
+ /** Longest per-line run per script. Returns [{name, run}]. */
92
+ function findScriptRuns(line) {
93
+ const out = [];
94
+ for (const [name, test] of Object.entries(CHAR_TESTS)) {
95
+ let max = 0, cur = 0;
96
+ for (const ch of line) {
97
+ if (test(ch)) { cur++; if (cur > max) max = cur; }
98
+ else cur = 0;
99
+ }
100
+ if (max > 0) out.push({ name, run: max });
101
+ }
102
+ return out;
103
+ }
104
+
105
+ // ---- Allowlist -------------------------------------------------------
106
+ function isAllowed(line) {
107
+ if (/https?:\/\//.test(line)) return true; // URL-bearing
108
+ if (/^\s*(import|export|require)\b/.test(line)) return true; // code lines
109
+ if (/[A-Za-z0-9+/]{40,}={0,2}/.test(line)) return true; // base64-ish
110
+ const env = process.env.LINT_LANGUAGE_ALLOW_RE;
111
+ if (env) { try { if (new RegExp(env).test(line)) return true; } catch (e) { /* hostile regex -- ignore, keep scanning */ } }
112
+ return false;
113
+ }
114
+
115
+ // ---- Scan ------------------------------------------------------------
116
+ const files = [];
117
+ for (const dir of SCAN_DIRS) {
118
+ const base = path.join(ROOT, dir);
119
+ if (!fs.existsSync(base)) continue;
120
+ (function walk(d) {
121
+ for (const f of fs.readdirSync(d, { withFileTypes: true })) {
122
+ const p = path.join(d, f.name);
123
+ if (f.isDirectory()) walk(p);
124
+ else if (f.name.endsWith('.md')) files.push(p);
125
+ }
126
+ })(base);
127
+ }
128
+ const ghDir = path.join(ROOT, SCAN_GLOBS_DIR);
129
+ if (fs.existsSync(ghDir)) {
130
+ (function walk(d) {
131
+ for (const f of fs.readdirSync(d, { withFileTypes: true })) {
132
+ const p = path.join(d, f.name);
133
+ if (f.isDirectory()) walk(p);
134
+ else if (f.name.endsWith('.md')) files.push(p);
135
+ }
136
+ })(ghDir);
137
+ }
138
+ for (const f of fs.readdirSync(ROOT)) {
139
+ if (fs.statSync(path.join(ROOT, f)).isFile() && SCAN_ROOT_META.test(f)) {
140
+ files.push(path.join(ROOT, f));
141
+ }
142
+ }
143
+ const seen = new Set();
144
+ const unique = files.filter(f => { if (seen.has(f)) return false; seen.add(f); return true; });
145
+
146
+ let issues = 0;
147
+ const findings = [];
148
+ for (const f of unique) {
149
+ const rel = path.relative(ROOT, f);
150
+ const lines = fs.readFileSync(f, 'utf8').split('\n');
151
+ let inFence = false;
152
+ for (let i = 0; i < lines.length; i++) {
153
+ let line = lines[i];
154
+ const n = i + 1;
155
+ if (/^\s*```/.test(line)) { inFence = !inFence; continue; }
156
+ if (inFence) continue;
157
+ line = line.replace(/`[^`]*`/g, ''); // inline-code is data, not prose
158
+ if (isAllowed(line)) continue;
159
+ for (const r of findScriptRuns(line)) {
160
+ if (r.run >= MIN_RUN) {
161
+ findings.push(`${rel}:${n} ${r.name} (${r.run} chars): ${lines[i].trim().slice(0, 100)}`);
162
+ issues++;
163
+ }
164
+ }
165
+ }
166
+ }
167
+ for (const f of findings) console.log(f);
168
+ console.log(issues === 0
169
+ ? `LANGUAGE GATE: PASS (English-only) -- ${unique.length} prose files scanned`
170
+ : `LANGUAGE GATE: FAIL (${issues} findings in ${unique.length} prose files)`);
171
+ process.exit(issues === 0 ? 0 : 1);
@@ -0,0 +1,4 @@
1
+ User-agent: *
2
+ Allow: /
3
+
4
+ Sitemap: __SITE_URL__/sitemap.xml
@@ -0,0 +1,11 @@
1
+ # Cloudflare Pages — __NAME__ landing (__NAME__.creadev.org)
2
+ # Deploy: CF Pages Git integration on this repo, or `npx wrangler pages deploy site`
3
+ name = "__NAME__"
4
+ compatibility_date = "2026-10-23"
5
+ pages_build_output_dir = "site"
6
+
7
+ [vars]
8
+ SITE_NAME = "__NAME__"
9
+
10
+ # Functions live in functions/ (Pages Functions = Workers under the hood).
11
+ # functions/api/health.js is the living proof; add more only when a real need shows.