Skip to content

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

add summary tag for anchor call, little bit of cleanup

Dane Schneiderd99e61af1d72
diff --git a/app/server/db/db.go b/app/server/db/db.go
index 0bde0f4c..235ef03e 100644
--- a/app/server/db/db.go
+++ b/app/server/db/db.go
@@ -100,7 +100,7 @@ func migrationsUp(dir string) error {
// Uncomment below (and update migration version) to reset migration state to a specific version after a failure
// if os.Getenv("GOENV") == "development" {
- // migrateVersion := 2024082900
+ // migrateVersion := 2024102200
// if err := m.Force(migrateVersion); err != nil {
// return fmt.Errorf("error forcing migration version: %v", err)
// }
diff --git a/app/server/model/plan/build_structured_edits.go b/app/server/model/plan/build_structured_edits.go
index 7f61a1ae..982b5c5f 100644
--- a/app/server/model/plan/build_structured_edits.go
+++ b/app/server/model/plan/build_structured_edits.go
@@ -135,14 +135,27 @@ func (fileState *activeBuildStreamFileState) buildStructuredEdits() {
log.Println("buildStructuredEdits - content:")
log.Println(content)
- anchorsXmlString, err := GetXMLTag(content, "SemanticAnchors")
+ anchorsXmlString, err := GetXMLTag(content, "PlandexSemanticAnchors")
if err != nil {
- log.Printf("buildStructuredEdits - error parsing SemanticAnchors xml: %v\n", err)
- fileState.structuredEditRetryOrError(fmt.Errorf("error parsing SemanticAnchors xml xml: %v", err))
+ log.Printf("buildStructuredEdits - error parsing PlandexSemanticAnchors xml: %v\n", err)
+ fileState.structuredEditRetryOrError(fmt.Errorf("error parsing PlandexSemanticAnchors xml xml: %v", err))
return
}
- var anchorsElement types.SemanticAnchors
+ summaryXmlString, err := GetXMLTag(content, "PlandexSummary")
+ if err != nil {
+ log.Printf("buildStructuredEdits - error parsing PlandexSummary xml: %v\n", err)
+ }
+
+ var summaryElement types.SummaryTag
+ if summaryXmlString != "" {
+ err = xml.Unmarshal([]byte(summaryXmlString), &summaryElement)
+ if err != nil {
+ log.Printf("buildStructuredEdits - error unmarshalling Summary xml: %v\n", err)
+ }
+ }
+
+ var anchorsElement types.SemanticAnchorsTag
err = xml.Unmarshal([]byte(anchorsXmlString), &anchorsElement)
if err != nil {
@@ -218,6 +231,12 @@ func (fileState *activeBuildStreamFileState) buildStructuredEdits() {
return
}
+ if summaryElement.Content != "" {
+ for _, replacement := range replacements {
+ replacement.Summary = strings.TrimSpace(summaryElement.Content)
+ }
+ }
+
res := db.PlanFileResult{
TypeVersion: 1,
OrgId: fileState.plan.OrgId,
diff --git a/app/server/model/prompts/build_update.go b/app/server/model/prompts/build_update.go
index 0d8202f7..95e9a51d 100644
--- a/app/server/model/prompts/build_update.go
+++ b/app/server/model/prompts/build_update.go
@@ -102,15 +102,21 @@ If a line in the *proposed updates* is a semantic anchor and there is a comment
First, output a single *brief* paragraph of general reasoning about the *proposed updates* and how they refer to the *original file*, focusing on the structure of each, which elements are changing, and how the changes map to the *original file*. Also make a brief note of any comments that are being modified or introduced in the *proposed updates* and whether/how they map to comments in the *original file*. Do NOT output a list of semantic anchors in this paragraph—save that for the next section.
-Next, output xml with this structure:
+Next, output a <PlandexSummary> element that gives a very brief, one-sentence summary of the changes being made. Example:
-<SemanticAnchors>
+<PlandexSummary>
+ Adds a 'log' parameter to the 'update' function and modifies the 'update' function to use it.
+</PlandexSummary>
+
+Last, output xml with this structure:
+
+<PlandexSemanticAnchors>
<Anchor
reasoning="'update function' signature with 'log' parameter added"
proposedLine="pdx-new-1"
originalLine="pdx-1"
/>
-</SemanticAnchors>
+</PlandexSemanticAnchors>
Explanation of 'Anchor' tag attributes:
@@ -120,7 +126,9 @@ Explanation of 'Anchor' tag attributes:
**originalLine**: The line number, prefixed by 'pdx-', in the *original file* that the anchor is referring to. MUST be a line that exists in the *original file* and MUST ALWAYS be prefixed by 'pdx-' (never pdx-new-).
-If there are no semantic anchors, output an empty <SemanticAnchors> element. Do NOT invent semantic anchors if there are none. It's common for there to be no semantic anchors in the *proposed updates*. In that case, output an empty <SemanticAnchors> element.
+If there are no semantic anchors, output an empty <PlandexSemanticAnchors> element. Do NOT invent semantic anchors if there are none. It's common for there to be no semantic anchors in the *proposed updates*. In that case, output an empty <PlandexSemanticAnchors> element.
+
+Every response must include a single <PlandexSummary> element and a single <PlandexSemanticAnchors> element.
Do NOT include any other text or comments in your output.
`
diff --git a/app/server/types/anchors.go b/app/server/types/anchors.go
index 35e329d7..e96004cb 100644
--- a/app/server/types/anchors.go
+++ b/app/server/types/anchors.go
@@ -2,13 +2,18 @@ package types
import "encoding/xml"
-type SemanticAnchors struct {
- XMLName xml.Name `xml:"SemanticAnchors"`
- Anchors []Anchor `xml:"Anchor"`
+type SemanticAnchorsTag struct {
+ XMLName xml.Name `xml:"PlandexSemanticAnchors"`
+ Anchors []AnchorTag `xml:"Anchor"`
}
-type Anchor struct {
+type AnchorTag struct {
Reasoning string `xml:"reasoning,attr"`
ProposedLine string `xml:"proposedLine,attr"`
OriginalLine string `xml:"originalLine,attr"`
}
+
+type SummaryTag struct {
+ XMLName xml.Name `xml:"PlandexSummary"`
+ Content string `xml:",chardata"`
+}