@shareai-lab/kode 2.0.2 → 2.0.3
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/LICENSE +201 -0
- package/README.md +649 -25
- package/README.zh-CN.md +579 -0
- package/cli-acp.js +3 -17
- package/cli.js +5 -7
- package/dist/chunks/Doctor-M3J7GRTJ.js +12 -0
- package/dist/chunks/LogList-ISWZ6DDD.js +121 -0
- package/dist/chunks/LogList-ISWZ6DDD.js.map +7 -0
- package/dist/chunks/REPL-RQ6LO6S7.js +56 -0
- package/dist/chunks/ResumeConversation-6DMVBEGH.js +56 -0
- package/dist/chunks/agentLoader-FCRG3TFJ.js +31 -0
- package/dist/{agentsValidate-XP3CFN6F.js → chunks/agentsValidate-PEWMYN4Q.js} +97 -69
- package/dist/chunks/agentsValidate-PEWMYN4Q.js.map +7 -0
- package/dist/{ask-3G5H5KD5.js → chunks/ask-D7SOHJ6Z.js} +36 -44
- package/dist/chunks/ask-D7SOHJ6Z.js.map +7 -0
- package/dist/chunks/autoUpdater-CNESBOKO.js +19 -0
- package/dist/{chunk-EH34V7CY.js → chunks/chunk-2JN5MY67.js} +12 -14
- package/dist/chunks/chunk-2JN5MY67.js.map +7 -0
- package/dist/chunks/chunk-2QONJ5MG.js +14 -0
- package/dist/chunks/chunk-2QONJ5MG.js.map +7 -0
- package/dist/chunks/chunk-2WEXPKHH.js +903 -0
- package/dist/chunks/chunk-2WEXPKHH.js.map +7 -0
- package/dist/{chunk-K2MI4TPB.js → chunks/chunk-3BYE3ME6.js} +717 -792
- package/dist/chunks/chunk-3BYE3ME6.js.map +7 -0
- package/dist/chunks/chunk-3JDNWX7W.js +1264 -0
- package/dist/chunks/chunk-3JDNWX7W.js.map +7 -0
- package/dist/chunks/chunk-3OEJVB5A.js +906 -0
- package/dist/chunks/chunk-3OEJVB5A.js.map +7 -0
- package/dist/chunks/chunk-3TNIOEBO.js +369 -0
- package/dist/chunks/chunk-3TNIOEBO.js.map +7 -0
- package/dist/chunks/chunk-4A46ZXMJ.js +67 -0
- package/dist/chunks/chunk-4A46ZXMJ.js.map +7 -0
- package/dist/{chunk-4GAIJGRH.js → chunks/chunk-4ATBQOFO.js} +107 -55
- package/dist/chunks/chunk-4ATBQOFO.js.map +7 -0
- package/dist/chunks/chunk-4CRUCZR4.js +0 -0
- package/dist/{chunk-54DNHKOD.js → chunks/chunk-4EO6SIQY.js} +32 -75
- package/dist/chunks/chunk-4EO6SIQY.js.map +7 -0
- package/dist/chunks/chunk-53M46S5I.js +64 -0
- package/dist/chunks/chunk-53M46S5I.js.map +7 -0
- package/dist/{chunk-JC6NCUG5.js → chunks/chunk-54KOYG5C.js} +0 -2
- package/dist/{chunk-EZXMVTDU.js → chunks/chunk-6BAS4WY6.js} +29 -45
- package/dist/chunks/chunk-6BAS4WY6.js.map +7 -0
- package/dist/{chunk-BHGTA6JQ.js → chunks/chunk-6KRRFSDN.js} +4 -6
- package/dist/chunks/chunk-6KRRFSDN.js.map +7 -0
- package/dist/chunks/chunk-6LJNZK4K.js +39 -0
- package/dist/chunks/chunk-6LJNZK4K.js.map +7 -0
- package/dist/chunks/chunk-6ZWEOSEI.js +666 -0
- package/dist/chunks/chunk-6ZWEOSEI.js.map +7 -0
- package/dist/chunks/chunk-77XDJMBP.js +3326 -0
- package/dist/chunks/chunk-77XDJMBP.js.map +7 -0
- package/dist/chunks/chunk-7RRW4NTB.js +6454 -0
- package/dist/chunks/chunk-7RRW4NTB.js.map +7 -0
- package/dist/chunks/chunk-7X3TW4JB.js +4520 -0
- package/dist/chunks/chunk-7X3TW4JB.js.map +7 -0
- package/dist/chunks/chunk-B3MW3YGY.js +1409 -0
- package/dist/chunks/chunk-B3MW3YGY.js.map +7 -0
- package/dist/chunks/chunk-BBJFHTBC.js +28 -0
- package/dist/chunks/chunk-BBJFHTBC.js.map +7 -0
- package/dist/chunks/chunk-BHDHXOXB.js +24 -0
- package/dist/chunks/chunk-BHDHXOXB.js.map +7 -0
- package/dist/{chunk-OZNRLY3E.js → chunks/chunk-BTA7SZ26.js} +152 -223
- package/dist/chunks/chunk-BTA7SZ26.js.map +7 -0
- package/dist/chunks/chunk-CDGRYGPZ.js +103 -0
- package/dist/chunks/chunk-CDGRYGPZ.js.map +7 -0
- package/dist/{chunk-S6HRABTA.js → chunks/chunk-CP6E5UG6.js} +1 -4
- package/dist/chunks/chunk-CP6E5UG6.js.map +7 -0
- package/dist/{chunk-2PMO2FS2.js → chunks/chunk-DQ4JHXMT.js} +462 -424
- package/dist/chunks/chunk-DQ4JHXMT.js.map +7 -0
- package/dist/chunks/chunk-DXD76CMV.js +208 -0
- package/dist/chunks/chunk-DXD76CMV.js.map +7 -0
- package/dist/chunks/chunk-GCQCAXJZ.js +0 -0
- package/dist/chunks/chunk-GELCZWMB.js +42 -0
- package/dist/chunks/chunk-GELCZWMB.js.map +7 -0
- package/dist/{chunk-NQLEUHMS.js → chunks/chunk-HJYOH4HC.js} +23 -18
- package/dist/chunks/chunk-HJYOH4HC.js.map +7 -0
- package/dist/chunks/chunk-HPYNW6TT.js +744 -0
- package/dist/chunks/chunk-HPYNW6TT.js.map +7 -0
- package/dist/{chunk-2KWKUXLT.js → chunks/chunk-HRJ3ICQK.js} +59 -55
- package/dist/chunks/chunk-HRJ3ICQK.js.map +7 -0
- package/dist/{chunk-ZQU3TXLC.js → chunks/chunk-IFCIADS3.js} +571 -573
- package/dist/chunks/chunk-IFCIADS3.js.map +7 -0
- package/dist/chunks/chunk-IN7XZ7BC.js +27 -0
- package/dist/chunks/chunk-IN7XZ7BC.js.map +7 -0
- package/dist/chunks/chunk-L7P4M4KW.js +193 -0
- package/dist/chunks/chunk-L7P4M4KW.js.map +7 -0
- package/dist/chunks/chunk-LB6TCPDI.js +0 -0
- package/dist/{chunk-3RUXVV4S.js → chunks/chunk-LOCXPQNJ.js} +1 -4
- package/dist/{chunk-3RUXVV4S.js.map → chunks/chunk-LOCXPQNJ.js.map} +2 -2
- package/dist/{chunk-IE2CG2TV.js → chunks/chunk-LOD5ZHCI.js} +213 -208
- package/dist/chunks/chunk-LOD5ZHCI.js.map +7 -0
- package/dist/{chunk-S3J2TLV6.js → chunks/chunk-M7P3QNRU.js} +1 -4
- package/dist/{chunk-S3J2TLV6.js.map → chunks/chunk-M7P3QNRU.js.map} +2 -2
- package/dist/chunks/chunk-PPHLQVL7.js +4234 -0
- package/dist/chunks/chunk-PPHLQVL7.js.map +7 -0
- package/dist/{chunk-ABLVTESJ.js → chunks/chunk-QAXE37B5.js} +1 -4
- package/dist/chunks/chunk-QAXE37B5.js.map +7 -0
- package/dist/chunks/chunk-QHQOBUF6.js +60 -0
- package/dist/chunks/chunk-QHQOBUF6.js.map +7 -0
- package/dist/{chunk-SRZZFAS7.js → chunks/chunk-RPJXO7GG.js} +241 -214
- package/dist/chunks/chunk-RPJXO7GG.js.map +7 -0
- package/dist/{chunk-NPFOMITO.js → chunks/chunk-SWQV4KSY.js} +1 -4
- package/dist/{chunk-NPFOMITO.js.map → chunks/chunk-SWQV4KSY.js.map} +2 -2
- package/dist/chunks/chunk-SZLAPULP.js +28 -0
- package/dist/chunks/chunk-SZLAPULP.js.map +7 -0
- package/dist/{chunk-SDGKPKDK.js → chunks/chunk-T7RB5V5J.js} +23 -25
- package/dist/chunks/chunk-T7RB5V5J.js.map +7 -0
- package/dist/{chunk-HN4E4UUQ.js → chunks/chunk-TI2CTTMA.js} +25 -17
- package/dist/chunks/chunk-TI2CTTMA.js.map +7 -0
- package/dist/{chunk-G6I7XROM.js → chunks/chunk-TNGVRTO5.js} +45 -20
- package/dist/chunks/chunk-TNGVRTO5.js.map +7 -0
- package/dist/chunks/chunk-TNWB3U5Y.js +2077 -0
- package/dist/chunks/chunk-TNWB3U5Y.js.map +7 -0
- package/dist/chunks/chunk-U2IHWPCU.js +12 -0
- package/dist/chunks/chunk-U2IHWPCU.js.map +7 -0
- package/dist/{chunk-KAA5BGMQ.js → chunks/chunk-UNOY3VJ2.js} +1 -4
- package/dist/{chunk-KAA5BGMQ.js.map → chunks/chunk-UNOY3VJ2.js.map} +2 -2
- package/dist/{chunk-3TXNP6HH.js → chunks/chunk-UVDJL6ZZ.js} +97 -58
- package/dist/chunks/chunk-UVDJL6ZZ.js.map +7 -0
- package/dist/chunks/chunk-VNCW4C2Z.js +13452 -0
- package/dist/chunks/chunk-VNCW4C2Z.js.map +7 -0
- package/dist/chunks/chunk-W5EGGA44.js +15 -0
- package/dist/chunks/chunk-W5EGGA44.js.map +7 -0
- package/dist/chunks/chunk-XR2W3MAM.js +1533 -0
- package/dist/chunks/chunk-XR2W3MAM.js.map +7 -0
- package/dist/{chunk-QYFKRZQC.js → chunks/chunk-YIO5EBMQ.js} +423 -377
- package/dist/chunks/chunk-YIO5EBMQ.js.map +7 -0
- package/dist/chunks/chunk-ZBVLKZ5V.js +1062 -0
- package/dist/chunks/chunk-ZBVLKZ5V.js.map +7 -0
- package/dist/{chunk-E6YNABER.js → chunks/chunk-ZCLTZIVP.js} +1 -4
- package/dist/chunks/chunk-ZCLTZIVP.js.map +7 -0
- package/dist/chunks/client-SILZNM5N.js +42 -0
- package/dist/{config-6ZMBCL23.js → chunks/config-25HRTPSP.js} +48 -10
- package/dist/chunks/cost-tracker-Z2UZT2J5.js +28 -0
- package/dist/{customCommands-DNEJS3ZU.js → chunks/customCommands-TYMYZRG5.js} +11 -8
- package/dist/chunks/engine-MRVF6FK6.js +39 -0
- package/dist/{env-OFAXZ3XG.js → chunks/env-TJ5NOBEB.js} +7 -5
- package/dist/{kodeAgentSessionId-X6XWQW7B.js → chunks/kodeAgentSessionId-VTNISJ2L.js} +2 -4
- package/dist/chunks/kodeAgentSessionLoad-YB2RKBGJ.js +15 -0
- package/dist/chunks/kodeAgentSessionResume-DZSIVKVA.js +13 -0
- package/dist/chunks/kodeAgentStreamJson-X5PLS2S6.js +11 -0
- package/dist/{kodeAgentStreamJsonSession-GRWG3SPE.js → chunks/kodeAgentStreamJsonSession-RDXM4XYF.js} +38 -24
- package/dist/chunks/kodeAgentStreamJsonSession-RDXM4XYF.js.map +7 -0
- package/dist/{chunk-4RTX4AG4.js → chunks/kodeAgentStructuredStdio-SVGDSB4P.js} +14 -9
- package/dist/chunks/kodeAgentStructuredStdio-SVGDSB4P.js.map +7 -0
- package/dist/{kodeHooks-TDMXFWSO.js → chunks/kodeHooks-RVKYRJHG.js} +11 -9
- package/dist/{llm-XVXWYOHK.js → chunks/llm-62N6T5ZT.js} +1734 -1526
- package/dist/chunks/llm-62N6T5ZT.js.map +7 -0
- package/dist/chunks/llmLazy-ZUSSE3ZA.js +13 -0
- package/dist/{mentionProcessor-YD7YXYGF.js → chunks/mentionProcessor-RJW5UPJD.js} +46 -16
- package/dist/chunks/mentionProcessor-RJW5UPJD.js.map +7 -0
- package/dist/{messages-OFUJSPRV.js → chunks/messages-EEWWLPHN.js} +2 -6
- package/dist/chunks/model-5TIEKQPD.js +37 -0
- package/dist/{openai-5G5D5Q4B.js → chunks/openai-XXK3YZG4.js} +13 -10
- package/dist/{outputStyles-HLDXFQK3.js → chunks/outputStyles-FAJTXN2A.js} +6 -9
- package/dist/chunks/permissions-HO7INPWM.js +27 -0
- package/dist/{pluginRuntime-FPTKK6NY.js → chunks/pluginRuntime-C7K5ULK2.js} +31 -48
- package/dist/chunks/pluginRuntime-C7K5ULK2.js.map +7 -0
- package/dist/chunks/pluginValidation-DAM7WRTC.js +20 -0
- package/dist/chunks/registry-XYJXMOA5.js +60 -0
- package/dist/chunks/responsesStreaming-JNGE2P3D.js +8 -0
- package/dist/chunks/runNonTextPrintMode-SVBLCZQX.js +577 -0
- package/dist/chunks/runNonTextPrintMode-SVBLCZQX.js.map +7 -0
- package/dist/chunks/server-REXXF5IK.js +46 -0
- package/dist/{skillMarketplace-PSNKDINM.js → chunks/skillMarketplace-N4HVHNST.js} +8 -6
- package/dist/chunks/src-OROQIWP3.js +44 -0
- package/dist/chunks/src-QXLGGMUW.js +1647 -0
- package/dist/chunks/src-QXLGGMUW.js.map +7 -0
- package/dist/{cli-SRV2INSL.js → chunks/src-SSDT6MVP.js} +2659 -3384
- package/dist/chunks/src-SSDT6MVP.js.map +7 -0
- package/dist/chunks/theme-YBJUIMWK.js +10 -0
- package/dist/{toolPermissionContext-65L65VEZ.js → chunks/toolPermissionContext-MOCTRR7N.js} +2 -4
- package/dist/chunks/toolPermissionSettings-EV2EJAXL.js +18 -0
- package/dist/chunks/toolPermissionSettings-EV2EJAXL.js.map +7 -0
- package/dist/chunks/uuid-6577SO6X.js +7 -0
- package/dist/chunks/uuid-6577SO6X.js.map +7 -0
- package/dist/chunks/webOnlyMode-ALXX7UQY.js +66 -0
- package/dist/chunks/webOnlyMode-ALXX7UQY.js.map +7 -0
- package/dist/entrypoints/cli.js +10 -0
- package/dist/entrypoints/cli.js.map +7 -0
- package/dist/entrypoints/daemon.js +10 -0
- package/dist/entrypoints/daemon.js.map +7 -0
- package/dist/entrypoints/mcp.js +71 -0
- package/dist/entrypoints/mcp.js.map +7 -0
- package/dist/index.js +6 -7
- package/dist/index.js.map +3 -3
- package/dist/sdk/client.cjs +391 -0
- package/dist/sdk/client.cjs.map +7 -0
- package/dist/sdk/client.js +364 -0
- package/dist/sdk/client.js.map +7 -0
- package/dist/sdk/core.cjs +19932 -0
- package/dist/sdk/core.cjs.map +7 -0
- package/dist/sdk/core.js +19893 -0
- package/dist/sdk/core.js.map +7 -0
- package/dist/sdk/daemon-client.cjs +257 -0
- package/dist/sdk/daemon-client.cjs.map +7 -0
- package/dist/sdk/daemon-client.js +221 -0
- package/dist/sdk/daemon-client.js.map +7 -0
- package/dist/sdk/protocol.cjs +170 -0
- package/dist/sdk/protocol.cjs.map +7 -0
- package/dist/sdk/protocol.js +140 -0
- package/dist/sdk/protocol.js.map +7 -0
- package/dist/sdk/runtime-node.cjs +236 -0
- package/dist/sdk/runtime-node.cjs.map +7 -0
- package/dist/sdk/runtime-node.js +222 -0
- package/dist/sdk/runtime-node.js.map +7 -0
- package/dist/sdk/runtime.cjs +17 -0
- package/dist/sdk/runtime.cjs.map +7 -0
- package/dist/sdk/runtime.js +0 -0
- package/dist/sdk/runtime.js.map +7 -0
- package/dist/sdk/tools.cjs +30300 -0
- package/dist/sdk/tools.cjs.map +7 -0
- package/dist/sdk/tools.js +30282 -0
- package/dist/sdk/tools.js.map +7 -0
- package/dist/webui/assets/index-5hlfByVS.css +1 -0
- package/dist/webui/assets/index-BR9lm1lA.js +82 -0
- package/dist/webui/index.html +28 -0
- package/package.json +93 -22
- package/scripts/binary-utils.cjs +12 -4
- package/scripts/cli-acp-wrapper.cjs +3 -17
- package/scripts/cli-wrapper.cjs +5 -7
- package/scripts/postinstall.js +8 -4
- package/dist/REPL-GIU4ZIXM.js +0 -42
- package/dist/acp-H3VJ77YG.js +0 -1357
- package/dist/acp-H3VJ77YG.js.map +0 -7
- package/dist/agentsValidate-XP3CFN6F.js.map +0 -7
- package/dist/ask-3G5H5KD5.js.map +0 -7
- package/dist/autoUpdater-DNRMJWFQ.js +0 -17
- package/dist/chunk-2KWKUXLT.js.map +0 -7
- package/dist/chunk-2PMO2FS2.js.map +0 -7
- package/dist/chunk-3TXNP6HH.js.map +0 -7
- package/dist/chunk-4GAIJGRH.js.map +0 -7
- package/dist/chunk-4RTX4AG4.js.map +0 -7
- package/dist/chunk-54DNHKOD.js.map +0 -7
- package/dist/chunk-67PY5IX6.js +0 -34
- package/dist/chunk-67PY5IX6.js.map +0 -7
- package/dist/chunk-6DRDLOLP.js +0 -2613
- package/dist/chunk-6DRDLOLP.js.map +0 -7
- package/dist/chunk-7CQVZNQV.js +0 -1609
- package/dist/chunk-7CQVZNQV.js.map +0 -7
- package/dist/chunk-ABLVTESJ.js.map +0 -7
- package/dist/chunk-AIMIPK4B.js +0 -835
- package/dist/chunk-AIMIPK4B.js.map +0 -7
- package/dist/chunk-BHGTA6JQ.js.map +0 -7
- package/dist/chunk-CIG63V4E.js +0 -72
- package/dist/chunk-CIG63V4E.js.map +0 -7
- package/dist/chunk-E6YNABER.js.map +0 -7
- package/dist/chunk-EH34V7CY.js.map +0 -7
- package/dist/chunk-EZXMVTDU.js.map +0 -7
- package/dist/chunk-FH5CHM6L.js +0 -148
- package/dist/chunk-FH5CHM6L.js.map +0 -7
- package/dist/chunk-G6I7XROM.js.map +0 -7
- package/dist/chunk-HN4E4UUQ.js.map +0 -7
- package/dist/chunk-HSPVVDIW.js +0 -30198
- package/dist/chunk-HSPVVDIW.js.map +0 -7
- package/dist/chunk-IE2CG2TV.js.map +0 -7
- package/dist/chunk-K2MI4TPB.js.map +0 -7
- package/dist/chunk-MN77D2F7.js +0 -2931
- package/dist/chunk-MN77D2F7.js.map +0 -7
- package/dist/chunk-NQLEUHMS.js.map +0 -7
- package/dist/chunk-OIFQB3S4.js +0 -515
- package/dist/chunk-OIFQB3S4.js.map +0 -7
- package/dist/chunk-OWTG2W3A.js +0 -164
- package/dist/chunk-OWTG2W3A.js.map +0 -7
- package/dist/chunk-OZNRLY3E.js.map +0 -7
- package/dist/chunk-QYFKRZQC.js.map +0 -7
- package/dist/chunk-S6HRABTA.js.map +0 -7
- package/dist/chunk-SDGKPKDK.js.map +0 -7
- package/dist/chunk-SRZZFAS7.js.map +0 -7
- package/dist/chunk-UKHTVRJM.js +0 -47
- package/dist/chunk-UKHTVRJM.js.map +0 -7
- package/dist/chunk-UYXEDKOZ.js +0 -24
- package/dist/chunk-UYXEDKOZ.js.map +0 -7
- package/dist/chunk-VBXVYQYY.js +0 -145
- package/dist/chunk-VBXVYQYY.js.map +0 -7
- package/dist/chunk-WVHORZQ5.js +0 -17
- package/dist/chunk-WVHORZQ5.js.map +0 -7
- package/dist/chunk-WWUWDNWW.js +0 -49
- package/dist/chunk-WWUWDNWW.js.map +0 -7
- package/dist/chunk-Z33T5YN5.js +0 -654
- package/dist/chunk-Z33T5YN5.js.map +0 -7
- package/dist/chunk-ZQU3TXLC.js.map +0 -7
- package/dist/cli-SRV2INSL.js.map +0 -7
- package/dist/commands-TWH6PGVG.js +0 -46
- package/dist/context-JQIOOI4W.js +0 -30
- package/dist/costTracker-6SL26FDB.js +0 -19
- package/dist/kodeAgentSessionLoad-6N27AC5K.js +0 -18
- package/dist/kodeAgentSessionResume-HUSAEO24.js +0 -16
- package/dist/kodeAgentStreamJson-NXFN7TXH.js +0 -13
- package/dist/kodeAgentStreamJsonSession-GRWG3SPE.js.map +0 -7
- package/dist/kodeAgentStructuredStdio-HGWJT7CU.js +0 -10
- package/dist/llm-XVXWYOHK.js.map +0 -7
- package/dist/llmLazy-7TD5N7XP.js +0 -15
- package/dist/loader-AUXIJTY6.js +0 -28
- package/dist/mcp-BXJ3K7NZ.js +0 -49
- package/dist/mentionProcessor-YD7YXYGF.js.map +0 -7
- package/dist/model-KPYCXWBK.js +0 -30
- package/dist/pluginRuntime-FPTKK6NY.js.map +0 -7
- package/dist/pluginValidation-DSFXZ4GF.js +0 -17
- package/dist/prompts-LWLAJRS2.js +0 -48
- package/dist/query-HVPWL27C.js +0 -50
- package/dist/responsesStreaming-AW344PQO.js +0 -10
- package/dist/ripgrep-YOPCY2GO.js +0 -17
- package/dist/state-KNRWP3FO.js +0 -16
- package/dist/theme-7S2QN2FO.js +0 -14
- package/dist/toolPermissionSettings-GPOBH4IV.js +0 -18
- package/dist/tools-FZU2FZBD.js +0 -47
- package/dist/userInput-VHNBN2MW.js +0 -311
- package/dist/userInput-VHNBN2MW.js.map +0 -7
- package/dist/uuid-QN2CNKKN.js +0 -9
- /package/dist/{REPL-GIU4ZIXM.js.map → chunks/Doctor-M3J7GRTJ.js.map} +0 -0
- /package/dist/{autoUpdater-DNRMJWFQ.js.map → chunks/REPL-RQ6LO6S7.js.map} +0 -0
- /package/dist/{chunk-JC6NCUG5.js.map → chunks/ResumeConversation-6DMVBEGH.js.map} +0 -0
- /package/dist/{commands-TWH6PGVG.js.map → chunks/agentLoader-FCRG3TFJ.js.map} +0 -0
- /package/dist/{config-6ZMBCL23.js.map → chunks/autoUpdater-CNESBOKO.js.map} +0 -0
- /package/dist/{context-JQIOOI4W.js.map → chunks/chunk-4CRUCZR4.js.map} +0 -0
- /package/dist/{costTracker-6SL26FDB.js.map → chunks/chunk-54KOYG5C.js.map} +0 -0
- /package/dist/{customCommands-DNEJS3ZU.js.map → chunks/chunk-GCQCAXJZ.js.map} +0 -0
- /package/dist/{env-OFAXZ3XG.js.map → chunks/chunk-LB6TCPDI.js.map} +0 -0
- /package/dist/{kodeAgentSessionId-X6XWQW7B.js.map → chunks/client-SILZNM5N.js.map} +0 -0
- /package/dist/{kodeAgentSessionLoad-6N27AC5K.js.map → chunks/config-25HRTPSP.js.map} +0 -0
- /package/dist/{kodeAgentSessionResume-HUSAEO24.js.map → chunks/cost-tracker-Z2UZT2J5.js.map} +0 -0
- /package/dist/{kodeAgentStreamJson-NXFN7TXH.js.map → chunks/customCommands-TYMYZRG5.js.map} +0 -0
- /package/dist/{kodeAgentStructuredStdio-HGWJT7CU.js.map → chunks/engine-MRVF6FK6.js.map} +0 -0
- /package/dist/{kodeHooks-TDMXFWSO.js.map → chunks/env-TJ5NOBEB.js.map} +0 -0
- /package/dist/{llmLazy-7TD5N7XP.js.map → chunks/kodeAgentSessionId-VTNISJ2L.js.map} +0 -0
- /package/dist/{loader-AUXIJTY6.js.map → chunks/kodeAgentSessionLoad-YB2RKBGJ.js.map} +0 -0
- /package/dist/{mcp-BXJ3K7NZ.js.map → chunks/kodeAgentSessionResume-DZSIVKVA.js.map} +0 -0
- /package/dist/{messages-OFUJSPRV.js.map → chunks/kodeAgentStreamJson-X5PLS2S6.js.map} +0 -0
- /package/dist/{model-KPYCXWBK.js.map → chunks/kodeHooks-RVKYRJHG.js.map} +0 -0
- /package/dist/{openai-5G5D5Q4B.js.map → chunks/llmLazy-ZUSSE3ZA.js.map} +0 -0
- /package/dist/{outputStyles-HLDXFQK3.js.map → chunks/messages-EEWWLPHN.js.map} +0 -0
- /package/dist/{pluginValidation-DSFXZ4GF.js.map → chunks/model-5TIEKQPD.js.map} +0 -0
- /package/dist/{prompts-LWLAJRS2.js.map → chunks/openai-XXK3YZG4.js.map} +0 -0
- /package/dist/{query-HVPWL27C.js.map → chunks/outputStyles-FAJTXN2A.js.map} +0 -0
- /package/dist/{responsesStreaming-AW344PQO.js.map → chunks/permissions-HO7INPWM.js.map} +0 -0
- /package/dist/{ripgrep-YOPCY2GO.js.map → chunks/pluginValidation-DAM7WRTC.js.map} +0 -0
- /package/dist/{skillMarketplace-PSNKDINM.js.map → chunks/registry-XYJXMOA5.js.map} +0 -0
- /package/dist/{state-KNRWP3FO.js.map → chunks/responsesStreaming-JNGE2P3D.js.map} +0 -0
- /package/dist/{theme-7S2QN2FO.js.map → chunks/server-REXXF5IK.js.map} +0 -0
- /package/dist/{toolPermissionContext-65L65VEZ.js.map → chunks/skillMarketplace-N4HVHNST.js.map} +0 -0
- /package/dist/{toolPermissionSettings-GPOBH4IV.js.map → chunks/src-OROQIWP3.js.map} +0 -0
- /package/dist/{tools-FZU2FZBD.js.map → chunks/theme-YBJUIMWK.js.map} +0 -0
- /package/dist/{uuid-QN2CNKKN.js.map → chunks/toolPermissionContext-MOCTRR7N.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../apps/cli/src/services/outputStyles.ts", "../../apps/cli/src/services/outputStyles/filesystem.ts"],
|
|
4
|
+
"sourcesContent": ["import figures from 'figures'\nimport { memoize } from 'lodash-es'\nimport { statSync } from 'node:fs'\nimport { basename, join } from 'path'\nimport { getSessionPlugins } from '#core/utils/sessionPlugins'\nimport { readLocalSettings, updateLocalSettings } from '#config'\nimport { getCwd } from '#core/utils/state'\nimport { isSettingSourceEnabled } from '#config'\nimport {\n findProjectSubdirs,\n getClaudePolicyBaseDir,\n getUserConfigBaseDirs,\n inodeKeyForPath,\n listMarkdownFilesRecursively,\n markdownFirstLineOrHeading,\n normalizeString,\n readMarkdownFile,\n} from './outputStyles/filesystem'\n\nexport type OutputStyleSource =\n | 'built-in'\n | 'plugin'\n | 'userSettings'\n | 'projectSettings'\n | 'policySettings'\n\nexport type OutputStyleDefinition = {\n name: string\n description: string\n prompt: string\n source: OutputStyleSource\n keepCodingInstructions?: boolean\n}\n\nexport type OutputStyleMap = Record<string, OutputStyleDefinition | null>\n\nexport const DEFAULT_OUTPUT_STYLE = 'default'\n\nconst INSIGHTS_SECTION = `\n## Insights\nIn order to encourage learning, before and after writing code, always provide brief educational explanations about implementation choices using (with backticks):\n\"\\`${figures.star} Insight \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\`\n[2-3 key educational points]\n\\`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\`\"\n\nThese insights should be included in the conversation, not in the codebase. You should generally focus on interesting insights that are specific to the codebase or the code you just wrote, rather than general programming concepts.`\n\nfunction getBuiltInOutputStyles(): OutputStyleMap {\n return {\n [DEFAULT_OUTPUT_STYLE]: null,\n Explanatory: {\n name: 'Explanatory',\n source: 'built-in',\n description:\n 'Claude explains its implementation choices and codebase patterns',\n keepCodingInstructions: true,\n prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should provide educational insights about the codebase along the way.\n\nYou should be clear and educational, providing helpful explanations while remaining focused on the task. Balance educational content with task completion. When providing insights, you may exceed typical length constraints, but remain focused and relevant.\n\n# Explanatory Style Active\n${INSIGHTS_SECTION}`,\n },\n Learning: {\n name: 'Learning',\n source: 'built-in',\n description:\n 'Claude pauses and asks you to write small pieces of code for hands-on practice',\n keepCodingInstructions: true,\n prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should help users learn more about the codebase through hands-on practice and educational insights.\n\nYou should be collaborative and encouraging. Balance task completion with learning by requesting user input for meaningful design decisions while handling routine implementation yourself. \n\n# Learning Style Active\n## Requesting Human Contributions\nIn order to encourage learning, ask the human to contribute 2-10 line code pieces when generating 20+ lines involving:\n- Design decisions (error handling, data structures)\n- Business logic with multiple valid approaches \n- Key algorithms or interface definitions\n\n**TodoList Integration**: If using a TodoList for the overall task, include a specific todo item like \"Request human input on [specific decision]\" when planning to request human input. This ensures proper task tracking. Note: TodoList is not required for all tasks.\n\nExample TodoList flow:\n \u2713 \"Set up component structure with placeholder for logic\"\n \u2713 \"Request human collaboration on decision logic implementation\"\n \u2713 \"Integrate contribution and complete feature\"\n\n### Request Format\n\\`\\`\\`\n${figures.bullet} **Learn by Doing**\n**Context:** [what's built and why this decision matters]\n**Your Task:** [specific function/section in file, mention file and TODO(human) but do not include line numbers]\n**Guidance:** [trade-offs and constraints to consider]\n\\`\\`\\`\n\n### Key Guidelines\n- Frame contributions as valuable design decisions, not busy work\n- You must first add a TODO(human) section into the codebase with your editing tools before making the Learn by Doing request \n- Make sure there is one and only one TODO(human) section in the code\n- Don't take any action or output anything after the Learn by Doing request. Wait for human implementation before proceeding.\n\n### Example Requests\n\n**Whole Function Example:**\n\\`\\`\\`\n${figures.bullet} **Learn by Doing**\n\n**Context:** I've set up the hint feature UI with a button that triggers the hint system. The infrastructure is ready: when clicked, it calls selectHintCell() to determine which cell to hint, then highlights that cell with a yellow background and shows possible values. The hint system needs to decide which empty cell would be most helpful to reveal to the user.\n\n**Your Task:** In sudoku.js, implement the selectHintCell(board) function. Look for TODO(human). This function should analyze the board and return {row, col} for the best cell to hint, or null if the puzzle is complete.\n\n**Guidance:** Consider multiple strategies: prioritize cells with only one possible value (naked singles), or cells that appear in rows/columns/boxes with many filled cells. You could also consider a balanced approach that helps without making it too easy. The board parameter is a 9x9 array where 0 represents empty cells.\n\\`\\`\\`\n\n**Partial Function Example:**\n\\`\\`\\`\n${figures.bullet} **Learn by Doing**\n\n**Context:** I've built a file upload component that validates files before accepting them. The main validation logic is complete, but it needs specific handling for different file type categories in the switch statement.\n\n**Your Task:** In upload.js, inside the validateFile() function's switch statement, implement the 'case \"document\":' branch. Look for TODO(human). This should validate document files (pdf, doc, docx).\n\n**Guidance:** Consider checking file size limits (maybe 10MB for documents?), validating the file extension matches the MIME type, and returning {valid: boolean, error?: string}. The file object has properties: name, size, type.\n\\`\\`\\`\n\n**Debugging Example:**\n\\`\\`\\`\n${figures.bullet} **Learn by Doing**\n\n**Context:** The user reported that number inputs aren't working correctly in the calculator. I've identified the handleInput() function as the likely source, but need to understand what values are being processed.\n\n**Your Task:** In calculator.js, inside the handleInput() function, add 2-3 console.log statements after the TODO(human) comment to help debug why number inputs fail.\n\n**Guidance:** Consider logging: the raw input value, the parsed result, and any validation state. This will help us understand where the conversion breaks.\n\\`\\`\\`\n\n### After Contributions\nShare one insight connecting their code to broader patterns or system effects. Avoid praise or repetition.\n\n## Insights\n${INSIGHTS_SECTION}`,\n },\n }\n}\n\nfunction parseKeepCodingInstructions(value: unknown): boolean | undefined {\n if (value === 'true') return true\n if (value === 'false') return false\n return undefined\n}\n\nfunction parseCustomOutputStyleFile(options: {\n filePath: string\n source: Exclude<OutputStyleSource, 'built-in' | 'plugin'>\n}): OutputStyleDefinition | null {\n const parsed = readMarkdownFile(options.filePath)\n if (!parsed) return null\n\n const base = basename(options.filePath, '.md')\n const name = normalizeString(parsed.frontmatter?.name) ?? base\n const description =\n normalizeString(parsed.frontmatter?.description) ??\n markdownFirstLineOrHeading(parsed.content, `Custom ${base} output style`)\n const keepCodingInstructions = parseKeepCodingInstructions(\n parsed.frontmatter?.['keep-coding-instructions'],\n )\n const prompt = parsed.content.trim()\n\n return {\n name,\n description,\n prompt,\n source: options.source,\n ...(keepCodingInstructions !== undefined ? { keepCodingInstructions } : {}),\n }\n}\n\nfunction parsePluginOutputStyleFile(options: {\n filePath: string\n pluginName: string\n seen: Set<string>\n}): OutputStyleDefinition | null {\n const inodeKey = inodeKeyForPath(options.filePath)\n const dedupeKey = inodeKey ? `inode:${inodeKey}` : `path:${options.filePath}`\n if (options.seen.has(dedupeKey)) return null\n options.seen.add(dedupeKey)\n\n const parsed = readMarkdownFile(options.filePath)\n if (!parsed) return null\n\n const base = basename(options.filePath, '.md')\n const styleName = normalizeString(parsed.frontmatter?.name) ?? base\n const fullName = `${options.pluginName}:${styleName}`\n const description =\n normalizeString(parsed.frontmatter?.description) ??\n markdownFirstLineOrHeading(\n parsed.content,\n `Output style from ${options.pluginName} plugin`,\n )\n const prompt = parsed.content.trim()\n\n return {\n name: fullName,\n description,\n prompt,\n source: 'plugin',\n }\n}\n\nfunction loadPluginOutputStyles(): OutputStyleDefinition[] {\n const out: OutputStyleDefinition[] = []\n const plugins = getSessionPlugins()\n for (const plugin of plugins) {\n const pluginName = plugin.name\n const seen = new Set<string>()\n for (const dir of plugin.outputStylesDirs ?? []) {\n let st: ReturnType<typeof statSync>\n try {\n st = statSync(dir)\n } catch {\n continue\n }\n if (st.isFile()) {\n if (!dir.endsWith('.md')) continue\n const style = parsePluginOutputStyleFile({\n filePath: dir,\n pluginName,\n seen,\n })\n if (style) out.push(style)\n continue\n }\n\n if (st.isDirectory()) {\n const files = listMarkdownFilesRecursively(dir)\n for (const filePath of files) {\n const style = parsePluginOutputStyleFile({\n filePath,\n pluginName,\n seen,\n })\n if (style) out.push(style)\n }\n }\n }\n }\n return out\n}\n\nfunction loadCustomOutputStyles(options: {\n cwd: string\n}): OutputStyleDefinition[] {\n const out: OutputStyleDefinition[] = []\n const seen = new Set<string>()\n\n const policyDir = join(getClaudePolicyBaseDir(), '.claude', 'output-styles')\n for (const filePath of listMarkdownFilesRecursively(policyDir)) {\n const inodeKey = inodeKeyForPath(filePath)\n const dedupeKey = inodeKey ? `inode:${inodeKey}` : `path:${filePath}`\n if (seen.has(dedupeKey)) continue\n seen.add(dedupeKey)\n const style = parseCustomOutputStyleFile({\n filePath,\n source: 'policySettings',\n })\n if (style) out.push(style)\n }\n\n if (isSettingSourceEnabled('userSettings')) {\n const userBases = getUserConfigBaseDirs()\n for (const base of userBases) {\n for (const userBaseDir of new Set([base.claude, base.kode])) {\n const dirPath = join(userBaseDir, 'output-styles')\n for (const filePath of listMarkdownFilesRecursively(dirPath)) {\n const inodeKey = inodeKeyForPath(filePath)\n const dedupeKey = inodeKey ? `inode:${inodeKey}` : `path:${filePath}`\n if (seen.has(dedupeKey)) continue\n seen.add(dedupeKey)\n const style = parseCustomOutputStyleFile({\n filePath,\n source: 'userSettings',\n })\n if (style) out.push(style)\n }\n }\n }\n }\n\n if (isSettingSourceEnabled('projectSettings')) {\n for (const dirPath of findProjectSubdirs('output-styles', options.cwd)) {\n for (const filePath of listMarkdownFilesRecursively(dirPath)) {\n const inodeKey = inodeKeyForPath(filePath)\n const dedupeKey = inodeKey ? `inode:${inodeKey}` : `path:${filePath}`\n if (seen.has(dedupeKey)) continue\n seen.add(dedupeKey)\n const style = parseCustomOutputStyleFile({\n filePath,\n source: 'projectSettings',\n })\n if (style) out.push(style)\n }\n }\n }\n\n return out\n}\n\nexport const getAvailableOutputStyles = memoize((): OutputStyleMap => {\n const cwd = getCwd()\n const builtIn = getBuiltInOutputStyles()\n const merged: OutputStyleMap = { ...builtIn }\n\n for (const style of loadPluginOutputStyles()) {\n merged[style.name] = style\n }\n\n const custom = loadCustomOutputStyles({ cwd })\n const user = custom.filter(s => s.source === 'userSettings')\n const project = custom.filter(s => s.source === 'projectSettings')\n const policy = custom.filter(s => s.source === 'policySettings')\n\n for (const style of user) merged[style.name] = style\n for (const style of project) merged[style.name] = style\n for (const style of policy) merged[style.name] = style\n\n return merged\n})\n\nexport function clearOutputStyleCache(): void {\n getAvailableOutputStyles.cache.clear?.()\n}\n\nexport function getCurrentOutputStyle(): string {\n if (!isSettingSourceEnabled('localSettings')) return DEFAULT_OUTPUT_STYLE\n\n const settings = readLocalSettings()\n const candidate = normalizeString(settings.outputStyle)\n return candidate ?? DEFAULT_OUTPUT_STYLE\n}\n\nexport function setCurrentOutputStyle(styleName: string): void {\n updateLocalSettings({ outputStyle: styleName })\n}\n\nexport function resolveOutputStyleName(input: string): string | null {\n const raw = normalizeString(input)\n if (!raw) return null\n const styles = getAvailableOutputStyles()\n if (raw in styles) return raw\n const lower = raw.toLowerCase()\n for (const name of Object.keys(styles)) {\n if (name.toLowerCase() === lower) return name\n }\n return null\n}\n\nexport function getCurrentOutputStyleDefinition(): OutputStyleDefinition | null {\n const current = getCurrentOutputStyle()\n const styles = getAvailableOutputStyles()\n return styles[current] ?? null\n}\n\nexport function getOutputStyleSystemPromptAdditions(): string[] {\n const style = getCurrentOutputStyleDefinition()\n if (!style) return []\n const prompt = style.prompt.trim()\n if (!prompt) return []\n return [`\\n# Output Style: ${style.name}\\n${prompt}\\n`]\n}\n", "import { existsSync, readdirSync, readFileSync, statSync } from 'fs'\nimport type { Dirent } from 'fs'\nimport { dirname, join, resolve } from 'path'\nimport { homedir } from 'os'\nimport matter from 'gray-matter'\n\nexport function normalizeString(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const trimmed = value.trim()\n return trimmed ? trimmed : null\n}\n\nexport function getClaudePolicyBaseDir(): string {\n switch (process.platform) {\n case 'darwin':\n return '/Library/Application Support/ClaudeCode'\n case 'win32':\n return existsSync('C:\\\\Program Files\\\\ClaudeCode')\n ? 'C:\\\\Program Files\\\\ClaudeCode'\n : 'C:\\\\ProgramData\\\\ClaudeCode'\n default:\n return '/etc/claude-code'\n }\n}\n\nexport function getUserConfigBaseDirs(): { claude: string; kode: string }[] {\n const out: { claude: string; kode: string }[] = []\n\n const hasAnyOverride =\n typeof process.env.CLAUDE_CONFIG_DIR === 'string' ||\n typeof process.env.KODE_CONFIG_DIR === 'string'\n\n const claudeBase = normalizeString(process.env.CLAUDE_CONFIG_DIR)\n const kodeBase = normalizeString(process.env.KODE_CONFIG_DIR)\n\n if (claudeBase)\n out.push({ claude: resolve(claudeBase), kode: resolve(claudeBase) })\n if (kodeBase) out.push({ claude: resolve(kodeBase), kode: resolve(kodeBase) })\n\n if (hasAnyOverride) {\n // Respect test/host overrides: do not read from real home dirs when an override is set.\n return dedupeConfigBases(out)\n }\n\n return dedupeConfigBases([\n { claude: join(homedir(), '.claude'), kode: join(homedir(), '.claude') },\n { claude: join(homedir(), '.kode'), kode: join(homedir(), '.kode') },\n ])\n}\n\nfunction dedupeConfigBases(\n bases: Array<{ claude: string; kode: string }>,\n): Array<{ claude: string; kode: string }> {\n const seen = new Set<string>()\n const out: Array<{ claude: string; kode: string }> = []\n for (const base of bases) {\n const key = `${base.claude}::${base.kode}`\n if (seen.has(key)) continue\n seen.add(key)\n out.push(base)\n }\n return out\n}\n\nexport function findProjectSubdirs(subdir: string, cwd: string): string[] {\n const result: string[] = []\n const home = resolve(homedir())\n let current = resolve(cwd)\n\n while (current !== home) {\n const claudeDir = join(current, '.claude', subdir)\n if (existsSync(claudeDir)) result.push(claudeDir)\n\n const kodeDir = join(current, '.kode', subdir)\n if (existsSync(kodeDir)) result.push(kodeDir)\n\n const parent = dirname(current)\n if (parent === current) break\n current = parent\n }\n\n return result\n}\n\nexport function markdownFirstLineOrHeading(\n content: string,\n fallback: string,\n): string {\n const lines = content.split('\\n')\n for (const line of lines) {\n const trimmed = line.trim()\n if (!trimmed) continue\n const heading = trimmed.match(/^#+\\s+(.+)$/)?.[1] ?? trimmed\n return heading.length > 100 ? `${heading.substring(0, 97)}...` : heading\n }\n return fallback\n}\n\nexport function listMarkdownFilesRecursively(rootDir: string): string[] {\n const files: string[] = []\n const visitedDirs = new Set<string>()\n\n const walk = (dirPath: string) => {\n let dirStat: ReturnType<typeof statSync>\n try {\n dirStat = statSync(dirPath)\n } catch {\n return\n }\n if (!dirStat.isDirectory()) return\n\n const dirKey = `${dirStat.dev}:${dirStat.ino}`\n if (visitedDirs.has(dirKey)) return\n visitedDirs.add(dirKey)\n\n let entries: Dirent[]\n try {\n entries = readdirSync(dirPath, { withFileTypes: true })\n } catch {\n return\n }\n\n for (const entry of entries) {\n const name = String(entry.name ?? '')\n const fullPath = join(dirPath, name)\n\n if (entry.isDirectory()) {\n walk(fullPath)\n continue\n }\n\n if (entry.isFile()) {\n if (name.endsWith('.md')) files.push(fullPath)\n continue\n }\n\n if (entry.isSymbolicLink()) {\n try {\n const st = statSync(fullPath)\n if (st.isDirectory()) {\n walk(fullPath)\n } else if (st.isFile() && name.endsWith('.md')) {\n files.push(fullPath)\n }\n } catch {\n continue\n }\n }\n }\n }\n\n if (!existsSync(rootDir)) return []\n walk(rootDir)\n return files\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return {}\n return value as Record<string, unknown>\n}\n\nexport function readMarkdownFile(\n filePath: string,\n): { frontmatter: Record<string, unknown>; content: string } | null {\n try {\n const raw = readFileSync(filePath, 'utf8')\n const parsed = matter(raw)\n return {\n frontmatter: asRecord(parsed.data),\n content: String(parsed.content ?? ''),\n }\n } catch {\n return null\n }\n}\n\nexport function inodeKeyForPath(filePath: string): string | null {\n try {\n const st = statSync(filePath)\n return `${st.dev}:${st.ino}`\n } catch {\n return null\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAAA,OAAO,aAAa;AACpB,SAAS,eAAe;AACxB,SAAS,YAAAA,iBAAgB;AACzB,SAAS,UAAU,QAAAC,aAAY;;;ACH/B,SAAS,YAAY,aAAa,cAAc,gBAAgB;AAEhE,SAAS,SAAS,MAAM,eAAe;AACvC,SAAS,eAAe;AACxB,OAAO,YAAY;AAEZ,SAAS,gBAAgB,OAA+B;AAC7D,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,SAAO,UAAU,UAAU;AAC7B;AAEO,SAAS,yBAAiC;AAC/C,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AACH,aAAO;AAAA,IACT,KAAK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gC;AAC9C,MAAI,CAAC,uBAAuB,eAAe,EAAG,QAAO;AAErD,QAAM,WAAW,kBAAkB;AACnC,QAAM,YAAY,gBAAgB,SAAS,WAAW;AACtD,SAAO,aAAa;AACtB;AAEO,SAAS,sBAAsB,WAAyB;AAC7D,sBAAoB,EAAE,aAAa,UAAU,CAAC;AAChD;AAEO,SAAS,uBAAuB,OAA8B;AACnE,QAAM,MAAM,gBAAgB,KAAK;AACjC,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,SAAS,yBAAyB;AACxC,MAAI,OAAO,OAAQ,QAAO;AAC1B,QAAM,QAAQ,IAAI,YAAY;AAC9B,aAAW,QAAQ,OAAO,KAAK,MAAM,GAAG;AACtC,QAAI,KAAK,YAAY,MAAM,MAAO,QAAO;AAAA,EAC3C;AACA,SAAO;AACT;AAEO,SAAS,kCAAgE;AAC9E,QAAM,UAAU,sBAAsB;AACtC,QAAM,SAAS,yBAAyB;AACxC,SAAO,OAAO,OAAO,KAAK;AAC5B;AAEO,SAAS,sCAAgD;AAC9D,QAAM,QAAQ,gCAAgC;AAC9C,MAAI,CAAC,MAAO,QAAO,CAAC;AACpB,QAAM,SAAS,MAAM,OAAO,KAAK;AACjC,MAAI,CAAC,OAAQ,QAAO,CAAC;AACrB,SAAO,CAAC;AAAA,kBAAqB,MAAM,IAAI;AAAA,EAAK,MAAM;AAAA,CAAI;AACxD;",
|
|
6
|
+
"names": ["statSync", "join", "statSync", "join"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getModelManager
|
|
3
|
+
} from "./chunk-6ZWEOSEI.js";
|
|
4
|
+
|
|
5
|
+
// packages/core/src/utils/thinking.ts
|
|
6
|
+
import { last } from "lodash-es";
|
|
7
|
+
async function getMaxThinkingTokens(messages) {
|
|
8
|
+
if (process.env.MAX_THINKING_TOKENS) {
|
|
9
|
+
const tokens = parseInt(process.env.MAX_THINKING_TOKENS, 10);
|
|
10
|
+
return tokens;
|
|
11
|
+
}
|
|
12
|
+
if (Boolean(process.env.THINK_TOOL)) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
const lastMessage = last(messages);
|
|
16
|
+
if (lastMessage?.type !== "user" || typeof lastMessage.message.content !== "string") {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
const content = lastMessage.message.content.toLowerCase();
|
|
20
|
+
if (content.includes("think harder") || content.includes("think intensely") || content.includes("think longer") || content.includes("think really hard") || content.includes("think super hard") || content.includes("think very hard") || content.includes("ultrathink")) {
|
|
21
|
+
return 32e3 - 1;
|
|
22
|
+
}
|
|
23
|
+
if (content.includes("think about it") || content.includes("think a lot") || content.includes("think hard") || content.includes("think more") || content.includes("megathink")) {
|
|
24
|
+
return 1e4;
|
|
25
|
+
}
|
|
26
|
+
if (content.includes("think")) {
|
|
27
|
+
return 4e3;
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
async function getReasoningEffort(modelProfile, messages) {
|
|
32
|
+
const thinkingTokens = await getMaxThinkingTokens(messages);
|
|
33
|
+
let reasoningEffort;
|
|
34
|
+
if (modelProfile?.reasoningEffort) {
|
|
35
|
+
const effort2 = modelProfile.reasoningEffort;
|
|
36
|
+
reasoningEffort = effort2 === "high" || effort2 === "medium" || effort2 === "low" ? effort2 : effort2 === "minimal" ? "low" : "medium";
|
|
37
|
+
} else {
|
|
38
|
+
const modelManager = getModelManager();
|
|
39
|
+
const fallbackProfile = modelManager.getModel("main");
|
|
40
|
+
const effort2 = fallbackProfile?.reasoningEffort;
|
|
41
|
+
reasoningEffort = effort2 === "high" || effort2 === "medium" || effort2 === "low" ? effort2 : effort2 === "minimal" ? "low" : "medium";
|
|
42
|
+
}
|
|
43
|
+
const maxEffort = reasoningEffort === "high" ? 2 : reasoningEffort === "medium" ? 1 : reasoningEffort === "low" ? 0 : null;
|
|
44
|
+
if (!maxEffort) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
let effort = 0;
|
|
48
|
+
if (thinkingTokens < 1e4) {
|
|
49
|
+
effort = 0;
|
|
50
|
+
} else if (thinkingTokens >= 1e4 && thinkingTokens < 3e4) {
|
|
51
|
+
effort = 1;
|
|
52
|
+
} else {
|
|
53
|
+
effort = 2;
|
|
54
|
+
}
|
|
55
|
+
if (effort > maxEffort) {
|
|
56
|
+
return maxEffort === 2 ? "high" : maxEffort === 1 ? "medium" : "low";
|
|
57
|
+
}
|
|
58
|
+
return effort === 2 ? "high" : effort === 1 ? "medium" : "low";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
getMaxThinkingTokens,
|
|
63
|
+
getReasoningEffort
|
|
64
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/core/src/utils/thinking.ts"],
|
|
4
|
+
"sourcesContent": ["import { last } from 'lodash-es'\nimport type { Message } from '#core/query'\nimport { getLastAssistantMessageId } from './messages'\nimport { USE_BEDROCK, USE_VERTEX, getModelManager } from './model'\n\nexport async function getMaxThinkingTokens(\n messages: Message[],\n): Promise<number> {\n if (process.env.MAX_THINKING_TOKENS) {\n const tokens = parseInt(process.env.MAX_THINKING_TOKENS, 10)\n return tokens\n }\n\n if (Boolean(process.env.THINK_TOOL)) {\n return 0\n }\n\n const lastMessage = last(messages)\n if (\n lastMessage?.type !== 'user' ||\n typeof lastMessage.message.content !== 'string'\n ) {\n return 0\n }\n\n const content = lastMessage.message.content.toLowerCase()\n if (\n content.includes('think harder') ||\n content.includes('think intensely') ||\n content.includes('think longer') ||\n content.includes('think really hard') ||\n content.includes('think super hard') ||\n content.includes('think very hard') ||\n content.includes('ultrathink')\n ) {\n return 32_000 - 1\n }\n\n if (\n content.includes('think about it') ||\n content.includes('think a lot') ||\n content.includes('think hard') ||\n content.includes('think more') ||\n content.includes('megathink')\n ) {\n return 10_000\n }\n\n if (content.includes('think')) {\n return 4_000\n }\n\n return 0\n}\n\nexport async function getReasoningEffort(\n modelProfile: any,\n messages: Message[],\n): Promise<'low' | 'medium' | 'high' | null> {\n const thinkingTokens = await getMaxThinkingTokens(messages)\n\n // Get reasoning effort from ModelProfile first, then fallback to config\n let reasoningEffort: 'low' | 'medium' | 'high' | undefined\n if (modelProfile?.reasoningEffort) {\n const effort = modelProfile.reasoningEffort\n reasoningEffort =\n effort === 'high' || effort === 'medium' || effort === 'low'\n ? effort\n : effort === 'minimal'\n ? 'low'\n : 'medium'\n } else {\n // \uD83D\uDD27 Fix: Use ModelManager fallback instead of legacy config\n const modelManager = getModelManager()\n const fallbackProfile = modelManager.getModel('main')\n const effort = fallbackProfile?.reasoningEffort\n reasoningEffort =\n effort === 'high' || effort === 'medium' || effort === 'low'\n ? effort\n : effort === 'minimal'\n ? 'low'\n : 'medium'\n }\n\n const maxEffort =\n reasoningEffort === 'high'\n ? 2\n : reasoningEffort === 'medium'\n ? 1\n : reasoningEffort === 'low'\n ? 0\n : null\n if (!maxEffort) {\n return null\n }\n\n let effort = 0\n if (thinkingTokens < 10_000) {\n effort = 0\n } else if (thinkingTokens >= 10_000 && thinkingTokens < 30_000) {\n effort = 1\n } else {\n effort = 2\n }\n\n if (effort > maxEffort) {\n return maxEffort === 2 ? 'high' : maxEffort === 1 ? 'medium' : 'low'\n }\n\n return effort === 2 ? 'high' : effort === 1 ? 'medium' : 'low'\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,SAAS,YAAY;AAKrB,eAAsB,qBACpB,UACiB;AACjB,MAAI,QAAQ,IAAI,qBAAqB;AACnC,UAAM,SAAS,SAAS,QAAQ,IAAI,qBAAqB,EAAE;AAC3D,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,QAAQ,IAAI,UAAU,GAAG;AACnC,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,KAAK,QAAQ;AACjC,MACE,aAAa,SAAS,UACtB,OAAO,YAAY,QAAQ,YAAY,UACvC;AACA,WAAO;AA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,WAAW;AACtB,WAAO,cAAc,IAAI,SAAS,cAAc,IAAI,WAAW;AAAA,EACjE;AAEA,SAAO,WAAW,IAAI,SAAS,WAAW,IAAI,WAAW;AAC3D;",
|
|
6
|
+
"names": ["effort"]
|
|
7
|
+
}
|
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
formatDuration
|
|
3
|
+
} from "./chunk-GELCZWMB.js";
|
|
4
|
+
import {
|
|
5
|
+
SESSION_ID
|
|
6
|
+
} from "./chunk-3OEJVB5A.js";
|
|
7
|
+
import {
|
|
8
|
+
getCurrentProjectConfig,
|
|
9
|
+
saveCurrentProjectConfig
|
|
10
|
+
} from "./chunk-XR2W3MAM.js";
|
|
3
11
|
|
|
4
|
-
//
|
|
12
|
+
// packages/core/src/cost-tracker.ts
|
|
5
13
|
import chalk from "chalk";
|
|
6
|
-
|
|
7
|
-
// src/utils/terminal/format.ts
|
|
8
|
-
function wrapText(text, width) {
|
|
9
|
-
const lines = [];
|
|
10
|
-
let currentLine = "";
|
|
11
|
-
for (const char of text) {
|
|
12
|
-
if ([...currentLine].length < width) {
|
|
13
|
-
currentLine += char;
|
|
14
|
-
} else {
|
|
15
|
-
lines.push(currentLine);
|
|
16
|
-
currentLine = char;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (currentLine) lines.push(currentLine);
|
|
20
|
-
return lines;
|
|
21
|
-
}
|
|
22
|
-
function formatDuration(ms) {
|
|
23
|
-
if (ms < 6e4) {
|
|
24
|
-
return `${(ms / 1e3).toFixed(1)}s`;
|
|
25
|
-
}
|
|
26
|
-
const hours = Math.floor(ms / 36e5);
|
|
27
|
-
const minutes = Math.floor(ms % 36e5 / 6e4);
|
|
28
|
-
const seconds = (ms % 6e4 / 1e3).toFixed(1);
|
|
29
|
-
if (hours > 0) {
|
|
30
|
-
return `${hours}h ${minutes}m ${seconds}s`;
|
|
31
|
-
}
|
|
32
|
-
if (minutes > 0) {
|
|
33
|
-
return `${minutes}m ${seconds}s`;
|
|
34
|
-
}
|
|
35
|
-
return `${seconds}s`;
|
|
36
|
-
}
|
|
37
|
-
function formatNumber(number) {
|
|
38
|
-
return new Intl.NumberFormat("en", {
|
|
39
|
-
notation: "compact",
|
|
40
|
-
maximumFractionDigits: 1
|
|
41
|
-
}).format(number).toLowerCase();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/core/costTracker.ts
|
|
45
14
|
var STATE = {
|
|
46
15
|
totalCost: 0,
|
|
47
16
|
totalAPIDuration: 0,
|
|
@@ -70,6 +39,23 @@ Total duration (API): ${formatDuration(STATE.totalAPIDuration)}
|
|
|
70
39
|
Total duration (wall): ${formatDuration(getTotalDuration())}`
|
|
71
40
|
);
|
|
72
41
|
}
|
|
42
|
+
function registerCostSummaryOnExit() {
|
|
43
|
+
const onExit = () => {
|
|
44
|
+
process.stdout.write("\n" + formatTotalCost() + "\n");
|
|
45
|
+
const projectConfig = getCurrentProjectConfig();
|
|
46
|
+
saveCurrentProjectConfig({
|
|
47
|
+
...projectConfig,
|
|
48
|
+
lastCost: STATE.totalCost,
|
|
49
|
+
lastAPIDuration: STATE.totalAPIDuration,
|
|
50
|
+
lastDuration: getTotalDuration(),
|
|
51
|
+
lastSessionId: SESSION_ID
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
process.on("exit", onExit);
|
|
55
|
+
return () => {
|
|
56
|
+
process.off("exit", onExit);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
73
59
|
function round(number, precision) {
|
|
74
60
|
return Math.round(number * precision) / precision;
|
|
75
61
|
}
|
|
@@ -83,13 +69,11 @@ function resetStateForTests() {
|
|
|
83
69
|
}
|
|
84
70
|
|
|
85
71
|
export {
|
|
86
|
-
wrapText,
|
|
87
|
-
formatDuration,
|
|
88
|
-
formatNumber,
|
|
89
72
|
addToTotalCost,
|
|
90
73
|
getTotalCost,
|
|
91
74
|
getTotalDuration,
|
|
92
75
|
getTotalAPIDuration,
|
|
93
76
|
formatTotalCost,
|
|
77
|
+
registerCostSummaryOnExit,
|
|
94
78
|
resetStateForTests
|
|
95
79
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/core/src/cost-tracker.ts"],
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport { formatDuration } from './utils/format'\nimport {\n getCurrentProjectConfig,\n saveCurrentProjectConfig,\n} from '#core/utils/config'\nimport { SESSION_ID } from './utils/log'\n\n// DO NOT ADD MORE STATE HERE OR BORIS WILL CURSE YOU\nconst STATE: {\n totalCost: number\n totalAPIDuration: number\n startTime: number\n} = {\n totalCost: 0,\n totalAPIDuration: 0,\n startTime: Date.now(),\n}\n\nexport function addToTotalCost(cost: number, duration: number): void {\n STATE.totalCost += cost\n STATE.totalAPIDuration += duration\n}\n\nexport function getTotalCost(): number {\n return STATE.totalCost\n}\n\nexport function getTotalDuration(): number {\n return Date.now() - STATE.startTime\n}\n\nexport function getTotalAPIDuration(): number {\n return STATE.totalAPIDuration\n}\n\nfunction formatCost(cost: number): string {\n return `$${cost > 0.5 ? round(cost, 100).toFixed(2) : cost.toFixed(4)}`\n}\n\nexport function formatTotalCost(): string {\n return chalk.grey(\n `Total cost: ${formatCost(STATE.totalCost)}\nTotal duration (API): ${formatDuration(STATE.totalAPIDuration)}\nTotal duration (wall): ${formatDuration(getTotalDuration())}`,\n )\n}\n\nexport function registerCostSummaryOnExit(): () => void {\n const onExit = () => {\n process.stdout.write('\\n' + formatTotalCost() + '\\n')\n\n // Save last cost and duration to project config\n const projectConfig = getCurrentProjectConfig()\n saveCurrentProjectConfig({\n ...projectConfig,\n lastCost: STATE.totalCost,\n lastAPIDuration: STATE.totalAPIDuration,\n lastDuration: getTotalDuration(),\n lastSessionId: SESSION_ID,\n })\n }\n\n process.on('exit', onExit)\n return () => {\n process.off('exit', onExit)\n }\n}\n\nfunction round(number: number, precision: number): number {\n return Math.round(number * precision) / precision\n}\n\n// Only used in tests\nexport function resetStateForTests(): void {\n if (process.env.NODE_ENV !== 'test') {\n throw new Error('resetStateForTests can only be called in tests')\n }\n STATE.startTime = Date.now()\n STATE.totalCost = 0\n STATE.totalAPIDuration = 0\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAAA,OAAO,WAAW;AASlB,IAAM,QAIF;AAAA,EACF,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,WAAW,KAAK,IAAI;AACtB;AAEO,SAAS,eAAe,MAAc,UAAwB;AACnE,QAAM,aAAa;AACnB,QAAM,oBAAoB;AAC5B;AAEO,SAAS,eAAuB;AACrC,SAAO,MAAM;AACf;AAEO,SAAS,mBAA2B;AACzC,SAAO,KAAK,IAAI,IAAI,MAAM;AAC5B;AAEO,SAAS,sBAA8B;AAC5C,SAAO,MAAM;AACf;AAEA,SAAS,WAAW,MAAsB;AACxC,SAAO,IAAI,OAAO,MAAM,MAAM,MAAM,GAAG,EAAE,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AACvE;AAEO,SAAS,kBAA0B;AACxC,SAAO,MAAM;AAAA,IACX,eAAe,WAAW,MAAM,SAAS,CAAC;AAAA,wBACtB,eAAe,MAAM,gBAAgB,CAAC;AAAA,yBACrC,eAAe,iBAAiB,CAAC,CAAC;AAAA,EACzD;AACF;AAEO,SAAS,4BAAwC;AACtD,QAAM,SAAS,MAAM;AACnB,YAAQ,OAAO,MAAM,OAAO,gBAAgB,IAAI,IAAI;AAGpD,UAAM,gBAAgB,wBAAwB;AAC9C,6BAAyB;AAAA,MACvB,GAAG;AAAA,MACH,UAAU,MAAM;AAAA,MAChB,iBAAiB,MAAM;AAAA,MACvB,cAAc,iBAAiB;AAAA,MAC/B,eAAe;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,UAAQ,GAAG,QAAQ,MAAM;AACzB,SAAO,MAAM;AACX,YAAQ,IAAI,QAAQ,MAAM;AAAA,EAC5B;AACF;AAEA,SAAS,MAAM,QAAgB,WAA2B;AACxD,SAAO,KAAK,MAAM,SAAS,SAAS,IAAI;AAC1C;AAGO,SAAS,qBAA2B;AACzC,MAAI,QAAQ,IAAI,aAAa,QAAQ;AACnC,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,QAAM,YAAY,KAAK,IAAI;AAC3B,QAAM,YAAY;AAClB,QAAM,mBAAmB;AAC3B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
-
const require = __kodeCreateRequire(import.meta.url);
|
|
3
1
|
import {
|
|
4
2
|
PRODUCT_NAME,
|
|
5
3
|
execFileNoThrow,
|
|
6
4
|
logError
|
|
7
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-3OEJVB5A.js";
|
|
8
6
|
import {
|
|
9
7
|
MACRO
|
|
10
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-W5EGGA44.js";
|
|
11
9
|
|
|
12
|
-
// src/utils/
|
|
10
|
+
// packages/core/src/utils/autoUpdater.ts
|
|
13
11
|
async function getSemver() {
|
|
14
12
|
const mod = await import("semver");
|
|
15
13
|
return mod?.default ?? mod;
|
|
@@ -82,7 +80,7 @@ async function checkAndNotifyUpdate() {
|
|
|
82
80
|
const [
|
|
83
81
|
{ isAutoUpdaterDisabled, getGlobalConfig, saveGlobalConfig },
|
|
84
82
|
{ env }
|
|
85
|
-
] = await Promise.all([import("./config-
|
|
83
|
+
] = await Promise.all([import("./config-25HRTPSP.js"), import("./env-TJ5NOBEB.js")]);
|
|
86
84
|
if (await isAutoUpdaterDisabled()) return;
|
|
87
85
|
if (await env.getIsDocker()) return;
|
|
88
86
|
if (!await env.hasInternetAccess()) return;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/core/src/utils/autoUpdater.ts"],
|
|
4
|
+
"sourcesContent": ["import { execFileNoThrow } from './execFileNoThrow'\nimport { logError } from './log'\n\nimport { MACRO } from '#core/constants/macros'\nimport { PRODUCT_NAME } from '#core/constants/product'\n\nasync function getSemver() {\n const mod: any = await import('semver')\n return (mod?.default ?? mod) as {\n lt: (a: string, b: string) => boolean\n gt: (a: string, b: string) => boolean\n }\n}\n\nexport type VersionConfig = {\n minVersion: string\n}\n\n// Ensure current version meets minimum supported version; exit if too old\nexport async function assertMinVersion(): Promise<void> {\n try {\n const versionConfig: VersionConfig = { minVersion: '0.0.0' }\n if (versionConfig.minVersion) {\n const { lt } = await getSemver()\n if (!lt(MACRO.VERSION, versionConfig.minVersion)) return\n\n const suggestions = await getUpdateCommandSuggestions()\n // Intentionally minimal: caller may print its own message; we just exit\n process.stderr.write(\n `Your ${PRODUCT_NAME} version ${MACRO.VERSION} is below the minimum supported ${versionConfig.minVersion}.\\n` +\n 'Update using one of:\\n' +\n suggestions.map(c => ` ${c}`).join('\\n') +\n '\\n',\n )\n process.exit(1)\n }\n } catch (error) {\n logError(`Error checking minimum version: ${error}`)\n }\n}\n\n// Get latest version from npm (via npm CLI or HTTP fallback)\nexport async function getLatestVersion(): Promise<string | null> {\n // Prefer npm CLI (fast when available)\n try {\n const abortController = new AbortController()\n setTimeout(() => abortController.abort(), 5000)\n const result = await execFileNoThrow(\n 'npm',\n ['view', MACRO.PACKAGE_URL, 'version'],\n abortController.signal,\n )\n if (result.code === 0) {\n const v = result.stdout.trim()\n if (v) return v\n }\n } catch {}\n\n // Fallback: query npm registry directly\n try {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), 5000)\n const res = await fetch(\n `https://registry.npmjs.org/${encodeURIComponent(MACRO.PACKAGE_URL)}`,\n {\n method: 'GET',\n headers: {\n Accept: 'application/vnd.npm.install-v1+json',\n 'User-Agent': `${PRODUCT_NAME}/${MACRO.VERSION}`,\n },\n signal: controller.signal,\n },\n )\n clearTimeout(timer)\n if (!res.ok) return null\n const json: any = await res.json().catch(() => null)\n const latest = json && json['dist-tags'] && json['dist-tags'].latest\n return typeof latest === 'string' ? latest : null\n } catch {\n return null\n }\n}\n\n// Suggest manual update commands; prefer Bun first, then npm\nexport async function getUpdateCommandSuggestions(): Promise<string[]> {\n return [\n `bun add -g ${MACRO.PACKAGE_URL}@latest`,\n `npm install -g ${MACRO.PACKAGE_URL}@latest`,\n ]\n}\n\n// Optional: background notifier that prints a simple banner\nexport async function checkAndNotifyUpdate(): Promise<void> {\n try {\n if (process.env.NODE_ENV === 'test') return\n const [\n { isAutoUpdaterDisabled, getGlobalConfig, saveGlobalConfig },\n { env },\n ] = await Promise.all([import('./config'), import('./env')])\n if (await isAutoUpdaterDisabled()) return\n if (await env.getIsDocker()) return\n if (!(await env.hasInternetAccess())) return\n\n const config: any = getGlobalConfig()\n const now = Date.now()\n const DAY_MS = 24 * 60 * 60 * 1000\n const lastCheck = Number(config.lastUpdateCheckAt || 0)\n if (lastCheck && now - lastCheck < DAY_MS) return\n\n const latest = await getLatestVersion()\n if (!latest) {\n saveGlobalConfig({ ...config, lastUpdateCheckAt: now })\n return\n }\n\n const { gt } = await getSemver()\n if (gt(latest, MACRO.VERSION)) {\n saveGlobalConfig({\n ...config,\n lastUpdateCheckAt: now,\n lastSuggestedVersion: latest,\n })\n const suggestions = await getUpdateCommandSuggestions()\n process.stderr.write(\n [\n `New version available: ${latest} (current: ${MACRO.VERSION})`,\n 'Run the following command to update:',\n ...suggestions.map(command => ` ${command}`),\n '',\n ].join('\\n'),\n )\n } else {\n saveGlobalConfig({ ...config, lastUpdateCheckAt: now })\n }\n } catch (error) {\n logError(`update-notify: ${error}`)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAMA,eAAe,YAAY;AACzB,QAAM,MAAW,MAAM,OAAO,QAAQ;AACtC,SAAQ,KAAK,WAAW;AAI1B;AAOA,eAAsB,mBAAkC;AACtD,MAAI;AACF,UAAM,gBAA+B,EAAE,YAAY,QAAQ;AAC3D,QAAI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GAAG,YAAY,IAAI,aAAW,KAAK,OAAO,EAAE;AAAA,UAC5C;AAAA,QACF,EAAE,KAAK,IAAI;AAAA,MACb;AAAA,IACF,OAAO;AACL,uBAAiB,EAAE,GAAG,QAAQ,mBAAmB,IAAI,CAAC;AAAA,IACxD;AAAA,EACF,SAAS,OAAO;AACd,aAAS,kBAAkB,KAAK,EAAE;AAAA,EACpC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// apps/cli/src/ui/hooks/useTerminalSize.ts
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
var globalSize = {
|
|
4
|
+
columns: process.stdout.columns || 80,
|
|
5
|
+
rows: process.stdout.rows || 24
|
|
6
|
+
};
|
|
7
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
8
|
+
var isListenerAttached = false;
|
|
9
|
+
function updateAllListeners() {
|
|
10
|
+
globalSize = {
|
|
11
|
+
columns: process.stdout.columns || 80,
|
|
12
|
+
rows: process.stdout.rows || 24
|
|
13
|
+
};
|
|
14
|
+
listeners.forEach((listener) => listener());
|
|
15
|
+
}
|
|
16
|
+
function useTerminalSize() {
|
|
17
|
+
const [size, setSize] = useState(globalSize);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const updateSize = () => setSize({ ...globalSize });
|
|
20
|
+
listeners.add(updateSize);
|
|
21
|
+
if (!isListenerAttached) {
|
|
22
|
+
process.stdout.setMaxListeners(20);
|
|
23
|
+
process.stdout.on("resize", updateAllListeners);
|
|
24
|
+
isListenerAttached = true;
|
|
25
|
+
}
|
|
26
|
+
return () => {
|
|
27
|
+
listeners.delete(updateSize);
|
|
28
|
+
if (listeners.size === 0 && isListenerAttached) {
|
|
29
|
+
process.stdout.off("resize", updateAllListeners);
|
|
30
|
+
isListenerAttached = false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
return size;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
useTerminalSize
|
|
39
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../apps/cli/src/ui/hooks/useTerminalSize.ts"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useState } from 'react'\n\n// Global state to share across all hook instances\nlet globalSize = {\n columns: process.stdout.columns || 80,\n rows: process.stdout.rows || 24,\n}\n\nconst listeners = new Set<() => void>()\nlet isListenerAttached = false\n\nfunction updateAllListeners() {\n globalSize = {\n columns: process.stdout.columns || 80,\n rows: process.stdout.rows || 24,\n }\n listeners.forEach(listener => listener())\n}\n\nexport function useTerminalSize() {\n const [size, setSize] = useState(globalSize)\n\n useEffect(() => {\n // Add this component's listener to the set\n const updateSize = () => setSize({ ...globalSize })\n listeners.add(updateSize)\n\n // Only attach the global resize listener once\n if (!isListenerAttached) {\n // Increase max listeners to prevent warnings\n process.stdout.setMaxListeners(20)\n process.stdout.on('resize', updateAllListeners)\n isListenerAttached = true\n }\n\n return () => {\n // Remove this component's listener\n listeners.delete(updateSize)\n\n // If no more listeners, remove the global listener\n if (listeners.size === 0 && isListenerAttached) {\n process.stdout.off('resize', updateAllListeners)\n isListenerAttached = false\n }\n }\n }, [])\n\n return size\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAW,gBAAgB;AAGpC,IAAI,aAAa;AAAA,EACf,SAAS,QAAQ,OAAO,WAAW;AAAA,EACnC,MAAM,QAAQ,OAAO,QAAQ;AAC/B;AAEA,IAAM,YAAY,oBAAI,IAAgB;AACtC,IAAI,qBAAqB;AAEzB,SAAS,qBAAqB;AAC5B,eAAa;AAAA,IACX,SAAS,QAAQ,OAAO,WAAW;AAAA,IACnC,MAAM,QAAQ,OAAO,QAAQ;AAAA,EAC/B;AACA,YAAU,QAAQ,cAAY,SAAS,CAAC;AAC1C;AAEO,SAAS,kBAAkB;AAChC,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,UAAU;AAE3C,YAAU,MAAM;AAEd,UAAM,aAAa,MAAM,QAAQ,EAAE,GAAG,WAAW,CAAC;AAClD,cAAU,IAAI,UAAU;AAGxB,QAAI,CAAC,oBAAoB;AAEvB,cAAQ,OAAO,gBAAgB,EAAE;AACjC,cAAQ,OAAO,GAAG,UAAU,kBAAkB;AAC9C,2BAAqB;AAAA,IACvB;AAEA,WAAO,MAAM;AAEX,gBAAU,OAAO,UAAU;AAG3B,UAAI,UAAU,SAAS,KAAK,oBAAoB;AAC9C,gBAAQ,OAAO,IAAI,UAAU,kBAAkB;AAC/C,6BAAqB;AAAA,MACvB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|