dsh-toolview-kit 0.3.4 → 0.3.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 +10 -0
- package/README.md +5 -5
- package/config/tools.json +11 -0
- package/docs/cards.md +3 -2
- package/docs/development.md +3 -3
- package/lib/client.js +23 -3
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.6 - 2026-12-03
|
|
4
|
+
|
|
5
|
+
- Registered a card for `mcp__jumpserver__get_command_result` and `mcp__jumpserver-prod__get_command_result`; they used to fall back to raw JSON because the keyed toolview slot has no wildcard and the map did not list them.
|
|
6
|
+
- Added the `mcp-receipt` card family: it unwraps the polled receipt, shows the `job_id` in the collapsed row while the poll is running, and keeps the per-asset sections.
|
|
7
|
+
- Added `jobKeys` to the map schema so a receipt tool can name its job-id argument.
|
|
8
|
+
|
|
9
|
+
## 0.3.5 - 2026-12-01
|
|
10
|
+
|
|
11
|
+
- Dropped a note under the screenshots that explained the images had their paths blanked.
|
|
12
|
+
|
|
3
13
|
## 0.3.4 - 2026-12-01
|
|
4
14
|
|
|
5
15
|
- Removed an FAQ entry about patching the DSH client bundle; the README now covers installation and usage only.
|
package/README.md
CHANGED
|
@@ -21,8 +21,6 @@ DSH 的对话界面按工具名挑卡片视图:`bash`、`read`、`grep` 有专
|
|
|
21
21
|
|
|
22
22
|

|
|
23
23
|
|
|
24
|
-
截图里的本机路径已遮盖。
|
|
25
|
-
|
|
26
24
|
## 安装
|
|
27
25
|
|
|
28
26
|
```bash
|
|
@@ -40,7 +38,7 @@ npm test
|
|
|
40
38
|
dsh plugin --profile desktop add file://$PWD
|
|
41
39
|
```
|
|
42
40
|
|
|
43
|
-
`npm test` 会先构建再跑
|
|
41
|
+
`npm test` 会先构建再跑 15 个用例,覆盖工具映射、loader 形状、注册数量、卡片渲染、Diff 和 JumpServer 回执(执行与回执查询)。测试不需要 DSH 运行时:用 `node:vm` 模拟 `window.__ModuleLoader__`,配一个极小的 React stub 渲染并断言文本。
|
|
44
42
|
|
|
45
43
|
手工登记、junction 接入、回滚和排障写在 [docs/installation.md](docs/installation.md)。
|
|
46
44
|
|
|
@@ -50,10 +48,11 @@ dsh plugin --profile desktop add file://$PWD
|
|
|
50
48
|
| --- | --- |
|
|
51
49
|
| shell | `ops_bash` |
|
|
52
50
|
| shell(远程) | `mcp__jumpserver__execute_command`、`mcp__jumpserver-prod__execute_command`、`mcp__jumpserver__submit_command`、`mcp__jumpserver-prod__submit_command` |
|
|
51
|
+
| shell(回执查询) | `mcp__jumpserver__get_command_result`、`mcp__jumpserver-prod__get_command_result` |
|
|
53
52
|
| file-read | `ops_inspect_local_file`、`ops_grep`、`ops_glob`、`ops_stat`、`ops_diff`、`ops_read_files`、`ops_read_table`、`ops_read_docx`、`ops_read_pdf` |
|
|
54
53
|
| file-write | `ops_replace`、`ops_write_file`、`ops_edit_file`、`ops_copy`、`ops_move`、`ops_remove` |
|
|
55
54
|
|
|
56
|
-
共
|
|
55
|
+
共 22 个工具名,全部来自 `config/tools.json`。要加新工具,改映射表再构建,不用写组件。
|
|
57
56
|
|
|
58
57
|
## 卡片内容
|
|
59
58
|
|
|
@@ -63,6 +62,7 @@ dsh plugin --profile desktop add file://$PWD
|
|
|
63
62
|
|
|
64
63
|
- 退出码取结果尾部的 `[exit code: N]`,展示时从正文剥离;`interrupted` 单独标成取消。
|
|
65
64
|
- JumpServer 返回的是 `{ok, state, job_id, out, results[]}` 这种作业回执。卡片会取出 `results[].ip` 和 `out`、`state`、`job_id`,把 `host | CHANGED | rc=0 >>` 这类 Ansible 包头换成小标题并折成 `exit N`,多台资产各占一段。
|
|
65
|
+
- `get_command_result` 是同一个回执形状的异步查询:折叠行直接用 `job_id` 当摘要,展开后照旧按资产分段,不再甩一坨 JSON。
|
|
66
66
|
- `ops_edit_file` 不是 DSH 内置的 `edit`,拿不到官方 diff 视图。插件读 `edits[].oldText` / `newText`(兼容 `old_string` / `new_string`)画逐行 Diff,并显示 `expectedRevision`。
|
|
67
67
|
|
|
68
68
|
## 主题
|
|
@@ -104,7 +104,7 @@ dsh plugin --profile desktop add file://$PWD
|
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
106
|
npm run build # src/client-template.js + config/tools.json → lib/client.js
|
|
107
|
-
npm test # 构建 +
|
|
107
|
+
npm test # 构建 + 15 个用例
|
|
108
108
|
npm run verify # 检查本机 desktop profile 的依赖、bundle 和 junction
|
|
109
109
|
```
|
|
110
110
|
|
package/config/tools.json
CHANGED
|
@@ -111,6 +111,17 @@
|
|
|
111
111
|
"label": "JumpServer Prod (async)",
|
|
112
112
|
"commandKeys": ["command", "cmd", "script"],
|
|
113
113
|
"targetKeys": ["ips", "hosts", "targets"]
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
"mcp__jumpserver__get_command_result": {
|
|
117
|
+
"kind": "mcp-receipt",
|
|
118
|
+
"label": "JumpServer (receipt)",
|
|
119
|
+
"jobKeys": ["job_id", "jobId", "task_id"]
|
|
120
|
+
},
|
|
121
|
+
"mcp__jumpserver-prod__get_command_result": {
|
|
122
|
+
"kind": "mcp-receipt",
|
|
123
|
+
"label": "JumpServer Prod (receipt)",
|
|
124
|
+
"jobKeys": ["job_id", "jobId", "task_id"]
|
|
114
125
|
}
|
|
115
126
|
}
|
|
116
127
|
}
|
package/docs/cards.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
| --- | --- | --- |
|
|
7
7
|
| `shell` | `$ command` 首行 | 命令块、输出块、CWD、退出码 |
|
|
8
8
|
| `mcp-shell` | 命令首行 + 目标资产 | 同上,另加 `MCP · <label>` 标题 |
|
|
9
|
+
| `mcp-receipt` | `job <id>` | 作业状态、按资产分段的输出 |
|
|
9
10
|
| `file-read` | 目标路径或查询条件 | 路径、查询条件、输出 |
|
|
10
11
|
| `file-write` | 目标路径 | 路径、写入内容、输出 |
|
|
11
12
|
| `mcp` | 工具名 | 参数 JSON 与输出 |
|
|
@@ -25,7 +26,7 @@ DSH 把一次工具调用分成三个阶段交给视图组件:`preparing` →
|
|
|
25
26
|
- `block.args` 是惰性对象,不能直接 `JSON.parse`;一律读 `argsRaw`。
|
|
26
27
|
- `result` 阶段的 `block.call` 可能为 `null`,此时只显示输出。
|
|
27
28
|
- 输出既可能是 `{ type: 'text', text }` 数组,也可能是纯字符串或对象;解析器逐层取 `text` / `output` / `content` / `result` / `json`。
|
|
28
|
-
- JumpServer MCP 的对象回执会识别 `ok`、`state`、`job_id`、`out` 和 `results[]`:输出只展示每个资产的 `out`,保留资产 IP、作业号和状态;`host | CHANGED | rc=N >>` / `host | FAILED | rc=N >>` 包头会被移除,`rc`
|
|
29
|
+
- JumpServer MCP 的对象回执会识别 `ok`、`state`、`job_id`、`out` 和 `results[]`:输出只展示每个资产的 `out`,保留资产 IP、作业号和状态;`host | CHANGED | rc=N >>` / `host | FAILED | rc=N >>` 包头会被移除,`rc` 转成退出码。`mcp-receipt`(`get_command_result`)是同一个回执形状的异步查询,走同一套解包,折叠行直接用 `job_id` 当摘要。
|
|
29
30
|
- 退出码优先取结构化字段 `exitCode`,其次取 JumpServer 每个结果的 `rc`,最后从正文尾部的 `[exit code: N]` 提取,并在展示前剥离该标记。
|
|
30
31
|
|
|
31
32
|
## 文件写入 Diff
|
|
@@ -57,7 +58,7 @@ Windows 下 `ops_edit_file` 由 dsh-ops 宿主执行时可能保留目标文件
|
|
|
57
58
|
## 扩展一个新工具
|
|
58
59
|
|
|
59
60
|
1. 在 `config/tools.json` 的 `tools` 里加一项,key 必须是线上工具名。
|
|
60
|
-
2. 选 `kind
|
|
61
|
+
2. 选 `kind`(`shell` / `mcp-shell` / `mcp-receipt` / `file-read` / `file-write`),补 `commandKeys` / `pathKeys` / `queryKeys` / `targetKeys` / `jobKeys` 中适用的那组。
|
|
61
62
|
3. `npm run build && npm test`。
|
|
62
63
|
4. 重开 DSH Desktop;主题令牌在宿主启动时注入,旧会话不会热替换客户端 bundle。
|
|
63
64
|
|
package/docs/development.md
CHANGED
|
@@ -9,7 +9,7 @@ dsh-toolview-kit/
|
|
|
9
9
|
├── scripts/build.mjs # 校验映射 + 内联 + 产出 lib/client.js + 语法检查
|
|
10
10
|
├── lib/index.js # 宿主半:空实现
|
|
11
11
|
├── lib/client.js # 构建产物(勿手改)
|
|
12
|
-
├── test/plugin.test.mjs #
|
|
12
|
+
├── test/plugin.test.mjs # 15 个用例
|
|
13
13
|
└── docs/ # 安装、卡片说明
|
|
14
14
|
```
|
|
15
15
|
|
|
@@ -35,9 +35,9 @@ function register(ctx, key) {
|
|
|
35
35
|
|
|
36
36
|
`test/plugin.test.mjs` 不依赖 DSH:
|
|
37
37
|
|
|
38
|
-
1. **映射覆盖**:断言 15 个 `ops_*` 文件工具、`ops_bash`、4 个 JumpServer
|
|
38
|
+
1. **映射覆盖**:断言 15 个 `ops_*` 文件工具、`ops_bash`、4 个 JumpServer 命令、2 个 `get_command_result`都在表里,且写操作归到 `file-write`。
|
|
39
39
|
2. **loader 形状**:`vm` 里跑 `lib/client.js`,断言调用 `load`、`id` 等于包名、`require('react')` 可解析。
|
|
40
|
-
3. **注册**:用假 `ctx.slots` 收集注册,断言
|
|
40
|
+
3. **注册**:用假 `ctx.slots` 收集注册,断言 22 个 key 与映射表一一对应。
|
|
41
41
|
4. **渲染**:极小 React stub(`createElement` + `useState`)直接调用视图,把元素树拍平成文本,断言命令、输出、退出码、路径、目标资产、取消态与 file-write Diff。
|
|
42
42
|
|
|
43
43
|
新增交互(例如折叠记忆)时,优先给 stub 加能力,而不是把组件改成不可测的副作用代码。
|
package/lib/client.js
CHANGED
|
@@ -198,6 +198,24 @@
|
|
|
198
198
|
"hosts",
|
|
199
199
|
"targets"
|
|
200
200
|
]
|
|
201
|
+
},
|
|
202
|
+
"mcp__jumpserver__get_command_result": {
|
|
203
|
+
"kind": "mcp-receipt",
|
|
204
|
+
"label": "JumpServer (receipt)",
|
|
205
|
+
"jobKeys": [
|
|
206
|
+
"job_id",
|
|
207
|
+
"jobId",
|
|
208
|
+
"task_id"
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
"mcp__jumpserver-prod__get_command_result": {
|
|
212
|
+
"kind": "mcp-receipt",
|
|
213
|
+
"label": "JumpServer Prod (receipt)",
|
|
214
|
+
"jobKeys": [
|
|
215
|
+
"job_id",
|
|
216
|
+
"jobId",
|
|
217
|
+
"task_id"
|
|
218
|
+
]
|
|
201
219
|
}
|
|
202
220
|
};
|
|
203
221
|
const h = React.createElement;
|
|
@@ -416,7 +434,7 @@
|
|
|
416
434
|
const kind = config && config.kind;
|
|
417
435
|
// Only MCP tools answer with job receipts; a shell or file tool that
|
|
418
436
|
// happens to print an object with an `ok` key must stay verbatim.
|
|
419
|
-
const receipt = kind === 'mcp-shell' || kind === 'mcp' ? receiptFrom(text) : null;
|
|
437
|
+
const receipt = kind === 'mcp-shell' || kind === 'mcp-receipt' || kind === 'mcp' ? receiptFrom(text) : null;
|
|
420
438
|
if (receipt) return receipt;
|
|
421
439
|
const parsed = parseExit(text, block);
|
|
422
440
|
return { receipt: false, output: parsed.output, exitCode: parsed.exitCode, hosts: [], job: '', state: '', failed: false };
|
|
@@ -674,13 +692,15 @@
|
|
|
674
692
|
const query = queryText(args, config);
|
|
675
693
|
const targets = targetKeysText(args, config);
|
|
676
694
|
const payload = payloadText(args);
|
|
695
|
+
const jobArg = firstValue(args, config && config.jobKeys);
|
|
696
|
+
const jobSummary = jobArg === undefined ? '' : 'job ' + safeText(jobArg);
|
|
677
697
|
const diff = config.kind === 'file-write' ? diffText(args) : '';
|
|
678
698
|
const expectedRevision = config.kind === 'file-write'
|
|
679
699
|
? firstValue(args, ['expectedRevision', 'revision'])
|
|
680
700
|
: undefined;
|
|
681
701
|
const isShell = config.kind === 'shell' || config.kind === 'mcp-shell';
|
|
682
702
|
const primary = isShell ? command : path;
|
|
683
|
-
const summary = compactText(primary || query || payload || 'Tool call', MAX_SUMMARY_CHARS);
|
|
703
|
+
const summary = compactText(primary || query || payload || jobSummary || 'Tool call', MAX_SUMMARY_CHARS);
|
|
684
704
|
const output = compactText(result.output || (phase === 'result' ? 'No output' : ''), MAX_OUTPUT_CHARS);
|
|
685
705
|
const cardLabel = labelOf(name, config);
|
|
686
706
|
const title = name.indexOf('mcp__') === 0 ? 'MCP · ' + cardLabel : cardLabel;
|
|
@@ -694,7 +714,7 @@
|
|
|
694
714
|
h(Meta, { key: 'tool', label: 'Tool', value: name }),
|
|
695
715
|
h(Meta, { key: 'cwd', label: 'CWD', value: props.cwd }),
|
|
696
716
|
h(Meta, { key: 'target', label: 'Target', value: targets }),
|
|
697
|
-
h(Meta, { key: 'job', label: 'Job', value: result.job }),
|
|
717
|
+
h(Meta, { key: 'job', label: 'Job', value: result.job || (jobArg === undefined ? '' : safeText(jobArg)) }),
|
|
698
718
|
h(Meta, { key: 'state', label: 'State', value: result.state }),
|
|
699
719
|
h(Meta, { key: 'revision', label: 'Expected revision', value: expectedRevision }),
|
|
700
720
|
exitLabel ? h(Meta, { key: 'exit', label: 'Result', value: exitLabel }) : null
|
package/lib/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* makes the package safe to load in profiles that do not expose client slots.
|
|
6
6
|
*/
|
|
7
7
|
export const name = 'dsh-toolview-kit';
|
|
8
|
-
export const version = '0.3.
|
|
8
|
+
export const version = '0.3.6';
|
|
9
9
|
|
|
10
10
|
export function apply() {
|
|
11
11
|
// Client registration is performed by the web bundle.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-toolview-kit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Data-driven readable tool cards for DSH shell, file, and JumpServer MCP calls.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dsh": {
|
|
41
41
|
"id": "dsh-toolview-kit",
|
|
42
42
|
"name": "DSH Toolview Kit",
|
|
43
|
-
"version": "0.3.
|
|
43
|
+
"version": "0.3.6",
|
|
44
44
|
"bundle": {
|
|
45
45
|
"patch": "./cordis.patch.yml"
|
|
46
46
|
},
|