@codingame/monaco-vscode-chat-service-override 9.0.2 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chat.js +8 -2
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +24 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +5 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +100 -293
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +115 -26
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +9 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +448 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +58 -43
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +2 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +7 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatGettingStarted.js +131 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +88 -88
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +4 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +6 -22
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +11 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +21 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +7 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +52 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +25 -29
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +8 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +1 -2
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +7 -8
- package/vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js +70 -20
- package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +172 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +30 -12
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +11 -15
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +5 -6
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +5 -6
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +5 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +0 -58
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +0 -412
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { DisposableStore, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { CursorChangeReason } from 'vscode/vscode/vs/editor/common/cursorEvents';
|
|
4
3
|
import { localize, localize2 } from 'vscode/vscode/vs/nls';
|
|
5
4
|
import { RawContextKey, ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
6
5
|
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
7
6
|
import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
8
|
-
import { InlineChatController
|
|
7
|
+
import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
9
8
|
import { CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_HAS_AGENT } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
10
9
|
import { EditorAction2 } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
11
10
|
import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
|
|
@@ -15,7 +14,7 @@ import { AbstractInlineChatAction } from 'vscode/vscode/vs/workbench/contrib/inl
|
|
|
15
14
|
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
16
15
|
|
|
17
16
|
const CTX_INLINE_CHAT_EXPANSION = ( (new RawContextKey('inlineChatExpansion', false, ( localize(
|
|
18
|
-
|
|
17
|
+
7267,
|
|
19
18
|
"Whether the inline chat expansion is enabled when at the end of a just-typed line"
|
|
20
19
|
)))));
|
|
21
20
|
let InlineChatExansionContextKey = class InlineChatExansionContextKey {
|
|
@@ -47,7 +46,7 @@ let InlineChatExansionContextKey = class InlineChatExansionContextKey {
|
|
|
47
46
|
const lastChangeEnds = [];
|
|
48
47
|
store.add(editor.onDidChangeCursorPosition(e => {
|
|
49
48
|
let enabled = false;
|
|
50
|
-
if (e.reason ===
|
|
49
|
+
if (e.reason === 0 ) {
|
|
51
50
|
const position = editor.getPosition();
|
|
52
51
|
const positionOffset = model.getOffsetAt(position);
|
|
53
52
|
const lineLength = model.getLineLength(position.lineNumber);
|
|
@@ -85,7 +84,7 @@ class InlineChatExpandLineAction extends EditorAction2 {
|
|
|
85
84
|
super({
|
|
86
85
|
id: 'inlineChat.startWithCurrentLine',
|
|
87
86
|
category: AbstractInlineChatAction.category,
|
|
88
|
-
title: ( localize2(
|
|
87
|
+
title: ( localize2(7268, "Start in Editor with Current Line")),
|
|
89
88
|
f1: true,
|
|
90
89
|
precondition: ( (ContextKeyExpr.and(
|
|
91
90
|
(CTX_INLINE_CHAT_VISIBLE.negate()),
|
|
@@ -121,7 +120,7 @@ class InlineChatExpandLineAction extends EditorAction2 {
|
|
|
121
120
|
finally {
|
|
122
121
|
d.dispose();
|
|
123
122
|
}
|
|
124
|
-
if (lastState ===
|
|
123
|
+
if (lastState === "CANCEL" ) {
|
|
125
124
|
model.pushEditOperations(null, undoEdits, () => null);
|
|
126
125
|
}
|
|
127
126
|
}
|
|
@@ -4,10 +4,7 @@ import { DisposableStore, MutableDisposable, dispose, combinedDisposable } from
|
|
|
4
4
|
import { isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
5
5
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
6
6
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
7
|
-
import { SaveReason } from 'vscode/vscode/vs/workbench/common/editor';
|
|
8
7
|
import { IInlineChatSessionService } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service';
|
|
9
|
-
import { InlineChatConfigKeys } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
|
|
10
|
-
import { GroupsOrder } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
11
8
|
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
|
12
9
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
13
10
|
import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
|
|
@@ -86,10 +83,10 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
86
83
|
this._saveParticipant.value = combinedDisposable(d1, d2, queue);
|
|
87
84
|
}
|
|
88
85
|
async _participate(uri, reason, progress, token) {
|
|
89
|
-
if (reason !==
|
|
86
|
+
if (reason !== 1 ) {
|
|
90
87
|
return;
|
|
91
88
|
}
|
|
92
|
-
if (!this._configService.getValue(
|
|
89
|
+
if (!this._configService.getValue("inlineChat.acceptedOrDiscardBeforeSave" )) {
|
|
93
90
|
return;
|
|
94
91
|
}
|
|
95
92
|
const sessions = ( (new Map()));
|
|
@@ -103,9 +100,9 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
103
100
|
}
|
|
104
101
|
progress.report({
|
|
105
102
|
message: sessions.size === 1
|
|
106
|
-
? ( localize(
|
|
103
|
+
? ( localize(3128, "Waiting for Inline Chat changes to be Accepted or Discarded..."))
|
|
107
104
|
: ( localize(
|
|
108
|
-
|
|
105
|
+
3129,
|
|
109
106
|
"Waiting for Inline Chat changes in {0} editors to be Accepted or Discarded...",
|
|
110
107
|
sessions.size
|
|
111
108
|
))
|
|
@@ -122,7 +119,7 @@ let InlineChatSavingServiceImpl = class InlineChatSavingServiceImpl {
|
|
|
122
119
|
}
|
|
123
120
|
_getGroupsAndOrphans(sessions) {
|
|
124
121
|
const groupByEditor = ( (new Map()));
|
|
125
|
-
for (const group of this._editorGroupService.getGroups(
|
|
122
|
+
for (const group of this._editorGroupService.getGroups(1 )) {
|
|
126
123
|
const candidate = group.activeEditorPane?.getControl();
|
|
127
124
|
if (isCodeEditor(candidate)) {
|
|
128
125
|
groupByEditor.set(candidate, group);
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
2
|
-
import { ChatWidget } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
3
|
-
|
|
4
|
-
class ChatContextAttachments extends Disposable {
|
|
5
|
-
static { this.ID = 'chatContextAttachments'; }
|
|
6
|
-
get id() {
|
|
7
|
-
return ChatContextAttachments.ID;
|
|
8
|
-
}
|
|
9
|
-
constructor(widget) {
|
|
10
|
-
super();
|
|
11
|
-
this.widget = widget;
|
|
12
|
-
this._attachedContext = ( new Set());
|
|
13
|
-
this._register(this.widget.onDidChangeContext((e) => {
|
|
14
|
-
if (e.removed) {
|
|
15
|
-
this._removeContext(e.removed);
|
|
16
|
-
}
|
|
17
|
-
}));
|
|
18
|
-
this._register(this.widget.onDidSubmitAgent(() => {
|
|
19
|
-
this._clearAttachedContext();
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
getInputState() {
|
|
23
|
-
return [...( this._attachedContext.values())];
|
|
24
|
-
}
|
|
25
|
-
setInputState(s) {
|
|
26
|
-
if (!Array.isArray(s)) {
|
|
27
|
-
s = [];
|
|
28
|
-
}
|
|
29
|
-
this._attachedContext.clear();
|
|
30
|
-
for (const attachment of s) {
|
|
31
|
-
this._attachedContext.add(attachment);
|
|
32
|
-
}
|
|
33
|
-
this.widget.setContext(true, ...s);
|
|
34
|
-
}
|
|
35
|
-
getContext() {
|
|
36
|
-
return ( new Set(( [...( this._attachedContext.values())].map((v) => v.id))));
|
|
37
|
-
}
|
|
38
|
-
setContext(overwrite, ...attachments) {
|
|
39
|
-
if (overwrite) {
|
|
40
|
-
this._attachedContext.clear();
|
|
41
|
-
}
|
|
42
|
-
for (const attachment of attachments) {
|
|
43
|
-
this._attachedContext.add(attachment);
|
|
44
|
-
}
|
|
45
|
-
this.widget.setContext(overwrite, ...attachments);
|
|
46
|
-
}
|
|
47
|
-
_removeContext(attachments) {
|
|
48
|
-
if (attachments.length) {
|
|
49
|
-
attachments.forEach(this._attachedContext.delete, this._attachedContext);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
_clearAttachedContext() {
|
|
53
|
-
this._attachedContext.clear();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
ChatWidget.CONTRIBS.push(ChatContextAttachments);
|
|
57
|
-
|
|
58
|
-
export { ChatContextAttachments };
|
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
-
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
4
|
-
import { getWordAtText } from 'vscode/vscode/vs/editor/common/core/wordHelper';
|
|
5
|
-
import { CompletionItemKind } from 'vscode/vscode/vs/editor/common/languages';
|
|
6
|
-
import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
|
|
7
|
-
import { localize } from 'vscode/vscode/vs/nls';
|
|
8
|
-
import { Action2, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
9
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
10
|
-
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
11
|
-
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
12
|
-
import { SubmitAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
|
|
13
|
-
import { IChatWidgetService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
14
|
-
import { ChatInputPart } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatInputPart';
|
|
15
|
-
import { SelectAndInsertFileAction } from 'vscode/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
|
|
16
|
-
import { getFullyQualifiedId, ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
17
|
-
import { IChatAgentService, IChatAgentNameService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
18
|
-
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestTextPart, chatSubcommandLeader, chatAgentLeader, chatVariableLeader, ChatRequestVariablePart, ChatRequestToolPart } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
19
|
-
import { IChatSlashCommandService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
|
|
20
|
-
import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
|
|
21
|
-
import { ILanguageModelToolsService } from 'vscode/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
|
|
22
|
-
import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
23
|
-
|
|
24
|
-
var BuiltinDynamicCompletions_1, VariableCompletions_1;
|
|
25
|
-
let SlashCommandCompletions = class SlashCommandCompletions extends Disposable {
|
|
26
|
-
constructor(languageFeaturesService, chatWidgetService, chatSlashCommandService) {
|
|
27
|
-
super();
|
|
28
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
29
|
-
this.chatWidgetService = chatWidgetService;
|
|
30
|
-
this.chatSlashCommandService = chatSlashCommandService;
|
|
31
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
32
|
-
_debugDisplayName: 'globalSlashCommands',
|
|
33
|
-
triggerCharacters: ['/'],
|
|
34
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
35
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
36
|
-
if (!widget || !widget.viewModel) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const range = computeCompletionRanges(model, position, /\/\w*/g);
|
|
40
|
-
if (!range) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const parsedRequest = widget.parsedInput.parts;
|
|
44
|
-
const usedAgent = parsedRequest.find(p => p instanceof ChatRequestAgentPart);
|
|
45
|
-
if (usedAgent) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const slashCommands = this.chatSlashCommandService.getCommands(widget.location);
|
|
49
|
-
if (!slashCommands) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
suggestions: ( (slashCommands.map((c, i) => {
|
|
54
|
-
const withSlash = `/${c.command}`;
|
|
55
|
-
return {
|
|
56
|
-
label: withSlash,
|
|
57
|
-
insertText: c.executeImmediately ? '' : `${withSlash} `,
|
|
58
|
-
detail: c.detail,
|
|
59
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
60
|
-
sortText: c.sortText ?? 'a'.repeat(i + 1),
|
|
61
|
-
kind: CompletionItemKind.Text,
|
|
62
|
-
command: c.executeImmediately ? { id: SubmitAction.ID, title: withSlash, arguments: [{ widget, inputValue: `${withSlash} ` }] } : undefined,
|
|
63
|
-
};
|
|
64
|
-
})))
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
SlashCommandCompletions = ( (__decorate([
|
|
71
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
72
|
-
( (__param(1, IChatWidgetService))),
|
|
73
|
-
( (__param(2, IChatSlashCommandService)))
|
|
74
|
-
], SlashCommandCompletions)));
|
|
75
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(SlashCommandCompletions, LifecyclePhase.Eventually);
|
|
76
|
-
let AgentCompletions = class AgentCompletions extends Disposable {
|
|
77
|
-
constructor(languageFeaturesService, chatWidgetService, chatAgentService, chatAgentNameService) {
|
|
78
|
-
super();
|
|
79
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
80
|
-
this.chatWidgetService = chatWidgetService;
|
|
81
|
-
this.chatAgentService = chatAgentService;
|
|
82
|
-
this.chatAgentNameService = chatAgentNameService;
|
|
83
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
84
|
-
_debugDisplayName: 'chatAgent',
|
|
85
|
-
triggerCharacters: ['@'],
|
|
86
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
87
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
88
|
-
if (!widget || !widget.viewModel) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
const parsedRequest = widget.parsedInput.parts;
|
|
92
|
-
const usedAgent = parsedRequest.find(p => p instanceof ChatRequestAgentPart);
|
|
93
|
-
if (usedAgent && !Range.containsPosition(usedAgent.editorRange, position)) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const range = computeCompletionRanges(model, position, /@\w*/g);
|
|
97
|
-
if (!range) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
const agents = this.chatAgentService.getAgents()
|
|
101
|
-
.filter(a => !a.isDefault)
|
|
102
|
-
.filter(a => a.locations.includes(widget.location));
|
|
103
|
-
return {
|
|
104
|
-
suggestions: ( (agents.map((agent, i) => {
|
|
105
|
-
const { label: agentLabel, isDupe } = this.getAgentCompletionDetails(agent);
|
|
106
|
-
return {
|
|
107
|
-
label: isDupe ?
|
|
108
|
-
{ label: agentLabel, description: agent.description, detail: ` (${agent.publisherDisplayName})` } :
|
|
109
|
-
agentLabel,
|
|
110
|
-
insertText: `${agentLabel} `,
|
|
111
|
-
detail: agent.description,
|
|
112
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
113
|
-
command: { id: AssignSelectedAgentAction.ID, title: AssignSelectedAgentAction.ID, arguments: [{ agent: agent, widget }] },
|
|
114
|
-
kind: CompletionItemKind.Text,
|
|
115
|
-
};
|
|
116
|
-
})))
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}));
|
|
120
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
121
|
-
_debugDisplayName: 'chatAgentSubcommand',
|
|
122
|
-
triggerCharacters: ['/'],
|
|
123
|
-
provideCompletionItems: async (model, position, _context, token) => {
|
|
124
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
125
|
-
if (!widget || !widget.viewModel) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const range = computeCompletionRanges(model, position, /\/\w*/g);
|
|
129
|
-
if (!range) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
const parsedRequest = widget.parsedInput.parts;
|
|
133
|
-
const usedAgentIdx = parsedRequest.findIndex((p) => p instanceof ChatRequestAgentPart);
|
|
134
|
-
if (usedAgentIdx < 0) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const usedSubcommand = parsedRequest.find(p => p instanceof ChatRequestAgentSubcommandPart);
|
|
138
|
-
if (usedSubcommand) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
for (const partAfterAgent of parsedRequest.slice(usedAgentIdx + 1)) {
|
|
142
|
-
if (!(partAfterAgent instanceof ChatRequestTextPart) || !partAfterAgent.text.trim().match(/^(\/\w*)?$/)) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const usedAgent = parsedRequest[usedAgentIdx];
|
|
147
|
-
return {
|
|
148
|
-
suggestions: ( (usedAgent.agent.slashCommands.map((c, i) => {
|
|
149
|
-
const withSlash = `/${c.name}`;
|
|
150
|
-
return {
|
|
151
|
-
label: withSlash,
|
|
152
|
-
insertText: `${withSlash} `,
|
|
153
|
-
detail: c.description,
|
|
154
|
-
range,
|
|
155
|
-
kind: CompletionItemKind.Text,
|
|
156
|
-
};
|
|
157
|
-
})))
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}));
|
|
161
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
162
|
-
_debugDisplayName: 'chatAgentAndSubcommand',
|
|
163
|
-
triggerCharacters: ['/'],
|
|
164
|
-
provideCompletionItems: async (model, position, _context, token) => {
|
|
165
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
166
|
-
const viewModel = widget?.viewModel;
|
|
167
|
-
if (!widget || !viewModel) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const range = computeCompletionRanges(model, position, /\/\w*/g);
|
|
171
|
-
if (!range) {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
const agents = this.chatAgentService.getAgents()
|
|
175
|
-
.filter(a => a.locations.includes(widget.location));
|
|
176
|
-
const getFilterText = (agent, command) => {
|
|
177
|
-
const dummyPrefix = agent.id === 'github.copilot.terminalPanel' ? `0000` : ``;
|
|
178
|
-
return `${chatSubcommandLeader}${dummyPrefix}${agent.name}.${command}`;
|
|
179
|
-
};
|
|
180
|
-
const justAgents = ( (agents
|
|
181
|
-
.filter(a => !a.isDefault)
|
|
182
|
-
.map(agent => {
|
|
183
|
-
const { label: agentLabel, isDupe } = this.getAgentCompletionDetails(agent);
|
|
184
|
-
const detail = agent.description;
|
|
185
|
-
return {
|
|
186
|
-
label: isDupe ?
|
|
187
|
-
{ label: agentLabel, description: agent.description, detail: ` (${agent.publisherDisplayName})` } :
|
|
188
|
-
agentLabel,
|
|
189
|
-
detail,
|
|
190
|
-
filterText: `${chatSubcommandLeader}${agent.name}`,
|
|
191
|
-
insertText: `${agentLabel} `,
|
|
192
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
193
|
-
kind: CompletionItemKind.Text,
|
|
194
|
-
sortText: `${chatSubcommandLeader}${agent.name}`,
|
|
195
|
-
command: { id: AssignSelectedAgentAction.ID, title: AssignSelectedAgentAction.ID, arguments: [{ agent, widget }] },
|
|
196
|
-
};
|
|
197
|
-
})));
|
|
198
|
-
return {
|
|
199
|
-
suggestions: justAgents.concat(agents.flatMap(agent => ( (agent.slashCommands.map((c, i) => {
|
|
200
|
-
const { label: agentLabel, isDupe } = this.getAgentCompletionDetails(agent);
|
|
201
|
-
const withSlash = `${chatSubcommandLeader}${c.name}`;
|
|
202
|
-
const item = {
|
|
203
|
-
label: { label: withSlash, description: agentLabel, detail: isDupe ? ` (${agent.publisherDisplayName})` : undefined },
|
|
204
|
-
filterText: getFilterText(agent, c.name),
|
|
205
|
-
commitCharacters: [' '],
|
|
206
|
-
insertText: `${agentLabel} ${withSlash} `,
|
|
207
|
-
detail: `(${agentLabel}) ${c.description ?? ''}`,
|
|
208
|
-
range: ( (new Range(1, 1, 1, 1))),
|
|
209
|
-
kind: CompletionItemKind.Text,
|
|
210
|
-
sortText: `${chatSubcommandLeader}${agent.name}${c.name}`,
|
|
211
|
-
command: { id: AssignSelectedAgentAction.ID, title: AssignSelectedAgentAction.ID, arguments: [{ agent, widget }] },
|
|
212
|
-
};
|
|
213
|
-
if (agent.isDefault) {
|
|
214
|
-
item.label = withSlash;
|
|
215
|
-
item.insertText = `${withSlash} `;
|
|
216
|
-
item.detail = c.description;
|
|
217
|
-
}
|
|
218
|
-
return item;
|
|
219
|
-
})))))
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
getAgentCompletionDetails(agent) {
|
|
225
|
-
const isAllowed = this.chatAgentNameService.getAgentNameRestriction(agent);
|
|
226
|
-
const agentLabel = `${chatAgentLeader}${isAllowed ? agent.name : getFullyQualifiedId(agent)}`;
|
|
227
|
-
const isDupe = isAllowed && this.chatAgentService.agentHasDupeName(agent.id);
|
|
228
|
-
return { label: agentLabel, isDupe };
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
AgentCompletions = ( (__decorate([
|
|
232
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
233
|
-
( (__param(1, IChatWidgetService))),
|
|
234
|
-
( (__param(2, IChatAgentService))),
|
|
235
|
-
( (__param(3, IChatAgentNameService)))
|
|
236
|
-
], AgentCompletions)));
|
|
237
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(AgentCompletions, LifecyclePhase.Eventually);
|
|
238
|
-
class AssignSelectedAgentAction extends Action2 {
|
|
239
|
-
static { this.ID = 'workbench.action.chat.assignSelectedAgent'; }
|
|
240
|
-
constructor() {
|
|
241
|
-
super({
|
|
242
|
-
id: AssignSelectedAgentAction.ID,
|
|
243
|
-
title: ''
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
async run(accessor, ...args) {
|
|
247
|
-
const arg = args[0];
|
|
248
|
-
if (!arg || !arg.widget || !arg.agent) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
arg.widget.lastSelectedAgent = arg.agent;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
registerAction2(AssignSelectedAgentAction);
|
|
255
|
-
let BuiltinDynamicCompletions = class BuiltinDynamicCompletions extends Disposable {
|
|
256
|
-
static { BuiltinDynamicCompletions_1 = this; }
|
|
257
|
-
static { this.VariableNameDef = ( (new RegExp(`${chatVariableLeader}\\w*`, 'g'))); }
|
|
258
|
-
constructor(languageFeaturesService, chatWidgetService) {
|
|
259
|
-
super();
|
|
260
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
261
|
-
this.chatWidgetService = chatWidgetService;
|
|
262
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
263
|
-
_debugDisplayName: 'chatDynamicCompletions',
|
|
264
|
-
triggerCharacters: [chatVariableLeader],
|
|
265
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
266
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
267
|
-
if (!widget || !widget.supportsFileReferences) {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
const range = computeCompletionRanges(model, position, BuiltinDynamicCompletions_1.VariableNameDef, true);
|
|
271
|
-
if (!range) {
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
274
|
-
const afterRange = ( (new Range(
|
|
275
|
-
position.lineNumber,
|
|
276
|
-
range.replace.startColumn,
|
|
277
|
-
position.lineNumber,
|
|
278
|
-
range.replace.startColumn + '#file:'.length
|
|
279
|
-
)));
|
|
280
|
-
return {
|
|
281
|
-
suggestions: [
|
|
282
|
-
{
|
|
283
|
-
label: `${chatVariableLeader}file`,
|
|
284
|
-
insertText: `${chatVariableLeader}file:`,
|
|
285
|
-
detail: ( localize(7161, "Pick a file")),
|
|
286
|
-
range,
|
|
287
|
-
kind: CompletionItemKind.Text,
|
|
288
|
-
command: { id: SelectAndInsertFileAction.ID, title: SelectAndInsertFileAction.ID, arguments: [{ widget, range: afterRange }] },
|
|
289
|
-
sortText: 'z'
|
|
290
|
-
}
|
|
291
|
-
]
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
}));
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
BuiltinDynamicCompletions = BuiltinDynamicCompletions_1 = ( (__decorate([
|
|
298
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
299
|
-
( (__param(1, IChatWidgetService)))
|
|
300
|
-
], BuiltinDynamicCompletions)));
|
|
301
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(BuiltinDynamicCompletions, LifecyclePhase.Eventually);
|
|
302
|
-
function computeCompletionRanges(model, position, reg, onlyOnWordStart = false) {
|
|
303
|
-
const varWord = getWordAtText(position.column, reg, model.getLineContent(position.lineNumber), 0);
|
|
304
|
-
if (!varWord && model.getWordUntilPosition(position).word) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
if (varWord && onlyOnWordStart) {
|
|
308
|
-
const wordBefore = model.getWordUntilPosition({ lineNumber: position.lineNumber, column: varWord.startColumn });
|
|
309
|
-
if (wordBefore.word) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
let insert;
|
|
314
|
-
let replace;
|
|
315
|
-
if (!varWord) {
|
|
316
|
-
insert = replace = Range.fromPositions(position);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
insert = ( (new Range(
|
|
320
|
-
position.lineNumber,
|
|
321
|
-
varWord.startColumn,
|
|
322
|
-
position.lineNumber,
|
|
323
|
-
position.column
|
|
324
|
-
)));
|
|
325
|
-
replace = ( (new Range(
|
|
326
|
-
position.lineNumber,
|
|
327
|
-
varWord.startColumn,
|
|
328
|
-
position.lineNumber,
|
|
329
|
-
varWord.endColumn
|
|
330
|
-
)));
|
|
331
|
-
}
|
|
332
|
-
return { insert, replace, varWord };
|
|
333
|
-
}
|
|
334
|
-
let VariableCompletions = class VariableCompletions extends Disposable {
|
|
335
|
-
static { VariableCompletions_1 = this; }
|
|
336
|
-
static { this.VariableNameDef = ( (new RegExp(`${chatVariableLeader}\\w*`, 'g'))); }
|
|
337
|
-
constructor(languageFeaturesService, chatWidgetService, chatVariablesService, configService, toolsService) {
|
|
338
|
-
super();
|
|
339
|
-
this.languageFeaturesService = languageFeaturesService;
|
|
340
|
-
this.chatWidgetService = chatWidgetService;
|
|
341
|
-
this.chatVariablesService = chatVariablesService;
|
|
342
|
-
this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
|
|
343
|
-
_debugDisplayName: 'chatVariables',
|
|
344
|
-
triggerCharacters: [chatVariableLeader],
|
|
345
|
-
provideCompletionItems: async (model, position, _context, _token) => {
|
|
346
|
-
const locations = ( (new Set()));
|
|
347
|
-
locations.add(ChatAgentLocation.Panel);
|
|
348
|
-
for (const value of ( (Object.values(ChatAgentLocation)))) {
|
|
349
|
-
if (typeof value === 'string' && configService.getValue(`chat.experimental.variables.${value}`)) {
|
|
350
|
-
locations.add(value);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
354
|
-
if (!widget || !( (locations.has(widget.location)))) {
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
const range = computeCompletionRanges(model, position, VariableCompletions_1.VariableNameDef, true);
|
|
358
|
-
if (!range) {
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
const usedAgent = widget.parsedInput.parts.find(p => p instanceof ChatRequestAgentPart);
|
|
362
|
-
const slowSupported = usedAgent ? usedAgent.agent.metadata.supportsSlowVariables : true;
|
|
363
|
-
const usedVariables = widget.parsedInput.parts.filter((p) => p instanceof ChatRequestVariablePart);
|
|
364
|
-
const usedVariableNames = ( (new Set( (usedVariables.map(v => v.variableName)))));
|
|
365
|
-
const variableItems = ( (Array.from(this.chatVariablesService.getVariables(widget.location))
|
|
366
|
-
.filter(v => !( (usedVariableNames.has(v.name))))
|
|
367
|
-
.filter(v => !v.isSlow || slowSupported)
|
|
368
|
-
.map((v) => {
|
|
369
|
-
const withLeader = `${chatVariableLeader}${v.name}`;
|
|
370
|
-
return {
|
|
371
|
-
label: withLeader,
|
|
372
|
-
range,
|
|
373
|
-
insertText: withLeader + ' ',
|
|
374
|
-
detail: v.description,
|
|
375
|
-
kind: CompletionItemKind.Text,
|
|
376
|
-
sortText: 'z'
|
|
377
|
-
};
|
|
378
|
-
})));
|
|
379
|
-
const usedTools = widget.parsedInput.parts.filter((p) => p instanceof ChatRequestToolPart);
|
|
380
|
-
const usedToolNames = ( (new Set( (usedTools.map(v => v.toolName)))));
|
|
381
|
-
const toolItems = [];
|
|
382
|
-
if (!usedAgent || usedAgent.agent.supportsToolReferences) {
|
|
383
|
-
toolItems.push(...( (Array.from(toolsService.getTools())
|
|
384
|
-
.filter(t => t.canBeInvokedManually)
|
|
385
|
-
.filter(t => !( (usedToolNames.has(t.name ?? ''))))
|
|
386
|
-
.map((t) => {
|
|
387
|
-
const withLeader = `${chatVariableLeader}${t.name}`;
|
|
388
|
-
return {
|
|
389
|
-
label: withLeader,
|
|
390
|
-
range,
|
|
391
|
-
insertText: withLeader + ' ',
|
|
392
|
-
detail: t.userDescription,
|
|
393
|
-
kind: CompletionItemKind.Text,
|
|
394
|
-
sortText: 'z'
|
|
395
|
-
};
|
|
396
|
-
}))));
|
|
397
|
-
}
|
|
398
|
-
return {
|
|
399
|
-
suggestions: [...variableItems, ...toolItems]
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
}));
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
VariableCompletions = VariableCompletions_1 = ( (__decorate([
|
|
406
|
-
( (__param(0, ILanguageFeaturesService))),
|
|
407
|
-
( (__param(1, IChatWidgetService))),
|
|
408
|
-
( (__param(2, IChatVariablesService))),
|
|
409
|
-
( (__param(3, IConfigurationService))),
|
|
410
|
-
( (__param(4, ILanguageModelToolsService)))
|
|
411
|
-
], VariableCompletions)));
|
|
412
|
-
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(VariableCompletions, LifecyclePhase.Eventually);
|