@within-7/minto 0.1.7 → 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.
- package/cli.js +155 -37
- package/dist/Tool.js +38 -0
- package/dist/Tool.js.map +3 -3
- package/dist/commands/agents/AgentsCommand.js +52 -26
- package/dist/commands/agents/AgentsCommand.js.map +2 -2
- package/dist/commands/agents/constants.js +1 -1
- package/dist/commands/agents/constants.js.map +1 -1
- package/dist/commands/agents/index.js +1 -1
- package/dist/commands/bug.js +74 -7
- package/dist/commands/bug.js.map +3 -3
- package/dist/commands/clear.js +3 -0
- package/dist/commands/clear.js.map +2 -2
- package/dist/commands/compact.js +37 -0
- package/dist/commands/compact.js.map +2 -2
- package/dist/commands/context.js +84 -0
- package/dist/commands/context.js.map +7 -0
- package/dist/commands/ctx_viz.js +18 -10
- package/dist/commands/ctx_viz.js.map +2 -2
- package/dist/commands/doctor.js +158 -12
- package/dist/commands/doctor.js.map +2 -2
- package/dist/commands/export.js +156 -0
- package/dist/commands/export.js.map +7 -0
- package/dist/commands/mcp-interactive.js +21 -12
- package/dist/commands/mcp-interactive.js.map +2 -2
- package/dist/commands/model.js +6 -5
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/permissions.js +86 -0
- package/dist/commands/permissions.js.map +7 -0
- package/dist/commands/quit.js +3 -1
- package/dist/commands/quit.js.map +2 -2
- package/dist/commands/sandbox.js +104 -0
- package/dist/commands/sandbox.js.map +7 -0
- package/dist/commands/status.js +58 -0
- package/dist/commands/status.js.map +7 -0
- package/dist/commands/tasks.js +108 -0
- package/dist/commands/tasks.js.map +7 -0
- package/dist/commands/todos.js +123 -0
- package/dist/commands/todos.js.map +7 -0
- package/dist/commands.js +20 -2
- package/dist/commands.js.map +2 -2
- package/dist/components/AgentThinkingBlock.js +10 -18
- package/dist/components/AgentThinkingBlock.js.map +2 -2
- package/dist/components/BackgroundTasksPanel.js +78 -29
- package/dist/components/BackgroundTasksPanel.js.map +2 -2
- package/dist/components/BashStreamingProgress.js +24 -0
- package/dist/components/BashStreamingProgress.js.map +7 -0
- package/dist/components/CollapsibleHint.js +14 -0
- package/dist/components/CollapsibleHint.js.map +7 -0
- package/dist/components/FileEditToolUpdatedMessage.js +1 -1
- package/dist/components/FileEditToolUpdatedMessage.js.map +2 -2
- package/dist/components/HotkeyHelpPanel.js +137 -0
- package/dist/components/HotkeyHelpPanel.js.map +7 -0
- package/dist/components/Logo.js +5 -5
- package/dist/components/Logo.js.map +2 -2
- package/dist/components/Message.js +23 -7
- package/dist/components/Message.js.map +3 -3
- package/dist/components/ModelConfig.js +16 -3
- package/dist/components/ModelConfig.js.map +2 -2
- package/dist/components/ModelListManager.js +3 -3
- package/dist/components/ModelListManager.js.map +2 -2
- package/dist/components/ModelSelector/ModelSelector.js +1 -1
- package/dist/components/Onboarding.js +19 -14
- package/dist/components/Onboarding.js.map +2 -2
- package/dist/components/ProgressBar.js +74 -0
- package/dist/components/ProgressBar.js.map +7 -0
- package/dist/components/PromptInput.js +156 -46
- package/dist/components/PromptInput.js.map +2 -2
- package/dist/components/RequestStatusIndicator.js +194 -0
- package/dist/components/RequestStatusIndicator.js.map +7 -0
- package/dist/components/Spinner.js +92 -27
- package/dist/components/Spinner.js.map +2 -2
- package/dist/components/SpinnerSymbol.js +21 -27
- package/dist/components/SpinnerSymbol.js.map +2 -2
- package/dist/components/StreamingBashOutput.js +9 -8
- package/dist/components/StreamingBashOutput.js.map +2 -2
- package/dist/components/SubagentBlock.js +1 -1
- package/dist/components/SubagentBlock.js.map +1 -1
- package/dist/components/SubagentProgress.js +10 -11
- package/dist/components/SubagentProgress.js.map +2 -2
- package/dist/components/TaskCard.js +16 -13
- package/dist/components/TaskCard.js.map +2 -2
- package/dist/components/TodoChangeBlock.js +1 -1
- package/dist/components/TodoChangeBlock.js.map +2 -2
- package/dist/components/TodoPanel.js +120 -29
- package/dist/components/TodoPanel.js.map +3 -3
- package/dist/components/TokenCounter.js +74 -0
- package/dist/components/TokenCounter.js.map +7 -0
- package/dist/components/TokenWarning.js +2 -1
- package/dist/components/TokenWarning.js.map +2 -2
- package/dist/components/TreeConnector.js +25 -0
- package/dist/components/TreeConnector.js.map +7 -0
- package/dist/components/TurnCompletionIndicator.js +18 -0
- package/dist/components/TurnCompletionIndicator.js.map +7 -0
- package/dist/components/messages/AssistantTextMessage.js +5 -2
- package/dist/components/messages/AssistantTextMessage.js.map +2 -2
- package/dist/components/messages/AssistantThinkingMessage.js +18 -3
- package/dist/components/messages/AssistantThinkingMessage.js.map +2 -2
- package/dist/components/messages/AssistantToolUseMessage.js +11 -8
- package/dist/components/messages/AssistantToolUseMessage.js.map +2 -2
- package/dist/components/messages/GroupRenderer.js +53 -0
- package/dist/components/messages/GroupRenderer.js.map +7 -0
- package/dist/components/messages/NestedTasksPreview.js +12 -0
- package/dist/components/messages/NestedTasksPreview.js.map +7 -0
- package/dist/components/messages/ParallelTasksGroupView.js +92 -0
- package/dist/components/messages/ParallelTasksGroupView.js.map +7 -0
- package/dist/components/messages/TaskInModuleView.js +198 -0
- package/dist/components/messages/TaskInModuleView.js.map +7 -0
- package/dist/components/messages/TaskOutputContent.js +53 -0
- package/dist/components/messages/TaskOutputContent.js.map +7 -0
- package/dist/components/messages/UserPromptMessage.js +1 -1
- package/dist/components/messages/UserPromptMessage.js.map +2 -2
- package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js +2 -3
- package/dist/components/messages/UserToolResultMessage/UserToolSuccessMessage.js.map +2 -2
- package/dist/components/permissions/FallbackPermissionRequest.js +4 -4
- package/dist/components/permissions/FallbackPermissionRequest.js.map +2 -2
- package/dist/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +4 -4
- package/dist/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js.map +2 -2
- package/dist/constants/colors.js +48 -0
- package/dist/constants/colors.js.map +2 -2
- package/dist/constants/formatRules.js +102 -0
- package/dist/constants/formatRules.js.map +7 -0
- package/dist/constants/prompts.js +12 -34
- package/dist/constants/prompts.js.map +2 -2
- package/dist/constants/symbols.js +64 -6
- package/dist/constants/symbols.js.map +2 -2
- package/dist/constants/timing.js +5 -0
- package/dist/constants/timing.js.map +2 -2
- package/dist/core/config/defaults.js +84 -0
- package/dist/core/config/defaults.js.map +7 -0
- package/dist/core/config/index.js +111 -0
- package/dist/core/config/index.js.map +7 -0
- package/dist/core/config/loader.js +221 -0
- package/dist/core/config/loader.js.map +7 -0
- package/dist/core/config/migrations.js +128 -0
- package/dist/core/config/migrations.js.map +7 -0
- package/dist/core/config/schema.js +178 -0
- package/dist/core/config/schema.js.map +7 -0
- package/dist/core/costTracker.js +138 -0
- package/dist/core/costTracker.js.map +7 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +7 -0
- package/dist/core/permissions/auditLog.js +204 -0
- package/dist/core/permissions/auditLog.js.map +7 -0
- package/dist/core/permissions/engine/index.js +3 -0
- package/dist/core/permissions/engine/index.js.map +7 -0
- package/dist/core/permissions/engine/permissionEngine.js +106 -0
- package/dist/core/permissions/engine/permissionEngine.js.map +7 -0
- package/dist/core/permissions/engine/types.js +1 -0
- package/dist/core/permissions/engine/types.js.map +7 -0
- package/dist/core/permissions/index.js +84 -0
- package/dist/core/permissions/index.js.map +7 -0
- package/dist/core/permissions/ruleEngine.js +259 -0
- package/dist/core/permissions/ruleEngine.js.map +7 -0
- package/dist/core/permissions/rules/allowedToolsRule.js +62 -0
- package/dist/core/permissions/rules/allowedToolsRule.js.map +7 -0
- package/dist/core/permissions/rules/autoEscalationRule.js +291 -0
- package/dist/core/permissions/rules/autoEscalationRule.js.map +7 -0
- package/dist/core/permissions/rules/index.js +46 -0
- package/dist/core/permissions/rules/index.js.map +7 -0
- package/dist/core/permissions/rules/planModeRule.js +55 -0
- package/dist/core/permissions/rules/planModeRule.js.map +7 -0
- package/dist/core/permissions/rules/projectBoundaryRule.js +168 -0
- package/dist/core/permissions/rules/projectBoundaryRule.js.map +7 -0
- package/dist/core/permissions/rules/safeModeRule.js +65 -0
- package/dist/core/permissions/rules/safeModeRule.js.map +7 -0
- package/dist/core/permissions/rules/sensitivePathsRule.js +340 -0
- package/dist/core/permissions/rules/sensitivePathsRule.js.map +7 -0
- package/dist/core/permissions/types.js +127 -0
- package/dist/core/permissions/types.js.map +7 -0
- package/dist/core/tools/executor.js +143 -0
- package/dist/core/tools/executor.js.map +7 -0
- package/dist/core/tools/index.js +15 -0
- package/dist/core/tools/index.js.map +7 -0
- package/dist/core/tools/registry.js +183 -0
- package/dist/core/tools/registry.js.map +7 -0
- package/dist/core/tools/types.js +1 -0
- package/dist/core/tools/types.js.map +7 -0
- package/dist/cost-tracker.js +23 -15
- package/dist/cost-tracker.js.map +2 -2
- package/dist/entrypoints/cli.js +43 -43
- package/dist/entrypoints/cli.js.map +2 -2
- package/dist/entrypoints/mcp.js +12 -4
- package/dist/entrypoints/mcp.js.map +2 -2
- package/dist/history.js +14 -3
- package/dist/history.js.map +2 -2
- package/dist/hooks/useAgentTranscripts.js +116 -0
- package/dist/hooks/useAgentTranscripts.js.map +7 -0
- package/dist/hooks/useAnimationSync.js +53 -0
- package/dist/hooks/useAnimationSync.js.map +7 -0
- package/dist/hooks/useArrowKeyHistory.js +4 -2
- package/dist/hooks/useArrowKeyHistory.js.map +2 -2
- package/dist/hooks/useCanUseTool.js +3 -1
- package/dist/hooks/useCanUseTool.js.map +2 -2
- package/dist/hooks/useCancelRequest.js +4 -1
- package/dist/hooks/useCancelRequest.js.map +2 -2
- package/dist/hooks/useExitOnCtrlCD.js +9 -5
- package/dist/hooks/useExitOnCtrlCD.js.map +2 -2
- package/dist/hooks/useHookStatus.js +40 -0
- package/dist/hooks/useHookStatus.js.map +7 -0
- package/dist/hooks/useLogMessages.js +17 -1
- package/dist/hooks/useLogMessages.js.map +2 -2
- package/dist/hooks/useMessageGroups.js +43 -0
- package/dist/hooks/useMessageGroups.js.map +7 -0
- package/dist/hooks/useTerminalSize.js +62 -6
- package/dist/hooks/useTerminalSize.js.map +2 -2
- package/dist/hooks/useUnifiedCompletion.js +69 -0
- package/dist/hooks/useUnifiedCompletion.js.map +2 -2
- package/dist/i18n/index.js +109 -0
- package/dist/i18n/index.js.map +7 -0
- package/dist/i18n/locales/en.js +347 -0
- package/dist/i18n/locales/en.js.map +7 -0
- package/dist/i18n/locales/index.js +7 -0
- package/dist/i18n/locales/index.js.map +7 -0
- package/dist/i18n/locales/zh-CN.js +347 -0
- package/dist/i18n/locales/zh-CN.js.map +7 -0
- package/dist/i18n/types.js +8 -0
- package/dist/i18n/types.js.map +7 -0
- package/dist/query.js +175 -17
- package/dist/query.js.map +3 -3
- package/dist/screens/REPL.js +501 -192
- package/dist/screens/REPL.js.map +3 -3
- package/dist/services/adapters/chatCompletions.js +3 -1
- package/dist/services/adapters/chatCompletions.js.map +2 -2
- package/dist/services/adapters/messageNormalizer.js +354 -0
- package/dist/services/adapters/messageNormalizer.js.map +7 -0
- package/dist/services/adapters/responsesAPI.js +6 -3
- package/dist/services/adapters/responsesAPI.js.map +2 -2
- package/dist/services/checkpointManager.js +386 -0
- package/dist/services/checkpointManager.js.map +7 -0
- package/dist/services/claude.js +138 -11
- package/dist/services/claude.js.map +3 -3
- package/dist/services/compressionService.js +50 -1
- package/dist/services/compressionService.js.map +2 -2
- package/dist/services/contextMonitor.js +162 -0
- package/dist/services/contextMonitor.js.map +7 -0
- package/dist/services/customCommands.js +60 -41
- package/dist/services/customCommands.js.map +2 -2
- package/dist/services/hookExecutor.js +173 -1
- package/dist/services/hookExecutor.js.map +2 -2
- package/dist/services/intelligentCompactor.js +281 -0
- package/dist/services/intelligentCompactor.js.map +7 -0
- package/dist/services/lspConfig.js +109 -0
- package/dist/services/lspConfig.js.map +7 -0
- package/dist/services/mcpClient.js +273 -34
- package/dist/services/mcpClient.js.map +2 -2
- package/dist/services/modelOrchestrator.js +310 -0
- package/dist/services/modelOrchestrator.js.map +7 -0
- package/dist/services/openai.js +8 -1
- package/dist/services/openai.js.map +2 -2
- package/dist/services/outputStyles.js +138 -0
- package/dist/services/outputStyles.js.map +7 -0
- package/dist/services/plugins/index.js +5 -0
- package/dist/services/plugins/index.js.map +7 -0
- package/dist/services/plugins/lspServers.js +188 -0
- package/dist/services/plugins/lspServers.js.map +7 -0
- package/dist/services/plugins/pluginRuntime.js +229 -0
- package/dist/services/plugins/pluginRuntime.js.map +7 -0
- package/dist/services/plugins/pluginValidation.js +219 -0
- package/dist/services/plugins/pluginValidation.js.map +7 -0
- package/dist/services/plugins/skillMarketplace.js +556 -0
- package/dist/services/plugins/skillMarketplace.js.map +7 -0
- package/dist/services/responseStateManager.js +37 -3
- package/dist/services/responseStateManager.js.map +2 -2
- package/dist/services/sandbox/filesystemBoundary.js +300 -0
- package/dist/services/sandbox/filesystemBoundary.js.map +7 -0
- package/dist/services/sandbox/index.js +14 -0
- package/dist/services/sandbox/index.js.map +7 -0
- package/dist/services/sandbox/networkProxy.js +293 -0
- package/dist/services/sandbox/networkProxy.js.map +7 -0
- package/dist/services/sandbox/sandboxController.js +574 -0
- package/dist/services/sandbox/sandboxController.js.map +7 -0
- package/dist/services/sandbox/types.js +50 -0
- package/dist/services/sandbox/types.js.map +7 -0
- package/dist/services/sessionMemory.js +266 -0
- package/dist/services/sessionMemory.js.map +7 -0
- package/dist/services/taskRouter.js +324 -0
- package/dist/services/taskRouter.js.map +7 -0
- package/dist/tools/ArchitectTool/ArchitectTool.js +7 -1
- package/dist/tools/ArchitectTool/ArchitectTool.js.map +2 -2
- package/dist/tools/AskExpertModelTool/AskExpertModelTool.js +3 -0
- package/dist/tools/AskExpertModelTool/AskExpertModelTool.js.map +2 -2
- package/dist/tools/AskUserQuestionTool/AskUserQuestionTool.js.map +2 -2
- package/dist/tools/BaseTool.js +72 -0
- package/dist/tools/BaseTool.js.map +7 -0
- package/dist/tools/BashOutputTool/BashOutputToolResultMessage.js +3 -0
- package/dist/tools/BashOutputTool/BashOutputToolResultMessage.js.map +2 -2
- package/dist/tools/BashTool/BashTool.js +60 -3
- package/dist/tools/BashTool/BashTool.js.map +2 -2
- package/dist/tools/BashTool/BashToolResultMessage.js +3 -0
- package/dist/tools/BashTool/BashToolResultMessage.js.map +2 -2
- package/dist/tools/BashTool/OutputLine.js +54 -0
- package/dist/tools/BashTool/OutputLine.js.map +2 -2
- package/dist/tools/BashTool/prompt.js +192 -3
- package/dist/tools/BashTool/prompt.js.map +2 -2
- package/dist/tools/FileEditTool/FileEditTool.js +29 -4
- package/dist/tools/FileEditTool/FileEditTool.js.map +2 -2
- package/dist/tools/FileWriteTool/FileWriteTool.js +5 -5
- package/dist/tools/FileWriteTool/FileWriteTool.js.map +2 -2
- package/dist/tools/GlobTool/GlobTool.js +4 -2
- package/dist/tools/GlobTool/GlobTool.js.map +2 -2
- package/dist/tools/GrepTool/GrepTool.js +36 -7
- package/dist/tools/GrepTool/GrepTool.js.map +2 -2
- package/dist/tools/KillShellTool/KillShellToolResultMessage.js +3 -0
- package/dist/tools/KillShellTool/KillShellToolResultMessage.js.map +2 -2
- package/dist/tools/ListMcpResourcesTool/ListMcpResourcesTool.js +109 -0
- package/dist/tools/ListMcpResourcesTool/ListMcpResourcesTool.js.map +7 -0
- package/dist/tools/ListMcpResourcesTool/prompt.js +19 -0
- package/dist/tools/ListMcpResourcesTool/prompt.js.map +7 -0
- package/dist/tools/LspTool/LspTool.js +664 -0
- package/dist/tools/LspTool/LspTool.js.map +7 -0
- package/dist/tools/LspTool/prompt.js +27 -0
- package/dist/tools/LspTool/prompt.js.map +7 -0
- package/dist/tools/MCPTool/MCPTool.js +9 -1
- package/dist/tools/MCPTool/MCPTool.js.map +2 -2
- package/dist/tools/MemoryReadTool/MemoryReadTool.js +19 -6
- package/dist/tools/MemoryReadTool/MemoryReadTool.js.map +2 -2
- package/dist/tools/MemoryWriteTool/MemoryWriteTool.js +6 -6
- package/dist/tools/MemoryWriteTool/MemoryWriteTool.js.map +2 -2
- package/dist/tools/MultiEditTool/MultiEditTool.js +19 -2
- package/dist/tools/MultiEditTool/MultiEditTool.js.map +2 -2
- package/dist/tools/NotebookEditTool/NotebookEditTool.js +5 -1
- package/dist/tools/NotebookEditTool/NotebookEditTool.js.map +2 -2
- package/dist/tools/NotebookReadTool/NotebookReadTool.js.map +2 -2
- package/dist/tools/PlanModeTool/EnterPlanModeTool.js +74 -0
- package/dist/tools/PlanModeTool/EnterPlanModeTool.js.map +7 -0
- package/dist/tools/PlanModeTool/ExitPlanModeTool.js +108 -0
- package/dist/tools/PlanModeTool/ExitPlanModeTool.js.map +7 -0
- package/dist/tools/PlanModeTool/prompt.js +94 -0
- package/dist/tools/PlanModeTool/prompt.js.map +7 -0
- package/dist/tools/ReadMcpResourceTool/ReadMcpResourceTool.js +130 -0
- package/dist/tools/ReadMcpResourceTool/ReadMcpResourceTool.js.map +7 -0
- package/dist/tools/ReadMcpResourceTool/prompt.js +17 -0
- package/dist/tools/ReadMcpResourceTool/prompt.js.map +7 -0
- package/dist/tools/SkillTool/SkillTool.js +6 -1
- package/dist/tools/SkillTool/SkillTool.js.map +2 -2
- package/dist/tools/SlashCommandTool/SlashCommandTool.js +260 -0
- package/dist/tools/SlashCommandTool/SlashCommandTool.js.map +7 -0
- package/dist/tools/SlashCommandTool/prompt.js +35 -0
- package/dist/tools/SlashCommandTool/prompt.js.map +7 -0
- package/dist/tools/TaskOutputTool/TaskOutputTool.js +189 -0
- package/dist/tools/TaskOutputTool/TaskOutputTool.js.map +7 -0
- package/dist/tools/TaskOutputTool/prompt.js +15 -0
- package/dist/tools/TaskOutputTool/prompt.js.map +7 -0
- package/dist/tools/TaskTool/TaskTool.js +302 -104
- package/dist/tools/TaskTool/TaskTool.js.map +2 -2
- package/dist/tools/TaskTool/prompt.js.map +2 -2
- package/dist/tools/TodoWriteTool/TodoWriteTool.js +42 -77
- package/dist/tools/TodoWriteTool/TodoWriteTool.js.map +2 -2
- package/dist/tools/URLFetcherTool/URLFetcherTool.js +4 -1
- package/dist/tools/URLFetcherTool/URLFetcherTool.js.map +2 -2
- package/dist/tools/URLFetcherTool/cache.js +55 -8
- package/dist/tools/URLFetcherTool/cache.js.map +2 -2
- package/dist/tools.js +31 -2
- package/dist/tools.js.map +2 -2
- package/dist/types/hooks.js +4 -0
- package/dist/types/hooks.js.map +2 -2
- package/dist/types/marketplace.js.map +2 -2
- package/dist/types/messageGroup.js +36 -0
- package/dist/types/messageGroup.js.map +7 -0
- package/dist/types/plugin.js.map +2 -2
- package/dist/types/thinking.js +1 -0
- package/dist/types/thinking.js.map +7 -0
- package/dist/utils/BackgroundShellManager.js +136 -39
- package/dist/utils/BackgroundShellManager.js.map +2 -2
- package/dist/utils/MessageBatchBuffer.js +102 -0
- package/dist/utils/MessageBatchBuffer.js.map +7 -0
- package/dist/utils/PersistentShell.js +151 -1
- package/dist/utils/PersistentShell.js.map +2 -2
- package/dist/utils/agentLoader.js +1 -23
- package/dist/utils/agentLoader.js.map +2 -2
- package/dist/utils/agentTranscripts.js +641 -0
- package/dist/utils/agentTranscripts.js.map +7 -0
- package/dist/utils/animationManager.js +213 -0
- package/dist/utils/animationManager.js.map +7 -0
- package/dist/utils/animationSync.js +110 -0
- package/dist/utils/animationSync.js.map +7 -0
- package/dist/utils/asyncFile.js +215 -0
- package/dist/utils/asyncFile.js.map +7 -0
- package/dist/utils/backgroundAgentManager.js +231 -0
- package/dist/utils/backgroundAgentManager.js.map +7 -0
- package/dist/utils/config.js +63 -7
- package/dist/utils/config.js.map +2 -2
- package/dist/utils/conversationRecovery.js +19 -0
- package/dist/utils/conversationRecovery.js.map +2 -2
- package/dist/utils/exit.js +73 -0
- package/dist/utils/exit.js.map +7 -0
- package/dist/utils/format.js +73 -5
- package/dist/utils/format.js.map +2 -2
- package/dist/utils/generators.js +76 -6
- package/dist/utils/generators.js.map +2 -2
- package/dist/utils/globalErrorHandler.js +149 -0
- package/dist/utils/globalErrorHandler.js.map +7 -0
- package/dist/utils/groupHandlers/index.js +8 -0
- package/dist/utils/groupHandlers/index.js.map +7 -0
- package/dist/utils/groupHandlers/parallelTasksHandler.js +140 -0
- package/dist/utils/groupHandlers/parallelTasksHandler.js.map +7 -0
- package/dist/utils/groupHandlers/taskHandler.js +104 -0
- package/dist/utils/groupHandlers/taskHandler.js.map +7 -0
- package/dist/utils/groupHandlers/types.js +1 -0
- package/dist/utils/groupHandlers/types.js.map +7 -0
- package/dist/utils/logRotation.js +224 -0
- package/dist/utils/logRotation.js.map +7 -0
- package/dist/utils/marketplaceManager.js +3 -5
- package/dist/utils/marketplaceManager.js.map +2 -2
- package/dist/utils/memSafety.js +264 -0
- package/dist/utils/memSafety.js.map +7 -0
- package/dist/utils/messageGroupManager.js +274 -0
- package/dist/utils/messageGroupManager.js.map +7 -0
- package/dist/utils/messages.js +13 -4
- package/dist/utils/messages.js.map +2 -2
- package/dist/utils/model.js +119 -15
- package/dist/utils/model.js.map +3 -3
- package/dist/utils/permissions/filesystem.js +157 -5
- package/dist/utils/permissions/filesystem.js.map +2 -2
- package/dist/utils/plan/planMode.js +143 -0
- package/dist/utils/plan/planMode.js.map +7 -0
- package/dist/utils/pluginLoader.js +17 -21
- package/dist/utils/pluginLoader.js.map +2 -2
- package/dist/utils/ripgrep.js +55 -2
- package/dist/utils/ripgrep.js.map +2 -2
- package/dist/utils/sanitizeInput.js +32 -0
- package/dist/utils/sanitizeInput.js.map +7 -0
- package/dist/utils/secureKeyStorage.js +312 -0
- package/dist/utils/secureKeyStorage.js.map +7 -0
- package/dist/utils/session/sessionPlugins.js +67 -0
- package/dist/utils/session/sessionPlugins.js.map +7 -0
- package/dist/utils/taskDisplayUtils.js +257 -0
- package/dist/utils/taskDisplayUtils.js.map +7 -0
- package/dist/utils/teamConfig.js +2 -1
- package/dist/utils/teamConfig.js.map +2 -2
- package/dist/utils/todoStorage.js +92 -2
- package/dist/utils/todoStorage.js.map +2 -2
- package/dist/utils/toolTimeout.js +136 -0
- package/dist/utils/toolTimeout.js.map +7 -0
- package/dist/utils/tooling/safeRender.js +115 -0
- package/dist/utils/tooling/safeRender.js.map +7 -0
- package/dist/utils/userFriendlyError.js +346 -0
- package/dist/utils/userFriendlyError.js.map +7 -0
- package/dist/utils/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/dist/version.js +2 -2
- package/dist/version.js.map +1 -1
- package/package.json +14 -4
- package/scripts/postinstall.js +128 -38
- package/dist/commands/agents.js +0 -2086
- package/dist/commands/agents.js.map +0 -7
- package/dist/commands/build.js +0 -74
- package/dist/commands/build.js.map +0 -7
- package/dist/commands/compression.js +0 -57
- package/dist/commands/compression.js.map +0 -7
- package/dist/commands/listen.js +0 -37
- package/dist/commands/listen.js.map +0 -7
- package/dist/commands/login.js +0 -37
- package/dist/commands/login.js.map +0 -7
- package/dist/commands/logout.js +0 -33
- package/dist/commands/logout.js.map +0 -7
- package/dist/commands/mcp.js +0 -40
- package/dist/commands/mcp.js.map +0 -7
- package/dist/commands/mcp_refresh.js +0 -40
- package/dist/commands/mcp_refresh.js.map +0 -7
- package/dist/commands/modelstatus.js +0 -21
- package/dist/commands/modelstatus.js.map +0 -7
- package/dist/commands/onboarding.js +0 -36
- package/dist/commands/onboarding.js.map +0 -7
- package/dist/commands/plugin-interactive.js +0 -446
- package/dist/commands/plugin-interactive.js.map +0 -7
- package/dist/commands/pr_comments.js +0 -61
- package/dist/commands/pr_comments.js.map +0 -7
- package/dist/commands/release-notes.js +0 -30
- package/dist/commands/release-notes.js.map +0 -7
- package/dist/commands/review.js +0 -51
- package/dist/commands/review.js.map +0 -7
- package/dist/components/Bug.js +0 -147
- package/dist/components/Bug.js.map +0 -7
- package/dist/components/ModelSelector.js +0 -2062
- package/dist/components/ModelSelector.js.map +0 -7
- package/dist/components/ModelStatusDisplay.js +0 -87
- package/dist/components/ModelStatusDisplay.js.map +0 -7
- package/dist/entrypoints/cli-wrapper.js +0 -61
- package/dist/entrypoints/cli-wrapper.js.map +0 -7
- package/dist/screens/Doctor.js +0 -22
- package/dist/screens/Doctor.js.map +0 -7
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import { FallbackToolUseRejectedMessage } from "../../components/FallbackToolUseRejectedMessage.js";
|
|
2
|
+
import { getCwd } from "../../utils/state.js";
|
|
3
|
+
import { existsSync, statSync } from "fs";
|
|
4
|
+
import { Box, Text } from "ink";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { extname, join, relative } from "path";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { pathToFileURL } from "url";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { DESCRIPTION, PROMPT, TOOL_NAME_FOR_PROMPT } from "./prompt.js";
|
|
11
|
+
const inputSchema = z.strictObject({
|
|
12
|
+
operation: z.enum([
|
|
13
|
+
"goToDefinition",
|
|
14
|
+
"findReferences",
|
|
15
|
+
"hover",
|
|
16
|
+
"documentSymbol",
|
|
17
|
+
"workspaceSymbol",
|
|
18
|
+
"goToImplementation",
|
|
19
|
+
"prepareCallHierarchy",
|
|
20
|
+
"incomingCalls",
|
|
21
|
+
"outgoingCalls"
|
|
22
|
+
]).describe("The LSP operation to perform"),
|
|
23
|
+
filePath: z.string().describe("The absolute or relative path to the file"),
|
|
24
|
+
line: z.number().int().positive().describe("The line number (1-based, as shown in editors)"),
|
|
25
|
+
character: z.number().int().positive().describe("The character offset (1-based, as shown in editors)")
|
|
26
|
+
});
|
|
27
|
+
const outputSchema = z.object({
|
|
28
|
+
operation: z.enum([
|
|
29
|
+
"goToDefinition",
|
|
30
|
+
"findReferences",
|
|
31
|
+
"hover",
|
|
32
|
+
"documentSymbol",
|
|
33
|
+
"workspaceSymbol",
|
|
34
|
+
"goToImplementation",
|
|
35
|
+
"prepareCallHierarchy",
|
|
36
|
+
"incomingCalls",
|
|
37
|
+
"outgoingCalls"
|
|
38
|
+
]).describe("The LSP operation that was performed"),
|
|
39
|
+
result: z.string().describe("The formatted result of the LSP operation"),
|
|
40
|
+
filePath: z.string().describe("The file path the operation was performed on"),
|
|
41
|
+
resultCount: z.number().int().nonnegative().optional().describe("Number of results (definitions, references, symbols)"),
|
|
42
|
+
fileCount: z.number().int().nonnegative().optional().describe("Number of files containing results")
|
|
43
|
+
});
|
|
44
|
+
const OPERATION_LABELS = {
|
|
45
|
+
goToDefinition: { singular: "definition", plural: "definitions" },
|
|
46
|
+
findReferences: { singular: "reference", plural: "references" },
|
|
47
|
+
documentSymbol: { singular: "symbol", plural: "symbols" },
|
|
48
|
+
workspaceSymbol: { singular: "symbol", plural: "symbols" },
|
|
49
|
+
hover: { singular: "hover info", plural: "hover info", special: "available" },
|
|
50
|
+
goToImplementation: { singular: "implementation", plural: "implementations" },
|
|
51
|
+
prepareCallHierarchy: { singular: "call item", plural: "call items" },
|
|
52
|
+
incomingCalls: { singular: "caller", plural: "callers" },
|
|
53
|
+
outgoingCalls: { singular: "callee", plural: "callees" }
|
|
54
|
+
};
|
|
55
|
+
function getAbsolutePath(filePath) {
|
|
56
|
+
if (filePath.startsWith("/")) return filePath;
|
|
57
|
+
return join(getCwd(), filePath);
|
|
58
|
+
}
|
|
59
|
+
function toProjectRelativeIfPossible(filePath) {
|
|
60
|
+
const cwd = getCwd();
|
|
61
|
+
try {
|
|
62
|
+
const rel = relative(cwd, filePath);
|
|
63
|
+
if (!rel || rel === "") return filePath;
|
|
64
|
+
if (rel.startsWith("..")) return filePath;
|
|
65
|
+
return rel;
|
|
66
|
+
} catch {
|
|
67
|
+
return filePath;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function formatLocation(fileName, line0, character0) {
|
|
71
|
+
return `${toProjectRelativeIfPossible(fileName)}:${line0 + 1}:${character0 + 1}`;
|
|
72
|
+
}
|
|
73
|
+
function formatGoToDefinitionResult(locations) {
|
|
74
|
+
if (!locations || locations.length === 0) {
|
|
75
|
+
return {
|
|
76
|
+
formatted: "No definition found. This may occur if the cursor is not on a symbol, or if the definition is in an external library not indexed by the LSP server.",
|
|
77
|
+
resultCount: 0,
|
|
78
|
+
fileCount: 0
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const fileCount = new Set(locations.map((l) => l.fileName)).size;
|
|
82
|
+
if (locations.length === 1) {
|
|
83
|
+
const loc = locations[0];
|
|
84
|
+
return {
|
|
85
|
+
formatted: `Defined in ${formatLocation(loc.fileName, loc.line0, loc.character0)}`,
|
|
86
|
+
resultCount: 1,
|
|
87
|
+
fileCount
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
formatted: `Found ${locations.length} definitions:
|
|
92
|
+
${locations.map(
|
|
93
|
+
(loc) => ` ${formatLocation(loc.fileName, loc.line0, loc.character0)}`
|
|
94
|
+
).join("\n")}`,
|
|
95
|
+
resultCount: locations.length,
|
|
96
|
+
fileCount
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function groupLocationsByFile(items) {
|
|
100
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
101
|
+
for (const item of items) {
|
|
102
|
+
const key = toProjectRelativeIfPossible(item.fileName);
|
|
103
|
+
const existing = grouped.get(key);
|
|
104
|
+
if (existing) existing.push(item);
|
|
105
|
+
else grouped.set(key, [item]);
|
|
106
|
+
}
|
|
107
|
+
return grouped;
|
|
108
|
+
}
|
|
109
|
+
function formatFindReferencesResult(references) {
|
|
110
|
+
if (!references || references.length === 0) {
|
|
111
|
+
return {
|
|
112
|
+
formatted: "No references found. This may occur if the symbol has no usages, or if the LSP server has not fully indexed the workspace.",
|
|
113
|
+
resultCount: 0,
|
|
114
|
+
fileCount: 0
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (references.length === 1) {
|
|
118
|
+
const ref = references[0];
|
|
119
|
+
return {
|
|
120
|
+
formatted: `Found 1 reference:
|
|
121
|
+
${formatLocation(ref.fileName, ref.line0, ref.character0)}`,
|
|
122
|
+
resultCount: 1,
|
|
123
|
+
fileCount: 1
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const grouped = groupLocationsByFile(references);
|
|
127
|
+
const lines = [
|
|
128
|
+
`Found ${references.length} references across ${grouped.size} files:`
|
|
129
|
+
];
|
|
130
|
+
for (const [file, refs] of grouped) {
|
|
131
|
+
lines.push(`
|
|
132
|
+
${file}:`);
|
|
133
|
+
for (const ref of refs) {
|
|
134
|
+
lines.push(` Line ${ref.line0 + 1}:${ref.character0 + 1}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
formatted: lines.join("\n"),
|
|
139
|
+
resultCount: references.length,
|
|
140
|
+
fileCount: grouped.size
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function formatHoverResult(hoverText, line0, character0) {
|
|
144
|
+
if (!hoverText || hoverText.trim() === "") {
|
|
145
|
+
return {
|
|
146
|
+
formatted: "No hover information available. This may occur if the cursor is not on a symbol, or if the LSP server has not fully indexed the file.",
|
|
147
|
+
resultCount: 0,
|
|
148
|
+
fileCount: 0
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
formatted: `Hover info at ${line0 + 1}:${character0 + 1}:
|
|
153
|
+
|
|
154
|
+
${hoverText}`,
|
|
155
|
+
resultCount: 1,
|
|
156
|
+
fileCount: 1
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function formatDocumentSymbolsResult(lines, symbolCount) {
|
|
160
|
+
if (symbolCount === 0) {
|
|
161
|
+
return {
|
|
162
|
+
formatted: "No symbols found in document. This may occur if the file is empty, not supported by the LSP server, or if the server has not fully indexed the file.",
|
|
163
|
+
resultCount: 0,
|
|
164
|
+
fileCount: 0
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
formatted: ["Document symbols:", ...lines].join("\n"),
|
|
169
|
+
resultCount: symbolCount,
|
|
170
|
+
fileCount: 1
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
let cachedTypeScript = null;
|
|
174
|
+
function tryLoadTypeScriptModule(projectCwd) {
|
|
175
|
+
if (cachedTypeScript?.cwd === projectCwd) return cachedTypeScript.module;
|
|
176
|
+
try {
|
|
177
|
+
const requireFromCwd = createRequire(
|
|
178
|
+
pathToFileURL(join(projectCwd, "__minto_lsp__.js"))
|
|
179
|
+
);
|
|
180
|
+
const mod = requireFromCwd("typescript");
|
|
181
|
+
cachedTypeScript = { cwd: projectCwd, module: mod };
|
|
182
|
+
return mod;
|
|
183
|
+
} catch {
|
|
184
|
+
cachedTypeScript = { cwd: projectCwd, module: null };
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const projectCache = /* @__PURE__ */ new Map();
|
|
189
|
+
function getOrCreateTsProject(projectCwd) {
|
|
190
|
+
const ts = tryLoadTypeScriptModule(projectCwd);
|
|
191
|
+
if (!ts) return null;
|
|
192
|
+
const existing = projectCache.get(projectCwd);
|
|
193
|
+
if (existing) return existing;
|
|
194
|
+
let compilerOptions = {
|
|
195
|
+
allowJs: true,
|
|
196
|
+
checkJs: false,
|
|
197
|
+
jsx: ts.JsxEmit.ReactJSX,
|
|
198
|
+
target: ts.ScriptTarget.ESNext,
|
|
199
|
+
module: ts.ModuleKind.ESNext,
|
|
200
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext
|
|
201
|
+
};
|
|
202
|
+
let rootFileNames = [];
|
|
203
|
+
try {
|
|
204
|
+
const configPath = ts.findConfigFile(
|
|
205
|
+
projectCwd,
|
|
206
|
+
ts.sys.fileExists,
|
|
207
|
+
"tsconfig.json"
|
|
208
|
+
);
|
|
209
|
+
if (configPath) {
|
|
210
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
211
|
+
if (!configFile.error) {
|
|
212
|
+
const parsed = ts.parseJsonConfigFileContent(
|
|
213
|
+
configFile.config,
|
|
214
|
+
ts.sys,
|
|
215
|
+
projectCwd
|
|
216
|
+
);
|
|
217
|
+
compilerOptions = { ...compilerOptions, ...parsed.options };
|
|
218
|
+
rootFileNames = parsed.fileNames;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
const rootFiles = new Set(rootFileNames);
|
|
224
|
+
const versions = /* @__PURE__ */ new Map();
|
|
225
|
+
const host = {
|
|
226
|
+
getCompilationSettings: () => compilerOptions,
|
|
227
|
+
getScriptFileNames: () => Array.from(rootFiles),
|
|
228
|
+
getScriptVersion: (fileName) => {
|
|
229
|
+
try {
|
|
230
|
+
const stat = statSync(fileName);
|
|
231
|
+
const version = String(stat.mtimeMs ?? Date.now());
|
|
232
|
+
versions.set(fileName, version);
|
|
233
|
+
return version;
|
|
234
|
+
} catch {
|
|
235
|
+
return versions.get(fileName) ?? "0";
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
getScriptSnapshot: (fileName) => {
|
|
239
|
+
try {
|
|
240
|
+
if (!ts.sys.fileExists(fileName)) return void 0;
|
|
241
|
+
const content = ts.sys.readFile(fileName);
|
|
242
|
+
if (content === void 0) return void 0;
|
|
243
|
+
const stat = statSync(fileName);
|
|
244
|
+
versions.set(fileName, String(stat.mtimeMs ?? Date.now()));
|
|
245
|
+
return ts.ScriptSnapshot.fromString(content);
|
|
246
|
+
} catch {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
getCurrentDirectory: () => projectCwd,
|
|
251
|
+
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
|
252
|
+
fileExists: ts.sys.fileExists,
|
|
253
|
+
readFile: ts.sys.readFile,
|
|
254
|
+
readDirectory: ts.sys.readDirectory,
|
|
255
|
+
directoryExists: ts.sys.directoryExists,
|
|
256
|
+
getDirectories: ts.sys.getDirectories,
|
|
257
|
+
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
|
|
258
|
+
getCanonicalFileName: (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
|
|
259
|
+
getNewLine: () => ts.sys.newLine
|
|
260
|
+
};
|
|
261
|
+
const languageService = ts.createLanguageService(
|
|
262
|
+
host,
|
|
263
|
+
ts.createDocumentRegistry()
|
|
264
|
+
);
|
|
265
|
+
const state = {
|
|
266
|
+
ts,
|
|
267
|
+
cwd: projectCwd,
|
|
268
|
+
rootFiles,
|
|
269
|
+
compilerOptions,
|
|
270
|
+
languageService,
|
|
271
|
+
versions
|
|
272
|
+
};
|
|
273
|
+
projectCache.set(projectCwd, state);
|
|
274
|
+
return state;
|
|
275
|
+
}
|
|
276
|
+
function isFileTypeSupportedByTypescriptBackend(filePath) {
|
|
277
|
+
const ext = extname(filePath).toLowerCase();
|
|
278
|
+
return ext === ".ts" || ext === ".tsx" || ext === ".js" || ext === ".jsx" || ext === ".mts" || ext === ".cts" || ext === ".mjs" || ext === ".cjs";
|
|
279
|
+
}
|
|
280
|
+
function summarizeToolResult(operation, resultCount, fileCount) {
|
|
281
|
+
const label = OPERATION_LABELS[operation] ?? {
|
|
282
|
+
singular: "result",
|
|
283
|
+
plural: "results"
|
|
284
|
+
};
|
|
285
|
+
const noun = resultCount === 1 ? label.singular : label.plural;
|
|
286
|
+
if (operation === "hover" && resultCount > 0 && label.special) {
|
|
287
|
+
return /* @__PURE__ */ React.createElement(Text, null, "Hover info ", label.special);
|
|
288
|
+
}
|
|
289
|
+
return /* @__PURE__ */ React.createElement(Text, null, "Found ", /* @__PURE__ */ React.createElement(Text, { bold: true }, resultCount), " ", noun, fileCount > 1 ? /* @__PURE__ */ React.createElement(React.Fragment, null, " ", "across ", /* @__PURE__ */ React.createElement(Text, { bold: true }, fileCount), " files") : null);
|
|
290
|
+
}
|
|
291
|
+
const LspTool = {
|
|
292
|
+
name: TOOL_NAME_FOR_PROMPT,
|
|
293
|
+
async description() {
|
|
294
|
+
return DESCRIPTION;
|
|
295
|
+
},
|
|
296
|
+
async prompt() {
|
|
297
|
+
return PROMPT;
|
|
298
|
+
},
|
|
299
|
+
inputSchema,
|
|
300
|
+
userFacingName() {
|
|
301
|
+
return "LSP";
|
|
302
|
+
},
|
|
303
|
+
async isEnabled() {
|
|
304
|
+
return tryLoadTypeScriptModule(getCwd()) !== null;
|
|
305
|
+
},
|
|
306
|
+
isReadOnly() {
|
|
307
|
+
return true;
|
|
308
|
+
},
|
|
309
|
+
isConcurrencySafe() {
|
|
310
|
+
return true;
|
|
311
|
+
},
|
|
312
|
+
needsPermissions({ filePath }) {
|
|
313
|
+
const abs = getAbsolutePath(filePath);
|
|
314
|
+
return !existsSync(abs);
|
|
315
|
+
},
|
|
316
|
+
async validateInput(input) {
|
|
317
|
+
const parsed = inputSchema.safeParse(input);
|
|
318
|
+
if (!parsed.success) {
|
|
319
|
+
return {
|
|
320
|
+
result: false,
|
|
321
|
+
message: `Invalid input: ${parsed.error.message}`,
|
|
322
|
+
errorCode: 3
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const absPath = getAbsolutePath(input.filePath);
|
|
326
|
+
if (!existsSync(absPath)) {
|
|
327
|
+
return {
|
|
328
|
+
result: false,
|
|
329
|
+
message: `File does not exist: ${input.filePath}`,
|
|
330
|
+
errorCode: 1
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
try {
|
|
334
|
+
if (!statSync(absPath).isFile()) {
|
|
335
|
+
return {
|
|
336
|
+
result: false,
|
|
337
|
+
message: `Path is not a file: ${input.filePath}`,
|
|
338
|
+
errorCode: 2
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
} catch (err) {
|
|
342
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
343
|
+
return {
|
|
344
|
+
result: false,
|
|
345
|
+
message: `Cannot access file: ${input.filePath}. ${e.message}`,
|
|
346
|
+
errorCode: 4
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
return { result: true };
|
|
350
|
+
},
|
|
351
|
+
renderToolUseMessage(input, { verbose }) {
|
|
352
|
+
const abs = getAbsolutePath(input.filePath);
|
|
353
|
+
const filePathForDisplay = verbose ? abs : toProjectRelativeIfPossible(abs);
|
|
354
|
+
const parts = [];
|
|
355
|
+
parts.push(`operation: "${input.operation}"`);
|
|
356
|
+
if (input.filePath) parts.push(`file: "${filePathForDisplay}"`);
|
|
357
|
+
if (input.line && input.character) {
|
|
358
|
+
parts.push(`position: ${input.line}:${input.character}`);
|
|
359
|
+
}
|
|
360
|
+
return parts.join(", ");
|
|
361
|
+
},
|
|
362
|
+
renderToolUseRejectedMessage() {
|
|
363
|
+
return /* @__PURE__ */ React.createElement(FallbackToolUseRejectedMessage, null);
|
|
364
|
+
},
|
|
365
|
+
renderToolResultMessage(output, { verbose }) {
|
|
366
|
+
if (!output) {
|
|
367
|
+
return /* @__PURE__ */ React.createElement(Box, { paddingLeft: 2 }, /* @__PURE__ */ React.createElement(Text, null, "LSP operation completed"));
|
|
368
|
+
}
|
|
369
|
+
if (output.resultCount !== void 0 && output.fileCount !== void 0) {
|
|
370
|
+
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "row" }, /* @__PURE__ */ React.createElement(Text, null, "\xA0\xA0\u23BF \xA0"), summarizeToolResult(
|
|
371
|
+
output.operation,
|
|
372
|
+
output.resultCount,
|
|
373
|
+
output.fileCount
|
|
374
|
+
)), verbose ? /* @__PURE__ */ React.createElement(Box, { marginLeft: 5 }, /* @__PURE__ */ React.createElement(Text, null, output.result)) : null);
|
|
375
|
+
}
|
|
376
|
+
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, null, output.result)));
|
|
377
|
+
},
|
|
378
|
+
renderResultForAssistant(output) {
|
|
379
|
+
return output?.result ?? "LSP operation completed";
|
|
380
|
+
},
|
|
381
|
+
async *call(input, _context) {
|
|
382
|
+
const absPath = getAbsolutePath(input.filePath);
|
|
383
|
+
if (!isFileTypeSupportedByTypescriptBackend(absPath)) {
|
|
384
|
+
const ext = extname(absPath);
|
|
385
|
+
const out = {
|
|
386
|
+
operation: input.operation,
|
|
387
|
+
result: `No LSP server available for file type: ${ext}`,
|
|
388
|
+
filePath: input.filePath,
|
|
389
|
+
resultCount: 0,
|
|
390
|
+
fileCount: 0
|
|
391
|
+
};
|
|
392
|
+
yield { type: "result", data: out, resultForAssistant: out.result };
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
const project = getOrCreateTsProject(getCwd());
|
|
396
|
+
if (!project) {
|
|
397
|
+
const out = {
|
|
398
|
+
operation: input.operation,
|
|
399
|
+
result: "TypeScript not found in project. Install typescript to use LSP features: npm install typescript",
|
|
400
|
+
filePath: input.filePath,
|
|
401
|
+
resultCount: 0,
|
|
402
|
+
fileCount: 0
|
|
403
|
+
};
|
|
404
|
+
yield { type: "result", data: out, resultForAssistant: out.result };
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
project.rootFiles.add(absPath);
|
|
408
|
+
const ts = project.ts;
|
|
409
|
+
const service = project.languageService;
|
|
410
|
+
const program = service.getProgram?.();
|
|
411
|
+
if (!program) {
|
|
412
|
+
const out = {
|
|
413
|
+
operation: input.operation,
|
|
414
|
+
result: `Error performing ${input.operation}: TypeScript program not available`,
|
|
415
|
+
filePath: input.filePath,
|
|
416
|
+
resultCount: 0,
|
|
417
|
+
fileCount: 0
|
|
418
|
+
};
|
|
419
|
+
yield { type: "result", data: out, resultForAssistant: out.result };
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
const sourceFile = program.getSourceFile(absPath);
|
|
423
|
+
if (!sourceFile) {
|
|
424
|
+
const out = {
|
|
425
|
+
operation: input.operation,
|
|
426
|
+
result: `Error performing ${input.operation}: File is not part of the TypeScript program`,
|
|
427
|
+
filePath: input.filePath,
|
|
428
|
+
resultCount: 0,
|
|
429
|
+
fileCount: 0
|
|
430
|
+
};
|
|
431
|
+
yield { type: "result", data: out, resultForAssistant: out.result };
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const pos = ts.getPositionOfLineAndCharacter(
|
|
435
|
+
sourceFile,
|
|
436
|
+
input.line - 1,
|
|
437
|
+
input.character - 1
|
|
438
|
+
);
|
|
439
|
+
try {
|
|
440
|
+
let formatted;
|
|
441
|
+
let resultCount = 0;
|
|
442
|
+
let fileCount = 0;
|
|
443
|
+
switch (input.operation) {
|
|
444
|
+
case "goToDefinition": {
|
|
445
|
+
const defs = service.getDefinitionAtPosition?.(absPath, pos) ?? [];
|
|
446
|
+
const locations = defs.map((d) => {
|
|
447
|
+
const defSourceFile = program.getSourceFile(d.fileName);
|
|
448
|
+
if (!defSourceFile) return null;
|
|
449
|
+
const lc = ts.getLineAndCharacterOfPosition(
|
|
450
|
+
defSourceFile,
|
|
451
|
+
d.textSpan.start
|
|
452
|
+
);
|
|
453
|
+
return {
|
|
454
|
+
fileName: d.fileName,
|
|
455
|
+
line0: lc.line,
|
|
456
|
+
character0: lc.character
|
|
457
|
+
};
|
|
458
|
+
}).filter(Boolean);
|
|
459
|
+
const res = formatGoToDefinitionResult(locations);
|
|
460
|
+
formatted = res.formatted;
|
|
461
|
+
resultCount = res.resultCount;
|
|
462
|
+
fileCount = res.fileCount;
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
case "goToImplementation": {
|
|
466
|
+
const impls = service.getImplementationAtPosition?.(absPath, pos) ?? [];
|
|
467
|
+
const locations = impls.map((d) => {
|
|
468
|
+
const defSourceFile = program.getSourceFile(d.fileName);
|
|
469
|
+
if (!defSourceFile) return null;
|
|
470
|
+
const lc = ts.getLineAndCharacterOfPosition(
|
|
471
|
+
defSourceFile,
|
|
472
|
+
d.textSpan.start
|
|
473
|
+
);
|
|
474
|
+
return {
|
|
475
|
+
fileName: d.fileName,
|
|
476
|
+
line0: lc.line,
|
|
477
|
+
character0: lc.character
|
|
478
|
+
};
|
|
479
|
+
}).filter(Boolean);
|
|
480
|
+
const res = formatGoToDefinitionResult(locations);
|
|
481
|
+
formatted = res.formatted;
|
|
482
|
+
resultCount = res.resultCount;
|
|
483
|
+
fileCount = res.fileCount;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
case "findReferences": {
|
|
487
|
+
const referencedSymbols = service.findReferences?.(absPath, pos) ?? [];
|
|
488
|
+
const refs = [];
|
|
489
|
+
for (const sym of referencedSymbols) {
|
|
490
|
+
for (const ref of sym.references ?? []) {
|
|
491
|
+
const refSource = program.getSourceFile(ref.fileName);
|
|
492
|
+
if (!refSource) continue;
|
|
493
|
+
const lc = ts.getLineAndCharacterOfPosition(
|
|
494
|
+
refSource,
|
|
495
|
+
ref.textSpan.start
|
|
496
|
+
);
|
|
497
|
+
refs.push({
|
|
498
|
+
fileName: ref.fileName,
|
|
499
|
+
line0: lc.line,
|
|
500
|
+
character0: lc.character
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const res = formatFindReferencesResult(refs);
|
|
505
|
+
formatted = res.formatted;
|
|
506
|
+
resultCount = res.resultCount;
|
|
507
|
+
fileCount = res.fileCount;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
case "hover": {
|
|
511
|
+
const info = service.getQuickInfoAtPosition?.(absPath, pos);
|
|
512
|
+
let text = null;
|
|
513
|
+
let hoverLine0 = input.line - 1;
|
|
514
|
+
let hoverCharacter0 = input.character - 1;
|
|
515
|
+
if (info) {
|
|
516
|
+
const parts = [];
|
|
517
|
+
const signature = ts.displayPartsToString(info.displayParts ?? []);
|
|
518
|
+
if (signature) parts.push(signature);
|
|
519
|
+
const doc = ts.displayPartsToString(info.documentation ?? []);
|
|
520
|
+
if (doc) parts.push(doc);
|
|
521
|
+
if (info.tags && info.tags.length > 0) {
|
|
522
|
+
for (const tag of info.tags) {
|
|
523
|
+
const tagText = ts.displayPartsToString(tag.text ?? []);
|
|
524
|
+
parts.push(`@${tag.name}${tagText ? ` ${tagText}` : ""}`);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
text = parts.filter(Boolean).join("\n\n");
|
|
528
|
+
const lc = ts.getLineAndCharacterOfPosition(
|
|
529
|
+
sourceFile,
|
|
530
|
+
info.textSpan.start
|
|
531
|
+
);
|
|
532
|
+
hoverLine0 = lc.line;
|
|
533
|
+
hoverCharacter0 = lc.character;
|
|
534
|
+
}
|
|
535
|
+
const res = formatHoverResult(text, hoverLine0, hoverCharacter0);
|
|
536
|
+
formatted = res.formatted;
|
|
537
|
+
resultCount = res.resultCount;
|
|
538
|
+
fileCount = res.fileCount;
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
case "documentSymbol": {
|
|
542
|
+
const tree = service.getNavigationTree?.(absPath);
|
|
543
|
+
const lines = [];
|
|
544
|
+
let count = 0;
|
|
545
|
+
const kindLabel = (kind) => {
|
|
546
|
+
const m = {
|
|
547
|
+
class: "Class",
|
|
548
|
+
interface: "Interface",
|
|
549
|
+
enum: "Enum",
|
|
550
|
+
function: "Function",
|
|
551
|
+
method: "Method",
|
|
552
|
+
property: "Property",
|
|
553
|
+
var: "Variable",
|
|
554
|
+
let: "Variable",
|
|
555
|
+
const: "Constant",
|
|
556
|
+
module: "Module",
|
|
557
|
+
alias: "Alias",
|
|
558
|
+
type: "Type"
|
|
559
|
+
};
|
|
560
|
+
return m[kind] ?? (kind ? kind[0].toUpperCase() + kind.slice(1) : "Unknown");
|
|
561
|
+
};
|
|
562
|
+
const walk = (node, depth) => {
|
|
563
|
+
const children = node?.childItems ?? [];
|
|
564
|
+
for (const child of children) {
|
|
565
|
+
const span = child.spans?.[0];
|
|
566
|
+
if (!span) continue;
|
|
567
|
+
const lc = ts.getLineAndCharacterOfPosition(
|
|
568
|
+
sourceFile,
|
|
569
|
+
span.start
|
|
570
|
+
);
|
|
571
|
+
const indent = " ".repeat(depth);
|
|
572
|
+
const label = kindLabel(child.kind);
|
|
573
|
+
const detail = child.kindModifiers ? ` ${child.kindModifiers}` : "";
|
|
574
|
+
lines.push(
|
|
575
|
+
`${indent}${child.text} (${label})${detail} - Line ${lc.line + 1}`
|
|
576
|
+
);
|
|
577
|
+
count += 1;
|
|
578
|
+
if (child.childItems && child.childItems.length > 0) {
|
|
579
|
+
walk(child, depth + 1);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
walk(tree, 0);
|
|
584
|
+
const res = formatDocumentSymbolsResult(lines, count);
|
|
585
|
+
formatted = res.formatted;
|
|
586
|
+
resultCount = res.resultCount;
|
|
587
|
+
fileCount = res.fileCount;
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
case "workspaceSymbol": {
|
|
591
|
+
const items = service.getNavigateToItems?.("", 100, void 0, true, true) ?? [];
|
|
592
|
+
if (!items || items.length === 0) {
|
|
593
|
+
formatted = "No symbols found in workspace. This may occur if the workspace is empty, or if the LSP server has not finished indexing the project.";
|
|
594
|
+
resultCount = 0;
|
|
595
|
+
fileCount = 0;
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
const lines = [
|
|
599
|
+
`Found ${items.length} symbol${items.length === 1 ? "" : "s"} in workspace:`
|
|
600
|
+
];
|
|
601
|
+
const grouped = groupLocationsByFile(
|
|
602
|
+
items.map((it) => ({
|
|
603
|
+
fileName: it.fileName,
|
|
604
|
+
item: it
|
|
605
|
+
}))
|
|
606
|
+
);
|
|
607
|
+
for (const [file, itemsInFile] of grouped) {
|
|
608
|
+
lines.push(`
|
|
609
|
+
${file}:`);
|
|
610
|
+
for (const wrapper of itemsInFile) {
|
|
611
|
+
const it = wrapper.item;
|
|
612
|
+
const sf = program.getSourceFile(it.fileName);
|
|
613
|
+
if (!sf) continue;
|
|
614
|
+
const span = it.textSpan;
|
|
615
|
+
const lc = span ? ts.getLineAndCharacterOfPosition(sf, span.start) : { line: 0, character: 0 };
|
|
616
|
+
const label = it.kind ? String(it.kind)[0].toUpperCase() + String(it.kind).slice(1) : "Symbol";
|
|
617
|
+
let line = ` ${it.name} (${label}) - Line ${lc.line + 1}`;
|
|
618
|
+
if (it.containerName) line += ` in ${it.containerName}`;
|
|
619
|
+
lines.push(line);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
formatted = lines.join("\n");
|
|
623
|
+
resultCount = items.length;
|
|
624
|
+
fileCount = grouped.size;
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
case "prepareCallHierarchy":
|
|
628
|
+
case "incomingCalls":
|
|
629
|
+
case "outgoingCalls": {
|
|
630
|
+
const opLabel = input.operation;
|
|
631
|
+
formatted = `Error performing ${opLabel}: Call hierarchy is not supported by the TypeScript backend`;
|
|
632
|
+
resultCount = 0;
|
|
633
|
+
fileCount = 0;
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
default: {
|
|
637
|
+
formatted = `Error performing ${input.operation}: Unsupported operation`;
|
|
638
|
+
resultCount = 0;
|
|
639
|
+
fileCount = 0;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
const out = {
|
|
643
|
+
operation: input.operation,
|
|
644
|
+
result: formatted,
|
|
645
|
+
filePath: input.filePath,
|
|
646
|
+
resultCount,
|
|
647
|
+
fileCount
|
|
648
|
+
};
|
|
649
|
+
yield { type: "result", data: out, resultForAssistant: out.result };
|
|
650
|
+
} catch (err) {
|
|
651
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
652
|
+
const out = {
|
|
653
|
+
operation: input.operation,
|
|
654
|
+
result: `Error performing ${input.operation}: ${message}`,
|
|
655
|
+
filePath: input.filePath
|
|
656
|
+
};
|
|
657
|
+
yield { type: "result", data: out, resultForAssistant: out.result };
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
export {
|
|
662
|
+
LspTool
|
|
663
|
+
};
|
|
664
|
+
//# sourceMappingURL=LspTool.js.map
|