src/vs/platform/agentHost/node/shared/sessionPluginBundler.ts

184 LOC · 166 covered · 18 uncovered · 29 ranges · 54 concepts · 9 introducers · 34 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery maps discovered files to parsed plugin preserving source URIs|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not include parsed agent-instruction rules in mapToParsedPlugin output|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×2 · 19 introduced LOCsessionCustomizationDisc…sessionPluginBundler.ts ×1 · 2 introduced LOCsessionPluginBundler.ts …sessionCustomizationDiscovery.test|title=SessionPluginBundler bundles discovered files into the synthetic plugin tree|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery bundles nested .instructions.md files into rules|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionPluginBundler.ts ×1 · 5 introduced LOCsessionPluginBundler.ts …sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover mode watches the discovered skill root so new skills fire onDidChange|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionPluginBundler.ts ×6 · 21 introduced LOCsessionPluginBundler.ts …sessionCustomizationDiscovery.ts ×1 · 1 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover includes hooks from recursive and fixed hook locations|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when an existing agent file is deleted under a non-recursively watched root|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×3 · 15 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery marks agent instruction rule sources as always apply|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×2 · 4 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×5 · 22 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×2 · 6 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×3 · 19 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×2 · 4 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×18 · 67 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not fire onDidChange for files outside any trigger URI|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when an existing agent file is modified under a non-recursively watched root|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when fixed hook settings file is modified|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when a new agent file is added under a non-recursively watched root|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when AGENTS.md in the workspace root is modified|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×2 · 4 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery includes non-README markdown files inside agent folders|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers hook settings files from fixed workspace locations|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery excludes exact-case README.md inside agent folders|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×2 · 10 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×1 · 2 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×9 · 15 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery installs watchers for roots that contain discovered customizations|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers agents, skills, instructions, and hooks across workspace and home roots|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns directories sorted by type and URI|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers supported agent instruction files in workspace roots|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery refresh keeps existing watchers when discovered roots are unchanged|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionPluginBundler.ts ×1 · 2 introduced LOCsessionPluginBundler.ts …sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not discover agent instruction files outside supported roots|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns undefined from mapToParsedPlugin when all customizations are agent-instruction files|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…copilotAgent.ts ×1 · 2 introduced LOCcopilotAgent.ts ×1sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers nested .instructions.md files|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×2 · 8 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns undefined when no files were discovered|occurrence=1 · 0 introduced LOCsessionCustomizationDisc…sessionPluginBundler.ts ×10 · 54 introduced LOCsessionPluginBundler.ts …sessionPluginBundler.ts ×2 · 2 introduced LOCsessionPluginBundler.ts …sessionCustomizationDiscovery.ts ×3 · 16 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×3 · 12 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×1 · 5 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×5 · 12 introduced LOCsessionCustomizationDisc…sessionCustomizationDiscovery.ts ×37 · 293 introduced LOCsessionCustomizationDisc…sessionPluginBundler.ts ×1 · 2 introduced LOCsessionPluginBundler.ts …sessionPluginBundler.ts ×1 · 8 introduced LOCsessionPluginBundler.ts …sessionPluginBundler.ts ×6 · 70 introduced LOCsessionPluginBundler.ts …sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery bundles nested .instructions.md files into rules|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery bundles nested .instructions.md files into rules|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery cancellation of one caller does not affect another concurrent caller|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery cancellation of one caller does not affect another concurrent caller|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover groups case-variant instructions and nested skills under their roots|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover groups case-variant instructions and nested skills under their roots|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover includes hooks from recursive and fixed hook locations|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover includes hooks from recursive and fixed hook locations|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover mode watches the discovered skill root so new skills fire onDidChange|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover mode watches the discovered skill root so new skills fire onDidChange|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover returns working-directory agents, skills, instructions, hooks, and agent instructions|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discover returns working-directory agents, skills, instructions, hooks, and agent instructions|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers agents, skills, instructions, and hooks across workspace and home roots|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers agents, skills, instructions, and hooks across workspace and home roots|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers hook settings files from fixed workspace locations|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers hook settings files from fixed workspace locations|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers nested .instructions.md files|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers nested .instructions.md files|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers nested .json hook files|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers nested .json hook files|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers supported agent instruction files in workspace roots|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery discovers supported agent instruction files in workspace roots|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not discover agent instruction files outside supported roots|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not discover agent instruction files outside supported roots|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not fire onDidChange for files outside any trigger URI|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not fire onDidChange for files outside any trigger URI|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not include parsed agent-instruction rules in mapToParsedPlugin output|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery does not include parsed agent-instruction rules in mapToParsedPlugin output|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery drops missing agent instruction files and empty agent instruction directories|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery drops missing agent instruction files and empty agent instruction directories|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery excludes exact-case README.md inside agent folders|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery excludes exact-case README.md inside agent folders|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when AGENTS.md in the workspace root is modified|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when AGENTS.md in the workspace root is modified|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when a new agent file is added under a non-recursively watched root|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when a new agent file is added under a non-recursively watched root|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when an existing agent file is deleted under a non-recursively watched root|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when an existing agent file is deleted under a non-recursively watched root|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when an existing agent file is modified under a non-recursively watched root|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when an existing agent file is modified under a non-recursively watched root|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when fixed hook settings file is modified|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery fires onDidChange when fixed hook settings file is modified|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery groups discovered customizations by parent folder|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery groups discovered customizations by parent folder|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery includes non-README markdown files inside agent folders|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery includes non-README markdown files inside agent folders|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery installs watchers for roots that contain discovered customizations|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery installs watchers for roots that contain discovered customizations|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery maps discovered files to parsed plugin preserving source URIs|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery maps discovered files to parsed plugin preserving source URIs|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery marks agent instruction rule sources as always apply|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery marks agent instruction rule sources as always apply|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery refresh keeps existing watchers when discovered roots are unchanged|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery refresh keeps existing watchers when discovered roots are unchanged|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns directories sorted by type and URI|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns directories sorted by type and URI|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns undefined from mapToParsedPlugin when all customizations are agent-instruction files|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns undefined from mapToParsedPlugin when all customizations are agent-instruction files|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns undefined when no files were discovered|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionCustomizationDiscovery returns undefined when no files were discovered|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionPluginBundler bundles discovered files into the synthetic plugin tree|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionPluginBundler bundles discovered files into the synthetic plugin tree|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionPluginBundler different working directories produce different bundle authorities|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionPluginBundler different working directories produce different bundle authorities|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionPluginBundler produces a stable nonce for identical content|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionPluginBundler produces a stable nonce for identical content|occurrence=1sessionCustomizationDisc…sessionCustomizationDiscovery.test|title=SessionPluginBundler returns undefined without rewriting when cancelled|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/sessionCustomizationDiscovery.test|title=SessionPluginBundler returns undefined without rewriting when cancelled|occurrence=1sessionCustomizationDisc…Focused file · src/vs/platform/agentHost/node/shared/sessionPluginBundler.ts · 184 LOCshared/sessionPluginBund…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- sessionPluginBundler.ts ×6
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 { VSBuffer } from '../../../../base/common/buffer.js';
7 > import { CancellationToken } from '../../../../base/common/cancellation.js';
8 > import { hash } from '../../../../base/common/hash.js';
9 > import { Disposable } from '../../../../base/common/lifecycle.js';
10 > import { basename, dirname } from '../../../../base/common/resources.js';
11 > import { URI } from '../../../../base/common/uri.js';
12 > import { IFileService } from '../../../files/common/files.js';
13 > import { IAgentPluginManager } from '../../common/agentPluginManager.js';
14 > import { customizationId, type ClientPluginCustomization } from '../../common/state/sessionState.js';
15 > import { CustomizationType, type URI as ProtocolURI } from '../../common/state/protocol/state.js';
16 > import { DiscoveredType, type IDiscoveredDirectory } from '../copilot/sessionCustomizationDiscovery.js';
17 >
18 > const DISPLAY_NAME = 'VS Code Synced Data';
19 > const HOST_DISCOVERY_DIR = 'host-discovery';
20 >
21 > const MANIFEST_CONTENT = JSON.stringify({
22 > name: DISPLAY_NAME,
23 > description: 'Customization data discovered from this workspace and your home directory',
24 > }, null, '\t');
25 >
26 > /**
27 > * Maps a {@link DiscoveredType} to the plugin sub-directory under which that
28 > * component type lives in the Open Plugin format.
29 > */
30 > function pluginDirForType(type: DiscoveredType): string | undefined { sessionPluginBundler.ts ×10
31 > switch (type) {
32 > case DiscoveredType.Agent: return 'agents';
33 > case DiscoveredType.Skill: return 'skills';
34 > case DiscoveredType.Instruction: return 'rules';
35 > case DiscoveredType.Hook: return 'hooks';
36 > case DiscoveredType.AgentInstruction: return undefined;
37 > }
38 > }
40 > interface IBundleResult {
41 > readonly ref: ClientPluginCustomization;
42 > }
43 >
44 > /**
45 > * Bundles host-discovered customization files into an Open Plugin layout
46 > * on real disk under `<agentPluginManager.basePath>/host-discovery/<hash>/`.
47 > *
48 > * Writing to a real directory (rather than an in-memory provider) is
49 > * required because the Copilot SDK subprocess receives skill directories
50 > * and hook commands as on-disk paths via `fsPath`, and because the
51 > * workbench fetches files through the agent-host filesystem bridge —
52 > * neither of which can read a host-side in-memory FS.
53 > *
54 > * The directory is namespaced by a hash of the working directory so
55 > * concurrent sessions on different folders don't collide. Repeated
56 > * `bundle()` calls with identical content reuse the prior bundle (nonce
57 > * match) and skip the rewrite.
58 > */
59 > export class SessionPluginBundler extends Disposable {
60 >
61 > private readonly _rootUri: URI;
62 > private _lastNonce: string | undefined;
63 >
64 > constructor(
65 > workingDirectory: URI, sessionPluginBundler.ts ×1
66 > @IFileService private readonly _fileService: IFileService,
67 > @IAgentPluginManager pluginManager: IAgentPluginManager,
68 > ) {
69 > super();
70 > const authority = `host-${hash(workingDirectory.toString())}`;
71 > this._rootUri = URI.joinPath(pluginManager.basePath, HOST_DISCOVERY_DIR, authority);
72 > }
74 > get rootUri(): URI {
75 > return this._rootUri; sessionPluginBundler.ts ×1
76 > }
78 > get lastNonce(): string | undefined {
79 return this._lastNonce;
80 }
82 > /**
83 > * Bundles the given files into the on-disk plugin directory.
84 > *
85 > * Overwrites any previous bundle for this working directory. Returns a
86 > * {@link ClientPluginCustomization} pointing at the on-disk plugin root
87 > * with a content-based nonce, or `undefined` when there are no files or
88 > * cancellation was requested.
89 > */
90 > async bundle(directories: readonly IDiscoveredDirectory[], token: CancellationToken = CancellationToken.None): Promise<IBundleResult | undefined> {
91 > if (directories.length === 0 || token.isCancellationRequested) { sessionPluginBundler.ts ×2
92 > return undefined; sessionPluginBundler.ts ×1
93 > }
95 > const hashParts: string[] = [];
96 > const files: { readonly destUri: URI; readonly content: VSBuffer }[] = [];
97 >
98 > for (const discoveredDirectory of directories) {
99 > const dir = pluginDirForType(discoveredDirectory.type);
100 > if (!dir) {
101 continue; // do not bundle agent instructions
102 }
103 > for (const file of discoveredDirectory.files) { sessionPluginBundler.ts ×10
104 > const fileUri = file.uri; sessionPluginBundler.ts ×6
105 > const fileName = basename(fileUri);
106 >
107 > let destUri: URI;
108 > let hashKey: string;
109 > if (discoveredDirectory.type === DiscoveredType.Skill) {
110 > // Skills are conventionally `<skillName>/SKILL.md`. Preserve the sessionPluginBundler.ts ×1
111 > // containing directory name so multiple skills don't collide.
112 > const skillDirName = basename(dirname(fileUri));
113 > destUri = URI.joinPath(this._rootUri, dir, skillDirName, fileName);
114 > hashKey = `${dir}/${skillDirName}/${fileName}`;
116 > destUri = URI.joinPath(this._rootUri, dir, fileName);
117 > hashKey = `${dir}/${fileName}`;
118 > }
119 >
120 > const content = await this._fileService.readFile(fileUri);
121 > if (token.isCancellationRequested) {
122 return undefined;
123 }
124 > files.push({ destUri, content: content.value }); sessionPluginBundler.ts ×6
125 > hashParts.push(`${hashKey}:${content.value.toString()}`);
126 > }
128 > if (token.isCancellationRequested) {
129 return undefined;
130 }
132 > hashParts.sort();
133 > const nonce = String(hash(hashParts.join('\n')));
134 >
135 > const rootUriString = this._rootUri.toString() as ProtocolURI;
136 > const result = {
137 > ref: {
138 > type: CustomizationType.Plugin,
139 > id: customizationId(rootUriString),
140 > uri: rootUriString,
141 > name: DISPLAY_NAME,
142 > enabled: true,
143 > nonce,
144 > },
145 > } satisfies IBundleResult;
146 >
147 > if (this._lastNonce === nonce) {
148 > return result; sessionPluginBundler.ts ×1
149 > }
151 > try {
152 > await this._fileService.del(this._rootUri, { recursive: true });
153 > } catch {
154 > // Directory may not exist on first bundle.
155 > }
156 > if (token.isCancellationRequested) {
157 return undefined;
158 }
160 > const manifestUri = URI.joinPath(this._rootUri, '.plugin', 'plugin.json');
161 > await this._fileService.createFolder(dirname(manifestUri));
162 > if (token.isCancellationRequested) {
163 return undefined;
164 }
165 > await this._fileService.writeFile(manifestUri, VSBuffer.fromString(MANIFEST_CONTENT)); sessionPluginBundler.ts ×10
166 > if (token.isCancellationRequested) {
167 return undefined;
168 }
170 > for (const file of files) {
171 > await this._fileService.createFolder(dirname(file.destUri)); sessionPluginBundler.ts ×6
172 > if (token.isCancellationRequested) {
173 return undefined;
174 }
175 > await this._fileService.writeFile(file.destUri, file.content); sessionPluginBundler.ts ×6
176 > if (token.isCancellationRequested) {
177 return undefined;
178 }
181 > this._lastNonce = nonce;
182 > return result;