promptFilesLocator.ts ×5

Frontier kind: Code frontier

unlabeled · c_942dcc51e5cd

112 tests · 67468 LOC · 326 files · introduces 0 tests · 62 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges62 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
6435 ranges67468 lines · 326 files · Browse complete extent
All tests (intent)
112 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.

2 files ranked by introduced lines: 62 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

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

Open complete file

348 */
349 private async _collectSourceFolderDiagnostics(type: PromptsType): Promise<IPromptSourceFolderResult[]> {
350 > const resolvedFolders = await this.fileLocator.getSourceFoldersInDiscoveryOrder(type); promptsServiceImpl.ts
351 > return resolvedFolders.map(folder => ({
352 > uri: folder.uri,
353 > storage: folder.storage,
354 > }));
355 > }
356
357 /**
1453
1454 public get(token: CancellationToken): Promise<T> {
1455 > // If a previous in-flight computation had all of its callers cancel, the pool's promptsServiceImpl.ts
1456 > // token will have fired and the computation may have rejected/aborted. A new
1457 > // caller arriving in that window must not inherit that cancellation, so start
1458 > // fresh.
1459 > if (this.cachedPool?.token.isCancellationRequested) {
1460 this.cachedPromise = undefined;
1461 this.cachedPool = undefined;
1462 }
1463 > let pool = this.cachedPool; promptsServiceImpl.ts
1464 > if (this.cachedPromise === undefined) {
1465 > // Aggregate callers' tokens so the shared computation is cancelled
1466 > // only after every live caller has cancelled. A single caller's
1467 > // cancellation no longer aborts the work for the others.
1468 > pool = new CancellationTokenPool();
1469 > const promise = this.computeFn(pool.token).catch(err => {
1470 if (this.cachedPromise === promise) {
1471 this.cachedPromise = undefined;
1472 }
1473 throw err;
1475 > // The pool is only meaningful while the computation is in flight.
1476 > promise.finally(() => {
1477 > if (this.cachedPool === pool) {
1478 > this.cachedPool = undefined;
1479 > }
1480 > pool!.dispose();
1481 > });
1482 > this.cachedPromise = promise;
1483 > this.cachedPool = pool;
1484 > }
1485 > pool?.add(token);
1486 > return raceCancellationError(this.cachedPromise, token);
1487 > }
1488
1489 public refresh(): void {
src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.ts 30 introduced LOC · 5 ranges

Open complete file

101 */
102 protected getDefaultSourceFolders(type: PromptsType): readonly IPromptSourceFolder[] {
103 > return getPromptFileDefaultLocations(type); promptFilesLocator.ts
104 > }
105
106 public async getWorkspaceFolderRoots(includeParents: boolean, logger?: Logger): Promise<URI[]> {
488 */
489 public async getSourceFoldersInDiscoveryOrder(type: PromptsType): Promise<readonly IResolvedPromptSourceFolder[]> {
490 > const absoluteLocations = await this.getLocalStorageFolders(type); promptFilesLocator.ts
491 > const userFolders = absoluteLocations.filter(loc => loc.storage === PromptsStorage.user);
492 > const localFolders = absoluteLocations.filter(loc => loc.storage === PromptsStorage.local);
493 > return this.dedupeSourceFolders([...userFolders, ...localFolders]);
494 > }
495
496 /**
499 */
500 private async getLocalStorageFolders(type: PromptsType): Promise<readonly IResolvedPromptSourceFolder[]> {
501 > const configuredLocations = this.getPromptSourceFolders(type); promptFilesLocator.ts
502 > const defaultFolders = this.getDefaultSourceFolders(type);
503 >
504 > // Merge default folders with configured locations, avoiding duplicates
505 > const allFolders = [
506 > ...defaultFolders,
507 > ...configuredLocations.filter(loc => !defaultFolders.some(df => df.path === loc.path))
508 > ];
509 >
510 > const absoluteLocations = await this.toAbsoluteLocations(type, allFolders, defaultFolders);
511 > if (type === PromptsType.agent || type === PromptsType.instructions || type === PromptsType.prompt) {
512 absoluteLocations.push(this.userDataFolder);
513 }
514 > return absoluteLocations; promptFilesLocator.ts
515 > }
516
517 /**
519 */
520 private dedupeSourceFolders(folders: readonly IResolvedPromptSourceFolder[]): IResolvedPromptSourceFolder[] {
521 > const seen = new ResourceSet(); promptFilesLocator.ts
522 > const result: IResolvedPromptSourceFolder[] = [];
523 > for (const folder of folders) {
524 > if (!seen.has(folder.uri)) {
525 > seen.add(folder.uri);
526 > result.push(folder);
527 > }
528 > }
529 > return result;
530 > }
531
532 /**