@codingame/monaco-vscode-xterm-addons-common 34.1.3 → 35.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/package.json +10 -10
- package/vscode/src/vs/base/browser/htmlToMarkdown.js +126 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +29 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/copilotCliEventsUri.d.ts +82 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/copilotCliEventsUri.js +114 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +9 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +26 -26
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +32 -32
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js +10 -10
- 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 -1
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +11 -10
- package/vscode/src/vs/base/common/htmlToMarkdown.js +0 -151
- /package/vscode/src/vs/base/{common → browser}/htmlToMarkdown.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-xterm-addons-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "35.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - common package depending on xterm addons",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
19
|
-
"@xterm/addon-clipboard": "0.3.0-beta.
|
|
20
|
-
"@xterm/addon-image": "0.10.0-beta.
|
|
21
|
-
"@xterm/addon-ligatures": "0.11.0-beta.
|
|
22
|
-
"@xterm/addon-progress": "0.3.0-beta.
|
|
23
|
-
"@xterm/addon-search": "0.17.0-beta.
|
|
24
|
-
"@xterm/addon-serialize": "0.15.0-beta.
|
|
25
|
-
"@xterm/addon-unicode11": "0.10.0-beta.
|
|
26
|
-
"@xterm/addon-webgl": "0.20.0-beta.
|
|
18
|
+
"@codingame/monaco-vscode-api": "35.0.0",
|
|
19
|
+
"@xterm/addon-clipboard": "0.3.0-beta.288",
|
|
20
|
+
"@xterm/addon-image": "0.10.0-beta.288",
|
|
21
|
+
"@xterm/addon-ligatures": "0.11.0-beta.288",
|
|
22
|
+
"@xterm/addon-progress": "0.3.0-beta.288",
|
|
23
|
+
"@xterm/addon-search": "0.17.0-beta.288",
|
|
24
|
+
"@xterm/addon-serialize": "0.15.0-beta.288",
|
|
25
|
+
"@xterm/addon-unicode11": "0.10.0-beta.288",
|
|
26
|
+
"@xterm/addon-webgl": "0.20.0-beta.287"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
|
|
2
|
+
import { createTrustedTypesPolicy } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/trustedTypes';
|
|
3
|
+
|
|
4
|
+
const maxInputLength = 200_000;
|
|
5
|
+
const ttPolicy = createTrustedTypesPolicy("htmlToMarkdown", {
|
|
6
|
+
createHTML: value => value
|
|
7
|
+
});
|
|
8
|
+
function convertHtmlToMarkdown(html) {
|
|
9
|
+
if (html.length > maxInputLength) {
|
|
10
|
+
return html.replace(/<[^>]+>/g, "");
|
|
11
|
+
}
|
|
12
|
+
const trustedHtml = ttPolicy?.createHTML(html) ?? html;
|
|
13
|
+
const doc = ( new DOMParser()).parseFromString(trustedHtml, "text/html");
|
|
14
|
+
let result = convertChildren(doc.body);
|
|
15
|
+
result = result.replace(/\u00A0/g, " ");
|
|
16
|
+
result = result.replace(/\n{3,}/g, "\n\n");
|
|
17
|
+
return result.trim();
|
|
18
|
+
}
|
|
19
|
+
function convertNode(node) {
|
|
20
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
21
|
+
return node.textContent ?? "";
|
|
22
|
+
}
|
|
23
|
+
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
const el = node;
|
|
27
|
+
const tag = el.tagName.toLowerCase();
|
|
28
|
+
switch (tag) {
|
|
29
|
+
case "h1":
|
|
30
|
+
return `\n# ${convertChildren(el).trim()}\n`;
|
|
31
|
+
case "h2":
|
|
32
|
+
return `\n## ${convertChildren(el).trim()}\n`;
|
|
33
|
+
case "h3":
|
|
34
|
+
return `\n### ${convertChildren(el).trim()}\n`;
|
|
35
|
+
case "h4":
|
|
36
|
+
return `\n#### ${convertChildren(el).trim()}\n`;
|
|
37
|
+
case "h5":
|
|
38
|
+
return `\n##### ${convertChildren(el).trim()}\n`;
|
|
39
|
+
case "h6":
|
|
40
|
+
return `\n###### ${convertChildren(el).trim()}\n`;
|
|
41
|
+
case "pre":
|
|
42
|
+
{
|
|
43
|
+
const codeEl = el.querySelector("code");
|
|
44
|
+
const text = (codeEl ?? el).textContent ?? "";
|
|
45
|
+
return `\n\`\`\`\n${text.replace(/^\n+|\n+$/g, "")}\n\`\`\`\n`;
|
|
46
|
+
}
|
|
47
|
+
case "code":
|
|
48
|
+
return `\`${el.textContent ?? ""}\``;
|
|
49
|
+
case "blockquote":
|
|
50
|
+
{
|
|
51
|
+
const inner = convertChildren(el).trim();
|
|
52
|
+
const lines = ( inner.split("\n").map(l => `> ${l.trim()}`));
|
|
53
|
+
return `\n${lines.join("\n")}\n`;
|
|
54
|
+
}
|
|
55
|
+
case "ol":
|
|
56
|
+
{
|
|
57
|
+
let index = 0;
|
|
58
|
+
let result = "\n";
|
|
59
|
+
for (const child of el.children) {
|
|
60
|
+
if (child.tagName.toLowerCase() === "li") {
|
|
61
|
+
index++;
|
|
62
|
+
result += `${index}. ${convertChildren(child).trim()}\n`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
case "ul":
|
|
68
|
+
{
|
|
69
|
+
let result = "\n";
|
|
70
|
+
for (const child of el.children) {
|
|
71
|
+
if (child.tagName.toLowerCase() === "li") {
|
|
72
|
+
result += `- ${convertChildren(child).trim()}\n`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
case "li":
|
|
78
|
+
return `- ${convertChildren(el).trim()}\n`;
|
|
79
|
+
case "p":
|
|
80
|
+
return `${convertChildren(el)}\n\n`;
|
|
81
|
+
case "div":
|
|
82
|
+
return `${convertChildren(el)}\n`;
|
|
83
|
+
case "br":
|
|
84
|
+
return "\n";
|
|
85
|
+
case "hr":
|
|
86
|
+
return "\n---\n";
|
|
87
|
+
case "a":
|
|
88
|
+
{
|
|
89
|
+
const href = el.getAttribute("href") ?? "";
|
|
90
|
+
return sanitizeLink(href, convertChildren(el).trim());
|
|
91
|
+
}
|
|
92
|
+
case "img":
|
|
93
|
+
{
|
|
94
|
+
const src = el.getAttribute("src") ?? "";
|
|
95
|
+
const alt = el.getAttribute("alt") ?? "";
|
|
96
|
+
return ``;
|
|
97
|
+
}
|
|
98
|
+
case "strong":
|
|
99
|
+
case "b":
|
|
100
|
+
return `**${convertChildren(el)}**`;
|
|
101
|
+
case "em":
|
|
102
|
+
case "i":
|
|
103
|
+
return `*${convertChildren(el)}*`;
|
|
104
|
+
case "del":
|
|
105
|
+
case "s":
|
|
106
|
+
case "strike":
|
|
107
|
+
return `~~${convertChildren(el)}~~`;
|
|
108
|
+
default:
|
|
109
|
+
return convertChildren(el);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function convertChildren(node) {
|
|
113
|
+
let result = "";
|
|
114
|
+
for (const child of node.childNodes) {
|
|
115
|
+
result += convertNode(child);
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
function sanitizeLink(href, text) {
|
|
120
|
+
if (/^(javascript|vbscript|data):/i.test(href.trim())) {
|
|
121
|
+
return text;
|
|
122
|
+
}
|
|
123
|
+
return `[${text}](${href})`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { convertHtmlToMarkdown };
|
|
@@ -5,6 +5,8 @@ import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/c
|
|
|
5
5
|
import { Disposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
6
|
import { isElectron } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
7
7
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
8
|
+
import { agentHostAuthority } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostUri';
|
|
9
|
+
import { IRemoteAgentHostService } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/remoteAgentHostService.service';
|
|
8
10
|
import { IClipboardService } from '@codingame/monaco-vscode-api/vscode/vs/platform/clipboard/common/clipboardService.service';
|
|
9
11
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
10
12
|
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
@@ -12,6 +14,7 @@ import { EditorResourceAccessor, SideBySideEditor } from '@codingame/monaco-vsco
|
|
|
12
14
|
import { DiffEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/diffEditorInput';
|
|
13
15
|
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
14
16
|
import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
|
|
17
|
+
import { IPathService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/path/common/pathService.service';
|
|
15
18
|
import { UntitledTextEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/untitled/common/untitledTextEditorInput';
|
|
16
19
|
import { FileEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/files/browser/editors/fileEditorInput';
|
|
17
20
|
import { NotebookEditorInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
|
|
@@ -28,6 +31,7 @@ import { AgentSessionProviders, getAgentSessionProviderIcon } from '@codingame/m
|
|
|
28
31
|
import { ITerminalService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
|
|
29
32
|
import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
|
|
30
33
|
import { getChatSessionType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatUri';
|
|
34
|
+
import { buildHostLocalEventsPath } from '../copilotCliEventsUri.js';
|
|
31
35
|
import { imageToHash } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatImageUtils';
|
|
32
36
|
|
|
33
37
|
function shouldShowOpenEditorsContext(widget, hasEligibleOpenEditors) {
|
|
@@ -73,7 +77,7 @@ ChatContextContributions = ( __decorate([( __param(0, IInstantiationService)), (
|
|
|
73
77
|
class ToolsContextPickerPick {
|
|
74
78
|
constructor() {
|
|
75
79
|
this.type = "pickerPick";
|
|
76
|
-
this.label = ( localize(
|
|
80
|
+
this.label = ( localize(5208, "Tools..."));
|
|
77
81
|
this.icon = Codicon.tools;
|
|
78
82
|
this.ordinal = -500;
|
|
79
83
|
}
|
|
@@ -124,7 +128,7 @@ class ToolsContextPickerPick {
|
|
|
124
128
|
picks.push(item);
|
|
125
129
|
}
|
|
126
130
|
return {
|
|
127
|
-
placeholder: ( localize(
|
|
131
|
+
placeholder: ( localize(5209, "Select a tool")),
|
|
128
132
|
picks: Promise.resolve(picks)
|
|
129
133
|
};
|
|
130
134
|
}
|
|
@@ -134,7 +138,7 @@ let OpenEditorContextValuePick = class OpenEditorContextValuePick {
|
|
|
134
138
|
this._editorService = _editorService;
|
|
135
139
|
this._labelService = _labelService;
|
|
136
140
|
this.type = "valuePick";
|
|
137
|
-
this.label = ( localize(
|
|
141
|
+
this.label = ( localize(5210, "Open Editors"));
|
|
138
142
|
this.icon = Codicon.file;
|
|
139
143
|
this.ordinal = 800;
|
|
140
144
|
}
|
|
@@ -171,7 +175,7 @@ let ClipboardImageContextValuePick = class ClipboardImageContextValuePick {
|
|
|
171
175
|
constructor(_clipboardService) {
|
|
172
176
|
this._clipboardService = _clipboardService;
|
|
173
177
|
this.type = "valuePick";
|
|
174
|
-
this.label = ( localize(
|
|
178
|
+
this.label = ( localize(5211, "Image from Clipboard"));
|
|
175
179
|
this.icon = Codicon.fileMedia;
|
|
176
180
|
}
|
|
177
181
|
async isEnabled(widget) {
|
|
@@ -188,8 +192,8 @@ let ClipboardImageContextValuePick = class ClipboardImageContextValuePick {
|
|
|
188
192
|
const fileBuffer = await this._clipboardService.readImage();
|
|
189
193
|
return {
|
|
190
194
|
id: await imageToHash(fileBuffer),
|
|
191
|
-
name: ( localize(
|
|
192
|
-
fullName: ( localize(
|
|
195
|
+
name: ( localize(5212, "Pasted Image")),
|
|
196
|
+
fullName: ( localize(5212, "Pasted Image")),
|
|
193
197
|
value: fileBuffer,
|
|
194
198
|
kind: "image"
|
|
195
199
|
};
|
|
@@ -202,7 +206,7 @@ let TerminalContext = class TerminalContext {
|
|
|
202
206
|
this._terminalService = _terminalService;
|
|
203
207
|
this.type = "valuePick";
|
|
204
208
|
this.icon = Codicon.terminal;
|
|
205
|
-
this.label = ( localize(
|
|
209
|
+
this.label = ( localize(5213, "Terminal"));
|
|
206
210
|
}
|
|
207
211
|
isEnabled(widget) {
|
|
208
212
|
const terminal = this._terminalService.getInstanceFromResource(this._resource);
|
|
@@ -267,7 +271,7 @@ let ScreenshotContextValuePick = class ScreenshotContextValuePick {
|
|
|
267
271
|
this._hostService = _hostService;
|
|
268
272
|
this.type = "valuePick";
|
|
269
273
|
this.icon = Codicon.deviceCamera;
|
|
270
|
-
this.label = (isElectron ? ( localize(
|
|
274
|
+
this.label = (isElectron ? ( localize(5214, "Screenshot Window")) : ( localize(5215, "Screenshot")));
|
|
271
275
|
}
|
|
272
276
|
async isEnabled(widget) {
|
|
273
277
|
return !!widget.attachmentCapabilities.supportsImageAttachments && !!widget.input.selectedLanguageModel.get()?.metadata.capabilities?.vision;
|
|
@@ -279,11 +283,13 @@ let ScreenshotContextValuePick = class ScreenshotContextValuePick {
|
|
|
279
283
|
};
|
|
280
284
|
ScreenshotContextValuePick = ( __decorate([( __param(0, IHostService))], ScreenshotContextValuePick));
|
|
281
285
|
let SessionReferenceContextPickerPick = class SessionReferenceContextPickerPick {
|
|
282
|
-
constructor(_chatSessionsService) {
|
|
286
|
+
constructor(_chatSessionsService, _pathService, _remoteAgentHostService) {
|
|
283
287
|
this._chatSessionsService = _chatSessionsService;
|
|
288
|
+
this._pathService = _pathService;
|
|
289
|
+
this._remoteAgentHostService = _remoteAgentHostService;
|
|
284
290
|
this.type = "pickerPick";
|
|
285
291
|
this.icon = Codicon.comment;
|
|
286
|
-
this.label = ( localize(
|
|
292
|
+
this.label = ( localize(5216, "Sessions..."));
|
|
287
293
|
this.ordinal = -400;
|
|
288
294
|
}
|
|
289
295
|
isEnabled(widget) {
|
|
@@ -291,14 +297,16 @@ let SessionReferenceContextPickerPick = class SessionReferenceContextPickerPick
|
|
|
291
297
|
}
|
|
292
298
|
asPicker(widget) {
|
|
293
299
|
const currentSessionResource = widget.viewModel?.sessionResource;
|
|
300
|
+
const onlyShowAttachableCopilotCliSessions = !!currentSessionResource && isAgentHostTarget(getChatSessionType(currentSessionResource));
|
|
294
301
|
return {
|
|
295
|
-
placeholder: ( localize(
|
|
302
|
+
placeholder: ( localize(5217, "Select a session")),
|
|
296
303
|
picks: (async () => {
|
|
297
304
|
const picks = [];
|
|
298
305
|
const sessionProviderFilter = [
|
|
299
306
|
AgentSessionProviders.Local,
|
|
300
307
|
AgentSessionProviders.Background,
|
|
301
|
-
AgentSessionProviders.Claude
|
|
308
|
+
AgentSessionProviders.Claude,
|
|
309
|
+
AgentSessionProviders.AgentHostCopilot
|
|
302
310
|
];
|
|
303
311
|
for await (const group of this._chatSessionsService.getChatSessionItems(sessionProviderFilter, CancellationToken.None)) {
|
|
304
312
|
const providerIcon = getAgentSessionProviderIcon(group.chatSessionType);
|
|
@@ -307,6 +315,9 @@ let SessionReferenceContextPickerPick = class SessionReferenceContextPickerPick
|
|
|
307
315
|
continue;
|
|
308
316
|
}
|
|
309
317
|
const sessionResource = item.resource;
|
|
318
|
+
if (onlyShowAttachableCopilotCliSessions && !this._canAttachCopilotCliSession(sessionResource)) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
310
321
|
const icon = item.iconPath ?? providerIcon;
|
|
311
322
|
picks.push({
|
|
312
323
|
label: item.label,
|
|
@@ -326,7 +337,12 @@ let SessionReferenceContextPickerPick = class SessionReferenceContextPickerPick
|
|
|
326
337
|
})()
|
|
327
338
|
};
|
|
328
339
|
}
|
|
340
|
+
_canAttachCopilotCliSession(sessionResource) {
|
|
341
|
+
return !!buildHostLocalEventsPath(sessionResource, this._pathService.userHome({
|
|
342
|
+
preferLocal: true
|
|
343
|
+
}), authority => this._remoteAgentHostService.connections.find(connection => agentHostAuthority(connection.address) === authority));
|
|
344
|
+
}
|
|
329
345
|
};
|
|
330
|
-
SessionReferenceContextPickerPick = ( __decorate([( __param(0, IChatSessionsService))], SessionReferenceContextPickerPick));
|
|
346
|
+
SessionReferenceContextPickerPick = ( __decorate([( __param(0, IChatSessionsService)), ( __param(1, IPathService)), ( __param(2, IRemoteAgentHostService))], SessionReferenceContextPickerPick));
|
|
331
347
|
|
|
332
348
|
export { ChatContextContributions, TerminalContext, shouldShowOpenEditorsContext };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
2
|
+
import { IRemoteAgentHostConnectionInfo } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/remoteAgentHostService";
|
|
3
|
+
export declare const COPILOT_CLI_LOCAL_AH_SCHEME = "agent-host-copilotcli";
|
|
4
|
+
export declare const COPILOT_CLI_EH_SCHEME = "copilotcli";
|
|
5
|
+
/**
|
|
6
|
+
* Builds the local `events.jsonl` URI under `~/.copilot/session-state/<rawId>/`.
|
|
7
|
+
*
|
|
8
|
+
* Used for both the local Agent Host Copilot CLI provider and the
|
|
9
|
+
* extension-host Copilot CLI provider, which share the same on-disk layout
|
|
10
|
+
* and the same chat session URI shape (`copilotcli:/<rawId>`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildLocalEventsUri(userHome: URI, rawSessionId: string): URI;
|
|
13
|
+
/**
|
|
14
|
+
* Builds the local `~/.copilot/logs` directory URI.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildLocalCopilotLogsUri(userHome: URI): URI;
|
|
17
|
+
/**
|
|
18
|
+
* Builds a `vscode-agent-host://` URI for the `events.jsonl` file inside
|
|
19
|
+
* the host's user home directory, using the connection's reported
|
|
20
|
+
* `defaultDirectory` (set from `os.homedir()` on the host during the
|
|
21
|
+
* AHP handshake).
|
|
22
|
+
*
|
|
23
|
+
* The path is joined at the URI-path level using forward slashes, which
|
|
24
|
+
* works for both POSIX hosts (`/home/me`) and Windows hosts whose
|
|
25
|
+
* `URI.file(os.homedir()).path` is also forward-slash-rooted (e.g.
|
|
26
|
+
* `/c:/Users/me`). Returns `undefined` if the host did not report a
|
|
27
|
+
* usable `defaultDirectory`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildRemoteEventsUri(connection: IRemoteAgentHostConnectionInfo, rawSessionId: string): URI | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Builds a `vscode-agent-host://` URI for the host's `~/.copilot/logs`
|
|
32
|
+
* directory, using the connection's reported home directory.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildRemoteCopilotLogsUri(connection: IRemoteAgentHostConnectionInfo): URI | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Parses the connection authority out of a remote AH chat session scheme
|
|
37
|
+
* of the form `remote-<authority>-copilotcli`. Returns `undefined` for
|
|
38
|
+
* any other scheme, including the local `copilotcli` scheme.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseRemoteAuthorityFromScheme(scheme: string): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Extracts the raw Copilot CLI session id from a chat session resource.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getCopilotCliSessionRawId(sessionResource: URI | undefined): string | undefined;
|
|
45
|
+
export type ResolveEventsUriResult = {
|
|
46
|
+
readonly kind: "ok";
|
|
47
|
+
readonly resource: URI;
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: "no-session";
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "unsupported-scheme";
|
|
52
|
+
readonly scheme: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: "remote-not-connected";
|
|
55
|
+
readonly authority: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: "remote-no-home";
|
|
58
|
+
readonly authority: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Pure resolver for tests. Translates a chat session resource into the
|
|
62
|
+
* `events.jsonl` URI for the corresponding Copilot CLI session, or
|
|
63
|
+
* returns a structured error.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveEventsUri(sessionResource: URI | undefined, userHome: URI, getConnectionByAuthority: (authority: string) => IRemoteAgentHostConnectionInfo | undefined): ResolveEventsUriResult;
|
|
66
|
+
/**
|
|
67
|
+
* Resolves the host-local filesystem path string of a Copilot CLI session's
|
|
68
|
+
* `events.jsonl`, suitable for tooling that runs **on the host** (e.g. the
|
|
69
|
+
* agent's terminal), as opposed to a workbench {@link URI} consumed by the
|
|
70
|
+
* file service.
|
|
71
|
+
*
|
|
72
|
+
* Reuses {@link resolveEventsUri} so it stays in lockstep with the resolution
|
|
73
|
+
* used by the chat debug panel and the "Open Copilot CLI State File" command,
|
|
74
|
+
* then unwraps the result into a plain path:
|
|
75
|
+
* - a local `file://` URI becomes its `fsPath` (same machine as the host).
|
|
76
|
+
* - a remote `vscode-agent-host://` URI is unwrapped to the underlying file
|
|
77
|
+
* URI whose `path` is the real path on the remote host the agent runs on.
|
|
78
|
+
*
|
|
79
|
+
* Returns `undefined` when the session is not a Copilot CLI session or the
|
|
80
|
+
* path cannot be resolved (e.g. a remote host that reported no home directory).
|
|
81
|
+
*/
|
|
82
|
+
export declare function buildHostLocalEventsPath(sessionResource: URI | undefined, userHome: URI, getConnectionByAuthority: (authority: string) => IRemoteAgentHostConnectionInfo | undefined): string | undefined;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
3
|
+
import { joinPath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
4
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
5
|
+
import { parseRemoteAgentHostSessionTypeAuthority } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostSessionType';
|
|
6
|
+
import { agentHostAuthority, toAgentHostUri, fromAgentHostUri } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/agentHostUri';
|
|
7
|
+
|
|
8
|
+
const COPILOT_CLI_PROVIDER = "copilotcli";
|
|
9
|
+
const COPILOT_CLI_LOCAL_AH_SCHEME = `agent-host-${COPILOT_CLI_PROVIDER}`;
|
|
10
|
+
const COPILOT_CLI_EH_SCHEME = COPILOT_CLI_PROVIDER;
|
|
11
|
+
function buildLocalEventsUri(userHome, rawSessionId) {
|
|
12
|
+
return joinPath(userHome, ".copilot", "session-state", rawSessionId, "events.jsonl");
|
|
13
|
+
}
|
|
14
|
+
function buildLocalCopilotLogsUri(userHome) {
|
|
15
|
+
return joinPath(userHome, ".copilot", "logs");
|
|
16
|
+
}
|
|
17
|
+
function buildRemoteEventsUri(connection, rawSessionId) {
|
|
18
|
+
const homePath = connection.defaultDirectory;
|
|
19
|
+
if (!homePath) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const trimmed = homePath.endsWith("/") ? homePath.slice(0, -1) : homePath;
|
|
23
|
+
const remoteFileUri = ( URI.from({
|
|
24
|
+
scheme: "file",
|
|
25
|
+
path: `${trimmed}/.copilot/session-state/${rawSessionId}/events.jsonl`
|
|
26
|
+
}));
|
|
27
|
+
const authority = agentHostAuthority(connection.address);
|
|
28
|
+
return toAgentHostUri(remoteFileUri, authority);
|
|
29
|
+
}
|
|
30
|
+
function buildRemoteCopilotLogsUri(connection) {
|
|
31
|
+
const homePath = connection.defaultDirectory;
|
|
32
|
+
if (!homePath) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const trimmed = homePath.endsWith("/") ? homePath.slice(0, -1) : homePath;
|
|
36
|
+
const remoteFileUri = ( URI.from({
|
|
37
|
+
scheme: "file",
|
|
38
|
+
path: `${trimmed}/.copilot/logs`
|
|
39
|
+
}));
|
|
40
|
+
const authority = agentHostAuthority(connection.address);
|
|
41
|
+
return toAgentHostUri(remoteFileUri, authority);
|
|
42
|
+
}
|
|
43
|
+
function parseRemoteAuthorityFromScheme(scheme) {
|
|
44
|
+
return parseRemoteAgentHostSessionTypeAuthority(scheme, COPILOT_CLI_PROVIDER);
|
|
45
|
+
}
|
|
46
|
+
function getCopilotCliSessionRawId(sessionResource) {
|
|
47
|
+
if (!sessionResource) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (sessionResource.scheme !== COPILOT_CLI_LOCAL_AH_SCHEME && sessionResource.scheme !== COPILOT_CLI_EH_SCHEME && !parseRemoteAuthorityFromScheme(sessionResource.scheme)) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return getRawSessionId(sessionResource);
|
|
54
|
+
}
|
|
55
|
+
function resolveEventsUri(sessionResource, userHome, getConnectionByAuthority) {
|
|
56
|
+
if (!sessionResource) {
|
|
57
|
+
return {
|
|
58
|
+
kind: "no-session"
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const rawId = getRawSessionId(sessionResource);
|
|
62
|
+
if (!rawId) {
|
|
63
|
+
return {
|
|
64
|
+
kind: "no-session"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (sessionResource.scheme === COPILOT_CLI_LOCAL_AH_SCHEME || sessionResource.scheme === COPILOT_CLI_EH_SCHEME) {
|
|
68
|
+
return {
|
|
69
|
+
kind: "ok",
|
|
70
|
+
resource: buildLocalEventsUri(userHome, rawId)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const remoteAuthority = parseRemoteAuthorityFromScheme(sessionResource.scheme);
|
|
74
|
+
if (remoteAuthority) {
|
|
75
|
+
const connection = getConnectionByAuthority(remoteAuthority);
|
|
76
|
+
if (!connection) {
|
|
77
|
+
return {
|
|
78
|
+
kind: "remote-not-connected",
|
|
79
|
+
authority: remoteAuthority
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const resource = buildRemoteEventsUri(connection, rawId);
|
|
83
|
+
if (!resource) {
|
|
84
|
+
return {
|
|
85
|
+
kind: "remote-no-home",
|
|
86
|
+
authority: remoteAuthority
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
kind: "ok",
|
|
91
|
+
resource
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
kind: "unsupported-scheme",
|
|
96
|
+
scheme: sessionResource.scheme
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function getRawSessionId(sessionResource) {
|
|
100
|
+
const rawId = sessionResource.path.startsWith("/") ? sessionResource.path.substring(1) : sessionResource.path;
|
|
101
|
+
return rawId || undefined;
|
|
102
|
+
}
|
|
103
|
+
function buildHostLocalEventsPath(sessionResource, userHome, getConnectionByAuthority) {
|
|
104
|
+
const result = resolveEventsUri(sessionResource, userHome, getConnectionByAuthority);
|
|
105
|
+
if (result.kind !== "ok") {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
if (result.resource.scheme === Schemas.file) {
|
|
109
|
+
return result.resource.fsPath;
|
|
110
|
+
}
|
|
111
|
+
return fromAgentHostUri(result.resource).path.replace(/^\/([a-zA-Z]:)/, "$1");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { COPILOT_CLI_EH_SCHEME, COPILOT_CLI_LOCAL_AH_SCHEME, buildHostLocalEventsPath, buildLocalCopilotLogsUri, buildLocalEventsUri, buildRemoteCopilotLogsUri, buildRemoteEventsUri, getCopilotCliSessionRawId, parseRemoteAuthorityFromScheme, resolveEventsUri };
|
package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js
CHANGED
|
@@ -23,8 +23,8 @@ class ManageInstructionsFilesAction extends Action2 {
|
|
|
23
23
|
constructor() {
|
|
24
24
|
super({
|
|
25
25
|
id: CONFIGURE_INSTRUCTIONS_ACTION_ID,
|
|
26
|
-
title: ( localize2(
|
|
27
|
-
shortTitle: ( localize2(
|
|
26
|
+
title: ( localize2(7480, "Configure Instructions & Rules...")),
|
|
27
|
+
shortTitle: ( localize2(7481, "Instructions & Rules")),
|
|
28
28
|
icon: Codicon.bookmark,
|
|
29
29
|
f1: true,
|
|
30
30
|
precondition: ChatContextKeys.enabled,
|
|
@@ -41,7 +41,7 @@ class ManageInstructionsFilesAction extends Action2 {
|
|
|
41
41
|
const openerService = accessor.get(IOpenerService);
|
|
42
42
|
const instaService = accessor.get(IInstantiationService);
|
|
43
43
|
const pickers = instaService.createInstance(PromptFilePickers);
|
|
44
|
-
const placeholder = ( localize(
|
|
44
|
+
const placeholder = ( localize(7482, "Select the instructions file to open"));
|
|
45
45
|
const result = await pickers.selectPromptFile({
|
|
46
46
|
placeholder,
|
|
47
47
|
type: PromptsType.instructions,
|
|
@@ -59,7 +59,7 @@ let ChatInstructionsPickerPick = class ChatInstructionsPickerPick {
|
|
|
59
59
|
constructor(promptsService) {
|
|
60
60
|
this.promptsService = promptsService;
|
|
61
61
|
this.type = "pickerPick";
|
|
62
|
-
this.label = ( localize(
|
|
62
|
+
this.label = ( localize(7483, "Instructions..."));
|
|
63
63
|
this.icon = Codicon.bookmark;
|
|
64
64
|
this.commandId = ATTACH_INSTRUCTIONS_ACTION_ID;
|
|
65
65
|
}
|
|
@@ -89,10 +89,10 @@ let ChatInstructionsPickerPick = class ChatInstructionsPickerPick {
|
|
|
89
89
|
return result;
|
|
90
90
|
});
|
|
91
91
|
return {
|
|
92
|
-
placeholder: ( localize(
|
|
92
|
+
placeholder: ( localize(7484, "Select instructions files to attach")),
|
|
93
93
|
picks,
|
|
94
94
|
configure: {
|
|
95
|
-
label: ( localize(
|
|
95
|
+
label: ( localize(7485, "Configure Instructions...")),
|
|
96
96
|
commandId: CONFIGURE_INSTRUCTIONS_ACTION_ID
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -104,17 +104,17 @@ class AbstractNewPromptFileAction extends Action2 {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
notificationService.prompt(Severity.Info, ( localize(
|
|
107
|
-
|
|
107
|
+
7518,
|
|
108
108
|
"Do you want to backup and sync your user prompt, instruction and custom agent files with Setting Sync?'"
|
|
109
109
|
)), [{
|
|
110
|
-
label: ( localize(
|
|
110
|
+
label: ( localize(7519, "Enable")),
|
|
111
111
|
run: () => {
|
|
112
112
|
commandService.executeCommand(CONFIGURE_SYNC_COMMAND_ID).catch(error => {
|
|
113
113
|
logService.error(`Failed to run '${CONFIGURE_SYNC_COMMAND_ID}' command: ${error}.`);
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
}, {
|
|
117
|
-
label: ( localize(
|
|
117
|
+
label: ( localize(7520, "Learn More")),
|
|
118
118
|
run: () => {
|
|
119
119
|
openerService.open(( URI.parse("https://aka.ms/vscode-settings-sync-help")));
|
|
120
120
|
}
|
|
@@ -212,24 +212,24 @@ const NEW_AGENT_COMMAND_ID = "workbench.command.new.agent";
|
|
|
212
212
|
const NEW_SKILL_COMMAND_ID = "workbench.command.new.skill";
|
|
213
213
|
class NewPromptFileAction extends AbstractNewPromptFileAction {
|
|
214
214
|
constructor() {
|
|
215
|
-
super(NEW_PROMPT_COMMAND_ID, ( localize(
|
|
215
|
+
super(NEW_PROMPT_COMMAND_ID, ( localize(7521, "New Prompt File...")), PromptsType.prompt);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
class NewInstructionsFileAction extends AbstractNewPromptFileAction {
|
|
219
219
|
constructor() {
|
|
220
|
-
super(NEW_INSTRUCTIONS_COMMAND_ID, ( localize(
|
|
220
|
+
super(NEW_INSTRUCTIONS_COMMAND_ID, ( localize(7522, "New Instructions File...")), PromptsType.instructions);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
class NewAgentFileAction extends AbstractNewPromptFileAction {
|
|
224
224
|
constructor() {
|
|
225
|
-
super(NEW_AGENT_COMMAND_ID, ( localize(
|
|
225
|
+
super(NEW_AGENT_COMMAND_ID, ( localize(7523, "New Custom Agent...")), PromptsType.agent);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
class NewSkillFileAction extends Action2 {
|
|
229
229
|
constructor() {
|
|
230
230
|
super({
|
|
231
231
|
id: NEW_SKILL_COMMAND_ID,
|
|
232
|
-
title: ( localize(
|
|
232
|
+
title: ( localize(7524, "New Skill File...")),
|
|
233
233
|
f1: false,
|
|
234
234
|
precondition: ChatContextKeys.enabled,
|
|
235
235
|
category: CHAT_CATEGORY,
|
|
@@ -260,29 +260,29 @@ class NewSkillFileAction extends Action2 {
|
|
|
260
260
|
}
|
|
261
261
|
const skillName = await quickInputService.input({
|
|
262
262
|
prompt: ( localize(
|
|
263
|
-
|
|
263
|
+
7525,
|
|
264
264
|
"Enter a name for the skill (lowercase letters, numbers, and hyphens only)"
|
|
265
265
|
)),
|
|
266
|
-
placeHolder: ( localize(
|
|
266
|
+
placeHolder: ( localize(7526, "e.g., pdf-processing, data-analysis")),
|
|
267
267
|
validateInput: async value => {
|
|
268
268
|
if (!value || !value.trim()) {
|
|
269
|
-
return localize(
|
|
269
|
+
return localize(7527, "Skill name is required");
|
|
270
270
|
}
|
|
271
271
|
const name = value.trim();
|
|
272
272
|
if (name.length > 64) {
|
|
273
|
-
return localize(
|
|
273
|
+
return localize(7528, "Skill name must be 64 characters or less");
|
|
274
274
|
}
|
|
275
275
|
if (!VALID_SKILL_NAME_REGEX.test(name)) {
|
|
276
276
|
return localize(
|
|
277
|
-
|
|
277
|
+
7529,
|
|
278
278
|
"Skill name may only contain lowercase letters, numbers, and hyphens"
|
|
279
279
|
);
|
|
280
280
|
}
|
|
281
281
|
if (name.startsWith("-") || name.endsWith("-")) {
|
|
282
|
-
return localize(
|
|
282
|
+
return localize(7530, "Skill name must not start or end with a hyphen");
|
|
283
283
|
}
|
|
284
284
|
if (name.includes("--")) {
|
|
285
|
-
return localize(
|
|
285
|
+
return localize(7531, "Skill name must not contain consecutive hyphens");
|
|
286
286
|
}
|
|
287
287
|
return undefined;
|
|
288
288
|
}
|
|
@@ -314,7 +314,7 @@ class NewUntitledPromptFileAction extends Action2 {
|
|
|
314
314
|
constructor() {
|
|
315
315
|
super({
|
|
316
316
|
id: "workbench.command.new.untitled.prompt",
|
|
317
|
-
title: ( localize2(
|
|
317
|
+
title: ( localize2(7532, "New Untitled Prompt File")),
|
|
318
318
|
f1: true,
|
|
319
319
|
precondition: ChatContextKeys.enabled,
|
|
320
320
|
category: CHAT_CATEGORY,
|