@pi-chamber/web 1.0.3 → 1.0.4-rc.2
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/assets/DiagramView-GKGxPczP.js +1 -0
- package/dist/assets/{DiffView-D19Jps0i.js → DiffView-Cay8VAqL.js} +6 -6
- package/dist/assets/FileSaveConflictDialog-BRM9TJo0.js +3 -0
- package/dist/assets/FilesView-CEeQzjc6.js +6 -0
- package/dist/assets/GitHubDetailScaffold-q4YP8iyJ.js +11 -0
- package/dist/assets/GitHubLinkPicker-B9xgIW8y.js +1 -0
- package/dist/assets/GitHubListPrimitives-XkALat1v.js +1 -0
- package/dist/assets/GitView-DV3d0oSJ.js +9 -0
- package/dist/assets/IssuesSurface-OTyt9f3A.js +7 -0
- package/dist/assets/JsonTreeView-X2Auiy_q.js +1 -0
- package/dist/assets/MarkdownRendererImpl-1HameF6j.js +12 -0
- package/dist/assets/PatchDiff-GMQAv4en.js +1 -0
- package/dist/assets/PierreDiffViewer-0X__nypk.js +134 -0
- package/dist/assets/PullRequestsSurface-Dec20SIg.js +2 -0
- package/dist/assets/SessionSwitcherContent-DEw4nz7K.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-DmLhbRzE.js +2 -0
- package/dist/assets/SessionUnreadDot-CJFawQpo.js +1 -0
- package/dist/assets/SettingsView-CwSspvq-.js +6 -0
- package/dist/assets/SettingsWindow-DkPv9MaU.js +1 -0
- package/dist/assets/ToolOutputDialog-DDwbOpTO.js +8 -0
- package/dist/assets/ToolPartDiffPreview-DZRP7p-Q.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-CJondRlh.js → VirtualizedFileDiff-CUWx7JVZ.js} +3 -3
- package/dist/assets/Virtualizer-wpC51ZBQ.js +1 -0
- package/dist/assets/collapsible-Ce85nuXX.js +1 -0
- package/dist/assets/computeVirtualFileMetrics-3PpRLd5B.js +3 -0
- package/dist/assets/{contextFileOpenGuard-CsZL8yie.js → contextFileOpenGuard-PoBklHMz.js} +1 -1
- package/dist/assets/gitStatusPredicates-BvzxqidP.js +1 -0
- package/dist/assets/githubLink-iQ51wqRa.js +10 -0
- package/dist/assets/index-CkMnC_GK.js +1 -0
- package/dist/assets/index-Dd2OcIUY.js +10 -0
- package/dist/assets/index-DvN8zlLT.css +1 -0
- package/dist/assets/main-FasHq7Ck.js +2 -0
- package/dist/assets/main-PSCt716b.js +136 -0
- package/dist/assets/markdownCore-BH56o6Wu.js +2 -0
- package/dist/assets/miniChat-BzfobBDq.js +2 -0
- package/dist/assets/mobile-DAzZE2EL.js +2 -0
- package/dist/assets/permissionStore-B9Hkrqny.js +1 -0
- package/dist/assets/pi-session-focus-preference-D2-1HWmY.js +10 -0
- package/dist/assets/renderDiffWithHighlighter-l8hZWWBO.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-DGYSIihR.js +2 -0
- package/dist/assets/renderFileWithHighlighter-BvDoP7ob.js +1 -0
- package/dist/assets/renderMobileApp-CwgWG0lU.js +11 -0
- package/dist/assets/runtimeEndpointReset-CmI6dBKM.js +62 -0
- package/dist/assets/{runtimeSurface-BdndJV2m.js → runtimeSurface-B1GRkkKC.js} +1 -1
- package/dist/assets/shell-CjFT_Tl9.js +1 -0
- package/dist/assets/sprite-HGQGInUp.js +6510 -0
- package/dist/assets/useAppFontEffects--lKKtKVo.js +212 -0
- package/dist/assets/{useFilesViewSearch-DJ3psTKU.js → useFilesViewSearch-D1jsGQrN.js} +3 -3
- package/dist/assets/useGitHubRemoteSearch-zNgy2bSt.js +1 -0
- package/dist/assets/useSwitcherItems-OCRYcHeu.js +1 -0
- package/dist/assets/vendor-base-ui-DIkTOIJS.js +1 -0
- package/dist/assets/{vendor-beautiful-mermaid-D3YCkKz7.js → vendor-beautiful-mermaid-DApbjBp2.js} +1 -1
- package/dist/assets/vendor-boot-DyL2td56.js +69 -0
- package/dist/assets/vendor-codemirror-autocomplete-DsFn4GLp.js +1 -0
- package/dist/assets/vendor-codemirror-lang-angular-B_NMmBbS.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +1 -0
- package/dist/assets/vendor-codemirror-lang-go-C2KHbcll.js +7 -0
- package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-javascript-DpTUrvx8.js +13 -0
- package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-HpQWHJjv.js → vendor-codemirror-lang-sql-C_RazIaB.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-BYL0r7KR.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +1 -0
- package/dist/assets/vendor-codemirror-language-data-DglcKYWT.js +2 -0
- package/dist/assets/vendor-codemirror-search-DaE6R5gH.js +2 -0
- package/dist/assets/{vendor-elkjs-mzfkf0ML.js → vendor-elkjs-D27273Ms.js} +1 -1
- package/dist/assets/{vendor-heic2any-BHsbokcA.js → vendor-heic2any-pq-UTQQR.js} +1 -1
- package/dist/assets/vendor-lezer-cpp-Dt99h3WT.js +1 -0
- package/dist/assets/vendor-lezer-css-DNU_fzPI.js +1 -0
- package/dist/assets/vendor-lezer-go-BEFtcNyS.js +1 -0
- package/dist/assets/vendor-lezer-html-DDGRhRUz.js +1 -0
- package/dist/assets/vendor-lezer-java-DmfZtW09.js +1 -0
- package/dist/assets/vendor-lezer-javascript-oje4tdp_.js +1 -0
- package/dist/assets/vendor-lezer-json-BRXb_bDX.js +1 -0
- package/dist/assets/vendor-lezer-lr-BU2qmu_5.js +1 -0
- package/dist/assets/{vendor-lezer-markdown-C6g-d6P3.js → vendor-lezer-markdown-CicYv7V9.js} +4 -4
- package/dist/assets/vendor-lezer-php-COORrTpE.js +1 -0
- package/dist/assets/vendor-lezer-python-Cuvm9X9Y.js +1 -0
- package/dist/assets/vendor-lezer-rust-C_zOfHbX.js +1 -0
- package/dist/assets/vendor-lezer-sass-DWP4w7O1.js +1 -0
- package/dist/assets/vendor-lezer-xml-Br6nOYeG.js +1 -0
- package/dist/assets/vendor-lezer-yaml-CYQmm6Sb.js +1 -0
- package/dist/assets/{vendor-lru_map-Cy8fTs3_.js → vendor-lru_map-DOPmc7GU.js} +1 -1
- package/dist/assets/{vendor-qrcode-B0KNSajT.js → vendor-qrcode-Dv4uniC1.js} +1 -1
- package/dist/assets/vendor-react-DASdDPIk.js +1 -0
- package/dist/assets/{vendor-react-drawio-BYDptOsj.js → vendor-react-drawio-Duu5LgQA.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-DaSwPsXt.js → vendor-replit-codemirror-vim-CZy3BUVv.js} +15 -15
- package/dist/assets/vendor-zustand-CUi8eEds.js +6 -0
- package/dist/assets/{web-components-CCKlju0Z.js → web-components-v9fuidaX.js} +4 -4
- package/dist/index.html +7 -9
- package/dist/mini-chat.html +6 -8
- package/dist/mobile.html +6 -8
- package/package.json +2 -2
- package/server/index.js +3 -1
- package/server/lib/fs/DOCUMENTATION.md +1 -1
- package/server/lib/fs/routes.js +1 -50
- package/server/lib/git/DOCUMENTATION.md +18 -11
- package/server/lib/git/index.js +8 -3
- package/server/lib/git/routes.js +0 -129
- package/server/lib/git/service.js +40 -152
- package/server/lib/git/service.test.js +42 -18
- package/server/lib/github/DOCUMENTATION.md +271 -0
- package/server/lib/github/cache.js +164 -0
- package/server/lib/github/checks.js +230 -0
- package/server/lib/github/client.js +305 -0
- package/server/lib/github/context.js +177 -0
- package/server/lib/github/contracts.test.js +235 -0
- package/server/lib/github/correctness.test.js +356 -0
- package/server/lib/github/credential.js +46 -0
- package/server/lib/github/errors.js +151 -0
- package/server/lib/github/gh-cli.js +336 -0
- package/server/lib/github/index.js +27 -0
- package/server/lib/github/issues.js +495 -0
- package/server/lib/github/pulls.js +699 -0
- package/server/lib/github/repo-scope.js +688 -0
- package/server/lib/github/routes.js +599 -0
- package/server/lib/github/security.test.js +275 -0
- package/server/lib/github/templates.js +153 -0
- package/server/lib/package-manager-detect-child.js +12 -0
- package/server/lib/package-manager.js +366 -92
- package/server/lib/package-manager.test.js +109 -0
- package/server/lib/pi/routes-extension-events.test.js +268 -4
- package/server/lib/pi/routes.js +109 -25
- package/server/lib/pi/routes.test.js +118 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +24 -9
- package/server/lib/pi/session-daemon/builtin-extensions.js +37 -0
- package/server/lib/pi/session-daemon/daemon-process.js +6 -0
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +222 -0
- package/server/lib/pi/session-daemon/extension-bridge.js +415 -42
- package/server/lib/pi/session-daemon/extension-name.js +87 -0
- package/server/lib/pi/session-daemon/extension-name.test.js +143 -0
- package/server/lib/pi/session-daemon/extension-theme.js +217 -0
- package/server/lib/pi/session-daemon/extension-theme.test.js +164 -0
- package/server/lib/pi/session-daemon/extension-tool-render.js +365 -0
- package/server/lib/pi/session-daemon/extension-tool-render.test.js +607 -0
- package/server/lib/pi/session-daemon/prompt-operations.test.js +3 -3
- package/server/lib/pi/session-daemon/prompt-preflight.test.js +12 -14
- package/server/lib/pi/session-daemon/sdk-upgrade.test.js +118 -2
- package/server/lib/pi/session-daemon/send-operation-dedup.test.js +1 -1
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +323 -3
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +244 -0
- package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +638 -0
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +437 -0
- package/server/lib/pi/session-daemon/session-daemon.js +265 -75
- package/server/lib/pi/session-daemon/session-daemon.test.js +271 -5
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +1 -1
- package/server/lib/pi/session-daemon/session-replay.test.js +1 -1
- package/server/lib/pi/session-persistence-gap.test.js +2 -3
- package/server/lib/pi/ui-settings-store.js +2 -1
- package/server/lib/pi/ui-settings-store.test.js +27 -0
- package/server/lib/static-cache-control.js +18 -0
- package/server/lib/static-cache-control.test.js +25 -0
- package/server/lib/workspace/host.js +2 -0
- package/dist/assets/DiagramView-Bj1ZrdhI.js +0 -1
- package/dist/assets/FileSaveConflictDialog-2Z4V_gZU.js +0 -3
- package/dist/assets/FilesView-K18gBSws.js +0 -6
- package/dist/assets/GitView-Hm1KBPaD.js +0 -8
- package/dist/assets/JsonTreeView-fNsiZEIo.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DV5Xkj8N.js +0 -12
- package/dist/assets/PatchDiff-DZaJG6jj.js +0 -1
- package/dist/assets/SessionSwitcherContent-RAsmsuYk.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-DuLPlIF_.js +0 -2
- package/dist/assets/SessionUnreadDot-Dm6k5OCd.js +0 -1
- package/dist/assets/SettingsView-Chu4zbWo.js +0 -6
- package/dist/assets/SettingsWindow-CJzFmmfu.js +0 -1
- package/dist/assets/ToolOutputDialog-uYeXsAGc.js +0 -8
- package/dist/assets/ToolPartDiffPreview-DnAHVRs-.js +0 -1
- package/dist/assets/Virtualizer-BSHVMKgK.js +0 -1
- package/dist/assets/collapsible-BH1vXEAI.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-DXkR5jdw.js +0 -3
- package/dist/assets/gitStatusPredicates-BW8heN1a.js +0 -134
- package/dist/assets/index-5fyXnZFi.css +0 -1
- package/dist/assets/index-BrgKwTb0.js +0 -1
- package/dist/assets/index-C-sV_9sb.js +0 -8
- package/dist/assets/isDiffPlainText-DZFr1Tta.js +0 -1
- package/dist/assets/isFilePlainText-KNpEMvb-.js +0 -1
- package/dist/assets/main-BPY2ug1A.js +0 -135
- package/dist/assets/main-BRIjzIRl.js +0 -2
- package/dist/assets/markdownCore-DYizLr1N.js +0 -3
- package/dist/assets/miniChat-Dva4MINl.js +0 -2
- package/dist/assets/mobile-6jNUNv_x.js +0 -2
- package/dist/assets/permissionStore-iKN1K2_x.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BIeBrZmO.js +0 -2
- package/dist/assets/renderMobileApp-BDCtZpeS.js +0 -11
- package/dist/assets/runtimeEndpointReset-DqdGOWp8.js +0 -53
- package/dist/assets/useAppFontEffects-BABx-DxZ.js +0 -6722
- package/dist/assets/usePushVisibilityBeacon-BciEu3HS.js +0 -10
- package/dist/assets/useSwitcherItems-C7_5TB_n.js +0 -1
- package/dist/assets/vendor-aria-hidden-DvXkyWUv.js +0 -1
- package/dist/assets/vendor-base-ui-DXSHfszQ.js +0 -1
- package/dist/assets/vendor-class-variance-authority-5VPnzWs2.js +0 -1
- package/dist/assets/vendor-cmdk-zXx6sGnS.js +0 -1
- package/dist/assets/vendor-codemirror-autocomplete-wd6iRebq.js +0 -1
- package/dist/assets/vendor-codemirror-commands-CNlncqrr.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-DU_4KiiW.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-CmIT9Z5_.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-djiuoTi8.js +0 -1
- package/dist/assets/vendor-codemirror-lang-go-COZSwZYW.js +0 -7
- package/dist/assets/vendor-codemirror-lang-html-CKHqhW5R.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-CNMP5hyC.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js +0 -13
- package/dist/assets/vendor-codemirror-lang-jinja-DaKn_b1k.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-CZ07HmNC.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-wJdQiDBf.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-0z48Roi8.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-DtcZDGqe.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-W8plS-JQ.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-DzzokVau.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-C4ulBVpf.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-BkZJYEwS.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-DiBPljCc.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-DoABsogh.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-BhLJhOCH.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-D95i1Y5R.js +0 -1
- package/dist/assets/vendor-codemirror-language-BByA_dGF.js +0 -3
- package/dist/assets/vendor-codemirror-language-data-BB5mQv-R.js +0 -2
- package/dist/assets/vendor-codemirror-search-BV44140v.js +0 -2
- package/dist/assets/vendor-codemirror-state-CNWM3Q8V.js +0 -5
- package/dist/assets/vendor-codemirror-view-Ct4T37Ue.js +0 -4
- package/dist/assets/vendor-crelt-C8TCjufn.js +0 -1
- package/dist/assets/vendor-detect-node-es-l0sNRNKZ.js +0 -1
- package/dist/assets/vendor-dnd-kit-accessibility-DZKKhs9S.js +0 -1
- package/dist/assets/vendor-dnd-kit-core-C9qcAm_1.js +0 -5
- package/dist/assets/vendor-dnd-kit-sortable-D8ozj8M-.js +0 -1
- package/dist/assets/vendor-dnd-kit-utilities-DTY1C6ST.js +0 -1
- package/dist/assets/vendor-floating-ui-core-CXmKXOXc.js +0 -1
- package/dist/assets/vendor-floating-ui-dom-WyXykhNi.js +0 -1
- package/dist/assets/vendor-floating-ui-react-dom-BZOGXAGe.js +0 -1
- package/dist/assets/vendor-floating-ui-utils-BzXdqYpP.js +0 -1
- package/dist/assets/vendor-framer-motion-CfplGuM0.js +0 -1
- package/dist/assets/vendor-get-nonce-C-Z93AgS.js +0 -1
- package/dist/assets/vendor-lezer-common-B3-cUCR_.js +0 -1
- package/dist/assets/vendor-lezer-cpp-BleAU9o-.js +0 -1
- package/dist/assets/vendor-lezer-css-C5xB6jxd.js +0 -1
- package/dist/assets/vendor-lezer-go-CXK1UKk8.js +0 -1
- package/dist/assets/vendor-lezer-highlight-CDMHUZ74.js +0 -1
- package/dist/assets/vendor-lezer-html-C0I1p52t.js +0 -1
- package/dist/assets/vendor-lezer-java-D_zzj-NV.js +0 -1
- package/dist/assets/vendor-lezer-javascript-D7Tj24ot.js +0 -1
- package/dist/assets/vendor-lezer-json-Iaex0UN-.js +0 -1
- package/dist/assets/vendor-lezer-lr-bhwg1HMg.js +0 -1
- package/dist/assets/vendor-lezer-php-_DHrbsZG.js +0 -1
- package/dist/assets/vendor-lezer-python-CvuFxeZl.js +0 -1
- package/dist/assets/vendor-lezer-rust-Lqgd5SAo.js +0 -1
- package/dist/assets/vendor-lezer-sass-Dnm2lY4t.js +0 -1
- package/dist/assets/vendor-lezer-xml-hUDuAyS5.js +0 -1
- package/dist/assets/vendor-lezer-yaml-BNIl6S_O.js +0 -1
- package/dist/assets/vendor-marijn-find-cluster-break-DXwl3gUT.js +0 -1
- package/dist/assets/vendor-motion-dom-DhJ-sYS5.js +0 -1
- package/dist/assets/vendor-motion-l0sNRNKZ.js +0 -1
- package/dist/assets/vendor-motion-utils-CKEGc_YG.js +0 -1
- package/dist/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +0 -1
- package/dist/assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js +0 -1
- package/dist/assets/vendor-radix-ui-react-context-CFsX-AUC.js +0 -1
- package/dist/assets/vendor-radix-ui-react-dialog-D2yhEu2p.js +0 -5
- package/dist/assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js +0 -1
- package/dist/assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js +0 -1
- package/dist/assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js +0 -1
- package/dist/assets/vendor-radix-ui-react-id-D2kS9K1j.js +0 -1
- package/dist/assets/vendor-radix-ui-react-portal-YgCRIyi7.js +0 -1
- package/dist/assets/vendor-radix-ui-react-presence-D432pCMB.js +0 -1
- package/dist/assets/vendor-radix-ui-react-primitive-DkH8dMOR.js +0 -1
- package/dist/assets/vendor-radix-ui-react-slot-BIDFZX0-.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-effect-event-D94va83M.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js +0 -1
- package/dist/assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js +0 -1
- package/dist/assets/vendor-react-B5Z1Mdn3.js +0 -9
- package/dist/assets/vendor-react-remove-scroll-bar-CSAHp1YF.js +0 -38
- package/dist/assets/vendor-react-remove-scroll-vR1dy1aP.js +0 -4
- package/dist/assets/vendor-react-style-singleton-Ctw6HnYx.js +0 -1
- package/dist/assets/vendor-reselect-l0sNRNKZ.js +0 -1
- package/dist/assets/vendor-scheduler-7OC5HNn7.js +0 -1
- package/dist/assets/vendor-simplewebauthn-browser-VDA66rT_.js +0 -2
- package/dist/assets/vendor-sonner-BDtm25td.js +0 -1
- package/dist/assets/vendor-style-mod-NZ5MEPvj.js +0 -3
- package/dist/assets/vendor-tanstack-react-virtual-2skouoFw.js +0 -1
- package/dist/assets/vendor-tanstack-virtual-core-Dubg10g5.js +0 -1
- package/dist/assets/vendor-tslib-De9GV7Vy.js +0 -1
- package/dist/assets/vendor-use-callback-ref-CVVuCyLj.js +0 -1
- package/dist/assets/vendor-use-sidecar-Vv4V8Nd1.js +0 -1
- package/dist/assets/vendor-use-sync-external-store-D0AXkdQC.js +0 -1
- package/dist/assets/vendor-w3c-keyname-Vcq4gwWv.js +0 -1
- package/dist/assets/vendor-zustand-GVb4H8HE.js +0 -6
- package/server/lib/git/credentials.js +0 -41
- package/server/lib/git/identity-storage.js +0 -122
- /package/dist/assets/{vendor-katex-CNckGUMB.js → vendor-katex-DZG0Ov6p.js} +0 -0
- /package/dist/assets/{vendor-katex-Cp579UoJ.css → vendor-katex-css-Cp579UoJ.css} +0 -0
- /package/dist/assets/{vendor-xterm-xterm-CrXqRur4.js → vendor-xterm-xterm-B-qIQCd3.js} +0 -0
- /package/dist/assets/{vendor-xterm-xterm-DDGTF8rc.css → vendor-xterm-xterm-css-DDGTF8rc.css} +0 -0
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
/** Repo scope resolution + shared validation/viewer helpers (§4). See DOCUMENTATION.md. */
|
|
2
|
+
|
|
3
|
+
import { execFile } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
import { createTtlCache } from './cache.js';
|
|
9
|
+
import { isSupportedHost } from './client.js';
|
|
10
|
+
import { failed, inputError } from './errors.js';
|
|
11
|
+
|
|
12
|
+
const defaultExecFileAsync = promisify(execFile);
|
|
13
|
+
|
|
14
|
+
export const SCOPE_CACHE_TTL_MS = 30_000;
|
|
15
|
+
export const REPO_INFO_TTL_MS = 5 * 60_000;
|
|
16
|
+
const GIT_TIMEOUT_MS = 10_000;
|
|
17
|
+
|
|
18
|
+
const FAIL_CLOSED_GIT_ENV = Object.freeze({
|
|
19
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
20
|
+
GCM_INTERACTIVE: 'never',
|
|
21
|
+
GIT_ASKPASS: '',
|
|
22
|
+
SSH_ASKPASS: '',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const NESTED_MAX_DEPTH = 4;
|
|
26
|
+
const NESTED_MAX_REPOS = 50;
|
|
27
|
+
const NESTED_MAX_DIRS = 5000;
|
|
28
|
+
const NESTED_BUDGET_MS = 2000;
|
|
29
|
+
|
|
30
|
+
const SKIP_DIR_NAMES = new Set([
|
|
31
|
+
'node_modules', '.git', 'dist', 'build', 'out', 'coverage', '.next', '.nuxt',
|
|
32
|
+
'target', 'vendor', '__pycache__', '.venv', 'venv', '.tox', '.gradle',
|
|
33
|
+
'.idea', '.vscode', 'Pods', 'DerivedData',
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
export const OWNER_REPO_PATTERN = /^[A-Za-z0-9_.-]+$/;
|
|
37
|
+
const MAX_OWNER_REPO_LENGTH = 100;
|
|
38
|
+
|
|
39
|
+
export const isValidOwnerOrRepo = (value) => typeof value === 'string'
|
|
40
|
+
&& value.length > 0
|
|
41
|
+
&& value.length <= MAX_OWNER_REPO_LENGTH
|
|
42
|
+
&& OWNER_REPO_PATTERN.test(value);
|
|
43
|
+
|
|
44
|
+
export const isValidIssueNumber = (value) => {
|
|
45
|
+
const number = typeof value === 'number' ? value : Number.parseInt(String(value), 10);
|
|
46
|
+
return Number.isInteger(number) && number > 0 && number <= 2_147_483_647 && String(value).trim() === String(number);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const DEFAULT_PER_PAGE = 30;
|
|
50
|
+
|
|
51
|
+
/** Shared page-size validation for list routes (400 input error on misuse). */
|
|
52
|
+
export const parsePerPage = (value, { defaultValue = DEFAULT_PER_PAGE } = {}) => {
|
|
53
|
+
if (value === undefined || value === null || value === '') return defaultValue;
|
|
54
|
+
const parsed = Number(value);
|
|
55
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 100) {
|
|
56
|
+
throw inputError('perPage must be an integer between 1 and 100.');
|
|
57
|
+
}
|
|
58
|
+
return parsed;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Allow-list a fixed-set query param. Absent/empty resolves to `fallback`
|
|
63
|
+
* (preserving current defaults); any other unknown value throws the
|
|
64
|
+
* existing 400 input error so it cannot reach the API.
|
|
65
|
+
*/
|
|
66
|
+
export const parseEnumParam = (value, allowed, fallback, { name = 'parameter' } = {}) => {
|
|
67
|
+
if (value === undefined || value === null || value === '') return fallback;
|
|
68
|
+
if (allowed.includes(value)) return value;
|
|
69
|
+
throw inputError(`Invalid ${name} parameter.`);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Parse `host/owner/name` repo params. Returns `{ host, owner, repo }` or null.
|
|
74
|
+
*/
|
|
75
|
+
export const parseRepoRef = (value) => {
|
|
76
|
+
if (typeof value !== 'string') return null;
|
|
77
|
+
const parts = value.trim().split('/');
|
|
78
|
+
if (parts.length !== 3) return null;
|
|
79
|
+
const [host, owner, repo] = parts.map((part) => part.trim());
|
|
80
|
+
if (!host || !owner || !repo) return null;
|
|
81
|
+
if (!/^[A-Za-z0-9.-]+(?::\d+)?$/.test(host)) return null;
|
|
82
|
+
if (!isValidOwnerOrRepo(owner) || !isValidOwnerOrRepo(repo)) return null;
|
|
83
|
+
return { host: host.toLowerCase(), owner, repo };
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const formatRepoRef = ({ host, owner, repo }) => `${host}/${owner}/${repo}`;
|
|
87
|
+
|
|
88
|
+
/** Strip credentials/userinfo from a remote URL before it leaves the server. */
|
|
89
|
+
export const redactRemoteUrl = (url) => {
|
|
90
|
+
if (typeof url !== 'string' || !url) return null;
|
|
91
|
+
if (url.includes('://')) {
|
|
92
|
+
try {
|
|
93
|
+
const parsed = new URL(url);
|
|
94
|
+
parsed.username = '';
|
|
95
|
+
parsed.password = '';
|
|
96
|
+
return parsed.toString();
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// scp-like `[user@]host:path`: strip a `user@` prefix when present.
|
|
102
|
+
if (/^(?:([^@/:]+)@)?([^:/]+):(.*)$/.test(url) && !url.startsWith('git@') && url.includes('@')) {
|
|
103
|
+
return url.slice(url.indexOf('@') + 1);
|
|
104
|
+
}
|
|
105
|
+
return url;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Parse a git remote URL into `{ host, owner, repo }`. Supports https/http
|
|
110
|
+
* (with optional port, credentials, `.git` suffix), `ssh://` (with optional
|
|
111
|
+
* user/port), and scp-like `git@host:owner/repo(.git)`. Returns null when
|
|
112
|
+
* the URL is not a parseable owner/repo reference.
|
|
113
|
+
*/
|
|
114
|
+
export const parseRemoteUrl = (url) => {
|
|
115
|
+
if (typeof url !== 'string') return null;
|
|
116
|
+
let text = url.trim();
|
|
117
|
+
if (!text) return null;
|
|
118
|
+
|
|
119
|
+
const cleanPath = (pathname) => {
|
|
120
|
+
let cleaned = decodeURIComponentSafe(pathname).replace(/^\/+/, '').replace(/\/+$/, '');
|
|
121
|
+
if (cleaned.toLowerCase().endsWith('.git')) cleaned = cleaned.slice(0, -4);
|
|
122
|
+
return cleaned;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
if (/^(https?|ssh|git):\/\//i.test(text)) {
|
|
126
|
+
let parsed = null;
|
|
127
|
+
try {
|
|
128
|
+
parsed = new URL(text);
|
|
129
|
+
} catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const host = parsed.hostname.toLowerCase();
|
|
133
|
+
if (!host) return null;
|
|
134
|
+
const segments = cleanPath(parsed.pathname).split('/').filter(Boolean);
|
|
135
|
+
if (segments.length !== 2) return null;
|
|
136
|
+
const [owner, repo] = segments;
|
|
137
|
+
if (!isValidOwnerOrRepo(owner) || !isValidOwnerOrRepo(repo)) return null;
|
|
138
|
+
return { host, owner, repo };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// scp-like syntax: [user@]host:owner/repo(.git)
|
|
142
|
+
const scpMatch = /^(?:[^@/:\s]+@)?([^@:/\s]+):(.*)$/.exec(text);
|
|
143
|
+
if (scpMatch) {
|
|
144
|
+
const host = scpMatch[1].toLowerCase();
|
|
145
|
+
const segments = cleanPath(scpMatch[2]).split('/').filter(Boolean);
|
|
146
|
+
if (segments.length !== 2) return null;
|
|
147
|
+
const [owner, repo] = segments;
|
|
148
|
+
if (!isValidOwnerOrRepo(owner) || !isValidOwnerOrRepo(repo)) return null;
|
|
149
|
+
return { host, owner, repo };
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const decodeURIComponentSafe = (value) => {
|
|
155
|
+
try {
|
|
156
|
+
return decodeURIComponent(value);
|
|
157
|
+
} catch {
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const createDefaultGitRunner = ({ execFileAsync = defaultExecFileAsync, env = process.env } = {}) => async (cwd, args) => {
|
|
163
|
+
try {
|
|
164
|
+
const result = await execFileAsync('git', args, {
|
|
165
|
+
cwd,
|
|
166
|
+
env: { ...env, ...FAIL_CLOSED_GIT_ENV },
|
|
167
|
+
timeout: GIT_TIMEOUT_MS,
|
|
168
|
+
windowsHide: true,
|
|
169
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
170
|
+
});
|
|
171
|
+
return { success: true, exitCode: 0, stdout: String(result?.stdout || ''), stderr: String(result?.stderr || '') };
|
|
172
|
+
} catch (error) {
|
|
173
|
+
return {
|
|
174
|
+
success: false,
|
|
175
|
+
exitCode: typeof error?.code === 'number' ? error.code : 1,
|
|
176
|
+
stdout: String(error?.stdout || ''),
|
|
177
|
+
stderr: String(error?.stderr || ''),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const parseRemoteVerbose = (stdout) => {
|
|
183
|
+
const remotes = new Map();
|
|
184
|
+
for (const line of String(stdout || '').split('\n')) {
|
|
185
|
+
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)\s*$/.exec(line.trim());
|
|
186
|
+
if (!match) continue;
|
|
187
|
+
const [, name, remoteUrl, direction] = match;
|
|
188
|
+
if (!remotes.has(name)) remotes.set(name, { name, fetchUrl: null, pushUrl: null });
|
|
189
|
+
const entry = remotes.get(name);
|
|
190
|
+
if (direction === 'fetch' && !entry.fetchUrl) entry.fetchUrl = remoteUrl;
|
|
191
|
+
if (direction === 'push' && !entry.pushUrl) entry.pushUrl = remoteUrl;
|
|
192
|
+
}
|
|
193
|
+
return [...remotes.values()];
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const parseGitmodules = (text) => {
|
|
197
|
+
const submodulePaths = new Set();
|
|
198
|
+
for (const line of String(text || '').split('\n')) {
|
|
199
|
+
const match = /^\s*path\s*=\s*(.+?)\s*$/.exec(line);
|
|
200
|
+
if (match) submodulePaths.add(match[1].trim());
|
|
201
|
+
}
|
|
202
|
+
return submodulePaths;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const pathExists = async (fsPromises, candidate) => {
|
|
206
|
+
try {
|
|
207
|
+
await fsPromises.stat(candidate);
|
|
208
|
+
return true;
|
|
209
|
+
} catch {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export const createRepoScopeResolver = ({
|
|
215
|
+
runGit = null,
|
|
216
|
+
fsPromises = fs.promises,
|
|
217
|
+
pathApi = path,
|
|
218
|
+
osApi = os,
|
|
219
|
+
now = Date.now,
|
|
220
|
+
scopeTtlMs = SCOPE_CACHE_TTL_MS,
|
|
221
|
+
} = {}) => {
|
|
222
|
+
const git = runGit || createDefaultGitRunner();
|
|
223
|
+
const scopeCache = createTtlCache({ ttlMs: scopeTtlMs, maxEntries: 200, now });
|
|
224
|
+
|
|
225
|
+
const normalizeDirectory = (directory) => {
|
|
226
|
+
if (typeof directory !== 'string' || !directory.trim()) return '';
|
|
227
|
+
const trimmed = directory.trim();
|
|
228
|
+
if (trimmed === '~') return osApi.homedir();
|
|
229
|
+
if (trimmed.startsWith('~/')) return pathApi.join(osApi.homedir(), trimmed.slice(2));
|
|
230
|
+
return pathApi.resolve(trimmed);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const readTopLevel = async (directory) => {
|
|
234
|
+
const result = await git(directory, ['rev-parse', '--show-toplevel']);
|
|
235
|
+
if (!result.success) return null;
|
|
236
|
+
const topLevel = result.stdout.trim().split('\n')[0]?.trim();
|
|
237
|
+
return topLevel || null;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const readBranch = async (directory) => {
|
|
241
|
+
const result = await git(directory, ['branch', '--show-current']);
|
|
242
|
+
if (!result.success) return null;
|
|
243
|
+
return result.stdout.trim() || null;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const readTrackingRemote = async (directory) => {
|
|
247
|
+
const result = await git(directory, ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']);
|
|
248
|
+
if (!result.success) return null;
|
|
249
|
+
const ref = result.stdout.trim();
|
|
250
|
+
const slash = ref.indexOf('/');
|
|
251
|
+
if (slash <= 0) return null;
|
|
252
|
+
return ref.slice(0, slash);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const readRemotes = async (directory) => {
|
|
256
|
+
const result = await git(directory, ['remote', '-v']);
|
|
257
|
+
if (!result.success) return [];
|
|
258
|
+
return parseRemoteVerbose(result.stdout);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const findEnclosingRepo = async (topLevel) => {
|
|
262
|
+
const home = pathApi.resolve(osApi.homedir());
|
|
263
|
+
let cursor = pathApi.dirname(topLevel);
|
|
264
|
+
let guard = 0;
|
|
265
|
+
while (cursor && guard < 64) {
|
|
266
|
+
guard += 1;
|
|
267
|
+
if (await pathExists(fsPromises, pathApi.join(cursor, '.git'))) {
|
|
268
|
+
return cursor;
|
|
269
|
+
}
|
|
270
|
+
if (cursor === home || cursor === pathApi.dirname(cursor)) break;
|
|
271
|
+
cursor = pathApi.dirname(cursor);
|
|
272
|
+
}
|
|
273
|
+
return null;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const findNestedRepos = async (root, { isRepoRoot }) => {
|
|
277
|
+
const nested = [];
|
|
278
|
+
let truncated = false;
|
|
279
|
+
let dirsVisited = 0;
|
|
280
|
+
const deadline = now() + NESTED_BUDGET_MS;
|
|
281
|
+
const queue = [{ dir: root, depth: 0 }];
|
|
282
|
+
const seen = new Set([pathApi.resolve(root)]);
|
|
283
|
+
|
|
284
|
+
while (queue.length > 0) {
|
|
285
|
+
if (now() > deadline) {
|
|
286
|
+
truncated = true;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
if (dirsVisited >= NESTED_MAX_DIRS) {
|
|
290
|
+
truncated = true;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
if (nested.length >= NESTED_MAX_REPOS) {
|
|
294
|
+
truncated = true;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
const { dir, depth } = queue.shift();
|
|
298
|
+
dirsVisited += 1;
|
|
299
|
+
let entries = null;
|
|
300
|
+
try {
|
|
301
|
+
entries = await fsPromises.readdir(dir, { withFileTypes: true });
|
|
302
|
+
} catch {
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
let hasGit = false;
|
|
306
|
+
for (const entry of entries) {
|
|
307
|
+
if (entry.name === '.git') {
|
|
308
|
+
hasGit = true;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const isRoot = pathApi.resolve(dir) === pathApi.resolve(root);
|
|
313
|
+
if (hasGit && !(isRoot && isRepoRoot)) {
|
|
314
|
+
nested.push(dir);
|
|
315
|
+
if (nested.length >= NESTED_MAX_REPOS) {
|
|
316
|
+
truncated = true;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (depth >= NESTED_MAX_DEPTH) continue;
|
|
322
|
+
for (const entry of entries) {
|
|
323
|
+
if (!entry.isDirectory()) continue;
|
|
324
|
+
if (SKIP_DIR_NAMES.has(entry.name)) continue;
|
|
325
|
+
const child = pathApi.join(dir, entry.name);
|
|
326
|
+
const resolved = pathApi.resolve(child);
|
|
327
|
+
if (seen.has(resolved)) continue;
|
|
328
|
+
seen.add(resolved);
|
|
329
|
+
queue.push({ dir: child, depth: depth + 1 });
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Honor submodule membership and git-ignored paths.
|
|
334
|
+
let submodulePaths = new Set();
|
|
335
|
+
try {
|
|
336
|
+
const gitmodules = await fsPromises.readFile(pathApi.join(root, '.gitmodules'), 'utf8');
|
|
337
|
+
submodulePaths = parseGitmodules(gitmodules);
|
|
338
|
+
} catch {
|
|
339
|
+
submodulePaths = new Set();
|
|
340
|
+
}
|
|
341
|
+
// Batch ignore filtering in a single git spawn (best-effort: on failure keep all).
|
|
342
|
+
let ignored = new Set();
|
|
343
|
+
if (isRepoRoot && nested.length > 0) {
|
|
344
|
+
ignored = await filterIgnoredPaths(root, nested);
|
|
345
|
+
}
|
|
346
|
+
const filtered = nested.filter((repoPath) => !ignored.has(repoPath));
|
|
347
|
+
return {
|
|
348
|
+
repos: filtered.map((repoPath) => ({
|
|
349
|
+
path: repoPath,
|
|
350
|
+
submodule: [...submodulePaths].some((submodulePath) => pathApi.resolve(root, submodulePath) === pathApi.resolve(repoPath)),
|
|
351
|
+
})),
|
|
352
|
+
truncated,
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const filterIgnoredPaths = async (root, repoPaths) => {
|
|
357
|
+
try {
|
|
358
|
+
const { spawn } = await import('node:child_process');
|
|
359
|
+
const relative = repoPaths.map((repoPath) => pathApi.relative(root, repoPath)).filter(Boolean);
|
|
360
|
+
if (relative.length === 0) return new Set();
|
|
361
|
+
const ignored = await new Promise((resolve) => {
|
|
362
|
+
const child = spawn('git', ['-C', root, 'check-ignore', '--stdin'], {
|
|
363
|
+
env: { ...process.env, ...FAIL_CLOSED_GIT_ENV },
|
|
364
|
+
windowsHide: true,
|
|
365
|
+
timeout: 5000,
|
|
366
|
+
});
|
|
367
|
+
let stdout = '';
|
|
368
|
+
let settled = false;
|
|
369
|
+
const done = (value) => {
|
|
370
|
+
if (!settled) {
|
|
371
|
+
settled = true;
|
|
372
|
+
resolve(value);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
child.stdout?.on('data', (chunk) => {
|
|
376
|
+
stdout += String(chunk);
|
|
377
|
+
});
|
|
378
|
+
child.on('error', () => done(new Set()));
|
|
379
|
+
child.on('close', () => {
|
|
380
|
+
const lines = stdout.split('\n').map((line) => line.trim()).filter(Boolean);
|
|
381
|
+
done(new Set(lines.map((line) => pathApi.resolve(root, line))));
|
|
382
|
+
});
|
|
383
|
+
try {
|
|
384
|
+
child.stdin?.write(`${relative.join('\n')}\n`);
|
|
385
|
+
child.stdin?.end();
|
|
386
|
+
} catch {
|
|
387
|
+
done(new Set());
|
|
388
|
+
}
|
|
389
|
+
setTimeout(() => done(new Set()), 5500).unref?.();
|
|
390
|
+
});
|
|
391
|
+
return ignored;
|
|
392
|
+
} catch {
|
|
393
|
+
return new Set();
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const mapLocalRepo = async (repoPath, kind, { rootForRelative, trackingRemote }) => {
|
|
398
|
+
const remotes = await readRemotes(repoPath);
|
|
399
|
+
const githubRemotes = [];
|
|
400
|
+
for (const remote of remotes) {
|
|
401
|
+
const parsed = parseRemoteUrl(remote.fetchUrl || remote.pushUrl || '');
|
|
402
|
+
if (parsed && isSupportedHost(parsed.host)) {
|
|
403
|
+
githubRemotes.push({ ...remote, ...parsed });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const relativePath = rootForRelative ? (pathApi.relative(rootForRelative, repoPath) || '.') : repoPath;
|
|
407
|
+
const base = {
|
|
408
|
+
kind,
|
|
409
|
+
path: repoPath,
|
|
410
|
+
relativePath,
|
|
411
|
+
submodule: false,
|
|
412
|
+
fork: null,
|
|
413
|
+
disabledReason: null,
|
|
414
|
+
};
|
|
415
|
+
if (remotes.length === 0) {
|
|
416
|
+
return { ...base, host: null, owner: null, repo: null, remote: null, remoteUrl: null, disabledReason: 'no-remote' };
|
|
417
|
+
}
|
|
418
|
+
const pickDefault = () => {
|
|
419
|
+
if (trackingRemote) {
|
|
420
|
+
const tracked = githubRemotes.find((remote) => remote.name === trackingRemote);
|
|
421
|
+
if (tracked) return tracked;
|
|
422
|
+
}
|
|
423
|
+
for (const name of ['origin', 'upstream']) {
|
|
424
|
+
const named = githubRemotes.find((remote) => remote.name === name);
|
|
425
|
+
if (named) return named;
|
|
426
|
+
}
|
|
427
|
+
return githubRemotes[0] || null;
|
|
428
|
+
};
|
|
429
|
+
const chosen = pickDefault();
|
|
430
|
+
if (!chosen) {
|
|
431
|
+
const firstRemote = remotes[0];
|
|
432
|
+
const parsed = parseRemoteUrl(firstRemote.fetchUrl || firstRemote.pushUrl || '');
|
|
433
|
+
if (parsed && !isSupportedHost(parsed.host)) {
|
|
434
|
+
return { ...base, host: parsed.host, owner: parsed.owner, repo: parsed.repo, remote: firstRemote.name, remoteUrl: redactRemoteUrl(firstRemote.fetchUrl), disabledReason: 'not-github' };
|
|
435
|
+
}
|
|
436
|
+
return { ...base, host: null, owner: null, repo: null, remote: firstRemote.name, remoteUrl: redactRemoteUrl(firstRemote.fetchUrl), disabledReason: 'not-github' };
|
|
437
|
+
}
|
|
438
|
+
return {
|
|
439
|
+
...base,
|
|
440
|
+
host: chosen.host,
|
|
441
|
+
owner: chosen.owner,
|
|
442
|
+
repo: chosen.repo,
|
|
443
|
+
remote: chosen.name,
|
|
444
|
+
remoteUrl: redactRemoteUrl(chosen.fetchUrl || chosen.pushUrl),
|
|
445
|
+
remotes: remotes.map((remote) => remote.name),
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const resolveScopeUncached = async (directory) => {
|
|
450
|
+
const normalized = normalizeDirectory(directory);
|
|
451
|
+
if (!normalized) {
|
|
452
|
+
throw failed('Directory parameter is required.');
|
|
453
|
+
}
|
|
454
|
+
let stats = null;
|
|
455
|
+
try {
|
|
456
|
+
stats = await fsPromises.stat(normalized);
|
|
457
|
+
} catch {
|
|
458
|
+
throw failed('Directory not found.');
|
|
459
|
+
}
|
|
460
|
+
if (!stats.isDirectory()) {
|
|
461
|
+
throw failed('Specified path is not a directory.');
|
|
462
|
+
}
|
|
463
|
+
const topLevel = await readTopLevel(normalized);
|
|
464
|
+
const branch = await readBranch(topLevel || normalized);
|
|
465
|
+
const repositories = [];
|
|
466
|
+
let truncated = false;
|
|
467
|
+
if (topLevel) {
|
|
468
|
+
const trackingRemote = await readTrackingRemote(topLevel);
|
|
469
|
+
const containing = await mapLocalRepo(topLevel, 'containing', { rootForRelative: topLevel, trackingRemote });
|
|
470
|
+
repositories.push(containing);
|
|
471
|
+
const enclosingPath = await findEnclosingRepo(topLevel);
|
|
472
|
+
if (enclosingPath) {
|
|
473
|
+
const enclosing = await mapLocalRepo(enclosingPath, 'enclosing', { rootForRelative: topLevel, trackingRemote });
|
|
474
|
+
repositories.push(enclosing);
|
|
475
|
+
}
|
|
476
|
+
const nestedResult = await findNestedRepos(topLevel, { isRepoRoot: true });
|
|
477
|
+
truncated = nestedResult.truncated;
|
|
478
|
+
for (const nestedRepo of nestedResult.repos) {
|
|
479
|
+
if (pathApi.resolve(nestedRepo.path) === pathApi.resolve(topLevel)) continue;
|
|
480
|
+
const entry = await mapLocalRepo(nestedRepo.path, 'nested', { rootForRelative: topLevel, trackingRemote });
|
|
481
|
+
entry.submodule = nestedRepo.submodule;
|
|
482
|
+
repositories.push(entry);
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
const nestedResult = await findNestedRepos(normalized, { isRepoRoot: false });
|
|
486
|
+
truncated = nestedResult.truncated;
|
|
487
|
+
for (const nestedRepo of nestedResult.repos) {
|
|
488
|
+
const entry = await mapLocalRepo(nestedRepo.path, 'nested', { rootForRelative: normalized, trackingRemote: null });
|
|
489
|
+
entry.submodule = nestedRepo.submodule;
|
|
490
|
+
repositories.push(entry);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const containing = repositories.find((entry) => entry.kind === 'containing' && entry.host && isSupportedHost(entry.host));
|
|
494
|
+
return {
|
|
495
|
+
directory: normalized,
|
|
496
|
+
topLevel,
|
|
497
|
+
branch,
|
|
498
|
+
repositories,
|
|
499
|
+
truncated,
|
|
500
|
+
defaultSelection: containing ? formatRepoRef(containing) : null,
|
|
501
|
+
fetchedAt: now(),
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
const resolveScope = async (directory) => {
|
|
506
|
+
const normalized = normalizeDirectory(directory);
|
|
507
|
+
const key = `scope:${normalized}`;
|
|
508
|
+
const record = await scopeCache.getOrLoad(key, () => resolveScopeUncached(normalized));
|
|
509
|
+
return record.value;
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
const invalidate = (directory = null) => {
|
|
513
|
+
if (!directory) {
|
|
514
|
+
scopeCache.clear();
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
const normalized = normalizeDirectory(directory);
|
|
518
|
+
scopeCache.invalidate((key) => key === `scope:${normalized}`);
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Allow-list check: `repo` (`host/owner/name`) must equal a repository the
|
|
523
|
+
* resolver returned for this directory. Returns the matching entry or null.
|
|
524
|
+
*/
|
|
525
|
+
const matchAllowedRepo = (scope, repoParam) => {
|
|
526
|
+
const parsed = parseRepoRef(repoParam);
|
|
527
|
+
if (!parsed || !scope || !Array.isArray(scope.repositories)) return null;
|
|
528
|
+
const match = scope.repositories.find((entry) => entry.host
|
|
529
|
+
&& entry.host.toLowerCase() === parsed.host
|
|
530
|
+
&& entry.owner.toLowerCase() === parsed.owner.toLowerCase()
|
|
531
|
+
&& entry.repo.toLowerCase() === parsed.repo.toLowerCase());
|
|
532
|
+
return match || null;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
return {
|
|
536
|
+
resolveScope,
|
|
537
|
+
invalidate,
|
|
538
|
+
matchAllowedRepo,
|
|
539
|
+
parseRemoteUrl,
|
|
540
|
+
parseRepoRef,
|
|
541
|
+
normalizeDirectory,
|
|
542
|
+
_internals: { mapLocalRepo, findNestedRepos, filterIgnoredPaths, parseRemoteVerbose },
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Lazy fork/repository metadata via the API (`GET /repos/{owner}/{repo}`).
|
|
548
|
+
* Called only when a credential is available; results cached per fingerprint.
|
|
549
|
+
*/
|
|
550
|
+
export const createRepoInfoLoader = ({ client, now = Date.now } = {}) => {
|
|
551
|
+
if (!client || typeof client.request !== 'function') {
|
|
552
|
+
throw new Error('createRepoInfoLoader requires client.request');
|
|
553
|
+
}
|
|
554
|
+
const infoCache = createTtlCache({ ttlMs: REPO_INFO_TTL_MS, maxEntries: 200, now });
|
|
555
|
+
|
|
556
|
+
const getRepoInfo = async (credential, { host, owner, repo }) => {
|
|
557
|
+
const key = `repoinfo:${credential.fingerprint}:${String(host).toLowerCase()}/${String(owner).toLowerCase()}/${String(repo).toLowerCase()}`;
|
|
558
|
+
const record = await infoCache.getOrLoad(key, async () => {
|
|
559
|
+
const response = await client.request({
|
|
560
|
+
credential,
|
|
561
|
+
host,
|
|
562
|
+
method: 'GET',
|
|
563
|
+
path: `/repos/${owner}/${repo}`,
|
|
564
|
+
operation: 'repository lookup',
|
|
565
|
+
});
|
|
566
|
+
const body = response.body || {};
|
|
567
|
+
return {
|
|
568
|
+
defaultBranch: typeof body.default_branch === 'string' ? body.default_branch : null,
|
|
569
|
+
isFork: body.fork === true,
|
|
570
|
+
parent: body.parent && typeof body.parent.full_name === 'string'
|
|
571
|
+
? parseParentFullName(body.parent.full_name)
|
|
572
|
+
: null,
|
|
573
|
+
permissions: body.permissions && typeof body.permissions === 'object' ? { ...body.permissions } : null,
|
|
574
|
+
private: body.private === true,
|
|
575
|
+
};
|
|
576
|
+
});
|
|
577
|
+
return record.value;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
const invalidate = (credential = null, repoRef = null) => {
|
|
581
|
+
if (!credential && !repoRef) {
|
|
582
|
+
infoCache.clear();
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
infoCache.invalidate((key) => {
|
|
586
|
+
if (credential && !key.includes(credential.fingerprint)) return false;
|
|
587
|
+
if (repoRef) {
|
|
588
|
+
const normalized = `${String(repoRef.host).toLowerCase()}/${String(repoRef.owner).toLowerCase()}/${String(repoRef.repo).toLowerCase()}`;
|
|
589
|
+
if (!key.endsWith(normalized)) return false;
|
|
590
|
+
}
|
|
591
|
+
return true;
|
|
592
|
+
});
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
return { getRepoInfo, invalidate };
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Viewer repository permission derived from `GET /repos/{owner}/{repo}`.
|
|
600
|
+
*
|
|
601
|
+
* The repository lookup returns `permissions` (`admin`, `maintain`, `push`,
|
|
602
|
+
* `triage`, `pull`) for the authenticated user. Resolution reuses
|
|
603
|
+
* `getRepoInfo`, so it is cached per token fingerprint + repo with the
|
|
604
|
+
* same ~5 min TTL and keyed so an account switch naturally partitions it.
|
|
605
|
+
* Only successes are cached; a failed lookup resolves to
|
|
606
|
+
* `{ level: null, fallback: true }` so callers keep the current
|
|
607
|
+
* attempt-and-surface behavior and mark it instead of hiding controls.
|
|
608
|
+
*/
|
|
609
|
+
export const PERMISSION_LEVELS = ['admin', 'maintain', 'push', 'triage', 'pull'];
|
|
610
|
+
|
|
611
|
+
export const normalizePermissionLevel = (permissions) => {
|
|
612
|
+
if (!permissions || typeof permissions !== 'object') return null;
|
|
613
|
+
for (const level of PERMISSION_LEVELS) {
|
|
614
|
+
if (permissions[level] === true) return level;
|
|
615
|
+
}
|
|
616
|
+
return null;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Rank-ordered capabilities derived from a permission level. `canComment`
|
|
621
|
+
* follows read (`pull`) access on public or accessible repositories — the
|
|
622
|
+
* server only resolves permissions for allow-listed repos the viewer can
|
|
623
|
+
* reach, so any resolved level implies read.
|
|
624
|
+
*/
|
|
625
|
+
export const deriveCapabilities = (level) => {
|
|
626
|
+
const rank = PERMISSION_LEVELS.indexOf(level);
|
|
627
|
+
if (rank === -1) return { canPush: false, canTriage: false, canPull: false, canComment: false };
|
|
628
|
+
return {
|
|
629
|
+
canPush: rank <= PERMISSION_LEVELS.indexOf('push'),
|
|
630
|
+
canTriage: rank <= PERMISSION_LEVELS.indexOf('triage'),
|
|
631
|
+
canPull: true,
|
|
632
|
+
canComment: true,
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
/** Permissive capabilities used when permission resolution failed: every
|
|
637
|
+
* action stays enabled and the single attempt reports the server error. */
|
|
638
|
+
export const FALLBACK_CAPABILITIES = { canPush: true, canTriage: true, canPull: true, canComment: true };
|
|
639
|
+
|
|
640
|
+
export const getViewerPermission = async (getRepoInfo, credential, repoRef) => {
|
|
641
|
+
try {
|
|
642
|
+
const info = await getRepoInfo(credential, repoRef);
|
|
643
|
+
const level = normalizePermissionLevel(info?.permissions);
|
|
644
|
+
if (!level) return { level: null, fallback: true, capabilities: { ...FALLBACK_CAPABILITIES } };
|
|
645
|
+
return { level, fallback: false, capabilities: deriveCapabilities(level) };
|
|
646
|
+
} catch {
|
|
647
|
+
return { level: null, fallback: true, capabilities: { ...FALLBACK_CAPABILITIES } };
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Shared viewer-context loader (permission + login) for detail readers.
|
|
653
|
+
* `getPermissions` maps `(credential, repoRef)` to `{ permissions }` —
|
|
654
|
+
* domain services pass a direct repo lookup, the route layer passes the
|
|
655
|
+
* cached repo-info loader. An explicit `resolvePermission` override wins
|
|
656
|
+
* over the default; viewer-login failures resolve to null, never throw.
|
|
657
|
+
*/
|
|
658
|
+
export const buildViewerContextLoader = ({ getPermissions, resolveViewer = null, resolvePermission = null } = {}) => {
|
|
659
|
+
if (typeof getPermissions !== 'function' && typeof resolvePermission !== 'function') {
|
|
660
|
+
throw new Error('buildViewerContextLoader requires getPermissions or resolvePermission');
|
|
661
|
+
}
|
|
662
|
+
const fallbackResolvePermission = (credential, repoRef) => getViewerPermission(getPermissions, credential, repoRef);
|
|
663
|
+
return async (credential, repo) => {
|
|
664
|
+
const permissionLoader = typeof resolvePermission === 'function' ? resolvePermission : fallbackResolvePermission;
|
|
665
|
+
const [permission, viewerLogin] = await Promise.all([
|
|
666
|
+
permissionLoader(credential, repo),
|
|
667
|
+
(async () => {
|
|
668
|
+
if (typeof resolveViewer !== 'function') return null;
|
|
669
|
+
try {
|
|
670
|
+
return await resolveViewer(credential);
|
|
671
|
+
} catch {
|
|
672
|
+
return null;
|
|
673
|
+
}
|
|
674
|
+
})(),
|
|
675
|
+
]);
|
|
676
|
+
return {
|
|
677
|
+
viewerPermission: { level: permission?.level ?? null, fallback: permission?.fallback !== false },
|
|
678
|
+
capabilities: permission?.capabilities ?? { ...FALLBACK_CAPABILITIES },
|
|
679
|
+
viewerLogin: typeof viewerLogin === 'string' ? viewerLogin : null,
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
const parseParentFullName = (fullName) => {
|
|
685
|
+
const parts = String(fullName || '').split('/');
|
|
686
|
+
if (parts.length !== 2 || !isValidOwnerOrRepo(parts[0]) || !isValidOwnerOrRepo(parts[1])) return null;
|
|
687
|
+
return { owner: parts[0], repo: parts[1] };
|
|
688
|
+
};
|