@capyclaw/publisher 0.1.4 → 0.1.5

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 (367) hide show
  1. package/node_modules/@capyclaw/foundation/README.md +51 -0
  2. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
  3. package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
  4. package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
  5. package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
  6. package/node_modules/@capyclaw/foundation/abi/loader.mjs +352 -0
  7. package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
  8. package/node_modules/@capyclaw/foundation/abi/spec.mjs +258 -0
  9. package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
  10. package/node_modules/@capyclaw/foundation/abi/version.mjs +140 -0
  11. package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
  12. package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
  13. package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
  14. package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
  15. package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
  16. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
  17. package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
  18. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
  19. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -0
  20. package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
  21. package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
  22. package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
  23. package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
  24. package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
  25. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
  26. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
  27. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
  28. package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +187 -0
  29. package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
  30. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
  31. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -0
  32. package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
  33. package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
  34. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +198 -0
  35. package/node_modules/@capyclaw/foundation/package.json +53 -0
  36. package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
  37. package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
  38. package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
  39. package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
  40. package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
  41. package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
  42. package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
  43. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
  44. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +60 -0
  45. package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
  46. package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
  47. package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
  48. package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
  49. package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
  50. package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
  51. package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
  52. package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
  53. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
  54. package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
  55. package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
  56. package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
  57. package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
  58. package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
  59. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
  60. package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
  61. package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
  62. package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
  63. package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
  64. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
  65. package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
  66. package/node_modules/@capyclaw/plugin-validator/bin/cli.mjs +49 -0
  67. package/node_modules/@capyclaw/plugin-validator/lib/index.mjs +303 -0
  68. package/node_modules/@capyclaw/plugin-validator/package.json +28 -0
  69. package/node_modules/@capyclaw/tool-host/README.md +56 -0
  70. package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
  71. package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
  72. package/node_modules/@capyclaw/tool-host/lib/host.mjs +37 -0
  73. package/node_modules/@capyclaw/tool-host/package.json +59 -0
  74. package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
  75. package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
  76. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
  77. package/node_modules/@capyclaw/tool-host/src/index.mjs +449 -0
  78. package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +214 -0
  79. package/node_modules/semver/LICENSE +15 -0
  80. package/node_modules/semver/README.md +680 -0
  81. package/node_modules/semver/bin/semver.js +195 -0
  82. package/node_modules/semver/classes/comparator.js +143 -0
  83. package/node_modules/semver/classes/index.js +7 -0
  84. package/node_modules/semver/classes/range.js +577 -0
  85. package/node_modules/semver/classes/semver.js +350 -0
  86. package/node_modules/semver/functions/clean.js +8 -0
  87. package/node_modules/semver/functions/cmp.js +54 -0
  88. package/node_modules/semver/functions/coerce.js +62 -0
  89. package/node_modules/semver/functions/compare-build.js +9 -0
  90. package/node_modules/semver/functions/compare-loose.js +5 -0
  91. package/node_modules/semver/functions/compare.js +7 -0
  92. package/node_modules/semver/functions/diff.js +60 -0
  93. package/node_modules/semver/functions/eq.js +5 -0
  94. package/node_modules/semver/functions/gt.js +5 -0
  95. package/node_modules/semver/functions/gte.js +5 -0
  96. package/node_modules/semver/functions/inc.js +21 -0
  97. package/node_modules/semver/functions/lt.js +5 -0
  98. package/node_modules/semver/functions/lte.js +5 -0
  99. package/node_modules/semver/functions/major.js +5 -0
  100. package/node_modules/semver/functions/minor.js +5 -0
  101. package/node_modules/semver/functions/neq.js +5 -0
  102. package/node_modules/semver/functions/parse.js +18 -0
  103. package/node_modules/semver/functions/patch.js +5 -0
  104. package/node_modules/semver/functions/prerelease.js +8 -0
  105. package/node_modules/semver/functions/rcompare.js +5 -0
  106. package/node_modules/semver/functions/rsort.js +5 -0
  107. package/node_modules/semver/functions/satisfies.js +12 -0
  108. package/node_modules/semver/functions/sort.js +5 -0
  109. package/node_modules/semver/functions/truncate.js +48 -0
  110. package/node_modules/semver/functions/valid.js +8 -0
  111. package/node_modules/semver/index.js +93 -0
  112. package/node_modules/semver/internal/constants.js +67 -0
  113. package/node_modules/semver/internal/debug.js +11 -0
  114. package/node_modules/semver/internal/identifiers.js +29 -0
  115. package/node_modules/semver/internal/lrucache.js +42 -0
  116. package/node_modules/semver/internal/parse-options.js +17 -0
  117. package/node_modules/semver/internal/re.js +223 -0
  118. package/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  119. package/node_modules/semver/package.json +78 -0
  120. package/node_modules/semver/preload.js +4 -0
  121. package/node_modules/semver/range.bnf +17 -0
  122. package/node_modules/semver/ranges/gtr.js +6 -0
  123. package/node_modules/semver/ranges/intersects.js +9 -0
  124. package/node_modules/semver/ranges/ltr.js +6 -0
  125. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  126. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  127. package/node_modules/semver/ranges/min-version.js +63 -0
  128. package/node_modules/semver/ranges/outside.js +82 -0
  129. package/node_modules/semver/ranges/simplify.js +49 -0
  130. package/node_modules/semver/ranges/subset.js +249 -0
  131. package/node_modules/semver/ranges/to-comparators.js +10 -0
  132. package/node_modules/semver/ranges/valid.js +13 -0
  133. package/node_modules/yaml/LICENSE +13 -0
  134. package/node_modules/yaml/README.md +172 -0
  135. package/node_modules/yaml/bin.mjs +11 -0
  136. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  137. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  138. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  139. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  140. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  141. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  142. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  143. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  144. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  145. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  146. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
  147. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  148. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  149. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  150. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  151. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  152. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  153. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  154. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  155. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  156. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  157. package/node_modules/yaml/browser/dist/errors.js +57 -0
  158. package/node_modules/yaml/browser/dist/index.js +17 -0
  159. package/node_modules/yaml/browser/dist/log.js +11 -0
  160. package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
  161. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  162. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  163. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  164. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  165. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  166. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  167. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  168. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  169. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  170. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  171. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  172. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  173. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  174. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  175. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  176. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  177. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  178. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  179. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  180. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  181. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  182. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  183. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  184. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  185. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  186. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  187. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  188. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  189. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  190. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  191. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  192. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  193. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  194. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  195. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  196. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  197. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  198. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  199. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  200. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  201. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  202. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  203. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  204. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  205. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  206. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  207. package/node_modules/yaml/browser/dist/util.js +11 -0
  208. package/node_modules/yaml/browser/dist/visit.js +233 -0
  209. package/node_modules/yaml/browser/index.js +5 -0
  210. package/node_modules/yaml/browser/package.json +3 -0
  211. package/node_modules/yaml/dist/cli.d.ts +8 -0
  212. package/node_modules/yaml/dist/cli.mjs +201 -0
  213. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  214. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  215. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  216. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  217. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  218. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  219. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  220. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  221. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  222. package/node_modules/yaml/dist/compose/composer.js +224 -0
  223. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  224. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  225. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  226. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  227. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  228. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  229. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  230. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  231. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  232. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  233. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  234. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
  235. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  236. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  237. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  238. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  239. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  240. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  241. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  242. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  243. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  244. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  245. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  246. package/node_modules/yaml/dist/doc/Document.js +337 -0
  247. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  248. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  249. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  250. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  251. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  252. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  253. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  254. package/node_modules/yaml/dist/doc/directives.js +178 -0
  255. package/node_modules/yaml/dist/errors.d.ts +21 -0
  256. package/node_modules/yaml/dist/errors.js +62 -0
  257. package/node_modules/yaml/dist/index.d.ts +25 -0
  258. package/node_modules/yaml/dist/index.js +50 -0
  259. package/node_modules/yaml/dist/log.d.ts +3 -0
  260. package/node_modules/yaml/dist/log.js +19 -0
  261. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  262. package/node_modules/yaml/dist/nodes/Alias.js +120 -0
  263. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  264. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  265. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  266. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  267. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  268. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  269. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  270. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  271. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  272. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  273. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  274. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  275. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  276. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  277. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  278. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  279. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  280. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  281. package/node_modules/yaml/dist/options.d.ts +350 -0
  282. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  283. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  284. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  285. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  286. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  287. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  288. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  289. package/node_modules/yaml/dist/parse/cst.js +112 -0
  290. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  291. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  292. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  293. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  294. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  295. package/node_modules/yaml/dist/parse/parser.js +980 -0
  296. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  297. package/node_modules/yaml/dist/public-api.js +107 -0
  298. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  299. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  300. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  301. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  302. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  303. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  304. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  305. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  306. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  307. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  308. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  309. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  310. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  311. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  312. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  313. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  314. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  315. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  316. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  317. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  318. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  319. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  320. package/node_modules/yaml/dist/schema/tags.js +99 -0
  321. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  322. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  323. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  324. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  325. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  326. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  327. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  328. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  329. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  330. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  331. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  332. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  333. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  334. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  335. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  336. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  337. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  338. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  339. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  340. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  341. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  342. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  343. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  344. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  345. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  346. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  347. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  348. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  349. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  350. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  351. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  352. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  353. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  354. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  355. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  356. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  357. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  358. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  359. package/node_modules/yaml/dist/test-events.js +134 -0
  360. package/node_modules/yaml/dist/util.d.ts +16 -0
  361. package/node_modules/yaml/dist/util.js +28 -0
  362. package/node_modules/yaml/dist/visit.d.ts +102 -0
  363. package/node_modules/yaml/dist/visit.js +236 -0
  364. package/node_modules/yaml/package.json +97 -0
  365. package/node_modules/yaml/util.js +2 -0
  366. package/package.json +10 -2
  367. package/server/impl.mjs +11 -1
@@ -0,0 +1,181 @@
1
+ /**
2
+ * 极简跨平台 ZIP 读写(store + deflate 读,store 写;无外部依赖)——全仓单一真源。
3
+ *
4
+ * 之前三处实现各持一份(plugin-development 写 / tools-plugin-release 读 /
5
+ * @capyclaw/suite-kit zip-read 读),本模块合并之。旧位置保留兼容 shim。
6
+ *
7
+ * 写入:store 模式(内容不压缩,跨平台稳定,产物可被任何标准读取器读)。
8
+ * 读取:支持 store(0) 与 deflate(8);接受 Buffer 或文件路径——本地文件与
9
+ * 远端下载源共用同一条校验/解包路径。
10
+ */
11
+ import fs from 'node:fs'
12
+ import path from 'node:path'
13
+ import zlib from 'node:zlib'
14
+
15
+ /* ------------------------------------------------------------------ 写入 */
16
+
17
+ const CRC_TABLE = (() => {
18
+ const table = new Uint32Array(256)
19
+ for (let n = 0; n < 256; n++) {
20
+ let c = n
21
+ for (let k = 0; k < 8; k++) c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1)
22
+ table[n] = c >>> 0
23
+ }
24
+ return table
25
+ })()
26
+
27
+ function crc32(buffer) {
28
+ let crc = 0xffffffff
29
+ for (let i = 0; i < buffer.length; i++) crc = CRC_TABLE[(crc ^ buffer[i]) & 0xff] ^ (crc >>> 8)
30
+ return (crc ^ 0xffffffff) >>> 0
31
+ }
32
+
33
+ function dosDateTime(date = new Date()) {
34
+ const year = Math.max(1980, date.getFullYear())
35
+ const time = ((date.getHours() & 0x1f) << 11) | ((date.getMinutes() & 0x3f) << 5) | (Math.floor(date.getSeconds() / 2) & 0x1f)
36
+ const day = (((year - 1980) & 0x7f) << 9) | (((date.getMonth() + 1) & 0x0f) << 5) | (date.getDate() & 0x1f)
37
+ return { time, day }
38
+ }
39
+
40
+ function walkFiles(dir, base = dir) {
41
+ const out = []
42
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
43
+ const full = path.join(dir, entry.name)
44
+ if (entry.isDirectory()) out.push(...walkFiles(full, base))
45
+ else if (entry.isFile()) out.push(path.relative(base, full).replace(/\\/g, '/'))
46
+ }
47
+ return out.sort()
48
+ }
49
+
50
+ /** 把目录写成 store 模式 ZIP。返回打包的相对路径列表。 */
51
+ export function writeZipFromDir(sourceDir, outFile) {
52
+ const files = walkFiles(sourceDir)
53
+ const now = dosDateTime()
54
+ const localParts = []
55
+ const centralParts = []
56
+ let offset = 0
57
+
58
+ for (const name of files) {
59
+ const data = fs.readFileSync(path.join(sourceDir, name))
60
+ const nameBytes = Buffer.from(name, 'utf8')
61
+ const crc = crc32(data)
62
+
63
+ const local = Buffer.alloc(30)
64
+ local.writeUInt32LE(0x04034b50, 0)
65
+ local.writeUInt16LE(20, 4)
66
+ local.writeUInt16LE(0x0800, 6)
67
+ local.writeUInt16LE(0, 8)
68
+ local.writeUInt16LE(now.time, 10)
69
+ local.writeUInt16LE(now.day, 12)
70
+ local.writeUInt32LE(crc, 14)
71
+ local.writeUInt32LE(data.length, 18)
72
+ local.writeUInt32LE(data.length, 22)
73
+ local.writeUInt16LE(nameBytes.length, 26)
74
+ local.writeUInt16LE(0, 28)
75
+ localParts.push(local, nameBytes, data)
76
+
77
+ const central = Buffer.alloc(46)
78
+ central.writeUInt32LE(0x02014b50, 0)
79
+ central.writeUInt16LE(20, 4)
80
+ central.writeUInt16LE(20, 6)
81
+ central.writeUInt16LE(0x0800, 8)
82
+ central.writeUInt16LE(0, 10)
83
+ central.writeUInt16LE(now.time, 12)
84
+ central.writeUInt16LE(now.day, 14)
85
+ central.writeUInt32LE(crc, 16)
86
+ central.writeUInt32LE(data.length, 20)
87
+ central.writeUInt32LE(data.length, 24)
88
+ central.writeUInt16LE(nameBytes.length, 28)
89
+ central.writeUInt16LE(0, 30)
90
+ central.writeUInt16LE(0, 32)
91
+ central.writeUInt16LE(0, 34)
92
+ central.writeUInt16LE(0, 36)
93
+ central.writeUInt32LE(0, 38)
94
+ central.writeUInt32LE(offset, 42)
95
+ centralParts.push(central, nameBytes)
96
+
97
+ offset += local.length + nameBytes.length + data.length
98
+ }
99
+
100
+ const centralBuffer = Buffer.concat(centralParts)
101
+ const eocd = Buffer.alloc(22)
102
+ eocd.writeUInt32LE(0x06054b50, 0)
103
+ eocd.writeUInt16LE(0, 4)
104
+ eocd.writeUInt16LE(0, 6)
105
+ eocd.writeUInt16LE(files.length, 8)
106
+ eocd.writeUInt16LE(files.length, 10)
107
+ eocd.writeUInt32LE(centralBuffer.length, 12)
108
+ eocd.writeUInt32LE(offset, 16)
109
+ eocd.writeUInt16LE(0, 20)
110
+
111
+ fs.mkdirSync(path.dirname(outFile), { recursive: true })
112
+ fs.writeFileSync(outFile, Buffer.concat([...localParts, centralBuffer, eocd]))
113
+ return files
114
+ }
115
+
116
+ /* ------------------------------------------------------------------ 读取 */
117
+
118
+ function locateEocd(data, label) {
119
+ for (let i = data.length - 22; i >= 0; i--) {
120
+ if (data.readUInt32LE(i) === 0x06054b50) return i
121
+ }
122
+ throw new Error(`不是有效的 ZIP: ${label}`)
123
+ }
124
+
125
+ /**
126
+ * 列出 ZIP 全部条目名。
127
+ * @param {Buffer|string} input - ZIP 字节或文件路径
128
+ */
129
+ export function listZipEntryNames(input, label = 'zip') {
130
+ const data = Buffer.isBuffer(input) ? input : fs.readFileSync(input)
131
+ const eocd = locateEocd(data, label)
132
+ const count = data.readUInt16LE(eocd + 10)
133
+ let offset = data.readUInt32LE(eocd + 16)
134
+ const names = []
135
+ for (let i = 0; i < count; i++) {
136
+ if (data.readUInt32LE(offset) !== 0x02014b50) throw new Error(`ZIP 中央目录损坏: ${label}`)
137
+ const nameLength = data.readUInt16LE(offset + 28)
138
+ const extraLength = data.readUInt16LE(offset + 30)
139
+ const commentLength = data.readUInt16LE(offset + 32)
140
+ names.push(data.subarray(offset + 46, offset + 46 + nameLength).toString('utf8'))
141
+ offset += 46 + nameLength + extraLength + commentLength
142
+ }
143
+ return names
144
+ }
145
+
146
+ /**
147
+ * 从 ZIP 读单个条目的原始字节;不存在返回 undefined。
148
+ * @param {Buffer|string} input - ZIP 字节或文件路径
149
+ */
150
+ export function readZipEntryBuffer(input, entryName, label = 'zip') {
151
+ const data = Buffer.isBuffer(input) ? input : fs.readFileSync(input)
152
+ const eocd = locateEocd(data, label)
153
+ const count = data.readUInt16LE(eocd + 10)
154
+ let offset = data.readUInt32LE(eocd + 16)
155
+ for (let i = 0; i < count; i++) {
156
+ if (data.readUInt32LE(offset) !== 0x02014b50) throw new Error(`ZIP 中央目录损坏: ${label}`)
157
+ const method = data.readUInt16LE(offset + 10)
158
+ const compSize = data.readUInt32LE(offset + 20)
159
+ const nameLength = data.readUInt16LE(offset + 28)
160
+ const extraLength = data.readUInt16LE(offset + 30)
161
+ const commentLength = data.readUInt16LE(offset + 32)
162
+ const localOffset = data.readUInt32LE(offset + 42)
163
+ const name = data.subarray(offset + 46, offset + 46 + nameLength).toString('utf8')
164
+ if (name === entryName) {
165
+ const localNameLength = data.readUInt16LE(localOffset + 26)
166
+ const localExtraLength = data.readUInt16LE(localOffset + 28)
167
+ const start = localOffset + 30 + localNameLength + localExtraLength
168
+ const body = data.subarray(start, start + compSize)
169
+ if (method === 0) return body
170
+ if (method === 8) return zlib.inflateRawSync(body)
171
+ throw new Error(`不支持的 ZIP 压缩方式 ${method}: ${label}`)
172
+ }
173
+ offset += 46 + nameLength + extraLength + commentLength
174
+ }
175
+ return undefined
176
+ }
177
+
178
+ /** 读取 ZIP 中央目录条目名(文件路径版;打包自检/测试用)。 */
179
+ export function listZipEntries(file) {
180
+ return listZipEntryNames(fs.readFileSync(file), file)
181
+ }
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * DSH 插件验证 CLI
4
+ * 用法: validate-plugin <plugin-path>
5
+ */
6
+
7
+ import { fileURLToPath } from 'node:url'
8
+ import { dirname, resolve } from 'node:path'
9
+ import { validatePlugin } from '../lib/index.mjs'
10
+
11
+ const __filename = fileURLToPath(import.meta.url)
12
+ const __dirname = dirname(__filename)
13
+
14
+ const pluginPath = process.argv[2]
15
+
16
+ if (!pluginPath) {
17
+ console.error('用法: validate-plugin <plugin-path>')
18
+ console.error('示例: validate-plugin B/official/capyclaw-port-sidebar')
19
+ process.exit(1)
20
+ }
21
+
22
+ const absolutePath = resolve(process.cwd(), pluginPath)
23
+
24
+ console.log('🔍 验证插件:', absolutePath)
25
+ console.log('━'.repeat(60))
26
+
27
+ try {
28
+ const result = await validatePlugin(absolutePath)
29
+
30
+ if (result.valid) {
31
+ console.log('\n✅ 验证通过!所有检查项合规。\n')
32
+ if (result.warnings.length > 0) {
33
+ console.log('⚠️ 警告:')
34
+ result.warnings.forEach(w => console.log(' -', w))
35
+ }
36
+ process.exit(0)
37
+ } else {
38
+ console.log('\n❌ 验证失败!发现以下问题:\n')
39
+ result.errors.forEach((err, i) => {
40
+ console.log(`${i + 1}. [${err.rule}] ${err.message}`)
41
+ if (err.hint) console.log(` 提示: ${err.hint}`)
42
+ })
43
+ console.log()
44
+ process.exit(1)
45
+ }
46
+ } catch (error) {
47
+ console.error('\n💥 验证过程出错:', error.message)
48
+ process.exit(1)
49
+ }
@@ -0,0 +1,303 @@
1
+ /**
2
+ * DSH 插件验证器核心
3
+ * 强制检查插件是否符合规范
4
+ */
5
+
6
+ import { readFileSync, existsSync, statSync, readdirSync } from 'node:fs'
7
+ import { join, basename } from 'node:path'
8
+ import semver from 'semver'
9
+
10
+ /**
11
+ * 验证规则定义
12
+ */
13
+ const RULES = {
14
+ // 必需文件
15
+ REQUIRED_FILES: ['package.json', 'README.md', 'lib'],
16
+
17
+ // 包名规则:dsh-<name> / @org/dsh-<name>,或已发布作用域 @capyclaw/<name>
18
+ PACKAGE_NAME_PATTERN: /^((@[\w.-]+\/)?dsh-[\w.-]+|@capyclaw\/[\w.-]+)$/,
19
+
20
+ // 必需的 package.json 字段
21
+ REQUIRED_PKG_FIELDS: ['name', 'version', 'description', 'type', 'main', 'dsh', 'meta'],
22
+
23
+ // 必需的 dsh 字段
24
+ REQUIRED_DSH_FIELDS: ['category', 'platform'],
25
+
26
+ // 有效的插件分类
27
+ VALID_CATEGORIES: ['ui', 'service', 'bridge', 'tool', 'suite', 'skills'],
28
+
29
+ // 有效的平台
30
+ VALID_PLATFORMS: ['web', 'desktop', 'both'],
31
+
32
+ // 基础设施包的锁定版本范围(统一走 @capyclaw/* scope 名)
33
+ INFRASTRUCTURE_VERSIONS: {
34
+ '@capyclaw/foundation': '^0.1.1',
35
+ '@capyclaw/plugin-kit': '^0.2.0',
36
+ '@capyclaw/service-host': '^0.1.0',
37
+ '@capyclaw/tool-host': '^0.1.0',
38
+ '@capyclaw/asset-service': '^0.1.0',
39
+ '@capyclaw/suite-kit': '^0.1.0'
40
+ }
41
+ }
42
+
43
+ /**
44
+ * 验证插件
45
+ * @param {string} pluginPath - 插件目录的绝对路径
46
+ * @returns {Promise<{valid: boolean, errors: Array, warnings: Array}>}
47
+ */
48
+ export async function validatePlugin(pluginPath) {
49
+ const errors = []
50
+ const warnings = []
51
+
52
+ // 1. 检查目录存在
53
+ if (!existsSync(pluginPath)) {
54
+ return {
55
+ valid: false,
56
+ errors: [{ rule: 'PATH', message: `插件目录不存在: ${pluginPath}` }],
57
+ warnings: []
58
+ }
59
+ }
60
+
61
+ if (!statSync(pluginPath).isDirectory()) {
62
+ return {
63
+ valid: false,
64
+ errors: [{ rule: 'PATH', message: `路径不是目录: ${pluginPath}` }],
65
+ warnings: []
66
+ }
67
+ }
68
+
69
+ // 2. 加载 package.json(必需文件检查需要区分 suite-only 组合包)
70
+ let pkg
71
+ try {
72
+ const pkgPath = join(pluginPath, 'package.json')
73
+ pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
74
+ } catch (error) {
75
+ checkRequiredFiles(pluginPath, null, errors)
76
+ if (!errors.some(e => e.rule === 'REQUIRED_FILES')) {
77
+ errors.push({
78
+ rule: 'PACKAGE_JSON',
79
+ message: `package.json 格式错误: ${error.message}`
80
+ })
81
+ }
82
+ return { valid: false, errors, warnings }
83
+ }
84
+
85
+ // 3. 检查必需文件
86
+ checkRequiredFiles(pluginPath, pkg, errors)
87
+
88
+ // 4. 验证 package.json 内容
89
+ checkPackageJson(pkg, errors, warnings)
90
+
91
+ // 5. 验证目录结构
92
+ checkDirectoryStructure(pluginPath, pkg, errors, warnings)
93
+
94
+ // 6. 验证依赖
95
+ checkDependencies(pkg, errors, warnings)
96
+
97
+ return {
98
+ valid: errors.length === 0,
99
+ errors,
100
+ warnings
101
+ }
102
+ }
103
+
104
+ /**
105
+ * 检查必需文件
106
+ */
107
+ function checkRequiredFiles(pluginPath, pkg, errors) {
108
+ const suiteOnly = pkg?.dsh?.suite && !pkg?.main
109
+ /* 入口有两种合法形态:legacy 的 lib/ 目录,或 foundation ABI 的 plugin.mjs
110
+ * (由 package.json main 指向)。只要 main 可达即可,不再强制 lib/。 */
111
+ const hasEntry = Boolean(pkg?.main) && existsSync(join(pluginPath, pkg.main))
112
+ for (const file of RULES.REQUIRED_FILES) {
113
+ if (file === 'lib' && (suiteOnly || hasEntry)) continue
114
+ const filePath = join(pluginPath, file)
115
+ if (!existsSync(filePath)) {
116
+ errors.push({
117
+ rule: 'REQUIRED_FILES',
118
+ message: `缺少必需文件: ${file}`,
119
+ hint: file === 'lib' ? '创建 lib/ 目录并放入主入口文件' : `创建 ${file} 文件`
120
+ })
121
+ }
122
+ }
123
+ }
124
+
125
+ /**
126
+ * 验证 package.json
127
+ */
128
+ function checkPackageJson(pkg, errors, warnings) {
129
+ // 检查必需字段
130
+ for (const field of RULES.REQUIRED_PKG_FIELDS) {
131
+ // suite 组合包(dsh.suite 且无代码入口)没有 main 字段
132
+ if (field === 'main' && pkg.dsh?.suite && !pkg.main) continue
133
+ if (!pkg[field]) {
134
+ errors.push({
135
+ rule: 'PACKAGE_FIELDS',
136
+ message: `package.json 缺少必需字段: ${field}`,
137
+ hint: `在 package.json 中添加 "${field}" 字段`
138
+ })
139
+ }
140
+ }
141
+
142
+ // 检查包名规范
143
+ if (pkg.name && !RULES.PACKAGE_NAME_PATTERN.test(pkg.name)) {
144
+ errors.push({
145
+ rule: 'PACKAGE_NAME',
146
+ message: `包名不符合规范: ${pkg.name}`,
147
+ hint: '包名必须形如 "dsh-<name>"、"@org/dsh-<name>",或已发布作用域 "@capyclaw/<name>"'
148
+ })
149
+ }
150
+
151
+ // 检查版本号格式
152
+ if (pkg.version && !semver.valid(pkg.version)) {
153
+ errors.push({
154
+ rule: 'VERSION',
155
+ message: `版本号格式错误: ${pkg.version}`,
156
+ hint: '使用语义化版本,如 "1.0.0"'
157
+ })
158
+ }
159
+
160
+ // 检查 type 字段
161
+ if (pkg.type !== 'module') {
162
+ errors.push({
163
+ rule: 'MODULE_TYPE',
164
+ message: `必须使用 ESM 模块: type="${pkg.type || 'commonjs'}"`,
165
+ hint: '在 package.json 中设置 "type": "module"'
166
+ })
167
+ }
168
+
169
+ // 检查 dsh 字段
170
+ if (pkg.dsh) {
171
+ for (const field of RULES.REQUIRED_DSH_FIELDS) {
172
+ if (!pkg.dsh[field]) {
173
+ errors.push({
174
+ rule: 'DSH_FIELDS',
175
+ message: `dsh 配置缺少必需字段: ${field}`,
176
+ hint: `在 package.json 的 dsh 对象中添加 "${field}" 字段`
177
+ })
178
+ }
179
+ }
180
+
181
+ // 检查分类有效性
182
+ if (pkg.dsh.category && !RULES.VALID_CATEGORIES.includes(pkg.dsh.category)) {
183
+ errors.push({
184
+ rule: 'DSH_CATEGORY',
185
+ message: `无效的插件分类: ${pkg.dsh.category}`,
186
+ hint: `category 必须是: ${RULES.VALID_CATEGORIES.join(', ')}`
187
+ })
188
+ }
189
+
190
+ // 检查平台有效性
191
+ if (pkg.dsh.platform && !RULES.VALID_PLATFORMS.includes(pkg.dsh.platform)) {
192
+ errors.push({
193
+ rule: 'DSH_PLATFORM',
194
+ message: `无效的平台: ${pkg.dsh.platform}`,
195
+ hint: `platform 必须是: ${RULES.VALID_PLATFORMS.join(', ')}`
196
+ })
197
+ }
198
+ }
199
+
200
+ // 检查 meta 字段
201
+ if (pkg.meta) {
202
+ if (!pkg.meta.title) {
203
+ errors.push({
204
+ rule: 'META_TITLE',
205
+ message: 'meta.title 必需(用户可见的插件标题)',
206
+ hint: '在 package.json 的 meta 对象中添加 "title" 字段'
207
+ })
208
+ }
209
+ if (!pkg.meta.description) {
210
+ warnings.push('meta.description 建议提供(用户可见的详细描述)')
211
+ }
212
+ }
213
+ }
214
+
215
+ /**
216
+ * 检查目录结构
217
+ */
218
+ function checkDirectoryStructure(pluginPath, pkg, errors, warnings) {
219
+ // 检查 lib/ 目录内容
220
+ const libPath = join(pluginPath, 'lib')
221
+ if (existsSync(libPath)) {
222
+ const libFiles = readdirSync(libPath)
223
+ if (libFiles.length === 0) {
224
+ errors.push({
225
+ rule: 'LIB_EMPTY',
226
+ message: 'lib/ 目录为空',
227
+ hint: '在 lib/ 中添加主入口文件(如 index.mjs)'
228
+ })
229
+ }
230
+
231
+ // 检查 main 字段指向的文件是否存在
232
+ if (pkg.main) {
233
+ const mainPath = join(pluginPath, pkg.main)
234
+ if (!existsSync(mainPath)) {
235
+ errors.push({
236
+ rule: 'MAIN_NOT_FOUND',
237
+ message: `main 字段指向的文件不存在: ${pkg.main}`,
238
+ hint: '确保 main 字段指向的文件存在'
239
+ })
240
+ }
241
+ }
242
+ }
243
+
244
+ // 检查 README.md 内容
245
+ const readmePath = join(pluginPath, 'README.md')
246
+ if (existsSync(readmePath)) {
247
+ const readme = readFileSync(readmePath, 'utf-8')
248
+ if (readme.trim().length < 100) {
249
+ warnings.push('README.md 内容过少,建议补充使用说明')
250
+ }
251
+ }
252
+ }
253
+
254
+ /**
255
+ * 检查依赖
256
+ */
257
+ function checkDependencies(pkg, errors, warnings) {
258
+ const deps = pkg.dependencies || {}
259
+
260
+ // 强制:必须依赖 @capyclaw/foundation(新 ABI)或 @capyclaw/plugin-kit(legacy),suite 除外
261
+ if (pkg.dsh?.category !== 'suite') {
262
+ if (deps['@capyclaw/foundation']) {
263
+ const expectedVersion = RULES.INFRASTRUCTURE_VERSIONS['@capyclaw/foundation']
264
+ if (expectedVersion && !semver.satisfies(semver.coerce(deps['@capyclaw/foundation']), expectedVersion)) {
265
+ warnings.push(`@capyclaw/foundation 版本建议使用 ${expectedVersion},当前: ${deps['@capyclaw/foundation']}`)
266
+ }
267
+ } else if (!deps['@capyclaw/plugin-kit']) {
268
+ errors.push({
269
+ rule: 'PLUGIN_KIT_REQUIRED',
270
+ message: '必须依赖 @capyclaw/foundation 或 @capyclaw/plugin-kit',
271
+ hint: '在 dependencies 中添加 "@capyclaw/foundation": "^0.1.0"(新插件)'
272
+ })
273
+ } else {
274
+ // 检查版本范围
275
+ const expectedVersion = RULES.INFRASTRUCTURE_VERSIONS['@capyclaw/plugin-kit']
276
+ if (!semver.satisfies(semver.coerce(deps['@capyclaw/plugin-kit']), expectedVersion)) {
277
+ warnings.push(`@capyclaw/plugin-kit 版本建议使用 ${expectedVersion},当前: ${deps['@capyclaw/plugin-kit']}`)
278
+ }
279
+ }
280
+ }
281
+
282
+ // 检查其他基础设施包的版本
283
+ for (const [pkgName, expectedVersion] of Object.entries(RULES.INFRASTRUCTURE_VERSIONS)) {
284
+ if (deps[pkgName]) {
285
+ const actualVersion = deps[pkgName]
286
+ if (!semver.intersects(actualVersion, expectedVersion)) {
287
+ warnings.push(`${pkgName} 版本不匹配,建议: ${expectedVersion},当前: ${actualVersion}`)
288
+ }
289
+ }
290
+ }
291
+ }
292
+
293
+ /**
294
+ * 批量验证多个插件
295
+ */
296
+ export async function validatePlugins(pluginPaths) {
297
+ const results = []
298
+ for (const path of pluginPaths) {
299
+ const result = await validatePlugin(path)
300
+ results.push({ path, ...result })
301
+ }
302
+ return results
303
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@capyclaw/plugin-validator",
3
+ "version": "1.0.0",
4
+ "description": "DSH 插件强制验证工具:检查目录结构、依赖规范、代码质量",
5
+ "type": "module",
6
+ "main": "./lib/index.mjs",
7
+ "bin": {
8
+ "validate-plugin": "./bin/cli.mjs"
9
+ },
10
+ "scripts": {},
11
+ "dependencies": {
12
+ "semver": "^7.5.4",
13
+ "yaml": "^2.3.4"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/Maple496/capyclaw.git",
22
+ "directory": "C/tools/capyclaw-plugin-validator"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/Maple496/capyclaw/issues"
26
+ },
27
+ "homepage": "https://github.com/Maple496/capyclaw/tree/main/C/tools/capyclaw-plugin-validator#readme"
28
+ }
@@ -0,0 +1,56 @@
1
+ # @capyclaw/tool-host
2
+
3
+ DSH 公共工具面插件。把每个插件都会重复写的工具声明、注册表、参数校验、契约报告、MCP 协议壳和 instructions 模板收成一套。
4
+
5
+ ## 使用
6
+
7
+ ```js
8
+ export const inject = ['toolHost']
9
+
10
+ const echo = ctx.toolHost.defineTool({
11
+ name: 'demo_echo',
12
+ description: '回显文本',
13
+ inputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'] },
14
+ handler: ({ text }) => ({ content: [{ type: 'text', text }] }),
15
+ })
16
+
17
+ const capabilities = [
18
+ ctx.toolHost.defineCapability({ id: 'demo', title: 'Demo', tools: [echo] }),
19
+ ]
20
+
21
+ const registry = ctx.toolHost.createRegistry(capabilities)
22
+ const mcp = ctx.toolHost.createMcpHandler({
23
+ registry,
24
+ instructions: ctx.toolHost.buildInstructions({ title: 'Demo', capabilities: registry.CAPABILITIES }),
25
+ })
26
+ ```
27
+
28
+ ## 原生 DSH 工具面
29
+
30
+ ```js
31
+ export const inject = ['toolHost']
32
+
33
+ export function apply(ctx) {
34
+ const registry = ctx.toolHost.createRegistry(capabilities)
35
+ const dispose = ctx.toolHost.registerWithDsh(ctx, registry, { namespace: 'demo' })
36
+ return dispose
37
+ }
38
+ ```
39
+
40
+ 注册后工具直接出现在 `ctx.tools`,不需要 loopback `/mcp` 和 `dsh-mcp-client` row。
41
+ MCP handler 仍保留给跨进程/外部客户端。
42
+
43
+ ## 提供什么
44
+
45
+ - `defineTool` / `defineCapability`:声明式能力 DSL
46
+ - `createRegistry`:校验 id/工具名/依赖/服务唯一性,派生 `TOOLS / TOOL_IMPL / TOOL_META / FEATURES / CAPABILITIES`
47
+ - `createToolDispatcher`:统一参数校验后分派
48
+ - `createMcpHandler`:MCP Streamable HTTP(initialize / ping / tools/list / tools/call)
49
+ - `createCapabilityReport`:契约报告
50
+ - `buildInstructions`:MCP server instructions 模板
51
+
52
+ ## 边界
53
+
54
+ - 不绑定具体插件;PPT 只是第一个消费者
55
+ - 不负责 HTTP 监听;和 `@capyclaw/service-host` 组合使用
56
+ - 不负责契约快照文件;由构建脚本调用 `registry.ctx.contract.report()` 生成
@@ -0,0 +1,4 @@
1
+ # 由 @capyclaw/tool-host 提供;功能插件通过 inject: ['toolHost'] 或 ctx.get('toolHost') 使用。
2
+ - insert:
3
+ - id: tool-host
4
+ name: "@capyclaw/tool-host"
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "../capyclaw-suite-kit/suite.schema.json",
3
+ "name": "dsh-tool-host-suite",
4
+ "version": "0.3.0",
5
+ "title": "Tool Host",
6
+ "description": "通用工具面:能力 DSL、注册表、校验、契约、MCP 壳、跨套件能力描述符注册/发现。",
7
+ "packages": {
8
+ "@capyclaw/tool-host": {
9
+ "role": "provider",
10
+ "version": "^0.3.1",
11
+ "path": ".",
12
+ "provides": {
13
+ "services": [
14
+ "toolHost"
15
+ ],
16
+ "capabilities": {
17
+ "tools.registry": "1.0.0",
18
+ "tools.descriptors": "1.1.0"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ "rows": [
24
+ {
25
+ "id": "tool-host",
26
+ "name": "@capyclaw/tool-host"
27
+ }
28
+ ],
29
+ "checks": []
30
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @capyclaw/tool-host 插件:向同进程插件提供 ctx.toolHost。
3
+ *
4
+ * 同时落地“会话模式锁”这一基础设施能力:
5
+ * · 把 work-store 惰性解析器注入 toolHost(模式锁的存储真源);
6
+ * · 给 DSH tools 服务挂全局 guard(异领域调用硬拒兜底);
7
+ * · 注册框架核心工具 mode_lock / mode_status(无领域,恒可见)——显式锁定入口。
8
+ * 核心工具与 guard 的注册统一走 modeGate.install(tools)(幂等):apply 时 best-effort 挂一次,
9
+ * 若那一刻 tools 服务尚未就绪,首个套件注册(registerWithDsh / bridge host)会再调 install 补上,
10
+ * 故不依赖加载顺序。所有经 toolHost.registerWithDsh / bridge host 注册的领域能力自动受锁约束,套件零接线。
11
+ */
12
+ import { defineDriver } from '@capyclaw/foundation/abi'
13
+ import { createToolHost } from '../src/index.mjs'
14
+
15
+ const safeGet = (ctx, name) => {
16
+ try { return ctx.reflect?.get?.(name) ?? ctx[name] } catch { return null }
17
+ }
18
+
19
+ export const { name, inject, apply } = defineDriver({
20
+ name: 'tool-host',
21
+ service: 'toolHost',
22
+ apply(ctx, config = {}) {
23
+ const service = createToolHost({ ...config, getWorkStore: () => safeGet(ctx, 'workStore') })
24
+ const dispose = ctx.provide('toolHost', service)
25
+
26
+ /* 模式锁兜底闸 + 核心锁定工具(幂等)。tools 缺席则降级:稍后套件注册时经 install 补挂。
27
+ * install 返回引用计数 disposer,必须随 driver 卸载释放,否则核心工具/guard 永驻。 */
28
+ const tools = safeGet(ctx, 'tools')
29
+ const gateDispose = (tools && typeof tools.register === 'function') ? service.modeGate.install(tools) : null
30
+
31
+ console.log('[tool-host] ready (mode-gate enabled)')
32
+ return () => {
33
+ if (typeof gateDispose === 'function') gateDispose()
34
+ if (typeof dispose === 'function') dispose()
35
+ }
36
+ },
37
+ })