@moberg_hr/work-tree 1.16.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/README.md +56 -142
  2. package/dist/answer-2J4XLIP7.js +63 -0
  3. package/dist/answer-2J4XLIP7.js.map +1 -0
  4. package/dist/attach-CZKRNPAJ.js +59 -0
  5. package/dist/attach-CZKRNPAJ.js.map +1 -0
  6. package/dist/bin.js +26 -11924
  7. package/dist/bin.js.map +1 -1
  8. package/dist/block-RAIDCJ4F.js +84 -0
  9. package/dist/block-RAIDCJ4F.js.map +1 -0
  10. package/dist/broadcast-BSI5NDDB.js +104 -0
  11. package/dist/broadcast-BSI5NDDB.js.map +1 -0
  12. package/dist/catchup-VVOPL2S5.js +51 -0
  13. package/dist/catchup-VVOPL2S5.js.map +1 -0
  14. package/dist/chunk-3JWTO5VZ.js +135 -0
  15. package/dist/chunk-3JWTO5VZ.js.map +1 -0
  16. package/dist/chunk-4BOK2GXL.js +210 -0
  17. package/dist/chunk-4BOK2GXL.js.map +1 -0
  18. package/dist/chunk-5QK7GB5K.js +112 -0
  19. package/dist/chunk-5QK7GB5K.js.map +1 -0
  20. package/dist/chunk-6AQRYLOB.js +16 -0
  21. package/dist/chunk-6AQRYLOB.js.map +1 -0
  22. package/dist/chunk-6FTIY5M6.js +120 -0
  23. package/dist/chunk-6FTIY5M6.js.map +1 -0
  24. package/dist/chunk-6H3MLDGG.js +48 -0
  25. package/dist/chunk-6H3MLDGG.js.map +1 -0
  26. package/dist/chunk-77XFJQGC.js +103 -0
  27. package/dist/chunk-77XFJQGC.js.map +1 -0
  28. package/dist/chunk-7H4BJ2YA.js +308 -0
  29. package/dist/chunk-7H4BJ2YA.js.map +1 -0
  30. package/dist/chunk-7HEB6SQS.js +257 -0
  31. package/dist/chunk-7HEB6SQS.js.map +1 -0
  32. package/dist/chunk-7NAXFBFI.js +206 -0
  33. package/dist/chunk-7NAXFBFI.js.map +1 -0
  34. package/dist/chunk-7NCW3LUT.js +358 -0
  35. package/dist/chunk-7NCW3LUT.js.map +1 -0
  36. package/dist/chunk-7OLPI334.js +537 -0
  37. package/dist/chunk-7OLPI334.js.map +1 -0
  38. package/dist/chunk-ABQYKTG4.js +38 -0
  39. package/dist/chunk-ABQYKTG4.js.map +1 -0
  40. package/dist/chunk-AH5TM3NB.js +21 -0
  41. package/dist/chunk-AH5TM3NB.js.map +1 -0
  42. package/dist/chunk-AKMPF72Y.js +274 -0
  43. package/dist/chunk-AKMPF72Y.js.map +1 -0
  44. package/dist/chunk-C2BK6EBN.js +162 -0
  45. package/dist/chunk-C2BK6EBN.js.map +1 -0
  46. package/dist/chunk-C2THFSXA.js +37 -0
  47. package/dist/chunk-C2THFSXA.js.map +1 -0
  48. package/dist/chunk-CLGVSX36.js +668 -0
  49. package/dist/chunk-CLGVSX36.js.map +1 -0
  50. package/dist/chunk-CXEC5W5V.js +267 -0
  51. package/dist/chunk-CXEC5W5V.js.map +1 -0
  52. package/dist/chunk-DW4JPVXB.js +41 -0
  53. package/dist/chunk-DW4JPVXB.js.map +1 -0
  54. package/dist/chunk-FR3EWVXI.js +188 -0
  55. package/dist/chunk-FR3EWVXI.js.map +1 -0
  56. package/dist/chunk-H5LKMR45.js +117 -0
  57. package/dist/chunk-H5LKMR45.js.map +1 -0
  58. package/dist/chunk-HSICXDMZ.js +41 -0
  59. package/dist/chunk-HSICXDMZ.js.map +1 -0
  60. package/dist/chunk-HUXS3VAI.js +90 -0
  61. package/dist/chunk-HUXS3VAI.js.map +1 -0
  62. package/dist/chunk-HWUINPIL.js +151 -0
  63. package/dist/chunk-HWUINPIL.js.map +1 -0
  64. package/dist/chunk-IXKVCR4Y.js +487 -0
  65. package/dist/chunk-IXKVCR4Y.js.map +1 -0
  66. package/dist/chunk-JNBYNRFS.js +54 -0
  67. package/dist/chunk-JNBYNRFS.js.map +1 -0
  68. package/dist/chunk-JYTMT5DF.js +421 -0
  69. package/dist/chunk-JYTMT5DF.js.map +1 -0
  70. package/dist/chunk-KA4JVX5U.js +295 -0
  71. package/dist/chunk-KA4JVX5U.js.map +1 -0
  72. package/dist/chunk-KGZ6OZ2T.js +102 -0
  73. package/dist/chunk-KGZ6OZ2T.js.map +1 -0
  74. package/dist/chunk-LNHSBM4L.js +26 -0
  75. package/dist/chunk-LNHSBM4L.js.map +1 -0
  76. package/dist/chunk-M4FVCAT6.js +2406 -0
  77. package/dist/chunk-M4FVCAT6.js.map +1 -0
  78. package/dist/chunk-MAGGGRSB.js +9 -0
  79. package/dist/chunk-MAGGGRSB.js.map +1 -0
  80. package/dist/chunk-N4EYQKSM.js +104 -0
  81. package/dist/chunk-N4EYQKSM.js.map +1 -0
  82. package/dist/chunk-NDWSLQPB.js +112 -0
  83. package/dist/chunk-NDWSLQPB.js.map +1 -0
  84. package/dist/chunk-O3QTWVSK.js +323 -0
  85. package/dist/chunk-O3QTWVSK.js.map +1 -0
  86. package/dist/chunk-P3BL4EOP.js +37 -0
  87. package/dist/chunk-P3BL4EOP.js.map +1 -0
  88. package/dist/chunk-PN44M5EE.js +887 -0
  89. package/dist/chunk-PN44M5EE.js.map +1 -0
  90. package/dist/chunk-PZ4RG6EW.js +132 -0
  91. package/dist/chunk-PZ4RG6EW.js.map +1 -0
  92. package/dist/chunk-Q6WZCO45.js +47 -0
  93. package/dist/chunk-Q6WZCO45.js.map +1 -0
  94. package/dist/chunk-QBAZG4CY.js +230 -0
  95. package/dist/chunk-QBAZG4CY.js.map +1 -0
  96. package/dist/chunk-R2LN3JJJ.js +132 -0
  97. package/dist/chunk-R2LN3JJJ.js.map +1 -0
  98. package/dist/chunk-RCYI7SRA.js +15 -0
  99. package/dist/chunk-RCYI7SRA.js.map +1 -0
  100. package/dist/chunk-RYNBBSLY.js +67 -0
  101. package/dist/chunk-RYNBBSLY.js.map +1 -0
  102. package/dist/chunk-S5HJT7CM.js +30 -0
  103. package/dist/chunk-S5HJT7CM.js.map +1 -0
  104. package/dist/chunk-SNAQOHNL.js +285 -0
  105. package/dist/chunk-SNAQOHNL.js.map +1 -0
  106. package/dist/chunk-SOCPIHCS.js +181 -0
  107. package/dist/chunk-SOCPIHCS.js.map +1 -0
  108. package/dist/chunk-TUC4QY4O.js +147 -0
  109. package/dist/chunk-TUC4QY4O.js.map +1 -0
  110. package/dist/chunk-TUFQJXXO.js +19 -0
  111. package/dist/chunk-TUFQJXXO.js.map +1 -0
  112. package/dist/chunk-UFY7C5PP.js +90 -0
  113. package/dist/chunk-UFY7C5PP.js.map +1 -0
  114. package/dist/chunk-UQ35KLHH.js +34 -0
  115. package/dist/chunk-UQ35KLHH.js.map +1 -0
  116. package/dist/chunk-VJ7SVDED.js +177 -0
  117. package/dist/chunk-VJ7SVDED.js.map +1 -0
  118. package/dist/chunk-VJNSIDOA.js +23 -0
  119. package/dist/chunk-VJNSIDOA.js.map +1 -0
  120. package/dist/chunk-WF5SBVPZ.js +190 -0
  121. package/dist/chunk-WF5SBVPZ.js.map +1 -0
  122. package/dist/chunk-WMJIU3YW.js +29 -0
  123. package/dist/chunk-WMJIU3YW.js.map +1 -0
  124. package/dist/chunk-XJDEROHY.js +19 -0
  125. package/dist/chunk-XJDEROHY.js.map +1 -0
  126. package/dist/chunk-YKODIG22.js +221 -0
  127. package/dist/chunk-YKODIG22.js.map +1 -0
  128. package/dist/chunk-YLG6DO5Y.js +162 -0
  129. package/dist/chunk-YLG6DO5Y.js.map +1 -0
  130. package/dist/chunk-YNKWLC45.js +122 -0
  131. package/dist/chunk-YNKWLC45.js.map +1 -0
  132. package/dist/chunk-YZDD5YGE.js +165 -0
  133. package/dist/chunk-YZDD5YGE.js.map +1 -0
  134. package/dist/chunk-YZWADOEW.js +151 -0
  135. package/dist/chunk-YZWADOEW.js.map +1 -0
  136. package/dist/chunk-ZJN5RWZD.js +76 -0
  137. package/dist/chunk-ZJN5RWZD.js.map +1 -0
  138. package/dist/chunk-ZSHWP2VS.js +22 -0
  139. package/dist/chunk-ZSHWP2VS.js.map +1 -0
  140. package/dist/chunk-ZXPYWZL5.js +307 -0
  141. package/dist/chunk-ZXPYWZL5.js.map +1 -0
  142. package/dist/cleanup-X45MA74G.js +192 -0
  143. package/dist/cleanup-X45MA74G.js.map +1 -0
  144. package/dist/cli-52VWEHIQ.js +18 -0
  145. package/dist/cli-52VWEHIQ.js.map +1 -0
  146. package/dist/command-hook-installer-SGEJTZ2Y.js +204 -0
  147. package/dist/command-hook-installer-SGEJTZ2Y.js.map +1 -0
  148. package/dist/completion-MXX5TRIV.js +118 -0
  149. package/dist/completion-MXX5TRIV.js.map +1 -0
  150. package/dist/config-IEIU7A66.js +410 -0
  151. package/dist/config-IEIU7A66.js.map +1 -0
  152. package/dist/console-reporter-XU6VFUZE.js +10 -0
  153. package/dist/console-reporter-XU6VFUZE.js.map +1 -0
  154. package/dist/diff-K47HB6SA.js +582 -0
  155. package/dist/diff-K47HB6SA.js.map +1 -0
  156. package/dist/digest-FBZTBXQO.js +100 -0
  157. package/dist/digest-FBZTBXQO.js.map +1 -0
  158. package/dist/fork-BKI5UNNS.js +120 -0
  159. package/dist/fork-BKI5UNNS.js.map +1 -0
  160. package/dist/hook-SLMZT5OV.js +220 -0
  161. package/dist/hook-SLMZT5OV.js.map +1 -0
  162. package/dist/hydrate-Y2AAMZTA.js +121 -0
  163. package/dist/hydrate-Y2AAMZTA.js.map +1 -0
  164. package/dist/init-7ESFTYZC.js +187 -0
  165. package/dist/init-7ESFTYZC.js.map +1 -0
  166. package/dist/install-skills-O34BHFHD.js +14 -0
  167. package/dist/install-skills-O34BHFHD.js.map +1 -0
  168. package/dist/install-skills-bin.js +12 -0
  169. package/dist/install-skills-bin.js.map +1 -0
  170. package/dist/list-KEF73NLQ.js +126 -0
  171. package/dist/list-KEF73NLQ.js.map +1 -0
  172. package/dist/move-FKT2P5LY.js +313 -0
  173. package/dist/move-FKT2P5LY.js.map +1 -0
  174. package/dist/note-WGM6LCP2.js +78 -0
  175. package/dist/note-WGM6LCP2.js.map +1 -0
  176. package/dist/overlaps-FRLMMIGC.js +56 -0
  177. package/dist/overlaps-FRLMMIGC.js.map +1 -0
  178. package/dist/pin-MQ5ZE37R.js +45 -0
  179. package/dist/pin-MQ5ZE37R.js.map +1 -0
  180. package/dist/pr-YU3NOW6G.js +118 -0
  181. package/dist/pr-YU3NOW6G.js.map +1 -0
  182. package/dist/prune-26FYYFTO.js +92 -0
  183. package/dist/prune-26FYYFTO.js.map +1 -0
  184. package/dist/pty-host-RWIS55N4.js +826 -0
  185. package/dist/pty-host-RWIS55N4.js.map +1 -0
  186. package/dist/read-AP6T3ZGN.js +57 -0
  187. package/dist/read-AP6T3ZGN.js.map +1 -0
  188. package/dist/recent-IE3LYQ65.js +111 -0
  189. package/dist/recent-IE3LYQ65.js.map +1 -0
  190. package/dist/remove-2UHJQ4DY.js +108 -0
  191. package/dist/remove-2UHJQ4DY.js.map +1 -0
  192. package/dist/report-KM4OZCZB.js +16 -0
  193. package/dist/report-KM4OZCZB.js.map +1 -0
  194. package/dist/resume-UUP6R2IE.js +81 -0
  195. package/dist/resume-UUP6R2IE.js.map +1 -0
  196. package/dist/run-V4755W7C.js +263 -0
  197. package/dist/run-V4755W7C.js.map +1 -0
  198. package/dist/screen-DNX4K23V.js +58 -0
  199. package/dist/screen-DNX4K23V.js.map +1 -0
  200. package/dist/search-3JZXLCR2.js +46 -0
  201. package/dist/search-3JZXLCR2.js.map +1 -0
  202. package/dist/section-TXLC5XO3.js +79 -0
  203. package/dist/section-TXLC5XO3.js.map +1 -0
  204. package/dist/send-6X46WZLC.js +87 -0
  205. package/dist/send-6X46WZLC.js.map +1 -0
  206. package/dist/sessions-T3QDTNP7.js +135 -0
  207. package/dist/sessions-T3QDTNP7.js.map +1 -0
  208. package/dist/snooze-KYSFXLPY.js +65 -0
  209. package/dist/snooze-KYSFXLPY.js.map +1 -0
  210. package/dist/start-SQSDQK4F.js +56 -0
  211. package/dist/start-SQSDQK4F.js.map +1 -0
  212. package/dist/state-4DFV6SHG.js +147 -0
  213. package/dist/state-4DFV6SHG.js.map +1 -0
  214. package/dist/status-H5OW4LYE.js +118 -0
  215. package/dist/status-H5OW4LYE.js.map +1 -0
  216. package/dist/stop-HC7XPSSP.js +45 -0
  217. package/dist/stop-HC7XPSSP.js.map +1 -0
  218. package/dist/sync-3CTAXM6J.js +96 -0
  219. package/dist/sync-3CTAXM6J.js.map +1 -0
  220. package/dist/time-GN6B4QD6.js +111 -0
  221. package/dist/time-GN6B4QD6.js.map +1 -0
  222. package/dist/todo-LWMQY6XW.js +152 -0
  223. package/dist/todo-LWMQY6XW.js.map +1 -0
  224. package/dist/tree-7BMORJ6J.js +235 -0
  225. package/dist/tree-7BMORJ6J.js.map +1 -0
  226. package/dist/update-6LQNLRA4.js +57 -0
  227. package/dist/update-6LQNLRA4.js.map +1 -0
  228. package/dist/wait-MZOZQ3CI.js +57 -0
  229. package/dist/wait-MZOZQ3CI.js.map +1 -0
  230. package/dist/wd-bin.js +21 -11912
  231. package/dist/wd-bin.js.map +1 -1
  232. package/dist/web/assets/PtyView-BrP-ENHg.css +1 -0
  233. package/dist/web/assets/PtyView-M4b0GFVs.js +90 -0
  234. package/dist/web/assets/PtyView-M4b0GFVs.js.map +1 -0
  235. package/dist/web/assets/index-5hi1kMKy.js +116 -0
  236. package/dist/web/assets/index-5hi1kMKy.js.map +1 -0
  237. package/dist/web/assets/index-L8mjakHP.css +1 -0
  238. package/dist/web/index.html +3 -5
  239. package/dist/web-BI3MRQEM.js +7662 -0
  240. package/dist/web-BI3MRQEM.js.map +1 -0
  241. package/npm-shrinkwrap.json +6947 -0
  242. package/package.json +52 -34
  243. package/plugins/work-tree/.claude-plugin/plugin.json +1 -1
  244. package/plugins/work-tree/skills/wd-review/SKILL.md +4 -4
  245. package/plugins/work-tree/skills/work-sessions/SKILL.md +62 -0
  246. package/scripts/postinstall.mjs +15 -45
  247. package/dist/web/assets/index-B9H3vCtL.js +0 -107
  248. package/dist/web/assets/index-B9H3vCtL.js.map +0 -1
  249. package/dist/web/assets/index-BseMpW5i.css +0 -1
@@ -0,0 +1,230 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ isPidAlive,
4
+ spawnDetachedWork
5
+ } from "./chunk-PN44M5EE.js";
6
+ import {
7
+ ensureFile,
8
+ getConfigDir,
9
+ withFileLock
10
+ } from "./chunk-7HEB6SQS.js";
11
+
12
+ // src/core/pty/pty-host-protocol.ts
13
+ import fs from "fs";
14
+ import path from "path";
15
+ var PROTOCOL_VERSION = 2;
16
+ var SECRET_NAME = /TOKEN|SECRET|PASS|PWD|CREDENTIAL|PRIVATE|KEY|AUTH|BEARER|COOKIE|SESSION|CERT|SIGN|SALT|(^|_)PAT($|_)|DSN|CONN|DATABASE_URL|_URI$|_URL$/i;
17
+ var SECRET_VALUE = /:\/\/[^/\s:@]+:[^/\s@]+@/;
18
+ function keepEnv(env, names) {
19
+ if (!env) return void 0;
20
+ const kept = Object.fromEntries(
21
+ names.filter((n) => !SECRET_NAME.test(n) && typeof env[n] === "string" && !SECRET_VALUE.test(env[n])).map((n) => [n, env[n]])
22
+ );
23
+ return Object.keys(kept).length ? kept : void 0;
24
+ }
25
+ function isPersistedPty(x) {
26
+ const e = x;
27
+ return !!e && typeof e === "object" && typeof e.cwd === "string" && !!e.tool && typeof e.tool === "object" && (e.keptEnv === void 0 || !!e.keptEnv && typeof e.keptEnv === "object" && Object.values(e.keptEnv).every((v) => typeof v === "string"));
28
+ }
29
+ function hostInfoPath() {
30
+ return path.join(getConfigDir(), "pty-host.json");
31
+ }
32
+ function hostStartLockPath() {
33
+ return path.join(getConfigDir(), "pty-host.start.lock");
34
+ }
35
+ function ptySessionsPath() {
36
+ return path.join(getConfigDir(), "pty-sessions.json");
37
+ }
38
+ function readHostInfo() {
39
+ try {
40
+ const raw = JSON.parse(fs.readFileSync(hostInfoPath(), "utf-8"));
41
+ if (typeof raw.port === "number" && typeof raw.token === "string" && typeof raw.pid === "number") {
42
+ return raw;
43
+ }
44
+ return null;
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+
50
+ // src/core/pty/pty-host-client.ts
51
+ import path2 from "path";
52
+ var PtyHostVersionError = class extends Error {
53
+ constructor(hostVersion) {
54
+ super(
55
+ `A PTY host from an older build (protocol v${hostVersion}, need v${PROTOCOL_VERSION}) is running. Restart it with \`work pty-host --restart\` \u2014 sessions come back via --continue.`
56
+ );
57
+ this.hostVersion = hostVersion;
58
+ }
59
+ };
60
+ async function probeHostDetailed(info, timeoutMs = 800) {
61
+ try {
62
+ const res = await fetch(`http://127.0.0.1:${info.port}/health`, {
63
+ headers: { "x-work-token": info.token },
64
+ signal: AbortSignal.timeout(timeoutMs)
65
+ });
66
+ if (!res.ok) return { kind: "not-ours" };
67
+ const body = await res.json();
68
+ if (typeof body.version !== "number" || typeof body.pid !== "number") return { kind: "not-ours" };
69
+ return { kind: "host", version: body.version, pid: body.pid };
70
+ } catch (err) {
71
+ const e = err;
72
+ if (e.cause?.code === "ECONNREFUSED") return { kind: "refused" };
73
+ if (e.name === "TimeoutError" || e.name === "AbortError") return { kind: "timeout" };
74
+ return { kind: "refused" };
75
+ }
76
+ }
77
+ var PtyHostBusyError = class extends Error {
78
+ constructor() {
79
+ super("The PTY host is running but not answering (busy?). Try again in a moment.");
80
+ this.name = "PtyHostBusyError";
81
+ }
82
+ };
83
+ async function findHost(timeoutsMs = [800, 5e3]) {
84
+ const info = readHostInfo();
85
+ if (!info) return null;
86
+ let probe = { kind: "timeout" };
87
+ for (const t of timeoutsMs) {
88
+ probe = await probeHostDetailed(info, t);
89
+ if (probe.kind !== "timeout") break;
90
+ }
91
+ if (probe.kind === "timeout") {
92
+ if (!isPidAlive(info.pid)) return null;
93
+ throw new PtyHostBusyError();
94
+ }
95
+ if (probe.kind !== "host" || probe.pid !== info.pid) return null;
96
+ if (probe.version !== PROTOCOL_VERSION) throw new PtyHostVersionError(probe.version);
97
+ return info;
98
+ }
99
+ async function findHostPatient(timeoutMs = 2e4) {
100
+ const deadline = Date.now() + timeoutMs;
101
+ for (; ; ) {
102
+ try {
103
+ return await findHost();
104
+ } catch (err) {
105
+ if (!(err instanceof PtyHostBusyError) || Date.now() >= deadline) throw err;
106
+ await new Promise((r) => setTimeout(r, 250));
107
+ }
108
+ }
109
+ }
110
+ async function findHostOrBusy() {
111
+ try {
112
+ return await findHost();
113
+ } catch (err) {
114
+ if (err instanceof PtyHostBusyError) return "busy";
115
+ throw err;
116
+ }
117
+ }
118
+ function hostSpawnLockPath() {
119
+ return path2.join(getConfigDir(), "pty-host.spawn.lock");
120
+ }
121
+ var inFlight = null;
122
+ function ensureHost(workBin, timeoutMs = 2e4) {
123
+ if (!inFlight) {
124
+ inFlight = ensureHostLocked(workBin, timeoutMs).finally(() => {
125
+ inFlight = null;
126
+ });
127
+ }
128
+ return inFlight;
129
+ }
130
+ async function ensureHostLocked(workBin, timeoutMs) {
131
+ const existing = await findHostOrBusy();
132
+ if (existing === "busy") return waitForHost(timeoutMs);
133
+ if (existing) return existing;
134
+ const lock = hostSpawnLockPath();
135
+ ensureFile(lock, "");
136
+ try {
137
+ return await withFileLock(lock, async () => {
138
+ const started = await findHostOrBusy();
139
+ if (started === "busy") return waitForHost(timeoutMs);
140
+ if (started) return started;
141
+ spawnHost(workBin);
142
+ return waitForHost(timeoutMs);
143
+ });
144
+ } catch (err) {
145
+ if (err.code === "ELOCKED") return waitForHost(timeoutMs);
146
+ throw err;
147
+ }
148
+ }
149
+ function spawnHost(workBin) {
150
+ spawnDetachedWork(workBin, ["pty-host"], path2.join(getConfigDir(), "pty-host.log"));
151
+ }
152
+ async function waitForHost(timeoutMs) {
153
+ const deadline = Date.now() + timeoutMs;
154
+ while (Date.now() < deadline) {
155
+ const found = await findHost().catch(() => null);
156
+ if (found) return found;
157
+ await new Promise((r) => setTimeout(r, 100));
158
+ }
159
+ throw new Error("PTY host did not start (see ~/.work/pty-host.log)");
160
+ }
161
+ var PtyHostClient = class {
162
+ constructor(info) {
163
+ this.info = info;
164
+ }
165
+ async call(method, p, body) {
166
+ const res = await fetch(`http://127.0.0.1:${this.info.port}${p}`, {
167
+ method,
168
+ headers: {
169
+ "x-work-token": this.info.token,
170
+ ...body !== void 0 ? { "Content-Type": "application/json" } : {}
171
+ },
172
+ body: body !== void 0 ? JSON.stringify(body) : void 0,
173
+ signal: AbortSignal.timeout(5e3)
174
+ });
175
+ const json = await res.json().catch(() => ({}));
176
+ if (!res.ok) throw new Error(json.error ?? `PTY host ${method} ${p}: ${res.status}`);
177
+ return json;
178
+ }
179
+ list() {
180
+ return this.call("GET", "/ptys");
181
+ }
182
+ get(id) {
183
+ return this.call("GET", `/ptys/${encodeURIComponent(id)}`).catch(() => null);
184
+ }
185
+ spawn(id, spec) {
186
+ return this.call("POST", `/ptys/${encodeURIComponent(id)}`, spec);
187
+ }
188
+ /** The session's visible screen as text; null when it has none — or the
189
+ * host predates this call (404 either way: nothing to answer by key). */
190
+ async screen(id) {
191
+ try {
192
+ const r = await this.call("GET", `/ptys/${encodeURIComponent(id)}/screen`);
193
+ return typeof r.text === "string" ? r.text : null;
194
+ } catch {
195
+ return null;
196
+ }
197
+ }
198
+ async write(id, data) {
199
+ try {
200
+ await this.call("POST", `/ptys/${encodeURIComponent(id)}/write`, { data });
201
+ return true;
202
+ } catch {
203
+ return false;
204
+ }
205
+ }
206
+ async kill(id) {
207
+ await this.call("DELETE", `/ptys/${encodeURIComponent(id)}`);
208
+ }
209
+ attachUrl(id) {
210
+ return `ws://127.0.0.1:${this.info.port}/ptys/${encodeURIComponent(id)}/attach?token=${this.info.token}`;
211
+ }
212
+ };
213
+
214
+ export {
215
+ PROTOCOL_VERSION,
216
+ keepEnv,
217
+ isPersistedPty,
218
+ hostInfoPath,
219
+ hostStartLockPath,
220
+ ptySessionsPath,
221
+ readHostInfo,
222
+ PtyHostVersionError,
223
+ probeHostDetailed,
224
+ PtyHostBusyError,
225
+ findHost,
226
+ findHostPatient,
227
+ ensureHost,
228
+ PtyHostClient
229
+ };
230
+ //# sourceMappingURL=chunk-QBAZG4CY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/pty/pty-host-protocol.ts","../src/core/pty/pty-host-client.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { getConfigDir } from '../platform/config.js';\nimport type { AiToolSpec } from '../platform/ai-launcher.js';\n\n/**\n * Wire contract between the PTY host (`work pty-host`, the long-lived\n * process that owns every Claude PTY) and its clients (`work web`,\n * `work attach`). Bump PROTOCOL_VERSION on any incompatible change: a\n * client that finds an older host running tells the user to restart it\n * (`work pty-host --restart`) instead of silently misbehaving — the host\n * outlives rebuilds by design.\n *\n * 2: the restore list moved from pty-sessions.json into state.db. A v1 host\n * still writes the file, which a v2 host adopts on start\n * (adoptLegacyRestoreList).\n */\nexport const PROTOCOL_VERSION = 2;\n\n/** Discovery file: where the running host listens and its auth token. */\nexport interface HostInfo {\n pid: number;\n port: number;\n token: string;\n version: number;\n}\n\n/** What a client asks the host to spawn. The host decides `--continue`\n * itself (see `hasClaudeConversation`) so restores after a reboot make\n * the same call a fresh spawn would. */\nexport interface SpawnSpec {\n cwd: string;\n tool: AiToolSpec;\n port?: number;\n cols?: number;\n rows?: number;\n /** `--unsafe`: the tool's skip-permissions flag. Persisted, so a restore\n * comes back with the same permission mode. */\n unsafe?: boolean;\n /** `--fresh`: start a new conversation even if one exists. First spawn\n * only — a restore always continues. */\n fresh?: boolean;\n /** `--prompt` / `--prompt-file` contents. First spawn only. */\n initialPrompt?: string;\n /** The launching shell's environment. First spawn only and never\n * persisted — it can hold secrets; a restore after reboot uses the\n * host's own environment. */\n env?: Record<string, string>;\n}\n\n/** One entry of the host's restore list: how to respawn a session. The\n * spec as launched, minus `env` (never persisted: it can hold secrets) —\n * except the variables config `hostEnv` names (`keptEnv`), which a restore\n * after a reboot puts back over the host's own environment. */\nexport interface PersistedPty extends SpawnSpec {\n startedAt: string;\n keptEnv?: Record<string, string>;\n}\n\n/** Names that look like secrets (or carry them, as a connection string does): never kept on disk, whatever `hostEnv` says. */\nconst SECRET_NAME =\n /TOKEN|SECRET|PASS|PWD|CREDENTIAL|PRIVATE|KEY|AUTH|BEARER|COOKIE|SESSION|CERT|SIGN|SALT|(^|_)PAT($|_)|DSN|CONN|DATABASE_URL|_URI$|_URL$/i;\n/** Values that carry a password whatever their name: `scheme://user:pass@host`. */\nconst SECRET_VALUE = /:\\/\\/[^/\\s:@]+:[^/\\s@]+@/;\n\n/** The variables of `env` to keep for a restore: the ones named, that exist, and look like neither a secret nor a URL with a password in it. Pure. */\nexport function keepEnv(env: Record<string, string> | undefined, names: readonly string[]): Record<string, string> | undefined {\n if (!env) return undefined;\n const kept = Object.fromEntries(\n names.filter((n) => !SECRET_NAME.test(n) && typeof env[n] === 'string' && !SECRET_VALUE.test(env[n])).map((n) => [n, env[n]]),\n );\n return Object.keys(kept).length ? kept : undefined;\n}\nexport type PersistedPtys = Record<string, PersistedPty>;\n\n/** Shape check for a restore-list entry read back from storage. */\nexport function isPersistedPty(x: unknown): x is PersistedPty {\n const e = x as PersistedPty | null;\n return (\n !!e &&\n typeof e === 'object' &&\n typeof e.cwd === 'string' &&\n !!e.tool &&\n typeof e.tool === 'object' &&\n (e.keptEnv === undefined ||\n (!!e.keptEnv && typeof e.keptEnv === 'object' && Object.values(e.keptEnv).every((v) => typeof v === 'string')))\n );\n}\n\nexport interface PtyInfo {\n id: string;\n cwd: string;\n pid: number;\n exited: boolean;\n cols: number;\n rows: number;\n startedAt: string;\n /** Respawned by the host on startup from the persisted session list\n * (after a crash, `--restart` or reboot), not by a client. */\n restored: boolean;\n /** Clients attached right now (dashboard Terminal tabs, `work attach`).\n * Additive: a host from before it sends none. */\n clients?: number;\n /** When the PTY last printed anything (ISO). Additive, like clients. */\n lastOutputAt?: string;\n /** The tool's binary (`claude`, `opencode`…). Additive, like clients. */\n tool?: string;\n}\n\n/** Client → host frames on the attach WebSocket (text, JSON). Host →\n * client PTY output is sent as binary frames; control frames as text. */\nexport type ClientFrame = { type: 'input'; data: string } | { type: 'resize'; cols: number; rows: number };\n\nexport type HostControlFrame =\n /** Sent once, first, on attach: the serialized screen and the grid it was\n * drawn for. Clients draw it at exactly cols×rows, then resize to their\n * own size (which makes Claude redraw), and only then send input. */\n { type: 'replay'; data: string; cols: number; rows: number } | { type: 'exit'; code: number } | { type: 'error'; message: string };\n\nexport function hostInfoPath(): string {\n return path.join(getConfigDir(), 'pty-host.json');\n}\n\n/** Held by a starting host from \"is one running?\" through writing its\n * discovery file AND restoring the saved sessions — so two hosts can't\n * both start, and a `work remove` racing a start waits for the restore\n * instead of slipping between it (see stopSessionPty). */\nexport function hostStartLockPath(): string {\n return path.join(getConfigDir(), 'pty-host.start.lock');\n}\n\n/** The pre-SQLite restore list. Only the one-time import reads it now. */\nexport function ptySessionsPath(): string {\n return path.join(getConfigDir(), 'pty-sessions.json');\n}\n\nexport function readHostInfo(): HostInfo | null {\n try {\n const raw = JSON.parse(fs.readFileSync(hostInfoPath(), 'utf-8')) as HostInfo;\n if (typeof raw.port === 'number' && typeof raw.token === 'string' && typeof raw.pid === 'number') {\n return raw;\n }\n return null;\n } catch {\n return null;\n }\n}\n","import path from 'node:path';\nimport { spawnDetachedWork } from '../platform/process.js';\nimport { getConfigDir } from '../platform/config.js';\nimport { isPidAlive } from '../platform/process.js';\nimport { ensureFile, withFileLock } from '../platform/fs-safe.js';\nimport { PROTOCOL_VERSION, readHostInfo, type HostInfo, type PtyInfo, type SpawnSpec } from './pty-host-protocol.js';\n\nexport class PtyHostVersionError extends Error {\n constructor(readonly hostVersion: number) {\n super(\n `A PTY host from an older build (protocol v${hostVersion}, need v${PROTOCOL_VERSION}) ` +\n 'is running. Restart it with `work pty-host --restart` — sessions come back via --continue.',\n );\n }\n}\n\n/**\n * Ask whoever listens on the discovery file's port whether it's our host:\n * it must answer /health with our token. Returns what it reports (its\n * protocol version and pid), or null if nothing answers / the token is\n * wrong — i.e. the discovery file is stale.\n */\nexport async function probeHost(info: HostInfo, timeoutMs = 800): Promise<{ version: number; pid: number } | null> {\n const r = await probeHostDetailed(info, timeoutMs);\n return r.kind === 'host' ? { version: r.version, pid: r.pid } : null;\n}\n\nexport type ProbeResult =\n | { kind: 'host'; version: number; pid: number }\n /** Nothing listens on the port (connection refused): definitely gone. */\n | { kind: 'refused' }\n /** Something answered, but not as our host (wrong token, bad body). */\n | { kind: 'not-ours' }\n /** No answer in time — could be a BUSY host (e.g. restoring many\n * sessions). Never treat this as proof the host is gone. */\n | { kind: 'timeout' };\n\nexport async function probeHostDetailed(info: HostInfo, timeoutMs = 800): Promise<ProbeResult> {\n try {\n const res = await fetch(`http://127.0.0.1:${info.port}/health`, {\n headers: { 'x-work-token': info.token },\n signal: AbortSignal.timeout(timeoutMs),\n });\n if (!res.ok) return { kind: 'not-ours' };\n const body = (await res.json()) as { version?: number; pid?: number };\n if (typeof body.version !== 'number' || typeof body.pid !== 'number') return { kind: 'not-ours' };\n return { kind: 'host', version: body.version, pid: body.pid };\n } catch (err) {\n const e = err as { name?: string; cause?: { code?: string } };\n if (e.cause?.code === 'ECONNREFUSED') return { kind: 'refused' };\n if (e.name === 'TimeoutError' || e.name === 'AbortError') return { kind: 'timeout' };\n return { kind: 'refused' };\n }\n}\n\n/** A host is there but didn't answer in time (event loop busy: a ConPTY\n * spawn, restoring many sessions). It is RUNNING — never start another. */\nexport class PtyHostBusyError extends Error {\n constructor() {\n super('The PTY host is running but not answering (busy?). Try again in a moment.');\n this.name = 'PtyHostBusyError';\n }\n}\n\n/**\n * The running host, or null when there is none. Throws PtyHostVersionError\n * on a mismatch, and PtyHostBusyError when a host holds the port but\n * doesn't answer even a patient second probe — treating that as \"no host\"\n * would start a second one, which restores every session again (two\n * Claudes per conversation).\n */\nexport async function findHost(timeoutsMs: number[] = [800, 5000]): Promise<HostInfo | null> {\n const info = readHostInfo();\n if (!info) return null;\n let probe: ProbeResult = { kind: 'timeout' };\n for (const t of timeoutsMs) {\n probe = await probeHostDetailed(info, t);\n if (probe.kind !== 'timeout') break;\n }\n if (probe.kind === 'timeout') {\n // No answer: a host whose process is alive is busy — but a dead one\n // (crashed, killed) left a stale file, and whatever now holds that port\n // is not our host. Calling THAT busy would make the host unstartable.\n if (!isPidAlive(info.pid)) return null;\n throw new PtyHostBusyError();\n }\n if (probe.kind !== 'host' || probe.pid !== info.pid) return null;\n if (probe.version !== PROTOCOL_VERSION) throw new PtyHostVersionError(probe.version);\n return info;\n}\n\n/**\n * findHost that waits out a busy host: retries until it answers or\n * `timeoutMs` passes, then throws PtyHostBusyError. For callers that must\n * reach the host (stopping a session before its worktree is deleted).\n */\nexport async function findHostPatient(timeoutMs = 20_000): Promise<HostInfo | null> {\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n try {\n return await findHost();\n } catch (err) {\n if (!(err instanceof PtyHostBusyError) || Date.now() >= deadline) throw err;\n await new Promise((r) => setTimeout(r, 250));\n }\n }\n}\n\n/** findHost for \"should I start one?\": a busy host counts as running. */\nasync function findHostOrBusy(): Promise<HostInfo | 'busy' | null> {\n try {\n return await findHost();\n } catch (err) {\n if (err instanceof PtyHostBusyError) return 'busy';\n throw err;\n }\n}\n\n/** Serializes host spawning across `work` processes (see ensureHost). */\nexport function hostSpawnLockPath(): string {\n return path.join(getConfigDir(), 'pty-host.spawn.lock');\n}\n\nlet inFlight: Promise<HostInfo> | null = null;\n\n/**\n * Return the running host, spawning a detached one if none is. `workBin` is\n * the path to the `work` binary (dist/bin.js) — passed in rather than\n * derived because core can't reach the commands layer's resolver (§2.1).\n *\n * Exactly one host may start: two hosts would each restore every saved\n * session — two Claudes on one conversation. So spawning is single-flight\n * within this process (concurrent callers share one attempt) and serialized\n * across processes by a file lock held from \"is one running?\" until the new\n * host answers; a caller that waited on the lock re-checks and finds it.\n */\n// A cold host start loads the whole `work` bundle; on a busy machine (right\n// after login with autostart, or a loaded test run) that can pass 8 s.\nexport function ensureHost(workBin: string, timeoutMs = 20_000): Promise<HostInfo> {\n if (!inFlight) {\n inFlight = ensureHostLocked(workBin, timeoutMs).finally(() => {\n inFlight = null;\n });\n }\n return inFlight;\n}\n\nasync function ensureHostLocked(workBin: string, timeoutMs: number): Promise<HostInfo> {\n const existing = await findHostOrBusy();\n if (existing === 'busy') return waitForHost(timeoutMs); // it's there; wait for it to answer\n if (existing) return existing;\n const lock = hostSpawnLockPath();\n ensureFile(lock, '');\n try {\n return await withFileLock(lock, async () => {\n // Another process may have started it while we waited for the lock.\n const started = await findHostOrBusy();\n if (started === 'busy') return waitForHost(timeoutMs);\n if (started) return started;\n spawnHost(workBin);\n return waitForHost(timeoutMs);\n });\n } catch (err) {\n // Couldn't get the lock in time (another process is mid-spawn and slow):\n // don't spawn a second one — wait for theirs.\n if ((err as { code?: string }).code === 'ELOCKED') return waitForHost(timeoutMs);\n throw err;\n }\n}\n\nfunction spawnHost(workBin: string): void {\n spawnDetachedWork(workBin, ['pty-host'], path.join(getConfigDir(), 'pty-host.log'));\n}\n\nasync function waitForHost(timeoutMs: number): Promise<HostInfo> {\n const deadline = Date.now() + timeoutMs;\n while (Date.now() < deadline) {\n const found = await findHost().catch(() => null);\n if (found) return found;\n await new Promise((r) => setTimeout(r, 100));\n }\n throw new Error('PTY host did not start (see ~/.work/pty-host.log)');\n}\n\nexport class PtyHostClient {\n constructor(readonly info: HostInfo) {}\n\n private async call<T>(method: string, p: string, body?: unknown): Promise<T> {\n const res = await fetch(`http://127.0.0.1:${this.info.port}${p}`, {\n method,\n headers: {\n 'x-work-token': this.info.token,\n ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(5000),\n });\n const json = (await res.json().catch(() => ({}))) as T & { error?: string };\n if (!res.ok) throw new Error(json.error ?? `PTY host ${method} ${p}: ${res.status}`);\n return json;\n }\n\n list(): Promise<PtyInfo[]> {\n return this.call('GET', '/ptys');\n }\n\n get(id: string): Promise<PtyInfo | null> {\n return this.call<PtyInfo>('GET', `/ptys/${encodeURIComponent(id)}`).catch(() => null);\n }\n\n spawn(id: string, spec: SpawnSpec): Promise<PtyInfo> {\n return this.call('POST', `/ptys/${encodeURIComponent(id)}`, spec);\n }\n\n /** The session's visible screen as text; null when it has none — or the\n * host predates this call (404 either way: nothing to answer by key). */\n async screen(id: string): Promise<string | null> {\n try {\n const r = await this.call<{ text?: unknown }>('GET', `/ptys/${encodeURIComponent(id)}/screen`);\n return typeof r.text === 'string' ? r.text : null;\n } catch {\n return null;\n }\n }\n\n async write(id: string, data: string): Promise<boolean> {\n try {\n await this.call('POST', `/ptys/${encodeURIComponent(id)}/write`, { data });\n return true;\n } catch {\n return false;\n }\n }\n\n async kill(id: string): Promise<void> {\n await this.call('DELETE', `/ptys/${encodeURIComponent(id)}`);\n }\n\n attachUrl(id: string): string {\n return `ws://127.0.0.1:${this.info.port}/ptys/${encodeURIComponent(id)}/attach?token=${this.info.token}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAgBV,IAAM,mBAAmB;AA2ChC,IAAM,cACJ;AAEF,IAAM,eAAe;AAGd,SAAS,QAAQ,KAAyC,OAA8D;AAC7H,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,OAAO,OAAO;AAAA,IAClB,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,KAAK,CAAC,KAAK,OAAO,IAAI,CAAC,MAAM,YAAY,CAAC,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAAA,EAC9H;AACA,SAAO,OAAO,KAAK,IAAI,EAAE,SAAS,OAAO;AAC3C;AAIO,SAAS,eAAe,GAA+B;AAC5D,QAAM,IAAI;AACV,SACE,CAAC,CAAC,KACF,OAAO,MAAM,YACb,OAAO,EAAE,QAAQ,YACjB,CAAC,CAAC,EAAE,QACJ,OAAO,EAAE,SAAS,aACjB,EAAE,YAAY,UACZ,CAAC,CAAC,EAAE,WAAW,OAAO,EAAE,YAAY,YAAY,OAAO,OAAO,E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ACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,KAAK,IAA2B;AACpC,UAAM,KAAK,KAAK,UAAU,SAAS,mBAAmB,EAAE,CAAC,EAAE;AAAA,EAC7D;AAAA,EAEA,UAAU,IAAoB;AAC5B,WAAO,kBAAkB,KAAK,KAAK,IAAI,SAAS,mBAAmB,EAAE,CAAC,iBAAiB,KAAK,KAAK,KAAK;AAAA,EACxG;AACF;","names":["path","path"]}
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ BUILD_DIR_NAMES
4
+ } from "./chunk-NDWSLQPB.js";
5
+
6
+ // src/core/worktree/repo-rules.ts
7
+ var baseName = (p) => p.replace(/[\\/]+$/, "").split(/[\\/]/).pop() ?? p;
8
+ var dirName = (p) => p.replace(/[\\/]+$/, "").replace(/[\\/][^\\/]*$/, "");
9
+ function pathKey(resolved, caseless) {
10
+ const r = resolved.replace(/\\/g, "/").replace(/\/+$/, "");
11
+ return caseless ? r.toLowerCase() : r;
12
+ }
13
+ var sameFolder = (a, b) => {
14
+ const caseless = /^[a-z]:/i.test(a) || /^[a-z]:/i.test(b);
15
+ return pathKey(a, caseless) === pathKey(b, caseless);
16
+ };
17
+ var ALIAS_RE = /^[a-z0-9][a-z0-9._-]*$/;
18
+ function aliasFromFolder(folder) {
19
+ return folder.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-._]+|[-._]+$/g, "") || "repo";
20
+ }
21
+ function suggestAlias(repoPath, taken) {
22
+ const base = aliasFromFolder(baseName(repoPath));
23
+ if (!taken(base)) return base;
24
+ const withParent = `${aliasFromFolder(baseName(dirName(repoPath)))}-${base}`;
25
+ if (!taken(withParent)) return withParent;
26
+ for (let n = 2; ; n++) if (!taken(`${base}-${n}`)) return `${base}-${n}`;
27
+ }
28
+ function enrollProblem(alias, repoPath, config) {
29
+ if (!ALIAS_RE.test(alias)) return "an alias is lowercase letters, digits, . _ - (starting with a letter or digit)";
30
+ if (alias in config.repos) return `\u201C${alias}\u201D is already the alias of ${config.repos[alias]}`;
31
+ if (alias in config.groups) return `\u201C${alias}\u201D is a group`;
32
+ const same = Object.entries(config.repos).find(([, p]) => sameFolder(p, repoPath));
33
+ if (same) return `already enrolled as \u201C${same[0]}\u201D`;
34
+ const folder = baseName(repoPath).toLowerCase();
35
+ const clash = Object.entries(config.repos).find(([, p]) => baseName(p).toLowerCase() === folder);
36
+ if (clash) return `another repo has the folder name \u201C${baseName(repoPath)}\u201D (${clash[0]}): their worktrees would share a folder`;
37
+ if (Object.keys(config.groups).some((g) => g.toLowerCase() === folder))
38
+ return `a group is called \u201C${folder}\u201D: its worktrees would share a folder`;
39
+ return null;
40
+ }
41
+ function groupProblem(name, members, config, opts) {
42
+ if (opts.creating) {
43
+ if (!ALIAS_RE.test(name)) return "a group name is lowercase letters, digits, . _ - (starting with a letter or digit)";
44
+ if (name in config.groups) return `a group \u201C${name}\u201D already exists`;
45
+ if (name in config.repos) return `\u201C${name}\u201D is a repo's alias`;
46
+ if (Object.values(config.repos).some((p) => baseName(p).toLowerCase() === name)) return `a repo's folder is called \u201C${name}\u201D`;
47
+ } else if (!(name in config.groups)) {
48
+ return `no group \u201C${name}\u201D`;
49
+ }
50
+ if (new Set(members).size < 2) return "a group needs at least two repos";
51
+ const unknown = members.filter((m) => !(m in config.repos));
52
+ if (unknown.length) return `not enrolled: ${unknown.join(", ")}`;
53
+ return null;
54
+ }
55
+
56
+ // src/core/worktree/repo-scan.ts
57
+ import fs from "fs";
58
+ import path from "path";
59
+ function samePathKey(p, platform = process.platform) {
60
+ return pathKey(path.resolve(p), platform === "win32");
61
+ }
62
+ function ownerRepo(url) {
63
+ const m = /[:/]([^/:]+)\/([^/]+?)(?:\.git)?\/?$/.exec(url.trim());
64
+ return m ? `${m[1]}/${m[2]}` : null;
65
+ }
66
+ function originUrl(configText) {
67
+ const section = /\[remote "origin"\]([\s\S]*?)(?=\n\[|$)/.exec(configText);
68
+ const url = section ? /^\s*url\s*=\s*(.+)$/m.exec(section[1]) : null;
69
+ if (!url) return null;
70
+ const v = url[1].trim().replace(/^"(.*)"$/, "$1");
71
+ return v.replace(/\\(["\\])/g, "$1");
72
+ }
73
+ function gitKind(dir) {
74
+ const g = path.join(dir, ".git");
75
+ let st;
76
+ try {
77
+ st = fs.statSync(g);
78
+ } catch {
79
+ return null;
80
+ }
81
+ if (st.isDirectory()) return "repo";
82
+ return "linked";
83
+ }
84
+ function readOrigin(dir) {
85
+ try {
86
+ const url = originUrl(fs.readFileSync(path.join(dir, ".git", "config"), "utf-8"));
87
+ return url ? ownerRepo(url) : null;
88
+ } catch {
89
+ return null;
90
+ }
91
+ }
92
+ function scanForRepos(root, opts = {}) {
93
+ const depth = opts.depth ?? 2;
94
+ const skip = new Set((opts.skip ?? []).filter(Boolean).map((p) => samePathKey(p)));
95
+ const found = [];
96
+ let level = [root];
97
+ for (let d = 0; d <= depth && level.length; d++) {
98
+ const next = [];
99
+ for (const dir of level) {
100
+ if (skip.has(samePathKey(dir))) continue;
101
+ const kind = d === 0 ? null : gitKind(dir);
102
+ if (kind === "repo") {
103
+ found.push({ path: dir, folder: path.basename(dir), origin: readOrigin(dir) });
104
+ continue;
105
+ }
106
+ if (kind === "linked") continue;
107
+ let entries;
108
+ try {
109
+ entries = fs.readdirSync(dir, { withFileTypes: true });
110
+ } catch {
111
+ continue;
112
+ }
113
+ for (const e of entries) {
114
+ if (!e.isDirectory() || e.name.startsWith(".") || BUILD_DIR_NAMES.has(e.name.toLowerCase())) continue;
115
+ next.push(path.join(dir, e.name));
116
+ }
117
+ }
118
+ level = next;
119
+ }
120
+ return found.sort((a, b) => a.folder.localeCompare(b.folder));
121
+ }
122
+
123
+ export {
124
+ suggestAlias,
125
+ enrollProblem,
126
+ groupProblem,
127
+ samePathKey,
128
+ ownerRepo,
129
+ originUrl,
130
+ scanForRepos
131
+ };
132
+ //# sourceMappingURL=chunk-R2LN3JJJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/worktree/repo-rules.ts","../src/core/worktree/repo-scan.ts"],"sourcesContent":["/**\n * The rules for enrolling repos and making groups (repo-admin.ts, the Repos\n * page, the demo): what alias a repo gets, and why one can't be used. Pure,\n * without node:path — the demo and the SPA import it.\n */\n\n/** A path's last part. */\nconst baseName = (p: string) =>\n p\n .replace(/[\\\\/]+$/, '')\n .split(/[\\\\/]/)\n .pop() ?? p;\n/** Its folder. */\nconst dirName = (p: string) => p.replace(/[\\\\/]+$/, '').replace(/[\\\\/][^\\\\/]*$/, '');\n\n/** A resolved path written one way, for comparing: `/`, no trailing separator, lowercase when `caseless` (Windows). */\nexport function pathKey(resolved: string, caseless: boolean): string {\n const r = resolved.replace(/\\\\/g, '/').replace(/\\/+$/, '');\n return caseless ? r.toLowerCase() : r;\n}\n\n/** Two paths as the same folder: separators, a trailing one and (with a drive letter) case don't matter. */\nconst sameFolder = (a: string, b: string) => {\n const caseless = /^[a-z]:/i.test(a) || /^[a-z]:/i.test(b);\n return pathKey(a, caseless) === pathKey(b, caseless);\n};\n\nconst ALIAS_RE = /^[a-z0-9][a-z0-9._-]*$/;\n\n/** A folder name as an alias: lowercase, only a-z 0-9 . _ - . Pure. */\nexport function aliasFromFolder(folder: string): string {\n return (\n folder\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, '-')\n .replace(/^[-._]+|[-._]+$/g, '') || 'repo'\n );\n}\n\n/**\n * The alias a found repo would get: its folder's, or — taken by an alias\n * or a group — its parent folder's in front (`iom-contracts`), then -2, -3….\n * Pure.\n */\nexport function suggestAlias(repoPath: string, taken: (alias: string) => boolean): string {\n const base = aliasFromFolder(baseName(repoPath));\n if (!taken(base)) return base;\n const withParent = `${aliasFromFolder(baseName(dirName(repoPath)))}-${base}`;\n if (!taken(withParent)) return withParent;\n for (let n = 2; ; n++) if (!taken(`${base}-${n}`)) return `${base}-${n}`;\n}\n\n/**\n * Why a repo can't be enrolled under `alias`; null when it can. Besides the\n * alias itself (its characters, an alias or group of that name), the\n * folder: worktrees go in `<worktreesRoot>/<folder>/`, so two repos with the\n * same folder name would share them. Pure.\n */\nexport function enrollProblem(\n alias: string,\n repoPath: string,\n config: { repos: Record<string, string>; groups: Record<string, string[]> },\n): string | null {\n if (!ALIAS_RE.test(alias)) return 'an alias is lowercase letters, digits, . _ - (starting with a letter or digit)';\n if (alias in config.repos) return `“${alias}” is already the alias of ${config.repos[alias]}`;\n if (alias in config.groups) return `“${alias}” is a group`;\n const same = Object.entries(config.repos).find(([, p]) => sameFolder(p, repoPath));\n if (same) return `already enrolled as “${same[0]}”`;\n const folder = baseName(repoPath).toLowerCase();\n const clash = Object.entries(config.repos).find(([, p]) => baseName(p).toLowerCase() === folder);\n if (clash) return `another repo has the folder name “${baseName(repoPath)}” (${clash[0]}): their worktrees would share a folder`;\n if (Object.keys(config.groups).some((g) => g.toLowerCase() === folder))\n return `a group is called “${folder}”: its worktrees would share a folder`;\n return null;\n}\n\n/** Why a group can't be called `name`, or made of `members`; null when it can. Pure. */\nexport function groupProblem(\n name: string,\n members: string[],\n config: { repos: Record<string, string>; groups: Record<string, string[]> },\n opts: { creating: boolean },\n): string | null {\n // The name is checked when it is given; an existing group keeps the one it has.\n if (opts.creating) {\n if (!ALIAS_RE.test(name)) return 'a group name is lowercase letters, digits, . _ - (starting with a letter or digit)';\n if (name in config.groups) return `a group “${name}” already exists`;\n if (name in config.repos) return `“${name}” is a repo's alias`;\n if (Object.values(config.repos).some((p) => baseName(p).toLowerCase() === name)) return `a repo's folder is called “${name}”`;\n } else if (!(name in config.groups)) {\n return `no group “${name}”`;\n }\n if (new Set(members).size < 2) return 'a group needs at least two repos';\n const unknown = members.filter((m) => !(m in config.repos));\n if (unknown.length) return `not enrolled: ${unknown.join(', ')}`;\n return null;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { BUILD_DIR_NAMES } from '../cleanup/build-folders.js';\nimport { pathKey } from './repo-rules.js';\nexport { aliasFromFolder, enrollProblem, groupProblem, suggestAlias } from './repo-rules.js';\n\n/**\n * Finding the git repos in a folder (the Repos page, `work config scan`):\n * a breadth-first walk, a few levels deep, that stops at each repo it finds\n * (a repo inside a repo is that repo's business), and skips what is never a\n * project of its own — build output, dot-folders, work's worktrees, a\n * worktree's or a submodule's `.git` file. Reads only: directory listings\n * and the `.git` entries.\n */\n\nexport interface FoundRepo {\n /** As found on disk. */\n path: string;\n /** Its folder name. */\n folder: string;\n /** `owner/name` from its origin URL, when it has one. */\n origin: string | null;\n}\n\n/** One way to write a path, for comparing: resolved, no trailing separator, `/`, lowercase on Windows. Pure. */\nexport function samePathKey(p: string, platform: NodeJS.Platform = process.platform): string {\n return pathKey(path.resolve(p), platform === 'win32');\n}\n\n/** `owner/name` from an origin URL (https or ssh, with or without .git); null when it isn't one. Pure. */\nexport function ownerRepo(url: string): string | null {\n const m = /[:/]([^/:]+)\\/([^/]+?)(?:\\.git)?\\/?$/.exec(url.trim());\n return m ? `${m[1]}/${m[2]}` : null;\n}\n\n/** The origin URL in a `.git/config` text. Pure. */\nexport function originUrl(configText: string): string | null {\n const section = /\\[remote \"origin\"\\]([\\s\\S]*?)(?=\\n\\[|$)/.exec(configText);\n const url = section ? /^\\s*url\\s*=\\s*(.+)$/m.exec(section[1]) : null;\n if (!url) return null;\n // As git writes a value: maybe quoted, with \\\\ and \\\" escaped (a Windows path).\n const v = url[1].trim().replace(/^\"(.*)\"$/, '$1');\n return v.replace(/\\\\([\"\\\\])/g, '$1');\n}\n\n/** What a folder's `.git` says it is: a repo, a linked worktree or a submodule (a `.git` file), or nothing. */\nfunction gitKind(dir: string): 'repo' | 'linked' | null {\n const g = path.join(dir, '.git');\n let st: fs.Stats;\n try {\n st = fs.statSync(g);\n } catch {\n return null;\n }\n if (st.isDirectory()) return 'repo';\n // A file: `gitdir: …/.git/worktrees/x` (a worktree) or `…/.git/modules/x` (a submodule) — part of another repo.\n return 'linked';\n}\n\nfunction readOrigin(dir: string): string | null {\n try {\n const url = originUrl(fs.readFileSync(path.join(dir, '.git', 'config'), 'utf-8'));\n return url ? ownerRepo(url) : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The git repos under `root`, at most `depth` folders down (1 = its\n * children). `skip`: folders never walked into (work's worktrees root),\n * compared with samePathKey. A root that doesn't exist gives none.\n */\nexport function scanForRepos(root: string, opts: { depth?: number; skip?: string[] } = {}): FoundRepo[] {\n const depth = opts.depth ?? 2;\n const skip = new Set((opts.skip ?? []).filter(Boolean).map((p) => samePathKey(p)));\n const found: FoundRepo[] = [];\n let level: string[] = [root];\n for (let d = 0; d <= depth && level.length; d++) {\n const next: string[] = [];\n for (const dir of level) {\n if (skip.has(samePathKey(dir))) continue;\n const kind = d === 0 ? null : gitKind(dir);\n if (kind === 'repo') {\n found.push({ path: dir, folder: path.basename(dir), origin: readOrigin(dir) });\n continue; // a repo's insides are its own\n }\n if (kind === 'linked') continue;\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n continue;\n }\n for (const e of entries) {\n if (!e.isDirectory() || e.name.startsWith('.') || BUILD_DIR_NAMES.has(e.name.toLowerCase())) continue;\n next.push(path.join(dir, e.name));\n }\n }\n level = next;\n }\n return found.sort((a, b) => a.folder.localeCompare(b.folder));\n}\n"],"mappings":";;;;;;AAOA,IAAM,WAAW,CAAC,MAChB,EACG,QAAQ,WAAW,EAAE,EACrB,MAAM,OAAO,EACb,IAAI,KAAK;AAEd,IAAM,UAAU,CAAC,MAAc,EAAE,QAAQ,WAAW,EAAE,EAAE,QAAQ,iBAAiB,EAAE;AAG5E,SAAS,QAAQ,UAAkB,UAA2B;AACnE,QAAM,IAAI,SAAS,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,EAAE;AACzD,SAAO,WAAW,EAAE,YAAY,IAAI;AACtC;AAGA,IAAM,aAAa,CAAC,GAAW,MAAc;AAC3C,QAAM,WAAW,WAAW,KAAK,CAAC,KAAK,WAAW,KAAK,CAAC;AACxD,SAAO,QAAQ,GAAG,QAAQ,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E,KAAK,WAAW,GAAG,KAAK,gBAAgB,IAAI,EAAE,KAAK,YAAY,CAAC,EAAG;AAC7F,aAAK,KAAK,KAAK,KAAK,KAAK,EAAE,IAAI,CAAC;AAAA,MAClC;AAAA,IACF;AACA,YAAQ;AAAA,EACV;AACA,SAAO,MAAM,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,cAAc,EAAE,MAAM,CAAC;AAC9D;","names":[]}
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/platform/spawn.ts
4
+ import { createRequire } from "module";
5
+ var loaded = null;
6
+ var load = () => loaded ??= createRequire(import.meta.url)("cross-spawn");
7
+ var spawn = Object.assign((...args) => load()(...args), {
8
+ sync: (...args) => load().sync(...args)
9
+ });
10
+ var spawn_default = spawn;
11
+
12
+ export {
13
+ spawn_default
14
+ };
15
+ //# sourceMappingURL=chunk-RCYI7SRA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/platform/spawn.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport type CrossSpawnModule from 'cross-spawn';\n\n/**\n * cross-spawn, loaded on first use. core's modules all spawn through it, and\n * importing it up front put it (and its dependencies) on every `work hook`\n * — which runs twice per turn of every Claude — whether the hook spawned\n * anything or not. Same function, same `.sync`.\n */\ntype CrossSpawn = typeof CrossSpawnModule;\n\nlet loaded: CrossSpawn | null = null;\nconst load = (): CrossSpawn => (loaded ??= createRequire(import.meta.url)('cross-spawn') as CrossSpawn);\n\nconst spawn = Object.assign((...args: unknown[]) => (load() as unknown as (...a: unknown[]) => unknown)(...args), {\n sync: (...args: unknown[]) => (load().sync as unknown as (...a: unknown[]) => unknown)(...args),\n}) as unknown as CrossSpawn;\n\nexport default spawn;\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAW9B,IAAI,SAA4B;AAChC,IAAM,OAAO,MAAmB,WAAW,cAAc,YAAY,GAAG,EAAE,aAAa;AAEvF,IAAM,QAAQ,OAAO,OAAO,IAAI,SAAqB,KAAK,EAA8C,GAAG,IAAI,GAAG;AAAA,EAChH,MAAM,IAAI,SAAqB,KAAK,EAAE,KAAiD,GAAG,IAAI;AAChG,CAAC;AAED,IAAO,gBAAQ;","names":[]}
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/sessions/session-control.ts
4
+ var MAX_SEND_CHARS = 2e4;
5
+ async function sendToSession(id, text, deps, opts = {}) {
6
+ const body = text.trim();
7
+ if (!body) return { ok: false, status: 400, error: "the message is empty" };
8
+ if (body.length > MAX_SEND_CHARS) return { ok: false, status: 400, error: `the message is over ${MAX_SEND_CHARS} characters` };
9
+ if (deps.archived(id)) return { ok: false, status: 409, error: "it is archived: restore it first" };
10
+ if (deps.unsafe(id) && !opts.force) {
11
+ return {
12
+ ok: false,
13
+ status: 409,
14
+ error: "its Claude runs with permission checks off (--unsafe), so it would act on this without asking you; send with --force if you mean it"
15
+ };
16
+ }
17
+ const sentAt = (opts.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
18
+ const delivered = await deps.post(id, body);
19
+ if (delivered) return { ok: true, how: delivered, sentAt };
20
+ if (deps.hostRuns(id)) return { ok: true, how: "next-turn", sentAt };
21
+ if (deps.runningOutside(id)) return { ok: true, how: "outside", sentAt };
22
+ if (!await deps.start(id))
23
+ return { ok: false, status: 502, error: "queued, but its Claude could not be started: it gets it when you open the session" };
24
+ return { ok: true, how: "started", sentAt };
25
+ }
26
+ function sendHowText(how) {
27
+ switch (how) {
28
+ case "typed":
29
+ return "sent: typed into its terminal";
30
+ case "next-turn":
31
+ return "queued: it is working, so it gets this when the turn ends";
32
+ case "outside":
33
+ return "queued: its Claude runs in a terminal outside work, and gets this on its next turn there";
34
+ case "started":
35
+ return "sent: its Claude was started (resuming its conversation) with this as the first message";
36
+ }
37
+ }
38
+ async function waitForTurn(id, deps, opts) {
39
+ const deadline = deps.now() + opts.timeoutMs;
40
+ const after = opts.after ? Date.parse(opts.after) : null;
41
+ for (; ; ) {
42
+ const s = deps.status(id);
43
+ const fresh = after === null || !!s && Date.parse(s.since) > after;
44
+ if (s && s.state !== "working" && fresh) return { ok: true, status: s };
45
+ if (deps.now() >= deadline) return { ok: false, reason: "timeout", status: s };
46
+ await deps.sleep(opts.pollMs ?? 1e3);
47
+ }
48
+ }
49
+ function pendingRequest(status) {
50
+ return status?.state === "needs_input" && status.request ? status.request : null;
51
+ }
52
+ function parseDuration(text) {
53
+ const m = /^\s*(\d+(?:\.\d+)?)\s*(s|m|h)?\s*$/i.exec(text);
54
+ if (!m) return null;
55
+ const n = Number(m[1]);
56
+ const unit = (m[2] ?? "s").toLowerCase();
57
+ return Math.round(n * (unit === "h" ? 36e5 : unit === "m" ? 6e4 : 1e3));
58
+ }
59
+
60
+ export {
61
+ sendToSession,
62
+ sendHowText,
63
+ waitForTurn,
64
+ pendingRequest,
65
+ parseDuration
66
+ };
67
+ //# sourceMappingURL=chunk-RYNBBSLY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/sessions/session-control.ts"],"sourcesContent":["import type { AgentState } from '../status/attention.js';\nimport type { PermissionRequest, SendHow } from '../api-types.js';\n\n/**\n * Driving a session from outside its terminal — another Claude, a script,\n * you in a shell: send it a message, wait for its turn to end, answer its\n * permission prompt. The policy is here; I/O is passed in (the routes in\n * session-control-routes.ts give the real one, tests a fake).\n *\n * A message goes the way every note to a session goes (§ saved prompts): a\n * published comment, which the dashboard types into a terminal it owns when\n * that Claude is idle, or which the prompt hook hands over on its next turn.\n * Never typed into a terminal directly.\n */\n\nexport const MAX_SEND_CHARS = 20_000;\n\nexport type { SendHow } from '../api-types.js';\n\nexport interface SendDeps {\n /** Queue it as a published comment (the comment route), resolving to what that route did with it: typed into an idle host Claude, left for the end of its turn, or null (no host terminal). */\n post: (id: string, body: string) => Promise<'typed' | 'next-turn' | null>;\n /** Its Claude runs in the PTY host. */\n hostRuns: (id: string) => boolean;\n /** Its Claude runs in a terminal outside work (seen in Claude Code's process files). */\n runningOutside: (id: string) => boolean;\n /** Start its Claude in the host, resuming its conversation, its first message saying a note is attached (NOTE_NUDGE). */\n start: (id: string) => Promise<boolean>;\n state: (id: string) => AgentState | null;\n /** It runs with permission checks off. */\n unsafe: (id: string) => boolean;\n archived: (id: string) => boolean;\n}\n\nexport type SendResult = { ok: true; how: SendHow; sentAt: string } | { ok: false; status: 400 | 409 | 502; error: string };\n\nexport async function sendToSession(\n id: string,\n text: string,\n deps: SendDeps,\n opts: { force?: boolean; now?: () => Date } = {},\n): Promise<SendResult> {\n const body = text.trim();\n if (!body) return { ok: false, status: 400, error: 'the message is empty' };\n if (body.length > MAX_SEND_CHARS) return { ok: false, status: 400, error: `the message is over ${MAX_SEND_CHARS} characters` };\n if (deps.archived(id)) return { ok: false, status: 409, error: 'it is archived: restore it first' };\n // A message to a Claude with permission checks off runs whatever it says,\n // unreviewed — and it may have come from another agent. Your say-so first.\n if (deps.unsafe(id) && !opts.force) {\n return {\n ok: false,\n status: 409,\n error:\n 'its Claude runs with permission checks off (--unsafe), so it would act on this without asking you; send with --force if you mean it',\n };\n }\n const sentAt = (opts.now?.() ?? new Date()).toISOString();\n // What the comment route did, as it decided it — not a second look at the state.\n const delivered = await deps.post(id, body);\n if (delivered) return { ok: true, how: delivered, sentAt };\n if (deps.hostRuns(id)) return { ok: true, how: 'next-turn', sentAt };\n if (deps.runningOutside(id)) return { ok: true, how: 'outside', sentAt };\n if (!(await deps.start(id)))\n return { ok: false, status: 502, error: 'queued, but its Claude could not be started: it gets it when you open the session' };\n return { ok: true, how: 'started', sentAt };\n}\n\n/** What `how` means, in a line. */\nexport function sendHowText(how: SendHow): string {\n switch (how) {\n case 'typed':\n return 'sent: typed into its terminal';\n case 'next-turn':\n return 'queued: it is working, so it gets this when the turn ends';\n case 'outside':\n return 'queued: its Claude runs in a terminal outside work, and gets this on its next turn there';\n case 'started':\n return 'sent: its Claude was started (resuming its conversation) with this as the first message';\n }\n}\n\nexport interface TurnStatus {\n state: AgentState;\n /** When it entered that state (ISO). */\n since: string;\n summary?: string;\n}\n\nexport interface WaitDeps {\n status: (id: string) => TurnStatus | null;\n sleep: (ms: number) => Promise<void>;\n now: () => number;\n}\n\nexport type WaitResult = { ok: true; status: TurnStatus } | { ok: false; reason: 'timeout'; status: TurnStatus | null };\n\n/**\n * Wait until the session isn't working: its turn ended (idle) or it asks\n * you something (needs input). With `after` (when a message was sent), only\n * a state entered after it counts — the turn that message started, not the\n * one before.\n */\nexport async function waitForTurn(\n id: string,\n deps: WaitDeps,\n opts: { after?: string; timeoutMs: number; pollMs?: number },\n): Promise<WaitResult> {\n const deadline = deps.now() + opts.timeoutMs;\n const after = opts.after ? Date.parse(opts.after) : null;\n for (;;) {\n const s = deps.status(id);\n const fresh = after === null || (!!s && Date.parse(s.since) > after);\n if (s && s.state !== 'working' && fresh) return { ok: true, status: s };\n if (deps.now() >= deadline) return { ok: false, reason: 'timeout', status: s };\n await deps.sleep(opts.pollMs ?? 1000);\n }\n}\n\n/** The permission prompt it is waiting on, if any (what `work answer` shows, and must send back). */\nexport function pendingRequest(status: { state: AgentState; request?: PermissionRequest } | null): PermissionRequest | null {\n return status?.state === 'needs_input' && status.request ? status.request : null;\n}\n\n/** Parse \"15m\", \"90s\", \"2h\", or a number of seconds. */\nexport function parseDuration(text: string): number | null {\n const m = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(s|m|h)?\\s*$/i.exec(text);\n if (!m) return null;\n const n = Number(m[1]);\n const unit = (m[2] ?? 's').toLowerCase();\n return Math.round(n * (unit === 'h' ? 3_600_000 : unit === 'm' ? 60_000 : 1000));\n}\n"],"mappings":";;;AAeO,IAAM,iBAAiB;AAqB9B,eAAsB,cACpB,IACA,MACA,MACA,OAA8C,CAAC,GAC1B;AACrB,QAAM,OAAO,KAAK,KAAK;AACvB,MAAI,CAAC,KAAM,QAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,uBAAuB;AAC1E,MAAI,KAAK,SAAS,eAAgB,QAAO,EAAE,IAAI,OAAO,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O,QAAO,EAAE,IAAI,MAAM,QAAQ,EAAE;AACtE,QAAI,KAAK,IAAI,KAAK,SAAU,QAAO,EAAE,IAAI,OAAO,QAAQ,WAAW,QAAQ,EAAE;AAC7E,UAAM,KAAK,MAAM,KAAK,UAAU,GAAI;AAAA,EACtC;AACF;AAGO,SAAS,eAAe,QAA6F;AAC1H,SAAO,QAAQ,UAAU,iBAAiB,OAAO,UAAU,OAAO,UAAU;AAC9E;AAGO,SAAS,cAAc,MAA6B;AACzD,QAAM,IAAI,sCAAsC,KAAK,IAAI;AACzD,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,IAAI,OAAO,EAAE,CAAC,CAAC;AACrB,QAAM,QAAQ,EAAE,CAAC,KAAK,KAAK,YAAY;AACvC,SAAO,KAAK,MAAM,KAAK,SAAS,MAAM,OAAY,SAAS,MAAM,MAAS,IAAK;AACjF;","names":[]}
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/commands/shared/console-reporter.ts
4
+ import chalk from "chalk";
5
+ var COLOR = {
6
+ step: chalk.cyan,
7
+ info: (s) => s,
8
+ detail: chalk.gray,
9
+ success: chalk.green,
10
+ warn: chalk.yellow,
11
+ error: chalk.red
12
+ };
13
+ function reportStreamFor(args) {
14
+ const end = args.indexOf("--");
15
+ const own = end === -1 ? args : args.slice(0, end);
16
+ return own.some((a) => a === "--json" || a === "--json=true") ? "stderr" : "stdout";
17
+ }
18
+ function consoleReporter(stream = "stdout") {
19
+ return (level, text) => {
20
+ const line = COLOR[level](text);
21
+ if (level === "error" || stream === "stderr") console.error(line);
22
+ else console.log(line);
23
+ };
24
+ }
25
+
26
+ export {
27
+ reportStreamFor,
28
+ consoleReporter
29
+ };
30
+ //# sourceMappingURL=chunk-S5HJT7CM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/shared/console-reporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { ReportLevel, Reporter } from '../../core/platform/report.js';\n\n/**\n * How the CLI shows core's reports. Colors live here, not in core.\n *\n * `stream`: `work` writes to stdout (as it always has); `wd` writes status\n * to stderr, since its stdout carries data only (the review markdown). Errors\n * always go to stderr.\n */\nconst COLOR: Record<ReportLevel, (s: string) => string> = {\n step: chalk.cyan,\n info: (s) => s,\n detail: chalk.gray,\n success: chalk.green,\n warn: chalk.yellow,\n error: chalk.red,\n};\n\n/**\n * Where a `work` invocation shows its reports: stderr when it was asked for\n * `--json`, whose stdout must be the JSON and nothing else (a script parses\n * it — `work cleanup --apply --json` once mixed \"Removed worktree\" lines into\n * it); stdout otherwise. Arguments after a bare `--` belong to something else.\n */\nexport function reportStreamFor(args: readonly string[]): 'stdout' | 'stderr' {\n const end = args.indexOf('--');\n const own = end === -1 ? args : args.slice(0, end);\n return own.some((a) => a === '--json' || a === '--json=true') ? 'stderr' : 'stdout';\n}\n\nexport function consoleReporter(stream: 'stdout' | 'stderr' = 'stdout'): Reporter {\n return (level, text) => {\n const line = COLOR[level](text);\n if (level === 'error' || stream === 'stderr') console.error(line);\n else console.log(line);\n };\n}\n"],"mappings":";;;AAAA,OAAO,WAAW;AAUlB,IAAM,QAAoD;AAAA,EACxD,MAAM,MAAM;AAAA,EACZ,MAAM,CAAC,MAAM;AAAA,EACb,QAAQ,MAAM;AAAA,EACd,SAAS,MAAM;AAAA,EACf,MAAM,MAAM;AAAA,EACZ,OAAO,MAAM;AACf;AAQO,SAAS,gBAAgB,MAA8C;AAC5E,QAAM,MAAM,KAAK,QAAQ,IAAI;AAC7B,QAAM,MAAM,QAAQ,KAAK,OAAO,KAAK,MAAM,GAAG,GAAG;AACjD,SAAO,IAAI,KAAK,CAAC,MAAM,MAAM,YAAY,MAAM,aAAa,IAAI,WAAW;AAC7E;AAEO,SAAS,gBAAgB,SAA8B,UAAoB;AAChF,SAAO,CAAC,OAAO,SAAS;AACtB,UAAM,OAAO,MAAM,KAAK,EAAE,IAAI;AAC9B,QAAI,UAAU,WAAW,WAAW,SAAU,SAAQ,MAAM,IAAI;AAAA,QAC3D,SAAQ,IAAI,IAAI;AAAA,EACvB;AACF;","names":[]}