@cerbur/clutch-dsh-worktree 0.1.9 → 0.1.12

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 (565) hide show
  1. package/README.md +230 -231
  2. package/README.zh.md +184 -225
  3. package/assets/screenshots/screenshots-dashboard.webp +0 -0
  4. package/assets/screenshots/screenshots-en.png +0 -0
  5. package/assets/screenshots/screenshots-import.png +0 -0
  6. package/assets/screenshots/screenshots-zh.png +0 -0
  7. package/lib/client/WorktreeSurface.d.ts +4 -7
  8. package/lib/client/WorktreeSurface.d.ts.map +1 -1
  9. package/lib/client/WorktreeSurface.js +179 -1418
  10. package/lib/client/WorktreeSurface.js.map +1 -1
  11. package/lib/client/{WorktreeContext.d.ts → context/WorktreeContext.d.ts} +1 -1
  12. package/lib/client/context/WorktreeContext.d.ts.map +1 -0
  13. package/lib/client/context/WorktreeContext.js.map +1 -0
  14. package/lib/client/{WorktreeHeroContext.d.ts → context/WorktreeHeroContext.d.ts} +1 -1
  15. package/lib/client/context/WorktreeHeroContext.d.ts.map +1 -0
  16. package/lib/client/context/WorktreeHeroContext.js.map +1 -0
  17. package/lib/client/{worktree-context-store.d.ts → context/worktree-context-store.d.ts} +1 -1
  18. package/lib/client/context/worktree-context-store.d.ts.map +1 -0
  19. package/lib/client/{worktree-context-store.js → context/worktree-context-store.js} +2 -2
  20. package/lib/client/context/worktree-context-store.js.map +1 -0
  21. package/lib/client/{worktree-context.d.ts → context/worktree-context.d.ts} +1 -1
  22. package/lib/client/context/worktree-context.d.ts.map +1 -0
  23. package/lib/client/{worktree-context.js → context/worktree-context.js} +5 -3
  24. package/lib/client/context/worktree-context.js.map +1 -0
  25. package/lib/client/dashboard/DashboardHeaderAction.d.ts +20 -0
  26. package/lib/client/dashboard/DashboardHeaderAction.d.ts.map +1 -0
  27. package/lib/client/dashboard/DashboardHeaderAction.js +19 -0
  28. package/lib/client/dashboard/DashboardHeaderAction.js.map +1 -0
  29. package/lib/client/dashboard/OpenInAppButton.d.ts +9 -0
  30. package/lib/client/dashboard/OpenInAppButton.d.ts.map +1 -0
  31. package/lib/client/dashboard/OpenInAppButton.js +123 -0
  32. package/lib/client/dashboard/OpenInAppButton.js.map +1 -0
  33. package/lib/client/dashboard/WorktreeDashboard.d.ts +21 -0
  34. package/lib/client/dashboard/WorktreeDashboard.d.ts.map +1 -0
  35. package/lib/client/dashboard/WorktreeDashboard.js +211 -0
  36. package/lib/client/dashboard/WorktreeDashboard.js.map +1 -0
  37. package/lib/client/dashboard/WorktreeInstructions.d.ts +8 -0
  38. package/lib/client/dashboard/WorktreeInstructions.d.ts.map +1 -0
  39. package/lib/client/dashboard/WorktreeInstructions.js +53 -0
  40. package/lib/client/dashboard/WorktreeInstructions.js.map +1 -0
  41. package/lib/client/dashboard/dashboard-icon.d.ts +7 -0
  42. package/lib/client/dashboard/dashboard-icon.d.ts.map +1 -0
  43. package/lib/client/dashboard/dashboard-icon.js +6 -0
  44. package/lib/client/dashboard/dashboard-icon.js.map +1 -0
  45. package/lib/client/dashboard/dashboard-overlay.d.ts +11 -0
  46. package/lib/client/dashboard/dashboard-overlay.d.ts.map +1 -0
  47. package/lib/client/dashboard/dashboard-overlay.js +120 -0
  48. package/lib/client/dashboard/dashboard-overlay.js.map +1 -0
  49. package/lib/client/dashboard/dashboard-selection.d.ts +32 -0
  50. package/lib/client/dashboard/dashboard-selection.d.ts.map +1 -0
  51. package/lib/client/dashboard/dashboard-selection.js +31 -0
  52. package/lib/client/dashboard/dashboard-selection.js.map +1 -0
  53. package/lib/client/dashboard/dashboard-sessions.d.ts +6 -0
  54. package/lib/client/dashboard/dashboard-sessions.d.ts.map +1 -0
  55. package/lib/client/dashboard/dashboard-sessions.js +21 -0
  56. package/lib/client/dashboard/dashboard-sessions.js.map +1 -0
  57. package/lib/client/dashboard/open-in-app-controller.d.ts +30 -0
  58. package/lib/client/dashboard/open-in-app-controller.d.ts.map +1 -0
  59. package/lib/client/dashboard/open-in-app-controller.js +94 -0
  60. package/lib/client/dashboard/open-in-app-controller.js.map +1 -0
  61. package/lib/client/dashboard/vscode-url.d.ts +3 -0
  62. package/lib/client/dashboard/vscode-url.d.ts.map +1 -0
  63. package/lib/client/dashboard/vscode-url.js +9 -0
  64. package/lib/client/dashboard/vscode-url.js.map +1 -0
  65. package/lib/client/dashboard/worktree-acquisition-facts.d.ts +16 -0
  66. package/lib/client/dashboard/worktree-acquisition-facts.d.ts.map +1 -0
  67. package/lib/client/dashboard/worktree-acquisition-facts.js +14 -0
  68. package/lib/client/dashboard/worktree-acquisition-facts.js.map +1 -0
  69. package/lib/client/dsh-slot-contract.d.ts +5 -0
  70. package/lib/client/dsh-slot-contract.d.ts.map +1 -1
  71. package/lib/client/entry.d.ts +1 -1
  72. package/lib/client/entry.d.ts.map +1 -1
  73. package/lib/client/entry.js +90 -13
  74. package/lib/client/entry.js.map +1 -1
  75. package/lib/client/index.d.ts +3 -3
  76. package/lib/client/index.d.ts.map +1 -1
  77. package/lib/client/index.js +2 -2
  78. package/lib/client/index.js.map +1 -1
  79. package/lib/client/locales.d.ts +204 -0
  80. package/lib/client/locales.d.ts.map +1 -1
  81. package/lib/client/locales.js +214 -10
  82. package/lib/client/locales.js.map +1 -1
  83. package/lib/client/{WorktreeOverlay.d.ts → overlay/WorktreeOverlay.d.ts} +2 -2
  84. package/lib/client/overlay/WorktreeOverlay.d.ts.map +1 -0
  85. package/lib/client/{WorktreeOverlay.js → overlay/WorktreeOverlay.js} +2 -2
  86. package/lib/client/overlay/WorktreeOverlay.js.map +1 -0
  87. package/lib/client/overlay/overlay-bounds.d.ts.map +1 -0
  88. package/lib/client/overlay/overlay-bounds.js.map +1 -0
  89. package/lib/client/overlay/sidebar-overlay-geometry.d.ts.map +1 -0
  90. package/lib/client/overlay/sidebar-overlay-geometry.js.map +1 -0
  91. package/lib/client/permission/worktree-permission-icon.d.ts.map +1 -0
  92. package/lib/client/permission/worktree-permission-icon.js.map +1 -0
  93. package/lib/client/permission/worktree-permission.d.ts.map +1 -0
  94. package/lib/client/permission/worktree-permission.js.map +1 -0
  95. package/lib/client/session/session-labels.d.ts +9 -0
  96. package/lib/client/session/session-labels.d.ts.map +1 -0
  97. package/lib/client/session/session-labels.js +44 -0
  98. package/lib/client/session/session-labels.js.map +1 -0
  99. package/lib/client/session/session-view.d.ts.map +1 -0
  100. package/lib/client/session/session-view.js.map +1 -0
  101. package/lib/client/{virtual-workspace-membership.d.ts → session/virtual-workspace-membership.d.ts} +1 -1
  102. package/lib/client/session/virtual-workspace-membership.d.ts.map +1 -0
  103. package/lib/client/{virtual-workspace-membership.js → session/virtual-workspace-membership.js} +1 -1
  104. package/lib/client/session/virtual-workspace-membership.js.map +1 -0
  105. package/lib/client/{worktree-session-fork.d.ts → session/worktree-session-fork.d.ts} +7 -1
  106. package/lib/client/session/worktree-session-fork.d.ts.map +1 -0
  107. package/lib/client/{worktree-session-fork.js → session/worktree-session-fork.js} +50 -4
  108. package/lib/client/session/worktree-session-fork.js.map +1 -0
  109. package/lib/client/session/worktree-session-order.d.ts.map +1 -0
  110. package/lib/client/session/worktree-session-order.js.map +1 -0
  111. package/lib/client/session/worktree-session-position.d.ts.map +1 -0
  112. package/lib/client/session/worktree-session-position.js.map +1 -0
  113. package/lib/client/{worktree-session.d.ts → session/worktree-session.d.ts} +3 -3
  114. package/lib/client/session/worktree-session.d.ts.map +1 -0
  115. package/lib/client/{worktree-session.js → session/worktree-session.js} +3 -3
  116. package/lib/client/session/worktree-session.js.map +1 -0
  117. package/lib/client/surface/actions/lifecycle-commands.d.ts +9 -0
  118. package/lib/client/surface/actions/lifecycle-commands.d.ts.map +1 -0
  119. package/lib/client/surface/actions/lifecycle-commands.js +243 -0
  120. package/lib/client/surface/actions/lifecycle-commands.js.map +1 -0
  121. package/lib/client/surface/actions/useDragActions.d.ts +26 -0
  122. package/lib/client/surface/actions/useDragActions.d.ts.map +1 -0
  123. package/lib/client/surface/actions/useDragActions.js +125 -0
  124. package/lib/client/surface/actions/useDragActions.js.map +1 -0
  125. package/lib/client/surface/actions/useLifecycleActions.d.ts +30 -0
  126. package/lib/client/surface/actions/useLifecycleActions.d.ts.map +1 -0
  127. package/lib/client/surface/actions/useLifecycleActions.js +140 -0
  128. package/lib/client/surface/actions/useLifecycleActions.js.map +1 -0
  129. package/lib/client/surface/actions/useNativeActions.d.ts +48 -0
  130. package/lib/client/surface/actions/useNativeActions.d.ts.map +1 -0
  131. package/lib/client/surface/actions/useNativeActions.js +182 -0
  132. package/lib/client/surface/actions/useNativeActions.js.map +1 -0
  133. package/lib/client/surface/actions/useSessionActions.d.ts +24 -0
  134. package/lib/client/surface/actions/useSessionActions.d.ts.map +1 -0
  135. package/lib/client/surface/actions/useSessionActions.js +116 -0
  136. package/lib/client/surface/actions/useSessionActions.js.map +1 -0
  137. package/lib/client/surface/actions/useSurfaceMutation.d.ts +15 -0
  138. package/lib/client/surface/actions/useSurfaceMutation.d.ts.map +1 -0
  139. package/lib/client/surface/actions/useSurfaceMutation.js +24 -0
  140. package/lib/client/surface/actions/useSurfaceMutation.js.map +1 -0
  141. package/lib/client/surface/actions/useWorktreeRegistration.d.ts +31 -0
  142. package/lib/client/surface/actions/useWorktreeRegistration.d.ts.map +1 -0
  143. package/lib/client/surface/actions/useWorktreeRegistration.js +203 -0
  144. package/lib/client/surface/actions/useWorktreeRegistration.js.map +1 -0
  145. package/lib/client/surface/actions/worktree-cleanup-flow.d.ts +10 -0
  146. package/lib/client/surface/actions/worktree-cleanup-flow.d.ts.map +1 -0
  147. package/lib/client/surface/actions/worktree-cleanup-flow.js +19 -0
  148. package/lib/client/surface/actions/worktree-cleanup-flow.js.map +1 -0
  149. package/lib/client/surface/components/AccessConfirmation.d.ts +9 -0
  150. package/lib/client/surface/components/AccessConfirmation.d.ts.map +1 -0
  151. package/lib/client/surface/components/AccessConfirmation.js +18 -0
  152. package/lib/client/surface/components/AccessConfirmation.js.map +1 -0
  153. package/lib/client/surface/components/ActiveWorktree.d.ts +28 -0
  154. package/lib/client/surface/components/ActiveWorktree.d.ts.map +1 -0
  155. package/lib/client/surface/components/ActiveWorktree.js +155 -0
  156. package/lib/client/surface/components/ActiveWorktree.js.map +1 -0
  157. package/lib/client/surface/components/ArchivedWorktree.d.ts +24 -0
  158. package/lib/client/surface/components/ArchivedWorktree.d.ts.map +1 -0
  159. package/lib/client/surface/components/ArchivedWorktree.js +146 -0
  160. package/lib/client/surface/components/ArchivedWorktree.js.map +1 -0
  161. package/lib/client/surface/components/ArchivedWorktrees.d.ts +25 -0
  162. package/lib/client/surface/components/ArchivedWorktrees.d.ts.map +1 -0
  163. package/lib/client/surface/components/ArchivedWorktrees.js +20 -0
  164. package/lib/client/surface/components/ArchivedWorktrees.js.map +1 -0
  165. package/lib/client/surface/components/LifecycleDialogs.d.ts +20 -0
  166. package/lib/client/surface/components/LifecycleDialogs.d.ts.map +1 -0
  167. package/lib/client/surface/components/LifecycleDialogs.js +31 -0
  168. package/lib/client/surface/components/LifecycleDialogs.js.map +1 -0
  169. package/lib/client/surface/components/NativeDialogs.d.ts +9 -0
  170. package/lib/client/surface/components/NativeDialogs.d.ts.map +1 -0
  171. package/lib/client/surface/components/NativeDialogs.js +14 -0
  172. package/lib/client/surface/components/NativeDialogs.js.map +1 -0
  173. package/lib/client/surface/components/NotificationToasts.d.ts +7 -0
  174. package/lib/client/surface/components/NotificationToasts.d.ts.map +1 -0
  175. package/lib/client/surface/components/NotificationToasts.js +24 -0
  176. package/lib/client/surface/components/NotificationToasts.js.map +1 -0
  177. package/lib/client/surface/components/RegistrationDialog.d.ts +15 -0
  178. package/lib/client/surface/components/RegistrationDialog.d.ts.map +1 -0
  179. package/lib/client/surface/components/RegistrationDialog.js +22 -0
  180. package/lib/client/surface/components/RegistrationDialog.js.map +1 -0
  181. package/lib/client/surface/components/SurfaceContent.d.ts +31 -0
  182. package/lib/client/surface/components/SurfaceContent.d.ts.map +1 -0
  183. package/lib/client/surface/components/SurfaceContent.js +65 -0
  184. package/lib/client/surface/components/SurfaceContent.js.map +1 -0
  185. package/lib/client/surface/components/SurfaceHeader.d.ts +15 -0
  186. package/lib/client/surface/components/SurfaceHeader.d.ts.map +1 -0
  187. package/lib/client/surface/components/SurfaceHeader.js +42 -0
  188. package/lib/client/surface/components/SurfaceHeader.js.map +1 -0
  189. package/lib/client/surface/components/WorkspaceTree.d.ts +32 -0
  190. package/lib/client/surface/components/WorkspaceTree.d.ts.map +1 -0
  191. package/lib/client/surface/components/WorkspaceTree.js +149 -0
  192. package/lib/client/surface/components/WorkspaceTree.js.map +1 -0
  193. package/lib/client/{worktree-surface-dialogs.d.ts → surface/components/dialogs.d.ts} +5 -2
  194. package/lib/client/surface/components/dialogs.d.ts.map +1 -0
  195. package/lib/client/{worktree-surface-dialogs.js → surface/components/dialogs.js} +67 -24
  196. package/lib/client/surface/components/dialogs.js.map +1 -0
  197. package/lib/client/{worktree-surface-rows.d.ts → surface/components/rows.d.ts} +3 -3
  198. package/lib/client/surface/components/rows.d.ts.map +1 -0
  199. package/lib/client/{worktree-surface-rows.js → surface/components/rows.js} +180 -20
  200. package/lib/client/surface/components/rows.js.map +1 -0
  201. package/lib/client/surface/notification-queue.d.ts +11 -0
  202. package/lib/client/surface/notification-queue.d.ts.map +1 -0
  203. package/lib/client/surface/notification-queue.js +19 -0
  204. package/lib/client/surface/notification-queue.js.map +1 -0
  205. package/lib/client/{worktree-surface-selectors.d.ts → surface/selectors.d.ts} +10 -5
  206. package/lib/client/surface/selectors.d.ts.map +1 -0
  207. package/lib/client/{worktree-surface-selectors.js → surface/selectors.js} +23 -6
  208. package/lib/client/surface/selectors.js.map +1 -0
  209. package/lib/client/surface/shared.d.ts +40 -0
  210. package/lib/client/surface/shared.d.ts.map +1 -0
  211. package/lib/client/surface/shared.js +53 -0
  212. package/lib/client/surface/shared.js.map +1 -0
  213. package/lib/client/surface/state/useLifecycleState.d.ts +34 -0
  214. package/lib/client/surface/state/useLifecycleState.d.ts.map +1 -0
  215. package/lib/client/surface/state/useLifecycleState.js +39 -0
  216. package/lib/client/surface/state/useLifecycleState.js.map +1 -0
  217. package/lib/client/surface/state/useRegistrationState.d.ts +34 -0
  218. package/lib/client/surface/state/useRegistrationState.d.ts.map +1 -0
  219. package/lib/client/surface/state/useRegistrationState.js +44 -0
  220. package/lib/client/surface/state/useRegistrationState.js.map +1 -0
  221. package/lib/client/surface/state/useSessionExpansion.d.ts +39 -0
  222. package/lib/client/surface/state/useSessionExpansion.d.ts.map +1 -0
  223. package/lib/client/surface/state/useSessionExpansion.js +230 -0
  224. package/lib/client/surface/state/useSessionExpansion.js.map +1 -0
  225. package/lib/client/surface/state/useSessionOrdering.d.ts +15 -0
  226. package/lib/client/surface/state/useSessionOrdering.d.ts.map +1 -0
  227. package/lib/client/surface/state/useSessionOrdering.js +68 -0
  228. package/lib/client/surface/state/useSessionOrdering.js.map +1 -0
  229. package/lib/client/surface/state/useSurfaceMenus.d.ts +9 -0
  230. package/lib/client/surface/state/useSurfaceMenus.d.ts.map +1 -0
  231. package/lib/client/surface/state/useSurfaceMenus.js +15 -0
  232. package/lib/client/surface/state/useSurfaceMenus.js.map +1 -0
  233. package/lib/client/surface/state/useSurfaceRefresh.d.ts +39 -0
  234. package/lib/client/surface/state/useSurfaceRefresh.d.ts.map +1 -0
  235. package/lib/client/surface/state/useSurfaceRefresh.js +274 -0
  236. package/lib/client/surface/state/useSurfaceRefresh.js.map +1 -0
  237. package/lib/client/surface/state/useSurfaceSources.d.ts +31 -0
  238. package/lib/client/surface/state/useSurfaceSources.d.ts.map +1 -0
  239. package/lib/client/surface/state/useSurfaceSources.js +63 -0
  240. package/lib/client/surface/state/useSurfaceSources.js.map +1 -0
  241. package/lib/client/{worktree-surface-types.d.ts → surface/types.d.ts} +58 -13
  242. package/lib/client/surface/types.d.ts.map +1 -0
  243. package/lib/client/surface/types.js +2 -0
  244. package/lib/client/surface/types.js.map +1 -0
  245. package/lib/client/{WorktreeModeAction.d.ts → view/WorktreeModeAction.d.ts} +1 -1
  246. package/lib/client/view/WorktreeModeAction.d.ts.map +1 -0
  247. package/lib/client/{WorktreeModeAction.js → view/WorktreeModeAction.js} +9 -1
  248. package/lib/client/view/WorktreeModeAction.js.map +1 -0
  249. package/lib/client/view/navigation.d.ts.map +1 -0
  250. package/lib/client/view/navigation.js.map +1 -0
  251. package/lib/client/view/view-mode-dispatch.d.ts +7 -0
  252. package/lib/client/view/view-mode-dispatch.d.ts.map +1 -0
  253. package/lib/client/view/view-mode-dispatch.js +11 -0
  254. package/lib/client/view/view-mode-dispatch.js.map +1 -0
  255. package/lib/client/view/view-mode-store.d.ts.map +1 -0
  256. package/lib/client/view/view-mode-store.js.map +1 -0
  257. package/lib/client/view/view-mode.d.ts.map +1 -0
  258. package/lib/client/view/view-mode.js.map +1 -0
  259. package/lib/client/{worktree-error-copy.d.ts → view/worktree-error-copy.d.ts} +2 -2
  260. package/lib/client/view/worktree-error-copy.d.ts.map +1 -0
  261. package/lib/client/view/worktree-error-copy.js.map +1 -0
  262. package/lib/client/{worktree-expand-state.d.ts → view/worktree-expand-state.d.ts} +1 -0
  263. package/lib/client/view/worktree-expand-state.d.ts.map +1 -0
  264. package/lib/client/{worktree-expand-state.js → view/worktree-expand-state.js} +11 -0
  265. package/lib/client/view/worktree-expand-state.js.map +1 -0
  266. package/lib/client/{worktree-view-actions.d.ts → view/worktree-view-actions.d.ts} +11 -5
  267. package/lib/client/view/worktree-view-actions.d.ts.map +1 -0
  268. package/lib/client/{worktree-view-actions.js → view/worktree-view-actions.js} +13 -11
  269. package/lib/client/view/worktree-view-actions.js.map +1 -0
  270. package/lib/client/view/worktree-view-errors.d.ts.map +1 -0
  271. package/lib/client/view/worktree-view-errors.js.map +1 -0
  272. package/lib/client/{worktree-view-read.d.ts → view/worktree-view-read.d.ts} +4 -2
  273. package/lib/client/view/worktree-view-read.d.ts.map +1 -0
  274. package/lib/client/{worktree-view-read.js → view/worktree-view-read.js} +4 -1
  275. package/lib/client/view/worktree-view-read.js.map +1 -0
  276. package/lib/client/view/worktree-view.d.ts.map +1 -0
  277. package/lib/client/view/worktree-view.js.map +1 -0
  278. package/lib/client/worktree-connection.d.ts +6 -0
  279. package/lib/client/worktree-connection.d.ts.map +1 -1
  280. package/lib/client/worktree-connection.js +20 -0
  281. package/lib/client/worktree-connection.js.map +1 -1
  282. package/lib/client.js +5869 -2648
  283. package/lib/client.js.map +1 -1
  284. package/lib/contract/index.contract.js +12 -0
  285. package/lib/contract/index.contract.js.map +1 -1
  286. package/lib/contract/index.d.ts +64 -3
  287. package/lib/contract/index.d.ts.map +1 -1
  288. package/lib/contract/index.js +8 -0
  289. package/lib/contract/index.js.map +1 -1
  290. package/lib/host/dsh-read-adapter.d.ts +13 -2
  291. package/lib/host/dsh-read-adapter.d.ts.map +1 -1
  292. package/lib/host/dsh-read-adapter.js +23 -3
  293. package/lib/host/dsh-read-adapter.js.map +1 -1
  294. package/lib/host/remote.d.ts.map +1 -1
  295. package/lib/host/remote.js +15 -0
  296. package/lib/host/remote.js.map +1 -1
  297. package/lib/host/service.d.ts +30 -0
  298. package/lib/host/service.d.ts.map +1 -1
  299. package/lib/host/service.js +47 -1
  300. package/lib/host/service.js.map +1 -1
  301. package/lib/host/worktree-activity.d.ts +13 -0
  302. package/lib/host/worktree-activity.d.ts.map +1 -0
  303. package/lib/host/worktree-activity.js +23 -0
  304. package/lib/host/worktree-activity.js.map +1 -0
  305. package/lib/host/worktree-instructions.d.ts +41 -0
  306. package/lib/host/worktree-instructions.d.ts.map +1 -0
  307. package/lib/host/worktree-instructions.js +65 -0
  308. package/lib/host/worktree-instructions.js.map +1 -0
  309. package/lib/host/worktree-permission-manager.js +2 -2
  310. package/lib/host/worktree-permission-manager.js.map +1 -1
  311. package/lib/index.d.ts +3 -3
  312. package/lib/index.d.ts.map +1 -1
  313. package/lib/index.js +2 -2
  314. package/lib/index.js.map +1 -1
  315. package/lib/manage/manager-context.d.ts +2 -1
  316. package/lib/manage/manager-context.d.ts.map +1 -1
  317. package/lib/manage/manager-sessions.js +4 -4
  318. package/lib/manage/manager-sessions.js.map +1 -1
  319. package/lib/manage/manager-worktree-lifecycle.d.ts +23 -0
  320. package/lib/manage/manager-worktree-lifecycle.d.ts.map +1 -0
  321. package/lib/manage/manager-worktree-lifecycle.js +165 -0
  322. package/lib/manage/manager-worktree-lifecycle.js.map +1 -0
  323. package/lib/manage/manager-worktrees.d.ts +1 -6
  324. package/lib/manage/manager-worktrees.d.ts.map +1 -1
  325. package/lib/manage/manager-worktrees.js +81 -112
  326. package/lib/manage/manager-worktrees.js.map +1 -1
  327. package/lib/manage/manager.d.ts +24 -1
  328. package/lib/manage/manager.d.ts.map +1 -1
  329. package/lib/manage/manager.js +70 -6
  330. package/lib/manage/manager.js.map +1 -1
  331. package/lib/manage/types.d.ts +1 -0
  332. package/lib/manage/types.d.ts.map +1 -1
  333. package/lib/provider/generated-name.d.ts +8 -0
  334. package/lib/provider/generated-name.d.ts.map +1 -0
  335. package/lib/provider/generated-name.js +29 -0
  336. package/lib/provider/generated-name.js.map +1 -0
  337. package/lib/provider/{git.d.ts → git/adapter.d.ts} +2 -2
  338. package/lib/provider/git/adapter.d.ts.map +1 -0
  339. package/lib/provider/{git.js → git/adapter.js} +11 -2
  340. package/lib/provider/git/adapter.js.map +1 -0
  341. package/lib/provider/{repository-fingerprint.d.ts → git/repository-fingerprint.d.ts} +1 -1
  342. package/lib/provider/git/repository-fingerprint.d.ts.map +1 -0
  343. package/lib/provider/git/repository-fingerprint.js.map +1 -0
  344. package/lib/provider/{subprocess.d.ts → git/subprocess.d.ts} +1 -1
  345. package/lib/provider/git/subprocess.d.ts.map +1 -0
  346. package/lib/provider/git/subprocess.js.map +1 -0
  347. package/lib/provider/git/worktree-status.d.ts +5 -0
  348. package/lib/provider/git/worktree-status.d.ts.map +1 -0
  349. package/lib/provider/git/worktree-status.js +23 -0
  350. package/lib/provider/git/worktree-status.js.map +1 -0
  351. package/lib/provider/index.d.ts +5 -5
  352. package/lib/provider/index.d.ts.map +1 -1
  353. package/lib/provider/index.js +5 -5
  354. package/lib/provider/index.js.map +1 -1
  355. package/lib/provider/mutation-token.d.ts +1 -1
  356. package/lib/provider/mutation-token.d.ts.map +1 -1
  357. package/lib/provider/mutation-token.js +1 -0
  358. package/lib/provider/mutation-token.js.map +1 -1
  359. package/lib/provider/sidecar/mutation-lock.d.ts.map +1 -0
  360. package/lib/provider/{mutation-lock.js → sidecar/mutation-lock.js} +1 -1
  361. package/lib/provider/sidecar/mutation-lock.js.map +1 -0
  362. package/lib/provider/{sidecar.d.ts → sidecar/repository.d.ts} +3 -3
  363. package/lib/provider/sidecar/repository.d.ts.map +1 -0
  364. package/lib/provider/{sidecar.js → sidecar/repository.js} +16 -5
  365. package/lib/provider/sidecar/repository.js.map +1 -0
  366. package/lib/provider/{sidecar-persistence.d.ts → sidecar/sidecar-persistence.d.ts} +1 -1
  367. package/lib/provider/sidecar/sidecar-persistence.d.ts.map +1 -0
  368. package/lib/provider/{sidecar-persistence.js → sidecar/sidecar-persistence.js} +29 -2
  369. package/lib/provider/sidecar/sidecar-persistence.js.map +1 -0
  370. package/lib/provider/{sidecar-schema.d.ts → sidecar/sidecar-schema.d.ts} +1 -1
  371. package/lib/provider/sidecar/sidecar-schema.d.ts.map +1 -0
  372. package/lib/provider/{sidecar-schema.js → sidecar/sidecar-schema.js} +59 -16
  373. package/lib/provider/sidecar/sidecar-schema.js.map +1 -0
  374. package/lib/provider/transaction/dependencies.d.ts +10 -0
  375. package/lib/provider/transaction/dependencies.d.ts.map +1 -0
  376. package/lib/provider/transaction/dependencies.js +2 -0
  377. package/lib/provider/transaction/dependencies.js.map +1 -0
  378. package/lib/provider/transaction/index.d.ts +17 -0
  379. package/lib/provider/transaction/index.d.ts.map +1 -0
  380. package/lib/provider/transaction/index.js +44 -0
  381. package/lib/provider/transaction/index.js.map +1 -0
  382. package/lib/provider/transaction/operations/adopt-branch.d.ts +6 -0
  383. package/lib/provider/transaction/operations/adopt-branch.d.ts.map +1 -0
  384. package/lib/provider/transaction/operations/adopt-branch.js +59 -0
  385. package/lib/provider/transaction/operations/adopt-branch.js.map +1 -0
  386. package/lib/provider/transaction/operations/clean.d.ts +4 -0
  387. package/lib/provider/transaction/operations/clean.d.ts.map +1 -0
  388. package/lib/provider/transaction/operations/clean.js +168 -0
  389. package/lib/provider/transaction/operations/clean.js.map +1 -0
  390. package/lib/provider/transaction/operations/create.d.ts +5 -0
  391. package/lib/provider/transaction/operations/create.d.ts.map +1 -0
  392. package/lib/provider/transaction/operations/create.js +136 -0
  393. package/lib/provider/transaction/operations/create.js.map +1 -0
  394. package/lib/provider/transaction/operations/import.d.ts +5 -0
  395. package/lib/provider/transaction/operations/import.d.ts.map +1 -0
  396. package/lib/provider/transaction/operations/import.js +93 -0
  397. package/lib/provider/transaction/operations/import.js.map +1 -0
  398. package/lib/provider/transaction/operations/remove.d.ts +4 -0
  399. package/lib/provider/transaction/operations/remove.d.ts.map +1 -0
  400. package/lib/provider/transaction/operations/remove.js +164 -0
  401. package/lib/provider/transaction/operations/remove.js.map +1 -0
  402. package/lib/provider/transaction/recovery/failure-recovery.d.ts +32 -0
  403. package/lib/provider/transaction/recovery/failure-recovery.d.ts.map +1 -0
  404. package/lib/provider/transaction/recovery/failure-recovery.js +147 -0
  405. package/lib/provider/transaction/recovery/failure-recovery.js.map +1 -0
  406. package/lib/provider/transaction/recovery/recover.d.ts +4 -0
  407. package/lib/provider/transaction/recovery/recover.d.ts.map +1 -0
  408. package/lib/provider/transaction/recovery/recover.js +164 -0
  409. package/lib/provider/transaction/recovery/recover.js.map +1 -0
  410. package/lib/provider/transaction/support/admission.d.ts +7 -0
  411. package/lib/provider/transaction/support/admission.d.ts.map +1 -0
  412. package/lib/provider/transaction/support/admission.js +90 -0
  413. package/lib/provider/transaction/support/admission.js.map +1 -0
  414. package/lib/provider/transaction/support/inspection.d.ts +11 -0
  415. package/lib/provider/transaction/support/inspection.d.ts.map +1 -0
  416. package/lib/provider/transaction/support/inspection.js +51 -0
  417. package/lib/provider/transaction/support/inspection.js.map +1 -0
  418. package/lib/provider/transaction/support/journal.d.ts +12 -0
  419. package/lib/provider/transaction/support/journal.d.ts.map +1 -0
  420. package/lib/provider/transaction/support/journal.js +74 -0
  421. package/lib/provider/transaction/support/journal.js.map +1 -0
  422. package/lib/provider/transaction/support/locking.d.ts +4 -0
  423. package/lib/provider/transaction/support/locking.d.ts.map +1 -0
  424. package/lib/provider/transaction/support/locking.js +11 -0
  425. package/lib/provider/transaction/support/locking.js.map +1 -0
  426. package/lib/provider/transaction/support/path-safety.d.ts +11 -0
  427. package/lib/provider/transaction/support/path-safety.d.ts.map +1 -0
  428. package/lib/provider/transaction/support/path-safety.js +82 -0
  429. package/lib/provider/transaction/support/path-safety.js.map +1 -0
  430. package/lib/provider/transaction/support/paths.d.ts +10 -0
  431. package/lib/provider/transaction/support/paths.d.ts.map +1 -0
  432. package/lib/provider/transaction/support/paths.js +68 -0
  433. package/lib/provider/transaction/support/paths.js.map +1 -0
  434. package/lib/provider/transaction/support/publication.d.ts +9 -0
  435. package/lib/provider/transaction/support/publication.d.ts.map +1 -0
  436. package/lib/provider/transaction/support/publication.js +92 -0
  437. package/lib/provider/transaction/support/publication.js.map +1 -0
  438. package/lib/provider/transaction/types.d.ts +38 -0
  439. package/lib/provider/transaction/types.d.ts.map +1 -0
  440. package/lib/provider/transaction/types.js +2 -0
  441. package/lib/provider/transaction/types.js.map +1 -0
  442. package/lib/provider/types.d.ts +22 -3
  443. package/lib/provider/types.d.ts.map +1 -1
  444. package/lib/provider/types.js +1 -1
  445. package/lib/provider/types.js.map +1 -1
  446. package/lib/provider/worktree-lifecycle.d.ts +19 -0
  447. package/lib/provider/worktree-lifecycle.d.ts.map +1 -0
  448. package/lib/provider/worktree-lifecycle.js +44 -0
  449. package/lib/provider/worktree-lifecycle.js.map +1 -0
  450. package/lib/typert.host.js +330 -36
  451. package/lib/typert.remote-client.d.ts +12 -0
  452. package/lib/typert.remote-client.d.ts.map +1 -1
  453. package/lib/typert.remote-client.js +330 -36
  454. package/package.json +21 -20
  455. package/lib/client/WorktreeContext.d.ts.map +0 -1
  456. package/lib/client/WorktreeContext.js.map +0 -1
  457. package/lib/client/WorktreeHeroContext.d.ts.map +0 -1
  458. package/lib/client/WorktreeHeroContext.js.map +0 -1
  459. package/lib/client/WorktreeModeAction.d.ts.map +0 -1
  460. package/lib/client/WorktreeModeAction.js.map +0 -1
  461. package/lib/client/WorktreeOverlay.d.ts.map +0 -1
  462. package/lib/client/WorktreeOverlay.js.map +0 -1
  463. package/lib/client/dsh-rc1-slot-contract.d.ts +0 -43
  464. package/lib/client/dsh-rc1-slot-contract.d.ts.map +0 -1
  465. package/lib/client/dsh-rc1-slot-contract.js +0 -2
  466. package/lib/client/dsh-rc1-slot-contract.js.map +0 -1
  467. package/lib/client/navigation.d.ts.map +0 -1
  468. package/lib/client/navigation.js.map +0 -1
  469. package/lib/client/overlay-bounds.d.ts.map +0 -1
  470. package/lib/client/overlay-bounds.js.map +0 -1
  471. package/lib/client/session-view.d.ts.map +0 -1
  472. package/lib/client/session-view.js.map +0 -1
  473. package/lib/client/sidebar-overlay-geometry.d.ts.map +0 -1
  474. package/lib/client/sidebar-overlay-geometry.js.map +0 -1
  475. package/lib/client/view-mode-store.d.ts.map +0 -1
  476. package/lib/client/view-mode-store.js.map +0 -1
  477. package/lib/client/view-mode.d.ts.map +0 -1
  478. package/lib/client/view-mode.js.map +0 -1
  479. package/lib/client/virtual-workspace-membership.d.ts.map +0 -1
  480. package/lib/client/virtual-workspace-membership.js.map +0 -1
  481. package/lib/client/worktree-context-store.d.ts.map +0 -1
  482. package/lib/client/worktree-context-store.js.map +0 -1
  483. package/lib/client/worktree-context.d.ts.map +0 -1
  484. package/lib/client/worktree-context.js.map +0 -1
  485. package/lib/client/worktree-error-copy.d.ts.map +0 -1
  486. package/lib/client/worktree-error-copy.js.map +0 -1
  487. package/lib/client/worktree-expand-state.d.ts.map +0 -1
  488. package/lib/client/worktree-expand-state.js.map +0 -1
  489. package/lib/client/worktree-permission-icon.d.ts.map +0 -1
  490. package/lib/client/worktree-permission-icon.js.map +0 -1
  491. package/lib/client/worktree-permission.d.ts.map +0 -1
  492. package/lib/client/worktree-permission.js.map +0 -1
  493. package/lib/client/worktree-session-fork.d.ts.map +0 -1
  494. package/lib/client/worktree-session-fork.js.map +0 -1
  495. package/lib/client/worktree-session-order.d.ts.map +0 -1
  496. package/lib/client/worktree-session-order.js.map +0 -1
  497. package/lib/client/worktree-session-position.d.ts.map +0 -1
  498. package/lib/client/worktree-session-position.js.map +0 -1
  499. package/lib/client/worktree-session.d.ts.map +0 -1
  500. package/lib/client/worktree-session.js.map +0 -1
  501. package/lib/client/worktree-surface-dialogs.d.ts.map +0 -1
  502. package/lib/client/worktree-surface-dialogs.js.map +0 -1
  503. package/lib/client/worktree-surface-rows.d.ts.map +0 -1
  504. package/lib/client/worktree-surface-rows.js.map +0 -1
  505. package/lib/client/worktree-surface-selectors.d.ts.map +0 -1
  506. package/lib/client/worktree-surface-selectors.js.map +0 -1
  507. package/lib/client/worktree-surface-types.d.ts.map +0 -1
  508. package/lib/client/worktree-surface-types.js +0 -2
  509. package/lib/client/worktree-surface-types.js.map +0 -1
  510. package/lib/client/worktree-view-actions.d.ts.map +0 -1
  511. package/lib/client/worktree-view-actions.js.map +0 -1
  512. package/lib/client/worktree-view-errors.d.ts.map +0 -1
  513. package/lib/client/worktree-view-errors.js.map +0 -1
  514. package/lib/client/worktree-view-read.d.ts.map +0 -1
  515. package/lib/client/worktree-view-read.js.map +0 -1
  516. package/lib/client/worktree-view.d.ts.map +0 -1
  517. package/lib/client/worktree-view.js.map +0 -1
  518. package/lib/provider/git.d.ts.map +0 -1
  519. package/lib/provider/git.js.map +0 -1
  520. package/lib/provider/mutation-lock.d.ts.map +0 -1
  521. package/lib/provider/mutation-lock.js.map +0 -1
  522. package/lib/provider/repository-fingerprint.d.ts.map +0 -1
  523. package/lib/provider/repository-fingerprint.js.map +0 -1
  524. package/lib/provider/sidecar-persistence.d.ts.map +0 -1
  525. package/lib/provider/sidecar-persistence.js.map +0 -1
  526. package/lib/provider/sidecar-schema.d.ts.map +0 -1
  527. package/lib/provider/sidecar-schema.js.map +0 -1
  528. package/lib/provider/sidecar.d.ts.map +0 -1
  529. package/lib/provider/sidecar.js.map +0 -1
  530. package/lib/provider/subprocess.d.ts.map +0 -1
  531. package/lib/provider/subprocess.js.map +0 -1
  532. package/lib/provider/transaction.d.ts +0 -65
  533. package/lib/provider/transaction.d.ts.map +0 -1
  534. package/lib/provider/transaction.js +0 -1011
  535. package/lib/provider/transaction.js.map +0 -1
  536. /package/lib/client/{WorktreeContext.js → context/WorktreeContext.js} +0 -0
  537. /package/lib/client/{WorktreeHeroContext.js → context/WorktreeHeroContext.js} +0 -0
  538. /package/lib/client/{overlay-bounds.d.ts → overlay/overlay-bounds.d.ts} +0 -0
  539. /package/lib/client/{overlay-bounds.js → overlay/overlay-bounds.js} +0 -0
  540. /package/lib/client/{sidebar-overlay-geometry.d.ts → overlay/sidebar-overlay-geometry.d.ts} +0 -0
  541. /package/lib/client/{sidebar-overlay-geometry.js → overlay/sidebar-overlay-geometry.js} +0 -0
  542. /package/lib/client/{worktree-permission-icon.d.ts → permission/worktree-permission-icon.d.ts} +0 -0
  543. /package/lib/client/{worktree-permission-icon.js → permission/worktree-permission-icon.js} +0 -0
  544. /package/lib/client/{worktree-permission.d.ts → permission/worktree-permission.d.ts} +0 -0
  545. /package/lib/client/{worktree-permission.js → permission/worktree-permission.js} +0 -0
  546. /package/lib/client/{session-view.d.ts → session/session-view.d.ts} +0 -0
  547. /package/lib/client/{session-view.js → session/session-view.js} +0 -0
  548. /package/lib/client/{worktree-session-order.d.ts → session/worktree-session-order.d.ts} +0 -0
  549. /package/lib/client/{worktree-session-order.js → session/worktree-session-order.js} +0 -0
  550. /package/lib/client/{worktree-session-position.d.ts → session/worktree-session-position.d.ts} +0 -0
  551. /package/lib/client/{worktree-session-position.js → session/worktree-session-position.js} +0 -0
  552. /package/lib/client/{navigation.d.ts → view/navigation.d.ts} +0 -0
  553. /package/lib/client/{navigation.js → view/navigation.js} +0 -0
  554. /package/lib/client/{view-mode-store.d.ts → view/view-mode-store.d.ts} +0 -0
  555. /package/lib/client/{view-mode-store.js → view/view-mode-store.js} +0 -0
  556. /package/lib/client/{view-mode.d.ts → view/view-mode.d.ts} +0 -0
  557. /package/lib/client/{view-mode.js → view/view-mode.js} +0 -0
  558. /package/lib/client/{worktree-error-copy.js → view/worktree-error-copy.js} +0 -0
  559. /package/lib/client/{worktree-view-errors.d.ts → view/worktree-view-errors.d.ts} +0 -0
  560. /package/lib/client/{worktree-view-errors.js → view/worktree-view-errors.js} +0 -0
  561. /package/lib/client/{worktree-view.d.ts → view/worktree-view.d.ts} +0 -0
  562. /package/lib/client/{worktree-view.js → view/worktree-view.js} +0 -0
  563. /package/lib/provider/{repository-fingerprint.js → git/repository-fingerprint.js} +0 -0
  564. /package/lib/provider/{subprocess.js → git/subprocess.js} +0 -0
  565. /package/lib/provider/{mutation-lock.d.ts → sidecar/mutation-lock.d.ts} +0 -0
@@ -0,0 +1,136 @@
1
+ import { createRepositoryFingerprint } from '../../git/repository-fingerprint.js';
2
+ import { assertGeneratedNameAvailable } from '../../generated-name.js';
3
+ import { recoveryError, recordForCreate, pendingCreate } from '../support/journal.js';
4
+ import { reconcileCreateFailure } from '../recovery/failure-recovery.js';
5
+ import { withShardLock } from '../support/locking.js';
6
+ import { resolveRepository, findActiveBranchConflict, isExactCreatedWorktree, } from '../support/inspection.js';
7
+ import { cleanLegacyObservations, assertMutationAdmitted, assertRepositoryCompatible, } from '../support/admission.js';
8
+ import { assertGeneratedTarget } from '../support/path-safety.js';
9
+ import { publishCreated, markRecovery } from '../support/publication.js';
10
+ import { providerError } from '../../types.js';
11
+ export async function createWorktreeTransaction(dependencies, input) {
12
+ return withShardLock(dependencies, input.workspaceId, async (locked) => {
13
+ await dependencies.git.validateRepository(input.workspaceRoot);
14
+ const repository = await resolveRepository(dependencies, input.workspaceRoot);
15
+ return dependencies.repositoryLock.run(`repository:${createRepositoryFingerprint(repository.identity)}`, async (lock) => {
16
+ lock.assertHeld();
17
+ const gitRoot = repository.identity.topLevel;
18
+ await cleanLegacyObservations(locked);
19
+ const current = await locked.read();
20
+ assertMutationAdmitted(current, input.workspaceId);
21
+ assertRepositoryCompatible(current, repository.identity, input.workspaceId);
22
+ assertGeneratedTarget(dependencies, input);
23
+ let existingGitWorktrees;
24
+ if (dependencies.git.listBranchesWithWorktreePaths) {
25
+ const branches = await dependencies.git.listBranchesWithWorktreePaths(gitRoot);
26
+ const baseBranch = branches.find((branch) => branch.name === input.baseBranch);
27
+ if (!baseBranch) {
28
+ throw providerError('GIT_OPERATION_FAILED', `Local branch does not exist: ${input.baseBranch}`, {
29
+ workspaceRoot: input.workspaceRoot,
30
+ branch: input.baseBranch,
31
+ });
32
+ }
33
+ if (input.newBranch !== undefined &&
34
+ branches.some((branch) => branch.name === input.newBranch)) {
35
+ throw providerError('WORKTREE_BRANCH_CONFLICT', `New branch already exists: ${input.newBranch}`, {
36
+ workspaceRoot: input.workspaceRoot,
37
+ branch: input.newBranch,
38
+ baseBranch: input.baseBranch,
39
+ });
40
+ }
41
+ if (branches.some((branch) => branch.name === input.targetBranch && branch.worktreePath !== undefined)) {
42
+ throw providerError('WORKTREE_BRANCH_CONFLICT', `Branch is already checked out: ${input.targetBranch}`, {
43
+ workspaceRoot: input.workspaceRoot,
44
+ branch: input.targetBranch,
45
+ baseBranch: input.baseBranch,
46
+ });
47
+ }
48
+ }
49
+ else {
50
+ const branches = await dependencies.git.listBranches(gitRoot);
51
+ if (!branches.includes(input.baseBranch)) {
52
+ throw providerError('GIT_OPERATION_FAILED', `Local branch does not exist: ${input.baseBranch}`, {
53
+ workspaceRoot: input.workspaceRoot,
54
+ branch: input.baseBranch,
55
+ });
56
+ }
57
+ if (input.newBranch !== undefined && branches.includes(input.newBranch)) {
58
+ throw providerError('WORKTREE_BRANCH_CONFLICT', `New branch already exists: ${input.newBranch}`, {
59
+ workspaceRoot: input.workspaceRoot,
60
+ branch: input.newBranch,
61
+ baseBranch: input.baseBranch,
62
+ });
63
+ }
64
+ existingGitWorktrees = await dependencies.git.listWorktrees(gitRoot);
65
+ if (existingGitWorktrees.some((worktree) => worktree.branch === input.targetBranch)) {
66
+ throw providerError('WORKTREE_BRANCH_CONFLICT', `Branch is already checked out: ${input.targetBranch}`, {
67
+ workspaceRoot: input.workspaceRoot,
68
+ branch: input.targetBranch,
69
+ baseBranch: input.baseBranch,
70
+ });
71
+ }
72
+ }
73
+ await assertGeneratedNameAvailable(input.worktreeId, input.targetPath, current, existingGitWorktrees ?? await dependencies.git.listWorktrees(gitRoot));
74
+ const sidecarConflict = await findActiveBranchConflict(dependencies, current, input.targetBranch, gitRoot);
75
+ if (sidecarConflict) {
76
+ throw providerError('WORKTREE_BRANCH_CONFLICT', `Branch is already recorded as active: ${input.targetBranch}`, {
77
+ branch: input.targetBranch,
78
+ worktreeId: sidecarConflict.worktreeId,
79
+ });
80
+ }
81
+ const record = recordForCreate(input);
82
+ const pending = pendingCreate(input, repository.identity);
83
+ await locked.mutate((snapshot) => {
84
+ const { repository: _repository, ...withoutRepository } = snapshot;
85
+ void _repository;
86
+ return {
87
+ result: undefined,
88
+ snapshot: {
89
+ ...withoutRepository,
90
+ repositoryFingerprint: createRepositoryFingerprint(repository.identity),
91
+ pendingOperation: pending,
92
+ },
93
+ };
94
+ });
95
+ try {
96
+ await dependencies.git.createWorktree(input.workspaceRoot, input.targetPath, input.baseBranch, input.newBranch);
97
+ }
98
+ catch (error) {
99
+ return reconcileCreateFailure(dependencies, {
100
+ locked,
101
+ input,
102
+ record,
103
+ pending,
104
+ repository: repository.identity,
105
+ gitRoot,
106
+ error,
107
+ });
108
+ }
109
+ lock.assertHeld();
110
+ let live;
111
+ try {
112
+ live = await dependencies.git.listWorktrees(gitRoot);
113
+ }
114
+ catch (inspectionError) {
115
+ await markRecovery(locked, pending, 'WORKTREE_RECOVERY_REQUIRED');
116
+ throw recoveryError(`Unable to verify Git after create: ${input.targetPath}`, {
117
+ workspaceId: input.workspaceId,
118
+ operationId: pending.id,
119
+ targetPath: input.targetPath,
120
+ cause: String(inspectionError),
121
+ });
122
+ }
123
+ if (!(await isExactCreatedWorktree(live, input))) {
124
+ await markRecovery(locked, pending, 'WORKTREE_RECOVERY_REQUIRED');
125
+ throw recoveryError(`Git create completed without the expected Worktree: ${input.targetPath}`, {
126
+ workspaceId: input.workspaceId,
127
+ worktreeId: input.worktreeId,
128
+ targetPath: input.targetPath,
129
+ });
130
+ }
131
+ await publishCreated(dependencies, locked, pending.id, record, repository.identity);
132
+ return record;
133
+ });
134
+ });
135
+ }
136
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/provider/transaction/operations/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,YAA6F,EAC7F,KAAqC;IAErC,OAAO,aAAa,CAAC,YAAY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KAAK,CAAC,UAAU,EAAE,EAAE;oBAC5E,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,WAAW,EAAE,OAAO,CAAC,EAAE;oBACvB,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,KAAK,EAAE,MAAM,CAAC,eAAe,CAAC;iBAC/B,CAAC,CAAC;YACL,CAAC;YACD,IAAI,CAAC,CAAC,MAAM,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;gBACjD,MAAM,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,4BAA4B,CAAC,CAAC;gBAClE,MAAM,aAAa,CACjB,uDAAuD,KAAK,CAAC,UAAU,EAAE,EACzE;oBACE,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;iBAC7B,CACF,CAAC;YACJ,CAAC;YACD,MAAM,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;YACpF,OAAO,MAAM,CAAC;QAChB,CAAC,CACF,CAAC;IACJ,CAAC,CAA4B,CAAC;AAChC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { WorktreeRecord } from '../../../contract/index.js';
2
+ import type { ImportWorktreeTransactionInput } from '../types.js';
3
+ import type { TransactionDependencies } from '../dependencies.js';
4
+ export declare function importWorktreeTransaction(dependencies: Pick<TransactionDependencies, 'git' | 'repositoryLock' | 'sidecar'>, input: ImportWorktreeTransactionInput): Promise<WorktreeRecord>;
5
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../../src/provider/transaction/operations/import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAalE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGlE,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,GAAG,gBAAgB,GAAG,SAAS,CAAC,EACjF,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,cAAc,CAAC,CAqHzB"}
@@ -0,0 +1,93 @@
1
+ import path from 'node:path';
2
+ import { readWorktreeStatus } from '../../git/worktree-status.js';
3
+ import { createRepositoryFingerprint } from '../../git/repository-fingerprint.js';
4
+ import { isDirectory, canonicalPath, samePhysicalPath } from '../support/paths.js';
5
+ import { withShardLock } from '../support/locking.js';
6
+ import { resolveRepository, findWorktreeByPhysicalPath, findSidecarWorktreeByPhysicalPath, } from '../support/inspection.js';
7
+ import { cleanLegacyObservations, assertMutationAdmitted, assertRepositoryCompatible, } from '../support/admission.js';
8
+ import { providerError } from '../../types.js';
9
+ export async function importWorktreeTransaction(dependencies, input) {
10
+ if (!path.isAbsolute(input.absolutePath)) {
11
+ throw providerError('WORKTREE_IMPORT_INVALID', 'An absolute Worktree path is required', {
12
+ workspaceId: input.workspaceId,
13
+ absolutePath: input.absolutePath,
14
+ });
15
+ }
16
+ const requestedPath = path.resolve(input.absolutePath);
17
+ if (!(await isDirectory(requestedPath))) {
18
+ throw providerError('WORKTREE_IMPORT_INVALID', `Worktree path is not a directory: ${requestedPath}`, {
19
+ workspaceId: input.workspaceId,
20
+ absolutePath: requestedPath,
21
+ });
22
+ }
23
+ return withShardLock(dependencies, input.workspaceId, async (locked) => {
24
+ await dependencies.git.validateRepository(input.workspaceRoot);
25
+ const repository = await resolveRepository(dependencies, input.workspaceRoot);
26
+ return dependencies.repositoryLock.run(`repository:${createRepositoryFingerprint(repository.identity)}`, async (lock) => {
27
+ lock.assertHeld();
28
+ const gitRoot = repository.identity.topLevel;
29
+ await cleanLegacyObservations(locked);
30
+ const current = await locked.read();
31
+ assertMutationAdmitted(current, input.workspaceId);
32
+ assertRepositoryCompatible(current, repository.identity, input.workspaceId);
33
+ return locked.mutate(async (snapshot) => {
34
+ const repositoryFingerprint = createRepositoryFingerprint(repository.identity);
35
+ const liveWorktree = await findWorktreeByPhysicalPath(await dependencies.git.listWorktrees(gitRoot), requestedPath);
36
+ if (!liveWorktree ||
37
+ !liveWorktree.branch ||
38
+ (await readWorktreeStatus(liveWorktree)) !== 'ready' ||
39
+ (await samePhysicalPath(liveWorktree.absolutePath, gitRoot))) {
40
+ throw providerError('WORKTREE_IMPORT_INVALID', `Path is not an importable Worktree: ${requestedPath}`, {
41
+ workspaceId: input.workspaceId,
42
+ absolutePath: requestedPath,
43
+ });
44
+ }
45
+ const normalizedPath = await canonicalPath(liveWorktree.absolutePath);
46
+ const existing = await findSidecarWorktreeByPhysicalPath(snapshot.worktrees, normalizedPath);
47
+ if (existing) {
48
+ if (existing.status === 'active' &&
49
+ existing.source === 'external' &&
50
+ existing.workspaceId === input.workspaceId) {
51
+ return {
52
+ result: existing,
53
+ snapshot: snapshot.repositoryFingerprint === repositoryFingerprint
54
+ ? snapshot
55
+ : { ...snapshot, repositoryFingerprint },
56
+ changed: snapshot.repositoryFingerprint === repositoryFingerprint ? false : undefined,
57
+ };
58
+ }
59
+ throw providerError('WORKTREE_ALREADY_MANAGED', `Worktree path is already managed: ${normalizedPath}`, {
60
+ workspaceId: input.workspaceId,
61
+ absolutePath: normalizedPath,
62
+ worktreeId: existing.worktreeId,
63
+ source: existing.source,
64
+ status: existing.status,
65
+ });
66
+ }
67
+ if (snapshot.worktrees.some((candidate) => candidate.worktreeId === input.worktreeId)) {
68
+ throw providerError('SIDECAR_CORRUPT', `Generated Worktree ID is already recorded: ${input.worktreeId}`, {
69
+ worktreeId: input.worktreeId,
70
+ });
71
+ }
72
+ const record = {
73
+ worktreeId: input.worktreeId,
74
+ workspaceId: input.workspaceId,
75
+ absolutePath: normalizedPath,
76
+ branch: liveWorktree.branch,
77
+ source: 'external',
78
+ importedAt: new Date().toISOString(),
79
+ status: 'active',
80
+ };
81
+ return {
82
+ result: record,
83
+ snapshot: {
84
+ ...snapshot,
85
+ repositoryFingerprint,
86
+ worktrees: [record, ...snapshot.worktrees],
87
+ },
88
+ };
89
+ });
90
+ });
91
+ });
92
+ }
93
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../../../src/provider/transaction/operations/import.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,YAAiF,EACjF,KAAqC;IAErC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;QACzC,MAAM,aAAa,CAAC,yBAAyB,EAAE,uCAAuC,EAAE;YACtF,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;SACjC,CAAC,CAAC;IACL,CAAC;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,aAAa,CAAC,CAAC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BACJ,CAAC;gBACD,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;oBACtF,MAAM,aAAa,CACjB,iBAAiB,EACjB,8CAA8C,KAAK,CAAC,UAAU,EAAE,EAChE;wBACE,UAAU,EAAE,KAAK,CAAC,UAAU;qBAC7B,CACF,CAAC;gBACJ,CAAC;gBACD,MAAM,MAAM,GAAmB;oBAC7B,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,YAAY,EAAE,cAAc;oBAC5B,MAAM,EAAE,YAAY,CAAC,MAAM;oBAC3B,MAAM,EAAE,UAAU;oBAClB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;oBACpC,MAAM,EAAE,QAAQ;iBACjB,CAAC;gBACF,OAAO;oBACL,MAAM,EAAE,MAAM;oBACd,QAAQ,EAAE;wBACR,GAAG,QAAQ;wBACX,qBAAqB;wBACrB,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC;qBAC3C;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACJ,CAAC,CAA4B,CAAC;AAChC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { RemoveWorktreeTransactionInput } from '../types.js';
2
+ import type { TransactionDependencies } from '../dependencies.js';
3
+ export declare function removeWorktreeTransaction(dependencies: Pick<TransactionDependencies, 'dshHome' | 'git' | 'repositoryLock' | 'sidecar'>, input: RemoveWorktreeTransactionInput): Promise<void>;
4
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../../src/provider/transaction/operations/remove.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAclE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGlE,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,SAAS,GAAG,KAAK,GAAG,gBAAgB,GAAG,SAAS,CAAC,EAC7F,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,IAAI,CAAC,CAyLf"}
@@ -0,0 +1,164 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { createRepositoryFingerprint } from '../../git/repository-fingerprint.js';
3
+ import { pathExists, samePhysicalPath } from '../support/paths.js';
4
+ import { recoveryError, pendingRemove } from '../support/journal.js';
5
+ import { reconcileRemoveFailure } from '../recovery/failure-recovery.js';
6
+ import { withShardLock } from '../support/locking.js';
7
+ import { resolveRepository, findExactWorktree, findWorktreeByPhysicalPath } from '../support/inspection.js';
8
+ import { cleanLegacyObservations, assertMutationAdmitted, assertMutationToken, assertRepositoryCompatible, } from '../support/admission.js';
9
+ import { assertSafeRemovalPath } from '../support/path-safety.js';
10
+ import { publishRemoved, markRecovery } from '../support/publication.js';
11
+ import { providerError } from '../../types.js';
12
+ export async function removeWorktreeTransaction(dependencies, input) {
13
+ return withShardLock(dependencies, input.workspaceId, async (locked) => {
14
+ await dependencies.git.validateRepository(input.workspaceRoot);
15
+ const repository = await resolveRepository(dependencies, input.workspaceRoot);
16
+ return dependencies.repositoryLock.run(`repository:${createRepositoryFingerprint(repository.identity)}`, async (lock) => {
17
+ lock.assertHeld();
18
+ const gitRoot = repository.identity.topLevel;
19
+ await cleanLegacyObservations(locked);
20
+ const current = await locked.read();
21
+ assertMutationAdmitted(current, input.workspaceId);
22
+ assertRepositoryCompatible(current, repository.identity, input.workspaceId);
23
+ const record = current.worktrees.find((candidate) => candidate.worktreeId === input.worktreeId);
24
+ if (!record) {
25
+ throw providerError('WORKTREE_NOT_FOUND', `Worktree not found: ${input.worktreeId}`, {
26
+ workspaceId: input.workspaceId,
27
+ worktreeId: input.worktreeId,
28
+ });
29
+ }
30
+ if (record.status === 'removed') {
31
+ throw providerError('WORKTREE_REMOVED', `Worktree has already been removed: ${input.worktreeId}`, {
32
+ workspaceId: input.workspaceId,
33
+ worktreeId: input.worktreeId,
34
+ });
35
+ }
36
+ assertMutationToken(current, record, input.mutationToken);
37
+ if (await samePhysicalPath(record.absolutePath, gitRoot)) {
38
+ throw providerError('WORKTREE_STATE_CONFLICT', 'The main Worktree cannot be removed', {
39
+ workspaceId: input.workspaceId,
40
+ worktreeId: input.worktreeId,
41
+ targetPath: record.absolutePath,
42
+ });
43
+ }
44
+ const liveBefore = await dependencies.git.listWorktrees(gitRoot);
45
+ const exactBefore = await findExactWorktree(liveBefore, record.absolutePath, record.branch);
46
+ if (!exactBefore) {
47
+ const pathRegistration = await findWorktreeByPhysicalPath(liveBefore, record.absolutePath);
48
+ const branchRegistration = liveBefore.find((worktree) => worktree.branch === record.branch);
49
+ if (!pathRegistration &&
50
+ !branchRegistration &&
51
+ !(await pathExists(record.absolutePath))) {
52
+ // A legacy caller may have completed Git removal before the v3
53
+ // journal was introduced. With no path or matching registration
54
+ // left to delete, finalizing the relation is safe and idempotent.
55
+ const pending = pendingRemove(input, record, repository.identity);
56
+ await locked.mutate((snapshot) => {
57
+ const { repository: _repository, ...withoutRepository } = snapshot;
58
+ void _repository;
59
+ return {
60
+ result: undefined,
61
+ snapshot: {
62
+ ...withoutRepository,
63
+ repositoryFingerprint: createRepositoryFingerprint(repository.identity),
64
+ pendingOperation: pending,
65
+ },
66
+ };
67
+ });
68
+ await publishRemoved(locked, pending.id, input.worktreeId, repository.identity);
69
+ return;
70
+ }
71
+ await markRecovery(locked, {
72
+ id: randomUUID(),
73
+ type: 'remove-worktree',
74
+ phase: 'recovery-needed',
75
+ workspaceId: input.workspaceId,
76
+ worktreeId: input.worktreeId,
77
+ targetPath: record.absolutePath,
78
+ branch: record.branch,
79
+ source: record.source,
80
+ repositoryFingerprint: createRepositoryFingerprint(repository.identity),
81
+ startedAt: new Date().toISOString(),
82
+ }, 'WORKTREE_IDENTITY_CHANGED');
83
+ throw providerError('WORKTREE_IDENTITY_CHANGED', `Worktree identity changed: ${record.absolutePath}`, {
84
+ workspaceId: input.workspaceId,
85
+ worktreeId: input.worktreeId,
86
+ targetPath: record.absolutePath,
87
+ });
88
+ }
89
+ await assertSafeRemovalPath(dependencies, record, input.workspaceRoot);
90
+ const pending = pendingRemove(input, record, repository.identity);
91
+ await locked.mutate((snapshot) => {
92
+ const { repository: _repository, ...withoutRepository } = snapshot;
93
+ void _repository;
94
+ return {
95
+ result: undefined,
96
+ snapshot: {
97
+ ...withoutRepository,
98
+ repositoryFingerprint: createRepositoryFingerprint(repository.identity),
99
+ pendingOperation: pending,
100
+ },
101
+ };
102
+ });
103
+ try {
104
+ await dependencies.git.removeWorktree(input.workspaceRoot, record.absolutePath);
105
+ }
106
+ catch (error) {
107
+ return reconcileRemoveFailure(dependencies, {
108
+ locked,
109
+ input,
110
+ record,
111
+ pending,
112
+ repository: repository.identity,
113
+ gitRoot,
114
+ error,
115
+ });
116
+ }
117
+ lock.assertHeld();
118
+ let liveAfter;
119
+ try {
120
+ liveAfter = await dependencies.git.listWorktrees(gitRoot);
121
+ }
122
+ catch (inspectionError) {
123
+ await markRecovery(locked, pending, 'WORKTREE_RECOVERY_REQUIRED');
124
+ throw recoveryError(`Unable to verify Git after remove: ${record.absolutePath}`, {
125
+ workspaceId: input.workspaceId,
126
+ operationId: pending.id,
127
+ targetPath: record.absolutePath,
128
+ cause: String(inspectionError),
129
+ });
130
+ }
131
+ if (await findExactWorktree(liveAfter, record.absolutePath, record.branch)) {
132
+ await markRecovery(locked, pending, 'WORKTREE_RECOVERY_REQUIRED');
133
+ throw recoveryError(`Git remove did not remove the registered Worktree: ${record.absolutePath}`, {
134
+ workspaceId: input.workspaceId,
135
+ worktreeId: input.worktreeId,
136
+ targetPath: record.absolutePath,
137
+ });
138
+ }
139
+ let targetExists;
140
+ try {
141
+ targetExists = await pathExists(record.absolutePath);
142
+ }
143
+ catch (inspectionError) {
144
+ await markRecovery(locked, pending, 'WORKTREE_RECOVERY_REQUIRED');
145
+ throw recoveryError(`Unable to verify the removed Worktree path: ${record.absolutePath}`, {
146
+ workspaceId: input.workspaceId,
147
+ operationId: pending.id,
148
+ targetPath: record.absolutePath,
149
+ cause: String(inspectionError),
150
+ });
151
+ }
152
+ if (targetExists) {
153
+ await markRecovery(locked, pending, 'WORKTREE_IDENTITY_CHANGED');
154
+ throw providerError('WORKTREE_IDENTITY_CHANGED', `Worktree path remains after Git removal: ${record.absolutePath}`, {
155
+ workspaceId: input.workspaceId,
156
+ worktreeId: input.worktreeId,
157
+ targetPath: record.absolutePath,
158
+ });
159
+ }
160
+ await publishRemoved(locked, pending.id, input.worktreeId, repository.identity);
161
+ });
162
+ });
163
+ }
164
+ //# sourceMappingURL=remove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/provider/transaction/operations/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,YAA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C;gBACjE,MAAM,aAAa,CACjB,2BAA2B,EAC3B,4CAA4C,MAAM,CAAC,YAAY,EAAE,EACjE;oBACE,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,UAAU,EAAE,MAAM,CAAC,YAAY;iBAChC,CACF,CAAC;YACJ,CAAC;YACD,MAAM,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;QAClF,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { WorktreeRecord } from '../../../contract/index.js';
2
+ import type { LockedSidecarStore, PendingOperation, RepositoryIdentity } from '../../types.js';
3
+ import type { CreateWorktreeTransactionInput, RemoveWorktreeTransactionInput, CleanWorktreeTransactionInput } from '../types.js';
4
+ import type { TransactionDependencies } from '../dependencies.js';
5
+ export declare function reconcileCreateFailure(dependencies: Pick<TransactionDependencies, 'git'>, options: {
6
+ readonly locked: LockedSidecarStore;
7
+ readonly input: CreateWorktreeTransactionInput;
8
+ readonly record: WorktreeRecord;
9
+ readonly pending: PendingOperation;
10
+ readonly repository: RepositoryIdentity;
11
+ readonly gitRoot: string;
12
+ readonly error: unknown;
13
+ }): Promise<WorktreeRecord>;
14
+ export declare function reconcileRemoveFailure(dependencies: Pick<TransactionDependencies, 'git'>, options: {
15
+ readonly locked: LockedSidecarStore;
16
+ readonly input: RemoveWorktreeTransactionInput;
17
+ readonly record: WorktreeRecord;
18
+ readonly pending: PendingOperation;
19
+ readonly repository: RepositoryIdentity;
20
+ readonly gitRoot: string;
21
+ readonly error: unknown;
22
+ }): Promise<void>;
23
+ export declare function reconcileCleanFailure(dependencies: Pick<TransactionDependencies, 'git'>, options: {
24
+ readonly locked: LockedSidecarStore;
25
+ readonly input: CleanWorktreeTransactionInput;
26
+ readonly record: WorktreeRecord;
27
+ readonly pending: PendingOperation;
28
+ readonly repository: RepositoryIdentity;
29
+ readonly gitRoot: string;
30
+ readonly error: unknown;
31
+ }): Promise<void>;
32
+ //# sourceMappingURL=failure-recovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure-recovery.d.ts","sourceRoot":"","sources":["../../../../src/provider/transaction/recovery/failure-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAEV,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,8BAA8B,EAC9B,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,aAAa,CAAC;AAWrB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAClD,OAAO,EAAE;IACP,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,8BAA8B,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,cAAc,CAAC,CA2EzB;AAED,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAClD,OAAO,EAAE;IACP,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,8BAA8B,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,IAAI,CAAC,CA0Df;AAED,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAClD,OAAO,EAAE;IACP,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,6BAA6B,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,IAAI,CAAC,CA0Df"}
@@ -0,0 +1,147 @@
1
+ import { pathExists } from '../support/paths.js';
2
+ import { recoveryError, normalizeGitError } from '../support/journal.js';
3
+ import { findExactWorktree, isExactCreatedWorktree } from '../support/inspection.js';
4
+ import { publishCreated, publishCleaned, publishRemoved, clearPending, markRecovery, } from '../support/publication.js';
5
+ export async function reconcileCreateFailure(dependencies, options) {
6
+ let live;
7
+ try {
8
+ live = await dependencies.git.listWorktrees(options.gitRoot);
9
+ }
10
+ catch (inspectionError) {
11
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
12
+ throw recoveryError(`Unable to inspect Git after create failure: ${options.input.targetPath}`, {
13
+ workspaceId: options.input.workspaceId,
14
+ operationId: options.pending.id,
15
+ targetPath: options.input.targetPath,
16
+ cause: String(inspectionError),
17
+ });
18
+ }
19
+ if (await isExactCreatedWorktree(live, options.input)) {
20
+ await publishCreated(dependencies, options.locked, options.pending.id, options.record, options.repository);
21
+ return options.record;
22
+ }
23
+ let branches;
24
+ try {
25
+ branches = await dependencies.git.listBranches(options.gitRoot);
26
+ }
27
+ catch (inspectionError) {
28
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
29
+ throw recoveryError(`Unable to inspect branches after create failure: ${options.input.targetPath}`, {
30
+ workspaceId: options.input.workspaceId,
31
+ operationId: options.pending.id,
32
+ targetPath: options.input.targetPath,
33
+ cause: String(inspectionError),
34
+ });
35
+ }
36
+ const branchAmbiguous = options.pending.type === 'create-worktree' &&
37
+ options.pending.baseRef !== undefined &&
38
+ branches.includes(options.pending.branch);
39
+ let targetExists;
40
+ try {
41
+ targetExists = await pathExists(options.input.targetPath);
42
+ }
43
+ catch (inspectionError) {
44
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
45
+ throw recoveryError(`Unable to inspect the Worktree path after create failure: ${options.input.targetPath}`, {
46
+ workspaceId: options.input.workspaceId,
47
+ operationId: options.pending.id,
48
+ targetPath: options.input.targetPath,
49
+ cause: String(inspectionError),
50
+ });
51
+ }
52
+ if (!branchAmbiguous && !targetExists) {
53
+ await clearPending(options.locked, options.pending.id);
54
+ throw normalizeGitError('create worktree', options.input.workspaceRoot, options.input.targetPath, options.error);
55
+ }
56
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
57
+ throw recoveryError(`Git create failed with an unreconciled Worktree: ${options.input.targetPath}`, {
58
+ workspaceId: options.input.workspaceId,
59
+ operationId: options.pending.id,
60
+ targetPath: options.input.targetPath,
61
+ });
62
+ }
63
+ export async function reconcileRemoveFailure(dependencies, options) {
64
+ let live;
65
+ try {
66
+ live = await dependencies.git.listWorktrees(options.gitRoot);
67
+ }
68
+ catch (inspectionError) {
69
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
70
+ throw recoveryError(`Unable to inspect Git after remove failure: ${options.record.absolutePath}`, {
71
+ workspaceId: options.input.workspaceId,
72
+ operationId: options.pending.id,
73
+ targetPath: options.record.absolutePath,
74
+ cause: String(inspectionError),
75
+ });
76
+ }
77
+ if (await findExactWorktree(live, options.record.absolutePath, options.record.branch)) {
78
+ await clearPending(options.locked, options.pending.id);
79
+ throw normalizeGitError('remove worktree', options.input.workspaceRoot, options.record.absolutePath, options.error);
80
+ }
81
+ let targetExists;
82
+ try {
83
+ targetExists = await pathExists(options.record.absolutePath);
84
+ }
85
+ catch (inspectionError) {
86
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
87
+ throw recoveryError(`Unable to inspect the Worktree path after remove failure: ${options.record.absolutePath}`, {
88
+ workspaceId: options.input.workspaceId,
89
+ operationId: options.pending.id,
90
+ targetPath: options.record.absolutePath,
91
+ cause: String(inspectionError),
92
+ });
93
+ }
94
+ if (!targetExists) {
95
+ await publishRemoved(options.locked, options.pending.id, options.record.worktreeId, options.repository);
96
+ return;
97
+ }
98
+ await markRecovery(options.locked, options.pending, 'WORKTREE_IDENTITY_CHANGED');
99
+ throw recoveryError(`Git remove failed with an unreconciled Worktree: ${options.record.absolutePath}`, {
100
+ workspaceId: options.input.workspaceId,
101
+ operationId: options.pending.id,
102
+ targetPath: options.record.absolutePath,
103
+ });
104
+ }
105
+ export async function reconcileCleanFailure(dependencies, options) {
106
+ let live;
107
+ try {
108
+ live = await dependencies.git.listWorktrees(options.gitRoot);
109
+ }
110
+ catch (inspectionError) {
111
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
112
+ throw recoveryError(`Unable to inspect Git after clean failure: ${options.record.absolutePath}`, {
113
+ workspaceId: options.input.workspaceId,
114
+ operationId: options.pending.id,
115
+ targetPath: options.record.absolutePath,
116
+ cause: String(inspectionError),
117
+ });
118
+ }
119
+ if (await findExactWorktree(live, options.record.absolutePath, options.record.branch)) {
120
+ await clearPending(options.locked, options.pending.id);
121
+ throw normalizeGitError('clean worktree', options.input.workspaceRoot, options.record.absolutePath, options.error);
122
+ }
123
+ let targetExists;
124
+ try {
125
+ targetExists = await pathExists(options.record.absolutePath);
126
+ }
127
+ catch (inspectionError) {
128
+ await markRecovery(options.locked, options.pending, 'WORKTREE_RECOVERY_REQUIRED');
129
+ throw recoveryError(`Unable to inspect the Worktree path after clean failure: ${options.record.absolutePath}`, {
130
+ workspaceId: options.input.workspaceId,
131
+ operationId: options.pending.id,
132
+ targetPath: options.record.absolutePath,
133
+ cause: String(inspectionError),
134
+ });
135
+ }
136
+ if (!targetExists) {
137
+ await publishCleaned(options.locked, options.pending.id, options.input.worktreeId, options.repository);
138
+ return;
139
+ }
140
+ await markRecovery(options.locked, options.pending, 'WORKTREE_IDENTITY_CHANGED');
141
+ throw recoveryError(`Git clean failed with an unreconciled Worktree: ${options.record.absolutePath}`, {
142
+ workspaceId: options.input.workspaceId,
143
+ operationId: options.pending.id,
144
+ targetPath: options.record.absolutePath,
145
+ });
146
+ }
147
+ //# sourceMappingURL=failure-recovery.js.map