mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:48:27 +00:00
fix(agents): allow empty edit replacement text
(cherry picked from commit 3c21fc30d3)
This commit is contained in:
committed by
Peter Steinberger
parent
fd7ca4c394
commit
3823587ada
@@ -353,6 +353,7 @@ export const CLAUDE_PARAM_GROUPS = {
|
|||||||
{
|
{
|
||||||
keys: ["newText", "new_string"],
|
keys: ["newText", "new_string"],
|
||||||
label: "newText (newText or new_string)",
|
label: "newText (newText or new_string)",
|
||||||
|
allowEmpty: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -60,6 +60,31 @@ describe("workspace path resolution", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows deletion edits with empty newText", async () => {
|
||||||
|
await withTempDir("openclaw-ws-", async (workspaceDir) => {
|
||||||
|
await withTempDir("openclaw-cwd-", async (otherDir) => {
|
||||||
|
const testFile = "delete.txt";
|
||||||
|
await fs.writeFile(path.join(workspaceDir, testFile), "hello world", "utf8");
|
||||||
|
|
||||||
|
const cwdSpy = vi.spyOn(process, "cwd").mockReturnValue(otherDir);
|
||||||
|
try {
|
||||||
|
const tools = createOpenClawCodingTools({ workspaceDir });
|
||||||
|
const { editTool } = expectReadWriteEditTools(tools);
|
||||||
|
|
||||||
|
await editTool.execute("ws-edit-delete", {
|
||||||
|
path: testFile,
|
||||||
|
oldText: " world",
|
||||||
|
newText: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(await fs.readFile(path.join(workspaceDir, testFile), "utf8")).toBe("hello");
|
||||||
|
} finally {
|
||||||
|
cwdSpy.mockRestore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("defaults exec cwd to workspaceDir when workdir is omitted", async () => {
|
it("defaults exec cwd to workspaceDir when workdir is omitted", async () => {
|
||||||
await withTempDir("openclaw-ws-", async (workspaceDir) => {
|
await withTempDir("openclaw-ws-", async (workspaceDir) => {
|
||||||
const tools = createOpenClawCodingTools({
|
const tools = createOpenClawCodingTools({
|
||||||
|
|||||||
Reference in New Issue
Block a user