@codingame/monaco-vscode-xterm-addons-common 26.2.2 → 28.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/package.json +10 -10
  2. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +5 -1
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +62 -10
  4. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugAttachment.d.ts +8 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugAttachment.js +72 -0
  6. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +8 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +7 -7
  8. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +13 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +79 -36
  10. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +9 -9
  11. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +25 -25
  12. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +1 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +117 -36
  14. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js +11 -12
  15. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +16 -16
  16. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +1 -0
  17. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +28 -13
  18. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatDynamicVariables.d.ts +0 -42
  19. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatDynamicVariables.js +0 -209
  20. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.d.ts +0 -112
  21. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.js +0 -1314
@@ -1,1314 +0,0 @@
1
-
2
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { splitGlobAware, parse, isEmptyPattern } from '@codingame/monaco-vscode-api/vscode/vs/base/common/glob';
4
- import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
5
- import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
6
- import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
7
- import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
8
- import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
9
- import { MarkerSeverity } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers';
10
- import { IMarkerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service';
11
- import { ChatMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes';
12
- import { IChatModeService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes.service';
13
- import { ChatModeKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
14
- import { ILanguageModelChatMetadata } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
15
- import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
16
- import { SpecedToolAliases } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsService';
17
- import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsService.service';
18
- import { PromptsType, getPromptsTypeForLanguageId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
19
- import { PromptHeaderAttributes, parseCommaSeparatedList, GithubPromptHeaderAttributes } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptFileParser';
20
- import { Disposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
21
- import { Delayer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
22
- import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
23
- import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
24
- import { Target } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService';
25
- import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service';
26
- import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
27
- import { LEGACY_MODE_FILE_EXTENSION, AGENTS_SOURCE_FOLDER, CLAUDE_AGENTS_SOURCE_FOLDER, isInClaudeRulesFolder } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations';
28
- import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
29
- import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
30
- import { dirname } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
31
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
32
-
33
- const MARKERS_OWNER_ID = "prompts-diagnostics-provider";
34
- let PromptValidator = class PromptValidator {
35
- constructor(
36
- languageModelsService,
37
- languageModelToolsService,
38
- chatModeService,
39
- fileService,
40
- labelService,
41
- promptsService
42
- ) {
43
- this.languageModelsService = languageModelsService;
44
- this.languageModelToolsService = languageModelToolsService;
45
- this.chatModeService = chatModeService;
46
- this.fileService = fileService;
47
- this.labelService = labelService;
48
- this.promptsService = promptsService;
49
- }
50
- async validate(promptAST, promptType, report) {
51
- promptAST.header?.errors.forEach(
52
- error => report(toMarker(error.message, error.range, MarkerSeverity.Error))
53
- );
54
- const target = getTarget(promptType, promptAST.header ?? promptAST.uri);
55
- await this.validateHeader(promptAST, promptType, target, report);
56
- await this.validateBody(promptAST, target, report);
57
- await this.validateFileName(promptAST, promptType, report);
58
- await this.validateSkillFolderName(promptAST, promptType, report);
59
- }
60
- async validateFileName(promptAST, promptType, report) {
61
- if (promptType === PromptsType.agent && promptAST.uri.path.endsWith(LEGACY_MODE_FILE_EXTENSION)) {
62
- const location = this.promptsService.getAgentFileURIFromModeFile(promptAST.uri);
63
- if (location && (await this.fileService.canCreateFile(location))) {
64
- report(toMarker(( localize(
65
- 6431,
66
- "Chat modes have been renamed to agents. Please move this file to {0}",
67
- (location.toString())
68
- )), ( new Range(1, 1, 1, 4)), MarkerSeverity.Warning));
69
- } else {
70
- report(toMarker(( localize(
71
- 6432,
72
- "Chat modes have been renamed to agents. Please move the file to {0}",
73
- AGENTS_SOURCE_FOLDER
74
- )), ( new Range(1, 1, 1, 4)), MarkerSeverity.Warning));
75
- }
76
- }
77
- }
78
- async validateSkillFolderName(promptAST, promptType, report) {
79
- if (promptType !== PromptsType.skill) {
80
- return;
81
- }
82
- const nameAttribute = promptAST.header?.attributes.find(attr => attr.key === PromptHeaderAttributes.name);
83
- if (!nameAttribute || nameAttribute.value.type !== "string") {
84
- return;
85
- }
86
- const skillName = nameAttribute.value.value.trim();
87
- if (!skillName) {
88
- return;
89
- }
90
- const pathParts = promptAST.uri.path.split("/");
91
- const skillIndex = pathParts.findIndex(part => part === "SKILL.md");
92
- if (skillIndex > 0) {
93
- const folderName = pathParts[skillIndex - 1];
94
- if (folderName && skillName !== folderName) {
95
- report(toMarker(( localize(
96
- 6433,
97
- "The skill name '{0}' should match the folder name '{1}'.",
98
- skillName,
99
- folderName
100
- )), nameAttribute.value.range, MarkerSeverity.Warning));
101
- }
102
- }
103
- }
104
- async validateBody(promptAST, target, report) {
105
- const body = promptAST.body;
106
- if (!body) {
107
- return;
108
- }
109
- const fileReferenceChecks = [];
110
- for (const ref of body.fileReferences) {
111
- const resolved = body.resolveFilePath(ref.content);
112
- if (!resolved) {
113
- report(toMarker(( localize(6434, "Invalid file reference '{0}'.", ref.content)), ref.range, MarkerSeverity.Warning));
114
- continue;
115
- }
116
- if (promptAST.uri.scheme === resolved.scheme) {
117
- fileReferenceChecks.push((async () => {
118
- try {
119
- const exists = await this.fileService.exists(resolved);
120
- if (exists) {
121
- return;
122
- }
123
- } catch {}
124
- const loc = this.labelService.getUriLabel(resolved);
125
- report(toMarker(( localize(6435, "File '{0}' not found at '{1}'.", ref.content, loc)), ref.range, MarkerSeverity.Warning));
126
- })());
127
- }
128
- }
129
- if (body.variableReferences.length && isVSCodeOrDefaultTarget(target)) {
130
- const headerTools = promptAST.header?.tools;
131
- const headerToolsMap = headerTools ? this.languageModelToolsService.toToolAndToolSetEnablementMap(headerTools, undefined) : undefined;
132
- const available = ( new Set(this.languageModelToolsService.getFullReferenceNames()));
133
- const deprecatedNames = this.languageModelToolsService.getDeprecatedFullReferenceNames();
134
- for (const variable of body.variableReferences) {
135
- if (!( available.has(variable.name))) {
136
- if (( deprecatedNames.has(variable.name))) {
137
- const currentNames = deprecatedNames.get(variable.name);
138
- if (currentNames && currentNames.size > 0) {
139
- if (currentNames.size === 1) {
140
- const newName = Array.from(currentNames)[0];
141
- report(toMarker(( localize(
142
- 6436,
143
- "Tool or toolset '{0}' has been renamed, use '{1}' instead.",
144
- variable.name,
145
- newName
146
- )), variable.range, MarkerSeverity.Info));
147
- } else {
148
- const newNames = Array.from(currentNames).sort((a, b) => a.localeCompare(b)).join(", ");
149
- report(toMarker(( localize(
150
- 6437,
151
- "Tool or toolset '{0}' has been renamed, use the following tools instead: {1}",
152
- variable.name,
153
- newNames
154
- )), variable.range, MarkerSeverity.Info));
155
- }
156
- }
157
- } else {
158
- report(toMarker(( localize(6438, "Unknown tool or toolset '{0}'.", variable.name)), variable.range, MarkerSeverity.Warning));
159
- }
160
- } else if (headerToolsMap) {
161
- const tool = this.languageModelToolsService.getToolByFullReferenceName(variable.name);
162
- if (tool && headerToolsMap.get(tool) === false) {
163
- report(toMarker(( localize(
164
- 6439,
165
- "Tool or toolset '{0}' also needs to be enabled in the header.",
166
- variable.name
167
- )), variable.range, MarkerSeverity.Warning));
168
- }
169
- }
170
- }
171
- }
172
- await Promise.all(fileReferenceChecks);
173
- }
174
- async validateHeader(promptAST, promptType, target, report) {
175
- const header = promptAST.header;
176
- if (!header) {
177
- return;
178
- }
179
- const attributes = header.attributes;
180
- this.checkForInvalidArguments(attributes, promptType, target, report);
181
- this.validateName(attributes, report);
182
- this.validateDescription(attributes, report);
183
- this.validateArgumentHint(attributes, report);
184
- switch (promptType) {
185
- case PromptsType.prompt:
186
- {
187
- const agent = this.validateAgent(attributes, report);
188
- this.validateTools(attributes, agent?.kind ?? ChatModeKind.Agent, target, report);
189
- this.validateModel(attributes, agent?.kind ?? ChatModeKind.Agent, report);
190
- break;
191
- }
192
- case PromptsType.instructions:
193
- if (target === Target.Claude) {
194
- this.validatePaths(attributes, report);
195
- } else {
196
- this.validateApplyTo(attributes, report);
197
- }
198
- this.validateExcludeAgent(attributes, report);
199
- break;
200
- case PromptsType.agent:
201
- {
202
- this.validateTarget(attributes, report);
203
- this.validateInfer(attributes, report);
204
- this.validateUserInvokable(attributes, report);
205
- this.validateDisableModelInvocation(attributes, report);
206
- this.validateTools(attributes, ChatModeKind.Agent, target, report);
207
- if (isVSCodeOrDefaultTarget(target)) {
208
- this.validateModel(attributes, ChatModeKind.Agent, report);
209
- this.validateHandoffs(attributes, report);
210
- await this.validateAgentsAttribute(attributes, header, report);
211
- } else if (target === Target.Claude) {
212
- this.validateClaudeAttributes(attributes, report);
213
- }
214
- break;
215
- }
216
- case PromptsType.skill:
217
- this.validateUserInvokable(attributes, report);
218
- this.validateDisableModelInvocation(attributes, report);
219
- break;
220
- }
221
- }
222
- checkForInvalidArguments(attributes, promptType, target, report) {
223
- const validAttributeNames = getValidAttributeNames(promptType, true, target);
224
- const validGithubCopilotAttributeNames = ( new Lazy(() => ( new Set(getValidAttributeNames(promptType, false, Target.GitHubCopilot)))));
225
- for (const attribute of attributes) {
226
- if (!validAttributeNames.includes(attribute.key)) {
227
- const supportedNames = ( new Lazy(() => getValidAttributeNames(promptType, false, target).sort().join(", ")));
228
- switch (promptType) {
229
- case PromptsType.prompt:
230
- report(toMarker(( localize(
231
- 6440,
232
- "Attribute '{0}' is not supported in prompt files. Supported: {1}.",
233
- attribute.key,
234
- supportedNames.value
235
- )), attribute.range, MarkerSeverity.Warning));
236
- break;
237
- case PromptsType.agent:
238
- if (target === Target.GitHubCopilot) {
239
- report(toMarker(( localize(
240
- 6441,
241
- "Attribute '{0}' is not supported in custom GitHub Copilot agent files. Supported: {1}.",
242
- attribute.key,
243
- supportedNames.value
244
- )), attribute.range, MarkerSeverity.Warning));
245
- } else if (target === Target.Claude)
246
- ; else {
247
- if (( validGithubCopilotAttributeNames.value.has(attribute.key))) {
248
- report(toMarker(( localize(
249
- 6442,
250
- "Attribute '{0}' is ignored when running locally in VS Code.",
251
- attribute.key
252
- )), attribute.range, MarkerSeverity.Info));
253
- } else {
254
- report(toMarker(( localize(
255
- 6443,
256
- "Attribute '{0}' is not supported in VS Code agent files. Supported: {1}.",
257
- attribute.key,
258
- supportedNames.value
259
- )), attribute.range, MarkerSeverity.Warning));
260
- }
261
- }
262
- break;
263
- case PromptsType.instructions:
264
- if (target === Target.Claude) {
265
- report(toMarker(( localize(
266
- 6444,
267
- "Attribute '{0}' is not supported in rules files. Supported: {1}.",
268
- attribute.key,
269
- supportedNames.value
270
- )), attribute.range, MarkerSeverity.Warning));
271
- } else {
272
- report(toMarker(( localize(
273
- 6445,
274
- "Attribute '{0}' is not supported in instructions files. Supported: {1}.",
275
- attribute.key,
276
- supportedNames.value
277
- )), attribute.range, MarkerSeverity.Warning));
278
- }
279
- break;
280
- case PromptsType.skill:
281
- report(toMarker(( localize(
282
- 6446,
283
- "Attribute '{0}' is not supported in skill files. Supported: {1}.",
284
- attribute.key,
285
- supportedNames.value
286
- )), attribute.range, MarkerSeverity.Warning));
287
- break;
288
- }
289
- }
290
- }
291
- }
292
- validateName(attributes, report) {
293
- const nameAttribute = attributes.find(attr => attr.key === PromptHeaderAttributes.name);
294
- if (!nameAttribute) {
295
- return;
296
- }
297
- if (nameAttribute.value.type !== "string") {
298
- report(toMarker(( localize(6447, "The 'name' attribute must be a string.")), nameAttribute.range, MarkerSeverity.Error));
299
- return;
300
- }
301
- if (nameAttribute.value.value.trim().length === 0) {
302
- report(toMarker(( localize(6448, "The 'name' attribute must not be empty.")), nameAttribute.value.range, MarkerSeverity.Error));
303
- return;
304
- }
305
- }
306
- validateDescription(attributes, report) {
307
- const descriptionAttribute = attributes.find(attr => attr.key === PromptHeaderAttributes.description);
308
- if (!descriptionAttribute) {
309
- return;
310
- }
311
- if (descriptionAttribute.value.type !== "string") {
312
- report(toMarker(( localize(6449, "The 'description' attribute must be a string.")), descriptionAttribute.range, MarkerSeverity.Error));
313
- return;
314
- }
315
- if (descriptionAttribute.value.value.trim().length === 0) {
316
- report(toMarker(( localize(6450, "The 'description' attribute should not be empty.")), descriptionAttribute.value.range, MarkerSeverity.Error));
317
- return;
318
- }
319
- }
320
- validateArgumentHint(attributes, report) {
321
- const argumentHintAttribute = attributes.find(attr => attr.key === PromptHeaderAttributes.argumentHint);
322
- if (!argumentHintAttribute) {
323
- return;
324
- }
325
- if (argumentHintAttribute.value.type !== "string") {
326
- report(toMarker(( localize(6451, "The 'argument-hint' attribute must be a string.")), argumentHintAttribute.range, MarkerSeverity.Error));
327
- return;
328
- }
329
- if (argumentHintAttribute.value.value.trim().length === 0) {
330
- report(toMarker(( localize(6452, "The 'argument-hint' attribute should not be empty.")), argumentHintAttribute.value.range, MarkerSeverity.Error));
331
- return;
332
- }
333
- }
334
- validateModel(attributes, agentKind, report) {
335
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.model);
336
- if (!attribute) {
337
- return;
338
- }
339
- if (attribute.value.type !== "string" && attribute.value.type !== "array") {
340
- report(toMarker(( localize(6453, "The 'model' attribute must be a string or an array of strings.")), attribute.value.range, MarkerSeverity.Error));
341
- return;
342
- }
343
- const modelNames = [];
344
- if (attribute.value.type === "string") {
345
- const modelName = attribute.value.value.trim();
346
- if (modelName.length === 0) {
347
- report(toMarker(( localize(6454, "The 'model' attribute must be a non-empty string.")), attribute.value.range, MarkerSeverity.Error));
348
- return;
349
- }
350
- modelNames.push([modelName, attribute.value.range]);
351
- } else if (attribute.value.type === "array") {
352
- if (attribute.value.items.length === 0) {
353
- report(toMarker(( localize(6455, "The 'model' array must not be empty.")), attribute.value.range, MarkerSeverity.Error));
354
- return;
355
- }
356
- for (const item of attribute.value.items) {
357
- if (item.type !== "string") {
358
- report(toMarker(( localize(6456, "The 'model' array must contain only strings.")), item.range, MarkerSeverity.Error));
359
- return;
360
- }
361
- const modelName = item.value.trim();
362
- if (modelName.length === 0) {
363
- report(toMarker(( localize(6457, "Model names in the array must be non-empty strings.")), item.range, MarkerSeverity.Error));
364
- return;
365
- }
366
- modelNames.push([modelName, item.range]);
367
- }
368
- }
369
- const languageModels = this.languageModelsService.getLanguageModelIds();
370
- if (languageModels.length === 0) {
371
- return;
372
- }
373
- for (const [modelName, range] of modelNames) {
374
- const modelMetadata = this.findModelByName(modelName);
375
- if (!modelMetadata) {
376
- report(toMarker(( localize(6458, "Unknown model '{0}'.", modelName)), range, MarkerSeverity.Warning));
377
- } else if (agentKind === ChatModeKind.Agent && !ILanguageModelChatMetadata.suitableForAgentMode(modelMetadata)) {
378
- report(toMarker(( localize(6459, "Model '{0}' is not suited for agent mode.", modelName)), range, MarkerSeverity.Warning));
379
- }
380
- }
381
- }
382
- validateClaudeAttributes(attributes, report) {
383
- for (const claudeAttributeName in claudeAgentAttributes) {
384
- const claudeAttribute = claudeAgentAttributes[claudeAttributeName];
385
- const enumValues = claudeAttribute.enums;
386
- if (enumValues) {
387
- const attribute = attributes.find(attr => attr.key === claudeAttributeName);
388
- if (!attribute) {
389
- continue;
390
- }
391
- if (attribute.value.type !== "string") {
392
- report(toMarker(( localize(6460, "The '{0}' attribute must be a string.", claudeAttributeName)), attribute.value.range, MarkerSeverity.Error));
393
- continue;
394
- } else {
395
- const modelName = attribute.value.value.trim();
396
- if (enumValues.every(model => model.name !== modelName)) {
397
- const validValues = ( enumValues.map(model => model.name)).join(", ");
398
- report(toMarker(( localize(6461, "Unknown value '{0}', valid: {1}.", modelName, validValues)), attribute.value.range, MarkerSeverity.Warning));
399
- }
400
- }
401
- }
402
- }
403
- }
404
- findModelByName(modelName) {
405
- const metadata = this.languageModelsService.lookupLanguageModelByQualifiedName(modelName);
406
- if (metadata && metadata.isUserSelectable !== false) {
407
- return metadata;
408
- }
409
- return undefined;
410
- }
411
- validateAgent(attributes, report) {
412
- const agentAttribute = attributes.find(attr => attr.key === PromptHeaderAttributes.agent);
413
- const modeAttribute = attributes.find(attr => attr.key === PromptHeaderAttributes.mode);
414
- if (modeAttribute) {
415
- if (agentAttribute) {
416
- report(toMarker(( localize(
417
- 6462,
418
- "The 'mode' attribute has been deprecated. The 'agent' attribute is used instead."
419
- )), modeAttribute.range, MarkerSeverity.Warning));
420
- } else {
421
- report(toMarker(( localize(
422
- 6463,
423
- "The 'mode' attribute has been deprecated. Please rename it to 'agent'."
424
- )), modeAttribute.range, MarkerSeverity.Error));
425
- }
426
- }
427
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.agent) ?? modeAttribute;
428
- if (!attribute) {
429
- return undefined;
430
- }
431
- if (attribute.value.type !== "string") {
432
- report(toMarker(( localize(6464, "The '{0}' attribute must be a string.", attribute.key)), attribute.value.range, MarkerSeverity.Error));
433
- return undefined;
434
- }
435
- const agentValue = attribute.value.value;
436
- if (agentValue.trim().length === 0) {
437
- report(toMarker(( localize(6465, "The '{0}' attribute must be a non-empty string.", attribute.key)), attribute.value.range, MarkerSeverity.Error));
438
- return undefined;
439
- }
440
- return this.validateAgentValue(attribute.value, report);
441
- }
442
- validateAgentValue(value, report) {
443
- const agents = this.chatModeService.getModes();
444
- const availableAgents = [];
445
- for (const agent of Iterable.concat(agents.builtin, agents.custom)) {
446
- if (agent.name.get() === value.value) {
447
- return agent;
448
- }
449
- availableAgents.push(agent.name.get());
450
- }
451
- const errorMessage = ( localize(
452
- 6466,
453
- "Unknown agent '{0}'. Available agents: {1}.",
454
- value.value,
455
- availableAgents.join(", ")
456
- ));
457
- report(toMarker(errorMessage, value.range, MarkerSeverity.Warning));
458
- return undefined;
459
- }
460
- validateTools(attributes, agentKind, target, report) {
461
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.tools);
462
- if (!attribute) {
463
- return;
464
- }
465
- if (agentKind !== ChatModeKind.Agent) {
466
- report(toMarker(( localize(
467
- 6467,
468
- "The 'tools' attribute is only supported when using agents. Attribute will be ignored."
469
- )), attribute.range, MarkerSeverity.Warning));
470
- }
471
- let value = attribute.value;
472
- if (value.type === "string") {
473
- value = parseCommaSeparatedList(value);
474
- }
475
- if (value.type !== "array") {
476
- report(toMarker(( localize(
477
- 6468,
478
- "The 'tools' attribute must be an array or a comma separated string."
479
- )), attribute.value.range, MarkerSeverity.Error));
480
- return;
481
- }
482
- if (target === Target.GitHubCopilot || target === Target.Claude)
483
- ; else {
484
- this.validateVSCodeTools(value, report);
485
- }
486
- }
487
- validateVSCodeTools(valueItem, report) {
488
- if (valueItem.items.length > 0) {
489
- const available = ( new Set(this.languageModelToolsService.getFullReferenceNames()));
490
- const deprecatedNames = this.languageModelToolsService.getDeprecatedFullReferenceNames();
491
- for (const item of valueItem.items) {
492
- if (item.type !== "string") {
493
- report(toMarker(( localize(6469, "Each tool name in the 'tools' attribute must be a string.")), item.range, MarkerSeverity.Error));
494
- } else if (item.value) {
495
- if (!( available.has(item.value))) {
496
- const currentNames = deprecatedNames.get(item.value);
497
- if (currentNames) {
498
- if (currentNames?.size === 1) {
499
- const newName = Array.from(currentNames)[0];
500
- report(toMarker(( localize(
501
- 6470,
502
- "Tool or toolset '{0}' has been renamed, use '{1}' instead.",
503
- item.value,
504
- newName
505
- )), item.range, MarkerSeverity.Info));
506
- } else {
507
- const newNames = Array.from(currentNames).sort((a, b) => a.localeCompare(b)).join(", ");
508
- report(toMarker(( localize(
509
- 6471,
510
- "Tool or toolset '{0}' has been renamed, use the following tools instead: {1}",
511
- item.value,
512
- newNames
513
- )), item.range, MarkerSeverity.Info));
514
- }
515
- } else {
516
- report(toMarker(( localize(6472, "Unknown tool '{0}'.", item.value)), item.range, MarkerSeverity.Warning));
517
- }
518
- }
519
- }
520
- }
521
- }
522
- }
523
- validateApplyTo(attributes, report) {
524
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.applyTo);
525
- if (!attribute) {
526
- return;
527
- }
528
- if (attribute.value.type !== "string") {
529
- report(toMarker(( localize(6473, "The 'applyTo' attribute must be a string.")), attribute.value.range, MarkerSeverity.Error));
530
- return;
531
- }
532
- const pattern = attribute.value.value;
533
- try {
534
- const patterns = splitGlobAware(pattern, ",");
535
- if (patterns.length === 0) {
536
- report(toMarker(( localize(6474, "The 'applyTo' attribute must be a valid glob pattern.")), attribute.value.range, MarkerSeverity.Error));
537
- return;
538
- }
539
- for (const pattern of patterns) {
540
- const globPattern = parse(pattern);
541
- if (isEmptyPattern(globPattern)) {
542
- report(toMarker(( localize(6474, "The 'applyTo' attribute must be a valid glob pattern.")), attribute.value.range, MarkerSeverity.Error));
543
- return;
544
- }
545
- }
546
- } catch (_error) {
547
- report(toMarker(( localize(6474, "The 'applyTo' attribute must be a valid glob pattern.")), attribute.value.range, MarkerSeverity.Error));
548
- }
549
- }
550
- validatePaths(attributes, report) {
551
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.paths);
552
- if (!attribute) {
553
- return;
554
- }
555
- if (attribute.value.type !== "array") {
556
- report(toMarker(( localize(6475, "The 'paths' attribute must be an array of glob patterns.")), attribute.value.range, MarkerSeverity.Error));
557
- return;
558
- }
559
- for (const item of attribute.value.items) {
560
- if (item.type !== "string") {
561
- report(toMarker(( localize(6476, "Each entry in the 'paths' attribute must be a string.")), item.range, MarkerSeverity.Error));
562
- continue;
563
- }
564
- const pattern = item.value.trim();
565
- if (pattern.length === 0) {
566
- report(toMarker(( localize(6477, "Path entries must be non-empty glob patterns.")), item.range, MarkerSeverity.Error));
567
- continue;
568
- }
569
- try {
570
- const globPattern = parse(pattern);
571
- if (isEmptyPattern(globPattern)) {
572
- report(toMarker(( localize(6478, "'{0}' is not a valid glob pattern.", pattern)), item.range, MarkerSeverity.Error));
573
- }
574
- } catch (_error) {
575
- report(toMarker(( localize(6478, "'{0}' is not a valid glob pattern.", pattern)), item.range, MarkerSeverity.Error));
576
- }
577
- }
578
- }
579
- validateExcludeAgent(attributes, report) {
580
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.excludeAgent);
581
- if (!attribute) {
582
- return;
583
- }
584
- if (attribute.value.type !== "array" && attribute.value.type !== "string") {
585
- report(toMarker(( localize(6479, "The 'excludeAgent' attribute must be an string or array.")), attribute.value.range, MarkerSeverity.Error));
586
- return;
587
- }
588
- }
589
- validateHandoffs(attributes, report) {
590
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.handOffs);
591
- if (!attribute) {
592
- return;
593
- }
594
- if (attribute.value.type !== "array") {
595
- report(toMarker(( localize(6480, "The 'handoffs' attribute must be an array.")), attribute.value.range, MarkerSeverity.Error));
596
- return;
597
- }
598
- for (const item of attribute.value.items) {
599
- if (item.type !== "object") {
600
- report(toMarker(( localize(
601
- 6481,
602
- "Each handoff in the 'handoffs' attribute must be an object with 'label', 'agent', 'prompt' and optional 'send'."
603
- )), item.range, MarkerSeverity.Error));
604
- continue;
605
- }
606
- const required = ( new Set(["label", "agent", "prompt"]));
607
- for (const prop of item.properties) {
608
- switch (prop.key.value) {
609
- case "label":
610
- if (prop.value.type !== "string" || prop.value.value.trim().length === 0) {
611
- report(toMarker(( localize(6482, "The 'label' property in a handoff must be a non-empty string.")), prop.value.range, MarkerSeverity.Error));
612
- }
613
- break;
614
- case "agent":
615
- if (prop.value.type !== "string" || prop.value.value.trim().length === 0) {
616
- report(toMarker(( localize(6483, "The 'agent' property in a handoff must be a non-empty string.")), prop.value.range, MarkerSeverity.Error));
617
- } else {
618
- this.validateAgentValue(prop.value, report);
619
- }
620
- break;
621
- case "prompt":
622
- if (prop.value.type !== "string") {
623
- report(toMarker(( localize(6484, "The 'prompt' property in a handoff must be a string.")), prop.value.range, MarkerSeverity.Error));
624
- }
625
- break;
626
- case "send":
627
- if (prop.value.type !== "boolean") {
628
- report(toMarker(( localize(6485, "The 'send' property in a handoff must be a boolean.")), prop.value.range, MarkerSeverity.Error));
629
- }
630
- break;
631
- case "showContinueOn":
632
- if (prop.value.type !== "boolean") {
633
- report(toMarker(( localize(6486, "The 'showContinueOn' property in a handoff must be a boolean.")), prop.value.range, MarkerSeverity.Error));
634
- }
635
- break;
636
- case "model":
637
- if (prop.value.type !== "string") {
638
- report(toMarker(( localize(6487, "The 'model' property in a handoff must be a string.")), prop.value.range, MarkerSeverity.Error));
639
- }
640
- break;
641
- default:
642
- report(toMarker(( localize(
643
- 6488,
644
- "Unknown property '{0}' in handoff object. Supported properties are 'label', 'agent', 'prompt' and optional 'send', 'showContinueOn', 'model'.",
645
- prop.key.value
646
- )), prop.value.range, MarkerSeverity.Warning));
647
- }
648
- required.delete(prop.key.value);
649
- }
650
- if (required.size > 0) {
651
- report(toMarker(( localize(
652
- 6489,
653
- "Missing required properties {0} in handoff object.",
654
- ( Array.from(required).map(s => `'${s}'`)).join(", ")
655
- )), item.range, MarkerSeverity.Error));
656
- }
657
- }
658
- }
659
- validateInfer(attributes, report) {
660
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.infer);
661
- if (!attribute) {
662
- return;
663
- }
664
- report(toMarker(( localize(
665
- 6490,
666
- "The 'infer' attribute is deprecated in favour of 'user-invokable' and 'disable-model-invocation'."
667
- )), attribute.value.range, MarkerSeverity.Error));
668
- }
669
- validateTarget(attributes, report) {
670
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.target);
671
- if (!attribute) {
672
- return;
673
- }
674
- if (attribute.value.type !== "string") {
675
- report(toMarker(( localize(6491, "The 'target' attribute must be a string.")), attribute.value.range, MarkerSeverity.Error));
676
- return;
677
- }
678
- const targetValue = attribute.value.value.trim();
679
- if (targetValue.length === 0) {
680
- report(toMarker(( localize(6492, "The 'target' attribute must be a non-empty string.")), attribute.value.range, MarkerSeverity.Error));
681
- return;
682
- }
683
- const validTargets = ["github-copilot", "vscode"];
684
- if (!validTargets.includes(targetValue)) {
685
- report(toMarker(( localize(
686
- 6493,
687
- "The 'target' attribute must be one of: {0}.",
688
- validTargets.join(", ")
689
- )), attribute.value.range, MarkerSeverity.Error));
690
- }
691
- }
692
- validateUserInvokable(attributes, report) {
693
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.userInvokable);
694
- if (!attribute) {
695
- return;
696
- }
697
- if (attribute.value.type !== "boolean") {
698
- report(toMarker(( localize(6494, "The 'user-invokable' attribute must be a boolean.")), attribute.value.range, MarkerSeverity.Error));
699
- return;
700
- }
701
- }
702
- validateDisableModelInvocation(attributes, report) {
703
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.disableModelInvocation);
704
- if (!attribute) {
705
- return;
706
- }
707
- if (attribute.value.type !== "boolean") {
708
- report(toMarker(( localize(6495, "The 'disable-model-invocation' attribute must be a boolean.")), attribute.value.range, MarkerSeverity.Error));
709
- return;
710
- }
711
- }
712
- async validateAgentsAttribute(attributes, header, report) {
713
- const attribute = attributes.find(attr => attr.key === PromptHeaderAttributes.agents);
714
- if (!attribute) {
715
- return;
716
- }
717
- if (attribute.value.type !== "array") {
718
- report(toMarker(( localize(6496, "The 'agents' attribute must be an array.")), attribute.value.range, MarkerSeverity.Error));
719
- return;
720
- }
721
- const agents = await this.promptsService.getCustomAgents(CancellationToken.None);
722
- const availableAgentNames = ( new Set(( agents.map(agent => agent.name))));
723
- availableAgentNames.add(ChatMode.Agent.name.get());
724
- const agentNames = [];
725
- for (const item of attribute.value.items) {
726
- if (item.type !== "string") {
727
- report(toMarker(( localize(6497, "Each agent name in the 'agents' attribute must be a string.")), item.range, MarkerSeverity.Error));
728
- } else if (item.value) {
729
- agentNames.push(item.value);
730
- if (item.value !== "*" && !( availableAgentNames.has(item.value))) {
731
- report(toMarker(( localize(
732
- 6498,
733
- "Unknown agent '{0}'. Available agents: {1}.",
734
- item.value,
735
- Array.from(availableAgentNames).join(", ")
736
- )), item.range, MarkerSeverity.Warning));
737
- }
738
- }
739
- }
740
- if (agentNames.length > 0) {
741
- const tools = header.tools;
742
- if (tools && !tools.includes(SpecedToolAliases.agent)) {
743
- report(toMarker(( localize(
744
- 6499,
745
- "When 'agents' and 'tools' are specified, the 'agent' tool must be included in the 'tools' attribute."
746
- )), attribute.value.range, MarkerSeverity.Warning));
747
- }
748
- }
749
- }
750
- };
751
- PromptValidator = ( __decorate([( __param(0, ILanguageModelsService)), ( __param(1, ILanguageModelToolsService)), ( __param(2, IChatModeService)), ( __param(3, IFileService)), ( __param(4, ILabelService)), ( __param(5, IPromptsService))], PromptValidator));
752
- const allAttributeNames = {
753
- [PromptsType.prompt]: [
754
- PromptHeaderAttributes.name,
755
- PromptHeaderAttributes.description,
756
- PromptHeaderAttributes.model,
757
- PromptHeaderAttributes.tools,
758
- PromptHeaderAttributes.mode,
759
- PromptHeaderAttributes.agent,
760
- PromptHeaderAttributes.argumentHint
761
- ],
762
- [PromptsType.instructions]: [
763
- PromptHeaderAttributes.name,
764
- PromptHeaderAttributes.description,
765
- PromptHeaderAttributes.applyTo,
766
- PromptHeaderAttributes.excludeAgent
767
- ],
768
- [PromptsType.agent]: [
769
- PromptHeaderAttributes.name,
770
- PromptHeaderAttributes.description,
771
- PromptHeaderAttributes.model,
772
- PromptHeaderAttributes.tools,
773
- PromptHeaderAttributes.advancedOptions,
774
- PromptHeaderAttributes.handOffs,
775
- PromptHeaderAttributes.argumentHint,
776
- PromptHeaderAttributes.target,
777
- PromptHeaderAttributes.infer,
778
- PromptHeaderAttributes.agents,
779
- PromptHeaderAttributes.userInvokable,
780
- PromptHeaderAttributes.disableModelInvocation
781
- ],
782
- [PromptsType.skill]: [
783
- PromptHeaderAttributes.name,
784
- PromptHeaderAttributes.description,
785
- PromptHeaderAttributes.license,
786
- PromptHeaderAttributes.compatibility,
787
- PromptHeaderAttributes.metadata,
788
- PromptHeaderAttributes.argumentHint,
789
- PromptHeaderAttributes.userInvokable,
790
- PromptHeaderAttributes.disableModelInvocation
791
- ],
792
- [PromptsType.hook]: []
793
- };
794
- const githubCopilotAgentAttributeNames = [
795
- PromptHeaderAttributes.name,
796
- PromptHeaderAttributes.description,
797
- PromptHeaderAttributes.tools,
798
- PromptHeaderAttributes.target,
799
- GithubPromptHeaderAttributes.mcpServers,
800
- PromptHeaderAttributes.infer
801
- ];
802
- const recommendedAttributeNames = {
803
- [PromptsType.prompt]: allAttributeNames[PromptsType.prompt].filter(name => !isNonRecommendedAttribute(name)),
804
- [PromptsType.instructions]: allAttributeNames[PromptsType.instructions].filter(name => !isNonRecommendedAttribute(name)),
805
- [PromptsType.agent]: allAttributeNames[PromptsType.agent].filter(name => !isNonRecommendedAttribute(name)),
806
- [PromptsType.skill]: allAttributeNames[PromptsType.skill].filter(name => !isNonRecommendedAttribute(name)),
807
- [PromptsType.hook]: []
808
- };
809
- function getValidAttributeNames(promptType, includeNonRecommended, target) {
810
- if (target === Target.Claude) {
811
- if (promptType === PromptsType.instructions) {
812
- return ( Object.keys(claudeRulesAttributes));
813
- }
814
- return ( Object.keys(claudeAgentAttributes));
815
- } else if (target === Target.GitHubCopilot) {
816
- if (promptType === PromptsType.agent) {
817
- return githubCopilotAgentAttributeNames;
818
- }
819
- }
820
- return includeNonRecommended ? allAttributeNames[promptType] : recommendedAttributeNames[promptType];
821
- }
822
- function isNonRecommendedAttribute(attributeName) {
823
- return attributeName === PromptHeaderAttributes.advancedOptions || attributeName === PromptHeaderAttributes.excludeAgent || attributeName === PromptHeaderAttributes.mode || attributeName === PromptHeaderAttributes.infer;
824
- }
825
- function getAttributeDescription(attributeName, promptType, target) {
826
- if (target === Target.Claude) {
827
- if (promptType === PromptsType.agent) {
828
- return claudeAgentAttributes[attributeName]?.description;
829
- }
830
- if (promptType === PromptsType.instructions) {
831
- return claudeRulesAttributes[attributeName]?.description;
832
- }
833
- }
834
- switch (promptType) {
835
- case PromptsType.instructions:
836
- switch (attributeName) {
837
- case PromptHeaderAttributes.name:
838
- return localize(
839
- 6500,
840
- "The name of the instruction file as shown in the UI. If not set, the name is derived from the file name."
841
- );
842
- case PromptHeaderAttributes.description:
843
- return localize(
844
- 6501,
845
- "The description of the instruction file. It can be used to provide additional context or information about the instructions and is passed to the language model as part of the prompt."
846
- );
847
- case PromptHeaderAttributes.applyTo:
848
- return localize(
849
- 6502,
850
- "One or more glob pattern (separated by comma) that describe for which files the instructions apply to. Based on these patterns, the file is automatically included in the prompt, when the context contains a file that matches one or more of these patterns. Use `**` when you want this file to always be added.\nExample: `**/*.ts`, `**/*.js`, `client/**`"
851
- );
852
- }
853
- break;
854
- case PromptsType.skill:
855
- switch (attributeName) {
856
- case PromptHeaderAttributes.name:
857
- return localize(6503, "The name of the skill.");
858
- case PromptHeaderAttributes.description:
859
- return localize(
860
- 6504,
861
- "The description of the skill. The description is added to every request and will be used by the agent to decide when to load the skill."
862
- );
863
- case PromptHeaderAttributes.argumentHint:
864
- return localize(
865
- 6505,
866
- "Hint shown during autocomplete to indicate expected arguments. Example: [issue-number] or [filename] [format]"
867
- );
868
- case PromptHeaderAttributes.userInvokable:
869
- return localize(
870
- 6506,
871
- "Set to false to hide from the / menu. Use for background knowledge users should not invoke directly. Default: true."
872
- );
873
- case PromptHeaderAttributes.disableModelInvocation:
874
- return localize(
875
- 6507,
876
- "Set to true to prevent the agent from automatically loading this skill. Use for workflows you want to trigger manually with /name. Default: false."
877
- );
878
- }
879
- break;
880
- case PromptsType.agent:
881
- switch (attributeName) {
882
- case PromptHeaderAttributes.name:
883
- return localize(6508, "The name of the agent as shown in the UI.");
884
- case PromptHeaderAttributes.description:
885
- return localize(
886
- 6509,
887
- "The description of the custom agent, what it does and when to use it."
888
- );
889
- case PromptHeaderAttributes.argumentHint:
890
- return localize(
891
- 6510,
892
- "The argument-hint describes what inputs the custom agent expects or supports."
893
- );
894
- case PromptHeaderAttributes.model:
895
- return localize(
896
- 6511,
897
- "Specify the model that runs this custom agent. Can also be a list of models. The first available model will be used."
898
- );
899
- case PromptHeaderAttributes.tools:
900
- return localize(6512, "The set of tools that the custom agent has access to.");
901
- case PromptHeaderAttributes.handOffs:
902
- return localize(6513, "Possible handoff actions when the agent has completed its task.");
903
- case PromptHeaderAttributes.target:
904
- return localize(
905
- 6514,
906
- "The target to which the header attributes like tools apply to. Possible values are `github-copilot` and `vscode`."
907
- );
908
- case PromptHeaderAttributes.infer:
909
- return localize(6515, "Controls visibility of the agent.");
910
- case PromptHeaderAttributes.agents:
911
- return localize(
912
- 6516,
913
- "One or more agents that this agent can use as subagents. Use '*' to specify all available agents."
914
- );
915
- case PromptHeaderAttributes.userInvokable:
916
- return localize(6517, "Whether the agent can be selected and invoked by users in the UI.");
917
- case PromptHeaderAttributes.disableModelInvocation:
918
- return localize(6518, "If true, prevents the agent from being invoked as a subagent.");
919
- }
920
- break;
921
- case PromptsType.prompt:
922
- switch (attributeName) {
923
- case PromptHeaderAttributes.name:
924
- return localize(
925
- 6519,
926
- "The name of the prompt. This is also the name of the slash command that will run this prompt."
927
- );
928
- case PromptHeaderAttributes.description:
929
- return localize(
930
- 6520,
931
- "The description of the reusable prompt, what it does and when to use it."
932
- );
933
- case PromptHeaderAttributes.argumentHint:
934
- return localize(
935
- 6521,
936
- "The argument-hint describes what inputs the prompt expects or supports."
937
- );
938
- case PromptHeaderAttributes.model:
939
- return localize(
940
- 6522,
941
- "The model to use in this prompt. Can also be a list of models. The first available model will be used."
942
- );
943
- case PromptHeaderAttributes.tools:
944
- return localize(6523, "The tools to use in this prompt.");
945
- case PromptHeaderAttributes.agent:
946
- case PromptHeaderAttributes.mode:
947
- return localize(6524, "The agent to use when running this prompt.");
948
- }
949
- break;
950
- }
951
- return undefined;
952
- }
953
- const knownGithubCopilotTools = [{
954
- name: SpecedToolAliases.execute,
955
- description: ( localize(6525, "Execute commands"))
956
- }, {
957
- name: SpecedToolAliases.read,
958
- description: ( localize(6526, "Read files"))
959
- }, {
960
- name: SpecedToolAliases.edit,
961
- description: ( localize(6527, "Edit files"))
962
- }, {
963
- name: SpecedToolAliases.search,
964
- description: ( localize(6528, "Search files"))
965
- }, {
966
- name: SpecedToolAliases.agent,
967
- description: ( localize(6529, "Use subagents"))
968
- }];
969
- const knownClaudeTools = [{
970
- name: "Bash",
971
- description: ( localize(6530, "Execute shell commands")),
972
- toolEquivalent: [SpecedToolAliases.execute]
973
- }, {
974
- name: "Edit",
975
- description: ( localize(6531, "Make targeted file edits")),
976
- toolEquivalent: ["edit/editNotebook", "edit/editFiles"]
977
- }, {
978
- name: "Glob",
979
- description: ( localize(6532, "Find files by pattern")),
980
- toolEquivalent: ["search/fileSearch"]
981
- }, {
982
- name: "Grep",
983
- description: ( localize(6533, "Search file contents with regex")),
984
- toolEquivalent: ["search/textSearch"]
985
- }, {
986
- name: "Read",
987
- description: ( localize(6534, "Read file contents")),
988
- toolEquivalent: ["read/readFile", "read/getNotebookSummary"]
989
- }, {
990
- name: "Write",
991
- description: ( localize(6535, "Create/overwrite files")),
992
- toolEquivalent: ["edit/createDirectory", "edit/createFile", "edit/createJupyterNotebook"]
993
- }, {
994
- name: "WebFetch",
995
- description: ( localize(6536, "Fetch URL content")),
996
- toolEquivalent: [SpecedToolAliases.web]
997
- }, {
998
- name: "WebSearch",
999
- description: ( localize(6537, "Perform web searches")),
1000
- toolEquivalent: [SpecedToolAliases.web]
1001
- }, {
1002
- name: "Task",
1003
- description: ( localize(6538, "Run subagents for complex tasks")),
1004
- toolEquivalent: [SpecedToolAliases.agent]
1005
- }, {
1006
- name: "Skill",
1007
- description: ( localize(6539, "Execute skills")),
1008
- toolEquivalent: []
1009
- }, {
1010
- name: "LSP",
1011
- description: ( localize(6540, "Code intelligence (requires plugin)")),
1012
- toolEquivalent: []
1013
- }, {
1014
- name: "NotebookEdit",
1015
- description: ( localize(6541, "Modify Jupyter notebooks")),
1016
- toolEquivalent: ["edit/editNotebook"]
1017
- }, {
1018
- name: "AskUserQuestion",
1019
- description: ( localize(6542, "Ask multiple-choice questions")),
1020
- toolEquivalent: ["vscode/askQuestions"]
1021
- }, {
1022
- name: "MCPSearch",
1023
- description: ( localize(6543, "Searches for MCP tools when tool search is enabled")),
1024
- toolEquivalent: []
1025
- }];
1026
- const knownClaudeModels = [{
1027
- name: "sonnet",
1028
- description: ( localize(6544, "Latest Claude Sonnet")),
1029
- modelEquivalent: "Claude Sonnet 4.5 (copilot)"
1030
- }, {
1031
- name: "opus",
1032
- description: ( localize(6545, "Latest Claude Opus")),
1033
- modelEquivalent: "Claude Opus 4.6 (copilot)"
1034
- }, {
1035
- name: "haiku",
1036
- description: ( localize(6546, "Latest Claude Haiku, fast for simple tasks")),
1037
- modelEquivalent: "Claude Haiku 4.5 (copilot)"
1038
- }, {
1039
- name: "inherit",
1040
- description: ( localize(6547, "Inherit model from parent agent or prompt")),
1041
- modelEquivalent: undefined
1042
- }];
1043
- function mapClaudeModels(claudeModelNames) {
1044
- const result = [];
1045
- for (const name of claudeModelNames) {
1046
- const claudeModel = knownClaudeModels.find(model => model.name === name);
1047
- if (claudeModel && claudeModel.modelEquivalent) {
1048
- result.push(claudeModel.modelEquivalent);
1049
- }
1050
- }
1051
- return result;
1052
- }
1053
- function mapClaudeTools(claudeToolNames) {
1054
- const result = [];
1055
- for (const name of claudeToolNames) {
1056
- const claudeTool = knownClaudeTools.find(tool => tool.name === name);
1057
- if (claudeTool) {
1058
- result.push(...claudeTool.toolEquivalent);
1059
- }
1060
- }
1061
- return result;
1062
- }
1063
- const claudeAgentAttributes = {
1064
- "name": {
1065
- type: "string",
1066
- description: ( localize(6548, "Unique identifier using lowercase letters and hyphens (required)"))
1067
- },
1068
- "description": {
1069
- type: "string",
1070
- description: ( localize(6549, "When to delegate to this subagent (required)"))
1071
- },
1072
- "tools": {
1073
- type: "array",
1074
- description: ( localize(6550, "Array of tools the subagent can use. Inherits all tools if omitted")),
1075
- defaults: ["Read, Edit, Bash"],
1076
- items: knownClaudeTools
1077
- },
1078
- "disallowedTools": {
1079
- type: "array",
1080
- description: ( localize(6551, "Tools to deny, removed from inherited or specified list")),
1081
- defaults: ["Write, Edit, Bash"],
1082
- items: knownClaudeTools
1083
- },
1084
- "model": {
1085
- type: "string",
1086
- description: ( localize(
1087
- 6552,
1088
- "Model to use: sonnet, opus, haiku, or inherit. Defaults to inherit."
1089
- )),
1090
- defaults: ["sonnet", "opus", "haiku", "inherit"],
1091
- enums: knownClaudeModels
1092
- },
1093
- "permissionMode": {
1094
- type: "string",
1095
- description: ( localize(
1096
- 6553,
1097
- "Permission mode: default, acceptEdits, dontAsk, bypassPermissions, or plan."
1098
- )),
1099
- defaults: ["default", "acceptEdits", "dontAsk", "bypassPermissions", "plan"],
1100
- enums: [{
1101
- name: "default",
1102
- description: ( localize(
1103
- 6554,
1104
- "Standard behavior: prompts for permission on first use of each tool."
1105
- ))
1106
- }, {
1107
- name: "acceptEdits",
1108
- description: ( localize(6555, "Automatically accepts file edit permissions for the session."))
1109
- }, {
1110
- name: "plan",
1111
- description: ( localize(
1112
- 6556,
1113
- "Plan Mode: Claude can analyze but not modify files or execute commands."
1114
- ))
1115
- }, {
1116
- name: "delegate",
1117
- description: ( localize(
1118
- 6557,
1119
- "Coordination-only mode for agent team leads. Only available when an agent team is active."
1120
- ))
1121
- }, {
1122
- name: "dontAsk",
1123
- description: ( localize(
1124
- 6558,
1125
- "Auto-denies tools unless pre-approved via /permissions or permissions.allow rules."
1126
- ))
1127
- }, {
1128
- name: "bypassPermissions",
1129
- description: ( localize(
1130
- 6559,
1131
- "Skips all permission prompts (requires safe environment like containers)."
1132
- ))
1133
- }]
1134
- },
1135
- "skills": {
1136
- type: "array",
1137
- description: ( localize(6560, "Skills to load into the subagent's context at startup."))
1138
- },
1139
- "mcpServers": {
1140
- type: "array",
1141
- description: ( localize(6561, "MCP servers available to this subagent."))
1142
- },
1143
- "hooks": {
1144
- type: "object",
1145
- description: ( localize(6562, "Lifecycle hooks scoped to this subagent."))
1146
- },
1147
- "memory": {
1148
- type: "string",
1149
- description: ( localize(
1150
- 6563,
1151
- "Persistent memory scope: user, project, or local. Enables cross-session learning."
1152
- )),
1153
- defaults: ["user", "project", "local"],
1154
- enums: [{
1155
- name: "user",
1156
- description: ( localize(6564, "Remember learnings across all projects."))
1157
- }, {
1158
- name: "project",
1159
- description: ( localize(
1160
- 6565,
1161
- "The subagent's knowledge is project-specific and shareable via version control."
1162
- ))
1163
- }, {
1164
- name: "local",
1165
- description: ( localize(
1166
- 6566,
1167
- "The subagent's knowledge is project-specific but should not be checked into version control."
1168
- ))
1169
- }]
1170
- }
1171
- };
1172
- const claudeRulesAttributes = {
1173
- "description": {
1174
- type: "string",
1175
- description: ( localize(
1176
- 6567,
1177
- "A description of what this rule covers, used to provide context about when it applies."
1178
- ))
1179
- },
1180
- "paths": {
1181
- type: "array",
1182
- description: ( localize(
1183
- 6568,
1184
- "Array of glob patterns that describe for which files the rule applies. Based on these patterns, the file is automatically included in the prompt when the context contains a file that matches.\nExample: `['src/**/*.ts', 'test/**']`"
1185
- ))
1186
- }
1187
- };
1188
- function isVSCodeOrDefaultTarget(target) {
1189
- return target === Target.VSCode || target === Target.Undefined;
1190
- }
1191
- function getTarget(promptType, header) {
1192
- const uri = header instanceof URI ? header : header.uri;
1193
- if (promptType === PromptsType.agent) {
1194
- const parentDir = dirname(uri);
1195
- if (parentDir.path.endsWith(`/${CLAUDE_AGENTS_SOURCE_FOLDER}`)) {
1196
- return Target.Claude;
1197
- }
1198
- if (!(header instanceof URI)) {
1199
- const target = header.target;
1200
- if (target === Target.GitHubCopilot || target === Target.VSCode) {
1201
- return target;
1202
- }
1203
- }
1204
- return Target.Undefined;
1205
- } else if (promptType === PromptsType.instructions) {
1206
- if (isInClaudeRulesFolder(uri)) {
1207
- return Target.Claude;
1208
- }
1209
- }
1210
- return Target.Undefined;
1211
- }
1212
- function toMarker(message, range, severity = MarkerSeverity.Error) {
1213
- return {
1214
- severity,
1215
- message,
1216
- ...range
1217
- };
1218
- }
1219
- let PromptValidatorContribution = class PromptValidatorContribution extends Disposable {
1220
- constructor(
1221
- modelService,
1222
- instantiationService,
1223
- markerService,
1224
- promptsService,
1225
- languageModelsService,
1226
- languageModelToolsService,
1227
- chatModeService
1228
- ) {
1229
- super();
1230
- this.modelService = modelService;
1231
- this.markerService = markerService;
1232
- this.promptsService = promptsService;
1233
- this.languageModelsService = languageModelsService;
1234
- this.languageModelToolsService = languageModelToolsService;
1235
- this.chatModeService = chatModeService;
1236
- this.localDisposables = this._register(( new DisposableStore()));
1237
- this.validator = instantiationService.createInstance(PromptValidator);
1238
- this.updateRegistration();
1239
- }
1240
- updateRegistration() {
1241
- this.localDisposables.clear();
1242
- const trackers = ( new ResourceMap());
1243
- this.localDisposables.add(toDisposable(() => {
1244
- trackers.forEach(tracker => tracker.dispose());
1245
- trackers.clear();
1246
- }));
1247
- this.modelService.getModels().forEach(model => {
1248
- const promptType = getPromptsTypeForLanguageId(model.getLanguageId());
1249
- if (promptType) {
1250
- trackers.set(model.uri, ( new ModelTracker(model, promptType, this.validator, this.promptsService, this.markerService)));
1251
- }
1252
- });
1253
- this.localDisposables.add(this.modelService.onModelAdded(model => {
1254
- const promptType = getPromptsTypeForLanguageId(model.getLanguageId());
1255
- if (promptType && !( trackers.has(model.uri))) {
1256
- trackers.set(model.uri, ( new ModelTracker(model, promptType, this.validator, this.promptsService, this.markerService)));
1257
- }
1258
- }));
1259
- this.localDisposables.add(this.modelService.onModelRemoved(model => {
1260
- const tracker = trackers.get(model.uri);
1261
- if (tracker) {
1262
- tracker.dispose();
1263
- trackers.delete(model.uri);
1264
- }
1265
- }));
1266
- this.localDisposables.add(this.modelService.onModelLanguageChanged(event => {
1267
- const {
1268
- model
1269
- } = event;
1270
- const tracker = trackers.get(model.uri);
1271
- if (tracker) {
1272
- tracker.dispose();
1273
- trackers.delete(model.uri);
1274
- }
1275
- const promptType = getPromptsTypeForLanguageId(model.getLanguageId());
1276
- if (promptType) {
1277
- trackers.set(model.uri, ( new ModelTracker(model, promptType, this.validator, this.promptsService, this.markerService)));
1278
- }
1279
- }));
1280
- const validateAll = () => trackers.forEach(tracker => tracker.validate());
1281
- this.localDisposables.add(this.languageModelToolsService.onDidChangeTools(() => validateAll()));
1282
- this.localDisposables.add(this.chatModeService.onDidChangeChatModes(() => validateAll()));
1283
- this.localDisposables.add(this.languageModelsService.onDidChangeLanguageModels(() => validateAll()));
1284
- }
1285
- };
1286
- PromptValidatorContribution = ( __decorate([( __param(0, IModelService)), ( __param(1, IInstantiationService)), ( __param(2, IMarkerService)), ( __param(3, IPromptsService)), ( __param(4, ILanguageModelsService)), ( __param(5, ILanguageModelToolsService)), ( __param(6, IChatModeService))], PromptValidatorContribution));
1287
- let ModelTracker = class ModelTracker extends Disposable {
1288
- constructor(textModel, promptType, validator, promptsService, markerService) {
1289
- super();
1290
- this.textModel = textModel;
1291
- this.promptType = promptType;
1292
- this.validator = validator;
1293
- this.promptsService = promptsService;
1294
- this.markerService = markerService;
1295
- this.delayer = this._register(( new Delayer(200)));
1296
- this._register(textModel.onDidChangeContent(() => this.validate()));
1297
- this.validate();
1298
- }
1299
- validate() {
1300
- this.delayer.trigger(async () => {
1301
- const markers = [];
1302
- const ast = this.promptsService.getParsedPromptFile(this.textModel);
1303
- await this.validator.validate(ast, this.promptType, m => markers.push(m));
1304
- this.markerService.changeOne(MARKERS_OWNER_ID, this.textModel.uri, markers);
1305
- });
1306
- }
1307
- dispose() {
1308
- this.markerService.remove(MARKERS_OWNER_ID, [this.textModel.uri]);
1309
- super.dispose();
1310
- }
1311
- };
1312
- ModelTracker = ( __decorate([( __param(3, IPromptsService)), ( __param(4, IMarkerService))], ModelTracker));
1313
-
1314
- export { MARKERS_OWNER_ID, PromptValidator, PromptValidatorContribution, claudeAgentAttributes, claudeRulesAttributes, getAttributeDescription, getTarget, getValidAttributeNames, isNonRecommendedAttribute, isVSCodeOrDefaultTarget, knownClaudeModels, knownClaudeTools, knownGithubCopilotTools, mapClaudeModels, mapClaudeTools };