@herbertgao/pi-extensions 2026.10.19 → 2026.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/THIRD_PARTY_NOTICES.md +53 -2
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +142 -45
- package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +17 -7
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +111 -59
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +135 -117
- package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +41 -14
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +110 -19
- package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +8 -0
- package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +31 -0
- package/node_modules/@tintinweb/pi-tasks/CHANGELOG.md +270 -0
- package/node_modules/@tintinweb/pi-tasks/CONTRIBUTING.md +67 -0
- package/node_modules/@tintinweb/pi-tasks/CUSTOMIZING.md +289 -0
- package/node_modules/@tintinweb/pi-tasks/LICENSE +21 -0
- package/node_modules/@tintinweb/pi-tasks/README.md +417 -0
- package/node_modules/@tintinweb/pi-tasks/SECURITY.md +107 -0
- package/node_modules/@tintinweb/pi-tasks/dist/auto-clear.d.ts +64 -0
- package/node_modules/@tintinweb/pi-tasks/dist/auto-clear.js +129 -0
- package/node_modules/@tintinweb/pi-tasks/dist/index.d.ts +17 -0
- package/node_modules/@tintinweb/pi-tasks/dist/index.js +1338 -0
- package/node_modules/@tintinweb/pi-tasks/dist/process-tracker.d.ts +29 -0
- package/node_modules/@tintinweb/pi-tasks/dist/process-tracker.js +121 -0
- package/node_modules/@tintinweb/pi-tasks/dist/reminder-cadence.d.ts +39 -0
- package/node_modules/@tintinweb/pi-tasks/dist/reminder-cadence.js +61 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-glyphs.d.ts +48 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-glyphs.js +68 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-paths.d.ts +44 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-paths.js +60 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-sort.d.ts +23 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-sort.js +69 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-store.d.ts +61 -0
- package/node_modules/@tintinweb/pi-tasks/dist/task-store.js +397 -0
- package/node_modules/@tintinweb/pi-tasks/dist/tasks-config.d.ts +16 -0
- package/node_modules/@tintinweb/pi-tasks/dist/tasks-config.js +51 -0
- package/node_modules/@tintinweb/pi-tasks/dist/types.d.ts +36 -0
- package/node_modules/@tintinweb/pi-tasks/dist/types.js +4 -0
- package/node_modules/@tintinweb/pi-tasks/dist/ui/settings-menu.d.ts +15 -0
- package/node_modules/@tintinweb/pi-tasks/dist/ui/settings-menu.js +140 -0
- package/node_modules/@tintinweb/pi-tasks/dist/ui/task-widget.d.ts +69 -0
- package/node_modules/@tintinweb/pi-tasks/dist/ui/task-widget.js +278 -0
- package/node_modules/@tintinweb/pi-tasks/package.json +57 -0
- package/node_modules/@tintinweb/pi-tasks/src/auto-clear.ts +134 -0
- package/node_modules/@tintinweb/pi-tasks/src/index.ts +1417 -0
- package/node_modules/@tintinweb/pi-tasks/src/process-tracker.ts +140 -0
- package/node_modules/@tintinweb/pi-tasks/src/reminder-cadence.ts +90 -0
- package/node_modules/@tintinweb/pi-tasks/src/task-glyphs.ts +110 -0
- package/node_modules/@tintinweb/pi-tasks/src/task-paths.ts +65 -0
- package/node_modules/@tintinweb/pi-tasks/src/task-sort.ts +90 -0
- package/node_modules/@tintinweb/pi-tasks/src/task-store.ts +402 -0
- package/node_modules/@tintinweb/pi-tasks/src/tasks-config.ts +77 -0
- package/node_modules/@tintinweb/pi-tasks/src/types.ts +40 -0
- package/node_modules/@tintinweb/pi-tasks/src/ui/settings-menu.ts +174 -0
- package/node_modules/@tintinweb/pi-tasks/src/ui/task-widget.ts +325 -0
- package/node_modules/pi-commandcode-provider/CHANGELOG.md +330 -0
- package/node_modules/pi-commandcode-provider/CONTRIBUTING.md +192 -0
- package/node_modules/pi-commandcode-provider/LICENSE +21 -0
- package/node_modules/pi-commandcode-provider/README.md +243 -0
- package/node_modules/pi-commandcode-provider/RELEASE.md +194 -0
- package/node_modules/pi-commandcode-provider/index.ts +309 -0
- package/node_modules/pi-commandcode-provider/package.json +91 -0
- package/node_modules/pi-commandcode-provider/scripts/live-e2e-profile.mjs +87 -0
- package/node_modules/pi-commandcode-provider/scripts/pi-authenticated.mjs +50 -0
- package/node_modules/pi-commandcode-provider/scripts/pi-isolated.mjs +79 -0
- package/node_modules/pi-commandcode-provider/src/api-key.ts +69 -0
- package/node_modules/pi-commandcode-provider/src/auth-server.ts +229 -0
- package/node_modules/pi-commandcode-provider/src/commandcode-catalog-overrides.ts +28 -0
- package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +260 -0
- package/node_modules/pi-commandcode-provider/src/converters.ts +477 -0
- package/node_modules/pi-commandcode-provider/src/core.ts +836 -0
- package/node_modules/pi-commandcode-provider/src/cost.ts +76 -0
- package/node_modules/pi-commandcode-provider/src/json-schema.ts +417 -0
- package/node_modules/pi-commandcode-provider/src/models.ts +515 -0
- package/node_modules/pi-commandcode-provider/src/oauth.ts +229 -0
- package/node_modules/pi-commandcode-provider/src/overflow.ts +120 -0
- package/node_modules/pi-commandcode-provider/src/pricing.ts +370 -0
- package/node_modules/pi-commandcode-provider/src/quota-command.ts +66 -0
- package/node_modules/pi-commandcode-provider/src/quota-format.ts +143 -0
- package/node_modules/pi-commandcode-provider/src/quota-types.ts +47 -0
- package/node_modules/pi-commandcode-provider/src/quota.ts +357 -0
- package/node_modules/pi-commandcode-provider/src/responses-stream.ts +249 -0
- package/node_modules/pi-commandcode-provider/src/runtime.ts +330 -0
- package/node_modules/pi-commandcode-provider/src/transcript.ts +56 -0
- package/node_modules/pi-commandcode-provider/src/transport.ts +147 -0
- package/node_modules/pi-commandcode-provider/src/types.ts +212 -0
- package/node_modules/pi-commandcode-provider/src/usage.ts +261 -0
- package/node_modules/pi-lens/CHANGELOG.md +149 -0
- package/node_modules/pi-lens/README.md +12 -2
- package/node_modules/pi-lens/config/markdownlint/run-no-fix.mjs +36 -0
- package/node_modules/pi-lens/dist/{chunk-WME2OQST.js → chunk-2453RRJ2.js} +11 -6
- package/node_modules/pi-lens/dist/{chunk-FZKFVUEC.js → chunk-2BKUFQKR.js} +276 -208
- package/node_modules/pi-lens/dist/chunk-2TS4GLOJ.js +31 -0
- package/node_modules/pi-lens/dist/{chunk-QHSNL7B2.js → chunk-2ZE3AUJQ.js} +12 -14
- package/node_modules/pi-lens/dist/{chunk-MPKRJBPK.js → chunk-35WKJWO5.js} +28 -30
- package/node_modules/pi-lens/dist/chunk-3JAHQBSY.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-4LM3VAZH.js → chunk-3O5EII3W.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-447YZL4S.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-H7OR7DFZ.js → chunk-4B2YFN4U.js} +25 -21
- package/node_modules/pi-lens/dist/{chunk-OSTKYB55.js → chunk-4BKU7PV3.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-RRV3FNNM.js → chunk-4LL2VRNY.js} +27 -28
- package/node_modules/pi-lens/dist/{chunk-BZARLRJW.js → chunk-4NBWFYWW.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-KKCK636N.js → chunk-4QG55RRC.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-RQS4QQSD.js → chunk-4W52ZKZX.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-Z2XAOKHK.js → chunk-565VRUP4.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-HWDAVBFU.js → chunk-57X2CDRX.js} +23 -23
- package/node_modules/pi-lens/dist/{chunk-MB6PXBUA.js → chunk-5F3XF3SX.js} +7 -15
- package/node_modules/pi-lens/dist/{chunk-O4BJFESU.js → chunk-5RNB4HVK.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ZMAUPOMG.js → chunk-5T5A6YAJ.js} +35 -34
- package/node_modules/pi-lens/dist/{chunk-4ZYJHQMB.js → chunk-6FIRFP6A.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-4YHYPW2G.js → chunk-6GMGEKQN.js} +9 -5
- package/node_modules/pi-lens/dist/{chunk-4LOE5R5P.js → chunk-6LJOJ6EO.js} +20 -15
- package/node_modules/pi-lens/dist/{chunk-3YY7IXIL.js → chunk-6YUNI7B5.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-PKES3ISE.js → chunk-7ANZ7XDD.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-FB5SCCPT.js → chunk-7CGIDRIK.js} +16 -15
- package/node_modules/pi-lens/dist/{chunk-L3CMBQMH.js → chunk-7MAD5ZAY.js} +16 -17
- package/node_modules/pi-lens/dist/{chunk-WDBICWH3.js → chunk-7TNILKGY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-RORGS5II.js → chunk-A5GRLYPZ.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-MNJIXFX4.js → chunk-AGGUWKRK.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ABPKUVA4.js → chunk-BBET6HD6.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-L5JYIU47.js → chunk-BHWW6FAX.js} +14 -13
- package/node_modules/pi-lens/dist/{chunk-URCQWAQ4.js → chunk-BOPDQ7AZ.js} +23 -21
- package/node_modules/pi-lens/dist/{chunk-KDX35VXP.js → chunk-BQG2QFVO.js} +158 -133
- package/node_modules/pi-lens/dist/{chunk-CB4WHS4H.js → chunk-BUZIQDFS.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-2PHMIAKO.js → chunk-CM73PPGD.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-DH5JPM3K.js → chunk-CUDD35TW.js} +10 -9
- package/node_modules/pi-lens/dist/{chunk-AWDSEDER.js → chunk-CZL44WFN.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-N5WSK2K7.js → chunk-DIWK3LBC.js} +12 -15
- package/node_modules/pi-lens/dist/{chunk-24BILSZW.js → chunk-DYRZGUMA.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-PR6PO3ES.js → chunk-FHEV6T4L.js} +22 -18
- package/node_modules/pi-lens/dist/{chunk-DQZFQSR5.js → chunk-FRLAUP2B.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-RZOXUSPC.js → chunk-G5GV2Q7K.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-EKWX4WD3.js → chunk-G6JKM4O7.js} +7 -7
- package/node_modules/pi-lens/dist/chunk-GGYOZWHW.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-XT2HTCJ5.js → chunk-GIRBSBGL.js} +6 -5
- package/node_modules/pi-lens/dist/{chunk-PQJFG24Z.js → chunk-GMROJJRN.js} +1292 -946
- package/node_modules/pi-lens/dist/{chunk-U6VN4NVL.js → chunk-HHR7WGCI.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-TIQJPRDD.js → chunk-HKIL6DCL.js} +3 -2
- package/node_modules/pi-lens/dist/{chunk-SNDXCFRS.js → chunk-HUAM7QG3.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-QOE342SU.js → chunk-HXFUTMX2.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-U7BD2QL7.js → chunk-I22THIHI.js} +12 -12
- package/node_modules/pi-lens/dist/chunk-IE5D3RA5.js +58 -0
- package/node_modules/pi-lens/dist/{chunk-DPGEAHZT.js → chunk-IYVYZQRL.js} +10 -16
- package/node_modules/pi-lens/dist/{chunk-3F6BMY53.js → chunk-JBP7KESM.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-U5HPROLA.js → chunk-JE6HKLC7.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-ZE3KXHS7.js → chunk-JPRDTY5S.js} +85 -3
- package/node_modules/pi-lens/dist/{chunk-HO6LWE2E.js → chunk-JYLOYTZD.js} +17 -1
- package/node_modules/pi-lens/dist/{chunk-KW5JQPO5.js → chunk-JZRP4DGP.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-CPSR3AVL.js → chunk-KZ4ALBCH.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6IR3ZYIB.js → chunk-L3CLUGDY.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-LV4UMYVH.js → chunk-L4NEVZ4T.js} +28 -27
- package/node_modules/pi-lens/dist/chunk-LPYTPNOJ.js +22 -0
- package/node_modules/pi-lens/dist/{chunk-WGRJOXED.js → chunk-LSFXZLPW.js} +1016 -636
- package/node_modules/pi-lens/dist/{chunk-LBLBAFG3.js → chunk-MC6VB2E5.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-U2SDMG7C.js → chunk-NM2NWH55.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-T7A2HK2B.js → chunk-NSPVR3FN.js} +19 -18
- package/node_modules/pi-lens/dist/{chunk-ZGSJDWQU.js → chunk-O2ARHQKF.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-OXOI55RU.js → chunk-O4N5BQ3T.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-3FRLWYBG.js → chunk-OC7VWJBZ.js} +39 -40
- package/node_modules/pi-lens/dist/chunk-OFNMHPBT.js +89 -0
- package/node_modules/pi-lens/dist/{chunk-HR3OJ3TH.js → chunk-OWTG6UMO.js} +21 -21
- package/node_modules/pi-lens/dist/{chunk-75GAYVNO.js → chunk-OY7WZI7Q.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-ZJTT47IG.js → chunk-OZWXLJMX.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-F6X3YJWD.js → chunk-PIQQM32Y.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-PKLB2XJL.js +8 -0
- package/node_modules/pi-lens/dist/{chunk-EAOK7MIZ.js → chunk-PKSUMEPT.js} +17 -4
- package/node_modules/pi-lens/dist/{chunk-YISME6ON.js → chunk-PPKECBPP.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-4L36HG27.js → chunk-R2QQC33W.js} +14 -14
- package/node_modules/pi-lens/dist/{chunk-LUBPZN36.js → chunk-R4QWJQ2H.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-V63BC55Q.js → chunk-RGGH6M34.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-Y7F7IEE3.js → chunk-RZG472YW.js} +65 -7
- package/node_modules/pi-lens/dist/{chunk-PUZ3E2J4.js → chunk-SDFKOLSF.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-YHC2O2WO.js → chunk-SFLHSL5R.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-CCV2EU7T.js → chunk-SP4TFY5F.js} +14 -13
- package/node_modules/pi-lens/dist/{chunk-J6JP25XU.js → chunk-SQC7K3SP.js} +4 -3
- package/node_modules/pi-lens/dist/{chunk-3K2F6UDZ.js → chunk-T2S3FNNJ.js} +44 -42
- package/node_modules/pi-lens/dist/{chunk-2TF6RXWB.js → chunk-TV6RXRYH.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-GNSIWBAT.js → chunk-U3AS2FR6.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-F7K5IBZG.js → chunk-UHHLR2VY.js} +40 -40
- package/node_modules/pi-lens/dist/chunk-UYXV5NIS.js +20 -0
- package/node_modules/pi-lens/dist/{chunk-VSFLRN5Y.js → chunk-VLQ7UKZH.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-VUZWQ7UG.js → chunk-VN3L2JWZ.js} +46 -72
- package/node_modules/pi-lens/dist/{chunk-NA7SEXHE.js → chunk-VOP4PJKA.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-F5Z6URKM.js → chunk-VOXTCULR.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-LLS45EWB.js → chunk-VPLBLWFO.js} +6 -8
- package/node_modules/pi-lens/dist/chunk-W3BGKBBK.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-ZKXQKGWZ.js → chunk-WC6WRNQT.js} +4 -3
- package/node_modules/pi-lens/dist/{chunk-YVHBNSME.js → chunk-WMDUT4KH.js} +1148 -1132
- package/node_modules/pi-lens/dist/{chunk-KXF5R4UN.js → chunk-WQV6BI4Q.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-WXUDRAG6.js +24 -0
- package/node_modules/pi-lens/dist/{chunk-KPPJTH44.js → chunk-X35S7HSB.js} +28 -10
- package/node_modules/pi-lens/dist/{chunk-JMEKXFOL.js → chunk-X66YJ2SS.js} +40 -34
- package/node_modules/pi-lens/dist/{chunk-CE6VMBCB.js → chunk-XOMGO63G.js} +22 -21
- package/node_modules/pi-lens/dist/{chunk-LS3QJRUB.js → chunk-XWIME22V.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-R5MOQM2H.js → chunk-XYLC35E4.js} +119 -87
- package/node_modules/pi-lens/dist/{chunk-OE5ZBP7F.js → chunk-YHGYAEFH.js} +18 -18
- package/node_modules/pi-lens/dist/{chunk-7E2563GA.js → chunk-ZFORSIED.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-E7HJ56Y7.js → chunk-ZKLTNLAW.js} +64 -73
- package/node_modules/pi-lens/dist/chunk-ZONZ6YY3.js +74 -0
- package/node_modules/pi-lens/dist/chunk-ZSM35JF4.js +30 -0
- package/node_modules/pi-lens/dist/{chunk-RC2Z6K47.js → chunk-ZZDIOAAJ.js} +15 -6
- package/node_modules/pi-lens/dist/index.js +6993 -5396
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +10 -10
- package/node_modules/pi-lens/dist/mcp/cli.js +44 -42
- package/node_modules/pi-lens/dist/mcp/server.js +1627 -504
- package/node_modules/pi-lens/dist/mcp/worker.js +62 -61
- package/node_modules/pi-lens/dist/probes/installer.js +20 -19
- package/node_modules/pi-lens/docs/adr/0003-git-guard-latch-writer.md +11 -6
- package/node_modules/pi-lens/docs/agent-tools.md +18 -8
- package/node_modules/pi-lens/docs/alignment-families.md +29 -0
- package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +6 -4
- package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +126 -0
- package/node_modules/pi-lens/docs/configuration.md +99 -3
- package/node_modules/pi-lens/docs/defect-shapes.md +55 -12
- package/node_modules/pi-lens/docs/engineering-principles.md +27 -2
- package/node_modules/pi-lens/docs/features.md +2 -2
- package/node_modules/pi-lens/docs/invariants/git-guard-host.md +7 -3
- package/node_modules/pi-lens/docs/invariants/language-config.md +15 -4
- package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +16 -2
- package/node_modules/pi-lens/docs/invariants/paths-os.md +4 -2
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +119 -39
- package/node_modules/pi-lens/docs/merge-queue-rollout.md +1 -1
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +24 -17
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +20 -11
- package/node_modules/pi-lens/docs/pi-lens-monitor.md +9 -0
- package/node_modules/pi-lens/docs/pi-lens-orchestration.md +4 -1
- package/node_modules/pi-lens/docs/pi-lens-reviewer.md +5 -5
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +6 -3
- package/node_modules/pi-lens/docs/public-api-stability.md +18 -2
- package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +10 -0
- package/node_modules/pi-lens/docs/settings.md +10 -6
- package/node_modules/pi-lens/docs/word-index.md +17 -5
- package/node_modules/pi-lens/package.json +5 -3
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-accumulating-spread-js-test.yml +37 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/ts-redundant-filter-map-test.yml +12 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-js-test.yml +12 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-test.yml +25 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-accumulating-spread-js.yml +49 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/ts-redundant-filter-map.yml +9 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rules-disabled/filter-then-map-js.yml +17 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules-disabled/filter-then-map.yml +36 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/self-scan-baseline.json +1 -1
- package/node_modules/pi-provider-qoder/README.md +22 -0
- package/node_modules/pi-provider-qoder/dist/index.js +370 -11
- package/node_modules/pi-provider-qoder/package.json +5 -2
- package/package.json +11 -8
- package/node_modules/@tifan/pi-preferred-thinking/README.md +0 -54
- package/node_modules/@tifan/pi-preferred-thinking/package.json +0 -43
- package/node_modules/@tifan/pi-preferred-thinking/src/index.ts +0 -236
- package/node_modules/pi-lens/dist/chunk-46TNM7XZ.js +0 -88
- package/node_modules/pi-lens/dist/chunk-72OKUXSD.js +0 -31
- package/node_modules/pi-lens/dist/chunk-7GLOLOSH.js +0 -57
- package/node_modules/pi-lens/dist/chunk-AKUUMGD5.js +0 -26
- package/node_modules/pi-lens/dist/chunk-ASUXV767.js +0 -22
- package/node_modules/pi-lens/dist/chunk-CTADOKYM.js +0 -25
- package/node_modules/pi-lens/dist/chunk-JJ2RRESP.js +0 -58
- package/node_modules/pi-lens/dist/chunk-LSC3VADM.js +0 -23
- package/node_modules/pi-lens/dist/chunk-SHLDT3OI.js +0 -27
- package/node_modules/pi-lens/dist/chunk-UF7RTZSO.js +0 -27
- package/node_modules/pi-lens/dist/chunk-W4WP2ERB.js +0 -30
- package/node_modules/pi-lens/dist/chunk-YES5CACN.js +0 -73
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Code provider for pi.
|
|
3
|
+
*
|
|
4
|
+
* Uses Command Code's documented Provider API:
|
|
5
|
+
* https://api.commandcode.ai/provider/v1
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { AssistantMessageEventStream } from "@earendil-works/pi-ai"
|
|
9
|
+
import * as piAiCompat from "@earendil-works/pi-ai/compat"
|
|
10
|
+
import { streamSimple as streamNativeProvider } from "@earendil-works/pi-ai/compat"
|
|
11
|
+
import {
|
|
12
|
+
getAgentDir,
|
|
13
|
+
type ExtensionAPI,
|
|
14
|
+
type ExtensionCommandContext,
|
|
15
|
+
type ProviderConfig,
|
|
16
|
+
} from "@earendil-works/pi-coding-agent"
|
|
17
|
+
import { join } from "node:path"
|
|
18
|
+
|
|
19
|
+
import { getConfiguredApiKey } from "./src/api-key.ts"
|
|
20
|
+
import { pickCommandCodeApiKey, withResolvedCommandCodeApiKey } from "./src/converters.ts"
|
|
21
|
+
import { createStreamCommandCode } from "./src/core.ts"
|
|
22
|
+
import { calculateCommandCodeCost, commandCodeCostRatesAt } from "./src/cost.ts"
|
|
23
|
+
import {
|
|
24
|
+
apiForModelId,
|
|
25
|
+
baseUrlForModel,
|
|
26
|
+
DEFAULT_MODELS_URL,
|
|
27
|
+
DEFAULT_PROVIDER_API_BASE,
|
|
28
|
+
getModelsTimeoutMs,
|
|
29
|
+
inputModalitiesForModel,
|
|
30
|
+
loadCachedCommandCodeModels,
|
|
31
|
+
loadCommandCodeModels,
|
|
32
|
+
MODEL_EFFORTS,
|
|
33
|
+
thinkingMetadataForModel,
|
|
34
|
+
type CommandCodeApi,
|
|
35
|
+
type CommandCodeModel,
|
|
36
|
+
} from "./src/models.ts"
|
|
37
|
+
import { getApiKey as getOAuthApiKey, login, refreshToken } from "./src/oauth.ts"
|
|
38
|
+
import { normalizeCommandCodeMessage } from "./src/overflow.ts"
|
|
39
|
+
import { MODEL_COSTS, ZERO_MODEL_COST } from "./src/pricing.ts"
|
|
40
|
+
import { registerCommandCodeQuota } from "./src/quota-command.ts"
|
|
41
|
+
import { normalizeCommandCodeResponsesResponse } from "./src/responses-stream.ts"
|
|
42
|
+
import { createCommandCodeRuntime } from "./src/runtime.ts"
|
|
43
|
+
import { createCommandCodeUsageProvider, type UsageProvider } from "./src/usage.ts"
|
|
44
|
+
import { transcriptReadersFrom, withTranscriptPromptAndTools } from "./src/transcript.ts"
|
|
45
|
+
import { createCommandCodeTransportRouter } from "./src/transport.ts"
|
|
46
|
+
|
|
47
|
+
const COMMAND_CODE_API = "commandcode-custom"
|
|
48
|
+
const COMPAT_SOURCE_ID = "pi-commandcode-provider"
|
|
49
|
+
|
|
50
|
+
type CompatStreamFunction = (
|
|
51
|
+
model: Parameters<typeof streamNativeProvider>[0],
|
|
52
|
+
context: Parameters<typeof streamNativeProvider>[1],
|
|
53
|
+
options?: Parameters<typeof streamNativeProvider>[2],
|
|
54
|
+
) => AssistantMessageEventStream
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* pi's compat entrypoint exposes `registerApiProvider`; Oh My Pi maps
|
|
58
|
+
* `@earendil-works/pi-ai/compat` onto its own pi-ai, which lacks that export
|
|
59
|
+
* and registers custom APIs itself inside `registerProvider`. Resolve the
|
|
60
|
+
* function at runtime so the extension loads on both hosts.
|
|
61
|
+
*/
|
|
62
|
+
function compatApiProviderRegistrar(): ((...args: unknown[]) => unknown) | undefined {
|
|
63
|
+
const register = (piAiCompat as { registerApiProvider?: unknown }).registerApiProvider
|
|
64
|
+
return typeof register === "function" ? (register as (...args: unknown[]) => unknown) : undefined
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function registerCompatApiProvider(stream: CompatStreamFunction): void {
|
|
68
|
+
compatApiProviderRegistrar()?.(
|
|
69
|
+
{ api: COMMAND_CODE_API, stream, streamSimple: stream },
|
|
70
|
+
COMPAT_SOURCE_ID,
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The `apiKey` handed to `registerProvider` means different things per host.
|
|
76
|
+
*
|
|
77
|
+
* pi parses `$COMMAND_CODE_API_KEY` as an env template: unresolved means
|
|
78
|
+
* "not configured", so `/login` credentials and `--api-key` take over, and
|
|
79
|
+
* the entry keeps the API-key auth method registered next to OAuth. Without
|
|
80
|
+
* it pi composes an OAuth-only provider and drops stored `api_key`
|
|
81
|
+
* credentials and `--api-key`.
|
|
82
|
+
*
|
|
83
|
+
* Oh My Pi has no template notion: an unresolved value stays a literal config
|
|
84
|
+
* override that shadows its `/login` credential store and is sent verbatim as
|
|
85
|
+
* `Authorization: Bearer $COMMAND_CODE_API_KEY`. There, omit `apiKey` unless
|
|
86
|
+
* a real key is configured; OMP then reads env keys and stored credentials
|
|
87
|
+
* itself.
|
|
88
|
+
*
|
|
89
|
+
* Hosts are told apart by the same `registerApiProvider` probe used for the
|
|
90
|
+
* compat registry: pi exports it, OMP does not.
|
|
91
|
+
*/
|
|
92
|
+
function providerApiKey(): string | undefined {
|
|
93
|
+
const configured = pickCommandCodeApiKey(getConfiguredApiKey(), undefined)
|
|
94
|
+
if (configured) return configured
|
|
95
|
+
return compatApiProviderRegistrar() ? "$COMMAND_CODE_API_KEY" : undefined
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function commandCodeHeaders(): Record<string, string> | undefined {
|
|
99
|
+
if (process.env.CMD_ZDR === "1" || process.env.COMMANDCODE_ZDR === "1") {
|
|
100
|
+
return { "x-cmd-zdr": "1" }
|
|
101
|
+
}
|
|
102
|
+
return undefined
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The registered config, plus Oh My Pi's extension-only usage hook.
|
|
107
|
+
*
|
|
108
|
+
* `usage` is not part of pi's `ProviderConfig`; pi ignores the extra field,
|
|
109
|
+
* while OMP turns it into the account's usage report. Both use the same
|
|
110
|
+
* registration call, so the field is attached unconditionally.
|
|
111
|
+
*/
|
|
112
|
+
type CommandCodeProviderConfig = ProviderConfig & { usage?: UsageProvider }
|
|
113
|
+
|
|
114
|
+
type CommandCodeModelCompat = NonNullable<ProviderConfig["models"]>[number]["compat"]
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Compatibility flags per wire. Chat Completions mirrors what the Provider API
|
|
118
|
+
* accepts for open models; Responses leaves pi's defaults (store off, encrypted
|
|
119
|
+
* reasoning) and only mutes the OpenAI extras Command Code does not advertise;
|
|
120
|
+
* Anthropic keeps the existing Claude tuning.
|
|
121
|
+
*/
|
|
122
|
+
function compatForModel(model: CommandCodeModel): CommandCodeModelCompat {
|
|
123
|
+
if (model.api === "openai-responses") {
|
|
124
|
+
return {
|
|
125
|
+
supportsDeveloperRole: false,
|
|
126
|
+
supportsLongCacheRetention: false,
|
|
127
|
+
sessionAffinityFormat: "openai-nosession",
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (model.api === "anthropic-messages") {
|
|
131
|
+
return {
|
|
132
|
+
supportsEagerToolInputStreaming: false,
|
|
133
|
+
supportsLongCacheRetention: false,
|
|
134
|
+
supportsCacheControlOnTools: false,
|
|
135
|
+
supportsToolReferences: false,
|
|
136
|
+
...(model.reasoning ? { forceAdaptiveThinking: true } : {}),
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
supportsStore: false,
|
|
141
|
+
supportsDeveloperRole: false,
|
|
142
|
+
supportsReasoningEffort: MODEL_EFFORTS[model.id] !== undefined,
|
|
143
|
+
maxTokensField: "max_tokens",
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function createProviderConfig(
|
|
148
|
+
models: readonly CommandCodeModel[],
|
|
149
|
+
apiBase: string,
|
|
150
|
+
streamCommandCode: ProviderConfig["streamSimple"],
|
|
151
|
+
): CommandCodeProviderConfig {
|
|
152
|
+
const headers = commandCodeHeaders()
|
|
153
|
+
return {
|
|
154
|
+
name: "Command Code",
|
|
155
|
+
baseUrl: apiBase,
|
|
156
|
+
apiKey: providerApiKey(),
|
|
157
|
+
api: COMMAND_CODE_API,
|
|
158
|
+
streamSimple: streamCommandCode,
|
|
159
|
+
headers,
|
|
160
|
+
// Same alpha endpoints and credentials as the /commandcode-quota command.
|
|
161
|
+
usage: createCommandCodeUsageProvider({
|
|
162
|
+
apiBase: legacyApiBase(apiBase),
|
|
163
|
+
headers,
|
|
164
|
+
}),
|
|
165
|
+
oauth: {
|
|
166
|
+
name: "Command Code",
|
|
167
|
+
login,
|
|
168
|
+
refreshToken,
|
|
169
|
+
getApiKey: getOAuthApiKey,
|
|
170
|
+
},
|
|
171
|
+
models: models.map((model) => ({
|
|
172
|
+
id: model.id,
|
|
173
|
+
name: model.name,
|
|
174
|
+
api: COMMAND_CODE_API,
|
|
175
|
+
baseUrl: baseUrlForModel(apiBase, model.api),
|
|
176
|
+
reasoning: model.reasoning,
|
|
177
|
+
...(thinkingMetadataForModel(model.id) ?? {}),
|
|
178
|
+
input: [...inputModalitiesForModel(model.id)],
|
|
179
|
+
cost: MODEL_COSTS[model.id] ?? ZERO_MODEL_COST,
|
|
180
|
+
contextWindow: model.contextWindow,
|
|
181
|
+
maxTokens: model.maxTokens,
|
|
182
|
+
headers,
|
|
183
|
+
compat: compatForModel(model),
|
|
184
|
+
})),
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function legacyApiBase(providerApiBase: string): string {
|
|
189
|
+
return providerApiBase.replace(/\/provider\/v1\/?$/, "")
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default async function (pi: ExtensionAPI) {
|
|
193
|
+
// Hosts may select their built-in Command Code model before loading extensions.
|
|
194
|
+
// Rebind that stale selection to our registered transport before the first turn.
|
|
195
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
196
|
+
if (ctx.model?.provider !== "commandcode") return
|
|
197
|
+
const registered = ctx.modelRegistry.find("commandcode", ctx.model.id)
|
|
198
|
+
if (registered?.api === COMMAND_CODE_API && ctx.model.api !== COMMAND_CODE_API) {
|
|
199
|
+
await pi.setModel(registered)
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
const apiBase = process.env.COMMANDCODE_API_BASE ?? DEFAULT_PROVIDER_API_BASE
|
|
203
|
+
const modelsUrl = process.env.COMMANDCODE_MODELS_URL ?? DEFAULT_MODELS_URL
|
|
204
|
+
const modelsTimeoutMs = getModelsTimeoutMs()
|
|
205
|
+
const modelsCachePath =
|
|
206
|
+
process.env.COMMANDCODE_MODELS_CACHE ?? join(getAgentDir(), "commandcode-models.json")
|
|
207
|
+
const streamGenerate = createStreamCommandCode({
|
|
208
|
+
createStream: () => new AssistantMessageEventStream(),
|
|
209
|
+
calculateCost: calculateCommandCodeCost,
|
|
210
|
+
apiBase: legacyApiBase(apiBase),
|
|
211
|
+
})
|
|
212
|
+
const resolveStreamOptions = (options?: Parameters<typeof streamNativeProvider>[2]) =>
|
|
213
|
+
withResolvedCommandCodeApiKey(options, getConfiguredApiKey())
|
|
214
|
+
// The provider transport delegates to pi-ai, which reads the transcript
|
|
215
|
+
// itself. The generate transport builds its own request body and needs the
|
|
216
|
+
// flat prompt and tool fields that pi 0.86+ no longer passes.
|
|
217
|
+
const transcriptReaders = transcriptReadersFrom(piAiCompat)
|
|
218
|
+
// The host dispatches every Command Code model through one custom api id, so
|
|
219
|
+
// the wire each model answers on is resolved here from the catalog that
|
|
220
|
+
// `createProviderConfig` registered. Unknown ids fall back to the id rule.
|
|
221
|
+
const modelApis = new Map<string, CommandCodeApi>()
|
|
222
|
+
const resolveModelApi = (modelId: string): CommandCodeApi =>
|
|
223
|
+
modelApis.get(modelId) ?? apiForModelId(modelId)
|
|
224
|
+
let streamWarning: string | undefined
|
|
225
|
+
const transport = createCommandCodeTransportRouter({
|
|
226
|
+
createStream: () => new AssistantMessageEventStream(),
|
|
227
|
+
streamProvider: (model, context, options) => {
|
|
228
|
+
const wire = resolveModelApi(model.id)
|
|
229
|
+
const resolvedOptions: Parameters<typeof streamNativeProvider>[2] =
|
|
230
|
+
resolveStreamOptions(options)
|
|
231
|
+
const nativeOptions =
|
|
232
|
+
wire === "openai-responses"
|
|
233
|
+
? {
|
|
234
|
+
...resolvedOptions,
|
|
235
|
+
fetch: async (...args: Parameters<typeof fetch>) =>
|
|
236
|
+
normalizeCommandCodeResponsesResponse(
|
|
237
|
+
await (resolvedOptions?.fetch ?? fetch)(...args),
|
|
238
|
+
(warning) => {
|
|
239
|
+
streamWarning = warning
|
|
240
|
+
},
|
|
241
|
+
),
|
|
242
|
+
}
|
|
243
|
+
: resolvedOptions
|
|
244
|
+
return streamNativeProvider(
|
|
245
|
+
{
|
|
246
|
+
...model,
|
|
247
|
+
api: wire,
|
|
248
|
+
cost: commandCodeCostRatesAt(model.id, model.cost),
|
|
249
|
+
compat: model.compatConfig ?? model.compat,
|
|
250
|
+
},
|
|
251
|
+
context,
|
|
252
|
+
nativeOptions,
|
|
253
|
+
)
|
|
254
|
+
},
|
|
255
|
+
streamGenerate: (model, context, options) =>
|
|
256
|
+
streamGenerate(
|
|
257
|
+
model,
|
|
258
|
+
withTranscriptPromptAndTools(context, transcriptReaders),
|
|
259
|
+
resolveStreamOptions(options),
|
|
260
|
+
),
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
// pi dispatches the main chat through the registered provider, but sibling
|
|
264
|
+
// extensions that call `streamSimple` from `@earendil-works/pi-ai/compat`
|
|
265
|
+
// with a Command Code model resolve `model.api` through the compat
|
|
266
|
+
// api-registry, which knows nothing about extension providers. Register the
|
|
267
|
+
// custom api there so those calls reach the same transport. The registry
|
|
268
|
+
// resolves no credentials for extension providers, so fall back to the
|
|
269
|
+
// configured key when the caller passes none or a placeholder.
|
|
270
|
+
const compatStream: CompatStreamFunction = (model, context, options) =>
|
|
271
|
+
transport.stream(model, context, resolveStreamOptions(options)) as AssistantMessageEventStream
|
|
272
|
+
registerCompatApiProvider(compatStream)
|
|
273
|
+
|
|
274
|
+
pi.on("message_end", async (event, ctx) => {
|
|
275
|
+
if (event.message.role !== "assistant") return
|
|
276
|
+
const normalized = normalizeCommandCodeMessage(event.message, ctx.model?.provider)
|
|
277
|
+
return normalized ? { message: normalized.message } : undefined
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
registerCommandCodeQuota(pi, {
|
|
281
|
+
apiBase: legacyApiBase(apiBase),
|
|
282
|
+
headers: commandCodeHeaders(),
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
const runtime = createCommandCodeRuntime<ProviderConfig, ExtensionCommandContext>(pi, {
|
|
286
|
+
endpoint: modelsUrl,
|
|
287
|
+
cachePath: modelsCachePath,
|
|
288
|
+
loadModels: (signal) =>
|
|
289
|
+
loadCommandCodeModels({
|
|
290
|
+
url: modelsUrl,
|
|
291
|
+
cachePath: modelsCachePath,
|
|
292
|
+
timeoutMs: modelsTimeoutMs,
|
|
293
|
+
signal,
|
|
294
|
+
}),
|
|
295
|
+
loadCachedModels: () => loadCachedCommandCodeModels(modelsCachePath),
|
|
296
|
+
createProviderConfig: (models) => {
|
|
297
|
+
for (const model of models) modelApis.set(model.id, model.api)
|
|
298
|
+
return createProviderConfig(models, apiBase, transport.stream)
|
|
299
|
+
},
|
|
300
|
+
getTransport: transport.getTransport,
|
|
301
|
+
getStreamWarning: () => streamWarning,
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
pi.on("session_shutdown", () => {
|
|
305
|
+
runtime.dispose()
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
await runtime.initialize()
|
|
309
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-commandcode-provider",
|
|
3
|
+
"version": "0.7.11",
|
|
4
|
+
"description": "pi custom provider for Command Code API (commandcode.ai)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package",
|
|
8
|
+
"pi-extension",
|
|
9
|
+
"commandcode",
|
|
10
|
+
"provider"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/patlux/pi-commandcode-provider.git"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/patlux/pi-commandcode-provider#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/patlux/pi-commandcode-provider/issues"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"index.ts",
|
|
23
|
+
"src/",
|
|
24
|
+
"scripts/",
|
|
25
|
+
"README.md",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"CONTRIBUTING.md",
|
|
28
|
+
"RELEASE.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "npm run typecheck && node --test tests/test-release.mjs tests/test-pi-child-cleanup.mjs && tsx tests/test-package-manifest.ts && tsx tests/test-api-key.ts && tsx tests/test-pure-functions.ts && tsx tests/test-models.ts && tsx tests/test-model-metadata-check.ts && tsx tests/test-runtime.ts && tsx tests/test-pricing.ts && tsx tests/test-pricing-check.ts && tsx tests/test-cost.ts && tsx tests/test-oauth.ts && tsx tests/test-abort.ts && tsx tests/test-overflow.ts && tsx tests/test-stream.ts && tsx tests/test-quota.ts && tsx tests/test-quota-command.ts && tsx tests/test-usage.ts && tsx tests/test-retry.ts && tsx tests/test-transport.ts && node tests/test-pi-isolated.mjs && node tests/test-pi-authenticated.mjs && node tests/test-pi-local.mjs && node tests/test-omp-compat.mjs",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"format:check": "prettier --check '**/*.{ts,mjs,json,md}'",
|
|
35
|
+
"format": "prettier --write '**/*.{ts,mjs,json,md}'",
|
|
36
|
+
"pi:isolated": "node scripts/pi-isolated.mjs",
|
|
37
|
+
"pi:authenticated": "node scripts/pi-authenticated.mjs",
|
|
38
|
+
"check:commandcode-catalog": "tsx .github/scripts/check-commandcode-model-metadata.ts command-code@latest",
|
|
39
|
+
"check:commandcode-pricing": "tsx .github/scripts/check-commandcode-pricing.ts",
|
|
40
|
+
"sync:commandcode-catalog": "tsx .github/scripts/check-commandcode-model-metadata.ts command-code@latest --write",
|
|
41
|
+
"test:quota": "tsx tests/test-quota.ts && tsx tests/test-quota-command.ts && tsx tests/test-usage.ts",
|
|
42
|
+
"test:usage": "tsx tests/test-usage.ts",
|
|
43
|
+
"test:unit": "tsx tests/test-api-key.ts && tsx tests/test-pure-functions.ts && tsx tests/test-models.ts && tsx tests/test-model-metadata-check.ts && tsx tests/test-runtime.ts && tsx tests/test-pricing.ts && tsx tests/test-pricing-check.ts && tsx tests/test-cost.ts && tsx tests/test-oauth.ts && tsx tests/test-abort.ts && tsx tests/test-overflow.ts && tsx tests/test-stream.ts && tsx tests/test-quota.ts && tsx tests/test-quota-command.ts && tsx tests/test-usage.ts && tsx tests/test-retry.ts && tsx tests/test-transport.ts",
|
|
44
|
+
"test:api-key": "tsx tests/test-api-key.ts",
|
|
45
|
+
"test:models": "tsx tests/test-models.ts && tsx tests/test-model-metadata-check.ts",
|
|
46
|
+
"test:runtime": "tsx tests/test-runtime.ts",
|
|
47
|
+
"test:pricing": "tsx tests/test-pricing.ts",
|
|
48
|
+
"test:pricing-check": "tsx tests/test-pricing-check.ts",
|
|
49
|
+
"test:oauth": "tsx tests/test-oauth.ts",
|
|
50
|
+
"test:abort": "tsx tests/test-abort.ts",
|
|
51
|
+
"test:overflow": "tsx tests/test-overflow.ts",
|
|
52
|
+
"test:stream": "tsx tests/test-stream.ts",
|
|
53
|
+
"test:retry": "tsx tests/test-retry.ts",
|
|
54
|
+
"test:transport": "tsx tests/test-transport.ts",
|
|
55
|
+
"test:pi-isolated": "node tests/test-pi-isolated.mjs",
|
|
56
|
+
"test:pi-authenticated": "node tests/test-pi-authenticated.mjs",
|
|
57
|
+
"test:pi-local": "node tests/test-pi-local.mjs",
|
|
58
|
+
"test:smoke": "node tests/test-smoke.mjs",
|
|
59
|
+
"test:release": "node --test tests/test-release.mjs",
|
|
60
|
+
"test:release-package": "node tests/test-release-package.mjs",
|
|
61
|
+
"test:e2e:live": "node tests/test-live-e2e.mjs",
|
|
62
|
+
"test:e2e:live:go": "node scripts/live-e2e-profile.mjs go",
|
|
63
|
+
"test:e2e:live:goat": "node scripts/live-e2e-profile.mjs goat",
|
|
64
|
+
"test:e2e:live:provider": "node scripts/live-e2e-profile.mjs provider",
|
|
65
|
+
"test:e2e:live:all": "node scripts/live-e2e-profile.mjs go goat",
|
|
66
|
+
"test:cost": "tsx tests/test-cost.ts"
|
|
67
|
+
},
|
|
68
|
+
"pi": {
|
|
69
|
+
"extensions": [
|
|
70
|
+
"./index.ts"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@types/node": "25.6.0",
|
|
75
|
+
"prettier": "^3.5.0",
|
|
76
|
+
"tsx": "4.22.4",
|
|
77
|
+
"typescript": "6.0.3"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"@earendil-works/pi-ai": "*",
|
|
81
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
82
|
+
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"@earendil-works/pi-ai": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"@earendil-works/pi-coding-agent": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process"
|
|
4
|
+
import { readFile } from "node:fs/promises"
|
|
5
|
+
import { dirname, resolve } from "node:path"
|
|
6
|
+
import { fileURLToPath } from "node:url"
|
|
7
|
+
|
|
8
|
+
const projectDir = resolve(dirname(fileURLToPath(import.meta.url)), "..")
|
|
9
|
+
const liveTest = resolve(projectDir, "tests", "test-live-e2e.mjs")
|
|
10
|
+
const profiles = process.argv.slice(2)
|
|
11
|
+
|
|
12
|
+
if (
|
|
13
|
+
profiles.length === 0 ||
|
|
14
|
+
profiles.some((profile) => profile !== "go" && profile !== "goat" && profile !== "provider")
|
|
15
|
+
) {
|
|
16
|
+
console.error("Usage: node scripts/live-e2e-profile.mjs <go|goat|provider> [go|goat|provider]")
|
|
17
|
+
process.exit(2)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function credentialFor(profile) {
|
|
21
|
+
const prefix =
|
|
22
|
+
profile === "go"
|
|
23
|
+
? "COMMANDCODE_E2E_GO"
|
|
24
|
+
: profile === "goat"
|
|
25
|
+
? "COMMANDCODE_E2E_GOAT"
|
|
26
|
+
: "COMMANDCODE_E2E_PROVIDER"
|
|
27
|
+
const direct = process.env[`${prefix}_API_KEY`]?.trim()
|
|
28
|
+
const file = process.env[`${prefix}_API_KEY_FILE`]
|
|
29
|
+
|
|
30
|
+
if (direct && file)
|
|
31
|
+
throw new Error(`${prefix}_API_KEY and ${prefix}_API_KEY_FILE are mutually exclusive`)
|
|
32
|
+
if (direct) return direct
|
|
33
|
+
if (file) {
|
|
34
|
+
const credential = (await readFile(file, "utf-8")).trim()
|
|
35
|
+
if (credential) return credential
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
throw new Error(`Set ${prefix}_API_KEY_FILE (recommended) or ${prefix}_API_KEY`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function runProfile(profile, apiKey) {
|
|
42
|
+
const modelVariable =
|
|
43
|
+
profile === "go"
|
|
44
|
+
? "COMMANDCODE_E2E_GO_MODEL"
|
|
45
|
+
: profile === "goat"
|
|
46
|
+
? "COMMANDCODE_E2E_GOAT_MODEL"
|
|
47
|
+
: "COMMANDCODE_E2E_PROVIDER_MODEL"
|
|
48
|
+
const model =
|
|
49
|
+
process.env[modelVariable] ??
|
|
50
|
+
(profile === "goat" ? "xai/grok-4.6" : "deepseek/deepseek-v4-flash")
|
|
51
|
+
const env = {
|
|
52
|
+
...process.env,
|
|
53
|
+
COMMAND_CODE_API_KEY: apiKey,
|
|
54
|
+
COMMANDCODE_E2E_MODEL: model,
|
|
55
|
+
COMMANDCODE_E2E_PROFILE: profile,
|
|
56
|
+
}
|
|
57
|
+
delete env.COMMANDCODE_API_KEY
|
|
58
|
+
delete env.COMMANDCODE_E2E_GO_API_KEY
|
|
59
|
+
delete env.COMMANDCODE_E2E_GOAT_API_KEY
|
|
60
|
+
delete env.COMMANDCODE_E2E_PROVIDER_API_KEY
|
|
61
|
+
|
|
62
|
+
return new Promise((resolveRun, reject) => {
|
|
63
|
+
console.log(`[live-e2e:${profile}] model ${model}`)
|
|
64
|
+
const child = spawn(process.execPath, [liveTest], {
|
|
65
|
+
cwd: projectDir,
|
|
66
|
+
env,
|
|
67
|
+
stdio: "inherit",
|
|
68
|
+
})
|
|
69
|
+
child.on("error", reject)
|
|
70
|
+
child.on("close", (code, signal) => {
|
|
71
|
+
if (code === 0) {
|
|
72
|
+
resolveRun()
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
reject(new Error(`[live-e2e:${profile}] failed (${signal ?? `exit ${code}`})`))
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
for (const profile of profiles) {
|
|
82
|
+
await runProfile(profile, await credentialFor(profile))
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
86
|
+
process.exit(1)
|
|
87
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process"
|
|
4
|
+
import { dirname, resolve } from "node:path"
|
|
5
|
+
import { fileURLToPath } from "node:url"
|
|
6
|
+
|
|
7
|
+
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..")
|
|
8
|
+
const extensionPath = resolve(repoRoot, "index.ts")
|
|
9
|
+
|
|
10
|
+
const env = {
|
|
11
|
+
...process.env,
|
|
12
|
+
PI_SKIP_VERSION_CHECK: "1",
|
|
13
|
+
}
|
|
14
|
+
delete env.COMMAND_CODE_API_KEY
|
|
15
|
+
delete env.COMMANDCODE_API_KEY
|
|
16
|
+
|
|
17
|
+
const child = spawn(
|
|
18
|
+
"pi",
|
|
19
|
+
[
|
|
20
|
+
"--no-extensions",
|
|
21
|
+
"--extension",
|
|
22
|
+
extensionPath,
|
|
23
|
+
"--provider",
|
|
24
|
+
"commandcode",
|
|
25
|
+
"--model",
|
|
26
|
+
"gpt-5.6-luna",
|
|
27
|
+
"--models",
|
|
28
|
+
"commandcode/*",
|
|
29
|
+
...process.argv.slice(2),
|
|
30
|
+
],
|
|
31
|
+
{
|
|
32
|
+
cwd: repoRoot,
|
|
33
|
+
env,
|
|
34
|
+
stdio: "inherit",
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
39
|
+
process.on(signal, () => child.kill(signal))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
child.once("error", (error) => {
|
|
43
|
+
console.error(`Could not start pi: ${error.message}`)
|
|
44
|
+
process.exitCode = 1
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
child.once("exit", (status, signal) => {
|
|
48
|
+
if (signal) process.kill(process.pid, signal)
|
|
49
|
+
process.exitCode = status ?? 1
|
|
50
|
+
})
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process"
|
|
4
|
+
import { mkdir, mkdtemp, rm } from "node:fs/promises"
|
|
5
|
+
import { tmpdir } from "node:os"
|
|
6
|
+
import { dirname, join, resolve } from "node:path"
|
|
7
|
+
import { fileURLToPath } from "node:url"
|
|
8
|
+
|
|
9
|
+
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..")
|
|
10
|
+
const testRoot = await mkdtemp(join(tmpdir(), "pi-commandcode-isolated-"))
|
|
11
|
+
const agentDir = join(testRoot, "agent")
|
|
12
|
+
const sessionDir = join(testRoot, "sessions")
|
|
13
|
+
|
|
14
|
+
await mkdir(agentDir, { mode: 0o700 })
|
|
15
|
+
await mkdir(sessionDir, { mode: 0o700 })
|
|
16
|
+
|
|
17
|
+
const env = {
|
|
18
|
+
...process.env,
|
|
19
|
+
HOME: testRoot,
|
|
20
|
+
USERPROFILE: testRoot,
|
|
21
|
+
PI_CODING_AGENT_DIR: agentDir,
|
|
22
|
+
PI_CODING_AGENT_SESSION_DIR: sessionDir,
|
|
23
|
+
PI_SKIP_VERSION_CHECK: "1",
|
|
24
|
+
}
|
|
25
|
+
delete env.COMMAND_CODE_API_KEY
|
|
26
|
+
delete env.COMMANDCODE_API_KEY
|
|
27
|
+
|
|
28
|
+
let activeChild
|
|
29
|
+
let receivedSignal
|
|
30
|
+
|
|
31
|
+
function forwardSignal(signal) {
|
|
32
|
+
receivedSignal = signal
|
|
33
|
+
activeChild?.kill(signal)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const forwardSigint = () => forwardSignal("SIGINT")
|
|
37
|
+
const forwardSigterm = () => forwardSignal("SIGTERM")
|
|
38
|
+
process.on("SIGINT", forwardSigint)
|
|
39
|
+
process.on("SIGTERM", forwardSigterm)
|
|
40
|
+
|
|
41
|
+
function runPi(args) {
|
|
42
|
+
return new Promise((resolveRun, rejectRun) => {
|
|
43
|
+
const child = spawn("pi", args, { cwd: repoRoot, env, stdio: "inherit" })
|
|
44
|
+
activeChild = child
|
|
45
|
+
child.once("error", rejectRun)
|
|
46
|
+
child.once("exit", (status, signal) => {
|
|
47
|
+
activeChild = undefined
|
|
48
|
+
resolveRun({ status, signal })
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let result
|
|
54
|
+
try {
|
|
55
|
+
console.error("Installing the current checkout into an isolated pi environment...")
|
|
56
|
+
const install = await runPi(["install", repoRoot, "--no-approve"])
|
|
57
|
+
if (install.status !== 0 || install.signal) {
|
|
58
|
+
result = install
|
|
59
|
+
} else {
|
|
60
|
+
console.error("Starting pi. Temporary auth and sessions will be removed on exit.")
|
|
61
|
+
result = await runPi([
|
|
62
|
+
"--no-approve",
|
|
63
|
+
"--provider",
|
|
64
|
+
"commandcode",
|
|
65
|
+
"--model",
|
|
66
|
+
"gpt-5.6-luna",
|
|
67
|
+
...process.argv.slice(2),
|
|
68
|
+
])
|
|
69
|
+
}
|
|
70
|
+
} finally {
|
|
71
|
+
process.removeListener("SIGINT", forwardSigint)
|
|
72
|
+
process.removeListener("SIGTERM", forwardSigterm)
|
|
73
|
+
await rm(testRoot, { recursive: true, force: true })
|
|
74
|
+
console.error("Removed the isolated pi environment.")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const signal = receivedSignal ?? result?.signal
|
|
78
|
+
if (signal) process.kill(process.pid, signal)
|
|
79
|
+
process.exitCode = result?.status ?? 1
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
2
|
+
import { homedir } from "node:os"
|
|
3
|
+
import { join } from "node:path"
|
|
4
|
+
|
|
5
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function stringValue(value: unknown): string | undefined {
|
|
10
|
+
return typeof value === "string" ? value : undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function defaultAuthPaths(home: string): string[] {
|
|
14
|
+
return [
|
|
15
|
+
join(home, ".commandcode", "auth.json"),
|
|
16
|
+
join(home, ".pi", "agent", "auth.json"),
|
|
17
|
+
join(home, ".omp", "agent", "auth.json"),
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function apiKeyFromCredential(value: unknown): string | undefined {
|
|
22
|
+
if (!isRecord(value)) return undefined
|
|
23
|
+
|
|
24
|
+
if (stringValue(value.type) === "oauth") return stringValue(value.access)
|
|
25
|
+
if (stringValue(value.type) === "api") return stringValue(value.key)
|
|
26
|
+
return stringValue(value.access) ?? stringValue(value.key)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getConfiguredApiKey(
|
|
30
|
+
options: {
|
|
31
|
+
env?: NodeJS.ProcessEnv
|
|
32
|
+
authPaths?: readonly string[]
|
|
33
|
+
homeDir?: () => string
|
|
34
|
+
} = {},
|
|
35
|
+
): string | undefined {
|
|
36
|
+
const env = options.env ?? process.env
|
|
37
|
+
if (env.COMMAND_CODE_API_KEY) return env.COMMAND_CODE_API_KEY
|
|
38
|
+
if (env.COMMANDCODE_API_KEY) return env.COMMANDCODE_API_KEY
|
|
39
|
+
|
|
40
|
+
const home = options.homeDir?.() ?? homedir()
|
|
41
|
+
const authPaths = options.authPaths ?? defaultAuthPaths(home)
|
|
42
|
+
|
|
43
|
+
for (const authPath of authPaths) {
|
|
44
|
+
try {
|
|
45
|
+
if (!existsSync(authPath)) continue
|
|
46
|
+
const parsed: unknown = JSON.parse(readFileSync(authPath, "utf-8"))
|
|
47
|
+
if (!isRecord(parsed)) continue
|
|
48
|
+
|
|
49
|
+
const apiKey = stringValue(parsed.apiKey)
|
|
50
|
+
if (apiKey) return apiKey
|
|
51
|
+
|
|
52
|
+
const commandcode = stringValue(parsed.commandcode)
|
|
53
|
+
if (commandcode) return commandcode
|
|
54
|
+
|
|
55
|
+
const providerKey = apiKeyFromCredential(parsed.commandcode)
|
|
56
|
+
if (providerKey) return providerKey
|
|
57
|
+
|
|
58
|
+
const commandCode = stringValue(parsed["command-code"])
|
|
59
|
+
if (commandCode) return commandCode
|
|
60
|
+
|
|
61
|
+
const commandCodeKey = apiKeyFromCredential(parsed["command-code"])
|
|
62
|
+
if (commandCodeKey) return commandCodeKey
|
|
63
|
+
} catch {
|
|
64
|
+
// Ignore malformed or unreadable auth files.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return undefined
|
|
69
|
+
}
|