@capyclaw/publisher 0.1.0 → 0.1.3

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 (376) hide show
  1. package/README.md +77 -2
  2. package/client/client.js +717 -0
  3. package/cordis.patch.yml +4 -15
  4. package/icon.svg +6 -0
  5. package/locale/en.json +6 -0
  6. package/locale/zh.json +6 -0
  7. package/node_modules/@capyclaw/foundation/README.md +51 -0
  8. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
  9. package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
  10. package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
  11. package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
  12. package/node_modules/@capyclaw/foundation/abi/loader.mjs +345 -0
  13. package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
  14. package/node_modules/@capyclaw/foundation/abi/spec.mjs +255 -0
  15. package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
  16. package/node_modules/@capyclaw/foundation/abi/version.mjs +82 -0
  17. package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
  18. package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
  19. package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
  20. package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
  21. package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
  22. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
  23. package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
  24. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +68 -0
  25. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +113 -0
  26. package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
  27. package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
  28. package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
  29. package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
  30. package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
  31. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
  32. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
  33. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
  34. package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +160 -0
  35. package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
  36. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
  37. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +87 -0
  38. package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
  39. package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
  40. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +188 -0
  41. package/node_modules/@capyclaw/foundation/package.json +53 -0
  42. package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
  43. package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
  44. package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
  45. package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
  46. package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
  47. package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
  48. package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
  49. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
  50. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +139 -0
  51. package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
  52. package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
  53. package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
  54. package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
  55. package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
  56. package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
  57. package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
  58. package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
  59. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
  60. package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
  61. package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
  62. package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
  63. package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
  64. package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
  65. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
  66. package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
  67. package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
  68. package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
  69. package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
  70. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
  71. package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
  72. package/node_modules/@capyclaw/plugin-validator/bin/cli.mjs +49 -0
  73. package/node_modules/@capyclaw/plugin-validator/lib/index.mjs +303 -0
  74. package/node_modules/@capyclaw/plugin-validator/package.json +28 -0
  75. package/node_modules/@capyclaw/tool-host/README.md +56 -0
  76. package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
  77. package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
  78. package/node_modules/@capyclaw/tool-host/lib/host.mjs +16 -0
  79. package/node_modules/@capyclaw/tool-host/package.json +59 -0
  80. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
  81. package/node_modules/@capyclaw/tool-host/src/index.mjs +416 -0
  82. package/node_modules/semver/LICENSE +15 -0
  83. package/node_modules/semver/README.md +680 -0
  84. package/node_modules/semver/bin/semver.js +195 -0
  85. package/node_modules/semver/classes/comparator.js +143 -0
  86. package/node_modules/semver/classes/index.js +7 -0
  87. package/node_modules/semver/classes/range.js +577 -0
  88. package/node_modules/semver/classes/semver.js +350 -0
  89. package/node_modules/semver/functions/clean.js +8 -0
  90. package/node_modules/semver/functions/cmp.js +54 -0
  91. package/node_modules/semver/functions/coerce.js +62 -0
  92. package/node_modules/semver/functions/compare-build.js +9 -0
  93. package/node_modules/semver/functions/compare-loose.js +5 -0
  94. package/node_modules/semver/functions/compare.js +7 -0
  95. package/node_modules/semver/functions/diff.js +60 -0
  96. package/node_modules/semver/functions/eq.js +5 -0
  97. package/node_modules/semver/functions/gt.js +5 -0
  98. package/node_modules/semver/functions/gte.js +5 -0
  99. package/node_modules/semver/functions/inc.js +21 -0
  100. package/node_modules/semver/functions/lt.js +5 -0
  101. package/node_modules/semver/functions/lte.js +5 -0
  102. package/node_modules/semver/functions/major.js +5 -0
  103. package/node_modules/semver/functions/minor.js +5 -0
  104. package/node_modules/semver/functions/neq.js +5 -0
  105. package/node_modules/semver/functions/parse.js +18 -0
  106. package/node_modules/semver/functions/patch.js +5 -0
  107. package/node_modules/semver/functions/prerelease.js +8 -0
  108. package/node_modules/semver/functions/rcompare.js +5 -0
  109. package/node_modules/semver/functions/rsort.js +5 -0
  110. package/node_modules/semver/functions/satisfies.js +12 -0
  111. package/node_modules/semver/functions/sort.js +5 -0
  112. package/node_modules/semver/functions/truncate.js +48 -0
  113. package/node_modules/semver/functions/valid.js +8 -0
  114. package/node_modules/semver/index.js +93 -0
  115. package/node_modules/semver/internal/constants.js +67 -0
  116. package/node_modules/semver/internal/debug.js +11 -0
  117. package/node_modules/semver/internal/identifiers.js +29 -0
  118. package/node_modules/semver/internal/lrucache.js +42 -0
  119. package/node_modules/semver/internal/parse-options.js +17 -0
  120. package/node_modules/semver/internal/re.js +223 -0
  121. package/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  122. package/node_modules/semver/package.json +78 -0
  123. package/node_modules/semver/preload.js +4 -0
  124. package/node_modules/semver/range.bnf +17 -0
  125. package/node_modules/semver/ranges/gtr.js +6 -0
  126. package/node_modules/semver/ranges/intersects.js +9 -0
  127. package/node_modules/semver/ranges/ltr.js +6 -0
  128. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  129. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  130. package/node_modules/semver/ranges/min-version.js +63 -0
  131. package/node_modules/semver/ranges/outside.js +82 -0
  132. package/node_modules/semver/ranges/simplify.js +49 -0
  133. package/node_modules/semver/ranges/subset.js +249 -0
  134. package/node_modules/semver/ranges/to-comparators.js +10 -0
  135. package/node_modules/semver/ranges/valid.js +13 -0
  136. package/node_modules/yaml/LICENSE +13 -0
  137. package/node_modules/yaml/README.md +172 -0
  138. package/node_modules/yaml/bin.mjs +11 -0
  139. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  140. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  141. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  142. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  143. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  144. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  145. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  146. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  147. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  148. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  149. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
  150. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  151. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  152. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  153. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  154. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  155. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  156. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  157. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  158. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  159. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  160. package/node_modules/yaml/browser/dist/errors.js +57 -0
  161. package/node_modules/yaml/browser/dist/index.js +17 -0
  162. package/node_modules/yaml/browser/dist/log.js +11 -0
  163. package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
  164. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  165. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  166. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  167. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  168. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  169. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  170. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  171. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  172. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  173. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  174. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  175. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  176. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  177. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  178. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  179. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  180. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  181. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  182. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  183. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  184. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  185. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  186. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  187. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  188. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  189. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  190. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  191. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  192. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  193. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  194. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  195. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  196. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  197. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  198. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  199. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  200. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  201. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  202. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  203. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  204. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  205. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  206. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  207. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  208. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  209. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  210. package/node_modules/yaml/browser/dist/util.js +11 -0
  211. package/node_modules/yaml/browser/dist/visit.js +233 -0
  212. package/node_modules/yaml/browser/index.js +5 -0
  213. package/node_modules/yaml/browser/package.json +3 -0
  214. package/node_modules/yaml/dist/cli.d.ts +8 -0
  215. package/node_modules/yaml/dist/cli.mjs +201 -0
  216. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  217. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  218. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  219. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  220. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  221. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  222. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  223. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  224. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  225. package/node_modules/yaml/dist/compose/composer.js +224 -0
  226. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  227. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  228. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  229. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  230. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  231. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  232. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  233. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  234. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  235. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  236. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  237. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
  238. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  239. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  240. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  241. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  242. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  243. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  244. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  245. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  246. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  247. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  248. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  249. package/node_modules/yaml/dist/doc/Document.js +337 -0
  250. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  251. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  252. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  253. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  254. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  255. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  256. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  257. package/node_modules/yaml/dist/doc/directives.js +178 -0
  258. package/node_modules/yaml/dist/errors.d.ts +21 -0
  259. package/node_modules/yaml/dist/errors.js +62 -0
  260. package/node_modules/yaml/dist/index.d.ts +25 -0
  261. package/node_modules/yaml/dist/index.js +50 -0
  262. package/node_modules/yaml/dist/log.d.ts +3 -0
  263. package/node_modules/yaml/dist/log.js +19 -0
  264. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  265. package/node_modules/yaml/dist/nodes/Alias.js +120 -0
  266. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  267. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  268. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  269. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  270. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  271. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  272. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  273. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  274. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  275. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  276. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  277. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  278. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  279. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  280. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  281. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  282. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  283. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  284. package/node_modules/yaml/dist/options.d.ts +350 -0
  285. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  286. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  287. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  288. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  289. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  290. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  291. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  292. package/node_modules/yaml/dist/parse/cst.js +112 -0
  293. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  294. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  295. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  296. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  297. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  298. package/node_modules/yaml/dist/parse/parser.js +980 -0
  299. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  300. package/node_modules/yaml/dist/public-api.js +107 -0
  301. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  302. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  303. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  304. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  305. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  306. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  307. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  308. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  309. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  310. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  311. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  312. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  313. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  314. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  315. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  316. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  317. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  318. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  319. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  320. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  321. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  322. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  323. package/node_modules/yaml/dist/schema/tags.js +99 -0
  324. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  325. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  326. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  327. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  328. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  329. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  330. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  331. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  332. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  333. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  334. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  335. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  336. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  337. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  338. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  339. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  340. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  341. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  342. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  343. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  344. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  345. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  346. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  347. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  348. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  349. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  350. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  351. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  352. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  353. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  354. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  355. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  356. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  357. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  358. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  359. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  360. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  361. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  362. package/node_modules/yaml/dist/test-events.js +134 -0
  363. package/node_modules/yaml/dist/util.d.ts +16 -0
  364. package/node_modules/yaml/dist/util.js +28 -0
  365. package/node_modules/yaml/dist/visit.d.ts +102 -0
  366. package/node_modules/yaml/dist/visit.js +236 -0
  367. package/node_modules/yaml/package.json +97 -0
  368. package/node_modules/yaml/util.js +2 -0
  369. package/package.json +34 -14
  370. package/plugin.mjs +113 -0
  371. package/server/archive.mjs +255 -0
  372. package/server/drop.mjs +498 -0
  373. package/server/impl.mjs +222 -76
  374. package/server/routes.mjs +339 -0
  375. package/lib/host.mjs +0 -27
  376. package/server/relay.mjs +0 -70
package/server/impl.mjs CHANGED
@@ -19,14 +19,18 @@ import os from 'node:os'
19
19
  import path from 'node:path'
20
20
 
21
21
  import { validatePlugin } from '@capyclaw/plugin-validator'
22
+ import { stagePlugin } from '@capyclaw/plugin-kit/packaging/pack'
23
+ import { makeSelfContained } from '@capyclaw/plugin-kit/packaging/self-contained'
22
24
 
23
25
  /** 支撑库目录(相对仓库根):纯库/独立服务,无 dsh.bundle,插件发现集不收,显式清单维护。
24
26
  * 可用 DSH_PUBLISHER_LIBS(JSON 数组,相对 root 的路径)覆盖。 */
25
27
  export const DEFAULT_SUPPORT_LIBS = [
26
- 'packages/capyclaw-plugin-kit',
27
- 'packages/capyclaw-document-workbench',
28
- 'packages/capyclaw-host-shell',
29
- 'extensions/bridges/ppt-bridge/capyclaw-skills-service',
28
+ 'C/packages/capyclaw-plugin-kit',
29
+ 'C/packages/capyclaw-document-workbench',
30
+ 'C/packages/capyclaw-host-shell',
31
+ 'C/packages/capyclaw-skills-service',
32
+ 'C/packages/capyclaw-portal',
33
+ 'C/packages/capyclaw-suite-kit',
30
34
  ]
31
35
 
32
36
  /** 与原脚本一致的失败状态集(其余视为通过或跳过)。 */
@@ -53,7 +57,17 @@ export function publishGateErrors(pkg, srcDir) {
53
57
  }
54
58
  const patch = pkg.dsh?.bundle?.patch
55
59
  const patches = Array.isArray(patch) ? patch : patch ? [patch] : []
56
- if (!patches.length) errors.push('缺少 dsh.bundle.patch(dsh 不会把这个包当作 profile 层加载)')
60
+ /* dsh.member: true —— 只随套件分发的成员包(如各 workbench)。
61
+ * 它们不向 profile 插入任何行,所以没有 bundle.patch 是**正确状态**;反过来,
62
+ * 成员包若声明了补丁就会和套件重复声明同一行,把卸载守卫焊死。
63
+ * 与 C/tools/capyclaw-plugin-release 的判定必须逐字一致(parity 闸会比对)。 */
64
+ if (pkg.dsh?.member === true) {
65
+ if (patches.length) {
66
+ errors.push('dsh.member: true 的成员包不应声明 dsh.bundle.patch(会与套件重复声明同一行)')
67
+ }
68
+ } else if (!patches.length) {
69
+ errors.push('缺少 dsh.bundle.patch(dsh 不会把这个包当作 profile 层加载)')
70
+ }
57
71
  for (const rel of patches) {
58
72
  if (!fs.existsSync(path.join(srcDir, rel))) errors.push(`dsh.bundle.patch 指向的文件不存在: ${rel}`)
59
73
  }
@@ -91,7 +105,7 @@ export function libraryGateErrors(pkg) {
91
105
  }
92
106
 
93
107
  /** 插件扫码根目录 + 包名形态。(移植自 plugin-release;发布闸用不到 suite 校验器注入) */
94
- const PLUGIN_BASES = ['packages', 'extensions/official', 'extensions/bridges', 'extensions/bridges/*/plugin']
108
+ const PLUGIN_BASES = ['C/packages', 'B/official', 'A/projects']
95
109
  const PUBLISHABLE_NAME = /^((@[\w.-]+\/)?dsh-[\w.-]+|@capyclaw\/[\w.-]+)$/
96
110
 
97
111
  /** 找出 root 下所有**可发布**的插件目录(过得了发布闸的才算)。未就绪的落 lastSkipped。 */
@@ -105,7 +119,7 @@ export function discoverPlugins({ root, includeNotReady = false } = {}) {
105
119
  try {
106
120
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
107
121
  const publishable = PUBLISHABLE_NAME.test(pkg.name || '')
108
- && (pkg.dsh?.bundle || pkg.dsh?.client || pkg.dsh?.suite)
122
+ && (pkg.dsh?.bundle || pkg.dsh?.client || pkg.dsh?.suite || pkg.dsh?.member)
109
123
  if (publishable && !seen.has(pkg.name)) {
110
124
  seen.add(pkg.name)
111
125
  const reasons = publishGateErrors(pkg, dir)
@@ -185,10 +199,18 @@ function createNpmContext() {
185
199
  }
186
200
 
187
201
  /** 发布顺序闸:待发包的 @capyclaw 依赖闭包,每一项必须 registry 可解析或在同批发布。
188
- * 拦截「只发 suite 不发依赖」这类顺序手滑(发布成功 ≠ 用户能装上)。 */
202
+ * 拦截「只发 suite 不发依赖」这类顺序手滑(发布成功 ≠ 用户能装上)。
203
+ *
204
+ * 自包含例外:列在 bundledDependencies 里的依赖**已经实体在 tarball 内**,
205
+ * 安装时 npm/pnpm 用包内副本、根本不会去 registry 解析。这类依赖不该被本闸拦下
206
+ * ——否则「全自包含」的包反而会因为成员尚未上架而发不出去。 */
189
207
  export function orderGate(pkg, localMap, batch, npm) {
190
208
  const errors = []
191
209
  const warnings = []
210
+ const bundled = new Set([
211
+ ...(Array.isArray(pkg.bundledDependencies) ? pkg.bundledDependencies : []),
212
+ ...(Array.isArray(pkg.bundleDependencies) ? pkg.bundleDependencies : []),
213
+ ])
192
214
  const seen = new Set([pkg.name])
193
215
  const queue = [pkg]
194
216
  while (queue.length) {
@@ -199,6 +221,8 @@ export function orderGate(pkg, localMap, batch, npm) {
199
221
  seen.add(name)
200
222
  const local = localMap.get(name)
201
223
  if (local) queue.push(local.pkg) /* 闭包继续沿本仓包展开 */
224
+ /* 已随包携带:安装侧不查 registry,无需顺序约束。 */
225
+ if (bundled.has(name)) continue
202
226
  const resolvable = npm.npmView(`${name}@${range}`, 'version')
203
227
  if (resolvable.status === 0) continue /* ① registry 已可解析 */
204
228
  if (batch.has(name)) {
@@ -216,14 +240,26 @@ export function orderGate(pkg, localMap, batch, npm) {
216
240
  * 认证令牌字段的模式用拼接构造,注释里也不写整串,
217
241
  * 否则扫描器会把自己的源码当成泄漏(自噬假阳性)。) */
218
242
  const AUTH_TOKEN_RE = new RegExp('_auth' + 'Token', 'i')
243
+ /* ownOnly=true 的模式只查「我们自己的代码」(包根文件 + node_modules/@capyclaw 成员)。
244
+ * 第三方 vendored 依赖(playwright/@types/pptxgenjs 等)的上游源码天然带构建机目录路径,
245
+ * 那不是本机凭据泄漏,不该拦发布;凭据形态(API key / npm 令牌 / npmrc 令牌字段)则对所有文件一律查。
246
+ * 注意:本文件自身也会被扫描,注释里切勿写出任何完整的凭据或路径模式字面量(自噬假阳性)。 */
219
247
  const SECRET_PATTERNS = [
220
- [/sk-[A-Za-z0-9]{20,}/, 'API key 形态(sk-…)'],
221
- [/npm_[A-Za-z0-9]{20,}/, 'npm token 形态(npm_…)'],
222
- [AUTH_TOKEN_RE, 'npmrc 认证令牌字段'],
223
- [/[A-Za-z]:\\Users\\/i, '本机绝对路径(盘符:\\Users\\)'],
224
- [/\/(home|Users)\/[A-Za-z0-9._-]+\//, '本机绝对路径(/home/ / /Users/)'],
248
+ [/sk-[A-Za-z0-9]{20,}/, 'API key 形态(sk-…)', false],
249
+ [/npm_[A-Za-z0-9]{20,}/, 'npm token 形态(npm_…)', false],
250
+ [AUTH_TOKEN_RE, 'npmrc 认证令牌字段', false],
251
+ [/[A-Za-z]:\\Users\\/i, '本机绝对路径(盘符:\\Users\\)', true],
252
+ [/\/(home|Users)\/[A-Za-z0-9._-]+\//, '本机绝对路径(/home/ / /Users/)', true],
225
253
  ]
226
254
 
255
+ /** 相对路径是否落在第三方 vendored 依赖里(最后一个 node_modules 段之后非 @capyclaw)。 */
256
+ function isThirdPartyVendored(rel) {
257
+ const parts = rel.split(/[\\/]/)
258
+ const i = parts.lastIndexOf('node_modules')
259
+ if (i === -1) return false
260
+ return parts[i + 1] !== '@capyclaw'
261
+ }
262
+
227
263
  /** 扫描目录内全部文本文件,返回命中的密钥/本机信息描述串。 */
228
264
  export function scanDirForSecrets(root) {
229
265
  const hits = []
@@ -235,8 +271,11 @@ export function scanDirForSecrets(root) {
235
271
  if (entry.isDirectory()) { walk(file); continue }
236
272
  let text = null
237
273
  try { text = fs.readFileSync(file, 'utf8') } catch { continue } /* 二进制/不可读跳过 */
238
- for (const [pattern, label] of SECRET_PATTERNS) {
239
- if (pattern.test(text)) hits.push(`${path.relative(root, file)}: ${label}`)
274
+ const rel = path.relative(root, file)
275
+ const thirdParty = isThirdPartyVendored(rel)
276
+ for (const [pattern, label, ownOnly] of SECRET_PATTERNS) {
277
+ if (ownOnly && thirdParty) continue
278
+ if (pattern.test(text)) hits.push(`${rel}: ${label}`)
240
279
  }
241
280
  }
242
281
  }
@@ -254,7 +293,12 @@ export function packGateErrors(pkg, dir, npm) {
254
293
  for (const rel of Array.isArray(patch) ? patch : patch ? [patch] : []) {
255
294
  mustHave.push(String(rel).replace(/^\.\//, ''))
256
295
  }
257
- if (pkg.dsh?.client) mustHave.push('client/client.js')
296
+ if (pkg.dsh?.client) {
297
+ /* client 入口由包 exports["./client"] 声明(各包不一:client/client.js、根 client.js、lib/client.js),
298
+ * 不能硬编码 client/client.js;无 exports 时回退约定默认值。 */
299
+ const clientEntry = pkg.exports?.['./client'] || 'client/client.js'
300
+ mustHave.push(String(clientEntry).replace(/^\.\//, ''))
301
+ }
258
302
  if (pkg.dsh?.suite) mustHave.push(String(pkg.dsh.suite).replace(/^\.\//, ''))
259
303
  const r = npm.rawNpmRun(['pack', '--dry-run', '--json'], { cwd: dir })
260
304
  if (r.status !== 0) return [`npm pack --dry-run 失败: ${String(r.stderr || r.stdout || '').trim().slice(0, 200)}`]
@@ -294,10 +338,92 @@ export function npmWhoami() {
294
338
  return { ok: true, user: String(r.stdout).trim() }
295
339
  }
296
340
 
341
+ /* ────────────────────────── 自包含发布目录 ────────────────────────── */
342
+
343
+ /** 真 suite = dsh.suite 清单里有「成员」(path 不是 '.' 的自条目)。
344
+ * 公共插件也带 dsh-suite.json,但只有自己的自条目,不属于这种情况。 */
345
+ function isRealSuite(dir, pkg) {
346
+ const rel = pkg.dsh?.suite
347
+ if (!rel) return false
348
+ const file = path.join(dir, String(rel))
349
+ if (!fs.existsSync(file)) return false
350
+ try {
351
+ const manifest = JSON.parse(fs.readFileSync(file, 'utf8'))
352
+ return Object.values(manifest.packages || {}).some((entry) => entry?.path && entry.path !== '.' && entry.path !== './')
353
+ } catch {
354
+ return false
355
+ }
356
+ }
357
+
358
+ /** 在 A/artifacts/suites/<bridge>/package(npm run assemble 的产物,首选)
359
+ * 或旧版 dist/suites/<bridge>/package 里找同名同版本的自包含拼装产物。 */
360
+ function findAssembledSuite(root, name, version) {
361
+ const bases = [path.join(root, 'A', 'artifacts', 'suites'), path.join(root, 'dist', 'suites')]
362
+ for (const suitesDir of bases) {
363
+ if (!fs.existsSync(suitesDir)) continue
364
+ let entries = []
365
+ try { entries = fs.readdirSync(suitesDir, { withFileTypes: true }) } catch { continue }
366
+ for (const entry of entries) {
367
+ if (!entry.isDirectory()) continue
368
+ const candidate = path.join(suitesDir, entry.name, 'package')
369
+ const pkgFile = path.join(candidate, 'package.json')
370
+ if (!fs.existsSync(pkgFile)) continue
371
+ try {
372
+ const p = JSON.parse(fs.readFileSync(pkgFile, 'utf8'))
373
+ if (p.name === name && p.version === version) return candidate
374
+ } catch { /* 坏包跳过 */ }
375
+ }
376
+ }
377
+ return null
378
+ }
379
+
380
+ /**
381
+ * 解析「真正要发布的那份内容」。
382
+ *
383
+ * 为什么不能直接发源码树:`npm publish` 会剥离 node_modules,只有
384
+ * package.json 的 bundledDependencies 列出的依赖才进 tarball。源码树里既没有
385
+ * node_modules,也没有 bundledDependencies,发出去的必然是瘦包——用户安装时
386
+ * 还得回 registry 逐个解析依赖(2.4.x 时代的实际行为)。
387
+ *
388
+ * 两类包分别处理:
389
+ * - 真 suite:改用 C 段拼装产物(dsh-suite.json 已改写成 ./node_modules/…,
390
+ * 成员与闭包都在包内,bundledDependencies 已写好)。找不到就报错,不静默降级。
391
+ * - 其它包:临时 staging(按 files 白名单)+ 实体化依赖闭包 + 写 bundledDependencies。
392
+ *
393
+ * @returns {{publishDir:string, cleanup:()=>void, mode:string, bundled?:string[]}|{error:string}}
394
+ */
395
+ export function preparePublishDir(dir, root, pkg) {
396
+ if (isRealSuite(dir, pkg)) {
397
+ const assembled = findAssembledSuite(root, pkg.name, pkg.version)
398
+ if (!assembled) {
399
+ return {
400
+ error: `找不到自包含拼装产物:${pkg.name}@${pkg.version} 不在 A/artifacts/suites/*/package(或旧版 dist/suites/*/package)里。`
401
+ + '先跑 npm run assemble,否则发出去的 suite 里没有成员,安装后要回 registry 拉取。',
402
+ }
403
+ }
404
+ return { publishDir: assembled, cleanup: () => {}, mode: 'assembled-suite' }
405
+ }
406
+
407
+ const staging = fs.mkdtempSync(path.join(os.tmpdir(), 'pub-selfcontained-'))
408
+ try {
409
+ stagePlugin({ srcDir: dir, destDir: staging, keepNodeModules: false })
410
+ const result = makeSelfContained({ stagingDir: staging, root })
411
+ return {
412
+ publishDir: staging,
413
+ cleanup: () => fs.rmSync(staging, { recursive: true, force: true }),
414
+ mode: 'staged-self-contained',
415
+ bundled: result.bundled,
416
+ }
417
+ } catch (error) {
418
+ fs.rmSync(staging, { recursive: true, force: true })
419
+ return { error: `自包含 staging 失败: ${error.message}` }
420
+ }
421
+ }
422
+
297
423
  /* ────────────────────────── 主流程(移植) ────────────────────────── */
298
424
 
299
425
  /** 单包发布流程(插件与库共用)。返回结果记录。 */
300
- async function publishOne(dir, { kind, localMap, batch, only, tag, skipTests, dryRun, npm, log }) {
426
+ async function publishOne(dir, { kind, localMap, batch, only, tag, skipTests, dryRun, npm, log, root }) {
301
427
  const pkg = pkgOf(dir)
302
428
  const label = `${pkg.name}@${pkg.version}`
303
429
  if (only && pkg.name !== only) return null
@@ -318,73 +444,93 @@ async function publishOne(dir, { kind, localMap, batch, only, tag, skipTests, dr
318
444
  }
319
445
  }
320
446
 
321
- if (npm.alreadyPublished(pkg.name, pkg.version)) {
322
- /* 同版本漂移闸:npm pack 确定性 ⇒ 本地 sha1 == registry dist.shasum 当且仅当内容一致。 */
323
- const remoteSha = npm.npmShasumOf(pkg.name, pkg.version)
324
- const localSha = remoteSha ? npm.localShasumOf(dir) : null
325
- if (remoteSha && localSha && remoteSha !== localSha) {
326
- log(`✗ ${label} — 同版本内容漂移:registry ${remoteSha.slice(0, 8)} ≠ 本地 ${localSha.slice(0, 8)}`)
327
- log(' npm 不允许同版本重发,请 bump 版本后再发布')
328
- return { label, status: 'version-drift', detail: `shasum ${localSha} != ${remoteSha}` }
329
- }
330
- if (!remoteSha) log(`! ${label} — 无法获取 registry shasum(网络?),跳过漂移对比`)
331
- log(`· ${label} — registry 上已存在,跳过`)
332
- return { label, status: 'skipped-exists' }
447
+ const exists = npm.alreadyPublished(pkg.name, pkg.version)
448
+
449
+ /* 自包含产物:npm/pnpm 会剥离 node_modules,必须发布「依赖已实体化且写进
450
+ * bundledDependencies」的那一份,否则装出来是瘦包、要回 registry 拉依赖。 */
451
+ const prepared = preparePublishDir(dir, root, pkg)
452
+ if (prepared.error) {
453
+ log(`✗ ${label} — 无法准备自包含产物`)
454
+ log(` - ${prepared.error}`)
455
+ return { label, status: 'pack-incomplete', detail: [prepared.error] }
333
456
  }
334
457
 
335
- /* pack 闸只对「真要发布」的包跑(真实 pack + 解包扫描很重,已发布的包由漂移闸把关)。 */
336
- if (kind === 'plugin') {
337
- const packErrors = packGateErrors(pkg, dir, npm)
338
- if (packErrors.length) {
339
- log(`✗ ${label} — pack 闸未过`)
340
- for (const item of packErrors) log(` - ${item}`)
341
- return { label, status: 'pack-incomplete', detail: packErrors }
458
+ try {
459
+ if (exists) {
460
+ /* 同版本漂移闸:npm pack 确定性 ⇒ 本地 sha1 == registry dist.shasum 当且仅当内容一致。
461
+ * 对比对象是**真正会发布的自包含产物**而非源码树:bundledDependencies 与 vendored
462
+ * 依赖只存在于产物里,直接比源码树会在每次续跑时误报漂移;源码改动若影响产物,
463
+ * 在这里同样会被抓住。 */
464
+ const remoteSha = npm.npmShasumOf(pkg.name, pkg.version)
465
+ const localSha = remoteSha ? npm.localShasumOf(prepared.publishDir) : null
466
+ if (remoteSha && localSha && remoteSha !== localSha) {
467
+ log(`✗ ${label} — 同版本内容漂移:registry ${remoteSha.slice(0, 8)} ≠ 本地 ${localSha.slice(0, 8)}`)
468
+ log(' npm 不允许同版本重发,请 bump 版本后再发布')
469
+ return { label, status: 'version-drift', detail: `shasum ${localSha} != ${remoteSha}` }
470
+ }
471
+ if (!remoteSha) log(`! ${label} — 无法获取 registry shasum(网络?),跳过漂移对比`)
472
+ log(`· ${label} — registry 上已存在,跳过`)
473
+ return { label, status: 'skipped-exists' }
474
+ }
475
+ /* pack 闸只对「真要发布」的包跑(真实 pack + 解包扫描很重,已发布的包由漂移闸把关)。
476
+ * 校验对象是自包含产物——那才是真正上 registry 的内容。 */
477
+ if (kind === 'plugin') {
478
+ const packErrors = packGateErrors(pkg, prepared.publishDir, npm)
479
+ if (packErrors.length) {
480
+ log(`✗ ${label} — pack 闸未过`)
481
+ for (const item of packErrors) log(` - ${item}`)
482
+ return { label, status: 'pack-incomplete', detail: packErrors }
483
+ }
342
484
  }
343
- }
344
485
 
345
- /* 发布顺序闸(发布成功 ≠ 用户能装上):依赖闭包须 registry 可解析或同批发布。 */
346
- const order = orderGate(pkg, localMap, batch, npm)
347
- if (order.errors.length) {
348
- log(`✗ ${label} — 发布顺序闸未过(发布后用户 npm install 会失败)`)
349
- for (const item of order.errors) log(` - ${item}`)
350
- return { label, status: 'order-blocked', detail: order.errors }
351
- }
352
- for (const w of order.warnings) log(`! ${label} — ${w}`)
486
+ /* 发布顺序闸(发布成功 ≠ 用户能装上):依赖闭包须 registry 可解析或同批发布。
487
+ * 用**自包含产物**的清单判定:bundledDependencies 在源码树里没有,
488
+ * 只有 staging/拼装产物里才有,拿错清单会把已随包携带的依赖误判成必须上架。 */
489
+ const order = orderGate(pkgOf(prepared.publishDir), localMap, batch, npm)
490
+ if (order.errors.length) {
491
+ log(`✗ ${label} — 发布顺序闸未过(发布后用户 npm install 会失败)`)
492
+ for (const item of order.errors) log(` - ${item}`)
493
+ return { label, status: 'order-blocked', detail: order.errors }
494
+ }
495
+ for (const w of order.warnings) log(`! ${label} — ${w}`)
353
496
 
354
- if (!skipTests && pkg.scripts?.test) {
355
- const t = npm.rawNpmRun(['test'], { cwd: dir })
356
- if (t.status !== 0) {
357
- log(`✗ ${label} — npm test 失败,跳过发布`)
358
- return { label, status: 'test-failed', detail: (t.stdout || '') + (t.stderr || '') }
497
+ if (!skipTests && pkg.scripts?.test) {
498
+ const t = npm.rawNpmRun(['test'], { cwd: dir })
499
+ if (t.status !== 0) {
500
+ log(`✗ ${label} — npm test 失败,跳过发布`)
501
+ return { label, status: 'test-failed', detail: (t.stdout || '') + (t.stderr || '') }
502
+ }
359
503
  }
360
- }
361
504
 
362
- if (dryRun) {
363
- log(`→ ${label} — 待发布(dry run${tag !== 'latest' ? `,dist-tag=${tag}` : ''})`)
364
- return { label, status: 'would-publish' }
365
- }
505
+ if (dryRun) {
506
+ log(`→ ${label} — 待发布(dry run,自包含产物=${prepared.mode}${prepared.bundled ? `,内置 ${prepared.bundled.length} 个依赖` : ''}${tag !== 'latest' ? `,dist-tag=${tag}` : ''})`)
507
+ return { label, status: 'would-publish' }
508
+ }
366
509
 
367
- const access = pkg.publishConfig?.access || 'public'
368
- const expectedSha = npm.localShasumOf(dir)
369
- const pub = npm.rawNpmRun(['publish', '--access', access, '--tag', tag], { cwd: dir })
370
- if (pub.status !== 0) {
371
- log(`✗ ${label} — npm publish 失败`)
372
- log(String(pub.stderr || pub.stdout || '').trim().slice(0, 500))
373
- return { label, status: 'publish-failed', detail: (pub.stdout || '') + (pub.stderr || '') }
374
- }
375
- /* 发布后复核:registry 收到的 tarball 必须与本地 pack 逐字节一致(shasum)。 */
376
- let remoteSha = null
377
- for (let i = 0; i < 5 && !remoteSha; i++) {
378
- if (i) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 3000)
379
- remoteSha = npm.npmShasumOf(pkg.name, pkg.version)
380
- }
381
- if (remoteSha && expectedSha && remoteSha !== expectedSha) {
382
- log(`✗ ${label} — 发布后复核失败:registry ${remoteSha.slice(0, 8)} ≠ 本地 ${expectedSha.slice(0, 8)}(registry 可能收到脏产物,bump 后重发)`)
383
- return { label, status: 'publish-corrupted', detail: `shasum ${remoteSha} != ${expectedSha}` }
510
+ const access = pkg.publishConfig?.access || 'public'
511
+ const expectedSha = npm.localShasumOf(prepared.publishDir)
512
+ const pub = npm.rawNpmRun(['publish', '--access', access, '--tag', tag], { cwd: prepared.publishDir })
513
+ if (pub.status !== 0) {
514
+ log(`✗ ${label} — npm publish 失败`)
515
+ log(String(pub.stderr || pub.stdout || '').trim().slice(0, 500))
516
+ return { label, status: 'publish-failed', detail: (pub.stdout || '') + (pub.stderr || '') }
517
+ }
518
+ /* 发布后复核:registry 收到的 tarball 必须与本地 pack 逐字节一致(shasum)。 */
519
+ let remoteSha = null
520
+ for (let i = 0; i < 5 && !remoteSha; i++) {
521
+ if (i) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 3000)
522
+ remoteSha = npm.npmShasumOf(pkg.name, pkg.version)
523
+ }
524
+ if (remoteSha && expectedSha && remoteSha !== expectedSha) {
525
+ log(`✗ ${label} — 发布后复核失败:registry ${remoteSha.slice(0, 8)} ≠ 本地 ${expectedSha.slice(0, 8)}(registry 可能收到脏产物,bump 后重发)`)
526
+ return { label, status: 'publish-corrupted', detail: `shasum ${remoteSha} != ${expectedSha}` }
527
+ }
528
+ if (!remoteSha) log(`! ${label} — 发布后复核降级:registry shasum 暂不可见(副本延迟),请稍后人工核对`)
529
+ log(`✓ ${label} — 已发布(自包含产物=${prepared.mode}${tag !== 'latest' ? `,dist-tag=${tag}` : ''})`)
530
+ return { label, status: 'published' }
531
+ } finally {
532
+ prepared.cleanup()
384
533
  }
385
- if (!remoteSha) log(`! ${label} — 发布后复核降级:registry shasum 暂不可见(副本延迟),请稍后人工核对`)
386
- log(`✓ ${label} — 已发布${tag !== 'latest' ? `(dist-tag=${tag})` : ''}`)
387
- return { label, status: 'published' }
388
534
  }
389
535
 
390
536
  /** 解析工作区 root:参数 → DSH_PUBLISHER_ROOT。 */
@@ -438,7 +584,7 @@ export async function runPublish(options = {}) {
438
584
  .map((pkg) => pkg.name),
439
585
  )
440
586
 
441
- const shared = { localMap, batch, only, tag, skipTests, dryRun, npm, log }
587
+ const shared = { localMap, batch, only, tag, skipTests, dryRun, npm, log, root }
442
588
  // 先库后插件:plugin-kit 等支撑库必须先上 registry,插件发布时依赖才可解析
443
589
  for (const dir of usableLibDirs) results.push(await publishOne(dir, { kind: 'lib', ...shared }))
444
590
  for (const dir of pluginDirs) results.push(await publishOne(dir, { kind: 'plugin', ...shared }))