carlos-flow 2.12.6 → 2.12.8
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/AGENTS.md +5 -5
- package/CHANGELOG.md +663 -660
- package/README.en.md +29 -0
- package/README.md +39 -0
- package/README.zh.md +39 -0
- package/TRIGGER_GUIDE.md +2 -2
- package/bridge/mcp-bridge.js +203 -203
- package/check-all.sh +0 -0
- package/ghost.json +1 -7
- package/package.json +114 -114
- package/plugins/carlos-flow-trigger.js +215 -215
- package/scripts/check-no-dead-handler.mjs +87 -87
- package/scripts/check-templates.mjs +126 -126
- package/scripts/clean-readme-noise.mjs +53 -53
- package/scripts/install-hooks.mjs +166 -166
- package/scripts/lang-audit.mjs +172 -172
- package/scripts/mutation-check.mjs +483 -483
- package/scripts/release.mjs +6 -6
- package/scripts/sync-readme.mjs +102 -102
- package/scripts/verify-activation-e2e.sh +55 -55
- package/smoke-test.js +142 -142
- package/src/card.js +296 -296
- package/src/commander.js +9 -9
- package/src/dispatch.js +750 -557
- package/src/index.js +1808 -1713
- package/src/protocol.js +95 -95
- package/src/state.js +930 -930
- package/src/trigger.js +909 -909
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
// 模板渲染合法性门禁
|
|
2
|
-
//
|
|
3
|
-
// 为什么需要(2026-11-13 实测事故):
|
|
4
|
-
// `carlos-flow init --target <platform>` 曾经用**裸字符串替换**把项目根路径塞进模板,
|
|
5
|
-
// 即不做任何转义地把路径原文替换进 JSON 字符串里。
|
|
6
|
-
// Windows 路径的原始反斜杠因此进了 JSON,产出形如
|
|
7
|
-
// "D:\dev-env\node-v22.23.4-win-x64\node_modules\carlos-flow/bridge/mcp-bridge.js"
|
|
8
|
-
// 其中 \d \n \v 都是**非法 JSON 转义序列** —— 配置文件根本解析不了,
|
|
9
|
-
// 表现为「安装成功但插件不出现」,而且任何解析器都报同一个位置。
|
|
10
|
-
// 现场文件 C:\Users\EDY\.cindy\ghosts\carlos-flow.json 就是这个状态。
|
|
11
|
-
// 正确写法见 client/carlos.js:JSON 目标用 JSON.stringify 转义,YAML 目标用正斜杠。
|
|
12
|
-
//
|
|
13
|
-
// 本门禁做的事:
|
|
14
|
-
// 用**真实的 Windows 路径**渲染全部模板,断言产物能被正确解析,
|
|
15
|
-
// 并且路径里的反斜杠没有丢失、没有变成非法转义。
|
|
16
|
-
//
|
|
17
|
-
// 运行:node scripts/check-templates.mjs
|
|
18
|
-
|
|
19
|
-
import { readFileSync } from "node:fs";
|
|
20
|
-
import { join, dirname } from "node:path";
|
|
21
|
-
import { fileURLToPath } from "node:url";
|
|
22
|
-
|
|
23
|
-
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
24
|
-
|
|
25
|
-
let pass = 0;
|
|
26
|
-
let fail = 0;
|
|
27
|
-
|
|
28
|
-
function ok(msg) {
|
|
29
|
-
pass++;
|
|
30
|
-
console.log(" ✅ " + msg);
|
|
31
|
-
}
|
|
32
|
-
function bad(msg) {
|
|
33
|
-
fail++;
|
|
34
|
-
console.log(" ❌ " + msg);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// 真实的 Windows 路径(含反斜杠、大写、子目录),用来复现事故现场
|
|
38
|
-
const WIN_ROOT = "D:\\dev-env\\node-v22.23.4-win-x64\\node_modules\\carlos-flow";
|
|
39
|
-
|
|
40
|
-
// 与 client/carlos.js 中的渲染逻辑保持一致(这是本门禁的关键:两处必须同源)
|
|
41
|
-
const rootJson = JSON.stringify(WIN_ROOT).slice(1, -1);
|
|
42
|
-
const rootYaml = WIN_ROOT.replace(/\\/g, "/");
|
|
43
|
-
|
|
44
|
-
console.log("▶ JSON 模板:Windows 路径渲染后必须可解析且路径无损");
|
|
45
|
-
|
|
46
|
-
const jsonTemplates = [
|
|
47
|
-
["ghost.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
48
|
-
["opencode.json.template", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
49
|
-
["templates/cursor/mcp.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
50
|
-
["templates/cline/mcp.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
51
|
-
["templates/vscode/mcp.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
52
|
-
["templates/claude/claude_desktop_config.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
for (const [rel, render] of jsonTemplates) {
|
|
56
|
-
let raw = "";
|
|
57
|
-
try {
|
|
58
|
-
raw = readFileSync(join(ROOT, rel), "utf8");
|
|
59
|
-
} catch {
|
|
60
|
-
bad(`${rel} 读不到`);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (!raw.includes("__ROOT__")) {
|
|
64
|
-
bad(`${rel} 里没有 __ROOT__ 占位符 —— 渲染逻辑可能已失效,模板与代码脱节`);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
const out = render(raw);
|
|
68
|
-
try {
|
|
69
|
-
const parsed = JSON.parse(out);
|
|
70
|
-
ok(`${rel} 渲染后可解析`);
|
|
71
|
-
// 路径无损检查:反斜杠必须完好,不能变成 \\ 之外的任何形态
|
|
72
|
-
const found = JSON.stringify(parsed).includes("dev-env");
|
|
73
|
-
if (!found) bad(`${rel} 渲染后路径内容丢失`);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
bad(`${rel} 渲染后无法解析:${e.message}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
console.log("▶ YAML 模板:.mcprc 必须用正斜杠(反斜杠在 YAML 双引号里同样非法)");
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
const raw = readFileSync(join(ROOT, ".mcprc.template"), "utf8");
|
|
83
|
-
const out = raw.replace(/__ROOT__/g, rootYaml);
|
|
84
|
-
if (out.includes("\\\\")) {
|
|
85
|
-
bad(".mcprc.template 渲染后仍含双反斜杠 —— YAML 双引号标量里 \\d \\U 是非法转义");
|
|
86
|
-
} else if (out.includes(rootYaml)) {
|
|
87
|
-
ok(".mcprc.template 渲染后为正斜杠路径");
|
|
88
|
-
} else {
|
|
89
|
-
bad(".mcprc.template 渲染后未找到正斜杠路径");
|
|
90
|
-
}
|
|
91
|
-
} catch (e) {
|
|
92
|
-
bad(".mcprc.template 读不到:" + e.message);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
console.log("▶ 反例确认:旧的裸替换写法必须确实产出非法 JSON");
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
const raw = readFileSync(join(ROOT, "ghost.json"), "utf8");
|
|
99
|
-
const oldOut = raw.replace(/__ROOT__/g, WIN_ROOT);
|
|
100
|
-
try {
|
|
101
|
-
JSON.parse(oldOut);
|
|
102
|
-
bad("旧的裸替换写法竟然能解析 —— 前提假设已变,门禁需重新评估");
|
|
103
|
-
} catch {
|
|
104
|
-
ok("旧的裸替换写法确实产出非法 JSON(本门禁守的正是这个)");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
console.log("▶ 源码一致性:client/carlos.js 必须用同样的转义方式");
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
const src = readFileSync(join(ROOT, "client", "carlos.js"), "utf8");
|
|
112
|
-
const usesJsonEscape = /JSON\.stringify\(ROOT_ABS\)\.slice\(1,\s*-1\)/.test(src);
|
|
113
|
-
const usesYamlSlash = /ROOT_ABS\.replace\(\/\\\\\/g,\s*"\/"\)/.test(src);
|
|
114
|
-
if (usesJsonEscape) ok("client/carlos.js 使用 JSON 转义渲染 ROOT");
|
|
115
|
-
else bad("client/carlos.js 未使用 JSON 转义渲染 ROOT —— 与本门禁不同源");
|
|
116
|
-
|
|
117
|
-
if (usesYamlSlash) ok("client/carlos.js 对 YAML 目标使用正斜杠");
|
|
118
|
-
else bad("client/carlos.js 未对 YAML 目标使用正斜杠 —— 与本门禁不同源");
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
console.log("");
|
|
122
|
-
if (fail) {
|
|
123
|
-
console.log(`❌ 模板渲染门禁失败:${pass} 通过 / ${fail} 失败`);
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
console.log(`✅ 模板渲染门禁全部通过(${pass} 条)`);
|
|
1
|
+
// 模板渲染合法性门禁
|
|
2
|
+
//
|
|
3
|
+
// 为什么需要(2026-11-13 实测事故):
|
|
4
|
+
// `carlos-flow init --target <platform>` 曾经用**裸字符串替换**把项目根路径塞进模板,
|
|
5
|
+
// 即不做任何转义地把路径原文替换进 JSON 字符串里。
|
|
6
|
+
// Windows 路径的原始反斜杠因此进了 JSON,产出形如
|
|
7
|
+
// "D:\dev-env\node-v22.23.4-win-x64\node_modules\carlos-flow/bridge/mcp-bridge.js"
|
|
8
|
+
// 其中 \d \n \v 都是**非法 JSON 转义序列** —— 配置文件根本解析不了,
|
|
9
|
+
// 表现为「安装成功但插件不出现」,而且任何解析器都报同一个位置。
|
|
10
|
+
// 现场文件 C:\Users\EDY\.cindy\ghosts\carlos-flow.json 就是这个状态。
|
|
11
|
+
// 正确写法见 client/carlos.js:JSON 目标用 JSON.stringify 转义,YAML 目标用正斜杠。
|
|
12
|
+
//
|
|
13
|
+
// 本门禁做的事:
|
|
14
|
+
// 用**真实的 Windows 路径**渲染全部模板,断言产物能被正确解析,
|
|
15
|
+
// 并且路径里的反斜杠没有丢失、没有变成非法转义。
|
|
16
|
+
//
|
|
17
|
+
// 运行:node scripts/check-templates.mjs
|
|
18
|
+
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
20
|
+
import { join, dirname } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
24
|
+
|
|
25
|
+
let pass = 0;
|
|
26
|
+
let fail = 0;
|
|
27
|
+
|
|
28
|
+
function ok(msg) {
|
|
29
|
+
pass++;
|
|
30
|
+
console.log(" ✅ " + msg);
|
|
31
|
+
}
|
|
32
|
+
function bad(msg) {
|
|
33
|
+
fail++;
|
|
34
|
+
console.log(" ❌ " + msg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 真实的 Windows 路径(含反斜杠、大写、子目录),用来复现事故现场
|
|
38
|
+
const WIN_ROOT = "D:\\dev-env\\node-v22.23.4-win-x64\\node_modules\\carlos-flow";
|
|
39
|
+
|
|
40
|
+
// 与 client/carlos.js 中的渲染逻辑保持一致(这是本门禁的关键:两处必须同源)
|
|
41
|
+
const rootJson = JSON.stringify(WIN_ROOT).slice(1, -1);
|
|
42
|
+
const rootYaml = WIN_ROOT.replace(/\\/g, "/");
|
|
43
|
+
|
|
44
|
+
console.log("▶ JSON 模板:Windows 路径渲染后必须可解析且路径无损");
|
|
45
|
+
|
|
46
|
+
const jsonTemplates = [
|
|
47
|
+
["ghost.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
48
|
+
["opencode.json.template", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
49
|
+
["templates/cursor/mcp.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
50
|
+
["templates/cline/mcp.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
51
|
+
["templates/vscode/mcp.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
52
|
+
["templates/claude/claude_desktop_config.json", (t) => t.replace(/__ROOT__/g, rootJson)],
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
for (const [rel, render] of jsonTemplates) {
|
|
56
|
+
let raw = "";
|
|
57
|
+
try {
|
|
58
|
+
raw = readFileSync(join(ROOT, rel), "utf8");
|
|
59
|
+
} catch {
|
|
60
|
+
bad(`${rel} 读不到`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (!raw.includes("__ROOT__")) {
|
|
64
|
+
bad(`${rel} 里没有 __ROOT__ 占位符 —— 渲染逻辑可能已失效,模板与代码脱节`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const out = render(raw);
|
|
68
|
+
try {
|
|
69
|
+
const parsed = JSON.parse(out);
|
|
70
|
+
ok(`${rel} 渲染后可解析`);
|
|
71
|
+
// 路径无损检查:反斜杠必须完好,不能变成 \\ 之外的任何形态
|
|
72
|
+
const found = JSON.stringify(parsed).includes("dev-env");
|
|
73
|
+
if (!found) bad(`${rel} 渲染后路径内容丢失`);
|
|
74
|
+
} catch (e) {
|
|
75
|
+
bad(`${rel} 渲染后无法解析:${e.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log("▶ YAML 模板:.mcprc 必须用正斜杠(反斜杠在 YAML 双引号里同样非法)");
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const raw = readFileSync(join(ROOT, ".mcprc.template"), "utf8");
|
|
83
|
+
const out = raw.replace(/__ROOT__/g, rootYaml);
|
|
84
|
+
if (out.includes("\\\\")) {
|
|
85
|
+
bad(".mcprc.template 渲染后仍含双反斜杠 —— YAML 双引号标量里 \\d \\U 是非法转义");
|
|
86
|
+
} else if (out.includes(rootYaml)) {
|
|
87
|
+
ok(".mcprc.template 渲染后为正斜杠路径");
|
|
88
|
+
} else {
|
|
89
|
+
bad(".mcprc.template 渲染后未找到正斜杠路径");
|
|
90
|
+
}
|
|
91
|
+
} catch (e) {
|
|
92
|
+
bad(".mcprc.template 读不到:" + e.message);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log("▶ 反例确认:旧的裸替换写法必须确实产出非法 JSON");
|
|
96
|
+
|
|
97
|
+
{
|
|
98
|
+
const raw = readFileSync(join(ROOT, "ghost.json"), "utf8");
|
|
99
|
+
const oldOut = raw.replace(/__ROOT__/g, WIN_ROOT);
|
|
100
|
+
try {
|
|
101
|
+
JSON.parse(oldOut);
|
|
102
|
+
bad("旧的裸替换写法竟然能解析 —— 前提假设已变,门禁需重新评估");
|
|
103
|
+
} catch {
|
|
104
|
+
ok("旧的裸替换写法确实产出非法 JSON(本门禁守的正是这个)");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log("▶ 源码一致性:client/carlos.js 必须用同样的转义方式");
|
|
109
|
+
|
|
110
|
+
{
|
|
111
|
+
const src = readFileSync(join(ROOT, "client", "carlos.js"), "utf8");
|
|
112
|
+
const usesJsonEscape = /JSON\.stringify\(ROOT_ABS\)\.slice\(1,\s*-1\)/.test(src);
|
|
113
|
+
const usesYamlSlash = /ROOT_ABS\.replace\(\/\\\\\/g,\s*"\/"\)/.test(src);
|
|
114
|
+
if (usesJsonEscape) ok("client/carlos.js 使用 JSON 转义渲染 ROOT");
|
|
115
|
+
else bad("client/carlos.js 未使用 JSON 转义渲染 ROOT —— 与本门禁不同源");
|
|
116
|
+
|
|
117
|
+
if (usesYamlSlash) ok("client/carlos.js 对 YAML 目标使用正斜杠");
|
|
118
|
+
else bad("client/carlos.js 未对 YAML 目标使用正斜杠 —— 与本门禁不同源");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
console.log("");
|
|
122
|
+
if (fail) {
|
|
123
|
+
console.log(`❌ 模板渲染门禁失败:${pass} 通过 / ${fail} 失败`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
console.log(`✅ 模板渲染门禁全部通过(${pass} 条)`);
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// 清理 README 中被重复注入的「语言栏 + 版本行」(只保留文档头部那一处)。
|
|
3
|
-
//
|
|
4
|
-
// 背景:早期版本用脚本给每个章节都插入了一行语言切换栏和版本行,
|
|
5
|
-
// 结果这些行被粘在 Markdown 表格行尾(如 `| ... |**语言 / Languages:** ...`),
|
|
6
|
-
// 破坏表格渲染,也让读者难以阅读。本脚本把它们收回到文档头部一处。
|
|
7
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
8
|
-
|
|
9
|
-
const NOISE = /\*\*语言 \/ Languages:\*\*|\*\*Language \/ Languages:\*\*|\*\*版本 \/ Version:\*\*|\*\*Version:\*\*/;
|
|
10
|
-
|
|
11
|
-
const files = process.argv.slice(2);
|
|
12
|
-
for (const f of files) {
|
|
13
|
-
const text = readFileSync(f, "utf8");
|
|
14
|
-
const lines = text.split("\n");
|
|
15
|
-
const out = [];
|
|
16
|
-
let navSeen = 0;
|
|
17
|
-
let verSeen = 0;
|
|
18
|
-
let removed = 0;
|
|
19
|
-
|
|
20
|
-
for (const line of lines) {
|
|
21
|
-
const isNav = /\*\*语言 \/ Languages:\*\*|\*\*Language \/ Languages:\*\*/.test(line);
|
|
22
|
-
const isVer = /\*\*版本 \/ Version:\*\*|\*\*Version:\*\*/.test(line);
|
|
23
|
-
|
|
24
|
-
if (isNav || isVer) {
|
|
25
|
-
const counter = isNav ? "nav" : "ver";
|
|
26
|
-
if (counter === "nav") navSeen += 1; else verSeen += 1;
|
|
27
|
-
const keepFirst = counter === "nav" ? navSeen === 1 : verSeen === 1;
|
|
28
|
-
if (!keepFirst) {
|
|
29
|
-
removed += 1;
|
|
30
|
-
// 若这一行还粘着表格内容,说明它是被拼到行尾的,把表格内容保留下来
|
|
31
|
-
const cleaned = line
|
|
32
|
-
.replace(/\*\*语言 \/ Languages:\*\*[^\n]*$/u, "")
|
|
33
|
-
.replace(/\*\*Language \/ Languages:\*\*[^\n]*$/u, "")
|
|
34
|
-
.replace(/\*\*版本 \/ Version:\*\*[^\n]*$/u, "")
|
|
35
|
-
.replace(/\*\*Version:\*\*[^\n]*$/u, "")
|
|
36
|
-
.trimEnd();
|
|
37
|
-
if (cleaned) out.push(cleaned);
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
out.push(line);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 折叠 3 个以上连续空行
|
|
45
|
-
const text2 = out.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
46
|
-
|
|
47
|
-
if (text2 !== text) {
|
|
48
|
-
writeFileSync(f, text2, "utf8");
|
|
49
|
-
console.log(`cleaned ${f}: removed ${removed} noise line(s)`);
|
|
50
|
-
} else {
|
|
51
|
-
console.log(`no change ${f}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 清理 README 中被重复注入的「语言栏 + 版本行」(只保留文档头部那一处)。
|
|
3
|
+
//
|
|
4
|
+
// 背景:早期版本用脚本给每个章节都插入了一行语言切换栏和版本行,
|
|
5
|
+
// 结果这些行被粘在 Markdown 表格行尾(如 `| ... |**语言 / Languages:** ...`),
|
|
6
|
+
// 破坏表格渲染,也让读者难以阅读。本脚本把它们收回到文档头部一处。
|
|
7
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
8
|
+
|
|
9
|
+
const NOISE = /\*\*语言 \/ Languages:\*\*|\*\*Language \/ Languages:\*\*|\*\*版本 \/ Version:\*\*|\*\*Version:\*\*/;
|
|
10
|
+
|
|
11
|
+
const files = process.argv.slice(2);
|
|
12
|
+
for (const f of files) {
|
|
13
|
+
const text = readFileSync(f, "utf8");
|
|
14
|
+
const lines = text.split("\n");
|
|
15
|
+
const out = [];
|
|
16
|
+
let navSeen = 0;
|
|
17
|
+
let verSeen = 0;
|
|
18
|
+
let removed = 0;
|
|
19
|
+
|
|
20
|
+
for (const line of lines) {
|
|
21
|
+
const isNav = /\*\*语言 \/ Languages:\*\*|\*\*Language \/ Languages:\*\*/.test(line);
|
|
22
|
+
const isVer = /\*\*版本 \/ Version:\*\*|\*\*Version:\*\*/.test(line);
|
|
23
|
+
|
|
24
|
+
if (isNav || isVer) {
|
|
25
|
+
const counter = isNav ? "nav" : "ver";
|
|
26
|
+
if (counter === "nav") navSeen += 1; else verSeen += 1;
|
|
27
|
+
const keepFirst = counter === "nav" ? navSeen === 1 : verSeen === 1;
|
|
28
|
+
if (!keepFirst) {
|
|
29
|
+
removed += 1;
|
|
30
|
+
// 若这一行还粘着表格内容,说明它是被拼到行尾的,把表格内容保留下来
|
|
31
|
+
const cleaned = line
|
|
32
|
+
.replace(/\*\*语言 \/ Languages:\*\*[^\n]*$/u, "")
|
|
33
|
+
.replace(/\*\*Language \/ Languages:\*\*[^\n]*$/u, "")
|
|
34
|
+
.replace(/\*\*版本 \/ Version:\*\*[^\n]*$/u, "")
|
|
35
|
+
.replace(/\*\*Version:\*\*[^\n]*$/u, "")
|
|
36
|
+
.trimEnd();
|
|
37
|
+
if (cleaned) out.push(cleaned);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
out.push(line);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 折叠 3 个以上连续空行
|
|
45
|
+
const text2 = out.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
46
|
+
|
|
47
|
+
if (text2 !== text) {
|
|
48
|
+
writeFileSync(f, text2, "utf8");
|
|
49
|
+
console.log(`cleaned ${f}: removed ${removed} noise line(s)`);
|
|
50
|
+
} else {
|
|
51
|
+
console.log(`no change ${f}`);
|
|
52
|
+
}
|
|
53
|
+
}
|