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
big commit -- updating to default to gpt-4o, lots of work on verify and auto-fix, better identification of code references in comments, and working on avoiding skipping of placeholder comments
Dane Schneiderb7585bbc5af6
diff --git a/app/cli/cmd/model_packs.go b/app/cli/cmd/model_packs.goindex 34970315..035450b2 100644--- a/app/cli/cmd/model_packs.go+++ b/app/cli/cmd/model_packs.go@@ -206,6 +206,10 @@ func createModelPack(cmd *cobra.Command, args []string) {mp.Namer = getModelRoleConfig(customModels, shared.ModelRoleName)mp.CommitMsg = getModelRoleConfig(customModels, shared.ModelRoleCommitMsg)mp.ExecStatus = getModelRoleConfig(customModels, shared.ModelRoleExecStatus)+ verifier := getModelRoleConfig(customModels, shared.ModelRoleVerifier)+ mp.Verifier = &verifier+ autoFix := getModelRoleConfig(customModels, shared.ModelRoleAutoFix)+ mp.AutoFix = &autoFixterm.StartSpinner("")apiErr = api.Client.CreateModelPack(mp)diff --git a/app/cli/cmd/models.go b/app/cli/cmd/models.goindex 4e84a1dd..ed5096c4 100644--- a/app/cli/cmd/models.go+++ b/app/cli/cmd/models.go@@ -445,6 +445,8 @@ func renderSettings(settings *shared.PlanSettings) {addModelRow(string(shared.ModelRoleName), modelPack.Namer)addModelRow(string(shared.ModelRoleCommitMsg), modelPack.CommitMsg)addModelRow(string(shared.ModelRoleExecStatus), modelPack.ExecStatus)+ addModelRow(string(shared.ModelRoleVerifier), modelPack.GetVerifier())+ addModelRow(string(shared.ModelRoleAutoFix), modelPack.GetAutoFix())table.Render()fmt.Println()diff --git a/app/cli/go.mod b/app/cli/go.modindex e5a1153f..0e1aa5fc 100644--- a/app/cli/go.mod+++ b/app/cli/go.mod@@ -36,7 +36,7 @@ require (github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirectgithub.com/muesli/cancelreader v0.2.2 // indirectgithub.com/rivo/uniseg v0.4.7 // indirect- github.com/sashabaranov/go-openai v1.21.0 // indirect+ github.com/sashabaranov/go-openai v1.24.0 // indirectgithub.com/yuin/goldmark v1.6.0 // indirectgithub.com/yuin/goldmark-emoji v1.0.2 // indirectgolang.org/x/net v0.18.0 // indirectdiff --git a/app/cli/go.sum b/app/cli/go.sumindex 8bff7308..a0ca19f4 100644--- a/app/cli/go.sum+++ b/app/cli/go.sum@@ -640,8 +640,8 @@ github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjgithub.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=github.com/sagikazarmark/crypt v0.8.0/go.mod h1:TmKwZAo97S4Fy4sfMH/HX/cQP5D+ijra2NyLpNNmttY=github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=-github.com/sashabaranov/go-openai v1.21.0 h1:isAf3zPSD3VLd0pC2/2Q6ZyRK7jzPAaz+X3rjsviaYQ=-github.com/sashabaranov/go-openai v1.21.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=+github.com/sashabaranov/go-openai v1.24.0 h1:4H4Pg8Bl2RH/YSnU8DYumZbuHnnkfioor/dtNlB20D4=+github.com/sashabaranov/go-openai v1.24.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=diff --git a/app/server/db/data_models.go b/app/server/db/data_models.goindex 410b9f9a..20eee9be 100644--- a/app/server/db/data_models.go+++ b/app/server/db/data_models.go@@ -480,10 +480,24 @@ type PlanFileResult struct {Replacements []*shared.Replacement `json:"replacements"`AnyFailed bool `json:"anyFailed"`Error string `json:"error"`- AppliedAt *time.Time `json:"appliedAt,omitempty"`- RejectedAt *time.Time `json:"rejectedAt,omitempty"`- CreatedAt time.Time `json:"createdAt"`- UpdatedAt time.Time `json:"updatedAt"`++ CanVerify bool `json:"canVerify"`+ RanVerifyAt *time.Time `json:"ranVerifyAt,omitempty"`+ VerifyPassed bool `json:"verifyPassed"`++ WillCheckSyntax bool `json:"willCheckSyntax"`+ SyntaxValid bool `json:"syntaxValid"`+ SyntaxErrors []string `json:"syntaxErrors"`++ IsFix bool `json:"isFix"`+ IsSyntaxFix bool `json:"isSyntaxFix"`+ IsOtherFix bool `json:"isOtherFix"`+ FixEpoch int `json:"fixEpoch"`++ AppliedAt *time.Time `json:"appliedAt,omitempty"`+ RejectedAt *time.Time `json:"rejectedAt,omitempty"`+ CreatedAt time.Time `json:"createdAt"`+ UpdatedAt time.Time `json:"updatedAt"`}func (res *PlanFileResult) ToApi() *shared.PlanFileResult {@@ -499,6 +513,12 @@ func (res *PlanFileResult) ToApi() *shared.PlanFileResult {AppliedAt: res.AppliedAt,RejectedAt: res.RejectedAt,Replacements: res.Replacements,+ CanVerify: res.CanVerify,+ RanVerifyAt: res.RanVerifyAt,+ VerifyPassed: res.VerifyPassed,+ IsFix: res.IsFix,+ IsSyntaxFix: res.IsSyntaxFix,+ IsOtherFix: res.IsOtherFix,CreatedAt: res.CreatedAt,UpdatedAt: res.UpdatedAt,}diff --git a/app/server/go.mod b/app/server/go.modindex aa13bbf7..a6095f21 100644--- a/app/server/go.mod+++ b/app/server/go.mod@@ -8,7 +8,7 @@ require (github.com/gorilla/mux v1.8.1github.com/pkg/errors v0.9.1github.com/plandex/plandex/shared v0.0.0-00010101000000-000000000000- github.com/sashabaranov/go-openai v1.21.0+ github.com/sashabaranov/go-openai v1.24.0)require (diff --git a/app/server/go.sum b/app/server/go.sumindex 434f0a11..7f7ebcb6 100644--- a/app/server/go.sum+++ b/app/server/go.sum@@ -85,8 +85,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNgithub.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=-github.com/sashabaranov/go-openai v1.21.0 h1:isAf3zPSD3VLd0pC2/2Q6ZyRK7jzPAaz+X3rjsviaYQ=-github.com/sashabaranov/go-openai v1.21.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=+github.com/sashabaranov/go-openai v1.24.0 h1:4H4Pg8Bl2RH/YSnU8DYumZbuHnnkfioor/dtNlB20D4=+github.com/sashabaranov/go-openai v1.24.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=github.com/smacker/go-tree-sitter v0.0.0-20240423010953-8ba036550382 h1:Cb8njhEbNgGk5lQMM/r1FWvrKT+ysH8H0WV9NAIKAu8=github.com/smacker/go-tree-sitter v0.0.0-20240423010953-8ba036550382/go.mod h1:q99oHDsbP0xRwmn7Vmob8gbSMNyvJ83OauXPSuHQuKE=github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=diff --git a/app/server/handlers/plans_exec.go b/app/server/handlers/plans_exec.goindex f5e95565..38ba578f 100644--- a/app/server/handlers/plans_exec.go+++ b/app/server/handlers/plans_exec.go@@ -13,7 +13,6 @@ import ("plandex-server/types""time"- "github.com/davecgh/go-spew/spew""github.com/gorilla/mux""github.com/plandex/plandex/shared")@@ -149,8 +148,6 @@ func BuildPlanHandler(w http.ResponseWriter, r *http.Request) {}if requestBody.ApiKey == "" && len(requestBody.ApiKeys) == 0 {- spew.Dump(requestBody)-log.Println("API key is required")http.Error(w, "API key is required", http.StatusBadRequest)returndiff --git a/app/server/model/plan/build_exec.go b/app/server/model/plan/build_exec.goindex 6322586a..6c856b18 100644--- a/app/server/model/plan/build_exec.go+++ b/app/server/model/plan/build_exec.go@@ -6,9 +6,9 @@ import ("plandex-server/db""plandex-server/model""plandex-server/model/prompts"+ "plandex-server/syntax""plandex-server/types"- "github.com/davecgh/go-spew/spew""github.com/plandex/plandex/shared""github.com/sashabaranov/go-openai")@@ -230,22 +230,34 @@ func (fileState *activeBuildStreamFileState) buildFile() {BuildInfo: buildInfo,})+ // validate syntax of new file+ validationRes, err := syntax.Validate(activePlan.Ctx, filePath, activeBuild.FileContent)++ if err != nil {+ log.Printf("Error validating syntax for new file '%s': %v\n", filePath, err)+ fileState.onBuildFileError(fmt.Errorf("error validating syntax for new file '%s': %v", filePath, err))+ return+ }+// new fileplanRes := &db.PlanFileResult{- OrgId: currentOrgId,- PlanId: planId,- PlanBuildId: build.Id,- ConvoMessageId: build.ConvoMessageId,- Path: filePath,- Content: activeBuild.FileContent,+ OrgId: currentOrgId,+ PlanId: planId,+ PlanBuildId: build.Id,+ ConvoMessageId: build.ConvoMessageId,+ Path: filePath,+ Content: activeBuild.FileContent,+ WillCheckSyntax: validationRes.HasParser && !validationRes.TimedOut,+ SyntaxValid: validationRes.Valid,+ SyntaxErrors: validationRes.Errors,}- fileState.updated = activeBuild.FileContent-log.Println("build exec - Plan file result:")- spew.Dump(planRes)+ // spew.Dump(planRes)- fileState.onFinishBuildFile(planRes)+ fileState.isNewFile = true++ fileState.onFinishBuildFile(planRes, activeBuild.FileContent)return} else {currentNumTokens, err := shared.GetNumTokens(currentState)@@ -340,77 +352,3 @@ func (fileState *activeBuildStreamFileState) buildFileLineNums() {go fileState.listenStreamChangesWithLineNums(stream)}--// func (fileState *activeBuildStreamFileState) buildFileFullChanges() {-// filePath := fileState.filePath-// activeBuild := fileState.activeBuild-// clients := fileState.clients-// planId := fileState.plan.Id-// branch := fileState.branch-// config := fileState.settings.ModelPack.Builder-// currentState := fileState.currentState--// activePlan := GetActivePlan(planId, branch)--// if activePlan == nil {-// log.Printf("Active plan not found for plan ID %s and branch %s\n", planId, branch)-// return-// }--// log.Println("buildFileFullChanges - getting file from model: " + filePath)-// // log.Println("File context:", fileContext)--// // log.Println("currentState:", currentState)--// sysPrompt := prompts.GetBuildFullChangesSysPrompt(filePath, currentState, activeBuild.FileDescription, activeBuild.FileContent)--// fileMessages := []openai.ChatCompletionMessage{-// {-// Role: openai.ChatMessageRoleSystem,-// Content: sysPrompt,-// },-// }--// log.Println("buildFileFullChanges - calling model for file: " + filePath)--// // for _, msg := range fileMessages {-// // log.Printf("%s: %s\n", msg.Role, msg.Content)-// // }--// var responseFormat *openai.ChatCompletionResponseFormat-// if config.BaseModelConfig.HasJsonResponseMode {-// responseFormat = &openai.ChatCompletionResponseFormat{Type: "json_object"}-// }--// modelReq := openai.ChatCompletionRequest{-// Model: config.BaseModelConfig.ModelName,-// Tools: []openai.Tool{-// {-// Type: "function",-// Function: &prompts.ListReplacementsFullFn,-// },-// },-// ToolChoice: openai.ToolChoice{-// Type: "function",-// Function: openai.ToolFunction{-// Name: prompts.ListReplacementsFullFn.Name,-// },-// },-// Messages: fileMessages,-// Temperature: config.Temperature,-// TopP: config.TopP,-// ResponseFormat: responseFormat,-// }--// envVar := config.BaseModelConfig.ApiKeyEnvVar-// client := clients[envVar]--// stream, err := model.CreateChatCompletionStreamWithRetries(client, activePlan.Ctx, modelReq)-// if err != nil {-// log.Printf("Error creating plan file stream for path '%s': %v\n", filePath, err)-// fileState.onBuildFileError(fmt.Errorf("error creating plan file stream for path '%s': %v", filePath, err))-// return-// }--// go fileState.listenStreamFullChanges(stream)-// }diff --git a/app/server/model/plan/build_finish.go b/app/server/model/plan/build_finish.goindex 1dc64c95..c726f5c5 100644--- a/app/server/model/plan/build_finish.go+++ b/app/server/model/plan/build_finish.go@@ -191,7 +191,7 @@ func (state *activeBuildStreamFileState) onFinishBuild() {}}-func (fileState *activeBuildStreamFileState) onFinishBuildFile(planRes *db.PlanFileResult) {+func (fileState *activeBuildStreamFileState) onFinishBuildFile(planRes *db.PlanFileResult, updated string) {planId := fileState.plan.Idbranch := fileState.branchcurrentOrgId := fileState.currentOrgId@@ -269,6 +269,31 @@ func (fileState *activeBuildStreamFileState) onFinishBuildFile(planRes *db.PlanF}}+ // if we have a syntax error, fix it if we aren't out of retries+ if planRes != nil && planRes.WillCheckSyntax && !planRes.SyntaxValid {+ if planRes.IsFix {+ if planRes.FixEpoch >= FixSyntaxEpochs-1 {+ // we're out of retries, just continue on to queue processing+ } else {+ fileState.syntaxNumEpoch+++ fileState.syntaxNumRetry = 0+ fileState.isFixingSyntax = true+ fileState.syntaxErrors = planRes.SyntaxErrors+ fileState.preBuildState = fileState.updated+ fileState.updated = updated+ go fileState.fixFileLineNums()+ return+ }+ } else {+ fileState.isFixingSyntax = true+ fileState.syntaxErrors = planRes.SyntaxErrors+ fileState.preBuildState = fileState.updated+ fileState.updated = updated+ go fileState.fixFileLineNums()+ return+ }+ }+activeBuild.Success = true// if more builds are queued, start the next one regardless of whether this is a verification build or not, then return@@ -295,58 +320,38 @@ func (fileState *activeBuildStreamFileState) onFinishBuildFile(planRes *db.PlanFreturn}- buildFinished := false-- UpdateActivePlan(planId, branch, func(ap *types.ActivePlan) {- ap.BuiltFiles[filePath] = true- ap.IsBuildingByPath[filePath] = false- if ap.BuildFinished() {- buildFinished = true- }- })+ // otherwise:+ // if this is a verification build or a new file build (new files aren't verified), check if the build is finished and call onFinishBuild if it is+ // if this is not a verification build, trigger the verification build+ if activeBuild.IsVerification || fileState.isNewFile || (planRes != nil && !planRes.CanVerify) {+ buildFinished := false++ UpdateActivePlan(planId, branch, func(ap *types.ActivePlan) {+ ap.BuiltFiles[filePath] = true+ ap.IsBuildingByPath[filePath] = false+ if ap.BuildFinished() {+ buildFinished = true+ }+ })- log.Printf("Finished building file %s\n", filePath)+ log.Printf("Finished building file %s\n", filePath)- if buildFinished {- log.Println("Finished building plan, calling onFinishBuild")- fileState.onFinishBuild()+ if buildFinished {+ log.Println("Finished building plan, calling onFinishBuild")+ fileState.onFinishBuild()+ }+ } else {+ go fileState.execPlanBuild(&types.ActiveBuild{+ ReplyId: activeBuild.ReplyId,+ FileDescription: activeBuild.FileDescription,+ FileContent: activeBuild.FileContent,+ Path: activeBuild.Path,+ Idx: activeBuild.Idx,+ IsVerification: true,+ ToVerifyUpdatedState: updated,+ })}- // Verification logic below is disabled for now pending more work on prompts-- // otherwise:- // if this is a verification build, check if the build is finished and call onFinishBuild if it is- // if this is not a verification build, trigger the verification build- // if activeBuild.IsVerification {- // buildFinished := false-- // UpdateActivePlan(planId, branch, func(ap *types.ActivePlan) {- // ap.BuiltFiles[filePath] = true- // ap.IsBuildingByPath[filePath] = false- // if ap.BuildFinished() {- // buildFinished = true- // }- // })-- // log.Printf("Finished building file %s\n", filePath)-- // if buildFinished {- // log.Println("Finished building plan, calling onFinishBuild")- // fileState.onFinishBuild()- // }- // } else {- // go fileState.execPlanBuild(&types.ActiveBuild{- // ReplyId: activeBuild.ReplyId,- // FileDescription: activeBuild.FileDescription,- // FileContent: activeBuild.FileContent,- // Path: activeBuild.Path,- // Idx: activeBuild.Idx,- // IsVerification: true,- // ToVerifyPreBuildState: fileState.preBuildState,- // ToVerifyUpdatedState: fileState.updated,- // })- // }-}func (fileState *activeBuildStreamFileState) onBuildFileError(err error) {diff --git a/app/server/model/plan/build_fix.go b/app/server/model/plan/build_fix.goindex 08c7da49..8456a7b9 100644--- a/app/server/model/plan/build_fix.go+++ b/app/server/model/plan/build_fix.go@@ -5,6 +5,7 @@ import ("log""plandex-server/model""plandex-server/model/prompts"+ "strings""github.com/sashabaranov/go-openai")@@ -15,9 +16,8 @@ func (fileState *activeBuildStreamFileState) fixFileLineNums() {clients := fileState.clientsplanId := fileState.plan.Idbranch := fileState.branch- config := fileState.settings.ModelPack.Builder+ config := fileState.settings.ModelPack.GetAutoFix()incorrectlyUpdated := fileState.updated- reasoning := fileState.incorrectlyUpdatedReasoningactivePlan := GetActivePlan(planId, branch)@@ -34,6 +34,21 @@ func (fileState *activeBuildStreamFileState) fixFileLineNums() {log.Println("fixFileLineNums - getting file from model: " + filePath)// log.Println("File context:", fileContext)+ reasoning := ""+ if len(fileState.syntaxErrors) > 0 {+ reasoning += "The following are syntax errors identified by the tree-sitter library. Here are line numbers:\n\n" + strings.Join(fileState.syntaxErrors, "\n")+ }++ if fileState.verificationErrors != "" {+ if len(fileState.syntaxErrors) > 0 {+ reasoning += "\n\n"+ reasoning += "The following are other problems identified in the file:\n\n"+ } else {+ reasoning += "Here are the problems identified in the file:\n\n"+ }+ reasoning += fileState.verificationErrors+ }+sysPrompt := prompts.GetBuildFixesLineNumbersSysPrompt(fileState.preBuildState, fmt.Sprintf("%s\n\n```%s```", activeBuild.FileDescription, activeBuild.FileContent), incorrectlyUpdated, reasoning)fileMessages := []openai.ChatCompletionMessage{diff --git a/app/server/model/plan/build_fix_stream.go b/app/server/model/plan/build_fix_stream.goindex 994cf371..a29efe97 100644--- a/app/server/model/plan/build_fix_stream.go+++ b/app/server/model/plan/build_fix_stream.go@@ -9,6 +9,7 @@ import ("math/rand""plandex-server/model""plandex-server/types"+ "sort""strings""time"@@ -44,7 +45,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openreturncase <-timer.C:// Timer triggered because no new chunk was received in time- fileState.fixRetryOrError(fmt.Errorf("listenStreamFixChanges - stream timeout due to inactivity for file '%s'", filePath))+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream timeout due to inactivity for file '%s'", filePath))returndefault:response, err := stream.Recv()@@ -63,32 +64,12 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openreturn}- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("Build fix stream - Plan file result:")- fileState.onFinishBuildFile(nil)+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream error: %v", err))return}if len(response.Choices) == 0 {- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("Build fix stream - Plan file result:")- fileState.onFinishBuildFile(nil)+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream error: no choices"))return}@@ -101,20 +82,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *opentrimmed := strings.TrimSpace(content)if trimmed == "{%invalidjson%}" || trimmed == "``(no output)``````" {log.Println("listenStreamFixChanges - File", filePath+":", "%invalidjson%} token in streamed chunk")- fileState.fixRetryOrError(fmt.Errorf("listenStreamFixChanges - invalid JSON in streamed chunk for file '%s'", filePath))-- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("Build fix stream - Plan file result:")- fileState.onFinishBuildFile(nil)-+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - invalid JSON in streamed chunk for file '%s'", filePath))return}@@ -144,17 +112,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openlog.Println("Buffer:")log.Println(fileState.activeBuild.FixBuffer)- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("Build fix stream - Plan file result:")- fileState.onFinishBuildFile(nil)+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream buffer tokens too high for file '%s'", filePath))return}}@@ -166,14 +124,49 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openlog.Printf("listenStreamFixChanges - File %s: Parsed streamed replacements\n", filePath)// spew.Dump(streamed)- fileState.streamedChangesWithLineNums = streamed.Changes+ sorted := []*shared.StreamedChangeWithLineNums{}++ // Sort the streamed changes by start line+ for _, change := range streamed.Changes {+ if change.HasChange {+ sorted = append(sorted, change)+ }+ }++ // Sort the streamed changes by start line+ sort.Slice(sorted, func(i, j int) bool {+ var iStartLine int+ var jStartLine int++ // Convert the line number part to an integer+ iStartLine, _, err := sorted[i].GetLines()++ if err != nil {+ log.Printf("listenStream - Error getting start line for change %v: %v\n", sorted[i], err)+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - error getting start line for change %v: %v", sorted[i], err))+ return false+ }++ jStartLine, _, err = sorted[j].GetLines()++ if err != nil {+ log.Printf("listenStream - Error getting start line for change %v: %v\n", sorted[j], err)+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - error getting start line for change %v: %v", sorted[j], err))+ return false+ }++ return iStartLine < jStartLine+ })++ fileState.streamedChangesWithLineNums = sortedvar overlapStrategy OverlapStrategy = OverlapStrategyErrorif fileState.fixFileNumRetry > 1 {overlapStrategy = OverlapStrategySkip}- planFileResult, _, allSucceeded, err := GetPlanResult(+ planFileResult, updated, allSucceeded, err := GetPlanResult(+ activePlan.Ctx,PlanResultParams{OrgId: currentOrgId,PlanId: planId,@@ -183,22 +176,20 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openPreBuildState: fileState.updated,StreamedChangesWithLineNums: streamed.Changes,OverlapStrategy: overlapStrategy,++ IsFix: true,+ IsSyntaxFix: fileState.isFixingSyntax,+ IsOtherFix: fileState.isFixingOther,++ FixEpoch: fileState.syntaxNumEpoch,++ CheckSyntax: true,},)if err != nil {log.Println("listenStreamFixChanges - Error getting plan result:", err)- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("Build fix stream - Plan file result:")- fileState.onFinishBuildFile(nil)+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - error getting plan result for file '%s': %v", filePath, err))return}@@ -217,31 +208,36 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *open}log.Println("listenStreamFixChanges - Plan file result:")- spew.Dump(planFileResult)+ // spew.Dump(planFileResult)++ // reset fix state+ fileState.isFixingSyntax = false+ fileState.isFixingOther = false++ // if we are below the number of FixSyntaxRetries, and the syntax is invalid, short-circuit here and retry+ // otherwise if the syntax is invalid but we're out of retries, continue to onFinishBuildFile, which will handle epoch-based retries (i.e. running additional fixes on top of this failed fix) if applicable+ if planFileResult.WillCheckSyntax && !planFileResult.SyntaxValid {+ if fileState.syntaxNumRetry < FixSyntaxRetries {+ fileState.isFixingSyntax = true+ fileState.syntaxNumRetry+++ go fileState.fixFileLineNums()+ return+ }+ }- fileState.onFinishBuildFile(planFileResult)+ fileState.onFinishBuildFile(planFileResult, updated)return} else if len(delta.ToolCalls) == 0 {log.Println("listenStreamFixChanges - Stream chunk missing function call.")- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("Build fix stream - Plan file result:")- fileState.onFinishBuildFile(nil)+ fileState.fixRetryOrAbort(fmt.Errorf("listenStreamFixChanges - stream chunk missing function call. File: %s", filePath))return}}}}-func (fileState *activeBuildStreamFileState) fixRetryOrError(err error) {+func (fileState *activeBuildStreamFileState) fixRetryOrAbort(err error) {if fileState.fixFileNumRetry < MaxBuildStreamErrorRetries {fileState.fixFileNumRetry++fileState.activeBuild.FixBuffer = ""@@ -249,10 +245,12 @@ func (fileState *activeBuildStreamFileState) fixRetryOrError(err error) {log.Printf("Retrying fix file '%s' due to error: %v\n", fileState.filePath, err)// Exponential backoff- time.Sleep(time.Duration(fileState.fixFileNumRetry*fileState.fixFileNumRetry)*time.Second + time.Duration(rand.Intn(1001))*time.Millisecond)+ time.Sleep(time.Duration((fileState.verifyFileNumRetry*fileState.verifyFileNumRetry)/2)*200*time.Millisecond + time.Duration(rand.Intn(500))*time.Millisecond)fileState.fixFileLineNums()} else {- fileState.onBuildFileError(err)+ log.Printf("Aborting fix file '%s' due to error: %v\n", fileState.filePath, err)++ fileState.onFinishBuildFile(nil, "")}}diff --git a/app/server/model/plan/build_load.go b/app/server/model/plan/build_load.goindex af10a842..fe5cb3fb 100644--- a/app/server/model/plan/build_load.go+++ b/app/server/model/plan/build_load.go@@ -156,6 +156,7 @@ func (state *activeBuildStreamFileState) loadBuildFile(activeBuild *types.Active}var currentPlan *shared.CurrentPlanState+ var convo []*db.ConvoMessagerepoLockId, err := db.LockRepo(db.LockRepoParams{@@ -190,26 +191,54 @@ func (state *activeBuildStreamFileState) loadBuildFile(activeBuild *types.Active}}()- res, err := db.GetCurrentPlanState(db.CurrentPlanStateParams{- OrgId: currentOrgId,- PlanId: planId,- })- if err != nil {- log.Printf("Error getting current plan state: %v\n", err)- UpdateActivePlan(activePlan.Id, activePlan.Branch, func(ap *types.ActivePlan) {- ap.IsBuildingByPath[filePath] = false+ errCh := make(chan error)++ go func() {+ res, err := db.GetCurrentPlanState(db.CurrentPlanStateParams{+ OrgId: currentOrgId,+ PlanId: planId,})- activePlan.StreamDoneCh <- &shared.ApiError{- Type: shared.ApiErrorTypeOther,- Status: http.StatusInternalServerError,- Msg: "Error getting current plan state: " + err.Error(),+ if err != nil {+ log.Printf("Error getting current plan state: %v\n", err)+ UpdateActivePlan(activePlan.Id, activePlan.Branch, func(ap *types.ActivePlan) {+ ap.IsBuildingByPath[filePath] = false+ })+ activePlan.StreamDoneCh <- &shared.ApiError{+ Type: shared.ApiErrorTypeOther,+ Status: http.StatusInternalServerError,+ Msg: "Error getting current plan state: " + err.Error(),+ }+ errCh <- fmt.Errorf("error getting current plan state: %v", err)+ return+ }+ currentPlan = res++ log.Println("Got current plan state")+ errCh <- nil+ }()++ go func() {+ res, err := db.GetPlanConvo(currentOrgId, planId)+ if err != nil {+ log.Printf("Error getting plan convo: %v\n", err)+ errCh <- fmt.Errorf("error getting plan convo: %v", err)+ return+ }+ convo = res++ errCh <- nil+ }()++ for i := 0; i < 2; i++ {+ err = <-errCh+ if err != nil {+ log.Printf("Error getting plan data: %v\n", err)+ return err}- return err}- currentPlan = res- log.Println("Got current plan state")return nil+}()if err != nil {@@ -220,6 +249,7 @@ func (state *activeBuildStreamFileState) loadBuildFile(activeBuild *types.Activestate.convoMessageId = convoMessageIdstate.build = buildstate.currentPlanState = currentPlan+ state.convo = convoreturn nildiff --git a/app/server/model/plan/build_result.go b/app/server/model/plan/build_result.goindex 38f33158..6761acb5 100644--- a/app/server/model/plan/build_result.go+++ b/app/server/model/plan/build_result.go@@ -1,12 +1,14 @@package planimport (+ "context""fmt""log""plandex-server/db"- "sort"+ "plandex-server/syntax""strings"+ "github.com/davecgh/go-spew/spew""github.com/google/uuid""github.com/plandex/plandex/shared")@@ -27,9 +29,16 @@ type PlanResultParams struct {PreBuildState stringOverlapStrategy OverlapStrategyStreamedChangesWithLineNums []*shared.StreamedChangeWithLineNums++ CheckSyntax bool++ IsFix bool+ IsSyntaxFix bool+ IsOtherFix bool+ FixEpoch int}-func GetPlanResult(params PlanResultParams) (*db.PlanFileResult, string, bool, error) {+func GetPlanResult(ctx context.Context, params PlanResultParams) (*db.PlanFileResult, string, bool, error) {orgId := params.OrgIdplanId := params.PlanIdplanBuildId := params.PlanBuildId@@ -63,6 +72,16 @@ func GetPlanResult(params PlanResultParams) (*db.PlanFileResult, string, bool, enew := streamedChange.New+ if streamedChange.Old.EntireFile {+ old = preBuildState+ replacements = append(replacements, &shared.Replacement{+ Old: old,+ New: new,+ StreamedChange: streamedChange,+ })+ continue+ }+// log.Printf("getPlanResult - streamedChange.Old.StartLine: %d\n", streamedChange.Old.StartLine)// log.Printf("getPlanResult - streamedChange.Old.EndLine: %d\n", streamedChange.Old.EndLine)@@ -90,6 +109,9 @@ func GetPlanResult(params PlanResultParams) (*db.PlanFileResult, string, bool, eif startLine < highestEndLine {log.Printf("Start line is less than highestEndLine: %d < %d\n", startLine, highestEndLine)+ log.Printf("streamedChange:\n")+ log.Println(spew.Sdump(streamedChangesWithLineNums))+if params.OverlapStrategy == OverlapStrategyError {return nil, "", false, fmt.Errorf("start line is less than highestEndLine: %d < %d", startLine,highestEndLine)@@ -128,12 +150,6 @@ func GetPlanResult(params PlanResultParams) (*db.PlanFileResult, string, bool, ereplacements = append(replacements, replacement)}- sort.Slice(replacements, func(i, j int) bool {- iIdx := strings.Index(preBuildState, replacements[i].Old)- jIdx := strings.Index(preBuildState, replacements[j].Old)- return iIdx < jIdx- })-log.Println("Will apply replacements")// log.Println("preBuildState:", preBuildState)@@ -155,7 +171,7 @@ func GetPlanResult(params PlanResultParams) (*db.PlanFileResult, string, bool, ereplacement.Id = id}- return &db.PlanFileResult{+ res := db.PlanFileResult{TypeVersion: 1,ReplaceWithLineNums: true,OrgId: orgId,@@ -166,5 +182,29 @@ func GetPlanResult(params PlanResultParams) (*db.PlanFileResult, string, bool, ePath: filePath,Replacements: replacements,AnyFailed: !allSucceeded,- }, updated, allSucceeded, nil+ CanVerify: !params.IsOtherFix,+ IsFix: params.IsFix,+ IsSyntaxFix: params.IsSyntaxFix,+ IsOtherFix: params.IsOtherFix,+ FixEpoch: params.FixEpoch,+ }++ if params.CheckSyntax {+ // validate syntax (if we have a parser)+ validationRes, err := syntax.Validate(ctx, filePath, updated)++ if err != nil {+ log.Println("Error validating syntax:", err)+ return nil, "", false, fmt.Errorf("error validating syntax: %v", err)+ }++ res.WillCheckSyntax = validationRes.HasParser && !validationRes.TimedOut+ res.SyntaxValid = validationRes.Valid+ res.SyntaxErrors = validationRes.Errors++ }++ // spew.Dump(res)++ return &res, updated, allSucceeded, nil}diff --git a/app/server/model/plan/build_state.go b/app/server/model/plan/build_state.goindex c938d8c9..392f766e 100644--- a/app/server/model/plan/build_state.go+++ b/app/server/model/plan/build_state.go@@ -8,7 +8,10 @@ import ("github.com/sashabaranov/go-openai")-const MaxBuildStreamErrorRetries = 3 // uses naive exponential backoff so be careful about setting this too high+const MaxBuildStreamErrorRetries = 3 // uses semi-exponential backoff so be careful with this++const FixSyntaxRetries = 2+const FixSyntaxEpochs = 2type activeBuildStreamState struct {clients map[string]*openai.Client@@ -19,6 +22,7 @@ type activeBuildStreamState struct {branch stringsettings *shared.PlanSettingsmodelContext []*db.Context+ convo []*db.ConvoMessage}type activeBuildStreamFileState struct {@@ -32,8 +36,18 @@ type activeBuildStreamFileState struct {lineNumsNumRetry intverifyFileNumRetry intfixFileNumRetry int- // fullChangesRetry int++ syntaxNumRetry int+ syntaxNumEpoch int++ isFixingSyntax bool+ isFixingOther bool+streamedChangesWithLineNums []*shared.StreamedChangeWithLineNumsupdated string- incorrectlyUpdatedReasoning string++ verificationErrors string+ syntaxErrors []string++ isNewFile bool}diff --git a/app/server/model/plan/build_stream_line_nums.go b/app/server/model/plan/build_stream_line_nums.goindex 57a34784..2efb9b11 100644--- a/app/server/model/plan/build_stream_line_nums.go+++ b/app/server/model/plan/build_stream_line_nums.go@@ -9,6 +9,7 @@ import ("math/rand""plandex-server/model""plandex-server/types"+ "sort""strings""time"@@ -128,7 +129,41 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(strlog.Printf("listenStream - File %s: Parsed streamed replacements\n", filePath)// spew.Dump(streamed)- fileState.streamedChangesWithLineNums = streamed.Changes+ sorted := []*shared.StreamedChangeWithLineNums{}++ // Sort the streamed changes by start line+ for _, change := range streamed.Changes {+ if change.HasChange {+ sorted = append(sorted, change)+ }+ }++ // Sort the streamed changes by start line+ sort.Slice(sorted, func(i, j int) bool {+ var iStartLine int+ var jStartLine int++ // Convert the line number part to an integer+ iStartLine, _, err := sorted[i].GetLines()++ if err != nil {+ log.Printf("listenStream - Error getting start line for change %v: %v\n", sorted[i], err)+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - error getting start line for change %v: %v", sorted[i], err))+ return false+ }++ jStartLine, _, err = sorted[j].GetLines()++ if err != nil {+ log.Printf("listenStream - Error getting start line for change %v: %v\n", sorted[j], err)+ fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - error getting start line for change %v: %v", sorted[j], err))+ return false+ }++ return iStartLine < jStartLine+ })++ fileState.streamedChangesWithLineNums = sortedvar overlapStrategy OverlapStrategy = OverlapStrategyErrorif fileState.lineNumsNumRetry > 1 {@@ -136,6 +171,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(str}planFileResult, updatedFile, allSucceeded, err := GetPlanResult(+ activePlan.Ctx,PlanResultParams{OrgId: currentOrgId,PlanId: planId,@@ -145,6 +181,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(strPreBuildState: preBuildState,StreamedChangesWithLineNums: streamed.Changes,OverlapStrategy: overlapStrategy,+ CheckSyntax: false,},)@@ -165,7 +202,6 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(str// no retry here as this should never happenfileState.onBuildFileError(fmt.Errorf("listenStream - replacements failed for file '%s'", filePath))return-}buildInfo := &shared.BuildInfo{@@ -184,13 +220,14 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(strlog.Printf("updatedFile exists: %v\n", updatedFile != "")log.Printf("toVerifyPlanFileResult exists: %v\n", planFileResult != nil)- fileState.onFinishBuildFile(planFileResult)+ fileState.onFinishBuildFile(planFileResult, updatedFile)return} else if len(delta.ToolCalls) == 0 {log.Println("listenStream - Stream chunk missing function call.")// log.Println(spew.Sdump(response))// log.Println(spew.Sdump(fileState))+ // log.Println("Current buffer:")// log.Println(fileState.activeBuild.WithLineNumsBuffer)fileState.lineNumsRetryOrError(fmt.Errorf("listenStream - stream chunk missing function call. Reason: %s, File: %s", choice.FinishReason, filePath))@@ -218,7 +255,7 @@ func (fileState *activeBuildStreamFileState) lineNumsRetryOrError(err error) {case <-activePlan.Ctx.Done():log.Println("lineNumsRetryOrError - Context canceled. Exiting.")return- case <-time.After(time.Duration(fileState.lineNumsNumRetry*fileState.lineNumsNumRetry)*time.Second + time.Duration(rand.Intn(1001))*time.Millisecond):+ case <-time.After(time.Duration((fileState.verifyFileNumRetry*fileState.verifyFileNumRetry)/2)*200*time.Millisecond + time.Duration(rand.Intn(500))*time.Millisecond):break}diff --git a/app/server/model/plan/build_verify.go b/app/server/model/plan/build_verify.goindex 07dbe801..06fc0e39 100644--- a/app/server/model/plan/build_verify.go+++ b/app/server/model/plan/build_verify.go@@ -11,12 +11,10 @@ import (func (fileState *activeBuildStreamFileState) verifyFileBuild() {filePath := fileState.filePath- activeBuild := fileState.activeBuildplanId := fileState.plan.Idbranch := fileState.branchclients := fileState.clients- config := fileState.settings.ModelPack.Builder- preBuildState := fileState.activeBuild.ToVerifyPreBuildState+ config := fileState.settings.ModelPack.GetVerifier()updated := fileState.activeBuild.ToVerifyUpdatedStateactivePlan := GetActivePlan(planId, branch)@@ -35,8 +33,16 @@ func (fileState *activeBuildStreamFileState) verifyFileBuild() {// log.Printf("activeBuild.FileDescription has content: %v\n", activeBuild.FileDescription != "")// log.Printf("activeBuild.FileContent has content: %v\n", activeBuild.FileContent != "")- sysPrompt := prompts.GetVerifyPrompt(preBuildState, updated,- fmt.Sprintf("%s\n\n```%s```", activeBuild.FileDescription, activeBuild.FileContent),+ verifyState, err := fileState.GetVerifyState()++ if err != nil {+ log.Printf("Error getting verify state for file '%s': %v\n", filePath, err)+ fileState.onBuildFileError(fmt.Errorf("error getting verify state for file '%s': %v", filePath, err))+ return+ }++ sysPrompt := prompts.GetVerifyPrompt(verifyState.preBuildFileState, updated,+ verifyState.proposedChanges,)log.Println("verify sysPrompt:\n", sysPrompt)diff --git a/app/server/model/plan/build_verify_state.go b/app/server/model/plan/build_verify_state.gonew file mode 100644index 00000000..6271d66d--- /dev/null+++ b/app/server/model/plan/build_verify_state.go@@ -0,0 +1,163 @@+package plan++import (+ "fmt"+ "log"+ "plandex-server/db"+ "plandex-server/types"+ "time"+)++type verifyState struct {+ proposedChanges string+ preBuildFileState string+}++func (fileState *activeBuildStreamFileState) GetVerifyState() (*verifyState, error) {+ planState := fileState.currentPlanState+ convo := fileState.convo+ path := fileState.filePath++ fileResults := planState.PlanResult.FileResultsByPath[path]++ if fileResults == nil {+ return nil, fmt.Errorf("no file results for path: %s", path)+ }++ proposedChanges := ""+ convoMessageIds := map[string]bool{}+ startingReplacementId := ""++ for _, fileResult := range fileResults {+ if !fileResult.IsPending() {+ continue+ }++ if fileResult.CanVerify && fileResult.RanVerifyAt != nil {+ convoMessageIds = map[string]bool{}+ startingReplacementId = ""+ } else if !fileResult.IsFix {+ convoMessageIds[fileResult.ConvoMessageId] = true+ if len(fileResult.Replacements) > 0 {+ startingReplacementId = fileResult.Replacements[0].Id+ }+ }+ }++ for _, convoMessage := range convo {+ if convoMessageIds[convoMessage.Id] {+ parser := types.NewReplyParser()+ parser.AddChunk(convoMessage.Message, false)+ parserRes := parser.FinishAndRead()++ for i, file := range parserRes.Files {+ if file == path {+ desc := parserRes.FileDescriptions[i]+ fileContents := parserRes.FileContents[i]++ proposedChanges += fmt.Sprintf("%s\n\n```\n%s\n```\n\n", desc, fileContents)+ }+ }++ }+ }++ var preBuildState string++ if startingReplacementId == "" {+ if planState.ContextsByPath[path] != nil {+ preBuildState = planState.ContextsByPath[path].Body+ }+ } else {+ files, err := planState.GetFilesBeforeReplacement(startingReplacementId)++ if err != nil {+ return nil, fmt.Errorf("error getting files before replacement: %v", err)+ }++ if files.Files[path] == "" {+ return nil, fmt.Errorf("no file content before replacement")+ }++ preBuildState = files.Files[path]+ }++ return &verifyState{+ proposedChanges: proposedChanges,+ preBuildFileState: preBuildState,+ }, nil++}++func (fileState *activeBuildStreamFileState) MarkLatestResultVerified(passed bool) error {+ planId := fileState.plan.Id+ branch := fileState.branch+ currentOrgId := fileState.currentOrgId+ currentUserId := fileState.currentUserId+ build := fileState.build++ activePlan := GetActivePlan(planId, branch)++ repoLockId, err := db.LockRepo(+ db.LockRepoParams{+ OrgId: currentOrgId,+ UserId: currentUserId,+ PlanId: planId,+ Branch: branch,+ PlanBuildId: build.Id,+ Scope: db.LockScopeWrite,+ Ctx: activePlan.Ctx,+ CancelFn: activePlan.CancelFn,+ },+ )+ if err != nil {+ log.Printf("Error locking repo for build file: %v\n", err)+ return fmt.Errorf("error locking repo for build file: %v", err)+ }++ err = func() error {+ var err error+ defer func() {+ if err != nil {+ log.Printf("Error: %v\n", err)+ err = db.GitClearUncommittedChanges(currentOrgId, planId)+ if err != nil {+ log.Printf("Error clearing uncommitted changes: %v\n", err)+ }+ }++ err := db.UnlockRepo(repoLockId)+ if err != nil {+ log.Printf("Error unlocking repo: %v\n", err)+ }+ }()++ results, err := db.GetPlanFileResults(currentOrgId, planId)++ if err != nil {+ return fmt.Errorf("error getting plan file results: %v", err)+ }++ if len(results) == 0 {+ return fmt.Errorf("no file results for path: %s", fileState.filePath)+ }++ latestPlanRes := results[len(results)-1]+ now := time.Now()+ latestPlanRes.RanVerifyAt = &now+ latestPlanRes.VerifyPassed = passed++ err = db.StorePlanResult(latestPlanRes)+ if err != nil {+ log.Printf("Error storing plan result: %v\n", err)+ return fmt.Errorf("error storing plan result: %v", err)+ }+ return nil+ }()++ if err != nil {+ return err+ }++ return nil+}diff --git a/app/server/model/plan/build_verify_stream.go b/app/server/model/plan/build_verify_stream.goindex 5a1c9299..049f934d 100644--- a/app/server/model/plan/build_verify_stream.go+++ b/app/server/model/plan/build_verify_stream.go@@ -41,7 +41,7 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *opreturncase <-timer.C:// Timer triggered because no new chunk was received in time- fileState.verifyRetryOrError(fmt.Errorf("listenStreamVerifyOutput - stream timeout due to inactivity for file '%s'", filePath))+ fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream timeout due to inactivity for file '%s'", filePath))returndefault:response, err := stream.Recv()@@ -60,34 +60,12 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *opreturn}- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })-- log.Println("build verify - error")-- fileState.onFinishBuildFile(nil)+ fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream error: %v", err))return}if len(response.Choices) == 0 {- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("build verify - no choices")- fileState.onFinishBuildFile(nil)+ fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream error: no choices"))return}@@ -101,19 +79,7 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *optrimmed := strings.TrimSpace(content)if trimmed == "{%invalidjson%}" || trimmed == "``(no output)``````" {log.Println("File", filePath+":", "%invalidjson%} token in streamed chunk")- fileState.verifyRetryOrError(fmt.Errorf("invalid JSON in streamed chunk for file '%s'", filePath))-- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("build verify - invalid json")- fileState.onFinishBuildFile(nil)+ fileState.verifyRetryOrAbort(fmt.Errorf("invalid JSON in streamed chunk for file '%s'", filePath))return}@@ -151,12 +117,16 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *opBuildInfo: buildInfo,})log.Println("build verify - streamed.IsCorrect")- fileState.onFinishBuildFile(nil)+ fileState.onFinishBuildFile(nil, "")} else {log.Printf("listenStreamVerifyOutput - File %s: Streamed verify result is incorrect\n", filePath)- fileState.incorrectlyUpdatedReasoning = streamed.GetReasoning()+ fileState.verificationErrors = streamed.GetReasoning()+ fileState.isFixingOther = true++ // log.Println("Verification errors:")+ // log.Println(fileState.verificationErrors)select {case <-activePlan.Ctx.Done():@@ -172,28 +142,14 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *oplog.Println("listenStreamVerifyOutput - Stream chunk missing function call.")// log.Println(spew.Sdump(response))- if fileState.verifyFileNumRetry > 0 {- buildInfo := &shared.BuildInfo{- Path: filePath,- NumTokens: 0,- Finished: true,- }- activePlan.Stream(shared.StreamMessage{- Type: shared.StreamMessageBuildInfo,- BuildInfo: buildInfo,- })- log.Println("build verify - retry")- fileState.onFinishBuildFile(nil)- } else {- fileState.verifyRetryOrError(fmt.Errorf("listenStreamVerifyOutput - stream chunk missing function call. Reason: %s, File: %s", choice.FinishReason, filePath))- }+ fileState.verifyRetryOrAbort(fmt.Errorf("listenStreamVerifyOutput - stream chunk missing function call. Reason: %s, File: %s", choice.FinishReason, filePath))}}}}-func (fileState *activeBuildStreamFileState) verifyRetryOrError(err error) {+func (fileState *activeBuildStreamFileState) verifyRetryOrAbort(err error) {if fileState.verifyFileNumRetry < MaxBuildStreamErrorRetries {fileState.verifyFileNumRetry++fileState.activeBuild.VerifyBuffer = ""@@ -201,10 +157,12 @@ func (fileState *activeBuildStreamFileState) verifyRetryOrError(err error) {log.Printf("Retrying verify file '%s' due to error: %v\n", fileState.filePath, err)// Exponential backoff- time.Sleep(time.Duration(fileState.verifyFileNumRetry*fileState.verifyFileNumRetry)*time.Second + time.Duration(rand.Intn(1001))*time.Millisecond)+ time.Sleep(time.Duration((fileState.verifyFileNumRetry*fileState.verifyFileNumRetry)/2)*200*time.Millisecond + time.Duration(rand.Intn(500))*time.Millisecond)- fileState.buildFile()+ fileState.verifyFileBuild()} else {- fileState.onBuildFileError(err)+ log.Printf("Aborting verify file '%s' due to error: %v\n", fileState.filePath, err)++ fileState.onFinishBuildFile(nil, "")}}diff --git a/app/server/model/plan/tell_state.go b/app/server/model/plan/tell_state.gonew file mode 100644index 00000000..434b49de--- /dev/null+++ b/app/server/model/plan/tell_state.go@@ -0,0 +1,34 @@+package plan++import (+ "plandex-server/db"+ "plandex-server/types"++ "github.com/plandex/plandex/shared"+ "github.com/sashabaranov/go-openai"+)++type activeTellStreamState struct {+ clients map[string]*openai.Client+ req *shared.TellPlanRequest+ auth *types.ServerAuth+ currentOrgId string+ currentUserId string+ plan *db.Plan+ branch string+ iteration int+ replyId string+ modelContext []*db.Context+ convo []*db.ConvoMessage+ missingFileResponse shared.RespondMissingFileChoice+ summaries []*db.ConvoSummary+ summarizedToMessageId string+ latestSummaryTokens int+ userPrompt string+ promptMessage *openai.ChatCompletionMessage+ replyParser *types.ReplyParser+ replyNumTokens int+ messages []openai.ChatCompletionMessage+ tokensBeforeConvo int+ settings *shared.PlanSettings+}diff --git a/app/server/model/plan/tell_stream.go b/app/server/model/plan/tell_stream.goindex 7dc10973..33a8351f 100644--- a/app/server/model/plan/tell_stream.go+++ b/app/server/model/plan/tell_stream.go@@ -17,31 +17,6 @@ import (const MaxAutoContinueIterations = 50-type activeTellStreamState struct {- clients map[string]*openai.Client- req *shared.TellPlanRequest- auth *types.ServerAuth- currentOrgId string- currentUserId string- plan *db.Plan- branch string- iteration int- replyId string- modelContext []*db.Context- convo []*db.ConvoMessage- missingFileResponse shared.RespondMissingFileChoice- summaries []*db.ConvoSummary- summarizedToMessageId string- latestSummaryTokens int- userPrompt string- promptMessage *openai.ChatCompletionMessage- replyParser *types.ReplyParser- replyNumTokens int- messages []openai.ChatCompletionMessage- tokensBeforeConvo int- settings *shared.PlanSettings-}-func (state *activeTellStreamState) listenStream(stream *openai.ChatCompletionStream) {defer stream.Close()diff --git a/app/server/model/prompts/build.go b/app/server/model/prompts/build.goindex d8f4806e..a08cf73e 100644--- a/app/server/model/prompts/build.go+++ b/app/server/model/prompts/build.go@@ -88,19 +88,23 @@ The 'hasChange' property is a boolean that indicates whether there is anything t`const lineNumsOldPrompt = `-The 'old' property is an object with 2 properties: 'startLineString' and 'endLineString'.+The 'old' property is an object with 3 properties: 'entireFile', 'startLineString' and 'endLineString'.- 'startLineString' is the **entire, exact line** where the section to be replaced begins in the original file, including the line number. Unless it's the first change, 'startLineString' ABSOLUTELY MUST begin with a line number that is HIGHER than both the 'endLineString' of the previous change and the 'startLineString' of the previous change.+ 'entireFile' is a boolean that indicates whether the **entire file** is being replaced. If 'entireFile' is true, 'startLineString' and 'endLineString' must be empty strings. If 'entireFile' is false, 'startLineString' and 'endLineString' must be valid strings that exactly match lines from the original file. If 'entireFile' is false, 'startLineString' and 'endLineString' MUST NEVER be empty strings.++ 'startLineString' is the **entire, exact line** where the section to be replaced begins in the original file, including the line number. Unless it's the first change, 'startLineString' ABSOLUTELY MUST begin with a line number that is HIGHER than both the 'endLineString' of the previous change and the 'startLineString' of the previous change. **The line number and line MUST EXACTLY MATCH a line from the original file.**If the previous change's 'endLineString' starts with 'pdx-75: ', then the current change's 'startLineString' MUST start with 'pdx-76: ' or higher. It MUST NOT be 'pdx-75: ' or lower. If the previous change's 'startLineString' starts with 'pdx-88: ' and the previous change's 'endLineString' is an empty string, then the current change's 'startLineString' MUST start with 'pdx-89: ' or higher. If the previous change's 'startLineString' starts with 'pdx-100: ' and the previous change's 'endLineString' starts with 'pdx-105: ', then the current change's 'startLineString' MUST start with 'pdx-106: ' or higher.- 'endLineString' is the **entire, exact line** where the section to be replaced ends in the original file. Pay careful attention to spaces and indentation. 'startLineString' and 'endLineString' must be *entire lines* and *not partial lines*. Even if a line is very long, you must include the entire line, including the line number and all text on the line.+ 'endLineString' is the **entire, exact line** where the section to be replaced ends in the original file. Pay careful attention to spaces and indentation. 'startLineString' and 'endLineString' must be *entire lines* and *not partial lines*. Even if a line is very long, you must include the entire line, including the line number and all text on the line. **The line number and line MUST EXACTLY MATCH a line from the original file.****For a single line replacement, 'endLineString' MUST be an empty string.**'endLineString' MUST ALWAYS come *after* 'startLineString' in the original file. It must start with a line number that is HIGHER than the 'startLineString' line number. If 'startLineString' starts with 'pdx-22: ', then 'endLineString' MUST either be an empty string (for a single line replacement) or start with 'pdx-23: ' or higher (for a multi-line replacement).- If 'hasChange' is false, both 'startLineString' and 'endLineString' must be empty strings. If 'hasChange' is true, 'startLineString' and 'endLineString' must be valid strings.+ If 'hasChange' is false, both 'startLineString' and 'endLineString' must be empty strings. If 'hasChange' is true, 'startLineString' and 'endLineString' must be valid strings that exactly match lines from the original file. If 'hasChange' is true, 'startLineString' and 'endLineString' MUST NEVER be empty strings.++ If you are replacing the entire file, 'startLineString' MUST be the first line of the original file and 'endLineString' MUST be the last line of the original file.`const changeLineInclusionAndNewPrompt = `@@ -119,6 +123,8 @@ If the proposed update includes references to the original code in comments likeIf the 'startLineIncluded' property is true, the 'startLineString' MUST be the first line of 'new'. If the 'startLineIncluded' property is false, the 'startLineString' MUST NOT be included in 'new'. If the 'endLineIncluded' property is true, the 'endLineString' MUST be the last line of 'new'. If the 'endLineIncluded' property is false, the 'endLineString' MUST NOT be included in 'new'.If the 'hasChange' property is false, the 'new' property must be an empty string. If the 'hasChange' property is true, the 'new' property must be a valid string.++If *any* change has the 'entireFile' key in the 'old' property set to true, the corresponding 'new' key MUST be the entire updated file, and there MUST only be a single change in the 'changes' array.`const lineNumsRulesPrompt = `@@ -127,10 +133,14 @@ You ABSOLUTELY MUST NOT generate overlapping changes. Group smaller changes togeFurthermore, unless doing so would require a very large change because some changes are far apart in the file, it's ideal to call the 'listChangesWithLineNums' with just a SINGLE change.Changes must be ordered in the array according to the order they appear in the file. The 'startLineString' of each 'old' property must come after the 'endLineString' of the previous 'old' property. Changes MUST NOT overlap. If a change is dependent on another change or intersects with it, group those changes together into a single change.++You MUST NOT repeat changes to the same block of lines multiple teams. You MUST NOT duplicate changes. It is extremely important that a given change is only applied *once*.`const changeRulesPrompt = `-Apply changes intelligently in order to avoid syntax errors, breaking code, or removing code from the original file that should not be removed. Consider the reason behind the update and make sure the result is consistent with the intention of the plan.+Apply changes intelligently **in order** to avoid syntax errors, breaking code, or removing code from the original file that should not be removed. Consider the reason behind the update and make sure the result is consistent with the intention of the plan.++Changes MUST be ordered based on their position in the original file. ALWAYS go from top to bottom IN ORDER when generating replacements. DO NOT EVER GENERATE AN OVERLAPPING CHANGE. If a change would fall within OR overlap a prior change in the list, SKIP that change and move on to the next one.You ABSOLUTELY MUST NOT overwrite or delete code from the original file unless the plan *clearly intends* for the code to be overwritten or removed. Do NOT replace a full section of code with only new code unless that is the clear intention of the plan. Instead, merge the original code and the proposed updates together intelligently according to the intention of the plan.@@ -138,7 +148,13 @@ Pay *EXTREMELY close attention* to opening and closing brackets, parentheses, an`const lineNumsJsonPrompt = `-The 'listChangesWithLineNums' function MUST be called *valid JSON*. Double quotes within json properties of the 'listChangesWithLineNums' function call parameters JSON object *must be properly escaped* with a backslash.+The 'listChangesWithLineNums' function MUST be called *valid JSON*. Double quotes within json properties of the 'listChangesWithLineNums' function call parameters JSON object *must be properly escaped* with a backslash. Pay careful attention to newlines, tabs, and other special characters. The JSON object must be properly formatted and must include all required keys. **You generate perfect JSON -every- time**, no matter how many quotes or special characters are in the input. You must always call 'listChangesWithLineNums' with a valid JSON object. Don't call any other function.+`++const commentsPrompt = `+The 'comments' key is an array of objects with two properties: 'txt' and 'reference'. 'txt' is the exact text of a code comment. 'reference' is a boolean that indicates whether the comment is a placeholder of or reference to the original code, like "// rest of the function..." or "# existing init code...", or "// rest of the main function" or "// rest of your function..." or "// Existing methods..." or "// Remaining methods" or "// Existing code..." or "// ... existing setup code ..."" or other comments which reference code from the original file. References DO NOT need to exactly match any of the previous examples. Use your judgement to determine whether each comment is a reference. If 'reference' is true, the comment is a placeholder or reference to the original code. If 'reference' is false, the comment is not a placeholder or reference to the original code.++In 'comments', you must list EVERY comment included in the proposed updates. Only list *code comments* that are valid comments for the programming language being used. Do not list logging statements or any other non-comment text that is not a valid code comment. If there are no code comments in the proposed updates, 'comments' must be an empty array.`func getListChangesLineNumsPrompt() string {@@ -147,7 +163,17 @@ func getListChangesLineNumsPrompt() string {[YOUR INSTRUCTIONS]- Call the 'listChangesWithLineNums' function with a valid JSON object that includes the 'changes' keys.+ Call the 'listChangesWithLineNums' function with a valid JSON object that includes the 'comments', 'problems', and 'changes' keys.++ ` + lineNumsRulesPrompt + `++ ` + commentsPrompt + `++ In the 'problems' key, you MUST explain how you will strategically generate changes in order to avoid any problems in the updated file. You should explain which changes you will make and how you will *avoid* making any overlapping or invalid changes. Consider whether any changes are close together or whether any change is potentially contained by another. If so, group those changes together into a single change.++ You must also consider how you will avoid including any references in the updated file if any are present in the proposed updates.++ You must also consider how you will *avoid incorrect duplication* in making your changes. For example if a 'main' function is present in the original file and the proposed updates include update code for the 'main' function, you must ensure the changes are applied within the existing 'main' function rather than incorrectly adding a duplicate 'main' function.` + changesKeyPrompt + `@@ -157,19 +183,19 @@ func getListChangesLineNumsPrompt() string {` + changeLineInclusionAndNewPrompt + `- Example function call with all keys:+ Example change object:---- listChangesWithLineNums([{+ {summary: "Fix syntax error in loop body.",old: {startLineString: "pdx-5: for i := 0; i < 10; i++ { ",endLineString: "pdx-7: }",},new: "for i := 0; i < 10; i++ {\n execQuery()\n }\n }\n}",- }])+ }---- ` + lineNumsRulesPrompt + `+ ` + `` + changeRulesPrompt + `@@ -178,7 +204,6 @@ func getListChangesLineNumsPrompt() string {[END YOUR INSTRUCTIONS]`}-func getFixChangesLineNumsPrompt() string {return `@@ -194,14 +219,16 @@ func getFixChangesLineNumsPrompt() string {- Incorrectly duplicated code- Incorrectly applied comments that reference the original code- If the updated includes references to the original code in comments like "// rest of the function..." or "# existing init code...", or "// rest of the main function..." or "// rest of your function..." or "// Existing methods..." **any other reference to the original code, the file is incorrect. References like these must be handled by including the exact code from the original file that the comment is referencing.+ If the updated file includes references to the original code in comments like "// rest of the function..." or "# existing init code...", or "// rest of the main function..." or "// rest of your function..." or "// Existing methods..." **any other reference to the original code, the file is incorrect. References like these must be handled by including the exact code from the original file that the comment is referencing.[YOUR INSTRUCTIONS]- Call the 'listChangesWithLineNums' function with a valid JSON object that includes the 'problems' and 'changes' keys.+ Call the 'listChangesWithLineNums' function with a valid JSON object that includes the 'comments','problems' and 'changes' keys.++ ` + commentsPrompt + `'problems': A string that describes all problems present within the updated file. Explain the cause of each problem and how it should be fixed. Do not just restate that there is a syntax error on a specific line. Explain what the syntax error is and how to fix it. Be exhaustive and include *every* problem that is present in the file.- Since you are fixing an incorrectly updated file, you *MUST* include the 'problems' key and you *MUST* describe *all* problems present in the file. If you cannot identify any problems immediately, output a few hypotheses about what might be wrong and then explain which of them are actually present in the file. The file definitely does have problems, so you *must* identify them.+ Since you are fixing an incorrectly updated file, you *MUST* include the 'problems' key and you *MUST* describe *all* problems present in the file. If you cannot identify any problems immediately, output a few hypotheses about what might be wrong and then explain which of them are actually present in the file. The file definitely does have problems, so you *must* identify them.` + changesKeyPrompt + `@@ -215,16 +242,16 @@ func getFixChangesLineNumsPrompt() string {Because you are implementing a fix, be more willing to make larger changes in order to fix all the problems. Smaller changes are more error-prone, and the fact that you are fixing a file means a line-number based change already failed. This likely means there was some tricky structural challenge in applying the changes with line numbers, so be prepared to make a larger change in order to avoid continuing to fail to fix the file.- Example function call with all keys:+ Example change object:---- listChangesWithLineNums([{+ {summary: "Fix syntax error in loop body.",old: {startLineString: "pdx-5: for i := 0; i < 10; i++ { ",endLineString: "pdx-7: }",},new: "for i := 0; i < 10; i++ {\n execQuery()\n }\n }\n}",- }])+ }---` + lineNumsRulesPrompt + `@@ -242,6 +269,21 @@ var ListReplacementsFn = openai.FunctionDefinition{Parameters: &jsonschema.Definition{Type: jsonschema.Object,Properties: map[string]jsonschema.Definition{+ "comments": {+ Type: jsonschema.Array,+ Items: &jsonschema.Definition{+ Type: jsonschema.Object,+ Properties: map[string]jsonschema.Definition{+ "txt": {+ Type: jsonschema.String,+ },+ "reference": {+ Type: jsonschema.Boolean,+ },+ },+ Required: []string{"txt", "reference"},+ },+ },"problems": {Type: jsonschema.String,},@@ -259,6 +301,9 @@ var ListReplacementsFn = openai.FunctionDefinition{"old": {Type: jsonschema.Object,Properties: map[string]jsonschema.Definition{+ "entireFile": {+ Type: jsonschema.Boolean,+ },"startLineString": {Type: jsonschema.String,},@@ -297,7 +342,7 @@ var ListReplacementsFn = openai.FunctionDefinition{},},},- Required: []string{"changes"},+ Required: []string{"comments", "problems", "changes"},},}@@ -371,7 +416,9 @@ In each of the reasoning keys above, be exhaustive and include *every* problem ts += updated + `-Now call the 'verifyOutput' function with a valid JSON object that includes the 'reasoning', and 'isCorrect' keys. You must always call 'verifyOutput' with a valid JSON object. Don't call any other function.`+Now call the 'verifyOutput' function with a valid JSON object that includes the 'reasoning', and 'isCorrect' keys. You must always call 'verifyOutput' with a valid JSON object. Don't call any other function.++You absolutely MUST generate PERFECTLY VALID JSON. Pay extremely close attention to the JSON syntax and structure. Double quotes within JSON properties *MUST* be properly escaped with a backslash.`return s}diff --git a/app/server/model/prompts/create.go b/app/server/model/prompts/create.goindex cf1d21c5..c35e6cc5 100644--- a/app/server/model/prompts/create.go+++ b/app/server/model/prompts/create.go@@ -45,7 +45,7 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context` + "```" + `b. If not:- Explicitly say "Let's break up this task."- - Divide the task into smaller subtasks and list them in a numbered list. Stop there.+ - Divide the task into smaller subtasks and list them in a numbered list. Subtasks MUST ALWAYS be numbered. Stop there.- If you are already working on a subtask and the subtask is still too large to be implemented in a single response, it should be further broken down into smaller subtasks. In that case, explicitly say "Let's further break up this subtask", further divide the subtask into even smaller steps, and list them in a numbered list. Stop there. Do NOT do this repetitively for the same subtask. Only break down a given subtask into smaller steps once.- Be thorough and exhaustive in your list of subtasks. Ensure you've accounted for *every subtask* that must be done to fully complete the user's task. Ensure that you list *every* file that needs to be created or updated. Be specific and detailed in your list of subtasks.- Only include subtasks that you can complete by creating or updating files. If a subtask requires executing code or commands, mention it to the user, but do not include it as a subtask in the plan. Do not include subtasks like "Testing and integration" or "Deployment" that require executing code or commands. Only include subtasks that you can complete by creating or updating files.@@ -119,11 +119,17 @@ const SysCreate = Identity + ` A plan is a set of files with an attached contextAfter implementing a task or subtask with code, and before moving on to another task or subtask, you MUST *explicitly mark it done*. You can do this by explicitly stating "[subtask] has been completed". For example, "**Adding the update function** has been completed." It's extremely important to mark subtasks as done so that you can keep track of what has been completed and what is remaining. Never move on to a new subtask. Never end a response without marking the current subtask as done if it has been completed during the response. You MUST NOT omit marking a subtask as done when it has been completed.- After marking the current subtask as done, move on to the next task or subtask if any are remaining. Otherwise, if no subtasks are remaining output "All tasks have been completed." and stop there.+ ` + CommentPlaceholderInstructions + `- If all subtasks are completed, then consider the plan complete. DO NOT repeat or re-implement a subtask that has already been done. Only work on subtasks that are NOT done--that have either not been started or have only been partially compeleted.+ Next, move on to the next task or subtask if any are remaining. Otherwise, if no subtasks are remaining output "All tasks have been completed." and stop there.++ If all subtasks are completed, then consider the plan complete. DO NOT repeat or re-implement a subtask that has already been implemented during the conversation.++ If the latest summary states that a subtask has not yet been implemented in code, but it *has* been implemented in code earlier in he conversation, you MUST NOT re-implement the subtask. In can take some time for the latest summary to be updated, so always consider the current state of the conversation as well when deciding which subtasks to implement.++ You should only implement each subtask once. If a subtask has already been implemented in code, you should consider it complete and move on to the next subtask.- You MUST ALWAYS work on subtasks IN ORDER. You must not skip a subtask or work on subtasks out of order. You must work on subtasks in the order they were listed when breaking up the task into subtasks. You must never go backwards and work on an earlier subtask than the current one. After finishing a subtask, you must always either work on the next subtask in the list of subtasks you created when breaking up the task or, if there are no remaining subtasks, end the plan with "All tasks have been completed.".+ You MUST ALWAYS work on subtasks IN ORDER. You must not skip a subtask or work on subtasks out of order. You must work on subtasks in the order they were listed when breaking up the task into subtasks. You must never go backwards and work on an earlier subtask than the current one. After finishing a subtask, you must always either work on the next subtask or, if there are no remaining subtasks, end the plan with "All tasks have been completed.".## Things you can't do@@ -150,6 +156,8 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context## Ending a responseBefore ending a response, first mark the current subtask as done as described above if it has been completed during the response.++ ` + CommentPlaceholderInstructions + `At the *very* end of your response, in a final, separate paragraph, you *must* decide whether the plan is completed and if not, whether it should be automatically continued.- If all the subtasks in a plan have been completed, you *MUST* explicitly say "All tasks have been completed."@@ -201,7 +209,7 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context## Consider the latest context- Be aware that since the plan started, the context may have been updated. It may have been updated by the user implementing your suggestions, by the user implementing their own work, or by the user adding more files or information to context. Be sure to consider the current state of the context when continuing with the plan, and whether the plan needs to be updated to reflect the latest context. For example, if you are working on a plan that has been broken up into subtasks, and you've reached the point of implementing a particular subtask, first consider whether the subtask is still necessary looking at the files in context. If it has already been implemented or is no longer necessary, say so, revise the plan as needed, and move on. Otherwise, implement the subtask.+ Be aware that since the plan started, the context may have been updated. It may have been updated by the user implementing your suggestions, by the user implementing their own work, or by the user adding more files or information to context. Be sure to consider the current state of the context when continuing with the plan, and whether the plan needs to be updated to reflect the latest context. For example, if you are working on a plan that has been broken up into subtasks, and you've reached the point of implementing a particular subtask, first consider whether the subtask is still necessary looking at the files in context. If it has already been implemented or is no longer necessary, say so, revise the plan as needed, and move on. Do NOT make an update that is no longer necessary based on the current state of the context. Otherwise, implement the subtask.## Responding to user questions@@ -232,6 +240,10 @@ If you're making a plan, end every response with either "All tasks have been comAlways name the subtask you are working on before starting it, and mark it as done before moving on to the next subtask.+ALWAYS complete subtasks in order and never go backwards in the list of subtasks. Never skip a subtask or work on subtasks out of order. Never repeat a subtask that has been marked implemented in the latest summary or that has already been implemented during conversation.++` + CommentPlaceholderInstructions + `+If you break up a task into subtasks, only include subtasks that can be implemented directly in code by creating or updating files. Do not include subtasks that require executing code or commands. Do not include subtasks that require user testing, deployment, or other tasks that go beyond coding.Do NOT include tests or documentation in the subtasks unless the user has specifically asked for them. Do not include extra code or features beyond what the user has asked for. Focus on the user's request and implement only what is necessary to fulfill it.`@@ -248,7 +260,11 @@ const AutoContinuePrompt = `Continue the plan from where you left off in the preContinue seamlessly from where your previous response left off. Never begin your response with 'The plan cannot be continued.' or 'All tasks have been completed.'.-Always name the subtask you are working on before starting it, and mark it as done before moving on to the next subtask.+Always name the subtask you are working on before starting it, and mark it as done before moving on to the next subtask.++ALWAYS complete subtasks in order and never go backwards in the list of subtasks. Never skip a subtask or work on subtasks out of order. Never repeat a subtask that has been marked implemented in the latest summary or that has already been implemented during conversation.++` + CommentPlaceholderInstructions + `If you break up a task into subtasks, only include subtasks that can be implemented directly in code by creating or updating files. Do not include subtasks that require executing code or commands. Do not include subtasks that require user testing, deployment, or other tasks that go beyond coding.@@ -257,3 +273,7 @@ Do NOT include tests or documentation in the subtasks unless the user has specifconst SkippedPathsPrompt = "\n\nSome files have been skipped by the user and *must not* be generated. The user will handle any updates to these files themselves. Skip any parts of the plan that require generating these files. You *must not* generate a file block for any of these files.\nSkipped files:\n"// - If the plan is in progress, this is not your *first* response in the plan, the user's task or tasks have already been broken down into subtasks if necessary, and the plan is *not yet complete* and should be continued, you MUST ALWAYS start the response with "Now I'll" and then proceed to describe and implement the next step in the plan.++const CommentPlaceholderInstructions = `+Immediately after EVERY code block, consider whether the code that implemented it contains one or more placeholders in comments for functionality that *has not been implemented*, like "// Add logic here" or "// Implement the function", or "# Update the state" or " # Finish impelementation" or any similar placeholder comments that describe tasks that still remain to be implemented. If comments like these are not followed by the *actual implementation in code*, and this task described in the placeholder comment is not *already* in the list of subtasks, you *must immediately* state that some tasks have been left unimplemented in the preceding code, then output a heading like "## Adding subtask 7: " (while using the appropriate number) followed by a brief description of the subtask that should be added based on the comment placeholder. If there are NO comment placeholders that were left unimplemtented, then mark the current subtask as done according to your instructions. You MUST ALWAYS either mark the current subtask as done or state that some tasks have been left unimplemented and then add them as additional subtasks. This is EXTREMELY IMPORTANT--if you skip this step, the plan will not be fully completed. You MUST NOT end the plan while placeholder comments remain unimplemented. When introducing a new subtask baced on a placeholder comment, it MUST be added to the END of the current list of subtasks as a new numbered subtask. You MUST NEVER output "All tasks have been completed" and end the plan without adding ALL unimplemented comment placeholders as subtasks and *fully implementing* every subtask that has been added based on a placeholder comment.+`diff --git a/app/server/model/prompts/summary.go b/app/server/model/prompts/summary.goindex 690dec15..50d26c87 100644--- a/app/server/model/prompts/summary.go+++ b/app/server/model/prompts/summary.go@@ -37,7 +37,7 @@ Based on the existing summary and the conversation so far, make a summary of the- Begin with a summary of the user's messages, with particular focus any tasks they have given you. Your summary of the tasks should reflect the latest version of each task--if they have changed over time, summarize the latest state of each task that was given and omit anything that is now obsolete. Condense this information as much as possible while still being clear and retaining the meaning of the original messages.-- Next, if the plan has been broken down into subtasks, include ALL those subtasks *verbatim* in the summary as a numbered list, then mark whether each subtask has been implemented in code during the conversation. You must include ALL subtasks, even if they have not been mentioned in the latest messages. If this conversation began with an existing summary, include ALL the subtasks from the existing summary.+- Next, if the plan has been broken down into subtasks, include ALL those subtasks *verbatim* in the summary as a numbered list, then mark whether each subtask has been implemented in code during the conversation. *Subtasks MUST ALWAYS be numbered.* You must include ALL subtasks, even if they have not been mentioned in the latest messages. If this conversation began with an existing summary, include ALL the subtasks from the existing summary.- Mark whether each subtask has been implemented in code during the conversation. A subtask has been implemented if *ANY* code blocks related to it have been included in the conversation. Do not be overly strict. Mark a subtask as implemented if it has been dealt with at all during the conversation. If a subtask has been implemented, mark it as implemented in code in the summary.@@ -55,7 +55,13 @@ Based on the existing summary and the conversation so far, make a summary of the- Do not include code in the summary. Explain in words what has been done and what needs to be done.-- Treat the summary as *append-only*. Keep as much information as possible from the existing summary and add the new information from the latest messages. The summary is meant to be a record of the entire plan as it evolves over time.+- Treat the summary as *append-only*. Keep as much information as possible from the existing summary and add the new information from the latest messages. The summary is meant to be a record of the entire plan as it evolves over time.++- If a subtask has been implemented in code, but the code contains one or more placeholders in comments for functionality that *has not been implemented*, like "// Add logic here" or "// Implement the function", or "# Update the state" or " # Finish impelementation", or any similar placeholder comments that describe tasks that still remain to be implemented. If comments like these are not followed by the *actual implementation in code*, and this task described in the placeholder comment is not *already* in the list of subtasks, then you MUST append a new subtask to the end of the list for each placeholder comment that has not been implemented, and mark it as not implemented in code. If the task described in the placeholder comment is already in the list of subtasks, then you MUST NOT add it again. When introducing a new subtask baced on a placeholder comment, it should be added as a FULL subtask, not a sub-subtask. It MUST be added to the end of the list.++- If a new subtask is introduced during the plan, and it is not already in the list of subtasks, and it has not already been implemented in code, then you MUST add it to the list of subtasks and mark it as not implemented in code.++- Do NOT duplicate subtasks or sub-subtasks in the list. If the plan or a comment placeholder introduces a new subtask or sub-subtask that is already in the list or is functionally equivalent to a subtask or sub-subtask in the list, do NOT add it to the list again.Output only the summary of the current state of the plan and nothing else.`diff --git a/app/server/syntax/validate.go b/app/server/syntax/validate.goindex 88b50403..b7ecf591 100644--- a/app/server/syntax/validate.go+++ b/app/server/syntax/validate.go@@ -3,6 +3,7 @@ package syntaximport ("path/filepath""strings"+ "time"tree_sitter "github.com/smacker/go-tree-sitter"@@ -10,10 +11,13 @@ import ("fmt")+const parserTimeout = 500 * time.Millisecond+type ValidationRes = struct {Ext stringLang stringHasParser bool+ TimedOut boolValid boolErrors []string}@@ -27,6 +31,10 @@ func Validate(ctx context.Context, path, file string) (*ValidationRes, error) {return &ValidationRes{Ext: ext, Lang: lang, HasParser: false}, nil}+ // Set a timeout duration for the parsing operations+ ctx, cancel := context.WithTimeout(ctx, parserTimeout)+ defer cancel()+// Parse the contenttree, err := parser.ParseCtx(ctx, nil, []byte(file))@@ -42,6 +50,11 @@ func Validate(ctx context.Context, path, file string) (*ValidationRes, error) {if fallbackParser != nil {fallbackTree, err := fallbackParser.ParseCtx(ctx, nil, []byte(file))if err != nil || fallbackTree == nil {++ if err != nil && strings.Contains(err.Error(), "timeout") {+ return &ValidationRes{Ext: ext, Lang: lang, HasParser: true, TimedOut: true}, nil+ }+return nil, fmt.Errorf("failed to parse the content with fallback parser: %v", err)}defer fallbackTree.Close()diff --git a/app/server/types/active_plan.go b/app/server/types/active_plan.goindex ce38bf8e..a7bbdbab 100644--- a/app/server/types/active_plan.go+++ b/app/server/types/active_plan.go@@ -27,15 +27,12 @@ type ActiveBuild struct {WithLineNumsBufferTokens intVerifyBuffer stringVerifyBufferTokens int- // FullChangeBuffer string- // FullChangeBufferTokens int- FixBuffer string- FixBufferTokens int- Success bool- Error error- IsVerification bool- ToVerifyPreBuildState string- ToVerifyUpdatedState string+ FixBuffer string+ FixBufferTokens int+ Success bool+ Error error+ IsVerification bool+ ToVerifyUpdatedState string}type subscription struct {diff --git a/app/server/types/active_plan_pending_builds.go b/app/server/types/active_plan_pending_builds.goindex 73cbe6a0..e19189f6 100644--- a/app/server/types/active_plan_pending_builds.go+++ b/app/server/types/active_plan_pending_builds.go@@ -66,6 +66,7 @@ func (ap *ActivePlan) PendingBuildsByPath(orgId, userId string, convoMessagesArg}fileContent := parserRes.FileContents[i]+ fileDesc := parserRes.FileDescriptions[i]numTokens, err := shared.GetNumTokens(fileContent)@@ -80,7 +81,7 @@ func (ap *ActivePlan) PendingBuildsByPath(orgId, userId string, convoMessagesArgFileContent: fileContent,FileContentTokens: numTokens,Path: file,- FileDescription: parserRes.FileDescriptions[i],+ FileDescription: fileDesc,})}}diff --git a/app/server/types/model.go b/app/server/types/model.goindex 3515b3ce..74cb9ce8 100644--- a/app/server/types/model.go+++ b/app/server/types/model.go@@ -11,6 +11,10 @@ type StreamedFile struct {}type StreamedChangesWithLineNums struct {+ Comments []struct {+ Txt string `json:"txt"`+ Reference bool `json:"reference"`+ }Problems string `json:"problems"`Changes []*shared.StreamedChangeWithLineNums `json:"changes"`}diff --git a/app/server/types/reply.go b/app/server/types/reply.goindex db3a1707..61b6650c 100644--- a/app/server/types/reply.go+++ b/app/server/types/reply.go@@ -1,6 +1,7 @@package typesimport (+ "os""strings")@@ -229,7 +230,20 @@ func (r *ReplyParser) GetReplyBeforePath(path string) string {}func lineMaybeHasFilePath(line string) bool {- return (strings.HasPrefix(line, "-")) || strings.HasPrefix(line, "-file:") || strings.HasPrefix(line, "- file:") || (strings.HasPrefix(line, "**") && strings.HasSuffix(line, "**")) || (strings.HasPrefix(line, "#") && strings.HasSuffix(line, ":"))+ couldBe := (strings.HasPrefix(line, "-")) || strings.HasPrefix(line, "-file:") || strings.HasPrefix(line, "- file:") || (strings.HasPrefix(line, "**") && strings.HasSuffix(line, "**")) || (strings.HasPrefix(line, "#") && strings.HasSuffix(line, ":"))++ if couldBe {+ extracted := extractFilePath(line)++ extSplit := strings.Split(extracted, ".")+ hasExt := len(extSplit) > 1 && !strings.Contains(extSplit[len(extSplit)-1], " ")+ hasFileSep := strings.Contains(extracted, string(os.PathSeparator))+ hasSpaces := strings.Contains(extracted, " ")++ return !(!hasExt && !hasFileSep && hasSpaces)+ }++ return couldBe}func extractFilePath(line string) string {diff --git a/app/shared/ai_models.go b/app/shared/ai_models.goindex 0d81aba6..57fa9d3b 100644--- a/app/shared/ai_models.go+++ b/app/shared/ai_models.go@@ -22,7 +22,7 @@ var AvailableModels = []*AvailableModel{DefaultReservedOutputTokens: 4096,BaseModelConfig: BaseModelConfig{Provider: ModelProviderOpenAI,- ModelName: "gpt-4o",+ ModelName: openai.GPT4o,MaxTokens: 128000,ApiKeyEnvVar: OpenAIEnvVar,ModelCompatibility: fullCompatibility,@@ -346,6 +346,14 @@ var DefaultConfigByRole = map[ModelRole]ModelRoleConfig{Temperature: 0.1,TopP: 0.1,},+ ModelRoleVerifier: {+ Temperature: 0.2,+ TopP: 0.2,+ },+ ModelRoleAutoFix: {+ Temperature: 0.1,+ TopP: 0.1,+ },}var RequiredCompatibilityByRole = map[ModelRole]ModelCompatibility{@@ -374,6 +382,18 @@ var RequiredCompatibilityByRole = map[ModelRole]ModelCompatibility{IsOpenAICompatible: true,HasFunctionCalling: true,},+ ModelRoleVerifier: {+ IsOpenAICompatible: true,+ HasStreaming: true,+ HasFunctionCalling: true,+ HasStreamingFunctionCalls: true,+ },+ ModelRoleAutoFix: {+ IsOpenAICompatible: true,+ HasStreaming: true,+ HasFunctionCalling: true,+ HasStreamingFunctionCalls: true,+ },}func init() {@@ -383,25 +403,25 @@ func init() {Gpt4oLatestModelPack = ModelPack{Name: "gpt-4o-latest",- Description: "Uses OpenAI's latest gpt-4o model, first released on 2024-05-13, for heavy lifting, latest version of gpt-3.5-turbo for lighter tasks.",+ Description: "Uses OpenAI's latest gpt-4o model, first released on 2024-05-13, for heavy lifting, and latest version of gpt-3.5-turbo for lighter tasks.",Planner: PlannerRoleConfig{ModelRoleConfig: ModelRoleConfig{Role: ModelRolePlanner,- BaseModelConfig: AvailableModelsByName["gpt-4o"].BaseModelConfig,+ BaseModelConfig: AvailableModelsByName[openai.GPT4o].BaseModelConfig,Temperature: DefaultConfigByRole[ModelRolePlanner].Temperature,TopP: DefaultConfigByRole[ModelRolePlanner].TopP,},- PlannerModelConfig: getPlannerModelConfig("gpt-4o"),+ PlannerModelConfig: getPlannerModelConfig(openai.GPT4o),},PlanSummary: ModelRoleConfig{Role: ModelRolePlanSummary,- BaseModelConfig: AvailableModelsByName["gpt-4o"].BaseModelConfig,+ BaseModelConfig: AvailableModelsByName[openai.GPT4o].BaseModelConfig,Temperature: DefaultConfigByRole[ModelRolePlanSummary].Temperature,TopP: DefaultConfigByRole[ModelRolePlanSummary].TopP,},Builder: ModelRoleConfig{Role: ModelRoleBuilder,- BaseModelConfig: AvailableModelsByName["gpt-4o"].BaseModelConfig,+ BaseModelConfig: AvailableModelsByName[openai.GPT4o].BaseModelConfig,Temperature: DefaultConfigByRole[ModelRoleBuilder].Temperature,TopP: DefaultConfigByRole[ModelRoleBuilder].TopP,},@@ -419,10 +439,22 @@ func init() {},ExecStatus: ModelRoleConfig{Role: ModelRoleExecStatus,- BaseModelConfig: AvailableModelsByName["gpt-4o"].BaseModelConfig,+ BaseModelConfig: AvailableModelsByName[openai.GPT4o].BaseModelConfig,Temperature: DefaultConfigByRole[ModelRoleExecStatus].Temperature,TopP: DefaultConfigByRole[ModelRoleExecStatus].TopP,},+ Verifier: &ModelRoleConfig{+ Role: ModelRoleVerifier,+ BaseModelConfig: AvailableModelsByName[openai.GPT4o].BaseModelConfig,+ Temperature: DefaultConfigByRole[ModelRoleVerifier].Temperature,+ TopP: DefaultConfigByRole[ModelRoleVerifier].TopP,+ },+ AutoFix: &ModelRoleConfig{+ Role: ModelRoleAutoFix,+ BaseModelConfig: AvailableModelsByName[openai.GPT4o].BaseModelConfig,+ Temperature: DefaultConfigByRole[ModelRoleAutoFix].Temperature,+ TopP: DefaultConfigByRole[ModelRoleAutoFix].TopP,+ },}Gpt4TurboLatestModelPack = ModelPack{diff --git a/app/shared/data_models.go b/app/shared/data_models.goindex 2ff79c4d..6c845337 100644--- a/app/shared/data_models.go+++ b/app/shared/data_models.go@@ -163,8 +163,17 @@ type PlanFileResult struct {AppliedAt *time.Time `json:"appliedAt,omitempty"`RejectedAt *time.Time `json:"rejectedAt,omitempty"`Replacements []*Replacement `json:"replacements"`- CreatedAt time.Time `json:"createdAt"`- UpdatedAt time.Time `json:"updatedAt"`++ CanVerify bool `json:"canVerify"`+ RanVerifyAt *time.Time `json:"ranVerifyAt,omitempty"`+ VerifyPassed bool `json:"verifyPassed"`++ IsFix bool `json:"isFix"`+ IsSyntaxFix bool `json:"isSyntaxFix"`+ IsOtherFix bool `json:"isOtherFix"`++ CreatedAt time.Time `json:"createdAt"`+ UpdatedAt time.Time `json:"updatedAt"`}type CurrentPlanFiles struct {@@ -286,6 +295,24 @@ type ModelPack struct {Namer ModelRoleConfig `json:"namer"`CommitMsg ModelRoleConfig `json:"commitMsg"`ExecStatus ModelRoleConfig `json:"execStatus"`++ // optional for backwards compatibility+ Verifier *ModelRoleConfig `json:"verifier"`+ AutoFix *ModelRoleConfig `json:"autoFix"`+}++func (m *ModelPack) GetVerifier() ModelRoleConfig {+ if m.Verifier == nil {+ return m.Builder+ }+ return *m.Verifier+}++func (m *ModelPack) GetAutoFix() ModelRoleConfig {+ if m.AutoFix == nil {+ return m.Builder+ }+ return *m.AutoFix}type ModelOverrides struct {diff --git a/app/shared/go.mod b/app/shared/go.modindex f5cee231..96e21420 100644--- a/app/shared/go.mod+++ b/app/shared/go.mod@@ -9,12 +9,12 @@ require (require (github.com/mattn/go-runewidth v0.0.15 // indirect- github.com/rivo/uniseg v0.2.0 // indirect+ github.com/rivo/uniseg v0.4.7 // indirect)require (github.com/dlclark/regexp2 v1.11.0 // indirectgithub.com/google/uuid v1.6.0 // indirectgithub.com/olekukonko/tablewriter v0.0.5- github.com/sashabaranov/go-openai v1.21.0+ github.com/sashabaranov/go-openai v1.24.0)diff --git a/app/shared/go.sum b/app/shared/go.sumindex fb68e516..5d05b54d 100644--- a/app/shared/go.sum+++ b/app/shared/go.sum@@ -20,10 +20,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbgithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=+github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=+github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=github.com/sashabaranov/go-openai v1.19.4 h1:GbaDiqvgYCabyqzuIbcEeT6/ZX1nVfur+++oTBfOgks=github.com/sashabaranov/go-openai v1.19.4/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=github.com/sashabaranov/go-openai v1.21.0 h1:isAf3zPSD3VLd0pC2/2Q6ZyRK7jzPAaz+X3rjsviaYQ=github.com/sashabaranov/go-openai v1.21.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=+github.com/sashabaranov/go-openai v1.24.0 h1:4H4Pg8Bl2RH/YSnU8DYumZbuHnnkfioor/dtNlB20D4=+github.com/sashabaranov/go-openai v1.24.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=diff --git a/app/shared/plan_result_replacements.go b/app/shared/plan_result_replacements.goindex 519cbf30..6a81f082 100644--- a/app/shared/plan_result_replacements.go+++ b/app/shared/plan_result_replacements.go@@ -42,6 +42,9 @@ func ApplyReplacements(content string, replacements []*Replacement, setFailed bolog.Println("Updated:")log.Println(updated)+ log.Println("All replacements:")+ log.Println(spew.Sdump(replacements))+return updated, i} else {diff --git a/app/shared/plan_settings.go b/app/shared/plan_settings.goindex 287c0e27..c72e3c60 100644--- a/app/shared/plan_settings.go+++ b/app/shared/plan_settings.go@@ -37,9 +37,11 @@ const (ModelRoleName ModelRole = "names"ModelRoleCommitMsg ModelRole = "commit-messages"ModelRoleExecStatus ModelRole = "auto-continue"+ ModelRoleVerifier ModelRole = "verifier"+ ModelRoleAutoFix ModelRole = "auto-fix")-var AllModelRoles = []ModelRole{ModelRolePlanner, ModelRolePlanSummary, ModelRoleBuilder, ModelRoleName, ModelRoleCommitMsg, ModelRoleExecStatus}+var AllModelRoles = []ModelRole{ModelRolePlanner, ModelRolePlanSummary, ModelRoleBuilder, ModelRoleName, ModelRoleCommitMsg, ModelRoleExecStatus, ModelRoleVerifier, ModelRoleAutoFix}var ModelRoleDescriptions = map[ModelRole]string{ModelRolePlanner: "replies to prompts and makes plans",ModelRolePlanSummary: "summarizes conversations exceeding max-convo-tokens",@@ -47,6 +49,8 @@ var ModelRoleDescriptions = map[ModelRole]string{ModelRoleName: "names plans",ModelRoleCommitMsg: "writes commit messages",ModelRoleExecStatus: "determines whether to auto-continue",+ ModelRoleVerifier: "verifies file correctness",+ ModelRoleAutoFix: "automatically fixes syntax errors",}var SettingDescriptions = map[string]string{"max-convo-tokens": "max conversation 🪙 before summarization",@@ -110,6 +114,7 @@ func (ps PlanSettings) GetRequiredEnvVars() map[string]bool {envVars[ms.Namer.BaseModelConfig.ApiKeyEnvVar] = trueenvVars[ms.CommitMsg.BaseModelConfig.ApiKeyEnvVar] = trueenvVars[ms.ExecStatus.BaseModelConfig.ApiKeyEnvVar] = true+ envVars[ms.Verifier.BaseModelConfig.ApiKeyEnvVar] = true// for backward compatibility with <= 0.8.4 server versionsif len(envVars) == 0 {diff --git a/app/shared/streamed_change.go b/app/shared/streamed_change.goindex fc9bfae4..de72c7ef 100644--- a/app/shared/streamed_change.go+++ b/app/shared/streamed_change.go@@ -12,6 +12,7 @@ type StreamedChangeSection struct {EndLine int `json:"endLine"`StartLineString string `json:"startLineString"`EndLineString string `json:"endLineString"`+ EntireFile bool `json:"entireFile"`}type StreamedChangeWithLineNums struct {@@ -40,6 +41,10 @@ func (streamedChange StreamedChangeWithLineNums) GetLines() (int, int, error) {var startLine, endLine intvar err error+ if streamedChange.Old.EntireFile {+ return 1, -1, nil+ }+if streamedChange.Old.StartLineString == "" {startLine = streamedChange.Old.StartLine} else {