- 重构版主提示词(14 parts,面向 ClassHelper 灵动岛重构) - ClassIsland 全量规格提示词(20 parts,含分卷与逐章版本) - 投喂指南、分卷、逐节文件 - 调研记录、一致性基线、生成与质检脚本
45 lines
2.1 KiB
JavaScript
45 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
||
/** 对 parts/*.md 做机械质检:长度、标题、证据密度、占位符、编号一致性、关键数值出现情况 */
|
||
import { readdirSync, readFileSync } from 'node:fs';
|
||
import { join, dirname } from 'node:path';
|
||
import { fileURLToPath } from 'node:url';
|
||
|
||
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||
const dir = join(root, 'parts');
|
||
const files = readdirSync(dir).filter((f) => /^\d{2}-.+\.md$/.test(f)).sort();
|
||
|
||
const placeholders = [/TODO/i, /待补充/, /待完善/, /占位/, /省略/, /\.\.\.\.\.\./, /示例文本/];
|
||
const rows = [];
|
||
for (const f of files) {
|
||
const text = readFileSync(join(dir, f), 'utf8');
|
||
const noWs = text.replace(/\s/g, '');
|
||
const num = f.slice(0, 2);
|
||
const h2 = [...text.matchAll(/^## (.+)$/gm)].map((m) => m[1]);
|
||
const evidence = (text.match(/repos\/(ClassIsland|ClassHelper-master)\/[^\s`::,,))]+/g) || []).length;
|
||
const inferred = (text.match(/【推断】/g) || []).length;
|
||
const ph = placeholders.filter((r) => r.test(text)).map((r) => r.source);
|
||
const firstHeadingOk = h2.length > 0 && new RegExp(`^${Number(num)}\\.`).test(h2[0]);
|
||
rows.push({ f, chars: [...noWs].length, lines: text.split('\n').length, h2: h2.length, evidence, inferred, ph, firstHeadingOk, firstH2: h2[0] || '' });
|
||
}
|
||
console.log('file'.padEnd(26), 'chars'.padStart(7), 'lines'.padStart(6), 'h2'.padStart(3), 'evid'.padStart(5), 'infer'.padStart(5), 'numOK', 'placeholders');
|
||
for (const r of rows) {
|
||
console.log(
|
||
r.f.padEnd(26),
|
||
String(r.chars).padStart(7),
|
||
String(r.lines).padStart(6),
|
||
String(r.h2).padStart(3),
|
||
String(r.evidence).padStart(5),
|
||
String(r.inferred).padStart(5),
|
||
String(r.firstHeadingOk).padStart(5),
|
||
r.ph.join('|') || '-',
|
||
);
|
||
}
|
||
const total = rows.reduce((a, r) => a + r.chars, 0);
|
||
console.log(`\n合计 ${rows.length} 个 part,去空白字符 ${total}`);
|
||
const missing = [];
|
||
for (let i = 0; i <= 19; i++) {
|
||
const n = String(i).padStart(2, '0');
|
||
if (!files.some((f) => f.startsWith(n + '-'))) missing.push(n);
|
||
}
|
||
console.log('缺失 part:', missing.join(',') || '无');
|