dsh-bash-terminal-ts 0.9.6-rc.3 → 0.9.6
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 +34 -0
- package/README.en.md +8 -0
- package/README.md +9 -0
- package/dsh.plugin.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.6 (2026-11-29)
|
|
4
|
+
|
|
5
|
+
**R1 预设全屏蔽 + R2 终端历史回顾:本计划的完整落地。**
|
|
6
|
+
|
|
7
|
+
### R1 预设全屏蔽(rc.1)
|
|
8
|
+
|
|
9
|
+
- `standard-win` 预设模板中官方 `tool-pwsh` 行从 `disabled: !!js process.platform !== 'win32'` 改为 `disabled: true`;`tool-bash` 行保持 `disabled: true`。注释块与 persona 的 `Shell tool routing` 行同步重写。`preset.yml` description / `agent-presets/README.md` 表行与段落同步。屏蔽属 per-preset:“少一个入口”、宿主 `bash-sandbox` / `pwsh-sandbox` 与 `ctx.shell` 接缝不动。
|
|
10
|
+
|
|
11
|
+
### R2 `terminal {action:"history"}`(rc.2 → rc.4)
|
|
12
|
+
|
|
13
|
+
- **`src/history.ts`**(rc.2):`redactCommand` 与 `stripAnsi` 为安全基元;`parsePsReadLine` / `parseBashHistory` / `historyCandidates` / `readShellHistory` / `groupByCwd` 实现 shell 历史读取;`ScreenHistoryStore` 实现已关会话的 LRU + 可选落盘。仅依赖 `node:fs/promises` / `node:child_process` / `node:path` / `node:crypto`,六条兼容线行为一致。
|
|
14
|
+
- **工具接线**(rc.3):`src/terminal.ts` 新增 `action:"history"` 分支与 `source`/`pattern`/`cwd`/`limit` 四参数;`createTerminalRegistry(ctx, onRetire?)` 新第二参;既六动作行为完全不变。
|
|
15
|
+
- **配置闸门**(rc.3):`historyShell:false / volatile`、`historyEntries:20`、`historyMaxBytes:65536`、`historyPath:""` 四个新 Config 字段;`apply()` 创建 store 并 `ctx.effect` 拆卸。
|
|
16
|
+
- **屏幕采集**(rc.3):`webterminals/registry.ts` 开可选 `UiRegistryOptions.onRetire?(info, snapshot)`,`mount.ts` 透传。未注入时行为与旧版完全一致。
|
|
17
|
+
- **设置页**(rc.3):`client.tsx` 新增两行——「命令历史回顾」开关与「历史条数」输入;`locales.ts` 4 键 × 10 语。
|
|
18
|
+
- **测试与文档**(rc.4):`test/history.ts` 28 断言(脱敏 8 类 × 十行反例、五候选 shell、WSL fake-spawn、LRU 淘汰、截尾 flag、persist/load 往返、坏 JSON 容错);`test/terminal.ts` 开一个隔离的 `toolWithHistory`,四场景验证闸门、空存储、回读命中、参数校验;`README.md` 与 `README.en.md` 新增「终端历史回顾」节。`package.json` test 链接入 `test-dist/history.js`。
|
|
19
|
+
|
|
20
|
+
### Phase 9(真机验收)与 API 冻结
|
|
21
|
+
|
|
22
|
+
- Phase 9(需 profile 装机 + 手动目测)与本仓 CI 无交集,已在 README 中列为“开 `historyShell` 后跑一次 `source:"shell"` + 一次 open→send→close→`source:"screen"`”。
|
|
23
|
+
- 本版本后 `history` 动作的 schema(`source`/`pattern`/`cwd`/`limit` 四字段与三值枚举)、`redactCommand` 正则集合、`ScreenHistoryStore` LRU 行为与落盘机制均冻结;后续补丁只修实际发现的小缺陷(rc 阶梯见 v0.9.7 / v0.9.8),新能力属 v0.10.0+ 独立计划。
|
|
24
|
+
|
|
25
|
+
## 0.9.6-rc.4 (2026-11-29)
|
|
26
|
+
|
|
27
|
+
**R2 Phase 7+8:`terminal.js` 四场景断言 + README 两语新增「终端历史回顾」节。**
|
|
28
|
+
|
|
29
|
+
- `test/terminal.ts` 开 `toolWithHistory` 实例,接入一个隔离的 `ScreenHistoryStore({size:5,path:"",maxBytes:512})`;四个场景:
|
|
30
|
+
1. `historyShell:false` + `source:"shell"` 仍返 `kind:"history"` 不抛,携 `note` 提示被配置门控。
|
|
31
|
+
2. `source:"screen"` 空存储 → `entries:[]` + `note` 含 `"no history"`,不抛。
|
|
32
|
+
3. 直接向 store 写一条含 `HIST_MARKER_42` 的尾面,工具回读命中。避开真开 PTY 的 ConPTY 代理 race(文件尾部已有 `process.exit(0)` 兑同目标)。
|
|
33
|
+
4. `source:"bogus"` / `limit:0` / `pattern` 超 512 字 均报错,错误文案包含字段名。
|
|
34
|
+
- `README.md` 新增「终端历史回顾」节 + 设计要点一条项目符号;`README.en.md` 同步。两个文件均声明两数据源语义、默认关与理由、`pattern` 字面量上限、不注入 system prompt、Phase 9 真机验收需手动开 `historyShell` 后跑一次 shell 与 screen 两面。
|
|
35
|
+
- **本次不含**:Phase 9 E2E 真机验收(需 profile 装机 + 手动目测),将伴随 0.9.6 正式版一同验证。
|
|
36
|
+
|
|
3
37
|
## 0.9.6-rc.3 (2026-11-29)
|
|
4
38
|
|
|
5
39
|
**R2 Phase 5+6:`terminal {action:"history"}` 接线、Config 四字段、设置页两行。**
|
package/README.en.md
CHANGED
|
@@ -150,6 +150,14 @@ After restarting DSH, the official “New” dropdown should list `msys-bash.exe
|
|
|
150
150
|
|
|
151
151
|
`terminal` actions: `open` (start a session on the configured default terminal), `send` (write input + read new output), `read`, `signal` (SIGINT = Ctrl+C etc.), `close`, `list` (enumerate live sessions). Reads wait for output to settle (quiet 300ms, cap 5s) so `send` returns the complete reply; buffer overflow reports a `truncated` notice. State (cwd / variables / aliases) persists across calls; end input with `\\n`. Sessions are background jobs (`job_kill` works) and auto-close after 10 idle minutes (`idleMs` overrides on open).
|
|
152
152
|
|
|
153
|
+
## Terminal history review (0.9.6+)
|
|
154
|
+
|
|
155
|
+
- **Two sources, one action**: `terminal {action:"history"}` accepts `source:"shell"` (human-entered commands from PSReadLine / `.bash_history`), `source:"screen"` (the tail of recently closed sessions from the plugin's own `ScreenHistoryStore`), or `source:"auto"` (default: merge shell first then screen). What the agent itself ran is left to the host's `ctx.sessionQuery`; this plugin deliberately does not mirror that axis.
|
|
156
|
+
- **Off by default**: `historyShell:false`. `ConsoleHost_history.txt` stores `--password` / `--token` / `ghp_xxx` verbatim, so the switch stays opt-in; even when enabled, every command passes through `redactCommand` before returning (8 credential-shaped patterns, and long hex strings are preserved so git SHAs stay useful). The screen axis has no gate — the tail is already stripped + redacted on the way in.
|
|
157
|
+
- **Literal `pattern`, not a regex**: capped at 512 characters to keep ReDoS off the model's side. `limit` defaults to `historyEntries: 20` (up to 100). The `cwd` filter uses best-effort grouping (`cd` / `Set-Location` / `Push-Location` scanned in order); multi-statement commands joined by `;` are not split further.
|
|
158
|
+
- **Not injected into the system prompt**: history varies with cwd, and baking it into prompts would blow the request cache. Model invokes on demand.
|
|
159
|
+
- **Phase 9 acceptance is manual**: turn on `historyShell`, run `terminal {action:"history", source:"shell", cwd:"<repo>"}` and a `open → send → close → history source:"screen"` cycle on a real desktop profile. CI asserts wiring + redaction only.
|
|
160
|
+
|
|
153
161
|
## Interactive terminal known limits (ConPTY)
|
|
154
162
|
|
|
155
163
|
- **Windows PowerShell 5.1 cannot start in a ConPTY** (0x8009001d) — install [PowerShell 7](https://github.com/PowerShell/PowerShell/releases) for interactive PowerShell (one-shot commands are unaffected).
|
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ DSH(DeepSeek Harness)插件:一个 `shell` 工具,在 Windows 上统一
|
|
|
43
43
|
- 前端设置页的「默认终端」是枚举(UI 自动渲染为下拉),模型每次调用都只按该设置执行,无法自行切换终端。
|
|
44
44
|
- **钉版 POSIX 运行时载荷(第五个一等终端后端,默认关)**:载荷包 `@drscrewdriver/posix-runtime-win32-x64`(命名政策:我们的制品不带 bash/gitbash/msys token;里面是 Git-for-Windows 运行时树)。两层开关:`enablePosixPayload: true`(操作者门,启动时跑摘要校验)+ 设置页里的「POSIX payload」行开关 `shellPayload`(默认关,决定已装载载荷能否进选择器/被选为默认终端);它有自己的目录行、专属工具描述(bash -lc)、交互终端与 `payload-unconfined` 执法面,**不顶替 Git Bash 槽位**。载荷不随包下载,用 `node scripts/provision-payload.mjs --from <本地 PortableGit SFX>` 自备(反解包 + SHA-256 钉版,自管不取用任何第三方载荷包);**检测到已装 WSL 发行版时只记一条建议日志**(WSL 里的 bash 通常更好用,拿不准选 `wsl`),不屏蔽载荷行——硬门只有摘要校验一条;校验不过即 fail-closed,绝不裸跑、绝不静默换执行器。详见 `src/payload.ts` 头注释。
|
|
45
45
|
- **终端语义预设模板(`agent-presets/`)**:把「默认终端 + 命令语法 + 终端归属权」显式声明在 Agent Preset 层的可分发模板(PowerShell / Git Bash / MSYS2 / WSL2 / 钉版 POSIX 载荷 / Niubash 六变体,含 Terminal authority 锚),用 `npm run presets:install` 装机——对标那些「安装即改写默认终端语义」的插件:同一份 bash-first 体验,由你在预设层自己选,可审计、可复现。
|
|
46
|
+
- **终端历史回顾(`terminal {action:"history"}`)**:新开动作,惰性读取两类历史源——人类在 PSReadLine / `.bash_history` 里手敲过的命令,与刚关闭的终端会话屏幕尾部。默认 `historyShell:false`(因为 PSReadLine 含明文 token/口令);`source:"screen"` 无需开关,任何会话 `close` 后自动进入 `ScreenHistoryStore`(内存 LRU 30 项 + 可选落盘)。既六动作行为与返回完全不变。
|
|
46
47
|
|
|
47
48
|
## 安装(web profile)
|
|
48
49
|
|
|
@@ -261,6 +262,14 @@ powershell -ExecutionPolicy Bypass -File install.ps1 uninstall
|
|
|
261
262
|
|
|
262
263
|
`shell` 工具在受限模式下:PowerShell 会经 `ctx.sandbox.confine` 包装(fail-closed);Git Bash 与 MSYS2 因 Cygwin/MSYS2 与 Windows ACL 受限令牌不兼容而**不包装**(与 dsh 进程同权限);WSL 因独立 Linux VM 不包装。它是**额外的多终端入口**,不享受官方 `pwsh` 工具的 ConstrainedLanguage 限制。DSH 的文件操作工具(read/write/edit)仍受文件沙箱约束。仅在你信任的会话中使用;需要受沙箱保护的 PowerShell 时请继续使用官方 `pwsh` 工具。
|
|
263
264
|
|
|
265
|
+
## 终端历史回顾
|
|
266
|
+
|
|
267
|
+
- **两个数据源,一个入口**:`source:"shell"` 读人类手敲命令历史(PSReadLine 一行一条 / `.bash_history` 多行会合并 `\` 续行、丢弃 `#<epoch>` 时间戳行);`source:"screen"` 读插件自己已关闭会话的屏幕尾部(先 strip ANSI、再过凭据脱敏、最后截尾)。`source:"auto"`(默认)先 shell 后 screen 合并。agent 自己跑过什么属于宿主 `ctx.sessionQuery`,本插件不做第二份历史源。
|
|
268
|
+
- **默认关:`historyShell:false`**——因为 PowerShell 的 `ConsoleHost_history.txt` 会把 `--password` / `--token` / `ghp_xxx` 都按原文存盘。开启后仍会先过 `redactCommand` 才回给模型(8 类凭据形态,十六进制串不脱敏以保护 git SHA)。`ScreenHistoryStore` 无需开关,屏幕尾部已在会话关闭前手动洗过一道。
|
|
269
|
+
- **`pattern` 是字面量子串,不是正则**:避免把 ReDoS 面交给模型;上限 512 字。`limit` 默认从 `historyEntries: 20` 读,上限 100。`cwd` 过滤是启发式归组(扫 `cd` / `Set-Location` / `Push-Location` / `cd --`),多段命令中的 `cd` 不拆行。
|
|
270
|
+
- **不注入 system prompt**:历史内容会随 cwd 变化,写进 prompt 会让请求缓存全失效。做成惰性工具,只在模型主动调时读。
|
|
271
|
+
- **Phase 9 真机验收**:需开启 `historyShell` 后实际调一次 `terminal {action:"history", source:"shell", cwd:"<repo>"}` 与一次先开后关的会话,确认 `sources` 列出 PSReadLine 路径与 `readable:true`、`screen` 尾部能看到 marker 命令。本仓库 CI 不验证真盘,仅验证接线与脱敏。
|
|
272
|
+
|
|
264
273
|
## 交互终端已知限制(ConPTY)
|
|
265
274
|
|
|
266
275
|
- **PowerShell 5.1 无法在 ConPTY 启动**(0x8009001d)—— 交互式 PowerShell 需要安装 [PowerShell 7](https://github.com/PowerShell/PowerShell/releases)(一次性命令不受影响)。
|
package/dsh.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-bash-terminal-ts",
|
|
3
3
|
"name": "dsh-bash-terminal-ts",
|
|
4
|
-
"version": "0.9.6
|
|
4
|
+
"version": "0.9.6",
|
|
5
5
|
"description": {
|
|
6
6
|
"en": "One shell tool that runs commands through PowerShell, Git Bash, MSYS2, WSL or Niubash on Windows, plus an embedded terminal for the bottom dock with per-shell activation switches and a default-shell fallback chain.",
|
|
7
7
|
"zh": "一个 shell 工具,可在 Windows 上通过 PowerShell / Git Bash / MSYS2 / WSL / Niubash 执行命令;另提供底部工作台的内嵌终端,支持按 shell 激活开关与默认 shell 回落链。",
|