From 224089b74a5a1aff7cd76668fd0f0a27f765b593 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 19 Mar 2024 22:57:41 -0700 Subject: [PATCH 01/14] =?UTF-8?q?=F0=9F=A9=B9=20ensure=20ordering=20in=20m?= =?UTF-8?q?arkComplete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/indexing/refreshIndex.ts | 7 +++- .../vscode/src/extension/vscodeExtension.ts | 38 +++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/core/indexing/refreshIndex.ts b/core/indexing/refreshIndex.ts index 03bf7f7fa..6f6ec1406 100644 --- a/core/indexing/refreshIndex.ts +++ b/core/indexing/refreshIndex.ts @@ -147,7 +147,12 @@ async function getAddRemoveForTag( } = {}; async function markComplete(items: PathAndCacheKey[], _: IndexResultType) { - const actions = items.map((item) => itemToAction[JSON.stringify(item)]); + const actions = items.map( + (item) => + itemToAction[ + JSON.stringify({ path: item.path, cacheKey: item.cacheKey }) + ], + ); for (const [{ path, cacheKey }, resultType] of actions) { switch (resultType) { case AddRemoveResultType.Add: diff --git a/extensions/vscode/src/extension/vscodeExtension.ts b/extensions/vscode/src/extension/vscodeExtension.ts index 9c57b884e..6af26350d 100644 --- a/extensions/vscode/src/extension/vscodeExtension.ts +++ b/extensions/vscode/src/extension/vscodeExtension.ts @@ -6,6 +6,7 @@ import * as vscode from "vscode"; import { ContinueCompletionProvider } from "../autocomplete/completionProvider"; import { setupStatusBar } from "../autocomplete/statusBar"; import { registerAllCommands } from "../commands"; +import { registerDebugTracker } from "../debug/debug"; import { ContinueGUIWebviewViewProvider } from "../debugPanel"; import { DiffManager } from "../diff/horizontal"; import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager"; @@ -14,7 +15,6 @@ import { registerAllCodeLensProviders } from "../lang-server/codeLens"; import { setupRemoteConfigSync } from "../stubs/activation"; import { TabAutocompleteModel } from "../util/loadAutocompleteModel"; import { VsCodeWebviewProtocol } from "../webviewProtocol"; -import { registerDebugTracker } from "../debug/debug"; export class VsCodeExtension { private configHandler: ConfigHandler; @@ -48,26 +48,26 @@ export class VsCodeExtension { // Config Handler with output channel const outputChannel = vscode.window.createOutputChannel( - "Continue - LLM Prompt/Completion" + "Continue - LLM Prompt/Completion", ); this.configHandler = new ConfigHandler( this.ide, Promise.resolve(ideSettings), async (log: string) => { outputChannel.appendLine( - "==========================================================================" + "==========================================================================", ); outputChannel.appendLine( - "==========================================================================" + "==========================================================================", ); outputChannel.append(log); }, - () => this.webviewProtocol?.request("configUpdate", undefined) + () => this.webviewProtocol?.request("configUpdate", undefined), ); this.configHandler.reloadConfig(); this.verticalDiffManager = new VerticalPerLineDiffManager( - this.configHandler + this.configHandler, ); this.extensionContext = context; this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler); @@ -77,7 +77,7 @@ export class VsCodeExtension { this.ide, this.windowId, this.extensionContext, - this.verticalDiffManager + this.verticalDiffManager, ); setupRemoteConfigSync( @@ -91,14 +91,14 @@ export class VsCodeExtension { this.sidebar, { webviewOptions: { retainContextWhenHidden: true }, - } - ) + }, + ), ); this.webviewProtocol = this.sidebar.webviewProtocol; // Indexing + pause token const indexingPauseToken = new PauseToken( - context.globalState.get("continue.indexingPaused") === true + context.globalState.get("continue.indexingPaused") === true, ); this.webviewProtocol.on("index/setPaused", (msg) => { context.globalState.update("continue.indexingPaused", msg.data); @@ -109,14 +109,14 @@ export class VsCodeExtension { this.indexer = new CodebaseIndexer( this.configHandler, this.ide, - indexingPauseToken + indexingPauseToken, ); // CodeLens registerAllCodeLensProviders( context, this.diffManager, - this.verticalDiffManager.editorToVerticalDiffCodeLens + this.verticalDiffManager.editorToVerticalDiffCodeLens, ); // Tab autocomplete @@ -131,9 +131,9 @@ export class VsCodeExtension { new ContinueCompletionProvider( this.configHandler, this.ide, - this.tabAutocompleteModel - ) - ) + this.tabAutocompleteModel, + ), + ), ); // Commands @@ -144,7 +144,7 @@ export class VsCodeExtension { this.sidebar, this.configHandler, this.diffManager, - this.verticalDiffManager + this.verticalDiffManager, ); registerDebugTracker(this.webviewProtocol, this.ide); @@ -195,7 +195,7 @@ export class VsCodeExtension { } }); } - }) + }), ); // Register a content provider for the readonly virtual documents @@ -213,8 +213,8 @@ export class VsCodeExtension { context.subscriptions.push( vscode.workspace.registerTextDocumentContentProvider( VsCodeExtension.continueVirtualDocumentScheme, - documentContentProvider - ) + documentContentProvider, + ), ); } From 30a3adf04e0b78188d360dc67ea7e6801aec3573 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 10:16:28 -0700 Subject: [PATCH 02/14] =?UTF-8?q?=F0=9F=A9=B9=20add=20claude=20models=20to?= =?UTF-8?q?=20/models=20response=20for=20free=20trial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/llm/llms/FreeTrial.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/llm/llms/FreeTrial.ts b/core/llm/llms/FreeTrial.ts index 4bafdccba..d59d114b9 100644 --- a/core/llm/llms/FreeTrial.ts +++ b/core/llm/llms/FreeTrial.ts @@ -98,6 +98,9 @@ class FreeTrial extends BaseLLM { "gemini-pro", "gpt-4-vision-preview", "codellama-70b", + "claude-3-opus-20240229", + "claude-3-sonnet-20240229", + "claude-3-haiku-20240307", ]; } } From 96074a529d6c6f49ae413c049e694f1934ab80b9 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 16:45:26 -0700 Subject: [PATCH 03/14] =?UTF-8?q?=F0=9F=A9=B9=20disable=20free=20trial=20f?= =?UTF-8?q?or=20autocomplete=20(because=20none=20of=20the=20models=20are?= =?UTF-8?q?=20built=20for=20this)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/autocomplete/completionProvider.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 66d29a17f..fd49b76e6 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -105,6 +105,10 @@ export async function getTabCompletion( // Model if (llm instanceof OpenAI) { llm.useLegacyCompletionsEndpoint = true; + } else if (llm.providerName === "free-trial") { + throw new Error( + "Free trial is not supported for tab-autocomplete. We recommend using starcoder with Ollama, LM Studio, or another provider.", + ); } if (!llm) return; From d4d1a8eec9fa253e34d650316a73172bcdec3cac Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 16:46:08 -0700 Subject: [PATCH 04/14] =?UTF-8?q?=F0=9F=90=9B=20Ctrl/Cmd=20in=20tutorial?= =?UTF-8?q?=20and=20make=20sure=20to=20use=20correct=20one=20for=20OS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/continue_tutorial.py | 14 +++++++------- extensions/vscode/src/activation/activate.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/vscode/continue_tutorial.py b/extensions/vscode/continue_tutorial.py index 2583d5621..e00c03b23 100644 --- a/extensions/vscode/continue_tutorial.py +++ b/extensions/vscode/continue_tutorial.py @@ -12,7 +12,7 @@ You can either - follow along by clicking the gray CodeLens buttons above the lines, in order, starting with "Begin Section" """ -# region —————————————————————————— Part 1: Ask a question about code [⌘ L] —————————————————————————— +# region —————————————————————————— Part 1: Ask a question about code [Cmd+L] —————————————————————————— """Step 1: Highlight the function below""" @@ -27,14 +27,14 @@ def mysterious_function(x): return x -"""Step 2: Use the keyboard shortcut [⌘ L] to +"""Step 2: Use the keyboard shortcut [Cmd+L] to select the code and toggle the Continue input box""" """Step 3: Ask a question and press Enter""" # endregion -# region ————————————————————————————————— Part 2: Edit code [⌘ I] ————————————————————————————————— +# region ————————————————————————————————— Part 2: Edit code [Cmd+I] ————————————————————————————————— """Step 1: Highlight this code""" @@ -53,16 +53,16 @@ def mysterious_function(x): return x -"""Step 2: Use the keyboard shortcut [⌘ I] to edit""" +"""Step 2: Use the keyboard shortcut [Cmd+I] to edit""" """Step 3: Type "" and press Enter""" """Step 4: Use keyboard shortcuts to -accept [⌘ ⇧ ⏎] or reject [⌘ ⇧ ⌫] the edit""" +accept [Cmd+Shift+Enter] or reject [Cmd+Shift+Backspace] the edit""" # endregion -# region ———————————————————————————— Part 3: Debug automatically [⌘ ⇧ R] ———————————————————————————— +# region ———————————————————————————— Part 3: Debug automatically [Cmd+Shift+R] ———————————————————————————— """Step 1: Run this Python file (it should error!)""" @@ -72,7 +72,7 @@ def print_sum(list_to_print): print(sum(list_to_print)) -"""Step 2: Use the keyboard shortcut [⌘ ⇧ R] +"""Step 2: Use the keyboard shortcut [Cmd+Shift+R] to automatically debug the error""" print_sum(["a", "b", "c"]) diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 3de6b77be..3b999b4b9 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -17,7 +17,7 @@ export async function showTutorial() { // Ensure keyboard shortcuts match OS if (process.platform !== "darwin") { let tutorialContent = fs.readFileSync(tutorialPath, "utf8"); - tutorialContent = tutorialContent.replace("⌘", "^"); + tutorialContent = tutorialContent.replace("⌘", "^").replace("Cmd", "Ctrl"); fs.writeFileSync(tutorialPath, tutorialContent); } From 4c13ac753b105881d375a2d5870af33736357c4e Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 19:27:34 -0700 Subject: [PATCH 05/14] =?UTF-8?q?=F0=9F=9A=B8=20allow=20errors=20parsing?= =?UTF-8?q?=20config.json=20to=20be=20thrown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config/handler.ts | 91 +++++++++++------------- core/config/load.ts | 4 +- extensions/vscode/src/webviewProtocol.ts | 2 +- gui/src/redux/slices/stateSlice.ts | 39 ++++------ 4 files changed, 57 insertions(+), 79 deletions(-) diff --git a/core/config/handler.ts b/core/config/handler.ts index 33712ed60..221a3ae37 100644 --- a/core/config/handler.ts +++ b/core/config/handler.ts @@ -16,15 +16,11 @@ export class ConfigHandler { private savedConfig: ContinueConfig | undefined; private savedBrowserConfig?: BrowserSerializedContinueConfig; - private readonly ide: IDE; - private ideSettingsPromise: Promise; - private readonly writeLog: (text: string) => void; - private readonly onConfigUpdate: () => void; constructor( - ide: IDE, - ideSettingsPromise: Promise, - writeLog: (text: string) => void, - onConfigUpdate: () => void, + private readonly ide: IDE, + private ideSettingsPromise: Promise, + private readonly writeLog: (text: string) => void, + private readonly onConfigUpdate: () => void, ) { this.ide = ide; this.ideSettingsPromise = ideSettingsPromise; @@ -58,50 +54,45 @@ export class ConfigHandler { } async loadConfig(): Promise { - try { - if (this.savedConfig) { - return this.savedConfig; - } - - let workspaceConfigs: ContinueRcJson[] = []; - try { - workspaceConfigs = await this.ide.getWorkspaceConfigs(); - } catch (e) { - console.warn("Failed to load workspace configs"); - } - - const ideInfo = await this.ide.getIdeInfo(); - const ideSettings = await this.ideSettingsPromise; - let remoteConfigServerUrl = undefined; - try { - remoteConfigServerUrl = - typeof ideSettings.remoteConfigServerUrl !== "string" || - ideSettings.remoteConfigServerUrl === "" - ? undefined - : new URL(ideSettings.remoteConfigServerUrl); - } catch (e) {} - - this.savedConfig = await loadFullConfigNode( - this.ide.readFile, - workspaceConfigs, - remoteConfigServerUrl, - ideInfo.ideType, - ); - this.savedConfig.allowAnonymousTelemetry = - this.savedConfig.allowAnonymousTelemetry && - (await this.ide.isTelemetryEnabled()); - - // Setup telemetry only after (and if) we know it is enabled - await Telemetry.setup( - this.savedConfig.allowAnonymousTelemetry ?? true, - await this.ide.getUniqueId(), - ); - + if (this.savedConfig) { return this.savedConfig; - } catch (e: any) { - console.error("Failed to loadConfig: ", e.message); - throw new Error("Failed to loadConfig: " + e.message); } + + let workspaceConfigs: ContinueRcJson[] = []; + try { + workspaceConfigs = await this.ide.getWorkspaceConfigs(); + } catch (e) { + console.warn("Failed to load workspace configs"); + } + + const ideInfo = await this.ide.getIdeInfo(); + const ideSettings = await this.ideSettingsPromise; + let remoteConfigServerUrl = undefined; + try { + remoteConfigServerUrl = + typeof ideSettings.remoteConfigServerUrl !== "string" || + ideSettings.remoteConfigServerUrl === "" + ? undefined + : new URL(ideSettings.remoteConfigServerUrl); + } catch (e) {} + + this.savedConfig = await loadFullConfigNode( + this.ide.readFile, + workspaceConfigs, + remoteConfigServerUrl, + ideInfo.ideType, + ); + this.savedConfig.allowAnonymousTelemetry = + this.savedConfig.allowAnonymousTelemetry && + (await this.ide.isTelemetryEnabled()); + + // Setup telemetry only after (and if) we know it is enabled + await Telemetry.setup( + this.savedConfig.allowAnonymousTelemetry ?? true, + await this.ide.getUniqueId(), + ); + + return this.savedConfig; } setupLlm(llm: ILLM): ILLM { diff --git a/core/config/load.ts b/core/config/load.ts index e30980b4b..6aa876417 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -38,7 +38,6 @@ import { getContinueDotEnv, migrate, } from "../util/paths"; -import { defaultConfig } from "./default"; const { execSync } = require("child_process"); function resolveSerializedConfig(filepath: string): SerializedContinueConfig { @@ -80,8 +79,7 @@ function loadSerializedConfig( try { config = resolveSerializedConfig(configPath); } catch (e) { - console.log("config.json is invalid. Falling back to default."); - config = defaultConfig; + throw new Error(`Failed to parse config.json: ${e}`); } if (config.allowAnonymousTelemetry === undefined) { diff --git a/extensions/vscode/src/webviewProtocol.ts b/extensions/vscode/src/webviewProtocol.ts index 381b543e5..ebca69c18 100644 --- a/extensions/vscode/src/webviewProtocol.ts +++ b/extensions/vscode/src/webviewProtocol.ts @@ -83,7 +83,7 @@ export class VsCodeWebviewProtocol { JSON.stringify({ msg }, null, 2), ); - let message = `Continue error: ${e.message}`; + let message = 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`; diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index a51c85965..86dde5ccf 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -97,18 +97,7 @@ const initialState: State = { contextItems: [], active: false, config: { - models: [ - { - title: "GPT-4 (Free Trial)", - model: "gpt-4", - provider: "free-trial", - }, - { - title: "GPT-3.5-Turbo (Free Trial)", - model: "gpt-3.5-turbo", - provider: "free-trial", - }, - ], + models: [], slashCommands: [ { name: "edit", @@ -140,7 +129,7 @@ export const stateSlice = createSlice({ reducers: { setConfig: ( state, - { payload: config }: PayloadAction + { payload: config }: PayloadAction, ) => { const defaultModelTitle = config.models.find((model) => model.title === state.defaultModelTitle) @@ -168,7 +157,7 @@ export const stateSlice = createSlice({ }: PayloadAction<{ index: number; contextItems: ChatHistoryItem["contextItems"]; - }> + }>, ) => { if (state.history[index]) { state.history[index].contextItems = contextItems; @@ -178,7 +167,7 @@ export const stateSlice = createSlice({ state, { payload: { index, item }, - }: PayloadAction<{ index?: number; item: ContextItemWithId }> + }: PayloadAction<{ index?: number; item: ContextItemWithId }>, ) => { if (index === undefined) { const isFirstContextItem = @@ -201,7 +190,7 @@ export const stateSlice = createSlice({ }: PayloadAction<{ index: number; editorState: JSONContent; - }> + }>, ) => { const historyItem = state.history[payload.index]; if (!historyItem) { @@ -228,7 +217,7 @@ export const stateSlice = createSlice({ payload, }: PayloadAction<{ editorState: JSONContent; - }> + }>, ) => { state.history.push({ message: { role: "user", content: "" }, @@ -253,7 +242,7 @@ export const stateSlice = createSlice({ message: ChatMessage; index: number; contextItems?: ContextItemWithId[]; - }> + }>, ) => { if (payload.index >= state.history.length) { state.history.push({ @@ -281,7 +270,7 @@ export const stateSlice = createSlice({ }: PayloadAction<{ index: number; contextItems: ContextItemWithId[]; - }> + }>, ) => { const historyItem = state.history[payload.index]; if (!historyItem) { @@ -300,7 +289,7 @@ export const stateSlice = createSlice({ }, newSession: ( state, - { payload }: PayloadAction + { payload }: PayloadAction, ) => { if (payload) { state.history = payload.history; @@ -318,14 +307,14 @@ export const stateSlice = createSlice({ state, { payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }> + }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, ) => { const getKey = (id: ContextItemId) => `${id.providerTitle}-${id.itemId}`; const ids = new Set(payload.ids.map(getKey)); if (payload.index === undefined) { state.contextItems = state.contextItems.filter( - (item) => !ids.has(getKey(item.id)) + (item) => !ids.has(getKey(item.id)), ); } else { state.history[payload.index].contextItems = state.history[ @@ -337,7 +326,7 @@ export const stateSlice = createSlice({ state, { payload, - }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }> + }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>, ) => { let contextItems = [...state.contextItems].map((item) => { return { ...item, editing: false }; @@ -400,7 +389,7 @@ export const stateSlice = createSlice({ state, { payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }> + }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, ) => { const ids = payload.ids.map((id) => id.itemId); @@ -436,7 +425,7 @@ export const stateSlice = createSlice({ }, setDefaultModel: (state, { payload }: PayloadAction) => { const model = state.config.models.find( - (model) => model.title === payload + (model) => model.title === payload, ); if (!model) return; return { From 8ee0db6441de469d90ae5a2d282aab60a4c9e0a3 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 19:45:18 -0700 Subject: [PATCH 06/14] =?UTF-8?q?=F0=9F=A9=B9=20add=20.wav=20to=20ignored?= =?UTF-8?q?=20file=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/src/util/traverseDirectory.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode/src/util/traverseDirectory.ts b/extensions/vscode/src/util/traverseDirectory.ts index e1af01848..e97623163 100644 --- a/extensions/vscode/src/util/traverseDirectory.ts +++ b/extensions/vscode/src/util/traverseDirectory.ts @@ -51,6 +51,7 @@ const DEFAULT_IGNORE_FILETYPES = [ "*.onnx", "*.parquet", "*.pqt", + "*.wav", ]; export const defaultIgnoreFile = ignore().add(DEFAULT_IGNORE_FILETYPES); const DEFAULT_IGNORE_DIRS = [ From 315d179d829de4df88606af56673e7b4cb3ada0d Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 19:46:47 -0700 Subject: [PATCH 07/14] =?UTF-8?q?=F0=9F=A9=B9=20add=20.wav=20and=20.webp?= =?UTF-8?q?=20to=20list=20of=20ignored=20file=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/src/util/traverseDirectory.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/vscode/src/util/traverseDirectory.ts b/extensions/vscode/src/util/traverseDirectory.ts index e1af01848..cd4095da4 100644 --- a/extensions/vscode/src/util/traverseDirectory.ts +++ b/extensions/vscode/src/util/traverseDirectory.ts @@ -51,6 +51,8 @@ const DEFAULT_IGNORE_FILETYPES = [ "*.onnx", "*.parquet", "*.pqt", + "*.wav", + "*.webp", ]; export const defaultIgnoreFile = ignore().add(DEFAULT_IGNORE_FILETYPES); const DEFAULT_IGNORE_DIRS = [ From 15fd7ae3311c48abbb162383b584c3afd3ca6b42 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 21:39:08 -0700 Subject: [PATCH 08/14] =?UTF-8?q?=F0=9F=A9=B9=20switch=20to=20lowercase=20?= =?UTF-8?q?for=20docs=20lancedb=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/indexing/docs/db.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/core/indexing/docs/db.ts b/core/indexing/docs/db.ts index 151b220fb..2e94aba91 100644 --- a/core/indexing/docs/db.ts +++ b/core/indexing/docs/db.ts @@ -8,19 +8,20 @@ import { default as configs } from "./preIndexedDocs"; const DOCS_TABLE_NAME = "docs"; +// Purposefully lowercase because lancedb converts interface LanceDbDocsRow { title: string; - baseUrl: string; + baseurl: string; // Chunk content: string; path: string; - startLine: number; - endLine: number; + startline: number; + endline: number; vector: number[]; [key: string]: any; } -let dbDocs:Database; +let dbDocs: Database; async function getDBDocs() { if (!dbDocs) { @@ -28,7 +29,7 @@ async function getDBDocs() { filename: getDocsSqlitePath(), driver: sqlite3.Database, }); - + dbDocs.exec(`CREATE TABLE IF NOT EXISTS docs ( id INTEGER PRIMARY KEY AUTOINCREMENT, title STRING NOT NULL, @@ -75,10 +76,10 @@ export async function retrieveDocs( let docs: LanceDbDocsRow[] = await table .search(vector) .limit(nRetrieve) - .where(`baseUrl = '${baseUrl}'`) + .where(`baseurl = '${baseUrl}'`) .execute(); - docs = docs.filter((doc) => doc.baseUrl === baseUrl); + docs = docs.filter((doc) => doc.baseurl === baseUrl); if ((!docs || docs.length === 0) && !nested) { const downloaded = await downloadDocs(); @@ -88,8 +89,8 @@ export async function retrieveDocs( return docs.map((doc) => ({ digest: doc.path, filepath: doc.path, - startLine: doc.startLine, - endLine: doc.endLine, + startLine: doc.startline, + endLine: doc.endline, index: 0, content: doc.content, otherMetadata: { @@ -106,11 +107,11 @@ export async function addDocs( ) { const data: LanceDbDocsRow[] = chunks.map((chunk, i) => ({ title: chunk.otherMetadata?.title || title, - baseUrl: baseUrl.toString(), + baseurl: baseUrl.toString(), content: chunk.content, path: chunk.filepath, - startLine: chunk.startLine, - endLine: chunk.endLine, + startline: chunk.startLine, + endline: chunk.endLine, vector: embeddings[i], })); @@ -144,5 +145,5 @@ export async function listDocs(): Promise< export async function hasDoc(baseUrl: string) { const db = await getDBDocs(); const doc = await db.get(`SELECT title FROM docs WHERE baseUrl =?`, baseUrl); - return!!doc; + return !!doc; } From 8140600a8c17229a9afaf3f67cda620a40f8c387 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 21:43:16 -0700 Subject: [PATCH 09/14] =?UTF-8?q?=F0=9F=90=9B=20copy=20over=20xhr-sync-wor?= =?UTF-8?q?ker=20for=20jsdom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/indexing/docs/article.ts | 9 ++++----- extensions/vscode/esbuild.js | 2 +- extensions/vscode/scripts/prepackage.js | 15 ++++++++------- pkg/build.js | 22 ++++++++++++++-------- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/core/indexing/docs/article.ts b/core/indexing/docs/article.ts index ec9a0c98b..9cc90d34b 100644 --- a/core/indexing/docs/article.ts +++ b/core/indexing/docs/article.ts @@ -1,8 +1,9 @@ import { Readability } from "@mozilla/readability"; +import { JSDOM } from "jsdom"; import { Chunk } from "../.."; import { MAX_CHUNK_SIZE } from "../../llm/constants"; import { cleanFragment, cleanHeader } from "../chunk/markdown"; -import { PageData } from "./crawl" +import { PageData } from "./crawl"; export type ArticleComponent = { title: string; @@ -96,7 +97,6 @@ export function chunkArticle(articleResult: Article): Chunk[] { async function extractTitlesAndBodies( html: string, ): Promise { - const { JSDOM } = await import("jsdom"); const dom = new JSDOM(html); const document = dom.window.document; @@ -123,7 +123,6 @@ export async function stringToArticle( subpath: string, ): Promise
{ try { - const { JSDOM } = await import("jsdom"); const dom = new JSDOM(htmlContent); let reader = new Readability(dom.window.document); let article = reader.parse(); @@ -133,7 +132,7 @@ export async function stringToArticle( } let article_components = await extractTitlesAndBodies(article.content); - + return { url, subpath, @@ -147,7 +146,7 @@ export async function stringToArticle( } export async function pageToArticle( - page: PageData + page: PageData, ): Promise
{ try { return stringToArticle(page.url, page.html, page.path); diff --git a/extensions/vscode/esbuild.js b/extensions/vscode/esbuild.js index 67c307d05..fed18197a 100644 --- a/extensions/vscode/esbuild.js +++ b/extensions/vscode/esbuild.js @@ -6,7 +6,7 @@ const esbuildConfig = { entryPoints: ["src/extension.ts"], bundle: true, outfile: "out/extension.js", - external: ["vscode", "esbuild", "jsdom"], + external: ["vscode", "esbuild"], format: "cjs", platform: "node", sourcemap: true, diff --git a/extensions/vscode/scripts/prepackage.js b/extensions/vscode/scripts/prepackage.js index cdcf4c2b1..0cc7e8348 100644 --- a/extensions/vscode/scripts/prepackage.js +++ b/extensions/vscode/scripts/prepackage.js @@ -317,13 +317,7 @@ if (args[2] === "--target") { }); // Copy node_modules for pre-built binaries - const NODE_MODULES_TO_COPY = [ - "esbuild", - "@esbuild", - "@lancedb", - "@vscode", - "jsdom", - ]; + const NODE_MODULES_TO_COPY = ["esbuild", "@esbuild", "@lancedb", "@vscode"]; fs.mkdirSync("out/node_modules", { recursive: true }); await Promise.all( @@ -346,5 +340,12 @@ if (args[2] === "--target") { }), ), ); + console.log(`[info] Copied ${NODE_MODULES_TO_COPY.join(", ")}`); + + // Copy over any worker files + fs.cpSync( + "node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js", + "out/xhr-sync-worker.js", + ); })(); diff --git a/pkg/build.js b/pkg/build.js index 623df780d..414b17c42 100644 --- a/pkg/build.js +++ b/pkg/build.js @@ -7,7 +7,7 @@ const esbuildOutputFile = "out/index.js"; const platforms = ["darwin", "linux", "win32"]; const architectures = ["x64", "arm64"]; let targets = platforms.flatMap((platform) => - architectures.map((arch) => `${platform}-${arch}`) + architectures.map((arch) => `${platform}-${arch}`), ); let esbuildOnly = false; @@ -57,7 +57,7 @@ const targetToLanceDb = { } else { resolve(); } - } + }, ); ncp( `node_modules/${mod}`, @@ -69,10 +69,10 @@ const targetToLanceDb = { } else { resolve(); } - } + }, ); - }) - ) + }), + ), ); console.log(`[info] Copied ${DYNAMIC_IMPORTS.join(", ")}`); @@ -105,6 +105,12 @@ const targetToLanceDb = { define: { "import.meta.url": "importMetaUrl" }, }); + // Copy over any worker files + fs.cpSync( + "../core/node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js", + "out/xhr-sync-worker.js", + ); + if (esbuildOnly) { return; } @@ -114,7 +120,7 @@ const targetToLanceDb = { const targetDir = `bin/${target}`; console.log(`[info] Building ${target}...`); execSync( - `npx pkg --no-bytecode --public-packages "*" --public pkgJson/${target} --out-path ${targetDir}` + `npx pkg --no-bytecode --public-packages "*" --public pkgJson/${target} --out-path ${targetDir}`, ); // Download and unzip prebuilt sqlite3 binary for the target @@ -125,7 +131,7 @@ const targetToLanceDb = { execSync(`cd ${targetDir} && tar -xvzf build.tar.gz`); fs.copyFileSync( `${targetDir}/build/Release/node_sqlite3.node`, - `${targetDir}/node_sqlite3.node` + `${targetDir}/node_sqlite3.node`, ); fs.unlinkSync(`${targetDir}/build.tar.gz`); fs.rmSync(`${targetDir}/build`, { @@ -136,7 +142,7 @@ const targetToLanceDb = { // Download and unzip prebuilt esbuild binary for the target console.log(`[info] Downloading esbuild for ${target}...`); execSync( - `curl -o ${targetDir}/esbuild.tgz https://registry.npmjs.org/@esbuild/${target}/-/${target}-0.19.11.tgz` + `curl -o ${targetDir}/esbuild.tgz https://registry.npmjs.org/@esbuild/${target}/-/${target}-0.19.11.tgz`, ); execSync(`tar -xzvf ${targetDir}/esbuild.tgz -C ${targetDir}`); if (target.startsWith("win32")) { From 020782705d9c2db01cddbf0f91e183946bdf214c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 21:43:34 -0700 Subject: [PATCH 10/14] =?UTF-8?q?=F0=9F=92=9A=20remove=20--yarn=20from=20p?= =?UTF-8?q?ackage.js=20to=20match=20CI=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/scripts/package.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/scripts/package.js b/extensions/vscode/scripts/package.js index 3da971d49..208ef0019 100644 --- a/extensions/vscode/scripts/package.js +++ b/extensions/vscode/scripts/package.js @@ -9,8 +9,8 @@ if (!fs.existsSync("build")) { } const command = isPreRelease - ? "vsce package --out ./build patch --pre-release --yarn" - : "vsce package --out ./build patch --yarn"; + ? "vsce package --out ./build patch --pre-release" // --yarn" + : "vsce package --out ./build patch"; // --yarn"; exec(command, (error) => { if (error) throw error; From 3e9ca173f6b126f25426564fcfa7fc4c649a6c19 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 21:57:02 -0700 Subject: [PATCH 11/14] =?UTF-8?q?=F0=9F=A9=B9=20disable=20.yaml=20tree-sit?= =?UTF-8?q?ter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/util/treeSitter.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/util/treeSitter.ts b/core/util/treeSitter.ts index 4a54f2044..64a7d66d3 100644 --- a/core/util/treeSitter.ts +++ b/core/util/treeSitter.ts @@ -36,8 +36,9 @@ export const supportedLanguages: { [key: string]: string } = { cts: "typescript", tsx: "tsx", vue: "vue", - yaml: "yaml", - yml: "yaml", + // The .wasm file being used is faulty, and yaml is split line-by-line anyway for the most part + // yaml: "yaml", + // yml: "yaml", elm: "elm", js: "javascript", jsx: "javascript", From 6e5d4a4d1b4b046c9e081666adb6d873f4541b6e Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 21:57:22 -0700 Subject: [PATCH 12/14] =?UTF-8?q?=F0=9F=90=9B=20fix=20error=20loading=20co?= =?UTF-8?q?de=20context=20provider=20first=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/indexing/CodeSnippetsIndex.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/indexing/CodeSnippetsIndex.ts b/core/indexing/CodeSnippetsIndex.ts index c1ab1c68d..f8f92443f 100644 --- a/core/indexing/CodeSnippetsIndex.ts +++ b/core/indexing/CodeSnippetsIndex.ts @@ -27,7 +27,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { constructor(private readonly ide: IDE) {} - private async _createTables(db: DatabaseConnection) { + private static async _createTables(db: DatabaseConnection) { await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets ( id INTEGER PRIMARY KEY, path TEXT NOT NULL, @@ -98,7 +98,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { markComplete: MarkCompleteCallback, ): AsyncGenerator { const db = await SqliteDb.get(); - await this._createTables(db); + await CodeSnippetsCodebaseIndex._createTables(db); const tagString = tagToString(tag); for (let i = 0; i < results.compute.length; i++) { @@ -193,6 +193,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { static async getAll(tag: IndexTag): Promise { const db = await SqliteDb.get(); + await CodeSnippetsCodebaseIndex._createTables(db); try { const rows = await db.all( `SELECT cs.id, cs.path, cs.title From 871d0bb6d3c60743ca36709fe9bba14008f4eb65 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 22:06:52 -0700 Subject: [PATCH 13/14] =?UTF-8?q?=F0=9F=93=8C=20update=20package=20locks?= =?UTF-8?q?=20to=20new=20@continuedev/core=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/package-lock.json | 11 +++++++---- core/yarn.lock | 10 ++++++++++ extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/yarn.lock | 7 +------ gui/package-lock.json | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 545983547..9c82cd3d2 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -1,12 +1,12 @@ { - "name": "core", - "version": "1.0.0", + "name": "@continuedev/core", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "core", - "version": "1.0.0", + "name": "@continuedev/core", + "version": "1.0.4", "license": "Apache-2.0", "dependencies": { "@mozilla/readability": "^0.5.0", @@ -56,6 +56,9 @@ "esbuild": "^0.19.11", "jest": "^29.7.0", "ts-jest": "^29.1.1" + }, + "engines": { + "node": ">=20.11.0" } }, "node_modules/@75lb/deep-merge": { diff --git a/core/yarn.lock b/core/yarn.lock index e3d3fc3d9..795d82637 100644 --- a/core/yarn.lock +++ b/core/yarn.lock @@ -326,6 +326,11 @@ resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@esbuild/darwin-arm64@0.19.12": + version "0.19.12" + resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz" + integrity sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g== + "@eslint-community/eslint-utils@^4.2.0": version "4.4.0" resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz" @@ -2662,6 +2667,11 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== +fsevents@^2.3.2: + version "2.3.3" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index d2afbe815..49945c294 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -86,7 +86,7 @@ }, "../../core": { "name": "@continuedev/core", - "version": "1.0.1", + "version": "1.0.4", "license": "Apache-2.0", "dependencies": { "@mozilla/readability": "^0.5.0", @@ -123,7 +123,7 @@ "sqlite3": "^5.1.7", "tree-sitter-wasms": "^0.1.6", "uuid": "^9.0.1", - "vectordb": "^0.4.3", + "vectordb": "^0.4.12", "web-tree-sitter": "^0.21.0" }, "devDependencies": { diff --git a/extensions/vscode/yarn.lock b/extensions/vscode/yarn.lock index b47e18677..ca4f8e209 100644 --- a/extensions/vscode/yarn.lock +++ b/extensions/vscode/yarn.lock @@ -691,11 +691,6 @@ resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz" integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg== -"@lancedb/vectordb-darwin-arm64@*": - version "0.4.13" - resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.13.tgz" - integrity sha512-JfroNCG8yKIU931Y+x8d0Fp8C9DHUSC5j+CjI+e5err7rTWtie4j3JbsXlWAnPFaFEOg0Xk3BWkSikCvhPGJGg== - "@lancedb/vectordb-darwin-arm64@0.4.12": version "0.4.12" resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.12.tgz" @@ -2353,7 +2348,7 @@ core-util-is@1.0.2: integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== "core@file:../../core": - version "1.0.1" + version "1.0.4" resolved "file:../../core" dependencies: "@mozilla/readability" "^0.5.0" diff --git a/gui/package-lock.json b/gui/package-lock.json index 92bc8e738..29944de82 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -74,7 +74,7 @@ }, "../core": { "name": "@continuedev/core", - "version": "1.0.1", + "version": "1.0.4", "license": "Apache-2.0", "dependencies": { "@mozilla/readability": "^0.5.0", @@ -111,7 +111,7 @@ "sqlite3": "^5.1.7", "tree-sitter-wasms": "^0.1.6", "uuid": "^9.0.1", - "vectordb": "^0.4.3", + "vectordb": "^0.4.12", "web-tree-sitter": "^0.21.0" }, "devDependencies": { From 9792e683f9e52aaa6978653bb5a0f19482d2191d Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 20 Mar 2024 23:09:25 -0700 Subject: [PATCH 14/14] =?UTF-8?q?=F0=9F=94=96=20update=20package.json=20ve?= =?UTF-8?q?rsion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 92b991564..badb8cfb6 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.9.88", + "version": "0.9.92", "repository": { "type": "git", "url": "https://github.com/continuedev/continue"