Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

feat(launch): show and auto-install Cline CLI (#16402)

Eva H06ff72824637
diff --git a/cmd/launch/cline.go b/cmd/launch/cline.go
index 656a0ad31..d73453119 100644
--- a/cmd/launch/cline.go
+++ b/cmd/launch/cline.go
@@ -21,18 +21,53 @@ type Cline struct{}
func (c *Cline) String() string { return "Cline" }
func (c *Cline) Run(model string, _ []LaunchModel, args []string) error {
- if _, err := exec.LookPath("cline"); err != nil {
- return fmt.Errorf("cline is not installed, install with: npm install -g cline")
+ bin, err := ensureClineInstalled()
+ if err != nil {
+ return err
}
launchArgs := clineLaunchArgs(model, args)
- cmd := exec.Command("cline", launchArgs...)
+ cmd := exec.Command(bin, launchArgs...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
+func ensureClineInstalled() (string, error) {
+ if _, err := exec.LookPath("cline"); err == nil {
+ return "cline", nil
+ }
+
+ if _, err := exec.LookPath("npm"); err != nil {
+ return "", fmt.Errorf("cline is not installed and required dependencies are missing\n\nInstall the following first:\n npm (Node.js): https://nodejs.org/\n\nThen re-run:\n ollama launch cline")
+ }
+
+ ok, err := ConfirmPrompt("Cline is not installed. Install with npm?")
+ if err != nil {
+ return "", err
+ }
+ if !ok {
+ return "", fmt.Errorf("cline installation cancelled")
+ }
+
+ fmt.Fprintf(os.Stderr, "\nInstalling Cline...\n")
+ cmd := exec.Command("npm", "install", "-g", "cline@latest")
+ cmd.Stdin = os.Stdin
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ if err := cmd.Run(); err != nil {
+ return "", fmt.Errorf("failed to install cline: %w", err)
+ }
+
+ if _, err := exec.LookPath("cline"); err != nil {
+ return "", fmt.Errorf("cline was installed but the binary was not found on PATH\n\nYou may need to restart your shell")
+ }
+
+ fmt.Fprintf(os.Stderr, "%sCline installed successfully%s\n\n", ansiGreen, ansiReset)
+ return "cline", nil
+}
+
func clineLaunchArgs(model string, extra []string) []string {
return extra
}
diff --git a/cmd/launch/cline_test.go b/cmd/launch/cline_test.go
index 57fc0dc27..4d0c4cc0f 100644
--- a/cmd/launch/cline_test.go
+++ b/cmd/launch/cline_test.go
@@ -2,8 +2,11 @@ package launch
import (
"encoding/json"
+ "fmt"
"os"
"path/filepath"
+ "runtime"
+ "strings"
"testing"
)
@@ -25,6 +28,55 @@ func TestClineIntegration(t *testing.T) {
})
}
+func TestEnsureClineInstalled(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("uses a POSIX shell test binary")
+ }
+
+ tmpDir := t.TempDir()
+ setTestHome(t, tmpDir)
+ t.Setenv("PATH", tmpDir)
+
+ clinePath := filepath.Join(tmpDir, "cline")
+ npmScript := fmt.Sprintf(`#!/bin/sh
+printf '%%s\n' "$*" > "$HOME/npm-calls.log"
+/bin/cat > %q <<'EOF'
+#!/bin/sh
+exit 0
+EOF
+/bin/chmod +x %q
+exit 0
+`, clinePath, clinePath)
+ if err := os.WriteFile(filepath.Join(tmpDir, "npm"), []byte(npmScript), 0o755); err != nil {
+ t.Fatal(err)
+ }
+
+ oldConfirmPrompt := DefaultConfirmPrompt
+ DefaultConfirmPrompt = func(prompt string, options ConfirmOptions) (bool, error) {
+ if prompt != "Cline is not installed. Install with npm?" {
+ t.Fatalf("unexpected prompt: %q", prompt)
+ }
+ return true, nil
+ }
+ defer func() { DefaultConfirmPrompt = oldConfirmPrompt }()
+
+ bin, err := ensureClineInstalled()
+ if err != nil {
+ t.Fatalf("ensureClineInstalled() error = %v", err)
+ }
+ if bin != "cline" {
+ t.Fatalf("ensureClineInstalled() bin = %q, want %q", bin, "cline")
+ }
+
+ data, err := os.ReadFile(filepath.Join(tmpDir, "npm-calls.log"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got := strings.TrimSpace(string(data)); got != "install -g cline@latest" {
+ t.Fatalf("npm args = %q, want %q", got, "install -g cline@latest")
+ }
+}
+
func TestClineEdit(t *testing.T) {
c := &Cline{}
tmpDir := t.TempDir()
diff --git a/cmd/launch/integrations_test.go b/cmd/launch/integrations_test.go
index 7b4347a06..9e34b248c 100644
--- a/cmd/launch/integrations_test.go
+++ b/cmd/launch/integrations_test.go
@@ -83,7 +83,7 @@ func TestIntegrationLookup(t *testing.T) {
}
func TestIntegrationRegistry(t *testing.T) {
- expectedIntegrations := []string{"claude", "claude-desktop", "codex", "codex-app", "kimi", "droid", "opencode", "hermes", "pool"}
+ expectedIntegrations := []string{"claude", "claude-desktop", "cline", "codex", "codex-app", "kimi", "droid", "opencode", "hermes", "pool"}
for _, name := range expectedIntegrations {
t.Run(name, func(t *testing.T) {
r, ok := integrations[name]
@@ -100,7 +100,7 @@ func TestIntegrationRegistry(t *testing.T) {
func TestHiddenIntegrationsExcludedFromVisibleLists(t *testing.T) {
for _, info := range ListIntegrationInfos() {
switch info.Name {
- case "cline", "vscode", "kimi":
+ case "vscode", "kimi":
t.Fatalf("hidden integration %q should not appear in ListIntegrationInfos", info.Name)
}
}
@@ -1865,7 +1865,7 @@ func TestListIntegrationInfos(t *testing.T) {
})
t.Run("includes known integrations", func(t *testing.T) {
- known := map[string]bool{"claude": false, "codex": false, "opencode": false}
+ known := map[string]bool{"claude": false, "cline": false, "codex": false, "opencode": false}
if codexAppSupported() == nil {
known["codex-app"] = false
}
@@ -2015,6 +2015,7 @@ func TestIntegration_AutoInstallable(t *testing.T) {
{"openclaw", true},
{"pi", true},
{"hermes", true},
+ {"cline", true},
{"claude", false},
{"claude-desktop", false},
{"codex", false},
diff --git a/cmd/launch/registry.go b/cmd/launch/registry.go
index a69a82bd1..209dd4e3e 100644
--- a/cmd/launch/registry.go
+++ b/cmd/launch/registry.go
@@ -33,7 +33,7 @@ type IntegrationInfo struct {
Description string
}
-var launcherIntegrationOrder = []string{"claude", "codex-app", "hermes", "openclaw", "opencode", "codex", "copilot", "droid", "pi", "pool"}
+var launcherIntegrationOrder = []string{"claude", "codex-app", "hermes", "openclaw", "opencode", "codex", "copilot", "cline", "droid", "pi", "pool"}
var integrationSpecs = []*IntegrationSpec{
{
@@ -65,13 +65,16 @@ var integrationSpecs = []*IntegrationSpec{
Name: "cline",
Runner: &Cline{},
Description: "Autonomous coding agent with parallel execution",
- Hidden: true,
Install: IntegrationInstallSpec{
CheckInstalled: func() bool {
_, err := exec.LookPath("cline")
return err == nil
},
- Command: []string{"npm", "install", "-g", "cline"},
+ EnsureInstalled: func() error {
+ _, err := ensureClineInstalled()
+ return err
+ },
+ Command: []string{"npm", "install", "-g", "cline@latest"},
},
},
{