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 { parse as parseJSONC } from '../../../../../base/common/json.js';
7
>
import { RunOnceScheduler } from '../../../../../base/common/async.js';
8
>
import { Disposable, DisposableStore } from '../../../../../base/common/lifecycle.js';
9
>
import { autorun, derived, IObservable, observableFromEvent, observableValue } from '../../../../../base/common/observable.js';
10
>
import { joinPath } from '../../../../../base/common/resources.js';
11
>
import { URI } from '../../../../../base/common/uri.js';
12
>
import { IFileService } from '../../../../../platform/files/common/files.js';
13
>
import { createDecorator } from '../../../../../platform/instantiation/common/instantiation.js';
14
>
import { ILogService } from '../../../../../platform/log/common/log.js';
15
>
import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.js';
16
>
import { CLAUDE_CONFIG_FOLDER } from '../promptSyntax/config/promptFileLocations.js';
17
>
import { IMarketplaceReference, parseMarketplaceObjectEntry } from './marketplaceReference.js';
18
>
19
>
const SETTINGS_FILENAME = 'settings.json';
20
>
const SETTINGS_LOCAL_FILENAME = 'settings.local.json';
21
>
22
>
/** Copilot CLI settings folder inside `.github/`. */
23
>
const COPILOT_CONFIG_FOLDER = '.github/copilot';
24
>
25
>
/**
26
>
* Minimal representation of a marketplace entry from `extraKnownMarketplaces`.
27
>
*/
28
>
export interface IWorkspaceMarketplaceEntry {
29
>
readonly name: string;
30
>
readonly reference: IMarketplaceReference;
31
>
}
32
>
33
>
export const IWorkspacePluginSettingsService = createDecorator<IWorkspacePluginSettingsService>('workspacePluginSettingsService');
34
>
35
>
export interface IWorkspacePluginSettingsService {
36
>
readonly _serviceBrand: undefined;
37
>
38
>
/**
39
>
* Marketplace references parsed from `extraKnownMarketplaces` in workspace
40
>
* settings files (`.claude/settings.json`, `.github/copilot/settings.json`).
41
>
*/
42
>
readonly extraMarketplaces: IObservable<readonly IWorkspaceMarketplaceEntry[]>;
43
>
44
>
/**
45
>
* Plugin recommendation map parsed from `enabledPlugins` in workspace
46
>
* settings files.
47
>
* Keys are `"pluginName@marketplaceName"`, values indicate recommendation.
48
>
*/
49
>
readonly enabledPlugins: IObservable<ReadonlyMap<string, boolean>>;
50
>
}
51
>
52
>
// --- Parsing helpers ---------------------------------------------------------
53
>
54
>
/**
55
>
* Parses `enabledPlugins` from a JSON object.
56
>
*/
57
function parseEnabledPlugins(json: unknown): ReadonlyMap<string, boolean> {
58
const result = new Map<string, boolean>();