dsh-plugin-tool-management 0.8.5 → 0.9.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 (59) hide show
  1. package/CHANGELOG.md +275 -206
  2. package/README.md +71 -69
  3. package/README_EN.md +65 -65
  4. package/docs/images/1-EN.png +0 -0
  5. package/docs/images/1.png +0 -0
  6. package/docs/images/2-EN.png +0 -0
  7. package/docs/images/2.png +0 -0
  8. package/docs/images/3-EN.png +0 -0
  9. package/docs/images/3.png +0 -0
  10. package/docs/images/4-EN.png +0 -0
  11. package/docs/images/4.png +0 -0
  12. package/docs/images/5-EN.png +0 -0
  13. package/docs/images/5.png +0 -0
  14. package/docs/images/6-EN.png +0 -0
  15. package/docs/images/6.png +0 -0
  16. package/docs/images/7-EN.png +0 -0
  17. package/docs/images/7.png +0 -0
  18. package/docs/images/8-EN.png +0 -0
  19. package/docs/images/8.png +0 -0
  20. package/docs/update.md +132 -86
  21. package/lib/agents-md/preset-id.js +1 -1
  22. package/lib/agents-md/service.js +46 -9
  23. package/lib/approval-policy.js +1 -1
  24. package/lib/client.js +867 -146
  25. package/lib/compat/preset-reach.js +155 -93
  26. package/lib/context-inject.js +401 -0
  27. package/lib/hub.js +155 -13
  28. package/lib/imports/upload.js +34 -14
  29. package/lib/index.js +1072 -243
  30. package/lib/mcp/state-section.js +46 -15
  31. package/lib/rules/archive-engine.js +158 -64
  32. package/lib/rules/archive.js +41 -1
  33. package/lib/rules/service.js +424 -162
  34. package/lib/scene-prompt-sync.js +93 -12
  35. package/lib/skills/catalog.js +125 -0
  36. package/lib/skills/core.js +6 -4
  37. package/lib/skills/service.js +56 -2
  38. package/lib/subagents/catalog.js +15 -6
  39. package/lib/subagents/service.js +25 -12
  40. package/lib/subagents/tools.js +18 -13
  41. package/package.json +11 -6
  42. package/screenshots.json +8 -8
  43. package/docs/images/1/345/234/272/346/231/257.png +0 -0
  44. package/docs/images/1/345/234/272/346/231/257_en.png +0 -0
  45. package/docs/images/2MCP.png +0 -0
  46. package/docs/images/2MCP_en.png +0 -0
  47. package/docs/images/3/346/212/200/350/203/275.png +0 -0
  48. package/docs/images/3/346/212/200/350/203/275_en.png +0 -0
  49. package/docs/images/4/345/255/220/346/231/272/350/203/275/344/275/223.png +0 -0
  50. package/docs/images/4/345/255/220/346/231/272/350/203/275/344/275/223_en.png +0 -0
  51. package/docs/images/5/346/217/220/347/244/272/350/257/215.png +0 -0
  52. package/docs/images/5/346/217/220/347/244/272/350/257/215_en.png +0 -0
  53. package/docs/images/6/350/256/260/345/277/206.png +0 -0
  54. package/docs/images/6/350/256/260/345/277/206_en.png +0 -0
  55. package/docs/images/7/344/274/232/350/257/235.png +0 -0
  56. package/docs/images/7/344/274/232/350/257/235_en.png +0 -0
  57. package/docs/images/8/345/205/274/345/256/271.png +0 -0
  58. package/docs/images/8/345/205/274/345/256/271_en.png +0 -0
  59. package/lib/prompt-sections.js +0 -148
package/README.md CHANGED
@@ -24,40 +24,35 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
24
24
 
25
25
  ## 截图
26
26
 
27
- | | |
28
- |:---:|:---:|
29
- | ![场景](docs/images/1场景.png) | ![MCP](docs/images/2MCP.png) |
30
- | **场景** | **MCP** |
31
- | ![技能](docs/images/3技能.png) | ![子智能体](docs/images/4子智能体.png) |
32
- | **技能** | **子智能体** |
33
- | ![提示词](docs/images/5提示词.png) | ![记忆](docs/images/6记忆.png) |
34
- | **提示词** | **记忆** |
35
- | ![会话](docs/images/7会话.png) | ![兼容](docs/images/8兼容.png) |
36
- | **会话** | **兼容** |
27
+ | | |
28
+ |:----------------------------:|:------------------------------:|
29
+ | ![场景](docs/images/1.png) | ![MCP](docs/images/2.png) |
30
+ | **场景** | **MCP** |
31
+ | ![技能](docs/images/3.png) | ![子智能体](docs/images/4.png) |
32
+ | **技能** | **子智能体** |
33
+ | ![提示词](docs/images/5.png) | ![记忆](docs/images/6.png) |
34
+ | **提示词** | **记忆** |
35
+ | ![会话](docs/images/7.png) | ![兼容](docs/images/8.png) |
36
+ | **会话** | **兼容** |
37
37
 
38
38
  ## 核心亮点
39
39
 
40
- | 能力 | 说明 |
41
- |---|---|
42
- | 场景记忆 | 启用场景里的 `.md` 正文**自动进系统提示词**,下一个请求即生效 |
43
- | 场景档案 | 每个场景自由搭配 **MCP 工具集 / 技能集 / 子智能体 / 记忆**;打开场景即应用,关闭按快照恢复 |
44
- | 场景提示词 | 场景绑一份提示词预设,切换场景直接改写 `~/.dsh/AGENTS.md`(关掉自动恢复) |
45
- | 场景锁定 | 锁住一个场景 = **五个管理域整体只读**(勾没勾的都不能动);未启动不能上锁,锁定中关不掉,先解锁再改 |
46
- | MCP 工具级开关 | 单台服务器里**单个工具**可独立启停:模型看不见也调不到 |
47
- | 重启语义 | 重启只重连,**不改变启停状态** |
48
- | 密钥安全 | 密钥默认打码;「显示密钥」与导出**必须带令牌**——没配 `token` 就不给明文 |
49
- | 技能来源 | 接入 `~/.agents` / `~/.codex` / `~/.claude` 与自定义目录;默认来源必须读取但技能可删 |
50
- | 回收站 | 人设 / 场景 / 提示词 / 记忆 / 技能删除都进回收站,可恢复 |
51
- | AGENTS.md 预设 | 多套全局基线,一键应用,保留 5 代备份 |
52
- | 归档会话 | 按项目分组、批量恢复 / 删除、保留期清理;工作区登记被删后可重建 |
53
- | 对话导入导出 | 接管 Claude Code / Cursor / Codex / 任意文本;导出 Markdown / JSONL |
54
- | 导入导出成对 | 技能 / 子智能体 / 提示词 / 记忆都有导出:勾选条目 → 打包 zip 到指定目录(只读源文件) |
55
- | 子智能体 | 一个文件一个人设,**启停开关**决定是否注入上下文;即用即弃不进 History,自动继承场景记忆 |
56
- | 上下文可见性 | 人设目录与「当前可用的 MCP server + 你的备注」进入系统提示词,模型自己知道有什么可用 |
57
- | 前缀缓存友好 | 注入段只由「启用场景 + 文件内容」决定,逐字节稳定 |
58
- | 兼容体检 | 「兼容」页一屏看清宿主能力、每个动作走原生还是适配、哪些降级 |
59
- | 模型工具 | **14 个**(`skill_mcp_manager_*` / `skill_manager_*` / `agentsmd_*` / `rule_manager_*` / `subagent_*`) |
60
- | 界面 | 自有设计系统,**八栏**,中英双语、跟随宿主语言 |
40
+ 一句话:**把「工作 / 写作 / 编程」各配成一套场景,点一下整套切换;插件管的东西,模型都看得见。**
41
+
42
+ | 亮点 | 说明 |
43
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
44
+ | 一键换场景 | 每个场景各配一套:用哪些 MCP 服务器、哪些技能、哪些人设、哪些记忆;点一下整套切换,关掉自动还原 |
45
+ | 记忆自动送到模型眼前 | 每个场景下写几段 `.md` 就是它的资料库,正文自动进上下文,不用每次复制粘贴 |
46
+ | 给 MCP 服务器写备注 | 像「A 不可用时改用 B 兜底」这种话写进备注,模型看得到,会照做 |
47
+ | 单个工具也能关 | 一台服务器里只停掉某个工具,模型看不见也调不到;「重启」只重连,不会偷偷改变开关 |
48
+ | 技能状况一眼看穿 | 哪些在生效、哪些被同名技能覆盖、哪一份是首选,都标得清清楚楚 |
49
+ | 子智能体 = 一个文件一个角色 | 写一份角色说明就能派活;跑完只回结果、不占你的会话记录;哪些角色能用还能按场景定 |
50
+ | 提示词备好几套 | AGENTS.md 可以存多份(简洁模式 / 教学口吻……),一键切换;场景可以各自绑一份 |
51
+ | 会话不再丢 | 归档按项目分组、能搜、能批量恢复;Claude Code / Cursor / Codex 的聊天记录都能导进来 |
52
+ | 模型一定看得见 | 插件管的内容(记忆 / MCP / 技能 / 子智能体 / 提示词)会主动告诉模型,每个域各发一条、内容没变不重复;极简模式下默认不注入(跟随预设),可在「兼容」页逐项打开 |
53
+ | 锁住就不怕手滑 | 场景可以上锁:五个域整体只读,先解锁才能改 |
54
+ | 删了能找回,配好能带走 | 删除都进回收站,随时恢复;技能 / 记忆 / 人设 / 提示词都能勾选打包成 zip,也能再导回来 |
55
+ | 安全、不添乱 | 密钥默认打码、看明文要令牌;只写自己的文件,技能源文件一个不动,升级重启配置都在 |
61
56
 
62
57
  ## 快速开始
63
58
 
@@ -78,7 +73,7 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
78
73
  装完提醒我硬刷新浏览器。
79
74
  ```
80
75
 
81
- 模型可用 14 个工具管理上述功能(见亮点表);脚本走 `POST /dsh-plugin-tool-management/api`(`{op, args}` 协议)。
76
+ 模型可用 14 个工具管理上述功能(`mcp_manager_*` / `skill_manager_*` / `prompt_manager_*` / `memory_manager_*` / `subagent_manager_*`);脚本走 `POST /dsh-plugin-tool-management/api`(`{op, args}` 协议)。
82
77
 
83
78
  ---
84
79
 
@@ -86,10 +81,10 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
86
81
 
87
82
  ### 场景与记忆
88
83
 
89
- - **场景 = 分组,记忆 = `.md` 文件**。`memories/<场景>/<名>.md`,整篇正文自动进系统提示词,文件名支持中文。
84
+ - **场景 = 分组,记忆 = `.md` 文件**。`memories/<场景>/<名>.md`,整篇正文自动注入上下文,文件名支持中文。
90
85
  - **单选启用**:同时只启用一个场景(其余置灰),关掉全部 = 只注入「全局」与 `_shared`。新场景默认不启动。
91
- - **场景绑提示词**:切换场景直接改写 `~/.dsh/AGENTS.md`(覆盖前 5 代备份,关掉自动恢复基线)。
92
- - **场景档案**:每个场景搭配 MCP 工具集 / 技能集 / 子智能体 / 记忆(任意组合);打开场景即应用并收窄注入,关闭按快照原文恢复(开关是唯一入口)。
86
+ - **场景绑提示词**:切换场景直接改写 `~/.dsh/AGENTS.md`(覆盖前 5 代备份,关掉自动恢复基线);预设挂不到官方 AGENTS.md 通道时(极简),改为把这份正文直接注入上下文。
87
+ - **场景档案**:每个场景搭配 MCP 工具集 / 技能集 / 子智能体 / 记忆(任意组合);打开场景即应用并收窄注入,关闭按快照原文恢复(开关是唯一入口)。勾选集语义:**勾的启用、没勾的停用,整段没建 = 一个都没勾 = 该域全部停用**(所以「没配 MCP 工具集」的场景进去就是全部 MCP 停用,退出再开回来)。**场景内这四个域(含提示词)的开关照常可用**——这里的改动会同步写进该场景的档案(当下生效、下次进这个场景照旧生效),只有**锁定**才冻结;记忆域的开关本来就是单一真相源,不经过档案。
93
88
  - **导入**:`.md` / `.zip`(目录名 = 场景,bundle 带附件),同名跳过绝不覆盖,超限逐条回报。
94
89
  - **导出**:勾选记忆打包成 zip,保留「场景/名称」层级;bundle 型连目录里的附件一起打进去。只读源文件。
95
90
  - **注入预算**:默认 64 KiB,放不下的跳过并列出清单。删除进回收站。
@@ -100,30 +95,36 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
100
95
 
101
96
  - **一个文件一个人设**:`agents/<人设>.md`,frontmatter 全可选。
102
97
  - **工具限制按 Agent 预设**:每个预设一份白/黑名单(互相排斥),运行期按当前预设生效——堵掉旧「全体并集」名单换预设后子代理起不来的坑。
103
- - **即用即弃**:`subagent_run` 带人设运行、只回传结果、不进 History,自动继承场景记忆。场景可绑定可用人设。
104
- - **启停开关**:停用的人设不注入上下文、模型不可见(文件不动);新建 / 导入 / 恢复自动启用。启动场景时档案勾选的人设自动启用,退出按快照精确停回。
105
- - **人设目录进系统提示词**:只列名字 + 描述,模型知道有哪些人设可委派;人设名可改,场景绑定自动跟着改。
98
+ - **即用即弃**:`subagent_manager_run` 带人设运行、只回传结果、不进 History,自动继承场景记忆。场景可绑定可用人设。
99
+ - **启停开关**:停用的人设不注入上下文、模型不可见(文件不动);新建 / 导入 / 恢复自动启用。**进场景按档案勾选集全量对齐**(勾了的开、没勾的关,整段没建 = 全关),退出按进场景前的开关精确还原;场景内这个开关照常可用,改动会同步写进该场景的档案(只有**锁定**才冻结);退出场景时回到进场景前的状态。
100
+ - **人设目录自动注入**:只列名字 + 描述,模型知道有哪些人设可委派;人设名可改,场景绑定自动跟着改。
106
101
 
107
102
  ### MCP 服务
108
103
 
109
104
  - **增删改查 + 即改即生效**:写入 `cordis.patch.yml`,HMR 自动生效。
110
105
  - **工具级开关**:单个工具可独立停用(模型看不见也调不到),整台支持批量。
106
+ - **停着也能看清单**:服务器没在跑时仍显示上次见过的工具名与描述(标「上次运行时」);从没跑过的可以一键「启动服务器读取工具」。
111
107
  - **密钥打码**:默认 `••••••`,「显示密钥」要令牌。
112
108
  - **迁移与备份**:跨项目级/全局迁移失败自动回滚;JSON 导出导入。
113
- - **状态与备注进系统提示词**:只列当前真正可用的 server,你的备注作为决策提示带给模型;级别分「全局 / 应用级」,新增默认全局。
109
+ - **状态与备注自动注入**:只列当前真正可用的 server,你的备注作为决策提示带给模型;级别分「全局 / 应用级」,新增默认全局。注:极简这类压制型预设默认不注入(模型可用 `mcp_manager_list` 读取服务器名、启停、工具数与备注)——想让它也注入,到「兼容」页的「注入」块打开开关。
114
110
 
115
111
  ### 技能
116
112
 
117
113
  - **来源一览**:项目级 / DSH / Agents / Codex / Claude / 自定义目录,按来源分组。
118
114
  - **两组权限相反**:默认来源(DSH / 导入技能)必须读取但技能可删;外部目录可停用/移除但技能只读。
119
115
  - **移除 ≠ 停用**:移除 = 连目录都不扫(文件零改动,可恢复);停用 = 仍列出但不可调用。
120
- - **同名自选 / 自定义目录 / ZIP 导入导出 / 回收站**。
116
+ - **同名技能一眼看出谁在生效**:真实生效的那份标「首选」,被同名覆盖的标出来源;启用被覆盖的副本会明说「这样不会生效」。
117
+ - **自定义目录 / ZIP 导入导出 / 回收站**。
118
+ - **目录可注入**:预设没挂官方技能目录行(如极简)时,由本插件的注入域按「兼容」页的开关兜底送达(名字 + 简介;正文照旧读文件)。
121
119
 
122
120
  ### 提示词预设
123
121
 
124
122
  - 多套 `~/.dsh/AGENTS.md` 基线,一键应用(宿主每轮重读该文件,下一轮对话生效),保留 5 代备份。
125
- - **描述**:每条预设可写一句「这份是干什么的」,只显示在插件界面里;它存在同目录的 `meta.json`,不进 AGENTS.md,也就不会被注入提示词。
126
- - 新建即可写正文,编辑可改 id(= 目录改名,场景绑定自动跟着改)。正在生效的不能删;删除进回收站。
123
+ - **记得「最近一次应用的是哪份」**:就算你手改过 `AGENTS.md`,模型问「现在用的哪份预设」也答得出来源(会注明「此后文件有变」)。
124
+ - **描述**:每条预设可写一句「这份是干什么的」,只显示在插件界面里;它存在同目录的 `meta.json`,不进 AGENTS.md,也就不会被注入上下文。
125
+ - 新建即可写正文,编辑可改 id(= 目录改名,场景绑定自动跟着改)。**被引用的不能删**(场景绑定 / `AGENTS.md` 当前内容 / 退出场景要恢复的那一份),删除进回收站。
126
+ - **正文可注入**:预设没挂官方 AGENTS.md 行(如极简)时,`~/.dsh/AGENTS.md` 的正文由本插件的注入域兜底(64 KiB 上限;可在「兼容」页关掉)。
127
+ - **场景接管期间「应用」只对场景绑定的那一份可用**(应用别的预设会绕过场景绑定,正是「显示 A、实际注入 B」的来源);要换提示词请到场景页改绑定,或先退出场景。
127
128
 
128
129
  ### 历史会话
129
130
 
@@ -136,33 +137,34 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
136
137
  插件运行期用宿主同一批 `@deepseek-ai/*` 库——必须是同一份物理模块,否则判断退化成猜。
137
138
 
138
139
  - **「兼容」页**:宿主版本、能力可用数、每个动作走原生/适配/不可用、降级项与原因。只读。
139
- - **命令行**:`node scripts/doctor.mjs`(体检)、`node scripts/host-deps.mjs --fix`(依赖对齐)。
140
- - `minimal` 预设下,场景记忆 / AGENTS.md / 技能目录不生效(该预设的设计意图),兼容页逐列标出。
140
+ - **命令行**:`node scripts/doctor.mjs`(体检)、`node scripts/host-deps.mjs --fix`(依赖对齐)、`npm run sync:profile`(把构建产物镜像到 profile 里那份本地安装 —— `file:` 装的是硬链接拷贝,构建新增的文件不会自动过去)。
141
+ - `minimal` 这类**压制型预设**(persona `complete` / 关闭运行时上下文)下,本插件的注入**默认停用**(跟随预设的设计意图),提示词与技能也因官方那两行没挂而缺席 —— 兼容页逐列标出,同一页的「注入」块可以按域强制打开。
141
142
 
142
143
  ---
143
144
 
144
145
  ## 数据落点
145
146
 
146
- | 内容 | 位置 |
147
- |---|---|
148
- | MCP 定义 | `cordis.patch.yml`(改前自动 `.bak`) |
149
- | 技能策略 / 自定义目录 | `~/.dsh/tool-management/state.json` |
150
- | 技能 / 记忆 / 人设 / 预设 | `~/.dsh/tool-management/{skills,memories,agents,agents-md}/` |
151
- | 子智能体启停 | `~/.dsh/tool-management/agents-index.json` |
152
- | 回收站 | `~/.dsh/tool-management/trash/` |
153
- | 归档账本 / 保留期 | `~/.dsh/tool-management/history-*.json` |
154
- | 记忆索引 / 场景 / 档案 | `~/.dsh/tool-management/rules-index.json` |
155
- | 页面设置 | `~/.dsh/dsh-plugin-tool-management-settings.json` |
156
- | 运行日志 | `~/.dsh/dsh-plugin-tool-management.log` |
147
+ | 内容 | 位置 |
148
+ | ------------------------------------------- | ------------------------------------------------------------------------- |
149
+ | MCP 定义 | `~/.dsh/cordis.patch.yml`(插件只写它;改前自动备份到 hub 的 `backups/`) |
150
+ | 技能策略 / 自定义目录 | `~/.dsh/tool-management/skills-state.json` |
151
+ | 技能 / 记忆 / 人设 / 预设 | `~/.dsh/tool-management/{skills,memories,subagents,prompts}/` |
152
+ | 子智能体启停 | `~/.dsh/tool-management/subagents-index.json` |
153
+ | 回收站 | `~/.dsh/tool-management/trash/{skills,subagents,prompts,scenes}-trash/` |
154
+ | 归档账本 / 保留期 | `~/.dsh/tool-management/history-*.json` |
155
+ | 记忆索引 / 场景 / 档案 | `~/.dsh/tool-management/memories-index.json` |
156
+ | MCP 侧车(停用表 / 已知工具 / 备注 / 设置) | `~/.dsh/tool-management/mcp-*.json` |
157
+ | 注入设置(五个域开关 / 压制型预设口径) | `~/.dsh/tool-management/inject-settings.json` |
158
+ | 运行日志 / patch 备份 | `~/.dsh/tool-management/tool-management.log` · `backups/` |
157
159
 
158
160
  **插件安装目录里不存用户数据**(`dsh plugin update` 会整体替换该目录)。
159
161
 
160
162
  ## 配置与安全
161
163
 
162
- | 字段 | 说明 |
163
- |---|---|
164
- | `token` | 访问令牌。设了之后**所有写操作 + 明文密钥**都要求 `x-dsh-token`;**不设时明文接口一律关闭**。也是 curl / 局域网的逃生门。 |
165
- | `maxBodyBytes` | 请求体上限,默认 88 MiB。 |
164
+ | 字段 | 说明 |
165
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------- |
166
+ | `token` | 访问令牌。设了之后**所有写操作 + 明文密钥**都要求 `x-dsh-token`;**不设时明文接口一律关闭**。也是 curl / 局域网的逃生门。 |
167
+ | `maxBodyBytes` | 请求体上限,默认 88 MiB。 |
166
168
 
167
169
  - **浏览器**:读写走 cookie,不需要 token;但**明文密钥**(显示密钥 / 导出)要令牌。
168
170
  - **curl / 脚本**:带 `x-dsh-token`,或带浏览器 cookie。
@@ -170,15 +172,15 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
170
172
 
171
173
  ## 常见问题
172
174
 
173
- | 现象 | 解决 |
174
- |---|---|
175
- | 装完没有页面 | 硬刷新;不行重启 DSH。 |
176
- | 重复 MCP 页签 | 删 `cordis.patch.yml` 里的旧 loader 行后重启。 |
177
- | 改坏配置 DSH 起不来 | 取最近的 `.bak-<时间戳>` 恢复。 |
178
- | 升级 DSH 后动作不可用 | 设置 → 工具 → **兼容** 看原因;`doctor.mjs` → `host-deps.mjs --fix`。 |
179
- | `approval=never` 还要确认吗 | 不弹卡,直接放行并记日志;想问回来切回「工作区内修改」。 |
180
- | `subagent_run` 报 spawn 不可用 | 宿主没注册 spawn provider;挂载 `@deepseek-ai/dsh-subagent-spawn-in-process` 后重启。 |
181
- | 场景绑了 A 人设,官方 `subagent` 还跑别的 | 两条通道:本插件只管 `subagent_run`;官方 `subagent` / `subagent_fork` 无确认门、不认人设。 |
175
+ | 现象 | 解决 |
176
+ | ----------------------------------------- | --------------------------------------------------------------------------------------------------- |
177
+ | 装完没有页面 | 硬刷新;不行重启 DSH。 |
178
+ | 重复 MCP 页签 | 删 `cordis.patch.yml` 里的旧 loader 行后重启。 |
179
+ | 改坏配置 DSH 起不来 | 取最近的 `.bak-<时间戳>` 恢复。 |
180
+ | 升级 DSH 后动作不可用 | 设置 → 工具 → **兼容** 看原因;`doctor.mjs` → `host-deps.mjs --fix`。 |
181
+ | `approval=never` 还要确认吗 | 不弹卡,直接放行并记日志;想问回来切回「工作区内修改」。 |
182
+ | `subagent_manager_run` 报 spawn 不可用 | 宿主没注册 spawn provider;挂载 `@deepseek-ai/dsh-subagent-spawn-in-process` 后重启。 |
183
+ | 场景绑了 A 人设,官方 `subagent` 还跑别的 | 两条通道:本插件只管 `subagent_manager_run`;官方 `subagent` / `subagent_fork` 无确认门、不认人设。 |
182
184
 
183
185
  ---
184
186
 
@@ -187,7 +189,7 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
187
189
  ```bash
188
190
  npm install
189
191
  npm run build # tsc + 同步客户端
190
- npm test # 构建 + i18n + 语义契约测试
192
+ npm test # 构建 + i18n + 冒烟测试(装配与渲染不抛错)
191
193
  npm run check:i18n # 词典自检
192
194
  npm run doctor # 宿主兼容体检
193
195
  ```
package/README_EN.md CHANGED
@@ -24,40 +24,35 @@ Hard-refresh the browser (Cmd/Ctrl+Shift-R) afterwards — a **Tools** panel in
24
24
 
25
25
  ## Screenshots
26
26
 
27
- | | |
28
- |:---:|:---:|
29
- | ![Scenes](docs/images/1场景_en.png) | ![MCP](docs/images/2MCP_en.png) |
30
- | **Scenes** | **MCP** |
31
- | ![Skills](docs/images/3技能_en.png) | ![Subagents](docs/images/4子智能体_en.png) |
32
- | **Skills** | **Subagents** |
33
- | ![Prompts](docs/images/5提示词_en.png) | ![Memories](docs/images/6记忆_en.png) |
34
- | **Prompts** | **Memories** |
35
- | ![Sessions](docs/images/7会话_en.png) | ![Host](docs/images/8兼容_en.png) |
36
- | **Sessions** | **Host** |
27
+ | | |
28
+ |:---------------------------------:|:----------------------------------:|
29
+ | ![Scenes](docs/images/1-EN.png) | ![MCP](docs/images/2-EN.png) |
30
+ | **Scenes** | **MCP** |
31
+ | ![Skills](docs/images/3-EN.png) | ![Subagents](docs/images/4-EN.png) |
32
+ | **Skills** | **Subagents** |
33
+ | ![Prompts](docs/images/5-EN.png) | ![Memories](docs/images/6-EN.png) |
34
+ | **Prompts** | **Memories** |
35
+ | ![Sessions](docs/images/7-EN.png) | ![Host](docs/images/8-EN.png) |
36
+ | **Sessions** | **Host** |
37
37
 
38
38
  ## Highlights
39
39
 
40
- | Capability | Description |
41
- |---|---|
42
- | Scene memory | `.md` bodies in an enabled scene are **injected into the system prompt**, effective on the next request |
43
- | Scene profile | Every scene freely combines **MCP tools / skills / subagents / memories**; opening a scene applies it, closing restores from the snapshot |
44
- | Scene prompt | A scene can bind a prompt preset; switching scenes rewrites `~/.dsh/AGENTS.md` (auto-restores on exit) |
45
- | Scene lock | Locking a scene freezes **all five domains read-only** (bound entries or not); a scene must be running to lock, and a locked scene can't be turned off — unlock first |
46
- | Per-tool switches | **Individual tools** inside one MCP server can be disabled: invisible to the model, blocked at call time |
47
- | Restart semantics | Restart only reconnects — it **never flips the enabled state** |
48
- | Secret safety | Secrets masked by default; "Reveal" & export **require a token** — no `token` configured means no plaintext |
49
- | Skill sources | Hooks up `~/.agents` / `~/.codex` / `~/.claude` & custom dirs; default sources must be read but skills can be deleted |
50
- | Recycle bin | Personas / scenes / prompts / memories / skills all go to recycle bin on delete, restorable |
51
- | AGENTS.md presets | Multiple global baselines, one-click apply, 5-generation backup |
52
- | Archived sessions | Grouped by project, batch restore / delete, retention cleanup; rebuildable after workspace deletion |
53
- | Transcript import/export | Take over Claude Code / Cursor / Codex / any text; export Markdown / JSONL |
54
- | Import pairs with export | Skills / subagents / prompts / memories all export too: pick items → zip into a directory you choose (read-only on sources) |
55
- | Subagents | One file per persona, with an **on/off toggle** deciding whether it is injected; run-and-discard, never enters History, inherits scene memories |
56
- | Context visibility | The persona catalog and "currently usable MCP servers + your notes" enter the system prompt, so the model knows what is available |
57
- | Prefix-cache friendly | Section text depends only on enabled scenes + file contents, byte-stable |
58
- | Compatibility check | The **Host** tab shows host capabilities, per-action routing, and degradations at a glance |
59
- | Model tools | **14** (`skill_mcp_manager_*` / `skill_manager_*` / `agentsmd_*` / `rule_manager_*` / `subagent_*`) |
60
- | UI | Custom design system, **eight tabs**, bilingual, follows host language |
40
+ In one line: **set up a scene for each kind of work — "day job / writing / coding" — and switch the whole stack with one click. Everything the plugin manages, the model can actually see.**
41
+
42
+ | Highlight | What it means |
43
+ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
44
+ | One-click scene switch | Each scene carries its own set: which MCP servers, which skills, which personas, which memories; flip it on and the whole stack follows, turn it off and everything comes back |
45
+ | Memories reach the model on their own | Write a few `.md` files under a scene and they become its knowledge base — injected automatically, no copy-pasting every session |
46
+ | Notes for MCP servers | Write "if A is down, fall back to B" as a note — the model sees it and acts on it |
47
+ | Disable a single tool | Keep a server but mute one tool: invisible and uncallable; "Restart" only reconnects and never flips switches |
48
+ | Skills at a glance | Which copy is in effect, which is shadowed by a same-name skill, which is preferred — all marked in the list |
49
+ | Subagent = one file, one role | Write a role file and delegate; only the result comes back and it never clutters your History; which roles are available can follow the scene |
50
+ | Several prompt presets | Keep multiple AGENTS.md baselines (terse mode, teaching tone, …), switch with one click; a scene can bind its own |
51
+ | Sessions no longer lost | Archive grouped by project, searchable, batch-restorable; import transcripts from Claude Code / Cursor / Codex |
52
+ | The model always sees it | Everything the plugin manages (memories / MCP / skills / subagents / prompts) is announced to the model — one message per domain, republished only on change; under Minimal nothing is injected by default (follows the preset), force any domain on in the Host tab |
53
+ | Lock it and relax | Lock a scene to make all five domains read-only; unlock first to change anything |
54
+ | Deleted is not gone | Deletes land in a recycle bin and can be restored; skills / memories / personas / presets zip out and back in |
55
+ | Safe by default | Secrets masked, plaintext needs a token; only the plugin's own files are written, skill sources stay untouched, and your config survives restarts and upgrades |
61
56
 
62
57
  ## Quick start
63
58
 
@@ -78,7 +73,7 @@ dsh plugin --profile web add dsh-plugin-tool-management@latest
78
73
  Then remind me to hard-refresh the browser.
79
74
  ```
80
75
 
81
- The model can manage everything above via 14 tools (see highlights); scripts use `POST /dsh-plugin-tool-management/api` (`{op, args}` protocol).
76
+ The model can manage everything above via 14 tools (`mcp_manager_*` / `skill_manager_*` / `prompt_manager_*` / `memory_manager_*` / `subagent_manager_*`); scripts use `POST /dsh-plugin-tool-management/api` (`{op, args}` protocol).
82
77
 
83
78
  ---
84
79
 
@@ -89,7 +84,7 @@ The model can manage everything above via 14 tools (see highlights); scripts use
89
84
  - **A scene = a group, a memory = a `.md` file**. `memories/<scene>/<name>.md`, the whole body is injected, file names can be non-ASCII.
90
85
  - **Single-choice toggle**: only one scene at a time (others greyed out); turning all off = only `global` and `_shared` inject. New scenes start off.
91
86
  - **Scene-bound prompt**: switching scenes rewrites `~/.dsh/AGENTS.md` (5-gen backup, auto-restore on exit).
92
- - **Scene profile**: every scene combines MCP tools / skills / subagents / memories (any mix); opening a scene applies and narrows injection, closing restores verbatim (the toggle is the only entry).
87
+ - **Scene profile**: every scene combines MCP tools / skills / subagents / memories (any mix); opening a scene applies and narrows injection, closing restores verbatim (the toggle is the only entry). Checked means on, unchecked means off, and **a missing section means nothing is checked — so that whole domain is off** (a scene with no MCP section therefore stops every MCP server, and exit starts them again). While a scene is active those switches (MCP, skills, subagents, prompts) still work — changes are written into that scene's profile too (they take effect immediately and are kept for the next visit); only locking freezes them. The memory domain has a single source of truth and never goes through the profile.
93
88
  - **Import**: `.md` / `.zip` (dir name = scene, bundles carry attachments), same names skipped never overwritten, over-limit items reported.
94
89
  - **Export**: pick memories and zip them, keeping the `scene/name` layout; bundle memories bring their attachments along. Sources are read-only.
95
90
  - **Injection budget**: default 64 KiB, oversized memories skipped with a list. Deletes go to recycle bin.
@@ -100,30 +95,34 @@ The model can manage everything above via 14 tools (see highlights); scripts use
100
95
 
101
96
  - **One file per persona**: `agents/<persona>.md`, frontmatter entirely optional.
102
97
  - **Tool limits per Agent preset**: each preset gets its own allow/deny list (mutually exclusive), effective at runtime by the current preset — fixes the old "union of all presets" list that broke subagents after a preset switch.
103
- - **Run and discard**: `subagent_run` runs with the persona, returns only the result, never enters History, inherits scene memories. Scenes can bind which personas are available.
104
- - **On/off toggles**: a disabled persona is not injected and invisible to the model (file untouched); newly created / imported / restored personas start enabled. Starting a scene auto-enables the personas its profile binds; exit restores precisely from the snapshot.
98
+ - **Run and discard**: `subagent_manager_run` runs with the persona, returns only the result, never enters History, inherits scene memories. Scenes can bind which personas are available.
99
+ - **On/off toggles**: a disabled persona is not injected and invisible to the model (file untouched); newly created / imported / restored personas start enabled. Entering a scene applies the profile's persona list exactly (checked on, everything else off; no section = all off) and exit restores the pre-scene switches. Inside a scene these toggles still work and are synced into the scene profile (only locking freezes them); leaving the scene restores the pre-scene state.
105
100
  - **Persona catalog enters the system prompt**: names + descriptions only, so the model knows what it can delegate to; personas are renameable, scene bindings follow.
106
101
 
107
102
  ### MCP servers
108
103
 
109
104
  - **CRUD + immediate effect**: writes to `cordis.patch.yml`, HMR picks it up.
110
105
  - **Per-tool switches**: disable individual tools (invisible to the model, blocked at call), whole-server batch.
106
+ - **Stopped servers still show their tools**: a server that is not running keeps the tool names and descriptions last seen (marked "as of last run"); one that has never run can be probed with "start server to read tools".
111
107
  - **Secret masking**: defaults to `••••••`, "Reveal" needs a token.
112
108
  - **Migrate & back up**: cross-project/global migration rolls back on failure; JSON export/import.
113
- - **Status & notes enter the system prompt**: only currently usable servers are listed, and your notes travel along as decision hints; levels are "global / app", new servers default to global.
109
+ - **Status & notes enter the system prompt**: only currently usable servers are listed, and your notes travel along as decision hints; levels are "global / app", new servers default to global. Note: a persona-complete preset such as minimal suppresses that section — there the model reads server names, enablement, tool counts and notes with `mcp_manager_list`.
114
110
 
115
111
  ### Skills
116
112
 
117
113
  - **Sources at a glance**: project / DSH / Agents / Codex / Claude / custom dirs, grouped by source.
118
114
  - **Opposite permissions**: default sources must be read but skills can be deleted; external dirs can be disabled/removed but skills are read-only.
119
115
  - **Remove ≠ disable**: remove = directory not scanned at all (files untouched, restorable); disable = still listed but not callable.
120
- - **Same-name picker / custom dirs / ZIP import & export / recycle bin**.
116
+ - **Same-name skills: see which copy is in effect**: the winning copy is marked "preferred", shadowed ones name the source that wins, and enabling a shadowed copy says so instead of pretending it worked.
117
+ - **Custom dirs / ZIP import & export / recycle bin**.
121
118
 
122
119
  ### Prompt presets
123
120
 
124
121
  - Multiple `~/.dsh/AGENTS.md` baselines, one-click apply (the host re-reads that file every turn, so it takes effect on the next turn), 5-gen backup.
122
+ - **Remembers the preset applied last**: even after you hand-edit `AGENTS.md`, the model can still answer "which preset is this from" (flagged "changed since").
125
123
  - **Description**: one line saying what a preset is for — shown in this panel only. It lives in a sibling `meta.json`, never in AGENTS.md, so it is never injected into prompts.
126
- - Create with body inline, edit can change id (= dir rename, scene bindings follow). Active preset can't be deleted; deletes go to recycle bin.
124
+ - Create with body inline, edit can change id (= dir rename, scene bindings follow). A referenced preset cannot be deleted (bound by a scene, currently in AGENTS.md, or the baseline to restore on scene exit); deletes go to recycle bin.
125
+ - **While a scene drives the baseline, Apply only works for that scene's bound preset** (applying another one would bypass the binding — that is exactly how "shows A, injects B" happened); rebind it on the Scenes page or exit the scene first.
127
126
 
128
127
  ### Archived sessions
129
128
 
@@ -136,33 +135,34 @@ The model can manage everything above via 14 tools (see highlights); scripts use
136
135
  The plugin uses the host's own `@deepseek-ai/*` libraries at runtime — they must be the same physical modules, or every "adapt to host" decision degrades into guesswork.
137
136
 
138
137
  - **Host tab**: host version, usable capability count, per-action routing (native/adapter/unavailable), degradations & reasons. Read-only.
139
- - **Command line**: `node scripts/doctor.mjs` (check), `node scripts/host-deps.mjs --fix` (align deps).
140
- - Under `minimal` preset, scene memory / AGENTS.md / skill directory don't take effect (by design); the Host tab marks this per column.
138
+ - **Command line**: `node scripts/doctor.mjs` (check), `node scripts/host-deps.mjs --fix` (align deps), `npm run sync:profile` (mirror the build into the profile's local install — a `file:` install is a hard-linked copy, so files ADDED by a build never show up there on their own).
139
+ - Under a **suppressing preset** such as `minimal` (persona `complete` / runtime context off) this plugin's injection is **off by default** (following the preset's intent), and the prompt and the skills are missing because their official rows are not mounted — the Host tab marks this per column, and its "Injection" block can force any domain back on.
141
140
 
142
141
  ---
143
142
 
144
143
  ## Where data lives
145
144
 
146
- | Content | Location |
147
- |---|---|
148
- | MCP definitions | `cordis.patch.yml` (auto `.bak` before rewrite) |
149
- | Skill policy / custom dirs | `~/.dsh/tool-management/state.json` |
150
- | Skills / memories / personas / presets | `~/.dsh/tool-management/{skills,memories,agents,agents-md}/` |
151
- | Subagent toggles | `~/.dsh/tool-management/agents-index.json` |
152
- | Recycle bin | `~/.dsh/tool-management/trash/` |
153
- | Archive ledger / retention | `~/.dsh/tool-management/history-*.json` |
154
- | Memory index / scenes / profiles | `~/.dsh/tool-management/rules-index.json` |
155
- | Page settings | `~/.dsh/dsh-plugin-tool-management-settings.json` |
156
- | Runtime log | `~/.dsh/dsh-plugin-tool-management.log` |
145
+ | Content | Location |
146
+ | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
147
+ | MCP definitions | `~/.dsh/cordis.patch.yml` (written by the plugin; pre-write copies land in the hub's `backups/`) |
148
+ | Skill policy / custom dirs | `~/.dsh/tool-management/skills-state.json` |
149
+ | Skills / memories / personas / presets | `~/.dsh/tool-management/{skills,memories,subagents,prompts}/` |
150
+ | Subagent toggles | `~/.dsh/tool-management/subagents-index.json` |
151
+ | Recycle bin | `~/.dsh/tool-management/trash/{skills,subagents,prompts,scenes}-trash/` |
152
+ | Archive ledger / retention | `~/.dsh/tool-management/history-*.json` |
153
+ | Memory index / scenes / profiles | `~/.dsh/tool-management/memories-index.json` |
154
+ | MCP sidecars (disabled tools / known tools / notes / settings) | `~/.dsh/tool-management/mcp-*.json` |
155
+ | Injection settings (five domain switches / suppressing-preset policy) | `~/.dsh/tool-management/inject-settings.json` |
156
+ | Runtime log / patch backups | `~/.dsh/tool-management/tool-management.log` · `backups/` |
157
157
 
158
158
  **No user data is stored inside the plugin's install directory** (`dsh plugin update` replaces it wholesale).
159
159
 
160
160
  ## Configuration & security
161
161
 
162
- | Field | Description |
163
- |---|---|
164
- | `token` | Access token. When set, **all writes + plaintext secrets** require `x-dsh-token`; **unset = plaintext endpoints closed**. Also the escape hatch for curl / LAN. |
165
- | `maxBodyBytes` | Request body cap, default 88 MiB. |
162
+ | Field | Description |
163
+ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
164
+ | `token` | Access token. When set, **all writes + plaintext secrets** require `x-dsh-token`; **unset = plaintext endpoints closed**. Also the escape hatch for curl / LAN. |
165
+ | `maxBodyBytes` | Request body cap, default 88 MiB. |
166
166
 
167
167
  - **Browser**: reads/writes via cookie, no token needed; but **plaintext secrets** (Reveal / export) need a token.
168
168
  - **curl / scripts**: send `x-dsh-token`, or carry the browser cookie.
@@ -170,15 +170,15 @@ The plugin uses the host's own `@deepseek-ai/*` libraries at runtime — they mu
170
170
 
171
171
  ## FAQ
172
172
 
173
- | Symptom | Fix |
174
- |---|---|
175
- | Pages missing after install | Hard refresh; restart DSH if that fails. |
176
- | Duplicate MCP tabs | Remove the stale loader row from `cordis.patch.yml`, restart. |
177
- | Broken config, DSH won't boot | Restore the newest `.bak-<timestamp>`. |
178
- | Action stopped after DSH upgrade | Settings → Tools → **Host** for the reason; `doctor.mjs` → `host-deps.mjs --fix`. |
179
- | Still asked to confirm in `approval=never`? | No card appears — straight through with a log line; switch back to "workspace write" to get asked again. |
180
- | `subagent_run` reports spawn unavailable | Host has no spawn provider; mount `@deepseek-ai/dsh-subagent-spawn-in-process` and restart. |
181
- | Scene binds persona A, but official `subagent` ran something else | Two channels: this plugin only governs `subagent_run`; official `subagent` / `subagent_fork` have no gate and don't know about personas. |
173
+ | Symptom | Fix |
174
+ | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
175
+ | Pages missing after install | Hard refresh; restart DSH if that fails. |
176
+ | Duplicate MCP tabs | Remove the stale loader row from `cordis.patch.yml`, restart. |
177
+ | Broken config, DSH won't boot | Restore the newest `.bak-<timestamp>`. |
178
+ | Action stopped after DSH upgrade | Settings → Tools → **Host** for the reason; `doctor.mjs` → `host-deps.mjs --fix`. |
179
+ | Still asked to confirm in `approval=never`? | No card appears — straight through with a log line; switch back to "workspace write" to get asked again. |
180
+ | `subagent_manager_run` reports spawn unavailable | Host has no spawn provider; mount `@deepseek-ai/dsh-subagent-spawn-in-process` and restart. |
181
+ | Scene binds persona A, but official `subagent` ran something else | Two channels: this plugin only governs `subagent_manager_run`; official `subagent` / `subagent_fork` have no gate and don't know about personas. |
182
182
 
183
183
  ---
184
184
 
@@ -187,7 +187,7 @@ The plugin uses the host's own `@deepseek-ai/*` libraries at runtime — they mu
187
187
  ```bash
188
188
  npm install
189
189
  npm run build # tsc + sync client
190
- npm test # build + i18n + semantic-contract tests
190
+ npm test # build + i18n + smoke tests (mount & render)
191
191
  npm run check:i18n # dictionary self-check
192
192
  npm run doctor # host compatibility check
193
193
  ```
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file