55
66import { URI } from '../../../../base/common/uri.js' ;
77import { localize } from '../../../../nls.js' ;
8- import { ConfigurationTarget , IConfigurationService } from '../../../../platform/configuration/common/configuration.js' ;
98import { IFileService } from '../../../../platform/files/common/files.js' ;
109import { INotificationService , Severity } from '../../../../platform/notification/common/notification.js' ;
11- import { ChatConfiguration } from '../common/constants.js' ;
1210import { IAgentPluginRepositoryService } from '../common/plugins/agentPluginRepositoryService.js' ;
1311import { IPluginInstallService } from '../common/plugins/pluginInstallService.js' ;
14- import { IMarketplacePlugin } from '../common/plugins/pluginMarketplaceService.js' ;
12+ import { IMarketplacePlugin , IPluginMarketplaceService } from '../common/plugins/pluginMarketplaceService.js' ;
1513
1614export 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}
0 commit comments