Skip to content

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

integrate config with 'apply' command. add 'skip-commit' option to config. fix 'apply' commit prompt spinner issue.

Dane Schneider1f3b21bf768f
diff --git a/app/cli/cmd/apply.go b/app/cli/cmd/apply.go
index 51ff46d6..95e710bc 100644
--- a/app/cli/cmd/apply.go
+++ b/app/cli/cmd/apply.go
@@ -5,20 +5,15 @@ import (
"plandex/lib"
"plandex/plan_exec"
"plandex/term"
- "strconv"
"github.com/spf13/cobra"
)
-var autoCommit, noCommit, autoExec bool
+var autoCommit, skipCommit, autoExec bool
func init() {
- applyCmd.Flags().BoolVarP(&autoCommit, "commit", "c", false, "Commit changes to git")
- applyCmd.Flags().BoolVar(&noCommit, "no-commit", false, "Do not commit changes to git")
- applyCmd.Flags().BoolVar(&noExec, "no-exec", false, "Disable _apply.sh execution")
- applyCmd.Flags().BoolVar(&autoExec, "auto-exec", false, "Automatically execute commands without confirmation")
- applyCmd.Flags().Var(newAutoDebugValue(&autoDebug), "debug", "Automatically execute and debug failing commands (optionally specify number of tries—default is 5)")
- applyCmd.Flag("debug").NoOptDefVal = strconv.Itoa(defaultAutoDebugTries)
+ initApplyFlags(applyCmd)
+ initExecScriptFlags(applyCmd)
RootCmd.AddCommand(applyCmd)
}
@@ -32,6 +27,7 @@ var applyCmd = &cobra.Command{
func apply(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
lib.MustResolveProject()
+ mustSetPlanExecFlags(cmd)
if lib.CurrentPlanId == "" {
term.OutputNoCurrentPlanErrorAndExit()
@@ -40,7 +36,7 @@ func apply(cmd *cobra.Command, args []string) {
flags := lib.ApplyFlags{
AutoConfirm: true,
AutoCommit: autoCommit,
- NoCommit: noCommit,
+ NoCommit: skipCommit,
AutoExec: autoExec,
NoExec: noExec,
AutoDebug: autoDebug,
diff --git a/app/cli/cmd/plan_exec_helpers.go b/app/cli/cmd/plan_exec_helpers.go
index 7eef0da1..772836b3 100644
--- a/app/cli/cmd/plan_exec_helpers.go
+++ b/app/cli/cmd/plan_exec_helpers.go
@@ -80,17 +80,11 @@ func initExecFlags(cmd *cobra.Command, params initExecFlagsParams) {
if !params.omitApply {
cmd.Flags().BoolVar(&tellAutoApply, "apply", false, "Automatically apply changes")
- cmd.Flags().BoolVarP(&autoCommit, "commit", "c", false, "Commit changes to git when --apply is passed")
+ initApplyFlags(cmd)
}
if !params.omitExec {
- cmd.Flags().BoolVar(&noExec, "no-exec", false, "Disable command execution")
-
- cmd.Flags().BoolVar(&autoExec, "auto-exec", false, "Automatically execute commands without confirmation")
-
- cmd.Flags().Var(newAutoDebugValue(&autoDebug), "debug", "Automatically execute and debug failing commands (optionally specify number of tries—default is 5)")
-
- cmd.Flag("debug").NoOptDefVal = strconv.Itoa(defaultAutoDebugTries)
+ initExecScriptFlags(cmd)
}
if !params.omitEditor {
@@ -99,6 +93,18 @@ func initExecFlags(cmd *cobra.Command, params initExecFlagsParams) {
}
}
+func initApplyFlags(cmd *cobra.Command) {
+ cmd.Flags().BoolVar(&autoCommit, "commit", false, "Commit changes to git when --apply is passed")
+ cmd.Flags().BoolVar(&skipCommit, "no-commit", false, "Skip committing changes to git when --apply is passed")
+}
+
+func initExecScriptFlags(cmd *cobra.Command) {
+ cmd.Flags().BoolVar(&noExec, "no-exec", false, "Disable command execution")
+ cmd.Flags().BoolVar(&autoExec, "auto-exec", false, "Automatically execute commands without confirmation")
+ cmd.Flags().Var(newAutoDebugValue(&autoDebug), "debug", "Automatically execute and debug failing commands (optionally specify number of tries—default is 5)")
+ cmd.Flag("debug").NoOptDefVal = strconv.Itoa(defaultAutoDebugTries)
+}
+
func validatePlanExecFlags() {
if tellAutoApply && tellNoBuild {
term.OutputErrorAndExit("--apply can't be used with --no-build/-n")
@@ -146,6 +152,9 @@ func mustSetPlanExecFlags(cmd *cobra.Command) {
if !cmd.Flags().Changed("apply") {
tellAutoApply = config.AutoApply
}
+ if !cmd.Flags().Changed("skip-commit") {
+ skipCommit = config.SkipCommit
+ }
if !cmd.Flags().Changed("commit") {
autoCommit = config.AutoCommit
}
diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.go
index 7d122e58..0749767f 100644
--- a/app/cli/lib/apply.go
+++ b/app/cli/lib/apply.go
@@ -208,8 +208,8 @@ func MustApplyPlanAttempt(
}
if isRepo && !noCommit {
- gitErr := commitApplied(autoCommit, commitSummary, updatedFiles, currentPlanState)
term.StopSpinner()
+ gitErr := commitApplied(autoCommit, commitSummary, updatedFiles, currentPlanState)
appliedMsgFn()
if gitErr != nil {
onGitErr("Failed to commit changes:", gitErr.Error())
diff --git a/app/server/model/plan/tell_exec.go b/app/server/model/plan/tell_exec.go
index 9d404c30..ecccc8ef 100644
--- a/app/server/model/plan/tell_exec.go
+++ b/app/server/model/plan/tell_exec.go
@@ -267,9 +267,6 @@ func execTellPlan(
// log.Printf("%s: %s\n", message.Role, message.Content)
// }
- // ts := time.Now().Format("2006-01-02-150405")
- // os.WriteFile(fmt.Sprintf("generations/messages-%s.txt", ts), []byte(spew.Sdump(state.messages)), 0644)
-
_, apiErr := hooks.ExecHook(hooks.WillSendModelRequest, hooks.HookParams{
Auth: auth,
Plan: plan,
@@ -306,6 +303,17 @@ func execTellPlan(
Stop: stop,
}
+ // output the modelReq to a json file
+ // if jsonData, err := json.MarshalIndent(modelReq, "", " "); err == nil {
+ // timestamp := time.Now().Format("2006-01-02-150405")
+ // filename := fmt.Sprintf("generations/model-request-%s.json", timestamp)
+ // if err := os.WriteFile(filename, jsonData, 0644); err != nil {
+ // log.Printf("Error writing model request to file: %v\n", err)
+ // }
+ // } else {
+ // log.Printf("Error marshaling model request to JSON: %v\n", err)
+ // }
+
envVar := state.settings.ModelPack.Planner.BaseModelConfig.ApiKeyEnvVar
client := clients[envVar]
diff --git a/app/shared/plan_config.go b/app/shared/plan_config.go
index ca32c49c..de866307 100644
--- a/app/shared/plan_config.go
+++ b/app/shared/plan_config.go
@@ -85,6 +85,7 @@ type PlanConfig struct {
AutoApply bool `json:"autoApply"`
AutoCommit bool `json:"autoCommit"`
+ SkipCommit bool `json:"skipCommit"`
CanExec bool `json:"canExec"`
AutoExec bool `json:"autoExec"`
@@ -331,7 +332,7 @@ var ConfigSettingsByKey = map[string]ConfigSetting{
},
"autocommit": {
Name: "auto-commit",
- Desc: "Automatically commit changes after apply",
+ Desc: "Automatically commit changes to git after apply",
BoolSetter: func(p *PlanConfig, enabled bool) {
if enabled != p.AutoCommit {
p.AutoMode = AutoModeCustom
@@ -342,6 +343,16 @@ var ConfigSettingsByKey = map[string]ConfigSetting{
return fmt.Sprintf("%t", p.AutoCommit)
},
},
+ "skipcommit": {
+ Name: "skip-commit",
+ Desc: "Skip committing changes to git after apply",
+ BoolSetter: func(p *PlanConfig, enabled bool) {
+ p.SkipCommit = enabled
+ },
+ Getter: func(p *PlanConfig) string {
+ return fmt.Sprintf("%t", p.SkipCommit)
+ },
+ },
"autoapply": {
Name: "auto-apply",
Desc: "Automatically apply changes after plan finishes",