Skip to content

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

dynamic repl warning for full auto mode. fix for exit after rollback issue in apply. context update fix

Dane Schneidere6bd4f03ec13
diff --git a/app/cli/cmd/repl.go b/app/cli/cmd/repl.go
index 88aea45f..9f35730a 100644
--- a/app/cli/cmd/repl.go
+++ b/app/cli/cmd/repl.go
@@ -35,6 +35,8 @@ var cliSuggestions []prompt.Suggest
var projectPaths *types.ProjectPaths
var currentPrompt *prompt.Prompt
+var replConfig *shared.PlanConfig
+
func init() {
RootCmd.AddCommand(replCmd)
@@ -54,6 +56,14 @@ func init() {
}
}
+func setReplConfig() {
+ res, apiErr := api.Client.GetPlanConfig(lib.CurrentPlanId)
+ if apiErr != nil {
+ term.OutputErrorAndExit("Error getting plan config: %v", apiErr.Msg)
+ }
+ replConfig = res
+}
+
func runRepl(cmd *cobra.Command, args []string) {
term.SetIsRepl(true)
auth.MustResolveAuthWithOrg()
@@ -125,10 +135,7 @@ func runRepl(cmd *cobra.Command, args []string) {
color.New(term.ColorHiRed).Printf("Error getting project paths: %v\n", err)
}
- config, apiErr := api.Client.GetPlanConfig(lib.CurrentPlanId)
- if apiErr != nil {
- term.OutputErrorAndExit("Error getting plan config: %v", apiErr.Msg)
- }
+ setReplConfig()
settings, apiErr := api.Client.GetSettings(lib.CurrentPlanId, lib.CurrentBranch)
if apiErr != nil {
@@ -141,15 +148,15 @@ func runRepl(cmd *cobra.Command, args []string) {
var didUpdateConfig bool
var updatedConfig *shared.PlanConfig
var updatedSettings *shared.PlanSettings
- didUpdateConfig, updatedConfig, printAutoFn = resolveAutoModeSilent(config)
+ didUpdateConfig, updatedConfig, printAutoFn = resolveAutoModeSilent(replConfig)
updatedSettings, printModelFn = resolveModelPackSilent(settings)
if didUpdateConfig {
- loadMapIfNeeded(config, updatedConfig)
- removeMapIfNeeded(config, updatedConfig)
+ loadMapIfNeeded(replConfig, updatedConfig)
+ removeMapIfNeeded(replConfig, updatedConfig)
if updatedConfig != nil {
- config = updatedConfig
+ replConfig = updatedConfig
}
}
@@ -163,7 +170,7 @@ func runRepl(cmd *cobra.Command, args []string) {
isHelp: false,
printAutoFn: printAutoFn,
printModelFn: printModelFn,
- config: config,
+ config: replConfig,
packName: settings.ModelPack.Name,
})
@@ -179,7 +186,7 @@ func runRepl(cmd *cobra.Command, args []string) {
var modeIcon string
if lib.CurrentReplState.Mode == lib.ReplModeTell {
modeIcon = "⚡️"
- if config.AutoApply && config.AutoExec {
+ if replConfig.AutoApply && replConfig.AutoExec {
modeIcon += "❗️" // warning reminder for auto apply and auto exec
}
} else if lib.CurrentReplState.Mode == lib.ReplModeChat {
@@ -493,6 +500,12 @@ func executor(in string, p *prompt.Prompt) {
if preservedBuffer != "" {
p.InsertTextMoveCursor(preservedBuffer, true)
}
+
+ if strings.HasPrefix(matchedCmd, "set-auto") || strings.HasPrefix(matchedCmd, "set-config") {
+ term.StartSpinner("")
+ setReplConfig()
+ term.StopSpinner()
+ }
return
}
}
diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.go
index eb2f0a33..b90f3c91 100644
--- a/app/cli/lib/apply.go
+++ b/app/cli/lib/apply.go
@@ -299,6 +299,7 @@ func handleApplyScript(
if res == string(types.ApplyRollbackOptionRollback) {
Rollback(toRollback, true)
+ os.Exit(0)
} else {
onSuccess()
}
diff --git a/app/cli/lib/context_update.go b/app/cli/lib/context_update.go
index 88863f57..b5800f6a 100644
--- a/app/cli/lib/context_update.go
+++ b/app/cli/lib/context_update.go
@@ -25,7 +25,20 @@ func CheckOutdatedContextWithOutput(quiet, autoConfirm bool, maybeContexts []*sh
term.StartSpinner("🔬 Checking context...")
}
- outdatedRes, err := CheckOutdatedContext(maybeContexts, projectPaths)
+ var contexts []*shared.Context
+
+ if maybeContexts != nil {
+ contexts = maybeContexts
+ } else {
+ res, err := api.Client.ListContext(CurrentPlanId, CurrentBranch)
+ if err != nil {
+ term.StopSpinner()
+ return false, false, fmt.Errorf("failed to list context: %s", err)
+ }
+ contexts = res
+ }
+
+ outdatedRes, err := CheckOutdatedContext(contexts, projectPaths)
if err != nil {
term.StopSpinner()
return false, false, fmt.Errorf("failed to check outdated context: %s", err)
@@ -163,7 +176,7 @@ func CheckOutdatedContextWithOutput(quiet, autoConfirm bool, maybeContexts []*sh
if confirmed {
_, err := UpdateContextWithOutput(UpdateContextParams{
- Contexts: maybeContexts,
+ Contexts: contexts,
OutdatedRes: *outdatedRes,
Req: outdatedRes.Req,
})
@@ -214,7 +227,6 @@ func UpdateContext(params UpdateContextParams) (UpdateContextResult, error) {
for _, context := range params.Contexts {
contextsById[context.Id] = context
}
-
deleteIds := map[string]bool{}
for _, context := range params.OutdatedRes.RemovedContexts {
deleteIds[context.Id] = true
diff --git a/app/cli/plan_exec/apply_exec.go b/app/cli/plan_exec/apply_exec.go
index 48c41abb..07184b4d 100644
--- a/app/cli/plan_exec/apply_exec.go
+++ b/app/cli/plan_exec/apply_exec.go
@@ -3,6 +3,7 @@ package plan_exec
import (
"fmt"
"log"
+ "os"
"plandex-cli/api"
"plandex-cli/auth"
"plandex-cli/lib"
@@ -105,7 +106,7 @@ func getOnApplyExecFail(applyFlags types.ApplyFlags, tellFlags types.TellFlags,
if toRollback != nil {
lib.Rollback(toRollback, true)
}
- term.OutputErrorAndExit("Rolling back changes and exiting")
+ os.Exit(1)
case ApplyChangesAndExit:
onSuccess()
return