From 78ef8fe118ef227b73ad544a684ea20b56a0b63d Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 21 Nov 2024 10:39:59 -0800 Subject: [PATCH 01/14] refactor: clean up code, add tests --- core/autocomplete/CompletionProvider.ts | 8 ++-- core/autocomplete/aggregateSnippets.ts | 10 ++--- .../context/ContextRetrievalService.ts | 10 ++--- core/autocomplete/context/ranking/index.ts | 44 ++++++++++++------- .../context/ranking/slidingWindow.ts | 6 +-- .../RootPathContextService.ts | 14 +++--- core/autocomplete/filtering/test/testCases.ts | 12 +++++ core/autocomplete/filtering/test/util.ts | 1 - core/autocomplete/snippets/types.ts | 17 +++++++ .../templating/AutocompleteTemplate.ts | 16 +++---- core/autocomplete/templating/index.ts | 6 +-- core/autocomplete/util/types.ts | 1 - .../src/autocomplete/completionProvider.ts | 15 +------ extensions/vscode/src/autocomplete/lsp.ts | 16 ++++--- 14 files changed, 103 insertions(+), 73 deletions(-) create mode 100644 core/autocomplete/snippets/types.ts diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index b2cfbd9d9..c3445498e 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -10,7 +10,7 @@ import { aggregateSnippets } from "./aggregateSnippets"; // @prettier-ignore import { ContextRetrievalService } from "./context/ContextRetrievalService.js"; -import { AutocompleteSnippet } from "./context/ranking/index.js"; +import { AutocompleteSnippetDeprecated } from "./context/ranking/index.js"; import { BracketMatchingService } from "./filtering/BracketMatchingService.js"; import { CompletionStreamer } from "./generation/CompletionStreamer.js"; import { postprocessCompletion } from "./postprocessing/index.js"; @@ -38,7 +38,7 @@ export type GetLspDefinitionsFunction = ( cursorIndex: number, ide: IDE, lang: AutocompleteLanguageInfo, -) => Promise; +) => Promise; export class CompletionProvider { private autocompleteCache = AutocompleteLruCache.get(); @@ -291,7 +291,7 @@ export class CompletionProvider { private async _getExtraSnippets( helper: HelperVars, - ): Promise { + ): Promise { let extraSnippets = helper.options.useOtherFiles ? ((await Promise.race([ this.getDefinitionsFromLsp( @@ -304,7 +304,7 @@ export class CompletionProvider { new Promise((resolve) => { setTimeout(() => resolve([]), 100); }), - ])) as AutocompleteSnippet[]) + ])) as AutocompleteSnippetDeprecated[]) : []; const workspaceDirs = await this.ide.getWorkspaceDirs(); diff --git a/core/autocomplete/aggregateSnippets.ts b/core/autocomplete/aggregateSnippets.ts index f47b9021f..e6c750a4b 100644 --- a/core/autocomplete/aggregateSnippets.ts +++ b/core/autocomplete/aggregateSnippets.ts @@ -2,14 +2,14 @@ import { ContextRetrievalService } from "./context/ContextRetrievalService.js"; import { fillPromptWithSnippets, rankAndOrderSnippets, - type AutocompleteSnippet, + type AutocompleteSnippetDeprecated, } from "./context/ranking/index.js"; import { HelperVars } from "./util/HelperVars.js"; function filterSnippetsAlreadyInCaretWindow( - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], caretWindow: string, -): AutocompleteSnippet[] { +): AutocompleteSnippetDeprecated[] { return snippets .map((snippet) => ({ ...snippet })) .filter( @@ -20,9 +20,9 @@ function filterSnippetsAlreadyInCaretWindow( export async function aggregateSnippets( helper: HelperVars, - extraSnippets: AutocompleteSnippet[], + extraSnippets: AutocompleteSnippetDeprecated[], contextRetrievalService: ContextRetrievalService, -): Promise { +): Promise { let snippets = await contextRetrievalService.retrieveCandidateSnippets( helper, extraSnippets, diff --git a/core/autocomplete/context/ContextRetrievalService.ts b/core/autocomplete/context/ContextRetrievalService.ts index 24f6e9182..66b67eec3 100644 --- a/core/autocomplete/context/ContextRetrievalService.ts +++ b/core/autocomplete/context/ContextRetrievalService.ts @@ -3,7 +3,7 @@ import { HelperVars } from "../util/HelperVars"; import { RecentlyEditedRange } from "../util/types"; import { ImportDefinitionsService } from "./ImportDefinitionsService"; -import { AutocompleteSnippet, getSymbolsForSnippet } from "./ranking"; +import { AutocompleteSnippetDeprecated, getSymbolsForSnippet } from "./ranking"; import { RootPathContextService } from "./root-path-context/RootPathContextService"; export class ContextRetrievalService { @@ -20,13 +20,13 @@ export class ContextRetrievalService { public async retrieveCandidateSnippets( helper: HelperVars, - extraSnippets: AutocompleteSnippet[], + extraSnippets: AutocompleteSnippetDeprecated[], ) { if (helper.options.useOtherFiles === false) { return []; } - let snippets: AutocompleteSnippet[] = []; + let snippets: AutocompleteSnippetDeprecated[] = []; // Snippets injected by the IDE for IDE-specific reasons snippets.push(...extraSnippets); @@ -52,7 +52,7 @@ export class ContextRetrievalService { private getSnippetsFromRecentlyEditedRanges( helper: HelperVars, - ): AutocompleteSnippet[] { + ): AutocompleteSnippetDeprecated[] { if (helper.options.useRecentlyEdited === false) { return []; } @@ -85,7 +85,7 @@ export class ContextRetrievalService { private async getSnippetsFromImportDefinitions( helper: HelperVars, - ): Promise { + ): Promise { if (helper.options.useImports === false) { return []; } diff --git a/core/autocomplete/context/ranking/index.ts b/core/autocomplete/context/ranking/index.ts index 3e83afca5..28e9b8112 100644 --- a/core/autocomplete/context/ranking/index.ts +++ b/core/autocomplete/context/ranking/index.ts @@ -3,7 +3,12 @@ import { Range } from "../../../index.js"; import { countTokens } from "../../../llm/countTokens.js"; import { HelperVars } from "../../util/HelperVars.js"; -export type AutocompleteSnippet = RangeInFileWithContents & { +/** + * @deprecated This type should be removed in the future or renamed. + * We have a new interface called AutocompleteSnippet which is more + * general. + */ +export type AutocompleteSnippetDeprecated = RangeInFileWithContents & { score?: number; }; @@ -43,9 +48,9 @@ export function jaccardSimilarity(a: string, b: string): number { * Rank code snippets to be used in tab-autocomplete prompt. Returns a sorted version of the snippet array. */ export function rankAndOrderSnippets( - ranges: AutocompleteSnippet[], + ranges: AutocompleteSnippetDeprecated[], helper: HelperVars, -): Required[] { +): Required[] { const windowAroundCursor = helper.fullPrefix.slice( -helper.options.slidingWindowSize * @@ -56,11 +61,14 @@ export function rankAndOrderSnippets( (1 - helper.options.slidingWindowPrefixPercentage), ); - const snippets: Required[] = ranges.map((snippet) => ({ - score: - snippet.score ?? jaccardSimilarity(snippet.contents, windowAroundCursor), - ...snippet, - })); + const snippets: Required[] = ranges.map( + (snippet) => ({ + score: + snippet.score ?? + jaccardSimilarity(snippet.contents, windowAroundCursor), + ...snippet, + }), + ); const uniqueSnippets = deduplicateSnippets(snippets); return uniqueSnippets.sort((a, b) => a.score - b.score); } @@ -69,10 +77,12 @@ export function rankAndOrderSnippets( * Deduplicate code snippets by merging overlapping ranges into a single range. */ export function deduplicateSnippets( - snippets: Required[], -): Required[] { + snippets: Required[], +): Required[] { // Group by file - const fileGroups: { [key: string]: Required[] } = {}; + const fileGroups: { + [key: string]: Required[]; + } = {}; for (const snippet of snippets) { if (!fileGroups[snippet.filepath]) { fileGroups[snippet.filepath] = []; @@ -89,8 +99,8 @@ export function deduplicateSnippets( } function mergeSnippetsByRange( - snippets: Required[], -): Required[] { + snippets: Required[], +): Required[] { if (snippets.length <= 1) { return snippets; } @@ -98,7 +108,7 @@ function mergeSnippetsByRange( const sorted = snippets.sort( (a, b) => a.range.start.line - b.range.start.line, ); - const merged: Required[] = []; + const merged: Required[] = []; while (sorted.length > 0) { const next = sorted.shift()!; @@ -134,12 +144,12 @@ function mergeOverlappingRangeContents( * It is assumed that the snippets are sorted by score. */ export function fillPromptWithSnippets( - snippets: Required[], + snippets: Required[], maxSnippetTokens: number, modelName: string, -): Required[] { +): Required[] { let tokensRemaining = maxSnippetTokens; - const keptSnippets: Required[] = []; + const keptSnippets: Required[] = []; for (let i = 0; i < snippets.length; i++) { const snippet = snippets[i]; const tokenCount = countTokens(snippet.contents, modelName); diff --git a/core/autocomplete/context/ranking/slidingWindow.ts b/core/autocomplete/context/ranking/slidingWindow.ts index 7b650eb44..3fd3a3f17 100644 --- a/core/autocomplete/context/ranking/slidingWindow.ts +++ b/core/autocomplete/context/ranking/slidingWindow.ts @@ -1,6 +1,6 @@ import { RangeInFileWithContents } from "../../../commands/util.js"; -import { AutocompleteSnippet, jaccardSimilarity } from "./index.js"; +import { AutocompleteSnippetDeprecated, jaccardSimilarity } from "./index.js"; function* slidingWindow( content: string, @@ -37,9 +37,9 @@ export async function slidingWindowMatcher( windowAroundCursor: string, topN: number, windowSize: number, -): Promise { +): Promise { // Sorted lowest similarity to highest - const topMatches: Required[] = []; + const topMatches: Required[] = []; for (const { filepath, contents, range } of recentFiles) { for (const window of slidingWindow(contents, windowSize)) { diff --git a/core/autocomplete/context/root-path-context/RootPathContextService.ts b/core/autocomplete/context/root-path-context/RootPathContextService.ts index 0147df151..98a947fb1 100644 --- a/core/autocomplete/context/root-path-context/RootPathContextService.ts +++ b/core/autocomplete/context/root-path-context/RootPathContextService.ts @@ -12,7 +12,7 @@ import { } from "../../../util/treeSitter"; import { AstPath } from "../../util/ast"; import { ImportDefinitionsService } from "../ImportDefinitionsService"; -import { AutocompleteSnippet } from "../ranking"; +import { AutocompleteSnippetDeprecated } from "../ranking"; function getSyntaxTreeString( node: Parser.SyntaxNode, @@ -30,7 +30,7 @@ function getSyntaxTreeString( } export class RootPathContextService { - private cache = new LRUCache({ + private cache = new LRUCache({ max: 100, }); @@ -72,8 +72,8 @@ export class RootPathContextService { private async getSnippetsForNode( filepath: string, node: Parser.SyntaxNode, - ): Promise { - const snippets: AutocompleteSnippet[] = []; + ): Promise { + const snippets: AutocompleteSnippetDeprecated[] = []; const language = getFullLanguageName(filepath); let query: Parser.Query | undefined; @@ -123,7 +123,7 @@ export class RootPathContextService { filepath: string, endPosition: Parser.Point, language: LanguageName, - ): Promise { + ): Promise { const definitions = await this.ide.gotoDefinition({ filepath, position: { @@ -153,8 +153,8 @@ export class RootPathContextService { filepath: string, astPath: AstPath, // cursorIndex: number, - ): Promise { - const snippets: AutocompleteSnippet[] = []; + ): Promise { + const snippets: AutocompleteSnippetDeprecated[] = []; let parentKey = filepath; for (const astNode of astPath.filter((node) => diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index f0584ab48..0640b6918 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -1565,7 +1565,19 @@ interface User { age: number; }`, }, + { + description: "Should autocomplete TypeScript interface declarations", + filename: "autocomplete.ts", + input: `interface AutocompleteDiffSnippet extends BaseAutocompleteSnippet {} +interface AutocompleteCodeSnippet`, + llmOutput: ` extends BaseAutocompleteSnippet { + filepath: string; +}`, + expectedCompletion: ` extends BaseAutocompleteSnippet { + filepath: string; +}`, + }, { description: "Should autocomplete a TypeScript arrow function inside a variable assignment", diff --git a/core/autocomplete/filtering/test/util.ts b/core/autocomplete/filtering/test/util.ts index 42ab196b7..dc35d5f94 100644 --- a/core/autocomplete/filtering/test/util.ts +++ b/core/autocomplete/filtering/test/util.ts @@ -54,7 +54,6 @@ export async function testAutocompleteFiltering( const line = prefix.split("\n").length - 1; const character = prefix.split("\n")[line].length; const autocompleteInput: AutocompleteInput = { - clipboardText: "", completionId: "test-completion-id", filepath, pos: { diff --git a/core/autocomplete/snippets/types.ts b/core/autocomplete/snippets/types.ts new file mode 100644 index 000000000..e39406b11 --- /dev/null +++ b/core/autocomplete/snippets/types.ts @@ -0,0 +1,17 @@ +interface BaseAutocompleteSnippet { + score?: number; + content: string; +} + +export interface AutocompleteCodeSnippet extends BaseAutocompleteSnippet { + filepath: string; +} + +export interface AutocompleteDiffSnippet extends BaseAutocompleteSnippet {} + +export interface AutocompleteClipboardSnippet extends BaseAutocompleteSnippet {} + +export type AutocompleteSnippet = + | AutocompleteCodeSnippet + | AutocompleteDiffSnippet + | AutocompleteClipboardSnippet; diff --git a/core/autocomplete/templating/AutocompleteTemplate.ts b/core/autocomplete/templating/AutocompleteTemplate.ts index ae8cf1487..11fd47333 100644 --- a/core/autocomplete/templating/AutocompleteTemplate.ts +++ b/core/autocomplete/templating/AutocompleteTemplate.ts @@ -2,7 +2,7 @@ import { CompletionOptions } from "../../index.js"; import { getLastNPathParts, shortestRelativePaths } from "../../util/index.js"; -import { AutocompleteSnippet } from "../context/ranking/index.js"; +import { AutocompleteSnippetDeprecated } from "../context/ranking/index.js"; export interface AutocompleteTemplate { compilePrefixSuffix?: ( @@ -10,7 +10,7 @@ export interface AutocompleteTemplate { suffix: string, filepath: string, reponame: string, - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], ) => [string, string]; template: | string @@ -20,7 +20,7 @@ export interface AutocompleteTemplate { filepath: string, reponame: string, language: string, - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], ) => string); completionOptions?: Partial; } @@ -73,7 +73,7 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = { suffix: string, filepath: string, reponame: string, - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], ): [string, string] => { if (snippets.length === 0) { if (suffix.trim().length === 0 && prefix.trim().length === 0) { @@ -101,7 +101,7 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = { filepath: string, reponame: string, language: string, - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], ): string => { return `[SUFFIX]${suffix}[PREFIX]${prefix}`; }, @@ -133,7 +133,7 @@ const starcoder2FimTemplate: AutocompleteTemplate = { filename: string, reponame: string, language: string, - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], ): string => { const otherFiles = snippets.length === 0 @@ -187,7 +187,7 @@ const codegeexFimTemplate: AutocompleteTemplate = { filepath: string, reponame: string, language: string, - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], ): string => { const relativePaths = shortestRelativePaths([ ...snippets.map((snippet) => snippet.filepath), @@ -233,7 +233,7 @@ const holeFillerTemplate: AutocompleteTemplate = { filename: string, reponame: string, language: string, - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], ) => { // From https://github.com/VictorTaelin/AI-scripts const SYSTEM_MSG = `You are a HOLE FILLER. You are provided with a file containing holes, formatted as '{{HOLE_NAME}}'. Your TASK is to complete with a string to replace this hole with, inside a XML tag, including context-aware indentation, if needed. All completions MUST be truthful, accurate, well-written and correct. diff --git a/core/autocomplete/templating/index.ts b/core/autocomplete/templating/index.ts index 6f95923d1..be2d178d4 100644 --- a/core/autocomplete/templating/index.ts +++ b/core/autocomplete/templating/index.ts @@ -3,7 +3,7 @@ import Handlebars from "handlebars"; import { CompletionOptions } from "../.."; import { getBasename, getLastNPathParts } from "../../util"; import { AutocompleteLanguageInfo } from "../constants/AutocompleteLanguageInfo"; -import { AutocompleteSnippet } from "../context/ranking"; +import { AutocompleteSnippetDeprecated } from "../context/ranking"; import { HelperVars } from "../util/HelperVars"; import { @@ -34,7 +34,7 @@ export function formatExternalSnippet( } function getContextComments( - snippets: AutocompleteSnippet[], + snippets: AutocompleteSnippetDeprecated[], lang: AutocompleteLanguageInfo, filepath: string, ) { @@ -137,7 +137,7 @@ export function renderPrompt({ diff, clipboardContent, }: { - snippets: AutocompleteSnippet[]; + snippets: AutocompleteSnippetDeprecated[]; workspaceDirs: string[]; helper: HelperVars; diff?: string; diff --git a/core/autocomplete/util/types.ts b/core/autocomplete/util/types.ts index cb9064b62..47d19b233 100644 --- a/core/autocomplete/util/types.ts +++ b/core/autocomplete/util/types.ts @@ -13,7 +13,6 @@ export interface AutocompleteInput { pos: Position; recentlyEditedFiles: RangeInFileWithContents[]; recentlyEditedRanges: RecentlyEditedRange[]; - clipboardText: string; // Used for notebook files manuallyPassFileContents?: string; // Used for VS Code git commit input box diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts index 0df8e58b1..ffe69a2c4 100644 --- a/extensions/vscode/src/autocomplete/completionProvider.ts +++ b/extensions/vscode/src/autocomplete/completionProvider.ts @@ -42,7 +42,7 @@ export class ContinueCompletionProvider e.message, this.configHandler.reloadConfig.bind(this.configHandler), () => { - void this.webviewProtocol.request("openOnboardingCard", undefined) + void this.webviewProtocol.request("openOnboardingCard", undefined); }, ); return; @@ -153,12 +153,6 @@ export class ContinueCompletionProvider const signal = abortController.signal; token.onCancellationRequested(() => abortController.abort()); - const config = await this.configHandler.loadConfig(); - let clipboardText = ""; - if (config.tabAutocompleteOptions?.useCopyBuffer === true) { - clipboardText = await vscode.env.clipboard.readText(); - } - // Handle notebook cells const pos = { line: position.line, @@ -194,12 +188,6 @@ export class ContinueCompletionProvider } // Handle commit message input box let manuallyPassPrefix: string | undefined = undefined; - if (document.uri.scheme === "vscode-scm") { - return null; - // let diff = await this.ide.getDiff(); - // diff = diff.split("\n").splice(-150).join("\n"); - // manuallyPassPrefix = `${diff}\n\nCommit message: `; - } const input: AutocompleteInput = { completionId: uuidv4(), @@ -208,7 +196,6 @@ export class ContinueCompletionProvider recentlyEditedFiles: [], recentlyEditedRanges: await this.recentlyEditedTracker.getRecentlyEditedRanges(), - clipboardText: clipboardText, manuallyPassFileContents, manuallyPassPrefix, selectedCompletionInfo, diff --git a/extensions/vscode/src/autocomplete/lsp.ts b/extensions/vscode/src/autocomplete/lsp.ts index f900058ab..de719d3bf 100644 --- a/extensions/vscode/src/autocomplete/lsp.ts +++ b/extensions/vscode/src/autocomplete/lsp.ts @@ -1,6 +1,6 @@ import { GetLspDefinitionsFunction } from "core/autocomplete/CompletionProvider"; import { AutocompleteLanguageInfo } from "core/autocomplete/constants/AutocompleteLanguageInfo"; -import { AutocompleteSnippet } from "core/autocomplete/context/ranking"; +import { AutocompleteSnippetDeprecated } from "core/autocomplete/context/ranking"; import { getAst, getTreePathAtCursor } from "core/autocomplete/util/ast"; import { RangeInFileWithContents } from "core/commands/util"; import { @@ -134,7 +134,9 @@ async function crawlTypes( // Parse AST const ast = await getAst(rif.filepath, contents); - if (!ast) {return results;} + if (!ast) { + return results; + } const astLineCount = ast.rootNode.text.split("\n").length; // Find type identifiers @@ -340,13 +342,17 @@ export const getDefinitionsFromLsp: GetLspDefinitionsFunction = async ( cursorIndex: number, ide: IDE, lang: AutocompleteLanguageInfo, -): Promise => { +): Promise => { try { const ast = await getAst(filepath, contents); - if (!ast) {return [];} + if (!ast) { + return []; + } const treePath = await getTreePathAtCursor(ast, cursorIndex); - if (!treePath) {return [];} + if (!treePath) { + return []; + } const results: RangeInFileWithContents[] = []; for (const node of treePath.reverse()) { From fec4b21f7b713708befa8dbd12cdd9f8a4f4f219 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 21 Nov 2024 11:45:37 -0800 Subject: [PATCH 02/14] improv: unify autocomplete snippets --- core/autocomplete/CompletionProvider.ts | 84 +++++------ core/autocomplete/aggregateSnippets.ts | 45 ------ .../context/ContextRetrievalService.ts | 109 ++++---------- core/autocomplete/context/ranking/index.ts | 116 +++++++-------- .../context/ranking/slidingWindow.ts | 105 +++++++------- .../RootPathContextService.ts | 21 ++- .../snippets/aggregateSnippets.ts | 45 ++++++ core/autocomplete/snippets/getAllSnippets.ts | 134 ++++++++++++++++++ core/autocomplete/snippets/index.ts | 1 + core/autocomplete/snippets/types.ts | 17 ++- .../templating/AutocompleteTemplate.ts | 24 ++-- core/autocomplete/templating/index.ts | 17 ++- core/autocomplete/types.ts | 21 +++ core/config/types.ts | 1 - core/index.d.ts | 1 - core/util/parameters.ts | 1 - extensions/vscode/package-lock.json | 4 +- extensions/vscode/src/autocomplete/lsp.ts | 16 ++- packages/config-types/src/index.ts | 1 - 19 files changed, 442 insertions(+), 321 deletions(-) delete mode 100644 core/autocomplete/aggregateSnippets.ts create mode 100644 core/autocomplete/snippets/aggregateSnippets.ts create mode 100644 core/autocomplete/snippets/getAllSnippets.ts create mode 100644 core/autocomplete/snippets/index.ts create mode 100644 core/autocomplete/types.ts diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index c3445498e..c41bbb389 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -5,17 +5,16 @@ import OpenAI from "../llm/llms/OpenAI.js"; import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js"; import { shouldCompleteMultiline } from "./classification/shouldCompleteMultiline.js"; -import { AutocompleteLanguageInfo } from "./constants/AutocompleteLanguageInfo.js"; -import { aggregateSnippets } from "./aggregateSnippets"; +import { ContextRetrievalService } from "./context/ContextRetrievalService.js"; // @prettier-ignore -import { ContextRetrievalService } from "./context/ContextRetrievalService.js"; -import { AutocompleteSnippetDeprecated } from "./context/ranking/index.js"; import { BracketMatchingService } from "./filtering/BracketMatchingService.js"; import { CompletionStreamer } from "./generation/CompletionStreamer.js"; import { postprocessCompletion } from "./postprocessing/index.js"; import { shouldPrefilter } from "./prefiltering/index.js"; +import { getAllSnippets, TEMP__Snippets } from "./snippets/index.js"; import { renderPrompt } from "./templating/index.js"; +import { GetLspDefinitionsFunction } from "./types.js"; import { AutocompleteDebouncer } from "./util/AutocompleteDebouncer.js"; import { AutocompleteLoggingService } from "./util/AutocompleteLoggingService.js"; import AutocompleteLruCache from "./util/AutocompleteLruCache.js"; @@ -32,14 +31,6 @@ const ERRORS_TO_IGNORE = [ "operation was aborted", ]; -export type GetLspDefinitionsFunction = ( - filepath: string, - contents: string, - cursorIndex: number, - ide: IDE, - lang: AutocompleteLanguageInfo, -) => Promise; - export class CompletionProvider { private autocompleteCache = AutocompleteLruCache.get(); public errorsShown: Set = new Set(); @@ -171,21 +162,14 @@ export class CompletionProvider { token = controller.signal; } - ////////// - - // Some IDEs might have special ways of finding snippets (e.g. JetBrains and VS Code have different "LSP-equivalent" systems, - // or they might separately track recently edited ranges) - const extraSnippets = await this._getExtraSnippets(helper); - - const [snippets, diff, clipboardContent, workspaceDirs] = + const [{ snippets, diff, clipboardContent }, workspaceDirs] = await Promise.all([ - aggregateSnippets( + getAllSnippets({ helper, - extraSnippets, - this.contextRetrievalService, - ), - this.ide.getDiff(true), - this.ide.getClipboardContent(), + ide: this.ide, + getDefinitionsFromLsp: this.getDefinitionsFromLsp, + contextRetrievalService: this.contextRetrievalService, + }), this.ide.getWorkspaceDirs(), ]); @@ -289,31 +273,31 @@ export class CompletionProvider { } } - private async _getExtraSnippets( - helper: HelperVars, - ): Promise { - let extraSnippets = helper.options.useOtherFiles - ? ((await Promise.race([ - this.getDefinitionsFromLsp( - helper.input.filepath, - helper.fullPrefix + helper.fullSuffix, - helper.fullPrefix.length, - this.ide, - helper.lang, - ), - new Promise((resolve) => { - setTimeout(() => resolve([]), 100); - }), - ])) as AutocompleteSnippetDeprecated[]) - : []; + // private async _getExtraSnippets( + // helper: HelperVars, + // ): Promise { + // let extraSnippets = helper.options.useOtherFiles + // ? ((await Promise.race([ + // this.getDefinitionsFromLsp( + // helper.input.filepath, + // helper.fullPrefix + helper.fullSuffix, + // helper.fullPrefix.length, + // this.ide, + // helper.lang, + // ), + // new Promise((resolve) => { + // setTimeout(() => resolve([]), 100); + // }), + // ])) as AutocompleteSnippetDeprecated[]) + // : []; - const workspaceDirs = await this.ide.getWorkspaceDirs(); - if (helper.options.onlyMyCode) { - extraSnippets = extraSnippets.filter((snippet) => { - return workspaceDirs.some((dir) => snippet.filepath.startsWith(dir)); - }); - } + // const workspaceDirs = await this.ide.getWorkspaceDirs(); + // if (helper.options.onlyMyCode) { + // extraSnippets = extraSnippets.filter((snippet) => { + // return workspaceDirs.some((dir) => snippet.filepath.startsWith(dir)); + // }); + // } - return extraSnippets; - } + // return extraSnippets; + // } } diff --git a/core/autocomplete/aggregateSnippets.ts b/core/autocomplete/aggregateSnippets.ts deleted file mode 100644 index e6c750a4b..000000000 --- a/core/autocomplete/aggregateSnippets.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { ContextRetrievalService } from "./context/ContextRetrievalService.js"; -import { - fillPromptWithSnippets, - rankAndOrderSnippets, - type AutocompleteSnippetDeprecated, -} from "./context/ranking/index.js"; -import { HelperVars } from "./util/HelperVars.js"; - -function filterSnippetsAlreadyInCaretWindow( - snippets: AutocompleteSnippetDeprecated[], - caretWindow: string, -): AutocompleteSnippetDeprecated[] { - return snippets - .map((snippet) => ({ ...snippet })) - .filter( - (s) => - s.contents.trim() !== "" && !caretWindow.includes(s.contents.trim()), - ); -} - -export async function aggregateSnippets( - helper: HelperVars, - extraSnippets: AutocompleteSnippetDeprecated[], - contextRetrievalService: ContextRetrievalService, -): Promise { - let snippets = await contextRetrievalService.retrieveCandidateSnippets( - helper, - extraSnippets, - ); - - snippets = filterSnippetsAlreadyInCaretWindow( - snippets, - helper.prunedCaretWindow, - ); - - const scoredSnippets = rankAndOrderSnippets(snippets, helper); - - const finalSnippets = fillPromptWithSnippets( - scoredSnippets, - helper.maxSnippetTokens, - helper.modelName, - ); - - return finalSnippets; -} diff --git a/core/autocomplete/context/ContextRetrievalService.ts b/core/autocomplete/context/ContextRetrievalService.ts index 66b67eec3..72e061fed 100644 --- a/core/autocomplete/context/ContextRetrievalService.ts +++ b/core/autocomplete/context/ContextRetrievalService.ts @@ -1,9 +1,12 @@ import { IDE } from "../.."; +import { + AutocompleteCodeSnippet, + AutocompleteSnippetType, +} from "../snippets/types"; import { HelperVars } from "../util/HelperVars"; -import { RecentlyEditedRange } from "../util/types"; import { ImportDefinitionsService } from "./ImportDefinitionsService"; -import { AutocompleteSnippetDeprecated, getSymbolsForSnippet } from "./ranking"; +import { getSymbolsForSnippet } from "./ranking"; import { RootPathContextService } from "./root-path-context/RootPathContextService"; export class ContextRetrievalService { @@ -18,79 +21,14 @@ export class ContextRetrievalService { ); } - public async retrieveCandidateSnippets( + public async getSnippetsFromImportDefinitions( helper: HelperVars, - extraSnippets: AutocompleteSnippetDeprecated[], - ) { - if (helper.options.useOtherFiles === false) { - return []; - } - - let snippets: AutocompleteSnippetDeprecated[] = []; - - // Snippets injected by the IDE for IDE-specific reasons - snippets.push(...extraSnippets); - - // If a recently edited range has a line that is a perfect match with the start of the current line - snippets.push(...this.getSnippetsFromRecentlyEditedRanges(helper)); - - // Import definitions of any symbols in near range of the caret - snippets.push(...(await this.getSnippetsFromImportDefinitions(helper))); - - // Root path context https://blog.continue.dev/root-path-context-the-secret-ingredient-in-continues-autocomplete-prompt/ - if (helper.options.useRootPathContext && helper.treePath) { - snippets.push( - ...(await this.rootPathContextService.getContextForPath( - helper.filepath, - helper.treePath, - )), - ); - } - - return snippets; - } - - private getSnippetsFromRecentlyEditedRanges( - helper: HelperVars, - ): AutocompleteSnippetDeprecated[] { - if (helper.options.useRecentlyEdited === false) { - return []; - } - - const currentLinePrefix = helper.prunedPrefix - .trim() - .split("\n") - .slice(-1)[0]; - if ( - currentLinePrefix?.length > helper.options.recentLinePrefixMatchMinLength - ) { - const matchingRange = this.findMatchingRange( - helper.input.recentlyEditedRanges, - currentLinePrefix, - ); - - if (matchingRange) { - return [ - { - ...matchingRange, - contents: matchingRange.lines.join("\n"), - score: 0.8, - }, - ]; - } - } - - return []; - } - - private async getSnippetsFromImportDefinitions( - helper: HelperVars, - ): Promise { + ): Promise { if (helper.options.useImports === false) { return []; } - const importSnippets = []; + const importSnippets: AutocompleteCodeSnippet[] = []; const fileInfo = this.importDefinitionsService.get(helper.filepath); if (fileInfo) { const { imports } = fileInfo; @@ -104,21 +42,32 @@ export class ContextRetrievalService { for (const symbol of symbols) { const rifs = imports[symbol]; if (Array.isArray(rifs)) { - importSnippets.push(...rifs); + const snippets: AutocompleteCodeSnippet[] = rifs.map((rif) => { + return { + filepath: rif.filepath, + content: rif.contents, + type: AutocompleteSnippetType.Code, + }; + }); + + importSnippets.push(...snippets); } } } + return importSnippets; } - findMatchingRange( - recentlyEditedRanges: RecentlyEditedRange[], - linePrefix: string, - ): RecentlyEditedRange | undefined { - return recentlyEditedRanges.find((recentlyEditedRange) => { - return recentlyEditedRange.lines.some((line) => - line.startsWith(linePrefix), - ); - }); + public async getRootPathSnippets( + helper: HelperVars, + ): Promise { + if (!helper.treePath) { + return []; + } + + return this.rootPathContextService.getContextForPath( + helper.filepath, + helper.treePath, + ); } } diff --git a/core/autocomplete/context/ranking/index.ts b/core/autocomplete/context/ranking/index.ts index 28e9b8112..a11389470 100644 --- a/core/autocomplete/context/ranking/index.ts +++ b/core/autocomplete/context/ranking/index.ts @@ -1,17 +1,9 @@ import { RangeInFileWithContents } from "../../../commands/util.js"; import { Range } from "../../../index.js"; import { countTokens } from "../../../llm/countTokens.js"; +import { AutocompleteSnippetDeprecated } from "../../types.js"; import { HelperVars } from "../../util/HelperVars.js"; -/** - * @deprecated This type should be removed in the future or renamed. - * We have a new interface called AutocompleteSnippet which is more - * general. - */ -export type AutocompleteSnippetDeprecated = RangeInFileWithContents & { - score?: number; -}; - const rx = /[\s.,\/#!$%\^&\*;:{}=\-_`~()\[\]]/g; export function getSymbolsForSnippet(snippet: string): Set { const symbols = snippet @@ -24,7 +16,7 @@ export function getSymbolsForSnippet(snippet: string): Set { /** * Calculate similarity as number of shared symbols divided by total number of unique symbols between both. */ -export function jaccardSimilarity(a: string, b: string): number { +function jaccardSimilarity(a: string, b: string): number { const aSet = getSymbolsForSnippet(a); const bSet = getSymbolsForSnippet(b); const union = new Set([...aSet, ...bSet]).size; @@ -76,7 +68,7 @@ export function rankAndOrderSnippets( /** * Deduplicate code snippets by merging overlapping ranges into a single range. */ -export function deduplicateSnippets( +function deduplicateSnippets( snippets: Required[], ): Required[] { // Group by file @@ -166,54 +158,54 @@ export function fillPromptWithSnippets( /** * Remove one range from another range, which may lead to returning two disjoint ranges */ -function rangeDifferenceByLines(orig: Range, remove: Range): Range[] { - if ( - orig.start.line >= remove.start.line && - orig.end.line <= remove.end.line - ) { - // / | | / - return []; - } - if ( - orig.start.line <= remove.start.line && - orig.end.line >= remove.end.line - ) { - // | / / | - // Splits the range - return [ - { - start: orig.start, - end: remove.start, - }, - { - start: remove.end, - end: orig.end, - }, - ]; - } - if ( - orig.start.line >= remove.start.line && - orig.end.line >= remove.end.line - ) { - // \ | / | - return [ - { - start: remove.end, - end: orig.end, - }, - ]; - } - if ( - orig.start.line <= remove.start.line && - orig.end.line <= remove.end.line - ) { - // | / | / - return [ - { - start: orig.start, - end: remove.start, - }, - ]; - } - return [orig]; -} +// function rangeDifferenceByLines(orig: Range, remove: Range): Range[] { +// if ( +// orig.start.line >= remove.start.line && +// orig.end.line <= remove.end.line +// ) { +// // / | | / +// return []; +// } +// if ( +// orig.start.line <= remove.start.line && +// orig.end.line >= remove.end.line +// ) { +// // | / / | +// // Splits the range +// return [ +// { +// start: orig.start, +// end: remove.start, +// }, +// { +// start: remove.end, +// end: orig.end, +// }, +// ]; +// } +// if ( +// orig.start.line >= remove.start.line && +// orig.end.line >= remove.end.line +// ) { +// // \ | / | +// return [ +// { +// start: remove.end, +// end: orig.end, +// }, +// ]; +// } +// if ( +// orig.start.line <= remove.start.line && +// orig.end.line <= remove.end.line +// ) { +// // | / | / +// return [ +// { +// start: orig.start, +// end: remove.start, +// }, +// ]; +// } +// return [orig]; +// } diff --git a/core/autocomplete/context/ranking/slidingWindow.ts b/core/autocomplete/context/ranking/slidingWindow.ts index 3fd3a3f17..88ee2bff3 100644 --- a/core/autocomplete/context/ranking/slidingWindow.ts +++ b/core/autocomplete/context/ranking/slidingWindow.ts @@ -1,60 +1,61 @@ -import { RangeInFileWithContents } from "../../../commands/util.js"; +// import { RangeInFileWithContents } from "../../../commands/util.js"; +// import { AutocompleteSnippetDeprecated } from "../../types.js"; -import { AutocompleteSnippetDeprecated, jaccardSimilarity } from "./index.js"; +// import { jaccardSimilarity } from "./index.js"; -function* slidingWindow( - content: string, - windowSize: number, -): Generator { - const lines = content.split("\n"); +// function* slidingWindow( +// content: string, +// windowSize: number, +// ): Generator { +// const lines = content.split("\n"); - let charCount = 0; - let currWindowLines: string[] = []; - for (let i = 0; i < lines.length; i++) { - if (charCount + lines[i].length >= windowSize) { - yield currWindowLines.join("\n"); - currWindowLines = [lines[i]]; - charCount = 0; - } else { - currWindowLines.push(lines[i]); - } - charCount += lines[i].length; - } +// let charCount = 0; +// let currWindowLines: string[] = []; +// for (let i = 0; i < lines.length; i++) { +// if (charCount + lines[i].length >= windowSize) { +// yield currWindowLines.join("\n"); +// currWindowLines = [lines[i]]; +// charCount = 0; +// } else { +// currWindowLines.push(lines[i]); +// } +// charCount += lines[i].length; +// } - if (currWindowLines.length > 0) { - yield currWindowLines.join("\n"); - } -} +// if (currWindowLines.length > 0) { +// yield currWindowLines.join("\n"); +// } +// } -/** - * Match by similarity over sliding windows of recent documents. - * @param recentFiles - * @param prefix - * @param suffix - */ -export async function slidingWindowMatcher( - recentFiles: RangeInFileWithContents[], - windowAroundCursor: string, - topN: number, - windowSize: number, -): Promise { - // Sorted lowest similarity to highest - const topMatches: Required[] = []; +// /** +// * Match by similarity over sliding windows of recent documents. +// * @param recentFiles +// * @param prefix +// * @param suffix +// */ +// export async function slidingWindowMatcher( +// recentFiles: RangeInFileWithContents[], +// windowAroundCursor: string, +// topN: number, +// windowSize: number, +// ): Promise { +// // Sorted lowest similarity to highest +// const topMatches: Required[] = []; - for (const { filepath, contents, range } of recentFiles) { - for (const window of slidingWindow(contents, windowSize)) { - const score = jaccardSimilarity(window, windowAroundCursor); +// for (const { filepath, contents, range } of recentFiles) { +// for (const window of slidingWindow(contents, windowSize)) { +// const score = jaccardSimilarity(window, windowAroundCursor); - // Insertion sort - let i = -1; - while (++i < topMatches.length && score > topMatches[i].score) {} - topMatches.splice(i + 1, 0, { filepath, contents, score, range }); - if (topMatches.length > topN) { - topMatches.shift(); - } - } - } +// // Insertion sort +// let i = -1; +// while (++i < topMatches.length && score > topMatches[i].score) {} +// topMatches.splice(i + 1, 0, { filepath, contents, score, range }); +// if (topMatches.length > topN) { +// topMatches.shift(); +// } +// } +// } - // TODO: convert the arbitrary window frame to some whole AST node? - return topMatches; -} +// // TODO: convert the arbitrary window frame to some whole AST node? +// return topMatches; +// } diff --git a/core/autocomplete/context/root-path-context/RootPathContextService.ts b/core/autocomplete/context/root-path-context/RootPathContextService.ts index 98a947fb1..a94e37e38 100644 --- a/core/autocomplete/context/root-path-context/RootPathContextService.ts +++ b/core/autocomplete/context/root-path-context/RootPathContextService.ts @@ -12,7 +12,11 @@ import { } from "../../../util/treeSitter"; import { AstPath } from "../../util/ast"; import { ImportDefinitionsService } from "../ImportDefinitionsService"; -import { AutocompleteSnippetDeprecated } from "../ranking"; +import { AutocompleteSnippetDeprecated } from "../../types"; +import { + AutocompleteCodeSnippet, + AutocompleteSnippetType, +} from "../../snippets/types"; function getSyntaxTreeString( node: Parser.SyntaxNode, @@ -153,8 +157,8 @@ export class RootPathContextService { filepath: string, astPath: AstPath, // cursorIndex: number, - ): Promise { - const snippets: AutocompleteSnippetDeprecated[] = []; + ): Promise { + const snippets: AutocompleteCodeSnippet[] = []; let parentKey = filepath; for (const astNode of astPath.filter((node) => @@ -167,7 +171,16 @@ export class RootPathContextService { const foundInCache = this.cache.get(key); const newSnippets = foundInCache ?? (await this.getSnippetsForNode(filepath, astNode)); - snippets.push(...newSnippets); + + const formattedSnippets: AutocompleteCodeSnippet[] = newSnippets.map( + (item) => ({ + filepath: item.filepath, + content: item.contents, + type: AutocompleteSnippetType.Code, + }), + ); + + snippets.push(...formattedSnippets); if (!foundInCache) { this.cache.set(key, newSnippets); diff --git a/core/autocomplete/snippets/aggregateSnippets.ts b/core/autocomplete/snippets/aggregateSnippets.ts new file mode 100644 index 000000000..1562c6f57 --- /dev/null +++ b/core/autocomplete/snippets/aggregateSnippets.ts @@ -0,0 +1,45 @@ +// import { ContextRetrievalService } from "../context/ContextRetrievalService.js"; +// import { +// fillPromptWithSnippets, +// rankAndOrderSnippets, +// } from "../context/ranking/index.js"; +// import { AutocompleteSnippetDeprecated } from "../types.js"; +// import { HelperVars } from "../util/HelperVars.js"; + +// function filterSnippetsAlreadyInCaretWindow( +// snippets: AutocompleteSnippetDeprecated[], +// caretWindow: string, +// ): AutocompleteSnippetDeprecated[] { +// return snippets +// .map((snippet) => ({ ...snippet })) +// .filter( +// (s) => +// s.contents.trim() !== "" && !caretWindow.includes(s.contents.trim()), +// ); +// } + +// export async function aggregateSnippets( +// helper: HelperVars, +// extraSnippets: AutocompleteSnippetDeprecated[], +// contextRetrievalService: ContextRetrievalService, +// ): Promise { +// let snippets = await contextRetrievalService.retrieveCandidateSnippets( +// helper, +// extraSnippets, +// ); + +// snippets = filterSnippetsAlreadyInCaretWindow( +// snippets, +// helper.prunedCaretWindow, +// ); + +// const scoredSnippets = rankAndOrderSnippets(snippets, helper); + +// const finalSnippets = fillPromptWithSnippets( +// scoredSnippets, +// helper.maxSnippetTokens, +// helper.modelName, +// ); + +// return finalSnippets; +// } diff --git a/core/autocomplete/snippets/getAllSnippets.ts b/core/autocomplete/snippets/getAllSnippets.ts new file mode 100644 index 000000000..6f6c79ba3 --- /dev/null +++ b/core/autocomplete/snippets/getAllSnippets.ts @@ -0,0 +1,134 @@ +import { IDE } from "../../index"; +import { ContextRetrievalService } from "../context/ContextRetrievalService"; +import { GetLspDefinitionsFunction } from "../types"; +import { HelperVars } from "../util/HelperVars"; +import { + AutocompleteClipboardSnippet, + AutocompleteCodeSnippet, + AutocompleteDiffSnippet, + AutocompleteSnippetType, +} from "./types"; + +// Some IDEs might have special ways of finding snippets (e.g. JetBrains and VS Code have different "LSP-equivalent" systems, +// or they might separately track recently edited ranges) +async function getIdeSnippets( + helper: HelperVars, + ide: IDE, + getDefinitionsFromLsp: GetLspDefinitionsFunction, +): Promise { + const ideSnippets = (await Promise.race([ + getDefinitionsFromLsp( + helper.input.filepath, + helper.fullPrefix + helper.fullSuffix, + helper.fullPrefix.length, + ide, + helper.lang, + ), + new Promise((resolve) => { + setTimeout(() => resolve([]), 100); + }), + ])) as AutocompleteCodeSnippet[]; + + if (helper.options.onlyMyCode) { + const workspaceDirs = await ide.getWorkspaceDirs(); + + return ideSnippets.filter((snippet) => + workspaceDirs.some((dir) => snippet.filepath.startsWith(dir)), + ); + } + + return ideSnippets; +} + +function getSnippetsFromRecentlyEditedRanges( + helper: HelperVars, +): AutocompleteCodeSnippet[] { + if (helper.options.useRecentlyEdited === false) { + return []; + } + + return helper.input.recentlyEditedRanges.map((range) => { + return { + filepath: range.filepath, + content: range.lines.join("\n"), + score: 0.8, + type: AutocompleteSnippetType.Code, + }; + }); +} + +export type TEMP__Snippets = { + snippets: AutocompleteCodeSnippet[]; + diff: string | undefined; + clipboardContent: { + text: string; + copiedAt: string; + }; + new: { + rootPathSnippets: AutocompleteCodeSnippet[]; + importDefinitionSnippets: AutocompleteCodeSnippet[]; + ideSnippets: AutocompleteCodeSnippet[]; + recentlyEditedRangeSnippets: AutocompleteCodeSnippet[]; + diffSnippets: AutocompleteDiffSnippet[]; + clipboardSnippets: AutocompleteClipboardSnippet[]; + }; +}; + +export const getAllSnippets = async ({ + helper, + ide, + getDefinitionsFromLsp, + contextRetrievalService, +}: { + helper: HelperVars; + ide: IDE; + getDefinitionsFromLsp: GetLspDefinitionsFunction; + contextRetrievalService: ContextRetrievalService; +}): Promise => { + const recentlyEditedRangeSnippets = + getSnippetsFromRecentlyEditedRanges(helper); + + const [ + rootPathSnippets, + importDefinitionSnippets, + ideSnippets, + diff, + clipboardContent, + ] = await Promise.all([ + contextRetrievalService.getRootPathSnippets(helper), + contextRetrievalService.getSnippetsFromImportDefinitions(helper), + getIdeSnippets(helper, ide, getDefinitionsFromLsp), + ide.getDiff(true), + ide.getClipboardContent(), + ]); + + return { + snippets: [ + ...rootPathSnippets, + ...importDefinitionSnippets, + ...ideSnippets, + ...recentlyEditedRangeSnippets, + ], + diff, + clipboardContent, + new: { + rootPathSnippets, + importDefinitionSnippets, + ideSnippets, + recentlyEditedRangeSnippets, + diffSnippets: [diff].map((item) => { + return { + content: item, + type: AutocompleteSnippetType.Diff, + }; + }), + clipboardSnippets: [clipboardContent].map((item) => { + return { + content: item.text, + copiedAt: item.copiedAt, + type: AutocompleteSnippetType.Clipboard, + }; + }), + }, + }; +}; diff --git a/core/autocomplete/snippets/index.ts b/core/autocomplete/snippets/index.ts new file mode 100644 index 000000000..2a9e1a7ce --- /dev/null +++ b/core/autocomplete/snippets/index.ts @@ -0,0 +1 @@ +export * from "./getAllSnippets"; diff --git a/core/autocomplete/snippets/types.ts b/core/autocomplete/snippets/types.ts index e39406b11..b97e07604 100644 --- a/core/autocomplete/snippets/types.ts +++ b/core/autocomplete/snippets/types.ts @@ -1,15 +1,28 @@ +export enum AutocompleteSnippetType { + Code = "code", + Diff = "diff", + Clipboard = "clipboard", +} + interface BaseAutocompleteSnippet { score?: number; content: string; + type: AutocompleteSnippetType; } export interface AutocompleteCodeSnippet extends BaseAutocompleteSnippet { filepath: string; + type: AutocompleteSnippetType.Code; } -export interface AutocompleteDiffSnippet extends BaseAutocompleteSnippet {} +export interface AutocompleteDiffSnippet extends BaseAutocompleteSnippet { + type: AutocompleteSnippetType.Diff; +} -export interface AutocompleteClipboardSnippet extends BaseAutocompleteSnippet {} +export interface AutocompleteClipboardSnippet extends BaseAutocompleteSnippet { + type: AutocompleteSnippetType.Clipboard; + copiedAt: string; +} export type AutocompleteSnippet = | AutocompleteCodeSnippet diff --git a/core/autocomplete/templating/AutocompleteTemplate.ts b/core/autocomplete/templating/AutocompleteTemplate.ts index 11fd47333..b84337c0e 100644 --- a/core/autocomplete/templating/AutocompleteTemplate.ts +++ b/core/autocomplete/templating/AutocompleteTemplate.ts @@ -2,7 +2,8 @@ import { CompletionOptions } from "../../index.js"; import { getLastNPathParts, shortestRelativePaths } from "../../util/index.js"; -import { AutocompleteSnippetDeprecated } from "../context/ranking/index.js"; +import { AutocompleteCodeSnippet } from "../snippets/types.js"; +import { AutocompleteSnippetDeprecated } from "../types.js"; export interface AutocompleteTemplate { compilePrefixSuffix?: ( @@ -10,7 +11,7 @@ export interface AutocompleteTemplate { suffix: string, filepath: string, reponame: string, - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], ) => [string, string]; template: | string @@ -20,7 +21,7 @@ export interface AutocompleteTemplate { filepath: string, reponame: string, language: string, - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], ) => string); completionOptions?: Partial; } @@ -73,7 +74,7 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = { suffix: string, filepath: string, reponame: string, - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], ): [string, string] => { if (snippets.length === 0) { if (suffix.trim().length === 0 && prefix.trim().length === 0) { @@ -86,7 +87,7 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = { filepath, ]); const otherFiles = snippets - .map((snippet, i) => `+++++ ${relativePaths[i]}\n${snippet.contents}`) + .map((snippet, i) => `+++++ ${relativePaths[i]}\n${snippet.content}`) .join("\n\n"); return [ `${otherFiles}\n\n+++++ ${ @@ -101,7 +102,7 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = { filepath: string, reponame: string, language: string, - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], ): string => { return `[SUFFIX]${suffix}[PREFIX]${prefix}`; }, @@ -133,15 +134,14 @@ const starcoder2FimTemplate: AutocompleteTemplate = { filename: string, reponame: string, language: string, - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], ): string => { const otherFiles = snippets.length === 0 ? "" : `${snippets .map((snippet) => { - return snippet.contents; - // return `${getBasename(snippet.filepath)}\n${snippet.contents}`; + return snippet.content; }) .join("")}`; @@ -187,7 +187,7 @@ const codegeexFimTemplate: AutocompleteTemplate = { filepath: string, reponame: string, language: string, - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], ): string => { const relativePaths = shortestRelativePaths([ ...snippets.map((snippet) => snippet.filepath), @@ -200,7 +200,7 @@ const codegeexFimTemplate: AutocompleteTemplate = { return `<|user|>\n${baseTemplate}<|assistant|>\n`; } const references = `###REFERENCE:\n${snippets - .map((snippet, i) => `###PATH:${relativePaths[i]}\n${snippet.contents}\n`) + .map((snippet, i) => `###PATH:${relativePaths[i]}\n${snippet.content}\n`) .join("###REFERENCE:\n")}`; const prompt = `<|user|>\n${references}\n${baseTemplate}<|assistant|>\n`; return prompt; @@ -233,7 +233,7 @@ const holeFillerTemplate: AutocompleteTemplate = { filename: string, reponame: string, language: string, - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], ) => { // From https://github.com/VictorTaelin/AI-scripts const SYSTEM_MSG = `You are a HOLE FILLER. You are provided with a file containing holes, formatted as '{{HOLE_NAME}}'. Your TASK is to complete with a string to replace this hole with, inside a XML tag, including context-aware indentation, if needed. All completions MUST be truthful, accurate, well-written and correct. diff --git a/core/autocomplete/templating/index.ts b/core/autocomplete/templating/index.ts index be2d178d4..2812130c5 100644 --- a/core/autocomplete/templating/index.ts +++ b/core/autocomplete/templating/index.ts @@ -3,7 +3,6 @@ import Handlebars from "handlebars"; import { CompletionOptions } from "../.."; import { getBasename, getLastNPathParts } from "../../util"; import { AutocompleteLanguageInfo } from "../constants/AutocompleteLanguageInfo"; -import { AutocompleteSnippetDeprecated } from "../context/ranking"; import { HelperVars } from "../util/HelperVars"; import { @@ -12,6 +11,11 @@ import { } from "./AutocompleteTemplate"; import { getStopTokens } from "./getStopTokens"; import { countTokens } from "../../llm/countTokens"; +import { AutocompleteSnippetDeprecated } from "../types"; +import { + AutocompleteCodeSnippet, + AutocompleteSnippet, +} from "../snippets/types"; const addCommentMarks = (text: string, language: AutocompleteLanguageInfo) => { const comment = language.singleLineComment; @@ -34,7 +38,7 @@ export function formatExternalSnippet( } function getContextComments( - snippets: AutocompleteSnippetDeprecated[], + snippets: AutocompleteCodeSnippet[], lang: AutocompleteLanguageInfo, filepath: string, ) { @@ -49,7 +53,7 @@ function getContextComments( headerSnipper + snippets .map((snippet) => - formatExternalSnippet(snippet.filepath, snippet.contents, lang), + formatExternalSnippet(snippet.filepath, snippet.content, lang), ) .join("\n") + fileNameSnippet; @@ -122,6 +126,11 @@ const formatClipboardContent = ( return ""; } + const isEmpty = text.trim() === ""; + if (isEmpty) { + return ""; + } + return ( addCommentMarks( `Recently copied by user:${text.includes("\n") ? "\n" : ""} ${text}`, @@ -137,7 +146,7 @@ export function renderPrompt({ diff, clipboardContent, }: { - snippets: AutocompleteSnippetDeprecated[]; + snippets: AutocompleteCodeSnippet[]; workspaceDirs: string[]; helper: HelperVars; diff?: string; diff --git a/core/autocomplete/types.ts b/core/autocomplete/types.ts new file mode 100644 index 000000000..9488fb085 --- /dev/null +++ b/core/autocomplete/types.ts @@ -0,0 +1,21 @@ +import { RangeInFileWithContents } from "../commands/util"; +import { IDE } from "../index"; +import { AutocompleteLanguageInfo } from "./constants/AutocompleteLanguageInfo"; +import { AutocompleteCodeSnippet } from "./snippets/types"; + +/** + * @deprecated This type should be removed in the future or renamed. + * We have a new interface called AutocompleteSnippet which is more + * general. + */ +export type AutocompleteSnippetDeprecated = RangeInFileWithContents & { + score?: number; +}; + +export type GetLspDefinitionsFunction = ( + filepath: string, + contents: string, + cursorIndex: number, + ide: IDE, + lang: AutocompleteLanguageInfo, +) => Promise; diff --git a/core/config/types.ts b/core/config/types.ts index f397b1ed7..47c4a5aa7 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -842,7 +842,6 @@ declare global { onlyMyCode: boolean; useOtherFiles: boolean; useRecentlyEdited: boolean; - recentLinePrefixMatchMinLength: number; disableInFiles?: string[]; useImports?: boolean; } diff --git a/core/index.d.ts b/core/index.d.ts index 0646edc54..f96cbd122 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -986,7 +986,6 @@ export interface TabAutocompleteOptions { onlyMyCode: boolean; useOtherFiles: boolean; useRecentlyEdited: boolean; - recentLinePrefixMatchMinLength: number; disableInFiles?: string[]; useImports?: boolean; useRootPathContext?: boolean; diff --git a/core/util/parameters.ts b/core/util/parameters.ts index 20b96ac47..7ba828f7a 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -18,7 +18,6 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { onlyMyCode: true, useOtherFiles: true, useRecentlyEdited: true, - recentLinePrefixMatchMinLength: 7, disableInFiles: undefined, useImports: true, useRootPathContext: true, diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 940503505..b30a951df 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.232", + "version": "0.9.233", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.232", + "version": "0.9.233", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/src/autocomplete/lsp.ts b/extensions/vscode/src/autocomplete/lsp.ts index de719d3bf..a11aeeead 100644 --- a/extensions/vscode/src/autocomplete/lsp.ts +++ b/extensions/vscode/src/autocomplete/lsp.ts @@ -1,6 +1,4 @@ -import { GetLspDefinitionsFunction } from "core/autocomplete/CompletionProvider"; import { AutocompleteLanguageInfo } from "core/autocomplete/constants/AutocompleteLanguageInfo"; -import { AutocompleteSnippetDeprecated } from "core/autocomplete/context/ranking"; import { getAst, getTreePathAtCursor } from "core/autocomplete/util/ast"; import { RangeInFileWithContents } from "core/commands/util"; import { @@ -12,6 +10,14 @@ import * as vscode from "vscode"; import type { IDE, Range, RangeInFile } from "core"; import type Parser from "web-tree-sitter"; +import { + AutocompleteSnippetDeprecated, + GetLspDefinitionsFunction, +} from "core/autocomplete/types"; +import { + AutocompleteCodeSnippet, + AutocompleteSnippetType, +} from "core/autocomplete/snippets/types"; type GotoProviderName = | "vscode.executeDefinitionProvider" @@ -342,7 +348,7 @@ export const getDefinitionsFromLsp: GetLspDefinitionsFunction = async ( cursorIndex: number, ide: IDE, lang: AutocompleteLanguageInfo, -): Promise => { +): Promise => { try { const ast = await getAst(filepath, contents); if (!ast) { @@ -366,8 +372,10 @@ export const getDefinitionsFromLsp: GetLspDefinitionsFunction = async ( } return results.map((result) => ({ - ...result, + filepath: result.filepath, + content: result.contents, score: 0.8, + type: AutocompleteSnippetType.Code, })); } catch (e) { console.warn("Error getting definitions from LSP: ", e); diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts index 876115d11..fc53c742f 100644 --- a/packages/config-types/src/index.ts +++ b/packages/config-types/src/index.ts @@ -148,7 +148,6 @@ export const tabAutocompleteOptionsSchema = z.object({ onlyMyCode: z.boolean(), useOtherFiles: z.boolean(), useRecentlyEdited: z.boolean(), - recentLinePrefixMatchMinLength: z.number(), disableInFiles: z.array(z.string()).optional(), useImports: z.boolean().optional(), }); From 8e56613cf779e4a258596ad0e6ce6633b9c0f64a Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 21 Nov 2024 17:03:55 -0800 Subject: [PATCH 03/14] improv: generating context (snippets) string --- core/autocomplete/CompletionProvider.ts | 25 ++-- core/autocomplete/snippets/getAllSnippets.ts | 20 ++-- core/autocomplete/templating/filtering.ts | 45 +++++++ core/autocomplete/templating/formatting.ts | 100 ++++++++++++++++ core/autocomplete/templating/index.ts | 120 ++----------------- core/autocomplete/templating/validation.ts | 29 +++++ 6 files changed, 209 insertions(+), 130 deletions(-) create mode 100644 core/autocomplete/templating/filtering.ts create mode 100644 core/autocomplete/templating/formatting.ts create mode 100644 core/autocomplete/templating/validation.ts diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index c41bbb389..fe9ec02e6 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -12,7 +12,7 @@ import { BracketMatchingService } from "./filtering/BracketMatchingService.js"; import { CompletionStreamer } from "./generation/CompletionStreamer.js"; import { postprocessCompletion } from "./postprocessing/index.js"; import { shouldPrefilter } from "./prefiltering/index.js"; -import { getAllSnippets, TEMP__Snippets } from "./snippets/index.js"; +import { getAllSnippets } from "./snippets/index.js"; import { renderPrompt } from "./templating/index.js"; import { GetLspDefinitionsFunction } from "./types.js"; import { AutocompleteDebouncer } from "./util/AutocompleteDebouncer.js"; @@ -162,19 +162,22 @@ export class CompletionProvider { token = controller.signal; } - const [{ snippets, diff, clipboardContent }, workspaceDirs] = - await Promise.all([ - getAllSnippets({ - helper, - ide: this.ide, - getDefinitionsFromLsp: this.getDefinitionsFromLsp, - contextRetrievalService: this.contextRetrievalService, - }), - this.ide.getWorkspaceDirs(), - ]); + const [ + { snippets, diff, clipboardContent, payload: snippetPayload }, + workspaceDirs, + ] = await Promise.all([ + getAllSnippets({ + helper, + ide: this.ide, + getDefinitionsFromLsp: this.getDefinitionsFromLsp, + contextRetrievalService: this.contextRetrievalService, + }), + this.ide.getWorkspaceDirs(), + ]); const { prompt, prefix, suffix, completionOptions } = renderPrompt({ snippets, + snippetPayload, diff, clipboardContent, workspaceDirs, diff --git a/core/autocomplete/snippets/getAllSnippets.ts b/core/autocomplete/snippets/getAllSnippets.ts index 6f6c79ba3..cda4874a1 100644 --- a/core/autocomplete/snippets/getAllSnippets.ts +++ b/core/autocomplete/snippets/getAllSnippets.ts @@ -57,6 +57,15 @@ function getSnippetsFromRecentlyEditedRanges( }); } +export interface SnippetPayload { + rootPathSnippets: AutocompleteCodeSnippet[]; + importDefinitionSnippets: AutocompleteCodeSnippet[]; + ideSnippets: AutocompleteCodeSnippet[]; + recentlyEditedRangeSnippets: AutocompleteCodeSnippet[]; + diffSnippets: AutocompleteDiffSnippet[]; + clipboardSnippets: AutocompleteClipboardSnippet[]; +} + export type TEMP__Snippets = { snippets: AutocompleteCodeSnippet[]; diff: string | undefined; @@ -64,14 +73,7 @@ export type TEMP__Snippets = { text: string; copiedAt: string; }; - new: { - rootPathSnippets: AutocompleteCodeSnippet[]; - importDefinitionSnippets: AutocompleteCodeSnippet[]; - ideSnippets: AutocompleteCodeSnippet[]; - recentlyEditedRangeSnippets: AutocompleteCodeSnippet[]; - diffSnippets: AutocompleteDiffSnippet[]; - clipboardSnippets: AutocompleteClipboardSnippet[]; - }; + payload: SnippetPayload; }; export const getAllSnippets = async ({ @@ -111,7 +113,7 @@ export const getAllSnippets = async ({ ], diff, clipboardContent, - new: { + payload: { rootPathSnippets, importDefinitionSnippets, ideSnippets, diff --git a/core/autocomplete/templating/filtering.ts b/core/autocomplete/templating/filtering.ts new file mode 100644 index 000000000..c657a75f3 --- /dev/null +++ b/core/autocomplete/templating/filtering.ts @@ -0,0 +1,45 @@ +import { countTokens } from "../../llm/countTokens"; +import { SnippetPayload } from "../snippets"; +import { AutocompleteSnippet } from "../snippets/types"; +import { HelperVars } from "../util/HelperVars"; +import { isValidSnippet } from "./validation"; + +const getRemainingTokenCount = (helper: HelperVars): number => { + const tokenCount = countTokens(helper.prunedCaretWindow, helper.modelName); + + return helper.options.maxPromptTokens - tokenCount; +}; + +const TOKEN_BUFFER = 10; // We may need extra tokens for snippet description etc. + +export const getSnippets = ( + helper: HelperVars, + payload: SnippetPayload, +): AutocompleteSnippet[] => { + const snippets = [ + ...payload.diffSnippets, + ...payload.clipboardSnippets, + ...payload.rootPathSnippets, + ]; + + const finalSnippets = []; + + let remainingTokenCount = getRemainingTokenCount(helper); + + while (remainingTokenCount > 0 && snippets.length > 0) { + const snippet = snippets.shift(); + if (!snippet || !isValidSnippet(snippet)) { + continue; + } + + const snippetSize = + countTokens(snippet.content, helper.modelName) + TOKEN_BUFFER; + + if (remainingTokenCount >= snippetSize) { + finalSnippets.push(snippet); + remainingTokenCount -= snippetSize; + } + } + + return finalSnippets; +}; diff --git a/core/autocomplete/templating/formatting.ts b/core/autocomplete/templating/formatting.ts new file mode 100644 index 000000000..904262d7a --- /dev/null +++ b/core/autocomplete/templating/formatting.ts @@ -0,0 +1,100 @@ +import { getBasename, getLastNPathParts } from "../../util"; +import { AutocompleteLanguageInfo } from "../constants/AutocompleteLanguageInfo"; +import { + AutocompleteClipboardSnippet, + AutocompleteCodeSnippet, + AutocompleteDiffSnippet, + AutocompleteSnippet, + AutocompleteSnippetType, +} from "../snippets/types"; +import { HelperVars } from "../util/HelperVars"; + +const getCommentMark = (helper: HelperVars) => { + return helper.lang.singleLineComment; +}; + +const addCommentMarks = (text: string, helper: HelperVars) => { + const lines = [ + ...text + .trim() + .split("\n") + .map((line) => `${getCommentMark(helper)} ${line}`), + ]; + return lines.join("\n"); +}; + +const formatClipboardSnippet = ( + snippet: AutocompleteClipboardSnippet, +): AutocompleteClipboardSnippet => { + return { + ...snippet, + content: `Recently copied by user:${snippet.content.includes("\n") ? "\n" : ""} ${snippet.content}`, + }; +}; + +const formatCodeSnippet = ( + snippet: AutocompleteCodeSnippet, +): AutocompleteCodeSnippet => { + return { + ...snippet, + content: `Path: ${getBasename(snippet.filepath)}\n${snippet.content}`, + }; +}; + +const formatDiffSnippet = ( + snippet: AutocompleteDiffSnippet, +): AutocompleteDiffSnippet => { + return snippet; +}; + +// TODO: Insert this somewhere +const getCurrentFilepathSnippet = (helper: HelperVars) => { + const currentFilePath = `\n\n${getLastNPathParts(helper.filepath, 2)}\n\n`; +}; + +const commentifySnippet = ( + helper: HelperVars, + snippet: AutocompleteSnippet, +): AutocompleteSnippet => { + return { + ...snippet, + content: addCommentMarks(snippet.content, helper), + }; +}; + +const SNIPPET_TYPES_TO_COMMENT = [ + AutocompleteSnippetType.Code, + AutocompleteSnippetType.Clipboard, +]; + +export const formatSnippets = ( + helper: HelperVars, + snippets: AutocompleteSnippet[], +): string => { + return snippets + .map((snippet) => { + switch (snippet.type) { + case AutocompleteSnippetType.Code: + return formatCodeSnippet(snippet); + case AutocompleteSnippetType.Diff: + return formatDiffSnippet(snippet); + case AutocompleteSnippetType.Clipboard: + return formatClipboardSnippet(snippet); + } + }) + .map((item) => { + if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { + return commentifySnippet(helper, item); + } + + return item; + }) + .map((item) => { + if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { + return item.content + `\n${getCommentMark}\n${getCommentMark}`; + } + + return item.content + "\n\n"; + }) + .join(""); +}; diff --git a/core/autocomplete/templating/index.ts b/core/autocomplete/templating/index.ts index 2812130c5..364c9114c 100644 --- a/core/autocomplete/templating/index.ts +++ b/core/autocomplete/templating/index.ts @@ -1,7 +1,7 @@ import Handlebars from "handlebars"; import { CompletionOptions } from "../.."; -import { getBasename, getLastNPathParts } from "../../util"; +import { getBasename } from "../../util"; import { AutocompleteLanguageInfo } from "../constants/AutocompleteLanguageInfo"; import { HelperVars } from "../util/HelperVars"; @@ -10,56 +10,10 @@ import { getTemplateForModel, } from "./AutocompleteTemplate"; import { getStopTokens } from "./getStopTokens"; -import { countTokens } from "../../llm/countTokens"; -import { AutocompleteSnippetDeprecated } from "../types"; -import { - AutocompleteCodeSnippet, - AutocompleteSnippet, -} from "../snippets/types"; - -const addCommentMarks = (text: string, language: AutocompleteLanguageInfo) => { - const comment = language.singleLineComment; - const lines = [ - ...text - .trim() - .split("\n") - .map((line) => `${comment} ${line}`), - ]; - return lines.join("\n"); -}; - -export function formatExternalSnippet( - filepath: string, - snippet: string, - language: AutocompleteLanguageInfo, -) { - const filePathString = `Path: ${getBasename(filepath)}\n`; - return addCommentMarks(`${filePathString}${snippet}`, language); -} - -function getContextComments( - snippets: AutocompleteCodeSnippet[], - lang: AutocompleteLanguageInfo, - filepath: string, -) { - if (snippets.length === 0) { - return ""; - } - - const headerSnipper = `\n\n${lang.singleLineComment} Related code:\n`; - const fileNameSnippet = `\n\n${lang.singleLineComment} ${getLastNPathParts(filepath, 2)}\n\n`; - - const formattedSnippets = - headerSnipper + - snippets - .map((snippet) => - formatExternalSnippet(snippet.filepath, snippet.content, lang), - ) - .join("\n") + - fileNameSnippet; - - return formattedSnippets; -} +import { AutocompleteCodeSnippet } from "../snippets/types"; +import { SnippetPayload } from "../snippets"; +import { formatSnippets } from "./formatting"; +import { getSnippets } from "./filtering"; function getTemplate(helper: HelperVars): AutocompleteTemplate { if (helper.options.template) { @@ -92,61 +46,14 @@ function renderStringTemplate( }); } -const formatDiff = (helper: HelperVars, diff?: string) => { - if (!diff) return ""; - - const tokenCount = countTokens(diff, helper.modelName); - - if (tokenCount > helper.maxDiffTokens) { - return ""; - } - - return `${diff}\n\n`; -}; - -const MAX_CLIPBOARD_AGE = 5 * 60 * 1000; - -const formatClipboardContent = ( - helper: HelperVars, - { text, copiedAt }: { text: string; copiedAt: string }, -) => { - const currDate = new Date(); - - const isTooOld = - currDate.getTime() - new Date(copiedAt).getTime() > MAX_CLIPBOARD_AGE; - - if (isTooOld) { - return ""; - } - - const tokenCount = countTokens(text, helper.modelName); - const isTooLong = tokenCount > helper.maxClipboardTokens; - - if (isTooLong) { - return ""; - } - - const isEmpty = text.trim() === ""; - if (isEmpty) { - return ""; - } - - return ( - addCommentMarks( - `Recently copied by user:${text.includes("\n") ? "\n" : ""} ${text}`, - helper.lang, - ) + "\n" - ); -}; - export function renderPrompt({ snippets, + snippetPayload, workspaceDirs, helper, - diff, - clipboardContent, }: { snippets: AutocompleteCodeSnippet[]; + snippetPayload: SnippetPayload; workspaceDirs: string[]; helper: HelperVars; diff?: string; @@ -180,17 +87,10 @@ export function renderPrompt({ snippets, ); } else { - const contextComments = getContextComments( - snippets, - helper.lang, - helper.filepath, - ); - const formattedDiff = formatDiff(helper, diff); - const formattedClipboard = formatClipboardContent(helper, clipboardContent); + const finalSnippets = getSnippets(helper, snippetPayload); + const formattedSnippets = formatSnippets(helper, finalSnippets); - prefix = [formattedClipboard, formattedDiff, contextComments, prefix].join( - "", - ); + prefix = [formattedSnippets, prefix].join("\n"); } const prompt = diff --git a/core/autocomplete/templating/validation.ts b/core/autocomplete/templating/validation.ts new file mode 100644 index 000000000..dad55dc5c --- /dev/null +++ b/core/autocomplete/templating/validation.ts @@ -0,0 +1,29 @@ +import { + AutocompleteClipboardSnippet, + AutocompleteSnippet, + AutocompleteSnippetType, +} from "../snippets/types"; + +const MAX_CLIPBOARD_AGE = 5 * 60 * 1000; + +const isValidClipboardSnippet = ( + snippet: AutocompleteClipboardSnippet, +): boolean => { + const currDate = new Date(); + + const isTooOld = + currDate.getTime() - new Date(snippet.copiedAt).getTime() > + MAX_CLIPBOARD_AGE; + + return !isTooOld; +}; + +export const isValidSnippet = (snippet: AutocompleteSnippet): boolean => { + if (snippet.content.trim() === "") return false; + + if (snippet.type === AutocompleteSnippetType.Clipboard) { + return isValidClipboardSnippet(snippet); + } + + return true; +}; From 0f6d280234c459e1935b62e5244f4577d64fac53 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 22 Nov 2024 10:41:52 -0800 Subject: [PATCH 04/14] fix: prompt format --- core/autocomplete/templating/formatting.ts | 77 ++++++++++++---------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/core/autocomplete/templating/formatting.ts b/core/autocomplete/templating/formatting.ts index 904262d7a..6554de26d 100644 --- a/core/autocomplete/templating/formatting.ts +++ b/core/autocomplete/templating/formatting.ts @@ -1,5 +1,4 @@ -import { getBasename, getLastNPathParts } from "../../util"; -import { AutocompleteLanguageInfo } from "../constants/AutocompleteLanguageInfo"; +import { getLastNPathParts } from "../../util"; import { AutocompleteClipboardSnippet, AutocompleteCodeSnippet, @@ -25,11 +24,12 @@ const addCommentMarks = (text: string, helper: HelperVars) => { const formatClipboardSnippet = ( snippet: AutocompleteClipboardSnippet, -): AutocompleteClipboardSnippet => { - return { - ...snippet, - content: `Recently copied by user:${snippet.content.includes("\n") ? "\n" : ""} ${snippet.content}`, - }; +): AutocompleteCodeSnippet => { + return formatCodeSnippet({ + filepath: "Untitled.txt", + content: snippet.content, + type: AutocompleteSnippetType.Code, + }); }; const formatCodeSnippet = ( @@ -37,7 +37,7 @@ const formatCodeSnippet = ( ): AutocompleteCodeSnippet => { return { ...snippet, - content: `Path: ${getBasename(snippet.filepath)}\n${snippet.content}`, + content: `Path: ${getLastNPathParts(snippet.filepath, 2)}\n${snippet.content}`, }; }; @@ -47,9 +47,8 @@ const formatDiffSnippet = ( return snippet; }; -// TODO: Insert this somewhere -const getCurrentFilepathSnippet = (helper: HelperVars) => { - const currentFilePath = `\n\n${getLastNPathParts(helper.filepath, 2)}\n\n`; +const getCurrentFilepath = (helper: HelperVars) => { + return getLastNPathParts(helper.filepath, 2); }; const commentifySnippet = ( @@ -71,30 +70,38 @@ export const formatSnippets = ( helper: HelperVars, snippets: AutocompleteSnippet[], ): string => { - return snippets - .map((snippet) => { - switch (snippet.type) { - case AutocompleteSnippetType.Code: - return formatCodeSnippet(snippet); - case AutocompleteSnippetType.Diff: - return formatDiffSnippet(snippet); - case AutocompleteSnippetType.Clipboard: - return formatClipboardSnippet(snippet); - } - }) - .map((item) => { - if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { - return commentifySnippet(helper, item); - } + const currentFilepathComment = addCommentMarks( + getCurrentFilepath(helper), + helper, + ); - return item; - }) - .map((item) => { - if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { - return item.content + `\n${getCommentMark}\n${getCommentMark}`; - } + return ( + snippets + .map((snippet) => { + switch (snippet.type) { + case AutocompleteSnippetType.Code: + return formatCodeSnippet(snippet); + case AutocompleteSnippetType.Diff: + return formatDiffSnippet(snippet); + case AutocompleteSnippetType.Clipboard: + return formatClipboardSnippet(snippet); + } + }) + .map((item) => { + if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { + return commentifySnippet(helper, item); + } - return item.content + "\n\n"; - }) - .join(""); + return item; + }) + .map((item) => { + if (SNIPPET_TYPES_TO_COMMENT.includes(item.type)) { + const commentMark = getCommentMark(helper); + return item.content + `\n${commentMark}\n${commentMark}`; + } + + return item.content + "\n\n"; + }) + .join("\n") + `\n${currentFilepathComment}` + ); }; From 3155b780764d9132d37e55101175b99578f37f2c Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 22 Nov 2024 11:27:27 -0800 Subject: [PATCH 05/14] improv: filtering, code cleanup --- core/autocomplete/CompletionProvider.ts | 28 ------------ core/autocomplete/README.md | 2 - .../snippets/aggregateSnippets.ts | 45 ------------------- core/autocomplete/snippets/getAllSnippets.ts | 1 - core/autocomplete/snippets/types.ts | 1 - core/autocomplete/templating/filtering.ts | 34 +++++++++++++- .../util/AutocompleteLoggingService.ts | 1 - core/config/types.ts | 2 - core/index.d.ts | 3 -- core/util/parameters.ts | 3 -- docs/docs/autocomplete/how-to-customize.md | 2 - .../docs/customize/deep-dives/autocomplete.md | 2 - docs/docs/reference.md | 2 - .../current/autocomplete/how-to-customize.md | 2 - .../customize/deep-dives/autocomplete.md | 2 - .../current/reference.md | 2 - extensions/vscode/config_schema.json | 8 ---- extensions/vscode/src/autocomplete/lsp.ts | 1 - packages/config-types/src/index.ts | 2 - 19 files changed, 32 insertions(+), 111 deletions(-) delete mode 100644 core/autocomplete/snippets/aggregateSnippets.ts diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index fe9ec02e6..b329dd0a1 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -275,32 +275,4 @@ export class CompletionProvider { this.loggingService.deleteAbortController(input.completionId); } } - - // private async _getExtraSnippets( - // helper: HelperVars, - // ): Promise { - // let extraSnippets = helper.options.useOtherFiles - // ? ((await Promise.race([ - // this.getDefinitionsFromLsp( - // helper.input.filepath, - // helper.fullPrefix + helper.fullSuffix, - // helper.fullPrefix.length, - // this.ide, - // helper.lang, - // ), - // new Promise((resolve) => { - // setTimeout(() => resolve([]), 100); - // }), - // ])) as AutocompleteSnippetDeprecated[]) - // : []; - - // const workspaceDirs = await this.ide.getWorkspaceDirs(); - // if (helper.options.onlyMyCode) { - // extraSnippets = extraSnippets.filter((snippet) => { - // return workspaceDirs.some((dir) => snippet.filepath.startsWith(dir)); - // }); - // } - - // return extraSnippets; - // } } diff --git a/core/autocomplete/README.md b/core/autocomplete/README.md index 9baf9cd4b..627ca1206 100644 --- a/core/autocomplete/README.md +++ b/core/autocomplete/README.md @@ -87,7 +87,6 @@ This is just another object like the ones in the `"models"` array of `config.jso This object allows you to customize the behavior of tab-autocomplete. The available options are: -- `useCopyBuffer`: Determines whether the copy buffer will be considered when constructing the prompt. (Boolean) - `useFileSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) - `maxPromptTokens`: The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context. (Number) - `debounceDelay`: The delay in milliseconds before triggering autocomplete after a keystroke. (Number) @@ -107,7 +106,6 @@ This object allows you to customize the behavior of tab-autocomplete. The availa "apiBase": "https://" }, "tabAutocompleteOptions": { - "useCopyBuffer": false, "maxPromptTokens": 400, "prefixPercentage": 0.5 } diff --git a/core/autocomplete/snippets/aggregateSnippets.ts b/core/autocomplete/snippets/aggregateSnippets.ts deleted file mode 100644 index 1562c6f57..000000000 --- a/core/autocomplete/snippets/aggregateSnippets.ts +++ /dev/null @@ -1,45 +0,0 @@ -// import { ContextRetrievalService } from "../context/ContextRetrievalService.js"; -// import { -// fillPromptWithSnippets, -// rankAndOrderSnippets, -// } from "../context/ranking/index.js"; -// import { AutocompleteSnippetDeprecated } from "../types.js"; -// import { HelperVars } from "../util/HelperVars.js"; - -// function filterSnippetsAlreadyInCaretWindow( -// snippets: AutocompleteSnippetDeprecated[], -// caretWindow: string, -// ): AutocompleteSnippetDeprecated[] { -// return snippets -// .map((snippet) => ({ ...snippet })) -// .filter( -// (s) => -// s.contents.trim() !== "" && !caretWindow.includes(s.contents.trim()), -// ); -// } - -// export async function aggregateSnippets( -// helper: HelperVars, -// extraSnippets: AutocompleteSnippetDeprecated[], -// contextRetrievalService: ContextRetrievalService, -// ): Promise { -// let snippets = await contextRetrievalService.retrieveCandidateSnippets( -// helper, -// extraSnippets, -// ); - -// snippets = filterSnippetsAlreadyInCaretWindow( -// snippets, -// helper.prunedCaretWindow, -// ); - -// const scoredSnippets = rankAndOrderSnippets(snippets, helper); - -// const finalSnippets = fillPromptWithSnippets( -// scoredSnippets, -// helper.maxSnippetTokens, -// helper.modelName, -// ); - -// return finalSnippets; -// } diff --git a/core/autocomplete/snippets/getAllSnippets.ts b/core/autocomplete/snippets/getAllSnippets.ts index cda4874a1..cf0b88253 100644 --- a/core/autocomplete/snippets/getAllSnippets.ts +++ b/core/autocomplete/snippets/getAllSnippets.ts @@ -51,7 +51,6 @@ function getSnippetsFromRecentlyEditedRanges( return { filepath: range.filepath, content: range.lines.join("\n"), - score: 0.8, type: AutocompleteSnippetType.Code, }; }); diff --git a/core/autocomplete/snippets/types.ts b/core/autocomplete/snippets/types.ts index b97e07604..e43b59862 100644 --- a/core/autocomplete/snippets/types.ts +++ b/core/autocomplete/snippets/types.ts @@ -5,7 +5,6 @@ export enum AutocompleteSnippetType { } interface BaseAutocompleteSnippet { - score?: number; content: string; type: AutocompleteSnippetType; } diff --git a/core/autocomplete/templating/filtering.ts b/core/autocomplete/templating/filtering.ts index c657a75f3..bc85fb909 100644 --- a/core/autocomplete/templating/filtering.ts +++ b/core/autocomplete/templating/filtering.ts @@ -1,6 +1,9 @@ import { countTokens } from "../../llm/countTokens"; import { SnippetPayload } from "../snippets"; -import { AutocompleteSnippet } from "../snippets/types"; +import { + AutocompleteCodeSnippet, + AutocompleteSnippet, +} from "../snippets/types"; import { HelperVars } from "../util/HelperVars"; import { isValidSnippet } from "./validation"; @@ -12,6 +15,28 @@ const getRemainingTokenCount = (helper: HelperVars): number => { const TOKEN_BUFFER = 10; // We may need extra tokens for snippet description etc. +/** + * Shuffles an array in place using the Fisher-Yates algorithm. + * @param array The array to shuffle. + * @returns The shuffled array. + */ +const shuffleArray = (array: T[]): T[] => { + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + return array; +}; + +function filterSnippetsAlreadyInCaretWindow( + snippets: AutocompleteCodeSnippet[], + caretWindow: string, +): AutocompleteCodeSnippet[] { + return snippets.filter( + (s) => s.content.trim() !== "" && !caretWindow.includes(s.content.trim()), + ); +} + export const getSnippets = ( helper: HelperVars, payload: SnippetPayload, @@ -19,7 +44,12 @@ export const getSnippets = ( const snippets = [ ...payload.diffSnippets, ...payload.clipboardSnippets, - ...payload.rootPathSnippets, + ...shuffleArray( + filterSnippetsAlreadyInCaretWindow( + [...payload.rootPathSnippets], + helper.prunedCaretWindow, + ), + ), ]; const finalSnippets = []; diff --git a/core/autocomplete/util/AutocompleteLoggingService.ts b/core/autocomplete/util/AutocompleteLoggingService.ts index 96261e646..35e0ead64 100644 --- a/core/autocomplete/util/AutocompleteLoggingService.ts +++ b/core/autocomplete/util/AutocompleteLoggingService.ts @@ -112,7 +112,6 @@ export class AutocompleteLoggingService { multilineCompletions: restOfOutcome.multilineCompletions, time: restOfOutcome.time, useRecentlyEdited: restOfOutcome.useRecentlyEdited, - useRootPathContext: restOfOutcome.useRootPathContext, }, true, ); diff --git a/core/config/types.ts b/core/config/types.ts index 47c4a5aa7..b6d24264c 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -825,7 +825,6 @@ declare global { export interface TabAutocompleteOptions { disable: boolean; - useCopyBuffer: boolean; useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; @@ -840,7 +839,6 @@ declare global { maxClipboardPercentage: number; useCache: boolean; onlyMyCode: boolean; - useOtherFiles: boolean; useRecentlyEdited: boolean; disableInFiles?: string[]; useImports?: boolean; diff --git a/core/index.d.ts b/core/index.d.ts index f96cbd122..ea4b88b62 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -968,7 +968,6 @@ export interface Reranker { export interface TabAutocompleteOptions { disable: boolean; - useCopyBuffer: boolean; useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; @@ -984,11 +983,9 @@ export interface TabAutocompleteOptions { maxClipboardPercentage: number; useCache: boolean; onlyMyCode: boolean; - useOtherFiles: boolean; useRecentlyEdited: boolean; disableInFiles?: string[]; useImports?: boolean; - useRootPathContext?: boolean; showWhateverWeHaveAtXMs?: number; } diff --git a/core/util/parameters.ts b/core/util/parameters.ts index 7ba828f7a..213052a7b 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -2,7 +2,6 @@ import { TabAutocompleteOptions } from "../index.js"; export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { disable: false, - useCopyBuffer: false, useFileSuffix: true, maxPromptTokens: 1024, prefixPercentage: 0.85, @@ -16,11 +15,9 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { maxClipboardPercentage: 0.5, // yes the percentages do not add up useCache: true, onlyMyCode: true, - useOtherFiles: true, useRecentlyEdited: true, disableInFiles: undefined, useImports: true, - useRootPathContext: true, transform: true, showWhateverWeHaveAtXMs: 300, }; diff --git a/docs/docs/autocomplete/how-to-customize.md b/docs/docs/autocomplete/how-to-customize.md index dcf6ba234..ccd1dca9d 100644 --- a/docs/docs/autocomplete/how-to-customize.md +++ b/docs/docs/autocomplete/how-to-customize.md @@ -9,14 +9,12 @@ Continue offers a handful of parameters in [`config.json`](../reference.md) that ```json title="config.json" "tabAutocompleteOptions": { - "useCopyBuffer": false, "maxPromptTokens": 400, "prefixPercentage": 0.5, "multilineCompletions": "always" } ``` -- `useCopyBuffer`: Determines if the clipboard content should be considered in prompt construction. - `maxPromptTokens`: Sets the maximum number of tokens for the prompt, balancing context and speed. - `prefixPercentage`: Defines the proportion of the prompt dedicated to the code before the cursor. - `multilineCompletions`: Controls whether suggestions can span multiple lines ("always", "never", or "auto"). diff --git a/docs/docs/customize/deep-dives/autocomplete.md b/docs/docs/customize/deep-dives/autocomplete.md index 9e03aa756..35789710c 100644 --- a/docs/docs/customize/deep-dives/autocomplete.md +++ b/docs/docs/customize/deep-dives/autocomplete.md @@ -60,7 +60,6 @@ This object allows you to customize the behavior of tab-autocomplete. The availa - `disable`: Disable autocomplete (can also be done from IDE settings) - `template`: An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables. (String) -- `useCopyBuffer`: Determines whether the copy buffer will be considered when constructing the prompt. (Boolean) - `useFileSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) - `maxPromptTokens`: The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context. (Number) - `prefixPercentage`: The percentage of the input that should be dedicated to the prefix. (Number) @@ -68,7 +67,6 @@ This object allows you to customize the behavior of tab-autocomplete. The availa - `debounceDelay`: The delay in milliseconds before triggering autocomplete after a keystroke. (Number) - `multilineCompletions`: Whether to enable multiline completions ("always", "never", or "auto"). Defaults to "auto". - `useCache`: Whether to cache and reuse completions when the prompt is the same as a previous one. May be useful to disable for testing purposes. -- `useOtherFiles`: Whether to include context from files outside of the current one. Turning this off should be expected to reduce the accuracy of completions, but might be good for testing. - `disableInFiles`: A list of glob patterns for files in which you want to disable tab autocomplete. ### Full example diff --git a/docs/docs/reference.md b/docs/docs/reference.md index f39e68998..5fc3218df 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -83,7 +83,6 @@ Specifies options for tab autocompletion behavior. **Properties:** - `disable`: If `true`, disables tab autocomplete (default: `false`). -- `useCopyBuffer`: If `true`, includes the copy buffer in the prompt. - `useFileSuffix`: If `true`, includes file suffix in the prompt. - `maxPromptTokens`: Maximum number of tokens for the prompt. - `debounceDelay`: Delay (in ms) before triggering autocomplete. @@ -93,7 +92,6 @@ Specifies options for tab autocompletion behavior. - `multilineCompletions`: Controls multiline completions (`"always"`, `"never"`, or `"auto"`). - `useCache`: If `true`, caches completions. - `onlyMyCode`: If `true`, only includes code within the repository. -- `useOtherFiles`: If `true`, includes snippets from other files (default: `true`). - `disableInFiles`: Array of glob patterns for files where autocomplete is disabled. Example diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-customize.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-customize.md index aa2a04d5f..143645591 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-customize.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-customize.md @@ -9,14 +9,12 @@ Continue 在 [`config.json`](../reference.md) 提供少量的参数,对于你 ```json title="config.json" "tabAutocompleteOptions": { - "useCopyBuffer": false, "maxPromptTokens": 400, "prefixPercentage": 0.5, "multilineCompletions": "always" } ``` -- `useCopyBuffer`: 决定剪贴板的内容是否包含在提示词构建中 - `maxPromptTokens`: 设置提示词的最大 token 数,平衡上下文和速度 - `prefixPercentage`: 决定提示词使用光标前代码的比例 - `multilineCompletions`: 控制建议是否可以跨多行 ("always", "never" 或 "auto") diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md index b85cfe323..15cb94c4d 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md @@ -60,7 +60,6 @@ ollama run starcoder2:3b - `disable`: 禁用自动补全(也可以在 IDE 配置中完成) - `template`: 一个用来自动补全的可选的模板字符串。它使用 Mustache 模板语言渲染,并且传递 'prefix' 和 'suffix' 变量。(字符串) -- `useCopyBuffer`: 决定 copy buffer 是否考虑为构建提示词。(布尔型) - `useFileSuffix`: 决定是否使用文件后缀在提示词中。(布尔型) - `maxPromptTokens`: 提示词使用的 token 的最大数量。一个较小的数字生成较快的补全,但是较少的上下文。(数字) - `prefixPercentage`: 输入专注于前缀的百分比。(数字) @@ -69,7 +68,6 @@ ollama run starcoder2:3b - `debounceDelay`: 在按键之后触发自动补全的毫秒延迟。(数字) - `multilineCompletions`: 是否启用多行补全 ("always", "never" 或 "auto") 。默认情况下是 "auto" 。 - `useCache`: 是否缓存和重新使用补全,当提示词与前一个相同时。对于测试的目的可能是有用的。 -- `useOtherFiles`: 是否包含当前文件之外的文件的上下文。关闭这个预期会减少补全的准确性,但是对于测试可能是有用的。 - `disableInFiles`: 一个你想要禁用 tab 自动补全的 glob 模式的文件列表。 ### 完整示例 diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md index 09dd150a6..a224cf8a8 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md @@ -83,7 +83,6 @@ Specifies options for tab autocompletion behavior. **Properties:** - `disable`: If `true`, disables tab autocomplete (default: `false`). -- `useCopyBuffer`: If `true`, includes the copy buffer in the prompt. - `useFileSuffix`: If `true`, includes file suffix in the prompt. - `maxPromptTokens`: Maximum number of tokens for the prompt. - `debounceDelay`: Delay (in ms) before triggering autocomplete. @@ -93,7 +92,6 @@ Specifies options for tab autocompletion behavior. - `multilineCompletions`: Controls multiline completions (`"always"`, `"never"`, or `"auto"`). - `useCache`: If `true`, caches completions. - `onlyMyCode`: If `true`, only includes code within the repository. -- `useOtherFiles`: If `true`, includes snippets from other files (default: `true`). - `disableInFiles`: Array of glob patterns for files where autocomplete is disabled. Example diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 7edceced4..3a274c8b0 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -2791,10 +2791,6 @@ "description": "Disable tab autocomplete. This can also be done from the IDE settings.", "default": false }, - "useCopyBuffer": { - "type": "boolean", - "description": "Determines whether the copy buffer will be considered when contructing the prompt." - }, "useFileSuffix": { "type": "boolean", "description": "Determines whether to use the file suffix in the prompt." @@ -2835,10 +2831,6 @@ "type": "boolean", "description": "If set to true, Continue will not include any snippets from go to definition unless they are within your repository" }, - "useOtherFiles": { - "type": "boolean", - "description": "Defaults to true. If set to false, Continue will not attempt to include snippets from other files." - }, "disableInFiles": { "description": "A list of files / glob patterns in which to disable tab autocomplete. For example, *.csv if you'd like to disable autocomplete in .csv files.", "type": "array", diff --git a/extensions/vscode/src/autocomplete/lsp.ts b/extensions/vscode/src/autocomplete/lsp.ts index a11aeeead..fb06115b5 100644 --- a/extensions/vscode/src/autocomplete/lsp.ts +++ b/extensions/vscode/src/autocomplete/lsp.ts @@ -374,7 +374,6 @@ export const getDefinitionsFromLsp: GetLspDefinitionsFunction = async ( return results.map((result) => ({ filepath: result.filepath, content: result.contents, - score: 0.8, type: AutocompleteSnippetType.Code, })); } catch (e) { diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts index fc53c742f..8557e3cf0 100644 --- a/packages/config-types/src/index.ts +++ b/packages/config-types/src/index.ts @@ -130,7 +130,6 @@ export type UiOptions = z.infer; export const tabAutocompleteOptionsSchema = z.object({ disable: z.boolean(), - useCopyBuffer: z.boolean(), useFileSuffix: z.boolean(), maxPromptTokens: z.number(), debounceDelay: z.number(), @@ -146,7 +145,6 @@ export const tabAutocompleteOptionsSchema = z.object({ maxClipboardPercentage: z.number(), useCache: z.boolean(), onlyMyCode: z.boolean(), - useOtherFiles: z.boolean(), useRecentlyEdited: z.boolean(), disableInFiles: z.array(z.string()).optional(), useImports: z.boolean().optional(), From 449d751d1d66d40b4671b72b83f8cf56331870a1 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 22 Nov 2024 14:45:25 -0800 Subject: [PATCH 06/14] refactor: clean up code --- core/autocomplete/util/HelperVars.ts | 11 ----------- core/config/types.ts | 3 --- core/index.d.ts | 3 --- core/util/parameters.ts | 3 --- packages/config-types/src/index.ts | 3 --- 5 files changed, 23 deletions(-) diff --git a/core/autocomplete/util/HelperVars.ts b/core/autocomplete/util/HelperVars.ts index c5429fe81..047038493 100644 --- a/core/autocomplete/util/HelperVars.ts +++ b/core/autocomplete/util/HelperVars.ts @@ -114,17 +114,6 @@ export class HelperVars { get pos() { return this.input.pos; } - get maxSnippetTokens() { - return this.options.maxPromptTokens * this.options.maxSnippetPercentage; - } - - get maxDiffTokens() { - return this.options.maxPromptTokens * this.options.maxDiffPercentage; - } - - get maxClipboardTokens() { - return this.options.maxPromptTokens * this.options.maxClipboardPercentage; - } get prunedCaretWindow() { return this.prunedPrefix + this.prunedSuffix; diff --git a/core/config/types.ts b/core/config/types.ts index b6d24264c..bb6c8f48c 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -834,9 +834,6 @@ declare global { multilineCompletions: "always" | "never" | "auto"; slidingWindowPrefixPercentage: number; slidingWindowSize: number; - maxSnippetPercentage: number; - maxDiffPercentage: number; - maxClipboardPercentage: number; useCache: boolean; onlyMyCode: boolean; useRecentlyEdited: boolean; diff --git a/core/index.d.ts b/core/index.d.ts index ea4b88b62..3fa415ad7 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -978,9 +978,6 @@ export interface TabAutocompleteOptions { multilineCompletions: "always" | "never" | "auto"; slidingWindowPrefixPercentage: number; slidingWindowSize: number; - maxSnippetPercentage: number; - maxDiffPercentage: number; - maxClipboardPercentage: number; useCache: boolean; onlyMyCode: boolean; useRecentlyEdited: boolean; diff --git a/core/util/parameters.ts b/core/util/parameters.ts index 213052a7b..24e94781c 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -10,9 +10,6 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { multilineCompletions: "auto", slidingWindowPrefixPercentage: 0.75, slidingWindowSize: 500, - maxSnippetPercentage: 0.5, - maxDiffPercentage: 0.5, - maxClipboardPercentage: 0.5, // yes the percentages do not add up useCache: true, onlyMyCode: true, useRecentlyEdited: true, diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts index 8557e3cf0..2170a116b 100644 --- a/packages/config-types/src/index.ts +++ b/packages/config-types/src/index.ts @@ -140,9 +140,6 @@ export const tabAutocompleteOptionsSchema = z.object({ multilineCompletions: z.enum(["always", "never", "auto"]), slidingWindowPrefixPercentage: z.number(), slidingWindowSize: z.number(), - maxSnippetPercentage: z.number(), - maxDiffPercentage: z.number(), - maxClipboardPercentage: z.number(), useCache: z.boolean(), onlyMyCode: z.boolean(), useRecentlyEdited: z.boolean(), From c203bc4ae9c3a0463af6c2f9bfd8d0a6685a2367 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 22 Nov 2024 14:47:55 -0800 Subject: [PATCH 07/14] refactor: remove unused code --- core/autocomplete/context/ranking/index.ts | 55 ----------------- .../context/ranking/slidingWindow.ts | 61 ------------------- 2 files changed, 116 deletions(-) delete mode 100644 core/autocomplete/context/ranking/slidingWindow.ts diff --git a/core/autocomplete/context/ranking/index.ts b/core/autocomplete/context/ranking/index.ts index a11389470..2d10d0864 100644 --- a/core/autocomplete/context/ranking/index.ts +++ b/core/autocomplete/context/ranking/index.ts @@ -154,58 +154,3 @@ export function fillPromptWithSnippets( return keptSnippets; } - -/** - * Remove one range from another range, which may lead to returning two disjoint ranges - */ -// function rangeDifferenceByLines(orig: Range, remove: Range): Range[] { -// if ( -// orig.start.line >= remove.start.line && -// orig.end.line <= remove.end.line -// ) { -// // / | | / -// return []; -// } -// if ( -// orig.start.line <= remove.start.line && -// orig.end.line >= remove.end.line -// ) { -// // | / / | -// // Splits the range -// return [ -// { -// start: orig.start, -// end: remove.start, -// }, -// { -// start: remove.end, -// end: orig.end, -// }, -// ]; -// } -// if ( -// orig.start.line >= remove.start.line && -// orig.end.line >= remove.end.line -// ) { -// // \ | / | -// return [ -// { -// start: remove.end, -// end: orig.end, -// }, -// ]; -// } -// if ( -// orig.start.line <= remove.start.line && -// orig.end.line <= remove.end.line -// ) { -// // | / | / -// return [ -// { -// start: orig.start, -// end: remove.start, -// }, -// ]; -// } -// return [orig]; -// } diff --git a/core/autocomplete/context/ranking/slidingWindow.ts b/core/autocomplete/context/ranking/slidingWindow.ts deleted file mode 100644 index 88ee2bff3..000000000 --- a/core/autocomplete/context/ranking/slidingWindow.ts +++ /dev/null @@ -1,61 +0,0 @@ -// import { RangeInFileWithContents } from "../../../commands/util.js"; -// import { AutocompleteSnippetDeprecated } from "../../types.js"; - -// import { jaccardSimilarity } from "./index.js"; - -// function* slidingWindow( -// content: string, -// windowSize: number, -// ): Generator { -// const lines = content.split("\n"); - -// let charCount = 0; -// let currWindowLines: string[] = []; -// for (let i = 0; i < lines.length; i++) { -// if (charCount + lines[i].length >= windowSize) { -// yield currWindowLines.join("\n"); -// currWindowLines = [lines[i]]; -// charCount = 0; -// } else { -// currWindowLines.push(lines[i]); -// } -// charCount += lines[i].length; -// } - -// if (currWindowLines.length > 0) { -// yield currWindowLines.join("\n"); -// } -// } - -// /** -// * Match by similarity over sliding windows of recent documents. -// * @param recentFiles -// * @param prefix -// * @param suffix -// */ -// export async function slidingWindowMatcher( -// recentFiles: RangeInFileWithContents[], -// windowAroundCursor: string, -// topN: number, -// windowSize: number, -// ): Promise { -// // Sorted lowest similarity to highest -// const topMatches: Required[] = []; - -// for (const { filepath, contents, range } of recentFiles) { -// for (const window of slidingWindow(contents, windowSize)) { -// const score = jaccardSimilarity(window, windowAroundCursor); - -// // Insertion sort -// let i = -1; -// while (++i < topMatches.length && score > topMatches[i].score) {} -// topMatches.splice(i + 1, 0, { filepath, contents, score, range }); -// if (topMatches.length > topN) { -// topMatches.shift(); -// } -// } -// } - -// // TODO: convert the arbitrary window frame to some whole AST node? -// return topMatches; -// } From 5fd8d2cae5926418116031dbab8ce9465bc4c8f9 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Fri, 22 Nov 2024 14:52:04 -0800 Subject: [PATCH 08/14] fix: broken imports --- core/autocomplete/types.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/autocomplete/types.ts b/core/autocomplete/types.ts index 9488fb085..23f762556 100644 --- a/core/autocomplete/types.ts +++ b/core/autocomplete/types.ts @@ -1,5 +1,4 @@ -import { RangeInFileWithContents } from "../commands/util"; -import { IDE } from "../index"; +import { IDE, RangeInFileWithContents } from "../index"; import { AutocompleteLanguageInfo } from "./constants/AutocompleteLanguageInfo"; import { AutocompleteCodeSnippet } from "./snippets/types"; From c359b296fa4b627db5e1e49f1adfc572621b61c9 Mon Sep 17 00:00:00 2001 From: Ruedi Steinmann Date: Sun, 24 Nov 2024 21:15:32 +0100 Subject: [PATCH 09/14] Fix Unit Test --- .../filtering/streamTransforms/StreamTransformPipeline.ts | 3 +-- .../filtering/streamTransforms/lineStream.test.ts | 4 ++-- core/autocomplete/filtering/test/testCases.ts | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index f1fb49300..6ddfda18a 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -11,7 +11,6 @@ import { stopAtLines, stopAtRepeatingLines, stopAtSimilarLine, - stopNCharsAfterClosingBracket, streamWithNewLines, } from "./lineStream"; @@ -48,7 +47,7 @@ export class StreamTransformPipeline { ); lineGenerator = avoidPathLine(lineGenerator, helper.lang.singleLineComment); lineGenerator = skipPrefixes(lineGenerator); - lineGenerator = stopNCharsAfterClosingBracket(lineGenerator); + // lineGenerator = stopNCharsAfterClosingBracket(lineGenerator); for (const lineFilter of helper.lang.lineFilters ?? []) { lineGenerator = lineFilter({ lines: lineGenerator, fullStop }); diff --git a/core/autocomplete/filtering/streamTransforms/lineStream.test.ts b/core/autocomplete/filtering/streamTransforms/lineStream.test.ts index 0a99a5a91..5cb05d2c3 100644 --- a/core/autocomplete/filtering/streamTransforms/lineStream.test.ts +++ b/core/autocomplete/filtering/streamTransforms/lineStream.test.ts @@ -98,7 +98,7 @@ describe("lineStream", () => { describe("stopAtSimilarLine", () => { it("should stop at the exact same line", async () => { - const lineToTest = "const x = 6;"; + const lineToTest = "const x = 6"; const linesGenerator = await getLineGenerator([ "console.log();", "const y = () => {};", @@ -116,7 +116,7 @@ describe("lineStream", () => { expect(mockFullStop).toHaveBeenCalledTimes(1); }); - it.only("should stop at a similar line", async () => { + it("should stop at a similar line", async () => { const lineToTest = "const x = 6;"; const linesGenerator = await getLineGenerator([ "console.log();", diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index f0584ab48..ec7f87516 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -131,6 +131,10 @@ public class Calculator { } `, expectedCompletion: ` + } + + public void subtract(double number) { + result -= number; }`, }, { From bd2bf657a019167623cadd1334497605c4cc9a81 Mon Sep 17 00:00:00 2001 From: Ruedi Steinmann Date: Mon, 25 Nov 2024 20:32:15 +0100 Subject: [PATCH 10/14] Improve Filtering --- .../StreamTransformPipeline.ts | 3 +- .../streamTransforms/charStream.test.ts | 138 +++++++++++------- .../filtering/streamTransforms/charStream.ts | 54 +++++++ core/autocomplete/filtering/test/testCases.ts | 48 +++--- core/autocomplete/filtering/test/util.ts | 2 +- 5 files changed, 176 insertions(+), 69 deletions(-) diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index 6ddfda18a..cedaaedfa 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -2,7 +2,7 @@ import { streamLines } from "../../../diff/util"; import { DEFAULT_AUTOCOMPLETE_OPTS } from "../../../util/parameters"; import { HelperVars } from "../../util/HelperVars"; -import { stopAtStopTokens } from "./charStream"; +import { stopAtStartOf, stopAtStopTokens } from "./charStream"; import { avoidEmptyComments, avoidPathLine, @@ -27,6 +27,7 @@ export class StreamTransformPipeline { let charGenerator = generator; charGenerator = stopAtStopTokens(generator, stopTokens); + charGenerator = stopAtStartOf(charGenerator, suffix); for (const charFilter of helper.lang.charFilters ?? []) { charGenerator = charFilter({ chars: charGenerator, diff --git a/core/autocomplete/filtering/streamTransforms/charStream.test.ts b/core/autocomplete/filtering/streamTransforms/charStream.test.ts index b466ae3cd..d82d9dbac 100644 --- a/core/autocomplete/filtering/streamTransforms/charStream.test.ts +++ b/core/autocomplete/filtering/streamTransforms/charStream.test.ts @@ -1,12 +1,20 @@ -import { stopAtStopTokens } from "./charStream"; +import { stopAtStartOf, stopAtStopTokens } from "./charStream"; + +async function* createMockStream(chunks: string[]): AsyncGenerator { + for (const chunk of chunks) { + yield chunk; + } +} + +async function streamToString(stream: AsyncGenerator): Promise { + let result = ""; + for await (const chunk of stream) { + result += chunk; + } + return result; +} describe("stopAtStopTokens", () => { - async function* createMockStream(chunks: string[]): AsyncGenerator { - for (const chunk of chunks) { - yield chunk; - } - } - it("should yield characters until a stop token is encountered", async () => { const mockStream = createMockStream(["Hello", " world", "! Stop", "here"]); const stopTokens = ["Stop"]; @@ -30,12 +38,7 @@ describe("stopAtStopTokens", () => { const stopTokens = ["END", "STOP", "HALT"]; const result = stopAtStopTokens(mockStream, stopTokens); - const output = []; - for await (const char of result) { - output.push(char); - } - - expect(output.join("")).toBe("This is a test. "); + expect(await streamToString(result)).toBe("This is a test. "); }); it("should handle stop tokens split across chunks", async () => { @@ -67,12 +70,7 @@ describe("stopAtStopTokens", () => { const stopTokens = ["END"]; const result = stopAtStopTokens(mockStream, stopTokens); - const output = []; - for await (const char of result) { - output.push(char); - } - - expect(output.join("")).toBe("This is a complete stream"); + expect(await streamToString(result)).toBe("This is a complete stream"); }); it("should handle empty chunks", async () => { @@ -80,12 +78,7 @@ describe("stopAtStopTokens", () => { const stopTokens = ["STOP"]; const result = stopAtStopTokens(mockStream, stopTokens); - const output = []; - for await (const char of result) { - output.push(char); - } - - expect(output.join("")).toBe("Hello world! "); + expect(await streamToString(result)).toBe("Hello world! "); }); it("should handle stop token at the beginning of the stream", async () => { @@ -106,12 +99,7 @@ describe("stopAtStopTokens", () => { const stopTokens = ["STOP"]; const result = stopAtStopTokens(mockStream, stopTokens); - const output = []; - for await (const char of result) { - output.push(char); - } - - expect(output.join("")).toBe("Hello world"); + expect(await streamToString(result)).toBe("Hello world"); }); it("should handle multiple stop tokens of different lengths", async () => { @@ -124,12 +112,7 @@ describe("stopAtStopTokens", () => { const stopTokens = ["STOP", "END", "HALT"]; const result = stopAtStopTokens(mockStream, stopTokens); - const output = []; - for await (const char of result) { - output.push(char); - } - - expect(output.join("")).toBe("This is a test with multiple "); + expect(await streamToString(result)).toBe("This is a test with multiple "); }); it("should handle an empty stream", async () => { @@ -137,12 +120,7 @@ describe("stopAtStopTokens", () => { const stopTokens = ["STOP"]; const result = stopAtStopTokens(mockStream, stopTokens); - const output = []; - for await (const char of result) { - output.push(char); - } - - expect(output.join("")).toBe(""); + expect(await streamToString(result)).toBe(""); }); it("should handle an empty stop tokens array", async () => { @@ -166,11 +144,73 @@ describe("stopAtStopTokens", () => { ]; const result = stopAtStopTokens(mockStream, stopTokens); - const output = []; - for await (const char of result) { - output.push(char); - } - - expect(output.join("")).toBe("Hello world!"); + expect(await streamToString(result)).toBe("Hello world!"); + }); +}); + +describe("stopAtStartOf", () => { + const sampleCode = ` { + method: "GET", + headers: { + "Content-Type": "application/json", + Authorization: \`Bearer \${this.workOsAccessToken}\`, + }, + }, + ); + const data = await response.json(); + return data.items; + } + + async getContextItems( + query: string, + extras: ContextProviderExtras, + ): Promise { + const response = await extras.fetch( + new URL( + \`/proxy/context/\${this.options.id}/retrieve\`, + controlPlaneEnv.CONTROL_PLANE_URL, + ), +`; + /* Some LLMs, such as Codestral, repeat the suffix of the query. To test our filtering, we cut the sample code at random positions, remove a part of the input +and construct a response, containing the removed part and the suffix. The goal of the stopAtStartOf() method is to detect the start of the suffix in the response */ + it("should stop if the start of the suffix is reached", async () => { + const removeLength = 10; + for (let i = 0; i < sampleCode.length - removeLength - 20; i++) { + const removed = sampleCode.slice(i, i + removeLength); + const suffix = sampleCode.slice(i + removeLength); + const response = removed + suffix; + + // split the response but keep spaces + const mockStream = createMockStream(response.split(/(?! )/g)); + const result = stopAtStartOf(mockStream, suffix); + + const resultStr = await streamToString(result); + if (resultStr !== removed) { + throw new Error( + `i=${i} result:\n${resultStr}\n\nremoved:\n${removed}\n\nsuffix:\n${suffix}`, + ); + } + } + }); + it("should stop if the start of the suffix is reached, even if the suffix has a prefix", async () => { + const removeLength = 10; + for (let i = 0; i < sampleCode.length - removeLength - 20; i++) { + const removed = sampleCode.slice(i, i + removeLength); + let suffix = sampleCode.slice(i + removeLength); + const response = removed + suffix; + // add a prefix to the suffix + suffix = "strange words;\n which start the suffix#" + suffix; + + // split the response but keep spaces + const mockStream = createMockStream(response.split(/(?! )/g)); + const result = stopAtStartOf(mockStream, suffix); + + const resultStr = await streamToString(result); + if (resultStr !== removed) { + throw new Error( + `i=${i} result:\n${resultStr}\n\nremoved:\n${removed}\n\nsuffix:\n${suffix}`, + ); + } + } }); }); diff --git a/core/autocomplete/filtering/streamTransforms/charStream.ts b/core/autocomplete/filtering/streamTransforms/charStream.ts index 9f37e1f58..f4b751ff9 100644 --- a/core/autocomplete/filtering/streamTransforms/charStream.ts +++ b/core/autocomplete/filtering/streamTransforms/charStream.ts @@ -117,3 +117,57 @@ export async function* stopAtStopTokens( yield char; } } + +/** + * Asynchronously yields characters from the input stream, stopping if a sequence contained in the beginning of the suffix is encountered. + * */ +export async function* stopAtStartOf( + stream: AsyncGenerator, + suffix: string, + sequenceLength: number = 20, +): AsyncGenerator { + if (suffix.length < sequenceLength) { + for await (const chunk of stream) { + yield chunk; + } + return; + } + + const n = Math.min(suffix.length, 3 * sequenceLength); + let prev = new Array(n + 1).fill(0); + let res = 0; + let buffer = ""; + + for await (const chunk of stream) { + const s1 = chunk; + const m = chunk.length; + for (let i = 1; i <= m; i++) { + // Create a temporary array to store the current row + let curr = new Array(n + 1).fill(0); + for (let j = 1; j <= n; j++) { + if (s1[i - 1] === suffix[j - 1]) { + curr[j] = prev[j - 1] + 1; + res = Math.max(res, curr[j]); + } else { + curr[j] = 0; + } + } + + // Move the current row's data to the previous row + prev = curr; + + if (res > sequenceLength) { + return; + } + + buffer += s1[i - 1]; + + while (buffer.length > sequenceLength) { + yield buffer[0]; + buffer = buffer.slice(1); + } + } + } + + yield buffer; +} diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index ec7f87516..2fecabff6 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -157,23 +157,35 @@ public class Calculator { POSTGRES_DB: mydb `, }, - // TODO - // { - // description: "Should autocomplete a Markdown list with nested items", - // filename: "test.md", - // input: ` - // - Item 1 - // - Item 2 - // - Subitem 1 - // <|fim|> - // - Item 3 - // `, - // llmOutput: ` - Subitem 2 - // - Subitem 3 - // `, - // expectedCompletion: ` - Subitem 2 - // - Subitem 3`, - // }, + { + description: + "Should filter out suffix generated by LLM (sample from Codestral)", + filename: "test.js", + input: ` + add(number) { + this.result += number; + return this; + } + // Add the subtract method + subtract(number) {<|fim|> + + subtract(number) { + this.result -= number; + return this; + } + + multiply(number) { + this.result *= number; + return this; + }`, + llmOutput: ` this.result -= number; + return this; + } + // Add the multiply method + multiply(number) { + `, + expectedCompletion: null, + }, { description: "Should enforce bracket matching in JSON files", filename: "test.json", @@ -559,7 +571,7 @@ export const Timer = () => { ); };`, llmOutput: "return () => clearInterval(interval);", - expectedCompletion: "return () => clearInterval(interval);", + expectedCompletion: null, filename: "Timer.tsx", }, diff --git a/core/autocomplete/filtering/test/util.ts b/core/autocomplete/filtering/test/util.ts index 42ab196b7..8107a5235 100644 --- a/core/autocomplete/filtering/test/util.ts +++ b/core/autocomplete/filtering/test/util.ts @@ -72,5 +72,5 @@ export async function testAutocompleteFiltering( ); // Ensure that we return the text that is wanted to be displayed - expect(result?.completion).toEqual(test.expectedCompletion); + expect(result?.completion ?? null).toEqual(test.expectedCompletion); } From 625aca8cf8e7cfe0c240cfee446fcc8edb75de5f Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 25 Nov 2024 15:51:07 -0800 Subject: [PATCH 11/14] bump package-lock files --- core/package-lock.json | 485 +--------------------------- core/package.json | 2 +- extensions/vscode/package-lock.json | 332 +++---------------- extensions/vscode/package.json | 4 +- gui/package-lock.json | 2 +- 5 files changed, 58 insertions(+), 767 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index a53a1a49c..09e22ce96 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -24,7 +24,7 @@ "cheerio": "^1.0.0-rc.12", "commander": "^12.0.0", "comment-json": "^4.2.3", - "dbinfoz": "^0.14.0", + "dbinfoz": "^0.11.0", "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", @@ -1229,241 +1229,6 @@ } } }, - "node_modules/@azure/abort-controller": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", - "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-auth": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.9.0.tgz", - "integrity": "sha512-FPwHpZywuyasDSLMqJ6fhbOK3TqUdviZNF8OqRGA4W5Ewib2lEEZ+pBsYcBa88B2NGO/SEnYPGhyBqNlE8ilSw==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-util": "^1.11.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-client": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.9.2.tgz", - "integrity": "sha512-kRdry/rav3fUKHl/aDLd/pDLcB+4pOFwPPTVEExuMyaI5r+JBbMWqRbCY1pn5BniDaU3lRxO9eaQ1AmSMehl/w==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.4.0", - "@azure/core-rest-pipeline": "^1.9.1", - "@azure/core-tracing": "^1.0.0", - "@azure/core-util": "^1.6.1", - "@azure/logger": "^1.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-http-compat": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-2.1.2.tgz", - "integrity": "sha512-5MnV1yqzZwgNLLjlizsU3QqOeQChkIXw781Fwh1xdAqJR5AA32IUaq6xv1BICJvfbHoa+JYcaij2HFkhLbNTJQ==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-client": "^1.3.0", - "@azure/core-rest-pipeline": "^1.3.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-lro": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.7.2.tgz", - "integrity": "sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-util": "^1.2.0", - "@azure/logger": "^1.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-paging": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.6.2.tgz", - "integrity": "sha512-YKWi9YuCU04B55h25cnOYZHxXYtEvQEbKST5vqRga7hWY9ydd3FZHdeQF8pyh+acWZvppw13M/LMGx0LABUVMA==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-rest-pipeline": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.18.0.tgz", - "integrity": "sha512-QSoGUp4Eq/gohEFNJaUOwTN7BCc2nHTjjbm75JT0aD7W65PWM1H/tItz0GsABn22uaKyGxiMhWQLt2r+FGU89Q==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.8.0", - "@azure/core-tracing": "^1.0.1", - "@azure/core-util": "^1.11.0", - "@azure/logger": "^1.0.0", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-tracing": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.2.0.tgz", - "integrity": "sha512-UKTiEJPkWcESPYJz3X5uKRYyOcJD+4nYph+KpfdPRnQJVrZfk0KJgdnaAWKfhsBBtAf/D58Az4AvCJEmWgIBAg==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-util": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.11.0.tgz", - "integrity": "sha512-DxOSLua+NdpWoSqULhjDyAZTXFdP/LKkqtYuxxz1SCN289zk3OG8UOpnCQAz/tygyACBtWp/BoO72ptK7msY8g==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/identity": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.5.0.tgz", - "integrity": "sha512-EknvVmtBuSIic47xkOqyNabAme0RYTw52BTMz8eBgU1ysTyMrD1uOoM+JdS0J/4Yfp98IBT3osqq3BfwSaNaGQ==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.9.0", - "@azure/core-client": "^1.9.2", - "@azure/core-rest-pipeline": "^1.17.0", - "@azure/core-tracing": "^1.0.0", - "@azure/core-util": "^1.11.0", - "@azure/logger": "^1.0.0", - "@azure/msal-browser": "^3.26.1", - "@azure/msal-node": "^2.15.0", - "events": "^3.0.0", - "jws": "^4.0.0", - "open": "^8.0.0", - "stoppable": "^1.1.0", - "tslib": "^2.2.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/keyvault-common": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@azure/keyvault-common/-/keyvault-common-2.0.0.tgz", - "integrity": "sha512-wRLVaroQtOqfg60cxkzUkGKrKMsCP6uYXAOomOIysSMyt1/YM0eUn9LqieAWM8DLcU4+07Fio2YGpPeqUbpP9w==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.3.0", - "@azure/core-client": "^1.5.0", - "@azure/core-rest-pipeline": "^1.8.0", - "@azure/core-tracing": "^1.0.0", - "@azure/core-util": "^1.10.0", - "@azure/logger": "^1.1.4", - "tslib": "^2.2.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/keyvault-keys": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/@azure/keyvault-keys/-/keyvault-keys-4.9.0.tgz", - "integrity": "sha512-ZBP07+K4Pj3kS4TF4XdkqFcspWwBHry3vJSOFM5k5ZABvf7JfiMonvaFk2nBF6xjlEbMpz5PE1g45iTMme0raQ==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.3.0", - "@azure/core-client": "^1.5.0", - "@azure/core-http-compat": "^2.0.1", - "@azure/core-lro": "^2.2.0", - "@azure/core-paging": "^1.1.1", - "@azure/core-rest-pipeline": "^1.8.1", - "@azure/core-tracing": "^1.0.0", - "@azure/core-util": "^1.0.0", - "@azure/keyvault-common": "^2.0.0", - "@azure/logger": "^1.0.0", - "tslib": "^2.2.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/logger": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.1.4.tgz", - "integrity": "sha512-4IXXzcCdLdlXuCG+8UKEwLA1T1NHqUfanhXYHiQTn+6sfWCZXduqbtXDGceg3Ce5QxTGo7EqmbV6Bi+aqKuClQ==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/msal-browser": { - "version": "3.27.0", - "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-3.27.0.tgz", - "integrity": "sha512-+b4ZKSD8+vslCtVRVetkegEhOFMLP3rxDWJY212ct+2r6jVg6OSQKc1Qz3kCoXo0FgwaXkb+76TMZfpHp8QtgA==", - "dependencies": { - "@azure/msal-common": "14.16.0" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@azure/msal-common": { - "version": "14.16.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.16.0.tgz", - "integrity": "sha512-1KOZj9IpcDSwpNiQNjt0jDYZpQvNZay7QAEi/5DLubay40iGYtLzya/jbjRPLyOTZhEKyL1MzPuw2HqBCjceYA==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@azure/msal-node": { - "version": "2.16.2", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.2.tgz", - "integrity": "sha512-An7l1hEr0w1HMMh1LU+rtDtqL7/jw74ORlc9Wnh06v7TU/xpG39/Zdr1ZJu3QpjUfKJ+E0/OXMW8DRSWTlh7qQ==", - "dependencies": { - "@azure/msal-common": "14.16.0", - "jsonwebtoken": "^9.0.0", - "uuid": "^8.3.0" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/@azure/msal-node/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@babel/code-frame": { "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", @@ -4090,11 +3855,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@js-joda/core": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/@js-joda/core/-/core-5.6.3.tgz", - "integrity": "sha512-T1rRxzdqkEXcou0ZprN1q9yDRlvzCPLqmlNt5IIsGBzoEVgLCCYrKEwc84+TvsXuAc95VAZwtWD2zVsKPY4bcA==" - }, "node_modules/@lancedb/vectordb-darwin-arm64": { "version": "0.4.20", "resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.20.tgz", @@ -5054,11 +4814,6 @@ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==" }, - "node_modules/@tediousjs/connection-string": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@tediousjs/connection-string/-/connection-string-0.5.0.tgz", - "integrity": "sha512-7qSgZbincDDDFyRweCIEvZULFAw5iz/DeunhvuxpL31nfntX3P4Yd4HkHBRg9H8CdqY1e5WFN1PZIz/REL9MVQ==" - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -5330,20 +5085,6 @@ "node": ">=12" } }, - "node_modules/@types/readable-stream": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.18.tgz", - "integrity": "sha512-21jK/1j+Wg+7jVw1xnSwy/2Q1VgVjWuFssbYGTREPUBeZ+rqVFl2udq0IkxzPC0ZhOzVceUbyIACFZKLqKEBlA==", - "dependencies": { - "@types/node": "*", - "safe-buffer": "~5.1.1" - } - }, - "node_modules/@types/readable-stream/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, "node_modules/@types/request": { "version": "2.48.12", "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.12.tgz", @@ -6532,6 +6273,7 @@ "url": "https://feross.org/support" } ], + "optional": true, "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" @@ -7223,11 +6965,10 @@ } }, "node_modules/dbinfoz": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.14.0.tgz", - "integrity": "sha512-8NLjmj3gEyxbMu1ZwPEby77QvoEkk5NrHKSwX4oSKeaREherwuSx1y08cXmxBEjrSmvByUX9axoKscuilSXfmg==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.11.0.tgz", + "integrity": "sha512-l7REBd9pwTBI6PWSk/dx+zCpSE2tiJdSKfApeoOajnSgyMJgkwGfhpPO2mV76MLQeKPaSm0mMKxmoqd38SaHmw==", "dependencies": { - "mssql": "^11.0.1", "mysql2": "^3.9.1", "pg": "^8.11.3", "sqlite3": "^5.1.7" @@ -7320,14 +7061,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/define-lazy-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", - "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", - "engines": { - "node": ">=8" - } - }, "node_modules/define-properties": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", @@ -9640,20 +9373,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-electron": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/is-electron/-/is-electron-2.2.2.tgz", @@ -9858,17 +9577,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dependencies": { - "is-docker": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/isarray": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", @@ -10851,11 +10559,6 @@ "jinjajs": "cli.js" } }, - "node_modules/js-md4": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/js-md4/-/js-md4-0.3.2.tgz", - "integrity": "sha512-/GDnfQYsltsjRswQhN9fhv3EMw2sCpUdrdxyWDOUK7eyD++r3gRhzgiQgc/x4MAv2i1iuQ4lxO5mvqM3vj4bwA==" - }, "node_modules/js-tiktoken": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.12.tgz", @@ -11020,46 +10723,6 @@ "node": ">= 10.0.0" } }, - "node_modules/jsonwebtoken": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", - "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", - "dependencies": { - "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", - "ms": "^2.1.1", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=12", - "npm": ">=6" - } - }, - "node_modules/jsonwebtoken/node_modules/jwa": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", - "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", - "dependencies": { - "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/jsonwebtoken/node_modules/jws": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", - "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", - "dependencies": { - "jwa": "^1.4.1", - "safe-buffer": "^5.0.1" - } - }, "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -11225,36 +10888,6 @@ "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "dev": true }, - "node_modules/lodash.includes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" - }, - "node_modules/lodash.isboolean": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" - }, - "node_modules/lodash.isinteger": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" - }, - "node_modules/lodash.isnumber": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" - }, - "node_modules/lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" - }, - "node_modules/lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" - }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -11266,11 +10899,6 @@ "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, - "node_modules/lodash.once": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" - }, "node_modules/long": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", @@ -11660,33 +11288,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node_modules/mssql": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/mssql/-/mssql-11.0.1.tgz", - "integrity": "sha512-KlGNsugoT90enKlR8/G36H0kTxPthDhmtNUCwEHvgRza5Cjpjoj+P2X6eMpFUDN7pFrJZsKadL4x990G8RBE1w==", - "dependencies": { - "@tediousjs/connection-string": "^0.5.0", - "commander": "^11.0.0", - "debug": "^4.3.3", - "rfdc": "^1.3.0", - "tarn": "^3.0.2", - "tedious": "^18.2.1" - }, - "bin": { - "mssql": "bin/mssql" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/mssql/node_modules/commander": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", - "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", - "engines": { - "node": ">=16" - } - }, "node_modules/myers-diff": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/myers-diff/-/myers-diff-2.1.0.tgz", @@ -11739,11 +11340,6 @@ "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" }, - "node_modules/native-duplexpair": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/native-duplexpair/-/native-duplexpair-1.0.0.tgz", - "integrity": "sha512-E7QQoM+3jvNtlmyfqRZ0/U75VFgCls+fSkbml2MpgWkWyz3ox8Y58gNhfuziuQYGNNQAbFZJQck55LHCnCK6CA==" - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -12202,22 +11798,6 @@ "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, - "node_modules/open": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", - "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", - "dependencies": { - "define-lazy-prop": "^2.0.0", - "is-docker": "^2.1.1", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/openai": { "version": "4.47.1", "resolved": "https://registry.npmjs.org/openai/-/openai-4.47.1.tgz", @@ -12933,6 +12513,7 @@ "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "optional": true, "engines": { "node": ">= 0.6.0" } @@ -13294,6 +12875,7 @@ "version": "4.5.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "optional": true, "dependencies": { "abort-controller": "^3.0.0", "buffer": "^6.0.3", @@ -13566,11 +13148,6 @@ "node": ">=0.10.0" } }, - "node_modules/rfdc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", - "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==" - }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -14134,15 +13711,6 @@ "node": ">=8" } }, - "node_modules/stoppable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", - "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", - "engines": { - "node": ">=4", - "npm": ">=6" - } - }, "node_modules/stream-read-all": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/stream-read-all/-/stream-read-all-3.0.1.tgz", @@ -14515,45 +14083,6 @@ "node": ">=18" } }, - "node_modules/tarn": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.0.2.tgz", - "integrity": "sha512-51LAVKUSZSVfI05vjPESNc5vwqqZpbXCsU+/+wxlOrUjk2SnFTt97v9ZgQrD4YmxYW1Px6w2KjaDitCfkvgxMQ==", - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/tedious": { - "version": "18.6.1", - "resolved": "https://registry.npmjs.org/tedious/-/tedious-18.6.1.tgz", - "integrity": "sha512-9AvErXXQTd6l7TDd5EmM+nxbOGyhnmdbp/8c3pw+tjaiSXW9usME90ET/CRG1LN1Y9tPMtz/p83z4Q97B4DDpw==", - "dependencies": { - "@azure/core-auth": "^1.7.2", - "@azure/identity": "^4.2.1", - "@azure/keyvault-keys": "^4.4.0", - "@js-joda/core": "^5.6.1", - "@types/node": ">=18", - "bl": "^6.0.11", - "iconv-lite": "^0.6.3", - "js-md4": "^0.3.2", - "native-duplexpair": "^1.0.0", - "sprintf-js": "^1.1.3" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/tedious/node_modules/bl": { - "version": "6.0.16", - "resolved": "https://registry.npmjs.org/bl/-/bl-6.0.16.tgz", - "integrity": "sha512-V/kz+z2Mx5/6qDfRCilmrukUXcXuCoXKg3/3hDvzKKoSUx8CJKudfIoT29XZc3UE9xBvxs5qictiHdprwtteEg==", - "dependencies": { - "@types/readable-stream": "^4.0.0", - "buffer": "^6.0.3", - "inherits": "^2.0.4", - "readable-stream": "^4.2.0" - } - }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", diff --git a/core/package.json b/core/package.json index 91652280a..e95c66509 100644 --- a/core/package.json +++ b/core/package.json @@ -55,7 +55,7 @@ "cheerio": "^1.0.0-rc.12", "commander": "^12.0.0", "comment-json": "^4.2.3", - "dbinfoz": "^0.14.0", + "dbinfoz": "^0.11.0", "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8d680fb94..a57404715 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.233", + "version": "0.9.235", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.233", + "version": "0.9.235", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -18,7 +18,7 @@ "axios": "^1.2.5", "core": "file:../../core", "cors": "^2.8.5", - "dbinfoz": "^0.14.0", + "dbinfoz": "^0.11.0", "downshift": "^7.6.0", "esbuild": "^0.17.19", "express": "^4.18.2", @@ -109,7 +109,7 @@ "cheerio": "^1.0.0-rc.12", "commander": "^12.0.0", "comment-json": "^4.2.3", - "dbinfoz": "^0.14.0", + "dbinfoz": "^0.11.0", "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", @@ -246,6 +246,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, "dependencies": { "tslib": "^2.6.2" }, @@ -257,6 +258,7 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.9.0.tgz", "integrity": "sha512-FPwHpZywuyasDSLMqJ6fhbOK3TqUdviZNF8OqRGA4W5Ewib2lEEZ+pBsYcBa88B2NGO/SEnYPGhyBqNlE8ilSw==", + "dev": true, "dependencies": { "@azure/abort-controller": "^2.0.0", "@azure/core-util": "^1.11.0", @@ -270,6 +272,7 @@ "version": "1.9.2", "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.9.2.tgz", "integrity": "sha512-kRdry/rav3fUKHl/aDLd/pDLcB+4pOFwPPTVEExuMyaI5r+JBbMWqRbCY1pn5BniDaU3lRxO9eaQ1AmSMehl/w==", + "dev": true, "dependencies": { "@azure/abort-controller": "^2.0.0", "@azure/core-auth": "^1.4.0", @@ -283,48 +286,11 @@ "node": ">=18.0.0" } }, - "node_modules/@azure/core-http-compat": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-2.1.2.tgz", - "integrity": "sha512-5MnV1yqzZwgNLLjlizsU3QqOeQChkIXw781Fwh1xdAqJR5AA32IUaq6xv1BICJvfbHoa+JYcaij2HFkhLbNTJQ==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-client": "^1.3.0", - "@azure/core-rest-pipeline": "^1.3.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-lro": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.7.2.tgz", - "integrity": "sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-util": "^1.2.0", - "@azure/logger": "^1.0.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/core-paging": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.6.2.tgz", - "integrity": "sha512-YKWi9YuCU04B55h25cnOYZHxXYtEvQEbKST5vqRga7hWY9ydd3FZHdeQF8pyh+acWZvppw13M/LMGx0LABUVMA==", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/core-rest-pipeline": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.17.0.tgz", "integrity": "sha512-62Vv8nC+uPId3j86XJ0WI+sBf0jlqTqPUFCBNrGtlaUeQUIXWV/D8GE5A1d+Qx8H7OQojn2WguC8kChD6v0shA==", + "dev": true, "dependencies": { "@azure/abort-controller": "^2.0.0", "@azure/core-auth": "^1.8.0", @@ -343,6 +309,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.2.0.tgz", "integrity": "sha512-UKTiEJPkWcESPYJz3X5uKRYyOcJD+4nYph+KpfdPRnQJVrZfk0KJgdnaAWKfhsBBtAf/D58Az4AvCJEmWgIBAg==", + "dev": true, "dependencies": { "tslib": "^2.6.2" }, @@ -354,6 +321,7 @@ "version": "1.11.0", "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.11.0.tgz", "integrity": "sha512-DxOSLua+NdpWoSqULhjDyAZTXFdP/LKkqtYuxxz1SCN289zk3OG8UOpnCQAz/tygyACBtWp/BoO72ptK7msY8g==", + "dev": true, "dependencies": { "@azure/abort-controller": "^2.0.0", "tslib": "^2.6.2" @@ -366,6 +334,7 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.5.0.tgz", "integrity": "sha512-EknvVmtBuSIic47xkOqyNabAme0RYTw52BTMz8eBgU1ysTyMrD1uOoM+JdS0J/4Yfp98IBT3osqq3BfwSaNaGQ==", + "dev": true, "dependencies": { "@azure/abort-controller": "^2.0.0", "@azure/core-auth": "^1.9.0", @@ -386,50 +355,11 @@ "node": ">=18.0.0" } }, - "node_modules/@azure/keyvault-common": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@azure/keyvault-common/-/keyvault-common-2.0.0.tgz", - "integrity": "sha512-wRLVaroQtOqfg60cxkzUkGKrKMsCP6uYXAOomOIysSMyt1/YM0eUn9LqieAWM8DLcU4+07Fio2YGpPeqUbpP9w==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.3.0", - "@azure/core-client": "^1.5.0", - "@azure/core-rest-pipeline": "^1.8.0", - "@azure/core-tracing": "^1.0.0", - "@azure/core-util": "^1.10.0", - "@azure/logger": "^1.1.4", - "tslib": "^2.2.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@azure/keyvault-keys": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/@azure/keyvault-keys/-/keyvault-keys-4.9.0.tgz", - "integrity": "sha512-ZBP07+K4Pj3kS4TF4XdkqFcspWwBHry3vJSOFM5k5ZABvf7JfiMonvaFk2nBF6xjlEbMpz5PE1g45iTMme0raQ==", - "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.3.0", - "@azure/core-client": "^1.5.0", - "@azure/core-http-compat": "^2.0.1", - "@azure/core-lro": "^2.2.0", - "@azure/core-paging": "^1.1.1", - "@azure/core-rest-pipeline": "^1.8.1", - "@azure/core-tracing": "^1.0.0", - "@azure/core-util": "^1.0.0", - "@azure/keyvault-common": "^2.0.0", - "@azure/logger": "^1.0.0", - "tslib": "^2.2.0" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@azure/logger": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.1.4.tgz", "integrity": "sha512-4IXXzcCdLdlXuCG+8UKEwLA1T1NHqUfanhXYHiQTn+6sfWCZXduqbtXDGceg3Ce5QxTGo7EqmbV6Bi+aqKuClQ==", + "dev": true, "dependencies": { "tslib": "^2.6.2" }, @@ -441,6 +371,7 @@ "version": "3.27.0", "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-3.27.0.tgz", "integrity": "sha512-+b4ZKSD8+vslCtVRVetkegEhOFMLP3rxDWJY212ct+2r6jVg6OSQKc1Qz3kCoXo0FgwaXkb+76TMZfpHp8QtgA==", + "dev": true, "dependencies": { "@azure/msal-common": "14.16.0" }, @@ -452,6 +383,7 @@ "version": "14.16.0", "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.16.0.tgz", "integrity": "sha512-1KOZj9IpcDSwpNiQNjt0jDYZpQvNZay7QAEi/5DLubay40iGYtLzya/jbjRPLyOTZhEKyL1MzPuw2HqBCjceYA==", + "dev": true, "engines": { "node": ">=0.8.0" } @@ -460,6 +392,7 @@ "version": "2.16.0", "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.0.tgz", "integrity": "sha512-oww0oJTOOvPKTVXqVyxfcFVjExQKYEkKR5KM0cTG3jnzt6u/MRMx8XaK49L/bxV35r9sCHQFjNlEShad9qGSYA==", + "dev": true, "dependencies": { "@azure/msal-common": "14.16.0", "jsonwebtoken": "^9.0.0", @@ -473,6 +406,7 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, "bin": { "uuid": "dist/bin/uuid" } @@ -1270,11 +1204,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@js-joda/core": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/@js-joda/core/-/core-5.6.3.tgz", - "integrity": "sha512-T1rRxzdqkEXcou0ZprN1q9yDRlvzCPLqmlNt5IIsGBzoEVgLCCYrKEwc84+TvsXuAc95VAZwtWD2zVsKPY4bcA==" - }, "node_modules/@jsdevtools/ono": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", @@ -1836,11 +1765,6 @@ "node": ">=10" } }, - "node_modules/@tediousjs/connection-string": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@tediousjs/connection-string/-/connection-string-0.5.0.tgz", - "integrity": "sha512-7qSgZbincDDDFyRweCIEvZULFAw5iz/DeunhvuxpL31nfntX3P4Yd4HkHBRg9H8CdqY1e5WFN1PZIz/REL9MVQ==" - }, "node_modules/@tootallnate/once": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", @@ -2111,20 +2035,6 @@ "@types/react": "*" } }, - "node_modules/@types/readable-stream": { - "version": "4.0.18", - "resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-4.0.18.tgz", - "integrity": "sha512-21jK/1j+Wg+7jVw1xnSwy/2Q1VgVjWuFssbYGTREPUBeZ+rqVFl2udq0IkxzPC0ZhOzVceUbyIACFZKLqKEBlA==", - "dependencies": { - "@types/node": "*", - "safe-buffer": "~5.1.1" - } - }, - "node_modules/@types/readable-stream/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, "node_modules/@types/request": { "version": "2.48.12", "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.12.tgz", @@ -2841,17 +2751,6 @@ "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -3400,7 +3299,8 @@ "node_modules/buffer-equal-constant-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "dev": true }, "node_modules/bytes": { "version": "3.1.2", @@ -4315,11 +4215,10 @@ } }, "node_modules/dbinfoz": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.14.0.tgz", - "integrity": "sha512-8NLjmj3gEyxbMu1ZwPEby77QvoEkk5NrHKSwX4oSKeaREherwuSx1y08cXmxBEjrSmvByUX9axoKscuilSXfmg==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.11.0.tgz", + "integrity": "sha512-l7REBd9pwTBI6PWSk/dx+zCpSE2tiJdSKfApeoOajnSgyMJgkwGfhpPO2mV76MLQeKPaSm0mMKxmoqd38SaHmw==", "dependencies": { - "mssql": "^11.0.1", "mysql2": "^3.9.1", "pg": "^8.11.3", "sqlite3": "^5.1.7" @@ -4448,6 +4347,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, "engines": { "node": ">=8" } @@ -4665,6 +4565,7 @@ "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dev": true, "dependencies": { "safe-buffer": "^5.0.1" } @@ -5194,14 +5095,6 @@ "es5-ext": "~0.10.14" } }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "engines": { - "node": ">=6" - } - }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", @@ -5211,6 +5104,7 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, "engines": { "node": ">=0.8.x" } @@ -6638,6 +6532,7 @@ "version": "2.2.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, "bin": { "is-docker": "cli.js" }, @@ -6763,6 +6658,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, "dependencies": { "is-docker": "^2.0.0" }, @@ -6816,11 +6712,6 @@ "jiti": "bin/jiti.js" } }, - "node_modules/js-md4": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/js-md4/-/js-md4-0.3.2.tgz", - "integrity": "sha512-/GDnfQYsltsjRswQhN9fhv3EMw2sCpUdrdxyWDOUK7eyD++r3gRhzgiQgc/x4MAv2i1iuQ4lxO5mvqM3vj4bwA==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -7016,6 +6907,7 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "dev": true, "dependencies": { "jws": "^3.2.2", "lodash.includes": "^4.3.0", @@ -7037,6 +6929,7 @@ "version": "1.4.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "dev": true, "dependencies": { "buffer-equal-constant-time": "1.0.1", "ecdsa-sig-formatter": "1.0.11", @@ -7047,6 +6940,7 @@ "version": "3.2.2", "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "dev": true, "dependencies": { "jwa": "^1.4.1", "safe-buffer": "^5.0.1" @@ -7081,6 +6975,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", "integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==", + "dev": true, "dependencies": { "buffer-equal-constant-time": "1.0.1", "ecdsa-sig-formatter": "1.0.11", @@ -7091,6 +6986,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", + "dev": true, "dependencies": { "jwa": "^2.0.0", "safe-buffer": "^5.0.1" @@ -7204,32 +7100,38 @@ "node_modules/lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "dev": true }, "node_modules/lodash.isboolean": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "dev": true }, "node_modules/lodash.isinteger": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "dev": true }, "node_modules/lodash.isnumber": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "dev": true }, "node_modules/lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true }, "node_modules/lodash.isstring": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "dev": true }, "node_modules/lodash.merge": { "version": "4.6.2", @@ -7240,7 +7142,8 @@ "node_modules/lodash.once": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "dev": true }, "node_modules/log-symbols": { "version": "4.1.0", @@ -8344,33 +8247,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, - "node_modules/mssql": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/mssql/-/mssql-11.0.1.tgz", - "integrity": "sha512-KlGNsugoT90enKlR8/G36H0kTxPthDhmtNUCwEHvgRza5Cjpjoj+P2X6eMpFUDN7pFrJZsKadL4x990G8RBE1w==", - "dependencies": { - "@tediousjs/connection-string": "^0.5.0", - "commander": "^11.0.0", - "debug": "^4.3.3", - "rfdc": "^1.3.0", - "tarn": "^3.0.2", - "tedious": "^18.2.1" - }, - "bin": { - "mssql": "bin/mssql" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/mssql/node_modules/commander": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", - "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", - "engines": { - "node": ">=16" - } - }, "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -8447,11 +8323,6 @@ "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" }, - "node_modules/native-duplexpair": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/native-duplexpair/-/native-duplexpair-1.0.0.tgz", - "integrity": "sha512-E7QQoM+3jvNtlmyfqRZ0/U75VFgCls+fSkbml2MpgWkWyz3ox8Y58gNhfuziuQYGNNQAbFZJQck55LHCnCK6CA==" - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -8979,6 +8850,7 @@ "version": "8.4.2", "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, "dependencies": { "define-lazy-prop": "^2.0.0", "is-docker": "^2.1.1", @@ -9770,14 +9642,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/process-exists": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/process-exists/-/process-exists-4.1.0.tgz", @@ -10456,11 +10320,6 @@ "node": ">=0.10.0" } }, - "node_modules/rfdc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", - "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==" - }, "node_modules/rimraf": { "version": "5.0.10", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz", @@ -11127,6 +10986,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", + "dev": true, "engines": { "node": ">=4", "npm": ">=6" @@ -11564,14 +11424,6 @@ "node": ">=8" } }, - "node_modules/tarn": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/tarn/-/tarn-3.0.2.tgz", - "integrity": "sha512-51LAVKUSZSVfI05vjPESNc5vwqqZpbXCsU+/+wxlOrUjk2SnFTt97v9ZgQrD4YmxYW1Px6w2KjaDitCfkvgxMQ==", - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/taskkill": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/taskkill/-/taskkill-4.0.0.tgz", @@ -11587,91 +11439,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/tedious": { - "version": "18.6.1", - "resolved": "https://registry.npmjs.org/tedious/-/tedious-18.6.1.tgz", - "integrity": "sha512-9AvErXXQTd6l7TDd5EmM+nxbOGyhnmdbp/8c3pw+tjaiSXW9usME90ET/CRG1LN1Y9tPMtz/p83z4Q97B4DDpw==", - "dependencies": { - "@azure/core-auth": "^1.7.2", - "@azure/identity": "^4.2.1", - "@azure/keyvault-keys": "^4.4.0", - "@js-joda/core": "^5.6.1", - "@types/node": ">=18", - "bl": "^6.0.11", - "iconv-lite": "^0.6.3", - "js-md4": "^0.3.2", - "native-duplexpair": "^1.0.0", - "sprintf-js": "^1.1.3" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/tedious/node_modules/@types/node": { - "version": "22.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", - "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", - "dependencies": { - "undici-types": "~6.19.8" - } - }, - "node_modules/tedious/node_modules/bl": { - "version": "6.0.16", - "resolved": "https://registry.npmjs.org/bl/-/bl-6.0.16.tgz", - "integrity": "sha512-V/kz+z2Mx5/6qDfRCilmrukUXcXuCoXKg3/3hDvzKKoSUx8CJKudfIoT29XZc3UE9xBvxs5qictiHdprwtteEg==", - "dependencies": { - "@types/readable-stream": "^4.0.0", - "buffer": "^6.0.3", - "inherits": "^2.0.4", - "readable-stream": "^4.2.0" - } - }, - "node_modules/tedious/node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/tedious/node_modules/readable-stream": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", - "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/tedious/node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -11979,11 +11746,6 @@ "node": ">=18.17" } }, - "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" - }, "node_modules/unified": { "version": "10.1.2", "resolved": "https://registry.npmjs.org/unified/-/unified-10.1.2.tgz", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 6cee57b23..355f8ab92 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.234", + "version": "0.9.235", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -651,7 +651,7 @@ "axios": "^1.2.5", "core": "file:../../core", "cors": "^2.8.5", - "dbinfoz": "^0.14.0", + "dbinfoz": "^0.11.0", "downshift": "^7.6.0", "esbuild": "^0.17.19", "express": "^4.18.2", diff --git a/gui/package-lock.json b/gui/package-lock.json index 1a9e4fe3f..7d5bf06c9 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -111,7 +111,7 @@ "cheerio": "^1.0.0-rc.12", "commander": "^12.0.0", "comment-json": "^4.2.3", - "dbinfoz": "^0.14.0", + "dbinfoz": "^0.11.0", "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", From 521b9b3d453c27271416f735d14dd3664df0b92f Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Mon, 25 Nov 2024 16:13:04 -0800 Subject: [PATCH 12/14] improv: better filtering, add tests --- .../StreamTransformPipeline.ts | 3 +- .../filtering/streamTransforms/lineStream.ts | 55 +++---- .../stopNCharsAfterClosingBracket.test.ts | 143 ------------------ core/autocomplete/filtering/test/testCases.ts | 109 ++++++++----- core/autocomplete/filtering/test/util.ts | 4 +- core/indexing/docs/DocsService.ts | 1 + 6 files changed, 98 insertions(+), 217 deletions(-) delete mode 100644 core/autocomplete/filtering/streamTransforms/stopNCharsAfterClosingBracket.test.ts diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index cedaaedfa..da178cb66 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -6,6 +6,7 @@ import { stopAtStartOf, stopAtStopTokens } from "./charStream"; import { avoidEmptyComments, avoidPathLine, + noDoubleNewlineAfterClosingBracket, showWhateverWeHaveAtXMs, skipPrefixes, stopAtLines, @@ -48,7 +49,7 @@ export class StreamTransformPipeline { ); lineGenerator = avoidPathLine(lineGenerator, helper.lang.singleLineComment); lineGenerator = skipPrefixes(lineGenerator); - // lineGenerator = stopNCharsAfterClosingBracket(lineGenerator); + lineGenerator = noDoubleNewlineAfterClosingBracket(lineGenerator); for (const lineFilter of helper.lang.lineFilters ?? []) { lineGenerator = lineFilter({ lines: lineGenerator, fullStop }); diff --git a/core/autocomplete/filtering/streamTransforms/lineStream.ts b/core/autocomplete/filtering/streamTransforms/lineStream.ts index 02408afa1..9cbf190ec 100644 --- a/core/autocomplete/filtering/streamTransforms/lineStream.ts +++ b/core/autocomplete/filtering/streamTransforms/lineStream.ts @@ -83,7 +83,7 @@ export const LINES_TO_REMOVE_BEFORE_START = [ "", "[CODE]", "", - "{{FILL_HERE}}" + "{{FILL_HERE}}", ]; export const ENGLISH_START_PHRASES = [ @@ -548,21 +548,32 @@ export async function* showWhateverWeHaveAtXMs( } } -export async function* stopNCharsAfterClosingBracket( +export async function* noDoubleNewlineAfterClosingBracket( lines: LineStream, - n: number = 20, ): LineStream { const bracketTypeCounts = new Map(); - let charsToStopAt: number | null = null; for await (const line of lines) { - let outputLine = ""; - let i = 0; + if (line.trim() === "") { + // Double newline detected + // Check if any bracket counts are negative + let hasNegativeCount = false; + for (const count of bracketTypeCounts.values()) { + if (count < 0) { + hasNegativeCount = true; + break; + } + } + if (hasNegativeCount) { + // Stop the generator if we've closed brackets we didn't open + return; + } + } - while (i < line.length) { - const char = line[i]; + yield line; - // Update bracket counts + // Update bracket counts + for (const char of line) { if (BRACKETS[char]) { // It's an opening bracket const count = bracketTypeCounts.get(char) || 0; @@ -571,32 +582,8 @@ export async function* stopNCharsAfterClosingBracket( // It's a closing bracket const openingBracket = BRACKETS_REVERSE[char]; const count = bracketTypeCounts.get(openingBracket) || 0; - const newCount = count - 1; - bracketTypeCounts.set(openingBracket, newCount); - - if (newCount < 0 && charsToStopAt === null) { - // Unmatched closing bracket detected - charsToStopAt = n; - } + bracketTypeCounts.set(openingBracket, count - 1); } - - // Add the character to the output line - outputLine += char; - - // If we've started counting down, decrement the remaining characters - if (charsToStopAt !== null) { - charsToStopAt -= 1; - if (charsToStopAt <= 0) { - // Yield the output line up to this point and stop the generator - yield outputLine; - return; - } - } - - i += 1; } - - // Yield whatever we've accumulated for this line - yield outputLine; } } diff --git a/core/autocomplete/filtering/streamTransforms/stopNCharsAfterClosingBracket.test.ts b/core/autocomplete/filtering/streamTransforms/stopNCharsAfterClosingBracket.test.ts deleted file mode 100644 index e5e003f80..000000000 --- a/core/autocomplete/filtering/streamTransforms/stopNCharsAfterClosingBracket.test.ts +++ /dev/null @@ -1,143 +0,0 @@ -import { stopNCharsAfterClosingBracket } from "./lineStream"; - -describe("noDoubleNewlineAfterClosingBracket", () => { - // Helper function to convert an array to an async generator - async function* arrayToAsyncGenerator(array: T[]): AsyncGenerator { - for (const item of array) { - yield item; - } - } - - // Helper function to collect lines from the async generator - async function collectLines(lines: AsyncIterable): Promise { - const result: string[] = []; - for await (const line of lines) { - result.push(line); - } - return result; - } - - test("should yield all lines when no unmatched brackets", async () => { - const inputLines = [ - "function test() {", - ' console.log("Hello World");', - "}", - ]; - const lines = arrayToAsyncGenerator(inputLines); - const outputLines = await collectLines( - stopNCharsAfterClosingBracket(lines), - ); - - expect(outputLines).toEqual(inputLines); - }); - - test("should yield all lines when >20 chars after brackets but brackets are matched", async () => { - const inputLines = [ - "function test() {", - ' console.log("Hello World");', - "}", - "// End of function and start of something else", - ]; - const lines = arrayToAsyncGenerator(inputLines); - const outputLines = await collectLines( - stopNCharsAfterClosingBracket(lines), - ); - - expect(outputLines).toEqual(inputLines); - }); - - test("should stop yielding after 20 chars when unmatched closing bracket is found", async () => { - const inputLines = [ - // "function test() {", - ' console.log("Hello World");', - // Unmatched closing bracket - "}", - "1234567890123456789", - 'console.log("End");', - ]; - const expectedOutputLines = [ - ' console.log("Hello World");', - "}", - "1234567890123456789", - ]; - const lines = arrayToAsyncGenerator(inputLines); - const outputLines = await collectLines( - stopNCharsAfterClosingBracket(lines), - ); - - expect(outputLines).toEqual(expectedOutputLines); - }); - - test("should stop yielding after 2 chars when unmatched closing bracket is found", async () => { - const inputLines = [ - // "function test() {", - ' console.log("Hello World");', - // Unmatched closing bracket - "}", - "12", - 'console.log("End");', - ]; - const expectedOutputLines = [' console.log("Hello World");', "}", "1"]; - const lines = arrayToAsyncGenerator(inputLines); - const outputLines = await collectLines( - stopNCharsAfterClosingBracket(lines, 2), - ); - - expect(outputLines).toEqual(expectedOutputLines); - }); - - test("should stop yielding after 4 chars when unmatched closing bracket is found, on same line", async () => { - const inputLines = [ - // "function test() {", - ' console.log("Hello World");', - // Unmatched closing bracket - "}23456", - ]; - const expectedOutputLines = [' console.log("Hello World");', "}234"]; - const lines = arrayToAsyncGenerator(inputLines); - const outputLines = await collectLines( - stopNCharsAfterClosingBracket(lines, 4), - ); - - expect(outputLines).toEqual(expectedOutputLines); - }); - - test("should yield all lines when unmatched brackets but less <20 chars after", async () => { - const inputLines = [ - "function test() {", - ' console.log("Hello World");', - "}", - // Unmatched closing bracket - ")", - "// Continue code", - ]; - const lines = arrayToAsyncGenerator(inputLines); - const outputLines = await collectLines( - stopNCharsAfterClosingBracket(lines), - ); - - expect(outputLines).toEqual(inputLines); - }); - - test("should yield all lines when brackets are matched even with many characters", async () => { - const inputLines = [ - "const arr = [", - " 1, 2, 3,", - "];", - "", - "", - "console.log(arr);", - "console.log(arr);", - "console.log(arr);", - "console.log(arr);", - "console.log(arr);", - "console.log(arr);", - ]; - const lines = arrayToAsyncGenerator(inputLines); - const outputLines = await collectLines( - stopNCharsAfterClosingBracket(lines), - ); - - expect(outputLines).toEqual(inputLines); - }); -}); diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index 2fecabff6..bde2afc08 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -131,10 +131,6 @@ public class Calculator { } `, expectedCompletion: ` - } - - public void subtract(double number) { - result -= number; }`, }, { @@ -184,7 +180,7 @@ public class Calculator { // Add the multiply method multiply(number) { `, - expectedCompletion: null, + expectedCompletion: undefined, }, { description: "Should enforce bracket matching in JSON files", @@ -197,7 +193,7 @@ public class Calculator { "state": "California", "city": "San BERNARDINO", "coordinates": { - + <|fim|> } }, "employees": [ @@ -246,8 +242,76 @@ public class Calculator { "required": ["JavaScript", "React", "Node.js", "Leadership", "Project Management"], "optional": ["Photoshop", "Illustrator"]`, expectedCompletion: `"latitude": 34.10834, - "longitude": -117.28977 + "longitude": -117.28977`, + }, + { + description: + "Should return nothing when output is duplicated lines in TypeScript", + filename: "file.ts", + input: ` +async getContextForPath( + filepath: string, + astPath: AstPatt, + language: LanguageName, + options: ContextOptions = {}, +<|fim|> + ): Promise { + const snippets: AutocompleteCodeSnippet[] = []; + let parentKey = filepath; +`, + llmOutput: ` ): Promise { + const snippets: AutocompleteCodeSnippet[] = []; `, + expectedCompletion: undefined, + }, + { + description: + "Should return partial result when output is duplicated lines in TypeScript", + filename: "file.ts", + input: ` +async getContextForPath( + filepath: string, + astPath: AstPatt, + language: LanguageName, + options: ContextOptions = {}, +<|fim|> + ): Promise { + const snippets: AutocompleteCodeSnippet[] = []; + let parentKey = filepath; +`, + llmOutput: `console.log('TEST'); + ): Promise { + const snippets: AutocompleteCodeSnippet[] = []; + `, + expectedCompletion: `console.log('TEST'); + `, + }, + { + description: "Should autocomplete React effect hook", + input: `import React, { useState, useEffect } from "react"; + +export const Timer = () => { + const [seconds, setSeconds] = useState(0); + + useEffect(() => { + const interval = setInterval(() => { + setSeconds(seconds + 1); + }, 1000); + + <|fim|>; + + return () => clearInterval(interval); + }, [seconds]); + + return ( +
+

{seconds} seconds have passed.

+
+ ); +};`, + llmOutput: "return () => clearInterval(interval);", + expectedCompletion: undefined, + filename: "Timer.tsx", }, ]; @@ -546,35 +610,6 @@ export const Counter = () => { expectedCompletion: "0", filename: "Counter.tsx", }, - - { - description: "Should autocomplete React effect hook", - input: `import React, { useState, useEffect } from "react"; - -export const Timer = () => { - const [seconds, setSeconds] = useState(0); - - useEffect(() => { - const interval = setInterval(() => { - setSeconds(seconds + 1); - }, 1000); - - <|fim|>; - - return () => clearInterval(interval); - }, [seconds]); - - return ( -
-

{seconds} seconds have passed.

-
- ); -};`, - llmOutput: "return () => clearInterval(interval);", - expectedCompletion: null, - filename: "Timer.tsx", - }, - { description: "Should autocomplete React component methods", input: `import React from "react"; @@ -762,7 +797,7 @@ func main() { CREATE TABLE products ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), - price DECIMAL(8,2) NOT NULL '0.00', + price DECIMAL(8,2) NOT NULL<|fim|> '0.00', quantity INT NOT NULL DEFAULT '0' ); diff --git a/core/autocomplete/filtering/test/util.ts b/core/autocomplete/filtering/test/util.ts index 8107a5235..8c8b8a9a2 100644 --- a/core/autocomplete/filtering/test/util.ts +++ b/core/autocomplete/filtering/test/util.ts @@ -18,7 +18,7 @@ export interface AutocompleteFileringTestInput { filename: string; input: string; llmOutput: string; - expectedCompletion: string | null; + expectedCompletion: string | null | undefined; options?: { only?: boolean; }; @@ -72,5 +72,5 @@ export async function testAutocompleteFiltering( ); // Ensure that we return the text that is wanted to be displayed - expect(result?.completion ?? null).toEqual(test.expectedCompletion); + expect(result?.completion).toEqual(test.expectedCompletion); } diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 838e8fb54..eb639eea5 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -70,6 +70,7 @@ export type AddParams = { favicon?: string; }; + /* General process: - On config update: From fa0422ae611fbc180048929cf989ac4af41ef76b Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Mon, 25 Nov 2024 16:22:34 -0800 Subject: [PATCH 13/14] improv: remove redundant workflow --- .github/workflows/ts-check.yaml | 100 -------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 .github/workflows/ts-check.yaml diff --git a/.github/workflows/ts-check.yaml b/.github/workflows/ts-check.yaml deleted file mode 100644 index 5f16c406c..000000000 --- a/.github/workflows/ts-check.yaml +++ /dev/null @@ -1,100 +0,0 @@ -name: TypeScript Check - -on: - pull_request: - branches: - - main - -jobs: - tsc-check: - runs-on: ubuntu-latest - - steps: - # 1. Check-out repository - - name: Check-out repository - uses: actions/checkout@v4 - - # 2. Install npm dependencies - - name: Use Node.js from .nvmrc - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - - name: Cache root node_modules - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - - - name: Cache extension node_modules - uses: actions/cache@v3 - with: - path: extensions/vscode/node_modules - key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }} - - - name: Cache core node_modules - uses: actions/cache@v3 - with: - path: core/node_modules - key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }} - - - name: Cache gui node_modules - uses: actions/cache@v3 - with: - path: gui/node_modules - key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} - - - name: Cache binary node_modules - uses: actions/cache@v3 - with: - path: binary/node_modules - key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }} - - - name: Install Root Dependencies - run: | - npm ci - - - name: Install extension Dependencies - run: | - cd extensions/vscode - npm ci - env: - # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333 - GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} - - - name: Install gui Dependencies - run: | - cd gui - npm ci - - - name: Install Core Dependencies - run: | - cd core - npm ci - - - name: Install Binary Dependencies - run: | - cd binary - npm ci - - - name: tsc core - run: | - cd core - npx tsc --noEmit - npm run lint - - - name: tsc extensions/vscode - run: | - cd extensions/vscode - npx tsc --noEmit - npm run lint - - - name: tsc binary - run: | - cd binary - npx tsc --noEmit - - - name: tsc gui - run: | - cd gui - npx tsc --noEmit From 75dce9cbd14cc374d1ce4921522f3423202be7b1 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Mon, 25 Nov 2024 16:50:01 -0800 Subject: [PATCH 14/14] fix: qwen completions missing whitespaces --- core/autocomplete/postprocessing/index.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core/autocomplete/postprocessing/index.ts b/core/autocomplete/postprocessing/index.ts index 3d97df9ca..1eb3b37da 100644 --- a/core/autocomplete/postprocessing/index.ts +++ b/core/autocomplete/postprocessing/index.ts @@ -120,10 +120,5 @@ export function postprocessCompletion({ completion = completion.slice(1); } - // Qwen often adds an extra space to the start - if (llm.model.toLowerCase().includes("qwen") && completion.startsWith(" ")) { - completion = completion.slice(1); - } - return completion; }