From 2a2ce8057792a8726a7e3d1daaccd4f2c39bcdcc Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 9 Jan 2024 22:26:13 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20codebase=20context=20provider?= =?UTF-8?q?=20to=20config.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/index.d.ts | 5 +++-- extensions/vscode/src/ideProtocol.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 6b1fbd064..0b35360a2 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -334,7 +334,8 @@ type ContextProviderName = | "search" | "url" | "tree" - | "http"; + | "http" + | "codebase"; type TemplateType = | "llama2" @@ -461,7 +462,7 @@ export type EmbeddingsProviderName = "transformers.js" | "ollama" | "openai"; export interface EmbedOptions { apiBase?: string; apiKey?: string; - model: string; + model?: string; } export interface EmbeddingsProviderDescription extends EmbedOptions { diff --git a/extensions/vscode/src/ideProtocol.ts b/extensions/vscode/src/ideProtocol.ts index 836b1520f..bcd0e31d6 100644 --- a/extensions/vscode/src/ideProtocol.ts +++ b/extensions/vscode/src/ideProtocol.ts @@ -75,6 +75,33 @@ class VsCodeIde implements IDE { fs.writeFileSync(configPath, contents, "utf8"); }); + migrate("codebaseContextProvider", () => { + if ( + !config.contextProviders?.filter((cp) => cp.name === "codebase") + ?.length + ) { + config.contextProviders = [ + ...(config.contextProviders || []), + { + name: "codebase", + params: {}, + }, + ]; + } + + if (!config.embeddingsProvider) { + config.embeddingsProvider = { + provider: "transformers.js", + }; + } + + fs.writeFileSync( + configPath, + JSON.stringify(config, undefined, 2), + "utf8" + ); + }); + for (const workspacePath of await this.getWorkspaceDirs()) { const continueRcPath = path.join(workspacePath, ".continuerc.json"); if (fs.existsSync(continueRcPath)) {