sessionCustomizationDiscovery.ts ×18

Frontier kind: Code frontier

unlabeled · c_1ec4eea7dbef

4 tests · 52159 LOC · 299 files · introduces 0 tests · 67 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges67 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5183 ranges52159 lines · 299 files · Browse complete extent
All tests (intent)
4 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: 67 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/sessionCustomizationDiscovery.ts 67 introduced LOC · 18 ranges

Open complete file

297 // Process instruction discovery paths
298 for (const instructionPath of instructionDiscovery?.paths ?? []) {
299 > throwIfCancelled(token); sessionCustomizationDiscovery.ts
300 > if (instructionPath.kind === 'file') {
301 > const fileUri = this._pathToUri(instructionPath.path);
302 > const discoveredFile: IDiscoveredFile = { uri: fileUri, etag: '' };
303 > if (extUriBiasedIgnorePathCase.isEqualOrParent(fileUri, this._workingDirectory)) {
304 workspaceAgentInstructionFiles.push(discoveredFile);
305 > } else if (extUriBiasedIgnorePathCase.isEqualOrParent(fileUri, this._userHome)) { sessionCustomizationDiscovery.ts
306 userAgentInstructionFiles.push(discoveredFile);
307 }
309 > } else if (instructionPath.kind === 'directory') {
310 result.push({
311 uri: this._pathToUri(instructionPath.path),
415
416 for (const file of discoveredDir.files) {
417 > throwIfCancelled(token); sessionCustomizationDiscovery.ts
418 >
419 > let currentFilePath = file.uri;
420 > while (!extUriBiasedIgnorePathCase.isEqual(currentFilePath, this._workingDirectory) && !extUriBiasedIgnorePathCase.isEqual(currentFilePath, this._userHome)) {
421 > const parent = uriDirname(currentFilePath);
422 > if (extUriBiasedIgnorePathCase.isEqual(parent, currentFilePath)) {
423 break;
424 }
425 > toResolve.add(parent); sessionCustomizationDiscovery.ts
426 > currentFilePath = parent;
427 > }
428 > }
429 }
430
463
464 for (const file of discoveredDir.files) {
465 > throwIfCancelled(token); sessionCustomizationDiscovery.ts
466 >
467 > let currentFilePath = file.uri;
468 > while (!extUriBiasedIgnorePathCase.isEqual(currentFilePath, this._workingDirectory) && !extUriBiasedIgnorePathCase.isEqual(currentFilePath, this._userHome)) {
469 > const parent = uriDirname(currentFilePath);
470 > if (extUriBiasedIgnorePathCase.isEqual(parent, currentFilePath)) {
471 break;
472 }
473 > if (existingDirectories.has(parent)) { sessionCustomizationDiscovery.ts
474 > addWatch(nextWatchRootUris, parent, false, currentFilePath);
475 > }
476 > currentFilePath = parent;
477 > }
478 > }
479 }
480
548 method: 'discoverRules.instructions.discover',
549 sources: instructionDiscovery.sources.map(source => ({
550 > id: source.id, sessionCustomizationDiscovery.ts
551 > label: source.label,
552 > sourcePath: source.sourcePath,
553 > applyTo: source.applyTo,
554 > type: source.type,
555 })),
556 });
557
558 for (const instruction of instructionDiscovery.sources) {
559 > let uri: URI; sessionCustomizationDiscovery.ts
560 > if (isAbsolute(instruction.sourcePath)) {
561 > uri = this._pathToUri(instruction.sourcePath);
562 > } else {
563 uri = joinPath(this._workingDirectory, instruction.sourcePath);
564 }
565 > const uriString = uri.toString(); sessionCustomizationDiscovery.ts
566 > rules.push({
567 > type: CustomizationType.Rule,
568 > uri: uriString,
569 > id: instruction.id,
570 > name: instruction.label,
571 > description: instruction.description,
572 > globs: instruction.applyTo ? [...instruction.applyTo] : undefined,
573 > alwaysApply: this._isAgentInstructionSource(instruction),
574 > });
575 > seenRuleUris.add(uriString);
576 > }
577
578 for (const directory of this._discoveredDirectories ?? []) {
580 continue;
581 }
583 > for (const file of directory.files) {
584 > const uri = file.uri.toString();
585 > if (seenRuleUris.has(uri)) {
586 continue;
587 }
602
603 private _isAgentInstructionSource(instruction: InstructionSource): boolean {
604 > if (instruction.type === 'home' || instruction.type === 'repo' || instruction.type === 'model') { sessionCustomizationDiscovery.ts
605 return true;
606 }
608 const filename = basename(instruction.sourcePath).toLowerCase();
609 return AGENT_INSTRUCTION_FILENAMES.has(filename);
611
612 private async discoverSkills(discoveryRequest: AgentsDiscoverRequest, client: CopilotClient, token: CancellationToken): Promise<SkillCustomization[]> {
785
786 if (type === CustomizationType.Rule && agentInstructionDirectoryUris.has(uri)) {
787 > const existingChildren: ChildCustomization[] = []; sessionCustomizationDiscovery.ts
788 > for (const child of children) {
789 > const childUri = URI.parse(child.uri);
790 > try {
791 > const stat = await this._fileService.resolve(childUri, { resolveMetadata: true });
792 if (stat.isFile) {
793 existingChildren.push(child);
794 }
796 // Ignore missing agent-instruction files; they should not surface.
797 }
799 > if (existingChildren.length === 0) {
800 continue;
801 }