diff --git a/src/acp/translator.prompt-prefix.test.ts b/src/acp/translator.prompt-prefix.test.ts index 77aeddb01..2faf40ff8 100644 --- a/src/acp/translator.prompt-prefix.test.ts +++ b/src/acp/translator.prompt-prefix.test.ts @@ -13,13 +13,12 @@ function createConnection(): AgentSideConnection { } describe("acp prompt cwd prefix", () => { - it("redacts home directory in prompt prefix", async () => { + async function runPromptWithCwd(cwd: string) { const sessionStore = createInMemorySessionStore(); - const homeCwd = path.join(os.homedir(), "openclaw-test"); sessionStore.createSession({ sessionId: "session-1", sessionKey: "agent:main:main", - cwd: homeCwd, + cwd, }); const requestSpy = vi.fn(async (method: string) => { @@ -44,7 +43,11 @@ describe("acp prompt cwd prefix", () => { _meta: {}, } as unknown as PromptRequest), ).rejects.toThrow("stop-after-send"); + return requestSpy; + } + it("redacts home directory in prompt prefix", async () => { + const requestSpy = await runPromptWithCwd(path.join(os.homedir(), "openclaw-test")); expect(requestSpy).toHaveBeenCalledWith( "chat.send", expect.objectContaining({ @@ -53,4 +56,15 @@ describe("acp prompt cwd prefix", () => { { expectFinal: true }, ); }); + + it("keeps backslash separators when cwd uses them", async () => { + const requestSpy = await runPromptWithCwd(`${os.homedir()}\\openclaw-test`); + expect(requestSpy).toHaveBeenCalledWith( + "chat.send", + expect.objectContaining({ + message: expect.stringContaining("[Working directory: ~\\openclaw-test]"), + }), + { expectFinal: true }, + ); + }); }); diff --git a/src/agents/tools/cron-tool.test-harness.ts b/src/agents/tools/cron-tool.test-harness.ts deleted file mode 100644 index af8153f3b..000000000 --- a/src/agents/tools/cron-tool.test-harness.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { vi } from "vitest"; -import type { MockFn } from "../../test-utils/vitest-mock-fn.js"; - -export const callGatewayMock = vi.fn() as unknown as MockFn; - -vi.mock("../../gateway/call.js", () => ({ - callGateway: (opts: unknown) => callGatewayMock(opts), -})); - -vi.mock("../agent-scope.js", () => ({ - resolveSessionAgentId: () => "agent-123", -})); diff --git a/src/agents/tools/cron-tool.test-helpers.ts b/src/agents/tools/cron-tool.test-helpers.ts deleted file mode 100644 index 904563686..000000000 --- a/src/agents/tools/cron-tool.test-helpers.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { vi } from "vitest"; - -type GatewayMockFn = ((opts: unknown) => unknown) & { - mockReset: () => void; - mockResolvedValue: (value: unknown) => void; -}; - -export const callGatewayMock = vi.fn() as GatewayMockFn; - -vi.mock("../../gateway/call.js", () => ({ - callGateway: (opts: unknown) => callGatewayMock(opts), -})); - -vi.mock("../agent-scope.js", () => ({ - resolveSessionAgentId: () => "agent-123", -})); - -export function resetCronToolGatewayMock() { - callGatewayMock.mockReset(); - callGatewayMock.mockResolvedValue({ ok: true }); -}