Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/promptSyntax/skillActions.ts
5247 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 { ChatViewId } from '../chat.js';
7
import { CHAT_CATEGORY, CHAT_CONFIG_MENU_ID } from '../actions/chatActions.js';
8
import { localize, localize2 } from '../../../../../nls.js';
9
import { ChatContextKeys } from '../../common/actions/chatContextKeys.js';
10
import { PromptFilePickers } from './pickers/promptFilePickers.js';
11
import { ServicesAccessor } from '../../../../../editor/browser/editorExtensions.js';
12
import { Action2, registerAction2 } from '../../../../../platform/actions/common/actions.js';
13
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
14
import { Codicon } from '../../../../../base/common/codicons.js';
15
import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js';
16
import { PromptsType } from '../../common/promptSyntax/promptTypes.js';
17
import { IOpenerService } from '../../../../../platform/opener/common/opener.js';
18
19
/**
20
* Action ID for the `Configure Skills` action.
21
*/
22
const CONFIGURE_SKILLS_ACTION_ID = 'workbench.action.chat.configure.skills';
23
24
25
class ManageSkillsAction extends Action2 {
26
constructor() {
27
super({
28
id: CONFIGURE_SKILLS_ACTION_ID,
29
title: localize2('configure-skills', "Configure Skills..."),
30
shortTitle: localize2('configure-skills.short', "Skills"),
31
icon: Codicon.lightbulb,
32
f1: true,
33
precondition: ChatContextKeys.enabled,
34
category: CHAT_CATEGORY,
35
menu: {
36
id: CHAT_CONFIG_MENU_ID,
37
when: ContextKeyExpr.and(ChatContextKeys.enabled, ContextKeyExpr.equals('view', ChatViewId)),
38
order: 9,
39
group: '1_level'
40
}
41
});
42
}
43
44
public override async run(
45
accessor: ServicesAccessor,
46
): Promise<void> {
47
const openerService = accessor.get(IOpenerService);
48
const instaService = accessor.get(IInstantiationService);
49
50
const pickers = instaService.createInstance(PromptFilePickers);
51
52
const placeholder = localize(
53
'commands.prompt.manage-skills-dialog.placeholder',
54
'Select the skill to open'
55
);
56
57
const result = await pickers.selectPromptFile({ placeholder, type: PromptsType.skill, optionEdit: false });
58
if (result !== undefined) {
59
await openerService.open(result.promptFile);
60
}
61
}
62
}
63
64
/**
65
* Helper to register the `Manage Skills` action.
66
*/
67
export function registerSkillActions(): void {
68
registerAction2(ManageSkillsAction);
69
}
70
71