diff --git a/cmd/daytona/config/const.go b/cmd/daytona/config/const.go index bd6de4a0d1..cca7dc16f2 100644 --- a/cmd/daytona/config/const.go +++ b/cmd/daytona/config/const.go @@ -31,6 +31,7 @@ func GetIdeList() []Ide { {"jupyter", "Jupyter"}, {"fleet", "Fleet"}, {"zed", "Zed"}, + {"windsurf", "Windsurf"}, } sortedJbIdes := []Ide{} diff --git a/docs/daytona_code.md b/docs/daytona_code.md index f376ea8cce..1129f89da6 100644 --- a/docs/daytona_code.md +++ b/docs/daytona_code.md @@ -9,7 +9,7 @@ daytona code [WORKSPACE] [PROJECT] [flags] ### Options ``` - -i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + -i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) -y, --yes Automatically confirm any prompts ``` diff --git a/docs/daytona_create.md b/docs/daytona_create.md index 80accb7306..f30cf0b64f 100644 --- a/docs/daytona_create.md +++ b/docs/daytona_create.md @@ -17,7 +17,7 @@ daytona create [REPOSITORY_URL | PROJECT_CONFIG_NAME]... [flags] --devcontainer-path string Automatically assign the devcontainer builder with the path passed as the flag value --env stringArray Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...') --git-provider-config string Specify the Git provider configuration ID or alias - -i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + -i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) --manual Manually enter the Git repository --multi-project Workspace with multiple projects/repos --name string Specify the workspace name diff --git a/hack/docs/daytona_code.yaml b/hack/docs/daytona_code.yaml index 840cdf1741..218b5d6024 100644 --- a/hack/docs/daytona_code.yaml +++ b/hack/docs/daytona_code.yaml @@ -5,7 +5,7 @@ options: - name: ide shorthand: i usage: | - Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) - name: "yes" shorthand: "y" default_value: "false" diff --git a/hack/docs/daytona_create.yaml b/hack/docs/daytona_create.yaml index d5ff472400..034b54cd4f 100644 --- a/hack/docs/daytona_create.yaml +++ b/hack/docs/daytona_create.yaml @@ -28,7 +28,7 @@ options: - name: ide shorthand: i usage: | - Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) + Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, windsurf, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm) - name: manual default_value: "false" usage: Manually enter the Git repository diff --git a/pkg/cmd/ide.go b/pkg/cmd/ide.go index c7af97a507..2ba53a3a79 100644 --- a/pkg/cmd/ide.go +++ b/pkg/cmd/ide.go @@ -60,6 +60,11 @@ var ideCmd = &cobra.Command{ if err != nil { log.Error(err) } + case "windsurf": + _, err := ide_util.GetWindsurfBinaryPath() + if err != nil { + log.Error(err) + } } jetbrainsIdes := jetbrains.GetIdes() diff --git a/pkg/cmd/workspace/code.go b/pkg/cmd/workspace/code.go index 59d356fbae..7033894323 100644 --- a/pkg/cmd/workspace/code.go +++ b/pkg/cmd/workspace/code.go @@ -193,6 +193,8 @@ func openIDE(ideId string, activeProfile config.Profile, workspaceId string, pro return ide.OpenFleet(activeProfile, workspaceId, projectName, gpgKey) case "zed": return ide.OpenZed(activeProfile, workspaceId, projectName, gpgKey) + case "windsurf": + return ide.OpenWindsurf(activeProfile, workspaceId, projectName, projectProviderMetadata, gpgKey) default: _, ok := jetbrains.GetIdes()[jetbrains.Id(ideId)] if ok { diff --git a/pkg/ide/windsurf.go b/pkg/ide/windsurf.go new file mode 100644 index 0000000000..7b511667a8 --- /dev/null +++ b/pkg/ide/windsurf.go @@ -0,0 +1,57 @@ +// Copyright 2024 Daytona Platforms Inc. +// SPDX-License-Identifier: Apache-2.0 + +package ide + +import ( + "errors" + "fmt" + "os/exec" + + "github.com/daytonaio/daytona/cmd/daytona/config" + "github.com/daytonaio/daytona/internal/util" + "github.com/daytonaio/daytona/pkg/build/devcontainer" +) + +func OpenWindsurf(activeProfile config.Profile, workspaceId string, projectName string, projectProviderMetadata string, gpgkey string) error { + path, err := GetWindsurfBinaryPath() + if err != nil { + return err + } + + projectHostname := config.GetProjectHostname(activeProfile.Id, workspaceId, projectName) + + projectDir, err := util.GetProjectDir(activeProfile, workspaceId, projectName, gpgkey) + if err != nil { + return err + } + + commandArgument := fmt.Sprintf("vscode-remote://ssh-remote+%s/%s", projectHostname, projectDir) + + windsurfCommand := exec.Command(path, "--disable-extension", "ms-vscode-remote.remote-containers", "--folder-uri", commandArgument) + + err = windsurfCommand.Run() + if err != nil { + return err + } + + if projectProviderMetadata == "" { + return nil + } + + return setupVSCodeCustomizations(projectHostname, projectProviderMetadata, devcontainer.Vscode, "*/.windsurf-server/*/bin/windsurf-server", "$HOME/.windsurf-server/data/Machine/settings.json", ".daytona-customizations-lock-windsurf") +} + +func GetWindsurfBinaryPath() (string, error) { + path, err := exec.LookPath("windsurf") + if err == nil { + return path, err + } + + redBold := "\033[1;31m" // ANSI escape code for red and bold + reset := "\033[0m" // ANSI escape code to reset text formatting + + errorMessage := "Please install Windsurf from https://codeium.com/windsurf/download and ensure it's in your PATH.\n" + + return "", errors.New(redBold + errorMessage + reset) +}