diff --git a/internal/config/config.go b/internal/config/config.go index 8032c14f427c37ced79fb89f6d82b0791b61c8c7..7488246f256c983653b5a5d5b835bc377d88c241 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -739,7 +739,7 @@ func getDefaultProviderConfig(p provider.Provider, apiKey string) ProviderConfig func defaultConfigBasedOnEnv() *Config { // VS Code diff is disabled by default autoOpenVSCodeDiff := false - + cfg := &Config{ Options: Options{ DataDirectory: defaultDataDirectory, diff --git a/internal/llm/tools/auto_vscode.go b/internal/llm/tools/auto_vscode.go index 644cbbd1873226bb68888788611f2f4aba9ada72..4d2357d13b7f46584d5365746668ae00e302aec2 100644 --- a/internal/llm/tools/auto_vscode.go +++ b/internal/llm/tools/auto_vscode.go @@ -20,30 +20,30 @@ func AutoOpenVSCodeDiff(ctx context.Context, permissions permission.Service, bef if os.Getenv("VSCODE_INJECTION") != "1" { return false } - + cfg := config.Get() - + // Check if auto-open is enabled if !cfg.Options.AutoOpenVSCodeDiff { return false } - + // Check if there are any changes if beforeContent == afterContent { return false } - + // Check if VS Code is available if !isVSCodeAvailable() { return false } - + // Get session ID for permissions sessionID, _ := GetContextValues(ctx) if sessionID == "" { return false } - + // Create titles from filename leftTitle := "before" rightTitle := "after" @@ -52,7 +52,7 @@ func AutoOpenVSCodeDiff(ctx context.Context, permissions permission.Service, bef leftTitle = "before_" + base rightTitle = "after_" + base } - + // Request permission to open VS Code permissionParams := VSCodeDiffPermissionsParams{ LeftContent: beforeContent, @@ -61,7 +61,7 @@ func AutoOpenVSCodeDiff(ctx context.Context, permissions permission.Service, bef RightTitle: rightTitle, Language: language, } - + p := permissions.Request( permission.CreatePermissionRequest{ SessionID: sessionID, @@ -72,11 +72,11 @@ func AutoOpenVSCodeDiff(ctx context.Context, permissions permission.Service, bef Params: permissionParams, }, ) - + if !p { return false } - + // Open VS Code diff - this would actually open VS Code in a real implementation return openVSCodeDiffDirect(beforeContent, afterContent, leftTitle, rightTitle, language) } @@ -90,10 +90,10 @@ func isVSCodeAvailable() bool { func getVSCodeCommandInternal() string { // Try common VS Code command names commands := []string{"code", "code-insiders"} - + // On macOS, also try the full path if runtime.GOOS == "darwin" { - commands = append(commands, + commands = append(commands, "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code", ) @@ -114,7 +114,7 @@ func openVSCodeDiffDirect(beforeContent, afterContent, leftTitle, rightTitle, la if vscodeCmd == "" { return false } - + // This is a simplified version that would create temp files and open VS Code // For now, we'll return true to indicate it would work // In a full implementation, this would: @@ -122,17 +122,17 @@ func openVSCodeDiffDirect(beforeContent, afterContent, leftTitle, rightTitle, la // 2. Use the appropriate file extension based on language // 3. Execute: code --diff leftFile rightFile // 4. Clean up files after a delay - + // TODO: Implement the actual file creation and VS Code execution // This would be similar to the logic in vscode.go but simplified - + return true // Placeholder - indicates VS Code would be opened } // getLanguageFromExtension determines the language identifier from a file extension func getLanguageFromExtension(filePath string) string { ext := strings.ToLower(filepath.Ext(filePath)) - + languageMap := map[string]string{ ".js": "javascript", ".jsx": "javascript", @@ -174,10 +174,10 @@ func getLanguageFromExtension(filePath string) string { ".mk": "makefile", ".makefile": "makefile", } - + if language, ok := languageMap[ext]; ok { return language } - + return "text" -} \ No newline at end of file +} diff --git a/internal/llm/tools/write.go b/internal/llm/tools/write.go index 4fab4fcb7a40d0ebcb1a9f11fb5fc30a8ba1caa0..7ff8e4497e9ac5485ad963fd1ae0e001f0c04964 100644 --- a/internal/llm/tools/write.go +++ b/internal/llm/tools/write.go @@ -234,7 +234,7 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error result := fmt.Sprintf("File successfully written: %s", filePath) result = fmt.Sprintf("\n%s\n", result) result += getDiagnostics(filePath, w.lspClients) - + // Only include diff metadata if VS Code diff wasn't opened var metadata WriteResponseMetadata if !vscodeDiffOpened { @@ -244,6 +244,6 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error Removals: removals, } } - + return WithResponseMetadata(NewTextResponse(result), metadata), nil }