The disallowed tools env var read in run.ts was DISALLOWED_TOOLS_INPUT (raw user input) instead of DISALLOWED_TOOLS (computed value including WebSearch/WebFetch defaults). This meant default tool disallowance was never enforced. Also removes orphaned ALLOWED_TOOLS env var export from createPrompt() (tag mode passes allowed tools via claudeArgs instead), extracts shared parseToolsInput utility to eliminate duplication, and adds tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { describe, test, expect } from "bun:test";
|
|
import { parseToolsInput } from "../../src/utils/parse-tools-input";
|
|
|
|
describe("parseToolsInput", () => {
|
|
test("returns empty array for undefined", () => {
|
|
expect(parseToolsInput(undefined)).toEqual([]);
|
|
});
|
|
|
|
test("returns empty array for empty string", () => {
|
|
expect(parseToolsInput("")).toEqual([]);
|
|
});
|
|
|
|
test("parses single tool", () => {
|
|
expect(parseToolsInput("WebSearch")).toEqual(["WebSearch"]);
|
|
});
|
|
|
|
test("parses comma-separated tools", () => {
|
|
expect(parseToolsInput("WebSearch,WebFetch")).toEqual([
|
|
"WebSearch",
|
|
"WebFetch",
|
|
]);
|
|
});
|
|
|
|
test("trims whitespace around tools", () => {
|
|
expect(parseToolsInput(" WebSearch , WebFetch ")).toEqual([
|
|
"WebSearch",
|
|
"WebFetch",
|
|
]);
|
|
});
|
|
|
|
test("filters empty entries from trailing commas", () => {
|
|
expect(parseToolsInput("WebSearch,,WebFetch,")).toEqual([
|
|
"WebSearch",
|
|
"WebFetch",
|
|
]);
|
|
});
|
|
|
|
test("handles tool patterns with special characters", () => {
|
|
expect(
|
|
parseToolsInput("Bash(npm test:*),mcp__github_ci__get_ci_status"),
|
|
).toEqual(["Bash(npm test:*)", "mcp__github_ci__get_ci_status"]);
|
|
});
|
|
});
|