diff --git a/.changes/unreleased/Added-20240129-210550.yaml b/.changes/unreleased/Added-20240129-210550.yaml new file mode 100644 index 000000000..bcadeee63 --- /dev/null +++ b/.changes/unreleased/Added-20240129-210550.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Full-text search index for retrieval +time: 2024-01-29T21:05:50.216548-08:00 diff --git a/.changes/unreleased/Added-20240130-123143.yaml b/.changes/unreleased/Added-20240130-123143.yaml new file mode 100644 index 000000000..419c65e6b --- /dev/null +++ b/.changes/unreleased/Added-20240130-123143.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Docs context provider +time: 2024-01-30T12:31:43.521306-08:00 diff --git a/.changes/unreleased/Added-20240130-130332.yaml b/.changes/unreleased/Added-20240130-130332.yaml new file mode 100644 index 000000000..75bd1ca2e --- /dev/null +++ b/.changes/unreleased/Added-20240130-130332.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: CodeLlama-70b support +time: 2024-01-30T13:03:32.287428-08:00 diff --git a/.changes/unreleased/Fixed-20240130-130315.yaml b/.changes/unreleased/Fixed-20240130-130315.yaml new file mode 100644 index 000000000..ddc4186b8 --- /dev/null +++ b/.changes/unreleased/Fixed-20240130-130315.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Fixed +body: Fixed proxy setting in config.json +time: 2024-01-30T13:03:15.8294-08:00 diff --git a/.continueignore b/.continueignore index 4f17aba35..1086d8297 100644 --- a/.continueignore +++ b/.continueignore @@ -1,2 +1,3 @@ **/*.run.xml -archive/**/* \ No newline at end of file +archive/**/* +extensions/vscode/models/**/* \ No newline at end of file diff --git a/.gitignore b/.gitignore index db987eda8..f8d2c8a18 100644 --- a/.gitignore +++ b/.gitignore @@ -151,4 +151,5 @@ codeql continue_server.build continue_server.dist -Icon \ No newline at end of file +Icon +Icon? \ No newline at end of file diff --git a/core/commands/util.ts b/core/commands/util.ts index 17e0151f0..e9ec5943d 100644 --- a/core/commands/util.ts +++ b/core/commands/util.ts @@ -15,10 +15,10 @@ export function contextItemToRangeInFileWithContents( const lines = item.name.split("(")[1].split(")")[0].split("-"); const rif: RangeInFileWithContents = { - filepath: item.description, + filepath: item.description.split(" (")[0], range: { start: { - line: parseInt(lines[0]) - 1, + line: parseInt(lines[0]), character: 0, }, end: { diff --git a/core/config/default.ts b/core/config/default.ts index fc52f24c3..037c7d15b 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -12,11 +12,6 @@ const defaultConfig: SerializedContinueConfig = { provider: "free-trial", model: "gpt-4-vision-preview", }, - { - title: "Phind CodeLlama (Free Trial)", - provider: "free-trial", - model: "phind-codellama-34b", - }, { title: "Gemini Pro (Free Trial)", provider: "free-trial", diff --git a/core/context/providers/CodebaseContextProvider.ts b/core/context/providers/CodebaseContextProvider.ts index c79d8cc60..5c31fcc67 100644 --- a/core/context/providers/CodebaseContextProvider.ts +++ b/core/context/providers/CodebaseContextProvider.ts @@ -4,7 +4,6 @@ import { ContextProviderDescription, ContextProviderExtras, } from "../.."; -import { retrieveContextItemsFromEmbeddings } from "../retrieval"; class CodebaseContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { @@ -18,6 +17,7 @@ class CodebaseContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras ): Promise { + const { retrieveContextItemsFromEmbeddings } = await import("../retrieval"); return retrieveContextItemsFromEmbeddings(extras, this.options, undefined); } async load(): Promise {} diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 3875dd3a0..803628f0c 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -36,13 +36,15 @@ class DocsContextProvider extends BaseContextProvider { return [ ...chunks .map((chunk) => ({ - name: chunk.filepath - .split("/") - .slice(1) - .join("/") - .split("/tree/main/") - .slice(1) - .join("/"), // chunk.otherMetadata?.title || chunk.filepath, + name: chunk.filepath.includes("/tree/main") // For display of GitHub files + ? chunk.filepath + .split("/") + .slice(1) + .join("/") + .split("/tree/main/") + .slice(1) + .join("/") + : chunk.otherMetadata?.title || chunk.filepath, description: new URL(chunk.filepath, query).toString(), content: chunk.content, })) diff --git a/core/context/providers/FolderContextProvider.ts b/core/context/providers/FolderContextProvider.ts index 10ad971d5..81955cb1e 100644 --- a/core/context/providers/FolderContextProvider.ts +++ b/core/context/providers/FolderContextProvider.ts @@ -7,7 +7,6 @@ import { LoadSubmenuItemsArgs, } from "../.."; import { getBasename, getLastNPathParts } from "../../util"; -import { retrieveContextItemsFromEmbeddings } from "../retrieval"; class FolderContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { @@ -21,6 +20,7 @@ class FolderContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras ): Promise { + const { retrieveContextItemsFromEmbeddings } = await import("../retrieval"); return retrieveContextItemsFromEmbeddings(extras, this.options, query); } async loadSubmenuItems( diff --git a/core/context/retrieval.ts b/core/context/retrieval.ts index 3e72a74ec..4ffc583cc 100644 --- a/core/context/retrieval.ts +++ b/core/context/retrieval.ts @@ -1,10 +1,8 @@ -import { - Chunk, - ContextItem, - ContextProviderExtras, - ILLM, - ModelProvider, -} from ".."; +import { Chunk, ContextItem, ContextProviderExtras, ILLM } from ".."; +import { FullTextSearchCodebaseIndex } from "../indexing/FullTextSearch"; +import { ChunkCodebaseIndex } from "../indexing/chunk/ChunkCodebaseIndex"; +import { IndexTag } from "../indexing/types"; +import { llmCanGenerateInParallel } from "../llm"; import { getBasename } from "../util"; const RERANK_PROMPT = ( @@ -47,28 +45,6 @@ ${document} Relevant: `; -const PARALLEL_PROVIDERS: ModelProvider[] = [ - "anthropic", - "bedrock", - "deepinfra", - "gemini", - "google-palm", - "huggingface-inference-api", - "huggingface-tgi", - "mistral", - "free-trial", - "replicate", - "together", -]; - -function llmCanGenerateInParallel(llm: ILLM): boolean { - if (llm.providerName === "openai") { - return llm.model.includes("gpt"); - } - - return PARALLEL_PROVIDERS.includes(llm.providerName); -} - async function scoreChunk( chunk: Chunk, llm: ILLM, @@ -133,19 +109,55 @@ export async function retrieveContextItemsFromEmbeddings( return []; } - const nRetrieve = options?.nRetrieve || 20; - const nFinal = options?.nFinal || 8; + const nFinal = options?.nFinal || 10; const useReranking = llmCanGenerateInParallel(extras.llm) && (options?.useReranking === undefined ? false : options?.useReranking); + const nRetrieve = useReranking === false ? nFinal : options?.nRetrieve || 20; - // Similarity search - let results = await extras.ide.retrieveChunks( + const ftsIndex = new FullTextSearchCodebaseIndex(); + const workspaceDirs = await extras.ide.getWorkspaceDirs(); + const branches = await Promise.all( + workspaceDirs.map((dir) => extras.ide.getBranch(dir)) + ); + const tags: IndexTag[] = workspaceDirs.map((directory, i) => ({ + directory, + branch: branches[i], + artifactId: ChunkCodebaseIndex.artifactId, + })); + + let ftsResults = await ftsIndex.retrieve( + tags, + extras.fullInput.trim().split(" ").join(" OR "), + nRetrieve / 2, + filterDirectory, + undefined + ); + + let vecResults = await extras.ide.retrieveChunks( extras.fullInput, - useReranking === false ? nFinal : nRetrieve, + nRetrieve, filterDirectory ); + // Now combine these (de-duplicate) and re-rank + let results = [...ftsResults]; + for (const vecResult of vecResults) { + if (results.length >= nRetrieve) { + break; + } + if ( + !ftsResults.find( + (r) => + r.filepath === vecResult.filepath && + r.startLine === vecResult.startLine && + r.endLine === vecResult.endLine + ) + ) { + results.push(vecResult); + } + } + // Re-ranking if (useReranking) { results = await rerank(results, extras.llm, extras.fullInput, nFinal); diff --git a/core/ide/filesystem.ts b/core/ide/filesystem.ts index 2635a05cb..ad79c7e1f 100644 --- a/core/ide/filesystem.ts +++ b/core/ide/filesystem.ts @@ -28,6 +28,13 @@ class FileSystemIde implements IDE { getTerminalContents(): Promise { return Promise.resolve(""); } + showLines( + filepath: string, + startLine: number, + endLine: number + ): Promise { + return Promise.resolve(); + } listWorkspaceContents(): Promise { return new Promise((resolve, reject) => { fs.readdir("/tmp/continue", (err, files) => { @@ -94,6 +101,10 @@ class FileSystemIde implements IDE { return Promise.resolve(); } + getBranch(dir: string): Promise { + return Promise.resolve(""); + } + async verticalDiffUpdate( filepath: string, startLine: number, diff --git a/core/ide/index.ts b/core/ide/index.ts index 66e865775..02c808634 100644 --- a/core/ide/index.ts +++ b/core/ide/index.ts @@ -30,6 +30,14 @@ export class ExtensionIde implements IDE { return await r("getWorkspaceDirs"); } + async showLines( + filepath: string, + startLine: number, + endLine: number + ): Promise { + return await r("showLines", { filepath, startLine, endLine }); + } + async listFolders(): Promise { return await r("listFolders"); } @@ -112,6 +120,10 @@ export class ExtensionIde implements IDE { return r("sendChunkForFile", { chunk, embedding, tags }); } + async getBranch(dir: string): Promise { + return r("getBranch", { dir }); + } + retrieveChunks( text: string, n: number, diff --git a/core/index.d.ts b/core/index.d.ts index 4c00ad93e..20763fc93 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -300,6 +300,11 @@ export interface IDE { runCommand(command: string): Promise; saveFile(filepath: string): Promise; readFile(filepath: string): Promise; + showLines( + filepath: string, + startLine: number, + endLine: number + ): Promise; showDiff( filepath: string, newContents: string, @@ -316,6 +321,7 @@ export interface IDE { getSearchResults(query: string): Promise; subprocess(command: string): Promise<[string, string]>; getProblems(filepath?: string | undefined): Promise; + getBranch(dir: string): Promise; // Embeddings /** @@ -398,6 +404,7 @@ type TemplateType = | "deepseek" | "xwin-coder" | "neural-chat" + | "codellama-70b" | "llava"; type ModelProvider = diff --git a/core/indexing/FullTextSearch.ts b/core/indexing/FullTextSearch.ts new file mode 100644 index 000000000..c7720bbf5 --- /dev/null +++ b/core/indexing/FullTextSearch.ts @@ -0,0 +1,135 @@ +import { Chunk, IndexingProgressUpdate } from ".."; +import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex"; +import { + CodebaseIndex, + IndexResultType, + IndexTag, + MarkCompleteCallback, + RefreshIndexResults, +} from "./types"; + +export class FullTextSearchCodebaseIndex implements CodebaseIndex { + artifactId: string = "sqliteFts"; + + private async _createTables(db: DatabaseConnection) { + await db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS fts USING fts5( + path, + content, + tokenize = 'trigram' + )`); + + await db.exec(`CREATE TABLE IF NOT EXISTS fts_metadata ( + id INTEGER PRIMARY KEY, + path TEXT NOT NULL, + cacheKey TEXT NOT NULL, + chunkId INTEGER NOT NULL, + FOREIGN KEY (chunkId) REFERENCES chunks (id), + FOREIGN KEY (id) REFERENCES fts (rowid) + )`); + } + + async *update( + tag: IndexTag, + results: RefreshIndexResults, + markComplete: MarkCompleteCallback + ): AsyncGenerator { + const db = await SqliteDb.get(); + await this._createTables(db); + + for (let i = 0; i < results.compute.length; i++) { + const item = results.compute[i]; + + // Insert chunks + const chunks = await db.all( + `SELECT * FROM chunks WHERE path = ? AND cacheKey = ?`, + [item.path, item.cacheKey] + ); + + for (let chunk of chunks) { + const { lastID } = await db.run( + `INSERT INTO fts (path, content) VALUES (?, ?)`, + [item.path, chunk.content] + ); + await db.run( + `INSERT INTO fts_metadata (id, path, cacheKey, chunkId) VALUES (?, ?, ?, ?)`, + [lastID, item.path, item.cacheKey, chunk.id] + ); + } + + yield { + progress: i / results.compute.length, + desc: `Indexing ${item.path}`, + }; + markComplete([item], IndexResultType.Compute); + } + + // Add tag + for (const item of results.addTag) { + markComplete([item], IndexResultType.AddTag); + } + + // Remove tag + for (const item of results.removeTag) { + markComplete([item], IndexResultType.RemoveTag); + } + + // Delete + for (const item of results.del) { + const { lastID } = await db.run( + `DELETE FROM fts_metadata WHERE path = ? AND cacheKey = ?`, + [item.path, item.cacheKey] + ); + await db.run(`DELETE FROM fts WHERE rowid = ?`, [lastID]); + + markComplete([item], IndexResultType.Delete); + } + } + + async retrieve( + tags: IndexTag[], + text: string, + n: number, + directory: string | undefined, + filterPaths: string[] | undefined + ): Promise { + const db = await SqliteDb.get(); + const tagStrings = tags.map(tagToString); + + const results = await db.all( + `SELECT fts_metadata.chunkId, fts_metadata.path, fts.content, rank + FROM fts + JOIN fts_metadata ON fts.rowid = fts_metadata.id + JOIN chunk_tags ON fts_metadata.chunkId = chunk_tags.chunkId + WHERE fts MATCH '${text.replace( + /\?/g, + "" + )}' AND chunk_tags.tag IN (${tagStrings.map(() => "?").join(",")}) + ${ + filterPaths + ? `AND fts_metadata.path IN (${filterPaths + .map(() => "?") + .join(",")})` + : "" + } + ORDER BY rank + LIMIT ?`, + [...tagStrings, ...(filterPaths || []), n] + ); + + const chunks = await db.all( + `SELECT * FROM chunks WHERE id IN (${results.map(() => "?").join(",")})`, + results.map((result) => result.chunkId) + ); + + return chunks.map((chunk) => { + return { + filepath: chunk.path, + index: chunk.index, + startLine: chunk.startLine, + endLine: chunk.endLine, + content: chunk.content, + digest: chunk.cacheKey, + }; + }); + } +} diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index fbeecc25f..792c01fd4 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -6,7 +6,7 @@ import { MAX_CHUNK_SIZE } from "../llm/constants"; import { getBasename } from "../util"; import { getLanceDbPath } from "../util/paths"; import { chunkDocument } from "./chunk/chunk"; -import { DatabaseConnection, SqliteDb } from "./refreshIndex"; +import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex"; import { CodebaseIndex, IndexResultType, @@ -15,10 +15,6 @@ import { RefreshIndexResults, } from "./types"; -export function tagToString(tag: IndexTag): string { - return `${tag.directory}::${tag.branch}::${tag.artifactId}`; -} - // LanceDB converts to lowercase, so names must all be lowercase interface LanceDbRow { uuid: string; diff --git a/core/indexing/chunk/ChunkCodebaseIndex.ts b/core/indexing/chunk/ChunkCodebaseIndex.ts new file mode 100644 index 000000000..477328365 --- /dev/null +++ b/core/indexing/chunk/ChunkCodebaseIndex.ts @@ -0,0 +1,127 @@ +import { IndexingProgressUpdate } from "../.."; +import { MAX_CHUNK_SIZE } from "../../llm/constants"; +import { getBasename } from "../../util"; +import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex"; +import { + CodebaseIndex, + IndexResultType, + IndexTag, + MarkCompleteCallback, + RefreshIndexResults, +} from "../types"; +import { chunkDocument } from "./chunk"; + +export class ChunkCodebaseIndex implements CodebaseIndex { + static artifactId: string = "chunks"; + artifactId: string = ChunkCodebaseIndex.artifactId; + + readFile: (filepath: string) => Promise; + constructor(readFile: (filepath: string) => Promise) { + this.readFile = readFile; + } + + private async _createTables(db: DatabaseConnection) { + await db.exec(`CREATE TABLE IF NOT EXISTS chunks ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + cacheKey TEXT NOT NULL, + path TEXT NOT NULL, + idx INTEGER NOT NULL, + startLine INTEGER NOT NULL, + endLine INTEGER NOT NULL, + content TEXT NOT NULL + )`); + + await db.exec(`CREATE TABLE IF NOT EXISTS chunk_tags ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + tag TEXT NOT NULL, + chunkId INTEGER NOT NULL, + FOREIGN KEY (chunkId) REFERENCES chunks (id) + )`); + } + + async *update( + tag: IndexTag, + results: RefreshIndexResults, + markComplete: MarkCompleteCallback + ): AsyncGenerator { + const db = await SqliteDb.get(); + await this._createTables(db); + const tagString = tagToString(tag); + + // Compute chunks for new files + const contents = await Promise.all( + results.compute.map(({ path }) => this.readFile(path)) + ); + for (let i = 0; i < results.compute.length; i++) { + const item = results.compute[i]; + + // Insert chunks + for await (let chunk of chunkDocument( + item.path, + contents[i], + MAX_CHUNK_SIZE, + item.cacheKey + )) { + const { lastID } = await db.run( + `INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)`, + [ + chunk.digest, + chunk.filepath, + chunk.index, + chunk.startLine, + chunk.endLine, + chunk.content, + ] + ); + + await db.run(`INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)`, [ + lastID, + tagString, + ]); + } + + yield { + progress: i / results.compute.length, + desc: `Chunking ${getBasename(item.path)}`, + }; + markComplete([item], IndexResultType.Compute); + } + + // Add tag + for (const item of results.addTag) { + const chunksWithPath = await db.all( + `SELECT * FROM chunks WHERE cacheKey = ?`, + [item.cacheKey] + ); + + for (const chunk of chunksWithPath) { + await db.run(`INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)`, [ + chunk.id, + tagString, + ]); + } + + markComplete([item], IndexResultType.AddTag); + } + + // Remove tag + for (const item of results.removeTag) { + await db.run(`DELETE FROM chunk_tags WHERE tag = ?`, [tagString]); + markComplete([item], IndexResultType.RemoveTag); + } + + // Delete + for (const item of results.del) { + const deleted = await db.run(`DELETE FROM chunks WHERE cacheKey = ?`, [ + item.cacheKey, + ]); + + // Delete from chunk_tags + await db.run(`DELETE FROM chunk_tags WHERE chunkId = ?`, [ + deleted.lastID, + ]); + + markComplete([item], IndexResultType.Delete); + } + } +} diff --git a/core/indexing/chunk/markdown.ts b/core/indexing/chunk/markdown.ts index 0ca92158c..0e0901cf0 100644 --- a/core/indexing/chunk/markdown.ts +++ b/core/indexing/chunk/markdown.ts @@ -58,14 +58,29 @@ export async function* markdownChunker( hLevel: number ): AsyncGenerator { if (countTokens(content, "gpt-4") <= maxChunkSize) { + const header = findHeader(content.split("\n")); yield { content, startLine: 0, endLine: content.split("\n").length, + otherMetadata: { + fragment: cleanFragment(header), + title: cleanHeader(header), + }, }; return; } else if (hLevel > 4) { - yield* basicChunker(content, maxChunkSize); + const header = findHeader(content.split("\n")); + + for (const chunk of basicChunker(content, maxChunkSize)) { + yield { + ...chunk, + otherMetadata: { + fragment: cleanFragment(header), + title: cleanHeader(header), + }, + }; + } return; } diff --git a/core/indexing/docs/crawl.ts b/core/indexing/docs/crawl.ts index 13b86c807..0152005f2 100644 --- a/core/indexing/docs/crawl.ts +++ b/core/indexing/docs/crawl.ts @@ -43,11 +43,16 @@ function shouldFilterPath(pathname: string, baseUrl: URL): boolean { return false; } -async function crawlLinks(path: string, baseUrl: URL, visited: Set) { +async function* crawlLinks( + path: string, + baseUrl: URL, + visited: Set +): AsyncGenerator { if (visited.has(path) || shouldFilterPath(path, baseUrl)) { return; } visited.add(path); + yield visited.size; const response = await fetch(new URL(path, baseUrl)); const text = await response.text(); @@ -71,8 +76,12 @@ async function crawlLinks(path: string, baseUrl: URL, visited: Set) { }); await Promise.all( - children.map((child) => crawlLinks(child, baseUrl, visited)) + children.map(async (child) => { + for await (const _ of crawlLinks(child, baseUrl, visited)) { + } + }) ); + yield visited.size; } async function crawlGithubRepo(baseUrl: URL) { @@ -116,25 +125,44 @@ async function crawlGithubRepo(baseUrl: URL) { return paths; } -export async function crawlSubpages(baseUrl: URL) { +export async function* crawlSubpages( + baseUrl: URL +): AsyncGenerator { // Special case for GitHub repos if (baseUrl.hostname === "github.com") { return crawlGithubRepo(baseUrl); } // First, check if the parent of the path redirects to the same page - const parentUrl = new URL(baseUrl); - parentUrl.pathname = parentUrl.pathname.split("/").slice(0, -1).join("/"); - const response = await fetch(parentUrl); - - let useParent = response.url === baseUrl.toString(); + if (baseUrl.pathname.endsWith("/")) { + baseUrl.pathname = baseUrl.pathname.slice(0, -1); + } + let realBaseUrl = new URL(baseUrl); + while (true) { + let parentUrl = new URL(realBaseUrl); + parentUrl.pathname = parentUrl.pathname.split("/").slice(0, -1).join("/"); + if ( + parentUrl.pathname === realBaseUrl.pathname || + parentUrl.pathname === "" + ) { + break; + } + const response = await fetch(parentUrl); + const redirected = response.url.toString() === baseUrl.toString() + "/"; + if (!redirected) { + break; + } + realBaseUrl = parentUrl; + } const visited = new Set(); - await crawlLinks( - (useParent ? parentUrl.pathname : baseUrl.pathname) || "/", - baseUrl, + for await (const count of crawlLinks( + realBaseUrl.pathname || "/", + realBaseUrl, visited - ); + )) { + yield count; + } return [...visited]; } diff --git a/core/indexing/docs/db.ts b/core/indexing/docs/db.ts index 760fc0f87..21a23d827 100644 --- a/core/indexing/docs/db.ts +++ b/core/indexing/docs/db.ts @@ -22,7 +22,7 @@ async function createDocsTable(db: Database) { db.exec(`CREATE TABLE IF NOT EXISTS docs ( id INTEGER PRIMARY KEY AUTOINCREMENT, title STRING NOT NULL, - baseUrl STRING NOT NULL + baseUrl STRING NOT NULL UNIQUE )`); } diff --git a/core/indexing/docs/index.ts b/core/indexing/docs/index.ts index 7b147dcdd..5c2ade9ac 100644 --- a/core/indexing/docs/index.ts +++ b/core/indexing/docs/index.ts @@ -16,7 +16,7 @@ export async function* indexDocs( embeddingsProvider: EmbeddingsProvider ): AsyncGenerator { const existingDocs = await listDocs(); - if (existingDocs.find((doc) => doc.title === title)) { + if (existingDocs.find((doc) => doc.baseUrl === baseUrl.toString())) { yield { progress: 1, desc: "Already indexed", @@ -29,8 +29,23 @@ export async function* indexDocs( desc: "Finding subpages", }; - let subpaths = await crawlSubpages(baseUrl); - console.log("Found subpaths", subpaths); + const subpathGenerator = crawlSubpages(baseUrl); + let { value, done } = await subpathGenerator.next(); + while (true) { + if (done) { + break; + } + yield { + progress: 0, + desc: `Finding subpages (${value})`, + }; + const next = await subpathGenerator.next(); + value = next.value; + done = next.done; + } + + let subpaths = value as string[]; + const chunks: Chunk[] = []; const embeddings: number[][] = []; @@ -53,7 +68,7 @@ export async function* indexDocs( for (let i = 0; i < subpaths.length; i++) { const subpath = subpaths[i]; yield { - progress: 1 / (subpaths.length + 1), + progress: Math.max(1, Math.floor(100 / (subpaths.length + 1))), desc: `${subpath}`, }; @@ -75,6 +90,7 @@ export async function* indexDocs( (chunk.otherMetadata?.fragment ? `#${chunk.otherMetadata.fragment}` : ""), + otherMetadata: chunk.otherMetadata, index, digest: subpath, }); diff --git a/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts b/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts index 333459f81..0b6f4fb22 100644 --- a/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts +++ b/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts @@ -16,13 +16,10 @@ class OpenAIEmbeddingsProvider extends BaseEmbeddingsProvider { if (apiBase?.endsWith("/")) { apiBase = apiBase.slice(0, -1); } - if (apiBase?.endsWith("/v1")) { - apiBase = apiBase.slice(0, -3); - } return await Promise.all( chunks.map(async (chunk) => { - const resp = await fetch(`${apiBase}/v1/embeddings`, { + const resp = await fetch(`${apiBase}/embeddings`, { method: "POST", body: JSON.stringify({ input: chunk, diff --git a/core/indexing/refreshIndex.ts b/core/indexing/refreshIndex.ts index 94ee72a9f..a37ae0077 100644 --- a/core/indexing/refreshIndex.ts +++ b/core/indexing/refreshIndex.ts @@ -15,6 +15,10 @@ import { export type DatabaseConnection = Database; +export function tagToString(tag: IndexTag): string { + return `${tag.directory}::${tag.branch}::${tag.artifactId}`; +} + export class SqliteDb { static db: DatabaseConnection | null = null; diff --git a/core/llm/index.ts b/core/llm/index.ts index b60f0f240..8b2d06765 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -6,11 +6,13 @@ import { LLMFullCompletionOptions, LLMOptions, LLMReturnValue, + ModelName, ModelProvider, RequestOptions, TemplateType, } from ".."; import { ideRequest, ideStreamRequest } from "../ide/messaging"; +import mergeJson from "../util/merge"; import { CONTEXT_LENGTH_FOR_MODEL, DEFAULT_ARGS, @@ -25,6 +27,7 @@ import { import { anthropicTemplateMessages, chatmlTemplateMessages, + codeLlama70bTemplateMessages, deepseekTemplateMessages, llama2TemplateMessages, llavaTemplateMessages, @@ -38,6 +41,7 @@ import { } from "./templates/chat"; import { alpacaEditPrompt, + codeLlama70bEditPrompt, codellamaEditPrompt, deepseekEditPrompt, mistralEditPrompt, @@ -49,11 +53,13 @@ import { xWinCoderEditPrompt, zephyrEditPrompt, } from "./templates/edit"; +import CompletionOptionsForModels from "./templates/options"; const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [ "lmstudio", "openai", "ollama", + "together", ]; const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ @@ -88,12 +94,33 @@ export function modelSupportsImages( return false; } +const PARALLEL_PROVIDERS: ModelProvider[] = [ + "anthropic", + "bedrock", + "deepinfra", + "gemini", + "google-palm", + "huggingface-inference-api", + "huggingface-tgi", + "mistral", + "free-trial", + "replicate", + "together", +]; + +export function llmCanGenerateInParallel(llm: ILLM): boolean { + if (llm.providerName === "openai") { + return llm.model.includes("gpt"); + } + + return PARALLEL_PROVIDERS.includes(llm.providerName); +} function autodetectTemplateType(model: string): TemplateType | undefined { const lower = model.toLowerCase(); - if (lower === "codellama-70b") { - return "none"; + if (lower.includes("codellama") && lower.includes("70b")) { + return "codellama-70b"; } if ( @@ -188,6 +215,7 @@ function autodetectTemplateFunction( "xwin-coder": xWinCoderTemplateMessages, "neural-chat": neuralChatTemplateMessages, llava: llavaTemplateMessages, + "codellama-70b": codeLlama70bTemplateMessages, none: null, }; @@ -228,6 +256,8 @@ function autodetectPromptTemplates( editTemplate = xWinCoderEditPrompt; } else if (templateType === "neural-chat") { editTemplate = neuralChatEditPrompt; + } else if (templateType === "codellama-70b") { + editTemplate = codeLlama70bEditPrompt; } else if (templateType) { editTemplate = simplestEditPrompt; } @@ -298,6 +328,12 @@ export abstract class BaseLLM implements ILLM { model: options.model || "gpt-4", maxTokens: options.completionOptions?.maxTokens || DEFAULT_MAX_TOKENS, }; + if (CompletionOptionsForModels[options.model as ModelName]) { + this.completionOptions = mergeJson( + this.completionOptions, + CompletionOptionsForModels[options.model as ModelName] || {} + ); + } this.requestOptions = options.requestOptions; this.promptTemplates = { ...autodetectPromptTemplates(options.model, templateType), @@ -380,11 +416,11 @@ export abstract class BaseLLM implements ILLM { .map(([key, value]) => `${key}: ${value}`) .join("\n"); return `Settings: - ${settings} +${settings} - ############################################ +############################################ - ${prompt}`; +${prompt}`; } private _logTokensGenerated(model: string, completion: string) { @@ -429,10 +465,10 @@ export abstract class BaseLLM implements ILLM { delete options.log; delete options.raw; - const completionOptions: CompletionOptions = { - ...this.completionOptions, - ...options, - }; + const completionOptions: CompletionOptions = mergeJson( + this.completionOptions, + options + ); return { completionOptions, log, raw }; } @@ -499,6 +535,10 @@ export abstract class BaseLLM implements ILLM { this._logTokensGenerated(completionOptions.model, completion); + if (log && this.writeLog) { + await this.writeLog(`Completion:\n\n${completion}\n\n`); + } + return { prompt, completion }; } @@ -539,6 +579,10 @@ export abstract class BaseLLM implements ILLM { const completion = await this._complete(prompt, completionOptions); this._logTokensGenerated(completionOptions.model, completion); + if (log && this.writeLog) { + await this.writeLog(`Completion:\n\n${completion}\n\n`); + } + return completion; } @@ -611,6 +655,10 @@ export abstract class BaseLLM implements ILLM { } this._logTokensGenerated(completionOptions.model, completion); + if (log && this.writeLog) { + await this.writeLog(`Completion:\n\n${completion}\n\n`); + } + return { prompt, completion }; } diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 91103e175..0d454fb59 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -104,6 +104,7 @@ class Ollama extends BaseLLM { const finalOptions: any = { model: this._getModel(), raw: true, + keep_alive: 60 * 30, // 30 minutes options: { temperature: options.temperature, top_p: options.topP, diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index 7c79ea515..b0c357765 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -24,7 +24,7 @@ const NON_CHAT_MODELS = [ class OpenAI extends BaseLLM { static providerName: ModelProvider = "openai"; static defaultOptions: Partial = { - apiBase: "https://api.openai.com", + apiBase: "https://api.openai.com/v1", }; protected _convertMessage(message: ChatMessage) { @@ -87,9 +87,7 @@ class OpenAI extends BaseLLM { if (url.endsWith("/")) { url = url.slice(0, -1); } - if (!url.endsWith("/v1") && !url.includes("api.perplexity.ai")) { - url += "/v1"; - } + return url + "/completions"; } } @@ -110,6 +108,10 @@ class OpenAI extends BaseLLM { prompt: string, options: CompletionOptions ): AsyncGenerator { + const args: any = this._convertArgs(options, []); + args.prompt = prompt; + delete args.messages; + const response = await this.fetch(this._getCompletionUrl(), { method: "POST", headers: { @@ -118,16 +120,7 @@ class OpenAI extends BaseLLM { "api-key": this.apiKey || "", // For Azure }, body: JSON.stringify({ - ...{ - prompt, - model: options.model, - max_tokens: options.maxTokens, - temperature: options.temperature, - top_p: options.topP, - frequency_penalty: options.frequencyPenalty, - presence_penalty: options.presencePenalty, - stop: options.stop, - }, + ...args, stream: true, }), }); @@ -153,10 +146,6 @@ class OpenAI extends BaseLLM { url = url.slice(0, -1); } - if (!url.includes("/v1") && !url.includes("api.perplexity.ai")) { - // includes instead of endsWith becuase DeepInfra uses /v1/openai/chat/completions - url += "/v1"; - } return url + "/chat/completions"; } } diff --git a/core/llm/llms/Together.ts b/core/llm/llms/Together.ts index 4ac82c880..d93be974c 100644 --- a/core/llm/llms/Together.ts +++ b/core/llm/llms/Together.ts @@ -1,18 +1,23 @@ -import { BaseLLM } from ".."; -import { CompletionOptions, LLMOptions, ModelProvider } from "../.."; -import { streamSse } from "../stream"; +import { + ChatMessage, + CompletionOptions, + LLMOptions, + ModelProvider, +} from "../.."; -class Together extends BaseLLM { +import OpenAI from "./OpenAI"; + +class Together extends OpenAI { static providerName: ModelProvider = "together"; static defaultOptions: Partial = { - apiBase: "https://api.together.xyz", + apiBase: "https://api.together.xyz/v1", }; private static MODEL_IDS: { [name: string]: string } = { "codellama-7b": "togethercomputer/CodeLlama-7b-Instruct", "codellama-13b": "togethercomputer/CodeLlama-13b-Instruct", "codellama-34b": "togethercomputer/CodeLlama-34b-Instruct", - "codellama-70b": "codellama/CodeLlama-70b-Python-hf", + "codellama-70b": "codellama/CodeLlama-70b-Instruct-hf", "llama2-7b": "togethercomputer/llama-2-7b-chat", "llama2-13b": "togethercomputer/llama-2-13b-chat", "llama2-70b": "togethercomputer/llama-2-70b-chat", @@ -25,17 +30,9 @@ class Together extends BaseLLM { return Together.MODEL_IDS[model] || this.model; } - private _convertArgs(options: CompletionOptions, prompt: string) { - const finalOptions = { - prompt, - model: this._getModelName(options.model), - temperature: options.temperature, - top_p: options.topP, - top_k: options.topK, - max_tokens: options.maxTokens, - repetition_penalty: options.frequencyPenalty, - }; - + protected _convertArgs(options: any, messages: ChatMessage[]) { + const finalOptions = super._convertArgs(options, messages); + finalOptions.model = this._getModelName(options.model); return finalOptions; } @@ -43,22 +40,8 @@ class Together extends BaseLLM { prompt: string, options: CompletionOptions ): AsyncGenerator { - const response = await this.fetch(`${this.apiBase}/inference`, { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${this.apiKey}`, - }, - body: JSON.stringify({ - ...this._convertArgs(options, prompt), - stream_tokens: true, - }), - }); - - for await (const value of streamSse(response)) { - if (value.choices) { - yield value.choices[0].text; - } + for await (const chunk of this._legacystreamComplete(prompt, options)) { + yield chunk; } } } diff --git a/core/llm/templates/chat.ts b/core/llm/templates/chat.ts index 8128b9a6d..bb0945042 100644 --- a/core/llm/templates/chat.ts +++ b/core/llm/templates/chat.ts @@ -264,9 +264,26 @@ function neuralChatTemplateMessages(msgs: ChatMessage[]): string { return prompt; } +/** +'Source: system\n\n System prompt Source: user\n\n First user query Source: assistant\n\n Model response to first query Source: user\n\n Second user query Source: assistant\nDestination: user\n\n ' + */ +function codeLlama70bTemplateMessages(msgs: ChatMessage[]): string { + let prompt = ""; + + for (const msg of msgs) { + prompt += `Source: ${msg.role}\n\n ${stripImages(msg.content).trim()}`; + prompt += " "; + } + + prompt += "Source: assistant\nDestination: user\n\n"; + + return prompt; +} + export { anthropicTemplateMessages, chatmlTemplateMessages, + codeLlama70bTemplateMessages, deepseekTemplateMessages, llama2TemplateMessages, llavaTemplateMessages, diff --git a/core/llm/templates/edit.ts b/core/llm/templates/edit.ts index 5a49f3158..0471ba4d1 100644 --- a/core/llm/templates/edit.ts +++ b/core/llm/templates/edit.ts @@ -138,18 +138,25 @@ Sure! Here's the code you requested: \`\`\`{{{language}}} `; +const codeLlama70bEditPrompt = `Source: system\n\n You are an expert programmer and write code on the first attempt without any errors or fillers. Source: user\n\n Rewrite the code to satisfy this request: "{{{userInput}}}" + +\`\`\`{{{language}}} +{{{codeToEdit}}} +\`\`\` Source: assistant\nDestination: user\n\n `; + export { alpacaEditPrompt, + codeLlama70bEditPrompt, codellamaEditPrompt, codellamaInfillEditPrompt, deepseekEditPrompt, gptEditPrompt, mistralEditPrompt, + neuralChatEditPrompt, openchatEditPrompt, phindEditPrompt, simplestEditPrompt, simplifiedEditPrompt, xWinCoderEditPrompt, zephyrEditPrompt, - neuralChatEditPrompt, }; diff --git a/core/llm/templates/options.ts b/core/llm/templates/options.ts new file mode 100644 index 000000000..1ebb02ba2 --- /dev/null +++ b/core/llm/templates/options.ts @@ -0,0 +1,11 @@ +import { CompletionOptions, ModelName } from "../.."; + +const CompletionOptionsForModels: { + [key in ModelName]?: Partial; +} = { + "codellama-70b": { + stop: ["Source: assistant"], + }, +}; + +export default CompletionOptionsForModels; diff --git a/core/util/merge.ts b/core/util/merge.ts new file mode 100644 index 000000000..c5a0af85f --- /dev/null +++ b/core/util/merge.ts @@ -0,0 +1,36 @@ +type JsonObject = { [key: string]: any }; + +export function mergeJson(first: JsonObject, second: JsonObject): any { + try { + for (var key in second) { + let secondValue = second[key]; + + if (!(key in first)) { + // New value + first[key] = secondValue; + continue; + } + + const firstValue = first[key]; + if (Array.isArray(secondValue)) { + // Array + first[key] = [...firstValue, ...secondValue]; + } else if (typeof secondValue === "object") { + // Object + first[key] = mergeJson(firstValue, secondValue); + } else { + // Other (boolean, number, string) + first[key] = secondValue; + } + } + return first; + } catch (e) { + console.error("Error merging JSON", e, first, second); + return { + ...first, + ...second, + }; + } +} + +export default mergeJson; diff --git a/docs/docs/customization/context-providers.md b/docs/docs/customization/context-providers.md index a8c0d5ea2..692035656 100644 --- a/docs/docs/customization/context-providers.md +++ b/docs/docs/customization/context-providers.md @@ -32,6 +32,14 @@ Type '@terminal' to reference the contents of your IDE's terminal. { "name": "terminal" } ``` +### Documentation + +Type `@docs` to index and retrieve snippets from any documentation site. You can add any site by selecting "Add Docs" in the dropdown, then entering the root URL of the documentation site and a title to remember it by. After the site has been indexed, you can type `@docs`, select your documentation from the dropdown, and Continue will use similarity search to automatically find important sections when answering your question. + +```json +{ "name": "docs" } +``` + ### Open Files Type '@open' to reference the contents of all of your open files. Set `onlyPinned` to `true` to only reference pinned files. diff --git a/docs/docs/reference/config.mdx b/docs/docs/reference/config.mdx index 8bad8f814..608072369 100644 --- a/docs/docs/reference/config.mdx +++ b/docs/docs/reference/config.mdx @@ -3,7 +3,7 @@ import JSONSchemaViewer from "@theme/JSONSchemaViewer"; # Configuration Options -The following shows the JSON Schema definition for `config.json`: +The following shows the JSON Schema definition for `config.json`. You can also define a partial `config.json` object in a file called `.continuerc.json` at the root of your workspace. This will be [applied on top of](https://github.com/continuedev/continue/blob/74c1eb5e25c517c575f72d26227d31d5d2ea18ed/extensions/vscode/src/ideProtocol.ts#L165-L173) any configuration from `config.json`. ("continue.tutorialShown") !== true) { - const tutorialPath = path.join( - getExtensionUri().fsPath, - "continue_tutorial.py" - ); - // Ensure keyboard shortcuts match OS - const os = process.platform; +export async function showTutorial() { + const tutorialPath = path.join( + getExtensionUri().fsPath, + "continue_tutorial.py" + ); + // Ensure keyboard shortcuts match OS + if (process.platform !== "darwin") { let tutorialContent = fs.readFileSync(tutorialPath, "utf8"); - if (os !== "darwin") { - tutorialContent = tutorialContent.replace("⌘", "^"); - fs.writeFileSync(tutorialPath, tutorialContent); - } + tutorialContent = tutorialContent.replace("⌘", "^"); + fs.writeFileSync(tutorialPath, tutorialContent); + } - const doc = await vscode.workspace.openTextDocument( - vscode.Uri.file(tutorialPath) - ); - await vscode.window.showTextDocument(doc); + const doc = await vscode.workspace.openTextDocument( + vscode.Uri.file(tutorialPath) + ); + await vscode.window.showTextDocument(doc); +} + +async function openTutorialFirstTime(context: vscode.ExtensionContext) { + if (context.globalState.get("continue.tutorialShown") !== true) { + await showTutorial(); context.globalState.update("continue.tutorialShown", true); } } @@ -79,7 +82,7 @@ export async function activateExtension(context: vscode.ExtensionContext) { registerAllCodeLensProviders(context); registerAllCommands(context); registerQuickFixProvider(); - await openTutorial(context); + await openTutorialFirstTime(context); setupInlineTips(context); showRefactorMigrationMessage(); @@ -142,6 +145,8 @@ export async function activateExtension(context: vscode.ExtensionContext) { fontColor: "#fff", }; themeJson.fileNames[".continueignore"] = "_f_continue"; + themeJson.fileNames[".continuerc.json"] = "_f_continue"; + themeJson.fileNames["config.json"] = "_f_continue"; fs.writeFileSync(themePath, JSON.stringify(themeJson)); found = true; break; diff --git a/extensions/vscode/src/activation/inlineTips.ts b/extensions/vscode/src/activation/inlineTips.ts index 9f78b8c3e..34ed41bd7 100644 --- a/extensions/vscode/src/activation/inlineTips.ts +++ b/extensions/vscode/src/activation/inlineTips.ts @@ -13,6 +13,11 @@ const inlineTipDecoration = vscode.window.createTextEditorDecorationType({ function handleSelectionChange(e: vscode.TextEditorSelectionChangeEvent) { const selection = e.selections[0]; const editor = e.textEditor; + + if (editor.document.uri.toString().startsWith("output:")) { + return; + } + if ( selection.isEmpty || vscode.workspace @@ -69,6 +74,10 @@ export function setupInlineTips(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.window.onDidChangeActiveTextEditor((editor) => { if (editor?.document.getText() === "") { + if (editor.document.uri.toString().startsWith("output:")) { + return; + } + editor.setDecorations(emptyFileTooltipDecoration, [ { range: new vscode.Range( @@ -83,6 +92,9 @@ export function setupInlineTips(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.workspace.onDidChangeTextDocument((e) => { + if (e.document.uri.toString().startsWith("vscode://inline-chat")) { + return; + } if (e.document.getText() === "") { vscode.window.visibleTextEditors.forEach((editor) => { editor.setDecorations(emptyFileTooltipDecoration, [ diff --git a/extensions/vscode/src/continueIdeClient.ts b/extensions/vscode/src/continueIdeClient.ts index 2f083f3bd..38cb966cc 100644 --- a/extensions/vscode/src/continueIdeClient.ts +++ b/extensions/vscode/src/continueIdeClient.ts @@ -233,9 +233,9 @@ class IdeProtocolClient { panel.webview.html = getSidebarContent(panel, "/monaco", edits); } - openFile(filepath: string) { + openFile(filepath: string, range?: vscode.Range) { // vscode has a builtin open/get open files - openEditorAndRevealRange(filepath, undefined, vscode.ViewColumn.One); + return openEditorAndRevealRange(filepath, range, vscode.ViewColumn.One); } async fileExists(filepath: string): Promise { diff --git a/extensions/vscode/src/debugPanel.ts b/extensions/vscode/src/debugPanel.ts index 95d7180af..8e813d1b1 100644 --- a/extensions/vscode/src/debugPanel.ts +++ b/extensions/vscode/src/debugPanel.ts @@ -8,7 +8,11 @@ import * as path from "path"; import * as io from "socket.io-client"; import { v4 as uuidv4 } from "uuid"; import * as vscode from "vscode"; -import { ideProtocolClient, windowId } from "./activation/activate"; +import { + ideProtocolClient, + showTutorial, + windowId, +} from "./activation/activate"; import { getContinueServerUrl } from "./bridge"; import { streamEdit } from "./diff/verticalPerLine/manager"; import historyManager from "./history"; @@ -211,25 +215,6 @@ export function getSidebarContent( }); break; } - case "showLines": { - ideProtocolClient.highlightCode( - { - filepath: data.filepath, - range: { - start: { - line: data.start, - character: 0, - }, - end: { - line: data.end, - character: 0, - }, - }, - }, - "#00ff0022" - ); - break; - } case "toggleDevTools": { vscode.commands.executeCommand("workbench.action.toggleDevTools"); vscode.commands.executeCommand("continue.viewLogs"); @@ -428,6 +413,11 @@ export function getSidebarContent( respond(await ide.getProblems(data.message.filepath)); break; } + case "getBranch": { + const { dir } = data.message; + respond(await ide.getBranch(dir)); + break; + } case "getOpenFiles": { respond(await ide.getOpenFiles()); break; @@ -436,6 +426,11 @@ export function getSidebarContent( respond(await ide.getPinnedFiles()); break; } + case "showLines": { + const { filepath, startLine, endLine } = data.message; + respond(await ide.showLines(filepath, startLine, endLine)); + break; + } // Other case "errorPopup": { vscode.window @@ -683,7 +678,7 @@ export function getSidebarContent( embeddingsProvider )) { progress.report({ - increment: update.progress * 100, + increment: update.progress, message: update.desc, }); } @@ -691,6 +686,10 @@ export function getSidebarContent( vscode.window.showInformationMessage( `🎉 Successfully indexed ${title}` ); + + debugPanelWebview?.postMessage({ + type: "refreshSubmenuItems", + }); } ); break; @@ -717,18 +716,25 @@ export function getSidebarContent( ); break; } + case "showTutorial": { + showTutorial(); + break; + } } } catch (e: any) { + let message = `Continue error: ${e.message}`; + if (e.cause) { + if (e.cause.name === "ConnectTimeoutError") { + message = `Connection timed out. If you expect it to take a long time to connect, you can increase the timeout in config.json by setting "requestOptions": { "timeout": 10000 }. You can find the full config reference here: https://continue.dev/docs/reference/config`; + } else if (e.cause.code === "ECONNREFUSED") { + message = `Connection was refused. This likely means that there is no server running at the specified URL. If you are running your own server you may need to set the "apiBase" parameter in config.json. For example, you can set up an OpenAI-compatible server like here: https://continue.dev/docs/reference/Model%20Providers/openai#openai-compatible-servers--apis`; + } else { + message = `The request failed with "${e.cause.name}": ${e.cause.message}. If you're having trouble setting up Continue, please see the troubleshooting guide for help.`; + } + } + vscode.window - .showErrorMessage( - `Continue error: ${e.message}${ - e.message.includes("fetch failed") - ? ". It is possible that this error is due to certificates not being configured. See the troubleshooting page to learn more." - : "" - }`, - "Show Logs", - "Troubleshooting" - ) + .showErrorMessage(message, "Show Logs", "Troubleshooting") .then((selection) => { if (selection === "Show Logs") { vscode.commands.executeCommand("workbench.action.toggleDevTools"); diff --git a/extensions/vscode/src/diff/horizontal.ts b/extensions/vscode/src/diff/horizontal.ts index 462778c73..d9c89bdd8 100644 --- a/extensions/vscode/src/diff/horizontal.ts +++ b/extensions/vscode/src/diff/horizontal.ts @@ -342,12 +342,18 @@ async function recordAcceptReject(accepted: boolean, diffInfo: DiffInfo) { ); } -export async function acceptDiffCommand(newFilepath?: string) { +export async function acceptDiffCommand(newFilepath?: string | vscode.Uri) { + if (newFilepath instanceof vscode.Uri) { + newFilepath = newFilepath.fsPath; + } verticalPerLineDiffManager.clearForFilepath(newFilepath, true); await diffManager.acceptDiff(newFilepath); } -export async function rejectDiffCommand(newFilepath?: string) { +export async function rejectDiffCommand(newFilepath?: string | vscode.Uri) { + if (newFilepath instanceof vscode.Uri) { + newFilepath = newFilepath.fsPath; + } verticalPerLineDiffManager.clearForFilepath(newFilepath, false); await diffManager.rejectDiff(newFilepath); } diff --git a/extensions/vscode/src/diff/verticalPerLine/manager.ts b/extensions/vscode/src/diff/verticalPerLine/manager.ts index 12c9cd7cb..a85b58100 100644 --- a/extensions/vscode/src/diff/verticalPerLine/manager.ts +++ b/extensions/vscode/src/diff/verticalPerLine/manager.ts @@ -108,14 +108,28 @@ export async function streamEdit(input: string) { editor.selection.active ); - await diffHandler.run( - streamDiffLines( - rangeContent, - llm, - input, - getMarkdownLanguageTagForFile(filepath) - ) + vscode.commands.executeCommand( + "setContext", + "continue.streamingDiff", + true ); + + try { + await diffHandler.run( + streamDiffLines( + rangeContent, + llm, + input, + getMarkdownLanguageTagForFile(filepath) + ) + ); + } finally { + vscode.commands.executeCommand( + "setContext", + "continue.streamingDiff", + false + ); + } } } diff --git a/extensions/vscode/src/extension.ts b/extensions/vscode/src/extension.ts index 421b6c169..725d09480 100644 --- a/extensions/vscode/src/extension.ts +++ b/extensions/vscode/src/extension.ts @@ -8,7 +8,6 @@ import { getUniqueId } from "./util/vscode"; let client: any = undefined; export async function capture(args: any) { - console.log("Capturing posthog event: ", args); if (!client) { const { PostHog } = await import("posthog-node"); client = new PostHog("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", { diff --git a/extensions/vscode/src/ideProtocol.ts b/extensions/vscode/src/ideProtocol.ts index 955a7dd04..43264dfc9 100644 --- a/extensions/vscode/src/ideProtocol.ts +++ b/extensions/vscode/src/ideProtocol.ts @@ -27,11 +27,11 @@ import { } from "core/config/load"; import { LanceDbIndex } from "core/indexing/LanceDbIndex"; import { IndexTag } from "core/indexing/types"; +import mergeJson from "core/util/merge"; import { verticalPerLineDiffManager } from "./diff/verticalPerLine/manager"; import { configHandler } from "./loadConfig"; -import mergeJson from "./util/merge"; import { traverseDirectory } from "./util/traverseDirectory"; -import { getExtensionUri } from "./util/vscode"; +import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode"; async function buildConfigTs(browser: boolean) { if (!fs.existsSync(getConfigTsPath())) { @@ -295,6 +295,26 @@ class VsCodeIde implements IDE { ideProtocolClient.openFile(path); } + async showLines( + filepath: string, + startLine: number, + endLine: number + ): Promise { + const range = new vscode.Range( + new vscode.Position(startLine, 0), + new vscode.Position(endLine, 0) + ); + openEditorAndRevealRange(filepath, range).then(() => { + ideProtocolClient.highlightCode( + { + filepath, + range, + }, + "#fff1" + ); + }); + } + async runCommand(command: string): Promise { await ideProtocolClient.runCommand(command); } @@ -416,6 +436,10 @@ class VsCodeIde implements IDE { }); } + async getBranch(dir: string): Promise { + return ideProtocolClient.getBranch(vscode.Uri.file(dir)); + } + async getFilesToEmbed( providerId: string ): Promise<[string, string, string][]> { diff --git a/extensions/vscode/src/loadConfig.ts b/extensions/vscode/src/loadConfig.ts index 8b34d0eb7..3f208eee6 100644 --- a/extensions/vscode/src/loadConfig.ts +++ b/extensions/vscode/src/loadConfig.ts @@ -1,10 +1,15 @@ import { ContinueConfig, IDE, ILLM } from "core"; import * as fs from "fs"; -import { Agent, fetch } from "undici"; +import { Agent, ProxyAgent, fetch } from "undici"; +import * as vscode from "vscode"; import { webviewRequest } from "./debugPanel"; import { VsCodeIde, loadFullConfigNode } from "./ideProtocol"; const tls = require("tls"); +const outputChannel = vscode.window.createOutputChannel( + "Continue - LLM Prompt/Completion" +); + class VsCodeConfigHandler { savedConfig: ContinueConfig | undefined; @@ -62,29 +67,66 @@ export async function llmFromTitle(title?: string): Promise { let timeout = (llm.requestOptions?.timeout || TIMEOUT) * 1000; // measured in ms - const agent = new Agent({ - connect: { - ca, - rejectUnauthorized: llm.requestOptions?.verifySsl, - timeout, - }, - bodyTimeout: timeout, - connectTimeout: timeout, - headersTimeout: timeout, - }); + const agent = + llm.requestOptions?.proxy !== undefined + ? new ProxyAgent({ + connect: { + ca, + rejectUnauthorized: llm.requestOptions?.verifySsl, + timeout, + }, + uri: llm.requestOptions?.proxy, + bodyTimeout: timeout, + connectTimeout: timeout, + headersTimeout: timeout, + }) + : new Agent({ + connect: { + ca, + rejectUnauthorized: llm.requestOptions?.verifySsl, + timeout, + }, + bodyTimeout: timeout, + connectTimeout: timeout, + headersTimeout: timeout, + }); - llm._fetch = (input, init) => { + llm._fetch = async (input, init) => { const headers: { [key: string]: string } = llm!.requestOptions?.headers || {}; for (const [key, value] of Object.entries(init?.headers || {})) { headers[key] = value as string; } - return fetch(input, { + const resp = await fetch(input, { ...init, dispatcher: agent, headers, }); + + if (!resp.ok) { + let text = await resp.text(); + if (resp.status === 404 && !resp.url.includes("/v1")) { + text = + "This may mean that you forgot to add '/v1' to the end of your 'apiBase' in config.json."; + } + throw new Error( + `HTTP ${resp.status} ${resp.statusText} from ${resp.url}\n\n${text}` + ); + } + + return resp; + }; + + llm.writeLog = async (log: string) => { + outputChannel.appendLine( + "==========================================================================" + ); + outputChannel.appendLine( + "==========================================================================" + ); + + outputChannel.append(log); }; return llm; diff --git a/extensions/vscode/src/util/indexCodebase.ts b/extensions/vscode/src/util/indexCodebase.ts index b99899bd9..90d1697ee 100644 --- a/extensions/vscode/src/util/indexCodebase.ts +++ b/extensions/vscode/src/util/indexCodebase.ts @@ -1,4 +1,6 @@ +import { FullTextSearchCodebaseIndex } from "core/indexing/FullTextSearch"; import { LanceDbIndex } from "core/indexing/LanceDbIndex"; +import { ChunkCodebaseIndex } from "core/indexing/chunk/ChunkCodebaseIndex"; import { getComputeDeleteAddRemove } from "core/indexing/refreshIndex"; import { CodebaseIndex, IndexTag, LastModifiedMap } from "core/indexing/types"; import * as vscode from "vscode"; @@ -23,11 +25,14 @@ const vscodeGetStats = async ( }; async function getIndexesToBuild(): Promise { - const indexes = []; - const ide = new VsCodeIde(); const config = await configHandler.loadConfig(ide); - indexes.push(new LanceDbIndex(config.embeddingsProvider, ide.readFile)); + + const indexes = [ + new ChunkCodebaseIndex(ide.readFile), // Chunking must come first + new LanceDbIndex(config.embeddingsProvider, ide.readFile), + new FullTextSearchCodebaseIndex(), + ]; return indexes; } @@ -62,12 +67,10 @@ export async function vsCodeIndexCodebase(workspaceDirs: string[]) { }; const [results, markComplete] = await getComputeDeleteAddRemove( tag, - stats, + { ...stats }, (filepath) => ideProtocolClient.readFile(filepath) ); - // console.log("RESULTS: ", results); - for await (let { progress, desc } of codebaseIndex.update( tag, results, diff --git a/extensions/vscode/src/util/merge.ts b/extensions/vscode/src/util/merge.ts deleted file mode 100644 index 418b83511..000000000 --- a/extensions/vscode/src/util/merge.ts +++ /dev/null @@ -1,27 +0,0 @@ -type JsonObject = { [key: string]: any }; - -function mergeJson(first: JsonObject, second: JsonObject): any { - for (var key in second) { - let secondValue = second[key]; - - if (!(key in first)) { - // New value - first[key] = secondValue; - } - - const firstValue = first[key]; - if (Array.isArray(secondValue)) { - // Array - first[key] = [...firstValue, ...secondValue]; - } else if (typeof secondValue === "object") { - // Object - first[key] = mergeJson(firstValue, secondValue); - } else { - // Other (boolean, number, string) - first[key] = secondValue; - } - } - return first; -} - -export default mergeJson; diff --git a/gui/package-lock.json b/gui/package-lock.json index 10049de81..967d5dbc0 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -46,9 +46,11 @@ "rehype-wrap-all": "^1.1.0", "remark-shiki-twoslash": "^3.1.3", "seti-file-icons": "^0.0.8", + "shikiji": "^0.10.2", "socket.io-client": "^4.7.2", "styled-components": "^5.3.6", "tippy.js": "^6.3.7", + "unist-util-visit": "^5.0.0", "uuid": "^9.0.1", "vscode-webview": "^1.0.1-beta.1" }, @@ -923,6 +925,27 @@ "node": ">=12" } }, + "node_modules/@mapbox/hast-util-table-cell-style/node_modules/unist-util-is": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz", + "integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==" + }, + "node_modules/@mapbox/hast-util-table-cell-style/node_modules/unist-util-visit": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", + "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", + "dependencies": { + "unist-util-visit-parents": "^2.0.0" + } + }, + "node_modules/@mapbox/hast-util-table-cell-style/node_modules/unist-util-visit-parents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", + "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", + "dependencies": { + "unist-util-is": "^3.0.0" + } + }, "node_modules/@monaco-editor/loader": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.4.0.tgz", @@ -1104,18 +1127,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/@shikijs/rehype/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/@shikijs/rehype/node_modules/unist-util-stringify-position": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", @@ -1128,33 +1139,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/@shikijs/rehype/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/@shikijs/rehype/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/@shikijs/rehype/node_modules/vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -4240,18 +4224,6 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "node_modules/mdast-util-to-hast/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/mdast-util-to-hast/node_modules/unist-util-position": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", @@ -4276,33 +4248,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-to-hast/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-hast/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/mdast-util-to-hast/node_modules/vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -4374,45 +4319,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-to-markdown/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-markdown/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/mdast-util-to-markdown/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/mdast-util-to-string": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz", @@ -5587,18 +5493,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/react-markdown/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/react-markdown/node_modules/unist-util-stringify-position": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", @@ -5611,33 +5505,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/react-markdown/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/react-markdown/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/react-markdown/node_modules/vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -6010,18 +5877,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/rehype-shikiji/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/rehype-shikiji/node_modules/unist-util-stringify-position": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", @@ -6034,33 +5889,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/rehype-shikiji/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/rehype-shikiji/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/rehype-shikiji/node_modules/vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -7000,45 +6828,6 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "node_modules/unist-util-remove-position/node_modules/unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "dependencies": { - "@types/unist": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-remove-position/node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/unist-util-remove-position/node_modules/unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "dependencies": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/unist-util-stringify-position": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", @@ -7052,25 +6841,65 @@ } }, "node_modules/unist-util-visit": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", - "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", + "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", "dependencies": { - "unist-util-visit-parents": "^2.0.0" + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, "node_modules/unist-util-visit-parents": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", - "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", + "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", "dependencies": { - "unist-util-is": "^3.0.0" + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, + "node_modules/unist-util-visit-parents/node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" + }, "node_modules/unist-util-visit-parents/node_modules/unist-util-is": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz", - "integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==" + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", + "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit/node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" + }, + "node_modules/unist-util-visit/node_modules/unist-util-is": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", + "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } }, "node_modules/universalify": { "version": "2.0.0", @@ -7824,6 +7653,29 @@ "integrity": "sha512-LyQz4XJIdCdY/+temIhD/Ed0x/p4GAOUycpFSEK2Ads1CPKZy6b7V/2ROEtQiLLQ8soIs0xe/QAoR6kwpyW/yw==", "requires": { "unist-util-visit": "^1.4.1" + }, + "dependencies": { + "unist-util-is": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz", + "integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==" + }, + "unist-util-visit": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", + "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", + "requires": { + "unist-util-visit-parents": "^2.0.0" + } + }, + "unist-util-visit-parents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", + "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", + "requires": { + "unist-util-is": "^3.0.0" + } + } } }, "@monaco-editor/loader": { @@ -7967,14 +7819,6 @@ "vfile": "^6.0.0" } }, - "unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "requires": { - "@types/unist": "^3.0.0" - } - }, "unist-util-stringify-position": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", @@ -7983,25 +7827,6 @@ "@types/unist": "^3.0.0" } }, - "unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - } - }, - "unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - } - }, "vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -10229,14 +10054,6 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, - "unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "requires": { - "@types/unist": "^3.0.0" - } - }, "unist-util-position": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", @@ -10253,25 +10070,6 @@ "@types/unist": "^3.0.0" } }, - "unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - } - }, - "unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - } - }, "vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -10328,33 +10126,6 @@ "requires": { "@types/mdast": "^4.0.0" } - }, - "unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "requires": { - "@types/unist": "^3.0.0" - } - }, - "unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - } - }, - "unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - } } } }, @@ -11125,14 +10896,6 @@ "vfile": "^6.0.0" } }, - "unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "requires": { - "@types/unist": "^3.0.0" - } - }, "unist-util-stringify-position": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", @@ -11141,25 +10904,6 @@ "@types/unist": "^3.0.0" } }, - "unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - } - }, - "unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - } - }, "vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -11425,14 +11169,6 @@ "vfile": "^6.0.0" } }, - "unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "requires": { - "@types/unist": "^3.0.0" - } - }, "unist-util-stringify-position": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", @@ -11441,25 +11177,6 @@ "@types/unist": "^3.0.0" } }, - "unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - } - }, - "unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - } - }, "vfile": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz", @@ -12165,33 +11882,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" - }, - "unist-util-is": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", - "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", - "requires": { - "@types/unist": "^3.0.0" - } - }, - "unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0", - "unist-util-visit-parents": "^6.0.0" - } - }, - "unist-util-visit-parents": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", - "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", - "requires": { - "@types/unist": "^3.0.0", - "unist-util-is": "^6.0.0" - } } } }, @@ -12204,25 +11894,51 @@ } }, "unist-util-visit": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", - "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", + "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", "requires": { - "unist-util-visit-parents": "^2.0.0" + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "dependencies": { + "@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" + }, + "unist-util-is": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", + "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "requires": { + "@types/unist": "^3.0.0" + } + } } }, "unist-util-visit-parents": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", - "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", + "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", "requires": { - "unist-util-is": "^3.0.0" + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" }, "dependencies": { + "@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" + }, "unist-util-is": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz", - "integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==" + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", + "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "requires": { + "@types/unist": "^3.0.0" + } } } }, diff --git a/gui/package.json b/gui/package.json index 44da6d41c..efb7fb888 100644 --- a/gui/package.json +++ b/gui/package.json @@ -47,9 +47,11 @@ "rehype-wrap-all": "^1.1.0", "remark-shiki-twoslash": "^3.1.3", "seti-file-icons": "^0.0.8", + "shikiji": "^0.10.2", "socket.io-client": "^4.7.2", "styled-components": "^5.3.6", "tippy.js": "^6.3.7", + "unist-util-visit": "^5.0.0", "uuid": "^9.0.1", "vscode-webview": "^1.0.1-beta.1" }, diff --git a/gui/src/App.tsx b/gui/src/App.tsx index d57d17642..0ad8260cc 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -66,19 +66,28 @@ const router = createMemoryRouter([ }, ]); -export const SubmenuContextProvidersContext = createContext< - (providerTitle: string | undefined, query: string) => ContextSubmenuItem[] ->(() => []); +export const SubmenuContextProvidersContext = createContext<{ + getSubmenuContextItems: ( + providerTitle: string | undefined, + query: string + ) => ContextSubmenuItem[]; + addItem: (providerTitle: string, item: ContextSubmenuItem) => void; +}>({ + getSubmenuContextItems: () => [], + addItem: () => {}, +}); function App() { const dispatch = useDispatch(); useSetup(dispatch); - const { getSubmenuContextItems } = useSubmenuContextProviders(); + const submenuContextProvidersMethods = useSubmenuContextProviders(); return ( - + ); diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index 3b342de2c..54a158078 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -1,9 +1,10 @@ import { postToIde } from "core/ide/messaging"; -import React, { useLayoutEffect } from "react"; +import { usePostHog } from "posthog-js/react"; +import React, { useContext, useLayoutEffect } from "react"; import { useDispatch } from "react-redux"; import styled from "styled-components"; import { Button, Input } from ".."; -import useSubmenuContextProviders from "../../hooks/useSubmenuContextProviders"; +import { SubmenuContextProvidersContext } from "../../App"; import { setShowDialog } from "../../redux/slices/uiStateSlice"; const GridDiv = styled.div` @@ -19,14 +20,17 @@ function AddDocsDialog() { const [urlValid, setUrlValid] = React.useState(false); const dispatch = useDispatch(); - const { addItem } = useSubmenuContextProviders(); + const { addItem } = useContext(SubmenuContextProvidersContext); const ref = React.useRef(null); + const posthog = usePostHog(); useLayoutEffect(() => { - if (ref.current) { - ref.current.focus(); - } + setTimeout(() => { + if (ref.current) { + ref.current.focus(); + } + }, 100); }, [ref]); return ( @@ -63,6 +67,7 @@ function AddDocsDialog() { title: docsTitle, description: new URL(docsUrl).hostname, }); + posthog.capture("add_docs", { url: docsUrl }); }} > Done diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 911407755..b9d2b5176 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -94,7 +94,6 @@ export function parseColorForHex(colorVar: string): string { .map((x) => x.toString(16)) .map((x) => (x.length === 1 ? "0" + x : x)) .join(""); - console.log(hex, value); return hex; } diff --git a/gui/src/components/mainInput/ContextItemsPeek.tsx b/gui/src/components/mainInput/ContextItemsPeek.tsx index bdf99d708..466700495 100644 --- a/gui/src/components/mainInput/ContextItemsPeek.tsx +++ b/gui/src/components/mainInput/ContextItemsPeek.tsx @@ -1,5 +1,6 @@ import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline"; import { ContextItemWithId } from "core"; +import { contextItemToRangeInFileWithContents } from "core/commands/util"; import { ExtensionIde } from "core/ide"; import React from "react"; import styled from "styled-components"; @@ -46,8 +47,11 @@ const ContextItemsPeek = (props: ContextItemsPeekProps) => { contextItem.description.startsWith("/") || contextItem.description.startsWith("\\") ) { - new ExtensionIde().openFile( - contextItem.description.split(" ").shift() || "" + const rif = contextItemToRangeInFileWithContents(contextItem); + new ExtensionIde().showLines( + rif.filepath, + rif.range.start.line, + rif.range.end.line ); } else { new ExtensionIde().showVirtualFile(contextItem.name, contextItem.content); diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index deb8fa03c..4827b8960 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -123,7 +123,7 @@ interface TipTapEditorProps { function TipTapEditor(props: TipTapEditorProps) { const dispatch = useDispatch(); - const getSubmenuContextItems = useContext(SubmenuContextProvidersContext); + const { getSubmenuContextItems } = useContext(SubmenuContextProvidersContext); const historyLength = useSelector( (store: RootStore) => store.state.history.length diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index 646764b5e..3f2a2adfa 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -5,6 +5,7 @@ import { XMarkIcon, } from "@heroicons/react/24/outline"; import { ContextItemWithId } from "core"; +import { ExtensionIde } from "core/ide"; import { getMarkdownLanguageTagForFile } from "core/util"; import React from "react"; import { useDispatch } from "react-redux"; @@ -97,11 +98,11 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { .split("(")[1] .split(")")[0] .split("-"); - postToIde("showLines", { - filepath: props.item.description, - start: parseInt(lines[0]) - 1, - end: parseInt(lines[1]) - 1, - }); + new ExtensionIde().showLines( + props.item.description, + parseInt(lines[0]) - 1, + parseInt(lines[1]) - 1 + ); } else { postToIde("showVirtualFile", { name: props.item.name, diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 6e7b3333d..e6f0629bb 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -1,7 +1,8 @@ -import { memo, useEffect } from "react"; +import React, { memo, useEffect } from "react"; import { useRemark } from "react-remark"; import rehypeShikiji from "rehype-shikiji"; import styled from "styled-components"; +import { visit } from "unist-util-visit"; import { defaultBorderRadius, vscBackground, @@ -50,6 +51,7 @@ const StyledMarkdown = styled.div<{ border-radius: ${defaultBorderRadius}; background-color: ${vscEditorBackground}; font-size: 12px; + font-family: var(--vscode-editor-font-family); } code:not(pre > code) { @@ -74,7 +76,10 @@ const StyledMarkdown = styled.div<{ padding-right: 8px; color: ${vscForeground}; - p { + p, + li, + ol, + ul { line-height: 1.5; } `; @@ -107,10 +112,124 @@ const FadeInWords: React.FC = (props: any) => { return

{words}

; }; +const supportedLanguages = [ + "abap", + "actionscript-3", + "ada", + "apex", + "applescript", + "asm", + "awk", + "bat", + "c", + "clojure", + "cobol", + "coffee", + "cpp", + "crystal", + "csharp", + "css", + "d", + "dart", + "diff", + "dockerfile", + "elixir", + "elm", + "erlang", + // "fortran", + "fsharp", + "git-commit", + "git-rebase", + // "go", + "graphql", + "groovy", + "hack", + "haml", + "handlebars", + "haskell", + "hcl", + "hlsl", + "html", + "ini", + "java", + "javascript", + "jinja-html", + "json", + "jsonc", + "jsonnet", + "jsx", + "julia", + "kotlin", + "latex", + "less", + "lisp", + "log", + "logo", + "lua", + "makefile", + "markdown", + "matlab", + "nix", + "objective-c", + "ocaml", + "pascal", + "perl", + "perl6", + "php", + "pls", + "postcss", + "powershell", + "prolog", + "pug", + "puppet", + "purescript", + "python", + "r", + "razor", + "ruby", + "rust", + "sas", + "sass", + "scala", + "scheme", + "scss", + "shaderlab", + "shellscript", + "smalltalk", + "sql", + "stylus", + "svelte", + "swift", + "tcl", + "toml", + "ts", + "tsx", + "typescript", + "vb", + "viml", + "vue", + "wasm", + "xml", + "xsl", + "yaml", + "文言", +]; + const StyledMarkdownPreview = memo(function StyledMarkdownPreview( props: StyledMarkdownPreviewProps ) { const [reactContent, setMarkdownSource] = useRemark({ + remarkPlugins: [ + () => { + return (tree) => { + visit(tree, "code", (node: any) => { + if (!supportedLanguages.includes(node.lang)) { + node.lang = "javascript"; // Default to javascript to get some highlighting + } + }); + }; + }, + ], rehypePlugins: [ [ rehypeShikiji as any, @@ -119,6 +238,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( (window as any).fullColorTheme || (window as any).colorThemeName || "dark-plus", + addLanguageClass: true, }, ], // [ @@ -139,7 +259,6 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( ); }, pre: ({ node, ...preProps }) => { - console.log(node, preProps); return props.showCodeBorder ? ( ) : ( diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index 90ec92fb9..25cf28970 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -5,6 +5,7 @@ import { ChatHistory, ChatHistoryItem, ChatMessage, + ContinueSDK, LLMReturnValue, MessageContent, SlashCommand, @@ -19,7 +20,7 @@ import { useSelector } from "react-redux"; import resolveEditorContent from "../components/mainInput/resolveInput"; import { defaultModelSelector } from "../redux/selectors/modelSelectors"; import { - addContextItems, + addContextItemsAtIndex, addLogs, initNewActiveMessage, resubmitAtIndex, @@ -120,19 +121,25 @@ function useChatHandler(dispatch: Dispatch) { async function _streamSlashCommand( messages: ChatMessage[], slashCommand: SlashCommand, - input: string + input: string, + historyIndex: number ) { let generator: AsyncGenerator; if (slashCommand.runInNodeJs) { generator = _streamSlashCommandFromVsCode(messages, slashCommand, input); } else { - const sdk = { + const sdk: ContinueSDK = { input, history: messages, ide: new ExtensionIde(), llm: defaultModel, addContextItem: (item) => { - dispatch(addContextItems([item])); + dispatch( + addContextItemsAtIndex({ + index: historyIndex, + contextItems: [item], + }) + ); }, contextItems, params: slashCommand.params, @@ -181,10 +188,11 @@ function useChatHandler(dispatch: Dispatch) { }; let newHistory: ChatHistory = [...history.slice(0, index), historyItem]; + const historyIndex = index || newHistory.length - 1; dispatch( setMessageAtIndex({ message, - index: index || newHistory.length - 1, + index: historyIndex, contextItems, }) ); @@ -217,7 +225,12 @@ function useChatHandler(dispatch: Dispatch) { user_input: commandInput, }, }); - await _streamSlashCommand(messages, slashCommand, commandInput); + await _streamSlashCommand( + messages, + slashCommand, + commandInput, + historyIndex + ); } } catch (e) { console.log("Continue: error streaming response: ", e); diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index f19f4b736..90550be25 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -1,6 +1,7 @@ import { Dispatch } from "@reduxjs/toolkit"; import { PersistedSessionInfo, SessionInfo } from "core"; import { ideRequest } from "core/ide/messaging"; +import { llmCanGenerateInParallel } from "core/llm"; import { stripImages } from "core/llm/countTokens"; import { useSelector } from "react-redux"; import { defaultModelSelector } from "../redux/selectors/modelSelectors"; @@ -36,7 +37,11 @@ function useHistory(dispatch: Dispatch) { stripImages(stateCopy.history[0].message.content), 50 ); - if (!disableSessionTitles) { + if ( + false && // Causing maxTokens to be set to 20 for main requests sometimes, so disabling until resolved + !disableSessionTitles && + llmCanGenerateInParallel(defaultModel) + ) { let { content } = await defaultModel.chat( [ ...stateCopy.history.map((item) => item.message), diff --git a/gui/src/hooks/useSubmenuContextProviders.tsx b/gui/src/hooks/useSubmenuContextProviders.tsx index c059f6ee2..b51cd7ca7 100644 --- a/gui/src/hooks/useSubmenuContextProviders.tsx +++ b/gui/src/hooks/useSubmenuContextProviders.tsx @@ -43,8 +43,20 @@ function useSubmenuContextProviders() { }); } + useEffect(() => { + const handler = (e) => { + if (e.data.type !== "refreshSubmenuItems") { + return; + } + setLoaded(false); + }; + window.addEventListener("message", handler); + return () => { + window.removeEventListener("message", handler); + }; + }, []); + function addItem(providerTitle: string, item: ContextSubmenuItem) { - console.log("Adding item", item, providerTitle, Object.keys(minisearches)); if (!minisearches[providerTitle]) { return; } diff --git a/gui/src/pages/help.tsx b/gui/src/pages/help.tsx index 1b36afe5a..3beb2c715 100644 --- a/gui/src/pages/help.tsx +++ b/gui/src/pages/help.tsx @@ -1,7 +1,8 @@ import { ArrowLeftIcon } from "@heroicons/react/24/outline"; +import { postToIde } from "core/ide/messaging"; import { useNavigate } from "react-router-dom"; import styled from "styled-components"; -import { lightGray, vscBackground, vscForeground } from "../components"; +import { Button, lightGray, vscBackground, vscForeground } from "../components"; import KeyboardShortcutsDialog from "../components/dialogs/KeyboardShortcuts"; const IconDiv = styled.div<{ backgroundColor?: string }>` @@ -18,6 +19,18 @@ const IconDiv = styled.div<{ backgroundColor?: string }>` } `; +const TutorialButton = styled(Button)` + padding: 2px 4px; + margin-left: auto; + margin-right: 12px; + background-color: transparent; + color: ${vscForeground}; + border: 1px solid ${lightGray}; + &:hover { + background-color: ${lightGray}; + } +`; + function HelpPage() { const navigate = useNavigate(); @@ -37,6 +50,13 @@ function HelpPage() { className="inline-block ml-4 cursor-pointer" />

Help Center

+ { + postToIde("showTutorial", {}); + }} + > + Open tutorial +
diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index 9d881ceea..b7ea70808 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -264,6 +264,21 @@ export const stateSlice = createSlice({ state.history[payload.index].message = payload.message; state.history[payload.index].contextItems = payload.contextItems || []; }, + addContextItemsAtIndex: ( + state, + { + payload, + }: { + payload: { + index: number; + contextItems: ContextItemWithId[]; + }; + } + ) => { + if (payload.index < state.history.length) { + state.history[payload.index].contextItems.push(...payload.contextItems); + } + }, setInactive: (state) => { return { ...state, @@ -450,6 +465,7 @@ export const stateSlice = createSlice({ export const { setContextItemsAtIndex, addContextItems, + addContextItemsAtIndex, setInactive, streamUpdate, newSession,