@moberg_hr/work-tree 2.0.13 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{answer-IL5AQHRO.js → answer-OF2QNF4A.js} +6 -6
- package/dist/{attach-MFU4KN47.js → attach-PAFAZ2EH.js} +9 -9
- package/dist/bin.js +2 -2
- package/dist/{block-OXGEQ2PZ.js → block-3LEG4LKJ.js} +6 -6
- package/dist/{broadcast-UJURJNEK.js → broadcast-ZDIL7UBP.js} +3 -3
- package/dist/{catchup-HN4VL5XK.js → catchup-ZZ5HZJIT.js} +8 -8
- package/dist/{chunk-E35NZVPX.js → chunk-2GX3IOSV.js} +15 -2
- package/dist/chunk-2GX3IOSV.js.map +1 -0
- package/dist/{chunk-R7B46WXN.js → chunk-3GAYLP7W.js} +4 -4
- package/dist/{chunk-OZIR2255.js → chunk-453EGT2R.js} +11 -7
- package/dist/chunk-453EGT2R.js.map +1 -0
- package/dist/{chunk-RLR66XLG.js → chunk-46VAWZZX.js} +2 -2
- package/dist/{chunk-SH7NSDRW.js → chunk-4CVUV2SE.js} +2 -2
- package/dist/{chunk-3XY76XBD.js → chunk-62C3CJ5M.js} +2 -2
- package/dist/{chunk-MIIJ2HQS.js → chunk-77SVSNME.js} +4 -4
- package/dist/{chunk-OQAQMCHF.js → chunk-C7OK4XEZ.js} +58 -9
- package/dist/chunk-C7OK4XEZ.js.map +1 -0
- package/dist/{chunk-YZLNJQAV.js → chunk-DLSAAP3S.js} +2 -2
- package/dist/{chunk-B2RCWZUW.js → chunk-EDAOG56H.js} +35 -7
- package/dist/chunk-EDAOG56H.js.map +1 -0
- package/dist/{chunk-EU3BS5A6.js → chunk-EXJYPF64.js} +3 -3
- package/dist/{chunk-PUYXTZ32.js → chunk-INVFNKU7.js} +4 -4
- package/dist/{chunk-KUWFGPGW.js → chunk-ISZM5C22.js} +15 -9
- package/dist/chunk-ISZM5C22.js.map +1 -0
- package/dist/{chunk-F375JY4M.js → chunk-KSVZVHTI.js} +6 -6
- package/dist/{chunk-F375JY4M.js.map → chunk-KSVZVHTI.js.map} +1 -1
- package/dist/{chunk-RQE5UOIW.js → chunk-KTFDSJUD.js} +16 -1
- package/dist/chunk-KTFDSJUD.js.map +1 -0
- package/dist/{chunk-HDO3PXCU.js → chunk-KWU35O5S.js} +3 -3
- package/dist/{chunk-U4UB4LG6.js → chunk-LBQR7KTC.js} +2 -2
- package/dist/{chunk-YXQIGBL6.js → chunk-LGDECE7V.js} +3 -3
- package/dist/{chunk-FX4IA5U4.js → chunk-M4YXBQZN.js} +5 -5
- package/dist/{chunk-OOCMPS5L.js → chunk-MRXD2NSO.js} +2 -2
- package/dist/{chunk-ZFPV46FA.js → chunk-NBI2INQS.js} +22 -13
- package/dist/chunk-NBI2INQS.js.map +1 -0
- package/dist/{chunk-BSFL3WDR.js → chunk-OCDHKDUN.js} +45 -45
- package/dist/{chunk-MVU7JAKG.js → chunk-OE34YZFO.js} +2 -2
- package/dist/{chunk-6O6765M7.js → chunk-OIQY4OKO.js} +2 -2
- package/dist/{chunk-M7AUWYOP.js → chunk-R4M5DDSN.js} +4 -4
- package/dist/{chunk-YJVZ5H3I.js → chunk-RK6NHIL6.js} +2 -2
- package/dist/chunk-THJGDJVO.js +9 -0
- package/dist/{chunk-4KNBN2OF.js.map → chunk-THJGDJVO.js.map} +1 -1
- package/dist/chunk-TN2TXRHS.js +249 -0
- package/dist/chunk-TN2TXRHS.js.map +1 -0
- package/dist/{chunk-427RB7E4.js → chunk-TROTIHD5.js} +3 -3
- package/dist/{chunk-KSIXTTO6.js → chunk-U4YUMSJY.js} +3 -3
- package/dist/{chunk-7JPCVEOY.js → chunk-U5V5J237.js} +6 -6
- package/dist/{chunk-PVN5IGDZ.js → chunk-UDOXLAE7.js} +2 -2
- package/dist/{chunk-MI3PS2SH.js → chunk-UOSZFFNY.js} +2 -2
- package/dist/{chunk-7GQCPGKQ.js → chunk-X6VBITXV.js} +4 -4
- package/dist/{chunk-OW46TR4G.js → chunk-XIL4QZFW.js} +3 -3
- package/dist/{chunk-QX4LFFNS.js → chunk-ZR2KWY6V.js} +2 -2
- package/dist/{chunk-4MXWNDH7.js → chunk-ZVJEWMJN.js} +39 -1
- package/dist/chunk-ZVJEWMJN.js.map +1 -0
- package/dist/{cleanup-LRT6J36R.js → cleanup-W5RGZ3Q6.js} +17 -15
- package/dist/{cleanup-LRT6J36R.js.map → cleanup-W5RGZ3Q6.js.map} +1 -1
- package/dist/{cli-VGUJI5WG.js → cli-64TLWGRH.js} +3 -3
- package/dist/{config-SSWYCX4C.js → config-MR7UZCST.js} +4 -4
- package/dist/{diff-JBCBQM4I.js → diff-URDY6YMT.js} +7 -7
- package/dist/{digest-WCZD6N7M.js → digest-D4FEZNLU.js} +6 -6
- package/dist/{fork-RJ3ZPPWT.js → fork-7EUVNEB7.js} +15 -15
- package/dist/{hook-CA5X3VKU.js → hook-6AD3FRKZ.js} +6 -6
- package/dist/{hydrate-Q4FWUQRC.js → hydrate-ZJZPM6YW.js} +3 -3
- package/dist/{init-AT3BQLXM.js → init-LWL4WVSJ.js} +4 -4
- package/dist/{install-skills-Z76FLXOU.js → install-skills-TQVWZDUD.js} +3 -3
- package/dist/install-skills-bin.js +2 -2
- package/dist/{move-OLXCDNA3.js → move-URV7XIDT.js} +7 -7
- package/dist/{note-JOR53JP4.js → note-S6EGTEIL.js} +5 -5
- package/dist/{overlaps-GXSEH2LG.js → overlaps-4T7NLTJH.js} +5 -5
- package/dist/{pin-DAWKCVB2.js → pin-KKQZ3AR6.js} +5 -5
- package/dist/{pr-RKOVRSHC.js → pr-5ZILTVDM.js} +5 -5
- package/dist/{prune-UYCQOEUF.js → prune-OK23KLHG.js} +16 -14
- package/dist/{prune-UYCQOEUF.js.map → prune-OK23KLHG.js.map} +1 -1
- package/dist/{pty-host-X3QK2LSK.js → pty-host-I5OJGWYA.js} +5 -5
- package/dist/{read-IKDSIDJD.js → read-NHK26F22.js} +5 -5
- package/dist/{recent-2LM44HN2.js → recent-DNSOJQVQ.js} +4 -4
- package/dist/{remove-6XACPXUU.js → remove-TZQVN2EG.js} +15 -13
- package/dist/{remove-6XACPXUU.js.map → remove-TZQVN2EG.js.map} +1 -1
- package/dist/{restart-6ZAFDRBO.js → restart-WHJDPDQA.js} +6 -6
- package/dist/{resume-VA34T7ZR.js → resume-BXIYEZM3.js} +4 -4
- package/dist/{run-E2WZPHHK.js → run-4MQLY3XF.js} +3 -3
- package/dist/{screen-KUXSDDLB.js → screen-URKN7PU6.js} +6 -6
- package/dist/{search-FJUZPI3P.js → search-MNBYJEL7.js} +3 -3
- package/dist/{section-QLUIAYAV.js → section-B3OQFADP.js} +5 -5
- package/dist/{send-V6LL6YR6.js → send-2QTMQQ6E.js} +7 -7
- package/dist/{sessions-MKXREA2M.js → sessions-4B22O45G.js} +12 -12
- package/dist/{snooze-JXI7VZJ4.js → snooze-LSCCM3QT.js} +5 -5
- package/dist/{start-5XFUYT6I.js → start-KVNLZRF5.js} +6 -6
- package/dist/{status-U5HKQ7MY.js → status-UEMXFLZZ.js} +3 -3
- package/dist/{stop-PFI7J2CS.js → stop-NEQBEYEY.js} +6 -6
- package/dist/{sync-MSU7QJWN.js → sync-BHEY6RXE.js} +16 -14
- package/dist/{sync-MSU7QJWN.js.map → sync-BHEY6RXE.js.map} +1 -1
- package/dist/{time-VDRCEIYQ.js → time-ON27QFG4.js} +6 -6
- package/dist/{timesheet-LSRRWV7Z.js → timesheet-HK5CHAA7.js} +8 -8
- package/dist/{tree-MOIO4GQL.js → tree-C5BEEKLO.js} +18 -11
- package/dist/tree-C5BEEKLO.js.map +1 -0
- package/dist/{update-DXIY6BEX.js → update-M4KS23HB.js} +7 -7
- package/dist/{wait-KPH5BQUD.js → wait-5QVWSCOL.js} +6 -6
- package/dist/wd-bin.js +2 -2
- package/dist/web/assets/{PtyView-D1TEpjVE.js → PtyView-TjC4VYWv.js} +2 -2
- package/dist/web/assets/{PtyView-D1TEpjVE.js.map → PtyView-TjC4VYWv.js.map} +1 -1
- package/dist/web/assets/index-BPadZeCm.js +119 -0
- package/dist/web/assets/index-BPadZeCm.js.map +1 -0
- package/dist/web/assets/index-YbJdcXjZ.css +1 -0
- package/dist/web/index.html +2 -2
- package/dist/{web-6AOR3MIE.js → web-5YGNY6MI.js} +746 -147
- package/dist/web-5YGNY6MI.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/chunk-4KNBN2OF.js +0 -9
- package/dist/chunk-4MXWNDH7.js.map +0 -1
- package/dist/chunk-B2RCWZUW.js.map +0 -1
- package/dist/chunk-E35NZVPX.js.map +0 -1
- package/dist/chunk-KUWFGPGW.js.map +0 -1
- package/dist/chunk-OQAQMCHF.js.map +0 -1
- package/dist/chunk-OZIR2255.js.map +0 -1
- package/dist/chunk-RQE5UOIW.js.map +0 -1
- package/dist/chunk-ZFPV46FA.js.map +0 -1
- package/dist/tree-MOIO4GQL.js.map +0 -1
- package/dist/web/assets/index-BVeughC2.css +0 -1
- package/dist/web/assets/index-DoMf82kx.js +0 -118
- package/dist/web/assets/index-DoMf82kx.js.map +0 -1
- package/dist/web-6AOR3MIE.js.map +0 -1
- /package/dist/{answer-IL5AQHRO.js.map → answer-OF2QNF4A.js.map} +0 -0
- /package/dist/{attach-MFU4KN47.js.map → attach-PAFAZ2EH.js.map} +0 -0
- /package/dist/{block-OXGEQ2PZ.js.map → block-3LEG4LKJ.js.map} +0 -0
- /package/dist/{broadcast-UJURJNEK.js.map → broadcast-ZDIL7UBP.js.map} +0 -0
- /package/dist/{catchup-HN4VL5XK.js.map → catchup-ZZ5HZJIT.js.map} +0 -0
- /package/dist/{chunk-R7B46WXN.js.map → chunk-3GAYLP7W.js.map} +0 -0
- /package/dist/{chunk-RLR66XLG.js.map → chunk-46VAWZZX.js.map} +0 -0
- /package/dist/{chunk-SH7NSDRW.js.map → chunk-4CVUV2SE.js.map} +0 -0
- /package/dist/{chunk-3XY76XBD.js.map → chunk-62C3CJ5M.js.map} +0 -0
- /package/dist/{chunk-MIIJ2HQS.js.map → chunk-77SVSNME.js.map} +0 -0
- /package/dist/{chunk-YZLNJQAV.js.map → chunk-DLSAAP3S.js.map} +0 -0
- /package/dist/{chunk-EU3BS5A6.js.map → chunk-EXJYPF64.js.map} +0 -0
- /package/dist/{chunk-PUYXTZ32.js.map → chunk-INVFNKU7.js.map} +0 -0
- /package/dist/{chunk-HDO3PXCU.js.map → chunk-KWU35O5S.js.map} +0 -0
- /package/dist/{chunk-U4UB4LG6.js.map → chunk-LBQR7KTC.js.map} +0 -0
- /package/dist/{chunk-YXQIGBL6.js.map → chunk-LGDECE7V.js.map} +0 -0
- /package/dist/{chunk-FX4IA5U4.js.map → chunk-M4YXBQZN.js.map} +0 -0
- /package/dist/{chunk-OOCMPS5L.js.map → chunk-MRXD2NSO.js.map} +0 -0
- /package/dist/{chunk-BSFL3WDR.js.map → chunk-OCDHKDUN.js.map} +0 -0
- /package/dist/{chunk-MVU7JAKG.js.map → chunk-OE34YZFO.js.map} +0 -0
- /package/dist/{chunk-6O6765M7.js.map → chunk-OIQY4OKO.js.map} +0 -0
- /package/dist/{chunk-M7AUWYOP.js.map → chunk-R4M5DDSN.js.map} +0 -0
- /package/dist/{chunk-YJVZ5H3I.js.map → chunk-RK6NHIL6.js.map} +0 -0
- /package/dist/{chunk-427RB7E4.js.map → chunk-TROTIHD5.js.map} +0 -0
- /package/dist/{chunk-KSIXTTO6.js.map → chunk-U4YUMSJY.js.map} +0 -0
- /package/dist/{chunk-7JPCVEOY.js.map → chunk-U5V5J237.js.map} +0 -0
- /package/dist/{chunk-PVN5IGDZ.js.map → chunk-UDOXLAE7.js.map} +0 -0
- /package/dist/{chunk-MI3PS2SH.js.map → chunk-UOSZFFNY.js.map} +0 -0
- /package/dist/{chunk-7GQCPGKQ.js.map → chunk-X6VBITXV.js.map} +0 -0
- /package/dist/{chunk-OW46TR4G.js.map → chunk-XIL4QZFW.js.map} +0 -0
- /package/dist/{chunk-QX4LFFNS.js.map → chunk-ZR2KWY6V.js.map} +0 -0
- /package/dist/{cli-VGUJI5WG.js.map → cli-64TLWGRH.js.map} +0 -0
- /package/dist/{config-SSWYCX4C.js.map → config-MR7UZCST.js.map} +0 -0
- /package/dist/{diff-JBCBQM4I.js.map → diff-URDY6YMT.js.map} +0 -0
- /package/dist/{digest-WCZD6N7M.js.map → digest-D4FEZNLU.js.map} +0 -0
- /package/dist/{fork-RJ3ZPPWT.js.map → fork-7EUVNEB7.js.map} +0 -0
- /package/dist/{hook-CA5X3VKU.js.map → hook-6AD3FRKZ.js.map} +0 -0
- /package/dist/{hydrate-Q4FWUQRC.js.map → hydrate-ZJZPM6YW.js.map} +0 -0
- /package/dist/{init-AT3BQLXM.js.map → init-LWL4WVSJ.js.map} +0 -0
- /package/dist/{install-skills-Z76FLXOU.js.map → install-skills-TQVWZDUD.js.map} +0 -0
- /package/dist/{move-OLXCDNA3.js.map → move-URV7XIDT.js.map} +0 -0
- /package/dist/{note-JOR53JP4.js.map → note-S6EGTEIL.js.map} +0 -0
- /package/dist/{overlaps-GXSEH2LG.js.map → overlaps-4T7NLTJH.js.map} +0 -0
- /package/dist/{pin-DAWKCVB2.js.map → pin-KKQZ3AR6.js.map} +0 -0
- /package/dist/{pr-RKOVRSHC.js.map → pr-5ZILTVDM.js.map} +0 -0
- /package/dist/{pty-host-X3QK2LSK.js.map → pty-host-I5OJGWYA.js.map} +0 -0
- /package/dist/{read-IKDSIDJD.js.map → read-NHK26F22.js.map} +0 -0
- /package/dist/{recent-2LM44HN2.js.map → recent-DNSOJQVQ.js.map} +0 -0
- /package/dist/{restart-6ZAFDRBO.js.map → restart-WHJDPDQA.js.map} +0 -0
- /package/dist/{resume-VA34T7ZR.js.map → resume-BXIYEZM3.js.map} +0 -0
- /package/dist/{run-E2WZPHHK.js.map → run-4MQLY3XF.js.map} +0 -0
- /package/dist/{screen-KUXSDDLB.js.map → screen-URKN7PU6.js.map} +0 -0
- /package/dist/{search-FJUZPI3P.js.map → search-MNBYJEL7.js.map} +0 -0
- /package/dist/{section-QLUIAYAV.js.map → section-B3OQFADP.js.map} +0 -0
- /package/dist/{send-V6LL6YR6.js.map → send-2QTMQQ6E.js.map} +0 -0
- /package/dist/{sessions-MKXREA2M.js.map → sessions-4B22O45G.js.map} +0 -0
- /package/dist/{snooze-JXI7VZJ4.js.map → snooze-LSCCM3QT.js.map} +0 -0
- /package/dist/{start-5XFUYT6I.js.map → start-KVNLZRF5.js.map} +0 -0
- /package/dist/{status-U5HKQ7MY.js.map → status-UEMXFLZZ.js.map} +0 -0
- /package/dist/{stop-PFI7J2CS.js.map → stop-NEQBEYEY.js.map} +0 -0
- /package/dist/{time-VDRCEIYQ.js.map → time-ON27QFG4.js.map} +0 -0
- /package/dist/{timesheet-LSRRWV7Z.js.map → timesheet-HK5CHAA7.js.map} +0 -0
- /package/dist/{update-DXIY6BEX.js.map → update-M4KS23HB.js.map} +0 -0
- /package/dist/{wait-KPH5BQUD.js.map → wait-5QVWSCOL.js.map} +0 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moberg_hr/work-tree",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@moberg_hr/work-tree",
|
|
9
|
-
"version": "2.0
|
|
9
|
+
"version": "2.2.0",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED
package/dist/chunk-4KNBN2OF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/pr/pr-ref.ts","../src/core/pr/pr.ts","../src/core/pr/pr-start.ts"],"sourcesContent":["/**\n * Starting a session on someone else's pull request — on their branch, so\n * what you push lands in their PR. Pure (the SPA and the demo use it): how a\n * PR is named, and what its session's Claude is told first. The lookup\n * (`gh pr view`) is `pr-start.ts`.\n */\n\nimport type { PrToStart } from '../api-types.js';\n\nexport type { PrToStart };\n\n/** A PR as you'd name it: its link (repo known), or its number (in a repo you pick). */\nexport interface PrRef {\n /** `owner/name`, lowercase, from a link. */\n repo?: string;\n number: number;\n}\n\n/** A PR link (`https://github.com/owner/repo/pull/123`, any tail), `#123` or `123`; null for anything else. */\nexport function parsePrRef(input: string): PrRef | null {\n const s = input.trim();\n const url = /^(?:https?:\\/\\/)?(?:www\\.)?github\\.com\\/([^/\\s]+)\\/([^/\\s]+)\\/pull\\/(\\d+)(?:[/?#].*)?$/i.exec(s);\n if (url) return { repo: `${url[1]}/${url[2]}`.toLowerCase(), number: Number(url[3]) };\n const n = /^#?(\\d+)$/.exec(s);\n return n && Number(n[1]) > 0 ? { number: Number(n[1]) } : null;\n}\n\n/**\n * The first message to the session's Claude: whose PR this is, that what it\n * pushes lands there, and to get up to speed — then do `instruction`, or\n * with none, say where it stands and wait for what the user wants. Nothing\n * on GitHub (no comments, reviews or replies): that's the author's\n * conversation.\n */\nexport function workOnPrPrompt(pr: Pick<PrToStart, 'number' | 'title' | 'url'> & { author?: string }, instruction?: string): string {\n const who = pr.author ? `@${pr.author}` : 'its author';\n const todo = instruction?.trim();\n const upToSpeed = `Get up to speed first (gh pr view ${pr.number}, gh pr diff ${pr.number})`;\n return [\n `Work on PR #${pr.number} by ${who}: ${pr.title}`,\n pr.url,\n '',\n `This worktree is on ${who}'s branch: what you commit and push lands in their PR.`,\n ...(todo ? [`${upToSpeed}, then:`, '', todo, ''] : [`${upToSpeed}, tell me where it stands, and wait for what I want done.`]),\n \"Don't post on GitHub (no comments, reviews or replies).\",\n ].join('\\n');\n}\n","import { execFile } from 'node:child_process';\nimport { originUrl, ownerRepo, readGitConfig } from '../worktree/repo-scan.js';\n\nexport interface PullRequestInfo {\n number: number;\n title: string;\n branch: string;\n url: string;\n isDraft: boolean;\n checksStatus: 'SUCCESS' | 'FAILURE' | 'PENDING' | 'NONE';\n reviewDecision: 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED' | 'NONE';\n /** Current user's latest review state on this PR. */\n myReview: 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED' | 'NONE';\n /** Whether the current user is the PR author. */\n isMine: boolean;\n /** It can't merge as it is: a conflict with its base (checks say nothing about that). */\n conflicting: boolean;\n /** Your review was asked for, by name (a team's request isn't known here). */\n reviewRequested: boolean;\n /** Repo alias this PR belongs to (for distinguishing group PRs). */\n repoAlias: string;\n /** Its author's login (absent from a server before this). */\n author?: string;\n /** It comes from a fork: its branch isn't on origin (absent from a server before this). */\n fork?: boolean;\n}\n\n/**\n * Map from branch name to array of PRs (one per repo that has a PR for that branch).\n * Single-repo sessions will have at most 1 entry; groups can have multiple.\n */\nexport type BranchPrMap = Map<string, PullRequestInfo[]>;\n\nfunction execAsync(cmd: string, args: string[], cwd: string, timeout: number): Promise<string> {\n return new Promise((resolve, reject) => {\n // `windowsHide: true` prevents a console window from flashing on\n // Windows whenever the PRs pane refreshes. Without it, opening\n // the PRs pane in `work web` triggers a visible terminal popup\n // for every configured repo's `gh pr list` invocation.\n execFile(cmd, args, { cwd, encoding: 'utf-8', timeout, windowsHide: true }, (err, stdout) => {\n if (err) reject(err);\n else resolve(stdout ?? '');\n });\n });\n}\n\n/** The fields of `gh pr list --json …` this reads; all optional — it is someone else's output. */\ninterface GhPr {\n number?: number;\n title?: string;\n headRefName?: string;\n url?: string;\n isDraft?: boolean;\n mergeable?: string;\n reviewDecision?: string;\n author?: { login?: string } | null;\n isCrossRepository?: boolean;\n statusCheckRollup?: Array<{ conclusion?: string | null; status?: string | null }> | null;\n reviews?: Array<{ author?: { login?: string } | null; state?: string }> | null;\n reviewRequests?: Array<{ login?: string } | null> | null;\n}\n\n/** `gh pr list --json …` output as work's PR rows: checks, review, yours or not, conflicts, review asked of you. Pure. */\nexport function parsePrJson(stdout: string, repoAlias: string, currentUser: string): PullRequestInfo[] {\n const parsed = JSON.parse(stdout) as unknown;\n const prs: GhPr[] = Array.isArray(parsed) ? (parsed as GhPr[]) : [];\n return prs.map((pr) => toPrInfo(pr, repoAlias, currentUser));\n}\n\n/** One PR as work's row. */\nfunction toPrInfo(pr: GhPr, repoAlias: string, currentUser: string): PullRequestInfo {\n {\n let checksStatus: PullRequestInfo['checksStatus'] = 'NONE';\n const checks = pr.statusCheckRollup ?? [];\n if (checks.length > 0) {\n const hasFailure = checks.some((c) => c.conclusion === 'FAILURE' || c.conclusion === 'TIMED_OUT' || c.conclusion === 'CANCELLED');\n const hasPending = checks.some((c) => c.status === 'IN_PROGRESS' || c.status === 'QUEUED' || c.status === 'PENDING');\n if (hasFailure) checksStatus = 'FAILURE';\n else if (hasPending) checksStatus = 'PENDING';\n else checksStatus = 'SUCCESS';\n }\n\n let reviewDecision: PullRequestInfo['reviewDecision'] = 'NONE';\n if (pr.reviewDecision === 'APPROVED') reviewDecision = 'APPROVED';\n else if (pr.reviewDecision === 'CHANGES_REQUESTED') reviewDecision = 'CHANGES_REQUESTED';\n else if (pr.reviewDecision === 'REVIEW_REQUIRED') reviewDecision = 'REVIEW_REQUIRED';\n\n // Check current user's latest review state\n let myReview: PullRequestInfo['myReview'] = 'NONE';\n if (currentUser) {\n const reviews = pr.reviews ?? [];\n for (let i = reviews.length - 1; i >= 0; i--) {\n if (reviews[i].author?.login?.toLowerCase() === currentUser.toLowerCase()) {\n const state = reviews[i].state;\n if (state === 'APPROVED') myReview = 'APPROVED';\n else if (state === 'CHANGES_REQUESTED') myReview = 'CHANGES_REQUESTED';\n else if (state === 'COMMENTED') myReview = 'COMMENTED';\n break;\n }\n }\n }\n\n return {\n number: pr.number ?? 0,\n title: pr.title ?? '',\n branch: pr.headRefName ?? '',\n url: pr.url ?? '',\n isDraft: pr.isDraft ?? false,\n checksStatus,\n reviewDecision,\n myReview,\n isMine: currentUser ? pr.author?.login?.toLowerCase() === currentUser.toLowerCase() : false,\n conflicting: pr.mergeable === 'CONFLICTING',\n reviewRequested: !!currentUser && (pr.reviewRequests ?? []).some((r) => r?.login?.toLowerCase() === currentUser.toLowerCase()),\n repoAlias,\n // Only when who you are is known: isMine is false for all of them otherwise, and your own would read \"by @you\".\n ...(currentUser && pr.author?.login ? { author: pr.author.login } : {}),\n fork: pr.isCrossRepository === true,\n };\n }\n}\n\n/**\n * Your open PRs and the ones asking for your review, across every GitHub\n * repo, in ONE GraphQL call (about one API point). The list used to be a\n * `gh pr list` per enrolled repo every two minutes: 27 calls for 27 repos.\n * Start shows only these two kinds anyway.\n */\nexport const PR_SEARCH_QUERY = `query($mine: String!, $asked: String!) {\n viewer { login }\n mine: search(query: $mine, type: ISSUE, first: 100) { issueCount nodes { ...pr } }\n asked: search(query: $asked, type: ISSUE, first: 100) { issueCount nodes { ...pr } }\n}\nfragment pr on PullRequest {\n number title url isDraft headRefName mergeable reviewDecision isCrossRepository\n author { login }\n repository { nameWithOwner }\n commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }\n reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } } } }\n latestReviews(first: 20) { nodes { author { login } state } }\n}`;\n\n/** The search's two queries: open PRs by you, and open PRs asking you by name. */\nexport const PR_SEARCH_VARS = {\n mine: 'is:pr is:open archived:false author:@me',\n asked: 'is:pr is:open archived:false review-requested:@me',\n};\n\ninterface SearchNode extends Omit<GhPr, 'statusCheckRollup' | 'reviews' | 'reviewRequests'> {\n repository?: { nameWithOwner?: string } | null;\n commits?: { nodes?: Array<{ commit?: { statusCheckRollup?: { state?: string } | null } | null } | null> | null } | null;\n reviewRequests?: { nodes?: Array<{ requestedReviewer?: { login?: string } | null } | null> | null } | null;\n latestReviews?: { nodes?: Array<{ author?: { login?: string } | null; state?: string } | null> | null } | null;\n}\n\n/** A check rollup's one word, in the shape `gh pr list` gives (so one conversion reads both). */\nfunction rollupAsChecks(state: string | undefined): GhPr['statusCheckRollup'] {\n if (state === 'FAILURE' || state === 'ERROR') return [{ conclusion: 'FAILURE', status: 'COMPLETED' }];\n if (state === 'PENDING' || state === 'EXPECTED') return [{ conclusion: null, status: 'PENDING' }];\n if (state === 'SUCCESS') return [{ conclusion: 'SUCCESS', status: 'COMPLETED' }];\n return [];\n}\n\n/**\n * The search's answer as work's PR rows, each under the alias (or aliases)\n * enrolled for its repository; PRs of repos you haven't enrolled are left\n * out, as before. `incomplete` when a search found more than it returned. Pure.\n */\nexport function parsePrSearch(\n stdout: string,\n aliasesOf: (nameWithOwner: string) => string[],\n): { prs: PullRequestInfo[]; incomplete: boolean } {\n const data = (JSON.parse(stdout) as { data?: Record<string, unknown> } | null)?.data ?? {};\n const user = ((data.viewer as { login?: string } | undefined)?.login ?? '').trim();\n const seen = new Set<string>();\n const prs: PullRequestInfo[] = [];\n let incomplete = false;\n for (const key of ['mine', 'asked']) {\n const result = data[key] as { issueCount?: number; nodes?: Array<SearchNode | null> } | undefined;\n const nodes = (result?.nodes ?? []).filter((n): n is SearchNode => !!n && typeof n.number === 'number');\n if ((result?.issueCount ?? 0) > nodes.length) incomplete = true;\n for (const n of nodes) {\n const pr: GhPr = {\n ...n,\n statusCheckRollup: rollupAsChecks(n.commits?.nodes?.[0]?.commit?.statusCheckRollup?.state),\n reviews: (n.latestReviews?.nodes ?? []).filter((r) => !!r),\n reviewRequests: (n.reviewRequests?.nodes ?? []).map((r) => r?.requestedReviewer ?? null),\n };\n for (const alias of aliasesOf(n.repository?.nameWithOwner ?? '')) {\n const id = `${alias}#${n.number}`;\n if (seen.has(id)) continue;\n seen.add(id);\n prs.push(toPrInfo(pr, alias, user));\n }\n }\n }\n return { prs, incomplete };\n}\n\n/** parsePrSearch, or null for an answer that isn't JSON. */\nfunction readSearch(stdout: string, aliasesOf: (nameWithOwner: string) => string[]): ReturnType<typeof parsePrSearch> | null {\n try {\n return parsePrSearch(stdout, aliasesOf);\n } catch {\n return null;\n }\n}\n\n/** `owner/name` (lowercase) of a repo's origin on github.com, from its `.git/config` text; null for another host or no origin. Pure. */\nexport function githubRepoOf(configText: string): string | null {\n const url = originUrl(configText);\n if (!url || !/(^|[@/.])github\\.com[:/]/i.test(url)) return null;\n return ownerRepo(url)?.toLowerCase() ?? null;\n}\n\n/**\n * Fetch open PRs for a repo using `gh` CLI (async, non-blocking).\n */\nconst PR_LIST_LIMIT = 100;\n\n/** Open PRs for a repo; null when gh couldn't say (missing, offline, not a GitHub repo). */\nasync function fetchPullRequests(repoPath: string, repoAlias: string, currentUser: string): Promise<PullRequestInfo[] | null> {\n try {\n const stdout = await execAsync(\n 'gh',\n [\n 'pr',\n 'list',\n '--state',\n 'open',\n '--json',\n 'number,title,headRefName,url,isDraft,statusCheckRollup,reviewDecision,reviews,reviewRequests,mergeable,author,isCrossRepository',\n '--limit',\n String(PR_LIST_LIMIT),\n ],\n repoPath,\n 15000,\n );\n if (!stdout) return [];\n return parsePrJson(stdout, repoAlias, currentUser);\n } catch {\n return null;\n }\n}\n\n/**\n * Fetch PRs for all configured repos (async, non-blocking).\n * Runs all repo fetches in parallel.\n * Returns a map from branch name → array of PRs across repos.\n */\nasync function getCurrentUser(): Promise<string> {\n try {\n const stdout = await execAsync('gh', ['api', 'user', '--jq', '.login'], process.cwd(), 5000);\n return stdout.trim();\n } catch {\n return '';\n }\n}\n\n/** What fetchAllPullRequests reaches outside (tests pass fakes). */\nexport interface PrListDeps {\n /** `gh api graphql` with the search: its stdout, or null when gh couldn't. */\n search: () => Promise<string | null>;\n /** One repo the old way (`gh pr list` there): not on github.com, or the search failed. */\n listRepo: (repoPath: string, alias: string) => Promise<PullRequestInfo[] | null>;\n /** A repo's `.git/config` text, or null. */\n gitConfig: (repoPath: string) => string | null;\n}\n\nfunction defaultPrListDeps(): PrListDeps {\n let user: Promise<string> | null = null;\n return {\n search: async () => {\n try {\n return await execAsync(\n 'gh',\n ['api', 'graphql', '-f', `query=${PR_SEARCH_QUERY}`, '-f', `mine=${PR_SEARCH_VARS.mine}`, '-f', `asked=${PR_SEARCH_VARS.asked}`],\n process.cwd(),\n 20000,\n );\n } catch {\n return null;\n }\n },\n listRepo: async (repoPath, alias) => fetchPullRequests(repoPath, alias, await (user ??= getCurrentUser())),\n gitConfig: readGitConfig,\n };\n}\n\n/**\n * The PRs for the dashboard: one search for every repo on github.com (yours,\n * and those asking your review), and the old per-repo list only for repos\n * elsewhere (GitHub Enterprise, no origin) — or for all of them when the\n * search fails. Returns a map from branch name → PRs across repos.\n */\nexport async function fetchAllPullRequests(\n repos: Record<string, string>,\n deps: PrListDeps = defaultPrListDeps(),\n): Promise<{ map: BranchPrMap; incomplete: string[] }> {\n const entries = Object.entries(repos);\n const onGithub = new Map<string, string[]>(); // owner/name → its aliases\n const elsewhere: Array<[string, string]> = [];\n for (const [alias, repoPath] of entries) {\n const text = deps.gitConfig(repoPath);\n const gh = text ? githubRepoOf(text) : null;\n if (gh) onGithub.set(gh, [...(onGithub.get(gh) ?? []), alias]);\n else elsewhere.push([alias, repoPath]);\n }\n\n const results: Array<PullRequestInfo[] | null> = [];\n const incomplete: string[] = [];\n if (onGithub.size) {\n const out = await deps.search();\n const parsed = out ? readSearch(out, (repo) => onGithub.get(repo.toLowerCase()) ?? []) : null;\n if (parsed) {\n results.push(parsed.prs);\n if (parsed.incomplete) incomplete.push(...[...onGithub.values()].flat());\n } else {\n // gh can't search (an old gh, no network): the old way, repo by repo.\n const asked = new Set(elsewhere.map(([a]) => a));\n for (const [alias, repoPath] of entries) if (!asked.has(alias)) elsewhere.push([alias, repoPath]);\n }\n }\n const listed = await Promise.all(elsewhere.map(([alias, repoPath]) => deps.listRepo(repoPath, alias)));\n results.push(...listed);\n // Repos whose list may be missing PRs: gh failed, or it hit the limit.\n incomplete.push(...elsewhere.filter((_, i) => listed[i] === null || listed[i]!.length >= PR_LIST_LIMIT).map(([alias]) => alias));\n\n const map: BranchPrMap = new Map();\n for (const prList of results) {\n for (const pr of prList ?? []) {\n const existing = map.get(pr.branch);\n if (existing) {\n existing.push(pr);\n } else {\n map.set(pr.branch, [pr]);\n }\n }\n }\n\n return { map, incomplete };\n}\n","import type { WorkConfig } from '../platform/config.js';\nimport { githubRepoOf } from './pr.js';\nimport { readGitConfig } from '../worktree/repo-scan.js';\nimport { parsePrRef, type PrToStart } from './pr-ref.js';\nimport { defaultRunner, type CommandRunner } from './ship.js';\n\nexport type PrStartResult = { ok: true; pr: PrToStart } | { ok: false; error: string };\n\nexport interface PrStartDeps {\n run?: CommandRunner;\n /** A repo's `.git/config` text (tests pass their own). */\n gitConfig?: (repoPath: string) => string | null;\n}\n\n/** The fields of `gh pr view --json …` this reads; all optional — it is someone else's output. */\ninterface GhPrView {\n number?: number;\n title?: string;\n url?: string;\n headRefName?: string;\n headRefOid?: string;\n baseRefName?: string;\n state?: string;\n isCrossRepository?: boolean;\n author?: { login?: string } | null;\n headRepositoryOwner?: { login?: string } | null;\n}\n\n/**\n * Which of your repos a PR is in, and its branch: from its link (the repo\n * matched by its origin) or its number (in `target`, a repo). Refused: a\n * repo you haven't enrolled, a group as the repo of a bare number, a PR\n * that isn't open, and one from a fork — its branch isn't on origin, so the\n * session couldn't push to it (and `work tree` would make a new, empty\n * branch of that name instead).\n */\nexport async function resolvePrToStart(\n input: string,\n config: Pick<WorkConfig, 'repos' | 'groups'>,\n target?: string,\n deps: PrStartDeps = {},\n): Promise<PrStartResult> {\n const run = deps.run ?? defaultRunner;\n const gitConfig = deps.gitConfig ?? readGitConfig;\n const ref = parsePrRef(input);\n if (!ref) return { ok: false, error: 'Give a pull request link (https://github.com/owner/repo/pull/123), or its number with a repo.' };\n\n const repoOf = (alias: string) => githubRepoOf(gitConfig(config.repos[alias]) ?? '');\n let alias: string | undefined;\n if (ref.repo) {\n const matches = Object.keys(config.repos).filter((a) => repoOf(a) === ref.repo);\n if (!matches.length) return { ok: false, error: `${ref.repo} isn't one of your repos: add it first (work config add <alias> <path>).` };\n // A target named beside a link must hold it: the repo itself, or a group with it among its repos.\n const within = target ? (config.groups?.[target] ?? [target]) : matches;\n alias = matches.find((a) => within.includes(a));\n if (!alias) return { ok: false, error: `PR #${ref.number} is in ${matches.join(' / ')} (${ref.repo}), not ${target}.` };\n } else {\n if (!target) return { ok: false, error: `PR #${ref.number}: which repo? Give its link, or pick the repo.` };\n if (config.groups?.[target])\n return { ok: false, error: `${target} is a group: a PR is one repo's. Give its link, or one of the group's repos.` };\n if (!config.repos[target]) return { ok: false, error: `${target} isn't one of your repos.` };\n alias = target;\n }\n const github = repoOf(alias);\n if (!github) return { ok: false, error: `${alias} isn't on github.com: work can only look up GitHub PRs.` };\n\n const view = await run(\n 'gh',\n [\n 'pr',\n 'view',\n String(ref.number),\n '--repo',\n github,\n '--json',\n 'number,title,url,headRefName,headRefOid,baseRefName,state,isCrossRepository,author,headRepositoryOwner',\n ],\n config.repos[alias],\n );\n if (view.code === 127) return { ok: false, error: 'GitHub CLI (gh) not found: install it to start from a PR.' };\n if (view.code !== 0)\n return { ok: false, error: `PR #${ref.number} in ${github}: ${view.stderr.trim().split('\\n')[0] || 'gh pr view failed'}` };\n let pr: GhPrView;\n try {\n pr = JSON.parse(view.stdout) as GhPrView;\n } catch {\n return { ok: false, error: \"Couldn't read what gh said about the PR.\" };\n }\n if (pr.state && pr.state !== 'OPEN') return { ok: false, error: `PR #${ref.number} is ${pr.state.toLowerCase()}.` };\n if (pr.isCrossRepository) {\n const owner = pr.headRepositoryOwner?.login ?? 'a fork';\n return {\n ok: false,\n error: `PR #${ref.number} comes from a fork (${owner}): its branch isn't on origin, so a session couldn't push to it.`,\n };\n }\n if (!pr.headRefName) return { ok: false, error: `PR #${ref.number}: gh didn't say its branch.` };\n const stale = await localGoneOtherWay(run, config.repos[alias], pr.headRefName, pr.headRefOid);\n if (stale) return { ok: false, error: stale };\n return {\n ok: true,\n pr: {\n alias,\n number: pr.number ?? ref.number,\n title: pr.title ?? '',\n url: pr.url ?? '',\n branch: pr.headRefName,\n base: pr.baseRefName ?? '',\n author: (pr.author?.login ?? '').replace(/^app\\//, ''),\n },\n };\n}\n\n/**\n * `work tree` takes a local branch of that name over origin's, moving it\n * forward when it can. One that has gone another way than the PR (the author\n * force-pushed, or an unrelated branch of the same name) would open on the\n * wrong commits, and what's pushed from it wouldn't go. Ahead (your commits\n * on top) or behind (it fast-forwards) is fine; when git can't tell (no\n * fetch), the usual warning on entering is left to say it.\n */\nasync function localGoneOtherWay(run: CommandRunner, repoPath: string, branch: string, headOid?: string): Promise<string | null> {\n if (!headOid) return null;\n const local = await run('git', ['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], repoPath);\n if (local.code !== 0) return null;\n await run('git', ['fetch', '--quiet', 'origin', branch], repoPath);\n const contains = await run('git', ['merge-base', '--is-ancestor', headOid, `refs/heads/${branch}`], repoPath);\n if (contains.code === 0) return null;\n const behind = await run('git', ['merge-base', '--is-ancestor', `refs/heads/${branch}`, headOid], repoPath);\n if (behind.code !== 1 || contains.code !== 1) return null; // 1 = not an ancestor; anything else: git couldn't say\n return `Your local branch ${branch} and the PR's have gone separate ways (a force-push, or another branch of that name): rename yours (git branch -m ${branch} ${branch}-old) and try again, or go into its session as it is (work tree <repo> ${branch}).`;\n}\n"],"mappings":";;;;;;;;;;;AAmBO,SAAS,WAAW,OAA6B;AACtD,QAAM,IAAI,MAAM,KAAK;AACrB,QAAM,MAAM,0FAA0F,KAAK,CAAC;AAC5G,MAAI,IAAK,QAAO,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,YAAY,GAAG,QAAQ,OAAO,IAAI,CAAC,CAAC,EAAE;AACpF,QAAM,IAAI,YAAY,KAAK,CAAC;AAC5B,SAAO,KAAK,OAAO,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,QAAQ,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI;AAC5D;AASO,SAAS,eAAe,IAAuE,aAA8B;AAClI,QAAM,MAAM,GAAG,SAAS,IAAI,GAAG,MAAM,KAAK;AAC1C,QAAM,OAAO,aAAa,KAAK;AAC/B,QAAM,YAAY,qCAAqC,G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AC,cAAc,iBAAiB,cAAc,MAAM,IAAI,OAAO,GAAG,QAAQ;AAC1G,MAAI,OAAO,SAAS,KAAK,SAAS,SAAS,EAAG,QAAO;AACrD,SAAO,qBAAqB,MAAM,qHAAqH,MAAM,IAAI,MAAM,0EAA0E,MAAM;AACzP;","names":["alias"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/diff/diff-scope.ts","../src/core/platform/web-static.ts","../src/server/local-origin.ts","../src/server/local-server.ts","../src/server/spa-handler.ts","../src/server/diff-server.ts","../src/core/diff/file-context.ts","../src/core/comments/comment-schemas.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { git } from '../git/git.js';\nimport { loadHistory, type WorktreeSession } from '../sessions/history.js';\nimport type { RepoSpec } from './repo-spec.js';\nimport { report } from '../platform/report.js';\n\nexport interface DiffScope {\n isGroup: boolean;\n session: WorktreeSession | null;\n /** Repos to diff (1 for single, N for group). */\n repos: { name: string; root: string }[];\n /** Name of the repo whose subtree the user is in (initial active tab). */\n activeRepoName: string | null;\n}\n\nexport interface ResolvedBase {\n base: string;\n source: 'arg' | 'session' | 'auto-detected' | 'default';\n}\n\nfunction normPath(p: string): string {\n return path.resolve(p).replace(/\\\\/g, '/').toLowerCase();\n}\n\n/**\n * Like {@link normPath} but resolves to the OS-canonical real path.\n * `git rev-parse --show-toplevel` returns the realpath (e.g. macOS `/var` →\n * `/private/var`, and on Windows the long-form name), so comparing it to a\n * stored session path must canonicalize both sides the same way.\n *\n * Uses `realpathSync.native`: the plain `realpathSync` does NOT expand Windows\n * 8.3 short names (`SAMDEV~1` → `SamDev`), so a session path under a\n * short-name parent would never match git's long-form toplevel. `.native`\n * resolves both 8.3 and symlinks. Falls back to {@link normPath} for paths\n * that don't exist (e.g. unit-test fixtures).\n */\nfunction realNorm(p: string): string {\n try {\n return normPath(fs.realpathSync.native(p));\n } catch {\n return normPath(p);\n }\n}\n\n/**\n * Resolve what scope to diff based on cwd. Handles single-repo worktrees,\n * group worktrees (cwd at group root or anywhere inside a sub-repo), and\n * \"random\" git repos not managed by `work`.\n */\nexport function resolveScope(cwd: string): DiffScope | null {\n const normCwd = normPath(cwd);\n const sessions = loadHistory();\n\n // cwd's own git worktree root. Used to reject session-path matches that are\n // really a *parent* repo: linked worktrees often live physically inside\n // another repo (e.g. `<repo>/.claude/worktrees/<branch>`), so a naive prefix\n // match collapses every nested worktree onto the parent's scope — they'd\n // share one daemon and show each other's diff.\n const top = git(['rev-parse', '--show-toplevel'], cwd);\n const toplevel = top.exitCode === 0 && top.stdout ? top.stdout : null;\n const realTop = toplevel ? realNorm(toplevel) : null;\n\n // 1. cwd is at or inside one of a session's repo paths.\n for (const s of sessions) {\n for (const p of s.paths) {\n const np = normPath(p);\n if (normCwd === np || normCwd.startsWith(np + '/')) {\n // Only honour the match if this session path is cwd's actual worktree\n // root. When cwd is in a nested worktree, its toplevel is deeper than\n // `np` — skip so we resolve the real (nested) worktree below.\n if (realTop && realNorm(p) !== realTop) continue;\n if (s.isGroup) {\n return {\n isGroup: true,\n session: s,\n repos: s.paths.map((rp) => ({ name: path.basename(rp), root: rp })),\n activeRepoName: path.basename(p),\n };\n }\n return {\n isGroup: false,\n session: s,\n repos: [{ name: path.basename(p), root: p }],\n activeRepoName: path.basename(p),\n };\n }\n }\n }\n\n // 2. cwd is at the group root (parent of all of a group's repo paths).\n for (const s of sessions) {\n if (!s.isGroup || s.paths.length === 0) continue;\n const parents = s.paths.map((p) => normPath(path.dirname(p)));\n const groupRoot = parents[0];\n if (!parents.every((par) => par === groupRoot)) continue;\n if (normCwd === groupRoot || normCwd.startsWith(groupRoot + '/')) {\n return {\n isGroup: true,\n session: s,\n repos: s.paths.map((rp) => ({ name: path.basename(rp), root: rp })),\n activeRepoName: null,\n };\n }\n }\n\n // 3. Fall back to git rev-parse for repos not managed by `work`.\n if (!toplevel) return null;\n return {\n isGroup: false,\n session: null,\n repos: [{ name: path.basename(toplevel), root: toplevel }],\n activeRepoName: path.basename(toplevel),\n };\n}\n\n/**\n * Find any plausible parent branch — same candidate list as\n * `detectParentBranch`, but DOESN'T require the parent to have commits\n * past HEAD. Returns the candidate with the most-recent merge-base (or\n * null only if no candidates exist at all).\n *\n * Used by the static renderer and the diff server's `?base=branch`\n * route to decide whether to offer the \"Since branch\" tab. `detectParentBranch`\n * skips parents where merge-base == HEAD (correct for the CLI's \"show\n * me what I added past parent\" semantic — empty diff), but the toggle\n * should still appear in that case so the user can confirm \"no, there's\n * nothing committed yet\".\n */\nexport function findAnyParentBranch(cwd: string): string | null {\n return findParent(cwd, false);\n}\n\n/** Walk candidate base branches and pick the one with the most recent merge-base. */\nexport function detectParentBranch(cwd: string): string | null {\n return findParent(cwd, true);\n}\n\nfunction findParent(cwd: string, requireAheadOfParent: boolean): string | null {\n const currentResult = git(['rev-parse', '--abbrev-ref', 'HEAD'], cwd);\n const currentBranch = currentResult.exitCode === 0 ? currentResult.stdout : '';\n\n const candidates = ['main', 'master', 'dev', 'develop'].flatMap((name) => [name, `origin/${name}`]);\n\n let best: { ref: string; sha: string; time: number } | null = null;\n\n for (const ref of candidates) {\n if (ref === currentBranch) continue;\n const exists = git(['rev-parse', '--verify', '--quiet', ref], cwd);\n if (exists.exitCode !== 0 || !exists.stdout) continue;\n\n const mb = git(['merge-base', ref, 'HEAD'], cwd);\n if (mb.exitCode !== 0 || !mb.stdout) continue;\n\n // Skip parents where the merge-base IS HEAD only when the caller\n // asked us to (CLI \"show me what I added\" semantics). When called\n // for the toggle UI, we want to surface the parent even though the\n // diff will be empty.\n if (requireAheadOfParent) {\n const headSha = git(['rev-parse', 'HEAD'], cwd).stdout;\n if (mb.stdout === headSha) continue;\n }\n\n const timeResult = git(['show', '-s', '--format=%ct', mb.stdout], cwd);\n if (timeResult.exitCode !== 0) continue;\n const time = Number(timeResult.stdout);\n if (!Number.isFinite(time)) continue;\n\n if (!best || time > best.time) {\n best = { ref, sha: mb.stdout, time };\n }\n }\n\n return best?.ref ?? null;\n}\n\nexport function resolveBase(scope: DiffScope, argv: { base?: string; branch?: boolean }): ResolvedBase {\n if (argv.base) return { base: argv.base, source: 'arg' };\n\n if (argv.branch) {\n if (scope.session?.baseBranch) {\n return { base: scope.session.baseBranch, source: 'session' };\n }\n const primaryRoot = scope.repos.find((r) => r.name === scope.activeRepoName)?.root ?? scope.repos[0].root;\n const detected = detectParentBranch(primaryRoot);\n if (detected) return { base: detected, source: 'auto-detected' };\n\n report('error', 'Could not determine a parent branch for this worktree.');\n report('detail', 'Pass one explicitly: diff <ref>');\n process.exit(1);\n }\n\n return { base: 'HEAD', source: 'default' };\n}\n\n/**\n * Compute per-repo merge-base when comparing against a non-HEAD ref.\n *\n * `perRepoBase` (keyed by repo root) overrides `base` for individual repos —\n * used by group worktrees forked with different bases per repo\n * (`work tree --base backend=dev --base frontend=feat/x`). A repo without an\n * override falls back to the shared `base`.\n */\nexport function buildRepoSpecs(scope: DiffScope, base: string, perRepoBase?: Record<string, string>): RepoSpec[] {\n return scope.repos.map((r) => {\n const repoBase = perRepoBase?.[r.root] ?? base;\n let diffArg = repoBase;\n if (repoBase !== 'HEAD') {\n const mb = git(['merge-base', repoBase, 'HEAD'], r.root);\n if (mb.exitCode === 0 && mb.stdout) diffArg = mb.stdout;\n }\n return { name: r.name, root: r.root, diffArg };\n });\n}\n\nexport interface ResolvedRepoDiff {\n /** The git ref the diff was computed against. `HEAD` for uncommitted,\n * the resolved parent (e.g. `origin/main`) for branch mode. */\n resolvedBase: string;\n /** The actual argument passed to `git diff` — typically the merge-base\n * sha for branch mode, or `HEAD` for uncommitted. */\n diffArg: string;\n}\n\n/**\n * Resolve the diff target for a single repo. Centralises the\n * \"find-parent → merge-base → fall back to HEAD\" dance that previously\n * lived in three places (scope-routes, web-server, the static renderer).\n *\n * For `base === 'uncommitted'` this is trivially `HEAD`. For\n * `base === 'branch'` it prefers an explicit `sessionBaseBranch` (the\n * value the user recorded with `work tree --base`), falling back to\n * `findAnyParentBranch` (so the toggle stays available even when the\n * branch has no commits past parent yet — diff just renders empty).\n */\nexport function resolveRepoDiff(root: string, base: 'uncommitted' | 'branch', sessionBaseBranch?: string | null): ResolvedRepoDiff {\n if (base === 'uncommitted') {\n return { resolvedBase: 'HEAD', diffArg: 'HEAD' };\n }\n // Prefer a parent we're actually *ahead of* (`detectParentBranch` skips\n // candidates whose merge-base is HEAD, e.g. a `dev` that already contains\n // this branch). `findAnyParentBranch` would pick the most-recent merge-base\n // even when it's HEAD — yielding a useless 0-commit \"since branch\" diff.\n // Fall back to it only so the toggle still resolves to *something*.\n const parent = sessionBaseBranch ?? detectParentBranch(root) ?? findAnyParentBranch(root);\n if (!parent) return { resolvedBase: 'HEAD', diffArg: 'HEAD' };\n let diffArg = 'HEAD';\n const mb = git(['merge-base', parent, 'HEAD'], root);\n if (mb.exitCode === 0 && mb.stdout) diffArg = mb.stdout;\n return { resolvedBase: parent, diffArg };\n}\n\n/**\n * Look up the recorded fork point for a worktree path from session history.\n * Prefers the per-repo base (`baseBranches`) for that exact path, falling\n * back to the session's representative `baseBranch`. Returns undefined when\n * the path isn't a known worktree — callers then auto-detect.\n *\n * Used by the scope diff route, which only carries repo paths (no session),\n * so a `wd` forked with `--base feat/x` still diffs against `feat/x` even\n * though auto-detection wouldn't find a non-mainline parent.\n */\nexport function sessionBaseForPath(root: string): string | undefined {\n const norm = normPath(root);\n for (const s of loadHistory()) {\n for (const p of s.paths) {\n if (normPath(p) === norm) {\n return s.baseBranches?.[p] ?? s.baseBranch;\n }\n }\n }\n return undefined;\n}\n","import fs from 'node:fs';\nimport { packageRoot } from './package-root.js';\nimport http from 'node:http';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst MIME: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'application/javascript; charset=utf-8',\n '.mjs': 'application/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n '.map': 'application/json; charset=utf-8',\n};\n\n/** Resolve the directory shipped by the Vite build. */\nexport function resolveWebRoot(): string | null {\n const entryDir = path.dirname(process.argv[1] ?? '');\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const candidates = [\n path.join(entryDir, 'web'),\n // bundled: this module is inlined into dist/<bin>.js, so dist/web is a\n // sibling of the bundle. Works even when argv[1] is an npm bin symlink\n // (which is not realpath'd, so the entryDir candidate above misses).\n path.join(moduleDir, 'web'),\n // dev/tsx: the package's dist/web (wherever under src/ this module sits).\n ...(packageRoot() ? [path.join(packageRoot()!, 'dist', 'web')] : []),\n ];\n for (const c of candidates) {\n if (fs.existsSync(path.join(c, 'index.html'))) return c;\n }\n return null;\n}\n\n/**\n * Serve a static file under `root`. Returns true if it served a file. Does\n * NOT do SPA fallback — caller decides whether to re-try with /index.html\n * on miss.\n */\nexport function serveStatic(root: string, urlPath: string, res: http.ServerResponse): boolean {\n const clean = urlPath.split('?')[0];\n const requested = clean === '/' ? '/index.html' : clean;\n const filePath = path.join(root, requested);\n const norm = path.normalize(filePath);\n const base = path.normalize(root);\n if (norm !== base && !norm.startsWith(base + path.sep)) return false;\n let stat: fs.Stats;\n try {\n stat = fs.statSync(norm);\n } catch {\n return false;\n }\n if (!stat.isFile()) return false;\n const ext = path.extname(norm).toLowerCase();\n res.writeHead(200, {\n 'Content-Type': MIME[ext] ?? 'application/octet-stream',\n 'Cache-Control': 'no-cache',\n });\n fs.createReadStream(norm).pipe(res);\n return true;\n}\n\n/** Convenience: serve the file if it exists, else fall back to index.html. */\nexport function serveStaticOrShell(root: string, urlPath: string, res: http.ServerResponse): boolean {\n if (serveStatic(root, urlPath, res)) return true;\n if (serveStatic(root, '/index.html', res)) return true;\n return false;\n}\n","/**\n * Who may talk to our localhost servers (work web / wd / comment server).\n *\n * Binding to 127.0.0.1 keeps the network out, and the Host check stops DNS\n * rebinding — but neither stops a web page you have open from making YOUR\n * browser send requests to 127.0.0.1:<port> (cross-site request forgery).\n * The port is predictable and session ids are guessable, and the terminal\n * WebSocket types straight into Claude — so every request that changes\n * something, and every WebSocket upgrade, must come from our own origin.\n *\n * Rules:\n * - Host must be 127.0.0.1:<port> or localhost:<port> (DNS rebinding).\n * - A browser marking the request `Sec-Fetch-Site: cross-site` (or\n * `same-site`: another localhost port) is refused,\n * except a top-level page load (GET/HEAD, `Sec-Fetch-Mode: navigate`,\n * `Sec-Fetch-Dest: document`): clicking a dashboard or diff link in\n * GitHub, Jira or Slack must open it. The opening site can't read the\n * response and a GET changes nothing; frames stay refused, so no other\n * page can embed the dashboard.\n * - Mutating requests (anything but GET/HEAD/OPTIONS) and WebSocket\n * upgrades: `Origin` must be absent (non-browser callers — the Claude\n * hooks, `wd`, the CLI — send none) or exactly our own origin. Browsers\n * always send Origin on cross-origin POSTs and on every WebSocket, and a\n * page can't forge it. `Origin: null` (sandboxed frames, file://) is\n * refused.\n */\n\nexport function allowedHost(host: string | undefined, port: number): boolean {\n return host === `127.0.0.1:${port}` || host === `localhost:${port}`;\n}\n\nexport function allowedOrigin(origin: string | undefined, port: number): boolean {\n if (origin === undefined || origin === '') return true;\n return origin === `http://127.0.0.1:${port}` || origin === `http://localhost:${port}`;\n}\n\nconst SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);\n\nexport interface RequestFacts {\n method: string;\n host?: string;\n origin?: string;\n secFetchSite?: string;\n secFetchMode?: string;\n secFetchDest?: string;\n /** A WebSocket upgrade — always checked like a mutating request. */\n upgrade?: boolean;\n}\n\n/** Null when allowed, else a short reason (for the 403 body / logs). */\nexport function refuseReason(req: RequestFacts, port: number): string | null {\n if (!allowedHost(req.host, port)) return 'bad host';\n const mutating = req.upgrade || !SAFE_METHODS.has(req.method.toUpperCase());\n const pageLoad =\n !req.upgrade &&\n ['GET', 'HEAD'].includes(req.method.toUpperCase()) &&\n req.secFetchMode === 'navigate' &&\n req.secFetchDest === 'document';\n // same-site = another localhost port (your dev servers, say): the\n // dashboard itself is always same-origin, so treat it like cross-site.\n if ((req.secFetchSite === 'cross-site' || req.secFetchSite === 'same-site') && !pageLoad) return 'cross-site request';\n if (mutating && !allowedOrigin(req.origin, port)) return 'foreign origin';\n return null;\n}\n","import { report } from '../core/platform/report.js';\nimport { Hono } from 'hono';\nimport { serve, type ServerType } from '@hono/node-server';\nimport { refuseReason } from './local-origin.js';\n\n// The one way to start a local HTTP server (work web, wd, the comment\n// server, the demo): 127.0.0.1 only, random port, behind the Host/Origin\n// guard. Its own module so a server that needs no git/fs — the demo — can\n// use it without importing the diff server.\n\nexport interface DiffServerHandle {\n url: string;\n port: number;\n stop(): Promise<void>;\n}\n\n/** Start a Hono app on a random port; resolve when it's listening. The\n * raw Node server is exposed via `httpServer` so callers can attach\n * WebSocket upgrade handlers (the terminal bridge).\n *\n * Installs a guard (core/local-origin.ts): Host must be ours (DNS\n * rebinding), and mutating requests must not come from another origin\n * (cross-site request forgery from any page open in the browser). The SPA\n * is served same-origin, and Node callers send no Origin, so both pass.\n */\nexport function launch(app: Hono): Promise<DiffServerHandle & { httpServer: ServerType }> {\n return new Promise((resolve) => {\n // Captured before serve() resolves; first guarded request runs after\n // this is set because serve() doesn't accept connections until it's\n // bound, and bind precedes the info-callback.\n let listenPort = 0;\n const guard = new Hono();\n guard.use('*', async (c, next) => {\n // Host (DNS rebinding) + Origin / Sec-Fetch-Site (cross-site request\n // forgery from any page open in the browser) — see local-origin.ts.\n const reason = refuseReason(\n {\n method: c.req.method,\n host: c.req.header('host'),\n origin: c.req.header('origin'),\n secFetchSite: c.req.header('sec-fetch-site'),\n secFetchMode: c.req.header('sec-fetch-mode'),\n secFetchDest: c.req.header('sec-fetch-dest'),\n },\n listenPort,\n );\n if (reason) return c.text(`Forbidden (${reason})`, 403);\n await next();\n });\n guard.route('/', app);\n\n const server: ServerType = serve({ fetch: guard.fetch, port: 0, hostname: '127.0.0.1' }, (info) => {\n listenPort = info.port;\n const url = `http://127.0.0.1:${info.port}/`;\n report('detail', `[server] listening at ${url}`);\n resolve({\n url,\n port: info.port,\n httpServer: server,\n stop: () =>\n new Promise<void>((res) => {\n server.close(() => res());\n }),\n });\n });\n });\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport type { Context } from 'hono';\n\nconst MIME: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'application/javascript; charset=utf-8',\n '.mjs': 'application/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n '.map': 'application/json; charset=utf-8',\n};\n\nfunction readFile(root: string, relPath: string): { body: Buffer; ext: string } | null {\n const clean = relPath.split('?')[0];\n const requested = clean === '/' ? '/index.html' : clean;\n const filePath = path.join(root, requested);\n const norm = path.normalize(filePath);\n if (!norm.startsWith(path.normalize(root))) return null;\n let stat: fs.Stats;\n try {\n stat = fs.statSync(norm);\n } catch {\n return null;\n }\n if (!stat.isFile()) return null;\n const ext = path.extname(norm).toLowerCase();\n return { body: fs.readFileSync(norm), ext };\n}\n\n/**\n * Hono handler for the bundled SPA. Tries to serve the requested file; if it\n * doesn't exist, falls back to index.html so client-side routing works on\n * deep links. Skips /api/* paths entirely (those should be handled by\n * earlier routes; if we reach here it's a 404).\n */\nexport function serveSpa(c: Context, webRoot: string): Response {\n const url = new URL(c.req.url);\n if (url.pathname.startsWith('/api/')) {\n return c.json({ error: 'not found' }, 404);\n }\n const hit = readFile(webRoot, url.pathname) ?? readFile(webRoot, '/index.html');\n if (!hit) return c.json({ error: 'not found' }, 404);\n return new Response(new Uint8Array(hit.body), {\n status: 200,\n headers: {\n 'Content-Type': MIME[hit.ext] ?? 'application/octet-stream',\n 'Cache-Control': 'no-cache',\n },\n });\n}\n","import { launch, type DiffServerHandle } from './local-server.js';\n\nexport { launch, type DiffServerHandle } from './local-server.js';\nimport { Hono, type Context } from 'hono';\nimport { streamSSE } from 'hono/streaming';\nimport { computeDiff } from '../core/diff/diff-pipeline.js';\nimport { readContextLines } from '../core/diff/file-context.js';\nimport { createFsWatcher } from '../core/platform/fs-watcher.js';\nimport { resolveRepoDiff } from '../core/diff/diff-scope.js';\nimport { git } from '../core/git/git.js';\nimport { resolveWebRoot } from '../core/platform/web-static.js';\nimport { serveSpa } from './spa-handler.js';\nimport type { RepoSpec } from '../core/diff/repo-spec.js';\n\nexport interface DiffServerOptions {\n /** Repos this server scopes to. */\n repos: RepoSpec[];\n /** Short human-readable label for /api/context. */\n scopeLabel: string;\n /** Optional session baseBranch (the value captured at `work tree --base`).\n * When set, the `?base=branch` route uses it instead of auto-detection,\n * so the diff matches what the user actually declared. */\n sessionBaseBranch?: string;\n /** Per-repo fork points keyed by repo root. Overrides `sessionBaseBranch`\n * for individual repos in a group forked with different bases per repo. */\n sessionBaseBranches?: Record<string, string>;\n /** Debounce for fs.watch events before broadcasting diff-changed. */\n watchDebounceMs?: number;\n /** When true, /api/context advertises readOnly=true and the SPA hides\n * the comment UI. Default false. */\n readOnly?: boolean;\n /** Called once the base app is built so feature apps (e.g. comments) can\n * mount themselves and emit events via the SSE hub. */\n attachRoutes?: (api: DiffServerApi) => void;\n}\n\n/** A typed SSE event broadcast to every connected client. */\nexport interface SseEvent {\n event: string;\n data: unknown;\n}\n\nexport interface DiffServerApi {\n /** Mount a Hono sub-app at the given path prefix. */\n route(prefix: string, app: Hono): void;\n /** Broadcast on the shared SSE hub. Fan-out is one-shot per client. */\n broadcast(event: string, data: unknown): void;\n}\n\n/**\n * The shared local HTTP server used by both `wd` (read-only) and `wd -c`\n * (comments). Owns the fs watcher, the SSE hub, and the three routes every\n * mode needs: GET /api/context, GET /api/diff, GET /events. Comment routes\n * register themselves via `attachRoutes`.\n */\nexport async function startDiffServer(opts: DiffServerOptions): Promise<DiffServerHandle> {\n const webRoot = resolveWebRoot();\n if (!webRoot) {\n throw new Error('Could not find dist/web/. Run `npm run build` first.');\n }\n\n const sseListeners = new Set<(e: SseEvent) => void>();\n const watcher = createFsWatcher({\n roots: opts.repos.map((r) => r.root),\n debounceMs: opts.watchDebounceMs,\n onChange: () => broadcast('diff-changed', { ts: Date.now() }),\n });\n\n function broadcast(event: string, data: unknown): void {\n const payload: SseEvent = { event, data };\n for (const cb of sseListeners) cb(payload);\n }\n\n const app = new Hono();\n // No CORS headers and no OPTIONS preflight handler — the SPA is served\n // same-origin so its requests don't trigger preflight. The Host guard in\n // `launch` rejects cross-origin requests before they reach any handler.\n\n app.get('/api/context', (c) => {\n // Current branch of the primary repo, for the \"<branch> vs <base>\" title.\n const primaryRoot = opts.repos[0]?.root;\n let headBranch: string | undefined;\n if (primaryRoot) {\n const head = git(['rev-parse', '--abbrev-ref', 'HEAD'], primaryRoot);\n if (head.exitCode === 0 && head.stdout && head.stdout !== 'HEAD') {\n headBranch = head.stdout;\n }\n }\n return c.json({\n mode: 'review',\n scopeLabel: opts.scopeLabel,\n repos: opts.repos.map((r) => ({ name: r.name })),\n readOnly: !!opts.readOnly,\n headBranch,\n });\n });\n\n app.get('/api/diff', (c) => {\n const base = c.req.query('base') === 'branch' ? 'branch' : 'uncommitted';\n try {\n // For 'uncommitted' we honour the configured `diffArg` (typically\n // HEAD) so single-repo callers preserve whatever ref they\n // configured. For 'branch' we delegate to `resolveRepoDiff` per\n // repo — each one resolves its own parent and merge-base. The\n // top-level `resolvedBase` is the primary repo's value (matches\n // scope-routes and web-server behavior for the badge label).\n const resolved = opts.repos.map((r) =>\n base === 'uncommitted'\n ? { resolvedBase: 'HEAD', diffArg: r.diffArg }\n : resolveRepoDiff(r.root, 'branch', opts.sessionBaseBranches?.[r.root] ?? opts.sessionBaseBranch),\n );\n const repos = opts.repos.map((r, i) => ({\n name: r.name,\n root: r.root,\n resolvedBase: resolved[i].resolvedBase,\n files: computeDiff({ root: r.root, diffArg: resolved[i].diffArg }),\n }));\n const resolvedBase = resolved[0]?.resolvedBase ?? 'HEAD';\n return c.json({ repos, base, resolvedBase });\n } catch (err) {\n return c.json({ error: (err as Error).message }, 500);\n }\n });\n\n // Reveal unchanged context lines around a hunk (\"expand lines\"). Maps the\n // SPA's repo name back to its RepoSpec root; single-repo scopes (the\n // common standalone case) skip the lookup.\n app.get('/api/file-lines', (c) => {\n const repoName = c.req.query('repo') ?? '';\n const relPath = c.req.query('path') ?? '';\n const start = Number(c.req.query('start'));\n const end = Number(c.req.query('end'));\n const ref = c.req.query('ref') || undefined;\n if (!relPath || !Number.isInteger(start) || !Number.isInteger(end)) {\n return c.json({ error: 'bad path/start/end' }, 400);\n }\n const root = opts.repos.length === 1 ? opts.repos[0].root : opts.repos.find((r) => r.name === repoName)?.root;\n if (!root) return c.json({ error: 'unknown repo' }, 404);\n const result = readContextLines({ root, relPath, start, end, ref });\n if (!result) return c.json({ error: 'cannot read file' }, 400);\n return c.json(result);\n });\n\n app.get('/events', (c) =>\n streamSSE(c, async (stream) => {\n const listener = (e: SseEvent) => {\n stream.writeSSE({ event: e.event, data: JSON.stringify(e.data) }).catch(() => {\n /* client gone */\n });\n };\n sseListeners.add(listener);\n await stream.writeSSE({ event: 'connected', data: '' });\n // Keep the stream open until the client disconnects.\n await new Promise<void>((resolve) => {\n stream.onAbort(() => {\n sseListeners.delete(listener);\n resolve();\n });\n });\n }),\n );\n\n // attachRoutes can mount Hono sub-apps with their own routes.\n if (opts.attachRoutes) {\n opts.attachRoutes({\n route: (prefix, sub) => app.route(prefix, sub),\n broadcast,\n });\n }\n\n // SPA fallback for the bundled web assets.\n app.get('*', (c: Context) => serveSpa(c, webRoot));\n\n // Wrap the handle so server shutdown also tears down our chokidar watcher.\n // Without this the watcher keeps Node's event loop open after `stop()` —\n // a real test/teardown leak (vitest hangs after a suite that exercises\n // the server) and a wasteful long-running ghost in dev.\n const handle = await launch(app);\n const baseStop = handle.stop;\n return {\n ...handle,\n stop: async () => {\n try {\n watcher.stop();\n } catch {\n /* */\n }\n await baseStop();\n },\n };\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport spawn from '../platform/spawn.js';\nimport { isInsideRoot } from './diff-pipeline.js';\n\nexport interface ContextLinesOptions {\n /** Git toplevel (repo root) the file lives under. */\n root: string;\n /** Repo-relative path of the file. */\n relPath: string;\n /** 1-based inclusive first line to return. */\n start: number;\n /** 1-based inclusive last line to return. */\n end: number;\n /** When omitted or `'working'`, read the working-tree file. Otherwise the\n * content comes from `git show <ref>:<relPath>` — used when the diff's\n * \"new\" side is a committed snapshot (checkpoint range) rather than the\n * live tree. */\n ref?: string;\n}\n\nexport interface ContextLinesResult {\n /** The requested slice. Shorter than `end - start + 1` when the file ends\n * before `end`. */\n lines: string[];\n /** Echoed 1-based first line of `lines` (clamped to >= 1). */\n start: number;\n /** Total line count of the file at this ref. */\n totalLines: number;\n /** True when `end` reached (or passed) the last line — there is nothing\n * further below to expand. */\n eof: boolean;\n}\n\n/**\n * Read a contiguous range of lines from a file so the diff viewer can\n * reveal the unchanged context around hunks (\"expand lines\" in GitHub's\n * UI). The expandable region is, by definition, identical on both diff\n * sides, so a single read of the appropriate side is enough — the caller\n * maps the old line numbers via the constant gap offset.\n *\n * Path safety mirrors `readMarkdownContent` in diff-pipeline: the textual\n * `relPath` is rejected if it escapes `root`, and the working-tree read is\n * symlink-canonicalised so a `notes.md -> /etc/passwd` symlink can't\n * exfiltrate an out-of-tree file into the payload.\n *\n * Returns `null` when the path is rejected or the content can't be read\n * (missing file, unknown ref, binary). Callers surface that as a 404/400.\n */\nexport function readContextLines(opts: ContextLinesOptions): ContextLinesResult | null {\n const { root, relPath, ref } = opts;\n if (!relPath || !isInsideRoot(root, relPath)) return null;\n\n const start = Math.max(1, Math.floor(opts.start));\n const end = Math.max(start, Math.floor(opts.end));\n\n const content = !ref || ref === 'working' ? readWorkingTree(root, relPath) : readAtRef(root, ref, relPath);\n if (content === null) return null;\n\n // Split on either line ending; drop the trailing empty element a final\n // newline produces so `totalLines` matches the line count git/editors\n // report. Matches how `parseGitDiff` strips line endings from hunk text,\n // so revealed context lines render identically to diff context lines.\n const all = content.split(/\\r?\\n/);\n if (all.length > 0 && all[all.length - 1] === '') all.pop();\n\n const totalLines = all.length;\n // start past EOF → empty slice, eof true.\n const slice = all.slice(start - 1, end);\n return {\n lines: slice,\n start,\n totalLines,\n eof: end >= totalLines,\n };\n}\n\n/** Symlink-safe working-tree read. Returns null on any failure. */\nfunction readWorkingTree(root: string, relPath: string): string | null {\n try {\n const absPath = path.join(root, relPath);\n const realRoot = fs.realpathSync(path.resolve(root));\n const realPath = fs.realpathSync(absPath);\n const sep = path.sep;\n if (realPath !== realRoot && !realPath.startsWith(realRoot + sep)) {\n return null;\n }\n return fs.readFileSync(absPath, 'utf-8');\n } catch {\n return null;\n }\n}\n\n/**\n * A ref we may hand to `git show`: a commit id, or a plain ref name. It\n * comes from a query string, and `git show` takes options — a ref of\n * `--output=/some/file` would make it WRITE a file. So nothing that starts\n * with `-`, and only characters refs actually use.\n */\nexport function isSafeRef(ref: string): boolean {\n return /^[A-Za-z0-9_][A-Za-z0-9._/~^@{}+-]{0,199}$/.test(ref) && !ref.includes('..');\n}\n\n/** `git show <ref>:<relPath>`. Uses cross-spawn directly (not the trimming\n * `git()` helper) so trailing newlines survive. Returns null on failure\n * (including a ref that isn't safe to pass — see isSafeRef). */\nfunction readAtRef(root: string, ref: string, relPath: string): string | null {\n if (!isSafeRef(ref)) return null;\n const r = spawn.sync('git', ['show', '--end-of-options', `${ref}:${relPath}`], {\n cwd: root,\n encoding: 'utf-8',\n maxBuffer: 64 * 1024 * 1024,\n windowsHide: true,\n });\n if (r.status === 0 && typeof r.stdout === 'string') return r.stdout;\n return null;\n}\n","/**\n * Shared zod schemas for the comment HTTP surface. Kept separate from\n * `comment-types.ts` because the SPA imports `comment-types.ts` for the\n * type-only exports and pulling zod into the SPA bundle is wasteful —\n * the schemas are server-side validation only.\n */\n\nimport { z } from 'zod';\n\nexport const commentInputSchema = z.object({\n repo: z.string().optional(),\n file: z.string().optional(),\n line: z.number().int().optional(),\n side: z.enum(['left', 'right', 'general', 'file']).optional(),\n body: z.string().min(1),\n status: z.enum(['published', 'draft']).optional(),\n lineContent: z.string().optional(),\n parentId: z.string().optional(),\n author: z.enum(['user', 'claude']).optional(),\n});\n\nexport const submitReviewSchema = z.object({\n summary: z.string().optional(),\n});\n\nexport const resolveSchema = z.object({\n resolved: z.boolean(),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAoBjB,SAAS,SAAS,GAAmB;AACnC,SAAO,KAAK,QAAQ,CAAC,EAAE,QAAQ,OAAO,GAAG,EAAE,YAAY;AACzD;AAcA,SAAS,SAAS,GAAmB;AACnC,MAAI;AACF,WAAO,SAAS,GAAG,aAAa,OAAO,CAAC,CAAC;AAAA,EAC3C,QAAQ;AACN,WAAO,SAAS,CAAC;AAAA,EACnB;AACF;AAOO,SAAS,aAAa,KAA+B;AAC1D,QAAM,UAAU,SAAS,GAAG;AAC5B,QAAM,WAAW,YAAY;AAO7B,QAAM,MAAM,IAAI,CAAC,aAAa,iBAAiB,GAAG,GAAG;AACrD,QAAM,WAAW,IAAI,aAAa,KAAK,IAAI,SAAS,IAAI,SAAS;AACjE,QAAM,UAAU,WAAW,SAAS,QAAQ,IAAI;AAGhD,aAAW,KAAK,UAAU;AACxB,eAAW,KAAK,EAAE,OAAO;AACvB,YAAM,KAAK,SAAS,CAAC;AACrB,UAAI,YAAY,MAAM,QAAQ,WAAW,KAAK,GAAG,GAAG;AAIlD,YAAI,WAAW,SAAS,CAAC,MAAM,QAAS;AACxC,YAAI,EAAE,SAAS;AACb,iBAAO;AAAA,YACL,SAAS;AAAA,YACT,SAAS;AAAA,YACT,OAAO,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,MAAM,KAAK,SAAS,EAAE,GAAG,MAAM,GAAG,EAAE;AAAA,YAClE,gBAAgB,KAAK,SAAS,CAAC;AAAA,UACjC;AAAA,QACF;AACA,eAAO;AAAA,UACL,SAAS;AAAA,UACT,SAAS;AAAA,UACT,OAAO,CAAC,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,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;AAAA,EACF;AACF;;;AEvLA,SAAS,SAAS;AAEX,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAChC,MAAM,EAAE,KAAK,CAAC,QAAQ,SAAS,WAAW,MAAM,CAAC,EAAE,SAAS;AAAA,EAC5D,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,QAAQ,EAAE,KAAK,CAAC,aAAa,OAAO,CAAC,EAAE,SAAS;AAAA,EAChD,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC,EAAE,SAAS;AAC9C,CAAC;AAEM,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,SAAS,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAEM,IAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,UAAU,EAAE,QAAQ;AACtB,CAAC;","names":["fs","path","path","fs","fs","path","Hono","fs","path","path","fs","Hono"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/platform/launch.ts"],"sourcesContent":["import spawn from './spawn.js';\nimport { buildAiLaunchArgs, type AiLaunchOpts, type AiToolSpec } from './ai-launcher.js';\n\n/** Get the platform-appropriate default editor. */\nexport function getEditor(): string {\n return process.env.EDITOR ?? process.env.VISUAL ?? (process.platform === 'win32' ? 'notepad' : 'vi');\n}\n\n/** Open a file in the user's editor. */\nexport function openInEditor(filePath: string): void {\n const editor = getEditor();\n spawn.sync(editor, [filePath], { stdio: 'inherit' });\n}\n\n/** Open a URL in the default browser. */\nexport function openUrl(url: string): void {\n const cmd = process.platform === 'win32' ? 'cmd' : process.platform === 'darwin' ? 'open' : 'xdg-open';\n const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];\n spawn(cmd, args, { stdio: 'ignore', detached: true }).unref();\n}\n\n/** Open VS Code in the given directory. */\nexport function openVSCode(dir: string): void {\n spawn.sync('code', ['.'], { cwd: dir, stdio: 'inherit' });\n}\n\n/**\n * Launch the configured AI tool in the given directory.\n *\n * When `port` is provided it is injected as `$PORT` into the launched process\n * so dev servers started by parallel agent sessions don't collide.\n */\nexport function launchAi(cwd: string, tool: AiToolSpec, opts: AiLaunchOpts = {}, port?: number): void {\n const { cmd, args } = buildAiLaunchArgs(tool, opts);\n const spawnOpts: Parameters<typeof spawn.sync>[2] =\n port !== undefined ? { cwd, stdio: 'inherit', env: { ...process.env, PORT: String(port) } } : { cwd, stdio: 'inherit' };\n spawn.sync(cmd, args, spawnOpts);\n}\n"],"mappings":";;;;;;;;;AAIO,SAAS,YAAoB;AAClC,SAAO,QAAQ,IAAI,UAAU,QAAQ,IAAI,WAAW,QAAQ,aAAa,UAAU,YAAY;AACjG;AAGO,SAAS,aAAa,UAAwB;AACnD,QAAM,SAAS,UAAU;AACzB,gBAAM,KAAK,QAAQ,CAAC,QAAQ,GAAG,EAAE,OAAO,UAAU,CAAC;AACrD;AAGO,SAAS,QAAQ,KAAmB;AACzC,QAAM,MAAM,QAAQ,aAAa,UAAU,QAAQ,QAAQ,aAAa,WAAW,SAAS;AAC5F,QAAM,OAAO,QAAQ,aAAa,UAAU,CAAC,MAAM,SAAS,IAAI,GAAG,IAAI,CAAC,GAAG;AAC3E,gBAAM,KAAK,MAAM,EAAE,OAAO,UAAU,UAAU,KAAK,CAAC,EAAE,MAAM;AAC9D;AAGO,SAAS,WAAW,KAAmB;AAC5C,gBAAM,KAAK,QAAQ,CAAC,GAAG,GAAG,EAAE,KAAK,KAAK,OAAO,UAAU,CAAC;AAC1D;AAQO,SAAS,SAAS,KAAa,MAAkB,OAAqB,CAAC,GAAG,MAAqB;AACpG,QAAM,EAAE,KAAK,KAAK,IAAI,kBAAkB,MAAM,IAAI;AAClD,QAAM,YACJ,SAAS,SAAY,EAAE,KAAK,OAAO,WAAW,KAAK,EAAE,GAAG,QAAQ,KAAK,MAAM,OAAO,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,OAAO,UAAU;AACxH,gBAAM,KAAK,KAAK,MAAM,SAAS;AACjC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/archive/session-archive-deps.ts","../src/core/archive/archive-summary.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { checkedOutBranch } from '../git/git-head.js';\nimport { loadConfig } from '../platform/config.js';\nimport { agentOf } from '../agents/index.js';\nimport { examineWorktree, normPath, type CleanupSession } from '../cleanup/cleanup.js';\nimport { loadHistory, setSessionArchived, type WorktreeSession } from '../sessions/history.js';\nimport { disposePty } from '../pty/pty-pool.js';\nimport { sessionIdFor } from '../sessions/session-id.js';\nimport { readStatus, turnInProgress } from '../status/session-status.js';\nimport { shownState } from '../status/turn-activity.js';\nimport { defaultRunner, type CommandRunner } from '../pr/ship.js';\nimport { teardownWorktree } from '../worktree/worktree.js';\nimport { archiveSession, type ArchiveDeps, type ArchivedPr } from './session-archive.js';\nimport { archiveRefFor, dropSaved, saveUncommitted, type SavedUncommitted } from './archive-uncommitted.js';\nimport { readPendingForSession } from '../comments/pending-delivery.js';\nimport { listReplies } from '../pr/pr-replies.js';\nimport { stopDev } from '../worktree/dev-server.js';\nimport { buildFoldersOf, clearBuildFolders } from '../cleanup/build-folders.js';\nimport { runInternal } from '../diff/checkpoint-summary.js';\nimport { summarizeArchive } from './archive-summary.js';\nimport { isLeftover } from '../worktree/leftover.js';\nimport { saveIgnored, type SavedIgnored } from './archive-ignored.js';\nimport { worktreeFor } from './archive-restore.js';\n\nconst plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`;\n\n/**\n * What archiving now would leave unfinished, in words (empty: nothing):\n * replies Claude drafted for you to post, notes its Claude hasn't been\n * given yet, a Claude mid-turn or waiting for your answer.\n */\nexport function archiveWaiting(id: string): string[] {\n const out: string[] = [];\n const drafts = listReplies(id).filter((r) => r.status === 'draft').length;\n if (drafts) out.push(`${plural(drafts, 'reply', 'replies')} to post on review threads`);\n const pending = readPendingForSession(id).length;\n if (pending) out.push(`${plural(pending, 'note', 'notes')} not yet delivered to its Claude`);\n // As the dashboard shows it (a Claude that died mid-turn isn't \"working\" forever).\n const session = loadHistory().find((s) => sessionIdFor(s) === id);\n const st = session ? shownState(session) : readStatus(id)?.state;\n if (st === 'working') out.push('its Claude is working');\n if (st === 'needs_input') out.push('its Claude is waiting for your answer');\n return out;\n}\n\n/**\n * The PR watch's archive of merged work (its `archive` dep): `merged`, so\n * nothing waiting in it holds it up. Resolves to what it kept that was\n * waiting (\"2 reply drafts\"), for the Activity note; throws when it didn't\n * archive (a turn in progress), so the watch notes it and tries again.\n */\nexport async function archiveMergedSession(id: string, deps: ArchiveDeps, onChanged: () => void = () => {}): Promise<string | undefined> {\n const s = loadHistory().find((x) => sessionIdFor(x) === id);\n if (!s || s.archivedAt) return undefined;\n const out = await archiveSession(s, deps, { merged: true });\n onChanged();\n if (!out.ok) throw new Error(out.message);\n return out.kept;\n}\n\nexport interface ArchiveDepsOptions {\n /** Release other handles on its folders first (the web server's watchers,\n * a Claude): Windows won't delete a folder something holds open. */\n release?: (sessionId: string) => Promise<void>;\n /** Its PRs, for the summary (the PR watch's cache). */\n prs?: (sessionId: string) => ArchivedPr[];\n run?: CommandRunner;\n}\n\n/** The real inputs of archiveSession, the same for the dashboard, the PR watch and the CLI. */\nexport function defaultArchiveDeps(opts: ArchiveDepsOptions = {}): ArchiveDeps {\n const run = opts.run ?? defaultRunner;\n const config = () => {\n const c = loadConfig();\n if (!c) throw new Error('No config: run `work init` first.');\n return c;\n };\n return {\n stopClaude: async (id) => {\n await disposePty(id);\n await opts.release?.(id);\n },\n removable: async (s, { uncommittedSaved = false } = {}) => {\n const cfg = loadConfig();\n if (!cfg) return { ok: false, reason: 'no work config to check it against' };\n const repos = Object.values(cfg.repos).map(normPath);\n // A session on a repo's own checkout (`work tree <repo>` without a\n // branch) points at the repo itself: that folder is never removed.\n if (s.paths.some((p) => repos.includes(normPath(p)))) return { ok: false, reason: \"it is the repo's own checkout\" };\n if (s.paths.every((p) => !fs.existsSync(p))) return { ok: true, reason: 'already gone' };\n const cs: CleanupSession = {\n id: sessionIdFor(s),\n target: s.target,\n branch: s.branch,\n isGroup: s.isGroup,\n paths: s.paths,\n archivedAt: null,\n lastActiveMs: 0,\n aliases: s.isGroup ? (cfg.groups[s.target] ?? []) : [s.target],\n };\n const c = await examineWorktree(cs, { baseCheckouts: () => Object.values(cfg.repos), run });\n // Uncommitted files that were saved don't keep it; commits not in the\n // main branch still do (nothing else has them).\n const savedAway = uncommittedSaved && c.verdict === 'dirty' && c.repos.every((r) => !r.exists || r.merged !== null);\n return { ok: c.verdict === 'merged' || c.verdict === 'gone' || savedAway, reason: c.reason };\n },\n saveUncommitted: async (s, dir, stamp) => {\n const id = sessionIdFor(s);\n const saved: Record<string, SavedUncommitted> = {};\n for (const [alias, repo] of repoPaths(s, loadConfig())) {\n const wt = worktreeOf(s, repo);\n // A repo's own checkout is never removed, so nothing of it needs saving.\n if (!wt || !fs.existsSync(wt) || normPath(wt) === normPath(repo)) continue;\n const r = await saveUncommitted(wt, alias, archiveRefFor(id, alias, stamp), dir, `${alias}-${stamp}`);\n if ('error' in r) return { saved, error: r.error };\n if ('saved' in r) saved[alias] = r.saved;\n }\n return { saved, error: null };\n },\n dropSaved: async (s, saved, dir) => {\n const cfg = loadConfig();\n for (const [alias, u] of Object.entries(saved)) {\n const repo = cfg?.repos[alias];\n if (repo) await dropSaved(repo, u, dir);\n }\n },\n halfRemoved: (s) => s.paths.filter(isLeftover),\n saveIgnored: async (s, dir) => {\n const cfg = loadConfig();\n const out: Record<string, SavedIgnored> = {};\n for (const [alias] of repoPaths(s, cfg)) {\n const wt = cfg ? worktreeFor(s, alias, cfg) : null;\n if (!wt || !fs.existsSync(wt)) continue;\n const r = await saveIgnored(wt, path.join(dir, 'ignored', alias));\n if (r.files || r.skipped) out[alias] = r;\n }\n return out;\n },\n removeWorktree: async (s) => {\n if (s.paths.every((p) => !fs.existsSync(p))) return true;\n return teardownWorktree(s.target, s.isGroup, s.branch, config(), true, s.paths);\n },\n setArchived: (s) => setSessionArchived(s.target, s.branch, true),\n transcripts: (s: WorktreeSession) => (agentOf(s).conversation?.files(s) ?? []).map((t) => t.file),\n prs: opts.prs,\n lastSummary: (id) => readStatus(id)?.summary ?? null,\n waiting: archiveWaiting,\n // Mid-turn: working as the dashboard shows it, or at a dialog mid-turn (turnInProgress).\n working: (id) => {\n const session = loadHistory().find((x) => sessionIdFor(x) === id);\n return (session ? shownState(session) : readStatus(id)?.state) === 'working' || turnInProgress(readStatus(id));\n },\n kept: (id) => {\n const st = readStatus(id);\n return {\n replyDrafts: listReplies(id)\n .filter((r) => r.status === 'draft')\n .map((r) => ({ threadId: r.threadId, url: r.url, reviewer: r.reviewer, draft: r.draft ?? '' })),\n notes: readPendingForSession(id).map((c) => ({ id: c.id, text: c.body })),\n ...(st?.state === 'needs_input' && st.summary ? { askingYou: st.summary } : {}),\n };\n },\n stopDev: (id) => void stopDev(id),\n heads: (s) => {\n const out: Record<string, string> = {};\n for (const [alias, repo] of repoPaths(s, loadConfig())) {\n const wt = worktreeOf(s, repo);\n const branch = wt ? checkedOutBranch(wt) : null;\n if (branch && branch !== s.branch) out[alias] = branch;\n }\n return out;\n },\n tips: async (s, heads) => {\n const cfg = loadConfig();\n const out: Record<string, string> = {};\n for (const [alias, repo] of repoPaths(s, cfg)) {\n const r = await run('git', ['-C', repo, 'rev-parse', '--verify', '--quiet', `refs/heads/${heads[alias] ?? s.branch}`], repo);\n if (r.code === 0 && r.stdout.trim()) out[alias] = r.stdout.trim();\n }\n return out;\n },\n clearBuildFolders: async (s) => {\n let folders = 0;\n let bytes = 0;\n for (const p of s.paths) {\n if (!fs.existsSync(p)) continue;\n const sized = await buildFoldersOf(p, run);\n const r = await clearBuildFolders(p, run);\n folders += r.removed.length;\n bytes += sized.filter((f) => r.removed.includes(f.path)).reduce((n, f) => n + f.bytes, 0);\n }\n return { folders, bytes };\n },\n tidy: async (s, heads) => {\n const cfg = loadConfig();\n const repos = repoPaths(s, cfg);\n // Its per-turn checkpoints stay (refs in the repos, and their manifest): Restore puts the\n // worktree back at the same path, so the Diff tab's turns come back with it. They go when\n // the session is deleted (clearSessionCheckpoints).\n // A local branch already in the main branch goes (its tip is recorded,\n // and reachable from the main branch, so Restore can recreate it). A\n // squash-merged one stays: its commits are reachable from nothing else.\n // Both the session's branch and the one checked out, when Claude switched.\n const deleted: string[] = [];\n for (const [alias, repo] of repos) {\n const base = (await run('git', ['-C', repo, 'rev-parse', '--abbrev-ref', 'origin/HEAD'], repo)).stdout.trim();\n if (!base || base === 'origin/HEAD') continue;\n const merged = (await run('git', ['-C', repo, 'branch', '--merged', base, '--format=%(refname:short)'], repo)).stdout\n .split('\\n')\n .map((l) => l.trim());\n const inUse = (await run('git', ['-C', repo, 'worktree', 'list', '--porcelain'], repo)).stdout;\n const head = heads[alias] ?? s.branch;\n for (const branch of new Set([s.branch, head])) {\n if (!merged.includes(branch) || inUse.includes(`branch refs/heads/${branch}\\n`)) continue;\n // Reported only for the checked-out one: that is what Restore recreates.\n if ((await run('git', ['-C', repo, 'branch', '-D', branch], repo)).code === 0 && branch === head) deleted.push(alias);\n }\n }\n return deleted;\n },\n summarize: (rec) => summarizeArchive(rec, (prompt) => runInternal(prompt, 60_000)),\n };\n}\n\n/** The session's worktree of a repo: its only path, or (a group) the one named after the repo's folder. */\nfunction worktreeOf(s: WorktreeSession, repo: string): string | null {\n if (!s.isGroup) return s.paths[0] ?? null;\n const name = path.basename(repo).toLowerCase();\n return s.paths.find((p) => path.basename(p).toLowerCase() === name) ?? null;\n}\n\n/** The session's repos as [alias, base checkout path] (a group: each member). */\nfunction repoPaths(s: WorktreeSession, cfg: ReturnType<typeof loadConfig>): Array<[string, string]> {\n if (!cfg) return [];\n const aliases = s.isGroup ? (cfg.groups[s.target] ?? []) : [s.target];\n return aliases.filter((a) => cfg.repos[a] && fs.existsSync(cfg.repos[a])).map((a) => [a, cfg.repos[a]]);\n}\n","import type { ArchiveRecord } from './session-archive.js';\n\n/**\n * The few sentences an archived session keeps on what was done and why —\n * what the Sessions list shows for it, and what archive search finds.\n * Written after archiving by an internal `claude -p` (no tools, neutral\n * cwd: the prompts are your text, but they are only material here).\n */\n\nconst MAX_PROMPT_CHARS = 600;\nconst MAX_INPUT_CHARS = 12_000;\n\n/** The prompt for the summary, from what the archive kept (pure, for tests). */\nexport function summaryPrompt(rec: ArchiveRecord): string {\n const prompts = rec.summary.prompts\n .map((p) => `- ${p.text.replace(/\\s+/g, ' ').slice(0, MAX_PROMPT_CHARS)}`)\n .join('\\n')\n .slice(0, MAX_INPUT_CHARS);\n const prs = rec.summary.prs.map((p) => `#${p.number} (${p.repo}, ${p.state.toLowerCase()})`).join(', ');\n return [\n 'Below is what a developer asked a coding assistant during one piece of work on a git branch, and how it ended.',\n 'Write 2–4 plain sentences on what was done and why, for finding this work again months later:',\n 'name the feature or bug, the main changes, and anything left open. No preamble, no lists, no markdown.',\n '',\n `Branch: ${rec.branch} (${rec.target})`,\n rec.summary.jiraKey ? `Jira: ${rec.summary.jiraKey}` : '',\n prs ? `Pull requests: ${prs}` : '',\n '',\n `The developer's requests (${rec.summary.promptCount} in all; first and latest shown):`,\n prompts || '(none kept)',\n '',\n rec.summary.lastSummary ? `How the last turn ended: ${rec.summary.lastSummary}` : '',\n ]\n .filter((l, i, all) => l !== '' || all[i - 1] !== '')\n .join('\\n');\n}\n\n/** Ask `claude -p` (injectable) for the summary; null when it can't say. */\nexport async function summarizeArchive(rec: ArchiveRecord, ask: (prompt: string) => Promise<string | null>): Promise<string | null> {\n if (rec.summary.prompts.length === 0 && !rec.summary.lastSummary) return null;\n const out = (await ask(summaryPrompt(rec)))?.trim();\n if (!out) return null;\n // One paragraph, bounded: it is shown in a list row.\n return clipToSentence(out.replace(/\\s+/g, ' '), MAX_SUMMARY_CHARS);\n}\n\nconst MAX_SUMMARY_CHARS = 800;\n\n/** At most `max` characters, ending at a sentence when one ends past half of it (else at a word, with \"…\"). */\nexport function clipToSentence(text: string, max = MAX_SUMMARY_CHARS): string {\n if (text.length <= max) return text;\n const head = text.slice(0, max);\n const end = Math.max(head.lastIndexOf('. '), head.lastIndexOf('! '), head.lastIndexOf('? '));\n if (end >= max / 2) return head.slice(0, end + 1);\n const space = head.lastIndexOf(' ');\n return `${head.slice(0, space > 0 ? space : max).trimEnd()}…`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACQjB,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAGjB,SAAS,cAAc,KAA4B;AACxD,QAAM,UAAU,IAAI,QAAQ,QACzB,IAAI,CAAC,MAAM,KAAK,EAAE,KAAK,QAAQ,QAAQ,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,EAAE,EACxE,KAAK,IAAI,EACT,MAAM,GAAG,eAAe;AAC3B,QAAM,MAAM,IAAI,QAAQ,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE,MAAM,KAAK,EAAE,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE,KAAK,IAAI;AACtG,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,IAAI,MAAM,KAAK,IAAI,MAAM;AAAA,IACpC,IAAI,QAAQ,UAAU,SAAS,IAAI,QAAQ,OAAO,KAAK;AAAA,IACvD,MAAM,kBAAkB,GAAG,KAAK;AAAA,IAChC;AAAA,IACA,6BAA6B,IAAI,QAAQ,WAAW;AAAA,IACpD,WAAW;AAAA,IACX;AAAA,IACA,IAAI,QAAQ,cAAc,4B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