dsh-plain-talk 0.1.10 → 0.1.12

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/CHANGELOG.md CHANGED
@@ -1,58 +1,62 @@
1
- # 0.1.10
2
-
3
- - 字数统计按 README 中实际展示的文本重算;token 列注明为整轮合计(含思考与工具),避免与字数误读为同向。
4
-
5
- # 0.1.9
6
-
7
- - 默认改为关闭:点一下按钮才开启,避免把“已开启”误点成关闭。
8
- - 规则补充:工具调用之间的进度说明也用用户语言、一句话。
9
-
10
- # 0.1.8
11
-
12
- - 同步远端 README 修订(百分比与表格格式)。
13
-
14
- # 0.1.7
15
-
16
- - 以修正后的 README 重新发布(0.1.6 的包内 README 仍是旧版)。
17
-
18
- # 0.1.6
19
-
20
- - 字数与 token 表格加变化百分比。
21
-
22
- # 0.1.5
23
-
24
- - 英文 README 按中文原文重译。
25
- - 修复中文 README 的表格转义与 A2 单元格。
26
-
27
- # 0.1.4
28
-
29
- - README 输出对比改为逐案例表格(A1/A2、B1/B2、C1/C2),每行一对输出。
30
- - 词汇清单移除「内部代号」:代号不再入表,每次出现都按未知处理。
31
- - 开关图标按脸部尺寸对齐,开启/关闭不再一大一小。
32
-
33
-
34
- # 0.1.3
35
-
36
- - 关闭态图标换成微笑版本;插件图标同步更新。
37
-
38
- # 0.1.2
39
-
40
- - 输入框按钮改用聊天气泡笑脸图:开启时带声波,关闭时用插件图标本体。
41
- - 插件图标换成同一张笑脸(`icon.png`)。
42
-
43
- # 0.1.1
44
-
45
- - README 重写:只保留用户需要的信息,删除 npm 发布与收录流程说明。
46
- - 输出对比改为左右并列表格,场景重排为 A / B / C。
47
- - 示例代号改为中性占位符(EXP-7、DEV-1K、run-3),规则与自检提示同步。
48
- - README 顶部加入 banner。
49
-
50
- # 0.1.0
51
-
52
- - 输入框「说人话」开关:按会话记录,状态写入 `$DSH_HOME/plain-talk.json`,重启后保留。
53
- - 系统提示词区段:结论先行、默认 ≤12 行 / 300 字、禁回指、引用必须贴原文、代号首现解释、语言跟随用户。
54
- - `plain_talk_check`:发送前自检,报回指、内部信息、只给指针的引用、未解释代号、长度与列表问题。
55
- - `plain_talk_vocab`:读取与维护用户词汇清单,分常识 / 专业 / 项目 / 内部代号 / 待归类五类。
56
- - 「调研 X」两阶段学习:第一次回复把 X 当作未知,回合结束后才写入词汇清单。
57
- - `PLAIN_TALK_DEFAULT=off` 可让新会话默认关闭,用于基准测试或按需开启的用法。
58
- - 不写 session 事件;只写两个 sidecar JSON 文件。
1
+ # 0.1.12
2
+
3
+ - 回退规则正文到 0.1.10 版本:0.1.11 把带数字的硬上限(12 行/300 字、列表最多 5 条)替换成了“按需展开”“按需保留”这类软约束。
4
+ - 新增 `npm test`:离线自检 `test/selftest.mjs`,校验规则正文契约(长度上限唯一、列表规则唯一、禁令仍在)与检查器行为,防止同类软化再次发布。
5
+ # 0.1.10
6
+
7
+ - 字数统计按 README 中实际展示的文本重算;token 列注明为整轮合计(含思考与工具),避免与字数误读为同向。
8
+
9
+ # 0.1.9
10
+
11
+ - 默认改为关闭:点一下按钮才开启,避免把“已开启”误点成关闭。
12
+ - 规则补充:工具调用之间的进度说明也用用户语言、一句话。
13
+
14
+ # 0.1.8
15
+
16
+ - 同步远端 README 修订(百分比与表格格式)。
17
+
18
+ # 0.1.7
19
+
20
+ - 以修正后的 README 重新发布(0.1.6 的包内 README 仍是旧版)。
21
+
22
+ # 0.1.6
23
+
24
+ - 字数与 token 表格加变化百分比。
25
+
26
+ # 0.1.5
27
+
28
+ - 英文 README 按中文原文重译。
29
+ - 修复中文 README 的表格转义与 A2 单元格。
30
+
31
+ # 0.1.4
32
+
33
+ - README 输出对比改为逐案例表格(A1/A2、B1/B2、C1/C2),每行一对输出。
34
+ - 词汇清单移除「内部代号」:代号不再入表,每次出现都按未知处理。
35
+ - 开关图标按脸部尺寸对齐,开启/关闭不再一大一小。
36
+
37
+
38
+ # 0.1.3
39
+
40
+ - 关闭态图标换成微笑版本;插件图标同步更新。
41
+
42
+ # 0.1.2
43
+
44
+ - 输入框按钮改用聊天气泡笑脸图:开启时带声波,关闭时用插件图标本体。
45
+ - 插件图标换成同一张笑脸(`icon.png`)。
46
+
47
+ # 0.1.1
48
+
49
+ - README 重写:只保留用户需要的信息,删除 npm 发布与收录流程说明。
50
+ - 输出对比改为左右并列表格,场景重排为 A / B / C。
51
+ - 示例代号改为中性占位符(EXP-7、DEV-1K、run-3),规则与自检提示同步。
52
+ - README 顶部加入 banner。
53
+
54
+ # 0.1.0
55
+
56
+ - 输入框「说人话」开关:按会话记录,状态写入 `$DSH_HOME/plain-talk.json`,重启后保留。
57
+ - 系统提示词区段:结论先行、默认 ≤12 行 / 300 字、禁回指、引用必须贴原文、代号首现解释、语言跟随用户。
58
+ - `plain_talk_check`:发送前自检,报回指、内部信息、只给指针的引用、未解释代号、长度与列表问题。
59
+ - `plain_talk_vocab`:读取与维护用户词汇清单,分常识 / 专业 / 项目 / 内部代号 / 待归类五类。
60
+ - 「调研 X」两阶段学习:第一次回复把 X 当作未知,回合结束后才写入词汇清单。
61
+ - `PLAIN_TALK_DEFAULT=off` 可让新会话默认关闭,用于基准测试或按需开启的用法。
62
+ - 不写 session 事件;只写两个 sidecar JSON 文件。
package/dsh/rules.js CHANGED
@@ -1,46 +1,46 @@
1
- // The system-prompt section injected while "说人话" is on for the session.
2
- //
3
- // Design notes:
4
- // - The rules target the reader's cost, not the model's output length alone:
5
- // a short reply that still needs the previous turns is still unreadable.
6
- // - Numbers in the comment block below come from a scan of 197 real sessions
7
- // in this workspace (median 2,076 characters, 96% with unexplained codes,
8
- // 22% with back-references, 43% almost entirely English).
9
- // - Keep the text shorter than the replies it is meant to shorten.
10
-
11
- export const RULES = `# 说人话(回复优化)
12
-
13
- 读者只看这一条回复就要能做决定。先给结论,再给必要细节。
14
-
15
- ## 长度
16
- - 能一句说清就一句;默认不超过 12 行、300 字。用户明确要细节时放开深度,但结论仍在第一行。
17
- - 不写"好的/我来看看/让我先…/希望这有帮助";不复述问题;不汇报你准备怎么做。
18
- - 不写过程日记("我先…然后…")。只写结果、判断和可验证的事实。
19
- - 工具调用之间的进度说明同样适用:用用户的语言,一句话(≤2 行);不需要说明就直接调工具。
20
- - 列表最多 5 条;只给一个下一步。结尾不要问"还需要我做什么"。
21
-
22
- ## 自包含
23
- - 不用"上述/前面/之前提到的/上一轮/前者/后者/刚才";要指代就重说一遍。
24
- - 代号、任务号、版本号、提交号、模块名(如 EXP-7、DEV-1K、run-3)第一次出现时写清它是什么:EXP-7(把实例校验加进推理流程的实验编号)。之后可以直接用。
25
- - 但用户在本对话里用过的词、项目名、常见术语(arXiv、DOI、API、GPU 等)默认读者已经懂,不要解释,也不要改写成别的说法。
26
- - 用户让你"调研 / 研究 / 查一下 X"时,第一遍回复默认读者还不了解 X,先把它讲清楚;这条回复交付之后,X 才进入词汇清单。
27
- - 内部代号(EXP-7、DEV-1K、run-3 这类)不进入词汇清单:每次出现都按未知处理,第一次出现时解释。
28
- - 不出现会话号、子代理、父会话、工具名等内部信息。
29
-
30
- ## 引用与数字
31
- - 引用文件、日志、网页时直接贴出那几行原文;只给"文件名:行号"不算证据。
32
- - 数字给单位和对照:"61.2% → 63.8%",不写"明显提升"。
33
-
34
- ## 语言
35
- - 用用户最近一条消息的语言回复。思考过程可以用英文。
36
- - 代码、命令、路径、报错原文保持原样,不翻译、不缩写。
37
-
38
- ## 执行类回复
39
- 用户给过计划、任务清单或验收要求时,第一行给结论:达标 / 部分达标 / 未达标,并点明哪几条没达标。
40
- 验收标准只用用户原话,不自己发明。然后按顺序:做了什么 → 没做到什么 → 用户怎么自己确认(贴出应看到的内容)→ 一个下一步。
41
-
42
- ## 收尾自检
43
- 完成类回复或超过 12 行的回复,发送前调用 plain_talk_check;把 error 全部改掉,warn 逐条判断。
44
-
45
- ## 覆盖规则
46
- 用户说"展开讲/详细说明"时,保留结论先行,正文可以长。破坏性操作仍然先确认。harness 规则优先于本节。`;
1
+ // The system-prompt section injected while "说人话" is on for the session.
2
+ //
3
+ // Design notes:
4
+ // - The rules target the reader's cost, not the model's output length alone:
5
+ // a short reply that still needs the previous turns is still unreadable.
6
+ // - Numbers in the comment block below come from a scan of 197 real sessions
7
+ // in this workspace (median 2,076 characters, 96% with unexplained codes,
8
+ // 22% with back-references, 43% almost entirely English).
9
+ // - Keep the text shorter than the replies it is meant to shorten.
10
+
11
+ export const RULES = `# 说人话(回复优化)
12
+
13
+ 读者只看这一条回复就要能做决定。先给结论,再给必要细节。
14
+
15
+ ## 长度
16
+ - 能一句说清就一句;默认不超过 12 行、300 字。用户明确要细节时放开深度,但结论仍在第一行。
17
+ - 不写"好的/我来看看/让我先…/希望这有帮助";不复述问题;不汇报你准备怎么做。
18
+ - 不写过程日记("我先…然后…")。只写结果、判断和可验证的事实。
19
+ - 工具调用之间的进度说明同样适用:用用户的语言,一句话(≤2 行);不需要说明就直接调工具。
20
+ - 列表最多 5 条;只给一个下一步。结尾不要问"还需要我做什么"。
21
+
22
+ ## 自包含
23
+ - 不用"上述/前面/之前提到的/上一轮/前者/后者/刚才";要指代就重说一遍。
24
+ - 代号、任务号、版本号、提交号、模块名(如 EXP-7、DEV-1K、run-3)第一次出现时写清它是什么:EXP-7(把实例校验加进推理流程的实验编号)。之后可以直接用。
25
+ - 但用户在本对话里用过的词、项目名、常见术语(arXiv、DOI、API、GPU 等)默认读者已经懂,不要解释,也不要改写成别的说法。
26
+ - 用户让你"调研 / 研究 / 查一下 X"时,第一遍回复默认读者还不了解 X,先把它讲清楚;这条回复交付之后,X 才进入词汇清单。
27
+ - 内部代号(EXP-7、DEV-1K、run-3 这类)不进入词汇清单:每次出现都按未知处理,第一次出现时解释。
28
+ - 不出现会话号、子代理、父会话、工具名等内部信息。
29
+
30
+ ## 引用与数字
31
+ - 引用文件、日志、网页时直接贴出那几行原文;只给"文件名:行号"不算证据。
32
+ - 数字给单位和对照:"61.2% → 63.8%",不写"明显提升"。
33
+
34
+ ## 语言
35
+ - 用用户最近一条消息的语言回复。思考过程可以用英文。
36
+ - 代码、命令、路径、报错原文保持原样,不翻译、不缩写。
37
+
38
+ ## 执行类回复
39
+ 用户给过计划、任务清单或验收要求时,第一行给结论:达标 / 部分达标 / 未达标,并点明哪几条没达标。
40
+ 验收标准只用用户原话,不自己发明。然后按顺序:做了什么 → 没做到什么 → 用户怎么自己确认(贴出应看到的内容)→ 一个下一步。
41
+
42
+ ## 收尾自检
43
+ 完成类回复或超过 12 行的回复,发送前调用 plain_talk_check;把 error 全部改掉,warn 逐条判断。
44
+
45
+ ## 覆盖规则
46
+ 用户说"展开讲/详细说明"时,保留结论先行,正文可以长。破坏性操作仍然先确认。harness 规则优先于本节。`;
package/package.json CHANGED
@@ -1,56 +1,60 @@
1
- {
2
- "name": "dsh-plain-talk",
3
- "version": "0.1.10",
4
- "description": "Composer toggle that shapes replies: conclusion first, inline quotes, no cross-turn references",
5
- "type": "module",
6
- "license": "MIT",
7
- "keywords": [
8
- "dsh",
9
- "dsh-plugin",
10
- "deepseek-harness",
11
- "reply",
12
- "readability",
13
- "concision",
14
- "composer"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/lizilong1993/dsh-plain-talk.git"
19
- },
20
- "homepage": "https://github.com/lizilong1993/dsh-plain-talk",
21
- "bugs": {
22
- "url": "https://github.com/lizilong1993/dsh-plain-talk/issues"
23
- },
24
- "files": [
25
- "dsh",
26
- "lib",
27
- "cordis.patch.yml",
28
- "locale/*.json",
29
- "icon.png",
30
- "README.md",
31
- "README.en.md",
32
- "CHANGELOG.md",
33
- "LICENSE"
34
- ],
35
- "exports": {
36
- ".": "./dsh/index.js",
37
- "./client": "./lib/client.js",
38
- "./rules": "./dsh/rules.js",
39
- "./check": "./dsh/check.js",
40
- "./locale/*.json": "./locale/*.json",
41
- "./icon": "./icon.png",
42
- "./package.json": "./package.json"
43
- },
44
- "engines": {
45
- "node": ">=20"
46
- },
47
- "dsh": {
48
- "bundle": {
49
- "patch": "./cordis.patch.yml"
50
- },
51
- "client": {
52
- "platform": "web",
53
- "immediately": true
54
- }
55
- }
56
- }
1
+ {
2
+ "name": "dsh-plain-talk",
3
+ "version": "0.1.12",
4
+ "description": "Composer toggle that shapes replies: conclusion first, inline quotes, no cross-turn references",
5
+ "scripts": {
6
+ "test": "node test/selftest.mjs"
7
+ },
8
+ "type": "module",
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "dsh",
12
+ "dsh-plugin",
13
+ "deepseek-harness",
14
+ "reply",
15
+ "readability",
16
+ "concision",
17
+ "composer"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/lizilong1993/dsh-plain-talk.git"
22
+ },
23
+ "homepage": "https://github.com/lizilong1993/dsh-plain-talk",
24
+ "bugs": {
25
+ "url": "https://github.com/lizilong1993/dsh-plain-talk/issues"
26
+ },
27
+ "files": [
28
+ "dsh",
29
+ "lib",
30
+ "cordis.patch.yml",
31
+ "locale/*.json",
32
+ "icon.png",
33
+ "README.md",
34
+ "README.en.md",
35
+ "CHANGELOG.md",
36
+ "LICENSE",
37
+ "test"
38
+ ],
39
+ "exports": {
40
+ ".": "./dsh/index.js",
41
+ "./client": "./lib/client.js",
42
+ "./rules": "./dsh/rules.js",
43
+ "./check": "./dsh/check.js",
44
+ "./locale/*.json": "./locale/*.json",
45
+ "./icon": "./icon.png",
46
+ "./package.json": "./package.json"
47
+ },
48
+ "engines": {
49
+ "node": ">=20"
50
+ },
51
+ "dsh": {
52
+ "bundle": {
53
+ "patch": "./cordis.patch.yml"
54
+ },
55
+ "client": {
56
+ "platform": "web",
57
+ "immediately": true
58
+ }
59
+ }
60
+ }
package/test/REPORT.md ADDED
@@ -0,0 +1,64 @@
1
+ # 0.1.11 效果实测
2
+
3
+ ## 结论先说
4
+
5
+ 1. 0.1.11 的改写方向没有被证据支持:同一模型下,0.1.11 在 4/4 个问题上中位字数都更长;但这个网关的采样噪声远大于版本差异,样本量不足以声称显著变差。
6
+ 2. 我之前的说法有过头的地方:0.1.11 不是"新旧条款并列矛盾",它只是把那三句替换了。真正的问题是替换后带数字的硬上限(12 行/300 字、列表最多 5 条)变成了"按需展开""按需保留"这类软约束。
7
+ 3. 本次发布回退到 0.1.10 的规则正文,并补了离线自检 npm test,防止同类软化再被发布。
8
+
9
+ ## 先量噪声(这一步之前漏了)
10
+
11
+ 同一份规则、同一个问题,连跑 4 次,输出字数:
12
+
13
+ | 问题 | 0.1.10 四次采样 | 极差 |
14
+ | --- | --- | --- |
15
+ | Nginx 502/504 | 345 / 176 / 326 / 243 | 169 |
16
+ | git push non-fast-forward | 352 / 258 / 319 / 274 | 94 |
17
+ | WebAssembly 调研 | 50 / 364 / 385 / 382 | 335 |
18
+ | CPU 打满排查 | 478 / 508 / 410 / 496 | 98 |
19
+
20
+ 同一版本内部极差最大 335 字,跨题最大 1402 字(WebAssembly 那题 0.1.11 采样为 741/962/862/2143)。tempterature=0 在这个网关上并不保证可复现。
21
+
22
+ ## 版本对比(中位数)
23
+
24
+ | 问题 | 0.1.10 中位 | 0.1.11 中位 | 差值 |
25
+ | --- | --- | --- | --- |
26
+ | Nginx 502/504 | 285 | 361 | +76 |
27
+ | git push | 297 | 515 | +218 |
28
+ | WebAssembly | 373 | 912 | +539 |
29
+ | CPU 打满 | 487 | 677 | +190 |
30
+
31
+ 4/4 同向偏长,平均 +256 字。噪声底(单版本内极差)达 1402 字,所以只能说"方向一致地变长",不能据此宣称统计显著。
32
+
33
+ ## 规则正文的实际差异
34
+
35
+ 逐行对比 npm 0.1.10 与 0.1.11 的 dsh/rules.js,只有三行不同:
36
+
37
+ | 项 | 0.1.10 | 0.1.11 |
38
+ | --- | --- | --- |
39
+ | 结论 | 先给结论,再给必要细节 | 第一句直接回答最关心的事…直接给成品 |
40
+ | 长度 | 默认不超过 12 行、300 字 | 普通回复以 12 行、300 字以内为参考;需要完整步骤…按任务需要展开 |
41
+ | 列表 | 列表最多 5 条;只给一个下一步 | 用列表呈现并列项,按需保留完整条目…答完就停 |
42
+
43
+ 后两行把唯一的数字上限换成软表述,这是可验证的规则退化,不依赖采样。
44
+
45
+ ## 处理
46
+
47
+ - dsh/rules.js 回退到 0.1.10 正文(与 npm 0.1.10 逐字节一致,1596 字节)
48
+ - npm test:17 项离线断言,其中包含"长度上限与列表上限各只有一种说法且带数字"
49
+ - 新版发布此回退
50
+
51
+ ## 怎么复现
52
+
53
+ ```bash
54
+ npm test # 离线契约检查,不需要模型
55
+ node test/noise.mjs # 采样噪声(约 32 次生成)
56
+ node test/bench.mjs --versions 0.1.10,0.1.11 # 版本对照
57
+ node test/determinism.mjs # 同输入多次调用是否一致
58
+ ```
59
+
60
+ test/bench.mjs 直接从 npm 拉指定版本的规则正文,不依赖本地仓库状态。
61
+
62
+ ## 遗留问题
63
+
64
+ 噪声这么大,单靠这个本地网关做不了可靠的效果判定。要真正评估提示词改动,需要:固定随机种子或可复现的推理后端、每臂 20+ 采样、并用配对统计而不是均值比较。
@@ -0,0 +1,281 @@
1
+ {
2
+ "summary": {
3
+ "versions": [
4
+ "0.1.10",
5
+ "0.1.11"
6
+ ],
7
+ "reps": 1,
8
+ "questions": 12,
9
+ "runs": 24,
10
+ "model": "group/free",
11
+ "arms": {
12
+ "0.1.10": {
13
+ "n": 12,
14
+ "avgChars": 345,
15
+ "avgLines": 5.9,
16
+ "errors": 0,
17
+ "warns": 10
18
+ },
19
+ "0.1.11": {
20
+ "n": 12,
21
+ "avgChars": 381,
22
+ "avgLines": 7.7,
23
+ "errors": 2,
24
+ "warns": 15
25
+ }
26
+ },
27
+ "pairs": {
28
+ "0.1.10/0.1.11": {
29
+ "n": 12,
30
+ "charsDelta": 434,
31
+ "warnsDelta": 5,
32
+ "shorter": 4,
33
+ "longer": 7,
34
+ "avgCharsDelta": 36,
35
+ "avgWarnsDelta": 0.42
36
+ }
37
+ }
38
+ },
39
+ "rows": [
40
+ {
41
+ "q": 1,
42
+ "rep": 1,
43
+ "version": "0.1.10",
44
+ "chars": 666,
45
+ "lines": 10,
46
+ "errors": 0,
47
+ "warns": 2,
48
+ "firstLine": "**Liveness Probe(存活探针)**:判断容器是否**还活着**。失败 → kubelet **杀掉并重启*"
49
+ },
50
+ {
51
+ "q": 1,
52
+ "rep": 1,
53
+ "version": "0.1.11",
54
+ "chars": 963,
55
+ "lines": 30,
56
+ "errors": 0,
57
+ "warns": 2,
58
+ "firstLine": "一句话:liveness 探针决定\"要不要重启容器\",readiness 探针决定\"要不要把流量发给这个 Pod\"。"
59
+ },
60
+ {
61
+ "q": 2,
62
+ "rep": 1,
63
+ "version": "0.1.10",
64
+ "chars": 346,
65
+ "lines": 9,
66
+ "errors": 0,
67
+ "warns": 0,
68
+ "firstLine": "被拒绝是因为远程分支有本地没有的提交,直接推送会覆盖远程提交,Git 拒绝以防丢数据。"
69
+ },
70
+ {
71
+ "q": 2,
72
+ "rep": 1,
73
+ "version": "0.1.11",
74
+ "chars": 143,
75
+ "lines": 1,
76
+ "errors": 0,
77
+ "warns": 0,
78
+ "firstLine": "因为远端分支上有你本地没有的提交,导致推送会使历史出现非快进(non‑fast‑forward),git 为防止意外覆盖"
79
+ },
80
+ {
81
+ "q": 3,
82
+ "rep": 1,
83
+ "version": "0.1.10",
84
+ "chars": 28,
85
+ "lines": 1,
86
+ "errors": 0,
87
+ "warns": 0,
88
+ "firstLine": "它只在组件首次渲染时运行一次。后续的重新渲染不会触发它。"
89
+ },
90
+ {
91
+ "q": 3,
92
+ "rep": 1,
93
+ "version": "0.1.11",
94
+ "chars": 339,
95
+ "lines": 4,
96
+ "errors": 0,
97
+ "warns": 1,
98
+ "firstLine": "在 React 的 `useEffect` 中,如果你把第二个参数(依赖数组)留空,或者写成 `undefined`,它"
99
+ },
100
+ {
101
+ "q": 4,
102
+ "rep": 1,
103
+ "version": "0.1.10",
104
+ "chars": 214,
105
+ "lines": 6,
106
+ "errors": 0,
107
+ "warns": 1,
108
+ "firstLine": "MySQL 索引失效的常见原因有以下几类。 "
109
+ },
110
+ {
111
+ "q": 4,
112
+ "rep": 1,
113
+ "version": "0.1.11",
114
+ "chars": 408,
115
+ "lines": 9,
116
+ "errors": 0,
117
+ "warns": 2,
118
+ "firstLine": "MySQL 索引失效的常见原因:"
119
+ },
120
+ {
121
+ "q": 5,
122
+ "rep": 1,
123
+ "version": "0.1.10",
124
+ "chars": 201,
125
+ "lines": 3,
126
+ "errors": 0,
127
+ "warns": 1,
128
+ "firstLine": "**结论**:这行日志说明进程因为内存耗尽而被操作系统强制杀掉(OOMKilled),对应的退出码是 137,即 SIG"
129
+ },
130
+ {
131
+ "q": 5,
132
+ "rep": 1,
133
+ "version": "0.1.11",
134
+ "chars": 556,
135
+ "lines": 9,
136
+ "errors": 0,
137
+ "warns": 2,
138
+ "firstLine": "OOMKilled exit code 137 means the process was killed by the "
139
+ },
140
+ {
141
+ "q": 6,
142
+ "rep": 1,
143
+ "version": "0.1.10",
144
+ "chars": 71,
145
+ "lines": 1,
146
+ "errors": 0,
147
+ "warns": 0,
148
+ "firstLine": "第一步:运行 `vue-upgrade` 命令扫描你的 Vue 2 项目,它会生成一份报告,列出需要手动修复的兼容性问题"
149
+ },
150
+ {
151
+ "q": 6,
152
+ "rep": 1,
153
+ "version": "0.1.11",
154
+ "chars": 524,
155
+ "lines": 11,
156
+ "errors": 0,
157
+ "warns": 1,
158
+ "firstLine": "**第一步:跑通 `vue-migration-build`(迁移构建版),把所有兼容模式警告清零。**"
159
+ },
160
+ {
161
+ "q": 7,
162
+ "rep": 1,
163
+ "version": "0.1.10",
164
+ "chars": 420,
165
+ "lines": 9,
166
+ "errors": 0,
167
+ "warns": 1,
168
+ "firstLine": "结论:WebAssembly 目前最适合浏览器内的计算密集型任务,以及服务器端的轻量级沙箱与插件扩展;不适合替代 Jav"
169
+ },
170
+ {
171
+ "q": 7,
172
+ "rep": 1,
173
+ "version": "0.1.11",
174
+ "chars": 420,
175
+ "lines": 7,
176
+ "errors": 0,
177
+ "warns": 2,
178
+ "firstLine": "WebAssembly(Wasm)当前最适合以下场景:"
179
+ },
180
+ {
181
+ "q": 8,
182
+ "rep": 1,
183
+ "version": "0.1.10",
184
+ "chars": 803,
185
+ "lines": 7,
186
+ "errors": 0,
187
+ "warns": 1,
188
+ "firstLine": "按可能性从高到低排查:"
189
+ },
190
+ {
191
+ "q": 8,
192
+ "rep": 1,
193
+ "version": "0.1.11",
194
+ "chars": 98,
195
+ "lines": 1,
196
+ "errors": 0,
197
+ "warns": 1,
198
+ "firstLine": "CPU 100%可能性从高到低排序:1.后台进程/服务异常 2.恶意软件/病毒 3.驱动程序冲突/过时 4.应用程序死循"
199
+ },
200
+ {
201
+ "q": 9,
202
+ "rep": 1,
203
+ "version": "0.1.10",
204
+ "chars": 394,
205
+ "lines": 8,
206
+ "errors": 0,
207
+ "warns": 1,
208
+ "firstLine": "Postgres VACUUM 必须定期运行,因为它会回收已删除的行(dead tuple)、更新统计信息、防止表膨胀并"
209
+ },
210
+ {
211
+ "q": 9,
212
+ "rep": 1,
213
+ "version": "0.1.11",
214
+ "chars": 434,
215
+ "lines": 6,
216
+ "errors": 0,
217
+ "warns": 2,
218
+ "firstLine": "PostgreSQL 的 **VACUUM**(或自动化的 `autovacuum`)每隔一段时间运行,是为了清理死数据"
219
+ },
220
+ {
221
+ "q": 10,
222
+ "rep": 1,
223
+ "version": "0.1.10",
224
+ "chars": 61,
225
+ "lines": 2,
226
+ "errors": 0,
227
+ "warns": 0,
228
+ "firstLine": "没收到要修改的 SQL,所以没法给出改后的索引版本。"
229
+ },
230
+ {
231
+ "q": 10,
232
+ "rep": 1,
233
+ "version": "0.1.11",
234
+ "chars": 22,
235
+ "lines": 1,
236
+ "errors": 0,
237
+ "warns": 0,
238
+ "firstLine": "请把 SQL 贴过来,我直接给你改好的版本。"
239
+ },
240
+ {
241
+ "q": 11,
242
+ "rep": 1,
243
+ "version": "0.1.10",
244
+ "chars": 232,
245
+ "lines": 3,
246
+ "errors": 0,
247
+ "warns": 1,
248
+ "firstLine": "**502 Bad Gateway**:Nginx 作为代理,从上游服务器(比如后端应用、PHP-FPM)收到了一个它认"
249
+ },
250
+ {
251
+ "q": 11,
252
+ "rep": 1,
253
+ "version": "0.1.11",
254
+ "chars": 619,
255
+ "lines": 9,
256
+ "errors": 1,
257
+ "warns": 1,
258
+ "firstLine": "**502 Bad Gateway**:Nginx 作为反向代理,成功连上了上游,但上游返回的响应**不合法或无法解析*"
259
+ },
260
+ {
261
+ "q": 12,
262
+ "rep": 1,
263
+ "version": "0.1.10",
264
+ "chars": 707,
265
+ "lines": 12,
266
+ "errors": 0,
267
+ "warns": 2,
268
+ "firstLine": "**结论**:OpenTelemetry 通过统一标准和生态,能将埋点接入成本从“每个项目自建”降低到“统一接入”,适合"
269
+ },
270
+ {
271
+ "q": 12,
272
+ "rep": 1,
273
+ "version": "0.1.11",
274
+ "chars": 51,
275
+ "lines": 4,
276
+ "errors": 1,
277
+ "warns": 1,
278
+ "firstLine": "{"
279
+ }
280
+ ]
281
+ }
package/test/bench.mjs ADDED
@@ -0,0 +1,172 @@
1
+ // 可复现的效果对照:把 npm 上指定版本的规则正文拉下来,用同一组问题分别生成,配对比较。
2
+ //
3
+ // 用法:
4
+ // node test/bench.mjs --versions 0.1.10,0.1.11 --reps 3
5
+ // node test/bench.mjs --versions 0.1.10,0.1.12
6
+ //
7
+ // 需要本地模型网关(默认 http://127.0.0.1:3425/v1/chat/completions),可用 --endpoint 覆盖。
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import os from 'node:os';
11
+ import { execFileSync } from 'node:child_process';
12
+ import { analyze } from '../dsh/check.js';
13
+
14
+ const args = process.argv.slice(2);
15
+ const opt = (name, fallback) => {
16
+ const i = args.indexOf('--' + name);
17
+ return i >= 0 && args[i + 1] ? args[i + 1] : fallback;
18
+ };
19
+ const VERSIONS = opt('versions', '0.1.10,0.1.11').split(',').map((s) => s.trim()).filter(Boolean);
20
+ const REPS = Number(opt('reps', '1'));
21
+ const ENDPOINT = opt('endpoint', 'http://127.0.0.1:3425/v1/chat/completions');
22
+ const MODEL = opt('model', 'group/free');
23
+
24
+ const QUESTIONS = [
25
+ 'Kubernetes 的 liveness 和 readiness 探针有什么区别?',
26
+ '为什么 git push 会被拒绝 non-fast-forward?',
27
+ 'React 的 useEffect 依赖数组留空会怎样?',
28
+ 'MySQL 索引失效常见的原因有哪些?',
29
+ '这段日志什么意思:OOMKilled exit code 137',
30
+ '我要从 Vue2 迁到 Vue3,先做哪一步?',
31
+ '调研一下 WebAssembly 现在适合用在什么场景。',
32
+ '线上 CPU 突然打满,按可能性从高到低给我排查顺序。',
33
+ 'Postgres 的 vacuum 为什么必须定期跑?',
34
+ '帮我把这段 SQL 改成走索引,只给改后的语句。',
35
+ 'Nginx 502 和 504 分别说明什么?',
36
+ '调研一下 OpenTelemetry 相比自建埋点的取舍。',
37
+ ];
38
+
39
+ const BT = String.fromCharCode(96);
40
+ const bodyOf = (src) => {
41
+ const s = src.replace(/\r\n/g, '\n');
42
+ const i = s.indexOf(BT);
43
+ const j = s.indexOf(BT, i + 1);
44
+ if (i < 0 || j <= i) throw new Error('rule body not found');
45
+ return s.slice(i + 1, j);
46
+ };
47
+
48
+ // 取指定版本已发布的规则正文;本地未发布时用 --local <version> 直接读工作区
49
+ function rulesOf(version) {
50
+ const dir = path.join(os.tmpdir(), 'plain-talk-bench', version);
51
+ const file = path.join(dir, 'rules.js');
52
+ if (fs.existsSync(file)) return bodyOf(fs.readFileSync(file, 'utf8'));
53
+ fs.mkdirSync(dir, { recursive: true });
54
+ const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
55
+ execFileSync(npm, ['pack', 'dsh-plain-talk@' + version, '--pack-destination', dir], {
56
+ stdio: 'ignore',
57
+ shell: process.platform === 'win32',
58
+ });
59
+ const tgz = fs.readdirSync(dir).find((f) => f.endsWith('.tgz'));
60
+ if (!tgz) throw new Error('pack failed for ' + version);
61
+ execFileSync('tar', ['-xzf', path.join(dir, tgz), '-C', dir], { stdio: 'ignore' });
62
+ const inner = path.join(dir, 'package', 'dsh', 'rules.js');
63
+ const body = bodyOf(fs.readFileSync(inner, 'utf8'));
64
+ fs.writeFileSync(file, 'export const RULES = ' + BT + body + BT + ';\n', 'utf8');
65
+ return body;
66
+ }
67
+
68
+ const call = async (system, user) => {
69
+ const res = await fetch(ENDPOINT, {
70
+ method: 'POST',
71
+ headers: { 'content-type': 'application/json' },
72
+ body: JSON.stringify({
73
+ model: MODEL,
74
+ temperature: 0,
75
+ messages: [
76
+ { role: 'system', content: system },
77
+ { role: 'user', content: user },
78
+ ],
79
+ }),
80
+ });
81
+ if (!res.ok) throw new Error('http ' + res.status + ' ' + (await res.text()).slice(0, 160));
82
+ const json = await res.json();
83
+ const text = json.choices?.[0]?.message?.content;
84
+ if (!text) throw new Error('empty completion');
85
+ return text;
86
+ };
87
+
88
+ const score = (text) => {
89
+ const r = analyze(text, { language: 'zh' });
90
+ return {
91
+ chars: r.stats.chars,
92
+ lines: r.stats.lines,
93
+ errors: r.issues.filter((i) => i.severity === 'error').length,
94
+ warns: r.issues.filter((i) => i.severity === 'warn').length,
95
+ firstLine: text.trim().split(/\n/)[0].slice(0, 60),
96
+ };
97
+ };
98
+
99
+ const arms = VERSIONS.map((v) => ({ version: v, rules: rulesOf(v) }));
100
+ const rows = [];
101
+ for (let q = 0; q < QUESTIONS.length; q++) {
102
+ for (let rep = 1; rep <= REPS; rep++) {
103
+ for (const arm of arms) {
104
+ try {
105
+ rows.push({ q: q + 1, rep, version: arm.version, ...score(await call(arm.rules, QUESTIONS[q])) });
106
+ } catch (e) {
107
+ rows.push({ q: q + 1, rep, version: arm.version, error: e.message });
108
+ }
109
+ }
110
+ process.stdout.write('.');
111
+ }
112
+ }
113
+ process.stdout.write('\n');
114
+
115
+ const agg = (version) => {
116
+ const xs = rows.filter((r) => r.version === version && !r.error);
117
+ if (!xs.length) return { n: 0 };
118
+ const s = (k) => xs.reduce((p, b) => p + b[k], 0);
119
+ return {
120
+ n: xs.length,
121
+ avgChars: Math.round(s('chars') / xs.length),
122
+ avgLines: +(s('lines') / xs.length).toFixed(1),
123
+ errors: s('errors'),
124
+ warns: s('warns'),
125
+ };
126
+ };
127
+
128
+ // 配对:同一题、同一轮次,比较字数与 warn
129
+ const pairs = [];
130
+ for (let q = 1; q <= QUESTIONS.length; q++) {
131
+ for (let rep = 1; rep <= REPS; rep++) {
132
+ const xs = rows.filter((r) => r.q === q && r.rep === rep && !r.error);
133
+ if (xs.length < 2) continue;
134
+ for (let i = 0; i < xs.length; i++) for (let j = i + 1; j < xs.length; j++) {
135
+ pairs.push({
136
+ pair: xs[i].version + '/' + xs[j].version,
137
+ chars: xs[j].chars - xs[i].chars,
138
+ warns: xs[j].warns - xs[i].warns,
139
+ });
140
+ }
141
+ }
142
+ }
143
+ const pairSummary = {};
144
+ for (const p of pairs) {
145
+ const acc = (pairSummary[p.pair] = pairSummary[p.pair] || { n: 0, charsDelta: 0, warnsDelta: 0, shorter: 0, longer: 0 });
146
+ acc.n++;
147
+ acc.charsDelta += p.chars; // >0 表示后者更长
148
+ acc.warnsDelta += p.warns;
149
+ if (p.chars > 0) acc.longer++;
150
+ else if (p.chars < 0) acc.shorter++;
151
+ }
152
+ for (const k of Object.keys(pairSummary)) {
153
+ const a = pairSummary[k];
154
+ a.avgCharsDelta = Math.round(a.charsDelta / a.n);
155
+ a.avgWarnsDelta = +(a.warnsDelta / a.n).toFixed(2);
156
+ }
157
+
158
+ const summary = {
159
+ versions: VERSIONS,
160
+ reps: REPS,
161
+ questions: QUESTIONS.length,
162
+ runs: rows.filter((r) => !r.error).length,
163
+ model: MODEL,
164
+ arms: Object.fromEntries(VERSIONS.map((v) => [v, agg(v)]).filter(([, a]) => a.n)),
165
+ pairs: pairSummary,
166
+ };
167
+ console.log('=== SUMMARY ===');
168
+ console.log(JSON.stringify(summary, null, 1));
169
+
170
+ const out = 'test/bench-result.json';
171
+ fs.writeFileSync(out, JSON.stringify({ summary, rows }, null, 2), 'utf8');
172
+ console.log('\nwritten ' + out);
@@ -0,0 +1,21 @@
1
+ // 判定网关是否可复现:同一 system+user 连续调用 3 次,比较输出。
2
+ const ENDPOINT = 'http://127.0.0.1:3425/v1/chat/completions';
3
+ const sys = '读者只看这一条回复就要能做决定。先给结论,再给必要细节。默认不超过 12 行、300 字。';
4
+ const user = 'Nginx 502 和 504 分别说明什么?';
5
+
6
+ const call = async () => {
7
+ const res = await fetch(ENDPOINT, {
8
+ method: 'POST',
9
+ headers: { 'content-type': 'application/json' },
10
+ body: JSON.stringify({ model: 'group/free', temperature: 0, messages: [{ role: 'system', content: sys }, { role: 'user', content: user }] }),
11
+ });
12
+ const j = await res.json();
13
+ return j.choices?.[0]?.message?.content ?? '';
14
+ };
15
+
16
+ const outs = [];
17
+ for (let i = 0; i < 3; i++) outs.push(await call());
18
+ console.log('lengths:', outs.map((o) => o.length).join(', '));
19
+ console.log('identical:', outs[0] === outs[1] && outs[1] === outs[2]);
20
+ console.log('unique outputs:', new Set(outs).size);
21
+ for (const [i, o] of outs.entries()) console.log('--- run ' + (i + 1) + ' ---\n' + o.slice(0, 220));
@@ -0,0 +1,58 @@
1
+ {
2
+ "data": {
3
+ "v0.1.10": {
4
+ "Nginx 502 和 504 分别说明什么?": [
5
+ 345,
6
+ 176,
7
+ 326,
8
+ 243
9
+ ],
10
+ "为什么 git push 会被拒绝 non-fast-forward?": [
11
+ 352,
12
+ 258,
13
+ 319,
14
+ 274
15
+ ],
16
+ "调研一下 WebAssembly 现在适合用在什么场景。": [
17
+ 50,
18
+ 364,
19
+ 385,
20
+ 382
21
+ ],
22
+ "线上 CPU 突然打满,按可能性从高到低给我排查顺序。": [
23
+ 478,
24
+ 508,
25
+ 410,
26
+ 496
27
+ ]
28
+ },
29
+ "v0.1.11": {
30
+ "Nginx 502 和 504 分别说明什么?": [
31
+ 384,
32
+ 361,
33
+ 361,
34
+ 346
35
+ ],
36
+ "为什么 git push 会被拒绝 non-fast-forward?": [
37
+ 428,
38
+ 225,
39
+ 601,
40
+ 724
41
+ ],
42
+ "调研一下 WebAssembly 现在适合用在什么场景。": [
43
+ 741,
44
+ 962,
45
+ 862,
46
+ 2143
47
+ ],
48
+ "线上 CPU 突然打满,按可能性从高到低给我排查顺序。": [
49
+ 1104,
50
+ 538,
51
+ 691,
52
+ 663
53
+ ]
54
+ }
55
+ },
56
+ "noiseFloor": 1402,
57
+ "meanDiff": 256
58
+ }
package/test/noise.mjs ADDED
@@ -0,0 +1,77 @@
1
+ // 先量噪声底:同一规则、同一问题重复采样,看字数波动有多大;
2
+ // 再比两版规则的中位数差,判断差异是否超过噪声。
3
+ import fs from 'node:fs';
4
+ import { analyze } from '../dsh/check.js';
5
+
6
+ const bt = String.fromCharCode(96);
7
+ const bodyOf = (p) => {
8
+ const s = fs.readFileSync(p, 'utf8').replace(/\r\n/g, '\n');
9
+ const i = s.indexOf(bt);
10
+ const j = s.indexOf(bt, i + 1);
11
+ return s.slice(i + 1, j);
12
+ };
13
+ const base = 'C:/Users/lizilong/AppData/Local/Temp/pt-verify';
14
+ const ARMS = [
15
+ ['v0.1.10', bodyOf(base + '/pkg-0.1.10/package/dsh/rules.js')],
16
+ ['v0.1.11', bodyOf(base + '/pkg-0.1.11/package/dsh/rules.js')],
17
+ ];
18
+ const QUESTIONS = [
19
+ 'Nginx 502 和 504 分别说明什么?',
20
+ '为什么 git push 会被拒绝 non-fast-forward?',
21
+ '调研一下 WebAssembly 现在适合用在什么场景。',
22
+ '线上 CPU 突然打满,按可能性从高到低给我排查顺序。',
23
+ ];
24
+ const N = 4; // 每臂每题采样次数
25
+
26
+ const call = async (system, user) => {
27
+ const res = await fetch('http://127.0.0.1:3425/v1/chat/completions', {
28
+ method: 'POST',
29
+ headers: { 'content-type': 'application/json' },
30
+ body: JSON.stringify({ model: 'group/free', temperature: 0, messages: [{ role: 'system', content: system }, { role: 'user', content: user }] }),
31
+ });
32
+ if (!res.ok) throw new Error('http ' + res.status);
33
+ const j = await res.json();
34
+ return j.choices?.[0]?.message?.content ?? '';
35
+ };
36
+ const chars = (t) => analyze(t, { language: 'zh' }).stats.chars;
37
+
38
+ const data = {};
39
+ for (const [armName, rules] of ARMS) {
40
+ for (const q of QUESTIONS) {
41
+ data[armName] = data[armName] || {};
42
+ data[armName][q] = [];
43
+ for (let i = 0; i < N; i++) data[armName][q].push(chars(await call(rules, q)));
44
+ process.stdout.write('.');
45
+ }
46
+ }
47
+ process.stdout.write('\n');
48
+
49
+ const median = (xs) => {
50
+ const s = [...xs].sort((a, b) => a - b);
51
+ const m = Math.floor(s.length / 2);
52
+ return s.length % 2 ? s[m] : Math.round((s[m - 1] + s[m]) / 2);
53
+ };
54
+ const spread = (xs) => Math.max(...xs) - Math.min(...xs);
55
+
56
+ console.log('\nquestion\tarm\tsamples\tmedian\trange');
57
+ let noiseFloor = 0;
58
+ for (const q of QUESTIONS) {
59
+ for (const [arm] of ARMS) {
60
+ const xs = data[arm][q];
61
+ const sp = spread(xs);
62
+ noiseFloor = Math.max(noiseFloor, sp);
63
+ console.log([q.slice(0, 18), arm, xs.join('/'), median(xs), sp].join('\t'));
64
+ }
65
+ }
66
+ console.log('\nnoise floor (max within-arm range):', noiseFloor);
67
+ console.log('\nBetween-arm median diff per question:');
68
+ const diffs = [];
69
+ for (const q of QUESTIONS) {
70
+ const d = median(data[ARMS[1][0]][q]) - median(data[ARMS[0][0]][q]);
71
+ diffs.push(d);
72
+ console.log(' ' + q.slice(0, 18) + ' -> ' + d + ' chars');
73
+ }
74
+ const meanDiff = Math.round(diffs.reduce((a, b) => a + b, 0) / diffs.length);
75
+ console.log('mean diff (0.1.11 - 0.1.10):', meanDiff, '| noise floor:', noiseFloor,
76
+ '| verdict:', Math.abs(meanDiff) > noiseFloor ? 'difference exceeds noise' : 'INDISTINGUISHABLE from noise');
77
+ fs.writeFileSync('test/noise.json', JSON.stringify({ data, noiseFloor, meanDiff }, null, 2), 'utf8');
@@ -0,0 +1,57 @@
1
+ // 离线自检:不需要模型网关。校验规则正文的契约与检查器行为。
2
+ // 重点防回归:0.1.11 曾把新旧条款并列写进同一份规则,导致自相矛盾、回复变长。
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { analyze } from '../dsh/check.js';
6
+
7
+ const root = path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1'));
8
+ const rulesSrc = fs.readFileSync(path.join(root, '..', 'dsh', 'rules.js'), 'utf8');
9
+ const bt = String.fromCharCode(96);
10
+ const i = rulesSrc.indexOf(bt);
11
+ const j = rulesSrc.indexOf(bt, i + 1);
12
+ const body = rulesSrc.slice(i + 1, j).replace(/\r\n/g, '\n');
13
+
14
+ let pass = 0;
15
+ const fails = [];
16
+ const check = (name, cond, detail = '') => {
17
+ if (cond) pass++;
18
+ else fails.push(name + (detail ? ' :: ' + detail : ''));
19
+ };
20
+ const rulesOf = (t) => analyze(t, { language: 'zh' }).issues.map((x) => x.rule);
21
+ const countOf = (needle) => body.split(needle).length - 1;
22
+
23
+ // 1. 文件与声明
24
+ check('declaration', /export const RULES = `/.test(rulesSrc));
25
+ check('body not empty', body.trim().length > 500, 'len=' + body.length);
26
+
27
+ // 2. 长度与列表必须有确定的硬上限(这是实测能压住篇幅的关键)
28
+ check('has line/char cap', body.includes('默认不超过 12 行、300 字'));
29
+ check('has list cap', body.includes('列表最多 5 条'));
30
+
31
+ // 3. 不许自相矛盾:同一约束只能有一种说法
32
+ const capVariants = ['默认不超过 12 行、300 字', '普通回复以 12 行、300 字以内为参考'];
33
+ check('one length cap only', capVariants.filter((v) => body.includes(v)).length === 1,
34
+ JSON.stringify(capVariants.map((v) => [v, countOf(v)])));
35
+ const listVariants = ['列表最多 5 条;只给一个下一步', '用列表呈现并列项,按需保留完整条目'];
36
+ check('one list rule only', listVariants.filter((v) => body.includes(v)).length === 1);
37
+ check('no expand-anything clause', !body.includes('按任务需要展开'));
38
+
39
+ // 4. 原有硬性禁令仍在
40
+ check('bans preamble', body.includes('希望这有帮助'));
41
+ check('bans process diary', body.includes('我先…然后…'));
42
+ check('bans backref', body.includes('前者') || body.includes('上述'));
43
+ check('keeps evidence rule', body.includes('原文'));
44
+ check('has checklist call', body.includes('plain_talk_check'));
45
+
46
+ // 5. 检查器行为(不依赖模型,只验证它按预期抓问题)
47
+ const zhLong = '这是一段用来测试长度规则的中文内容,'.repeat(20);
48
+ check('flags length', rulesOf(zhLong).includes('length'));
49
+ check('flags preamble', rulesOf('好的,我来看看。' + zhLong).includes('preamble'));
50
+ check('flags backref', rulesOf('上述问题已经修复。' + zhLong).includes('backref'));
51
+ check('flags closer', rulesOf('结论:已完成。还需要我做什么?').includes('closer'));
52
+ const clean = analyze('结论:接口从 180ms 降到 96ms。改动是加了 60 秒缓存,命中率 71%。', { language: 'zh' });
53
+ check('clean reply has no error', clean.issues.every((x) => x.severity !== 'error'), JSON.stringify(clean.issues));
54
+
55
+ console.log(`selftest: ${pass} passed, ${fails.length} failed`);
56
+ for (const f of fails) console.log(' FAIL ' + f);
57
+ process.exit(fails.length ? 1 : 0);