@askexenow/exe-os 0.9.264 → 0.9.266

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 (385) hide show
  1. package/deploy/compose/.env.example +4 -2
  2. package/deploy/compose/docker-compose.yml +6 -4
  3. package/deploy/compose/generate-env.ts +5 -2
  4. package/dist/active-agent-2XJJZFEW.js +25 -0
  5. package/dist/active-agent-JZ4PHIAK.js +26 -0
  6. package/dist/agentic-ontology-J4B525DT.js +25 -0
  7. package/dist/backfill-metadata-TWEC6BJD.js +597 -0
  8. package/dist/backfill-metadata-VGZLCJWZ.js +597 -0
  9. package/dist/backfill-metadata-WM46YQZL.js +597 -0
  10. package/dist/behaviors-BPIVFAGY.js +25 -0
  11. package/dist/bin/agentic-ontology-backfill.js +5 -5
  12. package/dist/bin/agentic-reflection-backfill.js +6 -6
  13. package/dist/bin/agentic-semantic-label.js +5 -5
  14. package/dist/bin/backfill-conversations.js +4 -4
  15. package/dist/bin/backfill-responses.js +4 -4
  16. package/dist/bin/backfill-vectors.js +5 -5
  17. package/dist/bin/bulk-sync-postgres.js +6 -6
  18. package/dist/bin/cc-doctor.js +6 -1
  19. package/dist/bin/cleanup-stale-review-tasks.js +9 -9
  20. package/dist/bin/cli.js +15 -15
  21. package/dist/bin/exe-agent-config.js +2 -2
  22. package/dist/bin/exe-agent.js +4 -4
  23. package/dist/bin/exe-assign.js +5 -5
  24. package/dist/bin/exe-boot.js +16 -16
  25. package/dist/bin/exe-call.js +4 -4
  26. package/dist/bin/exe-cloud.js +4 -4
  27. package/dist/bin/exe-dispatch.js +9 -9
  28. package/dist/bin/exe-doctor.js +1 -1
  29. package/dist/bin/exe-export-behaviors.js +7 -7
  30. package/dist/bin/exe-forget.js +6 -6
  31. package/dist/bin/exe-gateway.js +7 -7
  32. package/dist/bin/exe-healthcheck.js +6 -1
  33. package/dist/bin/exe-heartbeat.js +10 -10
  34. package/dist/bin/exe-kill.js +12 -12
  35. package/dist/bin/exe-launch-agent.js +16 -16
  36. package/dist/bin/exe-new-employee.js +6 -6
  37. package/dist/bin/exe-pending-messages.js +10 -10
  38. package/dist/bin/exe-pending-notifications.js +9 -9
  39. package/dist/bin/exe-pending-reviews.js +12 -10
  40. package/dist/bin/exe-rename.js +4 -4
  41. package/dist/bin/exe-review.js +11 -11
  42. package/dist/bin/exe-search.js +5 -5
  43. package/dist/bin/exe-session-cleanup.js +14 -14
  44. package/dist/bin/exe-settings.js +4 -4
  45. package/dist/bin/exe-start-codex.js +11 -11
  46. package/dist/bin/exe-start-opencode.js +8 -8
  47. package/dist/bin/exe-status.js +10 -10
  48. package/dist/bin/exe-team.js +3 -3
  49. package/dist/bin/git-sweep.js +10 -10
  50. package/dist/bin/graph-backfill.js +4 -4
  51. package/dist/bin/graph-export.js +5 -5
  52. package/dist/bin/import-history.js +7 -7
  53. package/dist/bin/install.js +6 -6
  54. package/dist/bin/intercom-check.js +6 -5
  55. package/dist/bin/mcp-sessions.js +2 -2
  56. package/dist/bin/orchestration-metrics.js +4 -4
  57. package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
  58. package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
  59. package/dist/bin/scan-tasks.js +9 -9
  60. package/dist/bin/setup.js +1 -1
  61. package/dist/bin/shard-migrate.js +4 -4
  62. package/dist/capacity-monitor-3QORC56J.js +49 -0
  63. package/dist/capacity-monitor-FWRBCZCZ.js +49 -0
  64. package/dist/capacity-monitor-FZORNXTA.js +49 -0
  65. package/dist/catchup-brief-242H63OP.js +151 -0
  66. package/dist/catchup-brief-PRKHIRWW.js +151 -0
  67. package/dist/catchup-brief-T7W2ARRB.js +151 -0
  68. package/dist/catchup-brief-VJDLXJHJ.js +151 -0
  69. package/dist/chunk-2FDYA3GS.js +75 -0
  70. package/dist/chunk-2GU3NYMB.js +813 -0
  71. package/dist/chunk-2V33IVZF.js +1148 -0
  72. package/dist/chunk-2VT7Z2E2.js +197 -0
  73. package/dist/chunk-2W5NQOQJ.js +333 -0
  74. package/dist/chunk-32QR5EHE.js +244 -0
  75. package/dist/chunk-3DBROKA6.js +382 -0
  76. package/dist/chunk-3DS2YHAT.js +204 -0
  77. package/dist/chunk-3L6XLN4V.js +1090 -0
  78. package/dist/chunk-3O2ZD7YV.js +227 -0
  79. package/dist/chunk-3T4PNG5O.js +447 -0
  80. package/dist/chunk-3W324KN7.js +13696 -0
  81. package/dist/chunk-43O2PZH7.js +214 -0
  82. package/dist/chunk-4AHL6I7X.js +284 -0
  83. package/dist/chunk-4IATAIAF.js +89 -0
  84. package/dist/chunk-5GBPXJIH.js +50 -0
  85. package/dist/chunk-5IXN2532.js +58 -0
  86. package/dist/chunk-5M4F2FVD.js +204 -0
  87. package/dist/chunk-5SH5TR45.js +731 -0
  88. package/dist/chunk-5TANMPI4.js +377 -0
  89. package/dist/chunk-5XGMTWKW.js +128 -0
  90. package/dist/chunk-67E5WIMW.js +333 -0
  91. package/dist/chunk-6AQAILCS.js +13696 -0
  92. package/dist/chunk-6NRJIARA.js +346 -0
  93. package/dist/chunk-6O22GTSE.js +1148 -0
  94. package/dist/chunk-72KQJZBH.js +382 -0
  95. package/dist/chunk-7B2AENJ3.js +1345 -0
  96. package/dist/chunk-7GKMYFVR.js +551 -0
  97. package/dist/chunk-7HUGVJHW.js +1021 -0
  98. package/dist/chunk-7HWBGXDV.js +333 -0
  99. package/dist/chunk-7O5CMDP6.js +1345 -0
  100. package/dist/chunk-7P2JKEO3.js +382 -0
  101. package/dist/chunk-7ROGPDW6.js +197 -0
  102. package/dist/chunk-7ZMLNURG.js +513 -0
  103. package/dist/chunk-A3G4UXNA.js +280 -0
  104. package/dist/chunk-A4T6U3XZ.js +371 -0
  105. package/dist/chunk-A4UY44T7.js +486 -0
  106. package/dist/chunk-ADJNRFEK.js +13696 -0
  107. package/dist/chunk-AVJTW67M.js +513 -0
  108. package/dist/chunk-AZHPQGSI.js +159 -0
  109. package/dist/chunk-B6RC7DAC.js +1090 -0
  110. package/dist/chunk-BAOJLZVC.js +244 -0
  111. package/dist/chunk-BCUMPA7J.js +159 -0
  112. package/dist/chunk-BH2ST7KK.js +183 -0
  113. package/dist/chunk-BQAC3GCO.js +127 -0
  114. package/dist/chunk-C4BIYP5C.js +129 -0
  115. package/dist/chunk-CBUZG6OC.js +89 -0
  116. package/dist/chunk-CGQRWCCP.js +81 -0
  117. package/dist/chunk-CIWJRYIC.js +244 -0
  118. package/dist/chunk-CLX4WQHT.js +214 -0
  119. package/dist/chunk-CZO2DGGF.js +214 -0
  120. package/dist/chunk-D4CQZL46.js +76 -0
  121. package/dist/chunk-D55SXO3N.js +3951 -0
  122. package/dist/chunk-DEBLYXA2.js +56 -0
  123. package/dist/chunk-EDNUE5L3.js +38 -0
  124. package/dist/chunk-EPDSRI6O.js +284 -0
  125. package/dist/chunk-ESNHLTLC.js +1073 -0
  126. package/dist/chunk-EU34R2A3.js +1073 -0
  127. package/dist/chunk-FICUAZEA.js +128 -0
  128. package/dist/chunk-FP6U5PSY.js +818 -0
  129. package/dist/chunk-G4KEDLSM.js +488 -0
  130. package/dist/chunk-G55UTKFR.js +89 -0
  131. package/dist/chunk-GIJUXLK5.js +330 -0
  132. package/dist/chunk-GVSSEGIV.js +348 -0
  133. package/dist/chunk-GYOOZ725.js +330 -0
  134. package/dist/chunk-HCULUL4D.js +447 -0
  135. package/dist/chunk-HDRQKH7R.js +1051 -0
  136. package/dist/chunk-HHBN7Y7R.js +197 -0
  137. package/dist/chunk-IODP4JNE.js +551 -0
  138. package/dist/chunk-IQBXQ7GF.js +1073 -0
  139. package/dist/chunk-ITF6GEJI.js +2091 -0
  140. package/dist/chunk-IXHVSWLM.js +58 -0
  141. package/dist/chunk-IZ6LCET7.js +58 -0
  142. package/dist/chunk-J3ZFONT4.js +1921 -0
  143. package/dist/chunk-JEOFG274.js +394 -0
  144. package/dist/chunk-JH7ISOIJ.js +33 -0
  145. package/dist/chunk-JVRMAVPN.js +731 -0
  146. package/dist/chunk-KBYRYSXT.js +3951 -0
  147. package/dist/chunk-KECNXWD6.js +1051 -0
  148. package/dist/chunk-KIYCHS35.js +128 -0
  149. package/dist/chunk-KUP3D6G2.js +1345 -0
  150. package/dist/chunk-KXS5HHDH.js +54 -0
  151. package/dist/chunk-LPG3U5UW.js +731 -0
  152. package/dist/chunk-LVZW4WQY.js +221 -0
  153. package/dist/chunk-LWOCCDSB.js +240 -0
  154. package/dist/chunk-M4HRKRSE.js +30 -0
  155. package/dist/chunk-MPG5DR3K.js +244 -0
  156. package/dist/chunk-NH6TPXZV.js +13696 -0
  157. package/dist/chunk-NOG2LVBA.js +159 -0
  158. package/dist/chunk-NP3CYOEY.js +290 -0
  159. package/dist/chunk-O5TZI7OZ.js +50 -0
  160. package/dist/chunk-OVQOKLYA.js +210 -0
  161. package/dist/chunk-OW26ML36.js +1148 -0
  162. package/dist/chunk-P2DOIWQG.js +260 -0
  163. package/dist/chunk-P2QTTEYP.js +3951 -0
  164. package/dist/chunk-P5IKFL7B.js +85 -0
  165. package/dist/chunk-PD2LUPHD.js +377 -0
  166. package/dist/chunk-PF5EFIAH.js +818 -0
  167. package/dist/chunk-PK3NFO76.js +551 -0
  168. package/dist/chunk-Q3N4KHLM.js +330 -0
  169. package/dist/chunk-QHQTMWYH.js +54 -0
  170. package/dist/chunk-QKMFMJTU.js +171 -0
  171. package/dist/chunk-QNYOPM2L.js +1921 -0
  172. package/dist/chunk-R77M74QM.js +13696 -0
  173. package/dist/chunk-RHZ2CRJU.js +3556 -0
  174. package/dist/chunk-RLR4LVO5.js +1090 -0
  175. package/dist/chunk-RMDDSWFH.js +495 -0
  176. package/dist/chunk-RPLEZ74B.js +95 -0
  177. package/dist/chunk-RXMVPGH2.js +346 -0
  178. package/dist/chunk-S2ARWNS6.js +135 -0
  179. package/dist/chunk-SHPIATX7.js +90 -0
  180. package/dist/chunk-SPOA7EOD.js +81 -0
  181. package/dist/chunk-SQUZ3TI2.js +668 -0
  182. package/dist/chunk-SUGBKORD.js +1148 -0
  183. package/dist/chunk-T2XD7XL2.js +346 -0
  184. package/dist/chunk-TAIYLROT.js +127 -0
  185. package/dist/chunk-TCD4XCBS.js +495 -0
  186. package/dist/chunk-TK23WXKB.js +128 -0
  187. package/dist/chunk-TOVXER6J.js +76 -0
  188. package/dist/chunk-TSBMSHMM.js +163 -0
  189. package/dist/chunk-U776PBU6.js +488 -0
  190. package/dist/chunk-UIPAZYP7.js +171 -0
  191. package/dist/chunk-UTVNIAOF.js +284 -0
  192. package/dist/chunk-VF6VT4MR.js +70 -0
  193. package/dist/chunk-VZXLYUKS.js +171 -0
  194. package/dist/chunk-WIAHPJDS.js +58 -0
  195. package/dist/chunk-WM5ELLT4.js +54 -0
  196. package/dist/chunk-WUUSPOCC.js +1921 -0
  197. package/dist/chunk-WXHAMPK4.js +81 -0
  198. package/dist/chunk-WXW4GF6M.js +495 -0
  199. package/dist/chunk-WYNZ23XH.js +262 -0
  200. package/dist/chunk-WZOQLU2Y.js +127 -0
  201. package/dist/chunk-X24GBZKR.js +157 -0
  202. package/dist/chunk-X5FRF5MG.js +13696 -0
  203. package/dist/chunk-XBPLYFBA.js +204 -0
  204. package/dist/chunk-XDGKFXFW.js +363 -0
  205. package/dist/chunk-XIT6ONPY.js +630 -0
  206. package/dist/{chunk-YGOUKUNX.js → chunk-XLYBSXWS.js} +2 -1
  207. package/dist/chunk-XNRJ5JHU.js +377 -0
  208. package/dist/chunk-XREWTPZM.js +123 -0
  209. package/dist/chunk-XURCA5VD.js +297 -0
  210. package/dist/chunk-Y55VFZJB.js +50 -0
  211. package/dist/chunk-YIH2YMWP.js +76 -0
  212. package/dist/chunk-YZMCCT73.js +97 -0
  213. package/dist/chunk-ZTP3VV23.js +447 -0
  214. package/dist/co-activation-JOYR73H2.js +72 -0
  215. package/dist/co-occurrence-G7RRJ3DB.js +74 -0
  216. package/dist/core-memory-6KK55Z65.js +110 -0
  217. package/dist/core-memory-QRS6GBXL.js +110 -0
  218. package/dist/core-memory-QXMQ5I7S.js +110 -0
  219. package/dist/crdt-sync-QWK65Z5A.js +33 -0
  220. package/dist/crm-webhook-BNUS3USD.js +10 -0
  221. package/dist/crm-webhook-CH5W633Y.js +10 -0
  222. package/dist/crm-webhook-ZTIRFVAH.js +10 -0
  223. package/dist/cto-delegation-gate-DNZJGBS7.js +206 -0
  224. package/dist/cto-delegation-gate-XY3NMGTE.js +206 -0
  225. package/dist/cto-delegation-gate-YI3LK7VY.js +206 -0
  226. package/dist/daemon-orchestration-7LVOHYKA.js +135 -0
  227. package/dist/daemon-orchestration-LS62JMTI.js +135 -0
  228. package/dist/daemon-orchestration-SDQNWI3K.js +135 -0
  229. package/dist/db-backup-5ENHDNZI.js +33 -0
  230. package/dist/dreaming-PGJOCGAM.js +32 -0
  231. package/dist/dreaming-UNHHGOU3.js +32 -0
  232. package/dist/dreaming-ZBKE2GFX.js +32 -0
  233. package/dist/exe-drift-QQJMUQXA.js +68 -0
  234. package/dist/exe-export-BEZZSQB4.js +73 -0
  235. package/dist/exe-export-JNSQRIWI.js +73 -0
  236. package/dist/exe-export-TQGI2VBT.js +73 -0
  237. package/dist/exe-import-2SR2UP3D.js +76 -0
  238. package/dist/exe-import-73Q4VLFK.js +76 -0
  239. package/dist/exe-import-AVGWQZLU.js +76 -0
  240. package/dist/exe-key-6JHEINOM.js +579 -0
  241. package/dist/exe-key-RIRPIFK6.js +579 -0
  242. package/dist/exe-key-WR6QEHYO.js +579 -0
  243. package/dist/exe-snapshot-NDMDQJOH.js +164 -0
  244. package/dist/exe-snapshot-PVCBPMPJ.js +164 -0
  245. package/dist/exe-snapshot-U6K3J6BD.js +164 -0
  246. package/dist/fast-db-init-22OBOPTN.js +7 -0
  247. package/dist/fast-db-init-M6ZYYGAL.js +7 -0
  248. package/dist/fast-db-init-ZHRRYI7M.js +7 -0
  249. package/dist/gateway/index.js +8 -8
  250. package/dist/git-staleness-4DGYC3RY.js +110 -0
  251. package/dist/git-task-sweep-64KSWRUI.js +40 -0
  252. package/dist/git-task-sweep-CUR7R2ZM.js +40 -0
  253. package/dist/git-task-sweep-YG3IVGK3.js +40 -0
  254. package/dist/global-procedures-TYDNKM7V.js +20 -0
  255. package/dist/graph-auto-extract-I6B5HWTP.js +162 -0
  256. package/dist/hooks/bug-report-worker.js +11 -11
  257. package/dist/hooks/codex-stop-task-finalizer.js +11 -11
  258. package/dist/hooks/commit-complete.js +11 -11
  259. package/dist/hooks/error-recall.js +6 -6
  260. package/dist/hooks/exe-heartbeat-hook.js +3 -3
  261. package/dist/hooks/ingest.js +6 -6
  262. package/dist/hooks/instructions-loaded.js +4 -4
  263. package/dist/hooks/manifest.json +19 -19
  264. package/dist/hooks/notification.js +4 -4
  265. package/dist/hooks/post-compact.js +10 -10
  266. package/dist/hooks/post-tool-combined.js +5 -5
  267. package/dist/hooks/pre-compact.js +11 -11
  268. package/dist/hooks/pre-tool-use.js +14 -14
  269. package/dist/hooks/prompt-submit.js +27 -22
  270. package/dist/hooks/session-end.js +15 -15
  271. package/dist/hooks/session-start.js +10 -10
  272. package/dist/hooks/stop.js +14 -14
  273. package/dist/hooks/subagent-stop.js +10 -10
  274. package/dist/hooks/summary-worker.js +14 -14
  275. package/dist/index.js +17 -17
  276. package/dist/installer-4LP73C3M.js +38 -0
  277. package/dist/installer-AUVLNS4D.js +296 -0
  278. package/dist/installer-KCRLQSQH.js +38 -0
  279. package/dist/installer-KGXYUOIV.js +296 -0
  280. package/dist/installer-UI6TNJGO.js +342 -0
  281. package/dist/installer-Z7NPD4PD.js +342 -0
  282. package/dist/lib/cloud-sync.js +4 -4
  283. package/dist/lib/consolidation.js +5 -5
  284. package/dist/lib/database.js +2 -2
  285. package/dist/lib/db-daemon-client.js +6 -0
  286. package/dist/lib/db.js +2 -2
  287. package/dist/lib/employee-templates.js +4 -4
  288. package/dist/lib/employees.js +2 -2
  289. package/dist/lib/exe-daemon.js +39 -38
  290. package/dist/lib/hybrid-search.js +5 -5
  291. package/dist/lib/identity.js +2 -2
  292. package/dist/lib/messaging.js +9 -9
  293. package/dist/lib/reminders.js +3 -3
  294. package/dist/lib/schedules.js +5 -5
  295. package/dist/lib/session-registry.js +4 -4
  296. package/dist/lib/skill-learning.js +4 -4
  297. package/dist/lib/store.js +4 -4
  298. package/dist/lib/task-router.js +3 -3
  299. package/dist/lib/tasks.js +10 -10
  300. package/dist/lib/tmux-routing.js +8 -8
  301. package/dist/lib/token-spend.js +3 -3
  302. package/dist/mcp/register-tools.js +53 -52
  303. package/dist/mcp/server.js +54 -53
  304. package/dist/mcp/tools/complete-reminder.js +4 -4
  305. package/dist/mcp/tools/create-reminder.js +4 -4
  306. package/dist/mcp/tools/create-task.js +12 -12
  307. package/dist/mcp/tools/deactivate-behavior.js +5 -5
  308. package/dist/mcp/tools/list-reminders.js +4 -4
  309. package/dist/mcp/tools/list-tasks.js +12 -12
  310. package/dist/mcp/tools/send-message.js +11 -11
  311. package/dist/mcp/tools/update-task.js +11 -11
  312. package/dist/mcp-http-config-LN5ITKGS.js +27 -0
  313. package/dist/mcp-http-config-V43VHNEH.js +27 -0
  314. package/dist/memory-cards-S36DCEY4.js +174 -0
  315. package/dist/memory-graph-extractor-66YL4V4B.js +17 -0
  316. package/dist/memory-poisoning-defense-MXWE6CTY.js +225 -0
  317. package/dist/memory-reflection-W676LUX5.js +238 -0
  318. package/dist/notifications-45QSHDFA.js +45 -0
  319. package/dist/notifications-OFLXZTDZ.js +45 -0
  320. package/dist/notifications-XAV4V7T5.js +45 -0
  321. package/dist/orchestration-events-MJLWJ2H2.js +25 -0
  322. package/dist/orchestrator-7XBMFK7D.js +33 -0
  323. package/dist/orchestrator-AIAKV5ST.js +33 -0
  324. package/dist/orchestrator-VK7D6I36.js +33 -0
  325. package/dist/pipeline-router-DXH5QVUH.js +13 -0
  326. package/dist/pipeline-router-EV6C5S33.js +13 -0
  327. package/dist/pipeline-router-MQKRNCTR.js +13 -0
  328. package/dist/plan-limits-TQMLKZBG.js +26 -0
  329. package/dist/project-boot-4XTXHDG4.js +299 -0
  330. package/dist/projection-worker-NAYVNSI4.js +964 -0
  331. package/dist/reranker-CJW3UYE2.js +19 -0
  332. package/dist/reranker-KHZI7HQK.js +19 -0
  333. package/dist/reranker-UPMS3OX7.js +19 -0
  334. package/dist/reranker-ZN73HWSB.js +19 -0
  335. package/dist/review-polling-3UEZSPNT.js +124 -0
  336. package/dist/review-polling-KBDX3ILL.js +124 -0
  337. package/dist/review-polling-RL75XLAY.js +124 -0
  338. package/dist/runtime/index.js +11 -11
  339. package/dist/session-events-2CHOLA6D.js +36 -0
  340. package/dist/session-events-HM22KEHN.js +36 -0
  341. package/dist/session-events-ZULAN4XL.js +36 -0
  342. package/dist/session-kill-telemetry-LUPVYGZX.js +29 -0
  343. package/dist/session-scope-EPZZZHHJ.js +86 -0
  344. package/dist/session-scope-V2RSOTDU.js +86 -0
  345. package/dist/session-scope-ZGE6GHMS.js +86 -0
  346. package/dist/setup-wizard-KNWH54HW.js +12 -0
  347. package/dist/skill-refinement-BSX6Q6IN.js +157 -0
  348. package/dist/skill-refinement-C4GNWV4F.js +157 -0
  349. package/dist/skill-refinement-CAUIE4YM.js +157 -0
  350. package/dist/steward-gate-MZ2DV36N.js +13 -0
  351. package/dist/task-enforcement-6OMXG6EA.js +333 -0
  352. package/dist/task-enforcement-JFSF6QDD.js +333 -0
  353. package/dist/task-enforcement-JRTAOYZT.js +333 -0
  354. package/dist/task-scope-4HJSCJ7L.js +35 -0
  355. package/dist/task-scope-7HYE4AS6.js +35 -0
  356. package/dist/task-scope-GNCB2GAM.js +35 -0
  357. package/dist/tasks-crud-JJL6MMJF.js +77 -0
  358. package/dist/tasks-crud-KMIPDHBZ.js +77 -0
  359. package/dist/tasks-crud-MZIOYF3R.js +77 -0
  360. package/dist/tasks-notify-5D6LF52K.js +38 -0
  361. package/dist/tasks-notify-7KNZ4ULO.js +38 -0
  362. package/dist/tasks-notify-JNGGXFUY.js +38 -0
  363. package/dist/tasks-review-N6I5UC7G.js +47 -0
  364. package/dist/tasks-review-U5VEV4Y7.js +47 -0
  365. package/dist/tasks-review-USHAMO5N.js +47 -0
  366. package/dist/telemetry-upload-BIB5TJA4.js +739 -0
  367. package/dist/telemetry-upload-BV2M2NND.js +739 -0
  368. package/dist/telemetry-upload-Y7QPDJW4.js +739 -0
  369. package/dist/token-budget-2LUZOFO7.js +84 -0
  370. package/dist/tool-telemetry-5JT6DPVK.js +17 -0
  371. package/dist/tui/App.js +16 -16
  372. package/dist/tui-data-DMAKZMGD.js +258 -0
  373. package/dist/tui-data-X7NI6ZQ3.js +258 -0
  374. package/dist/tui-data-ZSB5DDEY.js +258 -0
  375. package/dist/wiki-acl-QHGGWX63.js +111 -0
  376. package/dist/worker-gate-4XKUOFWO.js +21 -0
  377. package/dist/worker-gate-TPZBOXOA.js +21 -0
  378. package/dist/worker-gate-TXLX33PX.js +21 -0
  379. package/dist/workflow-engine-3PIT3Y56.js +28 -0
  380. package/dist/workflow-engine-F3URLOPA.js +28 -0
  381. package/dist/workflow-engine-OFOL446Z.js +28 -0
  382. package/dist/worktree-V3NVP7MV.js +26 -0
  383. package/dist/worktree-sweep-2CADL43Y.js +19 -0
  384. package/package.json +1 -1
  385. package/release-notes.json +27 -25
@@ -0,0 +1,280 @@
1
+ import {
2
+ recordOrchestrationEventBestEffort
3
+ } from "./chunk-XIT6ONPY.js";
4
+
5
+ // src/lib/worktree.ts
6
+ import { execSync } from "child_process";
7
+ import { existsSync, readFileSync, appendFileSync, mkdirSync, realpathSync } from "fs";
8
+ import path from "path";
9
+ var GIT_TIMEOUT_MS = 1e4;
10
+ function getGitRoot(dir) {
11
+ try {
12
+ const root = execSync("git rev-parse --show-toplevel", {
13
+ cwd: dir,
14
+ encoding: "utf-8",
15
+ timeout: GIT_TIMEOUT_MS,
16
+ stdio: ["pipe", "pipe", "pipe"]
17
+ }).trim();
18
+ return realpath(root);
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
23
+ function getMainRepoRoot(dir) {
24
+ try {
25
+ const commonDir = execSync(
26
+ "git rev-parse --path-format=absolute --git-common-dir",
27
+ { cwd: dir, encoding: "utf-8", timeout: GIT_TIMEOUT_MS, stdio: ["pipe", "pipe", "pipe"] }
28
+ ).trim();
29
+ return realpath(path.dirname(commonDir));
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+ function worktreePath(repoRoot, employeeName, instance) {
35
+ const label = instanceLabel(employeeName, instance);
36
+ return path.join(repoRoot, ".worktrees", label);
37
+ }
38
+ function worktreeBranch(employeeName, instance, taskSlug) {
39
+ const label = instanceLabel(employeeName, instance);
40
+ if (taskSlug) {
41
+ const slug = taskSlug.slice(0, 40).replace(/[^a-z0-9-]/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
42
+ return `${label}-${slug}`;
43
+ }
44
+ return `${label}-work`;
45
+ }
46
+ function instanceLabel(name, instance) {
47
+ return instance != null && instance > 0 ? `${name}${instance}` : name;
48
+ }
49
+ function ensureWorktree(projectDir, employeeName, instance) {
50
+ const repoRoot = getGitRoot(projectDir);
51
+ if (!repoRoot) return null;
52
+ const wtPath = worktreePath(repoRoot, employeeName, instance);
53
+ const branch = worktreeBranch(employeeName, instance);
54
+ if (existsSync(path.join(wtPath, ".git"))) {
55
+ recordOrchestrationEventBestEffort({
56
+ eventType: "worktree.reused",
57
+ source: "worktree.ensureWorktree",
58
+ agentId: employeeName,
59
+ instanceId: instance != null ? String(instance) : null,
60
+ payload: { branch }
61
+ });
62
+ return wtPath;
63
+ }
64
+ const worktreesDir = path.join(repoRoot, ".worktrees");
65
+ mkdirSync(worktreesDir, { recursive: true });
66
+ ensureGitignoreEntry(repoRoot, "/.worktrees/");
67
+ try {
68
+ execSync("git worktree prune", {
69
+ cwd: repoRoot,
70
+ encoding: "utf-8",
71
+ timeout: GIT_TIMEOUT_MS,
72
+ stdio: ["pipe", "pipe", "pipe"]
73
+ });
74
+ } catch {
75
+ }
76
+ const branchExists = branchExistsLocally(repoRoot, branch);
77
+ try {
78
+ if (branchExists) {
79
+ execSync(`git worktree add "${wtPath}" "${branch}"`, {
80
+ cwd: repoRoot,
81
+ encoding: "utf-8",
82
+ timeout: GIT_TIMEOUT_MS,
83
+ stdio: ["pipe", "pipe", "pipe"]
84
+ });
85
+ } else {
86
+ execSync(`git worktree add "${wtPath}" -b "${branch}" HEAD`, {
87
+ cwd: repoRoot,
88
+ encoding: "utf-8",
89
+ timeout: GIT_TIMEOUT_MS,
90
+ stdio: ["pipe", "pipe", "pipe"]
91
+ });
92
+ }
93
+ recordOrchestrationEventBestEffort({
94
+ eventType: "worktree.created",
95
+ source: "worktree.ensureWorktree",
96
+ agentId: employeeName,
97
+ instanceId: instance != null ? String(instance) : null,
98
+ payload: { branch, reusedBranch: branchExists }
99
+ });
100
+ return wtPath;
101
+ } catch (err) {
102
+ recordOrchestrationEventBestEffort({
103
+ eventType: "worktree.failed",
104
+ source: "worktree.ensureWorktree",
105
+ severity: "warn",
106
+ agentId: employeeName,
107
+ instanceId: instance != null ? String(instance) : null,
108
+ errorCode: err instanceof Error ? err.name : "worktree_create_failed",
109
+ payload: { branch }
110
+ });
111
+ process.stderr.write(
112
+ `[worktree] Failed to create worktree for ${employeeName}: ${err instanceof Error ? err.message : String(err)}
113
+ `
114
+ );
115
+ return null;
116
+ }
117
+ }
118
+ function isWorktreeDirty(wtPath) {
119
+ try {
120
+ const status = execSync("git status --porcelain", {
121
+ cwd: wtPath,
122
+ encoding: "utf-8",
123
+ timeout: GIT_TIMEOUT_MS,
124
+ stdio: ["pipe", "pipe", "pipe"]
125
+ }).trim();
126
+ return status.length > 0;
127
+ } catch {
128
+ return true;
129
+ }
130
+ }
131
+ function cleanupWorktree(projectDir, employeeName, instance) {
132
+ const repoRoot = getMainRepoRoot(projectDir);
133
+ if (!repoRoot) return { cleaned: false, reason: "not a git repo" };
134
+ const wtPath = worktreePath(repoRoot, employeeName, instance);
135
+ const branch = worktreeBranch(employeeName, instance);
136
+ if (!existsSync(wtPath)) {
137
+ recordOrchestrationEventBestEffort({
138
+ eventType: "worktree.skipped",
139
+ source: "worktree.cleanupWorktree",
140
+ agentId: employeeName,
141
+ instanceId: instance != null ? String(instance) : null,
142
+ payload: { reason: "worktree does not exist", branch }
143
+ });
144
+ return { cleaned: false, reason: "worktree does not exist" };
145
+ }
146
+ if (isWorktreeDirty(wtPath)) {
147
+ recordOrchestrationEventBestEffort({
148
+ eventType: "worktree.skipped",
149
+ source: "worktree.cleanupWorktree",
150
+ agentId: employeeName,
151
+ instanceId: instance != null ? String(instance) : null,
152
+ payload: { reason: "worktree has uncommitted changes", branch }
153
+ });
154
+ return { cleaned: false, reason: "worktree has uncommitted changes" };
155
+ }
156
+ const mainBranch = detectMainBranch(repoRoot);
157
+ if (!mainBranch) {
158
+ recordOrchestrationEventBestEffort({
159
+ eventType: "worktree.skipped",
160
+ source: "worktree.cleanupWorktree",
161
+ agentId: employeeName,
162
+ instanceId: instance != null ? String(instance) : null,
163
+ payload: { reason: "could not determine main branch", branch }
164
+ });
165
+ return { cleaned: false, reason: "could not determine main branch" };
166
+ }
167
+ if (!isBranchMerged(repoRoot, branch, mainBranch)) {
168
+ recordOrchestrationEventBestEffort({
169
+ eventType: "worktree.skipped",
170
+ source: "worktree.cleanupWorktree",
171
+ agentId: employeeName,
172
+ instanceId: instance != null ? String(instance) : null,
173
+ payload: { reason: "branch not merged", branch, mainBranch }
174
+ });
175
+ return { cleaned: false, reason: `branch ${branch} not merged into ${mainBranch}` };
176
+ }
177
+ try {
178
+ execSync(`git worktree remove "${wtPath}"`, {
179
+ cwd: repoRoot,
180
+ encoding: "utf-8",
181
+ timeout: GIT_TIMEOUT_MS,
182
+ stdio: ["pipe", "pipe", "pipe"]
183
+ });
184
+ } catch (err) {
185
+ recordOrchestrationEventBestEffort({
186
+ eventType: "worktree.failed",
187
+ source: "worktree.cleanupWorktree",
188
+ severity: "warn",
189
+ agentId: employeeName,
190
+ instanceId: instance != null ? String(instance) : null,
191
+ errorCode: err instanceof Error ? err.name : "worktree_remove_failed",
192
+ payload: { branch, mainBranch }
193
+ });
194
+ return {
195
+ cleaned: false,
196
+ reason: `git worktree remove failed: ${err instanceof Error ? err.message : String(err)}`
197
+ };
198
+ }
199
+ try {
200
+ execSync(`git branch -d "${branch}"`, {
201
+ cwd: repoRoot,
202
+ encoding: "utf-8",
203
+ timeout: GIT_TIMEOUT_MS,
204
+ stdio: ["pipe", "pipe", "pipe"]
205
+ });
206
+ } catch {
207
+ }
208
+ recordOrchestrationEventBestEffort({
209
+ eventType: "worktree.pruned",
210
+ source: "worktree.cleanupWorktree",
211
+ agentId: employeeName,
212
+ instanceId: instance != null ? String(instance) : null,
213
+ payload: { branch, mainBranch }
214
+ });
215
+ return { cleaned: true, reason: `worktree and branch ${branch} removed (merged into ${mainBranch})` };
216
+ }
217
+ function branchExistsLocally(repoRoot, branch) {
218
+ try {
219
+ execSync(`git rev-parse --verify "refs/heads/${branch}"`, {
220
+ cwd: repoRoot,
221
+ encoding: "utf-8",
222
+ timeout: GIT_TIMEOUT_MS,
223
+ stdio: ["pipe", "pipe", "pipe"]
224
+ });
225
+ return true;
226
+ } catch {
227
+ return false;
228
+ }
229
+ }
230
+ function detectMainBranch(repoRoot) {
231
+ for (const candidate of ["main", "master"]) {
232
+ if (branchExistsLocally(repoRoot, candidate)) return candidate;
233
+ }
234
+ return null;
235
+ }
236
+ function isBranchMerged(repoRoot, branch, into) {
237
+ try {
238
+ const merged = execSync(`git branch --merged "${into}"`, {
239
+ cwd: repoRoot,
240
+ encoding: "utf-8",
241
+ timeout: GIT_TIMEOUT_MS,
242
+ stdio: ["pipe", "pipe", "pipe"]
243
+ });
244
+ return merged.split("\n").map((l) => l.replace(/^[*+]?\s+/, "").trim()).includes(branch);
245
+ } catch {
246
+ return false;
247
+ }
248
+ }
249
+ function realpath(p) {
250
+ try {
251
+ return realpathSync(p);
252
+ } catch {
253
+ return p;
254
+ }
255
+ }
256
+ function ensureGitignoreEntry(repoRoot, entry) {
257
+ try {
258
+ const gitignorePath = path.join(repoRoot, ".gitignore");
259
+ if (existsSync(gitignorePath)) {
260
+ const content = readFileSync(gitignorePath, "utf-8");
261
+ if (content.includes(entry)) return;
262
+ appendFileSync(gitignorePath, `
263
+ # Agent worktrees (exe-os)
264
+ ${entry}
265
+ `);
266
+ } else {
267
+ }
268
+ } catch {
269
+ }
270
+ }
271
+
272
+ export {
273
+ getGitRoot,
274
+ getMainRepoRoot,
275
+ worktreePath,
276
+ worktreeBranch,
277
+ ensureWorktree,
278
+ isWorktreeDirty,
279
+ cleanupWorktree
280
+ };
@@ -0,0 +1,371 @@
1
+ import {
2
+ getGitRoot,
3
+ isWorktreeDirty
4
+ } from "./chunk-A3G4UXNA.js";
5
+
6
+ // src/lib/worktree-sweep.ts
7
+ import { execSync } from "child_process";
8
+ import { existsSync, readdirSync, readFileSync } from "fs";
9
+ import path from "path";
10
+ function isWorktreeUnpushed(wtPath, branch) {
11
+ if (!branch) return false;
12
+ try {
13
+ const remote = execSync(`git -C "${wtPath}" rev-parse --abbrev-ref "${branch}@{upstream}" 2>/dev/null`, { encoding: "utf-8" }).trim();
14
+ if (!remote) return true;
15
+ const ahead = execSync(`git -C "${wtPath}" rev-list "${remote}..${branch}" --count 2>/dev/null`, { encoding: "utf-8" }).trim();
16
+ return parseInt(ahead, 10) > 0;
17
+ } catch {
18
+ try {
19
+ const ahead = execSync(`git -C "${wtPath}" rev-list "main..${branch}" --count 2>/dev/null || git -C "${wtPath}" rev-list "master..${branch}" --count 2>/dev/null`, { encoding: "utf-8" }).trim();
20
+ return parseInt(ahead, 10) > 0;
21
+ } catch {
22
+ return true;
23
+ }
24
+ }
25
+ }
26
+ var REPO_ALIASES = {
27
+ "exe-crm": ["openclaw", "exe-crm"],
28
+ "exe-wiki": ["ink", "exe-wiki"]
29
+ };
30
+ function discoverRepoPaths() {
31
+ const roots = [];
32
+ let exeOsRoot = null;
33
+ let dir = path.dirname(new URL(import.meta.url).pathname);
34
+ for (let i = 0; i < 5; i++) {
35
+ const pkgPath = path.join(dir, "package.json");
36
+ if (existsSync(pkgPath)) {
37
+ try {
38
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
39
+ if (pkg.name === "@askexenow/exe-os") {
40
+ exeOsRoot = dir;
41
+ break;
42
+ }
43
+ } catch {
44
+ }
45
+ }
46
+ dir = path.dirname(dir);
47
+ }
48
+ if (!exeOsRoot) {
49
+ exeOsRoot = process.cwd();
50
+ }
51
+ roots.push(exeOsRoot);
52
+ const parentDir = path.dirname(exeOsRoot);
53
+ try {
54
+ const siblings = readdirSync(parentDir);
55
+ for (const sibling of siblings) {
56
+ if (sibling.startsWith(".")) continue;
57
+ const siblingPath = path.join(parentDir, sibling);
58
+ if (siblingPath === exeOsRoot) continue;
59
+ const root = getGitRoot(siblingPath);
60
+ if (root && !roots.includes(root)) {
61
+ roots.push(root);
62
+ }
63
+ }
64
+ } catch {
65
+ }
66
+ for (const aliases of Object.values(REPO_ALIASES)) {
67
+ for (const alias of aliases) {
68
+ const aliasPath = path.join(parentDir, alias);
69
+ if (existsSync(aliasPath)) {
70
+ const root = getGitRoot(aliasPath);
71
+ if (root && !roots.includes(root)) {
72
+ roots.push(root);
73
+ }
74
+ }
75
+ }
76
+ }
77
+ return roots;
78
+ }
79
+ var GIT_TIMEOUT_MS = 1e4;
80
+ function listWorktrees(repoRoot) {
81
+ try {
82
+ const output = execSync("git worktree list --porcelain", {
83
+ cwd: repoRoot,
84
+ encoding: "utf8",
85
+ timeout: GIT_TIMEOUT_MS,
86
+ stdio: ["pipe", "pipe", "pipe"]
87
+ });
88
+ const worktrees = [];
89
+ let currentPath = "";
90
+ for (const line of output.split("\n")) {
91
+ if (line.startsWith("worktree ")) {
92
+ currentPath = line.slice("worktree ".length);
93
+ } else if (line.startsWith("branch ") && currentPath) {
94
+ const branch = line.slice("branch refs/heads/".length);
95
+ worktrees.push({ path: currentPath, branch });
96
+ currentPath = "";
97
+ }
98
+ }
99
+ return worktrees;
100
+ } catch {
101
+ return [];
102
+ }
103
+ }
104
+ function detectMainBranch(repoRoot) {
105
+ for (const candidate of ["main", "master"]) {
106
+ try {
107
+ execSync(`git rev-parse --verify "refs/heads/${candidate}"`, {
108
+ cwd: repoRoot,
109
+ encoding: "utf8",
110
+ timeout: GIT_TIMEOUT_MS,
111
+ stdio: ["pipe", "pipe", "pipe"]
112
+ });
113
+ return candidate;
114
+ } catch {
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+ function isBranchMerged(repoRoot, branch, into) {
120
+ try {
121
+ const merged = execSync(`git branch --merged "${into}"`, {
122
+ cwd: repoRoot,
123
+ encoding: "utf8",
124
+ timeout: GIT_TIMEOUT_MS,
125
+ stdio: ["pipe", "pipe", "pipe"]
126
+ });
127
+ return merged.split("\n").map((l) => l.replace(/^[*+]?\s+/, "").trim()).includes(branch);
128
+ } catch {
129
+ return false;
130
+ }
131
+ }
132
+ function hasLiveTmuxSession(agentName) {
133
+ try {
134
+ const sessions = execSync("tmux list-sessions -F '#S' 2>/dev/null", {
135
+ encoding: "utf8",
136
+ timeout: 5e3,
137
+ stdio: ["pipe", "pipe", "pipe"]
138
+ }).trim();
139
+ if (!sessions) return false;
140
+ for (const session of sessions.split("\n")) {
141
+ const agentPart = session.split("-")[0];
142
+ if (!agentPart) continue;
143
+ const baseName = agentPart.replace(/\d+$/, "");
144
+ if (baseName === agentName || agentPart === agentName) return true;
145
+ }
146
+ return false;
147
+ } catch {
148
+ return false;
149
+ }
150
+ }
151
+ function removeWorktree(repoRoot, wtPath) {
152
+ try {
153
+ execSync(`git worktree remove ${JSON.stringify(wtPath)} --force`, {
154
+ cwd: repoRoot,
155
+ encoding: "utf8",
156
+ timeout: GIT_TIMEOUT_MS,
157
+ stdio: ["pipe", "pipe", "pipe"]
158
+ });
159
+ return true;
160
+ } catch {
161
+ return false;
162
+ }
163
+ }
164
+ function deleteBranch(repoRoot, branch) {
165
+ try {
166
+ execSync(`git branch -D ${JSON.stringify(branch)}`, {
167
+ cwd: repoRoot,
168
+ encoding: "utf8",
169
+ timeout: GIT_TIMEOUT_MS,
170
+ stdio: ["pipe", "pipe", "pipe"]
171
+ });
172
+ return true;
173
+ } catch {
174
+ return false;
175
+ }
176
+ }
177
+ function deleteRemoteBranch(repoRoot, branch) {
178
+ try {
179
+ execSync(`git push origin --delete ${JSON.stringify(branch)}`, {
180
+ cwd: repoRoot,
181
+ encoding: "utf8",
182
+ timeout: 15e3,
183
+ stdio: ["pipe", "pipe", "pipe"]
184
+ });
185
+ return true;
186
+ } catch {
187
+ return false;
188
+ }
189
+ }
190
+ function pruneWorktreeRegistry(repoRoot) {
191
+ try {
192
+ execSync("git worktree prune", {
193
+ cwd: repoRoot,
194
+ encoding: "utf8",
195
+ timeout: GIT_TIMEOUT_MS,
196
+ stdio: ["pipe", "pipe", "pipe"]
197
+ });
198
+ } catch {
199
+ }
200
+ }
201
+ function clearStashes(repoRoot) {
202
+ try {
203
+ const stashList = execSync("git stash list", {
204
+ cwd: repoRoot,
205
+ encoding: "utf8",
206
+ timeout: GIT_TIMEOUT_MS,
207
+ stdio: ["pipe", "pipe", "pipe"]
208
+ }).trim();
209
+ if (!stashList) return 0;
210
+ const count = stashList.split("\n").length;
211
+ execSync("git stash clear", {
212
+ cwd: repoRoot,
213
+ encoding: "utf8",
214
+ timeout: GIT_TIMEOUT_MS,
215
+ stdio: ["pipe", "pipe", "pipe"]
216
+ });
217
+ return count;
218
+ } catch {
219
+ return 0;
220
+ }
221
+ }
222
+ function parseAgentName(wtPath) {
223
+ const dirName = path.basename(wtPath);
224
+ if (!dirName) return null;
225
+ return dirName.replace(/\d+$/, "") || dirName;
226
+ }
227
+ async function sweepWorktrees(options = {}) {
228
+ const dryRun = options.dryRun ?? false;
229
+ const repoPaths = options.repoPaths ?? discoverRepoPaths();
230
+ const result = {
231
+ reposScanned: 0,
232
+ removed: [],
233
+ branchesDeleted: [],
234
+ stashesCleared: 0,
235
+ skipped: [],
236
+ errors: []
237
+ };
238
+ for (const repoPath of repoPaths) {
239
+ const repoRoot = getGitRoot(repoPath);
240
+ if (!repoRoot) continue;
241
+ result.reposScanned++;
242
+ const repoName = path.basename(repoRoot);
243
+ const mainBranch = detectMainBranch(repoRoot);
244
+ if (!dryRun) {
245
+ pruneWorktreeRegistry(repoRoot);
246
+ }
247
+ const worktrees = listWorktrees(repoRoot);
248
+ for (const wt of worktrees) {
249
+ if (!wt.path.includes("/.worktrees/")) continue;
250
+ const agentName = parseAgentName(wt.path);
251
+ const wtName = path.basename(wt.path);
252
+ if (agentName && hasLiveTmuxSession(agentName)) {
253
+ result.skipped.push({
254
+ repo: repoName,
255
+ worktree: wtName,
256
+ branch: wt.branch,
257
+ reason: "live tmux session"
258
+ });
259
+ continue;
260
+ }
261
+ if (existsSync(wt.path) && isWorktreeDirty(wt.path)) {
262
+ result.skipped.push({
263
+ repo: repoName,
264
+ worktree: wtName,
265
+ branch: wt.branch,
266
+ reason: "uncommitted changes"
267
+ });
268
+ continue;
269
+ }
270
+ if (existsSync(wt.path) && isWorktreeUnpushed(wt.path, wt.branch)) {
271
+ result.skipped.push({
272
+ repo: repoName,
273
+ worktree: wtName,
274
+ branch: wt.branch,
275
+ reason: "unpushed commits \u2014 push first or use --force"
276
+ });
277
+ continue;
278
+ }
279
+ const isMerged = mainBranch ? isBranchMerged(repoRoot, wt.branch, mainBranch) : false;
280
+ if (dryRun) {
281
+ result.removed.push({ repo: repoName, worktree: wtName, branch: wt.branch });
282
+ if (isMerged || !mainBranch) {
283
+ result.branchesDeleted.push({ repo: repoName, branch: wt.branch, remote: true });
284
+ } else {
285
+ result.branchesDeleted.push({ repo: repoName, branch: wt.branch, remote: false });
286
+ }
287
+ continue;
288
+ }
289
+ const removed = removeWorktree(repoRoot, wt.path);
290
+ if (!removed) {
291
+ result.errors.push(`${repoName}: failed to remove worktree ${wtName}`);
292
+ continue;
293
+ }
294
+ result.removed.push({ repo: repoName, worktree: wtName, branch: wt.branch });
295
+ process.stderr.write(`[worktree-sweep] Removed ${repoName}/.worktrees/${wtName} (branch: ${wt.branch})
296
+ `);
297
+ const localDeleted = deleteBranch(repoRoot, wt.branch);
298
+ let remoteDeleted = false;
299
+ if (localDeleted) {
300
+ remoteDeleted = deleteRemoteBranch(repoRoot, wt.branch);
301
+ }
302
+ if (localDeleted) {
303
+ result.branchesDeleted.push({ repo: repoName, branch: wt.branch, remote: remoteDeleted });
304
+ }
305
+ }
306
+ if (!dryRun) {
307
+ const cleared = clearStashes(repoRoot);
308
+ if (cleared > 0) {
309
+ result.stashesCleared += cleared;
310
+ process.stderr.write(`[worktree-sweep] Cleared ${cleared} stash(es) in ${repoName}
311
+ `);
312
+ }
313
+ }
314
+ if (!dryRun) {
315
+ pruneWorktreeRegistry(repoRoot);
316
+ }
317
+ }
318
+ return result;
319
+ }
320
+ function cleanupAgentWorktree(repoRoot, agentName) {
321
+ const worktreesDir = path.join(repoRoot, ".worktrees");
322
+ if (!existsSync(worktreesDir)) return "";
323
+ const notes = [];
324
+ try {
325
+ const entries = readdirSync(worktreesDir);
326
+ for (const entry of entries) {
327
+ const baseName = entry.replace(/\d+$/, "") || entry;
328
+ const agentBase = agentName.replace(/\d+$/, "") || agentName;
329
+ if (baseName !== agentBase) continue;
330
+ const wtPath = path.join(worktreesDir, entry);
331
+ const branch = getWorktreeBranch(repoRoot, wtPath);
332
+ if (isWorktreeDirty(wtPath)) {
333
+ notes.push(`Worktree .worktrees/${entry} has uncommitted changes \u2014 preserved`);
334
+ continue;
335
+ }
336
+ if (isWorktreeUnpushed(wtPath, branch)) {
337
+ notes.push(`Worktree .worktrees/${entry} has unpushed commits \u2014 preserved`);
338
+ continue;
339
+ }
340
+ if (removeWorktree(repoRoot, wtPath)) {
341
+ notes.push(`Removed worktree .worktrees/${entry}`);
342
+ if (branch && deleteBranch(repoRoot, branch)) {
343
+ notes.push(`Deleted branch ${branch}`);
344
+ if (deleteRemoteBranch(repoRoot, branch)) {
345
+ notes.push(`Deleted remote branch ${branch}`);
346
+ }
347
+ }
348
+ }
349
+ }
350
+ } catch {
351
+ }
352
+ pruneWorktreeRegistry(repoRoot);
353
+ return notes.join("\n");
354
+ }
355
+ function getWorktreeBranch(repoRoot, wtPath) {
356
+ try {
357
+ const worktrees = listWorktrees(repoRoot);
358
+ for (const wt of worktrees) {
359
+ if (wt.path === wtPath) return wt.branch;
360
+ }
361
+ return null;
362
+ } catch {
363
+ return null;
364
+ }
365
+ }
366
+
367
+ export {
368
+ discoverRepoPaths,
369
+ sweepWorktrees,
370
+ cleanupAgentWorktree
371
+ };