dsh-toolview-kit 0.3.5 → 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 CHANGED
@@ -1,5 +1,18 @@
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
+
10
+ ## 0.3.6 - 2026-12-03
11
+
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.
13
+ - 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.
14
+ - Added `jobKeys` to the map schema so a receipt tool can name its job-id argument.
15
+
3
16
  ## 0.3.5 - 2026-12-01
4
17
 
5
18
  - Dropped a note under the screenshots that explained the images had their paths blanked.
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` 会先构建再跑 13 个用例,覆盖工具映射、loader 形状、注册数量、卡片渲染、Diff 和 JumpServer 回执。测试不需要 DSH 运行时:用 `node:vm` 模拟 `window.__ModuleLoader__`,配一个极小的 React stub 渲染并断言文本。
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
 
@@ -48,10 +48,13 @@ dsh plugin --profile desktop add file://$PWD
48
48
  | --- | --- |
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
+ | 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` |
51
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` |
52
55
  | file-write | `ops_replace`、`ops_write_file`、`ops_edit_file`、`ops_copy`、`ops_move`、`ops_remove` |
53
56
 
54
- 共 20 个工具名,全部来自 `config/tools.json`。要加新工具,改映射表再构建,不用写组件。
57
+ 共 32 个工具名,全部来自 `config/tools.json`。要加新工具,改映射表再构建,不用写组件。
55
58
 
56
59
  ## 卡片内容
57
60
 
@@ -61,6 +64,9 @@ dsh plugin --profile desktop add file://$PWD
61
64
 
62
65
  - 退出码取结果尾部的 `[exit code: N]`,展示时从正文剥离;`interrupted` 单独标成取消。
63
66
  - JumpServer 返回的是 `{ok, state, job_id, out, results[]}` 这种作业回执。卡片会取出 `results[].ip` 和 `out`、`state`、`job_id`,把 `host | CHANGED | rc=0 >>` 这类 Ansible 包头换成小标题并折成 `exit N`,多台资产各占一段。
67
+ - `get_command_result` 是同一个回执形状的异步查询:折叠行直接用 `job_id` 当摘要,展开后照旧按资产分段,不再甩一坨 JSON。
68
+ - `upload_file` / `download_file` 复用这套解包:折叠行给出本地路径与目标资产,展开后按资产列出落地结果。
69
+ - `list_jobs`、`list_assets`、`get_status` 返回普通 JSON 数据,不是作业回执。`mcp-data` 卡片把顶层标量做成标签字段,把数组按行铺开(资产行是 `ip hostname …`),折叠行只给条目数。
64
70
  - `ops_edit_file` 不是 DSH 内置的 `edit`,拿不到官方 diff 视图。插件读 `edits[].oldText` / `newText`(兼容 `old_string` / `new_string`)画逐行 Diff,并显示 `expectedRevision`。
65
71
 
66
72
  ## 主题
@@ -89,12 +95,13 @@ dsh plugin --profile desktop add file://$PWD
89
95
  | 字段 | 说明 |
90
96
  | --- | --- |
91
97
  | key | DSH 线上工具名,必须精确匹配,不支持通配 |
92
- | `kind` | `shell`、`mcp-shell`、`file-read`、`file-write`、`mcp` |
98
+ | `kind` | `shell`、`mcp-shell`、`mcp-receipt`、`mcp-data`、`file-read`、`file-write`、`mcp` |
93
99
  | `label` | 折叠行标题;`mcp__*` 自动加 `MCP · ` 前缀,省略时由工具名推导 |
94
100
  | `commandKeys` | 依次尝试的参数名,取第一个非空值当命令 |
95
101
  | `pathKeys` | 文件类工具的目标路径参数名,支持数组值(如 `files`) |
96
102
  | `queryKeys` | 搜索或匹配条件的参数名 |
97
103
  | `targetKeys` | 目标资产参数名(JumpServer 的 `ips`) |
104
+ | `jobKeys` | 作业号参数名,回执类工具在折叠行显示 `job <id>` |
98
105
 
99
106
  改完跑 `npm run build`。DSH 只加载单文件 bundle,映射表会被内联进 `lib/client.js`,不能在运行时读 JSON。
100
107
 
@@ -102,7 +109,7 @@ dsh plugin --profile desktop add file://$PWD
102
109
 
103
110
  ```bash
104
111
  npm run build # src/client-template.js + config/tools.json → lib/client.js
105
- npm test # 构建 + 13 个用例
112
+ npm test # 构建 + 18 个用例
106
113
  npm run verify # 检查本机 desktop profile 的依赖、bundle 和 junction
107
114
  ```
108
115
 
package/config/tools.json CHANGED
@@ -111,6 +111,71 @@
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"]
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"]
114
179
  }
115
180
  }
116
181
  }
package/docs/cards.md CHANGED
@@ -6,6 +6,8 @@
6
6
  | --- | --- | --- |
7
7
  | `shell` | `$ command` 首行 | 命令块、输出块、CWD、退出码 |
8
8
  | `mcp-shell` | 命令首行 + 目标资产 | 同上,另加 `MCP · <label>` 标题 |
9
+ | `mcp-receipt` | `job <id>` 或目标路径 | 作业状态、按资产分段的输出 |
10
+ | `mcp-data` | 条目数(`n items`)或前两个字段 | 标签字段、每项一行 |
9
11
  | `file-read` | 目标路径或查询条件 | 路径、查询条件、输出 |
10
12
  | `file-write` | 目标路径 | 路径、写入内容、输出 |
11
13
  | `mcp` | 工具名 | 参数 JSON 与输出 |
@@ -25,7 +27,8 @@ DSH 把一次工具调用分成三个阶段交给视图组件:`preparing` →
25
27
  - `block.args` 是惰性对象,不能直接 `JSON.parse`;一律读 `argsRaw`。
26
28
  - `result` 阶段的 `block.call` 可能为 `null`,此时只显示输出。
27
29
  - 输出既可能是 `{ 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` 转成退出码。
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`)压成行尾摘要;解析不出对象时仍退回输出块。
29
32
  - 退出码优先取结构化字段 `exitCode`,其次取 JumpServer 每个结果的 `rc`,最后从正文尾部的 `[exit code: N]` 提取,并在展示前剥离该标记。
30
33
 
31
34
  ## 文件写入 Diff
@@ -57,7 +60,7 @@ Windows 下 `ops_edit_file` 由 dsh-ops 宿主执行时可能保留目标文件
57
60
  ## 扩展一个新工具
58
61
 
59
62
  1. 在 `config/tools.json` 的 `tools` 里加一项,key 必须是线上工具名。
60
- 2. 选 `kind`,补 `commandKeys` / `pathKeys` / `queryKeys` / `targetKeys`。
63
+ 2. 选 `kind`(`shell` / `mcp-shell` / `mcp-receipt` / `mcp-data` / `file-read` / `file-write`),补 `commandKeys` / `pathKeys` / `queryKeys` / `targetKeys` / `jobKeys` 中适用的那组。
61
64
  3. `npm run build && npm test`。
62
65
  4. 重开 DSH Desktop;主题令牌在宿主启动时注入,旧会话不会热替换客户端 bundle。
63
66
 
@@ -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 # 13 个用例
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 命令都在表里,且写操作归到 `file-write`。
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` 收集注册,断言 20 个 key 与映射表一一对应。
41
- 4. **渲染**:极小 React stub(`createElement` + `useState`)直接调用视图,把元素树拍平成文本,断言命令、输出、退出码、路径、目标资产、取消态与 file-write Diff。
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
@@ -198,6 +198,106 @@
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
+ ]
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
+ ]
201
301
  }
202
302
  };
203
303
  const h = React.createElement;
@@ -416,7 +516,7 @@
416
516
  const kind = config && config.kind;
417
517
  // Only MCP tools answer with job receipts; a shell or file tool that
418
518
  // happens to print an object with an `ok` key must stay verbatim.
419
- const receipt = kind === 'mcp-shell' || kind === 'mcp' ? receiptFrom(text) : null;
519
+ const receipt = kind === 'mcp-shell' || kind === 'mcp-receipt' || kind === 'mcp' ? receiptFrom(text) : null;
420
520
  if (receipt) return receipt;
421
521
  const parsed = parseExit(text, block);
422
522
  return { receipt: false, output: parsed.output, exitCode: parsed.exitCode, hosts: [], job: '', state: '', failed: false };
@@ -478,6 +578,59 @@
478
578
  return value === undefined ? '' : pretty(value);
479
579
  }
480
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
+
481
634
  function presentValue(object, keys) {
482
635
  for (const key of keys || []) {
483
636
  if (object && Object.prototype.hasOwnProperty.call(object, key)
@@ -580,6 +733,38 @@
580
733
  );
581
734
  }
582
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
+
583
768
  function DiffSection({ value }) {
584
769
  if (!value) return null;
585
770
  const lines = String(value).split(String.fromCharCode(10));
@@ -674,13 +859,17 @@
674
859
  const query = queryText(args, config);
675
860
  const targets = targetKeysText(args, config);
676
861
  const payload = payloadText(args);
862
+ const data = config.kind === 'mcp-data' ? dataParts(rawResultText(block)) : null;
863
+ const dataSummary = data ? dataSummaryOf(data) : '';
864
+ const jobArg = firstValue(args, config && config.jobKeys);
865
+ const jobSummary = jobArg === undefined ? '' : 'job ' + safeText(jobArg);
677
866
  const diff = config.kind === 'file-write' ? diffText(args) : '';
678
867
  const expectedRevision = config.kind === 'file-write'
679
868
  ? firstValue(args, ['expectedRevision', 'revision'])
680
869
  : undefined;
681
870
  const isShell = config.kind === 'shell' || config.kind === 'mcp-shell';
682
871
  const primary = isShell ? command : path;
683
- const summary = compactText(primary || query || payload || 'Tool call', MAX_SUMMARY_CHARS);
872
+ const summary = compactText(primary || query || payload || jobSummary || dataSummary || 'Tool call', MAX_SUMMARY_CHARS);
684
873
  const output = compactText(result.output || (phase === 'result' ? 'No output' : ''), MAX_OUTPUT_CHARS);
685
874
  const cardLabel = labelOf(name, config);
686
875
  const title = name.indexOf('mcp__') === 0 ? 'MCP · ' + cardLabel : cardLabel;
@@ -689,16 +878,19 @@
689
878
  const hosts = result.hosts || [];
690
879
  const multiHost = hosts.length > 1;
691
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
+ : [];
692
884
  const metaItems = [
693
885
  h(Meta, { key: 'status', label: 'Status', value: status.label }),
694
886
  h(Meta, { key: 'tool', label: 'Tool', value: name }),
695
887
  h(Meta, { key: 'cwd', label: 'CWD', value: props.cwd }),
696
888
  h(Meta, { key: 'target', label: 'Target', value: targets }),
697
- h(Meta, { key: 'job', label: 'Job', value: result.job }),
889
+ h(Meta, { key: 'job', label: 'Job', value: result.job || (jobArg === undefined ? '' : safeText(jobArg)) }),
698
890
  h(Meta, { key: 'state', label: 'State', value: result.state }),
699
891
  h(Meta, { key: 'revision', label: 'Expected revision', value: expectedRevision }),
700
892
  exitLabel ? h(Meta, { key: 'exit', label: 'Result', value: exitLabel }) : null
701
- ];
893
+ ].concat(dataMetas);
702
894
 
703
895
  const sections = [];
704
896
  if (command) sections.push(h(Section, { key: 'command', title: 'Command', value: '$ ' + command, maxHeight: 180 }));
@@ -720,10 +912,16 @@
720
912
  maxHeight: 240
721
913
  }));
722
914
  }
723
- } else if (output) {
915
+ } else if (output && !data) {
724
916
  sections.push(h(Section, { key: 'output', title: 'Output', value: output, maxHeight: 300 }));
725
917
  }
726
- if (sections.length === 0) {
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) {
727
925
  sections.push(h(Section, { key: 'args', title: 'Arguments', value: pretty(args), maxHeight: 220 }));
728
926
  }
729
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.5';
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.5",
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.5",
43
+ "version": "0.3.7",
44
44
  "bundle": {
45
45
  "patch": "./cordis.patch.yml"
46
46
  },