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