refactor(hashline): redesigned patch syntax from sigil-ops to anchor+payload model

- Replaced `LINE↑`/`LINE↓`/`A-B:` op sigils with unified `A-B:` anchor + `|`/`↑`/`↓` payload sigils.
- Added `mode: "replacement"` tag to insert edits so the applier distinguishes replace-bucket from insert-bucket lines.
- Removed lenient fallbacks (implicit continuation, inline payload acceptance, escaped delimiter stripping).
- Updated grammar, prompt, tokenizer, parser, applier, and messages to match the new format.
This commit is contained in:
can1357
2026-05-27 14:00:34 +02:00
parent f0c7df60d5
commit 8a0329026c
15 changed files with 625 additions and 737 deletions
+4 -4
View File
@@ -236,9 +236,9 @@ describe("computeHashlineDiff", () => {
const line = "unchanged content";
await Bun.write(sourcePath, `${line}\n`);
// `1:` with the same line as payload is a true no-op: the edit
// `1:` with the same line in the replace bucket is a true no-op: the edit
// fires through computeHashlineDiff but produces identical content.
const input = `${sourcePath}#${computeFileHash(`${line}\n`)}\n1:${line}\n`;
const input = `${sourcePath}#${computeFileHash(`${line}\n`)}\n1:\n|${line}\n`;
const result = await computeHashlineDiff({ input }, tempDir);
expect("error" in result).toBe(true);
if ("error" in result) {
@@ -250,14 +250,14 @@ describe("computeHashlineDiff", () => {
const sourcePath = path.join(tempDir, "source.txt");
await Bun.write(sourcePath, "first\n");
const result = await computeHashlineDiff({ input: `${sourcePath}\nEOF↓\nsecond` }, tempDir);
const result = await computeHashlineDiff({ input: `${sourcePath}\nEOF:\n↓second` }, tempDir);
expect("diff" in result).toBe(true);
if ("diff" in result) {
expect(result.diff).toContain("second");
}
});
test("returns a handled error when the source path is a local URL", async () => {
const result = await computeHashlineDiff({ input: "¶local://PLAN.md\nEOF↓\n" }, tempDir);
const result = await computeHashlineDiff({ input: "¶local://PLAN.md\nEOF:\n↓x" }, tempDir);
expect("error" in result).toBe(true);
if ("error" in result) {