@pi-chamber/web 1.0.5 → 1.0.6-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-CrKjR8CR.js → DiagramView-BdDt1SI7.js} +1 -1
- package/dist/assets/DiffView-Dk3VIX9E.js +18 -0
- package/dist/assets/FileSaveConflictDialog-DpyPjMH1.js +3 -0
- package/dist/assets/{FilesView-BRR3N7UA.js → FilesView-CumrwioK.js} +3 -3
- package/dist/assets/{GitHubDetailScaffold-C1UHuETI.js → GitHubDetailScaffold-CW2ZqU0Y.js} +3 -3
- package/dist/assets/{GitHubLinkPicker-B0O3Vapu.js → GitHubLinkPicker-BjJNQ7Ap.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-DvQDU--z.js → GitHubListPrimitives-BcB-cCTs.js} +1 -1
- package/dist/assets/{GitView-wAscrRhO.js → GitView-BoCaX5AO.js} +4 -4
- package/dist/assets/{IssuesSurface-mh50UUQ8.js → IssuesSurface-CDZENHrE.js} +3 -3
- package/dist/assets/{JsonTreeView-BfErTllU.js → JsonTreeView-DpCgOUXg.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-SXAK4uOu.js → MarkdownRendererImpl-BkT5TUWF.js} +2 -2
- package/dist/assets/{PatchDiff-CHr79sJ6.js → PatchDiff-Dcr3EQgA.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CGpKcLro.js → PierreDiffViewer-o_Edh6ny.js} +3 -3
- package/dist/assets/PullRequestsSurface-eSXl6sef.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DEAw6v12.js → SessionSwitcherContent-Dm30bfpn.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-CFj9VWSa.js +2 -0
- package/dist/assets/SessionUnreadDot-CHlK2awX.js +1 -0
- package/dist/assets/SettingsView-CcHRUyev.js +6 -0
- package/dist/assets/{SettingsWindow-BiY5FmhZ.js → SettingsWindow-BMzUErrM.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-BMITjK4e.js → StickyHorizontalScrollbar-p7EbL2-E.js} +2 -2
- package/dist/assets/{ToolOutputDialog-B3RRLhR3.js → ToolOutputDialog-QC8IoeBH.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-D9m_vrht.js → ToolPartDiffPreview-BigGwtul.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-B8lhZGLu.js → VirtualizedFileDiff-DvLCd7Qq.js} +4 -4
- package/dist/assets/{Virtualizer-DP6HbEeC.js → Virtualizer-DNJrJKVb.js} +1 -1
- package/dist/assets/{appThemeRegistry-gegrE2dq.js → appThemeRegistry-Ca8eGRB9.js} +1 -1
- package/dist/assets/{collapsible-9MJx4VhA.js → collapsible-0yfy07W2.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-Bjhk2CQS.js → computeVirtualFileMetrics-aX6tjjqv.js} +2 -2
- package/dist/assets/{contextFileOpenGuard-CsF5Boky.js → contextFileOpenGuard-CZKJuHxf.js} +1 -1
- package/dist/assets/{document-attachments-BslE4Ns7.js → document-attachments-CZl9rK1z.js} +5 -5
- package/dist/assets/{gitStatusPredicates-B3Zxud6E.js → gitStatusPredicates-3i8CcYWJ.js} +1 -1
- package/dist/assets/{githubLink-CbGYxsIq.js → githubLink-BvevcNay.js} +5 -5
- package/dist/assets/index-BMdbHCFt.js +1 -0
- package/dist/assets/{index-D4n3TVp2.js → index-C2ISrmRR.js} +10 -10
- package/dist/assets/index-DgwThEwf.css +1 -0
- package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
- package/dist/assets/main-BM-b2y8p.js +2 -0
- package/dist/assets/main-BXZ561E3.js +137 -0
- package/dist/assets/{markdown-shiki.worker-DnvH1S1x.js → markdown-shiki.worker-BVA5NZBT.js} +5 -5
- package/dist/assets/markdownCore-DbS8DkKw.js +2 -0
- package/dist/assets/miniChat-DO3DW6kJ.js +2 -0
- package/dist/assets/mobile-BgWLkut6.js +2 -0
- package/dist/assets/{nativeFileSave-BJsGPh58.js → nativeFileSave-Bhafll_7.js} +1 -1
- package/dist/assets/nsis-LY0VT_u5.js +1 -0
- package/dist/assets/permissionStore-zIpxq9Pq.js +1 -0
- package/dist/assets/pi-session-focus-preference-ChYVctYk.js +9 -0
- package/dist/assets/{registerCustomTheme-DmolaWWZ.js → registerCustomTheme-C-h6lsYW.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-BhMEWmHn.js → renderDiffWithHighlighter-xlvSvnTf.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-CgVqxKDm.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-DUGluXlw.js → renderFileWithHighlighter-CCoYfC-t.js} +1 -1
- package/dist/assets/renderMobileApp-CoY1tsk5.js +11 -0
- package/dist/assets/ruby-BK5aLJev.js +1 -0
- package/dist/assets/runtimeEndpointReset-fozcAShH.js +62 -0
- package/dist/assets/runtimeSurface-CJN1oo_1.js +1 -0
- package/dist/assets/themeResolver-DrfmQi8i.js +1 -0
- package/dist/assets/useAppFontEffects-D_gtiA95.js +215 -0
- package/dist/assets/useFilesViewSearch-BUxcZj60.js +7 -0
- package/dist/assets/{useGitHubRemoteSearch-DYoLQ4ro.js → useGitHubRemoteSearch-CevR5iLf.js} +1 -1
- package/dist/assets/{useSwitcherItems-BS6E199F.js → useSwitcherItems-kaRkXggX.js} +1 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BLsm9T1Y.js +1 -0
- package/dist/assets/vendor-base-ui-C7vVMZTg.js +1 -0
- package/dist/assets/{vendor-beautiful-mermaid-DApbjBp2.js → vendor-beautiful-mermaid-b48gT2g0.js} +1 -1
- package/dist/assets/vendor-boot-CoTxysn6.js +65 -0
- package/dist/assets/{vendor-capacitor-app-BaupizkW.js → vendor-capacitor-app-NX6DULfp.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-9BVxykO7.js → vendor-capacitor-keyboard-DJD81I9f.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-BsrUwiaA.js → vendor-capacitor-status-bar-DV24OoQV.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-qsuH4Dh-.js +1 -0
- package/dist/assets/vendor-codemirror-lang-angular-ZHWyBf7j.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-pCTOmv-k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-2bFuyM70.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-go-Crwca_X7.js → vendor-codemirror-lang-go-DrG_c7D7.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-html-BV8lrR8v.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-DrsvH6T2.js +1 -0
- package/dist/assets/vendor-codemirror-lang-javascript-Dkzl3s07.js +13 -0
- package/dist/assets/vendor-codemirror-lang-jinja-8Nn3bnoP.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-CsdmtHhi.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-DJuZ4cZe.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-D2RO-Pzr.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-C0Zu3b3n.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-CuDtt2Zj.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-Cv2exx_M.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-C4TxJ6Rg.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-BmtPz8kf.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-B0f-qCZo.js → vendor-codemirror-lang-sql-BF1ZaXqJ.js} +2 -2
- package/dist/assets/vendor-codemirror-lang-vue-DZgXrP2k.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-DsnaGtL_.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-D8DzzFat.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-D5hBv7m6.js +1 -0
- package/dist/assets/{vendor-codemirror-language-data-CqU7kHmg.js → vendor-codemirror-language-data-vn2RyN9T.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BVCYIV0D.js +2 -0
- package/dist/assets/vendor-dompurify-BGCr_sdL.js +3 -0
- package/dist/assets/vendor-elkjs-D1S1RCAO.js +24 -0
- package/dist/assets/vendor-fuse.js-t_7AcMTv.js +1 -0
- package/dist/assets/{vendor-hast-util-to-html-BKBhbTDb.js → vendor-hast-util-to-html-O3stl53j.js} +1 -1
- package/dist/assets/{vendor-heic2any-pq-UTQQR.js → vendor-heic2any-sztndhZI.js} +1 -1
- package/dist/assets/vendor-lezer-cpp-vqXSn3lv.js +1 -0
- package/dist/assets/vendor-lezer-css-JnEzSyZR.js +1 -0
- package/dist/assets/{vendor-lezer-go-CHIhCNY6.js → vendor-lezer-go-dD2gQMIL.js} +1 -1
- package/dist/assets/{vendor-lezer-html-B3h0MOrG.js → vendor-lezer-html-Cr3U-1pu.js} +1 -1
- package/dist/assets/vendor-lezer-java-CRM0IMCo.js +1 -0
- package/dist/assets/vendor-lezer-javascript-B3s21DIS.js +1 -0
- package/dist/assets/{vendor-lezer-json-BP_UAzLL.js → vendor-lezer-json-DPFM6EBV.js} +1 -1
- package/dist/assets/vendor-lezer-lr-Bllrq8hY.js +1 -0
- package/dist/assets/vendor-lezer-markdown-6-3PLvXG.js +6 -0
- package/dist/assets/vendor-lezer-php-DOyzfHRl.js +1 -0
- package/dist/assets/{vendor-lezer-python-EJ4Im4y2.js → vendor-lezer-python-CdHdN5qt.js} +1 -1
- package/dist/assets/vendor-lezer-rust-CqnW8EMH.js +1 -0
- package/dist/assets/{vendor-lezer-sass-CMi6zfXI.js → vendor-lezer-sass-BbcF4y6A.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-0MHMeZDp.js → vendor-lezer-xml-C31AyWoo.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-BE2EFjpA.js → vendor-lezer-yaml-Cv908yC2.js} +1 -1
- package/dist/assets/{vendor-lru_map-DOPmc7GU.js → vendor-lru_map-BbiDqlyL.js} +1 -1
- package/dist/assets/vendor-marked-Be78pDn1.js +59 -0
- package/dist/assets/{vendor-oniguruma-parser-C0D4_9rT.js → vendor-oniguruma-parser-BrbMHgHx.js} +1 -1
- package/dist/assets/vendor-oniguruma-to-es-DgwFOwdE.js +94 -0
- package/dist/assets/{vendor-pierre-theming-Dgp7B_O4.js → vendor-pierre-theming-BO6EPniU.js} +1 -1
- package/dist/assets/vendor-property-information-C40bX6nM.js +1 -0
- package/dist/assets/{vendor-qrcode-Dv4uniC1.js → vendor-qrcode-gzL9QFkg.js} +5 -5
- package/dist/assets/vendor-react-Bz1tRBxM.js +1 -0
- package/dist/assets/{vendor-react-drawio-Duu5LgQA.js → vendor-react-drawio-IYnLUY5N.js} +1 -1
- package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
- package/dist/assets/vendor-replit-codemirror-vim-Cwhyn_5f.js +6 -0
- package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
- package/dist/assets/vendor-shiki-BEwTOAFg.js +1 -0
- package/dist/assets/{vendor-shikijs-core-CGM_jqPK.js → vendor-shikijs-core-Ck_OPM_T.js} +1 -1
- package/dist/assets/{vendor-shikijs-engine-javascript-Cme4830A.js → vendor-shikijs-engine-javascript-DL394yyj.js} +1 -1
- package/dist/assets/vendor-shikijs-vscode-textmate-DPFxvYtK.js +3 -0
- package/dist/assets/vendor-tailwind-merge-BKkUfl9q.js +1 -0
- package/dist/assets/vendor-workbox-window-BBnX5xw4.js +2 -0
- package/dist/assets/vendor-zumer-snapdom-SJzqoCHV.js +8 -0
- package/dist/assets/vendor-zustand-CXhN0IMY.js +6 -0
- package/dist/assets/{web-components-DzQ9ybbb.js → web-components-6ORYp3Iv.js} +1 -1
- package/dist/assets/worker-CKCfxIfO.js +153 -0
- package/dist/assets/workerFactory-DlGfNFqf.js +1 -0
- package/dist/assets/zig-BB16gwVL.js +1 -0
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +7 -7
- package/package.json +54 -53
- package/server/index.js +18 -1
- package/server/lib/client-auth/live-revocation.test.js +4 -0
- package/server/lib/fs/DOCUMENTATION.md +10 -0
- package/server/lib/fs/project-icon.js +243 -0
- package/server/lib/fs/project-icon.test.js +114 -0
- package/server/lib/fs/routes.js +35 -0
- package/server/lib/fs/routes.test.js +74 -0
- package/server/lib/git/DOCUMENTATION.md +2 -1
- package/server/lib/git/routes.js +11 -3
- package/server/lib/git/routes.test.js +80 -0
- package/server/lib/git/service.js +38 -3
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/open-url/DOCUMENTATION.md +35 -0
- package/server/lib/open-url/browser-env.js +199 -0
- package/server/lib/open-url/browser-env.test.js +147 -0
- package/server/lib/open-url/browser-handler.mjs +154 -0
- package/server/lib/open-url/browser-handler.test.js +69 -0
- package/server/lib/open-url/intake.js +187 -0
- package/server/lib/open-url/intake.test.js +75 -0
- package/server/lib/pi/extension-protocol.js +149 -0
- package/server/lib/pi/extension-protocol.test.js +20 -1
- package/server/lib/pi/routes.js +195 -1
- package/server/lib/pi/routes.test.js +129 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +38 -10
- package/server/lib/pi/session-daemon/builtin-extensions.js +14 -4
- package/server/lib/pi/session-daemon/daemon-process.js +13 -0
- package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +6 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +40 -6
- package/server/lib/pi/session-daemon/extension-custom-host.js +1259 -0
- package/server/lib/pi/session-daemon/extension-custom-host.test.js +759 -0
- package/server/lib/pi/session-daemon/extension-keybindings.js +21 -0
- package/server/lib/pi/session-daemon/extension-keybindings.test.js +37 -0
- package/server/lib/pi/session-daemon/extension-message-render.js +7 -4
- package/server/lib/pi/session-daemon/extension-message-render.test.js +14 -2
- package/server/lib/pi/session-daemon/extension-tool-render.js +7 -0
- package/server/lib/pi/session-daemon/extension-tool-render.test.js +26 -0
- package/server/lib/pi/session-daemon/open-request.js +60 -0
- package/server/lib/pi/session-daemon/open-request.test.js +54 -0
- package/server/lib/pi/session-daemon/prompt-preflight.test.js +134 -0
- package/server/lib/pi/session-daemon/sdk-upgrade.test.js +21 -4
- package/server/lib/pi/session-daemon/session-daemon-bash.e2e.test.js +225 -0
- package/server/lib/pi/session-daemon/session-daemon-directory-catalog.e2e.test.js +156 -0
- package/server/lib/pi/session-daemon/session-daemon-directory-catalog.test.js +381 -0
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +11 -2
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +30 -4
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +20 -0
- package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +16 -4
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +7 -2
- package/server/lib/pi/session-daemon/session-daemon.js +448 -49
- package/server/lib/pi/session-daemon/session-daemon.test.js +91 -4
- package/server/lib/pi/session-daemon/session-engine-router.js +9 -3
- package/server/lib/pi/session-daemon/session-engine-router.test.js +12 -2
- package/server/lib/pi/session-daemon/session-engines.js +7 -2
- package/server/lib/pi/session-daemon/session-jsonl.js +170 -75
- package/server/lib/pi/session-daemon/session-jsonl.test.js +106 -2
- package/server/lib/pi/session-daemon/supervisor.js +4 -0
- package/server/lib/pi/session-daemon/user-bash.js +326 -0
- package/server/lib/pi/session-daemon/user-bash.test.js +371 -0
- package/server/lib/preview/proxy-runtime.js +140 -45
- package/server/lib/preview/proxy-runtime.test.js +174 -3
- package/server/lib/preview/proxy-runtime.websocket.test.js +89 -0
- package/server/lib/relay/tunnel-host.js +1 -0
- package/server/lib/security/request-security.js +37 -0
- package/server/lib/security/request-security.test.js +54 -0
- package/server/lib/security/server-network-host.js +107 -0
- package/server/lib/security/server-network-host.test.js +70 -0
- package/server/lib/server-browser/DOCUMENTATION.md +243 -0
- package/server/lib/server-browser/browser-tab.js +524 -0
- package/server/lib/server-browser/chrome-executable.js +138 -0
- package/server/lib/server-browser/chrome-launch.js +138 -0
- package/server/lib/server-browser/dev-servers.js +288 -0
- package/server/lib/server-browser/dev-servers.test.js +152 -0
- package/server/lib/server-browser/downloads.js +75 -0
- package/server/lib/server-browser/frame-policy.js +183 -0
- package/server/lib/server-browser/frame-policy.test.js +98 -0
- package/server/lib/server-browser/network-guard.js +235 -0
- package/server/lib/server-browser/page-scripts.js +209 -0
- package/server/lib/server-browser/runtime.integration.test.js +474 -0
- package/server/lib/server-browser/runtime.js +300 -0
- package/server/lib/server-browser/runtime.test.js +50 -0
- package/server/lib/server-browser/server-browser.js +431 -0
- package/server/lib/server-browser/server-browser.test.js +975 -0
- package/server/lib/server-browser/tab-input.js +241 -0
- package/server/lib/server-browser/tab-prompts.js +125 -0
- package/server/lib/server-browser/tab-stream.js +252 -0
- package/server/lib/server-browser/uploads.js +98 -0
- package/server/lib/stt/runtime.js +4 -1
- package/server/lib/stt/runtime.test.js +43 -0
- package/server/lib/terminal/runtime.js +4 -1
- package/server/lib/terminal/runtime.test.js +41 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +29 -1
- package/server/lib/ui-auth/ui-auth.js +1 -0
- package/server/lib/ui-auth/ui-auth.test.js +9 -1
- package/server/lib/workspace/host.js +20 -3
- package/dist/assets/DiffView-CSonR3pr.js +0 -18
- package/dist/assets/FileSaveConflictDialog-Cun0LIbj.js +0 -3
- package/dist/assets/PullRequestsSurface-CfaOpeZn.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-BSutduo7.js +0 -2
- package/dist/assets/SessionUnreadDot-Dav_rix1.js +0 -1
- package/dist/assets/SettingsView-CQJkOPJh.js +0 -6
- package/dist/assets/abap-BdImnpbu.js +0 -1
- package/dist/assets/actionscript-3-CoDkCxhg.js +0 -1
- package/dist/assets/ada-bCR0ucgS.js +0 -1
- package/dist/assets/angular-html-CU67Zn6k.js +0 -1
- package/dist/assets/angular-ts-BwZT4LLn.js +0 -1
- package/dist/assets/apache-Pmp26Uib.js +0 -1
- package/dist/assets/apex-D8_7TLub.js +0 -1
- package/dist/assets/apl-dKokRX4l.js +0 -1
- package/dist/assets/applescript-Co6uUVPk.js +0 -1
- package/dist/assets/ara-BRHolxvo.js +0 -1
- package/dist/assets/asciidoc-Ve4PFQV2.js +0 -1
- package/dist/assets/asm-D_Q5rh1f.js +0 -1
- package/dist/assets/astro-CbQHKStN.js +0 -1
- package/dist/assets/awk-DMzUqQB5.js +0 -1
- package/dist/assets/ballerina-BFfxhgS-.js +0 -1
- package/dist/assets/bat-BkioyH1T.js +0 -1
- package/dist/assets/beancount-k_qm7-4y.js +0 -1
- package/dist/assets/berry-uYugtg8r.js +0 -1
- package/dist/assets/bibtex-CHM0blh-.js +0 -1
- package/dist/assets/bicep-Bmn6On1c.js +0 -1
- package/dist/assets/bird2-DPOp833l.js +0 -1
- package/dist/assets/blade-D4QpJJKB.js +0 -1
- package/dist/assets/bsl-BO_Y6i37.js +0 -1
- package/dist/assets/c-BIGW1oBm.js +0 -1
- package/dist/assets/c3-eo99z4R2.js +0 -1
- package/dist/assets/cadence-Bv_4Rxtq.js +0 -1
- package/dist/assets/cairo-KRGpt6FW.js +0 -1
- package/dist/assets/clarity-D53aC0YG.js +0 -1
- package/dist/assets/clojure-P80f7IUj.js +0 -1
- package/dist/assets/cmake-D1j8_8rp.js +0 -1
- package/dist/assets/cobol-nwyudZeR.js +0 -1
- package/dist/assets/codeowners-Bp6g37R7.js +0 -1
- package/dist/assets/codeql-DsOJ9woJ.js +0 -1
- package/dist/assets/coffee-Ch7k5sss.js +0 -1
- package/dist/assets/common-lisp-Cg-RD9OK.js +0 -1
- package/dist/assets/coq-DkFqJrB1.js +0 -1
- package/dist/assets/cpp-CofmeUqb.js +0 -1
- package/dist/assets/crystal-tKQVLTB8.js +0 -1
- package/dist/assets/csharp-COcwbKMJ.js +0 -1
- package/dist/assets/css-DPfMkruS.js +0 -1
- package/dist/assets/csv-fuZLfV_i.js +0 -1
- package/dist/assets/cue-D82EKSYY.js +0 -1
- package/dist/assets/cypher-COkxafJQ.js +0 -1
- package/dist/assets/d-85-TOEBH.js +0 -1
- package/dist/assets/dart-CF10PKvl.js +0 -1
- package/dist/assets/dax-CEL-wOlO.js +0 -1
- package/dist/assets/desktop-BmXAJ9_W.js +0 -1
- package/dist/assets/diff-D97Zzqfu.js +0 -1
- package/dist/assets/docker-BcOcwvcX.js +0 -1
- package/dist/assets/dotenv-Da5cRb03.js +0 -1
- package/dist/assets/dream-maker-BtqSS_iP.js +0 -1
- package/dist/assets/edge-BkV0erSs.js +0 -1
- package/dist/assets/elixir-CDX3lj18.js +0 -1
- package/dist/assets/elm-DbKCFpqz.js +0 -1
- package/dist/assets/emacs-lisp-C9XAeP06.js +0 -1
- package/dist/assets/erb-B12qg9BL.js +0 -1
- package/dist/assets/erlang-DsQrWhSR.js +0 -1
- package/dist/assets/fennel-BYunw83y.js +0 -1
- package/dist/assets/fish-BvzEVeQv.js +0 -1
- package/dist/assets/fluent-C4IJs8-o.js +0 -1
- package/dist/assets/fortran-fixed-form-CkoXwp7k.js +0 -1
- package/dist/assets/fortran-free-form-BxgE0vQu.js +0 -1
- package/dist/assets/fsharp-CXgrBDvD.js +0 -1
- package/dist/assets/gdresource-BOOCDP_w.js +0 -1
- package/dist/assets/gdscript-C5YyOfLZ.js +0 -1
- package/dist/assets/gdshader-DkwncUOv.js +0 -1
- package/dist/assets/genie-D0YGMca9.js +0 -1
- package/dist/assets/gherkin-DyxjwDmM.js +0 -1
- package/dist/assets/git-commit-F4YmCXRG.js +0 -1
- package/dist/assets/git-rebase-r7XF79zn.js +0 -1
- package/dist/assets/gleam-BspZqrRM.js +0 -1
- package/dist/assets/glimmer-js-Rg0-pVw9.js +0 -1
- package/dist/assets/glimmer-ts-U6CK756n.js +0 -1
- package/dist/assets/glsl-DplSGwfg.js +0 -1
- package/dist/assets/gn-n2N0HUVH.js +0 -1
- package/dist/assets/gnuplot-DdkO51Og.js +0 -1
- package/dist/assets/go-CxLEBnE3.js +0 -1
- package/dist/assets/graphql-ChdNCCLP.js +0 -1
- package/dist/assets/groovy-gcz8RCvz.js +0 -1
- package/dist/assets/hack-CaT9iCJl.js +0 -1
- package/dist/assets/haml-B8DHNrY2.js +0 -1
- package/dist/assets/handlebars-BL8al0AC.js +0 -1
- package/dist/assets/haskell-Df6bDoY_.js +0 -1
- package/dist/assets/haxe-CzTSHFRz.js +0 -1
- package/dist/assets/hcl-BWvSN4gD.js +0 -1
- package/dist/assets/hjson-D5-asLiD.js +0 -1
- package/dist/assets/hlsl-D3lLCCz7.js +0 -1
- package/dist/assets/html-GMplVEZG.js +0 -1
- package/dist/assets/html-derivative-BFtXZ54Q.js +0 -1
- package/dist/assets/http-jrhK8wxY.js +0 -1
- package/dist/assets/hurl-irOxFIW8.js +0 -1
- package/dist/assets/hxml-Bvhsp5Yf.js +0 -1
- package/dist/assets/hy-DFXneXwc.js +0 -1
- package/dist/assets/imba-DGztddWO.js +0 -1
- package/dist/assets/index-B0h6_x5N.js +0 -1
- package/dist/assets/index-BwoW_-vk.css +0 -1
- package/dist/assets/ini-BEwlwnbL.js +0 -1
- package/dist/assets/java-CylS5w8V.js +0 -1
- package/dist/assets/javascript-wDzz0qaB.js +0 -1
- package/dist/assets/jinja-4LBKfQ-Z.js +0 -1
- package/dist/assets/jison-wvAkD_A8.js +0 -1
- package/dist/assets/json-Cp-IABpG.js +0 -1
- package/dist/assets/json5-C9tS-k6U.js +0 -1
- package/dist/assets/jsonc-Des-eS-w.js +0 -1
- package/dist/assets/jsonl-DcaNXYhu.js +0 -1
- package/dist/assets/jsonnet-DFQXde-d.js +0 -1
- package/dist/assets/jssm-C2t-YnRu.js +0 -1
- package/dist/assets/jsx-g9-lgVsj.js +0 -1
- package/dist/assets/julia-CxzCAyBv.js +0 -1
- package/dist/assets/just-Cw27pwNe.js +0 -1
- package/dist/assets/kdl-DV7GczEv.js +0 -1
- package/dist/assets/kotlin-BdnUsdx6.js +0 -1
- package/dist/assets/kusto-DZf3V79B.js +0 -1
- package/dist/assets/latex-CWtU0Tv5.js +0 -1
- package/dist/assets/lean-BZvkOJ9d.js +0 -1
- package/dist/assets/less-B1dDrJ26.js +0 -1
- package/dist/assets/liquid-DYVedYrR.js +0 -1
- package/dist/assets/llvm-DjAJT7YJ.js +0 -1
- package/dist/assets/log-2UxHyX5q.js +0 -1
- package/dist/assets/logo-BtOb2qkB.js +0 -1
- package/dist/assets/lua-BaeVxFsk.js +0 -1
- package/dist/assets/luau-C-HG3fhB.js +0 -1
- package/dist/assets/main-C6i4ph9N.js +0 -2
- package/dist/assets/main-r5elIPBi.js +0 -136
- package/dist/assets/make-CHLpvVh8.js +0 -1
- package/dist/assets/markdown-Cvjx9yec.js +0 -1
- package/dist/assets/markdownCore-C2YQ3Z0q.js +0 -2
- package/dist/assets/marko-CnJfTvn9.js +0 -1
- package/dist/assets/matlab-D7o27uSR.js +0 -1
- package/dist/assets/mdc-BMNejdWA.js +0 -1
- package/dist/assets/mdx-Cmh6b_Ma.js +0 -1
- package/dist/assets/mermaid-mWjccvbQ.js +0 -1
- package/dist/assets/miniChat-d_GCHoIf.js +0 -2
- package/dist/assets/mipsasm-CKIfxQSi.js +0 -1
- package/dist/assets/mobile-BJ3tgyKd.js +0 -2
- package/dist/assets/mojo-rZm6bMo-.js +0 -1
- package/dist/assets/moonbit-_H4v1dQx.js +0 -1
- package/dist/assets/move-IF9eRakj.js +0 -1
- package/dist/assets/narrat-DRg8JJMk.js +0 -1
- package/dist/assets/nextflow-Zz6hmt5N.js +0 -1
- package/dist/assets/nextflow-groovy-BeH2EWoN.js +0 -1
- package/dist/assets/nginx-BpAMiNFr.js +0 -1
- package/dist/assets/nim-CVrawwO9.js +0 -1
- package/dist/assets/nix-CwoSXNpI.js +0 -1
- package/dist/assets/nsis-LdVXkNf5.js +0 -1
- package/dist/assets/nushell-Cz2AlsmD.js +0 -1
- package/dist/assets/objective-c-DXmwc3jG.js +0 -1
- package/dist/assets/objective-cpp-CLxacb5B.js +0 -1
- package/dist/assets/ocaml-C0hk2d4L.js +0 -1
- package/dist/assets/odin-BBf5iR-q.js +0 -1
- package/dist/assets/openscad-C4EeE6gA.js +0 -1
- package/dist/assets/pascal-D93ZcfNL.js +0 -1
- package/dist/assets/perl-C0TMdlhV.js +0 -1
- package/dist/assets/permissionStore-B9Hkrqny.js +0 -1
- package/dist/assets/php-Dhbhpdrm.js +0 -1
- package/dist/assets/pi-session-focus-preference-BFnGFuvP.js +0 -9
- package/dist/assets/pkl-u5AG7uiY.js +0 -1
- package/dist/assets/plsql-ChMvpjG-.js +0 -1
- package/dist/assets/po-BTJTHyun.js +0 -1
- package/dist/assets/polar-C0HS_06l.js +0 -1
- package/dist/assets/postcss-CXtECtnM.js +0 -1
- package/dist/assets/powerquery-CEu0bR-o.js +0 -1
- package/dist/assets/powershell-Dpen1YoG.js +0 -1
- package/dist/assets/prisma-Dd19v3D-.js +0 -1
- package/dist/assets/prolog-CbFg5uaA.js +0 -1
- package/dist/assets/proto-C7zT0LnQ.js +0 -1
- package/dist/assets/pug-CGlum2m_.js +0 -1
- package/dist/assets/puppet-BMWR74SV.js +0 -1
- package/dist/assets/purescript-CklMAg4u.js +0 -1
- package/dist/assets/python-B6aJPvgy.js +0 -1
- package/dist/assets/qml-3beO22l8.js +0 -1
- package/dist/assets/qmldir-C8lEn-DE.js +0 -1
- package/dist/assets/qss-IeuSbFQv.js +0 -1
- package/dist/assets/r-Dspwwk_N.js +0 -1
- package/dist/assets/racket-BqYA7rlc.js +0 -1
- package/dist/assets/raku-DXvB9xmW.js +0 -1
- package/dist/assets/razor-Uh8Bk_45.js +0 -1
- package/dist/assets/reg-C-SQnVFl.js +0 -1
- package/dist/assets/regexp-CDVJQ6XC.js +0 -1
- package/dist/assets/rel-C3B-1QV4.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-Bap5OwgB.js +0 -2
- package/dist/assets/renderMobileApp-DJbslvby.js +0 -11
- package/dist/assets/riscv-BM1_JUlF.js +0 -1
- package/dist/assets/ron-D8l8udqQ.js +0 -1
- package/dist/assets/rosmsg-BJDFO7_C.js +0 -1
- package/dist/assets/rst-BrH8l1NY.js +0 -1
- package/dist/assets/ruby-B2Rjki9n.js +0 -1
- package/dist/assets/ruby-Dw2BHqvy.js +0 -1
- package/dist/assets/runtimeEndpointReset-D22U_Vjs.js +0 -62
- package/dist/assets/runtimeSurface-k1Eit61v.js +0 -1
- package/dist/assets/rust-B1yitclQ.js +0 -1
- package/dist/assets/sas-cz2c8ADy.js +0 -1
- package/dist/assets/sass-Cj5Yp3dK.js +0 -1
- package/dist/assets/scala-C151Ov-r.js +0 -1
- package/dist/assets/scheme-C98Dy4si.js +0 -1
- package/dist/assets/scss-OYdSNvt2.js +0 -1
- package/dist/assets/sdbl-DVxCFoDh.js +0 -1
- package/dist/assets/shaderlab-Dg9Lc6iA.js +0 -1
- package/dist/assets/shellscript-Yzrsuije.js +0 -1
- package/dist/assets/shellsession-BADoaaVG.js +0 -1
- package/dist/assets/smalltalk-BERRCDM3.js +0 -1
- package/dist/assets/solidity-rGO070M0.js +0 -1
- package/dist/assets/soy-Brmx7dQM.js +0 -1
- package/dist/assets/sparql-rVzFXLq3.js +0 -1
- package/dist/assets/splunk-BtCnVYZw.js +0 -1
- package/dist/assets/sql-BLtJtn59.js +0 -1
- package/dist/assets/ssh-config-_ykCGR6B.js +0 -1
- package/dist/assets/stata-BH5u7GGu.js +0 -1
- package/dist/assets/stylus-BEDo0Tqx.js +0 -1
- package/dist/assets/surrealql-Bq5Q-fJD.js +0 -1
- package/dist/assets/svelte-C_ipcX3V.js +0 -1
- package/dist/assets/swift-D82vCrfD.js +0 -1
- package/dist/assets/system-verilog-CnnmHF94.js +0 -1
- package/dist/assets/systemd-4A_iFExJ.js +0 -1
- package/dist/assets/talonscript-CkByrt1z.js +0 -1
- package/dist/assets/tasl-QIJgUcNo.js +0 -1
- package/dist/assets/tcl-dwOrl1Do.js +0 -1
- package/dist/assets/templ-P3uqSqPl.js +0 -1
- package/dist/assets/terraform-BETggiCN.js +0 -1
- package/dist/assets/tex-idrVyKtj.js +0 -1
- package/dist/assets/themeResolver-yJ9XpNMI.js +0 -1
- package/dist/assets/toml-vGWfd6FD.js +0 -1
- package/dist/assets/ts-tags-zn1MmPIZ.js +0 -1
- package/dist/assets/tsv-B_m7g4N7.js +0 -1
- package/dist/assets/tsx-COt5Ahok.js +0 -1
- package/dist/assets/turtle-BsS91CYL.js +0 -1
- package/dist/assets/twig-DNn4PbVi.js +0 -1
- package/dist/assets/typescript-BPQ3VLAy.js +0 -1
- package/dist/assets/typespec-BGHnOYBU.js +0 -1
- package/dist/assets/typst-DHCkPAjA.js +0 -1
- package/dist/assets/useAppFontEffects-CqHhRKmN.js +0 -212
- package/dist/assets/useFilesViewSearch-CqoYEK0U.js +0 -7
- package/dist/assets/v-BcVCzyr7.js +0 -1
- package/dist/assets/vala-CsfeWuGM.js +0 -1
- package/dist/assets/vb-D17OF-Vu.js +0 -1
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-BDrMx_CE.js +0 -1
- package/dist/assets/vendor-base-ui-CKRUCG-f.js +0 -1
- package/dist/assets/vendor-boot-EC6IyLt1.js +0 -69
- package/dist/assets/vendor-codemirror-autocomplete-CGpAsPWp.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-CDJoHJSY.js +0 -1
- package/dist/assets/vendor-codemirror-lang-cpp-BmHofQls.js +0 -1
- package/dist/assets/vendor-codemirror-lang-css-RM2HqXZ0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-html-CHSHUpwq.js +0 -1
- package/dist/assets/vendor-codemirror-lang-java-lhQXgWu0.js +0 -1
- package/dist/assets/vendor-codemirror-lang-javascript-Dw4kFO4e.js +0 -13
- package/dist/assets/vendor-codemirror-lang-jinja-_pAC3UTN.js +0 -1
- package/dist/assets/vendor-codemirror-lang-json-B-b1vAv-.js +0 -1
- package/dist/assets/vendor-codemirror-lang-less-xIgOi1ze.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-CP49m5dB.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-BTht2ATe.js +0 -1
- package/dist/assets/vendor-codemirror-lang-php-BguZDhaO.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-CH6_em9L.js +0 -3
- package/dist/assets/vendor-codemirror-lang-rust-EG_DtGyi.js +0 -1
- package/dist/assets/vendor-codemirror-lang-sass-BknY5Qpo.js +0 -1
- package/dist/assets/vendor-codemirror-lang-vue-CyGn9snv.js +0 -1
- package/dist/assets/vendor-codemirror-lang-wast-CsFfSyyB.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-Cdan_Jp1.js +0 -1
- package/dist/assets/vendor-codemirror-lang-yaml-COI5hck8.js +0 -1
- package/dist/assets/vendor-codemirror-search-DUfSCF9S.js +0 -2
- package/dist/assets/vendor-dompurify-r8glNMJW.js +0 -2
- package/dist/assets/vendor-elkjs-D27273Ms.js +0 -24
- package/dist/assets/vendor-fuse.js-Dw8P0qyA.js +0 -1
- package/dist/assets/vendor-lezer-cpp-DMZOJzBa.js +0 -1
- package/dist/assets/vendor-lezer-css-DUkkbMp7.js +0 -1
- package/dist/assets/vendor-lezer-java-tMazV_6X.js +0 -1
- package/dist/assets/vendor-lezer-javascript-ctwLWf4v.js +0 -1
- package/dist/assets/vendor-lezer-lr-B8TQctNw.js +0 -1
- package/dist/assets/vendor-lezer-markdown-aGLZf_3h.js +0 -6
- package/dist/assets/vendor-lezer-php-D5zCNzlt.js +0 -1
- package/dist/assets/vendor-lezer-rust-DO5c7OtA.js +0 -1
- package/dist/assets/vendor-marked-CX41MkDF.js +0 -59
- package/dist/assets/vendor-oniguruma-to-es-DLBnFDCE.js +0 -94
- package/dist/assets/vendor-property-information-rJCbAzvX.js +0 -1
- package/dist/assets/vendor-react-DASdDPIk.js +0 -1
- package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
- package/dist/assets/vendor-replit-codemirror-vim-AnOuN8yJ.js +0 -39
- package/dist/assets/vendor-shiki-Bbf2GEcE.js +0 -2
- package/dist/assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js +0 -3
- package/dist/assets/vendor-tailwind-merge-CPcsbTWB.js +0 -1
- package/dist/assets/vendor-workbox-window-BIl4cyR9.js +0 -2
- package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +0 -8
- package/dist/assets/vendor-zustand-CUi8eEds.js +0 -6
- package/dist/assets/verilog-BQ8w6xss.js +0 -1
- package/dist/assets/vhdl-CeAyd5Ju.js +0 -1
- package/dist/assets/viml-CJc9bBzg.js +0 -1
- package/dist/assets/vue-DN_0RTcg.js +0 -1
- package/dist/assets/vue-html-AaS7Mt5G.js +0 -1
- package/dist/assets/vue-vine-CQOfvN7w.js +0 -1
- package/dist/assets/vyper-CDx5xZoG.js +0 -1
- package/dist/assets/wasm-MzD3tlZU.js +0 -1
- package/dist/assets/wenyan-BV7otONQ.js +0 -1
- package/dist/assets/wgsl-Dx-B1_4e.js +0 -1
- package/dist/assets/wikitext-BhOHFoWU.js +0 -1
- package/dist/assets/wit-5i3qLPDT.js +0 -1
- package/dist/assets/wolfram-lXgVvXCa.js +0 -1
- package/dist/assets/worker-BBk7yuNN.js +0 -153
- package/dist/assets/workerFactory-tw7cIdmV.js +0 -1
- package/dist/assets/xml-sdJ4AIDG.js +0 -1
- package/dist/assets/xsl-CtQFsRM5.js +0 -1
- package/dist/assets/yaml-Buea-lGh.js +0 -1
- package/dist/assets/zenscript-DVFEvuxE.js +0 -1
- package/dist/assets/zig-VOosw3JB.js +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
|
|
6
|
+
import { createProjectIconResolver, findDeclaredIconHref } from './project-icon.js';
|
|
7
|
+
|
|
8
|
+
let root;
|
|
9
|
+
|
|
10
|
+
const write = async (relative, content = 'icon') => {
|
|
11
|
+
const file = path.join(root, relative);
|
|
12
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
13
|
+
await fs.writeFile(file, content);
|
|
14
|
+
return file;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const createResolver = (options = {}) => createProjectIconResolver({ fsPromises: fs, path, ...options });
|
|
18
|
+
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
root = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'project-icon-')));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(async () => {
|
|
24
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('findDeclaredIconHref', () => {
|
|
28
|
+
it('reads the href of an icon link in HTML', () => {
|
|
29
|
+
const html = '<link rel="stylesheet" href="/app.css"><link href="/brand.svg" rel="shortcut icon">';
|
|
30
|
+
expect(findDeclaredIconHref(html)).toBe('/brand.svg');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('reads an icon from a framework head config', () => {
|
|
34
|
+
const source = "links: [{ rel: 'stylesheet', href: '/app.css' }, { rel: 'icon', href: '/logo.png' }]";
|
|
35
|
+
expect(findDeclaredIconHref(source)).toBe('/logo.png');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('ignores apple-touch-icon-only and missing declarations', () => {
|
|
39
|
+
expect(findDeclaredIconHref('<link rel="apple-touch-icon-precomposed" href="/a.png">')).toBeNull();
|
|
40
|
+
expect(findDeclaredIconHref('<html></html>')).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('createProjectIconResolver', () => {
|
|
45
|
+
it('returns null for a project without an icon', async () => {
|
|
46
|
+
await write('README.md', '# hi');
|
|
47
|
+
expect(await createResolver().resolve(root)).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('prefers a root favicon over later candidates', async () => {
|
|
51
|
+
await write('public/favicon.ico');
|
|
52
|
+
const svg = await write('favicon.svg', '<svg/>');
|
|
53
|
+
expect(await createResolver().resolve(root)).toEqual({ path: svg, mime: 'image/svg+xml' });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('finds an app-router icon', async () => {
|
|
57
|
+
const icon = await write('src/app/favicon.ico');
|
|
58
|
+
expect(await createResolver().resolve(root)).toEqual({ path: icon, mime: 'image/x-icon' });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('follows an icon declared in index.html', async () => {
|
|
62
|
+
await write('index.html', '<head><link rel="icon" type="image/png" href="/brand/mark.png?v=2"></head>');
|
|
63
|
+
const icon = await write('public/brand/mark.png');
|
|
64
|
+
expect(await createResolver().resolve(root)).toEqual({ path: icon, mime: 'image/png' });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('skips remote and data-URL declarations', async () => {
|
|
68
|
+
await write('index.html', '<link rel="icon" href="https://cdn.example.com/icon.png">');
|
|
69
|
+
expect(await createResolver().resolve(root)).toBeNull();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('searches monorepo packages, preferring the web package', async () => {
|
|
73
|
+
await write('packages/docs/public/favicon.ico');
|
|
74
|
+
const web = await write('packages/web/public/favicon.svg', '<svg/>');
|
|
75
|
+
expect(await createResolver().resolve(root)).toEqual({ path: web, mime: 'image/svg+xml' });
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('never returns a file outside the project, even through a symlink', async () => {
|
|
79
|
+
const outside = await fs.mkdtemp(path.join(os.tmpdir(), 'project-icon-outside-'));
|
|
80
|
+
try {
|
|
81
|
+
await fs.writeFile(path.join(outside, 'favicon.ico'), 'icon');
|
|
82
|
+
await fs.symlink(path.join(outside, 'favicon.ico'), path.join(root, 'favicon.ico'));
|
|
83
|
+
await write('index.html', '<link rel="icon" href="../../etc/passwd.png">');
|
|
84
|
+
expect(await createResolver().resolve(root)).toBeNull();
|
|
85
|
+
} finally {
|
|
86
|
+
await fs.rm(outside, { recursive: true, force: true });
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('rejects icons that are empty or too large', async () => {
|
|
91
|
+
await write('favicon.ico', '');
|
|
92
|
+
await write('favicon.png', Buffer.alloc(1024 * 1024 + 1));
|
|
93
|
+
expect(await createResolver().resolve(root)).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('re-resolves when a cached icon disappears', async () => {
|
|
97
|
+
const resolver = createResolver();
|
|
98
|
+
const svg = await write('favicon.svg', '<svg/>');
|
|
99
|
+
const png = await write('public/favicon.png');
|
|
100
|
+
expect((await resolver.resolve(root))?.path).toBe(svg);
|
|
101
|
+
await fs.rm(svg);
|
|
102
|
+
expect((await resolver.resolve(root))?.path).toBe(png);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('caches a missing icon briefly, then looks again', async () => {
|
|
106
|
+
let time = 0;
|
|
107
|
+
const resolver = createResolver({ now: () => time });
|
|
108
|
+
expect(await resolver.resolve(root)).toBeNull();
|
|
109
|
+
const icon = await write('favicon.png');
|
|
110
|
+
expect(await resolver.resolve(root)).toBeNull();
|
|
111
|
+
time += 61 * 1000;
|
|
112
|
+
expect((await resolver.resolve(root))?.path).toBe(icon);
|
|
113
|
+
});
|
|
114
|
+
});
|
package/server/lib/fs/routes.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createHash } from 'node:crypto';
|
|
|
5
5
|
import { resolvePiChamberDataDir } from '../pichamber-data-dir.js';
|
|
6
6
|
import { createFsSearchRuntime } from './search.js';
|
|
7
7
|
import { pickHostDirectory } from './pick-directory.js';
|
|
8
|
+
import { createProjectIconResolver } from './project-icon.js';
|
|
8
9
|
|
|
9
10
|
const EXEC_JOB_TTL_MS = 30 * 60 * 1000;
|
|
10
11
|
const OUTSIDE_FILE_GRANT_TTL_MS = 10 * 60 * 1000;
|
|
@@ -520,6 +521,7 @@ export const registerFsRoutes = (app, dependencies) => {
|
|
|
520
521
|
pichamberUserConfigRoot,
|
|
521
522
|
pickDirectory = pickHostDirectory,
|
|
522
523
|
} = dependencies;
|
|
524
|
+
const projectIcons = createProjectIconResolver({ fsPromises, path });
|
|
523
525
|
const realpathCache = createRealpathCache({
|
|
524
526
|
realpath: fsPromises.realpath.bind(fsPromises),
|
|
525
527
|
});
|
|
@@ -1103,6 +1105,39 @@ export const registerFsRoutes = (app, dependencies) => {
|
|
|
1103
1105
|
}
|
|
1104
1106
|
});
|
|
1105
1107
|
|
|
1108
|
+
// The icon a project already ships (favicon, app icon, logo), or 204 when it
|
|
1109
|
+
// has none. `directory` is required: this never falls back to the server cwd.
|
|
1110
|
+
app.get('/api/fs/project-icon', async (req, res) => {
|
|
1111
|
+
const requested = Array.isArray(req.query?.directory) ? req.query.directory[0] : req.query?.directory;
|
|
1112
|
+
if (typeof requested !== 'string' || !requested.trim()) {
|
|
1113
|
+
return res.status(400).json({ error: 'Directory is required' });
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
const resolvedProject = await resolveProjectDirectory(req);
|
|
1117
|
+
if (!resolvedProject.directory) {
|
|
1118
|
+
return res.status(404).json({ error: resolvedProject.error || 'Directory not found' });
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
try {
|
|
1122
|
+
const icon = await projectIcons.resolve(resolvedProject.directory);
|
|
1123
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
1124
|
+
if (!icon) {
|
|
1125
|
+
return res.status(204).send();
|
|
1126
|
+
}
|
|
1127
|
+
const content = await fsPromises.readFile(icon.path);
|
|
1128
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
1129
|
+
// An SVG opened directly must not run scripts with this origin's access.
|
|
1130
|
+
res.setHeader('Content-Security-Policy', "default-src 'none'; style-src 'unsafe-inline'; sandbox");
|
|
1131
|
+
return res.type(icon.mime).send(content);
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
if (isOsPermissionError(error)) {
|
|
1134
|
+
return sendOsPermissionDenied(res, 'Access to project icon denied');
|
|
1135
|
+
}
|
|
1136
|
+
console.error('Failed to read project icon:', error);
|
|
1137
|
+
return res.status(500).json({ error: 'Failed to read project icon' });
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1106
1141
|
app.get(/^\/api\/fs\/serve\/(.+)$/, async (req, res) => {
|
|
1107
1142
|
const rawPath = req.params[0] || '';
|
|
1108
1143
|
if (!rawPath) {
|
|
@@ -1554,3 +1554,77 @@ describe('/api/fs/pick-directory', () => {
|
|
|
1554
1554
|
});
|
|
1555
1555
|
});
|
|
1556
1556
|
|
|
1557
|
+
|
|
1558
|
+
describe('/api/fs/project-icon', () => {
|
|
1559
|
+
let projectRoot;
|
|
1560
|
+
|
|
1561
|
+
beforeEach(async () => {
|
|
1562
|
+
const realFs = await import('node:fs/promises');
|
|
1563
|
+
const os = await import('node:os');
|
|
1564
|
+
projectRoot = await realFs.realpath(await realFs.mkdtemp(path.join(os.tmpdir(), 'project-icon-route-')));
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
afterEach(async () => {
|
|
1568
|
+
const realFs = await import('node:fs/promises');
|
|
1569
|
+
await realFs.rm(projectRoot, { recursive: true, force: true });
|
|
1570
|
+
});
|
|
1571
|
+
|
|
1572
|
+
const registerProjectIcon = async (resolveProjectDirectory) => {
|
|
1573
|
+
const realFs = await import('node:fs/promises');
|
|
1574
|
+
const { app, getRoute } = createRouteRegistry();
|
|
1575
|
+
registerFsRoutes(app, {
|
|
1576
|
+
os: { homedir: () => '/home/user' },
|
|
1577
|
+
path,
|
|
1578
|
+
fsPromises: realFs.default,
|
|
1579
|
+
spawn: vi.fn(),
|
|
1580
|
+
crypto: { randomUUID: () => 'job-0' },
|
|
1581
|
+
normalizeDirectoryPath: (p) => p,
|
|
1582
|
+
resolveProjectDirectory: resolveProjectDirectory ?? (async () => ({ directory: projectRoot })),
|
|
1583
|
+
buildAugmentedPath: () => '/usr/bin',
|
|
1584
|
+
resolveGitBinaryForSpawn: () => 'git',
|
|
1585
|
+
pichamberUserConfigRoot: '/home/user/.config',
|
|
1586
|
+
});
|
|
1587
|
+
return getRoute('GET', '/api/fs/project-icon');
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
it('requires an explicit directory instead of using the server cwd', async () => {
|
|
1591
|
+
const resolveProjectDirectory = vi.fn(async () => ({ directory: projectRoot }));
|
|
1592
|
+
const handler = await registerProjectIcon(resolveProjectDirectory);
|
|
1593
|
+
const res = createMockResponse();
|
|
1594
|
+
await handler({ query: {} }, res);
|
|
1595
|
+
expect(res.statusCode).toBe(400);
|
|
1596
|
+
expect(resolveProjectDirectory).not.toHaveBeenCalled();
|
|
1597
|
+
});
|
|
1598
|
+
|
|
1599
|
+
it('reports a missing directory as an error, not as "no icon"', async () => {
|
|
1600
|
+
const handler = await registerProjectIcon(async () => ({ directory: null, error: 'Directory not found' }));
|
|
1601
|
+
const res = createMockResponse();
|
|
1602
|
+
await handler({ query: { directory: '/gone' } }, res);
|
|
1603
|
+
expect(res.statusCode).toBe(404);
|
|
1604
|
+
});
|
|
1605
|
+
|
|
1606
|
+
it('answers 204 when the project has no icon', async () => {
|
|
1607
|
+
const handler = await registerProjectIcon();
|
|
1608
|
+
const res = createMockResponse();
|
|
1609
|
+
await handler({ query: { directory: projectRoot } }, res);
|
|
1610
|
+
expect(res.statusCode).toBe(204);
|
|
1611
|
+
});
|
|
1612
|
+
|
|
1613
|
+
it('sends the icon bytes with a sandboxing policy', async () => {
|
|
1614
|
+
const realFs = await import('node:fs/promises');
|
|
1615
|
+
await realFs.writeFile(path.join(projectRoot, 'favicon.svg'), '<svg xmlns="http://www.w3.org/2000/svg"/>');
|
|
1616
|
+
const handler = await registerProjectIcon();
|
|
1617
|
+
const res = createMockResponse();
|
|
1618
|
+
let type = null;
|
|
1619
|
+
res.type = (value) => {
|
|
1620
|
+
type = value;
|
|
1621
|
+
return res;
|
|
1622
|
+
};
|
|
1623
|
+
await handler({ query: { directory: projectRoot } }, res);
|
|
1624
|
+
expect(res.statusCode).toBe(200);
|
|
1625
|
+
expect(type).toBe('image/svg+xml');
|
|
1626
|
+
expect(Buffer.from(res.body).toString()).toContain('<svg');
|
|
1627
|
+
expect(res.getHeader('content-security-policy')).toContain('sandbox');
|
|
1628
|
+
expect(res.getHeader('x-content-type-options')).toBe('nosniff');
|
|
1629
|
+
});
|
|
1630
|
+
});
|
|
@@ -35,7 +35,8 @@ The following functions are exported and used by the web server:
|
|
|
35
35
|
|
|
36
36
|
### Status and Diff Operations
|
|
37
37
|
- `getStatus(directory)`: Get comprehensive Git status including current branch, tracking, ahead/behind, file changes, diff stats, merge/rebase state.
|
|
38
|
-
- `getDiff(directory, { path, staged, contextLines })`: Get diff output for files or entire working tree. Untracked symbolic links are represented as link entries without following their targets.
|
|
38
|
+
- `getDiff(directory, { path, source, staged, contextLines })`: Get diff output for files or entire working tree. `source` picks the change set: `unstaged` (default, index → working tree), `staged` (HEAD → index), or `head` (HEAD → working tree, staged and unstaged together; diffs against the empty tree before the first commit). `staged: true` is the legacy alias for `source: 'staged'`, and an unknown `source` throws. Exposed as `GET /api/git/diff?source=…`; the route still accepts `staged=true` for older clients and answers an unknown `source` with 400. Untracked files (including under `head`) fall back to a `--no-index` diff against `/dev/null`; untracked symbolic links are represented as link entries without following their targets.
|
|
39
|
+
- `resolveDiffSource({ source, staged })`: Validate and normalize the diff source used by `getDiff` and the `/api/git/diff` route.
|
|
39
40
|
- `getRangeDiff(directory, { base, head, path, contextLines })`: Get diff between two refs. Uses three-dot `base...head` semantics, so work merged into `head` from `base` is excluded and only the branch's own changes are returned. Prefers `origin/<base>` when that remote-tracking ref exists, so a stale local base branch does not resurface already-merged commits. Exposed as `GET /api/git/range-diff` (`path` optional; omit it for the whole range).
|
|
40
41
|
- `getFileDiff(directory, { path, staged })`: Get original and modified file contents for a single file (handles images as data URLs and symbolic links as their link-target text).
|
|
41
42
|
- `revertFile(directory, filePath, options)`: Revert a file. Default scope `all` discards staged and working-tree changes; scope `working` discards only unstaged/working-tree changes.
|
package/server/lib/git/routes.js
CHANGED
|
@@ -291,7 +291,7 @@ export function registerGitRoutes(app) {
|
|
|
291
291
|
});
|
|
292
292
|
|
|
293
293
|
app.get('/api/git/diff', async (req, res) => {
|
|
294
|
-
const { getDiff } = await getGitLibraries();
|
|
294
|
+
const { getDiff, resolveDiffSource } = await getGitLibraries();
|
|
295
295
|
try {
|
|
296
296
|
const directory = req.query.directory;
|
|
297
297
|
if (!directory) {
|
|
@@ -303,12 +303,20 @@ export function registerGitRoutes(app) {
|
|
|
303
303
|
return res.status(400).json({ error: 'path parameter is required' });
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
|
|
306
|
+
let source;
|
|
307
|
+
try {
|
|
308
|
+
source = resolveDiffSource({
|
|
309
|
+
source: req.query.source,
|
|
310
|
+
staged: req.query.staged === 'true',
|
|
311
|
+
});
|
|
312
|
+
} catch (error) {
|
|
313
|
+
return res.status(400).json({ error: error.message });
|
|
314
|
+
}
|
|
307
315
|
const context = req.query.context ? parseInt(String(req.query.context), 10) : undefined;
|
|
308
316
|
|
|
309
317
|
const diff = await getDiff(directory, {
|
|
310
318
|
path,
|
|
311
|
-
|
|
319
|
+
source,
|
|
312
320
|
contextLines: Number.isFinite(context) ? context : 3,
|
|
313
321
|
});
|
|
314
322
|
|
|
@@ -11,6 +11,8 @@ const gitLibraries = {
|
|
|
11
11
|
createWorktree: vi.fn(),
|
|
12
12
|
removeWorktree: vi.fn(),
|
|
13
13
|
getWorktreeBootstrapStatus: vi.fn(),
|
|
14
|
+
getDiff: vi.fn(),
|
|
15
|
+
resolveDiffSource: vi.fn(),
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
vi.mock('./index.js', () => ({
|
|
@@ -24,6 +26,8 @@ vi.mock('./index.js', () => ({
|
|
|
24
26
|
createWorktree: gitLibraries.createWorktree,
|
|
25
27
|
removeWorktree: gitLibraries.removeWorktree,
|
|
26
28
|
getWorktreeBootstrapStatus: gitLibraries.getWorktreeBootstrapStatus,
|
|
29
|
+
getDiff: gitLibraries.getDiff,
|
|
30
|
+
resolveDiffSource: gitLibraries.resolveDiffSource,
|
|
27
31
|
}));
|
|
28
32
|
|
|
29
33
|
const { registerGitRoutes } = await import('./routes.js');
|
|
@@ -384,3 +388,79 @@ describe('git routes status discovery', () => {
|
|
|
384
388
|
expect(response.body).toMatchObject({ current: 'main' });
|
|
385
389
|
});
|
|
386
390
|
});
|
|
391
|
+
|
|
392
|
+
describe('git routes diff', () => {
|
|
393
|
+
beforeEach(() => {
|
|
394
|
+
gitLibraries.getDiff.mockReset();
|
|
395
|
+
gitLibraries.resolveDiffSource.mockReset();
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('passes the resolved diff source to getDiff', async () => {
|
|
399
|
+
gitLibraries.resolveDiffSource.mockReturnValue('head');
|
|
400
|
+
gitLibraries.getDiff.mockResolvedValue('patch');
|
|
401
|
+
const { app, getRoute } = createRouteRegistry();
|
|
402
|
+
registerGitRoutes(app);
|
|
403
|
+
const response = createMockResponse();
|
|
404
|
+
|
|
405
|
+
await getRoute('GET', '/api/git/diff')(
|
|
406
|
+
{ query: { directory: '/repo', path: 'file.txt', source: 'head', context: '5' } },
|
|
407
|
+
response,
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
expect(gitLibraries.resolveDiffSource).toHaveBeenCalledWith({ source: 'head', staged: false });
|
|
411
|
+
expect(gitLibraries.getDiff).toHaveBeenCalledWith('/repo', { path: 'file.txt', source: 'head', contextLines: 5 });
|
|
412
|
+
expect(response.statusCode).toBe(200);
|
|
413
|
+
expect(response.body).toEqual({ diff: 'patch' });
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it('keeps staged=true working for older clients', async () => {
|
|
417
|
+
gitLibraries.resolveDiffSource.mockReturnValue('staged');
|
|
418
|
+
gitLibraries.getDiff.mockResolvedValue('');
|
|
419
|
+
const { app, getRoute } = createRouteRegistry();
|
|
420
|
+
registerGitRoutes(app);
|
|
421
|
+
|
|
422
|
+
await getRoute('GET', '/api/git/diff')(
|
|
423
|
+
{ query: { directory: '/repo', path: 'file.txt', staged: 'true' } },
|
|
424
|
+
createMockResponse(),
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
expect(gitLibraries.resolveDiffSource).toHaveBeenCalledWith({ source: undefined, staged: true });
|
|
428
|
+
expect(gitLibraries.getDiff).toHaveBeenCalledWith('/repo', { path: 'file.txt', source: 'staged', contextLines: 3 });
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
it('passes a repeated source key through so the resolver can reject it', async () => {
|
|
432
|
+
gitLibraries.resolveDiffSource.mockImplementation(() => {
|
|
433
|
+
throw new Error('Invalid diff source: head,staged');
|
|
434
|
+
});
|
|
435
|
+
const { app, getRoute } = createRouteRegistry();
|
|
436
|
+
registerGitRoutes(app);
|
|
437
|
+
const response = createMockResponse();
|
|
438
|
+
|
|
439
|
+
await getRoute('GET', '/api/git/diff')(
|
|
440
|
+
{ query: { directory: '/repo', path: 'file.txt', source: ['head', 'staged'] } },
|
|
441
|
+
response,
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
expect(gitLibraries.resolveDiffSource).toHaveBeenCalledWith({ source: ['head', 'staged'], staged: false });
|
|
445
|
+
expect(response.statusCode).toBe(400);
|
|
446
|
+
expect(gitLibraries.getDiff).not.toHaveBeenCalled();
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it('rejects an invalid source with 400 without running git', async () => {
|
|
450
|
+
gitLibraries.resolveDiffSource.mockImplementation(() => {
|
|
451
|
+
throw new Error('Invalid diff source: bogus');
|
|
452
|
+
});
|
|
453
|
+
const { app, getRoute } = createRouteRegistry();
|
|
454
|
+
registerGitRoutes(app);
|
|
455
|
+
const response = createMockResponse();
|
|
456
|
+
|
|
457
|
+
await getRoute('GET', '/api/git/diff')(
|
|
458
|
+
{ query: { directory: '/repo', path: 'file.txt', source: 'bogus' } },
|
|
459
|
+
response,
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
expect(response.statusCode).toBe(400);
|
|
463
|
+
expect(response.body).toEqual({ error: 'Invalid diff source: bogus' });
|
|
464
|
+
expect(gitLibraries.getDiff).not.toHaveBeenCalled();
|
|
465
|
+
});
|
|
466
|
+
});
|
|
@@ -2243,7 +2243,40 @@ export async function getStatus(directory, options = {}) {
|
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
2245
|
|
|
2246
|
-
|
|
2246
|
+
const DIFF_SOURCES = new Set(['unstaged', 'staged', 'head']);
|
|
2247
|
+
|
|
2248
|
+
const EMPTY_TREE_BY_OBJECT_FORMAT = {
|
|
2249
|
+
sha1: '4b825dc642cb6eb9a060e54bf8d69288fbee4904',
|
|
2250
|
+
sha256: '6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321',
|
|
2251
|
+
};
|
|
2252
|
+
|
|
2253
|
+
export function resolveDiffSource({ source, staged = false } = {}) {
|
|
2254
|
+
if (source === undefined || source === null || source === '') {
|
|
2255
|
+
return staged ? 'staged' : 'unstaged';
|
|
2256
|
+
}
|
|
2257
|
+
if (!DIFF_SOURCES.has(source)) {
|
|
2258
|
+
throw new Error(`Invalid diff source: ${source}`);
|
|
2259
|
+
}
|
|
2260
|
+
return source;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
const resolveHeadDiffBase = async (git) => {
|
|
2264
|
+
const head = await git
|
|
2265
|
+
.raw(['rev-parse', '--verify', '--quiet', 'HEAD'])
|
|
2266
|
+
.then((value) => String(value || '').trim())
|
|
2267
|
+
.catch(() => '');
|
|
2268
|
+
if (head) {
|
|
2269
|
+
return 'HEAD';
|
|
2270
|
+
}
|
|
2271
|
+
const objectFormat = await git
|
|
2272
|
+
.raw(['rev-parse', '--show-object-format'])
|
|
2273
|
+
.then((value) => String(value || '').trim())
|
|
2274
|
+
.catch(() => 'sha1');
|
|
2275
|
+
return EMPTY_TREE_BY_OBJECT_FORMAT[objectFormat] ?? EMPTY_TREE_BY_OBJECT_FORMAT.sha1;
|
|
2276
|
+
};
|
|
2277
|
+
|
|
2278
|
+
export async function getDiff(directory, { path: filePath, staged = false, source, contextLines = 3 } = {}) {
|
|
2279
|
+
const diffSource = resolveDiffSource({ source, staged });
|
|
2247
2280
|
const { directoryPath, directoryGit, repoRoot, git } = await createRepositoryGitContext(directory);
|
|
2248
2281
|
|
|
2249
2282
|
try {
|
|
@@ -2254,8 +2287,10 @@ export async function getDiff(directory, { path: filePath, staged = false, conte
|
|
|
2254
2287
|
args.push(`-U${Math.max(0, contextLines)}`);
|
|
2255
2288
|
}
|
|
2256
2289
|
|
|
2257
|
-
if (staged) {
|
|
2290
|
+
if (diffSource === 'staged') {
|
|
2258
2291
|
args.push('--cached');
|
|
2292
|
+
} else if (diffSource === 'head') {
|
|
2293
|
+
args.push(await resolveHeadDiffBase(git));
|
|
2259
2294
|
}
|
|
2260
2295
|
|
|
2261
2296
|
if (fileContext) {
|
|
@@ -2267,7 +2302,7 @@ export async function getDiff(directory, { path: filePath, staged = false, conte
|
|
|
2267
2302
|
return diff;
|
|
2268
2303
|
}
|
|
2269
2304
|
|
|
2270
|
-
if (staged) {
|
|
2305
|
+
if (diffSource === 'staged') {
|
|
2271
2306
|
return diff;
|
|
2272
2307
|
}
|
|
2273
2308
|
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
applyHunk,
|
|
31
31
|
getDiff,
|
|
32
32
|
getFileDiff,
|
|
33
|
+
resolveDiffSource,
|
|
33
34
|
} from './service.js';
|
|
34
35
|
|
|
35
36
|
// ---------------------------------------------------------------------------
|
|
@@ -335,6 +336,98 @@ describe('applyHunk', () => {
|
|
|
335
336
|
});
|
|
336
337
|
});
|
|
337
338
|
|
|
339
|
+
describe.skipIf(!canRunGit())('getDiff sources', () => {
|
|
340
|
+
const createCommittedRepo = async () => {
|
|
341
|
+
const { tmpDir, git } = await createTempRepo();
|
|
342
|
+
await writeFile(tmpDir, 'file.txt', ORIGINAL_FILE);
|
|
343
|
+
await git.add('file.txt');
|
|
344
|
+
await git.commit('Initial');
|
|
345
|
+
return { tmpDir, git };
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
it('shows staged-only changes for the head source', async () => {
|
|
349
|
+
const { tmpDir, git } = await createCommittedRepo();
|
|
350
|
+
await writeFile(tmpDir, 'file.txt', makeFile('TOP', 'line20'));
|
|
351
|
+
await git.add('file.txt');
|
|
352
|
+
|
|
353
|
+
expect(await getDiff(tmpDir, { path: 'file.txt' })).toBe('');
|
|
354
|
+
const diff = await getDiff(tmpDir, { path: 'file.txt', source: 'head' });
|
|
355
|
+
expect(diff).toContain('-line1');
|
|
356
|
+
expect(diff).toContain('+TOP');
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('combines staged and unstaged changes for the head source', async () => {
|
|
360
|
+
const { tmpDir, git } = await createCommittedRepo();
|
|
361
|
+
await writeFile(tmpDir, 'file.txt', makeFile('TOP', 'line20'));
|
|
362
|
+
await git.add('file.txt');
|
|
363
|
+
await writeFile(tmpDir, 'file.txt', EDITED_FILE);
|
|
364
|
+
|
|
365
|
+
const unstaged = await getDiff(tmpDir, { path: 'file.txt', source: 'unstaged' });
|
|
366
|
+
expect(unstaged).not.toContain('+TOP');
|
|
367
|
+
expect(unstaged).toContain('+BOTTOM');
|
|
368
|
+
|
|
369
|
+
const staged = await getDiff(tmpDir, { path: 'file.txt', source: 'staged' });
|
|
370
|
+
expect(staged).toContain('+TOP');
|
|
371
|
+
expect(staged).not.toContain('+BOTTOM');
|
|
372
|
+
|
|
373
|
+
const head = await getDiff(tmpDir, { path: 'file.txt', source: 'head' });
|
|
374
|
+
expect(head).toContain('+TOP');
|
|
375
|
+
expect(head).toContain('+BOTTOM');
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('shows a staged new file with later edits as a whole new file', async () => {
|
|
379
|
+
const { tmpDir, git } = await createCommittedRepo();
|
|
380
|
+
await writeFile(tmpDir, 'new.txt', 'first\n');
|
|
381
|
+
await git.add('new.txt');
|
|
382
|
+
await writeFile(tmpDir, 'new.txt', 'first\nsecond\n');
|
|
383
|
+
|
|
384
|
+
const diff = await getDiff(tmpDir, { path: 'new.txt', source: 'head' });
|
|
385
|
+
expect(diff).toContain('new file mode');
|
|
386
|
+
expect(diff).toContain('+first');
|
|
387
|
+
expect(diff).toContain('+second');
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it('shows untracked and deleted files for the head source', async () => {
|
|
391
|
+
const { tmpDir } = await createCommittedRepo();
|
|
392
|
+
await writeFile(tmpDir, 'untracked.txt', 'hello\n');
|
|
393
|
+
fs.rmSync(path.join(tmpDir, 'file.txt'));
|
|
394
|
+
|
|
395
|
+
expect(await getDiff(tmpDir, { path: 'untracked.txt', source: 'head' })).toContain('+hello');
|
|
396
|
+
const deleted = await getDiff(tmpDir, { path: 'file.txt', source: 'head' });
|
|
397
|
+
expect(deleted).toContain('deleted file mode');
|
|
398
|
+
expect(deleted).toContain('-line1');
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it('diffs against the empty tree before the first commit', async () => {
|
|
402
|
+
const { tmpDir, git } = await createTempRepo();
|
|
403
|
+
await writeFile(tmpDir, 'file.txt', 'staged\n');
|
|
404
|
+
await git.add('file.txt');
|
|
405
|
+
await writeFile(tmpDir, 'file.txt', 'staged\nedited\n');
|
|
406
|
+
|
|
407
|
+
const diff = await getDiff(tmpDir, { path: 'file.txt', source: 'head' });
|
|
408
|
+
expect(diff).toContain('+staged');
|
|
409
|
+
expect(diff).toContain('+edited');
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it('keeps staged: true as the staged source', async () => {
|
|
413
|
+
const { tmpDir, git } = await createCommittedRepo();
|
|
414
|
+
await writeFile(tmpDir, 'file.txt', makeFile('TOP', 'line20'));
|
|
415
|
+
await git.add('file.txt');
|
|
416
|
+
|
|
417
|
+
expect(await getDiff(tmpDir, { path: 'file.txt', staged: true })).toContain('+TOP');
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('rejects a repeated source key instead of falling back', () => {
|
|
421
|
+
expect(() => resolveDiffSource({ source: ['head', 'staged'] })).toThrow('Invalid diff source');
|
|
422
|
+
expect(resolveDiffSource({ source: undefined, staged: true })).toBe('staged');
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it('rejects an unknown source', async () => {
|
|
426
|
+
const { tmpDir } = await createCommittedRepo();
|
|
427
|
+
await expect(getDiff(tmpDir, { path: 'file.txt', source: 'bogus' })).rejects.toThrow('Invalid diff source');
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
|
|
338
431
|
describe('symlink diffs', () => {
|
|
339
432
|
it('treats an untracked directory symlink as a link in patch and split diffs', async () => {
|
|
340
433
|
if (!canRunGit() || process.platform === 'win32') return;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Open requests
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
When a tool on the server machine wants to show the person a URL (an extension starting a review page, `gh auth login --web`, Python's `webbrowser`), PiChamber shows it on the person's devices instead of opening a browser on the server. The mechanism is generic: anything that honors `$BROWSER` takes part, with no per-tool code. See `GLOSSARY.md` ("Open request").
|
|
6
|
+
|
|
7
|
+
## Flow
|
|
8
|
+
|
|
9
|
+
1. `daemon-process.js` calls `ensureOpenUrlBrowser` (`browser-env.js`) before any session starts. It writes an owner-only launcher script and points `$BROWSER` at it, keeping the previous value in `PICHAMBER_ORIGINAL_BROWSER` and the intake path in `PICHAMBER_OPEN_URL_SOCKET`. Every bash command and in-process extension inherits that environment. A watchdog (`watchOpenUrlBrowser`) re-checks the launcher every minute for the life of the daemon.
|
|
10
|
+
2. The launcher runs `browser-handler.mjs` with the URL arguments. Each http(s) URL is posted to the intake together with `PI_SESSION_ID` when the caller is a bash command.
|
|
11
|
+
3. `intake.js`, bound by the PiChamber server (`index.js`) on `<runtimeDir>/open-url.sock`, asks the daemon to publish (`openUrl.publish`). The daemon attributes the request (`session-daemon/open-request.js`) and publishes `session.openUrl` on that session's event stream.
|
|
12
|
+
4. Devices ask the person whether to open it (`packages/ui/src/components/chat/OpenRequestAlerts.tsx`). Nothing opens without a click.
|
|
13
|
+
5. The intake answers `{ delivered }`. `delivered` is true only when a device holds a live `/api/pi/events` stream and the daemon published. Otherwise the handler falls back to the original `$BROWSER` list, then `open` (macOS) or `xdg-open`, with `$BROWSER` restored in that child's environment so it cannot loop back.
|
|
14
|
+
|
|
15
|
+
Extensions in PiChamber can call `ctx.ui.openUrl(url)` (gate with `isPiChamber(ctx)`). It runs the same handler in-process with the exact session id and resolves whether the URL was shown or opened.
|
|
16
|
+
|
|
17
|
+
## Invariants
|
|
18
|
+
|
|
19
|
+
- The intake is a Unix socket in the profile's private runtime directory (directory `0700`, socket `0600`). Filesystem permissions are the only access check; no token is involved. The HTTP app, its auth middleware, and the relay cannot reach it.
|
|
20
|
+
- Only http(s) URLs up to 4096 characters are published. Anything else (a file path, `file:` URL) goes straight to the fallback.
|
|
21
|
+
- A request is never both published and opened on the server: with no connected device the intake skips the daemon.
|
|
22
|
+
- Attribution is exact for bash commands (`PI_SESSION_ID`, when that session is resident). Otherwise the sole busy resident session owns it. Otherwise it rides on the most recently active session with `attributed: false`, and devices only show a notice.
|
|
23
|
+
- `session.openUrl` is never stored in a transcript. The daemon replay log may resend it; the public projection stamps `serverNow` so devices judge age on the server's clock and ignore stale ones.
|
|
24
|
+
- The launcher only lives in a directory owned by this user, not a symlink, and writable by nobody else. Candidates, in order: the intake socket's directory, the daemon's private profile directory, then a fresh `mkdtemp` directory under the system temp directory. The launcher is written through an exclusive temp file and verified (owner, mode, exact contents) before `$BROWSER` points at it.
|
|
25
|
+
- Recovery: the daemon's watchdog reinstalls the launcher when it is missing or changed (temp cleaners, logout removing `XDG_RUNTIME_DIR`). If no candidate is usable, `$BROWSER` goes back to the user's original value and the PiChamber variables are removed. The server likewise re-binds the intake socket when its path disappears. A reboot ends the daemon; the next daemon installs everything afresh, so nothing on disk needs to survive one.
|
|
26
|
+
- Windows does nothing: `$BROWSER` is not installed and the intake does not start. Tools there open the system browser as before.
|
|
27
|
+
|
|
28
|
+
## Known limits
|
|
29
|
+
|
|
30
|
+
- A reused daemon keeps the environment it started with. A daemon started by an older PiChamber has no `$BROWSER` handler until it restarts.
|
|
31
|
+
- The launcher path must contain no whitespace, quotes, or `:`, because many tools split `$BROWSER` on them. When the runtime and profile directories contain one (macOS "Application Support"), the launcher lives under the system temp directory; if that is unsafe too, the feature stays off.
|
|
32
|
+
- Commands already running keep the `$BROWSER` they started with. If the watchdog moves or removes the launcher, only commands started afterwards see the change.
|
|
33
|
+
- A background browser tab counts as a connected device, so the server will not open the URL itself while one is open.
|
|
34
|
+
- Tools that call `open` or `xdg-open` directly, without `$BROWSER`, are not intercepted.
|
|
35
|
+
- Only Pi runtimes are attributed; sessions owned by other engines receive unattributed requests.
|