Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

working on upgrades

Dane Schneiderd9fb12e67c33
diff --git a/app/cli/go.mod b/app/cli/go.mod
index c38f941f..9a4bce89 100644
--- a/app/cli/go.mod
+++ b/app/cli/go.mod
@@ -53,6 +53,7 @@ require (
github.com/charmbracelet/glow v1.5.1
github.com/cqroot/prompt v0.9.3
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
+ github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
diff --git a/app/cli/go.sum b/app/cli/go.sum
index 676cb7a6..f224b5c2 100644
--- a/app/cli/go.sum
+++ b/app/cli/go.sum
@@ -464,6 +464,8 @@ github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
+github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
diff --git a/app/cli/main.go b/app/cli/main.go
index 21cba856..71460cae 100644
--- a/app/cli/main.go
+++ b/app/cli/main.go
@@ -1,11 +1,8 @@
package main
- "fmt"
- "io/ioutil"
+import (
"log"
- "net/http"
"os"
- "os/exec"
"path/filepath"
"plandex/api"
"plandex/auth"
@@ -14,16 +11,11 @@ package main
"plandex/lib"
"plandex/plan_exec"
"plandex/term"
- "plandex/version"
- "github.com/inconshreveable/go-update"
- "github.com/plandex/plandex/shared"
+ "github.com/plandex/plandex/shared"
)
func init() {
- // Version check and prompt for upgrade
- go checkForUpgrade()
-
// inter-package dependency injections to avoid circular imports
auth.SetApiClient(api.Client)
lib.SetBuildPlanInlineFn(func(maybeContexts []*shared.Context) (bool, error) {
@@ -32,38 +24,7 @@ func init() {
CurrentBranch: lib.CurrentBranch,
CheckOutdatedContext: func(cancelOpt bool, maybeContexts []*shared.Context) (bool, bool, bool) {
return lib.MustCheckOutdatedContext(cancelOpt, true, maybeContexts)
- func doUpgrade(version string) error {
- // Placeholder for download URL. This should point to the actual binary location.
- downloadURL := fmt.Sprintf("https://github.com/plandex-ai/plandex/releases/download/%s/plandex_%s_%s_%s.tar.gz", version, version, "os", "arch")
- resp, err := http.Get(downloadURL)
- if err != nil {
- return fmt.Errorf("failed to download the update: %w", err)
- }
- defer resp.Body.Close()
-
- err = update.Apply(resp.Body, update.Options{})
- if err != nil {
- return fmt.Errorf("failed to apply the update: %w", err)
- }
-
- return nil
-}
-
-func restartPlandex() {
- exe, err := os.Executable()
- if err != nil {
- log.Fatalf("Failed to determine executable path: %v", err)
- }
-
- cmd := exec.Command(exe, os.Args[1:]...)
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- err = cmd.Start()
- if err != nil {
- log.Fatalf("Failed to restart: %v", err)
- }
- os.Exit(0)
-},
+ },
}, false)
})
@@ -81,43 +42,7 @@ func restartPlandex() {
// log.Println("Starting Plandex - logging initialized")
}
-func checkForUpgrade() {
- latestVersionURL := "https://example.com/plandex/latest-version" // Placeholder URL
- resp, err := http.Get(latestVersionURL)
- if err != nil {
- log.Println("Error checking latest version:", err)
- return
- }
- defer resp.Body.Close()
-
- body, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- log.Println("Error reading response body:", err)
- return
- }
-
- latestVersion := string(body)
- if latestVersion > version.Version {
- fmt.Println("A new version of Plandex is available:", latestVersion)
- confirmed, err := term.ConfirmYesNo("Do you want to upgrade to the latest version?")
- if err != nil {
- log.Println("Error reading input:", err)
- return
- }
-
- if confirmed {
- err := doUpgrade(latestVersion)
- if err != nil {
- log.Println("Upgrade failed:", err)
- return
- }
- fmt.Println("Upgrade successful. Restarting Plandex...")
- restartPlandex()
- }
- }
-}
-}
-
func main() {
+ checkForUpgrade()
cmd.Execute()
}
diff --git a/app/cli/stream/stream.go b/app/cli/stream/stream.go
index e65ff693..98046e7e 100644
--- a/app/cli/stream/stream.go
+++ b/app/cli/stream/stream.go
@@ -5,7 +5,6 @@ import (
streamtui "plandex/stream_tui"
"plandex/types"
- "github.com/davecgh/go-spew/spew"
"github.com/plandex/plandex/shared"
)
@@ -20,8 +19,8 @@ var OnStreamPlan types.OnStreamPlan = func(params types.OnStreamPlanParams) {
return
}
- log.Println("Stream message:")
- log.Println(spew.Sdump(*params.Msg))
+ // log.Println("Stream message:")
+ // log.Println(spew.Sdump(*params.Msg))
streamtui.Send(*params.Msg)
}
diff --git a/app/cli/upgrade.go b/app/cli/upgrade.go
new file mode 100644
index 00000000..8b3392d1
--- /dev/null
+++ b/app/cli/upgrade.go
@@ -0,0 +1,83 @@
+package main
+
+import (
+ "fmt"
+ "io"
+ "log"
+ "net/http"
+ "os"
+ "os/exec"
+ "plandex/term"
+ "plandex/version"
+
+ "github.com/inconshreveable/go-update"
+)
+
+func checkForUpgrade() {
+ latestVersionURL := "https://example.com/plandex/latest-version" // Placeholder URL
+ resp, err := http.Get(latestVersionURL)
+ if err != nil {
+ log.Println("Error checking latest version:", err)
+ return
+ }
+ defer resp.Body.Close()
+
+ body, err := io.ReadAll(resp.Body)
+ if err != nil {
+ log.Println("Error reading response body:", err)
+ return
+ }
+
+ latestVersion := string(body)
+ if latestVersion > version.Version {
+ fmt.Println("A new version of Plandex is available:", latestVersion)
+ confirmed, err := term.ConfirmYesNo("Do you want to upgrade to the latest version?")
+ if err != nil {
+ log.Println("Error reading input:", err)
+ return
+ }
+
+ if confirmed {
+ err := doUpgrade(latestVersion)
+ if err != nil {
+ log.Println("Upgrade failed:", err)
+ return
+ }
+ fmt.Println("Upgrade successful. Restarting Plandex...")
+ restartPlandex()
+ }
+ }
+}
+
+func doUpgrade(version string) error {
+ // Placeholder for download URL. This should point to the actual binary location.
+ downloadURL := fmt.Sprintf("https://github.com/plandex-ai/plandex/releases/download/%s/plandex_%s_%s_%s.tar.gz", version, version, "os", "arch")
+ resp, err := http.Get(downloadURL)
+ if err != nil {
+ return fmt.Errorf("failed to download the update: %w", err)
+ }
+ defer resp.Body.Close()
+
+ err = update.Apply(resp.Body, update.Options{})
+ if err != nil {
+ return fmt.Errorf("failed to apply the update: %w", err)
+ }
+
+ return nil
+}
+
+func restartPlandex() {
+ exe, err := os.Executable()
+ if err != nil {
+ log.Fatalf("Failed to determine executable path: %v", err)
+ }
+
+ cmd := exec.Command(exe, os.Args[1:]...)
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ err = cmd.Start()
+ if err != nil {
+ log.Fatalf("Failed to restart: %v", err)
+ }
+ os.Exit(0)
+}
diff --git a/app/server/model/plan/build_result.go b/app/server/model/plan/build_result.go
index 47d60a9e..087bc49d 100644
--- a/app/server/model/plan/build_result.go
+++ b/app/server/model/plan/build_result.go
@@ -48,14 +48,15 @@ func getPlanResult(params planResultParams) (*db.PlanFileResult, bool) {
new := streamedChange.New
+ log.Printf("getPlanResult - streamedChange.Old.StartLine: %d\n", streamedChange.Old.StartLine)
+ log.Printf("getPlanResult - streamedChange.Old.EndLine: %d\n", streamedChange.Old.EndLine)
+
if streamedChange.Old.StartLine == streamedChange.Old.EndLine {
old = currentStateLines[streamedChange.Old.StartLine-1]
} else {
old = strings.Join(currentStateLines[streamedChange.Old.StartLine-1:streamedChange.Old.EndLine], "\n")
}
- log.Printf("getPlanResult - streamedChange.Old.StartLine: %d\n", streamedChange.Old.StartLine)
- log.Printf("getPlanResult - streamedChange.Old.EndLine: %d\n", streamedChange.Old.EndLine)
log.Printf("getPlanResult - old: %s\n", old)
replacement := &shared.Replacement{