@within-7/minto 0.4.1 → 0.4.2

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 (391) hide show
  1. package/dist/Tool.js +7 -0
  2. package/dist/Tool.js.map +2 -2
  3. package/dist/commands/agents/AgentsCommand.js +1 -1
  4. package/dist/commands/agents/AgentsCommand.js.map +2 -2
  5. package/dist/commands/agents/constants.js +2 -2
  6. package/dist/commands/agents/constants.js.map +2 -2
  7. package/dist/commands/clear.js +4 -3
  8. package/dist/commands/clear.js.map +2 -2
  9. package/dist/commands/compact.js +2 -2
  10. package/dist/commands/compact.js.map +1 -1
  11. package/dist/commands/context.js +3 -1
  12. package/dist/commands/context.js.map +2 -2
  13. package/dist/commands/login.js +128 -0
  14. package/dist/commands/login.js.map +7 -0
  15. package/dist/commands/memory.js +33 -82
  16. package/dist/commands/memory.js.map +2 -2
  17. package/dist/commands/quit.js +3 -1
  18. package/dist/commands/quit.js.map +2 -2
  19. package/dist/commands/resume.js +39 -239
  20. package/dist/commands/resume.js.map +2 -2
  21. package/dist/commands/tasks.js +1 -1
  22. package/dist/commands/tasks.js.map +2 -2
  23. package/dist/commands/terminalSetup.js +6 -2
  24. package/dist/commands/terminalSetup.js.map +2 -2
  25. package/dist/commands.js +2 -0
  26. package/dist/commands.js.map +2 -2
  27. package/dist/components/AgentDetailView.js +126 -0
  28. package/dist/components/AgentDetailView.js.map +7 -0
  29. package/dist/components/AgentThinkingBlock.js +1 -1
  30. package/dist/components/AgentThinkingBlock.js.map +2 -2
  31. package/dist/components/AgentViewBanner.js +22 -0
  32. package/dist/components/AgentViewBanner.js.map +7 -0
  33. package/dist/components/HeaderBar.js +1 -1
  34. package/dist/components/HeaderBar.js.map +2 -2
  35. package/dist/components/Help.js +8 -1
  36. package/dist/components/Help.js.map +2 -2
  37. package/dist/components/HotkeyHelpPanel.js +26 -8
  38. package/dist/components/HotkeyHelpPanel.js.map +2 -2
  39. package/dist/components/IdleNotificationBar.js +10 -0
  40. package/dist/components/IdleNotificationBar.js.map +7 -0
  41. package/dist/components/ModelSelector/ModelSelector.js +55 -20
  42. package/dist/components/ModelSelector/ModelSelector.js.map +2 -2
  43. package/dist/components/PromptInput.js +186 -115
  44. package/dist/components/PromptInput.js.map +2 -2
  45. package/dist/components/RewindPanel.js +272 -0
  46. package/dist/components/RewindPanel.js.map +7 -0
  47. package/dist/components/Spinner.js +10 -21
  48. package/dist/components/Spinner.js.map +2 -2
  49. package/dist/components/StreamingTextPreview.js +29 -0
  50. package/dist/components/StreamingTextPreview.js.map +7 -0
  51. package/dist/components/SubagentBlock.js +3 -2
  52. package/dist/components/SubagentBlock.js.map +2 -2
  53. package/dist/components/SubagentProgress.js +4 -4
  54. package/dist/components/SubagentProgress.js.map +2 -2
  55. package/dist/components/TabbedListView/SearchInput.js +1 -1
  56. package/dist/components/TabbedListView/SearchInput.js.map +2 -2
  57. package/dist/components/TabbedListView/TabbedListView.js +87 -41
  58. package/dist/components/TabbedListView/TabbedListView.js.map +2 -2
  59. package/dist/components/TaskCard.js +4 -4
  60. package/dist/components/TaskCard.js.map +2 -2
  61. package/dist/components/TeamMemberPanel.js +107 -0
  62. package/dist/components/TeamMemberPanel.js.map +7 -0
  63. package/dist/components/ThinkingSelector.js +84 -0
  64. package/dist/components/ThinkingSelector.js.map +7 -0
  65. package/dist/components/TitledDivider.js +26 -0
  66. package/dist/components/TitledDivider.js.map +7 -0
  67. package/dist/components/TodoPanel.js +31 -30
  68. package/dist/components/TodoPanel.js.map +2 -2
  69. package/dist/components/TokenWarning.js +28 -7
  70. package/dist/components/TokenWarning.js.map +2 -2
  71. package/dist/components/messages/AssistantTextMessage.js +5 -2
  72. package/dist/components/messages/AssistantTextMessage.js.map +2 -2
  73. package/dist/components/messages/AssistantToolUseMessage.js +9 -1
  74. package/dist/components/messages/AssistantToolUseMessage.js.map +2 -2
  75. package/dist/components/messages/DefaultToolResultFallback.js +11 -0
  76. package/dist/components/messages/DefaultToolResultFallback.js.map +7 -0
  77. package/dist/components/messages/ParallelTasksGroupView.js +14 -6
  78. package/dist/components/messages/ParallelTasksGroupView.js.map +2 -2
  79. package/dist/components/messages/TaskInModuleView.js +27 -27
  80. package/dist/components/messages/TaskInModuleView.js.map +2 -2
  81. package/dist/components/messages/UserGuidanceMessage.js +26 -0
  82. package/dist/components/messages/UserGuidanceMessage.js.map +7 -0
  83. package/dist/components/messages/UserPromptMessage.js +2 -1
  84. package/dist/components/messages/UserPromptMessage.js.map +2 -2
  85. package/dist/components/messages/UserTeamNotificationMessage.js +91 -0
  86. package/dist/components/messages/UserTeamNotificationMessage.js.map +7 -0
  87. package/dist/components/messages/UserTextMessage.js +8 -0
  88. package/dist/components/messages/UserTextMessage.js.map +2 -2
  89. package/dist/components/messages/UserToolResultMessage/UserToolRejectMessage.js +4 -2
  90. package/dist/components/messages/UserToolResultMessage/UserToolRejectMessage.js.map +2 -2
  91. package/dist/components/messages/UserToolResultMessage/UserToolResultMessage.js +18 -1
  92. package/dist/components/messages/UserToolResultMessage/UserToolResultMessage.js.map +2 -2
  93. package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js +12 -1
  94. package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js.map +2 -2
  95. package/dist/components/permissions/PermissionRequest.js +4 -0
  96. package/dist/components/permissions/PermissionRequest.js.map +2 -2
  97. package/dist/components/permissions/PlanApprovalRequest.js +164 -0
  98. package/dist/components/permissions/PlanApprovalRequest.js.map +7 -0
  99. package/dist/constants/agentTeams.js +17 -0
  100. package/dist/constants/agentTeams.js.map +7 -0
  101. package/dist/constants/macros.js +2 -1
  102. package/dist/constants/macros.js.map +2 -2
  103. package/dist/constants/prompts/agentPrompt.js +1 -0
  104. package/dist/constants/prompts/agentPrompt.js.map +2 -2
  105. package/dist/constants/prompts/autoMemory.js +39 -0
  106. package/dist/constants/prompts/autoMemory.js.map +7 -0
  107. package/dist/constants/prompts/codeConventions.js +1 -13
  108. package/dist/constants/prompts/codeConventions.js.map +2 -2
  109. package/dist/constants/prompts/doingTasks.js +21 -2
  110. package/dist/constants/prompts/doingTasks.js.map +2 -2
  111. package/dist/constants/prompts/envInfo.js +6 -7
  112. package/dist/constants/prompts/envInfo.js.map +2 -2
  113. package/dist/constants/prompts/index.js +27 -5
  114. package/dist/constants/prompts/index.js.map +2 -2
  115. package/dist/constants/prompts/taskManagement.js +2 -43
  116. package/dist/constants/prompts/taskManagement.js.map +2 -2
  117. package/dist/constants/prompts/teamOverlays.js +50 -0
  118. package/dist/constants/prompts/teamOverlays.js.map +7 -0
  119. package/dist/constants/prompts/toneAndStyle.js +4 -29
  120. package/dist/constants/prompts/toneAndStyle.js.map +2 -2
  121. package/dist/constants/prompts/toolUsagePolicy.js +7 -22
  122. package/dist/constants/prompts/toolUsagePolicy.js.map +2 -2
  123. package/dist/constants/toolInputExamples.js +2 -2
  124. package/dist/constants/toolInputExamples.js.map +2 -2
  125. package/dist/context.js +39 -6
  126. package/dist/context.js.map +2 -2
  127. package/dist/core/backupManager.js +1 -1
  128. package/dist/core/backupManager.js.map +2 -2
  129. package/dist/core/permissions/rules/planModeRule.js +1 -1
  130. package/dist/core/permissions/rules/planModeRule.js.map +1 -1
  131. package/dist/core/permissions/rules/safeModeRule.js +1 -1
  132. package/dist/core/permissions/rules/safeModeRule.js.map +1 -1
  133. package/dist/engine/AgentEngine.js +902 -0
  134. package/dist/engine/AgentEngine.js.map +7 -0
  135. package/dist/engine/EngineRegistry.js +89 -0
  136. package/dist/engine/EngineRegistry.js.map +7 -0
  137. package/dist/engine/foregroundAdapter.js +191 -0
  138. package/dist/engine/foregroundAdapter.js.map +7 -0
  139. package/dist/engine/index.js +15 -0
  140. package/dist/engine/index.js.map +7 -0
  141. package/dist/engine/types.js +1 -0
  142. package/dist/engine/types.js.map +7 -0
  143. package/dist/entrypoints/cli.js +410 -79
  144. package/dist/entrypoints/cli.js.map +3 -3
  145. package/dist/hooks/useAgentEngine.js +129 -0
  146. package/dist/hooks/useAgentEngine.js.map +7 -0
  147. package/dist/hooks/useAgentTokenStats.js +0 -16
  148. package/dist/hooks/useAgentTokenStats.js.map +2 -2
  149. package/dist/hooks/useCanUseTool.js +47 -2
  150. package/dist/hooks/useCanUseTool.js.map +2 -2
  151. package/dist/hooks/useDeferredLoading.js +4 -1
  152. package/dist/hooks/useDeferredLoading.js.map +2 -2
  153. package/dist/hooks/useIdleNotifications.js +66 -0
  154. package/dist/hooks/useIdleNotifications.js.map +7 -0
  155. package/dist/hooks/useSessionTracking.js +9 -7
  156. package/dist/hooks/useSessionTracking.js.map +2 -2
  157. package/dist/hooks/useTeamMembers.js +51 -0
  158. package/dist/hooks/useTeamMembers.js.map +7 -0
  159. package/dist/i18n/locales/en.js +77 -12
  160. package/dist/i18n/locales/en.js.map +2 -2
  161. package/dist/i18n/locales/zh-CN.js +77 -12
  162. package/dist/i18n/locales/zh-CN.js.map +2 -2
  163. package/dist/i18n/types.js.map +1 -1
  164. package/dist/messages.js.map +2 -2
  165. package/dist/permissions.js +113 -7
  166. package/dist/permissions.js.map +2 -2
  167. package/dist/query.js +135 -37
  168. package/dist/query.js.map +2 -2
  169. package/dist/screens/REPL.js +504 -361
  170. package/dist/screens/REPL.js.map +3 -3
  171. package/dist/screens/ResumeConversation.js +199 -14
  172. package/dist/screens/ResumeConversation.js.map +2 -2
  173. package/dist/services/adapters/base.js.map +1 -1
  174. package/dist/services/agentTeams/backends/headless.js +108 -0
  175. package/dist/services/agentTeams/backends/headless.js.map +7 -0
  176. package/dist/services/agentTeams/backends/inProcess.js +102 -0
  177. package/dist/services/agentTeams/backends/inProcess.js.map +7 -0
  178. package/dist/services/agentTeams/backends/resolver.js +18 -0
  179. package/dist/services/agentTeams/backends/resolver.js.map +7 -0
  180. package/dist/services/agentTeams/backends/tmux.js +168 -0
  181. package/dist/services/agentTeams/backends/tmux.js.map +7 -0
  182. package/dist/services/agentTeams/backends/types.js +1 -0
  183. package/dist/services/agentTeams/backends/types.js.map +7 -0
  184. package/dist/services/agentTeams/heartbeat.js +88 -0
  185. package/dist/services/agentTeams/heartbeat.js.map +7 -0
  186. package/dist/services/agentTeams/index.js +42 -2
  187. package/dist/services/agentTeams/index.js.map +2 -2
  188. package/dist/services/agentTeams/injectionChannel.js +105 -0
  189. package/dist/services/agentTeams/injectionChannel.js.map +7 -0
  190. package/dist/services/agentTeams/mailbox.js +410 -30
  191. package/dist/services/agentTeams/mailbox.js.map +2 -2
  192. package/dist/services/agentTeams/messageFormatter.js +80 -0
  193. package/dist/services/agentTeams/messageFormatter.js.map +7 -0
  194. package/dist/services/agentTeams/permissionDelegation.js +71 -0
  195. package/dist/services/agentTeams/permissionDelegation.js.map +7 -0
  196. package/dist/services/agentTeams/teamEvents.js +45 -0
  197. package/dist/services/agentTeams/teamEvents.js.map +7 -0
  198. package/dist/services/agentTeams/teamManager.js +251 -34
  199. package/dist/services/agentTeams/teamManager.js.map +2 -2
  200. package/dist/services/agentTeams/teamTaskStore.js +290 -61
  201. package/dist/services/agentTeams/teamTaskStore.js.map +2 -2
  202. package/dist/services/agentTeams/teammateSpawner.js +99 -18
  203. package/dist/services/agentTeams/teammateSpawner.js.map +2 -2
  204. package/dist/services/hookExecutor.js +51 -8
  205. package/dist/services/hookExecutor.js.map +2 -2
  206. package/dist/services/llm/anthropicProvider.js +56 -59
  207. package/dist/services/llm/anthropicProvider.js.map +2 -2
  208. package/dist/services/llm/dispatch.js +24 -5
  209. package/dist/services/llm/dispatch.js.map +2 -2
  210. package/dist/services/llm/openaiProvider.js +115 -136
  211. package/dist/services/llm/openaiProvider.js.map +3 -3
  212. package/dist/services/llm/types.js +89 -15
  213. package/dist/services/llm/types.js.map +2 -2
  214. package/dist/services/mcpClient.js +80 -4
  215. package/dist/services/mcpClient.js.map +2 -2
  216. package/dist/services/mintoAuth.js +299 -0
  217. package/dist/services/mintoAuth.js.map +7 -0
  218. package/dist/services/oauth.js +3 -3
  219. package/dist/services/oauth.js.map +2 -2
  220. package/dist/services/openai.js +91 -20
  221. package/dist/services/openai.js.map +2 -2
  222. package/dist/services/plugins/pluginRuntime.js +11 -5
  223. package/dist/services/plugins/pluginRuntime.js.map +2 -2
  224. package/dist/services/plugins/pluginValidation.js +4 -2
  225. package/dist/services/plugins/pluginValidation.js.map +2 -2
  226. package/dist/services/sandbox/sandboxController.js +11 -3
  227. package/dist/services/sandbox/sandboxController.js.map +2 -2
  228. package/dist/services/sessionMemoryInjector.js +77 -0
  229. package/dist/services/sessionMemoryInjector.js.map +7 -0
  230. package/dist/services/systemReminder.js +130 -8
  231. package/dist/services/systemReminder.js.map +2 -2
  232. package/dist/services/taskStore.js +199 -8
  233. package/dist/services/taskStore.js.map +3 -3
  234. package/dist/services/topicDetector.js +169 -0
  235. package/dist/services/topicDetector.js.map +7 -0
  236. package/dist/tools/AskExpertModelTool/AskExpertModelTool.js +0 -13
  237. package/dist/tools/AskExpertModelTool/AskExpertModelTool.js.map +2 -2
  238. package/dist/tools/BashTool/BashTool.js +51 -28
  239. package/dist/tools/BashTool/BashTool.js.map +2 -2
  240. package/dist/tools/BashTool/prompt.js +95 -118
  241. package/dist/tools/BashTool/prompt.js.map +2 -2
  242. package/dist/tools/BashTool/utils.js +39 -1
  243. package/dist/tools/BashTool/utils.js.map +2 -2
  244. package/dist/tools/EnterWorktreeTool/EnterWorktreeTool.js +121 -0
  245. package/dist/tools/EnterWorktreeTool/EnterWorktreeTool.js.map +7 -0
  246. package/dist/tools/EnterWorktreeTool/prompt.js +22 -0
  247. package/dist/tools/EnterWorktreeTool/prompt.js.map +7 -0
  248. package/dist/tools/FileEditTool/FileEditTool.js +9 -4
  249. package/dist/tools/FileEditTool/FileEditTool.js.map +2 -2
  250. package/dist/tools/FileEditTool/prompt.js +3 -7
  251. package/dist/tools/FileEditTool/prompt.js.map +2 -2
  252. package/dist/tools/FileReadTool/FileReadTool.js +125 -3
  253. package/dist/tools/FileReadTool/FileReadTool.js.map +2 -2
  254. package/dist/tools/FileReadTool/prompt.js +1 -2
  255. package/dist/tools/FileReadTool/prompt.js.map +2 -2
  256. package/dist/tools/FileWriteTool/prompt.js +3 -5
  257. package/dist/tools/FileWriteTool/prompt.js.map +2 -2
  258. package/dist/tools/GlobTool/GlobTool.js +3 -2
  259. package/dist/tools/GlobTool/GlobTool.js.map +2 -2
  260. package/dist/tools/GrepTool/GrepTool.js +16 -5
  261. package/dist/tools/GrepTool/GrepTool.js.map +2 -2
  262. package/dist/tools/ListMcpResourcesTool/ListMcpResourcesTool.js.map +2 -2
  263. package/dist/tools/MCPSearchTool/MCPSearchTool.js +172 -0
  264. package/dist/tools/MCPSearchTool/MCPSearchTool.js.map +7 -0
  265. package/dist/tools/MCPSearchTool/prompt.js +77 -0
  266. package/dist/tools/MCPSearchTool/prompt.js.map +7 -0
  267. package/dist/tools/MultiEditTool/prompt.js +4 -7
  268. package/dist/tools/MultiEditTool/prompt.js.map +2 -2
  269. package/dist/tools/PlanModeTool/EnterPlanModeTool.js +12 -8
  270. package/dist/tools/PlanModeTool/EnterPlanModeTool.js.map +2 -2
  271. package/dist/tools/PlanModeTool/ExitPlanModeTool.js +54 -1
  272. package/dist/tools/PlanModeTool/ExitPlanModeTool.js.map +2 -2
  273. package/dist/tools/PlanModeTool/prompt.js +23 -74
  274. package/dist/tools/PlanModeTool/prompt.js.map +2 -2
  275. package/dist/tools/SendMessageTool/SendMessageTool.js +341 -0
  276. package/dist/tools/SendMessageTool/SendMessageTool.js.map +7 -0
  277. package/dist/tools/SendMessageTool/prompt.js +44 -0
  278. package/dist/tools/SendMessageTool/prompt.js.map +7 -0
  279. package/dist/tools/TaskCreateTool/prompt.js +15 -4
  280. package/dist/tools/TaskCreateTool/prompt.js.map +2 -2
  281. package/dist/tools/TaskListTool/prompt.js +18 -3
  282. package/dist/tools/TaskListTool/prompt.js.map +2 -2
  283. package/dist/tools/TaskOutputTool/prompt.js +4 -3
  284. package/dist/tools/TaskOutputTool/prompt.js.map +2 -2
  285. package/dist/tools/TaskTool/TaskTool.js +762 -98
  286. package/dist/tools/TaskTool/TaskTool.js.map +3 -3
  287. package/dist/tools/TaskTool/constants.js +8 -2
  288. package/dist/tools/TaskTool/constants.js.map +2 -2
  289. package/dist/tools/TaskTool/prompt.js +74 -70
  290. package/dist/tools/TaskTool/prompt.js.map +2 -2
  291. package/dist/tools/TaskUpdateTool/TaskUpdateTool.js +15 -1
  292. package/dist/tools/TaskUpdateTool/TaskUpdateTool.js.map +2 -2
  293. package/dist/tools/TeamCreateTool/TeamCreateTool.js +129 -0
  294. package/dist/tools/TeamCreateTool/TeamCreateTool.js.map +7 -0
  295. package/dist/tools/TeamCreateTool/prompt.js +58 -0
  296. package/dist/tools/TeamCreateTool/prompt.js.map +7 -0
  297. package/dist/tools/TeamDeleteTool/TeamDeleteTool.js +151 -0
  298. package/dist/tools/TeamDeleteTool/TeamDeleteTool.js.map +7 -0
  299. package/dist/tools/TeamDeleteTool/prompt.js +16 -0
  300. package/dist/tools/TeamDeleteTool/prompt.js.map +7 -0
  301. package/dist/tools/URLFetcherTool/URLFetcherTool.js +106 -15
  302. package/dist/tools/URLFetcherTool/URLFetcherTool.js.map +2 -2
  303. package/dist/tools/URLFetcherTool/prompt.js +3 -2
  304. package/dist/tools/URLFetcherTool/prompt.js.map +2 -2
  305. package/dist/tools/WebSearchTool/WebSearchTool.js +2 -1
  306. package/dist/tools/WebSearchTool/WebSearchTool.js.map +2 -2
  307. package/dist/tools/WebSearchTool/prompt.js +5 -4
  308. package/dist/tools/WebSearchTool/prompt.js.map +2 -2
  309. package/dist/tools.js +100 -20
  310. package/dist/tools.js.map +2 -2
  311. package/dist/types/PermissionMode.js +35 -6
  312. package/dist/types/PermissionMode.js.map +2 -2
  313. package/dist/types/hooks.js +2 -0
  314. package/dist/types/hooks.js.map +2 -2
  315. package/dist/types/plugin.js +2 -0
  316. package/dist/types/plugin.js.map +3 -3
  317. package/dist/utils/CircuitBreaker.js +15 -9
  318. package/dist/utils/CircuitBreaker.js.map +2 -2
  319. package/dist/utils/agentLoader.js +249 -112
  320. package/dist/utils/agentLoader.js.map +2 -2
  321. package/dist/utils/animationManager.js +40 -3
  322. package/dist/utils/animationManager.js.map +2 -2
  323. package/dist/utils/ask.js +7 -6
  324. package/dist/utils/ask.js.map +2 -2
  325. package/dist/utils/atomicWrite.js +23 -0
  326. package/dist/utils/atomicWrite.js.map +7 -0
  327. package/dist/utils/autoCompactCore.js +73 -56
  328. package/dist/utils/autoCompactCore.js.map +2 -2
  329. package/dist/utils/autoMemoryPaths.js +89 -0
  330. package/dist/utils/autoMemoryPaths.js.map +7 -0
  331. package/dist/utils/config.js +63 -38
  332. package/dist/utils/config.js.map +2 -2
  333. package/dist/utils/configSchema.js +13 -8
  334. package/dist/utils/configSchema.js.map +2 -2
  335. package/dist/utils/credentials/index.js +14 -0
  336. package/dist/utils/credentials/index.js.map +2 -2
  337. package/dist/utils/dualPath.js +24 -0
  338. package/dist/utils/dualPath.js.map +7 -0
  339. package/dist/utils/exit.js +66 -7
  340. package/dist/utils/exit.js.map +2 -2
  341. package/dist/utils/externalEditor.js +155 -0
  342. package/dist/utils/externalEditor.js.map +7 -0
  343. package/dist/utils/fileLock.js +67 -0
  344. package/dist/utils/fileLock.js.map +7 -0
  345. package/dist/utils/format.js +24 -14
  346. package/dist/utils/format.js.map +2 -2
  347. package/dist/utils/globalErrorHandler.js +5 -96
  348. package/dist/utils/globalErrorHandler.js.map +3 -3
  349. package/dist/utils/groupHandlers/parallelTasksHandler.js +5 -3
  350. package/dist/utils/groupHandlers/parallelTasksHandler.js.map +2 -2
  351. package/dist/utils/groupHandlers/taskHandler.js +2 -2
  352. package/dist/utils/groupHandlers/taskHandler.js.map +2 -2
  353. package/dist/utils/hookManager.js +64 -6
  354. package/dist/utils/hookManager.js.map +2 -2
  355. package/dist/utils/log.js +6 -2
  356. package/dist/utils/log.js.map +2 -2
  357. package/dist/utils/markdown.js +237 -19
  358. package/dist/utils/markdown.js.map +2 -2
  359. package/dist/utils/messageContextManager.js +18 -5
  360. package/dist/utils/messageContextManager.js.map +2 -2
  361. package/dist/utils/messageGroupManager.js +1 -1
  362. package/dist/utils/messageGroupManager.js.map +2 -2
  363. package/dist/utils/messages.js +104 -46
  364. package/dist/utils/messages.js.map +2 -2
  365. package/dist/utils/model.js +2 -2
  366. package/dist/utils/model.js.map +2 -2
  367. package/dist/utils/pasteCache.js +8 -4
  368. package/dist/utils/pasteCache.js.map +2 -2
  369. package/dist/utils/pluginLoader.js +18 -0
  370. package/dist/utils/pluginLoader.js.map +2 -2
  371. package/dist/utils/secureKeyStorage.js +36 -7
  372. package/dist/utils/secureKeyStorage.js.map +2 -2
  373. package/dist/utils/simpleMode.js +7 -0
  374. package/dist/utils/simpleMode.js.map +7 -0
  375. package/dist/utils/streamingState.js +11 -1
  376. package/dist/utils/streamingState.js.map +2 -2
  377. package/dist/utils/taskDisplayUtils.js +2 -1
  378. package/dist/utils/taskDisplayUtils.js.map +2 -2
  379. package/dist/utils/teamConfig.js +2 -2
  380. package/dist/utils/teamConfig.js.map +2 -2
  381. package/dist/utils/thinking.js +6 -2
  382. package/dist/utils/thinking.js.map +3 -3
  383. package/dist/utils/tokenProgress.js +55 -0
  384. package/dist/utils/tokenProgress.js.map +7 -0
  385. package/dist/utils/toolRiskClassification.js +26 -17
  386. package/dist/utils/toolRiskClassification.js.map +2 -2
  387. package/dist/utils/tooling/toolError.js +12 -0
  388. package/dist/utils/tooling/toolError.js.map +7 -0
  389. package/dist/version.js +2 -2
  390. package/dist/version.js.map +1 -1
  391. package/package.json +10 -8
@@ -1,50 +1,9 @@
1
1
  import { PROJECT_FILE } from "../product.js";
2
2
  function getTaskManagementPrompt() {
3
3
  return `# Task Management
4
- 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.
5
- 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.
4
+ You have access to the TodoWrite tools to help you manage and plan tasks. Use these tools frequently to track progress and give the user visibility. They are also helpful for breaking down larger tasks into smaller steps.
6
5
 
7
- 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.
8
-
9
- Examples:
10
-
11
- <example>
12
- user: Run the build and fix any type errors
13
- assistant: I'm going to use the TodoWrite tool to write the following items to the todo list:
14
- - Run the build
15
- - Fix any type errors
16
-
17
- I'm now going to run the build using Bash.
18
-
19
- Looks like I found 10 type errors. I'm going to use the TodoWrite tool to write 10 items to the todo list.
20
-
21
- marking the first todo as in_progress
22
-
23
- Let me start working on the first item...
24
-
25
- The first item has been fixed, let me mark the first todo as completed, and move on to the second item...
26
- ..
27
- ..
28
- </example>
29
- In the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors.
30
-
31
- <example>
32
- user: Help me write a new feature that allows users to track their usage metrics and export them to various formats
33
- assistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task.
34
- Adding the following todos to the todo list:
35
- 1. Research existing metrics tracking in the codebase
36
- 2. Design the metrics collection system
37
- 3. Implement core metrics tracking functionality
38
- 4. Create export functionality for different formats
39
-
40
- Let me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that.
41
-
42
- I'm going to search for any existing metrics or telemetry code in the project.
43
-
44
- I've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned...
45
-
46
- [Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go]
47
- </example>
6
+ Mark todos as completed as soon as you finish each task. Do not batch up multiple tasks before marking them as completed.
48
7
 
49
8
  # Memory
50
9
  If the current working directory contains a file called ${PROJECT_FILE}, it will be automatically added to your context. This file serves multiple purposes:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/constants/prompts/taskManagement.ts"],
4
- "sourcesContent": ["import { PROJECT_FILE } from '../product'\n\nexport function getTaskManagementPrompt(): string {\n return `# Task Management\nYou 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.\nThese 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.\n\nIt 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.\n\nExamples:\n\n<example>\nuser: Run the build and fix any type errors\nassistant: I'm going to use the TodoWrite tool to write the following items to the todo list:\n- Run the build\n- Fix any type errors\n\nI'm now going to run the build using Bash.\n\nLooks like I found 10 type errors. I'm going to use the TodoWrite tool to write 10 items to the todo list.\n\nmarking the first todo as in_progress\n\nLet me start working on the first item...\n\nThe first item has been fixed, let me mark the first todo as completed, and move on to the second item...\n..\n..\n</example>\nIn the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors.\n\n<example>\nuser: Help me write a new feature that allows users to track their usage metrics and export them to various formats\nassistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task.\nAdding the following todos to the todo list:\n1. Research existing metrics tracking in the codebase\n2. Design the metrics collection system\n3. Implement core metrics tracking functionality\n4. Create export functionality for different formats\n\nLet me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that.\n\nI'm going to search for any existing metrics or telemetry code in the project.\n\nI've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned...\n\n[Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go]\n</example>\n\n# Memory\nIf the current working directory contains a file called ${PROJECT_FILE}, it will be automatically added to your context. This file serves multiple purposes:\n1. Storing frequently used bash commands (build, test, lint, etc.) so you can use them without searching each time\n2. Recording the user's code style preferences (naming conventions, preferred libraries, etc.)\n3. Maintaining useful information about the codebase structure and organization\n\nWhen 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.`\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAEtB,SAAS,0BAAkC;AAChD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0DA+CiD,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,+IAKyE,YAAY,8HAA8H,YAAY;AACrS;",
4
+ "sourcesContent": ["import { PROJECT_FILE } from '../product'\n\nexport function getTaskManagementPrompt(): string {\n return `# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools frequently to track progress and give the user visibility. They are also helpful for breaking down larger tasks into smaller steps.\n\nMark todos as completed as soon as you finish each task. Do not batch up multiple tasks before marking them as completed.\n\n# Memory\nIf the current working directory contains a file called ${PROJECT_FILE}, it will be automatically added to your context. This file serves multiple purposes:\n1. Storing frequently used bash commands (build, test, lint, etc.) so you can use them without searching each time\n2. Recording the user's code style preferences (naming conventions, preferred libraries, etc.)\n3. Maintaining useful information about the codebase structure and organization\n\nWhen 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.`\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAEtB,SAAS,0BAAkC;AAChD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0DAMiD,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,+IAKyE,YAAY,8HAA8H,YAAY;AACrS;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,50 @@
1
+ function getTeamLeadOverlay() {
2
+ return `# Team Role: Team Lead (Coordinator)
3
+
4
+ You are the **team lead** of an active Agent Team. Your responsibilities:
5
+
6
+ ## Core Duties
7
+ - **Plan**: Break down complex tasks into independent, parallelizable units
8
+ - **Decompose**: Identify task dependencies and optimal execution order
9
+ - **Dispatch**: Assign tasks to teammates via the Task tool with \`team_name\` parameter
10
+ - **Supervise**: Monitor teammate progress via TaskList, respond to their messages
11
+ - **Synthesize**: Combine teammate findings into a coherent final result
12
+
13
+ ## Rules
14
+ - Do NOT execute domain work yourself \u2014 delegate to teammates
15
+ - When a teammate reports a safety concern via SendMessage, evaluate and respond with guidance
16
+ - Use TaskCreate/TaskUpdate/TaskList to manage the shared task board
17
+ - When all work is complete: send shutdown_request to all teammates, then use TeamDelete to clean up
18
+ - Be patient with teammates \u2014 they go idle between turns, which is normal behavior
19
+ - When reporting teammate progress to the user, do not quote their full messages \u2014 summarize concisely`;
20
+ }
21
+ function getTeammateOverlay() {
22
+ return `# Team Role: Teammate (Executor)
23
+
24
+ You are a **teammate** in an active Agent Team. You execute tasks autonomously.
25
+
26
+ ## Core Duties
27
+ - **Execute**: Complete your assigned task fully using all available tools
28
+ - **Report**: Send findings to team-lead via SendMessage (your text output is NOT visible to the team)
29
+ - **Track**: Use TaskList to find your assigned task (look for your name as owner). If a task exists, update it via TaskUpdate with the **numeric task ID** (e.g., "1", "2") \u2014 NOT your agent name. If no task is assigned to you on the board, skip TaskUpdate and just report results via SendMessage.
30
+ - **Collaborate**: Read the shared task list (TaskList) to understand context and avoid duplicate work
31
+
32
+ ## Communication
33
+ - Your plain text output is NOT visible to the team lead or other teammates
34
+ - To communicate with anyone, you MUST use the SendMessage tool
35
+ - Send concise progress updates and final results to the team-lead
36
+ - If you encounter a safety concern or need confirmation, message the team-lead via SendMessage and wait for their response
37
+
38
+ ## Capabilities & Restrictions
39
+ - You run with 'acceptEdits' permission mode \u2014 file edits and bash commands are auto-approved within the project directory
40
+ - Critical safety checks remain enforced: fork bombs, rm -rf /, eval injection, and directory sandboxing cannot be bypassed
41
+ - You have access to all standard tools (Read, Write, Edit, Bash, Grep, Glob, etc.)
42
+ - You may use the Task tool to spawn standalone subagents for isolated research (subagent cannot nest further)
43
+ - You must NOT call TeamCreate or TeamDelete \u2014 team management is leader-only
44
+ - After completing your task, check TaskList for additional unblocked work to claim`;
45
+ }
46
+ export {
47
+ getTeamLeadOverlay,
48
+ getTeammateOverlay
49
+ };
50
+ //# sourceMappingURL=teamOverlays.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/constants/prompts/teamOverlays.ts"],
4
+ "sourcesContent": ["/**\n * Team role overlays for Agent Teams.\n *\n * These are injected into the full system prompt (after outputStyle/conciseness,\n * before envInfo) to specialize the agent's behavior for its team role.\n *\n * - team-lead: coordinator that plans, dispatches, supervises, synthesizes\n * - teammate: executor that works autonomously and reports back\n */\n\n/**\n * Team-lead overlay \u2014 coordinator role.\n *\n * The team-lead (REPL engine) gets this overlay when a team is created.\n * It guides the agent to plan/decompose/dispatch rather than execute domain work.\n */\nexport function getTeamLeadOverlay(): string {\n return `# Team Role: Team Lead (Coordinator)\n\nYou are the **team lead** of an active Agent Team. Your responsibilities:\n\n## Core Duties\n- **Plan**: Break down complex tasks into independent, parallelizable units\n- **Decompose**: Identify task dependencies and optimal execution order\n- **Dispatch**: Assign tasks to teammates via the Task tool with \\`team_name\\` parameter\n- **Supervise**: Monitor teammate progress via TaskList, respond to their messages\n- **Synthesize**: Combine teammate findings into a coherent final result\n\n## Rules\n- Do NOT execute domain work yourself \u2014 delegate to teammates\n- When a teammate reports a safety concern via SendMessage, evaluate and respond with guidance\n- Use TaskCreate/TaskUpdate/TaskList to manage the shared task board\n- When all work is complete: send shutdown_request to all teammates, then use TeamDelete to clean up\n- Be patient with teammates \u2014 they go idle between turns, which is normal behavior\n- When reporting teammate progress to the user, do not quote their full messages \u2014 summarize concisely`\n}\n\n/**\n * Teammate overlay \u2014 executor role.\n *\n * Each teammate spawned via TaskTool with team_name gets this overlay.\n * It guides autonomous execution with proper team communication.\n */\nexport function getTeammateOverlay(): string {\n return `# Team Role: Teammate (Executor)\n\nYou are a **teammate** in an active Agent Team. You execute tasks autonomously.\n\n## Core Duties\n- **Execute**: Complete your assigned task fully using all available tools\n- **Report**: Send findings to team-lead via SendMessage (your text output is NOT visible to the team)\n- **Track**: Use TaskList to find your assigned task (look for your name as owner). If a task exists, update it via TaskUpdate with the **numeric task ID** (e.g., \"1\", \"2\") \u2014 NOT your agent name. If no task is assigned to you on the board, skip TaskUpdate and just report results via SendMessage.\n- **Collaborate**: Read the shared task list (TaskList) to understand context and avoid duplicate work\n\n## Communication\n- Your plain text output is NOT visible to the team lead or other teammates\n- To communicate with anyone, you MUST use the SendMessage tool\n- Send concise progress updates and final results to the team-lead\n- If you encounter a safety concern or need confirmation, message the team-lead via SendMessage and wait for their response\n\n## Capabilities & Restrictions\n- You run with 'acceptEdits' permission mode \u2014 file edits and bash commands are auto-approved within the project directory\n- Critical safety checks remain enforced: fork bombs, rm -rf /, eval injection, and directory sandboxing cannot be bypassed\n- You have access to all standard tools (Read, Write, Edit, Bash, Grep, Glob, etc.)\n- You may use the Task tool to spawn standalone subagents for isolated research (subagent cannot nest further)\n- You must NOT call TeamCreate or TeamDelete \u2014 team management is leader-only\n- After completing your task, check TaskList for additional unblocked work to claim`\n}\n"],
5
+ "mappings": "AAgBO,SAAS,qBAA6B;AAC3C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBT;AAQO,SAAS,qBAA6B;AAC3C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBT;",
6
+ "names": []
7
+ }
@@ -13,38 +13,13 @@ There are additional slash commands and flags available to the user. If the user
13
13
  To give feedback, users should ${MACRO.ISSUES_EXPLAINER}.
14
14
 
15
15
  # Tone and style
16
- 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).
16
+ - Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
17
+ - Your responses should be short and concise.
18
+ - When referencing specific functions or pieces of code include the pattern file_path:line_number to allow the user to easily navigate to the source code location.
19
+ - Do not use a colon before tool calls. Your tool calls may not be shown directly in the output, so text like "Let me read the file:" followed by a read tool call should just be "Let me read the file." with a period.
17
20
  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.
18
21
  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.
19
22
  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.
20
- 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.
21
- 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.
22
- 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...".
23
- - Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
24
-
25
- # No time estimates
26
- Never give time estimates or predictions for how long tasks will take. Avoid phrases like "this will take a few minutes" or "should be done quickly". Focus on what needs to be done, not how long it might take.
27
-
28
- # Professional objectivity
29
- Prioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving. Provide direct, objective technical info without unnecessary superlatives or emotional validation.
30
-
31
- Examples of appropriate verbosity:
32
- <example>
33
- user: 2 + 2
34
- assistant: 4
35
- </example>
36
- <example>
37
- user: what command should I run to list files?
38
- assistant: ls
39
- </example>
40
- <example>
41
- user: what files are in src/?
42
- assistant: [runs ls] foo.c, bar.c, baz.c
43
- </example>
44
- <example>
45
- user: write tests for new feature
46
- assistant: [uses search tools to find test patterns, reads relevant files concurrently, uses edit tool to write tests]
47
- </example>
48
23
 
49
24
  # Proactiveness
50
25
  You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/constants/prompts/toneAndStyle.ts"],
4
- "sourcesContent": ["import { PRODUCT_NAME, PRODUCT_COMMAND } from '../product'\n\n// Hardcoded to avoid circular dependency:\n// BashTool \u2192 prompt \u2192 FileReadTool \u2192 NotebookReadTool \u2192 BashTool/utils \u2192 claude \u2192 prompts \u2192 toneAndStyle \u2192 BashTool\nconst BASH_TOOL_NAME = 'Bash'\nimport { MACRO } from '../macros'\nimport {\n INTERRUPT_MESSAGE,\n INTERRUPT_MESSAGE_FOR_TOOL_USE,\n} from '@utils/messages'\n\nexport function getToneAndStylePrompt(): string {\n return `Here are useful slash commands users can run to interact with you:\n- /help: Get help with using ${PRODUCT_NAME}\n- /compact: Compact and continue the conversation. This is useful if the conversation is reaching the context limit\nThere 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.\nTo give feedback, users should ${MACRO.ISSUES_EXPLAINER}.\n\n# Tone and style\nYou 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).\nRemember 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.\nOutput 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.\nIf 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.\nIMPORTANT: 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.\nIMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.\nIMPORTANT: 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...\".\n- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\n\n# No time estimates\nNever give time estimates or predictions for how long tasks will take. Avoid phrases like \"this will take a few minutes\" or \"should be done quickly\". Focus on what needs to be done, not how long it might take.\n\n# Professional objectivity\nPrioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving. Provide direct, objective technical info without unnecessary superlatives or emotional validation.\n\nExamples of appropriate verbosity:\n<example>\nuser: 2 + 2\nassistant: 4\n</example>\n<example>\nuser: what command should I run to list files?\nassistant: ls\n</example>\n<example>\nuser: what files are in src/?\nassistant: [runs ls] foo.c, bar.c, baz.c\n</example>\n<example>\nuser: write tests for new feature\nassistant: [uses search tools to find test patterns, reads relevant files concurrently, uses edit tool to write tests]\n</example>\n\n# Proactiveness\nYou are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:\n1. Doing the right thing when asked, including taking actions and follow-up actions\n2. Not surprising the user with actions you take without asking\nFor 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.\n3. 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.\n\n# Synthetic messages\nSometimes, 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.`\n}\n"],
5
- "mappings": "AAAA,SAAS,cAAc,uBAAuB;AAI9C,MAAM,iBAAiB;AACvB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEA,SAAS,wBAAgC;AAC9C,SAAO;AAAA,+BACsB,YAAY;AAAA;AAAA,8FAEmD,YAAY,gCAAgC,eAAe,cAAc,cAAc;AAAA,iCACpJ,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,qKAK8G,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yDAuC1H,iBAAiB,OAAO,8BAA8B;AAC/G;",
4
+ "sourcesContent": ["import { PRODUCT_NAME, PRODUCT_COMMAND } from '../product'\n\n// Hardcoded to avoid circular dependency:\n// BashTool \u2192 prompt \u2192 FileReadTool \u2192 NotebookReadTool \u2192 BashTool/utils \u2192 claude \u2192 prompts \u2192 toneAndStyle \u2192 BashTool\nconst BASH_TOOL_NAME = 'Bash'\nimport { MACRO } from '../macros'\nimport {\n INTERRUPT_MESSAGE,\n INTERRUPT_MESSAGE_FOR_TOOL_USE,\n} from '@utils/messages'\n\nexport function getToneAndStylePrompt(): string {\n return `Here are useful slash commands users can run to interact with you:\n- /help: Get help with using ${PRODUCT_NAME}\n- /compact: Compact and continue the conversation. This is useful if the conversation is reaching the context limit\nThere 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.\nTo give feedback, users should ${MACRO.ISSUES_EXPLAINER}.\n\n# Tone and style\n - Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\n - Your responses should be short and concise.\n - When referencing specific functions or pieces of code include the pattern file_path:line_number to allow the user to easily navigate to the source code location.\n - Do not use a colon before tool calls. Your tool calls may not be shown directly in the output, so text like \"Let me read the file:\" followed by a read tool call should just be \"Let me read the file.\" with a period.\nRemember 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.\nOutput 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.\nIf 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.\n\n# Proactiveness\nYou are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:\n1. Doing the right thing when asked, including taking actions and follow-up actions\n2. Not surprising the user with actions you take without asking\nFor 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.\n3. 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.\n\n# Synthetic messages\nSometimes, 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.`\n}\n"],
5
+ "mappings": "AAAA,SAAS,cAAc,uBAAuB;AAI9C,MAAM,iBAAiB;AACvB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEA,SAAS,wBAAgC;AAC9C,SAAO;AAAA,+BACsB,YAAY;AAAA;AAAA,8FAEmD,YAAY,gCAAgC,eAAe,cAAc,cAAc;AAAA,iCACpJ,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qKAQ8G,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yDAW1H,iBAAiB,OAAO,8BAA8B;AAC/G;",
6
6
  "names": []
7
7
  }
@@ -1,34 +1,19 @@
1
1
  function getToolUsagePolicyPrompt() {
2
2
  return `# Tool usage policy
3
- - When doing file search, prefer to use the Task tool in order to reduce context usage.
3
+ - When doing file search, prefer to use the Agent tool in order to reduce context usage.
4
4
  - You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.
5
5
  - When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
6
6
  - It is always better to speculatively read multiple files as a batch that are potentially useful.
7
7
  - It is always better to speculatively perform multiple searches as a batch that are potentially useful.
8
8
  - For making multiple edits to the same file, prefer using the MultiEdit tool over multiple Edit tool calls.
9
9
 
10
- # MCP Resources
11
- If MCP (Model Context Protocol) servers are configured, you have access to MCP Resources through two specialized tools:
12
- - ListMcpResources: Use this tool to discover available resources from connected MCP servers. Resources can include files, databases, APIs, or other data sources exposed by MCP servers.
13
- - ReadMcpResource: Use this tool to read the content of a specific MCP resource by its URI. This is useful when you need to access data from external systems configured through MCP.
14
- When the user mentions accessing external data sources, databases, or resources from configured services, consider using these MCP resource tools to discover and read the relevant data.
10
+ # MCP
11
+ When MCP servers are configured, you have access to MCP Resources (ListMcpResources, ReadMcpResource) and MCP Tools (prefixed "mcp__"). Review each tool's description to understand its capabilities.
15
12
 
16
- # MCP Tools
17
- When MCP servers are configured, you have access to MCP Tools in addition to built-in tools. MCP tools are named with the prefix "mcp__" (e.g., mcp__BrightData__search_engine).
18
- - Review each tool's description to understand its capabilities and limitations
19
- - Choose the most appropriate tool based on the task requirements, not a fixed priority
20
- - MCP tools often have additional capabilities (e.g., bypass bot detection, access to more data sources)
21
-
22
- # Tool Failure Recovery (IMPORTANT)
23
- When a tool call fails (returns is_error: true), you MUST try alternative approaches before giving up:
24
- 1. **Retry with different parameters**: If the error suggests parameter issues, adjust and retry
25
- 2. **Try equivalent tools**: If one search/fetch tool fails, try another available tool with similar capabilities
26
- - Example: If mcp__BrightData__search_engine fails \u2192 try WebSearch or mcp__BrightData__scrape_as_markdown
27
- - Example: If WebFetch fails \u2192 try mcp__BrightData__scrape_as_markdown
28
- 3. **Try different strategies**: Break down the task or use alternative approaches
29
- 4. **Only give up after exhausting options**: Report failure to user only when all reasonable alternatives have been tried
30
-
31
- Never tell the user "I cannot do this" after a single tool failure if alternative tools are available.
13
+ **MCP tool preference**: When MCP tools are available (listed in <available-deferred-tools>), prefer them over built-in equivalents for web operations:
14
+ - For web search: prefer MCP search tools (e.g. mcp__BrightData__search_engine) over built-in WebSearch \u2014 they have broader coverage, especially for regional/non-English content
15
+ - For web scraping: prefer MCP scraping tools (e.g. mcp__BrightData__scrape_as_markdown) over built-in WebFetch \u2014 they bypass bot detection and handle protected sites
16
+ - Use ToolSearch to activate MCP tools BEFORE calling them. Check <available-deferred-tools> for what's available.
32
17
 
33
18
  - 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.`;
34
19
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/constants/prompts/toolUsagePolicy.ts"],
4
- "sourcesContent": ["import { BashTool } from '@tools/BashTool/BashTool'\n\nexport function getToolUsagePolicyPrompt(): string {\n return `# Tool usage policy\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.\n- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.\n- It is always better to speculatively read multiple files as a batch that are potentially useful.\n- It is always better to speculatively perform multiple searches as a batch that are potentially useful.\n- For making multiple edits to the same file, prefer using the MultiEdit tool over multiple Edit tool calls.\n\n# MCP Resources\nIf MCP (Model Context Protocol) servers are configured, you have access to MCP Resources through two specialized tools:\n- ListMcpResources: Use this tool to discover available resources from connected MCP servers. Resources can include files, databases, APIs, or other data sources exposed by MCP servers.\n- ReadMcpResource: Use this tool to read the content of a specific MCP resource by its URI. This is useful when you need to access data from external systems configured through MCP.\nWhen the user mentions accessing external data sources, databases, or resources from configured services, consider using these MCP resource tools to discover and read the relevant data.\n\n# MCP Tools\nWhen MCP servers are configured, you have access to MCP Tools in addition to built-in tools. MCP tools are named with the prefix \"mcp__\" (e.g., mcp__BrightData__search_engine).\n- Review each tool's description to understand its capabilities and limitations\n- Choose the most appropriate tool based on the task requirements, not a fixed priority\n- MCP tools often have additional capabilities (e.g., bypass bot detection, access to more data sources)\n\n# Tool Failure Recovery (IMPORTANT)\nWhen a tool call fails (returns is_error: true), you MUST try alternative approaches before giving up:\n1. **Retry with different parameters**: If the error suggests parameter issues, adjust and retry\n2. **Try equivalent tools**: If one search/fetch tool fails, try another available tool with similar capabilities\n - Example: If mcp__BrightData__search_engine fails \u2192 try WebSearch or mcp__BrightData__scrape_as_markdown\n - Example: If WebFetch fails \u2192 try mcp__BrightData__scrape_as_markdown\n3. **Try different strategies**: Break down the task or use alternative approaches\n4. **Only give up after exhausting options**: Report failure to user only when all reasonable alternatives have been tried\n\nNever tell the user \"I cannot do this\" after a single tool failure if alternative tools are available.\n\n- 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.`\n}\n"],
5
- "mappings": "AAEO,SAAS,2BAAmC;AACjD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCT;",
4
+ "sourcesContent": ["import { BashTool } from '@tools/BashTool/BashTool'\n\nexport function getToolUsagePolicyPrompt(): string {\n return `# Tool usage policy\n- When doing file search, prefer to use the Agent tool in order to reduce context usage.\n- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.\n- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.\n- It is always better to speculatively read multiple files as a batch that are potentially useful.\n- It is always better to speculatively perform multiple searches as a batch that are potentially useful.\n- For making multiple edits to the same file, prefer using the MultiEdit tool over multiple Edit tool calls.\n\n# MCP\nWhen MCP servers are configured, you have access to MCP Resources (ListMcpResources, ReadMcpResource) and MCP Tools (prefixed \"mcp__\"). Review each tool's description to understand its capabilities.\n\n**MCP tool preference**: When MCP tools are available (listed in <available-deferred-tools>), prefer them over built-in equivalents for web operations:\n- For web search: prefer MCP search tools (e.g. mcp__BrightData__search_engine) over built-in WebSearch \u2014 they have broader coverage, especially for regional/non-English content\n- For web scraping: prefer MCP scraping tools (e.g. mcp__BrightData__scrape_as_markdown) over built-in WebFetch \u2014 they bypass bot detection and handle protected sites\n- Use ToolSearch to activate MCP tools BEFORE calling them. Check <available-deferred-tools> for what's available.\n\n- 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.`\n}\n"],
5
+ "mappings": "AAEO,SAAS,2BAAmC;AACjD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBT;",
6
6
  "names": []
7
7
  }
@@ -12,8 +12,8 @@ const TOOL_INPUT_EXAMPLES = {
12
12
  Ls: '{"path": "/path/to/directory"}',
13
13
  // Shell Execution
14
14
  Bash: '{"command": "ls -la"}',
15
- BashOutput: '{"command": "ls -la", "shell_id": "optional_shell_id"}',
16
- KillShell: '{"shell_id": "shell_id_to_kill"}',
15
+ TaskOutput: '{"task_id": "task-uuid"}',
16
+ TaskStop: '{"task_id": "task-uuid"}',
17
17
  // Task Management
18
18
  Task: '{"prompt": "task description", "description": "short description", "subagent_type": "agent-type"}',
19
19
  TodoWrite: '{"todos": [{"content": "Task description", "status": "pending", "priority": "medium"}]}',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/constants/toolInputExamples.ts"],
4
- "sourcesContent": ["/**\n * Tool Input Examples and Descriptions\n *\n * Provides user-friendly examples and descriptions for all tools to help with\n * error messaging when tool input validation fails. Each entry includes:\n * - A canonical example showing required parameters\n * - Optional description for complex tools\n */\n\nexport const TOOL_INPUT_EXAMPLES: Record<string, string> = {\n // File Operations\n Read: '{\"file_path\": \"/path/to/file.txt\"}',\n Write: '{\"file_path\": \"/path/to/file.txt\", \"content\": \"file contents\"}',\n Edit: '{\"file_path\": \"/path/to/file.txt\", \"old_string\": \"old text\", \"new_string\": \"new text\"}',\n MultiEdit:\n '{\"file_path\": \"/path/to/file.txt\", \"edits\": [{\"old_string\": \"old\", \"new_string\": \"new\"}]}',\n NotebookEdit:\n '{\"notebook_path\": \"/path/to/notebook.ipynb\", \"new_source\": \"cell source code\"}',\n NotebookRead: '{\"notebook_path\": \"/path/to/notebook.ipynb\"}',\n\n // Directory and Search\n Glob: '{\"pattern\": \"**/*.ts\", \"path\": \"/optional/search/path\"}',\n Grep: '{\"pattern\": \"search_term\", \"path\": \"/optional/search/path\", \"glob\": \"*.ts\"}',\n Ls: '{\"path\": \"/path/to/directory\"}',\n\n // Shell Execution\n Bash: '{\"command\": \"ls -la\"}',\n BashOutput: '{\"command\": \"ls -la\", \"shell_id\": \"optional_shell_id\"}',\n KillShell: '{\"shell_id\": \"shell_id_to_kill\"}',\n\n // Task Management\n Task: '{\"prompt\": \"task description\", \"description\": \"short description\", \"subagent_type\": \"agent-type\"}',\n TodoWrite:\n '{\"todos\": [{\"content\": \"Task description\", \"status\": \"pending\", \"priority\": \"medium\"}]}',\n\n // Web and API\n WebSearch: '{\"query\": \"search query\"}',\n URLFetcher:\n '{\"url\": \"https://example.com\", \"prompt\": \"what to extract from page\"}',\n\n // LLM Interactions\n AskExpertModel:\n '{\"model\": \"model-name\", \"prompt\": \"question for expert\", \"context\": \"optional context\"}',\n AskUserQuestion:\n '{\"question\": \"question to ask user\", \"default\": \"optional default\"}',\n\n // Memory (Anthropic-only)\n MemoryRead: '{\"name\": \"memory_block_name\"}',\n MemoryWrite: '{\"name\": \"memory_block_name\", \"content\": \"memory content\"}',\n\n // Planning and Reasoning\n Think: '{\"reasoning\": \"your thinking process\", \"plan\": \"optional plan\"}',\n EnterPlanMode: '{}',\n ExitPlanMode: '{}',\n\n // Code Intelligence\n Lsp: '{\"method\": \"textDocument/definition\", \"params\": {\"position\": {\"line\": 10, \"character\": 5}}}',\n Skill: '{\"skill\": \"skill_name\", \"args\": \"optional arguments\"}',\n\n // MCP Resources\n ListMcpResources:\n '{\"server\": \"server_name\", \"uri\": \"optional_resource_uri\", \"include\": \"resource_type\"}',\n ReadMcpResource: '{\"uri\": \"resource://path\"}',\n}\n\n/**\n * Tool Input Descriptions\n *\n * Provides helpful descriptions for complex tools to include in error messages\n */\nexport const TOOL_DESCRIPTIONS: Record<string, string> = {\n MultiEdit:\n 'Allows multiple edits in a single file. The \"edits\" parameter is an array of edit objects.',\n NotebookEdit:\n 'For Jupyter notebooks. Requires notebook_path and new_source for the cell content.',\n Grep: 'Searches file contents with regex. Optional \"glob\" parameter filters files by pattern.',\n Task: 'Creates a task for an AI agent. subagent_type determines which agent handles the task.',\n TodoWrite:\n 'Manages a task list. Each todo requires content (description), status (pending/in_progress/completed), and priority (high/medium/low).',\n URLFetcher:\n 'Fetches web content. The \"prompt\" parameter guides what to extract from the page.',\n AskExpertModel:\n 'Queries an alternative LLM model. Useful for specialized tasks requiring different models.',\n Lsp: 'Language Server Protocol queries for code intelligence. Method and params depend on LSP spec.',\n}\n\n/**\n * Parameter Descriptions for Common Tool Parameters\n *\n * Helps provide more specific error messages when particular parameters are invalid\n */\nexport const PARAMETER_DESCRIPTIONS: Record<string, Record<string, string>> = {\n Read: {\n file_path: 'Must be an absolute file path (e.g., /home/user/file.txt)',\n offset: 'Optional line number to start reading from (0-indexed)',\n limit: 'Optional number of lines to read from the offset',\n },\n Write: {\n file_path: 'Must be an absolute file path (e.g., /home/user/file.txt)',\n content: 'The file contents to write',\n },\n Edit: {\n file_path: 'Must be an absolute file path (e.g., /home/user/file.txt)',\n old_string: 'The exact text to find and replace (must match exactly)',\n new_string: 'The text to replace it with',\n },\n Bash: {\n command:\n 'The shell command to execute (will run in current working directory)',\n timeout: 'Maximum execution time in milliseconds (max 600000 = 10 minutes)',\n run_in_background:\n 'Set to true to run command without waiting for completion',\n },\n Glob: {\n pattern: 'Glob pattern like **/*.ts or src/**/*.{ts,tsx}',\n path: 'Directory to search in (optional, defaults to current directory)',\n },\n Grep: {\n pattern: 'Regular expression pattern to search for',\n path: 'Directory to search in (optional, defaults to current directory)',\n glob: 'Additional glob pattern to filter files being searched',\n },\n TodoWrite: {\n todos:\n 'Array of todo items. Each item must have: content (string), status (pending/in_progress/completed), priority (high/medium/low). Optional: id, activeForm.',\n },\n}\n"],
5
- "mappings": "AASO,MAAM,sBAA8C;AAAA;AAAA,EAEzD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WACE;AAAA,EACF,cACE;AAAA,EACF,cAAc;AAAA;AAAA,EAGd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA;AAAA,EAGJ,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,WAAW;AAAA;AAAA,EAGX,MAAM;AAAA,EACN,WACE;AAAA;AAAA,EAGF,WAAW;AAAA,EACX,YACE;AAAA;AAAA,EAGF,gBACE;AAAA,EACF,iBACE;AAAA;AAAA,EAGF,YAAY;AAAA,EACZ,aAAa;AAAA;AAAA,EAGb,OAAO;AAAA,EACP,eAAe;AAAA,EACf,cAAc;AAAA;AAAA,EAGd,KAAK;AAAA,EACL,OAAO;AAAA;AAAA,EAGP,kBACE;AAAA,EACF,iBAAiB;AACnB;AAOO,MAAM,oBAA4C;AAAA,EACvD,WACE;AAAA,EACF,cACE;AAAA,EACF,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WACE;AAAA,EACF,YACE;AAAA,EACF,gBACE;AAAA,EACF,KAAK;AACP;AAOO,MAAM,yBAAiE;AAAA,EAC5E,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACJ,SACE;AAAA,IACF,SAAS;AAAA,IACT,mBACE;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA,WAAW;AAAA,IACT,OACE;AAAA,EACJ;AACF;",
4
+ "sourcesContent": ["/**\n * Tool Input Examples and Descriptions\n *\n * Provides user-friendly examples and descriptions for all tools to help with\n * error messaging when tool input validation fails. Each entry includes:\n * - A canonical example showing required parameters\n * - Optional description for complex tools\n */\n\nexport const TOOL_INPUT_EXAMPLES: Record<string, string> = {\n // File Operations\n Read: '{\"file_path\": \"/path/to/file.txt\"}',\n Write: '{\"file_path\": \"/path/to/file.txt\", \"content\": \"file contents\"}',\n Edit: '{\"file_path\": \"/path/to/file.txt\", \"old_string\": \"old text\", \"new_string\": \"new text\"}',\n MultiEdit:\n '{\"file_path\": \"/path/to/file.txt\", \"edits\": [{\"old_string\": \"old\", \"new_string\": \"new\"}]}',\n NotebookEdit:\n '{\"notebook_path\": \"/path/to/notebook.ipynb\", \"new_source\": \"cell source code\"}',\n NotebookRead: '{\"notebook_path\": \"/path/to/notebook.ipynb\"}',\n\n // Directory and Search\n Glob: '{\"pattern\": \"**/*.ts\", \"path\": \"/optional/search/path\"}',\n Grep: '{\"pattern\": \"search_term\", \"path\": \"/optional/search/path\", \"glob\": \"*.ts\"}',\n Ls: '{\"path\": \"/path/to/directory\"}',\n\n // Shell Execution\n Bash: '{\"command\": \"ls -la\"}',\n TaskOutput: '{\"task_id\": \"task-uuid\"}',\n TaskStop: '{\"task_id\": \"task-uuid\"}',\n\n // Task Management\n Task: '{\"prompt\": \"task description\", \"description\": \"short description\", \"subagent_type\": \"agent-type\"}',\n TodoWrite:\n '{\"todos\": [{\"content\": \"Task description\", \"status\": \"pending\", \"priority\": \"medium\"}]}',\n\n // Web and API\n WebSearch: '{\"query\": \"search query\"}',\n URLFetcher:\n '{\"url\": \"https://example.com\", \"prompt\": \"what to extract from page\"}',\n\n // LLM Interactions\n AskExpertModel:\n '{\"model\": \"model-name\", \"prompt\": \"question for expert\", \"context\": \"optional context\"}',\n AskUserQuestion:\n '{\"question\": \"question to ask user\", \"default\": \"optional default\"}',\n\n // Memory (Anthropic-only)\n MemoryRead: '{\"name\": \"memory_block_name\"}',\n MemoryWrite: '{\"name\": \"memory_block_name\", \"content\": \"memory content\"}',\n\n // Planning and Reasoning\n Think: '{\"reasoning\": \"your thinking process\", \"plan\": \"optional plan\"}',\n EnterPlanMode: '{}',\n ExitPlanMode: '{}',\n\n // Code Intelligence\n Lsp: '{\"method\": \"textDocument/definition\", \"params\": {\"position\": {\"line\": 10, \"character\": 5}}}',\n Skill: '{\"skill\": \"skill_name\", \"args\": \"optional arguments\"}',\n\n // MCP Resources\n ListMcpResources:\n '{\"server\": \"server_name\", \"uri\": \"optional_resource_uri\", \"include\": \"resource_type\"}',\n ReadMcpResource: '{\"uri\": \"resource://path\"}',\n}\n\n/**\n * Tool Input Descriptions\n *\n * Provides helpful descriptions for complex tools to include in error messages\n */\nexport const TOOL_DESCRIPTIONS: Record<string, string> = {\n MultiEdit:\n 'Allows multiple edits in a single file. The \"edits\" parameter is an array of edit objects.',\n NotebookEdit:\n 'For Jupyter notebooks. Requires notebook_path and new_source for the cell content.',\n Grep: 'Searches file contents with regex. Optional \"glob\" parameter filters files by pattern.',\n Task: 'Creates a task for an AI agent. subagent_type determines which agent handles the task.',\n TodoWrite:\n 'Manages a task list. Each todo requires content (description), status (pending/in_progress/completed), and priority (high/medium/low).',\n URLFetcher:\n 'Fetches web content. The \"prompt\" parameter guides what to extract from the page.',\n AskExpertModel:\n 'Queries an alternative LLM model. Useful for specialized tasks requiring different models.',\n Lsp: 'Language Server Protocol queries for code intelligence. Method and params depend on LSP spec.',\n}\n\n/**\n * Parameter Descriptions for Common Tool Parameters\n *\n * Helps provide more specific error messages when particular parameters are invalid\n */\nexport const PARAMETER_DESCRIPTIONS: Record<string, Record<string, string>> = {\n Read: {\n file_path: 'Must be an absolute file path (e.g., /home/user/file.txt)',\n offset: 'Optional line number to start reading from (0-indexed)',\n limit: 'Optional number of lines to read from the offset',\n },\n Write: {\n file_path: 'Must be an absolute file path (e.g., /home/user/file.txt)',\n content: 'The file contents to write',\n },\n Edit: {\n file_path: 'Must be an absolute file path (e.g., /home/user/file.txt)',\n old_string: 'The exact text to find and replace (must match exactly)',\n new_string: 'The text to replace it with',\n },\n Bash: {\n command:\n 'The shell command to execute (will run in current working directory)',\n timeout: 'Maximum execution time in milliseconds (max 600000 = 10 minutes)',\n run_in_background:\n 'Set to true to run command without waiting for completion',\n },\n Glob: {\n pattern: 'Glob pattern like **/*.ts or src/**/*.{ts,tsx}',\n path: 'Directory to search in (optional, defaults to current directory)',\n },\n Grep: {\n pattern: 'Regular expression pattern to search for',\n path: 'Directory to search in (optional, defaults to current directory)',\n glob: 'Additional glob pattern to filter files being searched',\n },\n TodoWrite: {\n todos:\n 'Array of todo items. Each item must have: content (string), status (pending/in_progress/completed), priority (high/medium/low). Optional: id, activeForm.',\n },\n}\n"],
5
+ "mappings": "AASO,MAAM,sBAA8C;AAAA;AAAA,EAEzD,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WACE;AAAA,EACF,cACE;AAAA,EACF,cAAc;AAAA;AAAA,EAGd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA;AAAA,EAGJ,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,UAAU;AAAA;AAAA,EAGV,MAAM;AAAA,EACN,WACE;AAAA;AAAA,EAGF,WAAW;AAAA,EACX,YACE;AAAA;AAAA,EAGF,gBACE;AAAA,EACF,iBACE;AAAA;AAAA,EAGF,YAAY;AAAA,EACZ,aAAa;AAAA;AAAA,EAGb,OAAO;AAAA,EACP,eAAe;AAAA,EACf,cAAc;AAAA;AAAA,EAGd,KAAK;AAAA,EACL,OAAO;AAAA;AAAA,EAGP,kBACE;AAAA,EACF,iBAAiB;AACnB;AAOO,MAAM,oBAA4C;AAAA,EACvD,WACE;AAAA,EACF,cACE;AAAA,EACF,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WACE;AAAA,EACF,YACE;AAAA,EACF,gBACE;AAAA,EACF,KAAK;AACP;AAOO,MAAM,yBAAiE;AAAA,EAC5E,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,YAAY;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACJ,SACE;AAAA,IACF,SAAS;AAAA,IACT,mBACE;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA,WAAW;AAAA,IACT,OACE;AAAA,EACJ;AACF;",
6
6
  "names": []
7
7
  }
package/dist/context.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import { logError } from "./utils/log.js";
6
6
  import { getCodeStyle } from "./utils/style.js";
7
7
  import { getCwd } from "./utils/state.js";
8
- import { memoize, omit } from "lodash-es";
8
+ import { omit } from "lodash-es";
9
9
  import { LSTool } from "./tools/lsTool/lsTool.js";
10
10
  import { getIsGit } from "./utils/git.js";
11
11
  import { ripGrep } from "./utils/ripgrep.js";
@@ -19,7 +19,9 @@ import { getModelManager } from "./utils/model.js";
19
19
  import { lastX } from "./utils/generators.js";
20
20
  import { getGitEmail } from "./utils/user.js";
21
21
  import { AGENTS_FILE, CONFIG_BASE_DIR } from "./constants/product.js";
22
+ import { isSimpleMode } from "./utils/simpleMode.js";
22
23
  async function getClaudeFiles() {
24
+ if (isSimpleMode()) return null;
23
25
  const abortController = new AbortController();
24
26
  const timeout = setTimeout(() => abortController.abort(), 1e4);
25
27
  try {
@@ -76,7 +78,30 @@ function removeContext(key) {
76
78
  );
77
79
  saveCurrentProjectConfig({ ...projectConfig, context });
78
80
  }
79
- const getReadme = memoize(async () => {
81
+ function ttlMemoize(fn, ttlMs = 3e4) {
82
+ let cachedValue;
83
+ let hasCached = false;
84
+ let cachedAt = 0;
85
+ const wrapper = async () => {
86
+ const now = Date.now();
87
+ if (hasCached && now - cachedAt < ttlMs) {
88
+ return cachedValue;
89
+ }
90
+ cachedValue = await fn();
91
+ hasCached = true;
92
+ cachedAt = now;
93
+ return cachedValue;
94
+ };
95
+ wrapper.cache = {
96
+ clear: () => {
97
+ cachedValue = void 0;
98
+ hasCached = false;
99
+ cachedAt = 0;
100
+ }
101
+ };
102
+ return wrapper;
103
+ }
104
+ const getReadme = ttlMemoize(async () => {
80
105
  try {
81
106
  const readmePath = join(getCwd(), "README.md");
82
107
  if (!existsSync(readmePath)) {
@@ -112,7 +137,7 @@ async function getGlobalDocs() {
112
137
  );
113
138
  return claudeGlobal;
114
139
  }
115
- const getProjectDocs = memoize(async () => {
140
+ const getProjectDocs = ttlMemoize(async () => {
116
141
  try {
117
142
  const cwd = getCwd();
118
143
  const docs = [];
@@ -188,7 +213,7 @@ async function getDirectoryScopedDocs(filePath) {
188
213
 
189
214
  ${d.content}`).join("\n\n---\n\n");
190
215
  }
191
- const getGitStatus = memoize(async () => {
216
+ const getGitStatus = ttlMemoize(async () => {
192
217
  if (process.env.NODE_ENV === "test") {
193
218
  return null;
194
219
  }
@@ -260,7 +285,7 @@ ${authorLog || "(no recent commits)"}`;
260
285
  return null;
261
286
  }
262
287
  });
263
- const getContext = memoize(
288
+ const getContext = ttlMemoize(
264
289
  async () => {
265
290
  const codeStyle = getCodeStyle();
266
291
  const projectConfig = getCurrentProjectConfig();
@@ -283,7 +308,7 @@ const getContext = memoize(
283
308
  };
284
309
  }
285
310
  );
286
- const getDirectoryStructure = memoize(
311
+ const getDirectoryStructure = ttlMemoize(
287
312
  async function() {
288
313
  let lines;
289
314
  try {
@@ -320,6 +345,13 @@ const getDirectoryStructure = memoize(
320
345
  ${lines}`;
321
346
  }
322
347
  );
348
+ function invalidateContextCache() {
349
+ getReadme.cache.clear();
350
+ getProjectDocs.cache.clear();
351
+ getGitStatus.cache.clear();
352
+ getContext.cache.clear();
353
+ getDirectoryStructure.cache.clear();
354
+ }
323
355
  export {
324
356
  getClaudeFiles,
325
357
  getContext,
@@ -328,6 +360,7 @@ export {
328
360
  getGitStatus,
329
361
  getProjectDocs,
330
362
  getReadme,
363
+ invalidateContextCache,
331
364
  removeContext,
332
365
  setContext
333
366
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/context.ts"],
4
- "sourcesContent": ["import {\n getCurrentProjectConfig,\n saveCurrentProjectConfig,\n} from '@utils/config'\nimport { logError } from './utils/log'\nimport { getCodeStyle } from './utils/style'\nimport { getCwd } from './utils/state'\nimport { memoize, omit } from 'lodash-es'\nimport { LSTool } from './tools/lsTool/lsTool'\nimport { getIsGit } from './utils/git'\nimport { ripGrep } from './utils/ripgrep'\nimport * as path from 'path'\nimport { execFileNoThrow } from './utils/execFileNoThrow'\nimport { join } from 'path'\nimport { readFile } from 'fs/promises'\nimport { existsSync } from 'fs'\nimport { homedir } from 'os'\nimport { getModelManager } from './utils/model'\nimport { lastX } from './utils/generators'\nimport { getGitEmail } from './utils/user'\nimport { PROJECT_FILE, AGENTS_FILE, CONFIG_BASE_DIR } from './constants/product'\n\n/**\n * Locate MINTO.md, AGENTS.md (legacy), and CLAUDE.md files\n * Priority: MINTO.md > AGENTS.md > CLAUDE.md\n */\nexport async function getClaudeFiles(): Promise<string | null> {\n const abortController = new AbortController()\n const timeout = setTimeout(() => abortController.abort(), 10000)\n try {\n // Search for MINTO.md, AGENTS.md (legacy), and CLAUDE.md files\n const [mintoFiles, agentsFiles, claudeFiles] = await Promise.all([\n ripGrep(\n ['--files', '--glob', join('**', '*', 'MINTO.md')],\n getCwd(),\n abortController.signal,\n ).catch(() => []),\n ripGrep(\n ['--files', '--glob', join('**', '*', AGENTS_FILE)],\n getCwd(),\n abortController.signal,\n ).catch(() => []),\n ripGrep(\n ['--files', '--glob', join('**', '*', 'CLAUDE.md')],\n getCwd(),\n abortController.signal,\n ).catch(() => []),\n ])\n\n const allFiles = [...mintoFiles, ...agentsFiles, ...claudeFiles]\n if (!allFiles.length) {\n return null\n }\n\n // Add instructions for additional project files\n const fileTypes = []\n if (mintoFiles.length > 0) fileTypes.push('MINTO.md')\n if (agentsFiles.length > 0) fileTypes.push('AGENTS.md (legacy)')\n if (claudeFiles.length > 0) fileTypes.push('CLAUDE.md')\n\n return `NOTE: Additional project documentation files (${fileTypes.join(', ')}) were found. When working in these directories, make sure to read and follow the instructions in the corresponding files:\\n${allFiles\n .map(_ => path.join(getCwd(), _))\n .map(_ => `- ${_}`)\n .join('\\n')}`\n } catch (error) {\n logError(error)\n return null\n } finally {\n clearTimeout(timeout)\n }\n}\n\nexport function setContext(key: string, value: string): void {\n const projectConfig = getCurrentProjectConfig()\n const context = omit(\n { ...projectConfig.context, [key]: value },\n 'codeStyle',\n 'directoryStructure',\n )\n saveCurrentProjectConfig({ ...projectConfig, context })\n}\n\nexport function removeContext(key: string): void {\n const projectConfig = getCurrentProjectConfig()\n const context = omit(\n projectConfig.context,\n key,\n 'codeStyle',\n 'directoryStructure',\n )\n saveCurrentProjectConfig({ ...projectConfig, context })\n}\n\nexport const getReadme = memoize(async (): Promise<string | null> => {\n try {\n const readmePath = join(getCwd(), 'README.md')\n if (!existsSync(readmePath)) {\n return null\n }\n const content = await readFile(readmePath, 'utf-8')\n return content\n } catch (e) {\n logError(e)\n return null\n }\n})\n\n/**\n * Read a file if it exists, returning null otherwise\n */\nasync function readFileIfExists(filePath: string): Promise<string | null> {\n try {\n if (!existsSync(filePath)) return null\n return await readFile(filePath, 'utf-8')\n } catch {\n return null\n }\n}\n\n/**\n * Load global-level project docs (~/.minto/MINTO.md or ~/.claude/CLAUDE.md)\n */\nasync function getGlobalDocs(): Promise<string | null> {\n const home = homedir()\n\n // Try Minto global first\n const mintoGlobal = await readFileIfExists(\n join(home, CONFIG_BASE_DIR, 'MINTO.md'),\n )\n if (mintoGlobal) return mintoGlobal\n\n // Try AGENTS.md global\n const agentsGlobal = await readFileIfExists(\n join(home, CONFIG_BASE_DIR, AGENTS_FILE),\n )\n if (agentsGlobal) return agentsGlobal\n\n // Fallback to Claude global\n const claudeGlobal = await readFileIfExists(\n join(home, '.claude', 'CLAUDE.md'),\n )\n return claudeGlobal\n}\n\n/**\n * Get project documentation content\n *\n * Hierarchy (all concatenated, from low to high priority):\n * 1. Global: ~/.minto/MINTO.md or ~/.claude/CLAUDE.md\n * 2. Project: MINTO.md or CLAUDE.md (at project root)\n * 3. Local: MINTO.local.md or CLAUDE.local.md (appended to project)\n *\n * If MINTO.md exists at any level, CLAUDE.md at that level is ignored.\n */\nexport const getProjectDocs = memoize(async (): Promise<string | null> => {\n try {\n const cwd = getCwd()\n const docs: string[] = []\n\n // 1. Global docs\n const globalDocs = await getGlobalDocs()\n if (globalDocs) {\n docs.push(`# Global Instructions\\n\\n${globalDocs}`)\n }\n\n // 2. Project root docs (MINTO.md > CLAUDE.md)\n const mintoPath = join(cwd, 'MINTO.md')\n const claudePath = join(cwd, 'CLAUDE.md')\n const agentsPath = join(cwd, 'AGENTS.md')\n\n let projectContent: string | null = null\n let projectDocName = ''\n\n const mintoContent = await readFileIfExists(mintoPath)\n if (mintoContent) {\n projectContent = mintoContent\n projectDocName = 'MINTO.md'\n } else {\n // Try AGENTS.md (legacy) then CLAUDE.md\n const agentsContent = await readFileIfExists(agentsPath)\n if (agentsContent) {\n projectContent = agentsContent\n projectDocName = 'AGENTS.md'\n } else {\n const claudeContent = await readFileIfExists(claudePath)\n if (claudeContent) {\n projectContent = claudeContent\n projectDocName = 'CLAUDE.md'\n }\n }\n }\n\n if (projectContent) {\n docs.push(`# ${projectDocName}\\n\\n${projectContent}`)\n }\n\n // 3. Local overrides (.local.md variants, appended to project docs)\n // Check MINTO.local.md first, then CLAUDE.local.md\n const localContent =\n (await readFileIfExists(join(cwd, 'MINTO.local.md'))) ??\n (await readFileIfExists(join(cwd, 'AGENTS.local.md'))) ??\n (await readFileIfExists(join(cwd, 'CLAUDE.local.md')))\n\n if (localContent) {\n docs.push(`# Local Instructions\\n\\n${localContent}`)\n }\n\n return docs.length > 0 ? docs.join('\\n\\n---\\n\\n') : null\n } catch (e) {\n logError(e)\n return null\n }\n})\n\n/**\n * Get directory-scoped CLAUDE.md/MINTO.md content for a given file path.\n * Collects all CLAUDE.md/MINTO.md from the file's directory up to the project root.\n *\n * Example: for src/utils/foo.ts, collects:\n * - src/utils/MINTO.md (or CLAUDE.md)\n * - src/MINTO.md (or CLAUDE.md)\n *\n * Excludes root-level docs (already loaded by getProjectDocs).\n */\nexport async function getDirectoryScopedDocs(\n filePath: string,\n): Promise<string | null> {\n const cwd = getCwd()\n const absolutePath = path.isAbsolute(filePath)\n ? filePath\n : path.resolve(cwd, filePath)\n\n // Get the directory of the file being operated on\n let dir = path.dirname(absolutePath)\n const docs: { dir: string; content: string }[] = []\n\n // Walk up from file's directory to project root (exclusive)\n while (dir.length > cwd.length && dir.startsWith(cwd)) {\n const mintoDoc = await readFileIfExists(join(dir, 'MINTO.md'))\n if (mintoDoc) {\n docs.unshift({ dir: path.relative(cwd, dir), content: mintoDoc })\n } else {\n const agentsDoc = await readFileIfExists(join(dir, AGENTS_FILE))\n if (agentsDoc) {\n docs.unshift({ dir: path.relative(cwd, dir), content: agentsDoc })\n } else {\n const claudeDoc = await readFileIfExists(join(dir, 'CLAUDE.md'))\n if (claudeDoc) {\n docs.unshift({ dir: path.relative(cwd, dir), content: claudeDoc })\n }\n }\n }\n dir = path.dirname(dir)\n }\n\n if (docs.length === 0) return null\n\n return docs\n .map(d => `# Directory instructions (${d.dir}/)\\n\\n${d.content}`)\n .join('\\n\\n---\\n\\n')\n}\n\nexport const getGitStatus = memoize(async (): Promise<string | null> => {\n if (process.env.NODE_ENV === 'test') {\n // Avoid cycles in tests\n return null\n }\n if (!(await getIsGit())) {\n return null\n }\n\n try {\n const [branch, mainBranch, status, log, authorLog] = await Promise.all([\n execFileNoThrow(\n 'git',\n ['branch', '--show-current'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n execFileNoThrow(\n 'git',\n ['rev-parse', '--abbrev-ref', 'origin/HEAD'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.replace('origin/', '').trim()),\n execFileNoThrow(\n 'git',\n ['status', '--short'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n execFileNoThrow(\n 'git',\n ['log', '--oneline', '-n', '5'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n execFileNoThrow(\n 'git',\n [\n 'log',\n '--oneline',\n '-n',\n '5',\n '--author',\n (await getGitEmail()) || '',\n ],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n ])\n // Check if status has more than 200 lines\n const statusLines = status.split('\\n').length\n const truncatedStatus =\n statusLines > 200\n ? status.split('\\n').slice(0, 200).join('\\n') +\n '\\n... (truncated because there are more than 200 lines. If you need more information, run \"git status\" using BashTool)'\n : status\n\n 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.\\nCurrent branch: ${branch}\\n\\nMain branch (you will usually use this for PRs): ${mainBranch}\\n\\nStatus:\\n${truncatedStatus || '(clean)'}\\n\\nRecent commits:\\n${log}\\n\\nYour recent commits:\\n${authorLog || '(no recent commits)'}`\n } catch (error) {\n logError(error)\n return null\n }\n})\n\n/**\n * This context is prepended to each conversation, and cached for the duration of the conversation.\n */\nexport const getContext = memoize(\n async (): Promise<{\n [k: string]: string\n }> => {\n const codeStyle = getCodeStyle()\n const projectConfig = getCurrentProjectConfig()\n const dontCrawl = projectConfig.dontCrawlDirectory\n const [gitStatus, directoryStructure, claudeFiles, readme, projectDocs] =\n await Promise.all([\n getGitStatus(),\n dontCrawl ? Promise.resolve('') : getDirectoryStructure(),\n dontCrawl ? Promise.resolve('') : getClaudeFiles(),\n getReadme(),\n getProjectDocs(),\n ])\n return {\n ...projectConfig.context,\n ...(directoryStructure ? { directoryStructure } : {}),\n ...(gitStatus ? { gitStatus } : {}),\n ...(codeStyle ? { codeStyle } : {}),\n ...(claudeFiles ? { claudeFiles } : {}),\n ...(readme ? { readme } : {}),\n ...(projectDocs ? { projectDocs } : {}),\n }\n },\n)\n\n/**\n * Approximate directory structure, to orient Claude. Claude will start with this, then use\n * tools like LS and View to get more information.\n */\nexport const getDirectoryStructure = memoize(\n async function (): Promise<string> {\n let lines: string\n try {\n const abortController = new AbortController()\n setTimeout(() => {\n abortController.abort()\n }, 1_000)\n // \uD83D\uDD27 Fix: Use ModelManager instead of legacy function\n const model = getModelManager().getModelName('main')\n const resultsGen = LSTool.call(\n {\n path: '.',\n },\n {\n abortController,\n options: {\n commands: [],\n tools: [],\n forkNumber: 0,\n messageLogName: 'unused',\n maxThinkingTokens: 0,\n },\n messageId: undefined,\n readFileTimestamps: {},\n },\n )\n const result = await lastX(resultsGen)\n lines = result.data\n } catch (error) {\n logError(error)\n return ''\n }\n\n 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.\n\n${lines}`\n },\n)\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,SAAS,YAAY;AAC9B,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,YAAY,UAAU;AACtB,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAuB,aAAa,uBAAuB;AAM3D,eAAsB,iBAAyC;AAC7D,QAAM,kBAAkB,IAAI,gBAAgB;AAC5C,QAAM,UAAU,WAAW,MAAM,gBAAgB,MAAM,GAAG,GAAK;AAC/D,MAAI;AAEF,UAAM,CAAC,YAAY,aAAa,WAAW,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC/D;AAAA,QACE,CAAC,WAAW,UAAU,KAAK,MAAM,KAAK,UAAU,CAAC;AAAA,QACjD,OAAO;AAAA,QACP,gBAAgB;AAAA,MAClB,EAAE,MAAM,MAAM,CAAC,CAAC;AAAA,MAChB;AAAA,QACE,CAAC,WAAW,UAAU,KAAK,MAAM,KAAK,WAAW,CAAC;AAAA,QAClD,OAAO;AAAA,QACP,gB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AAc,EAAE,YAAY,IAAI,CAAC;AAAA,MACrC,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,MAC3B,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;AAAA,IACvC;AAAA,EACF;AACF;AAMO,MAAM,wBAAwB;AAAA,EACnC,iBAAmC;AACjC,QAAI;AACJ,QAAI;AACF,YAAM,kBAAkB,IAAI,gBAAgB;AAC5C,iBAAW,MAAM;AACf,wBAAgB,MAAM;AAAA,MACxB,GAAG,GAAK;AAER,YAAM,QAAQ,gBAAgB,EAAE,aAAa,MAAM;AACnD,YAAM,aAAa,OAAO;AAAA,QACxB;AAAA,UACE,MAAM;AAAA,QACR;AAAA,QACA;AAAA,UACE;AAAA,UACA,SAAS;AAAA,YACP,UAAU,CAAC;AAAA,YACX,OAAO,CAAC;AAAA,YACR,YAAY;AAAA,YACZ,gBAAgB;AAAA,YAChB,mBAAmB;AAAA,UACrB;AAAA,UACA,WAAW;AAAA,UACX,oBAAoB,CAAC;AAAA,QACvB;AAAA,MACF;AACA,YAAM,SAAS,MAAM,MAAM,UAAU;AACrC,cAAQ,OAAO;AAAA,IACjB,SAAS,OAAO;AACd,eAAS,KAAK;AACd,aAAO;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,EAET,KAAK;AAAA,EACL;AACF;",
4
+ "sourcesContent": ["import {\n getCurrentProjectConfig,\n saveCurrentProjectConfig,\n} from '@utils/config'\nimport { logError } from './utils/log'\nimport { getCodeStyle } from './utils/style'\nimport { getCwd } from './utils/state'\nimport { omit } from 'lodash-es'\nimport { LSTool } from './tools/lsTool/lsTool'\nimport { getIsGit } from './utils/git'\nimport { ripGrep } from './utils/ripgrep'\nimport * as path from 'path'\nimport { execFileNoThrow } from './utils/execFileNoThrow'\nimport { join } from 'path'\nimport { readFile } from 'fs/promises'\nimport { existsSync } from 'fs'\nimport { homedir } from 'os'\nimport { getModelManager } from './utils/model'\nimport { lastX } from './utils/generators'\nimport { getGitEmail } from './utils/user'\nimport { PROJECT_FILE, AGENTS_FILE, CONFIG_BASE_DIR } from './constants/product'\nimport { isSimpleMode } from './utils/simpleMode'\n\n/**\n * Locate MINTO.md, AGENTS.md (legacy), and CLAUDE.md files\n * Priority: MINTO.md > AGENTS.md > CLAUDE.md\n * Returns null in simple mode (no project docs loaded).\n */\nexport async function getClaudeFiles(): Promise<string | null> {\n if (isSimpleMode()) return null\n const abortController = new AbortController()\n const timeout = setTimeout(() => abortController.abort(), 10000)\n try {\n // Search for MINTO.md, AGENTS.md (legacy), and CLAUDE.md files\n const [mintoFiles, agentsFiles, claudeFiles] = await Promise.all([\n ripGrep(\n ['--files', '--glob', join('**', '*', 'MINTO.md')],\n getCwd(),\n abortController.signal,\n ).catch(() => []),\n ripGrep(\n ['--files', '--glob', join('**', '*', AGENTS_FILE)],\n getCwd(),\n abortController.signal,\n ).catch(() => []),\n ripGrep(\n ['--files', '--glob', join('**', '*', 'CLAUDE.md')],\n getCwd(),\n abortController.signal,\n ).catch(() => []),\n ])\n\n const allFiles = [...mintoFiles, ...agentsFiles, ...claudeFiles]\n if (!allFiles.length) {\n return null\n }\n\n // Add instructions for additional project files\n const fileTypes = []\n if (mintoFiles.length > 0) fileTypes.push('MINTO.md')\n if (agentsFiles.length > 0) fileTypes.push('AGENTS.md (legacy)')\n if (claudeFiles.length > 0) fileTypes.push('CLAUDE.md')\n\n return `NOTE: Additional project documentation files (${fileTypes.join(', ')}) were found. When working in these directories, make sure to read and follow the instructions in the corresponding files:\\n${allFiles\n .map(_ => path.join(getCwd(), _))\n .map(_ => `- ${_}`)\n .join('\\n')}`\n } catch (error) {\n logError(error)\n return null\n } finally {\n clearTimeout(timeout)\n }\n}\n\nexport function setContext(key: string, value: string): void {\n const projectConfig = getCurrentProjectConfig()\n const context = omit(\n { ...projectConfig.context, [key]: value },\n 'codeStyle',\n 'directoryStructure',\n )\n saveCurrentProjectConfig({ ...projectConfig, context })\n}\n\nexport function removeContext(key: string): void {\n const projectConfig = getCurrentProjectConfig()\n const context = omit(\n projectConfig.context,\n key,\n 'codeStyle',\n 'directoryStructure',\n )\n saveCurrentProjectConfig({ ...projectConfig, context })\n}\n\n/**\n * TTL-based cache helper for context functions.\n * Unlike lodash memoize, this invalidates after `ttlMs` so file changes\n * during long sessions are picked up.\n */\nfunction ttlMemoize<T>(\n fn: () => Promise<T>,\n ttlMs: number = 30_000,\n): {\n (): Promise<T>\n cache: { clear: () => void }\n} {\n let cachedValue: T | undefined\n let hasCached = false\n let cachedAt = 0\n\n const wrapper = async (): Promise<T> => {\n const now = Date.now()\n if (hasCached && now - cachedAt < ttlMs) {\n return cachedValue as T\n }\n cachedValue = await fn()\n hasCached = true\n cachedAt = now\n return cachedValue\n }\n\n wrapper.cache = {\n clear: () => {\n cachedValue = undefined\n hasCached = false\n cachedAt = 0\n },\n }\n\n return wrapper\n}\n\nexport const getReadme = ttlMemoize(async (): Promise<string | null> => {\n try {\n const readmePath = join(getCwd(), 'README.md')\n if (!existsSync(readmePath)) {\n return null\n }\n const content = await readFile(readmePath, 'utf-8')\n return content\n } catch (e) {\n logError(e)\n return null\n }\n})\n\n/**\n * Read a file if it exists, returning null otherwise\n */\nasync function readFileIfExists(filePath: string): Promise<string | null> {\n try {\n if (!existsSync(filePath)) return null\n return await readFile(filePath, 'utf-8')\n } catch {\n return null\n }\n}\n\n/**\n * Load global-level project docs (~/.minto/MINTO.md or ~/.claude/CLAUDE.md)\n */\nasync function getGlobalDocs(): Promise<string | null> {\n const home = homedir()\n\n // Try Minto global first\n const mintoGlobal = await readFileIfExists(\n join(home, CONFIG_BASE_DIR, 'MINTO.md'),\n )\n if (mintoGlobal) return mintoGlobal\n\n // Try AGENTS.md global\n const agentsGlobal = await readFileIfExists(\n join(home, CONFIG_BASE_DIR, AGENTS_FILE),\n )\n if (agentsGlobal) return agentsGlobal\n\n // Fallback to Claude global\n const claudeGlobal = await readFileIfExists(\n join(home, '.claude', 'CLAUDE.md'),\n )\n return claudeGlobal\n}\n\n/**\n * Get project documentation content\n *\n * Hierarchy (all concatenated, from low to high priority):\n * 1. Global: ~/.minto/MINTO.md or ~/.claude/CLAUDE.md\n * 2. Project: MINTO.md or CLAUDE.md (at project root)\n * 3. Local: MINTO.local.md or CLAUDE.local.md (appended to project)\n *\n * If MINTO.md exists at any level, CLAUDE.md at that level is ignored.\n */\nexport const getProjectDocs = ttlMemoize(async (): Promise<string | null> => {\n try {\n const cwd = getCwd()\n const docs: string[] = []\n\n // 1. Global docs\n const globalDocs = await getGlobalDocs()\n if (globalDocs) {\n docs.push(`# Global Instructions\\n\\n${globalDocs}`)\n }\n\n // 2. Project root docs (MINTO.md > CLAUDE.md)\n const mintoPath = join(cwd, 'MINTO.md')\n const claudePath = join(cwd, 'CLAUDE.md')\n const agentsPath = join(cwd, 'AGENTS.md')\n\n let projectContent: string | null = null\n let projectDocName = ''\n\n const mintoContent = await readFileIfExists(mintoPath)\n if (mintoContent) {\n projectContent = mintoContent\n projectDocName = 'MINTO.md'\n } else {\n // Try AGENTS.md (legacy) then CLAUDE.md\n const agentsContent = await readFileIfExists(agentsPath)\n if (agentsContent) {\n projectContent = agentsContent\n projectDocName = 'AGENTS.md'\n } else {\n const claudeContent = await readFileIfExists(claudePath)\n if (claudeContent) {\n projectContent = claudeContent\n projectDocName = 'CLAUDE.md'\n }\n }\n }\n\n if (projectContent) {\n docs.push(`# ${projectDocName}\\n\\n${projectContent}`)\n }\n\n // 3. Local overrides (.local.md variants, appended to project docs)\n // Check MINTO.local.md first, then CLAUDE.local.md\n const localContent =\n (await readFileIfExists(join(cwd, 'MINTO.local.md'))) ??\n (await readFileIfExists(join(cwd, 'AGENTS.local.md'))) ??\n (await readFileIfExists(join(cwd, 'CLAUDE.local.md')))\n\n if (localContent) {\n docs.push(`# Local Instructions\\n\\n${localContent}`)\n }\n\n return docs.length > 0 ? docs.join('\\n\\n---\\n\\n') : null\n } catch (e) {\n logError(e)\n return null\n }\n})\n\n/**\n * Get directory-scoped CLAUDE.md/MINTO.md content for a given file path.\n * Collects all CLAUDE.md/MINTO.md from the file's directory up to the project root.\n *\n * Example: for src/utils/foo.ts, collects:\n * - src/utils/MINTO.md (or CLAUDE.md)\n * - src/MINTO.md (or CLAUDE.md)\n *\n * Excludes root-level docs (already loaded by getProjectDocs).\n */\nexport async function getDirectoryScopedDocs(\n filePath: string,\n): Promise<string | null> {\n const cwd = getCwd()\n const absolutePath = path.isAbsolute(filePath)\n ? filePath\n : path.resolve(cwd, filePath)\n\n // Get the directory of the file being operated on\n let dir = path.dirname(absolutePath)\n const docs: { dir: string; content: string }[] = []\n\n // Walk up from file's directory to project root (exclusive)\n while (dir.length > cwd.length && dir.startsWith(cwd)) {\n const mintoDoc = await readFileIfExists(join(dir, 'MINTO.md'))\n if (mintoDoc) {\n docs.unshift({ dir: path.relative(cwd, dir), content: mintoDoc })\n } else {\n const agentsDoc = await readFileIfExists(join(dir, AGENTS_FILE))\n if (agentsDoc) {\n docs.unshift({ dir: path.relative(cwd, dir), content: agentsDoc })\n } else {\n const claudeDoc = await readFileIfExists(join(dir, 'CLAUDE.md'))\n if (claudeDoc) {\n docs.unshift({ dir: path.relative(cwd, dir), content: claudeDoc })\n }\n }\n }\n dir = path.dirname(dir)\n }\n\n if (docs.length === 0) return null\n\n return docs\n .map(d => `# Directory instructions (${d.dir}/)\\n\\n${d.content}`)\n .join('\\n\\n---\\n\\n')\n}\n\nexport const getGitStatus = ttlMemoize(async (): Promise<string | null> => {\n if (process.env.NODE_ENV === 'test') {\n // Avoid cycles in tests\n return null\n }\n if (!(await getIsGit())) {\n return null\n }\n\n try {\n const [branch, mainBranch, status, log, authorLog] = await Promise.all([\n execFileNoThrow(\n 'git',\n ['branch', '--show-current'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n execFileNoThrow(\n 'git',\n ['rev-parse', '--abbrev-ref', 'origin/HEAD'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.replace('origin/', '').trim()),\n execFileNoThrow(\n 'git',\n ['status', '--short'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n execFileNoThrow(\n 'git',\n ['log', '--oneline', '-n', '5'],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n execFileNoThrow(\n 'git',\n [\n 'log',\n '--oneline',\n '-n',\n '5',\n '--author',\n (await getGitEmail()) || '',\n ],\n undefined,\n undefined,\n false,\n ).then(({ stdout }) => stdout.trim()),\n ])\n // Check if status has more than 200 lines\n const statusLines = status.split('\\n').length\n const truncatedStatus =\n statusLines > 200\n ? status.split('\\n').slice(0, 200).join('\\n') +\n '\\n... (truncated because there are more than 200 lines. If you need more information, run \"git status\" using BashTool)'\n : status\n\n 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.\\nCurrent branch: ${branch}\\n\\nMain branch (you will usually use this for PRs): ${mainBranch}\\n\\nStatus:\\n${truncatedStatus || '(clean)'}\\n\\nRecent commits:\\n${log}\\n\\nYour recent commits:\\n${authorLog || '(no recent commits)'}`\n } catch (error) {\n logError(error)\n return null\n }\n})\n\n/**\n * This context is prepended to each conversation, and cached for the duration of the conversation.\n */\nexport const getContext = ttlMemoize(\n async (): Promise<{\n [k: string]: string\n }> => {\n const codeStyle = getCodeStyle()\n const projectConfig = getCurrentProjectConfig()\n const dontCrawl = projectConfig.dontCrawlDirectory\n const [gitStatus, directoryStructure, claudeFiles, readme, projectDocs] =\n await Promise.all([\n getGitStatus(),\n dontCrawl ? Promise.resolve('') : getDirectoryStructure(),\n dontCrawl ? Promise.resolve('') : getClaudeFiles(),\n getReadme(),\n getProjectDocs(),\n ])\n return {\n ...projectConfig.context,\n ...(directoryStructure ? { directoryStructure } : {}),\n ...(gitStatus ? { gitStatus } : {}),\n ...(codeStyle ? { codeStyle } : {}),\n ...(claudeFiles ? { claudeFiles } : {}),\n ...(readme ? { readme } : {}),\n ...(projectDocs ? { projectDocs } : {}),\n }\n },\n)\n\n/**\n * Approximate directory structure, to orient Claude. Claude will start with this, then use\n * tools like LS and View to get more information.\n */\nexport const getDirectoryStructure = ttlMemoize(\n async function (): Promise<string> {\n let lines: string\n try {\n const abortController = new AbortController()\n setTimeout(() => {\n abortController.abort()\n }, 1_000)\n // \uD83D\uDD27 Fix: Use ModelManager instead of legacy function\n const model = getModelManager().getModelName('main')\n const resultsGen = LSTool.call(\n {\n path: '.',\n },\n {\n abortController,\n options: {\n commands: [],\n tools: [],\n forkNumber: 0,\n messageLogName: 'unused',\n maxThinkingTokens: 0,\n },\n messageId: undefined,\n readFileTimestamps: {},\n },\n )\n const result = await lastX(resultsGen)\n lines = result.data\n } catch (error) {\n logError(error)\n return ''\n }\n\n 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.\n\n${lines}`\n },\n)\n\n/**\n * Invalidate all context caches.\n * Forces fresh reads on the next access. Useful when files have changed\n * during a session (e.g., after a git checkout or branch switch).\n */\nexport function invalidateContextCache(): void {\n getReadme.cache.clear()\n getProjectDocs.cache.clear()\n getGitStatus.cache.clear()\n getContext.cache.clear()\n getDirectoryStructure.cache.clear()\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,YAAY,UAAU;AACtB,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAuB,aAAa,uBAAuB;AAC3D,SAAS,oBAAoB;AAO7B,eAAsB,iBAAyC;AAC7D,MAAI,aAAa,EAAG,QAAO;AAC3B,QAAM,kBAAkB,IAAI,gBAAgB;AAC5C,QAAM,UAAU,WAAW,MAAM,gBAAgB,MAAM,GAAG,GAAK;A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YAAY;AAAA,YACZ,gBAAgB;AAAA,YAChB,mBAAmB;AAAA,UACrB;AAAA,UACA,WAAW;AAAA,UACX,oBAAoB,CAAC;AAAA,QACvB;AAAA,MACF;AACA,YAAM,SAAS,MAAM,MAAM,UAAU;AACrC,cAAQ,OAAO;AAAA,IACjB,SAAS,OAAO;AACd,eAAS,KAAK;AACd,aAAO;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,EAET,KAAK;AAAA,EACL;AACF;AAOO,SAAS,yBAA+B;AAC7C,YAAU,MAAM,MAAM;AACtB,iBAAe,MAAM,MAAM;AAC3B,eAAa,MAAM,MAAM;AACzB,aAAW,MAAM,MAAM;AACvB,wBAAsB,MAAM,MAAM;AACpC;",
6
6
  "names": []
7
7
  }
@@ -125,7 +125,7 @@ async function listBackedUpFiles() {
125
125
  const index = await readJsonAsync(indexPath);
126
126
  if (index && index.versions.length > 0) {
127
127
  const sortedVersions = [...index.versions].sort(
128
- (a, b) => b.timestamp - a.timestamp
128
+ (a, b) => b.timestamp - a.timestamp || b.version - a.version
129
129
  );
130
130
  const mostRecent = sortedVersions[0];
131
131
  summaries.push({