Skip to content

Commit 64dbc30

Browse files
committed
test(tools): cover codebase search mode permissions directly
1 parent 7a219bc commit 64dbc30

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

‎src/core/tools/__tests__/validateToolUse.spec.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// npx vitest run src/core/tools/__tests__/validateToolUse.spec.ts
22

3-
import type { ModeConfig } from "@roo-code/types"
3+
import { toolNamesSchema, type ModeConfig } from "@roo-code/types"
44

55
import { modes } from "../../../shared/modes"
66
import { TOOL_GROUPS } from "../../../shared/tools"
@@ -49,6 +49,28 @@ describe("mode-validator", () => {
4949
})
5050

5151
describe("custom modes", () => {
52+
it("allows codebase search in a read-only mode without manager readiness input", () => {
53+
const mode: ModeConfig = {
54+
slug: "read-only",
55+
name: "Read only",
56+
roleDefinition: "Read the codebase",
57+
groups: ["read"],
58+
}
59+
60+
expect(isToolAllowedForMode(toolNamesSchema.enum.codebase_search, mode.slug, [mode])).toBe(true)
61+
})
62+
63+
it("rejects codebase search in a command-only mode", () => {
64+
const mode: ModeConfig = {
65+
slug: "command-only",
66+
name: "Command only",
67+
roleDefinition: "Run commands without read tools",
68+
groups: ["command"],
69+
}
70+
71+
expect(isToolAllowedForMode(toolNamesSchema.enum.codebase_search, mode.slug, [mode])).toBe(false)
72+
})
73+
5274
it("allows tools from custom mode configuration", () => {
5375
const customModes: ModeConfig[] = [
5476
{

0 commit comments

Comments
 (0)