agentPluginEnablement.ts ×21

Frontier kind: Code frontier

unlabeled · c_6b5c22d51b72

3 tests · 36930 LOC · 172 files · introduces 0 tests · 83 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
21 ranges83 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3072 ranges36930 lines · 172 files · Browse complete extent
All tests (intent)
3 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: 83 introduced LOC across 21 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/plugins/agentPluginEnablement.ts 83 introduced LOC · 21 ranges

Open complete file

43
44 export function getCanonicalAgentPluginCollisionGroups(discoveries: readonly IDiscoveredAgentPlugins[], isBlocked?: (plugin: IAgentPlugin) => boolean): ReadonlyMap<string, readonly string[]> {
45 > const candidates = getUniqueAgentPluginCandidates(discoveries); agentPluginEnablement.ts
46 > const byCanonicalKey = new Map<string, string[]>();
47 > for (const candidate of candidates) {
48 > if (isBlocked?.(candidate.plugin)) {
49 continue;
50 }
51 > let group = byCanonicalKey.get(candidate.canonicalKey); agentPluginEnablement.ts
52 > if (!group) {
53 > group = [];
54 > byCanonicalKey.set(candidate.canonicalKey, group);
55 > }
56 > group.push(candidate.plugin.uri.toString());
57 > }
58 >
59 > const groups = new Map<string, readonly string[]>();
60 > for (const group of byCanonicalKey.values()) {
61 > if (group.length < 2) {
62 continue;
63 }
91 }
92
93 > function getAgentPluginCandidates(discoveries: readonly IDiscoveredAgentPlugins[]): IAgentPluginCandidate[] { agentPluginEnablement.ts
94 > const candidates: IAgentPluginCandidate[] = [];
95 > for (const discovery of discoveries) {
96 > for (let pluginOrder = 0; pluginOrder < discovery.plugins.length; pluginOrder++) {
97 > const plugin = discovery.plugins[pluginOrder];
98 > candidates.push({
99 > plugin,
100 > priority: discovery.priority,
101 > order: discovery.order,
102 > pluginOrder,
103 > canonicalKey: getCanonicalPluginIdentity(plugin),
104 > });
105 > }
106 > }
107 >
108 > return candidates.sort((a, b) =>
109 > a.priority - b.priority
110 || a.order - b.order
111 || a.pluginOrder - b.pluginOrder
112 || a.plugin.uri.toString().localeCompare(b.plugin.uri.toString())
114 > }
115
116 > function getUniqueAgentPluginCandidates(discoveries: readonly IDiscoveredAgentPlugins[]): IAgentPluginCandidate[] { agentPluginEnablement.ts
117 > const unique: IAgentPluginCandidate[] = [];
118 > const seen = new Set<string>();
119 > for (const candidate of getAgentPluginCandidates(discoveries)) {
120 > const key = candidate.plugin.uri.toString();
121 > if (seen.has(key)) {
122 continue;
123 }
124 > seen.add(key); agentPluginEnablement.ts
125 > unique.push(candidate);
126 > }
127 > return unique;
128 > }
129
130 > function getCanonicalPluginIdentity(plugin: IAgentPlugin): string { agentPluginEnablement.ts
131 > return getMarketplaceCanonicalIdentity(plugin.fromMarketplace)
132 > ?? getCopilotCliInstallCanonicalIdentity(plugin)
133 ?? `uri:${plugin.uri.toString()}`;
135
136 > function getMarketplaceCanonicalIdentity(plugin: IMarketplacePlugin | undefined): string | undefined { agentPluginEnablement.ts
137 > if (!plugin) {
138 > return undefined;
139 > }
140
141 const normalizedName = normalizePluginIdentitySegment(plugin.name);
148 return `marketplace:${plugin.marketplaceReference.canonicalId}|${normalizedName}`;
149 }
150 > case PluginSourceKind.GitHub: { agentPluginEnablement.ts
151 const github = source as IGitHubPluginSource;
152 return `github:${github.repo.toLowerCase()}|${normalizedName}`;
153 }
154 > case PluginSourceKind.GitUrl: { agentPluginEnablement.ts
155 const git = source as IGitUrlPluginSource;
156 return `git:${git.url.toLowerCase()}|${normalizedName}`;
157 }
158 > case PluginSourceKind.Npm: { agentPluginEnablement.ts
159 const npm = source as INpmPluginSource;
160 return `npm:${npm.package.toLowerCase()}|${normalizedName}`;
161 }
162 > case PluginSourceKind.Pip: { agentPluginEnablement.ts
163 const pip = source as IPipPluginSource;
164 return `pip:${pip.package.toLowerCase()}|${normalizedName}`;
165 }
167 > }
168
169 > function getCopilotCliInstallCanonicalIdentity(plugin: IAgentPlugin): string | undefined { agentPluginEnablement.ts
170 > if (plugin.uri.scheme !== 'file') {
171 return undefined;
172 }
174 > const idx = plugin.uri.path.indexOf(COPILOT_CLI_INSTALL_PATH_FRAGMENT);
175 > if (idx === -1) {
176 return undefined;
177 }
179 > const segments = plugin.uri.path.slice(idx + COPILOT_CLI_INSTALL_PATH_FRAGMENT.length).split('/').filter(s => s.length > 0);
180 > if (segments.length !== 2) {
181 return undefined;
182 }
184 > const [bucket, installName] = segments;
185 > const normalizedName = normalizePluginIdentitySegment(plugin.label || installName);
186 > if (bucket !== '_direct') {
187 return `copilot-cli-marketplace:${normalizePluginIdentitySegment(bucket)}|${normalizedName}`;
188 }
190 const match = /^(?<owner>.+)--(?<repo>.+)--(?<plugin>.+)$/.exec(installName);
191 const groups = match?.groups;
192 > if (!groups) { agentPluginEnablement.ts
193 return undefined;
194 }
197 }
198
199 > function normalizePluginIdentitySegment(value: string): string { agentPluginEnablement.ts
200 > return value
201 > .trim()
202 > .toLowerCase()
203 > .replace(/\s+/g, '-')
204 > .replace(/[^a-z0-9_.:-]/g, '-')
205 > .replace(/-+/g, '-')
206 > .replace(/^[-:.]+|[-:.]+$/g, '');
207 > }
208
209 interface IPolicyIdentity {