@@ -24,7 +24,7 @@ import { IExtensionService } from '../../../../services/extensions/common/extens
24
24
import { ILifecycleService , LifecyclePhase } from '../../../../services/lifecycle/common/lifecycle.js' ;
25
25
import { IUserDataProfileService } from '../../../../services/userDataProfile/common/userDataProfile.js' ;
26
26
import { CHAT_CATEGORY } from '../actions/chatActions.js' ;
27
- import { ILanguageModelToolsService , IToolData , ToolSet } from '../../common/languageModelToolsService.js' ;
27
+ import { ILanguageModelToolsService , IToolData , ToolDataSource , ToolSet } from '../../common/languageModelToolsService.js' ;
28
28
import { IRawToolSetContribution } from '../../common/tools/languageModelToolsContribution.js' ;
29
29
import { IEditorService } from '../../../../services/editor/common/editorService.js' ;
30
30
import { Codicon , getAllCodicons } from '../../../../../base/common/codicons.js' ;
@@ -46,7 +46,7 @@ const toolSetsSchema: IJSONSchema = {
46
46
allowTrailingCommas : true ,
47
47
defaultSnippets : [ {
48
48
label : localize ( 'schema.default' , "Empty tool set" ) ,
49
- body : { '${1:toolSetName}' : { 'tools' : [ '${2:toolName}' ] , 'description' : '${3 :description}' , 'icon' : '${4:$( tools) }' } }
49
+ body : { '${1:toolSetName}' : { 'tools' : [ '${2:someTool}' , '${3:anotherTool}' ] , 'description' : '${4 :description}' , 'icon' : '${5: tools}' } }
50
50
} ] ,
51
51
type : 'object' ,
52
52
description : localize ( 'toolsetSchema.json' , 'User tool sets configuration' ) ,
@@ -150,19 +150,52 @@ export class UserToolSetsContributions extends Disposable implements IWorkbenchC
150
150
const tools = toolsObs . read ( r ) ;
151
151
const toolSets = this . _languageModelToolsService . toolSets . read ( r ) ;
152
152
153
- toolEnumValues . length = 0 ;
154
- toolEnumDescriptions . length = 0 ;
155
153
154
+ type ToolDesc = {
155
+ name : string ;
156
+ sourceLabel : string ;
157
+ sourceOrdinal : number ;
158
+ description : string ;
159
+ } ;
160
+
161
+ const data : ToolDesc [ ] = [ ] ;
156
162
for ( const tool of tools ) {
157
- if ( tool . toolReferenceName && tool . canBeReferencedInPrompt ) {
158
- toolEnumValues . push ( tool . toolReferenceName ) ;
159
- toolEnumDescriptions . push ( localize ( 'tooldesc' , "{0} - {1}" , tool . source . label , tool . userDescription ?? tool . modelDescription ) ) ;
163
+ if ( tool . canBeReferencedInPrompt ) {
164
+ data . push ( {
165
+ name : tool . toolReferenceName ?? tool . displayName ,
166
+ sourceLabel : ToolDataSource . classify ( tool . source ) . label ,
167
+ sourceOrdinal : ToolDataSource . classify ( tool . source ) . ordinal ,
168
+ description : tool . userDescription ?? tool . modelDescription
169
+ } ) ;
160
170
}
161
171
}
162
172
for ( const toolSet of toolSets ) {
163
- toolEnumValues . push ( toolSet . toolReferenceName ) ;
164
- toolEnumDescriptions . push ( localize ( 'toolsetdesc' , "{0} - {1}" , toolSet . source . label , toolSet . description ?? toolSet . displayName ?? '' ) ) ;
173
+ data . push ( {
174
+ name : toolSet . toolReferenceName ,
175
+ sourceLabel : ToolDataSource . classify ( toolSet . source ) . label ,
176
+ sourceOrdinal : ToolDataSource . classify ( toolSet . source ) . ordinal ,
177
+ description : toolSet . description ?? toolSet . displayName
178
+ } ) ;
179
+ }
180
+
181
+ toolEnumValues . length = 0 ;
182
+ toolEnumDescriptions . length = 0 ;
183
+
184
+ data . sort ( ( a , b ) => {
185
+ if ( a . sourceOrdinal !== b . sourceOrdinal ) {
186
+ return a . sourceOrdinal - b . sourceOrdinal ;
187
+ }
188
+ if ( a . sourceLabel !== b . sourceLabel ) {
189
+ return a . sourceLabel . localeCompare ( b . sourceLabel ) ;
190
+ }
191
+ return a . name . localeCompare ( b . name ) ;
192
+ } ) ;
193
+
194
+ for ( const item of data ) {
195
+ toolEnumValues . push ( item . name ) ;
196
+ toolEnumDescriptions . push ( localize ( 'tool.description' , "{1} ({0})\n\n{2}" , item . sourceLabel , item . name , item . description ) ) ;
165
197
}
198
+
166
199
store . clear ( ) ; // reset old schema
167
200
reg . registerSchema ( toolSetSchemaId , toolSetsSchema , store ) ;
168
201
} ) ) ;
@@ -364,10 +397,11 @@ export class ConfigureToolSets extends Action2 {
364
397
'// {' ,
365
398
'// \t"toolSetName": {' ,
366
399
'// \t\t"tools": [' ,
367
- '// \t\t\t"toolName"' ,
400
+ '// \t\t\t"someTool",' ,
401
+ '// \t\t\t"anotherTool"' ,
368
402
'// \t\t],' ,
369
403
'// \t\t"description": "description",' ,
370
- '// \t\t"icon": "$( tools) "' ,
404
+ '// \t\t"icon": "tools"' ,
371
405
'// \t}' ,
372
406
'// }' ,
373
407
] . join ( '\n' ) ) ;
0 commit comments