@pi-chamber/web 1.0.3-rc.1 → 1.0.4-rc.1
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-DfZMQkXY.js +1 -0
- package/dist/assets/{DiffView-CXg8TAtI.js → DiffView-BjWUdbL5.js} +6 -6
- package/dist/assets/FileSaveConflictDialog-u5L4k_5k.js +3 -0
- package/dist/assets/FilesView-qP1ypN9J.js +6 -0
- package/dist/assets/GitHubDetailScaffold-zCKCy5OJ.js +11 -0
- package/dist/assets/GitHubLinkPicker-CwxKY3lN.js +1 -0
- package/dist/assets/GitHubListPrimitives-Ck3zllel.js +1 -0
- package/dist/assets/GitView-y2k2i4gR.js +9 -0
- package/dist/assets/IssuesSurface-HWgR87N3.js +7 -0
- package/dist/assets/JsonTreeView-DSuC4naV.js +1 -0
- package/dist/assets/{MarkdownRendererImpl-CeYMkg1A.js → MarkdownRendererImpl-CT5ln9em.js} +5 -5
- package/dist/assets/PatchDiff-DArTeWeK.js +1 -0
- package/dist/assets/PierreDiffViewer-DQKujzLb.js +134 -0
- package/dist/assets/PullRequestsSurface-Cfb1wSvC.js +2 -0
- package/dist/assets/SessionSwitcherContent-DEGJyZBl.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-cC9wVBH7.js +2 -0
- package/dist/assets/SessionUnreadDot-CELKNVIM.js +1 -0
- package/dist/assets/SettingsView-CZvRRgJe.js +6 -0
- package/dist/assets/SettingsWindow-CZM1dmVb.js +1 -0
- package/dist/assets/ToolOutputDialog-DClOSbJc.js +8 -0
- package/dist/assets/ToolPartDiffPreview-BaFiGUDE.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-CV_Cpmqu.js → VirtualizedFileDiff-D6KbvKc6.js} +3 -3
- package/dist/assets/Virtualizer-wpC51ZBQ.js +1 -0
- package/dist/assets/collapsible-DhV9d4dT.js +1 -0
- package/dist/assets/computeVirtualFileMetrics-CeMpF2xC.js +3 -0
- package/dist/assets/{contextFileOpenGuard-BA2pkQY_.js → contextFileOpenGuard-Ck5u_kAP.js} +1 -1
- package/dist/assets/gitStatusPredicates-DEBSqUNE.js +1 -0
- package/dist/assets/githubLink-DT7i2NlH.js +10 -0
- package/dist/assets/index-6IO1AcJI.js +10 -0
- package/dist/assets/index-BAmzAlNx.css +1 -0
- package/dist/assets/index-eDf4LKLY.js +1 -0
- package/dist/assets/main-BczEScAA.js +2 -0
- package/dist/assets/main-CHLNMYeJ.js +136 -0
- package/dist/assets/markdownCore-C4Gk5Zht.js +2 -0
- package/dist/assets/miniChat-Do3hE87Z.js +2 -0
- package/dist/assets/mobile-CTnihwfa.js +2 -0
- package/dist/assets/permissionStore-B9Hkrqny.js +1 -0
- package/dist/assets/pi-session-focus-preference-LDVCJ_YR.js +10 -0
- package/dist/assets/renderDiffWithHighlighter-CDsgOnkH.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-DSa3gYqR.js +2 -0
- package/dist/assets/renderFileWithHighlighter-TpKRyfCY.js +1 -0
- package/dist/assets/renderMobileApp-CPE-3uMl.js +11 -0
- package/dist/assets/runtimeEndpointReset-CzJfovWI.js +62 -0
- package/dist/assets/{runtimeSurface-BdndJV2m.js → runtimeSurface-DW_Ia4q3.js} +1 -1
- package/dist/assets/shell-CjFT_Tl9.js +1 -0
- package/dist/assets/sprite-HGQGInUp.js +6510 -0
- package/dist/assets/useAppFontEffects-CG3_yteE.js +212 -0
- package/dist/assets/{useFilesViewSearch-CI5Gy1cp.js → useFilesViewSearch-C_LzYIgD.js} +1 -1
- package/dist/assets/useGitHubRemoteSearch-DsxWOzKZ.js +1 -0
- package/dist/assets/useSwitcherItems-BmoCnS9W.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-Cdnmh4Xb.js → web-components-CH3-XV-n.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 +1 -1
- 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 +5 -3
- 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 +142 -0
- package/server/lib/pi/session-daemon/extension-theme.test.js +117 -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/session-daemon-extensions.test.js +322 -2
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +244 -0
- package/server/lib/pi/session-daemon/session-daemon.js +204 -33
- package/server/lib/pi/session-daemon/session-daemon.test.js +218 -0
- package/server/lib/pi/ui-settings-store.js +1 -1
- 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-CXjieF51.js +0 -1
- package/dist/assets/FileSaveConflictDialog-a-HOCgyP.js +0 -3
- package/dist/assets/FilesView-Dcd9ltOX.js +0 -6
- package/dist/assets/GitView-DF2nsuSA.js +0 -8
- package/dist/assets/JsonTreeView-BRU2mRTd.js +0 -1
- package/dist/assets/PatchDiff-kSTpjhu6.js +0 -1
- package/dist/assets/SessionSwitcherContent-BsXDFt24.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-D8fSObHr.js +0 -2
- package/dist/assets/SessionUnreadDot-BpsHyrri.js +0 -1
- package/dist/assets/SettingsView-OEl7QmXC.js +0 -6
- package/dist/assets/SettingsWindow-BMBCj_L_.js +0 -1
- package/dist/assets/ToolOutputDialog-KOVdmTqm.js +0 -8
- package/dist/assets/ToolPartDiffPreview-B9xuVvkm.js +0 -1
- package/dist/assets/Virtualizer-BSHVMKgK.js +0 -1
- package/dist/assets/collapsible-BH1vXEAI.js +0 -1
- package/dist/assets/computeVirtualFileMetrics-yHZbtf5H.js +0 -3
- package/dist/assets/gitStatusPredicates-CpGQLvMK.js +0 -134
- package/dist/assets/index-5fyXnZFi.css +0 -1
- package/dist/assets/index-C-sV_9sb.js +0 -8
- package/dist/assets/index-D_FGGnQQ.js +0 -1
- package/dist/assets/isDiffPlainText-BNyusJZz.js +0 -1
- package/dist/assets/isFilePlainText-CMAUe7qD.js +0 -1
- package/dist/assets/main-BMLgZ5yn.js +0 -2
- package/dist/assets/main-DNq1n9F_.js +0 -135
- package/dist/assets/markdownCore-CZWcaNr2.js +0 -3
- package/dist/assets/miniChat-B2AgUZqL.js +0 -2
- package/dist/assets/mobile-BsGiRUUg.js +0 -2
- package/dist/assets/permissionStore-iKN1K2_x.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-UV9dnnbf.js +0 -2
- package/dist/assets/renderMobileApp-BMifduGA.js +0 -11
- package/dist/assets/runtimeEndpointReset-CkvC02dQ.js +0 -53
- package/dist/assets/useAppFontEffects-CclUs9KY.js +0 -6722
- package/dist/assets/usePushVisibilityBeacon-aDmGZrTW.js +0 -10
- package/dist/assets/useSwitcherItems-BZKyNjhp.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-C6LBD7qA.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,151 @@
|
|
|
1
|
+
/** GitHub error taxonomy (§5.1). See DOCUMENTATION.md for kinds and HTTP mapping. */
|
|
2
|
+
|
|
3
|
+
export const UNAVAILABLE_REASONS = Object.freeze([
|
|
4
|
+
'gh-missing',
|
|
5
|
+
'gh-outdated',
|
|
6
|
+
'gh-unauthenticated',
|
|
7
|
+
'not-github',
|
|
8
|
+
'no-repository',
|
|
9
|
+
'no-access',
|
|
10
|
+
'scope-missing',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export class GitHubIntegrationError extends Error {
|
|
14
|
+
constructor(kind, details = {}) {
|
|
15
|
+
super(typeof details.message === 'string' && details.message ? details.message : kind);
|
|
16
|
+
this.name = 'GitHubIntegrationError';
|
|
17
|
+
this.kind = kind;
|
|
18
|
+
if (kind === 'unavailable') {
|
|
19
|
+
this.reason = details.reason;
|
|
20
|
+
if (Array.isArray(details.scopes)) this.scopes = [...details.scopes];
|
|
21
|
+
if (typeof details.host === 'string') this.host = details.host;
|
|
22
|
+
} else if (kind === 'rate-limited') {
|
|
23
|
+
this.retryAt = details.retryAt;
|
|
24
|
+
}
|
|
25
|
+
if (details.stale !== undefined) this.stale = details.stale;
|
|
26
|
+
if (details.fetchedAt !== undefined) this.fetchedAt = details.fetchedAt;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const unavailable = (reason, extra = {}) => {
|
|
31
|
+
if (!UNAVAILABLE_REASONS.includes(reason)) {
|
|
32
|
+
throw new Error(`Unknown unavailable reason: ${reason}`);
|
|
33
|
+
}
|
|
34
|
+
const message = typeof extra.message === 'string' && extra.message
|
|
35
|
+
? extra.message
|
|
36
|
+
: defaultUnavailableMessage(reason, extra);
|
|
37
|
+
return new GitHubIntegrationError('unavailable', { ...extra, reason, message });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const rateLimited = (retryAt, extra = {}) => new GitHubIntegrationError('rate-limited', {
|
|
41
|
+
...extra,
|
|
42
|
+
retryAt: Number.isFinite(retryAt) ? retryAt : Date.now() + 60_000,
|
|
43
|
+
message: 'GitHub rate limit reached. Try again shortly.',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const failed = (message, extra = {}) => new GitHubIntegrationError('failed', {
|
|
47
|
+
...extra,
|
|
48
|
+
message: typeof message === 'string' && message ? message : 'GitHub request failed',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Client input validation failure. Same `{ kind: 'failed' }` body shape, but
|
|
53
|
+
* mapped to HTTP 400 so callers can distinguish bad input from upstream
|
|
54
|
+
* failures. Used for malformed params and payloads, never for GitHub
|
|
55
|
+
* API responses.
|
|
56
|
+
*/
|
|
57
|
+
export const inputError = (message) => {
|
|
58
|
+
const error = failed(message);
|
|
59
|
+
error.statusCode = 400;
|
|
60
|
+
return error;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const defaultUnavailableMessage = (reason, extra = {}) => {
|
|
64
|
+
switch (reason) {
|
|
65
|
+
case 'gh-missing':
|
|
66
|
+
return 'GitHub CLI (gh) is not installed on the machine running PiChamber.';
|
|
67
|
+
case 'gh-outdated':
|
|
68
|
+
return `GitHub CLI (gh) is too old${extra.version ? ` (found ${extra.version})` : ''}. Update gh and try again.`;
|
|
69
|
+
case 'gh-unauthenticated':
|
|
70
|
+
return 'GitHub CLI is not signed in. Run `gh auth login` on the machine running PiChamber, then check again.';
|
|
71
|
+
case 'not-github':
|
|
72
|
+
return 'This repository does not use a github.com remote.';
|
|
73
|
+
case 'no-repository':
|
|
74
|
+
return 'This directory is not inside a git repository.';
|
|
75
|
+
case 'no-access':
|
|
76
|
+
return 'The signed-in GitHub account cannot access this repository.';
|
|
77
|
+
case 'scope-missing':
|
|
78
|
+
return `The GitHub token is missing required scope${extra.scopes?.length ? `: ${extra.scopes.join(', ')}` : ''}.`;
|
|
79
|
+
default:
|
|
80
|
+
return 'GitHub is unavailable.';
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const isGitHubIntegrationError = (error) => error instanceof GitHubIntegrationError;
|
|
85
|
+
|
|
86
|
+
export const toHttpStatus = (error) => {
|
|
87
|
+
if (!isGitHubIntegrationError(error)) return 502;
|
|
88
|
+
if (typeof error.statusCode === 'number') return error.statusCode;
|
|
89
|
+
if (error.kind === 'rate-limited') return 429;
|
|
90
|
+
if (error.kind === 'failed') return 502;
|
|
91
|
+
switch (error.reason) {
|
|
92
|
+
case 'scope-missing':
|
|
93
|
+
return 403;
|
|
94
|
+
case 'not-github':
|
|
95
|
+
case 'no-repository':
|
|
96
|
+
case 'no-access':
|
|
97
|
+
return 404;
|
|
98
|
+
case 'gh-missing':
|
|
99
|
+
case 'gh-outdated':
|
|
100
|
+
case 'gh-unauthenticated':
|
|
101
|
+
default:
|
|
102
|
+
return 503;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const toErrorBody = (error) => {
|
|
107
|
+
if (!isGitHubIntegrationError(error)) {
|
|
108
|
+
return { error: { kind: 'failed', message: redactSecrets(String(error?.message || 'GitHub request failed'), []) } };
|
|
109
|
+
}
|
|
110
|
+
if (error.kind === 'unavailable') {
|
|
111
|
+
const body = { error: { kind: 'unavailable', reason: error.reason } };
|
|
112
|
+
if (Array.isArray(error.scopes)) body.error.scopes = [...error.scopes];
|
|
113
|
+
if (typeof error.host === 'string') body.error.host = error.host;
|
|
114
|
+
return body;
|
|
115
|
+
}
|
|
116
|
+
if (error.kind === 'rate-limited') {
|
|
117
|
+
return { error: { kind: 'rate-limited', retryAt: error.retryAt } };
|
|
118
|
+
}
|
|
119
|
+
return { error: { kind: 'failed', message: String(error.message || 'GitHub request failed') } };
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Replace every occurrence of a secret with `[redacted]`. Used before any
|
|
124
|
+
* string derived from credentials-adjacent data crosses into logs, errors,
|
|
125
|
+
* or HTTP responses. Secrets are never logged in full — only compared.
|
|
126
|
+
*/
|
|
127
|
+
export const redactSecrets = (text, secrets) => {
|
|
128
|
+
let out = typeof text === 'string' ? text : String(text ?? '');
|
|
129
|
+
for (const secret of Array.isArray(secrets) ? secrets : [secrets]) {
|
|
130
|
+
if (typeof secret !== 'string' || secret.length < 4) continue;
|
|
131
|
+
out = out.split(secret).join('[redacted]');
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const containsSecret = (haystack, secrets) => {
|
|
137
|
+
const text = typeof haystack === 'string' ? haystack : JSON.stringify(haystack ?? '');
|
|
138
|
+
const list = Array.isArray(secrets) ? secrets : [secrets];
|
|
139
|
+
return list.some((secret) => typeof secret === 'string' && secret.length >= 4 && text.includes(secret));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Map a failed sub-read to a section error body. A failed section keeps its
|
|
144
|
+
* array as `[]` but is never authoritative empty — callers render the error.
|
|
145
|
+
*/
|
|
146
|
+
export const toSectionError = (error) => {
|
|
147
|
+
try {
|
|
148
|
+
if (isGitHubIntegrationError(error)) return toErrorBody(error).error;
|
|
149
|
+
} catch { /* fall through to generic failed */ }
|
|
150
|
+
return { kind: 'failed', message: 'GitHub request failed' };
|
|
151
|
+
};
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/** gh CLI discovery, version gate, auth status, token reads (§3.1). See DOCUMENTATION.md. */
|
|
2
|
+
|
|
3
|
+
import { execFile } from 'node:child_process';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { findExecutableOnPath, getExecutableSearchDirectories } from '../tunnels/executable-search.js';
|
|
6
|
+
import { unavailable } from './errors.js';
|
|
7
|
+
|
|
8
|
+
/** Floor based on the flags used: `gh auth token --hostname` + plain `gh auth status`. */
|
|
9
|
+
export const MIN_GH_VERSION = '2.4.0';
|
|
10
|
+
export const TOKEN_CACHE_TTL_MS = 30_000;
|
|
11
|
+
const LOGIN_SHELL_PATH_TIMEOUT_MS = 2500;
|
|
12
|
+
const LOGIN_SHELL_PATH_TTL_MS = 5 * 60_000;
|
|
13
|
+
const VERSION_TIMEOUT_MS = 8000;
|
|
14
|
+
const STATUS_TIMEOUT_MS = 8000;
|
|
15
|
+
const TOKEN_TIMEOUT_MS = 5000;
|
|
16
|
+
|
|
17
|
+
const defaultExecFileAsync = promisify(execFile);
|
|
18
|
+
|
|
19
|
+
const parseVersion = (text) => {
|
|
20
|
+
const match = /gh version (\d+)\.(\d+)\.(\d+)/i.exec(String(text || ''));
|
|
21
|
+
if (!match) return null;
|
|
22
|
+
return { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]) };
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const formatVersion = (version) => (version ? `${version.major}.${version.minor}.${version.patch}` : 'unknown');
|
|
26
|
+
|
|
27
|
+
export const compareVersions = (left, right) => {
|
|
28
|
+
for (const key of ['major', 'minor', 'patch']) {
|
|
29
|
+
if (left[key] !== right[key]) return left[key] < right[key] ? -1 : 1;
|
|
30
|
+
}
|
|
31
|
+
return 0;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const parseMinVersion = (text = MIN_GH_VERSION) => {
|
|
35
|
+
const [major = 0, minor = 0, patch = 0] = String(text).split('.').map((part) => Number.parseInt(part, 10) || 0);
|
|
36
|
+
return { major, minor, patch };
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const isUnknownFlagFailure = (error) => /unknown flag/i.test(String(error?.stderr || error?.message || ''));
|
|
40
|
+
|
|
41
|
+
const parseScopesLine = (line) => {
|
|
42
|
+
const match = /token scopes?:\s*(.*)$/i.exec(line);
|
|
43
|
+
if (!match) return null;
|
|
44
|
+
const raw = match[1].trim().replace(/^['"]|['"]$/g, '');
|
|
45
|
+
if (!raw || /none/i.test(raw)) return [];
|
|
46
|
+
return raw.split(',').map((scope) => scope.trim().replace(/^['"]|['"]$/g, '')).filter(Boolean);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Parse plain `gh auth status` output into per-host entries. Handles both the
|
|
51
|
+
* all-hosts shape and the `--hostname <host>` shape (identical block).
|
|
52
|
+
*/
|
|
53
|
+
export const parsePlainAuthStatus = (text) => {
|
|
54
|
+
const hosts = [];
|
|
55
|
+
let current = null;
|
|
56
|
+
const flush = () => {
|
|
57
|
+
if (current) hosts.push(current);
|
|
58
|
+
current = null;
|
|
59
|
+
};
|
|
60
|
+
for (const rawLine of String(text || '').split('\n')) {
|
|
61
|
+
const line = rawLine.replace(/\r$/, '');
|
|
62
|
+
if (!line.trim()) continue;
|
|
63
|
+
if (/^[^\s]/.test(line)) {
|
|
64
|
+
// A non-indented line starts a host block (`github.com`).
|
|
65
|
+
flush();
|
|
66
|
+
const host = line.trim();
|
|
67
|
+
if (/^[A-Za-z0-9.-]+(?::\d+)?$/.test(host)) {
|
|
68
|
+
current = { host: host.toLowerCase(), authenticated: false, login: null, scopes: [] };
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (!current) continue;
|
|
73
|
+
const trimmed = line.trim();
|
|
74
|
+
if (/you are not logged in/i.test(trimmed)) {
|
|
75
|
+
current.authenticated = false;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const loggedIn = /logged in to \S+ account (\S+)/i.exec(trimmed);
|
|
79
|
+
if (loggedIn || /^[✓✔]/.test(trimmed)) {
|
|
80
|
+
current.authenticated = true;
|
|
81
|
+
if (loggedIn) current.login = loggedIn[1].trim() || null;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const scopes = parseScopesLine(trimmed);
|
|
85
|
+
if (scopes) {
|
|
86
|
+
current.scopes = scopes;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
flush();
|
|
91
|
+
return hosts;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const parseJsonAuthStatus = (text) => {
|
|
95
|
+
// Newer `gh auth status --json hosts` shapes:
|
|
96
|
+
// `{ "hosts": { "github.com": { "user": "...", "token": "...", ... } } }`
|
|
97
|
+
// or `{ "hosts": [ { "hostname": "...", "user": "..." } ] }`.
|
|
98
|
+
const parsed = JSON.parse(String(text || ''));
|
|
99
|
+
const raw = parsed?.hosts;
|
|
100
|
+
const entries = Array.isArray(raw)
|
|
101
|
+
? raw
|
|
102
|
+
: (raw && typeof raw === 'object' ? Object.entries(raw).map(([hostname, info]) => ({ hostname, ...(info || {}) })) : []);
|
|
103
|
+
const hosts = [];
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
const host = String(entry.hostname || entry.host || '').trim().toLowerCase();
|
|
106
|
+
if (!host) continue;
|
|
107
|
+
const login = typeof entry.user === 'string' && entry.user ? entry.user : null;
|
|
108
|
+
hosts.push({
|
|
109
|
+
host,
|
|
110
|
+
authenticated: Boolean(login || entry.active === true),
|
|
111
|
+
login,
|
|
112
|
+
scopes: Array.isArray(entry.tokenScopes) ? entry.tokenScopes.filter((scope) => typeof scope === 'string') : [],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return hosts;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const createGhCli = ({
|
|
119
|
+
execFileAsync = defaultExecFileAsync,
|
|
120
|
+
env = process.env,
|
|
121
|
+
platform = process.platform,
|
|
122
|
+
now = Date.now,
|
|
123
|
+
minVersion = MIN_GH_VERSION,
|
|
124
|
+
} = {}) => {
|
|
125
|
+
let cachedBinary = null;
|
|
126
|
+
let cachedLoginPath = null;
|
|
127
|
+
let loginPathExpiresAt = 0;
|
|
128
|
+
// Process-lifetime: the gh binary and its version cannot change under us.
|
|
129
|
+
let cachedVersion = null;
|
|
130
|
+
// Which `gh auth status` flavor works: null = unprobed, true = --json,
|
|
131
|
+
// false = plain text (older gh, e.g. 2.46, rejects --json). Remembering
|
|
132
|
+
// avoids paying one failed spawn on every status call.
|
|
133
|
+
let jsonFlavorWorks = null;
|
|
134
|
+
const tokenCache = new Map();
|
|
135
|
+
|
|
136
|
+
const runGh = async (args, { timeout }) => {
|
|
137
|
+
const binary = await resolveGhBinary();
|
|
138
|
+
if (!binary) {
|
|
139
|
+
throw unavailable('gh-missing');
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const result = await execFileAsync(binary, args, {
|
|
143
|
+
timeout,
|
|
144
|
+
windowsHide: true,
|
|
145
|
+
maxBuffer: 256 * 1024,
|
|
146
|
+
env: { ...env },
|
|
147
|
+
});
|
|
148
|
+
return String(result?.stdout || '');
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (error?.killed) {
|
|
151
|
+
throw unavailable('gh-unauthenticated', { message: 'GitHub CLI timed out. Check that gh works on the server machine.' });
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const resolveLoginShellPath = async () => {
|
|
158
|
+
const at = now();
|
|
159
|
+
if (cachedLoginPath && loginPathExpiresAt > at) return cachedLoginPath;
|
|
160
|
+
const shell = typeof env.SHELL === 'string' && env.SHELL.trim()
|
|
161
|
+
? env.SHELL.trim()
|
|
162
|
+
: (platform === 'win32' ? null : '/bin/sh');
|
|
163
|
+
if (!shell) return '';
|
|
164
|
+
try {
|
|
165
|
+
const result = await execFileAsync(shell, ['-l', '-c', 'printf %s "$PATH"'], {
|
|
166
|
+
timeout: LOGIN_SHELL_PATH_TIMEOUT_MS,
|
|
167
|
+
windowsHide: true,
|
|
168
|
+
maxBuffer: 64 * 1024,
|
|
169
|
+
env: { ...env },
|
|
170
|
+
});
|
|
171
|
+
const probed = String(result?.stdout || '').trim();
|
|
172
|
+
// Sanity: a PATH is a delimiter-joined list of absolute dirs.
|
|
173
|
+
if (probed && /[/\\]/.test(probed) && probed.length < 32768) {
|
|
174
|
+
cachedLoginPath = probed;
|
|
175
|
+
loginPathExpiresAt = at + LOGIN_SHELL_PATH_TTL_MS;
|
|
176
|
+
return probed;
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
// Fall through to the process PATH.
|
|
180
|
+
}
|
|
181
|
+
return '';
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const resolveGhBinary = async () => {
|
|
185
|
+
if (cachedBinary) return cachedBinary;
|
|
186
|
+
const explicit = [env.GH_BINARY, env.PICHAMBER_GH_BINARY]
|
|
187
|
+
.map((value) => (typeof value === 'string' ? value.trim() : ''))
|
|
188
|
+
.filter(Boolean);
|
|
189
|
+
for (const candidate of explicit) {
|
|
190
|
+
try {
|
|
191
|
+
const probe = await execFileAsync(candidate, ['--version'], { timeout: VERSION_TIMEOUT_MS, windowsHide: true, maxBuffer: 64 * 1024 });
|
|
192
|
+
// The probe already ran `gh --version`: keep its output so the
|
|
193
|
+
// version gate below does not pay for a second spawn.
|
|
194
|
+
cachedVersion = parseVersion(probe?.stdout) || cachedVersion;
|
|
195
|
+
cachedBinary = candidate;
|
|
196
|
+
return cachedBinary;
|
|
197
|
+
} catch {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const command = platform === 'win32' ? 'gh.exe' : 'gh';
|
|
202
|
+
const loginPath = platform === 'win32' ? '' : await resolveLoginShellPath();
|
|
203
|
+
if (loginPath) {
|
|
204
|
+
const delimiter = platform === 'win32' ? ';' : ':';
|
|
205
|
+
const loginEnv = { ...env, PATH: loginPath, Path: loginPath };
|
|
206
|
+
const found = findExecutableOnPath(command, { env: loginEnv, platform });
|
|
207
|
+
if (found) {
|
|
208
|
+
cachedBinary = found;
|
|
209
|
+
return cachedBinary;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const searchDirs = getExecutableSearchDirectories({ env, platform });
|
|
213
|
+
if (searchDirs.length > 0) {
|
|
214
|
+
const found = findExecutableOnPath(command, { env, platform });
|
|
215
|
+
if (found) {
|
|
216
|
+
cachedBinary = found;
|
|
217
|
+
return cachedBinary;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const getVersion = async () => {
|
|
224
|
+
if (cachedVersion) return cachedVersion;
|
|
225
|
+
// Resolving the binary first lets the explicit-binary probe (which
|
|
226
|
+
// already runs `gh --version`) satisfy the version read with no spawn.
|
|
227
|
+
await resolveGhBinary();
|
|
228
|
+
if (cachedVersion) return cachedVersion;
|
|
229
|
+
const stdout = await runGh(['--version'], { timeout: VERSION_TIMEOUT_MS });
|
|
230
|
+
const version = parseVersion(stdout);
|
|
231
|
+
if (!version) {
|
|
232
|
+
throw unavailable('gh-missing', { message: 'GitHub CLI (gh) did not report a version.' });
|
|
233
|
+
}
|
|
234
|
+
cachedVersion = version;
|
|
235
|
+
return version;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const assertVersion = async () => {
|
|
239
|
+
const version = await getVersion();
|
|
240
|
+
if (compareVersions(version, parseMinVersion(minVersion)) < 0) {
|
|
241
|
+
throw unavailable('gh-outdated', { version: formatVersion(version) });
|
|
242
|
+
}
|
|
243
|
+
return version;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const getAuthState = async ({ hostname = null } = {}) => {
|
|
247
|
+
await assertVersion();
|
|
248
|
+
const binary = await resolveGhBinary();
|
|
249
|
+
// Prefer machine-readable output on CLIs that support it. Once the
|
|
250
|
+
// flavor is known, go straight to it instead of paying a failed spawn.
|
|
251
|
+
if (jsonFlavorWorks !== false) {
|
|
252
|
+
try {
|
|
253
|
+
const args = hostname ? ['auth', 'status', '--json', 'hosts', '--hostname', hostname] : ['auth', 'status', '--json', 'hosts'];
|
|
254
|
+
const result = await execFileAsync(binary, args, {
|
|
255
|
+
timeout: STATUS_TIMEOUT_MS,
|
|
256
|
+
windowsHide: true,
|
|
257
|
+
maxBuffer: 256 * 1024,
|
|
258
|
+
env: { ...env },
|
|
259
|
+
});
|
|
260
|
+
jsonFlavorWorks = true;
|
|
261
|
+
return { hosts: parseJsonAuthStatus(result?.stdout), source: 'json' };
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (isUnknownFlagFailure(error)) {
|
|
264
|
+
jsonFlavorWorks = false;
|
|
265
|
+
} else {
|
|
266
|
+
// `gh auth status` exits non-zero when not logged in; the plain text
|
|
267
|
+
// still describes state, so fall through to plain parsing.
|
|
268
|
+
if (error?.killed) {
|
|
269
|
+
throw unavailable('gh-unauthenticated', { message: 'GitHub CLI timed out. Check that gh works on the server machine.' });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const args = hostname ? ['auth', 'status', '--hostname', hostname] : ['auth', 'status'];
|
|
276
|
+
const result = await execFileAsync(binary, args, {
|
|
277
|
+
timeout: STATUS_TIMEOUT_MS,
|
|
278
|
+
windowsHide: true,
|
|
279
|
+
maxBuffer: 256 * 1024,
|
|
280
|
+
env: { ...env },
|
|
281
|
+
});
|
|
282
|
+
const combined = `${result?.stdout || ''}\n${result?.stderr || ''}`;
|
|
283
|
+
return { hosts: parsePlainAuthStatus(combined), source: 'text' };
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (error?.killed) {
|
|
286
|
+
throw unavailable('gh-unauthenticated', { message: 'GitHub CLI timed out. Check that gh works on the server machine.' });
|
|
287
|
+
}
|
|
288
|
+
const combined = `${error?.stdout || ''}\n${error?.stderr || ''}`;
|
|
289
|
+
const hosts = parsePlainAuthStatus(combined);
|
|
290
|
+
if (hosts.length > 0) return { hosts, source: 'text' };
|
|
291
|
+
throw unavailable('gh-unauthenticated');
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const getToken = async (host) => {
|
|
296
|
+
const normalizedHost = String(host || '').trim().toLowerCase();
|
|
297
|
+
if (!normalizedHost) throw unavailable('not-github');
|
|
298
|
+
const cached = tokenCache.get(normalizedHost);
|
|
299
|
+
if (cached && cached.expiresAt > now()) return cached.token;
|
|
300
|
+
await assertVersion();
|
|
301
|
+
let stdout = '';
|
|
302
|
+
try {
|
|
303
|
+
stdout = await runGh(['auth', 'token', '--hostname', normalizedHost], { timeout: TOKEN_TIMEOUT_MS });
|
|
304
|
+
} catch (error) {
|
|
305
|
+
if (error?.kind === 'unavailable') throw error;
|
|
306
|
+
throw unavailable('gh-unauthenticated');
|
|
307
|
+
}
|
|
308
|
+
const token = stdout.trim().split(/\s+/)[0] || '';
|
|
309
|
+
if (!token) {
|
|
310
|
+
throw unavailable('gh-unauthenticated');
|
|
311
|
+
}
|
|
312
|
+
tokenCache.set(normalizedHost, { token, expiresAt: now() + TOKEN_CACHE_TTL_MS });
|
|
313
|
+
// Bound the host-keyed cache.
|
|
314
|
+
while (tokenCache.size > 50) {
|
|
315
|
+
const oldest = tokenCache.keys().next();
|
|
316
|
+
if (oldest.done) break;
|
|
317
|
+
tokenCache.delete(oldest.value);
|
|
318
|
+
}
|
|
319
|
+
return token;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const clearTokenCache = (host = null) => {
|
|
323
|
+
if (host) tokenCache.delete(String(host).trim().toLowerCase());
|
|
324
|
+
else tokenCache.clear();
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
return {
|
|
328
|
+
resolveGhBinary,
|
|
329
|
+
getVersion,
|
|
330
|
+
assertVersion,
|
|
331
|
+
getAuthState,
|
|
332
|
+
getToken,
|
|
333
|
+
clearTokenCache,
|
|
334
|
+
_internals: { parsePlainAuthStatus, parseJsonAuthStatus, parseVersion, compareVersions },
|
|
335
|
+
};
|
|
336
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** GitHub module entrypoint. See DOCUMENTATION.md. */
|
|
2
|
+
|
|
3
|
+
import { createChecksService } from './checks.js';
|
|
4
|
+
import { createGitHubClient } from './client.js';
|
|
5
|
+
import { createContextBuilder } from './context.js';
|
|
6
|
+
import { createCredentialStore } from './credential.js';
|
|
7
|
+
import { createGhCli } from './gh-cli.js';
|
|
8
|
+
import { createIssuesService } from './issues.js';
|
|
9
|
+
import { createPullsService } from './pulls.js';
|
|
10
|
+
import { createTemplatesService } from './templates.js';
|
|
11
|
+
import { createRepoInfoLoader, createRepoScopeResolver } from './repo-scope.js';
|
|
12
|
+
import { createGitHubRoutes, registerGitHubRoutes } from './routes.js';
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
createGitHubRoutes,
|
|
16
|
+
registerGitHubRoutes,
|
|
17
|
+
createGhCli,
|
|
18
|
+
createCredentialStore,
|
|
19
|
+
createGitHubClient,
|
|
20
|
+
createRepoScopeResolver,
|
|
21
|
+
createRepoInfoLoader,
|
|
22
|
+
createPullsService,
|
|
23
|
+
createIssuesService,
|
|
24
|
+
createChecksService,
|
|
25
|
+
createTemplatesService,
|
|
26
|
+
createContextBuilder,
|
|
27
|
+
};
|