Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/common/plugins/pluginInstallService.ts
13405 views
1
/*---------------------------------------------------------------------------------------------
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 { CancellationToken } from '../../../../../base/common/cancellation.js';
7
import { URI } from '../../../../../base/common/uri.js';
8
import { createDecorator } from '../../../../../platform/instantiation/common/instantiation.js';
9
import { IMarketplacePlugin } from './pluginMarketplaceService.js';
10
11
export const IPluginInstallService = createDecorator<IPluginInstallService>('pluginInstallService');
12
13
export interface IUpdateAllPluginsOptions {
14
/**
15
* When `true`, also re-installs npm/pip packages that have no pinned
16
* version. Defaults to `false` to avoid interactive terminal prompts
17
* during background updates.
18
*/
19
readonly force?: boolean;
20
21
/**
22
* When `true`, suppresses the progress notification. An info
23
* notification is still shown listing any plugins that were
24
* updated, and error notifications are shown on failure.
25
*/
26
readonly silent?: boolean;
27
}
28
29
export interface IUpdateAllPluginsResult {
30
/** Names of plugins/marketplaces that were updated successfully. */
31
readonly updatedNames: readonly string[];
32
/** Names of plugins/marketplaces that failed to update. */
33
readonly failedNames: readonly string[];
34
}
35
36
export interface IInstallPluginFromSourceOptions {
37
/**
38
* When set, targets a specific plugin by name within the marketplace
39
* instead of installing all or prompting the user. The matched plugin
40
* is installed and returned in the result.
41
*/
42
readonly plugin?: string;
43
}
44
45
export interface IInstallPluginFromSourceResult {
46
readonly success: boolean;
47
readonly message?: string;
48
/**
49
* When {@link IInstallPluginFromSourceOptions.plugin} is set and the
50
* plugin was found, this contains the discovered marketplace plugin.
51
*/
52
readonly matchedPlugin?: IMarketplacePlugin;
53
}
54
55
export interface IPluginInstallService {
56
readonly _serviceBrand: undefined;
57
58
/**
59
* Clones the marketplace repository (if not already cached) and registers
60
* the plugin in the marketplace service's installed plugins storage.
61
*/
62
installPlugin(plugin: IMarketplacePlugin): Promise<void>;
63
64
/**
65
* Installs a plugin directly from a source location string. Accepts
66
* GitHub shorthand (`owner/repo`) or a full git clone URL. Clones the
67
* repository, reads marketplace metadata to discover plugins, and
68
* registers the selected plugin.
69
*
70
* When {@link IInstallPluginFromSourceOptions.plugin} is set, targets
71
* a specific plugin, installs it, and returns it.
72
*/
73
installPluginFromSource(source: string, options?: IInstallPluginFromSourceOptions): Promise<void>;
74
75
/**
76
* Synchronously validates the format of a plugin source string.
77
* Returns an error message if the format is invalid, or undefined if valid.
78
*/
79
validatePluginSource(source: string): string | undefined;
80
81
/**
82
* Installs a plugin from an already-validated source string.
83
* Handles trust, cloning, scanning, and registration. Returns a result
84
* with an optional error message (e.g. no plugins found).
85
*
86
* When {@link IInstallPluginFromSourceOptions.plugin} is set, targets
87
* a specific plugin, installs it, and returns it in
88
* {@link IInstallPluginFromSourceResult.matchedPlugin}.
89
*/
90
installPluginFromValidatedSource(source: string, options?: IInstallPluginFromSourceOptions): Promise<IInstallPluginFromSourceResult>;
91
92
/**
93
* Pulls the latest changes for an already-cloned marketplace repository.
94
*/
95
updatePlugin(plugin: IMarketplacePlugin): Promise<boolean>;
96
97
/**
98
* Updates all installed plugins. First pulls each unique marketplace
99
* repository, then updates non-relative-path plugins individually
100
* (git pull, npm install, pip install, etc.).
101
*/
102
updateAllPlugins(options: IUpdateAllPluginsOptions, token: CancellationToken): Promise<IUpdateAllPluginsResult>;
103
104
/**
105
* Returns the URI where a marketplace plugin would be installed on disk.
106
* Used to determine whether a marketplace plugin is already installed.
107
*/
108
getPluginInstallUri(plugin: IMarketplacePlugin): URI;
109
}
110
111