@herbertgao/pi-extensions 2026.10.13 → 2026.10.15
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/README.md +16 -14
- package/THIRD_PARTY_NOTICES.md +3 -3
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +1 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +3 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +22 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +44 -14
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +1 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +20 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +4 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +42 -18
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/layout.ts +12 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +131 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +217 -113
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +12 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/subagent-notification.ts +556 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +50 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/format.ts +11 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/patch-keys.ts +4 -0
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +1 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +27 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/config.ts +23 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +15 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +9 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/de.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +8 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/es.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/fr.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt-BR.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/ru.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/uk.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +7 -4
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +4 -3
- package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +11 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +6 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +49 -8
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +6 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +13 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +2 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +19 -7
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +36 -7
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +13 -2
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +24 -8
- package/node_modules/@juicesharp/rpiv-ask-user-question/view/transcript.ts +144 -0
- package/node_modules/@narumitw/pi-btw/README.md +8 -3
- package/node_modules/@narumitw/pi-btw/dist/index.ts +448 -182
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
- package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +10 -2
- package/node_modules/@narumitw/pi-btw/docs/main-context-runtime.md +45 -0
- package/node_modules/@narumitw/pi-btw/docs/workflows.md +48 -5
- package/node_modules/@narumitw/pi-btw/package.json +5 -5
- package/node_modules/@narumitw/pi-btw/src/btw.ts +39 -14
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +83 -63
- package/node_modules/@narumitw/pi-btw/src/import-main-updates.ts +84 -0
- package/node_modules/@narumitw/pi-btw/src/keybindings.ts +29 -4
- package/node_modules/@narumitw/pi-btw/src/main-context-snapshot.ts +125 -0
- package/node_modules/@narumitw/pi-btw/src/menu.ts +1 -0
- package/node_modules/@narumitw/pi-btw/src/side-thread.ts +66 -17
- package/node_modules/@narumitw/pi-btw/src/transcript-markdown.ts +5 -5
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +47 -6
- package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
- package/node_modules/pi-lens/CHANGELOG.md +440 -0
- package/node_modules/pi-lens/README.md +13 -3
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/node_modules/pi-lens/dist/chunk-22Y2BM7H.js +23 -0
- package/node_modules/pi-lens/dist/{chunk-ATKJFDQN.js → chunk-27VWVB23.js} +12 -14
- package/node_modules/pi-lens/dist/{chunk-S2HEXIWI.js → chunk-2FYKETQJ.js} +10 -6
- package/node_modules/pi-lens/dist/{chunk-SRYEJNES.js → chunk-2LDMXL2M.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-ZHH37KZL.js → chunk-2SDHYHHO.js} +17 -17
- package/node_modules/pi-lens/dist/chunk-2Y6OJRSI.js +38 -0
- package/node_modules/pi-lens/dist/chunk-3SNDVPOR.js +507 -0
- package/node_modules/pi-lens/dist/{chunk-5OFV52AM.js → chunk-3WCEHYOI.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-44X7VIKR.js +73 -0
- package/node_modules/pi-lens/dist/{chunk-DEL2U6CM.js → chunk-4FHUGDKU.js} +16 -14
- package/node_modules/pi-lens/dist/{chunk-CT4MN5IU.js → chunk-4ODSZ35Z.js} +353 -359
- package/node_modules/pi-lens/dist/{chunk-ZIVJBOO3.js → chunk-4U7GDSZQ.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-54NIOJJZ.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-N5FLEO7W.js → chunk-5DKE4HGX.js} +37 -37
- package/node_modules/pi-lens/dist/{chunk-P63GXC37.js → chunk-5LRUKYFA.js} +31 -4
- package/node_modules/pi-lens/dist/{chunk-HRNHZA3N.js → chunk-63NMUNYP.js} +12 -16
- package/node_modules/pi-lens/dist/{chunk-HWCCCQNX.js → chunk-6XSESGWD.js} +13 -6
- package/node_modules/pi-lens/dist/{chunk-UMS2MFPZ.js → chunk-72J27ICO.js} +2 -3
- package/node_modules/pi-lens/dist/{chunk-ED36RF6Y.js → chunk-7FLRUH6B.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-7IYC4ENJ.js +297 -0
- package/node_modules/pi-lens/dist/chunk-7WWQAW5P.js +30 -0
- package/node_modules/pi-lens/dist/{chunk-3DA2JDOL.js → chunk-7ZS7MC24.js} +551 -203
- package/node_modules/pi-lens/dist/{chunk-WMYE35PX.js → chunk-AHWA4AKM.js} +7 -5
- package/node_modules/pi-lens/dist/{chunk-JW3YWBVB.js → chunk-AI3GP74G.js} +17 -19
- package/node_modules/pi-lens/dist/{chunk-AGSS7277.js → chunk-APFJKOP6.js} +6 -23
- package/node_modules/pi-lens/dist/{chunk-ZVUL7QYY.js → chunk-ASRAO7KG.js} +29 -32
- package/node_modules/pi-lens/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
- package/node_modules/pi-lens/dist/{chunk-TLX72JTG.js → chunk-CG5V25HX.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-CKEQFGLT.js +32 -0
- package/node_modules/pi-lens/dist/{chunk-Y6GZHWSJ.js → chunk-COOUUC5W.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-XTBDCR27.js → chunk-CPZ5JJW6.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-RKKOYPRA.js → chunk-DS2USX5G.js} +13 -15
- package/node_modules/pi-lens/dist/chunk-EA2ZRG44.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-GSLNCYGG.js → chunk-EDMLIW6W.js} +13 -14
- package/node_modules/pi-lens/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
- package/node_modules/pi-lens/dist/chunk-EKNWOL2I.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-R3T7CLQ2.js → chunk-ELZRSR5N.js} +41 -41
- package/node_modules/pi-lens/dist/{chunk-GMX5OS7B.js → chunk-EN5AM7PX.js} +11 -12
- package/node_modules/pi-lens/dist/{chunk-3RKP3FMS.js → chunk-EWXXLS26.js} +226 -24
- package/node_modules/pi-lens/dist/chunk-EX4EXBW7.js +37 -0
- package/node_modules/pi-lens/dist/{chunk-XHJBS436.js → chunk-EXVXBSGN.js} +25 -25
- package/node_modules/pi-lens/dist/{chunk-MZGQNL3Y.js → chunk-F7BO6FWH.js} +12 -13
- package/node_modules/pi-lens/dist/{chunk-V35JG4JB.js → chunk-FEDWAYDS.js} +152 -334
- package/node_modules/pi-lens/dist/{chunk-J64T55EI.js → chunk-FWZRGGGY.js} +73 -9
- package/node_modules/pi-lens/dist/{chunk-T57LYLZT.js → chunk-G224FADB.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-G5UCJFT7.js +26 -0
- package/node_modules/pi-lens/dist/{chunk-LLJNQKQW.js → chunk-GLW3YDZZ.js} +20 -13
- package/node_modules/pi-lens/dist/{chunk-GXFV6MYU.js → chunk-GTDSYEA2.js} +72 -39
- package/node_modules/pi-lens/dist/{chunk-DUO2TU77.js → chunk-GYRZ72R4.js} +10 -4
- package/node_modules/pi-lens/dist/chunk-HYVXA3BB.js +49 -0
- package/node_modules/pi-lens/dist/{chunk-W66O5E25.js → chunk-IEBJF3PN.js} +13 -15
- package/node_modules/pi-lens/dist/{chunk-GAQ7OQG6.js → chunk-IL7K66ZQ.js} +83 -94
- package/node_modules/pi-lens/dist/{chunk-T7FEBKXN.js → chunk-JWOVP5BL.js} +7 -9
- package/node_modules/pi-lens/dist/{chunk-UBOQLVT2.js → chunk-K2GUZ4DN.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-5VSF4UUQ.js → chunk-K4SZB56V.js} +34 -39
- package/node_modules/pi-lens/dist/{chunk-7D6L4MTX.js → chunk-KCBRHV5E.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-GSM5UU7A.js → chunk-KFXCL4OV.js} +38 -28
- package/node_modules/pi-lens/dist/{chunk-J6MPGQTS.js → chunk-KJJAVH3X.js} +81 -15
- package/node_modules/pi-lens/dist/{chunk-BWD5EPKO.js → chunk-KPVLQHCZ.js} +4 -6
- package/node_modules/pi-lens/dist/{chunk-MPNJLASA.js → chunk-KX56K73G.js} +10 -13
- package/node_modules/pi-lens/dist/{chunk-AWSCPCN2.js → chunk-LMCTHJ2H.js} +19 -19
- package/node_modules/pi-lens/dist/{chunk-IWDLU6K3.js → chunk-MEFLGBCS.js} +4 -6
- package/node_modules/pi-lens/dist/{chunk-TOY6QKOH.js → chunk-MKPCELNI.js} +17 -17
- package/node_modules/pi-lens/dist/{chunk-POMLXPMY.js → chunk-N3PLNNCW.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-N5FBM25N.js +22 -0
- package/node_modules/pi-lens/dist/{chunk-CYRKQRPM.js → chunk-NFNVDDGB.js} +2 -4
- package/node_modules/pi-lens/dist/{chunk-RMLC67LF.js → chunk-NLIVE7L6.js} +2 -30
- package/node_modules/pi-lens/dist/{chunk-24AKHFGP.js → chunk-OMJ3OFBJ.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-IQWN5JCP.js → chunk-OZNCKLOX.js} +13 -14
- package/node_modules/pi-lens/dist/chunk-P5XUGPIX.js +31 -0
- package/node_modules/pi-lens/dist/{chunk-2KXTHF3M.js → chunk-PJXNTPB2.js} +253 -33
- package/node_modules/pi-lens/dist/chunk-PKOXJIVT.js +88 -0
- package/node_modules/pi-lens/dist/{chunk-DGUKIYSI.js → chunk-PP2A5V2T.js} +8 -10
- package/node_modules/pi-lens/dist/{chunk-KAPJINKN.js → chunk-Q42LJANT.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-UZ2XCLYS.js → chunk-Q4BKKOVC.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-TIQ2PKDW.js → chunk-QT66NEYN.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-U44DJXQP.js → chunk-RCHO5W7M.js} +15 -18
- package/node_modules/pi-lens/dist/{chunk-YH5MVY2U.js → chunk-RG3MXTRI.js} +7 -7
- package/node_modules/pi-lens/dist/chunk-RG7OODGM.js +57 -0
- package/node_modules/pi-lens/dist/{chunk-OHKJ7PQF.js → chunk-RU34BA4D.js} +43 -39
- package/node_modules/pi-lens/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
- package/node_modules/pi-lens/dist/{chunk-XBJVAEEO.js → chunk-S55TEC7I.js} +3 -2
- package/node_modules/pi-lens/dist/{chunk-RVK72CZX.js → chunk-SJHC3BCZ.js} +1397 -481
- package/node_modules/pi-lens/dist/{chunk-IYNJ6YPZ.js → chunk-SNEUMLM7.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-S67KYG37.js → chunk-T4NGVFYI.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-YCWYO6TQ.js → chunk-THEXI2QO.js} +48 -45
- package/node_modules/pi-lens/dist/{chunk-AMERCH6V.js → chunk-TL2TCJYL.js} +15 -16
- package/node_modules/pi-lens/dist/{chunk-KUA4OJ5Y.js → chunk-TPYYEDP5.js} +823 -350
- package/node_modules/pi-lens/dist/{chunk-YNE3RP52.js → chunk-TVZRLTG6.js} +8 -1
- package/node_modules/pi-lens/dist/{chunk-ROYSX2S5.js → chunk-UCVMSOXF.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-UL5SXQVX.js +32 -0
- package/node_modules/pi-lens/dist/{chunk-7HXE67BN.js → chunk-UO66IMVP.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-VOOAPROD.js → chunk-UVY4TOJH.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-RKBXZN3A.js → chunk-VIDEKABZ.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-2FN63LPV.js → chunk-VITFDI3O.js} +13 -14
- package/node_modules/pi-lens/dist/{chunk-6DLWKFEX.js → chunk-VUAVE3QC.js} +41 -42
- package/node_modules/pi-lens/dist/{chunk-FM4RDMKT.js → chunk-WUY4BZEP.js} +10 -12
- package/node_modules/pi-lens/dist/{chunk-SD4I7ZO4.js → chunk-X3UTCXAA.js} +43 -53
- package/node_modules/pi-lens/dist/chunk-XHDBJODR.js +45 -0
- package/node_modules/pi-lens/dist/{chunk-5IUSNGOC.js → chunk-XHLK33VM.js} +28 -21
- package/node_modules/pi-lens/dist/{chunk-3KAZU3VR.js → chunk-XI34NWDI.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QBFBRV2B.js → chunk-XWFIHYCH.js} +4 -2
- package/node_modules/pi-lens/dist/{chunk-JUKMK5Y4.js → chunk-Y2TPADJR.js} +10 -11
- package/node_modules/pi-lens/dist/{chunk-EBC36LNN.js → chunk-Y5KTA2OB.js} +17 -17
- package/node_modules/pi-lens/dist/{chunk-HYGZEMX6.js → chunk-YKVDBNPO.js} +11 -5
- package/node_modules/pi-lens/dist/{chunk-KN35K52N.js → chunk-YSDPVDFC.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-YWNO5Q4R.js +44 -0
- package/node_modules/pi-lens/dist/{chunk-US7ECLD7.js → chunk-YWWG4AQA.js} +119 -28
- package/node_modules/pi-lens/dist/{chunk-O4NWQT6I.js → chunk-YXDCRUKQ.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-XYURS6EN.js → chunk-YXGRRORB.js} +15 -17
- package/node_modules/pi-lens/dist/{chunk-IUE7SSKV.js → chunk-ZAPSUBLU.js} +13 -7
- package/node_modules/pi-lens/dist/{chunk-EUXZEFTV.js → chunk-ZPJM7DID.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-5HSRT26B.js → chunk-ZSUX7KEM.js} +16 -15
- package/node_modules/pi-lens/dist/index.js +37155 -32210
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +11 -12
- package/node_modules/pi-lens/dist/mcp/cli.js +46 -45
- package/node_modules/pi-lens/dist/mcp/server.js +1210 -574
- package/node_modules/pi-lens/dist/mcp/worker.js +65 -65
- package/node_modules/pi-lens/dist/probes/installer.js +21 -23
- package/node_modules/pi-lens/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
- package/node_modules/pi-lens/docs/adr/README.md +1 -0
- package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +5 -3
- package/node_modules/pi-lens/docs/configuration.md +9 -0
- package/node_modules/pi-lens/docs/engineering-principles.md +12 -0
- package/node_modules/pi-lens/docs/environment-variables.md +20 -0
- package/node_modules/pi-lens/docs/features.md +16 -1
- package/node_modules/pi-lens/docs/globalconfig.md +37 -8
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +105 -12
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +37 -18
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +22 -1
- package/node_modules/pi-lens/docs/pi-lens-investigator.md +14 -0
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +23 -10
- package/node_modules/pi-lens/docs/pi-lens-monitor.md +64 -8
- package/node_modules/pi-lens/docs/pi-lens-retro.md +2 -2
- package/node_modules/pi-lens/docs/pi-lens-reviewer.md +48 -1
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +8 -1
- package/node_modules/pi-lens/docs/release-qa-baseline.md +19 -7
- package/node_modules/pi-lens/docs/servercapabilities.md +47 -47
- package/node_modules/pi-lens/docs/settings.md +9 -5
- package/node_modules/pi-lens/docs/subagent-compat.md +1 -1
- package/node_modules/pi-lens/docs/usage.md +1 -0
- package/node_modules/pi-lens/package.json +6 -4
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
- package/node_modules/pi-lens/rules/rule-catalog.json +25 -1
- package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +15 -5
- package/node_modules/pi-lens/scripts/lib/is-main-module.mjs +27 -0
- package/node_modules/pi-lens/scripts/lib/scratch-home-env.mjs +21 -0
- package/node_modules/pi-lens/scripts/rpc-load-check.mjs +4 -6
- package/node_modules/pi-lens/scripts/warm-loader-cache.mjs +2 -5
- package/node_modules/pi-next-cue/package.json +4 -1
- package/node_modules/pi-typesafe/README.md +6 -6
- package/node_modules/pi-typesafe/dist/ask.js +9 -2
- package/node_modules/pi-typesafe/dist/auth.d.ts +3 -2
- package/node_modules/pi-typesafe/dist/auth.js +2 -2
- package/node_modules/pi-typesafe/dist/backends.d.ts +20 -5
- package/node_modules/pi-typesafe/dist/backends.js +32 -8
- package/node_modules/pi-typesafe/dist/batch.d.ts +1 -1
- package/node_modules/pi-typesafe/dist/batch.js +2 -2
- package/node_modules/pi-typesafe/dist/client.d.ts +1 -1
- package/node_modules/pi-typesafe/dist/client.js +24 -12
- package/node_modules/pi-typesafe/dist/credentials.d.ts +8 -6
- package/node_modules/pi-typesafe/dist/credentials.js +70 -16
- package/node_modules/pi-typesafe/dist/extension.js +118 -26
- package/node_modules/pi-typesafe/dist/index.d.ts +1 -1
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/dist/key-prompt.d.ts +1 -1
- package/node_modules/pi-typesafe/dist/key-prompt.js +6 -6
- package/node_modules/pi-typesafe/dist/login.d.ts +11 -10
- package/node_modules/pi-typesafe/dist/login.js +24 -21
- package/node_modules/pi-typesafe/dist/schema.d.ts +8 -8
- package/node_modules/pi-typesafe/dist/schema.js +29 -7
- package/node_modules/pi-typesafe/package.json +2 -2
- package/node_modules/pi-web-access/CHANGELOG.md +40 -0
- package/node_modules/pi-web-access/README.md +96 -22
- package/node_modules/pi-web-access/brave-rate-limit.ts +2 -2
- package/node_modules/pi-web-access/curator-page.ts +3 -1
- package/node_modules/pi-web-access/curator-server.ts +1 -0
- package/node_modules/pi-web-access/dist/index.js +2607 -1674
- package/node_modules/pi-web-access/dist/mcp-cli.js +1119 -327
- package/node_modules/pi-web-access/duckduckgo-rate-limit.ts +95 -0
- package/node_modules/pi-web-access/duckduckgo.ts +51 -45
- package/node_modules/pi-web-access/exa.ts +48 -6
- package/node_modules/pi-web-access/extract.ts +2 -2
- package/node_modules/pi-web-access/fetch-params.ts +5 -4
- package/node_modules/pi-web-access/field-extract.ts +347 -0
- package/node_modules/pi-web-access/gemini-search.ts +151 -13
- package/node_modules/pi-web-access/index.ts +128 -125
- package/node_modules/pi-web-access/mistral-search.ts +1 -1
- package/node_modules/pi-web-access/ninerouter.ts +92 -0
- package/node_modules/pi-web-access/offtopic-judge.ts +72 -0
- package/node_modules/pi-web-access/openai-search.ts +36 -10
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/perplexity.ts +1 -0
- package/node_modules/pi-web-access/query-rewrite.ts +39 -13
- package/node_modules/pi-web-access/source-check.ts +31 -15
- package/node_modules/pi-web-access/summary-model-scope.ts +19 -1
- package/node_modules/pi-web-access/summary-review.ts +13 -20
- package/node_modules/pi-web-access/tool-arguments.ts +1 -1
- package/node_modules/pi-web-access/upgrade-notice.ts +47 -0
- package/node_modules/pi-web-access/utils.ts +26 -1
- package/node_modules/pi-web-access/web-tool-contract.ts +4 -1
- package/node_modules/pi-web-access/web-tool-core.ts +99 -19
- package/node_modules/pi-web-access/xai-search.ts +3 -3
- package/package.json +15 -15
- package/node_modules/pi-lens/dist/chunk-3PTHXJXR.js +0 -28
- package/node_modules/pi-lens/dist/chunk-3QED2P4V.js +0 -31
- package/node_modules/pi-lens/dist/chunk-5WRPDP2A.js +0 -47
- package/node_modules/pi-lens/dist/chunk-ABBOA7UD.js +0 -157
- package/node_modules/pi-lens/dist/chunk-CUHSHSB6.js +0 -273
- package/node_modules/pi-lens/dist/chunk-GL5LUMZE.js +0 -51
- package/node_modules/pi-lens/dist/chunk-HAD7QRQI.js +0 -30
- package/node_modules/pi-lens/dist/chunk-JORED7EX.js +0 -44
- package/node_modules/pi-lens/dist/chunk-KYUB6QDC.js +0 -72
- package/node_modules/pi-lens/dist/chunk-LZSEQW6A.js +0 -57
- package/node_modules/pi-lens/dist/chunk-M2IFVFWU.js +0 -79
- package/node_modules/pi-lens/dist/chunk-M2UD3LPU.js +0 -88
- package/node_modules/pi-lens/dist/chunk-MBKQHGA7.js +0 -39
- package/node_modules/pi-lens/dist/chunk-R7YOCSNV.js +0 -23
- package/node_modules/pi-lens/dist/chunk-SKAMFC7A.js +0 -28
- package/node_modules/pi-lens/dist/chunk-SYE6T2EB.js +0 -28
- package/node_modules/pi-lens/dist/chunk-TRETHTQO.js +0 -26
- package/node_modules/pi-lens/dist/chunk-UA7ZXYDR.js +0 -184
- package/node_modules/pi-lens/dist/chunk-XTFDJI3T.js +0 -24
- package/node_modules/pi-lens/dist/chunk-Z3CCVDUB.js +0 -76
- package/node_modules/pi-next-cue/.github/workflows/publish.yml +0 -20
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
PathKeyedMap,
|
|
3
4
|
detectFileRole,
|
|
4
5
|
findNestedProjectMutationValue,
|
|
5
6
|
findPiLensConfigInDir,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
reportPiLensConfigRecords,
|
|
13
14
|
resolveOnePiLensConfigDocument,
|
|
14
15
|
warnIgnoredConfigOnce
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KJJAVH3X.js";
|
|
16
17
|
import {
|
|
17
18
|
CANONICAL_GLOBAL_CONFIG_FILE,
|
|
18
19
|
FRESHNESS_CADENCE_MS,
|
|
@@ -22,16 +23,19 @@ import {
|
|
|
22
23
|
errorClassName,
|
|
23
24
|
getPiLensGlobalConfigPath,
|
|
24
25
|
getProductionGlobalConfigResolution
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ZSUX7KEM.js";
|
|
26
27
|
import {
|
|
27
28
|
DEFAULT_MAX_OUTPUT_BYTES,
|
|
28
29
|
createBoundedOutputSink,
|
|
30
|
+
getProjectTrustState,
|
|
29
31
|
truncatedByOutputCap,
|
|
32
|
+
writeFileAtomic,
|
|
30
33
|
writeFileAtomicAsync
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-EIKRZ32J.js";
|
|
32
35
|
import {
|
|
33
36
|
GLOBAL_NON_FLAG_CONFIG_SECTIONS,
|
|
34
37
|
LENS_FLAGS,
|
|
38
|
+
PROJECT_NON_FLAG_CONFIG_SECTIONS,
|
|
35
39
|
assignFlagConfigSection,
|
|
36
40
|
compareOrdinal,
|
|
37
41
|
flagConfigSectionKeys,
|
|
@@ -39,39 +43,47 @@ import {
|
|
|
39
43
|
getLensFlagSpec,
|
|
40
44
|
incrementDegradationCount,
|
|
41
45
|
readFlagConfigValue,
|
|
46
|
+
readLazyToolsSetting,
|
|
42
47
|
readToolConfig,
|
|
43
48
|
recordDegradation,
|
|
44
49
|
recordDegradationOnce
|
|
45
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-FWZRGGGY.js";
|
|
46
51
|
import {
|
|
47
52
|
logExtension
|
|
48
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-N3PLNNCW.js";
|
|
49
54
|
import {
|
|
50
55
|
logLatency
|
|
51
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-XWFIHYCH.js";
|
|
52
57
|
import {
|
|
53
|
-
getProcessSingleton
|
|
54
|
-
|
|
58
|
+
getProcessSingleton,
|
|
59
|
+
machineStateDir
|
|
60
|
+
} from "./chunk-TVZRLTG6.js";
|
|
55
61
|
import {
|
|
62
|
+
STAGE_TMP_PATTERN,
|
|
63
|
+
stagePathFor,
|
|
56
64
|
sweepOwnStagingFiles
|
|
57
65
|
} from "./chunk-LJDODBBZ.js";
|
|
58
66
|
import {
|
|
59
67
|
BoundedFifoMap,
|
|
60
|
-
BoundedSet
|
|
61
|
-
} from "./chunk-ABBOA7UD.js";
|
|
62
|
-
import {
|
|
68
|
+
BoundedSet,
|
|
63
69
|
Minimatch,
|
|
64
70
|
homeRelativePath,
|
|
71
|
+
isAtOrAboveHomeDir,
|
|
65
72
|
isExternalOrVendorFile,
|
|
66
73
|
isFullyQualifiedWin32,
|
|
67
74
|
isRealGitMarker,
|
|
68
75
|
isUnderDir,
|
|
76
|
+
isWithinForm,
|
|
69
77
|
normalizeEphemeralMapKey,
|
|
70
78
|
normalizeFilePath,
|
|
71
79
|
normalizeLoggedPath,
|
|
72
80
|
normalizeMapKey,
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
normalizePathSpelling,
|
|
82
|
+
pathsEqual,
|
|
83
|
+
realpathOrResolve,
|
|
84
|
+
toProjectRelativePath,
|
|
85
|
+
walkUpDirs
|
|
86
|
+
} from "./chunk-EWXXLS26.js";
|
|
75
87
|
import {
|
|
76
88
|
__commonJS,
|
|
77
89
|
__require,
|
|
@@ -205,10 +217,10 @@ var require_history = __commonJS({
|
|
|
205
217
|
var require_ps = __commonJS({
|
|
206
218
|
"node_modules/pidusage/lib/ps.js"(exports, module) {
|
|
207
219
|
"use strict";
|
|
208
|
-
var
|
|
220
|
+
var os4 = __require("os");
|
|
209
221
|
var bin = require_bin();
|
|
210
222
|
var history = require_history();
|
|
211
|
-
var PLATFORM =
|
|
223
|
+
var PLATFORM = os4.platform();
|
|
212
224
|
function parseTime(timestr, centisec) {
|
|
213
225
|
let time = 0;
|
|
214
226
|
const tpart = timestr.split(/-|:|\./);
|
|
@@ -253,7 +265,7 @@ var require_ps = __commonJS({
|
|
|
253
265
|
return done(new Error("pidusage ps command exited with code " + code));
|
|
254
266
|
}
|
|
255
267
|
const date = Date.now();
|
|
256
|
-
stdout = stdout.split(
|
|
268
|
+
stdout = stdout.split(os4.EOL);
|
|
257
269
|
const statistics = {};
|
|
258
270
|
for (let i = 1; i < stdout.length; i++) {
|
|
259
271
|
const line = stdout[i].trim().split(/\s+/);
|
|
@@ -334,8 +346,8 @@ var require_parallel = __commonJS({
|
|
|
334
346
|
// node_modules/pidusage/lib/helpers/cpu.js
|
|
335
347
|
var require_cpu = __commonJS({
|
|
336
348
|
"node_modules/pidusage/lib/helpers/cpu.js"(exports, module) {
|
|
337
|
-
var
|
|
338
|
-
var
|
|
349
|
+
var os4 = __require("os");
|
|
350
|
+
var fs10 = __require("fs");
|
|
339
351
|
var exec = __require("child_process").exec;
|
|
340
352
|
var parallel = require_parallel();
|
|
341
353
|
function updateCpu(cpu, next) {
|
|
@@ -362,12 +374,12 @@ var require_cpu = __commonJS({
|
|
|
362
374
|
}
|
|
363
375
|
module.exports = updateCpu;
|
|
364
376
|
function getRealUptime(next) {
|
|
365
|
-
|
|
377
|
+
fs10.readFile("/proc/uptime", "utf8", function(err, uptime) {
|
|
366
378
|
if (err || uptime === void 0) {
|
|
367
379
|
if (!process.env.PIDUSAGE_SILENT) {
|
|
368
380
|
console.warn("[pidusage] We couldn't find uptime from /proc/uptime, using os.uptime() value");
|
|
369
381
|
}
|
|
370
|
-
return next(null,
|
|
382
|
+
return next(null, os4.uptime() || /* @__PURE__ */ new Date() / 1e3);
|
|
371
383
|
}
|
|
372
384
|
return next(null, parseFloat(uptime.split(" ")[0]));
|
|
373
385
|
});
|
|
@@ -407,101 +419,42 @@ var require_cpu = __commonJS({
|
|
|
407
419
|
}
|
|
408
420
|
});
|
|
409
421
|
|
|
410
|
-
// node_modules/safe-buffer/index.js
|
|
411
|
-
var require_safe_buffer = __commonJS({
|
|
412
|
-
"node_modules/safe-buffer/index.js"(exports, module) {
|
|
413
|
-
var buffer = __require("buffer");
|
|
414
|
-
var Buffer2 = buffer.Buffer;
|
|
415
|
-
function copyProps(src, dst) {
|
|
416
|
-
for (var key in src) {
|
|
417
|
-
dst[key] = src[key];
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
|
|
421
|
-
module.exports = buffer;
|
|
422
|
-
} else {
|
|
423
|
-
copyProps(buffer, exports);
|
|
424
|
-
exports.Buffer = SafeBuffer;
|
|
425
|
-
}
|
|
426
|
-
function SafeBuffer(arg, encodingOrOffset, length) {
|
|
427
|
-
return Buffer2(arg, encodingOrOffset, length);
|
|
428
|
-
}
|
|
429
|
-
SafeBuffer.prototype = Object.create(Buffer2.prototype);
|
|
430
|
-
copyProps(Buffer2, SafeBuffer);
|
|
431
|
-
SafeBuffer.from = function(arg, encodingOrOffset, length) {
|
|
432
|
-
if (typeof arg === "number") {
|
|
433
|
-
throw new TypeError("Argument must not be a number");
|
|
434
|
-
}
|
|
435
|
-
return Buffer2(arg, encodingOrOffset, length);
|
|
436
|
-
};
|
|
437
|
-
SafeBuffer.alloc = function(size, fill, encoding) {
|
|
438
|
-
if (typeof size !== "number") {
|
|
439
|
-
throw new TypeError("Argument must be a number");
|
|
440
|
-
}
|
|
441
|
-
var buf = Buffer2(size);
|
|
442
|
-
if (fill !== void 0) {
|
|
443
|
-
if (typeof encoding === "string") {
|
|
444
|
-
buf.fill(fill, encoding);
|
|
445
|
-
} else {
|
|
446
|
-
buf.fill(fill);
|
|
447
|
-
}
|
|
448
|
-
} else {
|
|
449
|
-
buf.fill(0);
|
|
450
|
-
}
|
|
451
|
-
return buf;
|
|
452
|
-
};
|
|
453
|
-
SafeBuffer.allocUnsafe = function(size) {
|
|
454
|
-
if (typeof size !== "number") {
|
|
455
|
-
throw new TypeError("Argument must be a number");
|
|
456
|
-
}
|
|
457
|
-
return Buffer2(size);
|
|
458
|
-
};
|
|
459
|
-
SafeBuffer.allocUnsafeSlow = function(size) {
|
|
460
|
-
if (typeof size !== "number") {
|
|
461
|
-
throw new TypeError("Argument must be a number");
|
|
462
|
-
}
|
|
463
|
-
return buffer.SlowBuffer(size);
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
|
|
468
422
|
// node_modules/pidusage/lib/procfile.js
|
|
469
423
|
var require_procfile = __commonJS({
|
|
470
424
|
"node_modules/pidusage/lib/procfile.js"(exports, module) {
|
|
471
|
-
var
|
|
472
|
-
var
|
|
425
|
+
var fs10 = __require("fs");
|
|
426
|
+
var path13 = __require("path");
|
|
473
427
|
var updateCpu = require_cpu();
|
|
474
428
|
var parallel = require_parallel();
|
|
475
429
|
var history = require_history();
|
|
476
430
|
var cpuInfo = null;
|
|
477
|
-
var Buffer2 = require_safe_buffer().Buffer;
|
|
478
431
|
var SIZE = 1024;
|
|
479
432
|
function noop() {
|
|
480
433
|
}
|
|
481
|
-
function open(
|
|
434
|
+
function open(path14, history2, cb) {
|
|
482
435
|
if (history2.fd) {
|
|
483
436
|
return cb(null, history2.fd);
|
|
484
437
|
}
|
|
485
|
-
|
|
438
|
+
fs10.open(path14, "r", cb);
|
|
486
439
|
}
|
|
487
440
|
function close(history2) {
|
|
488
441
|
if (history2.fd) {
|
|
489
|
-
|
|
442
|
+
fs10.close(history2.fd, noop);
|
|
490
443
|
}
|
|
491
444
|
}
|
|
492
445
|
function readUntilEnd(fd, buf, cb) {
|
|
493
446
|
let firstRead = false;
|
|
494
447
|
if (typeof buf === "function") {
|
|
495
448
|
cb = buf;
|
|
496
|
-
buf =
|
|
449
|
+
buf = Buffer.alloc(SIZE);
|
|
497
450
|
firstRead = true;
|
|
498
451
|
}
|
|
499
|
-
|
|
452
|
+
fs10.read(fd, buf, 0, SIZE, 0, function(err, bytesRead, buffer) {
|
|
500
453
|
if (err) {
|
|
501
454
|
cb(err);
|
|
502
455
|
return;
|
|
503
456
|
}
|
|
504
|
-
const data =
|
|
457
|
+
const data = Buffer.concat([buf, buffer], firstRead ? bytesRead : buf.length + bytesRead);
|
|
505
458
|
if (bytesRead === SIZE) {
|
|
506
459
|
readUntilEnd(fd, data, cb);
|
|
507
460
|
return;
|
|
@@ -516,7 +469,7 @@ var require_procfile = __commonJS({
|
|
|
516
469
|
again = true;
|
|
517
470
|
hst = {};
|
|
518
471
|
}
|
|
519
|
-
open(
|
|
472
|
+
open(path13.join("/proc", "" + pid, "stat"), hst, function(err, fd) {
|
|
520
473
|
if (err) {
|
|
521
474
|
if (err.code === "ENOENT") {
|
|
522
475
|
err.message = "No matching pid found";
|
|
@@ -587,7 +540,7 @@ var require_procfile = __commonJS({
|
|
|
587
540
|
var require_wmic = __commonJS({
|
|
588
541
|
"node_modules/pidusage/lib/wmic.js"(exports, module) {
|
|
589
542
|
"use strict";
|
|
590
|
-
var
|
|
543
|
+
var os4 = __require("os");
|
|
591
544
|
var bin = require_bin();
|
|
592
545
|
var history = require_history();
|
|
593
546
|
function parseDate(datestr) {
|
|
@@ -631,8 +584,8 @@ var require_wmic = __commonJS({
|
|
|
631
584
|
return done(new Error("pidusage wmic command exited with code " + code));
|
|
632
585
|
}
|
|
633
586
|
const date = Date.now();
|
|
634
|
-
const uptime = Math.floor(
|
|
635
|
-
stdout = stdout.split(
|
|
587
|
+
const uptime = Math.floor(os4.uptime() || date / 1e3);
|
|
588
|
+
stdout = stdout.split(os4.EOL);
|
|
636
589
|
let again = false;
|
|
637
590
|
const statistics = {};
|
|
638
591
|
for (let i = 1; i < stdout.length; i++) {
|
|
@@ -682,7 +635,7 @@ var require_wmic = __commonJS({
|
|
|
682
635
|
var require_gwmi = __commonJS({
|
|
683
636
|
"node_modules/pidusage/lib/gwmi.js"(exports, module) {
|
|
684
637
|
"use strict";
|
|
685
|
-
var
|
|
638
|
+
var os4 = __require("os");
|
|
686
639
|
var bin = require_bin();
|
|
687
640
|
var history = require_history();
|
|
688
641
|
function parseDate(datestr) {
|
|
@@ -707,8 +660,8 @@ var require_gwmi = __commonJS({
|
|
|
707
660
|
whereClause += " or ProcessId=" + pids[i];
|
|
708
661
|
}
|
|
709
662
|
const property = "CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize";
|
|
710
|
-
const
|
|
711
|
-
bin("
|
|
663
|
+
const command = "gwmi win32_process -Filter '" + whereClause + "' | select " + property + " | format-table";
|
|
664
|
+
bin("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], { windowsHide: true }, function(err, stdout, code) {
|
|
712
665
|
if (err) {
|
|
713
666
|
if (err.message.indexOf("No Instance(s) Available.") !== -1) {
|
|
714
667
|
const error = new Error("No matching pid found");
|
|
@@ -721,8 +674,8 @@ var require_gwmi = __commonJS({
|
|
|
721
674
|
return done(new Error("pidusage gwmi command exited with code " + code));
|
|
722
675
|
}
|
|
723
676
|
const date = Date.now();
|
|
724
|
-
const uptime = Math.floor(
|
|
725
|
-
stdout = stdout.split(
|
|
677
|
+
const uptime = Math.floor(os4.uptime() || date / 1e3);
|
|
678
|
+
stdout = stdout.split(os4.EOL).slice(1);
|
|
726
679
|
const index = stdout.findIndex((v) => !!v);
|
|
727
680
|
stdout = stdout.slice(index + 2);
|
|
728
681
|
if (!stdout.length) {
|
|
@@ -779,9 +732,9 @@ var require_gwmi = __commonJS({
|
|
|
779
732
|
var require_stats = __commonJS({
|
|
780
733
|
"node_modules/pidusage/lib/stats.js"(exports, module) {
|
|
781
734
|
"use strict";
|
|
782
|
-
var
|
|
783
|
-
var
|
|
784
|
-
var
|
|
735
|
+
var fs10 = __require("fs");
|
|
736
|
+
var os4 = __require("os");
|
|
737
|
+
var path13 = __require("path");
|
|
785
738
|
var requireMap = {
|
|
786
739
|
ps: () => require_ps(),
|
|
787
740
|
procfile: () => require_procfile(),
|
|
@@ -802,8 +755,8 @@ var require_stats = __commonJS({
|
|
|
802
755
|
sunos: "ps",
|
|
803
756
|
win: "wmic"
|
|
804
757
|
};
|
|
805
|
-
var platform =
|
|
806
|
-
if (
|
|
758
|
+
var platform = os4.platform();
|
|
759
|
+
if (fs10.existsSync("/etc/alpine-release")) {
|
|
807
760
|
platform = "alpine";
|
|
808
761
|
}
|
|
809
762
|
if (platform.match(/^win/)) {
|
|
@@ -814,27 +767,23 @@ var require_stats = __commonJS({
|
|
|
814
767
|
stat = requireMap[platformToMethod[platform]]();
|
|
815
768
|
} catch (err) {
|
|
816
769
|
}
|
|
770
|
+
var wmicAvailable;
|
|
771
|
+
function hasWmic() {
|
|
772
|
+
if (wmicAvailable === void 0) {
|
|
773
|
+
wmicAvailable = fs10.existsSync(path13.join(process.env.SystemRoot || "C:\\Windows", "System32", "wbem", "WMIC.exe"));
|
|
774
|
+
}
|
|
775
|
+
return wmicAvailable;
|
|
776
|
+
}
|
|
817
777
|
function get(pids, options, callback) {
|
|
818
778
|
let fn = stat;
|
|
819
779
|
if (platform !== "win" && options.usePs === true) {
|
|
820
780
|
fn = requireMap.ps();
|
|
821
781
|
}
|
|
822
782
|
if (platform === "win") {
|
|
823
|
-
|
|
824
|
-
try {
|
|
825
|
-
child = spawn2("wmic", function(err) {
|
|
826
|
-
if (err) throw new Error(err);
|
|
827
|
-
});
|
|
828
|
-
} catch (err) {
|
|
829
|
-
fn = requireMap.gwmi();
|
|
830
|
-
} finally {
|
|
831
|
-
if (child) {
|
|
832
|
-
child.kill();
|
|
833
|
-
}
|
|
834
|
-
}
|
|
783
|
+
fn = options.useGwmi === true || !hasWmic() ? requireMap.gwmi() : requireMap.wmic();
|
|
835
784
|
}
|
|
836
785
|
if (fn === void 0) {
|
|
837
|
-
return callback(new Error(
|
|
786
|
+
return callback(new Error(os4.platform() + " is not supported yet, please open an issue (https://github.com/soyuka/pidusage)"));
|
|
838
787
|
}
|
|
839
788
|
let single = false;
|
|
840
789
|
if (!Array.isArray(pids)) {
|
|
@@ -886,10 +835,10 @@ var require_pidusage = __commonJS({
|
|
|
886
835
|
stats(pids, options, callback);
|
|
887
836
|
return;
|
|
888
837
|
}
|
|
889
|
-
return new Promise(function(
|
|
838
|
+
return new Promise(function(resolve7, reject) {
|
|
890
839
|
stats(pids, options, function(err, data) {
|
|
891
840
|
if (err) return reject(err);
|
|
892
|
-
|
|
841
|
+
resolve7(data);
|
|
893
842
|
});
|
|
894
843
|
});
|
|
895
844
|
}
|
|
@@ -901,8 +850,291 @@ var require_pidusage = __commonJS({
|
|
|
901
850
|
// dist/clients/safe-spawn.js
|
|
902
851
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
903
852
|
import { spawn, spawnSync } from "node:child_process";
|
|
904
|
-
import * as
|
|
905
|
-
import * as
|
|
853
|
+
import * as fs9 from "node:fs";
|
|
854
|
+
import * as path12 from "node:path";
|
|
855
|
+
|
|
856
|
+
// dist/clients/session-repository.js
|
|
857
|
+
import * as fs2 from "node:fs";
|
|
858
|
+
import * as os from "node:os";
|
|
859
|
+
import * as path2 from "node:path";
|
|
860
|
+
|
|
861
|
+
// dist/clients/review-graph/git-identity.js
|
|
862
|
+
import * as fs from "node:fs";
|
|
863
|
+
import * as path from "node:path";
|
|
864
|
+
import { dirname, join as join2, resolve as resolve2 } from "node:path";
|
|
865
|
+
function createGitIdentityResolver() {
|
|
866
|
+
const memo = /* @__PURE__ */ new Map();
|
|
867
|
+
return (cwd) => {
|
|
868
|
+
if (memo.has(cwd))
|
|
869
|
+
return memo.get(cwd);
|
|
870
|
+
const identity = resolveGitIdentity(cwd);
|
|
871
|
+
memo.set(cwd, identity);
|
|
872
|
+
return identity;
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
function readCommonDir(gitDir) {
|
|
876
|
+
try {
|
|
877
|
+
const raw = fs.readFileSync(path.join(gitDir, "commondir"), "utf-8").trim();
|
|
878
|
+
if (!raw)
|
|
879
|
+
return gitDir;
|
|
880
|
+
return path.isAbsolute(raw) ? raw : path.resolve(gitDir, raw);
|
|
881
|
+
} catch {
|
|
882
|
+
return gitDir;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function resolveGitDir(cwd) {
|
|
886
|
+
for (const dir of walkUpDirs(cwd, { spelling: true })) {
|
|
887
|
+
const gitPath = path.join(dir, ".git");
|
|
888
|
+
let stat;
|
|
889
|
+
try {
|
|
890
|
+
stat = fs.statSync(gitPath);
|
|
891
|
+
} catch {
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
894
|
+
if (stat.isDirectory()) {
|
|
895
|
+
if (!fs.statSync(path.join(gitPath, "HEAD"), { throwIfNoEntry: false }))
|
|
896
|
+
continue;
|
|
897
|
+
return {
|
|
898
|
+
gitDir: gitPath,
|
|
899
|
+
commonDir: readCommonDir(gitPath),
|
|
900
|
+
worktreeRoot: dir
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
if (stat.isFile()) {
|
|
904
|
+
try {
|
|
905
|
+
const contents = fs.readFileSync(gitPath, "utf-8").trim();
|
|
906
|
+
const match = contents.match(/^gitdir:\s*(.+)$/);
|
|
907
|
+
if (!match)
|
|
908
|
+
return null;
|
|
909
|
+
const linkedGitDir = path.isAbsolute(match[1]) ? match[1] : path.resolve(dir, match[1]);
|
|
910
|
+
if (!fs.statSync(linkedGitDir).isDirectory())
|
|
911
|
+
return null;
|
|
912
|
+
return {
|
|
913
|
+
gitDir: linkedGitDir,
|
|
914
|
+
commonDir: readCommonDir(linkedGitDir),
|
|
915
|
+
worktreeRoot: dir
|
|
916
|
+
};
|
|
917
|
+
} catch {
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
return null;
|
|
924
|
+
}
|
|
925
|
+
function getResolvedGitDir(cwd) {
|
|
926
|
+
let resolved;
|
|
927
|
+
try {
|
|
928
|
+
resolved = resolveGitDir(cwd);
|
|
929
|
+
} catch {
|
|
930
|
+
resolved = null;
|
|
931
|
+
}
|
|
932
|
+
return resolved;
|
|
933
|
+
}
|
|
934
|
+
function canonicalDirectory(dir) {
|
|
935
|
+
try {
|
|
936
|
+
return fs.realpathSync.native(dir);
|
|
937
|
+
} catch {
|
|
938
|
+
return dir;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
function resolveGitCheckout(startPath) {
|
|
942
|
+
const resolved = getResolvedGitDir(startPath);
|
|
943
|
+
return resolved ? {
|
|
944
|
+
root: canonicalDirectory(resolved.worktreeRoot),
|
|
945
|
+
spelledRoot: resolved.worktreeRoot,
|
|
946
|
+
commonDir: canonicalDirectory(resolved.commonDir)
|
|
947
|
+
} : null;
|
|
948
|
+
}
|
|
949
|
+
function sameCheckoutOtherRoot(session, other) {
|
|
950
|
+
return other !== null && !pathsEqual(other.root, session.root) && pathsEqual(other.commonDir, session.commonDir);
|
|
951
|
+
}
|
|
952
|
+
function resolveLinkedWorktreeOwner(session, absoluteFile) {
|
|
953
|
+
const owner = resolveGitCheckout(dirname(absoluteFile));
|
|
954
|
+
return sameCheckoutOtherRoot(session, owner) ? owner : null;
|
|
955
|
+
}
|
|
956
|
+
function listLinkedWorktreeRoots(commonDir) {
|
|
957
|
+
const roots = [];
|
|
958
|
+
let names;
|
|
959
|
+
try {
|
|
960
|
+
names = fs.readdirSync(join2(commonDir, "worktrees"));
|
|
961
|
+
} catch {
|
|
962
|
+
return roots;
|
|
963
|
+
}
|
|
964
|
+
for (const name of names) {
|
|
965
|
+
try {
|
|
966
|
+
const entryDir = join2(commonDir, "worktrees", name);
|
|
967
|
+
const gitFile = fs.readFileSync(join2(entryDir, "gitdir"), "utf-8").trim();
|
|
968
|
+
if (gitFile) {
|
|
969
|
+
const root = canonicalDirectory(dirname(resolve2(entryDir, gitFile)));
|
|
970
|
+
if (fs.existsSync(join2(root, ".git")))
|
|
971
|
+
roots.push(root);
|
|
972
|
+
}
|
|
973
|
+
} catch {
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
return roots;
|
|
977
|
+
}
|
|
978
|
+
function listNestedLinkedWorktreeRoots(scanRoot) {
|
|
979
|
+
const checkout = resolveGitCheckout(scanRoot);
|
|
980
|
+
if (!checkout)
|
|
981
|
+
return [];
|
|
982
|
+
const base = canonicalDirectory(scanRoot);
|
|
983
|
+
const nested = [];
|
|
984
|
+
for (const root of listLinkedWorktreeRoots(checkout.commonDir)) {
|
|
985
|
+
if (!pathsEqual(root, base) && isUnderDir(root, base))
|
|
986
|
+
nested.push(root);
|
|
987
|
+
}
|
|
988
|
+
return nested;
|
|
989
|
+
}
|
|
990
|
+
function resolveRefToSha(commonDir, ref) {
|
|
991
|
+
try {
|
|
992
|
+
const loose = fs.readFileSync(path.join(commonDir, ref), "utf-8").trim();
|
|
993
|
+
if (loose)
|
|
994
|
+
return loose;
|
|
995
|
+
} catch {
|
|
996
|
+
}
|
|
997
|
+
try {
|
|
998
|
+
const packed = fs.readFileSync(path.join(commonDir, "packed-refs"), "utf-8");
|
|
999
|
+
for (const line of packed.split("\n")) {
|
|
1000
|
+
if (line.startsWith("#") || line.startsWith("^") || !line.trim())
|
|
1001
|
+
continue;
|
|
1002
|
+
const [sha, packedRef] = line.trim().split(/\s+/, 2);
|
|
1003
|
+
if (packedRef === ref)
|
|
1004
|
+
return sha;
|
|
1005
|
+
}
|
|
1006
|
+
} catch {
|
|
1007
|
+
}
|
|
1008
|
+
return null;
|
|
1009
|
+
}
|
|
1010
|
+
function resolveGitIdentity(cwd) {
|
|
1011
|
+
try {
|
|
1012
|
+
const resolved = getResolvedGitDir(cwd);
|
|
1013
|
+
if (!resolved)
|
|
1014
|
+
return void 0;
|
|
1015
|
+
const headRaw = fs.readFileSync(path.join(resolved.gitDir, "HEAD"), "utf-8").trim();
|
|
1016
|
+
const refMatch = headRaw.match(/^ref:\s*(.+)$/);
|
|
1017
|
+
let headCommit;
|
|
1018
|
+
if (refMatch) {
|
|
1019
|
+
headCommit = resolveRefToSha(resolved.commonDir, refMatch[1].trim());
|
|
1020
|
+
} else {
|
|
1021
|
+
headCommit = /^[0-9a-f]{7,40}$/i.test(headRaw) ? headRaw : null;
|
|
1022
|
+
}
|
|
1023
|
+
if (!headCommit)
|
|
1024
|
+
return void 0;
|
|
1025
|
+
return {
|
|
1026
|
+
headCommit,
|
|
1027
|
+
worktreeRoot: normalizeFilePath(resolved.worktreeRoot)
|
|
1028
|
+
};
|
|
1029
|
+
} catch {
|
|
1030
|
+
return void 0;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// dist/clients/session-repository.js
|
|
1035
|
+
var NODE_MODULES_BIN_DIRS = [
|
|
1036
|
+
path2.join("node_modules", ".bin")
|
|
1037
|
+
];
|
|
1038
|
+
var VENDOR_BIN_DIRS = [path2.join("vendor", "bin")];
|
|
1039
|
+
var VENV_BIN_DIRS = [
|
|
1040
|
+
path2.join(".venv", "bin"),
|
|
1041
|
+
path2.join("venv", "bin"),
|
|
1042
|
+
path2.join(".venv", "Scripts"),
|
|
1043
|
+
path2.join("venv", "Scripts")
|
|
1044
|
+
];
|
|
1045
|
+
var PROJECT_LOCAL_BIN_DIRS = [
|
|
1046
|
+
...NODE_MODULES_BIN_DIRS,
|
|
1047
|
+
...VENDOR_BIN_DIRS,
|
|
1048
|
+
...VENV_BIN_DIRS
|
|
1049
|
+
];
|
|
1050
|
+
function* projectLocalBinDirs(dir, home = os.homedir()) {
|
|
1051
|
+
for (const ancestor of walkUpDirs(dir, { spelling: true, homeDir: home })) {
|
|
1052
|
+
for (const binDir of PROJECT_LOCAL_BIN_DIRS)
|
|
1053
|
+
yield path2.join(ancestor, binDir);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function sessionRepositoryJudge() {
|
|
1057
|
+
const home = realpathOrResolve(os.homedir());
|
|
1058
|
+
const session = realpathOrResolve(process.cwd());
|
|
1059
|
+
if (isAtOrAboveHomeDir(session, home))
|
|
1060
|
+
return () => false;
|
|
1061
|
+
const sessionForm = pathForm(session);
|
|
1062
|
+
const dataDirForm = pathForm(realpathOrResolve(machineStateDir()));
|
|
1063
|
+
const binDirForms = [...projectLocalBinDirs(session, home)].filter((dir) => fs2.existsSync(dir)).map((dir) => pathForm(realpathOrResolve(dir)));
|
|
1064
|
+
let sessionCheckout;
|
|
1065
|
+
const ownerByDir = new PathKeyedMap(pathForm);
|
|
1066
|
+
return (target) => {
|
|
1067
|
+
const real = realpathOrResolve(target);
|
|
1068
|
+
const form = pathForm(real);
|
|
1069
|
+
if (isWithinForm(form, dataDirForm))
|
|
1070
|
+
return false;
|
|
1071
|
+
if (isWithinForm(form, sessionForm))
|
|
1072
|
+
return true;
|
|
1073
|
+
if (binDirForms.some((binDir) => isWithinForm(form, binDir)))
|
|
1074
|
+
return true;
|
|
1075
|
+
sessionCheckout ??= resolveGitCheckout(session);
|
|
1076
|
+
if (!sessionCheckout || isAtOrAboveHomeDir(sessionCheckout.root, home))
|
|
1077
|
+
return false;
|
|
1078
|
+
return ownerCommonDirForm(real) === pathForm(sessionCheckout.commonDir);
|
|
1079
|
+
};
|
|
1080
|
+
function ownerCommonDirForm(real) {
|
|
1081
|
+
const walked = [];
|
|
1082
|
+
let answer = null;
|
|
1083
|
+
for (const dir of walkUpDirs(real)) {
|
|
1084
|
+
const known = ownerByDir.get(dir);
|
|
1085
|
+
if (known !== void 0) {
|
|
1086
|
+
answer = known;
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
walked.push(dir);
|
|
1090
|
+
if (!hasGitEntry(dir))
|
|
1091
|
+
continue;
|
|
1092
|
+
const owner = resolveGitCheckout(dir);
|
|
1093
|
+
answer = owner && !isAtOrAboveHomeDir(owner.root, home) ? pathForm(owner.commonDir) : null;
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
for (const dir of walked)
|
|
1097
|
+
ownerByDir.set(dir, answer);
|
|
1098
|
+
return answer;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
function hasGitEntry(dir) {
|
|
1102
|
+
return fs2.existsSync(path2.join(dir, ".git"));
|
|
1103
|
+
}
|
|
1104
|
+
function pathForm(real) {
|
|
1105
|
+
return process.platform === "win32" ? normalizeEphemeralMapKey(real) : real;
|
|
1106
|
+
}
|
|
1107
|
+
function isSessionRepositoryPath(target) {
|
|
1108
|
+
return sessionRepositoryJudge()(target);
|
|
1109
|
+
}
|
|
1110
|
+
function isUntrustedProjectPath(target) {
|
|
1111
|
+
if (getProjectTrustState() === "trusted")
|
|
1112
|
+
return false;
|
|
1113
|
+
return isSessionRepositoryPath(target);
|
|
1114
|
+
}
|
|
1115
|
+
function recordProjectCommandRefusal(resolvedCommand) {
|
|
1116
|
+
const trust = getProjectTrustState();
|
|
1117
|
+
const target = realpathOrResolve(resolvedCommand);
|
|
1118
|
+
if (recordDegradationOnce({
|
|
1119
|
+
kind: "trust-refusal",
|
|
1120
|
+
subject: `project-command:${target}`,
|
|
1121
|
+
reason: `lookup resolved inside the project and was refused: pi project trust is ${trust}`
|
|
1122
|
+
})) {
|
|
1123
|
+
logExtension({
|
|
1124
|
+
subsystem: "project-trust",
|
|
1125
|
+
level: "warn",
|
|
1126
|
+
message: "lookup resolved inside the project and was refused: mark the project trusted in pi or upgrade pi",
|
|
1127
|
+
metadata: { command: resolvedCommand, target, trust }
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
function admittedLookupAnswer(stdout) {
|
|
1132
|
+
const answer = stdout.trim().split(/\r?\n/)[0] || null;
|
|
1133
|
+
if (answer === null || !isUntrustedProjectPath(answer))
|
|
1134
|
+
return answer;
|
|
1135
|
+
recordProjectCommandRefusal(answer);
|
|
1136
|
+
return null;
|
|
1137
|
+
}
|
|
906
1138
|
|
|
907
1139
|
// dist/clients/resource-sampler.js
|
|
908
1140
|
var import_pidusage = __toESM(require_pidusage(), 1);
|
|
@@ -912,18 +1144,18 @@ import { spawn as nodeSpawn2 } from "node:child_process";
|
|
|
912
1144
|
|
|
913
1145
|
// dist/clients/bounded-pid-file-lock.js
|
|
914
1146
|
import { randomUUID } from "node:crypto";
|
|
915
|
-
import * as
|
|
1147
|
+
import * as fs4 from "node:fs";
|
|
916
1148
|
import fsp from "node:fs/promises";
|
|
917
|
-
import
|
|
1149
|
+
import path4 from "node:path";
|
|
918
1150
|
|
|
919
1151
|
// dist/clients/generation-lock.js
|
|
920
1152
|
import { randomInt } from "node:crypto";
|
|
921
|
-
import * as
|
|
922
|
-
import * as
|
|
1153
|
+
import * as fs3 from "node:fs";
|
|
1154
|
+
import * as path3 from "node:path";
|
|
923
1155
|
var GENERATION = /^lock\.(\d+)(\.released)?$/;
|
|
924
1156
|
function pidFileOwner(file) {
|
|
925
1157
|
try {
|
|
926
|
-
const pid = Number(
|
|
1158
|
+
const pid = Number(fs3.readFileSync(file, "utf8").trim().split(/\s+/)[0]);
|
|
927
1159
|
return Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
928
1160
|
} catch {
|
|
929
1161
|
return void 0;
|
|
@@ -941,7 +1173,7 @@ function isPidAlive(pid) {
|
|
|
941
1173
|
}
|
|
942
1174
|
function pidFileIsStale(file, staleMs) {
|
|
943
1175
|
try {
|
|
944
|
-
const stat =
|
|
1176
|
+
const stat = fs3.statSync(file);
|
|
945
1177
|
if (Date.now() - stat.mtimeMs > staleMs)
|
|
946
1178
|
return true;
|
|
947
1179
|
const pid = pidFileOwner(file);
|
|
@@ -955,7 +1187,7 @@ function isLockContention(error) {
|
|
|
955
1187
|
return code === "EEXIST" || code === "EPERM" || code === "EBUSY";
|
|
956
1188
|
}
|
|
957
1189
|
function generationPath(dir, generation) {
|
|
958
|
-
return
|
|
1190
|
+
return path3.join(dir, `lock.${generation}`);
|
|
959
1191
|
}
|
|
960
1192
|
function releasedName(generation) {
|
|
961
1193
|
return `lock.${generation}.released`;
|
|
@@ -975,7 +1207,7 @@ function removeBelowPredecessor(dir, entries, generation) {
|
|
|
975
1207
|
if (!match || Number(match[1]) + 1 >= generation)
|
|
976
1208
|
continue;
|
|
977
1209
|
try {
|
|
978
|
-
|
|
1210
|
+
fs3.unlinkSync(path3.join(dir, name));
|
|
979
1211
|
} catch {
|
|
980
1212
|
}
|
|
981
1213
|
}
|
|
@@ -983,20 +1215,20 @@ function removeBelowPredecessor(dir, entries, generation) {
|
|
|
983
1215
|
function recordGenerationTakeover(hold) {
|
|
984
1216
|
incrementDegradationCount({
|
|
985
1217
|
kind: "generation-lock-stale-takeover",
|
|
986
|
-
subject:
|
|
1218
|
+
subject: path3.resolve(hold.dir),
|
|
987
1219
|
reason: `took over lock generation ${hold.generation - 1} from a dead or aged-out holder`
|
|
988
1220
|
});
|
|
989
1221
|
}
|
|
990
1222
|
function recordLegacyLockHeld(legacyPath) {
|
|
991
1223
|
incrementDegradationCount({
|
|
992
1224
|
kind: "generation-lock-legacy-held",
|
|
993
|
-
subject:
|
|
994
|
-
reason: `backed off: ${
|
|
1225
|
+
subject: path3.resolve(legacyPath),
|
|
1226
|
+
reason: `backed off: ${path3.basename(legacyPath)} is held by another writer (one from before #3476, or a holder past the generation lease)`
|
|
995
1227
|
});
|
|
996
1228
|
}
|
|
997
1229
|
function releaseGeneration(hold) {
|
|
998
1230
|
try {
|
|
999
|
-
|
|
1231
|
+
fs3.writeFileSync(path3.join(hold.dir, releasedName(hold.generation)), "");
|
|
1000
1232
|
} catch {
|
|
1001
1233
|
}
|
|
1002
1234
|
}
|
|
@@ -1008,7 +1240,7 @@ function startGenerationHeartbeat(hold, intervalMs) {
|
|
|
1008
1240
|
const timer = setInterval(() => {
|
|
1009
1241
|
try {
|
|
1010
1242
|
const now = /* @__PURE__ */ new Date();
|
|
1011
|
-
|
|
1243
|
+
fs3.utimesSync(file, now, now);
|
|
1012
1244
|
} catch {
|
|
1013
1245
|
}
|
|
1014
1246
|
}, intervalMs);
|
|
@@ -1017,7 +1249,7 @@ function startGenerationHeartbeat(hold, intervalMs) {
|
|
|
1017
1249
|
}
|
|
1018
1250
|
function ownsTopGeneration(hold) {
|
|
1019
1251
|
try {
|
|
1020
|
-
const entries =
|
|
1252
|
+
const entries = fs3.readdirSync(hold.dir);
|
|
1021
1253
|
if (entries.includes(releasedName(hold.generation)))
|
|
1022
1254
|
return false;
|
|
1023
1255
|
return topGeneration(entries) === hold.generation;
|
|
@@ -1026,8 +1258,8 @@ function ownsTopGeneration(hold) {
|
|
|
1026
1258
|
}
|
|
1027
1259
|
}
|
|
1028
1260
|
function tryAcquireGeneration(dir, staleMs) {
|
|
1029
|
-
|
|
1030
|
-
const listed =
|
|
1261
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
1262
|
+
const listed = fs3.readdirSync(dir);
|
|
1031
1263
|
const top = topGeneration(listed);
|
|
1032
1264
|
const free = top === 0 || listed.includes(releasedName(top));
|
|
1033
1265
|
if (!free && !pidFileIsStale(generationPath(dir, top), staleMs)) {
|
|
@@ -1035,7 +1267,7 @@ function tryAcquireGeneration(dir, staleMs) {
|
|
|
1035
1267
|
}
|
|
1036
1268
|
const hold = { dir, generation: top + 1, tookOverStale: !free };
|
|
1037
1269
|
try {
|
|
1038
|
-
|
|
1270
|
+
fs3.writeFileSync(generationPath(dir, hold.generation), `${process.pid} ${Date.now()}
|
|
1039
1271
|
`, { flag: "wx" });
|
|
1040
1272
|
} catch (error) {
|
|
1041
1273
|
if (isLockContention(error))
|
|
@@ -1044,7 +1276,7 @@ function tryAcquireGeneration(dir, staleMs) {
|
|
|
1044
1276
|
}
|
|
1045
1277
|
let entries;
|
|
1046
1278
|
try {
|
|
1047
|
-
entries =
|
|
1279
|
+
entries = fs3.readdirSync(dir);
|
|
1048
1280
|
} catch (cause) {
|
|
1049
1281
|
releaseGeneration(hold);
|
|
1050
1282
|
throw cause;
|
|
@@ -1059,8 +1291,8 @@ function tryAcquireGeneration(dir, staleMs) {
|
|
|
1059
1291
|
var timedOutHolders = new BoundedFifoMap(16);
|
|
1060
1292
|
function topGenerationHolder(dir) {
|
|
1061
1293
|
try {
|
|
1062
|
-
const top = topGeneration(
|
|
1063
|
-
return `lock.${top} ${
|
|
1294
|
+
const top = topGeneration(fs3.readdirSync(dir));
|
|
1295
|
+
return `lock.${top} ${fs3.readFileSync(generationPath(dir, top), "utf8").trim()}`;
|
|
1064
1296
|
} catch {
|
|
1065
1297
|
return void 0;
|
|
1066
1298
|
}
|
|
@@ -1107,11 +1339,11 @@ function generationDir(lockPath) {
|
|
|
1107
1339
|
return `${lockPath}s`;
|
|
1108
1340
|
}
|
|
1109
1341
|
function boundedLockIsStale(lockPath) {
|
|
1110
|
-
const [pidText] =
|
|
1342
|
+
const [pidText] = fs4.readFileSync(lockPath, "utf8").split(":", 1);
|
|
1111
1343
|
const pid = Number.parseInt(pidText ?? "", 10);
|
|
1112
1344
|
if (Number.isSafeInteger(pid) && pid > 0)
|
|
1113
1345
|
return !ownerPidIsLive(pid);
|
|
1114
|
-
return Date.now() -
|
|
1346
|
+
return Date.now() - fs4.statSync(lockPath).mtimeMs > UNREADABLE_LOCK_STALE_MS;
|
|
1115
1347
|
}
|
|
1116
1348
|
function ownerPidIsLive(pid) {
|
|
1117
1349
|
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
@@ -1143,13 +1375,13 @@ async function releaseQuarantineLock(lockPath, token) {
|
|
|
1143
1375
|
} catch (error) {
|
|
1144
1376
|
if (error.code !== "ENOENT" || attempt === 2)
|
|
1145
1377
|
return;
|
|
1146
|
-
await new Promise((
|
|
1378
|
+
await new Promise((resolve7) => setImmediate(resolve7));
|
|
1147
1379
|
}
|
|
1148
1380
|
}
|
|
1149
1381
|
if (!renamed)
|
|
1150
1382
|
return;
|
|
1151
1383
|
try {
|
|
1152
|
-
const owner = JSON.parse(await fsp.readFile(
|
|
1384
|
+
const owner = JSON.parse(await fsp.readFile(path4.join(quarantined, "owner.json"), "utf8"));
|
|
1153
1385
|
if (owner.token === token) {
|
|
1154
1386
|
await fsp.rm(quarantined, { recursive: true, force: true });
|
|
1155
1387
|
} else {
|
|
@@ -1174,7 +1406,7 @@ async function reclaimQuarantineLock(lockPath, staleMs) {
|
|
|
1174
1406
|
}
|
|
1175
1407
|
let stale = false;
|
|
1176
1408
|
try {
|
|
1177
|
-
const owner = JSON.parse(await fsp.readFile(
|
|
1409
|
+
const owner = JSON.parse(await fsp.readFile(path4.join(quarantined, "owner.json"), "utf8"));
|
|
1178
1410
|
stale = quarantineOwnerIsStale(owner, staleMs);
|
|
1179
1411
|
} catch {
|
|
1180
1412
|
try {
|
|
@@ -1200,7 +1432,7 @@ async function tryAcquireQuarantineLock(lockPath, staleMs) {
|
|
|
1200
1432
|
try {
|
|
1201
1433
|
await fsp.mkdir(lockPath);
|
|
1202
1434
|
try {
|
|
1203
|
-
await fsp.writeFile(
|
|
1435
|
+
await fsp.writeFile(path4.join(lockPath, "owner.json"), JSON.stringify(owner), "utf8");
|
|
1204
1436
|
} catch (error) {
|
|
1205
1437
|
await fsp.rm(lockPath, { recursive: true, force: true }).catch(() => {
|
|
1206
1438
|
});
|
|
@@ -1213,7 +1445,7 @@ async function tryAcquireQuarantineLock(lockPath, staleMs) {
|
|
|
1213
1445
|
}
|
|
1214
1446
|
let stale;
|
|
1215
1447
|
try {
|
|
1216
|
-
const existing = JSON.parse(await fsp.readFile(
|
|
1448
|
+
const existing = JSON.parse(await fsp.readFile(path4.join(lockPath, "owner.json"), "utf8"));
|
|
1217
1449
|
stale = quarantineOwnerIsStale(existing, staleMs);
|
|
1218
1450
|
} catch {
|
|
1219
1451
|
try {
|
|
@@ -1270,12 +1502,12 @@ async function acquireQuarantinePidFileLock(lockPath, options) {
|
|
|
1270
1502
|
}
|
|
1271
1503
|
throw new Error(options.timeoutMessage);
|
|
1272
1504
|
}
|
|
1273
|
-
await new Promise((
|
|
1505
|
+
await new Promise((resolve7) => setTimeout(resolve7, Math.min(options.retryMs, remaining)));
|
|
1274
1506
|
}
|
|
1275
1507
|
}
|
|
1276
1508
|
function createLegacyBoundedLock(lockPath, token) {
|
|
1277
1509
|
try {
|
|
1278
|
-
|
|
1510
|
+
fs4.writeFileSync(lockPath, token, { encoding: "utf8", flag: "wx" });
|
|
1279
1511
|
return true;
|
|
1280
1512
|
} catch (cause) {
|
|
1281
1513
|
if (isLockContention(cause))
|
|
@@ -1289,7 +1521,7 @@ function takeLegacyBoundedLock(lockPath, token) {
|
|
|
1289
1521
|
try {
|
|
1290
1522
|
if (!boundedLockIsStale(lockPath))
|
|
1291
1523
|
return false;
|
|
1292
|
-
|
|
1524
|
+
fs4.unlinkSync(lockPath);
|
|
1293
1525
|
} catch {
|
|
1294
1526
|
return false;
|
|
1295
1527
|
}
|
|
@@ -1297,8 +1529,8 @@ function takeLegacyBoundedLock(lockPath, token) {
|
|
|
1297
1529
|
}
|
|
1298
1530
|
function releaseLegacyBoundedLock(lockPath, token) {
|
|
1299
1531
|
try {
|
|
1300
|
-
if (
|
|
1301
|
-
|
|
1532
|
+
if (fs4.readFileSync(lockPath, "utf8") === token)
|
|
1533
|
+
fs4.unlinkSync(lockPath);
|
|
1302
1534
|
} catch {
|
|
1303
1535
|
}
|
|
1304
1536
|
}
|
|
@@ -1325,7 +1557,7 @@ function currentHolderIdentity(dir, lockPath, hold) {
|
|
|
1325
1557
|
if (hold === "busy")
|
|
1326
1558
|
return topGenerationHolder(dir);
|
|
1327
1559
|
try {
|
|
1328
|
-
const content =
|
|
1560
|
+
const content = fs4.readFileSync(lockPath, "utf8");
|
|
1329
1561
|
return content ? `legacy ${content}` : void 0;
|
|
1330
1562
|
} catch {
|
|
1331
1563
|
return void 0;
|
|
@@ -1352,7 +1584,7 @@ function acquireBoundedPidFileLock(lockPath, options) {
|
|
|
1352
1584
|
if (timedOutHolder !== void 0 && currentHolderIdentity(dir, lockPath, hold) === timedOutHolder) {
|
|
1353
1585
|
recordDegradationOnce({
|
|
1354
1586
|
kind: "bounded-pid-lock-wait-skipped",
|
|
1355
|
-
subject:
|
|
1587
|
+
subject: path4.resolve(dir),
|
|
1356
1588
|
reason: `did not wait: ${timedOutHolder} still holds the lock after an earlier wait ran out`
|
|
1357
1589
|
});
|
|
1358
1590
|
if (options.onContention === "skip-log") {
|
|
@@ -1385,7 +1617,7 @@ function unrefChildAndPipes(child) {
|
|
|
1385
1617
|
}
|
|
1386
1618
|
}
|
|
1387
1619
|
function spawnCollectStdoutResult(command, args, options, collectOptions = {}) {
|
|
1388
|
-
return new Promise((
|
|
1620
|
+
return new Promise((resolve7) => {
|
|
1389
1621
|
let settled = false;
|
|
1390
1622
|
let timer;
|
|
1391
1623
|
const settle = (result) => {
|
|
@@ -1394,7 +1626,7 @@ function spawnCollectStdoutResult(command, args, options, collectOptions = {}) {
|
|
|
1394
1626
|
settled = true;
|
|
1395
1627
|
if (timer)
|
|
1396
1628
|
clearTimeout(timer);
|
|
1397
|
-
|
|
1629
|
+
resolve7(result);
|
|
1398
1630
|
};
|
|
1399
1631
|
try {
|
|
1400
1632
|
const child = nodeSpawn(command, args, options);
|
|
@@ -1436,13 +1668,13 @@ async function terminateTimedOutChild(child, onTimeout) {
|
|
|
1436
1668
|
}
|
|
1437
1669
|
|
|
1438
1670
|
// dist/clients/file-utils.js
|
|
1439
|
-
import * as
|
|
1671
|
+
import * as fs5 from "node:fs";
|
|
1440
1672
|
import { createHash, randomBytes } from "node:crypto";
|
|
1441
|
-
import * as
|
|
1442
|
-
import * as
|
|
1673
|
+
import * as os3 from "node:os";
|
|
1674
|
+
import * as path8 from "node:path";
|
|
1443
1675
|
|
|
1444
1676
|
// dist/clients/spawn-timeout-cooldown.js
|
|
1445
|
-
import
|
|
1677
|
+
import path5 from "node:path";
|
|
1446
1678
|
var COOLDOWN_STATE_KEY = /* @__PURE__ */ Symbol.for("pi-lens:spawn-timeout-cooldown");
|
|
1447
1679
|
var _global = globalThis;
|
|
1448
1680
|
if (!_global[COOLDOWN_STATE_KEY]) {
|
|
@@ -1450,11 +1682,11 @@ if (!_global[COOLDOWN_STATE_KEY]) {
|
|
|
1450
1682
|
}
|
|
1451
1683
|
var timedOutByCommand = _global[COOLDOWN_STATE_KEY].timedOutByCommand;
|
|
1452
1684
|
function wrapperKindOf(command) {
|
|
1453
|
-
const ext =
|
|
1685
|
+
const ext = path5.extname(command);
|
|
1454
1686
|
return ext ? ext.slice(1) : "bare";
|
|
1455
1687
|
}
|
|
1456
1688
|
function cooldownKey(command) {
|
|
1457
|
-
return
|
|
1689
|
+
return path5.basename(command).replace(/\.[^.]+$/, "").toLowerCase();
|
|
1458
1690
|
}
|
|
1459
1691
|
function noteSpawnTimeout(input) {
|
|
1460
1692
|
const key = cooldownKey(input.command);
|
|
@@ -1493,7 +1725,7 @@ function resetSpawnTimeoutCooldowns() {
|
|
|
1493
1725
|
}
|
|
1494
1726
|
|
|
1495
1727
|
// dist/clients/git-tracked-ignore.js
|
|
1496
|
-
import * as
|
|
1728
|
+
import * as path6 from "node:path";
|
|
1497
1729
|
function recordTruncatedLsFiles(parseSite) {
|
|
1498
1730
|
recordDegradationOnce({
|
|
1499
1731
|
kind: "git-tracked-ignore-truncated",
|
|
@@ -1511,7 +1743,7 @@ function parseUntrackedIgnoredOutput(stdout, cwd) {
|
|
|
1511
1743
|
const dirSegments = rel.split("/").slice(0, -1);
|
|
1512
1744
|
if (dirSegments.some((segment) => isExcludedDirName(segment)))
|
|
1513
1745
|
continue;
|
|
1514
|
-
ids.add(normalizeMapKey(
|
|
1746
|
+
ids.add(normalizeMapKey(path6.join(cwd, rel)));
|
|
1515
1747
|
}
|
|
1516
1748
|
return ids;
|
|
1517
1749
|
}
|
|
@@ -1556,7 +1788,7 @@ function parseTrackedFilesOutput(stdout, cwd) {
|
|
|
1556
1788
|
const dirSegments = rel.split("/").slice(0, -1);
|
|
1557
1789
|
if (dirSegments.some((segment) => isExcludedDirName(segment)))
|
|
1558
1790
|
continue;
|
|
1559
|
-
ids.add(normalizeEphemeralMapKey(
|
|
1791
|
+
ids.add(normalizeEphemeralMapKey(path6.join(base, rel)));
|
|
1560
1792
|
}
|
|
1561
1793
|
return ids;
|
|
1562
1794
|
}
|
|
@@ -1603,7 +1835,6 @@ function getTrackedFilesSnapshot(cwd) {
|
|
|
1603
1835
|
}
|
|
1604
1836
|
|
|
1605
1837
|
// dist/clients/lens-config.js
|
|
1606
|
-
import * as path5 from "node:path";
|
|
1607
1838
|
function globalCanonicalLocation() {
|
|
1608
1839
|
const location = GLOBAL_CONFIG_LOCATIONS.find((candidate) => candidate.relativePath === CANONICAL_GLOBAL_CONFIG_FILE);
|
|
1609
1840
|
if (!location) {
|
|
@@ -1696,6 +1927,14 @@ function loadPiLensGlobalConfig(configPath) {
|
|
|
1696
1927
|
const toolConfig = readToolConfig(raw, warnInvalid);
|
|
1697
1928
|
if (toolConfig)
|
|
1698
1929
|
config.tools = toolConfig;
|
|
1930
|
+
const toolsSection = asConfigObject(raw.tools);
|
|
1931
|
+
if (toolsSection && "lazy" in toolsSection) {
|
|
1932
|
+
const lazy = readLazyToolsSetting(raw);
|
|
1933
|
+
if (lazy === void 0)
|
|
1934
|
+
warnInvalid('tools.lazy must be "auto", true, or false');
|
|
1935
|
+
else
|
|
1936
|
+
config.tools = { ...config.tools, lazy };
|
|
1937
|
+
}
|
|
1699
1938
|
for (const spec of LENS_FLAGS) {
|
|
1700
1939
|
if (spec.readGlobal)
|
|
1701
1940
|
continue;
|
|
@@ -1785,7 +2024,7 @@ function loadPiLensGlobalConfig(configPath) {
|
|
|
1785
2024
|
]);
|
|
1786
2025
|
for (const key of Object.keys(raw)) {
|
|
1787
2026
|
if (!knownGlobalConfigKeys.has(key)) {
|
|
1788
|
-
warnInvalid(`unknown key "${key}" is not a recognized pi-lens setting (check for a typo); ignored`);
|
|
2027
|
+
warnInvalid(PROJECT_NON_FLAG_CONFIG_SECTIONS.includes(key) ? `"${key}" is a project-scoped pi-lens setting; set it in <project>/.pi-lens.json, not in the global config; ignored` : `unknown key "${key}" is not a recognized pi-lens setting (check for a typo); ignored`);
|
|
1789
2028
|
}
|
|
1790
2029
|
}
|
|
1791
2030
|
return config;
|
|
@@ -1813,7 +2052,7 @@ function resolvePiLensFlagWithSource(name, value, config, projectConfig, editedF
|
|
|
1813
2052
|
if (nested) {
|
|
1814
2053
|
return {
|
|
1815
2054
|
value: flagValueFromConfig(spec, nested.value),
|
|
1816
|
-
source:
|
|
2055
|
+
source: pathsEqual(nested.dir, projectRoot) ? "project" : `nested-project:${nested.dir}`
|
|
1817
2056
|
};
|
|
1818
2057
|
}
|
|
1819
2058
|
const projectValue = readFlagConfigValue(projectConfig, spec.configKey);
|
|
@@ -1835,47 +2074,33 @@ function resolvePiLensFlag(name, value, config, projectConfig, editedFilePath, p
|
|
|
1835
2074
|
}
|
|
1836
2075
|
|
|
1837
2076
|
// dist/clients/ephemeral-root.js
|
|
1838
|
-
import * as
|
|
1839
|
-
import * as
|
|
1840
|
-
import * as path6 from "node:path";
|
|
2077
|
+
import * as os2 from "node:os";
|
|
2078
|
+
import * as path7 from "node:path";
|
|
1841
2079
|
var NOT_EPHEMERAL = { checkout: false };
|
|
1842
2080
|
var classified = new BoundedFifoMap(1024);
|
|
1843
|
-
function realPathOfNearestExisting(target) {
|
|
1844
|
-
const resolved = path6.resolve(target);
|
|
1845
|
-
const tail = [];
|
|
1846
|
-
for (let current = resolved; ; current = path6.dirname(current)) {
|
|
1847
|
-
try {
|
|
1848
|
-
return path6.join(fs3.realpathSync.native(current), ...tail.reverse());
|
|
1849
|
-
} catch {
|
|
1850
|
-
if (path6.dirname(current) === current)
|
|
1851
|
-
return resolved;
|
|
1852
|
-
tail.push(path6.basename(current));
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
2081
|
function classifyTmpDir(dir) {
|
|
1857
|
-
const tmpSpelling =
|
|
1858
|
-
const key = `${normalizeEphemeralMapKey(tmpSpelling)}\0${normalizeEphemeralMapKey(
|
|
2082
|
+
const tmpSpelling = os2.tmpdir();
|
|
2083
|
+
const key = `${normalizeEphemeralMapKey(tmpSpelling)}\0${normalizeEphemeralMapKey(path7.resolve(dir))}`;
|
|
1859
2084
|
const memo = classified.get(key);
|
|
1860
2085
|
if (memo)
|
|
1861
2086
|
return memo;
|
|
1862
|
-
const tmpRoot =
|
|
1863
|
-
const real =
|
|
2087
|
+
const tmpRoot = realpathOrResolve(tmpSpelling);
|
|
2088
|
+
const real = realpathOrResolve(dir);
|
|
1864
2089
|
let result = NOT_EPHEMERAL;
|
|
1865
2090
|
if (isUnderDir(real, tmpRoot)) {
|
|
1866
|
-
for (let current = real; current !== tmpRoot &&
|
|
1867
|
-
if (isRealGitMarker(
|
|
2091
|
+
for (let current = real; current !== tmpRoot && path7.dirname(current) !== current; current = path7.dirname(current)) {
|
|
2092
|
+
if (isRealGitMarker(path7.join(current, ".git"))) {
|
|
1868
2093
|
result = { checkout: true };
|
|
1869
2094
|
break;
|
|
1870
2095
|
}
|
|
1871
2096
|
}
|
|
1872
2097
|
if (!result.checkout) {
|
|
1873
|
-
const segments =
|
|
2098
|
+
const segments = path7.relative(tmpRoot, real).split(path7.sep);
|
|
1874
2099
|
const index = segments.findIndex((segment) => /^pi-agent(?:-|$)/i.test(segment));
|
|
1875
2100
|
if (index >= 0) {
|
|
1876
2101
|
result = {
|
|
1877
2102
|
checkout: false,
|
|
1878
|
-
stagingRoot:
|
|
2103
|
+
stagingRoot: path7.join(tmpRoot, ...segments.slice(0, index + 1))
|
|
1879
2104
|
};
|
|
1880
2105
|
}
|
|
1881
2106
|
}
|
|
@@ -1884,17 +2109,17 @@ function classifyTmpDir(dir) {
|
|
|
1884
2109
|
return result;
|
|
1885
2110
|
}
|
|
1886
2111
|
function ephemeralStagingRoot(filePath) {
|
|
1887
|
-
return classifyTmpDir(
|
|
2112
|
+
return classifyTmpDir(path7.dirname(path7.resolve(filePath))).stagingRoot;
|
|
1888
2113
|
}
|
|
1889
2114
|
function isPiOwnedTempPath(filePath) {
|
|
1890
|
-
const tmpRoot =
|
|
1891
|
-
const real =
|
|
2115
|
+
const tmpRoot = realpathOrResolve(os2.tmpdir());
|
|
2116
|
+
const real = realpathOrResolve(filePath);
|
|
1892
2117
|
if (!isUnderDir(real, tmpRoot))
|
|
1893
2118
|
return false;
|
|
1894
|
-
const relative3 =
|
|
1895
|
-
if (relative3.length === 0 ||
|
|
2119
|
+
const relative3 = path7.relative(tmpRoot, real);
|
|
2120
|
+
if (relative3.length === 0 || path7.isAbsolute(relative3))
|
|
1896
2121
|
return false;
|
|
1897
|
-
const segments = relative3.split(
|
|
2122
|
+
const segments = relative3.split(path7.sep);
|
|
1898
2123
|
return segments.length === 1 || /^pi-/i.test(segments[0] ?? "");
|
|
1899
2124
|
}
|
|
1900
2125
|
function isEphemeralCheckoutRoot(dir) {
|
|
@@ -1903,31 +2128,139 @@ function isEphemeralCheckoutRoot(dir) {
|
|
|
1903
2128
|
|
|
1904
2129
|
// dist/clients/file-utils.js
|
|
1905
2130
|
function getProjectDataDir(cwd) {
|
|
1906
|
-
const legacyProjectDir =
|
|
2131
|
+
const legacyProjectDir = path8.join(cwd, ".pi-lens");
|
|
1907
2132
|
const configuredBase = process.env.PILENS_DATA_DIR?.trim();
|
|
1908
2133
|
const resolvedBase = projectDataBase();
|
|
1909
|
-
const memoKey = `${resolvedBase}\0${
|
|
2134
|
+
const memoKey = `${resolvedBase}\0${path8.resolve(cwd)}`;
|
|
1910
2135
|
const cached = settledDataDirs.get(memoKey);
|
|
1911
2136
|
if (cached !== void 0)
|
|
1912
2137
|
return cached;
|
|
1913
|
-
if (!configuredBase &&
|
|
2138
|
+
if (!configuredBase && fs5.existsSync(legacyProjectDir)) {
|
|
1914
2139
|
return legacyProjectDir;
|
|
1915
2140
|
}
|
|
1916
|
-
const canonical =
|
|
2141
|
+
const canonical = dataDirCanonicalRoot(cwd);
|
|
1917
2142
|
const readable = projectDataDirReadableSlug(canonical.root);
|
|
1918
2143
|
const hash = projectDataDirRootHash(canonical.root);
|
|
1919
2144
|
const slug = `${readable || "default"}-${hash}`;
|
|
1920
2145
|
const base = isEphemeralCheckoutRoot(cwd) ? ephemeralDataBase(resolvedBase) : resolvedBase;
|
|
1921
|
-
const dir =
|
|
2146
|
+
const dir = path8.join(base, slug);
|
|
1922
2147
|
if (base !== resolvedBase && pendingDataDirMigrations.length < 32) {
|
|
1923
2148
|
pendingDataDirMigrations.push({ to: dir, outcome: "ephemeral" });
|
|
1924
2149
|
}
|
|
1925
2150
|
const settled = settleProjectDataDir(base, readable || "default", dir, memoKey, canonical.fallback);
|
|
2151
|
+
if (settled === dir) {
|
|
2152
|
+
adoptSpelledDataDirs(path8.resolve(cwd), base, dir, readable || "default");
|
|
2153
|
+
}
|
|
1926
2154
|
return settled;
|
|
1927
2155
|
}
|
|
2156
|
+
var ADOPT_MAX_ENTRIES = 4096;
|
|
2157
|
+
var ADOPTED_MARKER_PREFIX = ".adopted-";
|
|
2158
|
+
function adoptSpelledDataDirs(spelledRoot, base, dir, settledOldSlug) {
|
|
2159
|
+
const readable = projectDataDirReadableSlug(spelledRoot) || "default";
|
|
2160
|
+
const sources = [`${readable}-${projectDataDirRootHash(spelledRoot)}`];
|
|
2161
|
+
if (readable !== settledOldSlug)
|
|
2162
|
+
sources.push(readable);
|
|
2163
|
+
let copied = 0;
|
|
2164
|
+
let failed = 0;
|
|
2165
|
+
for (const source of sources) {
|
|
2166
|
+
const outcome = adoptSource(base, source, dir);
|
|
2167
|
+
copied += outcome.copied;
|
|
2168
|
+
failed += outcome.failed;
|
|
2169
|
+
}
|
|
2170
|
+
if ((copied > 0 || failed > 0) && pendingDataDirMigrations.length < 32) {
|
|
2171
|
+
pendingDataDirMigrations.push({
|
|
2172
|
+
to: dir,
|
|
2173
|
+
outcome: failed > 0 ? "adopt-failed" : "adopted"
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
function adoptSource(base, source, dir) {
|
|
2178
|
+
const from = path8.join(base, source);
|
|
2179
|
+
if (from === dir || !isDirectory(from))
|
|
2180
|
+
return { copied: 0, failed: 0 };
|
|
2181
|
+
const marker = path8.join(dir, `${ADOPTED_MARKER_PREFIX}${source}`);
|
|
2182
|
+
if (fs5.existsSync(marker))
|
|
2183
|
+
return { copied: 0, failed: 0 };
|
|
2184
|
+
const { copied, failed } = copyMissingFiles(from, dir);
|
|
2185
|
+
return { copied, failed: failed + (markAdopted(marker) ? 0 : 1) };
|
|
2186
|
+
}
|
|
2187
|
+
function markAdopted(marker) {
|
|
2188
|
+
try {
|
|
2189
|
+
fs5.mkdirSync(path8.dirname(marker), { recursive: true });
|
|
2190
|
+
writeFileAtomic(marker, "", { bestEffort: false });
|
|
2191
|
+
return true;
|
|
2192
|
+
} catch {
|
|
2193
|
+
return false;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
function isDirectory(dir) {
|
|
2197
|
+
try {
|
|
2198
|
+
return fs5.statSync(dir).isDirectory();
|
|
2199
|
+
} catch {
|
|
2200
|
+
return false;
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
function copyMissingFiles(from, to) {
|
|
2204
|
+
let copied = 0;
|
|
2205
|
+
let failed = 0;
|
|
2206
|
+
let seen = 0;
|
|
2207
|
+
const pending = [""];
|
|
2208
|
+
while (pending.length > 0) {
|
|
2209
|
+
const rel = pending.pop() ?? "";
|
|
2210
|
+
let entries;
|
|
2211
|
+
try {
|
|
2212
|
+
entries = fs5.readdirSync(path8.join(from, rel), { withFileTypes: true });
|
|
2213
|
+
} catch {
|
|
2214
|
+
failed++;
|
|
2215
|
+
continue;
|
|
2216
|
+
}
|
|
2217
|
+
for (const entry of entries) {
|
|
2218
|
+
const name = entry.name;
|
|
2219
|
+
if (name.endsWith(".lock") || name.endsWith(".locks"))
|
|
2220
|
+
continue;
|
|
2221
|
+
if (STAGE_TMP_PATTERN.test(name))
|
|
2222
|
+
continue;
|
|
2223
|
+
if (name.startsWith(ADOPTED_MARKER_PREFIX))
|
|
2224
|
+
continue;
|
|
2225
|
+
const child = path8.join(rel, name);
|
|
2226
|
+
if (entry.isDirectory()) {
|
|
2227
|
+
if (++seen > ADOPT_MAX_ENTRIES)
|
|
2228
|
+
return { copied, failed: failed + 1 };
|
|
2229
|
+
pending.push(child);
|
|
2230
|
+
continue;
|
|
2231
|
+
}
|
|
2232
|
+
if (!entry.isFile())
|
|
2233
|
+
continue;
|
|
2234
|
+
if (++seen > ADOPT_MAX_ENTRIES)
|
|
2235
|
+
return { copied, failed: failed + 1 };
|
|
2236
|
+
const outcome = copyIfMissing(path8.join(from, child), path8.join(to, child));
|
|
2237
|
+
if (outcome === "copied")
|
|
2238
|
+
copied++;
|
|
2239
|
+
else if (outcome === "failed")
|
|
2240
|
+
failed++;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
return { copied, failed };
|
|
2244
|
+
}
|
|
2245
|
+
function copyIfMissing(source, target) {
|
|
2246
|
+
const stage = stagePathFor(target);
|
|
2247
|
+
let staged = false;
|
|
2248
|
+
try {
|
|
2249
|
+
fs5.mkdirSync(path8.dirname(target), { recursive: true });
|
|
2250
|
+
staged = true;
|
|
2251
|
+
fs5.copyFileSync(source, stage);
|
|
2252
|
+
fs5.linkSync(stage, target);
|
|
2253
|
+
return "copied";
|
|
2254
|
+
} catch (cause) {
|
|
2255
|
+
return staged && cause.code === "EEXIST" ? "present" : "failed";
|
|
2256
|
+
} finally {
|
|
2257
|
+
if (staged)
|
|
2258
|
+
fs5.rmSync(stage, { force: true });
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
1928
2261
|
function projectDataBase() {
|
|
1929
2262
|
const configuredBase = process.env.PILENS_DATA_DIR?.trim();
|
|
1930
|
-
return configuredBase ||
|
|
2263
|
+
return configuredBase || path8.join(getGlobalPiLensDir(), "projects");
|
|
1931
2264
|
}
|
|
1932
2265
|
var EPHEMERAL_DATA_DIR_NAME = ".ephemeral";
|
|
1933
2266
|
var EPHEMERAL_TOKEN_PATTERN = /^(\d+)-[0-9a-f]{8}$/;
|
|
@@ -1943,20 +2276,20 @@ function ephemeralDataBase(resolvedBase) {
|
|
|
1943
2276
|
state.exitHook = true;
|
|
1944
2277
|
process.once("exit", removeEphemeralDataDirs);
|
|
1945
2278
|
}
|
|
1946
|
-
return
|
|
2279
|
+
return path8.join(resolvedBase, EPHEMERAL_DATA_DIR_NAME, state.token);
|
|
1947
2280
|
}
|
|
1948
2281
|
function removeEphemeralDataDirs() {
|
|
1949
|
-
const dir =
|
|
2282
|
+
const dir = path8.join(projectDataBase(), EPHEMERAL_DATA_DIR_NAME, ephemeralDataToken().token);
|
|
1950
2283
|
try {
|
|
1951
|
-
|
|
2284
|
+
fs5.rmSync(dir, { recursive: true, force: true });
|
|
1952
2285
|
} catch {
|
|
1953
2286
|
}
|
|
1954
2287
|
}
|
|
1955
2288
|
async function sweepDeadEphemeralDataDirs(options) {
|
|
1956
|
-
const parent =
|
|
2289
|
+
const parent = path8.join(projectDataBase(), EPHEMERAL_DATA_DIR_NAME);
|
|
1957
2290
|
let handle;
|
|
1958
2291
|
try {
|
|
1959
|
-
handle = await
|
|
2292
|
+
handle = await fs5.promises.opendir(parent);
|
|
1960
2293
|
} catch {
|
|
1961
2294
|
return 0;
|
|
1962
2295
|
}
|
|
@@ -1970,7 +2303,7 @@ async function sweepDeadEphemeralDataDirs(options) {
|
|
|
1970
2303
|
if (pid === void 0 || options.isPidAlive(Number(pid)))
|
|
1971
2304
|
continue;
|
|
1972
2305
|
try {
|
|
1973
|
-
await
|
|
2306
|
+
await fs5.promises.rm(path8.join(parent, entry.name), {
|
|
1974
2307
|
recursive: true,
|
|
1975
2308
|
force: true
|
|
1976
2309
|
});
|
|
@@ -1986,17 +2319,18 @@ async function sweepDeadEphemeralDataDirs(options) {
|
|
|
1986
2319
|
return removed;
|
|
1987
2320
|
}
|
|
1988
2321
|
function projectDataDirReadableSlug(canonicalRoot) {
|
|
1989
|
-
const normalized =
|
|
2322
|
+
const normalized = normalizePathSpelling(canonicalRoot);
|
|
1990
2323
|
return normalized.replace(/^[a-z]:/i, "").replace(/\/+/g, "-").replace(/[^A-Za-z0-9-]/g, "").replace(/^-+/, "").replace(/-+$/, "");
|
|
1991
2324
|
}
|
|
1992
|
-
function
|
|
1993
|
-
const resolved =
|
|
2325
|
+
function dataDirCanonicalRoot(cwd, platform = process.platform) {
|
|
2326
|
+
const resolved = path8.resolve(cwd);
|
|
2327
|
+
const root = platform === "win32" ? resolved : realpathOrResolve(resolved);
|
|
1994
2328
|
try {
|
|
1995
|
-
|
|
2329
|
+
fs5.realpathSync(resolved);
|
|
1996
2330
|
} catch {
|
|
1997
|
-
return { root
|
|
2331
|
+
return { root, fallback: true };
|
|
1998
2332
|
}
|
|
1999
|
-
return { root
|
|
2333
|
+
return { root, fallback: false };
|
|
2000
2334
|
}
|
|
2001
2335
|
function projectDataDirRootHash(canonicalRoot) {
|
|
2002
2336
|
return createHash("sha256").update(canonicalRoot).digest("hex").slice(0, 8);
|
|
@@ -2007,9 +2341,9 @@ function resetProjectDataDirSessionState() {
|
|
|
2007
2341
|
pendingDataDirMigrations.splice(0);
|
|
2008
2342
|
}
|
|
2009
2343
|
function settleProjectDataDir(base, oldSlug, dir, memoKey, identityFallback) {
|
|
2010
|
-
const oldDir =
|
|
2011
|
-
const newExists =
|
|
2012
|
-
const oldExists =
|
|
2344
|
+
const oldDir = path8.join(base, oldSlug);
|
|
2345
|
+
const newExists = fs5.existsSync(dir);
|
|
2346
|
+
const oldExists = fs5.existsSync(oldDir);
|
|
2013
2347
|
if (!oldExists) {
|
|
2014
2348
|
if (identityFallback && pendingDataDirMigrations.length < 32) {
|
|
2015
2349
|
pendingDataDirMigrations.push({
|
|
@@ -2022,14 +2356,14 @@ function settleProjectDataDir(base, oldSlug, dir, memoKey, identityFallback) {
|
|
|
2022
2356
|
}
|
|
2023
2357
|
if (!newExists) {
|
|
2024
2358
|
try {
|
|
2025
|
-
|
|
2359
|
+
fs5.renameSync(oldDir, dir);
|
|
2026
2360
|
} catch (error) {
|
|
2027
2361
|
if (error.code === "ENOENT") {
|
|
2028
|
-
if (
|
|
2362
|
+
if (fs5.existsSync(dir)) {
|
|
2029
2363
|
settledDataDirs.set(memoKey, dir);
|
|
2030
2364
|
return dir;
|
|
2031
2365
|
}
|
|
2032
|
-
if (
|
|
2366
|
+
if (fs5.existsSync(oldDir))
|
|
2033
2367
|
return oldDir;
|
|
2034
2368
|
return dir;
|
|
2035
2369
|
}
|
|
@@ -2056,7 +2390,7 @@ function drainProjectDataDirMigrations() {
|
|
|
2056
2390
|
return pendingDataDirMigrations.splice(0);
|
|
2057
2391
|
}
|
|
2058
2392
|
function displayProjectDataPath(cwd, ...segments) {
|
|
2059
|
-
const absolute =
|
|
2393
|
+
const absolute = path8.resolve(getProjectDataDir(cwd), ...segments);
|
|
2060
2394
|
const absolutePosix = absolute.replace(/\\/g, "/");
|
|
2061
2395
|
const relative3 = toProjectRelativePath(absolute, cwd);
|
|
2062
2396
|
if (relative3 !== absolutePosix) {
|
|
@@ -2065,19 +2399,16 @@ function displayProjectDataPath(cwd, ...segments) {
|
|
|
2065
2399
|
return homeRelativePath(absolutePosix);
|
|
2066
2400
|
}
|
|
2067
2401
|
function getGlobalPiLensDir() {
|
|
2068
|
-
|
|
2069
|
-
if (override)
|
|
2070
|
-
return path7.resolve(override);
|
|
2071
|
-
return path7.join(os2.homedir(), ".pi-lens");
|
|
2402
|
+
return machineStateDir();
|
|
2072
2403
|
}
|
|
2073
2404
|
function isPiLensInternalPath(filePath, projectRoot) {
|
|
2074
|
-
const absolute =
|
|
2075
|
-
const home =
|
|
2405
|
+
const absolute = path8.resolve(filePath);
|
|
2406
|
+
const home = path8.resolve(os3.homedir());
|
|
2076
2407
|
const candidates = [
|
|
2077
2408
|
getGlobalPiLensDir(),
|
|
2078
2409
|
getProjectDataDir(projectRoot),
|
|
2079
|
-
|
|
2080
|
-
|
|
2410
|
+
path8.join(home, ".pi"),
|
|
2411
|
+
path8.join(home, ".pi-lens")
|
|
2081
2412
|
];
|
|
2082
2413
|
if (candidates.some((dir) => isUnderDir(absolute, dir)))
|
|
2083
2414
|
return true;
|
|
@@ -2141,12 +2472,12 @@ var EXCLUDED_DIRS = [
|
|
|
2141
2472
|
"vendors"
|
|
2142
2473
|
];
|
|
2143
2474
|
function resolveGitIgnoreRoot(startDir) {
|
|
2144
|
-
const fallback =
|
|
2475
|
+
const fallback = realpathOrResolve(startDir);
|
|
2145
2476
|
let current = fallback;
|
|
2146
2477
|
while (true) {
|
|
2147
|
-
if (
|
|
2478
|
+
if (fs5.existsSync(path8.join(current, ".git")))
|
|
2148
2479
|
return current;
|
|
2149
|
-
const parent =
|
|
2480
|
+
const parent = path8.dirname(current);
|
|
2150
2481
|
if (parent === current)
|
|
2151
2482
|
return fallback;
|
|
2152
2483
|
current = parent;
|
|
@@ -2235,13 +2566,13 @@ function expandGitignorePattern(pattern) {
|
|
|
2235
2566
|
return [body];
|
|
2236
2567
|
return [body, `**/${body}`];
|
|
2237
2568
|
}
|
|
2238
|
-
function matchesGitignorePattern(pattern, relativePath,
|
|
2569
|
+
function matchesGitignorePattern(pattern, relativePath, isDirectory2, matchExpanded) {
|
|
2239
2570
|
const candidate = stripLeadingSlashes(normalizeIgnorePath(relativePath));
|
|
2240
2571
|
if (!candidate)
|
|
2241
2572
|
return false;
|
|
2242
|
-
const candidates =
|
|
2573
|
+
const candidates = isDirectory2 ? [candidate, `${candidate}/`] : [candidate];
|
|
2243
2574
|
return expandGitignorePattern(pattern).some((expanded) => {
|
|
2244
|
-
if (
|
|
2575
|
+
if (isDirectory2 && expanded.endsWith("/**")) {
|
|
2245
2576
|
const prefix = expanded.slice(0, -3);
|
|
2246
2577
|
if (candidate === prefix || candidate.startsWith(`${prefix}/`))
|
|
2247
2578
|
return true;
|
|
@@ -2250,23 +2581,23 @@ function matchesGitignorePattern(pattern, relativePath, isDirectory, matchExpand
|
|
|
2250
2581
|
});
|
|
2251
2582
|
}
|
|
2252
2583
|
function readGitignorePatterns(rootDir, layer = "gitignore") {
|
|
2253
|
-
const gitignorePath =
|
|
2584
|
+
const gitignorePath = path8.join(rootDir, ".gitignore");
|
|
2254
2585
|
try {
|
|
2255
|
-
return parseGitignoreContent(
|
|
2586
|
+
return parseGitignoreContent(fs5.readFileSync(gitignorePath, "utf-8"), layer);
|
|
2256
2587
|
} catch {
|
|
2257
2588
|
return [];
|
|
2258
2589
|
}
|
|
2259
2590
|
}
|
|
2260
2591
|
function ancestorDirsBetween(rootDir, targetDir) {
|
|
2261
|
-
const relative3 =
|
|
2262
|
-
if (relative3.startsWith("..") ||
|
|
2592
|
+
const relative3 = path8.relative(rootDir, targetDir);
|
|
2593
|
+
if (relative3.startsWith("..") || path8.isAbsolute(relative3))
|
|
2263
2594
|
return [];
|
|
2264
2595
|
const dirs = [rootDir];
|
|
2265
2596
|
if (!relative3)
|
|
2266
2597
|
return dirs;
|
|
2267
2598
|
let current = rootDir;
|
|
2268
|
-
for (const segment of relative3.split(
|
|
2269
|
-
current =
|
|
2599
|
+
for (const segment of relative3.split(path8.sep).filter(Boolean)) {
|
|
2600
|
+
current = path8.join(current, segment);
|
|
2270
2601
|
dirs.push(current);
|
|
2271
2602
|
}
|
|
2272
2603
|
return dirs;
|
|
@@ -2276,7 +2607,7 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
|
|
|
2276
2607
|
const rememberIgnoreSource = (filePath, signature = fileFreshnessSignature(filePath)) => {
|
|
2277
2608
|
consumedIgnoreSources.set(filePath, { path: filePath, ...signature });
|
|
2278
2609
|
};
|
|
2279
|
-
rememberIgnoreSource(
|
|
2610
|
+
rememberIgnoreSource(path8.join(resolvedRoot, ".gitignore"));
|
|
2280
2611
|
const nestedCache = /* @__PURE__ */ new Map();
|
|
2281
2612
|
const patternsForDir = (dir) => {
|
|
2282
2613
|
if (dir === resolvedRoot)
|
|
@@ -2287,7 +2618,7 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
|
|
|
2287
2618
|
return cached.patterns;
|
|
2288
2619
|
}
|
|
2289
2620
|
const gitignoreSig = gitignoreSignature(dir);
|
|
2290
|
-
rememberIgnoreSource(
|
|
2621
|
+
rememberIgnoreSource(path8.join(dir, ".gitignore"), gitignoreSig);
|
|
2291
2622
|
const pilensInfo = findPiLensConfigInDir(dir);
|
|
2292
2623
|
const pilensMtime = pilensInfo?.mtimeMs ?? -1;
|
|
2293
2624
|
const pilensSize = pilensInfo?.size ?? -1;
|
|
@@ -2314,18 +2645,31 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
|
|
|
2314
2645
|
};
|
|
2315
2646
|
const patternMemo = /* @__PURE__ */ new Map();
|
|
2316
2647
|
function dropVerdictsUnder(subtree) {
|
|
2317
|
-
const resolvedSubtree =
|
|
2648
|
+
const resolvedSubtree = path8.resolve(subtree);
|
|
2318
2649
|
for (const key of patternMemo.keys()) {
|
|
2319
2650
|
const memoPath = key.slice(2);
|
|
2320
|
-
const relative3 =
|
|
2321
|
-
if (!relative3 || !relative3.startsWith("..") && !
|
|
2651
|
+
const relative3 = path8.relative(resolvedSubtree, memoPath);
|
|
2652
|
+
if (!relative3 || !relative3.startsWith("..") && !path8.isAbsolute(relative3)) {
|
|
2322
2653
|
patternMemo.delete(key);
|
|
2323
2654
|
}
|
|
2324
2655
|
}
|
|
2325
2656
|
}
|
|
2657
|
+
const dirIdentities = /* @__PURE__ */ new Map();
|
|
2658
|
+
const identityOfDir = (dir) => {
|
|
2659
|
+
let identity = dirIdentities.get(dir);
|
|
2660
|
+
if (identity === void 0) {
|
|
2661
|
+
identity = realpathOrResolve(dir);
|
|
2662
|
+
dirIdentities.set(dir, identity);
|
|
2663
|
+
}
|
|
2664
|
+
return identity;
|
|
2665
|
+
};
|
|
2666
|
+
const rootPrefix = resolvedRoot.endsWith(path8.sep) ? resolvedRoot : resolvedRoot + path8.sep;
|
|
2667
|
+
const isUnderRootText = (absolute) => absolute === resolvedRoot || absolute.startsWith(rootPrefix);
|
|
2326
2668
|
const invalidateSubtree = (subtree) => {
|
|
2327
|
-
|
|
2328
|
-
|
|
2669
|
+
const absolute = path8.resolve(subtree);
|
|
2670
|
+
const local = isUnderRootText(absolute) ? absolute : identityOfDir(absolute);
|
|
2671
|
+
dropVerdictsUnder(local);
|
|
2672
|
+
nestedCache.delete(local);
|
|
2329
2673
|
};
|
|
2330
2674
|
const gitignoreGlobOptions = {
|
|
2331
2675
|
dot: true,
|
|
@@ -2358,26 +2702,27 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
|
|
|
2358
2702
|
ensureTrackedIndex() {
|
|
2359
2703
|
return collectTrackedFiles(resolvedRoot).then(() => void 0);
|
|
2360
2704
|
},
|
|
2361
|
-
isIgnored(filePath,
|
|
2362
|
-
const
|
|
2363
|
-
const
|
|
2705
|
+
isIgnored(filePath, isDirectory2 = false) {
|
|
2706
|
+
const spelled = path8.resolve(filePath);
|
|
2707
|
+
const resolved = isUnderRootText(spelled) ? spelled : path8.join(identityOfDir(path8.dirname(spelled)), path8.basename(spelled));
|
|
2708
|
+
const memoKey = (isDirectory2 ? "D:" : "F:") + resolved;
|
|
2364
2709
|
let verdict = patternMemo.get(memoKey);
|
|
2365
2710
|
if (verdict === void 0) {
|
|
2366
|
-
const rootRelative =
|
|
2367
|
-
if (!rootRelative || rootRelative.startsWith("..") ||
|
|
2711
|
+
const rootRelative = path8.relative(resolvedRoot, resolved);
|
|
2712
|
+
if (!rootRelative || rootRelative.startsWith("..") || path8.isAbsolute(rootRelative)) {
|
|
2368
2713
|
verdict = { ignored: false, layer: void 0 };
|
|
2369
2714
|
} else {
|
|
2370
2715
|
let ignored = false;
|
|
2371
2716
|
let layer;
|
|
2372
|
-
const patternDirs = ancestorDirsBetween(resolvedRoot,
|
|
2717
|
+
const patternDirs = ancestorDirsBetween(resolvedRoot, path8.dirname(resolved));
|
|
2373
2718
|
for (const dir of patternDirs) {
|
|
2374
2719
|
const dirPatterns = patternsForDir(dir);
|
|
2375
2720
|
if (dirPatterns.length === 0)
|
|
2376
2721
|
continue;
|
|
2377
|
-
const relative3 =
|
|
2722
|
+
const relative3 = path8.relative(dir, resolved);
|
|
2378
2723
|
const normalized = normalizeIgnorePath(relative3);
|
|
2379
2724
|
for (const pattern of dirPatterns) {
|
|
2380
|
-
if (!matchesGitignorePattern(pattern, normalized,
|
|
2725
|
+
if (!matchesGitignorePattern(pattern, normalized, isDirectory2, matchExpanded))
|
|
2381
2726
|
continue;
|
|
2382
2727
|
ignored = !pattern.negated;
|
|
2383
2728
|
layer = pattern.layer;
|
|
@@ -2389,7 +2734,7 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
|
|
|
2389
2734
|
}
|
|
2390
2735
|
if (!verdict.ignored)
|
|
2391
2736
|
return false;
|
|
2392
|
-
if (!
|
|
2737
|
+
if (!isDirectory2 && verdict.layer !== "pilens" && isTrackedAndRescued(resolved)) {
|
|
2393
2738
|
return false;
|
|
2394
2739
|
}
|
|
2395
2740
|
return true;
|
|
@@ -2409,7 +2754,7 @@ var projectIgnoreMatcherCache = /* @__PURE__ */ new Map();
|
|
|
2409
2754
|
var PROJECT_IGNORE_FRESHNESS_CADENCE_MS = FRESHNESS_CADENCE_MS;
|
|
2410
2755
|
function fileFreshnessSignature(filePath) {
|
|
2411
2756
|
try {
|
|
2412
|
-
const stat =
|
|
2757
|
+
const stat = fs5.statSync(filePath);
|
|
2413
2758
|
return { mtimeMs: stat.mtimeMs, size: stat.size };
|
|
2414
2759
|
} catch {
|
|
2415
2760
|
return { mtimeMs: -1, size: -1 };
|
|
@@ -2419,7 +2764,7 @@ function globalConfigSignature() {
|
|
|
2419
2764
|
return fileFreshnessSignature(getPiLensGlobalConfigPath());
|
|
2420
2765
|
}
|
|
2421
2766
|
function gitignoreSignature(rootDir) {
|
|
2422
|
-
return fileFreshnessSignature(
|
|
2767
|
+
return fileFreshnessSignature(path8.join(rootDir, ".gitignore"));
|
|
2423
2768
|
}
|
|
2424
2769
|
function hasIgnoreSourceDrift(sources) {
|
|
2425
2770
|
return sources.some((source) => {
|
|
@@ -2480,21 +2825,21 @@ function getProjectIgnoreMatcher(rootDir) {
|
|
|
2480
2825
|
return matcher;
|
|
2481
2826
|
}
|
|
2482
2827
|
function invalidateProjectIgnoreMatcherForPath(filePath) {
|
|
2483
|
-
const resolvedPath =
|
|
2484
|
-
if (
|
|
2828
|
+
const resolvedPath = path8.resolve(filePath);
|
|
2829
|
+
if (path8.basename(resolvedPath).toLowerCase() !== ".gitignore")
|
|
2485
2830
|
return;
|
|
2486
2831
|
for (const [cachedRoot, cached] of projectIgnoreMatcherCache) {
|
|
2487
2832
|
if (!isUnderDir(resolvedPath, cachedRoot))
|
|
2488
2833
|
continue;
|
|
2489
|
-
if (normalizeFilePath(resolvedPath) === normalizeFilePath(
|
|
2834
|
+
if (normalizeFilePath(resolvedPath) === normalizeFilePath(path8.join(cachedRoot, ".gitignore"))) {
|
|
2490
2835
|
projectIgnoreMatcherCache.delete(cachedRoot);
|
|
2491
2836
|
continue;
|
|
2492
2837
|
}
|
|
2493
|
-
cached.matcher.invalidateSubtree(
|
|
2838
|
+
cached.matcher.invalidateSubtree(path8.dirname(resolvedPath));
|
|
2494
2839
|
}
|
|
2495
2840
|
}
|
|
2496
|
-
function isPathIgnoredByProject(filePath, rootDir,
|
|
2497
|
-
return getProjectIgnoreMatcher(rootDir).isIgnored(filePath,
|
|
2841
|
+
function isPathIgnoredByProject(filePath, rootDir, isDirectory2 = false) {
|
|
2842
|
+
return getProjectIgnoreMatcher(rootDir).isIgnored(filePath, isDirectory2);
|
|
2498
2843
|
}
|
|
2499
2844
|
function isRecordableProjectPath(filePath, projectRoot) {
|
|
2500
2845
|
if (isPathIgnoredByProject(filePath, projectRoot, false))
|
|
@@ -2505,7 +2850,7 @@ function isRecordableProjectPath(filePath, projectRoot) {
|
|
|
2505
2850
|
}
|
|
2506
2851
|
var projectIgnoreGlobsCache = /* @__PURE__ */ new Map();
|
|
2507
2852
|
function getProjectIgnoreGlobs(rootDir) {
|
|
2508
|
-
const resolvedRoot =
|
|
2853
|
+
const resolvedRoot = path8.resolve(rootDir);
|
|
2509
2854
|
const signature = gitignoreSignature(resolvedRoot);
|
|
2510
2855
|
const cached = projectIgnoreGlobsCache.get(resolvedRoot);
|
|
2511
2856
|
if (cached && cached.mtimeMs === signature.mtimeMs && cached.size === signature.size) {
|
|
@@ -2565,8 +2910,8 @@ function isTestFile(filePath) {
|
|
|
2565
2910
|
}
|
|
2566
2911
|
|
|
2567
2912
|
// dist/clients/instance-registry.js
|
|
2568
|
-
import * as
|
|
2569
|
-
import * as
|
|
2913
|
+
import * as fs8 from "node:fs";
|
|
2914
|
+
import * as path11 from "node:path";
|
|
2570
2915
|
|
|
2571
2916
|
// dist/clients/generation-guard.js
|
|
2572
2917
|
var declaredSources = /* @__PURE__ */ new Set();
|
|
@@ -2690,9 +3035,9 @@ function createGenerationMap(name, options = {}) {
|
|
|
2690
3035
|
}
|
|
2691
3036
|
|
|
2692
3037
|
// dist/clients/instance-registry-lock.js
|
|
2693
|
-
import * as
|
|
3038
|
+
import * as fs6 from "node:fs";
|
|
2694
3039
|
import { randomInt as randomInt2 } from "node:crypto";
|
|
2695
|
-
import * as
|
|
3040
|
+
import * as path9 from "node:path";
|
|
2696
3041
|
var OWN_HOLDS_FAMILY = "instance-registry.lock-own-holds";
|
|
2697
3042
|
var OWN_HOLDS_VERSION = 1;
|
|
2698
3043
|
function ownAsyncHolds() {
|
|
@@ -2712,7 +3057,7 @@ function legacyLockPath(target) {
|
|
|
2712
3057
|
}
|
|
2713
3058
|
function createLegacyLock(lock) {
|
|
2714
3059
|
try {
|
|
2715
|
-
|
|
3060
|
+
fs6.writeFileSync(lock, `${process.pid} ${Date.now()}
|
|
2716
3061
|
`, { flag: "wx" });
|
|
2717
3062
|
return true;
|
|
2718
3063
|
} catch (error) {
|
|
@@ -2727,7 +3072,7 @@ function takeLegacyLock(lock) {
|
|
|
2727
3072
|
if (!pidFileIsStale(lock, LOCK_STALE_MS))
|
|
2728
3073
|
return false;
|
|
2729
3074
|
try {
|
|
2730
|
-
|
|
3075
|
+
fs6.unlinkSync(lock);
|
|
2731
3076
|
} catch {
|
|
2732
3077
|
}
|
|
2733
3078
|
return createLegacyLock(lock);
|
|
@@ -2736,7 +3081,7 @@ function releaseLegacyLock(lock) {
|
|
|
2736
3081
|
if (pidFileOwner(lock) !== process.pid)
|
|
2737
3082
|
return;
|
|
2738
3083
|
try {
|
|
2739
|
-
|
|
3084
|
+
fs6.unlinkSync(lock);
|
|
2740
3085
|
} catch {
|
|
2741
3086
|
}
|
|
2742
3087
|
}
|
|
@@ -2768,14 +3113,14 @@ function recordLockFailure(target, cause) {
|
|
|
2768
3113
|
const code = cause?.code ?? "unknown";
|
|
2769
3114
|
incrementDegradationCount({
|
|
2770
3115
|
kind: "instance-registry-lock-failed",
|
|
2771
|
-
subject:
|
|
2772
|
-
reason: `lock acquisition failed for ${
|
|
3116
|
+
subject: path9.resolve(target),
|
|
3117
|
+
reason: `lock acquisition failed for ${path9.basename(target)} (${code}); the registry write was skipped`
|
|
2773
3118
|
});
|
|
2774
3119
|
}
|
|
2775
3120
|
function recordStaleTakeover(target, hold) {
|
|
2776
3121
|
incrementDegradationCount({
|
|
2777
3122
|
kind: "instance-registry-lock-stale-takeover",
|
|
2778
|
-
subject:
|
|
3123
|
+
subject: path9.resolve(target),
|
|
2779
3124
|
reason: `took over lock generation ${hold.generation - 1} from a dead or aged-out holder`
|
|
2780
3125
|
});
|
|
2781
3126
|
}
|
|
@@ -2783,15 +3128,15 @@ function recordLegacyHeld(target) {
|
|
|
2783
3128
|
const lock = legacyLockPath(target);
|
|
2784
3129
|
incrementDegradationCount({
|
|
2785
3130
|
kind: "instance-registry-lock-legacy-held",
|
|
2786
|
-
subject:
|
|
2787
|
-
reason: `backed off: ${
|
|
3131
|
+
subject: path9.resolve(lock),
|
|
3132
|
+
reason: `backed off: ${path9.basename(lock)} is held by pid ${pidFileOwner(lock) ?? "unknown"}, a writer from before #3476`
|
|
2788
3133
|
});
|
|
2789
3134
|
}
|
|
2790
3135
|
function recordLockTimeout(target) {
|
|
2791
3136
|
incrementDegradationCount({
|
|
2792
3137
|
kind: "instance-registry-lock-timeout",
|
|
2793
|
-
subject:
|
|
2794
|
-
reason: `lock acquisition exhausted for ${
|
|
3138
|
+
subject: path9.resolve(target),
|
|
3139
|
+
reason: `lock acquisition exhausted for ${path9.basename(target)}`
|
|
2795
3140
|
});
|
|
2796
3141
|
}
|
|
2797
3142
|
function backoffMs() {
|
|
@@ -2806,7 +3151,7 @@ async function withInstanceRegistryLock(target, op, waitMs = LOCK_WAIT_MS) {
|
|
|
2806
3151
|
return void 0;
|
|
2807
3152
|
if (hold === "busy") {
|
|
2808
3153
|
if (Date.now() <= deadline)
|
|
2809
|
-
await new Promise((
|
|
3154
|
+
await new Promise((resolve7) => setTimeout(resolve7, backoffMs()));
|
|
2810
3155
|
continue;
|
|
2811
3156
|
}
|
|
2812
3157
|
const holds = ownAsyncHolds();
|
|
@@ -2823,8 +3168,8 @@ async function withInstanceRegistryLock(target, op, waitMs = LOCK_WAIT_MS) {
|
|
|
2823
3168
|
}
|
|
2824
3169
|
|
|
2825
3170
|
// dist/scripts/lib/process-scan.mjs
|
|
2826
|
-
import
|
|
2827
|
-
import
|
|
3171
|
+
import fs7 from "node:fs";
|
|
3172
|
+
import path10 from "node:path";
|
|
2828
3173
|
function runningOnWindows() {
|
|
2829
3174
|
return process.platform === "win32";
|
|
2830
3175
|
}
|
|
@@ -2842,13 +3187,13 @@ var FIELD_ORDER = Object.freeze(Object.keys(FIELD_COLUMNS));
|
|
|
2842
3187
|
var ALL_PROCESS_FIELDS = Object.freeze(["pid", "ppid", "command"]);
|
|
2843
3188
|
var FILTERABLE_COLUMNS = /* @__PURE__ */ new Set(["ProcessId", "Name", "CommandLine"]);
|
|
2844
3189
|
function windowsExe(name) {
|
|
2845
|
-
return
|
|
3190
|
+
return path10.join(process.env.SystemRoot ?? path10.join("C:", "Windows"), "System32", name);
|
|
2846
3191
|
}
|
|
2847
3192
|
function posixPsPath() {
|
|
2848
3193
|
try {
|
|
2849
|
-
if (
|
|
3194
|
+
if (fs7.existsSync("/bin/ps"))
|
|
2850
3195
|
return "/bin/ps";
|
|
2851
|
-
if (
|
|
3196
|
+
if (fs7.existsSync("/usr/bin/ps"))
|
|
2852
3197
|
return "/usr/bin/ps";
|
|
2853
3198
|
} catch {
|
|
2854
3199
|
}
|
|
@@ -2945,8 +3290,8 @@ function posixStartEnv() {
|
|
|
2945
3290
|
}
|
|
2946
3291
|
function readLinuxProcessStart(pid) {
|
|
2947
3292
|
try {
|
|
2948
|
-
const ticks = parseLinuxStatStart(
|
|
2949
|
-
const boot =
|
|
3293
|
+
const ticks = parseLinuxStatStart(fs7.readFileSync(`/proc/${assertPid(pid)}/stat`, "utf8"));
|
|
3294
|
+
const boot = fs7.readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
2950
3295
|
const offset = readBoottimeOffsetTicks();
|
|
2951
3296
|
return ticks === void 0 || offset === void 0 || !/^[0-9a-f-]{36}$/.test(boot) ? void 0 : `${Number(ticks) - offset}@${boot}`;
|
|
2952
3297
|
} catch {
|
|
@@ -2958,7 +3303,7 @@ var NSEC_PER_TICK = 1e9 / USER_HZ;
|
|
|
2958
3303
|
function readBoottimeOffsetTicks() {
|
|
2959
3304
|
let text;
|
|
2960
3305
|
try {
|
|
2961
|
-
text =
|
|
3306
|
+
text = fs7.readFileSync("/proc/self/timens_offsets", "utf8");
|
|
2962
3307
|
} catch (error) {
|
|
2963
3308
|
return (
|
|
2964
3309
|
/** @type {NodeJS.ErrnoException} */
|
|
@@ -2980,7 +3325,7 @@ function parseLinuxStatStart(stat) {
|
|
|
2980
3325
|
}
|
|
2981
3326
|
function readLinuxPidNamespace(pid) {
|
|
2982
3327
|
try {
|
|
2983
|
-
return
|
|
3328
|
+
return fs7.readlinkSync(`/proc/${assertPid(pid)}/ns/pid`);
|
|
2984
3329
|
} catch {
|
|
2985
3330
|
return void 0;
|
|
2986
3331
|
}
|
|
@@ -3243,7 +3588,7 @@ function subagentLightModeNotice() {
|
|
|
3243
3588
|
|
|
3244
3589
|
// dist/clients/instance-registry.js
|
|
3245
3590
|
function registryPath() {
|
|
3246
|
-
return
|
|
3591
|
+
return path11.join(getGlobalPiLensDir(), "instances.json");
|
|
3247
3592
|
}
|
|
3248
3593
|
function startReadOptions() {
|
|
3249
3594
|
return {
|
|
@@ -3273,7 +3618,7 @@ function recordCorruptRegistryRead(reasonCode) {
|
|
|
3273
3618
|
}
|
|
3274
3619
|
async function readRegistryAsync() {
|
|
3275
3620
|
try {
|
|
3276
|
-
const raw = await
|
|
3621
|
+
const raw = await fs8.promises.readFile(registryPath(), "utf-8");
|
|
3277
3622
|
const parsed = JSON.parse(raw);
|
|
3278
3623
|
if (parsed && Array.isArray(parsed.instances)) {
|
|
3279
3624
|
return parsed;
|
|
@@ -3295,7 +3640,7 @@ async function writeRegistryAsync(file) {
|
|
|
3295
3640
|
const dir = getGlobalPiLensDir();
|
|
3296
3641
|
const target = registryPath();
|
|
3297
3642
|
try {
|
|
3298
|
-
await
|
|
3643
|
+
await fs8.promises.mkdir(dir, { recursive: true });
|
|
3299
3644
|
} catch {
|
|
3300
3645
|
return;
|
|
3301
3646
|
}
|
|
@@ -3709,8 +4054,8 @@ async function sweepAtomicWriteStages(directories, options = {}) {
|
|
|
3709
4054
|
var KILL_VERIFY_ATTEMPTS = 5;
|
|
3710
4055
|
var KILL_VERIFY_INTERVAL_MS = 100;
|
|
3711
4056
|
function sleepUnref(ms) {
|
|
3712
|
-
return new Promise((
|
|
3713
|
-
const timer = setTimeout(
|
|
4057
|
+
return new Promise((resolve7) => {
|
|
4058
|
+
const timer = setTimeout(resolve7, ms);
|
|
3714
4059
|
timer.unref();
|
|
3715
4060
|
});
|
|
3716
4061
|
}
|
|
@@ -3728,9 +4073,9 @@ async function killPidTree(pid, options = {}) {
|
|
|
3728
4073
|
stdio: "ignore"
|
|
3729
4074
|
});
|
|
3730
4075
|
unrefChildAndPipes(killer);
|
|
3731
|
-
await new Promise((
|
|
3732
|
-
killer.once("close", () =>
|
|
3733
|
-
killer.once("error", () =>
|
|
4076
|
+
await new Promise((resolve7) => {
|
|
4077
|
+
killer.once("close", () => resolve7());
|
|
4078
|
+
killer.once("error", () => resolve7());
|
|
3734
4079
|
});
|
|
3735
4080
|
} catch {
|
|
3736
4081
|
}
|
|
@@ -4017,9 +4362,9 @@ async function sampleProcessTreeCpuPercent(pid, windowMs = 1200, floorPercent =
|
|
|
4017
4362
|
}
|
|
4018
4363
|
};
|
|
4019
4364
|
const first = await readOnce();
|
|
4020
|
-
const second = await new Promise((
|
|
4365
|
+
const second = await new Promise((resolve7) => {
|
|
4021
4366
|
const timer = setTimeout(() => {
|
|
4022
|
-
void readOnce().then(
|
|
4367
|
+
void readOnce().then(resolve7);
|
|
4023
4368
|
}, windowMs);
|
|
4024
4369
|
timer.unref?.();
|
|
4025
4370
|
});
|
|
@@ -4164,7 +4509,7 @@ async function cwdIsUnresolvable(cwd) {
|
|
|
4164
4509
|
if (cwd === void 0)
|
|
4165
4510
|
return false;
|
|
4166
4511
|
try {
|
|
4167
|
-
return !(await
|
|
4512
|
+
return !(await fs9.promises.stat(cwd)).isDirectory();
|
|
4168
4513
|
} catch {
|
|
4169
4514
|
return true;
|
|
4170
4515
|
}
|
|
@@ -4173,7 +4518,7 @@ function cwdIsUnresolvableSync(cwd) {
|
|
|
4173
4518
|
if (cwd === void 0)
|
|
4174
4519
|
return false;
|
|
4175
4520
|
try {
|
|
4176
|
-
return !
|
|
4521
|
+
return !fs9.statSync(cwd).isDirectory();
|
|
4177
4522
|
} catch {
|
|
4178
4523
|
return true;
|
|
4179
4524
|
}
|
|
@@ -4186,19 +4531,19 @@ function commandProbablyPresent(command) {
|
|
|
4186
4531
|
const existsWithExt = (base) => {
|
|
4187
4532
|
for (const ext of exts) {
|
|
4188
4533
|
try {
|
|
4189
|
-
if (
|
|
4534
|
+
if (fs9.existsSync(base + ext))
|
|
4190
4535
|
return true;
|
|
4191
4536
|
} catch {
|
|
4192
4537
|
}
|
|
4193
4538
|
}
|
|
4194
4539
|
return false;
|
|
4195
4540
|
};
|
|
4196
|
-
if (
|
|
4541
|
+
if (path12.isAbsolute(command))
|
|
4197
4542
|
return existsWithExt(command);
|
|
4198
4543
|
if (command.includes("/") || command.includes("\\"))
|
|
4199
4544
|
return "ambiguous";
|
|
4200
|
-
for (const dir of (process.env.PATH ?? "").split(
|
|
4201
|
-
if (dir && existsWithExt(
|
|
4545
|
+
for (const dir of (process.env.PATH ?? "").split(path12.delimiter)) {
|
|
4546
|
+
if (dir && existsWithExt(path12.join(dir, command)))
|
|
4202
4547
|
return true;
|
|
4203
4548
|
}
|
|
4204
4549
|
return false;
|
|
@@ -4268,7 +4613,7 @@ var PROC_PPID_READABLE = (() => {
|
|
|
4268
4613
|
if (process.platform !== "linux")
|
|
4269
4614
|
return false;
|
|
4270
4615
|
try {
|
|
4271
|
-
return /^PPid:\s*\d+$/m.test(
|
|
4616
|
+
return /^PPid:\s*\d+$/m.test(fs9.readFileSync("/proc/self/status", "utf8"));
|
|
4272
4617
|
} catch {
|
|
4273
4618
|
return false;
|
|
4274
4619
|
}
|
|
@@ -4334,7 +4679,7 @@ function isOwnLiveChild(pid, site, handle) {
|
|
|
4334
4679
|
}
|
|
4335
4680
|
let status;
|
|
4336
4681
|
try {
|
|
4337
|
-
status =
|
|
4682
|
+
status = fs9.readFileSync(`/proc/${pid}/status`, "utf8");
|
|
4338
4683
|
} catch {
|
|
4339
4684
|
return heldOwnPids.has(pid) || verifiedOwnPids.has(pid);
|
|
4340
4685
|
}
|
|
@@ -4459,13 +4804,13 @@ function mergeWindowsEnvironment(base, overrides) {
|
|
|
4459
4804
|
merged[key] = value;
|
|
4460
4805
|
return merged;
|
|
4461
4806
|
}
|
|
4807
|
+
function windowsEnvironmentKeys(env, name) {
|
|
4808
|
+
const folded = name.toLowerCase();
|
|
4809
|
+
return Object.keys(env).filter((key) => key.toLowerCase() === folded);
|
|
4810
|
+
}
|
|
4462
4811
|
function getWindowsEnvironmentValue(env, name) {
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
if (key.toLowerCase() === name.toLowerCase())
|
|
4466
|
-
value = entry;
|
|
4467
|
-
}
|
|
4468
|
-
return value;
|
|
4812
|
+
const key = windowsEnvironmentKeys(env, name).at(-1);
|
|
4813
|
+
return key === void 0 ? void 0 : env[key];
|
|
4469
4814
|
}
|
|
4470
4815
|
function driveLetter(value) {
|
|
4471
4816
|
const match = /^([A-Za-z]):/.exec(value);
|
|
@@ -4490,30 +4835,30 @@ function isRootedWindowsPath(value) {
|
|
|
4490
4835
|
function resolveRootedWindowsPath(value, driveSource) {
|
|
4491
4836
|
const drive = driveLetter(driveSource);
|
|
4492
4837
|
if (drive === void 0)
|
|
4493
|
-
return
|
|
4494
|
-
return
|
|
4838
|
+
return path12.win32.normalize(value);
|
|
4839
|
+
return path12.win32.normalize(path12.win32.resolve(`${drive}:\\`, value));
|
|
4495
4840
|
}
|
|
4496
4841
|
function getValidatedPerDriveCwd(env, drive) {
|
|
4497
4842
|
const value = getWindowsEnvironmentValue(env, `=${drive}:`);
|
|
4498
4843
|
if (value === void 0 || !isDriveAbsolute(value, drive))
|
|
4499
4844
|
return void 0;
|
|
4500
|
-
return
|
|
4845
|
+
return path12.win32.normalize(value);
|
|
4501
4846
|
}
|
|
4502
4847
|
function resolveEffectiveWindowsCwd(cwd, env) {
|
|
4503
4848
|
if (cwd === void 0) {
|
|
4504
|
-
return
|
|
4849
|
+
return path12.win32.normalize(process.cwd());
|
|
4505
4850
|
}
|
|
4506
4851
|
const requestedDrive = driveLetter(cwd);
|
|
4507
4852
|
if (requestedDrive !== void 0 && !isDriveAbsoluteAnyDrive(cwd)) {
|
|
4508
4853
|
const base = getValidatedPerDriveCwd(env, requestedDrive);
|
|
4509
|
-
return base === void 0 ? void 0 :
|
|
4854
|
+
return base === void 0 ? void 0 : path12.win32.normalize(path12.win32.resolve(base, cwd));
|
|
4510
4855
|
}
|
|
4511
4856
|
if (isFullyQualifiedWindowsPath(cwd))
|
|
4512
|
-
return
|
|
4857
|
+
return path12.win32.normalize(cwd);
|
|
4513
4858
|
if (isRootedWindowsPath(cwd)) {
|
|
4514
4859
|
return resolveRootedWindowsPath(cwd, process.cwd());
|
|
4515
4860
|
}
|
|
4516
|
-
return
|
|
4861
|
+
return path12.win32.normalize(path12.win32.resolve(process.cwd(), cwd));
|
|
4517
4862
|
}
|
|
4518
4863
|
function resolveDriveRelativeWindowsPath(value, effectiveCwd, env) {
|
|
4519
4864
|
const drive = driveLetter(value);
|
|
@@ -4523,20 +4868,20 @@ function resolveDriveRelativeWindowsPath(value, effectiveCwd, env) {
|
|
|
4523
4868
|
const base = cwdDrive?.toUpperCase() === drive ? effectiveCwd : getValidatedPerDriveCwd(env, drive);
|
|
4524
4869
|
if (base === void 0)
|
|
4525
4870
|
return void 0;
|
|
4526
|
-
return
|
|
4871
|
+
return path12.win32.normalize(path12.win32.resolve(base, value));
|
|
4527
4872
|
}
|
|
4528
4873
|
function resolveWindowsPathEntry(entry, effectiveCwd, env) {
|
|
4529
4874
|
if (driveLetter(entry) !== void 0 && !isDriveAbsoluteAnyDrive(entry)) {
|
|
4530
4875
|
return resolveDriveRelativeWindowsPath(entry, effectiveCwd, env);
|
|
4531
4876
|
}
|
|
4532
4877
|
if (isFullyQualifiedWindowsPath(entry))
|
|
4533
|
-
return
|
|
4878
|
+
return path12.win32.normalize(entry);
|
|
4534
4879
|
if (isRootedWindowsPath(entry)) {
|
|
4535
4880
|
return effectiveCwd === void 0 ? void 0 : resolveRootedWindowsPath(entry, effectiveCwd);
|
|
4536
4881
|
}
|
|
4537
4882
|
if (effectiveCwd === void 0)
|
|
4538
4883
|
return void 0;
|
|
4539
|
-
return
|
|
4884
|
+
return path12.win32.normalize(path12.win32.resolve(effectiveCwd, entry));
|
|
4540
4885
|
}
|
|
4541
4886
|
var WINDOWS_COMMAND_CACHE_MAX_ENTRIES = 256;
|
|
4542
4887
|
var WINDOWS_COMMAND_NEGATIVE_CACHE_TTL_MS = 1e3;
|
|
@@ -4554,14 +4899,14 @@ function getPathExts(env) {
|
|
|
4554
4899
|
}
|
|
4555
4900
|
function statIsFile(candidate) {
|
|
4556
4901
|
try {
|
|
4557
|
-
return
|
|
4902
|
+
return fs9.statSync(candidate).isFile();
|
|
4558
4903
|
} catch {
|
|
4559
4904
|
return false;
|
|
4560
4905
|
}
|
|
4561
4906
|
}
|
|
4562
4907
|
function resolveWindowsCommandUncached(command, effectiveCwd, env) {
|
|
4563
4908
|
const pathExts = getPathExts(env);
|
|
4564
|
-
const existingExt =
|
|
4909
|
+
const existingExt = path12.win32.extname(command).toLowerCase();
|
|
4565
4910
|
const hasExplicitExt = existingExt.length > 0;
|
|
4566
4911
|
const isKnownExecutableExt = (ext) => WINDOWS_DIRECT_RESOLVABLE_EXTS.has(ext) || pathExts.includes(ext);
|
|
4567
4912
|
const tryBase = (base) => {
|
|
@@ -4582,25 +4927,25 @@ function resolveWindowsCommandUncached(command, effectiveCwd, env) {
|
|
|
4582
4927
|
if (hasPathSep || hasDrivePrefix || isFullyQualifiedWindowsPath(command)) {
|
|
4583
4928
|
let base;
|
|
4584
4929
|
if (isFullyQualifiedWindowsPath(command)) {
|
|
4585
|
-
base =
|
|
4930
|
+
base = path12.win32.normalize(command);
|
|
4586
4931
|
} else if (hasDrivePrefix) {
|
|
4587
4932
|
base = resolveDriveRelativeWindowsPath(command, effectiveCwd, env);
|
|
4588
4933
|
} else if (isRootedWindowsPath(command)) {
|
|
4589
4934
|
base = effectiveCwd === void 0 ? void 0 : resolveRootedWindowsPath(command, effectiveCwd);
|
|
4590
4935
|
} else if (effectiveCwd !== void 0) {
|
|
4591
|
-
base =
|
|
4936
|
+
base = path12.win32.normalize(path12.win32.resolve(effectiveCwd, command));
|
|
4592
4937
|
}
|
|
4593
4938
|
return base === void 0 ? null : tryBase(base);
|
|
4594
4939
|
}
|
|
4595
4940
|
const pathValue = getWindowsEnvironmentValue(env, "PATH") ?? "";
|
|
4596
|
-
const pathDirs = pathValue.split(
|
|
4941
|
+
const pathDirs = pathValue.split(path12.win32.delimiter);
|
|
4597
4942
|
for (const dir of pathDirs) {
|
|
4598
4943
|
if (!dir)
|
|
4599
4944
|
continue;
|
|
4600
4945
|
const resolvedDir = resolveWindowsPathEntry(dir, effectiveCwd, env);
|
|
4601
4946
|
if (resolvedDir === void 0)
|
|
4602
4947
|
continue;
|
|
4603
|
-
const found = tryBase(
|
|
4948
|
+
const found = tryBase(path12.win32.join(resolvedDir, command));
|
|
4604
4949
|
if (found)
|
|
4605
4950
|
return found;
|
|
4606
4951
|
}
|
|
@@ -4647,6 +4992,113 @@ function getSpawnEnvironment(overrides, stripNpmConfig) {
|
|
|
4647
4992
|
}
|
|
4648
4993
|
return stripped;
|
|
4649
4994
|
}
|
|
4995
|
+
function isSpawnLookup(command) {
|
|
4996
|
+
if (process.platform !== "win32")
|
|
4997
|
+
return !command.includes("/");
|
|
4998
|
+
return !/[\\/]/.test(command) && driveLetter(command) === void 0;
|
|
4999
|
+
}
|
|
5000
|
+
function searchPathEntryDir(entry, cwd, env) {
|
|
5001
|
+
if (process.platform === "win32") {
|
|
5002
|
+
if (entry === "")
|
|
5003
|
+
return void 0;
|
|
5004
|
+
return resolveWindowsPathEntry(entry, resolveEffectiveWindowsCwd(cwd, env), env);
|
|
5005
|
+
}
|
|
5006
|
+
return posixSearchPathEntryDir(entry, cwd);
|
|
5007
|
+
}
|
|
5008
|
+
function posixSearchPathEntryDir(entry, cwd) {
|
|
5009
|
+
if (entry === "")
|
|
5010
|
+
return cwd;
|
|
5011
|
+
return path12.isAbsolute(entry) ? entry : `${cwd}${path12.sep}${entry}`;
|
|
5012
|
+
}
|
|
5013
|
+
function trustScopedSearchPath(pathValue, cwd = process.cwd(), env = process.env) {
|
|
5014
|
+
if (pathValue === void 0)
|
|
5015
|
+
return void 0;
|
|
5016
|
+
const trust = getProjectTrustState();
|
|
5017
|
+
if (trust === "trusted")
|
|
5018
|
+
return pathValue;
|
|
5019
|
+
const owned = sessionRepositoryJudge();
|
|
5020
|
+
const kept = [];
|
|
5021
|
+
for (const entry of pathValue.split(path12.delimiter)) {
|
|
5022
|
+
const dir = searchPathEntryDir(entry, cwd, env);
|
|
5023
|
+
if (dir === void 0 || !owned(dir)) {
|
|
5024
|
+
kept.push(entry);
|
|
5025
|
+
continue;
|
|
5026
|
+
}
|
|
5027
|
+
const real = realpathOrResolve(dir);
|
|
5028
|
+
if (recordDegradationOnce({
|
|
5029
|
+
kind: "trust-refusal",
|
|
5030
|
+
subject: `project-path-entry:${real}`,
|
|
5031
|
+
reason: `search-path entry inside the project ignored: pi project trust is ${trust}`
|
|
5032
|
+
})) {
|
|
5033
|
+
logExtension({
|
|
5034
|
+
subsystem: "project-trust",
|
|
5035
|
+
level: "warn",
|
|
5036
|
+
message: "search-path entry inside the project ignored: mark the project trusted in pi or upgrade pi",
|
|
5037
|
+
metadata: { entry, dir: real, trust }
|
|
5038
|
+
});
|
|
5039
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
return kept.length > 0 ? kept.join(path12.delimiter) : void 0;
|
|
5042
|
+
}
|
|
5043
|
+
function trustScopedEnvironment(env, cwd = process.cwd()) {
|
|
5044
|
+
const keys = process.platform === "win32" ? windowsEnvironmentKeys(env, "PATH") : ["PATH"];
|
|
5045
|
+
const lastKey = keys.at(-1);
|
|
5046
|
+
if (lastKey === void 0)
|
|
5047
|
+
return env;
|
|
5048
|
+
const value = env[lastKey];
|
|
5049
|
+
const scoped = trustScopedSearchPath(value, cwd, env);
|
|
5050
|
+
if (scoped === value)
|
|
5051
|
+
return env;
|
|
5052
|
+
const next = { ...env };
|
|
5053
|
+
for (const key of keys) {
|
|
5054
|
+
if (scoped === void 0)
|
|
5055
|
+
delete next[key];
|
|
5056
|
+
else
|
|
5057
|
+
next[key] = scoped;
|
|
5058
|
+
}
|
|
5059
|
+
return next;
|
|
5060
|
+
}
|
|
5061
|
+
function resolveSearchPathCommand(command, pathValue, cwd) {
|
|
5062
|
+
if (pathValue === void 0)
|
|
5063
|
+
return void 0;
|
|
5064
|
+
for (const entry of pathValue.split(path12.delimiter)) {
|
|
5065
|
+
const dir = posixSearchPathEntryDir(entry, cwd);
|
|
5066
|
+
const candidate = `${dir}${path12.sep}${command}`;
|
|
5067
|
+
try {
|
|
5068
|
+
if (!fs9.statSync(candidate).isFile())
|
|
5069
|
+
continue;
|
|
5070
|
+
fs9.accessSync(candidate, fs9.constants.X_OK);
|
|
5071
|
+
return candidate;
|
|
5072
|
+
} catch {
|
|
5073
|
+
}
|
|
5074
|
+
}
|
|
5075
|
+
return void 0;
|
|
5076
|
+
}
|
|
5077
|
+
function admitSpawn(command, cwd, env) {
|
|
5078
|
+
if (getProjectTrustState() === "trusted")
|
|
5079
|
+
return { admitted: true, env };
|
|
5080
|
+
const childCwd = cwd ?? process.cwd();
|
|
5081
|
+
const scoped = trustScopedEnvironment(env, childCwd);
|
|
5082
|
+
if (!isSpawnLookup(command))
|
|
5083
|
+
return { admitted: true, env: scoped };
|
|
5084
|
+
const executable = process.platform === "win32" ? resolveWindowsCommandForEnvironment(command, cwd, scoped)?.resolvedPath : resolveSearchPathCommand(command, scoped.PATH, childCwd);
|
|
5085
|
+
if (executable === void 0 || !isSessionRepositoryPath(executable))
|
|
5086
|
+
return { admitted: true, env: scoped };
|
|
5087
|
+
recordProjectCommandRefusal(executable);
|
|
5088
|
+
return { admitted: false, executable };
|
|
5089
|
+
}
|
|
5090
|
+
function trustRefusalResult(command, executable) {
|
|
5091
|
+
const message = `Refusing to run "${command}": ${executable} is inside the project, which pi has not trusted (${getProjectTrustState()})`;
|
|
5092
|
+
const cause = Object.assign(new Error(message), { code: "EACCES" });
|
|
5093
|
+
return {
|
|
5094
|
+
stdout: "",
|
|
5095
|
+
stderr: message,
|
|
5096
|
+
status: null,
|
|
5097
|
+
error: cause,
|
|
5098
|
+
failure: "spawn",
|
|
5099
|
+
spawnFailure: new SpawnFailureError("trust-refused", message, cause)
|
|
5100
|
+
};
|
|
5101
|
+
}
|
|
4650
5102
|
var CMD_UNSAFE_CHARS = /["%!\r\n]/;
|
|
4651
5103
|
function findCmdUnsafeValue(command, args) {
|
|
4652
5104
|
if (CMD_UNSAFE_CHARS.test(command))
|
|
@@ -4695,10 +5147,10 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
4695
5147
|
const callerSignal = options?.signal ?? (options?.ignoreAmbientSignal ? void 0 : ambientAbortSignal);
|
|
4696
5148
|
const scopedSignal = spawnAbortScope.getStore();
|
|
4697
5149
|
const abortSignal = scopedSignal && callerSignal ? AbortSignal.any([scopedSignal, callerSignal]) : scopedSignal ?? callerSignal;
|
|
4698
|
-
return new Promise((
|
|
5150
|
+
return new Promise((resolve7) => {
|
|
4699
5151
|
if (abortSignal?.aborted) {
|
|
4700
5152
|
const cause = new Error("Spawn aborted before start");
|
|
4701
|
-
|
|
5153
|
+
resolve7({
|
|
4702
5154
|
stdout: "",
|
|
4703
5155
|
stderr: "",
|
|
4704
5156
|
status: null,
|
|
@@ -4710,7 +5162,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
4710
5162
|
}
|
|
4711
5163
|
if (timeout <= 0) {
|
|
4712
5164
|
const cause = new Error(`Process timed out after ${timeout}ms`);
|
|
4713
|
-
|
|
5165
|
+
resolve7({
|
|
4714
5166
|
stdout: "",
|
|
4715
5167
|
stderr: "",
|
|
4716
5168
|
status: null,
|
|
@@ -4841,7 +5293,12 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
4841
5293
|
}
|
|
4842
5294
|
};
|
|
4843
5295
|
const isWindows2 = process.platform === "win32";
|
|
4844
|
-
const
|
|
5296
|
+
const admission = admitSpawn(command, options?.cwd, getSpawnEnvironment(options?.env, options?.stripNpmConfig));
|
|
5297
|
+
if (!admission.admitted) {
|
|
5298
|
+
resolve7(trustRefusalResult(command, admission.executable));
|
|
5299
|
+
return;
|
|
5300
|
+
}
|
|
5301
|
+
const spawnEnv = admission.env;
|
|
4845
5302
|
const spawnCwd = isWindows2 ? resolveEffectiveWindowsCwd(options?.cwd, spawnEnv) ?? options?.cwd : options?.cwd;
|
|
4846
5303
|
let spawnCmd = command;
|
|
4847
5304
|
let spawnArgs = args;
|
|
@@ -4875,7 +5332,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
4875
5332
|
void classifySpawnFailure(resolutionError, {
|
|
4876
5333
|
command,
|
|
4877
5334
|
cwd: options?.cwd
|
|
4878
|
-
}).then((spawnFailure) =>
|
|
5335
|
+
}).then((spawnFailure) => resolve7({
|
|
4879
5336
|
stdout: "",
|
|
4880
5337
|
stderr: "",
|
|
4881
5338
|
status: null,
|
|
@@ -4898,7 +5355,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
4898
5355
|
});
|
|
4899
5356
|
} catch (err) {
|
|
4900
5357
|
const cause = toError(err);
|
|
4901
|
-
void classifySpawnFailure(cause, { command, cwd: options?.cwd }).then((spawnFailure) =>
|
|
5358
|
+
void classifySpawnFailure(cause, { command, cwd: options?.cwd }).then((spawnFailure) => resolve7({
|
|
4902
5359
|
stdout: "",
|
|
4903
5360
|
stderr: "",
|
|
4904
5361
|
status: null,
|
|
@@ -5191,7 +5648,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
5191
5648
|
deathObservedAtMs: closedAtMs,
|
|
5192
5649
|
escalated: teardownEscalated
|
|
5193
5650
|
});
|
|
5194
|
-
|
|
5651
|
+
resolve7({
|
|
5195
5652
|
stdout,
|
|
5196
5653
|
stderr,
|
|
5197
5654
|
status: null,
|
|
@@ -5206,7 +5663,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
5206
5663
|
});
|
|
5207
5664
|
} else if (aborted) {
|
|
5208
5665
|
const cause = new Error("Spawn aborted");
|
|
5209
|
-
|
|
5666
|
+
resolve7({
|
|
5210
5667
|
stdout,
|
|
5211
5668
|
stderr,
|
|
5212
5669
|
status: null,
|
|
@@ -5220,7 +5677,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
5220
5677
|
});
|
|
5221
5678
|
} else if (signal) {
|
|
5222
5679
|
const cause = new Error(`Process killed by signal: ${signal}`);
|
|
5223
|
-
|
|
5680
|
+
resolve7({
|
|
5224
5681
|
stdout,
|
|
5225
5682
|
stderr,
|
|
5226
5683
|
status: null,
|
|
@@ -5238,7 +5695,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
5238
5695
|
command,
|
|
5239
5696
|
cwd: options?.cwd
|
|
5240
5697
|
});
|
|
5241
|
-
|
|
5698
|
+
resolve7({
|
|
5242
5699
|
stdout,
|
|
5243
5700
|
stderr,
|
|
5244
5701
|
status: code,
|
|
@@ -5250,7 +5707,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
5250
5707
|
resourceUsage
|
|
5251
5708
|
});
|
|
5252
5709
|
} else {
|
|
5253
|
-
|
|
5710
|
+
resolve7({
|
|
5254
5711
|
stdout,
|
|
5255
5712
|
stderr,
|
|
5256
5713
|
status: code,
|
|
@@ -5282,7 +5739,7 @@ async function safeSpawnAsync(command, args, options) {
|
|
|
5282
5739
|
else if (timedOut)
|
|
5283
5740
|
failure = "timeout";
|
|
5284
5741
|
const controlFailure = aborted ? new SpawnFailureError("killed", err.message, err) : timedOut ? new SpawnFailureError("timeout", err.message, err) : void 0;
|
|
5285
|
-
const finish = (spawnFailure) =>
|
|
5742
|
+
const finish = (spawnFailure) => resolve7({
|
|
5286
5743
|
stdout,
|
|
5287
5744
|
stderr,
|
|
5288
5745
|
status: null,
|
|
@@ -5322,10 +5779,13 @@ async function findCommandAsync(command) {
|
|
|
5322
5779
|
const result = await safeSpawnAsync(finder, [command], { timeout: 5e3 });
|
|
5323
5780
|
if (result.status !== 0 || result.error)
|
|
5324
5781
|
return null;
|
|
5325
|
-
return result.stdout
|
|
5782
|
+
return admittedLookupAnswer(result.stdout);
|
|
5326
5783
|
}
|
|
5327
5784
|
function safeSpawn(command, args, options) {
|
|
5328
|
-
const
|
|
5785
|
+
const admission = admitSpawn(command, options?.cwd, getSpawnEnvironment(options?.env, options?.stripNpmConfig));
|
|
5786
|
+
if (!admission.admitted)
|
|
5787
|
+
return trustRefusalResult(command, admission.executable);
|
|
5788
|
+
const spawnEnv = admission.env;
|
|
5329
5789
|
if (process.platform === "win32") {
|
|
5330
5790
|
const spawnCwd = resolveEffectiveWindowsCwd(options?.cwd, spawnEnv) ?? options?.cwd;
|
|
5331
5791
|
const resolved = resolveWindowsCommand(command, options?.cwd, spawnEnv);
|
|
@@ -5424,13 +5884,27 @@ function findCommand(command) {
|
|
|
5424
5884
|
const result = safeSpawn(finder, [command], { timeout: 5e3 });
|
|
5425
5885
|
if (result.status !== 0)
|
|
5426
5886
|
return null;
|
|
5427
|
-
return result.stdout
|
|
5887
|
+
return admittedLookupAnswer(result.stdout);
|
|
5428
5888
|
}
|
|
5429
5889
|
|
|
5430
5890
|
export {
|
|
5431
5891
|
noteSpawnTimeout,
|
|
5432
5892
|
isInSpawnTimeoutCooldown,
|
|
5433
5893
|
resetSpawnTimeoutCooldowns,
|
|
5894
|
+
createGitIdentityResolver,
|
|
5895
|
+
canonicalDirectory,
|
|
5896
|
+
resolveGitCheckout,
|
|
5897
|
+
resolveLinkedWorktreeOwner,
|
|
5898
|
+
listNestedLinkedWorktreeRoots,
|
|
5899
|
+
resolveGitIdentity,
|
|
5900
|
+
NODE_MODULES_BIN_DIRS,
|
|
5901
|
+
VENDOR_BIN_DIRS,
|
|
5902
|
+
VENV_BIN_DIRS,
|
|
5903
|
+
projectLocalBinDirs,
|
|
5904
|
+
isSessionRepositoryPath,
|
|
5905
|
+
isUntrustedProjectPath,
|
|
5906
|
+
recordProjectCommandRefusal,
|
|
5907
|
+
admittedLookupAnswer,
|
|
5434
5908
|
isLockContention,
|
|
5435
5909
|
recordGenerationTakeover,
|
|
5436
5910
|
recordLegacyLockHeld,
|
|
@@ -5473,7 +5947,11 @@ export {
|
|
|
5473
5947
|
mergeWindowsEnvironment,
|
|
5474
5948
|
WINDOWS_COMMAND_CACHE_MAX_ENTRIES,
|
|
5475
5949
|
resetSafeSpawnWindowsCommandCache,
|
|
5950
|
+
statIsFile,
|
|
5476
5951
|
resolveWindowsCommandForEnvironment,
|
|
5952
|
+
trustScopedSearchPath,
|
|
5953
|
+
trustScopedEnvironment,
|
|
5954
|
+
resolveSearchPathCommand,
|
|
5477
5955
|
resetUtf8ConsoleCodePageStateForTests,
|
|
5478
5956
|
spawnAbortScope,
|
|
5479
5957
|
safeSpawnAsync,
|
|
@@ -5506,8 +5984,3 @@ export {
|
|
|
5506
5984
|
getKnipIgnorePatterns,
|
|
5507
5985
|
isTestFile
|
|
5508
5986
|
};
|
|
5509
|
-
/*! Bundled license information:
|
|
5510
|
-
|
|
5511
|
-
safe-buffer/index.js:
|
|
5512
|
-
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
5513
|
-
*/
|