@codingame/monaco-vscode-xterm-addons-common 28.4.1 → 29.1.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/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +7 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +11 -37
- package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugAttachment.js +4 -51
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +24 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +25 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +48 -34
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js +234 -14
- package/vscode/src/vs/workbench/contrib/chat/common/chatDebugEvents.d.ts +58 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatDebugEvents.js +135 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +16 -16
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +20 -4
package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js
CHANGED
|
@@ -12,7 +12,7 @@ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/fi
|
|
|
12
12
|
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
13
13
|
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
14
14
|
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
15
|
-
import { getCleanPromptName } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations';
|
|
15
|
+
import { getSkillFolderName, getCleanPromptName } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations';
|
|
16
16
|
import { PromptsType, HOOK_DOCUMENTATION_URL, SKILL_DOCUMENTATION_URL, AGENT_DOCUMENTATION_URL, INSTRUCTIONS_DOCUMENTATION_URL, PROMPT_DOCUMENTATION_URL } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptTypes';
|
|
17
17
|
import { NEW_PROMPT_COMMAND_ID, NEW_INSTRUCTIONS_COMMAND_ID, NEW_AGENT_COMMAND_ID, NEW_SKILL_COMMAND_ID } from '../newPromptFileActions.js';
|
|
18
18
|
import { GENERATE_AGENT_INSTRUCTIONS_COMMAND_ID, GENERATE_ON_DEMAND_INSTRUCTIONS_COMMAND_ID, GENERATE_PROMPT_COMMAND_ID, GENERATE_SKILL_COMMAND_ID, GENERATE_AGENT_COMMAND_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
@@ -32,31 +32,31 @@ function newHelpButton(type) {
|
|
|
32
32
|
switch (type) {
|
|
33
33
|
case PromptsType.prompt:
|
|
34
34
|
return {
|
|
35
|
-
tooltip: ( localize(
|
|
35
|
+
tooltip: ( localize(6506, "Show help on prompt files")),
|
|
36
36
|
helpURI: ( URI.parse(PROMPT_DOCUMENTATION_URL)),
|
|
37
37
|
iconClass
|
|
38
38
|
};
|
|
39
39
|
case PromptsType.instructions:
|
|
40
40
|
return {
|
|
41
|
-
tooltip: ( localize(
|
|
41
|
+
tooltip: ( localize(6507, "Show help on instruction files")),
|
|
42
42
|
helpURI: ( URI.parse(INSTRUCTIONS_DOCUMENTATION_URL)),
|
|
43
43
|
iconClass
|
|
44
44
|
};
|
|
45
45
|
case PromptsType.agent:
|
|
46
46
|
return {
|
|
47
|
-
tooltip: ( localize(
|
|
47
|
+
tooltip: ( localize(6508, "Show help on custom agent files")),
|
|
48
48
|
helpURI: ( URI.parse(AGENT_DOCUMENTATION_URL)),
|
|
49
49
|
iconClass
|
|
50
50
|
};
|
|
51
51
|
case PromptsType.skill:
|
|
52
52
|
return {
|
|
53
|
-
tooltip: ( localize(
|
|
53
|
+
tooltip: ( localize(6509, "Show help on skill files")),
|
|
54
54
|
helpURI: ( URI.parse(SKILL_DOCUMENTATION_URL)),
|
|
55
55
|
iconClass
|
|
56
56
|
};
|
|
57
57
|
case PromptsType.hook:
|
|
58
58
|
return {
|
|
59
|
-
tooltip: ( localize(
|
|
59
|
+
tooltip: ( localize(6510, "Show help on hook files")),
|
|
60
60
|
helpURI: ( URI.parse(HOOK_DOCUMENTATION_URL)),
|
|
61
61
|
iconClass
|
|
62
62
|
};
|
|
@@ -73,7 +73,7 @@ function isExtensionPromptPath(prompt) {
|
|
|
73
73
|
}
|
|
74
74
|
const NEW_PROMPT_FILE_OPTION = {
|
|
75
75
|
type: "item",
|
|
76
|
-
label: `$(plus) ${( localize(
|
|
76
|
+
label: `$(plus) ${( localize(6511, "New prompt file..."))}`,
|
|
77
77
|
pickable: false,
|
|
78
78
|
alwaysShow: true,
|
|
79
79
|
buttons: [newHelpButton(PromptsType.prompt)],
|
|
@@ -81,7 +81,7 @@ const NEW_PROMPT_FILE_OPTION = {
|
|
|
81
81
|
};
|
|
82
82
|
const NEW_INSTRUCTIONS_FILE_OPTION = {
|
|
83
83
|
type: "item",
|
|
84
|
-
label: `$(plus) ${( localize(
|
|
84
|
+
label: `$(plus) ${( localize(6512, "New instruction file..."))}`,
|
|
85
85
|
pickable: false,
|
|
86
86
|
alwaysShow: true,
|
|
87
87
|
buttons: [newHelpButton(PromptsType.instructions)],
|
|
@@ -89,7 +89,7 @@ const NEW_INSTRUCTIONS_FILE_OPTION = {
|
|
|
89
89
|
};
|
|
90
90
|
const GENERATE_AGENT_INSTRUCTIONS_OPTION = {
|
|
91
91
|
type: "item",
|
|
92
|
-
label: `$(sparkle) ${( localize(
|
|
92
|
+
label: `$(sparkle) ${( localize(6513, "Generate agent instructions..."))}`,
|
|
93
93
|
pickable: false,
|
|
94
94
|
alwaysShow: true,
|
|
95
95
|
buttons: [newHelpButton(PromptsType.instructions)],
|
|
@@ -97,7 +97,7 @@ const GENERATE_AGENT_INSTRUCTIONS_OPTION = {
|
|
|
97
97
|
};
|
|
98
98
|
const GENERATE_ON_DEMAND_INSTRUCTIONS_OPTION = {
|
|
99
99
|
type: "item",
|
|
100
|
-
label: `$(sparkle) ${( localize(
|
|
100
|
+
label: `$(sparkle) ${( localize(6514, "Generate on-demand instructions..."))}`,
|
|
101
101
|
pickable: false,
|
|
102
102
|
alwaysShow: true,
|
|
103
103
|
buttons: [newHelpButton(PromptsType.instructions)],
|
|
@@ -105,7 +105,7 @@ const GENERATE_ON_DEMAND_INSTRUCTIONS_OPTION = {
|
|
|
105
105
|
};
|
|
106
106
|
const NEW_AGENT_FILE_OPTION = {
|
|
107
107
|
type: "item",
|
|
108
|
-
label: `$(plus) ${( localize(
|
|
108
|
+
label: `$(plus) ${( localize(6515, "Create new custom agent..."))}`,
|
|
109
109
|
pickable: false,
|
|
110
110
|
alwaysShow: true,
|
|
111
111
|
buttons: [newHelpButton(PromptsType.agent)],
|
|
@@ -113,7 +113,7 @@ const NEW_AGENT_FILE_OPTION = {
|
|
|
113
113
|
};
|
|
114
114
|
const NEW_SKILL_FILE_OPTION = {
|
|
115
115
|
type: "item",
|
|
116
|
-
label: `$(plus) ${( localize(
|
|
116
|
+
label: `$(plus) ${( localize(6516, "New skill..."))}`,
|
|
117
117
|
pickable: false,
|
|
118
118
|
alwaysShow: true,
|
|
119
119
|
buttons: [newHelpButton(PromptsType.skill)],
|
|
@@ -121,7 +121,7 @@ const NEW_SKILL_FILE_OPTION = {
|
|
|
121
121
|
};
|
|
122
122
|
const GENERATE_PROMPT_OPTION = {
|
|
123
123
|
type: "item",
|
|
124
|
-
label: `$(sparkle) ${( localize(
|
|
124
|
+
label: `$(sparkle) ${( localize(6517, "Generate prompt..."))}`,
|
|
125
125
|
pickable: false,
|
|
126
126
|
alwaysShow: true,
|
|
127
127
|
buttons: [newHelpButton(PromptsType.prompt)],
|
|
@@ -129,7 +129,7 @@ const GENERATE_PROMPT_OPTION = {
|
|
|
129
129
|
};
|
|
130
130
|
const GENERATE_SKILL_OPTION = {
|
|
131
131
|
type: "item",
|
|
132
|
-
label: `$(sparkle) ${( localize(
|
|
132
|
+
label: `$(sparkle) ${( localize(6518, "Generate skill..."))}`,
|
|
133
133
|
pickable: false,
|
|
134
134
|
alwaysShow: true,
|
|
135
135
|
buttons: [newHelpButton(PromptsType.skill)],
|
|
@@ -137,39 +137,39 @@ const GENERATE_SKILL_OPTION = {
|
|
|
137
137
|
};
|
|
138
138
|
const GENERATE_AGENT_OPTION = {
|
|
139
139
|
type: "item",
|
|
140
|
-
label: `$(sparkle) ${( localize(
|
|
140
|
+
label: `$(sparkle) ${( localize(6519, "Generate agent..."))}`,
|
|
141
141
|
pickable: false,
|
|
142
142
|
alwaysShow: true,
|
|
143
143
|
buttons: [newHelpButton(PromptsType.agent)],
|
|
144
144
|
commandId: GENERATE_AGENT_COMMAND_ID
|
|
145
145
|
};
|
|
146
146
|
const EDIT_BUTTON = {
|
|
147
|
-
tooltip: ( localize(
|
|
147
|
+
tooltip: ( localize(6520, "Open in Editor")),
|
|
148
148
|
iconClass: ThemeIcon.asClassName(Codicon.fileCode)
|
|
149
149
|
};
|
|
150
150
|
const DELETE_BUTTON = {
|
|
151
|
-
tooltip: ( localize(
|
|
151
|
+
tooltip: ( localize(6521, "Delete")),
|
|
152
152
|
iconClass: ThemeIcon.asClassName(Codicon.trash)
|
|
153
153
|
};
|
|
154
154
|
const RENAME_BUTTON = {
|
|
155
|
-
tooltip: ( localize(
|
|
155
|
+
tooltip: ( localize(6522, "Move and/or Rename")),
|
|
156
156
|
iconClass: ThemeIcon.asClassName(Codicon.replace)
|
|
157
157
|
};
|
|
158
158
|
const COPY_BUTTON = {
|
|
159
|
-
tooltip: ( localize(
|
|
159
|
+
tooltip: ( localize(6523, "Make a Copy")),
|
|
160
160
|
iconClass: ThemeIcon.asClassName(Codicon.copy)
|
|
161
161
|
};
|
|
162
162
|
const MAKE_VISIBLE_BUTTON = {
|
|
163
|
-
tooltip: ( localize(
|
|
163
|
+
tooltip: ( localize(6524, "Hidden from chat view agent picker. Click to show.")),
|
|
164
164
|
iconClass: ThemeIcon.asClassName(Codicon.eyeClosed),
|
|
165
165
|
alwaysVisible: true
|
|
166
166
|
};
|
|
167
167
|
const MAKE_INVISIBLE_BUTTON = {
|
|
168
|
-
tooltip: ( localize(
|
|
168
|
+
tooltip: ( localize(6525, "Shown in chat view agent picker. Click to hide.")),
|
|
169
169
|
iconClass: ThemeIcon.asClassName(Codicon.eye)
|
|
170
170
|
};
|
|
171
171
|
const RUN_IN_CHAT_BUTTON = {
|
|
172
|
-
tooltip: ( localize(
|
|
172
|
+
tooltip: ( localize(6526, "Run in Chat View")),
|
|
173
173
|
iconClass: ThemeIcon.asClassName(Codicon.play)
|
|
174
174
|
};
|
|
175
175
|
let PromptFilePickers = class PromptFilePickers {
|
|
@@ -200,7 +200,7 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
200
200
|
useSeparators: true
|
|
201
201
|
});
|
|
202
202
|
quickPick.busy = true;
|
|
203
|
-
quickPick.placeholder = ( localize(
|
|
203
|
+
quickPick.placeholder = ( localize(6527, "Searching file system..."));
|
|
204
204
|
try {
|
|
205
205
|
const fileOptions = await this._createPromptPickItems(options, cts.token);
|
|
206
206
|
const activeItem = options.resource && fileOptions.find(
|
|
@@ -301,7 +301,7 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
301
301
|
if (locals.length) {
|
|
302
302
|
result.push({
|
|
303
303
|
type: "separator",
|
|
304
|
-
label: ( localize(
|
|
304
|
+
label: ( localize(6528, "Workspace"))
|
|
305
305
|
});
|
|
306
306
|
result.push(...sortByLabel(await Promise.all(( locals.map(l => this._createPromptPickItem(l, buttons, getVisibility(l), token))))));
|
|
307
307
|
}
|
|
@@ -324,7 +324,7 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
324
324
|
const agentButtons = buttons.filter(b => b !== RENAME_BUTTON);
|
|
325
325
|
result.push({
|
|
326
326
|
type: "separator",
|
|
327
|
-
label: ( localize(
|
|
327
|
+
label: ( localize(6529, "Agent Instructions"))
|
|
328
328
|
});
|
|
329
329
|
result.push(...sortByLabel(await Promise.all(( agentInstructionFiles.map(l => this._createPromptPickItem(l, agentButtons, getVisibility(l), token))))));
|
|
330
330
|
}
|
|
@@ -361,7 +361,7 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
361
361
|
if (users.length) {
|
|
362
362
|
result.push({
|
|
363
363
|
type: "separator",
|
|
364
|
-
label: ( localize(
|
|
364
|
+
label: ( localize(6530, "User Data"))
|
|
365
365
|
});
|
|
366
366
|
result.push(...sortByLabel(await Promise.all(( users.map(u => this._createPromptPickItem(u, buttons, getVisibility(u), token))))));
|
|
367
367
|
}
|
|
@@ -373,17 +373,28 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
373
373
|
}
|
|
374
374
|
result.push({
|
|
375
375
|
type: "separator",
|
|
376
|
-
label: ( localize(
|
|
376
|
+
label: ( localize(6531, "Plugins"))
|
|
377
377
|
});
|
|
378
378
|
result.push(...sortByLabel(await Promise.all(( plugins.map(p => this._createPromptPickItem(p, pluginButtons, getVisibility(p), token))))));
|
|
379
379
|
}
|
|
380
|
+
const internals = await this._promptsService.listPromptFilesForStorage(options.type, PromptsStorage.internal, token);
|
|
381
|
+
if (internals.length) {
|
|
382
|
+
const internalButtons = [];
|
|
383
|
+
result.push({
|
|
384
|
+
type: "separator",
|
|
385
|
+
label: ( localize(6532, "Built-in"))
|
|
386
|
+
});
|
|
387
|
+
result.push(...sortByLabel(await Promise.all(( internals.map(
|
|
388
|
+
p => this._createPromptPickItem(p, internalButtons, getVisibility(p), token)
|
|
389
|
+
)))));
|
|
390
|
+
}
|
|
380
391
|
return result;
|
|
381
392
|
}
|
|
382
393
|
_getExtensionGroupLabel(extPath) {
|
|
383
394
|
if (isOrganizationPromptFile(extPath.uri, extPath.extension.identifier, this._productService)) {
|
|
384
|
-
return localize(
|
|
395
|
+
return localize(6533, "Organization");
|
|
385
396
|
}
|
|
386
|
-
return localize(
|
|
397
|
+
return localize(6534, "Extensions");
|
|
387
398
|
}
|
|
388
399
|
_getNewItems(type) {
|
|
389
400
|
switch (type) {
|
|
@@ -405,7 +416,7 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
405
416
|
}
|
|
406
417
|
async _createPromptPickItem(promptFile, buttons, visibility, token) {
|
|
407
418
|
const parsedPromptFile = await this._promptsService.parseNew(promptFile.uri, token).catch(() => undefined);
|
|
408
|
-
let promptName = parsedPromptFile?.header?.name ?? promptFile.name
|
|
419
|
+
let promptName = (parsedPromptFile?.header?.name ?? promptFile.name) || (promptFile.type === PromptsType.skill ? getSkillFolderName(promptFile.uri) : getCleanPromptName(promptFile.uri));
|
|
409
420
|
const promptDescription = parsedPromptFile?.header?.description ?? promptFile.description;
|
|
410
421
|
let tooltip;
|
|
411
422
|
switch (promptFile.storage) {
|
|
@@ -423,14 +434,17 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
423
434
|
case PromptsStorage.plugin:
|
|
424
435
|
tooltip = promptFile.name;
|
|
425
436
|
break;
|
|
437
|
+
case PromptsStorage.internal:
|
|
438
|
+
tooltip = undefined;
|
|
439
|
+
break;
|
|
426
440
|
default:
|
|
427
441
|
assertNever();
|
|
428
442
|
}
|
|
429
443
|
let iconClass;
|
|
430
444
|
if (visibility === false) {
|
|
431
445
|
buttons = (buttons ?? []).concat(MAKE_VISIBLE_BUTTON);
|
|
432
|
-
promptName = ( localize(
|
|
433
|
-
tooltip = ( localize(
|
|
446
|
+
promptName = ( localize(6535, "{0} (hidden)", promptName));
|
|
447
|
+
tooltip = ( localize(6536, "Hidden from chat view agent picker"));
|
|
434
448
|
} else if (visibility === true) {
|
|
435
449
|
buttons = (buttons ?? []).concat(MAKE_INVISIBLE_BUTTON);
|
|
436
450
|
}
|
|
@@ -506,10 +520,10 @@ let PromptFilePickers = class PromptFilePickers {
|
|
|
506
520
|
const isSkill = options.type === PromptsType.skill;
|
|
507
521
|
const filename = isSkill ? basename(dirname(value)) : item.label;
|
|
508
522
|
const message = isSkill ? ( localize(
|
|
509
|
-
|
|
523
|
+
6537,
|
|
510
524
|
"Are you sure you want to delete skill '{0}' and its folder?",
|
|
511
525
|
filename
|
|
512
|
-
)) : ( localize(
|
|
526
|
+
)) : ( localize(6538, "Are you sure you want to delete '{0}'?", filename));
|
|
513
527
|
const {
|
|
514
528
|
confirmed
|
|
515
529
|
} = await this._dialogService.confirm({
|
package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { DocumentPasteContext, DocumentPasteEditProvider, DocumentPasteEditsSess
|
|
|
7
7
|
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
8
8
|
import { ILanguageFeaturesService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service";
|
|
9
9
|
import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service";
|
|
10
|
+
import { IOutlineModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/contrib/documentSymbols/browser/outlineModel.service";
|
|
10
11
|
import { IEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service";
|
|
11
12
|
import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
|
|
12
13
|
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
@@ -29,10 +30,15 @@ export declare class PasteImageProvider implements DocumentPasteEditProvider {
|
|
|
29
30
|
}
|
|
30
31
|
export declare function isImage(array: Uint8Array): boolean;
|
|
31
32
|
export declare class CopyTextProvider implements DocumentPasteEditProvider {
|
|
33
|
+
private readonly modelService;
|
|
34
|
+
private readonly languageFeaturesService;
|
|
35
|
+
private readonly outlineModelService;
|
|
32
36
|
readonly providedPasteEditKinds: never[];
|
|
33
37
|
readonly copyMimeTypes: string[];
|
|
34
38
|
readonly pasteMimeTypes: never[];
|
|
39
|
+
constructor(modelService: IModelService, languageFeaturesService: ILanguageFeaturesService, outlineModelService: IOutlineModelService);
|
|
35
40
|
prepareDocumentPaste(model: ITextModel, ranges: readonly IRange[], dataTransfer: IReadonlyVSDataTransfer, token: CancellationToken): Promise<undefined | IReadonlyVSDataTransfer>;
|
|
41
|
+
private primeSymbolReferenceCache;
|
|
36
42
|
}
|
|
37
43
|
export declare class PasteTextProvider implements DocumentPasteEditProvider {
|
|
38
44
|
private readonly chatWidgetService;
|
package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
4
4
|
import { VSDataTransfer, createStringDataTransferItem } from '@codingame/monaco-vscode-api/vscode/vs/base/common/dataTransfer';
|
|
5
|
+
import { alert } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/aria/aria';
|
|
5
6
|
import { HierarchicalKind } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hierarchicalKind';
|
|
6
7
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
8
|
import { revive } from '@codingame/monaco-vscode-api/vscode/vs/base/common/marshalling';
|
|
@@ -9,8 +10,12 @@ import { Mimes } from '@codingame/monaco-vscode-api/vscode/vs/base/common/mime';
|
|
|
9
10
|
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
10
11
|
import { joinPath, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
11
12
|
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
13
|
+
import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
|
|
14
|
+
import { SymbolKinds } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
|
|
12
15
|
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures.service';
|
|
13
16
|
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
17
|
+
import { IOutlineModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/documentSymbols/browser/outlineModel.service';
|
|
18
|
+
import { getDefinitionsAtPosition } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/gotoSymbol/browser/goToSymbol';
|
|
14
19
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
15
20
|
import { IEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service';
|
|
16
21
|
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
@@ -18,6 +23,8 @@ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
18
23
|
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
19
24
|
import { isProposedApiEnabled } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions';
|
|
20
25
|
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
26
|
+
import { isImageVariableEntry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/attachments/chatVariableEntries';
|
|
27
|
+
import { chatVariableLeader } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/requestParser/chatParserTypes';
|
|
21
28
|
import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
22
29
|
import { getDynamicVariablesForWidget } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/attachments/chatVariables';
|
|
23
30
|
import { ChatDynamicVariableModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/attachments/chatDynamicVariables';
|
|
@@ -46,7 +53,7 @@ let PasteImageProvider = class PasteImageProvider {
|
|
|
46
53
|
cleanupOldImages(this.fileService, this.logService, this.imagesFolder);
|
|
47
54
|
}
|
|
48
55
|
async provideDocumentPasteEdits(model, ranges, dataTransfer, context, token) {
|
|
49
|
-
if (!( this.extensionService.extensions.some(ext => isProposedApiEnabled(ext
|
|
56
|
+
if (!( this.extensionService.extensions.some(ext => isProposedApiEnabled(ext)))) {
|
|
50
57
|
return;
|
|
51
58
|
}
|
|
52
59
|
const supportedMimeTypes = [
|
|
@@ -78,7 +85,7 @@ let PasteImageProvider = class PasteImageProvider {
|
|
|
78
85
|
return;
|
|
79
86
|
}
|
|
80
87
|
const attachedVariables = widget.attachmentModel.attachments;
|
|
81
|
-
const displayName = ( localize(
|
|
88
|
+
const displayName = ( localize(7036, "Pasted Image"));
|
|
82
89
|
let tempDisplayName = displayName;
|
|
83
90
|
for (let appendValue = 2; ( attachedVariables.some(attachment => attachment.name === tempDisplayName)); appendValue++)
|
|
84
91
|
{
|
|
@@ -100,7 +107,7 @@ let PasteImageProvider = class PasteImageProvider {
|
|
|
100
107
|
if (( currentContextIds.has(scaledImageContext.id))) {
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
|
-
const edit = createCustomPasteEdit(model, [scaledImageContext], mimeType, this.kind, ( localize(
|
|
110
|
+
const edit = createCustomPasteEdit(model, [scaledImageContext], mimeType, this.kind, ( localize(7037, "Pasted Image Attachment")), this.chatWidgetService);
|
|
104
111
|
return createEditSession(edit);
|
|
105
112
|
}
|
|
106
113
|
};
|
|
@@ -137,8 +144,11 @@ function isImage(array) {
|
|
|
137
144
|
};
|
|
138
145
|
return ( ( Object.values(identifier)).some(signature => signature.every((byte, index) => array[index] === byte)));
|
|
139
146
|
}
|
|
140
|
-
class CopyTextProvider {
|
|
141
|
-
constructor() {
|
|
147
|
+
let CopyTextProvider = class CopyTextProvider {
|
|
148
|
+
constructor(modelService, languageFeaturesService, outlineModelService) {
|
|
149
|
+
this.modelService = modelService;
|
|
150
|
+
this.languageFeaturesService = languageFeaturesService;
|
|
151
|
+
this.outlineModelService = outlineModelService;
|
|
142
152
|
this.providedPasteEditKinds = [];
|
|
143
153
|
this.copyMimeTypes = [COPY_MIME_TYPES];
|
|
144
154
|
this.pasteMimeTypes = [];
|
|
@@ -153,9 +163,32 @@ class CopyTextProvider {
|
|
|
153
163
|
uri: model.uri.toJSON()
|
|
154
164
|
};
|
|
155
165
|
customDataTransfer.append(COPY_MIME_TYPES, createStringDataTransferItem(JSON.stringify(data)));
|
|
166
|
+
const text = dataTransfer.get(Mimes.text);
|
|
167
|
+
if (text && ranges.length) {
|
|
168
|
+
void this.primeSymbolReferenceCache(model, ranges[0], text, token);
|
|
169
|
+
}
|
|
156
170
|
return customDataTransfer;
|
|
157
171
|
}
|
|
158
|
-
|
|
172
|
+
async primeSymbolReferenceCache(model, range, textItem, token) {
|
|
173
|
+
const copiedText = model.getValueInRange(range);
|
|
174
|
+
if (range.startLineNumber !== range.endLineNumber) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (token.isCancellationRequested || !identifierPattern.test(copiedText)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
cacheSymbolReference(model.uri, range, copiedText, resolveSymbolReference(
|
|
181
|
+
this.modelService,
|
|
182
|
+
this.languageFeaturesService,
|
|
183
|
+
this.outlineModelService,
|
|
184
|
+
model.uri,
|
|
185
|
+
range,
|
|
186
|
+
copiedText,
|
|
187
|
+
token
|
|
188
|
+
));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
CopyTextProvider = ( __decorate([( __param(0, IModelService)), ( __param(1, ILanguageFeaturesService)), ( __param(2, IOutlineModelService))], CopyTextProvider));
|
|
159
192
|
let CopyAttachmentsProvider = class CopyAttachmentsProvider {
|
|
160
193
|
static {
|
|
161
194
|
CopyAttachmentsProvider_1 = this;
|
|
@@ -218,7 +251,7 @@ let CopyAttachmentsProvider = class CopyAttachmentsProvider {
|
|
|
218
251
|
}
|
|
219
252
|
const edit = {
|
|
220
253
|
insertText: textdata,
|
|
221
|
-
title: ( localize(
|
|
254
|
+
title: ( localize(7038, "Insert Prompt & Attachments")),
|
|
222
255
|
kind: this.kind,
|
|
223
256
|
handledMimeType: CopyAttachmentsProvider_1.ATTACHMENT_MIME_TYPE,
|
|
224
257
|
additionalEdit: {
|
|
@@ -294,7 +327,7 @@ class PasteTextProvider {
|
|
|
294
327
|
if (( currentContextIds.has(copiedContext.id))) {
|
|
295
328
|
return;
|
|
296
329
|
}
|
|
297
|
-
const edit = createCustomPasteEdit(model, [copiedContext], Mimes.text, this.kind, ( localize(
|
|
330
|
+
const edit = createCustomPasteEdit(model, [copiedContext], Mimes.text, this.kind, ( localize(7039, "Pasted Code Attachment")), this.chatWidgetService);
|
|
298
331
|
edit.yieldTo = [{
|
|
299
332
|
kind: HierarchicalKind.Empty.append("text", "plain")
|
|
300
333
|
}];
|
|
@@ -306,7 +339,7 @@ function getCopiedContext(code, file, language, range) {
|
|
|
306
339
|
const start = range.startLineNumber;
|
|
307
340
|
const end = range.endLineNumber;
|
|
308
341
|
const resultText = `Copied Selection of Code: \n\n\n From the file: ${fileName} From lines ${start} to ${end} \n \`\`\`${code}\`\`\``;
|
|
309
|
-
const pastedLines = start === end ? ( localize(
|
|
342
|
+
const pastedLines = start === end ? ( localize(7040, "1 line")) : ( localize(7041, "{0} lines", end + 1 - start));
|
|
310
343
|
return {
|
|
311
344
|
kind: "paste",
|
|
312
345
|
value: resultText,
|
|
@@ -328,7 +361,8 @@ function getCopiedContext(code, file, language, range) {
|
|
|
328
361
|
};
|
|
329
362
|
}
|
|
330
363
|
function createCustomPasteEdit(model, context, handledMimeType, kind, title, chatWidgetService) {
|
|
331
|
-
const label = context.length === 1 ? context[0].name : ( localize(
|
|
364
|
+
const label = context.length === 1 ? context[0].name : ( localize(7042, "{0} and {1} more", context[0].name, context.length - 1));
|
|
365
|
+
const announceImageAttachment = context.length === 1 && isImageVariableEntry(context[0]);
|
|
332
366
|
const customEdit = {
|
|
333
367
|
resource: model.uri,
|
|
334
368
|
variable: context,
|
|
@@ -345,6 +379,9 @@ function createCustomPasteEdit(model, context, handledMimeType, kind, title, cha
|
|
|
345
379
|
throw ( new Error("No widget found for redo"));
|
|
346
380
|
}
|
|
347
381
|
widget.attachmentModel.addContext(...context);
|
|
382
|
+
if (announceImageAttachment) {
|
|
383
|
+
alert(( localize(7043, "Attached image")));
|
|
384
|
+
}
|
|
348
385
|
},
|
|
349
386
|
metadata: {
|
|
350
387
|
needsConfirmation: false,
|
|
@@ -367,6 +404,187 @@ function createEditSession(edit) {
|
|
|
367
404
|
dispose: () => {}
|
|
368
405
|
};
|
|
369
406
|
}
|
|
407
|
+
const identifierPattern = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
408
|
+
const symbolCacheMaxSize = 3;
|
|
409
|
+
const symbolReferenceCache = [];
|
|
410
|
+
function getSymbolReferenceCacheKey(uri, range, text) {
|
|
411
|
+
return `${( uri.toString())}|${range.startLineNumber}:${range.startColumn}-${range.endLineNumber}:${range.endColumn}|${text}`;
|
|
412
|
+
}
|
|
413
|
+
async function getCachedSymbolReference(uri, range, text) {
|
|
414
|
+
const key = getSymbolReferenceCacheKey(uri, range, text);
|
|
415
|
+
return symbolReferenceCache.find(e => e.key === key)?.promise;
|
|
416
|
+
}
|
|
417
|
+
function cacheSymbolReference(uri, range, text, valuePromise) {
|
|
418
|
+
const entry = {
|
|
419
|
+
key: getSymbolReferenceCacheKey(uri, range, text),
|
|
420
|
+
promise: valuePromise
|
|
421
|
+
};
|
|
422
|
+
symbolReferenceCache.unshift(entry);
|
|
423
|
+
while (symbolReferenceCache.length > symbolCacheMaxSize) {
|
|
424
|
+
symbolReferenceCache.pop();
|
|
425
|
+
}
|
|
426
|
+
valuePromise.catch(() => {
|
|
427
|
+
const i = symbolReferenceCache.indexOf(entry);
|
|
428
|
+
if (i !== -1) {
|
|
429
|
+
symbolReferenceCache.splice(i, 1);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
async function resolveSymbolReference(
|
|
434
|
+
modelService,
|
|
435
|
+
languageFeaturesService,
|
|
436
|
+
outlineModelService,
|
|
437
|
+
sourceUri,
|
|
438
|
+
sourceRange,
|
|
439
|
+
pastedText,
|
|
440
|
+
token
|
|
441
|
+
) {
|
|
442
|
+
const sourceModel = modelService.getModel(sourceUri);
|
|
443
|
+
if (!sourceModel) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const sourcePosition = ( new Position(sourceRange.startLineNumber, sourceRange.startColumn));
|
|
447
|
+
const definitions = await getDefinitionsAtPosition(
|
|
448
|
+
languageFeaturesService.definitionProvider,
|
|
449
|
+
sourceModel,
|
|
450
|
+
sourcePosition,
|
|
451
|
+
false,
|
|
452
|
+
token
|
|
453
|
+
);
|
|
454
|
+
if (token.isCancellationRequested || !definitions.length) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const def = definitions[0];
|
|
458
|
+
const defRange = def.targetSelectionRange ?? def.range;
|
|
459
|
+
const defLocation = {
|
|
460
|
+
uri: def.uri,
|
|
461
|
+
range: defRange
|
|
462
|
+
};
|
|
463
|
+
let icon = Codicon.symbolProperty;
|
|
464
|
+
const defModel = modelService.getModel(def.uri);
|
|
465
|
+
if (defModel) {
|
|
466
|
+
try {
|
|
467
|
+
const outline = await outlineModelService.getOrCreate(defModel, token);
|
|
468
|
+
if (!token.isCancellationRequested) {
|
|
469
|
+
const element = outline.getItemEnclosingPosition({
|
|
470
|
+
lineNumber: defRange.startLineNumber,
|
|
471
|
+
column: defRange.startColumn
|
|
472
|
+
});
|
|
473
|
+
if (element) {
|
|
474
|
+
icon = SymbolKinds.toIcon(element.symbol.kind);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
} catch {}
|
|
478
|
+
}
|
|
479
|
+
if (token.isCancellationRequested) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
id: `vscode.symbol/${JSON.stringify(defLocation)}`,
|
|
484
|
+
fullName: pastedText,
|
|
485
|
+
data: defLocation,
|
|
486
|
+
icon
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
let PasteSymbolProvider = class PasteSymbolProvider {
|
|
490
|
+
constructor(
|
|
491
|
+
chatWidgetService,
|
|
492
|
+
modelService,
|
|
493
|
+
languageFeaturesService,
|
|
494
|
+
outlineModelService
|
|
495
|
+
) {
|
|
496
|
+
this.chatWidgetService = chatWidgetService;
|
|
497
|
+
this.modelService = modelService;
|
|
498
|
+
this.languageFeaturesService = languageFeaturesService;
|
|
499
|
+
this.outlineModelService = outlineModelService;
|
|
500
|
+
this.kind = ( new HierarchicalKind("chat.attach.symbol"));
|
|
501
|
+
this.providedPasteEditKinds = [this.kind];
|
|
502
|
+
this.copyMimeTypes = [];
|
|
503
|
+
this.pasteMimeTypes = [COPY_MIME_TYPES];
|
|
504
|
+
}
|
|
505
|
+
async provideDocumentPasteEdits(model, ranges, dataTransfer, _context, token) {
|
|
506
|
+
if (model.uri.scheme !== Schemas.vscodeChatInput) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
const text = dataTransfer.get(Mimes.text);
|
|
510
|
+
const additionalEditorData = dataTransfer.get(COPY_MIME_TYPES);
|
|
511
|
+
if (!text || !additionalEditorData) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const pastedText = await text.asString();
|
|
515
|
+
if (!identifierPattern.test(pastedText)) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
let additionalData;
|
|
519
|
+
try {
|
|
520
|
+
additionalData = JSON.parse(await additionalEditorData.asString());
|
|
521
|
+
} catch {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const sourceUri = URI.revive(additionalData.uri);
|
|
525
|
+
const sourceRange = additionalData.range;
|
|
526
|
+
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
527
|
+
if (!widget) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const cached = await getCachedSymbolReference(sourceUri, sourceRange, pastedText);
|
|
531
|
+
let resolved = cached;
|
|
532
|
+
if (!resolved) {
|
|
533
|
+
resolved = await resolveSymbolReference(
|
|
534
|
+
this.modelService,
|
|
535
|
+
this.languageFeaturesService,
|
|
536
|
+
this.outlineModelService,
|
|
537
|
+
sourceUri,
|
|
538
|
+
sourceRange,
|
|
539
|
+
pastedText,
|
|
540
|
+
token
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
if (!resolved) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
if (token.isCancellationRequested) {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
const symText = `${chatVariableLeader}sym:${pastedText}`;
|
|
550
|
+
const pasteRange = ranges[0];
|
|
551
|
+
const insertText = `${symText} `;
|
|
552
|
+
const refRange = {
|
|
553
|
+
startLineNumber: pasteRange.startLineNumber,
|
|
554
|
+
startColumn: pasteRange.startColumn,
|
|
555
|
+
endLineNumber: pasteRange.startLineNumber,
|
|
556
|
+
endColumn: pasteRange.startColumn + symText.length
|
|
557
|
+
};
|
|
558
|
+
const dynamicRef = {
|
|
559
|
+
id: resolved.id,
|
|
560
|
+
fullName: resolved.fullName,
|
|
561
|
+
range: refRange,
|
|
562
|
+
data: resolved.data,
|
|
563
|
+
icon: resolved.icon
|
|
564
|
+
};
|
|
565
|
+
const edit = {
|
|
566
|
+
insertText,
|
|
567
|
+
title: ( localize(7044, "Pasted Symbol Reference")),
|
|
568
|
+
kind: this.kind,
|
|
569
|
+
handledMimeType: COPY_MIME_TYPES,
|
|
570
|
+
additionalEdit: {
|
|
571
|
+
edits: [{
|
|
572
|
+
resource: model.uri,
|
|
573
|
+
redo: () => {
|
|
574
|
+
const w = this.chatWidgetService.getWidgetByInputUri(model.uri);
|
|
575
|
+
w?.getContrib(ChatDynamicVariableModel.ID)?.addReference(dynamicRef);
|
|
576
|
+
},
|
|
577
|
+
undo: () => {}
|
|
578
|
+
}]
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
edit.yieldTo = [{
|
|
582
|
+
kind: ( new HierarchicalKind("chat.attach.text"))
|
|
583
|
+
}];
|
|
584
|
+
return createEditSession(edit);
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
PasteSymbolProvider = ( __decorate([( __param(0, IChatWidgetService)), ( __param(1, IModelService)), ( __param(2, ILanguageFeaturesService)), ( __param(3, IOutlineModelService))], PasteSymbolProvider));
|
|
370
588
|
let ChatPasteProvidersFeature = class ChatPasteProvidersFeature extends Disposable {
|
|
371
589
|
constructor(
|
|
372
590
|
instaService,
|
|
@@ -400,11 +618,13 @@ let ChatPasteProvidersFeature = class ChatPasteProvidersFeature extends Disposab
|
|
|
400
618
|
pattern: "*",
|
|
401
619
|
hasAccessToAllModels: true
|
|
402
620
|
}, ( new PasteTextProvider(chatWidgetService, modelService))));
|
|
621
|
+
this._register(languageFeaturesService.documentPasteEditProvider.register({
|
|
622
|
+
scheme: Schemas.vscodeChatInput,
|
|
623
|
+
pattern: "*",
|
|
624
|
+
hasAccessToAllModels: true
|
|
625
|
+
}, instaService.createInstance(PasteSymbolProvider)));
|
|
403
626
|
this._register(
|
|
404
|
-
languageFeaturesService.documentPasteEditProvider.register("*", (
|
|
405
|
-
);
|
|
406
|
-
this._register(
|
|
407
|
-
languageFeaturesService.documentPasteEditProvider.register("*", ( new CopyTextProvider()))
|
|
627
|
+
languageFeaturesService.documentPasteEditProvider.register("*", instaService.createInstance(CopyTextProvider))
|
|
408
628
|
);
|
|
409
629
|
}
|
|
410
630
|
};
|