trellis 3.1.35 → 3.2.0

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 (422) hide show
  1. package/CHANGELOG.md +16 -5
  2. package/README.md +19 -2
  3. package/bin/trellis.mjs +2 -75
  4. package/dist/better-sqlite-backend-2P4F6AOJ.js +209 -0
  5. package/dist/{better-sqlite-backend-ahx5p0br.js → better-sqlite-backend-PII64VE6.js} +37 -25
  6. package/dist/better-sqlite-backend-VUBVQ7SN.js +209 -0
  7. package/dist/better-sqlite-backend-Y3AQN65E.js +159 -0
  8. package/dist/better-sqlite-backend-Y3M7DXOX.js +159 -0
  9. package/dist/boot-middleware-FJDGVUM4.js +9 -0
  10. package/dist/boot-middleware-MHLHFCUC.js +9 -0
  11. package/dist/boot-middleware-MLJUTLUM.js +9 -0
  12. package/dist/boot-middleware-ZZPDZNYR.js +9 -0
  13. package/dist/{index-wncptktd.js → chunk-276LKLZR.js} +126 -59
  14. package/dist/chunk-2BRTCEHB.js +143 -0
  15. package/dist/chunk-2CX5UCRV.js +111 -0
  16. package/dist/chunk-2ESYSVXG.js +48 -0
  17. package/dist/{index-yp88he8n.js → chunk-2I5JU73Y.js} +88 -64
  18. package/dist/{index-w5wccer3.js → chunk-2UNSRRNB.js} +10 -5
  19. package/dist/{index-4wxa8xz4.js → chunk-335UEHQR.js} +158 -22
  20. package/dist/chunk-36VSSTL7.js +357 -0
  21. package/dist/chunk-3ETIIPPB.js +1077 -0
  22. package/dist/chunk-3GDRZTAW.js +45 -0
  23. package/dist/chunk-44FFQKQX.js +142 -0
  24. package/dist/chunk-4CF2L46N.js +29 -0
  25. package/dist/chunk-4HYPLFJD.js +150 -0
  26. package/dist/chunk-4XIVMVHC.js +361 -0
  27. package/dist/chunk-5CINODKT.js +41 -0
  28. package/dist/chunk-5ESGWJ5L.js +45 -0
  29. package/dist/chunk-5FGLQGMF.js +1676 -0
  30. package/dist/chunk-5IQZFITY.js +357 -0
  31. package/dist/{index-wt8rz4gn.js → chunk-5JWFAQDW.js} +41 -23
  32. package/dist/{index-7pjz3tsy.js → chunk-62UHTVU3.js} +50 -16
  33. package/dist/{index-h32txmxe.js → chunk-66UJQT2I.js} +6 -13
  34. package/dist/chunk-6CTA6MCE.js +340 -0
  35. package/dist/{index-4cdr7x2x.js → chunk-6RNNVOAS.js} +178 -109
  36. package/dist/chunk-6X23PZ6H.js +969 -0
  37. package/dist/chunk-7C7LL6MB.js +315 -0
  38. package/dist/chunk-7F4HM3JG.js +394 -0
  39. package/dist/chunk-7KJ7T4D3.js +910 -0
  40. package/dist/chunk-7QQQNUB5.js +92 -0
  41. package/dist/{index-53f3b8p8.js → chunk-7QWJBS72.js} +210 -165
  42. package/dist/chunk-7R36OZK3.js +957 -0
  43. package/dist/chunk-7UPKCOHE.js +946 -0
  44. package/dist/chunk-7WQGTFVJ.js +7434 -0
  45. package/dist/chunk-A3BONW34.js +35 -0
  46. package/dist/chunk-AHMDVHBL.js +141 -0
  47. package/dist/chunk-AW6A4OZY.js +171 -0
  48. package/dist/chunk-B3ZIFA2O.js +2240 -0
  49. package/dist/chunk-BJ5EKCJ5.js +458 -0
  50. package/dist/chunk-BJ7EZ7FP.js +145 -0
  51. package/dist/chunk-BQBUVMRN.js +171 -0
  52. package/dist/chunk-BRGYDO7D.js +223 -0
  53. package/dist/chunk-BXSTJVE3.js +67 -0
  54. package/dist/chunk-C5KPSEDN.js +359 -0
  55. package/dist/chunk-CCTNYTUC.js +940 -0
  56. package/dist/chunk-CYQ2OVD2.js +35 -0
  57. package/dist/chunk-DDAK7YOE.js +299 -0
  58. package/dist/chunk-DRILKBY6.js +965 -0
  59. package/dist/chunk-DXE24HNN.js +45 -0
  60. package/dist/chunk-E7ICUNW7.js +945 -0
  61. package/dist/chunk-EAL2PUOE.js +10022 -0
  62. package/dist/chunk-ELT7MLZB.js +109 -0
  63. package/dist/chunk-EO3J7GRP.js +0 -0
  64. package/dist/chunk-EWEIRF6G.js +171 -0
  65. package/dist/chunk-F5VDGQJC.js +120 -0
  66. package/dist/chunk-FCPL3IEQ.js +98 -0
  67. package/dist/{index-nq520y6k.js → chunk-FDPKYSV7.js} +43 -31
  68. package/dist/chunk-FES3TC24.js +171 -0
  69. package/dist/chunk-FF36CQHZ.js +61 -0
  70. package/dist/chunk-FKQO5A3H.js +35 -0
  71. package/dist/chunk-FOWKR5TW.js +129 -0
  72. package/dist/chunk-FZVCXDYW.js +150 -0
  73. package/dist/chunk-G3XIHPSQ.js +361 -0
  74. package/dist/chunk-GD5QJXSS.js +98 -0
  75. package/dist/chunk-GFZCJ4EH.js +108 -0
  76. package/dist/chunk-GKJLYLVU.js +359 -0
  77. package/dist/chunk-GLM4HGN4.js +55 -0
  78. package/dist/chunk-GNXHXNVQ.js +113 -0
  79. package/dist/chunk-GSR6ILTM.js +277 -0
  80. package/dist/chunk-GWRIMRSX.js +45 -0
  81. package/dist/chunk-H72UW2HJ.js +45 -0
  82. package/dist/chunk-HGI74PXB.js +7417 -0
  83. package/dist/chunk-HGRA37LO.js +145 -0
  84. package/dist/chunk-HO4TURXW.js +1078 -0
  85. package/dist/chunk-HXSRQO3L.js +145 -0
  86. package/dist/chunk-IG2X2BVO.js +373 -0
  87. package/dist/chunk-IIJVDD54.js +373 -0
  88. package/dist/chunk-IUWVEEOX.js +145 -0
  89. package/dist/chunk-IX4BBOIT.js +394 -0
  90. package/dist/{index-yhwjgfvj.js → chunk-IXU4RMQM.js} +67 -60
  91. package/dist/chunk-J3WYZO3Q.js +211 -0
  92. package/dist/{index-vkpkfwhq.js → chunk-J6OUIION.js} +234 -194
  93. package/dist/{index-xzym9w0m.js → chunk-JA7AIHRK.js} +12 -7
  94. package/dist/chunk-JUEMDWLU.js +233 -0
  95. package/dist/chunk-K46RNFDE.js +171 -0
  96. package/dist/chunk-KAGU2XMY.js +359 -0
  97. package/dist/chunk-KCVYJNVX.js +394 -0
  98. package/dist/chunk-KFQGP6VL.js +33 -0
  99. package/dist/chunk-KKDRMIV6.js +419 -0
  100. package/dist/chunk-KQ4A2D2P.js +910 -0
  101. package/dist/chunk-KSU2GW22.js +958 -0
  102. package/dist/chunk-KYLIQ3YI.js +399 -0
  103. package/dist/chunk-KZYJJIRN.js +946 -0
  104. package/dist/chunk-LFOX744K.js +96 -0
  105. package/dist/{index-rv1p47gp.js → chunk-LHOVJEWR.js} +2756 -2307
  106. package/dist/{index-h9e2efx4.js → chunk-LNUIGRDZ.js} +71 -55
  107. package/dist/chunk-LOPXTPF3.js +120 -0
  108. package/dist/chunk-LZR3VIFU.js +907 -0
  109. package/dist/chunk-MBNBTJCR.js +394 -0
  110. package/dist/chunk-MCKGQKYU.js +15 -0
  111. package/dist/{index-skhn0agf.js → chunk-MLC5BUYO.js} +19 -20
  112. package/dist/chunk-MPXUVGT3.js +104 -0
  113. package/dist/chunk-MU6EOS6F.js +0 -0
  114. package/dist/chunk-MWRQ2TXT.js +357 -0
  115. package/dist/{index-nzb3am4f.js → chunk-NO73OK2I.js} +43 -21
  116. package/dist/chunk-NPE2YJHK.js +394 -0
  117. package/dist/{index-xhcp6xrn.js → chunk-NSDXU6QX.js} +654 -500
  118. package/dist/chunk-NXIRDSZ6.js +145 -0
  119. package/dist/chunk-NZWFNHCS.js +407 -0
  120. package/dist/chunk-O2AV5WMN.js +48 -0
  121. package/dist/{index-h7zxhhhh.js → chunk-OB4CMMX6.js} +46 -38
  122. package/dist/chunk-OBKU74FU.js +7411 -0
  123. package/dist/chunk-OQNDWRDE.js +145 -0
  124. package/dist/chunk-OVWAJMB6.js +394 -0
  125. package/dist/chunk-PDHLBTTD.js +45 -0
  126. package/dist/chunk-PEQNRKLG.js +210 -0
  127. package/dist/chunk-QERIS7QY.js +7403 -0
  128. package/dist/chunk-QHA2DM3C.js +373 -0
  129. package/dist/chunk-QLM4HSYC.js +45 -0
  130. package/dist/chunk-RSWUFTO2.js +857 -0
  131. package/dist/chunk-S2OT3TQJ.js +283 -0
  132. package/dist/chunk-S5PHSN5K.js +907 -0
  133. package/dist/chunk-SIAA4J6H.js +21 -0
  134. package/dist/chunk-SPSPV5BC.js +390 -0
  135. package/dist/chunk-SQBNLUIA.js +171 -0
  136. package/dist/chunk-STLN6A6B.js +355 -0
  137. package/dist/chunk-TCKXSOBP.js +123 -0
  138. package/dist/chunk-U7HV7GU2.js +17 -0
  139. package/dist/chunk-UBGUDMUV.js +59 -0
  140. package/dist/chunk-UGZHOGRA.js +39 -0
  141. package/dist/chunk-UICF66FS.js +359 -0
  142. package/dist/chunk-UK3EQREE.js +1078 -0
  143. package/dist/chunk-UPKPURVY.js +394 -0
  144. package/dist/chunk-URC74VCN.js +959 -0
  145. package/dist/chunk-USEINYUL.js +12 -0
  146. package/dist/{index-bmyt7k8n.js → chunk-UZRUP7QW.js} +12 -4
  147. package/dist/chunk-V3G7Q3QQ.js +102 -0
  148. package/dist/chunk-VDAKEOML.js +857 -0
  149. package/dist/chunk-VUJ6SA55.js +303 -0
  150. package/dist/chunk-VUJQLIML.js +141 -0
  151. package/dist/chunk-VWKLKLYB.js +267 -0
  152. package/dist/chunk-VYC3RZMK.js +277 -0
  153. package/dist/chunk-WMERMSWI.js +154 -0
  154. package/dist/chunk-WMR777PO.js +2213 -0
  155. package/dist/{index-n9f2qyh5.js → chunk-X46IECAC.js} +55 -33
  156. package/dist/chunk-X5FLTRUB.js +517 -0
  157. package/dist/chunk-X762XWVC.js +419 -0
  158. package/dist/chunk-XEN3OEYY.js +2234 -0
  159. package/dist/chunk-XMQ7G77X.js +260 -0
  160. package/dist/chunk-XZQ66K7A.js +124 -0
  161. package/dist/{index-w7ng765c.js → chunk-YCM7ZYEZ.js} +102 -49
  162. package/dist/chunk-YY3GF7DH.js +7411 -0
  163. package/dist/chunk-ZE5R3H4C.js +907 -0
  164. package/dist/chunk-ZHVI7BQN.js +1077 -0
  165. package/dist/chunk-ZMN5LUB7.js +7411 -0
  166. package/dist/chunk-ZUV4MD5U.js +94 -0
  167. package/dist/cli/errors.d.ts +6 -0
  168. package/dist/cli/errors.d.ts.map +1 -0
  169. package/dist/cli/examples.d.ts +23 -0
  170. package/dist/cli/examples.d.ts.map +1 -0
  171. package/dist/cli/index.d.ts.map +1 -1
  172. package/dist/cli/index.js +2338 -6190
  173. package/dist/client/index.d.ts +6 -1
  174. package/dist/client/index.d.ts.map +1 -1
  175. package/dist/client/index.js +41 -21
  176. package/dist/client/live.d.ts +67 -0
  177. package/dist/client/live.d.ts.map +1 -0
  178. package/dist/client/reactive.d.ts +31 -0
  179. package/dist/client/reactive.d.ts.map +1 -0
  180. package/dist/client/sdk.d.ts +26 -2
  181. package/dist/client/sdk.d.ts.map +1 -1
  182. package/dist/client/sdk.js +9 -0
  183. package/dist/client/vcs-client.d.ts +129 -0
  184. package/dist/client/vcs-client.d.ts.map +1 -0
  185. package/dist/cms/index.js +171 -163
  186. package/dist/{config-8hczw0rs.js → config-KMY6RRK3.js} +8 -9
  187. package/dist/config-PFTP67TR.js +19 -0
  188. package/dist/config-VDMK2DUJ.js +19 -0
  189. package/dist/core/computation/index.d.ts +5 -0
  190. package/dist/core/computation/index.d.ts.map +1 -0
  191. package/dist/core/computation/rollup.d.ts +18 -0
  192. package/dist/core/computation/rollup.d.ts.map +1 -0
  193. package/dist/core/index.d.ts +5 -0
  194. package/dist/core/index.d.ts.map +1 -1
  195. package/dist/core/index.js +168 -101
  196. package/dist/core/kernel/boot-middleware.d.ts +10 -0
  197. package/dist/core/kernel/boot-middleware.d.ts.map +1 -0
  198. package/dist/core/kernel/logic-middleware.d.ts +7 -1
  199. package/dist/core/kernel/logic-middleware.d.ts.map +1 -1
  200. package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
  201. package/dist/core/ontology/types.d.ts +5 -0
  202. package/dist/core/ontology/types.d.ts.map +1 -1
  203. package/dist/core/persist/better-sqlite-backend.d.ts +9 -2
  204. package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -1
  205. package/dist/core/persist/factory.d.ts +6 -7
  206. package/dist/core/persist/factory.d.ts.map +1 -1
  207. package/dist/core/persist/factory.js +2 -3
  208. package/dist/core/persist/sqljs-backend.js +2 -3
  209. package/dist/db/index.d.ts +4 -1
  210. package/dist/db/index.d.ts.map +1 -1
  211. package/dist/db/index.js +69 -56
  212. package/dist/db/inspector.js +11 -19
  213. package/dist/decisions/index.js +9 -10
  214. package/dist/deploy-66EC752W.js +9 -0
  215. package/dist/deploy-SO7AFK6L.js +9 -0
  216. package/dist/embeddings/auto-embed.d.ts +2 -2
  217. package/dist/embeddings/auto-embed.d.ts.map +1 -1
  218. package/dist/embeddings/index.js +20 -22
  219. package/dist/embeddings/search.d.ts +2 -1
  220. package/dist/embeddings/search.d.ts.map +1 -1
  221. package/dist/embeddings/store.d.ts +25 -4
  222. package/dist/embeddings/store.d.ts.map +1 -1
  223. package/dist/engine-7GXBM4IT.js +7 -0
  224. package/dist/engine-NSR6BIF7.js +7 -0
  225. package/dist/engine.d.ts +32 -12
  226. package/dist/engine.d.ts.map +1 -1
  227. package/dist/factory-2P64OC7M.js +34 -0
  228. package/dist/factory-YP4ZZK5K.js +34 -0
  229. package/dist/import-AJLYHFIA.js +10 -0
  230. package/dist/import-UZEKXU3B.js +10 -0
  231. package/dist/index.js +102 -93
  232. package/dist/launch-explorer-AI6L2AWJ.js +91 -0
  233. package/dist/launch-explorer-HZ4ZJA4X.js +95 -0
  234. package/dist/links/index.js +24 -26
  235. package/dist/plugins/agent-memory/index.js +316 -0
  236. package/dist/plugins/idea-garden/index.js +165 -0
  237. package/dist/plugins/plan-approval/index.js +579 -0
  238. package/dist/plugins/proactive-watcher/index.js +194 -0
  239. package/dist/{index-2r4jxwnb.js → query-GJL3CVGN.js} +14 -15
  240. package/dist/query-MBJSK3EB.js +31 -0
  241. package/dist/query-TJHEVSKL.js +31 -0
  242. package/dist/query-WUIKOHPE.js +524 -0
  243. package/dist/query-XYLTJYSA.js +31 -0
  244. package/dist/react/index.js +39 -70
  245. package/dist/react/realtime.js +11 -0
  246. package/dist/react/schema-hooks.js +87 -0
  247. package/dist/realtime/broadcast-channel-transport.d.ts +43 -0
  248. package/dist/realtime/broadcast-channel-transport.d.ts.map +1 -0
  249. package/dist/realtime/durable-object-relay-transport.d.ts +96 -0
  250. package/dist/realtime/durable-object-relay-transport.d.ts.map +1 -0
  251. package/dist/realtime/index.d.ts +44 -0
  252. package/dist/realtime/index.d.ts.map +1 -0
  253. package/dist/realtime/index.js +40 -0
  254. package/dist/realtime/memory-hub.d.ts +32 -0
  255. package/dist/realtime/memory-hub.d.ts.map +1 -0
  256. package/dist/realtime/persistent-channel.d.ts +105 -0
  257. package/dist/realtime/persistent-channel.d.ts.map +1 -0
  258. package/dist/realtime/presence.d.ts +73 -0
  259. package/dist/realtime/presence.d.ts.map +1 -0
  260. package/dist/realtime/relay-persistence.d.ts +37 -0
  261. package/dist/realtime/relay-persistence.d.ts.map +1 -0
  262. package/dist/realtime/relay-persistence.js +107 -0
  263. package/dist/realtime/relay-server.d.ts +103 -0
  264. package/dist/realtime/relay-server.d.ts.map +1 -0
  265. package/dist/realtime/room.d.ts +98 -0
  266. package/dist/realtime/room.d.ts.map +1 -0
  267. package/dist/realtime/text.d.ts +73 -0
  268. package/dist/realtime/text.d.ts.map +1 -0
  269. package/dist/realtime/types.d.ts +89 -0
  270. package/dist/realtime/types.d.ts.map +1 -0
  271. package/dist/realtime/websocket-relay-transport.d.ts +28 -0
  272. package/dist/realtime/websocket-relay-transport.d.ts.map +1 -0
  273. package/dist/realtime.bundle.js +1100 -0
  274. package/dist/remote-manager-BLJZ6KF6.js +224 -0
  275. package/dist/{remote-manager-xvbg4230.js → remote-manager-BPYE46SI.js} +24 -15
  276. package/dist/remote-manager-FMESEAFA.js +224 -0
  277. package/dist/remote-manager-K2WZ5RHY.js +223 -0
  278. package/dist/remote-manager-SG545WNY.js +224 -0
  279. package/dist/remote-manager-SG5PQKCH.js +224 -0
  280. package/dist/remote-manager-WGP6MIQZ.js +224 -0
  281. package/dist/scaffold/write.d.ts.map +1 -1
  282. package/dist/schema/define.d.ts +137 -0
  283. package/dist/schema/define.d.ts.map +1 -0
  284. package/dist/schema/entity-projection.d.ts +34 -0
  285. package/dist/schema/entity-projection.d.ts.map +1 -0
  286. package/dist/schema/eql.d.ts +46 -0
  287. package/dist/schema/eql.d.ts.map +1 -0
  288. package/dist/schema/index.d.ts +21 -0
  289. package/dist/schema/index.d.ts.map +1 -0
  290. package/dist/schema/index.js +45 -0
  291. package/dist/schema/kernel-resolve.d.ts +21 -0
  292. package/dist/schema/kernel-resolve.d.ts.map +1 -0
  293. package/dist/schema/mutations.d.ts +20 -0
  294. package/dist/schema/mutations.d.ts.map +1 -0
  295. package/dist/schema/resolve.d.ts +21 -0
  296. package/dist/schema/resolve.d.ts.map +1 -0
  297. package/dist/sdk-3KBB3E6V.js +16 -0
  298. package/dist/sdk-4ZQO6UTU.js +16 -0
  299. package/dist/sdk-6JA6GV3G.js +16 -0
  300. package/dist/sdk-6VTP5UTZ.js +16 -0
  301. package/dist/sdk-7VS6TYCD.js +16 -0
  302. package/dist/sdk-HQ3FTLRT.js +16 -0
  303. package/dist/sdk-HZ7NU3XE.js +15 -0
  304. package/dist/sdk-KBQE2OXT.js +16 -0
  305. package/dist/sdk-LZ7W3EEY.js +9 -0
  306. package/dist/sdk-MSCDZ7JU.js +15 -0
  307. package/dist/sdk-WNZOGO3S.js +15 -0
  308. package/dist/sdk-YLV33ZCW.js +9 -0
  309. package/dist/sdk-ZSUD2LLJ.js +16 -0
  310. package/dist/server/index.d.ts +2 -0
  311. package/dist/server/index.d.ts.map +1 -1
  312. package/dist/server/index.js +69 -61
  313. package/dist/server/node-adapter.js +5 -104
  314. package/dist/server/realtime.d.ts +10 -2
  315. package/dist/server/realtime.d.ts.map +1 -1
  316. package/dist/server/server.d.ts +7 -16
  317. package/dist/server/server.d.ts.map +1 -1
  318. package/dist/server/sprites.d.ts.map +1 -1
  319. package/dist/server/tenancy.d.ts.map +1 -1
  320. package/dist/server-AFXFFBWA.js +11 -0
  321. package/dist/server-AGHC4VUL.js +11 -0
  322. package/dist/server-BOH7M4TT.js +13 -0
  323. package/dist/server-DBUY2KY5.js +11 -0
  324. package/dist/server-GWBQJPRG.js +11 -0
  325. package/dist/server-IGBIIJSF.js +13 -0
  326. package/dist/server-JZZFULVU.js +11 -0
  327. package/dist/server-L5XAF4M5.js +11 -0
  328. package/dist/server-NYFUHANA.js +12 -0
  329. package/dist/server-OABUB2LO.js +12 -0
  330. package/dist/server-P2CKZWWV.js +12 -0
  331. package/dist/{sprites-vc4qbrp1.js → sprites-RU3E4XQN.js} +6 -7
  332. package/dist/sprites-XVSMQLSI.js +15 -0
  333. package/dist/sql-wasm-FORCZFHZ.js +2148 -0
  334. package/dist/sql-wasm-JZH76RLO.js +2148 -0
  335. package/dist/sqljs-backend-CJQOIQYE.js +266 -0
  336. package/dist/sqljs-backend-KWXBUDUO.js +266 -0
  337. package/dist/state-demo.bundle.js +1033 -0
  338. package/dist/svelte/index.d.ts +17 -0
  339. package/dist/svelte/index.d.ts.map +1 -0
  340. package/dist/svelte/index.js +51 -0
  341. package/dist/svelte/schema-hooks.d.ts +45 -0
  342. package/dist/svelte/schema-hooks.d.ts.map +1 -0
  343. package/dist/svelte/schema-hooks.js +71 -0
  344. package/dist/svelte/stores.d.ts +78 -0
  345. package/dist/svelte/stores.d.ts.map +1 -0
  346. package/dist/sync/http-transport.d.ts +3 -3
  347. package/dist/sync/http-transport.d.ts.map +1 -1
  348. package/dist/sync/index.d.ts +15 -1
  349. package/dist/sync/index.d.ts.map +1 -1
  350. package/dist/sync/index.js +617 -0
  351. package/dist/sync/memory-room.d.ts +37 -0
  352. package/dist/sync/memory-room.d.ts.map +1 -0
  353. package/dist/sync/memory-transport.d.ts +3 -3
  354. package/dist/sync/memory-transport.d.ts.map +1 -1
  355. package/dist/sync/partykit-room.d.ts +40 -0
  356. package/dist/sync/partykit-room.d.ts.map +1 -0
  357. package/dist/sync/partykit-transport.d.ts +84 -0
  358. package/dist/sync/partykit-transport.d.ts.map +1 -0
  359. package/dist/sync/room-core.d.ts +53 -0
  360. package/dist/sync/room-core.d.ts.map +1 -0
  361. package/dist/sync/sync-engine.d.ts +40 -2
  362. package/dist/sync/sync-engine.d.ts.map +1 -1
  363. package/dist/sync/sync-room-server.d.ts +39 -0
  364. package/dist/sync/sync-room-server.d.ts.map +1 -0
  365. package/dist/sync/types.d.ts +70 -3
  366. package/dist/sync/types.d.ts.map +1 -1
  367. package/dist/sync/vcs-sync-peer.d.ts +63 -0
  368. package/dist/sync/vcs-sync-peer.d.ts.map +1 -0
  369. package/dist/sync/ws-transport.d.ts +2 -2
  370. package/dist/sync/ws-transport.d.ts.map +1 -1
  371. package/dist/tenancy-CBWYEVUB.js +11 -0
  372. package/dist/tenancy-FO6WVYFN.js +13 -0
  373. package/dist/tenancy-FWDBESMX.js +14 -0
  374. package/dist/tenancy-HGPIS5QA.js +13 -0
  375. package/dist/tenancy-HXFALA37.js +14 -0
  376. package/dist/tenancy-OP34NFFS.js +14 -0
  377. package/dist/tenancy-S676GLID.js +14 -0
  378. package/dist/tenancy-V7ARWNNV.js +14 -0
  379. package/dist/tenancy-ZDN4GXK5.js +13 -0
  380. package/dist/tenancy-ZT5VMY7B.js +14 -0
  381. package/dist/ui/client.html +355 -67
  382. package/dist/ui/launch-explorer.d.ts +22 -0
  383. package/dist/ui/launch-explorer.d.ts.map +1 -0
  384. package/dist/ui/server.d.ts +1 -1
  385. package/dist/ui/server.d.ts.map +1 -1
  386. package/dist/vcs/blob-store.d.ts.map +1 -1
  387. package/dist/vcs/idb-op-log.d.ts +67 -0
  388. package/dist/vcs/idb-op-log.d.ts.map +1 -0
  389. package/dist/vcs/index.d.ts +1 -0
  390. package/dist/vcs/index.d.ts.map +1 -1
  391. package/dist/vcs/index.js +81 -72
  392. package/dist/vcs/issue.d.ts +22 -5
  393. package/dist/vcs/issue.d.ts.map +1 -1
  394. package/dist/vcs/lane-materialize.d.ts +5 -0
  395. package/dist/vcs/lane-materialize.d.ts.map +1 -1
  396. package/dist/vcs/op-log.d.ts +28 -2
  397. package/dist/vcs/op-log.d.ts.map +1 -1
  398. package/dist/vcs/ops.d.ts +10 -0
  399. package/dist/vcs/ops.d.ts.map +1 -1
  400. package/dist/{vm-config-6xhsj6b3.js → vm-config-JI4OXKDQ.js} +9 -10
  401. package/dist/vm-config-YZRJ3KUB.js +21 -0
  402. package/dist/vue/hooks.d.ts +64 -0
  403. package/dist/vue/hooks.d.ts.map +1 -0
  404. package/dist/vue/index.d.ts +19 -0
  405. package/dist/vue/index.d.ts.map +1 -0
  406. package/dist/vue/index.js +59 -0
  407. package/dist/vue/schema-hooks.d.ts +41 -0
  408. package/dist/vue/schema-hooks.d.ts.map +1 -0
  409. package/dist/vue/schema-hooks.js +64 -0
  410. package/package.json +118 -16
  411. package/dist/deploy-999q207z.js +0 -10
  412. package/dist/engine-y0724kjq.js +0 -8
  413. package/dist/import-s2b8e0ft.js +0 -11
  414. package/dist/index-a76rekgs.js +0 -67
  415. package/dist/index-c9h37r6h.js +0 -1
  416. package/dist/index-hr9qvv77.js +0 -860
  417. package/dist/index-k5b0xskw.js +0 -1
  418. package/dist/index-y6a4kj0p.js +0 -43
  419. package/dist/sdk-bepky0xs.js +0 -16
  420. package/dist/server-szdjx0nt.js +0 -13
  421. package/dist/sqlite-backend-0vsmc6qj.js +0 -8
  422. package/dist/tenancy-pjm32b4v.js +0 -14
@@ -1,4 +1,3 @@
1
- // @bun
2
1
  import {
3
2
  createVcsOp,
4
3
  criterionEntityId,
@@ -9,25 +8,23 @@ import {
9
8
  init_types,
10
9
  issueEntityId,
11
10
  laneEntityId
12
- } from "./index-nzb3am4f.js";
11
+ } from "./chunk-V3G7Q3QQ.js";
13
12
  import {
14
13
  __esm,
15
14
  __require
16
- } from "./index-a76rekgs.js";
15
+ } from "./chunk-2ESYSVXG.js";
17
16
 
18
17
  // src/vcs/decompose.ts
19
18
  import { dirname } from "path";
20
19
  function pickFacts(input) {
21
- if (!Array.isArray(input))
22
- return [];
20
+ if (!Array.isArray(input)) return [];
23
21
  return input.filter((item) => {
24
22
  const fact = item;
25
23
  return typeof fact.e === "string" && typeof fact.a === "string" && (typeof fact.v === "string" || typeof fact.v === "number" || typeof fact.v === "boolean");
26
24
  });
27
25
  }
28
26
  function pickLinks(input) {
29
- if (!Array.isArray(input))
30
- return [];
27
+ if (!Array.isArray(input)) return [];
31
28
  return input.filter((item) => {
32
29
  const link = item;
33
30
  return typeof link.e1 === "string" && typeof link.a === "string" && typeof link.e2 === "string";
@@ -41,8 +38,7 @@ function decompose(op) {
41
38
  deleteLinks: []
42
39
  };
43
40
  const vcs = op.vcs;
44
- if (!vcs)
45
- return result;
41
+ if (!vcs) return result;
46
42
  if (vcs.issueId && vcs.oldIssueStatus) {
47
43
  result.deleteFacts.push({
48
44
  e: issueEntityId(vcs.issueId),
@@ -52,29 +48,33 @@ function decompose(op) {
52
48
  }
53
49
  switch (op.kind) {
54
50
  case "vcs:fileAdd": {
55
- if (!vcs.filePath)
56
- break;
51
+ if (!vcs.filePath) break;
57
52
  const eid = fileEntityId(vcs.filePath);
58
53
  const dir = dirname(vcs.filePath);
59
54
  const did = dirEntityId(dir === "." ? "" : dir);
60
- result.addFacts.push({ e: eid, a: "type", v: "FileNode" }, { e: eid, a: "path", v: vcs.filePath });
55
+ result.addFacts.push(
56
+ { e: eid, a: "type", v: "FileNode" },
57
+ { e: eid, a: "path", v: vcs.filePath }
58
+ );
61
59
  if (vcs.contentHash) {
62
60
  result.addFacts.push({ e: eid, a: "contentHash", v: vcs.contentHash });
63
61
  }
64
- if (vcs.size !== undefined) {
62
+ if (vcs.size !== void 0) {
65
63
  result.addFacts.push({ e: eid, a: "size", v: vcs.size });
66
64
  }
67
65
  if (vcs.language) {
68
66
  result.addFacts.push({ e: eid, a: "language", v: vcs.language });
69
67
  }
70
68
  result.addFacts.push({ e: eid, a: "lastModified", v: op.timestamp });
71
- result.addFacts.push({ e: did, a: "type", v: "DirectoryNode" }, { e: did, a: "path", v: dir === "." ? "" : dir });
69
+ result.addFacts.push(
70
+ { e: did, a: "type", v: "DirectoryNode" },
71
+ { e: did, a: "path", v: dir === "." ? "" : dir }
72
+ );
72
73
  result.addLinks.push({ e1: did, a: "contains", e2: eid });
73
74
  break;
74
75
  }
75
76
  case "vcs:fileModify": {
76
- if (!vcs.filePath)
77
- break;
77
+ if (!vcs.filePath) break;
78
78
  const eid = fileEntityId(vcs.filePath);
79
79
  if (vcs.oldContentHash) {
80
80
  result.deleteFacts.push({
@@ -86,19 +86,21 @@ function decompose(op) {
86
86
  if (vcs.contentHash) {
87
87
  result.addFacts.push({ e: eid, a: "contentHash", v: vcs.contentHash });
88
88
  }
89
- if (vcs.size !== undefined) {
89
+ if (vcs.size !== void 0) {
90
90
  result.addFacts.push({ e: eid, a: "size", v: vcs.size });
91
91
  }
92
92
  result.addFacts.push({ e: eid, a: "lastModified", v: op.timestamp });
93
93
  break;
94
94
  }
95
95
  case "vcs:fileDelete": {
96
- if (!vcs.filePath)
97
- break;
96
+ if (!vcs.filePath) break;
98
97
  const eid = fileEntityId(vcs.filePath);
99
98
  const dir = dirname(vcs.filePath);
100
99
  const did = dirEntityId(dir === "." ? "" : dir);
101
- result.deleteFacts.push({ e: eid, a: "type", v: "FileNode" }, { e: eid, a: "path", v: vcs.filePath });
100
+ result.deleteFacts.push(
101
+ { e: eid, a: "type", v: "FileNode" },
102
+ { e: eid, a: "path", v: vcs.filePath }
103
+ );
102
104
  if (vcs.contentHash) {
103
105
  result.deleteFacts.push({
104
106
  e: eid,
@@ -110,8 +112,7 @@ function decompose(op) {
110
112
  break;
111
113
  }
112
114
  case "vcs:fileRename": {
113
- if (!vcs.filePath || !vcs.oldFilePath)
114
- break;
115
+ if (!vcs.filePath || !vcs.oldFilePath) break;
115
116
  const eid = fileEntityId(vcs.oldFilePath);
116
117
  const oldDir = dirname(vcs.oldFilePath);
117
118
  const newDir = dirname(vcs.filePath);
@@ -121,15 +122,22 @@ function decompose(op) {
121
122
  result.addFacts.push({ e: eid, a: "path", v: vcs.filePath });
122
123
  result.addFacts.push({ e: eid, a: "lastModified", v: op.timestamp });
123
124
  result.deleteLinks.push({ e1: oldDid, a: "contains", e2: eid });
124
- result.addFacts.push({ e: newDid, a: "type", v: "DirectoryNode" }, { e: newDid, a: "path", v: newDir === "." ? "" : newDir });
125
+ result.addFacts.push(
126
+ { e: newDid, a: "type", v: "DirectoryNode" },
127
+ { e: newDid, a: "path", v: newDir === "." ? "" : newDir }
128
+ );
125
129
  result.addLinks.push({ e1: newDid, a: "contains", e2: eid });
126
130
  break;
127
131
  }
128
132
  case "vcs:branchCreate": {
129
- if (!vcs.branchName)
130
- break;
133
+ if (!vcs.branchName) break;
131
134
  const bid = `branch:${vcs.branchName}`;
132
- result.addFacts.push({ e: bid, a: "type", v: "Branch" }, { e: bid, a: "name", v: vcs.branchName }, { e: bid, a: "createdAt", v: op.timestamp }, { e: bid, a: "createdBy", v: op.agentId });
135
+ result.addFacts.push(
136
+ { e: bid, a: "type", v: "Branch" },
137
+ { e: bid, a: "name", v: vcs.branchName },
138
+ { e: bid, a: "createdAt", v: op.timestamp },
139
+ { e: bid, a: "createdBy", v: op.agentId }
140
+ );
133
141
  if (vcs.targetOpHash) {
134
142
  result.addFacts.push({ e: bid, a: "headOpHash", v: vcs.targetOpHash });
135
143
  }
@@ -143,24 +151,28 @@ function decompose(op) {
143
151
  break;
144
152
  }
145
153
  case "vcs:branchDelete": {
146
- if (!vcs.branchName)
147
- break;
154
+ if (!vcs.branchName) break;
148
155
  const bid = `branch:${vcs.branchName}`;
149
- result.deleteFacts.push({ e: bid, a: "type", v: "Branch" }, { e: bid, a: "name", v: vcs.branchName });
156
+ result.deleteFacts.push(
157
+ { e: bid, a: "type", v: "Branch" },
158
+ { e: bid, a: "name", v: vcs.branchName }
159
+ );
150
160
  break;
151
161
  }
152
162
  case "vcs:branchAdvance": {
153
- if (!vcs.branchName || !vcs.targetOpHash)
154
- break;
163
+ if (!vcs.branchName || !vcs.targetOpHash) break;
155
164
  const bid = `branch:${vcs.branchName}`;
156
165
  result.addFacts.push({ e: bid, a: "headOpHash", v: vcs.targetOpHash });
157
166
  break;
158
167
  }
159
168
  case "vcs:milestoneCreate": {
160
- if (!vcs.milestoneId)
161
- break;
169
+ if (!vcs.milestoneId) break;
162
170
  const mid = vcs.milestoneId;
163
- result.addFacts.push({ e: mid, a: "type", v: "Milestone" }, { e: mid, a: "createdAt", v: op.timestamp }, { e: mid, a: "createdBy", v: op.agentId });
171
+ result.addFacts.push(
172
+ { e: mid, a: "type", v: "Milestone" },
173
+ { e: mid, a: "createdAt", v: op.timestamp },
174
+ { e: mid, a: "createdBy", v: op.agentId }
175
+ );
164
176
  if (vcs.message) {
165
177
  result.addFacts.push({ e: mid, a: "message", v: vcs.message });
166
178
  }
@@ -174,17 +186,26 @@ function decompose(op) {
174
186
  }
175
187
  case "vcs:checkpointCreate": {
176
188
  const cid = `checkpoint:${op.hash}`;
177
- result.addFacts.push({ e: cid, a: "type", v: "Checkpoint" }, { e: cid, a: "createdAt", v: op.timestamp }, { e: cid, a: "atOpHash", v: op.hash });
189
+ result.addFacts.push(
190
+ { e: cid, a: "type", v: "Checkpoint" },
191
+ { e: cid, a: "createdAt", v: op.timestamp },
192
+ { e: cid, a: "atOpHash", v: op.hash }
193
+ );
178
194
  if (vcs.trigger) {
179
195
  result.addFacts.push({ e: cid, a: "trigger", v: vcs.trigger });
180
196
  }
181
197
  break;
182
198
  }
199
+ // ----- Issue tracking -----
183
200
  case "vcs:issueCreate": {
184
- if (!vcs.issueId)
185
- break;
201
+ if (!vcs.issueId) break;
186
202
  const eid = issueEntityId(vcs.issueId);
187
- result.addFacts.push({ e: eid, a: "type", v: "Issue" }, { e: eid, a: "status", v: vcs.issueStatus ?? "backlog" }, { e: eid, a: "createdAt", v: op.timestamp }, { e: eid, a: "createdBy", v: op.agentId });
203
+ result.addFacts.push(
204
+ { e: eid, a: "type", v: "Issue" },
205
+ { e: eid, a: "status", v: vcs.issueStatus ?? "backlog" },
206
+ { e: eid, a: "createdAt", v: op.timestamp },
207
+ { e: eid, a: "createdBy", v: op.agentId }
208
+ );
188
209
  if (vcs.issueTitle) {
189
210
  result.addFacts.push({ e: eid, a: "title", v: vcs.issueTitle });
190
211
  }
@@ -218,8 +239,7 @@ function decompose(op) {
218
239
  break;
219
240
  }
220
241
  case "vcs:issueUpdate": {
221
- if (!vcs.issueId)
222
- break;
242
+ if (!vcs.issueId) break;
223
243
  const eid = issueEntityId(vcs.issueId);
224
244
  if (vcs.issueStatus) {
225
245
  result.addFacts.push({ e: eid, a: "status", v: vcs.issueStatus });
@@ -240,7 +260,7 @@ function decompose(op) {
240
260
  if (vcs.issueAssignee) {
241
261
  result.addFacts.push({ e: eid, a: "assignee", v: vcs.issueAssignee });
242
262
  }
243
- if (vcs.issueDescription !== undefined) {
263
+ if (vcs.issueDescription !== void 0) {
244
264
  result.addFacts.push({
245
265
  e: eid,
246
266
  a: "description",
@@ -264,10 +284,12 @@ function decompose(op) {
264
284
  break;
265
285
  }
266
286
  case "vcs:issueStart": {
267
- if (!vcs.issueId)
268
- break;
287
+ if (!vcs.issueId) break;
269
288
  const eid = issueEntityId(vcs.issueId);
270
- result.addFacts.push({ e: eid, a: "status", v: "in_progress" }, { e: eid, a: "startedAt", v: op.timestamp });
289
+ result.addFacts.push(
290
+ { e: eid, a: "status", v: "in_progress" },
291
+ { e: eid, a: "startedAt", v: op.timestamp }
292
+ );
271
293
  if (vcs.issueAssignee) {
272
294
  result.addFacts.push({ e: eid, a: "assignee", v: vcs.issueAssignee });
273
295
  }
@@ -281,41 +303,50 @@ function decompose(op) {
281
303
  break;
282
304
  }
283
305
  case "vcs:issuePause": {
284
- if (!vcs.issueId)
285
- break;
306
+ if (!vcs.issueId) break;
286
307
  const eid = issueEntityId(vcs.issueId);
287
- result.addFacts.push({ e: eid, a: "status", v: "paused" }, { e: eid, a: "pausedAt", v: op.timestamp });
308
+ result.addFacts.push(
309
+ { e: eid, a: "status", v: "paused" },
310
+ { e: eid, a: "pausedAt", v: op.timestamp }
311
+ );
288
312
  if (vcs.pauseNote) {
289
313
  result.addFacts.push({ e: eid, a: "pauseNote", v: vcs.pauseNote });
290
314
  }
291
315
  break;
292
316
  }
293
317
  case "vcs:issueResume": {
294
- if (!vcs.issueId)
295
- break;
318
+ if (!vcs.issueId) break;
296
319
  const eid = issueEntityId(vcs.issueId);
297
- result.addFacts.push({ e: eid, a: "status", v: "in_progress" }, { e: eid, a: "resumedAt", v: op.timestamp }, { e: eid, a: "pauseNote", v: "" });
320
+ result.addFacts.push(
321
+ { e: eid, a: "status", v: "in_progress" },
322
+ { e: eid, a: "resumedAt", v: op.timestamp },
323
+ { e: eid, a: "pauseNote", v: "" }
324
+ );
298
325
  break;
299
326
  }
300
327
  case "vcs:issueClose": {
301
- if (!vcs.issueId)
302
- break;
328
+ if (!vcs.issueId) break;
303
329
  const eid = issueEntityId(vcs.issueId);
304
- result.addFacts.push({ e: eid, a: "status", v: "closed" }, { e: eid, a: "closedAt", v: op.timestamp });
330
+ result.addFacts.push(
331
+ { e: eid, a: "status", v: "closed" },
332
+ { e: eid, a: "closedAt", v: op.timestamp }
333
+ );
305
334
  break;
306
335
  }
307
336
  case "vcs:issueReopen": {
308
- if (!vcs.issueId)
309
- break;
337
+ if (!vcs.issueId) break;
310
338
  const eid = issueEntityId(vcs.issueId);
311
339
  result.addFacts.push({ e: eid, a: "status", v: "queue" });
312
340
  break;
313
341
  }
314
342
  case "vcs:criterionAdd": {
315
- if (!vcs.criterionId || !vcs.issueId)
316
- break;
343
+ if (!vcs.criterionId || !vcs.issueId) break;
317
344
  const ceid = vcs.criterionId;
318
- result.addFacts.push({ e: ceid, a: "type", v: "Criterion" }, { e: ceid, a: "status", v: "pending" }, { e: ceid, a: "createdAt", v: op.timestamp });
345
+ result.addFacts.push(
346
+ { e: ceid, a: "type", v: "Criterion" },
347
+ { e: ceid, a: "status", v: "pending" },
348
+ { e: ceid, a: "createdAt", v: op.timestamp }
349
+ );
319
350
  if (vcs.criterionDescription) {
320
351
  result.addFacts.push({
321
352
  e: ceid,
@@ -338,8 +369,7 @@ function decompose(op) {
338
369
  break;
339
370
  }
340
371
  case "vcs:criterionUpdate": {
341
- if (!vcs.criterionId)
342
- break;
372
+ if (!vcs.criterionId) break;
343
373
  const ceid = vcs.criterionId;
344
374
  if (vcs.criterionStatus) {
345
375
  result.addFacts.push({ e: ceid, a: "status", v: vcs.criterionStatus });
@@ -354,27 +384,30 @@ function decompose(op) {
354
384
  result.addFacts.push({ e: ceid, a: "lastRunAt", v: op.timestamp });
355
385
  break;
356
386
  }
387
+ // ----- Issue blocking -----
357
388
  case "vcs:issueBlock": {
358
- if (!vcs.issueId || !vcs.blockedByIssueId)
359
- break;
389
+ if (!vcs.issueId || !vcs.blockedByIssueId) break;
360
390
  const eid = issueEntityId(vcs.issueId);
361
391
  const blockerEid = issueEntityId(vcs.blockedByIssueId);
362
392
  result.addLinks.push({ e1: eid, a: "blockedBy", e2: blockerEid });
363
393
  break;
364
394
  }
365
395
  case "vcs:issueUnblock": {
366
- if (!vcs.issueId || !vcs.blockedByIssueId)
367
- break;
396
+ if (!vcs.issueId || !vcs.blockedByIssueId) break;
368
397
  const eid = issueEntityId(vcs.issueId);
369
398
  const blockerEid = issueEntityId(vcs.blockedByIssueId);
370
399
  result.deleteLinks.push({ e1: eid, a: "blockedBy", e2: blockerEid });
371
400
  break;
372
401
  }
402
+ // ----- Decision traces -----
373
403
  case "vcs:decisionRecord": {
374
- if (!vcs.decisionId)
375
- break;
404
+ if (!vcs.decisionId) break;
376
405
  const did = decisionEntityId(vcs.decisionId);
377
- result.addFacts.push({ e: did, a: "type", v: "Decision" }, { e: did, a: "createdAt", v: op.timestamp }, { e: did, a: "createdBy", v: op.agentId });
406
+ result.addFacts.push(
407
+ { e: did, a: "type", v: "Decision" },
408
+ { e: did, a: "createdAt", v: op.timestamp },
409
+ { e: did, a: "createdBy", v: op.agentId }
410
+ );
378
411
  if (vcs.decisionToolName) {
379
412
  result.addFacts.push({
380
413
  e: did,
@@ -416,10 +449,14 @@ function decompose(op) {
416
449
  break;
417
450
  }
418
451
  case "vcs:laneCreate": {
419
- if (!vcs.laneId)
420
- break;
452
+ if (!vcs.laneId) break;
421
453
  const lid = laneEntityId(vcs.laneId);
422
- result.addFacts.push({ e: lid, a: "type", v: "AgentLane" }, { e: lid, a: "status", v: "active" }, { e: lid, a: "createdAt", v: op.timestamp }, { e: lid, a: "createdBy", v: op.agentId });
454
+ result.addFacts.push(
455
+ { e: lid, a: "type", v: "AgentLane" },
456
+ { e: lid, a: "status", v: "active" },
457
+ { e: lid, a: "createdAt", v: op.timestamp },
458
+ { e: lid, a: "createdBy", v: op.agentId }
459
+ );
423
460
  if (vcs.baseBranch) {
424
461
  result.addFacts.push({ e: lid, a: "baseBranch", v: vcs.baseBranch });
425
462
  }
@@ -459,8 +496,7 @@ function decompose(op) {
459
496
  break;
460
497
  }
461
498
  case "vcs:laneDrop": {
462
- if (!vcs.laneId)
463
- break;
499
+ if (!vcs.laneId) break;
464
500
  const lid = laneEntityId(vcs.laneId);
465
501
  if (vcs.laneStatus) {
466
502
  result.deleteFacts.push({ e: lid, a: "status", v: "active" });
@@ -469,16 +505,14 @@ function decompose(op) {
469
505
  break;
470
506
  }
471
507
  case "vcs:lanePromoteStart": {
472
- if (!vcs.laneId)
473
- break;
508
+ if (!vcs.laneId) break;
474
509
  const lid = laneEntityId(vcs.laneId);
475
510
  result.deleteFacts.push({ e: lid, a: "status", v: "active" });
476
511
  result.addFacts.push({ e: lid, a: "status", v: "promoting" });
477
512
  break;
478
513
  }
479
514
  case "vcs:lanePromoteComplete": {
480
- if (!vcs.laneId)
481
- break;
515
+ if (!vcs.laneId) break;
482
516
  const lid = laneEntityId(vcs.laneId);
483
517
  result.deleteFacts.push({ e: lid, a: "status", v: "promoting" });
484
518
  result.addFacts.push({ e: lid, a: "status", v: "promoted" });
@@ -488,13 +522,13 @@ function decompose(op) {
488
522
  break;
489
523
  }
490
524
  case "vcs:lanePromoteAbort": {
491
- if (!vcs.laneId)
492
- break;
525
+ if (!vcs.laneId) break;
493
526
  const lid = laneEntityId(vcs.laneId);
494
527
  result.deleteFacts.push({ e: lid, a: "status", v: "promoting" });
495
528
  result.addFacts.push({ e: lid, a: "status", v: "active" });
496
529
  break;
497
530
  }
531
+ // ----- EAV store (CMS / knowledge graph) -----
498
532
  case "vcs:storeAssert": {
499
533
  result.addFacts.push(...pickFacts(vcs.facts));
500
534
  break;
@@ -514,89 +548,120 @@ function decompose(op) {
514
548
  }
515
549
  return result;
516
550
  }
517
- var init_decompose = __esm(() => {
518
- init_types();
551
+ var init_decompose = __esm({
552
+ "src/vcs/decompose.ts"() {
553
+ "use strict";
554
+ init_types();
555
+ }
519
556
  });
520
557
 
521
558
  // src/vcs/blob-store.ts
522
559
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
523
560
  import { join } from "path";
524
-
525
- class BlobStore {
526
- blobDir;
527
- constructor(trellisDir) {
528
- this.blobDir = join(trellisDir, "blobs");
529
- if (!existsSync(this.blobDir)) {
530
- mkdirSync(this.blobDir, { recursive: true });
531
- }
532
- }
533
- async put(content) {
534
- const hash = await this.hash(content);
535
- const blobPath = join(this.blobDir, hash);
536
- if (!existsSync(blobPath)) {
537
- writeFileSync(blobPath, content);
538
- }
539
- return hash;
540
- }
541
- putSync(content) {
542
- const hash = this.hashSync(content);
543
- const blobPath = join(this.blobDir, hash);
544
- if (!existsSync(blobPath)) {
545
- writeFileSync(blobPath, content);
546
- }
547
- return hash;
548
- }
549
- get(hash) {
550
- const blobPath = join(this.blobDir, hash);
551
- if (!existsSync(blobPath)) {
552
- return null;
553
- }
554
- return readFileSync(blobPath);
555
- }
556
- has(hash) {
557
- return existsSync(join(this.blobDir, hash));
558
- }
559
- async hash(content) {
560
- const hashBuffer = await crypto.subtle.digest("SHA-256", content);
561
- return this.hexFromBuffer(hashBuffer);
562
- }
563
- hashSync(content) {
564
- if (typeof globalThis.Bun !== "undefined") {
565
- const hasher = new globalThis.Bun.CryptoHasher("sha256");
566
- hasher.update(content);
567
- return hasher.digest("hex");
568
- }
569
- const { createHash } = __require("crypto");
570
- return createHash("sha256").update(content).digest("hex");
571
- }
572
- count() {
573
- try {
574
- const { readdirSync } = __require("fs");
575
- return readdirSync(this.blobDir).length;
576
- } catch {
577
- return 0;
578
- }
579
- }
580
- totalSize() {
581
- try {
582
- const { readdirSync, statSync } = __require("fs");
583
- const files = readdirSync(this.blobDir);
584
- return files.reduce((sum, f) => {
561
+ var BlobStore;
562
+ var init_blob_store = __esm({
563
+ "src/vcs/blob-store.ts"() {
564
+ "use strict";
565
+ BlobStore = class {
566
+ blobDir;
567
+ constructor(trellisDir) {
568
+ this.blobDir = join(trellisDir, "blobs");
569
+ if (!existsSync(this.blobDir)) {
570
+ mkdirSync(this.blobDir, { recursive: true });
571
+ }
572
+ }
573
+ /**
574
+ * Store content and return its SHA-256 hash.
575
+ * Idempotent — storing the same content twice is a no-op.
576
+ */
577
+ async put(content) {
578
+ const hash = await this.hash(content);
579
+ const blobPath = join(this.blobDir, hash);
580
+ if (!existsSync(blobPath)) {
581
+ writeFileSync(blobPath, content);
582
+ }
583
+ return hash;
584
+ }
585
+ /**
586
+ * Synchronous put — uses Bun's sync crypto if available.
587
+ */
588
+ putSync(content) {
589
+ const hash = this.hashSync(content);
590
+ const blobPath = join(this.blobDir, hash);
591
+ if (!existsSync(blobPath)) {
592
+ writeFileSync(blobPath, content);
593
+ }
594
+ return hash;
595
+ }
596
+ /**
597
+ * Retrieve content by hash. Returns null if not found.
598
+ */
599
+ get(hash) {
600
+ const blobPath = join(this.blobDir, hash);
601
+ if (!existsSync(blobPath)) {
602
+ return null;
603
+ }
604
+ return readFileSync(blobPath);
605
+ }
606
+ /**
607
+ * Check if a blob exists.
608
+ */
609
+ has(hash) {
610
+ return existsSync(join(this.blobDir, hash));
611
+ }
612
+ /**
613
+ * Compute SHA-256 hash of content (async).
614
+ */
615
+ async hash(content) {
616
+ const hashBuffer = await crypto.subtle.digest(
617
+ "SHA-256",
618
+ content
619
+ );
620
+ return this.hexFromBuffer(hashBuffer);
621
+ }
622
+ /**
623
+ * Compute SHA-256 hash of content (sync).
624
+ * Uses Bun.CryptoHasher when running under Bun, else node:crypto.
625
+ */
626
+ hashSync(content) {
627
+ const { createHash } = __require("crypto");
628
+ return createHash("sha256").update(content).digest("hex");
629
+ }
630
+ /**
631
+ * Returns the number of blobs stored.
632
+ */
633
+ count() {
585
634
  try {
586
- return sum + statSync(join(this.blobDir, f)).size;
635
+ const { readdirSync: readdirSync2 } = __require("fs");
636
+ return readdirSync2(this.blobDir).length;
587
637
  } catch {
588
- return sum;
638
+ return 0;
589
639
  }
590
- }, 0);
591
- } catch {
592
- return 0;
593
- }
594
- }
595
- hexFromBuffer(buffer) {
596
- return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
640
+ }
641
+ /**
642
+ * Returns the total size of all blobs in bytes.
643
+ */
644
+ totalSize() {
645
+ try {
646
+ const { readdirSync: readdirSync2, statSync } = __require("fs");
647
+ const files = readdirSync2(this.blobDir);
648
+ return files.reduce((sum, f) => {
649
+ try {
650
+ return sum + statSync(join(this.blobDir, f)).size;
651
+ } catch {
652
+ return sum;
653
+ }
654
+ }, 0);
655
+ } catch {
656
+ return 0;
657
+ }
658
+ }
659
+ hexFromBuffer(buffer) {
660
+ return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
661
+ }
662
+ };
597
663
  }
598
- }
599
- var init_blob_store = () => {};
664
+ });
600
665
 
601
666
  // src/vcs/branch.ts
602
667
  import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
@@ -676,19 +741,23 @@ function loadBranchState(rootPath) {
676
741
  activeLaneId: state.activeLaneId
677
742
  };
678
743
  }
679
- } catch {}
744
+ } catch {
745
+ }
680
746
  }
681
747
  return { currentBranch: "main" };
682
748
  }
683
749
  var BRANCH_ADVANCE_SKIP_KINDS;
684
- var init_branch = __esm(() => {
685
- init_ops();
686
- BRANCH_ADVANCE_SKIP_KINDS = new Set([
687
- "vcs:branchAdvance",
688
- "vcs:branchCreate",
689
- "vcs:branchDelete",
690
- "vcs:checkpointCreate"
691
- ]);
750
+ var init_branch = __esm({
751
+ "src/vcs/branch.ts"() {
752
+ "use strict";
753
+ init_ops();
754
+ BRANCH_ADVANCE_SKIP_KINDS = /* @__PURE__ */ new Set([
755
+ "vcs:branchAdvance",
756
+ "vcs:branchCreate",
757
+ "vcs:branchDelete",
758
+ "vcs:checkpointCreate"
759
+ ]);
760
+ }
692
761
  });
693
762
 
694
763
  // src/vcs/milestone.ts
@@ -715,7 +784,9 @@ async function createMilestone(ctx, message, opts) {
715
784
  const toIdx = ops.findIndex((o) => o.hash === toOpHash);
716
785
  const rangeOps = fromIdx >= 0 && toIdx >= 0 ? ops.slice(fromIdx, toIdx + 1) : ops;
717
786
  const affectedFiles = [
718
- ...new Set(rangeOps.filter((o) => o.vcs?.filePath).map((o) => o.vcs.filePath))
787
+ ...new Set(
788
+ rangeOps.filter((o) => o.vcs?.filePath).map((o) => o.vcs.filePath)
789
+ )
719
790
  ];
720
791
  const op = await createVcsOp("vcs:milestoneCreate", {
721
792
  agentId: ctx.agentId,
@@ -750,8 +821,11 @@ function listMilestones(ctx) {
750
821
  };
751
822
  });
752
823
  }
753
- var init_milestone = __esm(() => {
754
- init_ops();
824
+ var init_milestone = __esm({
825
+ "src/vcs/milestone.ts"() {
826
+ "use strict";
827
+ init_ops();
828
+ }
755
829
  });
756
830
 
757
831
  // src/vcs/checkpoint.ts
@@ -777,16 +851,18 @@ function listCheckpoints(ctx) {
777
851
  };
778
852
  });
779
853
  }
780
- var init_checkpoint = __esm(() => {
781
- init_ops();
854
+ var init_checkpoint = __esm({
855
+ "src/vcs/checkpoint.ts"() {
856
+ "use strict";
857
+ init_ops();
858
+ }
782
859
  });
783
860
 
784
861
  // src/vcs/diff.ts
785
862
  function diffFileStates(stateA, stateB, blobStore) {
786
863
  const diffs = [];
787
864
  for (const [path, bState] of stateB) {
788
- if (bState.deleted)
789
- continue;
865
+ if (bState.deleted) continue;
790
866
  const aState = stateA.get(path);
791
867
  if (!aState || aState.deleted) {
792
868
  diffs.push({
@@ -805,15 +881,18 @@ function diffFileStates(stateA, stateB, blobStore) {
805
881
  const oldContent = blobStore.get(aState.contentHash);
806
882
  const newContent = blobStore.get(bState.contentHash);
807
883
  if (oldContent && newContent) {
808
- diff.unifiedDiff = generateUnifiedDiff(path, oldContent.toString("utf-8"), newContent.toString("utf-8"));
884
+ diff.unifiedDiff = generateUnifiedDiff(
885
+ path,
886
+ oldContent.toString("utf-8"),
887
+ newContent.toString("utf-8")
888
+ );
809
889
  }
810
890
  }
811
891
  diffs.push(diff);
812
892
  }
813
893
  }
814
894
  for (const [path, aState] of stateA) {
815
- if (aState.deleted)
816
- continue;
895
+ if (aState.deleted) continue;
817
896
  const bState = stateB.get(path);
818
897
  if (!bState || bState.deleted) {
819
898
  diffs.push({
@@ -836,7 +915,7 @@ function diffFileStates(stateA, stateB, blobStore) {
836
915
  };
837
916
  }
838
917
  function buildFileStateAtOp(ops, atOpHash) {
839
- const state = new Map;
918
+ const state = /* @__PURE__ */ new Map();
840
919
  for (const op of ops) {
841
920
  if (op.vcs?.filePath) {
842
921
  switch (op.kind) {
@@ -855,8 +934,7 @@ function buildFileStateAtOp(ops, atOpHash) {
855
934
  break;
856
935
  }
857
936
  }
858
- if (atOpHash && op.hash === atOpHash)
859
- break;
937
+ if (atOpHash && op.hash === atOpHash) break;
860
938
  }
861
939
  return state;
862
940
  }
@@ -866,17 +944,16 @@ function diffOpRange(ops, fromHash, toHash, blobStore) {
866
944
  return diffFileStates(stateA, stateB, blobStore);
867
945
  }
868
946
  function generateUnifiedDiff(filePath, oldText, newText, contextLines = 3) {
869
- const oldLines = oldText.split(`
870
- `);
871
- const newLines = newText.split(`
872
- `);
947
+ const oldLines = oldText.split("\n");
948
+ const newLines = newText.split("\n");
873
949
  const edits = myersDiff(oldLines, newLines);
874
950
  const hunks = buildHunks(edits, contextLines);
875
- if (hunks.length === 0)
876
- return "";
951
+ if (hunks.length === 0) return "";
877
952
  const lines = [`--- a/${filePath}`, `+++ b/${filePath}`];
878
953
  for (const hunk of hunks) {
879
- lines.push(`@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@`);
954
+ lines.push(
955
+ `@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@`
956
+ );
880
957
  for (const edit of hunk.edits) {
881
958
  switch (edit.kind) {
882
959
  case "equal":
@@ -891,14 +968,12 @@ function generateUnifiedDiff(filePath, oldText, newText, contextLines = 3) {
891
968
  }
892
969
  }
893
970
  }
894
- return lines.join(`
895
- `);
971
+ return lines.join("\n");
896
972
  }
897
973
  function myersDiff(oldLines, newLines) {
898
974
  const n = oldLines.length;
899
975
  const m = newLines.length;
900
- if (n === 0 && m === 0)
901
- return [];
976
+ if (n === 0 && m === 0) return [];
902
977
  if (n === 0)
903
978
  return newLines.map((line) => ({ kind: "insert", line }));
904
979
  if (m === 0)
@@ -908,30 +983,28 @@ function myersDiff(oldLines, newLines) {
908
983
  const v = new Int32Array(size);
909
984
  const trace = [];
910
985
  const off = max;
911
- outer:
912
- for (let d = 0;d <= max; d++) {
913
- trace.push(v.slice());
914
- for (let k = -d;k <= d; k += 2) {
915
- let x2;
916
- if (k === -d || k !== d && v[k - 1 + off] < v[k + 1 + off]) {
917
- x2 = v[k + 1 + off];
918
- } else {
919
- x2 = v[k - 1 + off] + 1;
920
- }
921
- let y2 = x2 - k;
922
- while (x2 < n && y2 < m && oldLines[x2] === newLines[y2]) {
923
- x2++;
924
- y2++;
925
- }
926
- v[k + off] = x2;
927
- if (x2 >= n && y2 >= m)
928
- break outer;
986
+ outer: for (let d = 0; d <= max; d++) {
987
+ trace.push(v.slice());
988
+ for (let k = -d; k <= d; k += 2) {
989
+ let x2;
990
+ if (k === -d || k !== d && v[k - 1 + off] < v[k + 1 + off]) {
991
+ x2 = v[k + 1 + off];
992
+ } else {
993
+ x2 = v[k - 1 + off] + 1;
929
994
  }
995
+ let y2 = x2 - k;
996
+ while (x2 < n && y2 < m && oldLines[x2] === newLines[y2]) {
997
+ x2++;
998
+ y2++;
999
+ }
1000
+ v[k + off] = x2;
1001
+ if (x2 >= n && y2 >= m) break outer;
930
1002
  }
1003
+ }
931
1004
  let x = n;
932
1005
  let y = m;
933
1006
  const edits = [];
934
- for (let d = trace.length - 1;d >= 0; d--) {
1007
+ for (let d = trace.length - 1; d >= 0; d--) {
935
1008
  const tv = trace[d];
936
1009
  const k = x - y;
937
1010
  let prevK;
@@ -967,22 +1040,23 @@ function myersDiff(oldLines, newLines) {
967
1040
  return edits;
968
1041
  }
969
1042
  function buildHunks(edits, contextLines) {
970
- if (edits.length === 0)
971
- return [];
1043
+ if (edits.length === 0) return [];
972
1044
  const changeIndices = [];
973
- for (let i = 0;i < edits.length; i++) {
1045
+ for (let i = 0; i < edits.length; i++) {
974
1046
  if (edits[i].kind !== "equal") {
975
1047
  changeIndices.push(i);
976
1048
  }
977
1049
  }
978
- if (changeIndices.length === 0)
979
- return [];
1050
+ if (changeIndices.length === 0) return [];
980
1051
  const hunks = [];
981
1052
  let hunkStart = Math.max(0, changeIndices[0] - contextLines);
982
1053
  let hunkEnd = Math.min(edits.length - 1, changeIndices[0] + contextLines);
983
- for (let i = 1;i < changeIndices.length; i++) {
1054
+ for (let i = 1; i < changeIndices.length; i++) {
984
1055
  const changeStart = changeIndices[i] - contextLines;
985
- const changeEnd = Math.min(edits.length - 1, changeIndices[i] + contextLines);
1056
+ const changeEnd = Math.min(
1057
+ edits.length - 1,
1058
+ changeIndices[i] + contextLines
1059
+ );
986
1060
  if (changeStart <= hunkEnd + 1) {
987
1061
  hunkEnd = changeEnd;
988
1062
  } else {
@@ -998,19 +1072,15 @@ function createHunk(edits, start, end) {
998
1072
  const hunkEdits = edits.slice(start, end + 1);
999
1073
  let oldLine = 1;
1000
1074
  let newLine = 1;
1001
- for (let i = 0;i < start; i++) {
1002
- if (edits[i].kind === "equal" || edits[i].kind === "delete")
1003
- oldLine++;
1004
- if (edits[i].kind === "equal" || edits[i].kind === "insert")
1005
- newLine++;
1075
+ for (let i = 0; i < start; i++) {
1076
+ if (edits[i].kind === "equal" || edits[i].kind === "delete") oldLine++;
1077
+ if (edits[i].kind === "equal" || edits[i].kind === "insert") newLine++;
1006
1078
  }
1007
1079
  let oldCount = 0;
1008
1080
  let newCount = 0;
1009
1081
  for (const edit of hunkEdits) {
1010
- if (edit.kind === "equal" || edit.kind === "delete")
1011
- oldCount++;
1012
- if (edit.kind === "equal" || edit.kind === "insert")
1013
- newCount++;
1082
+ if (edit.kind === "equal" || edit.kind === "delete") oldCount++;
1083
+ if (edit.kind === "equal" || edit.kind === "insert") newCount++;
1014
1084
  }
1015
1085
  return {
1016
1086
  oldStart: oldLine,
@@ -1020,28 +1090,22 @@ function createHunk(edits, start, end) {
1020
1090
  edits: hunkEdits
1021
1091
  };
1022
1092
  }
1023
- var init_diff = () => {};
1093
+ var init_diff = __esm({
1094
+ "src/vcs/diff.ts"() {
1095
+ "use strict";
1096
+ }
1097
+ });
1024
1098
 
1025
1099
  // src/vcs/merge.ts
1026
1100
  function threeWayMerge(base, ours, theirs, blobStore) {
1027
- const mergedFiles = new Map;
1101
+ const mergedFiles = /* @__PURE__ */ new Map();
1028
1102
  const conflicts = [];
1029
- const allPaths = new Set;
1030
- for (const [p, s] of base)
1031
- if (!s.deleted)
1032
- allPaths.add(p);
1033
- for (const [p, s] of ours)
1034
- if (!s.deleted)
1035
- allPaths.add(p);
1036
- for (const [p, s] of theirs)
1037
- if (!s.deleted)
1038
- allPaths.add(p);
1039
- for (const [p, s] of ours)
1040
- if (s.deleted)
1041
- allPaths.add(p);
1042
- for (const [p, s] of theirs)
1043
- if (s.deleted)
1044
- allPaths.add(p);
1103
+ const allPaths = /* @__PURE__ */ new Set();
1104
+ for (const [p, s] of base) if (!s.deleted) allPaths.add(p);
1105
+ for (const [p, s] of ours) if (!s.deleted) allPaths.add(p);
1106
+ for (const [p, s] of theirs) if (!s.deleted) allPaths.add(p);
1107
+ for (const [p, s] of ours) if (s.deleted) allPaths.add(p);
1108
+ for (const [p, s] of theirs) if (s.deleted) allPaths.add(p);
1045
1109
  for (const path of allPaths) {
1046
1110
  const b = base.get(path);
1047
1111
  const o = ours.get(path);
@@ -1049,9 +1113,9 @@ function threeWayMerge(base, ours, theirs, blobStore) {
1049
1113
  const baseExists = b && !b.deleted;
1050
1114
  const oursExists = o && !o.deleted;
1051
1115
  const theirsExists = t && !t.deleted;
1052
- const baseHash = baseExists ? b.contentHash : undefined;
1053
- const oursHash = oursExists ? o.contentHash : undefined;
1054
- const theirsHash = theirsExists ? t.contentHash : undefined;
1116
+ const baseHash = baseExists ? b.contentHash : void 0;
1117
+ const oursHash = oursExists ? o.contentHash : void 0;
1118
+ const theirsHash = theirsExists ? t.contentHash : void 0;
1055
1119
  if (oursHash === theirsHash) {
1056
1120
  continue;
1057
1121
  }
@@ -1076,9 +1140,9 @@ function threeWayMerge(base, ours, theirs, blobStore) {
1076
1140
  if (oursHash === theirsHash) {
1077
1141
  continue;
1078
1142
  }
1079
- const oursContent = oursHash && blobStore ? blobStore.get(oursHash)?.toString("utf-8") : undefined;
1080
- const theirsContent = theirsHash && blobStore ? blobStore.get(theirsHash)?.toString("utf-8") : undefined;
1081
- if (oursContent !== undefined && theirsContent !== undefined) {
1143
+ const oursContent = oursHash && blobStore ? blobStore.get(oursHash)?.toString("utf-8") : void 0;
1144
+ const theirsContent = theirsHash && blobStore ? blobStore.get(theirsHash)?.toString("utf-8") : void 0;
1145
+ if (oursContent !== void 0 && theirsContent !== void 0) {
1082
1146
  const textResult = threeWayTextMerge("", oursContent, theirsContent);
1083
1147
  if (textResult.clean) {
1084
1148
  mergedFiles.set(path, textResult.merged);
@@ -1100,7 +1164,7 @@ function threeWayMerge(base, ours, theirs, blobStore) {
1100
1164
  conflicts.push({
1101
1165
  path,
1102
1166
  kind: "modify-delete",
1103
- ours: oursHash && blobStore ? blobStore.get(oursHash)?.toString("utf-8") : undefined
1167
+ ours: oursHash && blobStore ? blobStore.get(oursHash)?.toString("utf-8") : void 0
1104
1168
  });
1105
1169
  continue;
1106
1170
  }
@@ -1108,15 +1172,15 @@ function threeWayMerge(base, ours, theirs, blobStore) {
1108
1172
  conflicts.push({
1109
1173
  path,
1110
1174
  kind: "modify-delete",
1111
- theirs: theirsHash && blobStore ? blobStore.get(theirsHash)?.toString("utf-8") : undefined
1175
+ theirs: theirsHash && blobStore ? blobStore.get(theirsHash)?.toString("utf-8") : void 0
1112
1176
  });
1113
1177
  continue;
1114
1178
  }
1115
1179
  if (oursExists && theirsExists && oursHash !== theirsHash) {
1116
- const baseContent = baseHash && blobStore ? blobStore.get(baseHash)?.toString("utf-8") : undefined;
1117
- const oursContent = oursHash && blobStore ? blobStore.get(oursHash)?.toString("utf-8") : undefined;
1118
- const theirsContent = theirsHash && blobStore ? blobStore.get(theirsHash)?.toString("utf-8") : undefined;
1119
- if (baseContent !== undefined && oursContent !== undefined && theirsContent !== undefined) {
1180
+ const baseContent = baseHash && blobStore ? blobStore.get(baseHash)?.toString("utf-8") : void 0;
1181
+ const oursContent = oursHash && blobStore ? blobStore.get(oursHash)?.toString("utf-8") : void 0;
1182
+ const theirsContent = theirsHash && blobStore ? blobStore.get(theirsHash)?.toString("utf-8") : void 0;
1183
+ if (baseContent !== void 0 && oursContent !== void 0 && theirsContent !== void 0) {
1120
1184
  const textResult = threeWayTextMerge(baseContent, oursContent, theirsContent);
1121
1185
  if (textResult.clean) {
1122
1186
  mergedFiles.set(path, textResult.merged);
@@ -1151,18 +1215,16 @@ function threeWayMerge(base, ours, theirs, blobStore) {
1151
1215
  stats: {
1152
1216
  added,
1153
1217
  modified: added,
1218
+ // in a merge context, additions from theirs are "modified"
1154
1219
  deleted,
1155
1220
  conflicted: conflicts.length
1156
1221
  }
1157
1222
  };
1158
1223
  }
1159
1224
  function threeWayTextMerge(baseText, oursText, theirsText) {
1160
- const baseLines = baseText.split(`
1161
- `);
1162
- const oursLines = oursText.split(`
1163
- `);
1164
- const theirsLines = theirsText.split(`
1165
- `);
1225
+ const baseLines = baseText.split("\n");
1226
+ const oursLines = oursText.split("\n");
1227
+ const theirsLines = theirsText.split("\n");
1166
1228
  const oursChanges = computeLineChanges(baseLines, oursLines);
1167
1229
  const theirsChanges = computeLineChanges(baseLines, theirsLines);
1168
1230
  const result = [];
@@ -1198,9 +1260,7 @@ function threeWayTextMerge(baseText, oursText, theirsText) {
1198
1260
  oursIdx += theirsChange.baseCount;
1199
1261
  theirsIdx += theirsChange.newCount;
1200
1262
  } else if (oursChange && theirsChange) {
1201
- if (oursChange.baseCount === theirsChange.baseCount && oursChange.newLines.join(`
1202
- `) === theirsChange.newLines.join(`
1203
- `)) {
1263
+ if (oursChange.baseCount === theirsChange.baseCount && oursChange.newLines.join("\n") === theirsChange.newLines.join("\n")) {
1204
1264
  applyChange(oursChange, result);
1205
1265
  baseIdx += oursChange.baseCount;
1206
1266
  oursIdx += oursChange.newCount;
@@ -1208,11 +1268,9 @@ function threeWayTextMerge(baseText, oursText, theirsText) {
1208
1268
  } else {
1209
1269
  clean = false;
1210
1270
  result.push("<<<<<<< ours");
1211
- for (const line of oursChange.newLines)
1212
- result.push(line);
1271
+ for (const line of oursChange.newLines) result.push(line);
1213
1272
  result.push("=======");
1214
- for (const line of theirsChange.newLines)
1215
- result.push(line);
1273
+ for (const line of theirsChange.newLines) result.push(line);
1216
1274
  result.push(">>>>>>> theirs");
1217
1275
  baseIdx += Math.max(oursChange.baseCount, theirsChange.baseCount);
1218
1276
  oursIdx += oursChange.newCount;
@@ -1220,8 +1278,7 @@ function threeWayTextMerge(baseText, oursText, theirsText) {
1220
1278
  }
1221
1279
  }
1222
1280
  }
1223
- return { clean, merged: result.join(`
1224
- `) };
1281
+ return { clean, merged: result.join("\n") };
1225
1282
  }
1226
1283
  function applyChange(change, result) {
1227
1284
  for (const line of change.newLines) {
@@ -1229,7 +1286,7 @@ function applyChange(change, result) {
1229
1286
  }
1230
1287
  }
1231
1288
  function computeLineChanges(baseLines, newLines) {
1232
- const changes = new Map;
1289
+ const changes = /* @__PURE__ */ new Map();
1233
1290
  const matches = lcsMatch(baseLines, newLines);
1234
1291
  let baseIdx = 0;
1235
1292
  let newIdx = 0;
@@ -1266,11 +1323,13 @@ function computeLineChanges(baseLines, newLines) {
1266
1323
  function lcsMatch(a, b) {
1267
1324
  const n = a.length;
1268
1325
  const m = b.length;
1269
- if (n === 0 || m === 0)
1270
- return [];
1271
- const dp = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
1272
- for (let i2 = 1;i2 <= n; i2++) {
1273
- for (let j2 = 1;j2 <= m; j2++) {
1326
+ if (n === 0 || m === 0) return [];
1327
+ const dp = Array.from(
1328
+ { length: n + 1 },
1329
+ () => new Array(m + 1).fill(0)
1330
+ );
1331
+ for (let i2 = 1; i2 <= n; i2++) {
1332
+ for (let j2 = 1; j2 <= m; j2++) {
1274
1333
  if (a[i2 - 1] === b[j2 - 1]) {
1275
1334
  dp[i2][j2] = dp[i2 - 1][j2 - 1] + 1;
1276
1335
  } else {
@@ -1294,7 +1353,11 @@ function lcsMatch(a, b) {
1294
1353
  }
1295
1354
  return matches;
1296
1355
  }
1297
- var init_merge = () => {};
1356
+ var init_merge = __esm({
1357
+ "src/vcs/merge.ts"() {
1358
+ "use strict";
1359
+ }
1360
+ });
1298
1361
 
1299
1362
  // src/vcs/issue.ts
1300
1363
  import { exec } from "child_process";
@@ -1315,10 +1378,9 @@ function getIssueCounterPath(rootPath) {
1315
1378
  function nextIssueId(rootPath) {
1316
1379
  const counterPath = getIssueCounterPath(rootPath);
1317
1380
  const dir = dirname2(counterPath);
1318
- if (!existsSync3(dir))
1319
- mkdirSync2(dir, { recursive: true });
1381
+ if (!existsSync3(dir)) mkdirSync2(dir, { recursive: true });
1320
1382
  const lockPath = `${counterPath}.lock`;
1321
- const deadline = Date.now() + 5000;
1383
+ const deadline = Date.now() + 5e3;
1322
1384
  let lockFd;
1323
1385
  while (Date.now() < deadline) {
1324
1386
  try {
@@ -1330,15 +1392,18 @@ function nextIssueId(rootPath) {
1330
1392
  }
1331
1393
  }
1332
1394
  }
1333
- if (lockFd === undefined) {
1334
- throw new Error(`Timed out waiting for issue counter lock: ${lockPath}. Another Trellis process may be stalled.`);
1395
+ if (lockFd === void 0) {
1396
+ throw new Error(
1397
+ `Timed out waiting for issue counter lock: ${lockPath}. Another Trellis process may be stalled.`
1398
+ );
1335
1399
  }
1336
1400
  try {
1337
1401
  let counter = 0;
1338
1402
  if (existsSync3(counterPath)) {
1339
1403
  try {
1340
1404
  counter = JSON.parse(readFileSync3(counterPath, "utf-8")).counter ?? 0;
1341
- } catch {}
1405
+ } catch {
1406
+ }
1342
1407
  }
1343
1408
  counter++;
1344
1409
  writeFileSync3(counterPath, JSON.stringify({ counter }, null, 2));
@@ -1347,13 +1412,14 @@ function nextIssueId(rootPath) {
1347
1412
  closeSync(lockFd);
1348
1413
  try {
1349
1414
  unlinkSync(lockPath);
1350
- } catch {}
1415
+ } catch {
1416
+ }
1351
1417
  }
1352
1418
  }
1353
1419
  function getIssueFact(ctx, entityId, attr) {
1354
1420
  const facts = ctx.store.getFactsByEntity(entityId);
1355
1421
  const matches = facts.filter((f) => f.a === attr);
1356
- return matches.length > 0 ? matches[matches.length - 1].v : undefined;
1422
+ return matches.length > 0 ? matches[matches.length - 1].v : void 0;
1357
1423
  }
1358
1424
  function getIssueLinks(ctx, entityId, attr) {
1359
1425
  const links = ctx.store.getLinksByEntity(entityId);
@@ -1367,7 +1433,7 @@ function getCriteriaForIssue(ctx, issueId) {
1367
1433
  const facts = ctx.store.getFactsByEntity(ceid);
1368
1434
  const getLast = (a) => {
1369
1435
  const matches = facts.filter((f) => f.a === a);
1370
- return matches.length > 0 ? matches[matches.length - 1].v : undefined;
1436
+ return matches.length > 0 ? matches[matches.length - 1].v : void 0;
1371
1437
  };
1372
1438
  return {
1373
1439
  id: ceid,
@@ -1383,14 +1449,14 @@ function buildIssueInfo(ctx, entityId) {
1383
1449
  const facts = ctx.store.getFactsByEntity(entityId);
1384
1450
  const get = (a) => {
1385
1451
  const matches = facts.filter((f) => f.a === a);
1386
- return matches.length > 0 ? matches[matches.length - 1].v : undefined;
1452
+ return matches.length > 0 ? matches[matches.length - 1].v : void 0;
1387
1453
  };
1388
1454
  const labelsStr = get("labels");
1389
1455
  const labels = labelsStr ? labelsStr.split(",").filter(Boolean) : [];
1390
1456
  const trackedOnLinks = getIssueLinks(ctx, entityId, "trackedOn");
1391
- const branchName = trackedOnLinks.length > 0 ? trackedOnLinks[0].replace(/^branch:/, "") : undefined;
1457
+ const branchName = trackedOnLinks.length > 0 ? trackedOnLinks[0].replace(/^branch:/, "") : void 0;
1392
1458
  const childOfLinks = getIssueLinks(ctx, entityId, "childOf");
1393
- const parentId = childOfLinks.length > 0 ? childOfLinks[0].replace(/^issue:/, "") : undefined;
1459
+ const parentId = childOfLinks.length > 0 ? childOfLinks[0].replace(/^issue:/, "") : void 0;
1394
1460
  const bareId = entityId.replace(/^issue:/, "");
1395
1461
  const blockedByLinks = getIssueLinks(ctx, entityId, "blockedBy");
1396
1462
  const blockedBy = blockedByLinks.map((e) => e.replace(/^issue:/, ""));
@@ -1412,7 +1478,7 @@ function buildIssueInfo(ctx, entityId) {
1412
1478
  createdBy: get("createdBy"),
1413
1479
  startedAt: get("startedAt"),
1414
1480
  pausedAt: get("pausedAt"),
1415
- pauseNote: get("pauseNote") || undefined,
1481
+ pauseNote: get("pauseNote") || void 0,
1416
1482
  closedAt: get("closedAt"),
1417
1483
  parentId,
1418
1484
  branchName,
@@ -1440,8 +1506,13 @@ async function createIssue(ctx, rootPath, title, opts) {
1440
1506
  });
1441
1507
  await ctx.applyOp(op);
1442
1508
  if (opts?.criteria) {
1443
- for (let i = 0;i < opts.criteria.length; i++) {
1444
- await addCriterion(ctx, id, opts.criteria[i].description, opts.criteria[i].command);
1509
+ for (let i = 0; i < opts.criteria.length; i++) {
1510
+ await addCriterion(
1511
+ ctx,
1512
+ id,
1513
+ opts.criteria[i].description,
1514
+ opts.criteria[i].command
1515
+ );
1445
1516
  }
1446
1517
  }
1447
1518
  return op;
@@ -1452,21 +1523,16 @@ async function updateIssue(ctx, id, updates) {
1452
1523
  throw new Error(`Issue ${id} not found.`);
1453
1524
  }
1454
1525
  const vcs = { issueId: id };
1455
- if (updates.title !== undefined)
1456
- vcs.issueTitle = updates.title;
1457
- if (updates.description !== undefined)
1458
- vcs.issueDescription = updates.description;
1459
- if (updates.status !== undefined) {
1526
+ if (updates.title !== void 0) vcs.issueTitle = updates.title;
1527
+ if (updates.description !== void 0) vcs.issueDescription = updates.description;
1528
+ if (updates.status !== void 0) {
1460
1529
  vcs.oldIssueStatus = getIssueFact(ctx, issueEntityId(id), "status");
1461
1530
  vcs.issueStatus = updates.status;
1462
1531
  }
1463
- if (updates.priority !== undefined)
1464
- vcs.issuePriority = updates.priority;
1465
- if (updates.labels !== undefined)
1466
- vcs.issueLabels = updates.labels;
1467
- if (updates.assignee !== undefined)
1468
- vcs.issueAssignee = updates.assignee;
1469
- if (updates.parentId !== undefined) {
1532
+ if (updates.priority !== void 0) vcs.issuePriority = updates.priority;
1533
+ if (updates.labels !== void 0) vcs.issueLabels = updates.labels;
1534
+ if (updates.assignee !== void 0) vcs.issueAssignee = updates.assignee;
1535
+ if (updates.parentId !== void 0) {
1470
1536
  const newParent = updates.parentId;
1471
1537
  if (newParent === id) {
1472
1538
  throw new Error(`Issue ${id} cannot be its own parent.`);
@@ -1479,10 +1545,8 @@ async function updateIssue(ctx, id, updates) {
1479
1545
  }
1480
1546
  const currentParent = issue.parentId;
1481
1547
  if (newParent !== currentParent) {
1482
- if (currentParent)
1483
- vcs.oldParentIssueId = currentParent;
1484
- if (newParent)
1485
- vcs.parentIssueId = newParent;
1548
+ if (currentParent) vcs.oldParentIssueId = currentParent;
1549
+ if (newParent) vcs.parentIssueId = newParent;
1486
1550
  }
1487
1551
  }
1488
1552
  const op = await createVcsOp("vcs:issueUpdate", {
@@ -1517,12 +1581,16 @@ async function startIssue(ctx, id, branchName) {
1517
1581
  }
1518
1582
  async function pauseIssue(ctx, id, note) {
1519
1583
  if (!note || !note.trim()) {
1520
- throw new Error(`A pause note is required. Explain why the issue is paused and what must happen before resuming.`);
1584
+ throw new Error(
1585
+ `A pause note is required. Explain why the issue is paused and what must happen before resuming.`
1586
+ );
1521
1587
  }
1522
1588
  const eid = issueEntityId(id);
1523
1589
  const status = getIssueFact(ctx, eid, "status");
1524
1590
  if (status !== "in_progress") {
1525
- throw new Error(`Cannot pause issue ${id} \u2014 status is '${status}', expected 'in_progress'.`);
1591
+ throw new Error(
1592
+ `Cannot pause issue ${id} \u2014 status is '${status}', expected 'in_progress'.`
1593
+ );
1526
1594
  }
1527
1595
  const op = await createVcsOp("vcs:issuePause", {
1528
1596
  agentId: ctx.agentId,
@@ -1540,7 +1608,9 @@ async function resumeIssue(ctx, id) {
1540
1608
  const eid = issueEntityId(id);
1541
1609
  const status = getIssueFact(ctx, eid, "status");
1542
1610
  if (status !== "paused") {
1543
- throw new Error(`Cannot resume issue ${id} \u2014 status is '${status}', expected 'paused'.`);
1611
+ throw new Error(
1612
+ `Cannot resume issue ${id} \u2014 status is '${status}', expected 'paused'.`
1613
+ );
1544
1614
  }
1545
1615
  const op = await createVcsOp("vcs:issueResume", {
1546
1616
  agentId: ctx.agentId,
@@ -1566,9 +1636,10 @@ async function closeIssue(ctx, id, opts) {
1566
1636
  const allPassed = results.length === 0 || results.every((r) => r.status === "passed");
1567
1637
  if (!allPassed) {
1568
1638
  const failing = results.filter((r) => r.status !== "passed");
1569
- throw new Error(`Cannot close issue ${id}: ${failing.length} criteria not passing:
1570
- ` + failing.map((f) => ` - ${f.description ?? f.id} (${f.status})`).join(`
1571
- `));
1639
+ throw new Error(
1640
+ `Cannot close issue ${id}: ${failing.length} criteria not passing:
1641
+ ` + failing.map((f) => ` - ${f.description ?? f.id} (${f.status})`).join("\n")
1642
+ );
1572
1643
  }
1573
1644
  if (!opts?.confirm) {
1574
1645
  return { criteriaResults: results };
@@ -1590,7 +1661,9 @@ async function triageIssue(ctx, id) {
1590
1661
  const eid = issueEntityId(id);
1591
1662
  const status = getIssueFact(ctx, eid, "status");
1592
1663
  if (status !== "backlog") {
1593
- throw new Error(`Cannot triage issue ${id} \u2014 status is '${status}', expected 'backlog'.`);
1664
+ throw new Error(
1665
+ `Cannot triage issue ${id} \u2014 status is '${status}', expected 'backlog'.`
1666
+ );
1594
1667
  }
1595
1668
  const op = await createVcsOp("vcs:issueUpdate", {
1596
1669
  agentId: ctx.agentId,
@@ -1608,7 +1681,9 @@ async function reopenIssue(ctx, id) {
1608
1681
  const eid = issueEntityId(id);
1609
1682
  const status = getIssueFact(ctx, eid, "status");
1610
1683
  if (status !== "closed") {
1611
- throw new Error(`Cannot reopen issue ${id} \u2014 status is '${status}', expected 'closed'.`);
1684
+ throw new Error(
1685
+ `Cannot reopen issue ${id} \u2014 status is '${status}', expected 'closed'.`
1686
+ );
1612
1687
  }
1613
1688
  const op = await createVcsOp("vcs:issueReopen", {
1614
1689
  agentId: ctx.agentId,
@@ -1670,7 +1745,9 @@ async function addCriterion(ctx, issueId, description, command) {
1670
1745
  async function setCriterionStatus(ctx, issueId, criterionIndex, status) {
1671
1746
  const criteria = getCriteriaForIssue(ctx, issueId);
1672
1747
  if (criterionIndex < 1 || criterionIndex > criteria.length) {
1673
- throw new Error(`Criterion index ${criterionIndex} out of range (1\u2013${criteria.length})`);
1748
+ throw new Error(
1749
+ `Criterion index ${criterionIndex} out of range (1\u2013${criteria.length})`
1750
+ );
1674
1751
  }
1675
1752
  const c = criteria[criterionIndex - 1];
1676
1753
  const op = await createVcsOp("vcs:criterionUpdate", {
@@ -1703,15 +1780,13 @@ async function runCriteria(ctx, issueId, rootPath) {
1703
1780
  try {
1704
1781
  const result = await execAsync(c.command, {
1705
1782
  cwd: rootPath,
1706
- timeout: 120000
1783
+ timeout: 12e4
1707
1784
  });
1708
- output = (result.stdout + `
1709
- ` + result.stderr).trim();
1785
+ output = (result.stdout + "\n" + result.stderr).trim();
1710
1786
  exitCode = 0;
1711
1787
  status = "passed";
1712
1788
  } catch (err) {
1713
- output = (err.stdout ?? "") + `
1714
- ` + (err.stderr ?? err.message ?? "");
1789
+ output = (err.stdout ?? "") + "\n" + (err.stderr ?? err.message ?? "");
1715
1790
  output = output.trim();
1716
1791
  exitCode = err.code ?? 1;
1717
1792
  status = "failed";
@@ -1752,7 +1827,7 @@ function listIssues(ctx, filters) {
1752
1827
  if (filters?.parentId) {
1753
1828
  issues = issues.filter((i) => i.parentId === filters.parentId);
1754
1829
  }
1755
- if (filters?.blocked !== undefined) {
1830
+ if (filters?.blocked !== void 0) {
1756
1831
  issues = issues.filter((i) => i.isBlocked === filters.blocked);
1757
1832
  }
1758
1833
  return issues;
@@ -1760,8 +1835,7 @@ function listIssues(ctx, filters) {
1760
1835
  function getIssue(ctx, id) {
1761
1836
  const eid = issueEntityId(id);
1762
1837
  const typeFact = ctx.store.getFactsByEntity(eid).find((f) => f.a === "type" && f.v === "Issue");
1763
- if (!typeFact)
1764
- return null;
1838
+ if (!typeFact) return null;
1765
1839
  return buildIssueInfo(ctx, eid);
1766
1840
  }
1767
1841
  function getActiveIssues(ctx) {
@@ -1779,23 +1853,31 @@ function checkCompletionReadiness(ctx) {
1779
1853
  } else {
1780
1854
  parts.push("\u2717 Not ready for completion:");
1781
1855
  if (queue.length > 0) {
1782
- parts.push(` Queue (${queue.length}): ${queue.map((i) => i.id).join(", ")}`);
1856
+ parts.push(
1857
+ ` Queue (${queue.length}): ${queue.map((i) => i.id).join(", ")}`
1858
+ );
1783
1859
  }
1784
1860
  if (inProgress.length > 0) {
1785
- parts.push(` In progress (${inProgress.length}): ${inProgress.map((i) => i.id).join(", ")}`);
1861
+ parts.push(
1862
+ ` In progress (${inProgress.length}): ${inProgress.map((i) => i.id).join(", ")}`
1863
+ );
1786
1864
  }
1787
1865
  if (paused.length > 0) {
1788
- parts.push(` Paused (${paused.length}): ${paused.map((i) => `${i.id}${i.pauseNote ? ` \u2014 ${i.pauseNote}` : ""}`).join(", ")}`);
1866
+ parts.push(
1867
+ ` Paused (${paused.length}): ${paused.map((i) => `${i.id}${i.pauseNote ? ` \u2014 ${i.pauseNote}` : ""}`).join(", ")}`
1868
+ );
1789
1869
  }
1790
1870
  }
1791
- return { ready, queue, paused, inProgress, summary: parts.join(`
1792
- `) };
1871
+ return { ready, queue, paused, inProgress, summary: parts.join("\n") };
1793
1872
  }
1794
1873
  var execAsync;
1795
- var init_issue = __esm(() => {
1796
- init_ops();
1797
- init_types();
1798
- execAsync = promisify(exec);
1874
+ var init_issue = __esm({
1875
+ "src/vcs/issue.ts"() {
1876
+ "use strict";
1877
+ init_ops();
1878
+ init_types();
1879
+ execAsync = promisify(exec);
1880
+ }
1799
1881
  });
1800
1882
 
1801
1883
  // src/vcs/op-log.ts
@@ -1813,172 +1895,179 @@ import {
1813
1895
  import { dirname as dirname3 } from "path";
1814
1896
  function lockTimeoutMs() {
1815
1897
  const raw = process.env.TRELLIS_OPLOG_LOCK_MS;
1816
- if (!raw)
1817
- return 5000;
1898
+ if (!raw) return 5e3;
1818
1899
  const parsed = Number(raw);
1819
- return Number.isFinite(parsed) && parsed > 0 ? parsed : 5000;
1820
- }
1821
-
1822
- class JsonOpLog {
1823
- ops = [];
1824
- filePath;
1825
- lockPath;
1826
- constructor(filePath) {
1827
- this.filePath = filePath;
1828
- this.lockPath = `${filePath}.lock`;
1829
- }
1830
- get path() {
1831
- return this.filePath;
1832
- }
1833
- load() {
1834
- if (existsSync4(this.filePath)) {
1835
- const raw = readFileSync4(this.filePath, "utf-8");
1836
- try {
1837
- this.ops = JSON.parse(raw);
1838
- } catch {
1839
- const backupPath = this.filePath + ".bak";
1840
- if (existsSync4(backupPath)) {
1841
- const backupRaw = readFileSync4(backupPath, "utf-8");
1842
- this.ops = JSON.parse(backupRaw);
1843
- writeFileSync4(this.filePath, backupRaw);
1844
- } else {
1845
- throw new Error(`Corrupted ops log at ${this.filePath} and no backup found. Run \`trellis repair\` to attempt recovery.`);
1900
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 5e3;
1901
+ }
1902
+ var JsonOpLog, LaneOpLog;
1903
+ var init_op_log = __esm({
1904
+ "src/vcs/op-log.ts"() {
1905
+ "use strict";
1906
+ JsonOpLog = class {
1907
+ ops = [];
1908
+ filePath;
1909
+ lockPath;
1910
+ constructor(filePath) {
1911
+ this.filePath = filePath;
1912
+ this.lockPath = `${filePath}.lock`;
1913
+ }
1914
+ get path() {
1915
+ return this.filePath;
1916
+ }
1917
+ load() {
1918
+ if (existsSync4(this.filePath)) {
1919
+ const raw = readFileSync4(this.filePath, "utf-8");
1920
+ try {
1921
+ this.ops = JSON.parse(raw);
1922
+ } catch {
1923
+ const backupPath = this.filePath + ".bak";
1924
+ if (existsSync4(backupPath)) {
1925
+ const backupRaw = readFileSync4(backupPath, "utf-8");
1926
+ this.ops = JSON.parse(backupRaw);
1927
+ writeFileSync4(this.filePath, backupRaw);
1928
+ } else {
1929
+ throw new Error(
1930
+ `Corrupted ops log at ${this.filePath} and no backup found. Run \`trellis repair\` to attempt recovery.`
1931
+ );
1932
+ }
1933
+ }
1846
1934
  }
1847
1935
  }
1848
- }
1849
- }
1850
- append(op) {
1851
- this.withLock(() => {
1852
- const diskOps = this.readOpsFromDisk();
1853
- this.ops = diskOps;
1854
- if (this.ops.some((existing) => existing.hash === op.hash)) {
1855
- return;
1936
+ append(op) {
1937
+ this.withLock(() => {
1938
+ const diskOps = this.readOpsFromDisk();
1939
+ this.ops = diskOps;
1940
+ if (this.ops.some((existing) => existing.hash === op.hash)) {
1941
+ return;
1942
+ }
1943
+ this.ops.push(op);
1944
+ this.flush();
1945
+ });
1856
1946
  }
1857
- this.ops.push(op);
1858
- this.flush();
1859
- });
1860
- }
1861
- readAll() {
1862
- return [...this.ops];
1863
- }
1864
- getLastOp() {
1865
- return this.ops.length > 0 ? this.ops[this.ops.length - 1] : undefined;
1866
- }
1867
- count() {
1868
- return this.ops.length;
1869
- }
1870
- flush() {
1871
- const dir = dirname3(this.filePath);
1872
- if (!existsSync4(dir))
1873
- mkdirSync3(dir, { recursive: true });
1874
- if (existsSync4(this.filePath)) {
1875
- const backupPath = this.filePath + ".bak";
1876
- try {
1877
- copyFileSync(this.filePath, backupPath);
1878
- } catch {}
1879
- }
1880
- const tempPath = `${this.filePath}.tmp`;
1881
- writeFileSync4(tempPath, JSON.stringify(this.ops, null, 2));
1882
- renameSync(tempPath, this.filePath);
1883
- }
1884
- readOpsFromDisk() {
1885
- if (!existsSync4(this.filePath)) {
1886
- return [];
1887
- }
1888
- const raw = readFileSync4(this.filePath, "utf-8");
1889
- try {
1890
- const parsed = JSON.parse(raw);
1891
- return Array.isArray(parsed) ? parsed : [];
1892
- } catch {
1893
- const backupPath = this.filePath + ".bak";
1894
- if (existsSync4(backupPath)) {
1895
- const backupRaw = readFileSync4(backupPath, "utf-8");
1896
- const parsedBackup = JSON.parse(backupRaw);
1897
- writeFileSync4(this.filePath, backupRaw);
1898
- return Array.isArray(parsedBackup) ? parsedBackup : [];
1899
- }
1900
- throw new Error(`Corrupted ops log at ${this.filePath} and no backup found. Run \`trellis repair\` to attempt recovery.`);
1901
- }
1902
- }
1903
- withLock(fn) {
1904
- const dir = dirname3(this.filePath);
1905
- if (!existsSync4(dir))
1906
- mkdirSync3(dir, { recursive: true });
1907
- const deadline = Date.now() + lockTimeoutMs();
1908
- let lockFd;
1909
- while (Date.now() < deadline) {
1910
- try {
1911
- lockFd = openSync2(this.lockPath, "wx");
1912
- break;
1913
- } catch (err) {
1914
- if (err?.code !== "EEXIST") {
1915
- throw err;
1947
+ readAll() {
1948
+ return [...this.ops];
1949
+ }
1950
+ getLastOp() {
1951
+ return this.ops.length > 0 ? this.ops[this.ops.length - 1] : void 0;
1952
+ }
1953
+ count() {
1954
+ return this.ops.length;
1955
+ }
1956
+ flush() {
1957
+ const dir = dirname3(this.filePath);
1958
+ if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
1959
+ if (existsSync4(this.filePath)) {
1960
+ const backupPath = this.filePath + ".bak";
1961
+ try {
1962
+ copyFileSync(this.filePath, backupPath);
1963
+ } catch {
1964
+ }
1916
1965
  }
1966
+ const tempPath = `${this.filePath}.tmp`;
1967
+ writeFileSync4(tempPath, JSON.stringify(this.ops, null, 2));
1968
+ renameSync(tempPath, this.filePath);
1917
1969
  }
1918
- }
1919
- if (lockFd === undefined) {
1920
- throw new Error(`Timed out waiting for ops log lock: ${this.lockPath}. Another Trellis process may be stalled.`);
1921
- }
1922
- try {
1923
- fn();
1924
- } finally {
1925
- closeSync2(lockFd);
1926
- try {
1927
- unlinkSync2(this.lockPath);
1928
- } catch {}
1929
- }
1930
- }
1931
- static repair(filePath) {
1932
- if (!existsSync4(filePath)) {
1933
- return { recovered: 0, lost: 0 };
1934
- }
1935
- const raw = readFileSync4(filePath, "utf-8");
1936
- try {
1937
- const ops = JSON.parse(raw);
1938
- return { recovered: ops.length, lost: 0 };
1939
- } catch {}
1940
- const lastHash = raw.lastIndexOf('"hash": "trellis:op:');
1941
- if (lastHash === -1) {
1942
- const bakPath = filePath + ".bak";
1943
- if (existsSync4(bakPath)) {
1944
- const bakRaw = readFileSync4(bakPath, "utf-8");
1970
+ readOpsFromDisk() {
1971
+ if (!existsSync4(this.filePath)) {
1972
+ return [];
1973
+ }
1974
+ const raw = readFileSync4(this.filePath, "utf-8");
1945
1975
  try {
1946
- const ops = JSON.parse(bakRaw);
1947
- writeFileSync4(filePath, bakRaw);
1976
+ const parsed = JSON.parse(raw);
1977
+ return Array.isArray(parsed) ? parsed : [];
1978
+ } catch {
1979
+ const backupPath = this.filePath + ".bak";
1980
+ if (existsSync4(backupPath)) {
1981
+ const backupRaw = readFileSync4(backupPath, "utf-8");
1982
+ const parsedBackup = JSON.parse(backupRaw);
1983
+ writeFileSync4(this.filePath, backupRaw);
1984
+ return Array.isArray(parsedBackup) ? parsedBackup : [];
1985
+ }
1986
+ throw new Error(
1987
+ `Corrupted ops log at ${this.filePath} and no backup found. Run \`trellis repair\` to attempt recovery.`
1988
+ );
1989
+ }
1990
+ }
1991
+ withLock(fn) {
1992
+ const dir = dirname3(this.filePath);
1993
+ if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
1994
+ const deadline = Date.now() + lockTimeoutMs();
1995
+ let lockFd;
1996
+ while (Date.now() < deadline) {
1997
+ try {
1998
+ lockFd = openSync2(this.lockPath, "wx");
1999
+ break;
2000
+ } catch (err) {
2001
+ if (err?.code !== "EEXIST") {
2002
+ throw err;
2003
+ }
2004
+ }
2005
+ }
2006
+ if (lockFd === void 0) {
2007
+ throw new Error(
2008
+ `Timed out waiting for ops log lock: ${this.lockPath}. Another Trellis process may be stalled.`
2009
+ );
2010
+ }
2011
+ try {
2012
+ fn();
2013
+ } finally {
2014
+ closeSync2(lockFd);
2015
+ try {
2016
+ unlinkSync2(this.lockPath);
2017
+ } catch {
2018
+ }
2019
+ }
2020
+ }
2021
+ static repair(filePath) {
2022
+ if (!existsSync4(filePath)) {
2023
+ return { recovered: 0, lost: 0 };
2024
+ }
2025
+ const raw = readFileSync4(filePath, "utf-8");
2026
+ try {
2027
+ const ops = JSON.parse(raw);
2028
+ return { recovered: ops.length, lost: 0 };
2029
+ } catch {
2030
+ }
2031
+ const lastHash = raw.lastIndexOf('"hash": "trellis:op:');
2032
+ if (lastHash === -1) {
2033
+ const bakPath = filePath + ".bak";
2034
+ if (existsSync4(bakPath)) {
2035
+ const bakRaw = readFileSync4(bakPath, "utf-8");
2036
+ try {
2037
+ const ops = JSON.parse(bakRaw);
2038
+ writeFileSync4(filePath, bakRaw);
2039
+ return { recovered: ops.length, lost: 0 };
2040
+ } catch {
2041
+ }
2042
+ }
2043
+ writeFileSync4(filePath, "[]");
2044
+ return { recovered: 0, lost: -1 };
2045
+ }
2046
+ const endOfLine = raw.indexOf("\n", lastHash);
2047
+ const closingBrace = raw.indexOf(" }", endOfLine);
2048
+ if (closingBrace === -1) {
2049
+ writeFileSync4(filePath, "[]");
2050
+ return { recovered: 0, lost: -1 };
2051
+ }
2052
+ const fixed = raw.slice(0, closingBrace + 3) + "\n]";
2053
+ try {
2054
+ const ops = JSON.parse(fixed);
2055
+ writeFileSync4(filePath + ".corrupted", raw);
2056
+ writeFileSync4(filePath, fixed);
1948
2057
  return { recovered: ops.length, lost: 0 };
1949
- } catch {}
2058
+ } catch {
2059
+ writeFileSync4(filePath + ".corrupted", raw);
2060
+ writeFileSync4(filePath, "[]");
2061
+ return { recovered: 0, lost: -1 };
2062
+ }
1950
2063
  }
1951
- writeFileSync4(filePath, "[]");
1952
- return { recovered: 0, lost: -1 };
1953
- }
1954
- const endOfLine = raw.indexOf(`
1955
- `, lastHash);
1956
- const closingBrace = raw.indexOf(" }", endOfLine);
1957
- if (closingBrace === -1) {
1958
- writeFileSync4(filePath, "[]");
1959
- return { recovered: 0, lost: -1 };
1960
- }
1961
- const fixed = raw.slice(0, closingBrace + 3) + `
1962
- ]`;
1963
- try {
1964
- const ops = JSON.parse(fixed);
1965
- writeFileSync4(filePath + ".corrupted", raw);
1966
- writeFileSync4(filePath, fixed);
1967
- return { recovered: ops.length, lost: 0 };
1968
- } catch {
1969
- writeFileSync4(filePath + ".corrupted", raw);
1970
- writeFileSync4(filePath, "[]");
1971
- return { recovered: 0, lost: -1 };
1972
- }
2064
+ };
2065
+ LaneOpLog = class extends JsonOpLog {
2066
+ constructor(laneDir2) {
2067
+ super(`${laneDir2}/ops.json`);
2068
+ }
2069
+ };
1973
2070
  }
1974
- }
1975
- var LaneOpLog;
1976
- var init_op_log = __esm(() => {
1977
- LaneOpLog = class LaneOpLog extends JsonOpLog {
1978
- constructor(laneDir) {
1979
- super(`${laneDir}/ops.json`);
1980
- }
1981
- };
1982
2071
  });
1983
2072
 
1984
2073
  // src/vcs/lane.ts
@@ -1999,28 +2088,27 @@ function newLaneId() {
1999
2088
  }
2000
2089
  function loadLaneMeta(trellisDir, laneId) {
2001
2090
  const path = laneMetaPath(trellisDir, laneId);
2002
- if (!existsSync5(path))
2003
- return;
2091
+ if (!existsSync5(path)) return void 0;
2004
2092
  return JSON.parse(readFileSync5(path, "utf-8"));
2005
2093
  }
2006
2094
  function saveLaneMeta(trellisDir, meta) {
2007
2095
  const dir = laneDir(trellisDir, meta.id);
2008
- if (!existsSync5(dir))
2009
- mkdirSync4(dir, { recursive: true });
2010
- writeFileSync5(laneMetaPath(trellisDir, meta.id), JSON.stringify(meta, null, 2) + `
2011
- `);
2096
+ if (!existsSync5(dir)) mkdirSync4(dir, { recursive: true });
2097
+ writeFileSync5(
2098
+ laneMetaPath(trellisDir, meta.id),
2099
+ JSON.stringify(meta, null, 2) + "\n"
2100
+ );
2012
2101
  }
2013
2102
  function listLaneIds(trellisDir) {
2014
2103
  const root = lanesRoot(trellisDir);
2015
- if (!existsSync5(root))
2016
- return [];
2104
+ if (!existsSync5(root)) return [];
2017
2105
  return readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory() && d.name.startsWith("lane-")).map((d) => d.name);
2018
2106
  }
2019
2107
  function resolveLaneHeadFromJournal(meta, laneOps) {
2020
2108
  return laneOps.at(-1)?.hash ?? meta.headOpHash ?? meta.baseOpHash;
2021
2109
  }
2022
2110
  function createLaneMeta(trellisDir, params) {
2023
- const now = new Date().toISOString();
2111
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2024
2112
  const meta = {
2025
2113
  id: newLaneId(),
2026
2114
  status: "active",
@@ -2045,15 +2133,81 @@ function createLaneMeta(trellisDir, params) {
2045
2133
  }
2046
2134
  function updateLaneHead(trellisDir, laneId, headOpHash) {
2047
2135
  const meta = loadLaneMeta(trellisDir, laneId);
2048
- if (!meta)
2049
- return;
2136
+ if (!meta) return;
2050
2137
  meta.headOpHash = headOpHash;
2051
- meta.updatedAt = new Date().toISOString();
2138
+ meta.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
2052
2139
  saveLaneMeta(trellisDir, meta);
2053
2140
  }
2054
2141
  function listLaneMetas(trellisDir) {
2055
- return listLaneIds(trellisDir).map((id) => loadLaneMeta(trellisDir, id)).filter((m) => m !== undefined);
2142
+ return listLaneIds(trellisDir).map((id) => loadLaneMeta(trellisDir, id)).filter((m) => m !== void 0);
2056
2143
  }
2057
- var init_lane = () => {};
2144
+ var init_lane = __esm({
2145
+ "src/vcs/lane.ts"() {
2146
+ "use strict";
2147
+ }
2148
+ });
2058
2149
 
2059
- export { decompose, init_decompose, BlobStore, init_blob_store, shouldAdvanceBranchHead, getBranchHeadOpHash, createBranch, switchBranch, listBranches, deleteBranch, saveBranchState, loadBranchState, init_branch, createMilestone, listMilestones, init_milestone, createCheckpoint, listCheckpoints, init_checkpoint, diffFileStates, buildFileStateAtOp, diffOpRange, generateUnifiedDiff, myersDiff, init_diff, threeWayMerge, threeWayTextMerge, init_merge, createIssue, updateIssue, startIssue, pauseIssue, resumeIssue, closeIssue, triageIssue, reopenIssue, assignIssue, blockIssue, unblockIssue, addCriterion, setCriterionStatus, runCriteria, listIssues, getIssue, getActiveIssues, checkCompletionReadiness, init_issue, JsonOpLog, LaneOpLog, init_op_log, lanesRoot, laneDir, laneMetaPath, newLaneId, loadLaneMeta, saveLaneMeta, listLaneIds, resolveLaneHeadFromJournal, createLaneMeta, updateLaneHead, listLaneMetas, init_lane };
2150
+ export {
2151
+ decompose,
2152
+ init_decompose,
2153
+ BlobStore,
2154
+ init_blob_store,
2155
+ shouldAdvanceBranchHead,
2156
+ getBranchHeadOpHash,
2157
+ createBranch,
2158
+ switchBranch,
2159
+ listBranches,
2160
+ deleteBranch,
2161
+ saveBranchState,
2162
+ loadBranchState,
2163
+ init_branch,
2164
+ createMilestone,
2165
+ listMilestones,
2166
+ init_milestone,
2167
+ createCheckpoint,
2168
+ listCheckpoints,
2169
+ init_checkpoint,
2170
+ diffFileStates,
2171
+ buildFileStateAtOp,
2172
+ diffOpRange,
2173
+ generateUnifiedDiff,
2174
+ myersDiff,
2175
+ init_diff,
2176
+ threeWayMerge,
2177
+ threeWayTextMerge,
2178
+ init_merge,
2179
+ createIssue,
2180
+ updateIssue,
2181
+ startIssue,
2182
+ pauseIssue,
2183
+ resumeIssue,
2184
+ closeIssue,
2185
+ triageIssue,
2186
+ reopenIssue,
2187
+ assignIssue,
2188
+ blockIssue,
2189
+ unblockIssue,
2190
+ addCriterion,
2191
+ setCriterionStatus,
2192
+ runCriteria,
2193
+ listIssues,
2194
+ getIssue,
2195
+ getActiveIssues,
2196
+ checkCompletionReadiness,
2197
+ init_issue,
2198
+ JsonOpLog,
2199
+ LaneOpLog,
2200
+ init_op_log,
2201
+ lanesRoot,
2202
+ laneDir,
2203
+ laneMetaPath,
2204
+ newLaneId,
2205
+ loadLaneMeta,
2206
+ saveLaneMeta,
2207
+ listLaneIds,
2208
+ resolveLaneHeadFromJournal,
2209
+ createLaneMeta,
2210
+ updateLaneHead,
2211
+ listLaneMetas,
2212
+ init_lane
2213
+ };