@shareai-lab/kode 2.0.1 → 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-7LH4HTNR.js → chunks/agentsValidate-PEWMYN4Q.js} +97 -69
- package/dist/chunks/agentsValidate-PEWMYN4Q.js.map +7 -0
- package/dist/{ask-3NHFFUQG.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-AFFSCMYS.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-ARZSBOAO.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-UHYRLID6.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-YC6LJCDE.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-3IN27HA5.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-73WGVYLQ.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-QVLYOPO5.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-K2CWOTI2.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-RZWOUA25.js → chunks/chunk-HRJ3ICQK.js} +59 -55
- package/dist/chunks/chunk-HRJ3ICQK.js.map +7 -0
- package/dist/{chunk-DZE5YA7L.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-7M2YN6TU.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-W7GRKO7Q.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-7U7L4NMD.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-ZVDRDPII.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-MWRSY4X6.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-STSX7GIX.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-RUSD6G5Y.js → chunks/config-25HRTPSP.js} +48 -10
- package/dist/chunks/cost-tracker-Z2UZT2J5.js +28 -0
- package/dist/{customCommands-TOIJFZAL.js → chunks/customCommands-TYMYZRG5.js} +11 -8
- package/dist/chunks/engine-MRVF6FK6.js +39 -0
- package/dist/{env-XGKBLU3D.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-UGEZJJEB.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-QWM36A3D.js → chunks/kodeHooks-RVKYRJHG.js} +11 -9
- package/dist/{llm-ZUQC4WYM.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-EE3XFHCJ.js → chunks/mentionProcessor-RJW5UPJD.js} +46 -16
- package/dist/chunks/mentionProcessor-RJW5UPJD.js.map +7 -0
- package/dist/{messages-EOYQKPGM.js → chunks/messages-EEWWLPHN.js} +2 -6
- package/dist/chunks/model-5TIEKQPD.js +37 -0
- package/dist/{openai-RRCWW33N.js → chunks/openai-XXK3YZG4.js} +13 -10
- package/dist/{outputStyles-62Q3VH2J.js → chunks/outputStyles-FAJTXN2A.js} +6 -9
- package/dist/chunks/permissions-HO7INPWM.js +27 -0
- package/dist/{pluginRuntime-6ETCZ2LL.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-3RXQBVOL.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-DOPVY2CW.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-CW7AYLVL.js +0 -42
- package/dist/acp-VEPJ74LT.js +0 -1357
- package/dist/acp-VEPJ74LT.js.map +0 -7
- package/dist/agentsValidate-7LH4HTNR.js.map +0 -7
- package/dist/ask-3NHFFUQG.js.map +0 -7
- package/dist/autoUpdater-ITPIHCOI.js +0 -17
- package/dist/chunk-3IN27HA5.js.map +0 -7
- package/dist/chunk-4FX3IVPT.js +0 -164
- package/dist/chunk-4FX3IVPT.js.map +0 -7
- package/dist/chunk-4RTX4AG4.js.map +0 -7
- package/dist/chunk-5PDP7R6N.js +0 -515
- package/dist/chunk-5PDP7R6N.js.map +0 -7
- package/dist/chunk-73WGVYLQ.js.map +0 -7
- package/dist/chunk-7M2YN6TU.js.map +0 -7
- package/dist/chunk-7U7L4NMD.js.map +0 -7
- package/dist/chunk-ABLVTESJ.js.map +0 -7
- package/dist/chunk-AFFSCMYS.js.map +0 -7
- package/dist/chunk-ARZSBOAO.js.map +0 -7
- package/dist/chunk-CIG63V4E.js +0 -72
- package/dist/chunk-CIG63V4E.js.map +0 -7
- package/dist/chunk-CM3EGTG6.js +0 -1609
- package/dist/chunk-CM3EGTG6.js.map +0 -7
- package/dist/chunk-DZE5YA7L.js.map +0 -7
- package/dist/chunk-E6YNABER.js.map +0 -7
- package/dist/chunk-EZXMVTDU.js.map +0 -7
- package/dist/chunk-F2SJXUDI.js +0 -148
- package/dist/chunk-F2SJXUDI.js.map +0 -7
- package/dist/chunk-FC5ZCKBI.js +0 -30167
- package/dist/chunk-FC5ZCKBI.js.map +0 -7
- package/dist/chunk-HCBELH4J.js +0 -145
- package/dist/chunk-HCBELH4J.js.map +0 -7
- package/dist/chunk-HN4E4UUQ.js.map +0 -7
- package/dist/chunk-IZVMU4S2.js +0 -654
- package/dist/chunk-IZVMU4S2.js.map +0 -7
- package/dist/chunk-K2CWOTI2.js.map +0 -7
- package/dist/chunk-LC4TVOCZ.js +0 -835
- package/dist/chunk-LC4TVOCZ.js.map +0 -7
- package/dist/chunk-MIW7N2MY.js +0 -2613
- package/dist/chunk-MIW7N2MY.js.map +0 -7
- package/dist/chunk-MWRSY4X6.js.map +0 -7
- package/dist/chunk-ND3XWFO6.js +0 -34
- package/dist/chunk-ND3XWFO6.js.map +0 -7
- package/dist/chunk-QVLYOPO5.js.map +0 -7
- package/dist/chunk-RZWOUA25.js.map +0 -7
- package/dist/chunk-S6HRABTA.js.map +0 -7
- package/dist/chunk-STSX7GIX.js.map +0 -7
- package/dist/chunk-UHYRLID6.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-W7GRKO7Q.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-YC6LJCDE.js.map +0 -7
- package/dist/chunk-YXYYDIMI.js +0 -2931
- package/dist/chunk-YXYYDIMI.js.map +0 -7
- package/dist/chunk-ZVDRDPII.js.map +0 -7
- package/dist/cli-DOPVY2CW.js.map +0 -7
- package/dist/commands-2BF2CJ3A.js +0 -46
- package/dist/context-6FXPETYH.js +0 -30
- package/dist/costTracker-6SL26FDB.js +0 -19
- package/dist/kodeAgentSessionLoad-MITZADPB.js +0 -18
- package/dist/kodeAgentSessionResume-GVRWB4WO.js +0 -16
- package/dist/kodeAgentStreamJson-NXFN7TXH.js +0 -13
- package/dist/kodeAgentStreamJsonSession-UGEZJJEB.js.map +0 -7
- package/dist/kodeAgentStructuredStdio-HGWJT7CU.js +0 -10
- package/dist/llm-ZUQC4WYM.js.map +0 -7
- package/dist/llmLazy-54QQHA54.js +0 -15
- package/dist/loader-FYHJQES5.js +0 -28
- package/dist/mcp-J332IKT3.js +0 -49
- package/dist/mentionProcessor-EE3XFHCJ.js.map +0 -7
- package/dist/model-FV3JDJKH.js +0 -30
- package/dist/pluginRuntime-6ETCZ2LL.js.map +0 -7
- package/dist/pluginValidation-I4YKUWGS.js +0 -17
- package/dist/prompts-ZLEKDD77.js +0 -48
- package/dist/query-VFRJPBGD.js +0 -50
- package/dist/responsesStreaming-AW344PQO.js +0 -10
- package/dist/ripgrep-3NTIKQYW.js +0 -17
- package/dist/state-P5G6CO5V.js +0 -16
- package/dist/theme-3LWP3BG7.js +0 -14
- package/dist/toolPermissionSettings-3ROBVTUK.js +0 -18
- package/dist/tools-RO7HSSE5.js +0 -47
- package/dist/userInput-JSBJRFSK.js +0 -311
- package/dist/userInput-JSBJRFSK.js.map +0 -7
- package/dist/uuid-QN2CNKKN.js +0 -9
- /package/dist/{REPL-CW7AYLVL.js.map → chunks/Doctor-M3J7GRTJ.js.map} +0 -0
- /package/dist/{autoUpdater-ITPIHCOI.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-2BF2CJ3A.js.map → chunks/agentLoader-FCRG3TFJ.js.map} +0 -0
- /package/dist/{config-RUSD6G5Y.js.map → chunks/autoUpdater-CNESBOKO.js.map} +0 -0
- /package/dist/{context-6FXPETYH.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-TOIJFZAL.js.map → chunks/chunk-GCQCAXJZ.js.map} +0 -0
- /package/dist/{env-XGKBLU3D.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-MITZADPB.js.map → chunks/config-25HRTPSP.js.map} +0 -0
- /package/dist/{kodeAgentSessionResume-GVRWB4WO.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-QWM36A3D.js.map → chunks/env-TJ5NOBEB.js.map} +0 -0
- /package/dist/{llmLazy-54QQHA54.js.map → chunks/kodeAgentSessionId-VTNISJ2L.js.map} +0 -0
- /package/dist/{loader-FYHJQES5.js.map → chunks/kodeAgentSessionLoad-YB2RKBGJ.js.map} +0 -0
- /package/dist/{mcp-J332IKT3.js.map → chunks/kodeAgentSessionResume-DZSIVKVA.js.map} +0 -0
- /package/dist/{messages-EOYQKPGM.js.map → chunks/kodeAgentStreamJson-X5PLS2S6.js.map} +0 -0
- /package/dist/{model-FV3JDJKH.js.map → chunks/kodeHooks-RVKYRJHG.js.map} +0 -0
- /package/dist/{openai-RRCWW33N.js.map → chunks/llmLazy-ZUSSE3ZA.js.map} +0 -0
- /package/dist/{outputStyles-62Q3VH2J.js.map → chunks/messages-EEWWLPHN.js.map} +0 -0
- /package/dist/{pluginValidation-I4YKUWGS.js.map → chunks/model-5TIEKQPD.js.map} +0 -0
- /package/dist/{prompts-ZLEKDD77.js.map → chunks/openai-XXK3YZG4.js.map} +0 -0
- /package/dist/{query-VFRJPBGD.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-3NTIKQYW.js.map → chunks/pluginValidation-DAM7WRTC.js.map} +0 -0
- /package/dist/{skillMarketplace-3RXQBVOL.js.map → chunks/registry-XYJXMOA5.js.map} +0 -0
- /package/dist/{state-P5G6CO5V.js.map → chunks/responsesStreaming-JNGE2P3D.js.map} +0 -0
- /package/dist/{theme-3LWP3BG7.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-3ROBVTUK.js.map → chunks/src-OROQIWP3.js.map} +0 -0
- /package/dist/{tools-RO7HSSE5.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,744 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateSystemReminders
|
|
3
|
+
} from "./chunk-LOD5ZHCI.js";
|
|
4
|
+
import {
|
|
5
|
+
getSessionStartAdditionalContext
|
|
6
|
+
} from "./chunk-3BYE3ME6.js";
|
|
7
|
+
import {
|
|
8
|
+
INTERRUPT_MESSAGE,
|
|
9
|
+
INTERRUPT_MESSAGE_FOR_TOOL_USE
|
|
10
|
+
} from "./chunk-HRJ3ICQK.js";
|
|
11
|
+
import {
|
|
12
|
+
getModelManager
|
|
13
|
+
} from "./chunk-6ZWEOSEI.js";
|
|
14
|
+
import {
|
|
15
|
+
debug
|
|
16
|
+
} from "./chunk-YIO5EBMQ.js";
|
|
17
|
+
import {
|
|
18
|
+
PRODUCT_COMMAND,
|
|
19
|
+
PRODUCT_NAME,
|
|
20
|
+
PROJECT_FILE,
|
|
21
|
+
SESSION_ID,
|
|
22
|
+
env,
|
|
23
|
+
execFileNoThrow,
|
|
24
|
+
logError
|
|
25
|
+
} from "./chunk-3OEJVB5A.js";
|
|
26
|
+
import {
|
|
27
|
+
getCwd
|
|
28
|
+
} from "./chunk-BBJFHTBC.js";
|
|
29
|
+
import {
|
|
30
|
+
MACRO
|
|
31
|
+
} from "./chunk-W5EGGA44.js";
|
|
32
|
+
import {
|
|
33
|
+
getCurrentProjectConfig,
|
|
34
|
+
getGlobalConfig,
|
|
35
|
+
getOrCreateUserID,
|
|
36
|
+
saveCurrentProjectConfig
|
|
37
|
+
} from "./chunk-XR2W3MAM.js";
|
|
38
|
+
|
|
39
|
+
// packages/core/src/utils/git.ts
|
|
40
|
+
import { memoize } from "lodash-es";
|
|
41
|
+
var getIsGit = memoize(async () => {
|
|
42
|
+
const { code } = await execFileNoThrow("git", [
|
|
43
|
+
"rev-parse",
|
|
44
|
+
"--is-inside-work-tree"
|
|
45
|
+
]);
|
|
46
|
+
return code === 0;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// packages/core/src/constants/prompts.ts
|
|
50
|
+
var BASH_TOOL_NAME = "Bash";
|
|
51
|
+
function getCLISyspromptPrefix() {
|
|
52
|
+
return `You are ${PRODUCT_NAME}, ShareAI-lab's Agent AI CLI for terminal & coding.`;
|
|
53
|
+
}
|
|
54
|
+
async function getSystemPrompt(options) {
|
|
55
|
+
const disableSlashCommands = options?.disableSlashCommands === true;
|
|
56
|
+
const sessionStartAdditionalContext = await getSessionStartAdditionalContext();
|
|
57
|
+
const isOutputStyleActive = options?.outputStyleActive === true;
|
|
58
|
+
const includeCodingInstructions = !isOutputStyleActive || options?.keepCodingInstructions === true;
|
|
59
|
+
return [
|
|
60
|
+
`
|
|
61
|
+
You are an interactive CLI tool that helps users ${isOutputStyleActive ? 'according to your "Output Style" below, which describes how you should respond to user queries.' : "with software engineering tasks."} Use the instructions below and the tools available to you to assist the user.
|
|
62
|
+
|
|
63
|
+
IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
|
|
64
|
+
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
|
|
65
|
+
|
|
66
|
+
${disableSlashCommands ? "" : `Here are useful slash commands users can run to interact with you:
|
|
67
|
+
- /help: Get help with using ${PRODUCT_NAME}
|
|
68
|
+
- /compact: Compact and continue the conversation. This is useful if the conversation is reaching the context limit
|
|
69
|
+
There are additional slash commands and flags available to the user. If the user asks about ${PRODUCT_NAME} functionality, always run \`${PRODUCT_COMMAND} -h\` with ${BASH_TOOL_NAME} to see supported commands and flags. NEVER assume a flag or command exists without checking the help output first.`}
|
|
70
|
+
To give feedback, users should ${MACRO.ISSUES_EXPLAINER}.
|
|
71
|
+
|
|
72
|
+
# Task Management
|
|
73
|
+
You have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
|
|
74
|
+
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
|
|
75
|
+
|
|
76
|
+
It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.
|
|
77
|
+
|
|
78
|
+
# Memory
|
|
79
|
+
If the current working directory contains a file called ${PROJECT_FILE}, it will be automatically added to your context. This file serves multiple purposes:
|
|
80
|
+
1. Storing frequently used bash commands (build, test, lint, etc.) so you can use them without searching each time
|
|
81
|
+
2. Recording the user's code style preferences (naming conventions, preferred libraries, etc.)
|
|
82
|
+
3. Maintaining useful information about the codebase structure and organization
|
|
83
|
+
|
|
84
|
+
When you spend time searching for commands to typecheck, lint, build, or test, you should ask the user if it's okay to add those commands to ${PROJECT_FILE}. Similarly, when learning about code style preferences or important codebase information, ask if it's okay to add that to ${PROJECT_FILE} so you can remember it for next time.
|
|
85
|
+
|
|
86
|
+
${isOutputStyleActive ? "" : `# Tone and style
|
|
87
|
+
You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
|
|
88
|
+
Remember that your output will be displayed on a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
|
|
89
|
+
Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like ${BASH_TOOL_NAME} or code comments as means to communicate with the user during the session.
|
|
90
|
+
If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
|
|
91
|
+
IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
|
|
92
|
+
IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
|
|
93
|
+
IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
|
|
94
|
+
<example>
|
|
95
|
+
user: 2 + 2
|
|
96
|
+
assistant: 4
|
|
97
|
+
</example>
|
|
98
|
+
|
|
99
|
+
<example>
|
|
100
|
+
user: what is 2+2?
|
|
101
|
+
assistant: 4
|
|
102
|
+
</example>
|
|
103
|
+
|
|
104
|
+
<example>
|
|
105
|
+
user: is 11 a prime number?
|
|
106
|
+
assistant: Yes
|
|
107
|
+
</example>
|
|
108
|
+
|
|
109
|
+
<example>
|
|
110
|
+
user: what command should I run to list files in the current directory?
|
|
111
|
+
assistant: ls
|
|
112
|
+
</example>
|
|
113
|
+
|
|
114
|
+
<example>
|
|
115
|
+
user: what command should I run to watch files in the current directory?
|
|
116
|
+
assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
|
|
117
|
+
npm run dev
|
|
118
|
+
</example>
|
|
119
|
+
|
|
120
|
+
<example>
|
|
121
|
+
user: How many golf balls fit inside a jetta?
|
|
122
|
+
assistant: 150000
|
|
123
|
+
</example>
|
|
124
|
+
|
|
125
|
+
<example>
|
|
126
|
+
user: what files are in the directory src/?
|
|
127
|
+
assistant: [runs ls and sees foo.c, bar.c, baz.c]
|
|
128
|
+
user: which file contains the implementation of foo?
|
|
129
|
+
assistant: src/foo.c
|
|
130
|
+
</example>
|
|
131
|
+
|
|
132
|
+
<example>
|
|
133
|
+
user: write tests for new feature
|
|
134
|
+
assistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
|
|
135
|
+
</example>
|
|
136
|
+
`}
|
|
137
|
+
|
|
138
|
+
# Proactiveness
|
|
139
|
+
You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
|
|
140
|
+
1. Doing the right thing when asked, including taking actions and follow-up actions
|
|
141
|
+
2. Not surprising the user with actions you take without asking
|
|
142
|
+
For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
|
|
143
|
+
3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
|
|
144
|
+
|
|
145
|
+
# Synthetic messages
|
|
146
|
+
Sometimes, the conversation will contain messages like ${INTERRUPT_MESSAGE} or ${INTERRUPT_MESSAGE_FOR_TOOL_USE}. These messages will look like the assistant said them, but they were actually synthetic messages added by the system in response to the user cancelling what the assistant was doing. You should not respond to these messages. You must NEVER send messages like this yourself.
|
|
147
|
+
|
|
148
|
+
# Following conventions
|
|
149
|
+
When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
|
|
150
|
+
- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
|
|
151
|
+
- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
|
|
152
|
+
- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
|
|
153
|
+
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
|
|
154
|
+
|
|
155
|
+
# Code style
|
|
156
|
+
- Do not add comments to the code you write, unless the user asks you to, or the code is complex and requires additional context.
|
|
157
|
+
|
|
158
|
+
${includeCodingInstructions ? `# Doing tasks
|
|
159
|
+
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
160
|
+
- Use the TodoWrite tool to plan the task if required
|
|
161
|
+
- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
|
|
162
|
+
- Implement the solution using all tools available to you
|
|
163
|
+
- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
|
|
164
|
+
- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (eg. npm run lint, npm run typecheck, ruff, etc.) if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to ${PROJECT_FILE} so that you will know to run it next time.
|
|
165
|
+
NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
166
|
+
|
|
167
|
+
- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
|
|
168
|
+
` : ""}
|
|
169
|
+
|
|
170
|
+
# Tool usage policy
|
|
171
|
+
- When doing file search, prefer to use the Task tool in order to reduce context usage.
|
|
172
|
+
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
|
|
173
|
+
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.
|
|
174
|
+
- It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
175
|
+
- It is always better to speculatively perform multiple searches as a batch that are potentially useful.
|
|
176
|
+
- For making multiple edits to the same file, prefer using the MultiEdit tool over multiple Edit tool calls.
|
|
177
|
+
|
|
178
|
+
${isOutputStyleActive ? "" : "\nYou MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.\n"}
|
|
179
|
+
`,
|
|
180
|
+
`
|
|
181
|
+
${await getEnvInfo()}`,
|
|
182
|
+
...sessionStartAdditionalContext ? [`
|
|
183
|
+
${sessionStartAdditionalContext}`] : [],
|
|
184
|
+
`IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
|
|
185
|
+
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).`
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
async function getEnvInfo() {
|
|
189
|
+
const isGit = await getIsGit();
|
|
190
|
+
return `Here is useful information about the environment you are running in:
|
|
191
|
+
<env>
|
|
192
|
+
Working directory: ${getCwd()}
|
|
193
|
+
Is directory a git repo: ${isGit ? "Yes" : "No"}
|
|
194
|
+
Platform: ${env.platform}
|
|
195
|
+
Today's date: ${(/* @__PURE__ */ new Date()).toLocaleDateString()}
|
|
196
|
+
</env>`;
|
|
197
|
+
}
|
|
198
|
+
async function getAgentPrompt() {
|
|
199
|
+
return [
|
|
200
|
+
`
|
|
201
|
+
You are an agent for ${PRODUCT_NAME}. Given the user's prompt, you should use the tools available to you to answer the user's question.
|
|
202
|
+
|
|
203
|
+
Notes:
|
|
204
|
+
1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...".
|
|
205
|
+
2. When relevant, share file names and code snippets relevant to the query
|
|
206
|
+
3. Any file paths you return in your final response MUST be absolute. DO NOT use relative paths.`,
|
|
207
|
+
`${await getEnvInfo()}`
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// packages/core/src/utils/style.ts
|
|
212
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
213
|
+
import { memoize as memoize2 } from "lodash-es";
|
|
214
|
+
|
|
215
|
+
// packages/core/src/utils/projectInstructions.ts
|
|
216
|
+
import { existsSync, readFileSync } from "fs";
|
|
217
|
+
import { dirname, join, parse, relative, resolve, sep } from "path";
|
|
218
|
+
var DEFAULT_PROJECT_DOC_MAX_BYTES = 32 * 1024;
|
|
219
|
+
function isRegularFile(path) {
|
|
220
|
+
try {
|
|
221
|
+
return existsSync(path);
|
|
222
|
+
} catch {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function findGitRoot(startDir) {
|
|
227
|
+
let currentDir = resolve(startDir);
|
|
228
|
+
const fsRoot = parse(currentDir).root;
|
|
229
|
+
while (true) {
|
|
230
|
+
const dotGitPath = join(currentDir, ".git");
|
|
231
|
+
if (existsSync(dotGitPath)) {
|
|
232
|
+
return currentDir;
|
|
233
|
+
}
|
|
234
|
+
if (currentDir === fsRoot) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
currentDir = dirname(currentDir);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function getDirsFromGitRootToCwd(gitRoot, cwd) {
|
|
241
|
+
const absoluteGitRoot = resolve(gitRoot);
|
|
242
|
+
const absoluteCwd = resolve(cwd);
|
|
243
|
+
const rel = relative(absoluteGitRoot, absoluteCwd);
|
|
244
|
+
if (!rel || rel === ".") {
|
|
245
|
+
return [absoluteGitRoot];
|
|
246
|
+
}
|
|
247
|
+
const parts = rel.split(sep).filter(Boolean);
|
|
248
|
+
const dirs = [absoluteGitRoot];
|
|
249
|
+
for (let i = 0; i < parts.length; i++) {
|
|
250
|
+
dirs.push(join(absoluteGitRoot, ...parts.slice(0, i + 1)));
|
|
251
|
+
}
|
|
252
|
+
return dirs;
|
|
253
|
+
}
|
|
254
|
+
function getProjectInstructionFiles(cwd) {
|
|
255
|
+
const gitRoot = findGitRoot(cwd);
|
|
256
|
+
const root = gitRoot ?? resolve(cwd);
|
|
257
|
+
const dirs = getDirsFromGitRootToCwd(root, cwd);
|
|
258
|
+
const results = [];
|
|
259
|
+
for (const dir of dirs) {
|
|
260
|
+
const overridePath = join(dir, "AGENTS.override.md");
|
|
261
|
+
const agentsPath = join(dir, "AGENTS.md");
|
|
262
|
+
if (isRegularFile(overridePath)) {
|
|
263
|
+
results.push({
|
|
264
|
+
absolutePath: overridePath,
|
|
265
|
+
relativePathFromGitRoot: relative(root, overridePath) || "AGENTS.override.md",
|
|
266
|
+
filename: "AGENTS.override.md"
|
|
267
|
+
});
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (isRegularFile(agentsPath)) {
|
|
271
|
+
results.push({
|
|
272
|
+
absolutePath: agentsPath,
|
|
273
|
+
relativePathFromGitRoot: relative(root, agentsPath) || "AGENTS.md",
|
|
274
|
+
filename: "AGENTS.md"
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return results;
|
|
279
|
+
}
|
|
280
|
+
function getProjectDocMaxBytes() {
|
|
281
|
+
const raw = process.env.KODE_PROJECT_DOC_MAX_BYTES;
|
|
282
|
+
if (!raw) return DEFAULT_PROJECT_DOC_MAX_BYTES;
|
|
283
|
+
const parsed = Number.parseInt(raw, 10);
|
|
284
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
285
|
+
return DEFAULT_PROJECT_DOC_MAX_BYTES;
|
|
286
|
+
return parsed;
|
|
287
|
+
}
|
|
288
|
+
function readAndConcatProjectInstructionFiles(files, {
|
|
289
|
+
maxBytes = getProjectDocMaxBytes(),
|
|
290
|
+
includeHeadings = true
|
|
291
|
+
} = {}) {
|
|
292
|
+
let totalBytes = 0;
|
|
293
|
+
let truncated = false;
|
|
294
|
+
const parts = [];
|
|
295
|
+
const truncateUtf8ToBytes = (value, bytes) => {
|
|
296
|
+
const buf = Buffer.from(value, "utf8");
|
|
297
|
+
if (buf.length <= bytes) return value;
|
|
298
|
+
return buf.subarray(0, Math.max(0, bytes)).toString("utf8");
|
|
299
|
+
};
|
|
300
|
+
for (const file of files) {
|
|
301
|
+
if (totalBytes >= maxBytes) {
|
|
302
|
+
truncated = true;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
let raw;
|
|
306
|
+
try {
|
|
307
|
+
raw = readFileSync(file.absolutePath, "utf-8");
|
|
308
|
+
} catch {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (!raw.trim()) continue;
|
|
312
|
+
const separator = parts.length > 0 ? "\n\n" : "";
|
|
313
|
+
const separatorBytes = Buffer.byteLength(separator, "utf8");
|
|
314
|
+
const remainingAfterSeparator = maxBytes - totalBytes - separatorBytes;
|
|
315
|
+
if (remainingAfterSeparator <= 0) {
|
|
316
|
+
truncated = true;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
const heading = includeHeadings ? `# ${file.filename}
|
|
320
|
+
|
|
321
|
+
_Path: ${file.relativePathFromGitRoot}_
|
|
322
|
+
|
|
323
|
+
` : "";
|
|
324
|
+
const block = `${heading}${raw}`.trimEnd();
|
|
325
|
+
const blockBytes = Buffer.byteLength(block, "utf8");
|
|
326
|
+
if (blockBytes <= remainingAfterSeparator) {
|
|
327
|
+
parts.push(`${separator}${block}`);
|
|
328
|
+
totalBytes += separatorBytes + blockBytes;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
truncated = true;
|
|
332
|
+
const suffix = `
|
|
333
|
+
|
|
334
|
+
... (truncated: project instruction files exceeded ${maxBytes} bytes)`;
|
|
335
|
+
const suffixBytes = Buffer.byteLength(suffix, "utf8");
|
|
336
|
+
let finalBlock = "";
|
|
337
|
+
if (suffixBytes >= remainingAfterSeparator) {
|
|
338
|
+
finalBlock = truncateUtf8ToBytes(suffix, remainingAfterSeparator);
|
|
339
|
+
} else {
|
|
340
|
+
const prefixBudget = remainingAfterSeparator - suffixBytes;
|
|
341
|
+
const prefix = truncateUtf8ToBytes(block, prefixBudget);
|
|
342
|
+
finalBlock = `${prefix}${suffix}`;
|
|
343
|
+
}
|
|
344
|
+
parts.push(`${separator}${finalBlock}`);
|
|
345
|
+
totalBytes += separatorBytes + Buffer.byteLength(finalBlock, "utf8");
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
return { content: parts.join(""), truncated };
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// packages/core/src/utils/style.ts
|
|
352
|
+
var STYLE_PROMPT = "The codebase follows strict style guidelines shown below. All code changes must strictly adhere to these guidelines to maintain consistency and quality.";
|
|
353
|
+
var getCodeStyle = memoize2(() => {
|
|
354
|
+
const styles = [];
|
|
355
|
+
const instructionFiles = getProjectInstructionFiles(getCwd());
|
|
356
|
+
for (const file of instructionFiles) {
|
|
357
|
+
try {
|
|
358
|
+
styles.push(
|
|
359
|
+
`Contents of ${file.absolutePath}:
|
|
360
|
+
|
|
361
|
+
${readFileSync2(file.absolutePath, "utf-8")}`
|
|
362
|
+
);
|
|
363
|
+
} catch {
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (styles.length === 0) {
|
|
367
|
+
return "";
|
|
368
|
+
}
|
|
369
|
+
return `${STYLE_PROMPT}
|
|
370
|
+
|
|
371
|
+
${styles.join("\n\n")}`;
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
// packages/core/src/context/index.ts
|
|
375
|
+
import { memoize as memoize4, omit } from "lodash-es";
|
|
376
|
+
import { join as join2 } from "path";
|
|
377
|
+
import { readFile } from "fs/promises";
|
|
378
|
+
import { existsSync as existsSync2, readdirSync } from "fs";
|
|
379
|
+
|
|
380
|
+
// packages/core/src/utils/user.ts
|
|
381
|
+
import { memoize as memoize3 } from "lodash-es";
|
|
382
|
+
var getGitEmail = memoize3(async () => {
|
|
383
|
+
const result = await execFileNoThrow("git", ["config", "user.email"]);
|
|
384
|
+
if (result.code !== 0) {
|
|
385
|
+
logError(`Failed to get git email: ${result.stdout} ${result.stderr}`);
|
|
386
|
+
return void 0;
|
|
387
|
+
}
|
|
388
|
+
return result.stdout.trim() || void 0;
|
|
389
|
+
});
|
|
390
|
+
var getUser = memoize3(async () => {
|
|
391
|
+
const userID = getOrCreateUserID();
|
|
392
|
+
const config = getGlobalConfig();
|
|
393
|
+
const email = void 0;
|
|
394
|
+
return {
|
|
395
|
+
customIDs: {
|
|
396
|
+
// for session level tests
|
|
397
|
+
sessionId: SESSION_ID
|
|
398
|
+
},
|
|
399
|
+
userID,
|
|
400
|
+
appVersion: MACRO.VERSION,
|
|
401
|
+
userAgent: env.platform,
|
|
402
|
+
email,
|
|
403
|
+
custom: {
|
|
404
|
+
nodeVersion: env.nodeVersion,
|
|
405
|
+
userType: process.env.USER_TYPE,
|
|
406
|
+
organizationUuid: config.oauthAccount?.organizationUuid,
|
|
407
|
+
accountUuid: config.oauthAccount?.accountUuid
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// packages/core/src/context/index.ts
|
|
413
|
+
async function getInstructionFilesNote() {
|
|
414
|
+
try {
|
|
415
|
+
const cwd = getCwd();
|
|
416
|
+
const instructionFiles = getProjectInstructionFiles(cwd);
|
|
417
|
+
const legacyPath = join2(cwd, "CLAUDE.md");
|
|
418
|
+
const hasLegacy = existsSync2(legacyPath);
|
|
419
|
+
if (instructionFiles.length === 0 && !hasLegacy) {
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
const fileTypes = /* @__PURE__ */ new Set();
|
|
423
|
+
for (const f of instructionFiles) fileTypes.add(f.filename);
|
|
424
|
+
if (hasLegacy) fileTypes.add("CLAUDE.md (legacy)");
|
|
425
|
+
const allFiles = [
|
|
426
|
+
...instructionFiles.map((f) => f.absolutePath),
|
|
427
|
+
...hasLegacy ? [legacyPath] : []
|
|
428
|
+
];
|
|
429
|
+
return `NOTE: Additional project instruction files (${Array.from(fileTypes).join(", ")}) were found. When working in these directories, make sure to read and follow the instructions in the corresponding files:
|
|
430
|
+
${allFiles.map((_) => `- ${_}`).join("\n")}`;
|
|
431
|
+
} catch (error) {
|
|
432
|
+
logError(error);
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function setContext(key, value) {
|
|
437
|
+
const projectConfig = getCurrentProjectConfig();
|
|
438
|
+
const context = omit(
|
|
439
|
+
{ ...projectConfig.context, [key]: value },
|
|
440
|
+
"codeStyle",
|
|
441
|
+
"directoryStructure"
|
|
442
|
+
);
|
|
443
|
+
saveCurrentProjectConfig({ ...projectConfig, context });
|
|
444
|
+
}
|
|
445
|
+
function removeContext(key) {
|
|
446
|
+
const projectConfig = getCurrentProjectConfig();
|
|
447
|
+
const context = omit(
|
|
448
|
+
projectConfig.context,
|
|
449
|
+
key,
|
|
450
|
+
"codeStyle",
|
|
451
|
+
"directoryStructure"
|
|
452
|
+
);
|
|
453
|
+
saveCurrentProjectConfig({ ...projectConfig, context });
|
|
454
|
+
}
|
|
455
|
+
var getReadme = memoize4(async () => {
|
|
456
|
+
try {
|
|
457
|
+
const readmePath = join2(getCwd(), "README.md");
|
|
458
|
+
if (!existsSync2(readmePath)) {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
const content = await readFile(readmePath, "utf-8");
|
|
462
|
+
return content;
|
|
463
|
+
} catch (e) {
|
|
464
|
+
logError(e);
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
async function getProjectDocsForCwd(cwd) {
|
|
469
|
+
try {
|
|
470
|
+
const instructionFiles = getProjectInstructionFiles(cwd);
|
|
471
|
+
const legacyPath = join2(cwd, "CLAUDE.md");
|
|
472
|
+
const docs = [];
|
|
473
|
+
if (instructionFiles.length > 0) {
|
|
474
|
+
const { content } = readAndConcatProjectInstructionFiles(
|
|
475
|
+
instructionFiles,
|
|
476
|
+
{ includeHeadings: true }
|
|
477
|
+
);
|
|
478
|
+
if (content.trim().length > 0) docs.push(content);
|
|
479
|
+
}
|
|
480
|
+
if (existsSync2(legacyPath)) {
|
|
481
|
+
try {
|
|
482
|
+
const content = await readFile(legacyPath, "utf-8");
|
|
483
|
+
docs.push(`# Legacy instructions (CLAUDE.md)
|
|
484
|
+
|
|
485
|
+
${content}`);
|
|
486
|
+
} catch (e) {
|
|
487
|
+
logError(e);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return docs.length > 0 ? docs.join("\n\n---\n\n") : null;
|
|
491
|
+
} catch (e) {
|
|
492
|
+
logError(e);
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
var getProjectDocs = memoize4(async () => {
|
|
497
|
+
return getProjectDocsForCwd(getCwd());
|
|
498
|
+
});
|
|
499
|
+
var getGitStatus = memoize4(async () => {
|
|
500
|
+
if (process.env.NODE_ENV === "test") {
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
503
|
+
if (!await getIsGit()) {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
try {
|
|
507
|
+
const [branch, mainBranch, status, log, authorLog] = await Promise.all([
|
|
508
|
+
execFileNoThrow(
|
|
509
|
+
"git",
|
|
510
|
+
["branch", "--show-current"],
|
|
511
|
+
void 0,
|
|
512
|
+
void 0,
|
|
513
|
+
false
|
|
514
|
+
).then(({ stdout }) => stdout.trim()),
|
|
515
|
+
execFileNoThrow(
|
|
516
|
+
"git",
|
|
517
|
+
["rev-parse", "--abbrev-ref", "origin/HEAD"],
|
|
518
|
+
void 0,
|
|
519
|
+
void 0,
|
|
520
|
+
false
|
|
521
|
+
).then(({ stdout }) => stdout.replace("origin/", "").trim()),
|
|
522
|
+
execFileNoThrow(
|
|
523
|
+
"git",
|
|
524
|
+
["status", "--short"],
|
|
525
|
+
void 0,
|
|
526
|
+
void 0,
|
|
527
|
+
false
|
|
528
|
+
).then(({ stdout }) => stdout.trim()),
|
|
529
|
+
execFileNoThrow(
|
|
530
|
+
"git",
|
|
531
|
+
["log", "--oneline", "-n", "5"],
|
|
532
|
+
void 0,
|
|
533
|
+
void 0,
|
|
534
|
+
false
|
|
535
|
+
).then(({ stdout }) => stdout.trim()),
|
|
536
|
+
execFileNoThrow(
|
|
537
|
+
"git",
|
|
538
|
+
[
|
|
539
|
+
"log",
|
|
540
|
+
"--oneline",
|
|
541
|
+
"-n",
|
|
542
|
+
"5",
|
|
543
|
+
"--author",
|
|
544
|
+
await getGitEmail() || ""
|
|
545
|
+
],
|
|
546
|
+
void 0,
|
|
547
|
+
void 0,
|
|
548
|
+
false
|
|
549
|
+
).then(({ stdout }) => stdout.trim())
|
|
550
|
+
]);
|
|
551
|
+
const statusLines = status.split("\n").length;
|
|
552
|
+
const truncatedStatus = statusLines > 200 ? status.split("\n").slice(0, 200).join("\n") + '\n... (truncated because there are more than 200 lines. If you need more information, run "git status" using BashTool)' : status;
|
|
553
|
+
return `This is the git status at the start of the conversation. Note that this status is a snapshot in time, and will not update during the conversation.
|
|
554
|
+
Current branch: ${branch}
|
|
555
|
+
|
|
556
|
+
Main branch (you will usually use this for PRs): ${mainBranch}
|
|
557
|
+
|
|
558
|
+
Status:
|
|
559
|
+
${truncatedStatus || "(clean)"}
|
|
560
|
+
|
|
561
|
+
Recent commits:
|
|
562
|
+
${log}
|
|
563
|
+
|
|
564
|
+
Your recent commits:
|
|
565
|
+
${authorLog || "(no recent commits)"}`;
|
|
566
|
+
} catch (error) {
|
|
567
|
+
logError(error);
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
var getContext = memoize4(
|
|
572
|
+
async () => {
|
|
573
|
+
const codeStyle = getCodeStyle();
|
|
574
|
+
const projectConfig = getCurrentProjectConfig();
|
|
575
|
+
const dontCrawl = projectConfig.dontCrawlDirectory;
|
|
576
|
+
const [
|
|
577
|
+
gitStatus,
|
|
578
|
+
directoryStructure,
|
|
579
|
+
instructionFilesNote,
|
|
580
|
+
readme,
|
|
581
|
+
projectDocs
|
|
582
|
+
] = await Promise.all([
|
|
583
|
+
getGitStatus(),
|
|
584
|
+
dontCrawl ? Promise.resolve("") : getDirectoryStructure(),
|
|
585
|
+
dontCrawl ? Promise.resolve("") : getInstructionFilesNote(),
|
|
586
|
+
getReadme(),
|
|
587
|
+
getProjectDocs()
|
|
588
|
+
]);
|
|
589
|
+
return {
|
|
590
|
+
...projectConfig.context,
|
|
591
|
+
...directoryStructure ? { directoryStructure } : {},
|
|
592
|
+
...gitStatus ? { gitStatus } : {},
|
|
593
|
+
...codeStyle ? { codeStyle } : {},
|
|
594
|
+
...instructionFilesNote ? { instructionFilesNote } : {},
|
|
595
|
+
...readme ? { readme } : {},
|
|
596
|
+
...projectDocs ? { projectDocs } : {}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
var getDirectoryStructure = memoize4(
|
|
601
|
+
async function() {
|
|
602
|
+
let lines;
|
|
603
|
+
try {
|
|
604
|
+
const entries = readdirSync(getCwd(), { withFileTypes: true });
|
|
605
|
+
lines = entries.map((entry) => `${entry.isDirectory() ? "d" : "f"} ${entry.name}`).join("\n");
|
|
606
|
+
} catch (error) {
|
|
607
|
+
logError(error);
|
|
608
|
+
return "";
|
|
609
|
+
}
|
|
610
|
+
return `Below is a snapshot of this project's file structure at the start of the conversation. This snapshot will NOT update during the conversation.
|
|
611
|
+
|
|
612
|
+
${lines}`;
|
|
613
|
+
}
|
|
614
|
+
);
|
|
615
|
+
|
|
616
|
+
// packages/core/src/ai/llm/kodeContext.ts
|
|
617
|
+
var KodeContextManager = class _KodeContextManager {
|
|
618
|
+
static instance;
|
|
619
|
+
projectDocsCache = "";
|
|
620
|
+
cacheInitialized = false;
|
|
621
|
+
initPromise = null;
|
|
622
|
+
static getInstance() {
|
|
623
|
+
if (!_KodeContextManager.instance) {
|
|
624
|
+
_KodeContextManager.instance = new _KodeContextManager();
|
|
625
|
+
}
|
|
626
|
+
return _KodeContextManager.instance;
|
|
627
|
+
}
|
|
628
|
+
async initialize() {
|
|
629
|
+
if (this.initPromise) return this.initPromise;
|
|
630
|
+
this.initPromise = (async () => {
|
|
631
|
+
try {
|
|
632
|
+
const projectDocs = await getProjectDocs();
|
|
633
|
+
this.projectDocsCache = projectDocs || "";
|
|
634
|
+
this.cacheInitialized = true;
|
|
635
|
+
} catch (error) {
|
|
636
|
+
logError(error);
|
|
637
|
+
debug.warn("KODE_CONTEXT_LOAD_FAILED", {
|
|
638
|
+
error: error instanceof Error ? error.message : String(error)
|
|
639
|
+
});
|
|
640
|
+
this.projectDocsCache = "";
|
|
641
|
+
this.cacheInitialized = true;
|
|
642
|
+
}
|
|
643
|
+
})();
|
|
644
|
+
return this.initPromise;
|
|
645
|
+
}
|
|
646
|
+
getKodeContext() {
|
|
647
|
+
if (!this.cacheInitialized) {
|
|
648
|
+
this.initialize().catch((error) => {
|
|
649
|
+
logError(error);
|
|
650
|
+
debug.warn("KODE_CONTEXT_LOAD_FAILED", {
|
|
651
|
+
error: error instanceof Error ? error.message : String(error)
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
return "";
|
|
655
|
+
}
|
|
656
|
+
return this.projectDocsCache;
|
|
657
|
+
}
|
|
658
|
+
async refreshCache() {
|
|
659
|
+
this.cacheInitialized = false;
|
|
660
|
+
this.initPromise = null;
|
|
661
|
+
await this.initialize();
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
var kodeContextManager = KodeContextManager.getInstance();
|
|
665
|
+
var generateKodeContext = () => {
|
|
666
|
+
return kodeContextManager.getKodeContext();
|
|
667
|
+
};
|
|
668
|
+
var refreshKodeContext = async () => {
|
|
669
|
+
await kodeContextManager.refreshCache();
|
|
670
|
+
};
|
|
671
|
+
if (process.env.NODE_ENV !== "test") {
|
|
672
|
+
setTimeout(() => {
|
|
673
|
+
refreshKodeContext().catch(() => {
|
|
674
|
+
});
|
|
675
|
+
}, 0);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// packages/core/src/services/systemPrompt.ts
|
|
679
|
+
function isGPT5Model(modelName) {
|
|
680
|
+
return modelName.startsWith("gpt-5");
|
|
681
|
+
}
|
|
682
|
+
function formatSystemPromptWithContext(systemPrompt, context, agentId, skipContextReminders = false) {
|
|
683
|
+
const enhancedPrompt = [...systemPrompt];
|
|
684
|
+
let reminders = "";
|
|
685
|
+
const modelManager = getModelManager();
|
|
686
|
+
const modelProfile = modelManager.getModel("main");
|
|
687
|
+
if (modelProfile && isGPT5Model(modelProfile.modelName)) {
|
|
688
|
+
const persistencePrompts = [
|
|
689
|
+
"\n# Agent Persistence for Long-Running Coding Tasks",
|
|
690
|
+
"You are working on a coding project that may involve multiple steps and iterations. Please maintain context and continuity throughout the session:",
|
|
691
|
+
"- Remember architectural decisions and design patterns established earlier",
|
|
692
|
+
"- Keep track of file modifications and their relationships",
|
|
693
|
+
"- Maintain awareness of the overall project structure and goals",
|
|
694
|
+
"- Reference previous implementations when making related changes",
|
|
695
|
+
"- Ensure consistency with existing code style and conventions",
|
|
696
|
+
"- Build incrementally on previous work rather than starting from scratch"
|
|
697
|
+
];
|
|
698
|
+
enhancedPrompt.push(...persistencePrompts);
|
|
699
|
+
}
|
|
700
|
+
const hasContext = Object.entries(context).length > 0;
|
|
701
|
+
if (hasContext) {
|
|
702
|
+
if (!skipContextReminders) {
|
|
703
|
+
const kodeContext = generateKodeContext();
|
|
704
|
+
if (kodeContext) {
|
|
705
|
+
enhancedPrompt.push("\n---\n# \u9879\u76EE\u4E0A\u4E0B\u6587\n");
|
|
706
|
+
enhancedPrompt.push(kodeContext);
|
|
707
|
+
enhancedPrompt.push("\n---\n");
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
const reminderMessages = generateSystemReminders(hasContext, agentId);
|
|
711
|
+
if (reminderMessages.length > 0) {
|
|
712
|
+
reminders = reminderMessages.map((r) => r.content).join("\n") + "\n";
|
|
713
|
+
}
|
|
714
|
+
enhancedPrompt.push(
|
|
715
|
+
`
|
|
716
|
+
As you answer the user's questions, you can use the following context:
|
|
717
|
+
`
|
|
718
|
+
);
|
|
719
|
+
const filteredContext = Object.fromEntries(
|
|
720
|
+
Object.entries(context).filter(
|
|
721
|
+
([key]) => key !== "projectDocs" && key !== "userDocs"
|
|
722
|
+
)
|
|
723
|
+
);
|
|
724
|
+
enhancedPrompt.push(
|
|
725
|
+
...Object.entries(filteredContext).map(
|
|
726
|
+
([key, value]) => `<context name="${key}">${value}</context>`
|
|
727
|
+
)
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
return { systemPrompt: enhancedPrompt, reminders };
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
export {
|
|
734
|
+
getCLISyspromptPrefix,
|
|
735
|
+
getSystemPrompt,
|
|
736
|
+
getAgentPrompt,
|
|
737
|
+
getCodeStyle,
|
|
738
|
+
setContext,
|
|
739
|
+
removeContext,
|
|
740
|
+
getContext,
|
|
741
|
+
generateKodeContext,
|
|
742
|
+
refreshKodeContext,
|
|
743
|
+
formatSystemPromptWithContext
|
|
744
|
+
};
|