@weavecode/weave 0.1.0 → 0.1.1

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 (273) hide show
  1. package/node_modules/@weavecode/cli/dist/cli.js +4 -4
  2. package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
  3. package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
  4. package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
  5. package/node_modules/@weavecode/cli/dist/commands/dashboard.d.ts +0 -2
  6. package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -1
  7. package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
  8. package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
  9. package/node_modules/@weavecode/cli/dist/commands/msg.js +2 -2
  10. package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
  11. package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
  12. package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
  13. package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +5 -3
  14. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +44 -1
  15. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +6 -4
  16. package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
  17. package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
  18. package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +4 -4
  19. package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
  20. package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
  21. package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
  22. package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
  23. package/node_modules/@weavecode/cli/dist/init/helpers-gen.d.ts +4 -0
  24. package/node_modules/@weavecode/cli/dist/init/helpers-gen.js +1 -20
  25. package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
  26. package/node_modules/@weavecode/cli/dist/init/mcp-gen.d.ts +3 -20
  27. package/node_modules/@weavecode/cli/dist/init/mcp-gen.js +1 -1
  28. package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
  29. package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
  30. package/node_modules/@weavecode/cli/dist/init/settings-gen.d.ts +3 -30
  31. package/node_modules/@weavecode/cli/dist/init/settings-gen.js +1 -1
  32. package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
  33. package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
  34. package/node_modules/@weavecode/cli/dist/parser.js +1 -1
  35. package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
  36. package/node_modules/@weavecode/cli/dist/statusline/mock-input.js +1 -1
  37. package/node_modules/@weavecode/cli/dist/statusline/preview.js +2 -2
  38. package/node_modules/@weavecode/cli/package.json +5 -5
  39. package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
  40. package/node_modules/@weavecode/core/dist/harness.d.ts +45 -2
  41. package/node_modules/@weavecode/core/dist/harness.js +1 -1
  42. package/node_modules/@weavecode/core/dist/index.d.ts +1 -1
  43. package/node_modules/@weavecode/core/dist/index.js +1 -1
  44. package/node_modules/@weavecode/core/dist/platform.js +1 -1
  45. package/node_modules/@weavecode/core/dist/terminal.d.ts +28 -4
  46. package/node_modules/@weavecode/core/dist/terminal.js +1 -1
  47. package/node_modules/@weavecode/core/dist/types.d.ts +188 -11
  48. package/node_modules/@weavecode/core/dist/types.js +1 -1
  49. package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
  50. package/node_modules/@weavecode/core/dist/utils/logger.js +1 -1
  51. package/node_modules/@weavecode/core/package.json +1 -1
  52. package/node_modules/@weavecode/harness/dist/claude/assets.js +1 -1
  53. package/node_modules/@weavecode/harness/dist/claude/capture.d.ts +11 -1
  54. package/node_modules/@weavecode/harness/dist/claude/capture.js +5 -5
  55. package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
  56. package/node_modules/@weavecode/harness/dist/claude/event-source.d.ts +1 -1
  57. package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
  58. package/node_modules/@weavecode/harness/dist/claude/helpers-gen.d.ts +5 -0
  59. package/node_modules/@weavecode/harness/dist/claude/helpers-gen.js +20 -0
  60. package/node_modules/@weavecode/harness/dist/claude/index.d.ts +5 -1
  61. package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
  62. package/node_modules/@weavecode/harness/dist/claude/mcp-gen.d.ts +22 -0
  63. package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -0
  64. package/node_modules/@weavecode/harness/dist/claude/messaging.d.ts +11 -2
  65. package/node_modules/@weavecode/harness/dist/claude/messaging.js +4 -1
  66. package/node_modules/@weavecode/harness/dist/claude/model-aliases.d.ts +25 -0
  67. package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -0
  68. package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
  69. package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
  70. package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
  71. package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
  72. package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -1
  73. package/node_modules/@weavecode/harness/dist/claude/settings-gen.d.ts +32 -0
  74. package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -0
  75. package/node_modules/@weavecode/harness/dist/claude/transcript.d.ts +16 -0
  76. package/node_modules/@weavecode/harness/dist/claude/transcript.js +4 -2
  77. package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
  78. package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
  79. package/node_modules/@weavecode/harness/dist/codex/messaging.js +1 -1
  80. package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
  81. package/node_modules/@weavecode/harness/dist/codex/toml.js +9 -9
  82. package/node_modules/@weavecode/harness/dist/driver.d.ts +58 -1
  83. package/node_modules/@weavecode/harness/dist/driver.js +1 -1
  84. package/node_modules/@weavecode/harness/dist/index.d.ts +1 -0
  85. package/node_modules/@weavecode/harness/dist/index.js +1 -1
  86. package/node_modules/@weavecode/harness/dist/init/generated.d.ts +37 -0
  87. package/node_modules/@weavecode/harness/dist/init/generated.js +2 -0
  88. package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
  89. package/node_modules/@weavecode/harness/dist/registry-wiring.d.ts +3 -1
  90. package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
  91. package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
  92. package/node_modules/@weavecode/harness/package.json +2 -2
  93. package/node_modules/@weavecode/server/dist/daemon/ai-config.js +2 -2
  94. package/node_modules/@weavecode/server/dist/daemon/ai-context.js +6 -6
  95. package/node_modules/@weavecode/server/dist/daemon/ai-routes.js +4 -4
  96. package/node_modules/@weavecode/server/dist/daemon/api-log.d.ts +48 -0
  97. package/node_modules/@weavecode/server/dist/daemon/api-log.js +3 -0
  98. package/node_modules/@weavecode/server/dist/daemon/auth-routes.js +1 -1
  99. package/node_modules/@weavecode/server/dist/daemon/auto-start.js +6 -6
  100. package/node_modules/@weavecode/server/dist/daemon/capture-routes.js +1 -1
  101. package/node_modules/@weavecode/server/dist/daemon/claude-liveness.js +1 -1
  102. package/node_modules/@weavecode/server/dist/daemon/dashboard-auth.js +2 -2
  103. package/node_modules/@weavecode/server/dist/daemon/data-bus.js +1 -1
  104. package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
  105. package/node_modules/@weavecode/server/dist/daemon/fs-browser.js +1 -1
  106. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.d.ts +6 -1
  107. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.js +1 -1
  108. package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
  109. package/node_modules/@weavecode/server/dist/daemon/http.js +1 -1
  110. package/node_modules/@weavecode/server/dist/daemon/opener.d.ts +102 -19
  111. package/node_modules/@weavecode/server/dist/daemon/opener.js +97 -7
  112. package/node_modules/@weavecode/server/dist/daemon/port.js +1 -1
  113. package/node_modules/@weavecode/server/dist/daemon/project-harnesses.js +2 -2
  114. package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.d.ts +4 -3
  115. package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.js +1 -1
  116. package/node_modules/@weavecode/server/dist/daemon/server.d.ts +8 -0
  117. package/node_modules/@weavecode/server/dist/daemon/server.js +6 -6
  118. package/node_modules/@weavecode/server/dist/daemon/session-probe.d.ts +59 -2
  119. package/node_modules/@weavecode/server/dist/daemon/session-probe.js +1 -1
  120. package/node_modules/@weavecode/server/dist/daemon/settings.d.ts +10 -0
  121. package/node_modules/@weavecode/server/dist/daemon/settings.js +2 -2
  122. package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
  123. package/node_modules/@weavecode/server/dist/daemon/state.js +2 -2
  124. package/node_modules/@weavecode/server/dist/daemon/static.js +1 -1
  125. package/node_modules/@weavecode/server/dist/daemon/terminal-topology-refresher.d.ts +4 -1
  126. package/node_modules/@weavecode/server/dist/daemon/tls.js +1 -1
  127. package/node_modules/@weavecode/server/dist/daemon/toolkit-routes.js +1 -1
  128. package/node_modules/@weavecode/server/dist/db/db.js +20 -2
  129. package/node_modules/@weavecode/server/dist/db/paths.d.ts +4 -0
  130. package/node_modules/@weavecode/server/dist/db/paths.js +1 -1
  131. package/node_modules/@weavecode/server/dist/hooks/answer-keys.js +1 -1
  132. package/node_modules/@weavecode/server/dist/hooks/bus.js +1 -1
  133. package/node_modules/@weavecode/server/dist/hooks/dispatcher.js +6 -6
  134. package/node_modules/@weavecode/server/dist/hooks/handlers/webhook.js +1 -1
  135. package/node_modules/@weavecode/server/dist/hooks/headless-runner.js +2 -2
  136. package/node_modules/@weavecode/server/dist/hooks/inbox-socket.d.ts +17 -4
  137. package/node_modules/@weavecode/server/dist/hooks/inbox-socket.js +2 -1
  138. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.d.ts +20 -6
  139. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.js +3 -3
  140. package/node_modules/@weavecode/server/dist/hooks/match.js +1 -1
  141. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.d.ts +171 -13
  142. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +3 -2
  143. package/node_modules/@weavecode/server/dist/hooks/mirror.js +4 -4
  144. package/node_modules/@weavecode/server/dist/hooks/plugin-installer.js +3 -3
  145. package/node_modules/@weavecode/server/dist/hooks/plugin-loader.js +1 -1
  146. package/node_modules/@weavecode/server/dist/hooks/plugin-project-state.js +1 -1
  147. package/node_modules/@weavecode/server/dist/hooks/prompt-flusher.js +1 -1
  148. package/node_modules/@weavecode/server/dist/hooks/promptbox.d.ts +13 -0
  149. package/node_modules/@weavecode/server/dist/hooks/promptbox.js +8 -8
  150. package/node_modules/@weavecode/server/dist/hooks/push-notify.js +2 -2
  151. package/node_modules/@weavecode/server/dist/hooks/question-tracker.d.ts +6 -4
  152. package/node_modules/@weavecode/server/dist/hooks/question-tracker.js +1 -1
  153. package/node_modules/@weavecode/server/dist/hooks/registry.js +1 -1
  154. package/node_modules/@weavecode/server/dist/hooks/resume-runner.js +1 -1
  155. package/node_modules/@weavecode/server/dist/hooks/sequence-engine.js +1 -1
  156. package/node_modules/@weavecode/server/dist/hooks/session-purge.d.ts +4 -0
  157. package/node_modules/@weavecode/server/dist/hooks/session-purge.js +1 -1
  158. package/node_modules/@weavecode/server/dist/hooks/session-sweeper.d.ts +5 -8
  159. package/node_modules/@weavecode/server/dist/hooks/session-sweeper.js +1 -1
  160. package/node_modules/@weavecode/server/dist/hooks/toolkit-scan.js +1 -1
  161. package/node_modules/@weavecode/server/dist/hooks/toolkit.d.ts +8 -0
  162. package/node_modules/@weavecode/server/dist/hooks/toolkit.js +5 -5
  163. package/node_modules/@weavecode/server/dist/hooks/watch-engine.d.ts +7 -0
  164. package/node_modules/@weavecode/server/dist/hooks/watch-engine.js +1 -1
  165. package/node_modules/@weavecode/server/dist/index.d.ts +1 -1
  166. package/node_modules/@weavecode/server/dist/install/apply-update.d.ts +1 -1
  167. package/node_modules/@weavecode/server/dist/install/apply-update.js +1 -1
  168. package/node_modules/@weavecode/server/dist/install/capabilities.js +1 -1
  169. package/node_modules/@weavecode/server/dist/install/codex-toml.js +1 -1
  170. package/node_modules/@weavecode/server/dist/install/file-assets.js +1 -1
  171. package/node_modules/@weavecode/server/dist/install/fingerprint.d.ts +5 -1
  172. package/node_modules/@weavecode/server/dist/install/fingerprint.js +1 -1
  173. package/node_modules/@weavecode/server/dist/install/git-classify.d.ts +30 -0
  174. package/node_modules/@weavecode/server/dist/install/git-classify.js +1 -0
  175. package/node_modules/@weavecode/server/dist/install/global-config.js +2 -2
  176. package/node_modules/@weavecode/server/dist/install/global-file-assets.js +1 -1
  177. package/node_modules/@weavecode/server/dist/install/init-files.d.ts +46 -0
  178. package/node_modules/@weavecode/server/dist/install/init-files.js +2 -0
  179. package/node_modules/@weavecode/server/dist/install/install-ledger.js +1 -1
  180. package/node_modules/@weavecode/server/dist/install/installer.js +3 -3
  181. package/node_modules/@weavecode/server/dist/install/library-index.js +1 -1
  182. package/node_modules/@weavecode/server/dist/install/mcp-rows.js +1 -1
  183. package/node_modules/@weavecode/server/dist/install/plugin-install.js +1 -1
  184. package/node_modules/@weavecode/server/dist/install/plugin-rows.js +1 -1
  185. package/node_modules/@weavecode/server/dist/install/plugin-templates.js +1 -1
  186. package/node_modules/@weavecode/server/dist/install/project-config.d.ts +0 -2
  187. package/node_modules/@weavecode/server/dist/install/project-config.js +2 -2
  188. package/node_modules/@weavecode/server/dist/install/reader.js +1 -1
  189. package/node_modules/@weavecode/server/dist/install/scan-cache.js +1 -1
  190. package/node_modules/@weavecode/server/dist/install/scanner.js +1 -1
  191. package/node_modules/@weavecode/server/dist/install/settings-mcp.js +2 -2
  192. package/node_modules/@weavecode/server/dist/install/updates.d.ts +17 -5
  193. package/node_modules/@weavecode/server/dist/install/updates.js +1 -1
  194. package/node_modules/@weavecode/server/dist/market/builtin.js +1 -1
  195. package/node_modules/@weavecode/server/dist/market/identity.js +1 -1
  196. package/node_modules/@weavecode/server/dist/market/import.js +2 -2
  197. package/node_modules/@weavecode/server/dist/market/refresh.js +1 -1
  198. package/node_modules/@weavecode/server/dist/market/resolve.js +1 -1
  199. package/node_modules/@weavecode/server/dist/market/updates.js +1 -1
  200. package/node_modules/@weavecode/server/dist/registry.js +2 -2
  201. package/node_modules/@weavecode/server/dist/repositories/hook-dispatches.js +5 -5
  202. package/node_modules/@weavecode/server/dist/repositories/hook-events.js +2 -2
  203. package/node_modules/@weavecode/server/dist/repositories/hook-rules.js +4 -4
  204. package/node_modules/@weavecode/server/dist/repositories/libraries.js +1 -1
  205. package/node_modules/@weavecode/server/dist/repositories/plugin-states.js +1 -1
  206. package/node_modules/@weavecode/server/dist/repositories/projects.d.ts +7 -0
  207. package/node_modules/@weavecode/server/dist/repositories/projects.js +2 -2
  208. package/node_modules/@weavecode/server/dist/repositories/push-subscriptions.js +2 -2
  209. package/node_modules/@weavecode/server/dist/repositories/session-watches.js +4 -4
  210. package/node_modules/@weavecode/server/dist/repositories/sessions.d.ts +17 -4
  211. package/node_modules/@weavecode/server/dist/repositories/sessions.js +2 -2
  212. package/node_modules/@weavecode/server/dist/repositories/uploads.d.ts +66 -0
  213. package/node_modules/@weavecode/server/dist/repositories/uploads.js +7 -0
  214. package/node_modules/@weavecode/server/dist/statusline/cache-sweeper.js +1 -1
  215. package/node_modules/@weavecode/server/dist/statusline/generator.js +81 -40
  216. package/node_modules/@weavecode/server/dist/statusline/manager.d.ts +2 -0
  217. package/node_modules/@weavecode/server/dist/statusline/manager.js +4 -4
  218. package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
  219. package/node_modules/@weavecode/server/dist/watch/cache.js +1 -1
  220. package/node_modules/@weavecode/server/dist/watch/classifier.js +1 -1
  221. package/node_modules/@weavecode/server/dist/watch/plugin-mods.js +1 -1
  222. package/node_modules/@weavecode/server/dist/watch/sync-scheduler.d.ts +8 -4
  223. package/node_modules/@weavecode/server/dist/watch/sync-scheduler.js +1 -1
  224. package/node_modules/@weavecode/server/dist/watch/watch-service.js +1 -1
  225. package/node_modules/@weavecode/server/package.json +4 -4
  226. package/node_modules/@weavecode/server/web/dist/assets/index-D5WFh77i.css +11 -0
  227. package/node_modules/@weavecode/server/web/dist/assets/index-DJibaGnJ.js +585 -0
  228. package/node_modules/@weavecode/server/web/dist/index.html +14 -2
  229. package/node_modules/@weavecode/templates/dist/resources/weave-market/plugins/core-skills/weave-plugin-creator/skills/weave-plugin-creator/SKILL.md +2 -2
  230. package/node_modules/@weavecode/templates/package.json +2 -2
  231. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/README.md +50 -32
  232. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/build/index.d.ts +86 -40
  233. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/build/index.es.js +860 -353
  234. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/build/index.js +860 -353
  235. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-cms/node_modules/asn1js/package.json +20 -17
  236. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/README.md +50 -32
  237. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/build/index.d.ts +86 -40
  238. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/build/index.es.js +860 -353
  239. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/build/index.js +860 -353
  240. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-csr/node_modules/asn1js/package.json +20 -17
  241. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/README.md +50 -32
  242. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/build/index.d.ts +86 -40
  243. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/build/index.es.js +860 -353
  244. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/build/index.js +860 -353
  245. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-ecc/node_modules/asn1js/package.json +20 -17
  246. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/README.md +50 -32
  247. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/build/index.d.ts +86 -40
  248. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/build/index.es.js +860 -353
  249. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/build/index.js +860 -353
  250. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-pkcs9/node_modules/asn1js/package.json +20 -17
  251. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/README.md +50 -32
  252. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/build/index.d.ts +86 -40
  253. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/build/index.es.js +860 -353
  254. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/build/index.js +860 -353
  255. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-rsa/node_modules/asn1js/package.json +20 -17
  256. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/README.md +50 -32
  257. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/build/index.d.ts +86 -40
  258. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/build/index.es.js +860 -353
  259. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/build/index.js +860 -353
  260. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-schema/node_modules/asn1js/package.json +20 -17
  261. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/README.md +50 -32
  262. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/build/index.d.ts +86 -40
  263. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/build/index.es.js +860 -353
  264. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/build/index.js +860 -353
  265. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/@peculiar/asn1-x509/node_modules/asn1js/package.json +20 -17
  266. package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/README.md +50 -32
  267. package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/build/index.d.ts +86 -40
  268. package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/build/index.es.js +860 -353
  269. package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/build/index.js +860 -353
  270. package/node_modules/selfsigned/node_modules/pkijs/node_modules/asn1js/package.json +20 -17
  271. package/package.json +6 -6
  272. package/node_modules/@weavecode/server/web/dist/assets/index-BOzaRlQE.js +0 -560
  273. package/node_modules/@weavecode/server/web/dist/assets/index-ChX8G8cT.css +0 -11
@@ -1,7 +1,7 @@
1
- import a from"node:path";import{readFile as f,writeFile as c,readdir as D,unlink as A}from"node:fs/promises";import{DEFAULT_AGENTS as T,DEFAULT_COMMANDS as O,DEFAULT_HOOKS as F,DEFAULT_MCP as J,DEFAULT_SKILLS as N,ensureDir as m,fileExists as w,logger as p,resolveComponents as b,writeFileIfAbsent as y}from"@weavecode/core";import{templateRegistry as d}from"@weavecode/templates";import{generateStatuslineScript as C,readStatuslineConfig as M,WEAVE_VERSION as L}from"@weavecode/server";import{InitPipeline as P,generateHookHandler as U,readUserCapture as _}from"@weavecode/harness";import{generateSettingsJson as I,mergeSettingsJson as H}from"../settings-gen.js";import{generateMcpJson as R,mergeMcpJson as x}from"../mcp-gen.js";import{generateAutoMemoryHook as K}from"../helpers-gen.js";import{registerPluginTemplates as V,collectPluginMcpServers as W}from"../plugin-templates.js";import{t as l}from"../../i18n/index.js";export const WEAVE_HELPER_MARKER="@version weave@";const G={preToolUse:!1,postToolUse:!1,userPromptSubmit:!1,sessionStart:!1,stop:!1,subagentStop:!1,notification:!1,preCompact:!1,timeout:5e3,continueOnError:!0};export class ClaudeInitTemplate extends P{records={created:{directories:[],files:[]},skipped:[],merged:[],updated:[],removed:[]};st;constructor(s){super(s);const r=a.join(s.targetDir,".claude");this.st={targetDir:s.targetDir,force:s.force,platform:s.platform,components:b(s.preset,s.components),hooks:{...F,...s.hooks},skills:{...N,...s.skills},commands:{...O,...s.commands},agents:{...T,...s.agents},mcp:{...J,...s.mcp},claudeDir:r,skillsDir:a.join(r,"skills"),commandsDir:a.join(r,"commands"),agentsDir:a.join(r,"agents"),helpersDir:a.join(r,"helpers"),...this.records}}ensureDirs(){return q(this.st)}writeSettings(){return z(this.st)}writeMcp(){return B(this.st)}copySkills(){return Q(this.st)}copyCommands(){return X(this.st)}copyAgents(){return Y(this.st)}injectPluginTemplates(){return Z(this.st)}writeHelpers(){return $(this.st)}}async function q(t){await m(t.claudeDir),t.created.directories.push(t.claudeDir),t.components.skills&&(await m(t.skillsDir),t.created.directories.push(t.skillsDir)),t.components.commands&&(await m(t.commandsDir),t.created.directories.push(t.commandsDir)),t.components.agents&&(await m(t.agentsDir),t.created.directories.push(t.agentsDir)),t.components.helpers&&(await m(t.helpersDir),t.created.directories.push(t.helpersDir))}async function z(t){if(t.components.settings){const s=await _({home:t.platform.homeDir}),r=s.installed?G:t.hooks;s.installed&&p.dim(l("init.userCaptureActive"));const o=I({components:t.components,hooks:r,platform:t.platform,helpersDir:t.helpersDir}),e=a.join(t.claudeDir,"settings.json");if(t.force)await c(e,JSON.stringify(o,null,2)+`
2
- `,"utf-8"),t.created.files.push(e);else{const i=await S(e);if(i===void 0)await w(e)?(t.skipped.push(e),p.warn(l("init.skippedInvalidJson",{path:e}))):(await c(e,JSON.stringify(o,null,2)+`
3
- `,"utf-8"),t.created.files.push(e));else{const n=H(i,o);await c(e,JSON.stringify(n,null,2)+`
4
- `,"utf-8"),t.merged.push(e)}}}}async function B(t){if(t.components.mcp){const s=R({platform:t.platform,includeWeaveServer:t.mcp.weave}),r=Object.keys(s.mcpServers),o=await W(t.targetDir,void 0,r),e=s.mcpServers;for(const[i,n]of Object.entries(o.servers))e[i]=n;for(const i of o.renamed)p.warn(l("init.pluginMcpRenamed",{renamed:i}));if(Object.keys(e).length>0){const i=a.join(t.targetDir,".mcp.json");if(t.force)await c(i,JSON.stringify(s,null,2)+`
5
- `,"utf-8"),t.created.files.push(i);else{const n=await S(i);if(n===void 0)await w(i)?(t.skipped.push(i),p.warn(l("init.skippedInvalidJson",{path:i}))):(await c(i,JSON.stringify(s,null,2)+`
6
- `,"utf-8"),t.created.files.push(i));else{const u=x(n,s);await c(i,JSON.stringify(u,null,2)+`
7
- `,"utf-8"),t.merged.push(i)}}}else await w(a.join(t.targetDir,".mcp.json"))&&t.skipped.push(a.join(t.targetDir,".mcp.json"))}}async function Q(t){if(t.components.skills&&t.skills.core){const s=d.getSkillsSourceDir();await h(s,t.skillsDir,t.force,t.created,t.skipped)}}async function X(t){if(t.components.commands&&t.commands.core){const s=d.getCommandsSourceDir();await h(s,t.commandsDir,t.force,t.created,t.skipped)}}async function Y(t){if(t.components.agents&&t.agents.core){const s=d.getAgentsSourceDir();await h(s,t.agentsDir,t.force,t.created,t.skipped)}}async function Z(t){try{const{registered:s}=await V(t.targetDir);for(const r of s){const o=d.resolvePath(r);if(r.category==="skill"){await h(o,a.join(t.skillsDir,a.basename(o)),t.force,t.created,t.skipped);continue}const e=r.category==="command"?t.commandsDir:t.agentsDir,i=a.join(e,a.basename(o));try{const n=await f(o,"utf-8");await y(i,n,t.force)?t.created.files.push(i):t.skipped.push(i)}catch(n){p.warn(l("init.copyTemplatesFailed",{srcDir:o,error:String(n)}))}}}catch(s){p.warn(l("init.copyTemplatesFailed",{srcDir:"plugins",error:String(s)}))}}async function $(t){if(t.components.helpers){const s=await M(t.targetDir),r=[["hook-handler.cjs",U(L)],["statusline.cjs",C(s)],["auto-memory-hook.mjs",K()]];for(const[e,i]of r){const n=a.join(t.helpersDir,e);if(t.force){await c(n,i,"utf-8"),t.created.files.push(n);continue}const u=await k(n);u===null?(await c(n,i,"utf-8"),t.created.files.push(n)):u.includes(WEAVE_HELPER_MARKER)?(await c(n,i,"utf-8"),t.updated.push(n)):t.skipped.push(n)}const o=new Set(r.map(([e])=>e));try{for(const e of await D(t.helpersDir,{withFileTypes:!0})){if(!e.isFile()||o.has(e.name))continue;const i=a.join(t.helpersDir,e.name),n=await k(i);n!==null&&n.includes(WEAVE_HELPER_MARKER)&&(await A(i),t.removed.push(i))}}catch{}}}async function k(t){try{return await f(t,"utf-8")}catch(s){if(j(s))return null;throw s}}async function S(t){let s;try{s=await f(t,"utf-8")}catch(r){if(j(r))return;throw r}try{const r=JSON.parse(s);if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}catch{}}function j(t){return typeof t=="object"&&t!==null&&t.code==="ENOENT"}async function h(t,s,r,o,e){try{const i=await v(t);for(const n of i){const u=a.relative(t,n),g=a.join(s,u),E=await f(n,"utf-8");await y(g,E,r)?o.files.push(g):e.push(g)}}catch(i){p.warn(l("init.copyTemplatesFailed",{srcDir:t,error:String(i)}))}}async function v(t){const s=[];try{const r=await D(t,{withFileTypes:!0});for(const o of r){const e=a.join(t,o.name);o.isDirectory()?s.push(...await v(e)):s.push(e)}}catch{}return s}
1
+ import a from"node:path";import{readFile as d,writeFile as l,readdir as D,unlink as v}from"node:fs/promises";import{DEFAULT_AGENTS as F,DEFAULT_COMMANDS as A,DEFAULT_HOOKS as O,DEFAULT_MCP as C,DEFAULT_SKILLS as J,ensureDir as m,fileExists as w,logger as p,resolveComponents as M,writeFileIfAbsent as y}from"@weavecode/core";import{templateRegistry as g}from"@weavecode/templates";import{generateStatuslineScript as P,readStatuslineConfig as N,WEAVE_VERSION as b}from"@weavecode/server";import{InitPipeline as U,generateHookHandler as _,readUserCapture as R}from"@weavecode/harness";import{generateSettingsJson as I,mergeSettingsJson as L}from"../settings-gen.js";import{generateMcpJson as H,mergeMcpJson as K}from"../mcp-gen.js";import{generateAutoMemoryHook as V}from"../helpers-gen.js";import{registerPluginTemplates as W,collectPluginMcpServers as q}from"../plugin-templates.js";import{t as f}from"../../i18n/index.js";export const WEAVE_HELPER_MARKER="@version weave@";const G={preToolUse:!1,postToolUse:!1,userPromptSubmit:!1,sessionStart:!1,stop:!1,stopFailure:!1,subagentStop:!1,subagentStart:!1,notification:!1,postToolUseFailure:!1,permissionRequest:!1,permissionDenied:!1,preCompact:!1,sessionEnd:!1,preModelSwitch:!1,timeout:5e3,continueOnError:!0};export class ClaudeInitTemplate extends U{records={created:{directories:[],files:[]},skipped:[],merged:[],updated:[],removed:[]};st;constructor(i){super(i);const t=a.join(i.targetDir,".claude");this.st={targetDir:i.targetDir,force:i.force,platform:i.platform,components:M(i.preset,i.components),hooks:{...O,...i.hooks},skills:{...J,...i.skills},commands:{...A,...i.commands},agents:{...F,...i.agents},mcp:{...C,...i.mcp},claudeDir:t,skillsDir:a.join(t,"skills"),commandsDir:a.join(t,"commands"),agentsDir:a.join(t,"agents"),helpersDir:a.join(t,"helpers"),...this.records}}ensureDirs(){return z(this.st)}writeSettings(){return B(this.st)}writeMcp(){return Q(this.st)}copySkills(){return X(this.st)}copyCommands(){return Y(this.st)}copyAgents(){return Z(this.st)}injectPluginTemplates(){return $(this.st)}writeHelpers(){return x(this.st)}}async function z(e){await m(e.claudeDir),e.created.directories.push(e.claudeDir),e.components.skills&&(await m(e.skillsDir),e.created.directories.push(e.skillsDir)),e.components.commands&&(await m(e.commandsDir),e.created.directories.push(e.commandsDir)),e.components.agents&&(await m(e.agentsDir),e.created.directories.push(e.agentsDir)),e.components.helpers&&(await m(e.helpersDir),e.created.directories.push(e.helpersDir))}async function B(e){if(e.components.settings){const i=await R({home:e.platform.homeDir}),t=i.installed?G:e.hooks;i.installed&&p.dim(f("init.userCaptureActive"));const s=I({components:e.components,hooks:t,platform:e.platform,helpersDir:e.helpersDir}),n=a.join(e.claudeDir,"settings.json");if(e.force)await l(n,JSON.stringify(s,null,2)+`
2
+ `,"utf-8"),e.created.files.push(n);else{const o=await k(n);if(o===void 0)await w(n)?(e.skipped.push(n),p.warn(f("init.skippedInvalidJson",{path:n}))):(await l(n,JSON.stringify(s,null,2)+`
3
+ `,"utf-8"),e.created.files.push(n));else{const r=L(o,s);await l(n,JSON.stringify(r,null,2)+`
4
+ `,"utf-8"),e.merged.push(n)}}}}async function Q(e){if(e.components.mcp){const i=H({platform:e.platform,includeWeaveServer:e.mcp.weave}),t=Object.keys(i.mcpServers),s=await q(e.targetDir,void 0,t),n=i.mcpServers;for(const[r,c]of Object.entries(s.servers))n[r]=c;for(const r of s.renamed)p.warn(f("init.pluginMcpRenamed",{renamed:r}));if(Object.keys(n).length>0){const r=a.join(e.targetDir,".mcp.json");if(e.force)await l(r,JSON.stringify(i,null,2)+`
5
+ `,"utf-8"),e.created.files.push(r);else{const c=await k(r);if(c===void 0)await w(r)?(e.skipped.push(r),p.warn(f("init.skippedInvalidJson",{path:r}))):(await l(r,JSON.stringify(i,null,2)+`
6
+ `,"utf-8"),e.created.files.push(r));else{const u=K(c,i);await l(r,JSON.stringify(u,null,2)+`
7
+ `,"utf-8"),e.merged.push(r)}}}else await w(a.join(e.targetDir,".mcp.json"))&&e.skipped.push(a.join(e.targetDir,".mcp.json"))}}async function X(e){if(e.components.skills&&e.skills.core){const i=g.getSkillsSourceDir();await h(i,e.skillsDir,e.force,e.created,e.skipped)}}async function Y(e){if(e.components.commands&&e.commands.core){const i=g.getCommandsSourceDir();await h(i,e.commandsDir,e.force,e.created,e.skipped)}}async function Z(e){if(e.components.agents&&e.agents.core){const i=g.getAgentsSourceDir();await h(i,e.agentsDir,e.force,e.created,e.skipped)}}async function $(e){try{const{registered:i}=await W(e.targetDir);for(const t of i){const s=g.resolvePath(t);if(t.category==="skill"){await h(s,a.join(e.skillsDir,a.basename(s)),e.force,e.created,e.skipped);continue}const n=t.category==="command"?e.commandsDir:e.agentsDir,o=a.join(n,a.basename(s));try{const r=await d(s,"utf-8");await y(o,r,e.force)?e.created.files.push(o):e.skipped.push(o)}catch(r){p.warn(f("init.copyTemplatesFailed",{srcDir:s,error:String(r)}))}}}catch(i){p.warn(f("init.copyTemplatesFailed",{srcDir:"plugins",error:String(i)}))}}async function x(e){if(e.components.helpers){const i=await N(e.targetDir),t=[["hook-handler.cjs",_(b)],["statusline.cjs",P(i)],["auto-memory-hook.mjs",V()]];for(const[n,o]of t){const r=a.join(e.helpersDir,n);if(e.force){await l(r,o,"utf-8"),e.created.files.push(r);continue}const c=await S(r);c===null?(await l(r,o,"utf-8"),e.created.files.push(r)):c.includes(WEAVE_HELPER_MARKER)?(await l(r,o,"utf-8"),e.updated.push(r)):e.skipped.push(r)}const s=new Set(t.map(([n])=>n));try{for(const n of await D(e.helpersDir,{withFileTypes:!0})){if(!n.isFile()||s.has(n.name))continue;const o=a.join(e.helpersDir,n.name),r=await S(o);r!==null&&r.includes(WEAVE_HELPER_MARKER)&&(await v(o),e.removed.push(o))}}catch{}}}async function S(e){try{return await d(e,"utf-8")}catch(i){if(j(i))return null;throw i}}async function k(e){let i;try{i=await d(e,"utf-8")}catch(t){if(j(t))return;throw t}try{const t=JSON.parse(i);if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}catch{}}function j(e){return typeof e=="object"&&e!==null&&e.code==="ENOENT"}async function h(e,i,t,s,n){try{const o=await T(e);for(const r of o){const c=a.relative(e,r),u=a.join(i,c),E=await d(r,"utf-8");await y(u,E,t)?s.files.push(u):n.push(u)}}catch(o){p.warn(f("init.copyTemplatesFailed",{srcDir:e,error:String(o)}))}}async function T(e){const i=[];try{const t=await D(e,{withFileTypes:!0});for(const s of t){const n=a.join(e,s.name);s.isDirectory()?i.push(...await T(n)):i.push(n)}}catch{}return i}
@@ -1 +1 @@
1
- import o from"node:path";import{readdir as m,readFile as k}from"node:fs/promises";import{DEFAULT_SKILLS as f,HARNESS_DIRS as u,ensureDir as n,logger as p,resolveComponents as D,writeFileIfAbsent as w}from"@weavecode/core";import{templateRegistry as y}from"@weavecode/templates";import{InitPipeline as g}from"@weavecode/harness";import{t as a}from"../../i18n/index.js";export class CodexInitTemplate extends g{records={created:{directories:[],files:[]},skipped:[],merged:[],updated:[],removed:[]};force;components;skills;codexDir;skillsDir;constructor(s){super(s);const i=D(s.preset,s.components),e=o.join(s.targetDir,u.codex.projectDir);this.force=s.force,this.components=i,this.skills={...f,...s.skills},this.codexDir=e,this.skillsDir=o.join(e,"skills")}async ensureDirs(){await n(this.codexDir),this.records.created.directories.push(this.codexDir),this.components.skills&&(await n(this.skillsDir),this.records.created.directories.push(this.skillsDir))}writeSettings(){this.skipNoFace("writeSettings")}writeMcp(){this.skipNoFace("writeMcp")}async copySkills(){if(this.components.skills&&this.skills.core){const s=y.getSkillsSourceDir();await F(s,this.skillsDir,this.force,this.records)}}copyCommands(){this.skipNoFace("copyCommands")}copyAgents(){this.skipNoFace("copyAgents")}injectPluginTemplates(){this.skipNoFace("injectPluginTemplates")}writeHelpers(){this.skipNoFace("writeHelpers")}skipNoFace(s){const i=a("init.noPeerFace");this.skip(s,i),p.dim(a("init.stepSkipped",{step:s,reason:i}))}}async function F(t,s,i,e){try{for(const r of await l(t)){const h=o.relative(t,r),c=o.join(s,h),d=await k(r,"utf-8");await w(c,d,i)?e.created.files.push(c):e.skipped.push(c)}}catch(r){p.warn(a("init.copyTemplatesFailed",{srcDir:t,error:String(r)}))}}async function l(t){const s=[];try{const i=await m(t,{withFileTypes:!0});for(const e of i){const r=o.join(t,e.name);e.isDirectory()?s.push(...await l(r)):s.push(r)}}catch{return s}return s}
1
+ import o from"node:path";import{readdir as d,readFile as k}from"node:fs/promises";import{DEFAULT_SKILLS as f,HARNESS_DIRS as u,ensureDir as l,logger as p,resolveComponents as w,writeFileIfAbsent as D}from"@weavecode/core";import{templateRegistry as y}from"@weavecode/templates";import{InitPipeline as F}from"@weavecode/harness";import{t as n}from"../../i18n/index.js";export class CodexInitTemplate extends F{records={created:{directories:[],files:[]},skipped:[],merged:[],updated:[],removed:[]};force;components;skills;codexDir;skillsDir;constructor(e){super(e);const i=w(e.preset,e.components),s=o.join(e.targetDir,u.codex.projectDir);this.force=e.force,this.components=i,this.skills={...f,...e.skills},this.codexDir=s,this.skillsDir=o.join(s,"skills")}async ensureDirs(){await l(this.codexDir),this.records.created.directories.push(this.codexDir),this.components.skills&&(await l(this.skillsDir),this.records.created.directories.push(this.skillsDir))}writeSettings(){this.skipNoFace("writeSettings")}writeMcp(){this.skipNoFace("writeMcp")}async copySkills(){if(this.components.skills&&this.skills.core){const e=y.getSkillsSourceDir();await g(e,this.skillsDir,this.force,this.records)}}copyCommands(){this.skipNoFace("copyCommands")}copyAgents(){this.skipNoFace("copyAgents")}injectPluginTemplates(){this.skipNoFace("injectPluginTemplates")}writeHelpers(){this.skipNoFace("writeHelpers")}skipNoFace(e){const i=n("init.noPeerFace");this.skip(e,i),p.dim(n("init.stepSkipped",{step:e,reason:i}))}}async function g(t,e,i,s){try{for(const r of await a(t)){const h=o.relative(t,r),c=o.join(e,h),m=await k(r,"utf-8");await D(c,m,i)?s.created.files.push(c):s.skipped.push(c)}}catch(r){p.warn(n("init.copyTemplatesFailed",{srcDir:t,error:String(r)}))}}async function a(t){const e=[];try{const i=await d(t,{withFileTypes:!0});for(const s of i){const r=o.join(t,s.name);s.isDirectory()?e.push(...await a(r)):e.push(r)}}catch{return e}return e}
@@ -1 +1,5 @@
1
+ /**
2
+ * 脚本生成器已迁 `@weavecode/harness`(版本号由调用方注入,生成器保持纯字符串)。
3
+ * 这里绑上 cli 自己的 `WEAVE_VERSION`,存量调用点与测试零改动。
4
+ */
1
5
  export declare function generateAutoMemoryHook(): string;
@@ -1,20 +1 @@
1
- import{WEAVE_VERSION as e}from"@weavecode/server";export function generateAutoMemoryHook(){return`#!/usr/bin/env node
2
- /**
3
- * weave auto-memory-hook
4
- * Triggered on UserPromptSubmit to record user context.
5
- * @version weave@${e}
6
- */
7
- 'use strict';
8
-
9
- const chunks = [];
10
- process.stdin.on('data', (c) => chunks.push(c));
11
- process.stdin.on('end', () => {
12
- try {
13
- const input = JSON.parse(Buffer.concat(chunks).toString('utf-8'));
14
- process.stderr.write('[weave] auto-memory: session active\\n');
15
- } catch {
16
- // ignore
17
- }
18
- process.exit(0);
19
- });
20
- `}
1
+ import{generateAutoMemoryHook as o}from"@weavecode/harness";import{WEAVE_VERSION as e}from"@weavecode/server";export function generateAutoMemoryHook(){return o(e)}
@@ -1 +1 @@
1
- import o from"node:path";import{lstat as m,mkdir as p,readFile as u,readlink as b,symlink as g,unlink as f,writeFile as y}from"node:fs/promises";import{INSTRUCTION_FILES as F}from"@weavecode/core";import{t as c}from"../i18n/index.js";const[n,s]=F;async function w(t){try{if((await m(t)).isSymbolicLink()){const a=await b(t);try{return await u(o.resolve(o.dirname(t),a)),{state:"link",target:a}}catch{return{state:"broken-link",target:a}}}return{state:"file"}}catch{return{state:"absent"}}}async function k(t,a,r){const l=o.join(t,a);try{await g(r,l,"file")}catch(e){const i=e.code;throw new Error(c("ilink.linkFailed",{link:a,target:r,path:l,detail:i==="EPERM"||i==="EACCES"||i==="UNKNOWN"?c("ilink.symlinkNotAllowed"):String(e)}))}}async function h(t,a){const r=o.join(t,".weave","backup");await p(r,{recursive:!0});const l=new Date().toISOString().replace(/[:.]/g,"-"),e=o.join(r,`${a}.${l}`);return await y(e,await u(o.join(t,a),"utf-8"),"utf-8"),e}export async function ensureInstructionLink(t,a){const r=o.join(t,n),l=o.join(t,s),e=await w(r),i=await w(l);if(e.state==="link"&&e.target===s&&i.state==="file")return{action:"unchanged",realFile:s};if((i.state==="link"||i.state==="broken-link")&&i.target===n)return{action:"unchanged",realFile:n};if(e.state==="absent"&&i.state==="file")return await k(t,n,s),{action:"adopted",realFile:s};if(i.state==="absent")return(e.state==="link"||e.state==="broken-link")&&await f(r),await k(t,s,n),{action:"created",realFile:n};if(!(a.force||await a.confirm(c("ilink.bothHaveContent"),c("ilink.replaceDetail",{backupDir:".weave/backup/"}))))return{action:"unchanged",realFile:n};const d=i.state==="file"?await h(t,s):void 0;return await f(l),await k(t,s,n),{action:"replaced",realFile:n,backedUpTo:d}}
1
+ import c from"node:path";import{lstat as d,mkdir as h,readFile as k,readlink as b,symlink as g,unlink as f,writeFile as m}from"node:fs/promises";import{INSTRUCTION_FILES as y}from"@weavecode/core";import{t as l}from"../i18n/index.js";const[r,o]=y;async function w(t){try{if((await d(t)).isSymbolicLink()){const a=await b(t);try{return await k(c.resolve(c.dirname(t),a)),{state:"link",target:a}}catch{return{state:"broken-link",target:a}}}return{state:"file"}}catch{return{state:"absent"}}}async function u(t,i,a){const s=c.join(t,i);try{await g(a,s,"file")}catch(e){const n=e.code;throw new Error(l("ilink.linkFailed",{link:i,target:a,path:s,detail:n==="EPERM"||n==="EACCES"||n==="UNKNOWN"?l("ilink.symlinkNotAllowed"):String(e)}))}}async function F(t,i){const a=c.join(t,".weave","backup");await h(a,{recursive:!0});const s=new Date().toISOString().replace(/[:.]/g,"-"),e=c.join(a,`${i}.${s}`);return await m(e,await k(c.join(t,i),"utf-8"),"utf-8"),e}export async function ensureInstructionLink(t,i){const a=c.join(t,r),s=c.join(t,o),e=await w(a),n=await w(s);if(e.state==="link"&&e.target===o&&n.state==="file")return{action:"unchanged",realFile:o};if((n.state==="link"||n.state==="broken-link")&&n.target===r)return{action:"unchanged",realFile:r};if(e.state==="absent"&&n.state==="file")return await u(t,r,o),{action:"adopted",realFile:o};if(n.state==="absent")return(e.state==="link"||e.state==="broken-link")&&await f(a),await u(t,o,r),{action:"created",realFile:r};if(!(i.force?!0:await i.confirm(l("ilink.bothHaveContent"),l("ilink.replaceDetail",{backupDir:".weave/backup/"}))))return{action:"unchanged",realFile:r};const p=n.state==="file"?await F(t,o):void 0;return await f(s),await u(t,o,r),{action:"replaced",realFile:r,backedUpTo:p}}
@@ -1,22 +1,5 @@
1
- import type { PlatformInfo } from '@weavecode/core';
2
- export interface McpGeneratorInput {
3
- platform: PlatformInfo;
4
- /** Whether to include the weave MCP server entry */
5
- includeWeaveServer: boolean;
6
- }
7
- export declare function generateMcpJson(input: McpGeneratorInput): Record<string, unknown>;
8
1
  /**
9
- * Merge weave's generated servers into an existing user .mcp.json.
10
- *
11
- * Policy (weave init never overwrites user files):
12
- * - user-authored server entries and unknown top-level keys are preserved
13
- * - missing weave entries are appended
14
- * - the `weave` server entry is weave's own config key: when present it is
15
- * refreshed to the current generated value
2
+ * .mcp.json 生成器已迁 `@weavecode/harness`(claude 专属表示法,daemon 的 init
3
+ * 文件漂移检测也要用同一份);此处 re-export 保持存量 import 与测试零改动。
16
4
  */
17
- export declare function mergeMcpJson(existing: Record<string, unknown>, generated: Record<string, unknown>): Record<string, unknown>;
18
- /**
19
- * uninstall 用的剥除:删 `weave` 服务键(weave 自己的配置键);mcpServers 清空
20
- * 删键;顶层清空返回空对象,调用方据此删文件。用户自己的服务键不动。
21
- */
22
- export declare function stripWeaveMcp(existing: Record<string, unknown>): Record<string, unknown>;
5
+ export { generateMcpJson, mergeMcpJson, stripWeaveMcp, type McpGeneratorInput } from '@weavecode/harness';
@@ -1 +1 @@
1
- export function generateMcpJson(e){const r={};if(e.includeWeaveServer){const t=e.platform.os==="windows"?"cmd":"npx",c=e.platform.os==="windows"?["/c","npx","weave","mcp","start"]:["weave","mcp","start"];r.weave={command:t,args:c,env:{WEAVE_MCP:"true"}}}return{mcpServers:r}}export function mergeMcpJson(e,r){const t={...e},c=o(r.mcpServers)?r.mcpServers:{},n=o(t.mcpServers)?{...t.mcpServers}:{};for(const[s,p]of Object.entries(c))(s==="weave"||n[s]===void 0)&&(n[s]=p);return t.mcpServers=n,t}function o(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export function stripWeaveMcp(e){const r={...e};if(o(r.mcpServers)){const t={...r.mcpServers};delete t.weave,Object.keys(t).length>0?r.mcpServers=t:delete r.mcpServers}return r}
1
+ export{generateMcpJson,mergeMcpJson,stripWeaveMcp}from"@weavecode/harness";
@@ -1 +1 @@
1
- import o from"node:path";import{readdir as y,readFile as $}from"node:fs/promises";import{detectPlatform as w,WEAVE_PLUGIN_MANIFEST as P,WeavePluginManifestSchema as S}from"@weavecode/core";import{templateRegistry as j}from"@weavecode/templates";async function*g(f,m){const i=[m??o.join(w().configDir,"weave","plugins"),o.join(f,".weave","plugins")];for(const e of i){let s;try{s=await y(e)}catch{continue}for(const r of s){const t=o.join(e,r);let n;try{n=JSON.parse(await $(o.join(t,P),"utf8"))}catch{continue}const c=S.safeParse(n);c.success&&(yield{dir:t,manifest:c.data})}}}export async function registerPluginTemplates(f,m){const i=[],e=[];for await(const{dir:s,manifest:r}of g(f,m)){if(!r.templates)continue;const{id:t,templates:n}=r,c={skills:"skill",commands:"command",agents:"agent"};for(const[a,h]of Object.entries(n)){const l=c[a];if(l)for(const d of h??[]){const u=o.resolve(s,d);if(!u.startsWith(o.resolve(s)+o.sep)){e.push(d);continue}const v=o.basename(u).replace(/\.md$/,""),p={name:`${t}:${v}`,category:l,sourcePath:u,description:`${t} \u63D2\u4EF6\u6A21\u677F`};j.register(p)?i.push(p):e.push(p.name)}}}return{registered:i,skipped:e}}export async function collectPluginMcpServers(f,m,i=[]){const e={},s=[],r=new Set(i);for await(const{manifest:t}of g(f,m))if(t.mcpServers)for(const[n,c]of Object.entries(t.mcpServers)){let a=n;r.has(a)&&(a=`${t.id}-${n}`,s.push(`${n} \u2192 ${a}`)),r.add(a),e[a]=c}return{servers:e,renamed:s}}
1
+ import o from"node:path";import{readdir as v,readFile as w}from"node:fs/promises";import{detectPlatform as P,WEAVE_PLUGIN_MANIFEST as $,WeavePluginManifestSchema as S}from"@weavecode/core";import{templateRegistry as j}from"@weavecode/templates";async function*g(f,m){const a=[m??o.join(P().configDir,"weave","plugins"),o.join(f,".weave","plugins")];for(const e of a){let n;try{n=await v(e)}catch{continue}for(const r of n){const t=o.join(e,r);let s;try{s=JSON.parse(await w(o.join(t,$),"utf8"))}catch{continue}const c=S.safeParse(s);c.success&&(yield{dir:t,manifest:c.data})}}}export async function registerPluginTemplates(f,m){const a=[],e=[];for await(const{dir:n,manifest:r}of g(f,m)){if(!r.templates)continue;const{id:t,templates:s}=r,c={skills:"skill",commands:"command",agents:"agent"};for(const[i,h]of Object.entries(s)){const u=c[i];if(u)for(const d of h??[]){const p=o.resolve(n,d);if(!p.startsWith(o.resolve(n)+o.sep)){e.push(d);continue}const y=o.basename(p).replace(/\.md$/,""),l={name:`${t}:${y}`,category:u,sourcePath:p,description:`${t} \u63D2\u4EF6\u6A21\u677F`};j.register(l)?a.push(l):e.push(l.name)}}}return{registered:a,skipped:e}}export async function collectPluginMcpServers(f,m,a=[]){const e={},n=[],r=new Set(a);for await(const{manifest:t}of g(f,m))if(t.mcpServers)for(const[s,c]of Object.entries(t.mcpServers)){let i=s;r.has(i)&&(i=`${t.id}-${s}`,n.push(`${s} \u2192 ${i}`)),r.add(i),e[i]=c}return{servers:e,renamed:n}}
@@ -1,5 +1,5 @@
1
- import{logger as m}from"@weavecode/core";import{t as u}from"../i18n/index.js";export async function confirmPrompt(i,l,t){if(!t||!process.stdin.isTTY||!process.stdout.isTTY)return!0;const{createInterface:s}=await import("node:readline/promises"),n=s({input:process.stdin,output:process.stdout});try{const r=await n.question(`
2
- ${i}
1
+ import{logger as m}from"@weavecode/core";import{t as c}from"../i18n/index.js";export async function confirmPrompt(o,l,t){if(!t||!process.stdin.isTTY||!process.stdout.isTTY)return!0;const{createInterface:e}=await import("node:readline/promises"),s=e({input:process.stdin,output:process.stdout});try{const i=await s.question(`
2
+ ${o}
3
3
  ${l}
4
- ${u("init.proceed")} `);return!/^n(o)?$/i.test(r.trim())}finally{n.close()}}export function createPromptPort(i){const l=()=>i&&!!process.stdin.isTTY&&!!process.stdout.isTTY;return{confirm:(t,s="")=>confirmPrompt(t,s,i),async multiselect(t,s){if(!l())return[...s];if(t.length===0)return[];const{createInterface:n}=await import("node:readline/promises"),r=n({input:process.stdin,output:process.stdout});try{console.log(`
5
- ${u("init.multiselect.title")}`),t.forEach((e,o)=>console.log(` ${o+1}) ${e}`));const p=(await r.question(` ${u("init.multiselect.hint",{defaults:s.join(",")})} `)).trim();if(!p)return[...s];const c=[],a=[];for(const e of p.split(/[,\s]+/).filter(Boolean)){const o=(/^\d+$/.test(e)?t[Number(e)-1]:void 0)??t.find(f=>f.toLowerCase()===e.toLowerCase());o===void 0?a.push(e):c.includes(o)||c.push(o)}return a.length>0&&m.warn(u("init.multiselect.invalid",{keys:a.join(", ")})),c.length>0?c:[...s]}finally{r.close()}}}}
4
+ ${c("init.proceed")} `);return!/^n(o)?$/i.test(i.trim())}finally{s.close()}}export function createPromptPort(o){const l=()=>o&&!!process.stdin.isTTY&&!!process.stdout.isTTY;return{confirm:(t,e="")=>confirmPrompt(t,e,o),async multiselect(t,e){if(!l())return[...e];if(t.length===0)return[];const{createInterface:s}=await import("node:readline/promises"),i=s({input:process.stdin,output:process.stdout});try{console.log(`
5
+ ${c("init.multiselect.title")}`),t.forEach((n,f)=>console.log(` ${f+1}) ${n}`));const p=(await i.question(` ${c("init.multiselect.hint",{defaults:e.join(",")})} `)).trim();if(!p)return[...e];const r=[],u=[];for(const n of p.split(/[,\s]+/).filter(Boolean)){const a=(/^\d+$/.test(n)?t[Number(n)-1]:void 0)??t.find(d=>d.toLowerCase()===n.toLowerCase());a===void 0?u.push(n):r.includes(a)||r.push(a)}return u.length>0&&m.warn(c("init.multiselect.invalid",{keys:u.join(", ")})),r.length>0?r:[...e]}finally{i.close()}}}}
@@ -1,32 +1,5 @@
1
- import type { InitComponents, HooksConfig, PlatformInfo } from '@weavecode/core';
2
- export interface SettingsGeneratorInput {
3
- components: InitComponents;
4
- hooks: HooksConfig;
5
- platform: PlatformInfo;
6
- /** Absolute path to the helpers directory in the target project */
7
- helpersDir: string;
8
- }
9
- export declare function generateSettingsJson(input: SettingsGeneratorInput): Record<string, unknown>;
10
1
  /**
11
- * Merge weave's generated settings into an existing user settings.json.
12
- *
13
- * Policy (weave init never overwrites user files):
14
- * - every existing key is preserved as-is (including unknown keys)
15
- * - weave entries are appended where missing
16
- * - weave's own hooks entries are REPLACED wholesale by this generation: first
17
- * every group carrying the weave marker is dropped from all events (events
18
- * no longer generated no longer linger), then the generated groups are
19
- * appended. User-authored hook groups are never touched.
20
- * - statusLine pointing at `statusline.cjs` is refreshed in place
21
- * - user-authored statusLine, permissions, and env values are never touched
22
- *
23
- * Idempotent: merging the same `generated` twice yields the same result.
2
+ * settings.json 生成器已迁 `@weavecode/harness`(claude 专属表示法,daemon 的
3
+ * init 文件漂移检测也要用同一份);此处 re-export 保持存量 import 与测试零改动。
24
4
  */
25
- export declare function mergeSettingsJson(existing: Record<string, unknown>, generated: Record<string, unknown>): Record<string, unknown>;
26
- /**
27
- * uninstall 用的剥除:把 merge 的加法原样减回去。weave 的 hook 组、weave 的
28
- * statusLine、weave 写入的默认 permissions/env 条目与 $comment 一并移除;
29
- * 用户自己的键(含 weave 之外的一切)永远不动。返回剩余 settings——键全空
30
- * 时为空对象,调用方据此删文件。
31
- */
32
- export declare function stripWeaveSettings(existing: Record<string, unknown>): Record<string, unknown>;
5
+ export { generateSettingsJson, mergeSettingsJson, stripWeaveSettings, type SettingsGeneratorInput, } from '@weavecode/harness';
@@ -1 +1 @@
1
- import{captureHookGroup as u,sweepWeaveHookEvents as f}from"@weavecode/harness";const S=".claude/helpers/statusline.cjs",d="Generated by weave \u2014 do not edit manually",y=["Bash(npx weave:*)","Bash(pnpm:*)","Bash(npm:*)"],h=["Read(./.env)","Read(./.env.*)","Read(./secrets/*)"];export function generateSettingsJson(o){const{components:t,hooks:e,platform:p,helpersDir:s}=o,a={$comment:d};if(t.helpers){const n={};e.preToolUse&&(n.PreToolUse=u("PreToolUse",s)),e.postToolUse&&(n.PostToolUse=u("PostToolUse",s)),e.userPromptSubmit&&(n.UserPromptSubmit=u("UserPromptSubmit",s)),e.sessionStart&&(n.SessionStart=u("SessionStart",s)),e.stop&&(n.Stop=u("Stop",s)),e.subagentStop&&(n.SubagentStop=u("SubagentStop",s)),e.notification&&(n.Notification=u("Notification",s)),e.preCompact&&(n.PreCompact=u("PreCompact",s)),a.hooks=n}return a.permissions={allow:[...y],deny:[...h]},a.env={WEAVE_ENABLED:"true"},t.helpers&&(a.statusLine={type:"command",command:p.os==="windows"?`node "${s}/statusline.cjs"`:"node "+s+"/statusline.cjs",padding:0,refreshInterval:30}),a}export function mergeSettingsJson(o,t){const e={...o},p=t.hooks;if(p&&typeof p=="object"){const r=f(l(e.hooks)?{...e.hooks}:{})??{};for(const[i,c]of Object.entries(p)){const m=r[i];m===void 0?r[i]=c:Array.isArray(m)&&(r[i]=[...m,...Array.isArray(c)?c:[]])}e.hooks=r}const s=e.statusLine;t.statusLine&&(s===void 0||v(s))&&(e.statusLine=t.statusLine);const a=t.permissions;if(a&&typeof a=="object"){const r=l(e.permissions)?e.permissions:{};for(const i of["allow","deny"]){const c=a[i],m=r[i];Array.isArray(c)?r[i]=b(m,c):m===void 0&&(r[i]=c)}e.permissions=r}const n=t.env;if(n&&typeof n=="object"){const r=l(e.env)?e.env:{};for(const[i,c]of Object.entries(n))r[i]===void 0&&(r[i]=c);e.env=r}return e}function l(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function v(o){if(!l(o))return!1;const t=o.command;return typeof t=="string"&&A(t,S)}function A(o,t){return o.replace(/\\/g,"/").includes(t)}function b(o,t){return Array.isArray(o)?[...o,...t.filter(e=>!o.includes(e))]:[...t]}export function stripWeaveSettings(o){const t={...o};if(l(t.hooks)){const e=f(t.hooks);e?t.hooks=e:delete t.hooks}if(v(t.statusLine)&&delete t.statusLine,l(t.permissions)){const e={...t.permissions},p=(s,a)=>{const n=e[s];if(!Array.isArray(n))return;const r=n.filter(i=>!a.includes(i));r.length>0?e[s]=r:delete e[s]};p("allow",y),p("deny",h),Object.keys(e).length>0?t.permissions=e:delete t.permissions}if(l(t.env)){const e={...t.env};delete e.WEAVE_ENABLED,Object.keys(e).length>0?t.env=e:delete t.env}return t.$comment===d&&delete t.$comment,t}
1
+ export{generateSettingsJson,mergeSettingsJson,stripWeaveSettings}from"@weavecode/harness";
@@ -1,6 +1,6 @@
1
- import s from"node:path";import{lstat as A,readdir as P,readFile as O,rm as T,rmdir as x,unlink as m,writeFile as v}from"node:fs/promises";import{HARNESS_DIRS as R,HARNESS_KEYS as _,INSTRUCTION_FILES as D,logger as M}from"@weavecode/core";import{hashFile as N,projectPackFiles as W,unregisterProject as H}from"@weavecode/server";import{templateRegistry as F}from"@weavecode/templates";import{stripWeaveSettings as B}from"./settings-gen.js";import{stripWeaveMcp as U}from"./mcp-gen.js";import{WEAVE_BLOCK_START as C,WEAVE_BLOCK_END as b,WEAVE_MANAGED_HEADER as L}from"./claudemd-gen.js";import{WEAVE_HELPER_MARKER as K}from"./harnesses/claude.js";import{registerPluginTemplates as V}from"./plugin-templates.js";import{NESTED_GITIGNORE as J}from"./executor.js";import{COMMIT_MESSAGE as q,findGitRepoRoot as z,defaultGitExec as Y}from"./git-commit.js";import{t as $}from"../i18n/index.js";const Q="chore: weave uninstall \u79FB\u9664 init \u751F\u6210\u7269",S=D[1],X=[...D,".mcp.json",..._.map(n=>R[n].projectDir),".weave"];async function p(n){try{return await A(n),!0}catch{return!1}}async function g(n){try{return await O(n,"utf-8")}catch{return null}}async function G(n){const t=await g(n);if(t!==null)try{const i=JSON.parse(t);if(i&&typeof i=="object"&&!Array.isArray(i))return i}catch{}}async function E(n){const t=[];let i;try{i=await P(n,{withFileTypes:!0})}catch{return t}for(const e of i){const a=s.join(n,e.name);e.isDirectory()?t.push(...await E(a)):t.push(a)}return t}async function Z(n,t){const[i,e]=await Promise.all([g(n),g(t)]);return i!==null&&i===e}async function j(n,t,i){let e=n;const a=s.resolve(t);for(;;){if(s.resolve(e)===a||!e.startsWith(a+s.sep))return;try{await x(e),i.push(e)}catch{return}e=s.dirname(e)}}class tt{targetDir;execGit;dbPath;hooksDir;result;constructor(t){this.targetDir=s.resolve(t.targetDir),this.execGit=t.execGit??Y,this.dbPath=t.dbPath,this.hooksDir=t.hooksDir,this.result={status:"ok",removedFiles:[],removedDirs:[],modifiedFiles:[],keptUserFiles:[],git:"no-changes",server:{outcome:"absent"}}}async run(){const t=s.join(this.targetDir,".weave");if(!await p(t))return this.result.status="not-initialized",this.unregisterFromServer(),this.result;const i=await W(this.targetDir),e=await et(t);let a=[];try{a=(await V(this.targetDir)).registered}catch(o){M.warn($("uninstall.pluginScanFailed",{error:String(o)}))}for(const o of _)await this.sweepHarness(o,a);return await this.sweepMcp(),await this.sweepInstructionFiles(e),await this.sweepPackFiles(i),await T(t,{recursive:!0,force:!0}),this.result.removedDirs.push(t),await this.runGit(),this.unregisterFromServer(),this.result}unregisterFromServer(){try{const t=H(this.targetDir,this.dbPath,this.hooksDir);t&&(this.result.server={outcome:"removed",name:t.name,purged:t.purged})}catch(t){this.result.server={outcome:"failed",error:t instanceof Error?t.message:String(t)}}}async sweepHarness(t,i){const e=s.join(this.targetDir,R[t].projectDir);if(!await p(e))return;const a=s.join(e,"helpers");for(const r of await E(a)){const l=await g(r);l!==null&&l.includes(K)?(await m(r),this.result.removedFiles.push(r)):this.result.keptUserFiles.push(r)}const o=[["skills",F.getSkillsSourceDir()],["commands",F.getCommandsSourceDir()],["agents",F.getAgentsSourceDir()]];for(const[r,l]of o)l&&await this.removeTemplateMirrors(s.join(e,r),l);for(const r of i){const l=r.sourcePath;if(r.category==="skill")await this.removeTemplateMirrors(s.join(e,"skills",s.basename(l)),l);else{const d=r.category==="command"?"commands":"agents",w=s.join(e,d,s.basename(l));await this.removeIfSame(w,l)}}const c=s.join(e,"settings.json"),u=await G(c);if(u){const r=B(u);Object.keys(r).length>0?(await v(c,JSON.stringify(r,null,2)+`
2
- `,"utf-8"),this.result.modifiedFiles.push(c)):(await m(c),this.result.removedFiles.push(c))}const h=s.join(e,".gitignore");await g(h)===J&&(await m(h),this.result.removedFiles.push(h));for(const r of["helpers","skills","commands","agents"])await j(s.join(e,r),this.targetDir,this.result.removedDirs);await j(e,this.targetDir,this.result.removedDirs)}async removeTemplateMirrors(t,i){for(const e of await E(i)){const a=s.relative(i,e);await this.removeIfSame(s.join(t,a),e)}}async removeIfSame(t,i){await p(t)&&(await Z(t,i)?(await m(t),this.result.removedFiles.push(t)):this.result.keptUserFiles.push(t))}async sweepMcp(){const t=s.join(this.targetDir,".mcp.json"),i=await G(t);if(!i)return;const e=U(i);Object.keys(e).length>0?(await v(t,JSON.stringify(e,null,2)+`
3
- `,"utf-8"),this.result.modifiedFiles.push(t)):(await m(t),this.result.removedFiles.push(t))}async sweepInstructionFiles(t){for(const i of[...D].reverse()){const e=s.join(this.targetDir,i);let a;try{a=await A(e)}catch{continue}if(a.isSymbolicLink()){await m(e),this.result.removedFiles.push(e);continue}if(!a.isFile())continue;const o=await g(e);if(o===null)continue;if(o.includes(L)){await m(e),this.result.removedFiles.push(e);continue}const c=o.indexOf(C),u=o.indexOf(b);if(c!==-1&&u!==-1&&u>c){const h=(o.slice(0,c)+o.slice(u+b.length)).replace(/\s+$/,"");h===""?(await m(e),this.result.removedFiles.push(e)):(await v(e,h+`
4
- `,"utf-8"),this.result.modifiedFiles.push(e))}}if(t&&!await p(s.join(this.targetDir,S))){const i=await g(t);i!==null&&(await v(s.join(this.targetDir,S),i,"utf-8"),this.result.restoredFromBackup=s.join(this.targetDir,S))}}async sweepPackFiles(t){for(const[e,a]of t){const o=s.resolve(this.targetDir,e);o!==this.targetDir&&!o.startsWith(this.targetDir+s.sep)||(await N(o)===a?(await m(o).catch(()=>{}),this.result.removedFiles.push(o)):await p(o)&&this.result.keptUserFiles.push(o))}const i=[...new Set([...t.keys()].map(e=>s.dirname(s.resolve(this.targetDir,e))))];for(const e of i)await j(e,this.targetDir,this.result.removedDirs)}async git(t){return this.execGit("git",t,{cwd:this.targetDir})}async runGit(){if(!await z(this.targetDir)){this.result.git="skipped-not-repo";return}try{if((await this.git(["diff","--cached","--quiet"])).code!==0){this.result.git="skipped-dirty-index";return}const t=await this.git(["log","-1","--format=%s %H %P"]);if(t.code===0){const[r,l,d]=t.stdout.trimEnd().split(" ");if(r===q&&d){const w=await this.git(["diff-tree","--no-commit-id","--name-only","-r",l]),k=w.code===0?w.stdout.split(`
5
- `).map(f=>f.trim()).filter(Boolean):[],I=f=>X.some(y=>f===y||f===y+"/"||f.startsWith(y+"/"));if(k.length>0&&k.every(I)){const f=await this.git(["reset","--mixed","HEAD~1"]);if(f.code===0){this.result.git="reset",this.result.gitSha=d.slice(0,7);return}this.result.git="failed",this.result.gitError=f.stderr.trim()||"git reset failed";return}}}const i=[...this.result.removedFiles,...this.result.modifiedFiles,...this.result.restoredFromBackup?[this.result.restoredFromBackup]:[],s.join(this.targetDir,".weave")],e=[...new Set(i.map(r=>s.relative(this.targetDir,r).replace(/\\/g,"/")))],a=50,o=new Set;for(let r=0;r<e.length;r+=a){const l=await this.git(["ls-files","--",...e.slice(r,r+a)]);if(l.code!==0){this.result.git="failed",this.result.gitError=l.stderr.trim()||"git ls-files failed";return}for(const d of l.stdout.split(`
6
- `))d.trim()&&o.add(d.trim().replace(/\\/g,"/"))}const c=[...o];if(c.length>0)for(let r=0;r<c.length;r+=a){const l=await this.git(["add","--",...c.slice(r,r+a)]);if(l.code!==0){this.result.git="failed",this.result.gitError=l.stderr.trim()||"git add failed";return}}if((await this.git(["diff","--cached","--quiet"])).code===0){this.result.git="no-changes";return}const u=await this.git(["commit","-m",Q]);if(u.code!==0){this.result.git="failed",this.result.gitError=u.stderr.trim()||"git commit failed";return}const h=await this.git(["rev-parse","--short","HEAD"]);this.result.git="committed",this.result.gitSha=h.code===0?h.stdout.trim():void 0}catch(t){this.result.git="failed",this.result.gitError=t instanceof Error?t.message:String(t)}}}async function et(n){const t=s.join(n,"backup");let i;try{i=await P(t)}catch{return null}const e=i.filter(a=>D.some(o=>a.startsWith(o+"."))).sort();return e.length>0?s.join(t,e[e.length-1]):null}export async function executeUninstall(n){return new tt(n).run()}
1
+ import s from"node:path";import{lstat as T,readdir as _,readFile as G,rm as O,rmdir as W,unlink as m,writeFile as v}from"node:fs/promises";import{HARNESS_DIRS as x,HARNESS_KEYS as N,INSTRUCTION_FILES as S,logger as H}from"@weavecode/core";import{hashFile as C,projectPackFiles as U,unregisterProject as B}from"@weavecode/server";import{templateRegistry as F}from"@weavecode/templates";import{stripWeaveSettings as L}from"./settings-gen.js";import{stripWeaveMcp as V}from"./mcp-gen.js";import{WEAVE_BLOCK_START as J,WEAVE_BLOCK_END as R,WEAVE_MANAGED_HEADER as K}from"./claudemd-gen.js";import{WEAVE_HELPER_MARKER as q}from"./harnesses/claude.js";import{registerPluginTemplates as z}from"./plugin-templates.js";import{NESTED_GITIGNORE as Y}from"./executor.js";import{COMMIT_MESSAGE as $,findGitRepoRoot as Q,defaultGitExec as X}from"./git-commit.js";import{t as Z}from"../i18n/index.js";const tt="chore: weave uninstall \u79FB\u9664 init \u751F\u6210\u7269",k=S[1],et=[...S,".mcp.json",...N.map(n=>x[n].projectDir),".weave"];async function D(n){try{return await T(n),!0}catch{return!1}}async function p(n){try{return await G(n,"utf-8")}catch{return null}}async function b(n){const t=await p(n);if(t!==null)try{const i=JSON.parse(t);if(i&&typeof i=="object"&&!Array.isArray(i))return i}catch{}}async function j(n){const t=[];let i;try{i=await _(n,{withFileTypes:!0})}catch{return t}for(const e of i){const a=s.join(n,e.name);e.isDirectory()?t.push(...await j(a)):t.push(a)}return t}async function it(n,t){const[i,e]=await Promise.all([p(n),p(t)]);return i!==null&&i===e}async function A(n,t,i){let e=n;const a=s.resolve(t);for(;;){if(s.resolve(e)===a||!e.startsWith(a+s.sep))return;try{await W(e),i.push(e)}catch{return}e=s.dirname(e)}}class st{targetDir;execGit;dbPath;hooksDir;result;constructor(t){this.targetDir=s.resolve(t.targetDir),this.execGit=t.execGit??X,this.dbPath=t.dbPath,this.hooksDir=t.hooksDir,this.result={status:"ok",removedFiles:[],removedDirs:[],modifiedFiles:[],keptUserFiles:[],git:"no-changes",server:{outcome:"absent"}}}async run(){const t=s.join(this.targetDir,".weave");if(!await D(t))return this.result.status="not-initialized",this.unregisterFromServer(),this.result;const i=await U(this.targetDir),e=await rt(t);let a=[];try{a=(await z(this.targetDir)).registered}catch(r){H.warn(Z("uninstall.pluginScanFailed",{error:String(r)}))}for(const r of N)await this.sweepHarness(r,a);return await this.sweepMcp(),await this.sweepInstructionFiles(e),await this.sweepPackFiles(i),await O(t,{recursive:!0,force:!0}),this.result.removedDirs.push(t),await this.runGit(),this.unregisterFromServer(),this.result}unregisterFromServer(){try{const t=B(this.targetDir,this.dbPath,this.hooksDir);t&&(this.result.server={outcome:"removed",name:t.name,purged:t.purged})}catch(t){this.result.server={outcome:"failed",error:t instanceof Error?t.message:String(t)}}}async sweepHarness(t,i){const e=s.join(this.targetDir,x[t].projectDir);if(!await D(e))return;const a=s.join(e,"helpers");for(const o of await j(a)){const u=await p(o);u!==null&&u.includes(q)?(await m(o),this.result.removedFiles.push(o)):this.result.keptUserFiles.push(o)}const r=[["skills",F.getSkillsSourceDir()],["commands",F.getCommandsSourceDir()],["agents",F.getAgentsSourceDir()]];for(const[o,u]of r)u&&await this.removeTemplateMirrors(s.join(e,o),u);for(const o of i){const u=o.sourcePath;if(o.category==="skill")await this.removeTemplateMirrors(s.join(e,"skills",s.basename(u)),u);else{const y=o.category==="command"?"commands":"agents",l=s.join(e,y,s.basename(u));await this.removeIfSame(l,u)}}const c=s.join(e,"settings.json"),f=await b(c);if(f){const o=L(f);Object.keys(o).length>0?(await v(c,JSON.stringify(o,null,2)+`
2
+ `,"utf-8"),this.result.modifiedFiles.push(c)):(await m(c),this.result.removedFiles.push(c))}const h=s.join(e,".gitignore");await p(h)===Y&&(await m(h),this.result.removedFiles.push(h));for(const o of["helpers","skills","commands","agents"])await A(s.join(e,o),this.targetDir,this.result.removedDirs);await A(e,this.targetDir,this.result.removedDirs)}async removeTemplateMirrors(t,i){for(const e of await j(i)){const a=s.relative(i,e);await this.removeIfSame(s.join(t,a),e)}}async removeIfSame(t,i){await D(t)&&(await it(t,i)?(await m(t),this.result.removedFiles.push(t)):this.result.keptUserFiles.push(t))}async sweepMcp(){const t=s.join(this.targetDir,".mcp.json"),i=await b(t);if(!i)return;const e=V(i);Object.keys(e).length>0?(await v(t,JSON.stringify(e,null,2)+`
3
+ `,"utf-8"),this.result.modifiedFiles.push(t)):(await m(t),this.result.removedFiles.push(t))}async sweepInstructionFiles(t){for(const i of[...S].reverse()){const e=s.join(this.targetDir,i);let a;try{a=await T(e)}catch{continue}if(a.isSymbolicLink()){await m(e),this.result.removedFiles.push(e);continue}if(!a.isFile())continue;const r=await p(e);if(r===null)continue;if(r.includes(K)){await m(e),this.result.removedFiles.push(e);continue}const c=r.indexOf(J),f=r.indexOf(R);if(c!==-1&&f!==-1&&f>c){const h=(r.slice(0,c)+r.slice(f+R.length)).replace(/\s+$/,"");h===""?(await m(e),this.result.removedFiles.push(e)):(await v(e,h+`
4
+ `,"utf-8"),this.result.modifiedFiles.push(e))}}if(t&&!await D(s.join(this.targetDir,k))){const i=await p(t);i!==null&&(await v(s.join(this.targetDir,k),i,"utf-8"),this.result.restoredFromBackup=s.join(this.targetDir,k))}}async sweepPackFiles(t){for(const[e,a]of t){const r=s.resolve(this.targetDir,e);r!==this.targetDir&&!r.startsWith(this.targetDir+s.sep)||(await C(r)===a?(await m(r).catch(()=>{}),this.result.removedFiles.push(r)):await D(r)&&this.result.keptUserFiles.push(r))}const i=[...new Set([...t.keys()].map(e=>s.dirname(s.resolve(this.targetDir,e))))];for(const e of i)await A(e,this.targetDir,this.result.removedDirs)}async git(t){return this.execGit("git",t,{cwd:this.targetDir})}async runGit(){if(!await Q(this.targetDir)){this.result.git="skipped-not-repo";return}try{if((await this.git(["diff","--cached","--quiet"])).code!==0){this.result.git="skipped-dirty-index";return}const e=await this.git(["log","-1","--format=%s %H %P"]);if(e.code===0){const[l,d,w]=e.stdout.trimEnd().split(" ");if(l===$&&w){const I=await this.git(["diff-tree","--no-commit-id","--name-only","-r",d]),P=I.code===0?I.stdout.split(`
5
+ `).map(g=>g.trim()).filter(Boolean):[],M=g=>et.some(E=>g===E||g===E+"/"||g.startsWith(E+"/"));if(P.length>0&&P.every(M)){const g=await this.git(["reset","--mixed","HEAD~1"]);if(g.code===0){this.result.git="reset",this.result.gitSha=w.slice(0,7);return}this.result.git="failed",this.result.gitError=g.stderr.trim()||"git reset failed";return}}}const a=[...this.result.removedFiles,...this.result.modifiedFiles,...this.result.restoredFromBackup?[this.result.restoredFromBackup]:[],s.join(this.targetDir,".weave")],r=[...new Set(a.map(l=>s.relative(this.targetDir,l).replace(/\\/g,"/")))],c=50,f=new Set;for(let l=0;l<r.length;l+=c){const d=await this.git(["ls-files","--",...r.slice(l,l+c)]);if(d.code!==0){this.result.git="failed",this.result.gitError=d.stderr.trim()||"git ls-files failed";return}for(const w of d.stdout.split(`
6
+ `))w.trim()&&f.add(w.trim().replace(/\\/g,"/"))}const h=[...f];if(h.length>0)for(let l=0;l<h.length;l+=c){const d=await this.git(["add","--",...h.slice(l,l+c)]);if(d.code!==0){this.result.git="failed",this.result.gitError=d.stderr.trim()||"git add failed";return}}if((await this.git(["diff","--cached","--quiet"])).code===0){this.result.git="no-changes";return}const u=await this.git(["commit","-m",tt]);if(u.code!==0){this.result.git="failed",this.result.gitError=u.stderr.trim()||"git commit failed";return}const y=await this.git(["rev-parse","--short","HEAD"]);this.result.git="committed",this.result.gitSha=y.code===0?y.stdout.trim():void 0}catch(i){this.result.git="failed",this.result.gitError=i instanceof Error?i.message:String(i)}}}async function rt(n){const t=s.join(n,"backup");let i;try{i=await _(t)}catch{return null}const e=i.filter(a=>S.some(r=>a.startsWith(r+"."))).sort();return e.length>0?s.join(t,e[e.length-1]):null}export async function executeUninstall(n){return new st(n).run()}
@@ -1 +1 @@
1
- import{HARNESS_DRIVERS as r,createRuntimeRegistry as n}from"@weavecode/harness";import{ClaudeInitTemplate as o}from"./harnesses/claude.js";import{CodexInitTemplate as c}from"./harnesses/codex.js";const s={claude:o,codex:c};export function buildInitRegistry(){const t=n();for(const e of Object.keys(s)){const i=r[e],a={...i,capabilities:i.capabilities.includes("init")?i.capabilities:[...i.capabilities,"init"],init:s[e]};t.unregister(e),t.register(a)}return t}
1
+ import{HARNESS_DRIVERS as o,createRuntimeRegistry as s}from"@weavecode/harness";import{ClaudeInitTemplate as c}from"./harnesses/claude.js";import{CodexInitTemplate as a}from"./harnesses/codex.js";const r={claude:c,codex:a};export function buildInitRegistry(){const t=s();for(const e of Object.keys(r)){const i=o[e],n={...i,capabilities:i.capabilities.includes("init")?i.capabilities:[...i.capabilities,"init"],init:r[e]};t.unregister(e),t.register(n)}return t}
@@ -1 +1 @@
1
- import{t as m}from"./i18n/index.js";export class CommandParser{commands=new Map;globalOptions=[];constructor(){this.initGlobalOptions()}initGlobalOptions(){this.globalOptions=[{name:"help",short:"h",description:"flag.help",type:"boolean",default:!1},{name:"version",short:"V",description:"flag.version",type:"boolean",default:!1},{name:"verbose",short:"v",description:"flag.verbose",type:"boolean",default:!1},{name:"quiet",short:"q",description:"flag.quiet",type:"boolean",default:!1}]}registerCommand(s){if(this.commands.set(s.name,s),s.aliases)for(const t of s.aliases)this.commands.set(t,s)}getCommand(s){return this.commands.get(s)}getAllCommands(){const s=new Set;return Array.from(this.commands.values()).filter(t=>s.has(t)?!1:(s.add(t),!0))}parse(s){const t={command:[],flags:{_:[]},positional:[],raw:[...s]};let o;for(let r=0;r<s.length;r++){const i=s[r];if(i.startsWith("-"))break;if(t.command.length===0&&this.commands.has(i)){o=this.commands.get(i),t.command.push(i);continue}if(t.command.length===1&&o?.subcommands){const l=o.subcommands.find(h=>h.name===i||h.aliases?.includes(i));if(l){o=l,t.command.push(i);continue}}if(t.command.length===2&&o?.subcommands){const l=o.subcommands.find(h=>h.name===i||h.aliases?.includes(i));if(l){o=l,t.command.push(i);continue}}break}const c=this.buildAliases(o),n=this.booleanFlags(o);let a=!0,e=t.command.length;for(;e<s.length;){const r=s[e];if(r==="--"){a=!1,e++;continue}if(a&&r.startsWith("-")){const i=this.parseFlag(s,e,c,n);Object.assign(t.flags,i.flags),e=i.nextIndex;continue}t.positional.push(r),t.flags._.push(r),e++}return this.applyDefaults(t.flags,o),t}validateFlags(s,t){const o=[],c=[...this.globalOptions,...t?.options??[]];for(const n of c){const a=this.normalizeKey(n.name);if(n.required&&s[a]===void 0&&o.push(m("cli.missingRequired",{name:n.name})),n.choices&&s[a]!==void 0){const e=String(s[a]);n.choices.includes(e)||o.push(m("cli.invalidChoice",{name:n.name,value:e,choices:n.choices.join(", ")}))}if(n.validate&&s[a]!==void 0){const e=n.validate(s[a]);e!==!0&&o.push(e)}}return o}getGlobalOptions(){return[...this.globalOptions]}parseFlag(s,t,o,c){const n={},a=s[t];let e=t+1;if(a.startsWith("--")){const r=a.indexOf("=");if(r!==-1){const i=a.slice(2,r);n[this.normalizeKey(i)]=this.parseValue(a.slice(r+1))}else if(a.startsWith("--no-")){const i=a.slice(5);n[this.normalizeKey(i)]=!1}else{const i=a.slice(2),l=this.normalizeKey(i);c.has(l)?e<s.length&&this.isBooleanLiteral(s[e])?(n[l]=s[e].toLowerCase()==="true",e++):n[l]=!0:e<s.length&&this.isFlagValue(s[e])?(n[l]=this.parseValue(s[e]),e++):n[l]=!0}}else if(a.startsWith("-")){const r=a.slice(1);if(r.length===1){const i=o[r]||r,l=this.normalizeKey(i);c.has(l)?e<s.length&&this.isBooleanLiteral(s[e])?(n[l]=s[e].toLowerCase()==="true",e++):n[l]=!0:e<s.length&&this.isFlagValue(s[e])?(n[l]=this.parseValue(s[e]),e++):n[l]=!0}else for(const i of r){const l=o[i]||i;n[this.normalizeKey(l)]=!0}}return{flags:n,nextIndex:e}}isFlagValue(s){return s.startsWith("-")?/^-\d*\.?\d+(?:[eE][+-]?\d+)?$/.test(s):!0}isBooleanLiteral(s){const t=s.toLowerCase();return t==="true"||t==="false"}parseValue(s){if(s.toLowerCase()==="true")return!0;if(s.toLowerCase()==="false")return!1;const t=Number(s);return!isNaN(t)&&s.trim()!==""?t:s}normalizeKey(s){return s.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}buildAliases(s){const t={};for(const o of this.globalOptions)o.short&&(t[o.short]=o.name);if(s?.options)for(const o of s.options)o.short&&(t[o.short]=o.name);return t}booleanFlags(s){const t=new Set;for(const o of this.globalOptions)o.type==="boolean"&&t.add(this.normalizeKey(o.name));if(s?.options)for(const o of s.options)o.type==="boolean"?t.add(this.normalizeKey(o.name)):o.type&&t.delete(this.normalizeKey(o.name));return t}applyDefaults(s,t){const o=[];t?.options&&o.push(t.options),o.push(this.globalOptions);for(const c of o)for(const n of c){const a=this.normalizeKey(n.name);s[a]===void 0&&n.default!==void 0&&(s[a]=n.default)}}}
1
+ import{t as c}from"./i18n/index.js";export class CommandParser{commands=new Map;globalOptions=[];constructor(){this.initGlobalOptions()}initGlobalOptions(){this.globalOptions=[{name:"help",short:"h",description:"flag.help",type:"boolean",default:!1},{name:"version",short:"V",description:"flag.version",type:"boolean",default:!1},{name:"verbose",short:"v",description:"flag.verbose",type:"boolean",default:!1},{name:"quiet",short:"q",description:"flag.quiet",type:"boolean",default:!1}]}registerCommand(e){if(this.commands.set(e.name,e),e.aliases)for(const t of e.aliases)this.commands.set(t,e)}getCommand(e){return this.commands.get(e)}getAllCommands(){const e=new Set;return Array.from(this.commands.values()).filter(t=>e.has(t)?!1:(e.add(t),!0))}parse(e){const t={command:[],flags:{_:[]},positional:[],raw:[...e]};let s;for(let r=0;r<e.length;r++){const i=e[r];if(i.startsWith("-"))break;if(t.command.length===0&&this.commands.has(i)){s=this.commands.get(i),t.command.push(i);continue}if(t.command.length===1&&s?.subcommands){const l=s.subcommands.find(u=>u.name===i||u.aliases?.includes(i));if(l){s=l,t.command.push(i);continue}}if(t.command.length===2&&s?.subcommands){const l=s.subcommands.find(u=>u.name===i||u.aliases?.includes(i));if(l){s=l,t.command.push(i);continue}}break}const f=this.buildAliases(s),n=this.booleanFlags(s);let a=!0,o=t.command.length;for(;o<e.length;){const r=e[o];if(r==="--"){a=!1,o++;continue}if(a&&r.startsWith("-")){const i=this.parseFlag(e,o,f,n);Object.assign(t.flags,i.flags),o=i.nextIndex;continue}t.positional.push(r),t.flags._.push(r),o++}return this.applyDefaults(t.flags,s),t}validateFlags(e,t){const s=[],f=[...this.globalOptions,...t?.options??[]];for(const n of f){const a=this.normalizeKey(n.name);if(n.required&&e[a]===void 0&&s.push(c("cli.missingRequired",{name:n.name})),n.choices&&e[a]!==void 0){const o=String(e[a]);n.choices.includes(o)||s.push(c("cli.invalidChoice",{name:n.name,value:o,choices:n.choices.join(", ")}))}if(n.validate&&e[a]!==void 0){const o=n.validate(e[a]);o!==!0&&s.push(o)}}return s}getGlobalOptions(){return[...this.globalOptions]}parseFlag(e,t,s,f){const n={},a=e[t];let o=t+1;if(a.startsWith("--")){const r=a.indexOf("=");if(r!==-1){const i=a.slice(2,r);n[this.normalizeKey(i)]=this.parseValue(a.slice(r+1))}else if(a.startsWith("--no-")){const i=a.slice(5);n[this.normalizeKey(i)]=!1}else{const i=a.slice(2),l=this.normalizeKey(i);f.has(l)?o<e.length&&this.isBooleanLiteral(e[o])?(n[l]=e[o].toLowerCase()==="true",o++):n[l]=!0:o<e.length&&this.isFlagValue(e[o])?(n[l]=this.parseValue(e[o]),o++):n[l]=!0}}else if(a.startsWith("-")){const r=a.slice(1);if(r.length===1){const i=s[r]||r,l=this.normalizeKey(i);f.has(l)?o<e.length&&this.isBooleanLiteral(e[o])?(n[l]=e[o].toLowerCase()==="true",o++):n[l]=!0:o<e.length&&this.isFlagValue(e[o])?(n[l]=this.parseValue(e[o]),o++):n[l]=!0}else for(const i of r){const l=s[i]||i;n[this.normalizeKey(l)]=!0}}return{flags:n,nextIndex:o}}isFlagValue(e){return e.startsWith("-")?/^-\d*\.?\d+(?:[eE][+-]?\d+)?$/.test(e):!0}isBooleanLiteral(e){const t=e.toLowerCase();return t==="true"||t==="false"}parseValue(e){if(e.toLowerCase()==="true")return!0;if(e.toLowerCase()==="false")return!1;const t=Number(e);return!isNaN(t)&&e.trim()!==""?t:e}normalizeKey(e){return e.replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}buildAliases(e){const t={};for(const s of this.globalOptions)s.short&&(t[s.short]=s.name);if(e?.options)for(const s of e.options)s.short&&(t[s.short]=s.name);return t}booleanFlags(e){const t=new Set;for(const s of this.globalOptions)s.type==="boolean"&&t.add(this.normalizeKey(s.name));if(e?.options)for(const s of e.options)s.type==="boolean"?t.add(this.normalizeKey(s.name)):s.type&&t.delete(this.normalizeKey(s.name));return t}applyDefaults(e,t){const s=[];t?.options&&s.push(t.options),s.push(this.globalOptions);for(const f of s)for(const n of f){const a=this.normalizeKey(n.name);e[a]===void 0&&n.default!==void 0&&(e[a]=n.default)}}}
@@ -1 +1 @@
1
- const m={31:"red",32:"green",33:"yellow",34:"blue",35:"magenta",36:"cyan",90:"gray"},p={41:"red",42:"green",43:"yellow",44:"blue",45:"magenta",46:"cyan",100:"gray"};function h(n,e,o){const t=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${t(n)}${t(e)}${t(o)}`}export function toInkColor(n){const e="ansi256:";return n.startsWith(e)?`ansi256(${n.slice(e.length)})`:n}function b(n,e,o){if(n[e]!==o)return null;if(n[e+1]==="5"&&n[e+2]!==void 0){const t=Number(n[e+2]);return Number.isInteger(t)&&t>=0&&t<=255?{value:`ansi256:${t}`,next:e+3}:null}if(n[e+1]==="2"&&n[e+4]!==void 0){const[t,i,s]=[n[e+2],n[e+3],n[e+4]].map(Number);return[t,i,s].every(u=>Number.isFinite(u))?{value:h(t,i,s),next:e+5}:null}return null}export function parseAnsiSpans(n){const e=[];let o,t="";const i=()=>{o&&o.text&&e.push(o),o=void 0},s=()=>{t&&(e.push({text:t}),t="")},u=()=>(o||(s(),o={text:""}),o),d=n.split(/(\x1b\[[0-9;]*m)/);for(const c of d){const g=/^\x1b\[([0-9;]*)m$/.exec(c);if(!g){c&&(o?o.text+=c:t+=c);continue}const a=g[1].split(";").filter(r=>r!=="");for(let r=0;r<a.length;){const x=b(a,r,"38");if(x){u().color=x.value,r=x.next;continue}const f=b(a,r,"48");if(f){u().backgroundColor=f.value,r=f.next;continue}const l=a[r];l==="0"?i():l==="1"?u().bold=!0:l==="2"?u().dim=!0:m[l]?u().color=m[l]:p[l]&&(u().backgroundColor=p[l]),r++}}return i(),s(),e}export function stripAnsi(n){return n.replace(/\x1b\[[0-9;]*m/g,"")}
1
+ const m={31:"red",32:"green",33:"yellow",34:"blue",35:"magenta",36:"cyan",90:"gray"},p={41:"red",42:"green",43:"yellow",44:"blue",45:"magenta",46:"cyan",100:"gray"};function h(n,t,o){const e=u=>Math.max(0,Math.min(255,Math.round(u))).toString(16).padStart(2,"0");return`#${e(n)}${e(t)}${e(o)}`}export function toInkColor(n){const t="ansi256:";return n.startsWith(t)?`ansi256(${n.slice(t.length)})`:n}function b(n,t,o){if(n[t]!==o)return null;if(n[t+1]==="5"&&n[t+2]!==void 0){const e=Number(n[t+2]);return Number.isInteger(e)&&e>=0&&e<=255?{value:`ansi256:${e}`,next:t+3}:null}if(n[t+1]==="2"&&n[t+4]!==void 0){const[e,u,s]=[n[t+2],n[t+3],n[t+4]].map(Number);return[e,u,s].every(i=>Number.isFinite(i))?{value:h(e,u,s),next:t+5}:null}return null}export function parseAnsiSpans(n){const t=[];let o,e="";const u=()=>{o&&o.text&&t.push(o),o=void 0},s=()=>{e&&(t.push({text:e}),e="")},i=()=>(o||(s(),o={text:""}),o),d=n.split(/(\x1b\[[0-9;]*m)/);for(const c of d){const g=/^\x1b\[([0-9;]*)m$/.exec(c);if(!g){c&&(o?o.text+=c:e+=c);continue}const a=g[1].split(";").filter(r=>r!=="");for(let r=0;r<a.length;){const x=b(a,r,"38");if(x){i().color=x.value,r=x.next;continue}const f=b(a,r,"48");if(f){i().backgroundColor=f.value,r=f.next;continue}const l=a[r];l==="0"?u():l==="1"?i().bold=!0:l==="2"?i().dim=!0:m[l]?i().color=m[l]:p[l]&&(i().backgroundColor=p[l]),r++}}return u(),s(),t}export function stripAnsi(n){return n.replace(/\x1b\[[0-9;]*m/g,"")}
@@ -1,2 +1,2 @@
1
- import{mkdtempSync as _,writeFileSync as r}from"node:fs";import{tmpdir as a}from"node:os";import{join as s}from"node:path";export function writeFixtureTranscript(){const o=_(s(a(),"weave-sl-mock-")),t=s(o,"session.jsonl"),e=(n,i)=>`${JSON.stringify({type:"assistant",uuid:n,message:{id:n,usage:i}})}
1
+ import{mkdtempSync as _,writeFileSync as r}from"node:fs";import{tmpdir as a}from"node:os";import{join as n}from"node:path";export function writeFixtureTranscript(){const o=_(n(a(),"weave-sl-mock-")),t=n(o,"session.jsonl"),e=(s,i)=>`${JSON.stringify({type:"assistant",uuid:s,message:{id:s,usage:i}})}
2
2
  `;return r(t,e("msg_mock_1",{input_tokens:3e5,output_tokens:2e4,cache_read_input_tokens:1e5})+e("msg_mock_1",{input_tokens:3e5,output_tokens:2e4,cache_read_input_tokens:1e5})+e("msg_mock_2",{input_tokens:4e5,output_tokens:3e4,cache_read_input_tokens:110900})),t}export function buildMockInput(o,t=100,e=""){return{session_id:"mock-session",transcript_path:e,model:{display_name:"Fable 5",id:"claude-fable-5"},workspace:{current_dir:o},effort:{level:"high"},context_window:{used_percentage:42,remaining_percentage:58,context_window_size:1e6,total_input_tokens:42e4,total_output_tokens:0},cost:{total_cost_usd:1.234},rate_limits:{five_hour:{used_percentage:33,resets_at:0}},terminal:{columns:t}}}
@@ -1,3 +1,3 @@
1
- import{jsx as i,jsxs as w}from"react/jsx-runtime";import{spawnSync as Y}from"node:child_process";import _ from"node:path";import{useEffect as q,useState as b}from"react";import{render as N,Box as S,Text as a,useInput as U,useApp as X,useStdout as z}from"ink";import{applyStatuslineConfig as Q,generateStatuslineScript as W,readStatuslineConfig as Z,writeGlobalStatuslineConfig as ee}from"@weavecode/server";import{parseAnsiSpans as re,toInkColor as $}from"./ansi.js";import{buildMockInput as ne,writeFixtureTranscript as te}from"./mock-input.js";import{t as c}from"../i18n/index.js";const oe=["gray","red","green","yellow","blue","magenta","cyan"],le=["ansi256:196","ansi256:208","ansi256:39","#f7768e","#7aa2f7","#9ece6a"],x=[...oe,...le];export const COLOR_CYCLE=x;const I=[" \u2502 "," \xB7 "," \u2014 "," ",""],L=["left","center","right"],ie=["percent","bar","both"],A=[{fill:"\u2588",empty:"\u2591"},{fill:"\u25B0",empty:"\u25B1"},{fill:"=",empty:"\xB7"},{fill:"#",empty:"-"}],P=[": "," ",": "," \xBB "],ae={project:["","\u{1F4C1}"],git:["","\u{1F33F}"],git_user:["","\u{1F464}"],changes:["","\u270F\uFE0F"],model:["","\u{1F916}"],thinking:["","\u{1F9E9}"],context:["","\u{1F9E0}"],tokens:["","\u{1F522}"],cost:["","\u{1F4B8}"],rate:["","\u26A1"],time:["","\u{1F552}"]};let j;function ce(){return j===void 0&&(j=te()),j}export function runPreviewLines(e,r,t){const l=W(e).replace(/^#!.*\n/,""),h=JSON.stringify(ne(r,t,ce()));try{const n=Y(process.execPath,["-e",l],{input:h,encoding:"utf8",timeout:15e3,windowsHide:!0});return n.status!==0?{lines:[],error:(n.stderr||c("preview.scriptExit",{status:String(n.status)})).trim()}:{lines:(n.stdout??"").replace(/\r\n/g,`
1
+ import{jsx as i,jsxs as w}from"react/jsx-runtime";import{spawnSync as Y}from"node:child_process";import _ from"node:path";import{useEffect as q,useState as b}from"react";import{render as U,Box as S,Text as a,useInput as V,useApp as X,useStdout as z}from"ink";import{applyStatuslineConfig as Q,generateStatuslineScript as W,readStatuslineConfig as Z,writeGlobalStatuslineConfig as ee}from"@weavecode/server";import{parseAnsiSpans as re,toInkColor as $}from"./ansi.js";import{buildMockInput as ne,writeFixtureTranscript as te}from"./mock-input.js";import{t as c}from"../i18n/index.js";const oe=["gray","red","green","yellow","blue","magenta","cyan"],le=["ansi256:196","ansi256:208","ansi256:39","#f7768e","#7aa2f7","#9ece6a"],x=[...oe,...le];export const COLOR_CYCLE=x;const I=[" \u2502 "," \xB7 "," \u2014 "," ",""],L=["left","center","right"],ie=["percent","bar","both"],A=[{fill:"\u2588",empty:"\u2591"},{fill:"\u25B0",empty:"\u25B1"},{fill:"=",empty:"\xB7"},{fill:"#",empty:"-"}],P=[": "," ",": "," \xBB "],ae={project:["","\u{1F4C1}"],git:["","\u{1F33F}"],git_user:["","\u{1F464}"],changes:["","\u270F\uFE0F"],model:["","\u{1F916}"],thinking:["","\u{1F9E9}"],context:["","\u{1F9E0}"],tokens:["","\u{1F522}"],cost:["","\u{1F4B8}"],rate:["","\u26A1"],time:["","\u{1F552}"]};let j;function ce(){return j===void 0&&(j=te()),j}export function runPreviewLines(e,r,t){const l=W(e).replace(/^#!.*\n/,""),h=JSON.stringify(ne(r,t,ce()));try{const n=Y(process.execPath,["-e",l],{input:h,encoding:"utf8",timeout:15e3,windowsHide:!0});return n.status!==0?{lines:[],error:(n.stderr||c("preview.scriptExit",{status:String(n.status)})).trim()}:{lines:(n.stdout??"").replace(/\r\n/g,`
2
2
  `).split(`
3
- `).filter(v=>v!=="")}}catch(n){return{lines:[],error:String(n)}}}function y(e,r,t){return{...e,segments:{...e.segments,[r]:{...e.segments[r],...t}}}}export function toggleSegment(e,r){return y(e,r,{enabled:!e.segments[r].enabled})}export function cycleSegmentColor(e,r){const t=x.indexOf(e.segments[r].color);return y(e,r,{color:x[(t+1)%x.length]})}export function toggleSegmentBold(e,r){return y(e,r,{bold:!e.segments[r].bold})}export function toggleSegmentMerge(e,r){return y(e,r,{merge:!e.segments[r].merge})}export function cycleSegmentIcon(e,r){const t=ae[r]??[""],l=t.indexOf(e.segments[r].icon);return y(e,r,{icon:t[(l+1)%t.length]})}export function cycleContextStyle(e,r){if(r!=="context")return e;const t=ie,l=t.indexOf(e.segments[r].style??"both");return y(e,r,{style:t[(l+1)%t.length]})}export function cycleAlign(e){const r=L.indexOf(e.align);return{...e,align:L[(r+1)%L.length]}}export function togglePowerline(e){return{...e,powerline:{...e.powerline,enabled:!e.powerline.enabled}}}const k=["\uE0B0","\uE0B2","\uE0B4","\uE0B6"];export function cyclePowerlineGlyph(e){const r=e.powerline.separator??k[0],t=k.indexOf(r),l=k[(t+1)%k.length];return{...e,powerline:{...e.powerline,separator:l}}}export function cycleLogoColor(e){const r=x.indexOf(e.logoColor);return{...e,logoColor:x[(r+1)%x.length]}}export function cycleSeparator(e){const r=I.indexOf(e.separator);return{...e,separator:I[(r+1)%I.length]}}export function bumpRefreshInterval(e,r){return{...e,refreshInterval:Math.max(1,e.refreshInterval+r)}}export function setSegmentField(e,r,t,l){const h=l===""?{[t]:void 0}:{[t]:l};return y(e,r,h)}export function bumpBarCells(e,r){const t=Math.max(1,Math.min(40,e.bar.cells+r));return{...e,bar:{...e.bar,cells:t}}}export function cycleBarGlyph(e){const r=A.findIndex(l=>l.fill===e.bar.fill&&l.empty===e.bar.empty),t=A[(r+1)%A.length];return{...e,bar:{...e.bar,...t}}}export function cycleLabelSeparator(e){const r=P.indexOf(e.labelSeparator);return{...e,labelSeparator:P[(r+1)%P.length]}}export function clampCursor(e,r){const t=e.lines.length,l=Math.min(Math.max(r.row,0),t-1),h=e.lines[l]?.length??0,n=Math.min(Math.max(r.col,0),Math.max(0,h-1));return{row:l,col:n}}export function moveCursor(e,r,t,l){const h=e.lines.length;let n=Math.min(Math.max(r.row+t,0),h-1);for(;n!==r.row&&(e.lines[n]?.length??0)===0;)n-=Math.sign(n-r.row)||1;if((e.lines[n]?.length??0)===0)return r;const v=e.lines[n].length;let g=r.col+l;return g>=v&&(g=v-1),g<0&&(g=0),{row:n,col:g}}function se({line:e}){const r=re(e);return i(a,{children:r.map((t,l)=>i(a,{color:t.color?$(t.color):void 0,backgroundColor:t.backgroundColor?$(t.backgroundColor):void 0,bold:t.bold,dimColor:t.dim,children:t.text},l))})}function ue({segmentKey:e,seg:r,focused:t}){const l=`${r.enabled?"\u25CF":"\u25CB"}${r.icon?r.icon:""}${e}`;return i(a,{color:$(r.enabled?r.color:"gray"),bold:t,inverse:t,dimColor:!r.enabled,children:l})}function fe({initialConfig:e,projectPath:r,initialCursor:t}){const{exit:l}=X(),{stdout:h}=z(),[n,v]=b(e),[g,B]=b(t),[F,D]=b({lines:[]}),[J,T]=b(!1),[G,M]=b(null),[H,R]=b(!1),[m,C]=b(null),O=Math.max(60,h?.columns??100),f=n.lines[g.row]?.[g.col],p=s=>{v(s),T(!0),M(null)};q(()=>{const s=setTimeout(()=>{D(runPreviewLines(n,r,O))},60);return()=>clearTimeout(s)},[n,O,r]),U((s,u)=>{if(!H){if(m){if(u.escape){C(null);return}if(u.return){const{key:o,field:E,buf:K}=m;p(V=>setSegmentField(V,o,E,K)),C(null);return}if(u.backspace||u.delete){C({...m,buf:m.buf.slice(0,-1)});return}s&&!u.ctrl&&!u.meta&&C({...m,buf:m.buf+s});return}if(s==="q"){l();return}if(u.escape){l();return}if(u.upArrow){B(o=>moveCursor(n,o,-1,0));return}if(u.downArrow){B(o=>moveCursor(n,o,1,0));return}if(u.leftArrow){B(o=>moveCursor(n,o,0,-1));return}if(u.rightArrow){B(o=>moveCursor(n,o,0,1));return}if(!u.return){if(s==="B"){p(cycleBarGlyph);return}if(s==="L"){p(cycleLabelSeparator);return}if(s==="["){p(o=>bumpBarCells(o,-1));return}if(s==="]"){p(o=>bumpBarCells(o,1));return}if(f){if(s==="n"){C({key:f,field:"label",buf:n.segments[f].label??""});return}if(s==="f"){C({key:f,field:"format",buf:n.segments[f].format??""});return}switch(s.toLowerCase()){case" ":p(o=>toggleSegment(o,f));return;case"c":p(o=>cycleSegmentColor(o,f));return;case"b":p(o=>toggleSegmentBold(o,f));return;case"m":p(o=>toggleSegmentMerge(o,f));return;case"i":p(o=>cycleSegmentIcon(o,f));return;case"v":p(o=>cycleContextStyle(o,f));return;case"a":p(o=>cycleAlign(o));return;case"p":p(o=>togglePowerline(o));return;case"g":p(o=>cyclePowerlineGlyph(o));return;case"l":p(o=>cycleLogoColor(o));return;case"s":p(o=>cycleSeparator(o));return;case"r":D(runPreviewLines(n,r,O)),M(c("preview.reRendered"));return;case"w":(async()=>{R(!0);try{(n.source??"global")==="global"&&await ee(n),await Q(r,n),T(!1),M(c("preview.saved"))}catch(o){M(c("preview.writeFailed",{error:String(o)}))}finally{R(!1)}})();return;default:break}}}}});const d=f?n.segments[f]:void 0;return w(S,{flexDirection:"column",gap:0,children:[w(S,{children:[i(a,{bold:!0,color:"cyan",children:"weave statusline preview"}),w(a,{dimColor:!0,children:[" \u2014 ",_.basename(r)," "]}),i(a,{dimColor:!0,children:c("preview.headerMeta",{source:n.source??"global",refresh:n.refreshInterval,align:n.align,powerline:n.powerline.enabled?c("preview.on"):c("preview.off")})}),J&&i(a,{color:"yellow",children:c("preview.unsaved")})]}),i(S,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginY:0,children:F.error?i(a,{color:"red",children:c("preview.scriptError",{error:F.error})}):F.lines.length?F.lines.map((s,u)=>i(se,{line:s},u)):i(a,{dimColor:!0,children:c("preview.rendering")})}),w(S,{flexDirection:"column",children:[i(a,{dimColor:!0,children:c("preview.layoutHelp")}),n.lines.map((s,u)=>w(S,{gap:1,children:[i(a,{dimColor:!0,children:c("preview.rowLabel",{row:u+1})}),s.map((o,E)=>i(ue,{segmentKey:o,seg:n.segments[o],focused:g.row===u&&g.col===E},o))]},u))]}),w(S,{flexDirection:"column",gap:0,marginTop:1,children:[m?w(a,{children:[i(a,{bold:!0,color:"yellow",children:` ${m.key}.${m.field} `})," ",i(a,{children:m.buf}),i(a,{inverse:!0,children:" "}),i(a,{dimColor:!0,children:c("preview.editConfirm")})]}):d&&f?w(a,{children:[i(a,{bold:!0,inverse:!0,children:` ${f} `})," ",i(a,{dimColor:!0,children:c("preview.segDetail",{color:d.color,bold:d.bold?c("preview.on"):c("preview.off"),merge:d.merge?c("preview.on"):c("preview.off"),icon:d.icon||"\u2014",style:f==="context"?c("preview.styleSuffix",{style:d.style??"both"}):""})})]}):null,!m&&d&&f&&(d.label||d.format)?w(a,{dimColor:!0,children:[d.label?c("preview.labelValue",{value:`${d.label}${n.labelSeparator}`}):"",d.format?c("preview.formatValue",{value:d.format}):""]}):null,i(a,{dimColor:!0,children:c("preview.barLine",{cells:n.bar.cells,glyphs:`${n.bar.fill}${n.bar.empty}`,labelSep:JSON.stringify(n.labelSeparator)})}),i(a,{dimColor:!0,children:c("preview.keysHelp")}),G&&i(a,{color:"green",children:G}),H&&i(a,{color:"yellow",children:c("preview.writing")})]})]})}export async function runStatuslinePreview(e){const r=await Z(e),t=clampCursor(r,{row:0,col:0});await N(i(fe,{initialConfig:r,projectPath:e,initialCursor:t}),{exitOnCtrlC:!0}).waitUntilExit?.()}
3
+ `).filter(v=>v!=="")}}catch(n){return{lines:[],error:String(n)}}}function y(e,r,t){return{...e,segments:{...e.segments,[r]:{...e.segments[r],...t}}}}export function toggleSegment(e,r){return y(e,r,{enabled:!e.segments[r].enabled})}export function cycleSegmentColor(e,r){const t=x.indexOf(e.segments[r].color);return y(e,r,{color:x[(t+1)%x.length]})}export function toggleSegmentBold(e,r){return y(e,r,{bold:!e.segments[r].bold})}export function toggleSegmentMerge(e,r){return y(e,r,{merge:!e.segments[r].merge})}export function cycleSegmentIcon(e,r){const t=ae[r]??[""],l=t.indexOf(e.segments[r].icon);return y(e,r,{icon:t[(l+1)%t.length]})}export function cycleContextStyle(e,r){if(r!=="context")return e;const t=ie,l=t.indexOf(e.segments[r].style??"both");return y(e,r,{style:t[(l+1)%t.length]})}export function cycleAlign(e){const r=L.indexOf(e.align);return{...e,align:L[(r+1)%L.length]}}export function togglePowerline(e){return{...e,powerline:{...e.powerline,enabled:!e.powerline.enabled}}}const k=["\uE0B0","\uE0B2","\uE0B4","\uE0B6"];export function cyclePowerlineGlyph(e){const r=e.powerline.separator??k[0],t=k.indexOf(r),l=k[(t+1)%k.length];return{...e,powerline:{...e.powerline,separator:l}}}export function cycleLogoColor(e){const r=x.indexOf(e.logoColor);return{...e,logoColor:x[(r+1)%x.length]}}export function cycleSeparator(e){const r=I.indexOf(e.separator);return{...e,separator:I[(r+1)%I.length]}}export function bumpRefreshInterval(e,r){return{...e,refreshInterval:Math.max(1,e.refreshInterval+r)}}export function setSegmentField(e,r,t,l){const h=l===""?{[t]:void 0}:{[t]:l};return y(e,r,h)}export function bumpBarCells(e,r){const t=Math.max(1,Math.min(40,e.bar.cells+r));return{...e,bar:{...e.bar,cells:t}}}export function cycleBarGlyph(e){const r=A.findIndex(l=>l.fill===e.bar.fill&&l.empty===e.bar.empty),t=A[(r+1)%A.length];return{...e,bar:{...e.bar,...t}}}export function cycleLabelSeparator(e){const r=P.indexOf(e.labelSeparator);return{...e,labelSeparator:P[(r+1)%P.length]}}export function clampCursor(e,r){const t=e.lines.length,l=Math.min(Math.max(r.row,0),t-1),h=e.lines[l]?.length??0,n=Math.min(Math.max(r.col,0),Math.max(0,h-1));return{row:l,col:n}}export function moveCursor(e,r,t,l){const h=e.lines.length;let n=Math.min(Math.max(r.row+t,0),h-1);for(;n!==r.row&&(e.lines[n]?.length??0)===0;)n-=Math.sign(n-r.row)||1;if((e.lines[n]?.length??0)===0)return r;const v=e.lines[n].length;let g=r.col+l;return g>=v&&(g=v-1),g<0&&(g=0),{row:n,col:g}}function se({line:e}){const r=re(e);return i(a,{children:r.map((t,l)=>i(a,{color:t.color?$(t.color):void 0,backgroundColor:t.backgroundColor?$(t.backgroundColor):void 0,bold:t.bold,dimColor:t.dim,children:t.text},l))})}function ue({segmentKey:e,seg:r,focused:t}){const l=`${r.enabled?"\u25CF":"\u25CB"}${r.icon?r.icon:""}${e}`;return i(a,{color:$(r.enabled?r.color:"gray"),bold:t,inverse:t,dimColor:!r.enabled,children:l})}function fe({initialConfig:e,projectPath:r,initialCursor:t}){const{exit:l}=X(),{stdout:h}=z(),[n,v]=b(e),[g,B]=b(t),[F,D]=b({lines:[]}),[J,T]=b(!1),[G,M]=b(null),[H,R]=b(!1),[m,C]=b(null),O=Math.max(60,h?.columns??100),f=n.lines[g.row]?.[g.col],p=s=>{v(s),T(!0),M(null)};q(()=>{const s=setTimeout(()=>{D(runPreviewLines(n,r,O))},60);return()=>clearTimeout(s)},[n,O,r]),V((s,u)=>{if(!H){if(m){if(u.escape){C(null);return}if(u.return){const{key:o,field:E,buf:K}=m;p(N=>setSegmentField(N,o,E,K)),C(null);return}if(u.backspace||u.delete){C({...m,buf:m.buf.slice(0,-1)});return}s&&!u.ctrl&&!u.meta&&C({...m,buf:m.buf+s});return}if(s==="q"){l();return}if(u.escape){l();return}if(u.upArrow){B(o=>moveCursor(n,o,-1,0));return}if(u.downArrow){B(o=>moveCursor(n,o,1,0));return}if(u.leftArrow){B(o=>moveCursor(n,o,0,-1));return}if(u.rightArrow){B(o=>moveCursor(n,o,0,1));return}if(!u.return){if(s==="B"){p(cycleBarGlyph);return}if(s==="L"){p(cycleLabelSeparator);return}if(s==="["){p(o=>bumpBarCells(o,-1));return}if(s==="]"){p(o=>bumpBarCells(o,1));return}if(f){if(s==="n"){C({key:f,field:"label",buf:n.segments[f].label??""});return}if(s==="f"){C({key:f,field:"format",buf:n.segments[f].format??""});return}switch(s.toLowerCase()){case" ":p(o=>toggleSegment(o,f));return;case"c":p(o=>cycleSegmentColor(o,f));return;case"b":p(o=>toggleSegmentBold(o,f));return;case"m":p(o=>toggleSegmentMerge(o,f));return;case"i":p(o=>cycleSegmentIcon(o,f));return;case"v":p(o=>cycleContextStyle(o,f));return;case"a":p(o=>cycleAlign(o));return;case"p":p(o=>togglePowerline(o));return;case"g":p(o=>cyclePowerlineGlyph(o));return;case"l":p(o=>cycleLogoColor(o));return;case"s":p(o=>cycleSeparator(o));return;case"r":D(runPreviewLines(n,r,O)),M(c("preview.reRendered"));return;case"w":(async()=>{R(!0);try{(n.source??"global")==="global"&&await ee(n),await Q(r,n),T(!1),M(c("preview.saved"))}catch(o){M(c("preview.writeFailed",{error:String(o)}))}finally{R(!1)}})();return;default:break}}}}});const d=f?n.segments[f]:void 0;return w(S,{flexDirection:"column",gap:0,children:[w(S,{children:[i(a,{bold:!0,color:"cyan",children:"weave statusline preview"}),w(a,{dimColor:!0,children:[" \u2014 ",_.basename(r)," "]}),i(a,{dimColor:!0,children:c("preview.headerMeta",{source:n.source??"global",refresh:n.refreshInterval,align:n.align,powerline:n.powerline.enabled?c("preview.on"):c("preview.off")})}),J&&i(a,{color:"yellow",children:c("preview.unsaved")})]}),i(S,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginY:0,children:F.error?i(a,{color:"red",children:c("preview.scriptError",{error:F.error})}):F.lines.length?F.lines.map((s,u)=>i(se,{line:s},u)):i(a,{dimColor:!0,children:c("preview.rendering")})}),w(S,{flexDirection:"column",children:[i(a,{dimColor:!0,children:c("preview.layoutHelp")}),n.lines.map((s,u)=>w(S,{gap:1,children:[i(a,{dimColor:!0,children:c("preview.rowLabel",{row:u+1})}),s.map((o,E)=>i(ue,{segmentKey:o,seg:n.segments[o],focused:g.row===u&&g.col===E},o))]},u))]}),w(S,{flexDirection:"column",gap:0,marginTop:1,children:[m?w(a,{children:[i(a,{bold:!0,color:"yellow",children:` ${m.key}.${m.field} `})," ",i(a,{children:m.buf}),i(a,{inverse:!0,children:" "}),i(a,{dimColor:!0,children:c("preview.editConfirm")})]}):d&&f?w(a,{children:[i(a,{bold:!0,inverse:!0,children:` ${f} `})," ",i(a,{dimColor:!0,children:c("preview.segDetail",{color:d.color,bold:d.bold?c("preview.on"):c("preview.off"),merge:d.merge?c("preview.on"):c("preview.off"),icon:d.icon||"\u2014",style:f==="context"?c("preview.styleSuffix",{style:d.style??"both"}):""})})]}):null,!m&&d&&f&&(d.label||d.format)?w(a,{dimColor:!0,children:[d.label?c("preview.labelValue",{value:`${d.label}${n.labelSeparator}`}):"",d.format?c("preview.formatValue",{value:d.format}):""]}):null,i(a,{dimColor:!0,children:c("preview.barLine",{cells:n.bar.cells,glyphs:`${n.bar.fill}${n.bar.empty}`,labelSep:JSON.stringify(n.labelSeparator)})}),i(a,{dimColor:!0,children:c("preview.keysHelp")}),G&&i(a,{color:"green",children:G}),H&&i(a,{color:"yellow",children:c("preview.writing")})]})]})}export async function runStatuslinePreview(e){const r=await Z(e),t=clampCursor(r,{row:0,col:0});await U(i(fe,{initialConfig:r,projectPath:e,initialCursor:t}),{exitOnCtrlC:!0}).waitUntilExit?.()}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavecode/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI entry point for weave — parser, commands, and init executor",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,9 +22,9 @@
22
22
  "node": ">=22.5.0"
23
23
  },
24
24
  "dependencies": {
25
- "@weavecode/core": "^0.1.0",
26
- "@weavecode/harness": "^0.1.0",
27
- "@weavecode/server": "^0.1.0",
28
- "@weavecode/templates": "^0.1.0"
25
+ "@weavecode/core": "^0.1.1",
26
+ "@weavecode/harness": "^0.1.1",
27
+ "@weavecode/server": "^0.1.1",
28
+ "@weavecode/templates": "^0.1.1"
29
29
  }
30
30
  }
@@ -1 +1 @@
1
- import i from"node:path";import{lstat as k,readFile as p,readlink as g,access as y}from"node:fs/promises";const c="CLAUDE.md",u="AGENTS.md",d=".claude/helpers/statusline.cjs",w=".claude/settings.json";async function f(n){try{return await y(n),!0}catch{return!1}}async function l(n){try{if(!(await k(n)).isSymbolicLink())return"file";const t=i.resolve(i.dirname(n),await g(n));return await f(t)?"link":"dangling"}catch{return"absent"}}async function j(n){const t=i.join(n,u);if(await l(t)!=="file")return null;const a=(await p(t,"utf-8").catch(()=>"")).trim();return{id:"instruction-link-not-materialised",params:{agents:u,claude:c},ok:a!==c}}async function b(n){const t=await l(i.join(n,c)),a=await l(i.join(n,u));return t==="absent"||a==="absent"?null:{id:"instruction-files-duplicated",params:{claude:c,agents:u},ok:!(t==="file"&&a==="file")}}async function v(n){const t=[];for(const a of[c,u]){const s=await l(i.join(n,a));if(s==="dangling"){t.push({id:"instruction-link-dangling",params:{name:a},ok:!1});break}s==="link"&&t.push({id:"instruction-link-dangling",params:{name:a},ok:!0})}return t}function L(n){const t=/"([^"]+)"/.exec(n);if(t)return t[1];const a=n.trim().split(/\s+/),s=a[a.length-1];return s&&m(s).includes(d)?s:null}function m(n){return n.replace(/\\/g,"/")}async function S(n){const t=i.join(n,w);let a;try{a=JSON.parse(await p(t,"utf-8"))}catch{return[]}const s=a.statusLine;if(!s||typeof s!="object")return[];const r=s.command;if(typeof r!="string"||!m(r).includes(d))return[];const e=L(r);if(!e)return[{id:"statusline-path-unresolved",params:{command:r},ok:!1}];const o=[{id:"statusline-path-unresolved",params:{command:r},ok:!0}],h=i.resolve(n)+i.sep;return i.resolve(e).startsWith(h)?(o.push({id:"statusline-path-foreign",params:{path:e},ok:!0}),o.push({id:"statusline-script-missing",params:{path:e},ok:await f(e)}),o):(o.push({id:"statusline-path-foreign",params:{path:e},ok:!1}),o)}export async function checkHarness(n){const[t,a,s,r]=await Promise.all([j(n),b(n),v(n),S(n)]);return[t,a,...s,...r].filter(e=>e!==null)}
1
+ import a from"node:path";import{lstat as g,readFile as f,readlink as m,access as y}from"node:fs/promises";const o="CLAUDE.md",u="AGENTS.md",p=".claude/helpers/statusline.cjs",w=".claude/settings.json";async function h(t){try{return await y(t),!0}catch{return!1}}async function l(t){try{if(!(await g(t)).isSymbolicLink())return"file";const n=a.resolve(a.dirname(t),await m(t));return await h(n)?"link":"dangling"}catch{return"absent"}}async function S(t){const s=a.join(t,u);if(await l(s)!=="file")return null;const n=(await f(s,"utf-8").catch(()=>"")).trim();return{id:"instruction-link-not-materialised",params:{agents:u,claude:o},ok:n!==o}}async function j(t){const s=await l(a.join(t,o)),n=await l(a.join(t,u));return s==="absent"||n==="absent"?null:{id:"instruction-files-duplicated",params:{claude:o,agents:u},ok:!(s==="file"&&n==="file")}}async function E(t){const s=[];for(const n of[o,u]){const e=await l(a.join(t,n));if(e==="dangling"){s.push({id:"instruction-link-dangling",params:{name:n},ok:!1});break}e==="link"&&s.push({id:"instruction-link-dangling",params:{name:n},ok:!0})}return s}function L(t){const s=/"([^"]+)"/.exec(t);if(s)return s[1];const n=t.trim().split(/\s+/),e=n[n.length-1];return e&&d(e).includes(p)?e:null}function d(t){return t.replace(/\\/g,"/")}async function b(t){const s=a.join(t,w);let n;try{n=JSON.parse(await f(s,"utf-8"))}catch{return[]}const e=n.statusLine;if(!e||typeof e!="object")return[];const r=e.command;if(typeof r!="string"||!d(r).includes(p))return[];const i=L(r);if(!i)return[{id:"statusline-path-unresolved",params:{command:r},ok:!1}];const c=[{id:"statusline-path-unresolved",params:{command:r},ok:!0}],k=a.resolve(t)+a.sep;return a.resolve(i).startsWith(k)?(c.push({id:"statusline-path-foreign",params:{path:i},ok:!0}),c.push({id:"statusline-script-missing",params:{path:i},ok:await h(i)}),c):(c.push({id:"statusline-path-foreign",params:{path:i},ok:!1}),c)}export async function checkHarness(t){const[s,n,e,r]=await Promise.all([S(t),j(t),E(t),b(t)]);return[s,n,...e,...r].filter(i=>i!==null)}
@@ -24,7 +24,7 @@ export declare function isHarness(value: unknown): value is Harness;
24
24
  * 并集会造出非法规则、交集会砍掉独有事件)。规范名为 PascalCase。
25
25
  */
26
26
  export declare const HARNESS_EVENTS: {
27
- claude: readonly ["PreToolUse", "PostToolUse", "UserPromptSubmit", "SessionStart", "Stop", "SubagentStop", "Notification", "PreCompact"];
27
+ claude: readonly ["PreToolUse", "PostToolUse", "UserPromptSubmit", "SessionStart", "Stop", "StopFailure", "SubagentStop", "Notification", "PostToolUseFailure", "PermissionRequest", "PermissionDenied", "SubagentStart", "PreCompact", "SessionEnd", "PreModelSwitch", "PostModelSwitch"];
28
28
  /** Codex 事件待批 2 B0 调研锁定(BACKLOG §10-6);一期不注册(B0 闸门)。 */
29
29
  codex: readonly [];
30
30
  };
@@ -82,8 +82,10 @@ export type InstructionFile = (typeof HARNESS_INSTRUCTION_FILES)[Harness][number
82
82
  export interface HarnessLifecycle {
83
83
  /** 开启一个 turn 组的事件(组头)。 */
84
84
  open: string;
85
- /** 正常关闭组的事件。 */
85
+ /** 关闭组的事件(一轮对话结束,含失败收尾)。 */
86
86
  close: readonly string[];
87
+ /** `close` 里**非正常**收尾的那部分(组头照「未正常结束」标,不冒充正常闭环)。 */
88
+ closeFailed: readonly string[];
87
89
  /** 只作标记的会话级事件(open 组遇之按中断关组,其余不切组)。 */
88
90
  sessionMarkers: readonly string[];
89
91
  /** 组内计数、不独立成组。 */
@@ -93,6 +95,12 @@ export interface HarnessLifecycle {
93
95
  * 此表——谁是问答工具只说一处)。空数组 = 该 harness 无阻塞问答。
94
96
  */
95
97
  questionTools: readonly string[];
98
+ /**
99
+ * 会话退出事件(旁路事实——inbox 凭据 / pane 定位——随进程作废的信号);
100
+ * null = 该 harness 没有这个概念。与 `close` 不同义:`close` 是一轮对话结束,
101
+ * 这个是一整个会话结束。**只覆盖正常退出**(kill / 关窗口不发)。
102
+ */
103
+ sessionExit: string | null;
96
104
  }
97
105
  /**
98
106
  * 任务分组生命周期表(D7)——server/web 分组一律经表参数,
@@ -102,17 +110,21 @@ export declare const HARNESS_LIFECYCLE: {
102
110
  claude: {
103
111
  open: string;
104
112
  close: string[];
113
+ closeFailed: string[];
105
114
  sessionMarkers: string[];
106
115
  subagentStop: string;
107
116
  questionTools: string[];
117
+ sessionExit: string;
108
118
  };
109
119
  /** Codex 事件待批 2 B0 调研锁定(同 HARNESS_EVENTS 闸);空值占位,类型完整。 */
110
120
  codex: {
111
121
  open: string;
112
122
  close: never[];
123
+ closeFailed: never[];
113
124
  sessionMarkers: never[];
114
125
  subagentStop: string;
115
126
  questionTools: never[];
127
+ sessionExit: null;
116
128
  };
117
129
  };
118
130
  /** 压缩信号表的条目形状(谁在压缩、哪些事件是压缩)——压缩差异是 harness 知识。 */
@@ -145,6 +157,37 @@ export declare const HARNESS_COMPACTION: {
145
157
  endSource: null;
146
158
  };
147
159
  };
160
+ /** 会话控制面的条目形状(执行模式切换 / 模型切换)——差异是 harness 知识。 */
161
+ export interface HarnessSessionControl {
162
+ /**
163
+ * 执行模式取值词表(宿主自己的名字,展示原样)。空 = 该 harness 无执行模式
164
+ * 概念、没有切换这回事。**切换是一记键,不按这张表轮转**——宿主自己算下一个
165
+ * 模式(实测还会被计划提案、auto 闸插手),故表只供识别与展示。
166
+ */
167
+ modeNames: readonly string[];
168
+ /**
169
+ * 模型名候选(宿主**别名**,如 claude 的 default/opus/sonnet/haiku/fable)。
170
+ * 只收稳定别名——网关会增删的具体模型 ID 不进表,由用户按 `/model <名字>` 自填
171
+ * (名字形态由服务端验)。空 = 无模型切换概念。
172
+ */
173
+ modelNames: readonly string[];
174
+ }
175
+ /**
176
+ * 会话控制面表——「怎么切执行模式 / 模型」按 harness 声明(web 经
177
+ * tasks/lifecycle.ts 常量镜像);键序与命令形态不在本表(那是服务端投递键序的
178
+ * 事,见 message-deliverer,同 ESC 先例)。全空 = 该 harness 无此概念。
179
+ */
180
+ export declare const HARNESS_SESSION_CONTROL: {
181
+ claude: {
182
+ modeNames: string[];
183
+ modelNames: string[];
184
+ };
185
+ /** Codex 待调研;空值占位,类型完整。 */
186
+ codex: {
187
+ modeNames: never[];
188
+ modelNames: never[];
189
+ };
190
+ };
148
191
  /**
149
192
  * 可选 harness 键序(= 名单表):`--harness` flag 值域与 init 交互多选的
150
193
  * 选项表共用(批 5)。经名单表派生而非 `Object.keys(HARNESS_EVENTS)`——
@@ -1 +1 @@
1
- export const HARNESS_NAMES=["claude","codex"];export function isHarness(e){return typeof e=="string"&&HARNESS_NAMES.includes(e)}export const HARNESS_EVENTS={claude:["PreToolUse","PostToolUse","UserPromptSubmit","SessionStart","Stop","SubagentStop","Notification","PreCompact"],codex:[]},INJECTABLE_EVENTS={claude:["PostToolUse","UserPromptSubmit","SessionStart","Stop","SubagentStop"],codex:[]},TITLE_EFFECTIVE_EVENTS={claude:["SessionStart","UserPromptSubmit"],codex:[]},HARNESS_EVENT_UNION=[...new Set(Object.values(HARNESS_EVENTS).flat())],HARNESS_DIRS={claude:{projectDir:".claude",userDir:".claude"},codex:{projectDir:".codex",userDir:".codex"}},HARNESS_INSTRUCTION_FILES={claude:["CLAUDE.md"],codex:["AGENTS.md"]},HARNESS_LIFECYCLE={claude:{open:"UserPromptSubmit",close:["Stop"],sessionMarkers:["SessionStart","SessionEnd"],subagentStop:"SubagentStop",questionTools:["AskUserQuestion","ExitPlanMode"]},codex:{open:"",close:[],sessionMarkers:[],subagentStop:"",questionTools:[]}},HARNESS_COMPACTION={claude:{start:"PreCompact",end:"SessionStart",endSource:"compact"},codex:{start:null,end:null,endSource:null}},HARNESS_KEYS=HARNESS_NAMES,INSTRUCTION_FILES=[...new Set(HARNESS_KEYS.flatMap(e=>[...HARNESS_INSTRUCTION_FILES[e]]))];
1
+ export const HARNESS_NAMES=["claude","codex"];export function isHarness(e){return typeof e=="string"&&HARNESS_NAMES.includes(e)}export const HARNESS_EVENTS={claude:["PreToolUse","PostToolUse","UserPromptSubmit","SessionStart","Stop","StopFailure","SubagentStop","Notification","PostToolUseFailure","PermissionRequest","PermissionDenied","SubagentStart","PreCompact","SessionEnd","PreModelSwitch","PostModelSwitch"],codex:[]},INJECTABLE_EVENTS={claude:["PostToolUse","UserPromptSubmit","SessionStart","Stop","SubagentStop"],codex:[]},TITLE_EFFECTIVE_EVENTS={claude:["SessionStart","UserPromptSubmit"],codex:[]},HARNESS_EVENT_UNION=[...new Set(Object.values(HARNESS_EVENTS).flat())],HARNESS_DIRS={claude:{projectDir:".claude",userDir:".claude"},codex:{projectDir:".codex",userDir:".codex"}},HARNESS_INSTRUCTION_FILES={claude:["CLAUDE.md"],codex:["AGENTS.md"]},HARNESS_LIFECYCLE={claude:{open:"UserPromptSubmit",close:["Stop","StopFailure"],closeFailed:["StopFailure"],sessionMarkers:["SessionStart","SessionEnd"],subagentStop:"SubagentStop",questionTools:["AskUserQuestion","ExitPlanMode"],sessionExit:"SessionEnd"},codex:{open:"",close:[],closeFailed:[],sessionMarkers:[],subagentStop:"",questionTools:[],sessionExit:null}},HARNESS_COMPACTION={claude:{start:"PreCompact",end:"SessionStart",endSource:"compact"},codex:{start:null,end:null,endSource:null}},HARNESS_SESSION_CONTROL={claude:{modeNames:["default","acceptEdits","plan","auto","dontAsk","bypassPermissions"],modelNames:["default","opus","sonnet","haiku","fable"]},codex:{modeNames:[],modelNames:[]}},HARNESS_KEYS=HARNESS_NAMES,INSTRUCTION_FILES=[...new Set(HARNESS_KEYS.flatMap(e=>[...HARNESS_INSTRUCTION_FILES[e]]))];
@@ -4,7 +4,7 @@ export type { HookRule, HookRuleSource, HookRuleFilter, HookRuleOrigin, HandlerC
4
4
  export { HookRuleSchema, HookRuleSourceSchema, HookRuleFilterSchema, HookRuleOriginSchema, HandlerConfigSchema, HookDispatchStatusSchema, HookDispatchModeSchema, PluginRuleEntrySchema, WeavePluginManifestSchema, WEAVE_PLUGIN_MANIFEST, WEAVE_INJECTION_MARKER, CLAUDE_HOOK_EVENTS, INJECTABLE_HOOK_EVENTS, } from './types.js';
5
5
  export { InitOptionsSchema, PresetSchema, resolveComponents } from './types.js';
6
6
  export { normalizeHookRuleSource, hookSourceHarness } from './types.js';
7
- export { type Harness, type InstructionFile, HARNESS_EVENTS, HARNESS_KEYS, HARNESS_NAMES, HARNESS_EVENT_UNION, HARNESS_INSTRUCTION_FILES, INSTRUCTION_FILES, INJECTABLE_EVENTS, TITLE_EFFECTIVE_EVENTS, HARNESS_DIRS, HARNESS_LIFECYCLE, HARNESS_COMPACTION, type HarnessCompaction, isHarness, } from './harness.js';
7
+ export { type Harness, type InstructionFile, HARNESS_EVENTS, HARNESS_KEYS, HARNESS_NAMES, HARNESS_EVENT_UNION, HARNESS_INSTRUCTION_FILES, INSTRUCTION_FILES, INJECTABLE_EVENTS, TITLE_EFFECTIVE_EVENTS, HARNESS_DIRS, HARNESS_LIFECYCLE, HARNESS_COMPACTION, HARNESS_SESSION_CONTROL, type HarnessCompaction, isHarness, } from './harness.js';
8
8
  export { TERMINAL_LOCATOR_ENV, TERMINAL_LOCATOR_ENV_KEYS } from './terminal.js';
9
9
  export { type ToolScope, type ToolCategory, type EnableOverride, type InstallState, type ToolStateRow, } from './tool.js';
10
10
  export { DEFAULT_COMPONENTS, FULL_COMPONENTS, MINIMAL_COMPONENTS } from './types.js';
@@ -1 +1 @@
1
- export{HookRuleSchema,HookRuleSourceSchema,HookRuleFilterSchema,HookRuleOriginSchema,HandlerConfigSchema,HookDispatchStatusSchema,HookDispatchModeSchema,PluginRuleEntrySchema,WeavePluginManifestSchema,WEAVE_PLUGIN_MANIFEST,WEAVE_INJECTION_MARKER,CLAUDE_HOOK_EVENTS,INJECTABLE_HOOK_EVENTS}from"./types.js";export{InitOptionsSchema,PresetSchema,resolveComponents}from"./types.js";export{normalizeHookRuleSource,hookSourceHarness}from"./types.js";export{HARNESS_EVENTS,HARNESS_KEYS,HARNESS_NAMES,HARNESS_EVENT_UNION,HARNESS_INSTRUCTION_FILES,INSTRUCTION_FILES,INJECTABLE_EVENTS,TITLE_EFFECTIVE_EVENTS,HARNESS_DIRS,HARNESS_LIFECYCLE,HARNESS_COMPACTION,isHarness}from"./harness.js";export{TERMINAL_LOCATOR_ENV,TERMINAL_LOCATOR_ENV_KEYS}from"./terminal.js";export{DEFAULT_COMPONENTS,FULL_COMPONENTS,MINIMAL_COMPONENTS}from"./types.js";export{DEFAULT_HOOKS,DEFAULT_SKILLS,DEFAULT_COMMANDS,DEFAULT_AGENTS,DEFAULT_MCP}from"./types.js";export{detectPlatform}from"./platform.js";export{checkHarness}from"./harness-checks.js";export{ensureDir,writeFileIfAbsent,fileExists}from"./utils/fs.js";export{logger,formatTable}from"./utils/logger.js";
1
+ export{HookRuleSchema,HookRuleSourceSchema,HookRuleFilterSchema,HookRuleOriginSchema,HandlerConfigSchema,HookDispatchStatusSchema,HookDispatchModeSchema,PluginRuleEntrySchema,WeavePluginManifestSchema,WEAVE_PLUGIN_MANIFEST,WEAVE_INJECTION_MARKER,CLAUDE_HOOK_EVENTS,INJECTABLE_HOOK_EVENTS}from"./types.js";export{InitOptionsSchema,PresetSchema,resolveComponents}from"./types.js";export{normalizeHookRuleSource,hookSourceHarness}from"./types.js";export{HARNESS_EVENTS,HARNESS_KEYS,HARNESS_NAMES,HARNESS_EVENT_UNION,HARNESS_INSTRUCTION_FILES,INSTRUCTION_FILES,INJECTABLE_EVENTS,TITLE_EFFECTIVE_EVENTS,HARNESS_DIRS,HARNESS_LIFECYCLE,HARNESS_COMPACTION,HARNESS_SESSION_CONTROL,isHarness}from"./harness.js";export{TERMINAL_LOCATOR_ENV,TERMINAL_LOCATOR_ENV_KEYS}from"./terminal.js";export{DEFAULT_COMPONENTS,FULL_COMPONENTS,MINIMAL_COMPONENTS}from"./types.js";export{DEFAULT_HOOKS,DEFAULT_SKILLS,DEFAULT_COMMANDS,DEFAULT_AGENTS,DEFAULT_MCP}from"./types.js";export{detectPlatform}from"./platform.js";export{checkHarness}from"./harness-checks.js";export{ensureDir,writeFileIfAbsent,fileExists}from"./utils/fs.js";export{logger,formatTable}from"./utils/logger.js";