Path: blob/main/src/vs/workbench/contrib/chat/common/plugins/pluginSource.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { URI } from '../../../../../base/common/uri.js';6import { IEnsureRepositoryOptions, IPullRepositoryOptions } from './agentPluginRepositoryService.js';7import { IMarketplacePlugin, IPluginSourceDescriptor, PluginSourceKind } from './pluginMarketplaceService.js';89/**10* Per-kind strategy that centralizes install-path computation, source11* provisioning, update, label formatting, and uninstall cleanup for a12* single {@link PluginSourceKind}.13*14* Implementations are created via {@link IInstantiationService} so they15* can dependency-inject any services they need (git commands, file service,16* terminal service, etc.).17*/18export interface IPluginSource {19readonly kind: PluginSourceKind;2021/**22* Compute the local cache URI where this source's plugin files live.23* @param cacheRoot The root cache directory for all agent plugins.24*/25getInstallUri(cacheRoot: URI, descriptor: IPluginSourceDescriptor): URI;2627/**28* Ensure the plugin source is available locally (clone, npm install, etc.).29* Returns the install directory URI.30*/31ensure(cacheRoot: URI, plugin: IMarketplacePlugin, options?: IEnsureRepositoryOptions): Promise<URI>;3233/**34* Update an already-installed plugin source (git pull, npm update, etc.).35* Returns `true` if the update brought in new changes.36*/37update(cacheRoot: URI, plugin: IMarketplacePlugin, options?: IPullRepositoryOptions): Promise<boolean>;3839/**40* Returns the on-disk directory to delete when this plugin is41* uninstalled, or `undefined` if no cleanup is needed.42*43* Marketplace-relative sources return `undefined` because they share44* a marketplace repository cache. Direct sources (github, url, npm,45* pip) return the directory they own.46*/47getCleanupTarget(cacheRoot: URI, descriptor: IPluginSourceDescriptor): URI | undefined;4849/**50* Returns a human-readable label for a source descriptor of this kind,51* suitable for error messages and UI display.52*/53getLabel(descriptor: IPluginSourceDescriptor): string;5455/**56* For package-manager sources (npm, pip): run the terminal install57* command and return the resulting plugin directory, or `undefined`58* if the user cancelled or the command failed.59*60* Not implemented by non-package-manager sources.61*/62runInstall?(installDir: URI, pluginDir: URI, plugin: IMarketplacePlugin, options?: { silent?: boolean }): Promise<{ pluginDir: URI } | undefined>;63}646566