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
build model: write out full 'new' key in replacements. slower but far more reliable. also escaping of triple bacticks in context
Dane Schneider931d1738e9bc
diff --git a/README.md b/README.mdindex 8450033a..c04e45ed 100644--- a/README.md+++ b/README.md@@ -25,10 +25,10 @@ Grab the appropriate binary for your platform from the latest [release](https://### Build from source```bash-git clone plandex-ai/plandex.git+git clone https://github.com/plandex-ai/plandex.gitcd plandex/app/cli-go build -o plandex-cp plandex /usr/local/bin # adapt as needed for your system+go build -ldflags "-X plandex/version.Version=$(cat version.txt)"+mv plandex /usr/local/bin # adapt as needed for your system```### Windowsdiff --git a/app/cli/changes_tui/main_viewport.go b/app/cli/changes_tui/main_viewport.goindex ec5ba798..96e03952 100644--- a/app/cli/changes_tui/main_viewport.go+++ b/app/cli/changes_tui/main_viewport.go@@ -101,7 +101,7 @@ func (m changesUIModel) renderMainViewHeader() string {header = fmt.Sprintf(" %s New file: %s", icon, m.selectionInfo.currentPath)} else {- header = " π " + m.selectionInfo.currentRep.StreamedChange.ShortSummary+ header = " π " + m.selectionInfo.currentRep.StreamedChange.Summary}return style.Render(header)diff --git a/app/cli/changes_tui/model.go b/app/cli/changes_tui/model.goindex 61021def..ec1fe489 100644--- a/app/cli/changes_tui/model.go+++ b/app/cli/changes_tui/model.go@@ -1,12 +1,6 @@package changes_tuiimport (- "fmt"- "log"- "plandex/api"- "plandex/lib"- "plandex/term"-"github.com/charmbracelet/bubbles/help"bubbleKey "github.com/charmbracelet/bubbles/key""github.com/charmbracelet/bubbles/viewport"@@ -55,14 +49,7 @@ func (m changesUIModel) Init() tea.Cmd {return nil}-func initialModel() *changesUIModel {- currentPlan, apiErr := api.Client.GetCurrentPlanState(lib.CurrentPlanId, lib.CurrentBranch)- if apiErr != nil {- err := fmt.Errorf("error getting current plan state: %v", apiErr.Msg)- log.Println(err)- term.OutputErrorAndExit(err.Error())- }-+func initialModel(currentPlan *shared.CurrentPlanState) *changesUIModel {initialState := changesUIModel{currentPlan: currentPlan,selectedFileIndex: 0,diff --git a/app/cli/changes_tui/run.go b/app/cli/changes_tui/run.goindex afa61a19..4c2bbc5a 100644--- a/app/cli/changes_tui/run.go+++ b/app/cli/changes_tui/run.go@@ -6,10 +6,11 @@ import ("plandex/lib"tea "github.com/charmbracelet/bubbletea"+ "github.com/plandex/plandex/shared")-func StartChangesUI() error {- initial := initialModel()+func StartChangesUI(currentPlan *shared.CurrentPlanState) error {+ initial := initialModel(currentPlan)if len(initial.currentPlan.PlanResult.SortedPaths) == 0 {fmt.Println("π€·ββοΈ No changes pending")diff --git a/app/cli/cmd/changes.go b/app/cli/cmd/changes.goindex ba94b899..1415a288 100644--- a/app/cli/cmd/changes.go+++ b/app/cli/cmd/changes.go@@ -2,6 +2,7 @@ package cmdimport ("fmt"+ "log""plandex/api""plandex/auth""plandex/changes_tui"@@ -9,6 +10,7 @@ import ("plandex/plan_exec""plandex/term"+ "github.com/davecgh/go-spew/spew""github.com/plandex/plandex/shared""github.com/spf13/cobra")@@ -37,7 +39,7 @@ func changes(cmd *cobra.Command, args []string) {term.OutputErrorAndExit("Error getting current plan state: %s", apiErr.Msg)}- if currentPlanState.HasPendingBuilds() {+ for currentPlanState.HasPendingBuilds() {plansRunningRes, apiErr := api.Client.ListPlansRunning([]string{lib.CurrentProjectId}, false)if apiErr != nil {@@ -91,12 +93,22 @@ func changes(cmd *cobra.Command, args []string) {term.PrintCmds("", "build", "log", "rewind")return}++ term.ResumeSpinner()+ currentPlanState, apiErr = api.Client.GetCurrentPlanState(lib.CurrentPlanId, lib.CurrentBranch)++ if apiErr != nil {+ term.StopSpinner()+ term.OutputErrorAndExit("Error getting current plan state: %s", apiErr.Msg)+ }}}term.StopSpinner()- err := changes_tui.StartChangesUI()+ log.Println(spew.Sdump(currentPlanState.PlanResult.ReplacementsByPath["app/cli/main.go"]))++ err := changes_tui.StartChangesUI(currentPlanState)if err != nil {term.OutputErrorAndExit("Error starting changes UI: %v\n", err)diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.goindex 3e59df33..0d1748eb 100644--- a/app/cli/lib/apply.go+++ b/app/cli/lib/apply.go@@ -8,6 +8,7 @@ import ("plandex/api""plandex/fs""plandex/term"+ "strings")func MustApplyPlan(planId, branch string, autoConfirm bool) {@@ -216,6 +217,8 @@ func MustApplyPlan(planId, branch string, autoConfirm bool) {return}+ content = strings.ReplaceAll(content, "\\`\\`\\`", "```")+// Write the fileerr = os.WriteFile(dstPath, []byte(content), 0644)if err != nil {diff --git a/app/cli/stream_tui/run.go b/app/cli/stream_tui/run.goindex c832213a..f9bb9cd3 100644--- a/app/cli/stream_tui/run.go+++ b/app/cli/stream_tui/run.go@@ -118,6 +118,6 @@ func Send(msg shared.StreamMessage) {}mu.Lock()defer mu.Unlock()- log.Printf("sending stream message to UI: %s\n", msg.Type)+ // log.Printf("sending stream message to UI: %s\n", msg.Type)ui.Send(msg)}diff --git a/app/cli/term/help.go b/app/cli/term/help.goindex 3b1bc3a9..af96840a 100644--- a/app/cli/term/help.go+++ b/app/cli/term/help.go@@ -15,7 +15,7 @@ var CmdDesc = map[string][2]string{"cd": {"", "set current plan by name or index"},"load": {"l", "load files, dirs, urls, notes or piped data into context"},"tell": {"t", "describe a task, ask a question, or chat"},- "changes": {"ch", "show plan changes"},+ "changes": {"ch", "review plan changes"},// "diffs": {"d", "show diffs between plan and project files"},// "preview": {"pv", "preview the plan in a branch"},"apply": {"ap", "apply plan changes to project files"},diff --git a/app/cli/version/version.go b/app/cli/version/version.goindex f49f5590..d98c0bbf 100644--- a/app/cli/version/version.go+++ b/app/cli/version/version.go@@ -1,33 +1,4 @@package version-import (- "bufio"- "fmt"- "os"- "strings"-)-// Version will be set at build time using -ldflags-var Version = "source"-var BuiltFromSource = false--func init() {- if Version == "source" {- BuiltFromSource = true- readVersionFromFile()- }-}--func readVersionFromFile() {- file, err := os.Open("../version.txt")- if err != nil {- fmt.Println("Unable to read version from file, defaulting to:", Version)- return- }- defer file.Close()-- scanner := bufio.NewScanner(file)- if scanner.Scan() {- Version = strings.TrimSpace(scanner.Text())- }-}+var Version = "development"diff --git a/app/server/db/context_helpers.go b/app/server/db/context_helpers.goindex e6791d98..50edd6f5 100644--- a/app/server/db/context_helpers.go+++ b/app/server/db/context_helpers.go@@ -141,10 +141,12 @@ func StoreContext(context *Context) error {metaPath := filepath.Join(contextDir, metaFilename)originalBody := context.Body+ originalBody = strings.ReplaceAll(originalBody, "\\`\\`\\`", "\\\\`\\\\`\\\\`")+ originalBody = strings.ReplaceAll(originalBody, "```", "\\`\\`\\`")bodyFilename := context.Id + ".body"bodyPath := filepath.Join(contextDir, bodyFilename)- body := []byte(context.Body)+ body := []byte(originalBody)context.Body = ""// Convert the ModelContextPart to JSONdiff --git a/app/server/model/plan/build_result.go b/app/server/model/plan/build_result.goindex 984622b9..47d60a9e 100644--- a/app/server/model/plan/build_result.go+++ b/app/server/model/plan/build_result.go@@ -1,6 +1,7 @@package planimport (+ "log""plandex-server/db""sort""strings"@@ -27,41 +28,36 @@ func getPlanResult(params planResultParams) (*db.PlanFileResult, bool) {filePath := params.filePathcurrentState := params.currentStatestreamedChanges := params.streamedChanges- updated := params.currentStatefileContent := params.fileContentcurrentStateLines := strings.Split(currentState, "\n")- fileContentLines := strings.Split(fileContent, "\n")+ // fileContentLines := strings.Split(fileContent, "\n")++ log.Printf("\n\ngetPlanResult - path: %s\n", filePath)+ log.Println("getPlanResult - currentState:")+ log.Println(currentState)+ log.Println("getPlanResult - currentStateLines:")+ log.Println(currentStateLines)+ log.Println("getPlanResult - fileContent:")+ log.Println(fileContent)+ log.Print("\n\n")var replacements []*shared.Replacementfor _, streamedChange := range streamedChanges {var old string- var new string-- if streamedChange.New.StartLine == streamedChange.New.EndLine {- new = fileContentLines[streamedChange.New.StartLine-1]- } else {- new = strings.Join(fileContentLines[streamedChange.New.StartLine-1:streamedChange.New.EndLine], "\n")- }- switch streamedChange.ChangeType {+ new := streamedChange.New- case shared.StreamedChangeTypeReplace:- if streamedChange.Old.StartLine == streamedChange.Old.EndLine {- old = currentStateLines[streamedChange.Old.StartLine-1]- } else {- old = strings.Join(currentStateLines[streamedChange.Old.StartLine-1:streamedChange.Old.EndLine], "\n")- }-- case shared.StreamedChangeTypeAppend:- old = currentStateLines[streamedChange.Old.EndLine-1]- new = old + "\n" + new-- case shared.StreamedChangeTypePrepend:+ if streamedChange.Old.StartLine == streamedChange.Old.EndLine {old = currentStateLines[streamedChange.Old.StartLine-1]- new = new + "\n" + old+ } else {+ old = strings.Join(currentStateLines[streamedChange.Old.StartLine-1:streamedChange.Old.EndLine], "\n")}+ log.Printf("getPlanResult - streamedChange.Old.StartLine: %d\n", streamedChange.Old.StartLine)+ log.Printf("getPlanResult - streamedChange.Old.EndLine: %d\n", streamedChange.Old.EndLine)+ log.Printf("getPlanResult - old: %s\n", old)+replacement := &shared.Replacement{Old: old,New: new,@@ -72,8 +68,8 @@ func getPlanResult(params planResultParams) (*db.PlanFileResult, bool) {}sort.Slice(replacements, func(i, j int) bool {- iIdx := strings.Index(updated, replacements[i].Old)- jIdx := strings.Index(updated, replacements[j].Old)+ iIdx := strings.Index(currentState, replacements[i].Old)+ jIdx := strings.Index(currentState, replacements[j].Old)return iIdx < jIdx})diff --git a/app/server/model/plan/build_stream.go b/app/server/model/plan/build_stream.goindex fdcbfc9a..7b2e3aaa 100644--- a/app/server/model/plan/build_stream.go+++ b/app/server/model/plan/build_stream.go@@ -115,7 +115,7 @@ func (fileState *activeBuildStreamFileState) listenStream(stream *openai.ChatComerr = json.Unmarshal([]byte(fileState.buffer), &streamed)if err == nil {log.Printf("File %s: Parsed streamed replacements\n", filePath)- // spew.Dump(streamed)+ spew.Dump(streamed)planFileResult, allSucceeded := getPlanResult(planResultParams{diff --git a/app/server/model/prompts/build.go b/app/server/model/prompts/build.goindex a468e416..f69b3f62 100644--- a/app/server/model/prompts/build.go+++ b/app/server/model/prompts/build.go@@ -45,135 +45,55 @@ func getBuildCurrentStatePrompt(filePath, currentState string) string {}var listChangesPrompt = `- You are an AI that analyzes a code file and an AI-generated plan to update the code file and produces a list of changes.-- There are four types of changes:-- 1 - Replace: replace a section of code in the original file with a section of code from the proposed updates.-- 2 - Append: add a section of code from the proposed update immediately after a section of code in the original file.-- 3 - Prepend: add a section of code from the proposed updates immediately before a section of code in the original file.-- [YOUR INSTRUCTIONS]- Call the 'listChanges' function with a valid JSON array of changes. Each replacement is an object with properties: 'shortSummary', 'changeSections', 'changeType', 'old', and 'new'.-- The 'shortSummary' property is a brief summary of the change.-- 'shortSummary' examples:- - 'Update loop that aggregates the results to iterate 10 times instead of 5 and log the value of someVar.'- - 'Change the value of someVar to 10.'- - 'Update the Org model to include StripeCustomerId and StripeSubscriptionId fields.'- - 'Add function ExecQuery to execute a query.'-- The 'changeSections' property is a description of:- - The type of change (replace, append, prepend).- - If the type of change is 'replace', what section of code from the original file will be replaced.- - If the type of change is 'append', what section of code from the original file will have new code appended immediately after it.- - If the type of change is 'prepend', what section of code from the original file will have new code prepended immediately before it.- - What section of code from the proposed updates will be added.-- Refer to sections of code using line numbers, how the section begins, and how the section ends.-- If the change type is 'replace', it must be extremely clear which line(s) of code from the original file will be replaced with which line(s) of code from the proposed updates.-- If the change type is 'append' or 'prepend', it must be extremely clear which line(s) of code from the original file will have which line(s) of code from the proposed updates appended or prepended to them.-- 'changeSections' examples:- ---- Type: replace-- The section to be replaced begins on line 10 of the original file with 'for i := 0; i < 10; i++ {...' and ends on line 15 of the original file with '}'-- The new code begins on line 17 of the proposed updates with 'for i := 0; i < 10; i++ {...' and ends on line 25 of the proposed updates with '}'+ You are an AI that analyzes a code file and an AI-generated plan to update the code file and produces a list of changes.++ [YOUR INSTRUCTIONS]+ Call the 'listChanges' function with a valid JSON object that includes the 'changes' keys.++ 'changes': An array of changes. Each change is an object with properties: 'summary', 'section', 'old', and 'new'.++ The 'summary' property is a brief summary of the change.++ 'summary' examples:+ - 'Update loop that aggregates the results to iterate 10 times instead of 5 and log the value of someVar.'+ - 'Change the value of someVar to 10.'+ - 'Update the Org model to include StripeCustomerId and StripeSubscriptionId fields.'+ - 'Add function ExecQuery to execute a query.'++ The 'section' property is a description of what section of code from the original file will be replaced.++ Refer to sections of code using line numbers, how the section begins, and how the section ends. It must be extremely clear which line(s) of code from the original file will be replaced.++ 'section' examples:+ ---+ Begins line 10 of the original file with 'for i := 0; i < 10; i++ {...'+ Ends on line 15 of the original file with '}'---- ---- Type: append-- The section that should have code appended to it begins on line 10 of the original file with 'func GetResults() {...' and ends on line 15 of the original file with '}'-- The new code begins on line 10 of the proposed updates with 'func ExecQuery() {...' and ends on line 15 of the proposed updates with '}'- ----- ---- Type: prepend-- The section that should have code prepended to it begins on line 10 of the original file with 'func GetResults() {...' and ends on line 15 of the original file with '}'-- The new code begins on line 10 of the proposed updates with 'func ExecQuery() {...' and ends on line 15 of the proposed updates with '}'- ----- If the change type is 'replace' and only a single line needs to be replaced, you can reference a single line from the original file and the proposed updates rather than a range of lines like this:- ---- Type: replace-- The section to be replaced is on line 10 of the original file with 'someVar = 5'-- The new code is on line 12 of the proposed updates with 'someVar = 10'- ----- To append to the end of the file, you can reference a single line, the last line of the original file, for the new code to be appended to like this:- ---- Type: append-- Line 15 of the original file with '}'-- The new code begins on line 10 of the proposed updates with 'func ExecQuery() {...' and ends on line 15 of the proposed updates with '}'- ---- To prepend to the beginning of the file, you can reference a single line, the first line of the original file, for the new code to be prepended to like this:-- ---- Type: prepend-- Line 1 of the original file with 'package main'-- The new code begins on line 10 of the proposed updates with 'func ExecQuery() {...' and ends on line 15 of the proposed updates with '}'- ----- The 'changeType' property is an integer that represents the type of change. The value of 'changeType' corresponds to the type of change as follows:- - 1: replace- - 2: append- - 3: prepend- You must include the 'changeType' property in each change object and it must be one of the above values (1, 2, or 3).-- The 'old' property is an object with two properties: 'startLine' and 'endLine'.-- If the changeType is 'replace': 'startLine' is the line number where the section to be replaced begins in the original file. 'endLine' is the line number where the section to be replaced ends in the original file. For a single line replacement, 'startLine' and 'endLine' will be the same.-- If the changeType is 'append', 'startLine' and 'endLine' are both the same: the line number where the section to have code appended to it ends in the original file.-- If the changeType is 'prepend', 'startLine' and 'endLine' are both the same: the line number where the section to have code prepended to it begins in the original file.-- The 'new' property is also an object with two properties: 'startLine' and 'endLine'.-- 'startLine' is the line number where the new section begins in the code block included with the proposed updates. 'endLine' is the line number where the new section ends in the code block included with the proposed updates. For a single line replacement, 'startLine' and 'endLine' will be the same.-- Example function call with all keys:- ---- listChanges([{- shortSummary: "Insert function ExecQuery after GetResults function.",- changeSections: "Type: replace\nThe section to be replaced is on line 5 of the original file with '\\n'\n\nThe new code starts on line 3 of the proposed updates with 'func ExecQuery()...' and ends on line 10 of the proposed updates with '}'",- changeType: 1,- old: {- startLine: 5,- endLine: 5,- },- new: {- startLine: 3,- endLine: 10,- }- }])- ---+ The 'old' property is an object with two properties: 'startLine' and 'endLine'.- Very important notes:+ 'startLine' is the line number where the section to be replaced begins in the original file. 'endLine' is the line number where the section to be replaced ends in the original file. For a single line replacement, 'startLine' and 'endLine' will be the same.- - 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.+ The 'new' property is a string that represents the new code that will replace the old code. The new code must be valid and consistent with the intention of the plan. If the the proposed update is to remove code, the 'new' property should be an empty string.++ If the proposed update 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 any other reference to the original code, you *MUST* ensure that the comment making the reference is *NOT* included in the 'new' property. If the reference comment is included in the 'new' property the resulting code obviously won't work, so NEVER include the reference comment in the 'new' property. Instead include the actual code that the reference is pointing to so that the change results in the exact code that is intended.- - If the code block with the proposed updates includes references to the original code file, like this comment "// rest of the function here..." or "# rest of the code here" or "/* rest of the functionality goes here */", **do not include these references** when constructing the changes. In these cases, only replace the code that is actually changing and leave out the references to the original code file. The code should be ready for use and should not contain any artifacts of the planning process.+ Example function call with all keys:+ ---+ listChanges([{+ summary: "Insert function ExecQuery after GetResults function.",+ section' "Begins line 10 of the original file with 'for i := 0; i < 10; i++ {...'\nEnds on line 15 of the original file with '}'",+ old: {+ startLine: 5,+ endLine: 5,+ },+ new: "execQuery()\nreturn",+ }])+ ---- [END YOUR INSTRUCTIONS]+ 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.++ [END YOUR INSTRUCTIONS]`var ListReplacementsFn = openai.FunctionDefinition{Name: "listChanges",@@ -185,15 +105,12 @@ var ListReplacementsFn = openai.FunctionDefinition{Items: &jsonschema.Definition{Type: jsonschema.Object,Properties: map[string]jsonschema.Definition{- "shortSummary": {+ "summary": {Type: jsonschema.String,},- "changeSections": {+ "section": {Type: jsonschema.String,},- "changeType": {- Type: jsonschema.Integer,- },"old": {Type: jsonschema.Object,Properties: map[string]jsonschema.Definition{@@ -207,19 +124,10 @@ var ListReplacementsFn = openai.FunctionDefinition{Required: []string{"startLine", "endLine"},},"new": {- Type: jsonschema.Object,- Properties: map[string]jsonschema.Definition{- "startLine": {- Type: jsonschema.Integer,- },- "endLine": {- Type: jsonschema.Integer,- },- },- Required: []string{"startLine", "endLine"},+ Type: jsonschema.String,},},- Required: []string{"shortSummary", "changeSections", "changeType", "old", "new"},+ Required: []string{"summary", "section", "old", "new"},},},},diff --git a/app/server/model/prompts/create.go b/app/server/model/prompts/create.goindex 8b33017a..d5ec1bbc 100644--- a/app/server/model/prompts/create.go+++ b/app/server/model/prompts/create.go@@ -23,7 +23,7 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context- Ask the user for more information or context and stop there.2. Decide whether this task is small enough to be completed in a single response.- a. If so, write out the code to complete the task. Include only lines that will change and lines that are necessary to know where the changes should be applied. Precede the code block with the file path like this '- file_path:'--for example:+ a. If so, describe the task to be done and what your approach will be, then write out the code to complete the task. Include only lines that will change and lines that are necessary to know where the changes should be applied. Precede the code block with the file path like this '- file_path:'--for example:- src/main.rs:- lib/term.go:- main.py:@@ -42,9 +42,11 @@ const SysCreate = Identity + ` A plan is a set of files with an attached contextEvery file you reference in a plan should either exist in the context directly or be a new file that will be created in the same base directory as a file in the context. For example, if there is a file in context at path 'lib/term.go', you can create a new file at path 'lib/utils_test.go' but *not* at path 'src/lib/term.go'. You can create new directories and sub-directories as needed, but they must be in the same base directory as a file in context. Don't ask the user to create new files or directories--you must do that yourself.- **You must not include anything except code in labelled file blocks for code files.** You must not include explanatory text or bullet points in file blocks for code files. Only code. Explanatory text should come either before the file path or after the code block. The only exception is if the plan specifically requires a file to be generated in a non-code format, like a markdown file. In that case, you can include the non-code content in the file block. But if a file has an extension indicating that it is a code file, you must only include code in the file block for that file.+ **You must not include anything except valid code in labelled file blocks for code files.** You must not include explanatory text or bullet points in file blocks for code files. Only code. Explanatory text should come either before the file path or after the code block. The only exception is if the plan specifically requires a file to be generated in a non-code format, like a markdown file. In that case, you can include the non-code content in the file block. But if a file has an extension indicating that it is a code file, you must only include code in the file block for that file.For code in markdown blocks, always include the language name after the opening triple backticks.++ If there are triple backticks within any file in context, they will be escaped with backslashes like this '` + "\\`\\`\\`" + `'. If you are outputting triple backticks in a code block, you MUST escape them in exactly the same way.Don't include unnecessary comments in code. Lean towards no comments as much as you can. If you must include a comment to make the code understandable, be sure it is concise. Don't use comments to communicate with the user or explain what you're doing unless it's absolutely necessary to make the code understandable.@@ -62,15 +64,21 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context**You MUST NEVER give up and say the task is too large or complex for you to do.** Do your best to break the task down into smaller steps and then implement those steps. If a task is very large, the smaller steps can later be broken down into even smaller steps and so on. You can use as many responses as needed to complete a large task. Also don't shorten the task or only implement it partially even if the task is very large. Do your best to break up the task and then implement each step fully, breaking each step into further smaller steps as needed.- ## Use open source libraries+ ## Working on subtasks++ If you working on a subtask, first describe the subtask and what your approach will be, then implement it with code blocks. Apart from when you are following instruction 2b above to create the intial subtasks, you must not list, describe, or explain the subtask you are working on without an accompanying implementation in one or more code blocks. Describing what needs to be done to complete a subtask *DOES NOT* count as completing the subtask. It must be fully implemented with code blocks.++ If you are working on a subtask and it is too large to be implemented in a single response, it should be further broken down into smaller steps. Each smaller step should then be treated like a subtask. The smaller step should be described, your approach should be described, and then you should fully implement the step with one or more code blocks.++ ## Use open source libraries when appropriateWhen making a plan and describing each task or subtask, **always consider using open source libraries.** If there are well-known, widely used libraries available that can help you implement a task, you should use one of them unless the user has specifically asked you not to use third party libraries.Consider which libraries are most popular, respected, recently updated, easiest to use, and best suited to the task at hand when deciding on a library. Also prefer libraries that have a permissive license.- Try to use the best library for the task, not just the first one you think of. If you are deciding between multiple libraries, you can write a couple lines about each potential library and its pros and cons before deciding which one to use.+ Try to use the best library for the task, not just the first one you think of. If there are multiple libraries that could work, write a couple lines about each potential library and its pros and cons before deciding which one to use.- Don't ask the user which library to use--make the decision yourself. Don't recommend a library that is very old or unmaintained. Don't recommend a library that isn't widely used or respected. Don't recommend a library with a non-permissive license. Don't recommend a library that is difficult to use, has a steep learning curve, or is hard to understand unless it is the only library that can do the job. Strive for simplicity and ease of use when choosing a libraries.+ Don't ask the user which library to use--make the decision yourself. Don't use a library that is very old or unmaintained. Don't use a library that isn't widely used or respected. Don't use a library with a non-permissive license. Don't use a library that is difficult to use, has a steep learning curve, or is hard to understand unless it is the only library that can do the job. Strive for simplicity and ease of use when choosing a libraries.If the user asks you to use a specific library, then use that library.@@ -96,17 +104,15 @@ const SysCreate = Identity + ` A plan is a set of files with an attached contextYou *must never respond with just a single paragraph.* Every response should include at least a few paragraphs that try to move a plan forward. You *especially must never* reply with just a single paragraph that begins with "Next," or "The plan cannot be continued.". You must also **never reply with just a single paragraph that contains only "All tasks have been completed."**.- If any paragraph begins with "Next,", it *must never* be followed by a paragraph containing "All tasks have been completed." or "The plan cannot be continued." *Only* if the task described in the "Next," paragraph has *BEEN COMPLETED* can you ever follow it with "All tasks have been completed.".-- If you working on a subtask, it should be implemented with code blocks unless it is impossible to do so. Apart from when you are following instruction 2b above to create the intial subtasks, you must not list, describe, or explain the subtask you are working on without an accompanying implementation in one or more code blocks.-- If you are working on a subtask and it is too large to be implemented in a single response, it should be broken down into smaller steps. Each step should then be implemented with code blocks.+ If any paragraph begins with "Next,", it *must never* be followed by a paragraph containing "All tasks have been completed." or "The plan cannot be continued." *Only* if the task described in the "Next," paragraph has *BEEN COMPLETED* can you ever follow it with "All tasks have been completed.".++ Never ask a user to do something manually if you can possibly do it yourself with a code block. Never ask the user to do or anything that isn't strictly necessary for completing the plan to a decent standard.- Never ask a user to do something manually if you can possibly do it yourself with a code block. Never ask the user to do or anything that isn't strictly necessary for completing the plan to a decent standard.+ Don't implement a task or subtask that has already been completed in a previous response or is already included in the current state of a file. Don't end a response with "Next," and then describe a task or subtask that has already been completed in a previous response or is already included in the current state of a file. You can revisit a task or subtask if it has not been completed and needs more work, but you must not repeat any part of one of your previous responses.## Continuing the plan- If the last paragraph (p) of your previous response in the conversation began with "Next," and you are continuing the plan:+ If the last paragraph of your previous response in the conversation began with "Next," and you are continuing the plan:- Continue from where your previous response left off.- **Do not repeat any part of your previous response**- **Do not begin your response with "Next,"**@@ -118,7 +124,7 @@ const SysCreate = Identity + ` A plan is a set of files with an attached contextBe 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.- ## Responding to questions+ ## Responding to user questionsIf a plan is in progress and the user asks you a question, don't respond by continuing with the plan unless that is the clear intention of the question. Instead, respond in chat form and answer the question, then stop there.` +diff --git a/app/server/types/model.go b/app/server/types/model.goindex 4b0b6435..7a1771ca 100644--- a/app/server/types/model.go+++ b/app/server/types/model.go@@ -9,5 +9,6 @@ type StreamedFile struct {}type StreamedChanges struct {- Changes []*shared.StreamedChange `json:"changes"`+ References string `json:"references"`+ Changes []*shared.StreamedChange `json:"changes"`}diff --git a/app/server/types/reply.go b/app/server/types/reply.goindex c538e8c1..00ffd870 100644--- a/app/server/types/reply.go+++ b/app/server/types/reply.go@@ -5,12 +5,13 @@ import ()type parserRes struct {- CurrentFilePath string- Files []string- FileContents []string- FileDescriptions []string- NumTokensByFile map[string]int- TotalTokens int+ CurrentFilePath string+ Files []string+ FileContents []string+ FileDescriptions []string+ RepliesBeforeFiles []string+ NumTokensByFile map[string]int+ TotalTokens int}type ReplyParser struct {diff --git a/app/shared/streamed_change.go b/app/shared/streamed_change.goindex 4353664d..2954771c 100644--- a/app/shared/streamed_change.go+++ b/app/shared/streamed_change.go@@ -5,18 +5,18 @@ type StreamedChangeSection struct {EndLine int `json:"endLine"`}-type StreamedChangeType int+// type StreamedChangeType int-const (- StreamedChangeTypeReplace StreamedChangeType = 1- StreamedChangeTypeAppend StreamedChangeType = 2- StreamedChangeTypePrepend StreamedChangeType = 3-)+// const (+// StreamedChangeTypeSimple StreamedChangeType = 1+// StreamedChangeTypeComplex StreamedChangeType = 2+// )type StreamedChange struct {- ShortSummary string `json:"shortSummary"`- ChangeSections string `json:"changeSections"`- ChangeType StreamedChangeType `json:"changeType"`- Old StreamedChangeSection `json:"old"`- New StreamedChangeSection `json:"new"`+ Summary string `json:"summary"`+ Section string `json:"section"`+ // ChangeType StreamedChangeType `json:"changeType"`+ Old StreamedChangeSection `json:"old"`+ // New StreamedChangeSection `json:"new"`+ New string `json:"new"`}