clearai-dsh 0.5.4-rc.1 → 0.5.5

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
@@ -2,7 +2,44 @@
2
2
 
3
3
  All notable changes to this project are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
- ## [Unreleased]
5
+ ## [0.5.5] — 2026-10-14
6
+
7
+ **Windows 上的硬边界、证据落盘与自检全部补齐;另按社区 issue #33 / #34 做了能做的那部分加固。**
8
+
9
+ 这一版来自「在 Windows 上装最新发行版、按真实环境跑一遍」的结果:报告里的 issue #30(社区 PR #31,作者 YunzhouLi-hub)属实,且同一类平台假设在证据捕获与开发工具里还有几处。
10
+
11
+ ### Fixed
12
+
13
+ - **全屏退得出**(issue #33):本体图的全屏是自画的覆盖层(`position:fixed`),退出入口原先只是工具条里一个文字链接——没有快捷键、也不保证不被画布盖住,被遮住就只能刷新页面。现在:Escape 退出(window 级监听 + 覆盖层内 `onKeyDown` 两条一起,焦点在哪都能退)、退出入口在全屏时固定浮在右上角(`z-index:41`,高于覆盖层 `40`),并补了 6 条客户端检查(全屏态标记、入口在场且标出快捷键、点击/ Escape 都退出、别的键不误触、非全屏不接 Escape)。
14
+ - **预设不再依赖宿主模板变量**(issue #34):persona 里的 `{{cwd}}` 去掉了。宿主渲染提示词时按**变量表**严格解析,表里没有这个名字就整轮直接抛错(`unknown prompt variable "{{cwd}}" in section …`),而各宿主版本注册的变量并不一样——工作区的绝对路径本来就由宿主的运行时上下文给出,预设只留产品含义。同时加了一道门:预设里再出现 `{{…}}` 必须是宿主注册过的名字(`model` / `cwd`),并拿一条假变量自检这道门抓得到。
15
+ - **shell 硬边界不再只认 bash**(issue #30):危险命令闸、系统所有的路径写检测、L4 不可逆动作人放行三处从前写死 `exec.name === 'bash'`,而本预设按平台只挂一个 shell(win32 只挂 pwsh)——这三道门在 Windows 上**整体失效**。现在统一按 `SHELL_TOOLS = {bash, pwsh}` 判定。
16
+ - 补齐 pwsh 形态的危险写法:递归删除系统路径(`Remove-Item -Recurse C:\`)、远程脚本直灌(`iwr … | iex`)、动态执行下载内容、卷格式化、提权;写动词同时认 bash 与 pwsh(`Remove-Item`/`Set-Content`/`Out-File`…),并认 Windows 的反斜杠相对路径(`clear\knowledge\facts\x.json`)——只认正斜杠的门在 Windows 上会被绕开。写本体三支目录(`clear/ontology/{concepts,relations,entities}`)在两种分隔符下都照旧放行。
17
+ - 拒因文案由 `dangerous bash command` 改为 `dangerous shell command`(门不再只覆盖 bash,文案跟着如实)。
18
+ - **证据捕获(native 验收)不再依赖路径分隔符**:Windows 上 `relative()` 给出反斜杠,于是 `.git`/`.env` 排除、工作区归属校验、注册方法的输入/脚本捕获、report 提取**全都静默失配**。现在统一归一到 `/`,`inside()` 也按归一后的路径判越界。
19
+ - **按行解析不再被检出格式坑**:`tools/sim/config.mjs` 剥注释靠 `$` 收尾,CRLF 的 `\r` 会让注释整行留下、解析当场炸在"读不懂这一行"。同时新增 `.gitattributes`(`eol=lf`)从根上统一行尾,`tools/build-package.mjs` 读源时归一成 LF,保证 Windows 上重建的 `pack/presets/clearai.patch.yml` 与提交件仍逐字节一致。
20
+ - 模拟宿主按平台选 shell(win32 用 pwsh):写死 `bash` 会让内核按平台点的 `pwsh` 在工具表里不存在,核算复检当场「执行未完成」。
21
+ - 测试套件可在 Windows 运行:动态 `import()` 用 `file://` URL(原样传 `C:\…` 会 `ERR_UNSUPPORTED_ESM_URL_SCHEME`);文档扫描按归一后的路径判归属;没有符号链接权限时(Windows 需开发者模式)不再整条红。
22
+
23
+ ### Tests
24
+
25
+ - `test/kernel.test.mjs` 新增 8 条 pwsh 侧检查(危险闸门、卷格式化、递归删除、只读放行、绝对路径与反斜杠相对路径伪造评估卡、本体目录放行),`test/truth-table.test.mjs`/`docs-consistency` 的真值表符号同步更新。
26
+ - Windows 本机全量:内核 660/0、领域语言 251/0、本体 101/0、真值表 19/0、状态机 41/0、文档 15/0、注释 7/0、边界 19/0、组合 16/0、段 23/0、长测 41/0、不变量 27/0、对照 39/0、可读性 37/0、预算 28/0、native 七份全绿;宿主/客户端两份跑的是部署出去的那一份,装完本版即绿。
27
+
28
+ ## [0.5.4] — 2026-10-10
29
+
30
+ **修复慢评估误杀与审计恢复,正式用户可直接更新。**
31
+
32
+ ### Fixed
33
+
34
+ - 移除四分钟硬取消;交付与结案等待同一个原生评估结果,等待期间不调用主模型或重复派发。
35
+ - 正常返回、结束事件与日志恢复共用幂等持久收尾;保存裁决后重新检查材料。用户暂停、取消或更换目标后,迟到结果不会自动继续旧目标。
36
+ - 允许复跑的评估者通过原生后台任务工具收取长命令结果;连续连接故障不会因改写答案重置失败计数。
37
+
38
+ ### Migration and validation
39
+
40
+ - 与已验证的 0.5.4-rc.1 运行代码逐文件一致,仅版本及发布文档变化。投影版本 22,旧账本重建;`auditTimeoutMs` 仅诊断,`auditHardTimeoutMs` 废弃,历史超时目标不自动重启。
41
+ - 完整本机回归、Linux CI、Windows Node 24 审计回归、原生安装与生命周期验证通过。真实 DSH / deepseek-flash 完成快速闭环、305 秒慢评估、取消、断连与崩溃恢复;慢评估只派发一次,等待期间主模型请求为零。[验收证据](docs/optimization/0.5.4-rc.1/README.md)。人为延迟不作为性能收益。
42
+ - 本版发布到 npm `latest`;安装可指定 `clearai-dsh@0.5.4`。团队融合另走 0.5.5-rc.1,不混入本次修复。
6
43
 
7
44
  ## [0.5.4-rc.1] — 2026-10-10
8
45
 
package/README.md CHANGED
@@ -22,8 +22,8 @@ ClearAI is an **ontology discovery and exploration platform**, built on two core
22
22
 
23
23
  ```bash
24
24
  # Install (npm package, prebuilt — no build step, no allowBuilds prompt)
25
- dsh plugin --profile web add clearai-dsh@0.5.4-rc.1
26
- # or in the app: Plugins → Add plugin → clearai-dsh@0.5.4-rc.1
25
+ dsh plugin --profile web add clearai-dsh@0.5.5
26
+ # or in the app: Plugins → Add plugin → clearai-dsh@0.5.5
27
27
  ```
28
28
 
29
29
  Restart `dsh web`, then pick **ClearAI** in the preset picker at the top of a new session. That is the whole setup. [Full install notes ↓](#install-and-use)
@@ -86,12 +86,12 @@ ClearAI does **not** claim recursive self-improvement. It provides the epistemic
86
86
 
87
87
  **Recommended — install it in the app, with the version pinned:**
88
88
 
89
- In the sidebar open **Plugins → Add plugin**, enter `clearai-dsh@0.5.4-rc.1`, and install. That is DSH's own plugin manager: it hands what you type to pnpm, checks that the package declares a bundle and is compatible with this host, and applies it live. (The Settings page **插件列表 / Plugins** is the read-only inventory — installing happens on the sidebar's Plugins page.)
89
+ In the sidebar open **Plugins → Add plugin**, enter `clearai-dsh@0.5.5`, and install. That is DSH's own plugin manager: it hands what you type to pnpm, checks that the package declares a bundle and is compatible with this host, and applies it live. (The Settings page **插件列表 / Plugins** is the read-only inventory — installing happens on the sidebar's Plugins page.)
90
90
 
91
91
  **Or from a terminal — the same install:**
92
92
 
93
93
  ```bash
94
- dsh plugin --profile web add clearai-dsh@0.5.4-rc.1
94
+ dsh plugin --profile web add clearai-dsh@0.5.5
95
95
  ```
96
96
 
97
97
  This installs the prebuilt package from the npm registry. Nothing is compiled on your machine, so there is no `allowBuilds` grant to approve — the plugin is ready the moment the command returns.
@@ -156,7 +156,7 @@ node docs/diagrams/build-hero.mjs # redraw the product hero (needs google-chro
156
156
 
157
157
  ## What it looks like
158
158
 
159
- Two panes in the middle: **Explore** and **Ontology**. Explore holds the process; Ontology holds only results. The plan chip next to the input box shows exploration progress ("Question 1/2 · hypotheses to test: 2" or "Areas 3/6 · 1 question(s) awaiting your decision"); click it to open Explore.
159
+ Two panes in the middle: **Explore** and **Ontology**. Explore holds the process; Ontology holds only results. Plan progress mirrors to DSH's native todo dock.
160
160
 
161
161
  **Explore** — what is being answered, which possibilities are still open, and what comes next. The header gives the topic and mode (survey / solve), the current question and plan progress. Below come the items awaiting you, the survey areas (in survey mode), each question's candidate hypotheses (being examined / excluded / adopted / set aside; open one for its source, refutation condition, prediction and related records), the next step with each candidate's prediction (with a note when the predictions are identical and the step cannot tell them apart), and unexplained observations. A newly found question carries two buttons, "Make it a question" and "Park"; pressing one sends a sentence to the model on your behalf, and the model revises the framing. At the bottom, a collapsed **process record**: judgment counts and the progress rail, every judgment, and the plan's steps and gates.
162
162
 
package/README.zh-CN.md CHANGED
@@ -22,8 +22,8 @@ ClearAI 是一个**本体发现与探索平台**,核心由两个概念支撑
22
22
 
23
23
  ```bash
24
24
  # 安装(npm 包,预构建——无需构建步骤,不会触发 allowBuilds 授权)
25
- dsh plugin --profile web add clearai-dsh@0.5.4-rc.1
26
- # 或在应用里:侧栏「插件」→ 添加插件 → clearai-dsh@0.5.4-rc.1
25
+ dsh plugin --profile web add clearai-dsh@0.5.5
26
+ # 或在应用里:侧栏「插件」→ 添加插件 → clearai-dsh@0.5.5
27
27
  ```
28
28
 
29
29
  重启 `dsh web`,在新建会话顶部的模式选择器里选 **ClearAI** 即可。这就是全部步骤。[完整安装说明 ↓](#安装与使用)
@@ -86,12 +86,12 @@ ClearAI **不**声称递归自我改进。它提供的是自我改进系统所
86
86
 
87
87
  **推荐——在应用里装,并把版本钉住:**
88
88
 
89
- 侧栏打开**「插件」→ 添加插件**,填 `clearai-dsh@0.5.4-rc.1`,安装。这就是 DSH 自己的插件管理器:它把你填的东西交给 pnpm,校验这个包声明了组合包、与当前宿主兼容,然后当场生效。(设置里的**插件列表**是**只读清单**;安装入口在侧栏那个「插件」页。)
89
+ 侧栏打开**「插件」→ 添加插件**,填 `clearai-dsh@0.5.5`,安装。这就是 DSH 自己的插件管理器:它把你填的东西交给 pnpm,校验这个包声明了组合包、与当前宿主兼容,然后当场生效。(设置里的**插件列表**是**只读清单**;安装入口在侧栏那个「插件」页。)
90
90
 
91
91
  **或者开终端——同一次安装:**
92
92
 
93
93
  ```bash
94
- dsh plugin --profile web add clearai-dsh@0.5.4-rc.1
94
+ dsh plugin --profile web add clearai-dsh@0.5.5
95
95
  ```
96
96
 
97
97
  从 npm registry 装预构建产物。本机不跑任何编译,因此不需要批准 `allowBuilds` 授权——命令返回时插件就已经可用。
@@ -157,7 +157,7 @@ node docs/diagrams/build-hero.mjs # 重画产品主图(需 google-chrome)
157
157
 
158
158
  ## 它长什么样
159
159
 
160
- 中栏两格:**探索**与**本体**。探索记录过程,本体只放结果。输入框旁边的计划芯片显示探索进度(「问题 1/2 · 待检验假设 2 个」或「板块 3/6 · 1 个问题待您决定」),点一下打开探索。
160
+ 中栏两格:**探索**与**本体**。探索记录过程,本体只放结果。计划进度同步到 DSH 原生的 todo 停靠栏。
161
161
 
162
162
  **探索**——当前在回答什么、还有哪些可能未被排除、下一步做什么。页眉是课题与阶段(广度调研 / 定向求解)、当前问题、计划进度;下面依次是待您处理的事项、调研板块(广度调研时)、每个问题的候选假设(考察中 / 已排除 / 已采纳 / 暂不考察,点开看提出依据、推翻条件、预测与关联记录)、下一步及各候选的预测(预测相同时说明此步骤无法区分它们)、未解释的现象。新发现的问题带「立为问题 / 暂缓」两个按钮,按下即替您向模型发一句话,由模型修订立题。最下面是默认折叠的**过程记录**:判断的计数与进度轨、全部判断、计划的步骤与门。
163
163
 
package/bin/clearai.mjs CHANGED
@@ -163,6 +163,25 @@ function findOnPath(name) {
163
163
  return null
164
164
  }
165
165
 
166
+ /**
167
+ * 跑一个在 PATH 上找到的命令。
168
+ *
169
+ * **Windows 上 `.cmd`/`.bat` 不能直接 spawn** —— Node 只认 PE 可执行文件,裸 spawn 一个
170
+ * `dsh.cmd` 会失败(EINVAL/ENOENT),而 Windows 上的 CLI 正是 `.cmd` 包装脚本。
171
+ * 这类脚本要交给 `cmd.exe` 执行。
172
+ */
173
+ function spawnOnPath(bin, args, options) {
174
+ if (process.platform === 'win32' && /\.(?:cmd|bat)$/i.test(bin)) {
175
+ // `/s` 会剥掉整串的**最外层**引号,所以按 cmd 的规范写成 `""bin" "arg"…"`:
176
+ // 每个参数各自加引号(路径里有空格是常态),整体再包一层。`windowsVerbatimArguments`
177
+ // 让 Node 原样透传 —— 否则 Node 自己那套转义在 cmd 眼里是错的。
178
+ const quote = (value) => `"${String(value).replaceAll('"', '""')}"`
179
+ const line = `"${[bin, ...args].map(quote).join(' ')}"`
180
+ return spawnSync(process.env.ComSpec ?? 'cmd.exe', ['/d', '/s', '/c', line], { ...options, windowsVerbatimArguments: true })
181
+ }
182
+ return spawnSync(bin, args, options)
183
+ }
184
+
166
185
  /**
167
186
  * 问组合:宿主行到底有没有真的进组合。
168
187
  *
@@ -174,7 +193,7 @@ function composeQuery(profileName, env) {
174
193
  const args = ['--profile', profileName, '--dump-config']
175
194
  const run = onPath === null
176
195
  ? spawnSync('npx', ['--no-install', '@deepseek-ai/dsh', ...args], { encoding: 'utf8', env, timeout: 120000, stdio: ['ignore', 'pipe', 'ignore'] })
177
- : spawnSync(onPath, args, { encoding: 'utf8', env, timeout: 120000, stdio: ['ignore', 'pipe', 'ignore'] })
196
+ : spawnOnPath(onPath, args, { encoding: 'utf8', env, timeout: 120000, stdio: ['ignore', 'pipe', 'ignore'] })
178
197
  return run.status === 0 ? String(run.stdout ?? '') : null
179
198
  }
180
199
 
@@ -238,7 +257,7 @@ function install() {
238
257
  * 子进程**继承 stdio**:安装进度、以及 CLI 那句 `initialized profile …` 都如实流到用户眼前;
239
258
  * 失败时他看到的也是真实报错,而不是我截出来的尾巴。
240
259
  */
241
- const dsh = (args) => (dshPath === null ? spawnSync('npx', ['--yes', '@deepseek-ai/dsh', ...args], { env, stdio: 'inherit', timeout: 900000 }) : spawnSync(dshPath, args, { env, stdio: 'inherit', timeout: 900000 }))
260
+ const dsh = (args) => (dshPath === null ? spawnSync('npx', ['--yes', '@deepseek-ai/dsh', ...args], { env, stdio: 'inherit', timeout: 900000 }) : spawnOnPath(dshPath, args, { env, stdio: 'inherit', timeout: 900000 }))
242
261
 
243
262
  console.log(t('installHeader', { name: manifest.name, version: manifest.version }))
244
263
  console.log(` ${t('installWhat')}${spec}(${source})`)
package/lib/client.js CHANGED
@@ -81,10 +81,10 @@ var Wt=Object.create;var Le=Object.defineProperty;var Pt=Object.getOwnPropertyDe
81
81
  /**
82
82
  * clearai-dsh —— 浏览器半(ClearAI 的面板)。
83
83
  *
84
- * 它注册三个座位:
84
+ * 它注册两个座位:
85
85
  * 中栏 `conversation.view` 探索(问题 → 候选假设 → 下一步;过程记录里有判断列表与计划的世界树)
86
86
  * 中栏 `conversation.view` 本体(结论四部分 + 本体图 / 实体图 + 已确立的事实 + 经验)
87
- * 输入框 `conversation.input` 计划芯片(「问题 1/2 · 待检验假设 N 个」+ 「待处理 N」,点击打开探索货架)
87
+ * 计划进度同步到 DSH 原生的 todo 停靠栏,不再有输入框芯片。
88
88
  * 交付与文件改动走 DSH 原生的卡片,技能走原生技能目录,这里都不另做一份。
89
89
  * 面板**只读**:没有写入口。要人拍板的事由开门的那次工具调用当场问人;「立为问题 / 暂缓」只替人往对话里发一句话。
90
90
  *
@@ -300,7 +300,7 @@ window.__ModuleLoader__.load({
300
300
  /* 图 */
301
301
  .clearai-graph{margin-bottom:18px}
302
302
  .clearai-graph[data-full="1"]{position:fixed;inset:0;z-index:40;background:var(--dsw-alias-bg-base);padding:16px 20px;display:flex;flex-direction:column;margin:0}
303
- .clearai-graph-bar{display:flex;align-items:center;gap:14px;margin-bottom:8px;font-size:12px}
303
+ .clearai-graph-bar{display:flex;align-items:center;gap:14px;margin-bottom:8px;font-size:12px;position:relative;z-index:2}
304
304
  .clearai-seg{display:inline-flex;border:.5px solid var(--dsw-alias-border-l3);border-radius:999px;padding:2px}
305
305
  .clearai-seg>span{padding:2px 12px;border-radius:999px;cursor:pointer;color:var(--dsw-alias-label-secondary);white-space:nowrap}
306
306
  .clearai-seg>span[data-on="1"]{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-label-primary-inverted)}
@@ -314,6 +314,14 @@ window.__ModuleLoader__.load({
314
314
  .clearai-graph-body[data-side="1"]{flex-direction:row}
315
315
  .clearai-graph-canvas{height:340px;border:.5px solid var(--dsw-alias-border-l2);border-radius:10px;overflow:hidden;background:var(--dsw-alias-bg-base)}
316
316
  .clearai-graph[data-full="1"] .clearai-graph-canvas{height:auto;flex:1 1 auto;min-width:0}
317
+ /**
318
+ * 全屏是自画的覆盖层(fixed / inset:0 / z-index:40),画布与右下角抽屉都长在它里面。
319
+ * 「退出全屏」原来只是工具条里的一个文字链接(没有快捷键、也不保证不被画布盖住)——
320
+ * 一旦它被遮住或换行挤出视口,用户只能刷新页面(社区 issue #33)。
321
+ * 所以全屏时把退出入口做成浮层里的固定按钮:比覆盖层高一档(z-index 41),永远在右上角。
322
+ */
323
+ .clearai-graph[data-full="1"] .clearai-link[data-exit="1"]{position:fixed;top:12px;right:20px;z-index:41;padding:3px 10px;border:.5px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--dsw-alias-bg-base);text-decoration:none}
324
+ .clearai-graph[data-full="1"] .clearai-link[data-exit="1"]:hover{border-color:var(--dsw-alias-label-secondary)}
317
325
  .clearai-graph-side{flex:0 0 auto}
318
326
  .clearai-graph-body[data-side="1"] .clearai-graph-side{width:380px;overflow-y:auto}
319
327
  .clearai-graph-problems{margin-top:6px;font-size:11.5px;color:var(--dsw-alias-label-secondary)}.clearai-graph-problems summary{cursor:pointer;color:var(--dsw-alias-state-warn-primary)}.clearai-graph-problems>div{padding:2px 0 2px 12px;line-height:1.5}.clearai-graph-problems>div[data-sev=info]{opacity:.7}.clearai-graph-problems code{font-size:11px}
@@ -2693,6 +2701,21 @@ window.__ModuleLoader__.load({
2693
2701
  return () => clearTimeout(timer)
2694
2702
  }, [fullscreen, layer, picked !== null, allNodes.length])
2695
2703
 
2704
+ /**
2705
+ * **Escape 退出全屏**(issue #33)。
2706
+ *
2707
+ * 全屏是自画的覆盖层,不是原生 Fullscreen API,所以浏览器不会自己给退出键;
2708
+ * 退出入口又只有一个文字链接。这里挂一个 window 级监听(焦点在画布任意位置都能退,
2709
+ * 退出全屏或卸载时摘掉),并在根节点上同时接 onKeyDown —— 事件在组件内冒泡时同样生效,
2710
+ * 且这条接线在测试里可以直接验。
2711
+ */
2712
+ React.useEffect(() => {
2713
+ if (fullscreen !== true || typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
2714
+ const onKey = (event) => { if (event?.key === 'Escape') onToggleFullscreen() }
2715
+ window.addEventListener('keydown', onKey)
2716
+ return () => window.removeEventListener('keydown', onKey)
2717
+ }, [fullscreen, onToggleFullscreen])
2718
+
2696
2719
  /** 全屏时小卡走右侧抽屉:摆在画布下方会把画布压矮,刚点开的那个点直接掉出可视区。 */
2697
2720
  const sideBySide = fullscreen === true
2698
2721
  const empty =
@@ -2701,7 +2724,12 @@ window.__ModuleLoader__.load({
2701
2724
  : t('本体图暂无内容。模型在 clear/ontology/concepts/ 与 relations/ 下建立概念与关系文件后,将在此显示。')
2702
2725
  return h(
2703
2726
  'div',
2704
- { className: 'clearai-graph', 'data-full': fullscreen === true ? '1' : '0' },
2727
+ {
2728
+ className: 'clearai-graph',
2729
+ 'data-full': fullscreen === true ? '1' : '0',
2730
+ /** 覆盖层内也认 Escape(见上面的 window 监听):两条一起,焦点在哪都能退。 */
2731
+ onKeyDown: fullscreen === true ? (event) => { if (event?.key === 'Escape') onToggleFullscreen() } : undefined,
2732
+ },
2705
2733
  h(
2706
2734
  'div',
2707
2735
  { className: 'clearai-graph-bar' },
@@ -2721,7 +2749,7 @@ window.__ModuleLoader__.load({
2721
2749
  ),
2722
2750
  h('span', { style: { flex: '1 1 auto' } }),
2723
2751
  allNodes.length === 0 ? null : h('span', { className: 'clearai-link', onClick: () => rfRef.current?.fitView?.({ padding: 0.18, duration: 200 }) }, t('适配')),
2724
- h('span', { className: 'clearai-link', onClick: onToggleFullscreen }, fullscreen === true ? t('退出全屏') : t('全屏')),
2752
+ h('span', { className: 'clearai-link', 'data-exit': '1', onClick: onToggleFullscreen }, fullscreen === true ? `${t('退出全屏')} (Esc)` : t('全屏')),
2725
2753
  ),
2726
2754
  h(
2727
2755
  'div',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clearai-dsh",
3
- "version": "0.5.4-rc.1",
3
+ "version": "0.5.5",
4
4
  "description": "ClearAI: an ontology-first DSH agent preset — evidence-checked research that grows into a domain ontology.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -16,12 +16,20 @@
16
16
 
17
17
  # ── 身份 ────────────────────────────────────────────────────────────────────
18
18
 
19
- # 预设自己的 persona,覆盖部署默认。`{{model}}`/`{{cwd}}` 由 agent 自己的路由与工作区解析。
19
+ # 预设自己的 persona,覆盖部署默认。
20
+ #
21
+ # **刻意不写 `{{cwd}}` / `{{model}}` 这类模板变量**:宿主在渲染提示词时按**变量表**严格解析,
22
+ # 表里没有的名字会让整轮直接抛错(`unknown prompt variable "{{cwd}}" in section …`),
23
+ # 而各宿主版本注册的变量并不一样 —— 社区 issue #34 就是某些宿主的表里只有 provider/model、
24
+ # 没有 cwd,ClearAI 会话起不来。工作区的绝对路径本来由宿主的运行时上下文给出,
25
+ # 这里只写产品含义(工作区 = 用户的文件夹),不依赖模板变量。
26
+ #
27
+ # 变量契约由 test/prompt-sections.test.mjs 钉住:预设里若再出现 `{{…}}`,必须是宿主注册过的名字。
20
28
  - id: persona
21
29
  name: '@deepseek-ai/dsh-persona'
22
30
  config:
23
31
  prefix: '你是 ClearAI 的主人格,运行在 DeepSeek Harness 上。怎么工作见下面三段:身份、循环、对人说话。'
24
- suffix: 你的工作目录是 {{cwd}}。工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
32
+ suffix: 工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
25
33
 
26
34
  - id: agent-instructions
27
35
  name: '@deepseek-ai/dsh-agent-instructions'
@@ -33,12 +33,20 @@
33
33
 
34
34
  # ── 身份 ────────────────────────────────────────────────────────────────────
35
35
 
36
- # 预设自己的 persona,覆盖部署默认。`{{model}}`/`{{cwd}}` 由 agent 自己的路由与工作区解析。
36
+ # 预设自己的 persona,覆盖部署默认。
37
+ #
38
+ # **刻意不写 `{{cwd}}` / `{{model}}` 这类模板变量**:宿主在渲染提示词时按**变量表**严格解析,
39
+ # 表里没有的名字会让整轮直接抛错(`unknown prompt variable "{{cwd}}" in section …`),
40
+ # 而各宿主版本注册的变量并不一样 —— 社区 issue #34 就是某些宿主的表里只有 provider/model、
41
+ # 没有 cwd,ClearAI 会话起不来。工作区的绝对路径本来由宿主的运行时上下文给出,
42
+ # 这里只写产品含义(工作区 = 用户的文件夹),不依赖模板变量。
43
+ #
44
+ # 变量契约由 test/prompt-sections.test.mjs 钉住:预设里若再出现 `{{…}}`,必须是宿主注册过的名字。
37
45
  - id: persona
38
46
  name: '@deepseek-ai/dsh-persona'
39
47
  config:
40
48
  prefix: '你是 ClearAI 的主人格,运行在 DeepSeek Harness 上。怎么工作见下面三段:身份、循环、对人说话。'
41
- suffix: 你的工作目录是 {{cwd}}。工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
49
+ suffix: 工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
42
50
 
43
51
  - id: agent-instructions
44
52
  name: '@deepseek-ai/dsh-agent-instructions'
@@ -259,7 +259,6 @@ const CONTRIB_DEFAULTS = {
259
259
  * 清单校验:装配语义——清单里出现表外的名字当场抛错,
260
260
  * 而不是静默少装一件工具、等某一轮才发现。错法一律装配期抛错:
261
261
  * unknown_mechanism / unknown_tool / tool_of_disabled_mechanism / unknown_policy_slot
262
- * / unknown_budget / unknown_budget_tier / invalid_budget
263
262
  */
264
263
  function resolveContributions(contributions) {
265
264
  const declared = contributions ?? {}
@@ -4800,7 +4799,17 @@ export function apply(ctx, config = {}) {
4800
4799
  }
4801
4800
  }
4802
4801
 
4803
- // ═══ 事实边界:保护「系统所有」的路径 + bash 危险闸门 + L4 人放行 ═══════
4802
+ // ═══ 事实边界:保护「系统所有」的路径 + shell 危险闸门 + L4 人放行 ═══════
4803
+
4804
+ /**
4805
+ * 门对**所有 shell 工具**生效:bash 与 pwsh。
4806
+ *
4807
+ * 从前三处硬边界都写死 `exec.name === 'bash'`,而本预设按平台只挂一个 shell
4808
+ * (`tool-bash` 在 win32 禁用,`tool-pwsh` 只在 win32 挂上,见 agent.cordis.yml)——
4809
+ * 于是 Windows 上危险命令闸、系统路径写检测、L4 人放行**整体失效**,
4810
+ * 而它们本该是平台无关的硬边界(社区 issue #30)。
4811
+ */
4812
+ const SHELL_TOOLS = new Set(['bash', 'pwsh'])
4804
4813
 
4805
4814
  const DENY_REASONS = [
4806
4815
  [
@@ -4835,6 +4844,26 @@ export function apply(ctx, config = {}) {
4835
4844
  },
4836
4845
  ],
4837
4846
  [['拉起宿主应用', 'launching the host app'], (command) => /\.app\/Contents\/MacOS\/|\bopen\s+-a\b/.test(command)],
4847
+ // ── pwsh 形态:Windows 上本预设只挂 pwsh,这几种写法缺了门就等于没有闸门。──
4848
+ [
4849
+ ['递归删除系统路径(pwsh)', 'recursive delete of a system path (pwsh)'],
4850
+ (command) => {
4851
+ const match = /(^|[;&|]\s*)remove-item\s+([^;&|]*)/i.exec(command)
4852
+ if (match === null) return false
4853
+ const segment = match[2]
4854
+ if (!(/(^|\s)-[a-z]*r/i.test(segment) || segment.includes('--recurse'))) return false
4855
+ for (const token of segment.split(/\s+/)) {
4856
+ if (token === '' || token.startsWith('-')) continue
4857
+ const bare = token.replace(/^["']|["']$/g, '').replace(/^env:/i, '').toLowerCase()
4858
+ if (bare === '/' || bare === '~' || bare.startsWith('~/') || bare === '%systemroot%' || bare.startsWith('%systemroot%\\') || bare.startsWith('%systemroot%/') || /^\/[^/]+$/.test(bare) || /^[a-z]:\\?$/.test(bare) || /^[a-z]:\\windows\\?$/.test(bare)) return true
4859
+ }
4860
+ return false
4861
+ },
4862
+ ],
4863
+ [['远程脚本直灌 shell(pwsh)', 'remote script piped into a shell (pwsh)'], (command) => /(iwr|invoke-webrequest|invoke-restmethod|curl|wget)\b[^;&|]*\|\s*(iex|invoke-expression)\b/i.test(command)],
4864
+ [['动态执行下载内容(pwsh)', 'dynamic execution of downloaded content (pwsh)'], (command) => /(iex|invoke-expression)\b[^;&|]*((iwr|invoke-webrequest|invoke-restmethod|curl|wget)\b|https?:\/\/)/i.test(command)],
4865
+ [['卷格式化(pwsh)', 'volume formatting (pwsh)'], (command) => /(^|[;&|]\s*)format-volume\b|(^|[;&|]\s*)format\s+[a-z]:/i.test(command)],
4866
+ [['提权(pwsh)', 'privilege escalation (pwsh)'], (command) => /(^|[;&|]\s*)(sudo|gsudo)\s/.test(command)],
4838
4867
  ]
4839
4868
 
4840
4869
  /**
@@ -4868,20 +4897,24 @@ export function apply(ctx, config = {}) {
4868
4897
  return root === undefined ? null : root.join('/')
4869
4898
  }
4870
4899
 
4871
- /** bash 命令里**写**系统格子的迹象:命令里出现了那一格(相对或绝对写法)且带写操作。只读命令不拦。 */
4872
- const WRITE_HINT = /((?<![0-9&])>(?!&|\s*\/dev\/null)|\b(rm|mv|cp|tee|touch|mkdir|ln|chmod|truncate|install|rsync|dd)\b|\bsed\s+-i|\bperl\s+-[a-z]*i)/
4873
- function bashTouchesProtected(sessionId, command) {
4900
+ /**
4901
+ * shell 命令里**写**系统格子的迹象:命令里出现了那一格(相对或绝对写法)且带写操作。只读命令不拦。
4902
+ * 两族 shell 的写动词都要认:bash 的 `rm / tee / sed -i`,pwsh 的 `Remove-Item / Set-Content / Out-File`。
4903
+ */
4904
+ const WRITE_HINT = /((?<![0-9&])>(?!&|\s*\/dev\/null)|\b(rm|mv|cp|tee|touch|mkdir|ln|chmod|truncate|install|rsync|dd|del|ri|ni|sc|si)\b|\b(Remove-Item|Move-Item|Copy-Item|Set-Content|Add-Content|Clear-Content|New-Item|Out-File|Rename-Item|Tee-Object|Set-Item|Set-ItemProperty|Remove-ItemProperty)\b|\bsed\s+-i|\bperl\s+-[a-z]*i)/i
4905
+ function shellTouchesProtected(sessionId, command) {
4874
4906
  if (typeof command !== 'string' || command === '' || !WRITE_HINT.test(command)) return null
4875
4907
  const cwd = sessionCwd(sessionId)
4876
4908
  for (const parts of PROTECTED_REL) {
4877
4909
  const rel = parts.join('/')
4878
- const forms = cwd === null ? [rel] : [rel, join(cwd, ...parts)]
4910
+ // Windows 上模型会用反斜杠写相对路径(`clear\knowledge\facts\x.json`):只认正斜杠的门会当场漏掉。
4911
+ const forms = cwd === null ? [rel, rel.replaceAll('/', '\\')] : [rel, rel.replaceAll('/', '\\'), join(cwd, ...parts)]
4879
4912
  for (const form of forms) {
4880
4913
  let index = command.indexOf(form)
4881
4914
  while (index !== -1) {
4882
4915
  const rest = command.slice(index + form.length)
4883
- /** 写的是三支本体目录:放行(挪目录正是重新分层的方式)。 */
4884
- if (!(parts.at(-1) === 'ontology' && ONTOLOGY_BRANCH_DIRS.some((branch) => rest.startsWith(`/${branch}`)))) return rel
4916
+ /** 写的是三支本体目录:放行(挪目录正是重新分层的方式)。反斜杠写法同样放行。 */
4917
+ if (!(parts.at(-1) === 'ontology' && ONTOLOGY_BRANCH_DIRS.some((branch) => rest.startsWith(`/${branch}`) || rest.startsWith(`\\${branch}`)))) return rel
4885
4918
  index = command.indexOf(form, index + form.length)
4886
4919
  }
4887
4920
  }
@@ -5011,7 +5044,7 @@ export function apply(ctx, config = {}) {
5011
5044
  * 是模型自己的,写进去要过第一道校验。
5012
5045
  */
5013
5046
  const writing = exec.name === 'write' || exec.name === 'edit'
5014
- const suspect = writing ? (protectedPath(sessionId, args.file_path) ?? protectedPath(sessionId, args.path)) : exec.name === 'bash' ? bashTouchesProtected(sessionId, args.command) : null
5047
+ const suspect = writing ? (protectedPath(sessionId, args.file_path) ?? protectedPath(sessionId, args.path)) : SHELL_TOOLS.has(exec.name) ? shellTouchesProtected(sessionId, args.command) : null
5015
5048
  if (suspect !== null) {
5016
5049
  return {
5017
5050
  kind: 'deny',
@@ -5025,12 +5058,12 @@ export function apply(ctx, config = {}) {
5025
5058
  }
5026
5059
  }
5027
5060
  }
5028
- if (CFG.bashDenyRules && exec.name === 'bash' && typeof args.command === 'string') {
5061
+ if (CFG.bashDenyRules && SHELL_TOOLS.has(exec.name) && typeof args.command === 'string') {
5029
5062
  for (const [reason, test] of DENY_REASONS) {
5030
- if (test(args.command)) return { kind: 'deny', reason: tr(`危险的 bash 命令(${reason[0]}):改写命令避开这种写法(dangerous bash command)`, `dangerous bash command (${reason[1]}); rewrite the command to avoid this pattern`) }
5063
+ if (test(args.command)) return { kind: 'deny', reason: tr(`危险的 shell 命令(${reason[0]}):改写命令避开这种写法(dangerous shell command)`, `dangerous shell command (${reason[1]}); rewrite the command to avoid this pattern`) }
5031
5064
  }
5032
5065
  }
5033
- if (owned && exec.name === 'bash' && typeof args.command === 'string') {
5066
+ if (owned && SHELL_TOOLS.has(exec.name) && typeof args.command === 'string') {
5034
5067
  const denied = await releaseIrreversible(exec, sessionId, state, args.command)
5035
5068
  if (denied !== null) return denied
5036
5069
  }
@@ -38,7 +38,7 @@ description: Use when working inside the ClearAI preset and a delivery keeps get
38
38
 
39
39
  `holds=yes` 这一步就完成,不管 `results` 是支持、推翻还是说不清。推翻和说不清照样记成证据,判断的状态由证据算。评估卡写不进来时裁决降级为 `unknown`,这一步不推进,绝不静默放行。
40
40
 
41
- 评估卡、证据、事实由系统落盘;`clear/evidence`、`clear/knowledge/facts`、`clear/knowledge/lessons`、`clear/goals` 你都写不了。重评产生新证据,旧证据不改不删。
41
+ 评估卡、证据、事实由系统落盘;`clear/evidence`、`clear/knowledge/facts`、`clear/knowledge/lessons`、`clear/knowledge/negatives`、`clear/goals` 你都写不了。重评产生新证据,旧证据不改不删。
42
42
 
43
43
  ## 本体文件被拒或被标出来
44
44
 
@@ -95,7 +95,7 @@ One card carries two verdicts, each answering its own question:
95
95
 
96
96
  With `holds=yes` the step is complete, whatever `results` says. Refute and inconclusive are recorded as evidence all the same, and the judgment's status is computed from the evidence. If the card cannot be written, the verdict degrades to `unknown` and the step does not advance; it is never silently let through.
97
97
 
98
- The system writes evaluator cards, evidence and facts; you cannot write `clear/evidence`, `clear/knowledge/facts`, `clear/knowledge/lessons` or `clear/goals`. A re-evaluation adds new evidence; old evidence is never changed or deleted.
98
+ The system writes evaluator cards, evidence and facts; you cannot write `clear/evidence`, `clear/knowledge/facts`, `clear/knowledge/lessons`, `clear/knowledge/negatives` or `clear/goals`. A re-evaluation adds new evidence; old evidence is never changed or deleted.
99
99
 
100
100
  ## When an ontology file is refused or flagged
101
101