@moberg_hr/work-tree 2.0.5 → 2.0.7

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 (84) hide show
  1. package/dist/bin.js +1 -1
  2. package/dist/{chunk-46UD4QBL.js → chunk-5RRKVAIZ.js} +3 -2
  3. package/dist/chunk-5RRKVAIZ.js.map +1 -0
  4. package/dist/{chunk-UBC5DNLT.js → chunk-6HDVRMCX.js} +3 -3
  5. package/dist/{chunk-BSCAA322.js → chunk-7Z2USU3A.js} +22 -8
  6. package/dist/chunk-7Z2USU3A.js.map +1 -0
  7. package/dist/chunk-C4LRHXEB.js +9 -0
  8. package/dist/{chunk-FOG4WG3Y.js → chunk-CNFPZVNO.js} +2 -2
  9. package/dist/{chunk-ESPZRTUB.js → chunk-DH2PLKCW.js} +2 -2
  10. package/dist/{chunk-XHOQ7BWT.js → chunk-HB2I7GF7.js} +2 -2
  11. package/dist/{chunk-K7BSZRRF.js → chunk-IOO2OAUC.js} +4 -4
  12. package/dist/{chunk-G2O7EIKX.js → chunk-J2ZJ2DIJ.js} +2 -2
  13. package/dist/{chunk-XBNLSKTX.js → chunk-K3ESY6OJ.js} +3 -3
  14. package/dist/{chunk-HIXC67MU.js → chunk-LDCY457K.js} +2 -2
  15. package/dist/{chunk-CP6EFKEO.js → chunk-M2QL43DS.js} +2 -2
  16. package/dist/{chunk-XE2X7KH6.js → chunk-N23HFT4X.js} +73 -34
  17. package/dist/chunk-N23HFT4X.js.map +1 -0
  18. package/dist/{chunk-2VH5SJHF.js → chunk-QDNCUUNQ.js} +4 -4
  19. package/dist/chunk-QWIGFAKZ.js +334 -0
  20. package/dist/chunk-QWIGFAKZ.js.map +1 -0
  21. package/dist/{chunk-LRNAHZAK.js → chunk-VICXQQ5X.js} +4 -4
  22. package/dist/{chunk-YF66LR6K.js → chunk-YXTJVPOI.js} +16 -16
  23. package/dist/{cleanup-MCWFGGS6.js → cleanup-YVQOAMSK.js} +7 -7
  24. package/dist/{cli-LS45WVSJ.js → cli-VSCHBZRS.js} +3 -3
  25. package/dist/{config-TPYNBTVM.js → config-4W5MMHLU.js} +5 -5
  26. package/dist/{fork-ET4OKRNC.js → fork-ZBEMNEPA.js} +5 -5
  27. package/dist/{init-NGL64E3F.js → init-J2AB37DO.js} +5 -5
  28. package/dist/{move-I7SYL4FY.js → move-O7NEJZQV.js} +9 -13
  29. package/dist/move-O7NEJZQV.js.map +1 -0
  30. package/dist/{overlaps-3LZXSDYZ.js → overlaps-SKKGH6EG.js} +4 -4
  31. package/dist/{pr-JM4DRRIV.js → pr-AC44DGJY.js} +2 -2
  32. package/dist/{prune-5NUZUVYL.js → prune-NQOVBIFT.js} +6 -6
  33. package/dist/{remove-EFQQQRCW.js → remove-JESX7RCN.js} +5 -5
  34. package/dist/{sessions-CAOAXKKG.js → sessions-T6UXM2OX.js} +4 -4
  35. package/dist/{sync-LSUID373.js → sync-E4CU4IHG.js} +6 -6
  36. package/dist/{tree-CMDHHEUW.js → tree-RAN6SQKW.js} +32 -2
  37. package/dist/tree-RAN6SQKW.js.map +1 -0
  38. package/dist/{update-K73WHYY3.js → update-5DM5V2E3.js} +3 -3
  39. package/dist/wd-bin.js +2 -2
  40. package/dist/web/assets/{PtyView-Bst9Dw6x.js → PtyView-Ci395OL2.js} +2 -2
  41. package/dist/web/assets/{PtyView-Bst9Dw6x.js.map → PtyView-Ci395OL2.js.map} +1 -1
  42. package/dist/web/assets/index-D-_oxT3O.css +1 -0
  43. package/dist/web/assets/index-DjdfILvB.js +118 -0
  44. package/dist/web/assets/index-DjdfILvB.js.map +1 -0
  45. package/dist/web/index.html +2 -2
  46. package/dist/{web-PY55DXYZ.js → web-EUI5U2H4.js} +166 -317
  47. package/dist/web-EUI5U2H4.js.map +1 -0
  48. package/npm-shrinkwrap.json +2 -2
  49. package/package.json +1 -1
  50. package/dist/chunk-46UD4QBL.js.map +0 -1
  51. package/dist/chunk-BSCAA322.js.map +0 -1
  52. package/dist/chunk-GHO7HYP6.js +0 -9
  53. package/dist/chunk-XE2X7KH6.js.map +0 -1
  54. package/dist/move-I7SYL4FY.js.map +0 -1
  55. package/dist/tree-CMDHHEUW.js.map +0 -1
  56. package/dist/web/assets/index-CV8NpZB8.css +0 -1
  57. package/dist/web/assets/index-CcSEllUR.js +0 -117
  58. package/dist/web/assets/index-CcSEllUR.js.map +0 -1
  59. package/dist/web-PY55DXYZ.js.map +0 -1
  60. /package/dist/{chunk-UBC5DNLT.js.map → chunk-6HDVRMCX.js.map} +0 -0
  61. /package/dist/{chunk-GHO7HYP6.js.map → chunk-C4LRHXEB.js.map} +0 -0
  62. /package/dist/{chunk-FOG4WG3Y.js.map → chunk-CNFPZVNO.js.map} +0 -0
  63. /package/dist/{chunk-ESPZRTUB.js.map → chunk-DH2PLKCW.js.map} +0 -0
  64. /package/dist/{chunk-XHOQ7BWT.js.map → chunk-HB2I7GF7.js.map} +0 -0
  65. /package/dist/{chunk-K7BSZRRF.js.map → chunk-IOO2OAUC.js.map} +0 -0
  66. /package/dist/{chunk-G2O7EIKX.js.map → chunk-J2ZJ2DIJ.js.map} +0 -0
  67. /package/dist/{chunk-XBNLSKTX.js.map → chunk-K3ESY6OJ.js.map} +0 -0
  68. /package/dist/{chunk-HIXC67MU.js.map → chunk-LDCY457K.js.map} +0 -0
  69. /package/dist/{chunk-CP6EFKEO.js.map → chunk-M2QL43DS.js.map} +0 -0
  70. /package/dist/{chunk-2VH5SJHF.js.map → chunk-QDNCUUNQ.js.map} +0 -0
  71. /package/dist/{chunk-LRNAHZAK.js.map → chunk-VICXQQ5X.js.map} +0 -0
  72. /package/dist/{chunk-YF66LR6K.js.map → chunk-YXTJVPOI.js.map} +0 -0
  73. /package/dist/{cleanup-MCWFGGS6.js.map → cleanup-YVQOAMSK.js.map} +0 -0
  74. /package/dist/{cli-LS45WVSJ.js.map → cli-VSCHBZRS.js.map} +0 -0
  75. /package/dist/{config-TPYNBTVM.js.map → config-4W5MMHLU.js.map} +0 -0
  76. /package/dist/{fork-ET4OKRNC.js.map → fork-ZBEMNEPA.js.map} +0 -0
  77. /package/dist/{init-NGL64E3F.js.map → init-J2AB37DO.js.map} +0 -0
  78. /package/dist/{overlaps-3LZXSDYZ.js.map → overlaps-SKKGH6EG.js.map} +0 -0
  79. /package/dist/{pr-JM4DRRIV.js.map → pr-AC44DGJY.js.map} +0 -0
  80. /package/dist/{prune-5NUZUVYL.js.map → prune-NQOVBIFT.js.map} +0 -0
  81. /package/dist/{remove-EFQQQRCW.js.map → remove-JESX7RCN.js.map} +0 -0
  82. /package/dist/{sessions-CAOAXKKG.js.map → sessions-T6UXM2OX.js.map} +0 -0
  83. /package/dist/{sync-LSUID373.js.map → sync-E4CU4IHG.js.map} +0 -0
  84. /package/dist/{update-K73WHYY3.js.map → update-5DM5V2E3.js.map} +0 -0
@@ -20,10 +20,10 @@ import {
20
20
  deleteMergedBranches,
21
21
  findMergedBranches,
22
22
  summarizeAgents
23
- } from "./chunk-LRNAHZAK.js";
23
+ } from "./chunk-VICXQQ5X.js";
24
24
  import {
25
25
  defaultCleanupDeps
26
- } from "./chunk-K7BSZRRF.js";
26
+ } from "./chunk-IOO2OAUC.js";
27
27
  import {
28
28
  addTask,
29
29
  completeTask,
@@ -44,7 +44,7 @@ import {
44
44
  DiffStatCache,
45
45
  findOverlaps,
46
46
  wantsDiffStat
47
- } from "./chunk-XHOQ7BWT.js";
47
+ } from "./chunk-HB2I7GF7.js";
48
48
  import {
49
49
  createDigestSource
50
50
  } from "./chunk-HZEYGMYK.js";
@@ -75,11 +75,16 @@ import {
75
75
  import {
76
76
  sendToSession
77
77
  } from "./chunk-RYNBBSLY.js";
78
+ import {
79
+ fetchAllPullRequests,
80
+ parsePrRef,
81
+ resolvePrToStart
82
+ } from "./chunk-QWIGFAKZ.js";
78
83
  import {
79
84
  archiveMergedSession,
80
85
  archiveWaiting,
81
86
  defaultArchiveDeps
82
- } from "./chunk-2VH5SJHF.js";
87
+ } from "./chunk-QDNCUUNQ.js";
83
88
  import {
84
89
  MAX_REPLY_CHARS,
85
90
  THREAD_ID,
@@ -99,12 +104,12 @@ import {
99
104
  defaultForkDeps,
100
105
  forkSession,
101
106
  startSessionWithPrompt
102
- } from "./chunk-CP6EFKEO.js";
107
+ } from "./chunk-M2QL43DS.js";
103
108
  import {
104
109
  createInChild,
105
110
  createInProcess,
106
111
  oneAtATime
107
- } from "./chunk-UBC5DNLT.js";
112
+ } from "./chunk-6HDVRMCX.js";
108
113
  import {
109
114
  resolveWorkBinPath
110
115
  } from "./chunk-AH5TM3NB.js";
@@ -112,7 +117,7 @@ import {
112
117
  teardownWorktree,
113
118
  toBaseSpec,
114
119
  wouldRefuseRemoval
115
- } from "./chunk-XE2X7KH6.js";
120
+ } from "./chunk-N23HFT4X.js";
116
121
  import {
117
122
  configurePtyPool,
118
123
  detachPtyPool,
@@ -154,7 +159,7 @@ import {
154
159
  stackedOn,
155
160
  updateFromBase,
156
161
  updateFromMain
157
- } from "./chunk-ESPZRTUB.js";
162
+ } from "./chunk-DH2PLKCW.js";
158
163
  import {
159
164
  sessionStatusView,
160
165
  shownState
@@ -190,7 +195,7 @@ import {
190
195
  } from "./chunk-LNHSBM4L.js";
191
196
  import {
192
197
  VERSION
193
- } from "./chunk-GHO7HYP6.js";
198
+ } from "./chunk-C4LRHXEB.js";
194
199
  import {
195
200
  resolveProjectTarget
196
201
  } from "./chunk-H5LKMR45.js";
@@ -230,7 +235,7 @@ import {
230
235
  checkTools,
231
236
  saveFolders,
232
237
  setupState
233
- } from "./chunk-HIXC67MU.js";
238
+ } from "./chunk-LDCY457K.js";
234
239
  import {
235
240
  git
236
241
  } from "./chunk-7NAXFBFI.js";
@@ -243,24 +248,22 @@ import {
243
248
  saveGroup,
244
249
  setRepoIgnored,
245
250
  setScanRoot
246
- } from "./chunk-G2O7EIKX.js";
251
+ } from "./chunk-J2ZJ2DIJ.js";
247
252
  import {
248
253
  openUrl
249
254
  } from "./chunk-5XMXZIJS.js";
250
255
  import {
251
256
  enrollProblem,
252
257
  groupProblem,
253
- originUrl,
254
- ownerRepo,
255
258
  suggestAlias
256
- } from "./chunk-BSCAA322.js";
257
- import "./chunk-FOG4WG3Y.js";
259
+ } from "./chunk-7Z2USU3A.js";
260
+ import "./chunk-CNFPZVNO.js";
258
261
  import {
259
262
  defaultRunner,
260
263
  mergeSelected,
261
264
  runShipAction,
262
265
  shipPreflight
263
- } from "./chunk-46UD4QBL.js";
266
+ } from "./chunk-5RRKVAIZ.js";
264
267
  import {
265
268
  DECISION_MARKER,
266
269
  STAGE_WANTS_YOU,
@@ -373,7 +376,7 @@ import {
373
376
  import chalk from "chalk";
374
377
 
375
378
  // src/server/web-server.ts
376
- import fs12 from "fs";
379
+ import fs11 from "fs";
377
380
 
378
381
  // src/server/routes/session-control-routes.ts
379
382
  function realDeps(app) {
@@ -1735,7 +1738,7 @@ function describeStall(s) {
1735
1738
  }
1736
1739
 
1737
1740
  // src/server/web-server.ts
1738
- import path14 from "path";
1741
+ import path13 from "path";
1739
1742
  import { Hono } from "hono";
1740
1743
  import { streamSSE as streamSSE2 } from "hono/streaming";
1741
1744
 
@@ -1862,226 +1865,6 @@ function checkBranch(target, branch, config, deps = realBranchCheckDeps) {
1862
1865
  };
1863
1866
  }
1864
1867
 
1865
- // src/core/pr/pr.ts
1866
- import { execFile as execFile2 } from "child_process";
1867
- import fs3 from "fs";
1868
- import path4 from "path";
1869
- function execAsync2(cmd, args, cwd, timeout) {
1870
- return new Promise((resolve, reject) => {
1871
- execFile2(cmd, args, { cwd, encoding: "utf-8", timeout, windowsHide: true }, (err, stdout) => {
1872
- if (err) reject(err);
1873
- else resolve(stdout ?? "");
1874
- });
1875
- });
1876
- }
1877
- function parsePrJson(stdout, repoAlias, currentUser) {
1878
- const parsed = JSON.parse(stdout);
1879
- const prs = Array.isArray(parsed) ? parsed : [];
1880
- return prs.map((pr) => toPrInfo(pr, repoAlias, currentUser));
1881
- }
1882
- function toPrInfo(pr, repoAlias, currentUser) {
1883
- {
1884
- let checksStatus = "NONE";
1885
- const checks = pr.statusCheckRollup ?? [];
1886
- if (checks.length > 0) {
1887
- const hasFailure = checks.some((c) => c.conclusion === "FAILURE" || c.conclusion === "TIMED_OUT" || c.conclusion === "CANCELLED");
1888
- const hasPending = checks.some((c) => c.status === "IN_PROGRESS" || c.status === "QUEUED" || c.status === "PENDING");
1889
- if (hasFailure) checksStatus = "FAILURE";
1890
- else if (hasPending) checksStatus = "PENDING";
1891
- else checksStatus = "SUCCESS";
1892
- }
1893
- let reviewDecision = "NONE";
1894
- if (pr.reviewDecision === "APPROVED") reviewDecision = "APPROVED";
1895
- else if (pr.reviewDecision === "CHANGES_REQUESTED") reviewDecision = "CHANGES_REQUESTED";
1896
- else if (pr.reviewDecision === "REVIEW_REQUIRED") reviewDecision = "REVIEW_REQUIRED";
1897
- let myReview = "NONE";
1898
- if (currentUser) {
1899
- const reviews = pr.reviews ?? [];
1900
- for (let i = reviews.length - 1; i >= 0; i--) {
1901
- if (reviews[i].author?.login?.toLowerCase() === currentUser.toLowerCase()) {
1902
- const state = reviews[i].state;
1903
- if (state === "APPROVED") myReview = "APPROVED";
1904
- else if (state === "CHANGES_REQUESTED") myReview = "CHANGES_REQUESTED";
1905
- else if (state === "COMMENTED") myReview = "COMMENTED";
1906
- break;
1907
- }
1908
- }
1909
- }
1910
- return {
1911
- number: pr.number ?? 0,
1912
- title: pr.title ?? "",
1913
- branch: pr.headRefName ?? "",
1914
- url: pr.url ?? "",
1915
- isDraft: pr.isDraft ?? false,
1916
- checksStatus,
1917
- reviewDecision,
1918
- myReview,
1919
- isMine: currentUser ? pr.author?.login?.toLowerCase() === currentUser.toLowerCase() : false,
1920
- conflicting: pr.mergeable === "CONFLICTING",
1921
- reviewRequested: !!currentUser && (pr.reviewRequests ?? []).some((r) => r?.login?.toLowerCase() === currentUser.toLowerCase()),
1922
- repoAlias
1923
- };
1924
- }
1925
- }
1926
- var PR_SEARCH_QUERY = `query($mine: String!, $asked: String!) {
1927
- viewer { login }
1928
- mine: search(query: $mine, type: ISSUE, first: 100) { issueCount nodes { ...pr } }
1929
- asked: search(query: $asked, type: ISSUE, first: 100) { issueCount nodes { ...pr } }
1930
- }
1931
- fragment pr on PullRequest {
1932
- number title url isDraft headRefName mergeable reviewDecision
1933
- author { login }
1934
- repository { nameWithOwner }
1935
- commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }
1936
- reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } } } }
1937
- latestReviews(first: 20) { nodes { author { login } state } }
1938
- }`;
1939
- var PR_SEARCH_VARS = {
1940
- mine: "is:pr is:open archived:false author:@me",
1941
- asked: "is:pr is:open archived:false review-requested:@me"
1942
- };
1943
- function rollupAsChecks(state) {
1944
- if (state === "FAILURE" || state === "ERROR") return [{ conclusion: "FAILURE", status: "COMPLETED" }];
1945
- if (state === "PENDING" || state === "EXPECTED") return [{ conclusion: null, status: "PENDING" }];
1946
- if (state === "SUCCESS") return [{ conclusion: "SUCCESS", status: "COMPLETED" }];
1947
- return [];
1948
- }
1949
- function parsePrSearch(stdout, aliasesOf) {
1950
- const data = JSON.parse(stdout)?.data ?? {};
1951
- const user = (data.viewer?.login ?? "").trim();
1952
- const seen = /* @__PURE__ */ new Set();
1953
- const prs = [];
1954
- let incomplete = false;
1955
- for (const key of ["mine", "asked"]) {
1956
- const result = data[key];
1957
- const nodes = (result?.nodes ?? []).filter((n) => !!n && typeof n.number === "number");
1958
- if ((result?.issueCount ?? 0) > nodes.length) incomplete = true;
1959
- for (const n of nodes) {
1960
- const pr = {
1961
- ...n,
1962
- statusCheckRollup: rollupAsChecks(n.commits?.nodes?.[0]?.commit?.statusCheckRollup?.state),
1963
- reviews: (n.latestReviews?.nodes ?? []).filter((r) => !!r),
1964
- reviewRequests: (n.reviewRequests?.nodes ?? []).map((r) => r?.requestedReviewer ?? null)
1965
- };
1966
- for (const alias of aliasesOf(n.repository?.nameWithOwner ?? "")) {
1967
- const id = `${alias}#${n.number}`;
1968
- if (seen.has(id)) continue;
1969
- seen.add(id);
1970
- prs.push(toPrInfo(pr, alias, user));
1971
- }
1972
- }
1973
- }
1974
- return { prs, incomplete };
1975
- }
1976
- function readSearch(stdout, aliasesOf) {
1977
- try {
1978
- return parsePrSearch(stdout, aliasesOf);
1979
- } catch {
1980
- return null;
1981
- }
1982
- }
1983
- function githubRepoOf(configText) {
1984
- const url = originUrl(configText);
1985
- if (!url || !/(^|[@/.])github\.com[:/]/i.test(url)) return null;
1986
- return ownerRepo(url)?.toLowerCase() ?? null;
1987
- }
1988
- var PR_LIST_LIMIT = 100;
1989
- async function fetchPullRequests(repoPath, repoAlias, currentUser) {
1990
- try {
1991
- const stdout = await execAsync2(
1992
- "gh",
1993
- [
1994
- "pr",
1995
- "list",
1996
- "--state",
1997
- "open",
1998
- "--json",
1999
- "number,title,headRefName,url,isDraft,statusCheckRollup,reviewDecision,reviews,reviewRequests,mergeable,author",
2000
- "--limit",
2001
- String(PR_LIST_LIMIT)
2002
- ],
2003
- repoPath,
2004
- 15e3
2005
- );
2006
- if (!stdout) return [];
2007
- return parsePrJson(stdout, repoAlias, currentUser);
2008
- } catch {
2009
- return null;
2010
- }
2011
- }
2012
- async function getCurrentUser() {
2013
- try {
2014
- const stdout = await execAsync2("gh", ["api", "user", "--jq", ".login"], process.cwd(), 5e3);
2015
- return stdout.trim();
2016
- } catch {
2017
- return "";
2018
- }
2019
- }
2020
- function defaultPrListDeps() {
2021
- let user = null;
2022
- return {
2023
- search: async () => {
2024
- try {
2025
- return await execAsync2(
2026
- "gh",
2027
- ["api", "graphql", "-f", `query=${PR_SEARCH_QUERY}`, "-f", `mine=${PR_SEARCH_VARS.mine}`, "-f", `asked=${PR_SEARCH_VARS.asked}`],
2028
- process.cwd(),
2029
- 2e4
2030
- );
2031
- } catch {
2032
- return null;
2033
- }
2034
- },
2035
- listRepo: async (repoPath, alias) => fetchPullRequests(repoPath, alias, await (user ??= getCurrentUser())),
2036
- gitConfig: (repoPath) => {
2037
- try {
2038
- return fs3.readFileSync(path4.join(repoPath, ".git", "config"), "utf-8");
2039
- } catch {
2040
- return null;
2041
- }
2042
- }
2043
- };
2044
- }
2045
- async function fetchAllPullRequests(repos, deps = defaultPrListDeps()) {
2046
- const entries = Object.entries(repos);
2047
- const onGithub = /* @__PURE__ */ new Map();
2048
- const elsewhere = [];
2049
- for (const [alias, repoPath] of entries) {
2050
- const text = deps.gitConfig(repoPath);
2051
- const gh = text ? githubRepoOf(text) : null;
2052
- if (gh) onGithub.set(gh, [...onGithub.get(gh) ?? [], alias]);
2053
- else elsewhere.push([alias, repoPath]);
2054
- }
2055
- const results = [];
2056
- const incomplete = [];
2057
- if (onGithub.size) {
2058
- const out = await deps.search();
2059
- const parsed = out ? readSearch(out, (repo) => onGithub.get(repo.toLowerCase()) ?? []) : null;
2060
- if (parsed) {
2061
- results.push(parsed.prs);
2062
- if (parsed.incomplete) incomplete.push(...[...onGithub.values()].flat());
2063
- } else {
2064
- const asked = new Set(elsewhere.map(([a]) => a));
2065
- for (const [alias, repoPath] of entries) if (!asked.has(alias)) elsewhere.push([alias, repoPath]);
2066
- }
2067
- }
2068
- const listed = await Promise.all(elsewhere.map(([alias, repoPath]) => deps.listRepo(repoPath, alias)));
2069
- results.push(...listed);
2070
- incomplete.push(...elsewhere.filter((_, i) => listed[i] === null || listed[i].length >= PR_LIST_LIMIT).map(([alias]) => alias));
2071
- const map = /* @__PURE__ */ new Map();
2072
- for (const prList of results) {
2073
- for (const pr of prList ?? []) {
2074
- const existing = map.get(pr.branch);
2075
- if (existing) {
2076
- existing.push(pr);
2077
- } else {
2078
- map.set(pr.branch, [pr]);
2079
- }
2080
- }
2081
- }
2082
- return { map, incomplete };
2083
- }
2084
-
2085
1868
  // src/server/shared-fetch.ts
2086
1869
  function createSharedFetch(fetch2, ttlMs, now = Date.now) {
2087
1870
  let last = null;
@@ -2245,8 +2028,8 @@ function mountPanesRoutes(app, opts) {
2245
2028
  }
2246
2029
 
2247
2030
  // src/server/routes/worktree-routes.ts
2248
- import fs4 from "fs";
2249
- import path5 from "path";
2031
+ import fs3 from "fs";
2032
+ import path4 from "path";
2250
2033
  import { spawn } from "child_process";
2251
2034
  import crossSpawn2 from "cross-spawn";
2252
2035
  import { zValidator as zValidator4 } from "@hono/zod-validator";
@@ -2265,6 +2048,12 @@ function mountWorktreeRoutes(app, opts) {
2265
2048
  });
2266
2049
  const startSession = opts.startSession ?? startSessionWithPrompt;
2267
2050
  const create = opts.create ?? createInProcess;
2051
+ const resolvePr = opts.resolvePr ?? ((ref, target) => resolvePrToStart(ref, loadConfig() ?? { repos: {}, groups: {} }, target));
2052
+ app.get("/api/pr-start", async (c) => {
2053
+ const ref = c.req.query("ref") ?? "";
2054
+ const r = await resolvePr(ref, c.req.query("target") || void 0);
2055
+ return r.ok ? c.json({ pr: r.pr }) : c.json({ error: r.error }, 400);
2056
+ });
2268
2057
  app.post("/api/worktrees", zValidator4("json", createSchema), async (c) => {
2269
2058
  const { target, base, jiraKey, prompt, name } = c.req.valid("json");
2270
2059
  const config = loadConfig();
@@ -2335,7 +2124,7 @@ function mountWorktreeRoutes(app, opts) {
2335
2124
  if (waiting.length) return { body: { error: `Not deleted: ${waiting.join("; ")}.`, blocked: waiting }, status: 409 };
2336
2125
  }
2337
2126
  try {
2338
- const onDisk = session.paths.some((p) => fs4.existsSync(p));
2127
+ const onDisk = session.paths.some((p) => fs3.existsSync(p));
2339
2128
  if (!sessionOnly && onDisk && session.paths.some((p) => wouldRefuseRemoval(p, force ?? false))) {
2340
2129
  return { body: { error: REFUSED }, status: 409 };
2341
2130
  }
@@ -2397,7 +2186,7 @@ function mountWorktreeRoutes(app, opts) {
2397
2186
  const id = c.req.param("id");
2398
2187
  const session = findSession2(id);
2399
2188
  if (!session) return c.json({ error: "unknown session" }, 404);
2400
- const target = session.isGroup ? path5.dirname(session.paths[0]) : session.paths[0];
2189
+ const target = session.isGroup ? path4.dirname(session.paths[0]) : session.paths[0];
2401
2190
  const editor = loadConfig()?.editor?.trim() || "code";
2402
2191
  const failed = await new Promise((resolve) => {
2403
2192
  try {
@@ -2451,7 +2240,7 @@ function mountWorktreeRoutes(app, opts) {
2451
2240
  import { zValidator as zValidator5 } from "@hono/zod-validator";
2452
2241
  import { z as z4 } from "zod";
2453
2242
  import { EventEmitter } from "events";
2454
- import path6 from "path";
2243
+ import path5 from "path";
2455
2244
  import { streamSSE } from "hono/streaming";
2456
2245
  function mountScopeRoutes(app, opts) {
2457
2246
  const checkpointWatched = /* @__PURE__ */ new Set();
@@ -2691,7 +2480,7 @@ function mountScopeRoutes(app, opts) {
2691
2480
  const fromSha = fromEntry.repos[p] ?? "HEAD";
2692
2481
  const toSha = toEntry === void 0 ? "working" : toEntry.repos[p] ?? "HEAD";
2693
2482
  return {
2694
- name: path6.basename(p),
2483
+ name: path5.basename(p),
2695
2484
  root: p,
2696
2485
  files: computeRangeDiff({ root: p, fromRef: fromSha, toRef: toSha })
2697
2486
  };
@@ -2708,7 +2497,7 @@ function mountScopeRoutes(app, opts) {
2708
2497
  }
2709
2498
  const resolved = scope.paths.map((p) => resolveRepoDiff(p, base, sessionBaseForPath(p)));
2710
2499
  const repos = scope.paths.map((p, i) => ({
2711
- name: path6.basename(p),
2500
+ name: path5.basename(p),
2712
2501
  root: p,
2713
2502
  resolvedBase: resolved[i].resolvedBase,
2714
2503
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -2739,7 +2528,7 @@ function mountScopeRoutes(app, opts) {
2739
2528
  if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {
2740
2529
  return c.json({ error: "bad path/start/end" }, 400);
2741
2530
  }
2742
- const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path6.basename(p) === repoName);
2531
+ const root = scope.paths.length === 1 ? scope.paths[0] : scope.paths.find((p) => path5.basename(p) === repoName);
2743
2532
  if (!root) return c.json({ error: "unknown repo" }, 404);
2744
2533
  const result = readContextLines({ root, relPath, start, end, ref });
2745
2534
  if (!result) return c.json({ error: "cannot read file" }, 400);
@@ -2923,7 +2712,7 @@ function mountTerminalRoutes(app) {
2923
2712
  }
2924
2713
 
2925
2714
  // src/server/routes/status-routes.ts
2926
- import path7 from "path";
2715
+ import path6 from "path";
2927
2716
 
2928
2717
  // src/core/pr/pr-watch-store.ts
2929
2718
  function createSeenStores() {
@@ -3079,7 +2868,7 @@ function mountStatusRoutes(app, opts) {
3079
2868
  const kind = notifyKindForTransition(status.prevState ? { state: status.prevState } : null, status);
3080
2869
  if (kind) {
3081
2870
  const config = loadConfig();
3082
- const launchDir = session.isGroup && session.paths[0] ? path7.dirname(session.paths[0]) : session.paths[0] ?? body.cwd;
2871
+ const launchDir = session.isGroup && session.paths[0] ? path6.dirname(session.paths[0]) : session.paths[0] ?? body.cwd;
3083
2872
  const name = `${session.target} \xB7 ${session.branch}`;
3084
2873
  const snooze = readSnooze(id);
3085
2874
  const route = snooze?.until && snoozeActive(snooze, { attention: status }) ? "none" : presence.route(id);
@@ -3176,7 +2965,7 @@ function mountStatusRoutes(app, opts) {
3176
2965
  }
3177
2966
 
3178
2967
  // src/server/routes/ship-routes.ts
3179
- import fs5 from "fs";
2968
+ import fs4 from "fs";
3180
2969
  var ACTIONS = /* @__PURE__ */ new Set(["push", "create-pr", "merge"]);
3181
2970
  var METHODS = /* @__PURE__ */ new Set(["squash", "merge", "rebase"]);
3182
2971
  function mountShipRoutes(app, opts) {
@@ -3188,7 +2977,7 @@ function mountShipRoutes(app, opts) {
3188
2977
  const out = await archiveSession(session, defaultArchiveDeps({ release: opts.release }), { force, merged });
3189
2978
  if (out.blocked) return { ok: false, blocked: out.blocked, message: out.message };
3190
2979
  ok = out.ok;
3191
- } else if (session.paths.some((p) => !fs5.existsSync(p))) {
2980
+ } else if (session.paths.some((p) => !fs4.existsSync(p))) {
3192
2981
  const config = loadConfig();
3193
2982
  ok = !!config && (await (opts.create ?? createInProcess)({ target: session.target, branch: session.branch }, config)).ok;
3194
2983
  } else {
@@ -3343,9 +3132,9 @@ function mountRailRoutes(app, opts) {
3343
3132
  }
3344
3133
 
3345
3134
  // src/core/worktree/shared-folders.ts
3346
- import fs6 from "fs";
3347
- import path8 from "path";
3348
- var norm = (p) => path8.resolve(p).replace(/\\/g, "/").toLowerCase();
3135
+ import fs5 from "fs";
3136
+ import path7 from "path";
3137
+ var norm = (p) => path7.resolve(p).replace(/\\/g, "/").toLowerCase();
3349
3138
  function shadowedSessions(sessions, branchCheckedOut2) {
3350
3139
  const byFolder = /* @__PURE__ */ new Map();
3351
3140
  for (const s of sessions) {
@@ -3364,14 +3153,14 @@ function shadowedSessions(sessions, branchCheckedOut2) {
3364
3153
  }
3365
3154
  function branchCheckedOut(dir) {
3366
3155
  try {
3367
- const dotGit = path8.join(dir, ".git");
3156
+ const dotGit = path7.join(dir, ".git");
3368
3157
  let gitDir = dotGit;
3369
- if (fs6.statSync(dotGit).isFile()) {
3370
- const m = /^gitdir:\s*(.+)$/m.exec(fs6.readFileSync(dotGit, "utf8"));
3158
+ if (fs5.statSync(dotGit).isFile()) {
3159
+ const m = /^gitdir:\s*(.+)$/m.exec(fs5.readFileSync(dotGit, "utf8"));
3371
3160
  if (!m) return null;
3372
- gitDir = path8.resolve(dir, m[1].trim());
3161
+ gitDir = path7.resolve(dir, m[1].trim());
3373
3162
  }
3374
- const head = fs6.readFileSync(path8.join(gitDir, "HEAD"), "utf8");
3163
+ const head = fs5.readFileSync(path7.join(gitDir, "HEAD"), "utf8");
3375
3164
  const ref = /^ref:\s*refs\/heads\/(.+)$/m.exec(head);
3376
3165
  return ref ? ref[1].trim() : null;
3377
3166
  } catch {
@@ -3380,14 +3169,14 @@ function branchCheckedOut(dir) {
3380
3169
  }
3381
3170
 
3382
3171
  // src/core/platform/build-stamp.ts
3383
- import fs7 from "fs";
3172
+ import fs6 from "fs";
3384
3173
  var cached = null;
3385
3174
  function buildStamp() {
3386
3175
  if (cached) return cached;
3387
3176
  const forced = process.env.WORK_BUILD_STAMP;
3388
3177
  if (forced) return cached = forced;
3389
3178
  try {
3390
- cached = String(Math.floor(fs7.statSync(process.argv[1]).mtimeMs));
3179
+ cached = String(Math.floor(fs6.statSync(process.argv[1]).mtimeMs));
3391
3180
  } catch {
3392
3181
  cached = "unknown";
3393
3182
  }
@@ -3684,8 +3473,8 @@ function mountPrReplyRoutes(app, opts) {
3684
3473
  }
3685
3474
 
3686
3475
  // src/core/archive/archive-retention.ts
3687
- import fs8 from "fs";
3688
- import path9 from "path";
3476
+ import fs7 from "fs";
3477
+ import path8 from "path";
3689
3478
  import zlib from "zlib";
3690
3479
  var DEFAULT_COMPRESS_AFTER_DAYS = 30;
3691
3480
  var DAY_MS = 24 * 36e5;
@@ -3697,7 +3486,7 @@ function applyArchiveRetention(opts) {
3697
3486
  const out = { compressed: [], dropped: [], bytesSaved: 0 };
3698
3487
  let ids;
3699
3488
  try {
3700
- ids = fs8.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
3489
+ ids = fs7.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
3701
3490
  } catch {
3702
3491
  return out;
3703
3492
  }
@@ -3706,10 +3495,10 @@ function applyArchiveRetention(opts) {
3706
3495
  if (!rec || rec.transcriptsDroppedAt) continue;
3707
3496
  const age = now - Date.parse(rec.archivedAt);
3708
3497
  if (!Number.isFinite(age)) continue;
3709
- const dir = path9.join(archiveDirFor(id, root), "transcripts");
3498
+ const dir = path8.join(archiveDirFor(id, root), "transcripts");
3710
3499
  if (dropAfter > 0 && age >= dropAfter * DAY_MS) {
3711
3500
  out.bytesSaved += dirBytes(dir);
3712
- fs8.rmSync(dir, { recursive: true, force: true });
3501
+ fs7.rmSync(dir, { recursive: true, force: true });
3713
3502
  rec.transcriptsDroppedAt = new Date(now).toISOString();
3714
3503
  writeArchiveRecord(rec, root);
3715
3504
  out.dropped.push(id);
@@ -3717,16 +3506,16 @@ function applyArchiveRetention(opts) {
3717
3506
  }
3718
3507
  if (compressAfter <= 0 || rec.compressedAt || age < compressAfter * DAY_MS) continue;
3719
3508
  for (const t of rec.transcripts) {
3720
- const plain = path9.join(dir, t.file);
3721
- if (!fs8.existsSync(plain)) continue;
3722
- const data = fs8.readFileSync(plain);
3509
+ const plain = path8.join(dir, t.file);
3510
+ if (!fs7.existsSync(plain)) continue;
3511
+ const data = fs7.readFileSync(plain);
3723
3512
  const gz = zlib.gzipSync(data);
3724
- fs8.writeFileSync(`${plain}.gz`, gz);
3725
- if (!zlib.gunzipSync(fs8.readFileSync(`${plain}.gz`)).equals(data)) {
3726
- fs8.rmSync(`${plain}.gz`, { force: true });
3513
+ fs7.writeFileSync(`${plain}.gz`, gz);
3514
+ if (!zlib.gunzipSync(fs7.readFileSync(`${plain}.gz`)).equals(data)) {
3515
+ fs7.rmSync(`${plain}.gz`, { force: true });
3727
3516
  continue;
3728
3517
  }
3729
- fs8.rmSync(plain, { force: true });
3518
+ fs7.rmSync(plain, { force: true });
3730
3519
  out.bytesSaved += data.length - gz.length;
3731
3520
  }
3732
3521
  rec.compressedAt = new Date(now).toISOString();
@@ -3738,24 +3527,24 @@ function applyArchiveRetention(opts) {
3738
3527
  function dirBytes(dir) {
3739
3528
  let n = 0;
3740
3529
  try {
3741
- for (const f of fs8.readdirSync(dir)) n += fs8.statSync(path9.join(dir, f)).size;
3530
+ for (const f of fs7.readdirSync(dir)) n += fs7.statSync(path8.join(dir, f)).size;
3742
3531
  } catch {
3743
3532
  }
3744
3533
  return n;
3745
3534
  }
3746
3535
 
3747
3536
  // src/server/routes/revert-routes.ts
3748
- import path11 from "path";
3537
+ import path10 from "path";
3749
3538
  import { zValidator as zValidator6 } from "@hono/zod-validator";
3750
3539
  import { z as z5 } from "zod";
3751
3540
 
3752
3541
  // src/core/diff/revert.ts
3753
- import fs9 from "fs";
3754
- import path10 from "path";
3542
+ import fs8 from "fs";
3543
+ import path9 from "path";
3755
3544
  function inside(root, rel) {
3756
- const abs = path10.resolve(root, rel);
3757
- const back = path10.relative(path10.resolve(root), abs);
3758
- if (!back || back.startsWith("..") || path10.isAbsolute(back)) return null;
3545
+ const abs = path9.resolve(root, rel);
3546
+ const back = path9.relative(path9.resolve(root), abs);
3547
+ if (!back || back.startsWith("..") || path9.isAbsolute(back)) return null;
3759
3548
  return abs;
3760
3549
  }
3761
3550
  function inHead(root, rel) {
@@ -3765,7 +3554,7 @@ function removeNew(root, rel) {
3765
3554
  const abs = inside(root, rel);
3766
3555
  if (!abs) return { ok: false, status: 400, error: `path escapes the worktree: ${rel}` };
3767
3556
  git(["rm", "--cached", "-q", "--ignore-unmatch", "--", rel], root);
3768
- fs9.rmSync(abs, { force: true });
3557
+ fs8.rmSync(abs, { force: true });
3769
3558
  return null;
3770
3559
  }
3771
3560
  function revertFile(root, file) {
@@ -3868,8 +3657,8 @@ function mountRevertRoutes(app, opts) {
3868
3657
  if (!session) return c.json({ error: "unknown session" }, 404);
3869
3658
  const body = c.req.valid("json");
3870
3659
  const repo = opts.uncommitted(session).find((r) => r.name === body.repo);
3871
- const allowed = new Set(session.paths.map((p) => path11.resolve(p).toLowerCase()));
3872
- if (!repo || !allowed.has(path11.resolve(repo.root).toLowerCase())) {
3660
+ const allowed = new Set(session.paths.map((p) => path10.resolve(p).toLowerCase()));
3661
+ if (!repo || !allowed.has(path10.resolve(repo.root).toLowerCase())) {
3873
3662
  return c.json({ error: `unknown repo: ${body.repo}` }, 404);
3874
3663
  }
3875
3664
  const file = repo.files.find((f) => f.path === body.path);
@@ -3926,7 +3715,7 @@ function mountDevRoutes(app, opts) {
3926
3715
  }
3927
3716
 
3928
3717
  // src/server/routes/ci-routes.ts
3929
- import fs10 from "fs";
3718
+ import fs9 from "fs";
3930
3719
 
3931
3720
  // src/core/pr/review-quote.ts
3932
3721
  function quoteForAgent(s, max = 600) {
@@ -3980,6 +3769,16 @@ function parseReviewFeedback(stdout) {
3980
3769
  return null;
3981
3770
  }
3982
3771
  }
3772
+ function viewerLogin(run) {
3773
+ let known = null;
3774
+ return async () => {
3775
+ if (known) return known;
3776
+ const r = await run("gh", ["api", "user", "--jq", ".login"], process.cwd()).catch(() => null);
3777
+ const login = r?.code === 0 ? r.stdout.trim() : "";
3778
+ if (login) known = login;
3779
+ return known;
3780
+ };
3781
+ }
3983
3782
  async function fetchReviewFeedback(repoPath, prNumber, run) {
3984
3783
  const res = await run(
3985
3784
  "gh",
@@ -4192,6 +3991,10 @@ function createPrWatch(deps) {
4192
3991
  return states.get(id) ?? null;
4193
3992
  }
4194
3993
  const opts = deps.options();
3994
+ const viewer = pre.repos.some((r) => r.pr?.author) ? await (deps.viewer?.() ?? Promise.resolve(null)).catch(() => null) : null;
3995
+ const theirs = new Set(
3996
+ pre.repos.filter((r) => r.pr?.author && viewer && r.pr.author.toLowerCase() !== viewer.toLowerCase()).map((r) => r.name)
3997
+ );
4195
3998
  const feedback = [];
4196
3999
  const feedbackSeen = staged(id);
4197
4000
  const threads = /* @__PURE__ */ new Map();
@@ -4199,7 +4002,7 @@ function createPrWatch(deps) {
4199
4002
  const deliverReviews = !session.launchedUnsafe && !deps.runsUnsafe?.(id);
4200
4003
  if (deps.reviewFeedback && opts.reviewComments) {
4201
4004
  for (const r of pre.repos) {
4202
- if (r.pr?.state !== "OPEN") continue;
4005
+ if (r.pr?.state !== "OPEN" || theirs.has(r.name)) continue;
4203
4006
  const key = `${id}:${r.name}`;
4204
4007
  const cached2 = feedbackCache.get(key);
4205
4008
  const fresh = cached2 && r.pr.updatedAt && cached2.number === r.pr.number && cached2.updatedAt === r.pr.updatedAt;
@@ -4262,7 +4065,7 @@ function createPrWatch(deps) {
4262
4065
  } else note(`couldn't hand ${what} to its Claude; trying again next time`, "warn");
4263
4066
  } else feedbackSeen.commit();
4264
4067
  if (opts.fixCi) {
4265
- const fresh = failingOf(ci).filter((f) => !deps.told(id).has(`${id}:${f.repo}:${f.headSha}`));
4068
+ const fresh = failingOf(ci).filter((f) => !theirs.has(f.repo) && !deps.told(id).has(`${id}:${f.repo}:${f.headSha}`));
4266
4069
  if (fresh.length) {
4267
4070
  const ciSeen = staged(id);
4268
4071
  for (const f of fresh) ciSeen.add(`${id}:${f.repo}:${f.headSha}`);
@@ -4413,7 +4216,7 @@ function mountCiRoutes(app, opts) {
4413
4216
  lookOnly: opts.lookOnly,
4414
4217
  sessions: () => {
4415
4218
  const cutoff = Date.now() - RECENT_MS;
4416
- return loadHistory().filter((s) => !s.archivedAt && Date.parse(s.lastAccessedAt) >= cutoff && s.paths.some((p) => fs10.existsSync(p))).map((session) => ({ id: sessionIdFor(session), session }));
4219
+ return loadHistory().filter((s) => !s.archivedAt && Date.parse(s.lastAccessedAt) >= cutoff && s.paths.some((p) => fs9.existsSync(p))).map((session) => ({ id: sessionIdFor(session), session }));
4417
4220
  },
4418
4221
  // Never-pushed branches can't have a PR: don't ask GitHub about them,
4419
4222
  // unless the watch already knows one (a merged PR whose branch is gone).
@@ -4424,6 +4227,7 @@ function mountCiRoutes(app, opts) {
4424
4227
  });
4425
4228
  },
4426
4229
  reviewFeedback: (repoPath, n) => fetchReviewFeedback(repoPath, n, defaultRunner),
4230
+ viewer: viewerLogin(defaultRunner),
4427
4231
  runsUnsafe: (id) => dbPtySessions.read()[id]?.unsafe === true,
4428
4232
  ...opts.activity ? { activity: opts.activity } : {},
4429
4233
  busy: midTurn,
@@ -4477,27 +4281,27 @@ function mountCiRoutes(app, opts) {
4477
4281
  }
4478
4282
 
4479
4283
  // src/core/diff/diffs-sweep.ts
4480
- import fs11 from "fs";
4481
- import path12 from "path";
4284
+ import fs10 from "fs";
4285
+ import path11 from "path";
4482
4286
  var SWEEP_AFTER_DAYS = 30;
4483
4287
  var DISPOSABLE = /\.(html|log)$/i;
4484
- function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS, dir = path12.join(getConfigDir(), "diffs")) {
4288
+ function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS, dir = path11.join(getConfigDir(), "diffs")) {
4485
4289
  const cutoff = now - maxAgeDays * 24 * 60 * 60 * 1e3;
4486
4290
  let removed = 0;
4487
4291
  let bytes = 0;
4488
4292
  let names;
4489
4293
  try {
4490
- names = fs11.readdirSync(dir);
4294
+ names = fs10.readdirSync(dir);
4491
4295
  } catch {
4492
4296
  return { removed, bytes };
4493
4297
  }
4494
4298
  for (const name of names) {
4495
4299
  if (!DISPOSABLE.test(name)) continue;
4496
- const file = path12.join(dir, name);
4300
+ const file = path11.join(dir, name);
4497
4301
  try {
4498
- const st = fs11.statSync(file);
4302
+ const st = fs10.statSync(file);
4499
4303
  if (!st.isFile() || st.mtimeMs >= cutoff) continue;
4500
- fs11.rmSync(file, { force: true });
4304
+ fs10.rmSync(file, { force: true });
4501
4305
  removed++;
4502
4306
  bytes += st.size;
4503
4307
  } catch {
@@ -4507,7 +4311,7 @@ function sweepOldDiffArtifacts(now = Date.now(), maxAgeDays = SWEEP_AFTER_DAYS,
4507
4311
  }
4508
4312
 
4509
4313
  // src/core/diff/session-history.ts
4510
- import path13 from "path";
4314
+ import path12 from "path";
4511
4315
 
4512
4316
  // src/core/diff/diff-points.ts
4513
4317
  var SHA = /^[0-9a-f]{7,40}$/;
@@ -4577,7 +4381,7 @@ function sessionCommits(session) {
4577
4381
  if (log.exitCode !== 0 || !log.stdout) continue;
4578
4382
  for (const line of log.stdout.split("\n")) {
4579
4383
  const [sha, at, subject] = line.split("");
4580
- if (sha && at) out.push({ repo: path13.basename(root), sha, at, subject: subject ?? "" });
4384
+ if (sha && at) out.push({ repo: path12.basename(root), sha, at, subject: subject ?? "" });
4581
4385
  }
4582
4386
  }
4583
4387
  if (commitCache.size >= COMMIT_CACHE_MAX) commitCache.delete(commitCache.keys().next().value);
@@ -4585,7 +4389,7 @@ function sessionCommits(session) {
4585
4389
  return out;
4586
4390
  }
4587
4391
  function computeSessionRange(session, from, to) {
4588
- const paths = session.paths.map((p) => path13.resolve(p));
4392
+ const paths = session.paths.map((p) => path12.resolve(p));
4589
4393
  const refs = rangeRefs(paths, loadManifest(scopeHashForPaths(paths)).entries, from, to);
4590
4394
  if ("error" in refs) return refs;
4591
4395
  return { repos: refs.map((r) => ({ name: r.name, root: r.root, files: computeRangeDiff(r) })) };
@@ -4773,7 +4577,7 @@ function sleepCandidates(ptys, now, afterMs, busy, keep = /* @__PURE__ */ new Se
4773
4577
  function computeSessionDiff(s, base) {
4774
4578
  const resolved = s.paths.map((p) => resolveRepoDiff(p, base, s.baseBranches?.[p] ?? s.baseBranch));
4775
4579
  const repos = s.paths.map((p, i) => ({
4776
- name: path14.basename(p),
4580
+ name: path13.basename(p),
4777
4581
  root: p,
4778
4582
  resolvedBase: resolved[i].resolvedBase,
4779
4583
  files: computeDiff({ root: p, diffArg: resolved[i].diffArg })
@@ -4824,7 +4628,7 @@ async function startWebServer(opts = {}) {
4824
4628
  let activityWatcher = null;
4825
4629
  if (!lean) {
4826
4630
  try {
4827
- const roots = activityRoots().filter((r) => fs12.existsSync(r));
4631
+ const roots = activityRoots().filter((r) => fs11.existsSync(r));
4828
4632
  if (roots.length > 0) {
4829
4633
  activityWatcher = createFsWatcher({
4830
4634
  roots,
@@ -4875,7 +4679,7 @@ async function startWebServer(opts = {}) {
4875
4679
  }, 500);
4876
4680
  }
4877
4681
  });
4878
- const repoNames = (s) => s.isGroup ? s.paths.map((p) => path14.basename(p)) : [s.target];
4682
+ const repoNames = (s) => s.isGroup ? s.paths.map((p) => path13.basename(p)) : [s.target];
4879
4683
  const diffStatFor = (id, s, hasStatus) => wantsDiffStat(s, hasStatus) ? diffStats.get(id, s.paths, repoNames(s)) : null;
4880
4684
  const archivedRow = createArchivedRows();
4881
4685
  app.get("/api/sessions", (c) => {
@@ -5296,7 +5100,7 @@ async function startWebServer(opts = {}) {
5296
5100
  updatesTimer?.unref?.();
5297
5101
  const desktopFile = desktopUpdatePath();
5298
5102
  const onDesktopUpdate = () => broadcast("updates-changed", { ts: Date.now() });
5299
- if (jobs) fs12.watchFile(desktopFile, { interval: 3e3 }, onDesktopUpdate);
5103
+ if (jobs) fs11.watchFile(desktopFile, { interval: 3e3 }, onDesktopUpdate);
5300
5104
  app.get("/api/pty-host/health", (c) => c.json(hostHealth(hostBeat())));
5301
5105
  let lastHostState = hostHealth(hostBeat()).state;
5302
5106
  const hostTick = lean ? null : setInterval(() => {
@@ -5358,7 +5162,7 @@ async function startWebServer(opts = {}) {
5358
5162
  if (conversationsFirst) clearTimeout(conversationsFirst);
5359
5163
  if (updatesFirst) clearTimeout(updatesFirst);
5360
5164
  if (updatesTimer) clearInterval(updatesTimer);
5361
- fs12.unwatchFile(desktopFile, onDesktopUpdate);
5165
+ fs11.unwatchFile(desktopFile, onDesktopUpdate);
5362
5166
  for (const t of conversationSyncs.values()) clearTimeout(t);
5363
5167
  clearTimeout(sweepTimer);
5364
5168
  activityWatcher?.stop();
@@ -5381,11 +5185,11 @@ async function startWebServer(opts = {}) {
5381
5185
  }
5382
5186
 
5383
5187
  // src/core/platform/autostart.ts
5384
- import fs13 from "fs";
5385
- import path15 from "path";
5188
+ import fs12 from "fs";
5189
+ import path14 from "path";
5386
5190
  function startupScriptPath() {
5387
5191
  if (process.platform !== "win32" || !process.env.APPDATA) return null;
5388
- return path15.join(process.env.APPDATA, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "work-web.vbs");
5192
+ return path14.join(process.env.APPDATA, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "work-web.vbs");
5389
5193
  }
5390
5194
  function vbsQuote(s) {
5391
5195
  return '"' + s.replace(/"/g, '""') + '"';
@@ -5403,11 +5207,11 @@ function setAutostart(enabled, workBin) {
5403
5207
  const file = startupScriptPath();
5404
5208
  if (!file) throw new Error("Autostart is only supported on Windows so far.");
5405
5209
  if (enabled) {
5406
- fs13.mkdirSync(path15.dirname(file), { recursive: true });
5407
- fs13.writeFileSync(file, buildStartupScript(process.execPath, workBin), "utf-8");
5210
+ fs12.mkdirSync(path14.dirname(file), { recursive: true });
5211
+ fs12.writeFileSync(file, buildStartupScript(process.execPath, workBin), "utf-8");
5408
5212
  } else {
5409
5213
  try {
5410
- fs13.unlinkSync(file);
5214
+ fs12.unlinkSync(file);
5411
5215
  } catch {
5412
5216
  }
5413
5217
  }
@@ -5451,7 +5255,7 @@ function createDemoRepos(liveTargets) {
5451
5255
  /** GET /api/projects: what New worktree offers, as the real one reads config. */
5452
5256
  projects() {
5453
5257
  return {
5454
- singles: Object.entries(repos).map(([name, path16]) => ({ name, kind: "single", path: path16 })),
5258
+ singles: Object.entries(repos).map(([name, path15]) => ({ name, kind: "single", path: path15 })),
5455
5259
  groups: Object.entries(groups).map(([name, members]) => ({ name, kind: "group", members }))
5456
5260
  };
5457
5261
  },
@@ -5493,12 +5297,12 @@ function createDemoRepos(liveTargets) {
5493
5297
  }));
5494
5298
  return { roots: [root], repos: rows, groups: groupRows };
5495
5299
  },
5496
- enroll(alias, path16) {
5497
- if (!found.some((f) => f.path === path16)) throw new DemoRepoError(`${path16} is not the top folder of a git repository`);
5498
- const problem = enrollProblem(alias, path16, config());
5300
+ enroll(alias, path15) {
5301
+ if (!found.some((f) => f.path === path15)) throw new DemoRepoError(`${path15} is not the top folder of a git repository`);
5302
+ const problem = enrollProblem(alias, path15, config());
5499
5303
  if (problem) throw new DemoRepoError(problem);
5500
- repos[alias] = path16;
5501
- ignored.delete(path16);
5304
+ repos[alias] = path15;
5305
+ ignored.delete(path15);
5502
5306
  },
5503
5307
  remove(alias, force) {
5504
5308
  if (!(alias in repos)) throw new DemoRepoError(`no repo \u201C${alias}\u201D`);
@@ -5507,9 +5311,9 @@ function createDemoRepos(liveTargets) {
5507
5311
  delete repos[alias];
5508
5312
  for (const g of Object.keys(groups)) groups[g] = groups[g].filter((m) => m !== alias);
5509
5313
  },
5510
- ignore(path16, on) {
5511
- if (on) ignored.add(path16);
5512
- else ignored.delete(path16);
5314
+ ignore(path15, on) {
5315
+ if (on) ignored.add(path15);
5316
+ else ignored.delete(path15);
5513
5317
  },
5514
5318
  saveGroup(name, members, creating) {
5515
5319
  const problem = groupProblem(name, members, config(), { creating });
@@ -6727,6 +6531,7 @@ ${reply}\r
6727
6531
  reviewDecision: "APPROVED",
6728
6532
  myReview: "APPROVED",
6729
6533
  isMine: false,
6534
+ author: "ivana",
6730
6535
  conflicting: false,
6731
6536
  reviewRequested: false,
6732
6537
  repoAlias: "web"
@@ -6741,10 +6546,27 @@ ${reply}\r
6741
6546
  reviewDecision: "REVIEW_REQUIRED",
6742
6547
  myReview: "NONE",
6743
6548
  isMine: false,
6549
+ author: "dana",
6744
6550
  conflicting: false,
6745
6551
  reviewRequested: true,
6746
6552
  repoAlias: "api"
6747
6553
  });
6554
+ out.push({
6555
+ number: 219,
6556
+ title: "Fix a typo in the invoice footer",
6557
+ branch: "patch-1",
6558
+ url: "https://github.com/example/web/pull/219",
6559
+ isDraft: false,
6560
+ checksStatus: "SUCCESS",
6561
+ reviewDecision: "REVIEW_REQUIRED",
6562
+ myReview: "NONE",
6563
+ isMine: false,
6564
+ author: "outside-dev",
6565
+ fork: true,
6566
+ conflicting: false,
6567
+ reviewRequested: true,
6568
+ repoAlias: "web"
6569
+ });
6748
6570
  return out;
6749
6571
  }
6750
6572
  jira() {
@@ -7421,6 +7243,33 @@ async function startDemoServer(opts) {
7421
7243
  const s = scenario.create(body.target, branch, prompt);
7422
7244
  return c.json({ sessionId: s.id, launchDir: s.paths[0], paths: s.paths, ...prompt ? { started: "started" } : {} });
7423
7245
  });
7246
+ app.get("/api/pr-start", (c) => {
7247
+ const ref = parsePrRef(c.req.query("ref") ?? "");
7248
+ const target = c.req.query("target") || void 0;
7249
+ if (!ref)
7250
+ return c.json(
7251
+ { error: "Give a pull request link (https://github.com/owner/repo/pull/123), or its number with a repo." },
7252
+ 400
7253
+ );
7254
+ const pr = scenario.prs().find((p) => p.number === ref.number && (ref.repo ? ref.repo.endsWith(`/${p.repoAlias}`) : !target || p.repoAlias === target));
7255
+ if (!pr) return c.json({ error: `PR #${ref.number} isn't open in your repos.` }, 400);
7256
+ if (pr.fork)
7257
+ return c.json(
7258
+ { error: `PR #${ref.number} comes from a fork: its branch isn't on origin, so a session couldn't push to it.` },
7259
+ 400
7260
+ );
7261
+ return c.json({
7262
+ pr: {
7263
+ alias: pr.repoAlias,
7264
+ number: pr.number,
7265
+ title: pr.title,
7266
+ url: pr.url,
7267
+ branch: pr.branch,
7268
+ base: "main",
7269
+ author: pr.author || "dana"
7270
+ }
7271
+ });
7272
+ });
7424
7273
  app.delete(
7425
7274
  "/api/sessions/:id/worktree",
7426
7275
  (c) => scenario.remove(c.req.param("id")) ? c.json({ ok: true, worktreeRemoved: true }) : notFound(c)
@@ -7987,4 +7836,4 @@ export {
7987
7836
  stopExisting,
7988
7837
  webCommand
7989
7838
  };
7990
- //# sourceMappingURL=web-PY55DXYZ.js.map
7839
+ //# sourceMappingURL=web-EUI5U2H4.js.map