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 ] 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/.vscode/launch.json b/.vscode/launch.json index 835c09089..60c99a924 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/.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 016afe9bd..3afd1811a 100644 --- a/binary/build.js +++ b/binary/build.js @@ -270,24 +270,6 @@ 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( @@ -295,9 +277,6 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) { `${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 +284,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`, 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 67982ecad..0a2146d71 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -1,15 +1,16 @@ import * as JSONC from "comment-json"; import * as fs from "fs"; import path from "path"; +import * as tar from "tar"; 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,40 +29,44 @@ 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 os from "os"; 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, getConfigJsPathForRemote, getConfigJsonPath, getConfigJsonPathForRemote, getConfigTsPath, getContinueDotEnv, + 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"; +} from "./promptFile"; +import { GlobalContext } from "../util/GlobalContext"; +import { Readable } from "stream"; function resolveSerializedConfig(filepath: string): SerializedContinueConfig { let content = fs.readFileSync(filepath, "utf8"); @@ -492,80 +497,184 @@ 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, "\\ "); } -async function buildConfigTs() { - if (!fs.existsSync(getConfigTsPath())) { - return undefined; +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; } + const globalContext = new GlobalContext(); + if (globalContext.get("hasDismissedConfigTsNoticeJetBrains")) { + return; + } + + const esbuildPath = getEsbuildBinaryPath(); + + if (fs.existsSync(esbuildPath)) { + return; + } + + console.debug("No esbuild binary detected"); + + const shouldInstall = await promptEsbuildInstallation(ide); + + if (shouldInstall) { + await downloadAndInstallEsbuild(ide); + } +} + +async function promptEsbuildInstallation(ide: IDE): Promise { + 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?", + dismissMsg, + installMsg, + ); + + if (res === dismissMsg) { + const globalContext = new GlobalContext(); + globalContext.update("hasDismissedConfigTsNoticeJetBrains", true); + return false; + } + + return res === installMsg; +} + +/** + * The download logic is adapted from here: https://esbuild.github.io/getting-started/#download-a-build + */ +async function downloadAndInstallEsbuild(ide: IDE) { + const esbuildPath = getEsbuildBinaryPath(); + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "esbuild-")); + + try { + 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`); + + 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 + }); + + // 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 }); + + await ide.showToast( + "info", + `'esbuild' successfully installed to ${esbuildPath}`, + ); + } catch (error) { + console.error("Error downloading or saving esbuild binary:", error); + throw error; + } +} + +async function tryBuildConfigTs() { 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`, - ); + await buildConfigTsWithBinary(); } else { - // Dynamic import esbuild so potentially disastrous errors can be caught - const esbuild = await import("esbuild"); - - await esbuild.build({ - entryPoints: [getConfigTsPath()], - bundle: true, - platform: "node", - format: "cjs", - outfile: getConfigJsPath(), - external: ["fetch", "fs", "path", "os", "child_process"], - sourcemap: true, - }); + await buildConfigTsWithNodeModule(); } } catch (e) { console.log( `Build error. Please check your ~/.continue/config.ts file: ${e}`, ); + } +} + +async function buildConfigTsWithBinary() { + 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() { + 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; } - if (!fs.existsSync(getConfigJsPath())) { - return undefined; + return fs.readFileSync(configJsPath, "utf8"); +} + +async function buildConfigTs(ide: IDE, ideType: IdeType) { + const configTsPath = getConfigTsPath(); + + if (!fs.existsSync(configTsPath)) { + return; } - return fs.readFileSync(getConfigJsPath(), "utf8"); + + const currentContent = fs.readFileSync(configTsPath, "utf8"); + + // If the user hasn't modified the default config.ts, don't bother building + if (currentContent.trim() === DEFAULT_CONFIG_TS_CONTENTS.trim()) { + return; + } + + await handleEsbuildInstallation(ide, ideType); + await tryBuildConfigTs(); + + return readConfigJs(); } async function loadFullConfigNode( @@ -590,7 +699,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/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", diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 3880b4609..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,6 +13,7 @@ export type GlobalContextType = { * For VS Code users, it is unnecessary since we use transformers.js by default. */ curEmbeddingsProviderId: EmbeddingsProvider["id"]; + hasDismissedConfigTsNoticeJetBrains: 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/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/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/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 0d2c61941..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 @@ -29,7 +29,6 @@ class CoreMessenger( private val responseListeners = mutableMapOf Unit>() private val ideProtocolClient = ideProtocolClient private val useTcp: Boolean = false - private fun write(message: String) { try { writer?.write(message + "\r\n") @@ -98,7 +97,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..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,9 +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 @@ -31,18 +31,13 @@ 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.ui.MessageType -import com.intellij.openapi.ui.popup.Balloon -import com.intellij.openapi.ui.popup.JBPopupFactory +import com.intellij.openapi.util.IconLoader 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 @@ -53,81 +48,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() @@ -166,13 +96,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( @@ -189,18 +113,15 @@ 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 ) : DumbAware { val diffManager = DiffManager(project) - private val CONTINUE_NOTIFICATION_GROUP = NotificationGroup("Continue", NotificationDisplayType.BALLOON, true) private val ripgrep: String init { @@ -293,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" } @@ -465,7 +386,6 @@ class IdeProtocolClient( "setSuggestionsLocked" -> {} "getSessionId" -> {} - // INDEXING // "getLastModified" -> { // TODO val data = data as Map @@ -526,7 +446,6 @@ class IdeProtocolClient( respond(output) } - // NEW // "getDiff" -> { val builder = ProcessBuilder("git", "diff") builder.directory(File(workspacePath ?: ".")) @@ -631,6 +550,7 @@ class IdeProtocolClient( } "openFile" -> { + setFileOpen((data as Map)["path"] as String) respond(null) } @@ -642,10 +562,12 @@ 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 buttons = data.drop(2).toTypedArray() + + val result = showToast(toastType, message, buttons) + respond(result) } "listFolders" -> { @@ -742,25 +664,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 @@ -904,11 +807,6 @@ class IdeProtocolClient( fun sendHighlightedCode(edit: Boolean = false) { val rif = getHighlightedCode() ?: return -// send("highlightedCodePush", uuid(), HighlightedCodeUpdate( -// listOf(rif), -// edit -// )) - continuePluginService.sendToWebview( "highlightedCode", mapOf( @@ -918,9 +816,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()) @@ -1031,64 +926,55 @@ 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 - } - - CONTINUE_NOTIFICATION_GROUP.createNotification(content, notificationType) - .notify(project); - } - - 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 + 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 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 deferred = CompletableDeferred() + val icon = IconLoader.getIcon("/icons/continue.svg", javaClass) - val markupModel = editor!!.markupModel -// val textAttributes = TextAttributes(Color.decode(color.drop(1).toInt(color)), null, null, null, 0) + val notification = NotificationGroupManager.getInstance().getNotificationGroup("Continue") + .createNotification(content, notificationType).setIcon(icon) -// markupModel.addRangeHighlighter(startIdx, endIdx, 0, textAttributes, HighlighterTargetArea.EXACT_RANGE) + buttonTexts.forEach { buttonText -> + notification.addAction(NotificationAction.create(buttonText) { _, _ -> + deferred.complete(buttonText) + notification.expire() + }) + } + + // 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) + } + } + + notification.notify(project) + + deferred.await() } + + + fun highlightCode(rangeInFile: RangeInFile, color: String?) { + setFileOpen(rangeInFile.filepath, true) } 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 { @@ -1096,48 +982,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 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 @@ - - 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");