@herbertgao/pi-extensions 2026.10.18 → 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 -5
- package/THIRD_PARTY_NOTICES.md +53 -3
- 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 -11
- package/node_modules/@tifan/pi-inline-skills/README.md +0 -41
- package/node_modules/@tifan/pi-inline-skills/package.json +0 -44
- package/node_modules/@tifan/pi-inline-skills/src/index.ts +0 -646
- 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,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local cost calculation for Command Code usage.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors pi-ai's `calculateCost` arithmetic exactly. The provider ships its
|
|
5
|
+
* own copy because Oh My Pi's legacy pi-ai shim does not export
|
|
6
|
+
* `calculateCost`, which broke extension installation there (issue #24).
|
|
7
|
+
* `tests/test-cost.ts` locks this implementation to the pi-ai original.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ModelCostRates, ModelLike, Usage } from "./types.ts"
|
|
11
|
+
|
|
12
|
+
const DEEPSEEK_V4_TIME_PRICED_MODELS = new Set([
|
|
13
|
+
"deepseek/deepseek-v4-pro",
|
|
14
|
+
"deepseek/deepseek-v4-flash",
|
|
15
|
+
"deepseek/deepseek-v4-flash-vision-exp",
|
|
16
|
+
"deepseek/deepseek-v4.1-flash",
|
|
17
|
+
"deepseek/deepseek-v4.1-flash-fast",
|
|
18
|
+
])
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Command Code documents DeepSeek V4 peak pricing on weekdays from
|
|
22
|
+
* 01:00-04:00 and 06:00-10:00 UTC. Weekends are entirely off-peak.
|
|
23
|
+
*/
|
|
24
|
+
export function isDeepSeekV4Peak(atMs: number): boolean {
|
|
25
|
+
const at = new Date(atMs)
|
|
26
|
+
const day = at.getUTCDay()
|
|
27
|
+
if (day === 0 || day === 6) return false
|
|
28
|
+
|
|
29
|
+
const hour = at.getUTCHours()
|
|
30
|
+
return (hour >= 1 && hour < 4) || (hour >= 6 && hour < 10)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Select request-time rates for both the native provider transport and the
|
|
35
|
+
* local generate fallback. DeepSeek V4 peak rates are exactly 2x off-peak.
|
|
36
|
+
*/
|
|
37
|
+
export function commandCodeCostRatesAt(
|
|
38
|
+
modelId: string,
|
|
39
|
+
rates: ModelCostRates,
|
|
40
|
+
atMs: number = Date.now(),
|
|
41
|
+
): ModelCostRates {
|
|
42
|
+
if (!DEEPSEEK_V4_TIME_PRICED_MODELS.has(modelId) || !isDeepSeekV4Peak(atMs)) return rates
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
input: rates.input * 2,
|
|
46
|
+
output: rates.output * 2,
|
|
47
|
+
cacheRead: rates.cacheRead * 2,
|
|
48
|
+
cacheWrite: rates.cacheWrite * 2,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function calculateCommandCodeCost(
|
|
53
|
+
model: ModelLike,
|
|
54
|
+
usage: Usage,
|
|
55
|
+
atMs: number = Date.now(),
|
|
56
|
+
): void {
|
|
57
|
+
const inputTokens = usage.input + usage.cacheRead + usage.cacheWrite
|
|
58
|
+
let rates: ModelCostRates = model.cost
|
|
59
|
+
let matchedThreshold = -1
|
|
60
|
+
for (const tier of model.cost.tiers ?? []) {
|
|
61
|
+
if (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {
|
|
62
|
+
rates = tier
|
|
63
|
+
matchedThreshold = tier.inputTokensAbove
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
rates = commandCodeCostRatesAt(model.id, rates, atMs)
|
|
67
|
+
|
|
68
|
+
const longWrite = usage.cacheWrite1h ?? 0
|
|
69
|
+
const shortWrite = usage.cacheWrite - longWrite
|
|
70
|
+
usage.cost.input = (rates.input / 1_000_000) * usage.input
|
|
71
|
+
usage.cost.output = (rates.output / 1_000_000) * usage.output
|
|
72
|
+
usage.cost.cacheRead = (rates.cacheRead / 1_000_000) * usage.cacheRead
|
|
73
|
+
usage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1_000_000
|
|
74
|
+
usage.cost.total =
|
|
75
|
+
usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite
|
|
76
|
+
}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function stringValue(value: unknown): string | undefined {
|
|
6
|
+
return typeof value === "string" ? value : undefined
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function booleanValue(value: unknown): boolean | undefined {
|
|
10
|
+
return typeof value === "boolean" ? value : undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type JsonSchemaValue = boolean | Record<string, unknown>
|
|
14
|
+
|
|
15
|
+
const JSON_SCHEMA_TYPES = new Set([
|
|
16
|
+
"array",
|
|
17
|
+
"boolean",
|
|
18
|
+
"integer",
|
|
19
|
+
"null",
|
|
20
|
+
"number",
|
|
21
|
+
"object",
|
|
22
|
+
"string",
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
const LEGACY_KINDS = new Set([
|
|
26
|
+
"any",
|
|
27
|
+
"array",
|
|
28
|
+
"boolean",
|
|
29
|
+
"enum",
|
|
30
|
+
"integer",
|
|
31
|
+
"intersect",
|
|
32
|
+
"intersection",
|
|
33
|
+
"literal",
|
|
34
|
+
"never",
|
|
35
|
+
"null",
|
|
36
|
+
"nullable",
|
|
37
|
+
"number",
|
|
38
|
+
"object",
|
|
39
|
+
"optional",
|
|
40
|
+
"string",
|
|
41
|
+
"undefined",
|
|
42
|
+
"union",
|
|
43
|
+
"unknown",
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
const LEGACY_FIELDS = new Set([
|
|
47
|
+
"element",
|
|
48
|
+
"kind",
|
|
49
|
+
"inner",
|
|
50
|
+
"optional",
|
|
51
|
+
"value",
|
|
52
|
+
"values",
|
|
53
|
+
"variants",
|
|
54
|
+
"wrapped",
|
|
55
|
+
])
|
|
56
|
+
|
|
57
|
+
const SCHEMA_MAP_FIELDS = new Set([
|
|
58
|
+
"$defs",
|
|
59
|
+
"definitions",
|
|
60
|
+
"dependentSchemas",
|
|
61
|
+
"patternProperties",
|
|
62
|
+
"properties",
|
|
63
|
+
])
|
|
64
|
+
|
|
65
|
+
const SCHEMA_ARRAY_FIELDS = new Set(["allOf", "anyOf", "oneOf", "prefixItems"])
|
|
66
|
+
|
|
67
|
+
const SCHEMA_VALUE_FIELDS = new Set([
|
|
68
|
+
"additionalItems",
|
|
69
|
+
"additionalProperties",
|
|
70
|
+
"contains",
|
|
71
|
+
"contentSchema",
|
|
72
|
+
"else",
|
|
73
|
+
"if",
|
|
74
|
+
"items",
|
|
75
|
+
"not",
|
|
76
|
+
"propertyNames",
|
|
77
|
+
"then",
|
|
78
|
+
"unevaluatedItems",
|
|
79
|
+
"unevaluatedProperties",
|
|
80
|
+
])
|
|
81
|
+
|
|
82
|
+
const SCHEMA_KEYWORDS = new Set([
|
|
83
|
+
"$anchor",
|
|
84
|
+
"$comment",
|
|
85
|
+
"$defs",
|
|
86
|
+
"$dynamicAnchor",
|
|
87
|
+
"$dynamicRef",
|
|
88
|
+
"$id",
|
|
89
|
+
"$ref",
|
|
90
|
+
"$schema",
|
|
91
|
+
"$vocabulary",
|
|
92
|
+
"additionalItems",
|
|
93
|
+
"additionalProperties",
|
|
94
|
+
"allOf",
|
|
95
|
+
"anyOf",
|
|
96
|
+
"const",
|
|
97
|
+
"contains",
|
|
98
|
+
"contentEncoding",
|
|
99
|
+
"contentMediaType",
|
|
100
|
+
"contentSchema",
|
|
101
|
+
"default",
|
|
102
|
+
"definitions",
|
|
103
|
+
"dependentRequired",
|
|
104
|
+
"dependentSchemas",
|
|
105
|
+
"description",
|
|
106
|
+
"else",
|
|
107
|
+
"enum",
|
|
108
|
+
"examples",
|
|
109
|
+
"exclusiveMaximum",
|
|
110
|
+
"exclusiveMinimum",
|
|
111
|
+
"format",
|
|
112
|
+
"if",
|
|
113
|
+
"items",
|
|
114
|
+
"maxContains",
|
|
115
|
+
"maxItems",
|
|
116
|
+
"maxLength",
|
|
117
|
+
"maxProperties",
|
|
118
|
+
"maximum",
|
|
119
|
+
"minContains",
|
|
120
|
+
"minItems",
|
|
121
|
+
"minLength",
|
|
122
|
+
"minProperties",
|
|
123
|
+
"minimum",
|
|
124
|
+
"multipleOf",
|
|
125
|
+
"not",
|
|
126
|
+
"oneOf",
|
|
127
|
+
"pattern",
|
|
128
|
+
"patternProperties",
|
|
129
|
+
"prefixItems",
|
|
130
|
+
"properties",
|
|
131
|
+
"propertyNames",
|
|
132
|
+
"readOnly",
|
|
133
|
+
"required",
|
|
134
|
+
"title",
|
|
135
|
+
"type",
|
|
136
|
+
"unevaluatedItems",
|
|
137
|
+
"unevaluatedProperties",
|
|
138
|
+
"uniqueItems",
|
|
139
|
+
"writeOnly",
|
|
140
|
+
])
|
|
141
|
+
|
|
142
|
+
function stringArray(value: unknown): string[] | undefined {
|
|
143
|
+
if (!Array.isArray(value)) return undefined
|
|
144
|
+
const values = value.filter((item): item is string => typeof item === "string")
|
|
145
|
+
return values.length === value.length ? values : undefined
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function validSchemaType(value: unknown): boolean {
|
|
149
|
+
if (typeof value === "string") return JSON_SCHEMA_TYPES.has(value)
|
|
150
|
+
if (!Array.isArray(value) || value.length === 0) return false
|
|
151
|
+
return value.every((item) => typeof item === "string" && JSON_SCHEMA_TYPES.has(item))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function legacyKind(schema: Record<string, unknown>): string | undefined {
|
|
155
|
+
const explicitKind = stringValue(schema.kind)?.toLowerCase()
|
|
156
|
+
if (explicitKind && LEGACY_KINDS.has(explicitKind)) return explicitKind
|
|
157
|
+
|
|
158
|
+
const type = stringValue(schema.type)
|
|
159
|
+
const normalized = type?.toLowerCase()
|
|
160
|
+
if (!normalized || !LEGACY_KINDS.has(normalized)) return undefined
|
|
161
|
+
if (!validSchemaType(type) || Object.keys(schema).some((key) => LEGACY_FIELDS.has(key))) {
|
|
162
|
+
return normalized
|
|
163
|
+
}
|
|
164
|
+
return undefined
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function looksLikeJsonSchema(schema: Record<string, unknown>): boolean {
|
|
168
|
+
if (Object.keys(schema).length === 0) return true
|
|
169
|
+
if (schema.type !== undefined && !validSchemaType(schema.type)) return false
|
|
170
|
+
return Object.keys(schema).some((key) => SCHEMA_KEYWORDS.has(key))
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function isOptionalSchema(schema: unknown): boolean {
|
|
174
|
+
if (!isRecord(schema)) return false
|
|
175
|
+
if (booleanValue(schema.optional) === true) return true
|
|
176
|
+
|
|
177
|
+
const kind = legacyKind(schema)
|
|
178
|
+
if (kind === "optional") return true
|
|
179
|
+
if (kind !== "union") return false
|
|
180
|
+
|
|
181
|
+
const variants = Array.isArray(schema.variants)
|
|
182
|
+
? schema.variants
|
|
183
|
+
: Array.isArray(schema.anyOf)
|
|
184
|
+
? schema.anyOf
|
|
185
|
+
: []
|
|
186
|
+
return variants.some((variant) => legacyKind(isRecord(variant) ? variant : {}) === "undefined")
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function schemaValue(value: unknown, seen: WeakSet<object>): JsonSchemaValue {
|
|
190
|
+
if (typeof value === "boolean") return value
|
|
191
|
+
if (!isRecord(value)) return {}
|
|
192
|
+
return convertSchema(value, seen)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function setSchemaProperty(target: Record<string, unknown>, key: string, value: unknown): void {
|
|
196
|
+
Object.defineProperty(target, key, {
|
|
197
|
+
configurable: true,
|
|
198
|
+
enumerable: true,
|
|
199
|
+
value,
|
|
200
|
+
writable: true,
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function schemaMap(value: unknown, seen: WeakSet<object>): Record<string, unknown> {
|
|
205
|
+
if (!isRecord(value)) return {}
|
|
206
|
+
const out: Record<string, unknown> = {}
|
|
207
|
+
for (const [key, item] of Object.entries(value)) {
|
|
208
|
+
setSchemaProperty(out, key, schemaValue(item, seen))
|
|
209
|
+
}
|
|
210
|
+
return out
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function schemaArray(value: unknown, seen: WeakSet<object>): unknown[] {
|
|
214
|
+
if (!Array.isArray(value)) return []
|
|
215
|
+
return value.map((item) => schemaValue(item, seen))
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function isSchemaValue(value: unknown): value is JsonSchemaValue {
|
|
219
|
+
return typeof value === "boolean" || isRecord(value)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function copySchemaObject(
|
|
223
|
+
source: Record<string, unknown>,
|
|
224
|
+
seen: WeakSet<object>,
|
|
225
|
+
legacy: boolean,
|
|
226
|
+
forcedType?: string,
|
|
227
|
+
): JsonSchemaValue {
|
|
228
|
+
const out: Record<string, unknown> = {}
|
|
229
|
+
|
|
230
|
+
for (const [key, value] of Object.entries(source)) {
|
|
231
|
+
if (legacy && LEGACY_FIELDS.has(key)) continue
|
|
232
|
+
if (key === "nullable" || (forcedType !== undefined && key === "type")) continue
|
|
233
|
+
|
|
234
|
+
if (key === "required") {
|
|
235
|
+
const required = stringArray(value)
|
|
236
|
+
if (required) out.required = required
|
|
237
|
+
} else if (SCHEMA_MAP_FIELDS.has(key)) {
|
|
238
|
+
out[key] = schemaMap(value, seen)
|
|
239
|
+
} else if (SCHEMA_ARRAY_FIELDS.has(key)) {
|
|
240
|
+
out[key] = schemaArray(value, seen)
|
|
241
|
+
} else if (SCHEMA_VALUE_FIELDS.has(key)) {
|
|
242
|
+
out[key] =
|
|
243
|
+
Array.isArray(value) && key === "items"
|
|
244
|
+
? schemaArray(value, seen)
|
|
245
|
+
: schemaValue(value, seen)
|
|
246
|
+
} else {
|
|
247
|
+
out[key] = value
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (forcedType !== undefined) out.type = forcedType
|
|
252
|
+
if (booleanValue(source.nullable) === true) return makeNullable(out)
|
|
253
|
+
return out
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function makeNullable(schema: Record<string, unknown>): Record<string, unknown> {
|
|
257
|
+
const type = schema.type
|
|
258
|
+
if (typeof type === "string") {
|
|
259
|
+
if (type === "null") return schema
|
|
260
|
+
return { ...schema, type: [type, "null"] }
|
|
261
|
+
}
|
|
262
|
+
if (Array.isArray(type) && !type.includes("null")) {
|
|
263
|
+
return { ...schema, type: [...type, "null"] }
|
|
264
|
+
}
|
|
265
|
+
if (Array.isArray(schema.anyOf)) {
|
|
266
|
+
return { ...schema, anyOf: [...schema.anyOf, { type: "null" }] }
|
|
267
|
+
}
|
|
268
|
+
return { anyOf: [schema, { type: "null" }] }
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function legacyVariants(schema: Record<string, unknown>): unknown[] {
|
|
272
|
+
if (Array.isArray(schema.variants)) return schema.variants
|
|
273
|
+
if (Array.isArray(schema.anyOf)) return schema.anyOf
|
|
274
|
+
return []
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function convertLegacySchema(
|
|
278
|
+
source: Record<string, unknown>,
|
|
279
|
+
kind: string,
|
|
280
|
+
seen: WeakSet<object>,
|
|
281
|
+
): JsonSchemaValue {
|
|
282
|
+
if (kind === "optional") return schemaValue(source.wrapped ?? source.inner, seen)
|
|
283
|
+
if (kind === "nullable") {
|
|
284
|
+
const wrapped = schemaValue(source.wrapped ?? source.inner, seen)
|
|
285
|
+
return typeof wrapped === "boolean" ? wrapped : makeNullable(wrapped)
|
|
286
|
+
}
|
|
287
|
+
if (kind === "undefined" || kind === "never" || kind === "any" || kind === "unknown") return {}
|
|
288
|
+
|
|
289
|
+
if (kind === "union" || kind === "intersect" || kind === "intersection") {
|
|
290
|
+
const variants = legacyVariants(source)
|
|
291
|
+
.map((variant) => schemaValue(variant, seen))
|
|
292
|
+
.filter(
|
|
293
|
+
(variant) =>
|
|
294
|
+
isSchemaValue(variant) &&
|
|
295
|
+
(typeof variant === "boolean" || Object.keys(variant).length > 0),
|
|
296
|
+
)
|
|
297
|
+
if (variants.length === 0) return copySchemaObject(source, seen, true)
|
|
298
|
+
if (variants.length === 1) return variants[0] ?? {}
|
|
299
|
+
|
|
300
|
+
const out = copySchemaObject(source, seen, true)
|
|
301
|
+
if (typeof out !== "boolean") out[kind === "union" ? "anyOf" : "allOf"] = variants
|
|
302
|
+
return out
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (kind === "object") {
|
|
306
|
+
const converted = copySchemaObject(source, seen, true, "object")
|
|
307
|
+
if (typeof converted === "boolean") return converted
|
|
308
|
+
const out = converted
|
|
309
|
+
const sourceProperties = isRecord(source.properties) ? source.properties : undefined
|
|
310
|
+
if (!sourceProperties) return out
|
|
311
|
+
|
|
312
|
+
const properties: Record<string, unknown> = {}
|
|
313
|
+
const optional = stringArray(source.optional) ?? []
|
|
314
|
+
for (const [key, value] of Object.entries(sourceProperties)) {
|
|
315
|
+
setSchemaProperty(properties, key, schemaValue(value, seen))
|
|
316
|
+
}
|
|
317
|
+
out.properties = properties
|
|
318
|
+
|
|
319
|
+
const explicitRequired = stringArray(source.required)
|
|
320
|
+
const required =
|
|
321
|
+
explicitRequired ??
|
|
322
|
+
Object.entries(sourceProperties)
|
|
323
|
+
.filter(([key, value]) => !optional.includes(key) && !isOptionalSchema(value))
|
|
324
|
+
.map(([key]) => key)
|
|
325
|
+
if (required.length > 0) out.required = required
|
|
326
|
+
else delete out.required
|
|
327
|
+
return out
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (kind === "array") {
|
|
331
|
+
const converted = copySchemaObject(source, seen, true, "array")
|
|
332
|
+
if (typeof converted === "boolean") return converted
|
|
333
|
+
const out = converted
|
|
334
|
+
if (!("items" in source) && "element" in source) out.items = schemaValue(source.element, seen)
|
|
335
|
+
return out
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (kind === "enum") {
|
|
339
|
+
const converted = copySchemaObject(source, seen, true)
|
|
340
|
+
if (typeof converted === "boolean") return converted
|
|
341
|
+
const out = converted
|
|
342
|
+
if (!("enum" in out) && Array.isArray(source.values)) out.enum = source.values
|
|
343
|
+
return out
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (kind === "literal") {
|
|
347
|
+
const converted = copySchemaObject(source, seen, true)
|
|
348
|
+
if (typeof converted === "boolean") return converted
|
|
349
|
+
const out = converted
|
|
350
|
+
if (!("const" in out) && "value" in source) out.const = source.value
|
|
351
|
+
return out
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const scalarType =
|
|
355
|
+
kind === "string" ||
|
|
356
|
+
kind === "number" ||
|
|
357
|
+
kind === "boolean" ||
|
|
358
|
+
kind === "integer" ||
|
|
359
|
+
kind === "null"
|
|
360
|
+
? kind
|
|
361
|
+
: undefined
|
|
362
|
+
return scalarType ? copySchemaObject(source, seen, true, scalarType) : {}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function convertSchema(source: Record<string, unknown>, seen: WeakSet<object>): JsonSchemaValue {
|
|
366
|
+
if (seen.has(source)) return {}
|
|
367
|
+
seen.add(source)
|
|
368
|
+
try {
|
|
369
|
+
const kind = legacyKind(source)
|
|
370
|
+
if (kind) return convertLegacySchema(source, kind, seen)
|
|
371
|
+
if (!looksLikeJsonSchema(source)) return {}
|
|
372
|
+
return copySchemaObject(source, seen, false)
|
|
373
|
+
} finally {
|
|
374
|
+
seen.delete(source)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export function toJsonSchema(schema: unknown): unknown {
|
|
379
|
+
if (typeof schema === "boolean") return schema
|
|
380
|
+
if (!isRecord(schema)) return {}
|
|
381
|
+
return convertSchema(schema, new WeakSet<object>())
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Normalize nullable type arrays for Gemini's generate transport (#99).
|
|
386
|
+
* The gateway can turn these into any_of with sibling fields, which Vertex
|
|
387
|
+
* rejects. Use a single type plus nullable, omit null defaults, and leave
|
|
388
|
+
* genuine multi-type unions and required fields unchanged.
|
|
389
|
+
*/
|
|
390
|
+
export function geminiSafeJsonSchema(schema: unknown): unknown {
|
|
391
|
+
if (Array.isArray(schema)) return schema.map(geminiSafeJsonSchema)
|
|
392
|
+
if (!isRecord(schema)) return schema
|
|
393
|
+
const out: Record<string, unknown> = {}
|
|
394
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
395
|
+
if (key === "default" && value === null) continue
|
|
396
|
+
// Literal values (const, enum, defaults, examples) are data, not schemas.
|
|
397
|
+
const converted =
|
|
398
|
+
SCHEMA_MAP_FIELDS.has(key) && isRecord(value)
|
|
399
|
+
? Object.fromEntries(
|
|
400
|
+
Object.entries(value).map(([name, child]) => [name, geminiSafeJsonSchema(child)]),
|
|
401
|
+
)
|
|
402
|
+
: SCHEMA_ARRAY_FIELDS.has(key) || SCHEMA_VALUE_FIELDS.has(key)
|
|
403
|
+
? geminiSafeJsonSchema(value)
|
|
404
|
+
: value
|
|
405
|
+
setSchemaProperty(out, key, converted)
|
|
406
|
+
}
|
|
407
|
+
const type = out.type
|
|
408
|
+
if (Array.isArray(type)) {
|
|
409
|
+
const entries = type.filter((entry): entry is string => typeof entry === "string")
|
|
410
|
+
const nonNull = entries.filter((entry) => entry !== "null")
|
|
411
|
+
if (entries.length === type.length && entries.includes("null") && nonNull.length === 1) {
|
|
412
|
+
out.type = nonNull[0]
|
|
413
|
+
out.nullable = true
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return out
|
|
417
|
+
}
|