Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/common/plugins/pluginSource.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 { URI } from '../../../../../base/common/uri.js';
7
import { IEnsureRepositoryOptions, IPullRepositoryOptions } from './agentPluginRepositoryService.js';
8
import { IMarketplacePlugin, IPluginSourceDescriptor, PluginSourceKind } from './pluginMarketplaceService.js';
9
10
/**
11
* Per-kind strategy that centralizes install-path computation, source
12
* provisioning, update, label formatting, and uninstall cleanup for a
13
* single {@link PluginSourceKind}.
14
*
15
* Implementations are created via {@link IInstantiationService} so they
16
* can dependency-inject any services they need (git commands, file service,
17
* terminal service, etc.).
18
*/
19
export interface IPluginSource {
20
readonly kind: PluginSourceKind;
21
22
/**
23
* Compute the local cache URI where this source's plugin files live.
24
* @param cacheRoot The root cache directory for all agent plugins.
25
*/
26
getInstallUri(cacheRoot: URI, descriptor: IPluginSourceDescriptor): URI;
27
28
/**
29
* Ensure the plugin source is available locally (clone, npm install, etc.).
30
* Returns the install directory URI.
31
*/
32
ensure(cacheRoot: URI, plugin: IMarketplacePlugin, options?: IEnsureRepositoryOptions): Promise<URI>;
33
34
/**
35
* Update an already-installed plugin source (git pull, npm update, etc.).
36
* Returns `true` if the update brought in new changes.
37
*/
38
update(cacheRoot: URI, plugin: IMarketplacePlugin, options?: IPullRepositoryOptions): Promise<boolean>;
39
40
/**
41
* Returns the on-disk directory to delete when this plugin is
42
* uninstalled, or `undefined` if no cleanup is needed.
43
*
44
* Marketplace-relative sources return `undefined` because they share
45
* a marketplace repository cache. Direct sources (github, url, npm,
46
* pip) return the directory they own.
47
*/
48
getCleanupTarget(cacheRoot: URI, descriptor: IPluginSourceDescriptor): URI | undefined;
49
50
/**
51
* Returns a human-readable label for a source descriptor of this kind,
52
* suitable for error messages and UI display.
53
*/
54
getLabel(descriptor: IPluginSourceDescriptor): string;
55
56
/**
57
* For package-manager sources (npm, pip): run the terminal install
58
* command and return the resulting plugin directory, or `undefined`
59
* if the user cancelled or the command failed.
60
*
61
* Not implemented by non-package-manager sources.
62
*/
63
runInstall?(installDir: URI, pluginDir: URI, plugin: IMarketplacePlugin, options?: { silent?: boolean }): Promise<{ pluginDir: URI } | undefined>;
64
}
65
66