33import { describe , it , expect } from "vitest"
44import { getToolDescriptionsForMode } from "../index"
55import { defaultModeSlug } from "../../../../shared/modes"
6+ import { toolNames } from "@roo-code/types"
7+ import { TOOL_GROUPS , ALWAYS_AVAILABLE_TOOLS } from "../../../../shared/tools"
68
79describe ( "getToolDescriptionsForMode" , ( ) => {
810 const mockCwd = "/test/path"
@@ -21,7 +23,6 @@ describe("getToolDescriptionsForMode", () => {
2123 undefined , // experiments
2224 undefined , // partialReadsEnabled
2325 undefined , // settings
24- undefined , // disabledTools
2526 )
2627
2728 expect ( result ) . toBeTruthy ( )
@@ -47,8 +48,7 @@ describe("getToolDescriptionsForMode", () => {
4748 undefined ,
4849 undefined ,
4950 undefined ,
50- undefined ,
51- disabledTools ,
51+ { disabledTools } , // settings object with disabledTools
5252 )
5353
5454 // Check that disabled tools are not included
@@ -60,7 +60,7 @@ describe("getToolDescriptionsForMode", () => {
6060 expect ( result ) . toContain ( "## search_files" )
6161 } )
6262
63- it ( "should not filter out always-available tools even if disabled" , ( ) => {
63+ it ( "should filter out all tools including always-available tools when disabled" , ( ) => {
6464 const disabledTools = [ "ask_followup_question" , "attempt_completion" ]
6565 const result = getToolDescriptionsForMode (
6666 defaultModeSlug ,
@@ -73,13 +73,12 @@ describe("getToolDescriptionsForMode", () => {
7373 undefined ,
7474 undefined ,
7575 undefined ,
76- undefined ,
77- disabledTools ,
76+ { disabledTools } , // settings object with disabledTools
7877 )
7978
80- // These tools should always be available
81- expect ( result ) . toContain ( "## ask_followup_question" )
82- expect ( result ) . toContain ( "## attempt_completion" )
79+ // These tools should be filtered out since we now allow disabling all tools
80+ expect ( result ) . not . toContain ( "## ask_followup_question" )
81+ expect ( result ) . not . toContain ( "## attempt_completion" )
8382 } )
8483
8584 it ( "should handle empty disabled tools array" , ( ) => {
@@ -95,8 +94,7 @@ describe("getToolDescriptionsForMode", () => {
9594 undefined ,
9695 undefined ,
9796 undefined ,
98- undefined ,
99- disabledTools ,
97+ { disabledTools } , // settings object with empty disabledTools
10098 )
10199 const resultWithoutDisabled = getToolDescriptionsForMode (
102100 defaultModeSlug ,
@@ -109,8 +107,7 @@ describe("getToolDescriptionsForMode", () => {
109107 undefined ,
110108 undefined ,
111109 undefined ,
112- undefined ,
113- undefined ,
110+ undefined , // no settings
114111 )
115112
116113 // Should return the same tools
@@ -129,8 +126,7 @@ describe("getToolDescriptionsForMode", () => {
129126 undefined ,
130127 undefined ,
131128 undefined ,
132- undefined ,
133- undefined ,
129+ { disabledTools : undefined } , // settings with undefined disabledTools
134130 )
135131 const resultWithoutDisabled = getToolDescriptionsForMode (
136132 defaultModeSlug ,
@@ -143,8 +139,7 @@ describe("getToolDescriptionsForMode", () => {
143139 undefined ,
144140 undefined ,
145141 undefined ,
146- undefined ,
147- undefined ,
142+ undefined , // no settings
148143 )
149144
150145 // Should return the same tools
@@ -164,8 +159,7 @@ describe("getToolDescriptionsForMode", () => {
164159 undefined ,
165160 undefined ,
166161 undefined ,
167- undefined ,
168- disabledTools ,
162+ { disabledTools } , // settings object with disabledTools
169163 )
170164
171165 // Check that all disabled tools are filtered out
@@ -175,8 +169,8 @@ describe("getToolDescriptionsForMode", () => {
175169
176170 // Check that some other tools are still included
177171 expect ( result ) . toContain ( "# Tools" )
178- // Always available tools should still be there
179- expect ( result ) . toContain ( "## ask_followup_question " )
172+ // Other tools that weren't disabled should still be there
173+ expect ( result ) . toContain ( "## list_code_definition_names " )
180174 } )
181175
182176 it ( "should handle invalid tool names in disabled list" , ( ) => {
@@ -192,8 +186,7 @@ describe("getToolDescriptionsForMode", () => {
192186 undefined ,
193187 undefined ,
194188 undefined ,
195- undefined ,
196- disabledTools ,
189+ { disabledTools } , // settings object with disabledTools
197190 )
198191
199192 // Should still filter out valid disabled tools
@@ -217,8 +210,7 @@ describe("getToolDescriptionsForMode", () => {
217210 undefined ,
218211 undefined ,
219212 undefined ,
220- undefined ,
221- disabledTools ,
213+ { disabledTools } , // settings object with disabledTools
222214 )
223215
224216 // execute_command should be filtered out
@@ -228,4 +220,67 @@ describe("getToolDescriptionsForMode", () => {
228220 expect ( result ) . toContain ( "## read_file" )
229221 expect ( result ) . toContain ( "## write_to_file" )
230222 } )
223+
224+ it ( "should have all tools from packages/types/src/tool.ts represented in TOOL_GROUPS or ALWAYS_AVAILABLE_TOOLS" , ( ) => {
225+ // Get all tools from TOOL_GROUPS
226+ const toolsInGroups = new Set < string > ( )
227+ Object . values ( TOOL_GROUPS ) . forEach ( ( group ) => {
228+ group . tools . forEach ( ( tool ) => toolsInGroups . add ( tool ) )
229+ } )
230+
231+ // Get all tools from ALWAYS_AVAILABLE_TOOLS
232+ const alwaysAvailableSet = new Set ( ALWAYS_AVAILABLE_TOOLS )
233+
234+ // Combine both sets
235+ const allRepresentedTools = new Set ( [ ...toolsInGroups , ...alwaysAvailableSet ] )
236+
237+ // Check that every tool from toolNames is represented
238+ const missingTools : string [ ] = [ ]
239+ toolNames . forEach ( ( toolName ) => {
240+ if ( ! allRepresentedTools . has ( toolName ) ) {
241+ missingTools . push ( toolName )
242+ }
243+ } )
244+
245+ // Assert that there are no missing tools
246+ expect ( missingTools ) . toEqual ( [ ] )
247+ } )
248+
249+ it ( "should not have tools in TOOL_GROUPS that are not in packages/types/src/tool.ts" , ( ) => {
250+ // Get all tools from TOOL_GROUPS
251+ const toolsInGroups = new Set < string > ( )
252+ Object . values ( TOOL_GROUPS ) . forEach ( ( group ) => {
253+ group . tools . forEach ( ( tool ) => toolsInGroups . add ( tool ) )
254+ } )
255+
256+ // Convert toolNames to a Set for easier lookup
257+ const validToolNames = new Set ( toolNames )
258+
259+ // Check that every tool in TOOL_GROUPS exists in toolNames
260+ const invalidTools : string [ ] = [ ]
261+ toolsInGroups . forEach ( ( tool ) => {
262+ if ( ! validToolNames . has ( tool as any ) ) {
263+ invalidTools . push ( tool )
264+ }
265+ } )
266+
267+ // Assert that there are no invalid tools
268+ expect ( invalidTools ) . toEqual ( [ ] )
269+ } )
270+
271+ it ( "should not have tools in ALWAYS_AVAILABLE_TOOLS that are not in packages/types/src/tool.ts" , ( ) => {
272+ // Convert toolNames to a Set for easier lookup
273+ const validToolNames = new Set ( toolNames )
274+
275+ // Check that every tool in ALWAYS_AVAILABLE_TOOLS exists in toolNames
276+ const invalidTools : string [ ] = [ ]
277+ ALWAYS_AVAILABLE_TOOLS . forEach ( ( tool ) => {
278+ if ( ! validToolNames . has ( tool ) ) {
279+ invalidTools . push ( tool )
280+ }
281+ } )
282+
283+ // Assert that there are no invalid tools
284+ expect ( invalidTools ) . toEqual ( [ ] )
285+ } )
231286} )
0 commit comments