Skip to content

Commit 866ad75

Browse files
authored
feat: upgrades chat participant (experimental) (#80)
1 parent 0b0ddb8 commit 866ad75

File tree

13 files changed

+1313
-10
lines changed

13 files changed

+1313
-10
lines changed

package.json

Lines changed: 138 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"version": "0.0.0",
1313
"engines": {
1414
"node": ">=18",
15-
"vscode": "^1.91.0"
15+
"vscode": "^1.97.0"
1616
},
1717
"activationEvents": [
1818
"workspaceContains:electron_resources.grd",
@@ -38,6 +38,25 @@
3838
}
3939
},
4040
"contributes": {
41+
"chatParticipants": [
42+
{
43+
"id": "electron-build-tools",
44+
"name": "electron",
45+
"fullName": "Electron Build Tools",
46+
"description": "Ask about Electron",
47+
"when": "electron-build-tools:active",
48+
"commands": [
49+
{
50+
"name": "findUpstreamFiles",
51+
"description": "Attempt to find upstream Chromium files that Electron files are derived from."
52+
},
53+
{
54+
"name": "upgradesFindCL",
55+
"description": "Attempt to find the Chromium CL related to the current sync/build failure."
56+
}
57+
]
58+
}
59+
],
4160
"colors": [
4261
{
4362
"id": "electronBuildTools.gettingStartedIcon",
@@ -494,6 +513,120 @@
494513
]
495514
}
496515
],
516+
"languageModelTools": [
517+
{
518+
"name": "electron-build-tools_chromiumGitLog",
519+
"tags": ["chromium", "git", "log", "commits"],
520+
"displayName": "Chromium Git Log",
521+
"modelDescription": "Retrieves the git log for Chromium between two versions",
522+
"inputSchema": {
523+
"type": "object",
524+
"properties": {
525+
"startVersion": {
526+
"type": "string",
527+
"description": "The starting version to retrieve the log for.",
528+
"examples": [
529+
"135.0.7016.3",
530+
"135.0.7049.1"
531+
]
532+
},
533+
"endVersion": {
534+
"type": "string",
535+
"description": "The ending version to retrieve the log for.",
536+
"examples": [
537+
"135.0.7016.3",
538+
"135.0.7049.1"
539+
]
540+
},
541+
"page": {
542+
"type": "integer",
543+
"description": "The page number of the log to retrieve.",
544+
"minimum": 1
545+
}
546+
}
547+
}
548+
},
549+
{
550+
"name": "electron-build-tools_chromiumGitShow",
551+
"tags": ["chromium", "git", "show", "commits"],
552+
"displayName": "Chromium Git Show",
553+
"modelDescription": "Shows the log message and textual diff for a commit",
554+
"inputSchema": {
555+
"type": "object",
556+
"properties": {
557+
"commit": {
558+
"type": "string",
559+
"description": "The SHA for the commit to show.",
560+
"examples": [
561+
"26b69cddcef09655077629eeda8000f4ba621f5f"
562+
]
563+
}
564+
},
565+
"required": [
566+
"commit"
567+
]
568+
}
569+
},
570+
{
571+
"name": "electron-build-tools_gitLog",
572+
"tags": ["git", "log", "commits"],
573+
"displayName": "Git Log",
574+
"modelDescription": "Retrieves the git log for a given filename",
575+
"inputSchema": {
576+
"type": "object",
577+
"properties": {
578+
"filename": {
579+
"type": "string",
580+
"description": "The filename to retrieve the git log for.",
581+
"examples": [
582+
"chrome/browser/icon_loader.cc",
583+
"components/autofill/core/browser/geo/autofill_country.h"
584+
]
585+
},
586+
"since": {
587+
"type": "string",
588+
"description": "Show commits more recent than a specific date.",
589+
"examples": [
590+
"Mon Jan 10 18:11:51 2022 -0700"
591+
]
592+
}
593+
},
594+
"required": [
595+
"filename"
596+
]
597+
}
598+
},
599+
{
600+
"name": "electron-build-tools_gitShow",
601+
"tags": ["git", "show", "commits"],
602+
"displayName": "Git Show",
603+
"modelDescription": "Shows the log message and textual diff for a commit",
604+
"inputSchema": {
605+
"type": "object",
606+
"properties": {
607+
"commit": {
608+
"type": "string",
609+
"description": "The SHA for the commit to show.",
610+
"examples": [
611+
"26b69cddcef09655077629eeda8000f4ba621f5f"
612+
]
613+
},
614+
"filename": {
615+
"type": "string",
616+
"description": "The filename to limit the textual diff to.",
617+
"examples": [
618+
"chrome/browser/icon_loader.cc",
619+
"electron/shell/utility/electron_content_utility_client.h"
620+
]
621+
}
622+
},
623+
"required": [
624+
"commit",
625+
"filename"
626+
]
627+
}
628+
}
629+
],
497630
"markdown.markdownItPlugins": true,
498631
"menus": {
499632
"commandPalette": [
@@ -786,8 +919,8 @@
786919
"lint": "eslint electron src && yarn prettier:check",
787920
"prepare": "husky",
788921
"pretest": "yarn run esbuild && yarn run lint",
789-
"prettier:check": "prettier --check \"src/**/*.ts\" \"scripts/**/*.ts\" \"electron/**/*.ts\"",
790-
"prettier:write": "prettier --write \"src/**/*.ts\" \"scripts/**/*.ts\" \"electron/**/*.ts\""
922+
"prettier:check": "prettier --check \"src/**/*.{ts,tsx}\" \"scripts/**/*.ts\" \"electron/**/*.ts\"",
923+
"prettier:write": "prettier --write \"src/**/*.{ts,tsx}\" \"scripts/**/*.ts\" \"electron/**/*.ts\""
791924
},
792925
"devDependencies": {
793926
"@commitlint/cli": "^19.5.0",
@@ -800,7 +933,7 @@
800933
"@types/mocha": "^10.0.9",
801934
"@types/node": "^22.8.6",
802935
"@types/uuid": "^10.0.0",
803-
"@types/vscode": "1.91.0",
936+
"@types/vscode": "1.97.0",
804937
"esbuild": "^0.24.2",
805938
"eslint": "^9.13.0",
806939
"husky": "^9.1.6",
@@ -816,6 +949,7 @@
816949
"dependencies": {
817950
"@electron/docs-parser": "^2.0.0",
818951
"@octokit/rest": "^19.0.4",
952+
"@vscode/prompt-tsx": "^0.3.0-alpha.20",
819953
"diff": "^5.0.0",
820954
"lru-cache": "^7.14.0",
821955
"markdown-it": "^14.1.0",
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { renderPrompt } from "@vscode/prompt-tsx";
2+
import * as vscode from "vscode";
3+
4+
import { FindUpstreamFilePrompt } from "../prompts";
5+
6+
export async function findUpstreamFiles(
7+
chromiumRoot: vscode.Uri,
8+
request: vscode.ChatRequest,
9+
stream: vscode.ChatResponseStream,
10+
token: vscode.CancellationToken,
11+
) {
12+
const files = await vscode.workspace.findFiles(
13+
"shell/**/*.{cc,cpp,h,mm,hxx}",
14+
null,
15+
undefined,
16+
token,
17+
);
18+
for (const file of files) {
19+
const fileContents = await vscode.workspace.fs.readFile(file);
20+
const { messages } = await renderPrompt(
21+
FindUpstreamFilePrompt,
22+
{ fileContents: fileContents.toString() },
23+
{ modelMaxPromptTokens: request.model.maxInputTokens },
24+
request.model,
25+
);
26+
27+
const response = await request.model.sendRequest(messages, {}, token);
28+
let result = "";
29+
for await (const fragment of response.text) {
30+
result += fragment;
31+
}
32+
if (result.toLowerCase() !== "no") {
33+
try {
34+
await vscode.workspace.fs.stat(
35+
vscode.Uri.joinPath(chromiumRoot, result),
36+
);
37+
stream.markdown(
38+
`${vscode.workspace.asRelativePath(file, false)} -> ${result}\n`,
39+
);
40+
} catch {
41+
// File doesn't exist so ignore it
42+
}
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)