@codingame/monaco-vscode-chat-service-override 17.2.0 → 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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service';
|
|
4
|
+
import { isOneOf } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
4
5
|
import { extUri } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
5
|
-
import { assertOneOf } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
6
6
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
7
|
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
8
|
-
import {
|
|
8
|
+
import { ALL_PROMPTS_LANGUAGE_SELECTOR } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/constants';
|
|
9
9
|
import { assert, assertNever } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
10
10
|
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
11
11
|
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
|
|
@@ -36,7 +36,7 @@ let PromptPathAutocompletion = class PromptPathAutocompletion extends Disposable
|
|
|
36
36
|
this.languageService = languageService;
|
|
37
37
|
this._debugDisplayName = 'PromptPathAutocompletion';
|
|
38
38
|
this.triggerCharacters = [':', '.', '/'];
|
|
39
|
-
this._register(this.languageService.completionProvider.register(
|
|
39
|
+
this._register(this.languageService.completionProvider.register(ALL_PROMPTS_LANGUAGE_SELECTOR, this));
|
|
40
40
|
}
|
|
41
41
|
async provideCompletionItems(model, position, context, token) {
|
|
42
42
|
assert(!token.isCancellationRequested, ( new CancellationError()));
|
|
@@ -44,9 +44,9 @@ let PromptPathAutocompletion = class PromptPathAutocompletion extends Disposable
|
|
|
44
44
|
if (!triggerCharacter) {
|
|
45
45
|
return undefined;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
assert(isOneOf(triggerCharacter, this.triggerCharacters), `Prompt path autocompletion provider`);
|
|
48
48
|
const parser = this.promptsService.getSyntaxParserFor(model);
|
|
49
|
-
assert(
|
|
49
|
+
assert(parser.isDisposed === false, 'Prompt parser must not be disposed.');
|
|
50
50
|
const { references } = await parser
|
|
51
51
|
.start()
|
|
52
52
|
.settled();
|
|
@@ -2,9 +2,10 @@ import { TSharedPrompt } from "@codingame/monaco-vscode-api/vscode/vs/workbench/
|
|
|
2
2
|
import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service";
|
|
3
3
|
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
4
4
|
import { ObservableDisposable } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/base/common/observableDisposable";
|
|
5
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
5
6
|
export declare abstract class ProviderInstanceBase extends ObservableDisposable {
|
|
6
7
|
protected readonly model: ITextModel;
|
|
7
|
-
protected abstract onPromptSettled(error: Error | undefined):
|
|
8
|
+
protected abstract onPromptSettled(error: Error | undefined, token: CancellationToken): this;
|
|
8
9
|
abstract toString(): string;
|
|
9
10
|
protected readonly parser: TSharedPrompt;
|
|
10
11
|
constructor(model: ITextModel, promptsService: IPromptsService);
|
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service';
|
|
4
4
|
import { ObservableDisposable } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/base/common/observableDisposable';
|
|
5
|
+
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
5
6
|
|
|
6
7
|
let ProviderInstanceBase = class ProviderInstanceBase extends ObservableDisposable {
|
|
7
8
|
constructor(model, promptsService) {
|
|
8
9
|
super();
|
|
9
10
|
this.model = model;
|
|
10
11
|
this.parser = promptsService.getSyntaxParserFor(model);
|
|
11
|
-
this._register(this.parser.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
|
|
12
|
+
this._register(this.parser.onDispose(this.dispose.bind(this)));
|
|
13
|
+
let cancellationSource = ( new CancellationTokenSource());
|
|
14
|
+
this._register(this.parser.onSettled((error) => {
|
|
15
|
+
cancellationSource.dispose(true);
|
|
16
|
+
cancellationSource = ( new CancellationTokenSource());
|
|
17
|
+
this.onPromptSettled(error, cancellationSource.token);
|
|
18
|
+
}));
|
|
19
|
+
this.parser.start();
|
|
16
20
|
}
|
|
17
21
|
};
|
|
18
22
|
ProviderInstanceBase = ( __decorate([
|
|
@@ -9,9 +9,10 @@ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
9
9
|
export interface IPromptFileEditor extends IEditor {
|
|
10
10
|
readonly getModel: () => ITextModel;
|
|
11
11
|
}
|
|
12
|
+
export type TProviderClass<TInstance extends ProviderInstanceBase> = new (editor: ITextModel, ...args: any[]) => TInstance;
|
|
12
13
|
export declare abstract class ProviderInstanceManagerBase<TInstance extends ProviderInstanceBase> extends Disposable {
|
|
13
14
|
private readonly instances;
|
|
14
|
-
protected abstract get InstanceClass():
|
|
15
|
-
constructor(modelService: IModelService, editorService: IEditorService,
|
|
15
|
+
protected abstract get InstanceClass(): TProviderClass<TInstance>;
|
|
16
|
+
constructor(modelService: IModelService, editorService: IEditorService, instantiationService: IInstantiationService, configService: IConfigurationService);
|
|
16
17
|
private handleNewEditor;
|
|
17
18
|
}
|
|
@@ -4,20 +4,20 @@ import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/asser
|
|
|
4
4
|
import { assertDefined } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
5
5
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
6
|
import { ObjectCache } from '../../../../../../../../base/common/objectCache.js';
|
|
7
|
-
import { PROMPT_LANGUAGE_ID, INSTRUCTIONS_LANGUAGE_ID } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/constants';
|
|
7
|
+
import { PROMPT_LANGUAGE_ID, INSTRUCTIONS_LANGUAGE_ID, MODE_LANGUAGE_ID } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/constants';
|
|
8
8
|
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
9
|
-
import { PromptsConfig } from '@codingame/monaco-vscode-
|
|
9
|
+
import { PromptsConfig } from '@codingame/monaco-vscode-47472025-cc45-5680-86cd-09ceaba921a1-common/vscode/vs/platform/prompts/common/config';
|
|
10
10
|
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
11
11
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
12
|
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
13
13
|
|
|
14
14
|
let ProviderInstanceManagerBase = class ProviderInstanceManagerBase extends Disposable {
|
|
15
|
-
constructor(modelService, editorService,
|
|
15
|
+
constructor(modelService, editorService, instantiationService, configService) {
|
|
16
16
|
super();
|
|
17
17
|
this.instances = this._register(( new ObjectCache((model) => {
|
|
18
18
|
assert(model.isDisposed() === false, 'Text model must not be disposed.');
|
|
19
19
|
assertDefined(this.InstanceClass, 'Instance class field must be defined.');
|
|
20
|
-
const instance =
|
|
20
|
+
const instance = instantiationService.createInstance(this.InstanceClass, model);
|
|
21
21
|
instance.assertNotDisposed('Created instance must not be disposed.');
|
|
22
22
|
return instance;
|
|
23
23
|
})));
|
|
@@ -40,7 +40,7 @@ let ProviderInstanceManagerBase = class ProviderInstanceManagerBase extends Disp
|
|
|
40
40
|
this.instances.get(model);
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
if (
|
|
43
|
+
if (isPromptFile(oldLanguageId)) {
|
|
44
44
|
this.instances.remove(model, true);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
@@ -64,8 +64,12 @@ ProviderInstanceManagerBase = ( __decorate([
|
|
|
64
64
|
( __param(2, IInstantiationService)),
|
|
65
65
|
( __param(3, IConfigurationService))
|
|
66
66
|
], ProviderInstanceManagerBase));
|
|
67
|
-
const
|
|
68
|
-
return
|
|
67
|
+
const isPromptFile = (languageId) => {
|
|
68
|
+
return [
|
|
69
|
+
PROMPT_LANGUAGE_ID,
|
|
70
|
+
INSTRUCTIONS_LANGUAGE_ID,
|
|
71
|
+
MODE_LANGUAGE_ID,
|
|
72
|
+
].includes(languageId);
|
|
69
73
|
};
|
|
70
74
|
const isPromptFileModel = (model) => {
|
|
71
75
|
if ('modified' in model || 'model' in model) {
|
|
@@ -74,7 +78,7 @@ const isPromptFileModel = (model) => {
|
|
|
74
78
|
if (model.isDisposed()) {
|
|
75
79
|
return false;
|
|
76
80
|
}
|
|
77
|
-
if (
|
|
81
|
+
if (isPromptFile(model.getLanguageId()) === false) {
|
|
78
82
|
return false;
|
|
79
83
|
}
|
|
80
84
|
return true;
|
package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ import { TextModelContentsProvider } from "@codingame/monaco-vscode-fab30422-b48
|
|
|
5
5
|
import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
|
|
6
6
|
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
7
7
|
export declare class TextModelPromptParser extends BasePromptParser<TextModelContentsProvider> {
|
|
8
|
-
constructor(model: ITextModel, options: Partial<IPromptParserOptions
|
|
8
|
+
constructor(model: ITextModel, options: Partial<IPromptParserOptions>, instantiationService: IInstantiationService, workspaceService: IWorkspaceContextService, logService: ILogService);
|
|
9
9
|
toString(): string;
|
|
10
10
|
}
|
package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js
CHANGED
|
@@ -7,9 +7,9 @@ import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs
|
|
|
7
7
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
8
8
|
|
|
9
9
|
let TextModelPromptParser = class TextModelPromptParser extends BasePromptParser {
|
|
10
|
-
constructor(model, options
|
|
11
|
-
const contentsProvider =
|
|
12
|
-
super(contentsProvider, options,
|
|
10
|
+
constructor(model, options, instantiationService, workspaceService, logService) {
|
|
11
|
+
const contentsProvider = instantiationService.createInstance(TextModelContentsProvider, model, options);
|
|
12
|
+
super(contentsProvider, options, instantiationService, workspaceService, logService);
|
|
13
13
|
this._register(contentsProvider);
|
|
14
14
|
}
|
|
15
15
|
toString() {
|
package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.d.ts
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
|
-
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
2
|
-
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
1
|
+
import { type URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
3
2
|
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
3
|
+
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
4
|
+
import { type ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
5
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
4
6
|
import { TextModelPromptParser } from "../parsers/textModelPromptParser.js";
|
|
5
7
|
import { ILabelService } from "@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service";
|
|
6
8
|
import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service";
|
|
9
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
10
|
+
import { TLogFunction } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/base/common/decorators/logTime";
|
|
7
11
|
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
8
12
|
import { IUserDataProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service";
|
|
9
|
-
import { IChatPromptSlashCommand,
|
|
13
|
+
import type { IChatPromptSlashCommand, ICustomChatMode, IMetadata, IPromptPath } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types";
|
|
10
14
|
import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service";
|
|
15
|
+
import { PromptsType } from "@codingame/monaco-vscode-47472025-cc45-5680-86cd-09ceaba921a1-common/vscode/vs/platform/prompts/common/prompts";
|
|
11
16
|
export declare class PromptsService extends Disposable implements IPromptsService {
|
|
17
|
+
readonly logger: ILogService;
|
|
12
18
|
private readonly labelService;
|
|
13
19
|
private readonly modelService;
|
|
14
|
-
private readonly
|
|
20
|
+
private readonly instantiationService;
|
|
15
21
|
private readonly userDataService;
|
|
16
22
|
readonly _serviceBrand: undefined;
|
|
17
23
|
private readonly cache;
|
|
18
24
|
private readonly fileLocator;
|
|
19
|
-
|
|
25
|
+
logTime: TLogFunction;
|
|
26
|
+
private onDidChangeCustomChatModesEvent;
|
|
27
|
+
constructor(logger: ILogService, labelService: ILabelService, modelService: IModelService, instantiationService: IInstantiationService, userDataService: IUserDataProfileService);
|
|
28
|
+
get onDidChangeCustomChatModes(): Event<void>;
|
|
20
29
|
getSyntaxParserFor(model: ITextModel): TextModelPromptParser & {
|
|
21
|
-
|
|
30
|
+
isDisposed: false;
|
|
22
31
|
};
|
|
23
|
-
listPromptFiles(type:
|
|
24
|
-
getSourceFolders(type:
|
|
32
|
+
listPromptFiles(type: PromptsType, token: CancellationToken): Promise<readonly IPromptPath[]>;
|
|
33
|
+
getSourceFolders(type: PromptsType): readonly IPromptPath[];
|
|
25
34
|
asPromptSlashCommand(command: string): IChatPromptSlashCommand | undefined;
|
|
26
|
-
resolvePromptSlashCommand(data: IChatPromptSlashCommand): Promise<
|
|
35
|
+
resolvePromptSlashCommand(data: IChatPromptSlashCommand): Promise<IMetadata | undefined>;
|
|
36
|
+
private getPromptPath;
|
|
27
37
|
findPromptSlashCommands(): Promise<IChatPromptSlashCommand[]>;
|
|
38
|
+
getCustomChatModes(): Promise<readonly ICustomChatMode[]>;
|
|
28
39
|
findInstructionFilesFor(files: readonly URI[]): Promise<readonly URI[]>;
|
|
40
|
+
getMetadata(promptFileUri: URI): Promise<IMetadata>;
|
|
29
41
|
getAllMetadata(promptUris: readonly URI[]): Promise<IMetadata[]>;
|
|
30
|
-
getCombinedToolsMetadata(promptUris: readonly URI[]): Promise<TCombinedToolsMetadata | null>;
|
|
31
42
|
}
|
|
32
43
|
export declare function getPromptCommandName(path: string): string;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import {
|
|
3
|
+
import { flatten } from '../utils/treeUtils.js';
|
|
4
4
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
5
5
|
import { PROMPT_LANGUAGE_ID } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/constants';
|
|
6
|
-
import { flatten, forEach } from '../utils/treeUtils.js';
|
|
7
6
|
import { PromptParser } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptParser';
|
|
8
|
-
import { match } from '@codingame/monaco-vscode-api/vscode/vs/base/common/glob';
|
|
7
|
+
import { splitGlobAware, match } from '@codingame/monaco-vscode-api/vscode/vs/base/common/glob';
|
|
9
8
|
import { pick } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
10
9
|
import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
11
10
|
import { basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
|
|
@@ -13,44 +12,54 @@ import { ResourceSet } from '@codingame/monaco-vscode-api/vscode/vs/base/common/
|
|
|
13
12
|
import { PromptFilesLocator } from '../utils/promptFilesLocator.js';
|
|
14
13
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
15
14
|
import { ObjectCache } from '../../../../../../base/common/objectCache.js';
|
|
15
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
16
16
|
import { TextModelPromptParser } from '../parsers/textModelPromptParser.js';
|
|
17
17
|
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
18
18
|
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
19
|
-
import {
|
|
19
|
+
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
20
|
+
import { logTime } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/base/common/decorators/logTime';
|
|
20
21
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
21
22
|
import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
|
|
23
|
+
import { PromptsType, isValidPromptType, getCleanPromptName, PROMPT_FILE_EXTENSION } from '@codingame/monaco-vscode-47472025-cc45-5680-86cd-09ceaba921a1-common/vscode/vs/platform/prompts/common/prompts';
|
|
22
24
|
|
|
23
25
|
let PromptsService = class PromptsService extends Disposable {
|
|
24
|
-
constructor(labelService, modelService,
|
|
26
|
+
constructor(logger, labelService, modelService, instantiationService, userDataService) {
|
|
25
27
|
super();
|
|
28
|
+
this.logger = logger;
|
|
26
29
|
this.labelService = labelService;
|
|
27
30
|
this.modelService = modelService;
|
|
28
|
-
this.
|
|
31
|
+
this.instantiationService = instantiationService;
|
|
29
32
|
this.userDataService = userDataService;
|
|
30
|
-
this.fileLocator = this.
|
|
33
|
+
this.fileLocator = this._register(this.instantiationService.createInstance(PromptFilesLocator));
|
|
34
|
+
this.logTime = this.logger.trace.bind(this.logger);
|
|
31
35
|
this.cache = this._register(( new ObjectCache((model) => {
|
|
32
36
|
assert(model.isDisposed() === false, 'Text model must not be disposed.');
|
|
33
|
-
const parser =
|
|
37
|
+
const parser = instantiationService.createInstance(TextModelPromptParser, model, { seenReferences: [] }).start();
|
|
34
38
|
parser.assertNotDisposed('Created prompt parser must not be disposed.');
|
|
35
39
|
return parser;
|
|
36
40
|
})));
|
|
37
41
|
}
|
|
42
|
+
get onDidChangeCustomChatModes() {
|
|
43
|
+
if (!this.onDidChangeCustomChatModesEvent) {
|
|
44
|
+
this.onDidChangeCustomChatModesEvent = this.fileLocator.getFilesUpdatedEvent(PromptsType.mode);
|
|
45
|
+
}
|
|
46
|
+
return this.onDidChangeCustomChatModesEvent;
|
|
47
|
+
}
|
|
38
48
|
getSyntaxParserFor(model) {
|
|
39
49
|
assert(model.isDisposed() === false, 'Cannot create a prompt syntax parser for a disposed model.');
|
|
40
50
|
return this.cache.get(model);
|
|
41
51
|
}
|
|
42
|
-
async listPromptFiles(type) {
|
|
43
|
-
const userLocations = [this.userDataService.currentProfile.promptsHome];
|
|
52
|
+
async listPromptFiles(type, token) {
|
|
44
53
|
const prompts = await Promise.all([
|
|
45
|
-
this.fileLocator.
|
|
54
|
+
this.fileLocator.listFiles(type, 'user', token)
|
|
46
55
|
.then(withType('user', type)),
|
|
47
|
-
this.fileLocator.listFiles(type)
|
|
56
|
+
this.fileLocator.listFiles(type, 'local', token)
|
|
48
57
|
.then(withType('local', type)),
|
|
49
58
|
]);
|
|
50
59
|
return prompts.flat();
|
|
51
60
|
}
|
|
52
61
|
getSourceFolders(type) {
|
|
53
|
-
assert(type
|
|
62
|
+
assert(isValidPromptType(type), `Unknown prompt type '${type}'.`);
|
|
54
63
|
const result = [];
|
|
55
64
|
for (const uri of this.fileLocator.getConfigBasedSourceFolders(type)) {
|
|
56
65
|
result.push({ uri, storage: 'local', type });
|
|
@@ -61,34 +70,41 @@ let PromptsService = class PromptsService extends Disposable {
|
|
|
61
70
|
}
|
|
62
71
|
asPromptSlashCommand(command) {
|
|
63
72
|
if (command.match(/^[\w_\-\.]+$/)) {
|
|
64
|
-
return { command, detail: ( localize(
|
|
73
|
+
return { command, detail: ( localize(5202, 'Prompt file: {0}', command)) };
|
|
65
74
|
}
|
|
66
75
|
return undefined;
|
|
67
76
|
}
|
|
68
77
|
async resolvePromptSlashCommand(data) {
|
|
78
|
+
const promptUri = await this.getPromptPath(data);
|
|
79
|
+
if (!promptUri) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
return await this.getMetadata(promptUri);
|
|
83
|
+
}
|
|
84
|
+
async getPromptPath(data) {
|
|
69
85
|
if (data.promptPath) {
|
|
70
|
-
return data.promptPath;
|
|
86
|
+
return data.promptPath.uri;
|
|
71
87
|
}
|
|
72
|
-
const files = await this.listPromptFiles(
|
|
88
|
+
const files = await this.listPromptFiles(PromptsType.prompt, CancellationToken.None);
|
|
73
89
|
const command = data.command;
|
|
74
90
|
const result = files.find(file => getPromptCommandName(file.uri.path) === command);
|
|
75
91
|
if (result) {
|
|
76
|
-
return result;
|
|
92
|
+
return result.uri;
|
|
77
93
|
}
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
94
|
+
const textModel = this.modelService.getModels().find(model => model.getLanguageId() === PROMPT_LANGUAGE_ID && getPromptCommandName(model.uri.path) === command);
|
|
95
|
+
if (textModel) {
|
|
96
|
+
return textModel.uri;
|
|
81
97
|
}
|
|
82
98
|
return undefined;
|
|
83
99
|
}
|
|
84
100
|
async findPromptSlashCommands() {
|
|
85
|
-
const promptFiles = await this.listPromptFiles(
|
|
101
|
+
const promptFiles = await this.listPromptFiles(PromptsType.prompt, CancellationToken.None);
|
|
86
102
|
return (promptFiles.map(promptPath => {
|
|
87
103
|
const command = getPromptCommandName(promptPath.uri.path);
|
|
88
104
|
return {
|
|
89
105
|
command,
|
|
90
106
|
detail: ( localize(
|
|
91
|
-
|
|
107
|
+
5202,
|
|
92
108
|
'Prompt file: {0}',
|
|
93
109
|
this.labelService.getUriLabel(promptPath.uri, { relative: true })
|
|
94
110
|
)),
|
|
@@ -96,36 +112,83 @@ let PromptsService = class PromptsService extends Disposable {
|
|
|
96
112
|
};
|
|
97
113
|
}));
|
|
98
114
|
}
|
|
115
|
+
async getCustomChatModes() {
|
|
116
|
+
const modeFiles = ( (await this.listPromptFiles(PromptsType.mode, CancellationToken.None))
|
|
117
|
+
.map(modeFile => modeFile.uri));
|
|
118
|
+
const metadataList = await Promise.all(( modeFiles.map(async (uri) => {
|
|
119
|
+
let parser;
|
|
120
|
+
try {
|
|
121
|
+
parser = this.instantiationService.createInstance(PromptParser, uri, { allowNonPromptFiles: true }).start();
|
|
122
|
+
await parser.settled();
|
|
123
|
+
const { metadata } = parser;
|
|
124
|
+
const tools = (metadata && ('tools' in metadata))
|
|
125
|
+
? metadata.tools
|
|
126
|
+
: undefined;
|
|
127
|
+
const body = await parser.getBody();
|
|
128
|
+
return {
|
|
129
|
+
uri: uri,
|
|
130
|
+
name: getCleanPromptName(uri),
|
|
131
|
+
description: metadata?.description,
|
|
132
|
+
tools,
|
|
133
|
+
body,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
parser?.dispose();
|
|
138
|
+
}
|
|
139
|
+
})));
|
|
140
|
+
return metadataList;
|
|
141
|
+
}
|
|
99
142
|
async findInstructionFilesFor(files) {
|
|
100
|
-
const
|
|
101
|
-
const instructionFiles = await this.listPromptFiles('instructions');
|
|
143
|
+
const instructionFiles = await this.listPromptFiles(PromptsType.instructions, CancellationToken.None);
|
|
102
144
|
if (instructionFiles.length === 0) {
|
|
103
|
-
return
|
|
145
|
+
return [];
|
|
104
146
|
}
|
|
105
147
|
const instructions = await this.getAllMetadata(( instructionFiles.map(pick('uri'))));
|
|
148
|
+
const foundFiles = ( new ResourceSet());
|
|
106
149
|
for (const instruction of instructions.flatMap(flatten)) {
|
|
107
150
|
const { metadata, uri } = instruction;
|
|
108
|
-
|
|
109
|
-
if (applyTo === undefined) {
|
|
151
|
+
if (metadata?.promptType !== PromptsType.instructions) {
|
|
110
152
|
continue;
|
|
111
153
|
}
|
|
112
|
-
|
|
113
|
-
|
|
154
|
+
const { applyTo } = metadata;
|
|
155
|
+
if (applyTo === undefined) {
|
|
114
156
|
continue;
|
|
115
157
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
158
|
+
const patterns = splitGlobAware(applyTo, ',');
|
|
159
|
+
const patterMatches = (pattern) => {
|
|
160
|
+
pattern = pattern.trim();
|
|
161
|
+
if (pattern.length === 0) {
|
|
162
|
+
return false;
|
|
119
163
|
}
|
|
164
|
+
if (pattern === '**' || pattern === '**/*' || pattern === '*') {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (!pattern.startsWith('/') && !pattern.startsWith('**/')) {
|
|
168
|
+
pattern = '**/' + pattern;
|
|
169
|
+
}
|
|
170
|
+
for (const file of files) {
|
|
171
|
+
if (match(pattern, file.path)) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
};
|
|
177
|
+
if (( patterns.some(patterMatches))) {
|
|
178
|
+
foundFiles.add(uri);
|
|
120
179
|
}
|
|
121
180
|
}
|
|
122
|
-
return [...
|
|
181
|
+
return [...foundFiles];
|
|
182
|
+
}
|
|
183
|
+
async getMetadata(promptFileUri) {
|
|
184
|
+
const metaDatas = await this.getAllMetadata([promptFileUri]);
|
|
185
|
+
return metaDatas[0];
|
|
123
186
|
}
|
|
124
187
|
async getAllMetadata(promptUris) {
|
|
125
188
|
const metadata = await Promise.all(( promptUris.map(async (uri) => {
|
|
126
189
|
let parser;
|
|
127
190
|
try {
|
|
128
|
-
parser = this.
|
|
191
|
+
parser = this.instantiationService.createInstance(PromptParser, uri, { allowNonPromptFiles: true }).start();
|
|
129
192
|
await parser.allSettled();
|
|
130
193
|
return collectMetadata(parser);
|
|
131
194
|
}
|
|
@@ -135,99 +198,23 @@ let PromptsService = class PromptsService extends Disposable {
|
|
|
135
198
|
})));
|
|
136
199
|
return metadata;
|
|
137
200
|
}
|
|
138
|
-
async getCombinedToolsMetadata(promptUris) {
|
|
139
|
-
if (promptUris.length === 0) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
const filesMetadata = await this.getAllMetadata(promptUris);
|
|
143
|
-
const allTools = ( filesMetadata
|
|
144
|
-
.map((fileMetadata) => {
|
|
145
|
-
const result = [];
|
|
146
|
-
let isFirst = true;
|
|
147
|
-
let isRootInAgentMode = false;
|
|
148
|
-
let hasTools = false;
|
|
149
|
-
let chatMode;
|
|
150
|
-
forEach((node) => {
|
|
151
|
-
const { metadata } = node;
|
|
152
|
-
const { mode, tools } = metadata;
|
|
153
|
-
if (isFirst === true) {
|
|
154
|
-
isFirst = false;
|
|
155
|
-
if ((mode === ChatMode.Agent) || (tools !== undefined)) {
|
|
156
|
-
isRootInAgentMode = true;
|
|
157
|
-
chatMode = ChatMode.Agent;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
chatMode ??= mode;
|
|
161
|
-
if (chatMode && mode) {
|
|
162
|
-
chatMode = morePrivilegedChatMode(chatMode, mode);
|
|
163
|
-
}
|
|
164
|
-
if (isRootInAgentMode && tools !== undefined) {
|
|
165
|
-
result.push(...tools);
|
|
166
|
-
hasTools = true;
|
|
167
|
-
}
|
|
168
|
-
return false;
|
|
169
|
-
}, fileMetadata);
|
|
170
|
-
if (chatMode === ChatMode.Agent) {
|
|
171
|
-
return {
|
|
172
|
-
tools: (hasTools)
|
|
173
|
-
? [...( new Set(result))]
|
|
174
|
-
: undefined,
|
|
175
|
-
mode: ChatMode.Agent,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
mode: chatMode,
|
|
180
|
-
};
|
|
181
|
-
}));
|
|
182
|
-
let hasAnyTools = false;
|
|
183
|
-
let resultingChatMode;
|
|
184
|
-
const result = [];
|
|
185
|
-
for (const { tools, mode } of allTools) {
|
|
186
|
-
resultingChatMode ??= mode;
|
|
187
|
-
if (resultingChatMode && mode) {
|
|
188
|
-
resultingChatMode = morePrivilegedChatMode(resultingChatMode, mode);
|
|
189
|
-
}
|
|
190
|
-
if (tools) {
|
|
191
|
-
result.push(...tools);
|
|
192
|
-
hasAnyTools = true;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (resultingChatMode === ChatMode.Agent) {
|
|
196
|
-
return {
|
|
197
|
-
tools: (hasAnyTools)
|
|
198
|
-
? [...( new Set(result))]
|
|
199
|
-
: undefined,
|
|
200
|
-
mode: resultingChatMode,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
tools: undefined,
|
|
205
|
-
mode: resultingChatMode,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
201
|
};
|
|
202
|
+
PromptsService.__decorator = ( __decorate([
|
|
203
|
+
logTime()
|
|
204
|
+
], PromptsService.prototype, "getCustomChatModes", null));
|
|
205
|
+
PromptsService.__decorator = ( __decorate([
|
|
206
|
+
logTime()
|
|
207
|
+
], PromptsService.prototype, "findInstructionFilesFor", null));
|
|
208
|
+
PromptsService.__decorator = ( __decorate([
|
|
209
|
+
logTime()
|
|
210
|
+
], PromptsService.prototype, "getAllMetadata", null));
|
|
209
211
|
PromptsService = ( __decorate([
|
|
210
|
-
( __param(0,
|
|
211
|
-
( __param(1,
|
|
212
|
-
( __param(2,
|
|
213
|
-
( __param(3,
|
|
212
|
+
( __param(0, ILogService)),
|
|
213
|
+
( __param(1, ILabelService)),
|
|
214
|
+
( __param(2, IModelService)),
|
|
215
|
+
( __param(3, IInstantiationService)),
|
|
216
|
+
( __param(4, IUserDataProfileService))
|
|
214
217
|
], PromptsService));
|
|
215
|
-
const morePrivilegedChatMode = (chatMode1, chatMode2) => {
|
|
216
|
-
if (chatMode1 === chatMode2) {
|
|
217
|
-
return chatMode1;
|
|
218
|
-
}
|
|
219
|
-
if ((chatMode1 === ChatMode.Agent) || (chatMode2 === ChatMode.Agent)) {
|
|
220
|
-
return ChatMode.Agent;
|
|
221
|
-
}
|
|
222
|
-
if ((chatMode1 === ChatMode.Edit) || (chatMode2 === ChatMode.Edit)) {
|
|
223
|
-
return ChatMode.Edit;
|
|
224
|
-
}
|
|
225
|
-
throw ( new Error([
|
|
226
|
-
'Invalid logic encountered: ',
|
|
227
|
-
`at this point modes '${chatMode1}' and '${chatMode2}' are different, but`,
|
|
228
|
-
`both must have be equal to '${ChatMode.Ask}' at the same time.`,
|
|
229
|
-
].join(' ')));
|
|
230
|
-
};
|
|
231
218
|
const collectMetadata = (reference) => {
|
|
232
219
|
const childMetadata = [];
|
|
233
220
|
for (const child of reference.references) {
|
package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
|
-
import { TPromptsType } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types";
|
|
2
1
|
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
3
2
|
import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
|
|
4
3
|
import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
|
|
5
4
|
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
6
|
-
|
|
5
|
+
import { PromptsType } from "@codingame/monaco-vscode-47472025-cc45-5680-86cd-09ceaba921a1-common/vscode/vs/platform/prompts/common/prompts";
|
|
6
|
+
import { IWorkbenchEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service";
|
|
7
|
+
import { ISearchService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/search/common/search.service";
|
|
8
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
9
|
+
import { TPromptsStorage } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types";
|
|
10
|
+
import { IUserDataProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service";
|
|
11
|
+
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
12
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
13
|
+
export declare class PromptFilesLocator extends Disposable {
|
|
7
14
|
private readonly fileService;
|
|
8
15
|
private readonly configService;
|
|
9
16
|
private readonly workspaceService;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
private readonly environmentService;
|
|
18
|
+
private readonly searchService;
|
|
19
|
+
private readonly userDataService;
|
|
20
|
+
constructor(fileService: IFileService, configService: IConfigurationService, workspaceService: IWorkspaceContextService, environmentService: IWorkbenchEnvironmentService, searchService: ISearchService, userDataService: IUserDataProfileService);
|
|
21
|
+
listFiles(type: PromptsType, storage: TPromptsStorage, token: CancellationToken): Promise<readonly URI[]>;
|
|
22
|
+
private listFilesInUserData;
|
|
23
|
+
getFilesUpdatedEvent(type: PromptsType): Event<void>;
|
|
24
|
+
getConfigBasedSourceFolders(type: PromptsType): readonly URI[];
|
|
25
|
+
private listFilesInLocal;
|
|
26
|
+
private getLocalParentFolders;
|
|
27
|
+
private toAbsoluteLocations;
|
|
28
|
+
private resolveFilesAtLocation;
|
|
29
|
+
private searchFilesInLocation;
|
|
15
30
|
}
|
|
16
31
|
export declare const isValidGlob: (pattern: string) => boolean;
|
|
17
|
-
export declare const firstNonGlobParent: (location: URI) => URI;
|