dsh-vibe-math 2.0.21 → 2.0.22

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ChongCyrus
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ChongCyrus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -97,9 +97,10 @@ dsh plugin --profile <你的 profile> add github:ChongCyrus/Vibe-Mathematics
97
97
 
98
98
  - **形态依赖**:三个 preset 依赖 DSH 的标准 **agent-preset 机制**(`~/.dsh/.agent-presets/<id>/` + preset picker)与 **bundle patch 机制**(`cordis.patch.yml` 注入安装器)。
99
99
  - **宿主插件行**:`agent.cordis.yml` 引用宿主提供的 `@deepseek-ai/dsh-*` 插件行(persona、agent-instructions、tool-bash/pwsh、tool-fs/fs-search、tool-jobs、skill-filesystem、tool-skill、tool-goal、plan-mode、compaction、subagent/workflow、ask-user、todo、web 等,约 21 个唯一包名)。宿主缺行会导致 preset 挂载失败(会话启动时报错)。
100
- - **宿主服务 API**:预设插件消费 `subagents`(startContinuable / **sendMessage**(续做/唤醒;`followup` 仅为 `Agent` 对象方法、**不是** `subagents` 服务方法)/ interrupt)、`agents`(roots)、`tools`(register)、`commands`(register)、`fs`(resolve/stat/readText/writeText/listDir)、可选 `subprocess` / `sandboxPolicy`。这些 API 形状随 DSH 版本演进;本项目**已充分测试并确认适配 `dsh-v0.1.2-rc.1`**(`package.json` 的 `dsh.testedVersion`;`minVersion` 为 `0.1.2-rc.1`)。**注意:DSH 0.1.2 起 `subagents.startContinuable` 的 `agentOptions` / `toolFilter` 需要宿主 provider 声明对应 capability**(spawn / fork 进程内 provider 均支持,v4 指定常驻模型/路由与工具权限依赖于此)。
101
- - **DSH STORE 兼容声明**:`package.json` 的 `dsh.compatibility.dshReleases` 对每个完整 DSH 版本逐项声明 `compatible` / `incompatible` / `unknown`(当前 `0.1.2-alpha.4`、`0.1.2-alpha.5`、`0.1.2-rc.1` 均标 `compatible`);`engines.node` 为 `^22.19.0 || >=24.0.0`(与 DSH 0.1.2 相同)。
102
- - **运行时自检(能力 + 版本双检)**:安装器(bundle 插件)每次启动时:**① 尽力探测 DSH 版本**(读 `@deepseek-ai/dsh/package.json` 或 `DSH_VERSION` 环境变量;DSH 未通过公开 service/context 暴露版本,故为尽力而为,探测不到就跳过)。若探测到且该版本未被 `dshReleases` 声明为 `compatible`,会给出明确"DSH 版本不匹配,请使用 `dsh-v0.1.2-rc.1`(或 `0.1.2-alpha.4/alpha.5`)"提示;**② 再对上述服务与关键 API 做能力自检**(这是真正的挂载门槛,含 `fs.resolve` 返回形状检测与 subagent `agentOptions`/`toolFilter` capability 检测),不满足时打 warning。preset 挂载失败时先看 DSH 日志里的自检 warning。
100
+ - **宿主服务 API**:预设插件消费 `subagents`(startContinuable / **sendMessage**(续做/唤醒;`followup` 仅为 `Agent` 对象方法、**不是** `subagents` 服务方法)/ interrupt)、`agents`(get/roots)、`tools`(register/restrict)、`commands`(register)、`fs`(resolve/stat/readText/writeText/listDir),以及**可选** `subprocess` / `sandboxPolicy` / `compaction`。这些 API 形状随 DSH 版本演进;本项目**已在 `dsh-v0.1.5-rc.2` 上逐项核对并适配**(`package.json` 的 `dsh.testedVersion`)。**注意:DSH 0.1.2 起 `subagents.startContinuable` 的 `agentOptions` / `toolFilter` 需要宿主 provider 声明对应 capability**(spawn / fork 进程内 provider 均支持,v4 指定常驻模型/路由与工具权限依赖于此)。
101
+ > **2026 兼容性修复要点**(详见 `../COMPAT-AUDIT-ROUND2.md`):① `tools.restrict()` 对**未注册的工具名抛错**,而 filter 在建立子代理时应用,故权限名表必须只含本部署真正注册的名字——v2/v3 原先硬编码 `web`/`fetch`/`bash`(其中 `bash` 在 Windows 被 `disabled`)会导致"想收紧权限时子代理永远起不来";② v4 的真实 `/compact` 原先在 `subagent/end` 里查 `agents.get()`,但该事件在子代理**已被移出注册表之后**才触发,属死代码,已改为在 `subagent/start` 捕获引用;③ 可选服务改为**惰性读取**,不再在 `apply()` 快照(否则挂载顺序会让 `subprocess` 永久为 undefined 而静默不建目录)。
102
+ - **DSH STORE 兼容声明**:`package.json` 的 `dsh.compatibility.dshReleases` 对每个完整 DSH 版本逐项声明 `compatible` / `incompatible` / `unknown`(当前已声明 `0.1.2-alpha.4` … `0.1.5-rc.2` 共 8 个版本为 `compatible`,实测目标为 `0.1.5-rc.2`);`engines.node` 为 `^22.19.0 || >=24.0.0`。
103
+ - **运行时自检(能力 + 版本双检)**:安装器(bundle 插件)每次启动时:**① 尽力探测 DSH 版本**(读 `@deepseek-ai/dsh/package.json` 或 `DSH_VERSION` 环境变量;DSH 未通过公开 service/context 暴露版本,故为尽力而为,探测不到就跳过)。若探测到且该版本未被 `dshReleases` 声明为 `compatible`,会给出明确提示;**② 再对宿主服务与关键 API 做能力自检**(这是真正的挂载门槛):`subagents`/`agents`/`tools`/`commands`/`fs` 为**必需**(缺失即 warning),`subprocess`/`sandboxPolicy`/`compaction` 为**可选**(缺失只提示"功能会静默降级",不影响挂载),另含 `fs.resolve` 返回形状检测与 subagent `agentOptions`/`toolFilter` capability 检测。preset 挂载失败时先看 DSH 日志里的自检 warning。
103
104
  - **升级路径**:DSH 升级后无需重装本包;升级本包用 `dsh plugin update dsh-vibe-math`,重启 DSH 后安装器会自动把 preset 更新到新版本(见上文「安装」说明)。
104
105
 
105
106
  ---
@@ -430,7 +431,7 @@ dsh plugin --profile <你的 profile> add github:ChongCyrus/Vibe-Mathematics
430
431
 
431
432
  - **断点续跑**:所有状态落盘(v2:`VibeMath_State/*.json`;v3:`State/*.json`),每个子代理都是 DSH 的 **continuable 持久会话**(对话由 DSH 自动保存)。重启后新开会话 → `vibe_math_resume` 即可续跑。v2/v3 额外用**进程纪元**区分"同进程暂停→恢复"(保留存活子代理继续)与"跨进程重启"(清理陈旧任务)。**v3 的 md 知识库本身就是叙事断点**——代理 resume 时从研究日志/问题卡/命题卡尾部续写。
432
433
  - **中途人工干预**:`manual` 模式在关键节点挂起决策(v2:explorer/solver 派发、验证裁决;v3:**计划审批门**(规划代理产出计划后等你 approve/reject)、验证裁决门、**方法晋升门**(项目方法 → 全局库));可随时 `set_mode auto` 切回自动(自动放行所有挂起决策);可对任意子代理 `message_agent` / `interrupt_agent`。
433
- - **进度汇报**:默认**事件驱动** —— 只有代理状态更新等事件发生时才会写报告(v2:`Progress_Logs/report.json`;v3:`Progress_Logs/report.json` + `Logs/报告.md` 论文式人读摘要;`reportMode` 可 `file`/`push`/`both`,`push` 通过 `rootAgent.followup()` 唤醒主代理主动汇报);只有把 `reportIntervalMs` 设为 >0 才启动定时自动汇报(间隔毫秒)。
434
+ - **进度汇报**:默认**事件驱动** —— 只有代理状态更新等事件发生时才会写报告(v2:`Progress_Logs/report.json`;v3:`Progress_Logs/report.json` + `Logs/报告.md` 论文式人读摘要;`reportMode` 可 `file`/`push`/`both`,`push` 通过 `subagents.sendMessage(根代理, 常驻子代理, …)` 唤醒常驻主动汇报——`followup` **不是** `subagents` 服务的方法,它只是 `Agent` 对象方法);只有把 `reportIntervalMs` 设为 >0 才启动定时自动汇报(间隔毫秒)。
434
435
 
435
436
  ---
436
437
 
@@ -0,0 +1,112 @@
1
+ # v2.0.22 — 兼容性修复与数据安全加固
2
+
3
+ > 目标宿主:**DSH 0.1.5-rc.2**(`dsh.testedVersion`)。`minVersion` 仍为 `0.1.2-rc.1`。
4
+ > 本版**无破坏性改动**,升级路径与以往一致(`dsh plugin update dsh-vibe-math` 后重启 DSH)。
5
+ > 三套预设(v2 / v3 / v4)**都要更新**。
6
+ >
7
+ > 本版包含自 v2.0.21 以来的全部改动:**① DSH 0.1.5-rc.2 兼容性修复**(下文第一部分)与
8
+ > **② 上一轮深度审计修复**(本文件末尾「附:v2.0.21 之后的审计修复」)。
9
+
10
+ ## ⚠️ 升级前请先读这一条(可能影响你的数据)
11
+
12
+ **v2.0.21 及更早存在一个数据丢失缺陷**:当项目里的 JSON 状态文件被外部损坏(手工编辑出错、磁盘写入中断、编辑器崩溃等)时,插件会把"无法解析"误当成"文件不存在",随后用空数据把它覆盖掉 —— 表现为**问题清单/命题库/运行状态被静默清空**。
13
+
14
+ 本版修好了这个缺陷,但**它无法恢复已经被清空的历史数据**。如果你曾遇到过"知识库内容无故消失",请注意:
15
+
16
+ - 该缺陷的影响面:v2 的 `qs/qs.json`、`Propos/*.json`、`Verified/*.json`;v3/v4 的 `State/*.json`。
17
+ - 修复后的行为:一旦检测到"文件存在但无法解析",插件会**打印告警并拒绝覆盖该文件**,等你修复或删除它。
18
+ - 因此升级后如果看到 `exists but is not parseable JSON — REFUSING to overwrite it` 之类的日志,说明该文件本来就是坏的:请先修好或重命名它,插件才会继续写入。
19
+
20
+ ## 修复清单
21
+
22
+ ### 兼容性(针对 DSH 0.1.5-rc.2)
23
+
24
+ | 项 | 问题 | 影响 |
25
+ |---|---|---|
26
+ | **工具权限过滤器被宿主拒绝** | v2/v3 的权限名表硬编码了 `web`/`fetch`(**从来不是工具名**),且 `bash` 在 Windows 上因预设 `disabled: process.platform==='win32'` 未注册。宿主 `tools.restrict()` 对未注册名**直接抛错**,而过滤器是在建立子代理时应用的 | **想收紧网络/脚本权限时(`solverAllowNetwork:false` / `solverAllowScripts:false`)子代理永远起不来**,调度卡住。已改为按本平台真实注册名,并加"只保留宿主确认合法的名字"的带守卫重试;过滤后若为空则**拒绝派发**(宁可这一轮不派,也不越权) |
27
+ | **v4 的真实 `/compact` 是死代码** | `realCompact()` 在 `subagent/end` 里查 `agents.get(childId)`,但宿主时序是「先 `handle.dispose()` → 子代理移出注册表 → 之后才 emit `subagent/end`」,查询**必然** 返回 undefined | 真实压缩**从未执行**,上下文只靠模型自报占比。已改为在 `subagent/start` 捕获活 Agent 引用(`WeakRef` 持有,end 处理后释放) |
28
+ | **预设 realm 配置不生效** | compaction 隔离组的用途(DSH 自带 `standard` 预设注释原话)是"让预设决定自己的 agent 是否/如何压缩",但插件行在 realm 之外,取到的是**宿主根**实例 | 插件代常驻发起的压缩用的是宿主配置,与常驻自压的实例不一致。已改为经**子代理自身 `agent.ctx`** 解析,两条路径落到同一实例 |
29
+ | **可选服务在 `apply()` 同步快照** | `subprocess`/`sandboxPolicy`/`compaction` 在挂载时一次性读取,受挂载顺序影响会永久为 `undefined` | `runShell` 静默失效、`ensureDirs()` 不再建目录(仅被 `fs.writeText` 自动建父目录掩盖)。已改为**惰性读取** |
30
+ | **v4 注册未纳入 `ctx.effect`** | `tools.register`/`commands.register` 的 disposer 被丢弃 | 预设卸载/HMR 后注册不回收、重复挂载会撞名。已与 v2/v3 一致地纳入 `ctx.effect` |
31
+ | **安装器自检漏检三个服务** | 原先只查 `fs.resolve` 外形 | 现在把 `subprocess`/`sandboxPolicy`/`compaction` 也纳入自检,并区分**必需**(缺失即告警)与**可选降级**(只提示降级、不影响挂载) |
32
+
33
+ ### 数据安全 / 正确性
34
+
35
+ | 项 | 问题 |
36
+ |---|---|
37
+ | **损坏 JSON 被静默覆盖**(见上"升级前请先读") | 三套预设均已加"读取时记录 + 写入时拒写"守卫;v4 另在写前惰性检查磁盘内容,覆盖"只 configure/start、从未 `loadAll`"的路径 |
38
+ | **沙箱围栏根静默改变** | `getPolicy()` 的 `resolve({})` 回退会把围栏根换成宿主配置的 workspace(不一定是本会话 cwd),且异常被静默吞掉。现在首次触发即打印可见告警 |
39
+ | **fail-closed 自纠** | 上一条"重试"若把过滤器全部名字都过滤掉,原实现会删掉过滤器继续派发(等于放开全部权限)。已改为拒绝派发 |
40
+
41
+ ### 文档
42
+
43
+ - README 修正:`push` 汇报走的是 `subagents.sendMessage(...)`,**不是** `rootAgent.followup()`(`followup` 只是 `Agent` 对象方法,不是 `subagents` 服务方法)。
44
+ - 补全宿主服务清单(`tools.restrict`、`agents.get`、可选 `compaction`)与 2026 兼容性修复要点。
45
+ - 设计文档(v4 `实现方案.md`)更新:记录真实 `/compact` 的原缺陷与修法。
46
+
47
+ ## 验证
48
+
49
+ 本版在 DSH **0.1.5-rc.2** 上实跑:
50
+
51
+ ```
52
+ e2e-business 18 / e2e-regression 14 / e2e-multisession 25 / e2e-v3 100 / e2e-v4-fixes 120
53
+ e2e-v3-roundtrip 12 / e2e-d9-d13 7 / audit-path-consistency 18
54
+ audit-settings-roundtrip 12 / audit-round1-regressions 7 / audit-round6-persistence 8
55
+ verify-fixes 11 → 原有 380 项断言全绿
56
+
57
+ audit-f1-compact-fix 6 (mock 忠实复现宿主"先 teardown 再 emit",断言真实压缩被调用)
58
+ audit-f2-filter-fix 36 (用宿主自身拒绝谓词 × 本部署真实注册名)
59
+ audit-corrupt-file-guard 6 (损坏文件不被覆盖;三版本各做敏感性验证)
60
+ audit-fuzz-helpers 1654 calls (单参纯函数 × 19 类恶意输入,0 抛异常)
61
+ e2e-f1-agent-detach CONFIRMED (驱动真实 AgentRegistry 复现宿主时序)
62
+
63
+ 真宿主检查:3 discovered / 0 broken / 57 rows / 0 failing
64
+ 隔离 DSH_HOME 安装器全链路:通过(真实 ~/.dsh 未被触碰)
65
+ ```
66
+
67
+ 其中 F-1/F-2/F-9 三个修复都做了**敏感性验证**:把代码改回缺陷版本后,对应测试确实会失败 —— 证明这些测试不是空洞通过。
68
+
69
+ ## 已知边界(沿用,未在本版改动)
70
+
71
+ - `ensureDirs()` 依赖外部 `powershell`(Windows)/`sh`(其他平台),且返回值在调用点未被检查;兜底是 `fs.writeText` 自动创建父目录。
72
+ - v2/v3 的 tick 定时器用 Realm 全局 `setInterval`(在 `ctx.effect` 内且正确清理)而非宿主的 `ctx.interval`,仅为风格问题。
73
+ - v4 的 `claim_write`/`release_write` 仍是占位(常驻专属目录天然无写冲突)。
74
+ - `FIX-REPORT-2026.md` 第四节约 20 条历史审计编号(v4 D1/D2/D3/D7、v3 D17/D18/M14/M2 等)**未逐条验证**,不属本次兼容性范围。
75
+
76
+ ## 详细审计报告
77
+
78
+ 仓库内 `COMPAT-AUDIT-ROUND2.md`(含逐条证据与行号、与上一轮 `COMPAT-AUDIT-0.1.5-rc.2.md` 的差异修正)。
79
+
80
+ ---
81
+
82
+ ## 附:v2.0.21 之后的审计修复(同版本发布,非本部分兼容性范围)
83
+
84
+ 以下为 v2.0.21 之后、随本版一同发布的上一轮深度审计修复。详细证据见仓库 `FIX-REPORT-2026.md`。
85
+
86
+ **宿主兼容性(persona schema)**
87
+ - 三套预设的 `persona` 行从仅 `text:` 改为 **`prefix`(正文)+ `suffix`(cwd 句)+ 保留 `text`**:DSH ≥ 0.1.3-alpha.2 起 `prefix` 为必填,而 ≤ 0.1.2 只认 `text`;schemastery 容忍未知键,故一行同时兼容两代。**未修前,本项目在 DSH 0.1.5-rc.2 上完全无法挂载。**
88
+
89
+ **v2**
90
+ - **收敛闸门**:「判断命题」的收口路径让命题**永不收敛**,每 tick 重开辩论并饿死其它工作。
91
+ - **fail-closed**:工具过滤器失败时不再删掉过滤器重试(那会静默放开网络/脚本权限)。
92
+ - **平台 shell**:按平台选择解释器(原先硬编码 `powershell`,非 Windows 静默失效)。
93
+ - **参数下界**:整数字段补下界(如 `maxParallelThreshold:0` 会导致永不派发)。
94
+ - **设置模板合法化**:写出的模板含 `"mode": undefined` 等非法 JSON,导致插件自己回读失败、**用户参数静默丢失**。
95
+
96
+ **v3**
97
+ - **卡片无损往返**:往返会销毁代理产出(`经验与教训`、方法卡`改进历史`、应用记录`问题/方向`)。
98
+ - **路径消毒与单一来源**:原先写用 `idSafe`、读用原始 id,导致**读写路径不一致**(路径穿越)。
99
+ - **重派生计数**:`explorerRetries` 只增不减(重置点是死代码),3 次后**永久无法重派生**。
100
+ - **停摆判定**:人工计划待批时被判「停摆」,approve 后计划**永不执行**。
101
+ - **gate 单点设置**:gate 被无条件覆盖产生幽灵 pending 决策,会被 `auto` **重放副作用**。
102
+
103
+ **v4**
104
+ - **`maxParallel` 下界钳制**:`0` 会使闸门失效 → **无限并发**。
105
+ - **平台 shell**:同 v2。
106
+
107
+ **缺陷分类(D9 / D13 / D21 等)**
108
+ - `activeCount` 手写累加器漂移 → 闸门恒真、**永不派发**,而 status 仍报 running。
109
+ - `scheduler.gate` 粘滞 → 调度**永久卡死**且重启带病。
110
+
111
+ > 本部分改动均带有回归测试。原有测试套件在本版发布前实跑全绿(见上「验证」)。
112
+
package/cordis.patch.yml CHANGED
@@ -1,9 +1,9 @@
1
- # The dsh-vibe-math merged bundle patch. Installing this bundle (dsh plugin add
2
- # dsh-vibe-math / dsh-market) runs ONE plugin row: the preset installer, which
3
- # copies the agent presets (vibe-math-v2 + vibe-math-v3 + vibe-math-v4) into the
4
- # DSH preset root. The presets themselves register the vibe_math_* tools — nothing
5
- # is injected into the profile composition directly.
6
-
7
- - insert:
8
- - id: vibe-math-preset-installer
9
- name: dsh-vibe-math/installer
1
+ # The dsh-vibe-math merged bundle patch. Installing this bundle (dsh plugin add
2
+ # dsh-vibe-math / dsh-market) runs ONE plugin row: the preset installer, which
3
+ # copies the agent presets (vibe-math-v2 + vibe-math-v3 + vibe-math-v4) into the
4
+ # DSH preset root. The presets themselves register the vibe_math_* tools — nothing
5
+ # is injected into the profile composition directly.
6
+
7
+ - insert:
8
+ - id: vibe-math-preset-installer
9
+ name: dsh-vibe-math/installer