dsh-mcviseron-plugin 0.0.0-stage → 0.6.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 (44) hide show
  1. package/CHANGELOG.md +212 -0
  2. package/CONTRIBUTING.md +60 -0
  3. package/LICENSE +202 -0
  4. package/README.en.md +146 -0
  5. package/README.md +286 -2
  6. package/SECURITY.md +38 -0
  7. package/cordis.patch.yml +12 -0
  8. package/docs/automation-task.md +63 -0
  9. package/docs/migration-from-standalone.md +115 -0
  10. package/docs/release.md +83 -0
  11. package/lib/appearance.js +320 -0
  12. package/lib/auto-review-fix.js +336 -0
  13. package/lib/client.js +1266 -0
  14. package/lib/index.js +1469 -0
  15. package/lib/restart.js +226 -0
  16. package/lib/task-guard.js +621 -0
  17. package/package.json +148 -4
  18. package/scripts/repair-profile.mjs +77 -0
  19. package/src/api.ts +5 -0
  20. package/src/appearance/index.ts +103 -0
  21. package/src/auto-review-fix/index.ts +45 -0
  22. package/src/client/AppearanceScheduleRow.tsx +112 -0
  23. package/src/client/ConfigForm.tsx +284 -0
  24. package/src/client/FallbackRestartRow.tsx +23 -0
  25. package/src/client/RestartCard.tsx +108 -0
  26. package/src/client/SettingsSection.tsx +110 -0
  27. package/src/client/bridge.ts +131 -0
  28. package/src/client/driver.ts +166 -0
  29. package/src/client/index.ts +114 -0
  30. package/src/client/locales.ts +193 -0
  31. package/src/client/primitives.d.ts +15 -0
  32. package/src/client/section-presence.ts +33 -0
  33. package/src/client/styles.ts +154 -0
  34. package/src/components/auto-review-fix/index.ts +277 -0
  35. package/src/components/auto-review-fix/translate.ts +222 -0
  36. package/src/components/task-guard/index.ts +902 -0
  37. package/src/index.ts +71 -0
  38. package/src/loopback.ts +48 -0
  39. package/src/namespace.ts +7 -0
  40. package/src/restart/index.ts +268 -0
  41. package/src/routes.ts +228 -0
  42. package/src/schedule.ts +125 -0
  43. package/src/task-guard/index.ts +52 -0
  44. package/src/volatile.ts +32 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,212 @@
1
+ # Changelog
2
+
3
+ 本项目的所有重要变更都记录在此文件中,格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
4
+
5
+ ## [Unreleased]
6
+
7
+ ### 计划中
8
+
9
+ - 将「按时间切换」扩展为多时段表(例如白天的多个浅色窗口)。
10
+ - 设置行支持「立即测试」预览按钮。
11
+ - Restart 组件支持 macOS/Linux(当前仅 Windows 桌面版)。
12
+ - 把定时巡检任务 prompt 更新为当前单条目架构。
13
+
14
+ ## [0.6.1] - 2026-10-19
15
+
16
+ ### Added
17
+
18
+ - **单一 master 条目 `mcviseron`**:一个 Loader 行挂载 appearance / auto-review-fix / task-guard / restart 四个子组件;包根导出 `lib/index.js` 负责装配。
19
+ - **设置子页**:MCviseron 插件分区新增「Auto review 修复」「Todo 守卫」子页;所有开关使用 DSH 官方 `Switch`(`@deepseek-ai/dsh-client-ui-primitives`)。
20
+ - **组件配置桥**:设置桥支持 `autoReviewFix.*` / `taskGuard.*` / `restart.*` 嵌套路径,表单修改后自动写入 master 条目 Config。
21
+ - **重启**:Windows 任务计划程序创建一次性任务,任务动作直接启动 `DeepSeek Harness.exe`(不经过终端 / `Start-Process`),Host 随后关闭主进程;仅 Windows 桌面版可用。
22
+ - **审批翻译**:auto-review-fix 在翻译成功后把 `【审查理由 · 中文翻译】` 追加到 `reason`,使只读取持久 `approval/asked` 事件的邮箱兜底也能收到翻译;`displayReason` 仍保留译文。
23
+
24
+ ### Fixed
25
+
26
+ - **客户端半区被丢弃**:DSH `client-modules` 只给 Loader 行名称等于包名的条目组合浏览器半区;原四个子路径条目导致整个客户端插件(外观行、设置分区、重启回退)消失。改成单一 `mcviseron` 条目后恢复。
27
+ - **外观行位置**:`settings.general.item` 的 order 改为 `10.5`,紧跟在主题「外观」(10) 之后、字体(11) 之前。
28
+ - **重启配置引用**:嵌套 Config 的 volatile 引用在传入重启组件前统一 `toPlain()`,并给 `appPath` 加字符串兜底,修复 `override.trim is not a function`。
29
+
30
+ ### Changed
31
+
32
+ - `cordis.patch.yml` 只插入一个 `mcviseron` 条目(`name: dsh-mcviseron-plugin`),profile 只配置这一条;组件配置位于其 `autoReviewFix` / `taskGuard` / `restart` 子对象。
33
+ - 设置命名空间从 `mcviseron-appearance` 改为 `mcviseron`;外观字段仍在 Config 顶层。
34
+ - 版本号 `0.6.0` → `0.6.1`(原本地 0.7.0 未发布,不产生 tag)。
35
+ - 合计 **75 项测试**。
36
+
37
+ ### Compatibility
38
+
39
+ - 目标 DSH `0.2.0-rc.2` / `0.2.1-rc.2`;peer 范围 `^0.2.0-rc.2 || ^0.2.1-rc.2`。
40
+ - npm 发布工作流:tag 触发、校验 tag/版本、OIDC Trusted Publishing + provenance;`NPM_PUBLISH_ENABLED` 作为总开关。
41
+
42
+ ### Release
43
+
44
+ - 包名 `dsh-mcviseron-plugin` 在 npmjs 可用;`publishConfig` 指向官方 registry,`prepublishOnly` 执行 `pnpm check`。
45
+ - 新增 `.github/workflows/publish.yml` 与 [docs/release.md](docs/release.md);首次发布手动完成,之后绑定 Trusted Publisher 并设置 `NPM_PUBLISH_ENABLED=true`。
46
+
47
+ ## [0.6.0] - 2026-10-18
48
+
49
+ ### Added
50
+
51
+ - **一级设置分区「MCviseron 插件」**(`settings.section`,id `mcviseron`,order 115):
52
+ - **重启**子页:重启 DeepSeek Harness(按钮 + 可用状态 + 应用路径 + 确认)。
53
+ - **组件**子页:列出 appearance / auto-review-fix / task-guard / restart 及各自配置位置。
54
+ - 重启入口从「设置 → 通用」的一行移到本分区;外观组件的设置行**保持原位**,没有移动。
55
+ - 重启目标解析新增回退:当 Host 运行在 `node.exe` 下时,依次尝试 `argv[0]`、由运行时目录推导的应用 exe;同时页面会显示不可用原因(接口未加载 / 仅桌面版)。
56
+
57
+ ### Changed
58
+
59
+ - 客户端不再向 `settings.general.item` 注册重启行,改为注册 `settings.section`;`RestartRow.tsx` 由 `SettingsSection.tsx` 取代。
60
+ - 版本号 `0.5.0` → `0.6.0`;合计 **71 项测试**。
61
+
62
+ ## [0.5.0] - 2026-10-18
63
+
64
+ ### Added
65
+
66
+ - **重启组件 `mcviseron-restart`(`dsh-mcviseron-plugin/restart`)**:
67
+ - 「设置 → 通用」新增「重启 DeepSeek Harness」行,确认后重启桌面应用。
68
+ - Host 两条 loopback 接口:`POST /api/dsh-mcviseron/restart/status` 与 `/restart/execute`(要求 `{ confirm: true }`、5 秒防重、loopback + 同源栅栏)。
69
+ - 重启由 detached PowerShell 助手完成:先关闭 Electron 主进程,Host 在 IPC 断开后按官方流程优雅关闭;助手等待主进程与 Host 退出,清除 `ELECTRON_RUN_AS_NODE`(Host 继承了该变量),再启动应用。
70
+ - 仅桌面版可用;`dsh web` 下状态接口返回不可用,设置行自动隐藏。`appPath` 可显式覆盖应用路径。
71
+ - 会中断正在运行的任务(与托盘「退出」提示一致),不修改插件、配置或会话记录。
72
+ - 新增 `test/restart.test.ts`(7 项)与重启 Config 测试。
73
+
74
+ ### Notes
75
+
76
+ - DSH 的托盘菜单由 Electron 主进程的 `lib/main.js` 直接构建(`DesktopTray`),插件运行在独立的 Host 子进程,官方没有提供托盘扩展点,因此以设置行提供等价重启入口;未修改应用文件。
77
+ - 合计 **70 项测试**全部通过。
78
+
79
+ ## [0.4.1] - 2026-10-18
80
+
81
+ ### Fixed
82
+
83
+ - **profile 里 `pnpm install` 后所有本地插件变成「异常 / 包不可用」**:pnpm 在 Windows 上把跨盘符的 `link:D:/...` 依赖写成坏符号链接(`<profile>\D:\...`),DSH 无法解析;插件管理器还会把这些条目从 `dsh.profile.bundles` 中移除。新增 `scripts/repair-profile.mjs`:把所有 `link:` 依赖重建为绝对 junction,并把缺失条目补回 `dsh.profile.bundles`;脚本幂等,可反复运行。
84
+ - README / README.en 增加「故障排查」、CONTRIBUTING 增加 Profile 健康检查;本机 profile 已用该脚本修复并恢复 `dsh-mcviseron-plugin`、`dsh-eda-mcp`、`dsh-email-notify`、`dsh-edit-file-workspace` 四个条目。
85
+
86
+ ### Changed
87
+
88
+ - `package.json` 增加 `repair-profile` 脚本,`files` 纳入 `scripts/`;版本 `0.4.0` → `0.4.1`。
89
+
90
+ ## [0.4.0] - 2026-10-18
91
+
92
+ ### Added
93
+
94
+ - **Todo 步骤意图检测**(`detectStepIntent`,默认开启):监听官方 `agent/assistant-stream` 的 `text-delta` / `reasoning-delta`,识别「Now I will …」「Next I will …」「Let me …」「接下来我会 …」「下一步 …」等句式,并与 `pending` todo 做 token / 子串匹配。命中时在 `tools/post-execute` 追加一条**定向建议 notice**,内含可直接发送的 `todo_write` JSON(把下一阶段设为 `in_progress`、当前阶段设为 `completed`);每条消息最多一次,解析失败/无流/不匹配一律静默跳过,**绝不拒绝或阻塞任务**。
95
+ - **Notice 内中文 todo 展示**(`translateTodoContent`,默认开启):notice 中的英文 todo 标题通过宿主 `llm` 批量翻译为「中文(English)」;按标题缓存(上限 256)、单次超时 `todoTranslationTimeoutMs`(默认 3000ms),失败回退原文。只影响 notice 展示,**不改写模型写入的 todo 列表**。
96
+ - notice 增加「todo 内容可以直接用中文书写」提示,引导模型后续直接写中文 todo。
97
+ - 新增 `test/task-guard.test.ts` 用例:中英文意图匹配、每步最多一条意图 notice、todo 标题翻译。
98
+
99
+ ### Fixed
100
+
101
+ - **Auto review 修复组件对中文审查理由重复翻译**:审查正文已含 CJK 字符时直接跳过翻译,审批卡片保持原样;新增回归测试。
102
+ - **Todo 停滞提醒在真实 loop 中的每步重置**:`agent/pre-step` 同时重置 `reminderDeliveredThisStep` 与意图去重标记,并清理当前步骤的意图缓冲,避免一条通知之后整轮不再提醒。
103
+
104
+ ### Changed
105
+
106
+ - 组件更名,避免与官方自动审查插件重名:
107
+ - 条目 id `mcviseron-auto-review` → **`mcviseron-auto-review-fix`**
108
+ - 模块 `dsh-mcviseron-plugin/auto-review` → **`dsh-mcviseron-plugin/auto-review-fix`**
109
+ - 源码目录 `src/auto-review` → `src/auto-review-fix`,构建产物 `lib/auto-review-fix.js`
110
+ - `taskGuard` 新增三个字段:`detectStepIntent`、`translateTodoContent`、`todoTranslationTimeoutMs`(entry Config 与组件校验同步)。
111
+ - 本机 profile 已把 `mcviseron-auto-review` 条目改为 `mcviseron-auto-review-fix`,并在 `mcviseron-task-guard` 中显式写出三个新字段。
112
+ - 版本号 `0.3.0` → `0.4.0`。
113
+
114
+ ### Compatibility
115
+
116
+ - 目标 DSH `0.2.1-rc.2`;意图检测依赖的 `agent/assistant-stream` 帧格式在该代际为 `{ type: 'chunk', chunk: { type: 'text-delta' | 'reasoning-delta', text } }`,缺失时特性探测为 no-op。
117
+ - 合计 **62 项测试**全部通过。
118
+
119
+ ## [0.3.0] - 2026-10-18
120
+
121
+ ### Fixed
122
+
123
+ - **插件管理器只显示 1 个组件**:0.2.0 把三个组件放进同一个 `mcviseron` 条目,DSH 插件清单按 loader 条目渲染,因此「包含的组件」只有 1 项。本版把组件拆成三个独立的 bundle 条目,插件管理器与插件清单现在分别列出 appearance / auto-review / task-guard,可单独启停与配置。
124
+
125
+ ### Changed
126
+
127
+ - `cordis.patch.yml` 改为插入三条目:
128
+ - `mcviseron-appearance` → `dsh-mcviseron-plugin/appearance`
129
+ - `mcviseron-auto-review-fix` → `dsh-mcviseron-plugin/auto-review-fix`
130
+ - `mcviseron-task-guard` → `dsh-mcviseron-plugin/task-guard`
131
+ - 包新增三个子路径导出与三个 Host 构建产物:`lib/appearance.js`、`lib/auto-review.js`、`lib/task-guard.js`;删除旧的聚合 `lib/index.js`。
132
+ - 配置结构从 0.2.0 的嵌套分组(`appearance` / `autoReview` / `taskGuard`)恢复为**每个条目一份扁平 Config**;外观命名空间从 `mcviseron` 改为 `mcviseron-appearance`,设置桥路径恢复为 `['enabled']` 等扁平字段。
133
+ - 每个条目在 `apply()` 前用 `toPlain()` 展开 DSH 0.2 的 volatile 配置引用(否则组件会收到引用对象而不是布尔/数字)。
134
+ - 版本号 `0.2.0` → `0.3.0`。
135
+
136
+ ### Migration
137
+
138
+ - 本机 profile 已把单个 `mcviseron` 条目替换为三条目,配置值原样拆开;旧条目不再读取。
139
+ - 0.2.0 嵌套配置到 0.3.0 三条目的对应关系见 [docs/migration-from-standalone.md](docs/migration-from-standalone.md#30-从-020-的嵌套配置迁移)。
140
+
141
+ ### Tests
142
+
143
+ - `test/config.test.ts` 改为分别校验三个条目的 Config;`test/plugin.test.ts` 改为加载三条目验证组合行为;设置桥测试恢复扁平字段。
144
+ - 合计 **62 项测试**全部通过。
145
+
146
+ ## [0.2.0] - 2026-10-18
147
+
148
+ ### Added
149
+
150
+ - **组件化架构**:`src/components/` 下每个组件一个目录,总插件的 profile 条目(id `mcviseron`)一次性装配全部组件;配置改为 `appearance` / `autoReview` / `taskGuard` 三个分组,字段互不冲突。
151
+ - **并入 `dsh-auto-review-restart-fix` 0.2.0 的全部功能**(组件 `autoReview`):
152
+ - 关机预设守卫:根 Cordis fiber 不是 `ACTIVE` 时丢弃 `permissionPresets.set`,整套宿主退出不再把 Auto 会话写成完全访问;包装常驻、与挂载/卸载顺序无关。
153
+ - 审批理由中文译文:只在 `displayReason` 的本地化值末尾追加 `【审查理由 · 中文翻译】`,`reason` 与 `displayReason.en` 一字不改。
154
+ - 会话 provider/model 自动路由或 `translateProvider`/`translateModel` 固定路由;按原文缓存(上限 256)、超时 500–60000ms、失败原样放行。
155
+ - **并入 `dsh-task-guard` 1.0.0 的全部功能**(组件 `taskGuard`):
156
+ - `todo_write` 后还有 pending 但没有 in_progress:建议性 notice(默认不报错)。
157
+ - 连续 N 次工具调用未更新 todo:停滞 notice,支持重复间隔与每 step 去重。
158
+ - 可选 `rejectMissingActive` / `blockAfterCalls` 严格模式。
159
+ - session format v3/v4 source kind 自动选择(`plugin:task-guard` / `plugin`+`plugin`),`include`/`exclude` 通配过滤,`maxListItems` 截断。
160
+ - 三组件装配集成测试 `test/plugin.test.ts`(真实 Cordis 上下文 + 假 webServer/settings/approval/permissionPresets/llm)。
161
+ - 组件测试移植:`test/auto-review.test.ts`(15)、`test/auto-review-cordis.test.ts`(5)、`test/task-guard.test.ts`(13)、`test/task-guard-cordis.test.ts`(4)、`test/config.test.ts`(6),合计 60 项。
162
+
163
+ ### Changed
164
+
165
+ - **配置结构迁移**:`enabled` / `lightStart` / `lightEnd` 从顶层移到 `appearance` 分组;`autoReview` 与 `taskGuard` 分组沿用两个独立插件的字段名,可直接搬移。
166
+ - 设置桥只暴露 `appearance` 分组,写入路径改为嵌套 `['appearance', field]`;`autoReview` / `taskGuard` 不出现在浏览器接口中。
167
+ - `appearance.lightStart` / `lightEnd` 增加 `HH:MM` 模式校验,错误配置在插件加载时被拒绝。
168
+ - `Config` 的 `taskGuard.exclude` 显式声明默认值 `todo_write`、`ask_user_question`,避免空数组覆盖组件默认行为。
169
+ - 版本号 `0.1.0` → `0.2.0`。
170
+
171
+ ### Compatibility
172
+
173
+ - 目标 DSH `0.2.1-rc.2`(desktop profile,Web GUI)。peer 范围 `^0.2.0-rc.2 || ^0.2.1-rc.2`。
174
+ - 不支持 DSH 0.1.x:0.1 的插件自行注册设置命名空间,与本插件的条目 id 命名空间模型不同。
175
+ - 组件内部的接缝均做特性探测:`permissionPresets`、`approval`、`displayReason`、session format v3/v4;缺失时降级为 no-op 或原样放行。
176
+
177
+ ### Migration
178
+
179
+ - 从 `dsh-auto-review-restart-fix` 与 `dsh-task-guard` 迁移的字段映射、profile 修改和验证清单见 [docs/migration-from-standalone.md](docs/migration-from-standalone.md)。
180
+ - 两个旧仓库由维护者废弃;本仓库是唯一维护入口。
181
+
182
+ ### Notes
183
+
184
+ - 主题状态仍由官方 `ui-theme` 插件持有;本插件按计划调用 `setTheme`,不复制或覆盖 `ui-theme` 的持久化逻辑。
185
+ - profile 条目 id 必须为 `mcviseron`(设置命名空间 = 条目 id)。
186
+
187
+ ## [0.1.0] - 2026-10-18
188
+
189
+ ### Added
190
+
191
+ - **首个组件:外观 · 按时间自动切换深浅色**
192
+ - 在 `settings.general.item` 注册设置行,位置紧跟官方「外观」(order 10)与「字号」(order 11),order 为 12。
193
+ - 默认早间 `08:00`(含)– `23:00`(不含)浅色,其余时间深色。
194
+ - 早间开始/结束时间可自定义(`HH:MM`),支持跨午夜窗口;`start === end` 表示全天浅色。
195
+ - 驱动每 20 秒读取本机时间,在时段变化时调用 `ctx.theme.setTheme`;`visibilitychange` / `focus` 时补一次校准,覆盖休眠唤醒与时钟跳变。
196
+ - 启用、修改时段后立即应用;中途手动切换配色不被抢回,保留到下一个边界。
197
+ - 设置行实时显示当前时段与下次切换时间,并显示保存中/已保存/保存失败状态。
198
+ - Host 半边新增 `mcviseron` 设置命名空间(`enabled`、`lightStart`、`lightEnd`,全部 `.volatile()`),并关闭自动生成的设置页。
199
+ - 新增两条 loopback 设置桥:`/api/dsh-mcviseron/settings/describe` 与 `/api/dsh-mcviseron/settings/mutate`,带 loopback 地址、Host 头与同源 POST 校验;只接受本命名空间与三个已知字段。
200
+ - 中英文案、`test/schedule.test.ts` 时间规则单测、GitHub Actions CI(typecheck + test + build)。
201
+ - 总插件骨架:一个 profile 条目(id `mcviseron`)承载后续组件,`src/` 按 Host / client / 共享逻辑分层。
202
+ - 新增 DSH 自动化任务「维护 dsh-mcviseron-plugin 对最新 DSH 的兼容性」:每周一 10:00(Asia/Shanghai)检查最新 DSH、升级 peer 范围并修复兼容性 bug;任务 id 与提示词见 [docs/automation-task.md](docs/automation-task.md)。
203
+
204
+ ### Compatibility
205
+
206
+ - 目标 DSH `0.2.1-rc.2`(desktop profile,Web GUI)。peer 范围 `^0.2.0-rc.2 || ^0.2.1-rc.2`。
207
+ - 不支持 DSH 0.1.x:0.1 的插件自行注册设置命名空间,与本插件的条目 id 命名空间模型不同。
208
+
209
+ ### Notes
210
+
211
+ - 主题状态仍由官方 `ui-theme` 插件持有;本插件按计划调用 `setTheme`,不复制或覆盖 `ui-theme` 的持久化逻辑。
212
+ - profile 条目 id 必须为 `mcviseron`(设置命名空间 = 条目 id)。
@@ -0,0 +1,60 @@
1
+ # Contributing
2
+
3
+ ## 开发环境
4
+
5
+ - Node.js `^22.19.0 || >=24`
6
+ - pnpm `10.6.3`(仓库声明 `packageManager`)
7
+
8
+ ```bash
9
+ pnpm install
10
+ pnpm check
11
+ ```
12
+
13
+ `pnpm check` 依次执行 `tsc --noEmit`、全部 `node --experimental-strip-types test/*.test.ts`(71 项)与 `node build.mjs`。
14
+
15
+ ## 代码约定
16
+
17
+ - **一个组件 = 一个 bundle 条目**:`src/<component>/index.ts` 导出该条目自己的 `Config` 与 `apply(ctx, config)`,并作为一个子路径导出写进 `package.json` 与 `cordis.patch.yml`;DSH 插件清单按 loader 条目逐条渲染。
18
+ - 组件实现放在 `src/components/<component>/`,条目文件只做 Config 与装配;入口 `apply()` 必须先用 `toPlain()` 展开 DSH 0.2 的 volatile 配置引用。
19
+ - 每个条目的设置命名空间 = 条目 id(例如 `mcviseron-appearance`)。浏览器侧需要读写时,只暴露自己的条目命名空间,并加 loopback 信任栅栏。
20
+ - Host 与浏览器共用 `src/` 下的纯逻辑(`schedule.ts`、`api.ts`、`namespace.ts`),不把 DOM 或 cordis 服务引入纯逻辑,保证可单测。
21
+ - 组件的宿主接缝全部**特性探测**:服务缺失、字段缺失、老会话格式都必须降级为 no-op 或原样放行,绝不能让插件加载失败或阻塞审批。
22
+ - 新增第三方依赖前先确认能否用现有 DSH 服务或 Web API 完成(YAGNI)。
23
+
24
+ ## 新增一个组件
25
+
26
+ 1. 新建 `src/components/<id>/index.ts`(纯实现)与 `src/<id>/index.ts`(Config + `apply`)。
27
+ 2. 在 `package.json` 的 `exports` 增加 `"./<id>": "./lib/<id>.js"`,在 `build.mjs` 的 `hostEntries` 增加构建项。
28
+ 3. 在 `cordis.patch.yml` 增加一条 `- id: mcviseron-<id> / name: dsh-mcviseron-plugin/<id>`。
29
+ 4. 如果组件需要浏览器 UI:在 `src/client/` 实现,并在 `settings.general.item` 注册;如需读写配置,复用 `src/routes.ts` 的桥并加上条目命名空间。
30
+ 5. 增加行为测试与真实 Cordis 上下文测试;在 `test/plugin.test.ts` 加载新条目验证组合行为。
31
+ 6. 更新 README(组件表、配置表)、CHANGELOG 与 `docs/automation-task.md`。
32
+
33
+ ## 提交
34
+
35
+ - 使用 Conventional Commits:`feat:`、`fix:`、`docs:`、`chore:`、`refactor:`、`test:`。
36
+ - 每个发布版本更新 `CHANGELOG.md`(Keep a Changelog 格式),并同步 `package.json` 版本号。
37
+ - `lib/` 是构建产物,不入库。
38
+
39
+ ## DSH 版本升级流程
40
+
41
+ 1. 安装目标 DSH 版本对应的 `@deepseek-ai/*` 开发依赖(`pnpm add -D @deepseek-ai/dsh-client-connection@<ver> ...`,仅类型需要)。
42
+ 2. `pnpm check`;若接口变化,逐条目修复:
43
+ - `mcviseron-appearance`:`ctx.settings.describe/mutate/configure`、`settings.general.item` 插槽、`ctx.theme.setTheme/getTheme`;
44
+ - `mcviseron-auto-review-fix`:`permissionPresets.set`、`approval.request`、`displayReason`、`llm.stream`;
45
+ - `mcviseron-task-guard`:`tools/pre-execute` / `post-execute` / `agent/pre-step` / `session/event`、session format source kind。
46
+ 3. 在 `CHANGELOG.md` 的 `Compatibility` 段落记录验证过的版本与 peer 范围。
47
+ 4. 手动验证:插件管理器显示 3 个组件;外观开关与时段、跨午夜窗口、刷新后配置仍在;触发一次 Auto review 被拒看审批卡片译文;跑一个多阶段任务看 todo notice。
48
+
49
+ ## Profile 健康检查
50
+
51
+ - 本地安装/更新插件优先用 DSH 插件管理器。
52
+ - 在 `~/.dsh/profiles/<profile>` 里手动执行 `pnpm install` 后,务必跑一次 `node scripts/repair-profile.mjs`:pnpm 在 Windows 上会把跨盘符的 `link:D:/...` 依赖写成坏符号链接,并可能让插件管理器把这些条目从 `dsh.profile.bundles` 中移除。
53
+ - 修复脚本是幂等的,可随时运行确认 `link:` 依赖与 bundles 一致。
54
+
55
+ ## 发布
56
+
57
+ 1. `pnpm check` 全绿。
58
+ 2. 更新 `package.json` 版本与 `CHANGELOG.md`。
59
+ 3. `git tag vX.Y.Z && git push origin main --tags`。
60
+ 4. GitHub Release 附带 `CHANGELOG` 对应段落(可选:`pnpm publish`)。
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.en.md ADDED
@@ -0,0 +1,146 @@
1
+ # dsh-mcviseron-plugin
2
+
3
+ English | [中文](README.md)
4
+
5
+ MCviseron's **master plugin for DeepSeek Harness (DSH)**: one npm package and one `mcviseron` profile entry hosting four components. DSH `client-modules` only composes a browser half for a Loader row whose name exactly equals the package name, so the master entry must be `dsh-mcviseron-plugin`; components run as sub-plugins and own settings sub-pages. The former `dsh-auto-review-restart-fix` and `dsh-task-guard` are merged here and will be deprecated.
6
+
7
+ ## Components
8
+
9
+ | Component | Mounted at | What it does |
10
+ | --- | --- | --- |
11
+ | **Appearance · light/dark by time** | `mcviseron` top-level fields | Adds a settings row below DSH's Appearance row and switches the palette from the local wall clock |
12
+ | **Auto-review hardening** | `mcviseron.autoReviewFix` | Stops the whole-Host shutdown from persisting Full access over an Auto session; appends a Chinese translation to the manual-approval prompt |
13
+ | **Todo plan guard** | `mcviseron.taskGuard` | Advisory notices (optional hard stop) when multi-stage work stops updating its todo plan |
14
+ | **Restart DeepSeek Harness** | `mcviseron.restart` | Button in Settings → MCviseron plugin that closes and relaunches the desktop application |
15
+
16
+ > 0.6.1 returns to a **single** `mcviseron` entry: DSH `client-modules` only composes a browser half for an exact package-name Loader row, and subpath rows silently dropped the whole client plugin. Components still run as sub-plugins and expose settings sub-pages.
17
+
18
+ ### 1. Appearance · light/dark by time
19
+
20
+ - Default: **08:00 (inclusive) – 23:00 (exclusive) is light**, the rest is dark.
21
+ - Editable `HH:MM` window; `start > end` wraps midnight, `start === end` means light all day.
22
+ - Local wall clock; re-calibrates within 20 s after a sleeping tab or a clock jump.
23
+ - Applied on enabling, on editing the window, and at each boundary; a manual pick in between stays until the next boundary.
24
+
25
+ ### 2. Auto-review hardening
26
+
27
+ - Drops `permissionPresets.set` writes while the root Cordis fiber is not `ACTIVE`, so a whole-Host shutdown no longer migrates Auto sessions to Full access.
28
+ - Appends a `【审查理由 · 中文翻译】` block to the localized `displayReason` only; `reason` and `displayReason.en` stay byte-identical.
29
+ - Translation uses the session's provider/model (or a pinned pair), caches per source string (256 entries), times out after 6 s, and passes the approval through unchanged on any failure.
30
+ - A reviewer note that is already Chinese (or contains any CJK text) is never translated again; the approval prompt stays as-is.
31
+
32
+ ### 3. Todo plan guard
33
+
34
+ - A `todo_write` that leaves `pending` work with no `in_progress` task gets an advisory notice (never a tool error by default).
35
+ - After N successful tool calls without a todo update, a stale-plan notice follows (default 5, then every 4).
36
+ - Delivered through the official `tools/post-execute` `additionalContexts`; no system-prompt section, no user-prompt injection.
37
+ - Optional strict modes: `rejectMissingActive`, `blockAfterCalls`.
38
+ - Source kind follows the session format: v4 uses `plugin:task-guard`, v3 uses `plugin` + `plugin: 'task-guard'`.
39
+ - **Step-intent detection** (`detectStepIntent`): watches the official `agent/assistant-stream` text/reasoning deltas for phrases such as "Now I will …" / "接下来我会 …" and matches them against pending todos. A match adds one targeted, advisory notice per step (with a ready-to-send `todo_write` JSON); a miss, a missing stream, or malformed data is silently skipped and never blocks the task.
40
+ - **Chinese todo display** (`translateTodoContent`): English todo titles in notices are batch-translated into "中文(English)" through the host `llm` service (cached per title, 3 s default timeout, original text on failure). Display only — the model's stored todo list is never rewritten.
41
+
42
+ ### 4. Restart DeepSeek Harness
43
+
44
+ - A "Settings → MCviseron plugin → Restart" tab asks for confirmation and restarts the desktop app.
45
+ - A detached PowerShell helper closes the Electron main process; the Host performs its normal graceful shutdown when its IPC channel disconnects; the helper waits for both processes, clears `ELECTRON_RUN_AS_NODE`, and starts the application again.
46
+ - Running tasks are interrupted (same warning as the tray Quit); plugins, settings, and session records are not modified.
47
+ - Desktop-only: under `dsh web` the status route reports unavailable and the row hides.
48
+ - **Why not a tray item**: DSH builds its tray menu inside the Electron main process (`DesktopTray` in `lib/main.js`); plugins run in the Host child process and DSH exposes no tray extension point. The Settings row is the supported equivalent.
49
+
50
+ ## Settings page
51
+
52
+ Settings gains a first-level **MCviseron plugin** section (`settings.section`, id `mcviseron`). Components own a tab there when they have a settings surface:
53
+
54
+ - **Restart**: restart DeepSeek Harness (this component's settings).
55
+ - **Components**: list the four components and their configuration surfaces.
56
+
57
+ The Appearance component is intentionally **not** here — its row stays under General → Appearance. Auto review and Todo guard have editable sub-pages; the Components tab is an overview.
58
+
59
+ ## Install
60
+
61
+ ```bash
62
+ # from the profile directory (e.g. ~/.dsh/profiles/desktop)
63
+ pnpm add link:D:/Program/DSH-Plugin-Class/dsh-mcviseron-plugin
64
+ ```
65
+
66
+ Add `dsh-mcviseron-plugin` to `dsh.profile.bundles` and remove `dsh-auto-review-restart-fix` / `dsh-task-guard`. Restart DSH; the bundled `cordis.patch.yml` inserts one `mcviseron` master entry.
67
+
68
+ ## Configuration
69
+
70
+ ```yaml
71
+ - id: mcviseron
72
+ name: dsh-mcviseron-plugin
73
+ config:
74
+ enabled: true
75
+ lightStart: "08:00"
76
+ lightEnd: "23:00"
77
+ autoReviewFix:
78
+ keepPresetGuard: true
79
+ translateApprovalReason: true
80
+ translateTimeoutMs: 6000
81
+ translateMaxChars: 4000
82
+ translateProvider: ""
83
+ translateModel: ""
84
+ taskGuard:
85
+ enabled: true
86
+ locale: zh
87
+ staleAfterCalls: 5
88
+ repeatEveryCalls: 4
89
+ blockAfterCalls: 0
90
+ rejectMissingActive: false
91
+ sourceKind: auto
92
+ maxListItems: 6
93
+ restart:
94
+ enabled: true
95
+ appPath: ""
96
+ ```
97
+
98
+ Defaults: appearance off / `08:00–23:00`; auto-review both guards on, 6 s, 4000 chars; task-guard on, `zh`, stale at 5 / repeat 4, no blocking, step-intent detection and todo translation on (3 s), excludes `todo_write` and `ask_user_question`.
99
+
100
+ ## How it works
101
+
102
+ - `cordis.patch.yml` inserts one `mcviseron` master entry (`name: dsh-mcviseron-plugin`).
103
+ - `src/index.ts` mounts the four components with `ctx.plugin`; each keeps its own `inject` and implementation.
104
+ - `src/appearance` owns the two loopback routes (`/api/dsh-mcviseron/settings/describe|mutate`) the browser uses; the browser half lives in `src/client/` and registers the settings section and sub-pages.
105
+ - The settings bridge accepts appearance top-level fields and nested `autoReviewFix.*` / `taskGuard.*` / `restart.*` paths.
106
+ - The master entry and components unwrap DSH 0.2 volatile config references before use.
107
+
108
+ ## Compatibility
109
+
110
+ | DSH version | Status |
111
+ | --- | --- |
112
+ | `0.2.1-rc.2` | ✅ verified (desktop profile; 75 tests + real Cordis contexts) |
113
+ | `0.2.0-rc.x` | ✅ covered by the peer range |
114
+ | `0.1.x` | ❌ unsupported (different settings-namespace model) |
115
+
116
+ ## Migration
117
+
118
+ See [docs/migration-from-standalone.md](docs/migration-from-standalone.md). The old repositories are deprecated by the maintainer; all functionality continues here.
119
+
120
+ ## Development
121
+
122
+ ```bash
123
+ pnpm install
124
+ pnpm check
125
+ ```
126
+
127
+ ## Troubleshooting
128
+
129
+ ### After running `pnpm install` in the profile, every local plugin shows "unavailable"
130
+
131
+ Cause: cross-drive `link:D:/...` dependencies are written by pnpm on Windows as broken relative symlinks (`<profile>\D:\...`). DSH cannot resolve them, and the plugin manager may also drop those entries from `dsh.profile.bundles`.
132
+
133
+ Fix:
134
+
135
+ ```bash
136
+ node scripts/repair-profile.mjs # default: ~/.dsh/profiles/desktop
137
+ node scripts/repair-profile.mjs <profile> # another profile
138
+ ```
139
+
140
+ The script recreates every `link:` dependency as an absolute junction and restores the missing `dsh.profile.bundles` entries; restart DSH afterwards.
141
+
142
+ Prevention: prefer the DSH plugin manager for local plugins. If you must run `pnpm install` in the profile, run `pnpm repair-profile` right after it and restart.
143
+
144
+ ## License
145
+
146
+ [Apache-2.0](LICENSE)