install to .utils
This commit is contained in:
parent
c67e0449d9
commit
d39b6e69a5
6 changed files with 104 additions and 92 deletions
|
|
@ -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<boolean> {
|
||||
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)) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 = "<!-- Plugin description -->"
|
||||
val end = "<!-- Plugin description 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
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class CoreMessenger(
|
|||
private val gson = Gson()
|
||||
private val responseListeners = mutableMapOf<String, (Any?) -> 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")
|
||||
|
|
|
|||
|
|
@ -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<String, Any>
|
||||
|
|
@ -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<String, Any>)["path"] as String)
|
||||
respond(null)
|
||||
}
|
||||
|
|
@ -567,12 +564,10 @@ class IdeProtocolClient(
|
|||
val data = data as ArrayList<String>
|
||||
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<String> = emptyArray()): String? =
|
||||
withContext(Dispatchers.Default) {
|
||||
val notificationType = when (type.uppercase()) {
|
||||
"ERROR" -> NotificationType.ERROR
|
||||
"WARNING" -> NotificationType.WARNING
|
||||
else -> NotificationType.INFORMATION
|
||||
}
|
||||
|
||||
val deferred = CompletableDeferred<Boolean?>()
|
||||
val deferred = CompletableDeferred<String?>()
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
<statusBarWidgetFactory
|
||||
implementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteSpinnerWidgetFactory"
|
||||
id="AutocompleteSpinnerWidget"/>
|
||||
<notificationGroup id="Continue"
|
||||
displayType="BALLOON"/>
|
||||
</extensions>
|
||||
|
||||
<resource-bundle>messages.MyBundle</resource-bundle>
|
||||
|
|
@ -163,6 +165,4 @@
|
|||
<keyboard-shortcut first-keystroke="alt meta RIGHT" keymap="Mac OS X"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
|
||||
</idea-plugin>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue