agentHostWorkspaceFiles.ts ×5

Frontier kind: Code frontier

unlabeled · c_ab4d23d8750c

510 tests · 7912 LOC · 39 files · introduces 0 tests · 58 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges58 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1253 ranges7912 lines · 39 files · Browse complete extent
All tests (intent)
510 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: 58 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostWorkspaceFiles.ts 58 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostWorkspaceFiles.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as cp from 'child_process';
7 > import { CancellationToken } from '../../../base/common/cancellation.js';
8 > import { CancellationError } from '../../../base/common/errors.js';
9 > import { Disposable } from '../../../base/common/lifecycle.js';
10 > import { Schemas } from '../../../base/common/network.js';
11 > import { URI } from '../../../base/common/uri.js';
12 > import { ILogService } from '../../log/common/log.js';
13 > import { rgDiskPath } from '../../../base/node/ripgrep.js';
14 >
15 > /** Maximum number of files cached per working directory. */
16 > const MAX_FILES = 50_000;
17 >
18 > /** TTL for a cached file list before we re-enumerate. */
19 > const CACHE_TTL_MS = 30_000;
20 >
21 > interface ICacheEntry {
22 > readonly promise: Promise<readonly URI[]>;
23 > expiresAt: number;
24 > }
25 >
26 > /**
27 > * Enumerates files under a working directory using ripgrep, with results
28 > * cached per working directory for a short TTL.
29 > *
30 > * Mirrors the workbench's file-search invocation pattern (see
31 > * `ripgrepFileSearch.ts` in `vs/workbench/services/search/node/`) but does
32 > * not depend on the workbench layer — the agent host runs in a separate
33 > * node process that may not import from `vs/workbench/`.
34 > *
35 > * Files are returned as absolute {@link URI}s relative to the working
36 > * directory. `.gitignore` and other `.ignore` files are honoured by
37 > * ripgrep. Symlinks are followed.
38 > */
39 > export class AgentHostWorkspaceFiles extends Disposable {
40 >
41 > private readonly _cache = new Map<string, ICacheEntry>();
42 > /** Active ripgrep child processes, killed on dispose. */
43 > private readonly _activeChildren = new Set<cp.ChildProcessWithoutNullStreams>();
44 >
45 > constructor(
46 @ILogService private readonly _logService: ILogService,
47 ) {
48 super();
49 }
51 > override dispose(): void {
52 for (const child of this._activeChildren) {
53 try {
61 super.dispose();
62 }
64 > /**
65 > * Return the list of files under `workingDirectory`. Concurrent calls
66 > * with the same working directory share an in-flight enumeration.
67 > *
68 > * Only `file://` URIs are supported. Other schemes return an empty list.
69 > */
70 > async getFiles(workingDirectory: URI, token: CancellationToken): Promise<readonly URI[]> {
71 if (workingDirectory.scheme !== Schemas.file) {
72 return [];
115 });
116 }
118 > private async _enumerate(workingDirectory: URI): Promise<readonly URI[]> {
119 const resolvedRgDiskPath = await rgDiskPath();
120 return new Promise<readonly URI[]>(resolve => {