From cb071a74194f656a462f53ed503ba725c31958e3 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 21 Nov 2024 00:42:09 -0800 Subject: [PATCH 01/73] package file parsers --- core/core.ts | 4 + core/indexing/docs/suggestions/index.ts | 100 +++++++++++++++++ .../suggestions/packageCrawlers/Python.ts | 33 ++++++ .../docs/suggestions/packageCrawlers/TsJs.ts | 33 ++++++ core/protocol/core.ts | 1 + core/protocol/passThrough.ts | 1 + extensions/vscode/package-lock.json | 4 +- gui/src/hooks/useSetup.ts | 3 +- manual-testing-sandbox/package.json | 102 ++++++++++++++++++ manual-testing-sandbox/requirements.txt | 10 ++ 10 files changed, 287 insertions(+), 4 deletions(-) create mode 100644 core/indexing/docs/suggestions/index.ts create mode 100644 core/indexing/docs/suggestions/packageCrawlers/Python.ts create mode 100644 core/indexing/docs/suggestions/packageCrawlers/TsJs.ts create mode 100644 manual-testing-sandbox/package.json create mode 100644 manual-testing-sandbox/requirements.txt diff --git a/core/core.ts b/core/core.ts index c6b336c7d..d080ec34b 100644 --- a/core/core.ts +++ b/core/core.ts @@ -40,6 +40,7 @@ import { TTS } from "./util/tts"; import type { ContextItemId, IDE, IndexingProgressUpdate } from "."; import type { FromCoreProtocol, ToCoreProtocol } from "./protocol"; import type { IMessenger, Message } from "./util/messenger"; +import { getAllSuggestedDocs } from "./indexing/docs/suggestions"; export class Core { // implements IMessenger @@ -737,6 +738,9 @@ export class Core { on("indexing/initStatuses", async (msg) => { return this.docsService.initStatuses(); }); + on("docs/getSuggestedDocs", async (msg) => { + getAllSuggestedDocs(this.ide); + }); // on("didChangeSelectedProfile", (msg) => { diff --git a/core/indexing/docs/suggestions/index.ts b/core/indexing/docs/suggestions/index.ts new file mode 100644 index 000000000..d3d68aca2 --- /dev/null +++ b/core/indexing/docs/suggestions/index.ts @@ -0,0 +1,100 @@ +// write me an interface PackageCrawler that contains: +// 1. property `language` to store a given language like "python" or "typescript" +// 2. has a method `getPackageFiles` which takes a list of file names and decides which ones match package/dependency files (e.g. package.json for typescript, requirements.txt for python, etc) +// 3. has a method `parsePackageFile` which returns a list of package name and version from a relevant package file, in a standardized format like semver +// 4. has a method `getDocumentationLink` to check for documentation link for a given package (e.g. GET `https://registry.npmjs.org/` and find docs field for typescript, documentation link in the package metadata for PyPi, etc.) +// Then, write typescript classes to implement this typescript interface for the languages "python" and "typescript" + +import { IDE } from "../../.."; +import { walkDir } from "../../walkDir"; +import { PythonPackageCrawler } from "./packageCrawlers/Python"; +import { TypeScriptPackageCrawler } from "./packageCrawlers/TsJs"; + +const PACKAGE_CRAWLERS = [TypeScriptPackageCrawler, PythonPackageCrawler]; + +export interface PackageCrawler { + language: string; + getPackageFiles(fileNames: string[]): string[]; + parsePackageFile(fileContent: string, filePath: string): PackageInfo[]; + getDocumentationLink(packageName: string): Promise; +} + +export type PackageInfo = { + name: string; + version: string; + foundInFilepath: string; +}; +export type PackageDocsResult = PackageInfo & + ({ error: string; link?: never } | { link: string; error?: never }); + +export async function getAllSuggestedDocs(ide: IDE) { + const workspaceDirs = await ide.getWorkspaceDirs(); + const results = await Promise.all( + workspaceDirs.map((dir) => { + return walkDir(dir, ide); + }), + ); + const allPaths = results.flat(); // TODO only get files, not dirs. Not critical for now + const allFiles = allPaths.map((path) => path.split("/").pop()!); + const packageFilesByLanguage: Record = {}; + for (const Crawler of PACKAGE_CRAWLERS) { + const crawler = new Crawler(); + const packageFilePaths = crawler.getPackageFiles(allFiles); + packageFilesByLanguage[crawler.language] = packageFilePaths; + } + + const uniqueFilePaths = Array.from( + new Set(Object.values(packageFilesByLanguage).flat()), + ); + const fileContentsArray = await Promise.all( + uniqueFilePaths.map(async (path) => { + const contents = await ide.readFile(path); + return { path, contents }; + }), + ); + const fileContents = new Map( + fileContentsArray.map(({ path, contents }) => [path, contents]), + ); + + const packagesByLanguage: Record = {}; + PACKAGE_CRAWLERS.forEach((Crawler) => { + const crawler = new Crawler(); + const packageFiles = packageFilesByLanguage[crawler.language]; + packageFiles.forEach((file) => { + const contents = fileContents.get(file); + if (!contents) { + return; + } + const packages = crawler.parsePackageFile(contents, file); + if (!packagesByLanguage[crawler.language]) { + packagesByLanguage[crawler.language] = []; + } + packagesByLanguage[crawler.language].push(...packages); + }); + }); + console.log(packagesByLanguage); + // const allPackages = await Promise.all( + // PACKAGE_CRAWLERS.map(async (Crawler) => { + // const crawler = new Crawler(); + // const packageInfos = uniqueFileContents + // .filter(({ path }) => languageToFilePaths[crawler.language].includes(path)) + // .map(({ path, contents }) => crawler.parsePackageFile(contents, path)) + // .flat(); + // return packageInfos; + // }) + // ); + // for (const Crawler of PACKAGE_CRAWLERS) { + // const crawler = new Crawler(); + // const packages = crawler.parsePackageFile() + // languageToFilePaths[crawler.language] = packageFilePaths; + // } +} + +// I want to present the user with a list of dependencies and allow them to select which ones to index (embed) documentation for. +// In order to prevent duplicate file reads, the process will be like this: +// 1. take in a list of filepaths called `filepaths` +// 2. loop an array of PackageCrawler classes to build a map of `language` (string) to `packageFilePaths` (string[]) +// 3. Get unique filepaths from `packageFilePaths` and build a map ` of filepath to file contents using an existing `readFile` function, and skipping file reads of already in the map +// Finally, +// Add a `` method to the interface and classes that returns +// Then, assemble the classes in an array, and write a function getAllSuggestedDocs that returns a map of `language` to an ar diff --git a/core/indexing/docs/suggestions/packageCrawlers/Python.ts b/core/indexing/docs/suggestions/packageCrawlers/Python.ts new file mode 100644 index 000000000..ac0699766 --- /dev/null +++ b/core/indexing/docs/suggestions/packageCrawlers/Python.ts @@ -0,0 +1,33 @@ +import { PackageCrawler, PackageDocsResult, PackageInfo } from ".."; + +export class PythonPackageCrawler implements PackageCrawler { + language = "python"; + + getPackageFiles(fileNames: string[]): string[] { + // For Python, we typically look for files like requirements.txt or Pipfile + return fileNames.filter( + (fileName) => fileName === "requirements.txt" || fileName === "Pipfile", + ); + } + + parsePackageFile(fileContent: string, filepath: string): PackageInfo[] { + // Assume the fileContent is a string from a requirements.txt formatted file + return fileContent + .split("\n") + .map((line) => { + const [name, version] = line.split("=="); + return { name, version, foundInFilepath: filepath }; + }) + .filter((pkg) => pkg.name && pkg.version); + } + + async getDocumentationLink(packageName: string): Promise { + // Fetch metadata from PyPI to find the documentation link + const response = await fetch(`https://pypi.org/pypi/${packageName}/json`); + if (!response.ok) { + throw new Error(`Could not fetch data for package ${packageName}`); + } + const data = await response.json(); + return data.info.project_urls?.Documentation; + } +} diff --git a/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts new file mode 100644 index 000000000..fb073e2a1 --- /dev/null +++ b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts @@ -0,0 +1,33 @@ +import { PackageCrawler, PackageDocsResult, PackageInfo } from ".."; + +export class TypeScriptPackageCrawler implements PackageCrawler { + language = "typescript"; + + getPackageFiles(fileNames: string[]): string[] { + // For TypeScript, we look for package.json file + return fileNames.filter((fileName) => fileName === "package.json"); + } + + parsePackageFile(fileContent: string, filepath: string): PackageInfo[] { + // Parse the package.json content + const jsonData = JSON.parse(fileContent) as Record; + const dependencies = Object.entries(jsonData.dependencies || {}).concat( + Object.entries(jsonData.devDependencies || {}), + ); + return dependencies.map(([name, version]) => ({ + name, + version, + foundInFilepath: filepath, + })); + } + + async getDocumentationLink(packageName: string): Promise { + // Fetch metadata from the NPM registry to find the documentation link + const response = await fetch(`https://registry.npmjs.org/${packageName}`); + if (!response.ok) { + throw new Error(`Could not fetch data for package ${packageName}`); + } + const data = await response.json(); + return data.homepage; + } +} diff --git a/core/protocol/core.ts b/core/protocol/core.ts index c757e5d34..069f9e297 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -167,6 +167,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "indexing/abort": [{ type: string; id: string }, void]; "indexing/setPaused": [{ type: string; id: string; paused: boolean }, void]; "indexing/initStatuses": [undefined, void]; + "docs/getSuggestedDocs": [undefined, void]; addAutocompleteModel: [{ model: ModelDescription }, void]; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 40d537d41..ebe2a8697 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -52,6 +52,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "indexing/reindex", "indexing/abort", "indexing/setPaused", + "docs/getSuggestedDocs", // "completeOnboarding", "addAutocompleteModel", 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/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 4bef9da9c..f18379889 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -84,6 +84,7 @@ function useSetup(dispatch: Dispatch) { // ON LOAD useEffect(() => { + ideMessenger.post("docs/getSuggestedDocs", undefined); // Override persisted state dispatch(setInactive()); @@ -178,8 +179,6 @@ function useSetup(dispatch: Dispatch) { }, [defaultModelTitle], ); - - } export default useSetup; diff --git a/manual-testing-sandbox/package.json b/manual-testing-sandbox/package.json new file mode 100644 index 000000000..ef77ac910 --- /dev/null +++ b/manual-testing-sandbox/package.json @@ -0,0 +1,102 @@ +{ + "name": "gui", + "private": true, + "type": "module", + "author": "Continue Dev, Inc", + "license": "Apache-2.0", + "scripts": { + "dev": "vite", + "tsc:check": "tsc -p ./ --noEmit", + "build": "tsc && vite build", + "preview": "vite preview", + "test": "vitest run", + "test:coverage": "vitest run --coverage", + "test:ui": "vitest --ui", + "test:watch": "vitest" + }, + "dependencies": { + "@headlessui/react": "^1.7.17", + "@heroicons/react": "^2.0.18", + "@monaco-editor/react": "^4.6.0", + "@reduxjs/toolkit": "^1.9.3", + "@tiptap/core": "^2.3.2", + "@tiptap/extension-document": "^2.3.2", + "@tiptap/extension-dropcursor": "^2.1.16", + "@tiptap/extension-history": "^2.3.2", + "@tiptap/extension-image": "^2.1.16", + "@tiptap/extension-mention": "^2.1.13", + "@tiptap/extension-paragraph": "^2.3.2", + "@tiptap/extension-placeholder": "^2.1.13", + "@tiptap/extension-text": "^2.3.2", + "@tiptap/pm": "^2.1.13", + "@tiptap/react": "^2.1.13", + "@tiptap/starter-kit": "^2.1.13", + "@tiptap/suggestion": "^2.1.13", + "@types/vscode-webview": "^1.57.1", + "core": "file:../core", + "dompurify": "^3.0.6", + "downshift": "^7.6.0", + "lodash": "^4.17.21", + "minisearch": "^7.0.2", + "onigasm": "^2.2.5", + "posthog-js": "^1.130.1", + "prismjs": "^1.29.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-error-boundary": "^4.0.11", + "react-hook-form": "^7.47.0", + "react-intersection-observer": "^9.13.1", + "react-markdown": "^9.0.1", + "react-redux": "^8.0.5", + "react-remark": "^2.1.0", + "react-router-dom": "^6.14.2", + "react-switch": "^7.0.0", + "react-syntax-highlighter": "^15.5.0", + "react-tooltip": "^5.18.0", + "redux-persist": "^6.0.0", + "redux-persist-transform-filter": "^0.0.22", + "rehype-highlight": "^7.0.0", + "rehype-katex": "^7.0.0", + "rehype-wrap-all": "^1.1.0", + "remark-math": "^6.0.0", + "reselect": "^5.1.1", + "seti-file-icons": "^0.0.8", + "socket.io-client": "^4.7.2", + "styled-components": "^5.3.6", + "table": "^6.8.1", + "tippy.js": "^6.3.7", + "unist-util-visit": "^5.0.0", + "uuid": "^9.0.1", + "vscode-webview": "^1.0.1-beta.1" + }, + "devDependencies": { + "@swc/cli": "^0.3.14", + "@swc/core": "^1.7.26", + "@testing-library/dom": "^10.4.0", + "@testing-library/jest-dom": "^6.5.0", + "@testing-library/react": "^16.0.1", + "@testing-library/user-event": "^14.5.2", + "@types/lodash": "^4.17.6", + "@types/node": "^20.5.6", + "@types/node-fetch": "^2.6.4", + "@types/react": "^18.3.11", + "@types/react-dom": "^18.3.1", + "@types/react-router-dom": "^5.3.3", + "@types/react-syntax-highlighter": "^15.5.7", + "@types/styled-components": "^5.1.26", + "@vitejs/plugin-react-swc": "^3.7.0", + "@vitest/coverage-v8": "^2.1.3", + "@vitest/ui": "^2.1.3", + "autoprefixer": "^10.4.13", + "jsdom": "^25.0.1", + "postcss": "^8.4.21", + "tailwindcss": "^3.2.7", + "typescript": "^4.9.3", + "vite": "^4.1.0", + "vitest": "^2.1.3" + }, + "engine-strict": true, + "engines": { + "node": ">=20.11.0" + } +} diff --git a/manual-testing-sandbox/requirements.txt b/manual-testing-sandbox/requirements.txt new file mode 100644 index 000000000..793d6a827 --- /dev/null +++ b/manual-testing-sandbox/requirements.txt @@ -0,0 +1,10 @@ +flask==2.1.1 +requests==2.28.1 +numpy==1.23.4 +pandas==1.5.0 +scipy==1.9.3 +django==4.1.3 +matplotlib==3.6.2 +pytest==7.2.0 +sqlalchemy==1.4.41 +beautifulsoup4==4.11.1 \ No newline at end of file From 78ef8fe118ef227b73ad544a684ea20b56a0b63d Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 21 Nov 2024 10:39:59 -0800 Subject: [PATCH 02/73] 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 954bd5f563a278c04f40f0ec40bfbe27fc497afb Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 21 Nov 2024 11:58:48 -0800 Subject: [PATCH 03/73] python and typescript crawlers --- core/index.d.ts | 29 +++++ core/indexing/docs/suggestions/index.ts | 115 +++++++++++------- .../suggestions/packageCrawlers/Python.ts | 39 ++++-- .../docs/suggestions/packageCrawlers/TsJs.ts | 40 ++++-- 4 files changed, 159 insertions(+), 64 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 0646edc54..de1adb893 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1190,3 +1190,32 @@ export interface BrowserSerializedContinueConfig { experimental?: ExperimentalConfig; analytics?: AnalyticsConfig; } + +// DOCS SUGGESTIONS AND PACKAGE INFO +export interface FilePathAndName { + path: string; + name: string; +} +export type ParsedPackageInfo = { + language: string; + name: string; + version: string; + packageFile: FilePathAndName; +}; + +export type PackageDetails = { + docsLink?: string; + title?: string; + description?: string; +}; + +export type PackageDetailsSuccess = PackageDetails & { + docsLink: string; +}; + +export type PackageDocsResult = { + packageInfo: ParsedPackageInfo; +} & ( + | { error: string; details?: never } + | { details: PackageDetailsSuccess; error?: never } +); diff --git a/core/indexing/docs/suggestions/index.ts b/core/indexing/docs/suggestions/index.ts index d3d68aca2..5699cd761 100644 --- a/core/indexing/docs/suggestions/index.ts +++ b/core/indexing/docs/suggestions/index.ts @@ -1,12 +1,12 @@ -// write me an interface PackageCrawler that contains: -// 1. property `language` to store a given language like "python" or "typescript" -// 2. has a method `getPackageFiles` which takes a list of file names and decides which ones match package/dependency files (e.g. package.json for typescript, requirements.txt for python, etc) -// 3. has a method `parsePackageFile` which returns a list of package name and version from a relevant package file, in a standardized format like semver -// 4. has a method `getDocumentationLink` to check for documentation link for a given package (e.g. GET `https://registry.npmjs.org/` and find docs field for typescript, documentation link in the package metadata for PyPi, etc.) -// Then, write typescript classes to implement this typescript interface for the languages "python" and "typescript" - -import { IDE } from "../../.."; +import { + FilePathAndName, + IDE, + PackageDetails, + PackageDocsResult, + ParsedPackageInfo, +} from "../../.."; import { walkDir } from "../../walkDir"; + import { PythonPackageCrawler } from "./packageCrawlers/Python"; import { TypeScriptPackageCrawler } from "./packageCrawlers/TsJs"; @@ -14,19 +14,14 @@ const PACKAGE_CRAWLERS = [TypeScriptPackageCrawler, PythonPackageCrawler]; export interface PackageCrawler { language: string; - getPackageFiles(fileNames: string[]): string[]; - parsePackageFile(fileContent: string, filePath: string): PackageInfo[]; - getDocumentationLink(packageName: string): Promise; + getPackageFiles(files: FilePathAndName[]): FilePathAndName[]; + parsePackageFile( + file: FilePathAndName, + contents: string, + ): ParsedPackageInfo[]; + getPackageDetails(packageInfo: ParsedPackageInfo): Promise; } -export type PackageInfo = { - name: string; - version: string; - foundInFilepath: string; -}; -export type PackageDocsResult = PackageInfo & - ({ error: string; link?: never } | { link: string; error?: never }); - export async function getAllSuggestedDocs(ide: IDE) { const workspaceDirs = await ide.getWorkspaceDirs(); const results = await Promise.all( @@ -35,16 +30,26 @@ export async function getAllSuggestedDocs(ide: IDE) { }), ); const allPaths = results.flat(); // TODO only get files, not dirs. Not critical for now - const allFiles = allPaths.map((path) => path.split("/").pop()!); - const packageFilesByLanguage: Record = {}; + const allFiles = allPaths.map((path) => ({ + path, + name: path.split(/[\\/]/).pop()!, + })); + + // Build map of language -> package files + const packageFilesByLanguage: Record = {}; for (const Crawler of PACKAGE_CRAWLERS) { const crawler = new Crawler(); const packageFilePaths = crawler.getPackageFiles(allFiles); packageFilesByLanguage[crawler.language] = packageFilePaths; } + // Get file contents for all unique package files const uniqueFilePaths = Array.from( - new Set(Object.values(packageFilesByLanguage).flat()), + new Set( + Object.values(packageFilesByLanguage).flatMap((files) => + files.map((file) => file.path), + ), + ), ); const fileContentsArray = await Promise.all( uniqueFilePaths.map(async (path) => { @@ -56,40 +61,68 @@ export async function getAllSuggestedDocs(ide: IDE) { fileContentsArray.map(({ path, contents }) => [path, contents]), ); - const packagesByLanguage: Record = {}; + // Parse package files and build map of language -> packages + const packagesByLanguage: Record = {}; PACKAGE_CRAWLERS.forEach((Crawler) => { const crawler = new Crawler(); const packageFiles = packageFilesByLanguage[crawler.language]; packageFiles.forEach((file) => { - const contents = fileContents.get(file); + const contents = fileContents.get(file.path); if (!contents) { return; } - const packages = crawler.parsePackageFile(contents, file); + const packages = crawler.parsePackageFile(file, contents); if (!packagesByLanguage[crawler.language]) { packagesByLanguage[crawler.language] = []; } packagesByLanguage[crawler.language].push(...packages); }); }); - console.log(packagesByLanguage); - // const allPackages = await Promise.all( - // PACKAGE_CRAWLERS.map(async (Crawler) => { - // const crawler = new Crawler(); - // const packageInfos = uniqueFileContents - // .filter(({ path }) => languageToFilePaths[crawler.language].includes(path)) - // .map(({ path, contents }) => crawler.parsePackageFile(contents, path)) - // .flat(); - // return packageInfos; - // }) - // ); - // for (const Crawler of PACKAGE_CRAWLERS) { - // const crawler = new Crawler(); - // const packages = crawler.parsePackageFile() - // languageToFilePaths[crawler.language] = packageFilePaths; - // } + + // Get documentation links for all packages + const docsByLanguage: Record = {}; + await Promise.all( + PACKAGE_CRAWLERS.map(async (Crawler) => { + const crawler = new Crawler(); + const packages = packagesByLanguage[crawler.language]; + docsByLanguage[crawler.language] = await Promise.all( + packages.map(async (packageInfo) => { + try { + const details = await crawler.getPackageDetails(packageInfo); + if (!details.docsLink) { + return { + packageInfo, + error: `No documentation link found for ${packageInfo.name}`, + }; + } + return { + packageInfo, + details: { + ...details, + docsLink: details.docsLink, + }, + }; + } catch (error) { + return { + packageInfo, + error: `Error getting package details for ${name}`, + }; + } + }), + ); + }), + ); + + return docsByLanguage; } +// write me an interface PackageCrawler that contains: +// 1. property `language` to store a given language like "python" or "typescript" +// 2. has a method `getPackageFiles` which takes a list of file names and decides which ones match package/dependency files (e.g. package.json for typescript, requirements.txt for python, etc) +// 3. has a method `parsePackageFile` which returns a list of package name and version from a relevant package file, in a standardized format like semver +// 4. has a method `getDocumentationLink` to check for documentation link for a given package (e.g. GET `https://registry.npmjs.org/` and find docs field for typescript, documentation link in the package metadata for PyPi, etc.) +// Then, write typescript classes to implement this typescript interface for the languages "python" and "typescript" + // I want to present the user with a list of dependencies and allow them to select which ones to index (embed) documentation for. // In order to prevent duplicate file reads, the process will be like this: // 1. take in a list of filepaths called `filepaths` diff --git a/core/indexing/docs/suggestions/packageCrawlers/Python.ts b/core/indexing/docs/suggestions/packageCrawlers/Python.ts index ac0699766..233e44428 100644 --- a/core/indexing/docs/suggestions/packageCrawlers/Python.ts +++ b/core/indexing/docs/suggestions/packageCrawlers/Python.ts @@ -1,33 +1,50 @@ -import { PackageCrawler, PackageDocsResult, PackageInfo } from ".."; +import { PackageCrawler } from ".."; +import { + FilePathAndName, + PackageDetails, + ParsedPackageInfo, +} from "../../../.."; export class PythonPackageCrawler implements PackageCrawler { language = "python"; - getPackageFiles(fileNames: string[]): string[] { + getPackageFiles(files: FilePathAndName[]): FilePathAndName[] { // For Python, we typically look for files like requirements.txt or Pipfile - return fileNames.filter( - (fileName) => fileName === "requirements.txt" || fileName === "Pipfile", + return files.filter( + (file) => file.name === "requirements.txt" || file.name === "Pipfile", ); } - parsePackageFile(fileContent: string, filepath: string): PackageInfo[] { + parsePackageFile( + file: FilePathAndName, + contents: string, + ): ParsedPackageInfo[] { // Assume the fileContent is a string from a requirements.txt formatted file - return fileContent + return contents .split("\n") .map((line) => { const [name, version] = line.split("=="); - return { name, version, foundInFilepath: filepath }; + return { name, version, packageFile: file, language: this.language }; }) .filter((pkg) => pkg.name && pkg.version); } - async getDocumentationLink(packageName: string): Promise { + async getPackageDetails( + packageInfo: ParsedPackageInfo, + ): Promise { // Fetch metadata from PyPI to find the documentation link - const response = await fetch(`https://pypi.org/pypi/${packageName}/json`); + + const response = await fetch( + `https://pypi.org/pypi/${packageInfo.name}/json`, + ); if (!response.ok) { - throw new Error(`Could not fetch data for package ${packageName}`); + throw new Error(`Could not fetch data for package ${packageInfo.name}`); } const data = await response.json(); - return data.info.project_urls?.Documentation; + return { + docsLink: data.info.project_urls?.Documentation as string | undefined, + // title: data.info.name, + // description: data.info.summary as string | undefined, + }; } } diff --git a/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts index fb073e2a1..107d9ac2a 100644 --- a/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts +++ b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts @@ -1,33 +1,49 @@ -import { PackageCrawler, PackageDocsResult, PackageInfo } from ".."; +import { PackageCrawler } from ".."; +import { + FilePathAndName, + PackageDetails, + ParsedPackageInfo, +} from "../../../.."; export class TypeScriptPackageCrawler implements PackageCrawler { - language = "typescript"; + language = "js-ts"; - getPackageFiles(fileNames: string[]): string[] { - // For TypeScript, we look for package.json file - return fileNames.filter((fileName) => fileName === "package.json"); + getPackageFiles(files: FilePathAndName[]): FilePathAndName[] { + // For Javascript/TypeScript, we look for package.json file + return files.filter((file) => file.name === "package.json"); } - parsePackageFile(fileContent: string, filepath: string): PackageInfo[] { + parsePackageFile( + file: FilePathAndName, + contents: string, + ): ParsedPackageInfo[] { // Parse the package.json content - const jsonData = JSON.parse(fileContent) as Record; + const jsonData = JSON.parse(contents) as Record; const dependencies = Object.entries(jsonData.dependencies || {}).concat( Object.entries(jsonData.devDependencies || {}), ); return dependencies.map(([name, version]) => ({ name, version, - foundInFilepath: filepath, + packageFile: file, + language: this.language, })); } - async getDocumentationLink(packageName: string): Promise { + async getPackageDetails( + packageInfo: ParsedPackageInfo, + ): Promise { + const { name } = packageInfo; // Fetch metadata from the NPM registry to find the documentation link - const response = await fetch(`https://registry.npmjs.org/${packageName}`); + const response = await fetch(`https://registry.npmjs.org/${name}`); if (!response.ok) { - throw new Error(`Could not fetch data for package ${packageName}`); + throw new Error(`Could not fetch data for package ${name}`); } const data = await response.json(); - return data.homepage; + return { + docsLink: data.homepage as string | undefined, + // title: data.name, + // description: data.description as string | undefined, + }; } } From abd46dfb4ff1aea84e94922fdda5d6fce23c6edf Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 21 Nov 2024 12:52:25 -0800 Subject: [PATCH 04/73] docs suggestions: packages in GUI --- core/core.ts | 3 +- core/index.d.ts | 3 ++ core/indexing/docs/suggestions/index.ts | 4 +-- core/protocol/passThrough.ts | 1 + core/protocol/webview.ts | 2 ++ gui/src/components/dialogs/AddDocsDialog.tsx | 37 ++++++++++++++++++-- gui/src/hooks/useSetup.ts | 6 ++++ gui/src/redux/slices/stateSlice.ts | 11 ++++++ 8 files changed, 61 insertions(+), 6 deletions(-) diff --git a/core/core.ts b/core/core.ts index d080ec34b..d81df8a37 100644 --- a/core/core.ts +++ b/core/core.ts @@ -739,7 +739,8 @@ export class Core { return this.docsService.initStatuses(); }); on("docs/getSuggestedDocs", async (msg) => { - getAllSuggestedDocs(this.ide); + const suggestedDocs = await getAllSuggestedDocs(this.ide); + this.messenger.send("docs/suggestions", suggestedDocs); }); // diff --git a/core/index.d.ts b/core/index.d.ts index de1adb893..d6b2c1970 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1219,3 +1219,6 @@ export type PackageDocsResult = { | { error: string; details?: never } | { details: PackageDetailsSuccess; error?: never } ); + +// language -> package -> package info +export type DocsSuggestions = Record; diff --git a/core/indexing/docs/suggestions/index.ts b/core/indexing/docs/suggestions/index.ts index 5699cd761..3ee4fb642 100644 --- a/core/indexing/docs/suggestions/index.ts +++ b/core/indexing/docs/suggestions/index.ts @@ -1,4 +1,5 @@ import { + DocsSuggestions, FilePathAndName, IDE, PackageDetails, @@ -80,7 +81,7 @@ export async function getAllSuggestedDocs(ide: IDE) { }); // Get documentation links for all packages - const docsByLanguage: Record = {}; + const docsByLanguage: DocsSuggestions = {}; await Promise.all( PACKAGE_CRAWLERS.map(async (Crawler) => { const crawler = new Crawler(); @@ -112,7 +113,6 @@ export async function getAllSuggestedDocs(ide: IDE) { ); }), ); - return docsByLanguage; } diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index ebe2a8697..2bd8de2c1 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -75,4 +75,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = "getWebviewHistoryLength", "signInToControlPlane", "openDialogMessage", + "docs/suggestions", ]; diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 0dcdb047f..bf90497c8 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -2,6 +2,7 @@ import { ConfigValidationError } from "../config/validation.js"; import type { ContextItemWithId, + DocsSuggestions, IndexingProgressUpdate, IndexingStatus, } from "../index.js"; @@ -25,4 +26,5 @@ export type ToWebviewFromIdeOrCoreProtocol = { getWebviewHistoryLength: [undefined, number]; signInToControlPlane: [undefined, void]; openDialogMessage: ["account", void]; + "docs/suggestions": [DocsSuggestions, void]; }; diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index 098194886..c21aca5a6 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -5,7 +5,7 @@ import { } from "@heroicons/react/24/outline"; import { SiteIndexingConfig } from "core"; import { usePostHog } from "posthog-js/react"; -import { useContext, useLayoutEffect, useRef, useState } from "react"; +import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Button, HelperText, Input, lightGray, SecondaryButton } from ".."; import { IdeMessengerContext } from "../../context/IdeMessenger"; @@ -15,6 +15,7 @@ import { } from "../../redux/slices/uiStateSlice"; import { RootState } from "../../redux/store"; import IndexingStatusViewer from "../indexing/IndexingStatus"; +import { C } from "core/autocomplete/constants/AutocompleteLanguageInfo"; function AddDocsDialog() { const posthog = usePostHog(); @@ -34,6 +35,21 @@ function AddDocsDialog() { (store: RootState) => store.state.indexing.statuses, ); + const docsSuggestions = useSelector( + (store: RootState) => store.state.docsSuggestions, + ); + + const docsByLanguage = useMemo(() => { + console.log(docsSuggestions); + const languages = Object.keys(docsSuggestions); + return languages.map((language) => { + return { + language, + packages: docsSuggestions[language], + }; + }); + }, [docsSuggestions]); + const isFormValid = startUrl && title; useLayoutEffect(() => { @@ -118,8 +134,23 @@ function AddDocsDialog() { return (
-

Add a documentation site

- +

Add documentation

+ {docsByLanguage.map(({ language, packages }) => { + return ( +
+

{language}

+
+ {packages.map((pkg) => { + return ( +
+

{pkg.packageInfo.name}

+
+ ); + })} +
+
+ ); + })}

Continue pre-indexes many common documentation sites, but if there's one you don't see in the dropdown, enter the URL here. diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index f18379889..ecc7a7ac9 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -11,6 +11,7 @@ import { setInactive, setSelectedProfileId, setTTSActive, + updateDocsSuggestions, updateIndexingStatus, } from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; @@ -85,6 +86,7 @@ function useSetup(dispatch: Dispatch) { // ON LOAD useEffect(() => { ideMessenger.post("docs/getSuggestedDocs", undefined); + // Override persisted state dispatch(setInactive()); @@ -116,6 +118,10 @@ function useSetup(dispatch: Dispatch) { } }, []); + useWebviewListener("docs/suggestions", async (data) => { + dispatch(updateDocsSuggestions(data)); + }); + const { streamResponse } = useChatHandler(dispatch, ideMessenger); const defaultModelTitle = useSelector( diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index 770e9ce69..e965455c4 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -5,6 +5,7 @@ import { ChatMessage, Checkpoint, ContextItemWithId, + DocsSuggestions, FileSymbolMap, IndexingStatus, PersistedSessionInfo, @@ -47,6 +48,7 @@ type State = { }; streamAborter: AbortController; isMultifileEdit: boolean; + docsSuggestions: DocsSuggestions; }; const initialState: State = { @@ -89,6 +91,7 @@ const initialState: State = { }, }, streamAborter: new AbortController(), + docsSuggestions: {}, }; export const stateSlice = createSlice({ @@ -447,6 +450,13 @@ export const stateSlice = createSlice({ [payload.type]: payload.hidden, }; }, + updateDocsSuggestions: ( + state, + { payload }: PayloadAction, + ) => { + console.log("FROM REDUX", payload); + state.docsSuggestions = payload; + }, }, }); @@ -480,6 +490,7 @@ export const { updateIndexingStatus, setIndexingChatPeekHidden, abortStream, + updateDocsSuggestions, } = stateSlice.actions; export default stateSlice.reducer; From fec4b21f7b713708befa8dbd12cdd9f8a4f4f219 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 21 Nov 2024 11:45:37 -0800 Subject: [PATCH 05/73] 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 53f3638b8f0ec703579f3136f7293d4d88ea8a28 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 21 Nov 2024 16:37:28 -0800 Subject: [PATCH 06/73] suggested docs continued --- core/index.d.ts | 11 +++++-- core/indexing/docs/suggestions/index.ts | 30 ++++++++++++----- .../suggestions/packageCrawlers/Python.ts | 29 +++++++++++++---- .../docs/suggestions/packageCrawlers/TsJs.ts | 24 +++++++++++--- gui/src/components/dialogs/AddDocsDialog.tsx | 32 ++++--------------- gui/src/components/dialogs/SuggestedDocs.tsx | 18 +++++++++++ gui/src/redux/slices/stateSlice.ts | 9 +++--- 7 files changed, 100 insertions(+), 53 deletions(-) create mode 100644 gui/src/components/dialogs/SuggestedDocs.tsx diff --git a/core/index.d.ts b/core/index.d.ts index d6b2c1970..328462e70 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1196,6 +1196,12 @@ export interface FilePathAndName { path: string; name: string; } + +export interface PackageFilePathAndName extends FilePathAndName { + language: string; // e.g. javascript + registry: string; // e.g. npm +} + export type ParsedPackageInfo = { language: string; name: string; @@ -1207,6 +1213,8 @@ export type PackageDetails = { docsLink?: string; title?: string; description?: string; + repo?: string; + license?: string; }; export type PackageDetailsSuccess = PackageDetails & { @@ -1219,6 +1227,3 @@ export type PackageDocsResult = { | { error: string; details?: never } | { details: PackageDetailsSuccess; error?: never } ); - -// language -> package -> package info -export type DocsSuggestions = Record; diff --git a/core/indexing/docs/suggestions/index.ts b/core/indexing/docs/suggestions/index.ts index 3ee4fb642..0f86f5390 100644 --- a/core/indexing/docs/suggestions/index.ts +++ b/core/indexing/docs/suggestions/index.ts @@ -1,9 +1,9 @@ import { - DocsSuggestions, + PackageDocsResult, FilePathAndName, + PackageFilePathAndName, IDE, PackageDetails, - PackageDocsResult, ParsedPackageInfo, } from "../../.."; import { walkDir } from "../../walkDir"; @@ -15,9 +15,9 @@ const PACKAGE_CRAWLERS = [TypeScriptPackageCrawler, PythonPackageCrawler]; export interface PackageCrawler { language: string; - getPackageFiles(files: FilePathAndName[]): FilePathAndName[]; + getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[]; parsePackageFile( - file: FilePathAndName, + file: PackageFilePathAndName, contents: string, ): ParsedPackageInfo[]; getPackageDetails(packageInfo: ParsedPackageInfo): Promise; @@ -37,7 +37,7 @@ export async function getAllSuggestedDocs(ide: IDE) { })); // Build map of language -> package files - const packageFilesByLanguage: Record = {}; + const packageFilesByLanguage: Record = {}; for (const Crawler of PACKAGE_CRAWLERS) { const crawler = new Crawler(); const packageFilePaths = crawler.getPackageFiles(allFiles); @@ -80,13 +80,26 @@ export async function getAllSuggestedDocs(ide: IDE) { }); }); + // Deduplicate packages per language + // TODO - this is where you would allow docs for different versions + // by e.g. using "name-version" as the map key instead of just name + // For now have not allowed + const languages = Object.keys(packagesByLanguage); + languages.forEach((language) => { + const packages = packagesByLanguage[language]; + const uniquePackages = Array.from( + new Map(packages.map((pkg) => [pkg.name, pkg])).values(), + ); + packagesByLanguage[language] = uniquePackages; + }); + // Get documentation links for all packages - const docsByLanguage: DocsSuggestions = {}; + const allDocsResults: PackageDocsResult[] = []; await Promise.all( PACKAGE_CRAWLERS.map(async (Crawler) => { const crawler = new Crawler(); const packages = packagesByLanguage[crawler.language]; - docsByLanguage[crawler.language] = await Promise.all( + const docsByLanguage = await Promise.all( packages.map(async (packageInfo) => { try { const details = await crawler.getPackageDetails(packageInfo); @@ -111,9 +124,10 @@ export async function getAllSuggestedDocs(ide: IDE) { } }), ); + allDocsResults.push(...docsByLanguage); }), ); - return docsByLanguage; + return allDocsResults; } // write me an interface PackageCrawler that contains: diff --git a/core/indexing/docs/suggestions/packageCrawlers/Python.ts b/core/indexing/docs/suggestions/packageCrawlers/Python.ts index 233e44428..28b893b66 100644 --- a/core/indexing/docs/suggestions/packageCrawlers/Python.ts +++ b/core/indexing/docs/suggestions/packageCrawlers/Python.ts @@ -2,17 +2,24 @@ import { PackageCrawler } from ".."; import { FilePathAndName, PackageDetails, + PackageFilePathAndName, ParsedPackageInfo, } from "../../../.."; export class PythonPackageCrawler implements PackageCrawler { language = "python"; - getPackageFiles(files: FilePathAndName[]): FilePathAndName[] { + getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] { // For Python, we typically look for files like requirements.txt or Pipfile - return files.filter( - (file) => file.name === "requirements.txt" || file.name === "Pipfile", - ); + return files + .filter( + (file) => file.name === "requirements.txt" || file.name === "Pipfile", + ) + .map((file) => ({ + ...file, + language: this.language, + registry: "pypi", + })); } parsePackageFile( @@ -41,10 +48,18 @@ export class PythonPackageCrawler implements PackageCrawler { throw new Error(`Could not fetch data for package ${packageInfo.name}`); } const data = await response.json(); + const homePage = data?.info?.home_page as string | undefined; + return { - docsLink: data.info.project_urls?.Documentation as string | undefined, - // title: data.info.name, - // description: data.info.summary as string | undefined, + docsLink: + (data?.info?.project_urls?.Documentation as string | undefined) ?? + homePage, + title: data?.info?.name as string | undefined, + description: data?.info?.summary as string | undefined, + repo: + (data?.info?.project_urls?.Repository as string | undefined) ?? + homePage, + license: data?.info?.license as string | undefined, }; } } diff --git a/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts index 107d9ac2a..c16b8872e 100644 --- a/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts +++ b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts @@ -2,15 +2,22 @@ import { PackageCrawler } from ".."; import { FilePathAndName, PackageDetails, + PackageFilePathAndName, ParsedPackageInfo, } from "../../../.."; export class TypeScriptPackageCrawler implements PackageCrawler { language = "js-ts"; - getPackageFiles(files: FilePathAndName[]): FilePathAndName[] { + getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] { // For Javascript/TypeScript, we look for package.json file - return files.filter((file) => file.name === "package.json"); + return files + .filter((file) => file.name === "package.json") + .map((file) => ({ + ...file, + language: this.language, + registry: "npm", + })); } parsePackageFile( @@ -22,7 +29,10 @@ export class TypeScriptPackageCrawler implements PackageCrawler { const dependencies = Object.entries(jsonData.dependencies || {}).concat( Object.entries(jsonData.devDependencies || {}), ); - return dependencies.map(([name, version]) => ({ + const filtered = dependencies.filter( + ([name, version]) => !name.startsWith("@types/"), + ); + return filtered.map(([name, version]) => ({ name, version, packageFile: file, @@ -42,8 +52,12 @@ export class TypeScriptPackageCrawler implements PackageCrawler { const data = await response.json(); return { docsLink: data.homepage as string | undefined, - // title: data.name, - // description: data.description as string | undefined, + title: name, // package.json doesn't have specific title field + description: data.description as string | undefined, + repo: Array.isArray(data.repository) + ? (data.respository[0]?.url as string | undefined) + : undefined, + license: data.license as string | undefined, }; } } diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index c21aca5a6..7dcc478fc 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -15,7 +15,6 @@ import { } from "../../redux/slices/uiStateSlice"; import { RootState } from "../../redux/store"; import IndexingStatusViewer from "../indexing/IndexingStatus"; -import { C } from "core/autocomplete/constants/AutocompleteLanguageInfo"; function AddDocsDialog() { const posthog = usePostHog(); @@ -39,17 +38,6 @@ function AddDocsDialog() { (store: RootState) => store.state.docsSuggestions, ); - const docsByLanguage = useMemo(() => { - console.log(docsSuggestions); - const languages = Object.keys(docsSuggestions); - return languages.map((language) => { - return { - language, - packages: docsSuggestions[language], - }; - }); - }, [docsSuggestions]); - const isFormValid = startUrl && title; useLayoutEffect(() => { @@ -135,22 +123,16 @@ function AddDocsDialog() {

Add documentation

- {docsByLanguage.map(({ language, packages }) => { + {/* {docsSuggestions.map((docsResult) => { + const { error, details } = docsResult; + const { language, name, version } = docsResult.packageInfo; return ( -
-

{language}

-
- {packages.map((pkg) => { - return ( -
-

{pkg.packageInfo.name}

-
- ); - })} -
+
+

{`${name}`}

+

{error ? "error" : details.docsLink}

); - })} + })} */}

Continue pre-indexes many common documentation sites, but if there's one you don't see in the dropdown, enter the URL here. diff --git a/gui/src/components/dialogs/SuggestedDocs.tsx b/gui/src/components/dialogs/SuggestedDocs.tsx new file mode 100644 index 000000000..1540ea92f --- /dev/null +++ b/gui/src/components/dialogs/SuggestedDocs.tsx @@ -0,0 +1,18 @@ +import { PackageDocsResult } from "core"; + +interface SuggestedDocProps { + docResult: PackageDocsResult; +} +const SuggestedDoc = ({ docResult }: SuggestedDocProps) => { + return

SuggestedDoc
; +}; + +interface SuggestedDocsListProps { + docs: PackageDocsResult[]; + // on +} +const SuggestedDocsList = ({ docs }: SuggestedDocsListProps) => { + return
; +}; + +export default SuggestedDocsList; diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index e965455c4..2feaf8065 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -5,7 +5,7 @@ import { ChatMessage, Checkpoint, ContextItemWithId, - DocsSuggestions, + PackageDocsResult, FileSymbolMap, IndexingStatus, PersistedSessionInfo, @@ -48,7 +48,7 @@ type State = { }; streamAborter: AbortController; isMultifileEdit: boolean; - docsSuggestions: DocsSuggestions; + docsSuggestions: PackageDocsResult[]; }; const initialState: State = { @@ -91,7 +91,7 @@ const initialState: State = { }, }, streamAborter: new AbortController(), - docsSuggestions: {}, + docsSuggestions: [], }; export const stateSlice = createSlice({ @@ -452,9 +452,8 @@ export const stateSlice = createSlice({ }, updateDocsSuggestions: ( state, - { payload }: PayloadAction, + { payload }: PayloadAction, ) => { - console.log("FROM REDUX", payload); state.docsSuggestions = payload; }, }, From 48806f3f0831de8cf67546ef77467548187641cc Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 21 Nov 2024 18:07:37 -0800 Subject: [PATCH 07/73] docs suggestions p4 --- core/core.ts | 8 +- core/index.d.ts | 7 +- core/indexing/docs/suggestions/index.ts | 36 ++-- .../suggestions/packageCrawlers/Python.ts | 9 +- .../docs/suggestions/packageCrawlers/TsJs.ts | 27 ++- gui/src/components/dialogs/AddDocsDialog.tsx | 186 ++++++++++++------ gui/src/components/index.ts | 10 + .../components/indexing/IndexingStatuses.tsx | 27 ++- gui/tailwind.config.cjs | 11 +- 9 files changed, 199 insertions(+), 122 deletions(-) diff --git a/core/core.ts b/core/core.ts index d81df8a37..b2be3478c 100644 --- a/core/core.ts +++ b/core/core.ts @@ -19,6 +19,7 @@ import { ControlPlaneClient } from "./control-plane/client"; import { streamDiffLines } from "./edit/streamDiffLines"; import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer"; import DocsService from "./indexing/docs/DocsService"; +import { getAllSuggestedDocs } from "./indexing/docs/suggestions"; import { defaultIgnoreFile } from "./indexing/ignore.js"; import Ollama from "./llm/llms/Ollama"; import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile"; @@ -28,11 +29,7 @@ import { DevDataSqliteDb } from "./util/devdataSqlite"; import { fetchwithRequestOptions } from "./util/fetchWithOptions"; import { GlobalContext } from "./util/GlobalContext"; import historyManager from "./util/history"; -import { - editConfigJson, - getConfigJsonPath, - setupInitialDotContinueDirectory, -} from "./util/paths"; +import { editConfigJson, setupInitialDotContinueDirectory } from "./util/paths"; import { Telemetry } from "./util/posthog"; import { getSymbolsForManyFiles } from "./util/treeSitter"; import { TTS } from "./util/tts"; @@ -40,7 +37,6 @@ import { TTS } from "./util/tts"; import type { ContextItemId, IDE, IndexingProgressUpdate } from "."; import type { FromCoreProtocol, ToCoreProtocol } from "./protocol"; import type { IMessenger, Message } from "./util/messenger"; -import { getAllSuggestedDocs } from "./indexing/docs/suggestions"; export class Core { // implements IMessenger diff --git a/core/index.d.ts b/core/index.d.ts index 328462e70..5541584eb 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1198,15 +1198,14 @@ export interface FilePathAndName { } export interface PackageFilePathAndName extends FilePathAndName { - language: string; // e.g. javascript - registry: string; // e.g. npm + packageRegistry: string; // e.g. npm, pypi } export type ParsedPackageInfo = { - language: string; name: string; + packageFile: PackageFilePathAndName; + language: string; version: string; - packageFile: FilePathAndName; }; export type PackageDetails = { diff --git a/core/indexing/docs/suggestions/index.ts b/core/indexing/docs/suggestions/index.ts index 0f86f5390..4e0c2104a 100644 --- a/core/indexing/docs/suggestions/index.ts +++ b/core/indexing/docs/suggestions/index.ts @@ -9,12 +9,12 @@ import { import { walkDir } from "../../walkDir"; import { PythonPackageCrawler } from "./packageCrawlers/Python"; -import { TypeScriptPackageCrawler } from "./packageCrawlers/TsJs"; +import { NodePackageCrawler } from "./packageCrawlers/TsJs"; -const PACKAGE_CRAWLERS = [TypeScriptPackageCrawler, PythonPackageCrawler]; +const PACKAGE_CRAWLERS = [NodePackageCrawler, PythonPackageCrawler]; export interface PackageCrawler { - language: string; + packageRegistry: string; getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[]; parsePackageFile( file: PackageFilePathAndName, @@ -37,17 +37,17 @@ export async function getAllSuggestedDocs(ide: IDE) { })); // Build map of language -> package files - const packageFilesByLanguage: Record = {}; + const packageFilesByRegistry: Record = {}; for (const Crawler of PACKAGE_CRAWLERS) { const crawler = new Crawler(); const packageFilePaths = crawler.getPackageFiles(allFiles); - packageFilesByLanguage[crawler.language] = packageFilePaths; + packageFilesByRegistry[crawler.packageRegistry] = packageFilePaths; } // Get file contents for all unique package files const uniqueFilePaths = Array.from( new Set( - Object.values(packageFilesByLanguage).flatMap((files) => + Object.values(packageFilesByRegistry).flatMap((files) => files.map((file) => file.path), ), ), @@ -63,20 +63,20 @@ export async function getAllSuggestedDocs(ide: IDE) { ); // Parse package files and build map of language -> packages - const packagesByLanguage: Record = {}; + const packagesByRegistry: Record = {}; PACKAGE_CRAWLERS.forEach((Crawler) => { const crawler = new Crawler(); - const packageFiles = packageFilesByLanguage[crawler.language]; + const packageFiles = packageFilesByRegistry[crawler.packageRegistry]; packageFiles.forEach((file) => { const contents = fileContents.get(file.path); if (!contents) { return; } const packages = crawler.parsePackageFile(file, contents); - if (!packagesByLanguage[crawler.language]) { - packagesByLanguage[crawler.language] = []; + if (!packagesByRegistry[crawler.packageRegistry]) { + packagesByRegistry[crawler.packageRegistry] = []; } - packagesByLanguage[crawler.language].push(...packages); + packagesByRegistry[crawler.packageRegistry].push(...packages); }); }); @@ -84,13 +84,13 @@ export async function getAllSuggestedDocs(ide: IDE) { // TODO - this is where you would allow docs for different versions // by e.g. using "name-version" as the map key instead of just name // For now have not allowed - const languages = Object.keys(packagesByLanguage); + const languages = Object.keys(packagesByRegistry); languages.forEach((language) => { - const packages = packagesByLanguage[language]; + const packages = packagesByRegistry[language]; const uniquePackages = Array.from( new Map(packages.map((pkg) => [pkg.name, pkg])).values(), ); - packagesByLanguage[language] = uniquePackages; + packagesByRegistry[language] = uniquePackages; }); // Get documentation links for all packages @@ -98,8 +98,8 @@ export async function getAllSuggestedDocs(ide: IDE) { await Promise.all( PACKAGE_CRAWLERS.map(async (Crawler) => { const crawler = new Crawler(); - const packages = packagesByLanguage[crawler.language]; - const docsByLanguage = await Promise.all( + const packages = packagesByRegistry[crawler.packageRegistry]; + const docsByRegistry = await Promise.all( packages.map(async (packageInfo) => { try { const details = await crawler.getPackageDetails(packageInfo); @@ -119,12 +119,12 @@ export async function getAllSuggestedDocs(ide: IDE) { } catch (error) { return { packageInfo, - error: `Error getting package details for ${name}`, + error: `Error getting package details for ${packageInfo.name}`, }; } }), ); - allDocsResults.push(...docsByLanguage); + allDocsResults.push(...docsByRegistry); }), ); return allDocsResults; diff --git a/core/indexing/docs/suggestions/packageCrawlers/Python.ts b/core/indexing/docs/suggestions/packageCrawlers/Python.ts index 28b893b66..d00045f97 100644 --- a/core/indexing/docs/suggestions/packageCrawlers/Python.ts +++ b/core/indexing/docs/suggestions/packageCrawlers/Python.ts @@ -7,7 +7,7 @@ import { } from "../../../.."; export class PythonPackageCrawler implements PackageCrawler { - language = "python"; + packageRegistry = "pypi"; getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] { // For Python, we typically look for files like requirements.txt or Pipfile @@ -17,13 +17,12 @@ export class PythonPackageCrawler implements PackageCrawler { ) .map((file) => ({ ...file, - language: this.language, - registry: "pypi", + packageRegistry: "pypi", })); } parsePackageFile( - file: FilePathAndName, + file: PackageFilePathAndName, contents: string, ): ParsedPackageInfo[] { // Assume the fileContent is a string from a requirements.txt formatted file @@ -31,7 +30,7 @@ export class PythonPackageCrawler implements PackageCrawler { .split("\n") .map((line) => { const [name, version] = line.split("=="); - return { name, version, packageFile: file, language: this.language }; + return { name, version, packageFile: file, language: "python" }; }) .filter((pkg) => pkg.name && pkg.version); } diff --git a/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts index c16b8872e..42c500748 100644 --- a/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts +++ b/core/indexing/docs/suggestions/packageCrawlers/TsJs.ts @@ -6,8 +6,8 @@ import { ParsedPackageInfo, } from "../../../.."; -export class TypeScriptPackageCrawler implements PackageCrawler { - language = "js-ts"; +export class NodePackageCrawler implements PackageCrawler { + packageRegistry = "npm"; getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] { // For Javascript/TypeScript, we look for package.json file @@ -15,13 +15,12 @@ export class TypeScriptPackageCrawler implements PackageCrawler { .filter((file) => file.name === "package.json") .map((file) => ({ ...file, - language: this.language, - registry: "npm", + packageRegistry: this.packageRegistry, })); } parsePackageFile( - file: FilePathAndName, + file: PackageFilePathAndName, contents: string, ): ParsedPackageInfo[] { // Parse the package.json content @@ -29,14 +28,24 @@ export class TypeScriptPackageCrawler implements PackageCrawler { const dependencies = Object.entries(jsonData.dependencies || {}).concat( Object.entries(jsonData.devDependencies || {}), ); - const filtered = dependencies.filter( - ([name, version]) => !name.startsWith("@types/"), - ); + + // Filter out types packages and check if typescript is present + let foundTypes = false; + const filtered = dependencies.filter(([name, _]) => { + if (name.startsWith("@types/")) { + foundTypes = true; + return false; + } + if (name.includes("typescript")) { + foundTypes = true; + } + return true; + }); return filtered.map(([name, version]) => ({ name, version, packageFile: file, - language: this.language, + language: foundTypes ? "ts" : "js", })); } diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index 7dcc478fc..ca6a8bceb 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -2,8 +2,11 @@ import { CheckCircleIcon, ChevronDownIcon, ChevronUpIcon, + CodeBracketIcon, + InformationCircleIcon, + LinkIcon, } from "@heroicons/react/24/outline"; -import { SiteIndexingConfig } from "core"; +import { PackageDocsResult, SiteIndexingConfig } from "core"; import { usePostHog } from "posthog-js/react"; import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; @@ -16,6 +19,8 @@ import { import { RootState } from "../../redux/store"; import IndexingStatusViewer from "../indexing/IndexingStatus"; +import { ToolTip } from "../gui/Tooltip"; + function AddDocsDialog() { const posthog = usePostHog(); const dispatch = useDispatch(); @@ -67,72 +72,125 @@ function AddDocsDialog() { posthog.capture("add_docs_gui", { url: startUrl }); } - if (submittedConfig) { - const status = indexingStatuses[submittedConfig.startUrl]; - return ( -
-
- -

{`Docs added`}

-
-
-

Title: {submittedConfig.title}

-

Start URL: {submittedConfig.startUrl}

- {submittedConfig.rootUrl && ( -

Root URL: {submittedConfig.rootUrl}

- )} - {submittedConfig.maxDepth && ( -

Max depth: {submittedConfig.maxDepth}

- )} - {submittedConfig.faviconUrl && ( -

Favicon URL: {submittedConfig.faviconUrl}

- )} -
- {!!status && ( -
-

{`Type "@docs" and select ${submittedConfig.title} to reference these docs once indexing is complete. Check indexing status from the "More" page.`}

-
- -
-
- )} -
- { - setSubmittedConfig(undefined); - }} - > - Add another - - -
-
- ); - } + const handleSelectSuggestion = (docsResult: PackageDocsResult) => {}; + + // if (submittedConfig) { + // const status = indexingStatuses[submittedConfig.startUrl]; + // return ( + //
+ //
+ // + //

{`Docs added`}

+ //
+ //
+ //

Title: {submittedConfig.title}

+ //

Start URL: {submittedConfig.startUrl}

+ // {submittedConfig.rootUrl && ( + //

Root URL: {submittedConfig.rootUrl}

+ // )} + // {submittedConfig.maxDepth && ( + //

Max depth: {submittedConfig.maxDepth}

+ // )} + // {submittedConfig.faviconUrl && ( + //

Favicon URL: {submittedConfig.faviconUrl}

+ // )} + //
+ // {!!status && ( + //
+ //

{`Type "@docs" and select ${submittedConfig.title} to reference these docs once indexing is complete. Check indexing status from the "More" page.`}

+ //
+ // + //
+ //
+ // )} + //
+ // { + // setSubmittedConfig(undefined); + // }} + // > + // Add another + // + // + //
+ //
+ // ); + // } return (

Add documentation

- {/* {docsSuggestions.map((docsResult) => { - const { error, details } = docsResult; - const { language, name, version } = docsResult.packageInfo; - return ( -
-

{`${name}`}

-

{error ? "error" : details.docsLink}

-
- ); - })} */} + {docsSuggestions.length ? ( +
+ + + + + + {/* */} + + + + + + Add docs + {docsSuggestions.map((docsResult) => { + const { error, details } = docsResult; + const { language, name, version } = docsResult.packageInfo; + const id = `${language}-${name}-${version}`; + return ( + + + + {/* */} + + + + ); + })} + +
+ + TitleVersionStart Link
+ + {name}{version} + {error ? ( + + No docs link found + + ) : ( + +
+ +
+

+ {details.docsLink} +

+
+ )} +
+ + + +

{`Version: ${version}`}

+

{`Found in ${docsResult.packageInfo.packageFile.path}`}

+
+
+
+ ) : null}

Continue pre-indexes many common documentation sites, but if there's one you don't see in the dropdown, enter the URL here. @@ -143,7 +201,7 @@ function AddDocsDialog() { so that you can ask questions.

- + {/*
- + */}
); } diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index e380f3ef6..74f27a44a 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -4,6 +4,10 @@ import { getFontSize, isJetBrains } from "../util"; export const VSC_INPUT_BACKGROUND_VAR = "--vscode-input-background"; export const VSC_BACKGROUND_VAR = "--vscode-sideBar-background"; export const VSC_FOREGROUND_VAR = "--vscode-editor-foreground"; +export const VSC_FOREGROUND_MUTED_VAR = "--vscode-foreground-muted"; +export const VSC_DESCRIPTION_FOREGROUND = "--vscode-descriptionForeground"; +export const VSC_INPUT_PLACEHOLDER_FOREGROUND = + "--vscode-input-placeholderForeground"; export const VSC_BUTTON_BACKGROUND_VAR = "--vscode-button-background"; export const VSC_BUTTON_FOREGROUND_VAR = "--vscode-button-foreground"; export const VSC_EDITOR_BACKGROUND_VAR = "--vscode-editor-background"; @@ -27,6 +31,9 @@ export const VSC_THEME_COLOR_VARS = [ VSC_INPUT_BACKGROUND_VAR, VSC_BACKGROUND_VAR, VSC_FOREGROUND_VAR, + VSC_FOREGROUND_MUTED_VAR, + VSC_DESCRIPTION_FOREGROUND, + VSC_INPUT_PLACEHOLDER_FOREGROUND, VSC_BUTTON_BACKGROUND_VAR, VSC_BUTTON_FOREGROUND_VAR, VSC_EDITOR_BACKGROUND_VAR, @@ -51,6 +58,9 @@ export const vscInputBackground = `var(${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45 export const vscQuickInputBackground = `var(${VSC_QUICK_INPUT_BACKGROUND_VAR}, ${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45))`; export const vscBackground = `var(${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; export const vscForeground = `var(${VSC_FOREGROUND_VAR}, #fff)`; +export const vscForegroundMuted = `var(${VSC_FOREGROUND_MUTED_VAR}, #999)`; +export const vscDescriptionForeground = `var(${VSC_DESCRIPTION_FOREGROUND}, #999)`; +export const vscInputPlaceholderForeground = `var(${VSC_INPUT_PLACEHOLDER_FOREGROUND}, #999)`; export const vscButtonBackground = `var(${VSC_BUTTON_BACKGROUND_VAR}, #1bbe84)`; export const vscButtonForeground = `var(${VSC_BUTTON_FOREGROUND_VAR}, #ffffff)`; export const vscEditorBackground = `var(${VSC_EDITOR_BACKGROUND_VAR}, ${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; diff --git a/gui/src/components/indexing/IndexingStatuses.tsx b/gui/src/components/indexing/IndexingStatuses.tsx index 7441212f9..61bf102a9 100644 --- a/gui/src/components/indexing/IndexingStatuses.tsx +++ b/gui/src/components/indexing/IndexingStatuses.tsx @@ -34,20 +34,19 @@ function IndexingStatuses() { Manage your documentation sources {/*
*/} - {docsStatuses.length ? ( - docsStatuses.map((status) => { - return ; - }) - ) : ( - { - dispatch(setShowDialog(true)); - dispatch(setDialogMessage()); - }} - > - Add Docs - - )} + {docsStatuses.length + ? docsStatuses.map((status) => { + return ; + }) + : null} + { + dispatch(setShowDialog(true)); + dispatch(setDialogMessage()); + }} + > + Add Docs +
//
); diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index f021c748b..3b3642d6b 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -46,8 +46,15 @@ module.exports = { "vsc-badge-background": "var(--vscode-badge-background, #1bbe84)", "vsc-badge-foreground": "var(--vscode-badge-foreground, #fff)", "vsc-sidebar-border": "var(--vscode-sideBar-border, transparent)", - "vsc-find-match": "var(--vscode-editor-findMatchBackground, rgba(255, 255, 0, 0.6))", - "vsc-find-match-selected": "var(--vscode-editor-findMatchHighlightBackground, rgba(255, 223, 0, 0.8))", + "vsc-find-match": + "var(--vscode-editor-findMatchBackground, rgba(255, 255, 0, 0.6))", + "vsc-find-match-selected": + "var(--vscode-editor-findMatchHighlightBackground, rgba(255, 223, 0, 0.8))", + "vsc-foreground-muted": "var(--vscode-foreground-muted, #999)", + "vsc-description-foreground": + "var(--vscode-descriptionForeground, #999)", + "vsc-input-placeholder-foreground": + "var(--vscode-input-placeholderForeground, #999)", }, }, }, From 8a4118db1dc2186cbc4ab2ab678033e466962405 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 21 Nov 2024 18:23:17 -0800 Subject: [PATCH 08/73] improve styling of add to file btn --- gui/src/pages/Edit/AddFileButton.tsx | 10 ++++------ gui/src/pages/Edit/CodeToEdit.tsx | 2 +- gui/src/pages/Edit/CodeToEditListItem.tsx | 5 +++-- manual-testing-sandbox/testCalculator.js | 0 4 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 manual-testing-sandbox/testCalculator.js diff --git a/gui/src/pages/Edit/AddFileButton.tsx b/gui/src/pages/Edit/AddFileButton.tsx index 2f9e0f0dd..7fd7e7768 100644 --- a/gui/src/pages/Edit/AddFileButton.tsx +++ b/gui/src/pages/Edit/AddFileButton.tsx @@ -29,7 +29,7 @@ export default function AddFileButton() {
-
+
- + Add all open files diff --git a/gui/src/pages/Edit/CodeToEdit.tsx b/gui/src/pages/Edit/CodeToEdit.tsx index 26cb145d4..9de5847c3 100644 --- a/gui/src/pages/Edit/CodeToEdit.tsx +++ b/gui/src/pages/Edit/CodeToEdit.tsx @@ -57,7 +57,7 @@ export default function WorkingSet() {
{hasCodeToEdit && ( -
    +
      {codeToEditItems}
    )} diff --git a/gui/src/pages/Edit/CodeToEditListItem.tsx b/gui/src/pages/Edit/CodeToEditListItem.tsx index 8d84ef34b..c7cb46ff5 100644 --- a/gui/src/pages/Edit/CodeToEditListItem.tsx +++ b/gui/src/pages/Edit/CodeToEditListItem.tsx @@ -53,7 +53,7 @@ export default function CodeToEditListItem({ return (
  • setShowCodeSnippet((showCodeSnippet) => !showCodeSnippet)} >
    -
    +
    { e.stopPropagation(); @@ -98,6 +98,7 @@ export default function CodeToEditListItem({ />
    + {showCodeSnippet && (
    diff --git a/manual-testing-sandbox/testCalculator.js b/manual-testing-sandbox/testCalculator.js deleted file mode 100644 index e69de29bb..000000000 From 8e56613cf779e4a258596ad0e6ce6633b9c0f64a Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 21 Nov 2024 17:03:55 -0800 Subject: [PATCH 09/73] 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 5a8237407748df0ea7397201cf74036915411010 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 21 Nov 2024 18:53:33 -0800 Subject: [PATCH 10/73] add keyboard shortcuts to accept/reject --- extensions/vscode/src/commands.ts | 10 ++++++++-- .../StepContainer/AcceptRejectAllButtons.tsx | 5 +++-- gui/src/pages/Edit/CodeToEdit.tsx | 18 +++++++++--------- gui/src/pages/Edit/CodeToEditListItem.tsx | 5 ++++- .../{test.java => Calculator.java} | 1 + 5 files changed, 25 insertions(+), 14 deletions(-) rename manual-testing-sandbox/{test.java => Calculator.java} (99%) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 43115ae93..f41a308ae 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -218,10 +218,16 @@ async function processDiff( } else if (fullPath) { fullPath = getFullyQualifiedPath(ide, fullPath); } else { - console.warn(`Unable to resolve filepath: ${newFilepath}`); + const curFile = await ide.getCurrentFile(); + fullPath = curFile?.path; } - if (!fullPath) return; + if (!fullPath) { + console.warn( + `Unable to resolve filepath while attempting to resolve diff: ${newFilepath}`, + ); + return; + } await ide.openFile(fullPath); diff --git a/gui/src/components/StepContainer/AcceptRejectAllButtons.tsx b/gui/src/components/StepContainer/AcceptRejectAllButtons.tsx index d8a17ec8a..632468a65 100644 --- a/gui/src/components/StepContainer/AcceptRejectAllButtons.tsx +++ b/gui/src/components/StepContainer/AcceptRejectAllButtons.tsx @@ -2,6 +2,7 @@ import { useContext } from "react"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { ApplyState } from "core"; +import { getMetaKeyLabel } from "../../util"; export interface AcceptRejectAllButtonsProps { pendingApplyStates: ApplyState[]; @@ -37,7 +38,7 @@ export default function AcceptRejectAllButtons({ > {hasSinglePendingApplyStates ? ( - Reject + Reject ({getMetaKeyLabel()}⇧⌫) ) : ( <> Reject @@ -52,7 +53,7 @@ export default function AcceptRejectAllButtons({ > {hasSinglePendingApplyStates ? ( - Accept + Accept ({getMetaKeyLabel()}⇧⏎) ) : ( <> Accept diff --git a/gui/src/pages/Edit/CodeToEdit.tsx b/gui/src/pages/Edit/CodeToEdit.tsx index 9de5847c3..4197488fc 100644 --- a/gui/src/pages/Edit/CodeToEdit.tsx +++ b/gui/src/pages/Edit/CodeToEdit.tsx @@ -11,16 +11,16 @@ import AddFileButton from "./AddFileButton"; export default function WorkingSet() { const dispatch = useDispatch(); const ideMessenger = useContext(IdeMessengerContext); - const editModeState = useSelector((state: RootState) => state.editModeState); - - const hasCodeToEdit = editModeState.codeToEdit.length > 0; + const codeToEdit = useSelector( + (state: RootState) => state.editModeState.codeToEdit, + ); const title = - editModeState.codeToEdit.length === 0 + codeToEdit.length === 0 ? "Code to edit" - : editModeState.codeToEdit.length === 1 + : codeToEdit.length === 1 ? "Code to edit (1 item)" - : `Code to edit (${editModeState.codeToEdit.length} items)`; + : `Code to edit (${codeToEdit.length} items)`; function onDelete(rif: RangeInFileWithContents) { dispatch(removeCodeToEdit(rif)); @@ -38,7 +38,7 @@ export default function WorkingSet() { } } - const codeToEditItems = [...editModeState.codeToEdit] + const codeToEditItems = [...codeToEdit] .reverse() .map((code, i) => ( -
    +
    {title}
    - {hasCodeToEdit && ( + {codeToEdit.length > 0 && (
      {codeToEditItems}
    diff --git a/gui/src/pages/Edit/CodeToEditListItem.tsx b/gui/src/pages/Edit/CodeToEditListItem.tsx index c7cb46ff5..e672b8f89 100644 --- a/gui/src/pages/Edit/CodeToEditListItem.tsx +++ b/gui/src/pages/Edit/CodeToEditListItem.tsx @@ -40,7 +40,10 @@ export default function CodeToEditListItem({ let title = filepath; if ("range" in code) { - title += ` (${code.range.start.line + 1} - ${code.range.end.line + 1})`; + const start = code.range.start.line + 1; + const end = code.range.end.line + 1; + title += + start === end ? ` - Inserting at line ${start}` : ` (${start} - ${end})`; } const source = diff --git a/manual-testing-sandbox/test.java b/manual-testing-sandbox/Calculator.java similarity index 99% rename from manual-testing-sandbox/test.java rename to manual-testing-sandbox/Calculator.java index 0f22df25a..b9b9147e9 100644 --- a/manual-testing-sandbox/test.java +++ b/manual-testing-sandbox/Calculator.java @@ -11,6 +11,7 @@ public class Calculator { return this; } + public double getResult() { return result; } From ef26b7c80eb0cc503017df8b9abd634f868a9b89 Mon Sep 17 00:00:00 2001 From: liuk Date: Fri, 22 Nov 2024 18:25:44 +0800 Subject: [PATCH 11/73] fix: Clipboard is not available in chat window --- gui/src/components/mainInput/TipTapEditor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index bde052274..7737e5f25 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -598,7 +598,7 @@ function TipTapEditor(props: TipTapEditorProps) { if (isOSREnabled) { handleJetBrainsOSRMetaKeyIssues(e, editor); - } else { + } else if (!isJetBrains()){ await handleVSCMetaKeyIssues(e, editor); } }; From 504c0c3843e5388fcd661f9755be9b174e9ef334 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 22 Nov 2024 02:51:34 -0800 Subject: [PATCH 12/73] autodetect docs v1 --- core/config/ProfileLifecycleManager.ts | 2 - core/config/load.ts | 1 + core/core.ts | 6 + core/index.d.ts | 2 + core/indexing/docs/suggestions/index.ts | 39 +- .../suggestions/packageCrawlers/Python.ts | 2 +- core/protocol/core.ts | 1 - core/protocol/webview.ts | 4 +- gui/src/components/dialogs/AddDocsDialog.tsx | 479 ++++++++++-------- gui/src/components/dialogs/index.tsx | 2 +- .../components/indexing/ChatIndexingPeeks.tsx | 2 +- .../components/indexing/DocsIndexingPeeks.tsx | 76 +++ .../components/indexing/IndexingStatuses.tsx | 41 +- 13 files changed, 396 insertions(+), 261 deletions(-) create mode 100644 gui/src/components/indexing/DocsIndexingPeeks.tsx diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index 85116f213..8d44c8bac 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -1,5 +1,3 @@ -import { config } from "dotenv"; - import { BrowserSerializedContinueConfig, ContinueConfig, diff --git a/core/config/load.ts b/core/config/load.ts index b692b36bf..9911c840f 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -527,6 +527,7 @@ function finalToBrowserConfig( embeddingsProvider: final.embeddingsProvider?.id, ui: final.ui, experimental: final.experimental, + docs: final.docs, }; } diff --git a/core/core.ts b/core/core.ts index b2be3478c..331ffbe85 100644 --- a/core/core.ts +++ b/core/core.ts @@ -735,6 +735,10 @@ export class Core { return this.docsService.initStatuses(); }); on("docs/getSuggestedDocs", async (msg) => { + if (hasRequestedDocs) { + return; + } // TODO, remove, hack because of rerendering + hasRequestedDocs = true; const suggestedDocs = await getAllSuggestedDocs(this.ide); this.messenger.send("docs/suggestions", suggestedDocs); }); @@ -842,3 +846,5 @@ export class Core { // private } + +let hasRequestedDocs = false; diff --git a/core/index.d.ts b/core/index.d.ts index 5541584eb..35c072bdb 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1189,6 +1189,7 @@ export interface BrowserSerializedContinueConfig { reranker?: RerankerDescription; experimental?: ExperimentalConfig; analytics?: AnalyticsConfig; + docs?: SiteIndexingConfig[]; } // DOCS SUGGESTIONS AND PACKAGE INFO @@ -1210,6 +1211,7 @@ export type ParsedPackageInfo = { export type PackageDetails = { docsLink?: string; + docsLinkWarning?: string; title?: string; description?: string; repo?: string; diff --git a/core/indexing/docs/suggestions/index.ts b/core/indexing/docs/suggestions/index.ts index 4e0c2104a..db192489a 100644 --- a/core/indexing/docs/suggestions/index.ts +++ b/core/indexing/docs/suggestions/index.ts @@ -63,9 +63,10 @@ export async function getAllSuggestedDocs(ide: IDE) { ); // Parse package files and build map of language -> packages - const packagesByRegistry: Record = {}; + const packagesByCrawler: Record = {}; PACKAGE_CRAWLERS.forEach((Crawler) => { const crawler = new Crawler(); + packagesByCrawler[crawler.packageRegistry] = []; const packageFiles = packageFilesByRegistry[crawler.packageRegistry]; packageFiles.forEach((file) => { const contents = fileContents.get(file.path); @@ -73,10 +74,7 @@ export async function getAllSuggestedDocs(ide: IDE) { return; } const packages = crawler.parsePackageFile(file, contents); - if (!packagesByRegistry[crawler.packageRegistry]) { - packagesByRegistry[crawler.packageRegistry] = []; - } - packagesByRegistry[crawler.packageRegistry].push(...packages); + packagesByCrawler[crawler.packageRegistry].push(...packages); }); }); @@ -84,13 +82,13 @@ export async function getAllSuggestedDocs(ide: IDE) { // TODO - this is where you would allow docs for different versions // by e.g. using "name-version" as the map key instead of just name // For now have not allowed - const languages = Object.keys(packagesByRegistry); - languages.forEach((language) => { - const packages = packagesByRegistry[language]; + const registries = Object.keys(packagesByCrawler); + registries.forEach((registry) => { + const packages = packagesByCrawler[registry]; const uniquePackages = Array.from( new Map(packages.map((pkg) => [pkg.name, pkg])).values(), ); - packagesByRegistry[language] = uniquePackages; + packagesByCrawler[registry] = uniquePackages; }); // Get documentation links for all packages @@ -98,7 +96,7 @@ export async function getAllSuggestedDocs(ide: IDE) { await Promise.all( PACKAGE_CRAWLERS.map(async (Crawler) => { const crawler = new Crawler(); - const packages = packagesByRegistry[crawler.packageRegistry]; + const packages = packagesByCrawler[crawler.packageRegistry]; const docsByRegistry = await Promise.all( packages.map(async (packageInfo) => { try { @@ -114,6 +112,11 @@ export async function getAllSuggestedDocs(ide: IDE) { details: { ...details, docsLink: details.docsLink, + docsLinkWarning: details.docsLink.includes("github.com") + ? "Github docs not supported, find the docs site" + : details.docsLink.includes("docs") + ? undefined + : "May not be a docs site, check the URL", }, }; } catch (error) { @@ -129,19 +132,3 @@ export async function getAllSuggestedDocs(ide: IDE) { ); return allDocsResults; } - -// write me an interface PackageCrawler that contains: -// 1. property `language` to store a given language like "python" or "typescript" -// 2. has a method `getPackageFiles` which takes a list of file names and decides which ones match package/dependency files (e.g. package.json for typescript, requirements.txt for python, etc) -// 3. has a method `parsePackageFile` which returns a list of package name and version from a relevant package file, in a standardized format like semver -// 4. has a method `getDocumentationLink` to check for documentation link for a given package (e.g. GET `https://registry.npmjs.org/` and find docs field for typescript, documentation link in the package metadata for PyPi, etc.) -// Then, write typescript classes to implement this typescript interface for the languages "python" and "typescript" - -// I want to present the user with a list of dependencies and allow them to select which ones to index (embed) documentation for. -// In order to prevent duplicate file reads, the process will be like this: -// 1. take in a list of filepaths called `filepaths` -// 2. loop an array of PackageCrawler classes to build a map of `language` (string) to `packageFilePaths` (string[]) -// 3. Get unique filepaths from `packageFilePaths` and build a map ` of filepath to file contents using an existing `readFile` function, and skipping file reads of already in the map -// Finally, -// Add a `` method to the interface and classes that returns -// Then, assemble the classes in an array, and write a function getAllSuggestedDocs that returns a map of `language` to an ar diff --git a/core/indexing/docs/suggestions/packageCrawlers/Python.ts b/core/indexing/docs/suggestions/packageCrawlers/Python.ts index d00045f97..6a486c984 100644 --- a/core/indexing/docs/suggestions/packageCrawlers/Python.ts +++ b/core/indexing/docs/suggestions/packageCrawlers/Python.ts @@ -30,7 +30,7 @@ export class PythonPackageCrawler implements PackageCrawler { .split("\n") .map((line) => { const [name, version] = line.split("=="); - return { name, version, packageFile: file, language: "python" }; + return { name, version, packageFile: file, language: "py" }; }) .filter((pkg) => pkg.name && pkg.version); } diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 069f9e297..f5b04c9cf 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -9,7 +9,6 @@ import type { DiffLine, FileSymbolMap, IdeSettings, - IndexingStatusMap, LLMFullCompletionOptions, MessageContent, ModelDescription, diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index bf90497c8..fb6a8837c 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -2,9 +2,9 @@ import { ConfigValidationError } from "../config/validation.js"; import type { ContextItemWithId, - DocsSuggestions, IndexingProgressUpdate, IndexingStatus, + PackageDocsResult, } from "../index.js"; export type ToWebviewFromIdeOrCoreProtocol = { @@ -26,5 +26,5 @@ export type ToWebviewFromIdeOrCoreProtocol = { getWebviewHistoryLength: [undefined, number]; signInToControlPlane: [undefined, void]; openDialogMessage: ["account", void]; - "docs/suggestions": [DocsSuggestions, void]; + "docs/suggestions": [PackageDocsResult[], void]; }; diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index ca6a8bceb..0a90a60d2 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -1,12 +1,15 @@ import { CheckCircleIcon, + CheckIcon, ChevronDownIcon, ChevronUpIcon, CodeBracketIcon, + ExclamationTriangleIcon, InformationCircleIcon, LinkIcon, + PlusCircleIcon, } from "@heroicons/react/24/outline"; -import { PackageDocsResult, SiteIndexingConfig } from "core"; +import { IndexingStatus, PackageDocsResult, SiteIndexingConfig } from "core"; import { usePostHog } from "posthog-js/react"; import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; @@ -20,39 +23,79 @@ import { RootState } from "../../redux/store"; import IndexingStatusViewer from "../indexing/IndexingStatus"; import { ToolTip } from "../gui/Tooltip"; +import FileIcon from "../FileIcon"; +import DocsIndexingPeeks from "../indexing/DocsIndexingPeeks"; +import { updateIndexingStatus } from "../../redux/slices/stateSlice"; +import preIndexedDocs from "core/indexing/docs/preIndexedDocs"; function AddDocsDialog() { const posthog = usePostHog(); const dispatch = useDispatch(); - const ref = useRef(null); + const titleRef = useRef(null); + const urlRef = useRef(null); const [title, setTitle] = useState(""); const [startUrl, setStartUrl] = useState(""); const [faviconUrl, setFaviconUrl] = useState(""); - const [isOpen, setIsOpen] = useState(false); - - const [submittedConfig, setSubmittedConfig] = useState(); const ideMessenger = useContext(IdeMessengerContext); const indexingStatuses = useSelector( (store: RootState) => store.state.indexing.statuses, ); + const docsIndexingStatuses: IndexingStatus[] = useMemo(() => { + return Object.values(indexingStatuses).filter( + (status) => status.type === "docs" && status.status === "indexing", + ); + }, [indexingStatuses]); + const docsSuggestions = useSelector( (store: RootState) => store.state.docsSuggestions, ); + const configDocs = useSelector((store: RootState) => store.state.config.docs); + + const sortedDocsSuggestions = useMemo(() => { + const docsFromConfig = configDocs ?? []; + const filtered = docsSuggestions.filter((sug) => { + const startUrl = sug.details?.docsLink; + return ( + !docsFromConfig.find((d) => d.startUrl === startUrl) && + !docsIndexingStatuses.find((s) => s.id === startUrl) && + (startUrl ? !preIndexedDocs[startUrl] : true) + ); + }); + + filtered.sort((a, b) => { + const rank = (result: PackageDocsResult) => { + if (result.error) { + return 2; + } else if (result.details?.docsLinkWarning) { + return 1; + } else { + return 0; + } + }; + return rank(a) - rank(b); + }); + return filtered; + }, [docsSuggestions, configDocs, docsIndexingStatuses]); + const isFormValid = startUrl && title; useLayoutEffect(() => { setTimeout(() => { - if (ref.current) { - ref.current.focus(); + if (titleRef.current) { + titleRef.current.focus(); } }, 100); - }, [ref]); + }, [titleRef]); + const closeDialog = () => { + dispatch(setShowDialog(false)); + dispatch(setDialogMessage(undefined)); + }; function onSubmit(e: any) { e.preventDefault(); @@ -64,220 +107,236 @@ function AddDocsDialog() { ideMessenger.post("context/addDocs", siteIndexingConfig); - setSubmittedConfig(siteIndexingConfig); setTitle(""); setStartUrl(""); setFaviconUrl(""); posthog.capture("add_docs_gui", { url: startUrl }); + + // Optimistic status update + dispatch( + updateIndexingStatus({ + type: "docs", + description: "Initializing", + id: startUrl, + embeddingsProviderId: "mock-embeddings-provider-id", + progress: 0, + status: "indexing", + title, + url: startUrl, + }), + ); } - const handleSelectSuggestion = (docsResult: PackageDocsResult) => {}; + const handleSelectSuggestion = (docsResult: PackageDocsResult) => { + if (docsResult.error) { + setTitle(docsResult.packageInfo.name); + setStartUrl(""); + urlRef.current?.focus(); + return; + } + if (docsResult.details?.docsLinkWarning) { + setTitle(docsResult.packageInfo.name); + setStartUrl(docsResult.details.docsLink); + urlRef.current?.focus(); + return; + } + const siteIndexingConfig: SiteIndexingConfig = { + startUrl: docsResult.details.docsLink, + title: docsResult.details.title, + faviconUrl: undefined, + }; - // if (submittedConfig) { - // const status = indexingStatuses[submittedConfig.startUrl]; - // return ( - //
    - //
    - // - //

    {`Docs added`}

    - //
    - //
    - //

    Title: {submittedConfig.title}

    - //

    Start URL: {submittedConfig.startUrl}

    - // {submittedConfig.rootUrl && ( - //

    Root URL: {submittedConfig.rootUrl}

    - // )} - // {submittedConfig.maxDepth && ( - //

    Max depth: {submittedConfig.maxDepth}

    - // )} - // {submittedConfig.faviconUrl && ( - //

    Favicon URL: {submittedConfig.faviconUrl}

    - // )} - //
    - // {!!status && ( - //
    - //

    {`Type "@docs" and select ${submittedConfig.title} to reference these docs once indexing is complete. Check indexing status from the "More" page.`}

    - //
    - // - //
    - //
    - // )} - //
    - // { - // setSubmittedConfig(undefined); - // }} - // > - // Add another - // - // - //
    - //
    - // ); - // } + ideMessenger.post("context/addDocs", siteIndexingConfig); + + posthog.capture("add_docs_gui", { url: startUrl }); + + // Optimistic status update + dispatch( + updateIndexingStatus({ + type: "docs", + description: "Initializing", + id: docsResult.details.docsLink, + embeddingsProviderId: "mock-embeddings-provider-id", + progress: 0, + status: "indexing", + title: docsResult.details.title ?? docsResult.packageInfo.name, + url: docsResult.details.docsLink, + }), + ); + }; return ( -
    -
    -

    Add documentation

    - {docsSuggestions.length ? ( -
    - - - - - - {/* */} - - - - - - Add docs - {docsSuggestions.map((docsResult) => { - const { error, details } = docsResult; - const { language, name, version } = docsResult.packageInfo; - const id = `${language}-${name}-${version}`; - return ( - - - - {/* */} - - - - ); - })} - -
    - - TitleVersionStart Link
    - - {name}{version} - {error ? ( - - No docs link found - - ) : ( - -
    - -
    -

    - {details.docsLink} -

    -
    - )} -
    - - - -

    {`Version: ${version}`}

    -

    {`Found in ${docsResult.packageInfo.packageFile.path}`}

    -
    -
    -
    - ) : null} -

    - Continue pre-indexes many common documentation sites, but if there's - one you don't see in the dropdown, enter the URL here. -

    - -

    - Continue's indexing engine will crawl the site and generate embeddings - so that you can ask questions. -

    -
    - {/* -
    - - - - -
    setIsOpen((prev) => !prev)} - > - {isOpen ? ( - - ) : ( - - )} - Advanced -
    - - {isOpen && ( -
    - -
    +
    +
    +

    Add documentation

    +

    Add docs

    + {sortedDocsSuggestions.length && ( +

    Suggestions

    )} - -
    - +
    + {sortedDocsSuggestions.map((docsResult) => { + const { error, details } = docsResult; + const { language, name, version } = docsResult.packageInfo; + const id = `${language}-${name}-${version}`; + return ( + <> +
    { + handleSelectSuggestion(docsResult); + }} + > +
    + {error ? ( +
    + + + Docs URL not found + +
    + ) : details.docsLinkWarning ? ( +
    + + + Start URL might not lead to docs + +
    + ) : ( + + )} +
    +
    +
    + +
    + {name} +
    +
    + {error ? ( + + No docs link found + + ) : ( +
    + {/*
    + +
    */} +

    + {details.docsLink} +

    +
    + )} +
    +
    + + +

    {`Version: ${version}`}

    +

    {`Found in ${docsResult.packageInfo.packageFile.path}`}

    +
    +
    +
    + + {error ? "Add to form" : "Index these docs"} + + + ); + })}
    - */} +
    +
    +
    + + + +
    +
    + + Done + + +
    +
    +
    +
    + + +
    +
    + {docsIndexingStatuses.length ? ( +

    + It is safe to close this form while indexing +

    + ) : null} +
    +
    ); } diff --git a/gui/src/components/dialogs/index.tsx b/gui/src/components/dialogs/index.tsx index 7685109ba..8a3a67fe8 100644 --- a/gui/src/components/dialogs/index.tsx +++ b/gui/src/components/dialogs/index.tsx @@ -71,7 +71,7 @@ const TextDialog = (props: TextDialogProps) => { return (
)} + + {showAddFileCombobox && ( +
+
+ setShowAddFileCombobox(false)} + /> +
+ { + setShowAddFileCombobox(false); + }} + className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground mb-2 h-3.5 w-3.5 cursor-pointer rounded-md rounded-sm p-0.5 hover:bg-opacity-20" + /> +
+ )}
); } diff --git a/gui/src/redux/slices/editModeState.ts b/gui/src/redux/slices/editModeState.ts index 489bc7b41..79db2a804 100644 --- a/gui/src/redux/slices/editModeState.ts +++ b/gui/src/redux/slices/editModeState.ts @@ -24,13 +24,21 @@ export const editModeStateSlice = createSlice({ name: "editModeState", initialState, reducers: { - addCodeToEdit: (state, { payload }: PayloadAction) => { - const entryExists = state.codeToEdit.some((entry) => - isCodeToEditEqual(entry, payload), + addCodeToEdit: ( + state, + { payload }: PayloadAction, + ) => { + const entries = Array.isArray(payload) ? payload : [payload]; + + const newEntries = entries.filter( + (entry) => + !state.codeToEdit.some((existingEntry) => + isCodeToEditEqual(existingEntry, entry), + ), ); - if (!entryExists) { - state.codeToEdit.push(payload); + if (newEntries.length > 0) { + state.codeToEdit.push(...newEntries); } }, focusEdit: (state) => { diff --git a/gui/src/redux/slices/uiStateSlice.ts b/gui/src/redux/slices/uiStateSlice.ts index 9a13415d3..f952b5fc9 100644 --- a/gui/src/redux/slices/uiStateSlice.ts +++ b/gui/src/redux/slices/uiStateSlice.ts @@ -43,12 +43,6 @@ export const uiStateSlice = createSlice({ setShowDialog: (state, action: PayloadAction) => { state.showDialog = action.payload; }, - setShouldAddFileForEditing: ( - state, - action: PayloadAction, - ) => { - state.shouldAddFileForEditing = action.payload; - }, }, }); @@ -57,7 +51,6 @@ export const { setDialogMessage, setDialogEntryOn, setShowDialog, - setShouldAddFileForEditing, } = uiStateSlice.actions; export default uiStateSlice.reducer; From b3abfb80d71c16a0e51cc980d4262dbd218d6463 Mon Sep 17 00:00:00 2001 From: Test Date: Mon, 25 Nov 2024 22:58:06 -0800 Subject: [PATCH 65/73] fix: revert launch.json change --- .vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0e12bdfb3..dfe474f40 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,8 @@ "cwd": "${workspaceFolder}/extensions/vscode", "args": [ // Pass a directory to manually test in - "${workspaceFolder}/gui", - "${workspaceFolder}/gui/src/App.tsx", + "${workspaceFolder}/manual-testing-sandbox", + "${workspaceFolder}/manual-testing-sandbox/test.js", "--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode" ], "pauseForSourceMap": false, From 78c8631233cb6d542ac1a212a267a7e800bb1f67 Mon Sep 17 00:00:00 2001 From: Wouter Tichelaar Date: Tue, 26 Nov 2024 10:16:45 +0200 Subject: [PATCH 66/73] Update dbinfoz to 0.14.0 --- core/package-lock.json | 485 +++++++++++++++++++++++++++- core/package.json | 2 +- extensions/vscode/package-lock.json | 327 ++++++++++++++++--- extensions/vscode/package.json | 2 +- 4 files changed, 762 insertions(+), 54 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index 09e22ce96..a53a1a49c 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.11.0", + "dbinfoz": "^0.14.0", "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", @@ -1229,6 +1229,241 @@ } } }, + "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", @@ -3855,6 +4090,11 @@ "@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", @@ -4814,6 +5054,11 @@ "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", @@ -5085,6 +5330,20 @@ "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", @@ -6273,7 +6532,6 @@ "url": "https://feross.org/support" } ], - "optional": true, "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" @@ -6965,10 +7223,11 @@ } }, "node_modules/dbinfoz": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.11.0.tgz", - "integrity": "sha512-l7REBd9pwTBI6PWSk/dx+zCpSE2tiJdSKfApeoOajnSgyMJgkwGfhpPO2mV76MLQeKPaSm0mMKxmoqd38SaHmw==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.14.0.tgz", + "integrity": "sha512-8NLjmj3gEyxbMu1ZwPEby77QvoEkk5NrHKSwX4oSKeaREherwuSx1y08cXmxBEjrSmvByUX9axoKscuilSXfmg==", "dependencies": { + "mssql": "^11.0.1", "mysql2": "^3.9.1", "pg": "^8.11.3", "sqlite3": "^5.1.7" @@ -7061,6 +7320,14 @@ "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", @@ -9373,6 +9640,20 @@ "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", @@ -9577,6 +9858,17 @@ "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", @@ -10559,6 +10851,11 @@ "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", @@ -10723,6 +11020,46 @@ "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", @@ -10888,6 +11225,36 @@ "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", @@ -10899,6 +11266,11 @@ "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", @@ -11288,6 +11660,33 @@ "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", @@ -11340,6 +11739,11 @@ "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", @@ -11798,6 +12202,22 @@ "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", @@ -12513,7 +12933,6 @@ "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" } @@ -12875,7 +13294,6 @@ "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", @@ -13148,6 +13566,11 @@ "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", @@ -13711,6 +14134,15 @@ "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", @@ -14083,6 +14515,45 @@ "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 e95c66509..91652280a 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.11.0", + "dbinfoz": "^0.14.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 742211fb0..e0bc72e92 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -18,7 +18,7 @@ "axios": "^1.2.5", "core": "file:../../core", "cors": "^2.8.5", - "dbinfoz": "^0.11.0", + "dbinfoz": "^0.14.0", "downshift": "^7.6.0", "esbuild": "^0.17.19", "express": "^4.18.2", @@ -109,7 +109,6 @@ "cheerio": "^1.0.0-rc.12", "commander": "^12.0.0", "comment-json": "^4.2.3", - "dbinfoz": "^0.14.0", "diff": "^7.0.0", "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", @@ -246,7 +245,6 @@ "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" }, @@ -258,7 +256,6 @@ "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", @@ -272,7 +269,6 @@ "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", @@ -286,11 +282,48 @@ "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", @@ -309,7 +342,6 @@ "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" }, @@ -321,7 +353,6 @@ "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" @@ -334,7 +365,6 @@ "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", @@ -355,11 +385,50 @@ "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" }, @@ -371,7 +440,6 @@ "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" }, @@ -383,7 +451,6 @@ "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" } @@ -392,7 +459,6 @@ "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", @@ -406,7 +472,6 @@ "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" } @@ -1204,6 +1269,11 @@ "@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", @@ -1765,6 +1835,11 @@ "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", @@ -2035,6 +2110,20 @@ "@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", @@ -2751,6 +2840,17 @@ "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", @@ -3299,8 +3399,7 @@ "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==", - "dev": true + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, "node_modules/bytes": { "version": "3.1.2", @@ -4215,10 +4314,11 @@ } }, "node_modules/dbinfoz": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.11.0.tgz", - "integrity": "sha512-l7REBd9pwTBI6PWSk/dx+zCpSE2tiJdSKfApeoOajnSgyMJgkwGfhpPO2mV76MLQeKPaSm0mMKxmoqd38SaHmw==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/dbinfoz/-/dbinfoz-0.14.0.tgz", + "integrity": "sha512-8NLjmj3gEyxbMu1ZwPEby77QvoEkk5NrHKSwX4oSKeaREherwuSx1y08cXmxBEjrSmvByUX9axoKscuilSXfmg==", "dependencies": { + "mssql": "^11.0.1", "mysql2": "^3.9.1", "pg": "^8.11.3", "sqlite3": "^5.1.7" @@ -4347,7 +4447,6 @@ "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" } @@ -4565,7 +4664,6 @@ "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" } @@ -5095,6 +5193,14 @@ "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", @@ -5104,7 +5210,6 @@ "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" } @@ -6532,7 +6637,6 @@ "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" }, @@ -6658,7 +6762,6 @@ "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" }, @@ -6712,6 +6815,11 @@ "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", @@ -6907,7 +7015,6 @@ "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", @@ -6929,7 +7036,6 @@ "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", @@ -6940,7 +7046,6 @@ "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" @@ -6975,7 +7080,6 @@ "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", @@ -6986,7 +7090,6 @@ "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" @@ -7100,38 +7203,32 @@ "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==", - "dev": true + "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==", - "dev": true + "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==", - "dev": true + "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==", - "dev": true + "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==", - "dev": true + "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==", - "dev": true + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" }, "node_modules/lodash.merge": { "version": "4.6.2", @@ -7142,8 +7239,7 @@ "node_modules/lodash.once": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", - "dev": true + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" }, "node_modules/log-symbols": { "version": "4.1.0", @@ -8247,6 +8343,33 @@ "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", @@ -8323,6 +8446,11 @@ "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", @@ -8850,7 +8978,6 @@ "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", @@ -9642,6 +9769,14 @@ "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", @@ -10320,6 +10455,11 @@ "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", @@ -10986,7 +11126,6 @@ "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" @@ -11424,6 +11563,14 @@ "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", @@ -11439,6 +11586,91 @@ "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.10.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.0.tgz", + "integrity": "sha512-XC70cRZVElFHfIUB40FgZOBbgJYFKKMa5nb9lxcwYstFG/Mi+/Y0bGS+rs6Dmhmkpq4pnNiLiuZAbc02YCOnmA==", + "dependencies": { + "undici-types": "~6.20.0" + } + }, + "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", @@ -11746,6 +11978,11 @@ "node": ">=18.17" } }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==" + }, "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 355f8ab92..919804f1b 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -651,7 +651,7 @@ "axios": "^1.2.5", "core": "file:../../core", "cors": "^2.8.5", - "dbinfoz": "^0.11.0", + "dbinfoz": "^0.14.0", "downshift": "^7.6.0", "esbuild": "^0.17.19", "express": "^4.18.2", From 4ba41cc4c46770fcc547e6c3a7f189df2c33d65e Mon Sep 17 00:00:00 2001 From: Wouter Tichelaar <9594229+DifferentialityDevelopment@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:51:36 +0200 Subject: [PATCH 67/73] Update jest.config.js --- core/jest.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/jest.config.js b/core/jest.config.js index 2567c5891..b92d03e5e 100644 --- a/core/jest.config.js +++ b/core/jest.config.js @@ -8,6 +8,8 @@ export default { moduleNameMapper: { "^(\\.{1,2}/.*)\\.js$": "$1", "^uuid$": "uuid", // https://stackoverflow.com/a/73626360 + '^@azure/(.*)$': '/node_modules/@azure/$1', + '^mssql$': '/node_modules/mssql' }, extensionsToTreatAsEsm: [".ts"], preset: "ts-jest/presets/default-esm", From af9f6376f4e7d69103e70c0deae7fc9057c0ee54 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 26 Nov 2024 08:52:05 -0800 Subject: [PATCH 68/73] fix at mention bug --- gui/src/components/mainInput/TipTapEditor.tsx | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 7737e5f25..06743d2d6 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -40,16 +40,20 @@ import { IdeMessengerContext } from "../../context/IdeMessenger"; import { SubmenuContextProvidersContext } from "../../context/SubmenuContextProviders"; import useHistory from "../../hooks/useHistory"; import { useInputHistory } from "../../hooks/useInputHistory"; +import useIsOSREnabled from "../../hooks/useIsOSREnabled"; import useUpdatingRef from "../../hooks/useUpdatingRef"; import { useWebviewListener } from "../../hooks/useWebviewListener"; import { selectUseActiveFile } from "../../redux/selectors"; import { defaultModelSelector } from "../../redux/selectors/modelSelectors"; +import { addCodeToEdit } from "../../redux/slices/editModeState"; +import { setShouldAddFileForEditing } from "../../redux/slices/uiStateSlice"; import { RootState } from "../../redux/store"; import { getFontSize, isJetBrains, isMetaEquivalentKeyPressed, } from "../../util"; +import { AddCodeToEdit } from "./AddCodeToEditExtension"; import { CodeBlockExtension } from "./CodeBlockExtension"; import { SlashCommand } from "./CommandsExtension"; import InputToolbar, { ToolbarOptions } from "./InputToolbar"; @@ -64,10 +68,6 @@ import { handleVSCMetaKeyIssues, } from "./handleMetaKeyIssues"; import { ComboBoxItem } from "./types"; -import useIsOSREnabled from "../../hooks/useIsOSREnabled"; -import { setShouldAddFileForEditing } from "../../redux/slices/uiStateSlice"; -import { AddCodeToEdit } from "./AddCodeToEditExtension"; -import { addCodeToEdit } from "../../redux/slices/editModeState"; const InputBoxDiv = styled.div<{ border?: string }>` resize: none; @@ -459,25 +459,23 @@ function TipTapEditor(props: TipTapEditorProps) { }, }), Text, - props.availableContextProviders.length - ? Mention.configure({ - HTMLAttributes: { - class: "mention", - }, - suggestion: getContextProviderDropdownOptions( - availableContextProvidersRef, - getSubmenuContextItemsRef, - enterSubmenu, - onClose, - onOpen, - inSubmenuRef, - ideMessenger, - ), - renderHTML: (props) => { - return `@${props.node.attrs.label || props.node.attrs.id}`; - }, - }) - : undefined, + Mention.configure({ + HTMLAttributes: { + class: "mention", + }, + suggestion: getContextProviderDropdownOptions( + availableContextProvidersRef, + getSubmenuContextItemsRef, + enterSubmenu, + onClose, + onOpen, + inSubmenuRef, + ideMessenger, + ), + renderHTML: (props) => { + return `@${props.node.attrs.label || props.node.attrs.id}`; + }, + }), isInEditMode ? AddCodeToEdit.configure({ HTMLAttributes: { @@ -598,7 +596,7 @@ function TipTapEditor(props: TipTapEditorProps) { if (isOSREnabled) { handleJetBrainsOSRMetaKeyIssues(e, editor); - } else if (!isJetBrains()){ + } else if (!isJetBrains()) { await handleVSCMetaKeyIssues(e, editor); } }; From e87bfbe36fe1d53852a8d47150cdcda75bf9a9c3 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 26 Nov 2024 09:21:46 -0800 Subject: [PATCH 69/73] chore: inline edit list items --- gui/src/pages/edit/CodeToEdit.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gui/src/pages/edit/CodeToEdit.tsx b/gui/src/pages/edit/CodeToEdit.tsx index f4fe00a7a..659255942 100644 --- a/gui/src/pages/edit/CodeToEdit.tsx +++ b/gui/src/pages/edit/CodeToEdit.tsx @@ -56,15 +56,6 @@ export default function WorkingSet() { } } - const codeToEditItems = codeToEdit.map((code, i) => ( - - )); - return (
@@ -74,7 +65,14 @@ export default function WorkingSet() { {codeToEdit.length > 0 && (
    - {codeToEditItems} + {codeToEdit.map((code, i) => ( + + ))}
)} From 79471a45d6c7d9d891556feb110d51a35263a6c7 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 26 Nov 2024 09:22:23 -0800 Subject: [PATCH 70/73] chore: remove husky --- .husky/pre-commit | 1 - package.json | 4 ---- 2 files changed, 5 deletions(-) delete mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index d59df2ef6..000000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -npx prettier --write . \ No newline at end of file diff --git a/package.json b/package.json index e5dbe76f2..3009e5d12 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,7 @@ "devDependencies": { "@typescript-eslint/parser": "^7.8.0", "eslint-plugin-import": "^2.29.1", - "husky": "^9.1.7", "prettier": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.8" - }, - "scripts": { - "prepare": "husky" } } From 192b9327ad0f57cc7350a81b1ee069531cfdc90e Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 26 Nov 2024 09:25:55 -0800 Subject: [PATCH 71/73] chore: shorten tiptap placeholder text --- gui/src/components/mainInput/TipTapEditor.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 06743d2d6..5da0eea86 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -313,16 +313,6 @@ function TipTapEditor(props: TipTapEditorProps) { const { prevRef, nextRef, addRef } = useInputHistory(props.historyKey); - function getPlaceholder() { - if (!hasDefaultModel) { - return "Configure a Chat model to get started"; - } - - return historyLengthRef.current === 0 - ? "Ask anything, '/' for slash commands, '@' to add context" - : "Ask a follow-up"; - } - const editor: Editor = useEditor({ extensions: [ Document, @@ -366,7 +356,7 @@ function TipTapEditor(props: TipTapEditorProps) { placeholder: props.placeholder ?? (historyLengthRef.current === 0 - ? "Ask anything, '/' for slash commands, '@' to add context" + ? "Ask anything, '@' to add context" : "Ask a follow-up"), }), Paragraph.extend({ From 0240c7bceccbda4e71d8994138f6773d30d04841 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 26 Nov 2024 09:28:36 -0800 Subject: [PATCH 72/73] bump package.json --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 355f8ab92..d9cda68e7 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.235", + "version": "0.9.236", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From aac6f805eb35107e7d8754413d955ccfeb964576 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 26 Nov 2024 12:09:41 -0800 Subject: [PATCH 73/73] fix: use new edit for "Generate code" cmd --- extensions/vscode/package.json | 2 +- extensions/vscode/src/commands.ts | 73 +++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index d9cda68e7..278f9f5f0 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -176,7 +176,7 @@ "group": "Continue" }, { - "command": "continue.quickEdit", + "command": "continue.focusEdit", "category": "Continue", "title": "Generate Code", "group": "Continue" diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index f41a308ae..5c97cf281 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -93,19 +93,44 @@ function addCodeToContextFromRange( }); } -function getCurrentlyHighlightedCode( +function getRangeInFileWithContents( allowEmpty?: boolean, + range?: vscode.Range, ): RangeInFileWithContents | null { const editor = vscode.window.activeTextEditor; + if (editor) { const selection = editor.selection; + const filepath = editor.document.uri.fsPath; + + if (range) { + const contents = editor.document.getText(range); + + return { + range: { + start: { + line: range.start.line, + character: range.start.character, + }, + end: { + line: range.end.line, + character: range.end.character, + }, + }, + filepath, + contents, + }; + } + if (selection.isEmpty && !allowEmpty) { return null; } + // adjust starting position to include indentation const start = new vscode.Position(selection.start.line, 0); - const range = new vscode.Range(start, selection.end); - const contents = editor.document.getText(range); + const selectionRange = new vscode.Range(start, selection.end); + const contents = editor.document.getText(selectionRange); + return { filepath: editor.document.uri.fsPath, contents, @@ -121,13 +146,14 @@ function getCurrentlyHighlightedCode( }, }; } + return null; } async function addHighlightedCodeToContext( webviewProtocol: VsCodeWebviewProtocol | undefined, ) { - const rangeInFileWithContents = getCurrentlyHighlightedCode(); + const rangeInFileWithContents = getRangeInFileWithContents(); if (rangeInFileWithContents) { webviewProtocol?.request("highlightedCode", { rangeInFileWithContents, @@ -375,7 +401,7 @@ const getCommandsMap: ( // Passthrough for telemetry purposes "continue.defaultQuickAction": async (args: QuickEditShowParams) => { captureCommandTelemetry("defaultQuickAction"); - vscode.commands.executeCommand("continue.quickEdit", args); + vscode.commands.executeCommand("continue.focusEdit", args); }, "continue.customQuickActionSendToChat": async ( prompt: string, @@ -467,7 +493,9 @@ const getCommandsMap: ( void addHighlightedCodeToContext(sidebar.webviewProtocol); } }, - "continue.focusEdit": async () => { + // QuickEditShowParams are passed from CodeLens, temp fix + // until we update to new params specific to Edit + "continue.focusEdit": async (args?: QuickEditShowParams) => { captureCommandTelemetry("focusEdit"); focusGUI(); @@ -489,12 +517,13 @@ const getCommandsMap: ( return; } - editDecorationManager.setDecoration( - editor, - new vscode.Range(editor.selection.start, editor.selection.end), - ); + const range = + args?.range ?? + new vscode.Range(editor.selection.start, editor.selection.end); - const rangeInFileWithContents = getCurrentlyHighlightedCode(true); + editDecorationManager.setDecoration(editor, range); + + const rangeInFileWithContents = getRangeInFileWithContents(true, range); if (rangeInFileWithContents) { sidebar.webviewProtocol?.request( @@ -537,7 +566,7 @@ const getCommandsMap: ( return; } - const rangeInFileWithContents = getCurrentlyHighlightedCode(false); + const rangeInFileWithContents = getRangeInFileWithContents(false); if (rangeInFileWithContents) { sidebar.webviewProtocol?.request( @@ -562,16 +591,16 @@ const getCommandsMap: ( captureCommandTelemetry("exitEditMode"); await sidebar.webviewProtocol?.request("exitEditMode", undefined); }, - "continue.quickEdit": async (args: QuickEditShowParams) => { - let linesOfCode = undefined; - if (args.range) { - linesOfCode = args.range.end.line - args.range.start.line; - } - captureCommandTelemetry("quickEdit", { - linesOfCode, - }); - quickEdit.show(args); - }, + // "continue.quickEdit": async (args: QuickEditShowParams) => { + // let linesOfCode = undefined; + // if (args.range) { + // linesOfCode = args.range.end.line - args.range.start.line; + // } + // captureCommandTelemetry("quickEdit", { + // linesOfCode, + // }); + // quickEdit.show(args); + // }, "continue.writeCommentsForCode": async () => { captureCommandTelemetry("writeCommentsForCode");