From 2e9f005bafa006fcf5528a461e0d541d67f64772 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 14:53:45 -0700 Subject: [PATCH 01/67] getFileresults --- core/index.d.ts | 2 + core/protocol/ide.ts | 1 + core/protocol/messenger/messageIde.ts | 4 + core/protocol/messenger/reverseMessageIde.ts | 4 + core/util/filesystem.ts | 4 + .../constants/MessageTypes.kt | 1 + .../continue/IdeProtocolClient.kt | 9 +++ .../continue/IntelliJIde.kt | 27 +++++++ .../continueintellijextension/protocol/ide.kt | 1 + .../continueintellijextension/types.kt | 2 + extensions/vscode/src/VsCodeIde.ts | 79 ++++++++++--------- .../vscode/src/extension/VsCodeMessenger.ts | 5 +- 12 files changed, 99 insertions(+), 40 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index ba97377d3..5078dcca3 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -709,6 +709,8 @@ export interface IDE { getSearchResults(query: string): Promise; + getFileResults(pattern: string): Promise; + subprocess(command: string, cwd?: string): Promise<[string, string]>; getProblems(fileUri?: string | undefined): Promise; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 5b2a7ab1f..e165f9858 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -31,6 +31,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { openUrl: [string, void]; runCommand: [{ command: string; options?: TerminalOptions }, void]; getSearchResults: [{ query: string }, string]; + getFileResults: [{ pattern: string }, string[]]; subprocess: [{ command: string; cwd?: string }, [string, string]]; saveFile: [{ filepath: string }, void]; fileExists: [{ filepath: string }, boolean]; diff --git a/core/protocol/messenger/messageIde.ts b/core/protocol/messenger/messageIde.ts index 4bb78e0ed..5d541225b 100644 --- a/core/protocol/messenger/messageIde.ts +++ b/core/protocol/messenger/messageIde.ts @@ -187,6 +187,10 @@ export class MessageIde implements IDE { return this.request("getSearchResults", { query }); } + getFileResults(pattern: string): Promise { + return this.request("getFileResults", { pattern }); + } + getProblems(fileUri: string): Promise { return this.request("getProblems", { filepath: fileUri }); } diff --git a/core/protocol/messenger/reverseMessageIde.ts b/core/protocol/messenger/reverseMessageIde.ts index 620055a75..8cd1cfbd6 100644 --- a/core/protocol/messenger/reverseMessageIde.ts +++ b/core/protocol/messenger/reverseMessageIde.ts @@ -166,6 +166,10 @@ export class ReverseMessageIde { return this.ide.getSearchResults(data.query); }); + this.on("getFileResults", (data) => { + return this.ide.getFileResults(data.pattern); + }); + this.on("getProblems", (data) => { return this.ide.getProblems(data.filepath); }); diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 3c6963071..c59eb3320 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -238,6 +238,10 @@ class FileSystemIde implements IDE { return ""; } + async getFileResults(pattern: string): Promise { + return []; + } + async getProblems(fileUri?: string | undefined): Promise { return Promise.resolve([]); } 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 b9546aa63..a0d19c7f9 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 @@ -23,6 +23,7 @@ class MessageTypes { "getCurrentFile", "getPinnedFiles", "getSearchResults", + "getFileResults", "getProblems", "subprocess", "getBranch", 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 95270f26b..f820084a0 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 @@ -347,6 +347,15 @@ class IdeProtocolClient( respond(results) } + "getFileResults" -> { + val params = Gson().fromJson( + dataElement.toString(), + GetFileResultsParams::class.java + ) + val results = ide.getFileResults(params.pattern) + respond(results) + } + "getOpenFiles" -> { val openFiles = ide.getOpenFiles() respond(openFiles) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 7e68cf007..8645d3190 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -309,7 +309,34 @@ class IntelliJIDE( return getOpenFiles() } + override suspend fun getFileResults(pattern: String): List { + return listOf("") + } + override suspend fun getSearchResults(query: String): String { + // return withContext(Dispatchers.IO) { + // val findModel = FindModel().apply { + // stringToFind = query + // isRegularExpressions = false + // isWholeWordsOnly = false + // isCaseSensitive = false + // searchContext = UsageSearchContext.ANY + // } + + // val results = StringBuilder() + // runReadAction { + // FindInProjectUtil.findUsages( + // findModel, + // project.baseDir, + // { + // results.append("${it.file.path}:${it.line + 1}: ${it.lineText}\n") + // true + // }, + // null + // ) + // } + // results.toString() + // } val command = GeneralCommandLine(ripgrep, "-i", "-C", "2", "--heading", "-e", query, ".") command.setWorkDirectory(project.basePath) return ExecUtil.execAndGetOutput(command).stdout diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt index 5ce49e80a..4c66fcc0c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt @@ -23,6 +23,7 @@ typealias getTagsParams = String data class GetSearchResultsParams(val query: String) +data class GetFileResultsParams(val pattern: String) data class SaveFileParams(val filepath: String) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt index 5d340ede0..2970ca84a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt @@ -159,6 +159,8 @@ interface IDE { suspend fun getSearchResults(query: String): String + suspend fun getFileResults(pattern: String): List + // Note: This should be a `Pair` but we use `List` because the keys of `Pair` // will serialize to `first and `second` rather than `0` and `1` like in JavaScript suspend fun subprocess(command: String, cwd: String? = null): List diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 883039263..fba82e86d 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -555,50 +555,51 @@ class VsCodeIde implements IDE { .map((t) => (t.input as vscode.TabInputText).uri.toString()); } - private async _searchDir(query: string, dir: string): Promise { - const relativeDir = vscode.Uri.parse(dir).fsPath; - const ripGrepUri = vscode.Uri.joinPath( - getExtensionUri(), - "out/node_modules/@vscode/ripgrep/bin/rg", - ); - const p = child_process.spawn( - ripGrepUri.fsPath, - [ - "-i", // Case-insensitive search - "-C", - "2", // Show 2 lines of context - "--heading", // Only show filepath once per result - "-e", - query, // Pattern to search for - ".", // Directory to search in - ], - { cwd: relativeDir }, - ); - let output = ""; - - p.stdout.on("data", (data) => { - output += data.toString(); - }); - - return new Promise((resolve, reject) => { - p.on("error", reject); - p.on("close", (code) => { - if (code === 0) { - resolve(output); - } else if (code === 1) { - // No matches - resolve("No matches found"); - } else { - reject(new Error(`Process exited with code ${code}`)); - } - }); - }); + async getFileResults(pattern: string): Promise { + vscode.workspace.findFiles(""); + return []; } async getSearchResults(query: string): Promise { const results: string[] = []; for (const dir of await this.getWorkspaceDirs()) { - const dirResults = await this._searchDir(query, dir); + const relativeDir = vscode.Uri.parse(dir).fsPath; + const ripGrepUri = vscode.Uri.joinPath( + getExtensionUri(), + "out/node_modules/@vscode/ripgrep/bin/rg", + ); + const p = child_process.spawn( + ripGrepUri.fsPath, + [ + "-i", // Case-insensitive search + "-C", + "2", // Show 2 lines of context + "--heading", // Only show filepath once per result + "-e", + query, // Pattern to search for + ".", // Directory to search in + ], + { cwd: relativeDir }, + ); + let output = ""; + + p.stdout.on("data", (data) => { + output += data.toString(); + }); + + const dirResults = await new Promise((resolve, reject) => { + p.on("error", reject); + p.on("close", (code) => { + if (code === 0) { + resolve(output); + } else if (code === 1) { + // No matches + resolve("No matches found"); + } else { + reject(new Error(`Process exited with code ${code}`)); + } + }); + }); const keepLines: string[] = []; diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 23669305a..e0dc9ebef 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -18,6 +18,7 @@ import { stripImages } from "core/util/messageContent"; import { getUriPathBasename } from "core/util/uri"; import * as vscode from "vscode"; +import { ILLM } from "core"; import { VerticalDiffManager } from "../diff/vertical/manager"; import EditDecorationManager from "../quickEdit/EditDecorationManager"; import { @@ -28,7 +29,6 @@ import { showTutorial } from "../util/tutorial"; import { getExtensionUri } from "../util/vscode"; import { VsCodeIde } from "../VsCodeIde"; import { VsCodeWebviewProtocol } from "../webviewProtocol"; -import { ILLM } from "core"; /** * A shared messenger class between Core and Webview @@ -391,6 +391,9 @@ export class VsCodeMessenger { this.onWebviewOrCore("getSearchResults", async (msg) => { return ide.getSearchResults(msg.data.query); }); + this.onWebviewOrCore("getFileResults", async (msg) => { + return ide.getFileResults(msg.data.pattern); + }); this.onWebviewOrCore("subprocess", async (msg) => { return ide.subprocess(msg.data.command, msg.data.cwd); }); From b9e4737c775cd5bdd406117280f2a0ded98f2432 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 15:19:34 -0700 Subject: [PATCH 02/67] glob search --- core/tools/builtIn.ts | 3 +- core/tools/callTool.ts | 9 +++-- core/tools/definitions/globSearch.ts | 26 ++++++++++++ .../{exactSearch.ts => grepSearch.ts} | 8 ++-- core/tools/implementations/globSearch.ts | 12 ++++++ .../{exactSearch.ts => grepSearch.ts} | 2 +- core/tools/index.ts | 6 ++- .../continue/IntelliJIde.kt | 40 ++++++++++++++++++- extensions/vscode/src/VsCodeIde.ts | 3 ++ gui/src/redux/slices/uiSlice.ts | 5 +-- 10 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 core/tools/definitions/globSearch.ts rename core/tools/definitions/{exactSearch.ts => grepSearch.ts} (77%) create mode 100644 core/tools/implementations/globSearch.ts rename core/tools/implementations/{exactSearch.ts => grepSearch.ts} (76%) diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index fa76358c9..fac75090b 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -3,7 +3,8 @@ export enum BuiltInToolNames { ReadCurrentlyOpenFile = "builtin_read_currently_open_file", CreateNewFile = "builtin_create_new_file", RunTerminalCommand = "builtin_run_terminal_command", - ExactSearch = "builtin_exact_search", + GrepSearch = "builtin_grep_search", + FileGlobSearch = "builtin_file_glob_search", SearchWeb = "builtin_search_web", ViewDiff = "builtin_view_diff", LSTool = "builtin_ls", diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 25c56507c..cf8874533 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -4,7 +4,8 @@ import { canParseUrl } from "../util/url"; import { BuiltInToolNames } from "./builtIn"; import { createNewFileImpl } from "./implementations/createNewFile"; -import { exactSearchImpl } from "./implementations/exactSearch"; +import { fileGlobSearchImpl } from "./implementations/globSearch"; +import { grepSearchImpl } from "./implementations/grepSearch"; import { lsToolImpl } from "./implementations/lsTool"; import { readCurrentlyOpenFileImpl } from "./implementations/readCurrentlyOpenFile"; import { readFileImpl } from "./implementations/readFile"; @@ -140,8 +141,10 @@ export async function callTool( return await readFileImpl(args, extras); case BuiltInToolNames.CreateNewFile: return await createNewFileImpl(args, extras); - case BuiltInToolNames.ExactSearch: - return await exactSearchImpl(args, extras); + case BuiltInToolNames.GrepSearch: + return await grepSearchImpl(args, extras); + case BuiltInToolNames.FileGlobSearch: + return await fileGlobSearchImpl(args, extras); case BuiltInToolNames.RunTerminalCommand: return await runTerminalCommandImpl(args, extras); case BuiltInToolNames.SearchWeb: diff --git a/core/tools/definitions/globSearch.ts b/core/tools/definitions/globSearch.ts new file mode 100644 index 000000000..bff2d454c --- /dev/null +++ b/core/tools/definitions/globSearch.ts @@ -0,0 +1,26 @@ +import { Tool } from "../.."; +import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; + +export const globSearchTool: Tool = { + type: "function", + displayTitle: "Glob File Search", + wouldLikeTo: 'find file matches for "{{{ pattern }}}"', + isCurrently: 'finding file matches for "{{{ pattern }}}"', + hasAlready: 'retreived file matches for "{{{ pattern }}}"', + readonly: true, + group: BUILT_IN_GROUP_NAME, + function: { + name: BuiltInToolNames.FileGlobSearch, + description: "Search for files in the project", + parameters: { + type: "object", + required: ["pattern"], + properties: { + pattern: { + type: "string", + description: "Glob pattern for file path matching", + }, + }, + }, + }, +}; diff --git a/core/tools/definitions/exactSearch.ts b/core/tools/definitions/grepSearch.ts similarity index 77% rename from core/tools/definitions/exactSearch.ts rename to core/tools/definitions/grepSearch.ts index d20db3cec..b6b7b456f 100644 --- a/core/tools/definitions/exactSearch.ts +++ b/core/tools/definitions/grepSearch.ts @@ -1,17 +1,17 @@ import { Tool } from "../.."; import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; -export const exactSearchTool: Tool = { +export const grepSearchTool: Tool = { type: "function", - displayTitle: "Exact Search", + displayTitle: "Grep Search", wouldLikeTo: 'search for "{{{ query }}}" in the repository', isCurrently: 'getting search results for "{{{ query }}}"', hasAlready: 'retreived search results for "{{{ query }}}"', readonly: true, group: BUILT_IN_GROUP_NAME, function: { - name: BuiltInToolNames.ExactSearch, - description: "Perform an exact search over the repository using ripgrep.", + name: BuiltInToolNames.GrepSearch, + description: "Perform a search over the repository using ripgrep.", parameters: { type: "object", required: ["query"], diff --git a/core/tools/implementations/globSearch.ts b/core/tools/implementations/globSearch.ts new file mode 100644 index 000000000..2d74c533a --- /dev/null +++ b/core/tools/implementations/globSearch.ts @@ -0,0 +1,12 @@ +import { ToolImpl } from "."; + +export const fileGlobSearchImpl: ToolImpl = async (args, extras) => { + // const content = await extras.ide.getSearchResults(args.query); + return [ + { + name: "File results", + description: "Results from file glob search", + content: "", + }, + ]; +}; diff --git a/core/tools/implementations/exactSearch.ts b/core/tools/implementations/grepSearch.ts similarity index 76% rename from core/tools/implementations/exactSearch.ts rename to core/tools/implementations/grepSearch.ts index ae8f6fd02..cdbf747ea 100644 --- a/core/tools/implementations/exactSearch.ts +++ b/core/tools/implementations/grepSearch.ts @@ -1,6 +1,6 @@ import { ToolImpl } from "."; -export const exactSearchImpl: ToolImpl = async (args, extras) => { +export const grepSearchImpl: ToolImpl = async (args, extras) => { const content = await extras.ide.getSearchResults(args.query); return [ { diff --git a/core/tools/index.ts b/core/tools/index.ts index eea4ee79b..eb4d156d9 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -1,5 +1,6 @@ import { createNewFileTool } from "./definitions/createNewFile"; -import { exactSearchTool } from "./definitions/exactSearch"; +import { globSearchTool } from "./definitions/globSearch"; +import { grepSearchTool } from "./definitions/grepSearch"; import { lsTool } from "./definitions/lsTool"; import { readCurrentlyOpenFileTool } from "./definitions/readCurrentlyOpenFile"; import { readFileTool } from "./definitions/readFile"; @@ -12,7 +13,8 @@ export const allTools = [ createNewFileTool, runTerminalCommandTool, - exactSearchTool, + grepSearchTool, + globSearchTool, searchWebTool, viewDiffTool, readCurrentlyOpenFileTool, diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 8645d3190..84d62b680 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -26,6 +26,8 @@ import com.intellij.openapi.util.IconLoader import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.search.FilenameIndex +import com.intellij.psi.search.GlobalSearchScope import com.intellij.testFramework.LightVirtualFile import kotlinx.coroutines.* import java.awt.Toolkit @@ -37,6 +39,7 @@ import java.io.InputStreamReader import java.net.URI import java.nio.charset.Charset import java.nio.file.Paths +import org.apache.tools.ant.DirectoryScanner class IntelliJIDE( private val project: Project, @@ -310,10 +313,45 @@ class IntelliJIDE( } override suspend fun getFileResults(pattern: String): List { + // val scanner = DirectoryScanner().apply { + // includes = arrayOf(pattern) + // } + + // val projectBasePath = project.basePath ?: return emptyList() + + // return FilenameIndex.getAllFilesByExt(project, "*", GlobalSearchScope.projectScope(project)) + // .filter { virtualFile -> + // scanner.match(virtualFile.path.replace('\\', '/'), globPattern) + // } + // .map { it.path.removePrefix("$projectBasePath/") } return listOf("") } - override suspend fun getSearchResults(query: String): String { + // val findModel = FindModel().apply { + // stringToFind = searchText + // isRegularExpressions = false + // isWholeWordsOnly = false + // isCaseSensitive = false + // searchContext = FindModel.SearchContext.ANY + // isGlobal = true + // } + + // val findManager = FindManager.getInstance(project) + // val scope = GlobalSearchScope.projectScope(project) + + // FindInProjectUtil.findUsages( + // findModel, + // project.basePath, + // project, + // { + // // Process each found usage + // val virtualFile = it.virtualFile + // val lineNumber = it.line + // // Handle result + // }, + // scope + // ) + // return withContext(Dispatchers.IO) { // val findModel = FindModel().apply { // stringToFind = query diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index fba82e86d..5bc042ba5 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -561,6 +561,9 @@ class VsCodeIde implements IDE { } async getSearchResults(query: string): Promise { + if (vscode.env.remoteName) { + return "Exact search not supported for remote workspaces"; + } const results: string[] = []; for (const dir of await this.getWorkspaceDirs()) { const relativeDir = vscode.Uri.parse(dir).fsPath; diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 9ebf8969f..ba4801197 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -47,9 +47,8 @@ export const uiSlice = createSlice({ [BuiltInToolNames.ReadFile]: "allowedWithoutPermission", [BuiltInToolNames.CreateNewFile]: "allowedWithPermission", [BuiltInToolNames.RunTerminalCommand]: "allowedWithPermission", - [BuiltInToolNames.ViewSubdirectory]: "allowedWithoutPermission", - [BuiltInToolNames.ViewRepoMap]: "allowedWithoutPermission", - [BuiltInToolNames.ExactSearch]: "allowedWithoutPermission", + [BuiltInToolNames.GrepSearch]: "allowedWithoutPermission", + [BuiltInToolNames.FileGlobSearch]: "allowedWithoutPermission", [BuiltInToolNames.SearchWeb]: "allowedWithoutPermission", [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", [BuiltInToolNames.LSTool]: "allowedWithoutPermission", From 98d97721b29a364388a86d4a59f14b57e6aae6f0 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 3 Apr 2025 15:52:36 -0700 Subject: [PATCH 03/67] implementation of hub client --- packages/hub/.npmignore | 2 + packages/hub/jest.config.mjs | 20 + packages/hub/package-lock.json | 3831 ++++++++++++++++++++++++ packages/hub/package.json | 24 + packages/hub/src/ContinueHubClient.ts | 113 + packages/hub/src/IContinueHubClient.ts | 38 + packages/hub/src/index.ts | 2 + packages/hub/tsconfig.json | 23 + 8 files changed, 4053 insertions(+) create mode 100644 packages/hub/.npmignore create mode 100644 packages/hub/jest.config.mjs create mode 100644 packages/hub/package-lock.json create mode 100644 packages/hub/package.json create mode 100644 packages/hub/src/ContinueHubClient.ts create mode 100644 packages/hub/src/IContinueHubClient.ts create mode 100644 packages/hub/src/index.ts create mode 100644 packages/hub/tsconfig.json diff --git a/packages/hub/.npmignore b/packages/hub/.npmignore new file mode 100644 index 000000000..02818d352 --- /dev/null +++ b/packages/hub/.npmignore @@ -0,0 +1,2 @@ +.env +test \ No newline at end of file diff --git a/packages/hub/jest.config.mjs b/packages/hub/jest.config.mjs new file mode 100644 index 000000000..2592f3834 --- /dev/null +++ b/packages/hub/jest.config.mjs @@ -0,0 +1,20 @@ +import path from "path"; +import { fileURLToPath } from "url"; + +export default { + transform: { + "\\.[jt]sx?$": ["ts-jest", { useESM: true }], + }, + + moduleNameMapper: { + "(.+)\\.js": "$1", + }, + extensionsToTreatAsEsm: [".ts"], + preset: "ts-jest/presets/default-esm", + testTimeout: 10000, + testEnvironment: "node", + globals: { + __dirname: path.dirname(fileURLToPath(import.meta.url)), + __filename: path.resolve(fileURLToPath(import.meta.url)), + }, +}; diff --git a/packages/hub/package-lock.json b/packages/hub/package-lock.json new file mode 100644 index 000000000..bfc2041d5 --- /dev/null +++ b/packages/hub/package-lock.json @@ -0,0 +1,3831 @@ +{ + "name": "@continuedev/hub", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@continuedev/hub", + "version": "0.0.1", + "license": "Apache-2.0", + "dependencies": { + "@continuedev/config-yaml": "^1.0.70" + }, + "devDependencies": { + "@types/jest": "^29.5.14", + "cross-env": "^7.0.3", + "jest": "^29.7.0", + "ts-jest": "^29.2.3", + "ts-node": "^10.9.2" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", + "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.24.7", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.0.tgz", + "integrity": "sha512-P4fwKI2mjEb3ZU5cnMJzvRsRKGBUcs8jvxIoRmr6ufAY9Xk2Bz7JubRTTivkw55c7WQJfTECeqYVa+HZ0FzREg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", + "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.24.7", + "@babel/generator": "^7.24.9", + "@babel/helper-compilation-targets": "^7.24.8", + "@babel/helper-module-transforms": "^7.24.9", + "@babel/helpers": "^7.24.8", + "@babel/parser": "^7.24.8", + "@babel/template": "^7.24.7", + "@babel/traverse": "^7.24.8", + "@babel/types": "^7.24.9", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.0.tgz", + "integrity": "sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.25.0", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.8.tgz", + "integrity": "sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.24.8", + "@babel/helper-validator-option": "^7.24.8", + "browserslist": "^4.23.1", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", + "integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", + "dev": true, + "dependencies": { + "@babel/traverse": "^7.24.7", + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.0.tgz", + "integrity": "sha512-bIkOa2ZJYn7FHnepzr5iX9Kmz8FjIz4UKzJ9zhX3dnYuVW0xul9RuR3skBfoLu+FPTQw90EHW9rJsSZhyLQ3fQ==", + "dev": true, + "dependencies": { + "@babel/helper-module-imports": "^7.24.7", + "@babel/helper-simple-access": "^7.24.7", + "@babel/helper-validator-identifier": "^7.24.7", + "@babel/traverse": "^7.25.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.8.tgz", + "integrity": "sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", + "integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", + "dev": true, + "dependencies": { + "@babel/traverse": "^7.24.7", + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", + "integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", + "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz", + "integrity": "sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.0.tgz", + "integrity": "sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==", + "dev": true, + "dependencies": { + "@babel/template": "^7.25.0", + "@babel/types": "^7.25.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", + "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.24.7", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.0.tgz", + "integrity": "sha512-CzdIU9jdP0dg7HdyB+bHvDJGagUv+qtzZt5rYCWwW6tITNqV9odjp6Qu41gkG0ca5UfdDUWrKkiAnHHdGRnOrA==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.24.7.tgz", + "integrity": "sha512-6ddciUPe/mpMnOKv/U+RSd2vvVy+Yw/JfBB0ZHYjEZt9NLHmCUylNYlsbqCCS1Bffjlb0fCwC9Vqz+sBz6PsiQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.24.7.tgz", + "integrity": "sha512-c/+fVeJBB0FeKsFvwytYiUD+LBvhHjGSI0g446PRGdSVGZLRNArBUno2PETbAly3tpiNAQR5XaZ+JslxkotsbA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.0.tgz", + "integrity": "sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.24.7", + "@babel/parser": "^7.25.0", + "@babel/types": "^7.25.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.0.tgz", + "integrity": "sha512-ubALThHQy4GCf6mbb+5ZRNmLLCI7bJ3f8Q6LHBSRlSKSWj5a7dSUzJBLv3VuIhFrFPgjF4IzPF567YG/HSCdZA==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.24.7", + "@babel/generator": "^7.25.0", + "@babel/parser": "^7.25.0", + "@babel/template": "^7.25.0", + "@babel/types": "^7.25.0", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.0.tgz", + "integrity": "sha512-LcnxQSsd9aXOIgmmSpvZ/1yo46ra2ESYyqLcryaBZOghxy5qqOBjvCWP5JfkI8yl9rlxRgdLTTMCQQRcN2hdCg==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.24.8", + "@babel/helper-validator-identifier": "^7.24.7", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@continuedev/config-types": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz", + "integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==", + "dependencies": { + "zod": "^3.23.8" + } + }, + "node_modules/@continuedev/config-yaml": { + "version": "1.0.70", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.70.tgz", + "integrity": "sha512-0hwc2a2NyUDDNDAx23SOFfY4sV8EafuCow4JNpRzCz8swH3ZfO+vdOzKMIEzAzcYXcpjldsOAZsYE4iypu1L+Q==", + "dependencies": { + "@continuedev/config-types": "^1.0.14", + "yaml": "^2.6.1", + "zod": "^3.24.2" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "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", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz", + "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz", + "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/reporters": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.7.0", + "jest-config": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-resolve-dependencies": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "jest-watcher": "^29.7.0", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", + "dev": true, + "dependencies": { + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dev": true, + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz", + "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^6.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz", + "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz", + "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.8", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", + "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.6.tgz", + "integrity": "sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", + "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz", + "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz", + "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.5.14", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/node": { + "version": "18.19.39", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", + "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/stack-utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.32", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", + "integrity": "sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", + "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", + "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/async": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz", + "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==", + "dev": true + }, + "node_modules/babel-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", + "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==", + "dev": true, + "dependencies": { + "@jest/transform": "^29.7.0", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dev": true, + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", + "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dev": true, + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-top-level-await": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dev": true, + "dependencies": { + "babel-plugin-jest-hoist": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.23.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", + "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001640", + "electron-to-chromium": "^1.4.820", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.1.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001643", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", + "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.3.1.tgz", + "integrity": "sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==", + "dev": true + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, + "node_modules/create-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", + "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "prompts": "^2.0.1" + }, + "bin": { + "create-jest": "bin/create-jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/dedent": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz", + "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==", + "dev": true, + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "dev": true, + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.2.tgz", + "integrity": "sha512-kc4r3U3V3WLaaZqThjYz/Y6z8tJe+7K0bbjUVo3i+LWIypVdMx5nXCkwRe6SWbY6ILqLdc1rKcKmr3HoH7wjSQ==", + "dev": true + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/filelist": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "dev": true, + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/import-local": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", + "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==", + "dev": true, + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "node_modules/is-core-module": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "dev": true, + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jake": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz", + "integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==", + "dev": true, + "dependencies": { + "async": "^3.2.3", + "chalk": "^4.0.2", + "filelist": "^1.0.4", + "minimatch": "^3.1.2" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", + "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", + "dev": true, + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/types": "^29.6.3", + "import-local": "^3.0.2", + "jest-cli": "^29.7.0" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz", + "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==", + "dev": true, + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", + "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.7.0", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0", + "pretty-format": "^29.7.0", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", + "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==", + "dev": true, + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "create-jest": "^29.7.0", + "exit": "^0.1.2", + "import-local": "^3.0.2", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz", + "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-jest": "^29.7.0", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.7.0.tgz", + "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==", + "dev": true, + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.7.0.tgz", + "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "jest-util": "^29.7.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", + "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", + "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz", + "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz", + "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==", + "dev": true, + "dependencies": { + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz", + "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/environment": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-leak-detector": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-resolve": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-util": "^29.7.0", + "jest-watcher": "^29.7.0", + "jest-worker": "^29.7.0", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.7.0.tgz", + "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/globals": "^29.7.0", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", + "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "leven": "^3.1.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.7.0.tgz", + "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.7.0", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dev": true, + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node_modules/micromatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", + "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "dev": true, + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node_modules/node-releases": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/picocolors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", + "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pure-rand": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ] + }, + "node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "dev": true + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/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==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "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", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-jest": { + "version": "29.2.3", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.3.tgz", + "integrity": "sha512-yCcfVdiBFngVz9/keHin9EnsrQtQtEu3nRykNy9RVp+FiPFFbPJ3Sg6Qg4+TkmH0vMP5qsTKgXSsk80HRwvdgQ==", + "dev": true, + "dependencies": { + "bs-logger": "0.x", + "ejs": "^3.1.10", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "^7.5.3", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/transform": "^29.0.0", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/transform": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "dev": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/update-browserslist-db": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", + "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.2", + "picocolors": "^1.0.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/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==", + "dev": true, + "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", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + }, + "node_modules/yaml": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", + "integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zod": { + "version": "3.24.2", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", + "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/packages/hub/package.json b/packages/hub/package.json new file mode 100644 index 000000000..4996cccba --- /dev/null +++ b/packages/hub/package.json @@ -0,0 +1,24 @@ +{ + "name": "@continuedev/hub", + "version": "0.0.1", + "description": "", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "type": "module", + "scripts": { + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", + "build": "tsc" + }, + "author": "Continue Dev, Inc.", + "license": "Apache-2.0", + "dependencies": { + "@continuedev/config-yaml": "^1.0.70" + }, + "devDependencies": { + "@types/jest": "^29.5.14", + "cross-env": "^7.0.3", + "jest": "^29.7.0", + "ts-jest": "^29.2.3", + "ts-node": "^10.9.2" + } +} diff --git a/packages/hub/src/ContinueHubClient.ts b/packages/hub/src/ContinueHubClient.ts new file mode 100644 index 000000000..3c707bead --- /dev/null +++ b/packages/hub/src/ContinueHubClient.ts @@ -0,0 +1,113 @@ +import { + AssistantUnrolled, + ConfigResult, + FQSN, + FullSlug, + SecretResult, + SecretType, +} from "@continuedev/config-yaml"; +import { IContinueHubClient } from "./IContinueHubClient.js"; + +interface ContinueHubClientOptions { + apiKey: string; + apiBase?: string; +} + +export class ContinueHubClient implements IContinueHubClient { + private readonly apiKey: string; + private readonly apiBase: string; + + constructor(options: ContinueHubClientOptions) { + this.apiKey = options.apiKey; + this.apiBase = options.apiBase ?? "https://api.continue.dev"; + } + + private async request(path: string, init: RequestInit): Promise { + const url = new URL(path, this.apiBase).toString(); + const resp = await fetch(url, { + ...init, + headers: { + ...init.headers, + Authorization: `Bearer ${this.apiKey}`, + }, + }); + + if (!resp.ok) { + throw new Error( + `Control plane request failed: ${resp.status} ${await resp.text()}`, + ); + } + + return resp; + } + + async resolveFQSNs( + fqsns: FQSN[], + orgScopeId: string | null, + ): Promise<(SecretResult | undefined)[]> { + if (!this.apiKey) { + return fqsns.map((fqsn) => ({ + found: false, + fqsn, + secretLocation: { + secretName: fqsn.secretName, + secretType: SecretType.NotFound, + }, + })); + } + + const resp = await this.request("ide/sync-secrets", { + method: "POST", + body: JSON.stringify({ fqsns, orgScopeId }), + }); + return (await resp.json()) as any; + } + async listAssistants(organizationId: string | null): Promise< + { + configResult: ConfigResult; + ownerSlug: string; + packageSlug: string; + iconUrl: string; + rawYaml: string; + }[] + > { + if (!this.apiKey) { + return []; + } + + try { + const url = organizationId + ? `ide/list-assistants?organizationId=${organizationId}` + : "ide/list-assistants"; + + const resp = await this.request(url, { + method: "GET", + }); + return (await resp.json()) as any; + } catch (e) { + return []; + } + } + + async listAssistantFullSlugs( + organizationId: string | null, + ): Promise { + if (!this.apiKey) { + return null; + } + + const url = organizationId + ? `ide/list-assistant-full-slugs?organizationId=${organizationId}` + : "ide/list-assistant-full-slugs"; + + try { + const resp = await this.request(url, { + method: "GET", + }); + const { fullSlugs } = (await resp.json()) as any; + return fullSlugs; + } catch (e) { + return null; + } + } +} diff --git a/packages/hub/src/IContinueHubClient.ts b/packages/hub/src/IContinueHubClient.ts new file mode 100644 index 000000000..6ab2c5643 --- /dev/null +++ b/packages/hub/src/IContinueHubClient.ts @@ -0,0 +1,38 @@ +import { + AssistantUnrolled, + ConfigResult, + FQSN, + FullSlug, + SecretResult, +} from "@continuedev/config-yaml"; + +/** + * Interface for the Continue Hub client. + */ +export interface IContinueHubClient { + resolveFQSNs( + fqsns: FQSN[], + orgScopeId: string | null, + ): Promise<(SecretResult | undefined)[]>; + + /** + * Do a full reload of all assistants used in the organization by the user. + */ + listAssistants(organizationId: string | null): Promise< + { + configResult: ConfigResult; + ownerSlug: string; + packageSlug: string; + iconUrl: string; + rawYaml: string; + }[] + >; + + /** + * Get the list of FullSlugs (ownerSlug/packageSlug@versionSlug) for all assistant uses in the organization for the user. + * Can be used to poll for changes to assistants and then full reload when needed. + */ + listAssistantFullSlugs( + organizationId: string | null, + ): Promise; +} diff --git a/packages/hub/src/index.ts b/packages/hub/src/index.ts new file mode 100644 index 000000000..93a531842 --- /dev/null +++ b/packages/hub/src/index.ts @@ -0,0 +1,2 @@ +export * from "./ContinueHubClient.js"; +export * from "./IContinueHubClient.js"; diff --git a/packages/hub/tsconfig.json b/packages/hub/tsconfig.json new file mode 100644 index 000000000..63587b995 --- /dev/null +++ b/packages/hub/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "NodeNext", + "useDefineForClassFields": true, + "lib": ["DOM", "ESNext"], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "NodeNext", + "resolveJsonModule": true, + "isolatedModules": false, + "noEmitOnError": false, + "types": ["node", "jest"], + "outDir": "dist", + "declaration": true + // "sourceMap": true + }, + "include": ["src/**/*"] +} From 67888c7cfe2427183d943c22ce972725d89eb849 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 16:04:20 -0700 Subject: [PATCH 04/67] grep search cleanup, glob search tool --- .../providers/SearchContextProvider.ts | 4 +- core/tools/implementations/globSearch.ts | 4 +- core/tools/implementations/grepSearch.ts | 5 +- core/util/grepSearch.ts | 61 +++++++++++++++++++ extensions/vscode/package-lock.json | 4 +- extensions/vscode/src/VsCodeIde.ts | 50 ++------------- 6 files changed, 76 insertions(+), 52 deletions(-) create mode 100644 core/util/grepSearch.ts diff --git a/core/context/providers/SearchContextProvider.ts b/core/context/providers/SearchContextProvider.ts index bc44964ac..ec75994c3 100644 --- a/core/context/providers/SearchContextProvider.ts +++ b/core/context/providers/SearchContextProvider.ts @@ -3,6 +3,7 @@ import { ContextProviderDescription, ContextProviderExtras, } from "../../index.js"; +import { formatGrepSearchResults } from "../../util/grepSearch.js"; import { BaseContextProvider } from "../index.js"; class SearchContextProvider extends BaseContextProvider { @@ -19,10 +20,11 @@ class SearchContextProvider extends BaseContextProvider { extras: ContextProviderExtras, ): Promise { const results = await extras.ide.getSearchResults(query); + const formatted = formatGrepSearchResults(results); return [ { description: "Search results", - content: `Results of searching codebase for "${query}":\n\n${results}`, + content: `Results of searching codebase for "${query}":\n\n${formatted}`, name: "Search results", }, ]; diff --git a/core/tools/implementations/globSearch.ts b/core/tools/implementations/globSearch.ts index 2d74c533a..c0b214357 100644 --- a/core/tools/implementations/globSearch.ts +++ b/core/tools/implementations/globSearch.ts @@ -1,12 +1,12 @@ import { ToolImpl } from "."; export const fileGlobSearchImpl: ToolImpl = async (args, extras) => { - // const content = await extras.ide.getSearchResults(args.query); + const results = await extras.ide.getFileResults(args.pattern); return [ { name: "File results", description: "Results from file glob search", - content: "", + content: results.join("\n"), }, ]; }; diff --git a/core/tools/implementations/grepSearch.ts b/core/tools/implementations/grepSearch.ts index cdbf747ea..d618791e8 100644 --- a/core/tools/implementations/grepSearch.ts +++ b/core/tools/implementations/grepSearch.ts @@ -1,12 +1,13 @@ import { ToolImpl } from "."; +import { formatGrepSearchResults } from "../../util/grepSearch"; export const grepSearchImpl: ToolImpl = async (args, extras) => { - const content = await extras.ide.getSearchResults(args.query); + const results = await extras.ide.getSearchResults(args.query); return [ { name: "Search results", description: "Results from exact search", - content, + content: formatGrepSearchResults(results), }, ]; }; diff --git a/core/util/grepSearch.ts b/core/util/grepSearch.ts new file mode 100644 index 000000000..a30982e77 --- /dev/null +++ b/core/util/grepSearch.ts @@ -0,0 +1,61 @@ +export function formatGrepSearchResults(results: string): string { + const keepLines: string[] = []; + + function countLeadingSpaces(line: string) { + return line?.match(/^ */)?.[0].length ?? 0; + } + + const processResult = (lines: string[]) => { + // Skip results in which only the file path was kept + const resultPath = lines[0]; + const resultContent = lines.slice(1); + if (resultContent.length === 0) { + return; + } + + // Add path + keepLines.push(resultPath); + + // Find the minimum indentation of content lines + let minIndent = Infinity; + for (const line of resultContent) { + const indent = countLeadingSpaces(line); + if (indent < minIndent) { + minIndent = indent; + } + } + + // Make all lines line up to 2-space indent + const changeIndentBy = 2 - minIndent; + if (changeIndentBy === 0) { + keepLines.push(...resultContent); + } else if (changeIndentBy < 0) { + keepLines.push( + ...resultContent.map((line) => line.substring(-changeIndentBy)), + ); + } else { + keepLines.push( + ...resultContent.map((line) => " ".repeat(changeIndentBy) + line), + ); + } + }; + + let resultLines: string[] = []; + for (const line of results.split("\n").filter((l) => !!l)) { + if (line.startsWith("./") || line === "--") { + processResult(resultLines); // process previous result + resultLines = [line]; + continue; + } + + // Exclude leading zero- or single-char lines + if (resultLines.length === 1 && line.trim().length <= 1) { + continue; + } + + resultLines.push(line); + } + processResult(resultLines); + + return keepLines.join("\n"); +} diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c01a1eb12..a26290f1a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.18", + "version": "1.1.19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.18", + "version": "1.1.19", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 5bc042ba5..ba8f791ca 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -556,13 +556,13 @@ class VsCodeIde implements IDE { } async getFileResults(pattern: string): Promise { - vscode.workspace.findFiles(""); - return []; + // vscode.workspace.findFiles(""); + return ["file1", "file2"]; } async getSearchResults(query: string): Promise { if (vscode.env.remoteName) { - return "Exact search not supported for remote workspaces"; + return "Ripgrep not supported, this workspace is remote"; } const results: string[] = []; for (const dir of await this.getWorkspaceDirs()) { @@ -604,50 +604,10 @@ class VsCodeIde implements IDE { }); }); - const keepLines: string[] = []; - - function countLeadingSpaces(line: string) { - return line?.match(/^ */)?.[0].length ?? 0; - } - - // function formatLine(line: string, sectionIndent: number): string { - // return line.replace(new RegExp(`^[ ]{0,${sectionIndent}}`), ""); - // } - - let leading = false; - let sectionIndent = 0; - // let sectionTrim = 0; - for (const line of dirResults.split("\n").filter((l) => !!l)) { - if (line.startsWith("./") || line === "--") { - leading = true; - keepLines.push(line); - continue; - } - - if (leading) { - // Exclude leading single-char lines - if (line.trim().length > 1) { - // Record spacing at first non-single char line - leading = false; - sectionIndent = countLeadingSpaces(line); - keepLines.push(line); - } - continue; - } - // Exclude trailing - // TODO may exclude wanted results for lines that look like - // ./filename - // thisThing - // relevantThing - // - if (countLeadingSpaces(line) >= sectionIndent) { - keepLines.push(line); - } - } - results.push(keepLines.join("\n")); + results.push(dirResults); } - return results.join("\n\n"); + return results.join("\n"); } async getProblems(fileUri?: string | undefined): Promise { From 3505e1709dad53933ac6164ba810ad4461ea1dac Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 3 Apr 2025 16:36:36 -0700 Subject: [PATCH 05/67] optional apiKey --- packages/hub/src/ContinueHubClient.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/hub/src/ContinueHubClient.ts b/packages/hub/src/ContinueHubClient.ts index 3c707bead..87ce14c9c 100644 --- a/packages/hub/src/ContinueHubClient.ts +++ b/packages/hub/src/ContinueHubClient.ts @@ -9,12 +9,12 @@ import { import { IContinueHubClient } from "./IContinueHubClient.js"; interface ContinueHubClientOptions { - apiKey: string; + apiKey?: string; apiBase?: string; } export class ContinueHubClient implements IContinueHubClient { - private readonly apiKey: string; + private readonly apiKey?: string; private readonly apiBase: string; constructor(options: ContinueHubClientOptions) { @@ -24,13 +24,15 @@ export class ContinueHubClient implements IContinueHubClient { private async request(path: string, init: RequestInit): Promise { const url = new URL(path, this.apiBase).toString(); - const resp = await fetch(url, { - ...init, - headers: { + + if (this.apiKey) { + init.headers = { ...init.headers, Authorization: `Bearer ${this.apiKey}`, - }, - }); + }; + } + + const resp = await fetch(url, init); if (!resp.ok) { throw new Error( From 9df325a71f3340c46820ac5335249095cda443ac Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 3 Apr 2025 16:51:42 -0700 Subject: [PATCH 06/67] feat: prompt blocks --- .continue/rules/use-tailwind-not-styled.md | 3 + core/index.d.ts | 1 + .../ConversationStarterCards.tsx | 32 +- gui/src/components/FileIcon.tsx | 6 +- .../gui/HeaderButtonWithToolTip.tsx | 2 +- .../components/mainInput/ContinueInputBox.tsx | 2 +- .../Lump/sections/docs/DocsIndexingStatus.tsx | 9 +- .../{tiptap => TipTapEditor}/DragOverlay.tsx | 0 .../StyledComponents.ts | 0 .../{tiptap => TipTapEditor}/TipTapEditor.css | 0 .../{tiptap => TipTapEditor}/TipTapEditor.tsx | 7 +- .../extensions/AddCodeToEditExtension.ts | 19 +- .../extensions/CodeBlockExtension.tsx | 8 +- .../extensions/MentionExtension.ts | 19 +- .../extensions/PromptExtension.ts | 81 ++++ .../extensions/SlashCommandExtension.ts} | 75 +++- .../TipTapEditor/extensions/index.ts | 5 + .../TipTapEditor/extensions/types.ts | 11 + .../toolbar-previews/CodeblockPreview.tsx | 100 +++++ .../toolbar-previews/ExpandablePreview.tsx | 186 ++++++++++ .../toolbar-previews/PromptBlockPreview.tsx | 61 ++++ .../TipTapEditor/toolbar-previews/index.ts | 2 + .../useWebviewListeners.ts | 6 +- .../utils}/editorConfig.ts | 59 ++- .../utils}/getSuggestion.ts | 25 +- .../utils}/imageUtils.ts | 2 +- .../mainInput/TipTapEditor/utils/index.ts | 5 + .../utils}/keyHandlers.ts | 8 +- .../utils/resolveEditorContent.ts | 345 ++++++++++++++++++ .../mainInput/tiptap/CodeBlockComponent.tsx | 42 --- .../mainInput/tiptap/resolveInput.ts | 277 -------------- .../mainInput/util/handleMetaKeyIssues.ts | 3 +- .../markdown/CodeSnippetPreview.tsx | 184 ---------- .../markdown/StyledMarkdownPreview.tsx | 6 +- gui/src/pages/gui/Chat.tsx | 8 +- gui/src/redux/selectors/index.ts | 8 +- gui/src/redux/store.ts | 4 +- gui/src/redux/thunks/gatherContext.ts | 2 +- gui/src/redux/thunks/updateFileSymbols.ts | 7 +- gui/tailwind.config.cjs | 2 + 40 files changed, 996 insertions(+), 626 deletions(-) create mode 100644 .continue/rules/use-tailwind-not-styled.md rename gui/src/components/mainInput/{tiptap => TipTapEditor}/DragOverlay.tsx (100%) rename gui/src/components/mainInput/{tiptap => TipTapEditor}/StyledComponents.ts (100%) rename gui/src/components/mainInput/{tiptap => TipTapEditor}/TipTapEditor.css (100%) rename gui/src/components/mainInput/{tiptap => TipTapEditor}/TipTapEditor.tsx (97%) rename gui/src/components/mainInput/{tiptap => TipTapEditor}/extensions/AddCodeToEditExtension.ts (88%) rename gui/src/components/mainInput/{tiptap => TipTapEditor}/extensions/CodeBlockExtension.tsx (75%) rename gui/src/components/mainInput/{tiptap => TipTapEditor}/extensions/MentionExtension.ts (90%) create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts rename gui/src/components/mainInput/{tiptap/extensions/CommandsExtension.ts => TipTapEditor/extensions/SlashCommandExtension.ts} (66%) create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/index.ts create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/types.ts create mode 100644 gui/src/components/mainInput/TipTapEditor/toolbar-previews/CodeblockPreview.tsx create mode 100644 gui/src/components/mainInput/TipTapEditor/toolbar-previews/ExpandablePreview.tsx create mode 100644 gui/src/components/mainInput/TipTapEditor/toolbar-previews/PromptBlockPreview.tsx create mode 100644 gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts rename gui/src/components/mainInput/{tiptap => TipTapEditor}/useWebviewListeners.ts (97%) rename gui/src/components/mainInput/{tiptap => TipTapEditor/utils}/editorConfig.ts (90%) rename gui/src/components/mainInput/{tiptap => TipTapEditor/utils}/getSuggestion.ts (91%) rename gui/src/components/mainInput/{tiptap => TipTapEditor/utils}/imageUtils.ts (96%) create mode 100644 gui/src/components/mainInput/TipTapEditor/utils/index.ts rename gui/src/components/mainInput/{tiptap => TipTapEditor/utils}/keyHandlers.ts (90%) create mode 100644 gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts delete mode 100644 gui/src/components/mainInput/tiptap/CodeBlockComponent.tsx delete mode 100644 gui/src/components/mainInput/tiptap/resolveInput.ts delete mode 100644 gui/src/components/markdown/CodeSnippetPreview.tsx diff --git a/.continue/rules/use-tailwind-not-styled.md b/.continue/rules/use-tailwind-not-styled.md new file mode 100644 index 000000000..8a3ec0b3d --- /dev/null +++ b/.continue/rules/use-tailwind-not-styled.md @@ -0,0 +1,3 @@ +Always use Tailwind classes, not styled components. + +If a component is using styled components, it should be converted to use Tailwind classes. diff --git a/core/index.d.ts b/core/index.d.ts index ba97377d3..913d9167f 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1,6 +1,7 @@ import { DataDestination, ModelRole } from "@continuedev/config-yaml"; import Parser from "web-tree-sitter"; import { GetGhTokenArgs } from "./protocol/ide"; + declare global { interface Window { ide?: "vscode"; diff --git a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx index 7e0e2e183..b8004b472 100644 --- a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx +++ b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx @@ -1,9 +1,16 @@ import { SlashCommandDescription } from "core"; import { useState } from "react"; import { useBookmarkedSlashCommands } from "../../hooks/useBookmarkedSlashCommands"; +import { MAIN_EDITOR_INPUT_ID } from "../../pages/gui/Chat"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { setMainEditorContentTrigger } from "../../redux/slices/sessionSlice"; -import { getParagraphNodeFromString } from "../mainInput/utils"; +import { + setMainEditorContentTrigger, + setNewestCodeblocksForInput, +} from "../../redux/slices/sessionSlice"; +import { + createParagraphNodeFromSlashCmdDescription, + createPromptBlockNodeFromSlashCmdDescription, +} from "../mainInput/TipTapEditor/extensions"; import { ConversationStarterCard } from "./ConversationStarterCard"; const NUM_CARDS_TO_RENDER = 5; @@ -21,11 +28,22 @@ export function ConversationStarterCards() { ); function onClick(command: SlashCommandDescription) { - if (command.prompt) { - dispatch( - setMainEditorContentTrigger(getParagraphNodeFromString(command.prompt)), - ); - } + dispatch( + setNewestCodeblocksForInput({ + inputId: MAIN_EDITOR_INPUT_ID, + contextItemId: command.name, + }), + ); + + dispatch( + setMainEditorContentTrigger({ + type: "doc", + content: [ + createPromptBlockNodeFromSlashCmdDescription(command), + createParagraphNodeFromSlashCmdDescription(command), + ], + }), + ); } if (bookmarkedSlashCommands.length === 0) { diff --git a/gui/src/components/FileIcon.tsx b/gui/src/components/FileIcon.tsx index 6f96e498d..ab0d338dd 100644 --- a/gui/src/components/FileIcon.tsx +++ b/gui/src/components/FileIcon.tsx @@ -5,9 +5,10 @@ import { themeIcons } from "seti-file-icons"; export interface FileIconProps { filename: string; - height: string; - width: string; + height: `${number}px`; + width: `${number}px`; } + export default function FileIcon({ filename, height, width }: FileIconProps) { const file = useMemo(() => { if (filename.includes(" (")) { @@ -33,6 +34,7 @@ export default function FileIcon({ filename, height, width }: FileIconProps) { ignore: "#586e75", }); + console.log({ file }); // Sanitize the SVG string before rendering it const { svg, color } = getIcon(file); const sanitizedSVG = DOMPurify.sanitize(svg); diff --git a/gui/src/components/gui/HeaderButtonWithToolTip.tsx b/gui/src/components/gui/HeaderButtonWithToolTip.tsx index 8c357d5ea..2ee4496fe 100644 --- a/gui/src/components/gui/HeaderButtonWithToolTip.tsx +++ b/gui/src/components/gui/HeaderButtonWithToolTip.tsx @@ -48,7 +48,7 @@ const HeaderButtonWithToolTip = React.forwardRef< - {props.text} + {props.text} ); diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index cf2b4cf46..30ddd30f2 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -8,7 +8,7 @@ import { selectSlashCommandComboBoxInputs } from "../../redux/selectors"; import ContextItemsPeek from "./belowMainInput/ContextItemsPeek"; import { ToolbarOptions } from "./InputToolbar"; import { Lump } from "./Lump"; -import TipTapEditor from "./tiptap/TipTapEditor"; +import TipTapEditor from "./TipTapEditor/TipTapEditor"; interface ContinueInputBoxProps { isEditMode?: boolean; diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx index 51b9d35c3..777d30e4e 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx +++ b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx @@ -78,7 +78,7 @@ function DocsIndexingStatus({ if (hasDeleted) return null; return ( -
+
@@ -90,13 +90,6 @@ function DocsIndexingStatus({ } }} > - {docConfig.faviconUrl ? ( - doc icon - ) : null}

; - renderHTML: (props: { - options: MentionOptions; - node: ProseMirrorNode; - }) => DOMOutputSpec; - suggestion: Omit; -}; +export const ADD_CODE_TO_EDIT_NAME = "add-code-to-edit"; -export const AddCodeToEditPluginKey = new PluginKey("add-code-to-edit"); +export const AddCodeToEditPluginKey = new PluginKey(ADD_CODE_TO_EDIT_NAME); -export const AddCodeToEdit = Node.create({ - name: "add-code-to-edit", +export const AddCodeToEditExtension = Node.create({ + name: ADD_CODE_TO_EDIT_NAME, addOptions() { return { diff --git a/gui/src/components/mainInput/tiptap/extensions/CodeBlockExtension.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlockExtension.tsx similarity index 75% rename from gui/src/components/mainInput/tiptap/extensions/CodeBlockExtension.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/CodeBlockExtension.tsx index aea6e18af..3618a69ba 100644 --- a/gui/src/components/mainInput/tiptap/extensions/CodeBlockExtension.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlockExtension.tsx @@ -1,9 +1,11 @@ import { mergeAttributes, Node } from "@tiptap/core"; import { ReactNodeViewRenderer } from "@tiptap/react"; -import { CodeBlockComponent } from "../CodeBlockComponent"; +import { CodeblockPreview } from "../toolbar-previews/CodeblockPreview"; + +export const CODEBLOCK_NAME = "codeblock"; export const CodeBlockExtension = Node.create({ - name: "codeBlock", + name: CODEBLOCK_NAME, group: "block", @@ -37,6 +39,6 @@ export const CodeBlockExtension = Node.create({ }, addNodeView() { - return ReactNodeViewRenderer(CodeBlockComponent); + return ReactNodeViewRenderer(CodeblockPreview); }, }); diff --git a/gui/src/components/mainInput/tiptap/extensions/MentionExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts similarity index 90% rename from gui/src/components/mainInput/tiptap/extensions/MentionExtension.ts rename to gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts index 364b241ee..b81d223b4 100644 --- a/gui/src/components/mainInput/tiptap/extensions/MentionExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts @@ -1,21 +1,14 @@ import { mergeAttributes, Node } from "@tiptap/core"; -import { DOMOutputSpec, Node as ProseMirrorNode } from "@tiptap/pm/model"; import { PluginKey } from "@tiptap/pm/state"; -import Suggestion, { SuggestionOptions } from "@tiptap/suggestion"; +import Suggestion from "@tiptap/suggestion"; +import { MentionOptions } from "./types"; -export type MentionOptions = { - HTMLAttributes: Record; - renderHTML: (props: { - options: MentionOptions; - node: ProseMirrorNode; - }) => DOMOutputSpec; - suggestion: Omit; -}; +export const MENTION_NAME = "mention"; -export const MentionPluginKey = new PluginKey("mention"); +export const MentionPluginKey = new PluginKey(MENTION_NAME); -export const Mention = Node.create({ - name: "mention", +export const MentionExtension = Node.create({ + name: MENTION_NAME, addOptions() { return { diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts new file mode 100644 index 000000000..d5c5b6d7b --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts @@ -0,0 +1,81 @@ +import { mergeAttributes, Node } from "@tiptap/core"; +import { ReactNodeViewRenderer } from "@tiptap/react"; +import { ContextItemWithId, SlashCommandDescription } from "core"; +import { MAIN_EDITOR_INPUT_ID } from "../../../../pages/gui/Chat"; +import { PromptBlockPreview } from "../toolbar-previews/PromptBlockPreview"; + +export interface PromptOptions { + HTMLAttributes: Record; +} + +export const PROMPT_BLOCK_NAME = "prompt-block"; + +/** + * Extension for adding prompt blocks to the Tiptap editor + */ +export const PromptExtension = Node.create({ + name: PROMPT_BLOCK_NAME, + group: "block", + // atom: true, + // draggable: true, + + addOptions() { + return { + HTMLAttributes: {}, + }; + }, + + addAttributes() { + return { + item: { + default: null, + }, + inputId: { + default: null, + }, + }; + }, + + parseHTML() { + return [ + { + tag: "prompt-block", + }, + ]; + }, + + renderHTML({ HTMLAttributes }) { + return ["prompt-block", mergeAttributes(HTMLAttributes), 0]; + }, + + addNodeView() { + return ReactNodeViewRenderer(PromptBlockPreview); + }, +}); + +/** + * Creates a prompt block node from a slash command description + * @param command The slash command description to create the block from + * @param inputId Optional input ID, defaults to main editor input ID + * @returns A node object representing the prompt block + */ +export const createPromptBlockNodeFromSlashCmdDescription = ( + command: SlashCommandDescription, + inputId: string = MAIN_EDITOR_INPUT_ID, +) => { + return { + type: PromptExtension.name, + attrs: { + item: { + content: command.prompt, + name: command.name, + description: command.description || "", + id: { + providerTitle: "prompt", + itemId: command.name, + }, + } as ContextItemWithId, + inputId, + }, + }; +}; diff --git a/gui/src/components/mainInput/tiptap/extensions/CommandsExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts similarity index 66% rename from gui/src/components/mainInput/tiptap/extensions/CommandsExtension.ts rename to gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts index 0c25d7cca..eb97e6227 100644 --- a/gui/src/components/mainInput/tiptap/extensions/CommandsExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts @@ -4,29 +4,31 @@ import { mergeAttributes, Node } from "@tiptap/core"; import { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { PluginKey } from "@tiptap/pm/state"; import Suggestion, { SuggestionOptions } from "@tiptap/suggestion"; +import { ContextItemWithId, SlashCommandDescription } from "core"; +import { v4 as uuidv4 } from "uuid"; export type SlashCommandOptions = { HTMLAttributes: Record; - renderText: (props: { - options: SlashCommandOptions; - node: ProseMirrorNode; - }) => string; + renderText: (props: { node: ProseMirrorNode }) => string; suggestion: Omit; }; -export const SlashCommandPluginKey = new PluginKey("slashcommand"); +export const SLASH_CMD_NAME = "slash-command"; +export const SLASH_CMD_SUGGESTION_CHAR = "/"; -export const SlashCommand = Node.create({ - name: "slashcommand", +export const SlashCommandPluginKey = new PluginKey(SLASH_CMD_NAME); + +export const SlashCommandExtension = Node.create({ + name: SLASH_CMD_NAME, addOptions() { return { HTMLAttributes: {}, - renderText({ options, node }) { - return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`; + renderText({ node }) { + return node.attrs.label ?? node.attrs.id; }, suggestion: { - char: "/", + char: SLASH_CMD_SUGGESTION_CHAR, pluginKey: SlashCommandPluginKey, startOfLine: true, command: ({ editor, range, props }) => { @@ -54,6 +56,31 @@ export const SlashCommand = Node.create({ ]) .run(); + const promptId = uuidv4(); + + // Create a generic "promptToPromptBlockExtension" fn + // For here and in the conversation starters + + editor + .chain() + .focus() + .insertContentAt(0, { + type: "promptBlock", + attrs: { + item: { + content: props.content, + name: props.title, + description: props.description, + id: { + providerTitle: "prompt", + itemId: props.name, + }, + } as ContextItemWithId, + inputId: promptId, + }, + }) + .run(); + window.getSelection()?.collapseToEnd(); }, allow: ({ state, range }) => { @@ -124,7 +151,6 @@ export const SlashCommand = Node.create({ HTMLAttributes, ), this.options.renderText({ - options: this.options, node, }), ]; @@ -132,7 +158,6 @@ export const SlashCommand = Node.create({ renderText({ node }) { return this.options.renderText({ - options: this.options, node, }); }, @@ -176,3 +201,29 @@ export const SlashCommand = Node.create({ ]; }, }); + +/** + * Creates a paragraph node containing a slash command reference + * @param command The slash command description to create the reference from + * @returns A node object representing the paragraph with slash command + */ +export const createParagraphNodeFromSlashCmdDescription = ( + command: SlashCommandDescription, +) => { + return { + type: "paragraph", + content: [ + { + type: SlashCommandExtension.name, + attrs: { + id: command.name, + label: command.name, + }, + }, + { + type: "text", + text: " ", + }, + ], + }; +}; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts new file mode 100644 index 000000000..82bddd2a9 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts @@ -0,0 +1,5 @@ +export * from "./AddCodeToEditExtension"; +export * from "./CodeBlockExtension"; +export * from "./MentionExtension"; +export * from "./PromptExtension"; +export * from "./SlashCommandExtension"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/types.ts b/gui/src/components/mainInput/TipTapEditor/extensions/types.ts new file mode 100644 index 000000000..318b1062d --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/types.ts @@ -0,0 +1,11 @@ +import { DOMOutputSpec, Node as ProseMirrorNode } from "@tiptap/pm/model"; +import { SuggestionOptions } from "@tiptap/suggestion"; + +export type MentionOptions = { + HTMLAttributes: Record; + renderHTML: (props: { + options: MentionOptions; + node: ProseMirrorNode; + }) => DOMOutputSpec; + suggestion: Omit; +}; diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/CodeblockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/CodeblockPreview.tsx new file mode 100644 index 000000000..570e518c8 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/CodeblockPreview.tsx @@ -0,0 +1,100 @@ +import { + NodeViewProps, + NodeViewWrapper, + NodeViewWrapperProps, +} from "@tiptap/react"; +import { ContextItemWithId } from "core"; +import { ctxItemToRifWithContents } from "core/commands/util"; +import { dedent, getMarkdownLanguageTagForFile } from "core/util"; +import { useContext, useMemo } from "react"; +import { vscBadgeBackground } from "../../.."; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; +import { useAppSelector } from "../../../../redux/hooks"; +import FileIcon from "../../../FileIcon"; +import StyledMarkdownPreview from "../../../markdown/StyledMarkdownPreview"; +import { ExpandablePreview } from "./ExpandablePreview"; + +const backticksRegex = /`{3,}/gm; + +/** + * Component for displaying a code block in the TipTap editor + */ +export const CodeblockPreview = ({ + node, + deleteNode, + selected, +}: NodeViewProps) => { + const item: ContextItemWithId = node.attrs.item; + const inputId = node.attrs.inputId; + const isFirstContextItem = false; // TODO: fix this, decided not worth the insane renders for now + const ideMessenger = useContext(IdeMessengerContext); + + // Not setting this as a "p" will cause issues with foreign keyboards + // See https://github.com/continuedev/continue/issues/3199 + const nodeViewWrapperTag: NodeViewWrapperProps["as"] = "p"; + + const newestCodeblockForInputId = useAppSelector( + (store) => store.session.newestCodeblockForInput[inputId], + ); + + const initiallyHidden = useMemo(() => { + return newestCodeblockForInputId !== item.id.itemId; + }, [newestCodeblockForInputId, item.id.itemId]); + + const content = useMemo(() => { + return dedent`${item.content}`; + }, [item.content]); + + const fence = useMemo(() => { + const backticks = content.match(backticksRegex); + return backticks ? backticks.sort().at(-1) + "`" : "```"; + }, [content]); + + const handleTitleClick = (e: React.MouseEvent) => { + e.stopPropagation(); + + if (item.id.providerTitle === "file" && item.uri?.value) { + ideMessenger.post("showFile", { + filepath: item.uri.value, + }); + } else if (item.id.providerTitle === "code") { + const rif = ctxItemToRifWithContents(item, true); + ideMessenger.ide.showLines( + rif.filepath, + rif.range.start.line, + rif.range.end.line, + ); + } else { + ideMessenger.post("showVirtualFile", { + content: item.content, + name: item.name, + }); + } + }; + + const borderColor = isFirstContextItem + ? "#d0d" + : selected + ? vscBadgeBackground + : undefined; + + return ( + + } + initiallyHidden={initiallyHidden} + onDelete={() => deleteNode()} + borderColor={borderColor} + onTitleClick={handleTitleClick} + > + + + + ); +}; diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/ExpandablePreview.tsx b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/ExpandablePreview.tsx new file mode 100644 index 000000000..973700335 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/ExpandablePreview.tsx @@ -0,0 +1,186 @@ +import { + ChevronDownIcon, + EyeSlashIcon, + XMarkIcon, +} from "@heroicons/react/24/outline"; +import { EyeIcon } from "@heroicons/react/24/solid"; +import { useEffect, useRef, useState } from "react"; +import styled from "styled-components"; +import { defaultBorderRadius, lightGray, vscEditorBackground } from "../../.."; +import { getFontSize } from "../../../../util"; +import HeaderButtonWithToolTip from "../../../gui/HeaderButtonWithToolTip"; + +const MAX_PREVIEW_HEIGHT = 100; +const MAX_EXPANED_PREVIEW_HEIGHT = MAX_PREVIEW_HEIGHT * 3; + +const PreviewDiv = styled.div<{ + borderColor?: string; +}>` + background-color: ${vscEditorBackground}; + border-radius: ${defaultBorderRadius}; + border: 0.5px solid ${(props) => props.borderColor || lightGray}; + margin-top: 4px; + margin-bottom: 4px; + overflow: hidden; + position: relative; + + & div { + background-color: ${vscEditorBackground}; + } +`; + +const ContentContainer = styled.div<{ expanded: boolean }>` + position: relative; + max-height: ${(props) => + props.expanded + ? `${MAX_EXPANED_PREVIEW_HEIGHT}px` + : `${MAX_PREVIEW_HEIGHT}px`}; + overflow: hidden; + display: flex; + flex-direction: column; +`; + +const ScrollableContent = styled.div<{ shouldShowChevron: boolean }>` + overflow-y: auto; + padding-bottom: ${(props) => (props.shouldShowChevron ? "24px" : "0px")}; +`; + +const ChevronContainer = styled.div` + position: sticky; + bottom: 0; + left: 0; + right: 0; + display: flex; + justify-content: center; + background: ${vscEditorBackground}; + padding: 4px 0; + z-index: 10; +`; + +/** + * Props for the ExpandablePreview component + */ +interface ExpandablePreviewProps { + /** Title to display in the header */ + title: string; + /** Optional icon to display next to the title */ + icon?: React.ReactNode; + /** Whether the preview is initially hidden */ + initiallyHidden?: boolean; + /** Callback when the delete button is clicked */ + onDelete?: () => void; + /** Callback when the title is clicked */ + onTitleClick?: (e: React.MouseEvent) => void; + /** Border color of the preview */ + borderColor?: string; + /** Content to display in the preview */ + children: React.ReactNode; +} + +/** + * A generalized expandable preview component for displaying content with a header and expandable body + */ +export function ExpandablePreview(props: ExpandablePreviewProps) { + const [hidden, setHidden] = useState(props.initiallyHidden ?? false); + const [isExpanded, setIsExpanded] = useState(false); + + const contentRef = useRef(null); + const [contentDims, setContentDims] = useState({ width: 0, height: 0 }); + + useEffect(() => { + const resizeObserver = new ResizeObserver(() => { + setContentDims({ + width: contentRef.current?.scrollWidth ?? 0, + height: contentRef.current?.scrollHeight ?? 0, + }); + }); + + if (contentRef.current) { + resizeObserver.observe(contentRef.current); + } + + return () => { + resizeObserver.disconnect(); + }; + }, [contentRef]); + + return ( + + {/* Keep existing header code */} +

{ + setHidden(!hidden); + }} + > +
{ + e.stopPropagation(); + if (props.onTitleClick) { + props.onTitleClick(e); + } + }} + > + {props.icon} + {props.title} +
+
+ + {hidden ? ( + + ) : ( + + )} + + {props.onDelete && ( + { + e.stopPropagation(); + props.onDelete?.(); + }} + > + + + )} +
+
+ + {/* Updated content section */} + {!hidden && ( + + MAX_PREVIEW_HEIGHT} + > + {props.children} + + + {contentDims.height > MAX_PREVIEW_HEIGHT && ( + + + setIsExpanded((v) => !v)} + /> + + + )} + + )} + + ); +} diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/PromptBlockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/PromptBlockPreview.tsx new file mode 100644 index 000000000..2e02f742c --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/PromptBlockPreview.tsx @@ -0,0 +1,61 @@ +import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline"; +import { NodeViewWrapper, NodeViewWrapperProps } from "@tiptap/react"; +import { ContextItemWithId } from "core"; +import { useContext, useMemo } from "react"; +import { vscBadgeBackground } from "../../.."; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; +import { useAppSelector } from "../../../../redux/hooks"; +import { ExpandablePreview } from "./ExpandablePreview"; + +/** + * Component for prompt blocks in the Tiptap editor + */ +export const PromptBlockPreview = (props: any) => { + const { node, deleteNode, selected } = props; + const item: ContextItemWithId = node.attrs.item; + const inputId = node.attrs.inputId; + const ideMessenger = useContext(IdeMessengerContext); + + // Not setting this as a "p" will cause issues with foreign keyboards + const nodeViewWrapperTag: NodeViewWrapperProps["as"] = "p"; + + const newestCodeblockForInputId = useAppSelector( + (store) => store.session.newestCodeblockForInput[inputId], + ); + + const initiallyHidden = useMemo(() => { + return newestCodeblockForInputId !== item.id.itemId; + }, [newestCodeblockForInputId, item.id.itemId]); + + console.log({ id: item.id.itemId, newestCodeblockForInputId }); + + const handleTitleClick = (e: React.MouseEvent) => { + e.stopPropagation(); + ideMessenger.post("showVirtualFile", { + content: item.content, + name: item.name, + }); + }; + + const borderColor = selected ? vscBadgeBackground : undefined; + + return ( + + } + initiallyHidden={initiallyHidden} + onDelete={() => deleteNode()} + borderColor={borderColor} + onTitleClick={handleTitleClick} + > +
+ {item.content} +
+
+
+ ); +}; diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts new file mode 100644 index 000000000..183e0daa0 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts @@ -0,0 +1,2 @@ +export { CodeblockPreview } from "./CodeblockPreview"; +export { PromptBlockPreview as PromptPreview } from "./PromptBlockPreview"; diff --git a/gui/src/components/mainInput/tiptap/useWebviewListeners.ts b/gui/src/components/mainInput/TipTapEditor/useWebviewListeners.ts similarity index 97% rename from gui/src/components/mainInput/tiptap/useWebviewListeners.ts rename to gui/src/components/mainInput/TipTapEditor/useWebviewListeners.ts index 3a4694939..d98e72632 100644 --- a/gui/src/components/mainInput/tiptap/useWebviewListeners.ts +++ b/gui/src/components/mainInput/TipTapEditor/useWebviewListeners.ts @@ -10,6 +10,7 @@ import { import { AppDispatch } from "../../../redux/store"; import { loadSession, saveCurrentSession } from "../../../redux/thunks/session"; import { TipTapEditorProps } from "./TipTapEditor"; +import { CodeBlockExtension } from "./extensions"; export function useWebviewListeners(options: { editor: Editor | null; @@ -117,7 +118,7 @@ export function useWebviewListeners(options: { if (el.attrs?.item?.name === contextItem.name) { return; // Prevent exact duplicate code blocks } - if (el.type === "codeBlock") { + if (el.type === CodeBlockExtension.name) { index += 2; } else { break; @@ -126,13 +127,14 @@ export function useWebviewListeners(options: { editor .chain() .insertContentAt(index, { - type: "codeBlock", + type: CodeBlockExtension.name, attrs: { item: contextItem, inputId: props.inputId, }, }) .run(); + dispatch( setNewestCodeblocksForInput({ inputId: props.inputId, diff --git a/gui/src/components/mainInput/tiptap/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts similarity index 90% rename from gui/src/components/mainInput/tiptap/editorConfig.ts rename to gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index 985cadc64..384d4aee6 100644 --- a/gui/src/components/mainInput/tiptap/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -11,32 +11,29 @@ import { InputModifiers } from "core"; import { modelSupportsImages } from "core/llm/autodetect"; import { usePostHog } from "posthog-js/react"; import { useRef } from "react"; -import { IIdeMessenger } from "../../../context/IdeMessenger"; -import { useSubmenuContextProviders } from "../../../context/SubmenuContextProviders"; -import { useInputHistory } from "../../../hooks/useInputHistory"; -import useUpdatingRef from "../../../hooks/useUpdatingRef"; -import { useAppSelector } from "../../../redux/hooks"; -import { selectUseActiveFile } from "../../../redux/selectors"; -import { selectDefaultModel } from "../../../redux/slices/configSlice"; +import { + getContextProviderDropdownOptions, + getSlashCommandDropdownOptions, +} from "."; +import { IIdeMessenger } from "../../../../context/IdeMessenger"; +import { useSubmenuContextProviders } from "../../../../context/SubmenuContextProviders"; +import { useInputHistory } from "../../../../hooks/useInputHistory"; +import useUpdatingRef from "../../../../hooks/useUpdatingRef"; +import { useAppSelector } from "../../../../redux/hooks"; +import { selectUseActiveFile } from "../../../../redux/selectors"; +import { selectDefaultModel } from "../../../../redux/slices/configSlice"; import { addCodeToEdit, selectHasCodeToEdit, selectIsInEditMode, -} from "../../../redux/slices/sessionSlice"; -import { AppDispatch } from "../../../redux/store"; -import { exitEditMode } from "../../../redux/thunks"; -import { loadLastSession } from "../../../redux/thunks/session"; -import { getFontSize } from "../../../util"; -import { AddCodeToEdit } from "./extensions/AddCodeToEditExtension"; -import { CodeBlockExtension } from "./extensions/CodeBlockExtension"; -import { SlashCommand } from "./extensions/CommandsExtension"; -import { Mention } from "./extensions/MentionExtension"; -import { - getContextProviderDropdownOptions, - getSlashCommandDropdownOptions, -} from "./getSuggestion"; +} from "../../../../redux/slices/sessionSlice"; +import { AppDispatch } from "../../../../redux/store"; +import { exitEditMode } from "../../../../redux/thunks"; +import { loadLastSession } from "../../../../redux/thunks/session"; +import { getFontSize } from "../../../../util"; +import * as ContinueExtensions from "../extensions"; +import { TipTapEditorProps } from "../TipTapEditor"; import { handleImageFile } from "./imageUtils"; -import { TipTapEditorProps } from "./TipTapEditor"; export function getPlaceholderText( placeholder: TipTapEditorProps["placeholder"], @@ -63,7 +60,6 @@ export function createEditorConfig(options: { const posthog = usePostHog(); - // #region Selectors const { getSubmenuContextItems } = useSubmenuContextProviders(); const defaultModel = useAppSelector(selectDefaultModel); const isStreaming = useAppSelector((state) => state.session.isStreaming); @@ -72,9 +68,7 @@ export function createEditorConfig(options: { const isInEditMode = useAppSelector(selectIsInEditMode); const hasCodeToEdit = useAppSelector(selectHasCodeToEdit); const isEditModeAndNoCodeToEdit = isInEditMode && !hasCodeToEdit; - // #endregion - // #region Refs const inSubmenuRef = useRef(undefined); const inDropdownRef = useRef(false); const defaultModelRef = useUpdatingRef(defaultModel); @@ -90,8 +84,6 @@ export function createEditorConfig(options: { ); const { prevRef, nextRef, addRef } = useInputHistory(props.historyKey); - // #endregion - const enterSubmenu = async (editor: Editor, providerId: string) => { const contents = editor.getText(); const indexOfAt = contents.lastIndexOf("@"); @@ -294,7 +286,7 @@ export function createEditorConfig(options: { }, }), Text, - Mention.configure({ + ContinueExtensions.MentionExtension.configure({ HTMLAttributes: { class: "mention", }, @@ -312,7 +304,7 @@ export function createEditorConfig(options: { }, }), - AddCodeToEdit.configure({ + ContinueExtensions.AddCodeToEditExtension.configure({ HTMLAttributes: { class: "add-code-to-edit", }, @@ -351,7 +343,7 @@ export function createEditorConfig(options: { }, }, }), - SlashCommand.configure({ + ContinueExtensions.SlashCommandExtension.configure({ HTMLAttributes: { class: "mention", }, @@ -360,12 +352,19 @@ export function createEditorConfig(options: { onClose, onOpen, ideMessenger, + dispatch, + props.inputId, ), renderText: (props) => { return props.node.attrs.label; }, }), - CodeBlockExtension, + ContinueExtensions.PromptExtension.configure({ + HTMLAttributes: { + class: "prompt-block", + }, + }), + ContinueExtensions.CodeBlockExtension, ], editorProps: { attributes: { diff --git a/gui/src/components/mainInput/tiptap/getSuggestion.ts b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts similarity index 91% rename from gui/src/components/mainInput/tiptap/getSuggestion.ts rename to gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts index f9faad863..c1cd5c23e 100644 --- a/gui/src/components/mainInput/tiptap/getSuggestion.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts @@ -6,10 +6,12 @@ import { } from "core"; import { MutableRefObject } from "react"; import tippy from "tippy.js"; -import { IIdeMessenger } from "../../../context/IdeMessenger"; -import AtMentionDropdown from "../AtMentionDropdown"; -import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "../types"; -import { TIPPY_DIV_ID } from "./TipTapEditor"; +import { IIdeMessenger } from "../../../../context/IdeMessenger"; +import { setNewestCodeblocksForInput } from "../../../../redux/slices/sessionSlice"; +import { AppDispatch } from "../../../../redux/store"; +import AtMentionDropdown from "../../AtMentionDropdown"; +import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "../../types"; +import { TIPPY_DIV_ID } from "../TipTapEditor"; function getSuggestion( items: (props: { query: string }) => Promise, @@ -196,6 +198,8 @@ export function getSlashCommandDropdownOptions( onClose: () => void, onOpen: () => void, ideMessenger: IIdeMessenger, + dispatch: AppDispatch, + inputId: string, ) { const items = async ({ query }: { query: string }) => { const options = [...availableSlashCommandsRef.current]; @@ -216,7 +220,17 @@ export function getSlashCommandDropdownOptions( title: provider.title, label: provider.title, type: (provider.type ?? "slashCommand") as ComboBoxItemType, - action: provider.action, + content: provider.content, + action: () => { + dispatch( + setNewestCodeblocksForInput({ + inputId, + contextItemId: provider.title, + }), + ); + + provider.action?.(); + }, })); if (query.length === 0 && commandItems.length === 0) { @@ -232,6 +246,7 @@ export function getSlashCommandDropdownOptions( name: "", id: "", label: "", + content: "", }); } diff --git a/gui/src/components/mainInput/tiptap/imageUtils.ts b/gui/src/components/mainInput/TipTapEditor/utils/imageUtils.ts similarity index 96% rename from gui/src/components/mainInput/tiptap/imageUtils.ts rename to gui/src/components/mainInput/TipTapEditor/utils/imageUtils.ts index 0803e5ab8..23de2dda1 100644 --- a/gui/src/components/mainInput/tiptap/imageUtils.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/imageUtils.ts @@ -1,4 +1,4 @@ -import { IIdeMessenger } from "../../../context/IdeMessenger"; +import { IIdeMessenger } from "../../../../context/IdeMessenger"; const IMAGE_RESOLUTION = 1024; diff --git a/gui/src/components/mainInput/TipTapEditor/utils/index.ts b/gui/src/components/mainInput/TipTapEditor/utils/index.ts new file mode 100644 index 000000000..5ce05a866 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/utils/index.ts @@ -0,0 +1,5 @@ +export * from "./editorConfig"; +export * from "./getSuggestion"; +export * from "./imageUtils"; +export * from "./keyHandlers"; +export * from "./resolveEditorContent"; diff --git a/gui/src/components/mainInput/tiptap/keyHandlers.ts b/gui/src/components/mainInput/TipTapEditor/utils/keyHandlers.ts similarity index 90% rename from gui/src/components/mainInput/tiptap/keyHandlers.ts rename to gui/src/components/mainInput/TipTapEditor/utils/keyHandlers.ts index c25a53271..a102ba2f0 100644 --- a/gui/src/components/mainInput/tiptap/keyHandlers.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/keyHandlers.ts @@ -1,20 +1,18 @@ import { Editor } from "@tiptap/react"; import { KeyboardEvent } from "react"; -import { isJetBrains, isMetaEquivalentKeyPressed } from "../../../util"; +import { isJetBrains, isMetaEquivalentKeyPressed } from "../../../../util"; import { handleJetBrainsOSRMetaKeyIssues, handleVSCMetaKeyIssues, -} from "../util/handleMetaKeyIssues"; +} from "../../util/handleMetaKeyIssues"; export function useEditorEventHandlers(options: { editor: Editor | null; isOSREnabled: boolean; editorFocusedRef: React.MutableRefObject; - isInEditMode: boolean; setActiveKey: (key: string | null) => void; }) { - const { editor, isOSREnabled, editorFocusedRef, isInEditMode, setActiveKey } = - options; + const { editor, isOSREnabled, editorFocusedRef, setActiveKey } = options; /** * This handles various issues with meta key actions diff --git a/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts new file mode 100644 index 000000000..5ffd77ffc --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts @@ -0,0 +1,345 @@ +import { Dispatch } from "@reduxjs/toolkit"; +import Image from "@tiptap/extension-image"; +import { Paragraph } from "@tiptap/extension-paragraph"; +import { Text } from "@tiptap/extension-text"; +import { JSONContent } from "@tiptap/react"; +import { + ContextItemWithId, + DefaultContextProvider, + InputModifiers, + MessageContent, + MessagePart, + RangeInFile, + SlashCommandDescription, + TextMessagePart, +} from "core"; +import { ctxItemToRifWithContents } from "core/commands/util"; +import { renderChatMessage, stripImages } from "core/util/messageContent"; +import { getUriFileExtension } from "core/util/uri"; +import { IIdeMessenger } from "../../../../context/IdeMessenger"; +import { setIsGatheringContext } from "../../../../redux/slices/sessionSlice"; +import { + CodeBlockExtension, + MentionExtension, + SlashCommandExtension, +} from "../extensions"; + +interface MentionAttrs { + label: string; + id: string; + itemType?: string; + query?: string; +} + +interface ResolveEditorContentInput { + editorState: JSONContent; + modifiers: InputModifiers; + ideMessenger: IIdeMessenger; + defaultContextProviders: DefaultContextProvider[]; + availableSlashCommands: SlashCommandDescription[]; + selectedModelTitle: string; + dispatch: Dispatch; +} + +type ResolveEditorContentOutput = [ + ContextItemWithId[], + RangeInFile[], + MessageContent, + ( + | { + command: SlashCommandDescription; + input: string; + } + | undefined + ), +]; + +/** + * Processes editor content and extracts parts, context items, code, and slash commands + */ +function processEditorContent(editorState: JSONContent) { + const contextItemAttrs: MentionAttrs[] = []; + const selectedCode: RangeInFile[] = []; + let slashCommandName: string | undefined; + + const parts = (editorState?.content || []).reduce( + (parts, p) => { + switch (p.type) { + case Paragraph.name: { + const [text, ctxItems, foundSlashCommand] = resolveParagraph(p); + + // Only take the first slash command + if (foundSlashCommand && !slashCommandName) { + slashCommandName = foundSlashCommand; + } + + contextItemAttrs.push(...ctxItems); + + if (!text) return parts; + + // Merge with previous text part if possible + if (parts[parts.length - 1]?.type === "text") { + (parts[parts.length - 1] as TextMessagePart).text += "\n" + text; + return parts; + } + + return [...parts, { type: "text", text }]; + } + + case CodeBlockExtension.name: { + if (!p.attrs?.item) { + console.warn("codeBlock has no item attribute"); + return parts; + } + + const contextItem = p.attrs.item as ContextItemWithId; + const rif = ctxItemToRifWithContents(contextItem, true); + selectedCode.push(rif); + + // If editing, only include in selectedCode + if (contextItem.editing) { + return parts; + } + + const fileExtension = getUriFileExtension(rif.filepath); + const codeText = [ + "\n\n```", + fileExtension, + " ", + contextItem.description, + "\n", + contextItem.content, + "\n```", + ].join(""); + + if (parts[parts.length - 1]?.type === "text") { + (parts[parts.length - 1] as TextMessagePart).text += + "\n" + codeText; + return parts; + } + + return [...parts, { type: "text", text: codeText }]; + } + + case Image.name: { + return [ + ...parts, + { + type: "imageUrl", + imageUrl: { url: p.attrs?.src }, + }, + ]; + } + + default: { + console.warn("Unexpected content type", p.type); + return parts; + } + } + }, + [], + ); + + return { parts, contextItemAttrs, selectedCode, slashCommandName }; +} + +/** + * Processes slash commands and prepares the command with input + */ +function processSlashCommand( + slashCommandName: string | undefined, + availableSlashCommands: SlashCommandDescription[], + parts: MessagePart[], +): { command: SlashCommandDescription; input: string } | undefined { + if (!slashCommandName) return; + + const command = availableSlashCommands.find( + (c) => c.name === slashCommandName, + ); + + if (!command) return; + + const lastTextIndex = findLastIndex(parts, (part) => part.type === "text"); + const lastTextPart = parts[lastTextIndex] as TextMessagePart; + + let input: string; + + // Get input and add text of last slash command text back in to last text node + if (lastTextPart) { + // TODO: only input the slash cmd is currently using + // improove this comment + input = renderChatMessage({ + role: "user", + content: lastTextPart.text, + }).trimStart(); + lastTextPart.text = `/${command.name} ${lastTextPart.text}`; + } else { + input = ""; + parts.push({ type: "text", text: `/${command.name}` }); + } + + return { + command, + input, + }; +} + +/** + * Gathers context items from various sources + */ +async function gatherContextItems({ + contextItemAttrs, + modifiers, + ideMessenger, + defaultContextProviders, + parts, + selectedCode, + selectedModelTitle, +}: { + contextItemAttrs: MentionAttrs[]; + modifiers: InputModifiers; + ideMessenger: IIdeMessenger; + defaultContextProviders: DefaultContextProvider[]; + parts: MessagePart[]; + selectedCode: RangeInFile[]; + selectedModelTitle: string; +}): Promise { + let contextItems: ContextItemWithId[] = []; + + // Process context item attributes + for (const item of contextItemAttrs) { + const result = await ideMessenger.request("context/getContextItems", { + name: item.itemType === "contextProvider" ? item.id : item.itemType!, + query: item.query ?? "", + fullInput: stripImages(parts), + selectedCode, + selectedModelTitle, + }); + if (result.status === "success") { + contextItems.push(...result.content); + } + } + + // cmd+enter to use codebase + if (modifiers.useCodebase) { + const result = await ideMessenger.request("context/getContextItems", { + name: "codebase", + query: "", + fullInput: stripImages(parts), + selectedCode, + selectedModelTitle, + }); + + if (result.status === "success") { + contextItems.push(...result.content); + } + } + + // Include default context providers + const defaultContextItems = await Promise.all( + defaultContextProviders.map(async (provider) => { + const result = await ideMessenger.request("context/getContextItems", { + name: provider.name, + query: provider.query ?? "", + fullInput: stripImages(parts), + selectedCode, + selectedModelTitle, + }); + if (result.status === "success") { + return result.content; + } else { + return []; + } + }), + ); + contextItems.push(...defaultContextItems.flat()); + + return contextItems; +} + +function findLastIndex( + array: T[], + predicate: (value: T, index: number, obj: T[]) => boolean, +): number { + for (let i = array.length - 1; i >= 0; i--) { + if (predicate(array[i], i, array)) { + return i; + } + } + return -1; // if no element satisfies the predicate +} + +function resolveParagraph( + p: JSONContent, +): [string, MentionAttrs[], string | undefined] { + const contextItems: MentionAttrs[] = []; + let slashCommand: string | undefined; + + const text = (p.content || []) + .map((child) => { + switch (child.type) { + case Text.name: + return child.text; + case MentionExtension.name: + contextItems.push(child.attrs as MentionAttrs); + return child.attrs?.renderInlineAs ?? child.attrs?.label; + case SlashCommandExtension.name: + if (!slashCommand) { + slashCommand = child.attrs?.id; + return ""; + } + return child.attrs?.label; + default: + console.warn("Unexpected child type", child.type); + return ""; + } + }) + .join("") + .trimStart(); + + return [text, contextItems, slashCommand]; +} + +/** + * This function converts the input from the editor to a string, resolving any context items + * Context items are appended to the top of the prompt and then referenced within the input + */ +export async function resolveEditorContent({ + editorState, + modifiers, + ideMessenger, + defaultContextProviders, + availableSlashCommands, + selectedModelTitle, + dispatch, +}: ResolveEditorContentInput): Promise { + const { parts, contextItemAttrs, selectedCode, slashCommandName } = + processEditorContent(editorState); + + const slashCommandWithInput = processSlashCommand( + slashCommandName, + availableSlashCommands, + parts, + ); + + const shouldGatherContext = modifiers.useCodebase || slashCommandWithInput; + if (shouldGatherContext) { + dispatch(setIsGatheringContext(true)); + } + + const contextItems = await gatherContextItems({ + contextItemAttrs, + modifiers, + ideMessenger, + defaultContextProviders, + parts, + selectedCode, + selectedModelTitle, + }); + + if (shouldGatherContext) { + dispatch(setIsGatheringContext(false)); + } + + return [contextItems, selectedCode, parts, slashCommandWithInput]; +} diff --git a/gui/src/components/mainInput/tiptap/CodeBlockComponent.tsx b/gui/src/components/mainInput/tiptap/CodeBlockComponent.tsx deleted file mode 100644 index e63e273ad..000000000 --- a/gui/src/components/mainInput/tiptap/CodeBlockComponent.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { NodeViewWrapper, NodeViewWrapperProps } from "@tiptap/react"; -import { ContextItemWithId } from "core"; -import { vscBadgeBackground } from "../.."; -import CodeSnippetPreview from "../../markdown/CodeSnippetPreview"; - -export const CodeBlockComponent = (props: any) => { - const { node, deleteNode, selected, editor, updateAttributes } = props; - const item: ContextItemWithId = node.attrs.item; - const inputId = node.attrs.inputId; - // const contextItems = useSelector( - // (store: RootState) => - // store.session.messages[store.session.messages.length - 1].contextItems, - // ); - // const isFirstContextItem = item.id === contextItems[0]?.id; - const isFirstContextItem = false; // TODO: fix this, decided not worth the insane renders for now - - // Not setting this as a "p" will cause issues with foreign keyboards - // See https://github.com/continuedev/continue/issues/3199 - const nodeViewWrapperTag: NodeViewWrapperProps["as"] = "p"; - - return ( - - { - deleteNode(); - }} - /> - - ); -}; diff --git a/gui/src/components/mainInput/tiptap/resolveInput.ts b/gui/src/components/mainInput/tiptap/resolveInput.ts deleted file mode 100644 index 76a868115..000000000 --- a/gui/src/components/mainInput/tiptap/resolveInput.ts +++ /dev/null @@ -1,277 +0,0 @@ -import { Dispatch } from "@reduxjs/toolkit"; -import { JSONContent } from "@tiptap/react"; -import { - ContextItemWithId, - DefaultContextProvider, - InputModifiers, - MessageContent, - MessagePart, - RangeInFile, - SlashCommandDescription, - TextMessagePart, -} from "core"; -import { ctxItemToRifWithContents } from "core/commands/util"; -import { renderChatMessage, stripImages } from "core/util/messageContent"; -import { getUriFileExtension } from "core/util/uri"; -import { IIdeMessenger } from "../../../context/IdeMessenger"; -import { setIsGatheringContext } from "../../../redux/slices/sessionSlice"; - -interface MentionAttrs { - label: string; - id: string; - itemType?: string; - query?: string; -} - -interface ResolveEditorContentInput { - editorState: JSONContent; - modifiers: InputModifiers; - ideMessenger: IIdeMessenger; - defaultContextProviders: DefaultContextProvider[]; - availableSlashCommands: SlashCommandDescription[]; - selectedModelTitle: string; - dispatch: Dispatch; -} - -/** - * This function converts the input from the editor to a string, resolving any context items - * Context items are appended to the top of the prompt and then referenced within the input - */ -async function resolveEditorContent({ - editorState, - modifiers, - ideMessenger, - defaultContextProviders, - availableSlashCommands, - selectedModelTitle, - dispatch, -}: ResolveEditorContentInput): Promise< - [ - ContextItemWithId[], - RangeInFile[], - MessageContent, - ( - | { - command: SlashCommandDescription; - input: string; - } - | undefined - ), - ] -> { - let parts: MessagePart[] = []; - let contextItemAttrs: MentionAttrs[] = []; - const selectedCode: RangeInFile[] = []; - let slashCommandName: string | undefined = undefined; - let slashCommandWithInput: - | { command: SlashCommandDescription; input: string } - | undefined = undefined; - if (editorState?.content) { - for (const p of editorState.content) { - if (p.type === "paragraph") { - const [text, ctxItems, foundSlashCommand] = resolveParagraph(p); - // Only take the first slash command - if (foundSlashCommand && typeof slashCommandName === "undefined") { - slashCommandName = foundSlashCommand; - } - - contextItemAttrs.push(...ctxItems); - - if (text === "") { - continue; - } - - if (parts[parts.length - 1]?.type === "text") { - (parts[parts.length - 1] as TextMessagePart).text += "\n" + text; - } else { - parts.push({ type: "text", text }); - } - } else if (p.type === "codeBlock") { - if (p.attrs?.item) { - const contextItem = p.attrs.item as ContextItemWithId; - const rif = ctxItemToRifWithContents(contextItem, true); - // If not editing, include codeblocks in the prompt - // If editing is handled by selectedCode below - if (!contextItem.editing) { - const fileExtension = getUriFileExtension(rif.filepath); - // let extName = relativeFilepath.split(".").slice(-1)[0]; - const text = - "\n\n" + - "```" + - fileExtension + - " " + - contextItem.description + - "\n" + - contextItem.content + - "\n```"; - if (parts[parts.length - 1]?.type === "text") { - (parts[parts.length - 1] as TextMessagePart).text += "\n" + text; - } else { - parts.push({ - type: "text", - text, - }); - } - } - selectedCode.push(rif); - } else { - console.warn("codeBlock has no item attribute"); - } - } else if (p.type === "image") { - parts.push({ - type: "imageUrl", - imageUrl: { - url: p.attrs?.src, - }, - }); - } else { - console.warn("Unexpected content type", p.type); - } - } - } - - if (slashCommandName) { - const command = availableSlashCommands.find( - (c) => c.name === slashCommandName, - ); - if (command) { - const lastTextIndex = findLastIndex( - parts, - (part) => part.type === "text", - ); - const lastTextPart = parts[lastTextIndex] as TextMessagePart; - - let input: string; - // Get input and add text of last slash command text back in to last text node - if (lastTextPart) { - input = renderChatMessage({ - role: "user", - content: lastTextPart.text, - }).trimStart(); - lastTextPart.text = `/${command.name} ${lastTextPart.text}`; - } else { - input = ""; - parts.push({ type: "text", text: `/${command.name}` }); - } - - slashCommandWithInput = { - command, - input, - }; - } - } - - const shouldGatherContext = modifiers.useCodebase || slashCommandWithInput; - if (shouldGatherContext) { - dispatch(setIsGatheringContext(true)); - } - - let contextItemsText = ""; - let contextItems: ContextItemWithId[] = []; - for (const item of contextItemAttrs) { - const result = await ideMessenger.request("context/getContextItems", { - name: item.itemType === "contextProvider" ? item.id : item.itemType!, - query: item.query ?? "", - fullInput: stripImages(parts), - selectedCode, - selectedModelTitle, - }); - if (result.status === "success") { - const resolvedItems = result.content; - contextItems.push(...resolvedItems); - for (const resolvedItem of resolvedItems) { - contextItemsText += resolvedItem.content + "\n\n"; - } - } - } - - // cmd+enter to use codebase - if (modifiers.useCodebase) { - const result = await ideMessenger.request("context/getContextItems", { - name: "codebase", - query: "", - fullInput: stripImages(parts), - selectedCode, - selectedModelTitle, - }); - - if (result.status === "success") { - const codebaseItems = result.content; - contextItems.push(...codebaseItems); - for (const codebaseItem of codebaseItems) { - contextItemsText += codebaseItem.content + "\n\n"; - } - } - } - - // Include default context providers - const defaultContextItems = await Promise.all( - defaultContextProviders.map(async (provider) => { - const result = await ideMessenger.request("context/getContextItems", { - name: provider.name, - query: provider.query ?? "", - fullInput: stripImages(parts), - selectedCode, - selectedModelTitle, - }); - if (result.status === "success") { - return result.content; - } else { - return []; - } - }), - ); - contextItems.push(...defaultContextItems.flat()); - - if (contextItemsText !== "") { - contextItemsText += "\n"; - } - - if (shouldGatherContext) { - dispatch(setIsGatheringContext(false)); - } - - return [contextItems, selectedCode, parts, slashCommandWithInput]; -} - -function findLastIndex( - array: T[], - predicate: (value: T, index: number, obj: T[]) => boolean, -): number { - for (let i = array.length - 1; i >= 0; i--) { - if (predicate(array[i], i, array)) { - return i; - } - } - return -1; // if no element satisfies the predicate -} - -function resolveParagraph( - p: JSONContent, -): [string, MentionAttrs[], string | undefined] { - let text = ""; - const contextItems: MentionAttrs[] = []; - let slashCommand: string | undefined = undefined; - for (const child of p.content || []) { - if (child.type === "text") { - text += text === "" ? child.text?.trimStart() : child.text; - } else if (child.type === "mention") { - text += - typeof child.attrs?.renderInlineAs === "string" - ? child.attrs.renderInlineAs - : child.attrs?.label; - contextItems.push(child.attrs as MentionAttrs); - } else if (child.type === "slashcommand") { - if (typeof slashCommand === "undefined") { - slashCommand = child.attrs?.id; - } else { - text += child.attrs?.label; - } - } else { - console.warn("Unexpected child type", child.type); - } - } - return [text, contextItems, slashCommand]; -} - -export default resolveEditorContent; diff --git a/gui/src/components/mainInput/util/handleMetaKeyIssues.ts b/gui/src/components/mainInput/util/handleMetaKeyIssues.ts index 9f9078303..6c9406830 100644 --- a/gui/src/components/mainInput/util/handleMetaKeyIssues.ts +++ b/gui/src/components/mainInput/util/handleMetaKeyIssues.ts @@ -1,6 +1,7 @@ import { Editor } from "@tiptap/react"; import { KeyboardEvent } from "react"; import { getPlatform, isWebEnvironment } from "../../../util"; +import { CodeBlockExtension } from "../TipTapEditor/extensions"; const isWebEnv = isWebEnvironment(); @@ -103,7 +104,7 @@ export const handleJetBrainsMetaBackspace = (editor: Editor) => { for (let i = doc.content.childCount - 1; i >= 0; i--) { const node = doc.content.child(i); - if (node.type.name === "codeBlock") { + if (node.type.name === CodeBlockExtension.name) { continue; } diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx deleted file mode 100644 index 06717c5ee..000000000 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ /dev/null @@ -1,184 +0,0 @@ -import { - ChevronDownIcon, - EyeSlashIcon, - XMarkIcon, -} from "@heroicons/react/24/outline"; -import { ContextItemWithId } from "core"; -import { dedent, getMarkdownLanguageTagForFile } from "core/util"; -import { useContext, useEffect, useMemo, useRef, useState } from "react"; -import styled from "styled-components"; -import { defaultBorderRadius, lightGray, vscEditorBackground } from ".."; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { getFontSize } from "../../util"; -import FileIcon from "../FileIcon"; -import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; -import StyledMarkdownPreview from "./StyledMarkdownPreview"; -import { ctxItemToRifWithContents } from "core/commands/util"; -import { EyeIcon } from "@heroicons/react/24/solid"; -import { useAppSelector } from "../../redux/hooks"; - -const PreviewMarkdownDiv = styled.div<{ - borderColor?: string; -}>` - background-color: ${vscEditorBackground}; - border-radius: ${defaultBorderRadius}; - border: 0.5px solid ${(props) => props.borderColor || lightGray}; - margin-top: 4px; - margin-bottom: 4px; - overflow: hidden; - position: relative; - - & div { - background-color: ${vscEditorBackground}; - } -`; - -interface CodeSnippetPreviewProps { - item: ContextItemWithId; - onDelete?: () => void; - borderColor?: string; - inputId: string; -} - -const MAX_PREVIEW_HEIGHT = 100; - -const backticksRegex = /`{3,}/gm; - -function CodeSnippetPreview(props: CodeSnippetPreviewProps) { - const ideMessenger = useContext(IdeMessengerContext); - - const [localHidden, setLocalHidden] = useState(); - const [isSizeLimited, setIsSizeLimited] = useState(true); - - const newestCodeblockForInputId = useAppSelector( - (store) => store.session.newestCodeblockForInput[props.inputId], - ); - - const hidden = useMemo(() => { - return localHidden ?? newestCodeblockForInputId !== props.item.id.itemId; - }, [localHidden, newestCodeblockForInputId, props.item]); - - const content = useMemo(() => { - return dedent`${props.item.content}`; - }, [props.item.content]); - - const fence = useMemo(() => { - const backticks = content.match(backticksRegex); - return backticks ? backticks.sort().at(-1) + "`" : "```"; - }, [content]); - - const codeBlockRef = useRef(null); - - const [codeblockDims, setCodeblockDims] = useState({ width: 0, height: 0 }); - useEffect(() => { - const resizeObserver = new ResizeObserver(() => { - setCodeblockDims({ - width: codeBlockRef.current?.scrollWidth ?? 0, - height: codeBlockRef.current?.scrollHeight ?? 0, - }); - }); - - if (codeBlockRef.current) { - resizeObserver.observe(codeBlockRef.current); - } - - return () => { - resizeObserver.disconnect(); - }; - }, [codeBlockRef]); - - return ( - -
{ - setLocalHidden(!hidden); - }} - > -
{ - e.stopPropagation(); - if ( - props.item.id.providerTitle === "file" && - props.item.uri?.value - ) { - ideMessenger.post("showFile", { - filepath: props.item.uri.value, - }); - } else if (props.item.id.providerTitle === "code") { - const rif = ctxItemToRifWithContents(props.item, true); - ideMessenger.ide.showLines( - rif.filepath, - rif.range.start.line, - rif.range.end.line, - ); - } else { - ideMessenger.post("showVirtualFile", { - content, - name: props.item.name, - }); - } - }} - > - - {props.item.name} -
-
- - {hidden ? ( - - ) : ( - - )} - - { - e.stopPropagation(); - props.onDelete?.(); - }} - > - - -
-
-
- -
- - {codeblockDims.height > MAX_PREVIEW_HEIGHT && ( - - setIsSizeLimited((v) => !v)} - /> - - )} -
- ); -} - -export default CodeSnippetPreview; diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index d968101d0..bc60451bf 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -69,7 +69,7 @@ const StyledMarkdown = styled.div<{ overflow-x: scroll; overflow-y: hidden; - padding: 16px 8px; + padding: 8px; } code { @@ -114,10 +114,6 @@ const StyledMarkdown = styled.div<{ line-height: 1.5; } - > *:first-child { - margin-top: 8px; - } - > *:last-child { margin-bottom: 0; } diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index aea4bdadb..682671cbb 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -21,7 +21,7 @@ import TimelineItem from "../../components/gui/TimelineItem"; import { NewSessionButton } from "../../components/mainInput/belowMainInput/NewSessionButton"; import ThinkingBlockPeek from "../../components/mainInput/belowMainInput/ThinkingBlockPeek"; import ContinueInputBox from "../../components/mainInput/ContinueInputBox"; -import resolveEditorContent from "../../components/mainInput/tiptap/resolveInput"; +import { resolveEditorContent } from "../../components/mainInput/TipTapEditor/utils"; import { useOnboardingCard } from "../../components/OnboardingCard"; import StepContainer from "../../components/StepContainer"; import AcceptRejectAllButtons from "../../components/StepContainer/AcceptRejectAllButtons"; @@ -75,6 +75,8 @@ const StepsDiv = styled.div` } `; +export const MAIN_EDITOR_INPUT_ID = "main-editor-input"; + function fallbackRender({ error, resetErrorBoundary }: any) { // Call resetErrorBoundary() to reset the error boundary and retry the render. @@ -295,7 +297,7 @@ export function Chat() { 0 ? "flex-1" : ""}`} + className={`mt-3 overflow-y-scroll ${showPageHeader ? "" : "pt-[8px]"} ${showScrollbar ? "thin-scrollbar" : "no-scrollbar"} ${history.length > 0 ? "flex-1" : ""}`} > {highlights} {history.map((item, index: number) => ( @@ -406,7 +408,7 @@ export function Chat() { onEnter={(editorState, modifiers, editor) => sendInput(editorState, modifiers, undefined, editor) } - inputId={"main-editor"} + inputId={MAIN_EDITOR_INPUT_ID} /> )} diff --git a/gui/src/redux/selectors/index.ts b/gui/src/redux/selectors/index.ts index bb7850dd5..cca27e6e2 100644 --- a/gui/src/redux/selectors/index.ts +++ b/gui/src/redux/selectors/index.ts @@ -1,5 +1,8 @@ import { createSelector } from "@reduxjs/toolkit"; -import { ComboBoxItemType } from "../../components/mainInput/types"; +import { + ComboBoxItem, + ComboBoxItemType, +} from "../../components/mainInput/types"; import { RootState } from "../store"; export const selectSlashCommandComboBoxInputs = createSelector( @@ -11,7 +14,8 @@ export const selectSlashCommandComboBoxInputs = createSelector( title: cmd.name, description: cmd.description, type: "slashCommand" as ComboBoxItemType, - }; + content: cmd.prompt, + } as ComboBoxItem; }) || [] ); }, diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts index 8aff8e1de..f321f0dae 100644 --- a/gui/src/redux/store.ts +++ b/gui/src/redux/store.ts @@ -127,7 +127,9 @@ export function setupStore() { ideMessenger: new IdeMessenger(), }, }, - }).concat(logger), + }), + // This can be uncommented to get detailed Redux logs + // .concat(logger), }); } diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index 1c38e965b..450471164 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -8,7 +8,7 @@ import { SlashCommandDescription, } from "core"; import * as URI from "uri-js"; -import resolveEditorContent from "../../components/mainInput/tiptap/resolveInput"; +import { resolveEditorContent } from "../../components/mainInput/TipTapEditor/utils"; import { selectDefaultModel } from "../slices/configSlice"; import { ThunkApiType } from "../store"; diff --git a/gui/src/redux/thunks/updateFileSymbols.ts b/gui/src/redux/thunks/updateFileSymbols.ts index 05396c3ed..5f3e5e18d 100644 --- a/gui/src/redux/thunks/updateFileSymbols.ts +++ b/gui/src/redux/thunks/updateFileSymbols.ts @@ -1,7 +1,8 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; -import { ThunkApiType } from "../store"; -import { updateFileSymbols } from "../slices/sessionSlice"; import { ChatHistoryItem, ContextItemWithId } from "core"; +import { CodeBlockExtension } from "../../components/mainInput/TipTapEditor/extensions"; +import { updateFileSymbols } from "../slices/sessionSlice"; +import { ThunkApiType } from "../store"; export function getContextItemsFromHistory( historyItems: ChatHistoryItem[], @@ -25,7 +26,7 @@ export function getContextItemsFromHistory( .flatMap((item) => item.editorState.content) .filter( (content) => - content?.type === "codeBlock" && + content?.type === CodeBlockExtension.name && content?.attrs?.item?.uri?.value && content.attrs.item.uri?.type === "file", ) diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index 67677e103..fe2b8c0e4 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -33,6 +33,8 @@ module.exports = { "vsc-editor-background": "var(--vscode-editor-background, var(--vscode-sideBar-background, rgb(30 30 30)))", "vsc-input-border": "var(--vscode-input-border, #999998)", + "vsc-commandCenter-inactiveBorder": + "var(--vscode-commandCenter-inactiveBorder, #999998)", // Starting to make things less vsc-specific // TODO make it all non-IDE-specific naming From 57d46636c8f22808d3c18e9d01e48fc44bd3d368 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 3 Apr 2025 17:57:24 -0700 Subject: [PATCH 07/67] create main editor provider --- gui/src/App.tsx | 9 +- .../ConversationStarterCards.tsx | 23 ++-- .../TipTapEditor/MainEditorProvider.tsx | 117 ++++++++++++++++++ .../mainInput/TipTapEditor/TipTapEditor.tsx | 44 ++----- .../mainInput/TipTapEditor/index.ts | 3 + ...rs.ts => useMainEditorWebviewListeners.ts} | 96 +++++++------- 6 files changed, 190 insertions(+), 102 deletions(-) create mode 100644 gui/src/components/mainInput/TipTapEditor/MainEditorProvider.tsx create mode 100644 gui/src/components/mainInput/TipTapEditor/index.ts rename gui/src/components/mainInput/TipTapEditor/{useWebviewListeners.ts => useMainEditorWebviewListeners.ts} (72%) diff --git a/gui/src/App.tsx b/gui/src/App.tsx index deb1e376f..257160320 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -1,5 +1,6 @@ import { RouterProvider, createMemoryRouter } from "react-router-dom"; import Layout from "./components/Layout"; +import { MainEditorProvider } from "./components/mainInput/TipTapEditor"; import { SubmenuContextProvidersProvider } from "./context/SubmenuContextProviders"; import { VscThemeProvider } from "./context/VscTheme"; import useSetup from "./hooks/useSetup"; @@ -66,9 +67,11 @@ function SetupListeners() { function App() { return ( - - - + + + + + ); diff --git a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx index b8004b472..07d0b0cdb 100644 --- a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx +++ b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx @@ -3,10 +3,8 @@ import { useState } from "react"; import { useBookmarkedSlashCommands } from "../../hooks/useBookmarkedSlashCommands"; import { MAIN_EDITOR_INPUT_ID } from "../../pages/gui/Chat"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { - setMainEditorContentTrigger, - setNewestCodeblocksForInput, -} from "../../redux/slices/sessionSlice"; +import { setNewestCodeblocksForInput } from "../../redux/slices/sessionSlice"; +import { useMainEditor } from "../mainInput/TipTapEditor"; import { createParagraphNodeFromSlashCmdDescription, createPromptBlockNodeFromSlashCmdDescription, @@ -17,6 +15,7 @@ const NUM_CARDS_TO_RENDER = 5; export function ConversationStarterCards() { const dispatch = useAppDispatch(); + const { mainEditor } = useMainEditor(); const [showAll, setShowAll] = useState(false); const { isCommandBookmarked } = useBookmarkedSlashCommands(); const slashCommands = useAppSelector( @@ -35,15 +34,13 @@ export function ConversationStarterCards() { }), ); - dispatch( - setMainEditorContentTrigger({ - type: "doc", - content: [ - createPromptBlockNodeFromSlashCmdDescription(command), - createParagraphNodeFromSlashCmdDescription(command), - ], - }), - ); + mainEditor?.commands.setContent({ + type: "doc", + content: [ + createPromptBlockNodeFromSlashCmdDescription(command), + createParagraphNodeFromSlashCmdDescription(command), + ], + }); } if (bookmarkedSlashCommands.length === 0) { diff --git a/gui/src/components/mainInput/TipTapEditor/MainEditorProvider.tsx b/gui/src/components/mainInput/TipTapEditor/MainEditorProvider.tsx new file mode 100644 index 000000000..874640aa5 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/MainEditorProvider.tsx @@ -0,0 +1,117 @@ +import { Editor } from "@tiptap/react"; +import { InputModifiers } from "core"; +import React, { + createContext, + useContext, + useEffect, + useRef, + useState, +} from "react"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { setMainEditorContentTrigger } from "../../../redux/slices/sessionSlice"; +import { useMainEditorWebviewListeners } from "./useMainEditorWebviewListeners"; + +/** + * Context for accessing the main editor instance + */ +interface MainEditorContextType { + /** The current main editor instance */ + mainEditor: Editor | null; + /** Set the current main editor instance */ + setMainEditor: (editor: Editor | null) => void; + /** The current input ID */ + inputId: string | null; + /** Set the current input ID */ + setInputId: (id: string) => void; + /** Reference to the execute content function */ + onEnterRef: React.MutableRefObject<(modifiers: InputModifiers) => void>; +} + +const MainEditorContext = createContext( + undefined, +); + +/** + * Provider component that maintains a reference to the main editor + */ +export const MainEditorProvider: React.FC<{ children: React.ReactNode }> = ({ + children, +}) => { + const dispatch = useAppDispatch(); + const [mainEditor, setMainEditorInternal] = useState(null); + const [inputId, setInputId] = useState(null); + const onEnterRef = useRef<(modifiers: InputModifiers) => void>(() => {}); + const editorFocusedRef = useRef(false); + const historyLength = useAppSelector((store) => store.session.history.length); + + // Listen for changes to mainEditorContentTrigger in Redux + const mainEditorContentTrigger = useAppSelector( + (store) => store.session.mainEditorContentTrigger, + ); + + useEffect(() => { + if (mainEditor && mainEditorContentTrigger) { + queueMicrotask(() => { + mainEditor.commands.setContent(mainEditorContentTrigger); + }); + // Clear the trigger after using it + dispatch(setMainEditorContentTrigger(undefined)); + } + }, [mainEditor, mainEditorContentTrigger, dispatch]); + + // Update focused ref when editor focus state changes + useEffect(() => { + if (mainEditor) { + const updateFocus = () => { + editorFocusedRef.current = mainEditor.isFocused || false; + }; + + mainEditor.on("focus", updateFocus); + mainEditor.on("blur", updateFocus); + + return () => { + mainEditor.off("focus", updateFocus); + mainEditor.off("blur", updateFocus); + }; + } + }, [mainEditor]); + + // Set up main editor webview listeners when we have a valid editor and input ID + useMainEditorWebviewListeners({ + editor: mainEditor, + onEnterRef, + dispatch, + historyLength, + inputId: inputId || "", + editorFocusedRef, + }); + + const setMainEditor = (newEditor: Editor | null) => { + setMainEditorInternal(newEditor); + }; + + const value: MainEditorContextType = { + mainEditor, + setMainEditor, + inputId, + setInputId, + onEnterRef, + }; + + return ( + + {children} + + ); +}; + +/** + * Hook to access the main editor context + */ +export const useMainEditor = (): MainEditorContextType => { + const context = useContext(MainEditorContext); + if (context === undefined) { + throw new Error("useMainEditor must be used within a MainEditorProvider"); + } + return context; +}; diff --git a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx index 6d20b2f1c..24a9d4aa6 100644 --- a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx @@ -7,16 +7,13 @@ import useIsOSREnabled from "../../../hooks/useIsOSREnabled"; import useUpdatingRef from "../../../hooks/useUpdatingRef"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { selectDefaultModel } from "../../../redux/slices/configSlice"; -import { - selectIsInEditMode, - setMainEditorContentTrigger, -} from "../../../redux/slices/sessionSlice"; +import { selectIsInEditMode } from "../../../redux/slices/sessionSlice"; import InputToolbar, { ToolbarOptions } from "../InputToolbar"; import { ComboBoxItem } from "../types"; import { DragOverlay } from "./DragOverlay"; +import { useMainEditor } from "./MainEditorProvider"; import { InputBoxDiv } from "./StyledComponents"; import "./TipTapEditor.css"; -import { useWebviewListeners } from "./useWebviewListeners"; import { handleImageFile } from "./utils"; import { createEditorConfig, getPlaceholderText } from "./utils/editorConfig"; import { useEditorEventHandlers } from "./utils/keyHandlers"; @@ -41,6 +38,7 @@ export const TIPPY_DIV_ID = "tippy-js-div"; function TipTapEditor(props: TipTapEditorProps) { const dispatch = useAppDispatch(); + const mainEditorContext = useMainEditor(); const ideMessenger = useContext(IdeMessengerContext); @@ -57,6 +55,15 @@ function TipTapEditor(props: TipTapEditorProps) { dispatch, }); + // Register the main editor with the provider + useEffect(() => { + if (props.isMainInput && editor) { + mainEditorContext.setMainEditor(editor); + mainEditorContext.setInputId(props.inputId); + mainEditorContext.onEnterRef.current = onEnterRef.current; + } + }, [editor, props.isMainInput, props.inputId, mainEditorContext, onEnterRef]); + const [shouldHideToolbar, setShouldHideToolbar] = useState(true); useEffect(() => { @@ -101,30 +108,6 @@ function TipTapEditor(props: TipTapEditorProps) { } }, [props.isMainInput, isStreaming, editor]); - // This allows anywhere in the app to set the content of the main input - const mainInputContentTrigger = useAppSelector( - (store) => store.session.mainEditorContentTrigger, - ); - useEffect(() => { - if (!props.isMainInput || !mainInputContentTrigger) { - return; - } - queueMicrotask(() => { - editor?.commands.setContent(mainInputContentTrigger); - }); - dispatch(setMainEditorContentTrigger(undefined)); - }, [editor, props.isMainInput, mainInputContentTrigger]); - - // IDE event listeners - useWebviewListeners({ - editor, - onEnterRef, - dispatch, - historyLength, - props, - editorFocusedRef, - }); - const [showDragOverMsg, setShowDragOverMsg] = useState(false); const [activeKey, setActiveKey] = useState(null); @@ -186,9 +169,6 @@ function TipTapEditor(props: TipTapEditorProps) { setShouldHideToolbar(false); }, [cancelBlurTimeout]); - // TODO pass clear blur timeout to model and mode selectors - // Seems like unnecessary for now? - return ( void>; dispatch: AppDispatch; historyLength: number; - props: TipTapEditorProps; + inputId: string; editorFocusedRef: MutableRefObject; }) { - const { - editor, - onEnterRef, - dispatch, - historyLength, - props, - editorFocusedRef, - } = options; + useWebviewListener( + "isContinueInputFocused", + async () => { + return !!editorFocusedRef.current; + }, + [editorFocusedRef], + ); useWebviewListener( "userInput", async (data) => { - if (!props.isMainInput) { - return; - } - editor?.commands.insertContent(data.input); + if (!editor) return; + editor.commands.insertContent(data.input); onEnterRef.current({ useCodebase: false, noContext: true }); }, - [editor, onEnterRef.current, props.isMainInput], + [editor, onEnterRef.current], ); useWebviewListener("jetbrains/editorInsetRefresh", async () => { @@ -47,11 +53,7 @@ export function useWebviewListeners(options: { useWebviewListener( "focusContinueInput", - async (data) => { - if (!props.isMainInput) { - return; - } - + async () => { dispatch(clearCodeToEdit()); if (historyLength > 0) { @@ -62,52 +64,46 @@ export function useWebviewListeners(options: { }), ); } + setTimeout(() => { editor?.commands.blur(); editor?.commands.focus("end"); }, 20); }, - [historyLength, editor, props.isMainInput], + [historyLength, editor, dispatch], ); useWebviewListener( "focusContinueInputWithoutClear", async () => { - if (!props.isMainInput) { - return; - } setTimeout(() => { editor?.commands.focus("end"); }, 20); }, - [editor, props.isMainInput], + [editor], ); useWebviewListener( "focusContinueInputWithNewSession", async () => { - if (!props.isMainInput) { - return; - } await dispatch( saveCurrentSession({ openNewSession: true, generateTitle: true, }), ); + setTimeout(() => { editor?.commands.focus("end"); }, 20); }, - [editor, props.isMainInput], + [editor, dispatch], ); useWebviewListener( "highlightedCode", async (data) => { - if (!props.isMainInput || !editor) { - return; - } + if (!editor) return; const contextItem = rifWithContentsToContextItem( data.rangeInFileWithContents, @@ -124,23 +120,25 @@ export function useWebviewListeners(options: { break; } } + editor .chain() .insertContentAt(index, { type: CodeBlockExtension.name, attrs: { item: contextItem, - inputId: props.inputId, + inputId, }, }) .run(); dispatch( setNewestCodeblocksForInput({ - inputId: props.inputId, + inputId, contextItemId: contextItem.id.itemId, }), ); + if (data.prompt) { editor.commands.focus("end"); editor.commands.insertContent(data.prompt); @@ -155,52 +153,42 @@ export function useWebviewListeners(options: { editor.commands.focus("end"); }, 20); }, - [editor, props.isMainInput, historyLength, onEnterRef.current], + [editor, inputId, onEnterRef.current], ); useWebviewListener( "focusEdit", async () => { - if (!props.isMainInput) { - return; - } - setTimeout(() => { editor?.commands.focus("end"); }, 20); }, - [editor, props.isMainInput], + [editor], ); useWebviewListener( "focusEditWithoutClear", async () => { - if (!props.isMainInput) { - return; - } - setTimeout(() => { editor?.commands.focus("end"); }, 2000); }, - [editor, props.isMainInput], + [editor], ); useWebviewListener( "isContinueInputFocused", async () => { - return props.isMainInput && !!editorFocusedRef.current; + return !!editorFocusedRef.current; }, - [editorFocusedRef, props.isMainInput], - !props.isMainInput, + [editorFocusedRef], ); useWebviewListener( "focusContinueSessionId", async (data) => { - if (!props.isMainInput || !data.sessionId) { - return; - } + if (!data.sessionId) return; + await dispatch( loadSession({ sessionId: data.sessionId, @@ -208,6 +196,6 @@ export function useWebviewListeners(options: { }), ); }, - [props.isMainInput], + [], ); } From bbb180531e7270d388be48dd69601bd259eacb27 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 18:10:06 -0700 Subject: [PATCH 08/67] glob search working --- .../continue/IntelliJIde.kt | 115 ++++++------ extensions/vscode/src/VsCodeIde.ts | 169 +++++++++++++----- 2 files changed, 194 insertions(+), 90 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 84d62b680..fc0474be6 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -7,6 +7,8 @@ import com.github.continuedev.continueintellijextension.utils.* import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil +import com.intellij.find.FindModel +import com.intellij.find.impl.FindInProjectUtil import com.intellij.ide.plugins.PluginManager import com.intellij.ide.plugins.PluginManagerCore import com.intellij.lang.annotation.HighlightSeverity @@ -20,8 +22,10 @@ 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.progress.EmptyProgressIndicator import com.intellij.openapi.project.Project import com.intellij.openapi.project.guessProjectDir +import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.util.IconLoader import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFileManager @@ -29,6 +33,8 @@ import com.intellij.psi.PsiDocumentManager import com.intellij.psi.search.FilenameIndex import com.intellij.psi.search.GlobalSearchScope import com.intellij.testFramework.LightVirtualFile +import com.intellij.usages.FindUsagesProcessPresentation +import com.intellij.usages.UsageViewPresentation import kotlinx.coroutines.* import java.awt.Toolkit import java.awt.datatransfer.DataFlavor @@ -327,58 +333,67 @@ class IntelliJIDE( return listOf("") } override suspend fun getSearchResults(query: String): String { - // val findModel = FindModel().apply { - // stringToFind = searchText - // isRegularExpressions = false - // isWholeWordsOnly = false - // isCaseSensitive = false - // searchContext = FindModel.SearchContext.ANY - // isGlobal = true - // } + val ideInfo = this.getIdeInfo() + if (ideInfo.remoteName != "local") { + val command = GeneralCommandLine( + ripgrep, + "-i", + "--ignore-file", + ".continueignore", + "--ignore-file", + ".gitignore", + "-C", + "2", + "--heading", + "-e", + query, + "." + ) - // val findManager = FindManager.getInstance(project) - // val scope = GlobalSearchScope.projectScope(project) - - // FindInProjectUtil.findUsages( - // findModel, - // project.basePath, - // project, - // { - // // Process each found usage - // val virtualFile = it.virtualFile - // val lineNumber = it.line - // // Handle result - // }, - // scope - // ) - - // return withContext(Dispatchers.IO) { - // val findModel = FindModel().apply { - // stringToFind = query - // isRegularExpressions = false - // isWholeWordsOnly = false - // isCaseSensitive = false - // searchContext = UsageSearchContext.ANY - // } - - // val results = StringBuilder() - // runReadAction { - // FindInProjectUtil.findUsages( - // findModel, - // project.baseDir, - // { - // results.append("${it.file.path}:${it.line + 1}: ${it.lineText}\n") - // true - // }, - // null - // ) - // } - // results.toString() - // } - val command = GeneralCommandLine(ripgrep, "-i", "-C", "2", "--heading", "-e", query, ".") - command.setWorkDirectory(project.basePath) - return ExecUtil.execAndGetOutput(command).stdout + command.setWorkDirectory(project.basePath) + return ExecUtil.execAndGetOutput(command).stdout + } else { + return "Ripgrep not supported, this workspace is remote" + // For remote workspaces, use JetBrains search functionality +// val searchResults = StringBuilder() +// ApplicationManager.getApplication().invokeAndWait { +// val options = FindModel().apply { +// stringToFind = query +// isCaseSensitive = false +// isRegularExpressions = false +// isWholeWordsOnly = false +// searchContext = FindModel.SearchContext.ANY // or IN_CODE, IN_COMMENTS, IN_STRING_LITERALS, etc. +// isMultiline = true // Allow matching across multiple lines +// } +// +// val progressIndicator = EmptyProgressIndicator() +// val presentation = FindUsagesProcessPresentation( +// UsageViewPresentation() +// ) +// val filesToSearch = ProjectFileIndex.getInstance(project) +// .iterateContent(::ArrayList) +// .filterNot { it.isDirectory } +// .toSet() +// +// +// FindInProjectUtil.findUsages( +// options, +// project, +// progressIndicator, +// presentation, +// filesToSearch +// ) { result -> +// val virtualFile = result.virtualFile +// searchResults.append(virtualFile.path).append("\n") +// searchResults.append("${result..trim()}\n") +// true // continue searching +// } +// } +// return searchResults.toString() +// +// val scope = GlobalSearchScope.projectScope(project) } +} override suspend fun subprocess(command: String, cwd: String?): List { val commandList = command.split(" ") diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index ba8f791ca..3c8b66dcd 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -555,54 +555,143 @@ class VsCodeIde implements IDE { .map((t) => (t.input as vscode.TabInputText).uri.toString()); } + runRipgrepQuery(dirUri: string, args: string[]) { + const relativeDir = vscode.Uri.parse(dirUri).fsPath; + const ripGrepUri = vscode.Uri.joinPath( + getExtensionUri(), + "out/node_modules/@vscode/ripgrep/bin/rg", + ); + const p = child_process.spawn(ripGrepUri.fsPath, args, { + cwd: relativeDir, + }); + let output = ""; + + p.stdout.on("data", (data) => { + output += data.toString(); + }); + + return new Promise((resolve, reject) => { + p.on("error", reject); + p.on("close", (code) => { + if (code === 0) { + resolve(output); + } else if (code === 1) { + // No matches + resolve("No matches found"); + } else { + reject(new Error(`Process exited with code ${code}`)); + } + }); + }); + } + async getFileResults(pattern: string): Promise { - // vscode.workspace.findFiles(""); - return ["file1", "file2"]; + const MAX_FILE_RESULTS = 200; + if (vscode.env.remoteName) { + // TODO better tests for this remote search implementation + // throw new Error("Ripgrep not supported, this workspace is remote"); + + // IMPORTANT: findFiles automatically accounts for .gitignore + const ignoreFiles = await vscode.workspace.findFiles( + "**/.continueignore", + null, + ); + + const ignoreGlobs: Set = new Set(); + for (const file of ignoreFiles) { + const content = await vscode.workspace.fs.readFile(file); + const filePath = vscode.workspace.asRelativePath(file); + const fileDir = filePath + .replace(/\\/g, "/") + .replace(/\/$/, "") + .split("/") + .slice(0, -1) + .join("/"); + + const patterns = Buffer.from(content) + .toString() + .split("\n") + .map((line) => line.trim()) + .filter( + (line) => line && !line.startsWith("#") && !pattern.startsWith("!"), + ); + // VSCode does not support negations + + patterns + // Handle prefix + .map((pattern) => { + const normalizedPattern = pattern.replace(/\\/g, "/"); + + if (normalizedPattern.startsWith("/")) { + if (fileDir) { + return `{/,}${normalizedPattern}`; + } else { + return `${fileDir}/${normalizedPattern.substring(1)}`; + } + } else { + if (fileDir) { + return `${fileDir}/${normalizedPattern}`; + } else { + return `**/${normalizedPattern}`; + } + } + }) + // Handle suffix + .map((pattern) => { + return pattern.endsWith("/") ? `${pattern}**/*` : pattern; + }) + .forEach((pattern) => { + ignoreGlobs.add(pattern); + }); + } + + const ignoreGlobsArray = Array.from(ignoreGlobs); + + const results = await vscode.workspace.findFiles( + pattern, + ignoreGlobs.size ? `{${ignoreGlobsArray.join(",")}}` : null, + MAX_FILE_RESULTS, + ); + return results.map((result) => vscode.workspace.asRelativePath(result)); + } else { + const results: string[] = []; + for (const dir of await this.getWorkspaceDirs()) { + const dirResults = await this.runRipgrepQuery(dir, [ + "--files", + "--iglob", + pattern, + "--ignore-file", + ".continueignore", + "--ignore-file", + ".gitignore", + ]); + + results.push(dirResults); + } + + return results.join("\n").split("\n").slice(0, MAX_FILE_RESULTS); + } } async getSearchResults(query: string): Promise { if (vscode.env.remoteName) { - return "Ripgrep not supported, this workspace is remote"; + throw new Error("Ripgrep not supported, this workspace is remote"); } const results: string[] = []; for (const dir of await this.getWorkspaceDirs()) { - const relativeDir = vscode.Uri.parse(dir).fsPath; - const ripGrepUri = vscode.Uri.joinPath( - getExtensionUri(), - "out/node_modules/@vscode/ripgrep/bin/rg", - ); - const p = child_process.spawn( - ripGrepUri.fsPath, - [ - "-i", // Case-insensitive search - "-C", - "2", // Show 2 lines of context - "--heading", // Only show filepath once per result - "-e", - query, // Pattern to search for - ".", // Directory to search in - ], - { cwd: relativeDir }, - ); - let output = ""; - - p.stdout.on("data", (data) => { - output += data.toString(); - }); - - const dirResults = await new Promise((resolve, reject) => { - p.on("error", reject); - p.on("close", (code) => { - if (code === 0) { - resolve(output); - } else if (code === 1) { - // No matches - resolve("No matches found"); - } else { - reject(new Error(`Process exited with code ${code}`)); - } - }); - }); + const dirResults = await this.runRipgrepQuery(dir, [ + "-i", // Case-insensitive search + "--ignore-file", + ".continueignore", + "--ignore-file", + ".gitignore", + "-C", + "2", // Show 2 lines of context + "--heading", // Only show filepath once per result + "-e", + query, // Pattern to search for + ".", // Directory to search in + ]); results.push(dirResults); } From d4e1609d2a65aeeece6caa8620a1b45196f40c98 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 3 Apr 2025 18:15:30 -0700 Subject: [PATCH 09/67] feat: add slash command cmd --- .../ConversationStarterCards.tsx | 15 +-- ...ckExtension.tsx => CodeblockExtension.tsx} | 2 +- .../extensions/PromptExtension.ts | 33 +------ .../extensions/SlashCommandExtension.ts | 99 +++++++++++++------ .../TipTapEditor/extensions/index.ts | 4 +- .../useMainEditorWebviewListeners.ts | 6 +- .../TipTapEditor/utils/editorConfig.ts | 2 +- .../utils/resolveEditorContent.ts | 4 +- .../mainInput/util/handleMetaKeyIssues.ts | 4 +- gui/src/redux/thunks/updateFileSymbols.ts | 4 +- 10 files changed, 89 insertions(+), 84 deletions(-) rename gui/src/components/mainInput/TipTapEditor/extensions/{CodeBlockExtension.tsx => CodeblockExtension.tsx} (93%) diff --git a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx index 07d0b0cdb..6d29a1df6 100644 --- a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx +++ b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx @@ -5,14 +5,13 @@ import { MAIN_EDITOR_INPUT_ID } from "../../pages/gui/Chat"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { setNewestCodeblocksForInput } from "../../redux/slices/sessionSlice"; import { useMainEditor } from "../mainInput/TipTapEditor"; -import { - createParagraphNodeFromSlashCmdDescription, - createPromptBlockNodeFromSlashCmdDescription, -} from "../mainInput/TipTapEditor/extensions"; import { ConversationStarterCard } from "./ConversationStarterCard"; const NUM_CARDS_TO_RENDER = 5; +/** + * Displays a grid of conversation starter cards for bookmarked slash commands + */ export function ConversationStarterCards() { const dispatch = useAppDispatch(); const { mainEditor } = useMainEditor(); @@ -34,13 +33,7 @@ export function ConversationStarterCards() { }), ); - mainEditor?.commands.setContent({ - type: "doc", - content: [ - createPromptBlockNodeFromSlashCmdDescription(command), - createParagraphNodeFromSlashCmdDescription(command), - ], - }); + mainEditor?.commands.insertSlashCommand(command); } if (bookmarkedSlashCommands.length === 0) { diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlockExtension.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension.tsx similarity index 93% rename from gui/src/components/mainInput/TipTapEditor/extensions/CodeBlockExtension.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension.tsx index 3618a69ba..9c36ec9c9 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlockExtension.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension.tsx @@ -4,7 +4,7 @@ import { CodeblockPreview } from "../toolbar-previews/CodeblockPreview"; export const CODEBLOCK_NAME = "codeblock"; -export const CodeBlockExtension = Node.create({ +export const CodeblockExtension = Node.create({ name: CODEBLOCK_NAME, group: "block", diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts index d5c5b6d7b..1b18e30b8 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts @@ -1,7 +1,5 @@ import { mergeAttributes, Node } from "@tiptap/core"; import { ReactNodeViewRenderer } from "@tiptap/react"; -import { ContextItemWithId, SlashCommandDescription } from "core"; -import { MAIN_EDITOR_INPUT_ID } from "../../../../pages/gui/Chat"; import { PromptBlockPreview } from "../toolbar-previews/PromptBlockPreview"; export interface PromptOptions { @@ -16,8 +14,6 @@ export const PROMPT_BLOCK_NAME = "prompt-block"; export const PromptExtension = Node.create({ name: PROMPT_BLOCK_NAME, group: "block", - // atom: true, - // draggable: true, addOptions() { return { @@ -51,31 +47,4 @@ export const PromptExtension = Node.create({ addNodeView() { return ReactNodeViewRenderer(PromptBlockPreview); }, -}); - -/** - * Creates a prompt block node from a slash command description - * @param command The slash command description to create the block from - * @param inputId Optional input ID, defaults to main editor input ID - * @returns A node object representing the prompt block - */ -export const createPromptBlockNodeFromSlashCmdDescription = ( - command: SlashCommandDescription, - inputId: string = MAIN_EDITOR_INPUT_ID, -) => { - return { - type: PromptExtension.name, - attrs: { - item: { - content: command.prompt, - name: command.name, - description: command.description || "", - id: { - providerTitle: "prompt", - itemId: command.name, - }, - } as ContextItemWithId, - inputId, - }, - }; -}; +}); \ No newline at end of file diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts index eb97e6227..2c48ff56f 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts @@ -6,6 +6,8 @@ import { PluginKey } from "@tiptap/pm/state"; import Suggestion, { SuggestionOptions } from "@tiptap/suggestion"; import { ContextItemWithId, SlashCommandDescription } from "core"; import { v4 as uuidv4 } from "uuid"; +import { MAIN_EDITOR_INPUT_ID } from "../../../../pages/gui/Chat"; +import { PROMPT_BLOCK_NAME } from "./PromptExtension"; export type SlashCommandOptions = { HTMLAttributes: Record; @@ -18,6 +20,22 @@ export const SLASH_CMD_SUGGESTION_CHAR = "/"; export const SlashCommandPluginKey = new PluginKey(SLASH_CMD_NAME); +declare module "@tiptap/core" { + interface Commands { + slashCommand: { + /** + * Insert a slash command and its associated prompt block + * @param command The slash command description + * @param inputId The input ID (defaults to MAIN_EDITOR_INPUT_ID) + */ + insertSlashCommand: ( + command: SlashCommandDescription, + inputId?: string, + ) => ReturnType; + }; + } +} + export const SlashCommandExtension = Node.create({ name: SLASH_CMD_NAME, @@ -58,9 +76,6 @@ export const SlashCommandExtension = Node.create({ const promptId = uuidv4(); - // Create a generic "promptToPromptBlockExtension" fn - // For here and in the conversation starters - editor .chain() .focus() @@ -200,30 +215,58 @@ export const SlashCommandExtension = Node.create({ }), ]; }, -}); -/** - * Creates a paragraph node containing a slash command reference - * @param command The slash command description to create the reference from - * @returns A node object representing the paragraph with slash command - */ -export const createParagraphNodeFromSlashCmdDescription = ( - command: SlashCommandDescription, -) => { - return { - type: "paragraph", - content: [ - { - type: SlashCommandExtension.name, - attrs: { - id: command.name, - label: command.name, + addCommands() { + return { + insertSlashCommand: + ( + command: SlashCommandDescription, + inputId: string = MAIN_EDITOR_INPUT_ID, + ) => + ({ chain }) => { + // Create the document with both a prompt block and the slash command paragraph + return chain() + .setContent({ + type: "doc", + content: [ + // Add the prompt block at the beginning + { + type: PROMPT_BLOCK_NAME, + attrs: { + item: { + content: command.prompt, + name: command.name, + description: command.description || "", + id: { + providerTitle: "prompt", + itemId: command.name, + }, + } as ContextItemWithId, + inputId, + }, + }, + // Add the paragraph with the slash command + { + type: "paragraph", + content: [ + { + type: this.name, + attrs: { + id: command.name, + label: command.name, + }, + }, + { + type: "text", + text: " ", + }, + ], + }, + ], + }) + .focus() + .run(); }, - }, - { - type: "text", - text: " ", - }, - ], - }; -}; + }; + }, +}); diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts index 82bddd2a9..a790c5b0c 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/index.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts @@ -1,5 +1,5 @@ export * from "./AddCodeToEditExtension"; -export * from "./CodeBlockExtension"; +export * from "./CodeblockExtension"; export * from "./MentionExtension"; export * from "./PromptExtension"; -export * from "./SlashCommandExtension"; +export * from "./SlashCommandExtension"; \ No newline at end of file diff --git a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts index 43e9fdecc..90bfcd8cc 100644 --- a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts +++ b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts @@ -9,7 +9,7 @@ import { } from "../../../redux/slices/sessionSlice"; import { AppDispatch } from "../../../redux/store"; import { loadSession, saveCurrentSession } from "../../../redux/thunks/session"; -import { CodeBlockExtension } from "./extensions"; +import { CodeblockExtension } from "./extensions"; /** * Hook for setting up main editor specific webview listeners @@ -114,7 +114,7 @@ export function useMainEditorWebviewListeners({ if (el.attrs?.item?.name === contextItem.name) { return; // Prevent exact duplicate code blocks } - if (el.type === CodeBlockExtension.name) { + if (el.type === CodeblockExtension.name) { index += 2; } else { break; @@ -124,7 +124,7 @@ export function useMainEditorWebviewListeners({ editor .chain() .insertContentAt(index, { - type: CodeBlockExtension.name, + type: CodeblockExtension.name, attrs: { item: contextItem, inputId, diff --git a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index 384d4aee6..d2c77529d 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -364,7 +364,7 @@ export function createEditorConfig(options: { class: "prompt-block", }, }), - ContinueExtensions.CodeBlockExtension, + ContinueExtensions.CodeblockExtension, ], editorProps: { attributes: { diff --git a/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts index 5ffd77ffc..5476f100c 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts @@ -19,7 +19,7 @@ import { getUriFileExtension } from "core/util/uri"; import { IIdeMessenger } from "../../../../context/IdeMessenger"; import { setIsGatheringContext } from "../../../../redux/slices/sessionSlice"; import { - CodeBlockExtension, + CodeblockExtension, MentionExtension, SlashCommandExtension, } from "../extensions"; @@ -86,7 +86,7 @@ function processEditorContent(editorState: JSONContent) { return [...parts, { type: "text", text }]; } - case CodeBlockExtension.name: { + case CodeblockExtension.name: { if (!p.attrs?.item) { console.warn("codeBlock has no item attribute"); return parts; diff --git a/gui/src/components/mainInput/util/handleMetaKeyIssues.ts b/gui/src/components/mainInput/util/handleMetaKeyIssues.ts index 6c9406830..b147a5609 100644 --- a/gui/src/components/mainInput/util/handleMetaKeyIssues.ts +++ b/gui/src/components/mainInput/util/handleMetaKeyIssues.ts @@ -1,7 +1,7 @@ import { Editor } from "@tiptap/react"; import { KeyboardEvent } from "react"; import { getPlatform, isWebEnvironment } from "../../../util"; -import { CodeBlockExtension } from "../TipTapEditor/extensions"; +import { CodeblockExtension } from "../TipTapEditor/extensions"; const isWebEnv = isWebEnvironment(); @@ -104,7 +104,7 @@ export const handleJetBrainsMetaBackspace = (editor: Editor) => { for (let i = doc.content.childCount - 1; i >= 0; i--) { const node = doc.content.child(i); - if (node.type.name === CodeBlockExtension.name) { + if (node.type.name === CodeblockExtension.name) { continue; } diff --git a/gui/src/redux/thunks/updateFileSymbols.ts b/gui/src/redux/thunks/updateFileSymbols.ts index 5f3e5e18d..c237e4216 100644 --- a/gui/src/redux/thunks/updateFileSymbols.ts +++ b/gui/src/redux/thunks/updateFileSymbols.ts @@ -1,6 +1,6 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import { ChatHistoryItem, ContextItemWithId } from "core"; -import { CodeBlockExtension } from "../../components/mainInput/TipTapEditor/extensions"; +import { CodeblockExtension } from "../../components/mainInput/TipTapEditor/extensions"; import { updateFileSymbols } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; @@ -26,7 +26,7 @@ export function getContextItemsFromHistory( .flatMap((item) => item.editorState.content) .filter( (content) => - content?.type === CodeBlockExtension.name && + content?.type === CodeblockExtension.name && content?.attrs?.item?.uri?.value && content.attrs.item.uri?.type === "file", ) From 2baf137c0c6f008d647461899bf8697862ade9bd Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 3 Apr 2025 18:24:02 -0700 Subject: [PATCH 10/67] Update SlashCommandExtension.ts --- .../extensions/SlashCommandExtension.ts | 45 +++---------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts index 2c48ff56f..d29246e5e 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts @@ -5,14 +5,14 @@ import { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { PluginKey } from "@tiptap/pm/state"; import Suggestion, { SuggestionOptions } from "@tiptap/suggestion"; import { ContextItemWithId, SlashCommandDescription } from "core"; -import { v4 as uuidv4 } from "uuid"; import { MAIN_EDITOR_INPUT_ID } from "../../../../pages/gui/Chat"; +import { ComboBoxItem } from "../../types"; import { PROMPT_BLOCK_NAME } from "./PromptExtension"; export type SlashCommandOptions = { HTMLAttributes: Record; renderText: (props: { node: ProseMirrorNode }) => string; - suggestion: Omit; + suggestion: Omit, "editor">; }; export const SLASH_CMD_NAME = "slash-command"; @@ -59,42 +59,11 @@ export const SlashCommandExtension = Node.create({ range.to += 1; } - editor - .chain() - .focus() - .insertContentAt(range, [ - { - type: this.name, - attrs: props, - }, - { - type: "text", - text: " ", - }, - ]) - .run(); - - const promptId = uuidv4(); - - editor - .chain() - .focus() - .insertContentAt(0, { - type: "promptBlock", - attrs: { - item: { - content: props.content, - name: props.title, - description: props.description, - id: { - providerTitle: "prompt", - itemId: props.name, - }, - } as ContextItemWithId, - inputId: promptId, - }, - }) - .run(); + editor.commands.insertSlashCommand({ + name: props.title, + description: props.description, + prompt: props.content, + }); window.getSelection()?.collapseToEnd(); }, From 10a9e847f0c96eea22f1cf7ad93a45be46dbc0f8 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 18:32:04 -0700 Subject: [PATCH 11/67] cleanup --- .../continue/IntelliJIde.kt | 145 +++++++++++------- 1 file changed, 86 insertions(+), 59 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index fc0474be6..ce1eea771 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -30,11 +30,7 @@ import com.intellij.openapi.util.IconLoader import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.search.FilenameIndex -import com.intellij.psi.search.GlobalSearchScope import com.intellij.testFramework.LightVirtualFile -import com.intellij.usages.FindUsagesProcessPresentation -import com.intellij.usages.UsageViewPresentation import kotlinx.coroutines.* import java.awt.Toolkit import java.awt.datatransfer.DataFlavor @@ -45,7 +41,6 @@ import java.io.InputStreamReader import java.net.URI import java.nio.charset.Charset import java.nio.file.Paths -import org.apache.tools.ant.DirectoryScanner class IntelliJIDE( private val project: Project, @@ -55,7 +50,6 @@ class IntelliJIDE( private val gitService = GitService(project, continuePluginService) - private val ripgrep: String init { @@ -319,22 +313,55 @@ class IntelliJIDE( } override suspend fun getFileResults(pattern: String): List { - // val scanner = DirectoryScanner().apply { - // includes = arrayOf(pattern) - // } - - // val projectBasePath = project.basePath ?: return emptyList() - - // return FilenameIndex.getAllFilesByExt(project, "*", GlobalSearchScope.projectScope(project)) - // .filter { virtualFile -> - // scanner.match(virtualFile.path.replace('\\', '/'), globPattern) - // } - // .map { it.path.removePrefix("$projectBasePath/") } - return listOf("") + val ideInfo = this.getIdeInfo() + if (ideInfo.remoteName == "local") { + val command = GeneralCommandLine( + ripgrep, + "--files", + "--iglob", + pattern, + "--ignore-file", + ".continueignore", + "--ignore-file", + ".gitignore", + ) + + command.setWorkDirectory(project.basePath) + val results = ExecUtil.execAndGetOutput(command).stdout + return results.split("\n") + } else { + throw NotImplementedError("Ripgrep not supported, this workspace is remote") + + // Leaving in here for ideas + // val projectBasePath = project.basePath ?: return emptyList() + // val scope = GlobalSearchScope.projectScope(project) + // + // // Get all ignore patterns from .continueignore files + // val ignorePatterns = mutableSetOf() + // VirtualFileManager.getInstance().findFileByUrl("file://$projectBasePath")?.let { root -> + // VfsUtil.collectChildrenRecursively(root).forEach { file -> + // if (file.name == ".continueignore") { + // file.inputStream.bufferedReader().useLines { lines -> + // ignorePatterns.addAll(lines.filter { it.isNotBlank() && !it.startsWith("#") }) + // } + // } + // } + // } + // + // return FilenameIndex.getAllFilesByExt(project, "*", scope) + // .filter { file -> + // val relativePath = file.path.removePrefix("$projectBasePath/") + // // Check if file matches pattern and isn't ignored + // PatternUtil.(relativePath, pattern) && + // !ignorePatterns.any { PatternUtil.matchesGlob(relativePath, it) } + // } + // .map { it.path.removePrefix("$projectBasePath/") } + } } + override suspend fun getSearchResults(query: String): String { val ideInfo = this.getIdeInfo() - if (ideInfo.remoteName != "local") { + if (ideInfo.remoteName == "local") { val command = GeneralCommandLine( ripgrep, "-i", @@ -353,47 +380,47 @@ class IntelliJIDE( command.setWorkDirectory(project.basePath) return ExecUtil.execAndGetOutput(command).stdout } else { - return "Ripgrep not supported, this workspace is remote" - // For remote workspaces, use JetBrains search functionality -// val searchResults = StringBuilder() -// ApplicationManager.getApplication().invokeAndWait { -// val options = FindModel().apply { -// stringToFind = query -// isCaseSensitive = false -// isRegularExpressions = false -// isWholeWordsOnly = false -// searchContext = FindModel.SearchContext.ANY // or IN_CODE, IN_COMMENTS, IN_STRING_LITERALS, etc. -// isMultiline = true // Allow matching across multiple lines -// } -// -// val progressIndicator = EmptyProgressIndicator() -// val presentation = FindUsagesProcessPresentation( -// UsageViewPresentation() -// ) -// val filesToSearch = ProjectFileIndex.getInstance(project) -// .iterateContent(::ArrayList) -// .filterNot { it.isDirectory } -// .toSet() -// -// -// FindInProjectUtil.findUsages( -// options, -// project, -// progressIndicator, -// presentation, -// filesToSearch -// ) { result -> -// val virtualFile = result.virtualFile -// searchResults.append(virtualFile.path).append("\n") -// searchResults.append("${result..trim()}\n") -// true // continue searching -// } -// } -// return searchResults.toString() -// -// val scope = GlobalSearchScope.projectScope(project) + throw NotImplementedError("Ripgrep not supported, this workspace is remote") + + // For remote workspaces, use JetBrains search functionality + // val searchResults = StringBuilder() + // ApplicationManager.getApplication().invokeAndWait { + // val options = FindModel().apply { + // stringToFind = query + // isCaseSensitive = false + // isRegularExpressions = false + // isWholeWordsOnly = false + // searchContext = FindModel.SearchContext.ANY // or IN_CODE, IN_COMMENTS, IN_STRING_LITERALS, etc. + // isMultiline = true // Allow matching across multiple lines + // } + // + // val progressIndicator = EmptyProgressIndicator() + // val presentation = FindUsagesProcessPresentation( + // UsageViewPresentation() + // ) + // val filesToSearch = ProjectFileIndex.getInstance(project) + // .iterateContent(::ArrayList) + // .filterNot { it.isDirectory } + // .toSet() + // + // + // FindInProjectUtil.findUsages( + // options, + // project, + // progressIndicator, + // presentation, + // filesToSearch + // ) { result -> + // val virtualFile = result.virtualFile + // searchResults.append(virtualFile.path).append("\n") + // searchResults.append("${result..trim()}\n") + // true // continue searching + // } + // } + // return searchResults.toString() + } } -} + override suspend fun subprocess(command: String, cwd: String?): List { val commandList = command.split(" ") From 9a7cebac28359abd5de260054713d0023c297c26 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 18:44:43 -0700 Subject: [PATCH 12/67] cleanup --- core/tools/implementations/grepSearch.ts | 2 +- .../continueintellijextension/continue/IntelliJIde.kt | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/core/tools/implementations/grepSearch.ts b/core/tools/implementations/grepSearch.ts index d618791e8..a506be9cd 100644 --- a/core/tools/implementations/grepSearch.ts +++ b/core/tools/implementations/grepSearch.ts @@ -6,7 +6,7 @@ export const grepSearchImpl: ToolImpl = async (args, extras) => { return [ { name: "Search results", - description: "Results from exact search", + description: "Results from grep search", content: formatGrepSearchResults(results), }, ]; diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index ce1eea771..a23f2d716 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -7,8 +7,6 @@ import com.github.continuedev.continueintellijextension.utils.* import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil -import com.intellij.find.FindModel -import com.intellij.find.impl.FindInProjectUtil import com.intellij.ide.plugins.PluginManager import com.intellij.ide.plugins.PluginManagerCore import com.intellij.lang.annotation.HighlightSeverity @@ -22,10 +20,8 @@ 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.progress.EmptyProgressIndicator import com.intellij.openapi.project.Project import com.intellij.openapi.project.guessProjectDir -import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.util.IconLoader import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFileManager From e02741cb5e641388647bda2f486e05b360fc65a9 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 19:04:28 -0700 Subject: [PATCH 13/67] edit tool first take --- core/tools/builtIn.ts | 1 + core/tools/callTool.ts | 3 ++ core/tools/definitions/editFile.ts | 28 +++++++++++++++ core/tools/implementations/editFile.ts | 22 ++++++++++++ core/tools/index.ts | 2 ++ .../StepContainerPreToolbar.tsx | 36 +++++++++++-------- .../markdown/StyledMarkdownPreview.tsx | 22 ++++++++++-- gui/src/redux/slices/uiSlice.ts | 1 + 8 files changed, 97 insertions(+), 18 deletions(-) create mode 100644 core/tools/definitions/editFile.ts create mode 100644 core/tools/implementations/editFile.ts diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index fa76358c9..4ac7ad4ae 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -1,5 +1,6 @@ export enum BuiltInToolNames { ReadFile = "builtin_read_file", + EditExistingFile = "builtin_edit_existing_file", ReadCurrentlyOpenFile = "builtin_read_currently_open_file", CreateNewFile = "builtin_create_new_file", RunTerminalCommand = "builtin_run_terminal_command", diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 25c56507c..2866124ef 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -4,6 +4,7 @@ import { canParseUrl } from "../util/url"; import { BuiltInToolNames } from "./builtIn"; import { createNewFileImpl } from "./implementations/createNewFile"; +import { editFileImpl } from "./implementations/editFile"; import { exactSearchImpl } from "./implementations/exactSearch"; import { lsToolImpl } from "./implementations/lsTool"; import { readCurrentlyOpenFileImpl } from "./implementations/readCurrentlyOpenFile"; @@ -138,6 +139,8 @@ export async function callTool( switch (uri) { case BuiltInToolNames.ReadFile: return await readFileImpl(args, extras); + case BuiltInToolNames.EditExistingFile: + return await editFileImpl(args, extras); case BuiltInToolNames.CreateNewFile: return await createNewFileImpl(args, extras); case BuiltInToolNames.ExactSearch: diff --git a/core/tools/definitions/editFile.ts b/core/tools/definitions/editFile.ts new file mode 100644 index 000000000..1ff44f7c7 --- /dev/null +++ b/core/tools/definitions/editFile.ts @@ -0,0 +1,28 @@ +import { Tool } from "../.."; +import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; + +export const editFileTool: Tool = { + type: "function", + displayTitle: "Edit File", + wouldLikeTo: "edit {{{ filepath }}}", + isCurrently: "editing {{{ filepath }}}", + hasAlready: "edited {{{ filepath }}}", + group: BUILT_IN_GROUP_NAME, + readonly: false, + function: { + name: BuiltInToolNames.EditExistingFile, + description: + "To edit an existing file, call this tool and follow the returned instructions. If you don't have the contents of the file, read it first.", + parameters: { + type: "object", + required: ["filepath"], + properties: { + filepath: { + type: "string", + description: + "The path of the file to edit, relative to the root of the workspace.", + }, + }, + }, + }, +}; diff --git a/core/tools/implementations/editFile.ts b/core/tools/implementations/editFile.ts new file mode 100644 index 000000000..80de79923 --- /dev/null +++ b/core/tools/implementations/editFile.ts @@ -0,0 +1,22 @@ +import { ToolImpl } from "."; +import { resolveRelativePathInDir } from "../../util/ideUtils"; + +export const EDIT_TOOL_CONTEXT_ITEM_NAME = "Edit Tool Instructions"; + +export const editFileImpl: ToolImpl = async (args, extras) => { + const firstUriMatch = await resolveRelativePathInDir( + args.filepath, + extras.ide, + ); + if (!firstUriMatch) { + throw new Error(`File ${args.filepath} does not exist.`); + } + return [ + { + name: EDIT_TOOL_CONTEXT_ITEM_NAME, + description: "Instructions for editing the file", + content: + "Edit Instructions: return the full new file contents in a codeblock. The codeblock header should be of the format '```language filepath'", + }, + ]; +}; diff --git a/core/tools/index.ts b/core/tools/index.ts index eea4ee79b..407510691 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -1,4 +1,5 @@ import { createNewFileTool } from "./definitions/createNewFile"; +import { editFileTool } from "./definitions/editFile"; import { exactSearchTool } from "./definitions/exactSearch"; import { lsTool } from "./definitions/lsTool"; import { readCurrentlyOpenFileTool } from "./definitions/readCurrentlyOpenFile"; @@ -9,6 +10,7 @@ import { viewDiffTool } from "./definitions/viewDiff"; export const allTools = [ readFileTool, + editFileTool, createNewFileTool, runTerminalCommandTool, diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 46fa90d68..ec0000b2c 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -3,7 +3,6 @@ import { inferResolvedUriFromRelativePath } from "core/util/ideUtils"; import { debounce } from "lodash"; import { useContext, useEffect, useRef, useState } from "react"; import styled from "styled-components"; -import { v4 as uuidv4 } from "uuid"; import { defaultBorderRadius, vscCommandCenterInactiveBorder, @@ -52,17 +51,18 @@ export interface StepContainerPreToolbarProps { relativeFilepath: string; isGeneratingCodeBlock: boolean; codeBlockIndex: number; // To track which codeblock we are applying + codeBlockStreamId: string; range?: string; children: any; expanded?: boolean; hideApply?: boolean; + autoApply?: boolean; } export default function StepContainerPreToolbar( props: StepContainerPreToolbarProps, ) { const ideMessenger = useContext(IdeMessengerContext); - const streamIdRef = useRef(uuidv4()); const wasGeneratingRef = useRef(props.isGeneratingCodeBlock); const isInEditMode = useAppSelector(selectIsInEditMode); const [isExpanded, setIsExpanded] = useState( @@ -76,7 +76,7 @@ export default function StepContainerPreToolbar( ); const applyState = useAppSelector((state) => - selectApplyStateByStreamId(state, streamIdRef.current), + selectApplyStateByStreamId(state, props.codeBlockStreamId), ); // This handles an edge case when the last node in the markdown syntax tree is a codeblock. @@ -104,7 +104,7 @@ export default function StepContainerPreToolbar( ); ideMessenger.post("applyToFile", { - streamId: streamIdRef.current, + streamId: props.codeBlockStreamId, filepath: fileUri, text: codeBlockContent, curSelectedModelTitle: defaultModel.title, @@ -135,19 +135,25 @@ export default function StepContainerPreToolbar( } }, [props.children, codeBlockContent]); - // Temporarily disabling auto apply for Edit mode // useEffect(() => { // const hasCompletedGenerating = // wasGeneratingRef.current && !isGeneratingCodeBlock; - - // const shouldAutoApply = hasCompletedGenerating && isInEditMode; - - // if (shouldAutoApply) { - // onClickApply(); - // } - + // console.log( + // wasGeneratingRef.current, + // isGeneratingCodeBlock, + // props.autoApply, + // ); // wasGeneratingRef.current = isGeneratingCodeBlock; - // }, [isGeneratingCodeBlock]); + // if (hasCompletedGenerating) { + // console.log("Completed generating", props.autoApply); + // if (props.autoApply) { + // onClickApply(); + // } + // // else if(isInEditMode) { + // // onClickApply(); + // // } + // } + // }, [wasGeneratingRef, isGeneratingCodeBlock, props.autoApply]); async function onClickAcceptApply() { const fileUri = await inferResolvedUriFromRelativePath( @@ -156,7 +162,7 @@ export default function StepContainerPreToolbar( ); ideMessenger.post("acceptDiff", { filepath: fileUri, - streamId: streamIdRef.current, + streamId: props.codeBlockStreamId, }); } @@ -167,7 +173,7 @@ export default function StepContainerPreToolbar( ); ideMessenger.post("rejectDiff", { filepath: fileUri, - streamId: streamIdRef.current, + streamId: props.codeBlockStreamId, }); } diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index d968101d0..fbd6801b9 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -1,5 +1,5 @@ import { ctxItemToRifWithContents } from "core/commands/util"; -import { memo, useEffect, useMemo } from "react"; +import { memo, useEffect, useMemo, useRef } from "react"; import { useRemark } from "react-remark"; import rehypeHighlight, { Options } from "rehype-highlight"; import rehypeKatex from "rehype-katex"; @@ -196,6 +196,10 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( }, [props.itemIndex, history, allSymbols]); const pastFileInfoRef = useUpdatingRef(pastFileInfo); + const codeblockState = useRef<{ streamId: string; isGenerating: boolean }[]>( + [], + ); + const [reactContent, setMarkdownSource] = useRemark({ remarkPlugins: [ remarkTables, @@ -282,8 +286,6 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( const { className, range } = preChildProps; const relativeFilePath = preChildProps["data-relativefilepath"]; const codeBlockContent = preChildProps["data-codeblockcontent"]; - const isGeneratingCodeBlock = - preChildProps["data-isgeneratingcodeblock"]; if (!props.isRenderingInStepContainer) { return ; @@ -307,6 +309,18 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( ); } + const isGeneratingCodeBlock = + preChildProps["data-isgeneratingcodeblock"]; + + if (codeblockState.current[codeBlockIndex] === undefined) { + codeblockState.current[codeBlockIndex] = { + streamId: uuidv4(), + isGenerating: isGeneratingCodeBlock, + }; + } + const codeblockStreamId = + codeblockState.current[codeBlockIndex].streamId; + // We use a custom toolbar for codeblocks in the step container return ( diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 9ebf8969f..e7eccbad6 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -45,6 +45,7 @@ export const uiSlice = createSlice({ ttsActive: false, toolSettings: { [BuiltInToolNames.ReadFile]: "allowedWithoutPermission", + [BuiltInToolNames.EditExistingFile]: "allowedWithPermission", [BuiltInToolNames.CreateNewFile]: "allowedWithPermission", [BuiltInToolNames.RunTerminalCommand]: "allowedWithPermission", [BuiltInToolNames.ViewSubdirectory]: "allowedWithoutPermission", From dca4685baca1ffea0e768bf0714f808a7399dc49 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 3 Apr 2025 19:14:08 -0700 Subject: [PATCH 14/67] delete cmd on click --- .../{ => components}/DragOverlay.tsx | 0 .../ExpandablePreview.tsx | 0 .../{ => components}/StyledComponents.ts | 4 +- .../TipTapEditor/components/index.ts | 3 + .../extensions/AddCodeToEditExtension.ts | 8 +- .../CodeblockExtension.tsx | 6 +- .../CodeblockExtension}/CodeblockPreview.tsx | 12 +- .../extensions/CodeblockExtension/index.ts | 1 + .../extensions/MentionExtension.ts | 8 +- .../extensions/PromptExtension.ts | 50 -------- .../PromptExtension}/PromptBlockPreview.tsx | 48 +++++--- .../PromptExtension/PromptExtension.ts | 108 ++++++++++++++++++ .../extensions/PromptExtension/index.ts | 1 + .../extensions/SlashCommandExtension.ts | 94 +++++++++++---- .../TipTapEditor/extensions/index.ts | 2 +- .../TipTapEditor/toolbar-previews/index.ts | 2 - .../TipTapEditor/utils/getSuggestion.ts | 3 +- 17 files changed, 237 insertions(+), 113 deletions(-) rename gui/src/components/mainInput/TipTapEditor/{ => components}/DragOverlay.tsx (100%) rename gui/src/components/mainInput/TipTapEditor/{toolbar-previews => components}/ExpandablePreview.tsx (100%) rename gui/src/components/mainInput/TipTapEditor/{ => components}/StyledComponents.ts (95%) create mode 100644 gui/src/components/mainInput/TipTapEditor/components/index.ts rename gui/src/components/mainInput/TipTapEditor/extensions/{ => CodeblockExtension}/CodeblockExtension.tsx (82%) rename gui/src/components/mainInput/TipTapEditor/{toolbar-previews => extensions/CodeblockExtension}/CodeblockPreview.tsx (87%) create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts delete mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts rename gui/src/components/mainInput/TipTapEditor/{toolbar-previews => extensions/PromptExtension}/PromptBlockPreview.tsx (57%) create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptExtension.ts create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts delete mode 100644 gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts diff --git a/gui/src/components/mainInput/TipTapEditor/DragOverlay.tsx b/gui/src/components/mainInput/TipTapEditor/components/DragOverlay.tsx similarity index 100% rename from gui/src/components/mainInput/TipTapEditor/DragOverlay.tsx rename to gui/src/components/mainInput/TipTapEditor/components/DragOverlay.tsx diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/ExpandablePreview.tsx b/gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx similarity index 100% rename from gui/src/components/mainInput/TipTapEditor/toolbar-previews/ExpandablePreview.tsx rename to gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx diff --git a/gui/src/components/mainInput/TipTapEditor/StyledComponents.ts b/gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts similarity index 95% rename from gui/src/components/mainInput/TipTapEditor/StyledComponents.ts rename to gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts index 2aca4f1be..f994b53d6 100644 --- a/gui/src/components/mainInput/TipTapEditor/StyledComponents.ts +++ b/gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts @@ -8,8 +8,8 @@ import { vscForeground, vscInputBackground, vscInputBorderFocus, -} from "../.."; -import { getFontSize } from "../../../util"; +} from "../../.."; +import { getFontSize } from "../../../../util"; export const InputBoxDiv = styled.div<{}>` resize: none; diff --git a/gui/src/components/mainInput/TipTapEditor/components/index.ts b/gui/src/components/mainInput/TipTapEditor/components/index.ts new file mode 100644 index 000000000..266d7e1c3 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/components/index.ts @@ -0,0 +1,3 @@ +export * from "./DragOverlay"; +export * from "./ExpandablePreview"; +export * from "./StyledComponents"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEditExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEditExtension.ts index 2aeedadf3..519074bb1 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEditExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEditExtension.ts @@ -3,12 +3,8 @@ import { PluginKey } from "@tiptap/pm/state"; import Suggestion from "@tiptap/suggestion"; import { MentionOptions } from "./types"; -export const ADD_CODE_TO_EDIT_NAME = "add-code-to-edit"; - -export const AddCodeToEditPluginKey = new PluginKey(ADD_CODE_TO_EDIT_NAME); - export const AddCodeToEditExtension = Node.create({ - name: ADD_CODE_TO_EDIT_NAME, + name: "add-code-to-edit", addOptions() { return { @@ -22,7 +18,7 @@ export const AddCodeToEditExtension = Node.create({ }, suggestion: { char: "#", - pluginKey: AddCodeToEditPluginKey, + pluginKey: new PluginKey(this.name), allow: ({ state, range }) => { const $from = state.doc.resolve(range.from); const type = state.schema.nodes[this.name]; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockExtension.tsx similarity index 82% rename from gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockExtension.tsx index 9c36ec9c9..a43c1e9d2 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockExtension.tsx @@ -1,11 +1,9 @@ import { mergeAttributes, Node } from "@tiptap/core"; import { ReactNodeViewRenderer } from "@tiptap/react"; -import { CodeblockPreview } from "../toolbar-previews/CodeblockPreview"; - -export const CODEBLOCK_NAME = "codeblock"; +import { CodeblockPreview } from "./CodeblockPreview"; export const CodeblockExtension = Node.create({ - name: CODEBLOCK_NAME, + name: "codeblock", group: "block", diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/CodeblockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockPreview.tsx similarity index 87% rename from gui/src/components/mainInput/TipTapEditor/toolbar-previews/CodeblockPreview.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockPreview.tsx index 570e518c8..66812b1df 100644 --- a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/CodeblockPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockPreview.tsx @@ -7,12 +7,12 @@ import { ContextItemWithId } from "core"; import { ctxItemToRifWithContents } from "core/commands/util"; import { dedent, getMarkdownLanguageTagForFile } from "core/util"; import { useContext, useMemo } from "react"; -import { vscBadgeBackground } from "../../.."; -import { IdeMessengerContext } from "../../../../context/IdeMessenger"; -import { useAppSelector } from "../../../../redux/hooks"; -import FileIcon from "../../../FileIcon"; -import StyledMarkdownPreview from "../../../markdown/StyledMarkdownPreview"; -import { ExpandablePreview } from "./ExpandablePreview"; +import { vscBadgeBackground } from "../../../.."; +import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { useAppSelector } from "../../../../../redux/hooks"; +import FileIcon from "../../../../FileIcon"; +import StyledMarkdownPreview from "../../../../markdown/StyledMarkdownPreview"; +import { ExpandablePreview } from "../../components/ExpandablePreview"; const backticksRegex = /`{3,}/gm; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts new file mode 100644 index 000000000..f0a5fadde --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts @@ -0,0 +1 @@ +export * from "./CodeblockExtension"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts index b81d223b4..3719cbc14 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts @@ -3,12 +3,8 @@ import { PluginKey } from "@tiptap/pm/state"; import Suggestion from "@tiptap/suggestion"; import { MentionOptions } from "./types"; -export const MENTION_NAME = "mention"; - -export const MentionPluginKey = new PluginKey(MENTION_NAME); - export const MentionExtension = Node.create({ - name: MENTION_NAME, + name: "mention", addOptions() { return { @@ -22,7 +18,7 @@ export const MentionExtension = Node.create({ }, suggestion: { char: "@", - pluginKey: MentionPluginKey, + pluginKey: new PluginKey(this.name), command: ({ editor, range, props }) => { // increase range.to by one when the next node is of type "text" // and starts with a space character diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts deleted file mode 100644 index 1b18e30b8..000000000 --- a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { mergeAttributes, Node } from "@tiptap/core"; -import { ReactNodeViewRenderer } from "@tiptap/react"; -import { PromptBlockPreview } from "../toolbar-previews/PromptBlockPreview"; - -export interface PromptOptions { - HTMLAttributes: Record; -} - -export const PROMPT_BLOCK_NAME = "prompt-block"; - -/** - * Extension for adding prompt blocks to the Tiptap editor - */ -export const PromptExtension = Node.create({ - name: PROMPT_BLOCK_NAME, - group: "block", - - addOptions() { - return { - HTMLAttributes: {}, - }; - }, - - addAttributes() { - return { - item: { - default: null, - }, - inputId: { - default: null, - }, - }; - }, - - parseHTML() { - return [ - { - tag: "prompt-block", - }, - ]; - }, - - renderHTML({ HTMLAttributes }) { - return ["prompt-block", mergeAttributes(HTMLAttributes), 0]; - }, - - addNodeView() { - return ReactNodeViewRenderer(PromptBlockPreview); - }, -}); \ No newline at end of file diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/PromptBlockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptBlockPreview.tsx similarity index 57% rename from gui/src/components/mainInput/TipTapEditor/toolbar-previews/PromptBlockPreview.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptBlockPreview.tsx index 2e02f742c..891c8edb6 100644 --- a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/PromptBlockPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptBlockPreview.tsx @@ -1,19 +1,27 @@ import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline"; -import { NodeViewWrapper, NodeViewWrapperProps } from "@tiptap/react"; -import { ContextItemWithId } from "core"; +import { + NodeViewProps, + NodeViewWrapper, + NodeViewWrapperProps, +} from "@tiptap/react"; import { useContext, useMemo } from "react"; -import { vscBadgeBackground } from "../../.."; -import { IdeMessengerContext } from "../../../../context/IdeMessenger"; -import { useAppSelector } from "../../../../redux/hooks"; -import { ExpandablePreview } from "./ExpandablePreview"; +import { vscBadgeBackground } from "../../../.."; +import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { useAppSelector } from "../../../../../redux/hooks"; +import { ExpandablePreview } from "../../components/ExpandablePreview"; +import { PromptAttributes } from "./PromptExtension"; /** * Component for prompt blocks in the Tiptap editor */ -export const PromptBlockPreview = (props: any) => { - const { node, deleteNode, selected } = props; - const item: ContextItemWithId = node.attrs.item; - const inputId = node.attrs.inputId; +export const PromptBlockPreview = ({ + node, + deleteNode, + selected, + editor, +}: NodeViewProps) => { + const { item, inputId } = node.attrs as PromptAttributes; + const ideMessenger = useContext(IdeMessengerContext); // Not setting this as a "p" will cause issues with foreign keyboards @@ -27,8 +35,6 @@ export const PromptBlockPreview = (props: any) => { return newestCodeblockForInputId !== item.id.itemId; }, [newestCodeblockForInputId, item.id.itemId]); - console.log({ id: item.id.itemId, newestCodeblockForInputId }); - const handleTitleClick = (e: React.MouseEvent) => { e.stopPropagation(); ideMessenger.post("showVirtualFile", { @@ -37,6 +43,20 @@ export const PromptBlockPreview = (props: any) => { }); }; + const handleDelete = () => { + // Use the clearSlashCommand command to properly clean up everything + if (editor) { + // Make sure this runs after the current event loop cycle + // to avoid React state update conflicts + setTimeout(() => { + editor.commands.clearSlashCommand(); + }, 0); + } else { + // Fallback to deleteNode if editor is not available + deleteNode(); + } + }; + const borderColor = selected ? vscBadgeBackground : undefined; return ( @@ -48,7 +68,7 @@ export const PromptBlockPreview = (props: any) => { title={item.name} icon={} initiallyHidden={initiallyHidden} - onDelete={() => deleteNode()} + onDelete={handleDelete} borderColor={borderColor} onTitleClick={handleTitleClick} > @@ -58,4 +78,4 @@ export const PromptBlockPreview = (props: any) => { ); -}; +}; \ No newline at end of file diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptExtension.ts new file mode 100644 index 000000000..0921fe614 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptExtension.ts @@ -0,0 +1,108 @@ +import { mergeAttributes, Node } from "@tiptap/core"; +import { ReactNodeViewRenderer } from "@tiptap/react"; +import { ContextItemWithId } from "core"; +import { Node as ProseMirrorNode } from "@tiptap/pm/model"; +import { PromptBlockPreview } from "./PromptBlockPreview"; + +export interface PromptOptions { + HTMLAttributes: Record; +} + +export interface PromptAttributes { + item: ContextItemWithId; + inputId: string; +} + +declare module "@tiptap/core" { + interface Commands { + promptBlock: { + /** + * Insert a prompt block into the editor + */ + insertPrompt: (item: ContextItemWithId, inputId: string) => ReturnType; + + /** + * Clear all prompt blocks from the editor + */ + clearPrompt: () => ReturnType; + }; + } +} + +/** + * Extension for adding prompt blocks to the Tiptap editor + */ +export const PromptExtension = Node.create({ + name: "prompt-block", + group: "block", + + addOptions() { + return { + HTMLAttributes: {}, + }; + }, + + addAttributes() { + return { + item: { + default: null, + }, + inputId: { + default: null, + }, + }; + }, + + parseHTML() { + return [ + { + tag: "prompt-block", + }, + ]; + }, + + renderHTML({ HTMLAttributes }) { + return ["prompt-block", mergeAttributes(HTMLAttributes), 0]; + }, + + addNodeView() { + return ReactNodeViewRenderer(PromptBlockPreview); + }, + + addCommands() { + return { + insertPrompt: (item: ContextItemWithId, inputId: string) => + ({ commands }) => { + return commands.insertContent({ + type: this.name, + attrs: { + item, + inputId, + }, + }); + }, + + clearPrompt: () => ({ state, commands }) => { + // Find all prompt-block nodes in the document + const promptNodes: { pos: number, node: ProseMirrorNode }[] = []; + state.doc.descendants((node, pos) => { + if (node.type.name === this.name) { + promptNodes.push({ pos, node }); + return false; // Don't descend into this node + } + return true; + }); + + // Delete all found prompt blocks + // We process them in reverse order so that deleting one doesn't affect the position of others + for (let i = promptNodes.length - 1; i >= 0; i--) { + const { pos, node } = promptNodes[i]; + commands.deleteRange({ from: pos, to: pos + node.nodeSize }); + } + + // Return true if we deleted any nodes + return promptNodes.length > 0; + }, + }; + }, +}); \ No newline at end of file diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts new file mode 100644 index 000000000..c9c12a825 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts @@ -0,0 +1 @@ +export * from "./PromptExtension"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts index d29246e5e..e8a9b3006 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts @@ -7,7 +7,7 @@ import Suggestion, { SuggestionOptions } from "@tiptap/suggestion"; import { ContextItemWithId, SlashCommandDescription } from "core"; import { MAIN_EDITOR_INPUT_ID } from "../../../../pages/gui/Chat"; import { ComboBoxItem } from "../../types"; -import { PROMPT_BLOCK_NAME } from "./PromptExtension"; +import { PromptExtension } from "./PromptExtension/PromptExtension"; export type SlashCommandOptions = { HTMLAttributes: Record; @@ -26,12 +26,13 @@ declare module "@tiptap/core" { /** * Insert a slash command and its associated prompt block * @param command The slash command description - * @param inputId The input ID (defaults to MAIN_EDITOR_INPUT_ID) */ - insertSlashCommand: ( - command: SlashCommandDescription, - inputId?: string, - ) => ReturnType; + insertSlashCommand: (command: SlashCommandDescription) => ReturnType; + + /** + * Clear the slash command content from the editor + */ + clearSlashCommand: () => ReturnType; }; } } @@ -148,8 +149,12 @@ export const SlashCommandExtension = Node.create({ addKeyboardShortcuts() { return { - Backspace: () => - this.editor.commands.command(({ tr, state }) => { + Backspace: () => { + // Get a reference to the editor + const editor = this.editor; + + // First try to find if we're at a slash command + const result = editor.commands.command(({ tr, state }) => { let isSlashCommand = false; const { selection } = state; const { empty, anchor } = selection; @@ -172,7 +177,21 @@ export const SlashCommandExtension = Node.create({ }); return isSlashCommand; - }), + }); + + // If we found and processed a slash command, also call clearSlashCommand + // to remove the prompt block + if (result) { + // We need to do this with a small delay to ensure the transaction + // above completes first + setTimeout(() => { + editor.commands.clearSlashCommand(); + }, 0); + return true; + } + + return false; + }, }; }, @@ -192,25 +211,31 @@ export const SlashCommandExtension = Node.create({ command: SlashCommandDescription, inputId: string = MAIN_EDITOR_INPUT_ID, ) => - ({ chain }) => { + ({ commands, chain }) => { + if (!command.prompt) { + return false; + } + + const contextItem: ContextItemWithId = { + content: command.prompt, + name: command.name, + description: command.description || "", + id: { + providerTitle: "prompt", + itemId: command.name, + }, + }; + // Create the document with both a prompt block and the slash command paragraph return chain() .setContent({ type: "doc", content: [ - // Add the prompt block at the beginning + // First insert the prompt using the PromptExtension command { - type: PROMPT_BLOCK_NAME, + type: PromptExtension.name, attrs: { - item: { - content: command.prompt, - name: command.name, - description: command.description || "", - id: { - providerTitle: "prompt", - itemId: command.name, - }, - } as ContextItemWithId, + item: contextItem, inputId, }, }, @@ -236,6 +261,33 @@ export const SlashCommandExtension = Node.create({ .focus() .run(); }, + + clearSlashCommand: + () => + ({ commands, state }) => { + // First clear all prompt blocks using the PromptExtension command + commands.clearPrompt(); + + // Then find and remove all slash command nodes + let found = false; + const slashNodes: { pos: number; node: ProseMirrorNode }[] = []; + + state.doc.descendants((node, pos) => { + if (node.type.name === this.name) { + slashNodes.push({ pos, node }); + found = true; + } + return true; + }); + + // Delete all found slash command nodes in reverse order + for (let i = slashNodes.length - 1; i >= 0; i--) { + const { pos, node } = slashNodes[i]; + commands.deleteRange({ from: pos, to: pos + node.nodeSize }); + } + + return found; + }, }; }, }); diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts index a790c5b0c..ef316d4f0 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/index.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts @@ -2,4 +2,4 @@ export * from "./AddCodeToEditExtension"; export * from "./CodeblockExtension"; export * from "./MentionExtension"; export * from "./PromptExtension"; -export * from "./SlashCommandExtension"; \ No newline at end of file +export * from "./SlashCommandExtension"; diff --git a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts b/gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts deleted file mode 100644 index 183e0daa0..000000000 --- a/gui/src/components/mainInput/TipTapEditor/toolbar-previews/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { CodeblockPreview } from "./CodeblockPreview"; -export { PromptBlockPreview as PromptPreview } from "./PromptBlockPreview"; diff --git a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts index c1cd5c23e..ad3eb515e 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts @@ -12,6 +12,7 @@ import { AppDispatch } from "../../../../redux/store"; import AtMentionDropdown from "../../AtMentionDropdown"; import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "../../types"; import { TIPPY_DIV_ID } from "../TipTapEditor"; +import { SlashCommandExtension } from "../extensions"; function getSuggestion( items: (props: { query: string }) => Promise, @@ -219,7 +220,7 @@ export function getSlashCommandDropdownOptions( id: provider.title, title: provider.title, label: provider.title, - type: (provider.type ?? "slashCommand") as ComboBoxItemType, + type: (provider.type ?? SlashCommandExtension.name) as ComboBoxItemType, content: provider.content, action: () => { dispatch( From 441fe96d7a6e1470038f2a72a4d8846cdf071660 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 3 Apr 2025 20:53:51 -0700 Subject: [PATCH 15/67] updates --- packages/hub/package.json | 2 +- packages/hub/src/ContinueHubClient.ts | 38 +++++++++++---------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/packages/hub/package.json b/packages/hub/package.json index 4996cccba..2b49abd4a 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/hub", - "version": "0.0.1", + "version": "0.0.3", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/hub/src/ContinueHubClient.ts b/packages/hub/src/ContinueHubClient.ts index 87ce14c9c..501a8bc54 100644 --- a/packages/hub/src/ContinueHubClient.ts +++ b/packages/hub/src/ContinueHubClient.ts @@ -4,35 +4,46 @@ import { FQSN, FullSlug, SecretResult, - SecretType, } from "@continuedev/config-yaml"; import { IContinueHubClient } from "./IContinueHubClient.js"; interface ContinueHubClientOptions { apiKey?: string; apiBase?: string; + fetchOptions?: RequestInit; } export class ContinueHubClient implements IContinueHubClient { private readonly apiKey?: string; private readonly apiBase: string; + private readonly fetchOptions?: RequestInit; constructor(options: ContinueHubClientOptions) { this.apiKey = options.apiKey; this.apiBase = options.apiBase ?? "https://api.continue.dev"; + this.fetchOptions = options.fetchOptions; } private async request(path: string, init: RequestInit): Promise { const url = new URL(path, this.apiBase).toString(); - if (this.apiKey) { - init.headers = { + const finalInit: RequestInit = { + ...this.fetchOptions, + ...init, + headers: { + ...this.fetchOptions?.headers, ...init.headers, + }, + }; + + if (this.apiKey) { + finalInit.headers = { + ...finalInit.headers, Authorization: `Bearer ${this.apiKey}`, }; } - const resp = await fetch(url, init); + const resp = await fetch(url, finalInit); if (!resp.ok) { throw new Error( @@ -47,17 +58,6 @@ export class ContinueHubClient implements IContinueHubClient { fqsns: FQSN[], orgScopeId: string | null, ): Promise<(SecretResult | undefined)[]> { - if (!this.apiKey) { - return fqsns.map((fqsn) => ({ - found: false, - fqsn, - secretLocation: { - secretName: fqsn.secretName, - secretType: SecretType.NotFound, - }, - })); - } - const resp = await this.request("ide/sync-secrets", { method: "POST", body: JSON.stringify({ fqsns, orgScopeId }), @@ -73,10 +73,6 @@ export class ContinueHubClient implements IContinueHubClient { rawYaml: string; }[] > { - if (!this.apiKey) { - return []; - } - try { const url = organizationId ? `ide/list-assistants?organizationId=${organizationId}` @@ -94,10 +90,6 @@ export class ContinueHubClient implements IContinueHubClient { async listAssistantFullSlugs( organizationId: string | null, ): Promise { - if (!this.apiKey) { - return null; - } - const url = organizationId ? `ide/list-assistant-full-slugs?organizationId=${organizationId}` : "ide/list-assistant-full-slugs"; From 9c0f43342e6ba576c5105d810eda8101ec238426 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 21:08:48 -0700 Subject: [PATCH 16/67] edit tool ui take zero --- core/tools/definitions/editFile.ts | 13 +++++++++++-- .../markdown/StyledMarkdownPreview.tsx | 3 ++- gui/src/pages/gui/ToolCallDiv/EditFile.tsx | 19 +++++++++++++++++++ .../FunctionSpecificToolCallDiv.tsx | 15 ++++++++++++--- 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 gui/src/pages/gui/ToolCallDiv/EditFile.tsx diff --git a/core/tools/definitions/editFile.ts b/core/tools/definitions/editFile.ts index 1ff44f7c7..6ee5cee6b 100644 --- a/core/tools/definitions/editFile.ts +++ b/core/tools/definitions/editFile.ts @@ -1,6 +1,11 @@ import { Tool } from "../.."; import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; +export interface EditToolArgs { + filepath: string; + new_contents: string; +} + export const editFileTool: Tool = { type: "function", displayTitle: "Edit File", @@ -12,16 +17,20 @@ export const editFileTool: Tool = { function: { name: BuiltInToolNames.EditExistingFile, description: - "To edit an existing file, call this tool and follow the returned instructions. If you don't have the contents of the file, read it first.", + "Use this tool to edit an existing file. If you don't know the contents of the file, read it first.", parameters: { type: "object", - required: ["filepath"], + required: ["filepath", "new_contents"], properties: { filepath: { type: "string", description: "The path of the file to edit, relative to the root of the workspace.", }, + new_contents: { + type: "string", + description: "The new file contents", + }, }, }, }, diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index fbd6801b9..4c2635ce1 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -130,6 +130,7 @@ interface StyledMarkdownPreviewProps { scrollLocked?: boolean; itemIndex?: number; useParentBackgroundColor?: boolean; + autoApplyCodeblocks?: boolean; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -330,7 +331,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( relativeFilepath={relativeFilePath} isGeneratingCodeBlock={isGeneratingCodeBlock} range={range} - autoApply={false} + autoApply={props.autoApplyCodeblocks} codeBlockStreamId={codeblockStreamId} > diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx new file mode 100644 index 000000000..0dee7ab2b --- /dev/null +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -0,0 +1,19 @@ +import { getMarkdownLanguageTagForFile } from "core/util"; +import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview"; + +type EditToolCallProps = { + relativeFilePath: string; + newContents: string; +}; + +export function EditFile(props: EditToolCallProps) { + const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.newContents ?? ""}\n\`\`\``; + + return props.relativeFilePath ? ( + + ) : null; +} diff --git a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx index 52b41f505..8592960eb 100644 --- a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx @@ -1,5 +1,7 @@ -import { ToolCall, ToolCallDelta, ToolCallState } from "core"; +import { ToolCallDelta, ToolCallState } from "core"; +import { BuiltInToolNames } from "core/tools/builtIn"; import { CreateFile } from "./CreateFile"; +import { EditFile } from "./EditFile"; import { RunTerminalCommand } from "./RunTerminalCommand"; function FunctionSpecificToolCallDiv({ @@ -12,14 +14,21 @@ function FunctionSpecificToolCallDiv({ const args = toolCallState.parsedArgs; switch (toolCall.function?.name) { - case "builtin_create_new_file": + case BuiltInToolNames.CreateNewFile: return ( ); - case "builtin_run_terminal_command": + case BuiltInToolNames.EditExistingFile: + return ( + + ); + case BuiltInToolNames.RunTerminalCommand: return ( Date: Thu, 3 Apr 2025 20:46:19 -0700 Subject: [PATCH 17/67] error if already exists" --- core/tools/implementations/createNewFile.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/core/tools/implementations/createNewFile.ts b/core/tools/implementations/createNewFile.ts index b5d5e6c1b..cf8746328 100644 --- a/core/tools/implementations/createNewFile.ts +++ b/core/tools/implementations/createNewFile.ts @@ -1,6 +1,7 @@ import { inferResolvedUriFromRelativePath } from "../../util/ideUtils"; import { ToolImpl } from "."; +import { getCleanUriPath, getUriPathBasename } from "../../util/uri"; export const createNewFileImpl: ToolImpl = async (args, extras) => { const resolvedFileUri = await inferResolvedUriFromRelativePath( @@ -8,8 +9,26 @@ export const createNewFileImpl: ToolImpl = async (args, extras) => { extras.ide, ); if (resolvedFileUri) { + const exists = await extras.ide.fileExists(resolvedFileUri); + if (exists) { + throw new Error( + `File ${args.filepath} already exists. Use the edit too to edit this file`, + ); + } await extras.ide.writeFile(resolvedFileUri, args.contents); await extras.ide.openFile(resolvedFileUri); + return [ + { + name: getUriPathBasename(resolvedFileUri), + description: getCleanUriPath(resolvedFileUri), + content: "File created successfuly", + uri: { + type: "file", + value: resolvedFileUri, + }, + }, + ]; + } else { + throw new Error("Failed to resolve path"); } - return []; }; From e595ce871f7cf21f19d946641c7415594fac7a27 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 21:17:04 -0700 Subject: [PATCH 18/67] edit tool call div --- extensions/vscode/package-lock.json | 4 ++-- gui/src/pages/gui/ToolCallDiv/EditFile.tsx | 1 + gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c01a1eb12..a26290f1a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.18", + "version": "1.1.19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.18", + "version": "1.1.19", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index 0dee7ab2b..56ee77ef3 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -14,6 +14,7 @@ export function EditFile(props: EditToolCallProps) { isRenderingInStepContainer={true} source={src} autoApplyCodeblocks={true} + hideApply={true} /> ) : null; } diff --git a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx index 8592960eb..ee8726fae 100644 --- a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx @@ -25,7 +25,7 @@ function FunctionSpecificToolCallDiv({ return ( ); case BuiltInToolNames.RunTerminalCommand: From 95016e5c3c67a7f79c602d6826197eaf3c303363 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 20:57:16 -0700 Subject: [PATCH 19/67] merge create tool updates --- .../StepContainerPreToolbar.tsx | 21 +++++++++---------- .../markdown/StyledMarkdownPreview.tsx | 2 ++ gui/src/pages/gui/ToolCallDiv/CreateFile.tsx | 8 +++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index ec0000b2c..1a67e2cb4 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -216,17 +216,16 @@ export default function StepContainerPreToolbar( {!isGeneratingCodeBlock && ( <> - {props.hideApply || - (isTerminalCodeBlock(props.language, props.codeBlockContent) ? ( - - ) : ( - - ))} + {isTerminalCodeBlock(props.language, props.codeBlockContent) ? ( + + ) : props.hideApply ? null : ( + + )} )}
diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 4c2635ce1..4aed38536 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -131,6 +131,7 @@ interface StyledMarkdownPreviewProps { itemIndex?: number; useParentBackgroundColor?: boolean; autoApplyCodeblocks?: boolean; + hideApply?: boolean; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -333,6 +334,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( range={range} autoApply={props.autoApplyCodeblocks} codeBlockStreamId={codeblockStreamId} + hideApply={props.hideApply} > diff --git a/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx b/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx index bca805f45..9829ef64b 100644 --- a/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx @@ -7,9 +7,13 @@ interface CreateFileToolCallProps { } export function CreateFile(props: CreateFileToolCallProps) { - const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilepath ?? "test.txt")} ${props.relativeFilepath}\n${props.fileContents ?? ""}\n\`\`\``; + const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilepath ?? "output.txt")} ${props.relativeFilepath}\n${props.fileContents ?? ""}\n\`\`\``; return props.relativeFilepath ? ( - + ) : null; } From 2780b588f749b6743bc8514d32d854c4b6aa6653 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 21:19:40 -0700 Subject: [PATCH 20/67] edit tool autoapply --- .../StepContainerPreToolbar.tsx | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 1a67e2cb4..26fdb6261 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -135,25 +135,17 @@ export default function StepContainerPreToolbar( } }, [props.children, codeBlockContent]); - // useEffect(() => { - // const hasCompletedGenerating = - // wasGeneratingRef.current && !isGeneratingCodeBlock; - // console.log( - // wasGeneratingRef.current, - // isGeneratingCodeBlock, - // props.autoApply, - // ); - // wasGeneratingRef.current = isGeneratingCodeBlock; - // if (hasCompletedGenerating) { - // console.log("Completed generating", props.autoApply); - // if (props.autoApply) { - // onClickApply(); - // } - // // else if(isInEditMode) { - // // onClickApply(); - // // } - // } - // }, [wasGeneratingRef, isGeneratingCodeBlock, props.autoApply]); + useEffect(() => { + const hasCompletedGenerating = + wasGeneratingRef.current && !isGeneratingCodeBlock; + + wasGeneratingRef.current = isGeneratingCodeBlock; + if (hasCompletedGenerating) { + if (props.autoApply) { + onClickApply(); + } + } + }, [wasGeneratingRef, isGeneratingCodeBlock, props.autoApply]); async function onClickAcceptApply() { const fileUri = await inferResolvedUriFromRelativePath( From af9b80f4731275d0e5c97c8d931beafa6fd0e431 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 21:43:59 -0700 Subject: [PATCH 21/67] toolbar styling --- gui/src/components/FileIcon.tsx | 2 +- .../StepContainerPreToolbar/FileInfo.tsx | 25 ++++++++++--------- .../StepContainerPreToolbar.tsx | 25 ++++++++----------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/gui/src/components/FileIcon.tsx b/gui/src/components/FileIcon.tsx index 6f96e498d..0f2b729cb 100644 --- a/gui/src/components/FileIcon.tsx +++ b/gui/src/components/FileIcon.tsx @@ -45,7 +45,7 @@ export default function FileIcon({ filename, height, width }: FileIconProps) { height: height, fill: color, flexShrink: 0, - display: "block", + display: "flex", }} /> ); diff --git a/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx b/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx index c2f09a24a..06defbeac 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx @@ -1,8 +1,8 @@ -import FileIcon from "../../FileIcon"; +import { inferResolvedUriFromRelativePath } from "core/util/ideUtils"; +import { getLastNPathParts } from "core/util/uri"; import { useContext } from "react"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { getLastNPathParts, getUriPathBasename } from "core/util/uri"; -import { inferResolvedUriFromRelativePath } from "core/util/ideUtils"; +import FileIcon from "../../FileIcon"; export interface FileInfoProps { relativeFilepath: string; @@ -23,17 +23,18 @@ const FileInfo = ({ relativeFilepath, range }: FileInfoProps) => { } return ( -
-
+
+
- - {getLastNPathParts(relativeFilepath, 1)} - {range && ` ${range}`} -
+ + asdfasdfasdfasdfasdfasdfasdf + {getLastNPathParts(relativeFilepath, 1)} + {range && ` ${range}`} +
); }; diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 26fdb6261..776192e45 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -25,6 +25,8 @@ import GeneratingCodeLoader from "./GeneratingCodeLoader"; import RunInTerminalButton from "./RunInTerminalButton"; const TopDiv = styled.div` + display: flex; + flex-direction: column; outline: 1px solid ${vscCommandCenterInactiveBorder}; outline-offset: -0.5px; border-radius: ${defaultBorderRadius}; @@ -37,7 +39,6 @@ const ToolbarDiv = styled.div<{ isExpanded: boolean }>` display: flex; justify-content: space-between; align-items: center; - background: inherit; font-size: ${getFontSize() - 2}px; padding: 4px 6px; margin: 0; @@ -181,31 +182,27 @@ export default function StepContainerPreToolbar( return ( - -
+ +
-
- -
+
- {isGeneratingCodeBlock && ( + {isGeneratingCodeBlock ? ( - )} - - {!isGeneratingCodeBlock && ( + ) : ( <> {isTerminalCodeBlock(props.language, props.codeBlockContent) ? ( From ac27ec97d7044d2aedeeea85247c13dd0f8fd0ab Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 21:44:15 -0700 Subject: [PATCH 22/67] cleanup --- gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx b/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx index 06defbeac..ee46ccee8 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx @@ -31,7 +31,6 @@ const FileInfo = ({ relativeFilepath, range }: FileInfoProps) => {
- asdfasdfasdfasdfasdfasdfasdf {getLastNPathParts(relativeFilepath, 1)} {range && ` ${range}`} From 2c8cee9fd42fc8f18c9e6e37781e27276dae2786 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 3 Apr 2025 22:32:28 -0700 Subject: [PATCH 23/67] feat: handle deletions --- gui/src/components/FileIcon.tsx | 1 - .../mainInput/TipTapEditor/TipTapEditor.tsx | 6 +- .../components/ExpandablePreview.tsx | 5 +- .../components/NodeViewWrapper.tsx | 23 ++++++ ...odeToEditExtension.ts => AddCodeToEdit.ts} | 6 +- .../CodeBlock.tsx} | 6 +- .../CodeBlockPreview.tsx} | 24 +++--- .../extensions/CodeBlock/index.ts | 1 + .../extensions/CodeblockExtension/index.ts | 1 - .../{MentionExtension.ts => Mention.ts} | 7 +- .../PromptBlock.ts} | 59 ++++++++------- .../PromptBlockPreview.tsx | 34 ++------- .../TipTapEditor/extensions/Prompt/index.ts | 1 + .../extensions/PromptExtension/index.ts | 1 - ...ashCommandExtension.ts => SlashCommand.ts} | 74 +++++++++---------- .../TipTapEditor/extensions/index.ts | 10 +-- .../mainInput/TipTapEditor/index.ts | 1 + .../useMainEditorWebviewListeners.ts | 8 +- .../TipTapEditor/utils/editorConfig.ts | 32 ++------ .../TipTapEditor/utils/getSuggestion.ts | 4 +- .../utils/resolveEditorContent.ts | 12 +-- .../mainInput/util/handleMetaKeyIssues.ts | 4 +- gui/src/redux/thunks/updateFileSymbols.ts | 4 +- 23 files changed, 154 insertions(+), 170 deletions(-) create mode 100644 gui/src/components/mainInput/TipTapEditor/components/NodeViewWrapper.tsx rename gui/src/components/mainInput/TipTapEditor/extensions/{AddCodeToEditExtension.ts => AddCodeToEdit.ts} (97%) rename gui/src/components/mainInput/TipTapEditor/extensions/{CodeblockExtension/CodeblockExtension.tsx => CodeBlock/CodeBlock.tsx} (78%) rename gui/src/components/mainInput/TipTapEditor/extensions/{CodeblockExtension/CodeblockPreview.tsx => CodeBlock/CodeBlockPreview.tsx} (86%) create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/index.ts delete mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts rename gui/src/components/mainInput/TipTapEditor/extensions/{MentionExtension.ts => Mention.ts} (97%) rename gui/src/components/mainInput/TipTapEditor/extensions/{PromptExtension/PromptExtension.ts => Prompt/PromptBlock.ts} (56%) rename gui/src/components/mainInput/TipTapEditor/extensions/{PromptExtension => Prompt}/PromptBlockPreview.tsx (65%) create mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/Prompt/index.ts delete mode 100644 gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts rename gui/src/components/mainInput/TipTapEditor/extensions/{SlashCommandExtension.ts => SlashCommand.ts} (79%) diff --git a/gui/src/components/FileIcon.tsx b/gui/src/components/FileIcon.tsx index ab0d338dd..5d364bf03 100644 --- a/gui/src/components/FileIcon.tsx +++ b/gui/src/components/FileIcon.tsx @@ -34,7 +34,6 @@ export default function FileIcon({ filename, height, width }: FileIconProps) { ignore: "#586e75", }); - console.log({ file }); // Sanitize the SVG string before rendering it const { svg, color } = getIcon(file); const sanitizedSVG = DOMPurify.sanitize(svg); diff --git a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx index 24a9d4aa6..2c340c843 100644 --- a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx @@ -10,9 +10,8 @@ import { selectDefaultModel } from "../../../redux/slices/configSlice"; import { selectIsInEditMode } from "../../../redux/slices/sessionSlice"; import InputToolbar, { ToolbarOptions } from "../InputToolbar"; import { ComboBoxItem } from "../types"; -import { DragOverlay } from "./DragOverlay"; +import { DragOverlay, InputBoxDiv } from "./components"; import { useMainEditor } from "./MainEditorProvider"; -import { InputBoxDiv } from "./StyledComponents"; import "./TipTapEditor.css"; import { handleImageFile } from "./utils"; import { createEditorConfig, getPlaceholderText } from "./utils/editorConfig"; @@ -31,6 +30,9 @@ export interface TipTapEditorProps { toolbarOptions?: ToolbarOptions; placeholder?: string; historyKey: string; + + // TODO: This isn't actually used anywhere in this component, but it appears + // to be pulled into some of our TipTap extensions. inputId: string; } diff --git a/gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx b/gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx index 973700335..a6b886b05 100644 --- a/gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx @@ -87,6 +87,10 @@ export function ExpandablePreview(props: ExpandablePreviewProps) { const contentRef = useRef(null); const [contentDims, setContentDims] = useState({ width: 0, height: 0 }); + useEffect(() => { + setHidden(props.initiallyHidden ?? false); + }, [props.initiallyHidden]); + useEffect(() => { const resizeObserver = new ResizeObserver(() => { setContentDims({ @@ -154,7 +158,6 @@ export function ExpandablePreview(props: ExpandablePreviewProps) {
- {/* Updated content section */} {!hidden && ( = ({ + children, +}) => { + // Not setting this as a "p" will cause issues with foreign keyboards + // See https://github.com/continuedev/continue/issues/3199 + const nodeViewWrapperTag: TiptapNodeViewWrapperProps["as"] = "p"; + + return ( + + {children} + + ); +}; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEditExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEdit.ts similarity index 97% rename from gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEditExtension.ts rename to gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEdit.ts index 519074bb1..87b524435 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEditExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/AddCodeToEdit.ts @@ -3,12 +3,14 @@ import { PluginKey } from "@tiptap/pm/state"; import Suggestion from "@tiptap/suggestion"; import { MentionOptions } from "./types"; -export const AddCodeToEditExtension = Node.create({ +export const AddCodeToEdit = Node.create({ name: "add-code-to-edit", addOptions() { return { - HTMLAttributes: {}, + HTMLAttributes: { + class: "add-code-to-edit", + }, renderHTML({ options, node }) { return [ "span", diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockExtension.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/CodeBlock.tsx similarity index 78% rename from gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockExtension.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/CodeBlock.tsx index a43c1e9d2..e96c567c4 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockExtension.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/CodeBlock.tsx @@ -1,8 +1,8 @@ import { mergeAttributes, Node } from "@tiptap/core"; import { ReactNodeViewRenderer } from "@tiptap/react"; -import { CodeblockPreview } from "./CodeblockPreview"; +import { CodeBlockPreview } from "./CodeBlockPreview"; -export const CodeblockExtension = Node.create({ +export const CodeBlock = Node.create({ name: "codeblock", group: "block", @@ -37,6 +37,6 @@ export const CodeblockExtension = Node.create({ }, addNodeView() { - return ReactNodeViewRenderer(CodeblockPreview); + return ReactNodeViewRenderer(CodeBlockPreview); }, }); diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/CodeBlockPreview.tsx similarity index 86% rename from gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockPreview.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/CodeBlockPreview.tsx index 66812b1df..cf7eb7885 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/CodeblockPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/CodeBlockPreview.tsx @@ -1,8 +1,4 @@ -import { - NodeViewProps, - NodeViewWrapper, - NodeViewWrapperProps, -} from "@tiptap/react"; +import { NodeViewProps } from "@tiptap/react"; import { ContextItemWithId } from "core"; import { ctxItemToRifWithContents } from "core/commands/util"; import { dedent, getMarkdownLanguageTagForFile } from "core/util"; @@ -13,13 +9,14 @@ import { useAppSelector } from "../../../../../redux/hooks"; import FileIcon from "../../../../FileIcon"; import StyledMarkdownPreview from "../../../../markdown/StyledMarkdownPreview"; import { ExpandablePreview } from "../../components/ExpandablePreview"; +import { NodeViewWrapper } from "../../components/NodeViewWrapper"; const backticksRegex = /`{3,}/gm; /** * Component for displaying a code block in the TipTap editor */ -export const CodeblockPreview = ({ +export const CodeBlockPreview = ({ node, deleteNode, selected, @@ -29,10 +26,6 @@ export const CodeblockPreview = ({ const isFirstContextItem = false; // TODO: fix this, decided not worth the insane renders for now const ideMessenger = useContext(IdeMessengerContext); - // Not setting this as a "p" will cause issues with foreign keyboards - // See https://github.com/continuedev/continue/issues/3199 - const nodeViewWrapperTag: NodeViewWrapperProps["as"] = "p"; - const newestCodeblockForInputId = useAppSelector( (store) => store.session.newestCodeblockForInput[inputId], ); @@ -41,6 +34,12 @@ export const CodeblockPreview = ({ return newestCodeblockForInputId !== item.id.itemId; }, [newestCodeblockForInputId, item.id.itemId]); + console.log({ + newestCodeblockForInputId, + id: item.id.itemId, + initiallyHidden, + }); + const content = useMemo(() => { return dedent`${item.content}`; }, [item.content]); @@ -79,10 +78,7 @@ export const CodeblockPreview = ({ : undefined; return ( - + } diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/index.ts new file mode 100644 index 000000000..ca111193d --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/CodeBlock/index.ts @@ -0,0 +1 @@ +export * from "./CodeBlock"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts deleted file mode 100644 index f0a5fadde..000000000 --- a/gui/src/components/mainInput/TipTapEditor/extensions/CodeblockExtension/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./CodeblockExtension"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/Mention.ts similarity index 97% rename from gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts rename to gui/src/components/mainInput/TipTapEditor/extensions/Mention.ts index 3719cbc14..bfd48b0f6 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/MentionExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Mention.ts @@ -3,12 +3,15 @@ import { PluginKey } from "@tiptap/pm/state"; import Suggestion from "@tiptap/suggestion"; import { MentionOptions } from "./types"; -export const MentionExtension = Node.create({ +export const Mention = Node.create({ name: "mention", addOptions() { return { - HTMLAttributes: {}, + HTMLAttributes: { + class: "mention", + }, + renderHTML({ options, node }) { return [ "span", diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts similarity index 56% rename from gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptExtension.ts rename to gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts index 0921fe614..287a79e4a 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts @@ -1,14 +1,14 @@ import { mergeAttributes, Node } from "@tiptap/core"; +import { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { ReactNodeViewRenderer } from "@tiptap/react"; import { ContextItemWithId } from "core"; -import { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { PromptBlockPreview } from "./PromptBlockPreview"; -export interface PromptOptions { +export interface PromptBlockOptions { HTMLAttributes: Record; } -export interface PromptAttributes { +export interface PromptBlockAttributes { item: ContextItemWithId; inputId: string; } @@ -32,13 +32,15 @@ declare module "@tiptap/core" { /** * Extension for adding prompt blocks to the Tiptap editor */ -export const PromptExtension = Node.create({ +export const PromptBlock = Node.create({ name: "prompt-block", group: "block", addOptions() { return { - HTMLAttributes: {}, + HTMLAttributes: { + class: "prompt-block", + }, }; }, @@ -71,7 +73,8 @@ export const PromptExtension = Node.create({ addCommands() { return { - insertPrompt: (item: ContextItemWithId, inputId: string) => + insertPrompt: + (item: ContextItemWithId, inputId: string) => ({ commands }) => { return commands.insertContent({ type: this.name, @@ -82,27 +85,29 @@ export const PromptExtension = Node.create({ }); }, - clearPrompt: () => ({ state, commands }) => { - // Find all prompt-block nodes in the document - const promptNodes: { pos: number, node: ProseMirrorNode }[] = []; - state.doc.descendants((node, pos) => { - if (node.type.name === this.name) { - promptNodes.push({ pos, node }); - return false; // Don't descend into this node + clearPrompt: + () => + ({ state, commands }) => { + // Find all prompt-block nodes in the document + const promptNodes: { pos: number; node: ProseMirrorNode }[] = []; + state.doc.descendants((node, pos) => { + if (node.type.name === this.name) { + promptNodes.push({ pos, node }); + return false; // Don't descend into this node + } + return true; + }); + + // Delete all found prompt blocks + // We process them in reverse order so that deleting one doesn't affect the position of others + for (let i = promptNodes.length - 1; i >= 0; i--) { + const { pos, node } = promptNodes[i]; + commands.deleteRange({ from: pos, to: pos + node.nodeSize }); } - return true; - }); - - // Delete all found prompt blocks - // We process them in reverse order so that deleting one doesn't affect the position of others - for (let i = promptNodes.length - 1; i >= 0; i--) { - const { pos, node } = promptNodes[i]; - commands.deleteRange({ from: pos, to: pos + node.nodeSize }); - } - - // Return true if we deleted any nodes - return promptNodes.length > 0; - }, + + // Return true if we deleted any nodes + return promptNodes.length > 0; + }, }; }, -}); \ No newline at end of file +}); diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptBlockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx similarity index 65% rename from gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptBlockPreview.tsx rename to gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx index 891c8edb6..002740692 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/PromptBlockPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx @@ -1,32 +1,25 @@ import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline"; -import { - NodeViewProps, - NodeViewWrapper, - NodeViewWrapperProps, -} from "@tiptap/react"; +import { NodeViewProps } from "@tiptap/react"; import { useContext, useMemo } from "react"; import { vscBadgeBackground } from "../../../.."; import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; import { useAppSelector } from "../../../../../redux/hooks"; import { ExpandablePreview } from "../../components/ExpandablePreview"; -import { PromptAttributes } from "./PromptExtension"; +import { NodeViewWrapper } from "../../components/NodeViewWrapper"; +import { PromptBlockAttributes } from "./PromptBlock"; /** * Component for prompt blocks in the Tiptap editor */ export const PromptBlockPreview = ({ node, - deleteNode, selected, editor, }: NodeViewProps) => { - const { item, inputId } = node.attrs as PromptAttributes; + const { item, inputId } = node.attrs as PromptBlockAttributes; const ideMessenger = useContext(IdeMessengerContext); - // Not setting this as a "p" will cause issues with foreign keyboards - const nodeViewWrapperTag: NodeViewWrapperProps["as"] = "p"; - const newestCodeblockForInputId = useAppSelector( (store) => store.session.newestCodeblockForInput[inputId], ); @@ -44,26 +37,13 @@ export const PromptBlockPreview = ({ }; const handleDelete = () => { - // Use the clearSlashCommand command to properly clean up everything - if (editor) { - // Make sure this runs after the current event loop cycle - // to avoid React state update conflicts - setTimeout(() => { - editor.commands.clearSlashCommand(); - }, 0); - } else { - // Fallback to deleteNode if editor is not available - deleteNode(); - } + editor.commands.clearSlashCommand(); }; const borderColor = selected ? vscBadgeBackground : undefined; return ( - + } @@ -78,4 +58,4 @@ export const PromptBlockPreview = ({ ); -}; \ No newline at end of file +}; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/index.ts new file mode 100644 index 000000000..3a72d7bd3 --- /dev/null +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/index.ts @@ -0,0 +1 @@ +export * from "./PromptBlock"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts deleted file mode 100644 index c9c12a825..000000000 --- a/gui/src/components/mainInput/TipTapEditor/extensions/PromptExtension/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./PromptExtension"; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommand.ts similarity index 79% rename from gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts rename to gui/src/components/mainInput/TipTapEditor/extensions/SlashCommand.ts index e8a9b3006..4b5517c87 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommandExtension.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommand.ts @@ -1,13 +1,15 @@ // Adapted from SlashCommand extension (@tiptap/extension-mention/src/mention.ts) import { mergeAttributes, Node } from "@tiptap/core"; +import Document from "@tiptap/extension-document"; +import Paragraph from "@tiptap/extension-paragraph"; import { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { PluginKey } from "@tiptap/pm/state"; import Suggestion, { SuggestionOptions } from "@tiptap/suggestion"; import { ContextItemWithId, SlashCommandDescription } from "core"; import { MAIN_EDITOR_INPUT_ID } from "../../../../pages/gui/Chat"; import { ComboBoxItem } from "../../types"; -import { PromptExtension } from "./PromptExtension/PromptExtension"; +import { PromptBlock } from "./Prompt/PromptBlock"; export type SlashCommandOptions = { HTMLAttributes: Record; @@ -15,11 +17,6 @@ export type SlashCommandOptions = { suggestion: Omit, "editor">; }; -export const SLASH_CMD_NAME = "slash-command"; -export const SLASH_CMD_SUGGESTION_CHAR = "/"; - -export const SlashCommandPluginKey = new PluginKey(SLASH_CMD_NAME); - declare module "@tiptap/core" { interface Commands { slashCommand: { @@ -37,18 +34,20 @@ declare module "@tiptap/core" { } } -export const SlashCommandExtension = Node.create({ - name: SLASH_CMD_NAME, +export const SlashCommand = Node.create({ + name: "slash-command", addOptions() { return { - HTMLAttributes: {}, + HTMLAttributes: { + class: "mention", + }, renderText({ node }) { return node.attrs.label ?? node.attrs.id; }, suggestion: { - char: SLASH_CMD_SUGGESTION_CHAR, - pluginKey: SlashCommandPluginKey, + char: "/", + pluginKey: new PluginKey(this.name), startOfLine: true, command: ({ editor, range, props }) => { // increase range.to by one when the next node is of type "text" @@ -141,12 +140,6 @@ export const SlashCommandExtension = Node.create({ ]; }, - renderText({ node }) { - return this.options.renderText({ - node, - }); - }, - addKeyboardShortcuts() { return { Backspace: () => { @@ -211,7 +204,7 @@ export const SlashCommandExtension = Node.create({ command: SlashCommandDescription, inputId: string = MAIN_EDITOR_INPUT_ID, ) => - ({ commands, chain }) => { + ({ chain }) => { if (!command.prompt) { return false; } @@ -226,14 +219,17 @@ export const SlashCommandExtension = Node.create({ }, }; - // Create the document with both a prompt block and the slash command paragraph + // Right now this inserts at the beginning of the document, which removes codeblocks. + // This is the current behavior of slash commands, eg codeblocks aren't sent. + // Once this bug if fixed, we should instead insert prompt block at the beginning of the document + // without clearing the codeblocks. return chain() .setContent({ - type: "doc", + type: Document.name, content: [ // First insert the prompt using the PromptExtension command { - type: PromptExtension.name, + type: PromptBlock.name, attrs: { item: contextItem, inputId, @@ -241,7 +237,7 @@ export const SlashCommandExtension = Node.create({ }, // Add the paragraph with the slash command { - type: "paragraph", + type: Paragraph.name, content: [ { type: this.name, @@ -264,29 +260,25 @@ export const SlashCommandExtension = Node.create({ clearSlashCommand: () => - ({ commands, state }) => { - // First clear all prompt blocks using the PromptExtension command - commands.clearPrompt(); + ({ editor }) => { + editor.commands.clearPrompt(); - // Then find and remove all slash command nodes - let found = false; - const slashNodes: { pos: number; node: ProseMirrorNode }[] = []; + editor.commands.command(({ tr, state }) => { + let hasDeleted = false; - state.doc.descendants((node, pos) => { - if (node.type.name === this.name) { - slashNodes.push({ pos, node }); - found = true; - } - return true; + // Find all slash command nodes in the document + state.doc.descendants((node, pos) => { + if (node.type.name === this.name) { + // Delete the node at the found position + tr.delete(pos, pos + node.nodeSize); + hasDeleted = true; + } + }); + + return hasDeleted; }); - // Delete all found slash command nodes in reverse order - for (let i = slashNodes.length - 1; i >= 0; i--) { - const { pos, node } = slashNodes[i]; - commands.deleteRange({ from: pos, to: pos + node.nodeSize }); - } - - return found; + return true; }, }; }, diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/index.ts b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts index ef316d4f0..06426b9c3 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/index.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/index.ts @@ -1,5 +1,5 @@ -export * from "./AddCodeToEditExtension"; -export * from "./CodeblockExtension"; -export * from "./MentionExtension"; -export * from "./PromptExtension"; -export * from "./SlashCommandExtension"; +export * from "./AddCodeToEdit"; +export * from "./CodeBlock"; +export * from "./Mention"; +export * from "./Prompt"; +export * from "./SlashCommand"; diff --git a/gui/src/components/mainInput/TipTapEditor/index.ts b/gui/src/components/mainInput/TipTapEditor/index.ts index 51f6eba38..b2d446398 100644 --- a/gui/src/components/mainInput/TipTapEditor/index.ts +++ b/gui/src/components/mainInput/TipTapEditor/index.ts @@ -1,3 +1,4 @@ +export * from "./extensions"; export * from "./MainEditorProvider"; export * from "./TipTapEditor"; export * from "./utils"; diff --git a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts index 90bfcd8cc..bedb3df50 100644 --- a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts +++ b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts @@ -9,7 +9,7 @@ import { } from "../../../redux/slices/sessionSlice"; import { AppDispatch } from "../../../redux/store"; import { loadSession, saveCurrentSession } from "../../../redux/thunks/session"; -import { CodeblockExtension } from "./extensions"; +import { CodeBlock } from "./extensions"; /** * Hook for setting up main editor specific webview listeners @@ -114,7 +114,7 @@ export function useMainEditorWebviewListeners({ if (el.attrs?.item?.name === contextItem.name) { return; // Prevent exact duplicate code blocks } - if (el.type === CodeblockExtension.name) { + if (el.type === CodeBlock.name) { index += 2; } else { break; @@ -124,7 +124,7 @@ export function useMainEditorWebviewListeners({ editor .chain() .insertContentAt(index, { - type: CodeblockExtension.name, + type: CodeBlock.name, attrs: { item: contextItem, inputId, @@ -132,6 +132,8 @@ export function useMainEditorWebviewListeners({ }) .run(); + console.log("id: ", contextItem.id.itemId); + dispatch( setNewestCodeblocksForInput({ inputId, diff --git a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts index d2c77529d..8addede87 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts @@ -286,10 +286,7 @@ export function createEditorConfig(options: { }, }), Text, - ContinueExtensions.MentionExtension.configure({ - HTMLAttributes: { - class: "mention", - }, + ContinueExtensions.Mention.configure({ suggestion: getContextProviderDropdownOptions( availableContextProvidersRef, getSubmenuContextItemsRef, @@ -299,15 +296,8 @@ export function createEditorConfig(options: { inSubmenuRef, ideMessenger, ), - renderHTML: (props) => { - return `@${props.node.attrs.label || props.node.attrs.id}`; - }, }), - - ContinueExtensions.AddCodeToEditExtension.configure({ - HTMLAttributes: { - class: "add-code-to-edit", - }, + ContinueExtensions.AddCodeToEdit.configure({ suggestion: { ...getContextProviderDropdownOptions( availableContextProvidersRef, @@ -343,10 +333,7 @@ export function createEditorConfig(options: { }, }, }), - ContinueExtensions.SlashCommandExtension.configure({ - HTMLAttributes: { - class: "mention", - }, + ContinueExtensions.SlashCommand.configure({ suggestion: getSlashCommandDropdownOptions( availableSlashCommandsRef, onClose, @@ -355,20 +342,13 @@ export function createEditorConfig(options: { dispatch, props.inputId, ), - renderText: (props) => { - return props.node.attrs.label; - }, }), - ContinueExtensions.PromptExtension.configure({ - HTMLAttributes: { - class: "prompt-block", - }, - }), - ContinueExtensions.CodeblockExtension, + ContinueExtensions.PromptBlock, + ContinueExtensions.CodeBlock, ], editorProps: { attributes: { - class: "outline-none -mt-1 overflow-hidden", + class: "outline-none overflow-hidden", style: `font-size: ${getFontSize()}px;`, }, }, diff --git a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts index ad3eb515e..b553b6d9a 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts @@ -12,7 +12,7 @@ import { AppDispatch } from "../../../../redux/store"; import AtMentionDropdown from "../../AtMentionDropdown"; import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "../../types"; import { TIPPY_DIV_ID } from "../TipTapEditor"; -import { SlashCommandExtension } from "../extensions"; +import { SlashCommand } from "../extensions"; function getSuggestion( items: (props: { query: string }) => Promise, @@ -220,7 +220,7 @@ export function getSlashCommandDropdownOptions( id: provider.title, title: provider.title, label: provider.title, - type: (provider.type ?? SlashCommandExtension.name) as ComboBoxItemType, + type: (provider.type ?? SlashCommand.name) as ComboBoxItemType, content: provider.content, action: () => { dispatch( diff --git a/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts index 5476f100c..34962eed4 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts @@ -18,11 +18,7 @@ import { renderChatMessage, stripImages } from "core/util/messageContent"; import { getUriFileExtension } from "core/util/uri"; import { IIdeMessenger } from "../../../../context/IdeMessenger"; import { setIsGatheringContext } from "../../../../redux/slices/sessionSlice"; -import { - CodeblockExtension, - MentionExtension, - SlashCommandExtension, -} from "../extensions"; +import { CodeBlock, Mention, SlashCommand } from "../extensions"; interface MentionAttrs { label: string; @@ -86,7 +82,7 @@ function processEditorContent(editorState: JSONContent) { return [...parts, { type: "text", text }]; } - case CodeblockExtension.name: { + case CodeBlock.name: { if (!p.attrs?.item) { console.warn("codeBlock has no item attribute"); return parts; @@ -280,10 +276,10 @@ function resolveParagraph( switch (child.type) { case Text.name: return child.text; - case MentionExtension.name: + case Mention.name: contextItems.push(child.attrs as MentionAttrs); return child.attrs?.renderInlineAs ?? child.attrs?.label; - case SlashCommandExtension.name: + case SlashCommand.name: if (!slashCommand) { slashCommand = child.attrs?.id; return ""; diff --git a/gui/src/components/mainInput/util/handleMetaKeyIssues.ts b/gui/src/components/mainInput/util/handleMetaKeyIssues.ts index b147a5609..bc45d19f1 100644 --- a/gui/src/components/mainInput/util/handleMetaKeyIssues.ts +++ b/gui/src/components/mainInput/util/handleMetaKeyIssues.ts @@ -1,7 +1,7 @@ import { Editor } from "@tiptap/react"; import { KeyboardEvent } from "react"; import { getPlatform, isWebEnvironment } from "../../../util"; -import { CodeblockExtension } from "../TipTapEditor/extensions"; +import { CodeBlock } from "../TipTapEditor"; const isWebEnv = isWebEnvironment(); @@ -104,7 +104,7 @@ export const handleJetBrainsMetaBackspace = (editor: Editor) => { for (let i = doc.content.childCount - 1; i >= 0; i--) { const node = doc.content.child(i); - if (node.type.name === CodeblockExtension.name) { + if (node.type.name === CodeBlock.name) { continue; } diff --git a/gui/src/redux/thunks/updateFileSymbols.ts b/gui/src/redux/thunks/updateFileSymbols.ts index c237e4216..49e259421 100644 --- a/gui/src/redux/thunks/updateFileSymbols.ts +++ b/gui/src/redux/thunks/updateFileSymbols.ts @@ -1,6 +1,6 @@ import { createAsyncThunk } from "@reduxjs/toolkit"; import { ChatHistoryItem, ContextItemWithId } from "core"; -import { CodeblockExtension } from "../../components/mainInput/TipTapEditor/extensions"; +import { CodeBlock } from "../../components/mainInput/TipTapEditor/extensions"; import { updateFileSymbols } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; @@ -26,7 +26,7 @@ export function getContextItemsFromHistory( .flatMap((item) => item.editorState.content) .filter( (content) => - content?.type === CodeblockExtension.name && + content?.type === CodeBlock.name && content?.attrs?.item?.uri?.value && content.attrs.item.uri?.type === "file", ) From 1a63ea756df3827c27f6d114d03044460d004baf Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 3 Apr 2025 23:41:05 -0700 Subject: [PATCH 24/67] hacky apply implementation --- core/core.ts | 18 ++- core/index.d.ts | 1 + core/protocol/core.ts | 2 +- core/protocol/ide.ts | 11 ++ core/protocol/ideWebview.ts | 12 -- core/tools/implementations/editFile.ts | 16 ++- core/util/filesystem.ts | 4 + .../continue/IntelliJIde.kt | 117 +++++++++++++++++- .../continueintellijextension/protocol/ide.kt | 1 - extensions/vscode/src/VsCodeIde.ts | 13 +- .../vscode/src/extension/VsCodeMessenger.ts | 4 +- .../StepContainerPreToolbar.tsx | 21 ++-- .../markdown/StyledMarkdownPreview.tsx | 21 +++- gui/src/pages/gui/ToolCallDiv/EditFile.tsx | 13 +- gui/src/redux/slices/sessionSlice.ts | 8 ++ gui/src/redux/thunks/callTool.ts | 6 + 16 files changed, 215 insertions(+), 53 deletions(-) diff --git a/core/core.ts b/core/core.ts index 11fecffb2..911ea0072 100644 --- a/core/core.ts +++ b/core/core.ts @@ -36,6 +36,7 @@ import { TTS } from "./util/tts"; import { DiffLine, + ToolExtras, type ContextItemId, type IDE, type IndexingProgressUpdate, @@ -871,7 +872,8 @@ export class Core { } }); - on("tools/call", async ({ data: { toolCall, selectedModelTitle } }) => { + on("tools/call", async (msg) => { + const { toolCall, selectedModelTitle, applyStreamId } = msg.data; const { config } = await this.configHandler.loadConfig(); if (!config) { throw new Error("Config not loaded"); @@ -887,6 +889,19 @@ export class Core { const llm = await this.configHandler.llmFromTitle(selectedModelTitle); + let applyToFile: ToolExtras["applyToFile"] = undefined; + if (applyStreamId) { + applyToFile = async (path: string, contents: string) => { + return await this.messenger.request("applyToFile", { + filepath: path, + text: contents, + streamId: applyStreamId, + curSelectedModelTitle: + config.selectedModelByRole.apply?.title ?? selectedModelTitle, + }); + }; + } + const contextItems = await callTool( tool, JSON.parse(toolCall.function.arguments || "{}"), @@ -896,6 +911,7 @@ export class Core { fetch: (url, init) => fetchwithRequestOptions(url, init, config.requestOptions), tool, + applyToFile, }, ); diff --git a/core/index.d.ts b/core/index.d.ts index ba97377d3..5b2b482ed 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -891,6 +891,7 @@ export interface ToolExtras { llm: ILLM; fetch: FetchFunction; tool: Tool; + applyToFile?: (path: string, content: string) => Promise; } export interface Tool { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 03940c283..f92f70a50 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -193,7 +193,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }]; "tools/call": [ - { toolCall: ToolCall; selectedModelTitle: string }, + { toolCall: ToolCall; selectedModelTitle: string; applyStreamId?: string }, { contextItems: ContextItem[] }, ]; "clipboardCache/add": [{ content: string }, void]; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 5b2a7ab1f..9b3d030f6 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -23,6 +23,17 @@ export interface GetGhTokenArgs { export type ToIdeFromWebviewOrCoreProtocol = { // Methods from IDE type + // We pass the `curSelectedModel` because we currently cannot access the + // default model title in the GUI from JB + applyToFile: [ + { + text: string; + streamId: string; + curSelectedModelTitle: string; + filepath?: string; + }, + void, + ]; getIdeInfo: [undefined, IdeInfo]; getWorkspaceDirs: [undefined, string[]]; writeFile: [{ path: string; contents: string }, void]; diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index a7cd16e5b..03074b95f 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -4,7 +4,6 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview"; import type { ApplyState, CodeToEdit, - ContextSubmenuItem, EditStatus, MessageContent, RangeInFileWithContents, @@ -12,17 +11,6 @@ import type { export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { openUrl: [string, void]; - // We pass the `curSelectedModel` because we currently cannot access the - // default model title in the GUI from JB - applyToFile: [ - { - text: string; - streamId: string; - curSelectedModelTitle: string; - filepath?: string; - }, - void, - ]; overwriteFile: [{ filepath: string; prevFileContent: string | null }, void]; showTutorial: [undefined, void]; showFile: [{ filepath: string }, void]; diff --git a/core/tools/implementations/editFile.ts b/core/tools/implementations/editFile.ts index 80de79923..deac3cc54 100644 --- a/core/tools/implementations/editFile.ts +++ b/core/tools/implementations/editFile.ts @@ -1,8 +1,6 @@ import { ToolImpl } from "."; import { resolveRelativePathInDir } from "../../util/ideUtils"; -export const EDIT_TOOL_CONTEXT_ITEM_NAME = "Edit Tool Instructions"; - export const editFileImpl: ToolImpl = async (args, extras) => { const firstUriMatch = await resolveRelativePathInDir( args.filepath, @@ -11,12 +9,18 @@ export const editFileImpl: ToolImpl = async (args, extras) => { if (!firstUriMatch) { throw new Error(`File ${args.filepath} does not exist.`); } + if (!extras.applyToFile) { + throw new Error("Failed to apply to file: invalid apply stream id"); + } + if (!extras.llm.title) { + throw new Error("Failed to apply to file: no model selected"); + } + await extras.applyToFile(firstUriMatch, args.new_contents); return [ { - name: EDIT_TOOL_CONTEXT_ITEM_NAME, - description: "Instructions for editing the file", - content: - "Edit Instructions: return the full new file contents in a codeblock. The codeblock header should be of the format '```language filepath'", + name: "Edit results", + description: `Result of editing ${args.filepath}`, + content: `Successfully applied edits to ${args.filepath}. The users must manually reject/accept diffs, prompt them to do so`, }, ]; }; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 3c6963071..573838caa 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -242,6 +242,10 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } + async applyToFile() { + throw new Error("not implemented"); + } + async subprocess(command: string, cwd?: string): Promise<[string, string]> { return ["", ""]; } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index 7e68cf007..ce1eea771 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -7,6 +7,8 @@ import com.github.continuedev.continueintellijextension.utils.* import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil +import com.intellij.find.FindModel +import com.intellij.find.impl.FindInProjectUtil import com.intellij.ide.plugins.PluginManager import com.intellij.ide.plugins.PluginManagerCore import com.intellij.lang.annotation.HighlightSeverity @@ -20,8 +22,10 @@ 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.progress.EmptyProgressIndicator import com.intellij.openapi.project.Project import com.intellij.openapi.project.guessProjectDir +import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.util.IconLoader import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFileManager @@ -46,7 +50,6 @@ class IntelliJIDE( private val gitService = GitService(project, continuePluginService) - private val ripgrep: String init { @@ -309,12 +312,116 @@ class IntelliJIDE( return getOpenFiles() } - override suspend fun getSearchResults(query: String): String { - val command = GeneralCommandLine(ripgrep, "-i", "-C", "2", "--heading", "-e", query, ".") - command.setWorkDirectory(project.basePath) - return ExecUtil.execAndGetOutput(command).stdout + override suspend fun getFileResults(pattern: String): List { + val ideInfo = this.getIdeInfo() + if (ideInfo.remoteName == "local") { + val command = GeneralCommandLine( + ripgrep, + "--files", + "--iglob", + pattern, + "--ignore-file", + ".continueignore", + "--ignore-file", + ".gitignore", + ) + + command.setWorkDirectory(project.basePath) + val results = ExecUtil.execAndGetOutput(command).stdout + return results.split("\n") + } else { + throw NotImplementedError("Ripgrep not supported, this workspace is remote") + + // Leaving in here for ideas + // val projectBasePath = project.basePath ?: return emptyList() + // val scope = GlobalSearchScope.projectScope(project) + // + // // Get all ignore patterns from .continueignore files + // val ignorePatterns = mutableSetOf() + // VirtualFileManager.getInstance().findFileByUrl("file://$projectBasePath")?.let { root -> + // VfsUtil.collectChildrenRecursively(root).forEach { file -> + // if (file.name == ".continueignore") { + // file.inputStream.bufferedReader().useLines { lines -> + // ignorePatterns.addAll(lines.filter { it.isNotBlank() && !it.startsWith("#") }) + // } + // } + // } + // } + // + // return FilenameIndex.getAllFilesByExt(project, "*", scope) + // .filter { file -> + // val relativePath = file.path.removePrefix("$projectBasePath/") + // // Check if file matches pattern and isn't ignored + // PatternUtil.(relativePath, pattern) && + // !ignorePatterns.any { PatternUtil.matchesGlob(relativePath, it) } + // } + // .map { it.path.removePrefix("$projectBasePath/") } + } } + override suspend fun getSearchResults(query: String): String { + val ideInfo = this.getIdeInfo() + if (ideInfo.remoteName == "local") { + val command = GeneralCommandLine( + ripgrep, + "-i", + "--ignore-file", + ".continueignore", + "--ignore-file", + ".gitignore", + "-C", + "2", + "--heading", + "-e", + query, + "." + ) + + command.setWorkDirectory(project.basePath) + return ExecUtil.execAndGetOutput(command).stdout + } else { + throw NotImplementedError("Ripgrep not supported, this workspace is remote") + + // For remote workspaces, use JetBrains search functionality + // val searchResults = StringBuilder() + // ApplicationManager.getApplication().invokeAndWait { + // val options = FindModel().apply { + // stringToFind = query + // isCaseSensitive = false + // isRegularExpressions = false + // isWholeWordsOnly = false + // searchContext = FindModel.SearchContext.ANY // or IN_CODE, IN_COMMENTS, IN_STRING_LITERALS, etc. + // isMultiline = true // Allow matching across multiple lines + // } + // + // val progressIndicator = EmptyProgressIndicator() + // val presentation = FindUsagesProcessPresentation( + // UsageViewPresentation() + // ) + // val filesToSearch = ProjectFileIndex.getInstance(project) + // .iterateContent(::ArrayList) + // .filterNot { it.isDirectory } + // .toSet() + // + // + // FindInProjectUtil.findUsages( + // options, + // project, + // progressIndicator, + // presentation, + // filesToSearch + // ) { result -> + // val virtualFile = result.virtualFile + // searchResults.append(virtualFile.path).append("\n") + // searchResults.append("${result..trim()}\n") + // true // continue searching + // } + // } + // return searchResults.toString() + } + } + + override suspend fun subprocess(command: String, cwd: String?): List { val commandList = command.split(" ") val builder = ProcessBuilder(commandList) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt index 5ce49e80a..0e16eeba6 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt @@ -23,7 +23,6 @@ typealias getTagsParams = String data class GetSearchResultsParams(val query: String) - data class SaveFileParams(val filepath: String) data class FileExistsParams(val filepath: String) diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 883039263..504acce2b 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -8,13 +8,6 @@ import { editConfigFile, getConfigJsonPath } from "core/util/paths"; import * as URI from "uri-js"; import * as vscode from "vscode"; -import { executeGotoProvider } from "./autocomplete/lsp"; -import { Repository } from "./otherExtensions/git"; -import { SecretStorage } from "./stubs/SecretStorage"; -import { VsCodeIdeUtils } from "./util/ideUtils"; -import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode"; -import { VsCodeWebviewProtocol } from "./webviewProtocol"; - import type { ContinueRcJson, FileStatsMap, @@ -29,6 +22,12 @@ import type { TerminalOptions, Thread, } from "core"; +import { executeGotoProvider } from "./autocomplete/lsp"; +import { Repository } from "./otherExtensions/git"; +import { SecretStorage } from "./stubs/SecretStorage"; +import { VsCodeIdeUtils } from "./util/ideUtils"; +import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode"; +import { VsCodeWebviewProtocol } from "./webviewProtocol"; class VsCodeIde implements IDE { ideUtils: VsCodeIdeUtils; diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 23669305a..43987c4b8 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -18,6 +18,7 @@ import { stripImages } from "core/util/messageContent"; import { getUriPathBasename } from "core/util/uri"; import * as vscode from "vscode"; +import { ILLM } from "core"; import { VerticalDiffManager } from "../diff/vertical/manager"; import EditDecorationManager from "../quickEdit/EditDecorationManager"; import { @@ -28,7 +29,6 @@ import { showTutorial } from "../util/tutorial"; import { getExtensionUri } from "../util/vscode"; import { VsCodeIde } from "../VsCodeIde"; import { VsCodeWebviewProtocol } from "../webviewProtocol"; -import { ILLM } from "core"; /** * A shared messenger class between Core and Webview @@ -128,7 +128,7 @@ export class VsCodeMessenger { ); }); - this.onWebview("applyToFile", async ({ data }) => { + this.onWebviewOrCore("applyToFile", async ({ data }) => { webviewProtocol.request("updateApplyState", { streamId: data.streamId, status: "streaming", diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 776192e45..e9393f384 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -57,7 +57,6 @@ export interface StepContainerPreToolbarProps { children: any; expanded?: boolean; hideApply?: boolean; - autoApply?: boolean; } export default function StepContainerPreToolbar( @@ -136,17 +135,17 @@ export default function StepContainerPreToolbar( } }, [props.children, codeBlockContent]); - useEffect(() => { - const hasCompletedGenerating = - wasGeneratingRef.current && !isGeneratingCodeBlock; + // useEffect(() => { + // const hasCompletedGenerating = + // wasGeneratingRef.current && !isGeneratingCodeBlock; - wasGeneratingRef.current = isGeneratingCodeBlock; - if (hasCompletedGenerating) { - if (props.autoApply) { - onClickApply(); - } - } - }, [wasGeneratingRef, isGeneratingCodeBlock, props.autoApply]); + // wasGeneratingRef.current = isGeneratingCodeBlock; + // if (hasCompletedGenerating) { + // if (props.autoApply) { + // onClickApply(); + // } + // } + // }, [wasGeneratingRef, isGeneratingCodeBlock, props.autoApply]); async function onClickAcceptApply() { const fileUri = await inferResolvedUriFromRelativePath( diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 4aed38536..5137c63b9 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -130,8 +130,8 @@ interface StyledMarkdownPreviewProps { scrollLocked?: boolean; itemIndex?: number; useParentBackgroundColor?: boolean; - autoApplyCodeblocks?: boolean; hideApply?: boolean; + firstCodeblockStreamId?: string; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -199,7 +199,14 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( const pastFileInfoRef = useUpdatingRef(pastFileInfo); const codeblockState = useRef<{ streamId: string; isGenerating: boolean }[]>( - [], + props.firstCodeblockStreamId + ? [ + { + streamId: props.firstCodeblockStreamId, + isGenerating: false, + }, + ] + : [], ); const [reactContent, setMarkdownSource] = useRemark({ @@ -319,9 +326,10 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( streamId: uuidv4(), isGenerating: isGeneratingCodeBlock, }; + } else { + codeblockState.current[codeBlockIndex].isGenerating = + isGeneratingCodeBlock; } - const codeblockStreamId = - codeblockState.current[codeBlockIndex].streamId; // We use a custom toolbar for codeblocks in the step container return ( @@ -332,8 +340,9 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( relativeFilepath={relativeFilePath} isGeneratingCodeBlock={isGeneratingCodeBlock} range={range} - autoApply={props.autoApplyCodeblocks} - codeBlockStreamId={codeblockStreamId} + codeBlockStreamId={ + codeblockState.current[codeBlockIndex].streamId + } hideApply={props.hideApply} > diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index 56ee77ef3..f1c528966 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -1,5 +1,9 @@ import { getMarkdownLanguageTagForFile } from "core/util"; +import { useMemo } from "react"; +import { v4 as uuidv4 } from "uuid"; import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview"; +import { useAppDispatch } from "../../../redux/hooks"; +import { setLastApplyToolStreamId } from "../../../redux/slices/sessionSlice"; type EditToolCallProps = { relativeFilePath: string; @@ -7,14 +11,21 @@ type EditToolCallProps = { }; export function EditFile(props: EditToolCallProps) { + const dispatch = useAppDispatch(); const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.newContents ?? ""}\n\`\`\``; + const streamId = useMemo(() => { + const id = uuidv4(); + dispatch(setLastApplyToolStreamId({ streamId: id })); + return id; + }, []); + return props.relativeFilePath ? ( ) : null; } diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 5aa714acc..88ac4e3b4 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -54,6 +54,7 @@ type SessionState = { curIndex: number; }; newestCodeblockForInput: Record; + lastApplyToolStreamId?: string; }; function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) { @@ -637,6 +638,12 @@ export const sessionSlice = createSlice({ toolCallState.status = "calling"; }, + setLastApplyToolStreamId: ( + state, + action: PayloadAction<{ streamId: string }>, + ) => { + state.lastApplyToolStreamId = action.payload.streamId; + }, setMode: (state, action: PayloadAction) => { state.mode = action.payload; }, @@ -759,6 +766,7 @@ export const { updateSessionMetadata, deleteSessionMetadata, setNewestCodeblocksForInput, + setLastApplyToolStreamId, cycleMode, } = sessionSlice.actions; diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 34ae00390..82ec08f0f 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -1,4 +1,5 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; +import { BuiltInToolNames } from "core/tools/builtIn"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; import { selectDefaultModel } from "../slices/configSlice"; import { @@ -34,6 +35,11 @@ export const callTool = createAsyncThunk( const result = await extra.ideMessenger.request("tools/call", { toolCall: toolCallState.toolCall, selectedModelTitle: defaultModel.title, + applyStreamId: + toolCallState.toolCall.function.name === + BuiltInToolNames.EditExistingFile + ? state.session.lastApplyToolStreamId + : undefined, }); if (result.status === "success") { From 2a8cb6d524cc9fda0226290a462dc8e87034b99c Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 4 Apr 2025 12:47:23 +0530 Subject: [PATCH 25/67] improve(package.js): show the version when vsce packages --- extensions/vscode/scripts/package.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/scripts/package.js b/extensions/vscode/scripts/package.js index 35ad7d24f..2fd5177eb 100644 --- a/extensions/vscode/scripts/package.js +++ b/extensions/vscode/scripts/package.js @@ -1,6 +1,10 @@ const { exec } = require("child_process"); const fs = require("fs"); +const version = JSON.parse( + fs.readFileSync("./package.json", { encoding: "utf-8" }), +).version; + const args = process.argv.slice(2); let target; @@ -27,6 +31,6 @@ exec(command, (error) => { throw error; } console.log( - "vsce package completed - extension created at extensions/vscode/build/continue-{version}.vsix", + `vsce package completed - extension created at extensions/vscode/build/continue-${version}.vsix`, ); }); From 1bc816b1f1bf43c354f153a43d3875cb4273d21d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 00:38:33 -0700 Subject: [PATCH 26/67] edit file apply state --- core/tools/implementations/editFile.ts | 5 +- .../StepContainerPreToolbar/ApplyActions.tsx | 12 +++-- .../StepContainerPreToolbar.tsx | 5 +- .../markdown/StyledMarkdownPreview.tsx | 4 +- gui/src/pages/gui/ToolCallDiv/CreateFile.tsx | 2 +- gui/src/pages/gui/ToolCallDiv/EditFile.tsx | 54 +++++++++++++------ gui/src/redux/slices/sessionSlice.ts | 37 ++++++++----- 7 files changed, 80 insertions(+), 39 deletions(-) diff --git a/core/tools/implementations/editFile.ts b/core/tools/implementations/editFile.ts index deac3cc54..6862b29f2 100644 --- a/core/tools/implementations/editFile.ts +++ b/core/tools/implementations/editFile.ts @@ -12,15 +12,12 @@ export const editFileImpl: ToolImpl = async (args, extras) => { if (!extras.applyToFile) { throw new Error("Failed to apply to file: invalid apply stream id"); } - if (!extras.llm.title) { - throw new Error("Failed to apply to file: no model selected"); - } await extras.applyToFile(firstUriMatch, args.new_contents); return [ { name: "Edit results", description: `Result of editing ${args.filepath}`, - content: `Successfully applied edits to ${args.filepath}. The users must manually reject/accept diffs, prompt them to do so`, + content: `Successfully applied edits to ${args.filepath}. The users must manually reject/accept diffs. Prompt them to do so in your response`, }, ]; }; diff --git a/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx b/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx index 71e7ca9cf..0da1c5c7f 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx @@ -7,6 +7,7 @@ import Spinner from "../../gui/Spinner"; import { ToolbarButtonWithTooltip } from "./ToolbarButtonWithTooltip"; interface ApplyActionsProps { + disableManualApply?: boolean; applyState?: ApplyState; onClickAccept: () => void; onClickReject: () => void; @@ -59,8 +60,8 @@ export default function ApplyActions(props: ApplyActionsProps) { ); case "done": return ( -
- +
+ {`${props.applyState?.numDiffs === 1 ? "1 diff" : `${props.applyState?.numDiffs} diffs`}`} {` remaining`} @@ -90,10 +91,15 @@ export default function ApplyActions(props: ApplyActionsProps) { ); } - + if (props.disableManualApply) { + return null; + } return applyButton("Reapply"); } default: + if (props.disableManualApply) { + return null; + } return applyButton("Apply"); } } diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index e9393f384..375fd7ab8 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -56,7 +56,7 @@ export interface StepContainerPreToolbarProps { range?: string; children: any; expanded?: boolean; - hideApply?: boolean; + disableManualApply?: boolean; } export default function StepContainerPreToolbar( @@ -206,8 +206,9 @@ export default function StepContainerPreToolbar( {isTerminalCodeBlock(props.language, props.codeBlockContent) ? ( - ) : props.hideApply ? null : ( + ) : ( diff --git a/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx b/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx index 9829ef64b..45396dc23 100644 --- a/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx @@ -13,7 +13,7 @@ export function CreateFile(props: CreateFileToolCallProps) { ) : null; } diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index f1c528966..b3cb2bb63 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -1,9 +1,9 @@ import { getMarkdownLanguageTagForFile } from "core/util"; import { useMemo } from "react"; -import { v4 as uuidv4 } from "uuid"; import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview"; -import { useAppDispatch } from "../../../redux/hooks"; -import { setLastApplyToolStreamId } from "../../../redux/slices/sessionSlice"; +import AcceptRejectAllButtons from "../../../components/StepContainer/AcceptRejectAllButtons"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { selectApplyStateByStreamId } from "../../../redux/slices/sessionSlice"; type EditToolCallProps = { relativeFilePath: string; @@ -11,21 +11,45 @@ type EditToolCallProps = { }; export function EditFile(props: EditToolCallProps) { - const dispatch = useAppDispatch(); const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.newContents ?? ""}\n\`\`\``; + const dispatch = useAppDispatch(); + + const isStreaming = useAppSelector((state) => state.session.isStreaming); + const lastApplyToolStreamId = useAppSelector( + (state) => state.session.lastApplyToolStreamId, + ); const streamId = useMemo(() => { - const id = uuidv4(); - dispatch(setLastApplyToolStreamId({ streamId: id })); - return id; + return lastApplyToolStreamId; }, []); - return props.relativeFilePath ? ( - - ) : null; + console.log("STREAM ID", streamId); + + const applyState = useAppSelector((state) => + selectApplyStateByStreamId(state, streamId), + ); + + if (!props.relativeFilePath) { + return null; + } + + return ( + <> + + + {!isStreaming && applyState?.status === "done" && ( +
+ {}} + /> +
+ )} + + ); } diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 88ac4e3b4..51af56ee7 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -21,6 +21,7 @@ import { ToolCallDelta, ToolCallState, } from "core"; +import { BuiltInToolNames } from "core/tools/builtIn"; import { NEW_SESSION_TITLE } from "core/util/constants"; import { incrementalParseJson } from "core/util/incrementalParseJson"; import { renderChatMessage } from "core/util/messageContent"; @@ -354,16 +355,25 @@ export const sessionSlice = createSlice({ if (message.role === "assistant" && message.toolCalls?.[0]) { const toolCallDelta = message.toolCalls[0]; if ( - toolCallDelta.id && - toolCallDelta.function?.arguments && - toolCallDelta.function?.name && - toolCallDelta.type + !( + toolCallDelta.id && + toolCallDelta.function?.arguments && + toolCallDelta.function?.name && + toolCallDelta.type + ) ) { console.warn( "Received streamed tool call without required fields", toolCallDelta, ); } + + if ( + toolCallDelta.function?.name === + BuiltInToolNames.EditExistingFile + ) { + state.lastApplyToolStreamId = uuidv4(); + } historyItem.toolCallState = toolCallDeltaToState(toolCallDelta); } state.history.push(historyItem); @@ -638,12 +648,6 @@ export const sessionSlice = createSlice({ toolCallState.status = "calling"; }, - setLastApplyToolStreamId: ( - state, - action: PayloadAction<{ streamId: string }>, - ) => { - state.lastApplyToolStreamId = action.payload.streamId; - }, setMode: (state, action: PayloadAction) => { state.mode = action.payload; }, @@ -723,7 +727,17 @@ export const selectCurrentToolCall = createSelector( export const selectApplyStateByStreamId = createSelector( [ (state: RootState) => state.session.codeBlockApplyStates.states, - (state: RootState, streamId: string) => streamId, + (state: RootState, streamId?: string) => streamId, + ], + (states, streamId) => { + return states.find((state) => state.streamId === streamId); + }, +); + +export const selectLastEditToolApplyState = createSelector( + [ + (state: RootState) => state.session.codeBlockApplyStates.states, + (state: RootState) => state.session.lastApplyToolStreamId, ], (states, streamId) => { return states.find((state) => state.streamId === streamId); @@ -766,7 +780,6 @@ export const { updateSessionMetadata, deleteSessionMetadata, setNewestCodeblocksForInput, - setLastApplyToolStreamId, cycleMode, } = sessionSlice.actions; From 4683a20c2fbc0c70fe5457221743bd6a15749a3b Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 00:51:31 -0700 Subject: [PATCH 27/67] cleanup --- core/tools/implementations/editFile.ts | 4 +- core/util/filesystem.ts | 4 - .../continue/IntelliJIde.kt | 115 +----------------- .../continueintellijextension/protocol/ide.kt | 1 + extensions/vscode/src/VsCodeIde.ts | 13 +- manual-testing-sandbox/requirements.txt | 2 +- 6 files changed, 15 insertions(+), 124 deletions(-) diff --git a/core/tools/implementations/editFile.ts b/core/tools/implementations/editFile.ts index 6862b29f2..26156352b 100644 --- a/core/tools/implementations/editFile.ts +++ b/core/tools/implementations/editFile.ts @@ -16,8 +16,8 @@ export const editFileImpl: ToolImpl = async (args, extras) => { return [ { name: "Edit results", - description: `Result of editing ${args.filepath}`, - content: `Successfully applied edits to ${args.filepath}. The users must manually reject/accept diffs. Prompt them to do so in your response`, + description: `Edited ${args.filepath}`, + content: `Applied edit diffs to ${args.filepath}. The user must manually reject/accept diffs. Prompt them to do so in your response`, }, ]; }; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 573838caa..3c6963071 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -242,10 +242,6 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } - async applyToFile() { - throw new Error("not implemented"); - } - async subprocess(command: string, cwd?: string): Promise<[string, string]> { return ["", ""]; } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index ce1eea771..7e68cf007 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -7,8 +7,6 @@ import com.github.continuedev.continueintellijextension.utils.* import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil -import com.intellij.find.FindModel -import com.intellij.find.impl.FindInProjectUtil import com.intellij.ide.plugins.PluginManager import com.intellij.ide.plugins.PluginManagerCore import com.intellij.lang.annotation.HighlightSeverity @@ -22,10 +20,8 @@ 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.progress.EmptyProgressIndicator import com.intellij.openapi.project.Project import com.intellij.openapi.project.guessProjectDir -import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.util.IconLoader import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFileManager @@ -50,6 +46,7 @@ class IntelliJIDE( private val gitService = GitService(project, continuePluginService) + private val ripgrep: String init { @@ -312,115 +309,11 @@ class IntelliJIDE( return getOpenFiles() } - override suspend fun getFileResults(pattern: String): List { - val ideInfo = this.getIdeInfo() - if (ideInfo.remoteName == "local") { - val command = GeneralCommandLine( - ripgrep, - "--files", - "--iglob", - pattern, - "--ignore-file", - ".continueignore", - "--ignore-file", - ".gitignore", - ) - - command.setWorkDirectory(project.basePath) - val results = ExecUtil.execAndGetOutput(command).stdout - return results.split("\n") - } else { - throw NotImplementedError("Ripgrep not supported, this workspace is remote") - - // Leaving in here for ideas - // val projectBasePath = project.basePath ?: return emptyList() - // val scope = GlobalSearchScope.projectScope(project) - // - // // Get all ignore patterns from .continueignore files - // val ignorePatterns = mutableSetOf() - // VirtualFileManager.getInstance().findFileByUrl("file://$projectBasePath")?.let { root -> - // VfsUtil.collectChildrenRecursively(root).forEach { file -> - // if (file.name == ".continueignore") { - // file.inputStream.bufferedReader().useLines { lines -> - // ignorePatterns.addAll(lines.filter { it.isNotBlank() && !it.startsWith("#") }) - // } - // } - // } - // } - // - // return FilenameIndex.getAllFilesByExt(project, "*", scope) - // .filter { file -> - // val relativePath = file.path.removePrefix("$projectBasePath/") - // // Check if file matches pattern and isn't ignored - // PatternUtil.(relativePath, pattern) && - // !ignorePatterns.any { PatternUtil.matchesGlob(relativePath, it) } - // } - // .map { it.path.removePrefix("$projectBasePath/") } - } - } - override suspend fun getSearchResults(query: String): String { - val ideInfo = this.getIdeInfo() - if (ideInfo.remoteName == "local") { - val command = GeneralCommandLine( - ripgrep, - "-i", - "--ignore-file", - ".continueignore", - "--ignore-file", - ".gitignore", - "-C", - "2", - "--heading", - "-e", - query, - "." - ) - - command.setWorkDirectory(project.basePath) - return ExecUtil.execAndGetOutput(command).stdout - } else { - throw NotImplementedError("Ripgrep not supported, this workspace is remote") - - // For remote workspaces, use JetBrains search functionality - // val searchResults = StringBuilder() - // ApplicationManager.getApplication().invokeAndWait { - // val options = FindModel().apply { - // stringToFind = query - // isCaseSensitive = false - // isRegularExpressions = false - // isWholeWordsOnly = false - // searchContext = FindModel.SearchContext.ANY // or IN_CODE, IN_COMMENTS, IN_STRING_LITERALS, etc. - // isMultiline = true // Allow matching across multiple lines - // } - // - // val progressIndicator = EmptyProgressIndicator() - // val presentation = FindUsagesProcessPresentation( - // UsageViewPresentation() - // ) - // val filesToSearch = ProjectFileIndex.getInstance(project) - // .iterateContent(::ArrayList) - // .filterNot { it.isDirectory } - // .toSet() - // - // - // FindInProjectUtil.findUsages( - // options, - // project, - // progressIndicator, - // presentation, - // filesToSearch - // ) { result -> - // val virtualFile = result.virtualFile - // searchResults.append(virtualFile.path).append("\n") - // searchResults.append("${result..trim()}\n") - // true // continue searching - // } - // } - // return searchResults.toString() - } + val command = GeneralCommandLine(ripgrep, "-i", "-C", "2", "--heading", "-e", query, ".") + command.setWorkDirectory(project.basePath) + return ExecUtil.execAndGetOutput(command).stdout } - override suspend fun subprocess(command: String, cwd: String?): List { val commandList = command.split(" ") diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt index 0e16eeba6..5ce49e80a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt @@ -23,6 +23,7 @@ typealias getTagsParams = String data class GetSearchResultsParams(val query: String) + data class SaveFileParams(val filepath: String) data class FileExistsParams(val filepath: String) diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 504acce2b..883039263 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -8,6 +8,13 @@ import { editConfigFile, getConfigJsonPath } from "core/util/paths"; import * as URI from "uri-js"; import * as vscode from "vscode"; +import { executeGotoProvider } from "./autocomplete/lsp"; +import { Repository } from "./otherExtensions/git"; +import { SecretStorage } from "./stubs/SecretStorage"; +import { VsCodeIdeUtils } from "./util/ideUtils"; +import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode"; +import { VsCodeWebviewProtocol } from "./webviewProtocol"; + import type { ContinueRcJson, FileStatsMap, @@ -22,12 +29,6 @@ import type { TerminalOptions, Thread, } from "core"; -import { executeGotoProvider } from "./autocomplete/lsp"; -import { Repository } from "./otherExtensions/git"; -import { SecretStorage } from "./stubs/SecretStorage"; -import { VsCodeIdeUtils } from "./util/ideUtils"; -import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode"; -import { VsCodeWebviewProtocol } from "./webviewProtocol"; class VsCodeIde implements IDE { ideUtils: VsCodeIdeUtils; diff --git a/manual-testing-sandbox/requirements.txt b/manual-testing-sandbox/requirements.txt index 87f2e654b..9de6f14df 100644 --- a/manual-testing-sandbox/requirements.txt +++ b/manual-testing-sandbox/requirements.txt @@ -54,4 +54,4 @@ aiohttp==3.7.4 # Others jupyter==1.0.0 gunicorn==20.1.0 -psycopg2==2.9.1 \ No newline at end of file +psycopg2==2.9.1 From 8f556c0b014b16f9586a8cccca0b8a4fcfc36711 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 01:02:48 -0700 Subject: [PATCH 28/67] move to custom edit impl --- core/index.d.ts | 1 - core/protocol/core.ts | 2 +- core/protocol/ide.ts | 11 -------- core/protocol/ideWebview.ts | 12 +++++++++ core/tools/callTool.ts | 6 ++--- core/tools/implementations/editFile.ts | 24 +---------------- .../vscode/src/extension/VsCodeMessenger.ts | 4 +-- gui/src/redux/thunks/callTool.ts | 27 ++++++++++++++----- manual-testing-sandbox/requirements.txt | 2 +- 9 files changed, 41 insertions(+), 48 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 5b2b482ed..ba97377d3 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -891,7 +891,6 @@ export interface ToolExtras { llm: ILLM; fetch: FetchFunction; tool: Tool; - applyToFile?: (path: string, content: string) => Promise; } export interface Tool { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index f92f70a50..03940c283 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -193,7 +193,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }]; "tools/call": [ - { toolCall: ToolCall; selectedModelTitle: string; applyStreamId?: string }, + { toolCall: ToolCall; selectedModelTitle: string }, { contextItems: ContextItem[] }, ]; "clipboardCache/add": [{ content: string }, void]; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 9b3d030f6..5b2a7ab1f 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -23,17 +23,6 @@ export interface GetGhTokenArgs { export type ToIdeFromWebviewOrCoreProtocol = { // Methods from IDE type - // We pass the `curSelectedModel` because we currently cannot access the - // default model title in the GUI from JB - applyToFile: [ - { - text: string; - streamId: string; - curSelectedModelTitle: string; - filepath?: string; - }, - void, - ]; getIdeInfo: [undefined, IdeInfo]; getWorkspaceDirs: [undefined, string[]]; writeFile: [{ path: string; contents: string }, void]; diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 03074b95f..a7cd16e5b 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -4,6 +4,7 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview"; import type { ApplyState, CodeToEdit, + ContextSubmenuItem, EditStatus, MessageContent, RangeInFileWithContents, @@ -11,6 +12,17 @@ import type { export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { openUrl: [string, void]; + // We pass the `curSelectedModel` because we currently cannot access the + // default model title in the GUI from JB + applyToFile: [ + { + text: string; + streamId: string; + curSelectedModelTitle: string; + filepath?: string; + }, + void, + ]; overwriteFile: [{ filepath: string; prevFileContent: string | null }, void]; showTutorial: [undefined, void]; showFile: [{ filepath: string }, void]; diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 2866124ef..2a04cb828 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -4,7 +4,6 @@ import { canParseUrl } from "../util/url"; import { BuiltInToolNames } from "./builtIn"; import { createNewFileImpl } from "./implementations/createNewFile"; -import { editFileImpl } from "./implementations/editFile"; import { exactSearchImpl } from "./implementations/exactSearch"; import { lsToolImpl } from "./implementations/lsTool"; import { readCurrentlyOpenFileImpl } from "./implementations/readCurrentlyOpenFile"; @@ -139,8 +138,9 @@ export async function callTool( switch (uri) { case BuiltInToolNames.ReadFile: return await readFileImpl(args, extras); - case BuiltInToolNames.EditExistingFile: - return await editFileImpl(args, extras); + // Custom GUI handling for edit + // case BuiltInToolNames.EditExistingFile: + // return await editFileImpl(args, extras); case BuiltInToolNames.CreateNewFile: return await createNewFileImpl(args, extras); case BuiltInToolNames.ExactSearch: diff --git a/core/tools/implementations/editFile.ts b/core/tools/implementations/editFile.ts index 26156352b..cb829af6a 100644 --- a/core/tools/implementations/editFile.ts +++ b/core/tools/implementations/editFile.ts @@ -1,23 +1 @@ -import { ToolImpl } from "."; -import { resolveRelativePathInDir } from "../../util/ideUtils"; - -export const editFileImpl: ToolImpl = async (args, extras) => { - const firstUriMatch = await resolveRelativePathInDir( - args.filepath, - extras.ide, - ); - if (!firstUriMatch) { - throw new Error(`File ${args.filepath} does not exist.`); - } - if (!extras.applyToFile) { - throw new Error("Failed to apply to file: invalid apply stream id"); - } - await extras.applyToFile(firstUriMatch, args.new_contents); - return [ - { - name: "Edit results", - description: `Edited ${args.filepath}`, - content: `Applied edit diffs to ${args.filepath}. The user must manually reject/accept diffs. Prompt them to do so in your response`, - }, - ]; -}; +// Edit has custom handling on the GUI side diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 43987c4b8..23669305a 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -18,7 +18,6 @@ import { stripImages } from "core/util/messageContent"; import { getUriPathBasename } from "core/util/uri"; import * as vscode from "vscode"; -import { ILLM } from "core"; import { VerticalDiffManager } from "../diff/vertical/manager"; import EditDecorationManager from "../quickEdit/EditDecorationManager"; import { @@ -29,6 +28,7 @@ import { showTutorial } from "../util/tutorial"; import { getExtensionUri } from "../util/vscode"; import { VsCodeIde } from "../VsCodeIde"; import { VsCodeWebviewProtocol } from "../webviewProtocol"; +import { ILLM } from "core"; /** * A shared messenger class between Core and Webview @@ -128,7 +128,7 @@ export class VsCodeMessenger { ); }); - this.onWebviewOrCore("applyToFile", async ({ data }) => { + this.onWebview("applyToFile", async ({ data }) => { webviewProtocol.request("updateApplyState", { streamId: data.streamId, status: "streaming", diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 82ec08f0f..8df0ccfa9 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -1,5 +1,4 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; -import { BuiltInToolNames } from "core/tools/builtIn"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; import { selectDefaultModel } from "../slices/configSlice"; import { @@ -35,11 +34,6 @@ export const callTool = createAsyncThunk( const result = await extra.ideMessenger.request("tools/call", { toolCall: toolCallState.toolCall, selectedModelTitle: defaultModel.title, - applyStreamId: - toolCallState.toolCall.function.name === - BuiltInToolNames.EditExistingFile - ? state.session.lastApplyToolStreamId - : undefined, }); if (result.status === "success") { @@ -76,3 +70,24 @@ export const callTool = createAsyncThunk( } }, ); + +// export const editFileImpl: ToolImpl = async (args, extras) => { +// const firstUriMatch = await resolveRelativePathInDir( +// args.filepath, +// extras.ide, +// ); +// if (!firstUriMatch) { +// throw new Error(`File ${args.filepath} does not exist.`); +// } +// if (!extras.applyToFile) { +// throw new Error("Failed to apply to file: invalid apply stream id"); +// } +// await extras.applyToFile(firstUriMatch, args.new_contents); +// return [ +// { +// name: "Edit results", +// description: `Edited ${args.filepath}`, +// content: `Applied edit diffs to ${args.filepath}. The user must manually reject/accept diffs. Prompt them to do so in your response`, +// }, +// ]; +// }; diff --git a/manual-testing-sandbox/requirements.txt b/manual-testing-sandbox/requirements.txt index 9de6f14df..87f2e654b 100644 --- a/manual-testing-sandbox/requirements.txt +++ b/manual-testing-sandbox/requirements.txt @@ -54,4 +54,4 @@ aiohttp==3.7.4 # Others jupyter==1.0.0 gunicorn==20.1.0 -psycopg2==2.9.1 +psycopg2==2.9.1 \ No newline at end of file From e1ff2a9e57f21740672edddb24b45d8968d4d67b Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 02:07:43 -0700 Subject: [PATCH 29/67] custom gui approach --- core/core.ts | 17 +--- gui/src/hooks/useSetup.ts | 8 ++ gui/src/redux/slices/sessionSlice.ts | 12 +-- gui/src/redux/thunks/callTool.ts | 121 ++++++++++++++++++--------- 4 files changed, 95 insertions(+), 63 deletions(-) diff --git a/core/core.ts b/core/core.ts index 911ea0072..b1393f8cd 100644 --- a/core/core.ts +++ b/core/core.ts @@ -36,7 +36,6 @@ import { TTS } from "./util/tts"; import { DiffLine, - ToolExtras, type ContextItemId, type IDE, type IndexingProgressUpdate, @@ -873,7 +872,7 @@ export class Core { }); on("tools/call", async (msg) => { - const { toolCall, selectedModelTitle, applyStreamId } = msg.data; + const { toolCall, selectedModelTitle } = msg.data; const { config } = await this.configHandler.loadConfig(); if (!config) { throw new Error("Config not loaded"); @@ -889,19 +888,6 @@ export class Core { const llm = await this.configHandler.llmFromTitle(selectedModelTitle); - let applyToFile: ToolExtras["applyToFile"] = undefined; - if (applyStreamId) { - applyToFile = async (path: string, contents: string) => { - return await this.messenger.request("applyToFile", { - filepath: path, - text: contents, - streamId: applyStreamId, - curSelectedModelTitle: - config.selectedModelByRole.apply?.title ?? selectedModelTitle, - }); - }; - } - const contextItems = await callTool( tool, JSON.parse(toolCall.function.arguments || "{}"), @@ -911,7 +897,6 @@ export class Core { fetch: (url, init) => fetchwithRequestOptions(url, init, config.requestOptions), tool, - applyToFile, }, ); diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index d90259a9b..f1909afc5 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -17,6 +17,7 @@ import { import { updateIndexingStatus } from "../redux/slices/indexingSlice"; import { addContextItemsAtIndex, + selectLastEditToolApplyState, setInactive, } from "../redux/slices/sessionSlice"; import { setTTSActive } from "../redux/slices/uiSlice"; @@ -245,6 +246,13 @@ function useSetup() { }, [defaultModel], ); + + const lastEditToolApplyState = useAppSelector(selectLastEditToolApplyState); + useEffect(() => { + ideMessenger.post("showToast", ["info", "updated last apply state"]); + // dispatch(setToolCallOutput(output)); + // dispatch(acceptToolCall()); + }, [lastEditToolApplyState]); } export default useSetup; diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 51af56ee7..544a8c401 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -21,7 +21,6 @@ import { ToolCallDelta, ToolCallState, } from "core"; -import { BuiltInToolNames } from "core/tools/builtIn"; import { NEW_SESSION_TITLE } from "core/util/constants"; import { incrementalParseJson } from "core/util/incrementalParseJson"; import { renderChatMessage } from "core/util/messageContent"; @@ -368,12 +367,6 @@ export const sessionSlice = createSlice({ ); } - if ( - toolCallDelta.function?.name === - BuiltInToolNames.EditExistingFile - ) { - state.lastApplyToolStreamId = uuidv4(); - } historyItem.toolCallState = toolCallDeltaToState(toolCallDelta); } state.history.push(historyItem); @@ -559,7 +552,9 @@ export const sessionSlice = createSlice({ state.history[state.history.length - 1].contextItems = contextItems; }, - + setLastToolApplyStreamId: (state, { payload }: PayloadAction) => { + state.lastApplyToolStreamId = payload; + }, updateCurCheckpoint: ( state, { payload }: PayloadAction<{ filepath: string; content: string }>, @@ -781,6 +776,7 @@ export const { deleteSessionMetadata, setNewestCodeblocksForInput, cycleMode, + setLastToolApplyStreamId, } = sessionSlice.actions; export const { diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 8df0ccfa9..190c25ccf 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -1,10 +1,17 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; +import { ContextItem } from "core"; +import { BuiltInToolNames } from "core/tools/builtIn"; +import { EditToolArgs } from "core/tools/definitions/editFile"; +import { resolveRelativePathInDir } from "core/util/ideUtils"; +import { v4 as uuidv4 } from "uuid"; +import { IIdeMessenger } from "../../context/IdeMessenger"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; import { selectDefaultModel } from "../slices/configSlice"; import { acceptToolCall, cancelToolCall, setCalling, + setLastToolApplyStreamId, setToolCallOutput, } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; @@ -31,28 +38,46 @@ export const callTool = createAsyncThunk( dispatch(setCalling()); - const result = await extra.ideMessenger.request("tools/call", { - toolCall: toolCallState.toolCall, - selectedModelTitle: defaultModel.title, - }); + let errorMessage = ""; + let output: ContextItem[] | undefined = undefined; - if (result.status === "success") { - const contextItems = result.content.contextItems; - dispatch(setToolCallOutput(contextItems)); - dispatch(acceptToolCall()); - - // Send to the LLM to continue the conversation - const response = await dispatch( - streamResponseAfterToolCall({ - toolCallId: toolCallState.toolCall.id, - toolOutput: contextItems, - }), + if ( + toolCallState.toolCall.function.name === BuiltInToolNames.EditExistingFile + ) { + const newToolStreamId = uuidv4(); + dispatch(setLastToolApplyStreamId(newToolStreamId)); + const args = JSON.parse( + toolCallState.toolCall.function.arguments || "{}", ); - unwrapResult(response); + try { + await customGuiEditImpl( + args, + extra.ideMessenger, + newToolStreamId, + defaultModel.title, + ); + } catch (e) { + errorMessage = "Failed to call edit tool"; + if (e instanceof Error) { + errorMessage = e.message; + } + } } else { + const result = await extra.ideMessenger.request("tools/call", { + toolCall: toolCallState.toolCall, + selectedModelTitle: defaultModel.title, + }); + if (result.status === "error") { + errorMessage = result.error; + } else { + output = result.content.contextItems; + } + } + + if (errorMessage) { dispatch(cancelToolCall()); - const output = await dispatch( + const wrapped = await dispatch( streamResponseAfterToolCall({ toolCallId: toolCallState.toolCallId, toolOutput: [ @@ -60,34 +85,52 @@ export const callTool = createAsyncThunk( icon: "problems", name: "Tool Call Error", description: "Tool Call Failed", - content: `The tool call failed with the message:\n\n${result.error}\n\nPlease try something else or request further instructions.`, + content: `The tool call failed with the message:\n\n${errorMessage}\n\nPlease try something else or request further instructions.`, hidden: false, }, ], }), ); - unwrapResult(output); + unwrapResult(wrapped); + } else if (output) { + dispatch(setToolCallOutput(output)); + dispatch(acceptToolCall()); + + // Send to the LLM to continue the conversation + const wrapped = await dispatch( + streamResponseAfterToolCall({ + toolCallId: toolCallState.toolCall.id, + toolOutput: output, + }), + ); + unwrapResult(wrapped); } + // okay for a tool to have no output and need some GUI trigger or other to trigger response e.g. edit tool }, ); -// export const editFileImpl: ToolImpl = async (args, extras) => { -// const firstUriMatch = await resolveRelativePathInDir( -// args.filepath, -// extras.ide, -// ); -// if (!firstUriMatch) { -// throw new Error(`File ${args.filepath} does not exist.`); -// } -// if (!extras.applyToFile) { -// throw new Error("Failed to apply to file: invalid apply stream id"); -// } -// await extras.applyToFile(firstUriMatch, args.new_contents); -// return [ -// { -// name: "Edit results", -// description: `Edited ${args.filepath}`, -// content: `Applied edit diffs to ${args.filepath}. The user must manually reject/accept diffs. Prompt them to do so in your response`, -// }, -// ]; -// }; +async function customGuiEditImpl( + args: EditToolArgs, + ideMessenger: IIdeMessenger, + streamId: string, + modelTitle: string, +) { + const firstUriMatch = await resolveRelativePathInDir( + args.filepath, + ideMessenger.ide, + ); + if (!firstUriMatch) { + return [ + { + name: "Edit failure", + description: `editing ${args.filepath}`, + content: `Failed to edit ${args.filepath}: does not exist`, + }, + ]; + } + ideMessenger.post("applyToFile", { + streamId, + text: args.new_contents, + curSelectedModelTitle: modelTitle, + }); +} From 2efd3ff03a17b3a58d4c950ad9393dda3f82cb78 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 03:16:18 -0700 Subject: [PATCH 30/67] working and disable input when pending tool call stream --- core/core.ts | 3 +- core/index.d.ts | 1 + core/protocol/ideWebview.ts | 2 +- core/tools/definitions/exactSearch.ts | 2 +- core/tools/implementations/editFile.ts | 1 - .../protocol/ideWebview.kt | 3 +- extensions/vscode/src/commands.ts | 2 + .../vscode/src/diff/vertical/manager.ts | 4 ++ .../vscode/src/extension/VsCodeMessenger.ts | 5 ++- gui/src/components/mainInput/InputToolbar.tsx | 7 ++- .../markdown/StyledMarkdownPreview.tsx | 21 +++++---- gui/src/hooks/useSetup.ts | 44 +++++++++++++++---- gui/src/pages/gui/ToolCallDiv/EditFile.tsx | 33 +++++++------- .../FunctionSpecificToolCallDiv.tsx | 1 + gui/src/redux/slices/sessionSlice.ts | 32 +++++++------- gui/src/redux/thunks/callTool.ts | 22 ++++------ 16 files changed, 112 insertions(+), 71 deletions(-) delete mode 100644 core/tools/implementations/editFile.ts diff --git a/core/core.ts b/core/core.ts index b1393f8cd..11fecffb2 100644 --- a/core/core.ts +++ b/core/core.ts @@ -871,8 +871,7 @@ export class Core { } }); - on("tools/call", async (msg) => { - const { toolCall, selectedModelTitle } = msg.data; + on("tools/call", async ({ data: { toolCall, selectedModelTitle } }) => { const { config } = await this.configHandler.loadConfig(); if (!config) { throw new Error("Config not loaded"); diff --git a/core/index.d.ts b/core/index.d.ts index ba97377d3..98f724fda 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1141,6 +1141,7 @@ export interface ApplyState { numDiffs?: number; filepath?: string; fileContent?: string; + toolCallId?: string; } export interface RangeInFileWithContents { diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index a7cd16e5b..6aae337f0 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -4,7 +4,6 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview"; import type { ApplyState, CodeToEdit, - ContextSubmenuItem, EditStatus, MessageContent, RangeInFileWithContents, @@ -20,6 +19,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { streamId: string; curSelectedModelTitle: string; filepath?: string; + toolCallId?: string; }, void, ]; diff --git a/core/tools/definitions/exactSearch.ts b/core/tools/definitions/exactSearch.ts index d20db3cec..7f6e03d6b 100644 --- a/core/tools/definitions/exactSearch.ts +++ b/core/tools/definitions/exactSearch.ts @@ -6,7 +6,7 @@ export const exactSearchTool: Tool = { displayTitle: "Exact Search", wouldLikeTo: 'search for "{{{ query }}}" in the repository', isCurrently: 'getting search results for "{{{ query }}}"', - hasAlready: 'retreived search results for "{{{ query }}}"', + hasAlready: 'retrieved search results for "{{{ query }}}"', readonly: true, group: BUILT_IN_GROUP_NAME, function: { diff --git a/core/tools/implementations/editFile.ts b/core/tools/implementations/editFile.ts deleted file mode 100644 index cb829af6a..000000000 --- a/core/tools/implementations/editFile.ts +++ /dev/null @@ -1 +0,0 @@ -// Edit has custom handling on the GUI side diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt index 07988ad0e..5c587c54d 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ideWebview.kt @@ -12,7 +12,8 @@ data class ApplyToFileParams( val text: String, val streamId: String, val curSelectedModelTitle: String, - val filepath: String? + val filepath: String?, + val toolCallId: String? ) data class InsertAtCursorParams( diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 836360e51..32d240d5f 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -247,6 +247,7 @@ async function processDiff( verticalDiffManager: VerticalDiffManager, newFileUri?: string, streamId?: string, + toolCallId?: string, ) { captureCommandTelemetry(`${action}Diff`); @@ -280,6 +281,7 @@ async function processDiff( streamId, status: "closed", numDiffs: 0, + toolCallId, }); } diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index 34c3345ac..4d4256a1f 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -190,6 +190,7 @@ export class VerticalDiffManager { diffStream: AsyncGenerator, instant: boolean, streamId: string, + toolCallId?: string, ) { vscode.commands.executeCommand("setContext", "continue.diffVisible", true); @@ -226,6 +227,7 @@ export class VerticalDiffManager { numDiffs, fileContent, filepath: fileUri, + toolCallId, }), }, ); @@ -276,6 +278,7 @@ export class VerticalDiffManager { quickEdit?: string, range?: vscode.Range, newCode?: string, + toolCallId?: string, ): Promise { vscode.commands.executeCommand("setContext", "continue.diffVisible", true); @@ -351,6 +354,7 @@ export class VerticalDiffManager { numDiffs, fileContent, filepath: fileUri, + toolCallId, }), }, ); diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 23669305a..98fe8489b 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -18,6 +18,7 @@ import { stripImages } from "core/util/messageContent"; import { getUriPathBasename } from "core/util/uri"; import * as vscode from "vscode"; +import { ILLM } from "core"; import { VerticalDiffManager } from "../diff/vertical/manager"; import EditDecorationManager from "../quickEdit/EditDecorationManager"; import { @@ -28,7 +29,6 @@ import { showTutorial } from "../util/tutorial"; import { getExtensionUri } from "../util/vscode"; import { VsCodeIde } from "../VsCodeIde"; import { VsCodeWebviewProtocol } from "../webviewProtocol"; -import { ILLM } from "core"; /** * A shared messenger class between Core and Webview @@ -133,6 +133,7 @@ export class VsCodeMessenger { streamId: data.streamId, status: "streaming", fileContent: data.text, + toolCallId: data.toolCallId, }); if (data.filepath) { @@ -164,6 +165,7 @@ export class VsCodeMessenger { status: "closed", numDiffs: 0, fileContent: data.text, + toolCallId: data.toolCallId, }); return; @@ -232,6 +234,7 @@ export class VsCodeMessenger { undefined, rangeToApplyTo, data.text, + data.toolCallId, ); } }); diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 3d0a38cec..27c034721 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -98,11 +98,16 @@ function InputToolbar(props: InputToolbarProps) { const hasCodeToEdit = useAppSelector(selectHasCodeToEdit); const toolCallState = useAppSelector(selectCurrentToolCall); const isEditModeAndNoCodeToEdit = isInEditMode && !hasCodeToEdit; + const activeToolCallStreamId = useAppSelector( + (store) => store.session.activeToolStreamId, + ); const isEnterDisabled = props.disabled || isEditModeAndNoCodeToEdit || - toolCallState?.status === "generated"; + toolCallState?.status === "generated" || + activeToolCallStreamId; + const toolsSupported = defaultModel && modelSupportsTools(defaultModel); const supportsImages = diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index b473bb6f0..52ede7cbd 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -131,7 +131,7 @@ interface StyledMarkdownPreviewProps { itemIndex?: number; useParentBackgroundColor?: boolean; disableManualApply?: boolean; - firstCodeblockStreamId?: string; + singleCodeblockStreamId?: string; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -199,15 +199,18 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( const pastFileInfoRef = useUpdatingRef(pastFileInfo); const codeblockState = useRef<{ streamId: string; isGenerating: boolean }[]>( - props.firstCodeblockStreamId - ? [ - { - streamId: props.firstCodeblockStreamId, - isGenerating: false, - }, - ] - : [], + [], ); + useEffect(() => { + if (props.singleCodeblockStreamId) { + codeblockState.current = [ + { + streamId: props.singleCodeblockStreamId, + isGenerating: false, + }, + ]; + } + }, [props.singleCodeblockStreamId]); const [reactContent, setMarkdownSource] = useRemark({ remarkPlugins: [ diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index f1909afc5..914b96089 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -1,9 +1,9 @@ -import { useCallback, useContext, useEffect, useRef } from "react"; +import { useCallback, useContext, useEffect, useMemo, useRef } from "react"; import { VSC_THEME_COLOR_VARS } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { ConfigResult } from "@continuedev/config-yaml"; -import { BrowserSerializedContinueConfig } from "core"; +import { BrowserSerializedContinueConfig, ContextItem } from "core"; import { initializeProfilePreferencesThunk, selectProfileThunk, @@ -16,11 +16,13 @@ import { } from "../redux/slices/configSlice"; import { updateIndexingStatus } from "../redux/slices/indexingSlice"; import { + acceptToolCall, addContextItemsAtIndex, - selectLastEditToolApplyState, setInactive, + setToolCallOutput, } from "../redux/slices/sessionSlice"; import { setTTSActive } from "../redux/slices/uiSlice"; +import { streamResponseAfterToolCall } from "../redux/thunks"; import { refreshSessionMetadata } from "../redux/thunks/session"; import { streamResponseThunk } from "../redux/thunks/streamResponse"; import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols"; @@ -247,12 +249,38 @@ function useSetup() { [defaultModel], ); - const lastEditToolApplyState = useAppSelector(selectLastEditToolApplyState); + const activeToolStreamId = useAppSelector( + (store) => store.session.activeToolStreamId, + ); + const applyStates = useAppSelector( + (store) => store.session.codeBlockApplyStates, + ); + const activeToolApplyState = useMemo(() => { + if (!activeToolStreamId) { + return undefined; + } + return applyStates.states.find( + (state) => state.streamId && state.streamId === activeToolStreamId, + ); + }, [applyStates, activeToolStreamId]); + useEffect(() => { - ideMessenger.post("showToast", ["info", "updated last apply state"]); - // dispatch(setToolCallOutput(output)); - // dispatch(acceptToolCall()); - }, [lastEditToolApplyState]); + if (activeToolApplyState?.status === "closed") { + const output: ContextItem = { + name: "Edit tool output", + content: "Completed edit", + description: "", + }; + dispatch(acceptToolCall()); + dispatch(setToolCallOutput([output])); + dispatch( + streamResponseAfterToolCall({ + toolCallId: activeToolApplyState.toolCallId!, + toolOutput: [output], + }), + ); + } + }, [activeToolApplyState?.status]); } export default useSetup; diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index b3cb2bb63..56263b0a1 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -2,32 +2,25 @@ import { getMarkdownLanguageTagForFile } from "core/util"; import { useMemo } from "react"; import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview"; import AcceptRejectAllButtons from "../../../components/StepContainer/AcceptRejectAllButtons"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { selectApplyStateByStreamId } from "../../../redux/slices/sessionSlice"; +import { useAppSelector } from "../../../redux/hooks"; type EditToolCallProps = { relativeFilePath: string; newContents: string; + toolCallId?: string; }; export function EditFile(props: EditToolCallProps) { const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.newContents ?? ""}\n\`\`\``; - const dispatch = useAppDispatch(); - const isStreaming = useAppSelector((state) => state.session.isStreaming); - const lastApplyToolStreamId = useAppSelector( - (state) => state.session.lastApplyToolStreamId, - ); - const streamId = useMemo(() => { - return lastApplyToolStreamId; - }, []); + const states = useAppSelector((store) => store.session.codeBlockApplyStates); - console.log("STREAM ID", streamId); - - const applyState = useAppSelector((state) => - selectApplyStateByStreamId(state, streamId), - ); + const applyState = useMemo(() => { + return states.states.find( + (state) => state.toolCallId && state.toolCallId === props.toolCallId, + ); + }, [states, props.toolCallId]); if (!props.relativeFilePath) { return null; @@ -39,11 +32,15 @@ export function EditFile(props: EditToolCallProps) { isRenderingInStepContainer={true} source={src} disableManualApply={true} - firstCodeblockStreamId={streamId} + singleCodeblockStreamId={applyState?.streamId} /> - + {isStreaming && applyState?.status === "streaming" && ( +
+ Generating... +
+ )} {!isStreaming && applyState?.status === "done" && ( -
+
{}} diff --git a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx index ee8726fae..55ed79e2a 100644 --- a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx +++ b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx @@ -26,6 +26,7 @@ function FunctionSpecificToolCallDiv({ ); case BuiltInToolNames.RunTerminalCommand: diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 544a8c401..bf22a1858 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -21,6 +21,7 @@ import { ToolCallDelta, ToolCallState, } from "core"; +import { BuiltInToolNames } from "core/tools/builtIn"; import { NEW_SESSION_TITLE } from "core/util/constants"; import { incrementalParseJson } from "core/util/incrementalParseJson"; import { renderChatMessage } from "core/util/messageContent"; @@ -54,7 +55,7 @@ type SessionState = { curIndex: number; }; newestCodeblockForInput: Record; - lastApplyToolStreamId?: string; + activeToolStreamId?: string; }; function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) { @@ -367,6 +368,19 @@ export const sessionSlice = createSlice({ ); } + if ( + toolCallDelta.id && + toolCallDelta.function?.name === + BuiltInToolNames.EditExistingFile + ) { + const streamId = uuidv4(); + state.codeBlockApplyStates.states.push({ + streamId, + toolCallId: toolCallDelta.id, + status: "streaming", + }); + state.activeToolStreamId = streamId; + } historyItem.toolCallState = toolCallDeltaToState(toolCallDelta); } state.history.push(historyItem); @@ -552,9 +566,7 @@ export const sessionSlice = createSlice({ state.history[state.history.length - 1].contextItems = contextItems; }, - setLastToolApplyStreamId: (state, { payload }: PayloadAction) => { - state.lastApplyToolStreamId = payload; - }, + updateCurCheckpoint: ( state, { payload }: PayloadAction<{ filepath: string; content: string }>, @@ -632,6 +644,7 @@ export const sessionSlice = createSlice({ toolCallState.status = "canceled"; }, acceptToolCall: (state) => { + state.activeToolStreamId = undefined; const toolCallState = findCurrentToolCall(state.history); if (!toolCallState) return; @@ -729,16 +742,6 @@ export const selectApplyStateByStreamId = createSelector( }, ); -export const selectLastEditToolApplyState = createSelector( - [ - (state: RootState) => state.session.codeBlockApplyStates.states, - (state: RootState) => state.session.lastApplyToolStreamId, - ], - (states, streamId) => { - return states.find((state) => state.streamId === streamId); - }, -); - export const { updateFileSymbols, setContextItemsAtIndex, @@ -776,7 +779,6 @@ export const { deleteSessionMetadata, setNewestCodeblocksForInput, cycleMode, - setLastToolApplyStreamId, } = sessionSlice.actions; export const { diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 190c25ccf..7ee80973f 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -3,7 +3,6 @@ import { ContextItem } from "core"; import { BuiltInToolNames } from "core/tools/builtIn"; import { EditToolArgs } from "core/tools/definitions/editFile"; import { resolveRelativePathInDir } from "core/util/ideUtils"; -import { v4 as uuidv4 } from "uuid"; import { IIdeMessenger } from "../../context/IdeMessenger"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; import { selectDefaultModel } from "../slices/configSlice"; @@ -11,7 +10,6 @@ import { acceptToolCall, cancelToolCall, setCalling, - setLastToolApplyStreamId, setToolCallOutput, } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; @@ -44,17 +42,19 @@ export const callTool = createAsyncThunk( if ( toolCallState.toolCall.function.name === BuiltInToolNames.EditExistingFile ) { - const newToolStreamId = uuidv4(); - dispatch(setLastToolApplyStreamId(newToolStreamId)); const args = JSON.parse( toolCallState.toolCall.function.arguments || "{}", ); try { + if (!state.session.activeToolStreamId) { + throw new Error("Invalid apply state"); + } await customGuiEditImpl( args, extra.ideMessenger, - newToolStreamId, + state.session.activeToolStreamId, defaultModel.title, + toolCallState.toolCallId, ); } catch (e) { errorMessage = "Failed to call edit tool"; @@ -85,7 +85,7 @@ export const callTool = createAsyncThunk( icon: "problems", name: "Tool Call Error", description: "Tool Call Failed", - content: `The tool call failed with the message:\n\n${errorMessage}\n\nPlease try something else or request further instructions.`, + content: `${toolCallState.toolCall.function.name} failed with the message:\n\n${errorMessage}\n\nPlease try something else or request further instructions.`, hidden: false, }, ], @@ -114,23 +114,19 @@ async function customGuiEditImpl( ideMessenger: IIdeMessenger, streamId: string, modelTitle: string, + toolCallId: string, ) { const firstUriMatch = await resolveRelativePathInDir( args.filepath, ideMessenger.ide, ); if (!firstUriMatch) { - return [ - { - name: "Edit failure", - description: `editing ${args.filepath}`, - content: `Failed to edit ${args.filepath}: does not exist`, - }, - ]; + throw new Error(`${args.filepath} does not exist`); } ideMessenger.post("applyToFile", { streamId, text: args.new_contents, curSelectedModelTitle: modelTitle, + toolCallId, }); } From 05c0d85942c853d806ccb866122e25e97e8d015d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 03:17:13 -0700 Subject: [PATCH 31/67] cleanup --- gui/src/components/mainInput/InputToolbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 27c034721..20e40d9a9 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -106,7 +106,7 @@ function InputToolbar(props: InputToolbarProps) { props.disabled || isEditModeAndNoCodeToEdit || toolCallState?.status === "generated" || - activeToolCallStreamId; + !!activeToolCallStreamId; const toolsSupported = defaultModel && modelSupportsTools(defaultModel); From 05c092b3022913c7a879f4b2c739783cab8e4108 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 03:39:51 -0700 Subject: [PATCH 32/67] remove useeffect --- gui/src/components/Layout.tsx | 15 ------- gui/src/hooks/useSetup.ts | 62 +++++++++++++++------------- gui/src/redux/slices/sessionSlice.ts | 4 +- gui/src/redux/thunks/callTool.ts | 2 +- 4 files changed, 36 insertions(+), 47 deletions(-) diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 5b70f2e62..0f52d3d0b 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -12,7 +12,6 @@ import { newSession, selectIsInEditMode, setMode, - updateApplyState, } from "../redux/slices/sessionSlice"; import { setShowDialog } from "../redux/slices/uiSlice"; import { exitEditMode } from "../redux/thunks"; @@ -125,20 +124,6 @@ const Layout = () => { [], ); - useWebviewListener( - "updateApplyState", - async (state) => { - // dispatch( - // updateCurCheckpoint({ - // filepath: state.filepath, - // content: state.fileContent, - // }), - // ); - dispatch(updateApplyState(state)); - }, - [], - ); - useWebviewListener( "openOnboardingCard", async () => { diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 914b96089..25b1a7fc0 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -1,4 +1,4 @@ -import { useCallback, useContext, useEffect, useMemo, useRef } from "react"; +import { useCallback, useContext, useEffect, useRef } from "react"; import { VSC_THEME_COLOR_VARS } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; @@ -20,6 +20,7 @@ import { addContextItemsAtIndex, setInactive, setToolCallOutput, + updateApplyState, } from "../redux/slices/sessionSlice"; import { setTTSActive } from "../redux/slices/uiSlice"; import { streamResponseAfterToolCall } from "../redux/thunks"; @@ -252,35 +253,38 @@ function useSetup() { const activeToolStreamId = useAppSelector( (store) => store.session.activeToolStreamId, ); - const applyStates = useAppSelector( - (store) => store.session.codeBlockApplyStates, + useWebviewListener( + "updateApplyState", + async (state) => { + // dispatch( + // updateCurCheckpoint({ + // filepath: state.filepath, + // content: state.fileContent, + // }), + // ); + dispatch(updateApplyState(state)); + if ( + activeToolStreamId && + state.streamId === activeToolStreamId[0] && + state.status === "closed" + ) { + const output: ContextItem = { + name: "Edit tool output", + content: "Completed edit", + description: "", + }; + dispatch(acceptToolCall()); + dispatch(setToolCallOutput([output])); + dispatch( + streamResponseAfterToolCall({ + toolCallId: activeToolStreamId[1], + toolOutput: [output], + }), + ); + } + }, + [activeToolStreamId], ); - const activeToolApplyState = useMemo(() => { - if (!activeToolStreamId) { - return undefined; - } - return applyStates.states.find( - (state) => state.streamId && state.streamId === activeToolStreamId, - ); - }, [applyStates, activeToolStreamId]); - - useEffect(() => { - if (activeToolApplyState?.status === "closed") { - const output: ContextItem = { - name: "Edit tool output", - content: "Completed edit", - description: "", - }; - dispatch(acceptToolCall()); - dispatch(setToolCallOutput([output])); - dispatch( - streamResponseAfterToolCall({ - toolCallId: activeToolApplyState.toolCallId!, - toolOutput: [output], - }), - ); - } - }, [activeToolApplyState?.status]); } export default useSetup; diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index bf22a1858..1813f9af2 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -55,7 +55,7 @@ type SessionState = { curIndex: number; }; newestCodeblockForInput: Record; - activeToolStreamId?: string; + activeToolStreamId?: [string, string]; }; function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) { @@ -379,7 +379,7 @@ export const sessionSlice = createSlice({ toolCallId: toolCallDelta.id, status: "streaming", }); - state.activeToolStreamId = streamId; + state.activeToolStreamId = [streamId, toolCallDelta.id]; } historyItem.toolCallState = toolCallDeltaToState(toolCallDelta); } diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 7ee80973f..b1cf85650 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -52,7 +52,7 @@ export const callTool = createAsyncThunk( await customGuiEditImpl( args, extra.ideMessenger, - state.session.activeToolStreamId, + state.session.activeToolStreamId[0], defaultModel.title, toolCallState.toolCallId, ); From c50fbbbb4f6d3afa1f6bad105b761ef647e964b1 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 03:48:49 -0700 Subject: [PATCH 33/67] tool call id for instant apply --- extensions/vscode/src/extension/VsCodeMessenger.ts | 1 + gui/src/pages/gui/ToolCallDiv/EditFile.tsx | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 98fe8489b..05f307c55 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -213,6 +213,7 @@ export class VsCodeMessenger { diffLines, instant, data.streamId, + data.toolCallId, ); } else { const prompt = `The following code was suggested as an edit:\n\`\`\`\n${data.text}\n\`\`\`\nPlease apply it to the previous code.`; diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index 56263b0a1..2ff34d489 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -34,11 +34,12 @@ export function EditFile(props: EditToolCallProps) { disableManualApply={true} singleCodeblockStreamId={applyState?.streamId} /> - {isStreaming && applyState?.status === "streaming" && ( + {/* TODO better indicator of generation at bottom */} + {/* {isStreaming && applyState?.status === "streaming" && (
Generating...
- )} + )} */} {!isStreaming && applyState?.status === "done" && (
Date: Fri, 4 Apr 2025 13:50:38 +0200 Subject: [PATCH 34/67] Fix Chat mode cycling on VS Code Signed-off-by: Fred Bricon --- gui/src/redux/slices/sessionSlice.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 5aa714acc..79c5929a5 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -642,8 +642,8 @@ export const sessionSlice = createSlice({ }, cycleMode: (state, action: PayloadAction<{ isJetBrains: boolean }>) => { const modes = action.payload.isJetBrains - ? ["chat", "edit", "agent"] - : ["chat", "agent"]; + ? ["chat", "agent"] + : ["chat", "edit", "agent"]; const currentIndex = modes.indexOf(state.mode); const nextIndex = (currentIndex + 1) % modes.length; state.mode = modes[nextIndex] as MessageModes; From 6eddab18c5d6d442086eee4550bd838d22a781f0 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 08:38:32 -0700 Subject: [PATCH 35/67] code cleanup --- .../ConversationStarterCards.tsx | 4 +- .../components/mainInput/ContinueInputBox.tsx | 2 +- .../mainInput/TipTapEditor/TipTapEditor.tsx | 4 +- ...eview.tsx => ExpandableToolbarPreview.tsx} | 55 +++++++++--- .../TipTapEditor/components/index.ts | 2 +- .../extensions/CodeBlock/CodeBlock.tsx | 2 +- .../extensions/CodeBlock/CodeBlockPreview.tsx | 34 ++----- .../extensions/Prompt/PromptBlock.ts | 4 +- .../extensions/Prompt/PromptBlockPreview.tsx | 25 ++---- .../useMainEditorWebviewListeners.ts | 6 +- .../TipTapEditor/utils/getSuggestion.ts | 4 +- .../utils/resolveEditorContent.ts | 88 +++++++++---------- gui/src/redux/slices/sessionSlice.ts | 11 +-- 13 files changed, 121 insertions(+), 120 deletions(-) rename gui/src/components/mainInput/TipTapEditor/components/{ExpandablePreview.tsx => ExpandableToolbarPreview.tsx} (75%) diff --git a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx index 6d29a1df6..a680fa201 100644 --- a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx +++ b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx @@ -3,7 +3,7 @@ import { useState } from "react"; import { useBookmarkedSlashCommands } from "../../hooks/useBookmarkedSlashCommands"; import { MAIN_EDITOR_INPUT_ID } from "../../pages/gui/Chat"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { setNewestCodeblocksForInput } from "../../redux/slices/sessionSlice"; +import { setNewestToolbarPreviewForInput } from "../../redux/slices/sessionSlice"; import { useMainEditor } from "../mainInput/TipTapEditor"; import { ConversationStarterCard } from "./ConversationStarterCard"; @@ -27,7 +27,7 @@ export function ConversationStarterCards() { function onClick(command: SlashCommandDescription) { dispatch( - setNewestCodeblocksForInput({ + setNewestToolbarPreviewForInput({ inputId: MAIN_EDITOR_INPUT_ID, contextItemId: command.name, }), diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index 30ddd30f2..14777acb6 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -8,7 +8,7 @@ import { selectSlashCommandComboBoxInputs } from "../../redux/selectors"; import ContextItemsPeek from "./belowMainInput/ContextItemsPeek"; import { ToolbarOptions } from "./InputToolbar"; import { Lump } from "./Lump"; -import TipTapEditor from "./TipTapEditor/TipTapEditor"; +import { TipTapEditor } from "./TipTapEditor"; interface ContinueInputBoxProps { isEditMode?: boolean; diff --git a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx index 2c340c843..3e52cfe8f 100644 --- a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx @@ -38,7 +38,7 @@ export interface TipTapEditorProps { export const TIPPY_DIV_ID = "tippy-js-div"; -function TipTapEditor(props: TipTapEditorProps) { +export function TipTapEditor(props: TipTapEditorProps) { const dispatch = useAppDispatch(); const mainEditorContext = useMainEditor(); @@ -275,5 +275,3 @@ function TipTapEditor(props: TipTapEditorProps) { ); } - -export default TipTapEditor; diff --git a/gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx similarity index 75% rename from gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx rename to gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx index a6b886b05..9dd68df28 100644 --- a/gui/src/components/mainInput/TipTapEditor/components/ExpandablePreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx @@ -4,9 +4,16 @@ import { XMarkIcon, } from "@heroicons/react/24/outline"; import { EyeIcon } from "@heroicons/react/24/solid"; -import { useEffect, useRef, useState } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import styled from "styled-components"; -import { defaultBorderRadius, lightGray, vscEditorBackground } from "../../.."; +import { + defaultBorderRadius, + lightGray, + vscBadgeBackground, + vscCommandCenterInactiveBorder, + vscEditorBackground, +} from "../../.."; +import { useAppSelector } from "../../../../redux/hooks"; import { getFontSize } from "../../../../util"; import HeaderButtonWithToolTip from "../../../gui/HeaderButtonWithToolTip"; @@ -58,14 +65,18 @@ const ChevronContainer = styled.div` `; /** - * Props for the ExpandablePreview component + * Props for the ExpandableToolbarPreview component */ -interface ExpandablePreviewProps { +interface ExpandableToolbarPreviewProps { /** Title to display in the header */ title: string; /** Optional icon to display next to the title */ icon?: React.ReactNode; - /** Whether the preview is initially hidden */ + /** ID of the input this preview is associated with (for toolbar hiding logic) */ + inputId?: string; + /** ID of the item being displayed (for toolbar hiding logic) */ + itemId?: string; + /** Whether the preview is initially hidden (overridden if inputId and itemId are provided) */ initiallyHidden?: boolean; /** Callback when the delete button is clicked */ onDelete?: () => void; @@ -73,6 +84,8 @@ interface ExpandablePreviewProps { onTitleClick?: (e: React.MouseEvent) => void; /** Border color of the preview */ borderColor?: string; + /* Whether the preview is selected */ + isSelected?: boolean; /** Content to display in the preview */ children: React.ReactNode; } @@ -80,16 +93,35 @@ interface ExpandablePreviewProps { /** * A generalized expandable preview component for displaying content with a header and expandable body */ -export function ExpandablePreview(props: ExpandablePreviewProps) { - const [hidden, setHidden] = useState(props.initiallyHidden ?? false); +export function ExpandableToolbarPreview(props: ExpandableToolbarPreviewProps) { + // Get toolbar visibility state from Redux if inputId and itemId are provided + const newestCodeblockForInputId = useAppSelector((store) => + props.inputId + ? store.session.newestToolbarPreviewForInput[props.inputId] + : undefined, + ); + + const calculatedInitiallyHidden = useMemo(() => { + if (props.inputId && props.itemId) { + return newestCodeblockForInputId !== props.itemId; + } + return props.initiallyHidden ?? false; + }, [ + newestCodeblockForInputId, + props.inputId, + props.itemId, + props.initiallyHidden, + ]); + + const [hidden, setHidden] = useState(calculatedInitiallyHidden); const [isExpanded, setIsExpanded] = useState(false); const contentRef = useRef(null); const [contentDims, setContentDims] = useState({ width: 0, height: 0 }); useEffect(() => { - setHidden(props.initiallyHidden ?? false); - }, [props.initiallyHidden]); + setHidden(calculatedInitiallyHidden); + }, [calculatedInitiallyHidden]); useEffect(() => { const resizeObserver = new ResizeObserver(() => { @@ -111,10 +143,11 @@ export function ExpandablePreview(props: ExpandablePreviewProps) { return ( - {/* Keep existing header code */}
{ const item: ContextItemWithId = node.attrs.item; const inputId = node.attrs.inputId; - const isFirstContextItem = false; // TODO: fix this, decided not worth the insane renders for now const ideMessenger = useContext(IdeMessengerContext); - const newestCodeblockForInputId = useAppSelector( - (store) => store.session.newestCodeblockForInput[inputId], - ); - - const initiallyHidden = useMemo(() => { - return newestCodeblockForInputId !== item.id.itemId; - }, [newestCodeblockForInputId, item.id.itemId]); - - console.log({ - newestCodeblockForInputId, - id: item.id.itemId, - initiallyHidden, - }); - const content = useMemo(() => { return dedent`${item.content}`; }, [item.content]); @@ -71,26 +55,22 @@ export const CodeBlockPreview = ({ } }; - const borderColor = isFirstContextItem - ? "#d0d" - : selected - ? vscBadgeBackground - : undefined; - return ( - } - initiallyHidden={initiallyHidden} + inputId={inputId} + itemId={item.id.itemId} onDelete={() => deleteNode()} - borderColor={borderColor} + borderColor={selected ? vscBadgeBackground : undefined} onTitleClick={handleTitleClick} > - + ); }; diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts index 287a79e4a..5cbe10767 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts @@ -30,7 +30,7 @@ declare module "@tiptap/core" { } /** - * Extension for adding prompt blocks to the Tiptap editor + * Extension for adding prompt blocks to the TipTap editor */ export const PromptBlock = Node.create({ name: "prompt-block", @@ -85,6 +85,8 @@ export const PromptBlock = Node.create({ }); }, + // TODO: This could probably be greatly simplified with something along the lines of + // `editor.commands.deleteNode(this.name)`, but was unable to get it working clearPrompt: () => ({ state, commands }) => { diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx index 002740692..899cbdd37 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx @@ -1,10 +1,8 @@ import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline"; import { NodeViewProps } from "@tiptap/react"; -import { useContext, useMemo } from "react"; -import { vscBadgeBackground } from "../../../.."; +import { useContext } from "react"; import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; -import { useAppSelector } from "../../../../../redux/hooks"; -import { ExpandablePreview } from "../../components/ExpandablePreview"; +import { ExpandableToolbarPreview } from "../../components/ExpandableToolbarPreview"; import { NodeViewWrapper } from "../../components/NodeViewWrapper"; import { PromptBlockAttributes } from "./PromptBlock"; @@ -20,14 +18,6 @@ export const PromptBlockPreview = ({ const ideMessenger = useContext(IdeMessengerContext); - const newestCodeblockForInputId = useAppSelector( - (store) => store.session.newestCodeblockForInput[inputId], - ); - - const initiallyHidden = useMemo(() => { - return newestCodeblockForInputId !== item.id.itemId; - }, [newestCodeblockForInputId, item.id.itemId]); - const handleTitleClick = (e: React.MouseEvent) => { e.stopPropagation(); ideMessenger.post("showVirtualFile", { @@ -40,22 +30,21 @@ export const PromptBlockPreview = ({ editor.commands.clearSlashCommand(); }; - const borderColor = selected ? vscBadgeBackground : undefined; - return ( - } - initiallyHidden={initiallyHidden} + inputId={inputId} + itemId={item.id.itemId} onDelete={handleDelete} - borderColor={borderColor} onTitleClick={handleTitleClick} >
{item.content}
-
+
); }; diff --git a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts index bedb3df50..69feed370 100644 --- a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts +++ b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts @@ -5,7 +5,7 @@ import { MutableRefObject } from "react"; import { useWebviewListener } from "../../../hooks/useWebviewListener"; import { clearCodeToEdit, - setNewestCodeblocksForInput, + setNewestToolbarPreviewForInput, } from "../../../redux/slices/sessionSlice"; import { AppDispatch } from "../../../redux/store"; import { loadSession, saveCurrentSession } from "../../../redux/thunks/session"; @@ -132,10 +132,8 @@ export function useMainEditorWebviewListeners({ }) .run(); - console.log("id: ", contextItem.id.itemId); - dispatch( - setNewestCodeblocksForInput({ + setNewestToolbarPreviewForInput({ inputId, contextItemId: contextItem.id.itemId, }), diff --git a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts index b553b6d9a..399701e9d 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts @@ -7,7 +7,7 @@ import { import { MutableRefObject } from "react"; import tippy from "tippy.js"; import { IIdeMessenger } from "../../../../context/IdeMessenger"; -import { setNewestCodeblocksForInput } from "../../../../redux/slices/sessionSlice"; +import { setNewestToolbarPreviewForInput } from "../../../../redux/slices/sessionSlice"; import { AppDispatch } from "../../../../redux/store"; import AtMentionDropdown from "../../AtMentionDropdown"; import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "../../types"; @@ -224,7 +224,7 @@ export function getSlashCommandDropdownOptions( content: provider.content, action: () => { dispatch( - setNewestCodeblocksForInput({ + setNewestToolbarPreviewForInput({ inputId, contextItemId: provider.title, }), diff --git a/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts index 34962eed4..63ebad23c 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/resolveEditorContent.ts @@ -50,6 +50,50 @@ type ResolveEditorContentOutput = [ ), ]; +/** + * This function converts the input from the editor to a string, resolving any context items + * Context items are appended to the top of the prompt and then referenced within the input + */ +export async function resolveEditorContent({ + editorState, + modifiers, + ideMessenger, + defaultContextProviders, + availableSlashCommands, + selectedModelTitle, + dispatch, +}: ResolveEditorContentInput): Promise { + const { parts, contextItemAttrs, selectedCode, slashCommandName } = + processEditorContent(editorState); + + const slashCommandWithInput = processSlashCommand( + slashCommandName, + availableSlashCommands, + parts, + ); + + const shouldGatherContext = modifiers.useCodebase || slashCommandWithInput; + if (shouldGatherContext) { + dispatch(setIsGatheringContext(true)); + } + + const contextItems = await gatherContextItems({ + contextItemAttrs, + modifiers, + ideMessenger, + defaultContextProviders, + parts, + selectedCode, + selectedModelTitle, + }); + + if (shouldGatherContext) { + dispatch(setIsGatheringContext(false)); + } + + return [contextItems, selectedCode, parts, slashCommandWithInput]; +} + /** * Processes editor content and extracts parts, context items, code, and slash commands */ @@ -295,47 +339,3 @@ function resolveParagraph( return [text, contextItems, slashCommand]; } - -/** - * This function converts the input from the editor to a string, resolving any context items - * Context items are appended to the top of the prompt and then referenced within the input - */ -export async function resolveEditorContent({ - editorState, - modifiers, - ideMessenger, - defaultContextProviders, - availableSlashCommands, - selectedModelTitle, - dispatch, -}: ResolveEditorContentInput): Promise { - const { parts, contextItemAttrs, selectedCode, slashCommandName } = - processEditorContent(editorState); - - const slashCommandWithInput = processSlashCommand( - slashCommandName, - availableSlashCommands, - parts, - ); - - const shouldGatherContext = modifiers.useCodebase || slashCommandWithInput; - if (shouldGatherContext) { - dispatch(setIsGatheringContext(true)); - } - - const contextItems = await gatherContextItems({ - contextItemAttrs, - modifiers, - ideMessenger, - defaultContextProviders, - parts, - selectedCode, - selectedModelTitle, - }); - - if (shouldGatherContext) { - dispatch(setIsGatheringContext(false)); - } - - return [contextItems, selectedCode, parts, slashCommandWithInput]; -} diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 5aa714acc..f7c9756d2 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -53,7 +53,7 @@ type SessionState = { states: ApplyState[]; curIndex: number; }; - newestCodeblockForInput: Record; + newestToolbarPreviewForInput: Record; }; function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) { @@ -91,7 +91,7 @@ const initialState: SessionState = { curIndex: 0, }, lastSessionId: undefined, - newestCodeblockForInput: {}, + newestToolbarPreviewForInput: {}, }; export const sessionSlice = createSlice({ @@ -648,7 +648,7 @@ export const sessionSlice = createSlice({ const nextIndex = (currentIndex + 1) % modes.length; state.mode = modes[nextIndex] as MessageModes; }, - setNewestCodeblocksForInput: ( + setNewestToolbarPreviewForInput: ( state, { payload, @@ -657,7 +657,8 @@ export const sessionSlice = createSlice({ contextItemId: string; }>, ) => { - state.newestCodeblockForInput[payload.inputId] = payload.contextItemId; + state.newestToolbarPreviewForInput[payload.inputId] = + payload.contextItemId; }, }, selectors: { @@ -758,7 +759,7 @@ export const { addSessionMetadata, updateSessionMetadata, deleteSessionMetadata, - setNewestCodeblocksForInput, + setNewestToolbarPreviewForInput, cycleMode, } = sessionSlice.actions; From 709eb6361f93e9f9257e9b165b377e72f2ed0edd Mon Sep 17 00:00:00 2001 From: Ty Dunn Date: Fri, 4 Apr 2025 12:23:43 -0700 Subject: [PATCH 36/67] replace actions with agent in root README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fc07289d7..dffa26b4f 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,11 @@ ![edit](docs/static/img/edit.gif) -## Actions +## Agent -[Actions](https://continue.dev/docs/actions/how-to-use-it) are shortcuts for common use cases +[Agent](https://continue.dev/docs/agent/how-to-use-it) enables you to make more substantial changes to your codebase -![actions](docs/static/img/actions.gif) +![agent](docs/static/img/agent.gif)
From 6e11b246bc0d9f1b8f36c68fa60e635cf8c7b964 Mon Sep 17 00:00:00 2001 From: Ty Dunn Date: Fri, 4 Apr 2025 12:26:10 -0700 Subject: [PATCH 37/67] actions --> agent in vs code readme --- extensions/vscode/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/README.md b/extensions/vscode/README.md index 9470b2d5e..1bc087276 100644 --- a/extensions/vscode/README.md +++ b/extensions/vscode/README.md @@ -44,11 +44,11 @@ ![edit](docs/static/img/edit.gif) -## Actions +## Agent -[Actions](https://continue.dev/docs/actions/how-to-use-it) are shortcuts for common use cases. +[Agent](https://continue.dev/docs/agent/how-to-use-it) enables you to make more substantial changes to your codebase -![actions](docs/static/img/actions.gif) +![agent](docs/static/img/agent.gif)
From a835cfa40c726042c550c7f133ada60881e3f798 Mon Sep 17 00:00:00 2001 From: Ty Dunn Date: Fri, 4 Apr 2025 12:27:12 -0700 Subject: [PATCH 38/67] actions --> agent in JetBrains readme --- extensions/intellij/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/intellij/README.md b/extensions/intellij/README.md index dccf4a7f1..45a1f05f0 100644 --- a/extensions/intellij/README.md +++ b/extensions/intellij/README.md @@ -28,11 +28,11 @@ To enable it, simply click the "Continue" button in the status bar at the bottom Highlight a block of code, describe your code changes, and a diff will be streamed inline to your file which you can accept or reject. -## Actions +## Agent -[Actions](https://continue.dev/docs/actions/how-to-use-it) are shortcuts for common use cases. +[Agent](https://continue.dev/docs/agent/how-to-use-it) enables you to make more substantial changes to your codebase -For example, you might want to review code, write tests, or add a docstring. +Agent equips the Chat model with the tools needed to handle a wide range of coding tasks, allowing the model to make decisions and save you the work of manually finding context and performing actions.
From 36289b25802816d6b37ba930ecc083ca4f3e4c66 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 19:54:10 +0000 Subject: [PATCH 39/67] build(deps-dev): bump vite from 4.5.9 to 4.5.12 in /extensions/vscode Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.5.9 to 4.5.12. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v4.5.12/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v4.5.12/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 4.5.12 dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- extensions/vscode/package-lock.json | 12 ++++++------ extensions/vscode/package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index bef92c30c..c03168bf9 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.18", + "version": "1.1.20", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.18", + "version": "1.1.20", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", @@ -88,7 +88,7 @@ "ovsx": "^0.8.3", "rimraf": "^5.0.5", "typescript": "^5.6.3", - "vite": "^4.3.9", + "vite": "^4.5.12", "vsce": "^2.15.0", "vscode-extension-tester": "^8.10.0" }, @@ -13322,9 +13322,9 @@ } }, "node_modules/vite": { - "version": "4.5.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.9.tgz", - "integrity": "sha512-qK9W4xjgD3gXbC0NmdNFFnVFLMWSNiR3swj957yutwzzN16xF/E7nmtAyp1rT9hviDroQANjE4HK3H4WqWdFtw==", + "version": "4.5.12", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.12.tgz", + "integrity": "sha512-qrMwavANtSz91nDy3zEiUHMtL09x0mniQsSMvDkNxuCBM1W5vriJ22hEmwTth6DhLSWsZnHBT0yHFAQXt6efGA==", "dev": true, "license": "MIT", "dependencies": { diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 15599a1c0..4167b8dcc 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -625,7 +625,7 @@ "ovsx": "^0.8.3", "rimraf": "^5.0.5", "typescript": "^5.6.3", - "vite": "^4.3.9", + "vite": "^4.5.12", "vsce": "^2.15.0", "vscode-extension-tester": "^8.10.0" }, From e88485348c8b53e9f19d1f9fc0c8b33dd5266df7 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 12:57:03 -0700 Subject: [PATCH 40/67] feat: dallin's feedback --- .continue/rules/use-tailwind-not-styled.md | 3 - .../ConversationStarterCards.tsx | 11 +- .../components/mainInput/Lump/LumpContext.tsx | 51 ++++ gui/src/components/mainInput/Lump/index.tsx | 103 ++++---- .../Lump/sections/ExploreBlocksButton.tsx | 5 +- .../Lump/sections/PromptsSection.tsx | 51 +++- .../mainInput/Lump/sections/RulesSection.tsx | 16 +- .../Lump/sections/docs/DocsIndexingStatus.tsx | 3 + .../Lump/sections/docs/DocsSection.tsx | 1 - .../components/ExpandableToolbarPreview.tsx | 21 +- .../components/NodeViewWrapper.tsx | 2 +- .../extensions/Prompt/PromptBlock.ts | 35 ++- .../extensions/Prompt/PromptBlockPreview.tsx | 3 +- .../TipTapEditor/extensions/SlashCommand.ts | 243 +----------------- .../useMainEditorWebviewListeners.ts | 10 +- .../TipTapEditor/utils/getSuggestion.ts | 12 +- 16 files changed, 227 insertions(+), 343 deletions(-) delete mode 100644 .continue/rules/use-tailwind-not-styled.md create mode 100644 gui/src/components/mainInput/Lump/LumpContext.tsx diff --git a/.continue/rules/use-tailwind-not-styled.md b/.continue/rules/use-tailwind-not-styled.md deleted file mode 100644 index 8a3ec0b3d..000000000 --- a/.continue/rules/use-tailwind-not-styled.md +++ /dev/null @@ -1,3 +0,0 @@ -Always use Tailwind classes, not styled components. - -If a component is using styled components, it should be converted to use Tailwind classes. diff --git a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx index a680fa201..776c0721b 100644 --- a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx +++ b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx @@ -1,9 +1,7 @@ import { SlashCommandDescription } from "core"; import { useState } from "react"; import { useBookmarkedSlashCommands } from "../../hooks/useBookmarkedSlashCommands"; -import { MAIN_EDITOR_INPUT_ID } from "../../pages/gui/Chat"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { setNewestToolbarPreviewForInput } from "../../redux/slices/sessionSlice"; import { useMainEditor } from "../mainInput/TipTapEditor"; import { ConversationStarterCard } from "./ConversationStarterCard"; @@ -26,14 +24,7 @@ export function ConversationStarterCards() { ); function onClick(command: SlashCommandDescription) { - dispatch( - setNewestToolbarPreviewForInput({ - inputId: MAIN_EDITOR_INPUT_ID, - contextItemId: command.name, - }), - ); - - mainEditor?.commands.insertSlashCommand(command); + mainEditor?.commands.insertPrompt(command); } if (bookmarkedSlashCommands.length === 0) { diff --git a/gui/src/components/mainInput/Lump/LumpContext.tsx b/gui/src/components/mainInput/Lump/LumpContext.tsx new file mode 100644 index 000000000..4e93777ea --- /dev/null +++ b/gui/src/components/mainInput/Lump/LumpContext.tsx @@ -0,0 +1,51 @@ +/** + * Provides context for controlling the Lump component's visibility state + */ +import { createContext, ReactNode, useContext } from "react"; + +interface LumpContextType { + isLumpVisible: boolean; + selectedSection: string | null; + hideLump: () => void; + setSelectedSection: (section: string | null) => void; +} + +const LumpContext = createContext(undefined); + +interface LumpProviderProps { + children: ReactNode; + isLumpVisible: boolean; + selectedSection: string | null; + hideLump: () => void; + setSelectedSection: (section: string | null) => void; +} + +/** + * Provider component that makes Lump state available to any child component + */ +export function LumpProvider({ + children, + isLumpVisible, + selectedSection, + hideLump, + setSelectedSection, +}: LumpProviderProps) { + return ( + + {children} + + ); +} + +/** + * Hook that lets any component access the Lump context + */ +export function useLump() { + const context = useContext(LumpContext); + if (context === undefined) { + throw new Error("useLump must be used within a LumpProvider"); + } + return context; +} diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index 57276ad56..df1875c86 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useCallback, useState } from "react"; import styled from "styled-components"; import { defaultBorderRadius, @@ -6,6 +6,7 @@ import { vscInputBackground, } from "../.."; import { useAppSelector } from "../../../redux/hooks"; +import { LumpProvider } from "./LumpContext"; import { LumpToolbar } from "./LumpToolbar"; import { SelectedSection } from "./sections/SelectedSection"; @@ -30,64 +31,78 @@ const ContentDiv = styled.div<{ hasSection: boolean; isVisible: boolean }>` overflow-y: auto; `; +/** + * Main component that displays the toolbar and selected content section + */ export function Lump() { const [selectedSection, setSelectedSection] = useState(null); const [displayedSection, setDisplayedSection] = useState(null); const [isVisible, setIsVisible] = useState(false); const isStreaming = useAppSelector((state) => state.session.isStreaming); - useEffect(() => { - if (!selectedSection) { - return; - } - const handleKeyDown = (event: KeyboardEvent) => { - if (event.key === "Escape") { + // Handle keyboard escape + const handleKeyDown = useCallback( + (event: KeyboardEvent) => { + if (event.key === "Escape" && selectedSection) { setSelectedSection(null); } - }; - document.addEventListener("keydown", handleKeyDown); - return () => { - document.removeEventListener("keydown", handleKeyDown); - }; - }, [selectedSection]); + }, + [selectedSection], + ); - useEffect(() => { - if (isStreaming) { - setSelectedSection(null); - } - }, [isStreaming]); + // Function to hide the lump + const hideLump = useCallback(() => { + setSelectedSection(null); + }, []); - useEffect(() => { - if (selectedSection) { + // Reset when streaming starts + if (isStreaming && selectedSection) { + setSelectedSection(null); + } + + // Update displayedSection and visibility when selectedSection changes + if (selectedSection) { + if (displayedSection !== selectedSection || !isVisible) { setDisplayedSection(selectedSection); setIsVisible(true); - } else { - setIsVisible(false); - const timeout = setTimeout(() => { - setDisplayedSection(null); - }, 300); - return () => { - clearTimeout(timeout); - }; } - }, [selectedSection]); + } else if (isVisible) { + setIsVisible(false); + setTimeout(() => { + setDisplayedSection(null); + }, 300); + } + + // Set up keyboard listener + if (selectedSection) { + document.addEventListener("keydown", handleKeyDown); + } else { + document.removeEventListener("keydown", handleKeyDown); + } return ( - -
- + + +
+ - - - -
-
+ + + +
+
+ ); } diff --git a/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx b/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx index ad2212ac7..6885870df 100644 --- a/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx +++ b/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx @@ -50,7 +50,7 @@ export function ExploreBlocksButton(props: { blockType: string }) { return (
- {text} + + {text}
); diff --git a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx index 6ad536809..1ff27c16c 100644 --- a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx @@ -3,44 +3,70 @@ import { PencilIcon, } from "@heroicons/react/24/outline"; import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid"; +import { SlashCommandDescription } from "core"; import { useBookmarkedSlashCommands } from "../../../../hooks/useBookmarkedSlashCommands"; import { useAppSelector } from "../../../../redux/hooks"; import { fontSize } from "../../../../util"; +import { useMainEditor } from "../../TipTapEditor"; +import { useLump } from "../LumpContext"; import { ExploreBlocksButton } from "./ExploreBlocksButton"; interface PromptRowProps { - command: string; - description: string; + prompt: SlashCommandDescription; isBookmarked: boolean; setIsBookmarked: (isBookmarked: boolean) => void; onEdit?: () => void; } +/** + * Displays a single prompt row with bookmark and edit controls + */ function PromptRow({ - command, - description, + prompt, isBookmarked, setIsBookmarked, onEdit, }: PromptRowProps) { + const { mainEditor } = useMainEditor(); + const { hideLump } = useLump(); + + const handlePromptClick = (e: React.MouseEvent) => { + e.stopPropagation(); + mainEditor?.commands.insertPrompt(prompt); + hideLump(); + }; + + const handleBookmarkClick = (e: React.MouseEvent) => { + e.stopPropagation(); + setIsBookmarked(!isBookmarked); + }; + + const handleEditClick = (e: React.MouseEvent) => { + e.stopPropagation(); + if (onEdit) { + onEdit(); + } + }; + return (
- {command} - {description} + {prompt.name} + {prompt.description}
setIsBookmarked(!isBookmarked)} + onClick={handleBookmarkClick} className="cursor-pointer pt-0.5 text-gray-400 hover:brightness-125" > {isBookmarked ? ( @@ -54,8 +80,12 @@ function PromptRow({ ); } +/** + * Section that displays all available prompts with bookmarking functionality + */ export function PromptsSection() { const { isCommandBookmarked, toggleBookmark } = useBookmarkedSlashCommands(); + const slashCommands = useAppSelector( (state) => state.config.config.slashCommands ?? [], ); @@ -78,8 +108,7 @@ export function PromptsSection() { {sortedCommands.map((prompt) => ( toggleBookmark(prompt)} onEdit={() => handleEdit(prompt)} diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index 4cb7b0051..43c338b49 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -13,6 +13,7 @@ import { import { RootState } from "../../../../redux/store"; import { fontSize } from "../../../../util"; import HeaderButtonWithToolTip from "../../../gui/HeaderButtonWithToolTip"; +import { useLump } from "../LumpContext"; import { ExploreBlocksButton } from "./ExploreBlocksButton"; interface RuleCardProps { @@ -82,6 +83,7 @@ const RuleCard: React.FC = ({ index, rule, onClick, title }) => { export function RulesSection() { const ideMessenger = useContext(IdeMessengerContext); const { selectedProfile } = useAuth(); + const { hideLump } = useLump(); const rules = useSelector( (state: RootState) => state.config.config.rules ?? [], @@ -97,11 +99,13 @@ export function RulesSection() { })); }, [rules]); - const openUrl = (path: string) => + const openUrl = (path: string) => { ideMessenger.request("controlPlane/openUrl", { path, orgSlug: undefined, }); + hideLump(); + }; return (
@@ -113,11 +117,12 @@ export function RulesSection() { key={index} index={index} rule={rule.unrolledRule} - onClick={() => + onClick={() => { ideMessenger.post("config/openProfile", { profileId: undefined, - }) - } + }); + hideLump(); + }} title="Locally Defined Rule" /> ); @@ -158,6 +163,3 @@ export function RulesSection() {
); } -function useTypedDispatch() { - throw new Error("Function not implemented."); -} diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx index 777d30e4e..9189a794c 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx +++ b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx @@ -12,6 +12,7 @@ import { import { fontSize } from "../../../../../util"; import ConfirmationDialog from "../../../../dialogs/ConfirmationDialog"; import EditBlockButton from "../../EditBlockButton"; +import { useLump } from "../../LumpContext"; import { StatusIndicator } from "./StatusIndicator"; interface IndexingStatusViewerProps { docConfig: SiteIndexingConfig; @@ -24,6 +25,7 @@ function DocsIndexingStatus({ }: IndexingStatusViewerProps) { const ideMessenger = useContext(IdeMessengerContext); const dispatch = useAppDispatch(); + const { hideLump } = useLump(); const status = useAppSelector( (store) => store.indexing.indexing.statuses[docConfig.startUrl], @@ -87,6 +89,7 @@ function DocsIndexingStatus({ onClick={() => { if (status?.url) { ideMessenger.post("openUrl", status.url); + hideLump(); } }} > diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsSection.tsx b/gui/src/components/mainInput/Lump/sections/docs/DocsSection.tsx index 27796aecb..cbe7e6e72 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/docs/DocsSection.tsx @@ -14,7 +14,6 @@ function DocsIndexingStatuses() { (store) => store.indexing.indexing.statuses, ); const { selectedProfile } = useAuth(); - const mergedDocs = useMemo(() => { const parsed = selectedProfile?.rawYaml ? parseConfigYaml(selectedProfile?.rawYaml ?? "") diff --git a/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx index 9dd68df28..16e959ebb 100644 --- a/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/components/ExpandableToolbarPreview.tsx @@ -102,6 +102,12 @@ export function ExpandableToolbarPreview(props: ExpandableToolbarPreviewProps) { ); const calculatedInitiallyHidden = useMemo(() => { + // If initiallyHidden is explicitly set to false, always start visible + if (props.initiallyHidden === false) { + return false; + } + + // Otherwise, use the inputId/itemId logic if (props.inputId && props.itemId) { return newestCodeblockForInputId !== props.itemId; } @@ -116,13 +122,19 @@ export function ExpandableToolbarPreview(props: ExpandableToolbarPreviewProps) { const [hidden, setHidden] = useState(calculatedInitiallyHidden); const [isExpanded, setIsExpanded] = useState(false); + // Track if user has manually toggled visibility + const [userToggled, setUserToggled] = useState(false); + const contentRef = useRef(null); const [contentDims, setContentDims] = useState({ width: 0, height: 0 }); useEffect(() => { - setHidden(calculatedInitiallyHidden); - }, [calculatedInitiallyHidden]); - + // Only update hidden state from props if user hasn't manually toggled + // or if initiallyHidden isn't explicitly set to false + if (!userToggled || props.initiallyHidden !== false) { + setHidden(calculatedInitiallyHidden); + } + }, [calculatedInitiallyHidden, userToggled, props.initiallyHidden]); useEffect(() => { const resizeObserver = new ResizeObserver(() => { setContentDims({ @@ -146,7 +158,7 @@ export function ExpandableToolbarPreview(props: ExpandableToolbarPreviewProps) { borderColor={ props.isSelected ? vscBadgeBackground : vscCommandCenterInactiveBorder } - className="find-widget-skip" + className="find-widget-skip !my-0" >
{ + setUserToggled(true); setHidden(!hidden); }} > diff --git a/gui/src/components/mainInput/TipTapEditor/components/NodeViewWrapper.tsx b/gui/src/components/mainInput/TipTapEditor/components/NodeViewWrapper.tsx index 1dc7ccd51..ac1a67836 100644 --- a/gui/src/components/mainInput/TipTapEditor/components/NodeViewWrapper.tsx +++ b/gui/src/components/mainInput/TipTapEditor/components/NodeViewWrapper.tsx @@ -16,7 +16,7 @@ export const NodeViewWrapper: React.FC = ({ const nodeViewWrapperTag: TiptapNodeViewWrapperProps["as"] = "p"; return ( - + {children} ); diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts index 5cbe10767..b35a637ea 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlock.ts @@ -1,7 +1,8 @@ import { mergeAttributes, Node } from "@tiptap/core"; import { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { ReactNodeViewRenderer } from "@tiptap/react"; -import { ContextItemWithId } from "core"; +import { ContextItemWithId, SlashCommandDescription } from "core"; +import { MAIN_EDITOR_INPUT_ID } from "../../../../../pages/gui/Chat"; import { PromptBlockPreview } from "./PromptBlockPreview"; export interface PromptBlockOptions { @@ -19,7 +20,7 @@ declare module "@tiptap/core" { /** * Insert a prompt block into the editor */ - insertPrompt: (item: ContextItemWithId, inputId: string) => ReturnType; + insertPrompt: (item: SlashCommandDescription) => ReturnType; /** * Clear all prompt blocks from the editor @@ -35,6 +36,7 @@ declare module "@tiptap/core" { export const PromptBlock = Node.create({ name: "prompt-block", group: "block", + content: "inline*", addOptions() { return { @@ -74,15 +76,28 @@ export const PromptBlock = Node.create({ addCommands() { return { insertPrompt: - (item: ContextItemWithId, inputId: string) => - ({ commands }) => { - return commands.insertContent({ - type: this.name, - attrs: { - item, - inputId, + (prompt: SlashCommandDescription) => + ({ chain }) => { + const item: ContextItemWithId = { + content: prompt.prompt ?? "", + name: prompt.name, + description: prompt.description, + id: { + providerTitle: "prompt", + itemId: prompt.name, }, - }); + }; + + return chain() + .insertContentAt(0, { + type: this.name, + attrs: { + item, + inputId: MAIN_EDITOR_INPUT_ID, + }, + }) + .focus("end") + .run(); }, // TODO: This could probably be greatly simplified with something along the lines of diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx index 899cbdd37..8a1095d80 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx +++ b/gui/src/components/mainInput/TipTapEditor/extensions/Prompt/PromptBlockPreview.tsx @@ -27,12 +27,13 @@ export const PromptBlockPreview = ({ }; const handleDelete = () => { - editor.commands.clearSlashCommand(); + editor.commands.clearPrompt(); }; return ( } diff --git a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommand.ts b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommand.ts index 4b5517c87..892d80355 100644 --- a/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommand.ts +++ b/gui/src/components/mainInput/TipTapEditor/extensions/SlashCommand.ts @@ -1,191 +1,50 @@ // Adapted from SlashCommand extension (@tiptap/extension-mention/src/mention.ts) -import { mergeAttributes, Node } from "@tiptap/core"; -import Document from "@tiptap/extension-document"; -import Paragraph from "@tiptap/extension-paragraph"; -import { Node as ProseMirrorNode } from "@tiptap/pm/model"; +import { Node } from "@tiptap/core"; import { PluginKey } from "@tiptap/pm/state"; import Suggestion, { SuggestionOptions } from "@tiptap/suggestion"; -import { ContextItemWithId, SlashCommandDescription } from "core"; -import { MAIN_EDITOR_INPUT_ID } from "../../../../pages/gui/Chat"; import { ComboBoxItem } from "../../types"; -import { PromptBlock } from "./Prompt/PromptBlock"; export type SlashCommandOptions = { - HTMLAttributes: Record; - renderText: (props: { node: ProseMirrorNode }) => string; suggestion: Omit, "editor">; }; -declare module "@tiptap/core" { - interface Commands { - slashCommand: { - /** - * Insert a slash command and its associated prompt block - * @param command The slash command description - */ - insertSlashCommand: (command: SlashCommandDescription) => ReturnType; - - /** - * Clear the slash command content from the editor - */ - clearSlashCommand: () => ReturnType; - }; - } -} - export const SlashCommand = Node.create({ name: "slash-command", addOptions() { return { - HTMLAttributes: { - class: "mention", - }, - renderText({ node }) { - return node.attrs.label ?? node.attrs.id; - }, suggestion: { char: "/", pluginKey: new PluginKey(this.name), startOfLine: true, command: ({ editor, range, props }) => { - // increase range.to by one when the next node is of type "text" - // and starts with a space character - const nodeAfter = editor.view.state.selection.$to.nodeAfter; - const overrideSpace = nodeAfter?.text?.startsWith(" "); + // First delete the slash character and any text after it + editor.chain().focus().deleteRange(range).run(); - if (overrideSpace) { - range.to += 1; - } - - editor.commands.insertSlashCommand({ + editor.commands.insertPrompt({ name: props.title, description: props.description, prompt: props.content, }); - - window.getSelection()?.collapseToEnd(); - }, - allow: ({ state, range }) => { - const $from = state.doc.resolve(range.from); - const type = state.schema.nodes[this.name]; - const allow = !!$from.parent.type.contentMatch.matchType(type); - - return allow; }, }, }; }, group: "inline", - inline: true, - selectable: false, - atom: true, + // We don't need attributes since we won't be rendering any node addAttributes() { - return { - id: { - default: null, - parseHTML: (element) => element.getAttribute("data-id"), - renderHTML: (attributes) => { - if (!attributes.id) { - return {}; - } - - return { - "data-id": attributes.id, - }; - }, - }, - - label: { - default: null, - parseHTML: (element) => element.getAttribute("data-label"), - renderHTML: (attributes) => { - if (!attributes.label) { - return {}; - } - - return { - "data-label": attributes.label, - }; - }, - }, - }; + return {}; }, + // No need to parse HTML since we're not rendering anything parseHTML() { - return [ - { - tag: `span[data-type="${this.name}"]`, - }, - ]; - }, - - renderHTML({ node, HTMLAttributes }) { - return [ - "span", - mergeAttributes( - { "data-type": this.name }, - this.options.HTMLAttributes, - HTMLAttributes, - ), - this.options.renderText({ - node, - }), - ]; - }, - - addKeyboardShortcuts() { - return { - Backspace: () => { - // Get a reference to the editor - const editor = this.editor; - - // First try to find if we're at a slash command - const result = editor.commands.command(({ tr, state }) => { - let isSlashCommand = false; - const { selection } = state; - const { empty, anchor } = selection; - - if (!empty) { - return false; - } - - state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => { - if (node.type.name === this.name) { - isSlashCommand = true; - tr.insertText( - this.options.suggestion.char || "", - pos, - pos + node.nodeSize, - ); - - return false; - } - }); - - return isSlashCommand; - }); - - // If we found and processed a slash command, also call clearSlashCommand - // to remove the prompt block - if (result) { - // We need to do this with a small delay to ensure the transaction - // above completes first - setTimeout(() => { - editor.commands.clearSlashCommand(); - }, 0); - return true; - } - - return false; - }, - }; + return []; }, addProseMirrorPlugins() { @@ -196,90 +55,4 @@ export const SlashCommand = Node.create({ }), ]; }, - - addCommands() { - return { - insertSlashCommand: - ( - command: SlashCommandDescription, - inputId: string = MAIN_EDITOR_INPUT_ID, - ) => - ({ chain }) => { - if (!command.prompt) { - return false; - } - - const contextItem: ContextItemWithId = { - content: command.prompt, - name: command.name, - description: command.description || "", - id: { - providerTitle: "prompt", - itemId: command.name, - }, - }; - - // Right now this inserts at the beginning of the document, which removes codeblocks. - // This is the current behavior of slash commands, eg codeblocks aren't sent. - // Once this bug if fixed, we should instead insert prompt block at the beginning of the document - // without clearing the codeblocks. - return chain() - .setContent({ - type: Document.name, - content: [ - // First insert the prompt using the PromptExtension command - { - type: PromptBlock.name, - attrs: { - item: contextItem, - inputId, - }, - }, - // Add the paragraph with the slash command - { - type: Paragraph.name, - content: [ - { - type: this.name, - attrs: { - id: command.name, - label: command.name, - }, - }, - { - type: "text", - text: " ", - }, - ], - }, - ], - }) - .focus() - .run(); - }, - - clearSlashCommand: - () => - ({ editor }) => { - editor.commands.clearPrompt(); - - editor.commands.command(({ tr, state }) => { - let hasDeleted = false; - - // Find all slash command nodes in the document - state.doc.descendants((node, pos) => { - if (node.type.name === this.name) { - // Delete the node at the found position - tr.delete(pos, pos + node.nodeSize); - hasDeleted = true; - } - }); - - return hasDeleted; - }); - - return true; - }, - }; - }, }); diff --git a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts index 69feed370..6e7808ba7 100644 --- a/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts +++ b/gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts @@ -9,7 +9,7 @@ import { } from "../../../redux/slices/sessionSlice"; import { AppDispatch } from "../../../redux/store"; import { loadSession, saveCurrentSession } from "../../../redux/thunks/session"; -import { CodeBlock } from "./extensions"; +import { CodeBlock, PromptBlock } from "./extensions"; /** * Hook for setting up main editor specific webview listeners @@ -111,16 +111,20 @@ export function useMainEditorWebviewListeners({ let index = 0; for (const el of editor.getJSON()?.content ?? []) { + // Prevent exact duplicate code blocks if (el.attrs?.item?.name === contextItem.name) { - return; // Prevent exact duplicate code blocks + return; } - if (el.type === CodeBlock.name) { + + if (el.type === CodeBlock.name || el.type === PromptBlock.name) { index += 2; } else { break; } } + debugger; + editor .chain() .insertContentAt(index, { diff --git a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts index 399701e9d..8c0613a4a 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/getSuggestion.ts @@ -7,7 +7,6 @@ import { import { MutableRefObject } from "react"; import tippy from "tippy.js"; import { IIdeMessenger } from "../../../../context/IdeMessenger"; -import { setNewestToolbarPreviewForInput } from "../../../../redux/slices/sessionSlice"; import { AppDispatch } from "../../../../redux/store"; import AtMentionDropdown from "../../AtMentionDropdown"; import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "../../types"; @@ -222,16 +221,7 @@ export function getSlashCommandDropdownOptions( label: provider.title, type: (provider.type ?? SlashCommand.name) as ComboBoxItemType, content: provider.content, - action: () => { - dispatch( - setNewestToolbarPreviewForInput({ - inputId, - contextItemId: provider.title, - }), - ); - - provider.action?.(); - }, + action: provider.action, })); if (query.length === 0 && commandItems.length === 0) { From 1710c2032f35219a65a6ce1ee15d50dfbef009e9 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 13:14:44 -0700 Subject: [PATCH 41/67] fix apply for jetgrains --- .../continue/IdeProtocolClient.kt | 45 ++++++++++++++++++- .../editor/DiffStreamHandler.kt | 33 ++++++++++++-- .../editor/InlineEditAction.kt | 5 ++- .../markdown/StyledMarkdownPreview.tsx | 8 +--- gui/src/redux/thunks/callTool.ts | 6 ++- 5 files changed, 84 insertions(+), 13 deletions(-) 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 95270f26b..75f393172 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,6 +16,7 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.service +import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.SelectionModel import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.fileEditor.FileEditorManager @@ -423,11 +424,45 @@ class IdeProtocolClient( dataElement.toString(), ApplyToFileParams::class.java ) + val filepath = params.filepath - val editor = FileEditorManager.getInstance(project).selectedTextEditor + continuePluginService.sendToWebview("updateApplyState", mapOf( + "streamId" to params.streamId, + "status" to "streaming", + "fileContent" to params.text, + "toolCallId" to params.toolCallId, + "filepath" to filepath + )) + + + fun closeStream () { + continuePluginService.sendToWebview("updateApplyState", mapOf( + "numDiffs" to 0, + "streamId" to params.streamId, + "status" to "closed", + "fileContent" to params.text, + "toolCallId" to params.toolCallId, + "filepath" to filepath + )) + } + + var editor: Editor? = null; + +// if (!filepath.isNullOrEmpty()) { +// val virtualFile = VirtualFileManager.getInstance().findFileByUrl(filepath) +// if (virtualFile != null) { +//// ApplicationManager.getApplication().invokeAndWait { +// FileEditorManager.getInstance(project).openFile(virtualFile, true)?.first() +// editor = FileEditorManager.getInstance(project).selectedTextEditor +//// } +// } +// } else { +// } + editor = FileEditorManager.getInstance(project).selectedTextEditor if (editor == null) { ide.showToast(ToastType.ERROR, "No active editor to apply edits to") + closeStream() respond(null) return@launch } @@ -436,6 +471,7 @@ class IdeProtocolClient( WriteCommandAction.runWriteCommandAction(project) { editor.document.insertString(0, params.text) } + closeStream() respond(null) return@launch } @@ -481,6 +517,7 @@ class IdeProtocolClient( ToastType.ERROR, "Failed to fetch model configuration" ) } + closeStream() respond(null) return@launch } @@ -519,7 +556,11 @@ class IdeProtocolClient( editor, rif?.range?.start?.line ?: 0, rif?.range?.end?.line ?: (editor.document.lineCount - 1), - {}, {}) + {}, + {}, + params.streamId, + params.toolCallId + ) diffStreamService.register(diffStreamHandler, editor) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index 55df303a8..f6cf5972f 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -27,14 +27,15 @@ class DiffStreamHandler( private val startLine: Int, private val endLine: Int, private val onClose: () -> Unit, - private val onFinish: () -> Unit + private val onFinish: () -> Unit, + private val streamId: String?, + private val toolCallId: String? ) { private data class CurLineState( var index: Int, var highlighter: RangeHighlighter? = null, var diffBlock: VerticalDiffBlock? = null ) private var curLine = CurLineState(startLine) - private var isRunning: Boolean = false private var hasAcceptedOrRejectedBlock: Boolean = false @@ -48,8 +49,26 @@ class DiffStreamHandler( initUnfinishedRangeHighlights() } + private fun sendUpdate(status: String) { + if(this.streamId == null) { + return + } + val virtualFile = getVirtualFile() + val continuePluginService = ServiceManager.getService(project, ContinuePluginService::class.java) + continuePluginService.sendToWebview("updateApplyState", mapOf( + "numDiffs" to this.diffBlocks.size, + "streamId" to this.streamId, + "status" to status, + "fileContent" to "not implemented", + "toolCallId" to this.toolCallId, + "filepath" to virtualFile?.url + )) + } + fun acceptAll() { - editor.markupModel.removeAllHighlighters() + editor.markupModel.removeAllHighlighters(); + sendUpdate("closed") + resetState() } @@ -62,6 +81,7 @@ class DiffStreamHandler( } else { undoChanges() } + sendUpdate("closed") resetState() } @@ -70,6 +90,7 @@ class DiffStreamHandler( input: String, prefix: String, highlighted: String, suffix: String, modelTitle: String ) { isRunning = true + this.sendUpdate("streaming") val continuePluginService = ServiceManager.getService(project, ContinuePluginService::class.java) val virtualFile = getVirtualFile() @@ -83,6 +104,7 @@ class DiffStreamHandler( if (response["done"] as? Boolean == true) { handleFinishedResponse() + sendUpdate(if (diffBlocks.isEmpty()) "closed" else "done") return@request } @@ -133,7 +155,10 @@ class DiffStreamHandler( } if (diffBlocks.isEmpty()) { + sendUpdate("closed") onClose() + } else { + sendUpdate("done") } } @@ -144,6 +169,7 @@ class DiffStreamHandler( ) diffBlocks.add(diffBlock) + sendUpdate("streaming") return diffBlock } @@ -234,6 +260,7 @@ class DiffStreamHandler( undoManager.undo(fileEditor) } } + sendUpdate("done") } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index faaf7d058..fd910308d 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -207,7 +207,10 @@ fun openInlineEdit(project: Project?, editor: Editor) { textArea.document.insertString(textArea.caretPosition, ", ", null) textArea.requestFocus() customPanelRef.get().finish() - }) + }, + null, + null + ) val diffStreamService = project.service() diffStreamService.register(diffStreamHandler, editor) diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 52ede7cbd..d10a3dab7 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -17,7 +17,7 @@ import useUpdatingRef from "../../hooks/useUpdatingRef"; import { useAppSelector } from "../../redux/hooks"; import { selectUIConfig } from "../../redux/slices/configSlice"; import { getContextItemsFromHistory } from "../../redux/thunks/updateFileSymbols"; -import { getFontSize, isJetBrains } from "../../util"; +import { getFontSize } from "../../util"; import { ToolTip } from "../gui/Tooltip"; import FilenameLink from "./FilenameLink"; import "./katex.css"; @@ -305,11 +305,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( const language = getLanguageFromClassName(className); - // If we don't have a filepath show the more basic toolbar - // that is just action buttons on hover. - // We also use this in JB since we haven't yet implemented - // the logic forfileUri lazy apply. - if (!relativeFilePath || isJetBrains()) { + if (!relativeFilePath) { return ( Date: Fri, 4 Apr 2025 13:52:41 -0700 Subject: [PATCH 42/67] move toolbar to lumpprovider --- .../Lump/BlockSettingsTopToolbar.tsx | 19 ++++++++----------- .../components/mainInput/Lump/LumpContext.tsx | 15 ++++++++++++++- gui/src/components/mainInput/Lump/index.tsx | 8 ++++++++ .../platform/AssistantSelect.tsx | 11 +++++------ gui/src/redux/slices/uiSlice.ts | 7 ------- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx index ebef0251b..9d8c79ccc 100644 --- a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx +++ b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx @@ -9,11 +9,10 @@ import { WrenchScrewdriverIcon, } from "@heroicons/react/24/outline"; import { vscBadgeBackground, vscBadgeForeground } from "../.."; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { toggleBlockSettingsToolbar } from "../../../redux/slices/uiSlice"; import { fontSize } from "../../../util"; import AssistantSelect from "../../modelSelection/platform/AssistantSelect"; import HoverItem from "../InputToolbar/HoverItem"; +import { useLump } from "./LumpContext"; interface BlockSettingsToolbarIcon { tooltip: string; @@ -87,15 +86,13 @@ interface BlockSettingsTopToolbarProps { } export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) { - const isExpanded = useAppSelector( - (state) => state.ui.isBlockSettingsToolbarExpanded, - ); - const dispatch = useAppDispatch(); + const { isToolbarExpanded, toggleToolbar } = useLump(); + const handleEllipsisClick = () => { - if (isExpanded) { + if (isToolbarExpanded) { props.setSelectedSection(null); } - dispatch(toggleBlockSettingsToolbar()); + toggleToolbar(); }; return ( @@ -103,14 +100,14 @@ export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) {
{sections.map((section) => ( diff --git a/gui/src/components/mainInput/Lump/LumpContext.tsx b/gui/src/components/mainInput/Lump/LumpContext.tsx index 4e93777ea..8b6417f6f 100644 --- a/gui/src/components/mainInput/Lump/LumpContext.tsx +++ b/gui/src/components/mainInput/Lump/LumpContext.tsx @@ -6,8 +6,10 @@ import { createContext, ReactNode, useContext } from "react"; interface LumpContextType { isLumpVisible: boolean; selectedSection: string | null; + isToolbarExpanded: boolean; hideLump: () => void; setSelectedSection: (section: string | null) => void; + toggleToolbar: () => void; } const LumpContext = createContext(undefined); @@ -16,8 +18,10 @@ interface LumpProviderProps { children: ReactNode; isLumpVisible: boolean; selectedSection: string | null; + isToolbarExpanded: boolean; hideLump: () => void; setSelectedSection: (section: string | null) => void; + toggleToolbar: () => void; } /** @@ -27,12 +31,21 @@ export function LumpProvider({ children, isLumpVisible, selectedSection, + isToolbarExpanded, hideLump, setSelectedSection, + toggleToolbar, }: LumpProviderProps) { return ( {children} diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index df1875c86..b9df37108 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -38,6 +38,7 @@ export function Lump() { const [selectedSection, setSelectedSection] = useState(null); const [displayedSection, setDisplayedSection] = useState(null); const [isVisible, setIsVisible] = useState(false); + const [isToolbarExpanded, setIsToolbarExpanded] = useState(true); const isStreaming = useAppSelector((state) => state.session.isStreaming); // Handle keyboard escape @@ -55,6 +56,11 @@ export function Lump() { setSelectedSection(null); }, []); + // Function to toggle toolbar expanded state + const toggleToolbar = useCallback(() => { + setIsToolbarExpanded((prev) => !prev); + }, []); + // Reset when streaming starts if (isStreaming && selectedSection) { setSelectedSection(null); @@ -84,8 +90,10 @@ export function Lump() {
diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 36495145d..2c8fc2d68 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -11,7 +11,7 @@ import { useContext, useEffect, useMemo, useRef } from "react"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { cycleProfile, selectProfileThunk } from "../../../redux"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { useAppDispatch } from "../../../redux/hooks"; import { fontSize, getMetaKeyLabel, @@ -31,6 +31,7 @@ import { useNavigate } from "react-router-dom"; import { vscCommandCenterInactiveBorder } from "../.."; import { ROUTES } from "../../../util/navigation"; import { ToolTip } from "../../gui/Tooltip"; +import { useLump } from "../../mainInput/Lump/LumpContext"; import { useFontSize } from "../../ui/font"; import AssistantIcon from "./AssistantIcon"; @@ -143,9 +144,7 @@ export default function AssistantSelect() { const buttonRef = useRef(null); const { selectedProfile, selectedOrganization } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); - const isLumpToolbarExpanded = useAppSelector( - (state) => state.ui.isBlockSettingsToolbarExpanded, - ); + const { isToolbarExpanded } = useLump(); const { profiles, session, login } = useAuth(); const navigate = useNavigate(); @@ -205,7 +204,7 @@ export default function AssistantSelect() { > Create your first assistant @@ -227,7 +226,7 @@ export default function AssistantSelect() {
{selectedProfile.title} diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 7bb7fb3fd..13efdfa1a 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -25,7 +25,6 @@ type UIState = { toolSettings: { [toolName: string]: ToolSetting }; toolGroupSettings: { [toolGroupName: string]: ToolGroupSetting }; ttsActive: boolean; - isBlockSettingsToolbarExpanded: boolean; }; export const DEFAULT_TOOL_SETTING: ToolSetting = "allowedWithPermission"; @@ -56,7 +55,6 @@ export const uiSlice = createSlice({ toolGroupSettings: { BUILT_IN_GROUP_NAME: "include", }, - isBlockSettingsToolbarExpanded: true, } as UIState, reducers: { setOnboardingCard: ( @@ -124,10 +122,6 @@ export const uiSlice = createSlice({ setTTSActive: (state, { payload }: PayloadAction) => { state.ttsActive = payload; }, - toggleBlockSettingsToolbar: (state) => { - state.isBlockSettingsToolbarExpanded = - !state.isBlockSettingsToolbarExpanded; - }, }, }); @@ -142,7 +136,6 @@ export const { toggleToolGroupSetting, addTool, setTTSActive, - toggleBlockSettingsToolbar, } = uiSlice.actions; export default uiSlice.reducer; From 34ae653841b3933872248cf34100d25b068ef229 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 14:04:31 -0700 Subject: [PATCH 43/67] open new editor with file --- .../continue/IdeProtocolClient.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) 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 75f393172..d8905445e 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 @@ -448,17 +448,15 @@ class IdeProtocolClient( var editor: Editor? = null; -// if (!filepath.isNullOrEmpty()) { -// val virtualFile = VirtualFileManager.getInstance().findFileByUrl(filepath) -// if (virtualFile != null) { -//// ApplicationManager.getApplication().invokeAndWait { -// FileEditorManager.getInstance(project).openFile(virtualFile, true)?.first() -// editor = FileEditorManager.getInstance(project).selectedTextEditor -//// } -// } -// } else { -// } - editor = FileEditorManager.getInstance(project).selectedTextEditor + if (!filepath.isNullOrEmpty()) { + val virtualFile = VirtualFileManager.getInstance().findFileByUrl(filepath) + if (virtualFile != null) { + ApplicationManager.getApplication().invokeAndWait { + FileEditorManager.getInstance(project).openFile(virtualFile, true)?.first() + } + } + } + editor = FileEditorManager.getInstance(project).selectedTextEditor if (editor == null) { ide.showToast(ToastType.ERROR, "No active editor to apply edits to") From 8a7d7acb0304b255541ccbd59aa83f5c2fd4e74b Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 14:07:03 -0700 Subject: [PATCH 44/67] more lump provider centralization --- .../Lump/BlockSettingsTopToolbar.tsx | 22 ++-- .../components/mainInput/Lump/LumpContext.tsx | 85 +++++++++++--- .../components/mainInput/Lump/LumpToolbar.tsx | 14 +-- gui/src/components/mainInput/Lump/index.tsx | 104 +++++------------- .../Lump/sections/SelectedSection.tsx | 12 +- 5 files changed, 114 insertions(+), 123 deletions(-) diff --git a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx index 9d8c79ccc..64a477cbb 100644 --- a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx +++ b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx @@ -80,17 +80,17 @@ function BlockSettingsToolbarIcon(props: BlockSettingsToolbarIcon) { ); } -interface BlockSettingsTopToolbarProps { - selectedSection: string | null; - setSelectedSection: (value: string | null) => void; -} - -export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) { - const { isToolbarExpanded, toggleToolbar } = useLump(); +export function BlockSettingsTopToolbar() { + const { + isToolbarExpanded, + toggleToolbar, + selectedSection, + setSelectedSection, + } = useLump(); const handleEllipsisClick = () => { if (isToolbarExpanded) { - props.setSelectedSection(null); + setSelectedSection(null); } toggleToolbar(); }; @@ -115,10 +115,10 @@ export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) { key={section.id} icon={section.icon} tooltip={section.tooltip} - isSelected={props.selectedSection === section.id} + isSelected={selectedSection === section.id} onClick={() => - props.setSelectedSection( - props.selectedSection === section.id ? null : section.id, + setSelectedSection( + selectedSection === section.id ? null : section.id, ) } /> diff --git a/gui/src/components/mainInput/Lump/LumpContext.tsx b/gui/src/components/mainInput/Lump/LumpContext.tsx index 8b6417f6f..92c5dbd6c 100644 --- a/gui/src/components/mainInput/Lump/LumpContext.tsx +++ b/gui/src/components/mainInput/Lump/LumpContext.tsx @@ -1,11 +1,20 @@ /** * Provides context for controlling the Lump component's visibility state */ -import { createContext, ReactNode, useContext } from "react"; +import { + createContext, + ReactNode, + useCallback, + useContext, + useEffect, + useState, +} from "react"; +import { useAppSelector } from "../../../redux/hooks"; interface LumpContextType { isLumpVisible: boolean; selectedSection: string | null; + displayedSection: string | null; isToolbarExpanded: boolean; hideLump: () => void; setSelectedSection: (section: string | null) => void; @@ -16,31 +25,73 @@ const LumpContext = createContext(undefined); interface LumpProviderProps { children: ReactNode; - isLumpVisible: boolean; - selectedSection: string | null; - isToolbarExpanded: boolean; - hideLump: () => void; - setSelectedSection: (section: string | null) => void; - toggleToolbar: () => void; } /** * Provider component that makes Lump state available to any child component */ -export function LumpProvider({ - children, - isLumpVisible, - selectedSection, - isToolbarExpanded, - hideLump, - setSelectedSection, - toggleToolbar, -}: LumpProviderProps) { +export function LumpProvider({ children }: LumpProviderProps) { + const [selectedSection, setSelectedSection] = useState(null); + const [displayedSection, setDisplayedSection] = useState(null); + const [isVisible, setIsVisible] = useState(false); + const [isToolbarExpanded, setIsToolbarExpanded] = useState(true); + const isStreaming = useAppSelector((state) => state.session.isStreaming); + + // Handle keyboard escape + const handleKeyDown = useCallback( + (event: KeyboardEvent) => { + if (event.key === "Escape" && selectedSection) { + setSelectedSection(null); + } + }, + [selectedSection], + ); + + // Function to hide the lump + const hideLump = useCallback(() => { + setSelectedSection(null); + }, []); + + // Function to toggle toolbar expanded state + const toggleToolbar = useCallback(() => { + setIsToolbarExpanded((prev) => !prev); + }, []); + + // Update displayedSection and visibility when selectedSection changes + useEffect(() => { + if (selectedSection) { + setDisplayedSection(selectedSection); + setIsVisible(true); + } else { + setIsVisible(false); + const timeout = setTimeout(() => { + setDisplayedSection(null); + }, 300); + return () => clearTimeout(timeout); + } + }, [selectedSection]); + + // Reset when streaming starts + useEffect(() => { + if (isStreaming && selectedSection) { + setSelectedSection(null); + } + }, [isStreaming, selectedSection]); + + // Set up keyboard listener + useEffect(() => { + if (selectedSection) { + document.addEventListener("keydown", handleKeyDown); + return () => document.removeEventListener("keydown", handleKeyDown); + } + }, [selectedSection, handleKeyDown]); + return ( void; -} - -export function LumpToolbar(props: TopToolbarProps) { +export function LumpToolbar() { const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); const ttsActive = useAppSelector((state) => state.ui.ttsActive); @@ -60,10 +55,5 @@ export function LumpToolbar(props: TopToolbarProps) { ); } - return ( - - ); + return ; } diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index b9df37108..de432f1d1 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -1,12 +1,10 @@ -import { useCallback, useState } from "react"; import styled from "styled-components"; import { defaultBorderRadius, vscCommandCenterInactiveBorder, vscInputBackground, } from "../.."; -import { useAppSelector } from "../../../redux/hooks"; -import { LumpProvider } from "./LumpContext"; +import { LumpProvider, useLump } from "./LumpContext"; import { LumpToolbar } from "./LumpToolbar"; import { SelectedSection } from "./sections/SelectedSection"; @@ -35,82 +33,32 @@ const ContentDiv = styled.div<{ hasSection: boolean; isVisible: boolean }>` * Main component that displays the toolbar and selected content section */ export function Lump() { - const [selectedSection, setSelectedSection] = useState(null); - const [displayedSection, setDisplayedSection] = useState(null); - const [isVisible, setIsVisible] = useState(false); - const [isToolbarExpanded, setIsToolbarExpanded] = useState(true); - const isStreaming = useAppSelector((state) => state.session.isStreaming); - - // Handle keyboard escape - const handleKeyDown = useCallback( - (event: KeyboardEvent) => { - if (event.key === "Escape" && selectedSection) { - setSelectedSection(null); - } - }, - [selectedSection], - ); - - // Function to hide the lump - const hideLump = useCallback(() => { - setSelectedSection(null); - }, []); - - // Function to toggle toolbar expanded state - const toggleToolbar = useCallback(() => { - setIsToolbarExpanded((prev) => !prev); - }, []); - - // Reset when streaming starts - if (isStreaming && selectedSection) { - setSelectedSection(null); - } - - // Update displayedSection and visibility when selectedSection changes - if (selectedSection) { - if (displayedSection !== selectedSection || !isVisible) { - setDisplayedSection(selectedSection); - setIsVisible(true); - } - } else if (isVisible) { - setIsVisible(false); - setTimeout(() => { - setDisplayedSection(null); - }, 300); - } - - // Set up keyboard listener - if (selectedSection) { - document.addEventListener("keydown", handleKeyDown); - } else { - document.removeEventListener("keydown", handleKeyDown); - } - return ( - - -
- - - - - -
-
+ + ); } + +/** + * Internal component that consumes the LumpContext + */ +function LumpContent() { + const { isLumpVisible, selectedSection } = useLump(); + + return ( + +
+ + + + + +
+
+ ); +} diff --git a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx b/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx index 28dc37c28..e592d13ff 100644 --- a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx @@ -1,3 +1,4 @@ +import { useLump } from "../LumpContext"; import { ContextSection } from "./ContextSection"; import DocsSection from "./docs/DocsSection"; import { MCPSection } from "./MCPSection"; @@ -6,12 +7,13 @@ import { PromptsSection } from "./PromptsSection"; import { RulesSection } from "./RulesSection"; import { ToolsSection } from "./ToolsSection"; -interface SelectedSectionProps { - selectedSection: string | null; -} +/** + * Renders the appropriate section based on the selected section in the Lump context + */ +export function SelectedSection() { + const { displayedSection } = useLump(); -export function SelectedSection(props: SelectedSectionProps) { - switch (props.selectedSection) { + switch (displayedSection) { case "models": return ; case "rules": From fee9b5f51695d8f6aedaa0e59be988635dbaae7d Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 14:21:30 -0700 Subject: [PATCH 45/67] Update PromptsSection.tsx --- .../mainInput/Lump/sections/PromptsSection.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx index 1ff27c16c..8ea7a37d3 100644 --- a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx @@ -50,15 +50,19 @@ function PromptRow({ return (
-
- {prompt.name} - {prompt.description} +
+ + {prompt.name} + + + {prompt.description} +
Date: Fri, 4 Apr 2025 14:35:43 -0700 Subject: [PATCH 46/67] isGenerating logic fix --- .../StepContainerPreToolbar.tsx | 12 +----------- .../markdown/StyledMarkdownPreview.tsx | 18 +++++++++++++++--- gui/src/hooks/useSetup.ts | 16 ++++++++-------- gui/src/pages/gui/ToolCallDiv/EditFile.tsx | 1 + gui/src/redux/thunks/callTool.ts | 14 +++++++++++++- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 375fd7ab8..f09ed1a9f 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -69,7 +69,6 @@ export default function StepContainerPreToolbar( props.expanded ?? (isInEditMode ? false : true), ); const [codeBlockContent, setCodeBlockContent] = useState(""); - const isStreaming = useAppSelector((state) => state.session.isStreaming); const nextCodeBlockIndex = useAppSelector( (state) => state.session.codeBlockApplyStates.curIndex, @@ -79,15 +78,6 @@ export default function StepContainerPreToolbar( selectApplyStateByStreamId(state, props.codeBlockStreamId), ); - // This handles an edge case when the last node in the markdown syntax tree is a codeblock. - // In this scenario, `isGeneratingCodeBlock` is never set to false since we determine if - // we are done generating based on whether the next node in the tree is not a codeblock. - // The tree parsing logic for Remark is defined on page load, so we can't access state - // during the actual tree parsing. - const isGeneratingCodeBlock = !isStreaming - ? false - : props.isGeneratingCodeBlock; - const isNextCodeBlock = nextCodeBlockIndex === props.codeBlockIndex; const hasFileExtension = /\.[0-9a-z]+$/i.test(props.relativeFilepath); @@ -196,7 +186,7 @@ export default function StepContainerPreToolbar(
- {isGeneratingCodeBlock ? ( + {props.isGeneratingCodeBlock ? ( { + return props.itemIndex && props.itemIndex === history.length - 1; + }, [history.length, props.itemIndex]); + const isLastItemRef = useUpdatingRef(isLastItem); + + const isStreaming = useAppSelector((store) => store.session.isStreaming); + const isStreamingRef = useUpdatingRef(isStreaming); + const codeblockState = useRef<{ streamId: string; isGenerating: boolean }[]>( [], ); + useEffect(() => { if (props.singleCodeblockStreamId) { codeblockState.current = [ @@ -235,8 +245,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( node.data = node.data || {}; node.data.hProperties = node.data.hProperties || {}; - node.data.hProperties["data-isgeneratingcodeblock"] = - lastCodeNode === node; + node.data.hProperties["data-islastcodeblock"] = lastCodeNode === node; node.data.hProperties["data-codeblockcontent"] = node.value; if (node.meta) { @@ -318,7 +327,9 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( } const isGeneratingCodeBlock = - preChildProps["data-isgeneratingcodeblock"]; + preChildProps["data-islastcodeblock"] && + isLastItemRef.current && + !isStreamingRef.current; if (codeblockState.current[codeBlockIndex] === undefined) { codeblockState.current[codeBlockIndex] = { @@ -342,6 +353,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( codeBlockStreamId={ codeblockState.current[codeBlockIndex].streamId } + expanded={props.expandCodeblocks} disableManualApply={props.disableManualApply} > diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 25b1a7fc0..ded57ee08 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -3,7 +3,7 @@ import { VSC_THEME_COLOR_VARS } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { ConfigResult } from "@continuedev/config-yaml"; -import { BrowserSerializedContinueConfig, ContextItem } from "core"; +import { BrowserSerializedContinueConfig } from "core"; import { initializeProfilePreferencesThunk, selectProfileThunk, @@ -268,17 +268,17 @@ function useSetup() { state.streamId === activeToolStreamId[0] && state.status === "closed" ) { - const output: ContextItem = { - name: "Edit tool output", - content: "Completed edit", - description: "", - }; + // const output: ContextItem = { + // name: "Edit tool output", + // content: "Completed edit", + // description: "", + // }; dispatch(acceptToolCall()); - dispatch(setToolCallOutput([output])); + dispatch(setToolCallOutput([])); dispatch( streamResponseAfterToolCall({ toolCallId: activeToolStreamId[1], - toolOutput: [output], + toolOutput: [], }), ); } diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx index 2ff34d489..80927e6e7 100644 --- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx +++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx @@ -33,6 +33,7 @@ export function EditFile(props: EditToolCallProps) { source={src} disableManualApply={true} singleCodeblockStreamId={applyState?.streamId} + expandCodeblocks={false} /> {/* TODO better indicator of generation at bottom */} {/* {isStreaming && applyState?.status === "streaming" && ( diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 41557cb40..bf15e7ae8 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -11,6 +11,7 @@ import { cancelToolCall, setCalling, setToolCallOutput, + updateApplyState, } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall"; @@ -61,6 +62,17 @@ export const callTool = createAsyncThunk( if (e instanceof Error) { errorMessage = e.message; } + if (state.session.activeToolStreamId?.[0]) { + dispatch( + updateApplyState({ + streamId: state.session.activeToolStreamId[0], + status: "closed", + toolCallId: toolCallState.toolCallId, + numDiffs: 0, + filepath: args.filepath, + }), + ); + } } } else { const result = await extra.ideMessenger.request("tools/call", { @@ -128,7 +140,7 @@ async function customGuiEditImpl( text: args.new_contents, curSelectedModelTitle: modelTitle, toolCallId, - filepath: firstUriMatch + filepath: firstUriMatch, }); if (apply.status === "error") { throw new Error(apply.error); From d898d9fe305c7a38d4deb1ab1b9172bb05759fab Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 14:43:10 -0700 Subject: [PATCH 47/67] assistant select cleanup --- .../modelSelection/platform/AssistantSelect.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 2c8fc2d68..5219af10f 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -82,13 +82,13 @@ const AssistantSelectOption = ({ fontSizeModifier={-2} >
-
+
-
+
{profile.title} @@ -238,7 +238,7 @@ export default function AssistantSelect() { - +
@@ -281,7 +281,7 @@ export default function AssistantSelect() { />
{getMetaKeyLabel()} ⇧ ' to toggle
navigate(ROUTES.CONFIG)} > {selectedOrganization?.iconUrl ? ( From bf7cf661cc4357029492f067ca57b1a43401aaaa Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 15:45:03 -0700 Subject: [PATCH 48/67] feat: more cleanup --- .../modelSelection/platform/AssistantIcon.tsx | 10 +++- .../platform/AssistantSelect.tsx | 52 ++++++++++++++----- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/gui/src/components/modelSelection/platform/AssistantIcon.tsx b/gui/src/components/modelSelection/platform/AssistantIcon.tsx index 9f4bfcd0b..c901bfdf4 100644 --- a/gui/src/components/modelSelection/platform/AssistantIcon.tsx +++ b/gui/src/components/modelSelection/platform/AssistantIcon.tsx @@ -10,7 +10,15 @@ export interface AssistantIconProps { export default function AssistantIcon({ assistant, size }: AssistantIconProps) { const sizeTw = size ?? 4; if (isLocalProfile(assistant)) { - return ; + return ( +
+ +
+ ); } else if (assistant.iconUrl) { return ( { + const tinyFont = useFontSize(-4); + const navigate = useNavigate(); const hasFatalErrors = useMemo(() => { @@ -81,10 +83,20 @@ const AssistantSelectOption = ({ onClick={!hasFatalErrors ? handleOptionClick : undefined} fontSizeModifier={-2} > -
+
-
-
+
+
+ {selected ? ( + + ) : null} +
+
-
-
{selected ? : null}
+
{!profile.errors?.length ? ( isLocalProfile(profile) ? ( { e.stopPropagation(); e.preventDefault(); @@ -107,7 +118,7 @@ const AssistantSelectOption = ({ /> ) : ( { e.stopPropagation(); e.preventDefault(); @@ -240,7 +251,7 @@ export default function AssistantSelect() {
{profiles?.map((profile, idx) => { return ( @@ -267,8 +278,13 @@ export default function AssistantSelect() { fontSizeModifier={-2} onClick={session ? onNewAssistant : () => login(false)} > -
- +
+ New Assistant
@@ -281,12 +297,17 @@ export default function AssistantSelect() { />
- + {getMetaKeyLabel()} ⇧ ' to toggle
)} - + {selectedOrganization?.name || "Personal"}
From 4969539a89e6cb78d5ac9d6b2501570bbcade718 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 15:45:46 -0700 Subject: [PATCH 49/67] Update AssistantSelect.tsx --- gui/src/components/modelSelection/platform/AssistantSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 967e7cc77..0d45dface 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -317,7 +317,7 @@ export default function AssistantSelect() { {selectedOrganization?.iconUrl ? ( ) : ( From ebe9c5c3b9a6b6ed4402138a8618e213d053b6c4 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 15:46:15 -0700 Subject: [PATCH 50/67] typo --- core/tools/definitions/grepSearch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tools/definitions/grepSearch.ts b/core/tools/definitions/grepSearch.ts index b6b7b456f..42ea92e64 100644 --- a/core/tools/definitions/grepSearch.ts +++ b/core/tools/definitions/grepSearch.ts @@ -6,7 +6,7 @@ export const grepSearchTool: Tool = { displayTitle: "Grep Search", wouldLikeTo: 'search for "{{{ query }}}" in the repository', isCurrently: 'getting search results for "{{{ query }}}"', - hasAlready: 'retreived search results for "{{{ query }}}"', + hasAlready: 'retrieved search results for "{{{ query }}}"', readonly: true, group: BUILT_IN_GROUP_NAME, function: { From d056a8c44a6ea2e3a52988bfd511ee941e433bef Mon Sep 17 00:00:00 2001 From: Chad Metcalf Date: Fri, 4 Apr 2025 15:36:05 -0700 Subject: [PATCH 51/67] Switch to localhost for using Docker models. Docker only exposes the http://model-runner.docker.internal address inside of containers. So we will want to use localhost. --- core/llm/llms/Docker.ts | 57 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/core/llm/llms/Docker.ts b/core/llm/llms/Docker.ts index 229cfac17..d722f5c1c 100644 --- a/core/llm/llms/Docker.ts +++ b/core/llm/llms/Docker.ts @@ -1,6 +1,7 @@ import { spawn } from "child_process"; import { LLMOptions, ModelInstaller } from "../../index.js"; import OpenAI from "./OpenAI.js"; +import http from "http"; /** * Docker Model Runner provider @@ -16,7 +17,7 @@ import OpenAI from "./OpenAI.js"; class Docker extends OpenAI implements ModelInstaller { static providerName = "docker"; static defaultOptions: Partial = { - apiBase: "http://model-runner.docker.internal/v1/", + apiBase: "http://localhost:12434/engines/v1", model: "gemma3-4B-F4", // Default model }; @@ -53,6 +54,58 @@ class Docker extends OpenAI implements ModelInstaller { if (this.model && this.modelMap[this.model]) { this.model = this.modelMap[this.model]; } + + // Check if Docker Model Runner is active and enable it if needed + this.ensureModelRunnerEnabled(); + } + + /** + * Checks if Docker Model Runner is running at the expected port + * and enables it if not running + */ + private async ensureModelRunnerEnabled(): Promise { + try { + // Check if the Model Runner service is running on the expected port + const isRunning = await this.isPortBound(12434); + + if (!isRunning) { + console.log("Docker Model Runner not detected. Attempting to enable it..."); + await this.executeDockerCommand(['desktop', 'enable', 'model-runner', '--tcp', '12434']); + console.log("Docker Model Runner has been enabled on port 12434"); + } + } catch (error) { + console.warn("Failed to enable Docker Model Runner:", error); + } + } + + /** + * Checks if a port is currently bound/in use + */ + private isPortBound(port: number): Promise { + return new Promise((resolve) => { + const req = http.request({ + method: 'HEAD', + host: 'localhost', + port: port, + timeout: 1000, + path: '/' + }, () => { + // If we can connect, the port is in use + resolve(true); + }); + + req.on('error', () => { + // If we can't connect, the port is not in use + resolve(false); + }); + + req.on('timeout', () => { + req.destroy(); + resolve(false); + }); + + req.end(); + }); } private async executeDockerCommand( @@ -130,4 +183,4 @@ class Docker extends OpenAI implements ModelInstaller { } } -export default Docker; +export default Docker; \ No newline at end of file From 1f77f8a1d0d053e79b48eb03a41b986bca1384b6 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 15:57:46 -0700 Subject: [PATCH 52/67] Update AssistantSelect.tsx --- .../modelSelection/platform/AssistantSelect.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 0d45dface..919e269ee 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -1,7 +1,6 @@ import { ArrowTopRightOnSquareIcon, BuildingOfficeIcon, - CheckIcon, ChevronDownIcon, Cog6ToothIcon, ExclamationTriangleIcon, @@ -82,6 +81,7 @@ const AssistantSelectOption = ({ disabled={hasFatalErrors} onClick={!hasFatalErrors ? handleOptionClick : undefined} fontSizeModifier={-2} + className={selected ? "bg-list-active text-list-active-foreground" : ""} >
-
- {selected ? ( - - ) : null} -
@@ -284,7 +279,7 @@ export default function AssistantSelect() { fontSize: tinyFont, }} > - + New Assistant
From 2056ccd39d983d918d851b3cf4d748ae37ef505f Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 4 Apr 2025 15:58:31 -0700 Subject: [PATCH 53/67] Update AssistantSelect.tsx --- gui/src/components/modelSelection/platform/AssistantSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 919e269ee..0b20e2beb 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -279,7 +279,7 @@ export default function AssistantSelect() { fontSize: tinyFont, }} > - + New Assistant
From 00814eb5dc7bb163c621fbccde1604c6a286848e Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Apr 2025 17:04:13 -0700 Subject: [PATCH 54/67] update listAssistants --- packages/hub/package.json | 2 +- packages/hub/src/ContinueHubClient.ts | 22 ++++++++++++++++++---- packages/hub/src/IContinueHubClient.ts | 5 ++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/hub/package.json b/packages/hub/package.json index 2b49abd4a..e6f3ab8d3 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/hub", - "version": "0.0.3", + "version": "0.0.4", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/hub/src/ContinueHubClient.ts b/packages/hub/src/ContinueHubClient.ts index 501a8bc54..516dee31b 100644 --- a/packages/hub/src/ContinueHubClient.ts +++ b/packages/hub/src/ContinueHubClient.ts @@ -64,7 +64,10 @@ export class ContinueHubClient implements IContinueHubClient { }); return (await resp.json()) as any; } - async listAssistants(organizationId: string | null): Promise< + async listAssistants(options: { + organizationId: string | null; + alwaysUseProxy?: boolean; + }): Promise< { configResult: ConfigResult; ownerSlug: string; @@ -73,10 +76,21 @@ export class ContinueHubClient implements IContinueHubClient { rawYaml: string; }[] > { + const organizationId = options.organizationId; + const alwaysUseProxy = options.alwaysUseProxy ?? false; + try { - const url = organizationId - ? `ide/list-assistants?organizationId=${organizationId}` - : "ide/list-assistants"; + const urlObj = new URL( + organizationId ? "ide/list-assistants" : "ide/list-assistants", + this.apiBase, + ); + if (organizationId) { + urlObj.searchParams.set("organizationId", organizationId); + } + if (alwaysUseProxy) { + urlObj.searchParams.set("alwaysUseProxy", alwaysUseProxy.toString()); + } + const url = urlObj.toString(); const resp = await this.request(url, { method: "GET", diff --git a/packages/hub/src/IContinueHubClient.ts b/packages/hub/src/IContinueHubClient.ts index 6ab2c5643..161e36a41 100644 --- a/packages/hub/src/IContinueHubClient.ts +++ b/packages/hub/src/IContinueHubClient.ts @@ -18,7 +18,10 @@ export interface IContinueHubClient { /** * Do a full reload of all assistants used in the organization by the user. */ - listAssistants(organizationId: string | null): Promise< + listAssistants(options: { + organizationId: string | null; + alwaysUseProxy?: boolean; + }): Promise< { configResult: ConfigResult; ownerSlug: string; From f2237c03994948e8df430d696954a2bc62cba61b Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 4 Apr 2025 17:10:24 -0700 Subject: [PATCH 55/67] cleanup --- core/tools/callTool.ts | 4 +--- core/tools/implementations/createNewFile.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 2a04cb828..c81a0a6e4 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -138,9 +138,7 @@ export async function callTool( switch (uri) { case BuiltInToolNames.ReadFile: return await readFileImpl(args, extras); - // Custom GUI handling for edit - // case BuiltInToolNames.EditExistingFile: - // return await editFileImpl(args, extras); + // Note: Custom GUI handling for edit case BuiltInToolNames.CreateNewFile: return await createNewFileImpl(args, extras); case BuiltInToolNames.ExactSearch: diff --git a/core/tools/implementations/createNewFile.ts b/core/tools/implementations/createNewFile.ts index cf8746328..5a89141eb 100644 --- a/core/tools/implementations/createNewFile.ts +++ b/core/tools/implementations/createNewFile.ts @@ -12,7 +12,7 @@ export const createNewFileImpl: ToolImpl = async (args, extras) => { const exists = await extras.ide.fileExists(resolvedFileUri); if (exists) { throw new Error( - `File ${args.filepath} already exists. Use the edit too to edit this file`, + `File ${args.filepath} already exists. Use the edit tool to edit this file`, ); } await extras.ide.writeFile(resolvedFileUri, args.contents); From fb94c08ed5456ab6cf3f07726cd6026175c9aacc Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 4 Apr 2025 18:37:34 -0700 Subject: [PATCH 56/67] bump --- extensions/intellij/gradle.properties | 2 +- extensions/vscode/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 506f6bf62..7c00cb65c 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension pluginName=continue-intellij-extension pluginRepositoryUrl=https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion=1.0.11 +pluginVersion=1.0.12 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=223 # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 15599a1c0..97a2b6105 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.1.20", + "version": "1.1.21", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 63544f0f0b0e23a02b4a80124e1a9bffe9ca715f Mon Sep 17 00:00:00 2001 From: Nick B <8633545+nblake989@users.noreply.github.com> Date: Sat, 5 Apr 2025 13:10:09 -0700 Subject: [PATCH 57/67] Update bedrock.mdx mispelling for Poolside Point Link in docs read "poolisde" instead of Poolside. Link is functional, just mispelled alias --- docs/docs/customize/model-providers/top-level/bedrock.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/customize/model-providers/top-level/bedrock.mdx b/docs/docs/customize/model-providers/top-level/bedrock.mdx index 9582428a4..45cf5e5eb 100644 --- a/docs/docs/customize/model-providers/top-level/bedrock.mdx +++ b/docs/docs/customize/model-providers/top-level/bedrock.mdx @@ -80,7 +80,7 @@ We recommend configuring **Claude 3.5 Sonnet** as your chat model. ## Autocomplete model -Bedrock currently does not offer any autocomplete models. However, [Codestral from Mistral](https://mistral.ai/news/codestral-2501/) and [Point from Poolisde](https://aws.amazon.com/bedrock/poolside/) will be supported in the near future. +Bedrock currently does not offer any autocomplete models. However, [Codestral from Mistral](https://mistral.ai/news/codestral-2501/) and [Point from Poolside](https://aws.amazon.com/bedrock/poolside/) will be supported in the near future. In the meantime, you can view a list of autocomplete model providers [here](../../model-roles/autocomplete.md). From 401d67bbd0dc11fd6eda2f7d9c17dfd4da0a43f5 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sat, 5 Apr 2025 13:36:41 -0700 Subject: [PATCH 58/67] feat: use `fetch` instead of `http` --- core/llm/llms/Docker.ts | 111 ++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/core/llm/llms/Docker.ts b/core/llm/llms/Docker.ts index d722f5c1c..d9c3d5c58 100644 --- a/core/llm/llms/Docker.ts +++ b/core/llm/llms/Docker.ts @@ -1,7 +1,6 @@ import { spawn } from "child_process"; import { LLMOptions, ModelInstaller } from "../../index.js"; import OpenAI from "./OpenAI.js"; -import http from "http"; /** * Docker Model Runner provider @@ -42,9 +41,10 @@ class Docker extends OpenAI implements ModelInstaller { "llama3.2-1B-F8": "ai/llama3.2:1B-Q8_0", "qwq-32B-F16": "ai/qwq:32B-F16", "qwq-32B-F4": "ai/qwq:32B-Q4_K_M", - "deepseek-r1-distill-llama-70B-F4": "ai/deepseek-r1-distill-llama:70B-Q4_K_M", + "deepseek-r1-distill-llama-70B-F4": + "ai/deepseek-r1-distill-llama:70B-Q4_K_M", "deepseek-r1-distill-llama-8B-F16": "ai/deepseek-r1-distill-llama:8B-F16", - "deepseek-r1-distill-llama-8B-Q4": "ai/deepseek-r1-distill-llama:8B-Q4_K_M" + "deepseek-r1-distill-llama-8B-Q4": "ai/deepseek-r1-distill-llama:8B-Q4_K_M", }; constructor(options: LLMOptions) { @@ -54,7 +54,7 @@ class Docker extends OpenAI implements ModelInstaller { if (this.model && this.modelMap[this.model]) { this.model = this.modelMap[this.model]; } - + // Check if Docker Model Runner is active and enable it if needed this.ensureModelRunnerEnabled(); } @@ -67,10 +67,18 @@ class Docker extends OpenAI implements ModelInstaller { try { // Check if the Model Runner service is running on the expected port const isRunning = await this.isPortBound(12434); - + if (!isRunning) { - console.log("Docker Model Runner not detected. Attempting to enable it..."); - await this.executeDockerCommand(['desktop', 'enable', 'model-runner', '--tcp', '12434']); + console.log( + "Docker Model Runner not detected. Attempting to enable it...", + ); + await this.executeDockerCommand([ + "desktop", + "enable", + "model-runner", + "--tcp", + "12434", + ]); console.log("Docker Model Runner has been enabled on port 12434"); } } catch (error) { @@ -81,63 +89,50 @@ class Docker extends OpenAI implements ModelInstaller { /** * Checks if a port is currently bound/in use */ - private isPortBound(port: number): Promise { - return new Promise((resolve) => { - const req = http.request({ - method: 'HEAD', - host: 'localhost', - port: port, - timeout: 1000, - path: '/' - }, () => { - // If we can connect, the port is in use - resolve(true); + private async isPortBound(port: number): Promise { + try { + await this.fetch(`http://localhost:${port}`, { + method: "HEAD", + signal: AbortSignal.timeout(1000), }); - - req.on('error', () => { - // If we can't connect, the port is not in use - resolve(false); - }); - - req.on('timeout', () => { - req.destroy(); - resolve(false); - }); - - req.end(); - }); + return true; + } catch (e) { + return false; + } } private async executeDockerCommand( args: string[], - signal?: AbortSignal + signal?: AbortSignal, ): Promise<{ stdout: string; stderr: string }> { return new Promise((resolve, reject) => { - const proc = spawn('docker', args, { shell: true }); + const proc = spawn("docker", args, { shell: true }); - let stdout = ''; - let stderr = ''; + let stdout = ""; + let stderr = ""; - proc.stdout.on('data', (data) => { + proc.stdout.on("data", (data) => { stdout += data.toString(); }); - proc.stderr.on('data', (data) => { + proc.stderr.on("data", (data) => { stderr += data.toString(); }); - proc.on('close', (code) => { + proc.on("close", (code) => { if (code === 0) { resolve({ stdout, stderr }); } else { - reject(new Error(`Docker command failed with code ${code}: ${stderr}`)); + reject( + new Error(`Docker command failed with code ${code}: ${stderr}`), + ); } }); if (signal) { - signal.addEventListener('abort', () => { + signal.addEventListener("abort", () => { proc.kill(); - reject(new Error('Docker command was aborted')); + reject(new Error("Docker command was aborted")); }); } }); @@ -146,9 +141,15 @@ class Docker extends OpenAI implements ModelInstaller { async listModels(): Promise { try { // Execute docker model ls and parse the output - const { stdout } = await this.executeDockerCommand(['model', 'ls', '--format', '{{.Repository}}/{{.Tag}}']); - return stdout.split('\n') - .map(line => line.trim()) + const { stdout } = await this.executeDockerCommand([ + "model", + "ls", + "--format", + "{{.Repository}}/{{.Tag}}", + ]); + return stdout + .split("\n") + .map((line) => line.trim()) .filter(Boolean); } catch (error) { console.error("Failed to list Docker models:", error); @@ -159,7 +160,7 @@ class Docker extends OpenAI implements ModelInstaller { async installModel( modelName: string, signal: AbortSignal, - progressReporter?: (task: string, increment: number, total: number) => void + progressReporter?: (task: string, increment: number, total: number) => void, ): Promise { const targetModel = this.modelMap[modelName] || modelName; @@ -168,19 +169,29 @@ class Docker extends OpenAI implements ModelInstaller { progressReporter?.(`Installing Docker model ${targetModel}`, 0, 100); // Pull the model - const { stdout, stderr } = await this.executeDockerCommand(['model', 'pull', targetModel], signal); + const { stdout, stderr } = await this.executeDockerCommand( + ["model", "pull", targetModel], + signal, + ); // Report completion - progressReporter?.(`Docker model ${targetModel} installed successfully`, 100, 100); + progressReporter?.( + `Docker model ${targetModel} installed successfully`, + 100, + 100, + ); return { success: true, stdout, stderr }; } catch (error) { console.error(`Failed to install Docker model ${targetModel}:`, error); // Fix: Type check the error before accessing message property - const errorMessage = error instanceof Error ? error.message : String(error); - throw new Error(`Failed to install Docker model ${targetModel}: ${errorMessage}`); + const errorMessage = + error instanceof Error ? error.message : String(error); + throw new Error( + `Failed to install Docker model ${targetModel}: ${errorMessage}`, + ); } } } -export default Docker; \ No newline at end of file +export default Docker; From 8e589ed0e83eb609ffef08d5880b068646621c58 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 14:50:44 -0700 Subject: [PATCH 59/67] auto bump workflow --- .github/workflows/vscode-version-bump.yml | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/vscode-version-bump.yml diff --git a/.github/workflows/vscode-version-bump.yml b/.github/workflows/vscode-version-bump.yml new file mode 100644 index 000000000..4cb42e6f4 --- /dev/null +++ b/.github/workflows/vscode-version-bump.yml @@ -0,0 +1,75 @@ +name: VS Code Extension Version Bump +on: + schedule: + # Runs at 7 AM PST (15:00 UTC) every Friday + - cron: "0 15 * * 5" + workflow_dispatch: + # Allows manual triggering + +jobs: + version-bump: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history and tags + + - name: Use Node.js from .nvmrc + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Find and process version tags + run: | + # Find last v1.1.x-vscode tag that's at least 6 days old + CURRENT_TIMESTAMP=$(date +%s) + SIX_DAYS_AGO=$((CURRENT_TIMESTAMP - 6*24*60*60)) + + LAST_1_1_TAG=$(git for-each-ref --sort=-creatordate --format '%(refname:short) %(creatordate:unix)' refs/tags \ + | grep 'v1\.1\.[0-9]\+-vscode' \ + | while read tag timestamp; do + if [ $timestamp -le $SIX_DAYS_AGO ]; then + echo ${tag% *} + break + fi + done) + + if [ -z "$LAST_1_1_TAG" ]; then + echo "No suitable v1.1.x-vscode tag found" + exit 1 + fi + + # Find last v1.0.y-vscode tag + LAST_1_0_TAG=$(git tag --sort=-v:refname | grep '^v1\.0\.[0-9]\+-vscode' | head -n1) + if [ -z "$LAST_1_0_TAG" ]; then + echo "No v1.0.y-vscode tag found" + exit 1 + fi + + # Extract the y number and increment it + Y_NUMBER=$(echo $LAST_1_0_TAG | sed 's/v1\.0\.\([0-9]\+\)-vscode/\1/') + NEXT_Y=$((Y_NUMBER + 1)) + NEW_BRANCH="v1.0.${NEXT_Y}-vscode" + NEW_VERSION="1.0.${NEXT_Y}" + + # Create new branch from the v1.1.x tag + git checkout $LAST_1_1_TAG + git checkout -b $NEW_BRANCH + + # Update the version in package.json + jq ".version = \"$NEW_VERSION\"" extensions/vscode/package.json > temp.json && mv temp.json extensions/vscode/package.json + + # Configure git + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + + # Commit and push changes + git add extensions/vscode/package.json + git commit -m "Bump VS Code extension to ${NEW_VERSION}" + git push origin $NEW_BRANCH + + - name: Check for errors + if: failure() + run: | + echo "::error::Failed to process version tags and create new branch" From 735a1b658ef57a7a564fa50b3b98008054863ae5 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 14:51:30 -0700 Subject: [PATCH 60/67] better logging --- .github/workflows/vscode-version-bump.yml | 40 +++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vscode-version-bump.yml b/.github/workflows/vscode-version-bump.yml index 4cb42e6f4..39dc5b7f1 100644 --- a/.github/workflows/vscode-version-bump.yml +++ b/.github/workflows/vscode-version-bump.yml @@ -22,9 +22,16 @@ jobs: - name: Find and process version tags run: | + echo "Starting version bump process..." + # Find last v1.1.x-vscode tag that's at least 6 days old CURRENT_TIMESTAMP=$(date +%s) SIX_DAYS_AGO=$((CURRENT_TIMESTAMP - 6*24*60*60)) + echo "Current timestamp: $(date -d @${CURRENT_TIMESTAMP})" + echo "Six days ago: $(date -d @${SIX_DAYS_AGO})" + + echo "Looking for v1.1.x-vscode tags..." + git for-each-ref --sort=-creatordate --format '%(refname:short) %(creatordate:iso)' refs/tags | grep 'v1\.1\.[0-9]\+-vscode' || echo "No matching tags found" LAST_1_1_TAG=$(git for-each-ref --sort=-creatordate --format '%(refname:short) %(creatordate:unix)' refs/tags \ | grep 'v1\.1\.[0-9]\+-vscode' \ @@ -35,15 +42,20 @@ jobs: fi done) + echo "Selected v1.1.x tag: $LAST_1_1_TAG" if [ -z "$LAST_1_1_TAG" ]; then - echo "No suitable v1.1.x-vscode tag found" + echo "::error::No suitable v1.1.x-vscode tag found" exit 1 fi # Find last v1.0.y-vscode tag + echo "Looking for v1.0.y-vscode tags..." + git tag --sort=-v:refname | grep '^v1\.0\.[0-9]\+-vscode' || echo "No matching tags found" + LAST_1_0_TAG=$(git tag --sort=-v:refname | grep '^v1\.0\.[0-9]\+-vscode' | head -n1) + echo "Selected v1.0.y tag: $LAST_1_0_TAG" if [ -z "$LAST_1_0_TAG" ]; then - echo "No v1.0.y-vscode tag found" + echo "::error::No v1.0.y-vscode tag found" exit 1 fi @@ -52,24 +64,48 @@ jobs: NEXT_Y=$((Y_NUMBER + 1)) NEW_BRANCH="v1.0.${NEXT_Y}-vscode" NEW_VERSION="1.0.${NEXT_Y}" + echo "Current Y number: $Y_NUMBER" + echo "Next Y number: $NEXT_Y" + echo "New branch name: $NEW_BRANCH" + echo "New version: $NEW_VERSION" # Create new branch from the v1.1.x tag + echo "Creating new branch from $LAST_1_1_TAG..." git checkout $LAST_1_1_TAG git checkout -b $NEW_BRANCH # Update the version in package.json + echo "Current package.json version:" + cat extensions/vscode/package.json | grep version + + echo "Updating version in package.json..." jq ".version = \"$NEW_VERSION\"" extensions/vscode/package.json > temp.json && mv temp.json extensions/vscode/package.json + echo "New package.json version:" + cat extensions/vscode/package.json | grep version + # Configure git + echo "Configuring git..." git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" # Commit and push changes + echo "Committing changes..." git add extensions/vscode/package.json git commit -m "Bump VS Code extension to ${NEW_VERSION}" + + echo "Pushing branch to origin..." git push origin $NEW_BRANCH + echo "Version bump process completed successfully!" + - name: Check for errors if: failure() run: | echo "::error::Failed to process version tags and create new branch" + echo "Last few lines of git log:" + git log -n 5 --oneline + echo "Current git status:" + git status + echo "Current branches:" + git branch -a From 9593e9326d1ad81b49e805d6a9b8dfe0c5b5a1b0 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 14:57:11 -0700 Subject: [PATCH 61/67] automatically bump pre-release version after pre-release --- .github/workflows/preview.yaml | 39 +++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 7408cf76f..80eaa4931 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -1,4 +1,4 @@ -name: Publish Preview Extension +name: Publish Pre-release Extension on: release: @@ -207,6 +207,7 @@ jobs: if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true' permissions: contents: write + pull-requests: write steps: # 0. Setup git - name: Checkout @@ -242,12 +243,44 @@ jobs: cd extensions/vscode npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - # 4. Update the package.json version and push changes + # 4. Create PR with version bump + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Create PR branch + run: | + BRANCH_NAME="chore/bump-vscode-version-$(date +%Y%m%d-%H%M%S)" + git checkout -b $BRANCH_NAME + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + + - name: Bump version in package.json + run: | + cd extensions/vscode + npm version patch --no-git-tag-version + VERSION=$(node -p "require('./package.json').version") + echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.CI_GITHUB_TOKEN }} + commit-message: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}" + title: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}" + body: | + Automated PR to bump the VS Code extension version after successful pre-release publication. + + - Bumped version in extensions/vscode/package.json to ${{ env.NEW_VERSION }} + branch: ${{ env.BRANCH_NAME }} + base: main + delete-branch: true + + # 5. Update version in package.json # - name: Update version in package.json # run: | # cd extensions/vscode # npm version patch - # - name: Commit changes # run: | # git config --local user.email "action@github.com" From eb6735ee25da93e01a7b09223960b8975b41d898 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sat, 5 Apr 2025 15:15:56 -0700 Subject: [PATCH 62/67] fix: promptblock parsing --- extensions/vscode/package-lock.json | 4 +- .../Lump/sections/PromptsSection.tsx | 2 +- .../utils/resolveEditorContent.ts | 40 +++++++++---------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c03168bf9..108520e49 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.20", + "version": "1.1.21", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.20", + "version": "1.1.21", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx index 8ea7a37d3..25c9abc16 100644 --- a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx @@ -108,7 +108,7 @@ export function PromptsSection() { }); return ( -
+
{sortedCommands.map((prompt) => ( ( (parts, p) => { switch (p.type) { - case Paragraph.name: { - const [text, ctxItems, foundSlashCommand] = resolveParagraph(p); + case PromptBlock.name: { + slashCommandName = resvolePromptBlock(p); + } - // Only take the first slash command - if (foundSlashCommand && !slashCommandName) { - slashCommandName = foundSlashCommand; - } + case Paragraph.name: { + const [text, ctxItems] = resolveParagraph(p); contextItemAttrs.push(...ctxItems); @@ -204,10 +203,13 @@ function processSlashCommand( let input: string; - // Get input and add text of last slash command text back in to last text node + /** + * Although we no longer render slash command tags from the editor, + * we are inserting a slash command style text back into the text here. + * This is a a hack, but there's a number of assumptions in `core` that there + * is slash command text at the beginning of the text in order to process slash commands. + */ if (lastTextPart) { - // TODO: only input the slash cmd is currently using - // improove this comment input = renderChatMessage({ role: "user", content: lastTextPart.text, @@ -309,11 +311,12 @@ function findLastIndex( return -1; // if no element satisfies the predicate } -function resolveParagraph( - p: JSONContent, -): [string, MentionAttrs[], string | undefined] { +function resvolePromptBlock(p: JSONContent): string | undefined { + return p.attrs?.item.name; +} + +function resolveParagraph(p: JSONContent): [string, MentionAttrs[]] { const contextItems: MentionAttrs[] = []; - let slashCommand: string | undefined; const text = (p.content || []) .map((child) => { @@ -323,12 +326,7 @@ function resolveParagraph( case Mention.name: contextItems.push(child.attrs as MentionAttrs); return child.attrs?.renderInlineAs ?? child.attrs?.label; - case SlashCommand.name: - if (!slashCommand) { - slashCommand = child.attrs?.id; - return ""; - } - return child.attrs?.label; + default: console.warn("Unexpected child type", child.type); return ""; @@ -337,5 +335,5 @@ function resolveParagraph( .join("") .trimStart(); - return [text, contextItems, slashCommand]; + return [text, contextItems]; } From 2a3331db4886687cec48f4e8aa2056b52a0ca0cf Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 15:23:57 -0700 Subject: [PATCH 63/67] auto-release workflow --- .github/workflows/auto-release.yml | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/auto-release.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 000000000..11589da2a --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,52 @@ +name: Create Automatic Release + +on: + schedule: + - cron: "0 17 * * *" # Run at 9am PST (17:00 UTC) every day + workflow_dispatch: # Keep manual trigger option + +jobs: + create-release: + runs-on: ubuntu-latest + permissions: + contents: write # Needed for creating releases + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Important for getting all tags and commits + + - name: Get latest tag + id: get_latest_tag + run: | + # Get the latest tag ending in -vscode or default to v1.1.0-vscode if none exists + latest_tag=$(git tag --sort=-creatordate | grep -E "-vscode$" | head -n 1 || echo "v1.1.0-vscode") + echo "Latest tag: $latest_tag" + echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV + + - name: Generate next version + id: generate_version + run: | + # Extract version numbers (handle the -vscode suffix) + version=${LATEST_TAG#v} # Remove v prefix + version=${version%-vscode} # Remove -vscode suffix + IFS='.' read -ra VERSION_PARTS <<< "$version" + + # Increment patch version + ((VERSION_PARTS[2]++)) + + # Create new version string with -vscode suffix + new_version="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}-vscode" + echo "New version will be: $new_version" + echo "NEW_VERSION=$new_version" >> $GITHUB_ENV + + - name: Create Release + env: + GH_TOKEN: ${{ github.token }} + run: | + # Create a new draft release with auto-generated release notes + gh release create "$NEW_VERSION" \ + --generate-notes \ + --title "$NEW_VERSION" \ + --draft \ + --latest From 9cb7977d27373d81c3d053e753e7231cb36f9faa Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 15:24:26 -0700 Subject: [PATCH 64/67] fix cron --- .github/workflows/auto-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 11589da2a..98eabb0da 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -2,7 +2,7 @@ name: Create Automatic Release on: schedule: - - cron: "0 17 * * *" # Run at 9am PST (17:00 UTC) every day + - cron: "0 17 * * 1,3,5" # Run at 9am PST (17:00 UTC) on Monday, Wednesday, Friday workflow_dispatch: # Keep manual trigger option jobs: From 10b801f6409624e47a788667a4ecee82700c559e Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 15:28:01 -0700 Subject: [PATCH 65/67] create jetbrains draft release --- .github/workflows/auto-release.yml | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 98eabb0da..5985624de 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: # Keep manual trigger option jobs: - create-release: + create-vscode-release: runs-on: ubuntu-latest permissions: contents: write # Needed for creating releases @@ -50,3 +50,50 @@ jobs: --title "$NEW_VERSION" \ --draft \ --latest + --prerelease + + create-jetbrains-release: + runs-on: ubuntu-latest + permissions: + contents: write # Needed for creating releases + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Important for getting all tags and commits + + - name: Get latest tag + id: get_latest_tag + run: | + # Get the latest tag ending in -jetbrains or default to v1.1.0-jetbrains if none exists + latest_tag=$(git tag --sort=-creatordate | grep -E "-jetbrains$" | head -n 1 || echo "v1.1.0-jetbrains") + echo "Latest tag: $latest_tag" + echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV + + - name: Generate next version + id: generate_version + run: | + # Extract version numbers (handle the -jetbrains suffix) + version=${LATEST_TAG#v} # Remove v prefix + version=${version%-jetbrains} # Remove -jetbrains suffix + IFS='.' read -ra VERSION_PARTS <<< "$version" + + # Increment patch version + ((VERSION_PARTS[2]++)) + + # Create new version string with -jetbrains suffix + new_version="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}-jetbrains" + echo "New version will be: $new_version" + echo "NEW_VERSION=$new_version" >> $GITHUB_ENV + + - name: Create Release + env: + GH_TOKEN: ${{ github.token }} + run: | + # Create a new draft release with auto-generated release notes + gh release create "$NEW_VERSION" \ + --generate-notes \ + --title "$NEW_VERSION" \ + --draft \ + --latest + --prerelease From a4bcd83d0635c0ca7084193fb1836615d89d562d Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 20:30:15 -0700 Subject: [PATCH 66/67] semantic release for config-yaml --- .github/workflows/release-config-yaml.yml | 46 +++++++++++++++++++++++ packages/config-yaml/release.config.js | 9 +++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/release-config-yaml.yml create mode 100644 packages/config-yaml/release.config.js diff --git a/.github/workflows/release-config-yaml.yml b/.github/workflows/release-config-yaml.yml new file mode 100644 index 000000000..0847f5c0c --- /dev/null +++ b/.github/workflows/release-config-yaml.yml @@ -0,0 +1,46 @@ +name: Release @continuedev/config-yaml + +on: + push: + branches: + - main + paths: + - "packages/config-yaml/**" + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use Node.js from .nvmrc + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Install dependencies + run: | + cd packages/config-yaml + npm ci + + - name: Build + run: | + cd packages/config-yaml + npm run build + + - name: Run tests + run: | + cd packages/config-yaml + npm test + + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + cd packages/config-yaml + npx semantic-release diff --git a/packages/config-yaml/release.config.js b/packages/config-yaml/release.config.js new file mode 100644 index 000000000..6f8c41a66 --- /dev/null +++ b/packages/config-yaml/release.config.js @@ -0,0 +1,9 @@ +export default { + branches: ['main'], + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + '@semantic-release/npm', + '@semantic-release/github', + ], +} \ No newline at end of file From 6b3b26bb84914d4845e9079edb9a08526fdee9e1 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Apr 2025 22:01:50 -0700 Subject: [PATCH 67/67] cli for linting config-yaml --- packages/config-yaml/package-lock.json | 22 +++++++++------ packages/config-yaml/package.json | 4 +++ packages/config-yaml/src/cli.ts | 38 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 packages/config-yaml/src/cli.ts diff --git a/packages/config-yaml/package-lock.json b/packages/config-yaml/package-lock.json index 39d55afb1..bd174fa96 100644 --- a/packages/config-yaml/package-lock.json +++ b/packages/config-yaml/package-lock.json @@ -1,20 +1,24 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.52", + "version": "1.0.72", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/config-yaml", - "version": "1.0.52", + "version": "1.0.72", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", "zod": "^3.24.2" }, + "bin": { + "config-yaml": "dist/cli.js" + }, "devDependencies": { "@types/jest": "^29.5.14", + "@types/node": "^20.0.0", "cross-env": "^7.0.3", "jest": "^29.7.0", "ts-jest": "^29.2.3", @@ -1051,12 +1055,12 @@ } }, "node_modules/@types/node": { - "version": "18.19.39", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", - "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", + "version": "20.17.30", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz", + "integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==", "dev": true, "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "node_modules/@types/stack-utils": { @@ -3622,9 +3626,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "dev": true }, "node_modules/update-browserslist-db": { diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 73af0687e..0f6e6b82c 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -5,6 +5,9 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "type": "module", + "bin": { + "@continuedev/config-yaml": "./dist/cli.js" + }, "scripts": { "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "build": "tsc" @@ -18,6 +21,7 @@ }, "devDependencies": { "@types/jest": "^29.5.14", + "@types/node": "^20.0.0", "cross-env": "^7.0.3", "jest": "^29.7.0", "ts-jest": "^29.2.3", diff --git a/packages/config-yaml/src/cli.ts b/packages/config-yaml/src/cli.ts new file mode 100644 index 000000000..24ac2f6df --- /dev/null +++ b/packages/config-yaml/src/cli.ts @@ -0,0 +1,38 @@ +#!/usr/bin/env node + +import { readFileSync } from "fs"; +import { parseConfigYaml } from "./load/unroll.js"; +import { validateConfigYaml } from "./validation.js"; + +async function main() { + const filePath = process.argv[2]; + if (!filePath) { + console.error("Please provide a YAML file path"); + process.exit(1); + } + + try { + // Read and parse the YAML file + const fileContents = readFileSync(filePath, "utf-8"); + const parsedYaml = parseConfigYaml(fileContents); + + // Validate the config + const validationErrors = validateConfigYaml(parsedYaml); + + if (validationErrors.length === 0) { + console.log("✅ Config file is valid!"); + process.exit(0); + } else { + console.error("❌ Config file validation failed:"); + validationErrors.forEach((error) => { + console.error(`- ${error.message}`); + }); + process.exit(1); + } + } catch (error: any) { + console.error("Error processing file:", error.message); + process.exit(1); + } +} + +main().catch(console.error);