Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
apply plan fixes
Dane Schneider75427b8a976b
diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.goindex 10c93601..7e0c52a1 100644--- a/app/cli/lib/apply.go+++ b/app/cli/lib/apply.go@@ -8,6 +8,8 @@ import ("plandex/api""plandex/fs""plandex/term"++ "github.com/davecgh/go-spew/spew")func MustApplyPlan(planId, branch string, autoConfirm bool) {@@ -243,10 +245,10 @@ func MustApplyPlan(planId, branch string, autoConfirm bool) {// Commit the changesmsg := "🤖 Plandex" + currentPlanState.PendingChangesSummary()- // log.Println("Committing changes with message:")- // log.Println(msg)+ log.Println("Committing changes with message:")+ log.Println(msg)- // spew.Dump(currentPlanState)+ spew.Dump(currentPlanState)err := GitAddAndCommit(fs.ProjectRoot, msg, true)if err != nil {diff --git a/app/server/db/context_helpers.go b/app/server/db/context_helpers.goindex c9bdf54a..e6791d98 100644--- a/app/server/db/context_helpers.go+++ b/app/server/db/context_helpers.go@@ -169,11 +169,12 @@ func StoreContext(context *Context) error {}type LoadContextsParams struct {- Req *shared.LoadContextRequest- OrgId string- Plan *Plan- BranchName string- UserId string+ Req *shared.LoadContextRequest+ OrgId string+ Plan *Plan+ BranchName string+ UserId string+ SkipConflictInvalidation bool}func LoadContexts(params LoadContextsParams) (*shared.LoadContextResponse, []*Context, error) {@@ -190,9 +191,12 @@ func LoadContexts(params LoadContextsParams) (*shared.LoadContextResponse, []*CofilesToLoad[context.FilePath] = context.Body}}- err := invalidateConflictedResults(orgId, planId, filesToLoad)- if err != nil {- return nil, nil, fmt.Errorf("error invalidating conflicted results: %v", err)++ if !params.SkipConflictInvalidation {+ err := invalidateConflictedResults(orgId, planId, filesToLoad)+ if err != nil {+ return nil, nil, fmt.Errorf("error invalidating conflicted results: %v", err)+ }}tokensAdded := 0@@ -305,11 +309,12 @@ func LoadContexts(params LoadContextsParams) (*shared.LoadContextResponse, []*Co}type UpdateContextsParams struct {- Req *shared.UpdateContextRequest- OrgId string- Plan *Plan- BranchName string- ContextsById map[string]*Context+ Req *shared.UpdateContextRequest+ OrgId string+ Plan *Plan+ BranchName string+ ContextsById map[string]*Context+ SkipConflictInvalidation bool}func UpdateContexts(params UpdateContextsParams) (*shared.UpdateContextResponse, error) {@@ -436,9 +441,12 @@ func UpdateContexts(params UpdateContextsParams) (*shared.UpdateContextResponse,filesToLoad[context.FilePath] = (*req)[context.Id].Body}}- err = invalidateConflictedResults(orgId, planId, filesToLoad)- if err != nil {- return nil, fmt.Errorf("error invalidating conflicted results: %v", err)++ if !params.SkipConflictInvalidation {+ err = invalidateConflictedResults(orgId, planId, filesToLoad)+ if err != nil {+ return nil, fmt.Errorf("error invalidating conflicted results: %v", err)+ }}errCh = make(chan error)diff --git a/app/server/db/result_helpers.go b/app/server/db/result_helpers.goindex b26bbec7..fcef95b1 100644--- a/app/server/db/result_helpers.go+++ b/app/server/db/result_helpers.go@@ -185,7 +185,9 @@ func GetConvoMessageDescriptions(orgId, planId string) ([]*ConvoMessageDescriptifor _, file := range files {go func(file os.DirEntry) {- bytes, err := os.ReadFile(filepath.Join(descriptionsDir, file.Name()))+ path := filepath.Join(descriptionsDir, file.Name())++ bytes, err := os.ReadFile(path)if err != nil {errCh <- fmt.Errorf("error reading description file %s: %v", file.Name(), err)@@ -196,7 +198,11 @@ func GetConvoMessageDescriptions(orgId, planId string) ([]*ConvoMessageDescriptierr = json.Unmarshal(bytes, &description)if err != nil {- errCh <- fmt.Errorf("error unmarshalling description file %s: %v", file.Name(), err)+ log.Println("Error unmarshalling description file:", path)+ log.Println("bytes:")+ log.Println(string(bytes))++ errCh <- fmt.Errorf("error unmarshalling description file %s: %v", path, err)return}@@ -463,11 +469,12 @@ func ApplyPlan(orgId, userId, branchName string, plan *Plan) error {res, _, err := LoadContexts(LoadContextsParams{- OrgId: orgId,- UserId: userId,- Plan: plan,- BranchName: branchName,- Req: &loadReq,+ OrgId: orgId,+ UserId: userId,+ Plan: plan,+ BranchName: branchName,+ Req: &loadReq,+ SkipConflictInvalidation: true, // no need to invalidate conflicts when applying plan--and fixes race condition since invalidation check loads description},)@@ -493,10 +500,11 @@ func ApplyPlan(orgId, userId, branchName string, plan *Plan) error {res, err := UpdateContexts(UpdateContextsParams{- OrgId: orgId,- Plan: plan,- BranchName: branchName,- Req: &updateReq,+ OrgId: orgId,+ Plan: plan,+ BranchName: branchName,+ Req: &updateReq,+ SkipConflictInvalidation: true, // no need to invalidate conflicts when applying plan--and fixes race condition since invalidation check loads description},)