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