chore: unclanking edit pr

This commit is contained in:
can1357
2026-07-17 21:37:20 +02:00
parent 4d4090a578
commit 766790cbac
4 changed files with 5 additions and 40 deletions
-4
View File
@@ -2,10 +2,6 @@
## [Unreleased]
### Fixed
- Fixed repeated edit-tool rejections by recovering comma-separated ranges and malformed local-model trailers, while steering agents to canonical string input and `.=` syntax ([#5805](https://github.com/can1357/oh-my-pi/issues/5805)).
## [17.0.0] - 2026-07-15
### Added
-5
View File
@@ -116,11 +116,6 @@ function parseHashlineHeaderLine(line: string, cwd?: string): RawSection | null
// the half-dozen variants models actually emit.
const recovered = tryParseRecoveryHeader(trimmed, cwd);
if (recovered !== null) return recovered;
if (trimmed === "[" || trimmed.startsWith('["') || trimmed.startsWith("[{")) {
throw new Error(
"Edit input must be one patch string, not a JSON array. Join patch lines with newlines inside the `input` string.",
);
}
throw new Error(
`Input header must be ${HL_FILE_PREFIX}PATH${HL_FILE_SUFFIX} or ${HL_FILE_PREFIX}PATH${HL_FILE_HASH_SEP}TAG${HL_FILE_SUFFIX} with a ${HL_FILE_HASH_LENGTH}-hex content-hash tag; got ${JSON.stringify(trimmed)}.`,
);
+3 -17
View File
@@ -1,10 +1,5 @@
Your patch language names lines to replace, delete, or insert at, then lists the new content. Rule of thumb: a header ending in `:` is followed by `+` body rows; `DEL` has no body.
<critical>
- Input is ONE patch string. NEVER pass an array.
- Ranges use `N.=M` exactly. NEVER commas or `:=:`.
</critical>
<headers>
Every file section starts with `[PATH#TAG]`. `TAG` = 4-hex snapshot tag from your latest `read`/`search`, REQUIRED on every section — no hashless form. Create new files with `write`; hashline only edits existing files.
</headers>
@@ -135,13 +130,6 @@ SWAP.BLK 1:
</example>
<anti-patterns>
# WRONG — comma range and `:=:` trailer. RIGHT: `SWAP 1.=17:`
SWAP 1,17:=:
+replacement
# RIGHT
SWAP 1.=17:
+replacement
# WRONG — empty `SWAP` to delete. RIGHT: DEL 4
SWAP 4.=4:
@@ -178,9 +166,7 @@ INS.POST 3:
<critical>
If you remember nothing else:
1. INPUT IS ONE STRING. NEVER pass patch lines as an array.
2. RE-GROUND AFTER EVERY EDIT. Every apply mints a fresh `#TAG` and renumbers — take the next edit's numbers from the edit response or a fresh `read`. Stale tag or surprise? STOP, re-`read`.
3. RANGES ARE EXACT. Use `N.=M`; NEVER commas or `:=:`.
4. RANGES ARE TIGHT. Cover only lines that change; a stale wide range shreds everything it spans. Whole construct → `SWAP.BLK N`.
5. THE BODY IS THE FINAL CONTENT. Every body row starts with `+`; Markdown bullets use `+- item`, not `- item`.
1. RE-GROUND AFTER EVERY EDIT. Every apply mints a fresh `#TAG` and renumbers — take the next edit's numbers from the edit response or a fresh `read`. Stale tag or surprise? STOP, re-`read`.
2. RANGES ARE TIGHT. Cover only lines that change; a stale wide range shreds everything it spans. Whole construct → `SWAP.BLK N`.
3. THE BODY IS THE FINAL CONTENT. Every body row starts with `+`; Markdown bullets use `+- item`, not `- item`.
</critical>
+2 -14
View File
@@ -57,12 +57,6 @@ describe("hashline section headers", () => {
expect(message).not.toContain("#0A3");
}
});
it("explains that array-shaped tool input must be one patch string", () => {
expect(() => Patch.parse('["[a.ts#1A2B]", "SWAP 1.=1:", "+after"]')).toThrow(
/one patch string, not a JSON array/,
);
});
});
describe("hashline core — verb header forms", () => {
@@ -93,8 +87,6 @@ describe("hashline core — verb header forms", () => {
expect(applyPatch(FILE, "SWAP 2\u20263:\n+X")).toBe("a\nX\nd\ne");
expect(applyPatch(FILE, "SWAP 2 3:\n+X")).toBe("a\nX\nd\ne");
expect(applyPatch(FILE, "SWAP 2..3:\n+X")).toBe("a\nX\nd\ne"); // legacy `..` still accepted
expect(applyPatch(FILE, "SWAP 2,3:\n+X")).toBe("a\nX\nd\ne");
expect(applyPatch(FILE, "SWAP 2,3:=:\n+X")).toBe("a\nX\nd\ne");
expect(applyPatch(FILE, "SWAP 2.=3\n+X")).toBe("a\nX\nd\ne"); // missing colon
});
@@ -195,12 +187,8 @@ describe("hashline body contracts", () => {
expect(() => parsePatch("DEL 2\n+X")).toThrow(/does not take body rows/);
});
it("accepts a trailing colon on bodyless delete headers", () => {
expect(applyPatch(FILE, "DEL 2,3:")).toBe("a\nd\ne");
});
it("still rejects delete body rows after a trailing colon", () => {
expect(() => parsePatch("DEL 2:\n+X")).toThrow(/does not take body rows/);
it("rejects delete with a colon", () => {
expect(() => parsePatch("DEL 2:\n+X")).toThrow(/has no colon/);
});
});