@codingame/monaco-vscode-chat-service-override 15.0.2 → 16.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 +11 -8
- package/package.json +29 -20
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.d.ts +22 -0
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +9 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +80 -55
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +17 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/{askToSelectPrompt.d.ts → askToSelectPrompt/askToSelectPrompt.d.ts} +9 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/askToSelectPrompt.js +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.js +53 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.js +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.js +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +6 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +163 -72
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +22 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +4 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +9 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.js +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +242 -74
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.js +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +47 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +688 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +28 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +355 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +71 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +395 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +98 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +216 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +97 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +831 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +7 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +32 -47
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +110 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +985 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +69 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.js +67 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +147 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +284 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +578 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.d.ts +45 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +122 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.js +320 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +50 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +22 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +166 -62
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +6 -104
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +704 -732
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +10 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +329 -236
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +14 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +17 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +217 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css +114 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditorController.css +30 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css +90 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +65 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +4 -4
- 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 +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +14 -12
- 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 +5 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +16 -8
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +175 -57
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +66 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +313 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.js +30 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +2 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +6 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +10 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +18 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.js +117 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +3 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +6 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +157 -65
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +39 -21
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -3
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +11 -10
- 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 +10 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +47 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.d.ts +5 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.js +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +0 -142
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +0 -52
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +0 -331
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +0 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +0 -110
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +0 -85
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +0 -11
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +0 -22
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Sequencer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
4
|
+
import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
5
|
+
import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
|
|
6
|
+
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
7
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { revive } from '@codingame/monaco-vscode-api/vscode/vs/base/common/marshalling';
|
|
9
|
+
import { joinPath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
10
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
11
|
+
import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
|
|
12
|
+
import { toFileOperationResult, FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
13
|
+
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
14
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
15
|
+
import { StorageTarget, StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
16
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
17
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
18
|
+
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
19
|
+
import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
20
|
+
import { normalizeSerializableChatData, ChatModel } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
21
|
+
|
|
22
|
+
const maxPersistedSessions = 25;
|
|
23
|
+
const ChatIndexStorageKey = 'chat.ChatSessionStore.index';
|
|
24
|
+
let ChatSessionStore = class ChatSessionStore extends Disposable {
|
|
25
|
+
constructor(fileService, environmentService, logService, workspaceContextService, telemetryService, storageService, lifecycleService) {
|
|
26
|
+
super();
|
|
27
|
+
this.fileService = fileService;
|
|
28
|
+
this.environmentService = environmentService;
|
|
29
|
+
this.logService = logService;
|
|
30
|
+
this.workspaceContextService = workspaceContextService;
|
|
31
|
+
this.telemetryService = telemetryService;
|
|
32
|
+
this.storageService = storageService;
|
|
33
|
+
this.lifecycleService = lifecycleService;
|
|
34
|
+
this.storeQueue = ( new Sequencer());
|
|
35
|
+
this.shuttingDown = false;
|
|
36
|
+
const workspace = this.workspaceContextService.getWorkspace();
|
|
37
|
+
const isEmptyWindow = !workspace.configuration && workspace.folders.length === 0;
|
|
38
|
+
const workspaceId = isEmptyWindow ?
|
|
39
|
+
'no-workspace' :
|
|
40
|
+
this.workspaceContextService.getWorkspace().id;
|
|
41
|
+
this.storageRoot = joinPath(this.environmentService.workspaceStorageHome, workspaceId, 'chatSessions');
|
|
42
|
+
this._register(this.lifecycleService.onWillShutdown(e => {
|
|
43
|
+
this.shuttingDown = true;
|
|
44
|
+
if (!this.storeTask) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
e.join(this.storeTask, {
|
|
48
|
+
id: 'join.chatSessionStore',
|
|
49
|
+
label: ( localize(4986, "Saving chat history"))
|
|
50
|
+
});
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
async storeSessions(sessions) {
|
|
54
|
+
if (this.shuttingDown) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
this.storeTask = this.storeQueue.queue(async () => {
|
|
59
|
+
try {
|
|
60
|
+
await Promise.all(( sessions.map(session => this.writeSession(session))));
|
|
61
|
+
await this.trimEntries();
|
|
62
|
+
await this.flushIndex();
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
this.reportError('storeSessions', 'Error storing chat sessions', e);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
await this.storeTask;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
this.storeTask = undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async writeSession(session) {
|
|
75
|
+
try {
|
|
76
|
+
const index = this.internalGetIndex();
|
|
77
|
+
const storageLocation = this.getStorageLocation(session.sessionId);
|
|
78
|
+
const content = JSON.stringify(session, undefined, 2);
|
|
79
|
+
await this.fileService.writeFile(storageLocation, VSBuffer.fromString(content));
|
|
80
|
+
index.entries[session.sessionId] = getSessionMetadata(session);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
this.reportError('sessionWrite', 'Error writing chat session', e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async flushIndex() {
|
|
87
|
+
const index = this.internalGetIndex();
|
|
88
|
+
try {
|
|
89
|
+
this.storageService.store(ChatIndexStorageKey, index, this.getIndexStorageScope(), StorageTarget.MACHINE);
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
this.reportError('indexWrite', 'Error writing index', e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
getIndexStorageScope() {
|
|
96
|
+
const workspace = this.workspaceContextService.getWorkspace();
|
|
97
|
+
const isEmptyWindow = !workspace.configuration && workspace.folders.length === 0;
|
|
98
|
+
return isEmptyWindow ? StorageScope.APPLICATION : StorageScope.WORKSPACE;
|
|
99
|
+
}
|
|
100
|
+
async trimEntries() {
|
|
101
|
+
const index = this.internalGetIndex();
|
|
102
|
+
const entries = ( Object.entries(index.entries)
|
|
103
|
+
.sort((a, b) => b[1].lastMessageDate - a[1].lastMessageDate)
|
|
104
|
+
.map(([id]) => id));
|
|
105
|
+
if (entries.length > maxPersistedSessions) {
|
|
106
|
+
const entriesToDelete = entries.slice(maxPersistedSessions);
|
|
107
|
+
for (const entry of entriesToDelete) {
|
|
108
|
+
delete index.entries[entry];
|
|
109
|
+
}
|
|
110
|
+
this.logService.trace(`ChatSessionStore: Trimmed ${entriesToDelete.length} old chat sessions from index`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async internalDeleteSession(sessionId) {
|
|
114
|
+
const index = this.internalGetIndex();
|
|
115
|
+
if (!index.entries[sessionId]) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const storageLocation = this.getStorageLocation(sessionId);
|
|
119
|
+
try {
|
|
120
|
+
await this.fileService.del(storageLocation);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
if (toFileOperationResult(e) !== FileOperationResult.FILE_NOT_FOUND) {
|
|
124
|
+
this.reportError('sessionDelete', 'Error deleting chat session', e);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
delete index.entries[sessionId];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
hasSessions() {
|
|
132
|
+
return ( Object.keys(this.internalGetIndex().entries)).length > 0;
|
|
133
|
+
}
|
|
134
|
+
isSessionEmpty(sessionId) {
|
|
135
|
+
const index = this.internalGetIndex();
|
|
136
|
+
return index.entries[sessionId]?.isEmpty ?? true;
|
|
137
|
+
}
|
|
138
|
+
async deleteSession(sessionId) {
|
|
139
|
+
await this.storeQueue.queue(async () => {
|
|
140
|
+
await this.internalDeleteSession(sessionId);
|
|
141
|
+
await this.flushIndex();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async clearAllSessions() {
|
|
145
|
+
await this.storeQueue.queue(async () => {
|
|
146
|
+
const index = this.internalGetIndex();
|
|
147
|
+
const entries = ( Object.keys(index.entries));
|
|
148
|
+
this.logService.info(`ChatSessionStore: Clearing ${entries.length} chat sessions`);
|
|
149
|
+
await Promise.all(( entries.map(entry => this.internalDeleteSession(entry))));
|
|
150
|
+
await this.flushIndex();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async setSessionTitle(sessionId, title) {
|
|
154
|
+
await this.storeQueue.queue(async () => {
|
|
155
|
+
const index = this.internalGetIndex();
|
|
156
|
+
if (index.entries[sessionId]) {
|
|
157
|
+
index.entries[sessionId].title = title;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
reportError(reasonForTelemetry, message, error) {
|
|
162
|
+
this.logService.error(`ChatSessionStore: ` + message, toErrorMessage(error));
|
|
163
|
+
const fileOperationReason = error && toFileOperationResult(error);
|
|
164
|
+
this.telemetryService.publicLog2('chatSessionStoreError', {
|
|
165
|
+
reason: reasonForTelemetry,
|
|
166
|
+
fileOperationReason: fileOperationReason ?? -1
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
internalGetIndex() {
|
|
170
|
+
if (this.indexCache) {
|
|
171
|
+
return this.indexCache;
|
|
172
|
+
}
|
|
173
|
+
const data = this.storageService.get(ChatIndexStorageKey, this.getIndexStorageScope(), undefined);
|
|
174
|
+
if (!data) {
|
|
175
|
+
this.indexCache = { version: 1, entries: {} };
|
|
176
|
+
return this.indexCache;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const index = JSON.parse(data);
|
|
180
|
+
if (isChatSessionIndex(index)) {
|
|
181
|
+
this.indexCache = index;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.reportError('invalidIndexFormat', `Invalid index format: ${data}`);
|
|
185
|
+
this.indexCache = { version: 1, entries: {} };
|
|
186
|
+
}
|
|
187
|
+
return this.indexCache;
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
this.reportError('invalidIndexJSON', `Index corrupt: ${data}`, e);
|
|
191
|
+
this.indexCache = { version: 1, entries: {} };
|
|
192
|
+
return this.indexCache;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async getIndex() {
|
|
196
|
+
return this.storeQueue.queue(async () => {
|
|
197
|
+
return this.internalGetIndex().entries;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
logIndex() {
|
|
201
|
+
const data = this.storageService.get(ChatIndexStorageKey, this.getIndexStorageScope(), undefined);
|
|
202
|
+
this.logService.info('ChatSessionStore index: ', data);
|
|
203
|
+
}
|
|
204
|
+
async migrateDataIfNeeded(getInitialData) {
|
|
205
|
+
await this.storeQueue.queue(async () => {
|
|
206
|
+
const data = this.storageService.get(ChatIndexStorageKey, this.getIndexStorageScope(), undefined);
|
|
207
|
+
const needsMigrationFromStorageService = !data;
|
|
208
|
+
if (needsMigrationFromStorageService) {
|
|
209
|
+
const initialData = getInitialData();
|
|
210
|
+
if (initialData) {
|
|
211
|
+
await this.migrate(initialData);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
async migrate(initialData) {
|
|
217
|
+
const numSessions = ( Object.keys(initialData)).length;
|
|
218
|
+
this.logService.info(`ChatSessionStore: Migrating ${numSessions} chat sessions from storage service to file system`);
|
|
219
|
+
await Promise.all(( ( Object.values(initialData)).map(async (session) => {
|
|
220
|
+
await this.writeSession(session);
|
|
221
|
+
})));
|
|
222
|
+
await this.flushIndex();
|
|
223
|
+
}
|
|
224
|
+
async readSession(sessionId) {
|
|
225
|
+
return await this.storeQueue.queue(async () => {
|
|
226
|
+
let rawData;
|
|
227
|
+
const storageLocation = this.getStorageLocation(sessionId);
|
|
228
|
+
try {
|
|
229
|
+
rawData = ( (await this.fileService.readFile(storageLocation)).value.toString());
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
this.reportError('sessionReadFile', `Error reading chat session file ${sessionId}`, e);
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const session = revive(JSON.parse(rawData));
|
|
237
|
+
for (const request of session.requests) {
|
|
238
|
+
if (Array.isArray(request.response)) {
|
|
239
|
+
request.response = ( request.response.map((response) => {
|
|
240
|
+
if (typeof response === 'string') {
|
|
241
|
+
return ( new MarkdownString(response));
|
|
242
|
+
}
|
|
243
|
+
return response;
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
else if (typeof request.response === 'string') {
|
|
247
|
+
request.response = [( new MarkdownString(request.response))];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return normalizeSerializableChatData(session);
|
|
251
|
+
}
|
|
252
|
+
catch (err) {
|
|
253
|
+
this.reportError('malformedSession', `Malformed session data in ${storageLocation.fsPath}: [${rawData.substring(0, 20)}${rawData.length > 20 ? '...' : ''}]`, err);
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
getStorageLocation(chatSessionId) {
|
|
259
|
+
return joinPath(this.storageRoot, `${chatSessionId}.json`);
|
|
260
|
+
}
|
|
261
|
+
getChatStorageFolder() {
|
|
262
|
+
return this.storageRoot;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
ChatSessionStore = ( __decorate([
|
|
266
|
+
( __param(0, IFileService)),
|
|
267
|
+
( __param(1, IEnvironmentService)),
|
|
268
|
+
( __param(2, ILogService)),
|
|
269
|
+
( __param(3, IWorkspaceContextService)),
|
|
270
|
+
( __param(4, ITelemetryService)),
|
|
271
|
+
( __param(5, IStorageService)),
|
|
272
|
+
( __param(6, ILifecycleService))
|
|
273
|
+
], ChatSessionStore));
|
|
274
|
+
function isChatSessionEntryMetadata(obj) {
|
|
275
|
+
return (!!obj &&
|
|
276
|
+
typeof obj === 'object' &&
|
|
277
|
+
typeof obj.sessionId === 'string' &&
|
|
278
|
+
typeof obj.title === 'string' &&
|
|
279
|
+
typeof obj.lastMessageDate === 'number');
|
|
280
|
+
}
|
|
281
|
+
function isChatSessionIndex(data) {
|
|
282
|
+
if (typeof data !== 'object' || data === null) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
const index = data;
|
|
286
|
+
if (index.version !== 1) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
if (typeof index.entries !== 'object' || index.entries === null) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
for (const key in index.entries) {
|
|
293
|
+
if (!isChatSessionEntryMetadata(index.entries[key])) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
function getSessionMetadata(session) {
|
|
300
|
+
const title = session instanceof ChatModel ?
|
|
301
|
+
(session.title || ( localize(4987, "New Chat"))) :
|
|
302
|
+
session.customTitle ?? ChatModel.getDefaultTitle(session.requests);
|
|
303
|
+
return {
|
|
304
|
+
sessionId: session.sessionId,
|
|
305
|
+
title,
|
|
306
|
+
lastMessageDate: session.lastMessageDate,
|
|
307
|
+
isImported: session.isImported,
|
|
308
|
+
initialLocation: session.initialLocation,
|
|
309
|
+
isEmpty: session instanceof ChatModel ? session.getRequests().length === 0 : session.requests.length === 0
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export { ChatSessionStore };
|
|
@@ -5,7 +5,7 @@ import { IProgress } from "@codingame/monaco-vscode-api/vscode/vs/platform/progr
|
|
|
5
5
|
import { IChatMessage } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels";
|
|
6
6
|
import { IChatFollowup, IChatProgress, IChatResponseProgressFileTreeData } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService";
|
|
7
7
|
import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service";
|
|
8
|
-
import { ChatAgentLocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/
|
|
8
|
+
import { ChatAgentLocation, ChatMode } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants";
|
|
9
9
|
import { IChatSlashCommandService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service";
|
|
10
10
|
export interface IChatSlashData {
|
|
11
11
|
command: string;
|
|
@@ -13,6 +13,7 @@ export interface IChatSlashData {
|
|
|
13
13
|
sortText?: string;
|
|
14
14
|
executeImmediately?: boolean;
|
|
15
15
|
locations: ChatAgentLocation[];
|
|
16
|
+
modes?: ChatMode[];
|
|
16
17
|
}
|
|
17
18
|
export interface IChatSlashFragment {
|
|
18
19
|
content: string | {
|
|
@@ -33,7 +34,7 @@ export declare class ChatSlashCommandService extends Disposable implements IChat
|
|
|
33
34
|
constructor(_extensionService: IExtensionService);
|
|
34
35
|
dispose(): void;
|
|
35
36
|
registerSlashCommand(data: IChatSlashData, command: IChatSlashCallback): IDisposable;
|
|
36
|
-
getCommands(location: ChatAgentLocation): Array<IChatSlashData>;
|
|
37
|
+
getCommands(location: ChatAgentLocation, mode: ChatMode): Array<IChatSlashData>;
|
|
37
38
|
hasCommand(id: string): boolean;
|
|
38
39
|
executeCommand(id: string, prompt: string, progress: IProgress<IChatProgress>, history: IChatMessage[], location: ChatAgentLocation, token: CancellationToken): Promise<{
|
|
39
40
|
followUp: IChatFollowup[];
|
|
@@ -28,8 +28,10 @@ let ChatSlashCommandService = class ChatSlashCommandService extends Disposable {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
getCommands(location) {
|
|
32
|
-
return Array
|
|
31
|
+
getCommands(location, mode) {
|
|
32
|
+
return Array
|
|
33
|
+
.from(( this._commands.values()), v => v.data)
|
|
34
|
+
.filter(c => c.locations.includes(location) && (!c.modes || c.modes.includes(mode)));
|
|
33
35
|
}
|
|
34
36
|
hasCommand(id) {
|
|
35
37
|
return ( this._commands.has(id));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
|
|
2
|
+
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
|
3
|
+
import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
|
|
4
|
+
import { IWorkspaceTrustManagementService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspaceTrust.service";
|
|
5
|
+
import { IChatTransferService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatTransferService.service";
|
|
6
|
+
export declare class ChatTransferService implements IChatTransferService {
|
|
7
|
+
private readonly workspaceService;
|
|
8
|
+
private readonly storageService;
|
|
9
|
+
private readonly fileService;
|
|
10
|
+
private readonly workspaceTrustManagementService;
|
|
11
|
+
_serviceBrand: undefined;
|
|
12
|
+
constructor(workspaceService: IWorkspaceContextService, storageService: IStorageService, fileService: IFileService, workspaceTrustManagementService: IWorkspaceTrustManagementService);
|
|
13
|
+
checkAndSetWorkspaceTrust(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
4
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
5
|
+
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
6
|
+
import { IWorkspaceTrustManagementService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspaceTrust.service';
|
|
7
|
+
import { isChatTransferredWorkspace, areWorkspaceFoldersEmpty } from '../../../services/workspaces/common/workspaceUtils.js';
|
|
8
|
+
|
|
9
|
+
let ChatTransferService = class ChatTransferService {
|
|
10
|
+
constructor(workspaceService, storageService, fileService, workspaceTrustManagementService) {
|
|
11
|
+
this.workspaceService = workspaceService;
|
|
12
|
+
this.storageService = storageService;
|
|
13
|
+
this.fileService = fileService;
|
|
14
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
15
|
+
}
|
|
16
|
+
async checkAndSetWorkspaceTrust() {
|
|
17
|
+
const workspace = this.workspaceService.getWorkspace();
|
|
18
|
+
if (isChatTransferredWorkspace(workspace, this.storageService) && (await areWorkspaceFoldersEmpty(workspace, this.fileService))) {
|
|
19
|
+
await this.workspaceTrustManagementService.setWorkspaceTrust(true);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
ChatTransferService = ( __decorate([
|
|
24
|
+
( __param(0, IWorkspaceContextService)),
|
|
25
|
+
( __param(1, IStorageService)),
|
|
26
|
+
( __param(2, IFileService)),
|
|
27
|
+
( __param(3, IWorkspaceTrustManagementService))
|
|
28
|
+
], ChatTransferService));
|
|
29
|
+
|
|
30
|
+
export { ChatTransferService };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
+
import { LanguageFilter } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languageSelector";
|
|
1
2
|
export declare const DOCUMENTATION_URL = "https://aka.ms/vscode-ghcp-prompt-snippets";
|
|
2
|
-
export declare const LANGUAGE_SELECTOR:
|
|
3
|
-
pattern: "**/*.prompt.md";
|
|
4
|
-
}>;
|
|
3
|
+
export declare const LANGUAGE_SELECTOR: LanguageFilter;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
import { PROMPT_FILE_EXTENSION } from '@codingame/monaco-vscode-
|
|
2
|
+
import { PROMPT_FILE_EXTENSION, COPILOT_CUSTOM_INSTRUCTIONS_FILENAME } from '@codingame/monaco-vscode-a1eb43d5-da63-5f76-8ad4-acf0d6c3b749-common/vscode/vs/platform/prompts/common/constants';
|
|
3
3
|
|
|
4
4
|
const DOCUMENTATION_URL = 'https://aka.ms/vscode-ghcp-prompt-snippets';
|
|
5
|
+
const REUSABLE_PROMPT_FILE_PATTERNS = ( Object.freeze([
|
|
6
|
+
`**/*${PROMPT_FILE_EXTENSION}`,
|
|
7
|
+
`**/.github/${COPILOT_CUSTOM_INSTRUCTIONS_FILENAME}`,
|
|
8
|
+
]));
|
|
5
9
|
const LANGUAGE_SELECTOR = ( Object.freeze({
|
|
6
|
-
pattern:
|
|
10
|
+
pattern: `{${REUSABLE_PROMPT_FILE_PATTERNS.join(',')}}`,
|
|
7
11
|
}));
|
|
8
12
|
|
|
9
13
|
export { DOCUMENTATION_URL, LANGUAGE_SELECTOR };
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import { IPromptContentsProvider } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/types";
|
|
2
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
1
3
|
import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
|
|
2
4
|
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
3
5
|
import { PromptContentsProviderBase } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase";
|
|
4
6
|
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
5
7
|
import { ReadableStream } from "@codingame/monaco-vscode-api/vscode/vs/base/common/stream";
|
|
6
8
|
import { IModelContentChangedEvent } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/textModelEvents";
|
|
9
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
10
|
+
import { TextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel";
|
|
7
11
|
export declare class TextModelContentsProvider extends PromptContentsProviderBase<IModelContentChangedEvent> {
|
|
8
12
|
private readonly model;
|
|
9
|
-
readonly
|
|
10
|
-
|
|
13
|
+
private readonly initService;
|
|
14
|
+
readonly uri: URI;
|
|
15
|
+
constructor(model: ITextModel, initService: IInstantiationService);
|
|
11
16
|
protected getContentsStream(_event: IModelContentChangedEvent | "full", cancellationToken?: CancellationToken): Promise<ReadableStream<VSBuffer>>;
|
|
17
|
+
createNew(promptContentsSource: TextModel | {
|
|
18
|
+
uri: URI;
|
|
19
|
+
}): IPromptContentsProvider;
|
|
12
20
|
toString(): string;
|
|
13
21
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
2
3
|
import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
3
4
|
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
5
|
+
import { FilePromptContentProvider } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/filePromptContentsProvider';
|
|
4
6
|
import { PromptContentsProviderBase } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase';
|
|
5
7
|
import { newWriteableStream } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stream';
|
|
8
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
+
import { TextModel } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
var TextModelContentsProvider_1;
|
|
12
|
+
let TextModelContentsProvider = TextModelContentsProvider_1 = class TextModelContentsProvider extends PromptContentsProviderBase {
|
|
13
|
+
constructor(model, initService) {
|
|
9
14
|
super();
|
|
10
15
|
this.model = model;
|
|
16
|
+
this.initService = initService;
|
|
11
17
|
this.uri = this.model.uri;
|
|
12
18
|
this._register(this.model.onWillDispose(this.dispose.bind(this)));
|
|
13
19
|
this._register(this.model.onDidChangeContent(this.onChangeEmitter.fire));
|
|
@@ -41,9 +47,18 @@ class TextModelContentsProvider extends PromptContentsProviderBase {
|
|
|
41
47
|
}, 1);
|
|
42
48
|
return stream;
|
|
43
49
|
}
|
|
50
|
+
createNew(promptContentsSource) {
|
|
51
|
+
if (promptContentsSource instanceof TextModel) {
|
|
52
|
+
return this.initService.createInstance(TextModelContentsProvider_1, promptContentsSource);
|
|
53
|
+
}
|
|
54
|
+
return this.initService.createInstance(FilePromptContentProvider, promptContentsSource.uri);
|
|
55
|
+
}
|
|
44
56
|
toString() {
|
|
45
57
|
return `text-model-prompt-contents-provider:${this.uri.path}`;
|
|
46
58
|
}
|
|
47
|
-
}
|
|
59
|
+
};
|
|
60
|
+
TextModelContentsProvider = TextModelContentsProvider_1 = ( __decorate([
|
|
61
|
+
( __param(1, IInstantiationService))
|
|
62
|
+
], TextModelContentsProvider));
|
|
48
63
|
|
|
49
64
|
export { TextModelContentsProvider };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
|
|
3
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
4
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
5
|
+
export declare class PromptLinkDiagnosticsInstanceManager extends Disposable {
|
|
6
|
+
private readonly providers;
|
|
7
|
+
constructor(editorService: IEditorService, initService: IInstantiationService, configService: IConfigurationService);
|
|
8
|
+
private handleNewEditor;
|
|
9
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service';
|
|
4
|
+
import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
5
|
+
import { NotPromptFile } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptFileReferenceErrors';
|
|
6
|
+
import { assertDefined } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
7
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { ObjectCache } from '../../../../../../base/common/objectCache.js';
|
|
9
|
+
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
10
|
+
import { PromptsConfig } from '@codingame/monaco-vscode-a1eb43d5-da63-5f76-8ad4-acf0d6c3b749-common/vscode/vs/platform/prompts/common/config';
|
|
11
|
+
import { isPromptFile } from '@codingame/monaco-vscode-a1eb43d5-da63-5f76-8ad4-acf0d6c3b749-common/vscode/vs/platform/prompts/common/constants';
|
|
12
|
+
import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
13
|
+
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
14
|
+
import { ObservableDisposable } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/base/common/observableDisposable';
|
|
15
|
+
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
16
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
17
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
18
|
+
import { MarkerSeverity } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers';
|
|
19
|
+
import { IMarkerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service';
|
|
20
|
+
|
|
21
|
+
const MARKERS_OWNER_ID = 'reusable-prompts-syntax';
|
|
22
|
+
let PromptLinkDiagnosticsProvider = class PromptLinkDiagnosticsProvider extends ObservableDisposable {
|
|
23
|
+
constructor(editor, markerService, promptsService) {
|
|
24
|
+
super();
|
|
25
|
+
this.editor = editor;
|
|
26
|
+
this.markerService = markerService;
|
|
27
|
+
this.promptsService = promptsService;
|
|
28
|
+
this.parser = this.promptsService
|
|
29
|
+
.getSyntaxParserFor(this.editor)
|
|
30
|
+
.onUpdate(this.updateMarkers.bind(this))
|
|
31
|
+
.onDispose(this.dispose.bind(this))
|
|
32
|
+
.start();
|
|
33
|
+
this.updateMarkers();
|
|
34
|
+
}
|
|
35
|
+
async updateMarkers() {
|
|
36
|
+
await this.parser.allSettled();
|
|
37
|
+
this.markerService.remove(MARKERS_OWNER_ID, [this.editor.uri]);
|
|
38
|
+
const markers = [];
|
|
39
|
+
for (const link of this.parser.references) {
|
|
40
|
+
const { topError, linkRange } = link;
|
|
41
|
+
if (!topError || !linkRange) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const { originalError } = topError;
|
|
45
|
+
if (originalError instanceof NotPromptFile) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
markers.push(toMarker(link));
|
|
49
|
+
}
|
|
50
|
+
this.markerService.changeOne(MARKERS_OWNER_ID, this.editor.uri, markers);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
PromptLinkDiagnosticsProvider = ( __decorate([
|
|
54
|
+
( __param(1, IMarkerService)),
|
|
55
|
+
( __param(2, IPromptsService))
|
|
56
|
+
], PromptLinkDiagnosticsProvider));
|
|
57
|
+
const toMarker = (link) => {
|
|
58
|
+
const { topError, linkRange } = link;
|
|
59
|
+
assertDefined(topError, 'Top error must to be defined.');
|
|
60
|
+
assertDefined(linkRange, 'Link range must to be defined.');
|
|
61
|
+
const { originalError } = topError;
|
|
62
|
+
assert(!(originalError instanceof NotPromptFile), 'Error must not be of "not prompt file" type.');
|
|
63
|
+
const severity = (topError.errorSubject === 'root')
|
|
64
|
+
? MarkerSeverity.Error
|
|
65
|
+
: MarkerSeverity.Warning;
|
|
66
|
+
return {
|
|
67
|
+
message: topError.localizedMessage,
|
|
68
|
+
severity,
|
|
69
|
+
...linkRange,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
let PromptLinkDiagnosticsInstanceManager = class PromptLinkDiagnosticsInstanceManager extends Disposable {
|
|
73
|
+
constructor(editorService, initService, configService) {
|
|
74
|
+
super();
|
|
75
|
+
this.providers = this._register(( new ObjectCache((editor) => {
|
|
76
|
+
const parser = initService.createInstance(PromptLinkDiagnosticsProvider, editor);
|
|
77
|
+
parser.assertNotDisposed('Created prompt parser must not be disposed.');
|
|
78
|
+
return parser;
|
|
79
|
+
})));
|
|
80
|
+
if (!PromptsConfig.enabled(configService)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this._register(editorService.onDidActiveEditorChange(() => {
|
|
84
|
+
const { activeTextEditorControl } = editorService;
|
|
85
|
+
if (!activeTextEditorControl) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.handleNewEditor(activeTextEditorControl);
|
|
89
|
+
}));
|
|
90
|
+
editorService
|
|
91
|
+
.visibleTextEditorControls
|
|
92
|
+
.forEach(this.handleNewEditor.bind(this));
|
|
93
|
+
}
|
|
94
|
+
handleNewEditor(editor) {
|
|
95
|
+
const model = editor.getModel();
|
|
96
|
+
if (!model) {
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
if ('modified' in model || 'model' in model) {
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
if (!isPromptFile(model.uri)) {
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
this.providers.get(model);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
PromptLinkDiagnosticsInstanceManager = ( __decorate([
|
|
110
|
+
( __param(0, IEditorService)),
|
|
111
|
+
( __param(1, IInstantiationService)),
|
|
112
|
+
( __param(2, IConfigurationService))
|
|
113
|
+
], PromptLinkDiagnosticsInstanceManager));
|
|
114
|
+
( Registry.as(Extensions.Workbench))
|
|
115
|
+
.registerWorkbenchContribution(PromptLinkDiagnosticsInstanceManager, LifecyclePhase.Eventually);
|
|
116
|
+
|
|
117
|
+
export { PromptLinkDiagnosticsInstanceManager };
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { LANGUAGE_SELECTOR } from '../constants.js';
|
|
4
4
|
import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service';
|
|
5
|
-
import { FileReference } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/codecs/tokens/fileReference';
|
|
6
5
|
import { assertOneOf } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
7
6
|
import { isWindows } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
8
7
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
@@ -22,7 +21,7 @@ const findFileReference = (references, position) => {
|
|
|
22
21
|
if (reference.type !== 'file') {
|
|
23
22
|
return undefined;
|
|
24
23
|
}
|
|
25
|
-
if (
|
|
24
|
+
if (reference.subtype !== 'prompt') {
|
|
26
25
|
return undefined;
|
|
27
26
|
}
|
|
28
27
|
const { startLineNumber, endColumn } = range;
|
|
@@ -96,10 +95,10 @@ let PromptPathAutocompletion = class PromptPathAutocompletion extends Disposable
|
|
|
96
95
|
}
|
|
97
96
|
async getFirstFolderSuggestions(character, fileFolderUri, fileReference) {
|
|
98
97
|
const { linkRange } = fileReference;
|
|
99
|
-
if (character === ':' && linkRange !== undefined) {
|
|
98
|
+
if ((character === ':') && (linkRange !== undefined)) {
|
|
100
99
|
return [];
|
|
101
100
|
}
|
|
102
|
-
if (character === '.' && linkRange === undefined) {
|
|
101
|
+
if ((character === '.') && (linkRange === undefined)) {
|
|
103
102
|
return [];
|
|
104
103
|
}
|
|
105
104
|
const suggestions = await this.getFolderSuggestions(fileFolderUri);
|