Skip to content

Commit 3bc832a

Browse files
authored
plugins: store installed plugins in storage rather than paths (#298352)
* plugins: store installed plugins in storage rather than paths This simplifies some things and sets the groundwork for more special things (like updating and disk cleanup) that we'll do with marketplace plugins. * fix
1 parent 4be5209 commit 3bc832a

File tree

9 files changed

+343
-392
lines changed

9 files changed

+343
-392
lines changed

src/vs/workbench/contrib/chat/browser/agentPluginsView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,12 @@ class UninstallPluginAction extends Action {
157157

158158
constructor(
159159
private readonly plugin: IAgentPlugin,
160-
@IPluginInstallService private readonly pluginInstallService: IPluginInstallService,
161160
) {
162161
super(UninstallPluginAction.ID, localize('uninstall', "Uninstall"));
163162
}
164163

165164
override async run(): Promise<void> {
166-
this.pluginInstallService.uninstallPlugin(this.plugin.uri);
165+
this.plugin.remove();
167166
}
168167
}
169168

src/vs/workbench/contrib/chat/browser/chat.contribution.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ import './widget/input/editor/chatInputEditorContrib.js';
143143
import './widget/input/editor/chatInputEditorHover.js';
144144
import { LanguageModelToolsConfirmationService } from './tools/languageModelToolsConfirmationService.js';
145145
import { LanguageModelToolsService, globalAutoApproveDescription } from './tools/languageModelToolsService.js';
146-
import { AgentPluginService, ConfiguredAgentPluginDiscovery } from '../common/plugins/agentPluginServiceImpl.js';
146+
import { AgentPluginService, ConfiguredAgentPluginDiscovery, MarketplaceAgentPluginDiscovery } from '../common/plugins/agentPluginServiceImpl.js';
147147
import { IAgentPluginRepositoryService } from '../common/plugins/agentPluginRepositoryService.js';
148148
import { IPluginInstallService } from '../common/plugins/pluginInstallService.js';
149149
import { IPluginMarketplaceService, PluginMarketplaceService } from '../common/plugins/pluginMarketplaceService.js';
@@ -1701,6 +1701,7 @@ registerAction2(ConfigureToolSets);
17011701
registerEditorFeature(ChatPasteProvidersFeature);
17021702

17031703
agentPluginDiscoveryRegistry.register(new SyncDescriptor(ConfiguredAgentPluginDiscovery));
1704+
agentPluginDiscoveryRegistry.register(new SyncDescriptor(MarketplaceAgentPluginDiscovery));
17041705

17051706
registerSingleton(IChatTransferService, ChatTransferService, InstantiationType.Delayed);
17061707
registerSingleton(IChatService, ChatService, InstantiationType.Delayed);

src/vs/workbench/contrib/chat/browser/pluginInstallService.ts

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@
55

66
import { URI } from '../../../../base/common/uri.js';
77
import { localize } from '../../../../nls.js';
8-
import { ConfigurationTarget, IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
98
import { IFileService } from '../../../../platform/files/common/files.js';
109
import { INotificationService, Severity } from '../../../../platform/notification/common/notification.js';
11-
import { ChatConfiguration } from '../common/constants.js';
1210
import { IAgentPluginRepositoryService } from '../common/plugins/agentPluginRepositoryService.js';
1311
import { IPluginInstallService } from '../common/plugins/pluginInstallService.js';
14-
import { IMarketplacePlugin } from '../common/plugins/pluginMarketplaceService.js';
12+
import { IMarketplacePlugin, IPluginMarketplaceService } from '../common/plugins/pluginMarketplaceService.js';
1513

1614
export class PluginInstallService implements IPluginInstallService {
1715
declare readonly _serviceBrand: undefined;
1816

1917
constructor(
2018
@IAgentPluginRepositoryService private readonly _pluginRepositoryService: IAgentPluginRepositoryService,
21-
@IConfigurationService private readonly _configurationService: IConfigurationService,
19+
@IPluginMarketplaceService private readonly _pluginMarketplaceService: IPluginMarketplaceService,
2220
@IFileService private readonly _fileService: IFileService,
2321
@INotificationService private readonly _notificationService: INotificationService,
2422
) { }
@@ -54,7 +52,7 @@ export class PluginInstallService implements IPluginInstallService {
5452
return;
5553
}
5654

57-
this._addPluginPath(pluginDir.fsPath);
55+
this._pluginMarketplaceService.addInstalledPlugin(pluginDir, plugin);
5856
}
5957

6058
async updatePlugin(plugin: IMarketplacePlugin): Promise<void> {
@@ -65,43 +63,7 @@ export class PluginInstallService implements IPluginInstallService {
6563
});
6664
}
6765

68-
async uninstallPlugin(pluginUri: URI): Promise<void> {
69-
await this._removePluginPath(pluginUri.fsPath);
70-
}
71-
7266
getPluginInstallUri(plugin: IMarketplacePlugin): URI {
7367
return this._pluginRepositoryService.getPluginInstallUri(plugin);
7468
}
75-
76-
/**
77-
* Adds the given file-system path to `chat.plugins.paths` in user-local config.
78-
*/
79-
private _addPluginPath(fsPath: string): void {
80-
const current = this._configurationService.getValue<Record<string, boolean>>(ChatConfiguration.PluginPaths) ?? {};
81-
if (Object.prototype.hasOwnProperty.call(current, fsPath)) {
82-
return;
83-
}
84-
this._configurationService.updateValue(
85-
ChatConfiguration.PluginPaths,
86-
{ ...current, [fsPath]: true },
87-
ConfigurationTarget.USER_LOCAL,
88-
);
89-
}
90-
91-
/**
92-
* Removes the given file-system path from `chat.plugins.paths` in user-local config.
93-
*/
94-
private _removePluginPath(fsPath: string) {
95-
const current = this._configurationService.getValue<Record<string, boolean>>(ChatConfiguration.PluginPaths) ?? {};
96-
if (!Object.prototype.hasOwnProperty.call(current, fsPath)) {
97-
return;
98-
}
99-
const updated = { ...current };
100-
delete updated[fsPath];
101-
return this._configurationService.updateValue(
102-
ChatConfiguration.PluginPaths,
103-
updated,
104-
ConfigurationTarget.USER_LOCAL,
105-
);
106-
}
10769
}

src/vs/workbench/contrib/chat/common/plugins/agentPluginService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export interface IAgentPlugin {
4545
readonly uri: URI;
4646
readonly enabled: IObservable<boolean>;
4747
setEnabled(enabled: boolean): void;
48+
/** Removes this plugin from its discovery source (config or installed storage). */
49+
remove(): void;
4850
readonly hooks: IObservable<readonly IAgentPluginHook[]>;
4951
readonly commands: IObservable<readonly IAgentPluginCommand[]>;
5052
readonly skills: IObservable<readonly IAgentPluginSkill[]>;

0 commit comments

Comments
 (0)