@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.
Files changed (343) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +649 -25
  3. package/README.zh-CN.md +579 -0
  4. package/cli-acp.js +3 -17
  5. package/cli.js +5 -7
  6. package/dist/chunks/Doctor-M3J7GRTJ.js +12 -0
  7. package/dist/chunks/LogList-ISWZ6DDD.js +121 -0
  8. package/dist/chunks/LogList-ISWZ6DDD.js.map +7 -0
  9. package/dist/chunks/REPL-RQ6LO6S7.js +56 -0
  10. package/dist/chunks/ResumeConversation-6DMVBEGH.js +56 -0
  11. package/dist/chunks/agentLoader-FCRG3TFJ.js +31 -0
  12. package/dist/{agentsValidate-7LH4HTNR.js → chunks/agentsValidate-PEWMYN4Q.js} +97 -69
  13. package/dist/chunks/agentsValidate-PEWMYN4Q.js.map +7 -0
  14. package/dist/{ask-3NHFFUQG.js → chunks/ask-D7SOHJ6Z.js} +36 -44
  15. package/dist/chunks/ask-D7SOHJ6Z.js.map +7 -0
  16. package/dist/chunks/autoUpdater-CNESBOKO.js +19 -0
  17. package/dist/{chunk-AFFSCMYS.js → chunks/chunk-2JN5MY67.js} +12 -14
  18. package/dist/chunks/chunk-2JN5MY67.js.map +7 -0
  19. package/dist/chunks/chunk-2QONJ5MG.js +14 -0
  20. package/dist/chunks/chunk-2QONJ5MG.js.map +7 -0
  21. package/dist/chunks/chunk-2WEXPKHH.js +903 -0
  22. package/dist/chunks/chunk-2WEXPKHH.js.map +7 -0
  23. package/dist/{chunk-ARZSBOAO.js → chunks/chunk-3BYE3ME6.js} +717 -792
  24. package/dist/chunks/chunk-3BYE3ME6.js.map +7 -0
  25. package/dist/chunks/chunk-3JDNWX7W.js +1264 -0
  26. package/dist/chunks/chunk-3JDNWX7W.js.map +7 -0
  27. package/dist/chunks/chunk-3OEJVB5A.js +906 -0
  28. package/dist/chunks/chunk-3OEJVB5A.js.map +7 -0
  29. package/dist/chunks/chunk-3TNIOEBO.js +369 -0
  30. package/dist/chunks/chunk-3TNIOEBO.js.map +7 -0
  31. package/dist/chunks/chunk-4A46ZXMJ.js +67 -0
  32. package/dist/chunks/chunk-4A46ZXMJ.js.map +7 -0
  33. package/dist/{chunk-UHYRLID6.js → chunks/chunk-4ATBQOFO.js} +107 -55
  34. package/dist/chunks/chunk-4ATBQOFO.js.map +7 -0
  35. package/dist/chunks/chunk-4CRUCZR4.js +0 -0
  36. package/dist/{chunk-YC6LJCDE.js → chunks/chunk-4EO6SIQY.js} +32 -75
  37. package/dist/chunks/chunk-4EO6SIQY.js.map +7 -0
  38. package/dist/chunks/chunk-53M46S5I.js +64 -0
  39. package/dist/chunks/chunk-53M46S5I.js.map +7 -0
  40. package/dist/{chunk-JC6NCUG5.js → chunks/chunk-54KOYG5C.js} +0 -2
  41. package/dist/{chunk-EZXMVTDU.js → chunks/chunk-6BAS4WY6.js} +29 -45
  42. package/dist/chunks/chunk-6BAS4WY6.js.map +7 -0
  43. package/dist/{chunk-3IN27HA5.js → chunks/chunk-6KRRFSDN.js} +4 -6
  44. package/dist/chunks/chunk-6KRRFSDN.js.map +7 -0
  45. package/dist/chunks/chunk-6LJNZK4K.js +39 -0
  46. package/dist/chunks/chunk-6LJNZK4K.js.map +7 -0
  47. package/dist/chunks/chunk-6ZWEOSEI.js +666 -0
  48. package/dist/chunks/chunk-6ZWEOSEI.js.map +7 -0
  49. package/dist/chunks/chunk-77XDJMBP.js +3326 -0
  50. package/dist/chunks/chunk-77XDJMBP.js.map +7 -0
  51. package/dist/chunks/chunk-7RRW4NTB.js +6454 -0
  52. package/dist/chunks/chunk-7RRW4NTB.js.map +7 -0
  53. package/dist/chunks/chunk-7X3TW4JB.js +4520 -0
  54. package/dist/chunks/chunk-7X3TW4JB.js.map +7 -0
  55. package/dist/chunks/chunk-B3MW3YGY.js +1409 -0
  56. package/dist/chunks/chunk-B3MW3YGY.js.map +7 -0
  57. package/dist/chunks/chunk-BBJFHTBC.js +28 -0
  58. package/dist/chunks/chunk-BBJFHTBC.js.map +7 -0
  59. package/dist/chunks/chunk-BHDHXOXB.js +24 -0
  60. package/dist/chunks/chunk-BHDHXOXB.js.map +7 -0
  61. package/dist/{chunk-73WGVYLQ.js → chunks/chunk-BTA7SZ26.js} +152 -223
  62. package/dist/chunks/chunk-BTA7SZ26.js.map +7 -0
  63. package/dist/chunks/chunk-CDGRYGPZ.js +103 -0
  64. package/dist/chunks/chunk-CDGRYGPZ.js.map +7 -0
  65. package/dist/{chunk-S6HRABTA.js → chunks/chunk-CP6E5UG6.js} +1 -4
  66. package/dist/chunks/chunk-CP6E5UG6.js.map +7 -0
  67. package/dist/{chunk-QVLYOPO5.js → chunks/chunk-DQ4JHXMT.js} +462 -424
  68. package/dist/chunks/chunk-DQ4JHXMT.js.map +7 -0
  69. package/dist/chunks/chunk-DXD76CMV.js +208 -0
  70. package/dist/chunks/chunk-DXD76CMV.js.map +7 -0
  71. package/dist/chunks/chunk-GCQCAXJZ.js +0 -0
  72. package/dist/chunks/chunk-GELCZWMB.js +42 -0
  73. package/dist/chunks/chunk-GELCZWMB.js.map +7 -0
  74. package/dist/{chunk-K2CWOTI2.js → chunks/chunk-HJYOH4HC.js} +23 -18
  75. package/dist/chunks/chunk-HJYOH4HC.js.map +7 -0
  76. package/dist/chunks/chunk-HPYNW6TT.js +744 -0
  77. package/dist/chunks/chunk-HPYNW6TT.js.map +7 -0
  78. package/dist/{chunk-RZWOUA25.js → chunks/chunk-HRJ3ICQK.js} +59 -55
  79. package/dist/chunks/chunk-HRJ3ICQK.js.map +7 -0
  80. package/dist/{chunk-DZE5YA7L.js → chunks/chunk-IFCIADS3.js} +571 -573
  81. package/dist/chunks/chunk-IFCIADS3.js.map +7 -0
  82. package/dist/chunks/chunk-IN7XZ7BC.js +27 -0
  83. package/dist/chunks/chunk-IN7XZ7BC.js.map +7 -0
  84. package/dist/chunks/chunk-L7P4M4KW.js +193 -0
  85. package/dist/chunks/chunk-L7P4M4KW.js.map +7 -0
  86. package/dist/chunks/chunk-LB6TCPDI.js +0 -0
  87. package/dist/{chunk-3RUXVV4S.js → chunks/chunk-LOCXPQNJ.js} +1 -4
  88. package/dist/{chunk-3RUXVV4S.js.map → chunks/chunk-LOCXPQNJ.js.map} +2 -2
  89. package/dist/{chunk-7M2YN6TU.js → chunks/chunk-LOD5ZHCI.js} +213 -208
  90. package/dist/chunks/chunk-LOD5ZHCI.js.map +7 -0
  91. package/dist/{chunk-S3J2TLV6.js → chunks/chunk-M7P3QNRU.js} +1 -4
  92. package/dist/{chunk-S3J2TLV6.js.map → chunks/chunk-M7P3QNRU.js.map} +2 -2
  93. package/dist/chunks/chunk-PPHLQVL7.js +4234 -0
  94. package/dist/chunks/chunk-PPHLQVL7.js.map +7 -0
  95. package/dist/{chunk-ABLVTESJ.js → chunks/chunk-QAXE37B5.js} +1 -4
  96. package/dist/chunks/chunk-QAXE37B5.js.map +7 -0
  97. package/dist/chunks/chunk-QHQOBUF6.js +60 -0
  98. package/dist/chunks/chunk-QHQOBUF6.js.map +7 -0
  99. package/dist/{chunk-W7GRKO7Q.js → chunks/chunk-RPJXO7GG.js} +241 -214
  100. package/dist/chunks/chunk-RPJXO7GG.js.map +7 -0
  101. package/dist/{chunk-NPFOMITO.js → chunks/chunk-SWQV4KSY.js} +1 -4
  102. package/dist/{chunk-NPFOMITO.js.map → chunks/chunk-SWQV4KSY.js.map} +2 -2
  103. package/dist/chunks/chunk-SZLAPULP.js +28 -0
  104. package/dist/chunks/chunk-SZLAPULP.js.map +7 -0
  105. package/dist/{chunk-7U7L4NMD.js → chunks/chunk-T7RB5V5J.js} +23 -25
  106. package/dist/chunks/chunk-T7RB5V5J.js.map +7 -0
  107. package/dist/{chunk-HN4E4UUQ.js → chunks/chunk-TI2CTTMA.js} +25 -17
  108. package/dist/chunks/chunk-TI2CTTMA.js.map +7 -0
  109. package/dist/{chunk-ZVDRDPII.js → chunks/chunk-TNGVRTO5.js} +45 -20
  110. package/dist/chunks/chunk-TNGVRTO5.js.map +7 -0
  111. package/dist/chunks/chunk-TNWB3U5Y.js +2077 -0
  112. package/dist/chunks/chunk-TNWB3U5Y.js.map +7 -0
  113. package/dist/chunks/chunk-U2IHWPCU.js +12 -0
  114. package/dist/chunks/chunk-U2IHWPCU.js.map +7 -0
  115. package/dist/{chunk-KAA5BGMQ.js → chunks/chunk-UNOY3VJ2.js} +1 -4
  116. package/dist/{chunk-KAA5BGMQ.js.map → chunks/chunk-UNOY3VJ2.js.map} +2 -2
  117. package/dist/{chunk-MWRSY4X6.js → chunks/chunk-UVDJL6ZZ.js} +97 -58
  118. package/dist/chunks/chunk-UVDJL6ZZ.js.map +7 -0
  119. package/dist/chunks/chunk-VNCW4C2Z.js +13452 -0
  120. package/dist/chunks/chunk-VNCW4C2Z.js.map +7 -0
  121. package/dist/chunks/chunk-W5EGGA44.js +15 -0
  122. package/dist/chunks/chunk-W5EGGA44.js.map +7 -0
  123. package/dist/chunks/chunk-XR2W3MAM.js +1533 -0
  124. package/dist/chunks/chunk-XR2W3MAM.js.map +7 -0
  125. package/dist/{chunk-STSX7GIX.js → chunks/chunk-YIO5EBMQ.js} +423 -377
  126. package/dist/chunks/chunk-YIO5EBMQ.js.map +7 -0
  127. package/dist/chunks/chunk-ZBVLKZ5V.js +1062 -0
  128. package/dist/chunks/chunk-ZBVLKZ5V.js.map +7 -0
  129. package/dist/{chunk-E6YNABER.js → chunks/chunk-ZCLTZIVP.js} +1 -4
  130. package/dist/chunks/chunk-ZCLTZIVP.js.map +7 -0
  131. package/dist/chunks/client-SILZNM5N.js +42 -0
  132. package/dist/{config-RUSD6G5Y.js → chunks/config-25HRTPSP.js} +48 -10
  133. package/dist/chunks/cost-tracker-Z2UZT2J5.js +28 -0
  134. package/dist/{customCommands-TOIJFZAL.js → chunks/customCommands-TYMYZRG5.js} +11 -8
  135. package/dist/chunks/engine-MRVF6FK6.js +39 -0
  136. package/dist/{env-XGKBLU3D.js → chunks/env-TJ5NOBEB.js} +7 -5
  137. package/dist/{kodeAgentSessionId-X6XWQW7B.js → chunks/kodeAgentSessionId-VTNISJ2L.js} +2 -4
  138. package/dist/chunks/kodeAgentSessionLoad-YB2RKBGJ.js +15 -0
  139. package/dist/chunks/kodeAgentSessionResume-DZSIVKVA.js +13 -0
  140. package/dist/chunks/kodeAgentStreamJson-X5PLS2S6.js +11 -0
  141. package/dist/{kodeAgentStreamJsonSession-UGEZJJEB.js → chunks/kodeAgentStreamJsonSession-RDXM4XYF.js} +38 -24
  142. package/dist/chunks/kodeAgentStreamJsonSession-RDXM4XYF.js.map +7 -0
  143. package/dist/{chunk-4RTX4AG4.js → chunks/kodeAgentStructuredStdio-SVGDSB4P.js} +14 -9
  144. package/dist/chunks/kodeAgentStructuredStdio-SVGDSB4P.js.map +7 -0
  145. package/dist/{kodeHooks-QWM36A3D.js → chunks/kodeHooks-RVKYRJHG.js} +11 -9
  146. package/dist/{llm-ZUQC4WYM.js → chunks/llm-62N6T5ZT.js} +1734 -1526
  147. package/dist/chunks/llm-62N6T5ZT.js.map +7 -0
  148. package/dist/chunks/llmLazy-ZUSSE3ZA.js +13 -0
  149. package/dist/{mentionProcessor-EE3XFHCJ.js → chunks/mentionProcessor-RJW5UPJD.js} +46 -16
  150. package/dist/chunks/mentionProcessor-RJW5UPJD.js.map +7 -0
  151. package/dist/{messages-EOYQKPGM.js → chunks/messages-EEWWLPHN.js} +2 -6
  152. package/dist/chunks/model-5TIEKQPD.js +37 -0
  153. package/dist/{openai-RRCWW33N.js → chunks/openai-XXK3YZG4.js} +13 -10
  154. package/dist/{outputStyles-62Q3VH2J.js → chunks/outputStyles-FAJTXN2A.js} +6 -9
  155. package/dist/chunks/permissions-HO7INPWM.js +27 -0
  156. package/dist/{pluginRuntime-6ETCZ2LL.js → chunks/pluginRuntime-C7K5ULK2.js} +31 -48
  157. package/dist/chunks/pluginRuntime-C7K5ULK2.js.map +7 -0
  158. package/dist/chunks/pluginValidation-DAM7WRTC.js +20 -0
  159. package/dist/chunks/registry-XYJXMOA5.js +60 -0
  160. package/dist/chunks/responsesStreaming-JNGE2P3D.js +8 -0
  161. package/dist/chunks/runNonTextPrintMode-SVBLCZQX.js +577 -0
  162. package/dist/chunks/runNonTextPrintMode-SVBLCZQX.js.map +7 -0
  163. package/dist/chunks/server-REXXF5IK.js +46 -0
  164. package/dist/{skillMarketplace-3RXQBVOL.js → chunks/skillMarketplace-N4HVHNST.js} +8 -6
  165. package/dist/chunks/src-OROQIWP3.js +44 -0
  166. package/dist/chunks/src-QXLGGMUW.js +1647 -0
  167. package/dist/chunks/src-QXLGGMUW.js.map +7 -0
  168. package/dist/{cli-DOPVY2CW.js → chunks/src-SSDT6MVP.js} +2659 -3384
  169. package/dist/chunks/src-SSDT6MVP.js.map +7 -0
  170. package/dist/chunks/theme-YBJUIMWK.js +10 -0
  171. package/dist/{toolPermissionContext-65L65VEZ.js → chunks/toolPermissionContext-MOCTRR7N.js} +2 -4
  172. package/dist/chunks/toolPermissionSettings-EV2EJAXL.js +18 -0
  173. package/dist/chunks/toolPermissionSettings-EV2EJAXL.js.map +7 -0
  174. package/dist/chunks/uuid-6577SO6X.js +7 -0
  175. package/dist/chunks/uuid-6577SO6X.js.map +7 -0
  176. package/dist/chunks/webOnlyMode-ALXX7UQY.js +66 -0
  177. package/dist/chunks/webOnlyMode-ALXX7UQY.js.map +7 -0
  178. package/dist/entrypoints/cli.js +10 -0
  179. package/dist/entrypoints/cli.js.map +7 -0
  180. package/dist/entrypoints/daemon.js +10 -0
  181. package/dist/entrypoints/daemon.js.map +7 -0
  182. package/dist/entrypoints/mcp.js +71 -0
  183. package/dist/entrypoints/mcp.js.map +7 -0
  184. package/dist/index.js +6 -7
  185. package/dist/index.js.map +3 -3
  186. package/dist/sdk/client.cjs +391 -0
  187. package/dist/sdk/client.cjs.map +7 -0
  188. package/dist/sdk/client.js +364 -0
  189. package/dist/sdk/client.js.map +7 -0
  190. package/dist/sdk/core.cjs +19932 -0
  191. package/dist/sdk/core.cjs.map +7 -0
  192. package/dist/sdk/core.js +19893 -0
  193. package/dist/sdk/core.js.map +7 -0
  194. package/dist/sdk/daemon-client.cjs +257 -0
  195. package/dist/sdk/daemon-client.cjs.map +7 -0
  196. package/dist/sdk/daemon-client.js +221 -0
  197. package/dist/sdk/daemon-client.js.map +7 -0
  198. package/dist/sdk/protocol.cjs +170 -0
  199. package/dist/sdk/protocol.cjs.map +7 -0
  200. package/dist/sdk/protocol.js +140 -0
  201. package/dist/sdk/protocol.js.map +7 -0
  202. package/dist/sdk/runtime-node.cjs +236 -0
  203. package/dist/sdk/runtime-node.cjs.map +7 -0
  204. package/dist/sdk/runtime-node.js +222 -0
  205. package/dist/sdk/runtime-node.js.map +7 -0
  206. package/dist/sdk/runtime.cjs +17 -0
  207. package/dist/sdk/runtime.cjs.map +7 -0
  208. package/dist/sdk/runtime.js +0 -0
  209. package/dist/sdk/runtime.js.map +7 -0
  210. package/dist/sdk/tools.cjs +30300 -0
  211. package/dist/sdk/tools.cjs.map +7 -0
  212. package/dist/sdk/tools.js +30282 -0
  213. package/dist/sdk/tools.js.map +7 -0
  214. package/dist/webui/assets/index-5hlfByVS.css +1 -0
  215. package/dist/webui/assets/index-BR9lm1lA.js +82 -0
  216. package/dist/webui/index.html +28 -0
  217. package/package.json +93 -22
  218. package/scripts/binary-utils.cjs +12 -4
  219. package/scripts/cli-acp-wrapper.cjs +3 -17
  220. package/scripts/cli-wrapper.cjs +5 -7
  221. package/scripts/postinstall.js +8 -4
  222. package/dist/REPL-CW7AYLVL.js +0 -42
  223. package/dist/acp-VEPJ74LT.js +0 -1357
  224. package/dist/acp-VEPJ74LT.js.map +0 -7
  225. package/dist/agentsValidate-7LH4HTNR.js.map +0 -7
  226. package/dist/ask-3NHFFUQG.js.map +0 -7
  227. package/dist/autoUpdater-ITPIHCOI.js +0 -17
  228. package/dist/chunk-3IN27HA5.js.map +0 -7
  229. package/dist/chunk-4FX3IVPT.js +0 -164
  230. package/dist/chunk-4FX3IVPT.js.map +0 -7
  231. package/dist/chunk-4RTX4AG4.js.map +0 -7
  232. package/dist/chunk-5PDP7R6N.js +0 -515
  233. package/dist/chunk-5PDP7R6N.js.map +0 -7
  234. package/dist/chunk-73WGVYLQ.js.map +0 -7
  235. package/dist/chunk-7M2YN6TU.js.map +0 -7
  236. package/dist/chunk-7U7L4NMD.js.map +0 -7
  237. package/dist/chunk-ABLVTESJ.js.map +0 -7
  238. package/dist/chunk-AFFSCMYS.js.map +0 -7
  239. package/dist/chunk-ARZSBOAO.js.map +0 -7
  240. package/dist/chunk-CIG63V4E.js +0 -72
  241. package/dist/chunk-CIG63V4E.js.map +0 -7
  242. package/dist/chunk-CM3EGTG6.js +0 -1609
  243. package/dist/chunk-CM3EGTG6.js.map +0 -7
  244. package/dist/chunk-DZE5YA7L.js.map +0 -7
  245. package/dist/chunk-E6YNABER.js.map +0 -7
  246. package/dist/chunk-EZXMVTDU.js.map +0 -7
  247. package/dist/chunk-F2SJXUDI.js +0 -148
  248. package/dist/chunk-F2SJXUDI.js.map +0 -7
  249. package/dist/chunk-FC5ZCKBI.js +0 -30167
  250. package/dist/chunk-FC5ZCKBI.js.map +0 -7
  251. package/dist/chunk-HCBELH4J.js +0 -145
  252. package/dist/chunk-HCBELH4J.js.map +0 -7
  253. package/dist/chunk-HN4E4UUQ.js.map +0 -7
  254. package/dist/chunk-IZVMU4S2.js +0 -654
  255. package/dist/chunk-IZVMU4S2.js.map +0 -7
  256. package/dist/chunk-K2CWOTI2.js.map +0 -7
  257. package/dist/chunk-LC4TVOCZ.js +0 -835
  258. package/dist/chunk-LC4TVOCZ.js.map +0 -7
  259. package/dist/chunk-MIW7N2MY.js +0 -2613
  260. package/dist/chunk-MIW7N2MY.js.map +0 -7
  261. package/dist/chunk-MWRSY4X6.js.map +0 -7
  262. package/dist/chunk-ND3XWFO6.js +0 -34
  263. package/dist/chunk-ND3XWFO6.js.map +0 -7
  264. package/dist/chunk-QVLYOPO5.js.map +0 -7
  265. package/dist/chunk-RZWOUA25.js.map +0 -7
  266. package/dist/chunk-S6HRABTA.js.map +0 -7
  267. package/dist/chunk-STSX7GIX.js.map +0 -7
  268. package/dist/chunk-UHYRLID6.js.map +0 -7
  269. package/dist/chunk-UKHTVRJM.js +0 -47
  270. package/dist/chunk-UKHTVRJM.js.map +0 -7
  271. package/dist/chunk-UYXEDKOZ.js +0 -24
  272. package/dist/chunk-UYXEDKOZ.js.map +0 -7
  273. package/dist/chunk-W7GRKO7Q.js.map +0 -7
  274. package/dist/chunk-WVHORZQ5.js +0 -17
  275. package/dist/chunk-WVHORZQ5.js.map +0 -7
  276. package/dist/chunk-WWUWDNWW.js +0 -49
  277. package/dist/chunk-WWUWDNWW.js.map +0 -7
  278. package/dist/chunk-YC6LJCDE.js.map +0 -7
  279. package/dist/chunk-YXYYDIMI.js +0 -2931
  280. package/dist/chunk-YXYYDIMI.js.map +0 -7
  281. package/dist/chunk-ZVDRDPII.js.map +0 -7
  282. package/dist/cli-DOPVY2CW.js.map +0 -7
  283. package/dist/commands-2BF2CJ3A.js +0 -46
  284. package/dist/context-6FXPETYH.js +0 -30
  285. package/dist/costTracker-6SL26FDB.js +0 -19
  286. package/dist/kodeAgentSessionLoad-MITZADPB.js +0 -18
  287. package/dist/kodeAgentSessionResume-GVRWB4WO.js +0 -16
  288. package/dist/kodeAgentStreamJson-NXFN7TXH.js +0 -13
  289. package/dist/kodeAgentStreamJsonSession-UGEZJJEB.js.map +0 -7
  290. package/dist/kodeAgentStructuredStdio-HGWJT7CU.js +0 -10
  291. package/dist/llm-ZUQC4WYM.js.map +0 -7
  292. package/dist/llmLazy-54QQHA54.js +0 -15
  293. package/dist/loader-FYHJQES5.js +0 -28
  294. package/dist/mcp-J332IKT3.js +0 -49
  295. package/dist/mentionProcessor-EE3XFHCJ.js.map +0 -7
  296. package/dist/model-FV3JDJKH.js +0 -30
  297. package/dist/pluginRuntime-6ETCZ2LL.js.map +0 -7
  298. package/dist/pluginValidation-I4YKUWGS.js +0 -17
  299. package/dist/prompts-ZLEKDD77.js +0 -48
  300. package/dist/query-VFRJPBGD.js +0 -50
  301. package/dist/responsesStreaming-AW344PQO.js +0 -10
  302. package/dist/ripgrep-3NTIKQYW.js +0 -17
  303. package/dist/state-P5G6CO5V.js +0 -16
  304. package/dist/theme-3LWP3BG7.js +0 -14
  305. package/dist/toolPermissionSettings-3ROBVTUK.js +0 -18
  306. package/dist/tools-RO7HSSE5.js +0 -47
  307. package/dist/userInput-JSBJRFSK.js +0 -311
  308. package/dist/userInput-JSBJRFSK.js.map +0 -7
  309. package/dist/uuid-QN2CNKKN.js +0 -9
  310. /package/dist/{REPL-CW7AYLVL.js.map → chunks/Doctor-M3J7GRTJ.js.map} +0 -0
  311. /package/dist/{autoUpdater-ITPIHCOI.js.map → chunks/REPL-RQ6LO6S7.js.map} +0 -0
  312. /package/dist/{chunk-JC6NCUG5.js.map → chunks/ResumeConversation-6DMVBEGH.js.map} +0 -0
  313. /package/dist/{commands-2BF2CJ3A.js.map → chunks/agentLoader-FCRG3TFJ.js.map} +0 -0
  314. /package/dist/{config-RUSD6G5Y.js.map → chunks/autoUpdater-CNESBOKO.js.map} +0 -0
  315. /package/dist/{context-6FXPETYH.js.map → chunks/chunk-4CRUCZR4.js.map} +0 -0
  316. /package/dist/{costTracker-6SL26FDB.js.map → chunks/chunk-54KOYG5C.js.map} +0 -0
  317. /package/dist/{customCommands-TOIJFZAL.js.map → chunks/chunk-GCQCAXJZ.js.map} +0 -0
  318. /package/dist/{env-XGKBLU3D.js.map → chunks/chunk-LB6TCPDI.js.map} +0 -0
  319. /package/dist/{kodeAgentSessionId-X6XWQW7B.js.map → chunks/client-SILZNM5N.js.map} +0 -0
  320. /package/dist/{kodeAgentSessionLoad-MITZADPB.js.map → chunks/config-25HRTPSP.js.map} +0 -0
  321. /package/dist/{kodeAgentSessionResume-GVRWB4WO.js.map → chunks/cost-tracker-Z2UZT2J5.js.map} +0 -0
  322. /package/dist/{kodeAgentStreamJson-NXFN7TXH.js.map → chunks/customCommands-TYMYZRG5.js.map} +0 -0
  323. /package/dist/{kodeAgentStructuredStdio-HGWJT7CU.js.map → chunks/engine-MRVF6FK6.js.map} +0 -0
  324. /package/dist/{kodeHooks-QWM36A3D.js.map → chunks/env-TJ5NOBEB.js.map} +0 -0
  325. /package/dist/{llmLazy-54QQHA54.js.map → chunks/kodeAgentSessionId-VTNISJ2L.js.map} +0 -0
  326. /package/dist/{loader-FYHJQES5.js.map → chunks/kodeAgentSessionLoad-YB2RKBGJ.js.map} +0 -0
  327. /package/dist/{mcp-J332IKT3.js.map → chunks/kodeAgentSessionResume-DZSIVKVA.js.map} +0 -0
  328. /package/dist/{messages-EOYQKPGM.js.map → chunks/kodeAgentStreamJson-X5PLS2S6.js.map} +0 -0
  329. /package/dist/{model-FV3JDJKH.js.map → chunks/kodeHooks-RVKYRJHG.js.map} +0 -0
  330. /package/dist/{openai-RRCWW33N.js.map → chunks/llmLazy-ZUSSE3ZA.js.map} +0 -0
  331. /package/dist/{outputStyles-62Q3VH2J.js.map → chunks/messages-EEWWLPHN.js.map} +0 -0
  332. /package/dist/{pluginValidation-I4YKUWGS.js.map → chunks/model-5TIEKQPD.js.map} +0 -0
  333. /package/dist/{prompts-ZLEKDD77.js.map → chunks/openai-XXK3YZG4.js.map} +0 -0
  334. /package/dist/{query-VFRJPBGD.js.map → chunks/outputStyles-FAJTXN2A.js.map} +0 -0
  335. /package/dist/{responsesStreaming-AW344PQO.js.map → chunks/permissions-HO7INPWM.js.map} +0 -0
  336. /package/dist/{ripgrep-3NTIKQYW.js.map → chunks/pluginValidation-DAM7WRTC.js.map} +0 -0
  337. /package/dist/{skillMarketplace-3RXQBVOL.js.map → chunks/registry-XYJXMOA5.js.map} +0 -0
  338. /package/dist/{state-P5G6CO5V.js.map → chunks/responsesStreaming-JNGE2P3D.js.map} +0 -0
  339. /package/dist/{theme-3LWP3BG7.js.map → chunks/server-REXXF5IK.js.map} +0 -0
  340. /package/dist/{toolPermissionContext-65L65VEZ.js.map → chunks/skillMarketplace-N4HVHNST.js.map} +0 -0
  341. /package/dist/{toolPermissionSettings-3ROBVTUK.js.map → chunks/src-OROQIWP3.js.map} +0 -0
  342. /package/dist/{tools-RO7HSSE5.js.map → chunks/theme-YBJUIMWK.js.map} +0 -0
  343. /package/dist/{uuid-QN2CNKKN.js.map → chunks/toolPermissionContext-MOCTRR7N.js.map} +0 -0
@@ -0,0 +1,906 @@
1
+ import {
2
+ getCwd
3
+ } from "./chunk-BBJFHTBC.js";
4
+ import {
5
+ PLAN_SLUG_ADJECTIVES,
6
+ PLAN_SLUG_NOUNS,
7
+ PLAN_SLUG_VERBS
8
+ } from "./chunk-QHQOBUF6.js";
9
+ import {
10
+ MACRO
11
+ } from "./chunk-W5EGGA44.js";
12
+
13
+ // packages/core/src/utils/execFileNoThrow.ts
14
+ import { execFile } from "child_process";
15
+
16
+ // packages/core/src/logging/log/paths.ts
17
+ import { existsSync } from "fs";
18
+ import { randomUUID } from "crypto";
19
+ import { join } from "path";
20
+ import envPaths from "env-paths";
21
+
22
+ // packages/core/src/constants/product.ts
23
+ var PRODUCT_NAME = "Kode";
24
+ var PROJECT_FILE = "AGENTS.md";
25
+ var PRODUCT_COMMAND = "kode";
26
+ var CONFIG_BASE_DIR = ".kode";
27
+ var CONFIG_FILE = ".kode.json";
28
+ var GITHUB_ISSUES_REPO_URL = "https://github.com/shareAI-lab/Anykode/issues";
29
+ var ASCII_LOGO = `
30
+ _ __ _ ____ _ ___
31
+ | |/ /___ __| | ___ / ___| | |_ _|
32
+ | ' // _ \\ / _\` |/ _ \\| | | | | |
33
+ | . \\ (_) | (_| | __/| |___| |___ | |
34
+ |_|\\_\\___/ \\__,_|\\___| \\____|_____|___|`;
35
+
36
+ // packages/core/src/logging/log/paths.ts
37
+ var SESSION_ID = randomUUID();
38
+ var paths = envPaths(PRODUCT_COMMAND);
39
+ function getProjectDir(cwd) {
40
+ return cwd.replace(/[^a-zA-Z0-9]/g, "-");
41
+ }
42
+ function getLegacyCacheRoot() {
43
+ return process.env.KODE_LEGACY_CACHE_ROOT ?? paths.cache;
44
+ }
45
+ function getNewLogRoot() {
46
+ return process.env.KODE_LOG_ROOT ?? getKodeBaseDir();
47
+ }
48
+ var CACHE_PATHS = {
49
+ errors: () => join(getNewLogRoot(), getProjectDir(process.cwd()), "errors"),
50
+ messages: () => join(getNewLogRoot(), getProjectDir(process.cwd()), "messages"),
51
+ mcpLogs: (serverName) => join(
52
+ getLegacyCacheRoot(),
53
+ getProjectDir(process.cwd()),
54
+ `mcp-logs-${serverName}`
55
+ )
56
+ };
57
+ var LEGACY_CACHE_PATHS = {
58
+ errors: () => join(getLegacyCacheRoot(), getProjectDir(process.cwd()), "errors"),
59
+ messages: () => join(getLegacyCacheRoot(), getProjectDir(process.cwd()), "messages"),
60
+ mcpLogs: (serverName) => join(
61
+ getLegacyCacheRoot(),
62
+ getProjectDir(process.cwd()),
63
+ `mcp-logs-${serverName}`
64
+ )
65
+ };
66
+ function dateToFilename(date) {
67
+ return date.toISOString().replace(/[:.]/g, "-");
68
+ }
69
+ var DATE = dateToFilename(/* @__PURE__ */ new Date());
70
+ function getErrorsPath() {
71
+ return join(CACHE_PATHS.errors(), DATE + ".txt");
72
+ }
73
+ function getMessagesPath(messageLogName, forkNumber, sidechainNumber) {
74
+ return join(
75
+ CACHE_PATHS.messages(),
76
+ `${messageLogName}${forkNumber > 0 ? `-${forkNumber}` : ""}${sidechainNumber > 0 ? `-sidechain-${sidechainNumber}` : ""}.json`
77
+ );
78
+ }
79
+ function parseLogFilename(filename) {
80
+ const base = filename.split(".")[0];
81
+ const segments = base.split("-");
82
+ const hasSidechain = base.includes("-sidechain-");
83
+ let date = base;
84
+ let forkNumber = void 0;
85
+ let sidechainNumber = void 0;
86
+ if (hasSidechain) {
87
+ const sidechainIndex = segments.indexOf("sidechain");
88
+ sidechainNumber = Number(segments[sidechainIndex + 1]);
89
+ if (sidechainIndex > 6) {
90
+ forkNumber = Number(segments[sidechainIndex - 1]);
91
+ date = segments.slice(0, 6).join("-");
92
+ } else {
93
+ date = segments.slice(0, 6).join("-");
94
+ }
95
+ } else if (segments.length > 6) {
96
+ const lastSegment = Number(segments[segments.length - 1]);
97
+ forkNumber = lastSegment >= 0 ? lastSegment : void 0;
98
+ date = segments.slice(0, 6).join("-");
99
+ } else {
100
+ date = base;
101
+ }
102
+ return { date, forkNumber, sidechainNumber };
103
+ }
104
+ function getNextAvailableLogForkNumber(date, forkNumber, sidechainNumber) {
105
+ while (existsSync(getMessagesPath(date, forkNumber, sidechainNumber))) {
106
+ forkNumber++;
107
+ }
108
+ return forkNumber;
109
+ }
110
+ function getNextAvailableLogSidechainNumber(date, forkNumber) {
111
+ let sidechainNumber = 1;
112
+ while (existsSync(getMessagesPath(date, forkNumber, sidechainNumber))) {
113
+ sidechainNumber++;
114
+ }
115
+ return sidechainNumber;
116
+ }
117
+
118
+ // packages/core/src/logging/log/errors.ts
119
+ import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, existsSync as existsSync4 } from "fs";
120
+ import { join as join2 } from "path";
121
+
122
+ // packages/core/src/logging/log/jsonLog.ts
123
+ import { existsSync as existsSync3, readFileSync } from "fs";
124
+ import { dirname } from "path";
125
+
126
+ // packages/core/src/logging/log/filesystem.ts
127
+ import { existsSync as existsSync2, mkdirSync, writeFileSync } from "fs";
128
+ var PERMISSION_ERROR_CODES = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EROFS"]);
129
+ function isPermissionError(error) {
130
+ return typeof error === "object" && error !== null && "code" in error && PERMISSION_ERROR_CODES.has(error.code ?? "");
131
+ }
132
+ function safeMkdir(dir) {
133
+ if (existsSync2(dir)) return true;
134
+ try {
135
+ mkdirSync(dir, { recursive: true });
136
+ return true;
137
+ } catch (error) {
138
+ if (isPermissionError(error)) {
139
+ return false;
140
+ }
141
+ throw error;
142
+ }
143
+ }
144
+ function safeWriteFile(path, data, encoding = "utf8") {
145
+ try {
146
+ writeFileSync(path, data, encoding);
147
+ return true;
148
+ } catch (error) {
149
+ if (isPermissionError(error)) {
150
+ return false;
151
+ }
152
+ throw error;
153
+ }
154
+ }
155
+
156
+ // packages/core/src/logging/log/jsonLog.ts
157
+ function readJsonLog(path) {
158
+ if (!existsSync3(path)) {
159
+ return [];
160
+ }
161
+ try {
162
+ return JSON.parse(readFileSync(path, "utf8"));
163
+ } catch {
164
+ return [];
165
+ }
166
+ }
167
+ function appendToJsonLog(path, message) {
168
+ if (process.env.USER_TYPE === "external") {
169
+ return;
170
+ }
171
+ const dir = dirname(path);
172
+ if (!safeMkdir(dir)) {
173
+ return;
174
+ }
175
+ if (!existsSync3(path) && !safeWriteFile(path, "[]")) {
176
+ return;
177
+ }
178
+ const messages = readJsonLog(path);
179
+ const messageWithTimestamp = {
180
+ ...message,
181
+ cwd: process.cwd(),
182
+ userType: process.env.USER_TYPE,
183
+ sessionId: SESSION_ID,
184
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
185
+ version: MACRO.VERSION
186
+ };
187
+ messages.push(messageWithTimestamp);
188
+ safeWriteFile(path, JSON.stringify(messages, null, 2));
189
+ }
190
+
191
+ // packages/core/src/logging/log/errors.ts
192
+ var IN_MEMORY_ERROR_LOG = [];
193
+ var MAX_IN_MEMORY_ERRORS = 100;
194
+ function logError(error) {
195
+ try {
196
+ if (process.env.NODE_ENV === "test") {
197
+ console.error(error);
198
+ }
199
+ const errorStr = error instanceof Error ? error.stack || error.message : String(error);
200
+ const errorInfo = {
201
+ error: errorStr,
202
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
203
+ };
204
+ if (IN_MEMORY_ERROR_LOG.length >= MAX_IN_MEMORY_ERRORS) {
205
+ IN_MEMORY_ERROR_LOG.shift();
206
+ }
207
+ IN_MEMORY_ERROR_LOG.push(errorInfo);
208
+ appendToJsonLog(getErrorsPath(), {
209
+ error: errorStr
210
+ });
211
+ } catch {
212
+ }
213
+ }
214
+ function logMCPError(serverName, error) {
215
+ try {
216
+ const logDir = CACHE_PATHS.mcpLogs(serverName);
217
+ const errorStr = error instanceof Error ? error.stack || error.message : String(error);
218
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
219
+ const logFile = join2(logDir, DATE + ".txt");
220
+ if (!existsSync4(logDir)) {
221
+ mkdirSync2(logDir, { recursive: true });
222
+ }
223
+ if (!existsSync4(logFile)) {
224
+ writeFileSync2(logFile, "[]", "utf8");
225
+ }
226
+ const errorInfo = {
227
+ error: errorStr,
228
+ timestamp,
229
+ sessionId: SESSION_ID,
230
+ cwd: process.cwd()
231
+ };
232
+ const messages = readJsonLog(logFile);
233
+ messages.push(errorInfo);
234
+ writeFileSync2(logFile, JSON.stringify(messages, null, 2), "utf8");
235
+ } catch {
236
+ }
237
+ }
238
+
239
+ // packages/core/src/logging/log/messages.ts
240
+ import { dirname as dirname2 } from "path";
241
+
242
+ // packages/core/src/plan/mode/paths.ts
243
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync2, realpathSync } from "fs";
244
+ import { isAbsolute, join as join3, relative, resolve, parse as parse2 } from "path";
245
+
246
+ // packages/core/src/plan/mode/slug.ts
247
+ import { randomBytes } from "crypto";
248
+ import { parse } from "path";
249
+
250
+ // packages/core/src/plan/mode/state.ts
251
+ var DEFAULT_CONVERSATION_KEY = "default";
252
+ var planModeEnabledByConversationKey = /* @__PURE__ */ new Map();
253
+ var planModeFlagsByConversationKey = /* @__PURE__ */ new Map();
254
+ var planModeAttachmentStateByAgentKey = /* @__PURE__ */ new Map();
255
+ var activePlanConversationKey = null;
256
+ function getConversationKey(context) {
257
+ const messageLogName = context?.options?.messageLogName ?? DEFAULT_CONVERSATION_KEY;
258
+ const forkNumber = context?.options?.forkNumber ?? 0;
259
+ return `${messageLogName}:${forkNumber}`;
260
+ }
261
+ function getPlanConversationKey(context) {
262
+ return getConversationKey(context);
263
+ }
264
+ function setActivePlanConversationKey(conversationKey) {
265
+ activePlanConversationKey = conversationKey;
266
+ }
267
+ function getActivePlanConversationKey() {
268
+ return activePlanConversationKey;
269
+ }
270
+ function getAgentKey(context) {
271
+ const conversationKey = getConversationKey(context);
272
+ const agentId = context?.agentId ?? "main";
273
+ return `${conversationKey}:${agentId}`;
274
+ }
275
+ function isPlanModeEnabled(context) {
276
+ const key = getConversationKey(context);
277
+ return planModeEnabledByConversationKey.get(key) ?? false;
278
+ }
279
+ function setPlanModeEnabledForConversationKey(conversationKey, enabled) {
280
+ planModeEnabledByConversationKey.set(conversationKey, enabled);
281
+ }
282
+ function getPlanModeFlags(conversationKey) {
283
+ const existing = planModeFlagsByConversationKey.get(conversationKey);
284
+ if (existing) return existing;
285
+ const created = {
286
+ hasExitedPlanMode: false,
287
+ needsPlanModeExitAttachment: false
288
+ };
289
+ planModeFlagsByConversationKey.set(conversationKey, created);
290
+ return created;
291
+ }
292
+ function getPlanModeAttachmentState(agentKey) {
293
+ return planModeAttachmentStateByAgentKey.get(agentKey);
294
+ }
295
+ function setPlanModeAttachmentState(agentKey, state) {
296
+ planModeAttachmentStateByAgentKey.set(agentKey, state);
297
+ }
298
+
299
+ // packages/core/src/plan/mode/slug.ts
300
+ var planSlugCache = /* @__PURE__ */ new Map();
301
+ function pickIndex(length) {
302
+ return randomBytes(4).readUInt32BE(0) % length;
303
+ }
304
+ function pickWord(words) {
305
+ return words[pickIndex(words.length)];
306
+ }
307
+ function generateSlug() {
308
+ const adjective = pickWord(PLAN_SLUG_ADJECTIVES);
309
+ const verb = pickWord(PLAN_SLUG_VERBS);
310
+ const noun = pickWord(PLAN_SLUG_NOUNS);
311
+ return `${adjective}-${verb}-${noun}`;
312
+ }
313
+ function setPlanSlug(conversationKey, slug) {
314
+ planSlugCache.set(conversationKey, slug);
315
+ }
316
+ function getPlanSlugForConversationKey(conversationKey) {
317
+ return planSlugCache.get(conversationKey) ?? null;
318
+ }
319
+ function extractSlugFromPlanFilePath(planFilePath) {
320
+ if (!planFilePath) return null;
321
+ const baseName = parse(planFilePath).name;
322
+ if (!baseName) return null;
323
+ const agentMarker = "-agent-";
324
+ const idx = baseName.lastIndexOf(agentMarker);
325
+ if (idx === -1) return baseName;
326
+ if (idx === 0) return null;
327
+ return baseName.slice(0, idx);
328
+ }
329
+ function isRecord(value) {
330
+ return typeof value === "object" && value !== null;
331
+ }
332
+ function getTrimmedString(value) {
333
+ return typeof value === "string" ? value.trim() : "";
334
+ }
335
+ function hydratePlanSlugFromMessages(messages, context) {
336
+ const conversationKey = getConversationKey(context);
337
+ if (planSlugCache.has(conversationKey)) return true;
338
+ for (let i = messages.length - 1; i >= 0; i--) {
339
+ const msg = messages[i];
340
+ if (!isRecord(msg)) continue;
341
+ const directSlug = getTrimmedString(msg.slug);
342
+ if (directSlug) {
343
+ planSlugCache.set(conversationKey, directSlug);
344
+ return true;
345
+ }
346
+ const toolUseResult = msg.toolUseResult;
347
+ if (!isRecord(toolUseResult)) continue;
348
+ const data = toolUseResult.data;
349
+ if (!isRecord(data)) continue;
350
+ const planFilePath = getTrimmedString(data.planFilePath) || getTrimmedString(data.filePath);
351
+ if (!planFilePath) continue;
352
+ const slug = extractSlugFromPlanFilePath(planFilePath);
353
+ if (!slug) continue;
354
+ planSlugCache.set(conversationKey, slug);
355
+ return true;
356
+ }
357
+ return false;
358
+ }
359
+
360
+ // packages/core/src/plan/mode/paths.ts
361
+ var MAX_SLUG_ATTEMPTS = 10;
362
+ function getPlanDirectory() {
363
+ const dir = join3(getKodeBaseDir(), "plans");
364
+ if (!existsSync5(dir)) {
365
+ mkdirSync3(dir, { recursive: true });
366
+ }
367
+ return dir;
368
+ }
369
+ function getOrCreatePlanSlug(conversationKey) {
370
+ const existing = getPlanSlugForConversationKey(conversationKey);
371
+ if (existing) return existing;
372
+ const dir = getPlanDirectory();
373
+ let slug = null;
374
+ for (let attempt = 0; attempt < MAX_SLUG_ATTEMPTS; attempt++) {
375
+ slug = generateSlug();
376
+ const path = join3(dir, `${slug}.md`);
377
+ if (!existsSync5(path)) break;
378
+ }
379
+ if (!slug) slug = generateSlug();
380
+ setPlanSlug(conversationKey, slug);
381
+ return slug;
382
+ }
383
+ function getPlanFilePath(agentId, conversationKey) {
384
+ const dir = getPlanDirectory();
385
+ const key = conversationKey ?? DEFAULT_CONVERSATION_KEY;
386
+ const slug = getOrCreatePlanSlug(key);
387
+ if (!agentId) return join3(dir, `${slug}.md`);
388
+ return join3(dir, `${slug}-agent-${agentId}.md`);
389
+ }
390
+ function resolveExistingPath(path) {
391
+ const resolved = resolve(path);
392
+ try {
393
+ return realpathSync(resolved);
394
+ } catch {
395
+ return resolved;
396
+ }
397
+ }
398
+ function isMainPlanFilePathForActiveConversation(path) {
399
+ const key = getActivePlanConversationKey() ?? DEFAULT_CONVERSATION_KEY;
400
+ const expected = resolveExistingPath(getPlanFilePath(void 0, key));
401
+ const target = resolveExistingPath(path);
402
+ return target === expected;
403
+ }
404
+ function readPlanFile(agentId, conversationKey) {
405
+ const planFilePath = getPlanFilePath(agentId, conversationKey);
406
+ if (!existsSync5(planFilePath)) {
407
+ return { content: "", exists: false, planFilePath };
408
+ }
409
+ return {
410
+ content: readFileSync2(planFilePath, "utf8"),
411
+ exists: true,
412
+ planFilePath
413
+ };
414
+ }
415
+
416
+ // packages/core/src/plan/mode/systemPrompt.ts
417
+ import { existsSync as existsSync6 } from "fs";
418
+
419
+ // packages/core/src/plan/mode/reminders.ts
420
+ function getMaxParallelExploreAgents() {
421
+ const raw = process.env.KODE_PLAN_V2_EXPLORE_AGENT_COUNT ?? process.env.CLAUDE_CODE_PLAN_V2_EXPLORE_AGENT_COUNT;
422
+ if (raw) {
423
+ const parsed = Number.parseInt(raw, 10);
424
+ if (Number.isFinite(parsed) && parsed > 0 && parsed <= 10) return parsed;
425
+ }
426
+ return 3;
427
+ }
428
+ function getMaxParallelPlanAgents() {
429
+ const raw = process.env.KODE_PLAN_V2_AGENT_COUNT ?? process.env.CLAUDE_CODE_PLAN_V2_AGENT_COUNT;
430
+ if (raw) {
431
+ const parsed = Number.parseInt(raw, 10);
432
+ if (Number.isFinite(parsed) && parsed > 0 && parsed <= 10) return parsed;
433
+ }
434
+ return 1;
435
+ }
436
+ function buildPlanModeMainReminder(args) {
437
+ const { planExists, planFilePath } = args;
438
+ const writeToolName = "Write";
439
+ const editToolName = "Edit";
440
+ const askUserToolName = "AskUserQuestion";
441
+ const exploreAgentType = "Explore";
442
+ const planAgentType = "Plan";
443
+ const exitPlanModeToolName = "ExitPlanMode";
444
+ const maxParallelExploreAgents = getMaxParallelExploreAgents();
445
+ const maxParallelPlanAgents = getMaxParallelPlanAgents();
446
+ return `Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
447
+
448
+ ## Plan File Info:
449
+ ${planExists ? `A plan file already exists at ${planFilePath}. You can read it and make incremental edits using the ${editToolName} tool.` : `No plan file exists yet. You should create your plan at ${planFilePath} using the ${writeToolName} tool.`}
450
+ You should build your plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.
451
+
452
+ ## Plan Workflow
453
+
454
+ ### Phase 1: Initial Understanding
455
+ Goal: Gain a comprehensive understanding of the user's request by reading through code and asking them questions. Critical: In this phase you should only use the ${exploreAgentType} subagent type.
456
+
457
+ 1. Focus on understanding the user's request and the code associated with their request
458
+
459
+ 2. **Launch up to ${maxParallelExploreAgents} ${exploreAgentType} agents IN PARALLEL** (single message, multiple tool calls) to efficiently explore the codebase.
460
+ - Use 1 agent when the task is isolated to known files, the user provided specific file paths, or you're making a small targeted change.
461
+ - Use multiple agents when: the scope is uncertain, multiple areas of the codebase are involved, or you need to understand existing patterns before planning.
462
+ - Quality over quantity - ${maxParallelExploreAgents} agents maximum, but you should try to use the minimum number of agents necessary (usually just 1)
463
+ - If using multiple agents: Provide each agent with a specific search focus or area to explore. Example: One agent searches for existing implementations, another explores related components, a third investigates testing patterns
464
+
465
+ 3. After exploring the code, use the ${askUserToolName} tool to clarify ambiguities in the user request up front.
466
+
467
+ ### Phase 2: Design
468
+ Goal: Design an implementation approach.
469
+
470
+ Launch ${planAgentType} agent(s) to design the implementation based on the user's intent and your exploration results from Phase 1.
471
+
472
+ You can launch up to ${maxParallelPlanAgents} agent(s) in parallel.
473
+
474
+ **Guidelines:**
475
+ - **Default**: Launch at least 1 Plan agent for most tasks - it helps validate your understanding and consider alternatives
476
+ - **Skip agents**: Only for truly trivial tasks (typo fixes, single-line changes, simple renames)
477
+ ${maxParallelPlanAgents > 1 ? `- **Multiple agents**: Use up to ${maxParallelPlanAgents} agents for complex tasks that benefit from different perspectives
478
+
479
+ Examples of when to use multiple agents:
480
+ - The task touches multiple parts of the codebase
481
+ - It's a large refactor or architectural change
482
+ - There are many edge cases to consider
483
+ - You'd benefit from exploring different approaches
484
+
485
+ Example perspectives by task type:
486
+ - New feature: simplicity vs performance vs maintainability
487
+ - Bug fix: root cause vs workaround vs prevention
488
+ - Refactoring: minimal change vs clean architecture
489
+ ` : ""}
490
+ In the agent prompt:
491
+ - Provide comprehensive background context from Phase 1 exploration including filenames and code path traces
492
+ - Describe requirements and constraints
493
+ - Request a detailed implementation plan
494
+
495
+ ### Phase 3: Review
496
+ Goal: Review the plan(s) from Phase 2 and ensure alignment with the user's intentions.
497
+ 1. Read the critical files identified by agents to deepen your understanding
498
+ 2. Ensure that the plans align with the user's original request
499
+ 3. Use ${askUserToolName} to clarify any remaining questions with the user
500
+
501
+ ### Phase 4: Final Plan
502
+ Goal: Write your final plan to the plan file (the only file you can edit).
503
+ - Include only your recommended approach, not all alternatives
504
+ - Ensure that the plan file is concise enough to scan quickly, but detailed enough to execute effectively
505
+ - Include the paths of critical files to be modified
506
+
507
+ ### Phase 5: Call ${exitPlanModeToolName}
508
+ At the very end of your turn, once you have asked the user questions and are happy with your final plan file - you should always call ${exitPlanModeToolName} to indicate to the user that you are done planning.
509
+ This is critical - your turn should only end with either asking the user a question or calling ${exitPlanModeToolName}. Do not stop unless it's for these 2 reasons.
510
+
511
+ NOTE: At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.`;
512
+ }
513
+ function buildPlanModeSubAgentReminder(args) {
514
+ const { planExists, planFilePath } = args;
515
+ const writeToolName = "Write";
516
+ const editToolName = "Edit";
517
+ const askUserToolName = "AskUserQuestion";
518
+ return `Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received (for example, to make edits). Instead, you should:
519
+
520
+ ## Plan File Info:
521
+ ${planExists ? `A plan file already exists at ${planFilePath}. You can read it and make incremental edits using the ${editToolName} tool if you need to.` : `No plan file exists yet. You should create your plan at ${planFilePath} using the ${writeToolName} tool if you need to.`}
522
+ You should build your plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.
523
+ Answer the user's query comprehensively, using the ${askUserToolName} tool if you need to ask the user clarifying questions. If you do use the ${askUserToolName}, make sure to ask all clarifying questions you need to fully understand the user's intent before proceeding.`;
524
+ }
525
+ function buildPlanModeReentryReminder(planFilePath) {
526
+ const exitPlanModeToolName = "ExitPlanMode";
527
+ return `## Re-entering Plan Mode
528
+
529
+ You are returning to plan mode after having previously exited it. A plan file exists at ${planFilePath} from your previous planning session.
530
+
531
+ **Before proceeding with any new planning, you should:**
532
+ 1. Read the existing plan file to understand what was previously planned
533
+ 2. Evaluate the user's current request against that plan
534
+ 3. Decide how to proceed:
535
+ - **Different task**: If the user's request is for a different task\u2014even if it's similar or related\u2014start fresh by overwriting the existing plan
536
+ - **Same task, continuing**: If this is explicitly a continuation or refinement of the exact same task, modify the existing plan while cleaning up outdated or irrelevant sections
537
+ 4. Continue on with the plan process and most importantly you should always edit the plan file one way or the other before calling ${exitPlanModeToolName}
538
+
539
+ Treat this as a fresh planning session. Do not assume the existing plan is relevant without evaluating it first.`;
540
+ }
541
+ function buildPlanModeExitReminder(planFilePath) {
542
+ return `## Exited Plan Mode
543
+
544
+ You have exited plan mode. You can now make edits, run tools, and take actions. The plan file is located at ${planFilePath} if you need to reference it.`;
545
+ }
546
+ function wrapSystemReminder(text) {
547
+ return `<system-reminder>
548
+ ${text}
549
+ </system-reminder>`;
550
+ }
551
+
552
+ // packages/core/src/plan/mode/systemPrompt.ts
553
+ var TURNS_BETWEEN_ATTACHMENTS = 5;
554
+ function getPlanModeSystemPromptAdditions(messages, context) {
555
+ const conversationKey = getConversationKey(context);
556
+ const agentKey = getAgentKey(context);
557
+ const flags = getPlanModeFlags(conversationKey);
558
+ const additions = [];
559
+ const assistantTurns = messages.filter((m) => m?.type === "assistant").length;
560
+ if (isPlanModeEnabled(context)) {
561
+ const previous = getPlanModeAttachmentState(agentKey) ?? {
562
+ hasInjected: false,
563
+ lastInjectedAssistantTurn: -Infinity
564
+ };
565
+ if (previous.hasInjected && assistantTurns - previous.lastInjectedAssistantTurn < TURNS_BETWEEN_ATTACHMENTS) {
566
+ return [];
567
+ }
568
+ const planFilePath = getPlanFilePath(context.agentId, conversationKey);
569
+ const planExists = existsSync6(planFilePath);
570
+ if (flags.hasExitedPlanMode && planExists) {
571
+ additions.push(
572
+ wrapSystemReminder(buildPlanModeReentryReminder(planFilePath))
573
+ );
574
+ flags.hasExitedPlanMode = false;
575
+ }
576
+ const isSubAgent = !!context.agentId;
577
+ additions.push(
578
+ wrapSystemReminder(
579
+ isSubAgent ? buildPlanModeSubAgentReminder({ planExists, planFilePath }) : buildPlanModeMainReminder({ planExists, planFilePath })
580
+ )
581
+ );
582
+ setPlanModeAttachmentState(agentKey, {
583
+ hasInjected: true,
584
+ lastInjectedAssistantTurn: assistantTurns
585
+ });
586
+ return additions;
587
+ }
588
+ if (flags.needsPlanModeExitAttachment) {
589
+ const planFilePath = getPlanFilePath(context.agentId, conversationKey);
590
+ additions.push(wrapSystemReminder(buildPlanModeExitReminder(planFilePath)));
591
+ flags.needsPlanModeExitAttachment = false;
592
+ }
593
+ return additions;
594
+ }
595
+
596
+ // packages/core/src/plan/mode.ts
597
+ function enterPlanMode(context) {
598
+ const key = getConversationKey(context);
599
+ setPlanModeEnabledForConversationKey(key, true);
600
+ return { planFilePath: getPlanFilePath(context?.agentId, key) };
601
+ }
602
+ function enterPlanModeForConversationKey(conversationKey) {
603
+ setPlanModeEnabledForConversationKey(conversationKey, true);
604
+ }
605
+ function exitPlanModeForConversationKey(conversationKey) {
606
+ setPlanModeEnabledForConversationKey(conversationKey, false);
607
+ const flags = getPlanModeFlags(conversationKey);
608
+ flags.hasExitedPlanMode = true;
609
+ flags.needsPlanModeExitAttachment = true;
610
+ }
611
+
612
+ // packages/core/src/logging/log/messages.ts
613
+ function overwriteLog(path, messages, options) {
614
+ if (process.env.USER_TYPE === "external") {
615
+ return;
616
+ }
617
+ if (!messages.length) {
618
+ return;
619
+ }
620
+ const dir = dirname2(path);
621
+ if (!safeMkdir(dir)) {
622
+ return;
623
+ }
624
+ const slug = options?.conversationKey ? getPlanSlugForConversationKey(options.conversationKey) : null;
625
+ const messagesWithMetadata = messages.map((message) => ({
626
+ ...message,
627
+ ...slug ? { slug } : {},
628
+ cwd: process.cwd(),
629
+ userType: process.env.USER_TYPE,
630
+ sessionId: SESSION_ID,
631
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
632
+ version: MACRO.VERSION
633
+ }));
634
+ safeWriteFile(path, JSON.stringify(messagesWithMetadata, null, 2));
635
+ }
636
+
637
+ // packages/core/src/logging/log/loadLogList.ts
638
+ import {
639
+ existsSync as existsSync7,
640
+ mkdirSync as mkdirSync4,
641
+ readFileSync as readFileSync3,
642
+ readdirSync,
643
+ statSync,
644
+ copyFileSync,
645
+ promises as fsPromises
646
+ } from "fs";
647
+ import { join as join4 } from "path";
648
+
649
+ // packages/core/src/logging/log/util.ts
650
+ function sortLogs(logs) {
651
+ return logs.sort((a, b) => {
652
+ const modifiedDiff = b.modified.getTime() - a.modified.getTime();
653
+ if (modifiedDiff !== 0) {
654
+ return modifiedDiff;
655
+ }
656
+ const createdDiff = b.created.getTime() - a.created.getTime();
657
+ if (createdDiff !== 0) {
658
+ return createdDiff;
659
+ }
660
+ return (b.forkNumber ?? 0) - (a.forkNumber ?? 0);
661
+ });
662
+ }
663
+ function formatDate(date) {
664
+ const now = /* @__PURE__ */ new Date();
665
+ const yesterday = new Date(now);
666
+ yesterday.setDate(yesterday.getDate() - 1);
667
+ const isToday = date.toDateString() === now.toDateString();
668
+ const isYesterday = date.toDateString() === yesterday.toDateString();
669
+ const timeStr = date.toLocaleTimeString("en-US", {
670
+ hour: "numeric",
671
+ minute: "2-digit",
672
+ hour12: true
673
+ }).toLowerCase();
674
+ if (isToday) {
675
+ return `Today at ${timeStr}`;
676
+ } else if (isYesterday) {
677
+ return `Yesterday at ${timeStr}`;
678
+ } else {
679
+ return date.toLocaleDateString("en-US", {
680
+ month: "short",
681
+ day: "numeric"
682
+ }) + ` at ${timeStr}`;
683
+ }
684
+ }
685
+ function parseISOString(s) {
686
+ const b = s.split(/\D+/);
687
+ return new Date(
688
+ Date.UTC(
689
+ parseInt(b[0], 10),
690
+ parseInt(b[1], 10) - 1,
691
+ parseInt(b[2], 10),
692
+ parseInt(b[3], 10),
693
+ parseInt(b[4], 10),
694
+ parseInt(b[5], 10),
695
+ parseInt(b[6], 10)
696
+ )
697
+ );
698
+ }
699
+
700
+ // packages/core/src/logging/log/loadLogList.ts
701
+ var MIGRATION_MESSAGE_LOG_LIMIT = 50;
702
+ var didMigrateMessageLogs = false;
703
+ function migrateLegacyMessageLogsIfNeeded() {
704
+ if (didMigrateMessageLogs) return;
705
+ didMigrateMessageLogs = true;
706
+ const legacyDir = LEGACY_CACHE_PATHS.messages();
707
+ const newDir = CACHE_PATHS.messages();
708
+ if (!existsSync7(legacyDir)) return;
709
+ const newHasAny = existsSync7(newDir) && readdirSync(newDir).some((file) => file.endsWith(".json"));
710
+ if (newHasAny) return;
711
+ try {
712
+ mkdirSync4(newDir, { recursive: true });
713
+ } catch {
714
+ return;
715
+ }
716
+ let legacyFiles = [];
717
+ try {
718
+ legacyFiles = readdirSync(legacyDir).filter((file) => file.endsWith(".json"));
719
+ } catch {
720
+ return;
721
+ }
722
+ const sorted = legacyFiles.map((file) => {
723
+ try {
724
+ const stats = statSync(join4(legacyDir, file));
725
+ return { file, mtimeMs: stats.mtimeMs };
726
+ } catch {
727
+ return { file, mtimeMs: 0 };
728
+ }
729
+ }).sort((a, b) => b.mtimeMs - a.mtimeMs).slice(0, MIGRATION_MESSAGE_LOG_LIMIT);
730
+ for (const { file } of sorted) {
731
+ const src = join4(legacyDir, file);
732
+ const dest = join4(newDir, file);
733
+ if (existsSync7(dest)) continue;
734
+ try {
735
+ copyFileSync(src, dest);
736
+ } catch {
737
+ }
738
+ }
739
+ }
740
+ async function loadLogList(path = CACHE_PATHS.messages()) {
741
+ if (path === CACHE_PATHS.messages()) {
742
+ migrateLegacyMessageLogsIfNeeded();
743
+ }
744
+ const searchPaths = path === CACHE_PATHS.messages() ? [CACHE_PATHS.messages(), LEGACY_CACHE_PATHS.messages()] : [path];
745
+ const existingPaths = searchPaths.filter((p) => existsSync7(p));
746
+ if (existingPaths.length === 0) {
747
+ logError(`No logs found at ${path}`);
748
+ return [];
749
+ }
750
+ const filesWithDir = (await Promise.all(
751
+ existingPaths.map(async (dirPath) => {
752
+ const dirFiles = await fsPromises.readdir(dirPath);
753
+ return dirFiles.map((file) => ({ file, dirPath }));
754
+ })
755
+ )).flat();
756
+ const seen = /* @__PURE__ */ new Set();
757
+ const uniqueFiles = filesWithDir.filter(({ file }) => {
758
+ if (seen.has(file)) return false;
759
+ seen.add(file);
760
+ return true;
761
+ });
762
+ const logData = await Promise.all(
763
+ uniqueFiles.map(async ({ file, dirPath }, i) => {
764
+ const fullPath = join4(dirPath, file);
765
+ const content = readFileSync3(fullPath, "utf8");
766
+ const messages = JSON.parse(content);
767
+ const firstMessage = messages[0];
768
+ const lastMessage = messages[messages.length - 1];
769
+ const firstPrompt = firstMessage?.type === "user" && typeof firstMessage?.message?.content === "string" ? firstMessage?.message?.content : "No prompt";
770
+ const { date, forkNumber, sidechainNumber } = parseLogFilename(file);
771
+ return {
772
+ date,
773
+ forkNumber,
774
+ fullPath,
775
+ messages,
776
+ value: i,
777
+ // overwritten after sorting
778
+ created: parseISOString(firstMessage?.timestamp || date),
779
+ modified: lastMessage?.timestamp ? parseISOString(lastMessage.timestamp) : parseISOString(date),
780
+ firstPrompt: firstPrompt.split("\n")[0]?.slice(0, 50) + (firstPrompt.length > 50 ? "\u2026" : "") || "No prompt",
781
+ messageCount: messages.length,
782
+ sidechainNumber
783
+ };
784
+ })
785
+ );
786
+ return sortLogs(logData.filter((_) => _.messages.length)).map((_, i) => ({
787
+ ..._,
788
+ value: i
789
+ }));
790
+ }
791
+
792
+ // packages/core/src/utils/execFileNoThrow.ts
793
+ var MS_IN_SECOND = 1e3;
794
+ var SECONDS_IN_MINUTE = 60;
795
+ function execFileNoThrow(file, args, abortSignal, timeout = 10 * SECONDS_IN_MINUTE * MS_IN_SECOND, preserveOutputOnError = true) {
796
+ return new Promise((resolve2) => {
797
+ try {
798
+ execFile(
799
+ file,
800
+ args,
801
+ {
802
+ maxBuffer: 1e6,
803
+ signal: abortSignal,
804
+ timeout,
805
+ cwd: getCwd()
806
+ },
807
+ (error, stdout, stderr) => {
808
+ if (error) {
809
+ if (preserveOutputOnError) {
810
+ const errorCode = typeof error.code === "number" ? error.code : 1;
811
+ resolve2({
812
+ stdout: stdout || "",
813
+ stderr: stderr || "",
814
+ code: errorCode
815
+ });
816
+ } else {
817
+ resolve2({ stdout: "", stderr: "", code: 1 });
818
+ }
819
+ } else {
820
+ resolve2({ stdout, stderr, code: 0 });
821
+ }
822
+ }
823
+ );
824
+ } catch (error) {
825
+ logError(error);
826
+ resolve2({ stdout: "", stderr: "", code: 1 });
827
+ }
828
+ });
829
+ }
830
+
831
+ // packages/core/src/utils/env.ts
832
+ import { memoize } from "lodash-es";
833
+ import { join as join5 } from "path";
834
+ import { homedir } from "os";
835
+ function getKodeBaseDir() {
836
+ return process.env.KODE_CONFIG_DIR ?? process.env.CLAUDE_CONFIG_DIR ?? join5(homedir(), CONFIG_BASE_DIR);
837
+ }
838
+ function getGlobalConfigFilePath() {
839
+ return process.env.KODE_CONFIG_DIR || process.env.CLAUDE_CONFIG_DIR ? join5(getKodeBaseDir(), "config.json") : join5(homedir(), CONFIG_FILE);
840
+ }
841
+ function getMemoryDir() {
842
+ return join5(getKodeBaseDir(), "memory");
843
+ }
844
+ var KODE_BASE_DIR = getKodeBaseDir();
845
+ var GLOBAL_CONFIG_FILE = getGlobalConfigFilePath();
846
+ var MEMORY_DIR = getMemoryDir();
847
+ var getIsDocker = memoize(async () => {
848
+ const { code } = await execFileNoThrow("test", ["-f", "/.dockerenv"]);
849
+ if (code !== 0) {
850
+ return false;
851
+ }
852
+ return process.platform === "linux";
853
+ });
854
+ var hasInternetAccess = memoize(async () => {
855
+ const offline = process.env.KODE_OFFLINE ?? process.env.OFFLINE ?? process.env.NO_NETWORK ?? "";
856
+ const normalized = String(offline).trim().toLowerCase();
857
+ if (["1", "true", "yes", "on"].includes(normalized)) return false;
858
+ return true;
859
+ });
860
+ var env = {
861
+ getIsDocker,
862
+ hasInternetAccess,
863
+ isCI: Boolean(process.env.CI),
864
+ platform: process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : "linux",
865
+ nodeVersion: process.version,
866
+ terminal: process.env.TERM_PROGRAM
867
+ };
868
+
869
+ export {
870
+ getPlanConversationKey,
871
+ setActivePlanConversationKey,
872
+ hydratePlanSlugFromMessages,
873
+ PRODUCT_NAME,
874
+ PROJECT_FILE,
875
+ PRODUCT_COMMAND,
876
+ CONFIG_BASE_DIR,
877
+ GITHUB_ISSUES_REPO_URL,
878
+ ASCII_LOGO,
879
+ SESSION_ID,
880
+ CACHE_PATHS,
881
+ dateToFilename,
882
+ getMessagesPath,
883
+ parseLogFilename,
884
+ getNextAvailableLogForkNumber,
885
+ getNextAvailableLogSidechainNumber,
886
+ logError,
887
+ logMCPError,
888
+ overwriteLog,
889
+ formatDate,
890
+ loadLogList,
891
+ execFileNoThrow,
892
+ getKodeBaseDir,
893
+ getGlobalConfigFilePath,
894
+ getMemoryDir,
895
+ KODE_BASE_DIR,
896
+ GLOBAL_CONFIG_FILE,
897
+ MEMORY_DIR,
898
+ env,
899
+ getPlanFilePath,
900
+ isMainPlanFilePathForActiveConversation,
901
+ readPlanFile,
902
+ getPlanModeSystemPromptAdditions,
903
+ enterPlanMode,
904
+ enterPlanModeForConversationKey,
905
+ exitPlanModeForConversationKey
906
+ };