promptsServiceImpl.ts ×10

Frontier kind: Code frontier

unlabeled · c_d5a8d668b871

17 tests · 69178 LOC · 326 files · introduces 0 tests · 73 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges73 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
7015 ranges69178 lines · 326 files · Browse complete extent
All tests (intent)
17 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.

4 files ranked by introduced lines: 73 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts 59 introduced LOC · 10 ranges

Open complete file

637
638 public async getCustomAgents(token: CancellationToken): Promise<readonly ICustomAgent[]> {
639 > const discoveryInfo = await this.cachedCustomAgents.get(token); promptsServiceImpl.ts
640 > const result = this.agentsFromDiscoveryInfo(discoveryInfo);
641 > return result;
642 > }
643
644 /**
646 */
647 private agentsFromDiscoveryInfo(discoveryInfo: IAgentDiscoveryInfo): readonly ICustomAgent[] {
648 > const result: ICustomAgent[] = []; promptsServiceImpl.ts
649 > for (const file of discoveryInfo.files) {
650 > if (file.agent) {
651 > result.push(file.agent);
652 > }
653 > }
654 > return result;
655 > }
656
657 private async computeAgentDiscoveryInfo(token: CancellationToken): Promise<IAgentDiscoveryInfo> {
658 > const stopWatch = StopWatch.create(true); promptsServiceImpl.ts
659 > const allAgentFiles = await this.listPromptFiles(PromptsType.agent, token);
660 > const disabledAgents = this.getDisabledPromptFiles(PromptsType.agent);
661 > const useChatHooks = this.configurationService.getValue(PromptsConfig.USE_CHAT_HOOKS);
662 > const isWorkspaceTrusted = this.workspaceTrustService.isWorkspaceTrusted();
663 >
664 > // Get user home for tilde expansion in hook cwd paths
665 > const userHomeUri = await this.pathService.userHome();
666 > const userHome = userHomeUri.scheme === Schemas.file ? userHomeUri.fsPath : userHomeUri.path;
667 > const defaultFolder = this.workspaceService.getWorkspace().folders[0];
668 >
669 > const files = await Promise.all(allAgentFiles.map(async (promptPath): Promise<IAgentDiscoveryResult> => {
670 > const uri = promptPath.uri;
671 > const isEnabled = !disabledAgents.has(uri);
672 >
673 > try {
674 > const ast = await this.parseNew(uri, token);
675 >
676 > // Parse hooks from the frontmatter if present
677 > let hooks: ChatRequestHooks | undefined;
678 > const hooksRaw = ast.header?.hooksRaw;
679 > if (useChatHooks && isWorkspaceTrusted && hooksRaw) {
680 const hookWorkspaceFolder = this.workspaceService.getWorkspaceFolder(uri) ?? defaultFolder;
681 const workspaceRootUri = hookWorkspaceFolder?.uri;
683 hooks = parseSubagentHooksFromYaml(hooksRaw, workspaceRootUri, userHome, target);
684 }
685 > const extra = { promptsServiceImpl.ts
686 > sessionTypes: promptPath.sessionTypes,
687 > hooks,
688 > name: promptPath.name,
689 > description: promptPath.description,
690 > source: IAgentSource.fromPromptPath(promptPath),
691 > enabled: isEnabled,
692 > };
693 > const agent = CustomAgent.fromParsedPromptFile(ast, extra);
694 > const status = isEnabled ? 'loaded' : 'skipped';
695 > const skipReason = isEnabled ? undefined : 'disabled';
696 > return { status, skipReason, promptPath: this.withPromptPathMetadata(promptPath, agent.name, agent.description), agent };
697 > } catch (e) {
698 const error = e instanceof Error ? e : new Error(String(e));
699 if (error instanceof FileOperationError && error.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
709 };
710 }
712 >
713 > const sourceFolders = await this._collectSourceFolderDiagnostics(PromptsType.agent);
714 > return { type: PromptsType.agent, files, sourceFolders, durationInMillis: stopWatch.elapsed() };
715 > }
716
717
1556 let metadata: any | undefined;
1557 if (ast.header) {
1558 > const advanced = ast.header.getAttribute(PromptHeaderAttributes.advancedOptions); promptsServiceImpl.ts
1559 > if (advanced && advanced.value.type === 'map') {
1560 metadata = {};
1561 for (const [key, value] of Object.entries(advanced.value)) {
1565 }
1566 }
1568 const toolReferences: IVariableReference[] = [];
1569 if (ast.body) {
1588 return { id, uri, name, agentInstructions, source, target, visibility: { userInvocable: true, agentInvocable: true }, sessionTypes, hooks, enabled };
1589 }
1590 > const visibility = { promptsServiceImpl.ts
1591 > userInvocable: ast.header.userInvocable !== false,
1592 agentInvocable: ast.header.infer !== undefined ? ast.header.infer === true : ast.header.disableModelInvocation !== true,
1593 } satisfies ICustomAgentVisibility;
1597 model = mapClaudeModels(model);
1598 }
1599 > let { tools, handOffs, argumentHint, agents } = ast.header; promptsServiceImpl.ts
1600 if (target === Target.Claude && tools) {
1601 tools = mapClaudeTools(tools);
1602 }
1603 > return { id, uri, name, description, model, tools, handOffs, argumentHint, target, visibility, agents, agentInstructions, source, sessionTypes, hooks, enabled }; promptsServiceImpl.ts
1604
1605 }
src/vs/workbench/contrib/chat/common/promptSyntax/promptFileParser.ts 8 introduced LOC · 4 ranges

Open complete file

143
144 public getAttribute(key: string): IHeaderAttribute | undefined {
145 > return this._parsedHeader.attributes.find(attr => attr.key === key); promptFileParser.ts
146 > }
147
148 public get errors(): ParseError[] {
196
197 public get infer(): boolean | undefined {
198 > return this.getBooleanAttribute(PromptHeaderAttributes.infer); promptFileParser.ts
199 > }
200
201 public get tools(): string[] | undefined {
329 */
330 public get hooksRaw(): IMapValue | undefined {
331 > const attr = this._parsedHeader.attributes.find(a => a.key === PromptHeaderAttributes.hooks); promptFileParser.ts
332 > if (attr?.value.type === 'map') {
333 return attr.value;
334 }
335 > return undefined; promptFileParser.ts
336 > }
337
338 private getBooleanAttribute(key: string): boolean | undefined {
src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptFileAttributes.ts 3 introduced LOC · 2 ranges

Open complete file

421 }
422 if (!(header instanceof URI)) {
423 > const target = header.target; promptFileAttributes.ts
424 > if (target === Target.GitHubCopilot || target === Target.VSCode) {
425 return target;
426 }
428 return Target.Undefined;
429 } else if (promptType === PromptsType.instructions) {
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts 3 introduced LOC · 3 ranges

Open complete file

225 export namespace IAgentSource {
226 export function fromPromptPath(promptPath: IPromptPath): IAgentSource {
227 > if (promptPath.storage === PromptsStorage.extension) { promptsService.ts
228 return { storage: PromptsStorage.extension, extensionId: promptPath.extension.identifier };
229 > } else if (promptPath.storage === PromptsStorage.plugin) { promptsService.ts
230 return { storage: PromptsStorage.plugin, pluginUri: promptPath.pluginUri! };
231 } else {
232 return { storage: promptPath.storage };
233 }
235
236 export function isEquals(a: IAgentSource | undefined, b: IAgentSource | undefined): boolean {