@codingame/monaco-vscode-chat-service-override 17.2.1 → 18.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/index.js +7 -4
- package/package.json +36 -30
- package/vscode/src/vs/base/common/objectCache.d.ts +2 -2
- package/vscode/src/vs/base/common/objectCache.js +3 -3
- package/vscode/src/vs/platform/browserElements/common/browserElements.d.ts +10 -0
- package/vscode/src/vs/platform/browserElements/common/browserElements.js +9 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +40 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +158 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +13 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +256 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +3 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +234 -572
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +4 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +29 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolActions.js +107 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.js +344 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +84 -37
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatAttachInstructionsAction.d.ts +18 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatAttachInstructionsAction.js +137 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatModeActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatModeActions.js +54 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatRunPromptAction.js +40 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatSaveToPromptAction.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatSaveToPromptAction.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/promptFilePickers.d.ts +15 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/promptFilePickers.js +171 -101
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/utils/attachInstructions.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/utils/attachInstructions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/utils/runPrompt.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/index.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/index.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +176 -69
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +15 -29
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorAccessibility.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +22 -22
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +35 -29
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +80 -32
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +11 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +12 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +13 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +15 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSessionStorage.js +3 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +10 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +18 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/simpleBrowserEditorOverlay.js +118 -33
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +1 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +46 -48
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +379 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +31 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +382 -152
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +99 -56
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +11 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +1 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +9 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +10 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +18 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +95 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +92 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/media/github.svg +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/google.svg +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/simpleBrowserOverlay.css +10 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +111 -111
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.d.ts +3 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +36 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.d.ts +5 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +91 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +1 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.js +95 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.js +348 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatResponseResourceFileSystemProvider.d.ts +30 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatResponseResourceFileSystemProvider.js +93 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +5 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +46 -36
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/configMigration.d.ts +5 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/configMigration.js +21 -11
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/index.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/index.js +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptHeaderDiagnosticsProvider.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptHeaderDiagnosticsProvider.js +12 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptLinkDiagnosticsProvider.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptLinkDiagnosticsProvider.js +1 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptLinkProvider.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptPathAutocompletion.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceBase.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceBase.js +9 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceManagerBase.d.ts +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceManagerBase.js +12 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.d.ts +21 -10
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +111 -124
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +22 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +159 -97
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.d.ts +15 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.js +2 -14
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +8 -2
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +198 -33
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +7 -7
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +28 -18
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/attachInstructionsCommand.d.ts +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/attachInstructionsCommand.js +0 -73
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterDecoration.d.ts +0 -29
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterDecoration.js +0 -74
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterMarkerDecoration.d.ts +0 -14
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterMarkerDecoration.js +0 -40
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/decorationBase.d.ts +0 -23
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/decorationBase.js +0 -40
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/index.d.ts +0 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/index.js +0 -9
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/reactiveDecorationBase.d.ts +0 -23
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/reactiveDecorationBase.js +0 -68
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/types.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/promptDecorationsProvider.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/promptDecorationsProvider.js +0 -121
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/types.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/types.js +0 -13
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
|
|
2
|
+
import { assertNever } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
3
|
+
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
4
|
+
import { diffSets } from '@codingame/monaco-vscode-api/vscode/vs/base/common/collections';
|
|
5
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
6
|
+
import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
|
|
7
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
9
|
+
import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
10
|
+
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
11
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
12
|
+
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
13
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
14
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
15
|
+
import { IExtensionsWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/extensions/common/extensions.service';
|
|
16
|
+
import { AddConfigurationAction } from '@codingame/monaco-vscode-aa9ead53-dfd3-59da-b9e7-f163d201de8d-common/vscode/vs/workbench/contrib/mcp/browser/mcpCommands';
|
|
17
|
+
import { IMcpRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpRegistryTypes.service';
|
|
18
|
+
import { McpConnectionState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes';
|
|
19
|
+
import { IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
20
|
+
import { ToolDataSource, ToolSet } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService';
|
|
21
|
+
import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
|
|
22
|
+
import { ConfigureToolSets } from '../tools/toolSetsContribution.js';
|
|
23
|
+
|
|
24
|
+
var BucketOrdinal;
|
|
25
|
+
(function (BucketOrdinal) {
|
|
26
|
+
BucketOrdinal[BucketOrdinal["User"] = 0] = "User";
|
|
27
|
+
BucketOrdinal[BucketOrdinal["BuiltIn"] = 1] = "BuiltIn";
|
|
28
|
+
BucketOrdinal[BucketOrdinal["Mcp"] = 2] = "Mcp";
|
|
29
|
+
BucketOrdinal[BucketOrdinal["Extension"] = 3] = "Extension";
|
|
30
|
+
})(BucketOrdinal || (BucketOrdinal = {}));
|
|
31
|
+
function isBucketPick(obj) {
|
|
32
|
+
return Boolean(obj.children);
|
|
33
|
+
}
|
|
34
|
+
function isToolSetPick(obj) {
|
|
35
|
+
return Boolean(obj.toolset);
|
|
36
|
+
}
|
|
37
|
+
function isToolPick(obj) {
|
|
38
|
+
return Boolean(obj.tool);
|
|
39
|
+
}
|
|
40
|
+
function isCallbackPick(obj) {
|
|
41
|
+
return Boolean(obj.run);
|
|
42
|
+
}
|
|
43
|
+
function isActionableButton(obj) {
|
|
44
|
+
return typeof obj.action === 'function';
|
|
45
|
+
}
|
|
46
|
+
async function showToolsPicker(accessor, placeHolder, toolsEntries, onUpdate) {
|
|
47
|
+
const quickPickService = accessor.get(IQuickInputService);
|
|
48
|
+
const mcpService = accessor.get(IMcpService);
|
|
49
|
+
const mcpRegistry = accessor.get(IMcpRegistry);
|
|
50
|
+
const commandService = accessor.get(ICommandService);
|
|
51
|
+
const extensionWorkbenchService = accessor.get(IExtensionsWorkbenchService);
|
|
52
|
+
const editorService = accessor.get(IEditorService);
|
|
53
|
+
const toolsService = accessor.get(ILanguageModelToolsService);
|
|
54
|
+
const mcpServerByTool = ( new Map());
|
|
55
|
+
for (const server of mcpService.servers.get()) {
|
|
56
|
+
for (const tool of server.tools.get()) {
|
|
57
|
+
mcpServerByTool.set(tool.id, server);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const builtinBucket = {
|
|
61
|
+
type: 'item',
|
|
62
|
+
children: [],
|
|
63
|
+
label: ( localize(4498, "Built-In")),
|
|
64
|
+
ordinal: BucketOrdinal.BuiltIn,
|
|
65
|
+
picked: false,
|
|
66
|
+
};
|
|
67
|
+
const userBucket = {
|
|
68
|
+
type: 'item',
|
|
69
|
+
children: [],
|
|
70
|
+
label: ( localize(4499, "User Defined Tool Sets")),
|
|
71
|
+
ordinal: BucketOrdinal.User,
|
|
72
|
+
alwaysShow: true,
|
|
73
|
+
picked: false,
|
|
74
|
+
};
|
|
75
|
+
const addMcpPick = { type: 'item', label: ( localize(4500, "Add MCP Server...")), iconClass: ThemeIcon.asClassName(Codicon.add), pickable: false, run: () => commandService.executeCommand(AddConfigurationAction.ID) };
|
|
76
|
+
const configureToolSetsPick = { type: 'item', label: ( localize(4501, "Configure Tool Sets...")), iconClass: ThemeIcon.asClassName(Codicon.gear), pickable: false, run: () => commandService.executeCommand(ConfigureToolSets.ID) };
|
|
77
|
+
const addExpPick = { type: 'item', label: ( localize(4502, "Install Extension...")), iconClass: ThemeIcon.asClassName(Codicon.add), pickable: false, run: () => extensionWorkbenchService.openSearch('@tag:language-model-tools') };
|
|
78
|
+
const addPick = {
|
|
79
|
+
type: 'item', label: ( localize(4503, "Add More Tools...")), iconClass: ThemeIcon.asClassName(Codicon.add), pickable: false, run: async () => {
|
|
80
|
+
const pick = await quickPickService.pick([addMcpPick, addExpPick], {
|
|
81
|
+
canPickMany: false,
|
|
82
|
+
placeHolder: ( localize(4504, "Add tools to chat"))
|
|
83
|
+
});
|
|
84
|
+
pick?.run();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const toolBuckets = ( new Map());
|
|
88
|
+
if (!toolsEntries) {
|
|
89
|
+
const defaultEntries = ( new Map());
|
|
90
|
+
for (const tool of toolsService.getTools()) {
|
|
91
|
+
defaultEntries.set(tool, false);
|
|
92
|
+
}
|
|
93
|
+
for (const toolSet of toolsService.toolSets.get()) {
|
|
94
|
+
defaultEntries.set(toolSet, false);
|
|
95
|
+
}
|
|
96
|
+
toolsEntries = defaultEntries;
|
|
97
|
+
}
|
|
98
|
+
for (const [toolSetOrTool, picked] of toolsEntries) {
|
|
99
|
+
let bucket;
|
|
100
|
+
const buttons = [];
|
|
101
|
+
if (toolSetOrTool.source.type === 'mcp') {
|
|
102
|
+
const key = ToolDataSource.toKey(toolSetOrTool.source);
|
|
103
|
+
const { definitionId } = toolSetOrTool.source;
|
|
104
|
+
const mcpServer = mcpService.servers.get().find(candidate => candidate.definition.id === definitionId);
|
|
105
|
+
if (!mcpServer) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const buttons = [];
|
|
109
|
+
bucket = toolBuckets.get(key) ?? {
|
|
110
|
+
type: 'item',
|
|
111
|
+
label: ( localize(4505, "MCP Server: {0}", toolSetOrTool.source.label)),
|
|
112
|
+
ordinal: BucketOrdinal.Mcp,
|
|
113
|
+
picked: false,
|
|
114
|
+
alwaysShow: true,
|
|
115
|
+
children: [],
|
|
116
|
+
buttons
|
|
117
|
+
};
|
|
118
|
+
toolBuckets.set(key, bucket);
|
|
119
|
+
const collection = mcpRegistry.collections.get().find(c => c.id === mcpServer.collection.id);
|
|
120
|
+
if (collection?.presentation?.origin) {
|
|
121
|
+
buttons.push({
|
|
122
|
+
iconClass: ThemeIcon.asClassName(Codicon.settingsGear),
|
|
123
|
+
tooltip: ( localize(4506, "Configure {0}", collection.label)),
|
|
124
|
+
action: () => editorService.openEditor({
|
|
125
|
+
resource: collection.presentation.origin,
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (mcpServer.connectionState.get().state === McpConnectionState.Kind.Error) {
|
|
130
|
+
buttons.push({
|
|
131
|
+
iconClass: ThemeIcon.asClassName(Codicon.warning),
|
|
132
|
+
tooltip: ( localize(4507, "Show Output")),
|
|
133
|
+
action: () => mcpServer.showOutput(),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (toolSetOrTool.source.type === 'extension') {
|
|
138
|
+
const key = ToolDataSource.toKey(toolSetOrTool.source);
|
|
139
|
+
bucket = toolBuckets.get(key) ?? {
|
|
140
|
+
type: 'item',
|
|
141
|
+
label: ( localize(4508, 'Extension: {0}', toolSetOrTool.source.label)),
|
|
142
|
+
ordinal: BucketOrdinal.Extension,
|
|
143
|
+
picked: false,
|
|
144
|
+
alwaysShow: true,
|
|
145
|
+
children: []
|
|
146
|
+
};
|
|
147
|
+
toolBuckets.set(key, bucket);
|
|
148
|
+
}
|
|
149
|
+
else if (toolSetOrTool.source.type === 'internal') {
|
|
150
|
+
bucket = builtinBucket;
|
|
151
|
+
}
|
|
152
|
+
else if (toolSetOrTool.source.type === 'user') {
|
|
153
|
+
bucket = userBucket;
|
|
154
|
+
buttons.push({
|
|
155
|
+
iconClass: ThemeIcon.asClassName(Codicon.edit),
|
|
156
|
+
tooltip: ( localize(4509, "Edit Tool Set")),
|
|
157
|
+
action: () => {
|
|
158
|
+
assertType(toolSetOrTool.source.type === 'user');
|
|
159
|
+
editorService.openEditor({ resource: toolSetOrTool.source.file });
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
assertNever();
|
|
165
|
+
}
|
|
166
|
+
if (toolSetOrTool instanceof ToolSet) {
|
|
167
|
+
if (toolSetOrTool.source.type !== 'mcp') {
|
|
168
|
+
bucket.children.push({
|
|
169
|
+
parent: bucket,
|
|
170
|
+
type: 'item',
|
|
171
|
+
picked,
|
|
172
|
+
toolset: toolSetOrTool,
|
|
173
|
+
label: toolSetOrTool.referenceName,
|
|
174
|
+
description: toolSetOrTool.description,
|
|
175
|
+
indented: true,
|
|
176
|
+
buttons
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
bucket.toolset = toolSetOrTool;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (toolSetOrTool.canBeReferencedInPrompt) {
|
|
184
|
+
bucket.children.push({
|
|
185
|
+
parent: bucket,
|
|
186
|
+
type: 'item',
|
|
187
|
+
picked,
|
|
188
|
+
tool: toolSetOrTool,
|
|
189
|
+
label: toolSetOrTool.toolReferenceName ?? toolSetOrTool.displayName,
|
|
190
|
+
description: toolSetOrTool.userDescription ?? toolSetOrTool.modelDescription,
|
|
191
|
+
indented: true,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (picked) {
|
|
195
|
+
bucket.picked = true;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
for (const bucket of [builtinBucket, userBucket]) {
|
|
199
|
+
if (bucket.children.length > 0) {
|
|
200
|
+
toolBuckets.set(generateUuid(), bucket);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const store = ( new DisposableStore());
|
|
204
|
+
const picks = [];
|
|
205
|
+
for (const bucket of Array.from(( toolBuckets.values())).sort((a, b) => a.ordinal - b.ordinal)) {
|
|
206
|
+
picks.push({
|
|
207
|
+
type: 'separator',
|
|
208
|
+
label: bucket.status
|
|
209
|
+
});
|
|
210
|
+
picks.push(bucket);
|
|
211
|
+
picks.push(...bucket.children.sort((a, b) => a.label.localeCompare(b.label)));
|
|
212
|
+
}
|
|
213
|
+
const picker = store.add(quickPickService.createQuickPick({ useSeparators: true }));
|
|
214
|
+
picker.placeholder = placeHolder;
|
|
215
|
+
picker.canSelectMany = true;
|
|
216
|
+
picker.keepScrollPosition = true;
|
|
217
|
+
picker.sortByLabel = false;
|
|
218
|
+
picker.matchOnDescription = true;
|
|
219
|
+
if (picks.length === 0) {
|
|
220
|
+
picker.placeholder = ( localize(4504, "Add tools to chat"));
|
|
221
|
+
picker.canSelectMany = false;
|
|
222
|
+
picks.push(addMcpPick, addExpPick);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
picks.push({ type: 'separator' }, configureToolSetsPick, addPick);
|
|
226
|
+
}
|
|
227
|
+
let lastSelectedItems = ( new Set());
|
|
228
|
+
let ignoreEvent = false;
|
|
229
|
+
const result = ( new Map());
|
|
230
|
+
const _update = () => {
|
|
231
|
+
ignoreEvent = true;
|
|
232
|
+
try {
|
|
233
|
+
const items = picks.filter((p) => p.type === 'item' && Boolean(p.picked));
|
|
234
|
+
lastSelectedItems = ( new Set(items));
|
|
235
|
+
picker.selectedItems = items;
|
|
236
|
+
result.clear();
|
|
237
|
+
for (const item of picks) {
|
|
238
|
+
if (item.type !== 'item') {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (isToolSetPick(item)) {
|
|
242
|
+
result.set(item.toolset, item.picked);
|
|
243
|
+
}
|
|
244
|
+
else if (isToolPick(item)) {
|
|
245
|
+
result.set(item.tool, item.picked);
|
|
246
|
+
}
|
|
247
|
+
else if (isBucketPick(item)) {
|
|
248
|
+
if (item.toolset) {
|
|
249
|
+
result.set(item.toolset, item.picked);
|
|
250
|
+
}
|
|
251
|
+
for (const child of item.children) {
|
|
252
|
+
if (isToolSetPick(child)) {
|
|
253
|
+
result.set(child.toolset, item.picked);
|
|
254
|
+
}
|
|
255
|
+
else if (isToolPick(child)) {
|
|
256
|
+
result.set(child.tool, item.picked);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (onUpdate) {
|
|
262
|
+
let didChange = toolsEntries.size !== result.size;
|
|
263
|
+
for (const [key, value] of toolsEntries) {
|
|
264
|
+
if (didChange) {
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
didChange = result.get(key) !== value;
|
|
268
|
+
}
|
|
269
|
+
if (didChange) {
|
|
270
|
+
onUpdate(result);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
ignoreEvent = false;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
_update();
|
|
279
|
+
picker.items = picks;
|
|
280
|
+
picker.show();
|
|
281
|
+
store.add(picker.onDidTriggerItemButton(e => {
|
|
282
|
+
if (isActionableButton(e.button)) {
|
|
283
|
+
e.button.action();
|
|
284
|
+
store.dispose();
|
|
285
|
+
}
|
|
286
|
+
}));
|
|
287
|
+
store.add(picker.onDidChangeSelection(selectedPicks => {
|
|
288
|
+
if (ignoreEvent) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const addPick = selectedPicks.find(isCallbackPick);
|
|
292
|
+
if (addPick) {
|
|
293
|
+
addPick.run();
|
|
294
|
+
picker.hide();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const { added, removed } = diffSets(lastSelectedItems, ( new Set(selectedPicks)));
|
|
298
|
+
for (const item of added) {
|
|
299
|
+
item.picked = true;
|
|
300
|
+
if (isBucketPick(item)) {
|
|
301
|
+
for (const toolPick of item.children) {
|
|
302
|
+
toolPick.picked = true;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else if (isToolPick(item) || isToolSetPick(item)) {
|
|
306
|
+
item.parent.picked = true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
for (const item of removed) {
|
|
310
|
+
item.picked = false;
|
|
311
|
+
if (isBucketPick(item)) {
|
|
312
|
+
for (const toolPick of item.children) {
|
|
313
|
+
toolPick.picked = false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else if ((isToolPick(item) || isToolSetPick(item)) && item.parent.children.every(child => !child.picked)) {
|
|
317
|
+
item.parent.picked = false;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
_update();
|
|
321
|
+
}));
|
|
322
|
+
let didAccept = false;
|
|
323
|
+
store.add(picker.onDidAccept(() => {
|
|
324
|
+
picker.activeItems.find(isCallbackPick)?.run();
|
|
325
|
+
didAccept = true;
|
|
326
|
+
}));
|
|
327
|
+
await Promise.race([Event.toPromise(Event.any(picker.onDidAccept, picker.onDidHide))]);
|
|
328
|
+
store.dispose();
|
|
329
|
+
const mcpToolSets = ( new Set());
|
|
330
|
+
for (const item of toolsService.toolSets.get()) {
|
|
331
|
+
if (item.source.type === 'mcp') {
|
|
332
|
+
mcpToolSets.add(item);
|
|
333
|
+
if (Iterable.every(item.getTools(), tool => result.get(tool))) {
|
|
334
|
+
for (const tool of item.getTools()) {
|
|
335
|
+
result.delete(tool);
|
|
336
|
+
}
|
|
337
|
+
result.set(item, true);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return didAccept ? result : undefined;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export { showToolsPicker };
|
|
@@ -32,7 +32,6 @@ export declare class ApplyCodeBlockOperation {
|
|
|
32
32
|
private readonly editorService;
|
|
33
33
|
private readonly textFileService;
|
|
34
34
|
private readonly chatService;
|
|
35
|
-
private readonly languageService;
|
|
36
35
|
private readonly fileService;
|
|
37
36
|
private readonly dialogService;
|
|
38
37
|
private readonly logService;
|
|
@@ -42,14 +41,16 @@ export declare class ApplyCodeBlockOperation {
|
|
|
42
41
|
private readonly labelService;
|
|
43
42
|
private readonly instantiationService;
|
|
44
43
|
private readonly notebookService;
|
|
45
|
-
constructor(editorService: IEditorService, textFileService: ITextFileService, chatService: IChatService,
|
|
44
|
+
constructor(editorService: IEditorService, textFileService: ITextFileService, chatService: IChatService, fileService: IFileService, dialogService: IDialogService, logService: ILogService, codeMapperService: ICodeMapperService, progressService: IProgressService, quickInputService: IQuickInputService, labelService: ILabelService, instantiationService: IInstantiationService, notebookService: INotebookService);
|
|
46
45
|
run(context: ICodeBlockActionContext): Promise<void>;
|
|
47
46
|
private evaluateURIToUse;
|
|
48
47
|
private handleNotebookEditor;
|
|
49
48
|
private handleTextEditor;
|
|
50
|
-
private
|
|
49
|
+
private getTextEdits;
|
|
50
|
+
private getNotebookEdits;
|
|
51
51
|
private waitForFirstElement;
|
|
52
52
|
private applyWithInlinePreview;
|
|
53
|
+
private applyNotebookEditsWithInlinePreview;
|
|
53
54
|
private tryToRevealCodeBlock;
|
|
54
55
|
private notify;
|
|
55
56
|
}
|
|
@@ -22,12 +22,12 @@ import { ProgressLocation } from '@codingame/monaco-vscode-api/vscode/vs/platfor
|
|
|
22
22
|
import { IProgressService } from '@codingame/monaco-vscode-api/vscode/vs/platform/progress/common/progress.service';
|
|
23
23
|
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
24
24
|
import { ITextFileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
|
25
|
-
import { reviewEdits } from '@codingame/monaco-vscode-
|
|
25
|
+
import { reviewEdits, reviewNotebookEdits } from '@codingame/monaco-vscode-6c0f93b9-169c-58c3-a9cb-7d60698eb52c-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
26
26
|
import { insertCell } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/notebook/browser/controller/cellOperations';
|
|
27
27
|
import { CellKind, NOTEBOOK_EDITOR_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
28
28
|
import { ICodeMapperService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatCodeMapperService.service';
|
|
29
29
|
import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
|
|
30
|
-
import { isResponseVM } from '@codingame/monaco-vscode-
|
|
30
|
+
import { isResponseVM } from '@codingame/monaco-vscode-3a35f433-1297-5707-ab58-c261b8180e6d-common/vscode/vs/workbench/contrib/chat/common/chatViewModel';
|
|
31
31
|
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
32
32
|
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
33
33
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
@@ -55,7 +55,7 @@ let InsertCodeBlockOperation = class InsertCodeBlockOperation {
|
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
57
|
this.notify(( localize(
|
|
58
|
-
|
|
58
|
+
4510,
|
|
59
59
|
"To insert the code block, open a code editor or notebook editor and set the cursor at the location where to insert the code block."
|
|
60
60
|
)));
|
|
61
61
|
}
|
|
@@ -68,7 +68,7 @@ let InsertCodeBlockOperation = class InsertCodeBlockOperation {
|
|
|
68
68
|
}
|
|
69
69
|
async handleNotebookEditor(notebookEditor, codeBlockContext) {
|
|
70
70
|
if (notebookEditor.isReadOnly) {
|
|
71
|
-
this.notify(( localize(
|
|
71
|
+
this.notify(( localize(4511, "Cannot insert the code block to read-only notebook editor.")));
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
74
74
|
const focusRange = notebookEditor.getFocus();
|
|
@@ -79,7 +79,7 @@ let InsertCodeBlockOperation = class InsertCodeBlockOperation {
|
|
|
79
79
|
async handleTextEditor(codeEditor, codeBlockContext) {
|
|
80
80
|
const activeModel = codeEditor.getModel();
|
|
81
81
|
if (isReadOnly(activeModel, this.textFileService)) {
|
|
82
|
-
this.notify(( localize(
|
|
82
|
+
this.notify(( localize(4512, "Cannot insert the code block to read-only code editor.")));
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
85
85
|
const range = codeEditor.getSelection() ?? ( new Range(activeModel.getLineCount(), 1, activeModel.getLineCount(), 1));
|
|
@@ -103,11 +103,10 @@ InsertCodeBlockOperation = ( __decorate([
|
|
|
103
103
|
( __param(6, IDialogService))
|
|
104
104
|
], InsertCodeBlockOperation));
|
|
105
105
|
let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
106
|
-
constructor(editorService, textFileService, chatService,
|
|
106
|
+
constructor(editorService, textFileService, chatService, fileService, dialogService, logService, codeMapperService, progressService, quickInputService, labelService, instantiationService, notebookService) {
|
|
107
107
|
this.editorService = editorService;
|
|
108
108
|
this.textFileService = textFileService;
|
|
109
109
|
this.chatService = chatService;
|
|
110
|
-
this.languageService = languageService;
|
|
111
110
|
this.fileService = fileService;
|
|
112
111
|
this.dialogService = dialogService;
|
|
113
112
|
this.logService = logService;
|
|
@@ -133,7 +132,7 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
133
132
|
activeEditorControl = codeEditor;
|
|
134
133
|
}
|
|
135
134
|
else {
|
|
136
|
-
this.notify(( localize(
|
|
135
|
+
this.notify(( localize(4513, "Failed to open {0} in a code editor.", (codemapperUri.toString()))));
|
|
137
136
|
return;
|
|
138
137
|
}
|
|
139
138
|
}
|
|
@@ -149,10 +148,10 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
149
148
|
else {
|
|
150
149
|
const activeNotebookEditor = getActiveNotebookEditor(this.editorService);
|
|
151
150
|
if (activeNotebookEditor) {
|
|
152
|
-
result = await this.handleNotebookEditor(activeNotebookEditor, context.code);
|
|
151
|
+
result = await this.handleNotebookEditor(activeNotebookEditor, context.chatSessionId, context.code);
|
|
153
152
|
}
|
|
154
153
|
else {
|
|
155
|
-
this.notify(( localize(
|
|
154
|
+
this.notify(( localize(4514, "To apply this code block, open a code or notebook editor.")));
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
notifyUserAction(this.chatService, context, {
|
|
@@ -168,15 +167,15 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
168
167
|
return resource;
|
|
169
168
|
}
|
|
170
169
|
const activeEditorOption = activeEditorControl?.getModel().uri ? { label: ( localize(
|
|
171
|
-
|
|
170
|
+
4515,
|
|
172
171
|
"Active editor '{0}'",
|
|
173
172
|
this.labelService.getUriLabel(activeEditorControl.getModel().uri, { relative: true })
|
|
174
173
|
)), id: 'activeEditor' } : undefined;
|
|
175
|
-
const untitledEditorOption = { label: ( localize(
|
|
174
|
+
const untitledEditorOption = { label: ( localize(4516, "New untitled editor")), id: 'newUntitledFile' };
|
|
176
175
|
const options = [];
|
|
177
176
|
if (resource) {
|
|
178
177
|
options.push({ label: ( localize(
|
|
179
|
-
|
|
178
|
+
4517,
|
|
180
179
|
"New file '{0}'",
|
|
181
180
|
this.labelService.getUriLabel(resource, { relative: true })
|
|
182
181
|
)), id: 'createFile' });
|
|
@@ -191,7 +190,7 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
191
190
|
}
|
|
192
191
|
options.push(untitledEditorOption);
|
|
193
192
|
}
|
|
194
|
-
const selected = options.length > 1 ? await this.quickInputService.pick(options, { placeHolder: ( localize(
|
|
193
|
+
const selected = options.length > 1 ? await this.quickInputService.pick(options, { placeHolder: ( localize(4518, "Select where to apply the code block")) }) : options[0];
|
|
195
194
|
if (selected) {
|
|
196
195
|
switch (selected.id) {
|
|
197
196
|
case 'createFile':
|
|
@@ -200,7 +199,7 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
200
199
|
await this.fileService.writeFile(resource, VSBuffer.fromString(''));
|
|
201
200
|
}
|
|
202
201
|
catch (error) {
|
|
203
|
-
this.notify(( localize(
|
|
202
|
+
this.notify(( localize(4519, "Failed to create file: {0}", error.message)));
|
|
204
203
|
return ( URI.from({ scheme: 'untitled', path: resource.path }));
|
|
205
204
|
}
|
|
206
205
|
}
|
|
@@ -213,41 +212,66 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
213
212
|
}
|
|
214
213
|
return undefined;
|
|
215
214
|
}
|
|
216
|
-
async handleNotebookEditor(notebookEditor, code) {
|
|
215
|
+
async handleNotebookEditor(notebookEditor, chatSessionId, code) {
|
|
217
216
|
if (notebookEditor.isReadOnly) {
|
|
218
|
-
this.notify(( localize(
|
|
217
|
+
this.notify(( localize(4520, "Cannot apply code block to read-only notebook editor.")));
|
|
219
218
|
return undefined;
|
|
220
219
|
}
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
const uri = notebookEditor.textModel.uri;
|
|
221
|
+
const codeBlock = { code, resource: uri, markdownBeforeBlock: undefined };
|
|
222
|
+
const codeMapper = this.codeMapperService.providers[0]?.displayName;
|
|
223
|
+
if (!codeMapper) {
|
|
224
|
+
this.notify(( localize(4521, "No code mapper available.")));
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
let editsProposed = false;
|
|
228
|
+
const cancellationTokenSource = ( new CancellationTokenSource());
|
|
229
|
+
try {
|
|
230
|
+
const iterable = await this.progressService.withProgress({ location: ProgressLocation.Notification, delay: 500, sticky: true, cancellable: true }, async (progress) => {
|
|
231
|
+
progress.report({ message: ( localize(4522, "Applying code block using {0}...", codeMapper)) });
|
|
232
|
+
const editsIterable = this.getNotebookEdits(codeBlock, chatSessionId, cancellationTokenSource.token);
|
|
233
|
+
return await this.waitForFirstElement(editsIterable);
|
|
234
|
+
}, () => cancellationTokenSource.cancel());
|
|
235
|
+
editsProposed = await this.applyNotebookEditsWithInlinePreview(iterable, uri, cancellationTokenSource);
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
if (!isCancellationError(e)) {
|
|
239
|
+
this.notify(( localize(4523, "Failed to apply code block: {0}", e.message)));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
cancellationTokenSource.dispose();
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
editsProposed,
|
|
247
|
+
codeMapper
|
|
248
|
+
};
|
|
225
249
|
}
|
|
226
250
|
async handleTextEditor(codeEditor, chatSessionId, code) {
|
|
227
251
|
const activeModel = codeEditor.getModel();
|
|
228
252
|
if (isReadOnly(activeModel, this.textFileService)) {
|
|
229
|
-
this.notify(( localize(
|
|
253
|
+
this.notify(( localize(4524, "Cannot apply code block to read-only file.")));
|
|
230
254
|
return undefined;
|
|
231
255
|
}
|
|
232
256
|
const codeBlock = { code, resource: activeModel.uri, chatSessionId, markdownBeforeBlock: undefined };
|
|
233
257
|
const codeMapper = this.codeMapperService.providers[0]?.displayName;
|
|
234
258
|
if (!codeMapper) {
|
|
235
|
-
this.notify(( localize(
|
|
259
|
+
this.notify(( localize(4521, "No code mapper available.")));
|
|
236
260
|
return undefined;
|
|
237
261
|
}
|
|
238
262
|
let editsProposed = false;
|
|
239
263
|
const cancellationTokenSource = ( new CancellationTokenSource());
|
|
240
264
|
try {
|
|
241
265
|
const iterable = await this.progressService.withProgress({ location: ProgressLocation.Notification, delay: 500, sticky: true, cancellable: true }, async (progress) => {
|
|
242
|
-
progress.report({ message: ( localize(
|
|
243
|
-
const editsIterable = this.
|
|
266
|
+
progress.report({ message: ( localize(4522, "Applying code block using {0}...", codeMapper)) });
|
|
267
|
+
const editsIterable = this.getTextEdits(codeBlock, chatSessionId, cancellationTokenSource.token);
|
|
244
268
|
return await this.waitForFirstElement(editsIterable);
|
|
245
269
|
}, () => cancellationTokenSource.cancel());
|
|
246
270
|
editsProposed = await this.applyWithInlinePreview(iterable, codeEditor, cancellationTokenSource);
|
|
247
271
|
}
|
|
248
272
|
catch (e) {
|
|
249
273
|
if (!isCancellationError(e)) {
|
|
250
|
-
this.notify(( localize(
|
|
274
|
+
this.notify(( localize(4523, "Failed to apply code block: {0}", e.message)));
|
|
251
275
|
}
|
|
252
276
|
}
|
|
253
277
|
finally {
|
|
@@ -258,7 +282,7 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
258
282
|
codeMapper
|
|
259
283
|
};
|
|
260
284
|
}
|
|
261
|
-
|
|
285
|
+
getTextEdits(codeBlock, chatSessionId, token) {
|
|
262
286
|
return ( new AsyncIterableObject(async (executor) => {
|
|
263
287
|
const request = {
|
|
264
288
|
codeBlocks: [codeBlock],
|
|
@@ -277,6 +301,27 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
277
301
|
}
|
|
278
302
|
}));
|
|
279
303
|
}
|
|
304
|
+
getNotebookEdits(codeBlock, chatSessionId, token) {
|
|
305
|
+
return ( new AsyncIterableObject(async (executor) => {
|
|
306
|
+
const request = {
|
|
307
|
+
codeBlocks: [codeBlock],
|
|
308
|
+
chatSessionId,
|
|
309
|
+
location: 'panel'
|
|
310
|
+
};
|
|
311
|
+
const response = {
|
|
312
|
+
textEdit: (target, edits) => {
|
|
313
|
+
executor.emitOne([target, edits]);
|
|
314
|
+
},
|
|
315
|
+
notebookEdit(_resource, edit) {
|
|
316
|
+
executor.emitOne(edit);
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
const result = await this.codeMapperService.mapCode(request, response, token);
|
|
320
|
+
if (result?.errorMessage) {
|
|
321
|
+
executor.reject(( new Error(result.errorMessage)));
|
|
322
|
+
}
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
280
325
|
async waitForFirstElement(iterable) {
|
|
281
326
|
const iterator = iterable[Symbol.asyncIterator]();
|
|
282
327
|
let result = await iterator.next();
|
|
@@ -299,6 +344,9 @@ let ApplyCodeBlockOperation = class ApplyCodeBlockOperation {
|
|
|
299
344
|
async applyWithInlinePreview(edits, codeEditor, tokenSource) {
|
|
300
345
|
return this.instantiationService.invokeFunction(reviewEdits, codeEditor, edits, tokenSource.token);
|
|
301
346
|
}
|
|
347
|
+
async applyNotebookEditsWithInlinePreview(edits, uri, tokenSource) {
|
|
348
|
+
return this.instantiationService.invokeFunction(reviewNotebookEdits, uri, edits, tokenSource.token);
|
|
349
|
+
}
|
|
302
350
|
tryToRevealCodeBlock(codeEditor, codeBlock) {
|
|
303
351
|
const match = codeBlock.match(/(\S[^\n]*)\n/);
|
|
304
352
|
if (match && match[1].length > 10) {
|
|
@@ -316,16 +364,15 @@ ApplyCodeBlockOperation = ( __decorate([
|
|
|
316
364
|
( __param(0, IEditorService)),
|
|
317
365
|
( __param(1, ITextFileService)),
|
|
318
366
|
( __param(2, IChatService)),
|
|
319
|
-
( __param(3,
|
|
320
|
-
( __param(4,
|
|
321
|
-
( __param(5,
|
|
322
|
-
( __param(6,
|
|
323
|
-
( __param(7,
|
|
324
|
-
( __param(8,
|
|
325
|
-
( __param(9,
|
|
326
|
-
( __param(10,
|
|
327
|
-
( __param(11,
|
|
328
|
-
( __param(12, INotebookService))
|
|
367
|
+
( __param(3, IFileService)),
|
|
368
|
+
( __param(4, IDialogService)),
|
|
369
|
+
( __param(5, ILogService)),
|
|
370
|
+
( __param(6, ICodeMapperService)),
|
|
371
|
+
( __param(7, IProgressService)),
|
|
372
|
+
( __param(8, IQuickInputService)),
|
|
373
|
+
( __param(9, ILabelService)),
|
|
374
|
+
( __param(10, IInstantiationService)),
|
|
375
|
+
( __param(11, INotebookService))
|
|
329
376
|
], ApplyCodeBlockOperation));
|
|
330
377
|
function notifyUserAction(chatService, context, action) {
|
|
331
378
|
if (isResponseVM(context.element)) {
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import { IChatWidget } from "@codingame/monaco-vscode-
|
|
1
|
+
import { IChatWidget } from "@codingame/monaco-vscode-7adbeffb-8051-54a9-8c9b-b62ce9e5836f-common/vscode/vs/workbench/contrib/chat/browser/chat";
|
|
2
2
|
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
3
|
-
import {
|
|
3
|
+
import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service";
|
|
4
|
+
import { ChatContextPick, IChatContextPickerItem } from "@codingame/monaco-vscode-f338ac19-278c-5fe1-bec8-b588de04a788-common/vscode/vs/workbench/contrib/chat/browser/chatContextPickService";
|
|
5
|
+
import { ILabelService } from "@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service";
|
|
4
6
|
export interface IAttachInstructionsActionOptions {
|
|
5
7
|
readonly widget?: IChatWidget;
|
|
6
8
|
readonly resource?: URI;
|
|
7
9
|
readonly skipSelectionDialog?: boolean;
|
|
8
10
|
}
|
|
9
|
-
export declare const runAttachInstructionsAction: (commandService: ICommandService, options: IAttachInstructionsActionOptions) => Promise<void>;
|
|
10
11
|
export declare const registerAttachPromptActions: () => void;
|
|
12
|
+
export declare class ChatInstructionsPickerPick implements IChatContextPickerItem {
|
|
13
|
+
private readonly promptsService;
|
|
14
|
+
private readonly labelService;
|
|
15
|
+
readonly type = "pickerPick";
|
|
16
|
+
readonly label: string;
|
|
17
|
+
readonly icon: import("@codingame/monaco-vscode-api/vscode/vs/base/common/themables").ThemeIcon;
|
|
18
|
+
readonly commandId = "workbench.action.chat.attach.instructions";
|
|
19
|
+
constructor(promptsService: IPromptsService, labelService: ILabelService);
|
|
20
|
+
isEnabled(widget: IChatWidget): Promise<boolean> | boolean;
|
|
21
|
+
asPicker(): {
|
|
22
|
+
readonly placeholder: string;
|
|
23
|
+
readonly picks: Promise<ChatContextPick[]>;
|
|
24
|
+
};
|
|
25
|
+
}
|