@fish-under-sea/dsh-approval-guide 0.2.2 → 1.0.1

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +12 -137
  3. package/README.md +12 -136
  4. package/package.json +4 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fish-under-sea
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.en.md CHANGED
@@ -1,154 +1,29 @@
1
- <div align="center">
2
-
3
1
  # @fish-under-sea/dsh-approval-guide
4
2
 
5
- **Adds a Chinese explanation to every DSH approval prompt: what it will do, what the risks are, and on what basis.**
6
-
7
- [![npm](https://img.shields.io/npm/v/@fish-under-sea/dsh-approval-guide?style=flat-square&label=npm&color=cb3837)](https://www.npmjs.com/package/@fish-under-sea/dsh-approval-guide)
8
- ![license](https://img.shields.io/badge/license-MIT-green?style=flat-square)
9
- ![node](https://img.shields.io/badge/node-%5E22.19.0%20%7C%7C%20%3E%3D24.0.0-339933?style=flat-square)
10
- ![DSH](https://img.shields.io/badge/DSH-%3E%3D0.2.0--rc.2-4b6ef6?style=flat-square)
11
- ![plugin](https://img.shields.io/badge/plugin-client%20%2B%20host-6b7280?style=flat-square)
12
-
13
- [简体中文](README.md) · **English**
14
-
15
- </div>
3
+ **1.0.1 · Approval Guide**
16
4
 
17
- ## What Problem Does This Solve
18
-
19
- The approval dialog already ships some Chinese UI strings ("等待审批", "拒绝", "允许一次"), but **the approval reason generated by the host is English-only**. The most common one looks like this:
20
-
21
- ```text
22
- escalate sandbox to danger-full-access: <one-line English reason from the model>
23
- ```
24
-
25
- The reader has to judge on their own what the command will actually do, how much it will unlock, and what the consequences are — and the English-only template raises that cost. This plugin injects a tiered Chinese explanation below the reason and the command, covering "what it will do / what the risks are / on what basis".
26
-
27
- ## Result
28
-
29
- The detail area inside the approval card becomes:
30
-
31
- ```text
32
- <original command>
33
-
34
- What this approval will do
35
- Escalate the file sandbox scope of this pwsh call to "fully open" (danger-full-access).
36
- Effective only for this single call: no long-lived grant, no effect on later commands.
37
- Risk
38
- Once opened, this command is no longer confined by the workspace boundary: it can read
39
- and write any file on the host, including system directories, other projects, SSH keys,
40
- and credential files, and this execution no longer asks for your approval item by item.
41
- Only allow it if you fully trust this command.
42
- · Tool: pwsh
43
- · Target permission: fully open (danger-full-access)
44
- · Reason given by the model: <original text>
45
- When in doubt, click "Reject" first: rejecting does not interrupt the conversation;
46
- I can retry later with read-only or workspace-write instead.
47
- ```
5
+ [简体中文](README.md)
48
6
 
49
- The explanation is always shown in Chinese and does not follow the UI language — switching the interface to English still leaves the Chinese prompt in place.
7
+ ## Features
50
8
 
51
- ### Tiered Copy
52
-
53
- The Chinese explanation is produced by **static rules**: no extra model call, no API quota consumed, and it cannot be swayed by the requester's own wording.
54
-
55
- | Target permission | Level | Key points of the risk copy |
56
- | --- | --- | --- |
57
- | `danger-full-access` | High (red title) | No longer confined by the workspace boundary; can read and write any file on the host (including system directories, other projects, SSH keys, and credential files); this execution no longer asks for approval item by item. |
58
- | `workspace-write` | Caution | Can write to the current workspace directory and its subdirectories, plus the system temp directory; still cannot write outside the workspace. |
59
- | Other modes | Caution | Not a built-in DSH mode — no precise scope can be given; prompts that the command will run at the requested permission. |
60
- | No sandbox parameter | Caution | Generic fallback: the tool requests a higher permission for this single operation, effective only this time. |
9
+ Adds Chinese action, risk and rationale explanations to approval prompts for files, commands, network access and privilege changes.
61
10
 
62
11
  ## Installation
63
12
 
64
13
  ```sh
65
- # Install from npm (recommended)
66
- dsh plugin --profile <profile> add @fish-under-sea/dsh-approval-guide
67
- ```
68
-
69
- `--profile` should be followed by the actual profile name on your machine: `desktop` for the desktop app, `web` for the web app.
70
-
71
- Use `link:` to point at this directory only when you need to modify the source (the repo source is the install source — restart DSH after changes for them to take effect):
72
-
73
- ```sh
74
- dsh plugin --profile <profile> add "link:<absolute path to this directory>"
75
- ```
76
-
77
- After installation, you need to **restart the DSH app and refresh the page** for it to take effect (the web build has no in-place restart).
78
-
79
- ### Uninstallation
80
-
81
- ```sh
82
- dsh plugin --profile <profile> remove @fish-under-sea/dsh-approval-guide
14
+ dsh plugin --profile <profile> add @fish-under-sea/dsh-approval-guide@1.0.1
83
15
  ```
84
16
 
85
- ### Post-Install Self-Check
86
-
87
- ```sh
88
- dsh --profile <profile> --dump-config
89
- ```
90
-
91
- The end of the output should contain exactly one `- id: approval-guide` / `name: @fish-under-sea/dsh-approval-guide` entry. Multiple entries mean the plugin is mounted more than once, and the app will fail to start.
92
-
93
- ## Usage
94
-
95
- No configuration is needed after installation — the plugin automatically occupies the `conversation.approval.detail` slot of the approval detail area and appends the Chinese explanation to every approval prompt.
96
-
97
- The explanation is resolved in a defense-in-depth order: first read the tool-call arguments `sandbox_permissions` / `justification`; if those are unavailable, parse the host reason template (`escalate sandbox to <mode>: <reason>`); if that also fails, fall back to the generic explanation. Even when every layer fails to produce a value, a generic Chinese explanation is still shown.
98
-
99
- Coverage:
100
-
101
- - All interactive approvals **with a correlated tool call**: sandbox permission escalation, asks triggered by hooks, and asks initiated by other plugins through the approval channel.
102
-
103
- ## Configuration
104
-
105
- **No configuration file.** This package has no configuration options and does not read or write any settings file — all rules are hardcoded in `lib/client.js`.
106
-
107
- ## Compatibility and Boundaries
108
-
109
- - Platform: pure browser plugin (`dsh.client.platform: web`); the host half is an empty implementation.
110
- - Occupies the `conversation.approval.detail` sub-slot of the core package `@deepseek-ai/dsh-client-ui-approval`. The slot is of `single` type, sorted by priority in **ascending order** with the **smallest number rendered**; the official occupier `ApprovalCommand` uses the default priority 0, and this plugin registers with `priority: -1` to override it, while re-rendering the original command inside the component using the same logic (`useChat` to fetch the correlated tool call, parsing `argsRaw.command`) so no information is lost.
111
- - When the component throws, the slot renderer reclaims the entry (abdicate), and the official `ApprovalCommand` automatically resumes rendering — the approval card never goes blank, and the approval flow is never blocked.
112
- - Compatible with both generations of selectors: DSH 0.2.0 (`useSessionStatus`) and 0.1.x (`useSessionPendingInteraction`).
113
-
114
- Data sources:
115
-
116
- | Data | Source |
117
- | --- | --- |
118
- | Command and arguments of the correlated tool call | `useChat` selector (same as the official `ApprovalCommand`) |
119
- | Tool name and approval reason | `useSessionPendingInteraction` / `useSessionStatus` selector (pending interaction with `kind === 'approval'`) |
120
-
121
- ### Known Limitations
122
-
123
- - If an approval request has **no correlated tool call** (missing `callId`), the core does not render the detail area, and this plugin has nowhere to insert. This is dictated by the core slot contract and cannot be worked around by this plugin.
124
- - The Chinese explanation describes the risk at the "permission scope" layer; it does not judge whether the command itself is safe. You still need to read the command yourself.
125
- - If the host changes the reason template (`escalate sandbox to <mode>: <reason>`), the first-layer argument lookup still works; only the second-layer fallback would stop working.
126
-
127
- ## Development and Testing
128
-
129
- ```sh
130
- node packages/dsh-approval-guide/test/guide.test.mjs
131
- ```
132
-
133
- All 12 cases currently pass. The test loads the actual `lib/client.js` that goes into the browser: it uses `node:vm` to provide `window.__ModuleLoader__`, captures the factory registered by the bundle, instantiates it with a fake module table, and directly asserts on the element tree produced by the pure functions and the component. **Zero dependencies** — no need to install React or vitest.
134
-
135
- > Do not use `node --test test/`: the test runner spawns child processes and captures their piped output, which fails with `EPERM` inside a restricted sandbox. Just run the test file directly.
136
-
137
- Cases covered: tiered copy for the two sandbox modes, reason-template fallback parsing, unknown modes, generic approval fallback, corrupted argument JSON, no exception on empty input, component preserves the original command, degradation when pending interaction is unavailable, slot registration priority.
17
+ Also included in `@fish-under-sea/dsh-fish@1.0.1`. Do not expand duplicate rows through both aggregate and standalone bundles. Restart DSH after installation; use the desktop plugin manager when no CLI is available.
138
18
 
139
- Directory layout:
19
+ ## Configuration and Safety
140
20
 
141
- | Path | Purpose |
142
- | --- | --- |
143
- | `lib/index.js` | Host half, empty implementation (pure browser plugin) |
144
- | `lib/client.js` | Browser half: Chinese copy, tiering logic, approval detail component, slot registration |
145
- | `cordis.patch.yml` | Bundle patch layer that inserts the plugin entry into the profile registry |
146
- | `test/guide.test.mjs` | Zero-dependency tests |
21
+ Explanatory only: never grants approval or changes sandbox policy.
147
22
 
148
- ## Relationship with the Aggregation Package
23
+ Node requirement: `^22.19.0 || >=24.0.0`. Host compatibility follows this package manifest; the aggregate does not override Host checks.
149
24
 
150
- > This package is one of the members of the [`@fish-under-sea/dsh-fish`](https://github.com/Fish-under-sea/dsh-fish) aggregation package; installing it alone affects only this single item.
25
+ ## Maintenance and Attribution
151
26
 
152
- ## License
27
+ 1.0.1 is a coordinated release number, not a claim that all latest upstream commits are merged. Historical documentation remains in Git; see [aggregate changelog](https://github.com/Fish-under-sea/dsh-fish/blob/main/CHANGELOG.en.md).
153
28
 
154
- MIT © Fish-under-sea
29
+ Fish-native plugin. License: MIT.
package/README.md CHANGED
@@ -1,153 +1,29 @@
1
- <div align="center">
2
-
3
1
  # @fish-under-sea/dsh-approval-guide
4
2
 
5
- **给 DSH 审批弹窗补一段中文说明:这次审批会做什么、有什么风险、依据是什么。**
6
-
7
- [![npm](https://img.shields.io/npm/v/@fish-under-sea/dsh-approval-guide?style=flat-square&label=npm&color=cb3837)](https://www.npmjs.com/package/@fish-under-sea/dsh-approval-guide)
8
- ![license](https://img.shields.io/badge/license-MIT-green?style=flat-square)
9
- ![node](https://img.shields.io/badge/node-%5E22.19.0%20%7C%7C%20%3E%3D24.0.0-339933?style=flat-square)
10
- ![DSH](https://img.shields.io/badge/DSH-%3E%3D0.2.0--rc.2-4b6ef6?style=flat-square)
11
- ![plugin](https://img.shields.io/badge/plugin-client%20%2B%20host-6b7280?style=flat-square)
12
-
13
- **简体中文** · [English](README.en.md)
14
-
15
- </div>
3
+ **1.0.1 · 审批说明**
16
4
 
17
- ## 解决什么问题
18
-
19
- 审批弹窗的框架文案本来就有中文(「等待审批」「拒绝」「允许一次」),但**审批理由由宿主生成,只有英文**。最常见的一条长这样:
20
-
21
- ```text
22
- escalate sandbox to danger-full-access: <模型填写的一句英文理由>
23
- ```
24
-
25
- 读者要自己判断「这条命令到底会做什么、放开到什么程度、有什么后果」,而英文句式把这个判断成本抬高了。本插件在审批理由与命令下方插入中文分级说明,把「会做什么 / 风险 / 依据」三件事讲清楚。
26
-
27
- ## 效果
28
-
29
- 审批卡片内的详情区会变成:
30
-
31
- ```text
32
- <原命令>
33
-
34
- 这次审批会做什么
35
- 把这一次 pwsh 调用的文件沙箱范围提升到「完全放开」(danger-full-access)。
36
- 只对本次调用生效:不产生长期授权,也不影响之后的命令。
37
- 风险
38
- 放开后这条命令不再受工作区边界约束:它可以读写本机任意文件,
39
- 包括系统目录、其它项目、SSH 密钥与凭据文件,
40
- 本次执行也不再逐条征求你的同意。只有在你完全信任这条命令时才应允许。
41
- · 工具:pwsh
42
- · 目标权限:完全放开(danger-full-access)
43
- · 模型给的理由:<原文>
44
- 拿不准就先点「拒绝」:拒绝不会中断对话,之后我可以换成只读、
45
- 或只写工作区内的方式重试。
46
- ```
5
+ [English](README.en.md)
47
6
 
48
- 说明一律中文显示,不跟随界面语言——界面切到英文时,中文提示仍然在。
7
+ ## 功能
49
8
 
50
- ### 文案分级
51
-
52
- 中文说明由**静态规则**生成,不额外调用模型、不消耗 API 额度,也不会被请求方自己的说辞带偏。
53
-
54
- | 目标权限 | 级别 | 风险文案要点 |
55
- | --- | --- | --- |
56
- | `danger-full-access` | 高危(红色标题) | 不再受工作区边界约束,可读写本机任意文件(含系统目录、其它项目、SSH 密钥与凭据文件),本次执行不再逐条审批。 |
57
- | `workspace-write` | 注意 | 可写当前工作区目录及其子目录、系统临时目录;工作区之外仍不能写入。 |
58
- | 其它模式 | 注意 | 不是 DSH 内置模式,无法给出确切范围,提示按请求权限运行。 |
59
- | 无沙箱参数 | 注意 | 通用兜底:工具请求以更高权限执行本次操作,仅本次有效。 |
9
+ 为审批弹窗补充中文动作、风险与依据说明;覆盖文件、命令、网络及权限升级等常见请求。
60
10
 
61
11
  ## 安装
62
12
 
63
13
  ```sh
64
- # 从 npm 安装(推荐)
65
- dsh plugin --profile <profile> add @fish-under-sea/dsh-approval-guide
66
- ```
67
-
68
- `--profile` 后跟本机实际的 profile 名:桌面版 `desktop`,Web 版 `web`。
69
-
70
- 要改源码时才用 `link:` 指向本目录(仓库源码即安装源,改完重启 DSH 即生效):
71
-
72
- ```sh
73
- dsh plugin --profile <profile> add "link:<本目录的绝对路径>"
74
- ```
75
-
76
- 安装后需要**重启 DSH 应用并刷新页面**才会生效(Web 端没有原地重启)。
77
-
78
- ### 卸载
79
-
80
- ```sh
81
- dsh plugin --profile <profile> remove @fish-under-sea/dsh-approval-guide
14
+ dsh plugin --profile <profile> add @fish-under-sea/dsh-approval-guide@1.0.1
82
15
  ```
83
16
 
84
- ### 安装后自检
85
-
86
- ```sh
87
- dsh --profile <profile> --dump-config
88
- ```
89
-
90
- 输出末尾应恰好出现一行 `- id: approval-guide` / `name: @fish-under-sea/dsh-approval-guide`。多行即重复挂载,应用会启动失败。
91
-
92
- ## 使用
93
-
94
- 安装后无需任何操作——插件自动占用审批详情的 `conversation.approval.detail` 插槽,在每次审批弹窗里追加中文说明。
95
-
96
- 说明的取值按「纵深防御」分层:先看工具调用参数 `sandbox_permissions` / `justification`,取不到再解析宿主理由句式(`escalate sandbox to <mode>: <理由>`),再取不到走通用兜底。层层都拿不到时仍然显示通用中文说明。
97
-
98
- 覆盖范围:
99
-
100
- - 所有**带关联工具调用**的交互式审批:沙箱权限升级、hook 触发的 ask、其它插件通过审批通道发起的 ask。
101
-
102
- ## 配置
103
-
104
- **无配置文件。** 本包没有任何配置项,也不读写设置文件——所有规则硬编码在 `lib/client.js` 里。
105
-
106
- ## 兼容与边界
107
-
108
- - 平台:纯浏览器插件(`dsh.client.platform: web`),宿主半区是空实现。
109
- - 占用核心包 `@deepseek-ai/dsh-client-ui-approval` 的 `conversation.approval.detail` 子插槽。该插槽为 `single` 类型,按优先级**升序**排列、**数字最小者渲染**;官方占用者 `ApprovalCommand` 用默认优先级 0,本插件注册 `priority: -1` 覆盖它,并在组件里用同一套逻辑(`useChat` 取关联工具调用、解析 `argsRaw.command`)把命令原文重新渲染回来,不丢信息。
110
- - 组件抛错时,插槽渲染器会回收该条目(abdicate),官方 `ApprovalCommand` 自动恢复渲染——审批卡不会留白,也不会卡住审批流程。
111
- - 兼容 DSH 0.2.0(`useSessionStatus`)与 0.1.x(`useSessionPendingInteraction`)两代选择器。
112
-
113
- 数据源:
114
-
115
- | 数据 | 来源 |
116
- | --- | --- |
117
- | 关联工具调用的命令与参数 | `useChat` 选择器(与官方 `ApprovalCommand` 同款) |
118
- | 工具名与审批理由 | `useSessionPendingInteraction` / `useSessionStatus` 选择器(`kind === 'approval'` 的待办交互) |
119
-
120
- ### 已知限制
121
-
122
- - 审批请求若**不带关联工具调用**(`callId` 缺失),核心不会渲染详情区,本插件也就没有插入位置。这是核心插槽契约决定的,不是本插件可以绕过的。
123
- - 中文说明解释的是「权限范围」这一层风险,不判断命令本身是否安全。命令原文要自己看。
124
- - 宿主若调整理由句式(`escalate sandbox to <mode>: <理由>`),第一层参数取值仍然有效,只有第二层兜底会失效。
125
-
126
- ## 开发与测试
127
-
128
- ```sh
129
- node packages/dsh-approval-guide/test/guide.test.mjs
130
- ```
131
-
132
- 当前 12 个用例全部通过。测试装载的是真正会进浏览器的 `lib/client.js`:用 `node:vm` 提供 `window.__ModuleLoader__`,抓住 bundle 注册的 factory,再用假模块表实例化,直接断言纯函数与组件产出的元素树。**零依赖**,不需要安装 React 或 vitest。
133
-
134
- > 不要用 `node --test test/`:测试运行器会派生子进程并捕获管道输出,在受限沙箱里会以 `EPERM` 失败。直接运行测试文件即可。
135
-
136
- 覆盖的用例:两种沙箱模式的分级文案、理由兜底解析、未知模式、通用审批兜底、参数 JSON 损坏、空输入不抛异常、组件保留命令原文、取不到 pending 时降级、插槽注册优先级。
17
+ 也可安装聚合包 `@fish-under-sea/dsh-fish@1.0.1`。聚合与独立安装不要重复展开相同插件行;安装完成后重启 DSH。桌面环境无 CLI 时使用插件管理器。
137
18
 
138
- 目录结构:
19
+ ## 配置与边界
139
20
 
140
- | 路径 | 作用 |
141
- | --- | --- |
142
- | `lib/index.js` | 宿主半区,空实现(纯浏览器插件) |
143
- | `lib/client.js` | 浏览器半区:中文文案、分级逻辑、审批详情组件、插槽注册 |
144
- | `cordis.patch.yml` | bundle 补丁层,把插件行插入 profile 名册 |
145
- | `test/guide.test.mjs` | 零依赖测试 |
21
+ 仅补充说明,不代替人工审批,不改变沙箱或自动放行。
146
22
 
147
- ## 与聚合包的关系
23
+ Node 要求: `^22.19.0 || >=24.0.0`. DSH 支持范围以本包声明为准;聚合包不覆盖宿主兼容性检查。
148
24
 
149
- > 本包是 [`@fish-under-sea/dsh-fish`](https://github.com/Fish-under-sea/dsh-fish) 聚合包的成员之一;单独安装只影响这一项。
25
+ ## 维护与来源
150
26
 
151
- ## 许可
27
+ 1.0.1 统一发布版本,不表示已合并上游所有最新提交。历史说明保留在 Git 历史中;聚合变更见 [聚合变更记录](https://github.com/Fish-under-sea/dsh-fish/blob/main/CHANGELOG.md).
152
28
 
153
- MIT © Fish-under-sea
29
+ Fish 原生插件。 许可证: MIT.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fish-under-sea/dsh-approval-guide",
3
- "version": "0.2.2",
3
+ "version": "1.0.1",
4
4
  "description": "在 DSH Web GUI 的审批弹窗里追加中文说明:这次审批会做什么、有什么风险、依据是什么。原英文理由与命令原文保留显示。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -17,7 +17,8 @@
17
17
  "lib",
18
18
  "cordis.patch.yml",
19
19
  "README.md",
20
- "README.en.md"
20
+ "README.en.md",
21
+ "LICENSE"
21
22
  ],
22
23
  "license": "MIT",
23
24
  "publishConfig": {
@@ -53,4 +54,4 @@
53
54
  "platform": "web"
54
55
  }
55
56
  }
56
- }
57
+ }