@within-7/minto 0.2.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/agents/AgentsCommand.js +22 -24
- package/dist/commands/agents/AgentsCommand.js.map +2 -2
- package/dist/commands/context.js +2 -1
- package/dist/commands/context.js.map +2 -2
- package/dist/commands/export.js +2 -1
- package/dist/commands/export.js.map +2 -2
- package/dist/commands/mcp-interactive.js +7 -6
- package/dist/commands/mcp-interactive.js.map +2 -2
- package/dist/commands/model.js +3 -2
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/permissions.js +4 -3
- package/dist/commands/permissions.js.map +2 -2
- package/dist/commands/plugin/AddMarketplaceForm.js +3 -2
- package/dist/commands/plugin/AddMarketplaceForm.js.map +2 -2
- package/dist/commands/plugin/ConfirmDialog.js +2 -1
- package/dist/commands/plugin/ConfirmDialog.js.map +2 -2
- package/dist/commands/plugin/ErrorView.js +2 -1
- package/dist/commands/plugin/ErrorView.js.map +2 -2
- package/dist/commands/plugin/InstalledPluginsByMarketplace.js +5 -4
- package/dist/commands/plugin/InstalledPluginsByMarketplace.js.map +2 -2
- package/dist/commands/plugin/InstalledPluginsManager.js +5 -4
- package/dist/commands/plugin/InstalledPluginsManager.js.map +2 -2
- package/dist/commands/plugin/MainMenu.js +2 -1
- package/dist/commands/plugin/MainMenu.js.map +2 -2
- package/dist/commands/plugin/MarketplaceManager.js +5 -4
- package/dist/commands/plugin/MarketplaceManager.js.map +2 -2
- package/dist/commands/plugin/MarketplaceSelector.js +4 -3
- package/dist/commands/plugin/MarketplaceSelector.js.map +2 -2
- package/dist/commands/plugin/PlaceholderScreen.js +3 -2
- package/dist/commands/plugin/PlaceholderScreen.js.map +2 -2
- package/dist/commands/plugin/PluginBrowser.js +6 -5
- package/dist/commands/plugin/PluginBrowser.js.map +2 -2
- package/dist/commands/plugin/PluginDetailsInstall.js +5 -4
- package/dist/commands/plugin/PluginDetailsInstall.js.map +2 -2
- package/dist/commands/plugin/PluginDetailsManage.js +4 -3
- package/dist/commands/plugin/PluginDetailsManage.js.map +2 -2
- package/dist/commands/plugin.js +16 -15
- package/dist/commands/plugin.js.map +2 -2
- package/dist/commands/sandbox.js +4 -3
- package/dist/commands/sandbox.js.map +2 -2
- package/dist/commands/setup.js +2 -1
- package/dist/commands/setup.js.map +2 -2
- package/dist/commands/status.js +2 -1
- package/dist/commands/status.js.map +2 -2
- package/dist/commands/undo.js +245 -0
- package/dist/commands/undo.js.map +7 -0
- package/dist/commands.js +2 -0
- package/dist/commands.js.map +2 -2
- package/dist/components/AgentThinkingBlock.js +1 -1
- package/dist/components/AgentThinkingBlock.js.map +2 -2
- package/dist/components/AsciiLogo.js +7 -8
- package/dist/components/AsciiLogo.js.map +2 -2
- package/dist/components/AskUserQuestionDialog/AskUserQuestionDialog.js +3 -2
- package/dist/components/AskUserQuestionDialog/AskUserQuestionDialog.js.map +2 -2
- package/dist/components/AskUserQuestionDialog/QuestionView.js +2 -1
- package/dist/components/AskUserQuestionDialog/QuestionView.js.map +2 -2
- package/dist/components/CollapsibleHint.js +2 -1
- package/dist/components/CollapsibleHint.js.map +2 -2
- package/dist/components/Config.js +3 -2
- package/dist/components/Config.js.map +2 -2
- package/dist/components/ConsoleOAuthFlow.js +2 -1
- package/dist/components/ConsoleOAuthFlow.js.map +2 -2
- package/dist/components/Cost.js +2 -1
- package/dist/components/Cost.js.map +2 -2
- package/dist/components/HeaderBar.js +13 -8
- package/dist/components/HeaderBar.js.map +2 -2
- package/dist/components/HistorySearchOverlay.js +4 -3
- package/dist/components/HistorySearchOverlay.js.map +2 -2
- package/dist/components/HotkeyHelpPanel.js +8 -11
- package/dist/components/HotkeyHelpPanel.js.map +2 -2
- package/dist/components/InvalidConfigDialog.js +2 -1
- package/dist/components/InvalidConfigDialog.js.map +2 -2
- package/dist/components/Logo.js +23 -67
- package/dist/components/Logo.js.map +2 -2
- package/dist/components/MCPServerApprovalDialog.js +2 -1
- package/dist/components/MCPServerApprovalDialog.js.map +2 -2
- package/dist/components/MCPServerDialogCopy.js +2 -1
- package/dist/components/MCPServerDialogCopy.js.map +2 -2
- package/dist/components/MCPServerMultiselectDialog.js +2 -1
- package/dist/components/MCPServerMultiselectDialog.js.map +2 -2
- package/dist/components/MessageSelector.js +4 -3
- package/dist/components/MessageSelector.js.map +2 -2
- package/dist/components/ModeIndicator.js +2 -1
- package/dist/components/ModeIndicator.js.map +2 -2
- package/dist/components/ModelConfig.js +4 -3
- package/dist/components/ModelConfig.js.map +2 -2
- package/dist/components/ModelListManager.js +4 -3
- package/dist/components/ModelListManager.js.map +2 -2
- package/dist/components/ModelSelector/ModelSelector.js +26 -13
- package/dist/components/ModelSelector/ModelSelector.js.map +2 -2
- package/dist/components/Onboarding.js +3 -2
- package/dist/components/Onboarding.js.map +2 -2
- package/dist/components/OperationSummary.js +130 -0
- package/dist/components/OperationSummary.js.map +7 -0
- package/dist/components/PromptInput.js +88 -75
- package/dist/components/PromptInput.js.map +2 -2
- package/dist/components/SensitiveFileWarning.js +31 -0
- package/dist/components/SensitiveFileWarning.js.map +7 -0
- package/dist/components/Spinner.js +71 -22
- package/dist/components/Spinner.js.map +2 -2
- package/dist/components/StructuredDiff.js +6 -8
- package/dist/components/StructuredDiff.js.map +2 -2
- package/dist/components/SubagentBlock.js +4 -2
- package/dist/components/SubagentBlock.js.map +2 -2
- package/dist/components/SubagentProgress.js +17 -6
- package/dist/components/SubagentProgress.js.map +2 -2
- package/dist/components/TaskCard.js +14 -11
- package/dist/components/TaskCard.js.map +2 -2
- package/dist/components/TextInput.js +9 -1
- package/dist/components/TextInput.js.map +2 -2
- package/dist/components/TodoPanel.js +44 -26
- package/dist/components/TodoPanel.js.map +2 -2
- package/dist/components/ToolUseLoader.js +2 -2
- package/dist/components/ToolUseLoader.js.map +2 -2
- package/dist/components/TreeConnector.js +4 -3
- package/dist/components/TreeConnector.js.map +2 -2
- package/dist/components/TrustDialog.js +2 -1
- package/dist/components/TrustDialog.js.map +2 -2
- package/dist/components/binary-feedback/BinaryFeedbackView.js +2 -1
- package/dist/components/binary-feedback/BinaryFeedbackView.js.map +2 -2
- package/dist/components/messages/AssistantTextMessage.js +17 -9
- package/dist/components/messages/AssistantTextMessage.js.map +2 -2
- package/dist/components/messages/AssistantToolUseMessage.js +8 -4
- package/dist/components/messages/AssistantToolUseMessage.js.map +2 -2
- package/dist/components/messages/GroupRenderer.js +2 -1
- package/dist/components/messages/GroupRenderer.js.map +2 -2
- package/dist/components/messages/NestedTasksPreview.js +13 -1
- package/dist/components/messages/NestedTasksPreview.js.map +2 -2
- package/dist/components/messages/ParallelTasksGroupView.js +4 -3
- package/dist/components/messages/ParallelTasksGroupView.js.map +2 -2
- package/dist/components/messages/TaskInModuleView.js +35 -15
- package/dist/components/messages/TaskInModuleView.js.map +2 -2
- package/dist/components/messages/TaskOutputContent.js +9 -6
- package/dist/components/messages/TaskOutputContent.js.map +2 -2
- package/dist/components/messages/UserPromptMessage.js +2 -2
- package/dist/components/messages/UserPromptMessage.js.map +2 -2
- package/dist/constants/colors.js +90 -72
- package/dist/constants/colors.js.map +2 -2
- package/dist/constants/prompts.js +22 -1
- package/dist/constants/prompts.js.map +2 -2
- package/dist/constants/toolInputExamples.js +84 -0
- package/dist/constants/toolInputExamples.js.map +7 -0
- package/dist/core/backupManager.js +321 -0
- package/dist/core/backupManager.js.map +7 -0
- package/dist/core/costTracker.js +9 -18
- package/dist/core/costTracker.js.map +2 -2
- package/dist/core/gitAutoCommit.js +287 -0
- package/dist/core/gitAutoCommit.js.map +7 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +2 -2
- package/dist/core/operationTracker.js +212 -0
- package/dist/core/operationTracker.js.map +7 -0
- package/dist/core/permissions/rules/allowedToolsRule.js +1 -1
- package/dist/core/permissions/rules/allowedToolsRule.js.map +2 -2
- package/dist/core/permissions/rules/autoEscalationRule.js +5 -0
- package/dist/core/permissions/rules/autoEscalationRule.js.map +2 -2
- package/dist/core/permissions/rules/projectBoundaryRule.js +5 -0
- package/dist/core/permissions/rules/projectBoundaryRule.js.map +2 -2
- package/dist/core/permissions/rules/sensitivePathsRule.js +5 -0
- package/dist/core/permissions/rules/sensitivePathsRule.js.map +2 -2
- package/dist/core/tokenStats.js +9 -0
- package/dist/core/tokenStats.js.map +7 -0
- package/dist/core/tokenStatsManager.js +331 -0
- package/dist/core/tokenStatsManager.js.map +7 -0
- package/dist/entrypoints/cli.js +122 -88
- package/dist/entrypoints/cli.js.map +2 -2
- package/dist/hooks/useAgentTokenStats.js +72 -0
- package/dist/hooks/useAgentTokenStats.js.map +7 -0
- package/dist/hooks/useAgentTranscripts.js +30 -6
- package/dist/hooks/useAgentTranscripts.js.map +2 -2
- package/dist/hooks/useLogMessages.js +12 -1
- package/dist/hooks/useLogMessages.js.map +2 -2
- package/dist/i18n/locales/en.js +6 -5
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/zh-CN.js +6 -5
- package/dist/i18n/locales/zh-CN.js.map +2 -2
- package/dist/i18n/types.js.map +1 -1
- package/dist/permissions.js +147 -1
- package/dist/permissions.js.map +2 -2
- package/dist/query.js +78 -4
- package/dist/query.js.map +3 -3
- package/dist/screens/REPL.js +23 -3
- package/dist/screens/REPL.js.map +2 -2
- package/dist/screens/ResumeConversation.js +2 -0
- package/dist/screens/ResumeConversation.js.map +2 -2
- package/dist/services/claude.js +54 -3
- package/dist/services/claude.js.map +2 -2
- package/dist/services/intelligentCompactor.js +1 -1
- package/dist/services/intelligentCompactor.js.map +2 -2
- package/dist/services/mcpClient.js +81 -25
- package/dist/services/mcpClient.js.map +2 -2
- package/dist/services/sandbox/filesystemBoundary.js +58 -17
- package/dist/services/sandbox/filesystemBoundary.js.map +2 -2
- package/dist/services/taskStore.js +205 -0
- package/dist/services/taskStore.js.map +7 -0
- package/dist/tools/AskExpertModelTool/AskExpertModelTool.js +3 -2
- package/dist/tools/AskExpertModelTool/AskExpertModelTool.js.map +2 -2
- package/dist/tools/AskUserQuestionTool/AskUserQuestionTool.js +42 -4
- package/dist/tools/AskUserQuestionTool/AskUserQuestionTool.js.map +2 -2
- package/dist/tools/BashTool/BashTool.js +43 -7
- package/dist/tools/BashTool/BashTool.js.map +2 -2
- package/dist/tools/BashTool/prompt.js +184 -34
- package/dist/tools/BashTool/prompt.js.map +2 -2
- package/dist/tools/FileEditTool/FileEditTool.js +24 -9
- package/dist/tools/FileEditTool/FileEditTool.js.map +2 -2
- package/dist/tools/FileEditTool/prompt.js +10 -4
- package/dist/tools/FileEditTool/prompt.js.map +2 -2
- package/dist/tools/FileEditTool/utils.js +10 -4
- package/dist/tools/FileEditTool/utils.js.map +2 -2
- package/dist/tools/FileReadTool/FileReadTool.js +1 -1
- package/dist/tools/FileReadTool/FileReadTool.js.map +1 -1
- package/dist/tools/FileReadTool/prompt.js +16 -1
- package/dist/tools/FileReadTool/prompt.js.map +2 -2
- package/dist/tools/FileWriteTool/FileWriteTool.js +1 -1
- package/dist/tools/FileWriteTool/FileWriteTool.js.map +1 -1
- package/dist/tools/FileWriteTool/prompt.js +12 -3
- package/dist/tools/FileWriteTool/prompt.js.map +2 -2
- package/dist/tools/GlobTool/prompt.js +12 -1
- package/dist/tools/GlobTool/prompt.js.map +2 -2
- package/dist/tools/GrepTool/GrepTool.js +333 -65
- package/dist/tools/GrepTool/GrepTool.js.map +2 -2
- package/dist/tools/GrepTool/prompt.js +15 -8
- package/dist/tools/GrepTool/prompt.js.map +2 -2
- package/dist/tools/MultiEditTool/prompt.js +5 -3
- package/dist/tools/MultiEditTool/prompt.js.map +2 -2
- package/dist/tools/NotebookEditTool/NotebookEditTool.js +59 -46
- package/dist/tools/NotebookEditTool/NotebookEditTool.js.map +2 -2
- package/dist/tools/NotebookEditTool/prompt.js +1 -1
- package/dist/tools/NotebookEditTool/prompt.js.map +1 -1
- package/dist/tools/PlanModeTool/EnterPlanModeTool.js +3 -2
- package/dist/tools/PlanModeTool/EnterPlanModeTool.js.map +2 -2
- package/dist/tools/PlanModeTool/ExitPlanModeTool.js +3 -2
- package/dist/tools/PlanModeTool/ExitPlanModeTool.js.map +2 -2
- package/dist/tools/PlanModeTool/prompt.js +1 -1
- package/dist/tools/PlanModeTool/prompt.js.map +1 -1
- package/dist/tools/SkillTool/SkillTool.js +4 -3
- package/dist/tools/SkillTool/SkillTool.js.map +2 -2
- package/dist/tools/SkillTool/prompt.js +1 -1
- package/dist/tools/SkillTool/prompt.js.map +1 -1
- package/dist/tools/TaskCreateTool/TaskCreateTool.js +102 -0
- package/dist/tools/TaskCreateTool/TaskCreateTool.js.map +7 -0
- package/dist/tools/TaskCreateTool/prompt.js +47 -0
- package/dist/tools/TaskCreateTool/prompt.js.map +7 -0
- package/dist/tools/TaskGetTool/TaskGetTool.js +115 -0
- package/dist/tools/TaskGetTool/TaskGetTool.js.map +7 -0
- package/dist/tools/TaskGetTool/prompt.js +28 -0
- package/dist/tools/TaskGetTool/prompt.js.map +7 -0
- package/dist/tools/TaskListTool/TaskListTool.js +102 -0
- package/dist/tools/TaskListTool/TaskListTool.js.map +7 -0
- package/dist/tools/TaskListTool/prompt.js +27 -0
- package/dist/tools/TaskListTool/prompt.js.map +7 -0
- package/dist/tools/TaskOutputTool/TaskOutputTool.js +3 -2
- package/dist/tools/TaskOutputTool/TaskOutputTool.js.map +2 -2
- package/dist/tools/TaskStopTool/TaskStopTool.js +150 -0
- package/dist/tools/TaskStopTool/TaskStopTool.js.map +7 -0
- package/dist/tools/TaskStopTool/prompt.js +15 -0
- package/dist/tools/TaskStopTool/prompt.js.map +7 -0
- package/dist/tools/TaskTool/TaskTool.js +49 -1
- package/dist/tools/TaskTool/TaskTool.js.map +2 -2
- package/dist/tools/TaskUpdateTool/TaskUpdateTool.js +134 -0
- package/dist/tools/TaskUpdateTool/TaskUpdateTool.js.map +7 -0
- package/dist/tools/TaskUpdateTool/prompt.js +81 -0
- package/dist/tools/TaskUpdateTool/prompt.js.map +7 -0
- package/dist/tools/URLFetcherTool/prompt.js +1 -1
- package/dist/tools/URLFetcherTool/prompt.js.map +1 -1
- package/dist/tools.js +12 -0
- package/dist/tools.js.map +2 -2
- package/dist/utils/CircuitBreaker.js +242 -0
- package/dist/utils/CircuitBreaker.js.map +7 -0
- package/dist/utils/ask.js +2 -0
- package/dist/utils/ask.js.map +2 -2
- package/dist/utils/config.js +47 -5
- package/dist/utils/config.js.map +2 -2
- package/dist/utils/credentials/CredentialStore.js +1 -0
- package/dist/utils/credentials/CredentialStore.js.map +7 -0
- package/dist/utils/credentials/EncryptedFileStore.js +157 -0
- package/dist/utils/credentials/EncryptedFileStore.js.map +7 -0
- package/dist/utils/credentials/index.js +37 -0
- package/dist/utils/credentials/index.js.map +7 -0
- package/dist/utils/credentials/migration.js +82 -0
- package/dist/utils/credentials/migration.js.map +7 -0
- package/dist/utils/markdown.js +13 -1
- package/dist/utils/markdown.js.map +2 -2
- package/dist/utils/model.js +15 -2
- package/dist/utils/model.js.map +2 -2
- package/dist/utils/permissions/filesystem.js +5 -1
- package/dist/utils/permissions/filesystem.js.map +2 -2
- package/dist/utils/ripgrep.js +53 -1
- package/dist/utils/ripgrep.js.map +2 -2
- package/dist/utils/safePath.js +132 -0
- package/dist/utils/safePath.js.map +7 -0
- package/dist/utils/sensitiveFiles.js +125 -0
- package/dist/utils/sensitiveFiles.js.map +7 -0
- package/dist/utils/taskDisplayUtils.js +9 -9
- package/dist/utils/taskDisplayUtils.js.map +2 -2
- package/dist/utils/terminal.js +12 -0
- package/dist/utils/terminal.js.map +2 -2
- package/dist/utils/theme.js +6 -6
- package/dist/utils/theme.js.map +1 -1
- package/dist/utils/toolRiskClassification.js +207 -0
- package/dist/utils/toolRiskClassification.js.map +7 -0
- package/dist/utils/tooling/safeRender.js +17 -17
- package/dist/utils/tooling/safeRender.js.map +2 -2
- package/dist/version.js +2 -2
- package/dist/version.js.map +1 -1
- package/package.json +22 -28
- package/dist/hooks/useCancelRequest.js +0 -31
- package/dist/hooks/useCancelRequest.js.map +0 -7
|
@@ -16,21 +16,24 @@ import { DESCRIPTION, PROMPT } from "./prompt.js";
|
|
|
16
16
|
import { hasWritePermission } from "../../utils/permissions/filesystem.js";
|
|
17
17
|
import { emitReminderEvent } from "../../services/systemReminder.js";
|
|
18
18
|
import { recordFileEdit } from "../../services/fileFreshness.js";
|
|
19
|
+
import { FileEditTool } from "../FileEditTool/FileEditTool.js";
|
|
19
20
|
const inputSchema = z.strictObject({
|
|
20
21
|
notebook_path: z.string().describe(
|
|
21
22
|
"The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)"
|
|
22
23
|
),
|
|
23
|
-
|
|
24
|
+
cell_id: z.string().optional().describe(
|
|
25
|
+
"The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified."
|
|
26
|
+
),
|
|
24
27
|
new_source: z.string().describe("The new source for the cell"),
|
|
25
28
|
cell_type: z.enum(["code", "markdown"]).optional().describe(
|
|
26
29
|
"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."
|
|
27
30
|
),
|
|
28
|
-
edit_mode: z.
|
|
31
|
+
edit_mode: z.enum(["replace", "insert", "delete"]).optional().describe(
|
|
29
32
|
"The type of edit to make (replace, insert, delete). Defaults to replace."
|
|
30
33
|
)
|
|
31
34
|
});
|
|
32
35
|
const NotebookEditTool = {
|
|
33
|
-
name: "
|
|
36
|
+
name: "NotebookEdit",
|
|
34
37
|
async description() {
|
|
35
38
|
return DESCRIPTION;
|
|
36
39
|
},
|
|
@@ -53,21 +56,21 @@ const NotebookEditTool = {
|
|
|
53
56
|
needsPermissions({ notebook_path }) {
|
|
54
57
|
return !hasWritePermission(notebook_path);
|
|
55
58
|
},
|
|
56
|
-
renderResultForAssistant({
|
|
59
|
+
renderResultForAssistant({ cell_id, edit_mode, new_source, error }) {
|
|
57
60
|
if (error) {
|
|
58
61
|
return error;
|
|
59
62
|
}
|
|
60
63
|
switch (edit_mode) {
|
|
61
64
|
case "replace":
|
|
62
|
-
return `Updated cell ${
|
|
65
|
+
return `Updated cell ${cell_id} with ${new_source}`;
|
|
63
66
|
case "insert":
|
|
64
|
-
return `Inserted cell ${
|
|
67
|
+
return `Inserted cell after ${cell_id || "beginning"} with ${new_source}`;
|
|
65
68
|
case "delete":
|
|
66
|
-
return `Deleted cell ${
|
|
69
|
+
return `Deleted cell ${cell_id}`;
|
|
67
70
|
}
|
|
68
71
|
},
|
|
69
72
|
renderToolUseMessage(input, { verbose }) {
|
|
70
|
-
return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)},
|
|
73
|
+
return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}, cell_id: ${input.cell_id || "(beginning)"}, content: ${input.new_source.slice(0, 30)}\u2026, cell_type: ${input.cell_type}, edit_mode: ${input.edit_mode ?? "replace"}`;
|
|
71
74
|
},
|
|
72
75
|
renderToolUseRejectedMessage() {
|
|
73
76
|
return /* @__PURE__ */ React.createElement(FallbackToolUseRejectedMessage, null);
|
|
@@ -76,15 +79,15 @@ const NotebookEditTool = {
|
|
|
76
79
|
if (!output) {
|
|
77
80
|
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, "Notebook cell updated"));
|
|
78
81
|
}
|
|
79
|
-
const {
|
|
82
|
+
const { cell_id, new_source, language, error } = output;
|
|
80
83
|
if (error) {
|
|
81
84
|
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, { color: "red" }, error));
|
|
82
85
|
}
|
|
83
|
-
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, "Updated cell ",
|
|
86
|
+
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, "Updated cell ", cell_id, ":"), /* @__PURE__ */ React.createElement(Box, { marginLeft: 2 }, /* @__PURE__ */ React.createElement(HighlightedCode, { code: new_source, language })));
|
|
84
87
|
},
|
|
85
88
|
async validateInput({
|
|
86
89
|
notebook_path,
|
|
87
|
-
|
|
90
|
+
cell_id,
|
|
88
91
|
cell_type,
|
|
89
92
|
edit_mode = "replace"
|
|
90
93
|
}) {
|
|
@@ -98,19 +101,7 @@ const NotebookEditTool = {
|
|
|
98
101
|
if (extname(fullPath) !== ".ipynb") {
|
|
99
102
|
return {
|
|
100
103
|
result: false,
|
|
101
|
-
message:
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if (cell_number < 0) {
|
|
105
|
-
return {
|
|
106
|
-
result: false,
|
|
107
|
-
message: "Cell number must be non-negative."
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
if (edit_mode !== "replace" && edit_mode !== "insert" && edit_mode !== "delete") {
|
|
111
|
-
return {
|
|
112
|
-
result: false,
|
|
113
|
-
message: "Edit mode must be replace, insert, or delete."
|
|
104
|
+
message: `File must be a Jupyter notebook (.ipynb file). For editing other file types, use the ${FileEditTool.name} tool.`
|
|
114
105
|
};
|
|
115
106
|
}
|
|
116
107
|
if (edit_mode === "insert" && !cell_type) {
|
|
@@ -128,48 +119,70 @@ const NotebookEditTool = {
|
|
|
128
119
|
message: "Notebook is not valid JSON."
|
|
129
120
|
};
|
|
130
121
|
}
|
|
131
|
-
if (edit_mode === "
|
|
132
|
-
return {
|
|
133
|
-
result: false,
|
|
134
|
-
message: `Cell number is out of bounds. For insert mode, the maximum value is ${notebook.cells.length} (to append at the end).`
|
|
135
|
-
};
|
|
136
|
-
} else if ((edit_mode === "replace" || edit_mode === "delete") && (cell_number >= notebook.cells.length || !notebook.cells[cell_number])) {
|
|
122
|
+
if ((edit_mode === "replace" || edit_mode === "delete") && !cell_id) {
|
|
137
123
|
return {
|
|
138
124
|
result: false,
|
|
139
|
-
message:
|
|
125
|
+
message: "cell_id is required for replace and delete operations."
|
|
140
126
|
};
|
|
141
127
|
}
|
|
128
|
+
if (cell_id) {
|
|
129
|
+
const cellIndex = notebook.cells.findIndex(
|
|
130
|
+
(cell, index) => cell.id === cell_id || String(index) === cell_id
|
|
131
|
+
);
|
|
132
|
+
if (cellIndex === -1 && edit_mode !== "insert") {
|
|
133
|
+
return {
|
|
134
|
+
result: false,
|
|
135
|
+
message: `Cell with ID '${cell_id}' not found in notebook. Available cells: ${notebook.cells.length}`
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
142
139
|
return { result: true };
|
|
143
140
|
},
|
|
144
|
-
async *call({
|
|
145
|
-
notebook_path,
|
|
146
|
-
cell_number,
|
|
147
|
-
new_source,
|
|
148
|
-
cell_type,
|
|
149
|
-
edit_mode
|
|
150
|
-
}) {
|
|
141
|
+
async *call({ notebook_path, cell_id, new_source, cell_type, edit_mode }) {
|
|
151
142
|
const fullPath = isAbsolute(notebook_path) ? notebook_path : resolve(getCwd(), notebook_path);
|
|
152
143
|
try {
|
|
153
144
|
const enc = detectFileEncoding(fullPath);
|
|
154
145
|
const content = readFileSync(fullPath, enc);
|
|
155
146
|
const notebook = JSON.parse(content);
|
|
156
147
|
const language = notebook.metadata.language_info?.name ?? "python";
|
|
148
|
+
const findCellIndex = (id) => {
|
|
149
|
+
if (!id) return 0;
|
|
150
|
+
const byId = notebook.cells.findIndex(
|
|
151
|
+
(cell) => cell.id === id
|
|
152
|
+
);
|
|
153
|
+
if (byId !== -1) return byId;
|
|
154
|
+
const numIndex = parseInt(id, 10);
|
|
155
|
+
if (!isNaN(numIndex) && numIndex >= 0 && numIndex < notebook.cells.length) {
|
|
156
|
+
return numIndex;
|
|
157
|
+
}
|
|
158
|
+
return -1;
|
|
159
|
+
};
|
|
160
|
+
const cellIndex = findCellIndex(cell_id);
|
|
157
161
|
if (edit_mode === "delete") {
|
|
158
|
-
|
|
162
|
+
if (cellIndex === -1) {
|
|
163
|
+
throw new Error(`Cell with ID '${cell_id}' not found`);
|
|
164
|
+
}
|
|
165
|
+
notebook.cells.splice(cellIndex, 1);
|
|
159
166
|
} else if (edit_mode === "insert") {
|
|
167
|
+
const insertIndex = cell_id ? cellIndex + 1 : 0;
|
|
168
|
+
const newCellId = `cell-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
160
169
|
const new_cell = {
|
|
170
|
+
id: newCellId,
|
|
161
171
|
cell_type,
|
|
162
172
|
// validateInput ensures cell_type is not undefined
|
|
163
173
|
source: new_source,
|
|
164
174
|
metadata: {}
|
|
165
175
|
};
|
|
166
176
|
notebook.cells.splice(
|
|
167
|
-
|
|
177
|
+
insertIndex,
|
|
168
178
|
0,
|
|
169
|
-
cell_type
|
|
179
|
+
cell_type === "markdown" ? new_cell : { ...new_cell, outputs: [] }
|
|
170
180
|
);
|
|
171
181
|
} else {
|
|
172
|
-
|
|
182
|
+
if (cellIndex === -1) {
|
|
183
|
+
throw new Error(`Cell with ID '${cell_id}' not found`);
|
|
184
|
+
}
|
|
185
|
+
const targetCell = notebook.cells[cellIndex];
|
|
173
186
|
targetCell.source = new_source;
|
|
174
187
|
targetCell.execution_count = void 0;
|
|
175
188
|
targetCell.outputs = [];
|
|
@@ -183,7 +196,7 @@ const NotebookEditTool = {
|
|
|
183
196
|
recordFileEdit(fullPath, updatedNotebook);
|
|
184
197
|
emitReminderEvent("file:edited", {
|
|
185
198
|
filePath: fullPath,
|
|
186
|
-
|
|
199
|
+
cellId: cell_id,
|
|
187
200
|
newSource: new_source,
|
|
188
201
|
cellType: cell_type,
|
|
189
202
|
editMode: edit_mode || "replace",
|
|
@@ -191,7 +204,7 @@ const NotebookEditTool = {
|
|
|
191
204
|
operation: "notebook_edit"
|
|
192
205
|
});
|
|
193
206
|
const data = {
|
|
194
|
-
|
|
207
|
+
cell_id: cell_id || "0",
|
|
195
208
|
new_source,
|
|
196
209
|
cell_type: cell_type ?? "code",
|
|
197
210
|
language,
|
|
@@ -206,7 +219,7 @@ const NotebookEditTool = {
|
|
|
206
219
|
} catch (error) {
|
|
207
220
|
if (error instanceof Error) {
|
|
208
221
|
const data2 = {
|
|
209
|
-
|
|
222
|
+
cell_id: cell_id || "0",
|
|
210
223
|
new_source,
|
|
211
224
|
cell_type: cell_type ?? "code",
|
|
212
225
|
language: "python",
|
|
@@ -221,7 +234,7 @@ const NotebookEditTool = {
|
|
|
221
234
|
return;
|
|
222
235
|
}
|
|
223
236
|
const data = {
|
|
224
|
-
|
|
237
|
+
cell_id: cell_id || "0",
|
|
225
238
|
new_source,
|
|
226
239
|
cell_type: cell_type ?? "code",
|
|
227
240
|
language: "python",
|
|
@@ -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(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;
|
|
4
|
+
"sourcesContent": ["import { existsSync, readFileSync } from 'fs'\nimport { Box, Text } from 'ink'\nimport { extname, isAbsolute, relative, resolve } from 'path'\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { FallbackToolUseRejectedMessage } from '@components/FallbackToolUseRejectedMessage'\nimport { HighlightedCode } from '@components/HighlightedCode'\nimport type { Tool } from '@tool'\nimport { NotebookCellType, NotebookContent } from '@minto-types/notebook'\nimport {\n detectFileEncoding,\n detectLineEndings,\n writeTextContent,\n} from '@utils/file'\nimport { safeParseJSON } from '@utils/json'\nimport { getCwd } from '@utils/state'\nimport { DESCRIPTION, PROMPT } from './prompt'\nimport { hasWritePermission } from '@utils/permissions/filesystem'\nimport { emitReminderEvent } from '@services/systemReminder'\nimport { recordFileEdit } from '@services/fileFreshness'\nimport { FileEditTool } from '@tools/FileEditTool/FileEditTool'\n\nconst inputSchema = z.strictObject({\n notebook_path: z\n .string()\n .describe(\n 'The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)',\n ),\n cell_id: z\n .string()\n .optional()\n .describe(\n 'The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified.',\n ),\n new_source: z.string().describe('The new source for the cell'),\n cell_type: z\n .enum(['code', 'markdown'])\n .optional()\n .describe(\n 'The type of the cell (code or markdown). If not specified, it defaults to the current cell type. If using edit_mode=insert, this is required.',\n ),\n edit_mode: z\n .enum(['replace', 'insert', 'delete'])\n .optional()\n .describe(\n 'The type of edit to make (replace, insert, delete). Defaults to replace.',\n ),\n})\n\nexport const NotebookEditTool = {\n name: 'NotebookEdit',\n async description() {\n return DESCRIPTION\n },\n async prompt() {\n return PROMPT\n },\n inputSchema,\n userFacingName() {\n return 'Edit Notebook'\n },\n async isEnabled() {\n return true\n },\n isReadOnly() {\n return false\n },\n isConcurrencySafe() {\n return false // NotebookEditTool modifies state/files, not safe for concurrent execution\n },\n needsPermissions({ notebook_path }) {\n return !hasWritePermission(notebook_path)\n },\n renderResultForAssistant({ cell_id, edit_mode, new_source, error }) {\n if (error) {\n return error\n }\n switch (edit_mode) {\n case 'replace':\n return `Updated cell ${cell_id} with ${new_source}`\n case 'insert':\n return `Inserted cell after ${cell_id || 'beginning'} with ${new_source}`\n case 'delete':\n return `Deleted cell ${cell_id}`\n }\n },\n renderToolUseMessage(input, { verbose }) {\n return `notebook_path: ${verbose ? input.notebook_path : relative(getCwd(), input.notebook_path)}, cell_id: ${input.cell_id || '(beginning)'}, content: ${input.new_source.slice(0, 30)}\u2026, cell_type: ${input.cell_type}, edit_mode: ${input.edit_mode ?? 'replace'}`\n },\n renderToolUseRejectedMessage() {\n return <FallbackToolUseRejectedMessage />\n },\n renderToolResultMessage(output) {\n // Guard against undefined or null output\n if (!output) {\n return (\n <Box flexDirection=\"column\">\n <Text>Notebook cell updated</Text>\n </Box>\n )\n }\n\n const { cell_id, new_source, language, error } = output\n\n if (error) {\n return (\n <Box flexDirection=\"column\">\n <Text color=\"red\">{error}</Text>\n </Box>\n )\n }\n\n return (\n <Box flexDirection=\"column\">\n <Text>Updated cell {cell_id}:</Text>\n <Box marginLeft={2}>\n <HighlightedCode code={new_source} language={language} />\n </Box>\n </Box>\n )\n },\n async validateInput({\n notebook_path,\n cell_id,\n cell_type,\n edit_mode = 'replace',\n }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n if (!existsSync(fullPath)) {\n return {\n result: false,\n message: 'Notebook file does not exist.',\n }\n }\n\n if (extname(fullPath) !== '.ipynb') {\n return {\n result: false,\n message: `File must be a Jupyter notebook (.ipynb file). For editing other file types, use the ${FileEditTool.name} tool.`,\n }\n }\n\n if (edit_mode === 'insert' && !cell_type) {\n return {\n result: false,\n message: 'Cell type is required when using edit_mode=insert.',\n }\n }\n\n const enc = detectFileEncoding(fullPath)\n const content = readFileSync(fullPath, enc)\n const notebook = safeParseJSON(content) as NotebookContent | null\n if (!notebook) {\n return {\n result: false,\n message: 'Notebook is not valid JSON.',\n }\n }\n\n // For replace and delete, cell_id is required and must exist\n if ((edit_mode === 'replace' || edit_mode === 'delete') && !cell_id) {\n return {\n result: false,\n message: 'cell_id is required for replace and delete operations.',\n }\n }\n\n // Validate cell_id exists in notebook (if provided)\n if (cell_id) {\n const cellIndex = notebook.cells.findIndex(\n (cell: { id?: string }, index: number) =>\n cell.id === cell_id || String(index) === cell_id,\n )\n if (cellIndex === -1 && edit_mode !== 'insert') {\n return {\n result: false,\n message: `Cell with ID '${cell_id}' not found in notebook. Available cells: ${notebook.cells.length}`,\n }\n }\n }\n\n return { result: true }\n },\n async *call({ notebook_path, cell_id, new_source, cell_type, edit_mode }) {\n const fullPath = isAbsolute(notebook_path)\n ? notebook_path\n : resolve(getCwd(), notebook_path)\n\n try {\n const enc = detectFileEncoding(fullPath)\n const content = readFileSync(fullPath, enc)\n const notebook = JSON.parse(content) as NotebookContent\n const language = notebook.metadata.language_info?.name ?? 'python'\n\n // Find cell index by ID (or treat cell_id as index string for backward compatibility)\n const findCellIndex = (id: string | undefined): number => {\n if (!id) return 0 // Insert at beginning if no cell_id\n const byId = notebook.cells.findIndex(\n (cell: { id?: string }) => cell.id === id,\n )\n if (byId !== -1) return byId\n // Fallback: treat as numeric index for backward compatibility\n const numIndex = parseInt(id, 10)\n if (\n !isNaN(numIndex) &&\n numIndex >= 0 &&\n numIndex < notebook.cells.length\n ) {\n return numIndex\n }\n return -1\n }\n\n const cellIndex = findCellIndex(cell_id)\n\n if (edit_mode === 'delete') {\n // Delete the specified cell\n if (cellIndex === -1) {\n throw new Error(`Cell with ID '${cell_id}' not found`)\n }\n notebook.cells.splice(cellIndex, 1)\n } else if (edit_mode === 'insert') {\n // Insert the new cell after the specified cell (or at beginning if no cell_id)\n const insertIndex = cell_id ? cellIndex + 1 : 0\n const newCellId = `cell-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`\n const new_cell = {\n id: newCellId,\n cell_type: cell_type!, // validateInput ensures cell_type is not undefined\n source: new_source,\n metadata: {},\n }\n notebook.cells.splice(\n insertIndex,\n 0,\n cell_type === 'markdown' ? new_cell : { ...new_cell, outputs: [] },\n )\n } else {\n // Replace: Find the specified cell\n if (cellIndex === -1) {\n throw new Error(`Cell with ID '${cell_id}' not found`)\n }\n const targetCell = notebook.cells[cellIndex]!\n targetCell.source = new_source\n // Reset execution count and clear outputs since cell was modified\n targetCell.execution_count = undefined\n targetCell.outputs = []\n if (cell_type && cell_type !== targetCell.cell_type) {\n targetCell.cell_type = cell_type\n }\n }\n // Write back to file\n const endings = detectLineEndings(fullPath)\n const updatedNotebook = JSON.stringify(notebook, null, 1)\n writeTextContent(fullPath, updatedNotebook, enc, endings!)\n\n // Record Agent edit operation for file freshness tracking\n recordFileEdit(fullPath, updatedNotebook)\n\n // Emit file edited event for system reminders\n emitReminderEvent('file:edited', {\n filePath: fullPath,\n cellId: cell_id,\n newSource: new_source,\n cellType: cell_type,\n editMode: edit_mode || 'replace',\n timestamp: Date.now(),\n operation: 'notebook_edit',\n })\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language,\n edit_mode: edit_mode ?? 'replace',\n error: '',\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n } catch (error) {\n if (error instanceof Error) {\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language: 'python',\n edit_mode: 'replace',\n error: error.message,\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n return\n }\n const data = {\n cell_id: cell_id || '0',\n new_source,\n cell_type: cell_type ?? 'code',\n language: 'python',\n edit_mode: 'replace',\n error: 'Unknown error occurred while editing notebook',\n }\n yield {\n type: 'result',\n data,\n resultForAssistant: this.renderResultForAssistant(data),\n }\n }\n },\n} satisfies Tool<\n typeof inputSchema,\n {\n cell_id: string\n new_source: string\n cell_type: NotebookCellType\n language: string\n edit_mode: string\n error?: string\n }\n>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,KAAK,YAAY;AAC1B,SAAS,SAAS,YAAY,UAAU,eAAe;AACvD,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,sCAAsC;AAC/C,SAAS,uBAAuB;AAGhC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,aAAa,cAAc;AACpC,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAE7B,MAAM,cAAc,EAAE,aAAa;AAAA,EACjC,eAAe,EACZ,OAAO,EACP;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAAS,EACN,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,YAAY,EAAE,OAAO,EAAE,SAAS,6BAA6B;AAAA,EAC7D,WAAW,EACR,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW,EACR,KAAK,CAAC,WAAW,UAAU,QAAQ,CAAC,EACpC,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC;AAEM,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,SAAS;AACb,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EACA,iBAA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|
1
1
|
const DESCRIPTION = "Replace the contents of a specific cell in a Jupyter notebook.";
|
|
2
|
-
const PROMPT = `Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source. Jupyter notebooks are interactive documents that combine code, text, and visualizations, commonly used for data analysis and scientific computing. The notebook_path parameter must be an absolute path, not a relative path. The
|
|
2
|
+
const PROMPT = `Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source. Jupyter notebooks are interactive documents that combine code, text, and visualizations, commonly used for data analysis and scientific computing. The notebook_path parameter must be an absolute path, not a relative path. The cell_id is the ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified. Use edit_mode=insert to add a new cell at the index specified by cell_id. Use edit_mode=delete to delete the cell at the index specified by cell_id.`;
|
|
3
3
|
export {
|
|
4
4
|
DESCRIPTION,
|
|
5
5
|
PROMPT
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/tools/NotebookEditTool/prompt.ts"],
|
|
4
|
-
"sourcesContent": ["export const DESCRIPTION =\n 'Replace the contents of a specific cell in a Jupyter notebook.'\nexport const PROMPT = `Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source. Jupyter notebooks are interactive documents that combine code, text, and visualizations, commonly used for data analysis and scientific computing. The notebook_path parameter must be an absolute path, not a relative path. The
|
|
4
|
+
"sourcesContent": ["export const DESCRIPTION =\n 'Replace the contents of a specific cell in a Jupyter notebook.'\nexport const PROMPT = `Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source. Jupyter notebooks are interactive documents that combine code, text, and visualizations, commonly used for data analysis and scientific computing. The notebook_path parameter must be an absolute path, not a relative path. The cell_id is the ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified. Use edit_mode=insert to add a new cell at the index specified by cell_id. Use edit_mode=delete to delete the cell at the index specified by cell_id.`\n"],
|
|
5
5
|
"mappings": "AAAO,MAAM,cACX;AACK,MAAM,SAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { enterPlanMode } from "../../utils/plan/planMode.js";
|
|
5
5
|
import { ENTER_DESCRIPTION, ENTER_PROMPT, ENTER_TOOL_NAME } from "./prompt.js";
|
|
6
|
+
import { SEMANTIC_COLORS } from "../../constants/colors.js";
|
|
6
7
|
const inputSchema = z.strictObject({});
|
|
7
8
|
const EnterPlanModeTool = {
|
|
8
9
|
name: ENTER_TOOL_NAME,
|
|
@@ -35,10 +36,10 @@ const EnterPlanModeTool = {
|
|
|
35
36
|
return "";
|
|
36
37
|
},
|
|
37
38
|
renderToolUseRejectedMessage() {
|
|
38
|
-
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "row", marginTop: 1 }, /* @__PURE__ */ React.createElement(Text, {
|
|
39
|
+
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "row", marginTop: 1 }, /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, "User declined to enter plan mode"));
|
|
39
40
|
},
|
|
40
41
|
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, {
|
|
42
|
+
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, { color: SEMANTIC_COLORS.dim }, "Minto is now exploring and designing an implementation approach.")));
|
|
42
43
|
},
|
|
43
44
|
renderResultForAssistant(output) {
|
|
44
45
|
return `${output.message}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/tools/PlanModeTool/EnterPlanModeTool.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * Enter Plan Mode Tool\n *\n * Requests permission to enter plan mode for complex tasks.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport { enterPlanMode } from '@utils/plan/planMode'\nimport { ENTER_DESCRIPTION, ENTER_PROMPT, ENTER_TOOL_NAME } from './prompt'\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
|
|
5
|
-
"mappings": "AAMA,SAAS,KAAK,YAAY;AAC1B,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB,cAAc,uBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * Enter Plan Mode Tool\n *\n * Requests permission to enter plan mode for complex tasks.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport { enterPlanMode } from '@utils/plan/planMode'\nimport { ENTER_DESCRIPTION, ENTER_PROMPT, ENTER_TOOL_NAME } from './prompt'\nimport { SEMANTIC_COLORS } from '@constants/colors'\n\nconst inputSchema = z.strictObject({})\n\ntype Output = {\n message: string\n}\n\nexport const EnterPlanModeTool = {\n name: ENTER_TOOL_NAME,\n async description() {\n return ENTER_DESCRIPTION\n },\n userFacingName() {\n return ''\n },\n inputSchema,\n isReadOnly() {\n return true\n },\n isConcurrencySafe() {\n return true\n },\n async isEnabled() {\n return true\n },\n needsPermissions() {\n return true\n },\n requiresUserInteraction() {\n return true\n },\n async prompt() {\n return ENTER_PROMPT\n },\n renderToolUseMessage() {\n return ''\n },\n renderToolUseRejectedMessage() {\n return (\n <Box flexDirection=\"row\" marginTop={1}>\n <Text color={SEMANTIC_COLORS.dim}>\n User declined to enter plan mode\n </Text>\n </Box>\n )\n },\n renderToolResultMessage(_output: Output) {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box flexDirection=\"row\">\n <Text color=\"cyan\">\u25CF</Text>\n <Text> Entered plan mode</Text>\n </Box>\n <Box paddingLeft={2}>\n <Text color={SEMANTIC_COLORS.dim}>\n Minto is now exploring and designing an implementation approach.\n </Text>\n </Box>\n </Box>\n )\n },\n renderResultForAssistant(output: Output) {\n return `${output.message}\n\nIn plan mode, you should:\n1. Thoroughly explore the codebase to understand existing patterns\n2. Identify similar features and architectural approaches\n3. Consider multiple approaches and their trade-offs\n4. Use AskUserQuestion if you need to clarify the approach\n5. Design a concrete implementation strategy\n6. When ready, use ExitPlanMode to present your plan for approval\n\nRemember: DO NOT write or edit any files yet. This is a read-only exploration and planning phase.`\n },\n async *call(_input: z.infer<typeof inputSchema>, context: any) {\n if (context?.agentId) {\n throw new Error('EnterPlanMode tool cannot be used in agent contexts')\n }\n\n enterPlanMode(context)\n\n const output: Output = {\n message:\n 'Entered plan mode. You should now focus on exploring the codebase and designing an implementation approach.',\n }\n yield {\n type: 'result',\n data: output,\n resultForAssistant: this.renderResultForAssistant(output),\n }\n },\n} satisfies Tool<typeof inputSchema, Output>\n"],
|
|
5
|
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AAqD;AAAA,IACvE;AAEA,kBAAc,OAAO;AAErB,UAAM,SAAiB;AAAA,MACrB,SACE;AAAA,IACJ;AACA,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,oBAAoB,KAAK,yBAAyB,MAAM;AAAA,IAC1D;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
readPlanFile
|
|
8
8
|
} from "../../utils/plan/planMode.js";
|
|
9
9
|
import { EXIT_DESCRIPTION, EXIT_PROMPT, EXIT_TOOL_NAME } from "./prompt.js";
|
|
10
|
+
import { SEMANTIC_COLORS } from "../../constants/colors.js";
|
|
10
11
|
function getExitPlanModePlanText(conversationKey) {
|
|
11
12
|
const { content } = readPlanFile(void 0, conversationKey);
|
|
12
13
|
return content || "No plan found. Please write your plan to the plan file first.";
|
|
@@ -54,7 +55,7 @@ const ExitPlanModeTool = {
|
|
|
54
55
|
paddingX: 1,
|
|
55
56
|
overflow: "hidden"
|
|
56
57
|
},
|
|
57
|
-
/* @__PURE__ */ React.createElement(Text, {
|
|
58
|
+
/* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, plan)
|
|
58
59
|
))));
|
|
59
60
|
},
|
|
60
61
|
renderToolResultMessage(output) {
|
|
@@ -63,7 +64,7 @@ const ExitPlanModeTool = {
|
|
|
63
64
|
}
|
|
64
65
|
const planPath = typeof output.filePath === "string" ? output.filePath : null;
|
|
65
66
|
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, {
|
|
67
|
+
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, { color: SEMANTIC_COLORS.dim }, "Plan saved to: ", planPath) : null, /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, plan.substring(0, 200), "..."))));
|
|
67
68
|
},
|
|
68
69
|
renderResultForAssistant(output) {
|
|
69
70
|
if (!output) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/tools/PlanModeTool/ExitPlanModeTool.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * Exit Plan Mode Tool\n *\n * Prompts the user to exit plan mode and start coding.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport {\n getPlanConversationKey,\n getPlanFilePath,\n readPlanFile,\n} from '@utils/plan/planMode'\nimport { EXIT_DESCRIPTION, EXIT_PROMPT, EXIT_TOOL_NAME } from './prompt'\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> \u23BF </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
|
|
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;
|
|
4
|
+
"sourcesContent": ["/**\n * Exit Plan Mode Tool\n *\n * Prompts the user to exit plan mode and start coding.\n */\n\nimport { Box, Text } from 'ink'\nimport React from 'react'\nimport { z } from 'zod'\nimport { Tool } from '@tool'\nimport {\n getPlanConversationKey,\n getPlanFilePath,\n readPlanFile,\n} from '@utils/plan/planMode'\nimport { EXIT_DESCRIPTION, EXIT_PROMPT, EXIT_TOOL_NAME } from './prompt'\nimport { SEMANTIC_COLORS } from '@constants/colors'\n\nfunction getExitPlanModePlanText(conversationKey?: string): string {\n const { content } = readPlanFile(undefined, conversationKey)\n return (\n content || 'No plan found. Please write your plan to the plan file first.'\n )\n}\n\nconst inputSchema = z.strictObject({}).passthrough()\n\ntype Output = {\n plan: string\n isAgent: boolean\n filePath?: string\n}\n\nexport const ExitPlanModeTool = {\n name: EXIT_TOOL_NAME,\n async description() {\n return EXIT_DESCRIPTION\n },\n userFacingName() {\n return ''\n },\n inputSchema,\n isReadOnly() {\n return false\n },\n isConcurrencySafe() {\n return true\n },\n async isEnabled() {\n return true\n },\n needsPermissions() {\n return true\n },\n requiresUserInteraction() {\n return true\n },\n async prompt() {\n return EXIT_PROMPT\n },\n renderToolUseMessage() {\n return ''\n },\n renderToolUseRejectedMessage(\n _input: z.infer<typeof inputSchema>,\n options: { conversationKey?: string } = {},\n ) {\n const conversationKey =\n typeof options.conversationKey === 'string' &&\n options.conversationKey.trim()\n ? options.conversationKey.trim()\n : undefined\n\n const plan = getExitPlanModePlanText(conversationKey)\n\n return (\n <Box flexDirection=\"column\" marginTop={1} width=\"100%\">\n <Box flexDirection=\"row\">\n <Text> \u23BF </Text>\n <Box flexDirection=\"column\" width=\"100%\">\n <Text color=\"red\">User rejected the plan:</Text>\n <Box\n borderStyle=\"round\"\n borderColor=\"cyan\"\n borderDimColor\n paddingX={1}\n overflow=\"hidden\"\n >\n <Text color={SEMANTIC_COLORS.dim}>{plan}</Text>\n </Box>\n </Box>\n </Box>\n </Box>\n )\n },\n renderToolResultMessage(output: Output) {\n if (!output) {\n return (\n <Box paddingLeft={2}>\n <Text>Plan mode completed</Text>\n </Box>\n )\n }\n\n const planPath =\n typeof output.filePath === 'string' ? output.filePath : null\n const plan = output.plan || 'No plan found'\n\n return (\n <Box flexDirection=\"column\" marginTop={1} width=\"100%\">\n <Box flexDirection=\"row\">\n <Text color=\"cyan\">\u25CF</Text>\n <Text> User approved the plan</Text>\n </Box>\n <Box flexDirection=\"row\">\n <Text> \u23BF </Text>\n <Box flexDirection=\"column\">\n {planPath ? (\n <Text color={SEMANTIC_COLORS.dim}>Plan saved to: {planPath}</Text>\n ) : null}\n <Text color={SEMANTIC_COLORS.dim}>{plan.substring(0, 200)}...</Text>\n </Box>\n </Box>\n </Box>\n )\n },\n renderResultForAssistant(output: Output) {\n if (!output) {\n return 'Plan mode completed'\n }\n\n if (output.isAgent) {\n return 'User has approved the plan. There is nothing else needed from you now. Please respond with \"ok\"'\n }\n\n return `User has approved your plan. You can now start coding. Start with updating your todo list if applicable\n\nYour plan has been saved to: ${output.filePath}\nYou can refer back to it if needed during implementation.\n\n## Approved Plan:\n${output.plan}`\n },\n async *call(input: z.infer<typeof inputSchema>, context: any) {\n const conversationKey = getPlanConversationKey(context)\n const planFilePath = getPlanFilePath(context?.agentId, conversationKey)\n const { content, exists } = readPlanFile(context?.agentId, conversationKey)\n\n if (!exists) {\n throw new Error(\n `No plan file found at ${planFilePath}. Please write your plan to this file before calling ExitPlanMode.`,\n )\n }\n\n const isAgent = !!context?.agentId\n const output: Output = {\n plan: content,\n isAgent,\n filePath: planFilePath,\n }\n yield {\n type: 'result',\n data: output,\n resultForAssistant: this.renderResultForAssistant(output),\n }\n },\n} satisfies Tool<typeof inputSchema, Output>\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,KAAK,YAAY;AAC1B,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB,aAAa,sBAAsB;AAC9D,SAAS,uBAAuB;AAEhC,SAAS,wBAAwB,iBAAkC;AACjE,QAAM,EAAE,QAAQ,IAAI,aAAa,QAAW,eAAe;AAC3D,SACE,WAAW;AAEf;AAEA,MAAM,cAAc,EAAE,aAAa,CAAC,CAAC,EAAE,YAAY;AAQ5C,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,cAAc;AAClB,WAAO;AAAA,EACT;AAAA,EACA,iBAAiB;AACf,WAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA,aAAa;AACX,WAAO;AAAA,EACT;AAAA,EACA,oBAAoB;AAClB,WAAO;AAAA,EACT;AAAA,EACA,MAAM,YAAY;AAChB,WAAO;AAAA,EACT;AAAA,EACA,mBA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AS,IACzD,MACJ,oCAAC,QAAK,OAAO,gBAAgB,OAAM,KAAK,UAAU,GAAG,GAAG,GAAE,KAAG,CAC/D,CACF,CACF;AAAA,EAEJ;AAAA,EACA,yBAAyB,QAAgB;AACvC,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,IACT;AAEA,QAAI,OAAO,SAAS;AAClB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA;AAAA,+BAEoB,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA,EAI5C,OAAO,IAAI;AAAA,EACX;AAAA,EACA,OAAO,KAAK,OAAoC,SAAc;AAC5D,UAAM,kBAAkB,uBAAuB,OAAO;AACtD,UAAM,eAAe,gBAAgB,SAAS,SAAS,eAAe;AACtE,UAAM,EAAE,SAAS,OAAO,IAAI,aAAa,SAAS,SAAS,eAAe;AAE1E,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR,yBAAyB,YAAY;AAAA,MACvC;AAAA,IACF;AAEA,UAAM,UAAU,CAAC,CAAC,SAAS;AAC3B,UAAM,SAAiB;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,UAAU;AAAA,IACZ;AACA,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,oBAAoB,KAAK,yBAAyB,MAAM;AAAA,IAC1D;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -46,7 +46,7 @@ Only skip EnterPlanMode for simple tasks:
|
|
|
46
46
|
## What Happens in Plan Mode
|
|
47
47
|
|
|
48
48
|
In plan mode, you'll:
|
|
49
|
-
1. Thoroughly explore the codebase using Glob, Grep, and
|
|
49
|
+
1. Thoroughly explore the codebase using Glob, Grep, and View tools
|
|
50
50
|
2. Understand existing patterns and architecture
|
|
51
51
|
3. Design an implementation approach
|
|
52
52
|
4. Present your plan to the user for approval
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
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 View 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
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
getSkillCount
|
|
11
11
|
} from "../../utils/skillLoader.js";
|
|
12
12
|
import { DESCRIPTION, PROMPT } from "./prompt.js";
|
|
13
|
+
import { SEMANTIC_COLORS } from "../../constants/colors.js";
|
|
13
14
|
const inputSchema = z.strictObject({
|
|
14
15
|
action: z.enum(["list", "load", "search"]).describe(
|
|
15
16
|
"Action to perform: list all skills, load a specific skill, or search skills"
|
|
@@ -106,11 +107,11 @@ ${skill.content}
|
|
|
106
107
|
}
|
|
107
108
|
if (output.type === "list") {
|
|
108
109
|
const skills = output.skills || [];
|
|
109
|
-
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, { color: "green" }, "\u2713 Found ", skills.length, " skill", skills.length !== 1 ? "s" : ""), skills.slice(0, 10).map((skill, i) => /* @__PURE__ */ React.createElement(Box, { key: i, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Text, { bold: true }, skill?.name || "Unknown"), /* @__PURE__ */ React.createElement(Text, {
|
|
110
|
+
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, { color: "green" }, "\u2713 Found ", skills.length, " skill", skills.length !== 1 ? "s" : ""), skills.slice(0, 10).map((skill, i) => /* @__PURE__ */ React.createElement(Box, { key: i, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Text, { bold: true }, skill?.name || "Unknown"), /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", "(", skill?.plugin || "Unknown", ")")), /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", skill?.description || ""))), skills.length > 10 && /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", "... and ", skills.length - 10, " more"));
|
|
110
111
|
}
|
|
111
112
|
if (output.type === "search") {
|
|
112
113
|
const skills = output.skills || [];
|
|
113
|
-
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, { color: "green" }, "\u2713 Found ", skills.length, " skill", skills.length !== 1 ? "s" : "", ' matching "', output.query || "", '"'), skills.slice(0, 10).map((skill, i) => /* @__PURE__ */ React.createElement(Box, { key: i, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Text, { bold: true }, skill?.name || "Unknown"), /* @__PURE__ */ React.createElement(Text, {
|
|
114
|
+
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, { color: "green" }, "\u2713 Found ", skills.length, " skill", skills.length !== 1 ? "s" : "", ' matching "', output.query || "", '"'), skills.slice(0, 10).map((skill, i) => /* @__PURE__ */ React.createElement(Box, { key: i, flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Text, { bold: true }, skill?.name || "Unknown"), /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", "(", skill?.plugin || "Unknown", ")")), /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", skill?.description || ""))), skills.length > 10 && /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", "... and ", skills.length - 10, " more"));
|
|
114
115
|
}
|
|
115
116
|
if (output.type === "load") {
|
|
116
117
|
const skill = output.skill || {
|
|
@@ -119,7 +120,7 @@ ${skill.content}
|
|
|
119
120
|
plugin: "",
|
|
120
121
|
content: ""
|
|
121
122
|
};
|
|
122
|
-
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, { color: "green" }, "\u2713 Loaded skill: ", skill.name || "Unknown"), /* @__PURE__ */ React.createElement(Text, {
|
|
123
|
+
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, { color: "green" }, "\u2713 Loaded skill: ", skill.name || "Unknown"), /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", "Plugin: ", skill.plugin || "Unknown"), /* @__PURE__ */ React.createElement(Text, { color: SEMANTIC_COLORS.dim }, " ", "Content: ", (skill.content || "").length, " characters"));
|
|
123
124
|
}
|
|
124
125
|
return /* @__PURE__ */ React.createElement(Box, { paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, null, "Skill operation completed"));
|
|
125
126
|
},
|