marketplaceReference.ts ×13

Frontier kind: Code frontier

unlabeled · c_f7c875a217a5

202 tests · 22050 LOC · 120 files · introduces 0 tests · 87 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges87 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2457 ranges22050 lines · 120 files · Browse complete extent
All tests (intent)
202 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: 87 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/plugins/marketplaceReference.ts 87 introduced LOC · 13 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- marketplaceReference.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 { URI } from '../../../../../base/common/uri.js';
7 > import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
8 > import { ChatConfiguration } from '../constants.js';
9 >
10 > export { extraKnownMarketplacesToConfigDict } from '../../../../../base/common/managedSettings.js';
11 >
12 > export const enum MarketplaceReferenceKind {
13 > GitHubShorthand = 'githubShorthand',
14 > GitUri = 'gitUri',
15 > LocalFileUri = 'localFileUri',
16 > }
17 >
18 > export interface IMarketplaceReference {
19 > readonly rawValue: string;
20 > readonly displayLabel: string;
21 > readonly cloneUrl: string;
22 > readonly canonicalId: string;
23 > readonly cacheSegments: readonly string[];
24 > readonly kind: MarketplaceReferenceKind;
25 > readonly ref?: string;
26 > readonly githubRepo?: string;
27 > readonly localRepositoryUri?: URI;
28 > }
29 >
30 > /**
31 > * The two configuration layers behind plugin marketplaces:
32 > * - `userValues` — what's stored at {@link ChatConfiguration.PluginMarketplaces}
33 > * (default + user). Writable by the user.
34 > * - `extraValues` — what's delivered via the `ChatExtraMarketplaces` enterprise
35 > * policy into {@link ChatConfiguration.ExtraMarketplaces}. Read-only.
36 > *
37 > * Entries may be strings (`<owner>/<repo>` or git URIs) or, in the policy case,
38 > * {@link IExtraMarketplaceObjectEntry} objects — both shapes flow through
39 > * {@link parseMarketplaceReferences}.
40 > */
41 > export interface IConfiguredMarketplaces {
42 > readonly userValues: readonly unknown[];
43 > readonly extraValues: readonly unknown[];
44 > readonly effectiveValues: readonly unknown[];
45 > }
46 >
47 > /** Shorthand-or-URI regex used to detect GitHub `owner/repo[#ref]` entries. */
48 > const _githubShorthandRe = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#.+)?$/;
49 >
50 > export function readConfiguredMarketplaces(configurationService: IConfigurationService): IConfiguredMarketplaces {
51 const userValues = configurationService.getValue<(string | object)[]>(ChatConfiguration.PluginMarketplaces) ?? [];
52
68 };
69 }
71 > export function parseMarketplaceReferences(values: readonly unknown[]): IMarketplaceReference[] {
72 const byCanonicalId = new Map<string, IMarketplaceReference>();
73
86 return [...byCanonicalId.values()];
87 }
89 > /**
90 > * Object-form marketplace entry shape, as delivered via the enterprise
91 > * `managed_settings` policy or `.github/copilot/settings.json` workspace
92 > * file. `name` (when present) is used as the marketplace's `displayLabel`
93 > * so that `enabledPlugins["plugin@name"]` keys match consistently.
94 > *
95 > * Both the nested form (`source: { source, repo|url }`) and the flat form
96 > * (`source: 'github', repo: ...`) are accepted.
97 > */
98 > export interface IExtraMarketplaceObjectEntry {
99 > readonly name?: string;
100 > readonly source?: string | { readonly source?: string; readonly repo?: string; readonly url?: string; readonly ref?: string };
101 > readonly repo?: string;
102 > readonly url?: string;
103 > readonly ref?: string;
104 > }
105 >
106 > export function parseMarketplaceObjectEntry(entry: IExtraMarketplaceObjectEntry): IMarketplaceReference | undefined {
107 let sourceType: string | undefined;
108 let repo: string | undefined;
135 return parsed;
136 }
138 function appendMarketplaceRef(value: string, ref: string | undefined): string {
139 if (!ref) {
144 return `${base}#${ref}`;
145 }
147 > /**
148 > * Merges two sets of marketplace references, deduplicating by canonical ID.
149 > * The first set takes precedence when IDs collide.
150 > */
151 > export function deduplicateMarketplaceReferences(primary: readonly IMarketplaceReference[], secondary: readonly IMarketplaceReference[]): IMarketplaceReference[] {
152 const byCanonicalId = new Map<string, IMarketplaceReference>();
153 for (const ref of primary) {
161 return [...byCanonicalId.values()];
162 }
164 > export function parseMarketplaceReference(value: string): IMarketplaceReference | undefined {
165 const rawValue = value.trim();
166 if (!rawValue) {
197 return undefined;
198 }
200 function parseUriMarketplaceReference(rawValue: string): IMarketplaceReference | undefined {
201 let uri: URI;
283 };
284 }
286 function parseScpMarketplaceReference(rawValue: string): IMarketplaceReference | undefined {
287 const match = /^([^@\s]+)@([^:\s]+):(.+?\.git)(?:#(.+))?$/i.exec(rawValue);
323 };
324 }
326 function extractGitHubRepo(authority: string, pathWithoutGit: string): string | undefined {
327 if (authority.toLowerCase() !== 'github.com') {
334 return undefined;
335 }
337 function getGitHubCanonicalId(owner: string, repo: string, ref?: string): string {
338 return appendRefSuffix(`github:${owner.toLowerCase()}/${repo.toLowerCase()}`, ref);
339 }
341 function appendRefSuffix(canonicalId: string, ref: string | undefined): string {
342 return ref ? `${canonicalId}#${encodeURIComponent(ref)}` : canonicalId;
343 }
345 function getRefCacheSegments(ref: string | undefined): string[] {
346 return ref ? [`ref_${encodeURIComponent(ref)}`] : [];
347 }
349 function sanitizePathSegment(value: string): string {
350 return value.replace(/[\\/:*?"<>|]/g, '_');