dsh-task-mascot 2.1.1 → 2.1.3

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## 安装
11
11
 
12
- > 已验证:**DSH 0.2.2-rc.1**(npm `latest`,2026-11-09,Linux · `dsh web`)。要求 dsh ≥ 0.2.0-rc.2、Node ≥ 22.19。
12
+ > 已验证:**DSH 0.2.2-rc.5**(npm `next`,2026-11-18,Linux · `dsh web`);此前 **0.2.2-rc.2**(2026-11-12,Linux · `dsh web`);**DSH Desktop (macOS)** 已在 0.2.2-rc.1 上验证安装与启动加载(插件 2.1.2,2026-11-16)。要求 dsh ≥ 0.2.0-rc.2、Node ≥ 22.19。
13
13
 
14
14
  **`dsh web`(命令行)**
15
15
 
@@ -21,7 +21,7 @@ dsh plugin --profile web add github:sherconan/dsh-task-mascot # 或 npm 包:
21
21
 
22
22
  **`dsh web`(界面里装)**:左侧栏 **Plugins(插件)** → **Add plugin(添加插件)** → 输入 `dsh-task-mascot` → **Install(安装)** → 打开插件卡片右侧的开关(启用),刷新页面即可。
23
23
 
24
- **DSH Desktop(桌面版)**:Desktop 用自己独占的 `desktop` profile,上面 `--profile web` 的命令装进的是 web profile,**Desktop 里看不到**;npm 装的 `dsh` 也不能改 Desktop 的 profile。请在 Desktop 里按同样步骤 **Plugins → Add plugin → `dsh-task-mascot`** 安装并启用;或者用 Desktop 自带的 dsh 命令(应用菜单「管理 dsh 命令…」安装),先完全退出 Desktop,再运行 `dsh plugin --profile desktop add dsh-task-mascot`,重新打开即可。(以上 Desktop 步骤依据 [官方 Desktop 文档](https://github.com/deepseek-ai/deepseek-harness/blob/master/apps/desktop/README.zh.md#bundled-command-runtime),尚未在 Desktop 实机验证,遇到问题欢迎提 issue。)
24
+ **DSH Desktop(桌面版)**:Desktop 用自己独占的 `desktop` profile,上面 `--profile web` 的命令装进的是 web profile,**Desktop 里看不到**;npm 装的 `dsh` 也不能改 Desktop 的 profile。请在 Desktop 里按同样步骤 **Plugins → Add plugin → `dsh-task-mascot`** 安装并启用;或者用 Desktop 自带的 dsh 命令(应用菜单「管理 dsh 命令…」安装),先完全退出 Desktop,再运行 `dsh plugin --profile desktop add dsh-task-mascot`,重新打开即可。已在 **macOS DSH Desktop 0.2.2-rc.1** 实机验证安装与启动加载(依据 [官方 Desktop 文档](https://github.com/deepseek-ai/deepseek-harness/blob/master/apps/desktop/README.zh.md#bundled-command-runtime))。
25
25
 
26
26
  **设置入口**(0.2.1 起没有独立的 Settings 页面):左下角 **More(更多)→ Settings(设置)→ 任务角色 Mascot**。插件页里 dsh-task-mascot 的卡片只有启用开关和说明页,配置项不在卡片上。
27
27
 
@@ -50,7 +50,7 @@ dsh plugin --profile web add github:sherconan/dsh-task-mascot # 或 npm 包:
50
50
  ![search](docs/screenshot-search.png)
51
51
  ![approval](docs/screenshot-approval.png)
52
52
 
53
- - **大肥鱼图鉴(2.1.0)**:31 格收集卡,Agent 第一次触发某种动作(写代码、搜索、跑测试、出错……)时点亮一格,右上角弹出一张不挡对话的「新解锁」小提示(短时间内连续解锁会合并成一张,点它打开图鉴)。设置页「打开图鉴」或右键悬浮角色查看;进度只存在本地 localStorage。
53
+ - **大肥鱼图鉴(2.1.0)**:32 格收集卡,Agent 第一次触发某种动作(写代码、搜索、跑测试、出错……)时点亮一格,右上角弹出一张不挡对话的「新解锁」小提示(短时间内连续解锁会合并成一张,点它打开图鉴)。设置页「打开图鉴」或右键悬浮角色查看;进度只存在本地 localStorage。
54
54
 
55
55
  ## 工具 → 动画映射 / Tool → state mapping
56
56
 
@@ -61,16 +61,18 @@ First match wins (`tool`/`ext` are regexes; `ext` = target file extension). Edit
61
61
 
62
62
  | dsh 工具 / tools | 状态 / state | 大肥鱼实际动画 |
63
63
  |---|---|---|
64
- | `write` / `edit` / `str_replace_editor` 且目标是 md/txt/rst/doc/tex | `writingdoc` 写文档 | editing(回退)|
64
+ | `write` / `edit` / `str_replace_editor` / `apply_patch` 且目标是 md/txt/rst/doc/tex | `writingdoc` 写文档 | editing(回退)|
65
65
  | `write` | `coding` 写代码 | coding |
66
- | `edit`, `str_replace_editor` | `editing` 改代码 | editing |
67
- | `read`, `read_image`, `read_mcp_resource`, `lsp` | `reading` 读文件 | reading |
66
+ | `edit`, `str_replace_editor`, `apply_patch` | `editing` 改代码 | editing |
67
+ | `read`, `read_image`, `read_mcp_resource`, `lsp`, `user_terminal_list`, `user_terminal_read` | `reading` 读文件 | reading |
68
68
  | `glob`, `grep`, `session_*`, `web_search`, `web_fetch`, `stagehand_*` | `search` 搜索 | search |
69
69
  | `bash`, `pwsh`, `terminal_*`, `job_*` | `cmd` 跑命令 | cmd |
70
- | `run_code`, `workflow` | `data` 跑数据 | reading(回退)|
70
+ | `run_code`, `workflow`, `office_recalculate` | `data` 跑数据 | reading(回退)|
71
+ | `office_convert`, `office_render` | `writingdoc` 写文档 | editing(回退)|
71
72
  | `todo_write`, `exit_plan_mode`, `*_goal`, `schedule_*` | `planning` 做计划 | planning |
72
- | `subagent`, `send_message`, `list_agents`, `interrupt_agent`, `spawn_teammate`, `team_task_*`, `ralph` | `subagents` 派子代理 | subagents |
73
- | `ask_user_question` | `waiting` 等你 | waiting |
73
+ | `subagent`, `subagent_fork`, `subagent_oar`, `send_message`, `list_agents`, `interrupt_agent`, `spawn_teammate`, `wait_agent`, `team_task_*`, `ralph` | `subagents` 派子代理 | subagents |
74
+ | `ask_user_question`, `propose_action` | `waiting` 等你确认 | waiting |
75
+ | `list_mcp_resources`, `list_mcp_resource_templates`, `mcp__*` | `mcp` 调用 MCP | tools(回退)|
74
76
  | `present` | `summary` 总结 | thinking(回退)|
75
77
  | 其它 (MCP 等) / anything else | `tools` | cmd(回退)|
76
78
 
@@ -165,10 +167,10 @@ E2E 脚本在 `test/e2e/`(Playwright),截图输出到 `qa/`(已 gitignor
165
167
  - Swappable character packs (ships Whale Girl 大肥鱼 and Claude娘) and an editable tool→animation mapping. ~13 MB.
166
168
  - Runs fully locally; makes no external network calls.
167
169
 
168
- Install (verified on **DSH 0.2.2-rc.1**, Linux, `dsh web`; requires dsh ≥ 0.2.0-rc.2, Node ≥ 22.19):
170
+ Install (verified on **DSH 0.2.2-rc.5**, Linux, `dsh web`, 2026-11-18; previously **0.2.2-rc.2**; **DSH Desktop (macOS)** install and startup load verified on 0.2.2-rc.1 with plugin 2.1.2, 2026-11-16; requires dsh ≥ 0.2.0-rc.2, Node ≥ 22.19):
169
171
 
170
172
  - `dsh web`: `dsh plugin --profile web add github:sherconan/dsh-task-mascot` (or the npm package `dsh-task-mascot`), then restart `dsh web`. Or in the UI: **Plugins → Add plugin → `dsh-task-mascot` → Install**, turn on the switch on its card, and refresh.
171
- - DSH Desktop: Desktop owns its own `desktop` profile, so a `--profile web` install does **not** show up there. Install from Desktop's **Plugins → Add plugin**, or quit Desktop and run its bundled `dsh plugin --profile desktop add dsh-task-mascot`. (Per the [official Desktop docs](https://github.com/deepseek-ai/deepseek-harness/blob/master/apps/desktop/README.md#bundled-command-runtime); not yet tested on Desktop.)
173
+ - DSH Desktop: Desktop owns its own `desktop` profile, so a `--profile web` install does **not** show up there. Install from Desktop's **Plugins → Add plugin**, or quit Desktop and run its bundled `dsh plugin --profile desktop add dsh-task-mascot`. Verified on **macOS DSH Desktop 0.2.2-rc.1** (install and startup load). (Per the [official Desktop docs](https://github.com/deepseek-ai/deepseek-harness/blob/master/apps/desktop/README.md#bundled-command-runtime).)
172
174
  - Settings: from 0.2.1 there is no standalone Settings page. Open **More (bottom-left) → Settings → 任务角色 Mascot**. The plugin's card on the Plugins page only has the enable switch and the readme. On 0.2.0 and older, look for the same section in Settings.
173
175
 
174
176
  Code MIT © metsh. Artwork: 大肥鱼 CC BY-NC-SA 4.0 (「溟月」 by 上善无形 → ZipZipPipe → community 大肥鱼; via TreapGoGo/deepseek-whale-girl), Claude娘 CC BY-SA 4.0 — see ART_LICENSE.md. Unofficial; not affiliated with DeepSeek or Anthropic.
@@ -482,6 +482,20 @@
482
482
  "lit@2x": "cards/done.lit@2x.png",
483
483
  "locked": "cards/done.locked.png",
484
484
  "locked@2x": "cards/done.locked@2x.png"
485
+ },
486
+ {
487
+ "id": "refused",
488
+ "index": 32,
489
+ "label": "模型拒答",
490
+ "trigger": "模型以 refusal 结束(CONTENT_REFUSED)",
491
+ "group": "fail",
492
+ "art": "art/refused.png",
493
+ "anim": "anim/worried.webm",
494
+ "artSourceState": "worried",
495
+ "lit": "cards/refused.lit.png",
496
+ "lit@2x": "cards/refused.lit@2x.png",
497
+ "locked": "cards/refused.locked.png",
498
+ "locked@2x": "cards/refused.locked@2x.png"
485
499
  }
486
500
  ]
487
- }
501
+ }
package/lib/client.js CHANGED
@@ -19,21 +19,22 @@ window.__ModuleLoader__.load({
19
19
  { tool: '^(bash|pwsh)$', cmd: '(^|[;&|]\\s*)(sudo\\s+)?((npm|pnpm|yarn|bun)\\s+(i|install|add|ci)|pip3?\\s+install|uv\\s+(add|pip\\s+install|sync)|apt(-get)?\\s+install|brew\\s+install|cargo\\s+(add|install)|go\\s+get|gem\\s+install|Install-Module)\\b', state: 'install' },
20
20
  { tool: '^(bash|pwsh)$', cmd: '(^|[;&|]\\s*)(curl|wget|aria2c|Invoke-WebRequest|iwr|scp|rsync)\\b', state: 'download' },
21
21
  { tool: '^(bash|pwsh)$', cmd: '(^|[;&|]\\s*)(sudo\\s+)?(rm|rmdir|unlink|del|Remove-Item|shred)\\b', state: 'delete' },
22
- { tool: '^(write|edit|str_replace_editor)$', ext: '^(md|mdx|txt|rst|adoc|docx?|tex)$', state: 'writingdoc' },
22
+ { tool: '^(write|edit|str_replace_editor|apply_patch)$', ext: '^(md|mdx|txt|rst|adoc|docx?|tex)$', state: 'writingdoc' },
23
23
  { tool: '^write$', state: 'coding' },
24
- { tool: '^(edit|str_replace_editor)$', state: 'editing' },
24
+ { tool: '^(edit|str_replace_editor|apply_patch)$', state: 'editing' },
25
25
  { tool: '^read_image$', state: 'media' },
26
- { tool: '^(mcp__.*|mcp[_-].*|list_mcp_resources|read_mcp_resource)$', state: 'mcp' },
27
- { tool: '^(read|lsp|cordis_inspect_.*)$', state: 'reading' },
26
+ { tool: '^(mcp__.*|mcp[_-].*|list_mcp_resources|read_mcp_resource|list_mcp_resource_templates)$', state: 'mcp' },
27
+ { tool: '^(read|lsp|cordis_inspect_.*|user_terminal_list|user_terminal_read)$', state: 'reading' },
28
28
  { tool: '^session_.*$', state: 'memory' },
29
29
  { tool: '^(glob|grep)$', state: 'search' },
30
30
  { tool: '^(web_search|web_fetch|stagehand_.*)$', state: 'web' },
31
31
  { tool: '^(create_worktree|load_workspace_dependencies)$', state: 'git' },
32
32
  { tool: '^(bash|pwsh|terminal_.*|job_.*)$', state: 'cmd' },
33
- { tool: '^(run_code|workflow)$', state: 'data' },
33
+ { tool: '^(run_code|workflow|office_recalculate)$', state: 'data' },
34
+ { tool: '^(office_convert|office_render)$', state: 'writingdoc' },
34
35
  { tool: '^(todo_write|exit_plan_mode|create_goal|get_goal|update_goal|schedule_.*)$', state: 'planning' },
35
- { tool: '^(subagent|list_subagent_models|send_message|list_agents|interrupt_agent|spawn_teammate|team_task_.*|ralph)$', state: 'subagents' },
36
- { tool: '^ask_user_question$', state: 'waiting' },
36
+ { tool: '^(subagent|subagent_fork|subagent_oar|list_subagent_models|send_message|list_agents|interrupt_agent|spawn_teammate|wait_agent|team_task_.*|ralph)$', state: 'subagents' },
37
+ { tool: '^(ask_user_question|propose_action)$', state: 'waiting' },
37
38
  { tool: '^present$', state: 'summary' },
38
39
  { tool: '^(skill|plugin_manager|plugin_market|working_directory)$', state: 'tools' },
39
40
  { tool: '.*', state: 'tools' },
@@ -41,7 +42,7 @@ window.__ModuleLoader__.load({
41
42
  const ALL_STATES = ['idle', 'thinking', 'reading', 'search', 'coding', 'editing', 'writingdoc', 'cmd', 'data', 'planning', 'subagents', 'tools', 'summary', 'waiting', 'done', 'error',
42
43
  // v2
43
44
  'web', 'download', 'git', 'test', 'install', 'create', 'delete', 'mcp', 'memory', 'media', 'diff',
44
- 'retry', 'worried', 'busy', 'subtask', 'denied', 'interrupted', 'sweat', 'tired', 'cheer'];
45
+ 'retry', 'worried', 'busy', 'subtask', 'denied', 'interrupted', 'sweat', 'tired', 'cheer', 'refused'];
45
46
 
46
47
  function compileRules(rules) {
47
48
  const out = [];
@@ -65,7 +66,7 @@ window.__ModuleLoader__.load({
65
66
  const GLOBAL_FALLBACK = { writingdoc: ['editing', 'coding'], data: ['cmd', 'thinking'], tools: ['cmd', 'thinking'], subagents: ['planning', 'tools'], summary: ['done', 'thinking'], idle: ['waiting', 'thinking'], generating: ['thinking'],
66
67
  // v2 states degrade gracefully on packs that only ship the v1 set (e.g. claude)
67
68
  web: ['search'], download: ['web', 'cmd'], git: ['cmd'], test: ['cmd'], install: ['download', 'cmd'], create: ['coding'], delete: ['cmd'], mcp: ['tools', 'cmd'], memory: ['search', 'reading'], media: ['reading'], diff: ['editing', 'reading'],
68
- retry: ['error', 'thinking'], worried: ['error'], busy: ['cmd', 'thinking'], subtask: ['done'], denied: ['error'], interrupted: ['waiting', 'idle'], sweat: ['thinking'], tired: ['waiting', 'thinking'], cheer: ['done'] };
69
+ retry: ['error', 'thinking'], worried: ['error'], busy: ['cmd', 'thinking'], subtask: ['done'], denied: ['error'], interrupted: ['waiting', 'idle'], refused: ['worried', 'error'], sweat: ['thinking'], tired: ['waiting', 'thinking'], cheer: ['done'] };
69
70
  /**
70
71
  * A/B variants: manifest.variants = { coding: ['coding','coding_b'], ... }. `mode` 'alternate' picks by
71
72
  * seed parity (step number), 'random' hashes the seed, 'off' keeps the base state. Deterministic per seed so
@@ -162,12 +163,21 @@ window.__ModuleLoader__.load({
162
163
  const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); n = n || 48; return s.length > n ? s.slice(0, n - 1) + '…' : s; };
163
164
  const shortPath = (p) => String(p || '').split(/[\\/]/).filter(Boolean).slice(-2).join('/');
164
165
  const extOf = (p) => { const m = /\.([A-Za-z0-9]+)$/.exec(String(p || '')); return m ? m[1].toLowerCase() : undefined; };
166
+ /** Path from write/edit-style args, or from an apply_patch patch body. */
167
+ function toolPath(a) {
168
+ if (!a || typeof a !== 'object') return '';
169
+ const direct = a.file_path || a.path || a.notebook_path;
170
+ if (direct) return String(direct);
171
+ const raw = a.patch || a.input || a.diff || '';
172
+ const m = /\*\*\*\s+(?:Add|Update|Delete|Rename)\s+File:\s+(\S+)/.exec(String(raw));
173
+ return m ? m[1] : '';
174
+ }
165
175
  /** Parse possibly-incomplete streamed JSON arguments; falls back to regex-extracting known string fields. */
166
176
  function partialArgs(raw) {
167
177
  if (raw && typeof raw === 'object') return raw;
168
178
  try { const v = JSON.parse(raw); if (v && typeof v === 'object') return v; } catch (_e) { /* partial */ }
169
179
  const o = {}; const src = String(raw || '');
170
- for (const k of ['file_path', 'path', 'pattern', 'command', 'description', 'query', 'url', 'prompt', 'name', 'server', 'tool']) {
180
+ for (const k of ['file_path', 'path', 'pattern', 'command', 'description', 'query', 'url', 'prompt', 'name', 'server', 'tool', 'patch', 'input', 'uri', 'terminal']) {
171
181
  const m = new RegExp('"' + k + '"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"').exec(src);
172
182
  if (m) { let v; try { v = JSON.parse('"' + m[1] + '"'); } catch (_e) { v = m[1].replace(/\\(["\\/])/g, '$1').replace(/\\[nrt]/g, ' '); } o[k] = v; }
173
183
  }
@@ -176,13 +186,13 @@ window.__ModuleLoader__.load({
176
186
  }
177
187
  /** Chinese one-line description of what a tool call is doing (args stay in the browser). */
178
188
  function actionText(tool, a) {
179
- a = a || {}; const t = String(tool || ''); const f = shortPath(a.file_path || a.path || a.notebook_path);
189
+ a = a || {}; const t = String(tool || ''); const f = shortPath(toolPath(a));
180
190
  if (!t) return '准备调用工具…';
181
191
  if (/^(mcp__|mcp[_-])/i.test(t)) { const parts = t.replace(/^mcp(__|[_-])/i, '').split(/__|\//); return '调用 MCP: ' + clip(parts.join(' · '), 40); }
182
192
  switch (t) {
183
193
  case 'read': case 'read_image': return '正在读 ' + (f || '文件');
184
194
  case 'write': return '正在写 ' + (f || '文件');
185
- case 'edit': case 'str_replace_editor': return '正在改 ' + (f || '文件');
195
+ case 'edit': case 'str_replace_editor': case 'apply_patch': return '正在改 ' + (f || '文件');
186
196
  case 'grep': return '正在搜索 "' + clip(a.pattern, 30) + '"' + (a.path && a.path !== '.' ? ' @ ' + shortPath(a.path) : '');
187
197
  case 'glob': return '正在查找文件 ' + clip(a.pattern, 36);
188
198
  case 'web_search': return '正在联网搜索 "' + clip((a.queries && a.queries[0]) || a.query, 30) + '"';
@@ -190,13 +200,20 @@ window.__ModuleLoader__.load({
190
200
  case 'bash': case 'pwsh': return a.command ? '运行 ' + clip(a.command, 44) : '准备运行命令…';
191
201
  case 'session_search': case 'session_read': case 'session_list': return '翻看历史会话' + (a.query ? ' "' + clip(a.query, 24) + '"' : '');
192
202
  case 'list_mcp_resources': return '列出 MCP 资源';
203
+ case 'list_mcp_resource_templates': return '列出 MCP 资源模板';
193
204
  case 'read_mcp_resource': return '读取 MCP 资源 ' + clip(a.uri || a.server, 30);
194
205
  case 'create_worktree': return '新建 Git worktree';
195
206
  case 'wait_agent': return '等子代理回来';
196
207
  case 'todo_write': return '正在更新待办' + (Array.isArray(a.todos) ? '(' + a.todos.length + ' 项)' : '');
197
- case 'subagent': case 'spawn_teammate': return '派出子代理:' + clip(a.description || a.prompt, 36);
208
+ case 'subagent': case 'subagent_fork': case 'subagent_oar': case 'spawn_teammate': return '派出子代理:' + clip(a.description || a.prompt, 36);
198
209
  case 'send_message': return '给子代理发消息';
199
210
  case 'ask_user_question': return '正在向你提问';
211
+ case 'propose_action': return '正在等你确认';
212
+ case 'user_terminal_list': return '正在查看终端列表';
213
+ case 'user_terminal_read': return '正在读终端输出' + (a.terminal || a.name ? ' ' + clip(a.terminal || a.name, 24) : '');
214
+ case 'office_convert': return '正在转换文档' + (f ? ' ' + f : '');
215
+ case 'office_recalculate': return '正在重算表格' + (f ? ' ' + f : '');
216
+ case 'office_render': return '正在渲染文档' + (f ? ' ' + f : '');
200
217
  case 'job_output': return '查看后台任务输出';
201
218
  case 'present': return '正在展示交付物';
202
219
  case 'lsp': return '查询代码索引';
@@ -208,6 +225,7 @@ window.__ModuleLoader__.load({
208
225
  function shellFailed(st, m) {
209
226
  if (!/^(bash|pwsh|powershell|shell)$/.test(st.tool)) return false;
210
227
  const c = m.content; const txt = typeof c === 'string' ? c : Array.isArray(c) ? c.map((x) => (x && x.text) || '').join('\n') : '';
228
+ if (/\[sandbox: file access denied/i.test(txt)) return true;
211
229
  const mm = /\[exit code: (\d+)\]\s*$/.exec(txt); if (!mm || mm[1] === '0') return false;
212
230
  return !/^\s*(git\s+diff|diff|cmp|grep|rg|test|\[)\b/.test(String(st.args.command || ''));
213
231
  }
@@ -223,6 +241,13 @@ function resultBrief(message) {
223
241
  * ({type:'event'|'transient', event}). Live entries enqueue display frames that are each shown
224
242
  * for at least `dwellMs`; history entries rebuild state silently.
225
243
  */
244
+ /** Error code on a turn/end payload. Official DSH 0.2.2-rc.3+ shape is `reason.error.code` (LlmFailure). */
245
+ function turnErrorCode(d) {
246
+ const r = d && d.reason;
247
+ if (r && r.error && typeof r.error.code === 'string') return r.error.code;
248
+ if (d && d.error && typeof d.error.code === 'string') return d.error.code;
249
+ return '';
250
+ }
226
251
  function createTracker(opts) {
227
252
  // v2 knobs: stepSlowMs = one step/think this long -> sweat (x3 -> tired); loopLongMs = whole turn this long ->
228
253
  // tired while thinking, cheer on success; busyN = this many tool calls without thinking in between -> busy;
@@ -260,7 +285,7 @@ function resultBrief(message) {
260
285
  return [st, created];
261
286
  }
262
287
  function finishStep(st) {
263
- const path = st.args.file_path || st.args.path;
288
+ const path = toolPath(st.args);
264
289
  let state = stateForTool(st.tool, { ext: extOf(path), command: st.args.command }, compiled);
265
290
  // write to a path this session has never read/edited/written -> "create" (decided once, when the path is first known)
266
291
  if (st.tool === 'write' && path && st.isNew === undefined) st.isNew = !S.seenPaths.has(path);
@@ -326,7 +351,7 @@ function resultBrief(message) {
326
351
  const failed = !!m.isError || shellFailed(st, m);
327
352
  st.status = failed ? 'error' : 'ok'; st.endAt = ctx.time; st.result = resultBrief(m) || (failed ? '失败' : '完成');
328
353
  S.afterResult = true;
329
- const path = st.args.file_path || st.args.path; if (path && /^(read|write|edit|str_replace_editor)$/.test(st.tool)) S.seenPaths.add(path);
354
+ const path = toolPath(st.args); if (path && /^(read|write|edit|str_replace_editor|apply_patch)$/.test(st.tool)) S.seenPaths.add(path);
330
355
  if (failed) {
331
356
  S.failStreak++; S.lastFail = { sig: sig(st), retry: st.retry || 0 };
332
357
  const worried = S.failStreak >= o.worriedN;
@@ -334,7 +359,7 @@ function resultBrief(message) {
334
359
  } else {
335
360
  S.failStreak = 0; if (S.lastFail && S.lastFail.sig === sig(st)) S.lastFail = null;
336
361
  let sub = null;
337
- if (/^(subagent|spawn_teammate|wait_agent|team_task_(complete|done|update))$/.test(st.tool)) sub = '子任务完成:' + clip(st.args.description || st.args.prompt || st.result, 30);
362
+ if (/^(subagent|subagent_fork|subagent_oar|spawn_teammate|wait_agent|team_task_(complete|done|update))$/.test(st.tool)) sub = '子任务完成:' + clip(st.args.description || st.args.prompt || st.result, 30);
338
363
  else if (st.tool === 'todo_write' && Array.isArray(st.args.todos)) {
339
364
  const done = st.args.todos.filter((x) => x && /^(completed|done)$/i.test(x.status || '')).length;
340
365
  if (done > S.todoDone) sub = '完成一项待办(' + done + '/' + st.args.todos.length + ')';
@@ -349,12 +374,15 @@ function resultBrief(message) {
349
374
  case 'turn/end': {
350
375
  const k = (d.reason && d.reason.kind) || 'completed'; const ok = /^(completed|complete|stop|end_turn|done|ok)$/i.test(k);
351
376
  const cancelled = /cancel|interrupt|abort/i.test(k);
352
- S.active = false; S.turnEnd = ctx.time; S.outcome = ok ? 'ok' : cancelled ? 'cancelled' : 'error';
377
+ // Official DSH shape (0.2.2-rc.3+): data.reason.error.code. Do not treat MALFORMED_RESPONSE as refusal.
378
+ const errCode = turnErrorCode(d);
379
+ const refused = !ok && !cancelled && errCode === 'CONTENT_REFUSED';
380
+ S.active = false; S.turnEnd = ctx.time; S.outcome = ok ? 'ok' : cancelled ? 'cancelled' : refused ? 'refused' : 'error';
353
381
  const rec = S.turns.get(S.turn); if (rec) { rec.endAt = ctx.time; rec.outcome = S.outcome; }
354
- for (const st of S.steps) if (st.status === 'running' || st.status === 'streaming' || st.status === 'waiting') st.status = cancelled ? 'cancelled' : 'error';
382
+ for (const st of S.steps) if (st.status === 'running' || st.status === 'streaming' || st.status === 'waiting') st.status = cancelled || refused ? 'cancelled' : 'error';
355
383
  const long = S.turnStart && ctx.time - S.turnStart >= o.loopLongMs;
356
- push({ kind: ok ? 'done' : cancelled ? 'interrupted' : 'error', state: ok ? (long ? 'cheer' : 'done') : cancelled ? 'interrupted' : 'error',
357
- text: ok ? (long ? '终于搞定!' : '完成') + ' · 共 ' + S.steps.length + ' 步' + (S.round > 1 ? ' · ' + S.round + ' 轮' : '') + (long ? ' · 用时 ' + fmtDur(ctx.time - S.turnStart) : '') : cancelled ? '已中断' : '本轮出错(' + k + ')' }, ctx);
384
+ push({ kind: ok ? 'done' : cancelled ? 'interrupted' : refused ? 'refused' : 'error', state: ok ? (long ? 'cheer' : 'done') : cancelled ? 'interrupted' : refused ? 'refused' : 'error',
385
+ text: ok ? (long ? '终于搞定!' : '完成') + ' · 共 ' + S.steps.length + ' 步' + (S.round > 1 ? ' · ' + S.round + ' 轮' : '') + (long ? ' · 用时 ' + fmtDur(ctx.time - S.turnStart) : '') : cancelled ? '已中断' : refused ? '模型拒绝回答这个请求' : '本轮出错(' + k + ')' }, ctx);
358
386
  break;
359
387
  }
360
388
  default: return;
@@ -475,10 +503,10 @@ function resultBrief(message) {
475
503
  // ---------------------------------------------------------------- v2 surfaces: tracker registry, inline card, dock bar, turn summary, pet
476
504
  const STATE_ZH = { idle: '待机', thinking: '思考中', reading: '读文件', search: '搜索', coding: '写代码', editing: '改代码', writingdoc: '写文档', cmd: '跑命令', data: '跑数据', planning: '做计划', subagents: '派子代理', tools: '用工具', summary: '总结', waiting: '等你确认', done: '完成', error: '出错了',
477
505
  web: '上网', download: '下载', git: 'Git', test: '跑测试', install: '装依赖', create: '新建文件', delete: '删除', mcp: '调 MCP', memory: '翻记忆', media: '看图', diff: '对比改动',
478
- retry: '重试', worried: '有点慌', busy: '忙不过来', subtask: '子任务完成', denied: '被拒绝了', interrupted: '被打断', sweat: '有点久', tired: '好累', cheer: '终于搞定' };
506
+ retry: '重试', worried: '有点慌', busy: '忙不过来', subtask: '子任务完成', denied: '被拒绝了', interrupted: '被打断', sweat: '有点久', tired: '好累', cheer: '终于搞定', refused: '模型拒答' };
479
507
  const STATE_ICON = { thinking: '💭', reading: '📖', search: '🔍', coding: '⌨️', editing: '✏️', writingdoc: '📝', cmd: '💻', data: '📊', planning: '🗂️', subagents: '🤝', tools: '🧰', summary: '📋', waiting: '✋', done: '✅', error: '❌', idle: '😴',
480
508
  web: '🌐', download: '⬇️', git: '🌿', test: '🧪', install: '📦', create: '🆕', delete: '🗑️', mcp: '🔌', memory: '🧠', media: '🖼️', diff: '🔀',
481
- retry: '🔁', worried: '😰', busy: '🌀', subtask: '☑️', denied: '🚫', interrupted: '⏸️', sweat: '💦', tired: '🥱', cheer: '🎉' };
509
+ retry: '🔁', worried: '😰', busy: '🌀', subtask: '☑️', denied: '🚫', interrupted: '⏸️', sweat: '💦', tired: '🥱', cheer: '🎉', refused: '😰' };
482
510
  /** Pack state to actually play: logical -> resolved (fallbacks) -> A/B variant. */
483
511
  function displayState(v, manifest, mode) { return pickVariant(resolveState(v.state, manifest), manifest, v.seed, mode || 'alternate'); }
484
512
  const STATUS_MARK = { ok: { c: '#30a46c', m: '✓' }, error: { c: '#e5484d', m: '✗' }, waiting: { c: '#f5a524', m: '⏳' }, running: { c: '#3e63dd', m: '•' }, streaming: { c: '#8e4ec6', m: '…' }, cancelled: { c: '#888', m: '–' } };
@@ -580,7 +608,7 @@ function resultBrief(message) {
580
608
  const stepElapsed = st ? (st.endAt || (v.active ? now : v.turnEnd || now)) - st.startAt : 0;
581
609
  const turnElapsed = v.turnStart ? (v.active ? now : v.turnEnd || now) - v.turnStart : 0;
582
610
  const lastDone = v.steps.slice().reverse().find((x) => x.status === 'ok' || x.status === 'error');
583
- const tone = /^(error|worried|denied)$/.test(v.state) ? '#e5484d' : /^(waiting|interrupted|sweat|tired|retry)$/.test(v.state) ? '#f5a524' : /^(done|cheer|subtask)$/.test(v.state) ? '#30a46c' : '#3e63dd';
611
+ const tone = /^(error|worried|denied|refused)$/.test(v.state) ? '#e5484d' : /^(waiting|interrupted|sweat|tired|retry)$/.test(v.state) ? '#f5a524' : /^(done|cheer|subtask)$/.test(v.state) ? '#30a46c' : '#3e63dd';
584
612
  return h('div', { onClick: compact ? undefined : () => setOpen((x) => !x), title: compact ? undefined : '点击展开/收起本轮全部步骤', style: { cursor: compact ? 'default' : 'pointer' } }, h('div', { ref, 'data-mascot-card': surface, 'data-state': v.state, 'data-resolved': resolved || '', 'data-step': stepNo, 'data-queued': v.queued, 'data-round': v.round || 0, 'data-mood': v.mood || '',
585
613
  style: { display: 'flex', gap: compact ? 10 : 14, alignItems: 'center', padding: compact ? '6px 10px' : '10px 14px', borderRadius: 12, border: '1px solid ' + tone + '55', background: 'var(--dsw-alias-bg-l1, rgba(127,127,127,.06))', boxShadow: '0 1px 6px rgba(0,0,0,.06)', font: '13px/1.45 system-ui, sans-serif', color: 'inherit', maxWidth: '100%' } },
586
614
  h('div', { style: { flex: 'none', width: size, height: size } }, manifest ? h(Player, { pack, manifest, state: resolved, size }) : null),
@@ -682,7 +710,7 @@ function resultBrief(message) {
682
710
  const rec = tr.S.turns.get(turnNo); if (!rec || !rec.endAt || !rec.steps.length) return null;
683
711
  const ok = rec.steps.filter((x) => x.status === 'ok').length; const bad = rec.steps.filter((x) => x.status === 'error').length;
684
712
  return h('div', { 'data-mascot-turn-summary': turnNo, onClick: () => setOpen((x) => !x), title: '点击查看本轮每一步', style: { cursor: 'pointer', font: '12px system-ui, sans-serif', opacity: 0.85, padding: '4px 0' } }, h('div', { style: { display: 'flex', gap: 10, alignItems: 'center', flexWrap: 'wrap' } },
685
- h('span', null, (rec.outcome === 'ok' ? '✅' : '❌') + ' 本轮 ' + rec.steps.length + ' 步 · 用时 ' + fmtDur(rec.endAt - rec.startAt) + ' · 成功 ' + ok + (bad ? ' · 失败 ' + bad : '')),
713
+ h('span', null, (rec.outcome === 'ok' ? '✅' : rec.outcome === 'refused' ? '😰' : '❌') + ' 本轮 ' + rec.steps.length + ' 步 · 用时 ' + fmtDur(rec.endAt - rec.startAt) + ' · 成功 ' + ok + (bad ? ' · 失败 ' + bad : '')),
686
714
  h(StepIcons, { steps: rec.steps, max: 24 }), h('span', { style: { opacity: 0.6 } }, open ? '收起 ▲' : '回放 ▼')),
687
715
  open ? h(StepList, { steps: rec.steps }) : null);
688
716
  }
@@ -749,7 +777,7 @@ function resultBrief(message) {
749
777
  style: Object.assign({ position: 'fixed', zIndex: 2147483000, width: size, height: size, cursor: 'grab', userSelect: 'none', touchAction: 'none', opacity: settings.opacity, transform: dodge ? 'translateY(' + dodge + 'px)' : 'none' }, anchor), 'data-dodge': dodge,
750
778
  },
751
779
  h(Player, { pack: settings.pack, manifest, state: resolved, size }),
752
- settings.showChip ? h('div', { 'data-mascot-chip': '', style: { position: 'absolute', left: '50%', bottom: -6, transform: 'translateX(-50%)', maxWidth: size, boxSizing: 'border-box', overflow: 'hidden', textOverflow: 'ellipsis', font: '12px/18px system-ui, sans-serif', padding: '0 8px', borderRadius: 9, background: act.state === 'error' ? '#e5484d' : act.state === 'waiting' ? '#f5a524' : 'rgba(30,30,40,.72)', color: '#fff', whiteSpace: 'nowrap', pointerEvents: 'none' } },
780
+ settings.showChip ? h('div', { 'data-mascot-chip': '', style: { position: 'absolute', left: '50%', bottom: -6, transform: 'translateX(-50%)', maxWidth: size, boxSizing: 'border-box', overflow: 'hidden', textOverflow: 'ellipsis', font: '12px/18px system-ui, sans-serif', padding: '0 8px', borderRadius: 9, background: /^(error|worried|denied|refused)$/.test(act.state) ? '#e5484d' : act.state === 'waiting' ? '#f5a524' : 'rgba(30,30,40,.72)', color: '#fff', whiteSpace: 'nowrap', pointerEvents: 'none' } },
753
781
  v && v.text ? v.text : (STATE_ZH[act.state] || act.state)) : null);
754
782
  }
755
783
 
@@ -770,7 +798,7 @@ function resultBrief(message) {
770
798
  ov.style.setProperty('--c1', c1); ov.style.setProperty('--c2', c1 + '88'); let sp = '';
771
799
  for (let i = 0; i < 26; i++) { const a = i / 26 * 6.283 + Math.random() * 0.3; const r = 150 + Math.random() * 120; sp += '<i class="mdx-spark" style="--c:' + (i % 3 ? c1 : '#FFD43B') + ';--x:' + (Math.cos(a) * r).toFixed(0) + 'px;--y:' + (Math.sin(a) * r).toFixed(0) + 'px;--r:' + (Math.random() * 540).toFixed(0) + 'deg;--d:' + (0.55 + Math.random() * 0.15).toFixed(2) + 's"></i>'; }
772
800
  ov.innerHTML = '<div class="mdx-stage"><div class="mdx-rays"></div><div class="mdx-ring"></div>' + sp + '<div class="mdx-ribbon">' + (replay ? '图鉴' : '新解锁!') + '</div>' +
773
- '<div class="mdx-flip"><div class="mdx-in"><img src="' + dexImg(e['locked@2x']) + '"><div class="mdx-front"><img src="' + dexImg(e['lit@2x']) + '"><video src="' + assetUrl(DEX_PACK, e.id + '.webm') + '" autoplay loop muted playsinline onerror="this.remove()"></video><div class="mdx-shine"></div></div></div></div>' +
801
+ '<div class="mdx-flip"><div class="mdx-in"><img src="' + dexImg(e['locked@2x']) + '"><div class="mdx-front"><img src="' + dexImg(e['lit@2x']) + '"><video src="' + assetUrl(DEX_PACK, (e.artSourceState || e.id) + '.webm') + '" autoplay loop muted playsinline onerror="this.remove()"></video><div class="mdx-shine"></div></div></div></div>' +
774
802
  '<div class="mdx-cap"><b>#' + String(e.index).padStart(2, '0') + ' ' + esc(e.label) + '</b><small>' + esc(e.trigger) + '</small></div></div>';
775
803
  document.body.appendChild(ov);
776
804
  return new Promise((res) => { let done = false; const close = () => { if (done) return; done = true; ov.classList.add('mdx-out'); setTimeout(() => { ov.remove(); res(); }, 350); }; const st = ov.querySelector('.mdx-stage'); if (st) st.onclick = close; setTimeout(close, 3400); });
@@ -875,7 +903,7 @@ function resultBrief(message) {
875
903
  }
876
904
  exports.apply = apply;
877
905
  exports.inject = inject;
878
- exports.__internals = { DEFAULT_RULES, ALL_STATES, compileRules, stateForTool, resolveState, pickVariant, displayState, createMachine, createTracker, actionText, partialArgs, resultBrief, GLOBAL_FALLBACK, STATE_ZH, STATE_ICON, dexUnlock, dexLit, dexLoad, dex, dockShouldShow, dexToastText, DEFAULT_SETTINGS };
906
+ exports.__internals = { DEFAULT_RULES, ALL_STATES, compileRules, stateForTool, resolveState, pickVariant, displayState, createMachine, createTracker, actionText, partialArgs, resultBrief, toolPath, shellFailed, turnErrorCode, GLOBAL_FALLBACK, STATE_ZH, STATE_ICON, dexUnlock, dexLit, dexLoad, dex, dockShouldShow, dexToastText, DEFAULT_SETTINGS };
879
907
  return module.exports;
880
908
  },
881
909
  });
package/lib/index.js CHANGED
@@ -71,7 +71,12 @@ function summarizeArgs(a) {
71
71
  if (a == null) return undefined;
72
72
  if (typeof a === 'string') { try { a = JSON.parse(a); } catch { return undefined; } }
73
73
  if (typeof a !== 'object') return undefined;
74
- const p = a.path ?? a.file_path ?? a.filePath ?? a.target;
74
+ let p = a.path ?? a.file_path ?? a.filePath ?? a.target;
75
+ if (typeof p !== 'string') {
76
+ const raw = a.patch || a.input || a.diff || '';
77
+ const mm = /\*\*\*\s+(?:Add|Update|Delete|Rename)\s+File:\s+(\S+)/.exec(String(raw));
78
+ p = mm ? mm[1] : undefined;
79
+ }
75
80
  if (typeof p !== 'string') return undefined;
76
81
  const m = /\.([A-Za-z0-9]{1,8})$/.exec(p);
77
82
  return m ? { ext: m[1].toLowerCase() } : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-task-mascot",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "metsh · Task Mascot — 真跟着 Agent 每一步工具调用在动。A DeepSeek Harness Web plugin whose mascot acts out every live tool call (read / write / edit / search / run / plan / sub-agent / wait / error) with step cards in chat. Swappable character packs (大肥鱼, Claude娘).",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",