From 89a69576bcf8fffbf4bfcaf856b13a3ef097aa81 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 12 May 2024 15:18:23 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20eslint=20enforce=20import=20exte?= =?UTF-8?q?nsions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/.eslintrc.json | 24 ++++++---- core/autocomplete/ast.ts | 4 +- core/autocomplete/cache.ts | 4 +- core/autocomplete/charStream.ts | 6 +-- core/autocomplete/completionProvider.ts | 42 ++++++++--------- core/autocomplete/constructPrompt.ts | 14 +++--- core/autocomplete/languages.ts | 2 +- core/autocomplete/lineStream.ts | 4 +- core/autocomplete/ranking.ts | 6 +-- core/autocomplete/recentlyEdited.ts | 2 +- core/autocomplete/retrieval.ts | 4 +- core/autocomplete/slidingWindow.ts | 4 +- core/autocomplete/templates.ts | 4 +- core/commands/index.ts | 8 ++-- core/commands/slash/cmd.ts | 6 +-- core/commands/slash/comment.ts | 4 +- core/commands/slash/commit.ts | 4 +- core/commands/slash/draftIssue.ts | 6 +-- core/commands/slash/edit.ts | 12 ++--- core/commands/slash/http.ts | 6 +-- core/commands/slash/index.ts | 18 ++++---- core/commands/slash/review.ts | 8 ++-- core/commands/slash/share.ts | 10 ++-- core/commands/slash/stackOverflow.ts | 4 +- core/commands/util.ts | 2 +- core/config/default.ts | 2 +- core/config/handler.ts | 8 ++-- core/config/load.ts | 36 +++++++-------- core/config/onboarding.ts | 2 +- core/config/util.ts | 4 +- core/context/index.ts | 2 +- core/context/providers/CodeContextProvider.ts | 6 +-- .../CodeHighlightsContextProvider.ts | 6 +-- .../providers/CodeOutlineContextProvider.ts | 6 +-- .../providers/CodebaseContextProvider.ts | 6 +-- .../providers/CurrentFileContextProvider.ts | 6 +-- .../providers/CustomContextProvider.ts | 2 +- .../providers/DatabaseContextProvider.ts | 10 ++-- core/context/providers/DiffContextProvider.ts | 4 +- core/context/providers/DocsContextProvider.ts | 8 ++-- core/context/providers/FileContextProvider.ts | 6 +-- .../providers/FileTreeContextProvider.ts | 4 +- .../providers/FolderContextProvider.ts | 6 +-- .../providers/GitHubIssuesContextProvider.ts | 4 +- .../GitLabMergeRequestContextProvider.ts | 34 +++++++------- .../providers/GoogleContextProvider.ts | 4 +- core/context/providers/HttpContextProvider.ts | 4 +- .../JiraIssuesContextProvider/JiraClient.ts | 6 +-- .../JiraIssuesContextProvider/index.ts | 6 +-- core/context/providers/LocalsProvider.ts | 4 +- core/context/providers/OSContextProvider.ts | 4 +- .../providers/OpenFilesContextProvider.ts | 6 +-- .../providers/PostgresContextProvider.ts | 4 +- .../providers/ProblemsContextProvider.ts | 8 ++-- .../providers/SearchContextProvider.ts | 4 +- .../providers/TerminalContextProvider.ts | 4 +- core/context/providers/URLContextProvider.ts | 4 +- core/context/providers/index.ts | 46 +++++++++---------- core/context/rerankers/cohere.ts | 4 +- core/context/rerankers/freeTrial.ts | 6 +-- core/context/rerankers/index.ts | 10 ++-- core/context/rerankers/llm.ts | 4 +- core/context/rerankers/voyage.ts | 2 +- core/context/retrieval/fullTextSearch.ts | 4 +- core/context/retrieval/retrieval.ts | 10 ++-- core/continueServer/interface.ts | 2 +- core/continueServer/stubs/client.ts | 2 +- core/diff/streamDiff.ts | 4 +- core/diff/util.ts | 4 +- core/indexing/CodeSnippetsIndex.ts | 24 +++++----- core/indexing/FullTextSearch.ts | 20 ++++---- core/indexing/LanceDbIndex.ts | 16 +++---- core/indexing/chunk/ChunkCodebaseIndex.ts | 26 +++++------ core/indexing/chunk/basic.ts | 4 +- core/indexing/chunk/chunk.ts | 12 ++--- core/indexing/chunk/code.ts | 6 +-- core/indexing/chunk/markdown.ts | 6 +-- core/indexing/docs/article.ts | 8 ++-- core/indexing/docs/db.ts | 18 ++++---- core/indexing/docs/index.ts | 10 ++-- core/indexing/docs/preIndexed.ts | 4 +- .../embeddings/BaseEmbeddingsProvider.ts | 2 +- .../embeddings/CohereEmbeddingsProvider.ts | 6 +-- .../embeddings/DeepInfraEmbeddingsProvider.ts | 6 +-- .../embeddings/FreeTrialEmbeddingsProvider.ts | 10 ++-- .../embeddings/OllamaEmbeddingsProvider.ts | 6 +-- .../embeddings/OpenAIEmbeddingsProvider.ts | 6 +-- .../TransformersJsEmbeddingsProvider.ts | 2 +- core/indexing/embeddings/index.ts | 12 ++--- core/indexing/indexCodebase.ts | 18 ++++---- core/indexing/refreshIndex.ts | 10 ++-- core/indexing/types.ts | 2 +- core/llm/autodetect.ts | 6 +-- core/llm/constructMessages.ts | 2 +- core/llm/countTokens.ts | 8 ++-- core/llm/index.ts | 20 ++++---- core/llm/llms/Anthropic.ts | 8 ++-- core/llm/llms/Bedrock.ts | 6 +-- core/llm/llms/Cohere.ts | 8 ++-- core/llm/llms/CustomLLM.ts | 4 +- core/llm/llms/DeepInfra.ts | 4 +- core/llm/llms/Flowise.ts | 6 +-- core/llm/llms/FreeTrial.ts | 10 ++-- core/llm/llms/Gemini.ts | 8 ++-- core/llm/llms/Groq.ts | 4 +- core/llm/llms/HuggingFaceInferenceAPI.ts | 6 +-- core/llm/llms/HuggingFaceTGI.ts | 6 +-- core/llm/llms/LMStudio.ts | 4 +- core/llm/llms/LlamaCpp.ts | 6 +-- core/llm/llms/Llamafile.ts | 4 +- core/llm/llms/Mistral.ts | 4 +- core/llm/llms/Ollama.ts | 10 ++-- core/llm/llms/OpenAI.ts | 8 ++-- core/llm/llms/OpenAIFreeTrial.ts | 6 +-- core/llm/llms/Replicate.ts | 4 +- core/llm/llms/TextGenWebUI.ts | 4 +- core/llm/llms/Together.ts | 4 +- core/llm/llms/index.ts | 46 +++++++++---------- core/llm/stream.ts | 2 +- core/llm/templates/chat.ts | 4 +- core/llm/templates/edit.ts | 4 +- core/llm/templates/options.ts | 2 +- core/package.json | 7 ++- core/pnpm-lock.yaml | 13 ++++++ core/protocol.ts | 6 +-- core/test/diff.test.ts | 2 +- core/test/edit.test.ts | 16 +++---- core/test/llm.test.ts | 4 +- core/util/devdata.ts | 2 +- core/util/devdataSqlite.ts | 6 +-- core/util/fetchWithOptions.ts | 2 +- core/util/filesystem.ts | 4 +- core/util/history.ts | 6 +-- core/util/index.ts | 10 ++-- core/util/merge.ts | 2 +- core/util/messageIde.ts | 2 +- core/util/parameters.ts | 2 +- core/util/paths.ts | 6 +-- core/util/ranges.ts | 2 +- core/util/verticalEdit.ts | 12 ++--- core/web/webviewProtocol.ts | 6 +-- 141 files changed, 556 insertions(+), 532 deletions(-) diff --git a/core/.eslintrc.json b/core/.eslintrc.json index 7b666cad6..241f6e48b 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -5,15 +5,23 @@ "ecmaVersion": 6, "sourceType": "module" }, - "plugins": ["@typescript-eslint"], + "extends": ["plugin:require-extensions/recommended"], + "plugins": ["@typescript-eslint", "import", "require-extensions"], "rules": { - "@typescript-eslint/naming-convention": "warn", - "@typescript-eslint/semi": "warn", - "curly": "warn", - "eqeqeq": "warn", - "no-throw-literal": "warn", - "semi": "off" - }, + "quotes": ["warn", "double", {}], + "import/extensions": ["error", "always", { + "js": "never", + "jsx": "never", + "ts": "never", + "tsx": "never" + }], + "@typescript-eslint/naming-convention": "warn", + "@typescript-eslint/semi": "warn", + "curly": "warn", + "eqeqeq": "warn", + "no-throw-literal": "warn", + "semi": "off" + }, "ignorePatterns": ["out", "dist", "**/*.d.ts"] } \ No newline at end of file diff --git a/core/autocomplete/ast.ts b/core/autocomplete/ast.ts index b87539aa5..73afaf313 100644 --- a/core/autocomplete/ast.ts +++ b/core/autocomplete/ast.ts @@ -1,6 +1,6 @@ import Parser from "web-tree-sitter"; -import { RangeInFileWithContents } from "../commands/util"; -import { getParserForFile } from "../util/treeSitter"; +import { RangeInFileWithContents } from "../commands/util.js"; +import { getParserForFile } from "../util/treeSitter.js"; export async function getAst( filepath: string, diff --git a/core/autocomplete/cache.ts b/core/autocomplete/cache.ts index bd9c24d56..a71d7ca90 100644 --- a/core/autocomplete/cache.ts +++ b/core/autocomplete/cache.ts @@ -1,7 +1,7 @@ import { open } from "sqlite"; import sqlite3 from "sqlite3"; -import { DatabaseConnection } from "../indexing/refreshIndex"; -import { getTabAutocompleteCacheSqlitePath } from "../util/paths"; +import { DatabaseConnection } from "../indexing/refreshIndex.js"; +import { getTabAutocompleteCacheSqlitePath } from "../util/paths.js"; export class AutocompleteLruCache { private static capacity: number = 1000; diff --git a/core/autocomplete/charStream.ts b/core/autocomplete/charStream.ts index f8fe965cc..6cf4e827e 100644 --- a/core/autocomplete/charStream.ts +++ b/core/autocomplete/charStream.ts @@ -30,7 +30,7 @@ export async function* noFirstCharNewline(stream: AsyncGenerator) { for await (let char of stream) { if (first) { first = false; - if (char === "\n") return; + if (char === "\n") {return;} } yield char; } @@ -48,9 +48,9 @@ export async function* stopOnUnmatchedClosingBracket( ): AsyncGenerator { const stack: string[] = []; for (let i = 0; i < suffix.length; i++) { - if (suffix[i] === " ") continue; + if (suffix[i] === " ") {continue;} const openBracket = BRACKETS_REVERSE[suffix[i]]; - if (!openBracket) break; + if (!openBracket) {break;} stack.unshift(openBracket); } diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 709317996..2bbf48366 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -2,31 +2,31 @@ import Handlebars from "handlebars"; import ignore from "ignore"; import path from "path"; import { v4 as uuidv4 } from "uuid"; -import { IDE, ILLM, Position, Range, TabAutocompleteOptions } from ".."; -import { RangeInFileWithContents } from "../commands/util"; -import { ConfigHandler } from "../config/handler"; -import { streamLines } from "../diff/util"; -import OpenAI from "../llm/llms/OpenAI"; -import { getBasename } from "../util"; -import { logDevData } from "../util/devdata"; +import { IDE, ILLM, Position, Range, TabAutocompleteOptions } from "../index.js"; +import { RangeInFileWithContents } from "../commands/util.js"; +import { ConfigHandler } from "../config/handler.js"; +import { streamLines } from "../diff/util.js"; +import OpenAI from "../llm/llms/OpenAI.js"; +import { getBasename } from "../util/index.js"; +import { logDevData } from "../util/devdata.js"; import { COUNT_COMPLETION_REJECTED_AFTER, DEFAULT_AUTOCOMPLETE_OPTS, -} from "../util/parameters"; -import { Telemetry } from "../util/posthog"; -import { getRangeInString } from "../util/ranges"; -import AutocompleteLruCache from "./cache"; +} from "../util/parameters.js"; +import { Telemetry } from "../util/posthog.js"; +import { getRangeInString } from "../util/ranges.js"; +import AutocompleteLruCache from "./cache.js"; import { noFirstCharNewline, onlyWhitespaceAfterEndOfLine, stopOnUnmatchedClosingBracket, -} from "./charStream"; +} from "./charStream.js"; import { constructAutocompletePrompt, languageForFilepath, -} from "./constructPrompt"; -import { isOnlyPunctuationAndWhitespace } from "./filter"; -import { AutocompleteLanguageInfo } from "./languages"; +} from "./constructPrompt.js"; +import { isOnlyPunctuationAndWhitespace } from "./filter.js"; +import { AutocompleteLanguageInfo } from "./languages.js"; import { avoidPathLine, noTopLevelKeywordsMidline, @@ -34,11 +34,11 @@ import { stopAtRepeatingLines, stopAtSimilarLine, streamWithNewLines, -} from "./lineStream"; -import { AutocompleteSnippet } from "./ranking"; -import { RecentlyEditedRange } from "./recentlyEdited"; -import { getTemplateForModel } from "./templates"; -import { GeneratorReuseManager } from "./util"; +} from "./lineStream.js"; +import { AutocompleteSnippet } from "./ranking.js"; +import { RecentlyEditedRange } from "./recentlyEdited.js"; +import { getTemplateForModel } from "./templates.js"; +import { GeneratorReuseManager } from "./util.js"; export interface AutocompleteInput { completionId: string; @@ -157,7 +157,7 @@ export async function getTabCompletion( } // Model - if (!llm) return; + if (!llm) {return;} if (llm instanceof OpenAI) { llm.useLegacyCompletionsEndpoint = true; } else if ( diff --git a/core/autocomplete/constructPrompt.ts b/core/autocomplete/constructPrompt.ts index ad0effbe9..2e72e77e6 100644 --- a/core/autocomplete/constructPrompt.ts +++ b/core/autocomplete/constructPrompt.ts @@ -1,21 +1,21 @@ import Parser from "web-tree-sitter"; -import { TabAutocompleteOptions } from ".."; -import { RangeInFileWithContents } from "../commands/util"; +import { TabAutocompleteOptions } from "../index.js"; +import { RangeInFileWithContents } from "../commands/util.js"; import { countTokens, pruneLinesFromBottom, pruneLinesFromTop, -} from "../llm/countTokens"; -import { getAst, getTreePathAtCursor } from "./ast"; -import { AutocompleteLanguageInfo, LANGUAGES, Typescript } from "./languages"; +} from "../llm/countTokens.js"; +import { getAst, getTreePathAtCursor } from "./ast.js"; +import { AutocompleteLanguageInfo, LANGUAGES, Typescript } from "./languages.js"; import { AutocompleteSnippet, fillPromptWithSnippets, rankSnippets, removeRangeFromSnippets, -} from "./ranking"; -import { RecentlyEditedRange, findMatchingRange } from "./recentlyEdited"; +} from "./ranking.js"; +import { RecentlyEditedRange, findMatchingRange } from "./recentlyEdited.js"; export function languageForFilepath( filepath: string, diff --git a/core/autocomplete/languages.ts b/core/autocomplete/languages.ts index 467d9e0f0..6f15fd55a 100644 --- a/core/autocomplete/languages.ts +++ b/core/autocomplete/languages.ts @@ -15,7 +15,7 @@ export const Typescript = { export const Python = { // """"#" is for .ipynb files, where we add '"""' surrounding markdown blocks. // This stops the model from trying to complete the start of a new markdown block - stopWords: ["def", "class", '"""#'], + stopWords: ["def", "class", "\"\"\"#"], comment: "#", endOfLine: [], }; diff --git a/core/autocomplete/lineStream.ts b/core/autocomplete/lineStream.ts index d985dcbfa..74b7013e5 100644 --- a/core/autocomplete/lineStream.ts +++ b/core/autocomplete/lineStream.ts @@ -1,6 +1,6 @@ import { distance } from "fastest-levenshtein"; -import { DiffLine } from ".."; -import { LineStream } from "../diff/util"; +import { DiffLine } from "../index.js"; +import { LineStream } from "../diff/util.js"; export async function* noTopLevelKeywordsMidline( lines: LineStream, diff --git a/core/autocomplete/ranking.ts b/core/autocomplete/ranking.ts index 615337b98..850af99a9 100644 --- a/core/autocomplete/ranking.ts +++ b/core/autocomplete/ranking.ts @@ -1,6 +1,6 @@ -import { Range } from ".."; -import { RangeInFileWithContents } from "../commands/util"; -import { countTokens } from "../llm/countTokens"; +import { Range } from "../index.js"; +import { RangeInFileWithContents } from "../commands/util.js"; +import { countTokens } from "../llm/countTokens.js"; export type AutocompleteSnippet = RangeInFileWithContents & { score?: number; diff --git a/core/autocomplete/recentlyEdited.ts b/core/autocomplete/recentlyEdited.ts index c444c41dc..d0e7817ed 100644 --- a/core/autocomplete/recentlyEdited.ts +++ b/core/autocomplete/recentlyEdited.ts @@ -1,4 +1,4 @@ -import { RangeInFile } from ".."; +import { RangeInFile } from "../index.js"; export type RecentlyEditedRange = RangeInFile & { timestamp: number; diff --git a/core/autocomplete/retrieval.ts b/core/autocomplete/retrieval.ts index 5c9641863..635f52012 100644 --- a/core/autocomplete/retrieval.ts +++ b/core/autocomplete/retrieval.ts @@ -1,5 +1,5 @@ -import { BranchAndDir, Chunk } from ".."; -import { FullTextSearchCodebaseIndex } from "../indexing/FullTextSearch"; +import { BranchAndDir, Chunk } from "../index.js"; +import { FullTextSearchCodebaseIndex } from "../indexing/FullTextSearch.js"; export async function fullTextRetrieve( prefix: string, diff --git a/core/autocomplete/slidingWindow.ts b/core/autocomplete/slidingWindow.ts index e0517ceb5..72aa1a5ee 100644 --- a/core/autocomplete/slidingWindow.ts +++ b/core/autocomplete/slidingWindow.ts @@ -1,5 +1,5 @@ -import { RangeInFileWithContents } from "../commands/util"; -import { AutocompleteSnippet, jaccardSimilarity } from "./ranking"; +import { RangeInFileWithContents } from "../commands/util.js"; +import { AutocompleteSnippet, jaccardSimilarity } from "./ranking.js"; function* slidingWindow( content: string, diff --git a/core/autocomplete/templates.ts b/core/autocomplete/templates.ts index d041d909a..b790c14a0 100644 --- a/core/autocomplete/templates.ts +++ b/core/autocomplete/templates.ts @@ -1,7 +1,7 @@ // Fill in the middle prompts -import { CompletionOptions } from ".."; -import { AutocompleteSnippet } from "./ranking"; +import { CompletionOptions } from "../index.js"; +import { AutocompleteSnippet } from "./ranking.js"; interface AutocompleteTemplate { template: diff --git a/core/commands/index.ts b/core/commands/index.ts index 5cef3ccb7..ef41cd241 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -1,7 +1,7 @@ -import { CustomCommand, SlashCommand, SlashCommandDescription } from ".."; -import { stripImages } from "../llm/countTokens"; -import { renderTemplatedString } from "../llm/llms"; -import SlashCommands from "./slash"; +import { CustomCommand, SlashCommand, SlashCommandDescription } from "../index.js"; +import { stripImages } from "../llm/countTokens.js"; +import { renderTemplatedString } from "../llm/llms/index.js"; +import SlashCommands from "./slash/index.js"; export function slashFromCustomCommand( customCommand: CustomCommand, diff --git a/core/commands/slash/cmd.ts b/core/commands/slash/cmd.ts index 9afc4a61c..8e79519d9 100644 --- a/core/commands/slash/cmd.ts +++ b/core/commands/slash/cmd.ts @@ -1,6 +1,6 @@ -import { SlashCommand } from "../.."; -import { streamLines } from "../../diff/util"; -import { removeQuotesAndEscapes } from "../../util"; +import { SlashCommand } from "../../index.js"; +import { streamLines } from "../../diff/util.js"; +import { removeQuotesAndEscapes } from "../../util/index.js"; const GenerateTerminalCommand: SlashCommand = { name: "cmd", diff --git a/core/commands/slash/comment.ts b/core/commands/slash/comment.ts index ec6116516..929763bf3 100644 --- a/core/commands/slash/comment.ts +++ b/core/commands/slash/comment.ts @@ -1,5 +1,5 @@ -import { SlashCommand } from "../.."; -import EditSlashCommand from "./edit"; +import { SlashCommand } from "../../index.js"; +import EditSlashCommand from "./edit.js"; const CommentSlashCommand: SlashCommand = { name: "comment", diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index 34775fae1..004117bed 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -1,5 +1,5 @@ -import { SlashCommand } from "../.."; -import { stripImages } from "../../llm/countTokens"; +import { SlashCommand } from "../../index.js"; +import { stripImages } from "../../llm/countTokens.js"; const CommitMessageCommand: SlashCommand = { name: "commit", diff --git a/core/commands/slash/draftIssue.ts b/core/commands/slash/draftIssue.ts index 1dd2c8cc4..4a671eb56 100644 --- a/core/commands/slash/draftIssue.ts +++ b/core/commands/slash/draftIssue.ts @@ -1,6 +1,6 @@ -import { ChatMessage, SlashCommand } from "../.."; -import { stripImages } from "../../llm/countTokens"; -import { removeQuotesAndEscapes } from "../../util"; +import { ChatMessage, SlashCommand } from "../../index.js"; +import { stripImages } from "../../llm/countTokens.js"; +import { removeQuotesAndEscapes } from "../../util/index.js"; const PROMPT = ( input: string, diff --git a/core/commands/slash/edit.ts b/core/commands/slash/edit.ts index 3ec1cb2f2..4ed926be8 100644 --- a/core/commands/slash/edit.ts +++ b/core/commands/slash/edit.ts @@ -1,4 +1,4 @@ -import { ContextItemWithId, ILLM, SlashCommand } from "../.."; +import { ContextItemWithId, ILLM, SlashCommand } from "../../index.js"; import { filterCodeBlockLines, filterEnglishLinesAtEnd, @@ -6,17 +6,17 @@ import { fixCodeLlamaFirstLineIndentation, stopAtLines, streamWithNewLines, -} from "../../autocomplete/lineStream"; -import { streamLines } from "../../diff/util"; -import { stripImages } from "../../llm/countTokens"; +} from "../../autocomplete/lineStream.js"; +import { streamLines } from "../../diff/util.js"; +import { stripImages } from "../../llm/countTokens.js"; import { dedentAndGetCommonWhitespace, getMarkdownLanguageTagForFile, -} from "../../util"; +} from "../../util/index.js"; import { RangeInFileWithContents, contextItemToRangeInFileWithContents, -} from "../util"; +} from "../util.js"; const PROMPT = `Take the file prefix and suffix into account, but only rewrite the code_to_edit as specified in the user_request. The code you write in modified_code_to_edit will replace the code between the code_to_edit tags. Do NOT preface your answer or write anything other than code. The tag should be written to indicate the end of the modified code section. Do not ever use nested tags. diff --git a/core/commands/slash/http.ts b/core/commands/slash/http.ts index ff7f82ccd..20225c2c0 100644 --- a/core/commands/slash/http.ts +++ b/core/commands/slash/http.ts @@ -1,5 +1,5 @@ -import { SlashCommand } from "../.."; -import { removeQuotesAndEscapes } from "../../util"; +import { SlashCommand } from "../../index.js"; +import { removeQuotesAndEscapes } from "../../util/index.js"; const HttpSlashCommand: SlashCommand = { name: "http", @@ -26,7 +26,7 @@ const HttpSlashCommand: SlashCommand = { const reader = response.body.getReader(); while (true) { const { done, value } = await reader.read(); - if (done) break; + if (done) {break;} const decoded = new TextDecoder("utf-8").decode(value); yield decoded; } diff --git a/core/commands/slash/index.ts b/core/commands/slash/index.ts index fe51fac2e..fa6819acd 100644 --- a/core/commands/slash/index.ts +++ b/core/commands/slash/index.ts @@ -1,12 +1,12 @@ -import GenerateTerminalCommand from "./cmd"; -import CommentSlashCommand from "./comment"; -import CommitMessageCommand from "./commit"; -import DraftIssueCommand from "./draftIssue"; -import EditSlashCommand from "./edit"; -import HttpSlashCommand from "./http"; -import ShareSlashCommand from "./share"; -import StackOverflowSlashCommand from "./stackOverflow"; -import ReviewMessageCommand from "./review"; +import GenerateTerminalCommand from "./cmd.js"; +import CommentSlashCommand from "./comment.js"; +import CommitMessageCommand from "./commit.js"; +import DraftIssueCommand from "./draftIssue.js"; +import EditSlashCommand from "./edit.js"; +import HttpSlashCommand from "./http.js"; +import ShareSlashCommand from "./share.js"; +import StackOverflowSlashCommand from "./stackOverflow.js"; +import ReviewMessageCommand from "./review.js"; export default [ DraftIssueCommand, diff --git a/core/commands/slash/review.ts b/core/commands/slash/review.ts index 87ff75764..ddc412910 100644 --- a/core/commands/slash/review.ts +++ b/core/commands/slash/review.ts @@ -1,6 +1,6 @@ -import { SlashCommand } from "../.."; -import { stripImages } from "../../llm/countTokens"; -import { ChatMessage } from "../.."; +import { SlashCommand } from "../../index.js"; +import { stripImages } from "../../llm/countTokens.js"; +import { ChatMessage } from "../../index.js"; const prompt = ` Review the following code, focusing on Readability, Maintainability, Code Smells, Speed, and Memory Performance. Provide feedback with these guidelines: @@ -17,7 +17,7 @@ function getLastUserHistory(history: ChatMessage[]): string { .reverse() .find((message) => message.role === "user"); - if (!lastUserHistory) return ""; + if (!lastUserHistory) {return "";} if (lastUserHistory.content instanceof Array) { return lastUserHistory.content.reduce( diff --git a/core/commands/slash/share.ts b/core/commands/slash/share.ts index c78b2ae4c..cf7a31f3e 100644 --- a/core/commands/slash/share.ts +++ b/core/commands/slash/share.ts @@ -1,9 +1,9 @@ import path from "path"; import * as fs from "fs"; import { homedir } from "os"; -import { SlashCommand } from "../.."; -import { languageForFilepath } from "../../autocomplete/constructPrompt"; -import { stripImages } from "../../llm/countTokens"; +import { SlashCommand } from "../../index.js"; +import { languageForFilepath } from "../../autocomplete/constructPrompt.js"; +import { stripImages } from "../../llm/countTokens.js"; // If useful elsewhere, helper funcs should move to core/util/index.ts or similar function getOffsetDatetime(date: Date): Date { @@ -31,7 +31,7 @@ function reformatCodeBlocks(msgText: string): string { }, ); // Appease the markdown linter - return msgText.replace(/```\n```/g, '```\n\n```'); + return msgText.replace(/```\n```/g, "```\n\n```"); } const ShareSlashCommand: SlashCommand = { @@ -69,7 +69,7 @@ const ShareSlashCommand: SlashCommand = { outputDir = outputDir.replace(/^~/, homedir); } else if ( outputDir.startsWith("./") || - outputDir.startsWith(`.\\`) || + outputDir.startsWith(".\\") || outputDir === "." ) { const workspaceDirs = await ide.getWorkspaceDirs(); diff --git a/core/commands/slash/stackOverflow.ts b/core/commands/slash/stackOverflow.ts index 9a35c1330..26facd658 100644 --- a/core/commands/slash/stackOverflow.ts +++ b/core/commands/slash/stackOverflow.ts @@ -1,5 +1,5 @@ -import { ChatMessageRole, FetchFunction, SlashCommand } from "../.."; -import { pruneStringFromBottom, stripImages } from "../../llm/countTokens"; +import { ChatMessageRole, FetchFunction, SlashCommand } from "../../index.js"; +import { pruneStringFromBottom, stripImages } from "../../llm/countTokens.js"; const SERVER_URL = "https://proxy-server-l6vsfbzhba-uw.a.run.app"; const PROMPT = ( diff --git a/core/commands/util.ts b/core/commands/util.ts index f7111beb6..2507be83d 100644 --- a/core/commands/util.ts +++ b/core/commands/util.ts @@ -1,4 +1,4 @@ -import { ContextItemWithId } from ".."; +import { ContextItemWithId } from "../index.js"; export interface RangeInFileWithContents { filepath: string; diff --git a/core/config/default.ts b/core/config/default.ts index 2dc202bee..d6ea479f7 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -1,4 +1,4 @@ -import { ContextProviderWithParams, SerializedContinueConfig } from ".."; +import { ContextProviderWithParams, SerializedContinueConfig } from "../index.js"; export const defaultConfig: SerializedContinueConfig = { models: [ diff --git a/core/config/handler.ts b/core/config/handler.ts index 7e1f2f4c8..9882a05b0 100644 --- a/core/config/handler.ts +++ b/core/config/handler.ts @@ -1,11 +1,11 @@ -import { ContinueConfig, ContinueRcJson, IDE, ILLM } from ".."; -import { IdeSettings } from "../protocol"; -import { Telemetry } from "../util/posthog"; +import { ContinueConfig, ContinueRcJson, IDE, ILLM } from "../index.js"; +import { IdeSettings } from "../protocol.js"; +import { Telemetry } from "../util/posthog.js"; import { BrowserSerializedContinueConfig, finalToBrowserConfig, loadFullConfigNode, -} from "./load"; +} from "./load.js"; export class ConfigHandler { private savedConfig: ContinueConfig | undefined; diff --git a/core/config/load.ts b/core/config/load.ts index f138f9622..8ceafe1f1 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -16,24 +16,24 @@ import { RerankerDescription, SerializedContinueConfig, SlashCommand, -} from ".."; +} from "../index.js"; import { slashCommandFromDescription, slashFromCustomCommand, -} from "../commands"; -import { contextProviderClassFromName } from "../context/providers"; -import CustomContextProviderClass from "../context/providers/CustomContextProvider"; -import FileContextProvider from "../context/providers/FileContextProvider"; -import { AllRerankers } from "../context/rerankers"; -import { LLMReranker } from "../context/rerankers/llm"; -import { AllEmbeddingsProviders } from "../indexing/embeddings"; -import TransformersJsEmbeddingsProvider from "../indexing/embeddings/TransformersJsEmbeddingsProvider"; -import { BaseLLM } from "../llm"; -import { llmFromDescription } from "../llm/llms"; -import CustomLLMClass from "../llm/llms/CustomLLM"; -import { copyOf } from "../util"; -import { fetchwithRequestOptions } from "../util/fetchWithOptions"; -import mergeJson from "../util/merge"; +} from "../commands/index.js"; +import { contextProviderClassFromName } from "../context/providers/index.js"; +import CustomContextProviderClass from "../context/providers/CustomContextProvider.js"; +import FileContextProvider from "../context/providers/FileContextProvider.js"; +import { AllRerankers } from "../context/rerankers/index.js"; +import { LLMReranker } from "../context/rerankers/llm.js"; +import { AllEmbeddingsProviders } from "../indexing/embeddings/index.js"; +import TransformersJsEmbeddingsProvider from "../indexing/embeddings/TransformersJsEmbeddingsProvider.js"; +import { BaseLLM } from "../llm/index.js"; +import { llmFromDescription } from "../llm/llms/index.js"; +import CustomLLMClass from "../llm/llms/CustomLLM.js"; +import { copyOf } from "../util/index.js"; +import { fetchwithRequestOptions } from "../util/fetchWithOptions.js"; +import mergeJson from "../util/merge.js"; import { getConfigJsPath, getConfigJsPathForRemote, @@ -41,13 +41,13 @@ import { getConfigJsonPathForRemote, getConfigTsPath, getContinueDotEnv, -} from "../util/paths"; +} from "../util/paths.js"; import { defaultContextProvidersJetBrains, defaultContextProvidersVsCode, defaultSlashCommandsJetBrains, defaultSlashCommandsVscode, -} from "./default"; +} from "./default.js"; const { execSync } = require("child_process"); function resolveSerializedConfig(filepath: string): SerializedContinueConfig { @@ -181,7 +181,7 @@ async function intermediateToFinalConfig( config.completionOptions, config.systemMessage, ); - if (!llm) continue; + if (!llm) {continue;} if (llm.model === "AUTODETECT") { try { diff --git a/core/config/onboarding.ts b/core/config/onboarding.ts index ee2b10971..66de4daad 100644 --- a/core/config/onboarding.ts +++ b/core/config/onboarding.ts @@ -1,4 +1,4 @@ -import { SerializedContinueConfig } from ".."; +import { SerializedContinueConfig } from "../index.js"; export function setupOptimizedMode( config: SerializedContinueConfig, diff --git a/core/config/util.ts b/core/config/util.ts index ad2eb1a0b..9ab682cc2 100644 --- a/core/config/util.ts +++ b/core/config/util.ts @@ -1,6 +1,6 @@ import { readFileSync, writeFileSync } from "fs"; -import { ModelDescription } from ".."; -import { editConfigJson, getConfigJsonPath } from "../util/paths"; +import { ModelDescription } from "../index.js"; +import { editConfigJson, getConfigJsonPath } from "../util/paths.js"; function stringify(obj: any, indentation?: number): string { return JSON.stringify( diff --git a/core/context/index.ts b/core/context/index.ts index 24dbdd92f..03804dbff 100644 --- a/core/context/index.ts +++ b/core/context/index.ts @@ -5,7 +5,7 @@ import { ContextSubmenuItem, IContextProvider, LoadSubmenuItemsArgs, -} from ".."; +} from "../index.js"; export abstract class BaseContextProvider implements IContextProvider { options: { [key: string]: any }; diff --git a/core/context/providers/CodeContextProvider.ts b/core/context/providers/CodeContextProvider.ts index 89bf9b026..bf949a06b 100644 --- a/core/context/providers/CodeContextProvider.ts +++ b/core/context/providers/CodeContextProvider.ts @@ -1,12 +1,12 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; -import { CodeSnippetsCodebaseIndex } from "../../indexing/CodeSnippetsIndex"; +} from "../../index.js"; +import { CodeSnippetsCodebaseIndex } from "../../indexing/CodeSnippetsIndex.js"; class CodeContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/CodeHighlightsContextProvider.ts b/core/context/providers/CodeHighlightsContextProvider.ts index 761bd4495..62c662139 100644 --- a/core/context/providers/CodeHighlightsContextProvider.ts +++ b/core/context/providers/CodeHighlightsContextProvider.ts @@ -1,10 +1,10 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; -import { getBasename } from "../../util"; +} from "../../index.js"; +import { getBasename } from "../../util/index.js"; // import { getHighlightsThatFit, ILLMContextSizer } from "llm-code-highlighter/dist/index.continue"; diff --git a/core/context/providers/CodeOutlineContextProvider.ts b/core/context/providers/CodeOutlineContextProvider.ts index ead6fdc85..bb610a9b8 100644 --- a/core/context/providers/CodeOutlineContextProvider.ts +++ b/core/context/providers/CodeOutlineContextProvider.ts @@ -1,10 +1,10 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; -import { getBasename } from "../../util"; +} from "../../index.js"; +import { getBasename } from "../../util/index.js"; // import { getOutlines } from "llm-code-highlighter/dist/index.continue"; diff --git a/core/context/providers/CodebaseContextProvider.ts b/core/context/providers/CodebaseContextProvider.ts index 9a46807e8..7609ebf30 100644 --- a/core/context/providers/CodebaseContextProvider.ts +++ b/core/context/providers/CodebaseContextProvider.ts @@ -1,10 +1,10 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; -import { retrieveContextItemsFromEmbeddings } from "../retrieval/retrieval"; +} from "../../index.js"; +import { retrieveContextItemsFromEmbeddings } from "../retrieval/retrieval.js"; class CodebaseContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/CurrentFileContextProvider.ts b/core/context/providers/CurrentFileContextProvider.ts index 2f282d559..1470c16df 100644 --- a/core/context/providers/CurrentFileContextProvider.ts +++ b/core/context/providers/CurrentFileContextProvider.ts @@ -1,10 +1,10 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; -import { getBasename } from "../../util"; +} from "../../index.js"; +import { getBasename } from "../../util/index.js"; class CurrentFileContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/CustomContextProvider.ts b/core/context/providers/CustomContextProvider.ts index 1bc573e57..3fc6dcf93 100644 --- a/core/context/providers/CustomContextProvider.ts +++ b/core/context/providers/CustomContextProvider.ts @@ -5,7 +5,7 @@ import { CustomContextProvider, IContextProvider, LoadSubmenuItemsArgs, -} from "../.."; +} from "../../index.js"; class CustomContextProviderClass implements IContextProvider { custom: CustomContextProvider; diff --git a/core/context/providers/DatabaseContextProvider.ts b/core/context/providers/DatabaseContextProvider.ts index e0fa4ce3a..d0107ca37 100644 --- a/core/context/providers/DatabaseContextProvider.ts +++ b/core/context/providers/DatabaseContextProvider.ts @@ -1,11 +1,11 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; +} from "../../index.js"; class DatabaseContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { @@ -47,7 +47,7 @@ class DatabaseContextProvider extends BaseContextProvider { let contextItem = { name: `${connectionName}-all-tables-schemas`, - description: `Schema for all tables.`, + description: "Schema for all tables.", content: prompt, }; @@ -101,7 +101,7 @@ class DatabaseContextProvider extends BaseContextProvider { let contextItem = { id: `${connection.name}.all`, title: `${connection.name} all table schemas`, - description: ``, + description: "", }; contextItems.push(contextItem); @@ -110,7 +110,7 @@ class DatabaseContextProvider extends BaseContextProvider { let contextItem = { id: `${connection.name}.${tableName}`, title: `${connection.name}.${tableName} schema`, - description: ``, + description: "", }; contextItems.push(contextItem); diff --git a/core/context/providers/DiffContextProvider.ts b/core/context/providers/DiffContextProvider.ts index 44b9168b5..22fcad436 100644 --- a/core/context/providers/DiffContextProvider.ts +++ b/core/context/providers/DiffContextProvider.ts @@ -1,9 +1,9 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; class DiffContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 6e5fd7e5f..21b5b8a55 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -1,13 +1,13 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; -import configs from "../../indexing/docs/preIndexedDocs"; -import TransformersJsEmbeddingsProvider from "../../indexing/embeddings/TransformersJsEmbeddingsProvider"; +} from "../../index.js"; +import configs from "../../indexing/docs/preIndexedDocs.js"; +import TransformersJsEmbeddingsProvider from "../../indexing/embeddings/TransformersJsEmbeddingsProvider.js"; class DocsContextProvider extends BaseContextProvider { static DEFAULT_N_RETRIEVE = 30; diff --git a/core/context/providers/FileContextProvider.ts b/core/context/providers/FileContextProvider.ts index 0a40ec705..1a0071526 100644 --- a/core/context/providers/FileContextProvider.ts +++ b/core/context/providers/FileContextProvider.ts @@ -1,12 +1,12 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; -import { getBasename, getLastNPathParts } from "../../util"; +} from "../../index.js"; +import { getBasename, getLastNPathParts } from "../../util/index.js"; class FileContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/FileTreeContextProvider.ts b/core/context/providers/FileTreeContextProvider.ts index d1c175d99..0d9293282 100644 --- a/core/context/providers/FileTreeContextProvider.ts +++ b/core/context/providers/FileTreeContextProvider.ts @@ -1,9 +1,9 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; interface Directory { name: string; diff --git a/core/context/providers/FolderContextProvider.ts b/core/context/providers/FolderContextProvider.ts index e22afde34..90aab44a7 100644 --- a/core/context/providers/FolderContextProvider.ts +++ b/core/context/providers/FolderContextProvider.ts @@ -1,12 +1,12 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; -import { getBasename, getLastNPathParts } from "../../util"; +} from "../../index.js"; +import { getBasename, getLastNPathParts } from "../../util/index.js"; class FolderContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/GitHubIssuesContextProvider.ts b/core/context/providers/GitHubIssuesContextProvider.ts index f983dce6d..498f0d30c 100644 --- a/core/context/providers/GitHubIssuesContextProvider.ts +++ b/core/context/providers/GitHubIssuesContextProvider.ts @@ -1,11 +1,11 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; +} from "../../index.js"; class GitHubIssuesContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/GitLabMergeRequestContextProvider.ts b/core/context/providers/GitLabMergeRequestContextProvider.ts index d1b3da8eb..4a5ce49d6 100644 --- a/core/context/providers/GitLabMergeRequestContextProvider.ts +++ b/core/context/providers/GitLabMergeRequestContextProvider.ts @@ -1,6 +1,6 @@ import { AxiosInstance, AxiosError } from "axios"; -import {BaseContextProvider} from ".."; -import { ContextProviderExtras, ContextItem, ContextProviderDescription } from "../.."; +import {BaseContextProvider} from "../index.js"; +import { ContextProviderExtras, ContextItem, ContextProviderDescription } from "../../index.js"; interface RemoteBranchInfo { branch: string | null; @@ -70,10 +70,10 @@ const getSubprocess = async (extras: ContextProviderExtras) => { class GitLabMergeRequestContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { - title: 'gitlab-mr', - displayTitle: 'GitLab Merge Request', - description: 'Reference comments in a GitLab Merge Request', - type: 'normal' + title: "gitlab-mr", + displayTitle: "GitLab Merge Request", + description: "Reference comments in a GitLab Merge Request", + type: "normal" }; private async getApi(): Promise { @@ -83,7 +83,7 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { const token = this.options.token; if(!token) { - throw new Error(`GitLab Private Token is required!`); + throw new Error("GitLab Private Token is required!"); } return Axios.create({ @@ -99,13 +99,13 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { const subprocess = await getSubprocess(extras); - const branchName = await subprocess(`git branch --show-current`); + const branchName = await subprocess("git branch --show-current"); const branchRemote = await subprocess( `git config branch.${branchName}.remote` ); - const branchInfo = await subprocess(`git branch -vv`); + const branchInfo = await subprocess("git branch -vv"); const currentBranchInfo = branchInfo .split("\n") @@ -121,7 +121,7 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { const remoteUrl = await subprocess(`git remote get-url ${branchRemote}`); - const urlMatches = RegExp(`:(?.*).git`).exec(remoteUrl); + const urlMatches = RegExp(":(?.*).git").exec(remoteUrl); const project = urlMatches?.groups?.["project"] ?? null; @@ -157,8 +157,8 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { for (const mergeRequest of mergeRequests) { const parts = [ - `# GitLab Merge Request\ntitle: "${mergeRequest.title}"\ndescription: "${mergeRequest.description ?? 'None'}"`, - `## Comments`, + `# GitLab Merge Request\ntitle: "${mergeRequest.title}"\ndescription: "${mergeRequest.description ?? "None"}"`, + "## Comments", ]; const comments = await api.get>( @@ -195,7 +195,7 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { } const commentFormatter = async (comment: GitLabComment) => { - const commentLabel = comment.body.includes("```suggestion") ? 'Code Suggestion' : 'Comment'; + const commentLabel = comment.body.includes("```suggestion") ? "Code Suggestion" : "Comment"; let result = `#### ${commentLabel}\nauthor: "${comment.author.name}"\ndate: "${comment.created_at}"\nresolved: ${ comment.resolved ? "Yes" : "No" }`; @@ -240,13 +240,13 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { { name: mergeRequest.title, content, - description: `Comments from the Merge Request for this branch.`, + description: "Comments from the Merge Request for this branch.", }, ); } } catch (ex) { - let content = `# GitLab Merge Request\n\nError getting merge request. `; + let content = "# GitLab Merge Request\n\nError getting merge request. "; if (ex instanceof AxiosError) { if (ex.response) { const errorMessage = ex.response?.data ? ex.response.data.message ?? JSON.stringify(ex.response?.data) : `${ex.response.status}: ${ex.response.statusText}`; @@ -262,9 +262,9 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { result.push( { - name: `GitLab Merge Request`, + name: "GitLab Merge Request", content, - description: `Error getting the Merge Request for this branch.`, + description: "Error getting the Merge Request for this branch.", }, ); } diff --git a/core/context/providers/GoogleContextProvider.ts b/core/context/providers/GoogleContextProvider.ts index 3ee81654c..7d90c01ea 100644 --- a/core/context/providers/GoogleContextProvider.ts +++ b/core/context/providers/GoogleContextProvider.ts @@ -1,9 +1,9 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; class GoogleContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/HttpContextProvider.ts b/core/context/providers/HttpContextProvider.ts index 05b5a9a8f..87aa60759 100644 --- a/core/context/providers/HttpContextProvider.ts +++ b/core/context/providers/HttpContextProvider.ts @@ -1,9 +1,9 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; class HttpContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/JiraIssuesContextProvider/JiraClient.ts b/core/context/providers/JiraIssuesContextProvider/JiraClient.ts index d9efaa601..2727ea6ab 100644 --- a/core/context/providers/JiraIssuesContextProvider/JiraClient.ts +++ b/core/context/providers/JiraIssuesContextProvider/JiraClient.ts @@ -1,4 +1,4 @@ -import { RequestOptions } from "../../.."; +import { RequestOptions } from "../../../index.js"; const { convert: adf2md } = require("adf-to-md"); interface JiraClientOptions { @@ -67,7 +67,7 @@ export class JiraClient { private authHeader; constructor(options: JiraClientOptions) { this.options = { - issueQuery: `assignee = currentUser() AND resolution = Unresolved order by updated DESC`, + issueQuery: "assignee = currentUser() AND resolution = Unresolved order by updated DESC", apiVersion: "3", requestOptions: {}, ...options, @@ -142,7 +142,7 @@ export class JiraClient { this.baseUrl + `/search?fields=summary&jql=${ this.options.issueQuery ?? - `assignee = currentUser() AND resolution = Unresolved order by updated DESC` + "assignee = currentUser() AND resolution = Unresolved order by updated DESC" }`, ), { diff --git a/core/context/providers/JiraIssuesContextProvider/index.ts b/core/context/providers/JiraIssuesContextProvider/index.ts index e1ca1841e..adcb239cd 100644 --- a/core/context/providers/JiraIssuesContextProvider/index.ts +++ b/core/context/providers/JiraIssuesContextProvider/index.ts @@ -1,12 +1,12 @@ -import { BaseContextProvider } from "../.."; +import { BaseContextProvider } from "../../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../../.."; -import { JiraClient } from "./JiraClient"; +} from "../../../index.js"; +import { JiraClient } from "./JiraClient.js"; class JiraIssuesContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/LocalsProvider.ts b/core/context/providers/LocalsProvider.ts index 9b5ea5dbc..5d5d74485 100644 --- a/core/context/providers/LocalsProvider.ts +++ b/core/context/providers/LocalsProvider.ts @@ -1,11 +1,11 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; +} from "../../index.js"; class LocalsProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/OSContextProvider.ts b/core/context/providers/OSContextProvider.ts index fd0996e94..29489a7ab 100644 --- a/core/context/providers/OSContextProvider.ts +++ b/core/context/providers/OSContextProvider.ts @@ -1,12 +1,12 @@ //os.platform() //os.arch() -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; import os from "os"; class OSContextProvider extends BaseContextProvider { diff --git a/core/context/providers/OpenFilesContextProvider.ts b/core/context/providers/OpenFilesContextProvider.ts index 111cf31b5..0c04d2c83 100644 --- a/core/context/providers/OpenFilesContextProvider.ts +++ b/core/context/providers/OpenFilesContextProvider.ts @@ -1,10 +1,10 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; -import { getBasename } from "../../util"; +} from "../../index.js"; +import { getBasename } from "../../util/index.js"; class OpenFilesContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/PostgresContextProvider.ts b/core/context/providers/PostgresContextProvider.ts index 9c7e78528..479386e3f 100644 --- a/core/context/providers/PostgresContextProvider.ts +++ b/core/context/providers/PostgresContextProvider.ts @@ -1,11 +1,11 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, ContextSubmenuItem, LoadSubmenuItemsArgs, -} from "../.."; +} from "../../index.js"; class PostgresContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/ProblemsContextProvider.ts b/core/context/providers/ProblemsContextProvider.ts index 62916b8f5..316ce6026 100644 --- a/core/context/providers/ProblemsContextProvider.ts +++ b/core/context/providers/ProblemsContextProvider.ts @@ -1,10 +1,10 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; -import { getBasename } from "../../util"; +} from "../../index.js"; +import { getBasename } from "../../util/index.js"; class ProblemsContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { @@ -46,7 +46,7 @@ class ProblemsContextProvider extends BaseContextProvider { ? [ { description: "Problems in current file", - content: `There are no problems found in the open file.`, + content: "There are no problems found in the open file.", name: "No problems found", }, ] diff --git a/core/context/providers/SearchContextProvider.ts b/core/context/providers/SearchContextProvider.ts index 9760d14de..4941d56d9 100644 --- a/core/context/providers/SearchContextProvider.ts +++ b/core/context/providers/SearchContextProvider.ts @@ -1,9 +1,9 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; class SearchContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/TerminalContextProvider.ts b/core/context/providers/TerminalContextProvider.ts index 67e5b5957..fd8ef580b 100644 --- a/core/context/providers/TerminalContextProvider.ts +++ b/core/context/providers/TerminalContextProvider.ts @@ -1,9 +1,9 @@ -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; class TerminalContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/URLContextProvider.ts b/core/context/providers/URLContextProvider.ts index d5af8f6c9..2e864fbb9 100644 --- a/core/context/providers/URLContextProvider.ts +++ b/core/context/providers/URLContextProvider.ts @@ -1,12 +1,12 @@ import { Readability } from "@mozilla/readability"; import { JSDOM } from "jsdom"; import { NodeHtmlMarkdown } from "node-html-markdown"; -import { BaseContextProvider } from ".."; +import { BaseContextProvider } from "../index.js"; import { ContextItem, ContextProviderDescription, ContextProviderExtras, -} from "../.."; +} from "../../index.js"; class URLContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts index 342d49590..511afb375 100644 --- a/core/context/providers/index.ts +++ b/core/context/providers/index.ts @@ -1,26 +1,26 @@ -import { BaseContextProvider } from ".."; -import { ContextProviderName } from "../.."; -import CodeContextProvider from "./CodeContextProvider"; -import CodebaseContextProvider from "./CodebaseContextProvider"; -import CurrentFileContextProvider from "./CurrentFileContextProvider"; -import DatabaseContextProvider from "./DatabaseContextProvider"; -import DiffContextProvider from "./DiffContextProvider"; -import DocsContextProvider from "./DocsContextProvider"; -import FileTreeContextProvider from "./FileTreeContextProvider"; -import FolderContextProvider from "./FolderContextProvider"; -import GitHubIssuesContextProvider from "./GitHubIssuesContextProvider"; -import GitLabMergeRequestContextProvider from "./GitLabMergeRequestContextProvider"; -import GoogleContextProvider from "./GoogleContextProvider"; -import HttpContextProvider from "./HttpContextProvider"; -import JiraIssuesContextProvider from "./JiraIssuesContextProvider"; -import LocalsProvider from "./LocalsProvider"; -import OSContextProvider from "./OSContextProvider"; -import OpenFilesContextProvider from "./OpenFilesContextProvider"; -import PostgresContextProvider from "./PostgresContextProvider"; -import ProblemsContextProvider from "./ProblemsContextProvider"; -import SearchContextProvider from "./SearchContextProvider"; -import TerminalContextProvider from "./TerminalContextProvider"; -import URLContextProvider from "./URLContextProvider"; +import { BaseContextProvider } from "../index.js"; +import { ContextProviderName } from "../../index.js"; +import CodeContextProvider from "./CodeContextProvider.js"; +import CodebaseContextProvider from "./CodebaseContextProvider.js"; +import CurrentFileContextProvider from "./CurrentFileContextProvider.js"; +import DatabaseContextProvider from "./DatabaseContextProvider.js"; +import DiffContextProvider from "./DiffContextProvider.js"; +import DocsContextProvider from "./DocsContextProvider.js"; +import FileTreeContextProvider from "./FileTreeContextProvider.js"; +import FolderContextProvider from "./FolderContextProvider.js"; +import GitHubIssuesContextProvider from "./GitHubIssuesContextProvider.js"; +import GitLabMergeRequestContextProvider from "./GitLabMergeRequestContextProvider.js"; +import GoogleContextProvider from "./GoogleContextProvider.js"; +import HttpContextProvider from "./HttpContextProvider.js"; +import JiraIssuesContextProvider from "./JiraIssuesContextProvider/index.js"; +import LocalsProvider from "./LocalsProvider.js"; +import OSContextProvider from "./OSContextProvider.js"; +import OpenFilesContextProvider from "./OpenFilesContextProvider.js"; +import PostgresContextProvider from "./PostgresContextProvider.js"; +import ProblemsContextProvider from "./ProblemsContextProvider.js"; +import SearchContextProvider from "./SearchContextProvider.js"; +import TerminalContextProvider from "./TerminalContextProvider.js"; +import URLContextProvider from "./URLContextProvider.js"; const Providers: (typeof BaseContextProvider)[] = [ DiffContextProvider, diff --git a/core/context/rerankers/cohere.ts b/core/context/rerankers/cohere.ts index e2a9a98e6..7a0dcf2dc 100644 --- a/core/context/rerankers/cohere.ts +++ b/core/context/rerankers/cohere.ts @@ -1,5 +1,5 @@ import fetch from "node-fetch"; -import { Chunk, Reranker } from "../.."; +import { Chunk, Reranker } from "../../index.js"; export class CohereReranker implements Reranker { name = "cohere"; @@ -18,7 +18,7 @@ export class CohereReranker implements Reranker { ) {} async rerank(query: string, chunks: Chunk[]): Promise { - let apiBase = this.params.apiBase ?? CohereReranker.defaultOptions.apiBase + let apiBase = this.params.apiBase ?? CohereReranker.defaultOptions.apiBase; if (!apiBase.endsWith("/")) { apiBase += "/"; } diff --git a/core/context/rerankers/freeTrial.ts b/core/context/rerankers/freeTrial.ts index 4e6200822..a43930543 100644 --- a/core/context/rerankers/freeTrial.ts +++ b/core/context/rerankers/freeTrial.ts @@ -1,7 +1,7 @@ import fetch from "node-fetch"; -import { Chunk, Reranker } from "../.."; -import { getHeaders } from "../../continueServer/stubs/headers"; -import { SERVER_URL } from "../../util/parameters"; +import { Chunk, Reranker } from "../../index.js"; +import { getHeaders } from "../../continueServer/stubs/headers.js"; +import { SERVER_URL } from "../../util/parameters.js"; export class FreeTrialReranker implements Reranker { name = "free-trial"; diff --git a/core/context/rerankers/index.ts b/core/context/rerankers/index.ts index b2dad8dec..0a7cc685a 100644 --- a/core/context/rerankers/index.ts +++ b/core/context/rerankers/index.ts @@ -1,8 +1,8 @@ -import { RerankerName } from "../.."; -import { CohereReranker } from "./cohere"; -import { FreeTrialReranker } from "./freeTrial"; -import { LLMReranker } from "./llm"; -import { VoyageReranker } from "./voyage"; +import { RerankerName } from "../../index.js"; +import { CohereReranker } from "./cohere.js"; +import { FreeTrialReranker } from "./freeTrial.js"; +import { LLMReranker } from "./llm.js"; +import { VoyageReranker } from "./voyage.js"; export const AllRerankers: { [key in RerankerName]: any } = { cohere: CohereReranker, diff --git a/core/context/rerankers/llm.ts b/core/context/rerankers/llm.ts index f108d5a62..cd6b886ac 100644 --- a/core/context/rerankers/llm.ts +++ b/core/context/rerankers/llm.ts @@ -1,5 +1,5 @@ -import { Chunk, ILLM, Reranker } from "../.."; -import { getBasename } from "../../util"; +import { Chunk, ILLM, Reranker } from "../../index.js"; +import { getBasename } from "../../util/index.js"; const RERANK_PROMPT = ( query: string, diff --git a/core/context/rerankers/voyage.ts b/core/context/rerankers/voyage.ts index d44581e5c..e2a969350 100644 --- a/core/context/rerankers/voyage.ts +++ b/core/context/rerankers/voyage.ts @@ -1,5 +1,5 @@ import fetch from "node-fetch"; -import { Chunk, Reranker } from "../.."; +import { Chunk, Reranker } from "../../index.js"; export class VoyageReranker implements Reranker { name = "voyage"; diff --git a/core/context/retrieval/fullTextSearch.ts b/core/context/retrieval/fullTextSearch.ts index 34ec2e0a0..504037497 100644 --- a/core/context/retrieval/fullTextSearch.ts +++ b/core/context/retrieval/fullTextSearch.ts @@ -1,5 +1,5 @@ -import { BranchAndDir, Chunk } from "../.."; -import { FullTextSearchCodebaseIndex } from "../../indexing/FullTextSearch"; +import { BranchAndDir, Chunk } from "../../index.js"; +import { FullTextSearchCodebaseIndex } from "../../indexing/FullTextSearch.js"; export async function retrieveFts( query: string, n: number, diff --git a/core/context/retrieval/retrieval.ts b/core/context/retrieval/retrieval.ts index 9527aaa83..ff2132ba4 100644 --- a/core/context/retrieval/retrieval.ts +++ b/core/context/retrieval/retrieval.ts @@ -1,9 +1,9 @@ -import { BranchAndDir, Chunk, ContextItem, ContextProviderExtras } from "../.."; -import { LanceDbIndex } from "../../indexing/LanceDbIndex"; +import { BranchAndDir, Chunk, ContextItem, ContextProviderExtras } from "../../index.js"; +import { LanceDbIndex } from "../../indexing/LanceDbIndex.js"; -import { deduplicateArray, getBasename } from "../../util"; -import { RETRIEVAL_PARAMS } from "../../util/parameters"; -import { retrieveFts } from "./fullTextSearch"; +import { deduplicateArray, getBasename } from "../../util/index.js"; +import { RETRIEVAL_PARAMS } from "../../util/parameters.js"; +import { retrieveFts } from "./fullTextSearch.js"; function deduplicateChunks(chunks: Chunk[]): Chunk[] { return deduplicateArray(chunks, (a, b) => { diff --git a/core/continueServer/interface.ts b/core/continueServer/interface.ts index a306b03ae..72d129733 100644 --- a/core/continueServer/interface.ts +++ b/core/continueServer/interface.ts @@ -1,4 +1,4 @@ -import { Chunk } from ".."; +import { Chunk } from "../index.js"; export interface EmbeddingsCacheChunk { vector: number[]; diff --git a/core/continueServer/stubs/client.ts b/core/continueServer/stubs/client.ts index cfdde054c..98d429e87 100644 --- a/core/continueServer/stubs/client.ts +++ b/core/continueServer/stubs/client.ts @@ -2,7 +2,7 @@ import { ArtifactType, EmbeddingsCacheResponse, IContinueServerClient, -} from "../interface"; +} from "../interface.js"; export class ContinueServerClient implements IContinueServerClient { constructor( diff --git a/core/diff/streamDiff.ts b/core/diff/streamDiff.ts index f30e76e07..53446d387 100644 --- a/core/diff/streamDiff.ts +++ b/core/diff/streamDiff.ts @@ -1,5 +1,5 @@ -import { DiffLine } from ".."; -import { LineStream, matchLine } from "./util"; +import { DiffLine } from "../index.js"; +import { LineStream, matchLine } from "./util.js"; /** * https://blog.jcoglan.com/2017/02/12/the-myers-diff-algorithm-part-1/ diff --git a/core/diff/util.ts b/core/diff/util.ts index ade376291..0cbef6a4d 100644 --- a/core/diff/util.ts +++ b/core/diff/util.ts @@ -1,6 +1,6 @@ import { distance } from "fastest-levenshtein"; -import { ChatMessage } from ".."; -import { stripImages } from "../llm/countTokens"; +import { ChatMessage } from "../index.js"; +import { stripImages } from "../llm/countTokens.js"; export type LineStream = AsyncGenerator; diff --git a/core/indexing/CodeSnippetsIndex.ts b/core/indexing/CodeSnippetsIndex.ts index 6d9fa6037..73dc4973c 100644 --- a/core/indexing/CodeSnippetsIndex.ts +++ b/core/indexing/CodeSnippetsIndex.ts @@ -7,20 +7,20 @@ import { IDE, IndexTag, IndexingProgressUpdate, -} from ".."; -import { getBasename } from "../util"; +} from "../index.js"; +import { getBasename } from "../util/index.js"; import { getLanguageForFile, getParserForFile, supportedLanguages, -} from "../util/treeSitter"; -import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex"; +} from "../util/treeSitter.js"; +import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex.js"; import { CodebaseIndex, IndexResultType, MarkCompleteCallback, RefreshIndexResults, -} from "./types"; +} from "./types.js"; export class CodeSnippetsCodebaseIndex implements CodebaseIndex { artifactId = "codeSnippets"; @@ -118,7 +118,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { // Add snippets to sqlite for (const snippet of snippets) { const { lastID } = await db.run( - `INSERT INTO code_snippets (path, cacheKey, content, title, startLine, endLine) VALUES (?, ?, ?, ?, ?, ?)`, + "INSERT INTO code_snippets (path, cacheKey, content, title, startLine, endLine) VALUES (?, ?, ?, ?, ?, ?)", [ compute.path, compute.cacheKey, @@ -130,7 +130,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { ); await db.run( - `INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)`, + "INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)", [lastID, tagString], ); } @@ -146,10 +146,10 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { for (let i = 0; i < results.del.length; i++) { const del = results.del[i]; const deleted = await db.run( - `DELETE FROM code_snippets WHERE path = ? AND cacheKey = ?`, + "DELETE FROM code_snippets WHERE path = ? AND cacheKey = ?", [del.path, del.cacheKey], ); - await db.run(`DELETE FROM code_snippets_tags WHERE snippetId = ?`, [ + await db.run("DELETE FROM code_snippets_tags WHERE snippetId = ?", [ deleted.lastID, ]); markComplete([del], IndexResultType.Delete); @@ -157,13 +157,13 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { for (let i = 0; i < results.addTag.length; i++) { const snippetsWithPath = await db.all( - `SELECT * FROM code_snippets WHERE cacheKey = ?`, + "SELECT * FROM code_snippets WHERE cacheKey = ?", [results.addTag[i].cacheKey], ); for (const snippet of snippetsWithPath) { await db.run( - `INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)`, + "INSERT INTO code_snippets_tags (snippetId, tag) VALUES (?, ?)", [snippet.id, tagString], ); } @@ -190,7 +190,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { static async getForId(id: number): Promise { const db = await SqliteDb.get(); - const row = await db.get(`SELECT * FROM code_snippets WHERE id = ?`, [id]); + const row = await db.get("SELECT * FROM code_snippets WHERE id = ?", [id]); return { name: row.title, diff --git a/core/indexing/FullTextSearch.ts b/core/indexing/FullTextSearch.ts index fd0374ad1..8caa65c48 100644 --- a/core/indexing/FullTextSearch.ts +++ b/core/indexing/FullTextSearch.ts @@ -1,13 +1,13 @@ -import { BranchAndDir, Chunk, IndexTag, IndexingProgressUpdate } from ".."; -import { RETRIEVAL_PARAMS } from "../util/parameters"; -import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex"; -import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex"; +import { BranchAndDir, Chunk, IndexTag, IndexingProgressUpdate } from "../index.js"; +import { RETRIEVAL_PARAMS } from "../util/parameters.js"; +import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex.js"; +import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex.js"; import { CodebaseIndex, IndexResultType, MarkCompleteCallback, RefreshIndexResults, -} from "./types"; +} from "./types.js"; export class FullTextSearchCodebaseIndex implements CodebaseIndex { artifactId: string = "sqliteFts"; @@ -43,17 +43,17 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex { // Insert chunks const chunks = await db.all( - `SELECT * FROM chunks WHERE path = ? AND cacheKey = ?`, + "SELECT * FROM chunks WHERE path = ? AND cacheKey = ?", [item.path, item.cacheKey], ); for (let chunk of chunks) { const { lastID } = await db.run( - `INSERT INTO fts (path, content) VALUES (?, ?)`, + "INSERT INTO fts (path, content) VALUES (?, ?)", [item.path, chunk.content], ); await db.run( - `INSERT INTO fts_metadata (id, path, cacheKey, chunkId) VALUES (?, ?, ?, ?)`, + "INSERT INTO fts_metadata (id, path, cacheKey, chunkId) VALUES (?, ?, ?, ?)", [lastID, item.path, item.cacheKey, chunk.id], ); } @@ -79,10 +79,10 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex { // Delete for (const item of results.del) { const { lastID } = await db.run( - `DELETE FROM fts_metadata WHERE path = ? AND cacheKey = ?`, + "DELETE FROM fts_metadata WHERE path = ? AND cacheKey = ?", [item.path, item.cacheKey], ); - await db.run(`DELETE FROM fts WHERE rowid = ?`, [lastID]); + await db.run("DELETE FROM fts WHERE rowid = ?", [lastID]); markComplete([item], IndexResultType.Delete); } diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index 8bca1d583..1b50b0536 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -7,19 +7,19 @@ import { EmbeddingsProvider, IndexTag, IndexingProgressUpdate, -} from ".."; -import { ContinueServerClient } from "../continueServer/stubs/client"; -import { MAX_CHUNK_SIZE } from "../llm/constants"; -import { getBasename } from "../util"; -import { getLanceDbPath } from "../util/paths"; -import { chunkDocument } from "./chunk/chunk"; -import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex"; +} from "../index.js"; +import { ContinueServerClient } from "../continueServer/stubs/client.js"; +import { MAX_CHUNK_SIZE } from "../llm/constants.js"; +import { getBasename } from "../util/index.js"; +import { getLanceDbPath } from "../util/paths.js"; +import { chunkDocument } from "./chunk/chunk.js"; +import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex.js"; import { CodebaseIndex, IndexResultType, PathAndCacheKey, RefreshIndexResults, -} from "./types"; +} from "./types.js"; // LanceDB converts to lowercase, so names must all be lowercase interface LanceDbRow { diff --git a/core/indexing/chunk/ChunkCodebaseIndex.ts b/core/indexing/chunk/ChunkCodebaseIndex.ts index 355aefdbc..81b89f3cb 100644 --- a/core/indexing/chunk/ChunkCodebaseIndex.ts +++ b/core/indexing/chunk/ChunkCodebaseIndex.ts @@ -1,15 +1,15 @@ -import { Chunk, IndexTag, IndexingProgressUpdate } from "../.."; -import { ContinueServerClient } from "../../continueServer/stubs/client"; -import { MAX_CHUNK_SIZE } from "../../llm/constants"; -import { getBasename } from "../../util"; -import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex"; +import { Chunk, IndexTag, IndexingProgressUpdate } from "../../index.js"; +import { ContinueServerClient } from "../../continueServer/stubs/client.js"; +import { MAX_CHUNK_SIZE } from "../../llm/constants.js"; +import { getBasename } from "../../util/index.js"; +import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex.js"; import { CodebaseIndex, IndexResultType, MarkCompleteCallback, RefreshIndexResults, -} from "../types"; -import { chunkDocument } from "./chunk"; +} from "../types.js"; +import { chunkDocument } from "./chunk.js"; export class ChunkCodebaseIndex implements CodebaseIndex { static artifactId: string = "chunks"; @@ -53,7 +53,7 @@ export class ChunkCodebaseIndex implements CodebaseIndex { async function handleChunk(chunk: Chunk) { const { lastID } = await db.run( - `INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)`, + "INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)", [ chunk.digest, chunk.filepath, @@ -64,7 +64,7 @@ export class ChunkCodebaseIndex implements CodebaseIndex { ], ); - await db.run(`INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)`, [ + await db.run("INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)", [ lastID, tagString, ]); @@ -121,12 +121,12 @@ export class ChunkCodebaseIndex implements CodebaseIndex { // Add tag for (const item of results.addTag) { const chunksWithPath = await db.all( - `SELECT * FROM chunks WHERE cacheKey = ?`, + "SELECT * FROM chunks WHERE cacheKey = ?", [item.cacheKey], ); for (const chunk of chunksWithPath) { - await db.run(`INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)`, [ + await db.run("INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)", [ chunk.id, tagString, ]); @@ -153,12 +153,12 @@ export class ChunkCodebaseIndex implements CodebaseIndex { // Delete for (const item of results.del) { - const deleted = await db.run(`DELETE FROM chunks WHERE cacheKey = ?`, [ + const deleted = await db.run("DELETE FROM chunks WHERE cacheKey = ?", [ item.cacheKey, ]); // Delete from chunk_tags - await db.run(`DELETE FROM chunk_tags WHERE chunkId = ?`, [ + await db.run("DELETE FROM chunk_tags WHERE chunkId = ?", [ deleted.lastID, ]); diff --git a/core/indexing/chunk/basic.ts b/core/indexing/chunk/basic.ts index 454e80202..90733b031 100644 --- a/core/indexing/chunk/basic.ts +++ b/core/indexing/chunk/basic.ts @@ -1,5 +1,5 @@ -import { ChunkWithoutID } from "../.."; -import { countTokens } from "../../llm/countTokens"; +import { ChunkWithoutID } from "../../index.js"; +import { countTokens } from "../../llm/countTokens.js"; export function* basicChunker( contents: string, diff --git a/core/indexing/chunk/chunk.ts b/core/indexing/chunk/chunk.ts index e37d999d6..5db46ca26 100644 --- a/core/indexing/chunk/chunk.ts +++ b/core/indexing/chunk/chunk.ts @@ -1,9 +1,9 @@ -import { Chunk, ChunkWithoutID } from "../.."; -import { MAX_CHUNK_SIZE } from "../../llm/constants"; -import { countTokens } from "../../llm/countTokens"; -import { supportedLanguages } from "../../util/treeSitter"; -import { basicChunker } from "./basic"; -import { codeChunker } from "./code"; +import { Chunk, ChunkWithoutID } from "../../index.js"; +import { MAX_CHUNK_SIZE } from "../../llm/constants.js"; +import { countTokens } from "../../llm/countTokens.js"; +import { supportedLanguages } from "../../util/treeSitter.js"; +import { basicChunker } from "./basic.js"; +import { codeChunker } from "./code.js"; async function* chunkDocumentWithoutId( filepath: string, diff --git a/core/indexing/chunk/code.ts b/core/indexing/chunk/code.ts index f76628132..651e578a6 100644 --- a/core/indexing/chunk/code.ts +++ b/core/indexing/chunk/code.ts @@ -1,7 +1,7 @@ import { SyntaxNode } from "web-tree-sitter"; -import { ChunkWithoutID } from "../.."; -import { countTokens } from "../../llm/countTokens"; -import { getParserForFile } from "../../util/treeSitter"; +import { ChunkWithoutID } from "../../index.js"; +import { countTokens } from "../../llm/countTokens.js"; +import { getParserForFile } from "../../util/treeSitter.js"; function collapsedReplacement(node: SyntaxNode): string { if (node.type === "statement_block") { diff --git a/core/indexing/chunk/markdown.ts b/core/indexing/chunk/markdown.ts index 0542004b0..a4a41f78a 100644 --- a/core/indexing/chunk/markdown.ts +++ b/core/indexing/chunk/markdown.ts @@ -1,6 +1,6 @@ -import { ChunkWithoutID } from "../.."; -import { countTokens } from "../../llm/countTokens"; -import { basicChunker } from "./basic"; +import { ChunkWithoutID } from "../../index.js"; +import { countTokens } from "../../llm/countTokens.js"; +import { basicChunker } from "./basic.js"; export function cleanFragment( fragment: string | undefined, diff --git a/core/indexing/docs/article.ts b/core/indexing/docs/article.ts index e97bd3aec..4bf2055ca 100644 --- a/core/indexing/docs/article.ts +++ b/core/indexing/docs/article.ts @@ -1,9 +1,9 @@ import { Readability } from "@mozilla/readability"; import { JSDOM } from "jsdom"; -import { Chunk } from "../.."; -import { MAX_CHUNK_SIZE } from "../../llm/constants"; -import { cleanFragment, cleanHeader } from "../chunk/markdown"; -import { PageData } from "./crawl"; +import { Chunk } from "../../index.js"; +import { MAX_CHUNK_SIZE } from "../../llm/constants.js"; +import { cleanFragment, cleanHeader } from "../chunk/markdown.js"; +import { PageData } from "./crawl.js"; export type ArticleComponent = { title: string; diff --git a/core/indexing/docs/db.ts b/core/indexing/docs/db.ts index 2e94aba91..02d0502d9 100644 --- a/core/indexing/docs/db.ts +++ b/core/indexing/docs/db.ts @@ -1,10 +1,10 @@ import { Database, open } from "sqlite"; import sqlite3 from "sqlite3"; -import { Chunk } from "../.."; -import { getDocsSqlitePath, getLanceDbPath } from "../../util/paths"; +import { Chunk } from "../../index.js"; +import { getDocsSqlitePath, getLanceDbPath } from "../../util/paths.js"; -import { downloadPreIndexedDocs } from "./preIndexed"; -import { default as configs } from "./preIndexedDocs"; +import { downloadPreIndexedDocs } from "./preIndexed.js"; +import { default as configs } from "./preIndexedDocs.js"; const DOCS_TABLE_NAME = "docs"; @@ -69,7 +69,7 @@ export async function retrieveDocs( const tableNames = await lance.tableNames(); if (!tableNames.includes(DOCS_TABLE_NAME)) { const downloaded = await downloadDocs(); - if (downloaded) return downloaded; + if (downloaded) {return downloaded;} } const table = await lance.openTable(DOCS_TABLE_NAME); @@ -83,7 +83,7 @@ export async function retrieveDocs( if ((!docs || docs.length === 0) && !nested) { const downloaded = await downloadDocs(); - if (downloaded) return downloaded; + if (downloaded) {return downloaded;} } return docs.map((doc) => ({ @@ -128,7 +128,7 @@ export async function addDocs( // Only after add it to SQLite const db = await getDBDocs(); await db.run( - `INSERT INTO docs (title, baseUrl) VALUES (?, ?)`, + "INSERT INTO docs (title, baseUrl) VALUES (?, ?)", title, baseUrl.toString(), ); @@ -138,12 +138,12 @@ export async function listDocs(): Promise< { title: string; baseUrl: string }[] > { const db = await getDBDocs(); - const docs = db.all(`SELECT title, baseUrl FROM docs`); + const docs = db.all("SELECT title, baseUrl FROM docs"); return docs; } export async function hasDoc(baseUrl: string) { const db = await getDBDocs(); - const doc = await db.get(`SELECT title FROM docs WHERE baseUrl =?`, baseUrl); + const doc = await db.get("SELECT title FROM docs WHERE baseUrl =?", baseUrl); return !!doc; } diff --git a/core/indexing/docs/index.ts b/core/indexing/docs/index.ts index 255036bf2..b2ddb7833 100644 --- a/core/indexing/docs/index.ts +++ b/core/indexing/docs/index.ts @@ -1,8 +1,8 @@ -import { Chunk, EmbeddingsProvider, IndexingProgressUpdate } from "../.."; +import { Chunk, EmbeddingsProvider, IndexingProgressUpdate } from "../../index.js"; -import { Article, chunkArticle, pageToArticle } from "./article"; -import { crawlPage } from "./crawl"; -import { addDocs, hasDoc } from "./db"; +import { Article, chunkArticle, pageToArticle } from "./article.js"; +import { crawlPage } from "./crawl.js"; +import { addDocs, hasDoc } from "./db.js"; export async function* indexDocs( title: string, @@ -28,7 +28,7 @@ export async function* indexDocs( for await (const page of crawlPage(baseUrl)) { const article = pageToArticle(page); - if (!article) continue; + if (!article) {continue;} articles.push(article); diff --git a/core/indexing/docs/preIndexed.ts b/core/indexing/docs/preIndexed.ts index 7b5c6f9a6..275abf4f6 100644 --- a/core/indexing/docs/preIndexed.ts +++ b/core/indexing/docs/preIndexed.ts @@ -1,5 +1,5 @@ -import { Chunk } from "../.."; -import { addDocs } from "./db"; +import { Chunk } from "../../index.js"; +import { addDocs } from "./db.js"; const request = require("request"); diff --git a/core/indexing/embeddings/BaseEmbeddingsProvider.ts b/core/indexing/embeddings/BaseEmbeddingsProvider.ts index e15bf9c76..755f6c1e9 100644 --- a/core/indexing/embeddings/BaseEmbeddingsProvider.ts +++ b/core/indexing/embeddings/BaseEmbeddingsProvider.ts @@ -1,4 +1,4 @@ -import { EmbedOptions, EmbeddingsProvider, FetchFunction } from "../.."; +import { EmbedOptions, EmbeddingsProvider, FetchFunction } from "../../index.js"; class BaseEmbeddingsProvider implements EmbeddingsProvider { options: EmbedOptions; diff --git a/core/indexing/embeddings/CohereEmbeddingsProvider.ts b/core/indexing/embeddings/CohereEmbeddingsProvider.ts index 0668d49c4..2d0194568 100644 --- a/core/indexing/embeddings/CohereEmbeddingsProvider.ts +++ b/core/indexing/embeddings/CohereEmbeddingsProvider.ts @@ -1,7 +1,7 @@ import { Response } from "node-fetch"; -import { EmbedOptions } from "../.."; -import { withExponentialBackoff } from "../../util/withExponentialBackoff"; -import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider"; +import { EmbedOptions } from "../../index.js"; +import { withExponentialBackoff } from "../../util/withExponentialBackoff.js"; +import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js"; class CohereEmbeddingsProvider extends BaseEmbeddingsProvider { static maxBatchSize = 96; diff --git a/core/indexing/embeddings/DeepInfraEmbeddingsProvider.ts b/core/indexing/embeddings/DeepInfraEmbeddingsProvider.ts index 60560fe3a..e229c74e7 100644 --- a/core/indexing/embeddings/DeepInfraEmbeddingsProvider.ts +++ b/core/indexing/embeddings/DeepInfraEmbeddingsProvider.ts @@ -1,6 +1,6 @@ -import { EmbedOptions } from "../.."; -import { withExponentialBackoff } from "../../util/withExponentialBackoff"; -import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider"; +import { EmbedOptions } from "../../index.js"; +import { withExponentialBackoff } from "../../util/withExponentialBackoff.js"; +import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js"; class DeepInfraEmbeddingsProvider extends BaseEmbeddingsProvider { static defaultOptions: Partial | undefined = { diff --git a/core/indexing/embeddings/FreeTrialEmbeddingsProvider.ts b/core/indexing/embeddings/FreeTrialEmbeddingsProvider.ts index b5622788d..2a5a29625 100644 --- a/core/indexing/embeddings/FreeTrialEmbeddingsProvider.ts +++ b/core/indexing/embeddings/FreeTrialEmbeddingsProvider.ts @@ -1,9 +1,9 @@ import { Response } from "node-fetch"; -import { EmbedOptions } from "../.."; -import { getHeaders } from "../../continueServer/stubs/headers"; -import { SERVER_URL } from "../../util/parameters"; -import { withExponentialBackoff } from "../../util/withExponentialBackoff"; -import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider"; +import { EmbedOptions } from "../../index.js"; +import { getHeaders } from "../../continueServer/stubs/headers.js"; +import { SERVER_URL } from "../../util/parameters.js"; +import { withExponentialBackoff } from "../../util/withExponentialBackoff.js"; +import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js"; class FreeTrialEmbeddingsProvider extends BaseEmbeddingsProvider { static maxBatchSize = 128; diff --git a/core/indexing/embeddings/OllamaEmbeddingsProvider.ts b/core/indexing/embeddings/OllamaEmbeddingsProvider.ts index e66d2f3e8..e40cc46e1 100644 --- a/core/indexing/embeddings/OllamaEmbeddingsProvider.ts +++ b/core/indexing/embeddings/OllamaEmbeddingsProvider.ts @@ -1,6 +1,6 @@ -import { EmbedOptions, FetchFunction } from "../.."; -import { withExponentialBackoff } from "../../util/withExponentialBackoff"; -import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider"; +import { EmbedOptions, FetchFunction } from "../../index.js"; +import { withExponentialBackoff } from "../../util/withExponentialBackoff.js"; +import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js"; async function embedOne( chunk: string, diff --git a/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts b/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts index 36987cb80..15660bba4 100644 --- a/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts +++ b/core/indexing/embeddings/OpenAIEmbeddingsProvider.ts @@ -1,7 +1,7 @@ import { Response } from "node-fetch"; -import { EmbedOptions } from "../.."; -import { withExponentialBackoff } from "../../util/withExponentialBackoff"; -import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider"; +import { EmbedOptions } from "../../index.js"; +import { withExponentialBackoff } from "../../util/withExponentialBackoff.js"; +import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js"; class OpenAIEmbeddingsProvider extends BaseEmbeddingsProvider { // https://platform.openai.com/docs/api-reference/embeddings/create is 2048 diff --git a/core/indexing/embeddings/TransformersJsEmbeddingsProvider.ts b/core/indexing/embeddings/TransformersJsEmbeddingsProvider.ts index 39e3e4967..67fce631f 100644 --- a/core/indexing/embeddings/TransformersJsEmbeddingsProvider.ts +++ b/core/indexing/embeddings/TransformersJsEmbeddingsProvider.ts @@ -2,7 +2,7 @@ import { PipelineType, env, pipeline } from "../../vendor/modules/@xenova/transformers/src/transformers.js"; import path from "path"; -import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider"; +import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js"; env.allowLocalModels = true; env.allowRemoteModels = false; diff --git a/core/indexing/embeddings/index.ts b/core/indexing/embeddings/index.ts index 73a030ad7..268d5115f 100644 --- a/core/indexing/embeddings/index.ts +++ b/core/indexing/embeddings/index.ts @@ -1,9 +1,9 @@ -import { EmbeddingsProviderName } from "../.."; -import CohereEmbeddingsProvider from "./CohereEmbeddingsProvider"; -import FreeTrialEmbeddingsProvider from "./FreeTrialEmbeddingsProvider"; -import OllamaEmbeddingsProvider from "./OllamaEmbeddingsProvider"; -import OpenAIEmbeddingsProvider from "./OpenAIEmbeddingsProvider"; -import TransformersJsEmbeddingsProvider from "./TransformersJsEmbeddingsProvider"; +import { EmbeddingsProviderName } from "../../index.js"; +import CohereEmbeddingsProvider from "./CohereEmbeddingsProvider.js"; +import FreeTrialEmbeddingsProvider from "./FreeTrialEmbeddingsProvider.js"; +import OllamaEmbeddingsProvider from "./OllamaEmbeddingsProvider.js"; +import OpenAIEmbeddingsProvider from "./OpenAIEmbeddingsProvider.js"; +import TransformersJsEmbeddingsProvider from "./TransformersJsEmbeddingsProvider.js"; export const AllEmbeddingsProviders: { [key in EmbeddingsProviderName]: any; diff --git a/core/indexing/indexCodebase.ts b/core/indexing/indexCodebase.ts index e43a3062e..0aef8c1f3 100644 --- a/core/indexing/indexCodebase.ts +++ b/core/indexing/indexCodebase.ts @@ -1,12 +1,12 @@ -import { IDE, IndexTag, IndexingProgressUpdate } from ".."; -import { ConfigHandler } from "../config/handler"; -import { ContinueServerClient } from "../continueServer/stubs/client"; -import { CodeSnippetsCodebaseIndex } from "./CodeSnippetsIndex"; -import { FullTextSearchCodebaseIndex } from "./FullTextSearch"; -import { LanceDbIndex } from "./LanceDbIndex"; -import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex"; -import { getComputeDeleteAddRemove } from "./refreshIndex"; -import { CodebaseIndex } from "./types"; +import { IDE, IndexTag, IndexingProgressUpdate } from "../index.js"; +import { ConfigHandler } from "../config/handler.js"; +import { ContinueServerClient } from "../continueServer/stubs/client.js"; +import { CodeSnippetsCodebaseIndex } from "./CodeSnippetsIndex.js"; +import { FullTextSearchCodebaseIndex } from "./FullTextSearch.js"; +import { LanceDbIndex } from "./LanceDbIndex.js"; +import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex.js"; +import { getComputeDeleteAddRemove } from "./refreshIndex.js"; +import { CodebaseIndex } from "./types.js"; export class PauseToken { constructor(private _paused: boolean) {} diff --git a/core/indexing/refreshIndex.ts b/core/indexing/refreshIndex.ts index 3987b3519..192c9378b 100644 --- a/core/indexing/refreshIndex.ts +++ b/core/indexing/refreshIndex.ts @@ -2,8 +2,8 @@ import crypto from "crypto"; import * as fs from "fs"; import { Database, open } from "sqlite"; import sqlite3 from "sqlite3"; -import { IndexTag, IndexingProgressUpdate } from ".."; -import { getIndexSqlitePath } from "../util/paths"; +import { IndexTag, IndexingProgressUpdate } from "../index.js"; +import { getIndexSqlitePath } from "../util/paths.js"; import { CodebaseIndex, IndexResultType, @@ -11,7 +11,7 @@ import { MarkCompleteCallback, PathAndCacheKey, RefreshIndexResults, -} from "./types"; +} from "./types.js"; export type DatabaseConnection = Database; @@ -157,7 +157,7 @@ async function getAddRemoveForTag( switch (resultType) { case AddRemoveResultType.Add: await db.run( - `INSERT INTO tag_catalog (path, cacheKey, lastUpdated, dir, branch, artifactId) VALUES (?, ?, ?, ?, ?, ?)`, + "INSERT INTO tag_catalog (path, cacheKey, lastUpdated, dir, branch, artifactId) VALUES (?, ?, ?, ?, ?, ?)", path, cacheKey, newLastUpdatedTimestamp, @@ -243,7 +243,7 @@ async function getTagsFromGlobalCache( ): Promise { const db = await SqliteDb.get(); const stmt = await db.prepare( - `SELECT dir, branch, artifactId FROM global_cache WHERE cacheKey = ? AND artifactId = ?`, + "SELECT dir, branch, artifactId FROM global_cache WHERE cacheKey = ? AND artifactId = ?", ); const rows = await stmt.all(cacheKey, artifactId); return rows; diff --git a/core/indexing/types.ts b/core/indexing/types.ts index 6715413ad..3e3923e99 100644 --- a/core/indexing/types.ts +++ b/core/indexing/types.ts @@ -1,4 +1,4 @@ -import { IndexTag, IndexingProgressUpdate } from ".."; +import { IndexTag, IndexingProgressUpdate } from "../index.js"; export enum IndexResultType { Compute = "compute", diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 76185b657..1e526f612 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -1,4 +1,4 @@ -import { ModelProvider, TemplateType } from ".."; +import { ModelProvider, TemplateType } from "../index.js"; import { anthropicTemplateMessages, chatmlTemplateMessages, @@ -15,7 +15,7 @@ import { templateAlpacaMessages, xWinCoderTemplateMessages, zephyrTemplateMessages, -} from "./templates/chat"; +} from "./templates/chat.js"; import { alpacaEditPrompt, claudeEditPrompt, @@ -32,7 +32,7 @@ import { simplifiedEditPrompt, xWinCoderEditPrompt, zephyrEditPrompt, -} from "./templates/edit"; +} from "./templates/edit.js"; const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [ "lmstudio", diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index f9818075f..7dcaf59e1 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -1,4 +1,4 @@ -import { ChatHistory, ChatMessage, MessagePart } from ".."; +import { ChatHistory, ChatMessage, MessagePart } from "../index.js"; export function constructMessages(history: ChatHistory): ChatMessage[] { const msgs = []; diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index ef0c3f921..eb2982dae 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -1,8 +1,8 @@ import { Tiktoken, encodingForModel as _encodingForModel } from "js-tiktoken"; -import { ChatMessage, MessageContent, MessagePart } from ".."; -import { autodetectTemplateType } from "./autodetect"; -import { TOKEN_BUFFER_FOR_SAFETY } from "./constants"; -import llamaTokenizer from "./llamaTokenizer"; +import { ChatMessage, MessageContent, MessagePart } from "../index.js"; +import { autodetectTemplateType } from "./autodetect.js"; +import { TOKEN_BUFFER_FOR_SAFETY } from "./constants.js"; +import llamaTokenizer from "./llamaTokenizer.js"; interface Encoding { encode: Tiktoken["encode"]; diff --git a/core/llm/index.ts b/core/llm/index.ts index d3c8a2b47..b597de15c 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -12,31 +12,31 @@ import { PromptTemplate, RequestOptions, TemplateType, -} from ".."; -import { DevDataSqliteDb } from "../util/devdataSqlite"; -import { fetchwithRequestOptions } from "../util/fetchWithOptions"; -import mergeJson from "../util/merge"; -import { Telemetry } from "../util/posthog"; -import { withExponentialBackoff } from "../util/withExponentialBackoff"; +} from "../index.js"; +import { DevDataSqliteDb } from "../util/devdataSqlite.js"; +import { fetchwithRequestOptions } from "../util/fetchWithOptions.js"; +import mergeJson from "../util/merge.js"; +import { Telemetry } from "../util/posthog.js"; +import { withExponentialBackoff } from "../util/withExponentialBackoff.js"; import { autodetectPromptTemplates, autodetectTemplateFunction, autodetectTemplateType, modelSupportsImages, -} from "./autodetect"; +} from "./autodetect.js"; import { CONTEXT_LENGTH_FOR_MODEL, DEFAULT_ARGS, DEFAULT_CONTEXT_LENGTH, DEFAULT_MAX_TOKENS, -} from "./constants"; +} from "./constants.js"; import { compileChatMessages, countTokens, pruneRawPromptFromTop, stripImages, -} from "./countTokens"; -import CompletionOptionsForModels from "./templates/options"; +} from "./countTokens.js"; +import CompletionOptionsForModels from "./templates/options.js"; export abstract class BaseLLM implements ILLM { static providerName: ModelProvider; diff --git a/core/llm/llms/Anthropic.ts b/core/llm/llms/Anthropic.ts index 974bfc7cd..d461ab706 100644 --- a/core/llm/llms/Anthropic.ts +++ b/core/llm/llms/Anthropic.ts @@ -1,12 +1,12 @@ -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, LLMOptions, ModelProvider, -} from "../.."; -import { stripImages } from "../countTokens"; -import { streamSse } from "../stream"; +} from "../../index.js"; +import { stripImages } from "../countTokens.js"; +import { streamSse } from "../stream.js"; class Anthropic extends BaseLLM { static providerName: ModelProvider = "anthropic"; diff --git a/core/llm/llms/Bedrock.ts b/core/llm/llms/Bedrock.ts index 1a6a883a8..582386659 100644 --- a/core/llm/llms/Bedrock.ts +++ b/core/llm/llms/Bedrock.ts @@ -2,14 +2,14 @@ import * as fs from "fs"; import os from "os"; import { join as joinPath } from "path"; import { promisify } from "util"; -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, LLMOptions, ModelProvider, -} from "../.."; -import { stripImages } from "../countTokens"; +} from "../../index.js"; +import { stripImages } from "../countTokens.js"; const aws4 = require("aws4"); const readFile = promisify(fs.readFile); diff --git a/core/llm/llms/Cohere.ts b/core/llm/llms/Cohere.ts index d5781f645..6ca492bb2 100644 --- a/core/llm/llms/Cohere.ts +++ b/core/llm/llms/Cohere.ts @@ -1,12 +1,12 @@ -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, LLMOptions, ModelProvider, -} from "../.."; -import { stripImages } from "../countTokens"; -import { streamJSON } from "../stream"; +} from "../../index.js"; +import { stripImages } from "../countTokens.js"; +import { streamJSON } from "../stream.js"; class Cohere extends BaseLLM { static providerName: ModelProvider = "cohere"; diff --git a/core/llm/llms/CustomLLM.ts b/core/llm/llms/CustomLLM.ts index 98045de3f..487eec7d9 100644 --- a/core/llm/llms/CustomLLM.ts +++ b/core/llm/llms/CustomLLM.ts @@ -1,10 +1,10 @@ -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, CustomLLM, ModelProvider, -} from "../.."; +} from "../../index.js"; class CustomLLMClass extends BaseLLM { get providerName(): ModelProvider { diff --git a/core/llm/llms/DeepInfra.ts b/core/llm/llms/DeepInfra.ts index 1a6952cfa..6b33a4bdc 100644 --- a/core/llm/llms/DeepInfra.ts +++ b/core/llm/llms/DeepInfra.ts @@ -1,5 +1,5 @@ -import { LLMOptions, ModelProvider } from "../.."; -import OpenAI from "./OpenAI"; +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; class DeepInfra extends OpenAI { static providerName: ModelProvider = "deepinfra"; diff --git a/core/llm/llms/Flowise.ts b/core/llm/llms/Flowise.ts index 482bcce25..942f94cb9 100644 --- a/core/llm/llms/Flowise.ts +++ b/core/llm/llms/Flowise.ts @@ -1,12 +1,12 @@ import socketIOClient, { Socket } from "socket.io-client"; -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, LLMOptions, ModelProvider, -} from "../.."; -import { stripImages } from "../countTokens"; +} from "../../index.js"; +import { stripImages } from "../countTokens.js"; interface IFlowiseApiOptions { /** Sampling temperature to use */ diff --git a/core/llm/llms/FreeTrial.ts b/core/llm/llms/FreeTrial.ts index ea542f375..d0932a622 100644 --- a/core/llm/llms/FreeTrial.ts +++ b/core/llm/llms/FreeTrial.ts @@ -1,8 +1,8 @@ -import { BaseLLM } from ".."; -import { ChatMessage, CompletionOptions, ModelProvider } from "../.."; -import { getHeaders } from "../../continueServer/stubs/headers"; -import { SERVER_URL } from "../../util/parameters"; -import { streamResponse } from "../stream"; +import { BaseLLM } from "../index.js"; +import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js"; +import { getHeaders } from "../../continueServer/stubs/headers.js"; +import { SERVER_URL } from "../../util/parameters.js"; +import { streamResponse } from "../stream.js"; class FreeTrial extends BaseLLM { static providerName: ModelProvider = "free-trial"; diff --git a/core/llm/llms/Gemini.ts b/core/llm/llms/Gemini.ts index fc9bac252..d07cdac0e 100644 --- a/core/llm/llms/Gemini.ts +++ b/core/llm/llms/Gemini.ts @@ -1,13 +1,13 @@ -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, LLMOptions, MessagePart, ModelProvider, -} from "../.."; -import { stripImages } from "../countTokens"; -import { streamResponse } from "../stream"; +} from "../../index.js"; +import { stripImages } from "../countTokens.js"; +import { streamResponse } from "../stream.js"; class Gemini extends BaseLLM { static providerName: ModelProvider = "gemini"; diff --git a/core/llm/llms/Groq.ts b/core/llm/llms/Groq.ts index bbb23051e..0aa5b5636 100644 --- a/core/llm/llms/Groq.ts +++ b/core/llm/llms/Groq.ts @@ -1,5 +1,5 @@ -import { LLMOptions, ModelProvider } from "../.."; -import OpenAI from "./OpenAI"; +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; class Groq extends OpenAI { static providerName: ModelProvider = "groq"; diff --git a/core/llm/llms/HuggingFaceInferenceAPI.ts b/core/llm/llms/HuggingFaceInferenceAPI.ts index 001680523..8b0be9711 100644 --- a/core/llm/llms/HuggingFaceInferenceAPI.ts +++ b/core/llm/llms/HuggingFaceInferenceAPI.ts @@ -1,6 +1,6 @@ -import { BaseLLM } from ".."; -import { CompletionOptions, ModelProvider } from "../.."; -import { streamSse } from "../stream"; +import { BaseLLM } from "../index.js"; +import { CompletionOptions, ModelProvider } from "../../index.js"; +import { streamSse } from "../stream.js"; class HuggingFaceInferenceAPI extends BaseLLM { static providerName: ModelProvider = "huggingface-inference-api"; diff --git a/core/llm/llms/HuggingFaceTGI.ts b/core/llm/llms/HuggingFaceTGI.ts index f7f759e1e..c3b66a4be 100644 --- a/core/llm/llms/HuggingFaceTGI.ts +++ b/core/llm/llms/HuggingFaceTGI.ts @@ -1,6 +1,6 @@ -import { BaseLLM } from ".."; -import { CompletionOptions, LLMOptions, ModelProvider } from "../.."; -import { streamSse } from "../stream"; +import { BaseLLM } from "../index.js"; +import { CompletionOptions, LLMOptions, ModelProvider } from "../../index.js"; +import { streamSse } from "../stream.js"; class HuggingFaceTGI extends BaseLLM { static providerName: ModelProvider = "huggingface-tgi"; diff --git a/core/llm/llms/LMStudio.ts b/core/llm/llms/LMStudio.ts index 5a63701e1..d1e15c395 100644 --- a/core/llm/llms/LMStudio.ts +++ b/core/llm/llms/LMStudio.ts @@ -1,5 +1,5 @@ -import { LLMOptions, ModelProvider } from "../.."; -import OpenAI from "./OpenAI"; +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; class LMStudio extends OpenAI { static providerName: ModelProvider = "lmstudio"; diff --git a/core/llm/llms/LlamaCpp.ts b/core/llm/llms/LlamaCpp.ts index c52f6e527..aa9defb36 100644 --- a/core/llm/llms/LlamaCpp.ts +++ b/core/llm/llms/LlamaCpp.ts @@ -1,6 +1,6 @@ -import { BaseLLM } from ".."; -import { CompletionOptions, LLMOptions, ModelProvider } from "../.."; -import { streamSse } from "../stream"; +import { BaseLLM } from "../index.js"; +import { CompletionOptions, LLMOptions, ModelProvider } from "../../index.js"; +import { streamSse } from "../stream.js"; class LlamaCpp extends BaseLLM { static providerName: ModelProvider = "llama.cpp"; diff --git a/core/llm/llms/Llamafile.ts b/core/llm/llms/Llamafile.ts index f22ec3ba7..0f95787ef 100644 --- a/core/llm/llms/Llamafile.ts +++ b/core/llm/llms/Llamafile.ts @@ -1,5 +1,5 @@ -import { ModelProvider } from "../.."; -import LlamaCpp from "./LlamaCpp"; +import { ModelProvider } from "../../index.js"; +import LlamaCpp from "./LlamaCpp.js"; class Llamafile extends LlamaCpp { static providerName: ModelProvider = "llamafile"; diff --git a/core/llm/llms/Mistral.ts b/core/llm/llms/Mistral.ts index 03a2b3a07..5ff9f20dd 100644 --- a/core/llm/llms/Mistral.ts +++ b/core/llm/llms/Mistral.ts @@ -1,5 +1,5 @@ -import { LLMOptions, ModelProvider } from "../.."; -import OpenAI from "./OpenAI"; +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; class Mistral extends OpenAI { static providerName: ModelProvider = "mistral"; diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index e5cfa27b8..39ed723bb 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -1,12 +1,12 @@ -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, LLMOptions, ModelProvider, -} from "../.."; -import { stripImages } from "../countTokens"; -import { streamResponse } from "../stream"; +} from "../../index.js"; +import { stripImages } from "../countTokens.js"; +import { streamResponse } from "../stream.js"; class Ollama extends BaseLLM { static providerName: ModelProvider = "ollama"; @@ -56,7 +56,7 @@ class Ollama extends BaseLLM { this.completionOptions.stop.push(JSON.parse(value)); } catch (e) { console.warn( - 'Error parsing stop parameter value "{value}: ${e}', + "Error parsing stop parameter value \"{value}: ${e}", ); } break; diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index 6f096b88b..4a4939daf 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -1,12 +1,12 @@ -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, LLMOptions, ModelProvider, -} from "../.."; -import { stripImages } from "../countTokens"; -import { streamSse } from "../stream"; +} from "../../index.js"; +import { stripImages } from "../countTokens.js"; +import { streamSse } from "../stream.js"; const NON_CHAT_MODELS = [ "text-davinci-002", diff --git a/core/llm/llms/OpenAIFreeTrial.ts b/core/llm/llms/OpenAIFreeTrial.ts index f2e936d24..d7d47d70e 100644 --- a/core/llm/llms/OpenAIFreeTrial.ts +++ b/core/llm/llms/OpenAIFreeTrial.ts @@ -1,6 +1,6 @@ -import { BaseLLM } from ".."; -import { ChatMessage, CompletionOptions, ModelProvider } from "../.."; -import { streamResponse } from "../stream"; +import { BaseLLM } from "../index.js"; +import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js"; +import { streamResponse } from "../stream.js"; // const SERVER_URL = "http://localhost:8080"; const SERVER_URL = "https://proxy-server-l6vsfbzhba-uw.a.run.app"; diff --git a/core/llm/llms/Replicate.ts b/core/llm/llms/Replicate.ts index 4ebe96332..4222854a4 100644 --- a/core/llm/llms/Replicate.ts +++ b/core/llm/llms/Replicate.ts @@ -1,6 +1,6 @@ import ReplicateClient from "replicate"; -import { BaseLLM } from ".."; -import { CompletionOptions, LLMOptions, ModelProvider } from "../.."; +import { BaseLLM } from "../index.js"; +import { CompletionOptions, LLMOptions, ModelProvider } from "../../index.js"; class Replicate extends BaseLLM { private static MODEL_IDS: { diff --git a/core/llm/llms/TextGenWebUI.ts b/core/llm/llms/TextGenWebUI.ts index ce7e65ebd..2ee36f94a 100644 --- a/core/llm/llms/TextGenWebUI.ts +++ b/core/llm/llms/TextGenWebUI.ts @@ -1,5 +1,5 @@ -import { LLMOptions, ModelProvider } from "../.."; -import OpenAI from "./OpenAI"; +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; class TextGenWebUI extends OpenAI { static providerName: ModelProvider = "text-gen-webui"; diff --git a/core/llm/llms/Together.ts b/core/llm/llms/Together.ts index c15b6d181..5ce9b8a9e 100644 --- a/core/llm/llms/Together.ts +++ b/core/llm/llms/Together.ts @@ -3,9 +3,9 @@ import { CompletionOptions, LLMOptions, ModelProvider, -} from "../.."; +} from "../../index.js"; -import OpenAI from "./OpenAI"; +import OpenAI from "./OpenAI.js"; class Together extends OpenAI { static providerName: ModelProvider = "together"; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 4b7f6f450..0f78b5e8b 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -1,32 +1,32 @@ import Handlebars from "handlebars"; -import { BaseLLM } from ".."; +import { BaseLLM } from "../index.js"; import { BaseCompletionOptions, ILLM, LLMOptions, ModelDescription, -} from "../.."; -import { DEFAULT_MAX_TOKENS } from "../constants"; -import Anthropic from "./Anthropic"; -import Bedrock from "./Bedrock"; -import Cohere from "./Cohere"; -import DeepInfra from "./DeepInfra"; -import Flowise from "./Flowise"; -import FreeTrial from "./FreeTrial"; -import Gemini from "./Gemini"; -import Groq from "./Groq"; -import HuggingFaceInferenceAPI from "./HuggingFaceInferenceAPI"; -import HuggingFaceTGI from "./HuggingFaceTGI"; -import LMStudio from "./LMStudio"; -import LlamaCpp from "./LlamaCpp"; -import Llamafile from "./Llamafile"; -import Mistral from "./Mistral"; -import Ollama from "./Ollama"; -import OpenAI from "./OpenAI"; -import OpenAIFreeTrial from "./OpenAIFreeTrial"; -import Replicate from "./Replicate"; -import TextGenWebUI from "./TextGenWebUI"; -import Together from "./Together"; +} from "../../index.js"; +import { DEFAULT_MAX_TOKENS } from "../constants.js"; +import Anthropic from "./Anthropic.js"; +import Bedrock from "./Bedrock.js"; +import Cohere from "./Cohere.js"; +import DeepInfra from "./DeepInfra.js"; +import Flowise from "./Flowise.js"; +import FreeTrial from "./FreeTrial.js"; +import Gemini from "./Gemini.js"; +import Groq from "./Groq.js"; +import HuggingFaceInferenceAPI from "./HuggingFaceInferenceAPI.js"; +import HuggingFaceTGI from "./HuggingFaceTGI.js"; +import LMStudio from "./LMStudio.js"; +import LlamaCpp from "./LlamaCpp.js"; +import Llamafile from "./Llamafile.js"; +import Mistral from "./Mistral.js"; +import Ollama from "./Ollama.js"; +import OpenAI from "./OpenAI.js"; +import OpenAIFreeTrial from "./OpenAIFreeTrial.js"; +import Replicate from "./Replicate.js"; +import TextGenWebUI from "./TextGenWebUI.js"; +import Together from "./Together.js"; function convertToLetter(num: number): string { let result = ""; diff --git a/core/llm/stream.ts b/core/llm/stream.ts index 02a35c365..9208d4c75 100644 --- a/core/llm/stream.ts +++ b/core/llm/stream.ts @@ -6,7 +6,7 @@ export async function* streamResponse( } if (!response.body) { - throw new Error(`No response body returned.`); + throw new Error("No response body returned."); } const stream = response.body as any; diff --git a/core/llm/templates/chat.ts b/core/llm/templates/chat.ts index a4f12771c..9da47e30a 100644 --- a/core/llm/templates/chat.ts +++ b/core/llm/templates/chat.ts @@ -1,5 +1,5 @@ -import { ChatMessage } from "../.."; -import { stripImages } from "../countTokens"; +import { ChatMessage } from "../../index.js"; +import { stripImages } from "../countTokens.js"; function templateFactory( systemMessage: (msg: ChatMessage) => string, diff --git a/core/llm/templates/edit.ts b/core/llm/templates/edit.ts index 26ee44a74..c5c68880b 100644 --- a/core/llm/templates/edit.ts +++ b/core/llm/templates/edit.ts @@ -1,4 +1,4 @@ -import { ChatMessage, PromptTemplate } from "../.."; +import { ChatMessage, PromptTemplate } from "../../index.js"; const simplifiedEditPrompt = `Consider the following code: \`\`\`{{{language}}} @@ -74,7 +74,7 @@ const osModelsEditPrompt: PromptTemplate = (history, otherData) => { !firstCharOfFirstLine; const suffixTag = isSuffix ? "" : ""; const suffixExplanation = isSuffix - ? ' When you get to "", end your response.' + ? " When you get to \"\", end your response." : ""; // If neither prefilling nor /v1/completions are supported, we have to use a chat prompt without putting words in the model's mouth diff --git a/core/llm/templates/options.ts b/core/llm/templates/options.ts index 1ebb02ba2..614cca52a 100644 --- a/core/llm/templates/options.ts +++ b/core/llm/templates/options.ts @@ -1,4 +1,4 @@ -import { CompletionOptions, ModelName } from "../.."; +import { CompletionOptions, ModelName } from "../../index.js"; const CompletionOptionsForModels: { [key in ModelName]?: Partial; diff --git a/core/package.json b/core/package.json index 94dfa639e..e93acca5b 100644 --- a/core/package.json +++ b/core/package.json @@ -1,10 +1,12 @@ { "name": "@continuedev/core", - "version": "1.0.10", + "version": "1.0.11", "description": "The Continue Core contains functionality that can be shared across web, VS Code, or Node.js server. It is written in TypeScript and contains much of the functionality that was previously inside of the legacy Continue Python Server.", "scripts": { "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest ./test/diff.test.ts", - "build:npm": "tsc -p ./tsconfig.npm.json" + "build:npm": "tsc -p ./tsconfig.npm.json", + "lint": "eslint . --ext ts", + "lint:fix": "eslint . --ext ts --fix" }, "type": "module", "author": "Nate Sesti and Ty Dunn", @@ -18,6 +20,7 @@ "esbuild": "^0.19.11", "eslint": "^8", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-require-extensions": "^0.1.3", "jest": "^29.7.0", "ts-jest": "^29.1.1" }, diff --git a/core/pnpm-lock.yaml b/core/pnpm-lock.yaml index b6c177dac..38458503c 100644 --- a/core/pnpm-lock.yaml +++ b/core/pnpm-lock.yaml @@ -150,6 +150,9 @@ importers: eslint-plugin-import: specifier: ^2.29.1 version: 2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0) + eslint-plugin-require-extensions: + specifier: ^0.1.3 + version: 0.1.3(eslint@8.57.0) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@20.12.11) @@ -1598,6 +1601,12 @@ packages: '@typescript-eslint/parser': optional: true + eslint-plugin-require-extensions@0.1.3: + resolution: {integrity: sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug==} + engines: {node: '>=16'} + peerDependencies: + eslint: '*' + eslint-scope@7.2.2: resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -5332,6 +5341,10 @@ snapshots: - eslint-import-resolver-webpack - supports-color + eslint-plugin-require-extensions@0.1.3(eslint@8.57.0): + dependencies: + eslint: 8.57.0 + eslint-scope@7.2.2: dependencies: esrecurse: 4.3.0 diff --git a/core/protocol.ts b/core/protocol.ts index 3e37b00ee..1b6a3ac04 100644 --- a/core/protocol.ts +++ b/core/protocol.ts @@ -10,9 +10,9 @@ import { RangeInFile, SerializedContinueConfig, SessionInfo, -} from "."; -import { AutocompleteInput } from "./autocomplete/completionProvider"; -import { IdeProtocol } from "./web/webviewProtocol"; +} from "./index.js"; +import { AutocompleteInput } from "./autocomplete/completionProvider.js"; +import { IdeProtocol } from "./web/webviewProtocol.js"; export type ProtocolGeneratorType = AsyncGenerator<{ done?: boolean; diff --git a/core/test/diff.test.ts b/core/test/diff.test.ts index ccbbfa4b6..8ad3d7c50 100644 --- a/core/test/diff.test.ts +++ b/core/test/diff.test.ts @@ -1,4 +1,4 @@ -import { streamDiff } from "../diff/streamDiff"; +import { streamDiff } from "../diff/streamDiff.js"; const oldCode = [ `A diff --git a/core/test/edit.test.ts b/core/test/edit.test.ts index b39966d75..66006146a 100644 --- a/core/test/edit.test.ts +++ b/core/test/edit.test.ts @@ -1,12 +1,12 @@ import * as dotenv from "dotenv"; import fetch from "node-fetch"; -import { ContinueSDK } from ".."; -import EditSlashCommand, { getPromptParts } from "../commands/slash/edit"; -import { contextItemToRangeInFileWithContents } from "../commands/util"; -import FreeTrial from "../llm/llms/FreeTrial"; -import Ollama from "../llm/llms/Ollama"; -import { dedentAndGetCommonWhitespace } from "../util"; -import FileSystemIde from "../util/filesystem"; +import { ContinueSDK } from "../index.js"; +import EditSlashCommand, { getPromptParts } from "../commands/slash/edit.js"; +import { contextItemToRangeInFileWithContents } from "../commands/util.js"; +import FreeTrial from "../llm/llms/FreeTrial.js"; +import Ollama from "../llm/llms/Ollama.js"; +import { dedentAndGetCommonWhitespace } from "../util/index.js"; +import FileSystemIde from "../util/filesystem.js"; jest.setTimeout(100_000); @@ -70,7 +70,7 @@ describe("/edit slash command", () => { let total = ""; for await (const update of command.run(sdk)) { - if (update === undefined) continue; + if (update === undefined) {continue;} total += update; } console.log(total); diff --git a/core/test/llm.test.ts b/core/test/llm.test.ts index 3c6296377..6e5303873 100644 --- a/core/test/llm.test.ts +++ b/core/test/llm.test.ts @@ -1,7 +1,7 @@ import * as dotenv from "dotenv"; -import { CompletionOptions } from ".."; -import { BaseLLM } from "../llm"; +import { CompletionOptions } from "../index.js"; +import { BaseLLM } from "../llm/index.js"; jest.setTimeout(100_000); diff --git a/core/util/devdata.ts b/core/util/devdata.ts index bb98b2527..fc223c6e2 100644 --- a/core/util/devdata.ts +++ b/core/util/devdata.ts @@ -1,5 +1,5 @@ import { writeFileSync } from "fs"; -import { getDevDataFilePath } from "./paths"; +import { getDevDataFilePath } from "./paths.js"; export function logDevData(tableName: string, data: any) { const filepath: string = getDevDataFilePath(tableName); diff --git a/core/util/devdataSqlite.ts b/core/util/devdataSqlite.ts index 0ca1aa8d8..2d6ba81da 100644 --- a/core/util/devdataSqlite.ts +++ b/core/util/devdataSqlite.ts @@ -1,6 +1,6 @@ import fs from "fs"; -import { DatabaseConnection } from "../indexing/refreshIndex"; -import { getDevDataSqlitePath } from "./paths"; +import { DatabaseConnection } from "../indexing/refreshIndex.js"; +import { getDevDataSqlitePath } from "./paths.js"; export class DevDataSqliteDb { static db: DatabaseConnection | null = null; @@ -24,7 +24,7 @@ export class DevDataSqliteDb { ) { const db = await DevDataSqliteDb.get(); await db?.run( - `INSERT INTO tokens_generated (model, provider, tokens_generated) VALUES (?, ?, ?)`, + "INSERT INTO tokens_generated (model, provider, tokens_generated) VALUES (?, ?, ?)", [model, provider, tokens], ); } diff --git a/core/util/fetchWithOptions.ts b/core/util/fetchWithOptions.ts index 904a2fda6..661c326d9 100644 --- a/core/util/fetchWithOptions.ts +++ b/core/util/fetchWithOptions.ts @@ -5,7 +5,7 @@ import { globalAgent } from "https"; import { HttpsProxyAgent } from "https-proxy-agent"; import fetch, { RequestInit, Response } from "node-fetch"; import tls from "tls"; -import { RequestOptions } from ".."; +import { RequestOptions } from "../index.js"; export function fetchwithRequestOptions( url_: URL | string, diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index b66ce6a3c..c2956d28a 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -7,9 +7,9 @@ import { Problem, Range, Thread, -} from ".."; +} from "../index.js"; -import { getContinueGlobalPath } from "./paths"; +import { getContinueGlobalPath } from "./paths.js"; class FileSystemIde implements IDE { getRepoName(dir: string): Promise { diff --git a/core/util/history.ts b/core/util/history.ts index 21313d51e..ce9a855c1 100644 --- a/core/util/history.ts +++ b/core/util/history.ts @@ -1,7 +1,7 @@ import * as fs from "fs"; -import { PersistedSessionInfo, SessionInfo } from ".."; -import { ListHistoryOptions } from "../protocol"; -import { getSessionFilePath, getSessionsListPath } from "./paths"; +import { PersistedSessionInfo, SessionInfo } from "../index.js"; +import { ListHistoryOptions } from "../protocol.js"; +import { getSessionFilePath, getSessionsListPath } from "./paths.js"; class HistoryManager { list(options: ListHistoryOptions): SessionInfo[] { diff --git a/core/util/index.ts b/core/util/index.ts index 371a5193c..ead907fbe 100644 --- a/core/util/index.ts +++ b/core/util/index.ts @@ -2,19 +2,19 @@ export function removeQuotesAndEscapes(output: string): string { output = output.trim(); // Replace smart quotes - output = output.replace("“", '"'); - output = output.replace("”", '"'); + output = output.replace("“", "\""); + output = output.replace("”", "\""); output = output.replace("‘", "'"); output = output.replace("’", "'"); // Remove escapes - output = output.replace('\\"', '"'); + output = output.replace("\\\"", "\""); output = output.replace("\\'", "'"); output = output.replace("\\n", "\n"); output = output.replace("\\t", "\t"); output = output.replace("\\\\", "\\"); while ( - (output.startsWith('"') && output.endsWith('"')) || + (output.startsWith("\"") && output.endsWith("\"")) || (output.startsWith("'") && output.endsWith("'")) ) { output = output.slice(1, -1); @@ -158,7 +158,7 @@ export function getMarkdownLanguageTagForFile(filepath: string): string { } export function copyOf(obj: any): any { - if (obj === null || obj === undefined) return obj; + if (obj === null || obj === undefined) {return obj;} return JSON.parse(JSON.stringify(obj)); } diff --git a/core/util/merge.ts b/core/util/merge.ts index 1dab1baab..407dc306a 100644 --- a/core/util/merge.ts +++ b/core/util/merge.ts @@ -1,4 +1,4 @@ -import { ConfigMergeType } from ".."; +import { ConfigMergeType } from "../index.js"; type JsonObject = { [key: string]: any }; diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index 5132f473e..f08751b5c 100644 --- a/core/util/messageIde.ts +++ b/core/util/messageIde.ts @@ -6,7 +6,7 @@ import { Problem, Range, Thread, -} from ".."; +} from "../index.js"; export class MessageIde implements IDE { constructor( diff --git a/core/util/parameters.ts b/core/util/parameters.ts index a9387796b..51242a46e 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -1,4 +1,4 @@ -import { TabAutocompleteOptions } from ".."; +import { TabAutocompleteOptions } from "../index.js"; export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { disable: false, diff --git a/core/util/paths.ts b/core/util/paths.ts index c480116cd..f2c024441 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -2,9 +2,9 @@ import dotenv from "dotenv"; import * as fs from "fs"; import * as os from "os"; import * as path from "path"; -import { IdeType, SerializedContinueConfig } from ".."; -import { defaultConfig, defaultConfigJetBrains } from "../config/default"; -import Types from "../config/types"; +import { IdeType, SerializedContinueConfig } from "../index.js"; +import { defaultConfig, defaultConfigJetBrains } from "../config/default.js"; +import Types from "../config/types.js"; export function getContinueGlobalPath(): string { // This is ~/.continue on mac/linux diff --git a/core/util/ranges.ts b/core/util/ranges.ts index 6188e6a2f..345933f03 100644 --- a/core/util/ranges.ts +++ b/core/util/ranges.ts @@ -1,4 +1,4 @@ -import { Position, Range } from ".."; +import { Position, Range } from "../index.js"; export function getRangeInString(content: string, range: Range): string { const lines = content.split("\n"); diff --git a/core/util/verticalEdit.ts b/core/util/verticalEdit.ts index cd11c104f..e4bb6b7cb 100644 --- a/core/util/verticalEdit.ts +++ b/core/util/verticalEdit.ts @@ -1,4 +1,4 @@ -import { ChatMessage, DiffLine, ILLM } from ".."; +import { ChatMessage, DiffLine, ILLM } from "../index.js"; import { filterCodeBlockLines, filterEnglishLinesAtEnd, @@ -6,11 +6,11 @@ import { filterLeadingAndTrailingNewLineInsertion, skipLines, stopAtLines, -} from "../autocomplete/lineStream"; -import { streamDiff } from "../diff/streamDiff"; -import { streamLines } from "../diff/util"; -import { gptEditPrompt } from "../llm/templates/edit"; -import { Telemetry } from "./posthog"; +} from "../autocomplete/lineStream.js"; +import { streamDiff } from "../diff/streamDiff.js"; +import { streamLines } from "../diff/util.js"; +import { gptEditPrompt } from "../llm/templates/edit.js"; +import { Telemetry } from "./posthog.js"; function constructPrompt( prefix: string, diff --git a/core/web/webviewProtocol.ts b/core/web/webviewProtocol.ts index 55e1dbb2c..6f2d3576e 100644 --- a/core/web/webviewProtocol.ts +++ b/core/web/webviewProtocol.ts @@ -8,10 +8,10 @@ import { Problem, Range, Thread, -} from ".."; -import { RangeInFileWithContents } from "../commands/util"; +} from "../index.js"; +import { RangeInFileWithContents } from "../commands/util.js"; -import { Protocol } from "../protocol"; +import { Protocol } from "../protocol.js"; export type IdeProtocol = { listWorkspaceContents: [undefined, string[]];