From 90e994db3c106f9b63bd043203111e5e101071ba Mon Sep 17 00:00:00 2001 From: Mahdi Malaki Date: Thu, 17 Oct 2024 17:45:20 -0400 Subject: [PATCH 001/155] fix: 'inferenceConfig.stopSequences' failed to satisfy constraint: Member must have length less than or equal to 4 #2538 --- core/llm/llms/Bedrock.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 485b87015..9c6e4bb52 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -111,7 +111,15 @@ class Bedrock extends BaseLLM { maxTokens: options.maxTokens, temperature: options.temperature, topP: options.topP, - stopSequences: options.stop?.filter((stop) => stop.trim() !== ""), + // TODO: The current approach selects the first 4 items from the list to comply with Bedrock's requirement + // of having at least 4 stop sequences, as per the AWS documentation: + // https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_InferenceConfiguration.html + // However, it might be better to implement a strategy that dynamically selects the most appropriate stop sequences + // based on the context. + // TODO: Additionally, consider implementing a global exception handler for the provider to give users clearer feedback. + // For example, differentiate between client-side errors (4XX status codes) and server-side issues (5XX status codes), + // providing meaningful error messages to improve the user experience. + stopSequences: options.stop?.filter((stop) => stop.trim() !== "").slice(0, 4), }, }; } From 43349830ee3269479dad3e595d1ffb757dbd4650 Mon Sep 17 00:00:00 2001 From: Mahdi Malaki Date: Thu, 17 Oct 2024 22:07:16 -0400 Subject: [PATCH 002/155] fix the misleading comment --- core/llm/llms/Bedrock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 9c6e4bb52..1e6586a2a 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -112,7 +112,7 @@ class Bedrock extends BaseLLM { temperature: options.temperature, topP: options.topP, // TODO: The current approach selects the first 4 items from the list to comply with Bedrock's requirement - // of having at least 4 stop sequences, as per the AWS documentation: + // of having at most 4 stop sequences, as per the AWS documentation: // https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_InferenceConfiguration.html // However, it might be better to implement a strategy that dynamically selects the most appropriate stop sequences // based on the context. From b35d3e7d15c658d204286432df102dbcfe6cf192 Mon Sep 17 00:00:00 2001 From: Mahdi Malaki Date: Thu, 17 Oct 2024 22:13:11 -0400 Subject: [PATCH 003/155] modify the comment. --- core/llm/llms/Bedrock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 1e6586a2a..c143fa412 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -116,7 +116,7 @@ class Bedrock extends BaseLLM { // https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_InferenceConfiguration.html // However, it might be better to implement a strategy that dynamically selects the most appropriate stop sequences // based on the context. - // TODO: Additionally, consider implementing a global exception handler for the provider to give users clearer feedback. + // TODO: Additionally, consider implementing a global exception handler for the providers to give users clearer feedback. // For example, differentiate between client-side errors (4XX status codes) and server-side issues (5XX status codes), // providing meaningful error messages to improve the user experience. stopSequences: options.stop?.filter((stop) => stop.trim() !== "").slice(0, 4), From 83a5c5c800fb15510eee9ed6210ea9d6ef12d964 Mon Sep 17 00:00:00 2001 From: sadie100 <03sadie@gmail.com> Date: Fri, 18 Oct 2024 13:10:37 +0900 Subject: [PATCH 004/155] docs: add Ollama provider explanation --- docs/docs/customize/model-providers/top-level/ollama.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index 7a6a0776a..08ae3eec9 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -3,6 +3,8 @@ title: Ollama slug: ../ollama --- +Ollama is an open-source tool that allows users to run large language models (LLMs) locally on their own computers. To use Ollama providers, you need to install Ollama [here](https://ollama.ai/download) and download the model you want to run by `ollama pull` command. + ## Chat model We recommend configuring **Llama3.1 8B** as your chat model. From 6b35b5983b36dcfc0f039e80bca3eb7d0f6a40db Mon Sep 17 00:00:00 2001 From: sadie100 <03sadie@gmail.com> Date: Fri, 18 Oct 2024 14:13:29 +0900 Subject: [PATCH 005/155] docs: add Azure OpenAI explanation and link detailed setup info to the top --- docs/docs/customize/model-providers/top-level/azure.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/docs/customize/model-providers/top-level/azure.md b/docs/docs/customize/model-providers/top-level/azure.md index 814a056ea..8ade702f0 100644 --- a/docs/docs/customize/model-providers/top-level/azure.md +++ b/docs/docs/customize/model-providers/top-level/azure.md @@ -3,6 +3,14 @@ title: Azure OpenAI slug: ../azure --- +Azure OpenAI is a cloud-based service that provides access to OpenAI's large language models including GPT series, integrated with the security and enterprise features of the Microsoft Azure platform. To get started, you have to create an Azure OpenAI resource in [Azure portal](https://portal.azure.com). + +:::info + +For details on model setup, see [General model configuration](#general-model-configuration). + +::: + ## Chat model We recommend configuring **GPT-4o** as your chat model. From 0f8625faf4a43931fbee5cc5f9b1f14d6c67146c Mon Sep 17 00:00:00 2001 From: DongjaJ Date: Fri, 18 Oct 2024 14:24:42 +0900 Subject: [PATCH 006/155] refactor: declare private class properties and initialize --- core/indexing/chunk/ChunkCodebaseIndex.ts | 4 +--- core/indexing/refreshIndex.ts | 6 ++--- core/indexing/walkDir.ts | 22 +++++++++---------- core/util/generateRepoMap.ts | 12 +++++----- .../vscode/src/diff/vertical/decorations.ts | 12 +++------- .../vscode/src/diff/vertical/handler.ts | 18 +++++---------- .../vscode/src/terminal/terminalEmulator.ts | 5 +---- .../vscode/src/util/loadAutocompleteModel.ts | 6 +---- .../openai-adapters/src/apis/AzureOpenAI.ts | 4 +--- 9 files changed, 29 insertions(+), 60 deletions(-) diff --git a/core/indexing/chunk/ChunkCodebaseIndex.ts b/core/indexing/chunk/ChunkCodebaseIndex.ts index cdf91f359..e2d316d67 100644 --- a/core/indexing/chunk/ChunkCodebaseIndex.ts +++ b/core/indexing/chunk/ChunkCodebaseIndex.ts @@ -23,9 +23,7 @@ export class ChunkCodebaseIndex implements CodebaseIndex { private readonly pathSep: string, private readonly continueServerClient: IContinueServerClient, private readonly maxChunkSize: number, - ) { - this.readFile = readFile; - } + ) {} async *update( tag: IndexTag, diff --git a/core/indexing/refreshIndex.ts b/core/indexing/refreshIndex.ts index 51cbdb646..cf59899f1 100644 --- a/core/indexing/refreshIndex.ts +++ b/core/indexing/refreshIndex.ts @@ -416,11 +416,9 @@ export async function getComputeDeleteAddRemove( export class GlobalCacheCodeBaseIndex implements CodebaseIndex { relativeExpectedTime: number = 1; - private db: DatabaseConnection; - constructor(db: DatabaseConnection) { - this.db = db; - } + constructor(private db: DatabaseConnection) {} + artifactId = "globalCache"; static async create(): Promise { diff --git a/core/indexing/walkDir.ts b/core/indexing/walkDir.ts index eeeb064d0..4ce2d3961 100644 --- a/core/indexing/walkDir.ts +++ b/core/indexing/walkDir.ts @@ -38,15 +38,13 @@ type IgnoreContext = { }; class DFSWalker { - private readonly path: string; - private readonly ide: IDE; - private readonly options: WalkerOptions; private readonly ignoreFileNames: Set; - constructor(path: string, ide: IDE, options: WalkerOptions) { - this.path = path; - this.ide = ide; - this.options = options; + constructor( + private readonly path: string, + private readonly ide: IDE, + private readonly options: WalkerOptions, + ) { this.ignoreFileNames = new Set(options.ignoreFiles); } @@ -128,10 +126,7 @@ class DFSWalker { ignore: ignore().add(patterns), dirname: curDir.walkableEntry.relPath, }; - return [ - ...curDir.ignoreContexts, - newIgnoreContext - ]; + return [...curDir.ignoreContexts, newIgnoreContext]; } private async loadIgnoreFiles(entries: WalkableEntry[]): Promise { @@ -147,7 +142,10 @@ class DFSWalker { return this.ignoreFileNames.has(p); } - private shouldInclude(walkableEntry: WalkableEntry, ignoreContexts: IgnoreContext[]) { + private shouldInclude( + walkableEntry: WalkableEntry, + ignoreContexts: IgnoreContext[], + ) { if (this.entryIsSymlink(walkableEntry.entry)) { // If called from the root, a symlink either links to a real file in this repository, // and therefore will be walked OR it linksto something outside of the repository and diff --git a/core/util/generateRepoMap.ts b/core/util/generateRepoMap.ts index 785a62c41..fb4be85d7 100644 --- a/core/util/generateRepoMap.ts +++ b/core/util/generateRepoMap.ts @@ -12,9 +12,6 @@ export interface RepoMapOptions { } class RepoMapGenerator { - private llm: ILLM; - private ide: IDE; - private options: RepoMapOptions; private maxRepoMapTokens: number; private repoMapPath: string = getRepoMapFilePath(); @@ -32,10 +29,11 @@ class RepoMapGenerator { "this map contains the name of the file, and the signature for any " + "classes, methods, or functions in the file.\n\n"; - constructor(llm: ILLM, ide: IDE, options: RepoMapOptions) { - this.llm = llm; - this.ide = ide; - this.options = options; + constructor( + private llm: ILLM, + private ide: IDE, + private options: RepoMapOptions, + ) { this.maxRepoMapTokens = llm.contextLength * this.REPO_MAX_CONTEXT_LENGTH_RATIO; } diff --git a/extensions/vscode/src/diff/vertical/decorations.ts b/extensions/vscode/src/diff/vertical/decorations.ts index 276145207..5d3ae7525 100644 --- a/extensions/vscode/src/diff/vertical/decorations.ts +++ b/extensions/vscode/src/diff/vertical/decorations.ts @@ -36,16 +36,10 @@ export const belowIndexDecorationType = }); export class DecorationTypeRangeManager { - private decorationType: vscode.TextEditorDecorationType; - private editor: vscode.TextEditor; - constructor( - decorationType: vscode.TextEditorDecorationType, - editor: vscode.TextEditor, - ) { - this.decorationType = decorationType; - this.editor = editor; - } + private decorationType: vscode.TextEditorDecorationType, + private editor: vscode.TextEditor, + ) {} private ranges: vscode.Range[] = []; diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 125bf065d..d04e7a386 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -17,9 +17,6 @@ export interface VerticalDiffHandlerOptions { } export class VerticalDiffHandler implements vscode.Disposable { - private editor: vscode.TextEditor; - private startLine: number; - private endLine: number; private currentLineIndex: number; private cancelled = false; @@ -31,12 +28,10 @@ export class VerticalDiffHandler implements vscode.Disposable { private newLinesAdded = 0; - public options: VerticalDiffHandlerOptions; - constructor( - startLine: number, - endLine: number, - editor: vscode.TextEditor, + private startLine: number, + private endLine: number, + private editor: vscode.TextEditor, private readonly editorToVerticalDiffCodeLens: Map< string, VerticalDiffCodeLens[] @@ -46,18 +41,15 @@ export class VerticalDiffHandler implements vscode.Disposable { accept: boolean, ) => void, private readonly refreshCodeLens: () => void, - options: VerticalDiffHandlerOptions, + public options: VerticalDiffHandlerOptions, ) { this.currentLineIndex = startLine; - this.startLine = startLine; - this.endLine = endLine; - this.editor = editor; - this.options = options; this.redDecorationManager = new DecorationTypeRangeManager( redDecorationType, this.editor, ); + this.greenDecorationManager = new DecorationTypeRangeManager( greenDecorationType, this.editor, diff --git a/extensions/vscode/src/terminal/terminalEmulator.ts b/extensions/vscode/src/terminal/terminalEmulator.ts index d76823da6..b2a7a99a9 100644 --- a/extensions/vscode/src/terminal/terminalEmulator.ts +++ b/extensions/vscode/src/terminal/terminalEmulator.ts @@ -129,7 +129,6 @@ export class CapturedTerminal { private readonly writeEmitter: vscode.EventEmitter; private splitByCommandsBuffer = ""; - private readonly onCommandOutput: ((output: string) => void) | undefined; splitByCommandsListener(data: string) { // Split the output by commands so it can be sent to Continue Server @@ -164,10 +163,8 @@ export class CapturedTerminal { constructor( options: { name: string } & Partial, - onCommandOutput?: (output: string) => void, + private readonly onCommandOutput?: (output: string) => void, ) { - this.onCommandOutput = onCommandOutput; - // this.shellCmd = "bash"; // getDefaultShell(); this.shellCmd = getDefaultShell(); diff --git a/extensions/vscode/src/util/loadAutocompleteModel.ts b/extensions/vscode/src/util/loadAutocompleteModel.ts index 4437c11d1..9b86c7751 100644 --- a/extensions/vscode/src/util/loadAutocompleteModel.ts +++ b/extensions/vscode/src/util/loadAutocompleteModel.ts @@ -13,11 +13,7 @@ export class TabAutocompleteModel { private shownOllamaWarning = false; private shownDeepseekWarning = false; - private configHandler: ConfigHandler; - - constructor(configHandler: ConfigHandler) { - this.configHandler = configHandler; - } + constructor(private configHandler: ConfigHandler) {} clearLlm() { this._llm = undefined; diff --git a/packages/openai-adapters/src/apis/AzureOpenAI.ts b/packages/openai-adapters/src/apis/AzureOpenAI.ts index 6d74c029f..4ca592717 100644 --- a/packages/openai-adapters/src/apis/AzureOpenAI.ts +++ b/packages/openai-adapters/src/apis/AzureOpenAI.ts @@ -31,10 +31,8 @@ const MS_TOKEN = 30; export class AzureOpenAIApi implements BaseLlmApi { private client: OpenAIClient; - private config: LlmApiConfig; - constructor(config: LlmApiConfig) { - this.config = config; + constructor(private config: LlmApiConfig) { let proxyOptions; const PROXY = HTTPS_PROXY ?? HTTP_PROXY; if (PROXY) { From 87bc0f0ab42b852f77582d0df9f060a1c00442db Mon Sep 17 00:00:00 2001 From: DongjaJ Date: Fri, 18 Oct 2024 14:26:59 +0900 Subject: [PATCH 007/155] refactor: declare public class properties and initialize --- core/autocomplete/cache.ts | 6 +----- core/context/providers/CustomContextProvider.ts | 5 +---- .../codeLens/providers/DiffViewerCodeLensProvider.ts | 6 +----- .../providers/QuickActionsCodeLensProvider.ts | 12 +++--------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/core/autocomplete/cache.ts b/core/autocomplete/cache.ts index 5005480bf..3808edcb6 100644 --- a/core/autocomplete/cache.ts +++ b/core/autocomplete/cache.ts @@ -8,11 +8,7 @@ export class AutocompleteLruCache { private static capacity = 1000; private mutex = new Mutex(); - db: DatabaseConnection; - - constructor(db: DatabaseConnection) { - this.db = db; - } + constructor(public db: DatabaseConnection) {} static async get(): Promise { const db = await open({ diff --git a/core/context/providers/CustomContextProvider.ts b/core/context/providers/CustomContextProvider.ts index ac14dc9f4..26c9eaf87 100644 --- a/core/context/providers/CustomContextProvider.ts +++ b/core/context/providers/CustomContextProvider.ts @@ -8,10 +8,7 @@ import type { } from "../../"; class CustomContextProviderClass implements IContextProvider { - custom: CustomContextProvider; - constructor(custom: CustomContextProvider) { - this.custom = custom; - } + constructor(public custom: CustomContextProvider) {} get description(): ContextProviderDescription { return { diff --git a/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts index 405df9a24..4d5b23d55 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts @@ -4,11 +4,7 @@ import { DiffManager, DIFF_DIRECTORY } from "../../../diff/horizontal"; import { getMetaKeyLabel } from "../../../util/util"; export class DiffViewerCodeLensProvider implements vscode.CodeLensProvider { - diffManager: DiffManager; - - constructor(diffManager: DiffManager) { - this.diffManager = diffManager; - } + constructor(public diffManager: DiffManager) {} public provideCodeLenses( document: vscode.TextDocument, diff --git a/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts index 5f6748b61..5511a9098 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts @@ -62,13 +62,7 @@ export class QuickActionsCodeLensProvider implements vscode.CodeLensProvider { vscode.SymbolKind.Constructor, ]; - customQuickActionsConfig?: QuickActionConfig[]; - - constructor(customQuickActionsConfigs?: QuickActionConfig[]) { - if (customQuickActionsConfigs) { - this.customQuickActionsConfig = customQuickActionsConfigs; - } - } + constructor(public customQuickActionsConfigs?: QuickActionConfig[]) {} getCustomCommands( range: vscode.Range, @@ -145,8 +139,8 @@ export class QuickActionsCodeLensProvider implements vscode.CodeLensProvider { const symbols = await this.getTopLevelAndChildrenSymbols(document.uri); return symbols.flatMap(({ range }) => { - const commands: vscode.Command[] = !!this.customQuickActionsConfig - ? this.getCustomCommands(range, this.customQuickActionsConfig) + const commands: vscode.Command[] = !!this.customQuickActionsConfigs + ? this.getCustomCommands(range, this.customQuickActionsConfigs) : this.getDefaultCommand(range); return commands.map((command) => new vscode.CodeLens(range, command)); From dd71bf61afcd2d4cc46e7a6330c08e41d8ad3307 Mon Sep 17 00:00:00 2001 From: sadie100 <03sadie@gmail.com> Date: Fri, 18 Oct 2024 14:54:18 +0900 Subject: [PATCH 008/155] docs: add Anthropic explanation --- docs/docs/customize/model-providers/top-level/anthropic.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/customize/model-providers/top-level/anthropic.md b/docs/docs/customize/model-providers/top-level/anthropic.md index c4bb24a4c..fd22b3d6d 100644 --- a/docs/docs/customize/model-providers/top-level/anthropic.md +++ b/docs/docs/customize/model-providers/top-level/anthropic.md @@ -3,6 +3,8 @@ title: Anthropic slug: ../anthropic --- +Anthropic provider offers access to the Claude series of large language models, developed by Anthropic. + :::info You can get an API key from the [Anthropic console](https://console.anthropic.com/account/keys). From f8f681b523a6ccddd6658b76b78c65100e1d99ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E6=96=87=E6=B6=9B?= Date: Fri, 18 Oct 2024 15:56:39 +0800 Subject: [PATCH 009/155] fix edit command prefix and suffix range bug maxStartLine should minus 1 curEndLine should plus 1 --- core/commands/slash/edit.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/commands/slash/edit.ts b/core/commands/slash/edit.ts index c39fb2dc0..aafafa67e 100644 --- a/core/commands/slash/edit.ts +++ b/core/commands/slash/edit.ts @@ -95,10 +95,10 @@ export async function getPromptParts( } let filePrefix = fullFileContentsList - .slice(curStartLine, maxStartLine) + .slice(curStartLine, maxStartLine - 1) .join("\n"); let fileSuffix = fullFileContentsList - .slice(minEndLine, curEndLine - 1) + .slice(minEndLine, curEndLine + 1) .join("\n"); if (rif.contents.length > 0) { From 97a4a81f4dc27f3662d0c0522604a5db4624b05d Mon Sep 17 00:00:00 2001 From: Kyle Li Date: Fri, 18 Oct 2024 17:01:08 -0700 Subject: [PATCH 010/155] fix history bug --- extensions/vscode/package-lock.json | 1 + gui/src/hooks/useChatHandler.ts | 12 +++++++++++- gui/src/hooks/useHistory.tsx | 8 +++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index f7ab438b3..1abf35ad9 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -116,6 +116,7 @@ "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", "http-proxy-agent": "^7.0.1", "https-proxy-agent": "^7.0.3", diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index 655cfce96..c90c044dc 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -15,7 +15,7 @@ import { constructMessages } from "core/llm/constructMessages"; import { stripImages } from "core/llm/images"; import { getBasename, getRelativePath } from "core/util"; import { usePostHog } from "posthog-js/react"; -import { useEffect, useRef } from "react"; +import { useEffect, useRef, useState } from "react"; import { useSelector } from "react-redux"; import resolveEditorContent, { hasSlashCommandOrContextProvider, @@ -35,6 +35,7 @@ import { } from "../redux/slices/stateSlice"; import { resetNextCodeBlockToApplyIndex } from "../redux/slices/uiStateSlice"; import { RootState } from "../redux/store"; +import useHistory from "./useHistory"; function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { const posthog = usePostHog(); @@ -56,6 +57,14 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { const active = useSelector((store: RootState) => store.state.active); const activeRef = useRef(active); + const {saveSession} = useHistory(dispatch); + const [save, triggerSave] = useState(false); + + useEffect(() => { + saveSession(false); + }, [save]); + + useEffect(() => { activeRef.current = active; }, [active]); @@ -309,6 +318,7 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { ]); } finally { dispatch(setInactive()); + triggerSave(!save); } } diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index 62ccf5165..5f5391ebc 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -48,11 +48,14 @@ function useHistory(dispatch: Dispatch) { return result.status === "success" ? result.content : undefined; } - async function saveSession() { + async function saveSession(open_new_session = true) { if (state.history.length === 0) return; const stateCopy = { ...state }; - dispatch(newSession()); + if (open_new_session){ + dispatch(newSession()); + updateLastSessionId(stateCopy.sessionId); + } await new Promise((resolve) => setTimeout(resolve, 10)); if ( @@ -93,7 +96,6 @@ function useHistory(dispatch: Dispatch) { sessionId: stateCopy.sessionId, workspaceDirectory: window.workspacePaths?.[0] || "", }; - updateLastSessionId(stateCopy.sessionId); return await ideMessenger.request("history/save", sessionInfo); } From 889d49505d34726cbae85a380f0ef770e61ab9de Mon Sep 17 00:00:00 2001 From: sadie100 <03sadie@gmail.com> Date: Sat, 19 Oct 2024 10:13:30 +0900 Subject: [PATCH 011/155] docs: add Amazon Bedrock explanation --- docs/docs/customize/model-providers/top-level/bedrock.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/customize/model-providers/top-level/bedrock.md b/docs/docs/customize/model-providers/top-level/bedrock.md index 14cc70211..7129fd3bc 100644 --- a/docs/docs/customize/model-providers/top-level/bedrock.md +++ b/docs/docs/customize/model-providers/top-level/bedrock.md @@ -3,6 +3,8 @@ title: Amazon Bedrock slug: ../bedrock --- +Amazon Bedrock is a fully managed service that provides access to various foundation models from various AI companies through a single API, offering capabilities for building secure and responsible generative AI applications. + ## Chat model We recommend configuring **Claude 3.5 Sonnet** as your chat model. From 7204ea2bd049e01b443e5f050c5204b4588b824e Mon Sep 17 00:00:00 2001 From: Kyle Li Date: Fri, 18 Oct 2024 19:51:19 -0700 Subject: [PATCH 012/155] log quickEdit --- extensions/vscode/package-lock.json | 1 + extensions/vscode/src/diff/vertical/handler.ts | 3 +++ extensions/vscode/src/diff/vertical/manager.ts | 8 +++++--- extensions/vscode/src/quickEdit/QuickEditQuickPick.ts | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index f7ab438b3..1abf35ad9 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -116,6 +116,7 @@ "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", "http-proxy-agent": "^7.0.1", "https-proxy-agent": "^7.0.3", diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 125bf065d..ff42ede80 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -344,6 +344,7 @@ export class VerticalDiffHandler implements vscode.Disposable { } async run(diffLineGenerator: AsyncGenerator) { + let diffLines = [] try { // As an indicator of loading this.updateIndexLineDecorations(); @@ -352,6 +353,7 @@ export class VerticalDiffHandler implements vscode.Disposable { if (this.isCancelled) { return; } + diffLines.push(diffLine) await this.queueDiffLine(diffLine); } @@ -374,6 +376,7 @@ export class VerticalDiffHandler implements vscode.Disposable { this.clearForFilepath(this.filepath, false); throw e; } + return diffLines } async acceptRejectBlock( diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index 985a6ba29..5a6f8a96d 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -22,6 +22,8 @@ export class VerticalDiffManager { private userChangeListener: vscode.Disposable | undefined; + logDiffs: DiffLine[] | undefined; + constructor( private readonly configHandler: ConfigHandler, private readonly webviewProtocol: VsCodeWebviewProtocol, @@ -237,8 +239,8 @@ export class VerticalDiffManager { ); try { - await diffHandler.run(diffStream); - + this.logDiffs = await diffHandler.run(diffStream); + // enable a listener for user edits to file while diff is open this.enableDocumentChangeListener(); } catch (e) { @@ -410,7 +412,7 @@ export class VerticalDiffManager { ); try { - await diffHandler.run( + this.logDiffs = await diffHandler.run( streamDiffLines( prefix, rangeContent, diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 0cc11a0ad..3f3b014eb 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -15,6 +15,7 @@ import { ConfigHandler } from "core/config/ConfigHandler"; import { getModelByRole } from "core/config/util"; // @ts-ignore import MiniSearch from "minisearch"; +import { logDevData } from "core/util/devdata"; /** * Used to track what action to take after a user interacts @@ -236,7 +237,8 @@ export class QuickEdit { default: break; } - + let model = await this.getCurModelTitle(); + logDevData('quickEdit', {prompt, path, label, diffs: this.verticalDiffManager.logDiffs, model}); quickPick.dispose(); }); } From e83f8e19289803d29fdfa5fd2e2330e58e17ce4a Mon Sep 17 00:00:00 2001 From: Kyle Li Date: Fri, 18 Oct 2024 20:59:06 -0700 Subject: [PATCH 013/155] focus continue session id command --- core/protocol/ideWebview.ts | 1 + extensions/vscode/package-lock.json | 1 + extensions/vscode/package.json | 6 ++++++ extensions/vscode/src/commands.ts | 8 ++++++++ gui/src/components/mainInput/TipTapEditor.tsx | 13 ++++++++++++- 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 3b357b679..bf79315ee 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -66,6 +66,7 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { * @deprecated Use navigateTo with a path instead. */ viewHistory: [undefined, void]; + focusContinueSessionId: [{ sessionId: string | undefined }, void]; newSession: [undefined, void]; setTheme: [{ theme: any }, void]; setColors: [{ [key: string]: string }, void]; diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index f7ab438b3..1abf35ad9 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -116,6 +116,7 @@ "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", "http-proxy-agent": "^7.0.1", "https-proxy-agent": "^7.0.3", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 174c5dfdc..3166260c5 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -280,6 +280,12 @@ "category": "Continue", "title": "Docs Force Re-Index", "group": "Continue" + }, + { + "command": "continue.focusContinueSessionId", + "category": "Continue", + "title": "Focus Continue Chat", + "group": "Continue" } ], "keybindings": [ diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index babc695e3..e7373a300 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -480,6 +480,14 @@ const commandsMap: ( "continue.viewHistory": () => { sidebar.webviewProtocol?.request("viewHistory", undefined); }, + "continue.focusContinueSessionId": async (sessionId: string | undefined) => { + if (!sessionId) { + sessionId = await vscode.window.showInputBox({ + prompt: "Enter the Session ID" + }); + } + sidebar.webviewProtocol?.request("focusContinueSessionId", { sessionId }); + }, "continue.applyCodeFromChat": () => { sidebar.webviewProtocol.request("applyCodeFromChat", undefined); }, diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index d98bfef63..3e59f60de 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -151,7 +151,7 @@ function TipTapEditor(props: TipTapEditorProps) { ); const useActiveFile = useSelector(selectUseActiveFile); - const { saveSession } = useHistory(dispatch); + const { saveSession, loadSession } = useHistory(dispatch); const posthog = usePostHog(); const [isEditorFocused, setIsEditorFocused] = useState(false); @@ -807,6 +807,17 @@ function TipTapEditor(props: TipTapEditorProps) { !props.isMainInput, ); + useWebviewListener( + "focusContinueSessionId", + async (data) => { + if (!props.isMainInput) { + return; + } + loadSession(data.sessionId); + }, + [loadSession, props.isMainInput], + ); + const [showDragOverMsg, setShowDragOverMsg] = useState(false); useEffect(() => { From c36f23322265a0d9c28eb401acf49d76294a1249 Mon Sep 17 00:00:00 2001 From: DongjaJ Date: Sat, 19 Oct 2024 14:07:54 +0900 Subject: [PATCH 014/155] fix: modify access modifier public to private --- core/autocomplete/cache.ts | 2 +- core/context/providers/CustomContextProvider.ts | 2 +- .../codeLens/providers/DiffViewerCodeLensProvider.ts | 2 +- .../codeLens/providers/QuickActionsCodeLensProvider.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/autocomplete/cache.ts b/core/autocomplete/cache.ts index 3808edcb6..4886feb23 100644 --- a/core/autocomplete/cache.ts +++ b/core/autocomplete/cache.ts @@ -8,7 +8,7 @@ export class AutocompleteLruCache { private static capacity = 1000; private mutex = new Mutex(); - constructor(public db: DatabaseConnection) {} + constructor(private db: DatabaseConnection) {} static async get(): Promise { const db = await open({ diff --git a/core/context/providers/CustomContextProvider.ts b/core/context/providers/CustomContextProvider.ts index 26c9eaf87..f87a4554f 100644 --- a/core/context/providers/CustomContextProvider.ts +++ b/core/context/providers/CustomContextProvider.ts @@ -8,7 +8,7 @@ import type { } from "../../"; class CustomContextProviderClass implements IContextProvider { - constructor(public custom: CustomContextProvider) {} + constructor(private custom: CustomContextProvider) {} get description(): ContextProviderDescription { return { diff --git a/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts index 4d5b23d55..b67db0e52 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/DiffViewerCodeLensProvider.ts @@ -4,7 +4,7 @@ import { DiffManager, DIFF_DIRECTORY } from "../../../diff/horizontal"; import { getMetaKeyLabel } from "../../../util/util"; export class DiffViewerCodeLensProvider implements vscode.CodeLensProvider { - constructor(public diffManager: DiffManager) {} + constructor(private diffManager: DiffManager) {} public provideCodeLenses( document: vscode.TextDocument, diff --git a/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts index 5511a9098..08decb215 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/QuickActionsCodeLensProvider.ts @@ -62,7 +62,7 @@ export class QuickActionsCodeLensProvider implements vscode.CodeLensProvider { vscode.SymbolKind.Constructor, ]; - constructor(public customQuickActionsConfigs?: QuickActionConfig[]) {} + constructor(private customQuickActionsConfigs?: QuickActionConfig[]) {} getCustomCommands( range: vscode.Range, From dac28f939ba2f6988458809831fbfef3d1a491e5 Mon Sep 17 00:00:00 2001 From: Anantha Kandrapu Date: Fri, 18 Oct 2024 23:44:46 -0700 Subject: [PATCH 015/155] Added Cohere embeddings with bedrock provider --- .../embeddings/BedrockEmbeddingsProvider.ts | 68 +++++++++++++------ 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/core/indexing/embeddings/BedrockEmbeddingsProvider.ts b/core/indexing/embeddings/BedrockEmbeddingsProvider.ts index bf3bcac88..a5cfce6c4 100644 --- a/core/indexing/embeddings/BedrockEmbeddingsProvider.ts +++ b/core/indexing/embeddings/BedrockEmbeddingsProvider.ts @@ -6,11 +6,14 @@ import { fromIni } from "@aws-sdk/credential-providers"; import { EmbeddingsProviderName, EmbedOptions, FetchFunction } from "../../index.js"; import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js"; +interface ModelConfig { + formatPayload: (text: string) => any; + extractEmbeddings: (responseBody: any) => number[][]; +} + class BedrockEmbeddingsProvider extends BaseEmbeddingsProvider { - static providerName: EmbeddingsProviderName = "bedrock"; - - static defaultOptions: Partial | undefined = { + static defaultOptions: Partial = { model: "amazon.titan-embed-text-v2:0", region: "us-east-1" }; @@ -18,6 +21,7 @@ class BedrockEmbeddingsProvider extends BaseEmbeddingsProvider { constructor(options: EmbedOptions, fetch: FetchFunction) { super(options, fetch); + this.options.model = this.options.model || BedrockEmbeddingsProvider.defaultOptions.model!; if (!options.apiBase) { options.apiBase = `https://bedrock-runtime.${options.region}.amazonaws.com`; } @@ -29,7 +33,7 @@ class BedrockEmbeddingsProvider extends BaseEmbeddingsProvider { } } - async embed(chunks: string[]) { + async embed(chunks: string[]): Promise { const credentials = await this._getCredentials(); const client = new BedrockRuntimeClient({ region: this.options.region, @@ -43,41 +47,64 @@ class BedrockEmbeddingsProvider extends BaseEmbeddingsProvider { return ( await Promise.all( chunks.map(async (chunk) => { - const input = this._generateInvokeModelCommandInput(chunk, this.options); + const input = this._generateInvokeModelCommandInput(chunk); const command = new InvokeModelCommand(input); const response = await client.send(command); - if (response.body) { const responseBody = JSON.parse(new TextDecoder().decode(response.body)); - return [responseBody.embedding]; + return this._extractEmbeddings(responseBody); } + return []; }), ) ).flat(); } - private _generateInvokeModelCommandInput( - prompt: string, - options: EmbedOptions, - ): any { - const payload = { - "inputText": prompt, - "dimensions": 512, - "normalize": true - }; + private _generateInvokeModelCommandInput(text: string): any { + const modelConfig = this._getModelConfig(); + const payload = modelConfig.formatPayload(text); return { body: JSON.stringify(payload), modelId: this.options.model, - accept: "application/json", - contentType: "application/json" + accept: "*/*", + contentType: "application/json", }; } + private _extractEmbeddings(responseBody: any): number[][] { + const modelConfig = this._getModelConfig(); + return modelConfig.extractEmbeddings(responseBody); + } + + private _getModelConfig() { + const modelConfigs: { [key: string]: ModelConfig } = { + 'cohere': { + formatPayload: (text: string) => ({ + texts: [text], + input_type: "search_document", + truncate: "END", + }), + extractEmbeddings: (responseBody: any) => responseBody.embeddings || [], + }, + 'amazon.titan-embed': { + formatPayload: (text: string) => ({ + inputText: text, + }), + extractEmbeddings: (responseBody: any) => responseBody.embedding ? [responseBody.embedding] : [], + }, + }; + + const modelPrefix = Object.keys(modelConfigs).find(prefix => this.options.model!.startsWith(prefix)); + if (!modelPrefix) { + throw new Error(`Unsupported model: ${this.options.model}`); + } + return modelConfigs[modelPrefix]; + } + private async _getCredentials() { try { - return await - fromIni({ + return await fromIni({ profile: this.profile, ignoreCache: true })(); @@ -88,7 +115,6 @@ class BedrockEmbeddingsProvider extends BaseEmbeddingsProvider { return await fromIni()(); } } - } export default BedrockEmbeddingsProvider; From bfd9ed388cf05ba28b3844dd290c9214cd1e335e Mon Sep 17 00:00:00 2001 From: Anantha Kandrapu <90415186+Anantha-Kandrapu@users.noreply.github.com> Date: Sat, 19 Oct 2024 20:23:36 -0700 Subject: [PATCH 016/155] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 597256325..9751d618d 100644 --- a/README.md +++ b/README.md @@ -62,4 +62,4 @@ Check out the [contribution ideas board](https://github.com/orgs/continuedev/pro ## License -[Apache 2.0 © 2023 Continue Dev, Inc.](./LICENSE) +[Apache 2.0 © 2023-2024 Continue Dev, Inc.](./LICENSE) From 0d6e941fd44fec760154a2396589b8a651276590 Mon Sep 17 00:00:00 2001 From: Anantha Kandrapu <90415186+Anantha-Kandrapu@users.noreply.github.com> Date: Sat, 19 Oct 2024 20:24:56 -0700 Subject: [PATCH 017/155] Update CHANGELOG.md --- extensions/vscode/CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/extensions/vscode/CHANGELOG.md b/extensions/vscode/CHANGELOG.md index 55bd200ac..cabf54bf2 100644 --- a/extensions/vscode/CHANGELOG.md +++ b/extensions/vscode/CHANGELOG.md @@ -5,11 +5,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). -## 0.8.54 - 2024-10-15 -### Fixed -* Hotfix: throttle transformers.js embeddings provider - -## 0.8.53 - 2024-10-11 +Pre-release Changes ### Added * Web context provider * Cerebras inference provider From e53843492d16a5887c19a5d39be924fcfe17ba17 Mon Sep 17 00:00:00 2001 From: kongkong Date: Mon, 21 Oct 2024 17:14:07 +0800 Subject: [PATCH 018/155] Update webviewView --- extensions/vscode/src/ContinueGUIWebviewViewProvider.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts index ee11a1a64..4a39c0408 100644 --- a/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts +++ b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts @@ -58,6 +58,7 @@ export class ContinueGUIWebviewViewProvider _context: vscode.WebviewViewResolveContext, _token: vscode.CancellationToken, ): void | Thenable { + this._webviewView = webviewView; this._webview = webviewView.webview; this._webview.onDidReceiveMessage((message) => this.handleWebviewMessage(message), From d4168ede774ec75d8ca9264c194d6f852ce22fcb Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Mon, 21 Oct 2024 22:39:10 +0700 Subject: [PATCH 019/155] improv: linting --- .eslintrc.shared.json | 36 ++++++++++++++++++++++++++++++++ core/.eslintrc.json | 13 ++---------- core/package.json | 2 -- extensions/vscode/.eslintrc.json | 16 ++++---------- extensions/vscode/package.json | 3 +-- package.json | 4 +++- 6 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 .eslintrc.shared.json diff --git a/.eslintrc.shared.json b/.eslintrc.shared.json new file mode 100644 index 000000000..f4b9c4c78 --- /dev/null +++ b/.eslintrc.shared.json @@ -0,0 +1,36 @@ +{ + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "plugins": ["@typescript-eslint", "import"], + "rules": { + "@typescript-eslint/semi": "warn", + "curly": "warn", + "eqeqeq": "warn", + "no-throw-literal": "warn", + "semi": "off", + "import/order": [ + "warn", + { + "groups": [ + "builtin", + "external", + "internal", + "parent", + "sibling", + "index", + "object", + "type" + ], + "alphabetize": { + "order": "asc", + "caseInsensitive": true + }, + "newlines-between": "always" + } + ] + }, + "ignorePatterns": ["out", "dist", "**/*.d.ts"] +} diff --git a/core/.eslintrc.json b/core/.eslintrc.json index 04097f4db..ce1bc2575 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -1,21 +1,12 @@ { "root": true, - "parser": "@typescript-eslint/parser", + "extends": ["../.eslintrc.shared.json"], "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module", "project": "./tsconfig.json" }, - "plugins": ["@typescript-eslint", "import"], "rules": { "quotes": ["warn", "double", {}], "@typescript-eslint/naming-convention": "off", - "@typescript-eslint/semi": "warn", - "curly": "warn", - "eqeqeq": "warn", - "no-throw-literal": "warn", - "semi": "off", "@typescript-eslint/no-floating-promises": "warn" - }, - "ignorePatterns": ["out", "dist", "**/*.d.ts"] + } } diff --git a/core/package.json b/core/package.json index bdda48184..ed489d1f2 100644 --- a/core/package.json +++ b/core/package.json @@ -32,7 +32,6 @@ "cross-env": "^7.0.3", "esbuild": "0.17.19", "eslint": "^8", - "eslint-plugin-import": "^2.29.1", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "myers-diff": "^2.1.0", @@ -49,7 +48,6 @@ "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.0.2", "@typescript-eslint/eslint-plugin": "^7.8.0", - "@typescript-eslint/parser": "^7.8.0", "@xenova/transformers": "2.14.0", "adf-to-md": "^1.1.0", "async-mutex": "^0.5.0", diff --git a/extensions/vscode/.eslintrc.json b/extensions/vscode/.eslintrc.json index 5dfecab7e..c25ccff20 100644 --- a/extensions/vscode/.eslintrc.json +++ b/extensions/vscode/.eslintrc.json @@ -1,18 +1,10 @@ { "root": true, - "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" + "project": "./tsconfig.json" }, - "plugins": ["@typescript-eslint"], + "extends": ["../../.eslintrc.shared.json"], "rules": { - "@typescript-eslint/naming-convention": "warn", - "@typescript-eslint/semi": "warn", - "curly": "warn", - "eqeqeq": "warn", - "no-throw-literal": "warn", - "semi": "off" - }, - "ignorePatterns": ["out", "dist", "**/*.d.ts"] + "@typescript-eslint/naming-convention": "warn" + } } diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 28a70181a..49b687fe3 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.220", + "version": "0.9.222", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -539,7 +539,6 @@ "@types/vscode": "1.70", "@types/ws": "^8.5.4", "@typescript-eslint/eslint-plugin": "^5.45.0", - "@typescript-eslint/parser": "^5.45.0", "@vscode/vsce": "^2.22.0", "cargo-cp-artifact": "^0.1", "esbuild": "0.17.19", diff --git a/package.json b/package.json index 88e26a707..6d93be403 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,8 @@ { "devDependencies": { "prettier": "^3.3.3", - "prettier-plugin-tailwindcss": "^0.6.8" + "prettier-plugin-tailwindcss": "^0.6.8", + "@typescript-eslint/parser": "^7.8.0", + "eslint-plugin-import": "^2.29.1" } } From 853a62f28f54ddfd3f1633c611d043faa63fb3d2 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 21 Oct 2024 23:40:48 -0700 Subject: [PATCH 020/155] testing for autocomplete filtering --- core/autocomplete/test/filter.test.ts | 66 +++++++++++++++++++++++++ core/autocomplete/test/util.ts | 71 +++++++++++++++++++++++++++ core/llm/llms/Mock.ts | 14 +++--- core/util/filesystem.ts | 2 +- 4 files changed, 146 insertions(+), 7 deletions(-) create mode 100644 core/autocomplete/test/filter.test.ts create mode 100644 core/autocomplete/test/util.ts diff --git a/core/autocomplete/test/filter.test.ts b/core/autocomplete/test/filter.test.ts new file mode 100644 index 000000000..a146c870d --- /dev/null +++ b/core/autocomplete/test/filter.test.ts @@ -0,0 +1,66 @@ +import { dedent } from "../../util"; +import { testAutocompleteFiltering } from "./util"; + +describe("llms/Mock", () => { + it("should pass unless maybe I messed up the whitespace at the start or something idk", async () => { + const input = dedent` + class Calculator { + constructor() { + this.result = 0; + } + + add(number) { + this.result += number; + return this; + } + + subtract(number) { + this.result -= number; + return this; + } + + multiply(number) { + this.result *= number; + return this; + } + + divide(number) { + <|fim|> + + getResult() { + return this.result; + } + + reset() { + this.result = 0; + return this; + } + } + + `; + const completion = dedent` + if (number === 0) { + throw new Error("Cannot divide by zero"); + } + this.result /= number; + return this; + }`; + await testAutocompleteFiltering({ + input, + completion, + expectToDisplay: completion, + description: "divide", + filename: "test.js", + }); + }); + + it("should pass", async () => { + await testAutocompleteFiltering({ + input: "console.log('Hello <|fim|>!');", + completion: "World", + expectToDisplay: "World", + description: "Hello World", + filename: "test.js", + }); + }); +}); diff --git a/core/autocomplete/test/util.ts b/core/autocomplete/test/util.ts new file mode 100644 index 000000000..1b2e21ca9 --- /dev/null +++ b/core/autocomplete/test/util.ts @@ -0,0 +1,71 @@ +import fs from "node:fs"; +import path from "node:path"; +import Mock from "../../llm/llms/Mock"; +import { testConfigHandler, testIde } from "../../test/util/fixtures"; +import { AutocompleteInput, CompletionProvider } from "../completionProvider"; + +const FIM_DELIMITER = "<|fim|>"; + +function parseFimExample(text: string): { prefix: string; suffix: string } { + const [prefix, suffix] = text.split(FIM_DELIMITER); + return { prefix, suffix }; +} + +interface AutocompleteFileringTestInput { + description: string; + filename: string; + input: string; + completion: string; + expectToDisplay: string | null; +} + +export async function testAutocompleteFiltering( + test: AutocompleteFileringTestInput, +) { + const { prefix, suffix } = parseFimExample(test.input); + + // Setup necessary objects + const llm = new Mock({ + model: "mock", + }); + llm.completion = test.completion; + const ide = testIde; + const configHandler = testConfigHandler; + + // Create a real file + const [workspaceDir] = await ide.getWorkspaceDirs(); + const filepath = path.join(workspaceDir, test.filename); + fs.writeFileSync(filepath, test.input.replace(FIM_DELIMITER, "")); + + // Prepare completion input and provider + const completionProvider = new CompletionProvider( + configHandler, + ide, + async () => llm, + () => {}, + async () => [], + ); + + const line = prefix.split("\n").length - 1; + const character = prefix.split("\n")[line].length; + const autocompleteInput: AutocompleteInput = { + clipboardText: "", + completionId: "test-completion-id", + filepath, + pos: { + line, + character, + }, + recentlyEditedFiles: [], + recentlyEditedRanges: [], + }; + + // Generate a completion + const result = await completionProvider.provideInlineCompletionItems( + autocompleteInput, + undefined, + ); + + // Ensure that we return the text that is wanted to be displayed + expect(result?.completion).toEqual(test.expectToDisplay); +} diff --git a/core/llm/llms/Mock.ts b/core/llm/llms/Mock.ts index d5e2ef59c..e6097a60d 100644 --- a/core/llm/llms/Mock.ts +++ b/core/llm/llms/Mock.ts @@ -2,24 +2,26 @@ import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js"; import { BaseLLM } from "../index.js"; class Mock extends BaseLLM { - static Completion = "Test Completion"; + public completion: string = "Test Completion"; static providerName: ModelProvider = "mock"; protected async *_streamComplete( prompt: string, options: CompletionOptions, ): AsyncGenerator { - yield Mock.Completion; + yield this.completion; } protected async *_streamChat( messages: ChatMessage[], options: CompletionOptions, ): AsyncGenerator { - yield { - role: "assistant", - content: Mock.Completion, - }; + for (const char of this.completion) { + yield { + role: "assistant", + content: char, + }; + } } } diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 6e8bd6c0d..0f64d912c 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -38,7 +38,7 @@ class FileSystemIde implements IDE { throw new Error("Method not implemented."); } onDidChangeActiveTextEditor(callback: (filepath: string) => void): void { - throw new Error("Method not implemented."); + return; } async getIdeSettings(): Promise { From 6e543f4d08b08abbe0bc3c5652f237308048ceb6 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 22 Oct 2024 14:43:17 +0700 Subject: [PATCH 021/155] refactor: clean up code --- core/autocomplete/completionProvider.ts | 16 +++--- core/autocomplete/test/filter.test.ts | 64 ++---------------------- core/autocomplete/test/testCases.ts | 65 +++++++++++++++++++++++++ core/autocomplete/test/util.ts | 2 +- 4 files changed, 79 insertions(+), 68 deletions(-) create mode 100644 core/autocomplete/test/testCases.ts diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index bc826f934..6c1fed1cf 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -111,6 +111,14 @@ const ERRORS_TO_IGNORE = [ "unexpected server status", ]; +const LOCAL_PROVIDERS: ModelProvider[] = [ + "ollama", + "lmstudio", + "llama.cpp", + "llamafile", + "text-gen-webui", +]; + function formatExternalSnippet( filepath: string, snippet: string, @@ -335,13 +343,7 @@ export class CompletionProvider { } // Set model-specific options - const LOCAL_PROVIDERS: ModelProvider[] = [ - "ollama", - "lmstudio", - "llama.cpp", - "llamafile", - "text-gen-webui", - ]; + if ( !config.tabAutocompleteOptions?.maxPromptTokens && LOCAL_PROVIDERS.includes(llm.providerName) diff --git a/core/autocomplete/test/filter.test.ts b/core/autocomplete/test/filter.test.ts index a146c870d..98cef6be6 100644 --- a/core/autocomplete/test/filter.test.ts +++ b/core/autocomplete/test/filter.test.ts @@ -1,66 +1,10 @@ -import { dedent } from "../../util"; import { testAutocompleteFiltering } from "./util"; +import { testCases } from "./testCases"; describe("llms/Mock", () => { - it("should pass unless maybe I messed up the whitespace at the start or something idk", async () => { - const input = dedent` - class Calculator { - constructor() { - this.result = 0; - } - - add(number) { - this.result += number; - return this; - } - - subtract(number) { - this.result -= number; - return this; - } - - multiply(number) { - this.result *= number; - return this; - } - - divide(number) { - <|fim|> - - getResult() { - return this.result; - } - - reset() { - this.result = 0; - return this; - } - } - - `; - const completion = dedent` - if (number === 0) { - throw new Error("Cannot divide by zero"); - } - this.result /= number; - return this; - }`; - await testAutocompleteFiltering({ - input, - completion, - expectToDisplay: completion, - description: "divide", - filename: "test.js", - }); - }); - - it("should pass", async () => { - await testAutocompleteFiltering({ - input: "console.log('Hello <|fim|>!');", - completion: "World", - expectToDisplay: "World", - description: "Hello World", - filename: "test.js", + describe("Autocomplete Filtering Tests", () => { + it.each(testCases)("$description", async (testCase) => { + await testAutocompleteFiltering(testCase); }); }); }); diff --git a/core/autocomplete/test/testCases.ts b/core/autocomplete/test/testCases.ts new file mode 100644 index 000000000..4b9e3c05e --- /dev/null +++ b/core/autocomplete/test/testCases.ts @@ -0,0 +1,65 @@ +import { dedent } from "../../util"; +import { AutocompleteFileringTestInput } from "./util"; + +export const testCases: AutocompleteFileringTestInput[] = [ + { + description: + "should pass unless maybe I messed up the whitespace at the start or something idk", + filename: "test.js", + input: dedent` + class Calculator { + constructor() { + this.result = 0; + } + + add(number) { + this.result += number; + return this; + } + + subtract(number) { + this.result -= number; + return this; + } + + multiply(number) { + this.result *= number; + return this; + } + + divide(number) { + <|fim|> + + getResult() { + return this.result; + } + + reset() { + this.result = 0; + return this; + } + } + `, + completion: dedent` + if (number === 0) { + throw new Error("Cannot divide by zero"); + } + this.result /= number; + return this; + }`, + expectToDisplay: dedent` + if (number === 0) { + throw new Error("Cannot divide by zero"); + } + this.result /= number; + return this; + }`, + }, + { + description: "should pass", + filename: "test.js", + input: "console.log('Hello <|fim|>!');", + completion: "World", + expectToDisplay: "World", + }, +]; diff --git a/core/autocomplete/test/util.ts b/core/autocomplete/test/util.ts index 1b2e21ca9..0841a0dc2 100644 --- a/core/autocomplete/test/util.ts +++ b/core/autocomplete/test/util.ts @@ -11,7 +11,7 @@ function parseFimExample(text: string): { prefix: string; suffix: string } { return { prefix, suffix }; } -interface AutocompleteFileringTestInput { +export interface AutocompleteFileringTestInput { description: string; filename: string; input: string; From 38a43052a010a101f0d204f4ed296c0f2803d95b Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 22 Oct 2024 15:51:01 +0700 Subject: [PATCH 022/155] test: fix failing bracket tests --- core/autocomplete/completionProvider.ts | 7 -- .../services/BracketMatchingService.ts | 92 ------------------- core/autocomplete/test/testCases.ts | 8 +- 3 files changed, 3 insertions(+), 104 deletions(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 6c1fed1cf..e3d5a0a20 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -702,13 +702,6 @@ export class CompletionProvider { fullStop, ); charGenerator = stopAtStopTokens(charGenerator, stop); - charGenerator = this.bracketMatchingService.stopOnUnmatchedClosingBracket( - charGenerator, - prefix, - suffix, - filepath, - multiline, - ); let lineGenerator = streamLines(charGenerator); lineGenerator = stopAtLines(lineGenerator, fullStop); diff --git a/core/autocomplete/services/BracketMatchingService.ts b/core/autocomplete/services/BracketMatchingService.ts index 3734df2be..4d9dcd16b 100644 --- a/core/autocomplete/services/BracketMatchingService.ts +++ b/core/autocomplete/services/BracketMatchingService.ts @@ -39,96 +39,4 @@ export class BracketMatchingService { this.openingBracketsFromLastCompletion = stack; this.lastCompletionFile = filepath; } - - async *stopOnUnmatchedClosingBracket( - stream: AsyncGenerator, - prefix: string, - suffix: string, - filepath: string, - multiline: boolean, // Whether this is a multiline completion or not - ): AsyncGenerator { - let stack: string[] = []; - if (multiline) { - // Add opening brackets from the previous response - if (this.lastCompletionFile === filepath) { - stack = [...this.openingBracketsFromLastCompletion]; - } else { - this.lastCompletionFile = undefined; - } - } else { - // If single line completion, then allow completing bracket pairs that are - // started on the current line but not finished on the current line - if (!multiline) { - const currentLine = - (prefix.split("\n").pop() ?? "") + (suffix.split("\n")[0] ?? ""); - for (let i = 0; i < currentLine.length; i++) { - const char = currentLine[i]; - if (Object.keys(BracketMatchingService.BRACKETS).includes(char)) { - // It's an opening bracket - stack.push(char); - } else if ( - Object.values(BracketMatchingService.BRACKETS).includes(char) - ) { - // It's a closing bracket - if ( - stack.length === 0 || - BracketMatchingService.BRACKETS[stack.pop()!] !== char - ) { - break; - } - } - } - } - } - - // Add corresponding open brackets from suffix to stack - // because we overwrite them and the diff is displayed, and this allows something to be edited after that - for (let i = 0; i < suffix.length; i++) { - if (suffix[i] === " ") {continue;} - const openBracket = BracketMatchingService.BRACKETS_REVERSE[suffix[i]]; - if (!openBracket) {break;} - stack.unshift(openBracket); - } - - let all = ""; - let seenNonWhitespaceOrClosingBracket = false; - for await (let chunk of stream) { - // Allow closing brackets before any non-whitespace characters - if (!seenNonWhitespaceOrClosingBracket) { - const firstNonWhitespaceOrClosingBracketIndex = - chunk.search(/[^\s\)\}\]]/); - if (firstNonWhitespaceOrClosingBracketIndex !== -1) { - yield chunk.slice(0, firstNonWhitespaceOrClosingBracketIndex); - chunk = chunk.slice(firstNonWhitespaceOrClosingBracketIndex); - seenNonWhitespaceOrClosingBracket = true; - } else { - yield chunk; - continue; - } - } - - all += chunk; - const allLines = all.split("\n"); - for (let i = 0; i < chunk.length; i++) { - const char = chunk[i]; - if (Object.values(BracketMatchingService.BRACKETS).includes(char)) { - // It's a closing bracket - if ( - stack.length === 0 || - BracketMatchingService.BRACKETS[stack.pop()!] !== char - ) { - // If the stack is empty or the top of the stack doesn't match the current closing bracket - yield chunk.slice(0, i); - return; // Stop the generator if the closing bracket doesn't have a matching opening bracket in the stream - } - } else if ( - Object.keys(BracketMatchingService.BRACKETS).includes(char) - ) { - // It's an opening bracket - stack.push(char); - } - } - yield chunk; - } - } } diff --git a/core/autocomplete/test/testCases.ts b/core/autocomplete/test/testCases.ts index 4b9e3c05e..34484a7db 100644 --- a/core/autocomplete/test/testCases.ts +++ b/core/autocomplete/test/testCases.ts @@ -4,7 +4,7 @@ import { AutocompleteFileringTestInput } from "./util"; export const testCases: AutocompleteFileringTestInput[] = [ { description: - "should pass unless maybe I messed up the whitespace at the start or something idk", + "Should preserve closing brackets when the opening bracket is not a part of the completion.", filename: "test.js", input: dedent` class Calculator { @@ -40,15 +40,13 @@ export const testCases: AutocompleteFileringTestInput[] = [ } } `, - completion: dedent` - if (number === 0) { + completion: dedent`if (number === 0) { throw new Error("Cannot divide by zero"); } this.result /= number; return this; }`, - expectToDisplay: dedent` - if (number === 0) { + expectToDisplay: dedent`if (number === 0) { throw new Error("Cannot divide by zero"); } this.result /= number; From d09711ab5895aca1c91552e7d9140b3aa0535d77 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 22 Oct 2024 16:17:57 +0700 Subject: [PATCH 023/155] fix: broken build --- extensions/vscode/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode/tsconfig.json b/extensions/vscode/tsconfig.json index 157952843..b35899669 100644 --- a/extensions/vscode/tsconfig.json +++ b/extensions/vscode/tsconfig.json @@ -16,6 +16,7 @@ "exclude": [ "../../core/dist/**/*", "../../core/**/*.test.ts", + "../../core/**/test/**/*", "../../core/**/*.skip.ts" ] } From b6e6826676e5d6e87690b505d38806c39639d868 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 22 Oct 2024 15:59:52 +0200 Subject: [PATCH 024/155] replace tab-autocomplete untrained model error with warning --- core/autocomplete/completionProvider.ts | 54 +++++++++---------- .../src/quickEdit/QuickEditQuickPick.ts | 7 ++- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index bc826f934..52b48d6ca 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -480,9 +480,8 @@ export class CompletionProvider { !llm.model.toLowerCase().includes("codestral") ) { shownGptClaudeWarning = true; - throw new Error( - `Warning: ${llm.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/features/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`, - ); + await this.ide.showToast("warning", `${llm.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/features/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`); + return; // will not attempt autocomplete first time warning message shown } // Prompt @@ -494,11 +493,10 @@ export class CompletionProvider { if (input.injectDetails) { const lines = fullPrefix.split("\n"); - fullPrefix = `${lines.slice(0, -1).join("\n")}\n${ - lang.singleLineComment - } ${input.injectDetails - .split("\n") - .join(`\n${lang.singleLineComment} `)}\n${lines[lines.length - 1]}`; + fullPrefix = `${lines.slice(0, -1).join("\n")}\n${lang.singleLineComment + } ${input.injectDetails + .split("\n") + .join(`\n${lang.singleLineComment} `)}\n${lines[lines.length - 1]}`; } const fullSuffix = getRangeInString(fileContents, { @@ -519,17 +517,17 @@ export class CompletionProvider { let extrasSnippets = options.useOtherFiles ? ((await Promise.race([ - this.getDefinitionsFromLsp( - filepath, - fullPrefix + fullSuffix, - fullPrefix.length, - this.ide, - lang, - ), - new Promise((resolve) => { - setTimeout(() => resolve([]), 100); - }), - ])) as AutocompleteSnippet[]) + this.getDefinitionsFromLsp( + filepath, + fullPrefix + fullSuffix, + fullPrefix.length, + this.ide, + lang, + ), + new Promise((resolve) => { + setTimeout(() => resolve([]), 100); + }), + ])) as AutocompleteSnippet[]) : []; const workspaceDirs = await this.ide.getWorkspaceDirs(); @@ -568,8 +566,8 @@ export class CompletionProvider { completionOptions, compilePrefixSuffix = undefined, } = options.template - ? { template: options.template, completionOptions: {} } - : getTemplateForModel(llm.model); + ? { template: options.template, completionOptions: {} } + : getTemplateForModel(llm.model); let prompt: string; const filename = getBasename(filepath); @@ -666,14 +664,14 @@ export class CompletionProvider { () => llm.supportsFim() ? llm.streamFim(prefix, suffix, { - ...completionOptions, - stop, - }) + ...completionOptions, + stop, + }) : llm.streamComplete(prompt, { - ...completionOptions, - raw: true, - stop, - }), + ...completionOptions, + raw: true, + stop, + }), multiline, ); diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 0cc11a0ad..1116ed67f 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -319,9 +319,8 @@ export class QuickEdit { return isSelectionEmpty ? `Edit ${fileName}` - : `Edit ${fileName}:${start.line}${ - end.line > start.line ? `-${end.line}` : "" - }`; + : `Edit ${fileName}:${start.line}${end.line > start.line ? `-${end.line}` : "" + }`; }; private async _streamEditWithInputAndContext( @@ -385,7 +384,7 @@ export class QuickEdit { const modelTitle = await this.getCurModelTitle(); if (!modelTitle) { - this.ide.showToast("info", "Please configure a model to use Quick Edit"); + this.ide.showToast("error", "Please configure a model to use Quick Edit"); return { label: undefined, value: undefined }; } From 0243fb172e499f9851bf1735cfe2cb6b75adc629 Mon Sep 17 00:00:00 2001 From: Kyle Lacy Date: Tue, 22 Oct 2024 19:15:30 -0700 Subject: [PATCH 025/155] Fix false positives when checking if a file is in a workspace --- core/autocomplete/completionProvider.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index bc826f934..9b9f0a455 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -268,7 +268,10 @@ export class CompletionProvider { const workspaceDirs = await this.ide.getWorkspaceDirs(); let filepath = input.filepath; for (const workspaceDir of workspaceDirs) { - if (filepath.startsWith(workspaceDir)) { + const relativePath = path.relative(workspaceDir, filepath); + const relativePathBase = relativePath.split(path.sep).at(0); + const isInWorkspace = !path.isAbsolute(relativePath) && relativePathBase !== ".."; + if (isInWorkspace) { filepath = path.relative(workspaceDir, filepath); break; } From 0a5dc2bed250ecc37b1c1642012ff192aa029e8b Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 23 Oct 2024 04:27:43 +0200 Subject: [PATCH 026/155] validate tabautocomplete model(s) in config --- core/autocomplete/completionProvider.ts | 2 +- core/config/validation.ts | 33 +++++++++++++++++++++++-- sync/src/sync/merkle.rs | 2 +- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 52b48d6ca..94e969e3b 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -129,7 +129,7 @@ function formatExternalSnippet( } let shownGptClaudeWarning = false; -const nonAutocompleteModels = [ +export const nonAutocompleteModels = [ // "gpt", // "claude", "mistral", diff --git a/core/config/validation.ts b/core/config/validation.ts index 9da86c6ef..4177c7b2a 100644 --- a/core/config/validation.ts +++ b/core/config/validation.ts @@ -1,4 +1,5 @@ -import { SerializedContinueConfig } from "../"; +import { ModelDescription, SerializedContinueConfig } from "../"; +import { nonAutocompleteModels } from "../autocomplete/completionProvider"; import { Telemetry } from "../util/posthog"; export interface ConfigValidationError { @@ -14,7 +15,7 @@ export interface ConfigValidationError { export function validateConfig(config: SerializedContinueConfig) { const errors: ConfigValidationError[] = []; - // Validate models + // Validate chat models if (!Array.isArray(config.models) || config.models.length === 0) { errors.push({ fatal: true, @@ -34,9 +35,37 @@ export function validateConfig(config: SerializedContinueConfig) { message: `Model at index ${index} has an invalid 'provider'.`, }); } + if (typeof model.provider !== "string") { + errors.push({ + fatal: true, + message: `Model at index ${index} has an invalid 'provider'.`, + }); + } }); } + // Validate tab autocomplete model(s) + if (config.tabAutocompleteModel) { + function checkTabAutocompleteModel(modelDescription: ModelDescription, index?: number) { + if ( + nonAutocompleteModels.some((m) => modelDescription.model.includes(m)) && + !modelDescription.model.toLowerCase().includes("deepseek") && + !modelDescription.model.toLowerCase().includes("codestral") + ) { + errors.push({ + fatal: false, + message: `${modelDescription.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/features/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`, + }); + } + } + + if (Array.isArray(config.tabAutocompleteModel)) { + config.tabAutocompleteModel.forEach(checkTabAutocompleteModel); + } else { + checkTabAutocompleteModel(config.tabAutocompleteModel); + } + } + // Validate slashCommands if (config.slashCommands) { if (!Array.isArray(config.slashCommands)) { diff --git a/sync/src/sync/merkle.rs b/sync/src/sync/merkle.rs index 7dd99702a..5c78fb38f 100644 --- a/sync/src/sync/merkle.rs +++ b/sync/src/sync/merkle.rs @@ -423,7 +423,7 @@ fn global_ignore_path() -> PathBuf { let mut path = get_my_home().unwrap().unwrap(); path.push(".continue"); path.push("index"); - path.push(".globalcontinueignore"); + path.push(".continueignore"); path } From 180f7e547a8721982501cd416770f5017494e499 Mon Sep 17 00:00:00 2001 From: Luke Lashley Date: Tue, 22 Oct 2024 22:35:52 -0400 Subject: [PATCH 027/155] Add code-gecko --- core/llm/llms/VertexAI.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/core/llm/llms/VertexAI.ts b/core/llm/llms/VertexAI.ts index 772b30ea7..468bbbe1f 100644 --- a/core/llm/llms/VertexAI.ts +++ b/core/llm/llms/VertexAI.ts @@ -1,6 +1,7 @@ import { GoogleAuth } from "google-auth-library"; import { LLMOptions } from "../../index.js"; import { BaseLLM } from "../index.js"; +import { CompletionOptions } from "@continuedev/config-types"; abstract class VertexAI extends BaseLLM { declare apiBase: string; @@ -41,6 +42,42 @@ abstract class VertexAI extends BaseLLM { }, }); } + + supportsFim(): boolean { + return true; + } + + protected async *_streamFim( + prefix: string, + suffix: string, + options: CompletionOptions, + ): AsyncGenerator { + const endpoint = new URL("publishers/google/models/code-gecko:predict", this.apiBase); + const resp = await this.fetch(endpoint, { + method: "POST", + body: JSON.stringify({ + instances: [ + {prefix: prefix, + suffix: suffix + } + ], + parameters: { + temperature: options.temperature, + maxOutputTokens: Math.min(options.maxTokens ?? 64,64), + stopSequences: options.stop?.splice(0,5), + frequencyPenalty: options.frequencyPenalty, + presencePenalty: options.frequencyPenalty, + } + + }), + }); + // Streaming is not supported by code-gecko + // TODO: convert to non-streaming fim method when one exist in continue. + yield (await resp.json()).predictions[0].content; + } } + + + export default VertexAI; From 935295b26a55232bdc87e8ad475f9e1755126aa2 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 23 Oct 2024 04:41:44 +0200 Subject: [PATCH 028/155] validate tabautocomplete models in config v2 --- core/autocomplete/completionProvider.ts | 19 +++++++++++-------- core/config/validation.ts | 14 +++++--------- sync/src/sync/merkle.rs | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 94e969e3b..9d08e33a8 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -9,6 +9,7 @@ import { streamLines } from "../diff/util.js"; import { IDE, ILLM, + ModelDescription, ModelProvider, Position, Range, @@ -128,13 +129,20 @@ function formatExternalSnippet( return lines.join("\n"); } -let shownGptClaudeWarning = false; -export const nonAutocompleteModels = [ +const nonAutocompleteModels = [ // "gpt", // "claude", "mistral", "instruct", ]; +export function isModelTrainedForTabAutocomplete(model: string) { + return !( + nonAutocompleteModels.some((m) => model.includes(m)) && + !model.toLowerCase().includes("deepseek") && + !model.toLowerCase().includes("codestral") + ); +} +let shownGptClaudeWarning = false; export type GetLspDefinitionsFunction = ( filepath: string, @@ -473,12 +481,7 @@ export class CompletionProvider { llm.model = TRIAL_FIM_MODEL; } - if ( - !shownGptClaudeWarning && - nonAutocompleteModels.some((model) => llm.model.includes(model)) && - !llm.model.toLowerCase().includes("deepseek") && - !llm.model.toLowerCase().includes("codestral") - ) { + if (!isModelTrainedForTabAutocomplete(llm.model)) { shownGptClaudeWarning = true; await this.ide.showToast("warning", `${llm.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/features/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`); return; // will not attempt autocomplete first time warning message shown diff --git a/core/config/validation.ts b/core/config/validation.ts index 4177c7b2a..94b3f4f2c 100644 --- a/core/config/validation.ts +++ b/core/config/validation.ts @@ -1,5 +1,5 @@ import { ModelDescription, SerializedContinueConfig } from "../"; -import { nonAutocompleteModels } from "../autocomplete/completionProvider"; +import { isModelTrainedForTabAutocomplete } from "../autocomplete/completionProvider"; import { Telemetry } from "../util/posthog"; export interface ConfigValidationError { @@ -46,12 +46,8 @@ export function validateConfig(config: SerializedContinueConfig) { // Validate tab autocomplete model(s) if (config.tabAutocompleteModel) { - function checkTabAutocompleteModel(modelDescription: ModelDescription, index?: number) { - if ( - nonAutocompleteModels.some((m) => modelDescription.model.includes(m)) && - !modelDescription.model.toLowerCase().includes("deepseek") && - !modelDescription.model.toLowerCase().includes("codestral") - ) { + function validateTabAutocompleteModel(modelDescription: ModelDescription) { + if (!isModelTrainedForTabAutocomplete(modelDescription.model)) { errors.push({ fatal: false, message: `${modelDescription.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/features/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`, @@ -60,9 +56,9 @@ export function validateConfig(config: SerializedContinueConfig) { } if (Array.isArray(config.tabAutocompleteModel)) { - config.tabAutocompleteModel.forEach(checkTabAutocompleteModel); + config.tabAutocompleteModel.forEach(validateTabAutocompleteModel); } else { - checkTabAutocompleteModel(config.tabAutocompleteModel); + validateTabAutocompleteModel(config.tabAutocompleteModel); } } diff --git a/sync/src/sync/merkle.rs b/sync/src/sync/merkle.rs index 5c78fb38f..deb96ac80 100644 --- a/sync/src/sync/merkle.rs +++ b/sync/src/sync/merkle.rs @@ -446,7 +446,7 @@ pub fn build_walk(dir: &Path) -> Walk { let path = create_global_ignore_file(); // Make sure it sorts alphabetically by default let mut binding = WalkBuilder::new(dir); - let builder = binding.add_custom_ignore_filename(".continueignore"); + let builder = binding.add_custom_ignore_filename(".globalcontinueignore"); builder.add_ignore(path); builder.build() From 80d0b0484db24dd3753b1ed24710b7f8ff804a53 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 23 Oct 2024 04:43:28 +0200 Subject: [PATCH 029/155] reverse merkel update --- sync/src/sync/merkle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sync/src/sync/merkle.rs b/sync/src/sync/merkle.rs index deb96ac80..7dd99702a 100644 --- a/sync/src/sync/merkle.rs +++ b/sync/src/sync/merkle.rs @@ -423,7 +423,7 @@ fn global_ignore_path() -> PathBuf { let mut path = get_my_home().unwrap().unwrap(); path.push(".continue"); path.push("index"); - path.push(".continueignore"); + path.push(".globalcontinueignore"); path } @@ -446,7 +446,7 @@ pub fn build_walk(dir: &Path) -> Walk { let path = create_global_ignore_file(); // Make sure it sorts alphabetically by default let mut binding = WalkBuilder::new(dir); - let builder = binding.add_custom_ignore_filename(".globalcontinueignore"); + let builder = binding.add_custom_ignore_filename(".continueignore"); builder.add_ignore(path); builder.build() From d5a55b433489725da90f1c20f795651e9b10b6f5 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 22 Oct 2024 16:18:11 +0700 Subject: [PATCH 030/155] improv: multiline autocomplete for CSS blocks --- core/autocomplete/completionProvider.ts | 45 +++++++++++---- core/autocomplete/shouldCompleteMultiline.ts | 44 +------------- core/autocomplete/test/testCases.ts | 61 +++++++++++++++++--- core/autocomplete/test/util.ts | 8 +-- 4 files changed, 93 insertions(+), 65 deletions(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index e3d5a0a20..17f820efc 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -432,6 +432,33 @@ export class CompletionProvider { }; } + private isMultiline({ + language, + prefix, + suffix, + selectedCompletionInfo, + multilineCompletions, + completeMultiline, + }: { + language: AutocompleteLanguageInfo; + prefix: string; + suffix: string; + selectedCompletionInfo: AutocompleteInput["selectedCompletionInfo"]; + multilineCompletions: TabAutocompleteOptions["multilineCompletions"]; + completeMultiline: boolean; + }) { + let langMultilineDecision = language.useMultiline?.({ prefix, suffix }); + if (langMultilineDecision) { + return langMultilineDecision; + } else { + return ( + !selectedCompletionInfo && // Only ever single-line if using intellisense selected value + multilineCompletions !== "never" && + (multilineCompletions === "always" || completeMultiline) + ); + } + } + async getTabCompletion( token: AbortSignal, options: TabAutocompleteOptions, @@ -651,16 +678,14 @@ export class CompletionProvider { ...lang.topLevelKeywords.map((word) => `\n${word}`), ]; - let langMultilineDecision = lang.useMultiline?.({ prefix, suffix }); - let multiline: boolean = false; - if (langMultilineDecision) { - multiline = langMultilineDecision; - } else { - multiline = - !input.selectedCompletionInfo && // Only ever single-line if using intellisense selected value - options.multilineCompletions !== "never" && - (options.multilineCompletions === "always" || completeMultiline); - } + const multiline = this.isMultiline({ + multilineCompletions: options.multilineCompletions, + language: lang, + selectedCompletionInfo: input.selectedCompletionInfo, + prefix, + suffix, + completeMultiline, + }); // Try to reuse pending requests if what the user typed matches start of completion const generator = this.generatorReuseManager.getGenerator( diff --git a/core/autocomplete/shouldCompleteMultiline.ts b/core/autocomplete/shouldCompleteMultiline.ts index ae114151d..af244992e 100644 --- a/core/autocomplete/shouldCompleteMultiline.ts +++ b/core/autocomplete/shouldCompleteMultiline.ts @@ -3,33 +3,6 @@ import { AutocompleteLanguageInfo } from "./languages"; const BLOCK_TYPES = ["body", "statement_block"]; -function shouldCompleteMultilineAst( - treePath: AstPath, - cursorLine: number, -): boolean { - // If at the base of the file, do multiline - if (treePath.length === 1) { - return true; - } - - // If at the first line of an otherwise empty funtion body, do multiline - for (let i = treePath.length - 1; i >= 0; i--) { - const node = treePath[i]; - if ( - BLOCK_TYPES.includes(node.type) && - Math.abs(node.startPosition.row - cursorLine) <= 1 - ) { - let text = node.text; - text = text.slice(text.indexOf("{") + 1); - text = text.slice(0, text.lastIndexOf("}")); - text = text.trim(); - return text.split("\n").length === 1; - } - } - - return false; -} - function isMidlineCompletion(prefix: string, suffix: string): boolean { return !suffix.startsWith("\n"); } @@ -56,20 +29,5 @@ export async function shouldCompleteMultiline( return false; } - // First, if the line before ends with an opening bracket, then assume multi-line - if ( - ["{", "(", "["].includes( - fullPrefix.split("\n").slice(-2)[0]?.trim().slice(-1)[0], - ) - ) { - return true; - } - - // Use AST to determine whether to complete multiline - let completeMultiline = false; - if (treePath) { - const cursorLine = fullPrefix.split("\n").length - 1; - completeMultiline = shouldCompleteMultilineAst(treePath, cursorLine); - } - return completeMultiline; + return true; } diff --git a/core/autocomplete/test/testCases.ts b/core/autocomplete/test/testCases.ts index 34484a7db..64c9e8e37 100644 --- a/core/autocomplete/test/testCases.ts +++ b/core/autocomplete/test/testCases.ts @@ -2,6 +2,13 @@ import { dedent } from "../../util"; import { AutocompleteFileringTestInput } from "./util"; export const testCases: AutocompleteFileringTestInput[] = [ + { + description: "should pass", + filename: "test.js", + input: "console.log('Hello <|fim|>!');", + llmOutput: "World", + expectedCompletion: "World", + }, { description: "Should preserve closing brackets when the opening bracket is not a part of the completion.", @@ -29,7 +36,7 @@ export const testCases: AutocompleteFileringTestInput[] = [ divide(number) { <|fim|> - + getResult() { return this.result; } @@ -40,13 +47,13 @@ export const testCases: AutocompleteFileringTestInput[] = [ } } `, - completion: dedent`if (number === 0) { + llmOutput: dedent`if (number === 0) { throw new Error("Cannot divide by zero"); } this.result /= number; return this; }`, - expectToDisplay: dedent`if (number === 0) { + expectedCompletion: dedent`if (number === 0) { throw new Error("Cannot divide by zero"); } this.result /= number; @@ -54,10 +61,48 @@ export const testCases: AutocompleteFileringTestInput[] = [ }`, }, { - description: "should pass", - filename: "test.js", - input: "console.log('Hello <|fim|>!');", - completion: "World", - expectToDisplay: "World", + description: "Should multiline-autocomplete CSS blocks", + input: `body { + font-family: Arial, sans-serif; + font-size: 16px; + color: #333333; +} + +h1 { + font-size: 24px; + font-weight: bold; + color: #000000; +} + +h4<|fim|> + +a { + text-decoration: none; + color: #007bff; +} + +.container { + width: 100%; + max-width: 1200px; + margin: 0 auto; + padding: 20px; +} + +.button { + display: inline-block; + padding: 10px 20px; + background-color: #007bff; + color: #ffffff;`, + llmOutput: ` { + font-size: 18px; + font-weight: bold; + color: #000000; +}`, + expectedCompletion: ` { + font-size: 18px; + font-weight: bold; + color: #000000; +}`, + filename: "test.css", }, ]; diff --git a/core/autocomplete/test/util.ts b/core/autocomplete/test/util.ts index 0841a0dc2..8a65031a1 100644 --- a/core/autocomplete/test/util.ts +++ b/core/autocomplete/test/util.ts @@ -15,8 +15,8 @@ export interface AutocompleteFileringTestInput { description: string; filename: string; input: string; - completion: string; - expectToDisplay: string | null; + llmOutput: string; + expectedCompletion: string | null; } export async function testAutocompleteFiltering( @@ -28,7 +28,7 @@ export async function testAutocompleteFiltering( const llm = new Mock({ model: "mock", }); - llm.completion = test.completion; + llm.completion = test.llmOutput; const ide = testIde; const configHandler = testConfigHandler; @@ -67,5 +67,5 @@ export async function testAutocompleteFiltering( ); // Ensure that we return the text that is wanted to be displayed - expect(result?.completion).toEqual(test.expectToDisplay); + expect(result?.completion).toEqual(test.expectedCompletion); } From 7cc7b8b31a57aa28f8a86e6ce543d56cd779c0d9 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Wed, 23 Oct 2024 12:22:39 +0700 Subject: [PATCH 031/155] improve: remove redundant comment --- core/autocomplete/completionProvider.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 17f820efc..893f9bc36 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -342,8 +342,6 @@ export class CompletionProvider { llm.completionOptions.temperature = 0.01; } - // Set model-specific options - if ( !config.tabAutocompleteOptions?.maxPromptTokens && LOCAL_PROVIDERS.includes(llm.providerName) From 0918f24a296d021659135b3f6a3f86ca3dc45f4a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 23 Oct 2024 08:54:47 +0200 Subject: [PATCH 032/155] model names --- core/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/index.d.ts b/core/index.d.ts index 183d5e427..798721937 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -691,6 +691,11 @@ export type ModelName = // Llama 3.1 | "llama3.1-8b" | "llama3.1-70b" + // Llama 3.2 + | "llama3.2-1b" + | "llama3.2-3b" + | "llama3.2-11b" + | "llama3.2-90b" // Other Open-source | "phi2" | "phind-codellama-34b" From f6494d2f6647811d1078f08af83a334dd0393bfb Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 23 Oct 2024 09:09:02 +0200 Subject: [PATCH 033/155] update contributing model addition section --- CONTRIBUTING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d813a18a2..d1ca16637 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -200,10 +200,9 @@ Continue has support for more than a dozen different LLM "providers", making it While any model that works with a supported provider can be used with Continue, we keep a list of recommended models that can be automatically configured from the UI or `config.json`. The following files should be updated when adding a model: - [config_schema.json](./extensions/vscode/config_schema.json) - This is the JSON Schema definition that is used to validate `config.json`. You'll notice a number of rules defined in "definitions.ModelDescription.allOf". Here is where you write rules that can specify something like "for the provider 'anthropic', only models 'claude-2' and 'claude-instant-1' are allowed. Look through all of these rules and make sure that your model is included for providers that support it. -- [modelData.ts](./gui/src/util/modelData.ts) - This file defines that information that is shown in the model selection UI in the side bar. To add a new model: - 1. create a `ModelPackage` object, following the lead of the many examples near the top of the file - 2. add the `ModelPackage` to the `MODEL_INFO` array if you would like it to be displayed in the "Models" tab - 3. if you would like it to be displayed as an option under any of the providers, go to the `PROVIDER_INFO` object and add it to the `packages` array for each provider that you want it to be displayed under. If it is an OS model that should be valid for most providers offering OS models, you might just be able to add it to the `osModels` array as shorthand. +- [AddNewModel page](./gui/src/pages/AddNewModel) - This directory defines which model options are shown in the side bar model selection UI. To add a new model: + 1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file + 2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed) - [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this. - LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models). - [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates. From 15baeea3e458a98978e236973c64405417195094 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 23 Oct 2024 10:29:15 +0200 Subject: [PATCH 034/155] merkel --- sync/src/sync/merkle.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sync/src/sync/merkle.rs b/sync/src/sync/merkle.rs index 7dd99702a..827b63371 100644 --- a/sync/src/sync/merkle.rs +++ b/sync/src/sync/merkle.rs @@ -422,8 +422,7 @@ const GLOBAL_IGNORE_PATTERNS: &[&str] = &[ fn global_ignore_path() -> PathBuf { let mut path = get_my_home().unwrap().unwrap(); path.push(".continue"); - path.push("index"); - path.push(".globalcontinueignore"); + path.push(".continueignore"); path } From 1b4be003a137fba4ce0c51475e62861acb1a33b4 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 23 Oct 2024 08:41:04 -0700 Subject: [PATCH 035/155] destructure autocomplete object --- core/autocomplete/completionProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index bc826f934..3fd95dceb 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -388,7 +388,7 @@ export class CompletionProvider { // Wait 10 seconds, then assume it wasn't accepted outcome.accepted = false; logDevData("autocomplete", outcome); - const { prompt, completion, ...restOfOutcome } = outcome; + const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome; void Telemetry.capture( "autocomplete", { From 5782a2c809c124f530fe12a7d952c25ca33fe915 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 23 Oct 2024 09:53:02 -0700 Subject: [PATCH 036/155] explicit, don't use spread operator --- core/autocomplete/completionProvider.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 3fd95dceb..7e863e1c4 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -392,7 +392,19 @@ export class CompletionProvider { void Telemetry.capture( "autocomplete", { - ...restOfOutcome, + accepted: restOfOutcome.accepted, + cacheHit: restOfOutcome.cacheHit, + completionId: restOfOutcome.completionId, + completionOptions: restOfOutcome.completionOptions, + debounceDelay: restOfOutcome.debounceDelay, + fileExtension: restOfOutcome.filepath.split(".")?.slice(-1)[0], + maxPromptTokens: restOfOutcome.maxPromptTokens, + modelName: restOfOutcome.modelName, + modelProvider: restOfOutcome.modelProvider, + multilineCompletions: restOfOutcome.multilineCompletions, + time: restOfOutcome.time, + useRecentlyEdited: restOfOutcome.useRecentlyEdited, + useRootPathContext: restOfOutcome.useRootPathContext, }, true, ); From 0fe142a0cd99e8c2c0b4f5ca7702a039b822f568 Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 23 Oct 2024 12:20:20 -0700 Subject: [PATCH 037/155] chore: add release notes link to JB --- extensions/intellij/src/main/resources/META-INF/plugin.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index 572fe74b6..640fa05c1 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -2,7 +2,10 @@ com.github.continuedev.continueintellijextension Continue - continue-dev + continue-dev + + GitHub]]> + com.intellij.modules.platform com.intellij.modules.json From a2d76930ee3600edfe70fecf15c50c6af452d21b Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 23 Oct 2024 12:32:17 -0700 Subject: [PATCH 038/155] Update CONTRIBUTING.md --- extensions/intellij/CONTRIBUTING.md | 42 +++++++++++++++++------------ 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/extensions/intellij/CONTRIBUTING.md b/extensions/intellij/CONTRIBUTING.md index a08430c3b..0cd7b1d6a 100644 --- a/extensions/intellij/CONTRIBUTING.md +++ b/extensions/intellij/CONTRIBUTING.md @@ -1,23 +1,25 @@ # Contributing to Continue (JetBrains extension) -This file is for contribution guidelines specific to the JetBrains extension. See the root [`CONTRIBUTING.md`](../../CONTRIBUTING.md) for general contribution guidelines. +This file is for contribution guidelines specific to the JetBrains extension. See the root [ +`CONTRIBUTING.md`](../../CONTRIBUTING.md) for general contribution guidelines. ## Table of Contents - [Architecture Overview](#architecture-overview) - [Environment Setup](#environment-setup) - - [IDE Installation](#ide-installation) - - [IDE configuration](#ide-configuration) - - [Node.js Requirements](#nodejs-requirements) - - [Install all dependencies](#install-all-dependencies) - - [Misc](#misc) + - [IDE Installation](#ide-installation) + - [IDE configuration](#ide-configuration) + - [Node.js Requirements](#nodejs-requirements) + - [Install all dependencies](#install-all-dependencies) + - [Misc](#misc) - [Development Workflow](#development-workflow) - - [Running the extension](#running-the-extension) - - [Reloading changes](#reloading-changes) - - [Setting breakpoints](#setting-breakpoints) - - [Available Gradle tasks](#available-gradle-tasks) - - [Packaging](#packaging) - - [Testing the packaged extension](#testing-the-packaged-extension) + - [Running the extension](#running-the-extension) + - [Accessing files in the `.continue` directory](#accessing-files-in-the-continue-directory) + - [Reloading changes](#reloading-changes) + - [Setting breakpoints](#setting-breakpoints) + - [Available Gradle tasks](#available-gradle-tasks) + - [Packaging](#packaging) + - [Testing the packaged extension](#testing-the-packaged-extension) ## Architecture Overview @@ -65,20 +67,25 @@ have VS Code installed. - Open the project in VS Code and star the `Core binary` task - Switch back to Intellij and select the "Run Continue" configuration in the top-right corner of the IDE - Click the "Debug" button - - The first time running this will install the IDE version specified by the `platformVersion` property in [ - `./run/Run Extension.run.xml`](./.run/Run%20Extension.run.xml). This will take a moment as the installation size - can be close to 1GB. + - The first time running this will install the IDE version specified by the `platformVersion` property in [ + `./run/Run Extension.run.xml`](./.run/Run%20Extension.run.xml). This will take a moment as the installation size + can be close to 1GB. ![run-extension-screenshot](../../media/run-intellij-extension.png)\ This should open a new instance on IntelliJ with the extension installed and connected via TCP to the server started through the `Core binary` task. +### Accessing files in the `.continue` directory + +When running the `Core Binary` task, we set the location of your Continue directory to `./binary/.continue`. This is to +allow for changes to your `config.json` and other files during development, without affecting your actual configuration. + ### Reloading changes - `extensions/intellij`: Attempt to reload changed classes by selecting _Run | Debugging Actions | Reload Changed Classes`_ - - This will often fail on new imports, schema changes etc. In that case, you need to stop and restart the extension + - This will often fail on new imports, schema changes etc. In that case, you need to stop and restart the extension - `gui`: Changes will be reloaded automatically - `core`: Run `npm run build` from the `binary` directory and restart the `Core binary` task in VS Code @@ -111,7 +118,8 @@ verifyPluginConfiguration - Checks if Java and Kotlin compilers configuration me - Unix: `./gradlew buildPlugin` - Windows: `./gradlew.bat buildPlugin` -This will generate a .zip file in `./build/distributions` with the version defined in [`./gradle.properties`](./gradle.properties) +This will generate a .zip file in `./build/distributions` with the version defined in [ +`./gradle.properties`](./gradle.properties) #### Testing the packaged extension From b6c0a58b0eb099e2d9526937ed681190ed9dd7de Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 23 Oct 2024 13:35:30 -0700 Subject: [PATCH 039/155] adjust wording in docs --- docs/docs/customize/model-providers/top-level/anthropic.md | 2 -- docs/docs/customize/model-providers/top-level/azure.md | 2 +- docs/docs/customize/model-providers/top-level/bedrock.md | 2 +- docs/docs/customize/model-providers/top-level/ollama.md | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/docs/customize/model-providers/top-level/anthropic.md b/docs/docs/customize/model-providers/top-level/anthropic.md index fd22b3d6d..c4bb24a4c 100644 --- a/docs/docs/customize/model-providers/top-level/anthropic.md +++ b/docs/docs/customize/model-providers/top-level/anthropic.md @@ -3,8 +3,6 @@ title: Anthropic slug: ../anthropic --- -Anthropic provider offers access to the Claude series of large language models, developed by Anthropic. - :::info You can get an API key from the [Anthropic console](https://console.anthropic.com/account/keys). diff --git a/docs/docs/customize/model-providers/top-level/azure.md b/docs/docs/customize/model-providers/top-level/azure.md index 8ade702f0..adb390538 100644 --- a/docs/docs/customize/model-providers/top-level/azure.md +++ b/docs/docs/customize/model-providers/top-level/azure.md @@ -3,7 +3,7 @@ title: Azure OpenAI slug: ../azure --- -Azure OpenAI is a cloud-based service that provides access to OpenAI's large language models including GPT series, integrated with the security and enterprise features of the Microsoft Azure platform. To get started, you have to create an Azure OpenAI resource in [Azure portal](https://portal.azure.com). +Azure OpenAI is a cloud-based service that provides access to OpenAI's models, integrated with the security and enterprise features of the Microsoft Azure platform. To get started, create an Azure OpenAI resource in the [Azure portal](https://portal.azure.com). :::info diff --git a/docs/docs/customize/model-providers/top-level/bedrock.md b/docs/docs/customize/model-providers/top-level/bedrock.md index 7129fd3bc..8d46c5ad9 100644 --- a/docs/docs/customize/model-providers/top-level/bedrock.md +++ b/docs/docs/customize/model-providers/top-level/bedrock.md @@ -3,7 +3,7 @@ title: Amazon Bedrock slug: ../bedrock --- -Amazon Bedrock is a fully managed service that provides access to various foundation models from various AI companies through a single API, offering capabilities for building secure and responsible generative AI applications. +Amazon Bedrock is a fully managed service on AWS that provides access to foundation models from various AI companies through a single API. ## Chat model diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index 08ae3eec9..ae97d30c3 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -3,7 +3,7 @@ title: Ollama slug: ../ollama --- -Ollama is an open-source tool that allows users to run large language models (LLMs) locally on their own computers. To use Ollama providers, you need to install Ollama [here](https://ollama.ai/download) and download the model you want to run by `ollama pull` command. +Ollama is an open-source tool that allows to run large language models (LLMs) locally on their own computers. To use Ollama, you can install it [here](https://ollama.ai/download) and download the model you want to run with the `ollama run` command. ## Chat model From 44210afe7d9cfc63802189033200ac4de9dd2e43 Mon Sep 17 00:00:00 2001 From: Test Date: Wed, 23 Oct 2024 13:42:04 -0700 Subject: [PATCH 040/155] chore: add config to run core from intellij --- extensions/intellij/.run/Run Continue.run.xml | 3 ++- extensions/intellij/.run/Start Dev Server (core).run.xml | 9 +++++++++ ...ail Dev Logs.run.xml => Tail Dev Logs (core).run.xml} | 2 +- .../components/JetBrainsFetchGitHubTokenDialog.tsx | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 extensions/intellij/.run/Start Dev Server (core).run.xml rename extensions/intellij/.run/{Tail Dev Logs.run.xml => Tail Dev Logs (core).run.xml} (88%) diff --git a/extensions/intellij/.run/Run Continue.run.xml b/extensions/intellij/.run/Run Continue.run.xml index 32ba73bb9..cc705773b 100644 --- a/extensions/intellij/.run/Run Continue.run.xml +++ b/extensions/intellij/.run/Run Continue.run.xml @@ -1,7 +1,8 @@ - + + diff --git a/extensions/intellij/.run/Start Dev Server (core).run.xml b/extensions/intellij/.run/Start Dev Server (core).run.xml new file mode 100644 index 000000000..e7fe0ccac --- /dev/null +++ b/extensions/intellij/.run/Start Dev Server (core).run.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/extensions/intellij/.run/Tail Dev Logs.run.xml b/extensions/intellij/.run/Tail Dev Logs (core).run.xml similarity index 88% rename from extensions/intellij/.run/Tail Dev Logs.run.xml rename to extensions/intellij/.run/Tail Dev Logs (core).run.xml index 5685b4fd8..c92599ea4 100644 --- a/extensions/intellij/.run/Tail Dev Logs.run.xml +++ b/extensions/intellij/.run/Tail Dev Logs (core).run.xml @@ -1,5 +1,5 @@ - +