extensionPromptFileService.ts ×12

Frontier kind: Code frontier

unlabeled · c_500b5e20bb11

6 tests · 69168 LOC · 326 files · introduces 0 tests · 38 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges38 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
7016 ranges69168 lines · 326 files · Browse complete extent
All tests (intent)
6 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 38 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/promptSyntax/service/extensionPromptFileService.ts 38 introduced LOC · 12 ranges

Open complete file

163 // For skills, validate that the file follows the required structure
164 if (type === PromptsType.skill) {
166 > const validated = await this._validateAndSanitizeSkillFile(uri, CancellationToken.None);
167 > name = validated.name;
168 > description = validated.description;
169 > } catch (e) {
170 const msg = e instanceof Error ? e.message : String(e);
171 this.logger.error(`[registerContributedFile] Extension '${extension.identifier.value}' failed to validate skill file: ${uri}`, msg);
172 throw e;
173 }
175
176 return { uri, name, description, when, sessionTypes, storage: PromptsStorage.extension, type, extension, source: PromptFileSource.ExtensionContribution } satisfies IExtensionPromptPath;
334
335 private async _validateAndSanitizeSkillFile(uri: URI, token: CancellationToken): Promise<{ name: string; description: string | undefined }> {
336 > const parsedFile = await this._parsePromptFile(uri, token); extensionPromptFileService.ts
337 > const folderName = getSkillFolderName(uri);
338 >
339 > let name = parsedFile.header?.name;
340 > if (!name) {
341 this.logger.debug(`[validateAndSanitizeSkillFile] Agent skill file missing name attribute, using folder name "${folderName}": ${uri}`);
342 name = folderName;
343 }
345 > const description = parsedFile.header?.description;
346 >
347 > // Sanitize the name first (remove XML tags and truncate)
348 > let sanitizedName = this._truncateAgentSkillName(name, uri);
349 >
350 > // If sanitized name doesn't match folder name, use folder name (consistent with computeSkillDiscoveryInfo)
351 > if (sanitizedName !== folderName) {
352 this.logger.debug(`[validateAndSanitizeSkillFile] Agent skill name "${sanitizedName}" does not match folder name "${folderName}", using folder name: ${uri}`);
353 sanitizedName = folderName;
354 }
356 > const sanitizedDescription = description ? this._truncateAgentSkillDescription(description, uri) : undefined;
357 > return { name: sanitizedName, description: sanitizedDescription };
358 > }
359
360 private async _parsePromptFile(uri: URI, token: CancellationToken): Promise<ParsedPromptFile> {
361 > const model = this.modelService.getModel(uri); extensionPromptFileService.ts
362 > if (model) {
363 return new PromptFileParser().parse(uri, model.getValue());
364 }
365 > const fileContent = await this.fileService.readFile(uri); extensionPromptFileService.ts
366 > if (token.isCancellationRequested) {
367 throw new CancellationError();
368 }
369 > return new PromptFileParser().parse(uri, fileContent.value.toString()); extensionPromptFileService.ts
370 > }
371
372 private _sanitizeAgentSkillText(text: string): string {
373 > // Remove XML tags extensionPromptFileService.ts
374 > return text.replace(/<[^>]+>/g, '');
375 > }
376
377 private _truncateAgentSkillName(name: string, uri: URI): string {
378 > const MAX_NAME_LENGTH = 64; extensionPromptFileService.ts
379 > const sanitized = this._sanitizeAgentSkillText(name);
380 > if (sanitized !== name) {
381 this.logger.debug(`[findAgentSkills] Agent skill name contains XML tags, removed: ${uri}`);
382 }
383 > if (sanitized.length > MAX_NAME_LENGTH) { extensionPromptFileService.ts
384 this.logger.debug(`[findAgentSkills] Agent skill name exceeds ${MAX_NAME_LENGTH} characters, truncated: ${uri}`);
385 return sanitized.substring(0, MAX_NAME_LENGTH);
386 }
387 > return sanitized; extensionPromptFileService.ts
388 > }
389
390 private _truncateAgentSkillDescription(description: string, uri: URI): string {