feat(coding-agent): added hashline grammar for anchor ranges and payload
- Updated hashline markers to `¶` headers and `^/v/->` operators across constants, prompts, docs, and tests. - Reworked hashline grammar and parser to support `ANCHOR<SIGIL>[INLINE_PAYLOAD]` with optional inline bodies and `A-B` ranges. - Changed range and marker syntax from `..`/`"` to `-` and suffix `^/v/->` forms like `7v` and `A->`. - Aligned `sameLineRange()` output and BOF/EOF handling so `|TEXT` remains cosmetic and payload now follows the op line. - Centralized op-line detection by replacing local regex helpers with `isHashlineOpLineText` for payload terminator and bad-op checks.
This commit is contained in:
@@ -236,10 +236,10 @@ describe("computeHashlineDiff", () => {
|
||||
const line = "unchanged content";
|
||||
await Bun.write(sourcePath, `${line}\n`);
|
||||
|
||||
// `≔1<hash>` with the same line as payload is a true no-op: the edit
|
||||
// `1<hash>→` with the same line as payload is a true no-op: the edit
|
||||
// fires through computeHashlineDiff but produces identical content.
|
||||
const anchor = formatLineHash(1, line);
|
||||
const input = `§${sourcePath}\n≔${anchor}\n${line}\n`;
|
||||
const input = `¶${sourcePath}\n${anchor}→\n${line}\n`;
|
||||
const result = await computeHashlineDiff({ input }, tempDir);
|
||||
expect("error" in result).toBe(true);
|
||||
if ("error" in result) {
|
||||
@@ -251,14 +251,14 @@ describe("computeHashlineDiff", () => {
|
||||
const sourcePath = path.join(tempDir, "source.txt");
|
||||
await Bun.write(sourcePath, "first\n");
|
||||
|
||||
const result = await computeHashlineDiff({ input: `§${sourcePath}\n»EOF\nsecond` }, tempDir);
|
||||
const result = await computeHashlineDiff({ input: `¶${sourcePath}\nEOF↓\nsecond` }, 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\n»EOF\n" }, tempDir);
|
||||
const result = await computeHashlineDiff({ input: "¶local://PLAN.md\nEOF↓\n" }, tempDir);
|
||||
|
||||
expect("error" in result).toBe(true);
|
||||
if ("error" in result) {
|
||||
|
||||
Reference in New Issue
Block a user