@capyclaw/ppt-suite 2.5.70 → 2.5.72

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 (109) hide show
  1. package/composition.lock.json +27 -27
  2. package/contract/ppt-contract.json +1 -1
  3. package/dsh-suite.json +27 -17
  4. package/node_modules/@capyclaw/asset-service/dsh-suite.json +1 -1
  5. package/node_modules/@capyclaw/asset-service/package.json +1 -1
  6. package/node_modules/@capyclaw/asset-service/src/index.mjs +4 -3
  7. package/node_modules/@capyclaw/document-workbench/package.json +6 -3
  8. package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +56 -3
  9. package/node_modules/@capyclaw/document-workbench/src/client/visibility.mjs +112 -0
  10. package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +6 -4
  11. package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +7 -2
  12. package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +8 -0
  13. package/node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs +17 -10
  14. package/node_modules/@capyclaw/document-workbench/src/store/projection.mjs +39 -0
  15. package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +14 -11
  16. package/node_modules/@capyclaw/editor-host/dsh-suite.json +1 -1
  17. package/node_modules/@capyclaw/editor-host/package.json +1 -1
  18. package/node_modules/@capyclaw/editor-host/src/index.mjs +12 -21
  19. package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
  20. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +3 -1
  21. package/node_modules/@capyclaw/foundation/abi/index.mjs +15 -0
  22. package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
  23. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +21 -4
  24. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +5 -1
  25. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +5 -2
  26. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +4 -0
  27. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +13 -3
  28. package/node_modules/@capyclaw/foundation/package.json +1 -1
  29. package/node_modules/@capyclaw/plugin-kit/package.json +4 -1
  30. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +5 -2
  31. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
  32. package/node_modules/@capyclaw/plugin-kit/src/ledger.mjs +151 -0
  33. package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
  34. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +13 -5
  35. package/node_modules/@capyclaw/portal/package.json +1 -1
  36. package/node_modules/@capyclaw/ppt-editor/app.js +458 -10
  37. package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1 -1
  38. package/node_modules/@capyclaw/ppt-editor/heartbeat-worker.js +5 -2
  39. package/node_modules/@capyclaw/ppt-editor/index.html +4 -0
  40. package/node_modules/@capyclaw/ppt-editor/package.json +2 -2
  41. package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1 -1
  42. package/node_modules/@capyclaw/ppt-skill-api/package.json +1 -1
  43. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
  44. package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1 -1
  45. package/node_modules/@capyclaw/ppt-skill-proposal/package.json +1 -1
  46. package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1 -1
  47. package/node_modules/@capyclaw/ppt-workbench/core/deck-layout.js +3 -1
  48. package/node_modules/@capyclaw/ppt-workbench/core/ops/slide.js +9 -3
  49. package/node_modules/@capyclaw/ppt-workbench/core/text.js +14 -2
  50. package/node_modules/@capyclaw/ppt-workbench/package.json +10 -8
  51. package/node_modules/@capyclaw/ppt-workbench/plugin.mjs +13 -1
  52. package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
  53. package/node_modules/@capyclaw/ppt-workbench/server/embedded-host.mjs +200 -29
  54. package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +10 -7
  55. package/node_modules/@capyclaw/ppt-workbench/server/shared/SHARED_MANIFEST.json +4 -4
  56. package/node_modules/@capyclaw/ppt-workbench/server/store/backends/file-backend.mjs +3 -0
  57. package/node_modules/@capyclaw/ppt-workbench/server/store/checkpoints.mjs +4 -1
  58. package/node_modules/@capyclaw/ppt-workbench/server/store/index.mjs +4 -0
  59. package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +139 -4
  60. package/node_modules/@capyclaw/ppt-workbench/server/store/shape.mjs +37 -0
  61. package/node_modules/@capyclaw/service-broker/README.md +1 -1
  62. package/node_modules/@capyclaw/service-broker/lib/host.mjs +11 -6
  63. package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +13 -5
  64. package/node_modules/@capyclaw/service-broker/package.json +1 -1
  65. package/node_modules/@capyclaw/service-host/dsh-suite.json +1 -1
  66. package/node_modules/@capyclaw/service-host/package.json +2 -2
  67. package/node_modules/@capyclaw/service-host/src/index.mjs +45 -27
  68. package/node_modules/@capyclaw/skills-service/README.md +42 -10
  69. package/node_modules/@capyclaw/skills-service/package.json +6 -3
  70. package/node_modules/@capyclaw/skills-service/server.mjs +129 -51
  71. package/node_modules/@capyclaw/suite-kit/README.md +289 -0
  72. package/node_modules/@capyclaw/suite-kit/bin/dsh-domain.mjs +98 -0
  73. package/node_modules/@capyclaw/suite-kit/bin/dsh-suite.mjs +174 -0
  74. package/node_modules/@capyclaw/suite-kit/client/embed.js +35 -0
  75. package/node_modules/@capyclaw/suite-kit/domain.schema.json +129 -0
  76. package/node_modules/@capyclaw/suite-kit/package.json +58 -0
  77. package/node_modules/@capyclaw/suite-kit/src/activation-registry.mjs +184 -0
  78. package/node_modules/@capyclaw/suite-kit/src/artifacts.mjs +131 -0
  79. package/node_modules/@capyclaw/suite-kit/src/capability.mjs +181 -0
  80. package/node_modules/@capyclaw/suite-kit/src/compose.mjs +201 -0
  81. package/node_modules/@capyclaw/suite-kit/src/domain.mjs +138 -0
  82. package/node_modules/@capyclaw/suite-kit/src/embed.mjs +81 -0
  83. package/node_modules/@capyclaw/suite-kit/src/host.mjs +251 -0
  84. package/node_modules/@capyclaw/suite-kit/src/index.mjs +24 -0
  85. package/node_modules/@capyclaw/suite-kit/src/manifest.mjs +263 -0
  86. package/node_modules/@capyclaw/suite-kit/src/orchestration.mjs +100 -0
  87. package/node_modules/@capyclaw/suite-kit/src/profile.mjs +584 -0
  88. package/node_modules/@capyclaw/suite-kit/src/surface.mjs +28 -0
  89. package/node_modules/@capyclaw/suite-kit/suite.schema.json +128 -0
  90. package/node_modules/@capyclaw/tool-host/dsh-suite.json +1 -1
  91. package/node_modules/@capyclaw/tool-host/lib/host.mjs +15 -4
  92. package/node_modules/@capyclaw/tool-host/package.json +1 -1
  93. package/node_modules/@capyclaw/tool-host/src/index.mjs +19 -5
  94. package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +71 -3
  95. package/node_modules/@capyclaw/work-store/README.md +83 -0
  96. package/node_modules/@capyclaw/work-store/STANDARD.md +263 -0
  97. package/node_modules/@capyclaw/work-store/cordis.patch.yml +3 -0
  98. package/node_modules/@capyclaw/work-store/dsh-suite.json +33 -0
  99. package/node_modules/@capyclaw/work-store/icon.svg +7 -0
  100. package/node_modules/@capyclaw/work-store/lib/host.mjs +21 -0
  101. package/node_modules/@capyclaw/work-store/package.json +68 -0
  102. package/node_modules/@capyclaw/work-store/src/backend.mjs +90 -0
  103. package/node_modules/@capyclaw/work-store/src/db.mjs +199 -0
  104. package/node_modules/@capyclaw/work-store/src/envelope.mjs +132 -0
  105. package/node_modules/@capyclaw/work-store/src/index.mjs +571 -0
  106. package/node_modules/@capyclaw/work-store/src/interop.mjs +70 -0
  107. package/node_modules/@capyclaw/work-store/src/refs.mjs +99 -0
  108. package/node_modules/@capyclaw/work-store/src/routes.mjs +135 -0
  109. package/package.json +16 -14
@@ -1,17 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * capyclaw-skills-service:独立技能服务(服务解耦标准形态)。
3
+ * capyclaw-skills-service:可选的 standalone 技能 HTTP 聚合服务。
4
4
  *
5
- * 职责:把原「ctx.skills 进程内注册表」的技能内容(SKILL.md)搬出 dsh
6
- * 进程,作为独立端口服务对外提供:
5
+ * 定位(P1-10 决策记录):
6
+ * - 技能的标准路径 = skillProvider@1 进程内注册 → DSH 原生 SkillRegistry
7
+ * (ctx.skills)。全部技能包默认走这条路,不经过本服务。
8
+ * - 本服务是可选 standalone 模式:把技能内容(SKILL.md)搬出 dsh 进程,
9
+ * 聚合后经 HTTP 对外提供。**默认不启用**(全仓无 skills.url 配置);
10
+ * 仅当显式给 @capyclaw/service-broker 配置 skills.url 时才拉起本服务,
11
+ * 并由 broker 提供 ctx.skillsHttp 瘦客户端——服务名是 skillsHttp 而非
12
+ * skills,避免遮蔽原生 SkillRegistry(见 broker lib/skills-client.mjs)。
13
+ *
14
+ * HTTP 面:
7
15
  * GET /healthz { ok, service, pid, port, providers, skills }
8
16
  * GET /skills 全量技能清单(汇总各 provider)
9
17
  * GET /skills/:name 单技能正文(原 provider.get 形状)
10
18
  *
11
- * dsh 侧经 @capyclaw/service-broker 的 skills 瘦客户端(ctx.skills)访问本服务。
12
- * 技能数据源 = 各 capyclaw-ppt-skill-* 插件目录(不搬内容,按目录聚合)。
19
+ * 技能数据源 = 套件清单(dsh-suite.json / suite.json / suite-compose.json)里
20
+ * provides.skills 声明的技能包目录。发现只认清单声明,不按目录名前缀猜测
21
+ * (旧 capyclaw-ppt-skill-* 硬编码已去除);不搬内容,按目录聚合。
22
+ * --providers 可显式覆盖发现结果。
13
23
  *
14
- * 由 @capyclaw/service-broker 按清单拉起:
24
+ * 由 @capyclaw/service-broker 按清单拉起(仅启用 standalone 模式时):
15
25
  * { "id": "dsh-skills",
16
26
  * "cmd": ["node", "<本目录>/server.mjs", "--port", "${PORT}"],
17
27
  * "ports": { "main": "auto" },
@@ -51,7 +61,7 @@ function loopback(method, url) {
51
61
 
52
62
  /** 收集技能 provider:每个插件目录含 plugin.mjs(foundation ABI)。
53
63
  * 宿主只提供 ctx.skills,其余能力不承诺——与 dsh 里的装配路径完全一致。 */
54
- async function loadProviders(dirs) {
64
+ export async function loadProviders(dirs) {
55
65
  const providers = []
56
66
  const seen = new Set()
57
67
  for (const dir of dirs) {
@@ -86,32 +96,102 @@ async function loadProviders(dirs) {
86
96
  return providers
87
97
  }
88
98
 
89
- /** 候选技能目录:四种布局都要覆盖。
90
- * dev 树:<repo>/projects/<项目>/artifacts/plugin/capyclaw-ppt-skill-*(构建产物目录)。
91
- * npm 扁平安装:node_modules/@capyclaw/ppt-skill-*——父目录本身就是 @capyclaw
92
- * 作用域目录,ppt-skill-* 是它的直接子项。
93
- * pnpm 提升可见时:<profile>/node_modules/@capyclaw/ppt-skill-*(同上)。
94
- * pnpm 严格布局:本包真实路径在 <profile>/node_modules/.pnpm/<pkg>/node_modules/@capyclaw/skills-service,
95
- * 上溯 4 级是 .pnpm;技能包以虚拟目录 @capyclaw+ppt-skill-<x>@<ver> 平铺在 .pnpm 下,
96
- * 每个虚拟目录的真实树在其 node_modules/@capyclaw/ 里。 */
97
-
98
- /** dev 树里的技能包根:仓库根 A/projects/<项目>/artifacts/plugin(每个项目一个,互不混放)。 */
99
- function devPluginRoots() {
99
+ /** 套件清单文件名(与 @capyclaw/suite-kit 的清单方言一致):
100
+ * dsh-suite.json / suite.json = 单套件清单,packages 为「包名 → entry」对象;
101
+ * suite-compose.json = composeToDir 的组合结果快照,packages 为
102
+ * [{name, entry, suite, dir, file}] 数组,entry.path 相对 dir 解析。
103
+ * 技能包 = entry.provides.skills 为非空字符串数组的条目(role:'skills' 是
104
+ * 约定,但发现只认 provides.skills 声明本身,不认目录名)。 */
105
+ const SUITE_FILENAMES = ['dsh-suite.json', 'suite.json', 'suite-compose.json']
106
+
107
+ /** dev 树里的清单搜索根:项目根目录(rsp/conductor/capyclaw 的清单在项目根)
108
+ * 与各项目 artifacts/plugin(ppt/canvas/browser/wall 的成品套件包在其下一层)。 */
109
+ export function devManifestRoots() {
100
110
  const projectsDir = path.resolve(HERE, '..', '..', '..', 'A', 'projects')
101
111
  const out = []
102
112
  let entries = []
103
113
  try { entries = fs.readdirSync(projectsDir, { withFileTypes: true }) } catch { return out }
104
114
  for (const entry of entries) {
105
115
  if (!entry.isDirectory()) continue
106
- const root = path.join(projectsDir, entry.name, 'artifacts', 'plugin')
107
- if (fs.existsSync(root)) out.push(root)
116
+ const proj = path.join(projectsDir, entry.name)
117
+ out.push(proj)
118
+ const artifacts = path.join(proj, 'artifacts', 'plugin')
119
+ if (fs.existsSync(artifacts)) out.push(artifacts)
108
120
  }
109
121
  return out
110
122
  }
111
123
 
112
- function defaultProviderDirs() {
124
+ /** 收集一个根下的套件清单文件:根本身、直接子目录、@capyclaw 作用域下一层、
125
+ * pnpm 虚拟目录(@capyclaw+<name>@<ver> → 真实树 <dir>/node_modules/@capyclaw/<name>)。
126
+ * 覆盖 dev 产物目录 / npm 扁平安装 / pnpm 提升 / pnpm 严格布局四种形态。 */
127
+ export function manifestsUnder(root) {
128
+ const files = []
129
+ const addDir = (dir) => {
130
+ for (const name of SUITE_FILENAMES) {
131
+ const f = path.join(dir, name)
132
+ if (fs.existsSync(f)) files.push(f)
133
+ }
134
+ }
135
+ addDir(root)
136
+ let entries = []
137
+ try { entries = fs.readdirSync(root, { withFileTypes: true }) } catch { return files }
138
+ for (const e of entries) {
139
+ if (!e.isDirectory()) continue
140
+ const dir = path.join(root, e.name)
141
+ if (e.name === '@capyclaw') {
142
+ let scoped = []
143
+ try { scoped = fs.readdirSync(dir, { withFileTypes: true }) } catch { continue }
144
+ for (const s of scoped) if (s.isDirectory()) addDir(path.join(dir, s.name))
145
+ } else if (e.name.startsWith('@capyclaw+') && e.name.includes('@', '@capyclaw+'.length)) {
146
+ const base = e.name.slice('@capyclaw+'.length).split('@')[0]
147
+ addDir(path.join(dir, 'node_modules', '@capyclaw', base))
148
+ } else {
149
+ addDir(dir)
150
+ }
151
+ }
152
+ return files
153
+ }
154
+
155
+ /** npm 解析风格的声明(entry 无 path):从清单目录逐级上溯找 node_modules/<包名>。 */
156
+ export function resolveInstalled(name, fromDir) {
157
+ let cur = path.resolve(fromDir)
158
+ for (;;) {
159
+ const cand = path.join(cur, 'node_modules', ...name.split('/'))
160
+ if (fs.existsSync(path.join(cand, 'package.json'))) return cand
161
+ const parent = path.dirname(cur)
162
+ if (parent === cur) return null
163
+ cur = parent
164
+ }
165
+ }
166
+
167
+ /** 从一份清单提取技能包目录:只认 provides.skills 非空的 entry,
168
+ * 目录按 entry.path 解析(绝对路径直接用,相对路径相对清单目录)。 */
169
+ export function skillDirsFromManifest(file) {
170
+ let manifest
171
+ try { manifest = JSON.parse(fs.readFileSync(file, 'utf8')) } catch { return [] }
172
+ const dirs = []
173
+ const consider = (name, entry, baseDir) => {
174
+ const declared = entry?.provides?.skills
175
+ if (!Array.isArray(declared) || declared.length === 0) return
176
+ const dir = entry.path
177
+ ? (path.isAbsolute(entry.path) ? entry.path : path.resolve(baseDir, entry.path))
178
+ : resolveInstalled(name, baseDir)
179
+ if (dir && fs.existsSync(dir)) dirs.push(dir)
180
+ }
181
+ if (Array.isArray(manifest.packages)) {
182
+ // suite-compose.json:dir 是原清单目录(entry.path 的解析基准)
183
+ for (const p of manifest.packages) consider(p.name, p.entry, p.dir || path.dirname(file))
184
+ } else if (manifest.packages && typeof manifest.packages === 'object') {
185
+ for (const [name, entry] of Object.entries(manifest.packages)) consider(name, entry, path.dirname(file))
186
+ }
187
+ return dirs
188
+ }
189
+
190
+ /** 默认发现:dev 树 + 本包周边安装布局里找套件清单 → 收 provides.skills 声明的目录。
191
+ * 不再按 capyclaw-ppt-skill-* 等目录名前缀猜测(P1-10:通用化,任何套件声明的技能都认)。 */
192
+ export function defaultProviderDirs() {
113
193
  const roots = [
114
- ...devPluginRoots(),
194
+ ...devManifestRoots(),
115
195
  path.resolve(HERE, '..'),
116
196
  path.resolve(HERE, '..', '..'),
117
197
  path.resolve(HERE, '..', '..', 'node_modules'),
@@ -119,33 +199,20 @@ function defaultProviderDirs() {
119
199
  path.resolve(HERE, 'node_modules'),
120
200
  path.resolve(HERE, '..', '..', '..', '..'),
121
201
  ]
202
+ const manifests = new Set()
203
+ for (const root of roots) {
204
+ for (const file of manifestsUnder(root)) manifests.add(path.resolve(file))
205
+ }
122
206
  const seen = new Set()
123
207
  const dirs = []
124
- const add = (dir) => {
125
- const key = path.resolve(dir)
126
- if (!seen.has(key)) { seen.add(key); dirs.push(key) }
127
- }
128
- for (const root of roots) {
129
- let entries = []
130
- try { entries = fs.readdirSync(root, { withFileTypes: true }) } catch { continue }
131
- for (const e of entries) {
132
- if (!e.isDirectory()) continue
133
- // dev 目录名 capyclaw-ppt-skill-* 与安装态 @capyclaw/ppt-skill-* 都认(后者在作用域目录下出现)
134
- if (e.name.startsWith('capyclaw-ppt-skill-') || (root.endsWith('@capyclaw') && e.name.startsWith('ppt-skill-'))) {
135
- add(path.join(root, e.name))
136
- } else if (e.name === '@capyclaw') {
137
- // 作用域目录:扫一层,收 ppt-skill-*
138
- let scoped = []
139
- try { scoped = fs.readdirSync(path.join(root, e.name), { withFileTypes: true }) } catch { continue }
140
- for (const s of scoped) {
141
- if (s.isDirectory() && s.name.startsWith('ppt-skill-')) add(path.join(root, e.name, s.name))
142
- }
143
- } else if (e.name.startsWith('@capyclaw+ppt-skill-') && e.name.includes('@', '@capyclaw+ppt-skill-'.length)) {
144
- // pnpm 虚拟目录:@capyclaw+ppt-skill-<x>@<version> → 真实树在 <dir>/node_modules/@capyclaw/<x>
145
- const base = e.name.slice('@capyclaw+'.length).split('@')[0]
146
- const real = path.join(root, e.name, 'node_modules', '@capyclaw', base)
147
- if (fs.existsSync(path.join(real, 'package.json'))) add(real)
148
- }
208
+ for (const file of manifests) {
209
+ const found = skillDirsFromManifest(file)
210
+ if (found.length) {
211
+ console.log(`[dsh-skills] 清单 ${path.basename(path.dirname(file))}/${path.basename(file)} → ${found.length} 个技能包`)
212
+ }
213
+ for (const dir of found) {
214
+ const key = path.resolve(dir).toLowerCase()
215
+ if (!seen.has(key)) { seen.add(key); dirs.push(path.resolve(dir)) }
149
216
  }
150
217
  }
151
218
  return dirs
@@ -231,7 +298,18 @@ async function main() {
231
298
  process.on('SIGTERM', shutdown)
232
299
  }
233
300
 
234
- main().catch((err) => {
235
- console.error('[dsh-skills] 启动失败:', err.message)
236
- process.exit(1)
237
- })
301
+ /* 主模块判定:直接 node server.mjs(含 pnpm 符号链接路径)才启动 HTTP 服务;
302
+ * 被测试/工具 import 时只暴露发现函数,不起服务。 */
303
+ const isMain = (() => {
304
+ try {
305
+ return Boolean(process.argv[1])
306
+ && fs.realpathSync(path.resolve(process.argv[1])) === fs.realpathSync(fileURLToPath(import.meta.url))
307
+ } catch { return false }
308
+ })()
309
+
310
+ if (isMain) {
311
+ main().catch((err) => {
312
+ console.error('[dsh-skills] 启动失败:', err.message)
313
+ process.exit(1)
314
+ })
315
+ }
@@ -0,0 +1,289 @@
1
+ # @capyclaw/suite-kit(DSH 组合标准件)
2
+
3
+ 把“多个插件 + 一组 patch 行 + 健康检查 + 安装脚本”收成一个可校验、可组合、可诊断的标准件。
4
+
5
+ ## 一个 suite 的最小结构
6
+
7
+ ```text
8
+ my-suite/
9
+ ├─ package.json # dsh.bundle.patch -> cordis.patch.yml, dsh.suite -> dsh-suite.json
10
+ ├─ dsh-suite.json # 唯一真源:packages / rows / checks
11
+ ├─ cordis.patch.yml # 由 rows 生成,不手写
12
+ └─ lib/index.mjs # 可选:组合包自身的空实现
13
+ ```
14
+
15
+ `dsh-suite.json`:
16
+
17
+ ```json
18
+ {
19
+ "name": "my-suite",
20
+ "version": "1.0.0",
21
+ "title": "我的组合",
22
+ "packages": {
23
+ "my-plugin": {
24
+ "role": "runtime",
25
+ "version": "^1.0.0",
26
+ "path": "./plugins/my-plugin",
27
+ "provides": { "tools": ["my_*"], "ports": ["<port>"] }
28
+ }
29
+ },
30
+ "rows": [
31
+ { "id": "my-host", "name": "my-plugin" }
32
+ ],
33
+ "checks": [
34
+ { "id": "health", "type": "http", "url": "http://127.0.0.1:<port>/healthz", "expectStatus": 200 }
35
+ ]
36
+ }
37
+ ```
38
+
39
+ ## 两种组合粒度
40
+
41
+ ### Suite(组件集合)
42
+
43
+ 一个 suite 描述一组插件包和 patch 行。适合“一个产品/一个套件”。
44
+
45
+ suite 可以用 `components` 引用其他 suite,而不是复制它们的 C/packages/rows:
46
+
47
+ ```json
48
+ {
49
+ "name": "my-suite",
50
+ "components": ["../../packages/capyclaw-service-host", "../../packages/capyclaw-tool-host"],
51
+ "packages": { "my-plugin": { "role": "runtime", "version": "^1.0.0", "path": "../my-plugin" } },
52
+ "rows": [{ "id": "my-host", "name": "my-plugin" }]
53
+ }
54
+ ```
55
+
56
+ `loadSuiteManifest()` 会展开组件,并把组件行排在功能插件行之前,保证 `ctx.*`
57
+ 在功能插件 `apply()` 时已经就绪。`stageDomain` 会把展开后的 manifest 写入 staged
58
+ 组件,目录统一为 `components/<packageName>`。
59
+
60
+ ### Domain(领域包 / 启动单位)
61
+
62
+ 一个 domain 只选择某个工作领域需要的 suite,并生成独立 profile:
63
+
64
+ ```text
65
+ domain.json
66
+ components: [../ppt-suite, ../canvas-suite]
67
+ baseBundles: [dsh-base, dsh-web-app]
68
+ profile: { name: domain-ppt, port: 3080 }
69
+ ```
70
+
71
+ 启动时只加载 base + web-app + 选中的 suite;未选中的插件、skill、MCP 不注册。`stage` 只复制选中组件,形成一个可带走的领域包。
72
+
73
+ ## CLI
74
+
75
+ ```bash
76
+ dsh-suite validate ./my-suite
77
+ dsh-suite compose ./ppt-suite ./canvas-suite --out ./composed
78
+ dsh-suite install ./ppt-suite ./canvas-suite --profile web
79
+ dsh-suite doctor --profile web --dsh-bin /path/to/dsh
80
+ dsh-suite init ./new-suite --name my-suite --title "我的组合"
81
+
82
+ dsh-domain validate ./my-domain
83
+ dsh-domain resolve ./my-domain
84
+ dsh-domain install ./my-domain --profile domain-my --dsh-home ~/.dsh
85
+ dsh-domain stage ./my-domain --out ./dist/my-domain
86
+
87
+ # 直接启动需要处理 dsh 的登录 token;桌面/本地推荐走 auth-proxy 零登录
88
+ dsh-domain launch ./my-domain --auth-proxy /path/to/auth-proxy.mjs --port 3090 --proxy-port 3091
89
+
90
+ # 推荐:每个 DSH 进程一个 runtime(独立端口/目录/namespace)
91
+ dsh-runtime create --name my-runtime --domain ./my-domain
92
+ dsh-runtime start <runtimeId>
93
+ dsh-runtime list
94
+ dsh-runtime works <runtimeId>
95
+ dsh-runtime declare <runtimeId> main --files "state.json,journal.jsonl,checkpoints/**" --no-new
96
+ dsh-runtime stop <runtimeId>
97
+ ```
98
+
99
+ ## Runtime(统一中间层的启动单位)
100
+
101
+ `@capyclaw/suite-kit` 是统一中间层:它同时负责“打包哪些插件、分配哪些端口、
102
+ 创建哪个 runtime、这个 runtime 声明需要哪些工具/能力、工作范围多大、
103
+ 文件归属和生命周期”。
104
+
105
+ 每个 runtime 获得:
106
+
107
+ - `harness` 端口:浏览器访问 DSH 的入口;
108
+ - `dsh` 端口:auth-proxy 后面的 DSH 上游端口;
109
+ - `content` 端口:作品/编辑器的显示端口;
110
+ - 独立 `DSH_HOME`、profile、workspace、日志、临时目录、auth-proxy 锁;
111
+ - 独立 Content Store namespace token。
112
+
113
+ 启动声明写在 `dsh-domain.json` 的 `runtime` 段:
114
+
115
+ ```json
116
+ {
117
+ "runtime": {
118
+ "driver": "node",
119
+ "workId": "main",
120
+ "bindings": [
121
+ {
122
+ "row": "ppt-workbench-host",
123
+ "config": {
124
+ "port": "${ports.content}",
125
+ "hostDir": "${paths.contentState}",
126
+ "strictPort": true,
127
+ "workId": "${workId}"
128
+ }
129
+ }
130
+ ],
131
+ "env": {
132
+ "PPT_BRIDGE_HOME": "${paths.contentState}"
133
+ },
134
+ "model": {
135
+ "id": "llm-deepseek",
136
+ "plugin": "@deepseek-ai/dsh-llm-deepseek-api-key",
137
+ "apiKeyEnv": "DEEPSEEK_API_KEY",
138
+ "baseURL": "https://api.deepseek.com/anthropic"
139
+ },
140
+ "requires": {
141
+ "tools": ["ppt_*"],
142
+ "capabilities": ["ppt.runtime@^2.2.0"],
143
+ "services": ["ppt-workbench"]
144
+ },
145
+ "scope": {
146
+ "sessions": { "path": ".dsh/sessions", "isolated": true },
147
+ "files": [
148
+ { "id": "workspace", "kind": "workspace", "path": "workspace", "patterns": ["**"] },
149
+ { "id": "ppt", "kind": "content", "path": "content/ppt", "patterns": ["state.json", "journal.jsonl", "checkpoints/**"] }
150
+ ],
151
+ "workspace": {
152
+ "workId": "main",
153
+ "files": ["state.json", "journal.jsonl", "checkpoints/**"],
154
+ "allowNew": false
155
+ },
156
+ "network": { "bind": ["127.0.0.1"], "outbound": "none" }
157
+ },
158
+ "ports": {
159
+ "harness": { "preferred": 3080, "range": 100 },
160
+ "content": { "preferred": "<port>", "range": 100 }
161
+ }
162
+ }
163
+ }
164
+ ```
165
+
166
+ `dsh-runtime create` 在分配端口之前先校验 `requires`;`scope.workspace`
167
+ 会变成该 work 的 `manifest.json.declaration`,后续写入由中间层校验。
168
+ `scope.sessions` 和 `scope.files` 会解析成 `runtime.json.paths` /
169
+ `runtime.json.storage` 里的绝对路径:会话记录落在该 runtime 的
170
+ `DSH_HOME/sessions`,修改文件落在声明的 files 根目录内。
171
+ `bindings` 按 row/package 注入端口、目录、workId 等模板值,通用层不认具体插件名。
172
+ `env` 可按 runtime 注入插件兼容环境变量。`model` 会生成 runtime 自己的 `DSH_HOME/cordis.patch.yml` 模型通道,
173
+ 避免把用户的全局模型配置带进 runtime;`workspaceController` 会把
174
+ DSH 默认 workspace 固定到该 runtime 的 workspace 根目录下。
175
+ `declare` 命令可以在运行时调整声明:
176
+
177
+ ```bash
178
+ dsh-runtime works <runtimeId>
179
+ dsh-runtime declare <runtimeId> main --files "state.json,journal.jsonl,checkpoints/**" --no-new
180
+ ```
181
+
182
+ 同一个 runtime 内的多个会话共享同一个 work(例如 `main`);不同 runtime 即使
183
+ 使用相同 `workId` 也互相隔离。
184
+
185
+ 所有落盘文件都在同一个 `DSH_STORE_ROOT`(默认 `~/.dsh-store`):
186
+
187
+ ```text
188
+ <storeRoot>/
189
+ ├─ objects/<aa>/<sha256> # 纯对象仓库(不关心文件关系)
190
+ ├─ workspaces/<runtimeId>/<workId>/manifest.json # 中间层:文件关系/版本/归属
191
+ ├─ catalog/works.json # 供 UI / 生命周期管理读取的作品目录
192
+ ├─ namespaces/<runtimeId>.json # token 哈希 / TTL
193
+ ├─ runtimes/<runtimeId>/ # DSH_HOME、workspace、日志、锁、runtime.json
194
+ └─ registry.json # 端口租约
195
+ ```
196
+
197
+ `objects/` 只负责存字节;`workspaces/` 和 `catalog/` 是中间层,负责“哪些文件属于同一个作品、谁能修改、版本和生命周期”。`catalog/works.json` 是展示索引,采用最终一致性刷新,不作为热路径事务日志。
198
+
199
+ `runtime.driver` 预留 `node`(L1 逻辑隔离)、`jobobject`、`docker`、`wsl`;
200
+ 需要真正的文件/网络强隔离时接 L2/L3 driver。
201
+
202
+ ## 组合规则
203
+
204
+ - `components`:先展开组件 suite 的 C/packages/rows/checks,再合并本 suite;组件行优先。
205
+ - `packages`:同名包版本/role 必须一致;`provides` 合并去重。
206
+ - 能力(capability):`provides.capabilities` 声明“我提供什么”,`requires.capabilities` 声明“我需要什么”;组合时解析 provider,缺失或不兼容会报错。
207
+ - 例如 `dsh-ppt-skills` 只依赖 `ppt.runtime@^2`,不依赖某个具体 workbench 包,因此可以替换实现。
208
+ - `rows`:同 id 同 name/config 自动去重;不同则报冲突(除非 `allowOverride`)。
209
+ - 端口:同一个端口被不同包声明 → 冲突。
210
+ - 工具名:精确重名 → 冲突;多个通配工具面 → 告警。
211
+ - `checks`:同 id 去重;不同则冲突。
212
+
213
+ ## 安装规则
214
+
215
+ - profile 里只把 suite 包作为 `link:` 依赖;子包通过 junction 放进 `node_modules`,不进入 profile 的 `dependencies`。
216
+ - `dsh.profile.bundles` 只列 suite 名;suite patch 负责插入子包的行。
217
+ - 重复安装时按 `dshSuiteKit.managedPackages` 清理旧链接,避免残留。
218
+ - `doctor` 会检查:suite manifest、子包存在性、HTTP 健康、MCP contract major、组合后 row id 重复。
219
+
220
+ ## 从 domain 构建 bundle
221
+
222
+ `scripts/build-bundle.mjs` 直接使用本包的 `resolveDomain` / `stageDomain`:
223
+
224
+ ```bash
225
+ node scripts/build-bundle.mjs \
226
+ --domain A/projects/canvas/domains/canvas \
227
+ --out builds/ppt --target portable
228
+ ```
229
+
230
+ 生成的 bundle 内含 `domain/`(组件 + kit + domain.json)、`setup.mjs` 和启动脚本。
231
+ `setup.mjs` 调用 `installDomain({ runPnpm: false })`,在 bundle 自带的
232
+ `DSH_HOME` 下建立 profile 和组件链接,不依赖 pnpm,也不写用户主目录。
233
+
234
+ ## 双重身份:构建期库 + 运行时库(P2-12 决策记录)
235
+
236
+ 这个包同时是**构建期库**(suite/domain 清单 validate/compose/profile)与**运行时库**
237
+ (orchestration 闸/Mandate/事件/步骤、embed 握手、surface 挂载)。两类模块同包共存,
238
+ 但依赖方向严格单向:**运行时模块绝不 import 构建期模块**。
239
+
240
+ ### 构建期模块(清单校验 / 组合 / 安装,构建与安装期执行)
241
+
242
+ | 子路径 | 模块 | 职责 |
243
+ | --- | --- | --- |
244
+ | `@capyclaw/suite-kit/manifest` | `src/manifest.mjs` | suite/domain 清单读取与静态校验(`loadSuiteManifest`) |
245
+ | `@capyclaw/suite-kit/compose` | `src/compose.mjs` | 套件组合、冲突检测、`renderCordisPatch`、`composeToDir` |
246
+ | `@capyclaw/suite-kit/profile` | `src/profile.mjs` | profile 生成/安装(`installSuites`)、`doctor` 诊断 |
247
+ | `@capyclaw/suite-kit/domain` | `src/domain.mjs` | 领域解析(`resolveDomain`)与 staging(`stageDomain`) |
248
+ | `@capyclaw/suite-kit/artifacts` | `src/artifacts.mjs` | 版本化 artifact store:打包/回滚 |
249
+ | 仅根入口导出 | `src/activation-registry.mjs` | 安装期编译 launch-engine 激活注册表(无独立子路径) |
250
+ | `dsh-suite` / `dsh-domain` | `bin/` | CLI 入口 |
251
+ | `@capyclaw/suite-kit/schema` / `./domain-schema` | 两个 JSON Schema | 清单 schema |
252
+
253
+ 构建期内部依赖:`profile → compose / manifest / artifacts / activation-registry`,
254
+ `compose → manifest`,`domain → compose / manifest`。
255
+
256
+ ### 运行时模块(宿主无关的协议原语,被套件工作台在运行时 import)
257
+
258
+ | 子路径 | 模块 | 职责 | 现有消费者(grep 实证) |
259
+ | --- | --- | --- | --- |
260
+ | `@capyclaw/suite-kit/capability` | `src/capability.mjs` | 能力描述符词表/校验/匹配/发现(纯函数,无内部依赖) | capyclaw/rsp/conductor 工作台 `lib/host.mjs` |
261
+ | `@capyclaw/suite-kit/orchestration` | `src/orchestration.mjs` | 确认闸 `evaluateGate`、Mandate、事件、步骤原语(仅依赖 `node:crypto`) | conductor 工作台 `lib/engine.mjs`、`lib/plan-store.mjs` |
262
+ | `@capyclaw/suite-kit/embed` | `src/embed.mjs` | 嵌入握手协议原语(无内部依赖) | `surface.mjs` 与浏览器侧客户端 |
263
+ | `@capyclaw/suite-kit/surface` | `src/surface.mjs` | `attachSurface`:挂 `GET /embed.js` 与 `/api/surface`(import `./embed.mjs`) | capyclaw/rsp/conductor 工作台 `lib/workbench.mjs`、B/official/capyclaw-offline-ddr0 |
264
+ | `@capyclaw/suite-kit/client/embed.js` | `client/embed.js` | 浏览器侧握手客户端(经 surface 分发) | 嵌入页面 |
265
+
266
+ ### 依赖方向与使用约定
267
+
268
+ - 运行时模块(capability/orchestration/embed/surface/client)绝不 import 构建期模块;
269
+ 运行时内部唯一依赖是 `surface → embed`。
270
+ - 根入口 `export *` 同时导出两类模块:构建脚本 import 根入口会连带拉入运行时件
271
+ (均为纯函数、无副作用,不会触发安装逻辑);**运行时消费者应优先走子路径**,
272
+ 避免把构建期代码拉进运行时依赖图。
273
+
274
+ ### 为什么暂不拆包(决策记录)
275
+
276
+ 拆成 `suite-kit-build` / `suite-kit-runtime` 两个包会破坏既有项目的 import 面
277
+ (架构审查 M7/P2-12 统计涉及 9 个项目;本轮 grep 实证至少包括 A/projects 的
278
+ capyclaw/rsp/conductor 工作台、A/build 构建脚本、B/official/capyclaw-offline-ddr0、
279
+ C/tools/capyclaw-plugin-generator),所有消费者都要同步改 import 与依赖声明。
280
+ 而两类模块已按子路径隔离、依赖方向单向,实际耦合成本低。**收益不抵成本,暂不拆包**,
281
+ 改为以本节 + package.json description + 主入口头注释显式文档化双重身份。
282
+ 将来若确需拆包,应先把所有消费者迁到子路径 import,再做物理拆分。
283
+
284
+ ## 设计边界
285
+
286
+ - 这个包不是 DSH 运行时插件,不会出现在 agent 工具面里;但它有**双重身份**——
287
+ 构建期库 + 运行时库(运行时协议原语被套件工作台 import),见上节「双重身份」。
288
+ - 组合层不替子包做业务;它只负责“谁和谁一起跑、怎么验证、冲突在哪”。
289
+ - 运行时通信用 Cordis service / MCP / HTTP;suite-kit 不创建跨进程总线。
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * dsh-domain CLI:
4
+ * dsh-domain validate <domain>
5
+ * dsh-domain resolve <domain>
6
+ * dsh-domain registry <domain>
7
+ * dsh-domain doctor --profile name [--dsh-bin path]
8
+ */
9
+ import {
10
+ buildActivationRegistry, doctor, formatReport, loadDomainManifest,
11
+ resolveDomain, validateDomainManifest,
12
+ } from '../src/index.mjs'
13
+
14
+ function parse(argv) {
15
+ const args = []
16
+ const flags = {}
17
+ for (let i = 0; i < argv.length; i++) {
18
+ const item = argv[i]
19
+ if (!item.startsWith('--')) { args.push(item); continue }
20
+ const key = item.slice(2)
21
+ const next = argv[i + 1]
22
+ if (next && !next.startsWith('--')) { flags[key] = next; i++ }
23
+ else flags[key] = true
24
+ }
25
+ return { args, flags }
26
+ }
27
+
28
+ function fail(message) {
29
+ console.error(`✗ ${message}`)
30
+ process.exit(1)
31
+ }
32
+
33
+ function cmdValidate(input) {
34
+ if (!input) fail('用法: dsh-domain validate <domain>')
35
+ const loaded = loadDomainManifest(input)
36
+ const result = validateDomainManifest(loaded.manifest)
37
+ for (const warning of result.warnings) console.log(`! ${warning}`)
38
+ for (const error of result.errors) console.log(`✗ ${error}`)
39
+ console.log(result.ok ? `✓ ${loaded.manifest.name}` : '✗ domain 校验失败')
40
+ process.exit(result.ok ? 0 : 1)
41
+ }
42
+
43
+ function cmdResolve(input) {
44
+ if (!input) fail('用法: dsh-domain resolve <domain>')
45
+ const resolved = resolveDomain(input)
46
+ console.log(JSON.stringify({
47
+ domain: resolved.manifest.name,
48
+ components: resolved.suites.map((suite) => suite.manifest.name),
49
+ capabilities: resolved.composed.capabilities,
50
+ rows: resolved.composed.rows,
51
+ checks: resolved.composed.checks,
52
+ warnings: resolved.composed.warnings,
53
+ }, null, 2))
54
+ }
55
+
56
+ function cmdRegistry(input) {
57
+ if (!input) fail('用法: dsh-domain registry <domain>')
58
+ try {
59
+ const resolved = resolveDomain(input)
60
+ const { registry, warnings } = buildActivationRegistry({
61
+ suites: resolved.suites,
62
+ composed: resolved.composed,
63
+ requiredCapabilities: resolved.manifest.runtime?.requires?.capabilities || [],
64
+ })
65
+ for (const warning of warnings) console.error(`! ${warning}`)
66
+ console.log(JSON.stringify(registry, null, 2))
67
+ } catch (error) {
68
+ fail(error.message)
69
+ }
70
+ }
71
+
72
+ async function cmdDoctor(flags) {
73
+ const report = await doctor({
74
+ profile: flags.profile,
75
+ dshHome: flags['dsh-home'],
76
+ dshBin: flags['dsh-bin'],
77
+ })
78
+ console.log(formatReport(report))
79
+ process.exitCode = report.ok ? 0 : 1
80
+ }
81
+
82
+ const { args, flags } = parse(process.argv.slice(2))
83
+ const [command] = args
84
+ if (!command || command === 'help' || command === '--help') {
85
+ console.log(`dsh-domain — 领域包校验器
86
+
87
+ validate <domain> 校验 domain manifest
88
+ resolve <domain> 解析组件/能力/row
89
+ registry <domain> 生成 launch-engine 激活注册表(预览)
90
+ doctor --profile name 运行健康检查
91
+ `)
92
+ process.exit(0)
93
+ }
94
+ if (command === 'validate') cmdValidate(args[1])
95
+ else if (command === 'resolve') cmdResolve(args[1])
96
+ else if (command === 'registry') cmdRegistry(args[1])
97
+ else if (command === 'doctor') await cmdDoctor(flags)
98
+ else fail(`未知命令: ${command}`)