@capyclaw/publisher 0.1.4 → 0.1.6

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 (371) hide show
  1. package/node_modules/@capyclaw/foundation/README.md +51 -0
  2. package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
  3. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +88 -0
  4. package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
  5. package/node_modules/@capyclaw/foundation/abi/index.mjs +50 -0
  6. package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
  7. package/node_modules/@capyclaw/foundation/abi/loader.mjs +352 -0
  8. package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
  9. package/node_modules/@capyclaw/foundation/abi/spec.mjs +258 -0
  10. package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
  11. package/node_modules/@capyclaw/foundation/abi/version.mjs +140 -0
  12. package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
  13. package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
  14. package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
  15. package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
  16. package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
  17. package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
  18. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +72 -0
  19. package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
  20. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
  21. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -0
  22. package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
  23. package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
  24. package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
  25. package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
  26. package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
  27. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +38 -0
  28. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +88 -0
  29. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +54 -0
  30. package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +187 -0
  31. package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
  32. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +195 -0
  33. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -0
  34. package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
  35. package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
  36. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +198 -0
  37. package/node_modules/@capyclaw/foundation/package.json +53 -0
  38. package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
  39. package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
  40. package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
  41. package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
  42. package/node_modules/@capyclaw/plugin-kit/package.json +71 -0
  43. package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
  44. package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
  45. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +132 -0
  46. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
  47. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +60 -0
  48. package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
  49. package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
  50. package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
  51. package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
  52. package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
  53. package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
  54. package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
  55. package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
  56. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
  57. package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
  58. package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
  59. package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
  60. package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
  61. package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
  62. package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
  63. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
  64. package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
  65. package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
  66. package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
  67. package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
  68. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +664 -0
  69. package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
  70. package/node_modules/@capyclaw/plugin-validator/bin/cli.mjs +49 -0
  71. package/node_modules/@capyclaw/plugin-validator/lib/index.mjs +308 -0
  72. package/node_modules/@capyclaw/plugin-validator/package.json +30 -0
  73. package/node_modules/@capyclaw/tool-host/README.md +56 -0
  74. package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
  75. package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
  76. package/node_modules/@capyclaw/tool-host/lib/host.mjs +46 -0
  77. package/node_modules/@capyclaw/tool-host/package.json +59 -0
  78. package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
  79. package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
  80. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
  81. package/node_modules/@capyclaw/tool-host/src/index.mjs +461 -0
  82. package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +272 -0
  83. package/node_modules/semver/LICENSE +15 -0
  84. package/node_modules/semver/README.md +680 -0
  85. package/node_modules/semver/bin/semver.js +195 -0
  86. package/node_modules/semver/classes/comparator.js +143 -0
  87. package/node_modules/semver/classes/index.js +7 -0
  88. package/node_modules/semver/classes/range.js +577 -0
  89. package/node_modules/semver/classes/semver.js +350 -0
  90. package/node_modules/semver/functions/clean.js +8 -0
  91. package/node_modules/semver/functions/cmp.js +54 -0
  92. package/node_modules/semver/functions/coerce.js +62 -0
  93. package/node_modules/semver/functions/compare-build.js +9 -0
  94. package/node_modules/semver/functions/compare-loose.js +5 -0
  95. package/node_modules/semver/functions/compare.js +7 -0
  96. package/node_modules/semver/functions/diff.js +60 -0
  97. package/node_modules/semver/functions/eq.js +5 -0
  98. package/node_modules/semver/functions/gt.js +5 -0
  99. package/node_modules/semver/functions/gte.js +5 -0
  100. package/node_modules/semver/functions/inc.js +21 -0
  101. package/node_modules/semver/functions/lt.js +5 -0
  102. package/node_modules/semver/functions/lte.js +5 -0
  103. package/node_modules/semver/functions/major.js +5 -0
  104. package/node_modules/semver/functions/minor.js +5 -0
  105. package/node_modules/semver/functions/neq.js +5 -0
  106. package/node_modules/semver/functions/parse.js +18 -0
  107. package/node_modules/semver/functions/patch.js +5 -0
  108. package/node_modules/semver/functions/prerelease.js +8 -0
  109. package/node_modules/semver/functions/rcompare.js +5 -0
  110. package/node_modules/semver/functions/rsort.js +5 -0
  111. package/node_modules/semver/functions/satisfies.js +12 -0
  112. package/node_modules/semver/functions/sort.js +5 -0
  113. package/node_modules/semver/functions/truncate.js +48 -0
  114. package/node_modules/semver/functions/valid.js +8 -0
  115. package/node_modules/semver/index.js +93 -0
  116. package/node_modules/semver/internal/constants.js +67 -0
  117. package/node_modules/semver/internal/debug.js +11 -0
  118. package/node_modules/semver/internal/identifiers.js +29 -0
  119. package/node_modules/semver/internal/lrucache.js +42 -0
  120. package/node_modules/semver/internal/parse-options.js +17 -0
  121. package/node_modules/semver/internal/re.js +223 -0
  122. package/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  123. package/node_modules/semver/package.json +78 -0
  124. package/node_modules/semver/preload.js +4 -0
  125. package/node_modules/semver/range.bnf +17 -0
  126. package/node_modules/semver/ranges/gtr.js +6 -0
  127. package/node_modules/semver/ranges/intersects.js +9 -0
  128. package/node_modules/semver/ranges/ltr.js +6 -0
  129. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  130. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  131. package/node_modules/semver/ranges/min-version.js +63 -0
  132. package/node_modules/semver/ranges/outside.js +82 -0
  133. package/node_modules/semver/ranges/simplify.js +49 -0
  134. package/node_modules/semver/ranges/subset.js +249 -0
  135. package/node_modules/semver/ranges/to-comparators.js +10 -0
  136. package/node_modules/semver/ranges/valid.js +13 -0
  137. package/node_modules/yaml/LICENSE +13 -0
  138. package/node_modules/yaml/README.md +172 -0
  139. package/node_modules/yaml/bin.mjs +11 -0
  140. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  141. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  142. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  143. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  144. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  145. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  146. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  147. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  148. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  149. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  150. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
  151. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  152. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  153. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  154. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  155. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  156. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  157. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  158. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  159. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  160. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  161. package/node_modules/yaml/browser/dist/errors.js +57 -0
  162. package/node_modules/yaml/browser/dist/index.js +17 -0
  163. package/node_modules/yaml/browser/dist/log.js +11 -0
  164. package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
  165. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  166. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  167. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  168. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  169. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  170. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  171. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  172. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  173. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  174. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  175. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  176. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  177. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  178. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  179. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  180. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  181. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  182. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  183. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  184. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  185. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  186. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  187. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  188. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  189. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  190. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  191. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  192. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  193. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  194. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  195. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  196. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  197. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  198. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  199. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  200. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  201. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  202. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  203. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  204. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  205. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  206. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  207. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  208. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  209. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  210. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  211. package/node_modules/yaml/browser/dist/util.js +11 -0
  212. package/node_modules/yaml/browser/dist/visit.js +233 -0
  213. package/node_modules/yaml/browser/index.js +5 -0
  214. package/node_modules/yaml/browser/package.json +3 -0
  215. package/node_modules/yaml/dist/cli.d.ts +8 -0
  216. package/node_modules/yaml/dist/cli.mjs +201 -0
  217. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  218. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  219. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  220. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  221. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  222. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  223. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  224. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  225. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  226. package/node_modules/yaml/dist/compose/composer.js +224 -0
  227. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  228. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  229. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  230. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  231. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  232. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  233. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  234. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  235. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  236. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  237. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  238. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
  239. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  240. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  241. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  242. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  243. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  244. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  245. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  246. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  247. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  248. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  249. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  250. package/node_modules/yaml/dist/doc/Document.js +337 -0
  251. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  252. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  253. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  254. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  255. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  256. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  257. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  258. package/node_modules/yaml/dist/doc/directives.js +178 -0
  259. package/node_modules/yaml/dist/errors.d.ts +21 -0
  260. package/node_modules/yaml/dist/errors.js +62 -0
  261. package/node_modules/yaml/dist/index.d.ts +25 -0
  262. package/node_modules/yaml/dist/index.js +50 -0
  263. package/node_modules/yaml/dist/log.d.ts +3 -0
  264. package/node_modules/yaml/dist/log.js +19 -0
  265. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  266. package/node_modules/yaml/dist/nodes/Alias.js +120 -0
  267. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  268. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  269. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  270. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  271. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  272. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  273. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  274. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  275. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  276. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  277. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  278. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  279. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  280. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  281. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  282. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  283. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  284. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  285. package/node_modules/yaml/dist/options.d.ts +350 -0
  286. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  287. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  288. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  289. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  290. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  291. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  292. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  293. package/node_modules/yaml/dist/parse/cst.js +112 -0
  294. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  295. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  296. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  297. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  298. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  299. package/node_modules/yaml/dist/parse/parser.js +980 -0
  300. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  301. package/node_modules/yaml/dist/public-api.js +107 -0
  302. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  303. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  304. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  305. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  306. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  307. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  308. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  309. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  310. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  311. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  312. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  313. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  314. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  315. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  316. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  317. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  318. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  319. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  320. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  321. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  322. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  323. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  324. package/node_modules/yaml/dist/schema/tags.js +99 -0
  325. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  326. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  327. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  328. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  329. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  330. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  331. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  332. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  333. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  334. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  335. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  336. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  337. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  338. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  339. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  340. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  341. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  342. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  343. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  344. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  345. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  346. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  347. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  348. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  349. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  350. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  351. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  352. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  353. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  354. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  355. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  356. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  357. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  358. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  359. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  360. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  361. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  362. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  363. package/node_modules/yaml/dist/test-events.js +134 -0
  364. package/node_modules/yaml/dist/util.d.ts +16 -0
  365. package/node_modules/yaml/dist/util.js +28 -0
  366. package/node_modules/yaml/dist/visit.d.ts +102 -0
  367. package/node_modules/yaml/dist/visit.js +236 -0
  368. package/node_modules/yaml/package.json +97 -0
  369. package/node_modules/yaml/util.js +2 -0
  370. package/package.json +10 -2
  371. package/server/impl.mjs +43 -19
@@ -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,308 @@
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
+ * (导出供回归测试使用:test/versions.test.mjs 校验版本表与实际包版本对齐,M12)
13
+ */
14
+ export const RULES = {
15
+ // 必需文件
16
+ REQUIRED_FILES: ['package.json', 'README.md', 'lib'],
17
+
18
+ // 包名规则:dsh-<name> / @org/dsh-<name>,或已发布作用域 @capyclaw/<name>
19
+ PACKAGE_NAME_PATTERN: /^((@[\w.-]+\/)?dsh-[\w.-]+|@capyclaw\/[\w.-]+)$/,
20
+
21
+ // 必需的 package.json 字段
22
+ REQUIRED_PKG_FIELDS: ['name', 'version', 'description', 'type', 'main', 'dsh', 'meta'],
23
+
24
+ // 必需的 dsh 字段
25
+ REQUIRED_DSH_FIELDS: ['category', 'platform'],
26
+
27
+ // 有效的插件分类
28
+ VALID_CATEGORIES: ['ui', 'service', 'bridge', 'tool', 'suite', 'skills'],
29
+
30
+ // 有效的平台
31
+ VALID_PLATFORMS: ['web', 'desktop', 'both'],
32
+
33
+ // 基础设施包的锁定版本范围(统一走 @capyclaw/* scope 名)。
34
+ // M12 对齐:以 C/packages/<pkg>/package.json 的实际版本为准(2026-11-23 核对:
35
+ // foundation 0.1.10 / plugin-kit 0.2.7 / service-host 0.1.6 / tool-host 0.3.1 /
36
+ // asset-service 0.1.5 / suite-kit 0.2.0)。检查用 intersects/satisfies 语义,
37
+ // 旧声明(如 ^0.1.1、^0.3.0)仍与现值相交,不会新增噪音;真正过期的范围才告警。
38
+ INFRASTRUCTURE_VERSIONS: {
39
+ '@capyclaw/foundation': '^0.1.10',
40
+ '@capyclaw/plugin-kit': '^0.2.7',
41
+ '@capyclaw/service-host': '^0.1.6',
42
+ '@capyclaw/tool-host': '^0.3.1',
43
+ '@capyclaw/asset-service': '^0.1.5',
44
+ '@capyclaw/suite-kit': '^0.2.0'
45
+ }
46
+ }
47
+
48
+ /**
49
+ * 验证插件
50
+ * @param {string} pluginPath - 插件目录的绝对路径
51
+ * @returns {Promise<{valid: boolean, errors: Array, warnings: Array}>}
52
+ */
53
+ export async function validatePlugin(pluginPath) {
54
+ const errors = []
55
+ const warnings = []
56
+
57
+ // 1. 检查目录存在
58
+ if (!existsSync(pluginPath)) {
59
+ return {
60
+ valid: false,
61
+ errors: [{ rule: 'PATH', message: `插件目录不存在: ${pluginPath}` }],
62
+ warnings: []
63
+ }
64
+ }
65
+
66
+ if (!statSync(pluginPath).isDirectory()) {
67
+ return {
68
+ valid: false,
69
+ errors: [{ rule: 'PATH', message: `路径不是目录: ${pluginPath}` }],
70
+ warnings: []
71
+ }
72
+ }
73
+
74
+ // 2. 加载 package.json(必需文件检查需要区分 suite-only 组合包)
75
+ let pkg
76
+ try {
77
+ const pkgPath = join(pluginPath, 'package.json')
78
+ pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
79
+ } catch (error) {
80
+ checkRequiredFiles(pluginPath, null, errors)
81
+ if (!errors.some(e => e.rule === 'REQUIRED_FILES')) {
82
+ errors.push({
83
+ rule: 'PACKAGE_JSON',
84
+ message: `package.json 格式错误: ${error.message}`
85
+ })
86
+ }
87
+ return { valid: false, errors, warnings }
88
+ }
89
+
90
+ // 3. 检查必需文件
91
+ checkRequiredFiles(pluginPath, pkg, errors)
92
+
93
+ // 4. 验证 package.json 内容
94
+ checkPackageJson(pkg, errors, warnings)
95
+
96
+ // 5. 验证目录结构
97
+ checkDirectoryStructure(pluginPath, pkg, errors, warnings)
98
+
99
+ // 6. 验证依赖
100
+ checkDependencies(pkg, errors, warnings)
101
+
102
+ return {
103
+ valid: errors.length === 0,
104
+ errors,
105
+ warnings
106
+ }
107
+ }
108
+
109
+ /**
110
+ * 检查必需文件
111
+ */
112
+ function checkRequiredFiles(pluginPath, pkg, errors) {
113
+ const suiteOnly = pkg?.dsh?.suite && !pkg?.main
114
+ /* 入口有两种合法形态:legacy 的 lib/ 目录,或 foundation ABI 的 plugin.mjs
115
+ * (由 package.json main 指向)。只要 main 可达即可,不再强制 lib/。 */
116
+ const hasEntry = Boolean(pkg?.main) && existsSync(join(pluginPath, pkg.main))
117
+ for (const file of RULES.REQUIRED_FILES) {
118
+ if (file === 'lib' && (suiteOnly || hasEntry)) continue
119
+ const filePath = join(pluginPath, file)
120
+ if (!existsSync(filePath)) {
121
+ errors.push({
122
+ rule: 'REQUIRED_FILES',
123
+ message: `缺少必需文件: ${file}`,
124
+ hint: file === 'lib' ? '创建 lib/ 目录并放入主入口文件' : `创建 ${file} 文件`
125
+ })
126
+ }
127
+ }
128
+ }
129
+
130
+ /**
131
+ * 验证 package.json
132
+ */
133
+ function checkPackageJson(pkg, errors, warnings) {
134
+ // 检查必需字段
135
+ for (const field of RULES.REQUIRED_PKG_FIELDS) {
136
+ // suite 组合包(dsh.suite 且无代码入口)没有 main 字段
137
+ if (field === 'main' && pkg.dsh?.suite && !pkg.main) continue
138
+ if (!pkg[field]) {
139
+ errors.push({
140
+ rule: 'PACKAGE_FIELDS',
141
+ message: `package.json 缺少必需字段: ${field}`,
142
+ hint: `在 package.json 中添加 "${field}" 字段`
143
+ })
144
+ }
145
+ }
146
+
147
+ // 检查包名规范
148
+ if (pkg.name && !RULES.PACKAGE_NAME_PATTERN.test(pkg.name)) {
149
+ errors.push({
150
+ rule: 'PACKAGE_NAME',
151
+ message: `包名不符合规范: ${pkg.name}`,
152
+ hint: '包名必须形如 "dsh-<name>"、"@org/dsh-<name>",或已发布作用域 "@capyclaw/<name>"'
153
+ })
154
+ }
155
+
156
+ // 检查版本号格式
157
+ if (pkg.version && !semver.valid(pkg.version)) {
158
+ errors.push({
159
+ rule: 'VERSION',
160
+ message: `版本号格式错误: ${pkg.version}`,
161
+ hint: '使用语义化版本,如 "1.0.0"'
162
+ })
163
+ }
164
+
165
+ // 检查 type 字段
166
+ if (pkg.type !== 'module') {
167
+ errors.push({
168
+ rule: 'MODULE_TYPE',
169
+ message: `必须使用 ESM 模块: type="${pkg.type || 'commonjs'}"`,
170
+ hint: '在 package.json 中设置 "type": "module"'
171
+ })
172
+ }
173
+
174
+ // 检查 dsh 字段
175
+ if (pkg.dsh) {
176
+ for (const field of RULES.REQUIRED_DSH_FIELDS) {
177
+ if (!pkg.dsh[field]) {
178
+ errors.push({
179
+ rule: 'DSH_FIELDS',
180
+ message: `dsh 配置缺少必需字段: ${field}`,
181
+ hint: `在 package.json 的 dsh 对象中添加 "${field}" 字段`
182
+ })
183
+ }
184
+ }
185
+
186
+ // 检查分类有效性
187
+ if (pkg.dsh.category && !RULES.VALID_CATEGORIES.includes(pkg.dsh.category)) {
188
+ errors.push({
189
+ rule: 'DSH_CATEGORY',
190
+ message: `无效的插件分类: ${pkg.dsh.category}`,
191
+ hint: `category 必须是: ${RULES.VALID_CATEGORIES.join(', ')}`
192
+ })
193
+ }
194
+
195
+ // 检查平台有效性
196
+ if (pkg.dsh.platform && !RULES.VALID_PLATFORMS.includes(pkg.dsh.platform)) {
197
+ errors.push({
198
+ rule: 'DSH_PLATFORM',
199
+ message: `无效的平台: ${pkg.dsh.platform}`,
200
+ hint: `platform 必须是: ${RULES.VALID_PLATFORMS.join(', ')}`
201
+ })
202
+ }
203
+ }
204
+
205
+ // 检查 meta 字段
206
+ if (pkg.meta) {
207
+ if (!pkg.meta.title) {
208
+ errors.push({
209
+ rule: 'META_TITLE',
210
+ message: 'meta.title 必需(用户可见的插件标题)',
211
+ hint: '在 package.json 的 meta 对象中添加 "title" 字段'
212
+ })
213
+ }
214
+ if (!pkg.meta.description) {
215
+ warnings.push('meta.description 建议提供(用户可见的详细描述)')
216
+ }
217
+ }
218
+ }
219
+
220
+ /**
221
+ * 检查目录结构
222
+ */
223
+ function checkDirectoryStructure(pluginPath, pkg, errors, warnings) {
224
+ // 检查 lib/ 目录内容
225
+ const libPath = join(pluginPath, 'lib')
226
+ if (existsSync(libPath)) {
227
+ const libFiles = readdirSync(libPath)
228
+ if (libFiles.length === 0) {
229
+ errors.push({
230
+ rule: 'LIB_EMPTY',
231
+ message: 'lib/ 目录为空',
232
+ hint: '在 lib/ 中添加主入口文件(如 index.mjs)'
233
+ })
234
+ }
235
+
236
+ // 检查 main 字段指向的文件是否存在
237
+ if (pkg.main) {
238
+ const mainPath = join(pluginPath, pkg.main)
239
+ if (!existsSync(mainPath)) {
240
+ errors.push({
241
+ rule: 'MAIN_NOT_FOUND',
242
+ message: `main 字段指向的文件不存在: ${pkg.main}`,
243
+ hint: '确保 main 字段指向的文件存在'
244
+ })
245
+ }
246
+ }
247
+ }
248
+
249
+ // 检查 README.md 内容
250
+ const readmePath = join(pluginPath, 'README.md')
251
+ if (existsSync(readmePath)) {
252
+ const readme = readFileSync(readmePath, 'utf-8')
253
+ if (readme.trim().length < 100) {
254
+ warnings.push('README.md 内容过少,建议补充使用说明')
255
+ }
256
+ }
257
+ }
258
+
259
+ /**
260
+ * 检查依赖
261
+ */
262
+ function checkDependencies(pkg, errors, warnings) {
263
+ const deps = pkg.dependencies || {}
264
+
265
+ // 强制:必须依赖 @capyclaw/foundation(新 ABI)或 @capyclaw/plugin-kit(legacy),suite 除外
266
+ if (pkg.dsh?.category !== 'suite') {
267
+ if (deps['@capyclaw/foundation']) {
268
+ const expectedVersion = RULES.INFRASTRUCTURE_VERSIONS['@capyclaw/foundation']
269
+ if (expectedVersion && !semver.satisfies(semver.coerce(deps['@capyclaw/foundation']), expectedVersion)) {
270
+ warnings.push(`@capyclaw/foundation 版本建议使用 ${expectedVersion},当前: ${deps['@capyclaw/foundation']}`)
271
+ }
272
+ } else if (!deps['@capyclaw/plugin-kit']) {
273
+ errors.push({
274
+ rule: 'PLUGIN_KIT_REQUIRED',
275
+ message: '必须依赖 @capyclaw/foundation 或 @capyclaw/plugin-kit',
276
+ hint: '在 dependencies 中添加 "@capyclaw/foundation": "^0.1.0"(新插件)'
277
+ })
278
+ } else {
279
+ // 检查版本范围
280
+ const expectedVersion = RULES.INFRASTRUCTURE_VERSIONS['@capyclaw/plugin-kit']
281
+ if (!semver.satisfies(semver.coerce(deps['@capyclaw/plugin-kit']), expectedVersion)) {
282
+ warnings.push(`@capyclaw/plugin-kit 版本建议使用 ${expectedVersion},当前: ${deps['@capyclaw/plugin-kit']}`)
283
+ }
284
+ }
285
+ }
286
+
287
+ // 检查其他基础设施包的版本
288
+ for (const [pkgName, expectedVersion] of Object.entries(RULES.INFRASTRUCTURE_VERSIONS)) {
289
+ if (deps[pkgName]) {
290
+ const actualVersion = deps[pkgName]
291
+ if (!semver.intersects(actualVersion, expectedVersion)) {
292
+ warnings.push(`${pkgName} 版本不匹配,建议: ${expectedVersion},当前: ${actualVersion}`)
293
+ }
294
+ }
295
+ }
296
+ }
297
+
298
+ /**
299
+ * 批量验证多个插件
300
+ */
301
+ export async function validatePlugins(pluginPaths) {
302
+ const results = []
303
+ for (const path of pluginPaths) {
304
+ const result = await validatePlugin(path)
305
+ results.push({ path, ...result })
306
+ }
307
+ return results
308
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@capyclaw/plugin-validator",
3
+ "version": "1.0.1",
4
+ "description": "DSH 插件强制验证工具:检查目录结构、依赖规范、代码质量",
5
+ "type": "module",
6
+ "main": "./lib/index.mjs",
7
+ "bin": {
8
+ "validate-plugin": "./bin/cli.mjs"
9
+ },
10
+ "scripts": {
11
+ "test": "node --test test/*.test.mjs"
12
+ },
13
+ "dependencies": {
14
+ "semver": "^7.5.4",
15
+ "yaml": "^2.3.4"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/Maple496/capyclaw.git",
24
+ "directory": "C/tools/capyclaw-plugin-validator"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/Maple496/capyclaw/issues"
28
+ },
29
+ "homepage": "https://github.com/Maple496/capyclaw/tree/main/C/tools/capyclaw-plugin-validator#readme"
30
+ }
@@ -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.2",
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
+ }