@moberg_hr/work-tree 2.0.13 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/{answer-IL5AQHRO.js → answer-OF2QNF4A.js} +6 -6
  2. package/dist/{attach-MFU4KN47.js → attach-PAFAZ2EH.js} +9 -9
  3. package/dist/bin.js +2 -2
  4. package/dist/{block-OXGEQ2PZ.js → block-3LEG4LKJ.js} +6 -6
  5. package/dist/{broadcast-UJURJNEK.js → broadcast-ZDIL7UBP.js} +3 -3
  6. package/dist/{catchup-HN4VL5XK.js → catchup-ZZ5HZJIT.js} +8 -8
  7. package/dist/{chunk-E35NZVPX.js → chunk-2GX3IOSV.js} +15 -2
  8. package/dist/chunk-2GX3IOSV.js.map +1 -0
  9. package/dist/{chunk-R7B46WXN.js → chunk-3GAYLP7W.js} +4 -4
  10. package/dist/{chunk-OZIR2255.js → chunk-453EGT2R.js} +11 -7
  11. package/dist/chunk-453EGT2R.js.map +1 -0
  12. package/dist/{chunk-RLR66XLG.js → chunk-46VAWZZX.js} +2 -2
  13. package/dist/{chunk-SH7NSDRW.js → chunk-4CVUV2SE.js} +2 -2
  14. package/dist/{chunk-3XY76XBD.js → chunk-62C3CJ5M.js} +2 -2
  15. package/dist/{chunk-MIIJ2HQS.js → chunk-77SVSNME.js} +4 -4
  16. package/dist/{chunk-OQAQMCHF.js → chunk-C7OK4XEZ.js} +58 -9
  17. package/dist/chunk-C7OK4XEZ.js.map +1 -0
  18. package/dist/{chunk-YZLNJQAV.js → chunk-DLSAAP3S.js} +2 -2
  19. package/dist/{chunk-B2RCWZUW.js → chunk-EDAOG56H.js} +35 -7
  20. package/dist/chunk-EDAOG56H.js.map +1 -0
  21. package/dist/{chunk-EU3BS5A6.js → chunk-EXJYPF64.js} +3 -3
  22. package/dist/{chunk-PUYXTZ32.js → chunk-INVFNKU7.js} +4 -4
  23. package/dist/{chunk-KUWFGPGW.js → chunk-ISZM5C22.js} +15 -9
  24. package/dist/chunk-ISZM5C22.js.map +1 -0
  25. package/dist/{chunk-F375JY4M.js → chunk-KSVZVHTI.js} +6 -6
  26. package/dist/{chunk-F375JY4M.js.map → chunk-KSVZVHTI.js.map} +1 -1
  27. package/dist/{chunk-RQE5UOIW.js → chunk-KTFDSJUD.js} +16 -1
  28. package/dist/chunk-KTFDSJUD.js.map +1 -0
  29. package/dist/{chunk-HDO3PXCU.js → chunk-KWU35O5S.js} +3 -3
  30. package/dist/{chunk-U4UB4LG6.js → chunk-LBQR7KTC.js} +2 -2
  31. package/dist/{chunk-YXQIGBL6.js → chunk-LGDECE7V.js} +3 -3
  32. package/dist/{chunk-FX4IA5U4.js → chunk-M4YXBQZN.js} +5 -5
  33. package/dist/{chunk-OOCMPS5L.js → chunk-MRXD2NSO.js} +2 -2
  34. package/dist/{chunk-ZFPV46FA.js → chunk-NBI2INQS.js} +22 -13
  35. package/dist/chunk-NBI2INQS.js.map +1 -0
  36. package/dist/{chunk-BSFL3WDR.js → chunk-OCDHKDUN.js} +45 -45
  37. package/dist/{chunk-MVU7JAKG.js → chunk-OE34YZFO.js} +2 -2
  38. package/dist/{chunk-6O6765M7.js → chunk-OIQY4OKO.js} +2 -2
  39. package/dist/{chunk-M7AUWYOP.js → chunk-R4M5DDSN.js} +4 -4
  40. package/dist/{chunk-YJVZ5H3I.js → chunk-RK6NHIL6.js} +2 -2
  41. package/dist/chunk-THJGDJVO.js +9 -0
  42. package/dist/{chunk-4KNBN2OF.js.map → chunk-THJGDJVO.js.map} +1 -1
  43. package/dist/chunk-TN2TXRHS.js +249 -0
  44. package/dist/chunk-TN2TXRHS.js.map +1 -0
  45. package/dist/{chunk-427RB7E4.js → chunk-TROTIHD5.js} +3 -3
  46. package/dist/{chunk-KSIXTTO6.js → chunk-U4YUMSJY.js} +3 -3
  47. package/dist/{chunk-7JPCVEOY.js → chunk-U5V5J237.js} +6 -6
  48. package/dist/{chunk-PVN5IGDZ.js → chunk-UDOXLAE7.js} +2 -2
  49. package/dist/{chunk-MI3PS2SH.js → chunk-UOSZFFNY.js} +2 -2
  50. package/dist/{chunk-7GQCPGKQ.js → chunk-X6VBITXV.js} +4 -4
  51. package/dist/{chunk-OW46TR4G.js → chunk-XIL4QZFW.js} +3 -3
  52. package/dist/{chunk-QX4LFFNS.js → chunk-ZR2KWY6V.js} +2 -2
  53. package/dist/{chunk-4MXWNDH7.js → chunk-ZVJEWMJN.js} +39 -1
  54. package/dist/chunk-ZVJEWMJN.js.map +1 -0
  55. package/dist/{cleanup-LRT6J36R.js → cleanup-W5RGZ3Q6.js} +17 -15
  56. package/dist/{cleanup-LRT6J36R.js.map → cleanup-W5RGZ3Q6.js.map} +1 -1
  57. package/dist/{cli-VGUJI5WG.js → cli-64TLWGRH.js} +3 -3
  58. package/dist/{config-SSWYCX4C.js → config-MR7UZCST.js} +4 -4
  59. package/dist/{diff-JBCBQM4I.js → diff-URDY6YMT.js} +7 -7
  60. package/dist/{digest-WCZD6N7M.js → digest-D4FEZNLU.js} +6 -6
  61. package/dist/{fork-RJ3ZPPWT.js → fork-7EUVNEB7.js} +15 -15
  62. package/dist/{hook-CA5X3VKU.js → hook-6AD3FRKZ.js} +6 -6
  63. package/dist/{hydrate-Q4FWUQRC.js → hydrate-ZJZPM6YW.js} +3 -3
  64. package/dist/{init-AT3BQLXM.js → init-LWL4WVSJ.js} +4 -4
  65. package/dist/{install-skills-Z76FLXOU.js → install-skills-TQVWZDUD.js} +3 -3
  66. package/dist/install-skills-bin.js +2 -2
  67. package/dist/{move-OLXCDNA3.js → move-URV7XIDT.js} +7 -7
  68. package/dist/{note-JOR53JP4.js → note-S6EGTEIL.js} +5 -5
  69. package/dist/{overlaps-GXSEH2LG.js → overlaps-4T7NLTJH.js} +5 -5
  70. package/dist/{pin-DAWKCVB2.js → pin-KKQZ3AR6.js} +5 -5
  71. package/dist/{pr-RKOVRSHC.js → pr-5ZILTVDM.js} +5 -5
  72. package/dist/{prune-UYCQOEUF.js → prune-OK23KLHG.js} +16 -14
  73. package/dist/{prune-UYCQOEUF.js.map → prune-OK23KLHG.js.map} +1 -1
  74. package/dist/{pty-host-X3QK2LSK.js → pty-host-I5OJGWYA.js} +5 -5
  75. package/dist/{read-IKDSIDJD.js → read-NHK26F22.js} +5 -5
  76. package/dist/{recent-2LM44HN2.js → recent-DNSOJQVQ.js} +4 -4
  77. package/dist/{remove-6XACPXUU.js → remove-TZQVN2EG.js} +15 -13
  78. package/dist/{remove-6XACPXUU.js.map → remove-TZQVN2EG.js.map} +1 -1
  79. package/dist/{restart-6ZAFDRBO.js → restart-WHJDPDQA.js} +6 -6
  80. package/dist/{resume-VA34T7ZR.js → resume-BXIYEZM3.js} +4 -4
  81. package/dist/{run-E2WZPHHK.js → run-4MQLY3XF.js} +3 -3
  82. package/dist/{screen-KUXSDDLB.js → screen-URKN7PU6.js} +6 -6
  83. package/dist/{search-FJUZPI3P.js → search-MNBYJEL7.js} +3 -3
  84. package/dist/{section-QLUIAYAV.js → section-B3OQFADP.js} +5 -5
  85. package/dist/{send-V6LL6YR6.js → send-2QTMQQ6E.js} +7 -7
  86. package/dist/{sessions-MKXREA2M.js → sessions-4B22O45G.js} +12 -12
  87. package/dist/{snooze-JXI7VZJ4.js → snooze-LSCCM3QT.js} +5 -5
  88. package/dist/{start-5XFUYT6I.js → start-KVNLZRF5.js} +6 -6
  89. package/dist/{status-U5HKQ7MY.js → status-UEMXFLZZ.js} +3 -3
  90. package/dist/{stop-PFI7J2CS.js → stop-NEQBEYEY.js} +6 -6
  91. package/dist/{sync-MSU7QJWN.js → sync-BHEY6RXE.js} +16 -14
  92. package/dist/{sync-MSU7QJWN.js.map → sync-BHEY6RXE.js.map} +1 -1
  93. package/dist/{time-VDRCEIYQ.js → time-ON27QFG4.js} +6 -6
  94. package/dist/{timesheet-LSRRWV7Z.js → timesheet-HK5CHAA7.js} +8 -8
  95. package/dist/{tree-MOIO4GQL.js → tree-C5BEEKLO.js} +18 -11
  96. package/dist/tree-C5BEEKLO.js.map +1 -0
  97. package/dist/{update-DXIY6BEX.js → update-M4KS23HB.js} +7 -7
  98. package/dist/{wait-KPH5BQUD.js → wait-5QVWSCOL.js} +6 -6
  99. package/dist/wd-bin.js +2 -2
  100. package/dist/web/assets/{PtyView-D1TEpjVE.js → PtyView-TjC4VYWv.js} +2 -2
  101. package/dist/web/assets/{PtyView-D1TEpjVE.js.map → PtyView-TjC4VYWv.js.map} +1 -1
  102. package/dist/web/assets/index-BPadZeCm.js +119 -0
  103. package/dist/web/assets/index-BPadZeCm.js.map +1 -0
  104. package/dist/web/assets/index-YbJdcXjZ.css +1 -0
  105. package/dist/web/index.html +2 -2
  106. package/dist/{web-6AOR3MIE.js → web-5YGNY6MI.js} +746 -147
  107. package/dist/web-5YGNY6MI.js.map +1 -0
  108. package/npm-shrinkwrap.json +2 -2
  109. package/package.json +1 -1
  110. package/dist/chunk-4KNBN2OF.js +0 -9
  111. package/dist/chunk-4MXWNDH7.js.map +0 -1
  112. package/dist/chunk-B2RCWZUW.js.map +0 -1
  113. package/dist/chunk-E35NZVPX.js.map +0 -1
  114. package/dist/chunk-KUWFGPGW.js.map +0 -1
  115. package/dist/chunk-OQAQMCHF.js.map +0 -1
  116. package/dist/chunk-OZIR2255.js.map +0 -1
  117. package/dist/chunk-RQE5UOIW.js.map +0 -1
  118. package/dist/chunk-ZFPV46FA.js.map +0 -1
  119. package/dist/tree-MOIO4GQL.js.map +0 -1
  120. package/dist/web/assets/index-BVeughC2.css +0 -1
  121. package/dist/web/assets/index-DoMf82kx.js +0 -118
  122. package/dist/web/assets/index-DoMf82kx.js.map +0 -1
  123. package/dist/web-6AOR3MIE.js.map +0 -1
  124. /package/dist/{answer-IL5AQHRO.js.map → answer-OF2QNF4A.js.map} +0 -0
  125. /package/dist/{attach-MFU4KN47.js.map → attach-PAFAZ2EH.js.map} +0 -0
  126. /package/dist/{block-OXGEQ2PZ.js.map → block-3LEG4LKJ.js.map} +0 -0
  127. /package/dist/{broadcast-UJURJNEK.js.map → broadcast-ZDIL7UBP.js.map} +0 -0
  128. /package/dist/{catchup-HN4VL5XK.js.map → catchup-ZZ5HZJIT.js.map} +0 -0
  129. /package/dist/{chunk-R7B46WXN.js.map → chunk-3GAYLP7W.js.map} +0 -0
  130. /package/dist/{chunk-RLR66XLG.js.map → chunk-46VAWZZX.js.map} +0 -0
  131. /package/dist/{chunk-SH7NSDRW.js.map → chunk-4CVUV2SE.js.map} +0 -0
  132. /package/dist/{chunk-3XY76XBD.js.map → chunk-62C3CJ5M.js.map} +0 -0
  133. /package/dist/{chunk-MIIJ2HQS.js.map → chunk-77SVSNME.js.map} +0 -0
  134. /package/dist/{chunk-YZLNJQAV.js.map → chunk-DLSAAP3S.js.map} +0 -0
  135. /package/dist/{chunk-EU3BS5A6.js.map → chunk-EXJYPF64.js.map} +0 -0
  136. /package/dist/{chunk-PUYXTZ32.js.map → chunk-INVFNKU7.js.map} +0 -0
  137. /package/dist/{chunk-HDO3PXCU.js.map → chunk-KWU35O5S.js.map} +0 -0
  138. /package/dist/{chunk-U4UB4LG6.js.map → chunk-LBQR7KTC.js.map} +0 -0
  139. /package/dist/{chunk-YXQIGBL6.js.map → chunk-LGDECE7V.js.map} +0 -0
  140. /package/dist/{chunk-FX4IA5U4.js.map → chunk-M4YXBQZN.js.map} +0 -0
  141. /package/dist/{chunk-OOCMPS5L.js.map → chunk-MRXD2NSO.js.map} +0 -0
  142. /package/dist/{chunk-BSFL3WDR.js.map → chunk-OCDHKDUN.js.map} +0 -0
  143. /package/dist/{chunk-MVU7JAKG.js.map → chunk-OE34YZFO.js.map} +0 -0
  144. /package/dist/{chunk-6O6765M7.js.map → chunk-OIQY4OKO.js.map} +0 -0
  145. /package/dist/{chunk-M7AUWYOP.js.map → chunk-R4M5DDSN.js.map} +0 -0
  146. /package/dist/{chunk-YJVZ5H3I.js.map → chunk-RK6NHIL6.js.map} +0 -0
  147. /package/dist/{chunk-427RB7E4.js.map → chunk-TROTIHD5.js.map} +0 -0
  148. /package/dist/{chunk-KSIXTTO6.js.map → chunk-U4YUMSJY.js.map} +0 -0
  149. /package/dist/{chunk-7JPCVEOY.js.map → chunk-U5V5J237.js.map} +0 -0
  150. /package/dist/{chunk-PVN5IGDZ.js.map → chunk-UDOXLAE7.js.map} +0 -0
  151. /package/dist/{chunk-MI3PS2SH.js.map → chunk-UOSZFFNY.js.map} +0 -0
  152. /package/dist/{chunk-7GQCPGKQ.js.map → chunk-X6VBITXV.js.map} +0 -0
  153. /package/dist/{chunk-OW46TR4G.js.map → chunk-XIL4QZFW.js.map} +0 -0
  154. /package/dist/{chunk-QX4LFFNS.js.map → chunk-ZR2KWY6V.js.map} +0 -0
  155. /package/dist/{cli-VGUJI5WG.js.map → cli-64TLWGRH.js.map} +0 -0
  156. /package/dist/{config-SSWYCX4C.js.map → config-MR7UZCST.js.map} +0 -0
  157. /package/dist/{diff-JBCBQM4I.js.map → diff-URDY6YMT.js.map} +0 -0
  158. /package/dist/{digest-WCZD6N7M.js.map → digest-D4FEZNLU.js.map} +0 -0
  159. /package/dist/{fork-RJ3ZPPWT.js.map → fork-7EUVNEB7.js.map} +0 -0
  160. /package/dist/{hook-CA5X3VKU.js.map → hook-6AD3FRKZ.js.map} +0 -0
  161. /package/dist/{hydrate-Q4FWUQRC.js.map → hydrate-ZJZPM6YW.js.map} +0 -0
  162. /package/dist/{init-AT3BQLXM.js.map → init-LWL4WVSJ.js.map} +0 -0
  163. /package/dist/{install-skills-Z76FLXOU.js.map → install-skills-TQVWZDUD.js.map} +0 -0
  164. /package/dist/{move-OLXCDNA3.js.map → move-URV7XIDT.js.map} +0 -0
  165. /package/dist/{note-JOR53JP4.js.map → note-S6EGTEIL.js.map} +0 -0
  166. /package/dist/{overlaps-GXSEH2LG.js.map → overlaps-4T7NLTJH.js.map} +0 -0
  167. /package/dist/{pin-DAWKCVB2.js.map → pin-KKQZ3AR6.js.map} +0 -0
  168. /package/dist/{pr-RKOVRSHC.js.map → pr-5ZILTVDM.js.map} +0 -0
  169. /package/dist/{pty-host-X3QK2LSK.js.map → pty-host-I5OJGWYA.js.map} +0 -0
  170. /package/dist/{read-IKDSIDJD.js.map → read-NHK26F22.js.map} +0 -0
  171. /package/dist/{recent-2LM44HN2.js.map → recent-DNSOJQVQ.js.map} +0 -0
  172. /package/dist/{restart-6ZAFDRBO.js.map → restart-WHJDPDQA.js.map} +0 -0
  173. /package/dist/{resume-VA34T7ZR.js.map → resume-BXIYEZM3.js.map} +0 -0
  174. /package/dist/{run-E2WZPHHK.js.map → run-4MQLY3XF.js.map} +0 -0
  175. /package/dist/{screen-KUXSDDLB.js.map → screen-URKN7PU6.js.map} +0 -0
  176. /package/dist/{search-FJUZPI3P.js.map → search-MNBYJEL7.js.map} +0 -0
  177. /package/dist/{section-QLUIAYAV.js.map → section-B3OQFADP.js.map} +0 -0
  178. /package/dist/{send-V6LL6YR6.js.map → send-2QTMQQ6E.js.map} +0 -0
  179. /package/dist/{sessions-MKXREA2M.js.map → sessions-4B22O45G.js.map} +0 -0
  180. /package/dist/{snooze-JXI7VZJ4.js.map → snooze-LSCCM3QT.js.map} +0 -0
  181. /package/dist/{start-5XFUYT6I.js.map → start-KVNLZRF5.js.map} +0 -0
  182. /package/dist/{status-U5HKQ7MY.js.map → status-UEMXFLZZ.js.map} +0 -0
  183. /package/dist/{stop-PFI7J2CS.js.map → stop-NEQBEYEY.js.map} +0 -0
  184. /package/dist/{time-VDRCEIYQ.js.map → time-ON27QFG4.js.map} +0 -0
  185. /package/dist/{timesheet-LSRRWV7Z.js.map → timesheet-HK5CHAA7.js.map} +0 -0
  186. /package/dist/{update-DXIY6BEX.js.map → update-M4KS23HB.js.map} +0 -0
  187. /package/dist/{wait-KPH5BQUD.js.map → wait-5QVWSCOL.js.map} +0 -0
@@ -19,7 +19,7 @@ import {
19
19
  serveSpa,
20
20
  sessionBaseForPath,
21
21
  submitReviewSchema
22
- } from "./chunk-B2RCWZUW.js";
22
+ } from "./chunk-EDAOG56H.js";
23
23
  import {
24
24
  announceChange,
25
25
  createArchivedRows,
@@ -33,10 +33,10 @@ import {
33
33
  sessionWire,
34
34
  stageSeenKey,
35
35
  storeHolding
36
- } from "./chunk-OZIR2255.js";
36
+ } from "./chunk-453EGT2R.js";
37
37
  import {
38
38
  createDigestSource
39
- } from "./chunk-PUYXTZ32.js";
39
+ } from "./chunk-INVFNKU7.js";
40
40
  import {
41
41
  agentsBySession,
42
42
  createBuildFoldersJob,
@@ -45,12 +45,12 @@ import {
45
45
  deleteMergedBranches,
46
46
  findMergedBranches,
47
47
  summarizeAgents
48
- } from "./chunk-FX4IA5U4.js";
48
+ } from "./chunk-M4YXBQZN.js";
49
49
  import {
50
50
  DiffStatCache,
51
51
  findOverlaps,
52
52
  wantsDiffStat
53
- } from "./chunk-YJVZ5H3I.js";
53
+ } from "./chunk-RK6NHIL6.js";
54
54
  import {
55
55
  defaultTimeDeps,
56
56
  fetchIssueDetail,
@@ -63,10 +63,10 @@ import {
63
63
  graphProblem,
64
64
  signOutGraph,
65
65
  startDeviceLogin
66
- } from "./chunk-M7AUWYOP.js";
66
+ } from "./chunk-R4M5DDSN.js";
67
67
  import {
68
68
  defaultCleanupDeps
69
- } from "./chunk-F375JY4M.js";
69
+ } from "./chunk-KSVZVHTI.js";
70
70
  import {
71
71
  LATER_TEXT,
72
72
  restartCountsText
@@ -87,7 +87,7 @@ import {
87
87
  removeBlocker,
88
88
  sweepBlocks,
89
89
  unblockedPrompt
90
- } from "./chunk-YZLNJQAV.js";
90
+ } from "./chunk-DLSAAP3S.js";
91
91
  import {
92
92
  jiraWorklogPoster,
93
93
  logWorkDay,
@@ -96,7 +96,7 @@ import {
96
96
  } from "./chunk-LPJEV4R2.js";
97
97
  import {
98
98
  sessionWorkTime
99
- } from "./chunk-YXQIGBL6.js";
99
+ } from "./chunk-LGDECE7V.js";
100
100
  import {
101
101
  sendToSession
102
102
  } from "./chunk-RYNBBSLY.js";
@@ -112,17 +112,22 @@ import {
112
112
  } from "./chunk-WH3SPT3N.js";
113
113
  import {
114
114
  fetchAllPullRequests,
115
+ freeLeftovers,
116
+ leftoversOf,
117
+ lookAtLeftovers,
118
+ openInLeftovers,
115
119
  parsePrRef,
116
120
  resolvePrToStart
117
- } from "./chunk-4MXWNDH7.js";
121
+ } from "./chunk-ZVJEWMJN.js";
118
122
  import {
123
+ editorArgs,
119
124
  openUrl
120
- } from "./chunk-E35NZVPX.js";
125
+ } from "./chunk-2GX3IOSV.js";
121
126
  import {
122
127
  archiveMergedSession,
123
128
  archiveWaiting,
124
129
  defaultArchiveDeps
125
- } from "./chunk-KUWFGPGW.js";
130
+ } from "./chunk-ISZM5C22.js";
126
131
  import {
127
132
  cleanupVerdict,
128
133
  createCleanupJob
@@ -138,16 +143,17 @@ import {
138
143
  rememberSent,
139
144
  saveDraft
140
145
  } from "./chunk-26IZBYVL.js";
146
+ import "./chunk-TN2TXRHS.js";
141
147
  import {
142
148
  defaultForkDeps,
143
149
  forkSession,
144
150
  startSessionWithPrompt
145
- } from "./chunk-7GQCPGKQ.js";
151
+ } from "./chunk-X6VBITXV.js";
146
152
  import {
147
153
  createInChild,
148
154
  createInProcess,
149
155
  oneAtATime
150
- } from "./chunk-OW46TR4G.js";
156
+ } from "./chunk-XIL4QZFW.js";
151
157
  import {
152
158
  resolveWorkBinPath
153
159
  } from "./chunk-AH5TM3NB.js";
@@ -155,7 +161,7 @@ import {
155
161
  teardownWorktree,
156
162
  toBaseSpec,
157
163
  wouldRefuseRemoval
158
- } from "./chunk-ZFPV46FA.js";
164
+ } from "./chunk-NBI2INQS.js";
159
165
  import {
160
166
  isWorktreeFolder
161
167
  } from "./chunk-L6RUHCKB.js";
@@ -183,11 +189,11 @@ import {
183
189
  subscribeSession,
184
190
  syncPtyPool,
185
191
  writeToPty
186
- } from "./chunk-7JPCVEOY.js";
192
+ } from "./chunk-U5V5J237.js";
187
193
  import {
188
194
  dbPtySessions
189
- } from "./chunk-U4UB4LG6.js";
190
- import "./chunk-MI3PS2SH.js";
195
+ } from "./chunk-LBQR7KTC.js";
196
+ import "./chunk-UOSZFFNY.js";
191
197
  import {
192
198
  BehindCache,
193
199
  behindMain,
@@ -203,28 +209,28 @@ import {
203
209
  stackedOn,
204
210
  updateFromBase,
205
211
  updateFromMain
206
- } from "./chunk-HDO3PXCU.js";
212
+ } from "./chunk-KWU35O5S.js";
207
213
  import {
208
214
  sessionStatusView,
209
215
  shownState
210
- } from "./chunk-427RB7E4.js";
216
+ } from "./chunk-TROTIHD5.js";
211
217
  import {
212
218
  askCatchUp,
213
219
  cachedCatchUp,
214
220
  catchUp,
215
221
  catchUpFacts,
216
222
  forgetCatchUp
217
- } from "./chunk-MIIJ2HQS.js";
223
+ } from "./chunk-77SVSNME.js";
218
224
  import {
219
225
  runInternal,
220
226
  summarizeCheckpoint,
221
227
  throttleTrailing
222
- } from "./chunk-R7B46WXN.js";
228
+ } from "./chunk-3GAYLP7W.js";
223
229
  import {
224
230
  computeDiff,
225
231
  computeRangeDiff,
226
232
  parseGitDiff
227
- } from "./chunk-6O6765M7.js";
233
+ } from "./chunk-OIQY4OKO.js";
228
234
  import {
229
235
  applyPlacePatch,
230
236
  applySectionOp,
@@ -239,7 +245,7 @@ import {
239
245
  } from "./chunk-LNHSBM4L.js";
240
246
  import {
241
247
  VERSION
242
- } from "./chunk-4KNBN2OF.js";
248
+ } from "./chunk-THJGDJVO.js";
243
249
  import {
244
250
  resolveProjectTarget
245
251
  } from "./chunk-JTHILJFB.js";
@@ -276,18 +282,18 @@ import {
276
282
  readWebUrl,
277
283
  writeDevWebDiscovery,
278
284
  writeWebDiscovery
279
- } from "./chunk-QX4LFFNS.js";
285
+ } from "./chunk-ZR2KWY6V.js";
280
286
  import {
281
287
  CONTEXT_WARN,
282
288
  describeView,
283
289
  writeAssistantContext
284
- } from "./chunk-3XY76XBD.js";
290
+ } from "./chunk-62C3CJ5M.js";
285
291
  import {
286
292
  NOTE_NUDGE,
287
293
  findSessionForCwd,
288
294
  readPendingForSession,
289
295
  readPendingForWorktree
290
- } from "./chunk-PVN5IGDZ.js";
296
+ } from "./chunk-UDOXLAE7.js";
291
297
  import "./chunk-ZSHWP2VS.js";
292
298
  import {
293
299
  getCommentFileStore
@@ -299,7 +305,7 @@ import {
299
305
  checkTools,
300
306
  saveFolders,
301
307
  setupState
302
- } from "./chunk-RLR66XLG.js";
308
+ } from "./chunk-46VAWZZX.js";
303
309
  import {
304
310
  enrollProblem,
305
311
  groupProblem,
@@ -388,7 +394,7 @@ import {
388
394
  turnInProgress,
389
395
  updateCheckpoint,
390
396
  writeArchiveRecord
391
- } from "./chunk-OQAQMCHF.js";
397
+ } from "./chunk-C7OK4XEZ.js";
392
398
  import {
393
399
  activityRoots,
394
400
  agentOf,
@@ -399,7 +405,7 @@ import {
399
405
  liveAgents,
400
406
  readJsonlSince,
401
407
  recentProcessTable
402
- } from "./chunk-RQE5UOIW.js";
408
+ } from "./chunk-KTFDSJUD.js";
403
409
  import {
404
410
  spawn_default
405
411
  } from "./chunk-RCYI7SRA.js";
@@ -431,7 +437,7 @@ import {
431
437
  import chalk from "chalk";
432
438
 
433
439
  // src/server/web-server.ts
434
- import fs12 from "fs";
440
+ import fs13 from "fs";
435
441
 
436
442
  // src/server/routes/session-control-routes.ts
437
443
  function realDeps(app) {
@@ -815,6 +821,459 @@ function mountNoteRoutes(app, opts) {
815
821
  });
816
822
  }
817
823
 
824
+ // src/core/worktree/code-browse.ts
825
+ import fs from "fs";
826
+ import path from "path";
827
+ var MAX_CODE_FILES = 5e4;
828
+ var MAX_CODE_FILE_BYTES = 2 * 1024 * 1024;
829
+ var LIST_TTL_MS = 3e3;
830
+ function codeRoots(s) {
831
+ return s.paths.map((p) => ({ name: path.basename(p), root: p }));
832
+ }
833
+ function groupRoot(s) {
834
+ if (!s.isGroup || s.paths.length === 0) return null;
835
+ const parents = [...new Set(s.paths.map((p) => path.dirname(p)))];
836
+ return parents.length === 1 ? parents[0] : null;
837
+ }
838
+ var realIo = {
839
+ git: (cwd, args) => runGitAsync(cwd, { args })
840
+ };
841
+ var nul = (out) => out.split("\0").filter(Boolean);
842
+ var fwd = (p) => p.replace(/\\/g, "/");
843
+ var listCache = /* @__PURE__ */ new Map();
844
+ var MAX_LISTS = 12;
845
+ var sets = /* @__PURE__ */ new WeakMap();
846
+ function setOf(files) {
847
+ let set = sets.get(files);
848
+ if (!set) sets.set(files, set = new Set(files));
849
+ return set;
850
+ }
851
+ async function isListed(root, rel, io = realIo, now = Date.now()) {
852
+ const hit = listCache.get(root);
853
+ if (hit && now - hit.at < LIST_TTL_MS) return setOf(await hit.files).has(rel);
854
+ const r = await io.git(root, ["ls-files", "-c", "-o", "--exclude-standard", "-z", "--", `:(literal)${rel}`]);
855
+ return r.status === 0 && nul(r.stdout).some((f) => fwd(f) === rel);
856
+ }
857
+ function listRepoFiles(root, io = realIo, now = Date.now()) {
858
+ const hit = listCache.get(root);
859
+ if (hit && now - hit.at < LIST_TTL_MS) return hit.files;
860
+ const files = io.git(root, ["ls-files", "-t", "-c", "-o", "-d", "--exclude-standard", "-z"]).then((r) => {
861
+ if (r.status !== 0) return [];
862
+ const listed = /* @__PURE__ */ new Set();
863
+ const gone = /* @__PURE__ */ new Set();
864
+ for (const e of nul(r.stdout)) {
865
+ const p = fwd(e.slice(2));
866
+ if (e[0] === "R") gone.add(p);
867
+ else listed.add(p);
868
+ }
869
+ return [...listed].filter((f) => !gone.has(f)).sort();
870
+ });
871
+ listCache.delete(root);
872
+ listCache.set(root, { at: now, files });
873
+ while (listCache.size > MAX_LISTS) listCache.delete(listCache.keys().next().value);
874
+ return files;
875
+ }
876
+ async function changedFiles(root, base, io = realIo) {
877
+ const out = /* @__PURE__ */ new Set();
878
+ const status = await io.git(root, ["status", "--porcelain=v1", "-z", "--untracked-files=all"]);
879
+ if (status.status === 0) {
880
+ const entries = nul(status.stdout);
881
+ for (let i = 0; i < entries.length; i++) {
882
+ const e = entries[i];
883
+ const code = e.slice(0, 2);
884
+ out.add(fwd(e.slice(3)));
885
+ if (code.includes("R") || code.includes("C")) i++;
886
+ }
887
+ }
888
+ let from = null;
889
+ for (const ref of base ? base.startsWith("origin/") ? [base] : [base, `origin/${base}`] : ["origin/HEAD"]) {
890
+ const mb = await io.git(root, ["merge-base", ref, "HEAD"]);
891
+ const sha = mb.stdout.trim();
892
+ if (mb.status !== 0 || !sha || sha === from) continue;
893
+ if (!from || (await io.git(root, ["merge-base", "--is-ancestor", from, sha])).status === 0) from = sha;
894
+ }
895
+ if (!from && base) {
896
+ const mb = await io.git(root, ["merge-base", "origin/HEAD", "HEAD"]);
897
+ if (mb.status === 0 && mb.stdout.trim()) from = mb.stdout.trim();
898
+ }
899
+ if (from) {
900
+ const diff = await io.git(root, ["diff", "--name-only", "-z", `${from}...HEAD`]);
901
+ if (diff.status === 0) for (const f of nul(diff.stdout)) out.add(fwd(f));
902
+ }
903
+ return [...out].sort();
904
+ }
905
+ async function listCodeFiles(s, io = realIo) {
906
+ const repos = await Promise.all(
907
+ codeRoots(s).map(async ({ name, root }) => {
908
+ if (!fs.existsSync(root)) return { name, files: [], changed: [], truncated: false };
909
+ const [all, changed] = await Promise.all([listRepoFiles(root, io), changedFiles(root, s.baseBranches?.[root] ?? s.baseBranch, io)]);
910
+ const listed = new Set(all);
911
+ return {
912
+ name,
913
+ files: all.slice(0, MAX_CODE_FILES),
914
+ changed: changed.filter((f) => listed.has(f)),
915
+ truncated: all.length > MAX_CODE_FILES
916
+ };
917
+ })
918
+ );
919
+ return { group: !!s.isGroup, rootFiles: groupRootFiles(s), repos };
920
+ }
921
+ function groupRootFiles(s) {
922
+ const dir = groupRoot(s);
923
+ if (!dir) return [];
924
+ try {
925
+ return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && isGroupNote(e.name)).map((e) => e.name).sort();
926
+ } catch {
927
+ return [];
928
+ }
929
+ }
930
+ var isGroupNote = (name) => !name.startsWith(".") && /\.md$/i.test(name);
931
+ async function codeFilePath(s, repo, rel, io = realIo) {
932
+ let root;
933
+ let allowed;
934
+ if (repo === "") {
935
+ root = groupRoot(s);
936
+ allowed = !!root && groupRootFiles(s).includes(rel);
937
+ } else {
938
+ root = codeRoots(s).find((r) => r.name === repo)?.root ?? null;
939
+ allowed = !!root && await isListed(root, rel, io);
940
+ }
941
+ if (!root) return { error: "unknown repo" };
942
+ if (!allowed) return { error: "not listed" };
943
+ try {
944
+ const full = path.resolve(root, rel);
945
+ const realRoot = fs.realpathSync.native(root);
946
+ const real = fs.realpathSync.native(full);
947
+ const inside2 = path.relative(realRoot, real);
948
+ if (!inside2 || inside2.startsWith("..") || path.isAbsolute(inside2)) return { error: "not listed" };
949
+ const st = fs.statSync(real);
950
+ if (!st.isFile()) return { error: "unreadable" };
951
+ return { real, size: st.size };
952
+ } catch (err) {
953
+ return { error: err.code === "ENOENT" ? "not listed" : "unreadable" };
954
+ }
955
+ }
956
+ async function readCodeFile(s, repo, rel, io = realIo) {
957
+ const at = await codeFilePath(s, repo, rel, io);
958
+ if ("error" in at) return at;
959
+ if (at.size > MAX_CODE_FILE_BYTES) return { repo, path: rel, size: at.size, text: null, reason: "too-large" };
960
+ try {
961
+ const buf = await fs.promises.readFile(at.real);
962
+ if (buf.subarray(0, 8e3).includes(0)) return { repo, path: rel, size: at.size, text: null, reason: "binary" };
963
+ return { repo, path: rel, size: at.size, text: buf.toString("utf-8") };
964
+ } catch (err) {
965
+ return { error: err.code === "ENOENT" ? "not listed" : "unreadable" };
966
+ }
967
+ }
968
+
969
+ // src/core/worktree/code-symbols.ts
970
+ var MAX_LINE_CHARS = 240;
971
+ function parseGrepLine(line) {
972
+ const z6 = /^([^\0]+)\0(\d+)\0(.*)$/.exec(line);
973
+ if (z6) return { path: z6[1], line: Number(z6[2]), text: z6[3] };
974
+ const m = /^(.+?):(\d+):(.*)$/.exec(line);
975
+ return m ? { path: m[1], line: Number(m[2]), text: m[3] } : null;
976
+ }
977
+ var ignoresCase = (q) => q === q.toLowerCase();
978
+ var MODS = "(?:(?:public|private|protected|internal|static|sealed|abstract|partial|async|override|virtual|readonly|new|extern|unsafe|required|file)\\s+)*";
979
+ var RULES = [
980
+ // C#: types, then methods and properties (a member needs an access modifier, so a call isn't one).
981
+ {
982
+ ext: /\.(cs|cshtml|razor)$/i,
983
+ re: new RegExp(`^\\s*${MODS}(class|record\\s+struct|record|struct|interface|enum)\\s+([A-Za-z_]\\w*)`),
984
+ kind: (m) => m[1].startsWith("record") ? "record" : m[1],
985
+ name: (m) => m[2]
986
+ },
987
+ {
988
+ ext: /\.(cs|cshtml|razor)$/i,
989
+ re: new RegExp(`^\\s*(?:public|private|protected|internal)\\s+${MODS}[\\w<>\\[\\],.?() ]+?\\s+([A-Za-z_]\\w*)\\s*(?:<[^>]*>)?\\s*\\(`),
990
+ kind: () => "method",
991
+ name: (m) => m[1]
992
+ },
993
+ {
994
+ ext: /\.(cs|cshtml|razor)$/i,
995
+ re: new RegExp(`^\\s*(?:public|private|protected|internal)\\s+${MODS}[\\w<>\\[\\],.?]+\\s+([A-Za-z_]\\w*)\\s*(?:\\{|=>)`),
996
+ kind: () => "property",
997
+ name: (m) => m[1]
998
+ },
999
+ // TypeScript / JavaScript.
1000
+ {
1001
+ ext: /\.(ts|tsx|js|jsx|mjs|cjs|mts|cts)$/i,
1002
+ re: /^\s*(?:export\s+)?(?:default\s+)?(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(class|interface|enum|type|function\*?)\s+([A-Za-z_$][\w$]*)/,
1003
+ kind: (m) => m[1].startsWith("function") ? "function" : m[1],
1004
+ name: (m) => m[2]
1005
+ },
1006
+ {
1007
+ ext: /\.(ts|tsx|js|jsx|mjs|cjs|mts|cts)$/i,
1008
+ re: /^\s*export\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/,
1009
+ kind: () => "const",
1010
+ name: (m) => m[1]
1011
+ },
1012
+ // Python (and its stub files): classes, functions and methods, and a module's constants — an UPPER_CASE name
1013
+ // assigned at the start of a line (`MAX_RETRIES = 3`, `TIMEOUT: int = 30`), not a comparison.
1014
+ {
1015
+ ext: /\.pyi?$/i,
1016
+ re: /^\s*(?:async\s+)?(def|class)\s+([A-Za-z_]\w*)/,
1017
+ kind: (m) => m[1] === "class" ? "class" : "function",
1018
+ name: (m) => m[2]
1019
+ },
1020
+ {
1021
+ ext: /\.pyi?$/i,
1022
+ re: /^([A-Z][A-Z0-9_]*)\s*(?::[^=]+)?=(?!=)/,
1023
+ kind: () => "const",
1024
+ name: (m) => m[1]
1025
+ }
1026
+ ];
1027
+ var NOT_NAMES = /* @__PURE__ */ new Set([
1028
+ "if",
1029
+ "for",
1030
+ "foreach",
1031
+ "while",
1032
+ "switch",
1033
+ "catch",
1034
+ "using",
1035
+ "lock",
1036
+ "return",
1037
+ "new",
1038
+ "nameof",
1039
+ "typeof",
1040
+ "await"
1041
+ ]);
1042
+ function declarationOf(path17, text) {
1043
+ for (const r of RULES) {
1044
+ if (!r.ext.test(path17)) continue;
1045
+ const m = r.re.exec(text);
1046
+ if (!m) continue;
1047
+ const name = r.name(m);
1048
+ if (NOT_NAMES.has(name)) continue;
1049
+ return { name, kind: r.kind(m) };
1050
+ }
1051
+ return null;
1052
+ }
1053
+ function nameParts(name) {
1054
+ return name.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g) ?? [];
1055
+ }
1056
+ function startsOfParts(parts, query) {
1057
+ const ps = parts.map((p) => p.toLowerCase());
1058
+ const q = query.toLowerCase();
1059
+ const memo = /* @__PURE__ */ new Map();
1060
+ const from = (qi, pi) => {
1061
+ if (qi === q.length) return true;
1062
+ const key = `${qi}:${pi}`;
1063
+ const known = memo.get(key);
1064
+ if (known !== void 0) return known;
1065
+ let ok = false;
1066
+ for (let p = pi; p < ps.length && !ok; p++) {
1067
+ const part = ps[p];
1068
+ for (let k = Math.min(part.length, q.length - qi); k >= 1 && !ok; k--) {
1069
+ if (part.startsWith(q.slice(qi, qi + k))) ok = from(qi + k, p + 1);
1070
+ }
1071
+ }
1072
+ memo.set(key, ok);
1073
+ return ok;
1074
+ };
1075
+ return ps.length > 0 && ps.length <= 16 && from(0, 0);
1076
+ }
1077
+ function scoreOf(lower, parts, q) {
1078
+ if (!q) return null;
1079
+ if (lower === q) return 0;
1080
+ if (lower.startsWith(q)) return 1;
1081
+ if (parts.some((p) => p.startsWith(q))) return 2;
1082
+ if (lower.includes(q)) return 3;
1083
+ if (!parts.some((p) => p[0] === q[0])) return null;
1084
+ return startsOfParts(parts, q) ? 4 : null;
1085
+ }
1086
+ function prepareSymbols(symbols) {
1087
+ return symbols.map((s) => ({ s, lower: s.name.toLowerCase(), parts: nameParts(s.name).map((p) => p.toLowerCase()) }));
1088
+ }
1089
+ var KIND_ORDER = {
1090
+ class: 0,
1091
+ interface: 0,
1092
+ record: 0,
1093
+ struct: 0,
1094
+ enum: 0,
1095
+ type: 0,
1096
+ function: 1,
1097
+ method: 1,
1098
+ property: 2,
1099
+ const: 2
1100
+ };
1101
+ function matchSymbols(symbols, query, limit = 50) {
1102
+ const q = query.trim().toLowerCase();
1103
+ if (!q) return [];
1104
+ const prepared = symbols.length && "lower" in symbols[0] ? symbols : prepareSymbols(symbols);
1105
+ const byName = /* @__PURE__ */ new Map();
1106
+ const scored = [];
1107
+ for (const p of prepared) {
1108
+ let score = byName.get(p.s.name);
1109
+ if (score === void 0) byName.set(p.s.name, score = scoreOf(p.lower, p.parts, q));
1110
+ if (score !== null) scored.push({ s: p.s, score });
1111
+ }
1112
+ scored.sort(
1113
+ (a, b) => a.score - b.score || KIND_ORDER[a.s.kind] - KIND_ORDER[b.s.kind] || a.s.name.length - b.s.name.length || a.s.path.localeCompare(b.s.path) || a.s.line - b.s.line
1114
+ );
1115
+ return scored.slice(0, limit).map((x) => x.s);
1116
+ }
1117
+
1118
+ // src/core/worktree/code-search.ts
1119
+ var MAX_TEXT_HITS = 300;
1120
+ var INDEX_STALE_MS = 6e4;
1121
+ function gitLines(cwd, args, onLine, signal) {
1122
+ if (signal?.aborted) return Promise.resolve({ status: null, stopped: true });
1123
+ return new Promise((resolve) => {
1124
+ let stopped = false;
1125
+ let child;
1126
+ try {
1127
+ child = spawn_default("git", args, { cwd, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] });
1128
+ } catch {
1129
+ resolve({ status: null, stopped: false });
1130
+ return;
1131
+ }
1132
+ const stop = () => {
1133
+ stopped = true;
1134
+ child.kill();
1135
+ };
1136
+ signal?.addEventListener("abort", stop, { once: true });
1137
+ let rest = "";
1138
+ child.stdout?.setEncoding("utf-8");
1139
+ child.stdout?.on("data", (d) => {
1140
+ if (stopped) return;
1141
+ const parts = (rest + d).split("\n");
1142
+ rest = parts.pop() ?? "";
1143
+ for (const line of parts) {
1144
+ if (onLine(line.replace(/\r$/, "")) === false) {
1145
+ stop();
1146
+ return;
1147
+ }
1148
+ }
1149
+ });
1150
+ child.on("error", () => resolve({ status: null, stopped }));
1151
+ child.on("close", (code) => {
1152
+ signal?.removeEventListener("abort", stop);
1153
+ if (!stopped && rest) onLine(rest.replace(/\r$/, ""));
1154
+ resolve({ status: code, stopped });
1155
+ });
1156
+ });
1157
+ }
1158
+ async function searchText(s, query, signal) {
1159
+ const perRepo = await Promise.all(
1160
+ codeRoots(s).map(async ({ name, root }) => {
1161
+ const found = [];
1162
+ let more = false;
1163
+ const args = [
1164
+ "grep",
1165
+ "-z",
1166
+ "-n",
1167
+ "-I",
1168
+ "--untracked",
1169
+ "--no-color",
1170
+ "--full-name",
1171
+ ...ignoresCase(query) ? ["-i"] : [],
1172
+ "-F",
1173
+ "-e",
1174
+ query
1175
+ ];
1176
+ await gitLines(
1177
+ root,
1178
+ args,
1179
+ (line) => {
1180
+ const p = parseGrepLine(line);
1181
+ if (!p) return;
1182
+ if (found.length >= MAX_TEXT_HITS) {
1183
+ more = true;
1184
+ return false;
1185
+ }
1186
+ found.push({
1187
+ repo: name,
1188
+ path: p.path,
1189
+ line: p.line,
1190
+ text: p.text.length > MAX_LINE_CHARS ? p.text.slice(0, MAX_LINE_CHARS) + "\u2026" : p.text
1191
+ });
1192
+ },
1193
+ signal
1194
+ );
1195
+ return { found, more };
1196
+ })
1197
+ );
1198
+ const all = perRepo.flatMap((r) => r.found);
1199
+ const hits = all.slice(0, MAX_TEXT_HITS);
1200
+ const truncated = perRepo.some((r) => r.more) || all.length > MAX_TEXT_HITS;
1201
+ return { hits, truncated };
1202
+ }
1203
+ var SCAN = "(class|record|struct|interface|enum|function|def|public|private|protected|internal|export)[[:space:]]|^[[:space:]]*type[[:space:]]|^[A-Z][A-Z0-9_]*[[:space:]]*[:=]";
1204
+ var SCAN_FILES = ["*.cs", "*.cshtml", "*.razor", "*.ts", "*.tsx", "*.js", "*.jsx", "*.mjs", "*.cjs", "*.mts", "*.cts", "*.py", "*.pyi"];
1205
+ async function buildSymbolIndex(repo, root) {
1206
+ const out = [];
1207
+ await gitLines(
1208
+ root,
1209
+ ["grep", "-z", "-n", "-I", "--untracked", "--no-color", "--full-name", "-E", "-e", SCAN, "--", ...SCAN_FILES],
1210
+ (line) => {
1211
+ const p = parseGrepLine(line);
1212
+ if (!p) return;
1213
+ const d = declarationOf(p.path, p.text);
1214
+ if (d) out.push({ name: d.name, kind: d.kind, repo, path: p.path, line: p.line, text: p.text.trim().slice(0, MAX_LINE_CHARS) });
1215
+ }
1216
+ );
1217
+ return out;
1218
+ }
1219
+ var indexes = /* @__PURE__ */ new Map();
1220
+ var MAX_INDEXES = 6;
1221
+ function touch(cache, root, value, max) {
1222
+ cache.delete(root);
1223
+ cache.set(root, value);
1224
+ while (cache.size > max) cache.delete(cache.keys().next().value);
1225
+ }
1226
+ function symbolIndex(repo, root, now = Date.now(), build = buildSymbolIndex) {
1227
+ const hit = indexes.get(root);
1228
+ if (!hit) {
1229
+ const symbols = build(repo, root).then(prepareSymbols);
1230
+ touch(indexes, root, { at: now, symbols, building: false }, MAX_INDEXES);
1231
+ symbols.catch(() => indexes.delete(root));
1232
+ return symbols;
1233
+ }
1234
+ touch(indexes, root, hit, MAX_INDEXES);
1235
+ if (now - hit.at > INDEX_STALE_MS && !hit.building) {
1236
+ hit.building = true;
1237
+ void build(repo, root).then(
1238
+ (fresh) => indexes.has(root) && touch(indexes, root, { at: Date.now(), symbols: Promise.resolve(prepareSymbols(fresh)), building: false }, MAX_INDEXES),
1239
+ () => void (hit.building = false)
1240
+ );
1241
+ }
1242
+ return hit.symbols;
1243
+ }
1244
+ async function searchSymbols(s, query) {
1245
+ const all = await Promise.all(codeRoots(s).map(({ name, root }) => symbolIndex(name, root).catch(() => [])));
1246
+ return matchSymbols(all.flat(), query);
1247
+ }
1248
+
1249
+ // src/server/routes/code-routes.ts
1250
+ var MIN_SEARCH_CHARS = 2;
1251
+ function mountCodeRoutes(app) {
1252
+ app.get("/api/sessions/:id/files", async (c) => {
1253
+ const session = findSession2(c.req.param("id"));
1254
+ if (!session) return c.json({ error: "unknown session" }, 404);
1255
+ return c.json(await listCodeFiles(session));
1256
+ });
1257
+ app.get("/api/sessions/:id/file", async (c) => {
1258
+ const session = findSession2(c.req.param("id"));
1259
+ if (!session) return c.json({ error: "unknown session" }, 404);
1260
+ const repo = c.req.query("repo") ?? "";
1261
+ const rel = c.req.query("path") ?? "";
1262
+ if (!rel) return c.json({ error: "path required" }, 400);
1263
+ const r = await readCodeFile(session, repo, rel);
1264
+ if ("error" in r) return c.json({ error: r.error }, r.error === "unreadable" ? 500 : 404);
1265
+ return c.json(r);
1266
+ });
1267
+ app.get("/api/sessions/:id/code-search", async (c) => {
1268
+ const session = findSession2(c.req.param("id"));
1269
+ if (!session) return c.json({ error: "unknown session" }, 404);
1270
+ const q = (c.req.query("q") ?? "").trim();
1271
+ if (q.length < MIN_SEARCH_CHARS) return c.json({ query: q, symbols: [], text: [], truncated: false });
1272
+ const [symbols, text] = await Promise.all([searchSymbols(session, q), searchText(session, q, c.req.raw.signal)]);
1273
+ return c.json({ query: q, symbols, text: text.hits, truncated: text.truncated });
1274
+ });
1275
+ }
1276
+
818
1277
  // src/core/diff/diff-looks.ts
819
1278
  var LOOK_JOIN_MS = 15 * 6e4;
820
1279
  var MAX_LOOKS = 20;
@@ -939,8 +1398,8 @@ function mountSetupRoutes(app, opts) {
939
1398
  }
940
1399
 
941
1400
  // src/core/updates/update-source.ts
942
- import fs from "fs";
943
- import path from "path";
1401
+ import fs2 from "fs";
1402
+ import path2 from "path";
944
1403
 
945
1404
  // src/core/updates/updates.ts
946
1405
  function parseVersion(v) {
@@ -1025,8 +1484,8 @@ function parseDesktopUpdate(text) {
1025
1484
  var RELEASES_REPO = "moberghr/cli-work-tree-manager";
1026
1485
  var RELEASES_URL = `https://api.github.com/repos/${RELEASES_REPO}/releases?per_page=30`;
1027
1486
  var SEEN_KEY = "ui:seen-version";
1028
- var desktopUpdatePath = () => path.join(getConfigDir(), "desktop-update.json");
1029
- var desktopRequestPath = () => path.join(getConfigDir(), "desktop-request.json");
1487
+ var desktopUpdatePath = () => path2.join(getConfigDir(), "desktop-update.json");
1488
+ var desktopRequestPath = () => path2.join(getConfigDir(), "desktop-request.json");
1030
1489
  async function fetchReleases(get = (url) => fetch(url, { headers: { "User-Agent": "work", Accept: "application/vnd.github+json" }, signal: AbortSignal.timeout(15e3) }), run = defaultRunner) {
1031
1490
  const why = await get(RELEASES_URL).then(
1032
1491
  async (res) => res.ok ? parseReleases(await res.json()) : res.status === 403 ? "GitHub's limit for this address is spent" : `GitHub answered ${res.status}`,
@@ -1045,7 +1504,7 @@ async function fetchReleases(get = (url) => fetch(url, { headers: { "User-Agent"
1045
1504
  function readDesktopUpdate(file = desktopUpdatePath()) {
1046
1505
  let text;
1047
1506
  try {
1048
- text = fs.readFileSync(file, "utf-8");
1507
+ text = fs2.readFileSync(file, "utf-8");
1049
1508
  } catch {
1050
1509
  return null;
1051
1510
  }
@@ -1067,7 +1526,7 @@ function markSeenVersion(version) {
1067
1526
  }
1068
1527
  function installKind() {
1069
1528
  const root = packageRoot();
1070
- return installKindOf(root, getConfigDir(), !!root && fs.existsSync(path.join(root, ".git")));
1529
+ return installKindOf(root, getConfigDir(), !!root && fs2.existsSync(path2.join(root, ".git")));
1071
1530
  }
1072
1531
  var defaultDeps = () => ({
1073
1532
  fetchReleases: () => fetchReleases(),
@@ -1238,7 +1697,7 @@ function mountRepoRoutes(app, opts) {
1238
1697
  }
1239
1698
 
1240
1699
  // src/core/conversations/timeline-source.ts
1241
- import path2 from "path";
1700
+ import path3 from "path";
1242
1701
 
1243
1702
  // src/core/conversations/timeline.ts
1244
1703
  var SIZE_LABEL = /^(\d+ files? · \+\d+ −\d+|no changes)$/;
@@ -1287,7 +1746,7 @@ async function commitsOf(repo, since, run) {
1287
1746
  if (log.code !== 0) return [];
1288
1747
  return log.stdout.split("\n").filter(Boolean).map((line) => {
1289
1748
  const [sha, at, ...subject] = line.split(" ");
1290
- return { repo: path2.basename(repo), sha, at, subject: subject.join(" ") };
1749
+ return { repo: path3.basename(repo), sha, at, subject: subject.join(" ") };
1291
1750
  });
1292
1751
  }
1293
1752
  async function sessionTimeline(s, deps = {}) {
@@ -1355,8 +1814,8 @@ function mountBlockRoutes(app, opts) {
1355
1814
  }
1356
1815
 
1357
1816
  // src/server/routes/jira-watch-routes.ts
1358
- import fs2 from "fs";
1359
- import path3 from "path";
1817
+ import fs3 from "fs";
1818
+ import path4 from "path";
1360
1819
 
1361
1820
  // src/core/jira/jira-prompt.ts
1362
1821
  var branchFor = (issue) => `feat/${issue.key}`;
@@ -1577,16 +2036,16 @@ async function sweepJira(deps) {
1577
2036
  var EVERY_MS = 5 * 6e4;
1578
2037
  function aboutRepo(dir) {
1579
2038
  try {
1580
- const readme = ["README.md", "readme.md", "README"].map((n) => path3.join(dir, n)).find((f) => fs2.existsSync(f));
2039
+ const readme = ["README.md", "readme.md", "README"].map((n) => path4.join(dir, n)).find((f) => fs3.existsSync(f));
1581
2040
  if (readme) {
1582
- const line = fs2.readFileSync(readme, "utf8").split(/\r?\n/).map(
2041
+ const line = fs3.readFileSync(readme, "utf8").split(/\r?\n/).map(
1583
2042
  (l) => l.replace(/^[#>*\-\s]+/, "").replace(/[`*_[\]]/g, "").trim()
1584
2043
  ).find((l) => l.length > 20 && !/^(!|<|http)/.test(l));
1585
2044
  if (line) return line.slice(0, 160);
1586
2045
  }
1587
- const pkg = path3.join(dir, "package.json");
1588
- if (fs2.existsSync(pkg)) {
1589
- const d = JSON.parse(fs2.readFileSync(pkg, "utf8")).description;
2046
+ const pkg = path4.join(dir, "package.json");
2047
+ if (fs3.existsSync(pkg)) {
2048
+ const d = JSON.parse(fs3.readFileSync(pkg, "utf8")).description;
1590
2049
  if (typeof d === "string" && d.trim()) return d.trim().slice(0, 160);
1591
2050
  }
1592
2051
  } catch {
@@ -1598,7 +2057,7 @@ function watchTargets(cfg = loadConfig()) {
1598
2057
  const repos = Object.entries(cfg.repos).map(([alias, dir]) => ({
1599
2058
  name: alias,
1600
2059
  kind: "repo",
1601
- members: [path3.basename(dir)],
2060
+ members: [path4.basename(dir)],
1602
2061
  about: aboutRepo(dir)
1603
2062
  }));
1604
2063
  const groups = Object.entries(cfg.groups).map(([name, aliases]) => ({ name, kind: "group", members: aliases }));
@@ -1772,7 +2231,7 @@ function describeStall(s) {
1772
2231
  }
1773
2232
 
1774
2233
  // src/server/web-server.ts
1775
- import path14 from "path";
2234
+ import path15 from "path";
1776
2235
  import { Hono } from "hono";
1777
2236
  import { streamSSE as streamSSE2 } from "hono/streaming";
1778
2237
 
@@ -2074,8 +2533,8 @@ function mountPanesRoutes(app, opts) {
2074
2533
  }
2075
2534
 
2076
2535
  // src/server/routes/worktree-routes.ts
2077
- import fs3 from "fs";
2078
- import path4 from "path";
2536
+ import fs4 from "fs";
2537
+ import path5 from "path";
2079
2538
  import { spawn } from "child_process";
2080
2539
  import crossSpawn2 from "cross-spawn";
2081
2540
  import { zValidator as zValidator4 } from "@hono/zod-validator";
@@ -2170,7 +2629,7 @@ function mountWorktreeRoutes(app, opts) {
2170
2629
  if (waiting.length) return { body: { error: `Not deleted: ${waiting.join("; ")}.`, blocked: waiting }, status: 409 };
2171
2630
  }
2172
2631
  try {
2173
- const onDisk = session.paths.some((p) => fs3.existsSync(p));
2632
+ const onDisk = session.paths.some((p) => fs4.existsSync(p));
2174
2633
  if (!sessionOnly && onDisk && session.paths.some((p) => wouldRefuseRemoval(p, force ?? false))) {
2175
2634
  return { body: { error: REFUSED }, status: 409 };
2176
2635
  }
@@ -2228,15 +2687,31 @@ function mountWorktreeRoutes(app, opts) {
2228
2687
  opts.broadcast("sessions-changed", { ts: Date.now() });
2229
2688
  return c.json({ results });
2230
2689
  });
2690
+ const openFileSchema = z3.object({
2691
+ repo: z3.string().max(200),
2692
+ path: z3.string().min(1).max(4096),
2693
+ line: z3.number().int().positive().max(1e7).optional()
2694
+ });
2231
2695
  app.post("/api/sessions/:id/open-editor", async (c) => {
2232
2696
  const id = c.req.param("id");
2233
2697
  const session = findSession2(id);
2234
2698
  if (!session) return c.json({ error: "unknown session" }, 404);
2235
- const target = session.isGroup ? path4.dirname(session.paths[0]) : session.paths[0];
2699
+ const body = await c.req.json().catch(() => ({}));
2700
+ const wantsFile = !!body && typeof body === "object" && "path" in body;
2701
+ const asked = wantsFile ? openFileSchema.safeParse(body) : null;
2702
+ if (asked && !asked.success) return c.json({ error: "repo and path required" }, 400);
2703
+ const folder = session.isGroup ? path5.dirname(session.paths[0]) : session.paths[0];
2704
+ let file;
2705
+ if (asked?.success) {
2706
+ const at = await codeFilePath(session, asked.data.repo, asked.data.path);
2707
+ if ("error" in at) return c.json({ error: at.error }, at.error === "unreadable" ? 500 : 404);
2708
+ file = { path: at.real, line: asked.data.line };
2709
+ }
2710
+ const target = file?.path ?? folder;
2236
2711
  const editor = loadConfig()?.editor?.trim() || "code";
2237
2712
  const failed = await new Promise((resolve) => {
2238
2713
  try {
2239
- const child = crossSpawn2(editor, [target], { detached: true, stdio: "ignore", windowsHide: true });
2714
+ const child = crossSpawn2(editor, editorArgs(editor, folder, file), { detached: true, stdio: "ignore", windowsHide: true });
2240
2715
  const settle = setTimeout(() => resolve(null), 1500);
2241
2716
  child.once("error", (err) => {
2242
2717
  clearTimeout(settle);
@@ -2286,7 +2761,7 @@ function mountWorktreeRoutes(app, opts) {
2286
2761
  import { zValidator as zValidator5 } from "@hono/zod-validator";
2287
2762
  import { z as z4 } from "zod";
2288
2763
  import { EventEmitter } from "events";
2289
- import path5 from "path";
2764
+ import path6 from "path";
2290
2765
  import { streamSSE } from "hono/streaming";
2291
2766
  function mountScopeRoutes(app, opts) {
2292
2767
  const checkpointWatched = /* @__PURE__ */ new Set();
@@ -2526,7 +3001,7 @@ function mountScopeRoutes(app, opts) {
2526
3001
  const fromSha = fromEntry.repos[p] ?? "HEAD";
2527
3002
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
2528
3003
  return {
2529
- name: path5.basename(p),
3004
+ name: path6.basename(p),
2530
3005
  root: p,
2531
3006
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
2532
3007
  };
@@ -2543,7 +3018,7 @@ function mountScopeRoutes(app, opts) {
2543
3018
  }
2544
3019
  const resolved = scope.paths.map((p) => resolveRepoDiff(p, base, sessionBaseForPath(p)));
2545
3020
  const repos = scope.paths.map((p, i) => ({
2546
- name: path5.basename(p),
3021
+ name: path6.basename(p),
2547
3022
  root: p,
2548
3023
  resolvedBase: resolved[i].resolvedBase,
2549
3024
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -2574,7 +3049,7 @@ function mountScopeRoutes(app, opts) {
2574
3049
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
2575
3050
  return c.json({ error: "bad path/start/end" }, 400);
2576
3051
  }
2577
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path5.basename(p) === repoName);
3052
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path6.basename(p) === repoName);
2578
3053
  if (!root) return c.json({ error: "unknown repo" }, 404);
2579
3054
  const result = readContextLines({ root, relPath, start, end, ref });
2580
3055
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -2757,7 +3232,7 @@ function mountTerminalRoutes(app) {
2757
3232
  }
2758
3233
 
2759
3234
  // src/server/routes/status-routes.ts
2760
- import path6 from "path";
3235
+ import path7 from "path";
2761
3236
 
2762
3237
  // src/core/pr/pr-watch-store.ts
2763
3238
  function createSeenStores() {
@@ -2913,7 +3388,7 @@ function mountStatusRoutes(app, opts) {
2913
3388
  const kind = notifyKindForTransition(status.prevState ? { state: status.prevState } : null, status);
2914
3389
  if (kind) {
2915
3390
  const config = loadConfig();
2916
- const launchDir = session.isGroup && session.paths[0] ? path6.dirname(session.paths[0]) : session.paths[0] ?? body.cwd;
3391
+ const launchDir = session.isGroup && session.paths[0] ? path7.dirname(session.paths[0]) : session.paths[0] ?? body.cwd;
2917
3392
  const name = `${session.target} \xB7 ${session.branch}`;
2918
3393
  const snooze = readSnooze(id);
2919
3394
  const route = snooze?.until && snoozeActive(snooze, { attention: status }) ? "none" : presence.route(id);
@@ -3013,19 +3488,41 @@ function mountStatusRoutes(app, opts) {
3013
3488
  var ACTIONS = /* @__PURE__ */ new Set(["push", "create-pr", "merge"]);
3014
3489
  var METHODS = /* @__PURE__ */ new Set(["squash", "merge", "rebase"]);
3015
3490
  function mountShipRoutes(app, opts) {
3016
- const archive = async (id, archived, force = false, merged = false) => {
3491
+ const archive = async (id, archived, force = false, merged = false, stopHolders = false) => {
3017
3492
  const session = findSession2(id);
3018
3493
  if (!session) return { ok: false };
3019
3494
  let ok;
3020
3495
  if (archived) {
3021
- const out = await archiveSession(session, defaultArchiveDeps({ release: opts.release }), { force, merged });
3496
+ const out = await archiveSession(session, defaultArchiveDeps({ release: opts.release }), {
3497
+ force,
3498
+ merged,
3499
+ by: merged ? "shipped" : "you"
3500
+ });
3022
3501
  if (out.blocked) return { ok: false, blocked: out.blocked, message: out.message };
3023
3502
  ok = out.ok;
3024
3503
  } else if (session.paths.some((p) => !isWorktreeFolder(p))) {
3025
3504
  const config = loadConfig();
3026
3505
  if (!config) return { ok: false, error: "no config" };
3506
+ const io = { holders: opts.holders, stop: opts.stopHolders };
3507
+ const leftovers = leftoversOf(session.paths);
3508
+ let stopped = [];
3509
+ let looked = null;
3510
+ if (stopHolders) stopped = await freeLeftovers(leftovers, io);
3511
+ else {
3512
+ looked = await lookAtLeftovers(leftovers, io);
3513
+ const running = looked?.running ?? [];
3514
+ if (running.length) {
3515
+ return { ok: false, holders: running, error: `Couldn't restore it: still running from its old folder: ${running.join(", ")}` };
3516
+ }
3517
+ }
3027
3518
  const made = await (opts.create ?? createInProcess)({ target: session.target, branch: session.branch }, config);
3028
- if (!made.ok) return { ok: false, error: `Couldn't restore it: ${made.error}` };
3519
+ if (!made.ok) {
3520
+ const open = looked && !stopped.length ? looked.open : await openInLeftovers(leftovers, io);
3521
+ return {
3522
+ ok: false,
3523
+ error: `Couldn't restore it: ${made.error}${open.length ? ` (open there: ${open.join(", ")})` : ""}${stopped.length ? ` (stopped first: ${stopped.join(", ")})` : ""}`
3524
+ };
3525
+ }
3029
3526
  ok = true;
3030
3527
  } else {
3031
3528
  restoreArchivedTranscripts(session);
@@ -3083,8 +3580,9 @@ function mountShipRoutes(app, opts) {
3083
3580
  app.post("/api/sessions/:id/archive", async (c) => {
3084
3581
  const body = await c.req.json().catch(() => ({}));
3085
3582
  if (typeof body.archived !== "boolean") return c.json({ error: "archived (boolean) required" }, 400);
3086
- const r = await archive(c.req.param("id"), body.archived, body.force === true);
3583
+ const r = await archive(c.req.param("id"), body.archived, body.force === true, false, body.stopHolders === true);
3087
3584
  if (r.blocked) return c.json({ error: r.message, blocked: r.blocked }, 409);
3585
+ if (r.holders) return c.json({ error: r.error, holders: r.holders }, 409);
3088
3586
  if (r.error) return c.json({ error: r.error }, 500);
3089
3587
  return r.ok ? c.json({ ok: true }) : c.json({ error: "unknown session" }, 404);
3090
3588
  });
@@ -3180,9 +3678,9 @@ function mountRailRoutes(app, opts) {
3180
3678
  }
3181
3679
 
3182
3680
  // src/core/worktree/shared-folders.ts
3183
- import fs4 from "fs";
3184
- import path7 from "path";
3185
- var norm = (p) => path7.resolve(p).replace(/\\/g, "/").toLowerCase();
3681
+ import fs5 from "fs";
3682
+ import path8 from "path";
3683
+ var norm = (p) => path8.resolve(p).replace(/\\/g, "/").toLowerCase();
3186
3684
  function shadowedSessions(sessions, branchCheckedOut2) {
3187
3685
  const byFolder = /* @__PURE__ */ new Map();
3188
3686
  for (const s of sessions) {
@@ -3201,14 +3699,14 @@ function shadowedSessions(sessions, branchCheckedOut2) {
3201
3699
  }
3202
3700
  function branchCheckedOut(dir) {
3203
3701
  try {
3204
- const dotGit = path7.join(dir, ".git");
3702
+ const dotGit = path8.join(dir, ".git");
3205
3703
  let gitDir = dotGit;
3206
- if (fs4.statSync(dotGit).isFile()) {
3207
- const m = /^gitdir:\s*(.+)$/m.exec(fs4.readFileSync(dotGit, "utf8"));
3704
+ if (fs5.statSync(dotGit).isFile()) {
3705
+ const m = /^gitdir:\s*(.+)$/m.exec(fs5.readFileSync(dotGit, "utf8"));
3208
3706
  if (!m) return null;
3209
- gitDir = path7.resolve(dir, m[1].trim());
3707
+ gitDir = path8.resolve(dir, m[1].trim());
3210
3708
  }
3211
- const head = fs4.readFileSync(path7.join(gitDir, "HEAD"), "utf8");
3709
+ const head = fs5.readFileSync(path8.join(gitDir, "HEAD"), "utf8");
3212
3710
  const ref = /^ref:\s*refs\/heads\/(.+)$/m.exec(head);
3213
3711
  return ref ? ref[1].trim() : null;
3214
3712
  } catch {
@@ -3217,14 +3715,14 @@ function branchCheckedOut(dir) {
3217
3715
  }
3218
3716
 
3219
3717
  // src/core/platform/build-stamp.ts
3220
- import fs5 from "fs";
3718
+ import fs6 from "fs";
3221
3719
  var cached = null;
3222
3720
  function buildStamp() {
3223
3721
  if (cached) return cached;
3224
3722
  const forced = process.env.WORK_BUILD_STAMP;
3225
3723
  if (forced) return cached = forced;
3226
3724
  try {
3227
- cached = String(Math.floor(fs5.statSync(process.argv[1]).mtimeMs));
3725
+ cached = String(Math.floor(fs6.statSync(process.argv[1]).mtimeMs));
3228
3726
  } catch {
3229
3727
  cached = "unknown";
3230
3728
  }
@@ -3522,8 +4020,8 @@ function mountPrReplyRoutes(app, opts) {
3522
4020
  }
3523
4021
 
3524
4022
  // src/core/archive/archive-retention.ts
3525
- import fs6 from "fs";
3526
- import path8 from "path";
4023
+ import fs7 from "fs";
4024
+ import path9 from "path";
3527
4025
  import zlib from "zlib";
3528
4026
  var DEFAULT_COMPRESS_AFTER_DAYS = 30;
3529
4027
  var DAY_MS = 24 * 36e5;
@@ -3535,7 +4033,7 @@ function applyArchiveRetention(opts) {
3535
4033
  const out = { compressed: [], dropped: [], bytesSaved: 0 };
3536
4034
  let ids;
3537
4035
  try {
3538
- ids = fs6.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
4036
+ ids = fs7.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
3539
4037
  } catch {
3540
4038
  return out;
3541
4039
  }
@@ -3544,17 +4042,17 @@ function applyArchiveRetention(opts) {
3544
4042
  if (!rec) continue;
3545
4043
  const age = now - Date.parse(rec.archivedAt);
3546
4044
  if (!Number.isFinite(age)) continue;
3547
- const ignored = path8.join(archiveDirFor(id, root), "ignored");
3548
- if (compressAfter > 0 && age >= compressAfter * DAY_MS && !rec.ignoredDroppedAt && fs6.existsSync(ignored)) {
3549
- fs6.rmSync(ignored, { recursive: true, force: true });
4045
+ const ignored = path9.join(archiveDirFor(id, root), "ignored");
4046
+ if (compressAfter > 0 && age >= compressAfter * DAY_MS && !rec.ignoredDroppedAt && fs7.existsSync(ignored)) {
4047
+ fs7.rmSync(ignored, { recursive: true, force: true });
3550
4048
  rec.ignoredDroppedAt = new Date(now).toISOString();
3551
4049
  writeArchiveRecord(rec, root);
3552
4050
  }
3553
4051
  if (rec.transcriptsDroppedAt) continue;
3554
- const dir = path8.join(archiveDirFor(id, root), "transcripts");
4052
+ const dir = path9.join(archiveDirFor(id, root), "transcripts");
3555
4053
  if (dropAfter > 0 && age >= dropAfter * DAY_MS) {
3556
4054
  out.bytesSaved += dirBytes(dir);
3557
- fs6.rmSync(dir, { recursive: true, force: true });
4055
+ fs7.rmSync(dir, { recursive: true, force: true });
3558
4056
  rec.transcriptsDroppedAt = new Date(now).toISOString();
3559
4057
  writeArchiveRecord(rec, root);
3560
4058
  out.dropped.push(id);
@@ -3562,16 +4060,16 @@ function applyArchiveRetention(opts) {
3562
4060
  }
3563
4061
  if (compressAfter <= 0 || rec.compressedAt || age < compressAfter * DAY_MS) continue;
3564
4062
  for (const t of rec.transcripts) {
3565
- const plain = path8.join(dir, t.file);
3566
- if (!fs6.existsSync(plain)) continue;
3567
- const data = fs6.readFileSync(plain);
4063
+ const plain = path9.join(dir, t.file);
4064
+ if (!fs7.existsSync(plain)) continue;
4065
+ const data = fs7.readFileSync(plain);
3568
4066
  const gz = zlib.gzipSync(data);
3569
- fs6.writeFileSync(`${plain}.gz`, gz);
3570
- if (!zlib.gunzipSync(fs6.readFileSync(`${plain}.gz`)).equals(data)) {
3571
- fs6.rmSync(`${plain}.gz`, { force: true });
4067
+ fs7.writeFileSync(`${plain}.gz`, gz);
4068
+ if (!zlib.gunzipSync(fs7.readFileSync(`${plain}.gz`)).equals(data)) {
4069
+ fs7.rmSync(`${plain}.gz`, { force: true });
3572
4070
  continue;
3573
4071
  }
3574
- fs6.rmSync(plain, { force: true });
4072
+ fs7.rmSync(plain, { force: true });
3575
4073
  out.bytesSaved += data.length - gz.length;
3576
4074
  }
3577
4075
  rec.compressedAt = new Date(now).toISOString();
@@ -3583,7 +4081,7 @@ function applyArchiveRetention(opts) {
3583
4081
  function dirBytes(dir) {
3584
4082
  let n = 0;
3585
4083
  try {
3586
- for (const f of fs6.readdirSync(dir)) n += fs6.statSync(path8.join(dir, f)).size;
4084
+ for (const f of fs7.readdirSync(dir)) n += fs7.statSync(path9.join(dir, f)).size;
3587
4085
  } catch {
3588
4086
  }
3589
4087
  return n;
@@ -3788,17 +4286,17 @@ function mountTimeRoutes(app, opts) {
3788
4286
  }
3789
4287
 
3790
4288
  // src/server/routes/revert-routes.ts
3791
- import path10 from "path";
4289
+ import path11 from "path";
3792
4290
  import { zValidator as zValidator6 } from "@hono/zod-validator";
3793
4291
  import { z as z5 } from "zod";
3794
4292
 
3795
4293
  // src/core/diff/revert.ts
3796
- import fs7 from "fs";
3797
- import path9 from "path";
4294
+ import fs8 from "fs";
4295
+ import path10 from "path";
3798
4296
  function inside(root, rel) {
3799
- const abs = path9.resolve(root, rel);
3800
- const back = path9.relative(path9.resolve(root), abs);
3801
- if (!back || back.startsWith("..") || path9.isAbsolute(back)) return null;
4297
+ const abs = path10.resolve(root, rel);
4298
+ const back = path10.relative(path10.resolve(root), abs);
4299
+ if (!back || back.startsWith("..") || path10.isAbsolute(back)) return null;
3802
4300
  return abs;
3803
4301
  }
3804
4302
  function inHead(root, rel) {
@@ -3808,7 +4306,7 @@ function removeNew(root, rel) {
3808
4306
  const abs = inside(root, rel);
3809
4307
  if (!abs) return { ok: false, status: 400, error: `path escapes the worktree: ${rel}` };
3810
4308
  git(["rm", "--cached", "-q", "--ignore-unmatch", "--", rel], root);
3811
- fs7.rmSync(abs, { force: true });
4309
+ fs8.rmSync(abs, { force: true });
3812
4310
  return null;
3813
4311
  }
3814
4312
  function revertFile(root, file) {
@@ -3911,8 +4409,8 @@ function mountRevertRoutes(app, opts) {
3911
4409
  if (!session) return c.json({ error: "unknown session" }, 404);
3912
4410
  const body = c.req.valid("json");
3913
4411
  const repo = opts.uncommitted(session).find((r) => r.name === body.repo);
3914
- const allowed = new Set(session.paths.map((p) => path10.resolve(p).toLowerCase()));
3915
- if (!repo || !allowed.has(path10.resolve(repo.root).toLowerCase())) {
4412
+ const allowed = new Set(session.paths.map((p) => path11.resolve(p).toLowerCase()));
4413
+ if (!repo || !allowed.has(path11.resolve(repo.root).toLowerCase())) {
3916
4414
  return c.json({ error: `unknown repo: ${body.repo}` }, 404);
3917
4415
  }
3918
4416
  const file = repo.files.find((f) => f.path === body.path);
@@ -3969,7 +4467,7 @@ function mountDevRoutes(app, opts) {
3969
4467
  }
3970
4468
 
3971
4469
  // src/server/routes/ci-routes.ts
3972
- import fs8 from "fs";
4470
+ import fs9 from "fs";
3973
4471
 
3974
4472
  // src/core/pr/review-quote.ts
3975
4473
  function quoteForAgent(s, max = 600) {
@@ -4473,7 +4971,7 @@ function mountCiRoutes(app, opts) {
4473
4971
  lookOnly: opts.lookOnly,
4474
4972
  sessions: () => {
4475
4973
  const cutoff = Date.now() - RECENT_MS;
4476
- return loadHistory().filter((s) => !s.archivedAt && Date.parse(s.lastAccessedAt) >= cutoff && s.paths.some((p) => fs8.existsSync(p))).map((session) => ({ id: sessionIdFor(session), session }));
4974
+ return loadHistory().filter((s) => !s.archivedAt && Date.parse(s.lastAccessedAt) >= cutoff && s.paths.some((p) => fs9.existsSync(p))).map((session) => ({ id: sessionIdFor(session), session }));
4477
4975
  },
4478
4976
  // Never-pushed branches can't have a PR: don't ask GitHub about them,
4479
4977
  // unless the watch already knows one (a merged PR whose branch is gone).
@@ -4538,27 +5036,27 @@ function mountCiRoutes(app, opts) {
4538
5036
  }
4539
5037
 
4540
5038
  // src/core/diff/diffs-sweep.ts
4541
- import fs9 from "fs";
4542
- import path11 from "path";
5039
+ import fs10 from "fs";
5040
+ import path12 from "path";
4543
5041
  var SWEEP_AFTER_DAYS = 30;
4544
5042
  var DISPOSABLE = /\.(html|log)$/i;
4545
- function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS, dir = path11.join(getConfigDir(), "diffs")) {
5043
+ function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS, dir = path12.join(getConfigDir(), "diffs")) {
4546
5044
  const cutoff = now - maxAgeDays * 24 * 60 * 60 * 1e3;
4547
5045
  let removed = 0;
4548
5046
  let bytes = 0;
4549
5047
  let names;
4550
5048
  try {
4551
- names = fs9.readdirSync(dir);
5049
+ names = fs10.readdirSync(dir);
4552
5050
  } catch {
4553
5051
  return { removed, bytes };
4554
5052
  }
4555
5053
  for (const name of names) {
4556
5054
  if (!DISPOSABLE.test(name)) continue;
4557
- const file = path11.join(dir, name);
5055
+ const file = path12.join(dir, name);
4558
5056
  try {
4559
- const st = fs9.statSync(file);
5057
+ const st = fs10.statSync(file);
4560
5058
  if (!st.isFile() || st.mtimeMs >= cutoff) continue;
4561
- fs9.rmSync(file, { force: true });
5059
+ fs10.rmSync(file, { force: true });
4562
5060
  removed++;
4563
5061
  bytes += st.size;
4564
5062
  } catch {
@@ -4568,7 +5066,7 @@ function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS,
4568
5066
  }
4569
5067
 
4570
5068
  // src/core/diff/session-history.ts
4571
- import path12 from "path";
5069
+ import path13 from "path";
4572
5070
 
4573
5071
  // src/core/diff/diff-points.ts
4574
5072
  var SHA = /^[0-9a-f]{7,40}$/;
@@ -4638,7 +5136,7 @@ function sessionCommits(session) {
4638
5136
  if (log.exitCode !== 0 || !log.stdout) continue;
4639
5137
  for (const line of log.stdout.split("\n")) {
4640
5138
  const [sha, at, subject] = line.split("");
4641
- if (sha && at) out.push({ repo: path12.basename(root), sha, at, subject: subject ?? "" });
5139
+ if (sha && at) out.push({ repo: path13.basename(root), sha, at, subject: subject ?? "" });
4642
5140
  }
4643
5141
  }
4644
5142
  if (commitCache.size >= COMMIT_CACHE_MAX) commitCache.delete(commitCache.keys().next().value);
@@ -4646,7 +5144,7 @@ function sessionCommits(session) {
4646
5144
  return out;
4647
5145
  }
4648
5146
  function computeSessionRange(session, from, to) {
4649
- const paths = session.paths.map((p) => path12.resolve(p));
5147
+ const paths = session.paths.map((p) => path13.resolve(p));
4650
5148
  const refs = rangeRefs(paths, loadManifest(scopeHashForPaths(paths)).entries, from, to);
4651
5149
  if ("error" in refs) return refs;
4652
5150
  return { repos: refs.map((r) => ({ name: r.name, root: r.root, files: computeRangeDiff(r) })) };
@@ -4668,15 +5166,17 @@ function claudeElsewhere(i, now = Date.now()) {
4668
5166
  confirmed: true
4669
5167
  };
4670
5168
  }
4671
- const active = i.lastActivityMs !== null && now - i.lastActivityMs < ELSEWHERE_ACTIVE_MS;
5169
+ const after = (ms) => !i.stoppedAtMs || ms > i.stoppedAtMs;
5170
+ const active = i.lastActivityMs !== null && now - i.lastActivityMs < ELSEWHERE_ACTIVE_MS && after(i.lastActivityMs);
4672
5171
  const s = i.status;
4673
- const blockedOrWorking = !!s && (s.state === "needs_input" || s.state === "working");
4674
- const justFinished = !!s && s.state === "idle" && now - (Date.parse(s.endedAt ?? s.updatedAt) || 0) < ELSEWHERE_IDLE_MS;
5172
+ const blockedOrWorking = !!s && (s.state === "needs_input" || s.state === "working") && after(Date.parse(s.since ?? s.updatedAt) || 0);
5173
+ const endedAt = s ? Date.parse(s.endedAt ?? s.updatedAt) || 0 : 0;
5174
+ const justFinished = !!s && s.state === "idle" && now - endedAt < ELSEWHERE_IDLE_MS && after(endedAt);
4675
5175
  if (!active && !blockedOrWorking && !justFinished) return null;
4676
5176
  return { type: "elsewhere", lastActivity: i.lastActivityMs, state: s?.state ?? null };
4677
5177
  }
4678
5178
  function elsewhereStatus(raw, shown) {
4679
- return shown ? { state: shown.state, updatedAt: shown.updatedAt, endedAt: raw?.turnEndedAt ?? shown.since } : null;
5179
+ return shown ? { state: shown.state, updatedAt: shown.updatedAt, endedAt: raw?.turnEndedAt ?? shown.since, since: shown.since } : null;
4680
5180
  }
4681
5181
  async function defaultElsewhere(sessionId) {
4682
5182
  await syncPtyPool();
@@ -4687,11 +5187,14 @@ async function defaultElsewhere(sessionId) {
4687
5187
  const status = raw ? sessionStatusView(raw, session, activity.lastActivity ?? 0) : null;
4688
5188
  const hostPids = ptyPids();
4689
5189
  const runningOutside = (agentsBySession(liveAgents(), loadHistory()).get(sessionId) ?? []).filter((c) => !hostPids.has(c.pid));
5190
+ const archivedAt = Date.parse(readArchive(sessionId)?.archivedAt ?? "");
4690
5191
  return claudeElsewhere({
4691
5192
  hasPty: peekPty(sessionId),
4692
5193
  lastActivityMs: activity.lastActivity,
4693
5194
  status: elsewhereStatus(raw, status),
4694
- runningOutside
5195
+ runningOutside,
5196
+ // Archiving stopped its Claude: what that one did before isn't a Claude open somewhere now.
5197
+ stoppedAtMs: Number.isFinite(archivedAt) ? archivedAt : null
4695
5198
  });
4696
5199
  }
4697
5200
  function attachTerminalWs(httpServer, port, opts = {}) {
@@ -4805,28 +5308,28 @@ async function bridgeToHost(ws, sessionId, pending) {
4805
5308
  }
4806
5309
 
4807
5310
  // src/core/pty/agent-restart.ts
4808
- import fs11 from "fs";
5311
+ import fs12 from "fs";
4809
5312
 
4810
5313
  // src/core/platform/find-on-path.ts
4811
- import fs10 from "fs";
4812
- import path13 from "path";
5314
+ import fs11 from "fs";
5315
+ import path14 from "path";
4813
5316
  function findOnPath(cmd, env = process.env, platform = process.platform) {
4814
5317
  const win = platform === "win32";
4815
5318
  const isFile = (p) => {
4816
5319
  try {
4817
- const st = fs10.statSync(p);
5320
+ const st = fs11.statSync(p);
4818
5321
  return st.isFile() && (win || (st.mode & 73) !== 0);
4819
5322
  } catch {
4820
5323
  return false;
4821
5324
  }
4822
5325
  };
4823
5326
  const pathExt = (env.PATHEXT ?? env.Pathext ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((e) => e.toLowerCase());
4824
- const hasExt = pathExt.includes(path13.extname(cmd).toLowerCase());
5327
+ const hasExt = pathExt.includes(path14.extname(cmd).toLowerCase());
4825
5328
  const candidates = (base) => !win || hasExt ? [base] : pathExt.map((e) => base + e);
4826
5329
  if (cmd.includes("/") || win && cmd.includes("\\")) return candidates(cmd).find(isFile) ?? null;
4827
- const dirs = (env.PATH ?? env.Path ?? "").split(win ? ";" : path13.delimiter).filter(Boolean);
5330
+ const dirs = (env.PATH ?? env.Path ?? "").split(win ? ";" : path14.delimiter).filter(Boolean);
4828
5331
  for (const dir of dirs) {
4829
- const hit = candidates(path13.join(dir, cmd)).find(isFile);
5332
+ const hit = candidates(path14.join(dir, cmd)).find(isFile);
4830
5333
  if (hit) return hit;
4831
5334
  }
4832
5335
  return null;
@@ -4838,7 +5341,7 @@ function installedAt(cmd, find = findOnPath) {
4838
5341
  const file = find(cmd);
4839
5342
  if (!file) return null;
4840
5343
  try {
4841
- return installTime(fs11.statSync(fs11.realpathSync(file)));
5344
+ return installTime(fs12.statSync(fs12.realpathSync(file)));
4842
5345
  } catch {
4843
5346
  return null;
4844
5347
  }
@@ -5048,7 +5551,7 @@ function sleepCandidates(ptys, now, afterMs, busy, keep = /* @__PURE__ */ new Se
5048
5551
  function computeSessionDiff(s, base) {
5049
5552
  const resolved = s.paths.map((p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch));
5050
5553
  const repos = s.paths.map((p, i) => ({
5051
- name: path14.basename(p),
5554
+ name: path15.basename(p),
5052
5555
  root: p,
5053
5556
  resolvedBase: resolved[i].resolvedBase,
5054
5557
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -5099,7 +5602,7 @@ async function startWebServer(opts = {}) {
5099
5602
  let activityWatcher = null;
5100
5603
  if (!lean) {
5101
5604
  try {
5102
- const roots = activityRoots().filter((r) => fs12.existsSync(r));
5605
+ const roots = activityRoots().filter((r) => fs13.existsSync(r));
5103
5606
  if (roots.length > 0) {
5104
5607
  activityWatcher = createFsWatcher({
5105
5608
  roots,
@@ -5150,7 +5653,7 @@ async function startWebServer(opts = {}) {
5150
5653
  }, 500);
5151
5654
  }
5152
5655
  });
5153
- const repoNames = (s) => s.isGroup ? s.paths.map((p) => path14.basename(p)) : [s.target];
5656
+ const repoNames = (s) => s.isGroup ? s.paths.map((p) => path15.basename(p)) : [s.target];
5154
5657
  const diffStatFor = (id, s, hasStatus) => wantsDiffStat(s, hasStatus) ? diffStats.get(id, s.paths, repoNames(s)) : null;
5155
5658
  const archivedRow = createArchivedRows();
5156
5659
  app.get("/api/sessions", (c) => {
@@ -5596,6 +6099,7 @@ async function startWebServer(opts = {}) {
5596
6099
  mountSessionOrderRoutes(app, { broadcast });
5597
6100
  mountRailRoutes(app, { broadcast });
5598
6101
  mountNoteRoutes(app, { broadcast });
6102
+ mountCodeRoutes(app);
5599
6103
  mountDiffSeenRoutes(app);
5600
6104
  mountDiffPageRoutes(app, { ensureScope: sessionScope });
5601
6105
  mountRepoRoutes(app, { broadcast, activity, workBin: getWorkBin });
@@ -5619,7 +6123,7 @@ async function startWebServer(opts = {}) {
5619
6123
  updatesTimer?.unref?.();
5620
6124
  const desktopFile = desktopUpdatePath();
5621
6125
  const onDesktopUpdate = () => broadcast("updates-changed", { ts: Date.now() });
5622
- if (jobs) fs12.watchFile(desktopFile, { interval: 3e3 }, onDesktopUpdate);
6126
+ if (jobs) fs13.watchFile(desktopFile, { interval: 3e3 }, onDesktopUpdate);
5623
6127
  app.get("/api/pty-host/health", (c) => c.json(hostHealth(hostBeat())));
5624
6128
  let lastHostState = hostHealth(hostBeat()).state;
5625
6129
  const hostTick = lean ? null : setInterval(() => {
@@ -5684,7 +6188,7 @@ async function startWebServer(opts = {}) {
5684
6188
  if (timeFirst) clearTimeout(timeFirst);
5685
6189
  if (timeTimer) clearInterval(timeTimer);
5686
6190
  timeKeeper?.stop();
5687
- fs12.unwatchFile(desktopFile, onDesktopUpdate);
6191
+ fs13.unwatchFile(desktopFile, onDesktopUpdate);
5688
6192
  for (const t of conversationSyncs.values()) clearTimeout(t);
5689
6193
  clearTimeout(sweepTimer);
5690
6194
  activityWatcher?.stop();
@@ -5707,11 +6211,11 @@ async function startWebServer(opts = {}) {
5707
6211
  }
5708
6212
 
5709
6213
  // src/core/platform/autostart.ts
5710
- import fs13 from "fs";
5711
- import path15 from "path";
6214
+ import fs14 from "fs";
6215
+ import path16 from "path";
5712
6216
  function startupScriptPath() {
5713
6217
  if (process.platform !== "win32" || !process.env.APPDATA) return null;
5714
- return path15.join(process.env.APPDATA, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "work-web.vbs");
6218
+ return path16.join(process.env.APPDATA, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "work-web.vbs");
5715
6219
  }
5716
6220
  function vbsQuote(s) {
5717
6221
  return '"' + s.replace(/"/g, '""') + '"';
@@ -5729,11 +6233,11 @@ function setAutostart(enabled, workBin) {
5729
6233
  const file = startupScriptPath();
5730
6234
  if (!file) throw new Error("Autostart is only supported on Windows so far.");
5731
6235
  if (enabled) {
5732
- fs13.mkdirSync(path15.dirname(file), { recursive: true });
5733
- fs13.writeFileSync(file, buildStartupScript(process.execPath, workBin), "utf-8");
6236
+ fs14.mkdirSync(path16.dirname(file), { recursive: true });
6237
+ fs14.writeFileSync(file, buildStartupScript(process.execPath, workBin), "utf-8");
5734
6238
  } else {
5735
6239
  try {
5736
- fs13.unlinkSync(file);
6240
+ fs14.unlinkSync(file);
5737
6241
  } catch {
5738
6242
  }
5739
6243
  }
@@ -5777,7 +6281,7 @@ function createDemoRepos(liveTargets) {
5777
6281
  /** GET /api/projects: what New worktree offers, as the real one reads config. */
5778
6282
  projects() {
5779
6283
  return {
5780
- singles: Object.entries(repos).map(([name, path16]) => ({ name, kind: "single", path: path16 })),
6284
+ singles: Object.entries(repos).map(([name, path17]) => ({ name, kind: "single", path: path17 })),
5781
6285
  groups: Object.entries(groups).map(([name, members]) => ({ name, kind: "group", members }))
5782
6286
  };
5783
6287
  },
@@ -5819,12 +6323,12 @@ function createDemoRepos(liveTargets) {
5819
6323
  }));
5820
6324
  return { roots: [root], repos: rows, groups: groupRows };
5821
6325
  },
5822
- enroll(alias, path16) {
5823
- if (!found.some((f) => f.path === path16)) throw new DemoRepoError(`${path16} is not the top folder of a git repository`);
5824
- const problem = enrollProblem(alias, path16, config());
6326
+ enroll(alias, path17) {
6327
+ if (!found.some((f) => f.path === path17)) throw new DemoRepoError(`${path17} is not the top folder of a git repository`);
6328
+ const problem = enrollProblem(alias, path17, config());
5825
6329
  if (problem) throw new DemoRepoError(problem);
5826
- repos[alias] = path16;
5827
- ignored.delete(path16);
6330
+ repos[alias] = path17;
6331
+ ignored.delete(path17);
5828
6332
  },
5829
6333
  remove(alias, force) {
5830
6334
  if (!(alias in repos)) throw new DemoRepoError(`no repo \u201C${alias}\u201D`);
@@ -5833,9 +6337,9 @@ function createDemoRepos(liveTargets) {
5833
6337
  delete repos[alias];
5834
6338
  for (const g of Object.keys(groups)) groups[g] = groups[g].filter((m) => m !== alias);
5835
6339
  },
5836
- ignore(path16, on) {
5837
- if (on) ignored.add(path16);
5838
- else ignored.delete(path16);
6340
+ ignore(path17, on) {
6341
+ if (on) ignored.add(path17);
6342
+ else ignored.delete(path17);
5839
6343
  },
5840
6344
  saveGroup(name, members, creating) {
5841
6345
  const problem = groupProblem(name, members, config(), { creating });
@@ -6215,6 +6719,7 @@ var DemoScenario = class {
6215
6719
  );
6216
6720
  taxes.archivedAt = this.iso(60 * 20);
6217
6721
  taxes.worktreeRemoved = true;
6722
+ taxes.archivedBy = "pr-merged";
6218
6723
  this.add(
6219
6724
  "web",
6220
6725
  "feat/order-history",
@@ -6484,6 +6989,17 @@ ${reply}\r
6484
6989
  attention: s.attention,
6485
6990
  diffStat: stat.files ? stat : null,
6486
6991
  archivedAt: s.archivedAt,
6992
+ ...s.archivedAt && s.archivedBy ? {
6993
+ archive: {
6994
+ by: s.archivedBy,
6995
+ worktreeRemoved: !!s.worktreeRemoved,
6996
+ // As a real archive says it: a demo session's changes aren't in its main branch.
6997
+ keptBecause: s.worktreeRemoved ? null : "commits not in the main branch",
6998
+ promptCount: 0,
6999
+ prompts: [],
7000
+ lastSummary: null
7001
+ }
7002
+ } : {},
6487
7003
  port: s.port,
6488
7004
  ...s.baseBranch ? { baseBranch: s.baseBranch } : {},
6489
7005
  context: DEMO_CONTEXT[s.branch] ? { used: Math.round(DEMO_CONTEXT[s.branch] * 2e5), window: 2e5, model: "claude-sonnet-5" } : null,
@@ -6807,6 +7323,7 @@ ${reply}\r
6807
7323
  const s = this.sessions.get(id);
6808
7324
  if (!s) return false;
6809
7325
  s.archivedAt = archived ? new Date(this.now()).toISOString() : null;
7326
+ s.archivedBy = archived ? "you" : void 0;
6810
7327
  this.changed();
6811
7328
  return true;
6812
7329
  }
@@ -6874,8 +7391,10 @@ ${reply}\r
6874
7391
  results.push({ ...it, ok: false, message: c ? `Not removed: ${c.reason}.` : "The session is gone already." });
6875
7392
  continue;
6876
7393
  }
6877
- if (it.action === "archive") s.archivedAt = new Date(this.now()).toISOString();
6878
- else this.sessions.delete(it.sessionId);
7394
+ if (it.action === "archive") {
7395
+ s.archivedAt = new Date(this.now()).toISOString();
7396
+ s.archivedBy = "cleanup";
7397
+ } else this.sessions.delete(it.sessionId);
6879
7398
  results.push({
6880
7399
  ...it,
6881
7400
  ok: true,
@@ -7003,7 +7522,10 @@ ${reply}\r
7003
7522
  return { repo: sel.name, ok: true, merged: true, message: `PR #${r.pr.number} merged (${method})`, url: r.pr.url };
7004
7523
  });
7005
7524
  const allDone = s.repos.every((r) => this.repoState(s, r).done);
7006
- if (allDone) s.archivedAt = new Date(this.now()).toISOString();
7525
+ if (allDone) {
7526
+ s.archivedAt = new Date(this.now()).toISOString();
7527
+ s.archivedBy = "shipped";
7528
+ }
7007
7529
  this.changed();
7008
7530
  return { results, archived: allDone, allDone };
7009
7531
  }
@@ -7163,6 +7685,64 @@ function demoSha(seed) {
7163
7685
  return out.slice(0, 40);
7164
7686
  }
7165
7687
 
7688
+ // src/server/demo/demo-code.ts
7689
+ var COMMON = {
7690
+ "README.md": "# {repo}\n\nThe {repo} service of the demo shop.\n\n## Running it\n\n```sh\nnpm install\nnpm run dev\n```\n",
7691
+ "package.json": '{\n "name": "{repo}",\n "private": true,\n "scripts": {\n "dev": "vite",\n "test": "vitest run"\n }\n}\n',
7692
+ ".gitignore": "node_modules\ndist\n.env.local\n",
7693
+ "src/index.ts": "export { start } from './server';\n",
7694
+ "src/server.ts": "import { createServer } from 'node:http';\n\n/** Start the {repo} server on PORT (3000 by default). */\nexport function start(port = Number(process.env.PORT ?? 3000)) {\n return createServer((req, res) => {\n res.end('ok');\n }).listen(port);\n}\n"
7695
+ };
7696
+ function newSide(f) {
7697
+ const lines = [];
7698
+ for (const h of f.hunks) for (const l of h.lines) if (l.kind === "add" || l.kind === "context") lines.push(l.content);
7699
+ while (lines.length && lines[lines.length - 1] === "") lines.pop();
7700
+ return lines.join("\n") + "\n";
7701
+ }
7702
+ function demoCodeFiles(repos, group) {
7703
+ return {
7704
+ group,
7705
+ rootFiles: group ? ["CLAUDE.md"] : [],
7706
+ repos: repos.map((r) => {
7707
+ const changed = r.changed.filter((f) => f.status !== "deleted").map((f) => f.path);
7708
+ return { name: r.name, files: [.../* @__PURE__ */ new Set([...Object.keys(COMMON), ...changed])].sort(), changed: changed.sort(), truncated: false };
7709
+ })
7710
+ };
7711
+ }
7712
+ function demoCodeFile(repos, group, repo, path17) {
7713
+ if (repo === "") {
7714
+ if (!group || path17 !== "CLAUDE.md") return null;
7715
+ const text2 = `# Group instructions
7716
+
7717
+ Repos: ${repos.map((r2) => r2.name).join(", ")}.
7718
+ `;
7719
+ return { repo, path: path17, size: text2.length, text: text2 };
7720
+ }
7721
+ const r = repos.find((x) => x.name === repo);
7722
+ if (!r) return null;
7723
+ const changed = r.changed.find((f) => f.path === path17 && f.status !== "deleted");
7724
+ const text = changed ? newSide(changed) : COMMON[path17]?.replace(/\{repo\}/g, repo);
7725
+ return text === void 0 ? null : { repo, path: path17, size: text.length, text };
7726
+ }
7727
+ function demoCodeSearch(repos, group, query) {
7728
+ const q = query.trim();
7729
+ if (q.length < 2) return { query: q, symbols: [], text: [], truncated: false };
7730
+ const symbols = [];
7731
+ const text = [];
7732
+ const fold = (x) => ignoresCase(q) ? x.toLowerCase() : x;
7733
+ for (const r of demoCodeFiles(repos, group).repos) {
7734
+ for (const path17 of r.files) {
7735
+ const lines = (demoCodeFile(repos, group, r.name, path17)?.text ?? "").split("\n");
7736
+ lines.forEach((line, i) => {
7737
+ const d = declarationOf(path17, line);
7738
+ if (d) symbols.push({ ...d, repo: r.name, path: path17, line: i + 1, text: line.trim() });
7739
+ if (fold(line).includes(fold(q))) text.push({ repo: r.name, path: path17, line: i + 1, text: line });
7740
+ });
7741
+ }
7742
+ }
7743
+ return { query: q, symbols: matchSymbols(symbols, q), text, truncated: false };
7744
+ }
7745
+
7166
7746
  // src/server/demo/demo-activity.ts
7167
7747
  var SWEEP_EVERY_MS = 3e4;
7168
7748
  var STEP_MS = 700;
@@ -7606,6 +8186,25 @@ async function startDemoServer(opts) {
7606
8186
  const d = scenario.diff(c.req.param("id"), base);
7607
8187
  return d ? c.json(d) : notFound(c);
7608
8188
  });
8189
+ const demoRepos = (id) => {
8190
+ const d = scenario.diff(id, "branch");
8191
+ const w = scenario.list().find((x) => x.id === id);
8192
+ return d && w ? { repos: d.repos.map((r) => ({ name: r.name, changed: r.files })), group: w.isGroup } : null;
8193
+ };
8194
+ app.get("/api/sessions/:id/files", (c) => {
8195
+ const r = demoRepos(c.req.param("id"));
8196
+ return r ? c.json(demoCodeFiles(r.repos, r.group)) : notFound(c);
8197
+ });
8198
+ app.get("/api/sessions/:id/code-search", (c) => {
8199
+ const r = demoRepos(c.req.param("id"));
8200
+ return r ? c.json(demoCodeSearch(r.repos, r.group, c.req.query("q") ?? "")) : notFound(c);
8201
+ });
8202
+ app.get("/api/sessions/:id/file", (c) => {
8203
+ const r = demoRepos(c.req.param("id"));
8204
+ if (!r) return notFound(c);
8205
+ const f = demoCodeFile(r.repos, r.group, c.req.query("repo") ?? "", c.req.query("path") ?? "");
8206
+ return f ? c.json(f) : c.json({ error: "not listed" }, 404);
8207
+ });
7609
8208
  app.get("/api/sessions/:id/ci", (c) => {
7610
8209
  const d = scenario.ci(c.req.param("id"));
7611
8210
  return d ? c.json(d) : notFound(c);
@@ -8537,4 +9136,4 @@ export {
8537
9136
  stopExisting,
8538
9137
  webCommand
8539
9138
  };
8540
- //# sourceMappingURL=web-6AOR3MIE.js.map
9139
+ //# sourceMappingURL=web-5YGNY6MI.js.map