@moberg_hr/work-tree 2.0.6 → 2.0.8

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 (180) hide show
  1. package/dist/{answer-AX2VHEXS.js → answer-QQAEJ5N3.js} +4 -4
  2. package/dist/{attach-WLJVKXOJ.js → attach-XG3Y7QA7.js} +6 -6
  3. package/dist/bin.js +2 -2
  4. package/dist/{block-NZJC7GVM.js → block-WW4BWDN7.js} +5 -5
  5. package/dist/{broadcast-JPVHPQ6Y.js → broadcast-LEOMDVSA.js} +2 -2
  6. package/dist/{catchup-RUNKM6ZH.js → catchup-UBHGEMED.js} +7 -7
  7. package/dist/chunk-34QBYOHC.js +9 -0
  8. package/dist/{chunk-BSCAA322.js → chunk-4V7C3O6V.js} +22 -8
  9. package/dist/chunk-4V7C3O6V.js.map +1 -0
  10. package/dist/{chunk-46UD4QBL.js → chunk-5RRKVAIZ.js} +3 -2
  11. package/dist/chunk-5RRKVAIZ.js.map +1 -0
  12. package/dist/{chunk-EK3WRCQX.js → chunk-6AULWNAN.js} +3 -3
  13. package/dist/{chunk-UI5MPBIH.js → chunk-73J2ZJA6.js} +3 -3
  14. package/dist/{chunk-ES3KY6YT.js → chunk-7IZW6GLY.js} +2 -2
  15. package/dist/chunk-BLCAZAU5.js +334 -0
  16. package/dist/chunk-BLCAZAU5.js.map +1 -0
  17. package/dist/{chunk-G2O7EIKX.js → chunk-E72ETFAB.js} +2 -2
  18. package/dist/{chunk-7OUBCJVJ.js → chunk-E74YIDHX.js} +6 -6
  19. package/dist/{chunk-X5EMINGT.js → chunk-EN24GJCO.js} +4 -4
  20. package/dist/{chunk-5S3ORHTD.js → chunk-F3SPCHLH.js} +6 -6
  21. package/dist/{chunk-DUUH6FPH.js → chunk-G5PN5NIS.js} +28 -4
  22. package/dist/chunk-G5PN5NIS.js.map +1 -0
  23. package/dist/{chunk-65DPISNE.js → chunk-HLXEMPEI.js} +2 -2
  24. package/dist/{chunk-52IEEAYJ.js → chunk-I5HHTEAA.js} +4 -4
  25. package/dist/{chunk-CK2QC2UF.js → chunk-IC5PFQCV.js} +2 -2
  26. package/dist/{chunk-ED7E2WKK.js → chunk-JYWCNLZN.js} +2 -2
  27. package/dist/{chunk-LZHCTPBF.js → chunk-KLK6O54M.js} +3 -3
  28. package/dist/{chunk-FOG4WG3Y.js → chunk-LNMIG35F.js} +6 -2
  29. package/dist/chunk-LNMIG35F.js.map +1 -0
  30. package/dist/{chunk-67IZNVDI.js → chunk-LXM7QFBK.js} +2 -2
  31. package/dist/chunk-MFSKRN2J.js +78 -0
  32. package/dist/chunk-MFSKRN2J.js.map +1 -0
  33. package/dist/{chunk-HIXC67MU.js → chunk-MXZRFWC3.js} +3 -3
  34. package/dist/{chunk-KZQDONTU.js → chunk-NIRVJMJL.js} +12 -5
  35. package/dist/chunk-NIRVJMJL.js.map +1 -0
  36. package/dist/{chunk-HZEYGMYK.js → chunk-P2U6R35K.js} +3 -3
  37. package/dist/{chunk-ESPZRTUB.js → chunk-PG2MPTZD.js} +4 -4
  38. package/dist/{chunk-XHOQ7BWT.js → chunk-QQNI3K3V.js} +3 -3
  39. package/dist/{chunk-YCDULFF5.js → chunk-SIHAOB4F.js} +3 -3
  40. package/dist/{chunk-MODMK7WQ.js → chunk-ULQQ6SXT.js} +3 -3
  41. package/dist/{chunk-R7BXN427.js → chunk-UNLBHYA5.js} +2 -2
  42. package/dist/{chunk-XBNLSKTX.js → chunk-UZROMRQM.js} +3 -3
  43. package/dist/{chunk-UNPEZODB.js → chunk-V4RQ72HY.js} +28 -20
  44. package/dist/chunk-V4RQ72HY.js.map +1 -0
  45. package/dist/{chunk-QQJF4R6J.js → chunk-WB2BP2G5.js} +2 -2
  46. package/dist/{chunk-5653XPLJ.js → chunk-WOCS6MLE.js} +42 -42
  47. package/dist/{chunk-6GCF2XWP.js → chunk-WTR5BUGS.js} +20 -1
  48. package/dist/chunk-WTR5BUGS.js.map +1 -0
  49. package/dist/{chunk-WQMY4AJR.js → chunk-WUWED3LV.js} +2 -2
  50. package/dist/{chunk-N23HFT4X.js → chunk-YZSSYD2G.js} +244 -54
  51. package/dist/chunk-YZSSYD2G.js.map +1 -0
  52. package/dist/{cleanup-QLN3C3H5.js → cleanup-6LIZ3BQF.js} +16 -15
  53. package/dist/{cleanup-QLN3C3H5.js.map → cleanup-6LIZ3BQF.js.map} +1 -1
  54. package/dist/{cli-MIBNJRX6.js → cli-R3FITDNB.js} +3 -3
  55. package/dist/{config-TPYNBTVM.js → config-DULJPECI.js} +6 -6
  56. package/dist/{diff-IDF3K74H.js → diff-2PPFXZD6.js} +4 -4
  57. package/dist/{digest-AXSMYBYS.js → digest-5CRGAAK5.js} +4 -4
  58. package/dist/{fork-Y4PJNRUB.js → fork-FYEV4TU2.js} +15 -13
  59. package/dist/{fork-Y4PJNRUB.js.map → fork-FYEV4TU2.js.map} +1 -1
  60. package/dist/{hook-QMW5HHNP.js → hook-U37AFPKY.js} +4 -4
  61. package/dist/{hydrate-XMHHC5EG.js → hydrate-MAFHTY2W.js} +2 -2
  62. package/dist/{init-NGL64E3F.js → init-276XRZS2.js} +6 -6
  63. package/dist/{move-FFQR5TEI.js → move-QHCDO2R5.js} +14 -15
  64. package/dist/move-QHCDO2R5.js.map +1 -0
  65. package/dist/{note-C4RNIDRJ.js → note-TNC633NG.js} +4 -4
  66. package/dist/{overlaps-3LZXSDYZ.js → overlaps-SEK7H2YB.js} +5 -5
  67. package/dist/{pin-TJBCJGPQ.js → pin-E53PGMGD.js} +4 -4
  68. package/dist/{pr-JM4DRRIV.js → pr-JMMUGCKS.js} +5 -5
  69. package/dist/{prune-63N3QNDR.js → prune-MR37KLIW.js} +15 -14
  70. package/dist/{prune-63N3QNDR.js.map → prune-MR37KLIW.js.map} +1 -1
  71. package/dist/{pty-host-MQSUN6EI.js → pty-host-36Y4XSPP.js} +14 -7
  72. package/dist/pty-host-36Y4XSPP.js.map +1 -0
  73. package/dist/{read-NU4WZ3J5.js → read-ESOOJSBO.js} +4 -4
  74. package/dist/{recent-ZW4WDGCK.js → recent-3WYFF36X.js} +2 -2
  75. package/dist/{remove-ADWLTOFS.js → remove-5IZVMK4V.js} +14 -13
  76. package/dist/{remove-ADWLTOFS.js.map → remove-5IZVMK4V.js.map} +1 -1
  77. package/dist/{resume-SLNE75JO.js → resume-NDE6NKKT.js} +2 -2
  78. package/dist/{run-MD77Z2BV.js → run-UW4BJCSC.js} +2 -2
  79. package/dist/{screen-RCUGD52V.js → screen-5BLTXIKS.js} +4 -4
  80. package/dist/{search-5GK5HL4Y.js → search-MK6R5VR6.js} +2 -2
  81. package/dist/{section-OAMRNSO7.js → section-B4BWRY7K.js} +4 -4
  82. package/dist/{send-TT6U64HQ.js → send-OT3OXHHW.js} +5 -5
  83. package/dist/{sessions-CAOAXKKG.js → sessions-LHMTS6KT.js} +12 -10
  84. package/dist/{sessions-CAOAXKKG.js.map → sessions-LHMTS6KT.js.map} +1 -1
  85. package/dist/{snooze-DBJJD6ZM.js → snooze-A2BVEYWD.js} +4 -4
  86. package/dist/{start-2KUDSMBM.js → start-LEYVJWZG.js} +4 -4
  87. package/dist/{status-S3NZTRG3.js → status-AO653RKW.js} +2 -2
  88. package/dist/{stop-KJHXWYZ2.js → stop-QYIRUR5Y.js} +4 -4
  89. package/dist/{sync-EVPQVVWT.js → sync-SAZVBQIH.js} +15 -14
  90. package/dist/{sync-EVPQVVWT.js.map → sync-SAZVBQIH.js.map} +1 -1
  91. package/dist/{time-MWABXPA6.js → time-4V56YERF.js} +5 -5
  92. package/dist/{tree-O4VADOFG.js → tree-WFOG72Z3.js} +37 -6
  93. package/dist/tree-WFOG72Z3.js.map +1 -0
  94. package/dist/{update-K73WHYY3.js → update-NU5EMISM.js} +7 -7
  95. package/dist/{wait-JZIJB6P6.js → wait-FW7RARBV.js} +5 -5
  96. package/dist/wd-bin.js +2 -2
  97. package/dist/web/assets/PtyView-DQw8g-PN.js +90 -0
  98. package/dist/web/assets/PtyView-DQw8g-PN.js.map +1 -0
  99. package/dist/web/assets/index-CO_OtClq.js +118 -0
  100. package/dist/web/assets/index-CO_OtClq.js.map +1 -0
  101. package/dist/web/assets/index-D-_oxT3O.css +1 -0
  102. package/dist/web/index.html +2 -2
  103. package/dist/{web-GN2ATEXW.js → web-DTVGZZDZ.js} +199 -335
  104. package/dist/web-DTVGZZDZ.js.map +1 -0
  105. package/npm-shrinkwrap.json +2 -2
  106. package/package.json +1 -1
  107. package/dist/chunk-46UD4QBL.js.map +0 -1
  108. package/dist/chunk-6GCF2XWP.js.map +0 -1
  109. package/dist/chunk-BSCAA322.js.map +0 -1
  110. package/dist/chunk-DUUH6FPH.js.map +0 -1
  111. package/dist/chunk-FOG4WG3Y.js.map +0 -1
  112. package/dist/chunk-KZQDONTU.js.map +0 -1
  113. package/dist/chunk-MNZOOANK.js +0 -9
  114. package/dist/chunk-N23HFT4X.js.map +0 -1
  115. package/dist/chunk-UNPEZODB.js.map +0 -1
  116. package/dist/move-FFQR5TEI.js.map +0 -1
  117. package/dist/pty-host-MQSUN6EI.js.map +0 -1
  118. package/dist/tree-O4VADOFG.js.map +0 -1
  119. package/dist/web/assets/PtyView-DBMOq3Ro.js +0 -90
  120. package/dist/web/assets/PtyView-DBMOq3Ro.js.map +0 -1
  121. package/dist/web/assets/index-CV8NpZB8.css +0 -1
  122. package/dist/web/assets/index-DvFWtkAs.js +0 -117
  123. package/dist/web/assets/index-DvFWtkAs.js.map +0 -1
  124. package/dist/web-GN2ATEXW.js.map +0 -1
  125. /package/dist/{answer-AX2VHEXS.js.map → answer-QQAEJ5N3.js.map} +0 -0
  126. /package/dist/{attach-WLJVKXOJ.js.map → attach-XG3Y7QA7.js.map} +0 -0
  127. /package/dist/{block-NZJC7GVM.js.map → block-WW4BWDN7.js.map} +0 -0
  128. /package/dist/{broadcast-JPVHPQ6Y.js.map → broadcast-LEOMDVSA.js.map} +0 -0
  129. /package/dist/{catchup-RUNKM6ZH.js.map → catchup-UBHGEMED.js.map} +0 -0
  130. /package/dist/{chunk-MNZOOANK.js.map → chunk-34QBYOHC.js.map} +0 -0
  131. /package/dist/{chunk-EK3WRCQX.js.map → chunk-6AULWNAN.js.map} +0 -0
  132. /package/dist/{chunk-UI5MPBIH.js.map → chunk-73J2ZJA6.js.map} +0 -0
  133. /package/dist/{chunk-ES3KY6YT.js.map → chunk-7IZW6GLY.js.map} +0 -0
  134. /package/dist/{chunk-G2O7EIKX.js.map → chunk-E72ETFAB.js.map} +0 -0
  135. /package/dist/{chunk-7OUBCJVJ.js.map → chunk-E74YIDHX.js.map} +0 -0
  136. /package/dist/{chunk-X5EMINGT.js.map → chunk-EN24GJCO.js.map} +0 -0
  137. /package/dist/{chunk-5S3ORHTD.js.map → chunk-F3SPCHLH.js.map} +0 -0
  138. /package/dist/{chunk-65DPISNE.js.map → chunk-HLXEMPEI.js.map} +0 -0
  139. /package/dist/{chunk-52IEEAYJ.js.map → chunk-I5HHTEAA.js.map} +0 -0
  140. /package/dist/{chunk-CK2QC2UF.js.map → chunk-IC5PFQCV.js.map} +0 -0
  141. /package/dist/{chunk-ED7E2WKK.js.map → chunk-JYWCNLZN.js.map} +0 -0
  142. /package/dist/{chunk-LZHCTPBF.js.map → chunk-KLK6O54M.js.map} +0 -0
  143. /package/dist/{chunk-67IZNVDI.js.map → chunk-LXM7QFBK.js.map} +0 -0
  144. /package/dist/{chunk-HIXC67MU.js.map → chunk-MXZRFWC3.js.map} +0 -0
  145. /package/dist/{chunk-HZEYGMYK.js.map → chunk-P2U6R35K.js.map} +0 -0
  146. /package/dist/{chunk-ESPZRTUB.js.map → chunk-PG2MPTZD.js.map} +0 -0
  147. /package/dist/{chunk-XHOQ7BWT.js.map → chunk-QQNI3K3V.js.map} +0 -0
  148. /package/dist/{chunk-YCDULFF5.js.map → chunk-SIHAOB4F.js.map} +0 -0
  149. /package/dist/{chunk-MODMK7WQ.js.map → chunk-ULQQ6SXT.js.map} +0 -0
  150. /package/dist/{chunk-R7BXN427.js.map → chunk-UNLBHYA5.js.map} +0 -0
  151. /package/dist/{chunk-XBNLSKTX.js.map → chunk-UZROMRQM.js.map} +0 -0
  152. /package/dist/{chunk-QQJF4R6J.js.map → chunk-WB2BP2G5.js.map} +0 -0
  153. /package/dist/{chunk-5653XPLJ.js.map → chunk-WOCS6MLE.js.map} +0 -0
  154. /package/dist/{chunk-WQMY4AJR.js.map → chunk-WUWED3LV.js.map} +0 -0
  155. /package/dist/{cli-MIBNJRX6.js.map → cli-R3FITDNB.js.map} +0 -0
  156. /package/dist/{config-TPYNBTVM.js.map → config-DULJPECI.js.map} +0 -0
  157. /package/dist/{diff-IDF3K74H.js.map → diff-2PPFXZD6.js.map} +0 -0
  158. /package/dist/{digest-AXSMYBYS.js.map → digest-5CRGAAK5.js.map} +0 -0
  159. /package/dist/{hook-QMW5HHNP.js.map → hook-U37AFPKY.js.map} +0 -0
  160. /package/dist/{hydrate-XMHHC5EG.js.map → hydrate-MAFHTY2W.js.map} +0 -0
  161. /package/dist/{init-NGL64E3F.js.map → init-276XRZS2.js.map} +0 -0
  162. /package/dist/{note-C4RNIDRJ.js.map → note-TNC633NG.js.map} +0 -0
  163. /package/dist/{overlaps-3LZXSDYZ.js.map → overlaps-SEK7H2YB.js.map} +0 -0
  164. /package/dist/{pin-TJBCJGPQ.js.map → pin-E53PGMGD.js.map} +0 -0
  165. /package/dist/{pr-JM4DRRIV.js.map → pr-JMMUGCKS.js.map} +0 -0
  166. /package/dist/{read-NU4WZ3J5.js.map → read-ESOOJSBO.js.map} +0 -0
  167. /package/dist/{recent-ZW4WDGCK.js.map → recent-3WYFF36X.js.map} +0 -0
  168. /package/dist/{resume-SLNE75JO.js.map → resume-NDE6NKKT.js.map} +0 -0
  169. /package/dist/{run-MD77Z2BV.js.map → run-UW4BJCSC.js.map} +0 -0
  170. /package/dist/{screen-RCUGD52V.js.map → screen-5BLTXIKS.js.map} +0 -0
  171. /package/dist/{search-5GK5HL4Y.js.map → search-MK6R5VR6.js.map} +0 -0
  172. /package/dist/{section-OAMRNSO7.js.map → section-B4BWRY7K.js.map} +0 -0
  173. /package/dist/{send-TT6U64HQ.js.map → send-OT3OXHHW.js.map} +0 -0
  174. /package/dist/{snooze-DBJJD6ZM.js.map → snooze-A2BVEYWD.js.map} +0 -0
  175. /package/dist/{start-2KUDSMBM.js.map → start-LEYVJWZG.js.map} +0 -0
  176. /package/dist/{status-S3NZTRG3.js.map → status-AO653RKW.js.map} +0 -0
  177. /package/dist/{stop-KJHXWYZ2.js.map → stop-QYIRUR5Y.js.map} +0 -0
  178. /package/dist/{time-MWABXPA6.js.map → time-4V56YERF.js.map} +0 -0
  179. /package/dist/{update-K73WHYY3.js.map → update-NU5EMISM.js.map} +0 -0
  180. /package/dist/{wait-JZIJB6P6.js.map → wait-FW7RARBV.js.map} +0 -0
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ isLeftover,
4
+ putLeftoverBack,
5
+ setLeftoverAside,
6
+ takeLeftover
7
+ } from "./chunk-MFSKRN2J.js";
2
8
  import {
3
9
  resolveProjectTarget
4
10
  } from "./chunk-H5LKMR45.js";
@@ -14,6 +20,9 @@ import {
14
20
  remoteBranchExists,
15
21
  repoState
16
22
  } from "./chunk-7NAXFBFI.js";
23
+ import {
24
+ isBuildOutputPath
25
+ } from "./chunk-LNMIG35F.js";
17
26
  import {
18
27
  archiveDirFor,
19
28
  archiveRoot,
@@ -24,11 +33,12 @@ import {
24
33
  readArchive,
25
34
  restoreArchivedTranscripts,
26
35
  restoreUncommitted,
36
+ runGitAsync,
27
37
  setSessionTitle,
28
38
  upsertSession,
29
39
  upsertSessionWithPort,
30
40
  writeArchiveRecord
31
- } from "./chunk-DUUH6FPH.js";
41
+ } from "./chunk-G5PN5NIS.js";
32
42
  import {
33
43
  sessionIdFor
34
44
  } from "./chunk-WF57CF7A.js";
@@ -96,10 +106,116 @@ function toBaseSpec(base) {
96
106
  }
97
107
 
98
108
  // src/core/worktree/worktree.ts
99
- import fs2 from "fs";
109
+ import fs3 from "fs";
100
110
 
101
111
  // src/core/archive/archive-restore.ts
112
+ import path2 from "path";
113
+
114
+ // src/core/archive/archive-ignored.ts
115
+ import fs from "fs";
102
116
  import path from "path";
117
+ var MAX_IGNORED_FILE_BYTES = 5 * 1024 * 1024;
118
+ var MAX_IGNORED_TOTAL_BYTES = 50 * 1024 * 1024;
119
+ var MAX_IGNORED_FILES = 5e3;
120
+ var HEAVY = /* @__PURE__ */ new Set([
121
+ ".venv",
122
+ "venv",
123
+ "packages",
124
+ ".pnpm-store",
125
+ ".yarn",
126
+ ".cache",
127
+ ".terraform",
128
+ ".tox",
129
+ ".mypy_cache",
130
+ ".ruff_cache",
131
+ ".dart_tool"
132
+ ]);
133
+ var leftOut = (rel) => isBuildOutputPath(rel) || rel.split(/[\\/]/).some((seg) => HEAVY.has(seg));
134
+ async function ignoredFiles(worktree, max = MAX_IGNORED_FILES) {
135
+ const r = await runGitAsync(worktree, { args: ["ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"] });
136
+ if (r.status !== 0) return { files: [], more: false };
137
+ const files = [];
138
+ let more = false;
139
+ const walk = async (rel) => {
140
+ let entries2;
141
+ try {
142
+ entries2 = await fs.promises.readdir(path.join(worktree, rel), { withFileTypes: true });
143
+ } catch {
144
+ return;
145
+ }
146
+ for (const e of entries2) {
147
+ if (files.length >= max) {
148
+ more = true;
149
+ return;
150
+ }
151
+ const r2 = path.join(rel, e.name);
152
+ if (leftOut(r2)) continue;
153
+ if (e.isDirectory()) await walk(r2);
154
+ else if (e.isFile()) files.push(r2);
155
+ }
156
+ };
157
+ const entries = r.stdout.split("\0").filter(Boolean);
158
+ const dirs = entries.filter((e) => e.endsWith("/") && !leftOut(e.replace(/\/$/, "")));
159
+ const ignoredDirs = /* @__PURE__ */ new Set();
160
+ if (dirs.length) {
161
+ const check = await runGitAsync(worktree, { args: ["check-ignore", "--", ...dirs] });
162
+ for (const d of check.stdout.split(/\r?\n/).filter(Boolean)) ignoredDirs.add(d.replace(/\/$/, ""));
163
+ }
164
+ for (const entry of entries) {
165
+ if (files.length >= max) {
166
+ more = true;
167
+ break;
168
+ }
169
+ const rel = entry.replace(/\/$/, "");
170
+ if (leftOut(rel)) continue;
171
+ if (!entry.endsWith("/")) files.push(path.normalize(rel));
172
+ else if (ignoredDirs.has(rel)) await walk(path.normalize(rel));
173
+ }
174
+ return { files: [...new Set(files)], more };
175
+ }
176
+ async function saveIgnored(worktree, dest, caps = { file: MAX_IGNORED_FILE_BYTES, total: MAX_IGNORED_TOTAL_BYTES, files: MAX_IGNORED_FILES }) {
177
+ const saved = { files: 0, bytes: 0, skipped: 0 };
178
+ const listed = await ignoredFiles(worktree, caps.files);
179
+ if (listed.more) saved.partial = true;
180
+ const sized = [];
181
+ for (const rel of listed.files) {
182
+ try {
183
+ sized.push({ rel, size: (await fs.promises.stat(path.join(worktree, rel))).size });
184
+ } catch {
185
+ }
186
+ }
187
+ sized.sort((a, b) => a.size - b.size || a.rel.localeCompare(b.rel));
188
+ for (const { rel, size } of sized) {
189
+ if (size > caps.file || saved.bytes + size > caps.total) {
190
+ saved.skipped++;
191
+ continue;
192
+ }
193
+ try {
194
+ await fs.promises.mkdir(path.dirname(path.join(dest, rel)), { recursive: true });
195
+ await fs.promises.copyFile(path.join(worktree, rel), path.join(dest, rel));
196
+ saved.files++;
197
+ saved.bytes += size;
198
+ } catch {
199
+ saved.skipped++;
200
+ }
201
+ }
202
+ return saved;
203
+ }
204
+ function restoreIgnored(src, worktree) {
205
+ if (!fs.existsSync(src)) return 0;
206
+ let n = 0;
207
+ fs.cpSync(src, worktree, {
208
+ recursive: true,
209
+ force: true,
210
+ filter: (from) => {
211
+ if (fs.statSync(from).isFile()) n++;
212
+ return true;
213
+ }
214
+ });
215
+ return n;
216
+ }
217
+
218
+ // src/core/archive/archive-restore.ts
103
219
  async function restoreArchivedUncommitted(s, config, root = archiveRoot()) {
104
220
  const id = sessionIdFor(s);
105
221
  const rec = readArchive(id, root);
@@ -126,20 +242,45 @@ async function restoreArchivedUncommitted(s, config, root = archiveRoot()) {
126
242
  if (changed) writeArchiveRecord(rec, root);
127
243
  return out;
128
244
  }
245
+ function restoreArchivedIgnored(s, config, root = archiveRoot()) {
246
+ const id = sessionIdFor(s);
247
+ const rec = readArchive(id, root);
248
+ if (!rec?.worktreeRemoved || !rec.ignored) return [];
249
+ const dir = archiveDirFor(id, root);
250
+ const done = [];
251
+ let changed = false;
252
+ for (const [alias, saved] of Object.entries(rec.ignored)) {
253
+ if (saved.restoredAt || saved.restoreError) continue;
254
+ const wt = worktreeFor(s, alias, config);
255
+ if (!wt) continue;
256
+ try {
257
+ const n = restoreIgnored(path2.join(dir, "ignored", alias), wt);
258
+ saved.restoredAt = (/* @__PURE__ */ new Date()).toISOString();
259
+ done.push(alias);
260
+ if (n) report("info", `${alias}: put back ${n} git-ignored file${n === 1 ? "" : "s"} (local settings, editor state) it had`);
261
+ } catch (err) {
262
+ saved.restoreError = err.message;
263
+ report("warn", `${alias}: its local settings from the archive weren't all put back: ${saved.restoreError}`);
264
+ }
265
+ changed = true;
266
+ }
267
+ if (changed) writeArchiveRecord(rec, root);
268
+ return done;
269
+ }
129
270
  function worktreeFor(s, alias, config) {
130
271
  if (!s.isGroup) return s.paths[0] ?? null;
131
272
  const repo = config.repos[alias];
132
273
  if (!repo) return null;
133
- const name = path.basename(repo).toLowerCase();
134
- return s.paths.find((p) => path.basename(p).toLowerCase() === name) ?? null;
274
+ const name = path2.basename(repo).toLowerCase();
275
+ return s.paths.find((p) => path2.basename(p).toLowerCase() === name) ?? null;
135
276
  }
136
277
 
137
278
  // src/core/worktree/worktree.ts
138
- import path3 from "path";
279
+ import path4 from "path";
139
280
 
140
281
  // src/core/worktree/copy-files.ts
141
- import fs from "fs";
142
- import path2 from "path";
282
+ import fs2 from "fs";
283
+ import path3 from "path";
143
284
  import { globSync } from "glob";
144
285
  var EXCLUDED_DIRS = ["bin", "obj", "node_modules", ".git"];
145
286
  function copyConfigFiles(repoPath, worktreePath, patterns) {
@@ -147,12 +288,12 @@ function copyConfigFiles(repoPath, worktreePath, patterns) {
147
288
  const normalized = pattern.replace(/\\/g, "/");
148
289
  if (normalized.startsWith(".claude/")) {
149
290
  const relativePath = normalized;
150
- const sourcePath = path2.join(repoPath, relativePath);
151
- if (fs.existsSync(sourcePath)) {
152
- const destPath = path2.join(worktreePath, relativePath);
153
- const destDir = path2.dirname(destPath);
154
- fs.mkdirSync(destDir, { recursive: true });
155
- fs.copyFileSync(sourcePath, destPath);
291
+ const sourcePath = path3.join(repoPath, relativePath);
292
+ if (fs2.existsSync(sourcePath)) {
293
+ const destPath = path3.join(worktreePath, relativePath);
294
+ const destDir = path3.dirname(destPath);
295
+ fs2.mkdirSync(destDir, { recursive: true });
296
+ fs2.copyFileSync(sourcePath, destPath);
156
297
  report("info", ` Copied: ${relativePath}`);
157
298
  }
158
299
  continue;
@@ -168,11 +309,11 @@ function copyConfigFiles(repoPath, worktreePath, patterns) {
168
309
  if (parts.some((p) => EXCLUDED_DIRS.includes(p))) {
169
310
  continue;
170
311
  }
171
- const sourcePath = path2.join(repoPath, match);
172
- const destPath = path2.join(worktreePath, match);
173
- const destDir = path2.dirname(destPath);
174
- fs.mkdirSync(destDir, { recursive: true });
175
- fs.copyFileSync(sourcePath, destPath);
312
+ const sourcePath = path3.join(repoPath, match);
313
+ const destPath = path3.join(worktreePath, match);
314
+ const destDir = path3.dirname(destPath);
315
+ fs2.mkdirSync(destDir, { recursive: true });
316
+ fs2.copyFileSync(sourcePath, destPath);
176
317
  report("info", ` Copied: ${match}`);
177
318
  }
178
319
  }
@@ -226,9 +367,9 @@ function fastForwardBranch(repoPath, branchName) {
226
367
  }
227
368
  function samePath(a, b) {
228
369
  const norm = (p) => {
229
- let r = path3.resolve(p);
370
+ let r = path4.resolve(p);
230
371
  try {
231
- r = fs2.realpathSync.native(r);
372
+ r = fs3.realpathSync.native(r);
232
373
  } catch {
233
374
  }
234
375
  return process.platform === "win32" ? r.toLowerCase() : r;
@@ -237,7 +378,30 @@ function samePath(a, b) {
237
378
  }
238
379
  function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch, pull = true, fetched = false) {
239
380
  debug("createSingleWorktree", { repoPath, worktreePath, branchName, baseBranch });
240
- if (fs2.existsSync(worktreePath)) {
381
+ let aside = null;
382
+ if (isLeftover(worktreePath)) {
383
+ try {
384
+ aside = setLeftoverAside(worktreePath);
385
+ report("warn", ` ${worktreePath} was left half-removed (no git in it): making it again, its files set aside in ${aside}`);
386
+ git(["worktree", "prune"], repoPath);
387
+ } catch (err) {
388
+ report("error", ` ${err.message}`);
389
+ return false;
390
+ }
391
+ }
392
+ const made = makeSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch, pull, fetched);
393
+ if (!made && aside && !fs3.existsSync(worktreePath)) {
394
+ try {
395
+ fs3.renameSync(aside, worktreePath);
396
+ takeLeftover(worktreePath);
397
+ } catch {
398
+ report("warn", ` what was left of it is still at ${aside}`);
399
+ }
400
+ }
401
+ return made;
402
+ }
403
+ function makeSingleWorktree(repoPath, worktreePath, branchName, config, baseBranch, pull, fetched) {
404
+ if (fs3.existsSync(worktreePath)) {
241
405
  if (isGitRepo(worktreePath)) {
242
406
  const currentBranch = getCurrentBranch(worktreePath);
243
407
  if (currentBranch === branchName) {
@@ -263,8 +427,8 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
263
427
  report("error", " Remove that worktree first, or use the existing one.");
264
428
  return false;
265
429
  }
266
- const parentDir = path3.dirname(worktreePath);
267
- fs2.mkdirSync(parentDir, { recursive: true });
430
+ const parentDir = path4.dirname(worktreePath);
431
+ fs3.mkdirSync(parentDir, { recursive: true });
268
432
  if (!fetched) git(["fetch", "--quiet"], repoPath);
269
433
  const hasLocal = localBranchExists(branchName, repoPath);
270
434
  const hasRemote = remoteBranchExists(branchName, repoPath);
@@ -342,7 +506,7 @@ function createSingleWorktree(repoPath, worktreePath, branchName, config, baseBr
342
506
  return true;
343
507
  }
344
508
  function wouldRefuseRemoval(worktreePath, force) {
345
- if (force || !fs2.existsSync(worktreePath)) return false;
509
+ if (force || !fs3.existsSync(worktreePath)) return false;
346
510
  const state = repoState(worktreePath);
347
511
  if (state === "not-a-repo") return false;
348
512
  if (state === "unknown") return true;
@@ -354,13 +518,13 @@ function isDeleteFailure(stderr) {
354
518
  return /failed to delete/i.test(stderr);
355
519
  }
356
520
  function removeSingleWorktree(repoPath, worktreePath, branchName, force) {
357
- if (!fs2.existsSync(worktreePath)) {
521
+ if (!fs3.existsSync(worktreePath)) {
358
522
  report("warn", ` Worktree does not exist at: ${worktreePath}`);
359
523
  return true;
360
524
  }
361
525
  const state = repoState(worktreePath);
362
526
  if (state === "not-a-repo") {
363
- fs2.rmSync(worktreePath, { recursive: true, force: true });
527
+ fs3.rmSync(worktreePath, { recursive: true, force: true });
364
528
  git(["worktree", "prune"], repoPath);
365
529
  report("info", ` Removed invalid worktree directory: ${worktreePath}`);
366
530
  return true;
@@ -397,7 +561,7 @@ function removeSingleWorktree(repoPath, worktreePath, branchName, force) {
397
561
  return true;
398
562
  } else if (isDeleteFailure(result.stderr)) {
399
563
  try {
400
- fs2.rmSync(worktreePath, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 });
564
+ fs3.rmSync(worktreePath, { recursive: true, force: true, maxRetries: 3, retryDelay: 200 });
401
565
  } catch (err) {
402
566
  report("error", ` Failed to remove worktree: ${worktreePath}`);
403
567
  report("error", ` ${err.message}`);
@@ -408,7 +572,7 @@ function removeSingleWorktree(repoPath, worktreePath, branchName, force) {
408
572
  report("success", ` Removed worktree: ${worktreePath} (finished the delete git could not: ${why})`);
409
573
  return true;
410
574
  } else if (force && state === "unknown") {
411
- fs2.rmSync(worktreePath, { recursive: true, force: true });
575
+ fs3.rmSync(worktreePath, { recursive: true, force: true });
412
576
  git(["worktree", "prune"], repoPath);
413
577
  report("success", ` Removed worktree folder git could not read: ${worktreePath}`);
414
578
  return true;
@@ -444,10 +608,34 @@ async function setupWorktree(targetName, branchName, config, base, jiraKey, opts
444
608
  await restoreArchivedUncommitted(session, config).catch(
445
609
  (err) => report("warn", `couldn't put back its uncommitted changes: ${err.message}`)
446
610
  );
611
+ if (session) bestEffort("put back its local settings", () => restoreArchivedIgnored(session, config));
612
+ const tips = session ? readArchive(sessionIdFor(session))?.tips ?? {} : {};
613
+ for (const p of result.paths) {
614
+ const alias = target.isGroup ? target.repoAliases.find((a) => path4.basename(config.repos[a] ?? "").toLowerCase() === path4.basename(p).toLowerCase()) : targetName;
615
+ putBackLeftover(p, alias ? tips[alias] : void 0);
616
+ }
447
617
  if (opts.name?.trim()) await setSessionTitle(sessionTarget, branchName, opts.name);
448
618
  }
449
619
  return result;
450
620
  }
621
+ function putBackLeftover(worktree, tip) {
622
+ const aside = takeLeftover(worktree);
623
+ if (!aside) return;
624
+ const head = git(["rev-parse", "HEAD"], worktree).stdout;
625
+ const clean = git(["status", "--porcelain"], worktree).stdout === "";
626
+ const r = putLeftoverBack(aside, worktree, { overwrite: clean && (!tip || tip === head) });
627
+ if (r.failed.length)
628
+ report(
629
+ "warn",
630
+ `put back ${r.copied} file(s) left in the old folder; ${r.failed.length} couldn't be copied \u2014 they're still in ${aside}`
631
+ );
632
+ else if (r.copied)
633
+ report(
634
+ "info",
635
+ `put back ${r.copied} file(s) left in the old folder${r.removed ? "" : ` (it's still at ${aside}: remove it when done)`}`
636
+ );
637
+ else if (!r.removed) report("info", `nothing to put back from the old folder (still at ${aside}: remove it when done)`);
638
+ }
451
639
  function recreateArchivedBranches(sessionTarget, branch, aliases, config) {
452
640
  const session = findSession(loadHistory(), sessionTarget, branch);
453
641
  if (!session) return [];
@@ -472,7 +660,7 @@ function archivedHeads(sessionTarget, branch) {
472
660
  return rec?.worktreeRemoved && rec.heads && Object.keys(rec.heads).length ? rec.heads : void 0;
473
661
  }
474
662
  async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDirName, config, spec, jiraKey, opts = {}) {
475
- const groupWorktreePath = path3.join(config.worktreesRoot, groupName, workTreeDirName);
663
+ const groupWorktreePath = path4.join(config.worktreesRoot, groupName, workTreeDirName);
476
664
  if (!isEmptyBaseSpec(spec)) {
477
665
  const unknownAliases = baseSpecOverrideAliases(spec).filter((a) => !repoAliases.includes(a));
478
666
  if (unknownAliases.length > 0) {
@@ -507,10 +695,10 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
507
695
  report("step", `Creating group worktree: ${groupName}/${branchName}`);
508
696
  report("detail", `Directory: ${groupWorktreePath}`);
509
697
  report("info", "");
510
- fs2.mkdirSync(groupWorktreePath, { recursive: true });
698
+ fs3.mkdirSync(groupWorktreePath, { recursive: true });
511
699
  const createdWorktrees = [];
512
700
  const baseBranches = {};
513
- const toCreate = repoAliases.filter((alias) => !fs2.existsSync(path3.join(groupWorktreePath, path3.basename(config.repos[alias]))));
701
+ const toCreate = repoAliases.filter((alias) => !fs3.existsSync(path4.join(groupWorktreePath, path4.basename(config.repos[alias]))));
514
702
  const fetched = /* @__PURE__ */ new Set();
515
703
  if (toCreate.length > 1) {
516
704
  report("info", `Fetching ${toCreate.length} repos\u2026`);
@@ -525,8 +713,8 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
525
713
  }
526
714
  for (const alias of repoAliases) {
527
715
  const repoPath = config.repos[alias];
528
- const repoName = path3.basename(repoPath);
529
- const subWorktreePath = path3.join(groupWorktreePath, repoName);
716
+ const repoName = path4.basename(repoPath);
717
+ const subWorktreePath = path4.join(groupWorktreePath, repoName);
530
718
  const repoBase = baseForAlias(spec, alias);
531
719
  report("step", `[${alias}] (${repoName}):`);
532
720
  const success = createSingleWorktree(
@@ -548,8 +736,8 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
548
736
  removeSingleWorktree(wt.repoPath, wt.worktreePath, branchName, true);
549
737
  }
550
738
  try {
551
- if (fs2.readdirSync(groupWorktreePath).length === 0) {
552
- fs2.rmSync(groupWorktreePath, { recursive: true, force: true });
739
+ if (fs3.readdirSync(groupWorktreePath).length === 0) {
740
+ fs3.rmSync(groupWorktreePath, { recursive: true, force: true });
553
741
  }
554
742
  } catch {
555
743
  }
@@ -558,11 +746,11 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
558
746
  }
559
747
  }
560
748
  const configDir = getConfigDir();
561
- const claudeMdSrc = path3.join(configDir, `${groupName}.claude.md`);
749
+ const claudeMdSrc = path4.join(configDir, `${groupName}.claude.md`);
562
750
  const instructionsFile = agentFor(config, findSession(loadHistory(), groupName, branchName)).instructionsFile;
563
- const claudeMdDest = path3.join(groupWorktreePath, instructionsFile);
564
- if (fs2.existsSync(claudeMdSrc)) {
565
- fs2.copyFileSync(claudeMdSrc, claudeMdDest);
751
+ const claudeMdDest = path4.join(groupWorktreePath, instructionsFile);
752
+ if (fs3.existsSync(claudeMdSrc)) {
753
+ fs3.copyFileSync(claudeMdSrc, claudeMdDest);
566
754
  report("info", "");
567
755
  report("success", `Copied the group's ${instructionsFile} to the worktree root`);
568
756
  } else {
@@ -581,20 +769,20 @@ async function setupGroupWorktree(groupName, repoAliases, branchName, workTreeDi
581
769
  }
582
770
  async function setupSingleWorktree(targetName, branchName, workTreeDirName, config, spec, jiraKey, opts = {}) {
583
771
  const repoPath = config.repos[targetName];
584
- const repoName = path3.basename(repoPath);
585
- let workTreePath = path3.join(config.worktreesRoot, repoName, workTreeDirName);
772
+ const repoName = path4.basename(repoPath);
773
+ let workTreePath = path4.join(config.worktreesRoot, repoName, workTreeDirName);
586
774
  const unknownAliases = baseSpecOverrideAliases(spec).filter((a) => a !== targetName);
587
775
  if (unknownAliases.length > 0) {
588
776
  report("error", `--base names repo(s) other than '${targetName}': ${unknownAliases.join(", ")}`);
589
777
  return null;
590
778
  }
591
779
  const baseBranch = baseForAlias(spec, targetName);
592
- if (!fs2.existsSync(repoPath)) {
780
+ if (!fs3.existsSync(repoPath)) {
593
781
  report("error", `Repository path does not exist: ${repoPath}`);
594
782
  return null;
595
783
  }
596
784
  const worktrees = parseWorktreeList(repoPath);
597
- const existing = worktrees.find((wt) => wt.branch === branchName && path3.resolve(wt.path) !== path3.resolve(repoPath));
785
+ const existing = worktrees.find((wt) => wt.branch === branchName && path4.resolve(wt.path) !== path4.resolve(repoPath));
598
786
  if (existing) {
599
787
  if (baseBranch) {
600
788
  report("error", `Cannot use --base: worktree for '${branchName}' already exists at ${existing.path}`);
@@ -629,9 +817,9 @@ async function setupSingleWorktree(targetName, branchName, workTreeDirName, conf
629
817
  return { launchDir: workTreePath, paths: [workTreePath], isGroup: false, port };
630
818
  }
631
819
  var normalizeWorktreePath = (p) => {
632
- let full = path3.resolve(p);
820
+ let full = path4.resolve(p);
633
821
  try {
634
- full = fs2.realpathSync.native(full);
822
+ full = fs3.realpathSync.native(full);
635
823
  } catch {
636
824
  }
637
825
  return full.replace(/\\/g, "/").replace(/\/$/, "").toLowerCase();
@@ -640,26 +828,26 @@ function teardownWorktree(target, isGroup, branch, config, force = true, paths)
640
828
  const workTreeDirName = branch.replace(/\//g, "-");
641
829
  if (isGroup && config.groups[target]) {
642
830
  const aliases = config.groups[target];
643
- const groupWorktreePath = path3.join(config.worktreesRoot, target, workTreeDirName);
831
+ const groupWorktreePath = path4.join(config.worktreesRoot, target, workTreeDirName);
644
832
  let allRemoved = true;
645
833
  for (const alias of aliases) {
646
834
  const repoPath = config.repos[alias];
647
835
  if (!repoPath) continue;
648
- const repoName = path3.basename(repoPath);
649
- const subWorktreePath = path3.join(groupWorktreePath, repoName);
836
+ const repoName = path4.basename(repoPath);
837
+ const subWorktreePath = path4.join(groupWorktreePath, repoName);
650
838
  report("step", `[${alias}] (${repoName}):`);
651
839
  if (!removeSingleWorktree(repoPath, subWorktreePath, branch, force)) {
652
840
  allRemoved = false;
653
841
  }
654
842
  }
655
- const claudeMd = path3.join(groupWorktreePath, agentFor(config, findSession(loadHistory(), target, branch)).instructionsFile);
843
+ const claudeMd = path4.join(groupWorktreePath, agentFor(config, findSession(loadHistory(), target, branch)).instructionsFile);
656
844
  try {
657
- if (fs2.existsSync(claudeMd)) fs2.unlinkSync(claudeMd);
845
+ if (fs3.existsSync(claudeMd)) fs3.unlinkSync(claudeMd);
658
846
  } catch {
659
847
  }
660
848
  try {
661
- if (fs2.existsSync(groupWorktreePath) && fs2.readdirSync(groupWorktreePath).length === 0) {
662
- fs2.rmSync(groupWorktreePath, { recursive: true, force: true });
849
+ if (fs3.existsSync(groupWorktreePath) && fs3.readdirSync(groupWorktreePath).length === 0) {
850
+ fs3.rmSync(groupWorktreePath, { recursive: true, force: true });
663
851
  report("success", `Cleaned up group directory: ${groupWorktreePath}`);
664
852
  }
665
853
  } catch {
@@ -685,7 +873,7 @@ async function openBaseCheckout(targetName, config, opts = {}) {
685
873
  if (target.isGroup) return { ok: false, error: `${targetName} is a group: give it a branch (a group has no one checkout to open)` };
686
874
  const repoPath = config.repos[targetName];
687
875
  if (!repoPath) return { ok: false, error: `Repository path not configured for: ${targetName}` };
688
- if (!fs2.existsSync(repoPath)) return { ok: false, error: `Repository path does not exist: ${repoPath}` };
876
+ if (!fs3.existsSync(repoPath)) return { ok: false, error: `Repository path does not exist: ${repoPath}` };
689
877
  const branch = getCurrentBranch(repoPath) ?? "(detached)";
690
878
  if (opts.pull !== false && branch && branch !== "(detached)") pullLatestForBranch(repoPath, branch);
691
879
  await upsertSession(targetName, false, branch, [repoPath], opts.jiraKey);
@@ -695,6 +883,8 @@ async function openBaseCheckout(targetName, config, opts = {}) {
695
883
  }
696
884
 
697
885
  export {
886
+ saveIgnored,
887
+ worktreeFor,
698
888
  BaseSpecError,
699
889
  parseBaseSpec,
700
890
  isEmptyBaseSpec,
@@ -704,4 +894,4 @@ export {
704
894
  teardownWorktree,
705
895
  openBaseCheckout
706
896
  };
707
- //# sourceMappingURL=chunk-N23HFT4X.js.map
897
+ //# sourceMappingURL=chunk-YZSSYD2G.js.map