Path: blob/main/extensions/copilot/src/extension/common/constants.ts
13394 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 { ChatLocation } from '../../platform/chat/common/commonTypes';67export const enum Intent {8Explain = 'explain',9Review = 'review',10Tests = 'tests',11Fix = 'fix',12New = 'new',13NewNotebook = 'newNotebook',14notebookEditor = 'notebookEditor',15InlineChat = 'inlineChat',16Search = 'search',17SemanticSearch = 'semanticSearch',18Terminal = 'terminal',19TerminalExplain = 'terminalExplain',20VSCode = 'vscode',21Unknown = 'unknown',22SetupTests = 'setupTests',23Editor = 'editor',24Doc = 'doc',25Edit = 'edit',26Agent = 'editAgent',27Generate = 'generate',28SearchPanel = 'searchPanel',29SearchKeywords = 'searchKeywords',30AskAgent = 'askAgent',31Chronicle = 'chronicle',32}3334export const GITHUB_PLATFORM_AGENT = 'github.copilot-dynamic.platform';3536// TODO@jrieken THIS IS WEIRD. We should read this from package.json37export const agentsToCommands: Partial<Record<Intent, Record<string, Intent>>> = {38[Intent.Agent]: {39'explain': Intent.Explain,40'edit': Intent.Edit,41'review': Intent.Review,42'tests': Intent.Tests,43'fix': Intent.Fix,44'new': Intent.New,45'newNotebook': Intent.NewNotebook,46'semanticSearch': Intent.SemanticSearch,47'setupTests': Intent.SetupTests,48'compact': Intent.Agent,49'chronicle': Intent.Chronicle,50'chronicle:standup': Intent.Chronicle,51'chronicle:tips': Intent.Chronicle,52'chronicle:reindex': Intent.Chronicle,53},54[Intent.VSCode]: {55'search': Intent.Search,56},57[Intent.Terminal]: {58'explain': Intent.TerminalExplain59},60[Intent.Editor]: {61'doc': Intent.Doc,62'fix': Intent.Fix,63'explain': Intent.Explain,64'review': Intent.Review,65'tests': Intent.Tests,66'edit': Intent.Edit,67'generate': Intent.Generate68}69};7071// TODO@roblourens gotta tighten up the terminology of "commands", "intents", etc...72export function getAgentForIntent(intentId: Intent, location: ChatLocation): { agent: string; command?: string } | undefined {73if (Object.keys(agentsToCommands).includes(intentId)) {74return { agent: intentId };75}7677for (const [agent, commands] of Object.entries(agentsToCommands)) {78if (location === ChatLocation.Editor && agent !== Intent.Editor) {79continue;80}8182if (Object.values(commands).includes(intentId)) {83return { agent, command: intentId };84}85}86}8788export const EXTENSION_ID = 'GitHub.copilot-chat';899091