🎨 eslint enforce import extensions
This commit is contained in:
parent
81b95eba8c
commit
89a69576bc
141 changed files with 556 additions and 532 deletions
|
|
@ -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"]
|
||||
}
|
||||
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export async function* noFirstCharNewline(stream: AsyncGenerator<string>) {
|
|||
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<string> {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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: [],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { RangeInFile } from "..";
|
||||
import { RangeInFile } from "../index.js";
|
||||
|
||||
export type RecentlyEditedRange = RangeInFile & {
|
||||
timestamp: number;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 </modified_code_to_edit> tag should be written to indicate the end of the modified code section. Do not ever use nested tags.
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 = (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContextItemWithId } from "..";
|
||||
import { ContextItemWithId } from "../index.js";
|
||||
|
||||
export interface RangeInFileWithContents {
|
||||
filepath: string;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContextProviderWithParams, SerializedContinueConfig } from "..";
|
||||
import { ContextProviderWithParams, SerializedContinueConfig } from "../index.js";
|
||||
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
models: [
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SerializedContinueConfig } from "..";
|
||||
import { SerializedContinueConfig } from "../index.js";
|
||||
|
||||
export function setupOptimizedMode(
|
||||
config: SerializedContinueConfig,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
ContextSubmenuItem,
|
||||
IContextProvider,
|
||||
LoadSubmenuItemsArgs,
|
||||
} from "..";
|
||||
} from "../index.js";
|
||||
export abstract class BaseContextProvider implements IContextProvider {
|
||||
options: { [key: string]: any };
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
CustomContextProvider,
|
||||
IContextProvider,
|
||||
LoadSubmenuItemsArgs,
|
||||
} from "../..";
|
||||
} from "../../index.js";
|
||||
|
||||
class CustomContextProviderClass implements IContextProvider {
|
||||
custom: CustomContextProvider;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseContextProvider } from "..";
|
||||
import { BaseContextProvider } from "../index.js";
|
||||
import {
|
||||
ContextItem,
|
||||
ContextProviderDescription,
|
||||
ContextProviderExtras,
|
||||
} from "../..";
|
||||
} from "../../index.js";
|
||||
|
||||
interface Directory {
|
||||
name: string;
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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<AxiosInstance> {
|
||||
|
|
@ -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(`:(?<project>.*).git`).exec(remoteUrl);
|
||||
const urlMatches = RegExp(":(?<project>.*).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<Array<GitLabComment>>(
|
||||
|
|
@ -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.",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}`,
|
||||
),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<number[]> {
|
||||
let apiBase = this.params.apiBase ?? CohereReranker.defaultOptions.apiBase
|
||||
let apiBase = this.params.apiBase ?? CohereReranker.defaultOptions.apiBase;
|
||||
if (!apiBase.endsWith("/")) {
|
||||
apiBase += "/";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Chunk } from "..";
|
||||
import { Chunk } from "../index.js";
|
||||
|
||||
export interface EmbeddingsCacheChunk {
|
||||
vector: number[];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {
|
|||
ArtifactType,
|
||||
EmbeddingsCacheResponse,
|
||||
IContinueServerClient,
|
||||
} from "../interface";
|
||||
} from "../interface.js";
|
||||
|
||||
export class ContinueServerClient implements IContinueServerClient {
|
||||
constructor(
|
||||
|
|
|
|||
|
|
@ -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/
|
||||
|
|
|
|||
|
|
@ -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<string>;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<ContextItem> {
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { EmbedOptions, EmbeddingsProvider, FetchFunction } from "../..";
|
||||
import { EmbedOptions, EmbeddingsProvider, FetchFunction } from "../../index.js";
|
||||
|
||||
class BaseEmbeddingsProvider implements EmbeddingsProvider {
|
||||
options: EmbedOptions;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<EmbedOptions> | undefined = {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {}
|
||||
|
|
|
|||
|
|
@ -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<sqlite3.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<IndexTag[]> {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { IndexTag, IndexingProgressUpdate } from "..";
|
||||
import { IndexTag, IndexingProgressUpdate } from "../index.js";
|
||||
|
||||
export enum IndexResultType {
|
||||
Compute = "compute",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ChatHistory, ChatMessage, MessagePart } from "..";
|
||||
import { ChatHistory, ChatMessage, MessagePart } from "../index.js";
|
||||
|
||||
export function constructMessages(history: ChatHistory): ChatMessage[] {
|
||||
const msgs = [];
|
||||
|
|
|
|||
|
|
@ -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"];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue