@codingame/monaco-vscode-chat-service-override 14.0.6 → 15.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.
Files changed (110) hide show
  1. package/index.js +14 -8
  2. package/package.json +20 -20
  3. package/vscode/src/vs/base/common/objectCache.d.ts +1 -1
  4. package/vscode/src/vs/base/common/objectCache.js +1 -1
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +43 -42
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +10 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +40 -0
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.d.ts +17 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +142 -0
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +2 -2
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +25 -25
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +2 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +252 -260
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +3 -1
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +8 -4
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -6
  20. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +6 -6
  21. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +12 -41
  22. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +7 -5
  23. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +31 -29
  24. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +151 -69
  25. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
  26. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +1 -1
  27. package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.d.ts +4 -3
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.js +4 -4
  29. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorAccessibility.d.ts +10 -0
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorAccessibility.js +38 -0
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.d.ts +9 -0
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +379 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/{chatEditingService.d.ts → chatEditingServiceImpl.d.ts} +12 -28
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +423 -0
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +3 -3
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +6 -7
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +38 -38
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +16 -6
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +93 -24
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
  41. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +21 -2
  42. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +1 -1
  43. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
  44. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +101 -2
  45. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +146 -126
  46. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +39 -0
  47. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +386 -0
  48. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -12
  49. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +8 -91
  50. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
  51. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +7 -11
  52. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
  53. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +45 -45
  54. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
  55. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +11 -19
  56. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +6 -0
  57. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +6 -0
  58. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.d.ts +1 -0
  59. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +82 -0
  60. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.d.ts +2 -0
  61. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +22 -0
  62. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.d.ts +16 -0
  63. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +67 -0
  64. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.d.ts +9 -0
  65. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +17 -0
  66. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +12 -0
  67. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +24 -0
  68. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.d.ts +6 -0
  69. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +78 -0
  70. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +6 -6
  71. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +2 -0
  72. package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +19 -0
  73. package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +13 -0
  74. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +12 -10
  75. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +26 -13
  76. package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +31 -0
  77. package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +85 -0
  78. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +6 -2
  79. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +33 -27
  80. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +0 -10
  81. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +4 -0
  82. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +9 -0
  83. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +1 -1
  84. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +1 -1
  85. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.d.ts +4 -6
  86. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.js +15 -23
  87. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.d.ts +22 -0
  88. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +175 -0
  89. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +2 -3
  90. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +6 -7
  91. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.d.ts +20 -0
  92. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +62 -0
  93. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +14 -0
  94. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +101 -0
  95. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +17 -17
  96. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
  97. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
  98. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +12 -12
  99. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +2 -2
  100. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +4 -4
  101. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.d.ts +1 -1
  102. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +31 -36
  103. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +3 -3
  104. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +0 -505
  105. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +0 -104
  106. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +0 -871
  107. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +0 -54
  108. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +0 -245
  109. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.d.ts +0 -39
  110. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.js +0 -314
@@ -1,6 +1,6 @@
1
1
  import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
2
2
  import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
3
- import { PromptContentsProviderBase } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase";
3
+ import { PromptContentsProviderBase } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase";
4
4
  import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
5
5
  import { ReadableStream } from "@codingame/monaco-vscode-api/vscode/vs/base/common/stream";
6
6
  import { IModelContentChangedEvent } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/textModelEvents";
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
3
3
  import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
4
- import { PromptContentsProviderBase } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase';
4
+ import { PromptContentsProviderBase } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase';
5
5
  import { newWriteableStream } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stream';
6
6
 
7
7
  class TextModelContentsProvider extends PromptContentsProviderBase {
@@ -1,14 +1,12 @@
1
+ import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service";
1
2
  import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
2
3
  import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
4
  import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
4
5
  import { ILinksList, LinkProvider } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages";
5
- import { ILanguageFeaturesService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures";
6
- import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
6
+ import { ILanguageFeaturesService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service";
7
7
  export declare class PromptLinkProvider extends Disposable implements LinkProvider {
8
- private readonly initService;
8
+ private readonly promptsService;
9
9
  private readonly languageService;
10
- private readonly parserProvider;
11
- constructor(initService: IInstantiationService, languageService: ILanguageFeaturesService);
12
- private createParser;
10
+ constructor(promptsService: IPromptsService, languageService: ILanguageFeaturesService);
13
11
  provideLinks(model: ITextModel, token: CancellationToken): Promise<ILinksList>;
14
12
  }
@@ -1,38 +1,27 @@
1
1
 
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { LANGUAGE_SELECTOR } from '../constants.js';
4
+ import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service';
3
5
  import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
4
6
  import { assertDefined } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
5
7
  import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
6
- import { NonPromptSnippetFile } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptFileReferenceErrors';
7
- import { ObjectCache } from '../../../../../../base/common/objectCache.js';
8
8
  import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
9
- import { TextModelPromptParser } from '../parsers/textModelPromptParser.js';
10
9
  import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
10
+ import { FolderReference, NotPromptFile } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptFileReferenceErrors';
11
11
  import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
12
- import { PROMPT_SNIPPET_FILE_EXTENSION } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase';
13
- import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures';
14
- import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
15
12
  import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
13
+ import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
16
14
 
17
- const languageSelector = {
18
- pattern: `**/*${PROMPT_SNIPPET_FILE_EXTENSION}`,
19
- };
20
15
  let PromptLinkProvider = class PromptLinkProvider extends Disposable {
21
- constructor(initService, languageService) {
16
+ constructor(promptsService, languageService) {
22
17
  super();
23
- this.initService = initService;
18
+ this.promptsService = promptsService;
24
19
  this.languageService = languageService;
25
- this.languageService.linkProvider.register(languageSelector, this);
26
- this.parserProvider = this._register(( new ObjectCache(this.createParser.bind(this))));
27
- }
28
- createParser(model) {
29
- const parser = this.initService.createInstance(TextModelPromptParser, model, []);
30
- parser.assertNotDisposed('Created prompt parser must not be disposed.');
31
- return parser;
20
+ this._register(this.languageService.linkProvider.register(LANGUAGE_SELECTOR, this));
32
21
  }
33
22
  async provideLinks(model, token) {
34
23
  assert(!token.isCancellationRequested, ( new CancellationError()));
35
- const parser = this.parserProvider.get(model);
24
+ const parser = this.promptsService.getSyntaxParserFor(model);
36
25
  assert(!parser.disposed, 'Prompt parser must not be disposed.');
37
26
  const { references } = await parser
38
27
  .start()
@@ -44,14 +33,17 @@ let PromptLinkProvider = class PromptLinkProvider extends Disposable {
44
33
  if (!errorCondition && linkRange) {
45
34
  return true;
46
35
  }
47
- return errorCondition instanceof NonPromptSnippetFile;
36
+ if (errorCondition instanceof FolderReference) {
37
+ return false;
38
+ }
39
+ return errorCondition instanceof NotPromptFile;
48
40
  })
49
41
  .map((reference) => {
50
- const { linkRange } = reference;
42
+ const { uri, linkRange } = reference;
51
43
  assertDefined(linkRange, 'Link range must be defined.');
52
44
  return {
53
45
  range: linkRange,
54
- url: reference.uri,
46
+ url: uri,
55
47
  };
56
48
  }));
57
49
  return {
@@ -60,7 +52,7 @@ let PromptLinkProvider = class PromptLinkProvider extends Disposable {
60
52
  }
61
53
  };
62
54
  PromptLinkProvider = ( __decorate([
63
- ( __param(0, IInstantiationService)),
55
+ ( __param(0, IPromptsService)),
64
56
  ( __param(1, ILanguageFeaturesService))
65
57
  ], PromptLinkProvider));
66
58
  ( Registry.as(Extensions.Workbench))
@@ -0,0 +1,22 @@
1
+ import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service";
2
+ import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
3
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
4
+ import { Position } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position";
5
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
6
+ import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
7
+ import { ILanguageFeaturesService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service";
8
+ import { CompletionContext, CompletionItemProvider, CompletionList } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages";
9
+ type TTriggerCharacter = ":" | "." | "/";
10
+ export declare class PromptPathAutocompletion extends Disposable implements CompletionItemProvider {
11
+ private readonly fileService;
12
+ private readonly promptSyntaxService;
13
+ private readonly languageService;
14
+ readonly _debugDisplayName: string;
15
+ readonly triggerCharacters: TTriggerCharacter[];
16
+ constructor(fileService: IFileService, promptSyntaxService: IPromptsService, languageService: ILanguageFeaturesService);
17
+ provideCompletionItems(model: ITextModel, position: Position, context: CompletionContext, token: CancellationToken): Promise<CompletionList | undefined>;
18
+ private getFolderSuggestions;
19
+ private getFirstFolderSuggestions;
20
+ private getNonFirstFolderSuggestions;
21
+ }
22
+ export {};
@@ -0,0 +1,175 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { LANGUAGE_SELECTOR } from '../constants.js';
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
+ import { assertOneOf } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
7
+ import { isWindows } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
8
+ import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
9
+ import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
10
+ import { dirname, extUri } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
11
+ import { assert, assertNever } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
12
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
13
+ import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
14
+ import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
15
+ import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
16
+ import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
17
+ import { CompletionItemKind } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
18
+
19
+ const findFileReference = (references, position) => {
20
+ for (const reference of references) {
21
+ const { range } = reference;
22
+ if (reference.type !== 'file') {
23
+ return undefined;
24
+ }
25
+ if (!reference.text.startsWith(FileReference.TOKEN_START)) {
26
+ return undefined;
27
+ }
28
+ const { startLineNumber, endColumn } = range;
29
+ if ((startLineNumber !== position.lineNumber) || (endColumn !== position.column)) {
30
+ continue;
31
+ }
32
+ return reference;
33
+ }
34
+ return undefined;
35
+ };
36
+ let PromptPathAutocompletion = class PromptPathAutocompletion extends Disposable {
37
+ constructor(fileService, promptSyntaxService, languageService) {
38
+ super();
39
+ this.fileService = fileService;
40
+ this.promptSyntaxService = promptSyntaxService;
41
+ this.languageService = languageService;
42
+ this._debugDisplayName = 'PromptPathAutocompletion';
43
+ this.triggerCharacters = [':', '.', '/'];
44
+ this._register(this.languageService.completionProvider.register(LANGUAGE_SELECTOR, this));
45
+ }
46
+ async provideCompletionItems(model, position, context, token) {
47
+ assert(!token.isCancellationRequested, ( new CancellationError()));
48
+ const { triggerCharacter } = context;
49
+ if (!triggerCharacter) {
50
+ return undefined;
51
+ }
52
+ assertOneOf(triggerCharacter, this.triggerCharacters, `Prompt path autocompletion provider`);
53
+ const parser = this.promptSyntaxService.getSyntaxParserFor(model);
54
+ assert(!parser.disposed, 'Prompt parser must not be disposed.');
55
+ const { references } = await parser
56
+ .start()
57
+ .settled();
58
+ assert(!token.isCancellationRequested, ( new CancellationError()));
59
+ const fileReference = findFileReference(references, position);
60
+ if (!fileReference) {
61
+ return undefined;
62
+ }
63
+ const modelDirname = dirname(model.uri);
64
+ if (triggerCharacter === ':' || (triggerCharacter === '.' && fileReference.path === '.')) {
65
+ return {
66
+ suggestions: await this.getFirstFolderSuggestions(triggerCharacter, modelDirname, fileReference),
67
+ };
68
+ }
69
+ if (triggerCharacter === '/' || triggerCharacter === '.') {
70
+ return {
71
+ suggestions: await this.getNonFirstFolderSuggestions(triggerCharacter, modelDirname, fileReference),
72
+ };
73
+ }
74
+ assertNever(triggerCharacter, `Unexpected trigger character '${triggerCharacter}'.`);
75
+ }
76
+ async getFolderSuggestions(uri) {
77
+ const { children } = await this.fileService.resolve(uri);
78
+ const suggestions = [];
79
+ if (!children) {
80
+ return suggestions;
81
+ }
82
+ for (const child of children) {
83
+ const kind = child.isDirectory
84
+ ? CompletionItemKind.Folder
85
+ : CompletionItemKind.File;
86
+ const sortText = child.isDirectory
87
+ ? '1'
88
+ : '2';
89
+ suggestions.push({
90
+ label: child.name,
91
+ kind,
92
+ sortText,
93
+ });
94
+ }
95
+ return suggestions;
96
+ }
97
+ async getFirstFolderSuggestions(character, fileFolderUri, fileReference) {
98
+ const { linkRange } = fileReference;
99
+ if (character === ':' && linkRange !== undefined) {
100
+ return [];
101
+ }
102
+ if (character === '.' && linkRange === undefined) {
103
+ return [];
104
+ }
105
+ const suggestions = await this.getFolderSuggestions(fileFolderUri);
106
+ const startColumnOffset = (character === '.') ? 1 : 0;
107
+ const range = {
108
+ ...fileReference.range,
109
+ endColumn: fileReference.range.endColumn,
110
+ startColumn: fileReference.range.endColumn - startColumnOffset,
111
+ };
112
+ return [
113
+ {
114
+ label: '..',
115
+ kind: CompletionItemKind.Folder,
116
+ insertText: '..',
117
+ range,
118
+ sortText: '0',
119
+ },
120
+ ...( suggestions
121
+ .map((suggestion) => {
122
+ const suffix = (suggestion.kind === CompletionItemKind.File)
123
+ ? ' '
124
+ : '';
125
+ return {
126
+ ...suggestion,
127
+ range,
128
+ label: `./${suggestion.label}${suffix}`,
129
+ insertText: `./${suggestion.label}${suffix}`,
130
+ };
131
+ })),
132
+ ];
133
+ }
134
+ async getNonFirstFolderSuggestions(character, fileFolderUri, fileReference) {
135
+ const { linkRange, path } = fileReference;
136
+ if (linkRange === undefined) {
137
+ return [];
138
+ }
139
+ const currenFolder = extUri.resolvePath(fileFolderUri, path);
140
+ let suggestions = await this.getFolderSuggestions(currenFolder);
141
+ if (character === '.') {
142
+ suggestions = suggestions.filter((suggestion) => {
143
+ return suggestion.label.startsWith('.');
144
+ });
145
+ }
146
+ const startColumnOffset = (character === '.') ? 1 : 0;
147
+ const range = {
148
+ ...fileReference.range,
149
+ endColumn: fileReference.range.endColumn,
150
+ startColumn: fileReference.range.endColumn - startColumnOffset,
151
+ };
152
+ return ( suggestions
153
+ .map((suggestion) => {
154
+ const suffix = (suggestion.kind === CompletionItemKind.File)
155
+ ? ' '
156
+ : '';
157
+ return {
158
+ ...suggestion,
159
+ insertText: `${suggestion.label}${suffix}`,
160
+ range,
161
+ };
162
+ }));
163
+ }
164
+ };
165
+ PromptPathAutocompletion = ( __decorate([
166
+ ( __param(0, IFileService)),
167
+ ( __param(1, IPromptsService)),
168
+ ( __param(2, ILanguageFeaturesService))
169
+ ], PromptPathAutocompletion));
170
+ if (!isWindows) {
171
+ ( Registry.as(Extensions.Workbench))
172
+ .registerWorkbenchContribution(PromptPathAutocompletion, LifecyclePhase.Eventually);
173
+ }
174
+
175
+ export { PromptPathAutocompletion };
@@ -1,10 +1,9 @@
1
- import { BasePromptParser } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/parsers/basePromptParser";
1
+ import { BasePromptParser } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/parsers/basePromptParser";
2
2
  import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
3
3
  import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
4
4
  import { TextModelContentsProvider } from "../contentProviders/textModelContentsProvider.js";
5
- import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
6
5
  import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
7
6
  export declare class TextModelPromptParser extends BasePromptParser<TextModelContentsProvider> {
8
- constructor(model: ITextModel, seenReferences: string[] | undefined, initService: IInstantiationService, configService: IConfigurationService, logService: ILogService);
7
+ constructor(model: ITextModel, seenReferences: string[] | undefined, initService: IInstantiationService, logService: ILogService);
9
8
  toString(): string;
10
9
  }
@@ -1,15 +1,15 @@
1
1
 
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { BasePromptParser } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/parsers/basePromptParser';
3
+ import { BasePromptParser } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/parsers/basePromptParser';
4
4
  import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
5
5
  import { TextModelContentsProvider } from '../contentProviders/textModelContentsProvider.js';
6
- import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
7
6
  import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
8
7
 
9
8
  let TextModelPromptParser = class TextModelPromptParser extends BasePromptParser {
10
- constructor(model, seenReferences = [], initService, configService, logService) {
11
- const contentsProvider = initService.createInstance(TextModelContentsProvider, model);
12
- super(contentsProvider, seenReferences, initService, configService, logService);
9
+ constructor(model, seenReferences = [], initService, logService) {
10
+ const contentsProvider = initService.createInstance(TextModelContentsProvider, model)
11
+ .onDispose(() => this.dispose());
12
+ super(contentsProvider, seenReferences, initService, logService);
13
13
  }
14
14
  toString() {
15
15
  return `text-model-prompt:${this.uri.path}`;
@@ -17,8 +17,7 @@ let TextModelPromptParser = class TextModelPromptParser extends BasePromptParser
17
17
  };
18
18
  TextModelPromptParser = ( __decorate([
19
19
  ( __param(2, IInstantiationService)),
20
- ( __param(3, IConfigurationService)),
21
- ( __param(4, ILogService))
20
+ ( __param(3, ILogService))
22
21
  ], TextModelPromptParser));
23
22
 
24
23
  export { TextModelPromptParser };
@@ -0,0 +1,20 @@
1
+ import { IPromptPath } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types";
2
+ import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/types.service";
3
+ import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
4
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
5
+ import { TextModelPromptParser } from "../parsers/textModelPromptParser.js";
6
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
7
+ import { IUserDataProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service";
8
+ export declare class PromptsService extends Disposable implements IPromptsService {
9
+ private readonly initService;
10
+ private readonly userDataService;
11
+ readonly _serviceBrand: undefined;
12
+ private readonly cache;
13
+ private readonly fileLocator;
14
+ constructor(initService: IInstantiationService, userDataService: IUserDataProfileService);
15
+ getSyntaxParserFor(model: ITextModel): TextModelPromptParser & {
16
+ disposed: false;
17
+ };
18
+ listPromptFiles(): Promise<readonly IPromptPath[]>;
19
+ getSourceFolders(type: IPromptPath["type"]): readonly IPromptPath[];
20
+ }
@@ -0,0 +1,62 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
4
+ import { PromptFilesLocator } from '../utils/promptFilesLocator.js';
5
+ import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
6
+ import { ObjectCache } from '../../../../../../base/common/objectCache.js';
7
+ import { TextModelPromptParser } from '../parsers/textModelPromptParser.js';
8
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
9
+ import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
10
+
11
+ let PromptsService = class PromptsService extends Disposable {
12
+ constructor(initService, userDataService) {
13
+ super();
14
+ this.initService = initService;
15
+ this.userDataService = userDataService;
16
+ this.fileLocator = this.initService.createInstance(PromptFilesLocator);
17
+ this.cache = this._register(( new ObjectCache((model) => {
18
+ const parser = initService.createInstance(TextModelPromptParser, model, []);
19
+ parser.start();
20
+ parser.assertNotDisposed('Created prompt parser must not be disposed.');
21
+ return parser;
22
+ })));
23
+ }
24
+ getSyntaxParserFor(model) {
25
+ assert(!model.isDisposed(), 'Cannot create a prompt syntax parser for a disposed model.');
26
+ return this.cache.get(model);
27
+ }
28
+ async listPromptFiles() {
29
+ const userLocations = [this.userDataService.currentProfile.promptsHome];
30
+ const prompts = await Promise.all([
31
+ this.fileLocator.listFilesIn(userLocations, [])
32
+ .then(withType('user')),
33
+ this.fileLocator.listFiles([])
34
+ .then(withType('local')),
35
+ ]);
36
+ return prompts.flat();
37
+ }
38
+ getSourceFolders(type) {
39
+ assert(type === 'local' || type === 'user', `Unknown prompt type '${type}'.`);
40
+ const prompts = (type === 'user')
41
+ ? [this.userDataService.currentProfile.promptsHome]
42
+ : this.fileLocator.getConfigBasedSourceFolders();
43
+ return ( prompts.map(addType(type)));
44
+ }
45
+ };
46
+ PromptsService = ( __decorate([
47
+ ( __param(0, IInstantiationService)),
48
+ ( __param(1, IUserDataProfileService))
49
+ ], PromptsService));
50
+ const addType = (type) => {
51
+ return (uri) => {
52
+ return { uri, type: type };
53
+ };
54
+ };
55
+ const withType = (type) => {
56
+ return (uris) => {
57
+ return ( uris
58
+ .map(addType(type)));
59
+ };
60
+ };
61
+
62
+ export { PromptsService };
@@ -0,0 +1,14 @@
1
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
3
+ import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
4
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
5
+ export declare class PromptFilesLocator {
6
+ private readonly fileService;
7
+ private readonly workspaceService;
8
+ private readonly configService;
9
+ constructor(fileService: IFileService, workspaceService: IWorkspaceContextService, configService: IConfigurationService);
10
+ listFiles(exclude: readonly URI[]): Promise<readonly URI[]>;
11
+ listFilesIn(folders: readonly URI[], exclude: readonly URI[]): Promise<readonly URI[]>;
12
+ getConfigBasedSourceFolders(): readonly URI[];
13
+ private findInstructionFiles;
14
+ }
@@ -0,0 +1,101 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
4
+ import { ResourceSet } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
5
+ import { extUri, dirname } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
6
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
7
+ import { PromptsConfig } from '@codingame/monaco-vscode-52bb4d5b-ba1a-57fd-9bee-b28824214eac-common/vscode/vs/platform/prompts/common/config';
8
+ import { isPromptFile } from '@codingame/monaco-vscode-52bb4d5b-ba1a-57fd-9bee-b28824214eac-common/vscode/vs/platform/prompts/common/constants';
9
+ import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
10
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
11
+
12
+ let PromptFilesLocator = class PromptFilesLocator {
13
+ constructor(fileService, workspaceService, configService) {
14
+ this.fileService = fileService;
15
+ this.workspaceService = workspaceService;
16
+ this.configService = configService;
17
+ }
18
+ async listFiles(exclude) {
19
+ return await this.listFilesIn(this.getConfigBasedSourceFolders(), exclude);
20
+ }
21
+ async listFilesIn(folders, exclude) {
22
+ const excludeSet = ( new Set());
23
+ for (const excludeUri of exclude) {
24
+ excludeSet.add(excludeUri.path);
25
+ }
26
+ const cleanFolders = folders
27
+ .filter((folder) => {
28
+ return !( excludeSet.has(folder.path));
29
+ });
30
+ return await this.findInstructionFiles(cleanFolders, excludeSet);
31
+ }
32
+ getConfigBasedSourceFolders() {
33
+ const paths = ( new ResourceSet());
34
+ const sourceFolders = PromptsConfig.promptSourceFolders(this.configService);
35
+ for (const sourceFolderName of sourceFolders) {
36
+ const sourceFolderUri = URI.file(sourceFolderName);
37
+ if (sourceFolderUri.path === sourceFolderName) {
38
+ if (( paths.has(sourceFolderUri))) {
39
+ continue;
40
+ }
41
+ paths.add(sourceFolderUri);
42
+ continue;
43
+ }
44
+ const { folders } = this.workspaceService.getWorkspace();
45
+ for (const folder of folders) {
46
+ const relativeFolderUri = extUri.resolvePath(folder.uri, sourceFolderName);
47
+ if (!( paths.has(relativeFolderUri))) {
48
+ paths.add(relativeFolderUri);
49
+ }
50
+ if (folders.length <= 1) {
51
+ continue;
52
+ }
53
+ const workspaceRootUri = dirname(folder.uri);
54
+ const workspaceFolderUri = extUri.resolvePath(workspaceRootUri, sourceFolderName);
55
+ if (( paths.has(workspaceFolderUri))) {
56
+ continue;
57
+ }
58
+ if (workspaceFolderUri.fsPath.startsWith(folder.uri.fsPath)) {
59
+ paths.add(workspaceFolderUri);
60
+ }
61
+ }
62
+ }
63
+ return [...paths];
64
+ }
65
+ async findInstructionFiles(folders, exclude) {
66
+ const results = await this.fileService.resolveAll(( folders.map((resource) => {
67
+ return { resource };
68
+ })));
69
+ const files = [];
70
+ for (const result of results) {
71
+ const { stat, success } = result;
72
+ if (!success) {
73
+ continue;
74
+ }
75
+ if (!stat || !stat.children) {
76
+ continue;
77
+ }
78
+ for (const child of stat.children) {
79
+ const { resource, isDirectory } = child;
80
+ if (isDirectory) {
81
+ continue;
82
+ }
83
+ if (!isPromptFile(resource)) {
84
+ continue;
85
+ }
86
+ if (( exclude.has(resource.path))) {
87
+ continue;
88
+ }
89
+ files.push(resource);
90
+ }
91
+ }
92
+ return files;
93
+ }
94
+ };
95
+ PromptFilesLocator = ( __decorate([
96
+ ( __param(0, IFileService)),
97
+ ( __param(1, IWorkspaceContextService)),
98
+ ( __param(2, IConfigurationService))
99
+ ], PromptFilesLocator));
100
+
101
+ export { PromptFilesLocator };