centaurus-cli 3.0.1 → 3.1.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/dist/ai/types.js +0 -1
- package/dist/ai/types.js.map +1 -1
- package/dist/cli-adapter.js +5047 -5158
- package/dist/cli-adapter.js.map +1 -1
- package/dist/commands/CommandParser.js +372 -315
- package/dist/commands/CommandParser.js.map +1 -1
- package/dist/config/build-config.js +11 -42
- package/dist/config/build-config.js.map +1 -1
- package/dist/config/defaultConfig.js +94 -82
- package/dist/config/defaultConfig.js.map +1 -1
- package/dist/config/manager.js +144 -160
- package/dist/config/manager.js.map +1 -1
- package/dist/config/mcp-config-manager.js +411 -364
- package/dist/config/mcp-config-manager.js.map +1 -1
- package/dist/config/models.js +118 -185
- package/dist/config/models.js.map +1 -1
- package/dist/config/slash-commands.js +186 -184
- package/dist/config/slash-commands.js.map +1 -1
- package/dist/config/types.js +33 -26
- package/dist/config/types.js.map +1 -1
- package/dist/context/command-detector.js +63 -67
- package/dist/context/command-detector.js.map +1 -1
- package/dist/context/context-manager.js +533 -518
- package/dist/context/context-manager.js.map +1 -1
- package/dist/context/handlers/docker-handler.js +518 -576
- package/dist/context/handlers/docker-handler.js.map +1 -1
- package/dist/context/handlers/ssh-handler.js +1050 -1109
- package/dist/context/handlers/ssh-handler.js.map +1 -1
- package/dist/context/handlers/wsl-handler.js +558 -630
- package/dist/context/handlers/wsl-handler.js.map +1 -1
- package/dist/context/index.js +42 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/subshell-handler.js +0 -4
- package/dist/context/subshell-handler.js.map +1 -1
- package/dist/context/types.js +20 -31
- package/dist/context/types.js.map +1 -1
- package/dist/hooks/useConnectivity.js +13 -10
- package/dist/hooks/useConnectivity.js.map +1 -1
- package/dist/hooks/useTerminalDimensions.js +67 -79
- package/dist/hooks/useTerminalDimensions.js.map +1 -1
- package/dist/index.js +228 -251
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcp-command-handler.js +297 -260
- package/dist/mcp/mcp-command-handler.js.map +1 -1
- package/dist/mcp/mcp-server-manager.js +139 -155
- package/dist/mcp/mcp-server-manager.js.map +1 -1
- package/dist/mcp/mcp-tool-wrapper.js +74 -94
- package/dist/mcp/mcp-tool-wrapper.js.map +1 -1
- package/dist/services/ai-autocomplete-agent.js +169 -181
- package/dist/services/ai-autocomplete-agent.js.map +1 -1
- package/dist/services/ai-context-injector.js +180 -93
- package/dist/services/ai-context-injector.js.map +1 -1
- package/dist/services/ai-service-client.js +513 -456
- package/dist/services/ai-service-client.js.map +1 -1
- package/dist/services/api-client.js +443 -441
- package/dist/services/api-client.js.map +1 -1
- package/dist/services/auth-handler.js +162 -198
- package/dist/services/auth-handler.js.map +1 -1
- package/dist/services/background-task-manager.js +258 -282
- package/dist/services/background-task-manager.js.map +1 -1
- package/dist/services/checkpoint-manager.js +1526 -1512
- package/dist/services/checkpoint-manager.js.map +1 -1
- package/dist/services/clipboard-service.js +151 -200
- package/dist/services/clipboard-service.js.map +1 -1
- package/dist/services/connectivity-manager.js +63 -65
- package/dist/services/connectivity-manager.js.map +1 -1
- package/dist/services/conversation-manager.js +118 -121
- package/dist/services/conversation-manager.js.map +1 -1
- package/dist/services/environment-context-injector.js +160 -187
- package/dist/services/environment-context-injector.js.map +1 -1
- package/dist/services/fast-context-agent.js +203 -243
- package/dist/services/fast-context-agent.js.map +1 -1
- package/dist/services/input-detection-agent.js +190 -202
- package/dist/services/input-detection-agent.js.map +1 -1
- package/dist/services/input-requirement-detector.js +155 -189
- package/dist/services/input-requirement-detector.js.map +1 -1
- package/dist/services/local-chat-storage.js +342 -365
- package/dist/services/local-chat-storage.js.map +1 -1
- package/dist/services/monitored-shell-manager.js +225 -233
- package/dist/services/monitored-shell-manager.js.map +1 -1
- package/dist/services/ollama-service.js +293 -310
- package/dist/services/ollama-service.js.map +1 -1
- package/dist/services/rules-storage.js +142 -0
- package/dist/services/rules-storage.js.map +1 -0
- package/dist/services/session-quota-manager.js +219 -235
- package/dist/services/session-quota-manager.js.map +1 -1
- package/dist/services/shell-input-agent.js +299 -334
- package/dist/services/shell-input-agent.js.map +1 -1
- package/dist/services/sub-agent-manager.js +459 -501
- package/dist/services/sub-agent-manager.js.map +1 -1
- package/dist/services/warpify-detector.js +133 -183
- package/dist/services/warpify-detector.js.map +1 -1
- package/dist/services/workflow-storage.js +202 -217
- package/dist/services/workflow-storage.js.map +1 -1
- package/dist/test-ssh-handler.js +148 -193
- package/dist/test-ssh-handler.js.map +1 -1
- package/dist/tools/add-mcp.js +161 -0
- package/dist/tools/add-mcp.js.map +1 -0
- package/dist/tools/background-command.js +240 -273
- package/dist/tools/background-command.js.map +1 -1
- package/dist/tools/command.js +447 -440
- package/dist/tools/command.js.map +1 -1
- package/dist/tools/create-image.js +172 -202
- package/dist/tools/create-image.js.map +1 -1
- package/dist/tools/enter-remote-session.js +169 -215
- package/dist/tools/enter-remote-session.js.map +1 -1
- package/dist/tools/fast-context.js +60 -67
- package/dist/tools/fast-context.js.map +1 -1
- package/dist/tools/file-ops.js +601 -572
- package/dist/tools/file-ops.js.map +1 -1
- package/dist/tools/find-files.js +262 -303
- package/dist/tools/find-files.js.map +1 -1
- package/dist/tools/get-diff.js +423 -406
- package/dist/tools/get-diff.js.map +1 -1
- package/dist/tools/grep-search.js +966 -948
- package/dist/tools/grep-search.js.map +1 -1
- package/dist/tools/inspect-symbol.js +308 -323
- package/dist/tools/inspect-symbol.js.map +1 -1
- package/dist/tools/plan-mode.js +459 -503
- package/dist/tools/plan-mode.js.map +1 -1
- package/dist/tools/read-binary-file.js +160 -190
- package/dist/tools/read-binary-file.js.map +1 -1
- package/dist/tools/registry.js +100 -84
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/reproduce_issue.js +170 -151
- package/dist/tools/reproduce_issue.js.map +1 -1
- package/dist/tools/sub-agent.js +223 -228
- package/dist/tools/sub-agent.js.map +1 -1
- package/dist/tools/task-complete.js +28 -27
- package/dist/tools/task-complete.js.map +1 -1
- package/dist/tools/types.js +0 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/validation.js +96 -118
- package/dist/tools/validation.js.map +1 -1
- package/dist/tools/web-search.js +194 -194
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools/workflow-tool.js +77 -82
- package/dist/tools/workflow-tool.js.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/rule.js +1 -0
- package/dist/types/rule.js.map +1 -0
- package/dist/types/workflow.js +0 -7
- package/dist/types/workflow.js.map +1 -1
- package/dist/ui/components/AgentTimer.js +24 -25
- package/dist/ui/components/AgentTimer.js.map +1 -1
- package/dist/ui/components/App.js +3266 -3263
- package/dist/ui/components/App.js.map +1 -1
- package/dist/ui/components/AuthScreen.js +22 -34
- package/dist/ui/components/AuthScreen.js.map +1 -1
- package/dist/ui/components/AuthWelcomeScreen.js +30 -24
- package/dist/ui/components/AuthWelcomeScreen.js.map +1 -1
- package/dist/ui/components/Breadcrumbs.js +53 -82
- package/dist/ui/components/Breadcrumbs.js.map +1 -1
- package/dist/ui/components/CircularSelectInput.js +59 -67
- package/dist/ui/components/CircularSelectInput.js.map +1 -1
- package/dist/ui/components/ClipboardFileAutocomplete.js +78 -39
- package/dist/ui/components/ClipboardFileAutocomplete.js.map +1 -1
- package/dist/ui/components/CodeBlock.js +24 -42
- package/dist/ui/components/CodeBlock.js.map +1 -1
- package/dist/ui/components/ConfigViewer.js +18 -25
- package/dist/ui/components/ConfigViewer.js.map +1 -1
- package/dist/ui/components/ConfirmPrompt.js +49 -71
- package/dist/ui/components/ConfirmPrompt.js.map +1 -1
- package/dist/ui/components/ConnectionStatusMessage.js +32 -83
- package/dist/ui/components/ConnectionStatusMessage.js.map +1 -1
- package/dist/ui/components/ContextWindowIndicator.js +34 -49
- package/dist/ui/components/ContextWindowIndicator.js.map +1 -1
- package/dist/ui/components/DetailedPlanReviewScreen.js +104 -106
- package/dist/ui/components/DetailedPlanReviewScreen.js.map +1 -1
- package/dist/ui/components/DiffViewer.js +68 -121
- package/dist/ui/components/DiffViewer.js.map +1 -1
- package/dist/ui/components/ErrorBoundary.js +40 -48
- package/dist/ui/components/ErrorBoundary.js.map +1 -1
- package/dist/ui/components/FileCreationPreview.js +29 -60
- package/dist/ui/components/FileCreationPreview.js.map +1 -1
- package/dist/ui/components/FileOperation.js +34 -29
- package/dist/ui/components/FileOperation.js.map +1 -1
- package/dist/ui/components/FileTagAutocomplete.js +55 -25
- package/dist/ui/components/FileTagAutocomplete.js.map +1 -1
- package/dist/ui/components/FontRecommendation.js.map +1 -1
- package/dist/ui/components/GitDiffBreadcrumb.js +29 -0
- package/dist/ui/components/GitDiffBreadcrumb.js.map +1 -0
- package/dist/ui/components/InputBox.js +1620 -2150
- package/dist/ui/components/InputBox.js.map +1 -1
- package/dist/ui/components/InteractiveShell.js +234 -352
- package/dist/ui/components/InteractiveShell.js.map +1 -1
- package/dist/ui/components/KeyboardHelp.js +34 -35
- package/dist/ui/components/KeyboardHelp.js.map +1 -1
- package/dist/ui/components/LoadingIndicator.js +22 -25
- package/dist/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/ui/components/MCPAddScreen.js +40 -51
- package/dist/ui/components/MCPAddScreen.js.map +1 -1
- package/dist/ui/components/MCPListScreen.js +40 -48
- package/dist/ui/components/MCPListScreen.js.map +1 -1
- package/dist/ui/components/MCPServerListScreen.js +49 -56
- package/dist/ui/components/MCPServerListScreen.js.map +1 -1
- package/dist/ui/components/MarkdownRenderer.js +69 -96
- package/dist/ui/components/MarkdownRenderer.js.map +1 -1
- package/dist/ui/components/MessageBox.js +66 -48
- package/dist/ui/components/MessageBox.js.map +1 -1
- package/dist/ui/components/MessageDisplay.js +150 -142
- package/dist/ui/components/MessageDisplay.js.map +1 -1
- package/dist/ui/components/MonitorModeAIPanel.js +46 -65
- package/dist/ui/components/MonitorModeAIPanel.js.map +1 -1
- package/dist/ui/components/MultiLineInput.js +243 -277
- package/dist/ui/components/MultiLineInput.js.map +1 -1
- package/dist/ui/components/PasswordPrompt.js +37 -18
- package/dist/ui/components/PasswordPrompt.js.map +1 -1
- package/dist/ui/components/PlanAcceptedMessage.js +27 -38
- package/dist/ui/components/PlanAcceptedMessage.js.map +1 -1
- package/dist/ui/components/PlanReviewScreen.js +46 -50
- package/dist/ui/components/PlanReviewScreen.js.map +1 -1
- package/dist/ui/components/RulesEditorScreen.js +81 -0
- package/dist/ui/components/RulesEditorScreen.js.map +1 -0
- package/dist/ui/components/SelectPrompt.js +19 -8
- package/dist/ui/components/SelectPrompt.js.map +1 -1
- package/dist/ui/components/ShimmerText.js +44 -0
- package/dist/ui/components/ShimmerText.js.map +1 -0
- package/dist/ui/components/SlashCommandAutocomplete.js +49 -22
- package/dist/ui/components/SlashCommandAutocomplete.js.map +1 -1
- package/dist/ui/components/StatusBar.js +56 -87
- package/dist/ui/components/StatusBar.js.map +1 -1
- package/dist/ui/components/StreamingMessageDisplay.js +116 -99
- package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
- package/dist/ui/components/TaskCompletedMessage.js +28 -23
- package/dist/ui/components/TaskCompletedMessage.js.map +1 -1
- package/dist/ui/components/TaskProgressIndicator.js +44 -70
- package/dist/ui/components/TaskProgressIndicator.js.map +1 -1
- package/dist/ui/components/ThinkingDisplay.js +44 -41
- package/dist/ui/components/ThinkingDisplay.js.map +1 -1
- package/dist/ui/components/ToolExecutionMessage.js +772 -1326
- package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
- package/dist/ui/components/ToolExecutionStatus.js +53 -84
- package/dist/ui/components/ToolExecutionStatus.js.map +1 -1
- package/dist/ui/components/ToolResult.js +22 -15
- package/dist/ui/components/ToolResult.js.map +1 -1
- package/dist/ui/components/VersionUpdatePrompt.js +88 -120
- package/dist/ui/components/VersionUpdatePrompt.js.map +1 -1
- package/dist/ui/components/WelcomeBanner.js +176 -26
- package/dist/ui/components/WelcomeBanner.js.map +1 -1
- package/dist/ui/components/WorkflowCreatorScreen.js +94 -161
- package/dist/ui/components/WorkflowCreatorScreen.js.map +1 -1
- package/dist/utils/ansi-encoder.js +30 -61
- package/dist/utils/ansi-encoder.js.map +1 -1
- package/dist/utils/chat-formatter.js +327 -305
- package/dist/utils/chat-formatter.js.map +1 -1
- package/dist/utils/command-history.js +152 -174
- package/dist/utils/command-history.js.map +1 -1
- package/dist/utils/context-sanitizer.js +49 -112
- package/dist/utils/context-sanitizer.js.map +1 -1
- package/dist/utils/conversation-logger.js +292 -324
- package/dist/utils/conversation-logger.js.map +1 -1
- package/dist/utils/custom-commands-manager.js +126 -131
- package/dist/utils/custom-commands-manager.js.map +1 -1
- package/dist/utils/editor-utils.js +732 -837
- package/dist/utils/editor-utils.js.map +1 -1
- package/dist/utils/file.js +174 -213
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/git-stats.js +169 -0
- package/dist/utils/git-stats.js.map +1 -0
- package/dist/utils/input-classifier.js +960 -482
- package/dist/utils/input-classifier.js.map +1 -1
- package/dist/utils/logger.js +48 -73
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/markdown-parser.js +277 -310
- package/dist/utils/markdown-parser.js.map +1 -1
- package/dist/utils/rule-reference-resolver.js +54 -0
- package/dist/utils/rule-reference-resolver.js.map +1 -0
- package/dist/utils/shell.js +144 -156
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/state.js +23 -22
- package/dist/utils/state.js.map +1 -1
- package/dist/utils/syntax-checker.js +279 -327
- package/dist/utils/syntax-checker.js.map +1 -1
- package/dist/utils/terminal-output.js +199 -302
- package/dist/utils/terminal-output.js.map +1 -1
- package/dist/utils/text-clipboard.js +47 -70
- package/dist/utils/text-clipboard.js.map +1 -1
- package/dist/utils/unicode-sanitizer.js +134 -197
- package/dist/utils/unicode-sanitizer.js.map +1 -1
- package/dist/utils/version-checker.js +46 -56
- package/dist/utils/version-checker.js.map +1 -1
- package/package.json +6 -4
- package/dist/ai/types.d.ts +0 -20
- package/dist/ai/types.d.ts.map +0 -1
- package/dist/cli-adapter.d.ts +0 -514
- package/dist/cli-adapter.d.ts.map +0 -1
- package/dist/commands/CommandParser.d.ts +0 -27
- package/dist/commands/CommandParser.d.ts.map +0 -1
- package/dist/config/build-config.d.ts +0 -42
- package/dist/config/build-config.d.ts.map +0 -1
- package/dist/config/defaultConfig.d.ts +0 -79
- package/dist/config/defaultConfig.d.ts.map +0 -1
- package/dist/config/manager.d.ts +0 -62
- package/dist/config/manager.d.ts.map +0 -1
- package/dist/config/mcp-config-manager.d.ts +0 -79
- package/dist/config/mcp-config-manager.d.ts.map +0 -1
- package/dist/config/models.d.ts +0 -83
- package/dist/config/models.d.ts.map +0 -1
- package/dist/config/slash-commands.d.ts +0 -23
- package/dist/config/slash-commands.d.ts.map +0 -1
- package/dist/config/types.d.ts +0 -35
- package/dist/config/types.d.ts.map +0 -1
- package/dist/context/command-detector.d.ts +0 -50
- package/dist/context/command-detector.d.ts.map +0 -1
- package/dist/context/context-manager.d.ts +0 -157
- package/dist/context/context-manager.d.ts.map +0 -1
- package/dist/context/handlers/docker-handler.d.ts +0 -130
- package/dist/context/handlers/docker-handler.d.ts.map +0 -1
- package/dist/context/handlers/ssh-handler.d.ts +0 -201
- package/dist/context/handlers/ssh-handler.d.ts.map +0 -1
- package/dist/context/handlers/wsl-handler.d.ts +0 -146
- package/dist/context/handlers/wsl-handler.d.ts.map +0 -1
- package/dist/context/index.d.ts +0 -8
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/subshell-handler.d.ts +0 -165
- package/dist/context/subshell-handler.d.ts.map +0 -1
- package/dist/context/types.d.ts +0 -70
- package/dist/context/types.d.ts.map +0 -1
- package/dist/hooks/useConnectivity.d.ts +0 -2
- package/dist/hooks/useConnectivity.d.ts.map +0 -1
- package/dist/hooks/useTerminalDimensions.d.ts +0 -41
- package/dist/hooks/useTerminalDimensions.d.ts.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/mcp/mcp-command-handler.d.ts +0 -47
- package/dist/mcp/mcp-command-handler.d.ts.map +0 -1
- package/dist/mcp/mcp-server-manager.d.ts +0 -30
- package/dist/mcp/mcp-server-manager.d.ts.map +0 -1
- package/dist/mcp/mcp-tool-wrapper.d.ts +0 -12
- package/dist/mcp/mcp-tool-wrapper.d.ts.map +0 -1
- package/dist/services/ai-autocomplete-agent.d.ts +0 -39
- package/dist/services/ai-autocomplete-agent.d.ts.map +0 -1
- package/dist/services/ai-context-injector.d.ts +0 -41
- package/dist/services/ai-context-injector.d.ts.map +0 -1
- package/dist/services/ai-service-client.d.ts +0 -128
- package/dist/services/ai-service-client.d.ts.map +0 -1
- package/dist/services/api-client.d.ts +0 -353
- package/dist/services/api-client.d.ts.map +0 -1
- package/dist/services/auth-handler.d.ts +0 -30
- package/dist/services/auth-handler.d.ts.map +0 -1
- package/dist/services/background-task-manager.d.ts +0 -114
- package/dist/services/background-task-manager.d.ts.map +0 -1
- package/dist/services/checkpoint-manager.d.ts +0 -204
- package/dist/services/checkpoint-manager.d.ts.map +0 -1
- package/dist/services/clipboard-service.d.ts +0 -37
- package/dist/services/clipboard-service.d.ts.map +0 -1
- package/dist/services/connectivity-manager.d.ts +0 -18
- package/dist/services/connectivity-manager.d.ts.map +0 -1
- package/dist/services/conversation-manager.d.ts +0 -73
- package/dist/services/conversation-manager.d.ts.map +0 -1
- package/dist/services/environment-context-injector.d.ts +0 -69
- package/dist/services/environment-context-injector.d.ts.map +0 -1
- package/dist/services/fast-context-agent.d.ts +0 -12
- package/dist/services/fast-context-agent.d.ts.map +0 -1
- package/dist/services/input-detection-agent.d.ts +0 -40
- package/dist/services/input-detection-agent.d.ts.map +0 -1
- package/dist/services/input-requirement-detector.d.ts +0 -28
- package/dist/services/input-requirement-detector.d.ts.map +0 -1
- package/dist/services/local-chat-storage.d.ts +0 -182
- package/dist/services/local-chat-storage.d.ts.map +0 -1
- package/dist/services/monitored-shell-manager.d.ts +0 -120
- package/dist/services/monitored-shell-manager.d.ts.map +0 -1
- package/dist/services/ollama-service.d.ts +0 -197
- package/dist/services/ollama-service.d.ts.map +0 -1
- package/dist/services/session-quota-manager.d.ts +0 -101
- package/dist/services/session-quota-manager.d.ts.map +0 -1
- package/dist/services/shell-input-agent.d.ts +0 -89
- package/dist/services/shell-input-agent.d.ts.map +0 -1
- package/dist/services/sub-agent-manager.d.ts +0 -140
- package/dist/services/sub-agent-manager.d.ts.map +0 -1
- package/dist/services/warpify-detector.d.ts +0 -43
- package/dist/services/warpify-detector.d.ts.map +0 -1
- package/dist/services/workflow-storage.d.ts +0 -72
- package/dist/services/workflow-storage.d.ts.map +0 -1
- package/dist/test-ssh-handler.d.ts +0 -8
- package/dist/test-ssh-handler.d.ts.map +0 -1
- package/dist/tools/background-command.d.ts +0 -11
- package/dist/tools/background-command.d.ts.map +0 -1
- package/dist/tools/command.d.ts +0 -3
- package/dist/tools/command.d.ts.map +0 -1
- package/dist/tools/create-image.d.ts +0 -10
- package/dist/tools/create-image.d.ts.map +0 -1
- package/dist/tools/enter-remote-session.d.ts +0 -48
- package/dist/tools/enter-remote-session.d.ts.map +0 -1
- package/dist/tools/fast-context.d.ts +0 -3
- package/dist/tools/fast-context.d.ts.map +0 -1
- package/dist/tools/file-ops.d.ts +0 -7
- package/dist/tools/file-ops.d.ts.map +0 -1
- package/dist/tools/find-files.d.ts +0 -49
- package/dist/tools/find-files.d.ts.map +0 -1
- package/dist/tools/get-diff.d.ts +0 -14
- package/dist/tools/get-diff.d.ts.map +0 -1
- package/dist/tools/grep-search.d.ts +0 -155
- package/dist/tools/grep-search.d.ts.map +0 -1
- package/dist/tools/inspect-symbol.d.ts +0 -32
- package/dist/tools/inspect-symbol.d.ts.map +0 -1
- package/dist/tools/plan-mode.d.ts +0 -140
- package/dist/tools/plan-mode.d.ts.map +0 -1
- package/dist/tools/read-binary-file.d.ts +0 -10
- package/dist/tools/read-binary-file.d.ts.map +0 -1
- package/dist/tools/registry.d.ts +0 -31
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/reproduce_issue.d.ts +0 -2
- package/dist/tools/reproduce_issue.d.ts.map +0 -1
- package/dist/tools/sub-agent.d.ts +0 -9
- package/dist/tools/sub-agent.d.ts.map +0 -1
- package/dist/tools/task-complete.d.ts +0 -3
- package/dist/tools/task-complete.d.ts.map +0 -1
- package/dist/tools/types.d.ts +0 -40
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/validation.d.ts +0 -47
- package/dist/tools/validation.d.ts.map +0 -1
- package/dist/tools/web-search.d.ts +0 -24
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/workflow-tool.d.ts +0 -11
- package/dist/tools/workflow-tool.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -123
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/workflow.d.ts +0 -110
- package/dist/types/workflow.d.ts.map +0 -1
- package/dist/ui/components/AgentTimer.d.ts +0 -7
- package/dist/ui/components/AgentTimer.d.ts.map +0 -1
- package/dist/ui/components/App.d.ts +0 -197
- package/dist/ui/components/App.d.ts.map +0 -1
- package/dist/ui/components/AuthScreen.d.ts +0 -8
- package/dist/ui/components/AuthScreen.d.ts.map +0 -1
- package/dist/ui/components/AuthWelcomeScreen.d.ts +0 -8
- package/dist/ui/components/AuthWelcomeScreen.d.ts.map +0 -1
- package/dist/ui/components/Breadcrumbs.d.ts +0 -13
- package/dist/ui/components/Breadcrumbs.d.ts.map +0 -1
- package/dist/ui/components/CircularSelectInput.d.ts +0 -24
- package/dist/ui/components/CircularSelectInput.d.ts.map +0 -1
- package/dist/ui/components/ClipboardFileAutocomplete.d.ts +0 -10
- package/dist/ui/components/ClipboardFileAutocomplete.d.ts.map +0 -1
- package/dist/ui/components/CodeBlock.d.ts +0 -9
- package/dist/ui/components/CodeBlock.d.ts.map +0 -1
- package/dist/ui/components/ConfigViewer.d.ts +0 -11
- package/dist/ui/components/ConfigViewer.d.ts.map +0 -1
- package/dist/ui/components/ConfirmPrompt.d.ts +0 -13
- package/dist/ui/components/ConfirmPrompt.d.ts.map +0 -1
- package/dist/ui/components/ConnectionStatusMessage.d.ts +0 -17
- package/dist/ui/components/ConnectionStatusMessage.d.ts.map +0 -1
- package/dist/ui/components/ContextWindowIndicator.d.ts +0 -8
- package/dist/ui/components/ContextWindowIndicator.d.ts.map +0 -1
- package/dist/ui/components/DetailedPlanReviewScreen.d.ts +0 -17
- package/dist/ui/components/DetailedPlanReviewScreen.d.ts.map +0 -1
- package/dist/ui/components/DiffViewer.d.ts +0 -9
- package/dist/ui/components/DiffViewer.d.ts.map +0 -1
- package/dist/ui/components/ErrorBoundary.d.ts +0 -17
- package/dist/ui/components/ErrorBoundary.d.ts.map +0 -1
- package/dist/ui/components/FileCreationPreview.d.ts +0 -8
- package/dist/ui/components/FileCreationPreview.d.ts.map +0 -1
- package/dist/ui/components/FileOperation.d.ts +0 -10
- package/dist/ui/components/FileOperation.d.ts.map +0 -1
- package/dist/ui/components/FileTagAutocomplete.d.ts +0 -11
- package/dist/ui/components/FileTagAutocomplete.d.ts.map +0 -1
- package/dist/ui/components/FontRecommendation.d.ts +0 -1
- package/dist/ui/components/FontRecommendation.d.ts.map +0 -1
- package/dist/ui/components/InputBox.d.ts +0 -42
- package/dist/ui/components/InputBox.d.ts.map +0 -1
- package/dist/ui/components/InteractiveShell.d.ts +0 -30
- package/dist/ui/components/InteractiveShell.d.ts.map +0 -1
- package/dist/ui/components/KeyboardHelp.d.ts +0 -7
- package/dist/ui/components/KeyboardHelp.d.ts.map +0 -1
- package/dist/ui/components/LoadingIndicator.d.ts +0 -3
- package/dist/ui/components/LoadingIndicator.d.ts.map +0 -1
- package/dist/ui/components/MCPAddScreen.d.ts +0 -13
- package/dist/ui/components/MCPAddScreen.d.ts.map +0 -1
- package/dist/ui/components/MCPListScreen.d.ts +0 -17
- package/dist/ui/components/MCPListScreen.d.ts.map +0 -1
- package/dist/ui/components/MCPServerListScreen.d.ts +0 -16
- package/dist/ui/components/MCPServerListScreen.d.ts.map +0 -1
- package/dist/ui/components/MarkdownRenderer.d.ts +0 -8
- package/dist/ui/components/MarkdownRenderer.d.ts.map +0 -1
- package/dist/ui/components/MessageBox.d.ts +0 -10
- package/dist/ui/components/MessageBox.d.ts.map +0 -1
- package/dist/ui/components/MessageDisplay.d.ts +0 -14
- package/dist/ui/components/MessageDisplay.d.ts.map +0 -1
- package/dist/ui/components/MonitorModeAIPanel.d.ts +0 -23
- package/dist/ui/components/MonitorModeAIPanel.d.ts.map +0 -1
- package/dist/ui/components/MultiLineInput.d.ts +0 -13
- package/dist/ui/components/MultiLineInput.d.ts.map +0 -1
- package/dist/ui/components/PasswordPrompt.d.ts +0 -9
- package/dist/ui/components/PasswordPrompt.d.ts.map +0 -1
- package/dist/ui/components/PlanAcceptedMessage.d.ts +0 -20
- package/dist/ui/components/PlanAcceptedMessage.d.ts.map +0 -1
- package/dist/ui/components/PlanReviewScreen.d.ts +0 -14
- package/dist/ui/components/PlanReviewScreen.d.ts.map +0 -1
- package/dist/ui/components/SelectPrompt.d.ts +0 -12
- package/dist/ui/components/SelectPrompt.d.ts.map +0 -1
- package/dist/ui/components/SlashCommandAutocomplete.d.ts +0 -13
- package/dist/ui/components/SlashCommandAutocomplete.d.ts.map +0 -1
- package/dist/ui/components/StatusBar.d.ts +0 -14
- package/dist/ui/components/StatusBar.d.ts.map +0 -1
- package/dist/ui/components/StreamingMessageDisplay.d.ts +0 -15
- package/dist/ui/components/StreamingMessageDisplay.d.ts.map +0 -1
- package/dist/ui/components/TaskCompletedMessage.d.ts +0 -14
- package/dist/ui/components/TaskCompletedMessage.d.ts.map +0 -1
- package/dist/ui/components/TaskProgressIndicator.d.ts +0 -18
- package/dist/ui/components/TaskProgressIndicator.d.ts.map +0 -1
- package/dist/ui/components/ThinkingDisplay.d.ts +0 -15
- package/dist/ui/components/ThinkingDisplay.d.ts.map +0 -1
- package/dist/ui/components/ToolExecutionMessage.d.ts +0 -8
- package/dist/ui/components/ToolExecutionMessage.d.ts.map +0 -1
- package/dist/ui/components/ToolExecutionStatus.d.ts +0 -10
- package/dist/ui/components/ToolExecutionStatus.d.ts.map +0 -1
- package/dist/ui/components/ToolResult.d.ts +0 -10
- package/dist/ui/components/ToolResult.d.ts.map +0 -1
- package/dist/ui/components/VersionUpdatePrompt.d.ts +0 -9
- package/dist/ui/components/VersionUpdatePrompt.d.ts.map +0 -1
- package/dist/ui/components/WelcomeBanner.d.ts +0 -3
- package/dist/ui/components/WelcomeBanner.d.ts.map +0 -1
- package/dist/ui/components/WorkflowCreatorScreen.d.ts +0 -25
- package/dist/ui/components/WorkflowCreatorScreen.d.ts.map +0 -1
- package/dist/utils/ansi-encoder.d.ts +0 -7
- package/dist/utils/ansi-encoder.d.ts.map +0 -1
- package/dist/utils/chat-formatter.d.ts +0 -12
- package/dist/utils/chat-formatter.d.ts.map +0 -1
- package/dist/utils/command-history.d.ts +0 -24
- package/dist/utils/command-history.d.ts.map +0 -1
- package/dist/utils/context-sanitizer.d.ts +0 -50
- package/dist/utils/context-sanitizer.d.ts.map +0 -1
- package/dist/utils/conversation-logger.d.ts +0 -142
- package/dist/utils/conversation-logger.d.ts.map +0 -1
- package/dist/utils/custom-commands-manager.d.ts +0 -59
- package/dist/utils/custom-commands-manager.d.ts.map +0 -1
- package/dist/utils/editor-utils.d.ts +0 -101
- package/dist/utils/editor-utils.d.ts.map +0 -1
- package/dist/utils/file.d.ts +0 -61
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/input-classifier.d.ts +0 -25
- package/dist/utils/input-classifier.d.ts.map +0 -1
- package/dist/utils/logger.d.ts +0 -17
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/markdown-parser.d.ts +0 -60
- package/dist/utils/markdown-parser.d.ts.map +0 -1
- package/dist/utils/shell.d.ts +0 -47
- package/dist/utils/shell.d.ts.map +0 -1
- package/dist/utils/state.d.ts +0 -13
- package/dist/utils/state.d.ts.map +0 -1
- package/dist/utils/syntax-checker.d.ts +0 -24
- package/dist/utils/syntax-checker.d.ts.map +0 -1
- package/dist/utils/terminal-output.d.ts +0 -25
- package/dist/utils/terminal-output.d.ts.map +0 -1
- package/dist/utils/text-clipboard.d.ts +0 -12
- package/dist/utils/text-clipboard.d.ts.map +0 -1
- package/dist/utils/unicode-sanitizer.d.ts +0 -44
- package/dist/utils/unicode-sanitizer.d.ts.map +0 -1
- package/dist/utils/version-checker.d.ts +0 -14
- package/dist/utils/version-checker.d.ts.map +0 -1
package/dist/tools/get-diff.js
CHANGED
|
@@ -1,445 +1,462 @@
|
|
|
1
|
-
import { exec } from
|
|
2
|
-
import { promisify } from
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
3
|
const execAsync = promisify(exec);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ACTIONS:
|
|
21
|
-
- action="overview" (default): Shows a compact summary of files changed with line counts. Does NOT show content.
|
|
22
|
-
- action="file_diff": Shows the detailed diff for ONE specific file. Requires filePath.
|
|
23
|
-
|
|
24
|
-
SCOPES (controlled by 'scope' parameter):
|
|
25
|
-
- scope="request" (default): Shows changes made only in the current turn (since the last user message).
|
|
26
|
-
- scope="session": Shows cumulative changes made since the beginning of the entire conversation.
|
|
27
|
-
|
|
28
|
-
WORKFLOW:
|
|
29
|
-
1. Call with action="overview" to see changed files.
|
|
30
|
-
2. If needed, call with action="file_diff" and filePath="<path>" to see details.
|
|
4
|
+
const getDiffTool = {
|
|
5
|
+
schema: {
|
|
6
|
+
name: "get_diff",
|
|
7
|
+
description: `View changes made during the current session.
|
|
8
|
+
|
|
9
|
+
ACTIONS:
|
|
10
|
+
- action="overview" (default): Shows a compact summary of files changed with line counts. Does NOT show content.
|
|
11
|
+
- action="file_diff": Shows the detailed diff for ONE specific file. Requires filePath.
|
|
12
|
+
|
|
13
|
+
SCOPES (controlled by 'scope' parameter):
|
|
14
|
+
- scope="request" (default): Shows changes made only in the current turn (since the last user message).
|
|
15
|
+
- scope="session": Shows cumulative changes made since the beginning of the entire conversation.
|
|
16
|
+
|
|
17
|
+
WORKFLOW:
|
|
18
|
+
1. Call with action="overview" to see changed files.
|
|
19
|
+
2. If needed, call with action="file_diff" and filePath="<path>" to see details.
|
|
31
20
|
3. Use scope="session" to review all changes made during the conversation.`,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
required: ['reason_text']
|
|
21
|
+
parameters: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
reason_text: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "REQUIRED: Brief explanation of why you are checking the diff."
|
|
27
|
+
},
|
|
28
|
+
action: {
|
|
29
|
+
type: "string",
|
|
30
|
+
enum: ["overview", "file_diff"],
|
|
31
|
+
description: 'The action to perform. "overview" (summary) or "file_diff" (detailed).'
|
|
32
|
+
},
|
|
33
|
+
scope: {
|
|
34
|
+
type: "string",
|
|
35
|
+
enum: ["request", "session"],
|
|
36
|
+
description: 'Scope of changes. "request" (default): Current turn only. "session": Entire conversation history.'
|
|
37
|
+
},
|
|
38
|
+
filePath: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: 'The file path to get the detailed diff for. REQUIRED for action="file_diff".'
|
|
55
41
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return cp.remoteSessionInfo?.hostname === currentHost;
|
|
89
|
-
});
|
|
90
|
-
if (matching.length > 0) {
|
|
91
|
-
const earliest = matching.reduce((a, b) => (a.createdAtMs < b.createdAtMs ? a : b));
|
|
92
|
-
targetCheckpointId = earliest.id;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
const initialCheckpoint = checkpointManager.getInitialCheckpoint();
|
|
97
|
-
if (initialCheckpoint) {
|
|
98
|
-
targetCheckpointId = initialCheckpoint.id;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
// Fallback to current if getting initial fails
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
switch (action) {
|
|
107
|
-
case 'overview':
|
|
108
|
-
return handleOverview(checkpointManager, targetCheckpointId, context.cwd, scope, isRemote, remoteHandler);
|
|
109
|
-
case 'file_diff':
|
|
110
|
-
if (!filePath) {
|
|
111
|
-
throw new Error('Missing required parameter "filePath" for action "file_diff".');
|
|
112
|
-
}
|
|
113
|
-
return handleFileDiff(checkpointManager, targetCheckpointId, filePath, context.cwd, scope, isRemote, remoteHandler);
|
|
114
|
-
default:
|
|
115
|
-
throw new Error(`Unknown action "${action}". Valid actions are: "overview", "file_diff".`);
|
|
42
|
+
},
|
|
43
|
+
required: ["reason_text"]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
async execute(args, context) {
|
|
47
|
+
const action = args.action || "overview";
|
|
48
|
+
const scope = args.scope || "request";
|
|
49
|
+
const filePath = args.filePath;
|
|
50
|
+
const checkpointManager = context.checkpointManager;
|
|
51
|
+
let targetCheckpointId = context.currentCheckpointId;
|
|
52
|
+
const currentContext = context.contextManager && typeof context.contextManager.getCurrentContext === "function" ? context.contextManager.getCurrentContext() : null;
|
|
53
|
+
const isRemote = currentContext && currentContext.type !== "local";
|
|
54
|
+
let remoteHandler;
|
|
55
|
+
if (isRemote && currentContext.handler) {
|
|
56
|
+
if (typeof currentContext.handler.readFile === "function" && typeof currentContext.handler.writeFile === "function" && typeof currentContext.handler.executeCommand === "function" && typeof currentContext.handler.isConnected === "function") {
|
|
57
|
+
remoteHandler = currentContext.handler;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
targetCheckpointId = await resolveTargetCheckpointId(
|
|
61
|
+
checkpointManager,
|
|
62
|
+
targetCheckpointId,
|
|
63
|
+
scope,
|
|
64
|
+
isRemote,
|
|
65
|
+
currentContext,
|
|
66
|
+
remoteHandler
|
|
67
|
+
);
|
|
68
|
+
switch (action) {
|
|
69
|
+
case "overview":
|
|
70
|
+
return handleOverview(checkpointManager, targetCheckpointId, context.cwd, scope, isRemote, remoteHandler);
|
|
71
|
+
case "file_diff":
|
|
72
|
+
if (!filePath) {
|
|
73
|
+
throw new Error('Missing required parameter "filePath" for action "file_diff".');
|
|
116
74
|
}
|
|
75
|
+
return handleFileDiff(checkpointManager, targetCheckpointId, filePath, context.cwd, scope, isRemote, remoteHandler);
|
|
76
|
+
default:
|
|
77
|
+
throw new Error(`Unknown action "${action}". Valid actions are: "overview", "file_diff".`);
|
|
117
78
|
}
|
|
79
|
+
}
|
|
118
80
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
else {
|
|
155
|
-
output += ` - ${filePath}\n`;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
output += '\n';
|
|
159
|
-
}
|
|
160
|
-
if (changes.added.length > 0) {
|
|
161
|
-
output += `**Added:**\n`;
|
|
162
|
-
for (const filePath of changes.added) {
|
|
163
|
-
const stat = stats.find((s) => s.filePath === filePath);
|
|
164
|
-
if (stat) {
|
|
165
|
-
output += ` - ${filePath} (${stat.insertions} lines)\n`;
|
|
166
|
-
totalInsertions += stat.insertions;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
output += ` - ${filePath}\n`;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
output += '\n';
|
|
173
|
-
}
|
|
174
|
-
if (changes.deleted.length > 0) {
|
|
175
|
-
output += `**Deleted:**\n`;
|
|
176
|
-
for (const filePath of changes.deleted) {
|
|
177
|
-
const stat = stats.find((s) => s.filePath === filePath);
|
|
178
|
-
if (stat) {
|
|
179
|
-
output += ` - ${filePath} (${stat.deletions} lines)\n`;
|
|
180
|
-
totalDeletions += stat.deletions;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
output += ` - ${filePath}\n`;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
output += '\n';
|
|
187
|
-
}
|
|
188
|
-
output += `To see detailed diff for a file, use action="file_diff" with filePath and scope="${scope}".`;
|
|
189
|
-
// Create concise summary for UI
|
|
190
|
-
const summary = `${totalFiles} file(s) changed (+${totalInsertions}, -${totalDeletions})`;
|
|
191
|
-
return JSON.stringify({
|
|
192
|
-
result: output,
|
|
193
|
-
summary: summary
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
// Fall through to git fallback
|
|
199
|
-
}
|
|
81
|
+
function getMatchingCheckpoints(checkpointManager, isRemote, currentContext) {
|
|
82
|
+
if (!checkpointManager || typeof checkpointManager.list !== "function") {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
const all = checkpointManager.list();
|
|
86
|
+
if (!Array.isArray(all) || all.length === 0) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
if (!isRemote) {
|
|
90
|
+
return all.filter((cp) => cp?.contextType === "local");
|
|
91
|
+
}
|
|
92
|
+
const currentType = currentContext?.type;
|
|
93
|
+
const currentHost = currentContext?.metadata?.hostname;
|
|
94
|
+
return all.filter((cp) => {
|
|
95
|
+
if (!cp || cp.contextType !== currentType) return false;
|
|
96
|
+
if (currentType !== "ssh" || !currentHost) return true;
|
|
97
|
+
return cp.remoteSessionInfo?.hostname === currentHost;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async function resolveTargetCheckpointId(checkpointManager, initialCheckpointId, scope, isRemote, currentContext, remoteHandler) {
|
|
101
|
+
if (!checkpointManager) {
|
|
102
|
+
return initialCheckpointId;
|
|
103
|
+
}
|
|
104
|
+
const matching = getMatchingCheckpoints(checkpointManager, isRemote, currentContext);
|
|
105
|
+
let targetCheckpointId = initialCheckpointId;
|
|
106
|
+
if (scope === "session") {
|
|
107
|
+
if (matching.length > 0) {
|
|
108
|
+
const earliest = matching.reduce((a, b) => a.createdAtMs < b.createdAtMs ? a : b);
|
|
109
|
+
return earliest.id;
|
|
110
|
+
}
|
|
111
|
+
if (typeof checkpointManager.getInitialCheckpoint === "function") {
|
|
112
|
+
const initialCheckpoint = checkpointManager.getInitialCheckpoint();
|
|
113
|
+
if (initialCheckpoint) {
|
|
114
|
+
return initialCheckpoint.id;
|
|
115
|
+
}
|
|
200
116
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
117
|
+
return targetCheckpointId;
|
|
118
|
+
}
|
|
119
|
+
if (!targetCheckpointId && matching.length > 0) {
|
|
120
|
+
targetCheckpointId = matching[0].id;
|
|
121
|
+
}
|
|
122
|
+
if (!targetCheckpointId) {
|
|
123
|
+
return targetCheckpointId;
|
|
124
|
+
}
|
|
125
|
+
const targetMeta = matching.find((cp) => cp.id === targetCheckpointId);
|
|
126
|
+
if (targetMeta?.status === "active" && typeof checkpointManager.getSessionChanges === "function") {
|
|
127
|
+
try {
|
|
128
|
+
const sessionData = await checkpointManager.getSessionChanges(targetCheckpointId, remoteHandler);
|
|
129
|
+
const hasChanges = Boolean(sessionData) && (sessionData.changes.added.length > 0 || sessionData.changes.modified.length > 0 || sessionData.changes.deleted.length > 0);
|
|
130
|
+
if (!hasChanges) {
|
|
131
|
+
const previous = matching.find((cp) => cp.id !== targetCheckpointId);
|
|
132
|
+
if (previous) {
|
|
133
|
+
return previous.id;
|
|
205
134
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
summary: 'No remote checkpoint'
|
|
209
|
-
});
|
|
135
|
+
}
|
|
136
|
+
} catch {
|
|
210
137
|
}
|
|
211
|
-
|
|
138
|
+
}
|
|
139
|
+
return targetCheckpointId;
|
|
212
140
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
141
|
+
async function handleOverview(checkpointManager, targetCheckpointId, cwd, scope, isRemote, remoteHandler) {
|
|
142
|
+
const scopeLabel = scope === "session" ? "Total Session Changes" : "Current Request Changes";
|
|
143
|
+
if (checkpointManager && targetCheckpointId) {
|
|
144
|
+
try {
|
|
145
|
+
const sessionData = scope === "session" ? await checkpointManager.getAggregatedSessionChanges?.(remoteHandler) || await checkpointManager.getSessionChanges(targetCheckpointId, remoteHandler) : await checkpointManager.getSessionChanges(targetCheckpointId, remoteHandler);
|
|
146
|
+
if (sessionData) {
|
|
147
|
+
const { changes, stats } = sessionData;
|
|
148
|
+
const totalFiles = changes.added.length + changes.modified.length + changes.deleted.length;
|
|
149
|
+
if (totalFiles === 0) {
|
|
150
|
+
return JSON.stringify({
|
|
151
|
+
result: `No changes detected in ${scope} scope.`,
|
|
152
|
+
summary: `No changes (${scope})`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
let output = `## ${scopeLabel} Overview
|
|
156
|
+
|
|
157
|
+
`;
|
|
158
|
+
output += `**${totalFiles} file(s) changed** (${changes.modified.length} modified, ${changes.added.length} added, ${changes.deleted.length} deleted)
|
|
159
|
+
|
|
160
|
+
`;
|
|
161
|
+
let totalInsertions = 0;
|
|
162
|
+
let totalDeletions = 0;
|
|
163
|
+
if (changes.modified.length > 0) {
|
|
164
|
+
output += `**Modified:**
|
|
165
|
+
`;
|
|
166
|
+
for (const filePath of changes.modified) {
|
|
167
|
+
const stat = stats.find((s) => s.filePath === filePath);
|
|
168
|
+
if (stat) {
|
|
169
|
+
output += ` - ${filePath} (+${stat.insertions}, -${stat.deletions})
|
|
170
|
+
`;
|
|
171
|
+
totalInsertions += stat.insertions;
|
|
172
|
+
totalDeletions += stat.deletions;
|
|
173
|
+
} else {
|
|
174
|
+
output += ` - ${filePath}
|
|
175
|
+
`;
|
|
235
176
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
summary: `No changes: ${filePath}`
|
|
239
|
-
});
|
|
177
|
+
}
|
|
178
|
+
output += "\n";
|
|
240
179
|
}
|
|
241
|
-
|
|
242
|
-
|
|
180
|
+
if (changes.added.length > 0) {
|
|
181
|
+
output += `**Added:**
|
|
182
|
+
`;
|
|
183
|
+
for (const filePath of changes.added) {
|
|
184
|
+
const stat = stats.find((s) => s.filePath === filePath);
|
|
185
|
+
if (stat) {
|
|
186
|
+
output += ` - ${filePath} (${stat.insertions} lines)
|
|
187
|
+
`;
|
|
188
|
+
totalInsertions += stat.insertions;
|
|
189
|
+
} else {
|
|
190
|
+
output += ` - ${filePath}
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
output += "\n";
|
|
243
195
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
196
|
+
if (changes.deleted.length > 0) {
|
|
197
|
+
output += `**Deleted:**
|
|
198
|
+
`;
|
|
199
|
+
for (const filePath of changes.deleted) {
|
|
200
|
+
const stat = stats.find((s) => s.filePath === filePath);
|
|
201
|
+
if (stat) {
|
|
202
|
+
output += ` - ${filePath} (${stat.deletions} lines)
|
|
203
|
+
`;
|
|
204
|
+
totalDeletions += stat.deletions;
|
|
205
|
+
} else {
|
|
206
|
+
output += ` - ${filePath}
|
|
207
|
+
`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
output += "\n";
|
|
249
211
|
}
|
|
212
|
+
output += `To see detailed diff for a file, use action="file_diff" with filePath and scope="${scope}".`;
|
|
213
|
+
const summary = `${totalFiles} file(s) changed (+${totalInsertions}, -${totalDeletions})`;
|
|
250
214
|
return JSON.stringify({
|
|
251
|
-
|
|
252
|
-
|
|
215
|
+
result: output,
|
|
216
|
+
summary
|
|
253
217
|
});
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (isRemote) {
|
|
223
|
+
if (remoteHandler) {
|
|
224
|
+
return await gitDiffStatViaRemote(remoteHandler, cwd, scope);
|
|
254
225
|
}
|
|
255
|
-
return
|
|
226
|
+
return JSON.stringify({
|
|
227
|
+
result: "No checkpoint data and no remote handler available. Reconnect to the session.",
|
|
228
|
+
summary: "No remote checkpoint"
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return await gitDiffStatFallback(cwd, scope);
|
|
256
232
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
async function gitDiffStatFallback(cwd, scope) {
|
|
261
|
-
const scopeNote = scope === 'session' ? '(Session scope requested, but using git status as fallback)' : '(Request scope requested, using git status as fallback)';
|
|
233
|
+
async function handleFileDiff(checkpointManager, targetCheckpointId, filePath, cwd, scope, isRemote, remoteHandler) {
|
|
234
|
+
const scopeLabel = scope === "session" ? "Session" : "Request";
|
|
235
|
+
if (checkpointManager && targetCheckpointId) {
|
|
262
236
|
try {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
237
|
+
const diff = scope === "session" && checkpointManager.getSessionFileDiff ? await checkpointManager.getSessionFileDiff(filePath, remoteHandler) || await checkpointManager.getFileDiff(targetCheckpointId, filePath, remoteHandler) : await checkpointManager.getFileDiff(targetCheckpointId, filePath, remoteHandler);
|
|
238
|
+
if (diff !== null) {
|
|
239
|
+
const lines = diff.split("\n");
|
|
240
|
+
const added = lines.filter((l) => l.startsWith("+") && !l.startsWith("+++")).length;
|
|
241
|
+
const deleted = lines.filter((l) => l.startsWith("-") && !l.startsWith("---")).length;
|
|
242
|
+
const summary = `${filePath} (+${added}, -${deleted})`;
|
|
266
243
|
return JSON.stringify({
|
|
267
|
-
|
|
268
|
-
|
|
244
|
+
result: `## ${scopeLabel} Diff: ${filePath}
|
|
245
|
+
|
|
246
|
+
\`\`\`diff
|
|
247
|
+
${diff}
|
|
248
|
+
\`\`\``,
|
|
249
|
+
summary
|
|
269
250
|
});
|
|
251
|
+
}
|
|
252
|
+
return JSON.stringify({
|
|
253
|
+
result: `No changes found for "${filePath}" in ${scope} scope.`,
|
|
254
|
+
summary: `No changes: ${filePath}`
|
|
255
|
+
});
|
|
256
|
+
} catch (error) {
|
|
270
257
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const { stdout } = await execAsync('git diff --stat', { cwd, maxBuffer: 5 * 1024 * 1024 });
|
|
276
|
-
if (!stdout.trim()) {
|
|
277
|
-
return JSON.stringify({
|
|
278
|
-
result: 'No changes detected (git diff --stat empty).',
|
|
279
|
-
summary: 'No git changes'
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
// Extract file count from git diff --stat output
|
|
283
|
-
// Example: " 2 files changed, 10 insertions(+), 5 deletions(-)"
|
|
284
|
-
const lines = stdout.trim().split('\n');
|
|
285
|
-
const lastLine = lines[lines.length - 1].trim();
|
|
286
|
-
return JSON.stringify({
|
|
287
|
-
result: `## Git Diff Summary ${scopeNote}\n\n\`\`\`\n${stdout.trim()}\n\`\`\`\n\nNote: This is a git-based summary because checkpoints were unavailable.`,
|
|
288
|
-
summary: lastLine || 'Git changes detected'
|
|
289
|
-
});
|
|
258
|
+
}
|
|
259
|
+
if (isRemote) {
|
|
260
|
+
if (remoteHandler) {
|
|
261
|
+
return await gitDiffFileViaRemote(remoteHandler, cwd, filePath, scope);
|
|
290
262
|
}
|
|
291
|
-
|
|
292
|
-
|
|
263
|
+
return JSON.stringify({
|
|
264
|
+
result: `No checkpoint data and no remote handler available for "${filePath}". Reconnect to the session.`,
|
|
265
|
+
summary: `No remote checkpoint: ${filePath}`
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return await gitDiffFileFallback(cwd, filePath, scope);
|
|
269
|
+
}
|
|
270
|
+
async function gitDiffStatFallback(cwd, scope) {
|
|
271
|
+
const scopeNote = scope === "session" ? "(Session scope requested, but using git status as fallback)" : "(Request scope requested, using git status as fallback)";
|
|
272
|
+
try {
|
|
273
|
+
await execAsync("git rev-parse --git-dir", { cwd });
|
|
274
|
+
} catch {
|
|
275
|
+
return JSON.stringify({
|
|
276
|
+
result: "No active checkpoint available and not in a git repository.",
|
|
277
|
+
summary: "No git repo"
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
const { stdout } = await execAsync("git diff --stat", { cwd, maxBuffer: 5 * 1024 * 1024 });
|
|
282
|
+
if (!stdout.trim()) {
|
|
283
|
+
return JSON.stringify({
|
|
284
|
+
result: "No changes detected (git diff --stat empty).",
|
|
285
|
+
summary: "No git changes"
|
|
286
|
+
});
|
|
293
287
|
}
|
|
288
|
+
const lines = stdout.trim().split("\n");
|
|
289
|
+
const lastLine = lines[lines.length - 1].trim();
|
|
290
|
+
return JSON.stringify({
|
|
291
|
+
result: `## Git Diff Summary ${scopeNote}
|
|
292
|
+
|
|
293
|
+
\`\`\`
|
|
294
|
+
${stdout.trim()}
|
|
295
|
+
\`\`\`
|
|
296
|
+
|
|
297
|
+
Note: This is a git-based summary because checkpoints were unavailable.`,
|
|
298
|
+
summary: lastLine || "Git changes detected"
|
|
299
|
+
});
|
|
300
|
+
} catch (error) {
|
|
301
|
+
throw new Error(`Failed to get git diff stat: ${error.message}`);
|
|
302
|
+
}
|
|
294
303
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Fallback: git diff file
|
|
297
|
-
*/
|
|
298
304
|
async function gitDiffFileFallback(cwd, filePath, scope) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
// Calculate lines added/deleted
|
|
317
|
-
const lines = stdout.split('\n');
|
|
318
|
-
const added = lines.filter((l) => l.startsWith('+') && !l.startsWith('+++')).length;
|
|
319
|
-
const deleted = lines.filter((l) => l.startsWith('-') && !l.startsWith('---')).length;
|
|
320
|
-
const summary = `${filePath} (git: +${added}, -${deleted})`;
|
|
321
|
-
return JSON.stringify({
|
|
322
|
-
result: `## Git Diff: ${filePath} (${scope})\n\n\`\`\`diff\n${stdout.trim()}\n\`\`\``,
|
|
323
|
-
summary: summary
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
catch (error) {
|
|
327
|
-
throw new Error(`Failed to get git diff for "${filePath}": ${error.message}`);
|
|
305
|
+
try {
|
|
306
|
+
await execAsync("git rev-parse --git-dir", { cwd });
|
|
307
|
+
} catch {
|
|
308
|
+
return JSON.stringify({
|
|
309
|
+
result: `No active checkpoint and not in a git repo. Cannot diff "${filePath}".`,
|
|
310
|
+
summary: "No git repo"
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
const { stdout } = await execAsync(`git diff -- "${filePath}"`, { cwd, maxBuffer: 5 * 1024 * 1024 });
|
|
315
|
+
if (!stdout.trim()) {
|
|
316
|
+
return JSON.stringify({
|
|
317
|
+
result: `No changes detected in "${filePath}" (via git diff).`,
|
|
318
|
+
summary: `No changes: ${filePath}`
|
|
319
|
+
});
|
|
328
320
|
}
|
|
321
|
+
const lines = stdout.split("\n");
|
|
322
|
+
const added = lines.filter((l) => l.startsWith("+") && !l.startsWith("+++")).length;
|
|
323
|
+
const deleted = lines.filter((l) => l.startsWith("-") && !l.startsWith("---")).length;
|
|
324
|
+
const summary = `${filePath} (git: +${added}, -${deleted})`;
|
|
325
|
+
return JSON.stringify({
|
|
326
|
+
result: `## Git Diff: ${filePath} (${scope})
|
|
327
|
+
|
|
328
|
+
\`\`\`diff
|
|
329
|
+
${stdout.trim()}
|
|
330
|
+
\`\`\``,
|
|
331
|
+
summary
|
|
332
|
+
});
|
|
333
|
+
} catch (error) {
|
|
334
|
+
throw new Error(`Failed to get git diff for "${filePath}": ${error.message}`);
|
|
335
|
+
}
|
|
329
336
|
}
|
|
330
|
-
/**
|
|
331
|
-
* Remote fallback: Run git diff --stat on the remote machine via handler
|
|
332
|
-
*/
|
|
333
337
|
async function gitDiffStatViaRemote(handler, cwd, scope) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
result: 'No active checkpoint available and remote directory is not a git repository.',
|
|
343
|
-
summary: 'No git repo (remote)'
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
const result = await handler.executeCommand(`cd "${cwd}" && git diff --stat 2>/dev/null`);
|
|
347
|
-
const stdout = result.stdout?.trim() || '';
|
|
348
|
-
if (!stdout) {
|
|
349
|
-
// Also try git status for untracked/new files
|
|
350
|
-
const statusResult = await handler.executeCommand(`cd "${cwd}" && git status --porcelain 2>/dev/null`);
|
|
351
|
-
const statusOut = statusResult.stdout?.trim() || '';
|
|
352
|
-
if (!statusOut) {
|
|
353
|
-
return JSON.stringify({
|
|
354
|
-
result: 'No changes detected (git diff --stat empty on remote).',
|
|
355
|
-
summary: 'No git changes (remote)'
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
// Parse git status --porcelain output for a summary
|
|
359
|
-
const statusLines = statusOut.split('\n').filter((l) => l.trim().length > 0);
|
|
360
|
-
const newFiles = statusLines.filter((l) => l.startsWith('??') || l.startsWith('A '));
|
|
361
|
-
const modifiedFiles = statusLines.filter((l) => l.startsWith(' M') || l.startsWith('M '));
|
|
362
|
-
const deletedFiles = statusLines.filter((l) => l.startsWith(' D') || l.startsWith('D '));
|
|
363
|
-
let output = `## Remote Git Status ${scopeNote}\n\n`;
|
|
364
|
-
output += `**${statusLines.length} file(s) with changes** (${modifiedFiles.length} modified, ${newFiles.length} new, ${deletedFiles.length} deleted)\n\n`;
|
|
365
|
-
output += `\`\`\`\n${statusOut}\n\`\`\`\n\nNote: This is a git-based summary because checkpoints were unavailable.`;
|
|
366
|
-
return JSON.stringify({
|
|
367
|
-
result: output,
|
|
368
|
-
summary: `${statusLines.length} file(s) changed (remote git status)`
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
const lines = stdout.split('\n');
|
|
372
|
-
const lastLine = lines[lines.length - 1].trim();
|
|
373
|
-
return JSON.stringify({
|
|
374
|
-
result: `## Remote Git Diff Summary ${scopeNote}\n\n\`\`\`\n${stdout}\n\`\`\`\n\nNote: This is a git-based summary because checkpoints were unavailable.`,
|
|
375
|
-
summary: lastLine || 'Git changes detected (remote)'
|
|
376
|
-
});
|
|
338
|
+
const scopeNote = scope === "session" ? "(Session scope requested, using remote git status as fallback)" : "(Request scope requested, using remote git status as fallback)";
|
|
339
|
+
try {
|
|
340
|
+
const gitCheck = await handler.executeCommand(`cd "${cwd}" && git rev-parse --git-dir 2>/dev/null`);
|
|
341
|
+
if (gitCheck.exitCode !== 0) {
|
|
342
|
+
return JSON.stringify({
|
|
343
|
+
result: "No active checkpoint available and remote directory is not a git repository.",
|
|
344
|
+
summary: "No git repo (remote)"
|
|
345
|
+
});
|
|
377
346
|
}
|
|
378
|
-
|
|
347
|
+
const result = await handler.executeCommand(`cd "${cwd}" && git diff --stat 2>/dev/null`);
|
|
348
|
+
const stdout = result.stdout?.trim() || "";
|
|
349
|
+
if (!stdout) {
|
|
350
|
+
const statusResult = await handler.executeCommand(`cd "${cwd}" && git status --porcelain 2>/dev/null`);
|
|
351
|
+
const statusOut = statusResult.stdout?.trim() || "";
|
|
352
|
+
if (!statusOut) {
|
|
379
353
|
return JSON.stringify({
|
|
380
|
-
|
|
381
|
-
|
|
354
|
+
result: "No changes detected (git diff --stat empty on remote).",
|
|
355
|
+
summary: "No git changes (remote)"
|
|
382
356
|
});
|
|
357
|
+
}
|
|
358
|
+
const statusLines = statusOut.split("\n").filter((l) => l.trim().length > 0);
|
|
359
|
+
const newFiles = statusLines.filter((l) => l.startsWith("??") || l.startsWith("A "));
|
|
360
|
+
const modifiedFiles = statusLines.filter((l) => l.startsWith(" M") || l.startsWith("M "));
|
|
361
|
+
const deletedFiles = statusLines.filter((l) => l.startsWith(" D") || l.startsWith("D "));
|
|
362
|
+
let output = `## Remote Git Status ${scopeNote}
|
|
363
|
+
|
|
364
|
+
`;
|
|
365
|
+
output += `**${statusLines.length} file(s) with changes** (${modifiedFiles.length} modified, ${newFiles.length} new, ${deletedFiles.length} deleted)
|
|
366
|
+
|
|
367
|
+
`;
|
|
368
|
+
output += `\`\`\`
|
|
369
|
+
${statusOut}
|
|
370
|
+
\`\`\`
|
|
371
|
+
|
|
372
|
+
Note: This is a git-based summary because checkpoints were unavailable.`;
|
|
373
|
+
return JSON.stringify({
|
|
374
|
+
result: output,
|
|
375
|
+
summary: `${statusLines.length} file(s) changed (remote git status)`
|
|
376
|
+
});
|
|
383
377
|
}
|
|
378
|
+
const lines = stdout.split("\n");
|
|
379
|
+
const lastLine = lines[lines.length - 1].trim();
|
|
380
|
+
return JSON.stringify({
|
|
381
|
+
result: `## Remote Git Diff Summary ${scopeNote}
|
|
382
|
+
|
|
383
|
+
\`\`\`
|
|
384
|
+
${stdout}
|
|
385
|
+
\`\`\`
|
|
386
|
+
|
|
387
|
+
Note: This is a git-based summary because checkpoints were unavailable.`,
|
|
388
|
+
summary: lastLine || "Git changes detected (remote)"
|
|
389
|
+
});
|
|
390
|
+
} catch (error) {
|
|
391
|
+
return JSON.stringify({
|
|
392
|
+
result: `Failed to get remote git diff: ${error.message}`,
|
|
393
|
+
summary: "Remote git diff failed"
|
|
394
|
+
});
|
|
395
|
+
}
|
|
384
396
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Remote fallback: Run git diff for a specific file on the remote machine via handler
|
|
387
|
-
*/
|
|
388
397
|
async function gitDiffFileViaRemote(handler, cwd, filePath, scope) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
const result = await handler.executeCommand(`cd "${cwd}" && git diff -- "${filePath}" 2>/dev/null`);
|
|
399
|
-
const stdout = result.stdout?.trim() || '';
|
|
400
|
-
if (!stdout) {
|
|
401
|
-
// Check if file is untracked (new)
|
|
402
|
-
const statusResult = await handler.executeCommand(`cd "${cwd}" && git status --porcelain -- "${filePath}" 2>/dev/null`);
|
|
403
|
-
const statusOut = statusResult.stdout?.trim() || '';
|
|
404
|
-
if (statusOut.startsWith('??')) {
|
|
405
|
-
// Untracked file — show the entire content as additions
|
|
406
|
-
try {
|
|
407
|
-
const content = await handler.readFile(cwd + '/' + filePath);
|
|
408
|
-
const lines = content.split('\n');
|
|
409
|
-
let diff = `--- /dev/null\n+++ b/${filePath}\n@@ -0,0 +1,${lines.length} @@\n`;
|
|
410
|
-
diff += lines.map((l) => `+${l}`).join('\n');
|
|
411
|
-
return JSON.stringify({
|
|
412
|
-
result: `## Remote Git Diff: ${filePath} (new file, ${scope})\n\n\`\`\`diff\n${diff}\n\`\`\``,
|
|
413
|
-
summary: `${filePath} (new: +${lines.length} lines)`
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
catch {
|
|
417
|
-
return JSON.stringify({
|
|
418
|
-
result: `File "${filePath}" is new (untracked) but could not be read.`,
|
|
419
|
-
summary: `${filePath} (new, unreadable)`
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
return JSON.stringify({
|
|
424
|
-
result: `No changes detected in "${filePath}" (via remote git diff).`,
|
|
425
|
-
summary: `No changes: ${filePath}`
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
// Calculate lines added/deleted
|
|
429
|
-
const lines = stdout.split('\n');
|
|
430
|
-
const added = lines.filter((l) => l.startsWith('+') && !l.startsWith('+++')).length;
|
|
431
|
-
const deleted = lines.filter((l) => l.startsWith('-') && !l.startsWith('---')).length;
|
|
432
|
-
const summary = `${filePath} (remote git: +${added}, -${deleted})`;
|
|
433
|
-
return JSON.stringify({
|
|
434
|
-
result: `## Remote Git Diff: ${filePath} (${scope})\n\n\`\`\`diff\n${stdout}\n\`\`\``,
|
|
435
|
-
summary: summary
|
|
436
|
-
});
|
|
398
|
+
try {
|
|
399
|
+
const gitCheck = await handler.executeCommand(`cd "${cwd}" && git rev-parse --git-dir 2>/dev/null`);
|
|
400
|
+
if (gitCheck.exitCode !== 0) {
|
|
401
|
+
return JSON.stringify({
|
|
402
|
+
result: `No active checkpoint and remote directory is not a git repo. Cannot diff "${filePath}".`,
|
|
403
|
+
summary: "No git repo (remote)"
|
|
404
|
+
});
|
|
437
405
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
406
|
+
const result = await handler.executeCommand(`cd "${cwd}" && git diff -- "${filePath}" 2>/dev/null`);
|
|
407
|
+
const stdout = result.stdout?.trim() || "";
|
|
408
|
+
if (!stdout) {
|
|
409
|
+
const statusResult = await handler.executeCommand(`cd "${cwd}" && git status --porcelain -- "${filePath}" 2>/dev/null`);
|
|
410
|
+
const statusOut = statusResult.stdout?.trim() || "";
|
|
411
|
+
if (statusOut.startsWith("??")) {
|
|
412
|
+
try {
|
|
413
|
+
const content = await handler.readFile(cwd + "/" + filePath);
|
|
414
|
+
const lines2 = content.split("\n");
|
|
415
|
+
let diff = `--- /dev/null
|
|
416
|
+
+++ b/${filePath}
|
|
417
|
+
@@ -0,0 +1,${lines2.length} @@
|
|
418
|
+
`;
|
|
419
|
+
diff += lines2.map((l) => `+${l}`).join("\n");
|
|
420
|
+
return JSON.stringify({
|
|
421
|
+
result: `## Remote Git Diff: ${filePath} (new file, ${scope})
|
|
422
|
+
|
|
423
|
+
\`\`\`diff
|
|
424
|
+
${diff}
|
|
425
|
+
\`\`\``,
|
|
426
|
+
summary: `${filePath} (new: +${lines2.length} lines)`
|
|
427
|
+
});
|
|
428
|
+
} catch {
|
|
429
|
+
return JSON.stringify({
|
|
430
|
+
result: `File "${filePath}" is new (untracked) but could not be read.`,
|
|
431
|
+
summary: `${filePath} (new, unreadable)`
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return JSON.stringify({
|
|
436
|
+
result: `No changes detected in "${filePath}" (via remote git diff).`,
|
|
437
|
+
summary: `No changes: ${filePath}`
|
|
438
|
+
});
|
|
443
439
|
}
|
|
440
|
+
const lines = stdout.split("\n");
|
|
441
|
+
const added = lines.filter((l) => l.startsWith("+") && !l.startsWith("+++")).length;
|
|
442
|
+
const deleted = lines.filter((l) => l.startsWith("-") && !l.startsWith("---")).length;
|
|
443
|
+
const summary = `${filePath} (remote git: +${added}, -${deleted})`;
|
|
444
|
+
return JSON.stringify({
|
|
445
|
+
result: `## Remote Git Diff: ${filePath} (${scope})
|
|
446
|
+
|
|
447
|
+
\`\`\`diff
|
|
448
|
+
${stdout}
|
|
449
|
+
\`\`\``,
|
|
450
|
+
summary
|
|
451
|
+
});
|
|
452
|
+
} catch (error) {
|
|
453
|
+
return JSON.stringify({
|
|
454
|
+
result: `Failed to get remote git diff for "${filePath}": ${error.message}`,
|
|
455
|
+
summary: `Remote git diff failed: ${filePath}`
|
|
456
|
+
});
|
|
457
|
+
}
|
|
444
458
|
}
|
|
459
|
+
export {
|
|
460
|
+
getDiffTool
|
|
461
|
+
};
|
|
445
462
|
//# sourceMappingURL=get-diff.js.map
|