dsh-toolview-kit 0.3.6 → 0.3.7
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 +7 -0
- package/README.md +10 -5
- package/config/tools.json +54 -0
- package/docs/cards.md +5 -3
- package/docs/development.md +4 -4
- package/lib/client.js +182 -4
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.7 - 2026-12-03
|
|
4
|
+
|
|
5
|
+
- Mapped the last five JumpServer tools, so `list_jobs`, `list_assets`, `get_status`, `upload_file` and `download_file` stop falling back to raw JSON; both the plain and the `-prod` servers are covered.
|
|
6
|
+
- Added the `mcp-data` card family: top-level scalars become labelled fields, arrays become one row per item (`ip hostname …`), and the collapsed row summarises the count instead of printing the object.
|
|
7
|
+
- `upload_file` and `download_file` reuse `mcp-receipt`: the local path and target assets sit in the collapsed row, per-asset results in the body.
|
|
8
|
+
- 32 tool names in total.
|
|
9
|
+
|
|
3
10
|
## 0.3.6 - 2026-12-03
|
|
4
11
|
|
|
5
12
|
- 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.
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
DSH 的对话界面按工具名挑卡片视图:`bash`、`read`、`grep` 有专属样式,其它名字落到通用 JSON 渲染器。`dsh-ops` 发布的是 `ops_*`,JumpServer MCP 发布的是 `mcp__*`,两边都不在名单里,于是命令、文件读写和远程执行都以原始 JSON 出现。
|
|
11
11
|
|
|
12
|
-
这个插件给这些名字注册卡片:命令显示成终端块,文件操作显示路径和逐行 Diff,JumpServer
|
|
12
|
+
这个插件给这些名字注册卡片:命令显示成终端块,文件操作显示路径和逐行 Diff,JumpServer 回执按资产拆成文本,资产、作业与状态列表按行铺开。
|
|
13
13
|
|
|
14
14
|
## 界面
|
|
15
15
|
|
|
@@ -38,7 +38,7 @@ npm test
|
|
|
38
38
|
dsh plugin --profile desktop add file://$PWD
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
`npm test` 会先构建再跑
|
|
41
|
+
`npm test` 会先构建再跑 18 个用例,覆盖工具映射、loader 形状、注册数量、卡片渲染、Diff、JumpServer 回执(执行、回执查询、文件传输)和列表/状态字段。测试不需要 DSH 运行时:用 `node:vm` 模拟 `window.__ModuleLoader__`,配一个极小的 React stub 渲染并断言文本。
|
|
42
42
|
|
|
43
43
|
手工登记、junction 接入、回滚和排障写在 [docs/installation.md](docs/installation.md)。
|
|
44
44
|
|
|
@@ -49,10 +49,12 @@ dsh plugin --profile desktop add file://$PWD
|
|
|
49
49
|
| shell | `ops_bash` |
|
|
50
50
|
| shell(远程) | `mcp__jumpserver__execute_command`、`mcp__jumpserver-prod__execute_command`、`mcp__jumpserver__submit_command`、`mcp__jumpserver-prod__submit_command` |
|
|
51
51
|
| shell(回执查询) | `mcp__jumpserver__get_command_result`、`mcp__jumpserver-prod__get_command_result` |
|
|
52
|
+
| shell(文件传输) | `mcp__jumpserver__upload_file`、`mcp__jumpserver-prod__upload_file`、`mcp__jumpserver__download_file`、`mcp__jumpserver-prod__download_file` |
|
|
53
|
+
| data(列表与状态) | `mcp__jumpserver__list_jobs`、`mcp__jumpserver-prod__list_jobs`、`mcp__jumpserver__list_assets`、`mcp__jumpserver-prod__list_assets`、`mcp__jumpserver__get_status`、`mcp__jumpserver-prod__get_status` |
|
|
52
54
|
| 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` |
|
|
53
55
|
| file-write | `ops_replace`、`ops_write_file`、`ops_edit_file`、`ops_copy`、`ops_move`、`ops_remove` |
|
|
54
56
|
|
|
55
|
-
共
|
|
57
|
+
共 32 个工具名,全部来自 `config/tools.json`。要加新工具,改映射表再构建,不用写组件。
|
|
56
58
|
|
|
57
59
|
## 卡片内容
|
|
58
60
|
|
|
@@ -63,6 +65,8 @@ dsh plugin --profile desktop add file://$PWD
|
|
|
63
65
|
- 退出码取结果尾部的 `[exit code: N]`,展示时从正文剥离;`interrupted` 单独标成取消。
|
|
64
66
|
- JumpServer 返回的是 `{ok, state, job_id, out, results[]}` 这种作业回执。卡片会取出 `results[].ip` 和 `out`、`state`、`job_id`,把 `host | CHANGED | rc=0 >>` 这类 Ansible 包头换成小标题并折成 `exit N`,多台资产各占一段。
|
|
65
67
|
- `get_command_result` 是同一个回执形状的异步查询:折叠行直接用 `job_id` 当摘要,展开后照旧按资产分段,不再甩一坨 JSON。
|
|
68
|
+
- `upload_file` / `download_file` 复用这套解包:折叠行给出本地路径与目标资产,展开后按资产列出落地结果。
|
|
69
|
+
- `list_jobs`、`list_assets`、`get_status` 返回普通 JSON 数据,不是作业回执。`mcp-data` 卡片把顶层标量做成标签字段,把数组按行铺开(资产行是 `ip hostname …`),折叠行只给条目数。
|
|
66
70
|
- `ops_edit_file` 不是 DSH 内置的 `edit`,拿不到官方 diff 视图。插件读 `edits[].oldText` / `newText`(兼容 `old_string` / `new_string`)画逐行 Diff,并显示 `expectedRevision`。
|
|
67
71
|
|
|
68
72
|
## 主题
|
|
@@ -91,12 +95,13 @@ dsh plugin --profile desktop add file://$PWD
|
|
|
91
95
|
| 字段 | 说明 |
|
|
92
96
|
| --- | --- |
|
|
93
97
|
| key | DSH 线上工具名,必须精确匹配,不支持通配 |
|
|
94
|
-
| `kind` | `shell`、`mcp-shell`、`file-read`、`file-write`、`mcp` |
|
|
98
|
+
| `kind` | `shell`、`mcp-shell`、`mcp-receipt`、`mcp-data`、`file-read`、`file-write`、`mcp` |
|
|
95
99
|
| `label` | 折叠行标题;`mcp__*` 自动加 `MCP · ` 前缀,省略时由工具名推导 |
|
|
96
100
|
| `commandKeys` | 依次尝试的参数名,取第一个非空值当命令 |
|
|
97
101
|
| `pathKeys` | 文件类工具的目标路径参数名,支持数组值(如 `files`) |
|
|
98
102
|
| `queryKeys` | 搜索或匹配条件的参数名 |
|
|
99
103
|
| `targetKeys` | 目标资产参数名(JumpServer 的 `ips`) |
|
|
104
|
+
| `jobKeys` | 作业号参数名,回执类工具在折叠行显示 `job <id>` |
|
|
100
105
|
|
|
101
106
|
改完跑 `npm run build`。DSH 只加载单文件 bundle,映射表会被内联进 `lib/client.js`,不能在运行时读 JSON。
|
|
102
107
|
|
|
@@ -104,7 +109,7 @@ dsh plugin --profile desktop add file://$PWD
|
|
|
104
109
|
|
|
105
110
|
```bash
|
|
106
111
|
npm run build # src/client-template.js + config/tools.json → lib/client.js
|
|
107
|
-
npm test # 构建 +
|
|
112
|
+
npm test # 构建 + 18 个用例
|
|
108
113
|
npm run verify # 检查本机 desktop profile 的依赖、bundle 和 junction
|
|
109
114
|
```
|
|
110
115
|
|
package/config/tools.json
CHANGED
|
@@ -122,6 +122,60 @@
|
|
|
122
122
|
"kind": "mcp-receipt",
|
|
123
123
|
"label": "JumpServer Prod (receipt)",
|
|
124
124
|
"jobKeys": ["job_id", "jobId", "task_id"]
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
"mcp__jumpserver__list_jobs": {
|
|
128
|
+
"kind": "mcp-data",
|
|
129
|
+
"label": "JumpServer (jobs)"
|
|
130
|
+
},
|
|
131
|
+
"mcp__jumpserver-prod__list_jobs": {
|
|
132
|
+
"kind": "mcp-data",
|
|
133
|
+
"label": "JumpServer Prod (jobs)"
|
|
134
|
+
},
|
|
135
|
+
"mcp__jumpserver__list_assets": {
|
|
136
|
+
"kind": "mcp-data",
|
|
137
|
+
"label": "JumpServer (assets)"
|
|
138
|
+
},
|
|
139
|
+
"mcp__jumpserver-prod__list_assets": {
|
|
140
|
+
"kind": "mcp-data",
|
|
141
|
+
"label": "JumpServer Prod (assets)"
|
|
142
|
+
},
|
|
143
|
+
"mcp__jumpserver__get_status": {
|
|
144
|
+
"kind": "mcp-data",
|
|
145
|
+
"label": "JumpServer (status)"
|
|
146
|
+
},
|
|
147
|
+
"mcp__jumpserver-prod__get_status": {
|
|
148
|
+
"kind": "mcp-data",
|
|
149
|
+
"label": "JumpServer Prod (status)"
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
"mcp__jumpserver__upload_file": {
|
|
153
|
+
"kind": "mcp-receipt",
|
|
154
|
+
"label": "JumpServer (upload)",
|
|
155
|
+
"pathKeys": ["local_path"],
|
|
156
|
+
"targetKeys": ["ips"],
|
|
157
|
+
"jobKeys": ["job_id", "task_id"]
|
|
158
|
+
},
|
|
159
|
+
"mcp__jumpserver-prod__upload_file": {
|
|
160
|
+
"kind": "mcp-receipt",
|
|
161
|
+
"label": "JumpServer Prod (upload)",
|
|
162
|
+
"pathKeys": ["local_path"],
|
|
163
|
+
"targetKeys": ["ips"],
|
|
164
|
+
"jobKeys": ["job_id", "task_id"]
|
|
165
|
+
},
|
|
166
|
+
"mcp__jumpserver__download_file": {
|
|
167
|
+
"kind": "mcp-receipt",
|
|
168
|
+
"label": "JumpServer (download)",
|
|
169
|
+
"pathKeys": ["remote_path", "local_dir"],
|
|
170
|
+
"targetKeys": ["ips"],
|
|
171
|
+
"jobKeys": ["job_id", "task_id"]
|
|
172
|
+
},
|
|
173
|
+
"mcp__jumpserver-prod__download_file": {
|
|
174
|
+
"kind": "mcp-receipt",
|
|
175
|
+
"label": "JumpServer Prod (download)",
|
|
176
|
+
"pathKeys": ["remote_path", "local_dir"],
|
|
177
|
+
"targetKeys": ["ips"],
|
|
178
|
+
"jobKeys": ["job_id", "task_id"]
|
|
125
179
|
}
|
|
126
180
|
}
|
|
127
181
|
}
|
package/docs/cards.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
| --- | --- | --- |
|
|
7
7
|
| `shell` | `$ command` 首行 | 命令块、输出块、CWD、退出码 |
|
|
8
8
|
| `mcp-shell` | 命令首行 + 目标资产 | 同上,另加 `MCP · <label>` 标题 |
|
|
9
|
-
| `mcp-receipt` | `job <id>` | 作业状态、按资产分段的输出 |
|
|
9
|
+
| `mcp-receipt` | `job <id>` 或目标路径 | 作业状态、按资产分段的输出 |
|
|
10
|
+
| `mcp-data` | 条目数(`n items`)或前两个字段 | 标签字段、每项一行 |
|
|
10
11
|
| `file-read` | 目标路径或查询条件 | 路径、查询条件、输出 |
|
|
11
12
|
| `file-write` | 目标路径 | 路径、写入内容、输出 |
|
|
12
13
|
| `mcp` | 工具名 | 参数 JSON 与输出 |
|
|
@@ -26,7 +27,8 @@ DSH 把一次工具调用分成三个阶段交给视图组件:`preparing` →
|
|
|
26
27
|
- `block.args` 是惰性对象,不能直接 `JSON.parse`;一律读 `argsRaw`。
|
|
27
28
|
- `result` 阶段的 `block.call` 可能为 `null`,此时只显示输出。
|
|
28
29
|
- 输出既可能是 `{ type: 'text', text }` 数组,也可能是纯字符串或对象;解析器逐层取 `text` / `output` / `content` / `result` / `json`。
|
|
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
|
|
30
|
+
- JumpServer MCP 的对象回执会识别 `ok`、`state`、`job_id`、`out` 和 `results[]`:输出只展示每个资产的 `out`,保留资产 IP、作业号和状态;`host | CHANGED | rc=N >>` / `host | FAILED | rc=N >>` 包头会被移除,`rc` 转成退出码。`mcp-receipt`(`get_command_result`、`upload_file`、`download_file`)走同一套解包,折叠行用 `job_id` 或目标路径当摘要。
|
|
31
|
+
- `list_jobs`、`list_assets`、`get_status` 返回普通 JSON:`mcp-data` 把顶层标量做成 `label: value` 字段,把数组按 `ip`、`hostname`、`job_id`、`state` 等字段铺成每项一行,剩下的长文本(如 `out`)压成行尾摘要;解析不出对象时仍退回输出块。
|
|
30
32
|
- 退出码优先取结构化字段 `exitCode`,其次取 JumpServer 每个结果的 `rc`,最后从正文尾部的 `[exit code: N]` 提取,并在展示前剥离该标记。
|
|
31
33
|
|
|
32
34
|
## 文件写入 Diff
|
|
@@ -58,7 +60,7 @@ Windows 下 `ops_edit_file` 由 dsh-ops 宿主执行时可能保留目标文件
|
|
|
58
60
|
## 扩展一个新工具
|
|
59
61
|
|
|
60
62
|
1. 在 `config/tools.json` 的 `tools` 里加一项,key 必须是线上工具名。
|
|
61
|
-
2. 选 `kind`(`shell` / `mcp-shell` / `mcp-receipt` / `file-read` / `file-write`),补 `commandKeys` / `pathKeys` / `queryKeys` / `targetKeys` / `jobKeys` 中适用的那组。
|
|
63
|
+
2. 选 `kind`(`shell` / `mcp-shell` / `mcp-receipt` / `mcp-data` / `file-read` / `file-write`),补 `commandKeys` / `pathKeys` / `queryKeys` / `targetKeys` / `jobKeys` 中适用的那组。
|
|
62
64
|
3. `npm run build && npm test`。
|
|
63
65
|
4. 重开 DSH Desktop;主题令牌在宿主启动时注入,旧会话不会热替换客户端 bundle。
|
|
64
66
|
|
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 # 18 个用例
|
|
13
13
|
└── docs/ # 安装、卡片说明
|
|
14
14
|
```
|
|
15
15
|
|
|
@@ -35,10 +35,10 @@ 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 命令、6 个回执查询与文件传输工具、6 个列表与状态工具都在表里,且写操作归到 `file-write`。
|
|
39
39
|
2. **loader 形状**:`vm` 里跑 `lib/client.js`,断言调用 `load`、`id` 等于包名、`require('react')` 可解析。
|
|
40
|
-
3. **注册**:用假 `ctx.slots` 收集注册,断言
|
|
41
|
-
4. **渲染**:极小 React stub(`createElement` + `useState
|
|
40
|
+
3. **注册**:用假 `ctx.slots` 收集注册,断言 32 个 key 与映射表一一对应。
|
|
41
|
+
4. **渲染**:极小 React stub(`createElement` + `useState`)直接调用视图,把元素树拍平成文本,断言命令、输出、退出码、路径、目标资产、取消态、file-write Diff、列表行与状态字段。
|
|
42
42
|
|
|
43
43
|
新增交互(例如折叠记忆)时,优先给 stub 加能力,而不是把组件改成不可测的副作用代码。
|
|
44
44
|
|
package/lib/client.js
CHANGED
|
@@ -216,6 +216,88 @@
|
|
|
216
216
|
"jobId",
|
|
217
217
|
"task_id"
|
|
218
218
|
]
|
|
219
|
+
},
|
|
220
|
+
"mcp__jumpserver__list_jobs": {
|
|
221
|
+
"kind": "mcp-data",
|
|
222
|
+
"label": "JumpServer (jobs)"
|
|
223
|
+
},
|
|
224
|
+
"mcp__jumpserver-prod__list_jobs": {
|
|
225
|
+
"kind": "mcp-data",
|
|
226
|
+
"label": "JumpServer Prod (jobs)"
|
|
227
|
+
},
|
|
228
|
+
"mcp__jumpserver__list_assets": {
|
|
229
|
+
"kind": "mcp-data",
|
|
230
|
+
"label": "JumpServer (assets)"
|
|
231
|
+
},
|
|
232
|
+
"mcp__jumpserver-prod__list_assets": {
|
|
233
|
+
"kind": "mcp-data",
|
|
234
|
+
"label": "JumpServer Prod (assets)"
|
|
235
|
+
},
|
|
236
|
+
"mcp__jumpserver__get_status": {
|
|
237
|
+
"kind": "mcp-data",
|
|
238
|
+
"label": "JumpServer (status)"
|
|
239
|
+
},
|
|
240
|
+
"mcp__jumpserver-prod__get_status": {
|
|
241
|
+
"kind": "mcp-data",
|
|
242
|
+
"label": "JumpServer Prod (status)"
|
|
243
|
+
},
|
|
244
|
+
"mcp__jumpserver__upload_file": {
|
|
245
|
+
"kind": "mcp-receipt",
|
|
246
|
+
"label": "JumpServer (upload)",
|
|
247
|
+
"pathKeys": [
|
|
248
|
+
"local_path"
|
|
249
|
+
],
|
|
250
|
+
"targetKeys": [
|
|
251
|
+
"ips"
|
|
252
|
+
],
|
|
253
|
+
"jobKeys": [
|
|
254
|
+
"job_id",
|
|
255
|
+
"task_id"
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
"mcp__jumpserver-prod__upload_file": {
|
|
259
|
+
"kind": "mcp-receipt",
|
|
260
|
+
"label": "JumpServer Prod (upload)",
|
|
261
|
+
"pathKeys": [
|
|
262
|
+
"local_path"
|
|
263
|
+
],
|
|
264
|
+
"targetKeys": [
|
|
265
|
+
"ips"
|
|
266
|
+
],
|
|
267
|
+
"jobKeys": [
|
|
268
|
+
"job_id",
|
|
269
|
+
"task_id"
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
"mcp__jumpserver__download_file": {
|
|
273
|
+
"kind": "mcp-receipt",
|
|
274
|
+
"label": "JumpServer (download)",
|
|
275
|
+
"pathKeys": [
|
|
276
|
+
"remote_path",
|
|
277
|
+
"local_dir"
|
|
278
|
+
],
|
|
279
|
+
"targetKeys": [
|
|
280
|
+
"ips"
|
|
281
|
+
],
|
|
282
|
+
"jobKeys": [
|
|
283
|
+
"job_id",
|
|
284
|
+
"task_id"
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
"mcp__jumpserver-prod__download_file": {
|
|
288
|
+
"kind": "mcp-receipt",
|
|
289
|
+
"label": "JumpServer Prod (download)",
|
|
290
|
+
"pathKeys": [
|
|
291
|
+
"remote_path",
|
|
292
|
+
"local_dir"
|
|
293
|
+
],
|
|
294
|
+
"targetKeys": [
|
|
295
|
+
"ips"
|
|
296
|
+
],
|
|
297
|
+
"jobKeys": [
|
|
298
|
+
"job_id",
|
|
299
|
+
"task_id"
|
|
300
|
+
]
|
|
219
301
|
}
|
|
220
302
|
};
|
|
221
303
|
const h = React.createElement;
|
|
@@ -496,6 +578,59 @@
|
|
|
496
578
|
return value === undefined ? '' : pretty(value);
|
|
497
579
|
}
|
|
498
580
|
|
|
581
|
+
/**
|
|
582
|
+
* `list_assets`, `list_jobs` and `get_status` answer with plain data
|
|
583
|
+
* rather than a shell receipt. Unwrap that into labelled fields plus one
|
|
584
|
+
* row per list item, so the card never falls back to a JSON dump.
|
|
585
|
+
*/
|
|
586
|
+
const ROW_FIELDS = ['ip', 'hostname', 'host', 'job_id', 'jobId', 'task_id', 'state', 'status', 'ok', 'asset_id', 'name', 'path'];
|
|
587
|
+
|
|
588
|
+
function rowTextOf(item) {
|
|
589
|
+
if (item === null || item === undefined) return '';
|
|
590
|
+
if (typeof item !== 'object') return safeText(item);
|
|
591
|
+
const head = [];
|
|
592
|
+
for (const key of ROW_FIELDS) {
|
|
593
|
+
if (head.length >= 4) break;
|
|
594
|
+
const value = item[key];
|
|
595
|
+
if (value === undefined || value === null || value === '' || typeof value === 'object') continue;
|
|
596
|
+
head.push(safeText(value));
|
|
597
|
+
}
|
|
598
|
+
const text = head.length > 0 ? head.join(' ') : compactText(safeText(item), 220);
|
|
599
|
+
const body = splitChunk(safeText(item.out !== undefined ? item.out : item.output)).text;
|
|
600
|
+
if (!body) return text;
|
|
601
|
+
return text + ' ' + compactText(body.replace(/\s+/g, ' '), 120);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function dataParts(text) {
|
|
605
|
+
const value = maybeJsonObject(text);
|
|
606
|
+
if (!value) return null;
|
|
607
|
+
const fields = [];
|
|
608
|
+
const lists = [];
|
|
609
|
+
const add = (key, item) => {
|
|
610
|
+
if (Array.isArray(item)) {
|
|
611
|
+
lists.push({ key: key, rows: item.map(rowTextOf).filter(Boolean) });
|
|
612
|
+
} else if (item && typeof item === 'object') {
|
|
613
|
+
fields.push({ key: key, value: compactText(safeText(item), 160) });
|
|
614
|
+
} else if (item !== undefined && item !== null && item !== '') {
|
|
615
|
+
fields.push({ key: key, value: safeText(item) });
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
if (Array.isArray(value)) {
|
|
619
|
+
add('items', value);
|
|
620
|
+
} else {
|
|
621
|
+
for (const key of Object.keys(value)) add(key, value[key]);
|
|
622
|
+
}
|
|
623
|
+
if (fields.length === 0 && lists.length === 0) return null;
|
|
624
|
+
return { fields: fields, lists: lists };
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function dataSummaryOf(data) {
|
|
628
|
+
if (data.lists.length > 0) {
|
|
629
|
+
return data.lists.map((list) => list.rows.length + ' ' + list.key).join(' · ');
|
|
630
|
+
}
|
|
631
|
+
return data.fields.slice(0, 2).map((field) => field.key + ' ' + compactText(field.value, 32)).join(' · ');
|
|
632
|
+
}
|
|
633
|
+
|
|
499
634
|
function presentValue(object, keys) {
|
|
500
635
|
for (const key of keys || []) {
|
|
501
636
|
if (object && Object.prototype.hasOwnProperty.call(object, key)
|
|
@@ -598,6 +733,38 @@
|
|
|
598
733
|
);
|
|
599
734
|
}
|
|
600
735
|
|
|
736
|
+
function ListSection({ title, rows }) {
|
|
737
|
+
if (!rows || rows.length === 0) return null;
|
|
738
|
+
return h('section', { style: { borderTop: '0.5px solid ' + T.borderStrong } },
|
|
739
|
+
h('div', {
|
|
740
|
+
style: {
|
|
741
|
+
display: 'flex',
|
|
742
|
+
alignItems: 'center',
|
|
743
|
+
justifyContent: 'space-between',
|
|
744
|
+
gap: 8,
|
|
745
|
+
padding: '7px 12px 0'
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
h('span', { style: { color: T.caption, fontSize: 11.5, letterSpacing: 0.1 } }, title + ' (' + rows.length + ')'),
|
|
749
|
+
h(CopyButton, { value: rows.join('\n'), label: title })
|
|
750
|
+
),
|
|
751
|
+
h('div', {
|
|
752
|
+
style: {
|
|
753
|
+
padding: '5px 12px 10px',
|
|
754
|
+
background: T.codeSurface,
|
|
755
|
+
color: T.secondary,
|
|
756
|
+
fontFamily: T.mono,
|
|
757
|
+
fontSize: 12,
|
|
758
|
+
lineHeight: 1.55,
|
|
759
|
+
whiteSpace: 'pre-wrap',
|
|
760
|
+
overflowWrap: 'anywhere',
|
|
761
|
+
overflow: 'auto',
|
|
762
|
+
maxHeight: 260
|
|
763
|
+
}
|
|
764
|
+
}, rows.map((row, index) => h('div', { key: index, style: { minHeight: 18 } }, row)))
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
|
|
601
768
|
function DiffSection({ value }) {
|
|
602
769
|
if (!value) return null;
|
|
603
770
|
const lines = String(value).split(String.fromCharCode(10));
|
|
@@ -692,6 +859,8 @@
|
|
|
692
859
|
const query = queryText(args, config);
|
|
693
860
|
const targets = targetKeysText(args, config);
|
|
694
861
|
const payload = payloadText(args);
|
|
862
|
+
const data = config.kind === 'mcp-data' ? dataParts(rawResultText(block)) : null;
|
|
863
|
+
const dataSummary = data ? dataSummaryOf(data) : '';
|
|
695
864
|
const jobArg = firstValue(args, config && config.jobKeys);
|
|
696
865
|
const jobSummary = jobArg === undefined ? '' : 'job ' + safeText(jobArg);
|
|
697
866
|
const diff = config.kind === 'file-write' ? diffText(args) : '';
|
|
@@ -700,7 +869,7 @@
|
|
|
700
869
|
: undefined;
|
|
701
870
|
const isShell = config.kind === 'shell' || config.kind === 'mcp-shell';
|
|
702
871
|
const primary = isShell ? command : path;
|
|
703
|
-
const summary = compactText(primary || query || payload || jobSummary || 'Tool call', MAX_SUMMARY_CHARS);
|
|
872
|
+
const summary = compactText(primary || query || payload || jobSummary || dataSummary || 'Tool call', MAX_SUMMARY_CHARS);
|
|
704
873
|
const output = compactText(result.output || (phase === 'result' ? 'No output' : ''), MAX_OUTPUT_CHARS);
|
|
705
874
|
const cardLabel = labelOf(name, config);
|
|
706
875
|
const title = name.indexOf('mcp__') === 0 ? 'MCP · ' + cardLabel : cardLabel;
|
|
@@ -709,6 +878,9 @@
|
|
|
709
878
|
const hosts = result.hosts || [];
|
|
710
879
|
const multiHost = hosts.length > 1;
|
|
711
880
|
|
|
881
|
+
const dataMetas = data
|
|
882
|
+
? data.fields.slice(0, 8).map((field) => h(Meta, { key: 'data-' + field.key, label: field.key, value: field.value }))
|
|
883
|
+
: [];
|
|
712
884
|
const metaItems = [
|
|
713
885
|
h(Meta, { key: 'status', label: 'Status', value: status.label }),
|
|
714
886
|
h(Meta, { key: 'tool', label: 'Tool', value: name }),
|
|
@@ -718,7 +890,7 @@
|
|
|
718
890
|
h(Meta, { key: 'state', label: 'State', value: result.state }),
|
|
719
891
|
h(Meta, { key: 'revision', label: 'Expected revision', value: expectedRevision }),
|
|
720
892
|
exitLabel ? h(Meta, { key: 'exit', label: 'Result', value: exitLabel }) : null
|
|
721
|
-
];
|
|
893
|
+
].concat(dataMetas);
|
|
722
894
|
|
|
723
895
|
const sections = [];
|
|
724
896
|
if (command) sections.push(h(Section, { key: 'command', title: 'Command', value: '$ ' + command, maxHeight: 180 }));
|
|
@@ -740,10 +912,16 @@
|
|
|
740
912
|
maxHeight: 240
|
|
741
913
|
}));
|
|
742
914
|
}
|
|
743
|
-
} else if (output) {
|
|
915
|
+
} else if (output && !data) {
|
|
744
916
|
sections.push(h(Section, { key: 'output', title: 'Output', value: output, maxHeight: 300 }));
|
|
745
917
|
}
|
|
746
|
-
if (
|
|
918
|
+
if (data) {
|
|
919
|
+
for (let index = 0; index < data.lists.length; index += 1) {
|
|
920
|
+
const list = data.lists[index];
|
|
921
|
+
sections.push(h(ListSection, { key: 'list-' + index, title: list.key, rows: list.rows }));
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if (sections.length === 0 && !data) {
|
|
747
925
|
sections.push(h(Section, { key: 'args', title: 'Arguments', value: pretty(args), maxHeight: 220 }));
|
|
748
926
|
}
|
|
749
927
|
|
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.7';
|
|
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.7",
|
|
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.7",
|
|
44
44
|
"bundle": {
|
|
45
45
|
"patch": "./cordis.patch.yml"
|
|
46
46
|
},
|