refactor: streamlined diff generation output and clarified hashline prompt rules

- Reduced default context lines from 4 to 2 in diff generation.
- Removed leading and trailing ellipsis placeholders from generated diff strings.
- Clarified the destructive nature of the replace operator and added examples in the prompt.
This commit is contained in:
can1357
2026-05-27 12:50:34 +02:00
parent 0e9137a703
commit 7a44d802de
2 changed files with 16 additions and 4 deletions
+5 -3
View File
@@ -58,7 +58,7 @@ function formatNumberedDiffLine(prefix: "+" | "-" | " ", lineNum: number, conten
* Generate a unified diff string with line numbers and context.
* Returns both the diff string and the first changed line number (in the new file).
*/
export function generateDiffString(oldContent: string, newContent: string, contextLines = 4): DiffResult {
export function generateDiffString(oldContent: string, newContent: string, contextLines = 2): DiffResult {
const parts = Diff.diffLines(oldContent, newContent);
const output: string[] = [];
@@ -119,8 +119,9 @@ export function generateDiffString(oldContent: string, newContent: string, conte
linesToShow = raw.slice(0, contextLimit);
}
// Leading-skip placeholder is omitted: the first emitted line's
// number already conveys that earlier lines were trimmed.
if (leadingSkip > 0) {
output.push(formatNumberedDiffLine(" ", oldLineNum, "..."));
oldLineNum += leadingSkip;
newLineNum += leadingSkip;
}
@@ -143,8 +144,9 @@ export function generateDiffString(oldContent: string, newContent: string, conte
}
}
// Trailing-skip placeholder is omitted for the same reason: the
// final emitted line's number tells the reader the file continues.
if (trailingSkip > 0) {
output.push(formatNumberedDiffLine(" ", oldLineNum, "..."));
oldLineNum += trailingSkip;
newLineNum += trailingSkip;
}