monoforge 0.0.0-stage → 0.9.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 +21 -0
- package/README.md +72 -2
- package/bin/forge.mjs +65 -0
- package/package.json +49 -4
- package/src/cut.mjs +244 -0
- package/src/doctor.mjs +230 -0
- package/src/index.mjs +4 -0
- package/src/lint-packs.mjs +77 -0
- package/src/lock.mjs +37 -0
- package/src/stamp.mjs +201 -0
- package/src/templates.mjs +133 -0
- package/templates/monoforge/AGENTS.md +30 -0
- package/templates/monoforge/CHANGELOG.md +19 -0
- package/templates/monoforge/DEPLOY.md +53 -0
- package/templates/monoforge/LICENSE +21 -0
- package/templates/monoforge/README.md +16 -0
- package/templates/monoforge/TEMPLATE.md +19 -0
- package/templates/monoforge/docs/Gemfile +5 -0
- package/templates/monoforge/docs/_config.yml +36 -0
- package/templates/monoforge/docs/_layouts/default.html +29 -0
- package/templates/monoforge/docs/assets/css/style.css +14 -0
- package/templates/monoforge/docs/freestruct.config.yml +7 -0
- package/templates/monoforge/docs/index.md +27 -0
- package/templates/monoforge/docs/search.md +28 -0
- package/templates/monoforge/functions/api/health.js +10 -0
- package/templates/monoforge/gitignore.tmpl +9 -0
- package/templates/monoforge/horcrux/HORCRUX.md +7 -0
- package/templates/monoforge/labs/.eyes/ledger.json +1 -0
- package/templates/monoforge/labs/.eyes/manifest.yml +5 -0
- package/templates/monoforge/labs/TASKS.md +11 -0
- package/templates/monoforge/scripts/build-docs.sh +12 -0
- package/templates/monoforge/scripts/check-docs-frontmatter.cjs +112 -0
- package/templates/monoforge/scripts/check-docs-links.cjs +81 -0
- package/templates/monoforge/scripts/check-docs-style.cjs +79 -0
- package/templates/monoforge/scripts/check-fiction-signatures.cjs +69 -0
- package/templates/monoforge/scripts/check-jekyll-filters.cjs +62 -0
- package/templates/monoforge/scripts/check-language.cjs +171 -0
- package/templates/monoforge/site/robots.txt +4 -0
- package/templates/monoforge/wrangler.toml +11 -0
- package/templates/monoforge-headless/.github/workflows/docs.yml +102 -0
- package/templates/monoforge-headless/.github/workflows/publish.yml +141 -0
- package/templates/monoforge-headless/.github/workflows/staging-ff-sync.yml +44 -0
- package/templates/monoforge-headless/.github/workflows/test.yml +21 -0
- package/templates/monoforge-headless/TEMPLATE.md +17 -0
|
@@ -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,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.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
name: docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, staging]
|
|
6
|
+
paths: ['docs/**', 'scripts/**', '.github/workflows/docs.yml']
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
# GitHub Pages deploy permissions (official deploy-pages action)
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
pages: write
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
# Allow only one concurrent deployment
|
|
16
|
+
concurrency:
|
|
17
|
+
group: pages
|
|
18
|
+
cancel-in-progress: false
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
build:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with: { node-version: 20 }
|
|
28
|
+
|
|
29
|
+
# Docs truth gates (ported house checkers): frontmatter 5-field law,
|
|
30
|
+
# resolvable links, style law (no dashes in prose, language-tagged
|
|
31
|
+
# fences, no trailing ws), fiction-signature seeds, the two-argument
|
|
32
|
+
# Liquid filter trap, English-only prose.
|
|
33
|
+
- name: Docs gates
|
|
34
|
+
run: |
|
|
35
|
+
node scripts/check-docs-frontmatter.cjs
|
|
36
|
+
node scripts/check-docs-links.cjs
|
|
37
|
+
node scripts/check-docs-style.cjs
|
|
38
|
+
node scripts/check-fiction-signatures.cjs
|
|
39
|
+
node scripts/check-jekyll-filters.cjs
|
|
40
|
+
node scripts/check-language.cjs
|
|
41
|
+
|
|
42
|
+
- name: Setup Ruby
|
|
43
|
+
uses: ruby/setup-ruby@v1
|
|
44
|
+
with:
|
|
45
|
+
ruby-version: '3.3'
|
|
46
|
+
bundler-cache: true
|
|
47
|
+
cache-version: 1
|
|
48
|
+
|
|
49
|
+
- name: Setup Pages
|
|
50
|
+
id: pages
|
|
51
|
+
uses: actions/configure-pages@v4
|
|
52
|
+
|
|
53
|
+
- name: Install deps
|
|
54
|
+
working-directory: docs
|
|
55
|
+
run: bundle install
|
|
56
|
+
|
|
57
|
+
# House-measured: the pagefind npm package resolves a platform binary at
|
|
58
|
+
# install and an npx fallback DIED in CI ("Failed to install either of
|
|
59
|
+
# [pagefind_extended, pagefind]" - dhaupin/freestruct docs.yml note).
|
|
60
|
+
# The standalone musl tarball is the proven path (prestruct docs.yml).
|
|
61
|
+
- name: Download Pagefind
|
|
62
|
+
working-directory: docs
|
|
63
|
+
run: |
|
|
64
|
+
VERSION=$(curl -sL "https://api.github.com/repos/Pagefind/pagefind/releases/latest" | grep '"tag_name"' | sed 's/.*"v\([^\"]*\)".*/\1/')
|
|
65
|
+
curl -sL "https://github.com/Pagefind/pagefind/releases/download/v${VERSION}/pagefind-v${VERSION}-x86_64-unknown-linux-musl.tar.gz" -o pagefind.tar.gz
|
|
66
|
+
tar -xzf pagefind.tar.gz
|
|
67
|
+
rm pagefind.tar.gz
|
|
68
|
+
|
|
69
|
+
- name: Jekyll build
|
|
70
|
+
working-directory: docs
|
|
71
|
+
run: bundle exec jekyll build
|
|
72
|
+
|
|
73
|
+
# freestruct AFTER jekyll (post-render SEO layer; discovers
|
|
74
|
+
# docs/freestruct.config.yml + docs/_site by the engine's own rule) --
|
|
75
|
+
# --strict: broken links fail the build.
|
|
76
|
+
- name: Freestruct (strict)
|
|
77
|
+
run: npx --yes freestruct@1.1.0 --strict
|
|
78
|
+
|
|
79
|
+
# Pagefind LAST - index over the FINAL html (freestruct-injected)
|
|
80
|
+
- name: Index search with Pagefind
|
|
81
|
+
working-directory: docs
|
|
82
|
+
run: ./pagefind --site _site
|
|
83
|
+
|
|
84
|
+
- name: Upload artifact
|
|
85
|
+
id: upload-artifact
|
|
86
|
+
uses: actions/upload-pages-artifact@v3
|
|
87
|
+
with:
|
|
88
|
+
path: 'docs/_site'
|
|
89
|
+
|
|
90
|
+
deploy:
|
|
91
|
+
needs: build
|
|
92
|
+
# The integration branch is in the trigger list, so the trigger no longer
|
|
93
|
+
# keeps staging's docs out of production - this guard does (flowforge#30,
|
|
94
|
+
# point 3: the trap). Only a promotion to main deploys.
|
|
95
|
+
if: github.ref == 'refs/heads/main'
|
|
96
|
+
runs-on: ubuntu-latest
|
|
97
|
+
environment:
|
|
98
|
+
name: github-pages
|
|
99
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
100
|
+
steps:
|
|
101
|
+
- id: deployment
|
|
102
|
+
uses: actions/deploy-pages@v4
|