@weavecode/weave 0.1.3 → 0.1.4

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 (451) hide show
  1. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/.editorconfig +1 -1
  2. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/CHANGELOG.md +45 -22
  3. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/README.md +26 -1
  4. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/dist/qs.js +27 -27
  5. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/eslint.config.mjs +61 -50
  6. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/formats.js +7 -2
  7. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/parse.js +13 -6
  8. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/stringify.js +5 -3
  9. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/utils.js +15 -7
  10. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/package.json +6 -6
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/node_modules/ip-address/dist/common.js +2 -2
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/node_modules/ip-address/package.json +2 -2
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/README.md +2 -3
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/helper/css/common.js +8 -3
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/jsx/base.js +1 -1
  18. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +8 -0
  19. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/serve-static/index.js +3 -1
  20. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/router/trie-router/node.js +2 -2
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/utils/url.js +11 -6
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/helper/css/common.js +8 -3
  23. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/helper/css/index.js +1 -1
  24. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/helper/route/index.js +3 -1
  25. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/jsx/base.js +1 -1
  26. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/bearer-auth/index.js +8 -0
  27. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/serve-static/index.js +3 -1
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/router/trie-router/node.js +2 -2
  29. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
  30. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
  31. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
  32. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
  33. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
  34. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
  35. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
  36. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
  37. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
  38. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
  39. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
  40. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/hono-base.d.ts +21 -9
  41. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/index.d.ts +1 -1
  42. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
  43. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
  44. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
  45. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
  46. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
  47. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
  48. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
  49. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
  50. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
  51. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/utils/url.js +11 -6
  52. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/package.json +1 -1
  53. package/node_modules/@weavecode/cli/dist/cli.js +4 -4
  54. package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
  55. package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
  56. package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
  57. package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -2
  58. package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
  59. package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
  60. package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
  61. package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
  62. package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
  63. package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +2 -1
  64. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +14 -0
  65. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +4 -3
  66. package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
  67. package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
  68. package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +3 -3
  69. package/node_modules/@weavecode/cli/dist/init/executor.d.ts +5 -4
  70. package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
  71. package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
  72. package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
  73. package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
  74. package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
  75. package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
  76. package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
  77. package/node_modules/@weavecode/cli/dist/init/provision.d.ts +25 -0
  78. package/node_modules/@weavecode/cli/dist/init/provision.js +1 -0
  79. package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
  80. package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
  81. package/node_modules/@weavecode/cli/dist/parser.js +1 -1
  82. package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
  83. package/node_modules/@weavecode/cli/dist/statusline/mock-input.js +1 -1
  84. package/node_modules/@weavecode/cli/dist/statusline/preview.js +2 -2
  85. package/node_modules/@weavecode/cli/package.json +5 -5
  86. package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
  87. package/node_modules/@weavecode/core/dist/harness.d.ts +13 -1
  88. package/node_modules/@weavecode/core/dist/harness.js +1 -1
  89. package/node_modules/@weavecode/core/dist/index.d.ts +1 -1
  90. package/node_modules/@weavecode/core/dist/index.js +1 -1
  91. package/node_modules/@weavecode/core/dist/platform.js +1 -1
  92. package/node_modules/@weavecode/core/dist/types.js +1 -1
  93. package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
  94. package/node_modules/@weavecode/core/dist/utils/logger.js +1 -1
  95. package/node_modules/@weavecode/core/package.json +1 -1
  96. package/node_modules/@weavecode/harness/dist/claude/assets.js +4 -4
  97. package/node_modules/@weavecode/harness/dist/claude/capture.js +9 -9
  98. package/node_modules/@weavecode/harness/dist/claude/commands.js +3 -3
  99. package/node_modules/@weavecode/harness/dist/claude/config.d.ts +9 -0
  100. package/node_modules/@weavecode/harness/dist/claude/config.js +2 -2
  101. package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
  102. package/node_modules/@weavecode/harness/dist/claude/edits.js +1 -1
  103. package/node_modules/@weavecode/harness/dist/claude/event-source.d.ts +2 -0
  104. package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
  105. package/node_modules/@weavecode/harness/dist/claude/images.js +2 -2
  106. package/node_modules/@weavecode/harness/dist/claude/index.d.ts +4 -2
  107. package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
  108. package/node_modules/@weavecode/harness/dist/claude/liveness.d.ts +64 -0
  109. package/node_modules/@weavecode/harness/dist/claude/liveness.js +1 -0
  110. package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -1
  111. package/node_modules/@weavecode/harness/dist/claude/messaging.js +2 -2
  112. package/node_modules/@weavecode/harness/dist/claude/model-aliases.d.ts +4 -0
  113. package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -1
  114. package/node_modules/@weavecode/harness/dist/claude/narration.d.ts +13 -0
  115. package/node_modules/@weavecode/harness/dist/claude/narration.js +1 -0
  116. package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
  117. package/node_modules/@weavecode/harness/dist/claude/plan.js +1 -1
  118. package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
  119. package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
  120. package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
  121. package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -2
  122. package/node_modules/@weavecode/harness/dist/claude/resume.js +1 -1
  123. package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -1
  124. package/node_modules/@weavecode/harness/dist/claude/side-question.js +2 -2
  125. package/node_modules/@weavecode/harness/dist/claude/statusline/generator.js +14 -14
  126. package/node_modules/@weavecode/harness/dist/claude/statusline/git-cache.js +1 -1
  127. package/node_modules/@weavecode/harness/dist/claude/statusline/surface.js +2 -2
  128. package/node_modules/@weavecode/harness/dist/claude/transcript.d.ts +13 -0
  129. package/node_modules/@weavecode/harness/dist/claude/transcript.js +7 -6
  130. package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
  131. package/node_modules/@weavecode/harness/dist/codex/capture.d.ts +1 -2
  132. package/node_modules/@weavecode/harness/dist/codex/capture.js +2 -2
  133. package/node_modules/@weavecode/harness/dist/codex/commands.js +4 -4
  134. package/node_modules/@weavecode/harness/dist/codex/config.d.ts +10 -0
  135. package/node_modules/@weavecode/harness/dist/codex/config.js +2 -2
  136. package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
  137. package/node_modules/@weavecode/harness/dist/codex/event-source.d.ts +1 -1
  138. package/node_modules/@weavecode/harness/dist/codex/event-source.js +2 -2
  139. package/node_modules/@weavecode/harness/dist/codex/images.d.ts +2 -0
  140. package/node_modules/@weavecode/harness/dist/codex/images.js +1 -0
  141. package/node_modules/@weavecode/harness/dist/codex/index.d.ts +13 -2
  142. package/node_modules/@weavecode/harness/dist/codex/index.js +1 -1
  143. package/node_modules/@weavecode/harness/dist/codex/liveness.d.ts +38 -0
  144. package/node_modules/@weavecode/harness/dist/codex/liveness.js +1 -0
  145. package/node_modules/@weavecode/harness/dist/codex/mcp.js +1 -1
  146. package/node_modules/@weavecode/harness/dist/codex/messaging.d.ts +7 -3
  147. package/node_modules/@weavecode/harness/dist/codex/messaging.js +3 -3
  148. package/node_modules/@weavecode/harness/dist/codex/narration.d.ts +10 -0
  149. package/node_modules/@weavecode/harness/dist/codex/narration.js +1 -0
  150. package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
  151. package/node_modules/@weavecode/harness/dist/codex/plugins.js +3 -3
  152. package/node_modules/@weavecode/harness/dist/codex/provision.d.ts +12 -0
  153. package/node_modules/@weavecode/harness/dist/codex/provision.js +1 -0
  154. package/node_modules/@weavecode/harness/dist/codex/questions.d.ts +9 -0
  155. package/node_modules/@weavecode/harness/dist/codex/questions.js +2 -0
  156. package/node_modules/@weavecode/harness/dist/codex/resume.js +1 -1
  157. package/node_modules/@weavecode/harness/dist/codex/rollout.d.ts +8 -5
  158. package/node_modules/@weavecode/harness/dist/codex/rollout.js +5 -5
  159. package/node_modules/@weavecode/harness/dist/codex/side-question.d.ts +12 -0
  160. package/node_modules/@weavecode/harness/dist/codex/side-question.js +4 -0
  161. package/node_modules/@weavecode/harness/dist/codex/titles.d.ts +8 -0
  162. package/node_modules/@weavecode/harness/dist/codex/titles.js +4 -0
  163. package/node_modules/@weavecode/harness/dist/codex/toml.js +13 -13
  164. package/node_modules/@weavecode/harness/dist/codex/transcript.js +2 -2
  165. package/node_modules/@weavecode/harness/dist/driver.d.ts +162 -8
  166. package/node_modules/@weavecode/harness/dist/driver.js +1 -1
  167. package/node_modules/@weavecode/harness/dist/index.d.ts +1 -0
  168. package/node_modules/@weavecode/harness/dist/index.js +1 -1
  169. package/node_modules/@weavecode/harness/dist/init/generated.js +2 -2
  170. package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
  171. package/node_modules/@weavecode/harness/dist/install.d.ts +9 -0
  172. package/node_modules/@weavecode/harness/dist/install.js +1 -0
  173. package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
  174. package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
  175. package/node_modules/@weavecode/harness/dist/shared/json-cap.js +1 -1
  176. package/node_modules/@weavecode/harness/dist/zcode/assets.js +1 -1
  177. package/node_modules/@weavecode/harness/dist/zcode/capture.js +3 -3
  178. package/node_modules/@weavecode/harness/dist/zcode/mcp.js +2 -2
  179. package/node_modules/@weavecode/harness/package.json +2 -2
  180. package/node_modules/@weavecode/server/dist/config/dotted.js +1 -1
  181. package/node_modules/@weavecode/server/dist/config/profiles.d.ts +10 -1
  182. package/node_modules/@weavecode/server/dist/config/profiles.js +2 -2
  183. package/node_modules/@weavecode/server/dist/daemon/ai-config.js +2 -2
  184. package/node_modules/@weavecode/server/dist/daemon/ai-context.js +6 -6
  185. package/node_modules/@weavecode/server/dist/daemon/ai-routes.js +4 -4
  186. package/node_modules/@weavecode/server/dist/daemon/api-log.js +3 -3
  187. package/node_modules/@weavecode/server/dist/daemon/auth-routes.js +1 -1
  188. package/node_modules/@weavecode/server/dist/daemon/auto-start.js +6 -6
  189. package/node_modules/@weavecode/server/dist/daemon/capture-routes.js +1 -1
  190. package/node_modules/@weavecode/server/dist/daemon/claude-liveness.d.ts +4 -55
  191. package/node_modules/@weavecode/server/dist/daemon/claude-liveness.js +1 -1
  192. package/node_modules/@weavecode/server/dist/daemon/config-routes.js +1 -1
  193. package/node_modules/@weavecode/server/dist/daemon/cron.js +1 -1
  194. package/node_modules/@weavecode/server/dist/daemon/dashboard-auth.js +2 -2
  195. package/node_modules/@weavecode/server/dist/daemon/dashboard-pusher.js +1 -1
  196. package/node_modules/@weavecode/server/dist/daemon/data-bus.js +1 -1
  197. package/node_modules/@weavecode/server/dist/daemon/decision-config.js +2 -2
  198. package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
  199. package/node_modules/@weavecode/server/dist/daemon/fs-browser.js +1 -1
  200. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.d.ts +2 -0
  201. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.js +1 -1
  202. package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
  203. package/node_modules/@weavecode/server/dist/daemon/http.js +1 -1
  204. package/node_modules/@weavecode/server/dist/daemon/liveness.d.ts +7 -0
  205. package/node_modules/@weavecode/server/dist/daemon/liveness.js +1 -0
  206. package/node_modules/@weavecode/server/dist/daemon/mcp-orchestration.js +1 -1
  207. package/node_modules/@weavecode/server/dist/daemon/narration-watcher.d.ts +28 -0
  208. package/node_modules/@weavecode/server/dist/daemon/narration-watcher.js +2 -0
  209. package/node_modules/@weavecode/server/dist/daemon/opener/backend-ghostty.d.ts +16 -0
  210. package/node_modules/@weavecode/server/dist/daemon/opener/backend-ghostty.js +1 -0
  211. package/node_modules/@weavecode/server/dist/daemon/opener/backend-iterm.d.ts +20 -0
  212. package/node_modules/@weavecode/server/dist/daemon/opener/backend-iterm.js +12 -0
  213. package/node_modules/@weavecode/server/dist/daemon/opener/backend-konsole.d.ts +23 -0
  214. package/node_modules/@weavecode/server/dist/daemon/opener/backend-konsole.js +2 -0
  215. package/node_modules/@weavecode/server/dist/daemon/opener/backend-terminal-app.d.ts +19 -0
  216. package/node_modules/@weavecode/server/dist/daemon/opener/backend-terminal-app.js +1 -0
  217. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wezterm.d.ts +87 -0
  218. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wezterm.js +1 -0
  219. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wt.d.ts +45 -0
  220. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wt.js +1 -0
  221. package/node_modules/@weavecode/server/dist/daemon/opener/backend.d.ts +115 -0
  222. package/node_modules/@weavecode/server/dist/daemon/opener/backend.js +1 -0
  223. package/node_modules/@weavecode/server/dist/daemon/opener/launch.js +1 -1
  224. package/node_modules/@weavecode/server/dist/daemon/opener/pty-terminals.js +4 -4
  225. package/node_modules/@weavecode/server/dist/daemon/opener/shared.js +1 -1
  226. package/node_modules/@weavecode/server/dist/daemon/opener/wezterm-mux.d.ts +8 -5
  227. package/node_modules/@weavecode/server/dist/daemon/opener/wezterm-mux.js +1 -1
  228. package/node_modules/@weavecode/server/dist/daemon/opener/wt.js +3 -3
  229. package/node_modules/@weavecode/server/dist/daemon/opener.d.ts +23 -120
  230. package/node_modules/@weavecode/server/dist/daemon/opener.js +1 -13
  231. package/node_modules/@weavecode/server/dist/daemon/port.js +1 -1
  232. package/node_modules/@weavecode/server/dist/daemon/project-files.d.ts +17 -2
  233. package/node_modules/@weavecode/server/dist/daemon/project-files.js +2 -1
  234. package/node_modules/@weavecode/server/dist/daemon/project-harnesses.d.ts +2 -0
  235. package/node_modules/@weavecode/server/dist/daemon/project-harnesses.js +2 -2
  236. package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.js +1 -1
  237. package/node_modules/@weavecode/server/dist/daemon/prompt-images.js +1 -1
  238. package/node_modules/@weavecode/server/dist/daemon/routes/hooks-admin.js +1 -1
  239. package/node_modules/@weavecode/server/dist/daemon/routes/market.js +1 -1
  240. package/node_modules/@weavecode/server/dist/daemon/routes/orchestration.js +1 -1
  241. package/node_modules/@weavecode/server/dist/daemon/routes/path-refs.js +1 -1
  242. package/node_modules/@weavecode/server/dist/daemon/routes/project-files.d.ts +6 -0
  243. package/node_modules/@weavecode/server/dist/daemon/routes/project-files.js +1 -0
  244. package/node_modules/@weavecode/server/dist/daemon/routes/projects.js +1 -1
  245. package/node_modules/@weavecode/server/dist/daemon/routes/search.d.ts +38 -0
  246. package/node_modules/@weavecode/server/dist/daemon/routes/search.js +1 -0
  247. package/node_modules/@weavecode/server/dist/daemon/routes/session-control.js +1 -1
  248. package/node_modules/@weavecode/server/dist/daemon/routes/session-insights.js +1 -1
  249. package/node_modules/@weavecode/server/dist/daemon/routes/settings-statusline.js +1 -1
  250. package/node_modules/@weavecode/server/dist/daemon/routes/uploads.js +1 -1
  251. package/node_modules/@weavecode/server/dist/daemon/routes/watches.js +1 -1
  252. package/node_modules/@weavecode/server/dist/daemon/server.d.ts +8 -2
  253. package/node_modules/@weavecode/server/dist/daemon/server.js +8 -8
  254. package/node_modules/@weavecode/server/dist/daemon/session-open.d.ts +10 -1
  255. package/node_modules/@weavecode/server/dist/daemon/session-open.js +1 -1
  256. package/node_modules/@weavecode/server/dist/daemon/session-probe.js +1 -1
  257. package/node_modules/@weavecode/server/dist/daemon/settings.js +2 -2
  258. package/node_modules/@weavecode/server/dist/daemon/snapshot-refresher.js +1 -1
  259. package/node_modules/@weavecode/server/dist/daemon/sse-hub.js +1 -1
  260. package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
  261. package/node_modules/@weavecode/server/dist/daemon/state.js +2 -2
  262. package/node_modules/@weavecode/server/dist/daemon/static.js +1 -1
  263. package/node_modules/@weavecode/server/dist/daemon/terminal-topology-refresher.js +1 -1
  264. package/node_modules/@weavecode/server/dist/daemon/tls.js +1 -1
  265. package/node_modules/@weavecode/server/dist/daemon/toolkit-routes.js +1 -1
  266. package/node_modules/@weavecode/server/dist/daemon/upload-sessions.js +1 -1
  267. package/node_modules/@weavecode/server/dist/db/db.js +5 -2
  268. package/node_modules/@weavecode/server/dist/db/layout.js +1 -1
  269. package/node_modules/@weavecode/server/dist/hooks/answer-keys.js +1 -1
  270. package/node_modules/@weavecode/server/dist/hooks/bus.d.ts +10 -0
  271. package/node_modules/@weavecode/server/dist/hooks/bus.js +1 -1
  272. package/node_modules/@weavecode/server/dist/hooks/dashboard-rate.js +1 -1
  273. package/node_modules/@weavecode/server/dist/hooks/decision-judge.js +1 -1
  274. package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.d.ts +20 -0
  275. package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.js +1 -1
  276. package/node_modules/@weavecode/server/dist/hooks/delivery/channels.js +1 -1
  277. package/node_modules/@weavecode/server/dist/hooks/delivery/keys.d.ts +7 -1
  278. package/node_modules/@weavecode/server/dist/hooks/delivery/keys.js +1 -1
  279. package/node_modules/@weavecode/server/dist/hooks/delivery/queue.d.ts +4 -4
  280. package/node_modules/@weavecode/server/dist/hooks/delivery/queue.js +1 -1
  281. package/node_modules/@weavecode/server/dist/hooks/delivery/relay.js +1 -1
  282. package/node_modules/@weavecode/server/dist/hooks/delivery/send.js +2 -2
  283. package/node_modules/@weavecode/server/dist/hooks/delivery/views.d.ts +3 -1
  284. package/node_modules/@weavecode/server/dist/hooks/delivery/views.js +1 -1
  285. package/node_modules/@weavecode/server/dist/hooks/dispatcher.d.ts +5 -0
  286. package/node_modules/@weavecode/server/dist/hooks/dispatcher.js +6 -6
  287. package/node_modules/@weavecode/server/dist/hooks/edge-extract.js +1 -1
  288. package/node_modules/@weavecode/server/dist/hooks/handlers/webhook.js +1 -1
  289. package/node_modules/@weavecode/server/dist/hooks/headless-runner.js +2 -2
  290. package/node_modules/@weavecode/server/dist/hooks/inbox-socket.js +2 -2
  291. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.d.ts +15 -0
  292. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.js +3 -3
  293. package/node_modules/@weavecode/server/dist/hooks/match.js +1 -1
  294. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.d.ts +64 -6
  295. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +3 -2
  296. package/node_modules/@weavecode/server/dist/hooks/mirror.js +4 -4
  297. package/node_modules/@weavecode/server/dist/hooks/orchestration-engine.js +7 -7
  298. package/node_modules/@weavecode/server/dist/hooks/orchestration-graph.js +1 -1
  299. package/node_modules/@weavecode/server/dist/hooks/plugin-installer.d.ts +5 -0
  300. package/node_modules/@weavecode/server/dist/hooks/plugin-installer.js +3 -3
  301. package/node_modules/@weavecode/server/dist/hooks/plugin-loader.js +1 -1
  302. package/node_modules/@weavecode/server/dist/hooks/plugin-project-state.js +1 -1
  303. package/node_modules/@weavecode/server/dist/hooks/prompt-flusher.js +1 -1
  304. package/node_modules/@weavecode/server/dist/hooks/promptbox.js +8 -8
  305. package/node_modules/@weavecode/server/dist/hooks/push-notify.js +2 -2
  306. package/node_modules/@weavecode/server/dist/hooks/question-tracker.js +1 -1
  307. package/node_modules/@weavecode/server/dist/hooks/registry.js +1 -1
  308. package/node_modules/@weavecode/server/dist/hooks/resume-runner.js +1 -1
  309. package/node_modules/@weavecode/server/dist/hooks/session-purge.js +1 -1
  310. package/node_modules/@weavecode/server/dist/hooks/session-sweeper.d.ts +2 -0
  311. package/node_modules/@weavecode/server/dist/hooks/session-sweeper.js +1 -1
  312. package/node_modules/@weavecode/server/dist/hooks/side-questions.js +1 -1
  313. package/node_modules/@weavecode/server/dist/hooks/synthetic-sessions.js +1 -1
  314. package/node_modules/@weavecode/server/dist/hooks/toolkit-scan.js +1 -1
  315. package/node_modules/@weavecode/server/dist/hooks/toolkit.js +5 -5
  316. package/node_modules/@weavecode/server/dist/hooks/watch-engine.js +1 -1
  317. package/node_modules/@weavecode/server/dist/index.d.ts +1 -0
  318. package/node_modules/@weavecode/server/dist/index.js +1 -1
  319. package/node_modules/@weavecode/server/dist/install/apply-update.js +1 -1
  320. package/node_modules/@weavecode/server/dist/install/capabilities.js +1 -1
  321. package/node_modules/@weavecode/server/dist/install/codex-toml.js +1 -1
  322. package/node_modules/@weavecode/server/dist/install/file-assets.js +1 -1
  323. package/node_modules/@weavecode/server/dist/install/fingerprint.js +1 -1
  324. package/node_modules/@weavecode/server/dist/install/global-config.js +1 -1
  325. package/node_modules/@weavecode/server/dist/install/global-file-assets.js +1 -1
  326. package/node_modules/@weavecode/server/dist/install/init-files.js +2 -2
  327. package/node_modules/@weavecode/server/dist/install/install-ledger.js +1 -1
  328. package/node_modules/@weavecode/server/dist/install/installer.js +1 -1
  329. package/node_modules/@weavecode/server/dist/install/library-index.js +1 -1
  330. package/node_modules/@weavecode/server/dist/install/mcp-rows.js +1 -1
  331. package/node_modules/@weavecode/server/dist/install/plugin-install.js +1 -1
  332. package/node_modules/@weavecode/server/dist/install/plugin-rows.js +1 -1
  333. package/node_modules/@weavecode/server/dist/install/plugin-templates.js +1 -1
  334. package/node_modules/@weavecode/server/dist/install/project-config.js +1 -1
  335. package/node_modules/@weavecode/server/dist/install/reader.js +1 -1
  336. package/node_modules/@weavecode/server/dist/install/scan-cache.js +1 -1
  337. package/node_modules/@weavecode/server/dist/install/scanner.js +1 -1
  338. package/node_modules/@weavecode/server/dist/install/settings-mcp.js +2 -2
  339. package/node_modules/@weavecode/server/dist/install/updates.js +1 -1
  340. package/node_modules/@weavecode/server/dist/market/builtin.js +1 -1
  341. package/node_modules/@weavecode/server/dist/market/identity.js +1 -1
  342. package/node_modules/@weavecode/server/dist/market/import.js +2 -2
  343. package/node_modules/@weavecode/server/dist/market/refresh.js +1 -1
  344. package/node_modules/@weavecode/server/dist/market/resolve.js +1 -1
  345. package/node_modules/@weavecode/server/dist/market/updates.js +1 -1
  346. package/node_modules/@weavecode/server/dist/registry.js +2 -2
  347. package/node_modules/@weavecode/server/dist/repositories/hook-dispatches.js +5 -5
  348. package/node_modules/@weavecode/server/dist/repositories/hook-events.d.ts +19 -1
  349. package/node_modules/@weavecode/server/dist/repositories/hook-events.js +9 -3
  350. package/node_modules/@weavecode/server/dist/repositories/hook-rules.js +4 -4
  351. package/node_modules/@weavecode/server/dist/repositories/libraries.js +1 -1
  352. package/node_modules/@weavecode/server/dist/repositories/orchestrations.js +7 -7
  353. package/node_modules/@weavecode/server/dist/repositories/plugin-states.js +1 -1
  354. package/node_modules/@weavecode/server/dist/repositories/projects.js +2 -2
  355. package/node_modules/@weavecode/server/dist/repositories/push-subscriptions.js +2 -2
  356. package/node_modules/@weavecode/server/dist/repositories/session-watches.js +4 -4
  357. package/node_modules/@weavecode/server/dist/repositories/sessions.d.ts +12 -2
  358. package/node_modules/@weavecode/server/dist/repositories/sessions.js +2 -2
  359. package/node_modules/@weavecode/server/dist/repositories/side-questions.d.ts +7 -0
  360. package/node_modules/@weavecode/server/dist/repositories/side-questions.js +8 -5
  361. package/node_modules/@weavecode/server/dist/repositories/uploads.js +11 -11
  362. package/node_modules/@weavecode/server/dist/statusline/cache-sweeper.js +1 -1
  363. package/node_modules/@weavecode/server/dist/statusline/generator.js +1 -1
  364. package/node_modules/@weavecode/server/dist/statusline/manager.js +3 -3
  365. package/node_modules/@weavecode/server/dist/surfaces.d.ts +8 -1
  366. package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
  367. package/node_modules/@weavecode/server/dist/version.d.ts +1 -11
  368. package/node_modules/@weavecode/server/dist/version.js +1 -1
  369. package/node_modules/@weavecode/server/dist/watch/cache.js +1 -1
  370. package/node_modules/@weavecode/server/dist/watch/classifier.js +1 -1
  371. package/node_modules/@weavecode/server/dist/watch/plugin-mods.js +1 -1
  372. package/node_modules/@weavecode/server/dist/watch/sync-scheduler.js +1 -1
  373. package/node_modules/@weavecode/server/dist/watch/watch-service.js +1 -1
  374. package/node_modules/@weavecode/server/package.json +4 -4
  375. package/node_modules/@weavecode/server/web/dist/assets/{abnfDiagram-WEYOIA3C-etRkSvQM.js → abnfDiagram-WEYOIA3C-DA-K085F.js} +1 -1
  376. package/node_modules/@weavecode/server/web/dist/assets/{arc-FxRZALAZ.js → arc-BI1jnmdZ.js} +1 -1
  377. package/node_modules/@weavecode/server/web/dist/assets/{architectureDiagram-ZHVYKT53-5OxZ-ffz.js → architectureDiagram-ZHVYKT53-DbdBgric.js} +1 -1
  378. package/node_modules/@weavecode/server/web/dist/assets/{blockDiagram-RJAE7QA3-C-CgMF0O.js → blockDiagram-RJAE7QA3-BPRBmzb-.js} +1 -1
  379. package/node_modules/@weavecode/server/web/dist/assets/{c4Diagram-XDPPPE54-B6TqN1Pw.js → c4Diagram-XDPPPE54-C4D5sRs1.js} +1 -1
  380. package/node_modules/@weavecode/server/web/dist/assets/channel-DcCJrvon.js +1 -0
  381. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2E7WHVMD-Bdzr5RRj.js → chunk-2E7WHVMD-9ZSKiNU3.js} +1 -1
  382. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2Q5K7J3B-gBZASjAC.js → chunk-2Q5K7J3B-i0AOjw_8.js} +1 -1
  383. package/node_modules/@weavecode/server/web/dist/assets/{chunk-4EMNKR2T-DSlUhKMw.js → chunk-4EMNKR2T-DTpLfX1H.js} +1 -1
  384. package/node_modules/@weavecode/server/web/dist/assets/{chunk-55XCU76K-BDQ6zpGR.js → chunk-55XCU76K-COQYRD4q.js} +1 -1
  385. package/node_modules/@weavecode/server/web/dist/assets/{chunk-5VM5RSS4-DPnewKbl.js → chunk-5VM5RSS4-VsftEbvo.js} +1 -1
  386. package/node_modules/@weavecode/server/web/dist/assets/{chunk-JWPE2WC7-DagmT8Cc.js → chunk-JWPE2WC7-DonektJN.js} +1 -1
  387. package/node_modules/@weavecode/server/web/dist/assets/{chunk-VQ5W62QI-Da_2PxfM.js → chunk-VQ5W62QI-CaKUwuul.js} +1 -1
  388. package/node_modules/@weavecode/server/web/dist/assets/{chunk-XXDRQBXY-Cdaysois.js → chunk-XXDRQBXY-DXH3D_MT.js} +1 -1
  389. package/node_modules/@weavecode/server/web/dist/assets/{chunk-ZCHMQSOR-CvgYfbjU.js → chunk-ZCHMQSOR-COwyAuGn.js} +2 -2
  390. package/node_modules/@weavecode/server/web/dist/assets/{classDiagram-v2-4MYWR3UA-ahplYD2h.js → classDiagram-v2-4MYWR3UA-DEvMZ6mX.js} +1 -1
  391. package/node_modules/@weavecode/server/web/dist/assets/{cose-bilkent-JH36ORCC-DFyUfgKj.js → cose-bilkent-JH36ORCC-6JBJHfH6.js} +1 -1
  392. package/node_modules/@weavecode/server/web/dist/assets/{cynefin-EF2NZ3EQ-mr2qRwod.js → cynefin-EF2NZ3EQ-C4GM4sjT.js} +1 -1
  393. package/node_modules/@weavecode/server/web/dist/assets/{cynefinDiagram-WF24UDRP-BC26VqNp.js → cynefinDiagram-WF24UDRP-Cqgi0MBP.js} +1 -1
  394. package/node_modules/@weavecode/server/web/dist/assets/{dagre-NK4GIZVX-DoKn_P1x.js → dagre-NK4GIZVX-CljrnkCY.js} +1 -1
  395. package/node_modules/@weavecode/server/web/dist/assets/{diagram-CBK3MWTC-C9WfEmt3.js → diagram-CBK3MWTC-C3PyOj5J.js} +1 -1
  396. package/node_modules/@weavecode/server/web/dist/assets/{diagram-I5XIIV2D-D4Ibieda.js → diagram-I5XIIV2D-I5brQlaZ.js} +1 -1
  397. package/node_modules/@weavecode/server/web/dist/assets/{diagram-ODIL2UCW-wsLbYLi0.js → diagram-ODIL2UCW-BX9uFNbU.js} +1 -1
  398. package/node_modules/@weavecode/server/web/dist/assets/{diagram-PFBEJUXE-DBioMmDk.js → diagram-PFBEJUXE-y7D-VmqJ.js} +1 -1
  399. package/node_modules/@weavecode/server/web/dist/assets/{diagram-RJA3I4VV-Cl5gKsWm.js → diagram-RJA3I4VV-DLUL8W42.js} +1 -1
  400. package/node_modules/@weavecode/server/web/dist/assets/{diagram-TYUNFSNR-BSXOaZic.js → diagram-TYUNFSNR-DLCC3ILi.js} +1 -1
  401. package/node_modules/@weavecode/server/web/dist/assets/{ebnfDiagram-V4P3TTPT-CJIGOag6.js → ebnfDiagram-V4P3TTPT-D7vALia7.js} +1 -1
  402. package/node_modules/@weavecode/server/web/dist/assets/{elk-QONTBCTQ-D6nd2OVX.js → elk-QONTBCTQ-Ct2_hatz.js} +1 -1
  403. package/node_modules/@weavecode/server/web/dist/assets/{erDiagram-KYQIGQAA-gmXjWsuF.js → erDiagram-KYQIGQAA-DxLai58T.js} +1 -1
  404. package/node_modules/@weavecode/server/web/dist/assets/{flowDiagram-IUGLLWBU-DWAiZ43K.js → flowDiagram-IUGLLWBU-AWn2IHrF.js} +1 -1
  405. package/node_modules/@weavecode/server/web/dist/assets/{ganttDiagram-R7GPNTJY-De4v6Wtt.js → ganttDiagram-R7GPNTJY-DmRHd4Wz.js} +1 -1
  406. package/node_modules/@weavecode/server/web/dist/assets/{gitGraphDiagram-PDYL7XHY-CouLBWOB.js → gitGraphDiagram-PDYL7XHY-Ccj-t3zg.js} +1 -1
  407. package/node_modules/@weavecode/server/web/dist/assets/index-BSxzia7U.js +1031 -0
  408. package/node_modules/@weavecode/server/web/dist/assets/index-CEpJpR7P.css +11 -0
  409. package/node_modules/@weavecode/server/web/dist/assets/{infoDiagram-MVDRKAX5-CeMCdduD.js → infoDiagram-MVDRKAX5-BHquFlQa.js} +1 -1
  410. package/node_modules/@weavecode/server/web/dist/assets/{ishikawaDiagram-HPEHV2GE-DK6hETwg.js → ishikawaDiagram-HPEHV2GE-CVogEbdm.js} +1 -1
  411. package/node_modules/@weavecode/server/web/dist/assets/{journeyDiagram-BOSHW7O7-BcgwTlST.js → journeyDiagram-BOSHW7O7-DC9XG9oh.js} +1 -1
  412. package/node_modules/@weavecode/server/web/dist/assets/{kanban-definition-FNSA4HC5-CTVMJNz2.js → kanban-definition-FNSA4HC5-C_eu7DC_.js} +1 -1
  413. package/node_modules/@weavecode/server/web/dist/assets/{linear-CqQf5eWO.js → linear-keTbWHJ-.js} +1 -1
  414. package/node_modules/@weavecode/server/web/dist/assets/{mermaid.core-B6KZaljU.js → mermaid.core-4sbg0MnY.js} +4 -4
  415. package/node_modules/@weavecode/server/web/dist/assets/{mindmap-definition-6OY57UG3-cpKvrQTI.js → mindmap-definition-6OY57UG3-kMQS0S2l.js} +1 -1
  416. package/node_modules/@weavecode/server/web/dist/assets/{pegDiagram-ECIUJNBX-Bv2bNqMZ.js → pegDiagram-ECIUJNBX-DcUFoEwP.js} +1 -1
  417. package/node_modules/@weavecode/server/web/dist/assets/{pieDiagram-GNMPY74T-CXOnA429.js → pieDiagram-GNMPY74T-BQJ7WDCx.js} +1 -1
  418. package/node_modules/@weavecode/server/web/dist/assets/{quadrantDiagram-D57K4MC3-BFDUpWZb.js → quadrantDiagram-D57K4MC3-C7Oi1-sq.js} +1 -1
  419. package/node_modules/@weavecode/server/web/dist/assets/{railroadDiagram-Y72NRBL7-BHoDSO0D.js → railroadDiagram-Y72NRBL7-CEF2QbOF.js} +1 -1
  420. package/node_modules/@weavecode/server/web/dist/assets/{requirementDiagram-EQYSW5RA-B8JGji7q.js → requirementDiagram-EQYSW5RA-CTjjFS7X.js} +1 -1
  421. package/node_modules/@weavecode/server/web/dist/assets/{sankeyDiagram-SY24JHO5-BbE2-6ZM.js → sankeyDiagram-SY24JHO5-j0S5kubS.js} +1 -1
  422. package/node_modules/@weavecode/server/web/dist/assets/{sequenceDiagram-BLEHNHQU-DwK4X2MT.js → sequenceDiagram-BLEHNHQU-B76EsZp4.js} +1 -1
  423. package/node_modules/@weavecode/server/web/dist/assets/{sizeCapture-INFHLROL-CY10zRMe.js → sizeCapture-INFHLROL-r0DZuqAy.js} +1 -1
  424. package/node_modules/@weavecode/server/web/dist/assets/{stateDiagram-v2-A6IESKWZ-32t4Zx8b.js → stateDiagram-v2-A6IESKWZ-B4DR9LHz.js} +1 -1
  425. package/node_modules/@weavecode/server/web/dist/assets/{swimlanes-B3ENRKFQ-CZlYQ8_g.js → swimlanes-B3ENRKFQ-Dbcl85ro.js} +1 -1
  426. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-CZ_6SSBd.js +8 -0
  427. package/node_modules/@weavecode/server/web/dist/assets/{timeline-definition-JXYKGLGB-8VsB-Jwg.js → timeline-definition-JXYKGLGB-BlBXXRNf.js} +1 -1
  428. package/node_modules/@weavecode/server/web/dist/assets/{usecaseDiagram-WPOLBNNX-CKOTONay.js → usecaseDiagram-WPOLBNNX-Ck1M0dpc.js} +1 -1
  429. package/node_modules/@weavecode/server/web/dist/assets/{vennDiagram-Q3Y3IDCW-BzrNjxtm.js → vennDiagram-Q3Y3IDCW-N8B-ohWk.js} +1 -1
  430. package/node_modules/@weavecode/server/web/dist/assets/{wardleyDiagram-IVAIDKWA-CrSd-v8I.js → wardleyDiagram-IVAIDKWA-DX-AMXq_.js} +1 -1
  431. package/node_modules/@weavecode/server/web/dist/assets/{xychartDiagram-4URNHDU4-t9cV9_9b.js → xychartDiagram-4URNHDU4-4fgL48Yl.js} +1 -1
  432. package/node_modules/@weavecode/server/web/dist/index.html +5 -4
  433. package/node_modules/@weavecode/templates/package.json +2 -2
  434. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/@peculiar/asn1-x509-attr/package.json +3 -3
  435. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/package.json +4 -4
  436. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/package.json +3 -3
  437. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/package.json +3 -3
  438. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/@peculiar/asn1-pfx/package.json +5 -5
  439. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/@peculiar/asn1-pkcs8/package.json +3 -3
  440. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/@peculiar/asn1-x509-attr/package.json +3 -3
  441. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/package.json +7 -7
  442. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/package.json +3 -3
  443. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/package.json +1 -1
  444. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/build/cjs/time.js +1 -1
  445. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/build/es2015/time.js +1 -1
  446. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/package.json +2 -2
  447. package/package.json +6 -6
  448. package/node_modules/@weavecode/server/web/dist/assets/channel-Dv4QUMOJ.js +0 -1
  449. package/node_modules/@weavecode/server/web/dist/assets/index-BXhLerZ4.js +0 -1008
  450. package/node_modules/@weavecode/server/web/dist/assets/index-BYRxC-Zz.css +0 -11
  451. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-BlIxQLON.js +0 -8
@@ -1,2 +1,2 @@
1
- import{mkdir as y,readFile as p,writeFile as w}from"node:fs/promises";import l from"node:path";import{DEFAULT_HOOKS as u,DEFAULT_MCP as g,HARNESS_KEYS as P,detectPlatform as C,isHarness as E,resolveComponents as S}from"@weavecode/core";import{WEAVE_CONTENT_MARKER as h,generateInitFiles as O}from"@weavecode/harness";import{gitClassify as j}from"./git-classify.js";import{generateStatuslineScript as k}from"../statusline/generator.js";import{readStatuslineConfig as v,statuslineScriptRelPath as x}from"../statusline/manager.js";import{WEAVE_VERSION as A}from"../version.js";function F(t){const e={};for(const r of t.split(`
2
- `)){const n=r.indexOf(":");if(n<=0)continue;const a=r.slice(0,n).trim(),s=r.slice(n+1).trim();if(a)try{e[a]=JSON.parse(s)}catch{e[a]=s}}return e}function b(t){if(typeof t!="object"||t===null)return u;const e=t,r=Object.fromEntries(Object.keys(u).filter(n=>typeof u[n]=="boolean"&&!(n in e)).map(n=>[n,!1]));return{...u,...r,...e}}export async function readInitRuntime(t){let e;try{e=await p(l.join(t,".weave","config.yaml"),"utf-8")}catch{e=""}const r=F(e),n=r.preset,a=r.components,s=r.hooks,i=r.mcp,c=r.harnesses;return{initVersion:typeof r.initVersion=="string"?r.initVersion:null,preset:n==="minimal"||n==="full"||n==="default"?n:"default",harnesses:Array.isArray(c)?c.filter(E):[],components:S(n==="minimal"||n==="full"||n==="default"?n:"default",typeof a=="object"&&a!==null?a:void 0),hooks:b(s),mcp:{...g,...typeof i=="object"&&i!==null?i:{}}}}function I(){return C()}function R(t,e){return{projectPath:t,version:A,platform:I(),components:e.components,hooks:e.hooks,mcp:e.mcp}}async function V(t,e){if(!e.components.helpers)return[];const r=await v(t);return[{relPath:x(),weaveMarker:h,content:k(r)}]}async function _(t){try{return await p(t,"utf-8")}catch{return null}}function N(t,e){return t.merge?e===null?t.content:t.merge(e,t.content):e!==null&&!e.includes(t.weaveMarker??h)?null:t.content}async function M(t){try{return await p(l.join(t,".weave","config.yaml"),"utf-8"),!0}catch{return!1}}export async function detectInitFileUpdates(t){if(!await M(t))return[];const e=await readInitRuntime(t),r=R(t,e),n=e.harnesses.length>0?e.harnesses:[P[0]],a=[...await V(t,e)];for(const o of n)a.push(...await O(o,r));const s=[];for(const o of a){const m=l.join(t,...o.relPath.split("/")),d=await _(m),f=N(o,d);s.push({relPath:o.relPath,targetPath:m,outdated:f!==null&&f!==d,syncClass:null,expectedContent:f})}const i=s.filter(o=>o.outdated),c=await j(t,i.map(o=>o.relPath));for(const o of i)o.syncClass=c.classOf(o.relPath);return s}export async function applyInitFile(t){return t.syncClass!=="auto"||!t.outdated||t.expectedContent===null?!1:(await y(l.dirname(t.targetPath),{recursive:!0}),await w(t.targetPath,t.expectedContent,"utf-8"),!0)}export function needsInit(t){return t.some(e=>e.syncClass==="manual"&&e.outdated)}
1
+ import{mkdir as y,readFile as m,writeFile as g}from"node:fs/promises";import l from"node:path";import{DEFAULT_HOOKS as f,DEFAULT_MCP as w,HARNESS_KEYS as C,detectPlatform as E,isHarness as x,resolveComponents as O}from"@weavecode/core";import{WEAVE_CONTENT_MARKER as h,generateInitFiles as S}from"@weavecode/harness";import{gitClassify as k}from"./git-classify.js";import{generateStatuslineScript as F}from"../statusline/generator.js";import{readStatuslineConfig as v,statuslineScriptRelPath as A}from"../statusline/manager.js";import{WEAVE_VERSION as P}from"../version.js";function b(t){const e={};for(const o of t.split(`
2
+ `)){const n=o.indexOf(":");if(n<=0)continue;const s=o.slice(0,n).trim(),i=o.slice(n+1).trim();if(s)try{e[s]=JSON.parse(i)}catch{e[s]=i}}return e}function I(t){if(typeof t!="object"||t===null)return f;const e=t,o=Object.fromEntries(Object.keys(f).filter(n=>typeof f[n]=="boolean"&&!(n in e)).map(n=>[n,!1]));return{...f,...o,...e}}export async function readInitRuntime(t){let e;try{e=await m(l.join(t,".weave","config.yaml"),"utf-8")}catch{e=""}const o=b(e),n=o.preset,s=o.components,i=o.hooks,a=o.mcp,c=o.harnesses;return{initVersion:typeof o.initVersion=="string"?o.initVersion:null,preset:n==="minimal"||n==="full"||n==="default"?n:"default",harnesses:Array.isArray(c)?c.filter(x):[],components:O(n==="minimal"||n==="full"||n==="default"?n:"default",typeof s=="object"&&s!==null?s:void 0),hooks:I(i),mcp:{...w,...typeof a=="object"&&a!==null?a:{}}}}function R(){return E()}function V(t,e){return{projectPath:t,version:P,platform:R(),components:e.components,hooks:e.hooks,mcp:e.mcp}}async function _(t,e){if(!e.components.helpers)return[];const o=await v(t);return[{relPath:A(),weaveMarker:h,content:F(o)}]}async function N(t){try{return await m(t,"utf-8")}catch{return null}}function H(t,e){return t.merge?e===null?t.content:t.merge(e,t.content):e!==null&&!e.includes(t.weaveMarker??h)?null:t.content}async function M(t){try{return await m(l.join(t,".weave","config.yaml"),"utf-8"),!0}catch{return!1}}export async function detectInitFileUpdates(t){if(!await M(t))return[];const e=await readInitRuntime(t),o=V(t,e),n=e.harnesses.length>0?e.harnesses:[C[0]],s=[...await _(t,e)];for(const r of n)s.push(...await S(r,o));const i=[];for(const r of s){const p=l.join(t,...r.relPath.split("/")),d=await N(p),u=H(r,d);i.push({relPath:r.relPath,targetPath:p,outdated:u!==null&&u!==d,syncClass:null,expectedContent:u})}const a=i.filter(r=>r.outdated),c=await k(t,a.map(r=>r.relPath));for(const r of a)r.syncClass=c.classOf(r.relPath);return i}export async function applyInitFile(t){return t.syncClass!=="auto"||!t.outdated||t.expectedContent===null?!1:(await y(l.dirname(t.targetPath),{recursive:!0}),await g(t.targetPath,t.expectedContent,"utf-8"),!0)}export function needsInit(t){return t.some(e=>e.syncClass==="manual"&&e.outdated)}
@@ -1,2 +1,2 @@
1
- import{mkdir as l,readFile as f,writeFile as y}from"node:fs/promises";import r from"node:path";const i=r.join(".weave","installed.json"),s=e=>[e.category,e.name,e.agent,e.assetCategory??""].join("\0");function g(e){if(!e||typeof e!="object")return!1;const t=e;return(t.category==="skill"||t.category==="mcp"||t.category==="file")&&typeof t.name=="string"&&t.name!==""&&typeof t.agent=="string"}export async function readInstalledLedger(e){try{const t=JSON.parse(await f(r.join(e,i),"utf-8"));return Array.isArray(t.assets)?t.assets.filter(g):[]}catch{return[]}}export async function recordInstalled(e,t){const n=await readInstalledLedger(e);n.some(a=>s(a)===s(t))||await o(e,[...n,t])}export async function forgetInstalled(e,t){const n=await readInstalledLedger(e),a=n.filter(c=>s(c)!==s(t));a.length!==n.length&&await o(e,a)}async function o(e,t){const n=r.join(e,i);await l(r.dirname(n),{recursive:!0}),await y(n,`${JSON.stringify({version:1,assets:t},null,2)}
1
+ import{mkdir as c,readFile as l,writeFile as y}from"node:fs/promises";import r from"node:path";const i=r.join(".weave","installed.json"),s=t=>[t.category,t.name,t.agent,t.assetCategory??""].join("\0");function g(t){if(!t||typeof t!="object")return!1;const e=t;return(e.category==="skill"||e.category==="mcp"||e.category==="file")&&typeof e.name=="string"&&e.name!==""&&typeof e.agent=="string"}export async function readInstalledLedger(t){try{const e=JSON.parse(await l(r.join(t,i),"utf-8"));return Array.isArray(e.assets)?e.assets.filter(g):[]}catch{return[]}}export async function recordInstalled(t,e){const n=await readInstalledLedger(t);n.some(a=>s(a)===s(e))||await o(t,[...n,e])}export async function forgetInstalled(t,e){const n=await readInstalledLedger(t),a=n.filter(f=>s(f)!==s(e));a.length!==n.length&&await o(t,a)}async function o(t,e){const n=r.join(t,i);await c(r.dirname(n),{recursive:!0}),await y(n,`${JSON.stringify({version:1,assets:e},null,2)}
2
2
  `,"utf-8")}
@@ -1 +1 @@
1
- import{cp as w,rm as j,readFile as S,access as h,mkdir as E}from"node:fs/promises";import{homedir as c}from"node:os";import i from"node:path";import{FILE_ASSET_SPECS as m,fileAssetTargetDir as y}from"./file-assets.js";import{assetSurfaceFor as l}from"../surfaces.js";import{forgetInstalled as d,recordInstalled as p}from"./install-ledger.js";import{installForm as g,removeInstalled as k}from"../market/install-link.js";export class InstallConflictError extends Error{constructor(a){super(a),this.name="InstallConflictError"}}export class AssetNotFoundError extends Error{constructor(a){super(a),this.name="AssetNotFoundError"}}function u(e){if(!e||e.includes("/")||e.includes("\\")||e.includes("..")||e.includes(i.sep))throw new Error(`Invalid asset name: "${e}"`)}async function x(e){try{return await h(e),!0}catch{return!1}}function $(e){return l(e).projectSkillsRoots()}export async function installSkill(e,a,t,n="claude"){u(t);const r=$(n);for(const o of r)if(await g(i.join(e,o,t))!=="absent")throw new InstallConflictError(`Skill "${t}" is already installed${n==="codex"?" (Codex)":""}`);const s=i.join(e,r[0],t);return await w(a,s,{recursive:!0}),await p(e,{category:"skill",name:t,agent:n}),s}export async function uninstallSkill(e,a,t="claude"){u(a);let n;for(const r of $(t)){const s=i.join(e,r,a);if(await g(s)!=="absent"){n=s;break}}if(!n)throw new AssetNotFoundError(`Skill "${a}" is not installed${t==="codex"?" (Codex)":""}`);await k(n),await d(e,{category:"skill",name:a,agent:t})}export async function installFileAsset(e,a,t,n,r="claude",s="project"){u(t);const o=y(a,r,s,e,c()),f=i.join(o,`${t}${m[a].ext}`);if(await x(f))throw new InstallConflictError(`${a} "${t}" is already installed`);return await E(o,{recursive:!0}),await w(n,f),s==="project"&&await p(e,{category:"file",name:t,agent:r,assetCategory:a}),f}export async function uninstallFileAsset(e,a,t,n="claude",r="project"){u(t);const s=y(a,n,r,e,c()),o=i.join(s,`${t}${m[a].ext}`);if(!await x(o))throw new AssetNotFoundError(`${a} "${t}" is not installed`);await j(o,{force:!0}),r==="project"&&await d(e,{category:"file",name:t,agent:n,assetCategory:a})}export async function installMcp(e,a,t){if(a in await readMcpServers(e))throw new InstallConflictError(`MCP server "${a}" is already configured`);await l("claude").mcpWrite("project",e,c(),a,t),await p(e,{category:"mcp",name:a,agent:"claude"})}export async function uninstallMcp(e,a){if(!await l("claude").mcpRemove("project",e,c(),a))throw new AssetNotFoundError(`MCP server "${a}" is not configured`);await d(e,{category:"mcp",name:a,agent:"claude"})}export async function readMcpJson(e){try{const a=await S(e,"utf-8"),t=JSON.parse(a);return t&&typeof t=="object"?t:{}}catch{return{}}}export async function readMcpServers(e){return l("claude").mcpRead("project",e,c())}
1
+ import{cp as p,rm as k,readFile as C,access as F,mkdir as g}from"node:fs/promises";import{homedir as c}from"node:os";import n from"node:path";import{FILE_ASSET_SPECS as x,fileAssetTargetDir as y}from"./file-assets.js";import{assetSurfaceFor as l}from"../surfaces.js";import{forgetInstalled as d,recordInstalled as w}from"./install-ledger.js";import{installForm as $,removeInstalled as v}from"../market/install-link.js";export class InstallConflictError extends Error{constructor(r){super(r),this.name="InstallConflictError"}}export class AssetNotFoundError extends Error{constructor(r){super(r),this.name="AssetNotFoundError"}}function u(t){if(!t||t.includes("/")||t.includes("\\")||t.includes("..")||t.includes(n.sep))throw new Error(`Invalid asset name: "${t}"`)}async function S(t){try{return await F(t),!0}catch{return!1}}function E(t){return l(t).projectSkillsRoots()}export async function installSkill(t,r,o,i="claude"){u(o);const e=E(i);for(const a of e)if(await $(n.join(t,a,o))!=="absent")throw new InstallConflictError(`Skill "${o}" is already installed${i==="codex"?" (Codex)":""}`);const s=n.join(t,e[0],o);return await p(r,s,{recursive:!0}),await w(t,{category:"skill",name:o,agent:i}),s}export async function uninstallSkill(t,r,o="claude"){u(r);let i;for(const e of E(o)){const s=n.join(t,e,r);if(await $(s)!=="absent"){i=s;break}}if(!i)throw new AssetNotFoundError(`Skill "${r}" is not installed${o==="codex"?" (Codex)":""}`);await v(i),await d(t,{category:"skill",name:r,agent:o})}export async function installFileAsset(t,r,o,i,e="claude",s="project"){u(o);const a=y(r,e,s,t,c()),f=n.join(a,`${o}${x[r].ext}`);if(await S(f))throw new InstallConflictError(`${r} "${o}" is already installed`);return await g(a,{recursive:!0}),await p(i,f),s==="project"&&await w(t,{category:"file",name:o,agent:e,assetCategory:r}),f}export async function uninstallFileAsset(t,r,o,i="claude",e="project"){u(o);const s=y(r,i,e,t,c()),a=n.join(s,`${o}${x[r].ext}`);if(!await S(a))throw new AssetNotFoundError(`${r} "${o}" is not installed`);await k(a,{force:!0}),e==="project"&&await d(t,{category:"file",name:o,agent:i,assetCategory:r})}export async function installMcp(t,r,o){if(r in await readMcpServers(t))throw new InstallConflictError(`MCP server "${r}" is already configured`);await l("claude").mcpWrite("project",t,c(),r,o),await w(t,{category:"mcp",name:r,agent:"claude"})}export async function uninstallMcp(t,r){if(!await l("claude").mcpRemove("project",t,c(),r))throw new AssetNotFoundError(`MCP server "${r}" is not configured`);await d(t,{category:"mcp",name:r,agent:"claude"})}export async function readMcpJson(t){try{const r=await C(t,"utf-8"),o=JSON.parse(r);return o&&typeof o=="object"?o:{}}catch{return{}}}export async function readMcpServers(t){return l("claude").mcpRead("project",t,c())}
@@ -1 +1 @@
1
- import{getLibraryScan as u}from"./scan-cache.js";export async function buildLibraryIndex(e){const a=new Map,i=new Map,s=new Map;for(const n of e){const m=n.kind==="skill"||n.kind==="both",d=n.kind==="mcp"||n.kind==="both";let o;try{o=await u(n.path)}catch{continue}if(m){for(const t of o.skills)a.has(t.name)||a.set(t.name,{name:t.name,libraryId:n.id,libraryPath:n.path,dirPath:t.dirPath});for(const t of Object.values(o.files))for(const r of t){const c=`${r.category}/${r.name}`;s.has(c)||s.set(c,{name:r.name,category:r.category,libraryId:n.id,libraryPath:n.path,filePath:r.filePath})}}if(d){for(const t of o.mcp)if(!i.has(t.name)){const{name:r,command:c,args:f,env:l,sourcePath:h}=t,p={command:c,...f&&{args:f},...l&&{env:l}};i.set(t.name,{name:r,libraryId:n.id,libraryPath:n.path,config:p,sourcePath:h})}}}return{skills:a,mcp:i,files:s}}export function findSkillSource(e,a){return e.skills.get(a)}export function findMcpSource(e,a){return e.mcp.get(a)}export function findFileAssetSource(e,a,i){return e.files.get(`${a}/${i}`)}
1
+ import{getLibraryScan as u}from"./scan-cache.js";export async function buildLibraryIndex(e){const a=new Map,r=new Map,s=new Map;for(const t of e){const m=t.kind==="skill"||t.kind==="both",p=t.kind==="mcp"||t.kind==="both";let o;try{o=await u(t.path)}catch{continue}if(m){for(const n of o.skills)a.has(n.name)||a.set(n.name,{name:n.name,libraryId:t.id,libraryPath:t.path,dirPath:n.dirPath});for(const n of Object.values(o.files))for(const i of n){const c=`${i.category}/${i.name}`;s.has(c)||s.set(c,{name:i.name,category:i.category,libraryId:t.id,libraryPath:t.path,filePath:i.filePath})}}if(p){for(const n of o.mcp)if(!r.has(n.name)){const{name:i,command:c,args:f,env:l,sourcePath:d}=n,h={command:c,...f&&{args:f},...l&&{env:l}};r.set(n.name,{name:i,libraryId:t.id,libraryPath:t.path,config:h,sourcePath:d})}}}return{skills:a,mcp:r,files:s}}export function findSkillSource(e,a){return e.skills.get(a)}export function findMcpSource(e,a){return e.mcp.get(a)}export function findFileAssetSource(e,a,r){return e.files.get(`${a}/${r}`)}
@@ -1 +1 @@
1
- import{homedir as m}from"node:os";import{readMcpEnableMap as u,mcpOverrideOf as d,resolveMcpEffective as h}from"./settings-mcp.js";import{assetSurfaces as n}from"../surfaces.js";import{BUILTIN_MCP_SERVERS as S}from"./builtin-mcp.js";import{readDaemonState as b}from"../daemon/state.js";export async function readMcpRows(c){const p=await u(c),o=[];for(const e of n()){const s=e.mcpScopes();for(const a of s){const t=e.harness==="claude"&&a==="project"?p:null,l=await e.mcpRead(a,c,m()).catch(()=>({}));for(const[r,i]of Object.entries(l))o.push({key:r,category:"mcp",harness:e.harness,scope:a,installScopes:s,enable:t?d(t,r):null,effective:t?h(t,r):!0,detail:i})}}const f=b()?.port;for(const e of n())for(const s of S)e.harness==="claude"&&(o.some(a=>a.harness==="claude"&&a.key===s.name)||o.push({key:s.name,category:"mcp",harness:"claude",scope:"user",installScopes:["user"],install:"absent",enable:null,effective:!1,detail:{url:`http://127.0.0.1:${f??6420}${s.path}`},builtin:!0}));return o}
1
+ import{homedir as u}from"node:os";import{readMcpEnableMap as m,mcpOverrideOf as d,resolveMcpEffective as h}from"./settings-mcp.js";import{assetSurfaces as n}from"../surfaces.js";import{BUILTIN_MCP_SERVERS as b}from"./builtin-mcp.js";import{readDaemonState as S}from"../daemon/state.js";export async function readMcpRows(c){const f=await m(c),t=[];for(const e of n()){const o=e.mcpScopes();for(const s of o){const r=e.harness==="claude"&&s==="project"?f:null,l=await e.mcpRead(s,c,u()).catch(()=>({}));for(const[a,p]of Object.entries(l))t.push({key:a,category:"mcp",harness:e.harness,scope:s,installScopes:o,enable:r?d(r,a):null,effective:r?h(r,a):!0,detail:p})}}const i=S()?.port;for(const e of n())for(const o of b)e.harness==="claude"&&(t.some(s=>s.harness==="claude"&&s.key===o.name)||t.push({key:o.name,category:"mcp",harness:"claude",scope:"user",installScopes:["user"],install:"absent",enable:null,effective:!1,detail:{url:`http://127.0.0.1:${i??6420}${o.path}`},builtin:!0}));return t}
@@ -1 +1 @@
1
- import r from"node:path";import{marketIdOf as t}from"../market/identity.js";import{marketDir as a}from"../market/manifest.js";export async function installPluginPack(o,i){const n=t(i.dir);return o.globalInstall(i.dir,{name:i.name,version:i.version,description:i.description,...n?{marketplace:{name:n,dir:r.join(a(),n)}}:{}})}
1
+ import t from"node:path";import{marketIdOf as o}from"../market/identity.js";import{marketDir as e}from"../market/manifest.js";export async function installPluginPack(n,r){const i=o(r.dir);return n.globalInstall(r.dir,{name:r.name,version:r.version,description:r.description,...i?{marketplace:{name:i,dir:t.join(e(),i)}}:{}})}
@@ -1 +1 @@
1
- import{pluginSurfaces as b,pluginStateSurfaces as g}from"../surfaces.js";const u=["user","project","local"],y=(s,e)=>e in s?s[e]?"on":"off":"inherit";function S(s,e){for(let n=u.length-1;n>=0;n--){const o=s[u[n]][e];if(o!==void 0)return o}return!1}export async function readPluginRows(s){const e=[],n=b();for(const{harness:o,surface:a}of n){const f=a.pluginScopes(),[t,c]=await Promise.all([a.readInstalled().catch(()=>({})),a.readEnabledOverrides(s).catch(()=>({user:{},project:{},local:{}}))]),p=new Set(Object.keys(t));for(const r of u)for(const l of Object.keys(c[r]))p.add(l);for(const r of p){const l=t[r],d=S(c,r);for(const i of f)e.push({key:r,category:"plugin",harness:o,scope:i,installScopes:f,install:l?.some(h=>(h.scope??"user")===i)?"installed":"absent",enable:y(c[i],r),effective:d})}}for(const{harness:o,state:a}of g()){if(n.some(t=>t.harness===o))continue;const f=await a.readGlobalEnabled().catch(()=>({}));for(const[t,c]of Object.entries(f))e.push({key:t,category:"plugin",harness:o,scope:"user",installScopes:[],enable:c?"on":"off",effective:c})}return e}
1
+ import{pluginSurfaces as b,pluginStateSurfaces as g}from"../surfaces.js";const u=["user","project","local"],v=(s,e)=>e in s?s[e]?"on":"off":"inherit";function y(s,e){for(let n=u.length-1;n>=0;n--){const o=s[u[n]][e];if(o!==void 0)return o}return!1}export async function readPluginRows(s){const e=[],n=b();for(const{harness:o,surface:a}of n){const l=a.pluginScopes(),[t,c]=await Promise.all([a.readInstalled().catch(()=>({})),a.readEnabledOverrides(s).catch(()=>({user:{},project:{},local:{}}))]),p=new Set(Object.keys(t));for(const r of u)for(const f of Object.keys(c[r]))p.add(f);for(const r of p){const f=t[r],d=y(c,r);for(const i of l)e.push({key:r,category:"plugin",harness:o,scope:i,installScopes:l,install:f?.some(h=>(h.scope??"user")===i)?"installed":"absent",enable:v(c[i],r),effective:d})}}for(const{harness:o,state:a}of g()){if(n.some(t=>t.harness===o))continue;const l=await a.readGlobalEnabled().catch(()=>({}));for(const[t,c]of Object.entries(l))e.push({key:t,category:"plugin",harness:o,scope:"user",installScopes:[],enable:c?"on":"off",effective:c})}return e}
@@ -1 +1 @@
1
- import{cp as f,mkdir as h,readdir as d,readFile as P,rm as w}from"node:fs/promises";import{homedir as j}from"node:os";import r from"node:path";import{WEAVE_PLUGIN_MANIFEST as y,WeavePluginManifestSchema as k}from"@weavecode/core";import{assetSurfaceFor as v}from"../surfaces.js";const S={skills:"skill",commands:"command",agents:"agent"};async function F(t){const a=[];let s;try{s=await d(t)}catch{return a}for(const o of s){const i=r.join(t,o);try{const c=JSON.parse(await P(r.join(i,y),"utf8")),e=k.safeParse(c);e.success&&a.push({dir:i,manifest:e.data})}catch{}}return a}function E(t,a,s){const o=[];if(!s.templates)return o;const i=v("claude"),c=r.join(t,...i.projectSkillsRoots()[0].split("/"));for(const[e,l]of Object.entries(s.templates)){const n=S[e];if(n)for(const p of l??[]){const u=r.resolve(a,p);if(!u.startsWith(r.resolve(a)+r.sep))continue;const m=r.basename(u),g=n==="skill"?c:i.targetDir(n,"project",t,j());o.push({pluginId:s.id,category:n,name:m.replace(/\.md$/,""),sourcePath:u,targetPath:r.join(g,m)})}}return o}export async function detectPluginTemplateUpdates(t,a){const s=[],o=r.join(t,".weave","plugins");for(const{dir:i,manifest:c}of await F(o))for(const e of E(t,i,c)){const[l,n]=e.category==="skill"?await Promise.all([a.get(e.sourcePath),a.get(e.targetPath)]):await Promise.all([a.getFile(e.sourcePath),a.getFile(e.targetPath)]);s.push({...e,outdated:l!==n})}return s}export async function materializePluginTemplate(t){if(t.category==="skill"){await w(t.targetPath,{recursive:!0,force:!0}),await f(t.sourcePath,t.targetPath,{recursive:!0});return}await h(r.dirname(t.targetPath),{recursive:!0}),await f(t.sourcePath,t.targetPath)}
1
+ import{cp as f,mkdir as d,readdir as P,readFile as h,rm as w}from"node:fs/promises";import{homedir as y}from"node:os";import a from"node:path";import{WEAVE_PLUGIN_MANIFEST as k,WeavePluginManifestSchema as v}from"@weavecode/core";import{assetSurfaceFor as E}from"../surfaces.js";const T={skills:"skill",commands:"command",agents:"agent"};async function j(t){const e=[];let s;try{s=await P(t)}catch{return e}for(const o of s){const i=a.join(t,o);try{const c=JSON.parse(await h(a.join(i,k),"utf8")),r=v.safeParse(c);r.success&&e.push({dir:i,manifest:r.data})}catch{}}return e}function S(t,e,s){const o=[];if(!s.templates)return o;const i=E("claude"),c=a.join(t,...i.projectSkillsRoots()[0].split("/"));for(const[r,l]of Object.entries(s.templates)){const n=T[r];if(n)for(const p of l??[]){const u=a.resolve(e,p);if(!u.startsWith(a.resolve(e)+a.sep))continue;const m=a.basename(u),g=n==="skill"?c:i.targetDir(n,"project",t,y());o.push({pluginId:s.id,category:n,name:m.replace(/\.md$/,""),sourcePath:u,targetPath:a.join(g,m)})}}return o}export async function detectPluginTemplateUpdates(t,e){const s=[],o=a.join(t,".weave","plugins");for(const{dir:i,manifest:c}of await j(o))for(const r of S(t,i,c)){const[l,n]=r.category==="skill"?await Promise.all([e.get(r.sourcePath),e.get(r.targetPath)]):await Promise.all([e.getFile(r.sourcePath),e.getFile(r.targetPath)]);s.push({...r,outdated:l!==n})}return s}export async function materializePluginTemplate(t){if(t.category==="skill"){await w(t.targetPath,{recursive:!0,force:!0}),await f(t.sourcePath,t.targetPath,{recursive:!0});return}await d(a.dirname(t.targetPath),{recursive:!0}),await f(t.sourcePath,t.targetPath)}
@@ -1,2 +1,2 @@
1
- import{readFile as i,writeFile as e,mkdir as s}from"node:fs/promises";import a from"node:path";const o=".weave",u="config.json";export const DEFAULT_PROJECT_CONFIG={lastSyncAt:null};function c(t){return a.join(t,o,u)}function f(t){return{lastSyncAt:t.lastSyncAt??DEFAULT_PROJECT_CONFIG.lastSyncAt}}export async function readProjectConfig(t){try{const n=await i(c(t),"utf-8");return f(JSON.parse(n))}catch{return DEFAULT_PROJECT_CONFIG}}export async function writeProjectConfig(t,n){const r=a.join(t,o);await s(r,{recursive:!0}),await e(c(t),`${JSON.stringify(n,null,2)}
1
+ import{readFile as a,writeFile as e,mkdir as s}from"node:fs/promises";import i from"node:path";const c=".weave",f="config.json";export const DEFAULT_PROJECT_CONFIG={lastSyncAt:null};function o(t){return i.join(t,c,f)}function u(t){return{lastSyncAt:t.lastSyncAt??DEFAULT_PROJECT_CONFIG.lastSyncAt}}export async function readProjectConfig(t){try{const n=await a(o(t),"utf-8");return u(JSON.parse(n))}catch{return DEFAULT_PROJECT_CONFIG}}export async function writeProjectConfig(t,n){const r=i.join(t,c);await s(r,{recursive:!0}),await e(o(t),`${JSON.stringify(n,null,2)}
2
2
  `,"utf-8")}export async function markSynced(t,n){const r=await readProjectConfig(t);await writeProjectConfig(t,{...r,lastSyncAt:n})}
@@ -1 +1 @@
1
- import{readFile as c,stat as p}from"node:fs/promises";import{homedir as h}from"node:os";import s from"node:path";import{AssetNotFoundError as n}from"./installer.js";import{assetSurfaces as w}from"../surfaces.js";export class PathEscapeError extends Error{constructor(t){super(t),this.name="PathEscapeError"}}export class FileTooLargeError extends Error{constructor(t){super(t),this.name="FileTooLargeError"}}export const MAX_BYTES=512*1024;export function resolveWithinProject(e,t){const r=s.normalize(t).replace(/\\/g,"/");if(s.isAbsolute(t))throw new PathEscapeError(`Absolute paths are not allowed: "${t}"`);if(r.split("/").some(i=>i===".."))throw new PathEscapeError(`Path traversal is not allowed: "${t}"`);const o=s.join(e,r),a=e.endsWith(s.sep)?e:e+s.sep;if(o!==e&&!o.startsWith(a))throw new PathEscapeError(`Resolved path escapes the project: "${t}"`);return o}export function resolveProjectFile(e,t){const r=s.normalize(t).replace(/\\/g,"/"),o=w().flatMap(i=>i.projectSkillsRoots().map(l=>l.split("/")[0])),a=r.split("/")[0]??"";if(!(r===".mcp.json"||r==="CLAUDE.md"||r==="AGENTS.md"||o.includes(a)||r===".weave"||r.startsWith(".weave/")))throw new PathEscapeError(`Path is outside the allowed roots: "${t}"`);return resolveWithinProject(e,r)}export async function readProjectFile(e,t){const r=resolveProjectFile(e,t);let o;try{o=await p(r)}catch{throw new n(`File not found: "${t}"`)}if(!o.isFile())throw new n(`Not a file: "${t}"`);if(o.size>MAX_BYTES)throw new FileTooLargeError(`File exceeds ${MAX_BYTES} bytes: "${t}"`);return{content:await c(r,"utf-8"),size:o.size}}export async function readGlobalFile(e){return readProjectFile(h(),e)}
1
+ import{readFile as p,stat as w}from"node:fs/promises";import{homedir as d}from"node:os";import r from"node:path";import{AssetNotFoundError as a}from"./installer.js";import{assetSurfaces as f}from"../surfaces.js";export class PathEscapeError extends Error{constructor(o){super(o),this.name="PathEscapeError"}}export class FileTooLargeError extends Error{constructor(o){super(o),this.name="FileTooLargeError"}}export const MAX_BYTES=512*1024;export function resolveWithinProject(e,o){const t=r.normalize(o).replace(/\\/g,"/");if(r.isAbsolute(o))throw new PathEscapeError(`Absolute paths are not allowed: "${o}"`);if(t.split("/").some(i=>i===".."))throw new PathEscapeError(`Path traversal is not allowed: "${o}"`);const s=r.join(e,t),n=e.endsWith(r.sep)?e:e+r.sep;if(s!==e&&!s.startsWith(n))throw new PathEscapeError(`Resolved path escapes the project: "${o}"`);return s}export function resolveProjectFile(e,o){const t=r.normalize(o).replace(/\\/g,"/"),s=f().flatMap(c=>c.projectSkillsRoots().map(l=>l.split("/")[0])),n=t.split("/")[0]??"";if(!(t===".mcp.json"||t==="CLAUDE.md"||t==="AGENTS.md"||s.includes(n)||t===".weave"||t.startsWith(".weave/")))throw new PathEscapeError(`Path is outside the allowed roots: "${o}"`);return resolveWithinProject(e,t)}export async function readProjectFile(e,o){const t=resolveProjectFile(e,o);let s;try{s=await w(t)}catch{throw new a(`File not found: "${o}"`)}if(!s.isFile())throw new a(`Not a file: "${o}"`);if(s.size>MAX_BYTES)throw new FileTooLargeError(`File exceeds ${MAX_BYTES} bytes: "${o}"`);return{content:await p(t,"utf-8"),size:s.size}}export async function readGlobalFile(e){return readProjectFile(d(),e)}
@@ -1 +1 @@
1
- import{mkdir as f,readFile as p,rm as w,writeFile as m}from"node:fs/promises";import s from"node:path";import{scanLibraryFileAssets as g,scanLibraryMcp as v,scanLibraryPlugins as A,scanLibrarySkills as b}from"./scanner.js";const l="scans.json",u=1;function c(a){const r=s.resolve(a);return s.join(s.dirname(r),".weave-scans",s.basename(r))}const e=new Map,o=new Map;export async function scanLibrary(a){const{plugins:r,packRoots:t}=await A(a),[i,n,y]=await Promise.all([b(a,t),v(a,t),g(a,t)]);return{plugins:r,packRoots:t,skills:i,mcp:n,files:y}}export async function getLibraryScan(a){const r=s.resolve(a),t=e.get(r);if(t)return t;const i=o.get(r);if(i)return i;const n=d(r);o.set(r,n);try{return await n}finally{o.delete(r)}}async function d(a){const r=await k(a);if(r)return e.set(a,r),r;const t=await scanLibrary(a);return await L(a,t),e.set(a,t),t}async function k(a){try{const r=JSON.parse(await p(s.join(c(a),l),"utf8"));return!r||r.version!==u||r.root!==a||!Array.isArray(r.plugins)||!Array.isArray(r.packRoots)||!Array.isArray(r.skills)||!Array.isArray(r.mcp)||!r.files||typeof r.files!="object"?null:r}catch{return null}}async function L(a,r){try{await f(c(a),{recursive:!0}),await m(s.join(c(a),l),JSON.stringify({version:u,root:a,...r}),"utf8")}catch{}}export async function invalidateScan(a){const r=s.resolve(a);e.delete(r);const t=o.get(r);t&&await t.catch(()=>{}),await w(c(r),{recursive:!0,force:!0}),e.delete(r)}export function clearScanCache(){e.clear()}
1
+ import{mkdir as l,readFile as w,rm as u,writeFile as m}from"node:fs/promises";import{existsSync as d}from"node:fs";import t from"node:path";import{scanLibraryFileAssets as g,scanLibraryMcp as A,scanLibraryPlugins as v,scanLibrarySkills as S}from"./scanner.js";const y="scans.json",f=1;function c(e){const r=t.resolve(e);return t.join(t.dirname(r),".weave-scans",t.basename(r))}const a=new Map,o=new Map;export async function scanLibrary(e){const{plugins:r,packRoots:n}=await v(e),[s,i,p]=await Promise.all([S(e,n),A(e,n),g(e,n)]);return{plugins:r,packRoots:n,skills:s,mcp:i,files:p}}export async function getLibraryScan(e){const r=t.resolve(e),n=a.get(r);if(n)return n;const s=o.get(r);if(s)return s;const i=k(r);o.set(r,i);try{return await i}finally{o.delete(r)}}async function k(e){if(!d(e)){try{await u(c(e),{recursive:!0,force:!0})}catch{}const s=await scanLibrary(e);return a.set(e,s),s}const r=await L(e);if(r)return a.set(e,r),r;const n=await scanLibrary(e);return await F(e,n),a.set(e,n),n}async function L(e){try{const r=JSON.parse(await w(t.join(c(e),y),"utf8"));return!r||r.version!==f||r.root!==e||!Array.isArray(r.plugins)||!Array.isArray(r.packRoots)||!Array.isArray(r.skills)||!Array.isArray(r.mcp)||!r.files||typeof r.files!="object"?null:r}catch{return null}}async function F(e,r){try{await l(c(e),{recursive:!0}),await m(t.join(c(e),y),JSON.stringify({version:f,root:e,...r}),"utf8")}catch{}}export async function invalidateScan(e){const r=t.resolve(e);a.delete(r);const n=o.get(r);n&&await n.catch(()=>{}),await u(c(r),{recursive:!0,force:!0}),a.delete(r)}export function clearScanCache(){a.clear()}
@@ -1 +1 @@
1
- import{readdir as p,readFile as k,stat as F}from"node:fs/promises";import{join as c,basename as u,relative as l,dirname as j}from"node:path";import{FILE_ASSET_SPECS as P,FILE_ASSET_CATEGORIES as h}from"./file-assets.js";import{hasNonEmptyModules as L}from"../watch/plugin-mods.js";import{parseToolkitPack as E}from"../hooks/toolkit-scan.js";import{marketIdOf as O}from"../market/identity.js";import{pluginSurfaceFor as T}from"../surfaces.js";function C(e){if(!(!(e.ccPack||e.kind==="mod")||!e.targets.includes("claude")))return T("claude").pluginKey(e.name,O(e.dir))}const y=new Set(["node_modules",".git","dist","build",".next","coverage",".cache"]);async function d(e){try{return(await F(e)).isFile()}catch{return!1}}async function I(e){if(await d(c(e,".claude-plugin","plugin.json"))||await d(c(e,"weave-plugin.json")))return!0;try{const a=JSON.parse(await k(c(e,"hooks","hooks.json"),"utf8"));return L(a)}catch{return!1}}const x=10;export async function scanLibraryPlugins(e){const a=[],n=[],o=async(t,r)=>{if(await I(t)){n.push(l(e,t).replace(/\\/g,"/"));const s=await E(t,{root:e,provenance:"market"},"");if(s){const m=[];for(const w of s.skills)await d(c(t,"skills",w,"SKILL.md"))&&m.push(w);const f=C(s);a.push({name:s.name,version:s.version,...s.description?{description:s.description}:{},...f?{key:f}:{},dirPath:s.dir,relPath:l(e,t).replace(/\\/g,"/"),ccPack:s.ccPack,weavePack:s.weavePack,kind:s.kind,components:s.components,targets:s.targets,skills:m})}return}if(r>=x)return;let i;try{i=await p(t,{withFileTypes:!0})}catch{return}for(const s of i)s.isDirectory()&&(s.name.startsWith(".")||y.has(s.name)||await o(c(t,s.name),r+1))};return await o(e,0),{plugins:a.sort((t,r)=>t.relPath.localeCompare(r.relPath)),packRoots:n.sort((t,r)=>t.localeCompare(r))}}function g(e,a){return!a||a.length===0?!1:a.some(n=>n===""||e===n||e.startsWith(`${n}/`))}export async function scanLibrarySkills(e,a){const n=[];return await b(e,e,n,a),n.sort((o,t)=>o.name.localeCompare(t.name))}async function b(e,a,n,o){if(g(l(e,a).replace(/\\/g,"/"),o))return;let t;try{t=await p(a,{withFileTypes:!0})}catch{return}if(t.some(r=>r.isFile()&&r.name==="SKILL.md")){n.push({name:u(a),dirPath:a,relPath:l(e,a).replace(/\\/g,"/"),group:l(e,j(a)).replace(/\\/g,"/")});return}for(const r of t)r.isDirectory()&&(r.name.startsWith(".")||y.has(r.name)||await b(e,c(a,r.name),n,o))}export async function scanLibraryMcp(e,a){const n=[];await v(e,e,n,a);const o=[];for(const t of n)try{const r=JSON.parse(await k(t.abs,"utf-8"));$(r,t,o)}catch{}return o.sort((t,r)=>t.name.localeCompare(r.name))}async function v(e,a,n,o){if(g(l(e,a).replace(/\\/g,"/"),o))return;let t;try{t=await p(a,{withFileTypes:!0})}catch{return}for(const r of t)if(r.isDirectory()){if(r.name.startsWith(".")||y.has(r.name))continue;await v(e,c(a,r.name),n,o)}else if(r.isFile()){const i=r.name.replace(/\.mcp\.json$/i,"").replace(/\.json$/i,""),s=/\.mcp\.json$/i.test(r.name),m=u(a)==="mcp"&&/\.json$/i.test(r.name);(s||m)&&i&&n.push({abs:c(a,r.name),rel:l(e,c(a,r.name)).replace(/\\/g,"/")})}}function $(e,a,n){const o=a.rel.replace(/\.mcp\.json$/i,"").replace(/\.json$/i,"").replace(/^.*\//,"");if(e&&typeof e=="object"&&!Array.isArray(e)){const t=e,r=t.mcpServers;if(r&&typeof r=="object"&&!Array.isArray(r)){for(const[s,m]of Object.entries(r)){const f=S(s,m);f&&n.push({...f,sourcePath:a.abs,relPath:a.rel})}return}const i=S(o,t);i&&n.push({...i,sourcePath:a.abs,relPath:a.rel})}}function S(e,a){if(!a||typeof a!="object"||Array.isArray(a))return null;const n=a;if(typeof n.command!="string"||!n.command)return null;const o={name:e,command:n.command};if(Array.isArray(n.args)&&(o.args=n.args.filter(t=>typeof t=="string")),n.env&&typeof n.env=="object"&&!Array.isArray(n.env)){const t={};for(const[r,i]of Object.entries(n.env))typeof i=="string"&&(t[r]=i);Object.keys(t).length&&(o.env=t)}return o}const W=Object.fromEntries(h.flatMap(e=>Object.values(P[e].dirs).map(a=>a?.project).filter(a=>a!==void 0).map(a=>[u(a),e])));export async function scanLibraryFileAssets(e,a){const n={};for(const o of h)n[o]=[];await A(e,e,n,a);for(const o of h)n[o].sort((t,r)=>t.name.localeCompare(r.name));return n}async function A(e,a,n,o){if(g(l(e,a).replace(/\\/g,"/"),o))return;let t;try{t=await p(a,{withFileTypes:!0})}catch{return}if(t.some(i=>i.isFile()&&i.name==="SKILL.md"))return;const r=W[u(a)];if(r){const i=P[r];for(const s of t){if(!s.isFile()||!s.name.endsWith(i.ext))continue;const m=s.name.slice(0,-i.ext.length);if(!m)continue;const f=c(a,s.name);n[r].push({name:m,filePath:f,relPath:l(e,f).replace(/\\/g,"/"),group:l(e,j(a)).replace(/\\/g,"/"),category:r})}return}for(const i of t)i.isDirectory()&&(i.name.startsWith(".")||y.has(i.name)||await A(e,c(a,i.name),n,o))}
1
+ import{readdir as l,readFile as j,stat as E}from"node:fs/promises";import{join as o,basename as p,relative as f,dirname as S}from"node:path";import{FILE_ASSET_SPECS as A,FILE_ASSET_CATEGORIES as h}from"./file-assets.js";import{hasNonEmptyModules as L}from"../watch/plugin-mods.js";import{parseToolkitPack as I}from"../hooks/toolkit-scan.js";import{marketIdOf as T}from"../market/identity.js";import{pluginSurfaceFor as d}from"../surfaces.js";function _(t){if(!(!(t.ccPack||t.kind==="mod")||!t.targets.includes("claude")))return d("claude").pluginKey(t.name,T(t.dir))}const y=new Set(["node_modules",".git","dist","build",".next","coverage",".cache"]);async function g(t){try{return(await E(t)).isFile()}catch{return!1}}async function D(t){if(await g(o(t,".claude-plugin","plugin.json"))||await g(o(t,"weave-plugin.json")))return!0;try{const e=JSON.parse(await j(o(t,"hooks","hooks.json"),"utf8"));return L(e)}catch{return!1}}const M=10;export async function scanLibraryPlugins(t){const e=[],r=[],c=async(a,n)=>{if(await D(a)){r.push(f(t,a).replace(/\\/g,"/"));const s=await I(a,{root:t,provenance:"market"},"");if(s){const u=[];for(const k of s.skills)await g(o(a,"skills",k,"SKILL.md"))&&u.push(k);const m=_(s);e.push({name:s.name,version:s.version,...s.description?{description:s.description}:{},...m?{key:m}:{},dirPath:s.dir,relPath:f(t,a).replace(/\\/g,"/"),ccPack:s.ccPack,weavePack:s.weavePack,kind:s.kind,components:s.components,targets:s.targets,skills:u})}return}if(n>=M)return;let i;try{i=await l(a,{withFileTypes:!0})}catch{return}for(const s of i)s.isDirectory()&&(s.name.startsWith(".")||y.has(s.name)||await c(o(a,s.name),n+1))};return await c(t,0),{plugins:e.sort((a,n)=>a.relPath.localeCompare(n.relPath)),packRoots:r.sort((a,n)=>a.localeCompare(n))}}function w(t,e){return!e||e.length===0?!1:e.some(r=>r===""||t===r||t.startsWith(`${r}/`))}export async function scanLibrarySkills(t,e){const r=[];return await P(t,t,r,e),r.sort((c,a)=>c.name.localeCompare(a.name))}async function P(t,e,r,c){if(w(f(t,e).replace(/\\/g,"/"),c))return;let a;try{a=await l(e,{withFileTypes:!0})}catch{return}if(a.some(n=>n.isFile()&&n.name==="SKILL.md")){r.push({name:p(e),dirPath:e,relPath:f(t,e).replace(/\\/g,"/"),group:f(t,S(e)).replace(/\\/g,"/")});return}for(const n of a)n.isDirectory()&&(n.name.startsWith(".")||y.has(n.name)||await P(t,o(e,n.name),r,c))}export async function scanLibraryMcp(t,e){const r=[];await v(t,t,r,e);const c=[];for(const a of r)try{const n=JSON.parse(await j(a.abs,"utf-8"));O(n,a,c)}catch{}return c.sort((a,n)=>a.name.localeCompare(n.name))}async function v(t,e,r,c){if(w(f(t,e).replace(/\\/g,"/"),c))return;let a;try{a=await l(e,{withFileTypes:!0})}catch{return}for(const n of a)if(n.isDirectory()){if(n.name.startsWith(".")||y.has(n.name))continue;await v(t,o(e,n.name),r,c)}else if(n.isFile()){const i=n.name.replace(/\.mcp\.json$/i,"").replace(/\.json$/i,""),s=/\.mcp\.json$/i.test(n.name),u=p(e)==="mcp"&&/\.json$/i.test(n.name);(s||u)&&i&&r.push({abs:o(e,n.name),rel:f(t,o(e,n.name)).replace(/\\/g,"/")})}}function O(t,e,r){const c=e.rel.replace(/\.mcp\.json$/i,"").replace(/\.json$/i,"").replace(/^.*\//,"");if(t&&typeof t=="object"&&!Array.isArray(t)){const a=t,n=a.mcpServers;if(n&&typeof n=="object"&&!Array.isArray(n)){for(const[s,u]of Object.entries(n)){const m=F(s,u);m&&r.push({...m,sourcePath:e.abs,relPath:e.rel})}return}const i=F(c,a);i&&r.push({...i,sourcePath:e.abs,relPath:e.rel})}}function F(t,e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e;if(typeof r.command!="string"||!r.command)return null;const c={name:t,command:r.command};if(Array.isArray(r.args)&&(c.args=r.args.filter(a=>typeof a=="string")),r.env&&typeof r.env=="object"&&!Array.isArray(r.env)){const a={};for(const[n,i]of Object.entries(r.env))typeof i=="string"&&(a[n]=i);Object.keys(a).length&&(c.env=a)}return c}const C=Object.fromEntries(h.flatMap(t=>Object.values(A[t].dirs).map(e=>e?.project).filter(e=>e!==void 0).map(e=>[p(e),t])));export async function scanLibraryFileAssets(t,e){const r={};for(const c of h)r[c]=[];await b(t,t,r,e);for(const c of h)r[c].sort((a,n)=>a.name.localeCompare(n.name));return r}async function b(t,e,r,c){if(w(f(t,e).replace(/\\/g,"/"),c))return;let a;try{a=await l(e,{withFileTypes:!0})}catch{return}if(a.some(i=>i.isFile()&&i.name==="SKILL.md"))return;const n=C[p(e)];if(n){const i=A[n];for(const s of a){if(!s.isFile()||!s.name.endsWith(i.ext))continue;const u=s.name.slice(0,-i.ext.length);if(!u)continue;const m=o(e,s.name);r[n].push({name:u,filePath:m,relPath:f(t,m).replace(/\\/g,"/"),group:f(t,S(e)).replace(/\\/g,"/"),category:n})}return}for(const i of a)i.isDirectory()&&(i.name.startsWith(".")||y.has(i.name)||await b(t,o(e,i.name),r,c))}
@@ -1,2 +1,2 @@
1
- import{readFile as f,writeFile as u,mkdir as b,access as p}from"node:fs/promises";import o from"node:path";const c=".claude/settings.json";async function v(r){try{return await p(r),!0}catch{return!1}}async function d(r){const e=o.join(r,c);if(!await v(e))return{};try{const n=JSON.parse(await f(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}catch{return{}}}async function y(r,e){const n=o.join(r,c);await b(o.dirname(n),{recursive:!0}),await u(n,`${JSON.stringify(e,null,2)}
2
- `,"utf-8")}export async function readMcpEnableMap(r){const e=await d(r),n=i(e.enabledMcpjsonServers),t=i(e.disabledMcpjsonServers),a={};for(const s of n)a[s]="enabled";for(const s of t)a[s]="disabled";return{overrides:a,enableAll:e.enableAllProjectMcpServers===!0}}const M={enabled:"on",disabled:"off",default:"inherit"},S={on:"enabled",off:"disabled",inherit:"default"};export function mcpOverrideOf(r,e){return M[r.overrides[e]??"default"]}export function resolveMcpEffective(r,e){const n=r.overrides[e];return n==="enabled"?!0:n==="disabled"?!1:r.enableAll}export async function setMcpEnableState(r,e,n){const t=await d(r),a=new Set(i(t.enabledMcpjsonServers)),s=new Set(i(t.disabledMcpjsonServers));a.delete(e),s.delete(e),n==="enabled"?a.add(e):n==="disabled"&&s.add(e),l(t,"enabledMcpjsonServers",a),l(t,"disabledMcpjsonServers",s),await y(r,t)}export function setMcpEnableOverride(r,e,n){return setMcpEnableState(r,e,S[n])}function i(r){return Array.isArray(r)?r.filter(e=>typeof e=="string"):[]}function l(r,e,n){n.size===0?delete r[e]:r[e]=[...n].sort()}
1
+ import{readFile as f,writeFile as u,mkdir as b,access as p}from"node:fs/promises";import o from"node:path";const c=".claude/settings.json";async function S(t){try{return await p(t),!0}catch{return!1}}async function d(t){const e=o.join(t,c);if(!await S(e))return{};try{const r=JSON.parse(await f(e,"utf-8"));return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}async function v(t,e){const r=o.join(t,c);await b(o.dirname(r),{recursive:!0}),await u(r,`${JSON.stringify(e,null,2)}
2
+ `,"utf-8")}export async function readMcpEnableMap(t){const e=await d(t),r=i(e.enabledMcpjsonServers),n=i(e.disabledMcpjsonServers),s={};for(const a of r)s[a]="enabled";for(const a of n)s[a]="disabled";return{overrides:s,enableAll:e.enableAllProjectMcpServers===!0}}const y={enabled:"on",disabled:"off",default:"inherit"},M={on:"enabled",off:"disabled",inherit:"default"};export function mcpOverrideOf(t,e){return y[t.overrides[e]??"default"]}export function resolveMcpEffective(t,e){const r=t.overrides[e];return r==="enabled"?!0:r==="disabled"?!1:t.enableAll}export async function setMcpEnableState(t,e,r){const n=await d(t),s=new Set(i(n.enabledMcpjsonServers)),a=new Set(i(n.disabledMcpjsonServers));s.delete(e),a.delete(e),r==="enabled"?s.add(e):r==="disabled"&&a.add(e),l(n,"enabledMcpjsonServers",s),l(n,"disabledMcpjsonServers",a),await v(t,n)}export function setMcpEnableOverride(t,e,r){return setMcpEnableState(t,e,M[r])}function i(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function l(t,e,r){r.size===0?delete t[e]:t[e]=[...r].sort()}
@@ -1 +1 @@
1
- import{readdir as g,stat as w}from"node:fs/promises";import{homedir as k}from"node:os";import u from"node:path";import{hashMcpConfig as p}from"./fingerprint.js";import{buildLibraryIndex as h,findSkillSource as y,findMcpSource as f,findFileAssetSource as b}from"./library-index.js";import{readMcpServers as x}from"./installer.js";import{readGlobalMcpServers as F,readGlobalSkills as P}from"./global-config.js";import{readCodexMcpServers as v}from"./codex-toml.js";import{FILE_ASSET_CATEGORIES as C,FILE_ASSET_SPECS as E}from"./file-assets.js";import{assetSurfaces as j}from"../surfaces.js";import{readInstalledLedger as T}from"./install-ledger.js";import{detectPluginTemplateUpdates as U}from"./plugin-templates.js";import{detectInitFileUpdates as A,needsInit as L}from"./init-files.js";export async function detectUpdates(n,s,i,o){const a=o??await h(s),[e,t,d,c,m]=await Promise.all([detectSkillUpdates(n,i,a),G(n,a),detectFileAssetUpdates(n,i,a),U(n,i),A(n)]);await M(n,{skills:e,mcp:t,files:d},a);const l=e.filter(r=>!r.custom&&r.outdated).length+t.filter(r=>!r.custom&&r.outdated).length+d.filter(r=>!r.custom&&r.outdated).length+c.filter(r=>r.outdated).length+m.filter(r=>r.outdated&&r.syncClass==="auto").length;return{skills:e,mcp:t,files:d,pluginTemplates:c,initFiles:m,available:l,needsInit:L(m)}}export async function detectProjectUpdateCounts(n,s,i){const o=await h(s),a={};for(const e of n){const t=await detectUpdates(e.path,s,i,o);a[e.id]={available:t.available,needsInit:t.needsInit}}return a}async function M(n,s,i){for(const o of await T(n)){if(o.category==="skill"){if(!y(i,o.name)||s.skills.some(e=>e.scope==="project"&&e.name===o.name&&e.agent===o.agent))continue;s.skills.push({name:o.name,scope:"project",agent:o.agent,outdated:!0,custom:!1,missing:!0});continue}if(o.category==="mcp"){if(!f(i,o.name)||s.mcp.some(e=>e.scope==="project"&&e.name===o.name))continue;s.mcp.push({name:o.name,scope:"project",outdated:!0,custom:!1,missing:!0});continue}const a=o.assetCategory;a===void 0||!b(i,a,o.name)||s.files.some(e=>e.scope==="project"&&e.category===a&&e.name===o.name)||s.files.push({category:a,name:o.name,scope:"project",outdated:!0,custom:!1,missing:!0})}}async function D(n){let s;try{s=await g(n,{withFileTypes:!0})}catch{return[]}const i=[];for(const o of s)if(!(!o.isDirectory()&&!o.isSymbolicLink()))try{(await w(u.join(n,o.name))).isDirectory()&&i.push(o.name)}catch{}return i}export async function detectSkillUpdates(n,s,i){const o=k(),a=[...j().map(t=>({dir:u.join(n,...t.projectSkillsRoots()[0].split("/")),scope:"project",agent:t.harness})),...j().map(t=>({dir:t.globalSkillsRoots(o)[0],scope:"user",agent:t.harness}))],e=[];for(const t of a)for(const d of await D(t.dir)){const c=u.join(t.dir,d),m=y(i,d);if(!m){e.push({name:d,scope:t.scope,agent:t.agent,outdated:!1,custom:!0});continue}const[l,r]=await Promise.all([s.get(c),s.get(m.dirPath)]);e.push({name:d,scope:t.scope,agent:t.agent,outdated:l!==r,custom:!1,sourceDir:m.dirPath,libraryId:m.libraryId})}return e}export async function detectFileAssetUpdates(n,s,i){const o=[];for(const a of C){const e=E[a],t=e.dirs.claude?.project;if(!t)continue;const d=u.join(n,...t.split("/"));let c;try{c=(await g(d,{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(e.ext)).map(m=>m.name)}catch{continue}for(const m of c){const l=m.slice(0,-e.ext.length),r=b(i,a,l);if(!r){o.push({category:a,name:l,scope:"project",outdated:!1,custom:!0});continue}const[S,I]=await Promise.all([s.getFile(u.join(d,m)),s.getFile(r.filePath)]);o.push({category:a,name:l,scope:"project",outdated:S!==I,custom:!1,libraryId:r.libraryId})}}return o}async function G(n,s){const[i,o,a]=await Promise.all([x(n).catch(()=>({})),F().catch(()=>({})),v().catch(()=>({}))]),e=[];for(const[t,d]of Object.entries(i)){const c=f(s,t);c?e.push({name:t,scope:"project",outdated:p(d)!==p(c.config),custom:!1,libraryId:c.libraryId}):e.push({name:t,scope:"project",outdated:!1,custom:!0})}for(const[t,d]of Object.entries(o)){const c=f(s,t);c?e.push({name:t,scope:"user",outdated:p(d)!==p(c.config),custom:!1,libraryId:c.libraryId}):e.push({name:t,scope:"user",outdated:!1,custom:!0})}for(const[t,d]of Object.entries(a)){const c=f(s,t);c?e.push({name:t,scope:"user",agent:"codex",outdated:p(d)!==p(c.config),custom:!1,libraryId:c.libraryId}):e.push({name:t,scope:"user",agent:"codex",outdated:!1,custom:!0})}return e}export{P as readGlobalSkills};
1
+ import{readdir as g,stat as w}from"node:fs/promises";import{homedir as F}from"node:os";import f from"node:path";import{hashMcpConfig as p}from"./fingerprint.js";import{buildLibraryIndex as h,findSkillSource as y,findMcpSource as m,findFileAssetSource as S}from"./library-index.js";import{readMcpServers as k}from"./installer.js";import{readGlobalMcpServers as x,readGlobalSkills as v}from"./global-config.js";import{readCodexMcpServers as C}from"./codex-toml.js";import{FILE_ASSET_CATEGORIES as E,FILE_ASSET_SPECS as M}from"./file-assets.js";import{assetSurfaces as b}from"../surfaces.js";import{readInstalledLedger as T}from"./install-ledger.js";import{detectPluginTemplateUpdates as U}from"./plugin-templates.js";import{detectInitFileUpdates as L,needsInit as A}from"./init-files.js";export async function detectUpdates(a,o,l,t){const n=t??await h(o),[s,e,r,c,u]=await Promise.all([detectSkillUpdates(a,l,n),H(a,n),detectFileAssetUpdates(a,l,n),U(a,l),L(a)]);await D(a,{skills:s,mcp:e,files:r},n);const d=s.filter(i=>!i.custom&&i.outdated).length+e.filter(i=>!i.custom&&i.outdated).length+r.filter(i=>!i.custom&&i.outdated).length+c.filter(i=>i.outdated).length+u.filter(i=>i.outdated&&i.syncClass==="auto").length;return{skills:s,mcp:e,files:r,pluginTemplates:c,initFiles:u,available:d,needsInit:A(u)}}export async function detectProjectUpdateCounts(a,o,l){const t=await h(o),n={};for(const s of a){const e=await detectUpdates(s.path,o,l,t);n[s.id]={available:e.available,needsInit:e.needsInit}}return n}async function D(a,o,l){for(const t of await T(a)){if(t.category==="skill"){if(!y(l,t.name)||o.skills.some(r=>r.scope==="project"&&r.name===t.name&&r.agent===t.agent))continue;o.skills.push({name:t.name,scope:"project",agent:t.agent,outdated:!0,custom:!1,missing:!0});continue}if(t.category==="mcp"){if(!m(l,t.name)||o.mcp.some(e=>e.scope==="project"&&e.name===t.name))continue;o.mcp.push({name:t.name,scope:"project",outdated:!0,custom:!1,missing:!0});continue}const n=t.assetCategory;n===void 0||!S(l,n,t.name)||o.files.some(e=>e.scope==="project"&&e.category===n&&e.name===t.name)||o.files.push({category:n,name:t.name,scope:"project",outdated:!0,custom:!1,missing:!0})}}async function P(a){let o;try{o=await g(a,{withFileTypes:!0})}catch{return[]}const l=[];for(const t of o)if(!(!t.isDirectory()&&!t.isSymbolicLink()))try{(await w(f.join(a,t.name))).isDirectory()&&l.push(t.name)}catch{}return l}export async function detectSkillUpdates(a,o,l){const t=F(),n=[...b().map(e=>({dir:f.join(a,...e.projectSkillsRoots()[0].split("/")),scope:"project",agent:e.harness})),...b().map(e=>({dir:e.globalSkillsRoots(t)[0],scope:"user",agent:e.harness}))],s=[];for(const e of n)for(const r of await P(e.dir)){const c=f.join(e.dir,r),u=y(l,r);if(!u){s.push({name:r,scope:e.scope,agent:e.agent,outdated:!1,custom:!0});continue}const[d,i]=await Promise.all([o.get(c),o.get(u.dirPath)]);s.push({name:r,scope:e.scope,agent:e.agent,outdated:d!==i,custom:!1,sourceDir:u.dirPath,libraryId:u.libraryId})}return s}export async function detectFileAssetUpdates(a,o,l){const t=[];for(const n of E){const s=M[n],e=s.dirs.claude?.project;if(!e)continue;const r=f.join(a,...e.split("/"));let c;try{c=(await g(r,{withFileTypes:!0})).filter(u=>u.isFile()&&u.name.endsWith(s.ext)).map(u=>u.name)}catch{continue}for(const u of c){const d=u.slice(0,-s.ext.length),i=S(l,n,d);if(!i){t.push({category:n,name:d,scope:"project",outdated:!1,custom:!0});continue}const[j,I]=await Promise.all([o.getFile(f.join(r,u)),o.getFile(i.filePath)]);t.push({category:n,name:d,scope:"project",outdated:j!==I,custom:!1,libraryId:i.libraryId})}}return t}async function H(a,o){const[l,t,n]=await Promise.all([k(a).catch(()=>({})),x().catch(()=>({})),C().catch(()=>({}))]),s=[];for(const[e,r]of Object.entries(l)){const c=m(o,e);c?s.push({name:e,scope:"project",outdated:p(r)!==p(c.config),custom:!1,libraryId:c.libraryId}):s.push({name:e,scope:"project",outdated:!1,custom:!0})}for(const[e,r]of Object.entries(t)){const c=m(o,e);c?s.push({name:e,scope:"user",outdated:p(r)!==p(c.config),custom:!1,libraryId:c.libraryId}):s.push({name:e,scope:"user",outdated:!1,custom:!0})}for(const[e,r]of Object.entries(n)){const c=m(o,e);c?s.push({name:e,scope:"user",agent:"codex",outdated:p(r)!==p(c.config),custom:!1,libraryId:c.libraryId}):s.push({name:e,scope:"user",agent:"codex",outdated:!1,custom:!0})}return s}export{v as readGlobalSkills};
@@ -1 +1 @@
1
- import i from"node:path";import{lstat as u,realpath as s}from"node:fs/promises";import{builtinMarketRoot as c}from"@weavecode/templates";import{WEAVE_MARKETPLACE as m}from"@weavecode/harness";import{marketDir as f}from"./manifest.js";import{linkOrCopy as p,removeInstalled as h}from"./install-link.js";export const BUILTIN_MARKET_ID=m;export function builtinMarketDir(r){return i.join(f(r),BUILTIN_MARKET_ID)}export function builtinPacksDir(r){return i.join(builtinMarketDir(r),"plugins")}export function builtinRulesDir(r){return i.join(builtinMarketDir(r),"rules")}export function isBuiltinMarketDir(r,n){return i.resolve(r)===i.resolve(builtinMarketDir(n))}export async function ensureBuiltinMarket(r){const n=r.libraries.dataRoot,a=c(),t=builtinMarketDir(n);r.libraries.add({path:t,kind:"both"});const l=await s(a),e=await u(t).catch(()=>null);if(e){if(e.isSymbolicLink()&&await s(t).catch(()=>null)===l)return{changed:!1,form:"link"};await h(t)}try{return{changed:!0,form:await p(a,t)}}catch(o){return{changed:!1,error:o instanceof Error?o.message:String(o)}}}
1
+ import o from"node:path";import{lstat as l,realpath as s}from"node:fs/promises";import{builtinMarketRoot as u}from"@weavecode/templates";import{WEAVE_MARKETPLACE as f}from"@weavecode/harness";import{marketDir as m}from"./manifest.js";import{linkOrCopy as p,removeInstalled as h}from"./install-link.js";export const BUILTIN_MARKET_ID=f;export function builtinMarketDir(t){return o.join(m(t),BUILTIN_MARKET_ID)}export function builtinPacksDir(t){return o.join(builtinMarketDir(t),"plugins")}export function builtinRulesDir(t){return o.join(builtinMarketDir(t),"rules")}export function isBuiltinMarketDir(t,n){return o.resolve(t)===o.resolve(builtinMarketDir(n))}export async function ensureBuiltinMarket(t){const n=t.libraries.dataRoot,e=u(),r=builtinMarketDir(n);t.libraries.add({path:r,kind:"both"});const c=await s(e),a=await l(r).catch(()=>null);if(a){if(a.isSymbolicLink()&&await s(r).catch(()=>null)===c)return{changed:!1,form:"link"};await h(r)}try{return{changed:!0,form:await p(e,r)}}catch(i){return{changed:!1,error:i instanceof Error?i.message:String(i)}}}
@@ -1 +1 @@
1
- import t from"node:path";import{marketDir as s}from"./manifest.js";export function marketIdOf(e,o=s()){const r=t.relative(t.resolve(o),t.resolve(e));return r===""||r.startsWith("..")||t.isAbsolute(r)?void 0:r.split(t.sep)[0]||void 0}
1
+ import e from"node:path";import{marketDir as n}from"./manifest.js";export function marketIdOf(i,o=n()){const r=e.relative(e.resolve(o),e.resolve(i));if(r===""||r.startsWith("..")||e.isAbsolute(r))return;const t=r.split(e.sep)[0];return t||void 0}
@@ -1,2 +1,2 @@
1
- import{execFile as G}from"node:child_process";import{cp as y,mkdir as D,readdir as M,rename as b,rm as p,stat as B}from"node:fs/promises";import u from"node:path";import{promisify as P}from"node:util";import{getDataRoot as h}from"../db/paths.js";import{isInsideDir as v,toRelPosix as E}from"./resolve.js";import{isBuiltinMarketDir as z}from"./builtin.js";import{marketDir as x,readManifest as F,writeManifest as w}from"./manifest.js";const O=P(G),I=6e4,R=2e3;export function slugifyResourceId(r){const t=r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return/^[a-z0-9][a-z0-9-]*$/.test(t)?t:"resource"}export function assertSafeGitUrl(r){const t=r.trim();if(!t)throw new Error("Missing git URL");if(t.includes("--upload-pack"))throw new Error("Invalid git URL (--upload-pack rejected)");if(!(t.startsWith("https://")||t.startsWith("ssh://")||/^git@[^:/\s]+:/.test(t)))throw new Error(`Unsupported git URL (allowed: https/ssh): ${t}`);if(/[\s\r\n\t]/.test(t))throw new Error("Invalid git URL (whitespace)");return t}function l(){return new Date().toISOString()}function k(r){return r.length>R?`${r.slice(0,R)}\u2026(truncated)`:r}function d(r,t){if(!v(r,t))throw new Error(`Import target escapes the market directory: ${r}`)}async function S(r){try{return await B(r),!0}catch{return!1}}async function A(r,t){let a=u.join(t,r),i=1;for(;await S(a);)i+=1,a=u.join(t,`${r}-${i}`);return a}async function j(r,t){let a;try{a=await M(r,{withFileTypes:!0})}catch{return null}for(const i of a){if(!i.isDirectory())continue;const e=u.join(r,i.name);if((await F(e))?.origin===t)return e}return null}async function g(r,t,a,i,e=!1){const n=a.dataRoot??h(),o=E(r,n),s=a.libraries.add({path:o,kind:"both"});return{id:u.basename(r),dir:r,relPath:o,manifest:t,libraryId:s.id,reused:i,refreshed:e}}async function H(r,t,a){const i=`${t}.refresh-tmp`;await p(i,{recursive:!0,force:!0}),await y(r,i,{recursive:!0}),d(u.resolve(i),a),await p(t,{recursive:!0,force:!0}),await b(i,t)}export async function importFromDir(r,t){const a=t.dataRoot??h(),i=u.resolve(r);if(!(await B(i).catch(()=>null))?.isDirectory())throw new Error(`Not a directory: ${r}`);const e=x(a);if(v(i,e))throw new Error("\u4E0D\u80FD\u628A\u8D44\u6E90\u5E02\u573A\u7684\u5B58\u50A8\u76EE\u5F55\u5F53\u6765\u6E90\u5BFC\u5165\uFF1A\u5176\u4E2D\u7684\u8D44\u6E90\u5DF2\u5728\u5217\u8868\u4E2D\uFF08\u5185\u7F6E\u4ED3\u843D\u70B9 / \u5DF2\u5BFC\u5165\u7684\u526F\u672C\uFF09");const n=await j(e,i);if(n){const c=await F(n);await H(i,n,e);const f={...c,importedAt:l()};return await w(n,f),g(n,f,t,!0,!0)}const o=await A(slugifyResourceId(u.basename(i)),e);d(o,e),await D(u.dirname(o),{recursive:!0}),await y(i,o,{recursive:!0});const s={source:"dir",origin:i,importedAt:l()};return await w(o,s),d(u.resolve(o),e),g(o,s,t,!1)}export async function importFromGit(r,t){const a=t.dataRoot??h(),i=assertSafeGitUrl(r),e=x(a),n=await j(e,i);if(n){const f=await F(n),m=`${n}.refresh-tmp`;await p(m,{recursive:!0,force:!0});const L=["clone","--depth","1",i,m];try{await(t.execGit??defaultGitExec)("git",L,{timeout:I,maxBuffer:4*1024*1024,windowsHide:!0})}catch(U){throw new Error(`git clone failed: ${k(C(U))}`)}d(u.resolve(m),e),await p(n,{recursive:!0,force:!0}),await b(m,n);const $={...f,importedAt:l()};return await w(n,$),g(n,$,t,!0,!0)}const o=await A(slugifyResourceId(T(i)),e);d(o,e),await D(e,{recursive:!0});const s=["clone","--depth","1",i,o];try{await(t.execGit??defaultGitExec)("git",s,{timeout:I,maxBuffer:4*1024*1024,windowsHide:!0})}catch(f){throw new Error(`git clone failed: ${k(C(f))}`)}d(u.resolve(o),e);const c={source:"git",origin:i,importedAt:l()};return await w(o,c),g(o,c,t,!1)}export async function importLibraryIntoMarket(r,t){const a=t.dataRoot??h(),i=u.isAbsolute(r.path)?r.path:u.join(a,r.path),e=u.resolve(i),n=x(a);if(!await S(e))throw new Error(`Source directory not found: ${e}`);if(z(e,a))throw new Error("\u5185\u7F6E\u4ED3\u4E0D\u53EF\u8FC1\u5165\uFF1A\u5B83\u968F\u5305\u53D1\u5E03\u3001\u65E0\u5916\u90E8\u6765\u6E90\uFF0C\u4E14\u843D\u70B9\u662F\u94FE\u63A5\uFF08\u5199\u5165\u4F1A\u6539\u5230\u5305\u5185\u5BB9\uFF09");if(v(e,n)){let c=await F(e);return c||(c={source:"dir",origin:e,importedAt:l()},await w(e,c)),{id:u.basename(e),dir:e,relPath:E(e,a),manifest:c,libraryId:r.id,reused:!0,refreshed:!1}}const o=await A(slugifyResourceId(u.basename(e)),n);d(o,n),await D(u.dirname(o),{recursive:!0}),await y(e,o,{recursive:!0});const s={source:"dir",origin:e,importedAt:l()};return await w(o,s),t.libraries.setPath(r.id,E(o,a)),{id:u.basename(o),dir:o,relPath:E(o,a),manifest:s,libraryId:r.id,reused:!1,refreshed:!1}}function T(r){const t=r.split(/[?#]/)[0],a=t.lastIndexOf("/"),i=t.lastIndexOf(":");return(a>i?t.slice(a+1):t.slice(i+1)).replace(/\.git$/,"")||"repo"}function C(r){const t=r,a=[t?.stderr,t?.stdout].filter(Boolean).map(String);return(a.length?a.join(`
2
- `):r instanceof Error?r.message:String(r)).trim()||"unknown error"}export const defaultGitExec=async(r,t,a)=>{const{stdout:i,stderr:e}=await O(r,t,a);return{stdout:String(i),stderr:String(e)}};
1
+ import{execFile as F}from"node:child_process";import{cp as x,mkdir as E,readdir as G,rename as k,rm as p,stat as A}from"node:fs/promises";import s from"node:path";import{promisify as _}from"node:util";import{getDataRoot as h}from"../db/paths.js";import{isInsideDir as I,toRelPosix as g}from"./resolve.js";import{isBuiltinMarketDir as B}from"./builtin.js";import{marketDir as R,readManifest as y,writeManifest as d}from"./manifest.js";const C=_(F),D=6e4,M=2e3;export function slugifyResourceId(r){const t=r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return/^[a-z0-9][a-z0-9-]*$/.test(t)?t:"resource"}export function assertSafeGitUrl(r){const t=r.trim();if(!t)throw new Error("Missing git URL");if(t.includes("--upload-pack"))throw new Error("Invalid git URL (--upload-pack rejected)");if(!(t.startsWith("https://")||t.startsWith("ssh://")||/^git@[^:/\s]+:/.test(t)))throw new Error(`Unsupported git URL (allowed: https/ssh): ${t}`);if(/[\s\r\n\t]/.test(t))throw new Error("Invalid git URL (whitespace)");return t}function w(){return new Date().toISOString()}function S(r){return r.length>M?`${r.slice(0,M)}\u2026(truncated)`:r}function l(r,t){if(!I(r,t))throw new Error(`Import target escapes the market directory: ${r}`)}async function U(r){try{return await A(r),!0}catch{return!1}}async function b(r,t){let i=s.join(t,r),e=1;for(;await U(i);)e+=1,i=s.join(t,`${r}-${e}`);return i}async function L(r,t){let i;try{i=await G(r,{withFileTypes:!0})}catch{return null}for(const e of i){if(!e.isDirectory())continue;const o=s.join(r,e.name);if((await y(o))?.origin===t)return o}return null}async function v(r,t,i,e,o=!1){const n=i.dataRoot??h(),a=g(r,n),c=i.libraries.add({path:a,kind:"both"});return{id:s.basename(r),dir:r,relPath:a,manifest:t,libraryId:c.id,reused:e,refreshed:o}}async function P(r,t,i){const e=`${t}.refresh-tmp`;await p(e,{recursive:!0,force:!0}),await x(r,e,{recursive:!0}),l(s.resolve(e),i),await p(t,{recursive:!0,force:!0}),await k(e,t)}export async function importFromDir(r,t){const i=t.dataRoot??h(),e=s.resolve(r);if(!(await A(e).catch(()=>null))?.isDirectory())throw new Error(`Not a directory: ${r}`);const n=R(i);if(I(e,n))throw new Error("\u4E0D\u80FD\u628A\u8D44\u6E90\u5E02\u573A\u7684\u5B58\u50A8\u76EE\u5F55\u5F53\u6765\u6E90\u5BFC\u5165\uFF1A\u5176\u4E2D\u7684\u8D44\u6E90\u5DF2\u5728\u5217\u8868\u4E2D\uFF08\u5185\u7F6E\u4ED3\u843D\u70B9 / \u5DF2\u5BFC\u5165\u7684\u526F\u672C\uFF09");const a=await L(n,e);if(a){const m=await y(a);await P(e,a,n);const f={...m,importedAt:w()};return await d(a,f),v(a,f,t,!0,!0)}const c=await b(slugifyResourceId(s.basename(e)),n);l(c,n),await E(s.dirname(c),{recursive:!0}),await x(e,c,{recursive:!0});const u={source:"dir",origin:e,importedAt:w()};return await d(c,u),l(s.resolve(c),n),v(c,u,t,!1)}export async function importFromGit(r,t){const i=t.dataRoot??h(),e=assertSafeGitUrl(r),o=R(i),n=await L(o,e);if(n){const m=await y(n),f=`${n}.refresh-tmp`;await p(f,{recursive:!0,force:!0});const T=["clone","--depth","1",e,f];try{await(t.execGit??defaultGitExec)("git",T,{timeout:D,maxBuffer:4*1024*1024,windowsHide:!0})}catch(j){throw new Error(`git clone failed: ${S(O(j))}`)}l(s.resolve(f),o),await p(n,{recursive:!0,force:!0}),await k(f,n);const $={...m,importedAt:w()};return await d(n,$),v(n,$,t,!0,!0)}const a=await b(slugifyResourceId(z(e)),o);l(a,o),await E(o,{recursive:!0});const c=["clone","--depth","1",e,a];try{await(t.execGit??defaultGitExec)("git",c,{timeout:D,maxBuffer:4*1024*1024,windowsHide:!0})}catch(m){throw new Error(`git clone failed: ${S(O(m))}`)}l(s.resolve(a),o);const u={source:"git",origin:e,importedAt:w()};return await d(a,u),v(a,u,t,!1)}export async function importLibraryIntoMarket(r,t){const i=t.dataRoot??h(),e=s.isAbsolute(r.path)?r.path:s.join(i,r.path),o=s.resolve(e),n=R(i);if(!await U(o))throw new Error(`Source directory not found: ${o}`);if(B(o,i))throw new Error("\u5185\u7F6E\u4ED3\u4E0D\u53EF\u8FC1\u5165\uFF1A\u5B83\u968F\u5305\u53D1\u5E03\u3001\u65E0\u5916\u90E8\u6765\u6E90\uFF0C\u4E14\u843D\u70B9\u662F\u94FE\u63A5\uFF08\u5199\u5165\u4F1A\u6539\u5230\u5305\u5185\u5BB9\uFF09");if(I(o,n)){let u=await y(o);return u||(u={source:"dir",origin:o,importedAt:w()},await d(o,u)),{id:s.basename(o),dir:o,relPath:g(o,i),manifest:u,libraryId:r.id,reused:!0,refreshed:!1}}const a=await b(slugifyResourceId(s.basename(o)),n);l(a,n),await E(s.dirname(a),{recursive:!0}),await x(o,a,{recursive:!0});const c={source:"dir",origin:o,importedAt:w()};return await d(a,c),t.libraries.setPath(r.id,g(a,i)),{id:s.basename(a),dir:a,relPath:g(a,i),manifest:c,libraryId:r.id,reused:!1,refreshed:!1}}function z(r){const t=r.split(/[?#]/)[0],i=t.lastIndexOf("/"),e=t.lastIndexOf(":");return(i>e?t.slice(i+1):t.slice(e+1)).replace(/\.git$/,"")||"repo"}function O(r){const t=r,i=[t?.stderr,t?.stdout].filter(Boolean).map(String);return(i.length?i.join(`
2
+ `):r instanceof Error?r.message:String(r)).trim()||"unknown error"}export const defaultGitExec=async(r,t,i)=>{const{stdout:e,stderr:o}=await C(r,t,i);return{stdout:String(e),stderr:String(o)}};
@@ -1 +1 @@
1
- import{stat as d}from"node:fs/promises";import{defaultGitExec as u,importFromDir as c,importFromGit as m}from"./import.js";import{readManifest as n,writeManifest as f}from"./manifest.js";async function w(i){try{return(await d(i)).isDirectory()}catch{return!1}}export async function refreshMarketItems(i,a){return Promise.all(i.map(async t=>{const r=await n(t.dir);if(!r)return{id:t.id,status:"skipped"};if(r.source==="dir"&&!await w(r.origin))return{id:t.id,status:"origin-missing"};try{if(r.source==="git"){const s=await m(r.origin,a),e=await p(s.dir,a.execGit??u);if(e){const o={...await n(s.dir),commit:e};return await f(s.dir,o),{id:t.id,status:"refreshed",commit:e}}return{id:t.id,status:"refreshed"}}return await c(r.origin,a),{id:t.id,status:"refreshed"}}catch{return{id:t.id,status:"failed"}}}))}async function p(i,a){try{return(await a("git",["-C",i,"rev-parse","HEAD"],{timeout:15e3,maxBuffer:1048576,windowsHide:!0})).stdout.trim()||void 0}catch{return}}
1
+ import{stat as d}from"node:fs/promises";import{defaultGitExec as u,importFromDir as c,importFromGit as f}from"./import.js";import{readManifest as n,writeManifest as m}from"./manifest.js";async function w(t){try{return(await d(t)).isDirectory()}catch{return!1}}export async function refreshMarketItems(t,e){return Promise.all(t.map(async i=>{const r=await n(i.dir);if(!r)return{id:i.id,status:"skipped"};if(r.source==="dir"&&!await w(r.origin))return{id:i.id,status:"origin-missing"};try{if(r.source==="git"){const a=await f(r.origin,e),s=await h(a.dir,e.execGit??u);if(s){const o={...await n(a.dir),commit:s};return await m(a.dir,o),{id:i.id,status:"refreshed",commit:s}}return{id:i.id,status:"refreshed"}}return await c(r.origin,e),{id:i.id,status:"refreshed"}}catch{return{id:i.id,status:"failed"}}}))}async function h(t,e){try{return(await e("git",["-C",t,"rev-parse","HEAD"],{timeout:15e3,maxBuffer:1048576,windowsHide:!0})).stdout.trim()||void 0}catch{return}}
@@ -1 +1 @@
1
- import t from"node:path";import{getDataRoot as i}from"../db/paths.js";import{marketDir as l}from"./manifest.js";import{isBuiltinMarketDir as p}from"./builtin.js";export function resolveLibraryPath(r,e=i()){if(!t.isAbsolute(r.path))return t.join(e,r.path);const o=t.resolve(r.path);return isInsideDir(o,e)?o:r.path}export function isInsideDir(r,e){const o=t.relative(t.resolve(e),t.resolve(r));return t.isAbsolute(o)?!1:o===""||o!==".."&&!o.startsWith(`..${t.sep}`)}export function toRelPosix(r,e=i()){return t.relative(t.resolve(e),t.resolve(r)).split(t.sep).join("/")}export function marketLibraryRoots(r,e=i()){const o=t.resolve(l(e)),n=new Set;for(const a of r.list()){const s=t.resolve(a.path);s===o||p(s,e)||isInsideDir(s,o)&&n.add(s)}return[...n]}
1
+ import t from"node:path";import{getDataRoot as s}from"../db/paths.js";import{marketDir as a}from"./manifest.js";import{isBuiltinMarketDir as p}from"./builtin.js";export function resolveLibraryPath(e,o=s()){if(!t.isAbsolute(e.path))return t.join(o,e.path);const r=t.resolve(e.path);return isInsideDir(r,o)?r:e.path}export function isInsideDir(e,o){const r=t.relative(t.resolve(o),t.resolve(e));return t.isAbsolute(r)?!1:r===""||r!==".."&&!r.startsWith(`..${t.sep}`)}export function toRelPosix(e,o=s()){return t.relative(t.resolve(o),t.resolve(e)).split(t.sep).join("/")}export function marketLibraryRoots(e,o=s()){const r=t.resolve(a(o)),n=new Set;for(const l of e.list()){const i=t.resolve(l.path);i===r||p(i,o)||isInsideDir(i,r)&&n.add(i)}return[...n]}
@@ -1 +1 @@
1
- import{stat as u}from"node:fs/promises";import m from"node:path";import{hashSkillDir as c}from"../install/fingerprint.js";import{defaultGitExec as d}from"./import.js";import{readManifest as w}from"./manifest.js";const l=15e3;export const MARKET_SKIP_NAMES=new Set([".weave",".git","node_modules",".weave-market.json"]);async function p(e){try{return(await u(e)).isDirectory()}catch{return!1}}async function f(e,n){const r=m.resolve(n);if(!await p(r))return"origin-missing";const[t,a]=await Promise.all([c(e,MARKET_SKIP_NAMES),c(r,MARKET_SKIP_NAMES)]);return t===a?"uptodate":"update-available"}async function g(e,n,r){const t={timeout:l,maxBuffer:1048576,windowsHide:!0};try{const a=await r("git",["-C",e,"rev-parse","HEAD"],t),i=await r("git",["ls-remote",n,"HEAD"],t),o=a.stdout.trim(),s=i.stdout.trim().split(/\s+/)[0]??"";return!o||!s?"unknown":o===s?"uptodate":"update-available"}catch{return"unknown"}}export async function checkMarketUpdates(e,n){const r=n?.execGit??d;return Promise.all(e.map(async t=>{const a=await w(t.dir);let i;return a?a.source==="git"?i=await g(t.dir,a.origin,r):i=await f(t.dir,a.origin):i="unknown",{id:t.id,status:i,checkedAt:new Date().toISOString()}}))}
1
+ import{stat as u}from"node:fs/promises";import m from"node:path";import{hashSkillDir as c}from"../install/fingerprint.js";import{defaultGitExec as l}from"./import.js";import{readManifest as d}from"./manifest.js";const f=15e3;export const MARKET_SKIP_NAMES=new Set([".weave",".git","node_modules",".weave-market.json"]);async function p(i){try{return(await u(i)).isDirectory()}catch{return!1}}async function w(i,o){const r=m.resolve(o);if(!await p(r))return"origin-missing";const[t,e]=await Promise.all([c(i,MARKET_SKIP_NAMES),c(r,MARKET_SKIP_NAMES)]);return t===e?"uptodate":"update-available"}async function h(i,o,r){const t={timeout:f,maxBuffer:1048576,windowsHide:!0};try{const e=await r("git",["-C",i,"rev-parse","HEAD"],t),a=await r("git",["ls-remote",o,"HEAD"],t),n=e.stdout.trim(),s=a.stdout.trim().split(/\s+/)[0]??"";return!n||!s?"unknown":n===s?"uptodate":"update-available"}catch{return"unknown"}}export async function checkMarketUpdates(i,o){const r=o?.execGit??l;return Promise.all(i.map(async t=>{const e=await d(t.dir);let a;return e?e.source==="git"?a=await h(t.dir,e.origin,r):a=await w(t.dir,e.origin):a="unknown",{id:t.id,status:a,checkedAt:new Date().toISOString()}}))}
@@ -1,2 +1,2 @@
1
- import{basename as d,join as a}from"node:path";import{mkdirSync as f,writeFileSync as l}from"node:fs";import{openDatabase as p}from"./db/db.js";import{ProjectRepository as m}from"./repositories/projects.js";import{HookDispatchRepository as u}from"./repositories/hook-dispatches.js";import{HookEventRepository as h}from"./repositories/hook-events.js";import{SessionRepository as P}from"./repositories/sessions.js";import{SessionWatchRepository as w}from"./repositories/session-watches.js";import{OrchestrationRepository as j,OrchestrationRunRepository as k}from"./repositories/orchestrations.js";import{SideQuestionRepository as R}from"./repositories/side-questions.js";import{generateToken as g}from"./daemon/auth.js";import{purgeProjectPipeline as B}from"./daemon/hook-pipeline.js";import{hooksRoot as v}from"./hooks/mirror.js";export function registerProject(t,s,n){const o=p(n);try{const r=new m(o),e=r.getByPath(t)?.token??g(),i=r.register({path:t,name:d(t),token:e,source:s});return f(a(t,".weave"),{recursive:!0}),l(a(t,".weave","token"),e+`
2
- `,"utf-8"),{id:i.id,token:e,path:i.path}}finally{o.close()}}export function unregisterProject(t,s,n){const o=p(s);try{const r=new m(o),e=r.getByPath(t);if(!e)return null;const i=new u(o).deleteByProject(e.id),c=new h(o).deleteByProject(e.id);new w(o).deleteByProject(e.id),new j(o).deleteByProject(e.id),new R(o).deleteByProject(e.id),new k(o).clear("all",e.id);const y=new P(o).removeByProject(e.id);return B(n??v(),e.token),r.remove(e.id),{id:e.id,name:e.name,path:e.path,purged:{events:c,dispatches:i,sessions:y}}}finally{o.close()}}
1
+ import{basename as y,join as p}from"node:path";import{mkdirSync as f,writeFileSync as l}from"node:fs";import{openDatabase as m}from"./db/db.js";import{ProjectRepository as a}from"./repositories/projects.js";import{HookDispatchRepository as u}from"./repositories/hook-dispatches.js";import{HookEventRepository as w}from"./repositories/hook-events.js";import{SessionRepository as h}from"./repositories/sessions.js";import{SessionWatchRepository as j}from"./repositories/session-watches.js";import{OrchestrationRepository as P,OrchestrationRunRepository as R}from"./repositories/orchestrations.js";import{SideQuestionRepository as k}from"./repositories/side-questions.js";import{generateToken as B}from"./daemon/auth.js";import{purgeProjectPipeline as v}from"./daemon/hook-pipeline.js";import{hooksRoot as g}from"./hooks/mirror.js";export function registerProject(t,s,c){const o=m(c);try{const r=new a(o),n=r.getByPath(t)?.token??B(),i=r.register({path:t,name:y(t),token:n,source:s});return f(p(t,".weave"),{recursive:!0}),l(p(t,".weave","token"),n+`
2
+ `,"utf-8"),{id:i.id,token:n,path:i.path}}finally{o.close()}}export function unregisterProject(t,s,c){const o=m(s);try{const r=new a(o),e=r.getByPath(t);if(!e)return null;const n=new u(o).deleteByProject(e.id),i=new w(o).deleteByProject(e.id);new j(o).deleteByProject(e.id),new P(o).deleteByProject(e.id),new k(o).deleteByProject(e.id),new R(o).clear("all",e.id);const d=new h(o).removeByProject(e.id);return v(c??g(),e.token),r.remove(e.id),{id:e.id,name:e.name,path:e.path,purged:{events:i,dispatches:n,sessions:d}}}finally{o.close()}}
@@ -1,8 +1,8 @@
1
- export class HookDispatchRepository{db;constructor(t){this.db=t}insert(t){const s=this.db.prepare(`INSERT INTO hook_dispatches (rule_id, event_id, session_id, prompt, status, mode, started_at)
2
- VALUES (?, ?, ?, ?, ?, ?, ?)`).run(t.ruleId,t.eventId??null,t.sessionId??null,t.prompt,t.status,t.mode,new Date().toISOString());return this.getById(Number(s.lastInsertRowid))}getById(t){const s=this.db.prepare("SELECT * FROM hook_dispatches WHERE id = ?").get(t);return s?n(s):void 0}updateStatus(t,s){const r=new Date().toISOString();return this.db.prepare(`UPDATE hook_dispatches
1
+ export class HookDispatchRepository{db;constructor(t){this.db=t}insert(t){const e=this.db.prepare(`INSERT INTO hook_dispatches (rule_id, event_id, session_id, prompt, status, mode, started_at)
2
+ VALUES (?, ?, ?, ?, ?, ?, ?)`).run(t.ruleId,t.eventId??null,t.sessionId??null,t.prompt,t.status,t.mode,new Date().toISOString());return this.getById(Number(e.lastInsertRowid))}getById(t){const e=this.db.prepare("SELECT * FROM hook_dispatches WHERE id = ?").get(t);return e?r(e):void 0}updateStatus(t,e){const n=new Date().toISOString();return this.db.prepare(`UPDATE hook_dispatches
3
3
  SET status = ?, output = COALESCE(?, output), error = COALESCE(?, error),
4
4
  finished_at = CASE WHEN ? = 1 THEN ? ELSE finished_at END
5
- WHERE id = ?`).run(s.status,s.output??null,s.error??null,s.finished?1:0,r,t),this.getById(t)}list(t={}){const s=Math.min(Math.max(t.limit??50,1),200),r=[],i=[];t.ruleId&&(r.push("rule_id = ?"),i.push(t.ruleId)),t.status&&(r.push("status = ?"),i.push(t.status)),t.sessionId&&(r.push("session_id = ?"),i.push(t.sessionId));const d=r.length>0?`WHERE ${r.join(" AND ")}`:"";return this.db.prepare(`SELECT * FROM hook_dispatches ${d} ORDER BY started_at DESC, id DESC LIMIT ?`).all(...i,s).map(n)}deleteBySession(t){return Number(this.db.prepare("DELETE FROM hook_dispatches WHERE session_id = ?").run(t).changes)}deleteByProject(t){return Number(this.db.prepare(`DELETE FROM hook_dispatches WHERE session_id IN (SELECT session_id FROM sessions WHERE project_id = ?)
6
- OR event_id IN (SELECT id FROM hook_events WHERE project_id = ?)`).run(t,t).changes)}findRecentAuto(t,s,r){const i=this.db.prepare(`SELECT * FROM hook_dispatches
5
+ WHERE id = ?`).run(e.status,e.output??null,e.error??null,e.finished?1:0,n,t),this.getById(t)}list(t={}){const e=Math.min(Math.max(t.limit??50,1),200),n=[],i=[];t.ruleId&&(n.push("rule_id = ?"),i.push(t.ruleId)),t.status&&(n.push("status = ?"),i.push(t.status)),t.sessionId&&(n.push("session_id = ?"),i.push(t.sessionId));const d=n.length>0?`WHERE ${n.join(" AND ")}`:"";return this.db.prepare(`SELECT * FROM hook_dispatches ${d} ORDER BY started_at DESC, id DESC LIMIT ?`).all(...i,e).map(r)}deleteBySession(t){return Number(this.db.prepare("DELETE FROM hook_dispatches WHERE session_id = ?").run(t).changes)}deleteByProject(t){return Number(this.db.prepare(`DELETE FROM hook_dispatches WHERE session_id IN (SELECT session_id FROM sessions WHERE project_id = ?)
6
+ OR event_id IN (SELECT id FROM hook_events WHERE project_id = ?)`).run(t,t).changes)}findRecentAuto(t,e,n){const i=this.db.prepare(`SELECT * FROM hook_dispatches
7
7
  WHERE rule_id = ? AND session_id = ? AND mode = 'auto' AND started_at >= ?
8
- ORDER BY started_at DESC LIMIT 1`).get(t,s,r);return i?n(i):void 0}}function n(e){return{id:Number(e.id),ruleId:String(e.rule_id),eventId:e.event_id==null?null:Number(e.event_id),sessionId:e.session_id==null?null:String(e.session_id),prompt:String(e.prompt),status:String(e.status),mode:String(e.mode),output:e.output==null?null:String(e.output),error:e.error==null?null:String(e.error),startedAt:String(e.started_at),finishedAt:e.finished_at==null?null:String(e.finished_at)}}
8
+ ORDER BY started_at DESC LIMIT 1`).get(t,e,n);return i?r(i):void 0}}function r(s){return{id:Number(s.id),ruleId:String(s.rule_id),eventId:s.event_id==null?null:Number(s.event_id),sessionId:s.session_id==null?null:String(s.session_id),prompt:String(s.prompt),status:String(s.status),mode:String(s.mode),output:s.output==null?null:String(s.output),error:s.error==null?null:String(s.error),startedAt:String(s.started_at),finishedAt:s.finished_at==null?null:String(s.finished_at)}}
@@ -1,5 +1,5 @@
1
1
  import type { DatabaseSync } from 'node:sqlite';
2
- import type { Harness } from '@weavecode/core';
2
+ import { type Harness } from '@weavecode/core';
3
3
  export interface HookEventInput {
4
4
  projectId: number;
5
5
  source: Harness;
@@ -81,4 +81,22 @@ export declare class HookEventRepository {
81
81
  listByTools(sessionId: string, tools: readonly string[], needle: string | null, limit: number): HookEventRow[];
82
82
  /** `types` 非空只取这些事件类型(对话视图按开/闭轮类型翻页,不拉整条事件链)。 */
83
83
  listBySession(sessionId: string, limit?: number, beforeId?: number, types?: readonly string[]): HookEventRow[];
84
+ /**
85
+ * 全局搜索的聊天记录路:对话类事件(HARNESS_LIFECYCLE 的 open + close 全族,
86
+ * 不散写事件名)的正文键(UPS = raw.prompt,Stop 族 = raw.last_assistant_message)
87
+ * 做 LIKE——event_type 先走 idx_hook_events_type 收窄(对话类只占全库约 2%),
88
+ * json_extract 精确提键(不扫 cwd/transcriptPath 等非正文键)。
89
+ * `ORDER BY id DESC` 倒序早停:最新对话优先,凑满 limit 即停。
90
+ */
91
+ searchConversationTexts(q: string, limit: number): ConversationTextHit[];
92
+ }
93
+ /** 一条聊天正文命中(全文随行带;命中窗口由路由层截)。 */
94
+ export interface ConversationTextHit {
95
+ eventId: number;
96
+ projectId: number;
97
+ source: string;
98
+ eventType: string;
99
+ sessionId: string | null;
100
+ at: string;
101
+ text: string;
84
102
  }
@@ -1,3 +1,9 @@
1
- import{readDaemonSettingsSync as u,DEFAULT_EVENT_RETENTION_DAYS as d}from"../daemon/settings.js";export class HookEventRepository{db;lastPruneDay=-1;insertEvent;pruneByCutoff;constructor(e){this.db=e,this.insertEvent=e.prepare(`INSERT INTO hook_events (project_id, source, event_type, session_id, payload, created_at)
2
- VALUES (?, ?, ?, ?, ?, ?)`),this.pruneByCutoff=e.prepare("DELETE FROM hook_events WHERE created_at < ?")}resetPrune(){this.lastPruneDay=-1}insert(e){this.pruneExpired();const r=this.insertEvent.run(e.projectId,e.source,e.eventType,e.sessionId??null,e.payload,e.createdAt??new Date().toISOString());return Number(r.lastInsertRowid)}insertMany(e){this.pruneExpired();const r=[];this.db.exec("BEGIN");try{for(const t of e){const n=this.insertEvent.run(t.projectId,t.source,t.eventType,t.sessionId??null,t.payload,t.createdAt??new Date().toISOString());r.push(Number(n.lastInsertRowid))}this.db.exec("COMMIT")}catch(t){throw this.db.exec("ROLLBACK"),t}return r}pruneExpired(){const e=Math.floor(Date.now()/864e5);if(e===this.lastPruneDay)return;this.lastPruneDay=e;const r=u().events?.retentionDays??d,t=new Date((e-r)*864e5).toISOString();this.pruneByCutoff.run(t)}listByProject(e,r=100){return this.db.prepare("SELECT * FROM hook_events WHERE project_id = ? ORDER BY created_at DESC LIMIT ?").all(e,r).map(t=>p(t))}deleteBySession(e){return Number(this.db.prepare("DELETE FROM hook_events WHERE session_id = ?").run(e).changes)}deleteByProject(e){return Number(this.db.prepare("DELETE FROM hook_events WHERE project_id = ?").run(e).changes)}countAll(){return Number(this.db.prepare("SELECT COUNT(*) AS n FROM hook_events").get().n)}countSince(e,r){const t=this.db.prepare("SELECT COUNT(*) AS n FROM hook_events WHERE project_id = ? AND created_at >= ?");let n=0;for(const s of e)n+=Number(t.get(s,r).n);return n}seriesBySecond(e,r){const t=this.db.prepare(`SELECT substr(created_at, 1, 19) AS at, COUNT(*) AS n
3
- FROM hook_events WHERE project_id = ? AND created_at >= ? GROUP BY at`),n=new Map;for(const s of e)for(const o of t.all(s,r))n.set(o.at,(n.get(o.at)??0)+Number(o.n));return[...n].map(([s,o])=>({at:s,n:o})).sort((s,o)=>s.at<o.at?-1:1)}listByTools(e,r,t,n){if(r.length===0)return[];const s=["session_id = ?","event_type IN ('PreToolUse','PostToolUse')",`(${r.map(()=>"payload LIKE ?").join(" OR ")})`],o=[e,...r.map(a=>`%"toolName":"${a}"%`)];return t&&(s.push("payload LIKE ?"),o.push(`%${t}%`)),this.db.prepare(`SELECT * FROM hook_events WHERE ${s.join(" AND ")} ORDER BY id DESC LIMIT ?`).all(...o,n).map(a=>p(a))}listBySession(e,r=300,t,n){const s=["session_id = ?"],o=[e];return t!=null&&(s.push("id < ?"),o.push(t)),n?.length&&(s.push(`event_type IN (${n.map(()=>"?").join(",")})`),o.push(...n)),this.db.prepare(`SELECT * FROM hook_events WHERE ${s.join(" AND ")} ORDER BY id DESC LIMIT ?`).all(...o,r).map(a=>p(a)).reverse()}}function p(i){return{id:Number(i.id),projectId:Number(i.project_id),source:String(i.source),eventType:String(i.event_type),sessionId:i.session_id==null?null:String(i.session_id),payload:String(i.payload),createdAt:String(i.created_at)}}
1
+ import{HARNESS_LIFECYCLE as u}from"@weavecode/core";import{readDaemonSettingsSync as l,DEFAULT_EVENT_RETENTION_DAYS as _}from"../daemon/settings.js";export class HookEventRepository{db;lastPruneDay=-1;insertEvent;pruneByCutoff;constructor(e){this.db=e,this.insertEvent=e.prepare(`INSERT INTO hook_events (project_id, source, event_type, session_id, payload, created_at)
2
+ VALUES (?, ?, ?, ?, ?, ?)`),this.pruneByCutoff=e.prepare("DELETE FROM hook_events WHERE created_at < ?")}resetPrune(){this.lastPruneDay=-1}insert(e){this.pruneExpired();const s=this.insertEvent.run(e.projectId,e.source,e.eventType,e.sessionId??null,e.payload,e.createdAt??new Date().toISOString());return Number(s.lastInsertRowid)}insertMany(e){this.pruneExpired();const s=[];this.db.exec("BEGIN");try{for(const t of e){const r=this.insertEvent.run(t.projectId,t.source,t.eventType,t.sessionId??null,t.payload,t.createdAt??new Date().toISOString());s.push(Number(r.lastInsertRowid))}this.db.exec("COMMIT")}catch(t){throw this.db.exec("ROLLBACK"),t}return s}pruneExpired(){const e=Math.floor(Date.now()/864e5);if(e===this.lastPruneDay)return;this.lastPruneDay=e;const s=l().events?.retentionDays??_,t=new Date((e-s)*864e5).toISOString();this.pruneByCutoff.run(t)}listByProject(e,s=100){return this.db.prepare("SELECT * FROM hook_events WHERE project_id = ? ORDER BY created_at DESC LIMIT ?").all(e,s).map(t=>c(t))}deleteBySession(e){return Number(this.db.prepare("DELETE FROM hook_events WHERE session_id = ?").run(e).changes)}deleteByProject(e){return Number(this.db.prepare("DELETE FROM hook_events WHERE project_id = ?").run(e).changes)}countAll(){return Number(this.db.prepare("SELECT COUNT(*) AS n FROM hook_events").get().n)}countSince(e,s){const t=this.db.prepare("SELECT COUNT(*) AS n FROM hook_events WHERE project_id = ? AND created_at >= ?");let r=0;for(const n of e)r+=Number(t.get(n,s).n);return r}seriesBySecond(e,s){const t=this.db.prepare(`SELECT substr(created_at, 1, 19) AS at, COUNT(*) AS n
3
+ FROM hook_events WHERE project_id = ? AND created_at >= ? GROUP BY at`),r=new Map;for(const n of e)for(const a of t.all(n,s))r.set(a.at,(r.get(a.at)??0)+Number(a.n));return[...r].map(([n,a])=>({at:n,n:a})).sort((n,a)=>n.at<a.at?-1:1)}listByTools(e,s,t,r){if(s.length===0)return[];const n=["session_id = ?","event_type IN ('PreToolUse','PostToolUse')",`(${s.map(()=>"payload LIKE ?").join(" OR ")})`],a=[e,...s.map(p=>`%"toolName":"${p}"%`)];return t&&(n.push("payload LIKE ?"),a.push(`%${t}%`)),this.db.prepare(`SELECT * FROM hook_events WHERE ${n.join(" AND ")} ORDER BY id DESC LIMIT ?`).all(...a,r).map(p=>c(p))}listBySession(e,s=300,t,r){const n=["session_id = ?"],a=[e];return t!=null&&(n.push("id < ?"),a.push(t)),r?.length&&(n.push(`event_type IN (${r.map(()=>"?").join(",")})`),a.push(...r)),this.db.prepare(`SELECT * FROM hook_events WHERE ${n.join(" AND ")} ORDER BY id DESC LIMIT ?`).all(...a,s).map(p=>c(p)).reverse()}searchConversationTexts(e,s){const t=new Set;for(const i of Object.values(u)){t.add(i.open);for(const p of i.close)t.add(p)}const r=[...t].map(i=>`'${i}'`).join(","),n=h(e);return this.db.prepare(`SELECT id, project_id, source, event_type, session_id, payload, created_at
4
+ FROM hook_events
5
+ WHERE event_type IN (${r})
6
+ AND (COALESCE(json_extract(payload, '$.raw.prompt'), '') LIKE '%' || ? || '%' ESCAPE '\\'
7
+ OR COALESCE(json_extract(payload, '$.raw.last_assistant_message'), '') LIKE '%' || ? || '%' ESCAPE '\\')
8
+ ORDER BY id DESC
9
+ LIMIT ?`).all(n,n,s).map(i=>{const p=JSON.parse(String(i.payload)),E=d(p.raw?.prompt)??d(p.raw?.last_assistant_message)??"";return{eventId:Number(i.id),projectId:Number(i.project_id),source:String(i.source),eventType:String(i.event_type),sessionId:i.session_id==null?null:String(i.session_id),at:String(i.created_at),text:E}})}}function h(o){return o.replace(/[\\%_]/g,e=>`\\${e}`)}function d(o){return typeof o=="string"&&o.length>0?o:null}function c(o){return{id:Number(o.id),projectId:Number(o.project_id),source:String(o.source),eventType:String(o.event_type),sessionId:o.session_id==null?null:String(o.session_id),payload:String(o.payload),createdAt:String(o.created_at)}}
@@ -1,8 +1,8 @@
1
- import{randomUUID as s}from"node:crypto";import{HookRuleSchema as d}from"@weavecode/core";export class HookRuleRepository{db;constructor(r){this.db=r}create(r){const e=new Date().toISOString(),o=d.parse({id:s(),name:r.name,enabled:r.enabled??!0,priority:r.priority??0,projectId:r.projectId,source:r.source,filter:r.filter??{},handler:r.handler,timeoutMs:r.timeoutMs??1e4,record:r.record??r.handler.type!=="log",origin:r.origin??"user",pluginId:r.pluginId??null});return this.insertRow(o,e,e),o}upsertPluginRule(r){const e=new Date().toISOString(),o=this.getById(r.id);if(!o)return this.insertRow(r,e,e),r;const t=d.parse({...r,enabled:o.enabled});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
1
+ import{randomUUID as s}from"node:crypto";import{HookRuleSchema as o}from"@weavecode/core";export class HookRuleRepository{db;constructor(e){this.db=e}create(e){const t=new Date().toISOString(),i=o.parse({id:s(),name:e.name,enabled:e.enabled??!0,priority:e.priority??0,projectId:e.projectId,source:e.source,filter:e.filter??{},handler:e.handler,timeoutMs:e.timeoutMs??1e4,record:e.record??e.handler.type!=="log",origin:e.origin??"user",pluginId:e.pluginId??null});return this.insertRow(i,t,t),i}upsertPluginRule(e){const t=new Date().toISOString(),i=this.getById(e.id);if(!i)return this.insertRow(e,t,t),e;const r=o.parse({...e,enabled:i.enabled});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
2
2
  source = ?, filter = ?, handler = ?, timeout_ms = ?, record = ?,
3
3
  origin = ?, plugin_id = ?, updated_at = ?
4
- WHERE id = ?`).run(t.name,t.enabled?1:0,t.priority,t.projectId,JSON.stringify(t.source),JSON.stringify(t.filter),JSON.stringify(t.handler),t.timeoutMs,t.record?1:0,t.origin,t.pluginId,e,t.id),t}removeByPlugin(r){const e=this.db.prepare("DELETE FROM hook_rules WHERE plugin_id = ?").run(r);return Number(e.changes)}listByPlugin(r){return this.db.prepare("SELECT * FROM hook_rules WHERE plugin_id = ? ORDER BY created_at ASC").all(r).map(n).filter(e=>e!==void 0)}getById(r){const e=this.db.prepare("SELECT * FROM hook_rules WHERE id = ?").get(r);return e?n(e):void 0}list(r){return(r===void 0?this.db.prepare("SELECT * FROM hook_rules ORDER BY priority DESC, created_at ASC").all():this.db.prepare("SELECT * FROM hook_rules WHERE project_id IS NULL OR project_id = ? ORDER BY priority DESC, created_at ASC").all(r)).map(n).filter(e=>e!==void 0)}update(r,e){const o=this.getById(r);if(!o)return;const t=d.parse({...o,...e,id:r,projectId:"projectId"in e?e.projectId:o.projectId});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
4
+ WHERE id = ?`).run(r.name,r.enabled?1:0,r.priority,r.projectId,JSON.stringify(r.source),JSON.stringify(r.filter),JSON.stringify(r.handler),r.timeoutMs,r.record?1:0,r.origin,r.pluginId,t,r.id),r}removeByPlugin(e){const t=this.db.prepare("DELETE FROM hook_rules WHERE plugin_id = ?").run(e);return Number(t.changes)}listByPlugin(e){return this.db.prepare("SELECT * FROM hook_rules WHERE plugin_id = ? ORDER BY created_at ASC").all(e).map(d).filter(i=>i!==void 0)}getById(e){const t=this.db.prepare("SELECT * FROM hook_rules WHERE id = ?").get(e);return t?d(t):void 0}list(e){return(e===void 0?this.db.prepare("SELECT * FROM hook_rules ORDER BY priority DESC, created_at ASC").all():this.db.prepare("SELECT * FROM hook_rules WHERE project_id IS NULL OR project_id = ? ORDER BY priority DESC, created_at ASC").all(e)).map(d).filter(i=>i!==void 0)}update(e,t){const i=this.getById(e);if(!i)return;const r=o.parse({...i,...t,id:e,projectId:"projectId"in t?t.projectId:i.projectId});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
5
5
  source = ?, filter = ?, handler = ?, timeout_ms = ?, record = ?, updated_at = ?
6
- WHERE id = ?`).run(t.name,t.enabled?1:0,t.priority,t.projectId,JSON.stringify(t.source),JSON.stringify(t.filter),JSON.stringify(t.handler),t.timeoutMs,t.record?1:0,new Date().toISOString(),r),t}setEnabled(r,e){const o=this.db.prepare("UPDATE hook_rules SET enabled = ?, updated_at = ? WHERE id = ?").run(e?1:0,new Date().toISOString(),r);if(Number(o.changes)!==0)return this.getById(r)}remove(r){const e=this.db.prepare("DELETE FROM hook_rules WHERE id = ?").run(r);return Number(e.changes)>0}insertRow(r,e,o){this.db.prepare(`INSERT INTO hook_rules (id, name, enabled, priority, project_id, source, filter, handler,
6
+ WHERE id = ?`).run(r.name,r.enabled?1:0,r.priority,r.projectId,JSON.stringify(r.source),JSON.stringify(r.filter),JSON.stringify(r.handler),r.timeoutMs,r.record?1:0,new Date().toISOString(),e),r}setEnabled(e,t){const i=this.db.prepare("UPDATE hook_rules SET enabled = ?, updated_at = ? WHERE id = ?").run(t?1:0,new Date().toISOString(),e);if(Number(i.changes)!==0)return this.getById(e)}remove(e){const t=this.db.prepare("DELETE FROM hook_rules WHERE id = ?").run(e);return Number(t.changes)>0}insertRow(e,t,i){this.db.prepare(`INSERT INTO hook_rules (id, name, enabled, priority, project_id, source, filter, handler,
7
7
  timeout_ms, record, origin, plugin_id, created_at, updated_at)
8
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(r.id,r.name,r.enabled?1:0,r.priority,r.projectId,JSON.stringify(r.source),JSON.stringify(r.filter),JSON.stringify(r.handler),r.timeoutMs,r.record?1:0,r.origin,r.pluginId,e,o)}}function n(i){try{return d.parse({id:String(i.id),name:String(i.name),enabled:Number(i.enabled)===1,priority:Number(i.priority),projectId:i.project_id==null?null:Number(i.project_id),source:JSON.parse(String(i.source)),filter:JSON.parse(String(i.filter??"{}")),handler:JSON.parse(String(i.handler)),timeoutMs:Number(i.timeout_ms),record:Number(i.record)===1,origin:i.origin??"user",pluginId:i.plugin_id==null?null:String(i.plugin_id)})}catch{return}}
8
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(e.id,e.name,e.enabled?1:0,e.priority,e.projectId,JSON.stringify(e.source),JSON.stringify(e.filter),JSON.stringify(e.handler),e.timeoutMs,e.record?1:0,e.origin,e.pluginId,t,i)}}function d(n){try{return o.parse({id:String(n.id),name:String(n.name),enabled:Number(n.enabled)===1,priority:Number(n.priority),projectId:n.project_id==null?null:Number(n.project_id),source:JSON.parse(String(n.source)),filter:JSON.parse(String(n.filter??"{}")),handler:JSON.parse(String(n.handler)),timeoutMs:Number(n.timeout_ms),record:Number(n.record)===1,origin:n.origin??"user",pluginId:n.plugin_id==null?null:String(n.plugin_id)})}catch{return}}
@@ -1 +1 @@
1
- import a from"node:path";import{getDataRoot as h}from"../db/paths.js";import{isInsideDir as o,resolveLibraryPath as p,toRelPosix as d}from"../market/resolve.js";export class LibraryRepository{db;dataRoot;constructor(t,r=h()){this.db=t,this.dataRoot=r}add(t){return this.getByPath(t.path)||(this.db.prepare("INSERT OR IGNORE INTO libraries (path, kind, added_at) VALUES (?, ?, ?)").run(this.writeForm(t.path),t.kind,new Date().toISOString()),this.getByPath(t.path))}getByPath(t){for(const r of new Set([t,this.writeForm(t)])){const s=this.db.prepare("SELECT * FROM libraries WHERE path = ?").get(r);if(s)return this.resolveRow(e(s))}}getById(t){const r=this.db.prepare("SELECT * FROM libraries WHERE id = ?").get(t);return r?this.resolveRow(e(r)):void 0}list(){return this.db.prepare("SELECT * FROM libraries ORDER BY added_at DESC").all().map(t=>this.resolveRow(e(t)))}setPath(t,r){this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(this.writeForm(r),t)}remove(t){this.db.prepare("DELETE FROM libraries WHERE id = ?").run(t)}writeForm(t){return a.isAbsolute(t)&&o(t,this.dataRoot)?d(t,this.dataRoot):t}resolveRow(t){if(!a.isAbsolute(t.path))return{...t,path:p(t,this.dataRoot)};const r=a.resolve(t.path);return o(r,this.dataRoot)?(this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(d(r,this.dataRoot),t.id),{...t,path:r}):t}}function e(i){return{id:Number(i.id),path:String(i.path),kind:i.kind,addedAt:String(i.added_at)}}
1
+ import i from"node:path";import{getDataRoot as h}from"../db/paths.js";import{isInsideDir as o,resolveLibraryPath as n,toRelPosix as d}from"../market/resolve.js";export class LibraryRepository{db;dataRoot;constructor(t,r=h()){this.db=t,this.dataRoot=r}add(t){const r=this.getByPath(t.path);return r||(this.db.prepare("INSERT OR IGNORE INTO libraries (path, kind, added_at) VALUES (?, ?, ?)").run(this.writeForm(t.path),t.kind,new Date().toISOString()),this.getByPath(t.path))}getByPath(t){for(const r of new Set([t,this.writeForm(t)])){const s=this.db.prepare("SELECT * FROM libraries WHERE path = ?").get(r);if(s)return this.resolveRow(a(s))}}getById(t){const r=this.db.prepare("SELECT * FROM libraries WHERE id = ?").get(t);return r?this.resolveRow(a(r)):void 0}list(){return this.db.prepare("SELECT * FROM libraries ORDER BY added_at DESC").all().map(t=>this.resolveRow(a(t)))}setPath(t,r){this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(this.writeForm(r),t)}remove(t){this.db.prepare("DELETE FROM libraries WHERE id = ?").run(t)}writeForm(t){return i.isAbsolute(t)&&o(t,this.dataRoot)?d(t,this.dataRoot):t}resolveRow(t){if(!i.isAbsolute(t.path))return{...t,path:n(t,this.dataRoot)};const r=i.resolve(t.path);return o(r,this.dataRoot)?(this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(d(r,this.dataRoot),t.id),{...t,path:r}):t}}function a(e){return{id:Number(e.id),path:String(e.path),kind:e.kind,addedAt:String(e.added_at)}}
@@ -1,16 +1,16 @@
1
- import{randomBytes as E}from"node:crypto";export const ORCH_RUN_RETENTION_DAYS=7,ORCH_RUN_KEEP_PER_ORCH=100;function h(o){let t;try{t=JSON.parse(String(o))}catch{return[]}if(!Array.isArray(t))return[];const e=[];for(const r of t){if(typeof r!="object"||r===null)continue;const n=r;if(typeof n.id!="string"||!n.id)continue;const i={id:n.id,kind:n.kind==="webhook"?"webhook":n.kind==="trigger"?"trigger":"session"};typeof n.webhookToken=="string"&&n.webhookToken&&(i.webhookToken=n.webhookToken),typeof n.url=="string"&&n.url&&(i.url=n.url),typeof n.secret=="string"&&n.secret&&(i.secret=n.secret),n.autoFire===!0&&(i.autoFire=!0),e.push(i)}return e}export function graphDirections(o,t){const e=new Set(t.map(n=>n.to)),r=new Set(t.map(n=>n.from));return{entries:o.filter(n=>!e.has(n.id)),exits:o.filter(n=>!r.has(n.id))}}export function pendingCountsOf(o){const t={};for(const[e,r]of Object.entries(o.pending))r.length>0&&(t[e]=r.length);return t}export function toRunSummary(o){const{state:t,...e}=o;return{...e,pendingCounts:pendingCountsOf(t)}}function d(){return E(18).toString("base64url")}function p(){return{pending:{},events:[]}}export class OrchestrationRepository{db;constructor(t){this.db=t}insert(t){const e=new Date().toISOString(),r=l(this.db,t.nodes,t.edges),n=this.db.prepare(`INSERT INTO orchestrations
1
+ import{randomBytes as f}from"node:crypto";export const ORCH_RUN_RETENTION_DAYS=7,ORCH_RUN_KEEP_PER_ORCH=100;function l(s){let e;try{e=JSON.parse(String(s))}catch{return[]}if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const r=n;if(typeof r.id!="string"||!r.id)continue;const o={id:r.id,kind:r.kind==="webhook"?"webhook":r.kind==="trigger"?"trigger":"session"};typeof r.webhookToken=="string"&&r.webhookToken&&(o.webhookToken=r.webhookToken),typeof r.url=="string"&&r.url&&(o.url=r.url),typeof r.secret=="string"&&r.secret&&(o.secret=r.secret),r.autoFire===!0&&(o.autoFire=!0),t.push(o)}return t}export function graphDirections(s,e){const t=new Set(e.map(r=>r.to)),n=new Set(e.map(r=>r.from));return{entries:s.filter(r=>!t.has(r.id)),exits:s.filter(r=>!n.has(r.id))}}export function pendingCountsOf(s){const e={};for(const[t,n]of Object.entries(s.pending))n.length>0&&(e[t]=n.length);return e}export function toRunSummary(s){const{state:e,...t}=s;return{...t,pendingCounts:pendingCountsOf(e)}}function u(){return f(18).toString("base64url")}function g(){return{pending:{},events:[]}}export class OrchestrationRepository{db;constructor(e){this.db=e}insert(e){const t=new Date().toISOString(),n=p(this.db,e.nodes,e.edges),r=this.db.prepare(`INSERT INTO orchestrations
2
2
  (name, project_id, start_text, nodes, edges, enabled, cron, created_at, updated_at)
3
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(t.name,t.projectId,t.startText,JSON.stringify(r),JSON.stringify(t.edges),t.enabled===!1?0:1,t.cron??null,e,e);return this.getById(Number(n.lastInsertRowid))}getById(t){const e=this.db.prepare("SELECT * FROM orchestrations WHERE id = ?").get(t);return e?u(e):void 0}getByNodeToken(t){for(const e of this.list()){const r=e.nodes.find(n=>n.kind==="webhook"&&n.webhookToken===t);if(r)return{row:e,nodeId:r.id}}}list(){return this.db.prepare("SELECT * FROM orchestrations ORDER BY id").all().map(u)}listByProject(t){return this.db.prepare("SELECT * FROM orchestrations WHERE project_id = ? ORDER BY id").all(t).map(u)}update(t,e){const r=this.getById(t);if(!r)return;const n=l(this.db,e.nodes??r.nodes,e.edges??r.edges);return this.db.prepare(`UPDATE orchestrations
3
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(e.name,e.projectId,e.startText,JSON.stringify(n),JSON.stringify(e.edges),e.enabled===!1?0:1,e.cron??null,t,t);return this.getById(Number(r.lastInsertRowid))}getById(e){const t=this.db.prepare("SELECT * FROM orchestrations WHERE id = ?").get(e);return t?c(t):void 0}getByNodeToken(e){for(const t of this.list()){const n=t.nodes.find(r=>r.kind==="webhook"&&r.webhookToken===e);if(n)return{row:t,nodeId:n.id}}}list(){return this.db.prepare("SELECT * FROM orchestrations ORDER BY id").all().map(c)}listByProject(e){return this.db.prepare("SELECT * FROM orchestrations WHERE project_id = ? ORDER BY id").all(e).map(c)}update(e,t){const n=this.getById(e);if(!n)return;const r=p(this.db,t.nodes??n.nodes,t.edges??n.edges);return this.db.prepare(`UPDATE orchestrations
4
4
  SET name = ?, project_id = ?, start_text = ?, nodes = ?, edges = ?, enabled = ?, cron = ?, updated_at = ?
5
- WHERE id = ?`).run(e.name??r.name,e.projectId??r.projectId,e.startText??r.startText,JSON.stringify(n),JSON.stringify(e.edges??r.edges),e.enabled??r.enabled?1:0,e.cron===void 0?r.cron:e.cron,new Date().toISOString(),t),this.getById(t)}setCronFired(t,e){this.db.prepare("UPDATE orchestrations SET last_cron_at = ? WHERE id = ?").run(e,t)}rotateNodeToken(t,e){const r=this.getById(t);if(!r||!r.nodes.find(a=>a.id===e&&a.kind==="webhook"))return null;const n=this.allTokens();let i=d();for(;n.has(i);)i=d();const s=r.nodes.map(a=>a.id===e?{...a,webhookToken:i}:a);return this.db.prepare("UPDATE orchestrations SET nodes = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(s),new Date().toISOString(),t),i}allTokens(){const t=new Set;for(const e of this.list())for(const r of e.nodes)r.webhookToken&&t.add(r.webhookToken);return t}deleteById(t){return Number(this.db.prepare("DELETE FROM orchestrations WHERE id = ?").run(t).changes)===1}deleteMentioningSession(t){const e=this.list().filter(r=>r.nodes.some(n=>n.kind==="session"&&n.id===t));return this.deleteAll(e)}deleteByProject(t){return this.deleteAll(this.listByProject(t))}deleteAll(t){const e=this.db.prepare("DELETE FROM orchestrations WHERE id = ?");return t.reduce((r,n)=>r+Number(e.run(n.id).changes),0)}}function l(o,t,e){const r=new Set(e.map(i=>i.to)),n=new Set;try{for(const i of o.prepare("SELECT nodes FROM orchestrations").all())for(const s of h(i.nodes))s.webhookToken&&n.add(s.webhookToken)}catch{}return t.map(i=>{if(i.kind!=="webhook"||i.webhookToken||r.has(i.id))return i;let s=d();for(;n.has(s);)s=d();return n.add(s),{...i,webhookToken:s}})}export class OrchestrationRunRepository{db;constructor(t){this.db=t}insert(t){const e=new Date().toISOString(),r=this.db.prepare(`INSERT INTO orchestration_runs
5
+ WHERE id = ?`).run(t.name??n.name,t.projectId??n.projectId,t.startText??n.startText,JSON.stringify(r),JSON.stringify(t.edges??n.edges),t.enabled??n.enabled?1:0,t.cron===void 0?n.cron:t.cron,new Date().toISOString(),e),this.getById(e)}setCronFired(e,t){this.db.prepare("UPDATE orchestrations SET last_cron_at = ? WHERE id = ?").run(t,e)}rotateNodeToken(e,t){const n=this.getById(e);if(!n||!n.nodes.find(a=>a.id===t&&a.kind==="webhook"))return null;const o=this.allTokens();let i=u();for(;o.has(i);)i=u();const d=n.nodes.map(a=>a.id===t?{...a,webhookToken:i}:a);return this.db.prepare("UPDATE orchestrations SET nodes = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(d),new Date().toISOString(),e),i}allTokens(){const e=new Set;for(const t of this.list())for(const n of t.nodes)n.webhookToken&&e.add(n.webhookToken);return e}deleteById(e){return Number(this.db.prepare("DELETE FROM orchestrations WHERE id = ?").run(e).changes)===1}deleteMentioningSession(e){const t=this.list().filter(n=>n.nodes.some(r=>r.kind==="session"&&r.id===e));return this.deleteAll(t)}deleteByProject(e){return this.deleteAll(this.listByProject(e))}deleteAll(e){const t=this.db.prepare("DELETE FROM orchestrations WHERE id = ?");return e.reduce((n,r)=>n+Number(t.run(r.id).changes),0)}}function p(s,e,t){const n=new Set(t.map(o=>o.to)),r=new Set;try{for(const o of s.prepare("SELECT nodes FROM orchestrations").all())for(const i of l(o.nodes))i.webhookToken&&r.add(i.webhookToken)}catch{}return e.map(o=>{if(o.kind!=="webhook"||o.webhookToken||n.has(o.id))return o;let i=u();for(;r.has(i);)i=u();return r.add(i),{...o,webhookToken:i}})}export class OrchestrationRunRepository{db;constructor(e){this.db=e}insert(e){const t=new Date().toISOString(),n=this.db.prepare(`INSERT INTO orchestration_runs
6
6
  (orchestration_id, orchestration_name, project_id, trigger, status, deliveries, state, created_at, updated_at)
7
- VALUES (?, ?, ?, ?, 'running', 0, ?, ?, ?)`).run(t.orchestrationId,t.orchestrationName,t.projectId,t.trigger,JSON.stringify(p()),e,e);return this.getById(Number(r.lastInsertRowid))}getById(t){const e=this.db.prepare("SELECT * FROM orchestration_runs WHERE id = ?").get(t);return e?c(e):void 0}listRunning(){return this.db.prepare("SELECT * FROM orchestration_runs WHERE status = 'running' ORDER BY id").all().map(c)}query(t){const e=Math.min(Math.max(t.limit??30,1),200),r=[],n=[];t.orchestrationId!=null&&(r.push("orchestration_id = ?"),n.push(t.orchestrationId)),t.projectId!=null&&(r.push("project_id = ?"),n.push(t.projectId)),t.status&&(r.push("status = ?"),n.push(t.status)),t.text&&(r.push("orchestration_name LIKE ?"),n.push(`%${t.text}%`)),t.before!=null&&(r.push("id < ?"),n.push(t.before));const i=r.length>0?`WHERE ${r.join(" AND ")}`:"",s=this.db.prepare(`SELECT * FROM orchestration_runs ${i} ORDER BY id DESC LIMIT ?`).all(...n,e+1).map(c),a=s.slice(0,e);return{runs:a,nextBefore:s.length>e?a[a.length-1].id:null}}updateState(t,e,r){return Number(this.db.prepare(`UPDATE orchestration_runs SET state = ?, deliveries = ?, updated_at = ?
8
- WHERE id = ? AND status = 'running'`).run(JSON.stringify(e),r,new Date().toISOString(),t).changes)===1}finish(t,e,r=null,n){const i=new Date().toISOString();return Number(this.db.prepare(`UPDATE orchestration_runs
7
+ VALUES (?, ?, ?, ?, 'running', 0, ?, ?, ?)`).run(e.orchestrationId,e.orchestrationName,e.projectId,e.trigger,JSON.stringify(g()),t,t);return this.getById(Number(n.lastInsertRowid))}getById(e){const t=this.db.prepare("SELECT * FROM orchestration_runs WHERE id = ?").get(e);return t?h(t):void 0}listRunning(){return this.db.prepare("SELECT * FROM orchestration_runs WHERE status = 'running' ORDER BY id").all().map(h)}query(e){const t=Math.min(Math.max(e.limit??30,1),200),n=[],r=[];e.orchestrationId!=null&&(n.push("orchestration_id = ?"),r.push(e.orchestrationId)),e.projectId!=null&&(n.push("project_id = ?"),r.push(e.projectId)),e.status&&(n.push("status = ?"),r.push(e.status)),e.text&&(n.push("orchestration_name LIKE ?"),r.push(`%${e.text}%`)),e.before!=null&&(n.push("id < ?"),r.push(e.before));const o=n.length>0?`WHERE ${n.join(" AND ")}`:"",i=this.db.prepare(`SELECT * FROM orchestration_runs ${o} ORDER BY id DESC LIMIT ?`).all(...r,t+1).map(h),d=i.slice(0,t);return{runs:d,nextBefore:i.length>t?d[d.length-1].id:null}}updateState(e,t,n){return Number(this.db.prepare(`UPDATE orchestration_runs SET state = ?, deliveries = ?, updated_at = ?
8
+ WHERE id = ? AND status = 'running'`).run(JSON.stringify(t),n,new Date().toISOString(),e).changes)===1}finish(e,t,n=null,r){const o=new Date().toISOString();return Number(this.db.prepare(`UPDATE orchestration_runs
9
9
  SET status = ?, error = ?, state = COALESCE(?, state), finished_at = ?, updated_at = ?
10
- WHERE id = ? AND status = 'running'`).run(e,r,n?JSON.stringify(n):null,i,i,t).changes)===1}prune(t=new Date){const e=new Date(t.getTime()-ORCH_RUN_RETENTION_DAYS*864e5).toISOString(),r=Number(this.db.prepare("DELETE FROM orchestration_runs WHERE status <> 'running' AND created_at < ?").run(e).changes),n=Number(this.db.prepare(`DELETE FROM orchestration_runs
10
+ WHERE id = ? AND status = 'running'`).run(t,n,r?JSON.stringify(r):null,o,o,e).changes)===1}prune(e=new Date){const t=new Date(e.getTime()-ORCH_RUN_RETENTION_DAYS*864e5).toISOString(),n=Number(this.db.prepare("DELETE FROM orchestration_runs WHERE status <> 'running' AND created_at < ?").run(t).changes),r=Number(this.db.prepare(`DELETE FROM orchestration_runs
11
11
  WHERE status <> 'running' AND id IN (
12
12
  SELECT id FROM (
13
13
  SELECT id, ROW_NUMBER() OVER (PARTITION BY orchestration_id ORDER BY id DESC) AS rn
14
14
  FROM orchestration_runs
15
15
  ) WHERE rn > ?
16
- )`).run(ORCH_RUN_KEEP_PER_ORCH).changes);return r+n}clear(t,e){const r=[],n=[];t==="finished"&&r.push("status <> 'running'"),e!=null&&(r.push("project_id = ?"),n.push(e));const i=r.length>0?`WHERE ${r.join(" AND ")}`:"";return Number(this.db.prepare(`DELETE FROM orchestration_runs ${i}`).run(...n).changes)}}function u(o){return{id:Number(o.id),name:String(o.name),projectId:Number(o.project_id),startText:String(o.start_text??""),nodes:h(o.nodes),edges:g(o.edges,[]),enabled:Number(o.enabled??1)!==0,cron:o.cron==null?null:String(o.cron),lastCronAt:o.last_cron_at==null?null:String(o.last_cron_at),createdAt:String(o.created_at),updatedAt:String(o.updated_at)}}function c(o){const t=g(o.state,p());return{id:Number(o.id),orchestrationId:Number(o.orchestration_id),orchestrationName:String(o.orchestration_name),projectId:Number(o.project_id),trigger:String(o.trigger),status:String(o.status),deliveries:Number(o.deliveries),state:{pending:t.pending??{},events:t.events??[]},error:o.error==null?null:String(o.error),createdAt:String(o.created_at),finishedAt:o.finished_at==null?null:String(o.finished_at),updatedAt:String(o.updated_at)}}function g(o,t){try{return JSON.parse(String(o))}catch{return t}}
16
+ )`).run(ORCH_RUN_KEEP_PER_ORCH).changes);return n+r}clear(e,t){const n=[],r=[];e==="finished"&&n.push("status <> 'running'"),t!=null&&(n.push("project_id = ?"),r.push(t));const o=n.length>0?`WHERE ${n.join(" AND ")}`:"";return Number(this.db.prepare(`DELETE FROM orchestration_runs ${o}`).run(...r).changes)}}function c(s){return{id:Number(s.id),name:String(s.name),projectId:Number(s.project_id),startText:String(s.start_text??""),nodes:l(s.nodes),edges:E(s.edges,[]),enabled:Number(s.enabled??1)!==0,cron:s.cron==null?null:String(s.cron),lastCronAt:s.last_cron_at==null?null:String(s.last_cron_at),createdAt:String(s.created_at),updatedAt:String(s.updated_at)}}function h(s){const e=E(s.state,g());return{id:Number(s.id),orchestrationId:Number(s.orchestration_id),orchestrationName:String(s.orchestration_name),projectId:Number(s.project_id),trigger:String(s.trigger),status:String(s.status),deliveries:Number(s.deliveries),state:{pending:e.pending??{},events:e.events??[]},error:s.error==null?null:String(s.error),createdAt:String(s.created_at),finishedAt:s.finished_at==null?null:String(s.finished_at),updatedAt:String(s.updated_at)}}function E(s,e){try{return JSON.parse(String(s))}catch{return e}}