@xi4z/dsh-utils 0.5.0 → 0.7.0

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/README.md +99 -104
  2. package/cordis.patch.yml +36 -37
  3. package/lib/index.d.ts +5 -63
  4. package/lib/index.js +6 -859
  5. package/lib/index.js.map +1 -1
  6. package/locale/en.json +1 -1
  7. package/locale/zh.json +1 -1
  8. package/package.json +10 -46
  9. package/src/index.ts +6 -927
  10. package/client.js +0 -2330
  11. package/lib/ui-host.d.ts +0 -96
  12. package/lib/ui-host.js +0 -970
  13. package/lib/ui-host.js.map +0 -1
  14. package/packages/approval-policy/lib/index.d.ts +0 -297
  15. package/packages/approval-policy/lib/index.js +0 -425
  16. package/packages/approval-policy/lib/index.js.map +0 -1
  17. package/packages/approval-policy/locale/en.json +0 -6
  18. package/packages/approval-policy/locale/zh.json +0 -6
  19. package/packages/notify/lib/index.d.ts +0 -290
  20. package/packages/notify/lib/index.js +0 -915
  21. package/packages/notify/lib/index.js.map +0 -1
  22. package/packages/notify/locale/en.json +0 -6
  23. package/packages/notify/locale/zh.json +0 -6
  24. package/packages/skill-panel/lib/index.d.ts +0 -49
  25. package/packages/skill-panel/lib/index.js +0 -420
  26. package/packages/skill-panel/lib/index.js.map +0 -1
  27. package/packages/skill-panel/locale/en.json +0 -6
  28. package/packages/skill-panel/locale/zh.json +0 -6
  29. package/packages/utils-agents/lib/git.d.ts +0 -87
  30. package/packages/utils-agents/lib/git.js +0 -403
  31. package/packages/utils-agents/lib/git.js.map +0 -1
  32. package/packages/utils-agents/lib/global-repo.d.ts +0 -57
  33. package/packages/utils-agents/lib/global-repo.js +0 -301
  34. package/packages/utils-agents/lib/global-repo.js.map +0 -1
  35. package/packages/utils-agents/lib/index.d.ts +0 -80
  36. package/packages/utils-agents/lib/index.js +0 -435
  37. package/packages/utils-agents/lib/index.js.map +0 -1
  38. package/packages/utils-agents/lib/legacy.d.ts +0 -30
  39. package/packages/utils-agents/lib/legacy.js +0 -141
  40. package/packages/utils-agents/lib/legacy.js.map +0 -1
  41. package/packages/utils-agents/lib/native.d.ts +0 -74
  42. package/packages/utils-agents/lib/native.js +0 -232
  43. package/packages/utils-agents/lib/native.js.map +0 -1
  44. package/packages/utils-agents/lib/presets.d.ts +0 -34
  45. package/packages/utils-agents/lib/presets.js +0 -312
  46. package/packages/utils-agents/lib/presets.js.map +0 -1
  47. package/packages/utils-agents/lib/shared.d.ts +0 -105
  48. package/packages/utils-agents/lib/shared.js +0 -507
  49. package/packages/utils-agents/lib/shared.js.map +0 -1
  50. package/packages/utils-agents/lib/update.d.ts +0 -129
  51. package/packages/utils-agents/lib/update.js +0 -507
  52. package/packages/utils-agents/lib/update.js.map +0 -1
  53. package/packages/utils-agents/lib/util.d.ts +0 -215
  54. package/packages/utils-agents/lib/util.js +0 -475
  55. package/packages/utils-agents/lib/util.js.map +0 -1
  56. package/packages/utils-agents/locale/en.json +0 -6
  57. package/packages/utils-agents/locale/zh.json +0 -6
  58. package/skills/dsh-approval-policy-config/SKILL.md +0 -96
  59. package/src/ui-host.ts +0 -1073
package/README.md CHANGED
@@ -1,35 +1,36 @@
1
1
  # @xi4z/dsh-utils
2
2
 
3
- 单包形态:`@xi4z/dsh-utils` 一个包既是 bundle 层(`cordis.patch.yml` + locale + icon),也是主组件 `utils-main` 与整个浏览器半侧的代码所在,其余四个组件以**包内 subpath** 挂载(`@xi4z/dsh-utils/utils-agents`)。因此 manifest 里没有任何 `@xi4z/*` 依赖,npm 名、GitHub 地址、packed tarball、本地目录四种装法都只需要这一个 spec。行 id 就是 settings 命名空间,保持稳定。
3
+ 官方实验性 bundle 形态:根包 `@xi4z/dsh-utils` 只做拼装(`cordis.patch.yml` + locale + icon),**本身不挂任何组件**;四个组件各自是独立发布的包,根包用同版本精确依赖把它们装起来。浏览器半侧单独成包 `@xi4z/dsh-utils-ui`(宿主 `apply()` 为空),客户端扫描器据此从 `utils-ui` 这个包根行加载 `client.js`。行 id 就是 settings 命名空间,保持稳定。
4
4
 
5
5
  | 组件 | 挂载项 id | 包 | 作用 |
6
6
  |---|---|---|---|
7
- | 递归技能发现 + 旧技能仓库路由(主组件) | `utils-main` | `@xi4z/dsh-utils`(包根) | 嵌套目录找 `SKILL.md`;保留旧的全局技能仓库 JSON 路由;`client.js` 提供全部配置页与右侧栏 utils-agents 面板 |
8
- | 无人值守审批门控 | `dsh-approval-policy` | `@xi4z/dsh-utils/approval-policy` | 给审批请求设应答窗口,超时 fail-closed |
9
- | 会话通知 | `dsh-notify` | `@xi4z/dsh-utils/notify` | 会话结束/等授权/等回答时,经 Gotify 网关推送,带设备名 |
10
- | 技能面板(宿主侧) | `dsh-skill-panel` | `@xi4z/dsh-utils/skill-panel` | 旧侧边栏卡片已并入 utils-agents;保留当前会话的模型可见性开关与配置页 |
11
- | utils-agents | `utils-agents` | `@xi4z/dsh-utils/utils-agents` | 一个侧边栏面板按预设管理 skills、技能仓库与 AGENTS.md,用通用 Deploy Key 拉取私有仓库,并从技能仓库 `.dsh` 同步共享预设 |
7
+ | utils-agents(宿主侧) | `utils-agents` | `@xi4z/dsh-utils-utils-agents` | 技能与预设的唯一宿主:嵌套 `SKILL.md` 发现、模型可见性开关,以及按预设管理 skills、技能仓库与 AGENTS.md |
8
+ | 无人值守审批门控 | `dsh-approval-policy` | `@xi4z/dsh-utils-approval-policy` | 给审批请求设应答窗口,超时 fail-closed |
9
+ | 会话通知 | `dsh-notify` | `@xi4z/dsh-utils-notify` | 会话结束/等授权/等回答时,经 Gotify 网关推送,带设备名 |
10
+ | 共享浏览器界面 | `utils-ui` | `@xi4z/dsh-utils-ui` | 上面三行的配置页 + 右侧栏 utils-agents 面板;宿主侧只有空的 `apply()` |
12
11
 
13
- 根包的 `locale/{en,zh}.json` 同时是 bundle 展示名与 `utils-main` 行的标题(「Harness 工具集」);四个 subpath 行各自从 `./<subpath>/locale/*.json` 取行标题(无人值守审批门控 / 会话通知 / 技能面板 / utils-agents)。subpath 行不是包,DSH 不读它的 `package.json`,所以组件目录里那份 manifest 只是 tsc/测试的构建单元,不再发布。
12
+ `utils-agents` 合并了原来的 `utils-main`(递归发现、旧全局仓库路由)与 `dsh-skill-panel`(技能可见性):递归发现、可见性开关、预设/仓库/AGENTS.md 管理现在是**一个组件、一个配置命名空间**。旧的 `/api/dsh-utils-ui/*` 路由随 `utils-main` 一起删掉;仓库配置与 Deploy Key 仍沿用 `$DSH_HOME/storages/dsh-utils-ui.*` 文件,由 utils-agents 读写,升级后不用重填。
13
+
14
+ 根包 `locale/{en,zh}.json` 是 bundle 展示名;每个组件包用自己的 `locale/*.json` 提供行标题(utils-agents / 无人值守审批门控 / 会话通知 / 工具集界面)。`packages/*` 现在是**独立发布**的包,不再只是 tsc/测试的构建单元。
14
15
 
15
16
  ### 关于配置界面
16
17
 
17
- DSH 客户端扫描器从**包根挂载行**加载 `client.js`。根包自己声明 `dsh.client` 并导出 `./client`,而 `utils-main` 行挂的正是包根,所以这一行同时提供宿主行为(递归发现 + 技能仓库路由)和浏览器半侧;四个 subpath 行只做宿主行为,不会被当成 client source,因此不会出现 `multiple active Loader sources`。
18
+ DSH 只把一个包的浏览器半侧挂在「Loader 说明符恰为裸包名」的行上。`@xi4z/dsh-utils-ui` 自己声明 `dsh.client` 并导出 `./client`,patch 用 `utils-ui` 行挂它的裸包名,所以 `client.js` 落在这一行;三个宿主行不声明 `dsh.client`,不会出现 `multiple active Loader sources`。
18
19
 
19
- 「技能仓库」的旧全局路由仍在根包里(`src/ui-host.ts`,编译到 `lib/ui-host.js`),由 `utils-main` 行注册;但它不再有独立侧边栏卡片,新的按预设仓库同步在 `utils-agents`。`client.js` 现在只注册配置页和一个 utils-agents 侧边栏面板。停用 `utils-main` 会失去递归发现、旧仓库路由和整个配置界面;停用 `utils-agents` 只会失去 utils-agents 路由(面板显示 404 提示)。
20
+ UI 与宿主彻底解耦:停用 `utils-ui` 只失去配置页与侧边栏面板,宿主行照常工作;停用某个宿主行只让它自己的配置页消失(`whileServed` 按行 id 判定)。`utils-agents` 的配置页现在一页三块:递归技能发现、模型可见性开关、预设与技能仓库。
20
21
 
21
- 配置写 `cordis.patch.yml`:bundle 给默认值,profile 按 id 覆盖。覆盖行**不要写 `name`**(写旧包名会被 DSH 按 name mismatch 跳过)。技能仓库的仓库地址、分支与密钥不写 profile,存在 `$DSH_HOME/storages/dsh-utils-ui.json`(沿用旧文件名)。
22
+ 配置写 `cordis.patch.yml`:bundle 给默认值,profile 按 id 覆盖。覆盖行**不要写 `name`**。旧版的 `- id: utils-main` / `- id: dsh-skill-panel` 覆盖行不再生效,字段要搬进 `- id: utils-agents` 的 `config:`。
22
23
 
23
24
  ## 安装
24
25
 
25
- 一个包,四种 spec,装法都一样:
26
+ 一次装 bundle;四个组件由 pnpm 作为根包的精确版本依赖从 registry 装上。
26
27
 
27
28
  | 想要的 | `target` |
28
29
  |---|---|
29
30
  | 最近一次发布 | `@xi4z/dsh-utils` |
30
- | `main` 最新提交 | `https://github.com/xi4z/dsh-utils` |
31
- | 离线单文件 | `/abs/path/xi4z-dsh-utils-0.5.0.tgz` |
32
- | 改代码、即时生效 | `/abs/path/dsh-utils`(绝对目录,装成 `link:`) |
31
+ | `main` 最新提交 | `https://github.com/xi4z/dsh-utils`(组件包仍需 registry 上有同版本) |
32
+ | 离线 | 五个 tarball(见下) |
33
+ | 改代码、即时生效 | 目录 `link:`,profile 里同时 link 四个组件 |
33
34
 
34
35
  ```
35
36
  plugin_manager action=install_bundle target=@xi4z/dsh-utils
@@ -39,48 +40,52 @@ plugin_manager action=install_bundle target=@xi4z/dsh-utils
39
40
  dsh plugin --profile <profile> add @xi4z/dsh-utils
40
41
  ```
41
42
 
42
- 四种都不要求 registry 上有任何 `@xi4z/*` 包:四个组件是包内 subpath 行(`@xi4z/dsh-utils/utils-agents`),根包只依赖公共的 `@deepseek-ai/schemastery`。GitHub 地址装的是 `main` 当前状态、不钉版本;要钉就用 npm 名或 `#<commit>`。
43
+ 发布版只需要这一个 spec:根包的 `dependencies` 固定到四个 `@xi4z/dsh-utils-*`,版本与 bundle 相同。GitHub 地址装的是 `main` 当前状态、不钉版本;要钉就用 npm 名或 `#<commit>`(组件仍从 registry 取同版本)。
43
44
 
44
- 离线单文件由 `pnpm pack` 产出,本身就是自包含的:
45
+ 根包 tarball 不再自包含(组件是独立包)。要离线搬运,就把五个包都 pack:
45
46
 
46
47
  ```sh
47
48
  pnpm install && pnpm build
48
- pnpm pack --pack-destination dist # → dist/xi4z-dsh-utils-0.5.0.tgz
49
- # 复制到目标机器后:
50
- plugin_manager action=install_bundle target=/abs/path/xi4z-dsh-utils-0.5.0.tgz
49
+ pnpm -r --filter "./packages/*" pack --pack-destination dist
50
+ pnpm pack --pack-destination dist
51
+ # 目标机器 profile 里五个 tarball 都加 file: 依赖,再装 bundle
51
52
  ```
52
53
 
53
- 本地开发直接装目录(`link:`,不复制文件,改完 `pnpm build` 重启宿主):
54
-
55
- ```sh
56
- cd /path/to/dsh-utils
57
- pnpm install && pnpm build
58
- plugin_manager action=install_bundle target=/abs/path/to/dsh-utils
54
+ 本地开发直接装目录(`link:`,不复制文件,改完 `pnpm build` 重启宿主)。因为组件是精确版本依赖,profile 要把四个组件也 link 进来,pnpm 才会用本地目录而不是去 registry 解析:
55
+
56
+ ```json
57
+ {
58
+ "dependencies": {
59
+ "@xi4z/dsh-utils": "link:/abs/path/dsh-utils",
60
+ "@xi4z/dsh-utils-approval-policy": "link:/abs/path/dsh-utils/packages/approval-policy",
61
+ "@xi4z/dsh-utils-notify": "link:/abs/path/dsh-utils/packages/notify",
62
+ "@xi4z/dsh-utils-utils-agents": "link:/abs/path/dsh-utils/packages/utils-agents",
63
+ "@xi4z/dsh-utils-ui": "link:/abs/path/dsh-utils/packages/ui"
64
+ }
65
+ }
59
66
  ```
60
67
 
61
- > 别给根包加回 `@xi4z/*` 依赖,也别把版本写成 `workspace:^`:那会毁掉"一条 spec 装全套"——`workspace:` 只在仓库内 `pnpm publish`/`pnpm pack` 时被改写成版本号,profile 从 git 或 tarball 装时 pnpm 拿到的是字面量,直接报 `ERR_PNPM_WORKSPACE_PKG_NOT_FOUND`。
68
+ profile 的 `dsh.profile.bundles` 里是 `@xi4z/dsh-utils`。装后 bundle 的 patch 自动插四行,不手写挂载块;`config:` 只管配置。挂载项新增/改名要重启宿主。
62
69
 
63
- profile 的 `dsh.profile.bundles` 里是 `@xi4z/dsh-utils`。装后 bundle 的 patch 自动插五行,不手写挂载块;`config:` 只管配置。挂载项新增/改名要重启宿主。
70
+ 从 0.5.0 单包版升级:
64
71
 
65
- 从单包/无 scope 版本升级:
66
-
67
- 1. profile 依赖只留 `@xi4z/dsh-utils`,把 `dsh-utils`、`dsh-utils-*`、`@xi4z/dsh-utils-approval-policy` 这类的 link 全删掉(组件已并入根包,多留会变成不识别的孤儿依赖);
68
- 2. `dsh.profile.bundles` 里的旧名换成 `@xi4z/dsh-utils`;
69
- 3. profile `cordis.patch.yml` 的组件覆盖行不要写 `name:`(只留 `id` + `config`);旧的 `id: dsh-utils-ui` 覆盖行删掉(该行已并入 `utils-main`);
72
+ 1. 发布版:profile 依赖只留 `@xi4z/dsh-utils`(pnpm 会装上四个组件);本地开发:再按上表 link 四个 `packages/*`;
73
+ 2. `dsh.profile.bundles` 里的 `@xi4z/dsh-utils` 不变;
74
+ 3. profile `cordis.patch.yml` 的组件覆盖行只留 `id` + `config`;把 `id: utils-main` 与 `id: dsh-skill-panel` 下的字段搬进 `id: utils-agents`(旧 id 不再挂载),旧的 `id: dsh-utils-ui` 覆盖行删掉(新的 UI 行 id 是 `utils-ui`);
70
75
  4. 重启宿主。技能仓库设置、Deploy Key、上次同步记录都不用重填。
71
76
 
72
77
  ## 发布
73
78
 
74
- 只有一个包要发。`scripts/release.mjs` 先 `npm view` 探一遍,**版本已在 registry 上就跳过**,所以重复跑安全、失败后重跑能从断点续上。
79
+ 五个包同版本、按依赖顺序发布:四个组件在前,bundle 在后。`scripts/release.mjs` 先 `npm view` 探一遍,**版本已在 registry 上就跳过**,所以重复跑安全、失败后重跑能从断点续上;任一包版本与根包不一致会直接报错退出。
75
80
 
76
81
  推 GitHub 与发 npm 可以合成一次操作——打 tag 触发 [`publish.yml`](.github/workflows/publish.yml):
77
82
 
78
83
  ```sh
79
84
  git push # 先推代码
80
- git tag v0.5.0 && git push origin v0.5.0 # 再推 tag,CI 里 build + 发布
85
+ git tag v0.7.0 && git push origin v0.7.0 # 再推 tag,CI 里 build + 发布全部五个包
81
86
  ```
82
87
 
83
- tag 必须等于根包 `package.json` 的版本,否则 job 直接失败(防止把 0.5.0 的代码发成 0.3.9)。CI 里 `pnpm release` 只发根包(组件都在包里),带 `--provenance`。
88
+ tag 必须等于根包 `package.json` 的版本,否则 job 直接失败(防止把 0.7.0 的代码发成 0.3.9)。CI 里 `pnpm release` 按依赖顺序发五个包,带 `--provenance`。
84
89
 
85
90
  一次性准备:npm 建一个 Automation token,存成仓库 secret `NPM_TOKEN`。scope 是公开的 `@xi4z`,token 所属账号要能用这个 scope(scope 通常是 npm 用户名或已创建的组织)。
86
91
 
@@ -88,13 +93,13 @@ tag 必须等于根包 `package.json` 的版本,否则 job 直接失败(防
88
93
 
89
94
  ```sh
90
95
  pnpm build
91
- pnpm release # 发根包;版本已在 registry 上就跳过
96
+ pnpm release # 按顺序发组件与 bundle;已发布版本跳过
92
97
  pnpm release --dry-run # 只看会不会发,不动 registry
93
98
  ```
94
99
 
95
- 组件改了不用单独发布:它们随根包一起走,`packages/<名>/lib` 和 `locale` 都进 `files`,`pnpm pack` 后即自包含。只发一个包也意味着版本只有一个——改了任何组件都要提根包版本号。
100
+ 版本只有一个:改了任何组件都要把五个 `package.json` 的版本一起提到同一个值,再打 tag。
96
101
 
97
- ## 组件一(`utils-main`):递归技能发现、旧仓库路由与浏览器 UI
102
+ ## 组件一(`utils-agents`):技能目录 —— 递归发现与模型可见性
98
103
 
99
104
  ```
100
105
  .dsh/skills/
@@ -121,6 +126,13 @@ pnpm release --dry-run # 只看会不会发,不动 registry
121
126
 
122
127
  识别字段:`name`、`description`,可选 `whenToUse`、`disable-model-invocation`、`user-invocable`。非法文件记 warning,跳过。
123
128
 
129
+
130
+ ### 模型可见性(同一组件)
131
+
132
+ 配置页的「技能」开关列出当前会话能读到的 Skill:关掉 = 在 `ctx.skills.snapshot()` / `list()` 里把该技能标成 `modelInvocable: false`,模型下一轮拿到的 `<available_skills>` 里不再出现,**手动 `/名称` 仍可加载**。只能手动调用的技能显示「仅手动」,开关禁用。
133
+
134
+ 数据来源:`GET /api/dsh-utils/skill-panel/list`(Connection owner 认证);带 `sessionId` 时用该会话的 cwd 与 preset skill 层,不带时用宿主默认工作目录。持久化在 `utils-agents` 命名空间的 `disabledSkills`(volatile,保存即生效);这里只影响模型可见性,不改预设目录里的 `SKILL.md`——按预设开关技能仍在同一面板的「技能」视图(重命名 `SKILL.md` / `SKILL.md.disabled`)。
135
+
124
136
  ## 组件二:无人值守审批门控
125
137
 
126
138
  挂宿主 `'approval/request'` waterfall 链首(`prepend`)。判定无人值守的请求先 `next()` 给下游:窗口内有人答,用人的答案;窗口耗尽,按 fail-closed 默认值落定,turn 立即结束,不长期挂起。交互会话不改变。
@@ -315,31 +327,7 @@ template: |
315
327
  3. 两个 id 不能同时挂,否则同一事件发两遍。旧命名空间 `qq-notify` 的存量值不读取。按第 2 步搬。
316
328
  4. 环境变量(`DSH_QQ_NOTIFY_*`)不改。
317
329
 
318
- ## 组件四:技能面板(宿主侧)
319
-
320
- 右侧栏的「技能」卡片已并入组件五 utils-agents,不再单独注册。宿主侧仍保留原来的模型可见性开关与配置页:列出当前会话能读取到的 Skill(模型技能目录),每行一个开关。
321
-
322
- 开关语义:关掉 = 在 `ctx.skills.snapshot()` / `list()` 里把该技能标成 `modelInvocable: false`,模型下一轮拿到的 `<available_skills>` 里不再出现;**手动 `/名称` 仍可加载**。不是 modelInvocable 的技能(只能手动调用的)显示「仅手动」,开关禁用。
323
-
324
- 数据来源:`GET /api/dsh-utils/skill-panel/list`(Connection owner 认证)。带 `sessionId` 时用该会话的 cwd 与 preset skill 层;不带时用宿主默认工作目录。返回按名称排序,`enabled = modelInvocable && !disabled`。
325
-
326
- 持久化:写 profile settings 的 `dsh-skill-panel` 命名空间:
327
-
328
- ```yaml
329
- - id: dsh-skill-panel
330
- config:
331
- disabledSkills: []
332
- ```
333
-
334
- `disabledSkills` 是 volatile,保存即生效、不用重启。面板本身不落盘。
335
-
336
- 注意:这里只影响当前会话的模型可见性,不改预设目录里的 `SKILL.md`。按预设开关技能请用 utils-agents(重命名 `SKILL.md` / `SKILL.md.disabled`)。
337
-
338
- ### 旧技能仓库路由
339
-
340
- `utils-main` 仍注册旧的全局仓库路由 `/api/dsh-utils-ui/*`(存储 `dsh-utils-ui.json`、`.deploy-key`),但不再有侧边栏卡片。新面板的「预设同步」也读写同一份存储与 Deploy Key 文件,用来拉取私有技能仓库;旧数据和旧路由保留,停用 `utils-agents` 不会影响它们。
341
-
342
- ## 组件五:utils-agents
330
+ ## 组件四(`utils-agents` 面板):预设、技能仓库与 AGENTS.md
343
331
 
344
332
  一个侧边栏面板,把原来的「技能」「技能仓库」「Markdown」三张卡片合在一起,并把 `~/.dsh/.agent-presets/<id>/` 注册成真正的 agent preset。顶部选择预设(或「全局 / 项目 AGENTS.md」),下面四个视图:
345
333
 
@@ -377,7 +365,7 @@ Deploy Key 按预设保存到 `$DSH_HOME/storages/dsh-utils-agents/<preset>.key`
377
365
 
378
366
  #### 版本检查
379
367
 
380
- 面板顶部显示当前 bundle 版本(如 `v0.5.0`)、安装来源徽标(npm / GitHub / 本地)和「检查更新」按钮。宿主按 `updateCheckIntervalHours`(默认 6 小时)在后台检查,激活后约 15 秒先查一次;远端比当前版本新时,按钮旁出现「有新版本 x.y.z」。
368
+ 面板顶部显示当前 bundle 版本(如 `v0.7.0`)、安装来源徽标(npm / GitHub / 本地)和「检查更新」按钮。宿主按 `updateCheckIntervalHours`(默认 6 小时)在后台检查,激活后约 15 秒先查一次;远端比当前版本新时,按钮旁出现「有新版本 x.y.z」。
381
369
 
382
370
  查哪里取决于 profile 里 `@xi4z/dsh-utils` 的安装方式(读 profile 的 `package.json`):
383
371
 
@@ -490,35 +478,22 @@ DSH 的预设除了目录版,还可能来自 Cordis 声明(随包内置的 `
490
478
  | `updateRegistry` | `https://registry.npmjs.org` | 查询发布版本用的 registry,可换镜像 |
491
479
  | `updateAutoInstall` | `true` | 查到新版本就后台执行 `pnpm add` 自动安装(重启后生效) |
492
480
 
493
- 宿主半侧在 `packages/utils-agents/src/`(`index.ts` 路由、`presets.ts` 预设/技能/文件、`git.ts` 仓库同步、`update.ts` 发布版本检查),浏览器半侧仍是根包的 `client.js`。停用 `utils-agents` 行后路由消失,侧边栏 utils-agents 面板显示 404 提示。
481
+ 宿主半侧在 `packages/utils-agents/src/`(`index.ts` 路由、`presets.ts` 预设/技能/文件、`git.ts` 仓库同步、`update.ts` 发布版本检查),浏览器半侧在 `@xi4z/dsh-utils-ui` 的 `client.js`。停用 `utils-agents` 行后路由消失,侧边栏 utils-agents 面板显示 404 提示。
494
482
 
495
483
  ## 配置写法
496
484
 
497
485
  覆盖行只写 `id` 与 `config`,`name` 交给 bundle:
498
486
 
499
487
  ```yaml
500
- - id: utils-main
488
+ - id: utils-agents
501
489
  config:
490
+ # 递归发现
502
491
  maxDepth: 6
503
492
  extraRoots:
504
493
  - D:/Core/Projects/Skill
505
- - id: dsh-approval-policy
506
- config:
507
- origins: [subagent, scheduled, cron]
508
- windowSeconds: 300
509
- defaultOutcome: rejected
510
- - id: dsh-notify
511
- config:
512
- transport: gotify
513
- gotifyUrl: https://notify.example.com
514
- gotifyToken: gtfya.该系列的token
515
- deviceLabel: 办公本
516
- dryRun: false
517
- - id: dsh-skill-panel
518
- config:
494
+ # 模型可见性
519
495
  disabledSkills: []
520
- - id: utils-agents
521
- config:
496
+ # 预设 / 技能仓库 / AGENTS.md
522
497
  maxBytes: 524288
523
498
  presetDirs: []
524
499
  extraAgentsFiles: []
@@ -530,47 +505,67 @@ DSH 的预设除了目录版,还可能来自 Cordis 声明(随包内置的 `
530
505
  updateCheckIntervalHours: 6
531
506
  updateRegistry: https://registry.npmjs.org
532
507
  updateAutoInstall: true
508
+ - id: dsh-approval-policy
509
+ config:
510
+ origins: [subagent, scheduled, cron]
511
+ windowSeconds: 300
512
+ defaultOutcome: rejected
513
+ - id: dsh-notify
514
+ config:
515
+ transport: gotify
516
+ gotifyUrl: https://notify.example.com
517
+ gotifyToken: gtfya.该系列的token
518
+ deviceLabel: 办公本
519
+ dryRun: false
533
520
  ```
534
521
 
535
- 五个组件 id(`utils-main` + 四个 subpath 组件)同时是 settings 命名空间;配置写 `cordis.patch.yml`:bundle 给默认,profile 按 id 覆盖。根包声明 `dsh.client`,`utils-main` 这个包根行同时让宿主加载 `client.js`;插件页每个挂载项都有配置页,右侧栏只有一个 utils-agents 面板。组件启用/停用、运行状态照常显示。
522
+ 三个宿主 id(`utils-agents`、`dsh-approval-policy`、`dsh-notify`)同时是 settings 命名空间;`utils-ui` 没有 config,只是浏览器半侧的挂载行。配置写 `cordis.patch.yml`:bundle 给默认,profile 按 id 覆盖。插件页每个挂载项都有配置页(由 `utils-ui` 的 `client.js` 注册:审批、通知各一页,utils-agents 一页三块),右侧栏只有一个 utils-agents 面板。组件启用/停用、运行状态照常显示。
523
+
524
+ `@xi4z/dsh-utils-ui` 的 `client.js` 用 `ctx.configForms.whileServed(['dsh-approval-policy','dsh-notify','utils-agents'], …)` 把三个宿主的配置页注册到 `plugins.row.config`(key = `@xi4z/dsh-utils#<挂载项 id>`,因为插入这些行的是 bundle 包),并注册 `sidebar.right.pane.tab` 的 utils-agents 面板。三个宿主的配置字段全 volatile,写入走宿主 settings 文档,保存即生效;utils-agents 的仓库设置存在各预设的 `.dsh-utils/repo.json`,Deploy Key 存在 storages,Markdown 直接落盘。
525
+
526
+ ## 组件五(`utils-ui`):共享浏览器界面
527
+
528
+ 宿主半侧只有一个空 `apply()`,价值全在 `client.js`:
529
+
530
+ - 三个宿主行的配置页:`plugins.row.config`,key 是 `@xi4z/dsh-utils#<挂载项 id>`;utils-agents 一页含「递归技能发现 / 模型可见性 / 预设与技能仓库」三块,审批与通知各一页。字段表在 `client.js` 顶部。
531
+ - 右侧栏 `utils-agents` 标签页:注册 tab 类型与 `sidebar.right.pane.tab` 面板体;面板里的路由由 `utils-agents` 宿主行提供。
532
+ - 两套 Deploy Key 的保存/清除、技能仓库配置、版本检查与自动安装都在这个面板里,宿主路由全部在 `@xi4z/dsh-utils-utils-agents`。
536
533
 
537
- 根包的 `client.js` 用 `ctx.configForms.whileServed(['utils-main','dsh-approval-policy','dsh-notify','dsh-skill-panel','utils-agents'], …)` 把五个组件配置页注册到 `plugins.row.config`(key = `@xi4z/dsh-utils#<挂载项 id>`),并注册 `sidebar.right.pane.tab` 的 utils-agents 面板。五个组件的配置字段全 volatile,写入走宿主 settings 文档,保存即生效;utils-agents 的仓库设置存在各预设的 `.dsh-utils/repo.json`,Deploy Key 存在 storages,Markdown 直接落盘。
534
+ 停用 `utils-ui` 只影响界面;宿主行继续工作。
538
535
 
539
536
  ## 包结构
540
537
 
541
538
  ```
542
- @xi4z/dsh-utils/ 唯一的可安装包:bundle + 全部五个组件
543
- ├── package.json bundle patch/locale/icon + subpath exports + dsh.client
544
- ├── pnpm-workspace.yaml 只用来把 packages/* 当 tsc/测试的构建单元
545
- ├── cordis.patch.yml 五行:utils-main(包根)+ 四个 subpath 行
546
- ├── locale/{en,zh}.json bundle 展示名与 utils-main 行标题
539
+ @xi4z/dsh-utils/ 只做拼装的 bundle:patch + locale + icon,无组件代码
540
+ ├── package.json dsh.bundle.patch;dependencies = 四个同版本组件
541
+ ├── pnpm-workspace.yaml 把 packages/* 串成一个 workspace,本地链接同版本组件
542
+ ├── cordis.patch.yml 四行:按裸包名挂四个组件
543
+ ├── locale/{en,zh}.json bundle 展示名
547
544
  ├── icon.svg
548
- ├── skills/dsh-approval-policy-config/SKILL.md
549
- ├── client.js 浏览器半侧:配置页 + 右侧栏 utils-agents 面板
550
- ├── src/{index.ts,ui-host.ts} utils-main:递归发现 + 旧技能仓库路由
551
- ├── lib/… 编译产物(index.js / ui-host.js)
552
- ├── scripts/release.mjs 只发根包,已发布版本跳过
553
- ├── test/ 根包测试(utils-main / ui-host / client / 布局守卫)
554
- └── packages/
555
- ├── approval-policy/ → 导出为 @xi4z/dsh-utils/approval-policy
556
- ├── notify/ → 导出为 @xi4z/dsh-utils/notify
557
- ├── skill-panel/ → 导出为 @xi4z/dsh-utils/skill-panel
558
- └── utils-agents/ → 导出为 @xi4z/dsh-utils/utils-agents
545
+ ├── src/index.ts export {}(构建成 lib/index.js,仅有 main 入口)
546
+ ├── scripts/release.mjs 按依赖顺序发五个包,已发布版本跳过
547
+ ├── test/layout.test.mjs 布局守卫
548
+ └── packages/ 四个独立发布包
549
+ ├── approval-policy/ @xi4z/dsh-utils-approval-policy
550
+ ├── notify/ @xi4z/dsh-utils-notify
551
+ ├── utils-agents/ @xi4z/dsh-utils-utils-agents 行 utils-agents
552
+ │ (嵌套发现 + 可见性 + 预设/仓库/AGENTS.md)
553
+ └── ui/ @xi4z/dsh-utils-ui 行 utils-ui + client.js
559
554
  ```
560
555
 
561
- `packages/<名>/` 仍是标准的插件源码目录(`src/index.ts` + `locale/` + 自己的 `package.json` 供 tsc 与包内测试用),但**不单独发布**:根包的 `exports["./<名>"]` 指向它的 `lib/index.js`,`exports["./<名>/locale/*.json"]` 指向它的 locale,`files` 里的 `packages/*/lib` 与 `packages/*/locale` 负责打进 tarball。加组件=新建 `packages/<名>/`,再在根 `package.json` 加两条 `exports`(入口 + locale)、在 `files` 已覆盖的前提下加一行 patch;`test/layout.test.mjs` 会检查这三处是否对齐。
556
+ `packages/<名>/` 是标准插件包(`src/index.ts` + `locale/` + 自己的 `package.json`),各自 `publishConfig.access = public`、共享根包版本、由 `pnpm release` 单独发布。加组件=新建 `packages/<名>/`,在根 `package.json` 加一条依赖、在 `cordis.patch.yml` 加一行、在 `test/layout.test.mjs` 的 `COMPONENTS` 里登记;只带浏览器半侧的组件还要声明 `dsh.client` 并导出 `./client`。
562
557
 
563
558
  ## 开发
564
559
 
565
560
  ```sh
566
561
  pnpm install
567
- pnpm build # 根包(utils-main)+ packages/* 的 tsc -> lib/
568
- pnpm test # 构建 + client.js 语法检查 + 布局守卫 + 各包 node --test(176 个用例)
562
+ pnpm build # 根包空入口 + packages/* 四个组件
563
+ pnpm test # 构建 + client.js 语法检查 + 布局守卫 + 五个包的 node --test
569
564
  ```
570
565
 
571
566
  ## 兼容性
572
567
 
573
- DeepSeek Harness `0.2.2-rc.1` 及以上。Node.js 22.19 及以上。运行时依赖 `@deepseek-ai/schemastery`;`client.js` 只依赖宿主提供的 React 运行时。utils-agents 面板需要宿主带右侧栏(web 组合默认带)。
568
+ DeepSeek Harness `0.2.2-rc.1` 及以上。Node.js 22.19 及以上。宿主组件运行时依赖 `@deepseek-ai/schemastery`;`@xi4z/dsh-utils-ui` 的 `client.js` 只依赖宿主提供的 React 运行时。utils-agents 面板需要宿主带右侧栏(web 组合默认带)。
574
569
 
575
570
  ## License
576
571
 
package/cordis.patch.yml CHANGED
@@ -1,51 +1,40 @@
1
1
  # dsh-utils — bundle layer for the utility components.
2
2
  #
3
- # Everything ships in ONE package. The root package owns the patch + locale +
4
- # icon + browser bundle (client.js) and the `utils-main` component, and the
5
- # other four components are mounted as **subpath rows** of that same package
6
- # (`@xi4z/dsh-utils/utils-agents`), resolved through this package's `exports`.
7
- # A subpath row is not a package: DSH never reads its `package.json`; its display
8
- # title comes from the exported `./<subpath>/locale/*.json`. The upside is that
9
- # the manifest has no `@xi4z/*` dependencies at all, so the bundle installs from
10
- # a registry, a Git URL, a packed tarball or a local directory alike.
11
- # Because `utils-main` is a package-root row, DSH's client-module scanner also
12
- # serves this package's client.js from it.
3
+ # This package mounts no component of its own: it is the same shape as the
4
+ # shipped experimental bundles. Every component is an independently published
5
+ # package (a real dependency of this bundle), and this patch assembles them:
13
6
  #
14
- # The `packages/` directories stay as build units for tsc and for the per-package
15
- # tests; they are not published.
16
- #
17
- # utils-main — the root package itself: recursive SKILL.md discovery
18
- # in nested skill folders, plus the legacy global
19
- # skill-repository JSON routes (their UI moved into
20
- # utils-agents) and the browser half (client.js).
21
7
  # dsh-approval-policy — unattended approval gate: subagent/scheduled/cron
22
8
  # approval requests wait a bounded window, then settle
23
9
  # with a fail-closed default instead of hanging forever.
24
10
  # dsh-notify — session notifications: a turn ending, a pending
25
11
  # approval, or a pending question is pushed through a
26
12
  # Gotify gateway, tagged with this device's name.
27
- # dsh-skill-panel — settings-page skill switchboard: lists the skills the
28
- # current session can read and hides disabled ones from
29
- # the model catalog while keeping them manually
30
- # invocable.
31
- # utils-agents — the agents/presets panel: registers each
32
- # ~/.dsh/.agent-presets/<id>/ directory as a real
33
- # agent preset through cordis:include, then serves
13
+ # utils-agents — the one host component for skills and presets. It
14
+ # registers each ~/.dsh/.agent-presets/<id>/ directory
15
+ # as a real agent preset through cordis:include, serves
34
16
  # routes that list/toggle its skills, edit its
35
17
  # Markdown, and clone/fast-forward a Git repository
36
- # (public or private, via a Deploy Key) into it.
18
+ # (public or private, via a Deploy Key) into it — and
19
+ # it also owns recursive nested SKILL.md discovery plus
20
+ # the model-facing skill visibility switches, merged
21
+ # from the former utils-main and dsh-skill-panel rows.
22
+ # utils-ui — the browser half shared by every row above: the
23
+ # configuration page for each row and the utils-agents
24
+ # sidebar panel. Its host half is an empty marker; the
25
+ # client module scanner serves its client.js because
26
+ # this row mounts the bare package name.
37
27
  #
38
- # Row ids double as settings namespaces and stay stable.
28
+ # Row ids double as settings namespaces and stay stable. The plugin page keeps
29
+ # addressing each row's configuration as `@xi4z/dsh-utils#<row id>`, because
30
+ # this bundle is the package that inserted the row.
39
31
 
40
32
  - insert:
41
- - id: utils-main
42
- name: '@xi4z/dsh-utils'
43
- config: {}
44
33
  - id: dsh-approval-policy
45
- name: '@xi4z/dsh-utils/approval-policy'
34
+ name: '@xi4z/dsh-utils-approval-policy'
46
35
  config: {}
47
36
  - id: dsh-notify
48
- name: '@xi4z/dsh-utils/notify'
37
+ name: '@xi4z/dsh-utils-notify'
49
38
  config:
50
39
  # 留空 = 内置默认。下面只列出最常改的几项,完整字段见 README。
51
40
  #
@@ -65,13 +54,8 @@
65
54
  - aborted
66
55
  notifyOnApproval: true
67
56
  notifyOnQuestion: true
68
- - id: dsh-skill-panel
69
- name: '@xi4z/dsh-utils/skill-panel'
70
- config:
71
- # 模型技能目录里隐藏的技能名;面板开关写入这里,热生效。
72
- disabledSkills: []
73
57
  - id: utils-agents
74
- name: '@xi4z/dsh-utils/utils-agents'
58
+ name: '@xi4z/dsh-utils-utils-agents'
75
59
  config:
76
60
  # 单文件读写上限(字节)。AGENTS.md 本质上也是提示词,别放太大。
77
61
  maxBytes: 524288
@@ -92,6 +76,19 @@
92
76
  # 新预设技能仓库的默认值。
93
77
  defaultRepoUrl: 'https://github.com/xi4z/skills'
94
78
  defaultBranch: 'Agent'
79
+ # 嵌套 SKILL.md 递归发现(原 utils-main 行)。
80
+ minDepth: 2
81
+ maxDepth: 8
82
+ watch: true
83
+ includeProjectRoots: true
84
+ includeUserRoots: true
85
+ extraRoots: []
86
+ ignoreDirs:
87
+ - .system
88
+ - node_modules
89
+ - .git
90
+ # 模型技能目录里隐藏的技能名(原 dsh-skill-panel 行);仍可手动加载。
91
+ disabledSkills: []
95
92
  # 面板顶部的版本检查:定时查询 npm 上 @xi4z/dsh-utils 的 latest。
96
93
  # 手动「检查更新」按钮不受间隔限制;改镜像时把 updateRegistry 换掉。
97
94
  updateCheck: true
@@ -99,3 +96,5 @@
99
96
  updateRegistry: 'https://registry.npmjs.org'
100
97
  # 查到新版本就后台 pnpm add;装完要重启 dsh web。link:/file: 安装自动跳过。
101
98
  updateAutoInstall: true
99
+ - id: utils-ui
100
+ name: '@xi4z/dsh-utils-ui'
package/lib/index.d.ts CHANGED
@@ -1,69 +1,11 @@
1
1
  /**
2
- * `dsh-utils` main component (`utils-main`): the package root half of the
3
- * bundle, mounted as a normal row by `cordis.patch.yml`.
2
+ * `dsh-utils` bundle layer: a patch-only package.
4
3
  *
5
- * It adds nested `SKILL.md` bundles (depth >= `minDepth`) to the skill catalog,
6
- * leaving depth-1 discovery to the built-in filesystem provider, and owns the
7
- * skill-repository sync routes imported from `./ui-host.js`. The browser half
8
- * (`client.js`) is published by this same package: `utils-main` is a
9
- * package-root row, so the client-module scanner serves it from this row.
4
+ * The bundle itself mounts no component. `cordis.patch.yml` assembles the six
5
+ * independently published component packages, so this module stays empty: the
6
+ * build produces it so the package still exposes a valid `main`, exactly like
7
+ * the shipped experimental bundles.
10
8
  *
11
9
  * @module dsh-utils
12
10
  */
13
- import type { Context } from '@deepseek-ai/cordis';
14
- import z from '@deepseek-ai/schemastery';
15
- export declare const name = "utils-main";
16
- export declare const inject: string[];
17
- /**
18
- * Settings schema. Volatile fields are the only ones DSH exposes in the
19
- * Settings form and the ones the Loader can refresh in place.
20
- */
21
- export declare const Config: z<Schemastery.ObjectS<NoInfer<{
22
- minDepth: z<number, number, "volatile-defined">;
23
- maxDepth: z<number, number, "volatile-defined">;
24
- watch: z<boolean, boolean, "volatile-defined">;
25
- debounceMs: z<number, number, "volatile-defined">;
26
- pollIntervalMs: z<number, number, "volatile-defined">;
27
- includeProjectRoots: z<boolean, boolean, "volatile-defined">;
28
- includeUserRoots: z<boolean, boolean, "volatile-defined">;
29
- followSymlinks: z<boolean, boolean, "volatile-defined">;
30
- extraRoots: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
31
- ignoreDirs: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
32
- }>>, Schemastery.ObjectT<NoInfer<{
33
- minDepth: z<number, number, "volatile-defined">;
34
- maxDepth: z<number, number, "volatile-defined">;
35
- watch: z<boolean, boolean, "volatile-defined">;
36
- debounceMs: z<number, number, "volatile-defined">;
37
- pollIntervalMs: z<number, number, "volatile-defined">;
38
- includeProjectRoots: z<boolean, boolean, "volatile-defined">;
39
- includeUserRoots: z<boolean, boolean, "volatile-defined">;
40
- followSymlinks: z<boolean, boolean, "volatile-defined">;
41
- extraRoots: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
42
- ignoreDirs: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
43
- }>>, "plain">;
44
- /** Volatile Config fields arrive as live references; `.get()` snapshots. */
45
- interface VolatileRef<T> {
46
- get(): T;
47
- }
48
- /** One setting as the Loader supplies it: a live reference, or a plain value in tests. */
49
- type MaybeRef<T> = T | VolatileRef<T>;
50
- /** The runtime shape `apply` receives (every field volatile, every field optional). */
51
- export interface UtilsMainConfig {
52
- readonly minDepth?: MaybeRef<number>;
53
- readonly maxDepth?: MaybeRef<number>;
54
- readonly watch?: MaybeRef<boolean>;
55
- readonly debounceMs?: MaybeRef<number>;
56
- readonly pollIntervalMs?: MaybeRef<number>;
57
- readonly includeProjectRoots?: MaybeRef<boolean>;
58
- readonly includeUserRoots?: MaybeRef<boolean>;
59
- readonly followSymlinks?: MaybeRef<boolean>;
60
- readonly extraRoots?: MaybeRef<readonly string[]>;
61
- readonly ignoreDirs?: MaybeRef<readonly string[]>;
62
- }
63
- /**
64
- * Register the recursive skill provider on the host `skills` registry.
65
- * @param ctx - plugin context carrying the `skills` service.
66
- * @param config - optional row config; see {@link normalizeConfig}.
67
- */
68
- export declare function apply(ctx: Context, config?: UtilsMainConfig): void;
69
11
  export {};