From 1a85fd61f78bc989805144cfb581835ddcc752bc Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 14 Oct 2024 13:35:51 -0700 Subject: [PATCH 01/11] remove esbuild from `binary` build script --- binary/build.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/binary/build.js b/binary/build.js index 016afe9bd..ce8f3997e 100644 --- a/binary/build.js +++ b/binary/build.js @@ -270,34 +270,12 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { fs.unlinkSync(`${targetDir}/build.tar.gz`); - // Download and unzip prebuilt esbuild binary for the target - console.log(`[info] Downloading esbuild for ${target}...`); - // Version is pinned to 0.19.11 in package.json to make sure that they match - execCmdSync( - `curl -o ${targetDir}/esbuild.tgz https://registry.npmjs.org/@esbuild/${target}/-/${target}-0.19.11.tgz`, - ); - execCmdSync(`tar -xzvf ${targetDir}/esbuild.tgz -C ${targetDir}`); - if (target.startsWith("win32")) { - fs.cpSync(`${targetDir}/package/esbuild.exe`, `${targetDir}/esbuild.exe`); - } else { - fs.cpSync(`${targetDir}/package/bin/esbuild`, `${targetDir}/esbuild`); - } - fs.rmSync(`${targetDir}/esbuild.tgz`); - fs.rmSync(`${targetDir}/package`, { - force: true, - recursive: true, - }); - // copy @lancedb to bin folders console.log("[info] Copying @lancedb files to bin"); fs.copyFileSync( `node_modules/${targetToLanceDb[target]}/index.node`, `${targetDir}/index.node`, ); - } - // execCmdSync( - // `npx pkg out/index.js --target node18-darwin-arm64 --no-bytecode --public-packages "*" --public -o bin/pkg` - // ); const pathsToVerify = []; for (target of targets) { @@ -305,7 +283,6 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { const targetDir = `bin/${target}`; pathsToVerify.push( `${targetDir}/continue-binary${exe}`, - `${targetDir}/esbuild${exe}`, `${targetDir}/index.node`, // @lancedb "package.json", // Informs of where to look for node_sqlite3.node https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found `${targetDir}/build/Release/node_sqlite3.node`, From dc1eff8e8af5dc2f7fa739c80b53e2521b2fb4b1 Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 14 Oct 2024 17:24:44 -0700 Subject: [PATCH 02/11] add download step --- .idea/.name | 2 +- binary/.idea/vcs.xml | 6 ++ binary/build.js | 1 + core/config/load.ts | 122 +++++++++++++++++++------- core/util/GlobalContext.ts | 1 + core/util/paths.ts | 15 ++-- extensions/intellij/gradle.properties | 4 +- scripts/util/index.js | 5 +- 8 files changed, 114 insertions(+), 42 deletions(-) create mode 100644 binary/.idea/vcs.xml diff --git a/.idea/.name b/.idea/.name index c0d78d1d5..389f6bc71 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -Continue IntelliJ Extension \ No newline at end of file +continue-intellij-extension \ No newline at end of file diff --git a/binary/.idea/vcs.xml b/binary/.idea/vcs.xml new file mode 100644 index 000000000..6c0b86358 --- /dev/null +++ b/binary/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/binary/build.js b/binary/build.js index ce8f3997e..3afd1811a 100644 --- a/binary/build.js +++ b/binary/build.js @@ -276,6 +276,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { `node_modules/${targetToLanceDb[target]}/index.node`, `${targetDir}/index.node`, ); + } const pathsToVerify = []; for (target of targets) { diff --git a/core/config/load.ts b/core/config/load.ts index 67982ecad..9f2de836e 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -49,6 +49,8 @@ import { getConfigJsonPathForRemote, getConfigTsPath, getContinueDotEnv, + getContinueUtilsPath, + getEsbuildBinaryPath, readAllGlobalPromptFiles, } from "../util/paths.js"; import { @@ -62,6 +64,7 @@ import { getPromptFiles, slashCommandFromPromptFile, } from "./promptFile.js"; +import { GlobalContext } from "../util/GlobalContext.js"; function resolveSerializedConfig(filepath: string): SerializedContinueConfig { let content = fs.readFileSync(filepath, "utf8"); @@ -525,46 +528,103 @@ function escapeSpacesInPath(p: string): string { return p.replace(/ /g, "\\ "); } -async function buildConfigTs() { - if (!fs.existsSync(getConfigTsPath())) { +async function buildConfigTs(ide: IDE, ideType: IdeType) { + const configTsPath = getConfigTsPath(); + + if (!fs.existsSync(configTsPath)) { return undefined; } - try { - if (process.env.IS_BINARY === "true") { - execSync( - `${escapeSpacesInPath(path.dirname(process.execPath))}/esbuild${ - getTarget().startsWith("win32") ? ".exe" : "" - } ${escapeSpacesInPath( - getConfigTsPath(), - )} --bundle --outfile=${escapeSpacesInPath( - getConfigJsPath(), - )} --platform=node --format=cjs --sourcemap --external:fetch --external:fs --external:path --external:os --external:child_process`, - ); - } else { - // Dynamic import esbuild so potentially disastrous errors can be caught - const esbuild = await import("esbuild"); + const defaultContent = `export function modifyConfig(config: Config): Config { + return config; +}`; - await esbuild.build({ - entryPoints: [getConfigTsPath()], - bundle: true, - platform: "node", - format: "cjs", - outfile: getConfigJsPath(), - external: ["fetch", "fs", "path", "os", "child_process"], - sourcemap: true, - }); + // Read the current content of config.ts + const currentContent = fs.readFileSync(configTsPath, "utf8"); + + // Check if the current content matches the default content + if (currentContent.trim() !== defaultContent.trim()) { + // Config.ts has been modified + const esbuildPath = getEsbuildBinaryPath(); + const globalContext = new GlobalContext(); + + if ( + ideType === "jetbrains" && + !globalContext.get("hasReceivedConfigTsNoticeJetBrains") + ) { + try { + fs.accessSync(esbuildPath); + } catch (error) { + globalContext.update("hasReceivedConfigTsNoticeJetBrains", true); + + const actionMsg = "Install esbuild"; + + const res = await ide.showToast( + "info", + "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", + actionMsg, + ); + + if (res === actionMsg) { + const url = "https://esbuild.github.io/dl/v0.19.11"; + + try { + const response = await fetch(url); + const binaryData = await response.arrayBuffer(); + + fs.writeFileSync( + esbuildPath, + new Uint8Array(binaryData as ArrayBuffer), + ); + + fs.chmodSync(esbuildPath, 0o755); + + await ide.showToast( + "info", + `'esbuild' successfully installed to ${esbuildPath}`, + ); + } catch (error) { + console.debug("Error downloading or saving esbuild binary:", error); + } + } + } + } + + try { + if (process.env.IS_BINARY === "true") { + execSync( + `${escapeSpacesInPath(getEsbuildBinaryPath())} ${escapeSpacesInPath( + getConfigTsPath(), + )} --bundle --outfile=${escapeSpacesInPath( + getConfigJsPath(), + )} --platform=node --format=cjs --sourcemap --external:fetch --external:fs --external:path --external:os --external:child_process`, + ); + } else { + // Dynamic import esbuild so potentially disastrous errors can be caught + const { build } = await import("esbuild"); + + await build({ + entryPoints: [getConfigTsPath()], + bundle: true, + platform: "node", + format: "cjs", + outfile: getConfigJsPath(), + external: ["fetch", "fs", "path", "os", "child_process"], + sourcemap: true, + }); + } + } catch (e) { + console.log( + `Build error. Please check your ~/.continue/config.ts file: ${e}`, + ); + return undefined; } - } catch (e) { - console.log( - `Build error. Please check your ~/.continue/config.ts file: ${e}`, - ); - return undefined; } if (!fs.existsSync(getConfigJsPath())) { return undefined; } + return fs.readFileSync(getConfigJsPath(), "utf8"); } @@ -590,7 +650,7 @@ async function loadFullConfigNode( let intermediate = await serializedToIntermediateConfig(serialized, ide); // Apply config.ts to modify intermediate config - const configJsContents = await buildConfigTs(); + const configJsContents = await buildConfigTs(ide, ideType); if (configJsContents) { try { // Try config.ts first diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 3880b4609..ddc14bbd0 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -13,6 +13,7 @@ export type GlobalContextType = { * For VS Code users, it is unnecessary since we use transformers.js by default. */ curEmbeddingsProviderId: EmbeddingsProvider["id"]; + hasReceivedConfigTsNoticeJetBrains: boolean; }; /** diff --git a/core/util/paths.ts b/core/util/paths.ts index 28216d8af..864fc2c68 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -12,6 +12,10 @@ dotenv.config(); const CONTINUE_GLOBAL_DIR = process.env.CONTINUE_GLOBAL_DIR ?? path.join(os.homedir(), ".continue"); +export const DEFAULT_CONFIG_TS_CONTENTS = `export function modifyConfig(config: Config): Config { + return config; +}`; + export function getChromiumPath(): string { return path.join(getContinueUtilsPath(), ".chromium-browser-snapshots"); } @@ -80,12 +84,7 @@ export function getConfigJsonPath(ideType: IdeType = "vscode"): string { export function getConfigTsPath(): string { const p = path.join(getContinueGlobalPath(), "config.ts"); if (!fs.existsSync(p)) { - fs.writeFileSync( - p, - `export function modifyConfig(config: Config): Config { - return config; -}`, - ); + fs.writeFileSync(p, DEFAULT_CONFIG_TS_CONTENTS); } const typesPath = path.join(getContinueGlobalPath(), "types"); @@ -345,3 +344,7 @@ export function readAllGlobalPromptFiles( export function getRepoMapFilePath(): string { return path.join(getContinueUtilsPath(), "repo_map.txt"); } + +export function getEsbuildBinaryPath(): string { + return path.join(getContinueUtilsPath(), "esbuild"); +} diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 5174871a2..a892cf145 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -9,7 +9,7 @@ pluginSinceBuild=223 #pluginUntilBuild = 232.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType=IC -platformVersion=2023.2 +platformVersion=2022.3.3 #platformVersion = LATEST-EAP-SNAPSHOT # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 @@ -23,4 +23,4 @@ org.gradle.configuration-cache=true # Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html org.gradle.caching=true # Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment -systemProp.org.gradle.unsafe.kotlin.assignment=true +systemProp.org.gradle.unsafe.kotlin.assignment=true \ No newline at end of file diff --git a/scripts/util/index.js b/scripts/util/index.js index ec866eec3..384557492 100644 --- a/scripts/util/index.js +++ b/scripts/util/index.js @@ -1,5 +1,4 @@ const fs = require("fs"); -const os = require("os"); const { execSync } = require("child_process"); function execCmdSync(cmd) { @@ -91,7 +90,9 @@ function validateFilesPresent(pathsToVerify) { if (missingFiles.length > 0 || emptyFiles.length > 0) { throw new Error( - `The following files were missing:\n- ${missingFiles.join("\n- ")}\n\nThe following files were empty:\n- ${emptyFiles.join("\n- ")}`, + `The following files were missing:\n- ${missingFiles.join( + "\n- ", + )}\n\nThe following files were empty:\n- ${emptyFiles.join("\n- ")}`, ); } else { console.log("All paths exist"); From f57aad189c0a965dcd34429d4f489e9b98e3af59 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 09:06:12 -0700 Subject: [PATCH 03/11] add buttons to JB showToast --- core/config/load.ts | 206 ++++++++++-------- .../continue/CoreMessenger.kt | 4 +- .../continue/IdeProtocolClient.kt | 48 +++- 3 files changed, 158 insertions(+), 100 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 9f2de836e..37163d75f 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -43,6 +43,7 @@ import { fetchwithRequestOptions } from "../util/fetchWithOptions.js"; import { copyOf } from "../util/index.js"; import mergeJson from "../util/merge.js"; import { + DEFAULT_CONFIG_TS_CONTENTS, getConfigJsPath, getConfigJsPathForRemote, getConfigJsonPath, @@ -528,104 +529,135 @@ function escapeSpacesInPath(p: string): string { return p.replace(/ /g, "\\ "); } +async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { + // TODO: Uncomment + // if (ideType !== "jetbrains") { + // return; + // } + + // TODO: Uncomment + // const globalContext = new GlobalContext(); + // if (globalContext.get("hasReceivedConfigTsNoticeJetBrains")) { + // return; + // } + + const esbuildPath = getEsbuildBinaryPath(); + + if (fs.existsSync(esbuildPath)) { + return; + } + + console.debug("No esbuild binary detected"); + + const shouldInstall = await promptEsbuildInstallation(ide); + debugger; + + // TODO: Debug toast + if (shouldInstall || true) { + await downloadAndInstallEsbuild(ide, esbuildPath); + } +} + +async function promptEsbuildInstallation(ide: IDE): Promise { + const actionMsg = "Install esbuild"; + const res = await ide.showToast( + "info", + "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", + actionMsg, + ); + return res === actionMsg; +} + +async function downloadAndInstallEsbuild(ide: IDE, esbuildPath: string) { + const url = "https://esbuild.github.io/dl/v0.19.11"; + + try { + const response = await fetch(url); + const binaryData = await response.arrayBuffer(); + + fs.writeFileSync(esbuildPath, new Uint8Array(binaryData as ArrayBuffer)); + fs.chmodSync(esbuildPath, 0o755); + + await ide.showToast( + "info", + `'esbuild' successfully installed to ${esbuildPath}`, + ); + } catch (error) { + console.debug("Error downloading or saving esbuild binary:", error); + } +} + +async function tryBuildConfigTs() { + try { + if (process.env.IS_BINARY === "true") { + await buildConfigTsWithBinary(); + } else { + await buildConfigTsWithNodeModule(); + } + } catch (e) { + console.log( + `Build error. Please check your ~/.continue/config.ts file: ${e}`, + ); + } +} + +async function buildConfigTsWithBinary() { + execSync( + `${escapeSpacesInPath(getEsbuildBinaryPath())} ${escapeSpacesInPath( + getConfigTsPath(), + )} --bundle --outfile=${escapeSpacesInPath( + getConfigJsPath(), + )} --platform=node --format=cjs --sourcemap --external:fetch --external:fs --external:path --external:os --external:child_process`, + ); +} + +async function buildConfigTsWithNodeModule() { + const { build } = await import("esbuild"); + + await build({ + entryPoints: [getConfigTsPath()], + bundle: true, + platform: "node", + format: "cjs", + outfile: getConfigJsPath(), + external: ["fetch", "fs", "path", "os", "child_process"], + sourcemap: true, + }); +} + +function readConfigJs(): string | undefined { + const configJsPath = getConfigJsPath(); + if (!fs.existsSync(configJsPath)) { + return undefined; + } + return fs.readFileSync(configJsPath, "utf8"); +} + async function buildConfigTs(ide: IDE, ideType: IdeType) { + // TODO: Remove + await ide.showToast( + "info", + "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", + "YES", + ); + const configTsPath = getConfigTsPath(); if (!fs.existsSync(configTsPath)) { - return undefined; + return; } - const defaultContent = `export function modifyConfig(config: Config): Config { - return config; -}`; - - // Read the current content of config.ts const currentContent = fs.readFileSync(configTsPath, "utf8"); - // Check if the current content matches the default content - if (currentContent.trim() !== defaultContent.trim()) { - // Config.ts has been modified - const esbuildPath = getEsbuildBinaryPath(); - const globalContext = new GlobalContext(); - - if ( - ideType === "jetbrains" && - !globalContext.get("hasReceivedConfigTsNoticeJetBrains") - ) { - try { - fs.accessSync(esbuildPath); - } catch (error) { - globalContext.update("hasReceivedConfigTsNoticeJetBrains", true); - - const actionMsg = "Install esbuild"; - - const res = await ide.showToast( - "info", - "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", - actionMsg, - ); - - if (res === actionMsg) { - const url = "https://esbuild.github.io/dl/v0.19.11"; - - try { - const response = await fetch(url); - const binaryData = await response.arrayBuffer(); - - fs.writeFileSync( - esbuildPath, - new Uint8Array(binaryData as ArrayBuffer), - ); - - fs.chmodSync(esbuildPath, 0o755); - - await ide.showToast( - "info", - `'esbuild' successfully installed to ${esbuildPath}`, - ); - } catch (error) { - console.debug("Error downloading or saving esbuild binary:", error); - } - } - } - } - - try { - if (process.env.IS_BINARY === "true") { - execSync( - `${escapeSpacesInPath(getEsbuildBinaryPath())} ${escapeSpacesInPath( - getConfigTsPath(), - )} --bundle --outfile=${escapeSpacesInPath( - getConfigJsPath(), - )} --platform=node --format=cjs --sourcemap --external:fetch --external:fs --external:path --external:os --external:child_process`, - ); - } else { - // Dynamic import esbuild so potentially disastrous errors can be caught - const { build } = await import("esbuild"); - - await build({ - entryPoints: [getConfigTsPath()], - bundle: true, - platform: "node", - format: "cjs", - outfile: getConfigJsPath(), - external: ["fetch", "fs", "path", "os", "child_process"], - sourcemap: true, - }); - } - } catch (e) { - console.log( - `Build error. Please check your ~/.continue/config.ts file: ${e}`, - ); - return undefined; - } + // If the user hasn't modified the default config.ts, don't bother building + if (currentContent.trim() === DEFAULT_CONFIG_TS_CONTENTS.trim()) { + return; } - if (!fs.existsSync(getConfigJsPath())) { - return undefined; - } + await handleEsbuildInstallation(ide, ideType); + await tryBuildConfigTs(); - return fs.readFileSync(getConfigJsPath(), "utf8"); + return readConfigJs(); } async function loadFullConfigNode( diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index 0d2c61941..ce7e0088e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -28,7 +28,7 @@ class CoreMessenger( private val gson = Gson() private val responseListeners = mutableMapOf Unit>() private val ideProtocolClient = ideProtocolClient - private val useTcp: Boolean = false + private val useTcp: Boolean = true // TODO: Revert private fun write(message: String) { try { @@ -98,7 +98,7 @@ class CoreMessenger( val continuePluginService = project.service() continuePluginService.sendToWebview(messageType, responseMap["data"], messageType) } - + // Responses for messageId responseListeners[messageId]?.let { listener -> listener(data) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 350a96bdd..17e5ee9b4 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -19,6 +19,7 @@ import com.intellij.lang.annotation.HighlightSeverity import com.intellij.notification.NotificationDisplayType import com.intellij.notification.NotificationGroup import com.intellij.notification.NotificationType +import com.intellij.notification.NotificationAction import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager @@ -642,10 +643,14 @@ class IdeProtocolClient( "showToast" -> { val data = data as ArrayList - val toast_type = data[0] + val toastType = data[0] val message = data[1] - showToast(toast_type, message) - respond(null) + val buttonText = if (data.size > 2) data[2] else null + + coroutineScope.launch { + val result = showToast(toastType, message, buttonText) + respond(result) + } } "listFolders" -> { @@ -1031,16 +1036,37 @@ class IdeProtocolClient( return virtualFile?.path } - fun showToast(type: String, content: String) { - val notificationType = when (type.uppercase()) { - "ERROR" -> NotificationType.ERROR - "WARNING" -> NotificationType.WARNING - else -> NotificationType.INFORMATION + suspend fun showToast(type: String, content: String, actionButtonText: String? = null): Boolean? = + withContext(Dispatchers.Main) { + val notificationType = when (type.uppercase()) { + "ERROR" -> NotificationType.ERROR + "WARNING" -> NotificationType.WARNING + else -> NotificationType.INFORMATION + } + + val deferred = CompletableDeferred() + + val notification = CONTINUE_NOTIFICATION_GROUP.createNotification(content, notificationType) + + if (actionButtonText != null) { + notification.addAction(NotificationAction.create(actionButtonText) { _, _ -> + deferred.complete(true) + notification.expire() + }) + notification.whenExpired { + if (!deferred.isCompleted) { + deferred.complete(null) + } + } + } else { + deferred.complete(null) + } + + notification.notify(project) + + deferred.await() } - CONTINUE_NOTIFICATION_GROUP.createNotification(content, notificationType) - .notify(project); - } fun highlightCode(rangeInFile: RangeInFile, color: String?) { val file = From 2cb9a3e5f6906ff62331a35ed8049c66d30a1604 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 09:50:44 -0700 Subject: [PATCH 04/11] remove comments --- core/config/load.ts | 25 ++++++------------- .../continue/CoreMessenger.kt | 3 +-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 37163d75f..acccdbfdb 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -530,16 +530,14 @@ function escapeSpacesInPath(p: string): string { } async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { - // TODO: Uncomment - // if (ideType !== "jetbrains") { - // return; - // } + if (ideType !== "jetbrains") { + return; + } - // TODO: Uncomment - // const globalContext = new GlobalContext(); - // if (globalContext.get("hasReceivedConfigTsNoticeJetBrains")) { - // return; - // } + const globalContext = new GlobalContext(); + if (globalContext.get("hasReceivedConfigTsNoticeJetBrains")) { + return; + } const esbuildPath = getEsbuildBinaryPath(); @@ -550,9 +548,7 @@ async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { console.debug("No esbuild binary detected"); const shouldInstall = await promptEsbuildInstallation(ide); - debugger; - // TODO: Debug toast if (shouldInstall || true) { await downloadAndInstallEsbuild(ide, esbuildPath); } @@ -634,13 +630,6 @@ function readConfigJs(): string | undefined { } async function buildConfigTs(ide: IDE, ideType: IdeType) { - // TODO: Remove - await ide.showToast( - "info", - "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", - "YES", - ); - const configTsPath = getConfigTsPath(); if (!fs.existsSync(configTsPath)) { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index ce7e0088e..ff32b1af8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -28,8 +28,7 @@ class CoreMessenger( private val gson = Gson() private val responseListeners = mutableMapOf Unit>() private val ideProtocolClient = ideProtocolClient - private val useTcp: Boolean = true // TODO: Revert - + private val useTcp: Boolean = false private fun write(message: String) { try { writer?.write(message + "\r\n") From c67e0449d9f8cbdd366557d40c963d8169b87968 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 11:09:07 -0700 Subject: [PATCH 05/11] remove unused code --- .vscode/launch.json | 1 - binary/package.json | 1 - core/config/load.ts | 44 +--- .../ContinuePluginStartupActivity.kt | 3 - .../constants/MessageTypes.kt | 4 +- .../continue/CoreMessenger.kt | 2 +- .../continue/IdeProtocolClient.kt | 192 +----------------- 7 files changed, 14 insertions(+), 233 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 896793040..e92f1c136 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -29,7 +29,6 @@ "name": "Core Binary", "skipFiles": ["/**"], "program": "${workspaceFolder}/binary/out/index.js", - // "preLaunchTask": "binary:esbuild", "outFiles": ["${workspaceFolder}/binary/out/**/*.js"], "sourceMaps": true, "smartStep": true, diff --git a/binary/package.json b/binary/package.json index cb14c50f7..62a28b741 100644 --- a/binary/package.json +++ b/binary/package.json @@ -23,7 +23,6 @@ "scripts": { "test": "jest", "build": "node build.js", - "build:old": "ncc build src/index.ts -o out && pkg .", "build:dev": "tsc", "esbuild": "node build.js --esbuild-only" }, diff --git a/core/config/load.ts b/core/config/load.ts index acccdbfdb..a66500f65 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -496,35 +496,6 @@ function finalToBrowserConfig( }; } -function getTarget() { - const os = - { - aix: "linux", - darwin: "darwin", - freebsd: "linux", - linux: "linux", - openbsd: "linux", - sunos: "linux", - win32: "win32", - }[process.platform as string] ?? "linux"; - const arch = { - arm: "arm64", - arm64: "arm64", - ia32: "x64", - loong64: "arm64", - mips: "arm64", - mipsel: "arm64", - ppc: "x64", - ppc64: "x64", - riscv64: "arm64", - s390: "x64", - s390x: "x64", - x64: "x64", - }[process.arch]; - - return `${os}-${arch}`; -} - function escapeSpacesInPath(p: string): string { return p.replace(/ /g, "\\ "); } @@ -534,10 +505,11 @@ async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { return; } - const globalContext = new GlobalContext(); - if (globalContext.get("hasReceivedConfigTsNoticeJetBrains")) { - return; - } + // TODO: Uncomment + // const globalContext = new GlobalContext(); + // if (globalContext.get("hasReceivedConfigTsNoticeJetBrains")) { + // return; + // } const esbuildPath = getEsbuildBinaryPath(); @@ -556,11 +528,13 @@ async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { async function promptEsbuildInstallation(ide: IDE): Promise { const actionMsg = "Install esbuild"; + const res = await ide.showToast( - "info", + "warning", "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", actionMsg, ); + return res === actionMsg; } @@ -630,6 +604,8 @@ function readConfigJs(): string | undefined { } async function buildConfigTs(ide: IDE, ideType: IdeType) { + // TODO: Remove + await ide.showToast("info", "test toast"); const configTsPath = getConfigTsPath(); if (!fs.existsSync(configTsPath)) { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index dba2f7999..8ca3648dd 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -96,8 +96,6 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { ContinuePluginService::class.java ) - val defaultStrategy = DefaultTextSelectionStrategy() - coroutineScope.launch { val settings = ServiceManager.getService(ContinueExtensionSettings::class.java) @@ -111,7 +109,6 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { val ideProtocolClient = IdeProtocolClient( continuePluginService, - defaultStrategy, coroutineScope, project.basePath, project diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 2d3d3ddbc..264822b6c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -8,7 +8,7 @@ class MessageTypes { "command/run", "streamDiffLines" ) - + val ideMessageTypes = listOf( "readRangeInFile", "isTelemetryEnabled", @@ -53,7 +53,7 @@ class MessageTypes { "showToast", ) - val PASS_THROUGH_TO_WEBVIEW = listOf( + val PASS_THROUGH_TO_WEBVIEW = listOf( "configUpdate", "getDefaultModelTitle", "indexProgress", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index ff32b1af8..b4c03eca8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -28,7 +28,7 @@ class CoreMessenger( private val gson = Gson() private val responseListeners = mutableMapOf Unit>() private val ideProtocolClient = ideProtocolClient - private val useTcp: Boolean = false + private val useTcp: Boolean = false // TODO: Set to `false` private fun write(message: String) { try { writer?.write(message + "\r\n") diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 17e5ee9b4..fb9b89174 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -35,15 +35,10 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.TextEditor import com.intellij.openapi.project.DumbAware import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.MessageType -import com.intellij.openapi.ui.popup.Balloon -import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.vfs.* import com.intellij.openapi.vfs.newvfs.events.VFileEvent -import com.intellij.openapi.wm.WindowManager import com.intellij.psi.PsiDocumentManager import com.intellij.testFramework.LightVirtualFile -import com.intellij.ui.awt.RelativePoint import com.intellij.util.concurrency.annotations.RequiresEdt import kotlinx.coroutines.* import java.awt.Toolkit @@ -54,81 +49,16 @@ import java.nio.charset.Charset import java.nio.file.Paths import java.util.* - fun uuid(): String { return UUID.randomUUID().toString() } -val DEFAULT_IGNORE_FILETYPES = arrayOf( - ".DS_Store", - "-lock.json", - ".lock", - ".log", - ".ttf", - ".png", - ".jpg", - ".jpeg", - ".gif", - ".mp4", - ".svg", - ".ico", - ".pdf", - ".zip", - ".gz", - ".tar", - ".dmg", - ".tgz", - ".rar", - ".7z", - ".exe", - ".dll", - ".obj", - ".o", - ".o.d", - ".a", - ".lib", - ".so", - ".dylib", - ".ncb", - ".sdf", - ".woff", - ".woff2", - ".eot", - ".cur", - ".avi", - ".mpg", - ".mpeg", - ".mov", - ".mp3", - ".mp4", - ".mkv", - ".mkv", - ".webm", - ".jar", - ".onnx", - ".parquet", - ".pqt", - ".wav", - ".webp", - ".db", - ".sqlite", - ".wasm", - ".plist", - ".profraw", - ".gcda", - ".gcno", - "go.sum", -) - -data class IdeMessage(val type: String, val messageId: String, val message: T) data class Position(val line: Int, val character: Int) data class Range(val start: Position, val end: Position) data class RangeInFile(val filepath: String, val range: Range) data class RangeInFileWithContents(val filepath: String, val range: Range, val contents: String) -data class HighlightedCodeUpdate(val highlightedCode: List, val edit: Boolean) data class AcceptRejectDiff(val accepted: Boolean, val stepIndex: Int) data class DeleteAtIndex(val index: Int) -data class MainUserInput(val input: String) fun getMachineUniqueID(): String { val sb = StringBuilder() @@ -167,13 +97,7 @@ private fun readConfigJson(): Map { return config } -class AsyncFileSaveListener : AsyncFileListener { - private val ideProtocolClient: IdeProtocolClient - - constructor(ideProtocolClient: IdeProtocolClient) { - this.ideProtocolClient = ideProtocolClient - } - +class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) : AsyncFileListener { override fun prepareChange(events: MutableList): AsyncFileListener.ChangeApplier? { for (event in events) { if (event.path.endsWith(".continue/config.json") || event.path.endsWith(".continue/config.ts") || event.path.endsWith( @@ -190,12 +114,10 @@ class AsyncFileSaveListener : AsyncFileListener { } return null } - } class IdeProtocolClient( private val continuePluginService: ContinuePluginService, - private val textSelectionStrategy: TextSelectionStrategy, private val coroutineScope: CoroutineScope, private val workspacePath: String?, private val project: Project @@ -747,25 +669,6 @@ class IdeProtocolClient( continuePluginService.coreMessenger?.request("config/reload", null, null) { _ -> } } - private fun editConfigJson(callback: (config: MutableMap) -> Map): Map { - val gson = GsonBuilder().setPrettyPrinting().create() - val configJsonPath = getConfigJsonPath() - val reader = FileReader(configJsonPath) - val config: MutableMap = gson.fromJson( - reader, - object : TypeToken>() {}.type - ) - reader.close() - - val editedConfig = callback(config) - - val writer = FileWriter(configJsonPath) - gson.toJson(editedConfig, writer) - writer.close() - - return editedConfig - } - private fun initIdeProtocol() { val applicationInfo = ApplicationInfo.getInstance() val ideName: String = applicationInfo.fullApplicationName @@ -909,11 +812,6 @@ class IdeProtocolClient( fun sendHighlightedCode(edit: Boolean = false) { val rif = getHighlightedCode() ?: return -// send("highlightedCodePush", uuid(), HighlightedCodeUpdate( -// listOf(rif), -// edit -// )) - continuePluginService.sendToWebview( "highlightedCode", mapOf( @@ -923,9 +821,6 @@ class IdeProtocolClient( ) } - fun sendMainUserInput(input: String) { - continuePluginService.sendToWebview("userInput", mapOf("input" to input)) - } fun sendAcceptRejectDiff(accepted: Boolean, stepIndex: Int) { send("acceptRejectDiff", AcceptRejectDiff(accepted, stepIndex), uuid()) @@ -1069,52 +964,11 @@ class IdeProtocolClient( fun highlightCode(rangeInFile: RangeInFile, color: String?) { - val file = - LocalFileSystem.getInstance().findFileByPath(rangeInFile.filepath) - setFileOpen(rangeInFile.filepath, true) - - ApplicationManager.getApplication().invokeLater { - val editor = file?.let { - val fileEditor = - FileEditorManager.getInstance(project).getSelectedEditor(it) - (fileEditor as? TextEditor)?.editor - } - - val virtualFile = LocalFileSystem.getInstance() - .findFileByIoFile(File(rangeInFile.filepath)) - val document = - FileDocumentManager.getInstance().getDocument(virtualFile!!) - val startIdx = - document!!.getLineStartOffset(rangeInFile.range.start.line) + rangeInFile.range.start.character - val endIdx = - document.getLineEndOffset(rangeInFile.range.end.line) + rangeInFile.range.end.character - - val markupModel = editor!!.markupModel -// val textAttributes = TextAttributes(Color.decode(color.drop(1).toInt(color)), null, null, null, 0) - -// markupModel.addRangeHighlighter(startIdx, endIdx, 0, textAttributes, HighlighterTargetArea.EXACT_RANGE) - } } private fun terminalContents(): String { return "" -// val contents = project.service().latest()?.run { -// TerminalUtils.getTextInTerminal(terminalPanel) -// } ?: "" -// -// var lines = contents.split("\n").dropLastWhile { it.isEmpty() } -// val lastLine = lines.lastOrNull()?.trim() -// if (lastLine != null) { -// lines = lines.dropLast(1) -// var i = lines.size - 1 -// while (i >= 0 && !lines[i].trim().startsWith(lastLine)) { -// i-- -// } -// return lines.subList(maxOf(i, 0), lines.size).joinToString("\n") -// } -// -// return contents } private fun search(query: String): String { @@ -1122,48 +976,4 @@ class IdeProtocolClient( command.setWorkDirectory(project.basePath) return ExecUtil.execAndGetOutput(command).stdout ?: "" } -} - -interface TextSelectionStrategy { - fun handleTextSelection( - selectedText: String, - filepath: String, - startLine: Int, - startCharacter: Int, - endLine: Int, - endCharacter: Int - ): Map -} - -class DefaultTextSelectionStrategy : TextSelectionStrategy { - - override fun handleTextSelection( - selectedText: String, - filepath: String, - startLine: Int, - startCharacter: Int, - endLine: Int, - endCharacter: Int - ): Map { - - return mapOf( - "edit" to false, - "highlightedCode" to arrayOf( - mapOf( - "filepath" to filepath, - "contents" to selectedText, - "range" to mapOf( - "start" to mapOf( - "line" to startLine, - "character" to startCharacter - ), - "end" to mapOf( - "line" to endLine, - "character" to endCharacter - ) - ) - ) - ) - ) - } } \ No newline at end of file From c5c62a6f000bbc15a8850b347a5d79a16440142e Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 15 Oct 2024 14:38:19 -0700 Subject: [PATCH 06/11] Update pull_request_template.md --- .github/pull_request_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index f9a4b0151..1fed6b72b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -14,3 +14,4 @@ ## Testing [ For new or modified features, provide step-by-step testing instructions to validate the intended behavior of the change. ] +[ For new UI features, ensure that the changes look good across viewport widths, light/dark theme, etc ] From d39b6e69a52deed4b9d1f8308adf6006294ecd06 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 16:29:33 -0700 Subject: [PATCH 07/11] install to .utils --- core/config/load.ts | 109 ++++++++++-------- core/util/GlobalContext.ts | 6 +- extensions/intellij/build.gradle.kts | 19 +-- .../continue/CoreMessenger.kt | 2 +- .../continue/IdeProtocolClient.kt | 56 +++++---- .../src/main/resources/META-INF/plugin.xml | 4 +- 6 files changed, 104 insertions(+), 92 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index a66500f65..f2ab7c9ba 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -5,11 +5,11 @@ import { slashCommandFromDescription, slashFromCustomCommand, } from "../commands/index.js"; -import CustomContextProviderClass from "../context/providers/CustomContextProvider.js"; -import FileContextProvider from "../context/providers/FileContextProvider.js"; -import { contextProviderClassFromName } from "../context/providers/index.js"; -import { AllRerankers } from "../context/rerankers/index.js"; -import { LLMReranker } from "../context/rerankers/llm.js"; +import CustomContextProviderClass from "../context/providers/CustomContextProvider"; +import FileContextProvider from "../context/providers/FileContextProvider"; +import { contextProviderClassFromName } from "../context/providers/index"; +import { AllRerankers } from "../context/rerankers/index"; +import { LLMReranker } from "../context/rerankers/llm"; import { BrowserSerializedContinueConfig, Config, @@ -28,20 +28,20 @@ import { RerankerDescription, SerializedContinueConfig, SlashCommand, -} from "../index.js"; -import TransformersJsEmbeddingsProvider from "../indexing/embeddings/TransformersJsEmbeddingsProvider.js"; -import { allEmbeddingsProviders } from "../indexing/embeddings/index.js"; -import { BaseLLM } from "../llm/index.js"; -import CustomLLMClass from "../llm/llms/CustomLLM.js"; -import FreeTrial from "../llm/llms/FreeTrial.js"; -import { llmFromDescription } from "../llm/llms/index.js"; +} from ".."; +import TransformersJsEmbeddingsProvider from "../indexing/embeddings/TransformersJsEmbeddingsProvider"; +import { allEmbeddingsProviders } from "../indexing/embeddings"; +import { BaseLLM } from "../llm"; +import CustomLLMClass from "../llm/llms/CustomLLM"; +import FreeTrial from "../llm/llms/FreeTrial"; +import { llmFromDescription } from "../llm/llms"; import { execSync } from "child_process"; -import CodebaseContextProvider from "../context/providers/CodebaseContextProvider.js"; -import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider.js"; -import { fetchwithRequestOptions } from "../util/fetchWithOptions.js"; -import { copyOf } from "../util/index.js"; -import mergeJson from "../util/merge.js"; +import CodebaseContextProvider from "../context/providers/CodebaseContextProvider"; +import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider"; +import { fetchwithRequestOptions } from "../util/fetchWithOptions"; +import { copyOf } from "../util"; +import mergeJson from "../util/merge"; import { DEFAULT_CONFIG_TS_CONTENTS, getConfigJsPath, @@ -50,22 +50,21 @@ import { getConfigJsonPathForRemote, getConfigTsPath, getContinueDotEnv, - getContinueUtilsPath, getEsbuildBinaryPath, readAllGlobalPromptFiles, -} from "../util/paths.js"; +} from "../util/paths"; import { defaultContextProvidersJetBrains, defaultContextProvidersVsCode, defaultSlashCommandsJetBrains, defaultSlashCommandsVscode, -} from "./default.js"; +} from "./default"; import { DEFAULT_PROMPTS_FOLDER, getPromptFiles, slashCommandFromPromptFile, -} from "./promptFile.js"; -import { GlobalContext } from "../util/GlobalContext.js"; +} from "./promptFile"; +import { GlobalContext } from "../util/GlobalContext"; function resolveSerializedConfig(filepath: string): SerializedContinueConfig { let content = fs.readFileSync(filepath, "utf8"); @@ -505,11 +504,10 @@ async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { return; } - // TODO: Uncomment - // const globalContext = new GlobalContext(); - // if (globalContext.get("hasReceivedConfigTsNoticeJetBrains")) { - // return; - // } + const globalContext = new GlobalContext(); + if (globalContext.get("hasDismissedConfigTsNoticeJetBrains")) { + return; + } const esbuildPath = getEsbuildBinaryPath(); @@ -521,32 +519,44 @@ async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { const shouldInstall = await promptEsbuildInstallation(ide); - if (shouldInstall || true) { - await downloadAndInstallEsbuild(ide, esbuildPath); + if (shouldInstall) { + await downloadAndInstallEsbuild(ide); } } async function promptEsbuildInstallation(ide: IDE): Promise { - const actionMsg = "Install esbuild"; + const installMsg = "Install esbuild"; + const dismissMsg = "Dismiss"; const res = await ide.showToast( "warning", "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", - actionMsg, + dismissMsg, + installMsg, ); - return res === actionMsg; + if (res === dismissMsg) { + const globalContext = new GlobalContext(); + globalContext.update("hasDismissedConfigTsNoticeJetBrains", true); + return false; + } + + return res === installMsg; } -async function downloadAndInstallEsbuild(ide: IDE, esbuildPath: string) { +async function downloadAndInstallEsbuild(ide: IDE) { const url = "https://esbuild.github.io/dl/v0.19.11"; + const esbuildPath = getEsbuildBinaryPath(); try { const response = await fetch(url); - const binaryData = await response.arrayBuffer(); + const script = await response.text(); - fs.writeFileSync(esbuildPath, new Uint8Array(binaryData as ArrayBuffer)); - fs.chmodSync(esbuildPath, 0o755); + execSync("sh", { + input: script, + stdio: ["pipe", "inherit", "inherit"], + cwd: path.dirname(esbuildPath), + }); await ide.showToast( "info", @@ -572,13 +582,22 @@ async function tryBuildConfigTs() { } async function buildConfigTsWithBinary() { - execSync( - `${escapeSpacesInPath(getEsbuildBinaryPath())} ${escapeSpacesInPath( - getConfigTsPath(), - )} --bundle --outfile=${escapeSpacesInPath( - getConfigJsPath(), - )} --platform=node --format=cjs --sourcemap --external:fetch --external:fs --external:path --external:os --external:child_process`, - ); + const cmd = [ + escapeSpacesInPath(getEsbuildBinaryPath()), + escapeSpacesInPath(getConfigTsPath()), + "--bundle", + `--outfile=${escapeSpacesInPath(getConfigJsPath())}`, + "--platform=node", + "--format=cjs", + "--sourcemap", + "--external:fetch", + "--external:fs", + "--external:path", + "--external:os", + "--external:child_process", + ].join(" "); + + execSync(cmd); } async function buildConfigTsWithNodeModule() { @@ -597,15 +616,15 @@ async function buildConfigTsWithNodeModule() { function readConfigJs(): string | undefined { const configJsPath = getConfigJsPath(); + if (!fs.existsSync(configJsPath)) { return undefined; } + return fs.readFileSync(configJsPath, "utf8"); } async function buildConfigTs(ide: IDE, ideType: IdeType) { - // TODO: Remove - await ide.showToast("info", "test toast"); const configTsPath = getConfigTsPath(); if (!fs.existsSync(configTsPath)) { diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index ddc14bbd0..9e5641332 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; -import { getGlobalContextFilePath } from "./paths.js"; -import { EmbeddingsProvider } from "../index.js"; +import { getGlobalContextFilePath } from "./paths"; +import { EmbeddingsProvider } from "../"; export type GlobalContextType = { indexingPaused: boolean; @@ -13,7 +13,7 @@ export type GlobalContextType = { * For VS Code users, it is unnecessary since we use transformers.js by default. */ curEmbeddingsProviderId: EmbeddingsProvider["id"]; - hasReceivedConfigTsNoticeJetBrains: boolean; + hasDismissedConfigTsNoticeJetBrains: boolean; }; /** diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts index 59ce509e3..87f0a0374 100644 --- a/extensions/intellij/build.gradle.kts +++ b/extensions/intellij/build.gradle.kts @@ -29,13 +29,13 @@ dependencies { exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib") } implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32") - implementation("io.ktor:ktor-server-core:2.3.7"){ + implementation("io.ktor:ktor-server-core:2.3.7") { exclude(group = "org.slf4j", module = "slf4j-api") } implementation("io.ktor:ktor-server-netty:2.3.7") { exclude(group = "org.slf4j", module = "slf4j-api") } - implementation("io.ktor:ktor-server-cors:2.3.7"){ + implementation("io.ktor:ktor-server-cors:2.3.7") { exclude(group = "org.slf4j", module = "slf4j-api") } implementation("com.posthog.java:posthog:1.+") @@ -106,26 +106,13 @@ tasks { val start = "" val end = "" - with (it.lines()) { + with(it.lines()) { if (!containsAll(listOf(start, end))) { throw GradleException("Plugin description section not found in README.md:\n$start ... $end") } subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) } } -// -// val changelog = project.changelog // local variable for configuration cache compatibility -// // Get the latest available change notes from the changelog file -// changeNotes = properties("pluginVersion").map { pluginVersion -> -// with(changelog) { -// renderItem( -// (getOrNull(pluginVersion) ?: getUnreleased()) -// .withHeader(false) -// .withEmptySections(false), -// Changelog.OutputType.HTML, -// ) -// } -// } } // Configure UI tests plugin diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index b4c03eca8..ff32b1af8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -28,7 +28,7 @@ class CoreMessenger( private val gson = Gson() private val responseListeners = mutableMapOf Unit>() private val ideProtocolClient = ideProtocolClient - private val useTcp: Boolean = false // TODO: Set to `false` + private val useTcp: Boolean = false private fun write(message: String) { try { writer?.write(message + "\r\n") diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index fb9b89174..f523451f7 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -16,10 +16,9 @@ import com.intellij.execution.util.ExecUtil import com.intellij.ide.plugins.PluginManager import com.intellij.ide.plugins.PluginManagerCore import com.intellij.lang.annotation.HighlightSeverity -import com.intellij.notification.NotificationDisplayType -import com.intellij.notification.NotificationGroup import com.intellij.notification.NotificationType import com.intellij.notification.NotificationAction +import com.intellij.notification.NotificationGroupManager import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager @@ -32,9 +31,9 @@ import com.intellij.openapi.editor.impl.DocumentMarkupModel import com.intellij.openapi.extensions.PluginId import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.fileEditor.FileEditorManager -import com.intellij.openapi.fileEditor.TextEditor import com.intellij.openapi.project.DumbAware import com.intellij.openapi.project.Project +import com.intellij.openapi.util.IconLoader import com.intellij.openapi.vfs.* import com.intellij.openapi.vfs.newvfs.events.VFileEvent import com.intellij.psi.PsiDocumentManager @@ -123,7 +122,6 @@ class IdeProtocolClient( private val project: Project ) : DumbAware { val diffManager = DiffManager(project) - private val CONTINUE_NOTIFICATION_GROUP = NotificationGroup("Continue", NotificationDisplayType.BALLOON, true) private val ripgrep: String init { @@ -216,7 +214,7 @@ class IdeProtocolClient( val sshClient = System.getenv("SSH_CLIENT") val sshTty = System.getenv("SSH_TTY") - var remoteName: String = "local" + var remoteName = "local" if (sshClient != null || sshTty != null) { remoteName = "ssh" } @@ -388,7 +386,6 @@ class IdeProtocolClient( "setSuggestionsLocked" -> {} "getSessionId" -> {} - // INDEXING // "getLastModified" -> { // TODO val data = data as Map @@ -449,7 +446,6 @@ class IdeProtocolClient( respond(output) } - // NEW // "getDiff" -> { val builder = ProcessBuilder("git", "diff") builder.directory(File(workspacePath ?: ".")) @@ -554,6 +550,7 @@ class IdeProtocolClient( } "openFile" -> { + setFileOpen((data as Map)["path"] as String) respond(null) } @@ -567,12 +564,10 @@ class IdeProtocolClient( val data = data as ArrayList val toastType = data[0] val message = data[1] - val buttonText = if (data.size > 2) data[2] else null + val buttons = data.drop(2).toTypedArray() - coroutineScope.launch { - val result = showToast(toastType, message, buttonText) - respond(result) - } + val result = showToast(toastType, message, buttons) + respond(result) } "listFolders" -> { @@ -931,30 +926,41 @@ class IdeProtocolClient( return virtualFile?.path } - suspend fun showToast(type: String, content: String, actionButtonText: String? = null): Boolean? = - withContext(Dispatchers.Main) { + suspend fun showToast(type: String, content: String, buttonTexts: Array = emptyArray()): String? = + withContext(Dispatchers.Default) { val notificationType = when (type.uppercase()) { "ERROR" -> NotificationType.ERROR "WARNING" -> NotificationType.WARNING else -> NotificationType.INFORMATION } - val deferred = CompletableDeferred() + val deferred = CompletableDeferred() + val icon = IconLoader.getIcon("/icons/continue.svg", javaClass) - val notification = CONTINUE_NOTIFICATION_GROUP.createNotification(content, notificationType) + val notification = NotificationGroupManager.getInstance().getNotificationGroup("Continue") + .createNotification(content, notificationType).setIcon(icon) - if (actionButtonText != null) { - notification.addAction(NotificationAction.create(actionButtonText) { _, _ -> - deferred.complete(true) + buttonTexts.forEach { buttonText -> + notification.addAction(NotificationAction.create(buttonText) { _, _ -> + deferred.complete(buttonText) notification.expire() }) - notification.whenExpired { - if (!deferred.isCompleted) { - deferred.complete(null) - } + } + + // This timeout is to handle the case where a user closes out of the notification, which should trigger + // the `whenExpired` event but that doesn't seem to be occurring. + launch { + delay(15000) + if (!deferred.isCompleted) { + deferred.complete(null) + notification.expire() + } + } + + notification.whenExpired { + if (!deferred.isCompleted) { + deferred.complete(null) } - } else { - deferred.complete(null) } notification.notify(project) diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index 3633201f8..572fe74b6 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -29,6 +29,8 @@ + messages.MyBundle @@ -163,6 +165,4 @@ - - From a03cbd397417cab5376f8c7118cde139512a7173 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 16:32:07 -0700 Subject: [PATCH 08/11] Update load.ts --- core/config/load.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/config/load.ts b/core/config/load.ts index f2ab7c9ba..af1a885cc 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -500,6 +500,8 @@ function escapeSpacesInPath(p: string): string { } async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { + // JetBrains is currently the only IDE that we've reached the plugin size limit and + // therefore need to install esbuild manually to reduce the size if (ideType !== "jetbrains") { return; } From 2bb97f4bb91817a50cf5e0e05becc6181f5ebd64 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 17:53:37 -0700 Subject: [PATCH 09/11] pull down binary directly --- core/config/load.ts | 71 +++++-- core/package-lock.json | 427 +++++++++++++++++++++++++++++++++++++++-- core/package.json | 1 + 3 files changed, 467 insertions(+), 32 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index af1a885cc..433d92cc0 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -1,6 +1,7 @@ import * as JSONC from "comment-json"; import * as fs from "fs"; import path from "path"; +import * as tar from "tar"; import { slashCommandFromDescription, slashFromCustomCommand, @@ -35,7 +36,7 @@ import { BaseLLM } from "../llm"; import CustomLLMClass from "../llm/llms/CustomLLM"; import FreeTrial from "../llm/llms/FreeTrial"; import { llmFromDescription } from "../llm/llms"; - +import os from "os"; import { execSync } from "child_process"; import CodebaseContextProvider from "../context/providers/CodebaseContextProvider"; import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider"; @@ -65,6 +66,7 @@ import { slashCommandFromPromptFile, } from "./promptFile"; import { GlobalContext } from "../util/GlobalContext"; +import { Readable } from "stream"; function resolveSerializedConfig(filepath: string): SerializedContinueConfig { let content = fs.readFileSync(filepath, "utf8"); @@ -546,26 +548,67 @@ async function promptEsbuildInstallation(ide: IDE): Promise { return res === installMsg; } -async function downloadAndInstallEsbuild(ide: IDE) { - const url = "https://esbuild.github.io/dl/v0.19.11"; +/** + * The download logic is adapted from here: https://esbuild.github.io/getting-started/#download-a-build + */ +async function downloadAndInstallEsbuild() { const esbuildPath = getEsbuildBinaryPath(); + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "esbuild-")); try { - const response = await fetch(url); - const script = await response.text(); + const platform = `${os.platform()} ${os.arch()}`; + const version = "0.19.11"; + const tgzPath = path.join(tempDir, `esbuild-${version}.tgz`); - execSync("sh", { - input: script, - stdio: ["pipe", "inherit", "inherit"], - cwd: path.dirname(esbuildPath), + let url; + switch (platform) { + case "darwin arm64": + url = `https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-${version}.tgz`; + break; + case "darwin x64": + url = `https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-${version}.tgz`; + break; + case "linux arm64": + url = `https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-${version}.tgz`; + break; + case "linux x64": + url = `https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-${version}.tgz`; + break; + default: + throw new Error(`Unsupported platform: ${platform}`); + } + + console.debug(`Downloading esbuild from: ${url}`); + execSync(`curl -fo "${tgzPath}" "${url}"`); + + console.debug(`Extracting tgz file to: ${tempDir}`); + await tar.x({ + file: tgzPath, + cwd: tempDir, + strip: 2, // Remove the top two levels of directories }); - await ide.showToast( - "info", - `'esbuild' successfully installed to ${esbuildPath}`, - ); + // Ensure the destination directory exists + const destDir = path.dirname(esbuildPath); + if (!fs.existsSync(destDir)) { + fs.mkdirSync(destDir, { recursive: true }); + } + + // Move the file + const extractedBinaryPath = path.join(tempDir, "esbuild"); + fs.renameSync(extractedBinaryPath, esbuildPath); + + // Ensure the binary is executable (not needed on Windows) + if (os.platform() !== "win32") { + fs.chmodSync(esbuildPath, 0o755); + } + + // Clean up + fs.unlinkSync(tgzPath); + fs.rmSync(tempDir, { recursive: true }); } catch (error) { - console.debug("Error downloading or saving esbuild binary:", error); + console.error("Error downloading or saving esbuild binary:", error); + throw error; } } diff --git a/core/package-lock.json b/core/package-lock.json index fe1e4c48d..7e5d49778 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -58,6 +58,7 @@ "sqlite": "^5.1.1", "sqlite3": "^5.1.7", "system-ca": "^1.0.3", + "tar": "^7.4.3", "tree-sitter-wasms": "^0.1.11", "uuid": "^9.0.1", "vectordb": "^0.4.20", @@ -3305,6 +3306,114 @@ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==" }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/fs-minipass": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", + "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", + "dependencies": { + "minipass": "^7.0.4" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@isaacs/fs-minipass/node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -4017,6 +4126,15 @@ "@octokit/openapi-types": "^22.2.0" } }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -6170,6 +6288,32 @@ "node": ">=10" } }, + "node_modules/cacache/node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "optional": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/cacache/node_modules/tar/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "optional": true, + "engines": { + "node": ">=8" + } + }, "node_modules/cacache/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -7054,6 +7198,11 @@ "url": "https://dotenvx.com" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" + }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -8068,6 +8217,32 @@ "is-callable": "^1.1.3" } }, + "node_modules/foreground-child": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -9283,6 +9458,20 @@ "node": ">=8" } }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", @@ -11040,6 +11229,38 @@ "node": ">= 10.12.0" } }, + "node_modules/node-gyp/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/node-gyp/node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "optional": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-gyp/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "optional": true + }, "node_modules/node-html-markdown": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/node-html-markdown/-/node-html-markdown-1.3.0.tgz", @@ -11552,6 +11773,11 @@ "node": ">= 14" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==" + }, "node_modules/pad-left": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/pad-left/-/pad-left-2.1.0.tgz", @@ -11655,6 +11881,29 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -13120,6 +13369,14 @@ } } }, + "node_modules/sqlite3/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "engines": { + "node": ">=8" + } + }, "node_modules/sqlite3/node_modules/node-addon-api": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.0.tgz", @@ -13128,6 +13385,27 @@ "node": "^16 || ^18 || >= 20" } }, + "node_modules/sqlite3/node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sqlite3/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/sqlstring": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.3.tgz", @@ -13253,6 +13531,20 @@ "node": ">=8" } }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/string.prototype.trim": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz", @@ -13310,6 +13602,18 @@ "node": ">=8" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", @@ -13420,19 +13724,19 @@ } }, "node_modules/tar": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", - "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz", + "integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==", "dependencies": { - "chownr": "^2.0.0", - "fs-minipass": "^2.0.0", - "minipass": "^5.0.0", - "minizlib": "^2.1.1", - "mkdirp": "^1.0.3", - "yallist": "^4.0.0" + "@isaacs/fs-minipass": "^4.0.0", + "chownr": "^3.0.0", + "minipass": "^7.1.2", + "minizlib": "^3.0.1", + "mkdirp": "^3.0.1", + "yallist": "^5.0.0" }, "engines": { - "node": ">=10" + "node": ">=18" } }, "node_modules/tar-fs": { @@ -13458,18 +13762,88 @@ "streamx": "^2.15.0" } }, - "node_modules/tar/node_modules/minipass": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", - "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "node_modules/tar/node_modules/chownr": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", + "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", "engines": { - "node": ">=8" + "node": ">=18" + } + }, + "node_modules/tar/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/tar/node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/tar/node_modules/minizlib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.1.tgz", + "integrity": "sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg==", + "dependencies": { + "minipass": "^7.0.4", + "rimraf": "^5.0.5" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/tar/node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/tar/node_modules/rimraf": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz", + "integrity": "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==", + "dependencies": { + "glob": "^10.3.7" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/tar/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", + "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "engines": { + "node": ">=18" + } }, "node_modules/test-exclude": { "version": "6.0.0", @@ -14274,6 +14648,23 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/core/package.json b/core/package.json index b04da182b..678a65572 100644 --- a/core/package.json +++ b/core/package.json @@ -88,6 +88,7 @@ "sqlite": "^5.1.1", "sqlite3": "^5.1.7", "system-ca": "^1.0.3", + "tar": "^7.4.3", "tree-sitter-wasms": "^0.1.11", "uuid": "^9.0.1", "vectordb": "^0.4.20", From f8087289b95ced3eecbcdfa1f41658aac14011dd Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 17:59:05 -0700 Subject: [PATCH 10/11] Update load.ts --- core/config/load.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/config/load.ts b/core/config/load.ts index 433d92cc0..71d7d649e 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -551,7 +551,7 @@ async function promptEsbuildInstallation(ide: IDE): Promise { /** * The download logic is adapted from here: https://esbuild.github.io/getting-started/#download-a-build */ -async function downloadAndInstallEsbuild() { +async function downloadAndInstallEsbuild(ide: IDE) { const esbuildPath = getEsbuildBinaryPath(); const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "esbuild-")); @@ -606,6 +606,11 @@ async function downloadAndInstallEsbuild() { // Clean up fs.unlinkSync(tgzPath); fs.rmSync(tempDir, { recursive: true }); + + await ide.showToast( + "info", + `'esbuild' successfully installed to ${esbuildPath}`, + ); } catch (error) { console.error("Error downloading or saving esbuild binary:", error); throw error; From d00119b8febf35253b2aabaa8d8adc8cca674735 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 15 Oct 2024 18:03:11 -0700 Subject: [PATCH 11/11] Update load.ts --- core/config/load.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 71d7d649e..0a2146d71 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -556,28 +556,11 @@ async function downloadAndInstallEsbuild(ide: IDE) { const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "esbuild-")); try { - const platform = `${os.platform()} ${os.arch()}`; + const target = `${os.platform()}-${os.arch()}`; const version = "0.19.11"; + const url = `https://registry.npmjs.org/@esbuild/${target}/-/${target}-${version}.tgz`; const tgzPath = path.join(tempDir, `esbuild-${version}.tgz`); - let url; - switch (platform) { - case "darwin arm64": - url = `https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-${version}.tgz`; - break; - case "darwin x64": - url = `https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-${version}.tgz`; - break; - case "linux arm64": - url = `https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-${version}.tgz`; - break; - case "linux x64": - url = `https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-${version}.tgz`; - break; - default: - throw new Error(`Unsupported platform: ${platform}`); - } - console.debug(`Downloading esbuild from: ${url}`); execSync(`curl -fo "${tgzPath}" "${url}"`);