@within-7/minto 0.3.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/dist/Tool.js.map +2 -2
  2. package/dist/commands/agents/AgentsCommand.js +461 -657
  3. package/dist/commands/agents/AgentsCommand.js.map +2 -2
  4. package/dist/commands/agents/types.js +1 -0
  5. package/dist/commands/agents/types.js.map +2 -2
  6. package/dist/commands/agents/utils/fileOperations.js +96 -36
  7. package/dist/commands/agents/utils/fileOperations.js.map +3 -3
  8. package/dist/commands/agents/utils/index.js +3 -1
  9. package/dist/commands/agents/utils/index.js.map +2 -2
  10. package/dist/commands/context.js +54 -23
  11. package/dist/commands/context.js.map +2 -2
  12. package/dist/commands/ctx_viz.js +1 -1
  13. package/dist/commands/effort.js +87 -0
  14. package/dist/commands/effort.js.map +7 -0
  15. package/dist/commands/export.js +684 -94
  16. package/dist/commands/export.js.map +2 -2
  17. package/dist/commands/ide.js +18 -0
  18. package/dist/commands/ide.js.map +7 -0
  19. package/dist/commands/language.js +19 -46
  20. package/dist/commands/language.js.map +2 -2
  21. package/dist/commands/mcp-interactive.js +425 -217
  22. package/dist/commands/mcp-interactive.js.map +2 -2
  23. package/dist/commands/memory.js +168 -0
  24. package/dist/commands/memory.js.map +7 -0
  25. package/dist/commands/model.js +457 -65
  26. package/dist/commands/model.js.map +2 -2
  27. package/dist/commands/outputStyle.js +64 -0
  28. package/dist/commands/outputStyle.js.map +7 -0
  29. package/dist/commands/permissions.js +75 -49
  30. package/dist/commands/permissions.js.map +2 -2
  31. package/dist/commands/plugin/utils.js +33 -1
  32. package/dist/commands/plugin/utils.js.map +2 -2
  33. package/dist/commands/plugin.js +891 -185
  34. package/dist/commands/plugin.js.map +3 -3
  35. package/dist/commands/refreshCommands.js +2 -0
  36. package/dist/commands/refreshCommands.js.map +2 -2
  37. package/dist/commands/resume.js +1 -1
  38. package/dist/commands/resume.js.map +1 -1
  39. package/dist/commands/review.js +51 -0
  40. package/dist/commands/review.js.map +7 -0
  41. package/dist/commands/sandbox.js +168 -70
  42. package/dist/commands/sandbox.js.map +2 -2
  43. package/dist/commands/setup.js +593 -107
  44. package/dist/commands/setup.js.map +2 -2
  45. package/dist/commands/stats.js +188 -131
  46. package/dist/commands/stats.js.map +2 -2
  47. package/dist/commands/status.js +75 -13
  48. package/dist/commands/status.js.map +2 -2
  49. package/dist/commands/terminalSetup.js +6 -0
  50. package/dist/commands/terminalSetup.js.map +2 -2
  51. package/dist/commands/undo.js +146 -174
  52. package/dist/commands/undo.js.map +2 -2
  53. package/dist/commands/vim.js +22 -0
  54. package/dist/commands/vim.js.map +7 -0
  55. package/dist/commands.js +12 -0
  56. package/dist/commands.js.map +2 -2
  57. package/dist/components/Help.js +165 -32
  58. package/dist/components/Help.js.map +2 -2
  59. package/dist/components/HighlightedCode.js +1 -0
  60. package/dist/components/HighlightedCode.js.map +2 -2
  61. package/dist/components/InfoPanel/InfoPanel.js +123 -0
  62. package/dist/components/InfoPanel/InfoPanel.js.map +7 -0
  63. package/dist/components/InfoPanel/index.js +5 -0
  64. package/dist/components/InfoPanel/index.js.map +7 -0
  65. package/dist/components/InfoPanel/types.js +1 -0
  66. package/dist/components/InfoPanel/types.js.map +7 -0
  67. package/dist/components/ModelSelector/BrandTextInput.js +43 -0
  68. package/dist/components/ModelSelector/BrandTextInput.js.map +7 -0
  69. package/dist/components/ModelSelector/ModelSelector.js +590 -565
  70. package/dist/components/ModelSelector/ModelSelector.js.map +2 -2
  71. package/dist/components/ModelSelector/WizardContainer.js +45 -0
  72. package/dist/components/ModelSelector/WizardContainer.js.map +7 -0
  73. package/dist/components/ModelSelector/index.js +1 -3
  74. package/dist/components/ModelSelector/index.js.map +2 -2
  75. package/dist/components/PromptInput.js +26 -11
  76. package/dist/components/PromptInput.js.map +2 -2
  77. package/dist/components/PulseLabel.js +44 -0
  78. package/dist/components/PulseLabel.js.map +7 -0
  79. package/dist/components/RequestStatusIndicator.js +1 -1
  80. package/dist/components/RequestStatusIndicator.js.map +1 -1
  81. package/dist/components/SimpleSelector/SimpleSelector.js +154 -0
  82. package/dist/components/SimpleSelector/SimpleSelector.js.map +7 -0
  83. package/dist/components/SimpleSelector/index.js +5 -0
  84. package/dist/components/SimpleSelector/index.js.map +7 -0
  85. package/dist/components/SimpleSelector/types.js +1 -0
  86. package/dist/components/SimpleSelector/types.js.map +7 -0
  87. package/dist/components/Spinner.js +12 -42
  88. package/dist/components/Spinner.js.map +3 -3
  89. package/dist/components/StartupStatus.js +57 -0
  90. package/dist/components/StartupStatus.js.map +7 -0
  91. package/dist/components/StatusOverlayContent.js +21 -0
  92. package/dist/components/StatusOverlayContent.js.map +7 -0
  93. package/dist/components/SubagentBlock.js +43 -6
  94. package/dist/components/SubagentBlock.js.map +2 -2
  95. package/dist/components/TabbedListView/ScrollableList.js +31 -5
  96. package/dist/components/TabbedListView/ScrollableList.js.map +2 -2
  97. package/dist/components/TabbedListView/TabBar.js +13 -8
  98. package/dist/components/TabbedListView/TabBar.js.map +2 -2
  99. package/dist/components/TabbedListView/TabbedListView.js +123 -48
  100. package/dist/components/TabbedListView/TabbedListView.js.map +2 -2
  101. package/dist/components/TodoPanel.js +1 -1
  102. package/dist/components/TodoPanel.js.map +1 -1
  103. package/dist/components/ToolUseLoader.js +5 -0
  104. package/dist/components/ToolUseLoader.js.map +2 -2
  105. package/dist/components/TrustDialog.js +0 -2
  106. package/dist/components/TrustDialog.js.map +2 -2
  107. package/dist/components/messages/TaskInModuleView.js +1 -1
  108. package/dist/components/messages/TaskInModuleView.js.map +2 -2
  109. package/dist/components/messages/TaskToolMessage.js +1 -1
  110. package/dist/components/messages/TaskToolMessage.js.map +2 -2
  111. package/dist/components/messages/UserPromptMessage.js +6 -1
  112. package/dist/components/messages/UserPromptMessage.js.map +2 -2
  113. package/dist/constants/modelCapabilities.js +103 -18
  114. package/dist/constants/modelCapabilities.js.map +2 -2
  115. package/dist/constants/product.js +2 -0
  116. package/dist/constants/product.js.map +2 -2
  117. package/dist/constants/prompts/agentPrompt.js +30 -0
  118. package/dist/constants/prompts/agentPrompt.js.map +7 -0
  119. package/dist/constants/prompts/codeConventions.js +27 -0
  120. package/dist/constants/prompts/codeConventions.js.map +7 -0
  121. package/dist/constants/prompts/doingTasks.js +15 -0
  122. package/dist/constants/prompts/doingTasks.js.map +7 -0
  123. package/dist/constants/prompts/envInfo.js +17 -0
  124. package/dist/constants/prompts/envInfo.js.map +7 -0
  125. package/dist/constants/prompts/executingWithCare.js +17 -0
  126. package/dist/constants/prompts/executingWithCare.js.map +7 -0
  127. package/dist/constants/prompts/identity.js +10 -0
  128. package/dist/constants/prompts/identity.js.map +7 -0
  129. package/dist/constants/prompts/index.js +78 -0
  130. package/dist/constants/prompts/index.js.map +7 -0
  131. package/dist/constants/prompts/taskManagement.js +60 -0
  132. package/dist/constants/prompts/taskManagement.js.map +7 -0
  133. package/dist/constants/prompts/toneAndStyle.js +62 -0
  134. package/dist/constants/prompts/toneAndStyle.js.map +7 -0
  135. package/dist/constants/prompts/toolUsagePolicy.js +38 -0
  136. package/dist/constants/prompts/toolUsagePolicy.js.map +7 -0
  137. package/dist/constants/prompts.js +5 -176
  138. package/dist/constants/prompts.js.map +2 -2
  139. package/dist/constants/providerRegistry.js +235 -0
  140. package/dist/constants/providerRegistry.js.map +7 -0
  141. package/dist/constants/providers.js +35 -0
  142. package/dist/constants/providers.js.map +7 -0
  143. package/dist/context/PermissionContext.js +0 -1
  144. package/dist/context/PermissionContext.js.map +2 -2
  145. package/dist/context.js +87 -31
  146. package/dist/context.js.map +2 -2
  147. package/dist/core/backupHook.js +29 -0
  148. package/dist/core/backupHook.js.map +7 -0
  149. package/dist/core/config/defaults.js +11 -2
  150. package/dist/core/config/defaults.js.map +2 -2
  151. package/dist/core/config/schema.js +21 -3
  152. package/dist/core/config/schema.js.map +2 -2
  153. package/dist/core/costTracker.js +18 -16
  154. package/dist/core/costTracker.js.map +2 -2
  155. package/dist/core/index.js +0 -1
  156. package/dist/core/index.js.map +2 -2
  157. package/dist/core/tokenStatsManager.js +22 -4
  158. package/dist/core/tokenStatsManager.js.map +2 -2
  159. package/dist/cost-tracker.js +0 -16
  160. package/dist/cost-tracker.js.map +2 -2
  161. package/dist/entrypoints/bootstrap.js +3 -1
  162. package/dist/entrypoints/bootstrap.js.map +2 -2
  163. package/dist/entrypoints/cli.js +81 -68
  164. package/dist/entrypoints/cli.js.map +2 -2
  165. package/dist/hooks/useAgentTokenStats.js +1 -1
  166. package/dist/hooks/useAgentTokenStats.js.map +2 -2
  167. package/dist/hooks/useAgentTranscripts.js +2 -1
  168. package/dist/hooks/useAgentTranscripts.js.map +2 -2
  169. package/dist/hooks/useBackgroundShells.js +29 -0
  170. package/dist/hooks/useBackgroundShells.js.map +7 -0
  171. package/dist/hooks/useCanUseTool.js +1 -1
  172. package/dist/hooks/useCanUseTool.js.map +2 -2
  173. package/dist/hooks/useDeferredLoading.js +64 -0
  174. package/dist/hooks/useDeferredLoading.js.map +7 -0
  175. package/dist/hooks/useHookStatus.js +1 -1
  176. package/dist/hooks/useHookStatus.js.map +2 -2
  177. package/dist/hooks/useSessionTracking.js +55 -0
  178. package/dist/hooks/useSessionTracking.js.map +7 -0
  179. package/dist/hooks/useTerminalSize.js +21 -0
  180. package/dist/hooks/useTerminalSize.js.map +2 -2
  181. package/dist/hooks/useTextInput.js +1 -0
  182. package/dist/hooks/useTextInput.js.map +2 -2
  183. package/dist/hooks/useUnifiedCompletion.js +3 -2
  184. package/dist/hooks/useUnifiedCompletion.js.map +2 -2
  185. package/dist/i18n/locales/en.js +299 -1
  186. package/dist/i18n/locales/en.js.map +2 -2
  187. package/dist/i18n/locales/zh-CN.js +300 -2
  188. package/dist/i18n/locales/zh-CN.js.map +2 -2
  189. package/dist/i18n/types.js.map +1 -1
  190. package/dist/messages.js +41 -17
  191. package/dist/messages.js.map +2 -2
  192. package/dist/permissions.js +94 -1
  193. package/dist/permissions.js.map +2 -2
  194. package/dist/query.js +27 -19
  195. package/dist/query.js.map +2 -2
  196. package/dist/screens/REPL.js +83 -74
  197. package/dist/screens/REPL.js.map +2 -2
  198. package/dist/services/adapters/responsesAPI.js +6 -0
  199. package/dist/services/adapters/responsesAPI.js.map +2 -2
  200. package/dist/services/agentTeams/index.js +35 -0
  201. package/dist/services/agentTeams/index.js.map +7 -0
  202. package/dist/services/agentTeams/mailbox.js +114 -0
  203. package/dist/services/agentTeams/mailbox.js.map +7 -0
  204. package/dist/services/agentTeams/teamManager.js +149 -0
  205. package/dist/services/agentTeams/teamManager.js.map +7 -0
  206. package/dist/services/agentTeams/teamTaskStore.js +114 -0
  207. package/dist/services/agentTeams/teamTaskStore.js.map +7 -0
  208. package/dist/services/agentTeams/teammateSpawner.js +80 -0
  209. package/dist/services/agentTeams/teammateSpawner.js.map +7 -0
  210. package/dist/services/checkpointManager.js +16 -3
  211. package/dist/services/checkpointManager.js.map +2 -2
  212. package/dist/services/claude.js +19 -1728
  213. package/dist/services/claude.js.map +3 -3
  214. package/dist/services/customCommands.js +30 -8
  215. package/dist/services/customCommands.js.map +2 -2
  216. package/dist/services/gpt5ConnectionTest.js +4 -2
  217. package/dist/services/gpt5ConnectionTest.js.map +2 -2
  218. package/dist/services/hookExecutor.js +411 -127
  219. package/dist/services/hookExecutor.js.map +2 -2
  220. package/dist/services/llm/anthropicProvider.js +807 -0
  221. package/dist/services/llm/anthropicProvider.js.map +7 -0
  222. package/dist/services/llm/dispatch.js +218 -0
  223. package/dist/services/llm/dispatch.js.map +7 -0
  224. package/dist/services/llm/index.js +44 -0
  225. package/dist/services/llm/index.js.map +7 -0
  226. package/dist/services/llm/mintoContext.js +69 -0
  227. package/dist/services/llm/mintoContext.js.map +7 -0
  228. package/dist/services/llm/openaiProvider.js +622 -0
  229. package/dist/services/llm/openaiProvider.js.map +7 -0
  230. package/dist/services/llm/types.js +157 -0
  231. package/dist/services/llm/types.js.map +7 -0
  232. package/dist/services/mcpClient.js +183 -33
  233. package/dist/services/mcpClient.js.map +2 -2
  234. package/dist/services/notifier.js +14 -0
  235. package/dist/services/notifier.js.map +2 -2
  236. package/dist/services/oauth.js +4 -2
  237. package/dist/services/oauth.js.map +2 -2
  238. package/dist/services/openai.js +66 -56
  239. package/dist/services/openai.js.map +3 -3
  240. package/dist/services/outputStyles.js +102 -21
  241. package/dist/services/outputStyles.js.map +2 -2
  242. package/dist/services/plugins/lspServers.js +1 -1
  243. package/dist/services/plugins/lspServers.js.map +2 -2
  244. package/dist/services/plugins/pluginRuntime.js +2 -1
  245. package/dist/services/plugins/pluginRuntime.js.map +2 -2
  246. package/dist/services/plugins/pluginValidation.js +10 -3
  247. package/dist/services/plugins/pluginValidation.js.map +2 -2
  248. package/dist/services/plugins/skillMarketplace.js +20 -9
  249. package/dist/services/plugins/skillMarketplace.js.map +2 -2
  250. package/dist/services/sentry.js +1 -1
  251. package/dist/services/sentry.js.map +2 -2
  252. package/dist/services/sessionMemory.js +16 -3
  253. package/dist/services/sessionMemory.js.map +2 -2
  254. package/dist/services/systemReminder.js +367 -9
  255. package/dist/services/systemReminder.js.map +2 -2
  256. package/dist/services/taskStore.js +19 -0
  257. package/dist/services/taskStore.js.map +2 -2
  258. package/dist/tools/ArchitectTool/ArchitectTool.js.map +1 -1
  259. package/dist/tools/AskUserQuestionTool/AskUserQuestionTool.js.map +1 -1
  260. package/dist/tools/BashOutputTool/BashOutputTool.js.map +1 -1
  261. package/dist/tools/BashTool/BashTool.js +28 -0
  262. package/dist/tools/BashTool/BashTool.js.map +2 -2
  263. package/dist/tools/FileEditTool/FileEditTool.js +8 -1
  264. package/dist/tools/FileEditTool/FileEditTool.js.map +2 -2
  265. package/dist/tools/FileReadTool/FileReadTool.js +14 -0
  266. package/dist/tools/FileReadTool/FileReadTool.js.map +2 -2
  267. package/dist/tools/FileWriteTool/FileWriteTool.js +10 -1
  268. package/dist/tools/FileWriteTool/FileWriteTool.js.map +2 -2
  269. package/dist/tools/GlobTool/GlobTool.js.map +1 -1
  270. package/dist/tools/GrepTool/GrepTool.js.map +1 -1
  271. package/dist/tools/KillShellTool/KillShellTool.js.map +1 -1
  272. package/dist/tools/ListMcpResourcesTool/ListMcpResourcesTool.js.map +2 -2
  273. package/dist/tools/LspTool/LspTool.js +11 -2
  274. package/dist/tools/LspTool/LspTool.js.map +2 -2
  275. package/dist/tools/MCPTool/MCPTool.js.map +1 -1
  276. package/dist/tools/MemoryReadTool/MemoryReadTool.js +2 -1
  277. package/dist/tools/MemoryReadTool/MemoryReadTool.js.map +2 -2
  278. package/dist/tools/MemoryWriteTool/MemoryWriteTool.js +2 -1
  279. package/dist/tools/MemoryWriteTool/MemoryWriteTool.js.map +2 -2
  280. package/dist/tools/MultiEditTool/MultiEditTool.js +7 -0
  281. package/dist/tools/MultiEditTool/MultiEditTool.js.map +2 -2
  282. package/dist/tools/NotebookEditTool/NotebookEditTool.js +2 -0
  283. package/dist/tools/NotebookEditTool/NotebookEditTool.js.map +2 -2
  284. package/dist/tools/NotebookReadTool/NotebookReadTool.js.map +1 -1
  285. package/dist/tools/PlanModeTool/EnterPlanModeTool.js +8 -2
  286. package/dist/tools/PlanModeTool/EnterPlanModeTool.js.map +2 -2
  287. package/dist/tools/PlanModeTool/ExitPlanModeTool.js +2 -0
  288. package/dist/tools/PlanModeTool/ExitPlanModeTool.js.map +2 -2
  289. package/dist/tools/ReadMcpResourceTool/ReadMcpResourceTool.js.map +1 -1
  290. package/dist/tools/SlashCommandTool/SlashCommandTool.js +174 -18
  291. package/dist/tools/SlashCommandTool/SlashCommandTool.js.map +3 -3
  292. package/dist/tools/TaskCreateTool/TaskCreateTool.js.map +1 -1
  293. package/dist/tools/TaskGetTool/TaskGetTool.js.map +1 -1
  294. package/dist/tools/TaskListTool/TaskListTool.js.map +1 -1
  295. package/dist/tools/TaskOutputTool/TaskOutputTool.js.map +1 -1
  296. package/dist/tools/TaskStopTool/TaskStopTool.js.map +1 -1
  297. package/dist/tools/TaskTool/TaskTool.js +84 -11
  298. package/dist/tools/TaskTool/TaskTool.js.map +2 -2
  299. package/dist/tools/TaskTool/prompt.js +12 -6
  300. package/dist/tools/TaskTool/prompt.js.map +2 -2
  301. package/dist/tools/TaskUpdateTool/TaskUpdateTool.js.map +1 -1
  302. package/dist/tools/ThinkTool/ThinkTool.js.map +1 -1
  303. package/dist/tools/TodoWriteTool/TodoWriteTool.js.map +1 -1
  304. package/dist/tools/URLFetcherTool/URLFetcherTool.js.map +1 -1
  305. package/dist/tools/WebSearchTool/WebSearchTool.js.map +1 -1
  306. package/dist/tools/WebSearchTool/searchProviders.js +2 -1
  307. package/dist/tools/WebSearchTool/searchProviders.js.map +2 -2
  308. package/dist/tools/lsTool/lsTool.js.map +2 -2
  309. package/dist/tools/lsTool/prompt.js.map +1 -1
  310. package/dist/tools.js +14 -3
  311. package/dist/tools.js.map +2 -2
  312. package/dist/types/PermissionMode.js +21 -1
  313. package/dist/types/PermissionMode.js.map +2 -2
  314. package/dist/types/agentTeams.js +1 -0
  315. package/dist/types/agentTeams.js.map +7 -0
  316. package/dist/types/hooks.js +8 -2
  317. package/dist/types/hooks.js.map +2 -2
  318. package/dist/types/plugin.js +3 -5
  319. package/dist/types/plugin.js.map +2 -2
  320. package/dist/utils/agentHookExecutor.js +1 -4
  321. package/dist/utils/agentHookExecutor.js.map +2 -2
  322. package/dist/utils/agentLoader.js +91 -15
  323. package/dist/utils/agentLoader.js.map +2 -2
  324. package/dist/utils/agentMemory.js.map +2 -2
  325. package/dist/utils/animationManager.js +1 -1
  326. package/dist/utils/animationManager.js.map +2 -2
  327. package/dist/utils/ask.js +1 -1
  328. package/dist/utils/async.js +5 -1
  329. package/dist/utils/async.js.map +2 -2
  330. package/dist/utils/autoCompactCore.js +60 -0
  331. package/dist/utils/autoCompactCore.js.map +2 -2
  332. package/dist/utils/claudeCodeSync.js +439 -0
  333. package/dist/utils/claudeCodeSync.js.map +7 -0
  334. package/dist/utils/config.js +27 -151
  335. package/dist/utils/config.js.map +2 -2
  336. package/dist/utils/configSchema.js +227 -0
  337. package/dist/utils/configSchema.js.map +7 -0
  338. package/dist/utils/debugLogger.js.map +2 -2
  339. package/dist/utils/env.js +4 -3
  340. package/dist/utils/env.js.map +2 -2
  341. package/dist/utils/envConfig.js +34 -0
  342. package/dist/utils/envConfig.js.map +3 -3
  343. package/dist/utils/execFileNoThrow.js +2 -1
  344. package/dist/utils/execFileNoThrow.js.map +2 -2
  345. package/dist/utils/gpt5.js +146 -0
  346. package/dist/utils/gpt5.js.map +7 -0
  347. package/dist/utils/hookManager.js +374 -140
  348. package/dist/utils/hookManager.js.map +2 -2
  349. package/dist/utils/markdown.js +47 -0
  350. package/dist/utils/markdown.js.map +2 -2
  351. package/dist/utils/marketplaceManager.js +80 -43
  352. package/dist/utils/marketplaceManager.js.map +2 -2
  353. package/dist/utils/memoizeWithTTL.js +25 -0
  354. package/dist/utils/memoizeWithTTL.js.map +7 -0
  355. package/dist/utils/messages.js +2 -2
  356. package/dist/utils/messages.js.map +2 -2
  357. package/dist/utils/model.js +34 -9
  358. package/dist/utils/model.js.map +2 -2
  359. package/dist/utils/pluginInstaller.js +68 -29
  360. package/dist/utils/pluginInstaller.js.map +2 -2
  361. package/dist/utils/pluginLoader.js +249 -57
  362. package/dist/utils/pluginLoader.js.map +2 -2
  363. package/dist/utils/repoFetcher.js +110 -0
  364. package/dist/utils/repoFetcher.js.map +7 -0
  365. package/dist/utils/safeFetch.js +45 -0
  366. package/dist/utils/safeFetch.js.map +7 -0
  367. package/dist/utils/skillLoader.js +77 -12
  368. package/dist/utils/skillLoader.js.map +2 -2
  369. package/dist/utils/streamingState.js +52 -0
  370. package/dist/utils/streamingState.js.map +7 -0
  371. package/dist/utils/stringSubstitution.js +4 -5
  372. package/dist/utils/stringSubstitution.js.map +2 -2
  373. package/dist/utils/style.js +6 -3
  374. package/dist/utils/style.js.map +2 -2
  375. package/dist/utils/teamConfig.js +162 -16
  376. package/dist/utils/teamConfig.js.map +2 -2
  377. package/dist/utils/terminal.js +1 -1
  378. package/dist/utils/terminal.js.map +2 -2
  379. package/dist/utils/toolRiskClassification.js +0 -6
  380. package/dist/utils/toolRiskClassification.js.map +2 -2
  381. package/dist/version.js +2 -2
  382. package/dist/version.js.map +1 -1
  383. package/package.json +7 -6
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/tools/NotebookEditTool/NotebookEditTool.tsx"],
4
- "sourcesContent": ["import { existsSync, readFileSync } from 'fs'\nimport { Box, Text } from 'ink'\nimport { extname, isAbsolute, relative, resolve } from 'path'\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { FallbackToolUseRejectedMessage } from '@components/FallbackToolUseRejectedMessage'\nimport { HighlightedCode } from '@components/HighlightedCode'\nimport type { Tool } from '@tool'\nimport { NotebookCellType, NotebookContent } from '@minto-types/notebook'\nimport {\n detectFileEncoding,\n detectLineEndings,\n writeTextContent,\n} from '@utils/file'\nimport { safeParseJSON } from '@utils/json'\nimport { getCwd } from '@utils/state'\nimport { DESCRIPTION, PROMPT } from './prompt'\nimport { hasWritePermission } from '@utils/permissions/filesystem'\nimport { emitReminderEvent } from '@services/systemReminder'\nimport { recordFileEdit } from '@services/fileFreshness'\nimport { FileEditTool } from '@tools/FileEditTool/FileEditTool'\n\nconst inputSchema = z.strictObject({\n notebook_path: z\n .string()\n .describe(\n 'The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)',\n ),\n cell_id: z\n .string()\n .optional()\n .describe(\n 'The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified.',\n ),\n new_source: z.string().describe('The new source for the cell'),\n cell_type: z\n .enum(['code', 'markdown'])\n .optional()\n .describe(\n 'The type of the cell (code or markdown). If not specified, it defaults to the current cell type. If using edit_mode=insert, this is required.',\n ),\n edit_mode: z\n .enum(['replace', 'insert', 'delete'])\n .optional()\n .describe(\n 'The type of edit to make (replace, insert, delete). Defaults to replace.',\n ),\n})\n\nexport const NotebookEditTool = {\n name: 'NotebookEdit',\n async description() {\n return DESCRIPTION\n },\n async prompt() {\n return PROMPT\n },\n inputSchema,\n userFacingName() {\n return 'Edit Notebook'\n },\n async isEnabled() {\n return true\n },\n isReadOnly() {\n return false\n },\n isConcurrencySafe() {\n return false // NotebookEditTool modifies state/files, not safe for concurrent execution\n },\n needsPermissions({ notebook_path }) {\n return !hasWritePermission(notebook_path)\n },\n renderResultForAssistant({ cell_id, edit_mode, new_source, error }) {\n if (error) {\n return error\n }\n switch (edit_mode) {\n case 'replace':\n return `Updated cell ${cell_id} with ${new_source}`\n case 'insert':\n return `Inserted cell after ${cell_id || 'beginning'} with ${new_source}`\n case 'delete':\n return `Deleted cell ${cell_id}`\n }\n },\n renderToolUseMessage(input, { verbose }) {\n return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}, cell_id: ${input.cell_id || '(beginning)'}, content: ${input.new_source.slice(0, 30)}\u2026, cell_type: ${input.cell_type}, edit_mode: ${input.edit_mode ?? 'replace'}`\n },\n renderToolUseRejectedMessage() {\n return <FallbackToolUseRejectedMessage />\n },\n renderToolResultMessage(output) {\n // Guard against undefined or null output\n if (!output) {\n return (\n <Box flexDirection=\"column\">\n <Text>Notebook cell updated</Text>\n </Box>\n )\n }\n\n const { cell_id, new_source, language, error } = output\n\n if (error) {\n return (\n <Box flexDirection=\"column\">\n <Text color=\"red\">{error}</Text>\n </Box>\n )\n }\n\n return (\n <Box flexDirection=\"column\">\n <Text>Updated cell {cell_id}:</Text>\n <Box marginLeft={2}>\n <HighlightedCode code={new_source} language={language} />\n </Box>\n </Box>\n )\n },\n async validateInput({\n notebook_path,\n cell_id,\n cell_type,\n edit_mode = 'replace',\n }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n if (!existsSync(fullPath)) {\n return {\n result: false,\n message: 'Notebook file does not exist.',\n }\n }\n\n if (extname(fullPath) !== '.ipynb') {\n return {\n result: false,\n message: `File must be a Jupyter notebook (.ipynb file). For editing other file types, use the ${FileEditTool.name} tool.`,\n }\n }\n\n if (edit_mode === 'insert' && !cell_type) {\n return {\n result: false,\n message: 'Cell type is required when using edit_mode=insert.',\n }\n }\n\n const enc = detectFileEncoding(fullPath)\n const content = readFileSync(fullPath, enc)\n const notebook = safeParseJSON(content) as NotebookContent | null\n if (!notebook) {\n return {\n result: false,\n message: 'Notebook is not valid JSON.',\n }\n }\n\n // For replace and delete, cell_id is required and must exist\n if ((edit_mode === 'replace' || edit_mode === 'delete') && !cell_id) {\n return {\n result: false,\n message: 'cell_id is required for replace and delete operations.',\n }\n }\n\n // Validate cell_id exists in notebook (if provided)\n if (cell_id) {\n const cellIndex = notebook.cells.findIndex(\n (cell: { id?: string }, index: number) =>\n cell.id === cell_id || String(index) === cell_id,\n )\n if (cellIndex === -1 && edit_mode !== 'insert') {\n return {\n result: false,\n message: `Cell with ID '${cell_id}' not found in notebook. Available cells: ${notebook.cells.length}`,\n }\n }\n }\n\n return { result: true }\n },\n async *call({ notebook_path, cell_id, new_source, cell_type, edit_mode }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n try {\n const enc = detectFileEncoding(fullPath)\n const content = readFileSync(fullPath, enc)\n const notebook = JSON.parse(content) as NotebookContent\n const language = notebook.metadata.language_info?.name ?? 'python'\n\n // Find cell index by ID (or treat cell_id as index string for backward compatibility)\n const findCellIndex = (id: string | undefined): number => {\n if (!id) return 0 // Insert at beginning if no cell_id\n const byId = notebook.cells.findIndex(\n (cell: { id?: string }) => cell.id === id,\n )\n if (byId !== -1) return byId\n // Fallback: treat as numeric index for backward compatibility\n const numIndex = parseInt(id, 10)\n if (\n !isNaN(numIndex) &&\n numIndex >= 0 &&\n numIndex < notebook.cells.length\n ) {\n return numIndex\n }\n return -1\n }\n\n const cellIndex = findCellIndex(cell_id)\n\n if (edit_mode === 'delete') {\n // Delete the specified cell\n if (cellIndex === -1) {\n throw new Error(`Cell with ID '${cell_id}' not found`)\n }\n notebook.cells.splice(cellIndex, 1)\n } else if (edit_mode === 'insert') {\n // Insert the new cell after the specified cell (or at beginning if no cell_id)\n const insertIndex = cell_id ? cellIndex + 1 : 0\n const newCellId = `cell-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`\n const new_cell = {\n id: newCellId,\n cell_type: cell_type!, // validateInput ensures cell_type is not undefined\n source: new_source,\n metadata: {},\n }\n notebook.cells.splice(\n insertIndex,\n 0,\n cell_type === 'markdown' ? new_cell : { ...new_cell, outputs: [] },\n )\n } else {\n // Replace: Find the specified cell\n if (cellIndex === -1) {\n throw new Error(`Cell with ID '${cell_id}' not found`)\n }\n const targetCell = notebook.cells[cellIndex]!\n targetCell.source = new_source\n // Reset execution count and clear outputs since cell was modified\n targetCell.execution_count = undefined\n targetCell.outputs = []\n if (cell_type && cell_type !== targetCell.cell_type) {\n targetCell.cell_type = cell_type\n }\n }\n // Write back to file\n const endings = detectLineEndings(fullPath)\n const updatedNotebook = JSON.stringify(notebook, null, 1)\n writeTextContent(fullPath, updatedNotebook, enc, endings!)\n\n // Record Agent edit operation for file freshness tracking\n recordFileEdit(fullPath, updatedNotebook)\n\n // Emit file edited event for system reminders\n emitReminderEvent('file:edited', {\n filePath: fullPath,\n cellId: cell_id,\n newSource: new_source,\n cellType: cell_type,\n editMode: edit_mode || 'replace',\n timestamp: Date.now(),\n operation: 'notebook_edit',\n })\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language,\n edit_mode: edit_mode ?? 'replace',\n error: '',\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n } catch (error) {\n if (error instanceof Error) {\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language: 'python',\n edit_mode: 'replace',\n error: error.message,\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n return\n }\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language: 'python',\n edit_mode: 'replace',\n error: 'Unknown error occurred while editing notebook',\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n }\n },\n} satisfies Tool<\n typeof inputSchema,\n {\n cell_id: string\n new_source: string\n cell_type: NotebookCellType\n language: string\n edit_mode: string\n error?: string\n }\n>\n"],
5
- "mappings": "AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,KAAK,YAAY;AAC1B,SAAS,SAAS,YAAY,UAAU,eAAe;AACvD,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,sCAAsC;AAC/C,SAAS,uBAAuB;AAGhC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,aAAa,cAAc;AACpC,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAE7B,MAAM,cAAc,EAAE,aAAa;AAAA,EACjC,eAAe,EACZ,OAAO,EACP;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAAS,EACN,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,YAAY,EAAE,OAAO,EAAE,SAAS,6BAA6B;AAAA,EAC7D,WAAW,EACR,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW,EACR,KAAK,CAAC,WAAW,UAAU,QAAQ,CAAC,EACpC,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC;AAEM,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,SAAS;AACb,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,aAAa;AAC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ACF;AACF;",
4
+ "sourcesContent": ["import { existsSync, readFileSync } from 'fs'\nimport { Box, Text } from 'ink'\nimport { extname, isAbsolute, relative, resolve } from 'path'\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { FallbackToolUseRejectedMessage } from '@components/FallbackToolUseRejectedMessage'\nimport { HighlightedCode } from '@components/HighlightedCode'\nimport type { Tool } from '@tool'\nimport { NotebookCellType, NotebookContent } from '@minto-types/notebook'\nimport {\n detectFileEncoding,\n detectLineEndings,\n writeTextContent,\n} from '@utils/file'\nimport { safeParseJSON } from '@utils/json'\nimport { getCwd } from '@utils/state'\nimport { DESCRIPTION, PROMPT } from './prompt'\nimport { hasWritePermission } from '@utils/permissions/filesystem'\nimport { emitReminderEvent } from '@services/systemReminder'\nimport { recordFileEdit } from '@services/fileFreshness'\nimport { triggerBackup } from '@core/backupHook'\nimport { FileEditTool } from '@tools/FileEditTool/FileEditTool'\n\nconst inputSchema = z.strictObject({\n notebook_path: z\n .string()\n .describe(\n 'The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)',\n ),\n cell_id: z\n .string()\n .optional()\n .describe(\n 'The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified.',\n ),\n new_source: z.string().describe('The new source for the cell'),\n cell_type: z\n .enum(['code', 'markdown'])\n .optional()\n .describe(\n 'The type of the cell (code or markdown). If not specified, it defaults to the current cell type. If using edit_mode=insert, this is required.',\n ),\n edit_mode: z\n .enum(['replace', 'insert', 'delete'])\n .optional()\n .describe(\n 'The type of edit to make (replace, insert, delete). Defaults to replace.',\n ),\n})\n\nexport const NotebookEditTool = {\n name: 'NotebookEdit',\n async description() {\n return DESCRIPTION\n },\n async prompt() {\n return PROMPT\n },\n inputSchema,\n userFacingName() {\n return 'Edit Notebook'\n },\n async isEnabled() {\n return true\n },\n isReadOnly() {\n return false\n },\n isConcurrencySafe() {\n return false // NotebookEditTool modifies state/files, not safe for concurrent execution\n },\n needsPermissions({ notebook_path }) {\n return !hasWritePermission(notebook_path)\n },\n renderResultForAssistant({ cell_id, edit_mode, new_source, error }) {\n if (error) {\n return error\n }\n switch (edit_mode) {\n case 'replace':\n return `Updated cell ${cell_id} with ${new_source}`\n case 'insert':\n return `Inserted cell after ${cell_id || 'beginning'} with ${new_source}`\n case 'delete':\n return `Deleted cell ${cell_id}`\n }\n },\n renderToolUseMessage(input, { verbose }) {\n return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}, cell_id: ${input.cell_id || '(beginning)'}, content: ${input.new_source.slice(0, 30)}\u2026, cell_type: ${input.cell_type}, edit_mode: ${input.edit_mode ?? 'replace'}`\n },\n renderToolUseRejectedMessage() {\n return <FallbackToolUseRejectedMessage />\n },\n renderToolResultMessage(output) {\n // Guard against undefined or null output\n if (!output) {\n return (\n <Box flexDirection=\"column\">\n <Text>Notebook cell updated</Text>\n </Box>\n )\n }\n\n const { cell_id, new_source, language, error } = output\n\n if (error) {\n return (\n <Box flexDirection=\"column\">\n <Text color=\"red\">{error}</Text>\n </Box>\n )\n }\n\n return (\n <Box flexDirection=\"column\">\n <Text>Updated cell {cell_id}:</Text>\n <Box marginLeft={2}>\n <HighlightedCode code={new_source} language={language} />\n </Box>\n </Box>\n )\n },\n async validateInput({\n notebook_path,\n cell_id,\n cell_type,\n edit_mode = 'replace',\n }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n if (!existsSync(fullPath)) {\n return {\n result: false,\n message: 'Notebook file does not exist.',\n }\n }\n\n if (extname(fullPath) !== '.ipynb') {\n return {\n result: false,\n message: `File must be a Jupyter notebook (.ipynb file). For editing other file types, use the ${FileEditTool.name} tool.`,\n }\n }\n\n if (edit_mode === 'insert' && !cell_type) {\n return {\n result: false,\n message: 'Cell type is required when using edit_mode=insert.',\n }\n }\n\n const enc = detectFileEncoding(fullPath)\n const content = readFileSync(fullPath, enc)\n const notebook = safeParseJSON(content) as NotebookContent | null\n if (!notebook) {\n return {\n result: false,\n message: 'Notebook is not valid JSON.',\n }\n }\n\n // For replace and delete, cell_id is required and must exist\n if ((edit_mode === 'replace' || edit_mode === 'delete') && !cell_id) {\n return {\n result: false,\n message: 'cell_id is required for replace and delete operations.',\n }\n }\n\n // Validate cell_id exists in notebook (if provided)\n if (cell_id) {\n const cellIndex = notebook.cells.findIndex(\n (cell: { id?: string }, index: number) =>\n cell.id === cell_id || String(index) === cell_id,\n )\n if (cellIndex === -1 && edit_mode !== 'insert') {\n return {\n result: false,\n message: `Cell with ID '${cell_id}' not found in notebook. Available cells: ${notebook.cells.length}`,\n }\n }\n }\n\n return { result: true }\n },\n async *call({ notebook_path, cell_id, new_source, cell_type, edit_mode }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n try {\n const enc = detectFileEncoding(fullPath)\n const content = readFileSync(fullPath, enc)\n const notebook = JSON.parse(content) as NotebookContent\n const language = notebook.metadata.language_info?.name ?? 'python'\n\n // Find cell index by ID (or treat cell_id as index string for backward compatibility)\n const findCellIndex = (id: string | undefined): number => {\n if (!id) return 0 // Insert at beginning if no cell_id\n const byId = notebook.cells.findIndex(\n (cell: { id?: string }) => cell.id === id,\n )\n if (byId !== -1) return byId\n // Fallback: treat as numeric index for backward compatibility\n const numIndex = parseInt(id, 10)\n if (\n !isNaN(numIndex) &&\n numIndex >= 0 &&\n numIndex < notebook.cells.length\n ) {\n return numIndex\n }\n return -1\n }\n\n const cellIndex = findCellIndex(cell_id)\n\n if (edit_mode === 'delete') {\n // Delete the specified cell\n if (cellIndex === -1) {\n throw new Error(`Cell with ID '${cell_id}' not found`)\n }\n notebook.cells.splice(cellIndex, 1)\n } else if (edit_mode === 'insert') {\n // Insert the new cell after the specified cell (or at beginning if no cell_id)\n const insertIndex = cell_id ? cellIndex + 1 : 0\n const newCellId = `cell-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`\n const new_cell = {\n id: newCellId,\n cell_type: cell_type!, // validateInput ensures cell_type is not undefined\n source: new_source,\n metadata: {},\n }\n notebook.cells.splice(\n insertIndex,\n 0,\n cell_type === 'markdown' ? new_cell : { ...new_cell, outputs: [] },\n )\n } else {\n // Replace: Find the specified cell\n if (cellIndex === -1) {\n throw new Error(`Cell with ID '${cell_id}' not found`)\n }\n const targetCell = notebook.cells[cellIndex]!\n targetCell.source = new_source\n // Reset execution count and clear outputs since cell was modified\n targetCell.execution_count = undefined\n targetCell.outputs = []\n if (cell_type && cell_type !== targetCell.cell_type) {\n targetCell.cell_type = cell_type\n }\n }\n // Write back to file\n const endings = detectLineEndings(fullPath)\n const updatedNotebook = JSON.stringify(notebook, null, 1)\n writeTextContent(fullPath, updatedNotebook, enc, endings!)\n\n // Record Agent edit operation for file freshness tracking\n recordFileEdit(fullPath, updatedNotebook)\n triggerBackup(fullPath, content, updatedNotebook, 'update')\n\n // Emit file edited event for system reminders\n emitReminderEvent('file:edited', {\n filePath: fullPath,\n cellId: cell_id,\n newSource: new_source,\n cellType: cell_type,\n editMode: edit_mode || 'replace',\n timestamp: Date.now(),\n operation: 'notebook_edit',\n })\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language,\n edit_mode: edit_mode ?? 'replace',\n error: '',\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n } catch (error) {\n if (error instanceof Error) {\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language: 'python',\n edit_mode: 'replace',\n error: error.message,\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n return\n }\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language: 'python',\n edit_mode: 'replace',\n error: 'Unknown error occurred while editing notebook',\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n }\n },\n} satisfies Tool\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,oBAAoB;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B,KAAK,OAAQ;AAGzD,qBAAe,UAAU,eAAe;AACxC,oBAAc,UAAU,SAAS,iBAAiB,QAAQ;AAG1D,wBAAkB,eAAe;AAAA,QAC/B,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,WAAW;AAAA,QACX,UAAU;AAAA,QACV,UAAU,aAAa;AAAA,QACvB,WAAW,KAAK,IAAI;AAAA,QACpB,WAAW;AAAA,MACb,CAAC;AACD,YAAM,OAAO;AAAA,QACX,SAAS,WAAW;AAAA,QACpB;AAAA,QACA,WAAW,aAAa;AAAA,QACxB;AAAA,QACA,WAAW,aAAa;AAAA,QACxB,OAAO;AAAA,MACT;AACA,YAAM;AAAA,QACJ,MAAM;AAAA,QACN;AAAA,QACA,oBAAoB,KAAK,yBAAyB,IAAI;AAAA,MACxD;AAAA,IACF,SAAS,OAAO;AACd,UAAI,iBAAiB,OAAO;AAC1B,cAAMA,QAAO;AAAA,UACX,SAAS,WAAW;AAAA,UACpB;AAAA,UACA,WAAW,aAAa;AAAA,UACxB,UAAU;AAAA,UACV,WAAW;AAAA,UACX,OAAO,MAAM;AAAA,QACf;AACA,cAAM;AAAA,UACJ,MAAM;AAAA,UACN,MAAAA;AAAA,UACA,oBAAoB,KAAK,yBAAyBA,KAAI;AAAA,QACxD;AACA;AAAA,MACF;AACA,YAAM,OAAO;AAAA,QACX,SAAS,WAAW;AAAA,QACpB;AAAA,QACA,WAAW,aAAa;AAAA,QACxB,UAAU;AAAA,QACV,WAAW;AAAA,QACX,OAAO;AAAA,MACT;AACA,YAAM;AAAA,QACJ,MAAM;AAAA,QACN;AAAA,QACA,oBAAoB,KAAK,yBAAyB,IAAI;AAAA,MACxD;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": ["data"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/tools/NotebookReadTool/NotebookReadTool.tsx"],
4
- "sourcesContent": ["import type {\n ImageBlockParam,\n TextBlockParam,\n} from '@anthropic-ai/sdk/resources/index.mjs'\n\nimport { existsSync, readFileSync } from 'fs'\nimport { Text } from 'ink'\nimport { extname, isAbsolute, relative, resolve } from 'path'\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { FallbackToolUseRejectedMessage } from '@components/FallbackToolUseRejectedMessage'\nimport { Tool } from '@tool'\nimport {\n NotebookCellSource,\n NotebookContent,\n NotebookCell,\n NotebookOutputImage,\n NotebookCellSourceOutput,\n NotebookCellOutput,\n NotebookCellType,\n} from '@minto-types/notebook'\nimport { formatOutput } from '@tools/BashTool/utils'\nimport { getCwd } from '@utils/state'\nimport { findSimilarFile } from '@utils/file'\nimport { DESCRIPTION, PROMPT } from './prompt'\nimport { hasReadPermission } from '@utils/permissions/filesystem'\n\nconst inputSchema = z.strictObject({\n notebook_path: z\n .string()\n .describe(\n 'The absolute path to the Jupyter notebook file to read (must be absolute, not relative)',\n ),\n})\n\ntype In = typeof inputSchema\ntype Out = NotebookCellSource[]\n\nexport const NotebookReadTool = {\n name: 'ReadNotebook',\n async description() {\n return DESCRIPTION\n },\n async prompt() {\n return PROMPT\n },\n isReadOnly() {\n return true\n },\n isConcurrencySafe() {\n return true // NotebookReadTool is read-only, safe for concurrent execution\n },\n inputSchema,\n userFacingName() {\n return 'Read Notebook'\n },\n async isEnabled() {\n return true\n },\n needsPermissions({ notebook_path }) {\n return !hasReadPermission(notebook_path)\n },\n async validateInput({ notebook_path }) {\n const fullFilePath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n if (!existsSync(fullFilePath)) {\n // Try to find a similar file with a different extension\n const similarFilename = findSimilarFile(fullFilePath)\n let message = 'File does not exist.'\n\n // If we found a similar file, suggest it to the assistant\n if (similarFilename) {\n message += ` Did you mean ${similarFilename}?`\n }\n\n return {\n result: false,\n message,\n }\n }\n\n if (extname(fullFilePath) !== '.ipynb') {\n return {\n result: false,\n message: 'File must be a Jupyter notebook (.ipynb file).',\n }\n }\n\n return { result: true }\n },\n renderToolUseMessage(input, { verbose }) {\n return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}`\n },\n renderToolUseRejectedMessage() {\n return <FallbackToolUseRejectedMessage />\n },\n\n renderToolResultMessage(content) {\n if (!content) {\n return <Text>No cells found in notebook</Text>\n }\n if (content.length < 1 || !content[0]) {\n return <Text>No cells found in notebook</Text>\n }\n return <Text>Read {content.length} cells</Text>\n },\n async *call({ notebook_path }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n const content = readFileSync(fullPath, 'utf-8')\n const notebook = JSON.parse(content) as NotebookContent\n const language = notebook.metadata.language_info?.name ?? 'python'\n const cells = notebook.cells.map((cell, index) =>\n processCell(cell, index, language),\n )\n\n yield {\n type: 'result',\n resultForAssistant: this.renderResultForAssistant(cells),\n data: cells,\n }\n },\n renderResultForAssistant(data: NotebookCellSource[]) {\n // Guard against undefined or null data\n if (!data || !Array.isArray(data)) {\n return 'No cells found in notebook'\n }\n\n // Convert the complex structure to a string representation for the assistant\n return data\n .map((cell, index) => {\n if (!cell) return `Cell ${index + 1}: (empty)`\n let content = `Cell ${index + 1} (${cell.cellType || 'unknown'}):\\n${cell.source || ''}`\n if (\n cell.outputs &&\n Array.isArray(cell.outputs) &&\n cell.outputs.length > 0\n ) {\n const outputText = cell.outputs\n .filter(output => output != null)\n .map(output => output.text || '')\n .filter(Boolean)\n .join('\\n')\n if (outputText) {\n content += `\\nOutput:\\n${outputText}`\n }\n }\n return content\n })\n .join('\\n\\n')\n },\n} satisfies Tool<In, Out>\n\nfunction processOutputText(text: string | string[] | undefined): string {\n if (!text) return ''\n const rawText = Array.isArray(text) ? text.join('') : text\n const { truncatedContent } = formatOutput(rawText)\n return truncatedContent\n}\n\nfunction extractImage(\n data: Record<string, unknown>,\n): NotebookOutputImage | undefined {\n if (typeof data['image/png'] === 'string') {\n return {\n image_data: data['image/png'] as string,\n media_type: 'image/png',\n }\n }\n if (typeof data['image/jpeg'] === 'string') {\n return {\n image_data: data['image/jpeg'] as string,\n media_type: 'image/jpeg',\n }\n }\n return undefined\n}\n\nfunction processOutput(output: NotebookCellOutput) {\n switch (output.output_type) {\n case 'stream':\n return {\n output_type: output.output_type,\n text: processOutputText(output.text),\n }\n case 'execute_result':\n case 'display_data':\n return {\n output_type: output.output_type,\n text: processOutputText(\n output.data?.['text/plain'] as string | string[] | undefined,\n ),\n image: output.data && extractImage(output.data),\n }\n case 'error':\n return {\n output_type: output.output_type,\n text: processOutputText(\n `${output.ename}: ${output.evalue}\\n${output.traceback.join('\\n')}`,\n ),\n }\n }\n}\n\nfunction processCell(\n cell: NotebookCell,\n index: number,\n language: string,\n): NotebookCellSource {\n const cellData: NotebookCellSource = {\n cell: index,\n cellType: cell.cell_type,\n source: Array.isArray(cell.source) ? cell.source.join('') : cell.source,\n language,\n execution_count: cell.execution_count,\n }\n\n if (cell.outputs?.length) {\n cellData.outputs = cell.outputs.map(processOutput)\n }\n\n return cellData\n}\n\nfunction cellContentToToolResult(cell: NotebookCellSource): TextBlockParam {\n const metadata = []\n if (cell.cellType !== 'code') {\n metadata.push(`<cell_type>${cell.cellType}</cell_type>`)\n }\n if (cell.language !== 'python' && cell.cellType === 'code') {\n metadata.push(`<language>${cell.language}</language>`)\n }\n const cellContent = `<cell ${cell.cell}>${metadata.join('')}${cell.source}</cell ${cell.cell}>`\n return {\n text: cellContent,\n type: 'text',\n }\n}\n\nfunction cellOutputToToolResult(output: NotebookCellSourceOutput) {\n const outputs: (TextBlockParam | ImageBlockParam)[] = []\n if (output.text) {\n outputs.push({\n text: `\\n${output.text}`,\n type: 'text',\n })\n }\n if (output.image) {\n outputs.push({\n type: 'image',\n source: {\n data: output.image.image_data,\n media_type: output.image.media_type,\n type: 'base64',\n },\n })\n }\n return outputs\n}\n\nfunction getToolResultFromCell(cell: NotebookCellSource) {\n const contentResult = cellContentToToolResult(cell)\n const outputResults = cell.outputs?.flatMap(cellOutputToToolResult)\n return [contentResult, ...(outputResults ?? [])]\n}\n\nexport function isNotebookCellType(\n value: string | null,\n): value is NotebookCellType {\n return value === 'code' || value === 'markdown'\n}\n"],
4
+ "sourcesContent": ["import type {\n ImageBlockParam,\n TextBlockParam,\n} from '@anthropic-ai/sdk/resources/index.mjs'\n\nimport { existsSync, readFileSync } from 'fs'\nimport { Text } from 'ink'\nimport { extname, isAbsolute, relative, resolve } from 'path'\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { FallbackToolUseRejectedMessage } from '@components/FallbackToolUseRejectedMessage'\nimport { Tool } from '@tool'\nimport {\n NotebookCellSource,\n NotebookContent,\n NotebookCell,\n NotebookOutputImage,\n NotebookCellSourceOutput,\n NotebookCellOutput,\n NotebookCellType,\n} from '@minto-types/notebook'\nimport { formatOutput } from '@tools/BashTool/utils'\nimport { getCwd } from '@utils/state'\nimport { findSimilarFile } from '@utils/file'\nimport { DESCRIPTION, PROMPT } from './prompt'\nimport { hasReadPermission } from '@utils/permissions/filesystem'\n\nconst inputSchema = z.strictObject({\n notebook_path: z\n .string()\n .describe(\n 'The absolute path to the Jupyter notebook file to read (must be absolute, not relative)',\n ),\n})\n\ntype In = typeof inputSchema\ntype Out = NotebookCellSource[]\n\nexport const NotebookReadTool = {\n name: 'ReadNotebook',\n async description() {\n return DESCRIPTION\n },\n async prompt() {\n return PROMPT\n },\n isReadOnly() {\n return true\n },\n isConcurrencySafe() {\n return true // NotebookReadTool is read-only, safe for concurrent execution\n },\n inputSchema,\n userFacingName() {\n return 'Read Notebook'\n },\n async isEnabled() {\n return true\n },\n needsPermissions({ notebook_path }) {\n return !hasReadPermission(notebook_path)\n },\n async validateInput({ notebook_path }) {\n const fullFilePath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n if (!existsSync(fullFilePath)) {\n // Try to find a similar file with a different extension\n const similarFilename = findSimilarFile(fullFilePath)\n let message = 'File does not exist.'\n\n // If we found a similar file, suggest it to the assistant\n if (similarFilename) {\n message += ` Did you mean ${similarFilename}?`\n }\n\n return {\n result: false,\n message,\n }\n }\n\n if (extname(fullFilePath) !== '.ipynb') {\n return {\n result: false,\n message: 'File must be a Jupyter notebook (.ipynb file).',\n }\n }\n\n return { result: true }\n },\n renderToolUseMessage(input, { verbose }) {\n return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}`\n },\n renderToolUseRejectedMessage() {\n return <FallbackToolUseRejectedMessage />\n },\n\n renderToolResultMessage(content) {\n if (!content) {\n return <Text>No cells found in notebook</Text>\n }\n if (content.length < 1 || !content[0]) {\n return <Text>No cells found in notebook</Text>\n }\n return <Text>Read {content.length} cells</Text>\n },\n async *call({ notebook_path }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n const content = readFileSync(fullPath, 'utf-8')\n const notebook = JSON.parse(content) as NotebookContent\n const language = notebook.metadata.language_info?.name ?? 'python'\n const cells = notebook.cells.map((cell, index) =>\n processCell(cell, index, language),\n )\n\n yield {\n type: 'result',\n resultForAssistant: this.renderResultForAssistant(cells),\n data: cells,\n }\n },\n renderResultForAssistant(data: NotebookCellSource[]) {\n // Guard against undefined or null data\n if (!data || !Array.isArray(data)) {\n return 'No cells found in notebook'\n }\n\n // Convert the complex structure to a string representation for the assistant\n return data\n .map((cell, index) => {\n if (!cell) return `Cell ${index + 1}: (empty)`\n let content = `Cell ${index + 1} (${cell.cellType || 'unknown'}):\\n${cell.source || ''}`\n if (\n cell.outputs &&\n Array.isArray(cell.outputs) &&\n cell.outputs.length > 0\n ) {\n const outputText = cell.outputs\n .filter(output => output != null)\n .map(output => output.text || '')\n .filter(Boolean)\n .join('\\n')\n if (outputText) {\n content += `\\nOutput:\\n${outputText}`\n }\n }\n return content\n })\n .join('\\n\\n')\n },\n} satisfies Tool\n\nfunction processOutputText(text: string | string[] | undefined): string {\n if (!text) return ''\n const rawText = Array.isArray(text) ? text.join('') : text\n const { truncatedContent } = formatOutput(rawText)\n return truncatedContent\n}\n\nfunction extractImage(\n data: Record<string, unknown>,\n): NotebookOutputImage | undefined {\n if (typeof data['image/png'] === 'string') {\n return {\n image_data: data['image/png'] as string,\n media_type: 'image/png',\n }\n }\n if (typeof data['image/jpeg'] === 'string') {\n return {\n image_data: data['image/jpeg'] as string,\n media_type: 'image/jpeg',\n }\n }\n return undefined\n}\n\nfunction processOutput(output: NotebookCellOutput) {\n switch (output.output_type) {\n case 'stream':\n return {\n output_type: output.output_type,\n text: processOutputText(output.text),\n }\n case 'execute_result':\n case 'display_data':\n return {\n output_type: output.output_type,\n text: processOutputText(\n output.data?.['text/plain'] as string | string[] | undefined,\n ),\n image: output.data && extractImage(output.data),\n }\n case 'error':\n return {\n output_type: output.output_type,\n text: processOutputText(\n `${output.ename}: ${output.evalue}\\n${output.traceback.join('\\n')}`,\n ),\n }\n }\n}\n\nfunction processCell(\n cell: NotebookCell,\n index: number,\n language: string,\n): NotebookCellSource {\n const cellData: NotebookCellSource = {\n cell: index,\n cellType: cell.cell_type,\n source: Array.isArray(cell.source) ? cell.source.join('') : cell.source,\n language,\n execution_count: cell.execution_count,\n }\n\n if (cell.outputs?.length) {\n cellData.outputs = cell.outputs.map(processOutput)\n }\n\n return cellData\n}\n\nfunction cellContentToToolResult(cell: NotebookCellSource): TextBlockParam {\n const metadata = []\n if (cell.cellType !== 'code') {\n metadata.push(`<cell_type>${cell.cellType}</cell_type>`)\n }\n if (cell.language !== 'python' && cell.cellType === 'code') {\n metadata.push(`<language>${cell.language}</language>`)\n }\n const cellContent = `<cell ${cell.cell}>${metadata.join('')}${cell.source}</cell ${cell.cell}>`\n return {\n text: cellContent,\n type: 'text',\n }\n}\n\nfunction cellOutputToToolResult(output: NotebookCellSourceOutput) {\n const outputs: (TextBlockParam | ImageBlockParam)[] = []\n if (output.text) {\n outputs.push({\n text: `\\n${output.text}`,\n type: 'text',\n })\n }\n if (output.image) {\n outputs.push({\n type: 'image',\n source: {\n data: output.image.image_data,\n media_type: output.image.media_type,\n type: 'base64',\n },\n })\n }\n return outputs\n}\n\nfunction getToolResultFromCell(cell: NotebookCellSource) {\n const contentResult = cellContentToToolResult(cell)\n const outputResults = cell.outputs?.flatMap(cellOutputToToolResult)\n return [contentResult, ...(outputResults ?? [])]\n}\n\nexport function isNotebookCellType(\n value: string | null,\n): value is NotebookCellType {\n return value === 'code' || value === 'markdown'\n}\n"],
5
5
  "mappings": "AAKA,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AACrB,SAAS,SAAS,YAAY,UAAU,eAAe;AACvD,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,sCAAsC;AAW/C,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,uBAAuB;AAChC,SAAS,aAAa,cAAc;AACpC,SAAS,yBAAyB;AAElC,MAAM,cAAc,EAAE,aAAa;AAAA,EACjC,eAAe,EACZ,OAAO,EACP;AAAA,IACC;AAAA,EACF;AACJ,CAAC;AAKM,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,SAAS;AACb,WAAO;AAAA,EACT;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,iBAAiB,EAAE,cAAc,GAAG;AAClC,WAAO,CAAC,kBAAkB,aAAa;AAAA,EACzC;AAAA,EACA,MAAM,cAAc,EAAE,cAAc,GAAG;AACrC,UAAM,eAAe,WAAW,aAAa,IACzC,gBACA,QAAQ,OAAO,GAAG,aAAa;AAEnC,QAAI,CAAC,WAAW,YAAY,GAAG;AAE7B,YAAM,kBAAkB,gBAAgB,YAAY;AACpD,UAAI,UAAU;AAGd,UAAI,iBAAiB;AACnB,mBAAW,iBAAiB,eAAe;AAAA,MAC7C;AAEA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ChB,YAAQ,KAAK;AAAA,MACX,MAAM;AAAA,MACN,QAAQ;AAAA,QACN,MAAM,OAAO,MAAM;AAAA,QACnB,YAAY,OAAO,MAAM;AAAA,QACzB,MAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,SAAS,sBAAsB,MAA0B;AACvD,QAAM,gBAAgB,wBAAwB,IAAI;AAClD,QAAM,gBAAgB,KAAK,SAAS,QAAQ,sBAAsB;AAClE,SAAO,CAAC,eAAe,GAAI,iBAAiB,CAAC,CAAE;AACjD;AAEO,SAAS,mBACd,OAC2B;AAC3B,SAAO,UAAU,UAAU,UAAU;AACvC;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import { Box, Text } from "ink";
2
2
  import React from "react";
3
3
  import { z } from "zod";
4
- import { enterPlanMode } from "../../utils/plan/planMode.js";
4
+ import { enterPlanMode, isPlanModeEnabled } from "../../utils/plan/planMode.js";
5
+ import { emitReminderEvent } from "../../services/systemReminder.js";
5
6
  import { ENTER_DESCRIPTION, ENTER_PROMPT, ENTER_TOOL_NAME } from "./prompt.js";
6
7
  import { SEMANTIC_COLORS } from "../../constants/colors.js";
7
8
  const inputSchema = z.strictObject({});
@@ -58,7 +59,12 @@ Remember: DO NOT write or edit any files yet. This is a read-only exploration an
58
59
  if (context?.agentId) {
59
60
  throw new Error("EnterPlanMode tool cannot be used in agent contexts");
60
61
  }
61
- enterPlanMode(context);
62
+ const wasAlreadyInPlanMode = isPlanModeEnabled(context);
63
+ const { planFilePath } = enterPlanMode(context);
64
+ if (wasAlreadyInPlanMode) {
65
+ emitReminderEvent("plan:mode_reentry", { planPath: planFilePath });
66
+ }
67
+ emitReminderEvent("plan:file_reference", { planPath: planFilePath });
62
68
  const output = {
63
69
  message: "Entered plan mode. You should now focus on exploring the codebase and designing an implementation approach."
64
70
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/tools/PlanModeTool/EnterPlanModeTool.tsx"],
4
- "sourcesContent": ["/**\n * Enter Plan Mode Tool\n *\n * Requests permission to enter plan mode for complex tasks.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport { enterPlanMode } from '@utils/plan/planMode'\nimport { ENTER_DESCRIPTION, ENTER_PROMPT, ENTER_TOOL_NAME } from './prompt'\nimport { SEMANTIC_COLORS } from '@constants/colors'\n\nconst inputSchema = z.strictObject({})\n\ntype Output = {\n message: string\n}\n\nexport const EnterPlanModeTool = {\n name: ENTER_TOOL_NAME,\n async description() {\n return ENTER_DESCRIPTION\n },\n userFacingName() {\n return ''\n },\n inputSchema,\n isReadOnly() {\n return true\n },\n isConcurrencySafe() {\n return true\n },\n async isEnabled() {\n return true\n },\n needsPermissions() {\n return true\n },\n requiresUserInteraction() {\n return true\n },\n async prompt() {\n return ENTER_PROMPT\n },\n renderToolUseMessage() {\n return ''\n },\n renderToolUseRejectedMessage() {\n return (\n <Box flexDirection=\"row\" marginTop={1}>\n <Text color={SEMANTIC_COLORS.dim}>\n User declined to enter plan mode\n </Text>\n </Box>\n )\n },\n renderToolResultMessage(_output: Output) {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box flexDirection=\"row\">\n <Text color=\"cyan\">\u25CF</Text>\n <Text> Entered plan mode</Text>\n </Box>\n <Box paddingLeft={2}>\n <Text color={SEMANTIC_COLORS.dim}>\n Minto is now exploring and designing an implementation approach.\n </Text>\n </Box>\n </Box>\n )\n },\n renderResultForAssistant(output: Output) {\n return `${output.message}\n\nIn plan mode, you should:\n1. Thoroughly explore the codebase to understand existing patterns\n2. Identify similar features and architectural approaches\n3. Consider multiple approaches and their trade-offs\n4. Use AskUserQuestion if you need to clarify the approach\n5. Design a concrete implementation strategy\n6. When ready, use ExitPlanMode to present your plan for approval\n\nRemember: DO NOT write or edit any files yet. This is a read-only exploration and planning phase.`\n },\n async *call(_input: z.infer<typeof inputSchema>, context: any) {\n if (context?.agentId) {\n throw new Error('EnterPlanMode tool cannot be used in agent contexts')\n }\n\n enterPlanMode(context)\n\n const output: Output = {\n message:\n 'Entered plan mode. You should now focus on exploring the codebase and designing an implementation approach.',\n }\n yield {\n type: 'result',\n data: output,\n resultForAssistant: this.renderResultForAssistant(output),\n }\n },\n} satisfies Tool<typeof inputSchema, Output>\n"],
5
- "mappings": "AAMA,SAAS,KAAK,YAAY;AAC1B,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB,cAAc,uBAAuB;AACjE,SAAS,uBAAuB;AAEhC,MAAM,cAAc,EAAE,aAAa,CAAC,CAAC;AAM9B,MAAM,oBAAoB;AAAA,EAC/B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,mBAAmB;AACjB,WAAO;AAAA,EACT;AAAA,EACA,0BAA0B;AACxB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,SAAS;AACb,WAAO;AAAA,EACT;AAAA,EACA,uBAAuB;AACrB,WAAO;AAAA,EACT;AAAA,EACA,+BAA+B;AAC7B,WACE,oCAAC,OAAI,eAAc,OAAM,WAAW,KAClC,oCAAC,QAAK,OAAO,gBAAgB,OAAK,kCAElC,CACF;AAAA,EAEJ;AAAA,EACA,wBAAwB,SAAiB;AACvC,WACE,oCAAC,OAAI,eAAc,UAAS,WAAW,KACrC,oCAAC,OAAI,eAAc,SACjB,oCAAC,QAAK,OAAM,UAAO,QAAC,GACpB,oCAAC,YAAK,oBAAkB,CAC1B,GACA,oCAAC,OAAI,aAAa,KAChB,oCAAC,QAAK,OAAO,gBAAgB,OAAK,kEAElC,CACF,CACF;AAAA,EAEJ;AAAA,EACA,yBAAyB,QAAgB;AACvC,WAAO,GAAG,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW1B;AAAA,EACA,OAAO,KAAK,QAAqC,SAAc;AAC7D,QAAI,SAAS,SAAS;AACpB,YAAM,IAAI,MAAM,qDAAqD;AAAA,IACvE;AAEA,kBAAc,OAAO;AAErB,UAAM,SAAiB;AAAA,MACrB,SACE;AAAA,IACJ;AACA,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,oBAAoB,KAAK,yBAAyB,MAAM;AAAA,IAC1D;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * Enter Plan Mode Tool\n *\n * Requests permission to enter plan mode for complex tasks.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport { enterPlanMode, isPlanModeEnabled } from '@utils/plan/planMode'\nimport { emitReminderEvent } from '@services/systemReminder'\nimport { ENTER_DESCRIPTION, ENTER_PROMPT, ENTER_TOOL_NAME } from './prompt'\nimport { SEMANTIC_COLORS } from '@constants/colors'\n\nconst inputSchema = z.strictObject({})\n\ntype Output = {\n message: string\n}\n\nexport const EnterPlanModeTool = {\n name: ENTER_TOOL_NAME,\n async description() {\n return ENTER_DESCRIPTION\n },\n userFacingName() {\n return ''\n },\n inputSchema,\n isReadOnly() {\n return true\n },\n isConcurrencySafe() {\n return true\n },\n async isEnabled() {\n return true\n },\n needsPermissions() {\n return true\n },\n requiresUserInteraction() {\n return true\n },\n async prompt() {\n return ENTER_PROMPT\n },\n renderToolUseMessage() {\n return ''\n },\n renderToolUseRejectedMessage() {\n return (\n <Box flexDirection=\"row\" marginTop={1}>\n <Text color={SEMANTIC_COLORS.dim}>\n User declined to enter plan mode\n </Text>\n </Box>\n )\n },\n renderToolResultMessage(_output: Output) {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box flexDirection=\"row\">\n <Text color=\"cyan\">\u25CF</Text>\n <Text> Entered plan mode</Text>\n </Box>\n <Box paddingLeft={2}>\n <Text color={SEMANTIC_COLORS.dim}>\n Minto is now exploring and designing an implementation approach.\n </Text>\n </Box>\n </Box>\n )\n },\n renderResultForAssistant(output: Output) {\n return `${output.message}\n\nIn plan mode, you should:\n1. Thoroughly explore the codebase to understand existing patterns\n2. Identify similar features and architectural approaches\n3. Consider multiple approaches and their trade-offs\n4. Use AskUserQuestion if you need to clarify the approach\n5. Design a concrete implementation strategy\n6. When ready, use ExitPlanMode to present your plan for approval\n\nRemember: DO NOT write or edit any files yet. This is a read-only exploration and planning phase.`\n },\n async *call(_input: z.infer<typeof inputSchema>, context: any) {\n if (context?.agentId) {\n throw new Error('EnterPlanMode tool cannot be used in agent contexts')\n }\n\n const wasAlreadyInPlanMode = isPlanModeEnabled(context)\n const { planFilePath } = enterPlanMode(context)\n\n if (wasAlreadyInPlanMode) {\n emitReminderEvent('plan:mode_reentry', { planPath: planFilePath })\n }\n emitReminderEvent('plan:file_reference', { planPath: planFilePath })\n\n const output: Output = {\n message:\n 'Entered plan mode. You should now focus on exploring the codebase and designing an implementation approach.',\n }\n yield {\n type: 'result',\n data: output,\n resultForAssistant: this.renderResultForAssistant(output),\n }\n },\n} satisfies Tool\n"],
5
+ "mappings": "AAMA,SAAS,KAAK,YAAY;AAC1B,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB,SAAS,eAAe,yBAAyB;AACjD,SAAS,yBAAyB;AAClC,SAAS,mBAAmB,cAAc,uBAAuB;AACjE,SAAS,uBAAuB;AAEhC,MAAM,cAAc,EAAE,aAAa,CAAC,CAAC;AAM9B,MAAM,oBAAoB;AAAA,EAC/B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAo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",
6
6
  "names": []
7
7
  }
@@ -6,6 +6,7 @@ import {
6
6
  getPlanFilePath,
7
7
  readPlanFile
8
8
  } from "../../utils/plan/planMode.js";
9
+ import { emitReminderEvent } from "../../services/systemReminder.js";
9
10
  import { EXIT_DESCRIPTION, EXIT_PROMPT, EXIT_TOOL_NAME } from "./prompt.js";
10
11
  import { SEMANTIC_COLORS } from "../../constants/colors.js";
11
12
  function getExitPlanModePlanText(conversationKey) {
@@ -90,6 +91,7 @@ ${output.plan}`;
90
91
  `No plan file found at ${planFilePath}. Please write your plan to this file before calling ExitPlanMode.`
91
92
  );
92
93
  }
94
+ emitReminderEvent("plan:exited", { planPath: planFilePath });
93
95
  const isAgent = !!context?.agentId;
94
96
  const output = {
95
97
  plan: content,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/tools/PlanModeTool/ExitPlanModeTool.tsx"],
4
- "sourcesContent": ["/**\n * Exit Plan Mode Tool\n *\n * Prompts the user to exit plan mode and start coding.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport {\n getPlanConversationKey,\n getPlanFilePath,\n readPlanFile,\n} from '@utils/plan/planMode'\nimport { EXIT_DESCRIPTION, EXIT_PROMPT, EXIT_TOOL_NAME } from './prompt'\nimport { SEMANTIC_COLORS } from '@constants/colors'\n\nfunction getExitPlanModePlanText(conversationKey?: string): string {\n const { content } = readPlanFile(undefined, conversationKey)\n return (\n content || 'No plan found. Please write your plan to the plan file first.'\n )\n}\n\nconst inputSchema = z.strictObject({}).passthrough()\n\ntype Output = {\n plan: string\n isAgent: boolean\n filePath?: string\n}\n\nexport const ExitPlanModeTool = {\n name: EXIT_TOOL_NAME,\n async description() {\n return EXIT_DESCRIPTION\n },\n userFacingName() {\n return ''\n },\n inputSchema,\n isReadOnly() {\n return false\n },\n isConcurrencySafe() {\n return true\n },\n async isEnabled() {\n return true\n },\n needsPermissions() {\n return true\n },\n requiresUserInteraction() {\n return true\n },\n async prompt() {\n return EXIT_PROMPT\n },\n renderToolUseMessage() {\n return ''\n },\n renderToolUseRejectedMessage(\n _input: z.infer<typeof inputSchema>,\n options: { conversationKey?: string } = {},\n ) {\n const conversationKey =\n typeof options.conversationKey === 'string' &&\n options.conversationKey.trim()\n ? options.conversationKey.trim()\n : undefined\n\n const plan = getExitPlanModePlanText(conversationKey)\n\n return (\n <Box flexDirection=\"column\" marginTop={1} width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Box flexDirection=\"column\" width=\"100%\">\n <Text color=\"red\">User rejected the plan:</Text>\n <Box\n borderStyle=\"round\"\n borderColor=\"cyan\"\n borderDimColor\n paddingX={1}\n overflow=\"hidden\"\n >\n <Text color={SEMANTIC_COLORS.dim}>{plan}</Text>\n </Box>\n </Box>\n </Box>\n </Box>\n )\n },\n renderToolResultMessage(output: Output) {\n if (!output) {\n return (\n <Box paddingLeft={2}>\n <Text>Plan mode completed</Text>\n </Box>\n )\n }\n\n const planPath =\n typeof output.filePath === 'string' ? output.filePath : null\n const plan = output.plan || 'No plan found'\n\n return (\n <Box flexDirection=\"column\" marginTop={1} width=\"100%\">\n <Box flexDirection=\"row\">\n <Text color=\"cyan\">\u25CF</Text>\n <Text> User approved the plan</Text>\n </Box>\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Box flexDirection=\"column\">\n {planPath ? (\n <Text color={SEMANTIC_COLORS.dim}>Plan saved to: {planPath}</Text>\n ) : null}\n <Text color={SEMANTIC_COLORS.dim}>{plan.substring(0, 200)}...</Text>\n </Box>\n </Box>\n </Box>\n )\n },\n renderResultForAssistant(output: Output) {\n if (!output) {\n return 'Plan mode completed'\n }\n\n if (output.isAgent) {\n return 'User has approved the plan. There is nothing else needed from you now. Please respond with \"ok\"'\n }\n\n return `User has approved your plan. You can now start coding. Start with updating your todo list if applicable\n\nYour plan has been saved to: ${output.filePath}\nYou can refer back to it if needed during implementation.\n\n## Approved Plan:\n${output.plan}`\n },\n async *call(input: z.infer<typeof inputSchema>, context: any) {\n const conversationKey = getPlanConversationKey(context)\n const planFilePath = getPlanFilePath(context?.agentId, conversationKey)\n const { content, exists } = readPlanFile(context?.agentId, conversationKey)\n\n if (!exists) {\n throw new Error(\n `No plan file found at ${planFilePath}. Please write your plan to this file before calling ExitPlanMode.`,\n )\n }\n\n const isAgent = !!context?.agentId\n const output: Output = {\n plan: content,\n isAgent,\n filePath: planFilePath,\n }\n yield {\n type: 'result',\n data: output,\n resultForAssistant: this.renderResultForAssistant(output),\n }\n },\n} satisfies Tool<typeof inputSchema, Output>\n"],
5
- "mappings": "AAMA,SAAS,KAAK,YAAY;AAC1B,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB,aAAa,sBAAsB;AAC9D,SAAS,uBAAuB;AAEhC,SAAS,wBAAwB,iBAAkC;AACjE,QAAM,EAAE,QAAQ,IAAI,aAAa,QAAW,eAAe;AAC3D,SACE,WAAW;AAEf;AAEA,MAAM,cAAc,EAAE,aAAa,CAAC,CAAC,EAAE,YAAY;AAQ5C,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,mBAAmB;AACjB,WAAO;AAAA,EACT;AAAA,EACA,0BAA0B;AACxB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,SAAS;AACb,WAAO;AAAA,EACT;AAAA,EACA,uBAAuB;AACrB,WAAO;AAAA,EACT;AAAA,EACA,6BACE,QACA,UAAwC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IACT;AAEA,QAAI,OAAO,SAAS;AAClB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,+BAEoB,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA,EAI5C,OAAO,IAAI;AAAA,EACX;AAAA,EACA,OAAO,KAAK,OAAoC,SAAc;AAC5D,UAAM,kBAAkB,uBAAuB,OAAO;AACtD,UAAM,eAAe,gBAAgB,SAAS,SAAS,eAAe;AACtE,UAAM,EAAE,SAAS,OAAO,IAAI,aAAa,SAAS,SAAS,eAAe;AAE1E,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR,yBAAyB,YAAY;AAAA,MACvC;AAAA,IACF;AAEA,UAAM,UAAU,CAAC,CAAC,SAAS;AAC3B,UAAM,SAAiB;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,UAAU;AAAA,IACZ;AACA,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,oBAAoB,KAAK,yBAAyB,MAAM;AAAA,IAC1D;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * Exit Plan Mode Tool\n *\n * Prompts the user to exit plan mode and start coding.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport {\n getPlanConversationKey,\n getPlanFilePath,\n readPlanFile,\n} from '@utils/plan/planMode'\nimport { emitReminderEvent } from '@services/systemReminder'\nimport { EXIT_DESCRIPTION, EXIT_PROMPT, EXIT_TOOL_NAME } from './prompt'\nimport { SEMANTIC_COLORS } from '@constants/colors'\n\nfunction getExitPlanModePlanText(conversationKey?: string): string {\n const { content } = readPlanFile(undefined, conversationKey)\n return (\n content || 'No plan found. Please write your plan to the plan file first.'\n )\n}\n\nconst inputSchema = z.strictObject({}).passthrough()\n\ntype Output = {\n plan: string\n isAgent: boolean\n filePath?: string\n}\n\nexport const ExitPlanModeTool = {\n name: EXIT_TOOL_NAME,\n async description() {\n return EXIT_DESCRIPTION\n },\n userFacingName() {\n return ''\n },\n inputSchema,\n isReadOnly() {\n return false\n },\n isConcurrencySafe() {\n return true\n },\n async isEnabled() {\n return true\n },\n needsPermissions() {\n return true\n },\n requiresUserInteraction() {\n return true\n },\n async prompt() {\n return EXIT_PROMPT\n },\n renderToolUseMessage() {\n return ''\n },\n renderToolUseRejectedMessage(\n _input: z.infer<typeof inputSchema>,\n options: { conversationKey?: string } = {},\n ) {\n const conversationKey =\n typeof options.conversationKey === 'string' &&\n options.conversationKey.trim()\n ? options.conversationKey.trim()\n : undefined\n\n const plan = getExitPlanModePlanText(conversationKey)\n\n return (\n <Box flexDirection=\"column\" marginTop={1} width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Box flexDirection=\"column\" width=\"100%\">\n <Text color=\"red\">User rejected the plan:</Text>\n <Box\n borderStyle=\"round\"\n borderColor=\"cyan\"\n borderDimColor\n paddingX={1}\n overflow=\"hidden\"\n >\n <Text color={SEMANTIC_COLORS.dim}>{plan}</Text>\n </Box>\n </Box>\n </Box>\n </Box>\n )\n },\n renderToolResultMessage(output: Output) {\n if (!output) {\n return (\n <Box paddingLeft={2}>\n <Text>Plan mode completed</Text>\n </Box>\n )\n }\n\n const planPath =\n typeof output.filePath === 'string' ? output.filePath : null\n const plan = output.plan || 'No plan found'\n\n return (\n <Box flexDirection=\"column\" marginTop={1} width=\"100%\">\n <Box flexDirection=\"row\">\n <Text color=\"cyan\">\u25CF</Text>\n <Text> User approved the plan</Text>\n </Box>\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Box flexDirection=\"column\">\n {planPath ? (\n <Text color={SEMANTIC_COLORS.dim}>Plan saved to: {planPath}</Text>\n ) : null}\n <Text color={SEMANTIC_COLORS.dim}>{plan.substring(0, 200)}...</Text>\n </Box>\n </Box>\n </Box>\n )\n },\n renderResultForAssistant(output: Output) {\n if (!output) {\n return 'Plan mode completed'\n }\n\n if (output.isAgent) {\n return 'User has approved the plan. There is nothing else needed from you now. Please respond with \"ok\"'\n }\n\n return `User has approved your plan. You can now start coding. Start with updating your todo list if applicable\n\nYour plan has been saved to: ${output.filePath}\nYou can refer back to it if needed during implementation.\n\n## Approved Plan:\n${output.plan}`\n },\n async *call(input: z.infer<typeof inputSchema>, context: any) {\n const conversationKey = getPlanConversationKey(context)\n const planFilePath = getPlanFilePath(context?.agentId, conversationKey)\n const { content, exists } = readPlanFile(context?.agentId, conversationKey)\n\n if (!exists) {\n throw new Error(\n `No plan file found at ${planFilePath}. Please write your plan to this file before calling ExitPlanMode.`,\n )\n }\n\n emitReminderEvent('plan:exited', { planPath: planFilePath })\n\n const isAgent = !!context?.agentId\n const output: Output = {\n plan: content,\n isAgent,\n filePath: planFilePath,\n }\n yield {\n type: 'result',\n data: output,\n resultForAssistant: this.renderResultForAssistant(output),\n }\n },\n} satisfies Tool\n"],
5
+ "mappings": "AAMA,SAAS,KAAK,YAAY;AAC1B,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,kBAAkB,aAAa,sBAAsB;AAC9D,SAAS,uBAAuB;AAEhC,SAAS,wBAAwB,iBAAkC;AACjE,QAAM,EAAE,QAAQ,IAAI,aAAa,QAAW,eAAe;AAC3D,SACE,WAAW;AAEf;AAEA,MAAM,cAAc,EAAE,aAAa,CAAC,CAAC,EAAE,YAAY;AAQ5C,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,mBAAmB;AACjB,WAAO;AAAA,E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AAK,OAAO,gBAAgB,OAAM,KAAK,UAAU,GAAG,GAAG,GAAE,KAAG,CAC/D,CACF,CACF;AAAA,EAEJ;AAAA,EACA,yBAAyB,QAAgB;AACvC,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,IACT;AAEA,QAAI,OAAO,SAAS;AAClB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,+BAEoB,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA,EAI5C,OAAO,IAAI;AAAA,EACX;AAAA,EACA,OAAO,KAAK,OAAoC,SAAc;AAC5D,UAAM,kBAAkB,uBAAuB,OAAO;AACtD,UAAM,eAAe,gBAAgB,SAAS,SAAS,eAAe;AACtE,UAAM,EAAE,SAAS,OAAO,IAAI,aAAa,SAAS,SAAS,eAAe;AAE1E,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR,yBAAyB,YAAY;AAAA,MACvC;AAAA,IACF;AAEA,sBAAkB,eAAe,EAAE,UAAU,aAAa,CAAC;AAE3D,UAAM,UAAU,CAAC,CAAC,SAAS;AAC3B,UAAM,SAAiB;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,UAAU;AAAA,IACZ;AACA,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,oBAAoB,KAAK,yBAAyB,MAAM;AAAA,IAC1D;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/tools/ReadMcpResourceTool/ReadMcpResourceTool.tsx"],
4
- "sourcesContent": ["import { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Cost } from '@components/Cost'\nimport { FallbackToolUseRejectedMessage } from '@components/FallbackToolUseRejectedMessage'\nimport { Tool } from '@tool'\nimport { readMCPResource, McpResourceContent } from '@services/mcpClient'\nimport { DESCRIPTION, TOOL_NAME_FOR_PROMPT } from './prompt'\nimport { getTheme } from '@utils/theme'\n\nconst inputSchema = z.strictObject({\n uri: z.string().describe('The URI of the resource to read'),\n server: z\n .string()\n .optional()\n .describe('Optional server name to target a specific MCP server'),\n})\n\ntype Output = {\n durationMs: number\n content: McpResourceContent | null\n error?: string\n}\n\nexport const ReadMcpResourceTool = {\n name: TOOL_NAME_FOR_PROMPT,\n async description() {\n return DESCRIPTION\n },\n userFacingName() {\n return 'Read MCP Resource'\n },\n inputSchema,\n async isEnabled() {\n return true\n },\n isReadOnly() {\n return true\n },\n isConcurrencySafe() {\n return true // Read-only operation, safe for concurrent execution\n },\n needsPermissions() {\n return false // No file system access needed\n },\n async prompt() {\n return DESCRIPTION\n },\n renderToolUseMessage({ uri, server }, { verbose }) {\n let msg = `uri: \"${uri}\"`\n if (server) {\n msg += `, server: \"${server}\"`\n }\n return msg\n },\n renderToolUseRejectedMessage() {\n return <FallbackToolUseRejectedMessage />\n },\n renderToolResultMessage(output) {\n if (!output) {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Text color={getTheme().error}>Failed to read resource</Text>\n </Box>\n </Box>\n )\n }\n\n // Handle string content for backward compatibility\n if (typeof output === 'string') {\n try {\n output = JSON.parse(output) as Output\n } catch {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;Read MCP resource</Text>\n </Box>\n </Box>\n )\n }\n }\n\n const durationMs = output?.durationMs ?? 0\n\n if (output?.error) {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Text color={getTheme().error}>{output.error}</Text>\n </Box>\n <Cost costUSD={0} durationMs={durationMs} debug={false} />\n </Box>\n )\n }\n\n if (!output?.content) {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Text color={getTheme().warning}>Resource not found</Text>\n </Box>\n <Cost costUSD={0} durationMs={durationMs} debug={false} />\n </Box>\n )\n }\n\n const contentType = output.content.mimeType || 'unknown'\n const hasText = !!output.content.text\n const hasBlob = !!output.content.blob\n\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;Read resource </Text>\n <Text color={getTheme().secondaryText}>\n ({contentType}, {hasText ? 'text' : hasBlob ? 'binary' : 'empty'})\n </Text>\n </Box>\n <Cost costUSD={0} durationMs={durationMs} debug={false} />\n </Box>\n )\n },\n async *call({ uri, server }) {\n const start = Date.now()\n\n try {\n const content = await readMCPResource(uri, server)\n const output: Output = {\n content,\n durationMs: Date.now() - start,\n }\n yield {\n type: 'result',\n resultForAssistant: this.renderResultForAssistant(output),\n data: output,\n }\n } catch (error) {\n const output: Output = {\n content: null,\n durationMs: Date.now() - start,\n error: error instanceof Error ? error.message : String(error),\n }\n yield {\n type: 'result',\n resultForAssistant: this.renderResultForAssistant(output),\n data: output,\n }\n }\n },\n renderResultForAssistant(output) {\n if (output.error) {\n return `Error reading resource: ${output.error}`\n }\n\n if (!output.content) {\n return 'Resource not found or not accessible'\n }\n\n const lines: string[] = []\n lines.push(`Resource: ${output.content.uri}`)\n\n if (output.content.mimeType) {\n lines.push(`MIME Type: ${output.content.mimeType}`)\n }\n\n lines.push('')\n\n if (output.content.text) {\n lines.push('Content:')\n lines.push(output.content.text)\n } else if (output.content.blob) {\n lines.push(\n `Binary content (base64, ${output.content.blob.length} characters)`,\n )\n // Only show first 200 chars of base64 for preview\n if (output.content.blob.length > 200) {\n lines.push(output.content.blob.substring(0, 200) + '...')\n } else {\n lines.push(output.content.blob)\n }\n } else {\n lines.push('(Empty content)')\n }\n\n return lines.join('\\n')\n },\n} satisfies Tool<typeof inputSchema, Output>\n"],
4
+ "sourcesContent": ["import { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Cost } from '@components/Cost'\nimport { FallbackToolUseRejectedMessage } from '@components/FallbackToolUseRejectedMessage'\nimport { Tool } from '@tool'\nimport { readMCPResource, McpResourceContent } from '@services/mcpClient'\nimport { DESCRIPTION, TOOL_NAME_FOR_PROMPT } from './prompt'\nimport { getTheme } from '@utils/theme'\n\nconst inputSchema = z.strictObject({\n uri: z.string().describe('The URI of the resource to read'),\n server: z\n .string()\n .optional()\n .describe('Optional server name to target a specific MCP server'),\n})\n\ntype Output = {\n durationMs: number\n content: McpResourceContent | null\n error?: string\n}\n\nexport const ReadMcpResourceTool = {\n name: TOOL_NAME_FOR_PROMPT,\n async description() {\n return DESCRIPTION\n },\n userFacingName() {\n return 'Read MCP Resource'\n },\n inputSchema,\n async isEnabled() {\n return true\n },\n isReadOnly() {\n return true\n },\n isConcurrencySafe() {\n return true // Read-only operation, safe for concurrent execution\n },\n needsPermissions() {\n return false // No file system access needed\n },\n async prompt() {\n return DESCRIPTION\n },\n renderToolUseMessage({ uri, server }, { verbose }) {\n let msg = `uri: \"${uri}\"`\n if (server) {\n msg += `, server: \"${server}\"`\n }\n return msg\n },\n renderToolUseRejectedMessage() {\n return <FallbackToolUseRejectedMessage />\n },\n renderToolResultMessage(output) {\n if (!output) {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Text color={getTheme().error}>Failed to read resource</Text>\n </Box>\n </Box>\n )\n }\n\n // Handle string content for backward compatibility\n if (typeof output === 'string') {\n try {\n output = JSON.parse(output) as Output\n } catch {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;Read MCP resource</Text>\n </Box>\n </Box>\n )\n }\n }\n\n const durationMs = output?.durationMs ?? 0\n\n if (output?.error) {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Text color={getTheme().error}>{output.error}</Text>\n </Box>\n <Cost costUSD={0} durationMs={durationMs} debug={false} />\n </Box>\n )\n }\n\n if (!output?.content) {\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;</Text>\n <Text color={getTheme().warning}>Resource not found</Text>\n </Box>\n <Cost costUSD={0} durationMs={durationMs} debug={false} />\n </Box>\n )\n }\n\n const contentType = output.content.mimeType || 'unknown'\n const hasText = !!output.content.text\n const hasBlob = !!output.content.blob\n\n return (\n <Box justifyContent=\"space-between\" width=\"100%\">\n <Box flexDirection=\"row\">\n <Text>&nbsp;&nbsp;\u23BF &nbsp;Read resource </Text>\n <Text color={getTheme().secondaryText}>\n ({contentType}, {hasText ? 'text' : hasBlob ? 'binary' : 'empty'})\n </Text>\n </Box>\n <Cost costUSD={0} durationMs={durationMs} debug={false} />\n </Box>\n )\n },\n async *call({ uri, server }) {\n const start = Date.now()\n\n try {\n const content = await readMCPResource(uri, server)\n const output: Output = {\n content,\n durationMs: Date.now() - start,\n }\n yield {\n type: 'result',\n resultForAssistant: this.renderResultForAssistant(output),\n data: output,\n }\n } catch (error) {\n const output: Output = {\n content: null,\n durationMs: Date.now() - start,\n error: error instanceof Error ? error.message : String(error),\n }\n yield {\n type: 'result',\n resultForAssistant: this.renderResultForAssistant(output),\n data: output,\n }\n }\n },\n renderResultForAssistant(output) {\n if (output.error) {\n return `Error reading resource: ${output.error}`\n }\n\n if (!output.content) {\n return 'Resource not found or not accessible'\n }\n\n const lines: string[] = []\n lines.push(`Resource: ${output.content.uri}`)\n\n if (output.content.mimeType) {\n lines.push(`MIME Type: ${output.content.mimeType}`)\n }\n\n lines.push('')\n\n if (output.content.text) {\n lines.push('Content:')\n lines.push(output.content.text)\n } else if (output.content.blob) {\n lines.push(\n `Binary content (base64, ${output.content.blob.length} characters)`,\n )\n // Only show first 200 chars of base64 for preview\n if (output.content.blob.length > 200) {\n lines.push(output.content.blob.substring(0, 200) + '...')\n } else {\n lines.push(output.content.blob)\n }\n } else {\n lines.push('(Empty content)')\n }\n\n return lines.join('\\n')\n },\n} satisfies Tool\n"],
5
5
  "mappings": "AAAA,SAAS,KAAK,YAAY;AAC1B,OAAO,WAAW;AAClB,SAAS,SAAS;AAClB,SAAS,YAAY;AACrB,SAAS,sCAAsC;AAE/C,SAAS,uBAA2C;AACpD,SAAS,aAAa,4BAA4B;AAClD,SAAS,gBAAgB;AAEzB,MAAM,cAAc,EAAE,aAAa;AAAA,EACjC,KAAK,EAAE,OAAO,EAAE,SAAS,iCAAiC;AAAA,EAC1D,QAAQ,EACL,OAAO,EACP,SAAS,EACT,SAAS,sDAAsD;AACpE,CAAC;AAQM,MAAM,sBAAsB;AAAA,EACjC,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EACA,mBAAmB;AACjB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,SAAS;AACb,WAAO;AAAA,EACT;AAAA,EACA,qBAAqB,EAAE,KAAK,OAAO,GAAG,EAAE,QAAQ,GAAG;AACjD,QAAI,MAAM,SAAS,GAAG;AACtB,QAAI,QAAQ;AACV,aAAO,cAAc,MAAM;AAAA,IAC7B;AACA,WAAO;AAAA,EACT;AAAA,EACA,+BAA+B;AAC7B,WAAO,oCAAC,oCAA+B;AAAA,EACzC;AAAA,EACA,wBAAwB,QAAQ;AAC9B,QAAI,CAAC,QAAQ;AACX,aACE,oCAAC,OAAI,gBAAe,iBAAgB,OAAM,UACxC,oCAAC,OAAI,eAAc,SACjB,oCAAC,YAAK,qBAAoB,GAC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,KAAK,UAAU,GAAG,GAAG,IAAI,KAAK;AAAA,MAC1D,OAAO;AACL,cAAM,KAAK,OAAO,QAAQ,IAAI;AAAA,MAChC;AAAA,IACF,OAAO;AACL,YAAM,KAAK,iBAAiB;AAAA,IAC9B;AAEA,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { dirname } from "path";
2
3
  import { FallbackToolUseRejectedMessage } from "../../components/FallbackToolUseRejectedMessage.js";
3
4
  import * as React from "react";
4
5
  import { createUserMessage } from "../../utils/messages.js";
@@ -6,12 +7,39 @@ import { getCommands } from "../../commands.js";
6
7
  import {
7
8
  loadCustomCommands
8
9
  } from "../../services/customCommands.js";
10
+ import {
11
+ getAllSkillEntries,
12
+ getSkill,
13
+ loadSkillContent
14
+ } from "../../utils/skillLoader.js";
15
+ import { substituteVariables } from "../../utils/stringSubstitution.js";
16
+ import { getCwd } from "../../utils/state.js";
17
+ import { getHookManager } from "../../utils/hookManager.js";
18
+ import { emitReminderEvent } from "../../services/systemReminder.js";
9
19
  import { TOOL_NAME_FOR_PROMPT } from "./prompt.js";
10
20
  import { Box, Text } from "ink";
11
21
  const inputSchema = z.strictObject({
12
22
  skill: z.string().describe('The skill name. E.g., "commit", "review-pr", or "pdf"'),
13
23
  args: z.string().optional().describe("Optional arguments for the skill")
14
24
  });
25
+ function buildSkillHooks(skill) {
26
+ if (!skill.config.hooks?.length) return [];
27
+ return skill.config.hooks.map((h, i) => ({
28
+ name: `skill:${skill.name}:${h.event}:${i}`,
29
+ filePath: skill.filePath,
30
+ config: {
31
+ event: h.event,
32
+ matcher: h.matcher,
33
+ type: h.type || "command",
34
+ command: h.command,
35
+ prompt: h.prompt,
36
+ timeout: h.timeout
37
+ },
38
+ pluginName: `skill:${skill.name}`,
39
+ event: h.event,
40
+ matcher: h.matcher
41
+ }));
42
+ }
15
43
  function normalizeCommandModelName(model) {
16
44
  if (typeof model !== "string") return void 0;
17
45
  const trimmed = model.trim();
@@ -25,6 +53,60 @@ function getCharBudget() {
25
53
  const raw = Number(process.env.SLASH_COMMAND_TOOL_CHAR_BUDGET);
26
54
  return Number.isFinite(raw) && raw > 0 ? raw : 15e3;
27
55
  }
56
+ function formatCommandLine(cmd) {
57
+ const name = `/${cmd.name}`;
58
+ const args = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
59
+ const whenToUse = cmd.whenToUse ? `- ${cmd.whenToUse}` : "";
60
+ return `- ${name}${args}: ${cmd.description} ${whenToUse}`.trim();
61
+ }
62
+ function formatSkillLine(skill, key) {
63
+ const name = `/${key}`;
64
+ const args = skill.config.argumentHint ? ` ${skill.config.argumentHint}` : "";
65
+ return `- ${name}${args}: ${skill.config.description}`.trim();
66
+ }
67
+ async function convertSkillToCommand(skill) {
68
+ const content = await loadSkillContent(skill);
69
+ const baseDir = dirname(skill.filePath);
70
+ return {
71
+ type: "prompt",
72
+ name: skill.name,
73
+ description: skill.config.description,
74
+ isEnabled: true,
75
+ isHidden: false,
76
+ aliases: [],
77
+ progressMessage: `Running ${skill.name}...`,
78
+ scope: skill.source === "user" ? "user" : "project",
79
+ allowedTools: skill.config.allowedTools,
80
+ model: skill.config.model,
81
+ disableModelInvocation: skill.config.disableModelInvocation,
82
+ argumentHint: skill.config.argumentHint,
83
+ userFacingName: () => skill.name,
84
+ async getPromptForCommand(args) {
85
+ let prompt = content;
86
+ prompt = prompt.replace(/\{baseDir\}/g, baseDir);
87
+ prompt = await substituteVariables(prompt, args || "", {
88
+ cwd: getCwd(),
89
+ env: { BASE_DIR: baseDir },
90
+ allowDynamicCommands: true
91
+ });
92
+ if (args.trim() && !content.includes("$ARGUMENTS") && !content.includes("$0")) {
93
+ prompt += `
94
+
95
+ Additional context: ${args}`;
96
+ }
97
+ return [{ role: "user", content: prompt }];
98
+ }
99
+ };
100
+ }
101
+ async function resolveSkillOrCommand(skillName, commands) {
102
+ const cmd = findCommand(skillName, commands);
103
+ if (cmd) return cmd;
104
+ const skillObj = getSkill(skillName);
105
+ if (skillObj) {
106
+ return convertSkillToCommand(skillObj);
107
+ }
108
+ return null;
109
+ }
28
110
  const SlashCommandTool = {
29
111
  name: TOOL_NAME_FOR_PROMPT,
30
112
  async description(input) {
@@ -48,29 +130,41 @@ const SlashCommandTool = {
48
130
  return true;
49
131
  },
50
132
  async prompt() {
51
- const all = await loadCustomCommands();
133
+ const [all, allSkillEntries] = await Promise.all([
134
+ loadCustomCommands(),
135
+ Promise.resolve(getAllSkillEntries())
136
+ ]);
52
137
  const commands = all.filter(
53
138
  (cmd) => cmd.type === "prompt" && cmd.isSkill !== true && cmd.disableModelInvocation !== true
54
139
  );
55
- const limited = [];
140
+ const commandBaseNames = new Set(
141
+ commands.map((c) => c.name.replace(/^(user|project|plugin:[^:]+):/, ""))
142
+ );
143
+ const skillEntries = allSkillEntries.filter(
144
+ ([key, skill]) => !commandBaseNames.has(skill.name) && skill.config.disableModelInvocation !== true && skill.config.userInvocable !== false
145
+ );
146
+ const budget = getCharBudget();
147
+ const lines = [];
56
148
  let used = 0;
149
+ let totalCount = commands.length + skillEntries.length;
150
+ let includedCount = 0;
57
151
  for (const cmd of commands) {
58
- const name = `/${cmd.name}`;
59
- const args = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
60
- const whenToUse = cmd.whenToUse ? `- ${cmd.whenToUse}` : "";
61
- const line = `- ${name}${args}: ${cmd.description} ${whenToUse}`.trim();
152
+ const line = formatCommandLine(cmd);
153
+ if (used + line.length + 1 > budget) break;
154
+ lines.push(line);
155
+ used += line.length + 1;
156
+ includedCount++;
157
+ }
158
+ for (const [key, skill] of skillEntries) {
159
+ const line = formatSkillLine(skill, key);
160
+ if (used + line.length + 1 > budget) break;
161
+ lines.push(line);
62
162
  used += line.length + 1;
63
- if (used > getCharBudget()) break;
64
- limited.push(cmd);
163
+ includedCount++;
65
164
  }
66
- const availableLines = limited.length > 0 ? limited.map((cmd) => {
67
- const name = `/${cmd.name}`;
68
- const args = cmd.argumentHint ? ` ${cmd.argumentHint}` : "";
69
- const whenToUse = cmd.whenToUse ? `- ${cmd.whenToUse}` : "";
70
- return `- ${name}${args}: ${cmd.description} ${whenToUse}`.trim();
71
- }).join("\n") : "";
72
- const truncatedNotice = commands.length > limited.length ? `
73
- (Showing ${limited.length} of ${commands.length} commands due to token limits)` : "";
165
+ const availableLines = lines.length > 0 ? lines.join("\n") : "";
166
+ const truncatedNotice = totalCount > includedCount ? `
167
+ (Showing ${includedCount} of ${totalCount} skills due to token limits)` : "";
74
168
  return `Execute a skill within the main conversation
75
169
 
76
170
  <skills_instructions>
@@ -130,7 +224,7 @@ ${availableLines}${truncatedNotice}
130
224
  };
131
225
  }
132
226
  const commands = context?.options?.commands ?? await getCommands();
133
- const cmd = findCommand(parsed.skillName, commands);
227
+ const cmd = await resolveSkillOrCommand(parsed.skillName, commands);
134
228
  if (!cmd) {
135
229
  return {
136
230
  result: false,
@@ -167,7 +261,7 @@ ${availableLines}${truncatedNotice}
167
261
  throw new Error(`Invalid skill name: ${skill}`);
168
262
  }
169
263
  const commands = context.options?.commands ?? await getCommands();
170
- const cmd = findCommand(parsed.skillName, commands);
264
+ const cmd = await resolveSkillOrCommand(parsed.skillName, commands);
171
265
  if (!cmd) {
172
266
  throw new Error(`Unknown skill: ${parsed.skillName}`);
173
267
  }
@@ -186,6 +280,59 @@ ${availableLines}${truncatedNotice}
186
280
  `Unexpected ${cmd.type} command. Expected 'prompt' command. Use /${parsed.skillName} directly in the main conversation.`
187
281
  );
188
282
  }
283
+ const skillObj = getSkill(parsed.skillName);
284
+ if (skillObj?.config.context === "fork") {
285
+ const content = await loadSkillContent(skillObj);
286
+ const baseDir = dirname(skillObj.filePath);
287
+ let forkPrompt = content.replace(/\{baseDir\}/g, baseDir);
288
+ forkPrompt = await substituteVariables(forkPrompt, args || "", {
289
+ cwd: getCwd(),
290
+ env: { BASE_DIR: baseDir },
291
+ allowDynamicCommands: true
292
+ });
293
+ if (args?.trim() && !content.includes("$ARGUMENTS") && !content.includes("$0")) {
294
+ forkPrompt += `
295
+
296
+ Additional context: ${args}`;
297
+ }
298
+ const forkAgentType = skillObj.config.agent || "general-purpose";
299
+ const forkModel = normalizeCommandModelName(skillObj.config.model);
300
+ const output2 = { success: true, skillName: parsed.skillName };
301
+ const forkInstruction = `This skill runs in fork mode. You MUST immediately call the Task tool with:
302
+ - description: "Skill: ${parsed.skillName}"
303
+ - subagent_type: "${forkAgentType}"
304
+ ` + (forkModel ? `- model: "${forkModel}"
305
+ ` : "") + `- prompt: The full skill content below
306
+
307
+ <skill-content>
308
+ ${forkPrompt}
309
+ </skill-content>`;
310
+ yield {
311
+ type: "result",
312
+ data: output2,
313
+ resultForAssistant: this.renderResultForAssistant(output2),
314
+ newMessages: [
315
+ createUserMessage(
316
+ `<command-name>${parsed.skillName}</command-name>
317
+ <command-message>${parsed.skillName} is running in fork mode\u2026</command-message>`
318
+ ),
319
+ createUserMessage(forkInstruction)
320
+ ]
321
+ };
322
+ return;
323
+ }
324
+ let cleanupSkillHooks;
325
+ const resolvedSkill = getSkill(parsed.skillName);
326
+ if (resolvedSkill?.config.hooks?.length) {
327
+ const hookMgr = getHookManager();
328
+ if (hookMgr) {
329
+ const skillHooks = buildSkillHooks(resolvedSkill);
330
+ if (skillHooks.length > 0) {
331
+ cleanupSkillHooks = hookMgr.addHooks(skillHooks);
332
+ }
333
+ }
334
+ }
335
+ emitReminderEvent("skill:invoked", { skillName: parsed.skillName });
189
336
  const combinedArgs = args || "";
190
337
  const prompt = await cmd.getPromptForCommand(combinedArgs);
191
338
  const expandedMessages = prompt.map((msg) => {
@@ -209,6 +356,7 @@ ${availableLines}${truncatedNotice}
209
356
  const model = normalizeCommandModelName(cmd.model);
210
357
  const maxThinkingTokens = typeof cmd.maxThinkingTokens === "number" ? cmd.maxThinkingTokens : void 0;
211
358
  const output = { success: true, skillName: parsed.skillName };
359
+ const _cleanupRef = cleanupSkillHooks;
212
360
  yield {
213
361
  type: "result",
214
362
  data: output,
@@ -241,12 +389,20 @@ ${availableLines}${truncatedNotice}
241
389
  }
242
390
  } : void 0
243
391
  };
392
+ if (_cleanupRef) _cleanupRef();
244
393
  }
245
394
  };
246
395
  function parseSkillName(skill) {
247
396
  const trimmed = skill.trim();
248
397
  const withoutSlash = trimmed.startsWith("/") ? trimmed.slice(1) : trimmed;
249
398
  if (!withoutSlash) return null;
399
+ if (withoutSlash.includes(":")) {
400
+ const colonIdx = withoutSlash.indexOf(":");
401
+ const pluginName = withoutSlash.slice(0, colonIdx);
402
+ const skillPart = withoutSlash.slice(colonIdx + 1);
403
+ if (!pluginName || !skillPart) return null;
404
+ return { skillName: withoutSlash, pluginName };
405
+ }
250
406
  return { skillName: withoutSlash };
251
407
  }
252
408
  function findCommand(skillName, commands) {