Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/core/src/tests/web-search-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ test("WebSearch returns a configuration error when neither a script nor an LLM c
);
});

test("WebSearch executes a configured .bat script on Windows", { skip: process.platform !== "win32" }, async () => {
const workspace = createTempWorkspace();
const scriptPath = path.join(workspace, "web-search.bat");
fs.writeFileSync(scriptPath, "@echo off\r\necho query=%1\r\n", "utf8");

const result = await handleWebSearchTool({ query: "test" }, createContext(workspace, { webSearchTool: scriptPath }));

assert.equal(result.ok, true);
assert.match(result.output ?? "", /query=test/);
});

function createContext(
projectRoot: string,
options: {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/tools/web-search-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ async function runWebSearchScript(
return new Promise((resolve) => {
const child = spawn(scriptPath, [query], {
cwd: context.projectRoot,
// Node.js v20+ removed the automatic cmd.exe routing for .bat/.cmd
// files on Windows, so custom webSearchTool scripts pointing at .bat
// files need an explicit shell. (#190)
shell: process.platform === "win32",
env: { ...process.env, ...configuredEnv },
stdio: ["ignore", "pipe", "pipe"],
});
Expand Down