@agimon-ai/doompi-git 0.0.1-alpha.7 → 0.0.1-alpha.9

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 (325) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +23 -1
  2. package/dist/api-contracts.cjs +7 -1
  3. package/dist/api-contracts.d.cts +1 -1
  4. package/dist/api-contracts.d.mts +1 -1
  5. package/dist/api-contracts.mjs +2 -1
  6. package/dist/extensions/pi.cjs +38 -1
  7. package/dist/extensions/pi.cjs.map +1 -1
  8. package/dist/extensions/pi.d.cts +5 -4
  9. package/dist/extensions/pi.d.cts.map +1 -1
  10. package/dist/extensions/pi.d.mts +5 -4
  11. package/dist/extensions/pi.d.mts.map +1 -1
  12. package/dist/extensions/pi.mjs +33 -1
  13. package/dist/extensions/pi.mjs.map +1 -1
  14. package/dist/extensions/server.cjs +72 -1
  15. package/dist/extensions/server.cjs.map +1 -1
  16. package/dist/extensions/server.d.cts +3 -3
  17. package/dist/extensions/server.d.cts.map +1 -1
  18. package/dist/extensions/server.d.mts +3 -3
  19. package/dist/extensions/server.d.mts.map +1 -1
  20. package/dist/extensions/server.mjs +67 -1
  21. package/dist/extensions/server.mjs.map +1 -1
  22. package/dist/extensions/web.mjs +485 -0
  23. package/dist/extensions/web.mjs.map +1 -0
  24. package/dist/index.cjs +5 -1
  25. package/dist/index.d.cts +3 -3
  26. package/dist/index.d.mts +3 -3
  27. package/dist/index.mjs +3 -1
  28. package/dist/src/constants/git.cjs +8 -0
  29. package/dist/src/constants/git.cjs.map +1 -0
  30. package/dist/src/constants/git.mjs +7 -0
  31. package/dist/src/constants/git.mjs.map +1 -0
  32. package/dist/src/extensions/(backend)/api/_lib/route.server.cjs +93 -0
  33. package/dist/src/extensions/(backend)/api/_lib/route.server.cjs.map +1 -0
  34. package/dist/src/extensions/(backend)/api/_lib/route.server.mjs +92 -0
  35. package/dist/src/extensions/(backend)/api/_lib/route.server.mjs.map +1 -0
  36. package/dist/src/extensions/(backend)/api/route.server.cjs +7 -0
  37. package/dist/src/extensions/(backend)/api/route.server.cjs.map +1 -0
  38. package/dist/src/extensions/(backend)/api/route.server.mjs +8 -0
  39. package/dist/src/extensions/(backend)/api/route.server.mjs.map +1 -0
  40. package/dist/src/extensions/(backend)/channel/_lib/git-worktrees.server.cjs +195 -0
  41. package/dist/src/extensions/(backend)/channel/_lib/git-worktrees.server.cjs.map +1 -0
  42. package/dist/src/extensions/(backend)/channel/_lib/git-worktrees.server.mjs +194 -0
  43. package/dist/src/extensions/(backend)/channel/_lib/git-worktrees.server.mjs.map +1 -0
  44. package/dist/src/extensions/(backend)/channel/git-worktrees.server.cjs +7 -0
  45. package/dist/src/extensions/(backend)/channel/git-worktrees.server.cjs.map +1 -0
  46. package/dist/src/extensions/(backend)/channel/git-worktrees.server.mjs +8 -0
  47. package/dist/src/extensions/(backend)/channel/git-worktrees.server.mjs.map +1 -0
  48. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.cli.cjs +7 -0
  49. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.cli.cjs.map +1 -0
  50. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.cli.mjs +8 -0
  51. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.cli.mjs.map +1 -0
  52. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.server.cjs +71 -0
  53. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.server.cjs.map +1 -0
  54. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.server.mjs +70 -0
  55. package/dist/src/extensions/workspaces/sessions/(backend)/_lib/root.server.mjs.map +1 -0
  56. package/dist/src/extensions/workspaces/sessions/(backend)/command/_lib/git.cli.cjs +17 -0
  57. package/dist/src/extensions/workspaces/sessions/(backend)/command/_lib/git.cli.cjs.map +1 -0
  58. package/dist/src/extensions/workspaces/sessions/(backend)/command/_lib/git.cli.mjs +16 -0
  59. package/dist/src/extensions/workspaces/sessions/(backend)/command/_lib/git.cli.mjs.map +1 -0
  60. package/dist/src/extensions/workspaces/sessions/(backend)/command/git.cli.cjs +7 -0
  61. package/dist/src/extensions/workspaces/sessions/(backend)/command/git.cli.cjs.map +1 -0
  62. package/dist/src/extensions/workspaces/sessions/(backend)/command/git.cli.mjs +8 -0
  63. package/dist/src/extensions/workspaces/sessions/(backend)/command/git.cli.mjs.map +1 -0
  64. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-git.cli.cjs +15 -0
  65. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-git.cli.cjs.map +1 -0
  66. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-git.cli.mjs +15 -0
  67. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompi-use-git.cli.mjs.map +1 -0
  68. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGit.server.cjs +6 -0
  69. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGit.server.cjs.map +1 -0
  70. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGit.server.mjs +6 -0
  71. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGit.server.mjs.map +1 -0
  72. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGitReadme.server.cjs +6 -0
  73. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGitReadme.server.cjs.map +1 -0
  74. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGitReadme.server.mjs +6 -0
  75. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGitReadme.server.mjs.map +1 -0
  76. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiUseGit.server.cjs +6 -0
  77. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiUseGit.server.cjs.map +1 -0
  78. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiUseGit.server.mjs +6 -0
  79. package/dist/src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiUseGit.server.mjs.map +1 -0
  80. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-git.cli.cjs +7 -0
  81. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-git.cli.cjs.map +1 -0
  82. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-git.cli.mjs +8 -0
  83. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-git.cli.mjs.map +1 -0
  84. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGit.server.cjs +7 -0
  85. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGit.server.cjs.map +1 -0
  86. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGit.server.mjs +8 -0
  87. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGit.server.mjs.map +1 -0
  88. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGitReadme.server.cjs +7 -0
  89. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGitReadme.server.cjs.map +1 -0
  90. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGitReadme.server.mjs +8 -0
  91. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiGitReadme.server.mjs.map +1 -0
  92. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiUseGit.server.cjs +7 -0
  93. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiUseGit.server.cjs.map +1 -0
  94. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiUseGit.server.mjs +8 -0
  95. package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompiUseGit.server.mjs.map +1 -0
  96. package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.cjs +7 -0
  97. package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.cjs.map +1 -0
  98. package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.mjs +8 -0
  99. package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.mjs.map +1 -0
  100. package/dist/src/extensions/workspaces/sessions/(backend)/root.server.cjs +7 -0
  101. package/dist/src/extensions/workspaces/sessions/(backend)/root.server.cjs.map +1 -0
  102. package/dist/src/extensions/workspaces/sessions/(backend)/root.server.mjs +8 -0
  103. package/dist/src/extensions/workspaces/sessions/(backend)/root.server.mjs.map +1 -0
  104. package/dist/src/extensions/workspaces/sessions/(backend)/tool/_lib/runWorktree.cli.cjs +38 -0
  105. package/dist/src/extensions/workspaces/sessions/(backend)/tool/_lib/runWorktree.cli.cjs.map +1 -0
  106. package/dist/src/extensions/workspaces/sessions/(backend)/tool/_lib/runWorktree.cli.mjs +36 -0
  107. package/dist/src/extensions/workspaces/sessions/(backend)/tool/_lib/runWorktree.cli.mjs.map +1 -0
  108. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.cli.cjs +7 -0
  109. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.cli.cjs.map +1 -0
  110. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.cli.mjs +8 -0
  111. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.cli.mjs.map +1 -0
  112. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.server.cjs +6 -0
  113. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.server.cjs.map +1 -0
  114. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.server.mjs +7 -0
  115. package/dist/src/extensions/workspaces/sessions/(backend)/tool/runWorktree.server.mjs.map +1 -0
  116. package/dist/src/schemas/apiContracts.cjs +138 -0
  117. package/dist/src/schemas/apiContracts.cjs.map +1 -0
  118. package/dist/{schemas → src/schemas}/apiContracts.d.cts +2 -2
  119. package/dist/{schemas → src/schemas}/apiContracts.d.cts.map +1 -1
  120. package/dist/{schemas → src/schemas}/apiContracts.d.mts +2 -2
  121. package/dist/{schemas → src/schemas}/apiContracts.d.mts.map +1 -1
  122. package/dist/src/schemas/apiContracts.mjs +135 -0
  123. package/dist/src/schemas/apiContracts.mjs.map +1 -0
  124. package/dist/src/schemas/runWorktreeTool.cjs +152 -0
  125. package/dist/src/schemas/runWorktreeTool.cjs.map +1 -0
  126. package/dist/src/schemas/runWorktreeTool.mjs +150 -0
  127. package/dist/src/schemas/runWorktreeTool.mjs.map +1 -0
  128. package/dist/src/services/atomicJson/index.cjs +42 -0
  129. package/dist/src/services/atomicJson/index.cjs.map +1 -0
  130. package/dist/src/services/atomicJson/index.mjs +38 -0
  131. package/dist/src/services/atomicJson/index.mjs.map +1 -0
  132. package/dist/src/services/compositionMirror/index.cjs +119 -0
  133. package/dist/src/services/compositionMirror/index.cjs.map +1 -0
  134. package/dist/src/services/compositionMirror/index.mjs +116 -0
  135. package/dist/src/services/compositionMirror/index.mjs.map +1 -0
  136. package/dist/src/services/errors/index.cjs +29 -0
  137. package/dist/src/services/errors/index.cjs.map +1 -0
  138. package/dist/src/services/errors/index.mjs +27 -0
  139. package/dist/src/services/errors/index.mjs.map +1 -0
  140. package/dist/src/services/extensionService/index.cjs +13 -0
  141. package/dist/src/services/extensionService/index.cjs.map +1 -0
  142. package/dist/{services → src/services}/extensionService/index.d.cts +1 -2
  143. package/dist/src/services/extensionService/index.d.cts.map +1 -0
  144. package/dist/{services → src/services}/extensionService/index.d.mts +1 -2
  145. package/dist/src/services/extensionService/index.d.mts.map +1 -0
  146. package/dist/src/services/extensionService/index.mjs +13 -0
  147. package/dist/src/services/extensionService/index.mjs.map +1 -0
  148. package/dist/src/services/gitCli/index.cjs +144 -0
  149. package/dist/src/services/gitCli/index.cjs.map +1 -0
  150. package/dist/src/services/gitCli/index.mjs +142 -0
  151. package/dist/src/services/gitCli/index.mjs.map +1 -0
  152. package/dist/src/services/gitDependencies/index.cjs +14 -0
  153. package/dist/src/services/gitDependencies/index.cjs.map +1 -0
  154. package/dist/src/services/gitDependencies/index.d.cts +5 -0
  155. package/dist/src/services/gitDependencies/index.d.cts.map +1 -0
  156. package/dist/src/services/gitDependencies/index.d.mts +5 -0
  157. package/dist/src/services/gitDependencies/index.d.mts.map +1 -0
  158. package/dist/src/services/gitDependencies/index.mjs +14 -0
  159. package/dist/src/services/gitDependencies/index.mjs.map +1 -0
  160. package/dist/src/services/paths/index.cjs +35 -0
  161. package/dist/src/services/paths/index.cjs.map +1 -0
  162. package/dist/src/services/paths/index.mjs +30 -0
  163. package/dist/src/services/paths/index.mjs.map +1 -0
  164. package/dist/src/services/repositoryIdentity/index.cjs +71 -0
  165. package/dist/src/services/repositoryIdentity/index.cjs.map +1 -0
  166. package/dist/src/services/repositoryIdentity/index.mjs +65 -0
  167. package/dist/src/services/repositoryIdentity/index.mjs.map +1 -0
  168. package/dist/src/services/runWorktree/index.cjs +145 -0
  169. package/dist/src/services/runWorktree/index.cjs.map +1 -0
  170. package/dist/src/services/runWorktree/index.mjs +142 -0
  171. package/dist/src/services/runWorktree/index.mjs.map +1 -0
  172. package/dist/src/services/worktreeEvents/index.cjs +64 -0
  173. package/dist/src/services/worktreeEvents/index.cjs.map +1 -0
  174. package/dist/{services → src/services}/worktreeEvents/index.d.cts +3 -4
  175. package/dist/src/services/worktreeEvents/index.d.cts.map +1 -0
  176. package/dist/{services → src/services}/worktreeEvents/index.d.mts +3 -4
  177. package/dist/src/services/worktreeEvents/index.d.mts.map +1 -0
  178. package/dist/src/services/worktreeEvents/index.mjs +60 -0
  179. package/dist/src/services/worktreeEvents/index.mjs.map +1 -0
  180. package/dist/src/services/worktreeNaming/index.cjs +99 -0
  181. package/dist/src/services/worktreeNaming/index.cjs.map +1 -0
  182. package/dist/{services → src/services}/worktreeNaming/index.d.cts +2 -3
  183. package/dist/src/services/worktreeNaming/index.d.cts.map +1 -0
  184. package/dist/{services → src/services}/worktreeNaming/index.d.mts +2 -3
  185. package/dist/src/services/worktreeNaming/index.d.mts.map +1 -0
  186. package/dist/src/services/worktreeNaming/index.mjs +94 -0
  187. package/dist/src/services/worktreeNaming/index.mjs.map +1 -0
  188. package/dist/src/services/worktreeOperations/index.cjs +263 -0
  189. package/dist/src/services/worktreeOperations/index.cjs.map +1 -0
  190. package/dist/{services → src/services}/worktreeOperations/index.d.cts +4 -5
  191. package/dist/src/services/worktreeOperations/index.d.cts.map +1 -0
  192. package/dist/{services → src/services}/worktreeOperations/index.d.mts +4 -5
  193. package/dist/src/services/worktreeOperations/index.d.mts.map +1 -0
  194. package/dist/src/services/worktreeOperations/index.mjs +261 -0
  195. package/dist/src/services/worktreeOperations/index.mjs.map +1 -0
  196. package/dist/src/services/worktreeRegistry/index.cjs +38 -0
  197. package/dist/src/services/worktreeRegistry/index.cjs.map +1 -0
  198. package/dist/src/services/worktreeRegistry/index.mjs +38 -0
  199. package/dist/src/services/worktreeRegistry/index.mjs.map +1 -0
  200. package/dist/{types → src/types}/extension.d.cts +4 -5
  201. package/dist/src/types/extension.d.cts.map +1 -0
  202. package/dist/{types → src/types}/extension.d.mts +4 -5
  203. package/dist/src/types/extension.d.mts.map +1 -0
  204. package/dist/src/types/webWorktrees.cjs +20 -0
  205. package/dist/src/types/webWorktrees.cjs.map +1 -0
  206. package/dist/src/types/webWorktrees.mjs +20 -0
  207. package/dist/src/types/webWorktrees.mjs.map +1 -0
  208. package/dist/{types → src/types}/worktreeRegistry.d.cts +3 -4
  209. package/dist/src/types/worktreeRegistry.d.cts.map +1 -0
  210. package/dist/{types → src/types}/worktreeRegistry.d.mts +3 -4
  211. package/dist/src/types/worktreeRegistry.d.mts.map +1 -0
  212. package/package.json +31 -26
  213. package/dist/constants/git.cjs +0 -2
  214. package/dist/constants/git.cjs.map +0 -1
  215. package/dist/constants/git.mjs +0 -2
  216. package/dist/constants/git.mjs.map +0 -1
  217. package/dist/controllers/gitCommand.cjs +0 -2
  218. package/dist/controllers/gitCommand.cjs.map +0 -1
  219. package/dist/controllers/gitCommand.mjs +0 -2
  220. package/dist/controllers/gitCommand.mjs.map +0 -1
  221. package/dist/controllers/gitSession.cjs +0 -2
  222. package/dist/controllers/gitSession.cjs.map +0 -1
  223. package/dist/controllers/gitSession.mjs +0 -2
  224. package/dist/controllers/gitSession.mjs.map +0 -1
  225. package/dist/controllers/hubApi.cjs +0 -2
  226. package/dist/controllers/hubApi.cjs.map +0 -1
  227. package/dist/controllers/hubApi.mjs +0 -2
  228. package/dist/controllers/hubApi.mjs.map +0 -1
  229. package/dist/controllers/worktreesChannel.cjs +0 -2
  230. package/dist/controllers/worktreesChannel.cjs.map +0 -1
  231. package/dist/controllers/worktreesChannel.mjs +0 -2
  232. package/dist/controllers/worktreesChannel.mjs.map +0 -1
  233. package/dist/schemas/apiContracts.cjs +0 -2
  234. package/dist/schemas/apiContracts.cjs.map +0 -1
  235. package/dist/schemas/apiContracts.mjs +0 -2
  236. package/dist/schemas/apiContracts.mjs.map +0 -1
  237. package/dist/schemas/runWorktreeTool.cjs +0 -2
  238. package/dist/schemas/runWorktreeTool.cjs.map +0 -1
  239. package/dist/schemas/runWorktreeTool.mjs +0 -2
  240. package/dist/schemas/runWorktreeTool.mjs.map +0 -1
  241. package/dist/services/atomicJson/index.cjs +0 -2
  242. package/dist/services/atomicJson/index.cjs.map +0 -1
  243. package/dist/services/atomicJson/index.mjs +0 -2
  244. package/dist/services/atomicJson/index.mjs.map +0 -1
  245. package/dist/services/compositionMirror/index.cjs +0 -2
  246. package/dist/services/compositionMirror/index.cjs.map +0 -1
  247. package/dist/services/compositionMirror/index.mjs +0 -2
  248. package/dist/services/compositionMirror/index.mjs.map +0 -1
  249. package/dist/services/errors/index.cjs +0 -2
  250. package/dist/services/errors/index.cjs.map +0 -1
  251. package/dist/services/errors/index.mjs +0 -2
  252. package/dist/services/errors/index.mjs.map +0 -1
  253. package/dist/services/extensionService/index.cjs +0 -2
  254. package/dist/services/extensionService/index.cjs.map +0 -1
  255. package/dist/services/extensionService/index.d.cts.map +0 -1
  256. package/dist/services/extensionService/index.d.mts.map +0 -1
  257. package/dist/services/extensionService/index.mjs +0 -2
  258. package/dist/services/extensionService/index.mjs.map +0 -1
  259. package/dist/services/gitCli/index.cjs +0 -4
  260. package/dist/services/gitCli/index.cjs.map +0 -1
  261. package/dist/services/gitCli/index.mjs +0 -4
  262. package/dist/services/gitCli/index.mjs.map +0 -1
  263. package/dist/services/gitDependencies/index.cjs +0 -2
  264. package/dist/services/gitDependencies/index.cjs.map +0 -1
  265. package/dist/services/gitDependencies/index.d.cts +0 -6
  266. package/dist/services/gitDependencies/index.d.cts.map +0 -1
  267. package/dist/services/gitDependencies/index.d.mts +0 -6
  268. package/dist/services/gitDependencies/index.d.mts.map +0 -1
  269. package/dist/services/gitDependencies/index.mjs +0 -2
  270. package/dist/services/gitDependencies/index.mjs.map +0 -1
  271. package/dist/services/paths/index.cjs +0 -2
  272. package/dist/services/paths/index.cjs.map +0 -1
  273. package/dist/services/paths/index.mjs +0 -2
  274. package/dist/services/paths/index.mjs.map +0 -1
  275. package/dist/services/repositoryIdentity/index.cjs +0 -2
  276. package/dist/services/repositoryIdentity/index.cjs.map +0 -1
  277. package/dist/services/repositoryIdentity/index.mjs +0 -2
  278. package/dist/services/repositoryIdentity/index.mjs.map +0 -1
  279. package/dist/services/runWorktree/index.cjs +0 -15
  280. package/dist/services/runWorktree/index.cjs.map +0 -1
  281. package/dist/services/runWorktree/index.mjs +0 -15
  282. package/dist/services/runWorktree/index.mjs.map +0 -1
  283. package/dist/services/worktreeEvents/index.cjs +0 -2
  284. package/dist/services/worktreeEvents/index.cjs.map +0 -1
  285. package/dist/services/worktreeEvents/index.d.cts.map +0 -1
  286. package/dist/services/worktreeEvents/index.d.mts.map +0 -1
  287. package/dist/services/worktreeEvents/index.mjs +0 -2
  288. package/dist/services/worktreeEvents/index.mjs.map +0 -1
  289. package/dist/services/worktreeNaming/index.cjs +0 -2
  290. package/dist/services/worktreeNaming/index.cjs.map +0 -1
  291. package/dist/services/worktreeNaming/index.d.cts.map +0 -1
  292. package/dist/services/worktreeNaming/index.d.mts.map +0 -1
  293. package/dist/services/worktreeNaming/index.mjs +0 -2
  294. package/dist/services/worktreeNaming/index.mjs.map +0 -1
  295. package/dist/services/worktreeOperations/index.cjs +0 -2
  296. package/dist/services/worktreeOperations/index.cjs.map +0 -1
  297. package/dist/services/worktreeOperations/index.d.cts.map +0 -1
  298. package/dist/services/worktreeOperations/index.d.mts.map +0 -1
  299. package/dist/services/worktreeOperations/index.mjs +0 -2
  300. package/dist/services/worktreeOperations/index.mjs.map +0 -1
  301. package/dist/services/worktreeRegistry/index.cjs +0 -2
  302. package/dist/services/worktreeRegistry/index.cjs.map +0 -1
  303. package/dist/services/worktreeRegistry/index.mjs +0 -2
  304. package/dist/services/worktreeRegistry/index.mjs.map +0 -1
  305. package/dist/tools/runWorktree.cjs +0 -2
  306. package/dist/tools/runWorktree.cjs.map +0 -1
  307. package/dist/tools/runWorktree.mjs +0 -2
  308. package/dist/tools/runWorktree.mjs.map +0 -1
  309. package/dist/types/extension.d.cts.map +0 -1
  310. package/dist/types/extension.d.mts.map +0 -1
  311. package/dist/types/webWorktrees.cjs +0 -2
  312. package/dist/types/webWorktrees.cjs.map +0 -1
  313. package/dist/types/webWorktrees.mjs +0 -2
  314. package/dist/types/webWorktrees.mjs.map +0 -1
  315. package/dist/types/worktreeRegistry.d.cts.map +0 -1
  316. package/dist/types/worktreeRegistry.d.mts.map +0 -1
  317. package/src/extensions/web.ts +0 -33
  318. package/src/types/webWorktrees.ts +0 -55
  319. package/src/types/worktreeRegistry.ts +0 -78
  320. package/src/web/components/RunWorktreeToolMessage.tsx +0 -45
  321. package/src/web/components/WorktreesActivitySection.tsx +0 -80
  322. package/src/web/components/WorktreesPanel.tsx +0 -175
  323. package/src/web/components/toolRenderers.ts +0 -8
  324. package/src/web/stores/worktreesActivityStore.ts +0 -125
  325. package/src/web/tsconfig.json +0 -22
@@ -0,0 +1,261 @@
1
+ import { mirrorComposition } from "../compositionMirror/index.mjs";
2
+ import { DoomGitExpectedError, HubUnavailableError } from "../errors/index.mjs";
3
+ import { repositoryId, repositoryLabel, shortId } from "../repositoryIdentity/index.mjs";
4
+ import { registryFile, worktreesRoot } from "../paths/index.mjs";
5
+ import { MAX_WORKTREE_MESSAGE_BYTES } from "../worktreeEvents/index.mjs";
6
+ import { planPrune, reconcile, refuseClose, refuseSpawn, worktreeDirectory } from "../worktreeNaming/index.mjs";
7
+ import { createWorktreeRegistry } from "../worktreeRegistry/index.mjs";
8
+ import fs from "node:fs";
9
+ import { randomUUID } from "node:crypto";
10
+ //#region src/services/worktreeOperations/index.ts
11
+ function createWorktreeOperations(deps) {
12
+ const { git } = deps;
13
+ const sessionService = deps.sessionService;
14
+ const mirror = deps.mirror ?? mirrorComposition;
15
+ const now = deps.now ?? (() => /* @__PURE__ */ new Date());
16
+ const requireSessionService = () => {
17
+ if (sessionService === void 0) throw new HubUnavailableError("The cockpit session service is unavailable. Start the cockpit and try again.");
18
+ return sessionService;
19
+ };
20
+ const requireMessageInbox = () => {
21
+ if (deps.messageInbox === void 0) throw new HubUnavailableError("The Git message service is unavailable. Start the cockpit and try again.");
22
+ return deps.messageInbox;
23
+ };
24
+ const probe = {
25
+ alive: (record) => requireSessionService().isLive(record.sessionId),
26
+ exists: (path) => fs.existsSync(path)
27
+ };
28
+ /**
29
+ * Everything an action needs about the repository it is acting on.
30
+ *
31
+ * Resolved per call rather than cached: a session's cwd is stable, but the
32
+ * worktree registry is shared and another process may have written it since
33
+ * the last call.
34
+ */
35
+ const resolve = async (context) => {
36
+ const root = await git.repositoryRoot(context.cwd);
37
+ if (root === void 0) throw new DoomGitExpectedError("not_a_repository", `${context.cwd} is not inside a git repository.`, false, "Run this from a repository checkout.");
38
+ const store = createWorktreeRegistry(registryFile(root, deps.homeDir));
39
+ return {
40
+ root,
41
+ store,
42
+ records: store.list()
43
+ };
44
+ };
45
+ const require = (records, id) => {
46
+ const record = records.find((entry) => entry.id === id);
47
+ if (record === void 0) throw new DoomGitExpectedError("worktree_not_found", `No worktree with id ${id}.`, false, "Call list to see the current ids.");
48
+ return record;
49
+ };
50
+ /**
51
+ * Refuses to destroy or merge a worktree another live session is using.
52
+ *
53
+ * `parentSessionId` records who asked for the worktree. Two sessions in one
54
+ * checkout share this registry, so without the check either could close the
55
+ * other's work in progress by id.
56
+ *
57
+ * Once that session is gone there is no owner left to protect, and refusing
58
+ * would strand the worktree: nothing else could ever close it.
59
+ */
60
+ const requireOwner = (context, record, action) => {
61
+ if (record.parentSessionId === context.sessionId) return;
62
+ if (!requireSessionService().isLive(record.parentSessionId)) return;
63
+ throw new DoomGitExpectedError("worktree_not_owned", `Worktree ${record.id} belongs to another session.`, false, `Ask the session that created it to ${action} it, or close that session first.`);
64
+ };
65
+ const peerFor = (context, record) => {
66
+ if (context.sessionId === record.parentSessionId) return {
67
+ sessionId: record.sessionId,
68
+ party: "parent"
69
+ };
70
+ if (context.sessionId === record.sessionId) return {
71
+ sessionId: record.parentSessionId,
72
+ party: "child"
73
+ };
74
+ throw new DoomGitExpectedError("worktree_not_owned", `Worktree ${record.id} belongs to another session.`, false, "Use a worktree owned by this session.");
75
+ };
76
+ const requirePeerLive = (peerSessionId) => {
77
+ if (!requireSessionService().isLive(peerSessionId)) throw new DoomGitExpectedError("worktree_peer_unavailable", "The other worktree session is no longer live.", false, "Start a new worktree session before sending a message.");
78
+ };
79
+ return {
80
+ async spawn(context, request, options) {
81
+ const { root, store, records } = await resolve(context);
82
+ const refusal = refuseSpawn({
83
+ branch: request.branch,
84
+ existing: records
85
+ });
86
+ if (refusal !== void 0) throw new DoomGitExpectedError("worktree_exists", refusal, false, "Pick another branch name, or close it.");
87
+ const baseRef = request.baseRef ?? await git.currentBranch(root) ?? "HEAD";
88
+ const id = shortId(randomUUID());
89
+ const path = worktreeDirectory({
90
+ worktreesRoot: worktreesRoot(deps.homeDir),
91
+ repositoryLabel: repositoryLabel(root),
92
+ repositoryId: repositoryId(root),
93
+ branch: request.branch,
94
+ shortId: id
95
+ });
96
+ const cancelled = () => options?.signal?.aborted === true;
97
+ const rollback = async () => {
98
+ await git.removeWorktree({
99
+ repositoryRoot: root,
100
+ path,
101
+ force: true
102
+ }).catch(() => void 0);
103
+ return await git.deleteBranch({
104
+ repositoryRoot: root,
105
+ branch: request.branch
106
+ }).catch(() => false) ? "" : ` The branch ${request.branch} has work on it and was kept.`;
107
+ };
108
+ options?.onProgress?.(`creating branch ${request.branch}\u2026`);
109
+ await git.addWorktree({
110
+ repositoryRoot: root,
111
+ path,
112
+ branch: request.branch,
113
+ baseRef
114
+ });
115
+ if (cancelled()) {
116
+ const kept = await rollback();
117
+ throw new DoomGitExpectedError("spawn_cancelled", `Cancelled before the session started.${kept}`, false, "The worktree was removed; run it again when you are ready.");
118
+ }
119
+ options?.onProgress?.("mirroring build output…");
120
+ mirror(root, path);
121
+ options?.onProgress?.("starting session…");
122
+ let sessionId;
123
+ try {
124
+ sessionId = (await requireSessionService().create({
125
+ cwd: path,
126
+ name: request.name ?? request.branch,
127
+ parentSessionId: context.sessionId,
128
+ sessionProvenance: "worktree",
129
+ ...options?.signal === void 0 ? {} : { signal: options.signal }
130
+ })).sessionId;
131
+ } catch (error) {
132
+ const kept = await rollback();
133
+ if (cancelled()) throw new DoomGitExpectedError("spawn_cancelled", `Cancelled while the session was starting.${kept}`, false, "The worktree was removed; run it again when you are ready.");
134
+ if (error instanceof HubUnavailableError) throw new DoomGitExpectedError("hub_unavailable", `${error.message}${kept}`, true, "Start the cockpit and try again.");
135
+ throw error;
136
+ }
137
+ const record = {
138
+ version: 1,
139
+ id,
140
+ branch: request.branch,
141
+ baseRef,
142
+ path,
143
+ repositoryRoot: root,
144
+ sessionId,
145
+ parentSessionId: context.sessionId,
146
+ status: "running",
147
+ createdAt: now().toISOString()
148
+ };
149
+ try {
150
+ store.replace([...records, record]);
151
+ } catch (error) {
152
+ await requireSessionService().close(sessionId).catch(() => void 0);
153
+ const kept = await rollback();
154
+ throw new DoomGitExpectedError("registry_write_failed", `The worktree was created but the registry could not be written (${error.message}).${kept}`, true, "Check the registry file for permissions or free space, then try again.");
155
+ }
156
+ return record;
157
+ },
158
+ async close(context, id, force) {
159
+ const { root, store, records } = await resolve(context);
160
+ const record = require(records, id);
161
+ requireOwner(context, record, "close");
162
+ const dirtyFiles = fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : [];
163
+ const refusal = refuseClose({
164
+ record,
165
+ dirtyFiles,
166
+ force
167
+ });
168
+ if (refusal !== void 0) throw new DoomGitExpectedError("worktree_dirty", refusal, false, "Commit the work, or pass force: true.");
169
+ await requireSessionService().close(record.sessionId);
170
+ await git.removeWorktree({
171
+ repositoryRoot: root,
172
+ path: record.path,
173
+ force
174
+ });
175
+ store.replace(records.filter((entry) => entry.id !== id));
176
+ return record;
177
+ },
178
+ async list(context) {
179
+ const { store, records } = await resolve(context);
180
+ const outcome = reconcile(records, probe);
181
+ if (outcome.changed.length > 0) store.replace(outcome.records);
182
+ return outcome.records;
183
+ },
184
+ async status(context, id) {
185
+ const { records } = await resolve(context);
186
+ const record = require(records, id);
187
+ return {
188
+ record,
189
+ dirtyFiles: fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : []
190
+ };
191
+ },
192
+ async merge(context, id, message) {
193
+ const { root, records } = await resolve(context);
194
+ const record = require(records, id);
195
+ requireOwner(context, record, "merge");
196
+ const parentDirty = await git.dirtyFiles(root);
197
+ if (parentDirty.length > 0) throw new DoomGitExpectedError("worktree_dirty", `The parent checkout has ${String(parentDirty.length)} uncommitted file(s): ${parentDirty.slice(0, 10).join(", ")}.`, false, "Commit or stash the parent checkout first.");
198
+ await git.mergeBranch({
199
+ repositoryRoot: root,
200
+ branch: record.branch,
201
+ ...message === void 0 ? {} : { message }
202
+ });
203
+ return record;
204
+ },
205
+ /** Sends only between the parent session and its own worktree session. */
206
+ async send(context, id, message) {
207
+ if (Buffer.byteLength(message, "utf8") > 65536) throw new DoomGitExpectedError("message_too_large", `A message may not exceed ${String(MAX_WORKTREE_MESSAGE_BYTES)} bytes.`, false, "Send a shorter message.");
208
+ const { records } = await resolve(context);
209
+ const record = require(records, id);
210
+ const peer = peerFor(context, record);
211
+ requirePeerLive(peer.sessionId);
212
+ requireMessageInbox().send(peer.sessionId, {
213
+ version: 1,
214
+ worktreeId: record.id,
215
+ fromSessionId: context.sessionId,
216
+ from: peer.party,
217
+ text: message,
218
+ sentAt: (/* @__PURE__ */ new Date()).toISOString()
219
+ });
220
+ },
221
+ async messages(context, id) {
222
+ const { records } = await resolve(context);
223
+ const record = require(records, id);
224
+ peerFor(context, record);
225
+ return requireMessageInbox().receive(record.id);
226
+ },
227
+ async prune(context, dryRun) {
228
+ const { root, store, records } = await resolve(context);
229
+ const reconciled = reconcile(records, probe);
230
+ const gitPaths = await git.listWorktreePaths(root);
231
+ const dirtyByPath = /* @__PURE__ */ new Map();
232
+ for (const record of reconciled.records) if (record.status === "orphaned" && fs.existsSync(record.path)) dirtyByPath.set(record.path, await git.dirtyFiles(record.path));
233
+ const plan = planPrune({
234
+ records: reconciled.records,
235
+ gitPaths,
236
+ worktreesRoot: worktreesRoot(deps.homeDir),
237
+ dirtyByPath
238
+ });
239
+ if (dryRun) {
240
+ store.replace(reconciled.records);
241
+ return plan;
242
+ }
243
+ for (const record of plan.remove) await git.removeWorktree({
244
+ repositoryRoot: root,
245
+ path: record.path,
246
+ force: false
247
+ });
248
+ for (const record of [...plan.remove, ...plan.forget]) if (!await git.deleteBranch({
249
+ repositoryRoot: root,
250
+ branch: record.branch
251
+ }).catch(() => false)) plan.keptBranches.push(record.branch);
252
+ const dropped = new Set([...plan.remove, ...plan.forget].map((record) => record.id));
253
+ store.replace(reconciled.records.filter((record) => !dropped.has(record.id)));
254
+ return plan;
255
+ }
256
+ };
257
+ }
258
+ //#endregion
259
+ export { createWorktreeOperations };
260
+
261
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/worktreeOperations/index.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\n\nimport type { DoomHubSessionService } from '@agimon-ai/doompi-core/hub-channel';\n\nimport { WORKTREE_RECORD_VERSION } from '../../types/worktreeRegistry';\nimport type { WorktreeGit, WorktreeRecord } from '../../types/worktreeRegistry';\nimport { mirrorComposition } from '../compositionMirror';\nimport { DoomGitExpectedError, HubUnavailableError } from '../errors';\nimport { registryFile, worktreesRoot } from '../paths';\nimport { repositoryId, repositoryLabel, shortId } from '../repositoryIdentity';\nimport { MAX_WORKTREE_MESSAGE_BYTES, type WorktreeMessageInbox, type WorktreeMessageParty } from '../worktreeEvents';\nimport { planPrune, reconcile, refuseClose, refuseSpawn, worktreeDirectory } from '../worktreeNaming';\nimport { createWorktreeRegistry } from '../worktreeRegistry';\n\nexport interface WorktreeContext {\n /** Where the calling session is working, used to find the repository. */\n cwd: string;\n /** The calling session, recorded as the new session's parent. */\n sessionId: string;\n}\n\nexport interface SpawnWorktreeRequest {\n branch: string;\n baseRef?: string;\n name?: string;\n}\n\nexport interface SpawnOptions {\n /** Aborted when the caller gives up, so a spawn nobody is waiting for stops. */\n signal?: AbortSignal;\n /** Phase labels, for a caller that can show them while the work runs. */\n onProgress?: (label: string) => void;\n}\n\nexport interface WorktreeOperations {\n spawn(context: WorktreeContext, request: SpawnWorktreeRequest, options?: SpawnOptions): Promise<WorktreeRecord>;\n close(context: WorktreeContext, id: string, force: boolean): Promise<WorktreeRecord>;\n list(context: WorktreeContext): Promise<WorktreeRecord[]>;\n status(context: WorktreeContext, id: string): Promise<{ record: WorktreeRecord; dirtyFiles: string[] }>;\n merge(context: WorktreeContext, id: string, message?: string): Promise<WorktreeRecord>;\n prune(context: WorktreeContext, dryRun: boolean): Promise<ReturnType<typeof planPrune>>;\n send(context: WorktreeContext, id: string, message: string): Promise<void>;\n messages(context: WorktreeContext, id: string): Promise<import('../worktreeEvents').WorktreeMessage[]>;\n}\n\nexport interface WorktreeOperationsDeps {\n git: WorktreeGit;\n /** The canonical hub-owned session lifecycle. */\n sessionService?: DoomHubSessionService;\n /** Session-local inbox for parent/worktree messages. */\n messageInbox?: WorktreeMessageInbox;\n /** Injected so a test never copies a real dependency tree. */\n mirror?: typeof mirrorComposition;\n homeDir?: string;\n /** Injected so a record's createdAt is reproducible in a test. */\n now?: () => Date;\n}\n\nexport function createWorktreeOperations(deps: WorktreeOperationsDeps): WorktreeOperations {\n const { git } = deps;\n const sessionService = deps.sessionService;\n const mirror = deps.mirror ?? mirrorComposition;\n const now = deps.now ?? (() => new Date());\n const requireSessionService = (): DoomHubSessionService => {\n if (sessionService === undefined)\n throw new HubUnavailableError('The cockpit session service is unavailable. Start the cockpit and try again.');\n return sessionService;\n };\n const requireMessageInbox = (): WorktreeMessageInbox => {\n if (deps.messageInbox === undefined)\n throw new HubUnavailableError('The Git message service is unavailable. Start the cockpit and try again.');\n return deps.messageInbox;\n };\n const probe = {\n alive: (record: WorktreeRecord) => requireSessionService().isLive(record.sessionId),\n exists: (path: string) => fs.existsSync(path),\n };\n\n /**\n * Everything an action needs about the repository it is acting on.\n *\n * Resolved per call rather than cached: a session's cwd is stable, but the\n * worktree registry is shared and another process may have written it since\n * the last call.\n */\n const resolve = async (context: WorktreeContext) => {\n const root = await git.repositoryRoot(context.cwd);\n if (root === undefined) {\n throw new DoomGitExpectedError(\n 'not_a_repository',\n `${context.cwd} is not inside a git repository.`,\n false,\n 'Run this from a repository checkout.',\n );\n }\n const store = createWorktreeRegistry(registryFile(root, deps.homeDir));\n return { root, store, records: store.list() };\n };\n\n const require = (records: readonly WorktreeRecord[], id: string): WorktreeRecord => {\n const record = records.find((entry) => entry.id === id);\n if (record === undefined) {\n throw new DoomGitExpectedError(\n 'worktree_not_found',\n `No worktree with id ${id}.`,\n false,\n 'Call list to see the current ids.',\n );\n }\n return record;\n };\n\n /**\n * Refuses to destroy or merge a worktree another live session is using.\n *\n * `parentSessionId` records who asked for the worktree. Two sessions in one\n * checkout share this registry, so without the check either could close the\n * other's work in progress by id.\n *\n * Once that session is gone there is no owner left to protect, and refusing\n * would strand the worktree: nothing else could ever close it.\n */\n const requireOwner = (context: WorktreeContext, record: WorktreeRecord, action: string): void => {\n if (record.parentSessionId === context.sessionId) return;\n if (!requireSessionService().isLive(record.parentSessionId)) return;\n throw new DoomGitExpectedError(\n 'worktree_not_owned',\n `Worktree ${record.id} belongs to another session.`,\n false,\n `Ask the session that created it to ${action} it, or close that session first.`,\n );\n };\n\n const peerFor = (\n context: WorktreeContext,\n record: WorktreeRecord,\n ): { sessionId: string; party: WorktreeMessageParty } => {\n if (context.sessionId === record.parentSessionId) return { sessionId: record.sessionId, party: 'parent' };\n if (context.sessionId === record.sessionId) return { sessionId: record.parentSessionId, party: 'child' };\n throw new DoomGitExpectedError(\n 'worktree_not_owned',\n `Worktree ${record.id} belongs to another session.`,\n false,\n 'Use a worktree owned by this session.',\n );\n };\n\n const requirePeerLive = (peerSessionId: string): void => {\n if (!requireSessionService().isLive(peerSessionId)) {\n throw new DoomGitExpectedError(\n 'worktree_peer_unavailable',\n 'The other worktree session is no longer live.',\n false,\n 'Start a new worktree session before sending a message.',\n );\n }\n };\n\n return {\n async spawn(context, request, options) {\n const { root, store, records } = await resolve(context);\n const refusal = refuseSpawn({ branch: request.branch, existing: records });\n if (refusal !== undefined) {\n throw new DoomGitExpectedError('worktree_exists', refusal, false, 'Pick another branch name, or close it.');\n }\n const baseRef = request.baseRef ?? (await git.currentBranch(root)) ?? 'HEAD';\n const id = shortId(randomUUID());\n const path = worktreeDirectory({\n worktreesRoot: worktreesRoot(deps.homeDir),\n repositoryLabel: repositoryLabel(root),\n repositoryId: repositoryId(root),\n branch: request.branch,\n shortId: id,\n });\n\n // The worktree and the branch are made by one command, so they are undone\n // by one too. `worktree remove` leaves the branch behind, and a branch\n // nobody asked for is what a failed spawn used to leave on the floor.\n const cancelled = (): boolean => options?.signal?.aborted === true;\n const rollback = async (): Promise<string> => {\n await git.removeWorktree({ repositoryRoot: root, path, force: true }).catch(() => undefined);\n const deleted = await git.deleteBranch({ repositoryRoot: root, branch: request.branch }).catch(() => false);\n return deleted ? '' : ` The branch ${request.branch} has work on it and was kept.`;\n };\n\n options?.onProgress?.(`creating branch ${request.branch}\\u2026`);\n await git.addWorktree({ repositoryRoot: root, path, branch: request.branch, baseRef });\n\n // Checked here rather than only inside the session call: this is the\n // point where a checkout exists that nothing has recorded yet, which is\n // exactly the state an interrupted spawn used to leave behind.\n if (cancelled()) {\n const kept = await rollback();\n throw new DoomGitExpectedError(\n 'spawn_cancelled',\n `Cancelled before the session started.${kept}`,\n false,\n 'The worktree was removed; run it again when you are ready.',\n );\n }\n\n // Before the session, because the session composes the extensions this\n // repository's config names and those live in build output git does not\n // track. A worktree without it starts and dies on the first package it\n // cannot resolve. Nothing here can fail the spawn: a repository with no\n // build output to mirror simply has none.\n options?.onProgress?.('mirroring build output\\u2026');\n mirror(root, path);\n\n // The worktree exists from here on, so every later failure has to leave\n // it removed or recorded. An unrecorded directory on disk is the one\n // outcome with no way back: nothing would ever list it again.\n options?.onProgress?.('starting session\\u2026');\n let sessionId: string;\n try {\n const session = await requireSessionService().create({\n cwd: path,\n name: request.name ?? request.branch,\n parentSessionId: context.sessionId,\n sessionProvenance: 'worktree',\n ...(options?.signal === undefined ? {} : { signal: options.signal }),\n });\n sessionId = session.sessionId;\n } catch (error) {\n const kept = await rollback();\n if (cancelled()) {\n throw new DoomGitExpectedError(\n 'spawn_cancelled',\n `Cancelled while the session was starting.${kept}`,\n false,\n 'The worktree was removed; run it again when you are ready.',\n );\n }\n if (error instanceof HubUnavailableError) {\n throw new DoomGitExpectedError(\n 'hub_unavailable',\n `${error.message}${kept}`,\n true,\n 'Start the cockpit and try again.',\n );\n }\n throw error;\n }\n\n const record: WorktreeRecord = {\n version: WORKTREE_RECORD_VERSION,\n id,\n branch: request.branch,\n baseRef,\n path,\n repositoryRoot: root,\n sessionId,\n parentSessionId: context.sessionId,\n status: 'running',\n createdAt: now().toISOString(),\n };\n try {\n store.replace([...records, record]);\n } catch (error) {\n // A live session with no record is the worst outcome available here:\n // it runs, and no id anything can name points at it. The session goes\n // back too, rather than being left for someone to find by hand.\n await requireSessionService()\n .close(sessionId)\n .catch(() => undefined);\n const kept = await rollback();\n throw new DoomGitExpectedError(\n 'registry_write_failed',\n `The worktree was created but the registry could not be written (${(error as Error).message}).${kept}`,\n true,\n 'Check the registry file for permissions or free space, then try again.',\n );\n }\n return record;\n },\n\n async close(context, id, force) {\n const { root, store, records } = await resolve(context);\n const record = require(records, id);\n requireOwner(context, record, 'close');\n const dirtyFiles = fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : [];\n const refusal = refuseClose({ record, dirtyFiles, force });\n if (refusal !== undefined) {\n throw new DoomGitExpectedError('worktree_dirty', refusal, false, 'Commit the work, or pass force: true.');\n }\n // The session is stopped before the directory goes. Removing a checkout\n // while a process still holds files open in it is how a half-removed\n // worktree and a stale git administrative entry are made.\n await requireSessionService().close(record.sessionId);\n await git.removeWorktree({ repositoryRoot: root, path: record.path, force });\n store.replace(records.filter((entry) => entry.id !== id));\n return record;\n },\n\n async list(context) {\n const { store, records } = await resolve(context);\n const outcome = reconcile(records, probe);\n if (outcome.changed.length > 0) store.replace(outcome.records);\n return outcome.records;\n },\n\n async status(context, id) {\n const { records } = await resolve(context);\n const record = require(records, id);\n const dirtyFiles = fs.existsSync(record.path) ? await git.dirtyFiles(record.path) : [];\n return { record, dirtyFiles };\n },\n\n async merge(context, id, message) {\n const { root, records } = await resolve(context);\n const record = require(records, id);\n requireOwner(context, record, 'merge');\n // The merge lands in the parent, so the parent is what must be clean. A\n // dirty parent would mix the person's in-flight edits into a merge commit\n // they did not intend to make.\n const parentDirty = await git.dirtyFiles(root);\n if (parentDirty.length > 0) {\n throw new DoomGitExpectedError(\n 'worktree_dirty',\n `The parent checkout has ${String(parentDirty.length)} uncommitted file(s): ${parentDirty.slice(0, 10).join(', ')}.`,\n false,\n 'Commit or stash the parent checkout first.',\n );\n }\n await git.mergeBranch({\n repositoryRoot: root,\n branch: record.branch,\n ...(message === undefined ? {} : { message }),\n });\n return record;\n },\n\n /** Sends only between the parent session and its own worktree session. */\n async send(context, id, message) {\n if (Buffer.byteLength(message, 'utf8') > MAX_WORKTREE_MESSAGE_BYTES) {\n throw new DoomGitExpectedError(\n 'message_too_large',\n `A message may not exceed ${String(MAX_WORKTREE_MESSAGE_BYTES)} bytes.`,\n false,\n 'Send a shorter message.',\n );\n }\n const { records } = await resolve(context);\n const record = require(records, id);\n const peer = peerFor(context, record);\n requirePeerLive(peer.sessionId);\n requireMessageInbox().send(peer.sessionId, {\n version: 1,\n worktreeId: record.id,\n fromSessionId: context.sessionId,\n from: peer.party,\n text: message,\n sentAt: new Date().toISOString(),\n });\n },\n\n async messages(context, id) {\n const { records } = await resolve(context);\n const record = require(records, id);\n peerFor(context, record);\n return requireMessageInbox().receive(record.id);\n },\n\n async prune(context, dryRun) {\n const { root, store, records } = await resolve(context);\n const reconciled = reconcile(records, probe);\n const gitPaths = await git.listWorktreePaths(root);\n const dirtyByPath = new Map<string, readonly string[]>();\n for (const record of reconciled.records) {\n if (record.status === 'orphaned' && fs.existsSync(record.path)) {\n dirtyByPath.set(record.path, await git.dirtyFiles(record.path));\n }\n }\n const plan = planPrune({\n records: reconciled.records,\n gitPaths,\n worktreesRoot: worktreesRoot(deps.homeDir),\n dirtyByPath,\n });\n if (dryRun) {\n store.replace(reconciled.records);\n return plan;\n }\n for (const record of plan.remove) {\n await git.removeWorktree({ repositoryRoot: root, path: record.path, force: false });\n }\n // The checkout goes, so the branch it was made for goes with it. Safe\n // delete only: git keeps anything holding commits, and the plan says\n // which ones it kept rather than leaving the reader to notice later.\n for (const record of [...plan.remove, ...plan.forget]) {\n const deleted = await git.deleteBranch({ repositoryRoot: root, branch: record.branch }).catch(() => false);\n if (!deleted) plan.keptBranches.push(record.branch);\n }\n const dropped = new Set([...plan.remove, ...plan.forget].map((record) => record.id));\n store.replace(reconciled.records.filter((record) => !dropped.has(record.id)));\n return plan;\n },\n };\n}\n"],"mappings":";;;;;;;;;;AA2DA,SAAgB,yBAAyB,MAAkD;CACzF,MAAM,EAAE,QAAQ;CAChB,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AAO,IAAI,CAAC;GAGlE,MAAM,OAAO,UAAU;IACrB,SAAS,WAAW;IACpB;IACA,eAAe,cAAc,KAAK,OAAO;IACzC;GACF,CAAC;GACD,IAAI,QAAQ;IACV,MAAM,QAAQ,WAAW,OAAO;IAChC,OAAO;GACT;GACA,KAAK,MAAM,UAAU,KAAK,QACxB,MAAM,IAAI,eAAe;IAAE,gBAAgB;IAAM,MAAM,OAAO;IAAM,OAAO;GAAM,CAAC;GAKpF,KAAK,MAAM,UAAU,CAAC,GAAG,KAAK,QAAQ,GAAG,KAAK,MAAM,GAElD,IAAI,CAAC,MADiB,IAAI,aAAa;IAAE,gBAAgB;IAAM,QAAQ,OAAO;GAAO,CAAC,CAAC,CAAC,YAAY,KAAK,GAC3F,KAAK,aAAa,KAAK,OAAO,MAAM;GAEpD,MAAM,UAAU,IAAI,IAAI,CAAC,GAAG,KAAK,QAAQ,GAAG,KAAK,MAAM,CAAC,CAAC,KAAK,WAAW,OAAO,EAAE,CAAC;GACnF,MAAM,QAAQ,WAAW,QAAQ,QAAQ,WAAW,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,CAAC;GAC5E,OAAO;EACT;CACF;AACF"}
@@ -0,0 +1,38 @@
1
+ const require_index = require("../atomicJson/index.cjs");
2
+ //#region src/services/worktreeRegistry/index.ts
3
+ function isRecord(value) {
4
+ if (typeof value !== "object" || value === null) return false;
5
+ const record = value;
6
+ return record.version === 1 && typeof record.id === "string" && record.id !== "" && typeof record.path === "string" && typeof record.branch === "string" && typeof record.sessionId === "string";
7
+ }
8
+ /**
9
+ * The worktree registry for one repository, as a single JSON file.
10
+ *
11
+ * One file rather than a file per worktree, and read-modify-write rather than
12
+ * merging: every write comes from a tool call in one session's turn, so there
13
+ * is no concurrent writer to reconcile with. Choosing the simpler shape now
14
+ * means a reader can see the whole registry in one place; if concurrent writers
15
+ * ever appear, that is the point to revisit, not before.
16
+ *
17
+ * A file that does not parse is treated as empty rather than fatal. Losing
18
+ * track of worktrees is recoverable through prune; refusing to run is not.
19
+ */
20
+ function createWorktreeRegistry(file) {
21
+ return {
22
+ list() {
23
+ const parsed = require_index.readJson(file);
24
+ if (!parsed || parsed.version !== 1 || !Array.isArray(parsed.entries)) return [];
25
+ return parsed.entries.filter(isRecord);
26
+ },
27
+ replace(entries) {
28
+ require_index.writeJsonAtomic(file, {
29
+ version: 1,
30
+ entries
31
+ });
32
+ }
33
+ };
34
+ }
35
+ //#endregion
36
+ exports.createWorktreeRegistry = createWorktreeRegistry;
37
+
38
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["readJson"],"sources":["../../../../src/services/worktreeRegistry/index.ts"],"sourcesContent":["import {\n WORKTREE_RECORD_VERSION,\n type WorktreeRecord,\n type WorktreeRegistryFile,\n type WorktreeRegistryStore,\n} from '../../types/worktreeRegistry';\nimport { readJson, writeJsonAtomic } from '../atomicJson';\n\nfunction isRecord(value: unknown): value is WorktreeRecord {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Partial<WorktreeRecord>;\n return (\n record.version === WORKTREE_RECORD_VERSION &&\n typeof record.id === 'string' &&\n record.id !== '' &&\n typeof record.path === 'string' &&\n typeof record.branch === 'string' &&\n typeof record.sessionId === 'string'\n );\n}\n\n/**\n * The worktree registry for one repository, as a single JSON file.\n *\n * One file rather than a file per worktree, and read-modify-write rather than\n * merging: every write comes from a tool call in one session's turn, so there\n * is no concurrent writer to reconcile with. Choosing the simpler shape now\n * means a reader can see the whole registry in one place; if concurrent writers\n * ever appear, that is the point to revisit, not before.\n *\n * A file that does not parse is treated as empty rather than fatal. Losing\n * track of worktrees is recoverable through prune; refusing to run is not.\n */\nexport function createWorktreeRegistry(file: string): WorktreeRegistryStore {\n return {\n list() {\n const parsed = readJson<WorktreeRegistryFile>(file);\n if (!parsed || parsed.version !== WORKTREE_RECORD_VERSION || !Array.isArray(parsed.entries)) return [];\n return parsed.entries.filter(isRecord);\n },\n replace(entries) {\n writeJsonAtomic(file, { version: WORKTREE_RECORD_VERSION, entries } satisfies WorktreeRegistryFile);\n },\n };\n}\n"],"mappings":";;AAQA,SAAS,SAAS,OAAyC;CACzD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,SAAS;CACf,OACE,OAAO,YAAA,KACP,OAAO,OAAO,OAAO,YACrB,OAAO,OAAO,MACd,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,WAAW,YACzB,OAAO,OAAO,cAAc;AAEhC;;;;;;;;;;;;;AAcA,SAAgB,uBAAuB,MAAqC;CAC1E,OAAO;EACL,OAAO;GACL,MAAM,SAASA,cAAAA,SAA+B,IAAI;GAClD,IAAI,CAAC,UAAU,OAAO,YAAA,KAAuC,CAAC,MAAM,QAAQ,OAAO,OAAO,GAAG,OAAO,CAAC;GACrG,OAAO,OAAO,QAAQ,OAAO,QAAQ;EACvC;EACA,QAAQ,SAAS;GACf,cAAA,gBAAgB,MAAM;IAAE,SAAA;IAAkC;GAAQ,CAAgC;EACpG;CACF;AACF"}
@@ -0,0 +1,38 @@
1
+ import { readJson, writeJsonAtomic } from "../atomicJson/index.mjs";
2
+ //#region src/services/worktreeRegistry/index.ts
3
+ function isRecord(value) {
4
+ if (typeof value !== "object" || value === null) return false;
5
+ const record = value;
6
+ return record.version === 1 && typeof record.id === "string" && record.id !== "" && typeof record.path === "string" && typeof record.branch === "string" && typeof record.sessionId === "string";
7
+ }
8
+ /**
9
+ * The worktree registry for one repository, as a single JSON file.
10
+ *
11
+ * One file rather than a file per worktree, and read-modify-write rather than
12
+ * merging: every write comes from a tool call in one session's turn, so there
13
+ * is no concurrent writer to reconcile with. Choosing the simpler shape now
14
+ * means a reader can see the whole registry in one place; if concurrent writers
15
+ * ever appear, that is the point to revisit, not before.
16
+ *
17
+ * A file that does not parse is treated as empty rather than fatal. Losing
18
+ * track of worktrees is recoverable through prune; refusing to run is not.
19
+ */
20
+ function createWorktreeRegistry(file) {
21
+ return {
22
+ list() {
23
+ const parsed = readJson(file);
24
+ if (!parsed || parsed.version !== 1 || !Array.isArray(parsed.entries)) return [];
25
+ return parsed.entries.filter(isRecord);
26
+ },
27
+ replace(entries) {
28
+ writeJsonAtomic(file, {
29
+ version: 1,
30
+ entries
31
+ });
32
+ }
33
+ };
34
+ }
35
+ //#endregion
36
+ export { createWorktreeRegistry };
37
+
38
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/worktreeRegistry/index.ts"],"sourcesContent":["import {\n WORKTREE_RECORD_VERSION,\n type WorktreeRecord,\n type WorktreeRegistryFile,\n type WorktreeRegistryStore,\n} from '../../types/worktreeRegistry';\nimport { readJson, writeJsonAtomic } from '../atomicJson';\n\nfunction isRecord(value: unknown): value is WorktreeRecord {\n if (typeof value !== 'object' || value === null) return false;\n const record = value as Partial<WorktreeRecord>;\n return (\n record.version === WORKTREE_RECORD_VERSION &&\n typeof record.id === 'string' &&\n record.id !== '' &&\n typeof record.path === 'string' &&\n typeof record.branch === 'string' &&\n typeof record.sessionId === 'string'\n );\n}\n\n/**\n * The worktree registry for one repository, as a single JSON file.\n *\n * One file rather than a file per worktree, and read-modify-write rather than\n * merging: every write comes from a tool call in one session's turn, so there\n * is no concurrent writer to reconcile with. Choosing the simpler shape now\n * means a reader can see the whole registry in one place; if concurrent writers\n * ever appear, that is the point to revisit, not before.\n *\n * A file that does not parse is treated as empty rather than fatal. Losing\n * track of worktrees is recoverable through prune; refusing to run is not.\n */\nexport function createWorktreeRegistry(file: string): WorktreeRegistryStore {\n return {\n list() {\n const parsed = readJson<WorktreeRegistryFile>(file);\n if (!parsed || parsed.version !== WORKTREE_RECORD_VERSION || !Array.isArray(parsed.entries)) return [];\n return parsed.entries.filter(isRecord);\n },\n replace(entries) {\n writeJsonAtomic(file, { version: WORKTREE_RECORD_VERSION, entries } satisfies WorktreeRegistryFile);\n },\n };\n}\n"],"mappings":";;AAQA,SAAS,SAAS,OAAyC;CACzD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,SAAS;CACf,OACE,OAAO,YAAA,KACP,OAAO,OAAO,OAAO,YACrB,OAAO,OAAO,MACd,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,WAAW,YACzB,OAAO,OAAO,cAAc;AAEhC;;;;;;;;;;;;;AAcA,SAAgB,uBAAuB,MAAqC;CAC1E,OAAO;EACL,OAAO;GACL,MAAM,SAAS,SAA+B,IAAI;GAClD,IAAI,CAAC,UAAU,OAAO,YAAA,KAAuC,CAAC,MAAM,QAAQ,OAAO,OAAO,GAAG,OAAO,CAAC;GACrG,OAAO,OAAO,QAAQ,OAAO,QAAQ;EACvC;EACA,QAAQ,SAAS;GACf,gBAAgB,MAAM;IAAE,SAAA;IAAkC;GAAQ,CAAgC;EACpG;CACF;AACF"}
@@ -1,17 +1,16 @@
1
1
  import { WorktreeOperations } from "../services/worktreeOperations/index.cjs";
2
2
  //#region src/types/extension.d.ts
3
- type GitNotificationLevel = 'info';
4
- interface GitExtensionResult {
3
+ export type GitNotificationLevel = 'info';
4
+ export interface GitExtensionResult {
5
5
  message: string;
6
6
  level: GitNotificationLevel;
7
7
  }
8
- interface GitExtensionService {
8
+ export interface GitExtensionService {
9
9
  execute(): Promise<GitExtensionResult>;
10
10
  }
11
- interface GitExtensionDependencies {
11
+ export interface GitExtensionDependencies {
12
12
  service: GitExtensionService;
13
13
  operations: WorktreeOperations;
14
14
  }
15
15
  //#endregion
16
- export { GitExtensionDependencies, GitExtensionResult, GitExtensionService, GitNotificationLevel };
17
16
  //# sourceMappingURL=extension.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/types/extension.ts"],"mappings":";;YAGY;iBAEK;EACf;EACA,OAAO;;iBAGQ;EACf,WAAW,QAAQ;;iBAGJ;EACf,SAAS;EACT,YAAY"}
@@ -1,17 +1,16 @@
1
1
  import { WorktreeOperations } from "../services/worktreeOperations/index.mjs";
2
2
  //#region src/types/extension.d.ts
3
- type GitNotificationLevel = 'info';
4
- interface GitExtensionResult {
3
+ export type GitNotificationLevel = 'info';
4
+ export interface GitExtensionResult {
5
5
  message: string;
6
6
  level: GitNotificationLevel;
7
7
  }
8
- interface GitExtensionService {
8
+ export interface GitExtensionService {
9
9
  execute(): Promise<GitExtensionResult>;
10
10
  }
11
- interface GitExtensionDependencies {
11
+ export interface GitExtensionDependencies {
12
12
  service: GitExtensionService;
13
13
  operations: WorktreeOperations;
14
14
  }
15
15
  //#endregion
16
- export { GitExtensionDependencies, GitExtensionResult, GitExtensionService, GitNotificationLevel };
17
16
  //# sourceMappingURL=extension.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/types/extension.ts"],"mappings":";;YAGY;iBAEK;EACf;EACA,OAAO;;iBAGQ;EACf,WAAW,QAAQ;;iBAGJ;EACf,SAAS;EACT,YAAY"}
@@ -0,0 +1,20 @@
1
+ //#region src/types/webWorktrees.ts
2
+ /**
3
+ * The cockpit's view of this session's worktrees.
4
+ *
5
+ * DESIGN PATTERNS:
6
+ * - Declarations only. The channel frame type is a constant so the hub and the
7
+ * page cannot drift apart on a string.
8
+ * - A view is the subset of a record the dock needs, not the record. The
9
+ * registry may hold paths and provenance the page has no business rendering.
10
+ *
11
+ * AVOID:
12
+ * - Adding behaviour here. This file is imported by browser code, so it must
13
+ * stay free of node builtins.
14
+ */
15
+ /** The data channel carrying one session's worktrees to the page. */
16
+ const GIT_WORKTREES_TYPE = "git_worktrees";
17
+ //#endregion
18
+ exports.GIT_WORKTREES_TYPE = GIT_WORKTREES_TYPE;
19
+
20
+ //# sourceMappingURL=webWorktrees.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webWorktrees.cjs","names":[],"sources":["../../../src/types/webWorktrees.ts"],"sourcesContent":["/**\n * The cockpit's view of this session's worktrees.\n *\n * DESIGN PATTERNS:\n * - Declarations only. The channel frame type is a constant so the hub and the\n * page cannot drift apart on a string.\n * - A view is the subset of a record the dock needs, not the record. The\n * registry may hold paths and provenance the page has no business rendering.\n *\n * AVOID:\n * - Adding behaviour here. This file is imported by browser code, so it must\n * stay free of node builtins.\n */\n\n/** The data channel carrying one session's worktrees to the page. */\nexport const GIT_WORKTREES_TYPE = 'git_worktrees';\n\n/** One worktree, as the activity dock and its panel render it. */\nexport interface WorktreeView {\n id: string;\n branch: string;\n path: string;\n /** The session the hub started for this worktree, when it is still live. */\n sessionId: string | null;\n /** True once the directory the record names has gone missing. */\n orphaned: boolean;\n /**\n * True when the session that asked for this worktree is gone.\n *\n * An owned worktree is only ever shown to its own session. This flag marks\n * the exception: once the parent is dead nobody would see the worktree at\n * all, so every session in the repository does, and may close it.\n */\n unowned: boolean;\n}\n\n/**\n * What the panel asks the hub channel to do.\n *\n * The dock acts through its own channel rather than through the agent: a\n * worktree made from the panel and one made by the tool take the same\n * `worktreeOperations` path, but the panel no longer has to spend a turn of\n * the conversation to get there.\n */\nexport type GitWorktreesCommand =\n | { action: 'create'; branch: string; baseRef?: string }\n | { action: 'close'; id: string; force?: boolean };\n\nexport interface GitWorktreesPayload {\n worktrees: WorktreeView[];\n /** Label of the operation in flight, absent when the session is idle. */\n pending?: string;\n /** The last failure, cleared when the next command starts. */\n error?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,qBAAqB"}
@@ -0,0 +1,20 @@
1
+ //#region src/types/webWorktrees.ts
2
+ /**
3
+ * The cockpit's view of this session's worktrees.
4
+ *
5
+ * DESIGN PATTERNS:
6
+ * - Declarations only. The channel frame type is a constant so the hub and the
7
+ * page cannot drift apart on a string.
8
+ * - A view is the subset of a record the dock needs, not the record. The
9
+ * registry may hold paths and provenance the page has no business rendering.
10
+ *
11
+ * AVOID:
12
+ * - Adding behaviour here. This file is imported by browser code, so it must
13
+ * stay free of node builtins.
14
+ */
15
+ /** The data channel carrying one session's worktrees to the page. */
16
+ const GIT_WORKTREES_TYPE = "git_worktrees";
17
+ //#endregion
18
+ export { GIT_WORKTREES_TYPE };
19
+
20
+ //# sourceMappingURL=webWorktrees.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webWorktrees.mjs","names":[],"sources":["../../../src/types/webWorktrees.ts"],"sourcesContent":["/**\n * The cockpit's view of this session's worktrees.\n *\n * DESIGN PATTERNS:\n * - Declarations only. The channel frame type is a constant so the hub and the\n * page cannot drift apart on a string.\n * - A view is the subset of a record the dock needs, not the record. The\n * registry may hold paths and provenance the page has no business rendering.\n *\n * AVOID:\n * - Adding behaviour here. This file is imported by browser code, so it must\n * stay free of node builtins.\n */\n\n/** The data channel carrying one session's worktrees to the page. */\nexport const GIT_WORKTREES_TYPE = 'git_worktrees';\n\n/** One worktree, as the activity dock and its panel render it. */\nexport interface WorktreeView {\n id: string;\n branch: string;\n path: string;\n /** The session the hub started for this worktree, when it is still live. */\n sessionId: string | null;\n /** True once the directory the record names has gone missing. */\n orphaned: boolean;\n /**\n * True when the session that asked for this worktree is gone.\n *\n * An owned worktree is only ever shown to its own session. This flag marks\n * the exception: once the parent is dead nobody would see the worktree at\n * all, so every session in the repository does, and may close it.\n */\n unowned: boolean;\n}\n\n/**\n * What the panel asks the hub channel to do.\n *\n * The dock acts through its own channel rather than through the agent: a\n * worktree made from the panel and one made by the tool take the same\n * `worktreeOperations` path, but the panel no longer has to spend a turn of\n * the conversation to get there.\n */\nexport type GitWorktreesCommand =\n | { action: 'create'; branch: string; baseRef?: string }\n | { action: 'close'; id: string; force?: boolean };\n\nexport interface GitWorktreesPayload {\n worktrees: WorktreeView[];\n /** Label of the operation in flight, absent when the session is idle. */\n pending?: string;\n /** The last failure, cleared when the next command starts. */\n error?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,qBAAqB"}
@@ -14,9 +14,9 @@
14
14
  * directory has vanished, but the worktree may still hold uncommitted work, so
15
15
  * the record is kept until someone decides what to do with it.
16
16
  */
17
- type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
18
- declare const WORKTREE_RECORD_VERSION = 1;
19
- interface WorktreeRecord {
17
+ export type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
18
+ export declare const WORKTREE_RECORD_VERSION = 1;
19
+ export interface WorktreeRecord {
20
20
  version: typeof WORKTREE_RECORD_VERSION;
21
21
  /** This registry's own id, distinct from the session id, and stable across restarts. */
22
22
  id: string;
@@ -37,5 +37,4 @@ interface WorktreeRecord {
37
37
  createdAt: string;
38
38
  }
39
39
  //#endregion
40
- export { WORKTREE_RECORD_VERSION, WorktreeRecord, WorktreeStatus };
41
40
  //# sourceMappingURL=worktreeRegistry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktreeRegistry.d.cts","names":[],"sources":["../../../src/types/worktreeRegistry.ts"],"mappings":";;;;;;;;;;;;;;;;YAgBY;qBAEC;iBAEI;EACf,gBAAgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,QAAQ;;EAER"}
@@ -14,9 +14,9 @@
14
14
  * directory has vanished, but the worktree may still hold uncommitted work, so
15
15
  * the record is kept until someone decides what to do with it.
16
16
  */
17
- type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
18
- declare const WORKTREE_RECORD_VERSION = 1;
19
- interface WorktreeRecord {
17
+ export type WorktreeStatus = 'spawning' | 'running' | 'closing' | 'orphaned';
18
+ export declare const WORKTREE_RECORD_VERSION = 1;
19
+ export interface WorktreeRecord {
20
20
  version: typeof WORKTREE_RECORD_VERSION;
21
21
  /** This registry's own id, distinct from the session id, and stable across restarts. */
22
22
  id: string;
@@ -37,5 +37,4 @@ interface WorktreeRecord {
37
37
  createdAt: string;
38
38
  }
39
39
  //#endregion
40
- export { WORKTREE_RECORD_VERSION, WorktreeRecord, WorktreeStatus };
41
40
  //# sourceMappingURL=worktreeRegistry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktreeRegistry.d.mts","names":[],"sources":["../../../src/types/worktreeRegistry.ts"],"mappings":";;;;;;;;;;;;;;;;YAgBY;qBAEC;iBAEI;EACf,gBAAgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA,QAAQ;;EAER"}