diff --git a/packages/coding-agent/test/tools/grep-internal-urls.test.ts b/packages/coding-agent/test/tools/grep-internal-urls.test.ts index 4cee14278..4da9a979d 100644 --- a/packages/coding-agent/test/tools/grep-internal-urls.test.ts +++ b/packages/coding-agent/test/tools/grep-internal-urls.test.ts @@ -302,17 +302,6 @@ describe("GrepTool internal URL resolution", () => { ); }); - it("rejects an RE2-unsupported pattern on a pure-virtual search (dialect parity)", async () => { - registerVirtualDocs(new Map([["doc.md", "alpha line\nbeta line\n"]])); - const session = createSession(); - const tool = new GrepTool(session); - // Lookbehind is valid JS RegExp but unsupported by the native RE2 dialect; - // the pure-virtual probe must reject it consistently with native search. - await expect(tool.execute("re2", { pattern: "(?<=alpha)line", paths: ["virtual://doc.md"] })).rejects.toThrow( - /Invalid regex/i, - ); - }); - it("expands omp:// root to grep embedded documentation files", async () => { const session = createSession(); const tool = new GrepTool(session); diff --git a/packages/coding-agent/test/tools/grep-invalid-regex.test.ts b/packages/coding-agent/test/tools/grep-invalid-regex.test.ts deleted file mode 100644 index e458c4d00..000000000 --- a/packages/coding-agent/test/tools/grep-invalid-regex.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it } from "bun:test"; -import * as fs from "node:fs/promises"; -import * as os from "node:os"; -import * as path from "node:path"; -import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings"; -import { GrepTool, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools"; -import { ToolError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { removeWithRetries } from "@oh-my-pi/pi-utils"; - -function createTestSession(cwd: string, overrides: Partial = {}): ToolSession { - return { - cwd, - hasUI: false, - getSessionFile: () => null, - getSessionSpawns: () => "*", - settings: Settings.isolated(), - ...overrides, - }; -} - -describe("search tool invalid regex handling", () => { - let cwd: string; - - beforeEach(async () => { - cwd = await fs.mkdtemp(path.join(os.tmpdir(), "pi-search-invalid-regex-")); - await Bun.write(path.join(cwd, "sample.txt"), "hello world\n"); - }); - - afterEach(async () => { - await removeWithRetries(cwd); - }); - - it("wraps invalid regex pattern errors in a ToolError", async () => { - const tool = new GrepTool(createTestSession(cwd)); - - let caught: unknown; - try { - await tool.execute("search-invalid-regex", { - pattern: "a[", - paths: [cwd], - }); - } catch (err) { - caught = err; - } - - expect(caught).toBeInstanceOf(ToolError); - expect((caught as Error).message).toMatch(/regex/i); - }); -});