Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagement.ts
13406 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 { RawContextKey } from '../../../../../platform/contextkey/common/contextkey.js';
7
import { AICustomizationManagementSection } from '../../common/aiCustomizationWorkspaceService.js';
8
import { PromptsType } from '../../common/promptSyntax/promptTypes.js';
9
import { localize } from '../../../../../nls.js';
10
import { MenuId } from '../../../../../platform/actions/common/actions.js';
11
12
// Re-export for convenience — consumers import from this file
13
export { AICustomizationManagementSection } from '../../common/aiCustomizationWorkspaceService.js';
14
export type { AICustomizationPromptsStorage } from '../../common/aiCustomizationWorkspaceService.js';
15
export { BUILTIN_STORAGE } from '../../common/aiCustomizationWorkspaceService.js';
16
17
export function sectionToPromptType(section: AICustomizationManagementSection): PromptsType {
18
switch (section) {
19
case AICustomizationManagementSection.Agents:
20
return PromptsType.agent;
21
case AICustomizationManagementSection.Skills:
22
return PromptsType.skill;
23
case AICustomizationManagementSection.Instructions:
24
return PromptsType.instructions;
25
case AICustomizationManagementSection.Hooks:
26
return PromptsType.hook;
27
case AICustomizationManagementSection.Prompts:
28
default:
29
return PromptsType.prompt;
30
}
31
}
32
33
/**
34
* Editor pane ID for the AI Customizations Management Editor.
35
*/
36
export const AI_CUSTOMIZATION_MANAGEMENT_EDITOR_ID = 'workbench.editor.aiCustomizationManagement';
37
38
/**
39
* Editor input type ID for serialization.
40
*/
41
export const AI_CUSTOMIZATION_MANAGEMENT_EDITOR_INPUT_ID = 'workbench.input.aiCustomizationManagement';
42
43
/**
44
* Command IDs for the AI Customizations Management Editor.
45
*/
46
export const AICustomizationManagementCommands = {
47
OpenEditor: 'aiCustomization.openManagementEditor',
48
OpenMarketplace: 'aiCustomization.openMarketplace',
49
CreateNewAgent: 'aiCustomization.createNewAgent',
50
CreateNewSkill: 'aiCustomization.createNewSkill',
51
CreateNewInstructions: 'aiCustomization.createNewInstructions',
52
CreateNewPrompt: 'aiCustomization.createNewPrompt',
53
GenerateDebugReport: 'aiCustomization.generateDebugReport',
54
} as const;
55
56
/**
57
* Context key indicating the AI Customization Management Editor is focused.
58
*/
59
export const CONTEXT_AI_CUSTOMIZATION_MANAGEMENT_EDITOR = new RawContextKey<boolean>(
60
'aiCustomizationManagementEditorFocused',
61
false,
62
localize('aiCustomizationManagementEditorFocused', "Whether the Agent Customizations editor is focused")
63
);
64
65
/**
66
* Context key for the currently selected section.
67
*/
68
export const CONTEXT_AI_CUSTOMIZATION_MANAGEMENT_SECTION = new RawContextKey<string>(
69
'chatCustomizationSection',
70
AICustomizationManagementSection.Agents,
71
localize('chatCustomizationSection', "The currently selected section in the Agent Customizations editor")
72
);
73
74
/**
75
* Context key for the active harness (session type) in the customizations editor.
76
* Extensions use this in when-clauses to scope create actions to their harness.
77
*/
78
export const CONTEXT_AI_CUSTOMIZATION_MANAGEMENT_HARNESS = new RawContextKey<string>(
79
'chatCustomizationSessionType',
80
'',
81
localize('chatCustomizationSessionType', "The active harness (session type) in the Agent Customizations editor")
82
);
83
84
/**
85
* Menu ID for the AI Customization Management Editor title bar actions.
86
*/
87
export const AICustomizationManagementTitleMenuId = MenuId.for('AICustomizationManagementEditorTitle');
88
89
/**
90
* Menu ID for the AI Customization Management Editor item context menu.
91
*/
92
export const AICustomizationManagementItemMenuId = MenuId.for('AICustomizationManagementEditorItem');
93
94
/**
95
* Menu ID for the AI Customization Management Editor create/add button.
96
* Extensions can contribute commands here to add create actions to the section's add button dropdown.
97
* Use the `chatCustomizationSection` context key to target a specific section.
98
*/
99
export const AICustomizationManagementCreateMenuId = MenuId.for('AICustomizationManagementCreate');
100
101
/**
102
* Context key for the item prompt type (e.g. 'prompt', 'agent') used in when-clause filtering.
103
*/
104
export const AI_CUSTOMIZATION_ITEM_TYPE_KEY = 'aiCustomizationManagementItemType';
105
106
/**
107
* Context key for the item storage type (e.g. 'local', 'user', 'extension') used in when-clause filtering.
108
*/
109
export const AI_CUSTOMIZATION_ITEM_STORAGE_KEY = 'aiCustomizationManagementItemStorage';
110
111
/**
112
* Context key for the item URI used in when-clause filtering.
113
*/
114
export const AI_CUSTOMIZATION_ITEM_URI_KEY = 'aiCustomizationManagementItemUri';
115
116
/**
117
* Context key for the parent plugin URI, set when the item is provided by a plugin.
118
*/
119
export const AI_CUSTOMIZATION_ITEM_PLUGIN_URI_KEY = 'aiCustomizationManagementItemPluginUri';
120
121
/**
122
* Context key indicating whether the item is disabled.
123
*/
124
export const AI_CUSTOMIZATION_ITEM_DISABLED_KEY = 'aiCustomizationManagementItemDisabled';
125
126
127
/**
128
* Storage key for persisting the selected section.
129
*/
130
export const AI_CUSTOMIZATION_MANAGEMENT_SELECTED_SECTION_KEY = 'aiCustomizationManagement.selectedSection';
131
132
/**
133
* Storage key for persisting the sidebar width.
134
*/
135
export const AI_CUSTOMIZATION_MANAGEMENT_SIDEBAR_WIDTH_KEY = 'aiCustomizationManagement.sidebarWidth';
136
137
/**
138
* Storage key for persisting the search query.
139
*/
140
export const AI_CUSTOMIZATION_MANAGEMENT_SEARCH_KEY = 'aiCustomizationManagement.searchQuery';
141
142
/**
143
* Layout constants for the editor.
144
*/
145
export const SIDEBAR_DEFAULT_WIDTH = 200;
146
export const SIDEBAR_MIN_WIDTH = 150;
147
export const SIDEBAR_MAX_WIDTH = 350;
148
export const CONTENT_MIN_WIDTH = 400;
149
150