better-dsh 0.2.3-b → 0.2.3-d
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/docs/50_test-reports/upstream-dsh-0.1.5-rc.2-local-test-report.md +79 -0
- package/docs/upstream-dsh-0.1.5-rc.2-report.md +156 -0
- package/eval-description.md +33 -0
- package/lib/client/index.js +59 -50
- package/lib/index.d.ts +4 -21
- package/lib/index.js +37 -77
- package/lib/py-sdk-Chvy92MB.js +178 -0
- package/lib/py-sdk.d.ts +19 -2
- package/lib/py-sdk.js +2 -2
- package/package.json +3 -3
- package/control-prompt.md +0 -37
- package/docs/50_test-reports/v0.1.8d_artifacts/README.md +0 -138
- package/docs/50_test-reports/v0.1.8d_artifacts/code-mode-repl-only.observation.md +0 -74
- package/docs/50_test-reports/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.jsonl +0 -3890
- package/docs/50_test-reports/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.w-sample-0435.jsonl +0 -544
- package/docs/50_test-reports/v0.1.8d_artifacts/functions.json +0 -592
- package/docs/50_test-reports/v0.1.8d_artifacts/skills-catalog.snapshot.md +0 -30
- package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.output-schemas.json +0 -1236
- package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.python.txt +0 -592
- package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.typescript.txt +0 -516
- package/docs/50_test-reports/v0.1.8d_artifacts/wire-vs-transcription.diff.md +0 -54
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/Cargo.lock +0 -7
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/Cargo.toml +0 -6
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/src/bin/messy.rs +0 -8
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/src/main.rs +0 -4
- package/docs/50_test-reports/v0.2.0b_artifacts/hashline-probe.md +0 -5
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/Cargo.lock +0 -7
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/Cargo.toml +0 -7
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/build.rs +0 -4
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/src/main.rs +0 -13
- package/docs/60_exploration-and-research/01-cordis-runtime/bun-compile-cordis-runtime-bootstrap-research.md +0 -536
- package/docs/60_exploration-and-research/01-cordis-runtime/cordis-customization-and-override-mechanics.md +0 -418
- package/docs/60_exploration-and-research/01-cordis-runtime/cordis-engineering-feasibility.md +0 -155
- package/docs/60_exploration-and-research/01-cordis-runtime/cordis-research.md +0 -583
- package/docs/60_exploration-and-research/01-cordis-runtime/dsh-cordis-hotplug-mcp-patch-research.md +0 -265
- package/docs/60_exploration-and-research/01-cordis-runtime/js-ts-language-fundamentals.md +0 -628
- package/docs/60_exploration-and-research/02-dsh/dash-research.md +0 -592
- package/docs/60_exploration-and-research/02-dsh/dsh-web-profile-package-map.md +0 -186
- package/docs/60_exploration-and-research/02-dsh/dsh-web-ui-slot-system-research.md +0 -310
- package/docs/60_exploration-and-research/02-dsh/dsh-webui-backend-data-inventory.md +0 -633
- package/docs/60_exploration-and-research/02-dsh/dsh-webui-strip-boundary-research.md +0 -300
- package/docs/60_exploration-and-research/02-dsh/dsh-webui-wire-appendix.md +0 -3729
- package/docs/60_exploration-and-research/02-dsh/web-frontend-composability-research.md +0 -191
- package/docs/60_exploration-and-research/02-dsh/webui-wire-data/capture-live-turn.json +0 -1
- package/docs/60_exploration-and-research/02-dsh/webui-wire-data/observed-endpoints.json +0 -224
- package/docs/60_exploration-and-research/02-dsh/webui-wire-data/remote-inventory.json +0 -110954
- package/docs/60_exploration-and-research/02-dsh/webui-wire-data/served-index-sample.html +0 -47
- package/docs/60_exploration-and-research/02-dsh/webui-wire-data/session-events.json +0 -9411
- package/docs/60_exploration-and-research/02-dsh/webui-wire-data/ws-frame-examples.json +0 -20
- package/docs/60_exploration-and-research/02-dsh-webui/dsh-web-profile-package-map.md +0 -186
- package/docs/60_exploration-and-research/02-dsh-webui/dsh-web-ui-slot-system-research.md +0 -310
- package/docs/60_exploration-and-research/02-dsh-webui/dsh-webui-backend-data-inventory.md +0 -633
- package/docs/60_exploration-and-research/02-dsh-webui/dsh-webui-strip-boundary-research.md +0 -300
- package/docs/60_exploration-and-research/02-dsh-webui/dsh-webui-wire-appendix.md +0 -3729
- package/docs/60_exploration-and-research/02-dsh-webui/web-frontend-composability-research.md +0 -191
- package/docs/60_exploration-and-research/02-dsh-webui/webui-wire-data/capture-live-turn.json +0 -1
- package/docs/60_exploration-and-research/02-dsh-webui/webui-wire-data/observed-endpoints.json +0 -224
- package/docs/60_exploration-and-research/02-dsh-webui/webui-wire-data/remote-inventory.json +0 -110954
- package/docs/60_exploration-and-research/02-dsh-webui/webui-wire-data/served-index-sample.html +0 -47
- package/docs/60_exploration-and-research/02-dsh-webui/webui-wire-data/session-events.json +0 -9411
- package/docs/60_exploration-and-research/02-dsh-webui/webui-wire-data/ws-frame-examples.json +0 -20
- package/docs/60_exploration-and-research/03-mobile-ios/dsh-mobile-spa-ios-input-experience-research.md +0 -160
- package/docs/60_exploration-and-research/03-mobile-ios/ios-chat-app-bridge-research.md +0 -324
- package/docs/60_exploration-and-research/04-session-storage/alpha5-compaction-jsonl-mapping.md +0 -1532
- package/docs/60_exploration-and-research/04-session-storage/alpha5-compaction-sample/episode-failed.json +0 -46
- package/docs/60_exploration-and-research/04-session-storage/alpha5-compaction-sample/episode1.json +0 -1124
- package/docs/60_exploration-and-research/04-session-storage/alpha5-compaction-sample/episode2.json +0 -1240
- package/docs/60_exploration-and-research/05-dashr-dev/plugin-development.md +0 -148
- package/docs/60_exploration-and-research/05-dashr-dev/upstream-alignment.md +0 -102
- package/docs/60_exploration-and-research/README.md +0 -87
- package/docs/60_exploration-and-research/bun-compile-cordis-runtime-bootstrap-research.md +0 -348
- package/docs/60_exploration-and-research/cordis-research.md +0 -350
- package/docs/60_exploration-and-research/dsh-mobile-spa-ios-input-experience-research.md +0 -160
- package/docs/60_exploration-and-research/dsh-web-profile-package-map.md +0 -186
- package/docs/60_exploration-and-research/dsh-web-ui-slot-system-research.md +0 -310
- package/docs/60_exploration-and-research/dsh-webui-strip-boundary-research.md +0 -300
- package/docs/60_exploration-and-research/ios-chat-app-bridge-research.md +0 -324
- package/docs/60_exploration-and-research/web-frontend-composability-research.md +0 -191
- package/docs/superd/00-blueprint.md +0 -331
- package/docs/superd/01-component-boundaries.md +0 -261
- package/docs/superd/02-dsh-embed-modes.md +0 -151
- package/docs/superd/image.png +0 -0
- package/lib/py-sdk-BCaOGYz7.d.ts +0 -125
- package/lib/py-sdk-CbgYiX8O.js +0 -691
package/docs/60_exploration-and-research/01-cordis-runtime/dsh-cordis-hotplug-mcp-patch-research.md
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
# DSH + Cordis 热插拔实测:profile patch 热重载、MCP 热挂载与渐进披露
|
|
2
|
-
|
|
3
|
-
> 记录:2026-09-05 · 一手核验:本机 prod `dsh 0.1.2-alpha.5`(npm 布局,
|
|
4
|
-
> `~/.local/lib/node_modules/@deepseek-ai/dsh`,profile `web`,systemd --user `dsh.service`)
|
|
5
|
-
> + `@deepseek-ai/dsh-app-boot` 源码(`lib/profile-boot-*.js` / `lib/index.js`)
|
|
6
|
-
> + `@deepseek-ai/dsh-mcp-client` 源码 + `graphify-http-mcp` 收编改造全程实测。
|
|
7
|
-
> 关联:`cordis-research.md`(Cordis 框架本体研究)· `../02-dsh-webui/dsh-web-profile-package-map.md`(profile 依赖拓扑)。
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 0. 结论先行(两个问题的答案)
|
|
12
|
-
|
|
13
|
-
**Q1:编辑 `cordis.patch.yml` 加/删 MCP server,就能热插拔,对吗?**
|
|
14
|
-
**对。** `cordis.patch.yml` 是本机 dsh **profile web 的用户 patch 层**(runtime 启动后依然"活着"的
|
|
15
|
-
配置文件)。web profile 的 `patchReload` 是 `live`:dsh 启动时经 Cordis HMR 服务 watch 这个文件,
|
|
16
|
-
**保存即触发**——重新解析 patch → 事务性重组插件树 → 新增的 insert 条目对应的插件实例被创建
|
|
17
|
-
(MCP client 连接远端并注册工具),删除的条目对应实例被 dispose(工具注销)。**不需要重启
|
|
18
|
-
`dsh web`,也不需要任何手动触发**(详见 §2 机制、§3 实测时间线)。
|
|
19
|
-
|
|
20
|
-
**Q2:改完 YAML 需要手动触发扫描吗?**
|
|
21
|
-
**不需要。** 保存文件本身就是触发。`watchUserPatches → hmr.registerConfig(filename, cb)`,
|
|
22
|
-
文件变更(含首次注册时的初始扫描)→ 回调重新 `loadOptionalPatches` 解析并热应用。全程自动。
|
|
23
|
-
|
|
24
|
-
**边界与前提(重要):**
|
|
25
|
-
1. **仅 long-lived 面热插拔**:`web` 与自定义 profile 默认 `patchReload: "live"`;官方模板
|
|
26
|
-
`acp` / `headless` / `sdk` / `sdk-minimal` 是 `startup` —— 那些面改 patch 需要重启才生效。
|
|
27
|
-
2. **工具面是"会话启动快照"**:某会话开始后其可调用工具清单已定稿;HMR 热增/热删的 MCP 工具
|
|
28
|
-
只影响**之后新建的会话**(当前进行中的会话工具面不变)。
|
|
29
|
-
3. **YAML 只管配置,不管安装**:insert 引用的插件名必须在 loader 树里可解析。本机 5 个 MCP
|
|
30
|
-
全部复用同一个内置桥插件 `@deepseek-ai/dsh-mcp-client`(host 依赖,profile 自带),所以
|
|
31
|
-
纯 YAML 即可;**第三方插件要先进 profile**(`dsh plugin add <pkg>` / pnpm 装进
|
|
32
|
-
`~/.dsh/profiles/web/package.json` 的 bundles),patch 里才能 insert。
|
|
33
|
-
4. **坏 patch 会 fail loud**:patch 文件存在但不可解析/不可应用 = 配置错误,启动或热重载时报错
|
|
34
|
-
而不是静默跳过 —— 改完可用 dsh 自己的 loader 解析函数离线校验(见附录 C)。
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## 1. 背景:为什么这事值得研究
|
|
39
|
-
|
|
40
|
-
DSH 的插件/配置体系把"运行时组合"和"配置热更"做成了第一公民,直接效果是:**MCP server 的
|
|
41
|
-
挂载/摘除/重挂变成了改一个 YAML、存盘即生效**。本次会话把这条链路完整跑了一遍并量化了
|
|
42
|
-
收益(一个自研 MCP server:schema 12.2 KB → 6.2 KB;顺带完成一次"全局服务收编治理")。
|
|
43
|
-
本文把机制、实测、沉淀的模式一次写清,供后续在 dashr/better-dsh 开发里复用。
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## 2. 机制拆解(源码级,一手核验)
|
|
48
|
-
|
|
49
|
-
### 2.1 Profile 树:patch 是"覆盖层",不是唯一配置
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
~/.dsh/profiles/web/
|
|
53
|
-
├── package.json # dsh.profile.bundles = [@deepseek-ai/dsh-base, @deepseek-ai/dsh-web-app,
|
|
54
|
-
│ # dshmarket, dsh-better-sidebar, corti-memory, better-dsh]
|
|
55
|
-
├── cordis.yml # 空 [] —— 树由 patch 组成,本文件只是占位
|
|
56
|
-
├── cordis.patch.yml # ★ 用户 patch 层(本机所有 MCP insert 都在这里)
|
|
57
|
-
└── node_modules/ # pnpm hoisted 依赖树
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
组合顺序(`dsh-app-boot` `composeEntries`/`prepareProfile`):
|
|
61
|
-
`cordis.yml 根条目` + 每个 bundle 的 `cordis.patch.yml` + **用户层 `cordis.patch.yml`** +
|
|
62
|
-
home 级 patch + `--patch` overlay —— 用户层永远最后覆盖。patch 条目三种形态:
|
|
63
|
-
|
|
64
|
-
| 形态 | 作用 | 本机例子 |
|
|
65
|
-
|---|---|---|
|
|
66
|
-
| `{id, config}` | 覆盖某个既有插件配置 | `agent-presets.default: standard`(dashr bundle 钉的 `dashr` preset 缺失 → 回退)、`dashr-repl` 的 `trustedPageAuthorities` |
|
|
67
|
-
| `{insert: [...]}` | 向树里插入新插件实例 | 5 个 MCP server(见 §4) |
|
|
68
|
-
| `{id, disabled: true}` | 禁用行(⚠ 2026-09-05 勘误:无独立 `disable:` 键,实为 `disabled` 字段覆盖;也无 delete 形态,唯一删除等价物即此) | (本机未用) |
|
|
69
|
-
| `{id, config}` | 覆盖某个既有插件配置 | `agent-presets.default: standard`(dashr bundle 钉的 `dashr` preset 缺失 → 回退)、`dashr-repl` 的 `trustedPageAuthorities` |
|
|
70
|
-
| `{insert: [...]}` | 向树里插入新插件实例 | 5 个 MCP server(见 §4) |
|
|
71
|
-
| `{disable: [...]}` | 停用(本机未用) | — |
|
|
72
|
-
|
|
73
|
-
### 2.2 patchReload:live vs startup
|
|
74
|
-
|
|
75
|
-
`PROFILE_TEMPLATES`(`dsh-app-boot`):
|
|
76
|
-
|
|
77
|
-
- `web` → `live`("hot-reloaded on long-lived surfaces")
|
|
78
|
-
- `acp` / `headless` / `sdk` / `sdk-minimal` → `startup`
|
|
79
|
-
- 自定义 profile(名字不在模板表)→ 默认 `live`
|
|
80
|
-
|
|
81
|
-
`profile-boot` 的运行时判定(`lib/profile-boot-*.js`):
|
|
82
|
-
|
|
83
|
-
```js
|
|
84
|
-
if (composed.profile.patchReload === "live" && …) {
|
|
85
|
-
if (ctx.get("hmr") === void 0) await ctx.loader.create({
|
|
86
|
-
name: "@deepseek-ai/cordis-plugin-hmr", config: { root: [] } });
|
|
87
|
-
await watchUserPatches(ctx, { filename: composed.profile.patchPath, … });
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### 2.3 HMR 链路(保存 → 生效的每一步)
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
保存 cordis.patch.yml
|
|
95
|
-
→ hmr.registerConfig(filename, cb) 的文件 watch 触发(Cordis HMR 服务)
|
|
96
|
-
→ cb: loadOptionalPatches(binName, file) 重新解析(!!js 表达式可 eval process.env)
|
|
97
|
-
→ composeLive() = bundle patches + 用户 patch + overlays 的深拷贝合并
|
|
98
|
-
→ entry.update({ config: { …includeConfig, patches } }) ← 事务性
|
|
99
|
-
→ 差异插件 dispose / create(Cordis "可逆效应"):新增 insert → 实例激活;
|
|
100
|
-
删除/变更的条目 → 旧实例回滚、新实例上线
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
关键实现(`dsh-app-boot/lib/index.js` `watchUserPatches`):
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
const register = hmr.registerConfig(filename, async () => {
|
|
107
|
-
const patches = compose(loadOptionalPatches(binName, filename) ?? []);
|
|
108
|
-
await entry.update({ config: { …includeConfig, patches } });
|
|
109
|
-
});
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### 2.4 dsh-mcp-client:一个插件实例 = 一个 MCP server
|
|
113
|
-
|
|
114
|
-
`@deepseek-ai/dsh-mcp-client` 是 Cordis 命名空间插件:**每个实例连一个 MCP server**,
|
|
115
|
-
把它的工具注册到 harness 的 `ctx.tools`,公开名 `mcp__<serverName>__<rawName>`。
|
|
116
|
-
所以 5 个 MCP = 5 条 insert,全部复用同一插件名、只是 config 不同:
|
|
117
|
-
|
|
118
|
-
```yaml
|
|
119
|
-
- insert:
|
|
120
|
-
- id: mcp-graphify # 实例 id(唯一)
|
|
121
|
-
name: '@deepseek-ai/dsh-mcp-client'
|
|
122
|
-
config:
|
|
123
|
-
serverName: graphify # 工具命名空间(mcp__graphify__*)
|
|
124
|
-
transport: streamable-http
|
|
125
|
-
url: http://127.0.0.1:4749/mcp
|
|
126
|
-
toolCallTimeoutMs: 120000
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
配置面(源码 `lib/types/*.d.ts`):`transport: 'stdio' | 'streamable-http'`;
|
|
130
|
-
stdio 侧 `command/args/env/cwd`,HTTP 侧 `url/headers`;公共 `serverName`/
|
|
131
|
-
`toolCallTimeoutMs`/`failOnStartupError`/`reconnect`。
|
|
132
|
-
|
|
133
|
-
连接语义(`lib/index.js` `syncTools`):连接时**一次全量 `tools/list`(含 drain pagination)**
|
|
134
|
-
并整代注册;收到 `notifications/tools/list_changed` 会重同步换代(旧代先 dispose 再注册新代)。
|
|
135
|
-
**模型只能调用已注册名字的工具** —— 这决定了"渐进披露"只能在 schema 体积上做、不能藏名字
|
|
136
|
-
(详见 §4.3)。
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## 3. 实测时间线(2026-09-05,全部真实回放)
|
|
141
|
-
|
|
142
|
-
| 时刻 | 动作 | 生效方式 | 结果 |
|
|
143
|
-
|---|---|---|---|
|
|
144
|
-
| 上午 | patch 加入 `mcp-exa` + `mcp-graphify` | **保存即 HMR**,无重启 | loader 解析 7 顶层条目;DSH 工具面 +2 server |
|
|
145
|
-
| 上午 | patch 移除 `mcp-graphify`(评估期暂摘) | **保存即 HMR**,无重启 | 回到 4 个 MCP,graphify 工具自动注销 |
|
|
146
|
-
| 下午 | graphify server 端渐进披露改造 + 收编(见 §4、§5) | `busctl` 经 systemd bus `RestartUnit` | 新代码上线,工具 16→17 |
|
|
147
|
-
| 下午 | patch 重挂 `mcp-graphify` | **保存即 HMR**,无重启 | 5 个 MCP;`mcp__graphify__*` 在新会话可见 |
|
|
148
|
-
|
|
149
|
-
全程 `dsh web` 服务进程从未重启;`cordis.patch.yml` 的每次变更都只靠文件保存触发。
|
|
150
|
-
(注意:systemctl --user 在本 agent 沙箱连不上 private socket,但 `busctl --user call
|
|
151
|
-
org.freedesktop.systemd1 … RestartUnit` 可走 D-Bus 直达 systemd,实测可用。)
|
|
152
|
-
|
|
153
|
-
### 3.1 schema payload 实测(同一 server,改造前后)
|
|
154
|
-
|
|
155
|
-
| 指标 | 改造前 | 改造后 | 说明 |
|
|
156
|
-
|---|---|---|---|
|
|
157
|
-
| 工具数 | 16 | **17**(+`detailed_description`) | help 入口按需返回手册 |
|
|
158
|
-
| description 合计 | 5,074 chars(均 317) | **1,462 chars**(均 86) | 一行化 + 手册外置 |
|
|
159
|
-
| `outputSchema` | 每工具一个(非标准、被客户端忽略) | **0** | FastMCP `structured_output=False` |
|
|
160
|
-
| tools/list compact | 12,235 B | **6,187 B** | ~2× |
|
|
161
|
-
| token 估算(÷3.5~4) | ~3.1K | **~1.5–1.8K** | 每请求全量随行,乘模型往返次数 |
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## 4. 沉淀的模式一:MCP server 端"渐进披露"(CLI --help 语义)
|
|
166
|
-
|
|
167
|
-
### 4.1 动机
|
|
168
|
-
|
|
169
|
-
MCP 客户端对 server 是 eager 全量注册;schema(尤其长 description)**每个模型请求都全量随行**、
|
|
170
|
-
按 input token 计费。Hermes 2026-07 曾因 graphify eager 注入占 code profile 上下文 ~10%
|
|
171
|
-
(~15.5KB/轮) 而把 MCP 降级成 skill —— 同一 server、同一配置,问题出在**服务端把手册写在
|
|
172
|
-
description 里**。
|
|
173
|
-
|
|
174
|
-
### 4.2 做法
|
|
175
|
-
|
|
176
|
-
1. `tools/list` 里每个工具只留:**名字 + 一行功能性描述 + 极简 typed schema**(足够模型构造首次调用)。
|
|
177
|
-
2. 完整手册(参数语义 / 示例 / 返回形态 / CLI 等价)移入服务端常驻字典,经新增的总入口工具
|
|
178
|
-
**按需返回**:`detailed_description(tool?)` —— 无参 = 工具目录,带参 = 单工具手册。
|
|
179
|
-
3. 类比:人和模型遇到陌生 CLI 都会先 `-h/--help` —— 这是双方都"原生"的渐进披露。
|
|
180
|
-
|
|
181
|
-
实现要点(graphify-http-mcp.py canonical 版):
|
|
182
|
-
- `_HELP: dict[str,str]` 存 16 条手册;`detailed_description` 负责索引/详情/未知名提示。
|
|
183
|
-
- **FastMCP 实测坑①**:docstring 全量(含 Args/Returns 段)会进 `description` → 必须一行化。
|
|
184
|
-
- **FastMCP 实测坑②**:该版本默认给每个工具发 `outputSchema`(非 MCP 标准字段,客户端忽略但
|
|
185
|
-
白吃 payload)→ 用 `structured_output=False` 的装饰器别名统一抑制(`def _tool(fn):
|
|
186
|
-
return mcp.tool(structured_output=False)(fn)`)。
|
|
187
|
-
- 残余可压项(本次未做,边际收益 ~1.4KB):inputSchema 里的 `title` 字段("Graph Path"、
|
|
188
|
-
"query_graphArguments" 等)可后处理剥掉;需要侵入 FastMCP 内部,收益 ~25%,先不碰。
|
|
189
|
-
|
|
190
|
-
### 4.3 架构红利
|
|
191
|
-
|
|
192
|
-
披露坍缩在 **server 端**、MCP 配置在各 runtime 间不变 → server 改一次,Hermes / DSH / OMP /
|
|
193
|
-
Claude Code 等所有消费者**自动**同时瘦身。这也是"配置跨运行时复用"的正确姿势:把变体下沉到
|
|
194
|
-
自己写的服务里,而不是在每个运行时各改一遍。
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## 5. 沉淀的模式二:自研 MCP server 的收编治理
|
|
199
|
-
|
|
200
|
-
### 5.1 问题(审计发现)
|
|
201
|
-
|
|
202
|
-
graphify-http-mcp 是**全局 MCP 服务**,却只有 `~/.hermes/services/` 与
|
|
203
|
-
`~/.hermes/profiles/code/services/` 两份**无版本控制的物理副本**(md5 相同、非 symlink);
|
|
204
|
-
dev 侧文档/unit 模板在 base 仓库但整目录从未提交。全局服务挂在某个 agent runtime 的 profile
|
|
205
|
-
目录里 = 部署位即单点、无 canonical、易漂移。
|
|
206
|
-
|
|
207
|
-
### 5.2 收编动作(本次落地)
|
|
208
|
-
|
|
209
|
-
1. **canonical 源码** → `~/workspaces/base/40_Services/05_graphify/graphify-http-mcp.py`
|
|
210
|
-
(部署资产随 tier 目录入库;base git 提交 `d56e61c`)。
|
|
211
|
-
2. **unit 模板** → 同目录 `templates/graphify-http-mcp.service`;live unit
|
|
212
|
-
`~/.config/systemd/user/` ExecStart 指向 canonical 路径。
|
|
213
|
-
3. `~/.hermes` 两份副本 → **symlink 指回 canonical**(不再有分叉副本)。
|
|
214
|
-
4. **路径逻辑与文件位置解耦**:wrapper 原来用 `Path(__file__).resolve()...` 推算 uv python
|
|
215
|
-
路径(只在 `~/.hermes/services/` 深度成立),改为 `Path.home()` 推算 + `GRAPHIFY_PYTHON`
|
|
216
|
-
env 覆盖 —— 文件挪进 base 深层目录后依然能启动。
|
|
217
|
-
5. 风险提示:若某 runtime 按 profile **重新 stage services(copy 而非保留 symlink)**会盖掉
|
|
218
|
-
symlink —— 收编后要留意这类"写回副本"逻辑。
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## 6. 一句话沉淀
|
|
223
|
-
|
|
224
|
-
**DSH 的热插拔 = Cordis 的"可逆效应 + 反应式余效应"在 profile patch 层的落地**:把
|
|
225
|
-
"配置文件"做成能被 HMR 监控、事务性重组合的覆盖层,于是 MCP 的挂/摘/重挂、插件的加/减/改,
|
|
226
|
-
都是"改 YAML、存盘、等下一个会话";而 schema 开销这类**服务端可修的问题,永远优先修在服务端**,
|
|
227
|
-
让所有消费者零改动地同时受益。
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## 附录 A:本机 5 个 MCP 的 patch 摘要
|
|
232
|
-
|
|
233
|
-
```yaml
|
|
234
|
-
# ~/.dsh/profiles/web/cordis.patch.yml —— 每个 - insert: 块 = 一个 MCP server
|
|
235
|
-
mcp-cordis-a2a → streamable-http https://a2a.randomhash.app/?uuid=… (A2A 桥)
|
|
236
|
-
mcp-zai-vision → stdio npx -y @z_ai/mcp-server@latest (GLM-4.6V,ZAI_PLAN_API_KEY)
|
|
237
|
-
mcp-web-reader → streamable-http https://api.z.ai/api/mcp/web_reader/mcp(Bearer $ZAI_PLAN_API_KEY)
|
|
238
|
-
mcp-exa → streamable-http https://mcp.exa.ai/mcp (x-api-key $EXA_API_KEY)
|
|
239
|
-
mcp-graphify → streamable-http http://127.0.0.1:4749/mcp (本机自研,canonical 于 base)
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## 附录 B:相关源码/文件索引
|
|
243
|
-
|
|
244
|
-
- `~/.dsh/profiles/web/cordis.patch.yml` · `cordis.yml` · `package.json`
|
|
245
|
-
- `~/.local/lib/node_modules/@deepseek-ai/dsh/`(lib/profile-boot-*.js、bin.js)
|
|
246
|
-
- `…/@deepseek-ai/dsh-app-boot/lib/index.js`(watchUserPatches / PROFILE_TEMPLATES / loadOptionalPatches)
|
|
247
|
-
- `…/@deepseek-ai/dsh-mcp-client/lib/index.js`(syncTools / 类型定义 lib/types/*.d.ts)
|
|
248
|
-
- `~/workspaces/base/40_Services/05_graphify/graphify-http-mcp.py`(canonical + _HELP 渐进披露实现)
|
|
249
|
-
- 上游:Cordis = `@deepseek-ai/cordis`(vendored)/ `github.com/cordiverse/cordis`;
|
|
250
|
-
框架本体研究见同目录 `cordis-research.md`
|
|
251
|
-
|
|
252
|
-
## 附录 C:patch 离线校验(loader 同款解析)
|
|
253
|
-
|
|
254
|
-
不重启、不触发热重载的前提下验证 `cordis.patch.yml` 能否被 dsh 真实解析:
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
cd /home/u1/.local/lib/node_modules/@deepseek-ai/dsh
|
|
258
|
-
node --input-type=module -e "
|
|
259
|
-
import { loadOptionalPatches } from '@deepseek-ai/dsh-app-boot';
|
|
260
|
-
const p = loadOptionalPatches('validate', '/home/u1/.dsh/profiles/web/cordis.patch.yml');
|
|
261
|
-
console.log('parse OK —', p.length, 'entries');
|
|
262
|
-
"
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
解析抛错 = patch 有问题(fail loud),先修再存盘,避免把坏配置热重载进运行中的树。
|