interplane.Get Omega
Read in your language

sovereign-intelligence

Front door to Drake Stapleton's sovereign stack.

Brought by drakestapleton

branch main Branches Tags History

sovereign-intelligence / docs / archive / drakestapleton.com-old / scripts / check-copy.mjs

45 lines · 1898 bytes Raw Blame History
1import { readFileSync, readdirSync } from "node:fs";
2import { extname, join } from "node:path";
3
4const roots = ["src/pages", "src/components", "src/data", "src/diagrams"];
5const forbidden = /\b(not|no|never|isn['’]t|wasn['’]t|didn['’]t|don['’]t|doesn['’]t|can['’]t|cannot|won['’]t|without|nobody|nothing|neither|nor|lacked?|unwilling|refus(?:e|ed|ing))\b/gi;
6const synthetic = /\b(agentic|delve|tapestry|testament|cutting-edge|seamless|transformative|thought leader)\b/gi;
7// HisWords marks the author's own spoken words. His voice is exempt from the
8// affirmative-copy rule: the rule governs AI-drafted prose, not him.
9const hisWordsOpen = /<HisWords[\s>]/g;
10const hisWordsClose = /<\/HisWords>/g;
11const findings = [];
12
13function visit(directory) {
14 for (const entry of readdirSync(directory, { withFileTypes: true })) {
15 const path = join(directory, entry.name);
16 if (entry.isDirectory()) {
17 visit(path);
18 continue;
19 }
20 if (![".ts", ".tsx"].includes(extname(path))) continue;
21 const lines = readFileSync(path, "utf8").split("\n");
22 let hisWordsDepth = 0;
23 lines.forEach((line, index) => {
24 hisWordsOpen.lastIndex = 0;
25 hisWordsClose.lastIndex = 0;
26 const opens = [...line.matchAll(hisWordsOpen)].length;
27 const closes = [...line.matchAll(hisWordsClose)].length;
28 const inHisWords = hisWordsDepth > 0 || opens > 0;
29 hisWordsDepth = Math.max(0, hisWordsDepth + opens - closes);
30 if (inHisWords) return;
31 for (const pattern of [forbidden, synthetic]) {
32 pattern.lastIndex = 0;
33 const matches = [...line.matchAll(pattern)].map((match) => match[0]);
34 if (matches.length) findings.push(`${path}:${index + 1}: ${matches.join(", ")}`);
35 }
36 });
37 }
38}
39
40roots.forEach(visit);
41if (findings.length) {
42 console.error(findings.join("\n"));
43 process.exit(1);
44}
45console.log("copy check passed");