@moberg_hr/work-tree 2.0.2 → 2.0.3

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 (198) hide show
  1. package/dist/{answer-BD5A6XMM.js → answer-ZYRJTGPR.js} +8 -8
  2. package/dist/{attach-ID6KEOQ5.js → attach-PEOW6HHM.js} +11 -11
  3. package/dist/bin.js +2 -2
  4. package/dist/{block-AQDYKNWG.js → block-EA7LCWBG.js} +8 -8
  5. package/dist/{broadcast-BSI5NDDB.js → broadcast-VE7WYHDK.js} +5 -5
  6. package/dist/{catchup-3454JUMS.js → catchup-DF7YZFOJ.js} +10 -10
  7. package/dist/{chunk-2PRI27ND.js → chunk-2P26VJY3.js} +12 -12
  8. package/dist/{chunk-ZXPYWZL5.js → chunk-46UD4QBL.js} +10 -6
  9. package/dist/chunk-46UD4QBL.js.map +1 -0
  10. package/dist/{chunk-C2BK6EBN.js → chunk-4SK76CPY.js} +4 -4
  11. package/dist/{chunk-77XFJQGC.js → chunk-4WEYZ3YG.js} +5 -5
  12. package/dist/{chunk-ITNPMWPY.js → chunk-52ST6RVB.js} +8 -8
  13. package/dist/{chunk-3JWTO5VZ.js → chunk-5OUTCUYQ.js} +46 -26
  14. package/dist/chunk-5OUTCUYQ.js.map +1 -0
  15. package/dist/{chunk-FPKERDK7.js → chunk-6GCF2XWP.js} +2 -2
  16. package/dist/{chunk-O3VNU7EZ.js → chunk-AUGWUZR2.js} +6 -6
  17. package/dist/{chunk-6H3MLDGG.js → chunk-BFLJ6PGX.js} +4 -4
  18. package/dist/{chunk-R2LN3JJJ.js → chunk-BSCAA322.js} +2 -2
  19. package/dist/{chunk-CA7LI4N2.js → chunk-C763EC47.js} +7 -6
  20. package/dist/{chunk-CA7LI4N2.js.map → chunk-C763EC47.js.map} +1 -1
  21. package/dist/{chunk-QBAZG4CY.js → chunk-DJBOQU56.js} +2 -2
  22. package/dist/{chunk-JYTMT5DF.js → chunk-DKKXDLMQ.js} +5 -5
  23. package/dist/{chunk-IXKVCR4Y.js → chunk-E4GZGQWP.js} +3 -3
  24. package/dist/{chunk-7OLPI334.js → chunk-EF5GZEXK.js} +2 -2
  25. package/dist/{chunk-YZWADOEW.js → chunk-EY3ZPJT3.js} +3 -3
  26. package/dist/{chunk-CLGVSX36.js → chunk-EYZG4MR6.js} +4 -4
  27. package/dist/{chunk-NDWSLQPB.js → chunk-FOG4WG3Y.js} +2 -2
  28. package/dist/{chunk-YZDD5YGE.js → chunk-G2O7EIKX.js} +2 -2
  29. package/dist/{chunk-OYQFLBLO.js → chunk-IAOFCBAO.js} +7 -7
  30. package/dist/{chunk-Q6WZCO45.js → chunk-IISQUS7L.js} +2 -2
  31. package/dist/{chunk-5QK7GB5K.js → chunk-JJRPLNLN.js} +2 -2
  32. package/dist/{chunk-FR3EWVXI.js → chunk-KNKXGEPJ.js} +4 -4
  33. package/dist/{chunk-4BOK2GXL.js → chunk-KPVCQBHZ.js} +3 -3
  34. package/dist/{chunk-P3BL4EOP.js → chunk-LC2UWKAQ.js} +2 -2
  35. package/dist/{chunk-O3QTWVSK.js → chunk-LQCYTZ2F.js} +14 -8
  36. package/dist/chunk-LQCYTZ2F.js.map +1 -0
  37. package/dist/chunk-LYNBLVEM.js +9 -0
  38. package/dist/{chunk-C2THFSXA.js → chunk-NDEELC3K.js} +4 -4
  39. package/dist/{chunk-JNBYNRFS.js → chunk-NEZNZM7K.js} +2 -2
  40. package/dist/{chunk-UFY7C5PP.js → chunk-NS3HSXF7.js} +2 -2
  41. package/dist/{chunk-G2WWMJJB.js → chunk-PA2744MS.js} +8 -8
  42. package/dist/{chunk-PN44M5EE.js → chunk-PMA7QPUV.js} +8 -2
  43. package/dist/chunk-PMA7QPUV.js.map +1 -0
  44. package/dist/{chunk-SOCPIHCS.js → chunk-REKP6EIC.js} +2 -2
  45. package/dist/{chunk-TUC4QY4O.js → chunk-RM6XOZMU.js} +2 -2
  46. package/dist/{chunk-M4FVCAT6.js → chunk-SBL4VVXD.js} +36 -3
  47. package/dist/{chunk-M4FVCAT6.js.map → chunk-SBL4VVXD.js.map} +1 -1
  48. package/dist/{chunk-XJDEROHY.js → chunk-T2KX2B6I.js} +2 -2
  49. package/dist/{chunk-QECEHQ4U.js → chunk-TMUMQRNM.js} +45 -45
  50. package/dist/{chunk-KGZ6OZ2T.js → chunk-VSX6ICYG.js} +5 -5
  51. package/dist/{chunk-YNKWLC45.js → chunk-WDVIPH6X.js} +3 -3
  52. package/dist/{chunk-7NCW3LUT.js → chunk-WF57CF7A.js} +14 -1
  53. package/dist/chunk-WF57CF7A.js.map +1 -0
  54. package/dist/{chunk-ZJN5RWZD.js → chunk-XOHJUVU6.js} +3 -3
  55. package/dist/{chunk-6FTIY5M6.js → chunk-XWJ6BB63.js} +4 -4
  56. package/dist/{chunk-YKODIG22.js → chunk-YMNFSV5C.js} +4 -4
  57. package/dist/{chunk-VHWQE2WE.js → chunk-YNB3M2SM.js} +3 -3
  58. package/dist/{cleanup-E6OD3TUM.js → cleanup-2FPGGFMO.js} +20 -20
  59. package/dist/{cli-O6IF63TS.js → cli-PI7WSA4S.js} +3 -3
  60. package/dist/{config-IEIU7A66.js → config-HZOLEXYK.js} +9 -9
  61. package/dist/{diff-K47HB6SA.js → diff-3YNZDI65.js} +8 -8
  62. package/dist/{digest-FBZTBXQO.js → digest-CZG3FZE7.js} +7 -7
  63. package/dist/{fork-XJPZFNMX.js → fork-QPD5JTUH.js} +18 -18
  64. package/dist/{hook-MTWRSD4S.js → hook-6GDHRNT6.js} +8 -8
  65. package/dist/{hydrate-Y2AAMZTA.js → hydrate-YGDWGBXX.js} +4 -4
  66. package/dist/{init-7ESFTYZC.js → init-MBNE57LN.js} +8 -8
  67. package/dist/{install-skills-O34BHFHD.js → install-skills-5XINJXYY.js} +3 -3
  68. package/dist/install-skills-bin.js +2 -2
  69. package/dist/{move-FKT2P5LY.js → move-HUC4Y4FX.js} +11 -11
  70. package/dist/{note-M53Q6EWY.js → note-2YE44FRK.js} +8 -8
  71. package/dist/{overlaps-FRLMMIGC.js → overlaps-75LVGJWA.js} +7 -7
  72. package/dist/{pin-VMM5TINM.js → pin-FWJVLOSH.js} +8 -8
  73. package/dist/{pr-EHF642TN.js → pr-2XIZWDS2.js} +9 -9
  74. package/dist/{prune-3DRPO3VJ.js → prune-7MSLBWVA.js} +19 -19
  75. package/dist/{pty-host-RWIS55N4.js → pty-host-HQPWKXVI.js} +65 -16
  76. package/dist/pty-host-HQPWKXVI.js.map +1 -0
  77. package/dist/{read-DDQDRHRB.js → read-PYIADA63.js} +7 -7
  78. package/dist/{recent-IE3LYQ65.js → recent-JKFUXEKV.js} +5 -5
  79. package/dist/{remove-XJYZVAPX.js → remove-MGXS7QZ6.js} +18 -18
  80. package/dist/{resume-UUP6R2IE.js → resume-DMGXYTGC.js} +5 -5
  81. package/dist/{run-V4755W7C.js → run-3KH6GAOL.js} +4 -4
  82. package/dist/{screen-XMGBRC25.js → screen-3UMWSHAY.js} +8 -8
  83. package/dist/{search-3JZXLCR2.js → search-OOJIPNZT.js} +4 -4
  84. package/dist/{section-OO7IOLI7.js → section-ZHCDMSCB.js} +8 -8
  85. package/dist/{send-GMG27KFT.js → send-DXNOANZQ.js} +9 -9
  86. package/dist/{sessions-GOP5Y6LS.js → sessions-CLE6ZC23.js} +15 -15
  87. package/dist/{snooze-HOS6J3SY.js → snooze-OHZFIQEG.js} +7 -7
  88. package/dist/{start-2XGTR7NW.js → start-LDLKCTBE.js} +8 -8
  89. package/dist/{state-4DFV6SHG.js → state-FGYNNSDP.js} +2 -2
  90. package/dist/{status-H5OW4LYE.js → status-MIERES2A.js} +4 -4
  91. package/dist/{stop-2B2HFRHR.js → stop-BJ2OO6QL.js} +8 -8
  92. package/dist/{sync-YP6NMA5H.js → sync-HZ6I2EU7.js} +19 -19
  93. package/dist/{time-5SAXO4M7.js → time-TWCZGQ2W.js} +8 -8
  94. package/dist/{todo-LWMQY6XW.js → todo-Y2BZ65MS.js} +3 -3
  95. package/dist/{tree-7BMORJ6J.js → tree-ML343C6O.js} +11 -11
  96. package/dist/{update-A7G46IYO.js → update-RNIAUEA6.js} +10 -10
  97. package/dist/{wait-NP6HODWB.js → wait-2M76BDB5.js} +8 -8
  98. package/dist/wd-bin.js +2 -2
  99. package/dist/web/assets/{PtyView-BdoF3ROW.js → PtyView-C1eEBxiL.js} +2 -2
  100. package/dist/web/assets/{PtyView-BdoF3ROW.js.map → PtyView-C1eEBxiL.js.map} +1 -1
  101. package/dist/web/assets/index-3TfcsOhs.css +1 -0
  102. package/dist/web/assets/index-CjoTiPVM.js +117 -0
  103. package/dist/web/assets/index-CjoTiPVM.js.map +1 -0
  104. package/dist/web/index.html +2 -2
  105. package/dist/{web-FSOY6574.js → web-W33235GF.js} +420 -119
  106. package/dist/web-W33235GF.js.map +1 -0
  107. package/npm-shrinkwrap.json +2 -2
  108. package/package.json +3 -1
  109. package/dist/chunk-3JWTO5VZ.js.map +0 -1
  110. package/dist/chunk-7NCW3LUT.js.map +0 -1
  111. package/dist/chunk-O3QTWVSK.js.map +0 -1
  112. package/dist/chunk-PN44M5EE.js.map +0 -1
  113. package/dist/chunk-UJD6QUGG.js +0 -9
  114. package/dist/chunk-ZXPYWZL5.js.map +0 -1
  115. package/dist/pty-host-RWIS55N4.js.map +0 -1
  116. package/dist/web/assets/index-BrkfzFos.js +0 -116
  117. package/dist/web/assets/index-BrkfzFos.js.map +0 -1
  118. package/dist/web/assets/index-L8mjakHP.css +0 -1
  119. package/dist/web-FSOY6574.js.map +0 -1
  120. /package/dist/{answer-BD5A6XMM.js.map → answer-ZYRJTGPR.js.map} +0 -0
  121. /package/dist/{attach-ID6KEOQ5.js.map → attach-PEOW6HHM.js.map} +0 -0
  122. /package/dist/{block-AQDYKNWG.js.map → block-EA7LCWBG.js.map} +0 -0
  123. /package/dist/{broadcast-BSI5NDDB.js.map → broadcast-VE7WYHDK.js.map} +0 -0
  124. /package/dist/{catchup-3454JUMS.js.map → catchup-DF7YZFOJ.js.map} +0 -0
  125. /package/dist/{chunk-2PRI27ND.js.map → chunk-2P26VJY3.js.map} +0 -0
  126. /package/dist/{chunk-C2BK6EBN.js.map → chunk-4SK76CPY.js.map} +0 -0
  127. /package/dist/{chunk-77XFJQGC.js.map → chunk-4WEYZ3YG.js.map} +0 -0
  128. /package/dist/{chunk-ITNPMWPY.js.map → chunk-52ST6RVB.js.map} +0 -0
  129. /package/dist/{chunk-FPKERDK7.js.map → chunk-6GCF2XWP.js.map} +0 -0
  130. /package/dist/{chunk-O3VNU7EZ.js.map → chunk-AUGWUZR2.js.map} +0 -0
  131. /package/dist/{chunk-6H3MLDGG.js.map → chunk-BFLJ6PGX.js.map} +0 -0
  132. /package/dist/{chunk-R2LN3JJJ.js.map → chunk-BSCAA322.js.map} +0 -0
  133. /package/dist/{chunk-QBAZG4CY.js.map → chunk-DJBOQU56.js.map} +0 -0
  134. /package/dist/{chunk-JYTMT5DF.js.map → chunk-DKKXDLMQ.js.map} +0 -0
  135. /package/dist/{chunk-IXKVCR4Y.js.map → chunk-E4GZGQWP.js.map} +0 -0
  136. /package/dist/{chunk-7OLPI334.js.map → chunk-EF5GZEXK.js.map} +0 -0
  137. /package/dist/{chunk-YZWADOEW.js.map → chunk-EY3ZPJT3.js.map} +0 -0
  138. /package/dist/{chunk-CLGVSX36.js.map → chunk-EYZG4MR6.js.map} +0 -0
  139. /package/dist/{chunk-NDWSLQPB.js.map → chunk-FOG4WG3Y.js.map} +0 -0
  140. /package/dist/{chunk-YZDD5YGE.js.map → chunk-G2O7EIKX.js.map} +0 -0
  141. /package/dist/{chunk-OYQFLBLO.js.map → chunk-IAOFCBAO.js.map} +0 -0
  142. /package/dist/{chunk-Q6WZCO45.js.map → chunk-IISQUS7L.js.map} +0 -0
  143. /package/dist/{chunk-5QK7GB5K.js.map → chunk-JJRPLNLN.js.map} +0 -0
  144. /package/dist/{chunk-FR3EWVXI.js.map → chunk-KNKXGEPJ.js.map} +0 -0
  145. /package/dist/{chunk-4BOK2GXL.js.map → chunk-KPVCQBHZ.js.map} +0 -0
  146. /package/dist/{chunk-P3BL4EOP.js.map → chunk-LC2UWKAQ.js.map} +0 -0
  147. /package/dist/{chunk-UJD6QUGG.js.map → chunk-LYNBLVEM.js.map} +0 -0
  148. /package/dist/{chunk-C2THFSXA.js.map → chunk-NDEELC3K.js.map} +0 -0
  149. /package/dist/{chunk-JNBYNRFS.js.map → chunk-NEZNZM7K.js.map} +0 -0
  150. /package/dist/{chunk-UFY7C5PP.js.map → chunk-NS3HSXF7.js.map} +0 -0
  151. /package/dist/{chunk-G2WWMJJB.js.map → chunk-PA2744MS.js.map} +0 -0
  152. /package/dist/{chunk-SOCPIHCS.js.map → chunk-REKP6EIC.js.map} +0 -0
  153. /package/dist/{chunk-TUC4QY4O.js.map → chunk-RM6XOZMU.js.map} +0 -0
  154. /package/dist/{chunk-XJDEROHY.js.map → chunk-T2KX2B6I.js.map} +0 -0
  155. /package/dist/{chunk-QECEHQ4U.js.map → chunk-TMUMQRNM.js.map} +0 -0
  156. /package/dist/{chunk-KGZ6OZ2T.js.map → chunk-VSX6ICYG.js.map} +0 -0
  157. /package/dist/{chunk-YNKWLC45.js.map → chunk-WDVIPH6X.js.map} +0 -0
  158. /package/dist/{chunk-ZJN5RWZD.js.map → chunk-XOHJUVU6.js.map} +0 -0
  159. /package/dist/{chunk-6FTIY5M6.js.map → chunk-XWJ6BB63.js.map} +0 -0
  160. /package/dist/{chunk-YKODIG22.js.map → chunk-YMNFSV5C.js.map} +0 -0
  161. /package/dist/{chunk-VHWQE2WE.js.map → chunk-YNB3M2SM.js.map} +0 -0
  162. /package/dist/{cleanup-E6OD3TUM.js.map → cleanup-2FPGGFMO.js.map} +0 -0
  163. /package/dist/{cli-O6IF63TS.js.map → cli-PI7WSA4S.js.map} +0 -0
  164. /package/dist/{config-IEIU7A66.js.map → config-HZOLEXYK.js.map} +0 -0
  165. /package/dist/{diff-K47HB6SA.js.map → diff-3YNZDI65.js.map} +0 -0
  166. /package/dist/{digest-FBZTBXQO.js.map → digest-CZG3FZE7.js.map} +0 -0
  167. /package/dist/{fork-XJPZFNMX.js.map → fork-QPD5JTUH.js.map} +0 -0
  168. /package/dist/{hook-MTWRSD4S.js.map → hook-6GDHRNT6.js.map} +0 -0
  169. /package/dist/{hydrate-Y2AAMZTA.js.map → hydrate-YGDWGBXX.js.map} +0 -0
  170. /package/dist/{init-7ESFTYZC.js.map → init-MBNE57LN.js.map} +0 -0
  171. /package/dist/{install-skills-O34BHFHD.js.map → install-skills-5XINJXYY.js.map} +0 -0
  172. /package/dist/{move-FKT2P5LY.js.map → move-HUC4Y4FX.js.map} +0 -0
  173. /package/dist/{note-M53Q6EWY.js.map → note-2YE44FRK.js.map} +0 -0
  174. /package/dist/{overlaps-FRLMMIGC.js.map → overlaps-75LVGJWA.js.map} +0 -0
  175. /package/dist/{pin-VMM5TINM.js.map → pin-FWJVLOSH.js.map} +0 -0
  176. /package/dist/{pr-EHF642TN.js.map → pr-2XIZWDS2.js.map} +0 -0
  177. /package/dist/{prune-3DRPO3VJ.js.map → prune-7MSLBWVA.js.map} +0 -0
  178. /package/dist/{read-DDQDRHRB.js.map → read-PYIADA63.js.map} +0 -0
  179. /package/dist/{recent-IE3LYQ65.js.map → recent-JKFUXEKV.js.map} +0 -0
  180. /package/dist/{remove-XJYZVAPX.js.map → remove-MGXS7QZ6.js.map} +0 -0
  181. /package/dist/{resume-UUP6R2IE.js.map → resume-DMGXYTGC.js.map} +0 -0
  182. /package/dist/{run-V4755W7C.js.map → run-3KH6GAOL.js.map} +0 -0
  183. /package/dist/{screen-XMGBRC25.js.map → screen-3UMWSHAY.js.map} +0 -0
  184. /package/dist/{search-3JZXLCR2.js.map → search-OOJIPNZT.js.map} +0 -0
  185. /package/dist/{section-OO7IOLI7.js.map → section-ZHCDMSCB.js.map} +0 -0
  186. /package/dist/{send-GMG27KFT.js.map → send-DXNOANZQ.js.map} +0 -0
  187. /package/dist/{sessions-GOP5Y6LS.js.map → sessions-CLE6ZC23.js.map} +0 -0
  188. /package/dist/{snooze-HOS6J3SY.js.map → snooze-OHZFIQEG.js.map} +0 -0
  189. /package/dist/{start-2XGTR7NW.js.map → start-LDLKCTBE.js.map} +0 -0
  190. /package/dist/{state-4DFV6SHG.js.map → state-FGYNNSDP.js.map} +0 -0
  191. /package/dist/{status-H5OW4LYE.js.map → status-MIERES2A.js.map} +0 -0
  192. /package/dist/{stop-2B2HFRHR.js.map → stop-BJ2OO6QL.js.map} +0 -0
  193. /package/dist/{sync-YP6NMA5H.js.map → sync-HZ6I2EU7.js.map} +0 -0
  194. /package/dist/{time-5SAXO4M7.js.map → time-TWCZGQ2W.js.map} +0 -0
  195. /package/dist/{todo-LWMQY6XW.js.map → todo-Y2BZ65MS.js.map} +0 -0
  196. /package/dist/{tree-7BMORJ6J.js.map → tree-ML343C6O.js.map} +0 -0
  197. /package/dist/{update-A7G46IYO.js.map → update-RNIAUEA6.js.map} +0 -0
  198. /package/dist/{wait-NP6HODWB.js.map → wait-2M76BDB5.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/platform/web-discovery.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { isPidAlive } from './process.js';\n\n/**\n * How everything finds the running `work web` (the singleton): the\n * `web.url` + `web.pid` files it writes in ~/.work. One module instead of\n * copies in the web command, `wd`, and the Claude hook bridge.\n *\n * The files outlive the process (crash, kill, reboot) and Windows reuses\n * PIDs, so neither file is proof of anything: `probeWeb` asks the server\n * itself, and it answers /api/context with its own pid.\n */\n\n// os.homedir() per call (not getConfigDir, which creates the dir): tests\n// mock homedir, and readers must not create ~/.work as a side effect.\n// One pair of files per server: `web` (the real one) or `web-dev` (the dev server).\ntype Stem = 'web' | 'web-dev';\nconst fileOf = (stem: Stem, ext: 'url' | 'pid') => path.join(os.homedir(), '.work', `${stem}.${ext}`);\n\nfunction readUrl(stem: Stem): string | null {\n try {\n return fs.readFileSync(fileOf(stem, 'url'), 'utf-8').trim() || null;\n } catch {\n return null;\n }\n}\n\nfunction readPid(stem: Stem): number | null {\n try {\n const n = Number(fs.readFileSync(fileOf(stem, 'pid'), 'utf-8').trim());\n return Number.isFinite(n) && n > 0 ? n : null;\n } catch {\n return null;\n }\n}\n\nfunction writeFiles(stem: Stem, url: string, pid: number): void {\n fs.mkdirSync(path.dirname(fileOf(stem, 'url')), { recursive: true });\n // The pid first: a server leaving at the same moment clears only files that name it,\n // so it never takes the url of the one that just started.\n fs.writeFileSync(fileOf(stem, 'pid'), String(pid));\n fs.writeFileSync(fileOf(stem, 'url'), url);\n}\n\n/**\n * Remove a server's files; with `ownerPid`, only while they still name that\n * server. `strict`: not when the pid can't be read either (the dev server's:\n * another may be writing its own).\n */\nfunction clearFiles(stem: Stem, ownerPid?: number, strict = false): void {\n if (ownerPid !== undefined) {\n const current = readPid(stem);\n if (current === null ? strict : current !== ownerPid) return;\n }\n for (const ext of ['pid', 'url'] as const) {\n try {\n fs.unlinkSync(fileOf(stem, ext));\n } catch {\n /* already gone */\n }\n }\n}\n\nexport function webUrlPath(): string {\n return fileOf('web', 'url');\n}\nexport function webPidPath(): string {\n return fileOf('web', 'pid');\n}\nexport const readWebUrl = (): string | null => readUrl('web');\nexport const readWebPid = (): number | null => readPid('web');\nexport const writeWebDiscovery = (url: string, pid: number): void => writeFiles('web', url, pid);\n\n/**\n * Remove the discovery files. With `ownerPid`, only if they still name that\n * server: a new one (the desktop app restarts it at once) may have written\n * its own in the meantime, and deleting those hides it from every client —\n * `wd`, the CLI, the Claude hooks.\n */\nexport const clearWebDiscovery = (ownerPid?: number): void => clearFiles('web', ownerPid);\n\n/**\n * The dev server's (`work web --dev`): a checkout's build next to the\n * installed work, found by the dev app through these files only — nothing\n * that looks for work web (`wd`, the CLI, the Claude hooks, the installed\n * app) reads them, so it never takes the dev server for the real one.\n */\nexport const devWebUrlPath = (): string => fileOf('web-dev', 'url');\n\nexport const writeDevWebDiscovery = (url: string, pid: number): void => writeFiles('web-dev', url, pid);\n/** Remove them, only while they still name `ownerPid`. */\nexport const clearDevWebDiscovery = (ownerPid: number): void => clearFiles('web-dev', ownerPid, true);\n\n/** Where the dev server stands, for `work web --dev` (start, reuse, stop). */\nexport type DevWebState =\n | { kind: 'running'; url: string; pid: number }\n /** Its process runs but it didn't answer in time: busy, never proof it's gone (as findHost). */\n | { kind: 'busy'; url: string; pid: number }\n | { kind: 'none' };\n\n/**\n * The recorded dev server, only when it answers /api/context with the\n * recorded pid and says it's the dev server: files that outlived a crash\n * can name a reused pid, and their port another work web — the real one,\n * which `--dev --stop` (run by every `npm run app:dev`) would then shut\n * down. Files that name no live dev server are removed.\n */\nexport async function findDevWeb(probe: typeof probeWeb = probeWeb, alive: (pid: number) => boolean = isPidAlive): Promise<DevWebState> {\n const url = readUrl('web-dev');\n const pid = readPid('web-dev');\n if (!url || pid === null) return { kind: 'none' };\n if (!alive(pid)) {\n clearFiles('web-dev', pid, true);\n return { kind: 'none' };\n }\n const p = await probe(url, 3000);\n if (p.kind === 'timeout') return { kind: 'busy', url, pid };\n if (p.kind === 'ours' && p.pid === pid && p.dev) return { kind: 'running', url, pid };\n clearFiles('web-dev', pid, true);\n return { kind: 'none' };\n}\n\nexport type WebProbe =\n | {\n kind: 'ours';\n pid: number | null;\n lean: boolean;\n /** null: a build before stamps. */ build: string | null;\n /** The dev server (`work web --dev`). */ dev: boolean;\n }\n /** Nothing listens there (or something that isn't work web answered). */\n | { kind: 'gone' }\n /** No answer in time — possibly just busy; never proof it's gone. */\n | { kind: 'timeout' };\n\nexport async function probeWeb(url: string, timeoutMs = 1500): Promise<WebProbe> {\n try {\n const res = await fetch(`${url}api/context`, { signal: AbortSignal.timeout(timeoutMs) });\n if (!res.ok) return { kind: 'gone' };\n const body = (await res.json().catch(() => ({}))) as { mode?: unknown; pid?: unknown; lean?: unknown; build?: unknown; dev?: unknown };\n if (typeof body.mode !== 'string') return { kind: 'gone' };\n return {\n kind: 'ours',\n pid: typeof body.pid === 'number' ? body.pid : null,\n lean: body.lean === true,\n build: typeof body.build === 'string' ? body.build : null,\n dev: body.dev === true,\n };\n } catch (err) {\n const name = (err as { name?: string }).name;\n return name === 'TimeoutError' || name === 'AbortError' ? { kind: 'timeout' } : { kind: 'gone' };\n }\n}\n\n/**\n * What to do with the recorded work web before starting one:\n * - 'reuse' it answered as work web — or it is BUSY (timed out, possibly\n * more than once): a slow server is still the running one, and\n * replacing it orphans it (the new one sees the live pid and\n * exits; the old one keeps the port and hooks but can no longer\n * be found once web.url is gone).\n * - 'start' nothing is there any more (the url file is stale).\n * Busy servers get `patienceMs` of re-probing before being reused anyway.\n */\nexport async function existingWebDecision(\n url: string,\n opts: { patienceMs?: number; probe?: typeof probeWeb } = {},\n): Promise<'reuse' | 'start'> {\n const probe = opts.probe ?? probeWeb;\n const until = Date.now() + (opts.patienceMs ?? 6000);\n for (let first = true; ; first = false) {\n const r = await probe(url, first ? 1500 : 3000);\n if (r.kind === 'ours') return 'reuse';\n if (r.kind === 'gone') return 'start';\n if (Date.now() >= until) return 'reuse';\n }\n}\n\n/**\n * A running work web checks, now and then, that it is still THE one:\n * - 'keep' web.pid names us.\n * - 'retire' web.pid names another work web that answers as itself: two\n * were started at once (a restart racing the desktop app's\n * watchdog, which starts one when none answers) and the other\n * won the discovery files. Ours can no longer be found, but it\n * kept its PR watch and gh calls going — twice the GitHub API\n * use — and the desktop app stayed on it, an old build.\n * - 'reclaim' nothing recorded (or a dead pid): write ours back, so `wd`,\n * the app and `work web --stop` find the one that runs.\n * A busy or silent other is never reason to retire (see existingWebDecision).\n */\nexport async function discoveryCheck(\n self: { pid: number; url: string },\n deps: { readPid?: () => number | null; readUrl?: () => string | null; alive?: (pid: number) => boolean; probe?: typeof probeWeb } = {},\n): Promise<'keep' | 'retire' | 'reclaim'> {\n const pid = (deps.readPid ?? readWebPid)();\n if (pid === self.pid) return 'keep';\n const alive = deps.alive ?? isPidAlive;\n if (pid === null || !alive(pid)) return 'reclaim';\n const url = (deps.readUrl ?? readWebUrl)();\n if (!url || url === self.url) return 'keep';\n const r = await (deps.probe ?? probeWeb)(url, 3000);\n return r.kind === 'ours' && r.pid === pid ? 'retire' : 'keep';\n}\n\n/**\n * Liveness only: is a server serving the recorded URL (any 2xx at\n * api/context)? Enough for \"reuse it / autostart one\". Identity — is it\n * work web, with the recorded pid — is probeWeb's job, and only matters\n * before killing something.\n */\nexport async function webServerResponds(url: string, timeoutMs = 1500): Promise<boolean> {\n try {\n const res = await fetch(`${url}api/context`, { signal: AbortSignal.timeout(timeoutMs) });\n return res.ok;\n } catch {\n return false;\n }\n}\n\n/**\n * GET a JSON route from the running work web, for what only it holds (the\n * PR watch's cache, which PTYs are live). Null when none runs or it doesn't\n * answer in time: callers go without that part rather than fail.\n */\nexport async function askWorkWeb<T>(route: string, timeoutMs = 3000): Promise<T | null> {\n const url = readWebUrl();\n if (!url) return null;\n try {\n const res = await fetch(`${url}${route.replace(/^\\//, '')}`, { signal: AbortSignal.timeout(timeoutMs) });\n return res.ok ? ((await res.json()) as T) : null;\n } catch {\n return null;\n }\n}\n\nexport type WorkWebAnswer<T> =\n { ok: true; body: T } | { ok: false; status: number; error: string } | { ok: false; status: 0; error: string };\n\n/**\n * Call a route of the running work web (what only it can do: type into a\n * terminal it owns, start a Claude in the PTY host). Unlike askWorkWeb, a\n * refusal comes back with its reason, and \"no work web\" is its own answer\n * (status 0), so the caller can say how to start one.\n */\nexport async function callWorkWeb<T>(method: 'GET' | 'POST', route: string, body?: unknown, timeoutMs = 15_000): Promise<WorkWebAnswer<T>> {\n const url = readWebUrl();\n if (!url) return { ok: false, status: 0, error: 'work web is not running (start it with `work web`, or open the desktop app)' };\n try {\n const res = await fetch(`${url}${route.replace(/^\\//, '')}`, {\n method,\n signal: AbortSignal.timeout(timeoutMs),\n ...(body !== undefined ? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}),\n });\n const json = (await res.json().catch(() => null)) as (T & { error?: unknown }) | null;\n if (res.ok && json) return { ok: true, body: json };\n return { ok: false, status: res.status, error: typeof json?.error === 'string' ? json.error : `work web answered ${res.status}` };\n } catch (err) {\n return { ok: false, status: 0, error: `work web did not answer (${(err as Error).message})` };\n }\n}\n"],"mappings":";;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AAiBjB,IAAM,SAAS,CAAC,MAAY,QAAuB,KAAK,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,IAAI,GAAG,EAAE;AAEpG,SAAS,QAAQ,MAA2B;AAC1C,MAAI;AACF,WAAO,GAAG,aAAa,OAAO,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,KAAK;AAAA,EACjE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,MAA2B;AAC1C,MAAI;AACF,UAAM,IAAI,OAAO,GAAG,aAAa,OAAO,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;AACrE,WAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;AAAA,EAC3C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,WAAW,MAAY,KAAa,KAAmB;AAC9D,KAAG,UAAU,KAAK,QAAQ,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,WAAW,KAAK,CAAC;AAGnE,KAAG,cAAc,OAAO,MAAM,KAAK,GAAG,OAAO,GAAG,CAAC;AACjD,KAAG,cAAc,OAAO,MAAM,KAAK,GAAG,GAAG;AAC3C;AAOA,SAAS,WAAW,MAAY,UAAmB,SAAS,OAAa;AACvE,MAAI,aAAa,QAAW;AAC1B,UAAM,UAAU,QAAQ,IAAI;AAC5B,QAAI,YAAY,OAAO,SAAS,YAAY,SAAU;AAAA,EACxD;AACA,aAAW,OAAO,CAAC,OAAO,KAAK,GAAY;AACzC,QAAI;AACF,SAAG,WAAW,OAAO,MAAM,GAAG,CAAC;AAAA,IACjC,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAEO,SAAS,aAAq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,EAC9F;AACF;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  sessionIdFor,
5
5
  tx,
6
6
  withDb
7
- } from "./chunk-7NCW3LUT.js";
7
+ } from "./chunk-WF57CF7A.js";
8
8
 
9
9
  // src/core/pr/pr-replies.ts
10
10
  var THREAD_ID = /^PRRT_[A-Za-z0-9_-]{4,120}$/;
@@ -139,4 +139,4 @@ export {
139
139
  postDrafts,
140
140
  markPostedAnswered
141
141
  };
142
- //# sourceMappingURL=chunk-FPKERDK7.js.map
142
+ //# sourceMappingURL=chunk-6GCF2XWP.js.map
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createInProcess
4
- } from "./chunk-C2BK6EBN.js";
4
+ } from "./chunk-4SK76CPY.js";
5
5
  import {
6
6
  ensurePty,
7
7
  peekPty
8
- } from "./chunk-O3QTWVSK.js";
8
+ } from "./chunk-LQCYTZ2F.js";
9
9
  import {
10
10
  resolveProjectTarget
11
11
  } from "./chunk-H5LKMR45.js";
12
12
  import {
13
13
  checkedOutBranch
14
- } from "./chunk-CA7LI4N2.js";
14
+ } from "./chunk-C763EC47.js";
15
15
  import {
16
16
  getCommentFileStore
17
- } from "./chunk-5QK7GB5K.js";
17
+ } from "./chunk-JJRPLNLN.js";
18
18
  import {
19
19
  getStatusChecked,
20
20
  git
21
21
  } from "./chunk-7NAXFBFI.js";
22
22
  import {
23
23
  sessionIdFor
24
- } from "./chunk-7NCW3LUT.js";
24
+ } from "./chunk-WF57CF7A.js";
25
25
  import {
26
26
  loadConfig
27
27
  } from "./chunk-7HEB6SQS.js";
@@ -148,4 +148,4 @@ export {
148
148
  uncommittedFiles,
149
149
  defaultForkDeps
150
150
  };
151
- //# sourceMappingURL=chunk-O3VNU7EZ.js.map
151
+ //# sourceMappingURL=chunk-AUGWUZR2.js.map
@@ -6,14 +6,14 @@ import {
6
6
  lastTurnEntryMs,
7
7
  readSessionActivity,
8
8
  readStatus
9
- } from "./chunk-M4FVCAT6.js";
9
+ } from "./chunk-SBL4VVXD.js";
10
10
  import {
11
11
  sessionIdFor
12
- } from "./chunk-7NCW3LUT.js";
12
+ } from "./chunk-WF57CF7A.js";
13
13
  import {
14
14
  agentOf,
15
15
  readJsonlTail
16
- } from "./chunk-PN44M5EE.js";
16
+ } from "./chunk-PMA7QPUV.js";
17
17
 
18
18
  // src/core/status/turn-activity.ts
19
19
  var cache = /* @__PURE__ */ new Map();
@@ -45,4 +45,4 @@ export {
45
45
  sessionStatusView,
46
46
  shownState
47
47
  };
48
- //# sourceMappingURL=chunk-6H3MLDGG.js.map
48
+ //# sourceMappingURL=chunk-BFLJ6PGX.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  BUILD_DIR_NAMES
4
- } from "./chunk-NDWSLQPB.js";
4
+ } from "./chunk-FOG4WG3Y.js";
5
5
 
6
6
  // src/core/worktree/repo-rules.ts
7
7
  var baseName = (p) => p.replace(/[\\/]+$/, "").split(/[\\/]/).pop() ?? p;
@@ -129,4 +129,4 @@ export {
129
129
  originUrl,
130
130
  scanForRepos
131
131
  };
132
- //# sourceMappingURL=chunk-R2LN3JJJ.js.map
132
+ //# sourceMappingURL=chunk-BSCAA322.js.map
@@ -5,15 +5,15 @@ import {
5
5
  import {
6
6
  getCommentFileStore,
7
7
  readStoreComments
8
- } from "./chunk-5QK7GB5K.js";
8
+ } from "./chunk-JJRPLNLN.js";
9
9
  import {
10
10
  loadHistory
11
- } from "./chunk-M4FVCAT6.js";
11
+ } from "./chunk-SBL4VVXD.js";
12
12
  import {
13
13
  sessionIdFor,
14
14
  tx,
15
15
  withDb
16
- } from "./chunk-7NCW3LUT.js";
16
+ } from "./chunk-WF57CF7A.js";
17
17
 
18
18
  // src/core/git/git-head.ts
19
19
  import fs from "fs";
@@ -135,7 +135,8 @@ function claimForDelivery(sessionId, ids) {
135
135
  });
136
136
  }
137
137
  var MAX_BODY_BYTES = 4 * 1024;
138
- var MAX_TOTAL_BYTES = 32 * 1024;
138
+ var MAX_NOTE_BYTES = 16 * 1024;
139
+ var MAX_TOTAL_BYTES = 4 * MAX_NOTE_BYTES;
139
140
  function formatPendingForPrompt(pending) {
140
141
  if (pending.length === 0) return "";
141
142
  const sorted = [...pending].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
@@ -187,7 +188,7 @@ function formatBody(prefix, c) {
187
188
  }
188
189
  function formatFullBody(prefix, c) {
189
190
  const body = c.body.trim();
190
- const capped = body.length > MAX_BODY_BYTES ? `${body.slice(0, MAX_BODY_BYTES)}\u2026` : body;
191
+ const capped = body.length > MAX_NOTE_BYTES ? `${body.slice(0, MAX_NOTE_BYTES)}\u2026` : body;
191
192
  const bodyLines = capped.split("\n");
192
193
  if (bodyLines.length === 1) return `${prefix}: ${bodyLines[0]}`;
193
194
  const [first, ...rest] = bodyLines;
@@ -204,4 +205,4 @@ export {
204
205
  claimForDelivery,
205
206
  formatPendingForPrompt
206
207
  };
207
- //# sourceMappingURL=chunk-CA7LI4N2.js.map
208
+ //# sourceMappingURL=chunk-C763EC47.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/git/git-head.ts","../src/core/comments/pending-delivery.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * The branch checked out in a checkout, read from its HEAD file — no `git`\n * process, so the session list can ask for every session on every request.\n * A worktree's `.git` is a file (`gitdir: <repo>/.git/worktrees/<name>`)\n * whose HEAD names the branch; a base checkout's `.git` is the folder.\n *\n * null: detached HEAD, not a checkout, or unreadable.\n */\nexport function checkedOutBranch(checkout: string): string | null {\n try {\n const dotGit = path.join(checkout, '.git');\n let gitDir = dotGit;\n if (fs.statSync(dotGit).isFile()) {\n const m = /^gitdir:\\s*(.+?)\\s*$/m.exec(fs.readFileSync(dotGit, 'utf8'));\n if (!m) return null;\n gitDir = path.resolve(checkout, m[1]);\n }\n return branchFromHead(fs.readFileSync(path.join(gitDir, 'HEAD'), 'utf8'));\n } catch {\n return null;\n }\n}\n\n/** `ref: refs/heads/fix/x` → `fix/x`; a commit sha (detached) → null. */\nexport function branchFromHead(head: string): string | null {\n const m = /^ref:\\s*refs\\/heads\\/(.+?)\\s*$/m.exec(head);\n return m ? m[1] : null;\n}\n","/**\n * Bridge between `work web` review comments and any live Claude session\n * running in the same worktree. Storage (state.db, see db.ts):\n *\n * comments the comment stores (comment-file-store.ts)\n * comment_deliveries (session, comment id) pairs surfaced to Claude\n *\n * \"Pending\" = published, user-authored, not in the delivered list. Replies\n * authored by Claude (author === 'claude') are excluded — Claude wrote\n * them; we don't need to echo them back.\n *\n * Delivery is lazy: when a Claude in the matching worktree submits a\n * prompt, the hook reads pending comments via this module, prints them as\n * a system-reminder block to stdout (which Claude Code injects into the\n * conversation), and marks them delivered.\n */\n\nimport { checkedOutBranch } from '../git/git-head.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { loadHistory, type WorktreeSession } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { getCommentFileStore, readStoreComments } from './comment-file-store.js';\nimport { scopeHashFor } from '../diff/repo-spec.js';\nimport { tx, withDb, type Db } from '../platform/db.js';\nimport type { Comment } from './comment-types.js';\n\nfunction deliveredIds(d: Db, sessionId: string): Set<string> {\n return new Set(\n (d.prepare('SELECT comment_id FROM comment_deliveries WHERE session_id = ?').all(sessionId) as Array<{ comment_id: string }>).map(\n (r) => r.comment_id,\n ),\n );\n}\n\n/** Norm-path comparison that mirrors what we do server-side. */\nfunction normalize(p: string): string {\n return path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n}\n\n/** Map a Claude cwd back to a session. Tries direct-match against any\n * session's path first, then ancestor match (so cwd inside a subdir of a\n * worktree still resolves to the worktree's session). */\n/**\n * Two sessions on one folder (an old entry and a newer one, a typo'd target\n * re-added): which of them a Claude there is. Not an archived one when the\n * other isn't; then the one whose branch is checked out there; then the one\n * entered last. The oldest used to win, so status and comments went to an\n * entry nobody looks at.\n */\nfunction owns(candidate: WorktreeSession, current: WorktreeSession, root: string): boolean {\n if (!!candidate.archivedAt !== !!current.archivedAt) return !candidate.archivedAt;\n const onBranch = checkedOutBranch(root);\n const a = candidate.branch === onBranch;\n const b = current.branch === onBranch;\n if (a !== b) return a;\n return (Date.parse(candidate.lastAccessedAt) || 0) > (Date.parse(current.lastAccessedAt) || 0);\n}\n\nexport function findSessionForCwd(cwd: string, sessions: WorktreeSession[] = loadHistory()): WorktreeSession | null {\n const here = normalize(cwd);\n // Deepest root containing cwd wins, so nested worktrees disambiguate. A\n // group's roots include the group root (the sub-repos' parent) — that's\n // where `work tree` launches Claude for a group, so hooks fire from there.\n let best: { session: WorktreeSession; root: string; len: number } | null = null;\n for (const s of sessions) {\n const roots = s.isGroup && s.paths[0] ? [...s.paths, path.dirname(s.paths[0])] : s.paths;\n for (const root of roots) {\n const r = normalize(root);\n if (!(here === r || here.startsWith(r + '/'))) continue;\n if (!best || r.length > best.len || (r.length === best.len && owns(s, best.session, root))) {\n best = { session: s, root, len: r.length };\n }\n }\n }\n if (!best) return null;\n // A separate checkout nested INSIDE the session's tree (a git worktree at\n // <repo>/.claude/worktrees/x, a vendored repo) is not this session: its\n // Claude must not report status, take checkpoints or receive comments as\n // if it were the parent. Any `.git` between cwd and the matched root —\n // other than the session's own repos — marks a different checkout.\n // (Plain fs checks: this runs on every hook.)\n const own = new Set(best.session.paths.map(normalize));\n const top = normalize(best.root);\n for (let dir = path.resolve(cwd); normalize(dir) !== top && normalize(dir).startsWith(top + '/'); dir = path.dirname(dir)) {\n if (!own.has(normalize(dir)) && fs.existsSync(path.join(dir, '.git'))) return null;\n if (path.dirname(dir) === dir) break;\n }\n return best.session;\n}\n\nfunction isPendingFor(delivered: Set<string>) {\n return (c: Comment) => c.status === 'published' && c.author === 'user' && !delivered.has(c.id);\n}\n\n/** Returns published user comments that haven't been delivered yet.\n * Reads through the file-store cache so we see in-flight writes\n * (`session-meta.ts` and other readers couldn't, when they re-read the\n * disk directly). */\n/**\n * The line typed into an idle Claude (or given as the first prompt of one\n * work starts) so its UserPromptSubmit hook attaches the pending comments.\n * Short on purpose: a long typed note got mangled by Claude Code's paste\n * handling. It says where the content is, so it reads right in the\n * transcript.\n */\nexport const NOTE_NUDGE =\n 'work has new notes for you (review feedback, CI results or comments); they are attached to this message. Work through them now.';\n\nexport function readPendingForSession(sessionId: string): Comment[] {\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n return readStoreComments(sessionId).filter(isPendingFor(delivered));\n}\n\n/** Comment-store ids for every `wd` scope that could cover this worktree.\n * A scope is keyed by `sha1` of its sorted repo roots (see\n * `repo-spec.scopeHashFor`), so from a session's paths we can rebuild the\n * exact ids without consulting `work web`'s in-memory scope registry:\n * - the whole-set hash → a group `wd` opened at the group root, or the\n * single-repo `wd` (one path);\n * - each individual path's hash → a `wd` opened inside one sub-repo of a\n * group worktree.\n * `registerScope` hashes `path.resolve()`d roots, so we resolve here too or\n * the hashes won't line up. Mirrors `scope-manager.commentStoreIdForScope`\n * (`scope-<hash>`). */\nfunction scopeStoreIdsForPaths(paths: string[]): string[] {\n const resolved = paths.map((p) => path.resolve(p));\n const ids = new Set<string>();\n ids.add(`scope-${scopeHashFor(resolved)}`);\n for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);\n return [...ids];\n}\n\n/**\n * Pending comments for a whole worktree: the session's own comment store\n * PLUS any `wd` / `wd -c` scope review store covering the same paths.\n *\n * `wd` registers its review under a scope-hash comment store, not the\n * session store the hook reads — without this merge, comments left in the\n * `wd` review UI would never reach the Claude running in that worktree.\n * Delivered-tracking stays per-session (one `<sessionId>.delivered.json`),\n * so a comment surfaced here won't be re-delivered regardless of which\n * store it came from.\n */\nexport function readPendingForWorktree(session: WorktreeSession): Comment[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n const pending = isPendingFor(delivered);\n const seen = new Set<string>();\n const out: Comment[] = [];\n const collect = (storeId: string) => {\n for (const c of readStoreComments(storeId)) {\n if (seen.has(c.id) || !pending(c)) continue;\n seen.add(c.id);\n out.push(c);\n }\n };\n collect(sessionId);\n for (const storeId of scopeStoreIdsForPaths(session.paths)) collect(storeId);\n return out;\n}\n\n/**\n * What was handed to Claude is done once its turn really ends: your review\n * comments and work's notes to it (PR feedback, CI, a prompt you sent) —\n * every top-level comment of yours it was given, in the session's store and\n * any `wd` scope store over its paths — are marked resolved. Left open, they\n * piled up on the Diff tab's badge (three PR-watch notes read as \"3\"), to\n * resolve or delete by hand. Resolved threads stay listed (dimmed) and can\n * be reopened. Claude's own replies are left as they are. Returns the ids\n * resolved.\n */\nexport function resolveAddressed(session: WorktreeSession): string[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n if (delivered.size === 0) return [];\n const done: string[] = [];\n for (const storeId of [sessionId, ...scopeStoreIdsForPaths(session.paths)]) {\n const open = readStoreComments(storeId).filter(\n (c) => delivered.has(c.id) && c.author === 'user' && c.status === 'published' && !c.parentId && !c.resolved,\n );\n if (open.length === 0) continue;\n const store = getCommentFileStore(storeId);\n for (const c of open) if (store.setResolved(c.id, true)) done.push(c.id);\n }\n return done;\n}\n\n/** Persist a delivery batch, so these ids are never surfaced again. */\nexport function markDelivered(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n for (const id of ids) ins.run(sessionId, id);\n });\n}\n\n/**\n * Claim comments for delivery: of `ids`, return the ones nobody has\n * delivered yet, and mark them delivered — atomically. Two deliverers\n * racing (a Stop hook and the PTY push for the same comment) then can't\n * both send it: only the one that claimed it does. A deliverer whose send\n * fails gives the ids back with `releaseClaim`.\n */\nexport function claimForDelivery(sessionId: string, ids: string[]): string[] {\n if (ids.length === 0) return [];\n // INSERT OR IGNORE in one write transaction: a row inserted here is our\n // claim; one that already existed was someone else's.\n return tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n return ids.filter((id) => ins.run(sessionId, id).changes > 0);\n });\n}\n\n/** Undo a claim whose delivery failed, so the next hook picks them up. */\nexport function releaseClaim(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const del = d.prepare('DELETE FROM comment_deliveries WHERE session_id = ? AND comment_id = ?');\n for (const id of ids) del.run(sessionId, id);\n });\n}\n\n/** Cap the size of one comment body we surface to Claude. A pathologically\n * long comment shouldn't blow out Claude's context — we truncate, then\n * hint at the rest via \"(truncated)\". 4 KB is generous for a code-review\n * note while leaving headroom for batches. */\nconst MAX_BODY_BYTES = 4 * 1024;\n/** Overall cap on the whole system-reminder payload. Multiple long\n * comments at once still get bounded. */\nconst MAX_TOTAL_BYTES = 32 * 1024;\n\n/**\n * Format pending comments as a system-reminder block suitable for stdout.\n * Returns empty string when there's nothing pending — the caller (the\n * `work hook` CLI) just exits silently in that case.\n *\n * Truncates pathologically long bodies and caps the overall payload so\n * one runaway comment can't displace the rest of Claude's context.\n */\nexport function formatPendingForPrompt(pending: Comment[]): string {\n if (pending.length === 0) return '';\n\n const sorted = [...pending].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n\n const general = sorted.filter((c) => c.side === 'general' && !c.parentId);\n const inline = sorted.filter((c) => c.side !== 'general' && !c.parentId);\n const replies = sorted.filter((c) => c.parentId);\n\n const lines: string[] = [];\n lines.push('<system-reminder>');\n lines.push(`New review comments from \\`work web\\` (${pending.length} item${pending.length === 1 ? '' : 's'}):`);\n lines.push('');\n\n if (general.length > 0) {\n lines.push('## General notes');\n for (const c of general) {\n // General notes (this is where `work broadcast` lands) may be multi-line\n // prompts — deliver the whole body, not just line 1. Only the byte cap\n // applies. Inline/reply comments still use the one-line `formatBody`.\n lines.push(formatFullBody('-', c));\n }\n lines.push('');\n }\n\n if (inline.length > 0) {\n lines.push('## Inline comments');\n for (const c of inline) {\n const where = `${c.repo}/${c.file}:${c.line} (${c.side})`;\n lines.push(formatBody(`- ${where}`, c));\n }\n lines.push('');\n }\n\n if (replies.length > 0) {\n lines.push('## Replies');\n for (const c of replies) {\n lines.push(formatBody(`- (reply to ${c.parentId})`, c));\n }\n lines.push('');\n }\n\n lines.push(\n 'Address them as part of your next response. You can reply via the same review UI by posting back to the latest review URL at `~/.work/web.url` + `/api/sessions/<id>/comments` with `author: \"claude\"`.',\n );\n lines.push('</system-reminder>');\n const out = lines.join('\\n');\n if (out.length <= MAX_TOTAL_BYTES) return out;\n const trimmed = out.slice(0, MAX_TOTAL_BYTES - 200);\n return (\n trimmed +\n '\\n\\n(…review payload truncated for context-window safety; ' +\n `${pending.length} comment(s) total — open work web for the full list.)\\n` +\n '</system-reminder>'\n );\n}\n\nfunction formatBody(prefix: string, c: Comment): string {\n const lead = c.body.split('\\n')[0].trim();\n const capped = lead.length > MAX_BODY_BYTES ? `${lead.slice(0, MAX_BODY_BYTES)}…` : lead;\n return `${prefix}: ${capped}${c.body.includes('\\n') ? ' …' : ''}`;\n}\n\n/** Like `formatBody` but preserves the full multi-line body (only the byte\n * cap applies). Multi-line bodies are emitted under the bullet, indented, so\n * a broadcast prompt arrives intact rather than truncated to its first line. */\nfunction formatFullBody(prefix: string, c: Comment): string {\n const body = c.body.trim();\n const capped = body.length > MAX_BODY_BYTES ? `${body.slice(0, MAX_BODY_BYTES)}…` : body;\n const bodyLines = capped.split('\\n');\n if (bodyLines.length === 1) return `${prefix}: ${bodyLines[0]}`;\n const [first, ...rest] = bodyLines;\n return [`${prefix}: ${first}`, ...rest.map((l) => ` ${l}`)].join('\\n');\n}\n\n/** Re-export so consumers don't have to know which module owns it. */\nexport { sessionIdFor };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAUV,SAAS,iBAAiB,UAAiC;AAChE,MAAI;AACF,UAAM,SAAS,KAAK,KAAK,UAAU,MAAM;AACzC,QAAI,SAAS;AACb,QAAI,GAAG,SAAS,MAAM,EAAE,OAAO,GAAG;AACh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,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,IAAI;AACxE;","names":["fs","path","path","fs"]}
1
+ {"version":3,"sources":["../src/core/git/git-head.ts","../src/core/comments/pending-delivery.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\n/**\n * The branch checked out in a checkout, read from its HEAD file — no `git`\n * process, so the session list can ask for every session on every request.\n * A worktree's `.git` is a file (`gitdir: <repo>/.git/worktrees/<name>`)\n * whose HEAD names the branch; a base checkout's `.git` is the folder.\n *\n * null: detached HEAD, not a checkout, or unreadable.\n */\nexport function checkedOutBranch(checkout: string): string | null {\n try {\n const dotGit = path.join(checkout, '.git');\n let gitDir = dotGit;\n if (fs.statSync(dotGit).isFile()) {\n const m = /^gitdir:\\s*(.+?)\\s*$/m.exec(fs.readFileSync(dotGit, 'utf8'));\n if (!m) return null;\n gitDir = path.resolve(checkout, m[1]);\n }\n return branchFromHead(fs.readFileSync(path.join(gitDir, 'HEAD'), 'utf8'));\n } catch {\n return null;\n }\n}\n\n/** `ref: refs/heads/fix/x` → `fix/x`; a commit sha (detached) → null. */\nexport function branchFromHead(head: string): string | null {\n const m = /^ref:\\s*refs\\/heads\\/(.+?)\\s*$/m.exec(head);\n return m ? m[1] : null;\n}\n","/**\n * Bridge between `work web` review comments and any live Claude session\n * running in the same worktree. Storage (state.db, see db.ts):\n *\n * comments the comment stores (comment-file-store.ts)\n * comment_deliveries (session, comment id) pairs surfaced to Claude\n *\n * \"Pending\" = published, user-authored, not in the delivered list. Replies\n * authored by Claude (author === 'claude') are excluded — Claude wrote\n * them; we don't need to echo them back.\n *\n * Delivery is lazy: when a Claude in the matching worktree submits a\n * prompt, the hook reads pending comments via this module, prints them as\n * a system-reminder block to stdout (which Claude Code injects into the\n * conversation), and marks them delivered.\n */\n\nimport { checkedOutBranch } from '../git/git-head.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { loadHistory, type WorktreeSession } from '../sessions/history.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { getCommentFileStore, readStoreComments } from './comment-file-store.js';\nimport { scopeHashFor } from '../diff/repo-spec.js';\nimport { tx, withDb, type Db } from '../platform/db.js';\nimport type { Comment } from './comment-types.js';\n\nfunction deliveredIds(d: Db, sessionId: string): Set<string> {\n return new Set(\n (d.prepare('SELECT comment_id FROM comment_deliveries WHERE session_id = ?').all(sessionId) as Array<{ comment_id: string }>).map(\n (r) => r.comment_id,\n ),\n );\n}\n\n/** Norm-path comparison that mirrors what we do server-side. */\nfunction normalize(p: string): string {\n return path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n}\n\n/** Map a Claude cwd back to a session. Tries direct-match against any\n * session's path first, then ancestor match (so cwd inside a subdir of a\n * worktree still resolves to the worktree's session). */\n/**\n * Two sessions on one folder (an old entry and a newer one, a typo'd target\n * re-added): which of them a Claude there is. Not an archived one when the\n * other isn't; then the one whose branch is checked out there; then the one\n * entered last. The oldest used to win, so status and comments went to an\n * entry nobody looks at.\n */\nfunction owns(candidate: WorktreeSession, current: WorktreeSession, root: string): boolean {\n if (!!candidate.archivedAt !== !!current.archivedAt) return !candidate.archivedAt;\n const onBranch = checkedOutBranch(root);\n const a = candidate.branch === onBranch;\n const b = current.branch === onBranch;\n if (a !== b) return a;\n return (Date.parse(candidate.lastAccessedAt) || 0) > (Date.parse(current.lastAccessedAt) || 0);\n}\n\nexport function findSessionForCwd(cwd: string, sessions: WorktreeSession[] = loadHistory()): WorktreeSession | null {\n const here = normalize(cwd);\n // Deepest root containing cwd wins, so nested worktrees disambiguate. A\n // group's roots include the group root (the sub-repos' parent) — that's\n // where `work tree` launches Claude for a group, so hooks fire from there.\n let best: { session: WorktreeSession; root: string; len: number } | null = null;\n for (const s of sessions) {\n const roots = s.isGroup && s.paths[0] ? [...s.paths, path.dirname(s.paths[0])] : s.paths;\n for (const root of roots) {\n const r = normalize(root);\n if (!(here === r || here.startsWith(r + '/'))) continue;\n if (!best || r.length > best.len || (r.length === best.len && owns(s, best.session, root))) {\n best = { session: s, root, len: r.length };\n }\n }\n }\n if (!best) return null;\n // A separate checkout nested INSIDE the session's tree (a git worktree at\n // <repo>/.claude/worktrees/x, a vendored repo) is not this session: its\n // Claude must not report status, take checkpoints or receive comments as\n // if it were the parent. Any `.git` between cwd and the matched root —\n // other than the session's own repos — marks a different checkout.\n // (Plain fs checks: this runs on every hook.)\n const own = new Set(best.session.paths.map(normalize));\n const top = normalize(best.root);\n for (let dir = path.resolve(cwd); normalize(dir) !== top && normalize(dir).startsWith(top + '/'); dir = path.dirname(dir)) {\n if (!own.has(normalize(dir)) && fs.existsSync(path.join(dir, '.git'))) return null;\n if (path.dirname(dir) === dir) break;\n }\n return best.session;\n}\n\nfunction isPendingFor(delivered: Set<string>) {\n return (c: Comment) => c.status === 'published' && c.author === 'user' && !delivered.has(c.id);\n}\n\n/** Returns published user comments that haven't been delivered yet.\n * Reads through the file-store cache so we see in-flight writes\n * (`session-meta.ts` and other readers couldn't, when they re-read the\n * disk directly). */\n/**\n * The line typed into an idle Claude (or given as the first prompt of one\n * work starts) so its UserPromptSubmit hook attaches the pending comments.\n * Short on purpose: a long typed note got mangled by Claude Code's paste\n * handling. It says where the content is, so it reads right in the\n * transcript.\n */\nexport const NOTE_NUDGE =\n 'work has new notes for you (review feedback, CI results or comments); they are attached to this message. Work through them now.';\n\nexport function readPendingForSession(sessionId: string): Comment[] {\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n return readStoreComments(sessionId).filter(isPendingFor(delivered));\n}\n\n/** Comment-store ids for every `wd` scope that could cover this worktree.\n * A scope is keyed by `sha1` of its sorted repo roots (see\n * `repo-spec.scopeHashFor`), so from a session's paths we can rebuild the\n * exact ids without consulting `work web`'s in-memory scope registry:\n * - the whole-set hash → a group `wd` opened at the group root, or the\n * single-repo `wd` (one path);\n * - each individual path's hash → a `wd` opened inside one sub-repo of a\n * group worktree.\n * `registerScope` hashes `path.resolve()`d roots, so we resolve here too or\n * the hashes won't line up. Mirrors `scope-manager.commentStoreIdForScope`\n * (`scope-<hash>`). */\nfunction scopeStoreIdsForPaths(paths: string[]): string[] {\n const resolved = paths.map((p) => path.resolve(p));\n const ids = new Set<string>();\n ids.add(`scope-${scopeHashFor(resolved)}`);\n for (const p of resolved) ids.add(`scope-${scopeHashFor([p])}`);\n return [...ids];\n}\n\n/**\n * Pending comments for a whole worktree: the session's own comment store\n * PLUS any `wd` / `wd -c` scope review store covering the same paths.\n *\n * `wd` registers its review under a scope-hash comment store, not the\n * session store the hook reads — without this merge, comments left in the\n * `wd` review UI would never reach the Claude running in that worktree.\n * Delivered-tracking stays per-session (one `<sessionId>.delivered.json`),\n * so a comment surfaced here won't be re-delivered regardless of which\n * store it came from.\n */\nexport function readPendingForWorktree(session: WorktreeSession): Comment[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n const pending = isPendingFor(delivered);\n const seen = new Set<string>();\n const out: Comment[] = [];\n const collect = (storeId: string) => {\n for (const c of readStoreComments(storeId)) {\n if (seen.has(c.id) || !pending(c)) continue;\n seen.add(c.id);\n out.push(c);\n }\n };\n collect(sessionId);\n for (const storeId of scopeStoreIdsForPaths(session.paths)) collect(storeId);\n return out;\n}\n\n/**\n * What was handed to Claude is done once its turn really ends: your review\n * comments and work's notes to it (PR feedback, CI, a prompt you sent) —\n * every top-level comment of yours it was given, in the session's store and\n * any `wd` scope store over its paths — are marked resolved. Left open, they\n * piled up on the Diff tab's badge (three PR-watch notes read as \"3\"), to\n * resolve or delete by hand. Resolved threads stay listed (dimmed) and can\n * be reopened. Claude's own replies are left as they are. Returns the ids\n * resolved.\n */\nexport function resolveAddressed(session: WorktreeSession): string[] {\n const sessionId = sessionIdFor(session);\n const delivered = withDb((d) => deliveredIds(d, sessionId));\n if (delivered.size === 0) return [];\n const done: string[] = [];\n for (const storeId of [sessionId, ...scopeStoreIdsForPaths(session.paths)]) {\n const open = readStoreComments(storeId).filter(\n (c) => delivered.has(c.id) && c.author === 'user' && c.status === 'published' && !c.parentId && !c.resolved,\n );\n if (open.length === 0) continue;\n const store = getCommentFileStore(storeId);\n for (const c of open) if (store.setResolved(c.id, true)) done.push(c.id);\n }\n return done;\n}\n\n/** Persist a delivery batch, so these ids are never surfaced again. */\nexport function markDelivered(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n for (const id of ids) ins.run(sessionId, id);\n });\n}\n\n/**\n * Claim comments for delivery: of `ids`, return the ones nobody has\n * delivered yet, and mark them delivered — atomically. Two deliverers\n * racing (a Stop hook and the PTY push for the same comment) then can't\n * both send it: only the one that claimed it does. A deliverer whose send\n * fails gives the ids back with `releaseClaim`.\n */\nexport function claimForDelivery(sessionId: string, ids: string[]): string[] {\n if (ids.length === 0) return [];\n // INSERT OR IGNORE in one write transaction: a row inserted here is our\n // claim; one that already existed was someone else's.\n return tx((d) => {\n const ins = d.prepare('INSERT OR IGNORE INTO comment_deliveries (session_id, comment_id) VALUES (?, ?)');\n return ids.filter((id) => ins.run(sessionId, id).changes > 0);\n });\n}\n\n/** Undo a claim whose delivery failed, so the next hook picks them up. */\nexport function releaseClaim(sessionId: string, ids: string[]): void {\n if (ids.length === 0) return;\n tx((d) => {\n const del = d.prepare('DELETE FROM comment_deliveries WHERE session_id = ? AND comment_id = ?');\n for (const id of ids) del.run(sessionId, id);\n });\n}\n\n/** Cap the size of one comment body we surface to Claude. A pathologically\n * long comment shouldn't blow out Claude's context — we truncate, then\n * hint at the rest via \"(truncated)\". 4 KB is generous for a code-review\n * note while leaving headroom for batches. */\nconst MAX_BODY_BYTES = 4 * 1024;\n/** A general note: a prompt, or work's own note (a PR review round quotes\n * every thread, then a bot's overview). 4 KB once cut such a note before\n * the line telling Claude how to draft its replies. */\nconst MAX_NOTE_BYTES = 16 * 1024;\n/** Overall cap on the whole system-reminder payload. Multiple long\n * comments at once still get bounded — but room for four whole notes, since\n * the cut falls on the newest one's end: its instructions. */\nconst MAX_TOTAL_BYTES = 4 * MAX_NOTE_BYTES;\n\n/**\n * Format pending comments as a system-reminder block suitable for stdout.\n * Returns empty string when there's nothing pending — the caller (the\n * `work hook` CLI) just exits silently in that case.\n *\n * Truncates pathologically long bodies and caps the overall payload so\n * one runaway comment can't displace the rest of Claude's context.\n */\nexport function formatPendingForPrompt(pending: Comment[]): string {\n if (pending.length === 0) return '';\n\n const sorted = [...pending].sort((a, b) => a.createdAt.localeCompare(b.createdAt));\n\n const general = sorted.filter((c) => c.side === 'general' && !c.parentId);\n const inline = sorted.filter((c) => c.side !== 'general' && !c.parentId);\n const replies = sorted.filter((c) => c.parentId);\n\n const lines: string[] = [];\n lines.push('<system-reminder>');\n lines.push(`New review comments from \\`work web\\` (${pending.length} item${pending.length === 1 ? '' : 's'}):`);\n lines.push('');\n\n if (general.length > 0) {\n lines.push('## General notes');\n for (const c of general) {\n // General notes (this is where `work broadcast` lands) may be multi-line\n // prompts — deliver the whole body, not just line 1. Only the byte cap\n // applies. Inline/reply comments still use the one-line `formatBody`.\n lines.push(formatFullBody('-', c));\n }\n lines.push('');\n }\n\n if (inline.length > 0) {\n lines.push('## Inline comments');\n for (const c of inline) {\n const where = `${c.repo}/${c.file}:${c.line} (${c.side})`;\n lines.push(formatBody(`- ${where}`, c));\n }\n lines.push('');\n }\n\n if (replies.length > 0) {\n lines.push('## Replies');\n for (const c of replies) {\n lines.push(formatBody(`- (reply to ${c.parentId})`, c));\n }\n lines.push('');\n }\n\n lines.push(\n 'Address them as part of your next response. You can reply via the same review UI by posting back to the latest review URL at `~/.work/web.url` + `/api/sessions/<id>/comments` with `author: \"claude\"`.',\n );\n lines.push('</system-reminder>');\n const out = lines.join('\\n');\n if (out.length <= MAX_TOTAL_BYTES) return out;\n const trimmed = out.slice(0, MAX_TOTAL_BYTES - 200);\n return (\n trimmed +\n '\\n\\n(…review payload truncated for context-window safety; ' +\n `${pending.length} comment(s) total — open work web for the full list.)\\n` +\n '</system-reminder>'\n );\n}\n\nfunction formatBody(prefix: string, c: Comment): string {\n const lead = c.body.split('\\n')[0].trim();\n const capped = lead.length > MAX_BODY_BYTES ? `${lead.slice(0, MAX_BODY_BYTES)}…` : lead;\n return `${prefix}: ${capped}${c.body.includes('\\n') ? ' …' : ''}`;\n}\n\n/** Like `formatBody` but preserves the full multi-line body (only the note\n * cap applies). Multi-line bodies are emitted under the bullet, indented, so\n * a broadcast prompt arrives intact rather than truncated to its first line. */\nfunction formatFullBody(prefix: string, c: Comment): string {\n const body = c.body.trim();\n const capped = body.length > MAX_NOTE_BYTES ? `${body.slice(0, MAX_NOTE_BYTES)}…` : body;\n const bodyLines = capped.split('\\n');\n if (bodyLines.length === 1) return `${prefix}: ${bodyLines[0]}`;\n const [first, ...rest] = bodyLines;\n return [`${prefix}: ${first}`, ...rest.map((l) => ` ${l}`)].join('\\n');\n}\n\n/** Re-export so consumers don't have to know which module owns it. */\nexport { sessionIdFor };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAUV,SAAS,iBAAiB,UAAiC;AAChE,MAAI;AACF,UAAM,SAAS,KAAK,KAAK,UAAU,MAAM;AACzC,QAAI,SAAS;AACb,QAAI,GAAG,SAAS,MAAM,EAAE,OAAO,GAAG;AAChC,YAAM,IAAI,wBAAwB,KAAK,GAAG,aAAa,QAAQ,MAAM,CAAC;AACtE,UAAI,CAAC,EAAG,QAAO;AACf,eAAS,KAAK,QAAQ,UAAU,EAAE,CAAC,CAAC;AAAA,IACtC;AACA,WAAO,eAAe,GAAG,aAAa,KAAK,KAAK,QAAQ,MAAM,GAAG,MAAM,CAAC;AAAA,EAC1E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,eAAe,MAA6B;AAC1D,QAAM,IAAI,kCAAkC,KAAK,IAAI;AACrD,SAAO,IAAI,EAAE,CAAC,IAAI;AACpB;;;ACZA,OAAOA,SAAQ;AACf,OAAOC,WAAU;AAQjB,SAAS,aA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M,MAAM,MAAM,KAAK,IAAI;AAC3B,MAAI,IAAI,UAAU,gBAAiB,QAAO;AAC1C,QAAM,UAAU,IAAI,MAAM,GAAG,kBAAkB,GAAG;AAClD,SACE,UACA;AAAA;AAAA,6DACG,QAAQ,MAAM;AAAA;AAGrB;AAEA,SAAS,WAAW,QAAgB,GAAoB;AACtD,QAAM,OAAO,EAAE,KAAK,MAAM,IAAI,EAAE,CAAC,EAAE,KAAK;AACxC,QAAM,SAAS,KAAK,SAAS,iBAAiB,GAAG,KAAK,MAAM,GAAG,cAAc,CAAC,WAAM;AACpF,SAAO,GAAG,MAAM,KAAK,MAAM,GAAG,EAAE,KAAK,SAAS,IAAI,IAAI,YAAO,EAAE;AACjE;AAKA,SAAS,eAAe,QAAgB,GAAoB;AAC1D,QAAM,OAAO,EAAE,KAAK,KAAK;AACzB,QAAM,SAAS,KAAK,SAAS,iBAAiB,GAAG,KAAK,MAAM,GAAG,cAAc,CAAC,WAAM;AACpF,QAAM,YAAY,OAAO,MAAM,IAAI;AACnC,MAAI,UAAU,WAAW,EAAG,QAAO,GAAG,MAAM,KAAK,UAAU,CAAC,CAAC;AAC7D,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AACzB,SAAO,CAAC,GAAG,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,IAAI;AACxE;","names":["fs","path","path","fs"]}
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  isPidAlive,
4
4
  spawnDetachedWork
5
- } from "./chunk-PN44M5EE.js";
5
+ } from "./chunk-PMA7QPUV.js";
6
6
  import {
7
7
  ensureFile,
8
8
  getConfigDir,
@@ -227,4 +227,4 @@ export {
227
227
  ensureHost,
228
228
  PtyHostClient
229
229
  };
230
- //# sourceMappingURL=chunk-QBAZG4CY.js.map
230
+ //# sourceMappingURL=chunk-DJBOQU56.js.map
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  shownState
4
- } from "./chunk-6H3MLDGG.js";
4
+ } from "./chunk-BFLJ6PGX.js";
5
5
  import {
6
6
  defaultRunner
7
- } from "./chunk-ZXPYWZL5.js";
7
+ } from "./chunk-46UD4QBL.js";
8
8
  import {
9
9
  archiveDirFor,
10
10
  loadHistory,
11
11
  logSwallowed,
12
12
  readArchive,
13
13
  setSessionBase
14
- } from "./chunk-M4FVCAT6.js";
14
+ } from "./chunk-SBL4VVXD.js";
15
15
  import {
16
16
  sessionIdFor
17
- } from "./chunk-7NCW3LUT.js";
17
+ } from "./chunk-WF57CF7A.js";
18
18
  import {
19
19
  loadConfig
20
20
  } from "./chunk-7HEB6SQS.js";
@@ -418,4 +418,4 @@ export {
418
418
  moveOntoMain,
419
419
  updateSession
420
420
  };
421
- //# sourceMappingURL=chunk-JYTMT5DF.js.map
421
+ //# sourceMappingURL=chunk-DKKXDLMQ.js.map
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  computeDiff,
4
4
  isInsideRoot
5
- } from "./chunk-7OLPI334.js";
5
+ } from "./chunk-EF5GZEXK.js";
6
6
  import {
7
7
  packageRoot
8
8
  } from "./chunk-LNHSBM4L.js";
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  createFsWatcher,
14
14
  loadHistory
15
- } from "./chunk-M4FVCAT6.js";
15
+ } from "./chunk-SBL4VVXD.js";
16
16
  import {
17
17
  spawn_default
18
18
  } from "./chunk-RCYI7SRA.js";
@@ -484,4 +484,4 @@ export {
484
484
  submitReviewSchema,
485
485
  resolveSchema
486
486
  };
487
- //# sourceMappingURL=chunk-IXKVCR4Y.js.map
487
+ //# sourceMappingURL=chunk-E4GZGQWP.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-7NAXFBFI.js";
5
5
  import {
6
6
  writeTempTree
7
- } from "./chunk-M4FVCAT6.js";
7
+ } from "./chunk-SBL4VVXD.js";
8
8
  import {
9
9
  spawn_default
10
10
  } from "./chunk-RCYI7SRA.js";
@@ -534,4 +534,4 @@ export {
534
534
  computeDiff,
535
535
  computeRangeDiff
536
536
  };
537
- //# sourceMappingURL=chunk-7OLPI334.js.map
537
+ //# sourceMappingURL=chunk-EF5GZEXK.js.map
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  loadHistory
4
- } from "./chunk-M4FVCAT6.js";
4
+ } from "./chunk-SBL4VVXD.js";
5
5
  import {
6
6
  json,
7
7
  sessionIdFor,
8
8
  tx,
9
9
  withDb
10
- } from "./chunk-7NCW3LUT.js";
10
+ } from "./chunk-WF57CF7A.js";
11
11
 
12
12
  // src/core/rail/blocks.ts
13
13
  var MAX_BLOCKERS = 10;
@@ -148,4 +148,4 @@ export {
148
148
  sweepBlocks,
149
149
  blockRefFrom
150
150
  };
151
- //# sourceMappingURL=chunk-YZWADOEW.js.map
151
+ //# sourceMappingURL=chunk-EY3ZPJT3.js.map
@@ -27,13 +27,13 @@ import {
27
27
  upsertSession,
28
28
  upsertSessionWithPort,
29
29
  writeArchiveRecord
30
- } from "./chunk-M4FVCAT6.js";
30
+ } from "./chunk-SBL4VVXD.js";
31
31
  import {
32
32
  sessionIdFor
33
- } from "./chunk-7NCW3LUT.js";
33
+ } from "./chunk-WF57CF7A.js";
34
34
  import {
35
35
  agentFor
36
- } from "./chunk-PN44M5EE.js";
36
+ } from "./chunk-PMA7QPUV.js";
37
37
  import {
38
38
  report
39
39
  } from "./chunk-DW4JPVXB.js";
@@ -665,4 +665,4 @@ export {
665
665
  teardownWorktree,
666
666
  openBaseCheckout
667
667
  };
668
- //# sourceMappingURL=chunk-CLGVSX36.js.map
668
+ //# sourceMappingURL=chunk-EYZG4MR6.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  defaultRunner
4
- } from "./chunk-ZXPYWZL5.js";
4
+ } from "./chunk-46UD4QBL.js";
5
5
 
6
6
  // src/core/cleanup/build-folders.ts
7
7
  import fs from "fs";
@@ -109,4 +109,4 @@ export {
109
109
  buildFoldersOf,
110
110
  clearBuildFolders
111
111
  };
112
- //# sourceMappingURL=chunk-NDWSLQPB.js.map
112
+ //# sourceMappingURL=chunk-FOG4WG3Y.js.map
@@ -5,7 +5,7 @@ import {
5
5
  samePathKey,
6
6
  scanForRepos,
7
7
  suggestAlias
8
- } from "./chunk-R2LN3JJJ.js";
8
+ } from "./chunk-BSCAA322.js";
9
9
  import {
10
10
  atomicWriteFile,
11
11
  getConfigDir,
@@ -162,4 +162,4 @@ export {
162
162
  saveGroup,
163
163
  deleteGroup
164
164
  };
165
- //# sourceMappingURL=chunk-YZDD5YGE.js.map
165
+ //# sourceMappingURL=chunk-G2O7EIKX.js.map
@@ -1,32 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  defaultArchiveDeps
4
- } from "./chunk-2PRI27ND.js";
4
+ } from "./chunk-2P26VJY3.js";
5
5
  import {
6
6
  normPath
7
7
  } from "./chunk-AKMPF72Y.js";
8
8
  import {
9
9
  teardownWorktree
10
- } from "./chunk-CLGVSX36.js";
10
+ } from "./chunk-EYZG4MR6.js";
11
11
  import {
12
12
  disposePty
13
- } from "./chunk-O3QTWVSK.js";
13
+ } from "./chunk-LQCYTZ2F.js";
14
14
  import {
15
15
  fetchRemoteAsync
16
16
  } from "./chunk-7NAXFBFI.js";
17
17
  import {
18
18
  defaultRunner
19
- } from "./chunk-ZXPYWZL5.js";
19
+ } from "./chunk-46UD4QBL.js";
20
20
  import {
21
21
  archiveSession,
22
22
  loadHistory,
23
23
  readSessionActivity,
24
24
  readStatus,
25
25
  removeSession
26
- } from "./chunk-M4FVCAT6.js";
26
+ } from "./chunk-SBL4VVXD.js";
27
27
  import {
28
28
  sessionIdFor
29
- } from "./chunk-7NCW3LUT.js";
29
+ } from "./chunk-WF57CF7A.js";
30
30
  import {
31
31
  loadConfig
32
32
  } from "./chunk-7HEB6SQS.js";
@@ -159,4 +159,4 @@ function defaultCleanupDeps(opts = {}) {
159
159
  export {
160
160
  defaultCleanupDeps
161
161
  };
162
- //# sourceMappingURL=chunk-OYQFLBLO.js.map
162
+ //# sourceMappingURL=chunk-IAOFCBAO.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-LNHSBM4L.js";
5
5
  import {
6
6
  knownAgents
7
- } from "./chunk-PN44M5EE.js";
7
+ } from "./chunk-PMA7QPUV.js";
8
8
 
9
9
  // src/commands/install-skills.ts
10
10
  import chalk from "chalk";
@@ -44,4 +44,4 @@ export {
44
44
  runInstallSkills,
45
45
  installSkillsCommand
46
46
  };
47
- //# sourceMappingURL=chunk-Q6WZCO45.js.map
47
+ //# sourceMappingURL=chunk-IISQUS7L.js.map
@@ -6,7 +6,7 @@ import {
6
6
  json,
7
7
  tx,
8
8
  withDb
9
- } from "./chunk-7NCW3LUT.js";
9
+ } from "./chunk-WF57CF7A.js";
10
10
 
11
11
  // src/core/comments/comment-file-store.ts
12
12
  function isComment(x) {
@@ -109,4 +109,4 @@ export {
109
109
  readStoreComments,
110
110
  getCommentFileStore
111
111
  };
112
- //# sourceMappingURL=chunk-5QK7GB5K.js.map
112
+ //# sourceMappingURL=chunk-JJRPLNLN.js.map
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  computeRangeDiff
4
- } from "./chunk-7OLPI334.js";
4
+ } from "./chunk-EF5GZEXK.js";
5
5
  import {
6
6
  loadManifest
7
- } from "./chunk-M4FVCAT6.js";
7
+ } from "./chunk-SBL4VVXD.js";
8
8
  import {
9
9
  agentSettings,
10
10
  internalAgent,
11
11
  internalRunEnv,
12
12
  killTree
13
- } from "./chunk-PN44M5EE.js";
13
+ } from "./chunk-PMA7QPUV.js";
14
14
  import {
15
15
  spawn_default
16
16
  } from "./chunk-RCYI7SRA.js";
@@ -185,4 +185,4 @@ export {
185
185
  runInternal,
186
186
  summarizeCheckpoint
187
187
  };
188
- //# sourceMappingURL=chunk-FR3EWVXI.js.map
188
+ //# sourceMappingURL=chunk-KNKXGEPJ.js.map
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  defaultRunner
4
- } from "./chunk-ZXPYWZL5.js";
4
+ } from "./chunk-46UD4QBL.js";
5
5
  import {
6
6
  logSwallowed
7
- } from "./chunk-M4FVCAT6.js";
7
+ } from "./chunk-SBL4VVXD.js";
8
8
 
9
9
  // src/core/diff/diff-stat.ts
10
10
  import fs from "fs";
@@ -207,4 +207,4 @@ export {
207
207
  wantsDiffStat,
208
208
  findOverlaps
209
209
  };
210
- //# sourceMappingURL=chunk-4BOK2GXL.js.map
210
+ //# sourceMappingURL=chunk-KPVCQBHZ.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  buildAiLaunchArgs
4
- } from "./chunk-PN44M5EE.js";
4
+ } from "./chunk-PMA7QPUV.js";
5
5
  import {
6
6
  spawn_default
7
7
  } from "./chunk-RCYI7SRA.js";
@@ -34,4 +34,4 @@ export {
34
34
  openVSCode,
35
35
  launchAi
36
36
  };
37
- //# sourceMappingURL=chunk-P3BL4EOP.js.map
37
+ //# sourceMappingURL=chunk-LC2UWKAQ.js.map