fix(hashline-edit): integrate continuation/merge helpers into expand logic and strengthen tool description
- maybeExpandSingleLineMerge now uses stripTrailingContinuationTokens and stripMergeOperatorChars as fallback matching strategies - Add 'refs interpreted against last read' atomicity clause to tool description - Add 'output tool calls only; no prose' rule to tool description
This commit is contained in:
@@ -77,7 +77,21 @@ export function maybeExpandSingleLineMerge(
|
|||||||
let offset = 0
|
let offset = 0
|
||||||
let orderedMatch = true
|
let orderedMatch = true
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
const idx = merged.indexOf(part, offset)
|
let idx = merged.indexOf(part, offset)
|
||||||
|
if (idx === -1) {
|
||||||
|
const stripped = stripTrailingContinuationTokens(part)
|
||||||
|
if (stripped !== part) {
|
||||||
|
idx = merged.indexOf(stripped, offset)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (idx === -1) {
|
||||||
|
const mergeStripped = stripMergeOperatorChars(merged.slice(offset))
|
||||||
|
const partStripped = stripMergeOperatorChars(part)
|
||||||
|
const fuzzyIdx = mergeStripped.indexOf(partStripped)
|
||||||
|
if (fuzzyIdx !== -1) {
|
||||||
|
idx = offset + fuzzyIdx
|
||||||
|
}
|
||||||
|
}
|
||||||
if (idx === -1) {
|
if (idx === -1) {
|
||||||
orderedMatch = false
|
orderedMatch = false
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ VALIDATION:
|
|||||||
Payload shape: { "filePath": string, "edits": [...], "delete"?: boolean, "rename"?: string }
|
Payload shape: { "filePath": string, "edits": [...], "delete"?: boolean, "rename"?: string }
|
||||||
Each edit must be one of: set_line, replace_lines, insert_after, insert_before, insert_between, replace, append, prepend
|
Each edit must be one of: set_line, replace_lines, insert_after, insert_before, insert_between, replace, append, prepend
|
||||||
text/new_text must contain plain replacement text only (no LINE#ID prefixes, no diff + markers)
|
text/new_text must contain plain replacement text only (no LINE#ID prefixes, no diff + markers)
|
||||||
CRITICAL: all operations validate against the same pre-edit file snapshot and apply bottom-up.
|
CRITICAL: all operations validate against the same pre-edit file snapshot and apply bottom-up. Refs/tags are interpreted against the last-read version of the file.
|
||||||
|
|
||||||
LINE#ID FORMAT (CRITICAL):
|
LINE#ID FORMAT (CRITICAL):
|
||||||
Each line reference must be in "LINE#ID" format where:
|
Each line reference must be in "LINE#ID" format where:
|
||||||
@@ -48,6 +48,7 @@ RULES (CRITICAL):
|
|||||||
5. Touch only requested code: avoid incidental edits.
|
5. Touch only requested code: avoid incidental edits.
|
||||||
6. Use exact current tokens: NEVER rewrite approximately.
|
6. Use exact current tokens: NEVER rewrite approximately.
|
||||||
7. For swaps/moves: prefer one range operation over multiple single-line operations.
|
7. For swaps/moves: prefer one range operation over multiple single-line operations.
|
||||||
|
8. Output tool calls only; no prose or commentary between them.
|
||||||
|
|
||||||
TAG CHOICE (ALWAYS):
|
TAG CHOICE (ALWAYS):
|
||||||
- Copy tags exactly from read output or >>> mismatch output.
|
- Copy tags exactly from read output or >>> mismatch output.
|
||||||
|
|||||||
Reference in New Issue
Block a user