dsh-progress-union 0.7.3 → 0.7.4

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,6 +2,19 @@
2
2
 
3
3
  本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
4
4
 
5
+ ## 0.7.4 (2026-12-04)
6
+
7
+ **fix(download):工具名本身就是解释器(实测 `pwsh`)时不再被 `isShell` 门拦下。**
8
+
9
+ 真机回灌(沙箱宿主 0.2.2-rc.5 + dsh-progress-union 0.7.3):改发 `curl.exe -L -o dl073/echarts.tgz http://registry.npmmirror.com/…`,面板 88 帧探针仍 `basis=""` / `subbar=NO-SUBBAR`。但板面 `current` 供出了真因:`自动同步:pwsh · command=New-Item -ItemType Directory -Force -Path dl073 | Out-Null; curl.exe -` —— 这行里的 `pwsh` 是 `lastTool.name`,即宿主把跑命令的工具直接报成解释器名,而不是 `Bash`。0.7.3 只修了命令词表,而 `classifyDownload` 在 `isShell` 那道门上就 `return null`,后面的首词归一与引号体拆分根本轮不到。
10
+
11
+ - **新增 `SHELL_INTERPRETERS` + `isShellToolName()`**:除工具名白名单外,再认一批「解释器即工具名」的形状(`sh/bash/zsh/ksh/dash/fish/nu/xonsh/busybox/pwsh/powershell/powershell_ise/cmd/command.com`),判定前先取 basename 并剥 `.exe/.cmd/.bat/.ps1`,所以 `C:\Program Files\PowerShell\7\pwsh.exe` 也算 shell 通道。
12
+ - **两处消费面同时接入**:`classifyDownload` 的 `isShell` 门改为 `isShellToolName(toolKey)`;`describeToolStep` 的 shell 分支同样改用它 —— 否则 Windows 会话里「工序人话」依旧退回 `pwsh` 裸名而不是一句话。
13
+ - **白名单补齐**:`SHELL_TOOL_NAMES` 补 `shell_exec / shell_run / run_shell / terminal_run`(宿主侧另一类常见命法)。
14
+ - **不放宽误判面**:`read_file` / `mcp__tools__fetch` 这类不在词表里的工具名,即使参数里带了 `command` 也仍然返回 `null`;解释器名但拿不出命令文本同样 `null`(软感知纪律不变)。
15
+ - **测试**:`test/download-classify.test.mjs` +3 用例(共 22):pwsh/powershell 工具名命中真机命令串、非 shell 工具名不得被解释器名规则误放、`describeToolStep('pwsh', …)` 出人话。`npm test` **242 pass / 0 fail**(239 → +3),零回归。
16
+
17
+
5
18
  ## 0.7.3 (2026-12-04)
6
19
 
7
20
  **fix(download):Windows 宿主上 `curl.exe` / `Invoke-WebRequest` / `pwsh -Command "…"` 全漏识别,下载子条根本不出来。**
package/README.md CHANGED
@@ -268,7 +268,7 @@ assistant:
268
268
  ## 开发与测试
269
269
 
270
270
  ```bash
271
- npm test # node --test test/*.test.mjs(239 用例,纯 mock ctx,无需宿主进程)
271
+ npm test # node --test test/*.test.mjs(242 用例,纯 mock ctx,无需宿主进程)
272
272
  ```
273
273
 
274
274
  ## 冷启动接续(v0.6.2)
@@ -293,6 +293,8 @@ npm test # node --test test/*.test.mjs(239 用例,纯 mock ctx,无需宿
293
293
 
294
294
  **Windows 宿主形状(v0.7.3)**:DSH 的 Bash 工具在 Windows 上实落 pwsh,命令名常带 `.exe` 后缀与路径前缀,真下载还常被裹在 `pwsh -Command "…"` 的引号体里。分类器因此做三件事:首词先过 `normalizeHead`(剥引号 → 取 basename → 去 `.exe/.cmd/.bat/.ps1`),shell 包层的引号体额外再切一段(只拆一层),下载器词表补 PowerShell 自有的 `Invoke-WebRequest/iwr/Invoke-RestMethod/irm/Start-BitsTransfer`。反例仍然拦得住:`git.exe status`、`New-Item -ItemType Directory`、`pwsh -Command "Get-Process …"` 依旧返回 `null`。
295
295
 
296
+ **工具名即解释器(v0.7.4)**:上面那些只修到命令串,而真机上更靠外的一道门是工具名本身——宿主在 Windows 上报的是 `pwsh` 而不是 `Bash`,不在 shell 名单里时整条识别直接结束。现在 `isShellToolName()` 先取 basename 并剥 `.exe/.cmd/.bat/.ps1`,再比对解释器集(`pwsh/powershell/sh/bash/zsh/ksh/dash/fish/nu/xonsh/busybox/cmd`),`classifyDownload` 的 `isShell` 门与 `describeToolStep` 的 shell 分支共用它,所以子条与工序人话在 `pwsh` 会话里一起活过来。不在词表里的工具名(`read_file` 等)即使带 `command` 仍不算 shell 通道。
297
+
296
298
  ## 下载子进度条(v0.7.0)
297
299
 
298
300
  输入框上方的迷你条在主条行之后渲染一行子条,真值全部来自本插件自解析 `tool/result`(`parseProgress` 覆盖 wget/curl 的 `45%` 与 `12.3MB/27.8MB`、pip/uv 单尾单位、git `Receiving objects: 62%`、pnpm `[3/12]`),**零跨插件依赖**。
package/client.js CHANGED
@@ -24,7 +24,7 @@ window.__ModuleLoader__.load({
24
24
  var REPO_URL = "https://github.com/drscrewdriver/dsh-progress-union";
25
25
  var STAR_NS = "progress-union";
26
26
  var STAR_GEN = "v4"; /* ladder:gen */
27
- var STAR_VERSION = "0.7.3"; /* ladder:ver */
27
+ var STAR_VERSION = "0.7.4"; /* ladder:ver */
28
28
  var LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
29
29
 
30
30
  // 三代共享:GitHub 单色 mark(octicon 轮廓,fill 随 currentColor)。
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-progress-union",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "main": "./index.js",
5
5
  "description": "进度结合原型:board 槽位真相源(用户可编辑、diff+ack 增量同步、staleness nudge)× 鲸程时间引擎(step 计数、ETA 三档 board>todo>local>prior、悬浮迷你条),向压缩插件暴露只读三层进度锚点 progressAnchor(board 语义锚 + time 时间锚 + userEdits 未确认改动,service 与 HTTP 双平面),并在 0.6.0 起每回合落一版会话归档(handoff 规则摘要 + 重启注入一次)。",
6
6
  "engines": {
package/index.js CHANGED
@@ -173,11 +173,24 @@ export const inject = ['tools', 'systemPrompt', 'webServer', 'agents', 'commands
173
173
  // ============================================================================
174
174
 
175
175
  // 跑命令的工具名(跨宿主常见命名,大小写不敏感)。
176
- const SHELL_TOOL_NAMES = new Set(['bash', 'shell', 'terminal', 'terminal_send', 'terminal_exec', 'exec', 'execute', 'run', 'run_command', 'command', 'cmd'])
176
+ const SHELL_TOOL_NAMES = new Set(['bash', 'shell', 'terminal', 'terminal_send', 'terminal_exec', 'exec', 'execute', 'run', 'run_command', 'command', 'cmd', 'shell_exec', 'shell_run', 'run_shell', 'terminal_run'])
177
177
  // 本身就是「把东西拉到本地」语义的工具名(非 shell 通道)。
178
178
  const FETCH_TOOL_NAMES = new Set(['download', 'download_file', 'fetch_file', 'git_clone'])
179
179
  // 明确的后台执行器:走 shell 词表,但默认记为 background。
180
180
  const BACKGROUND_TOOL_NAMES = new Set(['background_exec', 'exec_background', 'shell_background', 'run_in_background', 'terminal_spawn'])
181
+ // 0.7.4 真机回灌:宿主会把「跑命令」的工具名直接报成解释器本身——Windows 上实测是
182
+ // `pwsh`(不是 `Bash`)。只列 bash/shell/terminal 家族的话 isShell=false,下载识别
183
+ // 与工序人话在第一道门就整体失效,UI 永远看不到子进度条。
184
+ const SHELL_INTERPRETERS = new Set(['sh', 'bash', 'zsh', 'ksh', 'dash', 'fish', 'nu', 'xonsh', 'busybox', 'pwsh', 'powershell', 'powershell_ise', 'cmd', 'command.com'])
185
+
186
+ /** 这个工具名是不是「跑一条命令」的通道(含后台执行器与解释器名形态)。 */
187
+ function isShellToolName(raw) {
188
+ const key = String(raw || '').toLowerCase()
189
+ if (!key) return false
190
+ if (SHELL_TOOL_NAMES.has(key) || BACKGROUND_TOOL_NAMES.has(key)) return true
191
+ const name = key.split(/[\\/]/).pop().replace(/\.(?:exe|cmd|bat|ps1)$/, '')
192
+ return SHELL_INTERPRETERS.has(name)
193
+ }
181
194
 
182
195
  // 包管理器 / 安装器的「动词」集合:只在这些动词后才是真正的下载/安装。
183
196
  // 排除 test/list/status/run/show/freeze —— 它们不产生网络拉取(误判会把每次 npm test 当下载)。
@@ -302,7 +315,7 @@ function classifyDownload(name, argsRaw) {
302
315
  return target ? { kind: 'download', target, background, command: '' } : null
303
316
  }
304
317
  // 后台执行器也是跑命令的通道,否则 `exec_background({command:'wget …'})` 会漏识别。
305
- const isShell = SHELL_TOOL_NAMES.has(toolKey) || BACKGROUND_TOOL_NAMES.has(toolKey)
318
+ const isShell = isShellToolName(toolKey)
306
319
  if (!isShell || !command) return null
307
320
 
308
321
  // 后台线索:独立的一个 &(两侧不是另一个 &,且自成一词)、nohup、--detach、> log &
@@ -584,7 +597,7 @@ function describeToolStep(name, argsRaw, maxLen) {
584
597
  try { const v = JSON.parse(String(u.argsRaw || '')); if (isObject(v)) o = v } catch (_err) {}
585
598
  const cap = Math.max(8, Number(maxLen) || 46)
586
599
  let out = ''
587
- if (SHELL_TOOL_NAMES.has(key) || BACKGROUND_TOOL_NAMES.has(key)) {
600
+ if (isShellToolName(key)) {
588
601
  const cmd = argText(o, ['command', 'cmd', 'input', 'text']) || (typeof u.argsRaw === 'string' ? u.argsRaw : '')
589
602
  out = glossCommand(cmd)
590
603
  } else if (FETCH_TOOL_NAMES.has(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-progress-union",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "type": "module",
5
5
  "description": "进度结合原型:dsh-progress-board 槽位真相源 × 鲸程 widget 时间/ETA 引擎;向压缩插件暴露只读三层进度锚点(service + HTTP 双平面);0.6.0 起每回合落一版会话归档(handoff + 重启注入一次)。基于 l3j3y3/dsh-progress-board (MIT) 与 uuhihj/task-progress-bar dsh-progress-widget (MIT)。",
6
6
  "license": "MIT",
@@ -249,3 +249,36 @@ test('glossCommand:Windows 命令名给人话而不是退回 Bash×n', async (
249
249
  assert.match(glossCommand('Invoke-WebRequest -Uri https://x -OutFile y'), /下载文件/)
250
250
  assert.match(glossCommand('git.exe clone https://github.com/a/b'), /克隆|拉取/)
251
251
  })
252
+
253
+ // ── v0.7.4:工具名本身是解释器(宿主实测报成 `pwsh` 而不是 `Bash`)──
254
+ // 0.7.3 只修了命令词表,但 isShell 这道门在上一行就把整条判成非 shell,
255
+ // 所以下面这些形状在 0.7.3 上依旧全漏——这两个用例就是那次的真机回灌。
256
+ test('classifyDownload:工具名为 pwsh/powershell 时不再被 isShell 门拦下', () => {
257
+ const pwsh = (command) => ['pwsh', JSON.stringify({ command })]
258
+ const real = 'New-Item -ItemType Directory -Force -Path dl073 | Out-Null; curl.exe -L -o dl073/echarts.tgz http://registry.npmmirror.com/echarts/-/echarts-5.5.0.tgz'
259
+ const hit = classifyDownload(...pwsh(real))
260
+ assert.equal(hit?.kind, 'download', 'pwsh 工具名 + 分号后的 curl.exe 必须命中')
261
+ assert.equal(hit.target, 'echarts.tgz')
262
+
263
+ assert.equal(classifyDownload(...pwsh('wget https://example.com/a.bin')).kind, 'download')
264
+ const p2 = ['powershell', JSON.stringify({ command: 'Invoke-WebRequest -Uri https://example.com/files/big.iso -OutFile big.iso' })]
265
+ assert.equal(classifyDownload(...p2).target, 'big.iso')
266
+ const p3 = ['C:\\Program Files\\PowerShell\\7\\pwsh.exe', JSON.stringify({ command: 'git.exe clone https://github.com/a/b' })]
267
+ assert.equal(classifyDownload(...p3).kind, 'clone')
268
+ assert.equal(classifyDownload(...pwsh('npm install lodash')).kind, 'install')
269
+ })
270
+
271
+ test('classifyDownload:解释器名不得把非 shell 工具变成 shell', () => {
272
+ // read/search 这类工具名不在词表里,带了 command 字段也不许当下载通道。
273
+ assert.equal(classifyDownload('read_file', JSON.stringify({ command: 'curl -O https://x/a.bin' })), null)
274
+ assert.equal(classifyDownload('mcp__tools__fetch', JSON.stringify({ command: 'wget https://x/a.bin' })), null)
275
+ // 解释器名但拿不出命令文本 → 仍然 null,不臆造。
276
+ assert.equal(classifyDownload('pwsh', JSON.stringify({})), null)
277
+ })
278
+
279
+ test('describeToolStep:pwsh 工具名走 shell 分支而不是退回空串', async () => {
280
+ const { describeToolStep } = await import('../index.js')
281
+ const step = describeToolStep('pwsh', JSON.stringify({ command: 'New-Item -ItemType Directory -Force -Path d1 | Out-Null; curl.exe -L -o a.bin http://x/a.bin' }), 46)
282
+ assert.ok(step, 'pwsh 形态必须有人话')
283
+ assert.match(step, /建目录或文件|发 HTTP 请求|下载/)
284
+ })