fix(coding-agent): fixed local plan URL path separator handling in chunk edits

- Updated `chunkReadPathSeparatorIndex` to detect URL schemes and split at the final selector colon only after the URL path.
- Added tests for `parseChunkEditPath` and `parseChunkReadPath` covering local plan URLs with selectors and scheme-only URLs.
This commit is contained in:
can1357
2026-04-24 18:51:32 +02:00
parent ddff481260
commit 501106a3c4
3 changed files with 35 additions and 1 deletions
@@ -10,6 +10,8 @@ import {
DEFAULT_FUZZY_THRESHOLD,
findMatch,
loadChunkSource,
parseChunkEditPath,
parseChunkReadPath,
} from "@oh-my-pi/pi-coding-agent/edit";
describe("findMatch", () => {
@@ -217,6 +219,23 @@ describe("computeChunkDiff", () => {
});
});
describe("chunk path parsing", () => {
test("splits local plan URLs with chunk selectors after the URL path", () => {
expect(parseChunkEditPath("local://PLAN.md:sct_0_T#SRJJ")).toEqual({
filePath: "local://PLAN.md",
selector: "sct_0_T#SRJJ",
});
expect(parseChunkReadPath("local://PLAN.md:sct_6_R.sct_6_u#MZKS")).toEqual({
filePath: "local://PLAN.md",
selector: "sct_6_R.sct_6_u#MZKS",
});
});
test("does not treat the local URL scheme colon as a chunk selector separator", () => {
expect(parseChunkEditPath("local://PLAN.md")).toEqual({ filePath: "local://PLAN.md" });
});
});
describe("adjustIndentation", () => {
test("adds indentation when actualText is more indented than oldText", () => {
const oldText = "foo\nbar";