@within-7/minto 0.1.6 → 0.2.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 (487) hide show
  1. package/cli.js +155 -37
  2. package/dist/Tool.js +38 -0
  3. package/dist/Tool.js.map +3 -3
  4. package/dist/commands/agents/AgentsCommand.js +52 -26
  5. package/dist/commands/agents/AgentsCommand.js.map +2 -2
  6. package/dist/commands/agents/constants.js +1 -1
  7. package/dist/commands/agents/constants.js.map +1 -1
  8. package/dist/commands/agents/index.js +1 -1
  9. package/dist/commands/bug.js +74 -7
  10. package/dist/commands/bug.js.map +3 -3
  11. package/dist/commands/clear.js +3 -0
  12. package/dist/commands/clear.js.map +2 -2
  13. package/dist/commands/compact.js +37 -0
  14. package/dist/commands/compact.js.map +2 -2
  15. package/dist/commands/context.js +84 -0
  16. package/dist/commands/context.js.map +7 -0
  17. package/dist/commands/ctx_viz.js +18 -10
  18. package/dist/commands/ctx_viz.js.map +2 -2
  19. package/dist/commands/doctor.js +158 -12
  20. package/dist/commands/doctor.js.map +2 -2
  21. package/dist/commands/export.js +156 -0
  22. package/dist/commands/export.js.map +7 -0
  23. package/dist/commands/mcp-interactive.js +21 -12
  24. package/dist/commands/mcp-interactive.js.map +2 -2
  25. package/dist/commands/model.js +6 -5
  26. package/dist/commands/model.js.map +2 -2
  27. package/dist/commands/permissions.js +86 -0
  28. package/dist/commands/permissions.js.map +7 -0
  29. package/dist/commands/quit.js +3 -1
  30. package/dist/commands/quit.js.map +2 -2
  31. package/dist/commands/sandbox.js +104 -0
  32. package/dist/commands/sandbox.js.map +7 -0
  33. package/dist/commands/status.js +58 -0
  34. package/dist/commands/status.js.map +7 -0
  35. package/dist/commands/tasks.js +108 -0
  36. package/dist/commands/tasks.js.map +7 -0
  37. package/dist/commands/todos.js +123 -0
  38. package/dist/commands/todos.js.map +7 -0
  39. package/dist/commands.js +20 -2
  40. package/dist/commands.js.map +2 -2
  41. package/dist/components/AgentThinkingBlock.js +10 -18
  42. package/dist/components/AgentThinkingBlock.js.map +2 -2
  43. package/dist/components/BackgroundTasksPanel.js +78 -29
  44. package/dist/components/BackgroundTasksPanel.js.map +2 -2
  45. package/dist/components/BashStreamingProgress.js +24 -0
  46. package/dist/components/BashStreamingProgress.js.map +7 -0
  47. package/dist/components/CollapsibleHint.js +14 -0
  48. package/dist/components/CollapsibleHint.js.map +7 -0
  49. package/dist/components/FileEditToolUpdatedMessage.js +1 -1
  50. package/dist/components/FileEditToolUpdatedMessage.js.map +2 -2
  51. package/dist/components/HotkeyHelpPanel.js +137 -0
  52. package/dist/components/HotkeyHelpPanel.js.map +7 -0
  53. package/dist/components/Logo.js +5 -5
  54. package/dist/components/Logo.js.map +2 -2
  55. package/dist/components/Message.js +23 -7
  56. package/dist/components/Message.js.map +3 -3
  57. package/dist/components/ModelConfig.js +16 -3
  58. package/dist/components/ModelConfig.js.map +2 -2
  59. package/dist/components/ModelListManager.js +3 -3
  60. package/dist/components/ModelListManager.js.map +2 -2
  61. package/dist/components/ModelSelector/ModelSelector.js +1 -1
  62. package/dist/components/Onboarding.js +19 -14
  63. package/dist/components/Onboarding.js.map +2 -2
  64. package/dist/components/ProgressBar.js +74 -0
  65. package/dist/components/ProgressBar.js.map +7 -0
  66. package/dist/components/PromptInput.js +156 -46
  67. package/dist/components/PromptInput.js.map +2 -2
  68. package/dist/components/RequestStatusIndicator.js +194 -0
  69. package/dist/components/RequestStatusIndicator.js.map +7 -0
  70. package/dist/components/Spinner.js +92 -27
  71. package/dist/components/Spinner.js.map +2 -2
  72. package/dist/components/SpinnerSymbol.js +21 -27
  73. package/dist/components/SpinnerSymbol.js.map +2 -2
  74. package/dist/components/StreamingBashOutput.js +9 -8
  75. package/dist/components/StreamingBashOutput.js.map +2 -2
  76. package/dist/components/SubagentBlock.js +1 -1
  77. package/dist/components/SubagentBlock.js.map +1 -1
  78. package/dist/components/SubagentProgress.js +10 -11
  79. package/dist/components/SubagentProgress.js.map +2 -2
  80. package/dist/components/TaskCard.js +16 -13
  81. package/dist/components/TaskCard.js.map +2 -2
  82. package/dist/components/TodoChangeBlock.js +1 -1
  83. package/dist/components/TodoChangeBlock.js.map +2 -2
  84. package/dist/components/TodoPanel.js +120 -29
  85. package/dist/components/TodoPanel.js.map +3 -3
  86. package/dist/components/TokenCounter.js +74 -0
  87. package/dist/components/TokenCounter.js.map +7 -0
  88. package/dist/components/TokenWarning.js +2 -1
  89. package/dist/components/TokenWarning.js.map +2 -2
  90. package/dist/components/TreeConnector.js +25 -0
  91. package/dist/components/TreeConnector.js.map +7 -0
  92. package/dist/components/TurnCompletionIndicator.js +18 -0
  93. package/dist/components/TurnCompletionIndicator.js.map +7 -0
  94. package/dist/components/messages/AssistantTextMessage.js +5 -2
  95. package/dist/components/messages/AssistantTextMessage.js.map +2 -2
  96. package/dist/components/messages/AssistantThinkingMessage.js +18 -3
  97. package/dist/components/messages/AssistantThinkingMessage.js.map +2 -2
  98. package/dist/components/messages/AssistantToolUseMessage.js +11 -8
  99. package/dist/components/messages/AssistantToolUseMessage.js.map +2 -2
  100. package/dist/components/messages/GroupRenderer.js +53 -0
  101. package/dist/components/messages/GroupRenderer.js.map +7 -0
  102. package/dist/components/messages/NestedTasksPreview.js +12 -0
  103. package/dist/components/messages/NestedTasksPreview.js.map +7 -0
  104. package/dist/components/messages/ParallelTasksGroupView.js +92 -0
  105. package/dist/components/messages/ParallelTasksGroupView.js.map +7 -0
  106. package/dist/components/messages/TaskInModuleView.js +198 -0
  107. package/dist/components/messages/TaskInModuleView.js.map +7 -0
  108. package/dist/components/messages/TaskOutputContent.js +53 -0
  109. package/dist/components/messages/TaskOutputContent.js.map +7 -0
  110. package/dist/components/messages/UserPromptMessage.js +1 -1
  111. package/dist/components/messages/UserPromptMessage.js.map +2 -2
  112. package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js +2 -3
  113. package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js.map +2 -2
  114. package/dist/components/permissions/FallbackPermissionRequest.js +4 -4
  115. package/dist/components/permissions/FallbackPermissionRequest.js.map +2 -2
  116. package/dist/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +4 -4
  117. package/dist/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js.map +2 -2
  118. package/dist/constants/colors.js +48 -0
  119. package/dist/constants/colors.js.map +2 -2
  120. package/dist/constants/formatRules.js +102 -0
  121. package/dist/constants/formatRules.js.map +7 -0
  122. package/dist/constants/prompts.js +12 -34
  123. package/dist/constants/prompts.js.map +2 -2
  124. package/dist/constants/symbols.js +64 -6
  125. package/dist/constants/symbols.js.map +2 -2
  126. package/dist/constants/timing.js +5 -0
  127. package/dist/constants/timing.js.map +2 -2
  128. package/dist/core/config/defaults.js +84 -0
  129. package/dist/core/config/defaults.js.map +7 -0
  130. package/dist/core/config/index.js +111 -0
  131. package/dist/core/config/index.js.map +7 -0
  132. package/dist/core/config/loader.js +221 -0
  133. package/dist/core/config/loader.js.map +7 -0
  134. package/dist/core/config/migrations.js +128 -0
  135. package/dist/core/config/migrations.js.map +7 -0
  136. package/dist/core/config/schema.js +178 -0
  137. package/dist/core/config/schema.js.map +7 -0
  138. package/dist/core/costTracker.js +138 -0
  139. package/dist/core/costTracker.js.map +7 -0
  140. package/dist/core/index.js +5 -0
  141. package/dist/core/index.js.map +7 -0
  142. package/dist/core/permissions/auditLog.js +204 -0
  143. package/dist/core/permissions/auditLog.js.map +7 -0
  144. package/dist/core/permissions/engine/index.js +3 -0
  145. package/dist/core/permissions/engine/index.js.map +7 -0
  146. package/dist/core/permissions/engine/permissionEngine.js +106 -0
  147. package/dist/core/permissions/engine/permissionEngine.js.map +7 -0
  148. package/dist/core/permissions/engine/types.js +1 -0
  149. package/dist/core/permissions/engine/types.js.map +7 -0
  150. package/dist/core/permissions/index.js +84 -0
  151. package/dist/core/permissions/index.js.map +7 -0
  152. package/dist/core/permissions/ruleEngine.js +259 -0
  153. package/dist/core/permissions/ruleEngine.js.map +7 -0
  154. package/dist/core/permissions/rules/allowedToolsRule.js +62 -0
  155. package/dist/core/permissions/rules/allowedToolsRule.js.map +7 -0
  156. package/dist/core/permissions/rules/autoEscalationRule.js +291 -0
  157. package/dist/core/permissions/rules/autoEscalationRule.js.map +7 -0
  158. package/dist/core/permissions/rules/index.js +46 -0
  159. package/dist/core/permissions/rules/index.js.map +7 -0
  160. package/dist/core/permissions/rules/planModeRule.js +55 -0
  161. package/dist/core/permissions/rules/planModeRule.js.map +7 -0
  162. package/dist/core/permissions/rules/projectBoundaryRule.js +168 -0
  163. package/dist/core/permissions/rules/projectBoundaryRule.js.map +7 -0
  164. package/dist/core/permissions/rules/safeModeRule.js +65 -0
  165. package/dist/core/permissions/rules/safeModeRule.js.map +7 -0
  166. package/dist/core/permissions/rules/sensitivePathsRule.js +340 -0
  167. package/dist/core/permissions/rules/sensitivePathsRule.js.map +7 -0
  168. package/dist/core/permissions/types.js +127 -0
  169. package/dist/core/permissions/types.js.map +7 -0
  170. package/dist/core/tools/executor.js +143 -0
  171. package/dist/core/tools/executor.js.map +7 -0
  172. package/dist/core/tools/index.js +15 -0
  173. package/dist/core/tools/index.js.map +7 -0
  174. package/dist/core/tools/registry.js +183 -0
  175. package/dist/core/tools/registry.js.map +7 -0
  176. package/dist/core/tools/types.js +1 -0
  177. package/dist/core/tools/types.js.map +7 -0
  178. package/dist/cost-tracker.js +23 -15
  179. package/dist/cost-tracker.js.map +2 -2
  180. package/dist/entrypoints/cli.js +43 -43
  181. package/dist/entrypoints/cli.js.map +2 -2
  182. package/dist/entrypoints/mcp.js +12 -4
  183. package/dist/entrypoints/mcp.js.map +2 -2
  184. package/dist/history.js +14 -3
  185. package/dist/history.js.map +2 -2
  186. package/dist/hooks/useAgentTranscripts.js +116 -0
  187. package/dist/hooks/useAgentTranscripts.js.map +7 -0
  188. package/dist/hooks/useAnimationSync.js +53 -0
  189. package/dist/hooks/useAnimationSync.js.map +7 -0
  190. package/dist/hooks/useArrowKeyHistory.js +4 -2
  191. package/dist/hooks/useArrowKeyHistory.js.map +2 -2
  192. package/dist/hooks/useCanUseTool.js +3 -1
  193. package/dist/hooks/useCanUseTool.js.map +2 -2
  194. package/dist/hooks/useCancelRequest.js +4 -1
  195. package/dist/hooks/useCancelRequest.js.map +2 -2
  196. package/dist/hooks/useExitOnCtrlCD.js +9 -5
  197. package/dist/hooks/useExitOnCtrlCD.js.map +2 -2
  198. package/dist/hooks/useHookStatus.js +40 -0
  199. package/dist/hooks/useHookStatus.js.map +7 -0
  200. package/dist/hooks/useLogMessages.js +17 -1
  201. package/dist/hooks/useLogMessages.js.map +2 -2
  202. package/dist/hooks/useMessageGroups.js +43 -0
  203. package/dist/hooks/useMessageGroups.js.map +7 -0
  204. package/dist/hooks/useTerminalSize.js +62 -6
  205. package/dist/hooks/useTerminalSize.js.map +2 -2
  206. package/dist/hooks/useUnifiedCompletion.js +69 -0
  207. package/dist/hooks/useUnifiedCompletion.js.map +2 -2
  208. package/dist/i18n/index.js +109 -0
  209. package/dist/i18n/index.js.map +7 -0
  210. package/dist/i18n/locales/en.js +347 -0
  211. package/dist/i18n/locales/en.js.map +7 -0
  212. package/dist/i18n/locales/index.js +7 -0
  213. package/dist/i18n/locales/index.js.map +7 -0
  214. package/dist/i18n/locales/zh-CN.js +347 -0
  215. package/dist/i18n/locales/zh-CN.js.map +7 -0
  216. package/dist/i18n/types.js +8 -0
  217. package/dist/i18n/types.js.map +7 -0
  218. package/dist/query.js +175 -17
  219. package/dist/query.js.map +3 -3
  220. package/dist/screens/REPL.js +501 -192
  221. package/dist/screens/REPL.js.map +3 -3
  222. package/dist/services/adapters/chatCompletions.js +3 -1
  223. package/dist/services/adapters/chatCompletions.js.map +2 -2
  224. package/dist/services/adapters/messageNormalizer.js +354 -0
  225. package/dist/services/adapters/messageNormalizer.js.map +7 -0
  226. package/dist/services/adapters/responsesAPI.js +6 -3
  227. package/dist/services/adapters/responsesAPI.js.map +2 -2
  228. package/dist/services/checkpointManager.js +386 -0
  229. package/dist/services/checkpointManager.js.map +7 -0
  230. package/dist/services/claude.js +138 -11
  231. package/dist/services/claude.js.map +3 -3
  232. package/dist/services/compressionService.js +50 -1
  233. package/dist/services/compressionService.js.map +2 -2
  234. package/dist/services/contextMonitor.js +162 -0
  235. package/dist/services/contextMonitor.js.map +7 -0
  236. package/dist/services/customCommands.js +60 -41
  237. package/dist/services/customCommands.js.map +2 -2
  238. package/dist/services/hookExecutor.js +173 -1
  239. package/dist/services/hookExecutor.js.map +2 -2
  240. package/dist/services/intelligentCompactor.js +281 -0
  241. package/dist/services/intelligentCompactor.js.map +7 -0
  242. package/dist/services/lspConfig.js +109 -0
  243. package/dist/services/lspConfig.js.map +7 -0
  244. package/dist/services/mcpClient.js +273 -34
  245. package/dist/services/mcpClient.js.map +2 -2
  246. package/dist/services/modelOrchestrator.js +310 -0
  247. package/dist/services/modelOrchestrator.js.map +7 -0
  248. package/dist/services/openai.js +8 -1
  249. package/dist/services/openai.js.map +2 -2
  250. package/dist/services/outputStyles.js +138 -0
  251. package/dist/services/outputStyles.js.map +7 -0
  252. package/dist/services/plugins/index.js +5 -0
  253. package/dist/services/plugins/index.js.map +7 -0
  254. package/dist/services/plugins/lspServers.js +188 -0
  255. package/dist/services/plugins/lspServers.js.map +7 -0
  256. package/dist/services/plugins/pluginRuntime.js +229 -0
  257. package/dist/services/plugins/pluginRuntime.js.map +7 -0
  258. package/dist/services/plugins/pluginValidation.js +219 -0
  259. package/dist/services/plugins/pluginValidation.js.map +7 -0
  260. package/dist/services/plugins/skillMarketplace.js +556 -0
  261. package/dist/services/plugins/skillMarketplace.js.map +7 -0
  262. package/dist/services/responseStateManager.js +37 -3
  263. package/dist/services/responseStateManager.js.map +2 -2
  264. package/dist/services/sandbox/filesystemBoundary.js +300 -0
  265. package/dist/services/sandbox/filesystemBoundary.js.map +7 -0
  266. package/dist/services/sandbox/index.js +14 -0
  267. package/dist/services/sandbox/index.js.map +7 -0
  268. package/dist/services/sandbox/networkProxy.js +293 -0
  269. package/dist/services/sandbox/networkProxy.js.map +7 -0
  270. package/dist/services/sandbox/sandboxController.js +574 -0
  271. package/dist/services/sandbox/sandboxController.js.map +7 -0
  272. package/dist/services/sandbox/types.js +50 -0
  273. package/dist/services/sandbox/types.js.map +7 -0
  274. package/dist/services/sessionMemory.js +266 -0
  275. package/dist/services/sessionMemory.js.map +7 -0
  276. package/dist/services/taskRouter.js +324 -0
  277. package/dist/services/taskRouter.js.map +7 -0
  278. package/dist/tools/ArchitectTool/ArchitectTool.js +10 -3
  279. package/dist/tools/ArchitectTool/ArchitectTool.js.map +2 -2
  280. package/dist/tools/AskExpertModelTool/AskExpertModelTool.js +3 -0
  281. package/dist/tools/AskExpertModelTool/AskExpertModelTool.js.map +2 -2
  282. package/dist/tools/AskUserQuestionTool/AskUserQuestionTool.js +8 -1
  283. package/dist/tools/AskUserQuestionTool/AskUserQuestionTool.js.map +2 -2
  284. package/dist/tools/BaseTool.js +72 -0
  285. package/dist/tools/BaseTool.js.map +7 -0
  286. package/dist/tools/BashOutputTool/BashOutputToolResultMessage.js +3 -0
  287. package/dist/tools/BashOutputTool/BashOutputToolResultMessage.js.map +2 -2
  288. package/dist/tools/BashTool/BashTool.js +60 -3
  289. package/dist/tools/BashTool/BashTool.js.map +2 -2
  290. package/dist/tools/BashTool/BashToolResultMessage.js +3 -0
  291. package/dist/tools/BashTool/BashToolResultMessage.js.map +2 -2
  292. package/dist/tools/BashTool/OutputLine.js +54 -0
  293. package/dist/tools/BashTool/OutputLine.js.map +2 -2
  294. package/dist/tools/BashTool/prompt.js +192 -3
  295. package/dist/tools/BashTool/prompt.js.map +2 -2
  296. package/dist/tools/FileEditTool/FileEditTool.js +29 -4
  297. package/dist/tools/FileEditTool/FileEditTool.js.map +2 -2
  298. package/dist/tools/FileReadTool/FileReadTool.js +23 -4
  299. package/dist/tools/FileReadTool/FileReadTool.js.map +2 -2
  300. package/dist/tools/FileWriteTool/FileWriteTool.js +5 -5
  301. package/dist/tools/FileWriteTool/FileWriteTool.js.map +2 -2
  302. package/dist/tools/GlobTool/GlobTool.js +14 -3
  303. package/dist/tools/GlobTool/GlobTool.js.map +2 -2
  304. package/dist/tools/GrepTool/GrepTool.js +41 -7
  305. package/dist/tools/GrepTool/GrepTool.js.map +2 -2
  306. package/dist/tools/KillShellTool/KillShellToolResultMessage.js +3 -0
  307. package/dist/tools/KillShellTool/KillShellToolResultMessage.js.map +2 -2
  308. package/dist/tools/ListMcpResourcesTool/ListMcpResourcesTool.js +109 -0
  309. package/dist/tools/ListMcpResourcesTool/ListMcpResourcesTool.js.map +7 -0
  310. package/dist/tools/ListMcpResourcesTool/prompt.js +19 -0
  311. package/dist/tools/ListMcpResourcesTool/prompt.js.map +7 -0
  312. package/dist/tools/LspTool/LspTool.js +664 -0
  313. package/dist/tools/LspTool/LspTool.js.map +7 -0
  314. package/dist/tools/LspTool/prompt.js +27 -0
  315. package/dist/tools/LspTool/prompt.js.map +7 -0
  316. package/dist/tools/MCPTool/MCPTool.js +11 -4
  317. package/dist/tools/MCPTool/MCPTool.js.map +2 -2
  318. package/dist/tools/MemoryReadTool/MemoryReadTool.js +19 -6
  319. package/dist/tools/MemoryReadTool/MemoryReadTool.js.map +2 -2
  320. package/dist/tools/MemoryWriteTool/MemoryWriteTool.js +6 -6
  321. package/dist/tools/MemoryWriteTool/MemoryWriteTool.js.map +2 -2
  322. package/dist/tools/MultiEditTool/MultiEditTool.js +19 -2
  323. package/dist/tools/MultiEditTool/MultiEditTool.js.map +2 -2
  324. package/dist/tools/NotebookEditTool/NotebookEditTool.js +5 -1
  325. package/dist/tools/NotebookEditTool/NotebookEditTool.js.map +2 -2
  326. package/dist/tools/NotebookReadTool/NotebookReadTool.js +8 -4
  327. package/dist/tools/NotebookReadTool/NotebookReadTool.js.map +2 -2
  328. package/dist/tools/PlanModeTool/EnterPlanModeTool.js +74 -0
  329. package/dist/tools/PlanModeTool/EnterPlanModeTool.js.map +7 -0
  330. package/dist/tools/PlanModeTool/ExitPlanModeTool.js +108 -0
  331. package/dist/tools/PlanModeTool/ExitPlanModeTool.js.map +7 -0
  332. package/dist/tools/PlanModeTool/prompt.js +94 -0
  333. package/dist/tools/PlanModeTool/prompt.js.map +7 -0
  334. package/dist/tools/ReadMcpResourceTool/ReadMcpResourceTool.js +130 -0
  335. package/dist/tools/ReadMcpResourceTool/ReadMcpResourceTool.js.map +7 -0
  336. package/dist/tools/ReadMcpResourceTool/prompt.js +17 -0
  337. package/dist/tools/ReadMcpResourceTool/prompt.js.map +7 -0
  338. package/dist/tools/SkillTool/SkillTool.js +14 -3
  339. package/dist/tools/SkillTool/SkillTool.js.map +2 -2
  340. package/dist/tools/SlashCommandTool/SlashCommandTool.js +260 -0
  341. package/dist/tools/SlashCommandTool/SlashCommandTool.js.map +7 -0
  342. package/dist/tools/SlashCommandTool/prompt.js +35 -0
  343. package/dist/tools/SlashCommandTool/prompt.js.map +7 -0
  344. package/dist/tools/TaskOutputTool/TaskOutputTool.js +189 -0
  345. package/dist/tools/TaskOutputTool/TaskOutputTool.js.map +7 -0
  346. package/dist/tools/TaskOutputTool/prompt.js +15 -0
  347. package/dist/tools/TaskOutputTool/prompt.js.map +7 -0
  348. package/dist/tools/TaskTool/TaskTool.js +321 -146
  349. package/dist/tools/TaskTool/TaskTool.js.map +2 -2
  350. package/dist/tools/TaskTool/prompt.js.map +2 -2
  351. package/dist/tools/TodoWriteTool/TodoWriteTool.js +42 -73
  352. package/dist/tools/TodoWriteTool/TodoWriteTool.js.map +2 -2
  353. package/dist/tools/URLFetcherTool/URLFetcherTool.js +7 -1
  354. package/dist/tools/URLFetcherTool/URLFetcherTool.js.map +2 -2
  355. package/dist/tools/URLFetcherTool/cache.js +55 -8
  356. package/dist/tools/URLFetcherTool/cache.js.map +2 -2
  357. package/dist/tools/WebSearchTool/WebSearchTool.js +6 -1
  358. package/dist/tools/WebSearchTool/WebSearchTool.js.map +2 -2
  359. package/dist/tools.js +31 -2
  360. package/dist/tools.js.map +2 -2
  361. package/dist/types/hooks.js +4 -0
  362. package/dist/types/hooks.js.map +2 -2
  363. package/dist/types/marketplace.js.map +2 -2
  364. package/dist/types/messageGroup.js +36 -0
  365. package/dist/types/messageGroup.js.map +7 -0
  366. package/dist/types/plugin.js.map +2 -2
  367. package/dist/types/thinking.js +1 -0
  368. package/dist/types/thinking.js.map +7 -0
  369. package/dist/utils/BackgroundShellManager.js +136 -39
  370. package/dist/utils/BackgroundShellManager.js.map +2 -2
  371. package/dist/utils/MessageBatchBuffer.js +102 -0
  372. package/dist/utils/MessageBatchBuffer.js.map +7 -0
  373. package/dist/utils/PersistentShell.js +151 -1
  374. package/dist/utils/PersistentShell.js.map +2 -2
  375. package/dist/utils/agentLoader.js +1 -23
  376. package/dist/utils/agentLoader.js.map +2 -2
  377. package/dist/utils/agentTranscripts.js +641 -0
  378. package/dist/utils/agentTranscripts.js.map +7 -0
  379. package/dist/utils/animationManager.js +213 -0
  380. package/dist/utils/animationManager.js.map +7 -0
  381. package/dist/utils/animationSync.js +110 -0
  382. package/dist/utils/animationSync.js.map +7 -0
  383. package/dist/utils/asyncFile.js +215 -0
  384. package/dist/utils/asyncFile.js.map +7 -0
  385. package/dist/utils/backgroundAgentManager.js +231 -0
  386. package/dist/utils/backgroundAgentManager.js.map +7 -0
  387. package/dist/utils/config.js +63 -7
  388. package/dist/utils/config.js.map +2 -2
  389. package/dist/utils/conversationRecovery.js +19 -0
  390. package/dist/utils/conversationRecovery.js.map +2 -2
  391. package/dist/utils/exit.js +73 -0
  392. package/dist/utils/exit.js.map +7 -0
  393. package/dist/utils/format.js +73 -5
  394. package/dist/utils/format.js.map +2 -2
  395. package/dist/utils/generators.js +76 -6
  396. package/dist/utils/generators.js.map +2 -2
  397. package/dist/utils/globalErrorHandler.js +149 -0
  398. package/dist/utils/globalErrorHandler.js.map +7 -0
  399. package/dist/utils/groupHandlers/index.js +8 -0
  400. package/dist/utils/groupHandlers/index.js.map +7 -0
  401. package/dist/utils/groupHandlers/parallelTasksHandler.js +140 -0
  402. package/dist/utils/groupHandlers/parallelTasksHandler.js.map +7 -0
  403. package/dist/utils/groupHandlers/taskHandler.js +104 -0
  404. package/dist/utils/groupHandlers/taskHandler.js.map +7 -0
  405. package/dist/utils/groupHandlers/types.js +1 -0
  406. package/dist/utils/groupHandlers/types.js.map +7 -0
  407. package/dist/utils/logRotation.js +224 -0
  408. package/dist/utils/logRotation.js.map +7 -0
  409. package/dist/utils/marketplaceManager.js +3 -5
  410. package/dist/utils/marketplaceManager.js.map +2 -2
  411. package/dist/utils/memSafety.js +264 -0
  412. package/dist/utils/memSafety.js.map +7 -0
  413. package/dist/utils/messageGroupManager.js +274 -0
  414. package/dist/utils/messageGroupManager.js.map +7 -0
  415. package/dist/utils/messages.js +13 -4
  416. package/dist/utils/messages.js.map +2 -2
  417. package/dist/utils/model.js +119 -15
  418. package/dist/utils/model.js.map +3 -3
  419. package/dist/utils/permissions/filesystem.js +157 -5
  420. package/dist/utils/permissions/filesystem.js.map +2 -2
  421. package/dist/utils/plan/planMode.js +143 -0
  422. package/dist/utils/plan/planMode.js.map +7 -0
  423. package/dist/utils/pluginLoader.js +17 -21
  424. package/dist/utils/pluginLoader.js.map +2 -2
  425. package/dist/utils/ripgrep.js +55 -2
  426. package/dist/utils/ripgrep.js.map +2 -2
  427. package/dist/utils/sanitizeInput.js +32 -0
  428. package/dist/utils/sanitizeInput.js.map +7 -0
  429. package/dist/utils/secureKeyStorage.js +312 -0
  430. package/dist/utils/secureKeyStorage.js.map +7 -0
  431. package/dist/utils/session/sessionPlugins.js +67 -0
  432. package/dist/utils/session/sessionPlugins.js.map +7 -0
  433. package/dist/utils/taskDisplayUtils.js +257 -0
  434. package/dist/utils/taskDisplayUtils.js.map +7 -0
  435. package/dist/utils/teamConfig.js +2 -1
  436. package/dist/utils/teamConfig.js.map +2 -2
  437. package/dist/utils/todoStorage.js +92 -2
  438. package/dist/utils/todoStorage.js.map +2 -2
  439. package/dist/utils/toolTimeout.js +136 -0
  440. package/dist/utils/toolTimeout.js.map +7 -0
  441. package/dist/utils/tooling/safeRender.js +115 -0
  442. package/dist/utils/tooling/safeRender.js.map +7 -0
  443. package/dist/utils/userFriendlyError.js +346 -0
  444. package/dist/utils/userFriendlyError.js.map +7 -0
  445. package/dist/utils/vendor/ripgrep/arm64-darwin/rg +0 -0
  446. package/dist/version.js +2 -2
  447. package/dist/version.js.map +1 -1
  448. package/package.json +14 -4
  449. package/scripts/postinstall.js +128 -38
  450. package/dist/commands/agents.js +0 -2086
  451. package/dist/commands/agents.js.map +0 -7
  452. package/dist/commands/build.js +0 -74
  453. package/dist/commands/build.js.map +0 -7
  454. package/dist/commands/compression.js +0 -57
  455. package/dist/commands/compression.js.map +0 -7
  456. package/dist/commands/listen.js +0 -37
  457. package/dist/commands/listen.js.map +0 -7
  458. package/dist/commands/login.js +0 -37
  459. package/dist/commands/login.js.map +0 -7
  460. package/dist/commands/logout.js +0 -33
  461. package/dist/commands/logout.js.map +0 -7
  462. package/dist/commands/mcp.js +0 -40
  463. package/dist/commands/mcp.js.map +0 -7
  464. package/dist/commands/mcp_refresh.js +0 -40
  465. package/dist/commands/mcp_refresh.js.map +0 -7
  466. package/dist/commands/modelstatus.js +0 -21
  467. package/dist/commands/modelstatus.js.map +0 -7
  468. package/dist/commands/onboarding.js +0 -36
  469. package/dist/commands/onboarding.js.map +0 -7
  470. package/dist/commands/plugin-interactive.js +0 -446
  471. package/dist/commands/plugin-interactive.js.map +0 -7
  472. package/dist/commands/pr_comments.js +0 -61
  473. package/dist/commands/pr_comments.js.map +0 -7
  474. package/dist/commands/release-notes.js +0 -30
  475. package/dist/commands/release-notes.js.map +0 -7
  476. package/dist/commands/review.js +0 -51
  477. package/dist/commands/review.js.map +0 -7
  478. package/dist/components/Bug.js +0 -147
  479. package/dist/components/Bug.js.map +0 -7
  480. package/dist/components/ModelSelector.js +0 -2062
  481. package/dist/components/ModelSelector.js.map +0 -7
  482. package/dist/components/ModelStatusDisplay.js +0 -87
  483. package/dist/components/ModelStatusDisplay.js.map +0 -7
  484. package/dist/entrypoints/cli-wrapper.js +0 -61
  485. package/dist/entrypoints/cli-wrapper.js.map +0 -7
  486. package/dist/screens/Doctor.js +0 -22
  487. package/dist/screens/Doctor.js.map +0 -7
@@ -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'\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_number: z.number().describe('The index of the cell to edit (0-based)'),\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 .string()\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: 'NotebookEditCell',\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_number, edit_mode, new_source, error }) {\n if (error) {\n return error\n }\n switch (edit_mode) {\n case 'replace':\n return `Updated cell ${cell_number} with ${new_source}`\n case 'insert':\n return `Inserted cell ${cell_number} with ${new_source}`\n case 'delete':\n return `Deleted cell ${cell_number}`\n }\n },\n renderToolUseMessage(input, { verbose }) {\n return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}, cell: ${input.cell_number}, 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({ cell_number, new_source, language, error }) {\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_number}:</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_number,\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:\n 'File must be a Jupyter notebook (.ipynb file). For editing other file types, use the FileEdit tool.',\n }\n }\n\n if (cell_number < 0) {\n return {\n result: false,\n message: 'Cell number must be non-negative.',\n }\n }\n\n if (\n edit_mode !== 'replace' &&\n edit_mode !== 'insert' &&\n edit_mode !== 'delete'\n ) {\n return {\n result: false,\n message: 'Edit mode must be replace, insert, or delete.',\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 if (edit_mode === 'insert' && cell_number > notebook.cells.length) {\n return {\n result: false,\n message: `Cell number is out of bounds. For insert mode, the maximum value is ${notebook.cells.length} (to append at the end).`,\n }\n } else if (\n (edit_mode === 'replace' || edit_mode === 'delete') &&\n (cell_number >= notebook.cells.length || !notebook.cells[cell_number])\n ) {\n return {\n result: false,\n message: `Cell number is out of bounds. Notebook has ${notebook.cells.length} cells.`,\n }\n }\n\n return { result: true }\n },\n async *call({\n notebook_path,\n cell_number,\n new_source,\n cell_type,\n edit_mode,\n }) {\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 if (edit_mode === 'delete') {\n // Delete the specified cell\n notebook.cells.splice(cell_number, 1)\n } else if (edit_mode === 'insert') {\n // Insert the new cell\n const new_cell = {\n cell_type: cell_type!, // validateInput ensures cell_type is not undefined\n source: new_source,\n metadata: {},\n }\n notebook.cells.splice(\n cell_number,\n 0,\n cell_type == 'markdown' ? new_cell : { ...new_cell, outputs: [] },\n )\n } else {\n // Find the specified cell\n const targetCell = notebook.cells[cell_number]! // validateInput ensures cell_number is in bounds\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 cellNumber: cell_number,\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_number,\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_number,\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_number,\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_number: number\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;AAE/B,MAAM,cAAc,EAAE,aAAa;AAAA,EACjC,eAAe,EACZ,OAAO,EACP;AAAA,IACC;AAAA,EACF;AAAA,EACF,aAAa,EAAE,OAAO,EAAE,SAAS,yCAAyC;AA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AAK,OAAQ;AAGzD,qBAAe,UAAU,eAAe;AAGxC,wBAAkB,eAAe;AAAA,QAC/B,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,UAAU;AAAA,QACV,UAAU,aAAa;AAAA,QACvB,WAAW,KAAK,IAAI;AAAA,QACpB,WAAW;AAAA,MACb,CAAC;AACD,YAAM,OAAO;AAAA,QACX;AAAA,QACA;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;AAAA,UACA;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;AAAA,QACA;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;",
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'\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_number: z.number().describe('The index of the cell to edit (0-based)'),\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 .string()\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: 'NotebookEditCell',\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_number, edit_mode, new_source, error }) {\n if (error) {\n return error\n }\n switch (edit_mode) {\n case 'replace':\n return `Updated cell ${cell_number} with ${new_source}`\n case 'insert':\n return `Inserted cell ${cell_number} with ${new_source}`\n case 'delete':\n return `Deleted cell ${cell_number}`\n }\n },\n renderToolUseMessage(input, { verbose }) {\n return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}, cell: ${input.cell_number}, 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_number, 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_number}:</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_number,\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:\n 'File must be a Jupyter notebook (.ipynb file). For editing other file types, use the FileEdit tool.',\n }\n }\n\n if (cell_number < 0) {\n return {\n result: false,\n message: 'Cell number must be non-negative.',\n }\n }\n\n if (\n edit_mode !== 'replace' &&\n edit_mode !== 'insert' &&\n edit_mode !== 'delete'\n ) {\n return {\n result: false,\n message: 'Edit mode must be replace, insert, or delete.',\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 if (edit_mode === 'insert' && cell_number > notebook.cells.length) {\n return {\n result: false,\n message: `Cell number is out of bounds. For insert mode, the maximum value is ${notebook.cells.length} (to append at the end).`,\n }\n } else if (\n (edit_mode === 'replace' || edit_mode === 'delete') &&\n (cell_number >= notebook.cells.length || !notebook.cells[cell_number])\n ) {\n return {\n result: false,\n message: `Cell number is out of bounds. Notebook has ${notebook.cells.length} cells.`,\n }\n }\n\n return { result: true }\n },\n async *call({\n notebook_path,\n cell_number,\n new_source,\n cell_type,\n edit_mode,\n }) {\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 if (edit_mode === 'delete') {\n // Delete the specified cell\n notebook.cells.splice(cell_number, 1)\n } else if (edit_mode === 'insert') {\n // Insert the new cell\n const new_cell = {\n cell_type: cell_type!, // validateInput ensures cell_type is not undefined\n source: new_source,\n metadata: {},\n }\n notebook.cells.splice(\n cell_number,\n 0,\n cell_type == 'markdown' ? new_cell : { ...new_cell, outputs: [] },\n )\n } else {\n // Find the specified cell\n const targetCell = notebook.cells[cell_number]! // validateInput ensures cell_number is in bounds\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 cellNumber: cell_number,\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_number,\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_number,\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_number,\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_number: number\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;AAE/B,MAAM,cAAc,EAAE,aAAa;AAAA,EACjC,eAAe,EACZ,OAAO,EACP;AAAA,IACC;AAAA,EACF;AAAA,EACF,aAAa,EAAE,OAAO,EAAE,SAAS,yCAAyC;AAAA,EAC1E,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,OAAO,EACP,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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A,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;AAAA,UACA;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;AAAA,QACA;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
  }
@@ -89,11 +89,15 @@ const NotebookReadTool = {
89
89
  };
90
90
  },
91
91
  renderResultForAssistant(data) {
92
+ if (!data || !Array.isArray(data)) {
93
+ return "No cells found in notebook";
94
+ }
92
95
  return data.map((cell, index) => {
93
- let content = `Cell ${index + 1} (${cell.cellType}):
94
- ${cell.source}`;
95
- if (cell.outputs && cell.outputs.length > 0) {
96
- const outputText = cell.outputs.map((output) => output.text).filter(Boolean).join("\n");
96
+ if (!cell) return `Cell ${index + 1}: (empty)`;
97
+ let content = `Cell ${index + 1} (${cell.cellType || "unknown"}):
98
+ ${cell.source || ""}`;
99
+ if (cell.outputs && Array.isArray(cell.outputs) && cell.outputs.length > 0) {
100
+ const outputText = cell.outputs.filter((output) => output != null).map((output) => output.text || "").filter(Boolean).join("\n");
97
101
  if (outputText) {
98
102
  content += `
99
103
  Output:
@@ -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 // Convert the complex structure to a string representation for the assistant\n return data\n .map((cell, index) => {\n let content = `Cell ${index + 1} (${cell.cellType}):\\n${cell.source}`\n if (cell.outputs && cell.outputs.length > 0) {\n const outputText = cell.outputs\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"],
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,aAAO;AAAA,QACL,QAAQ;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,QAAI,QAAQ,YAAY,MAAM,UAAU;AACtC,aAAO;AAAA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AI,iBAAiB,CAAC,CAAE;AACjD;AAEO,SAAS,mBACd,OAC2B;AAC3B,SAAO,UAAU,UAAU,UAAU;AACvC;",
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"],
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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AAO,OAAO;AAChB,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
  }
@@ -0,0 +1,74 @@
1
+ import { Box, Text } from "ink";
2
+ import React from "react";
3
+ import { z } from "zod";
4
+ import { enterPlanMode } from "../../utils/plan/planMode.js";
5
+ import { ENTER_DESCRIPTION, ENTER_PROMPT, ENTER_TOOL_NAME } from "./prompt.js";
6
+ const inputSchema = z.strictObject({});
7
+ const EnterPlanModeTool = {
8
+ name: ENTER_TOOL_NAME,
9
+ async description() {
10
+ return ENTER_DESCRIPTION;
11
+ },
12
+ userFacingName() {
13
+ return "";
14
+ },
15
+ inputSchema,
16
+ isReadOnly() {
17
+ return true;
18
+ },
19
+ isConcurrencySafe() {
20
+ return true;
21
+ },
22
+ async isEnabled() {
23
+ return true;
24
+ },
25
+ needsPermissions() {
26
+ return true;
27
+ },
28
+ requiresUserInteraction() {
29
+ return true;
30
+ },
31
+ async prompt() {
32
+ return ENTER_PROMPT;
33
+ },
34
+ renderToolUseMessage() {
35
+ return "";
36
+ },
37
+ renderToolUseRejectedMessage() {
38
+ return /* @__PURE__ */ React.createElement(Box, { flexDirection: "row", marginTop: 1 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "User declined to enter plan mode"));
39
+ },
40
+ renderToolResultMessage(_output) {
41
+ return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, { color: "cyan" }, "\u25CF"), /* @__PURE__ */ React.createElement(Text, null, " Entered plan mode")), /* @__PURE__ */ React.createElement(Box, { paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "Minto is now exploring and designing an implementation approach.")));
42
+ },
43
+ renderResultForAssistant(output) {
44
+ return `${output.message}
45
+
46
+ In plan mode, you should:
47
+ 1. Thoroughly explore the codebase to understand existing patterns
48
+ 2. Identify similar features and architectural approaches
49
+ 3. Consider multiple approaches and their trade-offs
50
+ 4. Use AskUserQuestion if you need to clarify the approach
51
+ 5. Design a concrete implementation strategy
52
+ 6. When ready, use ExitPlanMode to present your plan for approval
53
+
54
+ Remember: DO NOT write or edit any files yet. This is a read-only exploration and planning phase.`;
55
+ },
56
+ async *call(_input, context) {
57
+ if (context?.agentId) {
58
+ throw new Error("EnterPlanMode tool cannot be used in agent contexts");
59
+ }
60
+ enterPlanMode(context);
61
+ const output = {
62
+ message: "Entered plan mode. You should now focus on exploring the codebase and designing an implementation approach."
63
+ };
64
+ yield {
65
+ type: "result",
66
+ data: output,
67
+ resultForAssistant: this.renderResultForAssistant(output)
68
+ };
69
+ }
70
+ };
71
+ export {
72
+ EnterPlanModeTool
73
+ };
74
+ //# sourceMappingURL=EnterPlanModeTool.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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'\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 dimColor>User declined to enter plan mode</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 dimColor>\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;AAEjE,MAA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AAAA,IAC1D;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,108 @@
1
+ import { Box, Text } from "ink";
2
+ import React from "react";
3
+ import { z } from "zod";
4
+ import {
5
+ getPlanConversationKey,
6
+ getPlanFilePath,
7
+ readPlanFile
8
+ } from "../../utils/plan/planMode.js";
9
+ import { EXIT_DESCRIPTION, EXIT_PROMPT, EXIT_TOOL_NAME } from "./prompt.js";
10
+ function getExitPlanModePlanText(conversationKey) {
11
+ const { content } = readPlanFile(void 0, conversationKey);
12
+ return content || "No plan found. Please write your plan to the plan file first.";
13
+ }
14
+ const inputSchema = z.strictObject({}).passthrough();
15
+ const ExitPlanModeTool = {
16
+ name: EXIT_TOOL_NAME,
17
+ async description() {
18
+ return EXIT_DESCRIPTION;
19
+ },
20
+ userFacingName() {
21
+ return "";
22
+ },
23
+ inputSchema,
24
+ isReadOnly() {
25
+ return false;
26
+ },
27
+ isConcurrencySafe() {
28
+ return true;
29
+ },
30
+ async isEnabled() {
31
+ return true;
32
+ },
33
+ needsPermissions() {
34
+ return true;
35
+ },
36
+ requiresUserInteraction() {
37
+ return true;
38
+ },
39
+ async prompt() {
40
+ return EXIT_PROMPT;
41
+ },
42
+ renderToolUseMessage() {
43
+ return "";
44
+ },
45
+ renderToolUseRejectedMessage(_input, options = {}) {
46
+ const conversationKey = typeof options.conversationKey === "string" && options.conversationKey.trim() ? options.conversationKey.trim() : void 0;
47
+ const plan = getExitPlanModePlanText(conversationKey);
48
+ return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", marginTop: 1, width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", width: "100%" }, /* @__PURE__ */ React.createElement(Text, { color: "red" }, "User rejected the plan:"), /* @__PURE__ */ React.createElement(
49
+ Box,
50
+ {
51
+ borderStyle: "round",
52
+ borderColor: "cyan",
53
+ borderDimColor: true,
54
+ paddingX: 1,
55
+ overflow: "hidden"
56
+ },
57
+ /* @__PURE__ */ React.createElement(Text, { dimColor: true }, plan)
58
+ ))));
59
+ },
60
+ renderToolResultMessage(output) {
61
+ if (!output) {
62
+ return /* @__PURE__ */ React.createElement(Box, { paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, null, "Plan mode completed"));
63
+ }
64
+ const planPath = typeof output.filePath === "string" ? output.filePath : null;
65
+ const plan = output.plan || "No plan found";
66
+ return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", marginTop: 1, width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, { color: "cyan" }, "\u25CF"), /* @__PURE__ */ React.createElement(Text, null, " User approved the plan")), /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, planPath ? /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "Plan saved to: ", planPath) : null, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, plan.substring(0, 200), "..."))));
67
+ },
68
+ renderResultForAssistant(output) {
69
+ if (!output) {
70
+ return "Plan mode completed";
71
+ }
72
+ if (output.isAgent) {
73
+ return 'User has approved the plan. There is nothing else needed from you now. Please respond with "ok"';
74
+ }
75
+ return `User has approved your plan. You can now start coding. Start with updating your todo list if applicable
76
+
77
+ Your plan has been saved to: ${output.filePath}
78
+ You can refer back to it if needed during implementation.
79
+
80
+ ## Approved Plan:
81
+ ${output.plan}`;
82
+ },
83
+ async *call(input, context) {
84
+ const conversationKey = getPlanConversationKey(context);
85
+ const planFilePath = getPlanFilePath(context?.agentId, conversationKey);
86
+ const { content, exists } = readPlanFile(context?.agentId, conversationKey);
87
+ if (!exists) {
88
+ throw new Error(
89
+ `No plan file found at ${planFilePath}. Please write your plan to this file before calling ExitPlanMode.`
90
+ );
91
+ }
92
+ const isAgent = !!context?.agentId;
93
+ const output = {
94
+ plan: content,
95
+ isAgent,
96
+ filePath: planFilePath
97
+ };
98
+ yield {
99
+ type: "result",
100
+ data: output,
101
+ resultForAssistant: this.renderResultForAssistant(output)
102
+ };
103
+ }
104
+ };
105
+ export {
106
+ ExitPlanModeTool
107
+ };
108
+ //# sourceMappingURL=ExitPlanModeTool.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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'\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 dimColor>{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 ? <Text dimColor>Plan saved to: {planPath}</Text> : null}\n <Text dimColor>{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;AAE9D,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,CAAC,GACzC;AACA,UAAM,kBACJ,OAAO,QAAQ,oBAAoB,YACnC,QAAQ,gBAAgB,KAAK,IACzB,QAAQ,gBAAgB,KAAK,IAC7B;AAEN,UAAM,OAAO,wBAAwB,eAAe;AAEpD,WACE,oCAAC,OAAI,eAAc,UAAS,WAAW,GAAG,OAAM,UAC9C,oCAAC,OAAI,eAAc,SACjB,oCAAC,YAAK,qBAAoB,GAC1B,oCAAC,OAAI,eAAc,UAAS,OAAM,UAChC,oCAAC,QAAK,OAAM,SAAM,yBAAuB,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ACX,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;",
6
+ "names": []
7
+ }
@@ -0,0 +1,94 @@
1
+ const ENTER_TOOL_NAME = "EnterPlanMode";
2
+ const EXIT_TOOL_NAME = "ExitPlanMode";
3
+ const ENTER_DESCRIPTION = "Requests permission to enter plan mode for complex tasks requiring exploration and design";
4
+ const ENTER_PROMPT = `Use this tool proactively when you're about to start a non-trivial implementation task. Getting user sign-off on your approach before writing code prevents wasted effort and ensures alignment. This tool transitions you into plan mode where you can explore the codebase and design an implementation approach for user approval.
5
+
6
+ ## When to Use This Tool
7
+
8
+ **Prefer using EnterPlanMode** for implementation tasks unless they're simple. Use it when ANY of these conditions apply:
9
+
10
+ 1. **New Feature Implementation**: Adding meaningful new functionality
11
+ - Example: "Add a logout button" - where should it go? What should happen on click?
12
+ - Example: "Add form validation" - what rules? What error messages?
13
+
14
+ 2. **Multiple Valid Approaches**: The task can be solved in several different ways
15
+ - Example: "Add caching to the API" - could use Redis, in-memory, file-based, etc.
16
+ - Example: "Improve performance" - many optimization strategies possible
17
+
18
+ 3. **Code Modifications**: Changes that affect existing behavior or structure
19
+ - Example: "Update the login flow" - what exactly should change?
20
+ - Example: "Refactor this component" - what's the target architecture?
21
+
22
+ 4. **Architectural Decisions**: The task requires choosing between patterns or technologies
23
+ - Example: "Add real-time updates" - WebSockets vs SSE vs polling
24
+ - Example: "Implement state management" - Redux vs Context vs custom solution
25
+
26
+ 5. **Multi-File Changes**: The task will likely touch more than 2-3 files
27
+ - Example: "Refactor the authentication system"
28
+ - Example: "Add a new API endpoint with tests"
29
+
30
+ 6. **Unclear Requirements**: You need to explore before understanding the full scope
31
+ - Example: "Make the app faster" - need to profile and identify bottlenecks
32
+ - Example: "Fix the bug in checkout" - need to investigate root cause
33
+
34
+ 7. **User Preferences Matter**: The implementation could reasonably go multiple ways
35
+ - If you would use AskUserQuestion to clarify the approach, use EnterPlanMode instead
36
+ - Plan mode lets you explore first, then present options with context
37
+
38
+ ## When NOT to Use This Tool
39
+
40
+ Only skip EnterPlanMode for simple tasks:
41
+ - Single-line or few-line fixes (typos, obvious bugs, small tweaks)
42
+ - Adding a single function with clear requirements
43
+ - Tasks where the user has given very specific, detailed instructions
44
+ - Pure research/exploration tasks (use the Task tool with explore agent instead)
45
+
46
+ ## What Happens in Plan Mode
47
+
48
+ In plan mode, you'll:
49
+ 1. Thoroughly explore the codebase using Glob, Grep, and Read tools
50
+ 2. Understand existing patterns and architecture
51
+ 3. Design an implementation approach
52
+ 4. Present your plan to the user for approval
53
+ 5. Use AskUserQuestion if you need to clarify approaches
54
+ 6. Exit plan mode with ExitPlanMode when ready to implement
55
+
56
+ ## Important Notes
57
+
58
+ - This tool REQUIRES user approval - they must consent to entering plan mode
59
+ - If unsure whether to use it, err on the side of planning - it's better to get alignment upfront than to redo work
60
+ - Users appreciate being consulted before significant changes are made to their codebase`;
61
+ const EXIT_DESCRIPTION = "Prompts the user to exit plan mode and start coding";
62
+ const EXIT_PROMPT = `Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
63
+
64
+ ## How This Tool Works
65
+ - You should have already written your plan to the plan file specified in the plan mode system message
66
+ - This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote
67
+ - This tool simply signals that you're done planning and ready for the user to review and approve
68
+ - The user will see the contents of your plan file when they review it
69
+
70
+ ## When to Use This Tool
71
+ IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you're gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.
72
+
73
+ ## Handling Ambiguity in Plans
74
+ Before using this tool, ensure your plan is clear and unambiguous. If there are multiple valid approaches or unclear requirements:
75
+ 1. Use the AskUserQuestion tool to clarify with the user
76
+ 2. Ask about specific implementation choices (e.g., architectural patterns, which library to use)
77
+ 3. Clarify any assumptions that could affect the implementation
78
+ 4. Edit your plan file to incorporate user feedback
79
+ 5. Only proceed with ExitPlanMode after resolving ambiguities and updating the plan file
80
+
81
+ ## Examples
82
+
83
+ 1. Initial task: "Search for and understand the implementation of vim mode in the codebase" - Do not use the exit plan mode tool because you are not planning the implementation steps of a task.
84
+ 2. Initial task: "Help me implement yank mode for vim" - Use the exit plan mode tool after you have finished planning the implementation steps of the task.
85
+ 3. Initial task: "Add a new feature to handle user authentication" - If unsure about auth method (OAuth, JWT, etc.), use AskUserQuestion first, then use exit plan mode tool after clarifying the approach.`;
86
+ export {
87
+ ENTER_DESCRIPTION,
88
+ ENTER_PROMPT,
89
+ ENTER_TOOL_NAME,
90
+ EXIT_DESCRIPTION,
91
+ EXIT_PROMPT,
92
+ EXIT_TOOL_NAME
93
+ };
94
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/tools/PlanModeTool/prompt.ts"],
4
+ "sourcesContent": ["export const ENTER_TOOL_NAME = 'EnterPlanMode'\nexport const EXIT_TOOL_NAME = 'ExitPlanMode'\n\nexport const ENTER_DESCRIPTION =\n 'Requests permission to enter plan mode for complex tasks requiring exploration and design'\n\nexport const ENTER_PROMPT = `Use this tool proactively when you're about to start a non-trivial implementation task. Getting user sign-off on your approach before writing code prevents wasted effort and ensures alignment. This tool transitions you into plan mode where you can explore the codebase and design an implementation approach for user approval.\n\n## When to Use This Tool\n\n**Prefer using EnterPlanMode** for implementation tasks unless they're simple. Use it when ANY of these conditions apply:\n\n1. **New Feature Implementation**: Adding meaningful new functionality\n - Example: \"Add a logout button\" - where should it go? What should happen on click?\n - Example: \"Add form validation\" - what rules? What error messages?\n\n2. **Multiple Valid Approaches**: The task can be solved in several different ways\n - Example: \"Add caching to the API\" - could use Redis, in-memory, file-based, etc.\n - Example: \"Improve performance\" - many optimization strategies possible\n\n3. **Code Modifications**: Changes that affect existing behavior or structure\n - Example: \"Update the login flow\" - what exactly should change?\n - Example: \"Refactor this component\" - what's the target architecture?\n\n4. **Architectural Decisions**: The task requires choosing between patterns or technologies\n - Example: \"Add real-time updates\" - WebSockets vs SSE vs polling\n - Example: \"Implement state management\" - Redux vs Context vs custom solution\n\n5. **Multi-File Changes**: The task will likely touch more than 2-3 files\n - Example: \"Refactor the authentication system\"\n - Example: \"Add a new API endpoint with tests\"\n\n6. **Unclear Requirements**: You need to explore before understanding the full scope\n - Example: \"Make the app faster\" - need to profile and identify bottlenecks\n - Example: \"Fix the bug in checkout\" - need to investigate root cause\n\n7. **User Preferences Matter**: The implementation could reasonably go multiple ways\n - If you would use AskUserQuestion to clarify the approach, use EnterPlanMode instead\n - Plan mode lets you explore first, then present options with context\n\n## When NOT to Use This Tool\n\nOnly skip EnterPlanMode for simple tasks:\n- Single-line or few-line fixes (typos, obvious bugs, small tweaks)\n- Adding a single function with clear requirements\n- Tasks where the user has given very specific, detailed instructions\n- Pure research/exploration tasks (use the Task tool with explore agent instead)\n\n## What Happens in Plan Mode\n\nIn plan mode, you'll:\n1. Thoroughly explore the codebase using Glob, Grep, and Read tools\n2. Understand existing patterns and architecture\n3. Design an implementation approach\n4. Present your plan to the user for approval\n5. Use AskUserQuestion if you need to clarify approaches\n6. Exit plan mode with ExitPlanMode when ready to implement\n\n## Important Notes\n\n- This tool REQUIRES user approval - they must consent to entering plan mode\n- If unsure whether to use it, err on the side of planning - it's better to get alignment upfront than to redo work\n- Users appreciate being consulted before significant changes are made to their codebase`\n\nexport const EXIT_DESCRIPTION =\n 'Prompts the user to exit plan mode and start coding'\n\nexport const EXIT_PROMPT = `Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.\n\n## How This Tool Works\n- You should have already written your plan to the plan file specified in the plan mode system message\n- This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote\n- This tool simply signals that you're done planning and ready for the user to review and approve\n- The user will see the contents of your plan file when they review it\n\n## When to Use This Tool\nIMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you're gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.\n\n## Handling Ambiguity in Plans\nBefore using this tool, ensure your plan is clear and unambiguous. If there are multiple valid approaches or unclear requirements:\n1. Use the AskUserQuestion tool to clarify with the user\n2. Ask about specific implementation choices (e.g., architectural patterns, which library to use)\n3. Clarify any assumptions that could affect the implementation\n4. Edit your plan file to incorporate user feedback\n5. Only proceed with ExitPlanMode after resolving ambiguities and updating the plan file\n\n## Examples\n\n1. Initial task: \"Search for and understand the implementation of vim mode in the codebase\" - Do not use the exit plan mode tool because you are not planning the implementation steps of a task.\n2. Initial task: \"Help me implement yank mode for vim\" - Use the exit plan mode tool after you have finished planning the implementation steps of the task.\n3. Initial task: \"Add a new feature to handle user authentication\" - If unsure about auth method (OAuth, JWT, etc.), use AskUserQuestion first, then use exit plan mode tool after clarifying the approach.`\n"],
5
+ "mappings": "AAAO,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AAEvB,MAAM,oBACX;AAEK,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0DrB,MAAM,mBACX;AAEK,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,130 @@
1
+ import { Box, Text } from "ink";
2
+ import React from "react";
3
+ import { z } from "zod";
4
+ import { Cost } from "../../components/Cost.js";
5
+ import { FallbackToolUseRejectedMessage } from "../../components/FallbackToolUseRejectedMessage.js";
6
+ import { readMCPResource } from "../../services/mcpClient.js";
7
+ import { DESCRIPTION, TOOL_NAME_FOR_PROMPT } from "./prompt.js";
8
+ import { getTheme } from "../../utils/theme.js";
9
+ const inputSchema = z.strictObject({
10
+ uri: z.string().describe("The URI of the resource to read"),
11
+ server: z.string().optional().describe("Optional server name to target a specific MCP server")
12
+ });
13
+ const ReadMcpResourceTool = {
14
+ name: TOOL_NAME_FOR_PROMPT,
15
+ async description() {
16
+ return DESCRIPTION;
17
+ },
18
+ userFacingName() {
19
+ return "Read MCP Resource";
20
+ },
21
+ inputSchema,
22
+ async isEnabled() {
23
+ return true;
24
+ },
25
+ isReadOnly() {
26
+ return true;
27
+ },
28
+ isConcurrencySafe() {
29
+ return true;
30
+ },
31
+ needsPermissions() {
32
+ return false;
33
+ },
34
+ async prompt() {
35
+ return DESCRIPTION;
36
+ },
37
+ renderToolUseMessage({ uri, server }, { verbose }) {
38
+ let msg = `uri: "${uri}"`;
39
+ if (server) {
40
+ msg += `, server: "${server}"`;
41
+ }
42
+ return msg;
43
+ },
44
+ renderToolUseRejectedMessage() {
45
+ return /* @__PURE__ */ React.createElement(FallbackToolUseRejectedMessage, null);
46
+ },
47
+ renderToolResultMessage(output) {
48
+ if (!output) {
49
+ return /* @__PURE__ */ React.createElement(Box, { justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React.createElement(Text, { color: getTheme().error }, "Failed to read resource")));
50
+ }
51
+ if (typeof output === "string") {
52
+ try {
53
+ output = JSON.parse(output);
54
+ } catch {
55
+ return /* @__PURE__ */ React.createElement(Box, { justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0Read MCP resource")));
56
+ }
57
+ }
58
+ const durationMs = output?.durationMs ?? 0;
59
+ if (output?.error) {
60
+ return /* @__PURE__ */ React.createElement(Box, { justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React.createElement(Text, { color: getTheme().error }, output.error)), /* @__PURE__ */ React.createElement(Cost, { costUSD: 0, durationMs, debug: false }));
61
+ }
62
+ if (!output?.content) {
63
+ return /* @__PURE__ */ React.createElement(Box, { justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React.createElement(Text, { color: getTheme().warning }, "Resource not found")), /* @__PURE__ */ React.createElement(Cost, { costUSD: 0, durationMs, debug: false }));
64
+ }
65
+ const contentType = output.content.mimeType || "unknown";
66
+ const hasText = !!output.content.text;
67
+ const hasBlob = !!output.content.blob;
68
+ return /* @__PURE__ */ React.createElement(Box, { justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0Read resource "), /* @__PURE__ */ React.createElement(Text, { color: getTheme().secondaryText }, "(", contentType, ", ", hasText ? "text" : hasBlob ? "binary" : "empty", ")")), /* @__PURE__ */ React.createElement(Cost, { costUSD: 0, durationMs, debug: false }));
69
+ },
70
+ async *call({ uri, server }) {
71
+ const start = Date.now();
72
+ try {
73
+ const content = await readMCPResource(uri, server);
74
+ const output = {
75
+ content,
76
+ durationMs: Date.now() - start
77
+ };
78
+ yield {
79
+ type: "result",
80
+ resultForAssistant: this.renderResultForAssistant(output),
81
+ data: output
82
+ };
83
+ } catch (error) {
84
+ const output = {
85
+ content: null,
86
+ durationMs: Date.now() - start,
87
+ error: error instanceof Error ? error.message : String(error)
88
+ };
89
+ yield {
90
+ type: "result",
91
+ resultForAssistant: this.renderResultForAssistant(output),
92
+ data: output
93
+ };
94
+ }
95
+ },
96
+ renderResultForAssistant(output) {
97
+ if (output.error) {
98
+ return `Error reading resource: ${output.error}`;
99
+ }
100
+ if (!output.content) {
101
+ return "Resource not found or not accessible";
102
+ }
103
+ const lines = [];
104
+ lines.push(`Resource: ${output.content.uri}`);
105
+ if (output.content.mimeType) {
106
+ lines.push(`MIME Type: ${output.content.mimeType}`);
107
+ }
108
+ lines.push("");
109
+ if (output.content.text) {
110
+ lines.push("Content:");
111
+ lines.push(output.content.text);
112
+ } else if (output.content.blob) {
113
+ lines.push(
114
+ `Binary content (base64, ${output.content.blob.length} characters)`
115
+ );
116
+ if (output.content.blob.length > 200) {
117
+ lines.push(output.content.blob.substring(0, 200) + "...");
118
+ } else {
119
+ lines.push(output.content.blob);
120
+ }
121
+ } else {
122
+ lines.push("(Empty content)");
123
+ }
124
+ return lines.join("\n");
125
+ }
126
+ };
127
+ export {
128
+ ReadMcpResourceTool
129
+ };
130
+ //# sourceMappingURL=ReadMcpResourceTool.js.map