@lifeaitools/rdc-skills 0.13.2 → 0.13.4
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/package.json +1 -1
- package/scripts/rdc-brochure.mjs +464 -0
- package/skills/brochure/SKILL.md +107 -0
- package/skills/rdc-convert/SKILL.md +127 -0
package/package.json
CHANGED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* rdc:brochure — zip/folder/html/url/markdown → PDF via Puppeteer.
|
|
4
|
+
* See skills/brochure/SKILL.md for the contract.
|
|
5
|
+
*/
|
|
6
|
+
import { execSync, spawnSync } from 'node:child_process';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync, copyFileSync } from 'node:fs';
|
|
9
|
+
import { homedir, tmpdir } from 'node:os';
|
|
10
|
+
import { dirname, basename, extname, join, resolve, relative, sep } from 'node:path';
|
|
11
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
12
|
+
import { createRequire } from 'node:module';
|
|
13
|
+
|
|
14
|
+
const AUTO_FIT_CSS = `
|
|
15
|
+
/* rdc:brochure --auto-fit corrective stylesheet
|
|
16
|
+
Generic print-overflow safety net. Applied AFTER document stylesheets. */
|
|
17
|
+
@media print, screen {
|
|
18
|
+
html, body { overflow: visible !important; }
|
|
19
|
+
body { max-width: 100% !important; }
|
|
20
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
21
|
+
|
|
22
|
+
img, svg, video, canvas, iframe, object, embed {
|
|
23
|
+
max-width: 100% !important;
|
|
24
|
+
height: auto !important;
|
|
25
|
+
object-fit: contain;
|
|
26
|
+
}
|
|
27
|
+
figure, .figure, picture { break-inside: avoid; page-break-inside: avoid; max-width: 100%; }
|
|
28
|
+
|
|
29
|
+
table {
|
|
30
|
+
table-layout: fixed !important;
|
|
31
|
+
width: 100% !important;
|
|
32
|
+
max-width: 100% !important;
|
|
33
|
+
word-wrap: break-word;
|
|
34
|
+
overflow-wrap: anywhere;
|
|
35
|
+
border-collapse: collapse;
|
|
36
|
+
}
|
|
37
|
+
th, td { word-wrap: break-word; overflow-wrap: anywhere; max-width: 100%; }
|
|
38
|
+
thead { display: table-header-group; }
|
|
39
|
+
tr, td, th { break-inside: avoid; page-break-inside: avoid; }
|
|
40
|
+
|
|
41
|
+
pre, code, kbd, samp { white-space: pre-wrap !important; word-break: break-word; overflow-wrap: anywhere; max-width: 100%; }
|
|
42
|
+
pre { break-inside: avoid; page-break-inside: avoid; }
|
|
43
|
+
|
|
44
|
+
h1, h2, h3, h4, h5, h6 { break-after: avoid; page-break-after: avoid; }
|
|
45
|
+
h1 + *, h2 + *, h3 + *, h4 + * { break-before: avoid; }
|
|
46
|
+
p, li { orphans: 3; widows: 3; }
|
|
47
|
+
|
|
48
|
+
/* Generic wide-content sentinels */
|
|
49
|
+
.wide, .full-bleed, .panorama { max-width: 100% !important; }
|
|
50
|
+
|
|
51
|
+
/* Avoid blank-page artifacts from oversized flex/grid containers */
|
|
52
|
+
[style*="position: fixed"], [style*="position:fixed"] { position: static !important; }
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
57
|
+
const REPO_ROOT = resolve(HERE, '..');
|
|
58
|
+
const TEMPLATES_DIR = join(REPO_ROOT, 'scaffold', 'templates');
|
|
59
|
+
|
|
60
|
+
// --- args ------------------------------------------------------------------
|
|
61
|
+
const argv = process.argv.slice(2);
|
|
62
|
+
const opts = { template: 'studio-default', format: 'Letter', printEmulate: true, keepWorkdir: false, autoFit: false, scale: 1 };
|
|
63
|
+
let input;
|
|
64
|
+
for (let i = 0; i < argv.length; i++) {
|
|
65
|
+
const a = argv[i];
|
|
66
|
+
if (a === '--out') opts.out = argv[++i];
|
|
67
|
+
else if (a === '--template') opts.template = argv[++i];
|
|
68
|
+
else if (a === '--format') opts.format = argv[++i];
|
|
69
|
+
else if (a === '--margin') opts.margin = argv[++i];
|
|
70
|
+
else if (a === '--no-print-emulate') opts.printEmulate = false;
|
|
71
|
+
else if (a === '--keep-workdir') opts.keepWorkdir = true;
|
|
72
|
+
else if (a === '--auto-fit') opts.autoFit = true;
|
|
73
|
+
else if (a === '--scale') opts.scale = parseFloat(argv[++i]);
|
|
74
|
+
else if (!input) input = a;
|
|
75
|
+
}
|
|
76
|
+
if (!input) {
|
|
77
|
+
console.error('usage: rdc-brochure.mjs <zip|folder|html|md|url> [--out path] [--template name] [--format Letter|A4]');
|
|
78
|
+
process.exit(2);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// --- helpers ---------------------------------------------------------------
|
|
82
|
+
const isUrl = /^https?:\/\//i.test(input);
|
|
83
|
+
const hash = createHash('sha1').update(input).digest('hex').slice(0, 10);
|
|
84
|
+
const workRoot = join(tmpdir(), 'rdc-brochure', hash);
|
|
85
|
+
mkdirSync(workRoot, { recursive: true });
|
|
86
|
+
|
|
87
|
+
const log = (...a) => console.log('[brochure]', ...a);
|
|
88
|
+
|
|
89
|
+
function human(n) {
|
|
90
|
+
const u = ['B', 'KB', 'MB', 'GB'];
|
|
91
|
+
let i = 0;
|
|
92
|
+
while (n >= 1024 && i < u.length - 1) { n /= 1024; i++; }
|
|
93
|
+
return `${n.toFixed(1)} ${u[i]}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function walk(dir) {
|
|
97
|
+
const out = [];
|
|
98
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
99
|
+
const p = join(dir, e.name);
|
|
100
|
+
if (e.isDirectory()) out.push(...walk(p));
|
|
101
|
+
else out.push(p);
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// --- ensure puppeteer ------------------------------------------------------
|
|
107
|
+
async function loadPuppeteer() {
|
|
108
|
+
try { return (await import('puppeteer')).default; } catch {}
|
|
109
|
+
// Try a local cache install.
|
|
110
|
+
const cacheDir = join(homedir(), '.cache', 'rdc-brochure');
|
|
111
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
112
|
+
if (!existsSync(join(cacheDir, 'package.json'))) {
|
|
113
|
+
writeFileSync(join(cacheDir, 'package.json'), JSON.stringify({ name: 'rdc-brochure-cache', private: true }, null, 2));
|
|
114
|
+
}
|
|
115
|
+
if (!existsSync(join(cacheDir, 'node_modules', 'puppeteer'))) {
|
|
116
|
+
log('installing puppeteer into', cacheDir);
|
|
117
|
+
execSync('npm install puppeteer --no-audit --no-fund --loglevel=error', { cwd: cacheDir, stdio: 'inherit' });
|
|
118
|
+
}
|
|
119
|
+
const req = createRequire(join(cacheDir, 'package.json'));
|
|
120
|
+
const mod = req('puppeteer');
|
|
121
|
+
return mod.default || mod;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// --- cross-platform unzip --------------------------------------------------
|
|
125
|
+
// Pure-Node first (adm-zip — works on every platform, no external binary).
|
|
126
|
+
// If the lib cannot be resolved or installed, fall back to a platform-native
|
|
127
|
+
// extractor: `unzip` on POSIX, PowerShell `Expand-Archive` on win32.
|
|
128
|
+
function loadAdmZip() {
|
|
129
|
+
try { return createRequire(import.meta.url)('adm-zip'); } catch {}
|
|
130
|
+
// Reuse the puppeteer on-demand cache dir for an isolated local install.
|
|
131
|
+
const cacheDir = join(homedir(), '.cache', 'rdc-brochure');
|
|
132
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
133
|
+
if (!existsSync(join(cacheDir, 'package.json'))) {
|
|
134
|
+
writeFileSync(join(cacheDir, 'package.json'), JSON.stringify({ name: 'rdc-brochure-cache', private: true }, null, 2));
|
|
135
|
+
}
|
|
136
|
+
if (!existsSync(join(cacheDir, 'node_modules', 'adm-zip'))) {
|
|
137
|
+
try {
|
|
138
|
+
log('installing adm-zip into', cacheDir);
|
|
139
|
+
execSync('npm install adm-zip --no-audit --no-fund --loglevel=error', { cwd: cacheDir, stdio: 'inherit' });
|
|
140
|
+
} catch { return null; }
|
|
141
|
+
}
|
|
142
|
+
try { return createRequire(join(cacheDir, 'package.json'))('adm-zip'); } catch { return null; }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Reject any archive member that resolves outside destDir (zip-slip / path
|
|
146
|
+
// traversal). Returns the validated absolute destination path. Throws on escape.
|
|
147
|
+
function safeJoinOrThrow(destDir, entryName) {
|
|
148
|
+
const root = resolve(destDir);
|
|
149
|
+
const dest = resolve(root, entryName);
|
|
150
|
+
if (dest !== root && !dest.startsWith(root + sep)) {
|
|
151
|
+
throw new Error(`zip-slip: entry "${entryName}" escapes destination directory`);
|
|
152
|
+
}
|
|
153
|
+
return dest;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function extractZip(zipPath, destDir) {
|
|
157
|
+
mkdirSync(destDir, { recursive: true });
|
|
158
|
+
const root = resolve(destDir);
|
|
159
|
+
const AdmZip = loadAdmZip();
|
|
160
|
+
if (AdmZip) {
|
|
161
|
+
const zip = new AdmZip(zipPath);
|
|
162
|
+
const entries = zip.getEntries();
|
|
163
|
+
// First pass: validate every entry resolves inside destDir. A brochure
|
|
164
|
+
// source zip must never contain `..` or absolute members — reject the whole
|
|
165
|
+
// archive rather than silently skipping (fail-closed).
|
|
166
|
+
for (const entry of entries) {
|
|
167
|
+
safeJoinOrThrow(root, entry.entryName);
|
|
168
|
+
}
|
|
169
|
+
// Second pass: extract validated entries individually. Do NOT use the
|
|
170
|
+
// blanket extractAllTo — adm-zip does not sanitize entry paths.
|
|
171
|
+
for (const entry of entries) {
|
|
172
|
+
if (entry.isDirectory) {
|
|
173
|
+
mkdirSync(safeJoinOrThrow(root, entry.entryName), { recursive: true });
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const dest = safeJoinOrThrow(root, entry.entryName);
|
|
177
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
178
|
+
zip.extractEntryTo(entry, root, /* maintainEntryPath */ true, /* overwrite */ true);
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// Fallback: platform-native extractor. Validate members via a listing pass
|
|
183
|
+
// BEFORE extracting, since the bulk extract commands cannot apply per-entry
|
|
184
|
+
// guards. Reject any `..` segment or absolute/leading-slash member.
|
|
185
|
+
log('adm-zip unavailable — falling back to platform unzip');
|
|
186
|
+
assertNativeZipSafe(zipPath);
|
|
187
|
+
let r;
|
|
188
|
+
if (process.platform === 'win32') {
|
|
189
|
+
r = spawnSync('powershell', ['-NoProfile', '-Command',
|
|
190
|
+
`Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force`], { stdio: 'inherit' });
|
|
191
|
+
} else {
|
|
192
|
+
r = spawnSync('unzip', ['-o', '-q', zipPath, '-d', destDir], { stdio: 'inherit' });
|
|
193
|
+
}
|
|
194
|
+
if (!r || r.status !== 0) throw new Error('unzip failed (no pure-Node lib and platform extractor failed)');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// List archive members with a native tool and reject any traversal/absolute
|
|
198
|
+
// entry. Throws if a member is unsafe or the listing cannot be produced.
|
|
199
|
+
function assertNativeZipSafe(zipPath) {
|
|
200
|
+
let names = [];
|
|
201
|
+
if (process.platform === 'win32') {
|
|
202
|
+
const ps = spawnSync('powershell', ['-NoProfile', '-Command',
|
|
203
|
+
`Add-Type -AssemblyName System.IO.Compression.FileSystem; ` +
|
|
204
|
+
`[System.IO.Compression.ZipFile]::OpenRead('${zipPath}').Entries | ForEach-Object { $_.FullName }`],
|
|
205
|
+
{ encoding: 'utf8' });
|
|
206
|
+
if (ps.status !== 0) throw new Error('cannot list zip members for traversal check (PowerShell)');
|
|
207
|
+
names = String(ps.stdout || '').split(/\r?\n/);
|
|
208
|
+
} else {
|
|
209
|
+
const zi = spawnSync('zipinfo', ['-1', zipPath], { encoding: 'utf8' });
|
|
210
|
+
if (zi.status === 0) {
|
|
211
|
+
names = String(zi.stdout || '').split(/\r?\n/);
|
|
212
|
+
} else {
|
|
213
|
+
const ul = spawnSync('unzip', ['-Z1', zipPath], { encoding: 'utf8' });
|
|
214
|
+
if (ul.status !== 0) throw new Error('cannot list zip members for traversal check (unzip -Z1)');
|
|
215
|
+
names = String(ul.stdout || '').split(/\r?\n/);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
for (const raw of names) {
|
|
219
|
+
const name = raw.trim();
|
|
220
|
+
if (!name) continue;
|
|
221
|
+
const norm = name.replace(/\\/g, '/');
|
|
222
|
+
if (norm.startsWith('/') || /^[A-Za-z]:/.test(norm) || norm.split('/').some((seg) => seg === '..')) {
|
|
223
|
+
throw new Error(`zip-slip: entry "${name}" escapes destination directory`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// --- stage input -----------------------------------------------------------
|
|
229
|
+
function stageInput() {
|
|
230
|
+
const stageDir = join(workRoot, 'src');
|
|
231
|
+
mkdirSync(stageDir, { recursive: true });
|
|
232
|
+
if (isUrl) return { kind: 'url', url: input, stageDir };
|
|
233
|
+
const abs = resolve(input);
|
|
234
|
+
if (!existsSync(abs)) throw new Error(`not found: ${abs}`);
|
|
235
|
+
const st = statSync(abs);
|
|
236
|
+
if (st.isDirectory()) return { kind: 'folder', root: abs, stageDir: abs };
|
|
237
|
+
const ext = extname(abs).toLowerCase();
|
|
238
|
+
if (ext === '.zip') {
|
|
239
|
+
log('extracting zip to', stageDir);
|
|
240
|
+
extractZip(abs, stageDir);
|
|
241
|
+
return { kind: 'folder', root: stageDir, stageDir };
|
|
242
|
+
}
|
|
243
|
+
if (ext === '.html' || ext === '.htm') return { kind: 'html', file: abs, stageDir: dirname(abs) };
|
|
244
|
+
if (ext === '.md' || ext === '.markdown') return { kind: 'md', file: abs, stageDir: dirname(abs) };
|
|
245
|
+
throw new Error(`unsupported input: ${ext || '(no extension)'}`);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// --- pick HTML in render mode ----------------------------------------------
|
|
249
|
+
function pickHtml(rootDir) {
|
|
250
|
+
const htmls = walk(rootDir).filter((p) => /\.html?$/i.test(p));
|
|
251
|
+
if (!htmls.length) return null;
|
|
252
|
+
const scored = htmls.map((p) => {
|
|
253
|
+
const text = readFileSync(p, 'utf8');
|
|
254
|
+
const size = statSync(p).size;
|
|
255
|
+
let score = 0;
|
|
256
|
+
if (/@page\b/.test(text)) score += 1000;
|
|
257
|
+
if (/@media\s+print/i.test(text)) score += 500;
|
|
258
|
+
if (/-print\.html?$/i.test(p)) score += 300;
|
|
259
|
+
if (/brochure\.html?$/i.test(p)) score += 250;
|
|
260
|
+
if (/(^|[\\/])print\.html?$/i.test(p)) score += 250;
|
|
261
|
+
if (/standalone/i.test(basename(p))) score -= 50; // usually huge embedded duplicate
|
|
262
|
+
score += Math.min(size / 1024, 200); // size as tiebreaker, capped
|
|
263
|
+
return { p, score, size };
|
|
264
|
+
}).sort((a, b) => b.score - a.score);
|
|
265
|
+
return scored[0].p;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// --- compose mode ----------------------------------------------------------
|
|
269
|
+
function listTemplates() {
|
|
270
|
+
if (!existsSync(TEMPLATES_DIR)) return [];
|
|
271
|
+
return readdirSync(TEMPLATES_DIR)
|
|
272
|
+
.map((f) => /^brochure-(.+)\.html$/i.exec(f))
|
|
273
|
+
.filter(Boolean)
|
|
274
|
+
.map((m) => m[1])
|
|
275
|
+
.sort();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async function composeFromFolder(root, file) {
|
|
279
|
+
const tpl = join(TEMPLATES_DIR, `brochure-${opts.template}.html`);
|
|
280
|
+
if (!existsSync(tpl)) {
|
|
281
|
+
const available = listTemplates();
|
|
282
|
+
const list = available.length ? available.join(', ') : '(none found)';
|
|
283
|
+
throw new Error(`unknown template "${opts.template}". Available template(s): ${list}`);
|
|
284
|
+
}
|
|
285
|
+
let html = readFileSync(tpl, 'utf8');
|
|
286
|
+
|
|
287
|
+
let mdFiles = [];
|
|
288
|
+
if (file) mdFiles = [file];
|
|
289
|
+
else mdFiles = walk(root).filter((p) => /\.(md|markdown)$/i.test(p)).sort();
|
|
290
|
+
|
|
291
|
+
const title = (() => {
|
|
292
|
+
for (const p of mdFiles) {
|
|
293
|
+
const m = readFileSync(p, 'utf8').match(/^#\s+(.+)$/m);
|
|
294
|
+
if (m) return m[1].trim();
|
|
295
|
+
}
|
|
296
|
+
return basename(file || root);
|
|
297
|
+
})();
|
|
298
|
+
|
|
299
|
+
const sections = mdFiles.map((p) => {
|
|
300
|
+
const md = readFileSync(p, 'utf8');
|
|
301
|
+
// Only prepend the filename heading when the markdown has no leading ATX heading
|
|
302
|
+
// of its own. Avoids a redundant <h2>filename</h2> stacked above a "# Title".
|
|
303
|
+
const firstNonEmpty = md.replace(/\r\n/g, '\n').split('\n').find((l) => l.trim() !== '') || '';
|
|
304
|
+
const hasLeadingHeading = /^#{1,6}\s+\S/.test(firstNonEmpty.trim());
|
|
305
|
+
const heading = hasLeadingHeading ? '' : `<h2>${escapeHtml(basename(p, extname(p)))}</h2>`;
|
|
306
|
+
return `<section class="brochure-section">${heading}${mdToHtml(md, dirname(p))}</section>`;
|
|
307
|
+
}).join('\n');
|
|
308
|
+
|
|
309
|
+
html = html.replace(/\{\{TITLE\}\}/g, escapeHtml(title)).replace(/\{\{SECTIONS\}\}/g, sections);
|
|
310
|
+
|
|
311
|
+
const tokensCss = findSibling(root || dirname(file), 'tokens.css');
|
|
312
|
+
if (tokensCss) html = html.replace('/* TOKENS_INJECT */', readFileSync(tokensCss, 'utf8'));
|
|
313
|
+
|
|
314
|
+
const outHtml = join(workRoot, 'composed.html');
|
|
315
|
+
writeFileSync(outHtml, html);
|
|
316
|
+
return outHtml;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function findSibling(dir, name) {
|
|
320
|
+
if (!dir) return null;
|
|
321
|
+
const p = join(dir, name);
|
|
322
|
+
return existsSync(p) ? p : null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function escapeHtml(s) {
|
|
326
|
+
return String(s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Minimal markdown — headings, paragraphs, lists, bold/italic, inline code, fenced code, images.
|
|
330
|
+
function mdToHtml(md, baseDir) {
|
|
331
|
+
let out = md.replace(/\r\n/g, '\n');
|
|
332
|
+
out = out.replace(/```([a-z]*)\n([\s\S]*?)```/g, (_, lang, body) => `<pre><code class="lang-${escapeHtml(lang)}">${escapeHtml(body)}</code></pre>`);
|
|
333
|
+
out = out.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, (_, alt, src) => `<img alt="${escapeHtml(alt)}" src="${resolveImg(src, baseDir)}"/>`);
|
|
334
|
+
out = out.replace(/^######\s+(.+)$/gm, '<h6>$1</h6>')
|
|
335
|
+
.replace(/^#####\s+(.+)$/gm, '<h5>$1</h5>')
|
|
336
|
+
.replace(/^####\s+(.+)$/gm, '<h4>$1</h4>')
|
|
337
|
+
.replace(/^###\s+(.+)$/gm, '<h3>$1</h3>')
|
|
338
|
+
.replace(/^##\s+(.+)$/gm, '<h2>$1</h2>')
|
|
339
|
+
.replace(/^#\s+(.+)$/gm, '<h1>$1</h1>');
|
|
340
|
+
out = out.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>').replace(/\*([^*]+)\*/g, '<em>$1</em>').replace(/`([^`]+)`/g, '<code>$1</code>');
|
|
341
|
+
out = out.replace(/(?:^|\n)((?:[-*]\s+.+\n?)+)/g, (_, block) => `\n<ul>${block.trim().split(/\n/).map((l) => `<li>${l.replace(/^[-*]\s+/, '')}</li>`).join('')}</ul>\n`);
|
|
342
|
+
out = out.split(/\n{2,}/).map((b) => /^<(h\d|ul|ol|pre|img|section|div)/.test(b.trim()) ? b : `<p>${b.trim()}</p>`).join('\n');
|
|
343
|
+
return out;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function resolveImg(src, baseDir) {
|
|
347
|
+
if (/^https?:|^data:/.test(src)) return src;
|
|
348
|
+
const p = resolve(baseDir, src);
|
|
349
|
+
if (!existsSync(p)) return src;
|
|
350
|
+
return pathToFileURL(p).href;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// --- render ----------------------------------------------------------------
|
|
354
|
+
async function render(htmlSource) {
|
|
355
|
+
const puppeteer = await loadPuppeteer();
|
|
356
|
+
const browser = await puppeteer.launch({ headless: 'new', args: ['--no-sandbox', '--disable-setuid-sandbox', '--font-render-hinting=none'] });
|
|
357
|
+
try {
|
|
358
|
+
const page = await browser.newPage();
|
|
359
|
+
page.on('pageerror', (e) => log('pageerror:', e.message));
|
|
360
|
+
const url = htmlSource.startsWith('http') ? htmlSource : pathToFileURL(htmlSource).href;
|
|
361
|
+
log('loading', url);
|
|
362
|
+
await page.goto(url, { waitUntil: 'networkidle0', timeout: 180_000 });
|
|
363
|
+
await page.evaluateHandle('document.fonts.ready');
|
|
364
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
365
|
+
if (opts.printEmulate) await page.emulateMediaType('print');
|
|
366
|
+
|
|
367
|
+
if (opts.autoFit) {
|
|
368
|
+
await page.addStyleTag({ content: AUTO_FIT_CSS });
|
|
369
|
+
const report = await page.evaluate(() => {
|
|
370
|
+
const issues = [];
|
|
371
|
+
const all = document.body.querySelectorAll('*');
|
|
372
|
+
const pageWidthPx = document.documentElement.clientWidth;
|
|
373
|
+
for (const el of all) {
|
|
374
|
+
const r = el.getBoundingClientRect();
|
|
375
|
+
if (r.width > pageWidthPx + 4) {
|
|
376
|
+
issues.push({ tag: el.tagName, cls: el.className?.toString().slice(0, 60) || '', width: Math.round(r.width), pageWidth: pageWidthPx });
|
|
377
|
+
if (issues.length >= 25) break;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return issues;
|
|
381
|
+
});
|
|
382
|
+
if (report.length) {
|
|
383
|
+
log(`auto-fit: ${report.length} overflow element(s) detected — corrective CSS applied`);
|
|
384
|
+
for (const r of report.slice(0, 8)) log(` · ${r.tag}${r.cls ? '.' + r.cls : ''} width=${r.width}px (page=${r.pageWidth}px)`);
|
|
385
|
+
} else {
|
|
386
|
+
log('auto-fit: no overflow detected after corrective CSS');
|
|
387
|
+
}
|
|
388
|
+
await new Promise((r) => setTimeout(r, 400));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const outPath = resolve(opts.out || defaultOutPath());
|
|
392
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
393
|
+
|
|
394
|
+
const pdfOpts = {
|
|
395
|
+
path: outPath,
|
|
396
|
+
format: opts.format,
|
|
397
|
+
printBackground: true,
|
|
398
|
+
preferCSSPageSize: true,
|
|
399
|
+
displayHeaderFooter: false,
|
|
400
|
+
scale: opts.scale && opts.scale !== 1 ? opts.scale : undefined,
|
|
401
|
+
};
|
|
402
|
+
if (opts.margin) {
|
|
403
|
+
const m = opts.margin;
|
|
404
|
+
pdfOpts.margin = { top: m, bottom: m, left: m, right: m };
|
|
405
|
+
pdfOpts.preferCSSPageSize = false;
|
|
406
|
+
} else if (!htmlSource.startsWith('http')) {
|
|
407
|
+
const text = readFileSync(htmlSource, 'utf8');
|
|
408
|
+
if (!/@page\b/.test(text)) {
|
|
409
|
+
pdfOpts.margin = { top: '0.6in', bottom: '0.6in', left: '0.7in', right: '0.7in' };
|
|
410
|
+
pdfOpts.preferCSSPageSize = false;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
await page.pdf(pdfOpts);
|
|
415
|
+
return outPath;
|
|
416
|
+
} finally {
|
|
417
|
+
await browser.close();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function defaultOutPath() {
|
|
422
|
+
if (isUrl) return resolve('brochure.pdf');
|
|
423
|
+
const abs = resolve(input);
|
|
424
|
+
const base = basename(abs, extname(abs));
|
|
425
|
+
return resolve(dirname(abs), `${base}.pdf`);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// --- main ------------------------------------------------------------------
|
|
429
|
+
(async () => {
|
|
430
|
+
const staged = stageInput();
|
|
431
|
+
let htmlSource;
|
|
432
|
+
|
|
433
|
+
if (staged.kind === 'url') {
|
|
434
|
+
htmlSource = staged.url;
|
|
435
|
+
} else if (staged.kind === 'html') {
|
|
436
|
+
htmlSource = staged.file;
|
|
437
|
+
} else if (staged.kind === 'md') {
|
|
438
|
+
htmlSource = await composeFromFolder(null, staged.file);
|
|
439
|
+
} else { // folder
|
|
440
|
+
const picked = pickHtml(staged.stageDir);
|
|
441
|
+
if (picked) {
|
|
442
|
+
log('picked html:', relative(staged.stageDir, picked));
|
|
443
|
+
htmlSource = picked;
|
|
444
|
+
} else {
|
|
445
|
+
log('no html found — composing from markdown');
|
|
446
|
+
htmlSource = await composeFromFolder(staged.stageDir);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const outPath = await render(htmlSource);
|
|
451
|
+
const size = statSync(outPath).size;
|
|
452
|
+
let pages = '?';
|
|
453
|
+
try {
|
|
454
|
+
const buf = readFileSync(outPath);
|
|
455
|
+
const m = buf.toString('latin1').match(/\/Type\s*\/Page[^s]/g);
|
|
456
|
+
if (m) pages = String(m.length);
|
|
457
|
+
} catch {}
|
|
458
|
+
|
|
459
|
+
console.log('');
|
|
460
|
+
console.log(`PDF: ${outPath}`);
|
|
461
|
+
console.log(`Pages: ${pages}`);
|
|
462
|
+
console.log(`Size: ${human(size)}`);
|
|
463
|
+
console.log(`Source: ${input} → ${htmlSource.startsWith('http') ? htmlSource : relative(process.cwd(), htmlSource)}`);
|
|
464
|
+
})().catch((err) => { console.error('[brochure] error:', err.message); process.exit(1); });
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rdc:brochure
|
|
3
|
+
description: "Usage `rdc:brochure <input> [--out <path>] [--template <name>] [--format Letter|A4]` — Turn a zip, folder, HTML file, URL, or markdown folder into a print-quality PDF brochure via Puppeteer. Auto-detects print-variant HTML, honors @page CSS, falls back to a Studio-token-aware template when no HTML exists."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> **⚠️ OUTPUT CONTRACT (READ FIRST):** `guides/output-contract.md`
|
|
7
|
+
> Checklist-only output. No tool-call narration. No raw MCP/JSON/log dumps.
|
|
8
|
+
> One checklist upfront, updated in place, shown again at end with a 1-line verdict.
|
|
9
|
+
|
|
10
|
+
> **Sandbox contract:** Honors `RDC_TEST=1`. Under the flag the skill renders to a fixture path and skips any post-deploy or upload steps.
|
|
11
|
+
|
|
12
|
+
# rdc:brochure — Zip / Folder / HTML → PDF Brochure
|
|
13
|
+
|
|
14
|
+
A focused render pipeline. Two modes:
|
|
15
|
+
|
|
16
|
+
1. **Render mode** — input already contains print-ready HTML. Skill picks the best HTML file and renders it.
|
|
17
|
+
2. **Compose mode** — input is a folder of assets + markdown/text with no HTML. Skill composes a Studio-token-aware brochure layout, then renders it.
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
- A client zip of deliverables that includes a print-first HTML doc (FuturVille ASP, ranch reports, project plans).
|
|
21
|
+
- A `places/<slug>/` or `apps/<app>/` markdown package that needs a PDF artifact.
|
|
22
|
+
- A single URL or HTML file you want as a clean PDF.
|
|
23
|
+
|
|
24
|
+
## When NOT to Use
|
|
25
|
+
- Production marketing collateral that lives in `apps/*` and ships via Coolify — that goes through `rdc:design` + `rdc:deploy`.
|
|
26
|
+
- Multi-document publication systems — use `rdc:plan` to scaffold first.
|
|
27
|
+
|
|
28
|
+
## Arguments
|
|
29
|
+
- `rdc:brochure <input>` — path to `.zip`, folder, `.html`, `.md`, or `http(s)://...` URL.
|
|
30
|
+
- `--out <path>` — output PDF path. Default: `<input-basename>.pdf` next to the input (or `./brochure.pdf` for URLs).
|
|
31
|
+
- `--template <name>` — compose-mode template. Default `studio-default`. Templates live in `scaffold/templates/brochure-*.html`. An unknown name errors out and lists the available template(s) — it does not silently fall back.
|
|
32
|
+
- `--format Letter|A4` — page size. Default `Letter`.
|
|
33
|
+
- `--margin <css>` — override margin. Default honors `@page` from source CSS, else `0.6in 0.7in`.
|
|
34
|
+
- `--no-print-emulate` — render with screen media instead of print.
|
|
35
|
+
- `--keep-workdir` — keep the staged working directory for inspection.
|
|
36
|
+
- `--auto-fit` — inject corrective print-fit CSS (oversized images, wide tables, long code, heading orphans, figure splits) and log overflow diagnostics. Use when source HTML overflows page boundaries.
|
|
37
|
+
- `--scale <n>` — PDF scale factor (e.g. `0.92` to tighten). Default `1`.
|
|
38
|
+
|
|
39
|
+
## Procedure
|
|
40
|
+
|
|
41
|
+
1. **Resolve input.**
|
|
42
|
+
- Zip → extract to `tmp/rdc-brochure/<hash>/src`.
|
|
43
|
+
- Folder → stage in place (read-only).
|
|
44
|
+
- URL → fetch into a sandbox dir as `index.html` + linked assets via Puppeteer.
|
|
45
|
+
- `.html` → stage as-is.
|
|
46
|
+
- `.md` or folder-without-html → compose mode.
|
|
47
|
+
|
|
48
|
+
2. **Pick HTML in render mode.**
|
|
49
|
+
- Prefer the largest standalone HTML containing `@page` or `@media print` rules.
|
|
50
|
+
- Else prefer files matching `*-print.html`, `*-brochure.html`, `print.html`.
|
|
51
|
+
- Else the largest HTML at root.
|
|
52
|
+
|
|
53
|
+
3. **Compose mode.**
|
|
54
|
+
- Read the chosen template (`scaffold/templates/brochure-studio-default.html`).
|
|
55
|
+
- Inventory the input dir: `*.md`, `*.txt`, images grouped by directory, `cover.*`, `logo.*`.
|
|
56
|
+
- Render markdown to HTML, inject into template slots: cover, foreword, sections, figures, back-matter.
|
|
57
|
+
- Use Studio token CSS (Source Serif 4 + Hanken Grotesk, loam/moss/ochre palette) as the default. If a sibling `tokens.css` is present, prefer that.
|
|
58
|
+
|
|
59
|
+
4. **Render with Puppeteer.**
|
|
60
|
+
- `headless: 'new'`, `--font-render-hinting=none`.
|
|
61
|
+
- `waitUntil: 'networkidle0'`, await `document.fonts.ready`, then 1500ms settle.
|
|
62
|
+
- `emulateMediaType('print')` unless `--no-print-emulate`.
|
|
63
|
+
- `printBackground: true`, `preferCSSPageSize: true`.
|
|
64
|
+
- Letter @ `0.6in 0.7in` default margins.
|
|
65
|
+
|
|
66
|
+
5. **Verify.**
|
|
67
|
+
- Output exists and `> 50KB`.
|
|
68
|
+
- PDF metadata: page count > 0.
|
|
69
|
+
- Log: input, picked HTML or template, page count, file size, output path.
|
|
70
|
+
|
|
71
|
+
## Output
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
PDF: <absolute path>
|
|
75
|
+
Pages: <n>
|
|
76
|
+
Size: <human bytes>
|
|
77
|
+
Source: <input> → <chosen html or template>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Boundaries
|
|
81
|
+
- Does not commit, publish, or upload the resulting PDF. The user moves it.
|
|
82
|
+
- Does not modify the source input.
|
|
83
|
+
- Does not auto-install global dependencies — uses `npx puppeteer` via the skill's own `node_modules` if present, otherwise an on-demand local install under `~/.cache/rdc-brochure/`.
|
|
84
|
+
- Compose-mode templates live in `scaffold/templates/brochure-*.html`. New templates need `rdc:plan` if they cross the architectural-change-approval triggers.
|
|
85
|
+
|
|
86
|
+
## Implementation
|
|
87
|
+
The executable is `scripts/rdc-brochure.mjs` (in the rdc-skills repo). Invoke directly:
|
|
88
|
+
|
|
89
|
+
```powershell
|
|
90
|
+
node {RDC_SKILLS_ROOT}/scripts/rdc-brochure.mjs <input> [--out path] [--template name] [--format Letter|A4]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Examples
|
|
94
|
+
|
|
95
|
+
```powershell
|
|
96
|
+
# Zip of deliverables with print HTML inside
|
|
97
|
+
rdc:brochure "C:/Users/me/Downloads/FuturVille Deliverables.zip"
|
|
98
|
+
|
|
99
|
+
# Folder of markdown + images, compose a brochure
|
|
100
|
+
rdc:brochure "places/futurville-vulcan" --template studio-default --out reports/futurville.pdf
|
|
101
|
+
|
|
102
|
+
# Single HTML to PDF, A4
|
|
103
|
+
rdc:brochure docs/source/some-prototype.html --format A4
|
|
104
|
+
|
|
105
|
+
# URL
|
|
106
|
+
rdc:brochure https://example.com/spec.html --out spec.pdf
|
|
107
|
+
```
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rdc-convert
|
|
3
|
+
version: 0.1.0
|
|
4
|
+
description: |
|
|
5
|
+
Convert Office documents to/from Markdown with the build-corpus CLI: .docx/.pptx/.ppt → Markdown (Word OMML equations become KaTeX-readable TeX; tables, images, headings preserved), and Markdown → Word (.docx) where inline $...$ and display $$...$$ LaTeX become NATIVE Office Math (OMML) that Word renders as real equations. Use this skill whenever the user asks to convert a Word/PowerPoint document to Markdown, build a Markdown corpus from Office files, turn Markdown into a .docx (optionally with a .dotx template), or "open the report" to edit. Install build-corpus straight from GitHub and run it in the session.
|
|
6
|
+
triggers:
|
|
7
|
+
- "convert this docx to markdown"
|
|
8
|
+
- "convert to word"
|
|
9
|
+
- "docx to markdown"
|
|
10
|
+
- "pptx to markdown"
|
|
11
|
+
- "markdown to docx"
|
|
12
|
+
- "build a markdown corpus"
|
|
13
|
+
- "render the equations to word"
|
|
14
|
+
- "build-corpus"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# rdc-convert — Office ↔ Markdown conversion (build-corpus)
|
|
18
|
+
|
|
19
|
+
`build-corpus` is a Python CLI that converts between Office documents and Markdown.
|
|
20
|
+
This is a self-contained skill: install the tool from GitHub into the current
|
|
21
|
+
session and run `build-corpus`. No local checkout or other rdc skill is required.
|
|
22
|
+
|
|
23
|
+
## When to Use
|
|
24
|
+
- `.docx` / `.pptx` / `.ppt` → Markdown — preserves Word OMML equations (as
|
|
25
|
+
KaTeX-readable TeX), tables, images, headings, and lists.
|
|
26
|
+
- Markdown → Word (`.docx`) — inline `$...$` and display `$$...$$` LaTeX are
|
|
27
|
+
converted to **native OMML** Word renders as real equations; optional `.dotx`
|
|
28
|
+
template via `--word-template`.
|
|
29
|
+
- Build a Markdown corpus from a folder of Office files (recursive, one pass).
|
|
30
|
+
- Inline a Markdown file's images as data URIs, or rehost them to R2/S3.
|
|
31
|
+
|
|
32
|
+
## When NOT to Use
|
|
33
|
+
- Rendering a folder/HTML/zip into a print-ready **PDF** brochure (that is a
|
|
34
|
+
separate brochure pipeline).
|
|
35
|
+
- Rasterizing HTML/JSX/SVG to images — build-corpus is a format converter, not a
|
|
36
|
+
render engine; it flags those and a separate render step handles them.
|
|
37
|
+
|
|
38
|
+
## Install & Run (install from GitHub — it is the source of truth)
|
|
39
|
+
|
|
40
|
+
The published PyPI/npm packages lag GitHub. Install from the repository to get the
|
|
41
|
+
current behavior (native LaTeX→OMML, the fidelity report, the escaped-currency fix):
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install "git+https://github.com/LIFEAI/build-corpus.git@feat/dual-package-ubuntu"
|
|
45
|
+
# once merged to main, drop the @branch:
|
|
46
|
+
# pip install "git+https://github.com/LIFEAI/build-corpus.git"
|
|
47
|
+
build-corpus --help
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This installs the `build-corpus` command and its dependencies (latex2mathml,
|
|
51
|
+
mathml2omml, python-docx, Pillow, omml2latex). Notes:
|
|
52
|
+
- Debian/Ubuntu externally-managed Python (PEP 668): add `--break-system-packages`,
|
|
53
|
+
use a venv, or `pipx install "git+https://github.com/LIFEAI/build-corpus.git@feat/dual-package-ubuntu"`.
|
|
54
|
+
- S3/R2 image upload: append `[s3]` to the package spec.
|
|
55
|
+
- Legacy `.ppt` input also needs LibreOffice (`soffice`) on PATH (`apt install libreoffice`).
|
|
56
|
+
`.docx`/`.pptx` need nothing extra.
|
|
57
|
+
|
|
58
|
+
## Command Reference
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
build-corpus <input> [input ...] [options]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`<input>` — one or more `.md`, `.docx`, `.pptx`, or `.ppt` files or directories.
|
|
65
|
+
|
|
66
|
+
| Flag | Values / default | Effect |
|
|
67
|
+
|------|------------------|--------|
|
|
68
|
+
| `--out <dir>` | path | Output directory for the converted tree. |
|
|
69
|
+
| `--out-same-dir` | — | Write `.md`, `.assets`, and reports beside each source file. |
|
|
70
|
+
| `--to` | `auto` \| `markdown` \| `word` (default `auto`) | Output target. `auto` infers from a single-file input. |
|
|
71
|
+
| `--images` | `assets` \| `base64` \| `s3` (default `assets`) | Image handling. |
|
|
72
|
+
| `--equations` | `tex` \| `image` (default `tex`) | docx→md: OMML → KaTeX TeX, or rendered images (debug). |
|
|
73
|
+
| `--inline-images` | — | Emit `<name>.inline.md` with images embedded as data URIs. |
|
|
74
|
+
| `--word-template <file>` | `.docx`/`.dotx` | Template for Markdown → Word exports. |
|
|
75
|
+
| `--move-sources` | — | After a successful convert, move sources into a `sources/` folder. |
|
|
76
|
+
| `--config <file>` | JSON | Conversion/output/S3 defaults (CLI flags override). |
|
|
77
|
+
|
|
78
|
+
S3/R2 (only with `--images s3`): `--s3-bucket`, `--s3-public-base-url`,
|
|
79
|
+
`--s3-prefix`, `--s3-endpoint-url` (required for R2), `--s3-region` (`auto` for R2),
|
|
80
|
+
`--s3-access-key-id`, `--s3-secret-access-key`, `--s3-cache-control`, `--s3-acl`.
|
|
81
|
+
|
|
82
|
+
## Equations (real in both directions)
|
|
83
|
+
- **docx → markdown** (`--equations`): `tex` converts Word OMML equations to
|
|
84
|
+
KaTeX-readable TeX (default); `image` renders them as images (debug only).
|
|
85
|
+
- **markdown → word** (`--to word`): inline `$...$` and display `$$...$$` LaTeX are
|
|
86
|
+
converted to **native OMML** (`\sum`, `\int`, `\frac`, `\Delta`, `\rightarrow`,
|
|
87
|
+
`\leq`, …). Escaped currency like `\$252.3B` is kept as literal text, never mistaken
|
|
88
|
+
for math. Unparseable fragments fall back to Cambria-Math text and are flagged in the
|
|
89
|
+
report. Fence display math with `$$` on their own lines, no blank lines inside.
|
|
90
|
+
|
|
91
|
+
## Fidelity report (md → word)
|
|
92
|
+
Each md→word export writes `export-report.json` (and a batch report) so you can
|
|
93
|
+
confirm nothing was silently dropped or changed:
|
|
94
|
+
- **`fidelity_ok`** — top-level ship gate (`true` only when every row matches and no
|
|
95
|
+
equation fell back).
|
|
96
|
+
- **`reconciliation`** — input vs output per type (`tables`, `equations`
|
|
97
|
+
{in/out_omml/fell_back}, `images` {in/out/failed}, `code_blocks`, `headings`, `links`).
|
|
98
|
+
- **`issues`** — `{ type, line, source|target, reason }` per problem.
|
|
99
|
+
- **`text_fixups`** — markdown escapes the engine resolved (e.g. `currency_unescaped`).
|
|
100
|
+
- A one-line **stdout digest** for a quick glance.
|
|
101
|
+
|
|
102
|
+
Image-failure `reason` values: `missing-file`, `unsupported-on-platform` (EMF/WMF —
|
|
103
|
+
install LibreOffice), `unsupported-format` (.html/.jsx — route to a render pipeline),
|
|
104
|
+
`svg-needs-rasterization` / `mislabeled-svg` (rasterize the SVG to PNG and repoint),
|
|
105
|
+
`skipped-remote`.
|
|
106
|
+
|
|
107
|
+
## Examples
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
build-corpus input.docx --out out # docx → markdown
|
|
111
|
+
build-corpus deck.pptx --out out # pptx → markdown
|
|
112
|
+
build-corpus ./word-files --out ./markdown # whole folder, recursive
|
|
113
|
+
build-corpus ./word-files --out-same-dir # write beside each source
|
|
114
|
+
build-corpus input.md --to word --out out # markdown → Word (LaTeX → OMML)
|
|
115
|
+
build-corpus input.md --to word --word-template custom.dotx --out out
|
|
116
|
+
build-corpus report.md --inline-images # → report.inline.md
|
|
117
|
+
build-corpus input.docx --images s3 --config build-corpus.config.json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Boundaries
|
|
121
|
+
- Does not commit, deploy, or upload outputs (except images when `--images s3`).
|
|
122
|
+
- Does not modify source documents unless `--move-sources` is passed.
|
|
123
|
+
- Does not rasterize HTML/JSX/SVG — flags them for an external render step.
|
|
124
|
+
|
|
125
|
+
## Reference
|
|
126
|
+
- Source (install from here): `github.com/LIFEAI/build-corpus`
|
|
127
|
+
- Packages (currently lag GitHub): PyPI `build-corpus`, npm `regen-mde`.
|