feat: removed chunk-mode modules and read/edit entrypoints from pi-natives

- Removed `pi-natives` chunk language classifier modules and all core chunk subsystems (kind, state, render, edit, resolve).
- Removed chunk-mode CLI/read/edit entrypoints, including `read` command and chunk mode registration/prompt tooling.
- Removed chunk selectors from `read` and `grep` tools, switching behavior to raw/L-range handling.
- Fixed poll wait parsing to keep defaulting to `30s` when the provided value is empty.
This commit is contained in:
can1357
2026-04-26 08:19:02 +02:00
parent a227adad1b
commit 5ea1d55e56
88 changed files with 49 additions and 30753 deletions
@@ -4,14 +4,10 @@ import * as os from "node:os";
import * as path from "node:path";
import {
adjustIndentation,
computeChunkDiff,
computeEditDiff,
computeHashlineDiff,
DEFAULT_FUZZY_THRESHOLD,
findMatch,
loadChunkSource,
parseChunkEditPath,
parseChunkReadPath,
} from "@oh-my-pi/pi-coding-agent/edit";
describe("findMatch", () => {
@@ -162,127 +158,6 @@ describe("findMatch", () => {
});
});
describe("computeChunkDiff", () => {
let tmpDir: string;
beforeEach(async () => {
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "compute-chunk-"));
});
afterEach(async () => {
await fs.rm(tmpDir, { recursive: true, force: true });
});
test("returns { error } when chunk selector cannot resolve", async () => {
const file = path.join(tmpDir, "c.ts");
await fs.writeFile(file, "export const x = 1;\n");
const result = await computeChunkDiff(
{
path: "c.ts:fn_does_not_exist#ABCD",
edits: [
{
path: "c.ts:fn_does_not_exist#ABCD",
write: "console.log('replaced')\n",
},
],
},
tmpDir,
);
expect("error" in result).toBe(true);
});
test("returns { error } when path is empty", async () => {
const result = await computeChunkDiff({ path: "", edits: [{ path: "", write: "x\n" }] }, tmpDir);
expect("error" in result).toBe(true);
});
test("rejects write:null instead of previewing a delete", async () => {
const file = path.join(tmpDir, "null-delete.ts");
await fs.writeFile(file, "export const x = 1;\n");
const result = await computeChunkDiff(
{
path: "null-delete.ts",
edits: [{ path: "null-delete.ts", write: null }],
},
tmpDir,
);
expect("error" in result).toBe(true);
if ("error" in result) {
expect(result.error).toContain("write:null no longer deletes chunks");
}
});
test("rejects bare chunk edit entries instead of treating them as deletes", async () => {
const file = path.join(tmpDir, "bare.ts");
await fs.writeFile(file, "export const x = 1;\n");
const result = await computeChunkDiff(
{
path: "bare.ts",
edits: [{ path: "bare.ts" }],
},
tmpDir,
);
expect("error" in result).toBe(true);
if ("error" in result) {
expect(result.error).toContain("no operation specified");
}
});
test("rejects write empty string instead of previewing a destructive empty replacement", async () => {
const file = path.join(tmpDir, "empty-write.ts");
await fs.writeFile(file, "export const x = 1;\n");
const result = await computeChunkDiff(
{
path: "empty-write.ts",
edits: [{ path: "empty-write.ts", write: "" }],
},
tmpDir,
);
expect("error" in result).toBe(true);
if ("error" in result) {
expect(result.error).toContain('write:"" is a destructive empty replacement');
}
});
test("aborts when signal fires before compute completes", async () => {
const controller = new AbortController();
controller.abort();
const result = await computeChunkDiff(
{
path: "d.ts",
edits: [{ path: "d.ts", write: "foo\n" }],
},
tmpDir,
{ signal: controller.signal },
);
expect("error" in result).toBe(true);
});
test("computes diff for a root chunk replacement with valid checksum", async () => {
const file = path.join(tmpDir, "e.ts");
await fs.writeFile(file, "export const x = 1;\n");
// Read the file once via loadChunkSource so the test does not depend on
// knowing the internal chunk checksum scheme.
const loaded = await loadChunkSource({ cwd: tmpDir, path: "e.ts" });
expect(loaded.exists).toBe(true);
expect(loaded.rawContent).toContain("export const x");
});
});
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", () => {