Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/claudePluginRecommendations.ts
13401 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 { Disposable } from '../../../../base/common/lifecycle.js';
7
import { localize } from '../../../../nls.js';
8
import { INotificationService, NeverShowAgainScope, Severity } from '../../../../platform/notification/common/notification.js';
9
import { IWorkbenchContribution } from '../../../common/contributions.js';
10
import { IExtensionsWorkbenchService } from '../../extensions/common/extensions.js';
11
import { IChatService } from '../common/chatService/chatService.js';
12
import { IPluginMarketplaceService } from '../common/plugins/pluginMarketplaceService.js';
13
14
export class AgentPluginRecommendations extends Disposable implements IWorkbenchContribution {
15
static readonly ID = 'workbench.contrib.agentPluginRecommendations';
16
17
private _hasNotified = false;
18
19
constructor(
20
@IChatService private readonly _chatService: IChatService,
21
@IPluginMarketplaceService private readonly _pluginMarketplaceService: IPluginMarketplaceService,
22
@INotificationService private readonly _notificationService: INotificationService,
23
@IExtensionsWorkbenchService private readonly _extensionsWorkbenchService: IExtensionsWorkbenchService,
24
) {
25
super();
26
27
this._register(this._chatService.onDidSubmitRequest(() => {
28
if (!this._hasNotified) {
29
this._hasNotified = true;
30
this._checkForRecommendedPlugins();
31
}
32
}));
33
}
34
35
private _checkForRecommendedPlugins(): void {
36
const recommended = this._pluginMarketplaceService.recommendedPlugins.get();
37
if (recommended.size === 0) {
38
return;
39
}
40
41
// Build a set of installed plugin keys ("name@marketplace") from
42
// storage without triggering any network fetch.
43
const installedKeys = new Set<string>();
44
for (const entry of this._pluginMarketplaceService.installedPlugins.get()) {
45
const key = `${entry.plugin.name}@${entry.plugin.marketplace}`;
46
installedKeys.add(key);
47
}
48
49
let uninstalledCount = 0;
50
for (const key of recommended) {
51
if (!installedKeys.has(key)) {
52
uninstalledCount++;
53
}
54
}
55
56
if (uninstalledCount === 0) {
57
return;
58
}
59
60
this._notificationService.prompt(
61
Severity.Info,
62
uninstalledCount === 1
63
? localize('agentPluginRecommendation.one', "This workspace recommends 1 agent plugin.")
64
: localize('agentPluginRecommendation.many', "This workspace recommends {0} agent plugins.", uninstalledCount),
65
[{
66
label: localize('showPlugins', "Show Plugins"),
67
run: () => {
68
this._extensionsWorkbenchService.openSearch('@agentPlugins @recommended');
69
}
70
}],
71
{
72
neverShowAgain: {
73
id: 'agentPluginRecommendations.dismissed',
74
scope: NeverShowAgainScope.WORKSPACE,
75
isSecondary: true,
76
}
77
}
78
);
79
}
80
}
81
82