Merge branch 'preview' into add-fixed-version-of-nodejs

This commit is contained in:
Ihor Pavlenko 2024-02-01 10:36:28 +01:00 • committed by GitHub
commit 20670673f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
91 changed files with 4121 additions and 2165 deletions

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: Full-text search index for retrieval
time: 2024-01-29T21:05:50.216548-08:00

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: Docs context provider
time: 2024-01-30T12:31:43.521306-08:00

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: CodeLlama-70b support
time: 2024-01-30T13:03:32.287428-08:00

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Fixed
body: Fixed proxy setting in config.json
time: 2024-01-30T13:03:15.8294-08:00

View file

@ -1,2 +1,3 @@
**/*.run.xml
archive/**/*
archive/**/*
extensions/vscode/models/**/*

3
.gitignore vendored
View file

@ -151,4 +151,5 @@ codeql
continue_server.build
continue_server.dist
Icon
Icon
Icon?

View file

@ -0,0 +1,82 @@
import { open } from "sqlite";
import sqlite3 from "sqlite3";
import { DatabaseConnection } from "../indexing/refreshIndex";
import { getTabAutocompleteCacheSqlitePath } from "../util/paths";
export class AutocompleteLruCache {
private static capacity: number = 1000;
db: DatabaseConnection;
constructor(db: DatabaseConnection) {
this.db = db;
}
static async get(): Promise<AutocompleteLruCache> {
const db = await open({
filename: getTabAutocompleteCacheSqlitePath(),
driver: sqlite3.Database,
});
await db.run(`
CREATE TABLE IF NOT EXISTS cache (
key TEXT PRIMARY KEY,
value TEXT NOT NULL,
timestamp INTEGER NOT NULL
)
`);
return new AutocompleteLruCache(db);
}
async get(key: string): Promise<string | undefined> {
const result = await this.db.get(
"SELECT value FROM cache WHERE key = ?",
key
);
if (result) {
await this.db.run(
"UPDATE cache SET timestamp = ? WHERE key = ?",
Date.now(),
key
);
return result.value;
}
return undefined;
}
async put(key: string, value: string) {
const result = await this.db.get(
"SELECT key FROM cache WHERE key = ?",
key
);
if (result) {
await this.db.run(
"UPDATE cache SET value = ?, timestamp = ? WHERE key = ?",
value,
Date.now(),
key
);
} else {
const count = await this.db.get("SELECT COUNT(*) as count FROM cache");
if (count.count >= AutocompleteLruCache.capacity) {
await this.db.run(
"DELETE FROM cache WHERE key = (SELECT key FROM cache ORDER BY timestamp ASC LIMIT 1)"
);
}
await this.db.run(
"INSERT INTO cache (key, value, timestamp) VALUES (?, ?, ?)",
key,
value,
Date.now()
);
}
}
}
export default AutocompleteLruCache;

View file

@ -0,0 +1,128 @@
import Parser from "web-tree-sitter";
import {
countTokens,
pruneLinesFromBottom,
pruneLinesFromTop,
} from "../llm/countTokens";
import { getBasename } from "../util";
import { getParserForFile } from "../util/treeSitter";
import { AutocompleteLanguageInfo, Typescript } from "./languages";
import {
MAX_PROMPT_TOKENS,
MAX_SUFFIX_PERCENTAGE,
PREFIX_PERCENTAGE,
} from "./parameters";
export function languageForFilepath(
filepath: string
): AutocompleteLanguageInfo {
return Typescript;
}
function formatExternalSnippet(
filepath: string,
snippet: string,
language: AutocompleteLanguageInfo
) {
const comment = language.comment;
const lines = [
comment + " Path: " + getBasename(filepath),
...snippet.split("\n").map((line) => comment + " " + line),
comment,
];
return lines.join("\n");
}
async function getTreePathAtCursor(
filepath: string,
fileContents: string,
cursorIndex: number
): Promise<Parser.SyntaxNode[]> {
const parser = await getParserForFile(filepath);
const ast = parser.parse(fileContents);
const path = [ast.rootNode];
while (path[path.length - 1].childCount > 0) {
let foundChild = false;
for (let child of path[path.length - 1].children) {
if (child.startIndex <= cursorIndex && child.endIndex >= cursorIndex) {
path.push(child);
foundChild = true;
break;
}
}
if (!foundChild) {
break;
}
}
return path;
}
export interface AutocompleteSnippet {
filepath: string;
content: string;
}
export async function constructAutocompletePrompt(
filepath: string,
fullPrefix: string,
fullSuffix: string,
clipboardText: string,
language: AutocompleteLanguageInfo,
getDefinition: (
filepath: string,
line: number,
character: number
) => Promise<AutocompleteSnippet | undefined>
): Promise<{ prefix: string; suffix: string; useFim: boolean }> {
// Find external snippets
const snippets: AutocompleteSnippet[] = [];
const treePath = await getTreePathAtCursor(
filepath,
fullPrefix + fullSuffix,
fullPrefix.length
);
// Get function def when inside call expression
let callExpression = undefined;
for (let node of treePath.reverse()) {
if (node.type === "call_expression") {
callExpression = node;
break;
}
}
if (callExpression) {
const definition = await getDefinition(
filepath,
callExpression.startPosition.row,
callExpression.startPosition.column
);
if (definition) {
snippets.push(definition);
}
}
// Construct basic prefix / suffix
const formattedSnippets = snippets
.map((snippet) =>
formatExternalSnippet(snippet.filepath, snippet.content, language)
)
.join("\n");
const maxPrefixTokens =
MAX_PROMPT_TOKENS * PREFIX_PERCENTAGE -
countTokens(formattedSnippets, "gpt-4");
let prefix = pruneLinesFromTop(fullPrefix, maxPrefixTokens);
if (formattedSnippets.length > 0) {
prefix = formattedSnippets + "\n" + prefix;
}
const maxSuffixTokens = Math.min(
MAX_PROMPT_TOKENS - countTokens(prefix, "gpt-4"),
MAX_SUFFIX_PERCENTAGE * MAX_PROMPT_TOKENS
);
let suffix = pruneLinesFromBottom(fullSuffix, maxSuffixTokens);
return { prefix, suffix, useFim: true };
}

View file

View file

@ -0,0 +1,11 @@
export interface AutocompleteLanguageInfo {
stopWords: string[];
comment: string;
endOfLine: string[];
}
export const Typescript = {
stopWords: ["function", "class", "module", "export "],
comment: "//",
endOfLine: [";"],
};

View file

@ -0,0 +1,4 @@
export const MAX_PROMPT_TOKENS = 1_000;
export const PREFIX_PERCENTAGE = 0.85;
export const MAX_SUFFIX_PERCENTAGE = 0.25;
export const DEBOUNCE_DELAY = 350;

View file

@ -0,0 +1,55 @@
// Fill in the middle prompts
import { CompletionOptions } from "..";
interface AutocompleteTemplate {
template: string | ((prefix: string, suffix: string) => string);
completionOptions?: Partial<CompletionOptions>;
}
// https://huggingface.co/stabilityai/stable-code-3b
const stableCodeFimTemplate: AutocompleteTemplate = {
template: "<fim_prefix>{{{prefix}}}<fim_suffix>{{{suffix}}}<fim_middle>",
completionOptions: {
stop: ["<fim_prefix>", "<fim_suffix>", "<fim_middle>", "<|endoftext|>"],
},
};
const codeLlamaFimTemplate: AutocompleteTemplate = {
template: "<PRE> {{{prefix}}} <SUF>{{{suffix}}} <MID>",
completionOptions: { stop: ["<PRE>", "<SUF>", "<MID>"] },
};
// https://huggingface.co/deepseek-ai/deepseek-coder-1.3b-base
const deepseekFimTemplate: AutocompleteTemplate = {
template:
"<|fim▁begin|>{{{prefix}}}<|fim▁hole|>{{{suffix}}}<|fim▁end|>",
completionOptions: {
stop: ["<|fim▁begin|>", "<|fim▁hole|>", "<|fim▁end|>", "//"],
},
};
const deepseekFimTemplateWrongPipeChar: AutocompleteTemplate = {
template: "<|fim▁begin|>{{{prefix}}}<|fim▁hole|>{{{suffix}}}<|fim▁end|>",
completionOptions: { stop: ["<|fim▁begin|>", "<|fim▁hole|>", "<|fim▁end|>"] },
};
export function getTemplateForModel(model: string): AutocompleteTemplate {
if (
model.includes("starcoder") ||
model.includes("star-coder") ||
model.includes("stable")
) {
return stableCodeFimTemplate;
}
if (model.includes("codellama")) {
return codeLlamaFimTemplate;
}
if (model.includes("deepseek")) {
return deepseekFimTemplate;
}
return stableCodeFimTemplate;
}

View file

@ -15,10 +15,10 @@ export function contextItemToRangeInFileWithContents(
const lines = item.name.split("(")[1].split(")")[0].split("-");
const rif: RangeInFileWithContents = {
filepath: item.description,
filepath: item.description.split(" (")[0],
range: {
start: {
line: parseInt(lines[0]) - 1,
line: parseInt(lines[0]),
character: 0,
},
end: {

View file

@ -12,11 +12,6 @@ const defaultConfig: SerializedContinueConfig = {
provider: "free-trial",
model: "gpt-4-vision-preview",
},
{
title: "Phind CodeLlama (Free Trial)",
provider: "free-trial",
model: "phind-codellama-34b",
},
{
title: "Gemini Pro (Free Trial)",
provider: "free-trial",
@ -62,6 +57,7 @@ const defaultConfig: SerializedContinueConfig = {
},
{ name: "terminal", params: {} },
{ name: "problems", params: {} },
{ name: "codebase", params: {} },
],
};

View file

@ -80,6 +80,20 @@ async function intermediateToFinalConfig(
models.push(llm);
}
let autocompleteLlm: BaseLLM | undefined = undefined;
if (config.tabAutocompleteModel) {
if (isModelDescription(config.tabAutocompleteModel)) {
autocompleteLlm = await llmFromDescription(
config.tabAutocompleteModel,
readFile,
config.completionOptions,
config.systemMessage
);
} else {
autocompleteLlm = new CustomLLMClass(config.tabAutocompleteModel);
}
}
const contextProviders: IContextProvider[] = [new FileContextProvider({})];
for (const provider of config.contextProviders || []) {
if (isContextProviderWithParams(provider)) {
@ -112,6 +126,7 @@ async function intermediateToFinalConfig(
contextProviders,
models,
embeddingsProvider: config.embeddingsProvider as any,
tabAutocompleteModel: autocompleteLlm,
};
}

View file

@ -4,7 +4,6 @@ import {
ContextProviderDescription,
ContextProviderExtras,
} from "../..";
import { retrieveContextItemsFromEmbeddings } from "../retrieval";
class CodebaseContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
@ -18,6 +17,7 @@ class CodebaseContextProvider extends BaseContextProvider {
query: string,
extras: ContextProviderExtras
): Promise<ContextItem[]> {
const { retrieveContextItemsFromEmbeddings } = await import("../retrieval");
return retrieveContextItemsFromEmbeddings(extras, this.options, undefined);
}
async load(): Promise<void> {}

View file

@ -36,13 +36,15 @@ class DocsContextProvider extends BaseContextProvider {
return [
...chunks
.map((chunk) => ({
name: chunk.filepath
.split("/")
.slice(1)
.join("/")
.split("/tree/main/")
.slice(1)
.join("/"), // chunk.otherMetadata?.title || chunk.filepath,
name: chunk.filepath.includes("/tree/main") // For display of GitHub files
? chunk.filepath
.split("/")
.slice(1)
.join("/")
.split("/tree/main/")
.slice(1)
.join("/")
: chunk.otherMetadata?.title || chunk.filepath,
description: new URL(chunk.filepath, query).toString(),
content: chunk.content,
}))

View file

@ -7,7 +7,6 @@ import {
LoadSubmenuItemsArgs,
} from "../..";
import { getBasename, getLastNPathParts } from "../../util";
import { retrieveContextItemsFromEmbeddings } from "../retrieval";
class FolderContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
@ -21,6 +20,7 @@ class FolderContextProvider extends BaseContextProvider {
query: string,
extras: ContextProviderExtras
): Promise<ContextItem[]> {
const { retrieveContextItemsFromEmbeddings } = await import("../retrieval");
return retrieveContextItemsFromEmbeddings(extras, this.options, query);
}
async loadSubmenuItems(

View file

@ -1,10 +1,8 @@
import {
Chunk,
ContextItem,
ContextProviderExtras,
ILLM,
ModelProvider,
} from "..";
import { Chunk, ContextItem, ContextProviderExtras, ILLM } from "..";
import { FullTextSearchCodebaseIndex } from "../indexing/FullTextSearch";
import { ChunkCodebaseIndex } from "../indexing/chunk/ChunkCodebaseIndex";
import { IndexTag } from "../indexing/types";
import { llmCanGenerateInParallel } from "../llm";
import { getBasename } from "../util";
const RERANK_PROMPT = (
@ -47,28 +45,6 @@ ${document}
Relevant:
`;
const PARALLEL_PROVIDERS: ModelProvider[] = [
"anthropic",
"bedrock",
"deepinfra",
"gemini",
"google-palm",
"huggingface-inference-api",
"huggingface-tgi",
"mistral",
"free-trial",
"replicate",
"together",
];
function llmCanGenerateInParallel(llm: ILLM): boolean {
if (llm.providerName === "openai") {
return llm.model.includes("gpt");
}
return PARALLEL_PROVIDERS.includes(llm.providerName);
}
async function scoreChunk(
chunk: Chunk,
llm: ILLM,
@ -133,19 +109,55 @@ export async function retrieveContextItemsFromEmbeddings(
return [];
}
const nRetrieve = options?.nRetrieve || 20;
const nFinal = options?.nFinal || 8;
const nFinal = options?.nFinal || 10;
const useReranking =
llmCanGenerateInParallel(extras.llm) &&
(options?.useReranking === undefined ? false : options?.useReranking);
const nRetrieve = useReranking === false ? nFinal : options?.nRetrieve || 20;
// Similarity search
let results = await extras.ide.retrieveChunks(
const ftsIndex = new FullTextSearchCodebaseIndex();
const workspaceDirs = await extras.ide.getWorkspaceDirs();
const branches = await Promise.all(
workspaceDirs.map((dir) => extras.ide.getBranch(dir))
);
const tags: IndexTag[] = workspaceDirs.map((directory, i) => ({
directory,
branch: branches[i],
artifactId: ChunkCodebaseIndex.artifactId,
}));
let ftsResults = await ftsIndex.retrieve(
tags,
extras.fullInput.trim().split(" ").join(" OR "),
nRetrieve / 2,
filterDirectory,
undefined
);
let vecResults = await extras.ide.retrieveChunks(
extras.fullInput,
useReranking === false ? nFinal : nRetrieve,
nRetrieve,
filterDirectory
);
// Now combine these (de-duplicate) and re-rank
let results = [...ftsResults];
for (const vecResult of vecResults) {
if (results.length >= nRetrieve) {
break;
}
if (
!ftsResults.find(
(r) =>
r.filepath === vecResult.filepath &&
r.startLine === vecResult.startLine &&
r.endLine === vecResult.endLine
)
) {
results.push(vecResult);
}
}
// Re-ranking
if (useReranking) {
results = await rerank(results, extras.llm, extras.fullInput, nFinal);

View file

@ -28,6 +28,13 @@ class FileSystemIde implements IDE {
getTerminalContents(): Promise<string> {
return Promise.resolve("");
}
showLines(
filepath: string,
startLine: number,
endLine: number
): Promise<void> {
return Promise.resolve();
}
listWorkspaceContents(): Promise<string[]> {
return new Promise((resolve, reject) => {
fs.readdir("/tmp/continue", (err, files) => {
@ -94,6 +101,10 @@ class FileSystemIde implements IDE {
return Promise.resolve();
}
getBranch(dir: string): Promise<string> {
return Promise.resolve("");
}
async verticalDiffUpdate(
filepath: string,
startLine: number,

View file

@ -30,6 +30,14 @@ export class ExtensionIde implements IDE {
return await r("getWorkspaceDirs");
}
async showLines(
filepath: string,
startLine: number,
endLine: number
): Promise<void> {
return await r("showLines", { filepath, startLine, endLine });
}
async listFolders(): Promise<string[]> {
return await r("listFolders");
}
@ -112,6 +120,10 @@ export class ExtensionIde implements IDE {
return r("sendChunkForFile", { chunk, embedding, tags });
}
async getBranch(dir: string): Promise<string> {
return r("getBranch", { dir });
}
retrieveChunks(
text: string,
n: number,

25
core/index.d.ts vendored
View file

@ -300,6 +300,11 @@ export interface IDE {
runCommand(command: string): Promise<void>;
saveFile(filepath: string): Promise<void>;
readFile(filepath: string): Promise<string>;
showLines(
filepath: string,
startLine: number,
endLine: number
): Promise<void>;
showDiff(
filepath: string,
newContents: string,
@ -316,6 +321,7 @@ export interface IDE {
getSearchResults(query: string): Promise<string>;
subprocess(command: string): Promise<[string, string]>;
getProblems(filepath?: string | undefined): Promise<Problem[]>;
getBranch(dir: string): Promise<string>;
// Embeddings
/**
@ -398,6 +404,7 @@ type TemplateType =
| "deepseek"
| "xwin-coder"
| "neural-chat"
| "codellama-70b"
| "llava";
type ModelProvider =
@ -445,7 +452,6 @@ export type ModelName =
| "wizardcoder-34b"
| "zephyr-7b"
| "codeup-13b"
| "deepseek-1b"
| "deepseek-7b"
| "deepseek-33b"
| "neural-chat-7b"
@ -458,7 +464,12 @@ export type ModelName =
// Mistral
| "mistral-tiny"
| "mistral-small"
| "mistral-medium";
| "mistral-medium"
// Tab autocomplete
| "deepseek-1b"
| "starcoder-1b"
| "starcoder-3b"
| "stable-code-3b";
export interface RequestOptions {
timeout?: number;
@ -533,6 +544,11 @@ export interface EmbeddingsProvider {
embed(chunks: string[]): Promise<number[][]>;
}
export interface TabAutocompleteOptions {
useCopyBuffer?: boolean;
useSuffix?: boolean;
}
export interface SerializedContinueConfig {
disallowedSteps?: string[];
allowAnonymousTelemetry?: boolean;
@ -546,6 +562,8 @@ export interface SerializedContinueConfig {
disableSessionTitles?: boolean;
userToken?: string;
embeddingsProvider?: EmbeddingsProviderDescription;
tabAutocompleteModel?: ModelDescription;
tabAutocompleteOptions?: TabAutocompleteOptions;
}
export interface Config {
@ -574,6 +592,8 @@ export interface Config {
userToken?: string;
/** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */
embeddingsProvider?: EmbeddingsProviderDescription | EmbeddingsProvider;
/** The model that Continue will use for tab autocompletions. */
tabAutocompleteModel?: CustomLLM | ModelDescription;
}
export interface ContinueConfig {
@ -587,4 +607,5 @@ export interface ContinueConfig {
disableIndexing?: boolean;
userToken?: string;
embeddingsProvider: EmbeddingsProvider;
tabAutocompleteModel?: ILLM;
}

View file

@ -0,0 +1,135 @@
import { Chunk, IndexingProgressUpdate } from "..";
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex";
import {
CodebaseIndex,
IndexResultType,
IndexTag,
MarkCompleteCallback,
RefreshIndexResults,
} from "./types";
export class FullTextSearchCodebaseIndex implements CodebaseIndex {
artifactId: string = "sqliteFts";
private async _createTables(db: DatabaseConnection) {
await db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS fts USING fts5(
path,
content,
tokenize = 'trigram'
)`);
await db.exec(`CREATE TABLE IF NOT EXISTS fts_metadata (
id INTEGER PRIMARY KEY,
path TEXT NOT NULL,
cacheKey TEXT NOT NULL,
chunkId INTEGER NOT NULL,
FOREIGN KEY (chunkId) REFERENCES chunks (id),
FOREIGN KEY (id) REFERENCES fts (rowid)
)`);
}
async *update(
tag: IndexTag,
results: RefreshIndexResults,
markComplete: MarkCompleteCallback
): AsyncGenerator<IndexingProgressUpdate, any, unknown> {
const db = await SqliteDb.get();
await this._createTables(db);
for (let i = 0; i < results.compute.length; i++) {
const item = results.compute[i];
// Insert chunks
const chunks = await db.all(
`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 (?, ?)`,
[item.path, chunk.content]
);
await db.run(
`INSERT INTO fts_metadata (id, path, cacheKey, chunkId) VALUES (?, ?, ?, ?)`,
[lastID, item.path, item.cacheKey, chunk.id]
);
}
yield {
progress: i / results.compute.length,
desc: `Indexing ${item.path}`,
};
markComplete([item], IndexResultType.Compute);
}
// Add tag
for (const item of results.addTag) {
markComplete([item], IndexResultType.AddTag);
}
// Remove tag
for (const item of results.removeTag) {
markComplete([item], IndexResultType.RemoveTag);
}
// Delete
for (const item of results.del) {
const { lastID } = await db.run(
`DELETE FROM fts_metadata WHERE path = ? AND cacheKey = ?`,
[item.path, item.cacheKey]
);
await db.run(`DELETE FROM fts WHERE rowid = ?`, [lastID]);
markComplete([item], IndexResultType.Delete);
}
}
async retrieve(
tags: IndexTag[],
text: string,
n: number,
directory: string | undefined,
filterPaths: string[] | undefined
): Promise<Chunk[]> {
const db = await SqliteDb.get();
const tagStrings = tags.map(tagToString);
const results = await db.all(
`SELECT fts_metadata.chunkId, fts_metadata.path, fts.content, rank
FROM fts
JOIN fts_metadata ON fts.rowid = fts_metadata.id
JOIN chunk_tags ON fts_metadata.chunkId = chunk_tags.chunkId
WHERE fts MATCH '${text.replace(
/\?/g,
""
)}' AND chunk_tags.tag IN (${tagStrings.map(() => "?").join(",")})
${
filterPaths
? `AND fts_metadata.path IN (${filterPaths
.map(() => "?")
.join(",")})`
: ""
}
ORDER BY rank
LIMIT ?`,
[...tagStrings, ...(filterPaths || []), n]
);
const chunks = await db.all(
`SELECT * FROM chunks WHERE id IN (${results.map(() => "?").join(",")})`,
results.map((result) => result.chunkId)
);
return chunks.map((chunk) => {
return {
filepath: chunk.path,
index: chunk.index,
startLine: chunk.startLine,
endLine: chunk.endLine,
content: chunk.content,
digest: chunk.cacheKey,
};
});
}
}

View file

@ -6,7 +6,7 @@ import { MAX_CHUNK_SIZE } from "../llm/constants";
import { getBasename } from "../util";
import { getLanceDbPath } from "../util/paths";
import { chunkDocument } from "./chunk/chunk";
import { DatabaseConnection, SqliteDb } from "./refreshIndex";
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex";
import {
CodebaseIndex,
IndexResultType,
@ -15,10 +15,6 @@ import {
RefreshIndexResults,
} from "./types";
export function tagToString(tag: IndexTag): string {
return `${tag.directory}::${tag.branch}::${tag.artifactId}`;
}
// LanceDB converts to lowercase, so names must all be lowercase
interface LanceDbRow {
uuid: string;

View file

@ -0,0 +1,127 @@
import { IndexingProgressUpdate } from "../..";
import { MAX_CHUNK_SIZE } from "../../llm/constants";
import { getBasename } from "../../util";
import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex";
import {
CodebaseIndex,
IndexResultType,
IndexTag,
MarkCompleteCallback,
RefreshIndexResults,
} from "../types";
import { chunkDocument } from "./chunk";
export class ChunkCodebaseIndex implements CodebaseIndex {
static artifactId: string = "chunks";
artifactId: string = ChunkCodebaseIndex.artifactId;
readFile: (filepath: string) => Promise<string>;
constructor(readFile: (filepath: string) => Promise<string>) {
this.readFile = readFile;
}
private async _createTables(db: DatabaseConnection) {
await db.exec(`CREATE TABLE IF NOT EXISTS chunks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
cacheKey TEXT NOT NULL,
path TEXT NOT NULL,
idx INTEGER NOT NULL,
startLine INTEGER NOT NULL,
endLine INTEGER NOT NULL,
content TEXT NOT NULL
)`);
await db.exec(`CREATE TABLE IF NOT EXISTS chunk_tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
tag TEXT NOT NULL,
chunkId INTEGER NOT NULL,
FOREIGN KEY (chunkId) REFERENCES chunks (id)
)`);
}
async *update(
tag: IndexTag,
results: RefreshIndexResults,
markComplete: MarkCompleteCallback
): AsyncGenerator<IndexingProgressUpdate, any, unknown> {
const db = await SqliteDb.get();
await this._createTables(db);
const tagString = tagToString(tag);
// Compute chunks for new files
const contents = await Promise.all(
results.compute.map(({ path }) => this.readFile(path))
);
for (let i = 0; i < results.compute.length; i++) {
const item = results.compute[i];
// Insert chunks
for await (let chunk of chunkDocument(
item.path,
contents[i],
MAX_CHUNK_SIZE,
item.cacheKey
)) {
const { lastID } = await db.run(
`INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)`,
[
chunk.digest,
chunk.filepath,
chunk.index,
chunk.startLine,
chunk.endLine,
chunk.content,
]
);
await db.run(`INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)`, [
lastID,
tagString,
]);
}
yield {
progress: i / results.compute.length,
desc: `Chunking ${getBasename(item.path)}`,
};
markComplete([item], IndexResultType.Compute);
}
// Add tag
for (const item of results.addTag) {
const chunksWithPath = await db.all(
`SELECT * FROM chunks WHERE cacheKey = ?`,
[item.cacheKey]
);
for (const chunk of chunksWithPath) {
await db.run(`INSERT INTO chunk_tags (chunkId, tag) VALUES (?, ?)`, [
chunk.id,
tagString,
]);
}
markComplete([item], IndexResultType.AddTag);
}
// Remove tag
for (const item of results.removeTag) {
await db.run(`DELETE FROM chunk_tags WHERE tag = ?`, [tagString]);
markComplete([item], IndexResultType.RemoveTag);
}
// Delete
for (const item of results.del) {
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 = ?`, [
deleted.lastID,
]);
markComplete([item], IndexResultType.Delete);
}
}
}

View file

@ -1,8 +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, supportedLanguages } from "./code";
import { codeChunker } from "./code";
async function* chunkDocumentWithoutId(
filepath: string,

View file

@ -1,97 +1,7 @@
// import treeSitterBash from "tree-sitter-wasms/out/tree-sitter-bash.wasm";
// import treeSitterC from "tree-sitter-wasms/out/tree-sitter-c.wasm";
// import treeSitterCSharp from "tree-sitter-wasms/out/tree-sitter-c_sharp.wasm";
// import treeSitterCpp from "tree-sitter-wasms/out/tree-sitter-cpp.wasm";
// import treeSitterCss from "tree-sitter-wasms/out/tree-sitter-css.wasm";
// // import treeSitterElisp from "tree-sitter-wasms/out/tree-sitter-elisp.wasm"
// // import treeSitterElixir from "tree-sitter-wasms/out/tree-sitter-elixir.wasm"
// import treeSitterElm from "tree-sitter-wasms/out/tree-sitter-elm.wasm";
// // import treeSitterEmbeddedTemplate from "tree-sitter-wasms/out/tree-sitter-embedded_template.wasm"
// import treeSitterGo from "tree-sitter-wasms/out/tree-sitter-go.wasm";
// import treeSitterHtml from "tree-sitter-wasms/out/tree-sitter-html.wasm";
// import treeSitterJava from "tree-sitter-wasms/out/tree-sitter-java.wasm";
// import treeSitterJavascript from "tree-sitter-wasms/out/tree-sitter-javascript.wasm";
// import treeSitterJson from "tree-sitter-wasms/out/tree-sitter-json.wasm";
// // import treeSitterLua from "tree-sitter-wasms/out/tree-sitter-lua.wasm"
// import treeSitterOcaml from "tree-sitter-wasms/out/tree-sitter-ocaml.wasm";
// import treeSitterPhp from "tree-sitter-wasms/out/tree-sitter-php.wasm";
// import treeSitterPython from "tree-sitter-wasms/out/tree-sitter-python.wasm";
// // import treeSitterQl from "tree-sitter-wasms/out/tree-sitter-ql.wasm"
// // import treeSitterRescript from "tree-sitter-wasms/out/tree-sitter-rescript.wasm"
// import treeSitterRuby from "tree-sitter-wasms/out/tree-sitter-ruby.wasm";
// import treeSitterRust from "tree-sitter-wasms/out/tree-sitter-rust.wasm";
// // import treeSitterSystemRdl from "tree-sitter-wasms/out/tree-sitter-systemrdl.wasm"
// import treeSitterToml from "tree-sitter-wasms/out/tree-sitter-toml.wasm";
// import treeSitterTsx from "tree-sitter-wasms/out/tree-sitter-tsx.wasm";
// import treeSitterTypescript from "tree-sitter-wasms/out/tree-sitter-typescript.wasm";
// import treeSitterVue from "tree-sitter-wasms/out/tree-sitter-vue.wasm";
// import treeSitterYaml from "tree-sitter-wasms/out/tree-sitter-yaml.wasm";
import Parser, { SyntaxNode } from "web-tree-sitter";
import { ChunkWithoutID } from "../..";
import { countTokens } from "../../llm/countTokens";
// export const fileExtensionToWasm: { [key: string]: string } = {
// py: treeSitterPython,
// js: treeSitterJavascript,
// html: treeSitterHtml,
// java: treeSitterJava,
// go: treeSitterGo,
// rb: treeSitterRuby,
// rs: treeSitterRust,
// c: treeSitterC,
// cpp: treeSitterCpp,
// cs: treeSitterCSharp,
// php: treeSitterPhp,
// css: treeSitterCss,
// bash: treeSitterBash,
// json: treeSitterJson,
// ts: treeSitterTypescript,
// tsx: treeSitterTsx,
// vue: treeSitterVue,
// yaml: treeSitterYaml,
// toml: treeSitterToml,
// ocaml: treeSitterOcaml,
// elm: treeSitterElm,
// // jl: treeSitterJulia,
// // swift: "swift",
// // kt: "kotlin",
// // scala: treeSitterScala,
// };
export const supportedLanguages: { [key: string]: string } = {
cpp: "cpp",
cs: "csharp",
php: "php",
css: "css",
bash: "bash",
json: "json",
ts: "typescript",
tsx: "tsx",
vue: "vue",
yaml: "yaml",
toml: "toml",
ocaml: "ocaml",
elm: "elm",
rb: "ruby",
js: "javascript",
// jl: "julia",
// swift: "swift",
// kt: "kotlin",
// scala: "scala",
};
async function getParserForFile(filepath: string) {
await Parser.init();
const parser = new Parser();
const segs = filepath.split(".");
const wasmPath = `${__dirname}/tree-sitter-wasms/tree-sitter-${
supportedLanguages[segs[segs.length - 1]]
}.wasm`;
const Language = await Parser.Language.load(wasmPath);
parser.setLanguage(Language);
return parser;
}
import { getParserForFile } from "../../util/treeSitter";
function collapsedReplacement(node: SyntaxNode): string {
if (node.type === "statement_block") {

View file

@ -58,14 +58,29 @@ export async function* markdownChunker(
hLevel: number
): AsyncGenerator<ChunkWithoutID> {
if (countTokens(content, "gpt-4") <= maxChunkSize) {
const header = findHeader(content.split("\n"));
yield {
content,
startLine: 0,
endLine: content.split("\n").length,
otherMetadata: {
fragment: cleanFragment(header),
title: cleanHeader(header),
},
};
return;
} else if (hLevel > 4) {
yield* basicChunker(content, maxChunkSize);
const header = findHeader(content.split("\n"));
for (const chunk of basicChunker(content, maxChunkSize)) {
yield {
...chunk,
otherMetadata: {
fragment: cleanFragment(header),
title: cleanHeader(header),
},
};
}
return;
}

View file

@ -43,11 +43,16 @@ function shouldFilterPath(pathname: string, baseUrl: URL): boolean {
return false;
}
async function crawlLinks(path: string, baseUrl: URL, visited: Set<string>) {
async function* crawlLinks(
path: string,
baseUrl: URL,
visited: Set<string>
): AsyncGenerator<number> {
if (visited.has(path) || shouldFilterPath(path, baseUrl)) {
return;
}
visited.add(path);
yield visited.size;
const response = await fetch(new URL(path, baseUrl));
const text = await response.text();
@ -71,8 +76,12 @@ async function crawlLinks(path: string, baseUrl: URL, visited: Set<string>) {
});
await Promise.all(
children.map((child) => crawlLinks(child, baseUrl, visited))
children.map(async (child) => {
for await (const _ of crawlLinks(child, baseUrl, visited)) {
}
})
);
yield visited.size;
}
async function crawlGithubRepo(baseUrl: URL) {
@ -116,25 +125,44 @@ async function crawlGithubRepo(baseUrl: URL) {
return paths;
}
export async function crawlSubpages(baseUrl: URL) {
export async function* crawlSubpages(
baseUrl: URL
): AsyncGenerator<number, string[]> {
// Special case for GitHub repos
if (baseUrl.hostname === "github.com") {
return crawlGithubRepo(baseUrl);
}
// First, check if the parent of the path redirects to the same page
const parentUrl = new URL(baseUrl);
parentUrl.pathname = parentUrl.pathname.split("/").slice(0, -1).join("/");
const response = await fetch(parentUrl);
let useParent = response.url === baseUrl.toString();
if (baseUrl.pathname.endsWith("/")) {
baseUrl.pathname = baseUrl.pathname.slice(0, -1);
}
let realBaseUrl = new URL(baseUrl);
while (true) {
let parentUrl = new URL(realBaseUrl);
parentUrl.pathname = parentUrl.pathname.split("/").slice(0, -1).join("/");
if (
parentUrl.pathname === realBaseUrl.pathname ||
parentUrl.pathname === ""
) {
break;
}
const response = await fetch(parentUrl);
const redirected = response.url.toString() === baseUrl.toString() + "/";
if (!redirected) {
break;
}
realBaseUrl = parentUrl;
}
const visited = new Set<string>();
await crawlLinks(
(useParent ? parentUrl.pathname : baseUrl.pathname) || "/",
baseUrl,
for await (const count of crawlLinks(
realBaseUrl.pathname || "/",
realBaseUrl,
visited
);
)) {
yield count;
}
return [...visited];
}

View file

@ -22,7 +22,7 @@ async function createDocsTable(db: Database<sqlite3.Database>) {
db.exec(`CREATE TABLE IF NOT EXISTS docs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title STRING NOT NULL,
baseUrl STRING NOT NULL
baseUrl STRING NOT NULL UNIQUE
)`);
}

View file

@ -16,7 +16,7 @@ export async function* indexDocs(
embeddingsProvider: EmbeddingsProvider
): AsyncGenerator<IndexingProgressUpdate> {
const existingDocs = await listDocs();
if (existingDocs.find((doc) => doc.title === title)) {
if (existingDocs.find((doc) => doc.baseUrl === baseUrl.toString())) {
yield {
progress: 1,
desc: "Already indexed",
@ -29,8 +29,23 @@ export async function* indexDocs(
desc: "Finding subpages",
};
let subpaths = await crawlSubpages(baseUrl);
console.log("Found subpaths", subpaths);
const subpathGenerator = crawlSubpages(baseUrl);
let { value, done } = await subpathGenerator.next();
while (true) {
if (done) {
break;
}
yield {
progress: 0,
desc: `Finding subpages (${value})`,
};
const next = await subpathGenerator.next();
value = next.value;
done = next.done;
}
let subpaths = value as string[];
const chunks: Chunk[] = [];
const embeddings: number[][] = [];
@ -53,7 +68,7 @@ export async function* indexDocs(
for (let i = 0; i < subpaths.length; i++) {
const subpath = subpaths[i];
yield {
progress: 1 / (subpaths.length + 1),
progress: Math.max(1, Math.floor(100 / (subpaths.length + 1))),
desc: `${subpath}`,
};
@ -75,6 +90,7 @@ export async function* indexDocs(
(chunk.otherMetadata?.fragment
? `#${chunk.otherMetadata.fragment}`
: ""),
otherMetadata: chunk.otherMetadata,
index,
digest: subpath,
});

View file

@ -3,7 +3,7 @@ import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider";
class OpenAIEmbeddingsProvider extends BaseEmbeddingsProvider {
static defaultOptions: Partial<EmbedOptions> | undefined = {
apiBase: "https://api.openai.com",
apiBase: "https://api.openai.com/v1",
model: "text-embedding-3-large",
};
@ -16,13 +16,10 @@ class OpenAIEmbeddingsProvider extends BaseEmbeddingsProvider {
if (apiBase?.endsWith("/")) {
apiBase = apiBase.slice(0, -1);
}
if (apiBase?.endsWith("/v1")) {
apiBase = apiBase.slice(0, -3);
}
return await Promise.all(
chunks.map(async (chunk) => {
const resp = await fetch(`${apiBase}/v1/embeddings`, {
const resp = await fetch(`${apiBase}/embeddings`, {
method: "POST",
body: JSON.stringify({
input: chunk,

View file

@ -15,6 +15,10 @@ import {
export type DatabaseConnection = Database<sqlite3.Database>;
export function tagToString(tag: IndexTag): string {
return `${tag.directory}::${tag.branch}::${tag.artifactId}`;
}
export class SqliteDb {
static db: DatabaseConnection | null = null;

View file

@ -72,6 +72,26 @@ function countChatMessageTokens(
return countTokens(chatMessage.content, modelName) + TOKENS_PER_MESSAGE;
}
function pruneLinesFromTop(prompt: string, maxTokens: number): string {
let totalTokens = countTokens(prompt, "gpt-4");
const lines = prompt.split("\n");
while (totalTokens > maxTokens && lines.length > 0) {
totalTokens -= countTokens(lines.shift()!, "gpt-4");
}
return lines.join("\n");
}
function pruneLinesFromBottom(prompt: string, maxTokens: number): string {
let totalTokens = countTokens(prompt, "gpt-4");
const lines = prompt.split("\n");
while (totalTokens > maxTokens && lines.length > 0) {
totalTokens -= countTokens(lines.pop()!, "gpt-4");
}
return lines.join("\n");
}
function pruneStringFromBottom(
modelName: string,
maxTokens: number,
@ -307,6 +327,9 @@ function compileChatMessages(
export {
compileChatMessages,
countTokens,
pruneLinesFromBottom,
pruneLinesFromTop,
pruneRawPromptFromTop,
pruneStringFromBottom,
pruneStringFromTop,
};

View file

@ -6,11 +6,13 @@ import {
LLMFullCompletionOptions,
LLMOptions,
LLMReturnValue,
ModelName,
ModelProvider,
RequestOptions,
TemplateType,
} from "..";
import { ideRequest, ideStreamRequest } from "../ide/messaging";
import mergeJson from "../util/merge";
import {
CONTEXT_LENGTH_FOR_MODEL,
DEFAULT_ARGS,
@ -25,6 +27,7 @@ import {
import {
anthropicTemplateMessages,
chatmlTemplateMessages,
codeLlama70bTemplateMessages,
deepseekTemplateMessages,
llama2TemplateMessages,
llavaTemplateMessages,
@ -38,6 +41,7 @@ import {
} from "./templates/chat";
import {
alpacaEditPrompt,
codeLlama70bEditPrompt,
codellamaEditPrompt,
deepseekEditPrompt,
mistralEditPrompt,
@ -49,11 +53,13 @@ import {
xWinCoderEditPrompt,
zephyrEditPrompt,
} from "./templates/edit";
import CompletionOptionsForModels from "./templates/options";
const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [
"lmstudio",
"openai",
"ollama",
"together",
];
const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [
@ -88,12 +94,33 @@ export function modelSupportsImages(
return false;
}
const PARALLEL_PROVIDERS: ModelProvider[] = [
"anthropic",
"bedrock",
"deepinfra",
"gemini",
"google-palm",
"huggingface-inference-api",
"huggingface-tgi",
"mistral",
"free-trial",
"replicate",
"together",
];
export function llmCanGenerateInParallel(llm: ILLM): boolean {
if (llm.providerName === "openai") {
return llm.model.includes("gpt");
}
return PARALLEL_PROVIDERS.includes(llm.providerName);
}
function autodetectTemplateType(model: string): TemplateType | undefined {
const lower = model.toLowerCase();
if (lower === "codellama-70b") {
return "none";
if (lower.includes("codellama") && lower.includes("70b")) {
return "codellama-70b";
}
if (
@ -188,6 +215,7 @@ function autodetectTemplateFunction(
"xwin-coder": xWinCoderTemplateMessages,
"neural-chat": neuralChatTemplateMessages,
llava: llavaTemplateMessages,
"codellama-70b": codeLlama70bTemplateMessages,
none: null,
};
@ -228,6 +256,8 @@ function autodetectPromptTemplates(
editTemplate = xWinCoderEditPrompt;
} else if (templateType === "neural-chat") {
editTemplate = neuralChatEditPrompt;
} else if (templateType === "codellama-70b") {
editTemplate = codeLlama70bEditPrompt;
} else if (templateType) {
editTemplate = simplestEditPrompt;
}
@ -298,6 +328,12 @@ export abstract class BaseLLM implements ILLM {
model: options.model || "gpt-4",
maxTokens: options.completionOptions?.maxTokens || DEFAULT_MAX_TOKENS,
};
if (CompletionOptionsForModels[options.model as ModelName]) {
this.completionOptions = mergeJson(
this.completionOptions,
CompletionOptionsForModels[options.model as ModelName] || {}
);
}
this.requestOptions = options.requestOptions;
this.promptTemplates = {
...autodetectPromptTemplates(options.model, templateType),
@ -380,11 +416,11 @@ export abstract class BaseLLM implements ILLM {
.map(([key, value]) => `${key}: ${value}`)
.join("\n");
return `Settings:
${settings}
${settings}
############################################
############################################
${prompt}`;
${prompt}`;
}
private _logTokensGenerated(model: string, completion: string) {
@ -429,10 +465,10 @@ export abstract class BaseLLM implements ILLM {
delete options.log;
delete options.raw;
const completionOptions: CompletionOptions = {
...this.completionOptions,
...options,
};
const completionOptions: CompletionOptions = mergeJson(
this.completionOptions,
options
);
return { completionOptions, log, raw };
}
@ -499,6 +535,10 @@ export abstract class BaseLLM implements ILLM {
this._logTokensGenerated(completionOptions.model, completion);
if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
}
return { prompt, completion };
}
@ -539,6 +579,10 @@ export abstract class BaseLLM implements ILLM {
const completion = await this._complete(prompt, completionOptions);
this._logTokensGenerated(completionOptions.model, completion);
if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
}
return completion;
}
@ -611,6 +655,10 @@ export abstract class BaseLLM implements ILLM {
}
this._logTokensGenerated(completionOptions.model, completion);
if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
}
return { prompt, completion };
}

View file

@ -4,7 +4,7 @@ import OpenAI from "./OpenAI";
class LMStudio extends OpenAI {
static providerName: ModelProvider = "lmstudio";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "http://localhost:1234",
apiBase: "http://localhost:1234/v1",
};
}

View file

@ -4,7 +4,7 @@ import OpenAI from "./OpenAI";
class Mistral extends OpenAI {
static providerName: ModelProvider = "mistral";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://api.mistral.ai",
apiBase: "https://api.mistral.ai/v1",
model: "mistral-small",
};
}

View file

@ -79,6 +79,9 @@ class Ollama extends BaseLLM {
"deepseek-7b": "deepseek-coder:6.7b",
"deepseek-33b": "deepseek-coder:33b",
"neural-chat-7b": "neural-chat:7b-v3.3",
"starcoder-1b": "starcoder:1b",
"starcoder-3b": "starcoder:3b",
"stable-code-3b": "stable-code:3b",
}[this.model] || this.model
);
}
@ -104,6 +107,7 @@ class Ollama extends BaseLLM {
const finalOptions: any = {
model: this._getModel(),
raw: true,
keep_alive: 60 * 30, // 30 minutes
options: {
temperature: options.temperature,
top_p: options.topP,
@ -203,6 +207,14 @@ class Ollama extends BaseLLM {
}
}
}
async listModels(): Promise<string[]> {
const response = await this.fetch(`${this.apiBase}/api/tags`, {
method: "GET",
});
const data = await response.json();
return data.models.map((model: any) => model.name);
}
}
export default Ollama;

View file

@ -24,7 +24,7 @@ const NON_CHAT_MODELS = [
class OpenAI extends BaseLLM {
static providerName: ModelProvider = "openai";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://api.openai.com",
apiBase: "https://api.openai.com/v1",
};
protected _convertMessage(message: ChatMessage) {
@ -87,9 +87,7 @@ class OpenAI extends BaseLLM {
if (url.endsWith("/")) {
url = url.slice(0, -1);
}
if (!url.endsWith("/v1") && !url.includes("api.perplexity.ai")) {
url += "/v1";
}
return url + "/completions";
}
}
@ -110,6 +108,10 @@ class OpenAI extends BaseLLM {
prompt: string,
options: CompletionOptions
): AsyncGenerator<string> {
const args: any = this._convertArgs(options, []);
args.prompt = prompt;
delete args.messages;
const response = await this.fetch(this._getCompletionUrl(), {
method: "POST",
headers: {
@ -118,16 +120,7 @@ class OpenAI extends BaseLLM {
"api-key": this.apiKey || "", // For Azure
},
body: JSON.stringify({
...{
prompt,
model: options.model,
max_tokens: options.maxTokens,
temperature: options.temperature,
top_p: options.topP,
frequency_penalty: options.frequencyPenalty,
presence_penalty: options.presencePenalty,
stop: options.stop,
},
...args,
stream: true,
}),
});
@ -153,10 +146,6 @@ class OpenAI extends BaseLLM {
url = url.slice(0, -1);
}
if (!url.includes("/v1") && !url.includes("api.perplexity.ai")) {
// includes instead of endsWith becuase DeepInfra uses /v1/openai/chat/completions
url += "/v1";
}
return url + "/chat/completions";
}
}

View file

@ -26,10 +26,13 @@ class Replicate extends BaseLLM {
"nateraw/zephyr-7b-beta:b79f33de5c6c4e34087d44eaea4a9d98ce5d3f3a09522f7328eea0685003a931",
"mistral-7b":
"mistralai/mistral-7b-instruct-v0.1:83b6a56e7c828e667f21fd596c338fd4f0039b46bcfa18d973e8e70e455fda70",
"mistral-8x7b": "mistralai/mixtral-8x7b-instruct-v0.1" as any,
"wizardcoder-34b":
"andreasjansson/wizardcoder-python-34b-v1-gguf:67eed332a5389263b8ede41be3ee7dc119fa984e2bde287814c4abed19a45e54",
"neural-chat-7b":
"tomasmcm/neural-chat-7b-v3-1:acb450496b49e19a1e410b50c574a34acacd54820bc36c19cbfe05148de2ba57",
"deepseek-7b": "kcaverly/deepseek-coder-33b-instruct-gguf" as any,
"phind-codellama-34b": "kcaverly/phind-codellama-34b-v2-gguf" as any,
};
static providerName: ModelProvider = "replicate";

View file

@ -4,7 +4,7 @@ import OpenAI from "./OpenAI";
class TextGenWebUI extends OpenAI {
static providerName: ModelProvider = "text-gen-webui";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "http://localhost:5000",
apiBase: "http://localhost:5000/v1",
};
}

View file

@ -1,41 +1,39 @@
import { BaseLLM } from "..";
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
import { streamSse } from "../stream";
import {
ChatMessage,
CompletionOptions,
LLMOptions,
ModelProvider,
} from "../..";
class Together extends BaseLLM {
import OpenAI from "./OpenAI";
class Together extends OpenAI {
static providerName: ModelProvider = "together";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://api.together.xyz",
apiBase: "https://api.together.xyz/v1",
};
private static MODEL_IDS: { [name: string]: string } = {
"codellama-7b": "togethercomputer/CodeLlama-7b-Instruct",
"codellama-13b": "togethercomputer/CodeLlama-13b-Instruct",
"codellama-34b": "togethercomputer/CodeLlama-34b-Instruct",
"codellama-70b": "codellama/CodeLlama-70b-Python-hf",
"codellama-70b": "codellama/CodeLlama-70b-Instruct-hf",
"llama2-7b": "togethercomputer/llama-2-7b-chat",
"llama2-13b": "togethercomputer/llama-2-13b-chat",
"llama2-70b": "togethercomputer/llama-2-70b-chat",
"mistral-7b": "mistralai/Mistral-7B-Instruct-v0.1",
"mistral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"phind-codellama-34b": "Phind/Phind-CodeLlama-34B-v2",
"wizardcoder-34b": "WizardLM/WizardCoder-Python-34B-V1.0",
};
private _getModelName(model: string) {
return Together.MODEL_IDS[model] || this.model;
}
private _convertArgs(options: CompletionOptions, prompt: string) {
const finalOptions = {
prompt,
model: this._getModelName(options.model),
temperature: options.temperature,
top_p: options.topP,
top_k: options.topK,
max_tokens: options.maxTokens,
repetition_penalty: options.frequencyPenalty,
};
protected _convertArgs(options: any, messages: ChatMessage[]) {
const finalOptions = super._convertArgs(options, messages);
finalOptions.model = this._getModelName(options.model);
return finalOptions;
}
@ -43,22 +41,8 @@ class Together extends BaseLLM {
prompt: string,
options: CompletionOptions
): AsyncGenerator<string> {
const response = await this.fetch(`${this.apiBase}/inference`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.apiKey}`,
},
body: JSON.stringify({
...this._convertArgs(options, prompt),
stream_tokens: true,
}),
});
for await (const value of streamSse(response)) {
if (value.choices) {
yield value.choices[0].text;
}
for await (const chunk of this._legacystreamComplete(prompt, options)) {
yield chunk;
}
}
}

View file

@ -264,9 +264,26 @@ function neuralChatTemplateMessages(msgs: ChatMessage[]): string {
return prompt;
}
/**
'<s>Source: system\n\n System prompt <step> Source: user\n\n First user query <step> Source: assistant\n\n Model response to first query <step> Source: user\n\n Second user query <step> Source: assistant\nDestination: user\n\n '
*/
function codeLlama70bTemplateMessages(msgs: ChatMessage[]): string {
let prompt = "<s>";
for (const msg of msgs) {
prompt += `Source: ${msg.role}\n\n ${stripImages(msg.content).trim()}`;
prompt += " <step> ";
}
prompt += "Source: assistant\nDestination: user\n\n";
return prompt;
}
export {
anthropicTemplateMessages,
chatmlTemplateMessages,
codeLlama70bTemplateMessages,
deepseekTemplateMessages,
llama2TemplateMessages,
llavaTemplateMessages,

View file

@ -138,18 +138,25 @@ Sure! Here's the code you requested:
\`\`\`{{{language}}}
`;
const codeLlama70bEditPrompt = `<s>Source: system\n\n You are an expert programmer and write code on the first attempt without any errors or fillers. <step> Source: user\n\n Rewrite the code to satisfy this request: "{{{userInput}}}"
\`\`\`{{{language}}}
{{{codeToEdit}}}
\`\`\` <step> Source: assistant\nDestination: user\n\n `;
export {
alpacaEditPrompt,
codeLlama70bEditPrompt,
codellamaEditPrompt,
codellamaInfillEditPrompt,
deepseekEditPrompt,
gptEditPrompt,
mistralEditPrompt,
neuralChatEditPrompt,
openchatEditPrompt,
phindEditPrompt,
simplestEditPrompt,
simplifiedEditPrompt,
xWinCoderEditPrompt,
zephyrEditPrompt,
neuralChatEditPrompt,
};

View file

@ -0,0 +1,11 @@
import { CompletionOptions, ModelName } from "../..";
const CompletionOptionsForModels: {
[key in ModelName]?: Partial<CompletionOptions>;
} = {
"codellama-70b": {
stop: ["Source: assistant"],
},
};
export default CompletionOptionsForModels;

View file

@ -120,7 +120,7 @@ export function renderPromptTemplate(
}
}
export function getBasename(filepath: string): string {
export function getBasename(filepath: string, n: number = 1): string {
return filepath.split(/[\\/]/).pop() || "";
}

36
core/util/merge.ts Normal file
View file

@ -0,0 +1,36 @@
type JsonObject = { [key: string]: any };
export function mergeJson(first: JsonObject, second: JsonObject): any {
try {
for (var key in second) {
let secondValue = second[key];
if (!(key in first)) {
// New value
first[key] = secondValue;
continue;
}
const firstValue = first[key];
if (Array.isArray(secondValue)) {
// Array
first[key] = [...firstValue, ...secondValue];
} else if (typeof secondValue === "object") {
// Object
first[key] = mergeJson(firstValue, secondValue);
} else {
// Other (boolean, number, string)
first[key] = secondValue;
}
}
return first;
} catch (e) {
console.error("Error merging JSON", e, first, second);
return {
...first,
...second,
};
}
}
export default mergeJson;

View file

@ -176,6 +176,10 @@ export function getLanceDbPath(): string {
return path.join(getIndexFolderPath(), "lancedb");
}
export function getTabAutocompleteCacheSqlitePath(): string {
return path.join(getIndexFolderPath(), "autocompleteCache.sqlite");
}
export function getDocsSqlitePath(): string {
return path.join(getIndexFolderPath(), "docs.sqlite");
}

92
core/util/treeSitter.ts Normal file
View file

@ -0,0 +1,92 @@
// import treeSitterBash from "tree-sitter-wasms/out/tree-sitter-bash.wasm";
// import treeSitterC from "tree-sitter-wasms/out/tree-sitter-c.wasm";
// import treeSitterCSharp from "tree-sitter-wasms/out/tree-sitter-c_sharp.wasm";
// import treeSitterCpp from "tree-sitter-wasms/out/tree-sitter-cpp.wasm";
// import treeSitterCss from "tree-sitter-wasms/out/tree-sitter-css.wasm";
// // import treeSitterElisp from "tree-sitter-wasms/out/tree-sitter-elisp.wasm"
// // import treeSitterElixir from "tree-sitter-wasms/out/tree-sitter-elixir.wasm"
// import treeSitterElm from "tree-sitter-wasms/out/tree-sitter-elm.wasm";
// // import treeSitterEmbeddedTemplate from "tree-sitter-wasms/out/tree-sitter-embedded_template.wasm"
// import treeSitterGo from "tree-sitter-wasms/out/tree-sitter-go.wasm";
// import treeSitterHtml from "tree-sitter-wasms/out/tree-sitter-html.wasm";
// import treeSitterJava from "tree-sitter-wasms/out/tree-sitter-java.wasm";
// import treeSitterJavascript from "tree-sitter-wasms/out/tree-sitter-javascript.wasm";
// import treeSitterJson from "tree-sitter-wasms/out/tree-sitter-json.wasm";
// // import treeSitterLua from "tree-sitter-wasms/out/tree-sitter-lua.wasm"
// import treeSitterOcaml from "tree-sitter-wasms/out/tree-sitter-ocaml.wasm";
// import treeSitterPhp from "tree-sitter-wasms/out/tree-sitter-php.wasm";
// import treeSitterPython from "tree-sitter-wasms/out/tree-sitter-python.wasm";
// // import treeSitterQl from "tree-sitter-wasms/out/tree-sitter-ql.wasm"
// // import treeSitterRescript from "tree-sitter-wasms/out/tree-sitter-rescript.wasm"
// import treeSitterRuby from "tree-sitter-wasms/out/tree-sitter-ruby.wasm";
// import treeSitterRust from "tree-sitter-wasms/out/tree-sitter-rust.wasm";
// // import treeSitterSystemRdl from "tree-sitter-wasms/out/tree-sitter-systemrdl.wasm"
// import treeSitterToml from "tree-sitter-wasms/out/tree-sitter-toml.wasm";
// import treeSitterTsx from "tree-sitter-wasms/out/tree-sitter-tsx.wasm";
// import treeSitterTypescript from "tree-sitter-wasms/out/tree-sitter-typescript.wasm";
// import treeSitterVue from "tree-sitter-wasms/out/tree-sitter-vue.wasm";
// import treeSitterYaml from "tree-sitter-wasms/out/tree-sitter-yaml.wasm";
import Parser from "web-tree-sitter";
// export const fileExtensionToWasm: { [key: string]: string } = {
// py: treeSitterPython,
// js: treeSitterJavascript,
// html: treeSitterHtml,
// java: treeSitterJava,
// go: treeSitterGo,
// rb: treeSitterRuby,
// rs: treeSitterRust,
// c: treeSitterC,
// cpp: treeSitterCpp,
// cs: treeSitterCSharp,
// php: treeSitterPhp,
// css: treeSitterCss,
// bash: treeSitterBash,
// json: treeSitterJson,
// ts: treeSitterTypescript,
// tsx: treeSitterTsx,
// vue: treeSitterVue,
// yaml: treeSitterYaml,
// toml: treeSitterToml,
// ocaml: treeSitterOcaml,
// elm: treeSitterElm,
// // jl: treeSitterJulia,
// // swift: "swift",
// // kt: "kotlin",
// // scala: treeSitterScala,
// };
export const supportedLanguages: { [key: string]: string } = {
cpp: "cpp",
cs: "csharp",
php: "php",
css: "css",
bash: "bash",
json: "json",
ts: "typescript",
tsx: "tsx",
vue: "vue",
yaml: "yaml",
toml: "toml",
ocaml: "ocaml",
elm: "elm",
rb: "ruby",
js: "javascript",
// jl: "julia",
// swift: "swift",
// kt: "kotlin",
// scala: "scala",
};
export async function getParserForFile(filepath: string) {
await Parser.init();
const parser = new Parser();
const segs = filepath.split(".");
const wasmPath = `${__dirname}/tree-sitter-wasms/tree-sitter-${
supportedLanguages[segs[segs.length - 1]]
}.wasm`;
const Language = await Parser.Language.load(wasmPath);
parser.setLanguage(Language);
return parser;
}

View file

@ -32,6 +32,14 @@ Type '@terminal' to reference the contents of your IDE's terminal.
{ "name": "terminal" }
```
### Documentation
Type `@docs` to index and retrieve snippets from any documentation site. You can add any site by selecting "Add Docs" in the dropdown, then entering the root URL of the documentation site and a title to remember it by. After the site has been indexed, you can type `@docs`, select your documentation from the dropdown, and Continue will use similarity search to automatically find important sections when answering your question.
```json
{ "name": "docs" }
```
### Open Files
Type '@open' to reference the contents of all of your open files. Set `onlyPinned` to `true` to only reference pinned files.

View file

@ -98,32 +98,29 @@ This exact function and a few other default implementations are available in [`c
You also have access to customize the prompt used in the '/edit' slash command. We already have a well-engineered prompt for GPT-4 and sensible defaults for less powerful open-source models, but you might wish to play with the prompt and try to find a more reliable alternative if you are for example getting English as well as code in your output.
To customize the prompt, use the `promptTemplates` property of any `LLM`, which is a dictionary, and set the "edit" key to a template string with Mustache syntax. The 'filePrefix', 'fileSuffix', 'codeToEdit', 'contextItems', and 'userInput' variables are available in the template. Here is an example (the default for non-GPT-4 models):
To customize the prompt, use the `promptTemplates` property of any model, which is a dictionary, and set the "edit" key to a template string with Mustache syntax. The 'filePrefix', 'fileSuffix', 'codeToEdit', 'language', 'contextItems', and 'userInput' variables are available in the template. Here is an example:
```typescript
`
[INST] Consider the following code:
\`\`\`
const codellamaEditPrompt = `\`\`\`{{{language}}}
{{{codeToEdit}}}
\`\`\`
Edit the code to perfectly satisfy the following user request:
{{{userInput}}}
Output nothing except for the code. No code block, no English explanation, no start/end tags.
[/INST]
`;
[INST] You are an expert programmer and personal assistant. Your task is to rewrite the above code with these instructions: "{{{userInput}}}"
Your answer should be given inside of a code block. It should use the same kind of indentation as above.
[/INST] Sure! Here's the rewritten code you requested:
\`\`\`{{{language}}}`;
```
It can then be used like this in `config.py`:
It can then be used like this in `config.ts`:
```typescript title="~/.continue/config.py"
```typescript title="~/.continue/config.ts"
function modifyConfig(config: Config): Config {
config.models[0].promptTemplates["edit"] = "<INSERT_TEMPLATE_HERE>";
return config;
}
```
A few pre-made templates are available in [`continuedev.libs.llm.prompts.edit`](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/prompts/edit.py).
You can find all existing templates for /edit in [`core/llm/templates/edit.ts`](https://github.com/continuedev/continue/blob/main/core/llm/templates/edit.ts).
## Defining a Custom LLM Provider

View file

@ -3,7 +3,7 @@ import JSONSchemaViewer from "@theme/JSONSchemaViewer";
# Configuration Options
The following shows the JSON Schema definition for `config.json`:
The following shows the JSON Schema definition for `config.json`. You can also define a partial `config.json` object in a file called `.continuerc.json` at the root of your workspace. This will be [applied on top of](https://github.com/continuedev/continue/blob/74c1eb5e25c517c575f72d26227d31d5d2ea18ed/extensions/vscode/src/ideProtocol.ts#L165-L173) any configuration from `config.json`.
<JSONSchemaViewer
schema={Schema}

View file

@ -0,0 +1,52 @@
# Tab Autocomplete (Experimental)
Continue now provides experimental support for tab autocomplete in VS Code. You can enable it by downloading the pre-release version of the extension, opening VS Code settings, and then checking the box that says "Enable Tab Autocomplete". There is also a button on the bottom/status bar for fast access. We will be greatly improving the experience over the next few releases, and it is always helpful to hear feedback. If you have any problems or suggestions, please let us know in our [Discord](https://discord.gg/vapESyrFmJ).
## Setting up with Ollama
We recommend setting up tab-autocomplete with a local Ollama instance. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model:
```bash
ollama run deepseek-coder:1.3b-base
```
Once it has been downloaded, you should begin to see completions in VS Code.
## Configuration Options
The following can be configured in `config.json`:
### `tabAutocompleteModel`
This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `starcoder-1b`, or `starcoder-3b`.
### `tabAutocompleteOptions`
Empty for now. Let use know what you'd like access to!
## Troubleshooting
### I'm not seeing any completions
Follow these steps to ensure that everything is set up correctly:
1. Make sure you have the pre-release version of the extension installed.
2. Make sure you have the "Enable Tab Autocomplete" setting checked.
3. Make sure you have downloaded Ollama.
4. Run `ollama run deepseek-coder:1.3b-base` to verify that the model is downloaded.
5. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere.
6. Make sure that you aren't also using another Ollama model for chat. This will cause Ollama to constantly load and unload the models from memory, resulting in slow responses (or none at all) for both.
7. Check the output of the logs to find any potential errors (cmd/ctrl+shift+p -> "Toggle Developer Tools" -> "Console" tab).
8. If you are still having issues, please let us know in our [Discord](https://discord.gg/vapESyrFmJ) and we'll help as soon as possible.
### Completions are slow
We are working on this! You can expect improvements in the time frame of the next few days. For now, you will probably see faster completions in smaller files where there isn't as much context above the cursor.
### Completions don't know about my code
We are working on this as well! Right now Continue only sees your current file surrounding the cursor. We're already partway through building a full-text search feature that will help Continue know about other files. You can expect to see improvements in the time frame of roughly a week.
### Completions contain formatting errors
If you're seeing a common pattern of mistake that might be helpful to report, please share in Discord. We will do our best to fix it as soon as possible.

View file

@ -49,6 +49,7 @@ const sidebars = {
// "walkthroughs/codellama",
"walkthroughs/running-continue-without-internet",
"walkthroughs/codebase-embeddings",
"walkthroughs/tab-autocomplete",
// "walkthroughs/config-file-migration",
],
},

View file

@ -172,7 +172,8 @@
"deepseek",
"openchat",
"xwin-coder",
"neural-chat"
"neural-chat",
"codellama-70b"
],
"type": "string"
},
@ -434,10 +435,13 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"neural-chat-7b"
"neural-chat-7b",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -568,10 +572,13 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"neural-chat-7b"
"neural-chat-7b",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -609,10 +616,13 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"neural-chat-7b"
"neural-chat-7b",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -784,7 +794,6 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"claude-2",
@ -792,7 +801,11 @@
"gemini-pro",
"mistral-tiny",
"mistral-small",
"mistral-medium"
"mistral-medium",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -968,6 +981,7 @@
"problems",
"folder",
"issue",
"docs",
"tree"
],
"markdownEnumDescriptions": [
@ -982,6 +996,7 @@
"Include important files from a folder in the prompt, as determined by similarity search",
"Reference GitHub issues from a repository",
"Retrieve important pages from a documentation website, as determined by similarity search",
"Index and retrieve the contents of any documentation site, using embeddings to find important snippets",
"Display a file tree of the current workspace"
],
"type": "string"
@ -1292,6 +1307,16 @@
}
}
]
},
"tabAutocompleteModel": {
"title": "Tab Autocomplete Model",
"markdownDescription": "The model used for tab autocompletion. If undefined, Continue will not do tab autocompletion.",
"default": {
"title": "Tab Autocomplete Model",
"provider": "ollama",
"model": "deepseek-coder:1.3b-base"
},
"$ref": "#/definitions/ModelDescription"
}
}
}

View file

@ -6,6 +6,15 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
Pre-release Changes
### Added
* Image support
* Full-text search index for retrieval
* Docs context provider
* CodeLlama-70b support
### Fixed
* Fixed proxy setting in config.json
## v0.8.2 - 2024-01-23
### Added
* Add codellama and gemini to free trial, using new server
@ -14,7 +23,6 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
### Changed
* Updates to packaging to download native modules for current platform (lancedb, sqlite, onnxruntime, tree-sitter wasms)
* Context providers now run from the extension side (in Node.js instead of browser javascript)
* Image support
## v0.8.1 - 2024-01-08

View file

@ -172,7 +172,8 @@
"deepseek",
"openchat",
"xwin-coder",
"neural-chat"
"neural-chat",
"codellama-70b"
],
"type": "string"
},
@ -434,10 +435,13 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"neural-chat-7b"
"neural-chat-7b",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -568,10 +572,13 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"neural-chat-7b"
"neural-chat-7b",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -609,10 +616,13 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"neural-chat-7b"
"neural-chat-7b",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -784,7 +794,6 @@
"wizardcoder-34b",
"zephyr-7b",
"codeup-13b",
"deepseek-1b",
"deepseek-7b",
"deepseek-33b",
"claude-2",
@ -792,7 +801,11 @@
"gemini-pro",
"mistral-tiny",
"mistral-small",
"mistral-medium"
"mistral-medium",
"deepseek-1b",
"stable-code-3b",
"starcoder-1b",
"starcoder-3b"
]
},
{ "type": "string" }
@ -968,6 +981,7 @@
"problems",
"folder",
"issue",
"docs",
"tree"
],
"markdownEnumDescriptions": [
@ -982,6 +996,7 @@
"Include important files from a folder in the prompt, as determined by similarity search",
"Reference GitHub issues from a repository",
"Retrieve important pages from a documentation website, as determined by similarity search",
"Index and retrieve the contents of any documentation site, using embeddings to find important snippets",
"Display a file tree of the current workspace"
],
"type": "string"
@ -1292,6 +1307,16 @@
}
}
]
},
"tabAutocompleteModel": {
"title": "Tab Autocomplete Model",
"markdownDescription": "The model used for tab autocompletion. If undefined, Continue will not do tab autocompletion.",
"default": {
"title": "Tab Autocomplete Model",
"provider": "ollama",
"model": "deepseek-coder:1.3b-base"
},
"$ref": "#/definitions/ModelDescription"
}
}
}

View file

@ -1,3 +1,13 @@
function mergeSortAlgorithm(arr) {
// TODO
}
import { factorial, repeat } from "./factorial";
function fib(n) {
if (n <= 1) return n;
return fib(n - 2) + fib(n - 1);
}
let d = repeat(5, "a");
console.log(d);
let e = factorial(3);
console.log(e);

View file

@ -0,0 +1,8 @@
export function factorial(n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
export function repeat(n: number, a: string) {
return a.repeat(n);
}

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
{
"name": "continue",
"icon": "media/icon.png",
"version": "0.8.7",
"version": "0.9.44",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"
@ -22,7 +22,7 @@
"description": "Open-source autopilot for software development - bring the power of ChatGPT to your IDE",
"publisher": "Continue",
"engines": {
"vscode": "^1.67.0",
"vscode": "^1.70.0",
"node": ">=20.11.0"
},
"galleryBanner": {
@ -56,17 +56,17 @@
"continue.telemetryEnabled": {
"type": "boolean",
"default": true,
"description": "Continue collects anonymous usage data, cleaned of PII, to help us improve the product for our users. Read more at https://continue.dev/docs/telemetry."
"markdownDescription": "Continue collects anonymous usage data, cleaned of PII, to help us improve the product for our users. Read more at [continue.dev › Telemetry](https://continue.dev/docs/telemetry)."
},
"continue.showInlineTip": {
"type": "boolean",
"default": true,
"description": "Show inline suggestion to use the Continue keyboard shortcuts."
},
"continue.proxyServerUrl": {
"type": "string",
"default": "http://localhost:65433",
"description": "An optional proxy server URL through which you can route all Continue requests. Do not change this unless you have set up your own server to proxy requests."
"continue.enableTabAutocomplete": {
"type": "boolean",
"default": false,
"markdownDescription": "Enable Continue's experimental tab autocomplete feature. Read our walkthrough to learn about configuration and how to share feedback: [continue.dev › Walkthrough: Tab Autocomplete](https://continue.dev/docs/walkthroughs/tab-autocomplete)"
}
}
},
@ -74,90 +74,108 @@
{
"command": "continue.acceptDiff",
"category": "Continue",
"title": "Accept Diff"
"title": "Accept Diff",
"group": "Continue"
},
{
"command": "continue.rejectDiff",
"category": "Continue",
"title": "Reject Diff"
"title": "Reject Diff",
"group": "Continue",
"icon": "$(stop)"
},
{
"command": "continue.quickEdit",
"category": "Continue",
"title": "Quick Edit"
"title": "Quick Edit",
"group": "Continue"
},
{
"command": "continue.toggleAuxiliaryBar",
"category": "Continue",
"title": "Toggle Right Sidebar"
"title": "Toggle Right Sidebar",
"group": "Continue"
},
{
"command": "continue.focusContinueInput",
"category": "Continue",
"title": "Add Highlighted Code to Context"
"title": "Add Highlighted Code to Context",
"group": "Continue"
},
{
"command": "continue.focusContinueInputWithoutClear",
"category": "Continue",
"title": "Add Highlighted Code to Context"
"title": "Add Highlighted Code to Context",
"group": "Continue"
},
{
"command": "continue.debugTerminal",
"category": "Continue",
"title": "Debug Terminal"
"title": "Debug Terminal",
"group": "Continue"
},
{
"command": "continue.toggleFullScreen",
"category": "Continue",
"title": "Toggle Full Screen",
"icon": "$(fullscreen)"
"icon": "$(fullscreen)",
"group": "Continue"
},
{
"command": "continue.shareSession",
"category": "Continue",
"title": "Share Session"
"title": "Share Session",
"group": "Continue"
},
{
"command": "continue.selectFilesAsContext",
"category": "Continue",
"title": "Continue: Select Files as Context"
"title": "Continue: Select Files as Context",
"group": "Continue"
},
{
"command": "continue.newSession",
"category": "Continue",
"title": "New Session",
"icon": "$(add)"
"icon": "$(add)",
"group": "Continue"
},
{
"command": "continue.viewHistory",
"category": "Continue",
"title": "View History",
"icon": "$(history)"
"icon": "$(history)",
"group": "Continue"
},
{
"command": "continue.writeCommentsForCode",
"category": "Continue",
"title": "Write Comments for this Code"
"title": "Write Comments for this Code",
"group": "Continue"
},
{
"command": "continue.writeDocstringForCode",
"category": "Continue",
"title": "Write a Docstring for this Code"
"title": "Write a Docstring for this Code",
"group": "Continue"
},
{
"command": "continue.fixCode",
"category": "Continue",
"title": "Fix this Code"
"title": "Fix this Code",
"group": "Continue"
},
{
"command": "continue.optimizeCode",
"category": "Continue",
"title": "Optimize this Code"
"title": "Optimize this Code",
"group": "Continue"
},
{
"command": "continue.fixGrammar",
"category": "Continue",
"title": "Fix Grammar / Spelling"
"title": "Fix Grammar / Spelling",
"group": "Continue"
}
],
"keybindings": [
@ -210,6 +228,29 @@
}
],
"menus": {
"commandPalette": [
{
"command": "continue.quickEdit"
},
{
"command": "continue.toggleAuxiliaryBar"
},
{
"command": "continue.focusContinueInput"
},
{
"command": "continue.focusContinueInputWithoutClear"
},
{
"command": "continue.debugTerminal"
},
{
"command": "continue.toggleFullScreen"
},
{
"command": "continue.newSession"
}
],
"webview/context": [
{
"command": "continue.shareSession",
@ -219,7 +260,14 @@
"editor/context": [
{
"submenu": "continue.continueSubMenu",
"group": "1_debug@1"
"group": "0_acontinue"
}
],
"editor/title/run": [
{
"command": "continue.rejectDiff",
"group": "Continue",
"when": "continue.streamingDiff"
}
],
"continue.continueSubMenu": [
@ -383,7 +431,7 @@
"@types/node-fetch": "^2.6.2",
"@types/react-dom": "^18.2.4",
"@types/request": "^2.48.8",
"@types/vscode": "1.67",
"@types/vscode": "1.70",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
@ -412,6 +460,7 @@
"express": "^4.18.2",
"fkill": "^8.1.0",
"follow-redirects": "^1.15.4",
"handlebars": "^4.7.8",
"highlight.js": "^11.7.0",
"highlightable": "^1.3.0-beta.0",
"http-proxy": "^1.18.1",

View file

@ -33,7 +33,9 @@ if (args[2] === "--target") {
execSync("npm install");
console.log("npm install in gui completed");
execSync("npm run build");
if (ghAction()) {
execSync("npm run build");
}
// Copy over the dist folder to the Intellij extension //
const intellijExtensionWebviewPath = path.join(

View file

@ -8,6 +8,10 @@ import IdeProtocolClient from "../continueIdeClient";
import { ContinueGUIWebviewViewProvider } from "../debugPanel";
import registerQuickFixProvider from "../lang-server/codeActions";
import { registerAllCodeLensProviders } from "../lang-server/codeLens";
import {
ContinueCompletionProvider,
setupStatusBar,
} from "../lang-server/completionProvider";
import { vsCodeIndexCodebase } from "../util/indexCodebase";
import { getExtensionUri } from "../util/vscode";
import { setupInlineTips } from "./inlineTips";
@ -17,24 +21,27 @@ export let extensionContext: vscode.ExtensionContext | undefined = undefined;
export let ideProtocolClient: IdeProtocolClient;
export let windowId: string = v4();
async function openTutorial(context: vscode.ExtensionContext) {
if (context.globalState.get<boolean>("continue.tutorialShown") !== true) {
const tutorialPath = path.join(
getExtensionUri().fsPath,
"continue_tutorial.py"
);
// Ensure keyboard shortcuts match OS
const os = process.platform;
export async function showTutorial() {
const tutorialPath = path.join(
getExtensionUri().fsPath,
"continue_tutorial.py"
);
// Ensure keyboard shortcuts match OS
if (process.platform !== "darwin") {
let tutorialContent = fs.readFileSync(tutorialPath, "utf8");
if (os !== "darwin") {
tutorialContent = tutorialContent.replace("⌘", "^");
fs.writeFileSync(tutorialPath, tutorialContent);
}
tutorialContent = tutorialContent.replace("⌘", "^");
fs.writeFileSync(tutorialPath, tutorialContent);
}
const doc = await vscode.workspace.openTextDocument(
vscode.Uri.file(tutorialPath)
);
await vscode.window.showTextDocument(doc);
const doc = await vscode.workspace.openTextDocument(
vscode.Uri.file(tutorialPath)
);
await vscode.window.showTextDocument(doc);
}
async function openTutorialFirstTime(context: vscode.ExtensionContext) {
if (context.globalState.get<boolean>("continue.tutorialShown") !== true) {
await showTutorial();
context.globalState.update("continue.tutorialShown", true);
}
}
@ -79,9 +86,20 @@ export async function activateExtension(context: vscode.ExtensionContext) {
registerAllCodeLensProviders(context);
registerAllCommands(context);
registerQuickFixProvider();
await openTutorial(context);
await openTutorialFirstTime(context);
setupInlineTips(context);
showRefactorMigrationMessage();
const config = vscode.workspace.getConfiguration("continue");
const enabled = config.get<boolean>("enableTabAutocomplete");
setupStatusBar(enabled);
// Register inline completion provider
context.subscriptions.push(
vscode.languages.registerInlineCompletionItemProvider(
[{ pattern: "**" }],
new ContinueCompletionProvider()
)
);
ideProtocolClient = new IdeProtocolClient(context);
@ -142,6 +160,8 @@ export async function activateExtension(context: vscode.ExtensionContext) {
fontColor: "#fff",
};
themeJson.fileNames[".continueignore"] = "_f_continue";
themeJson.fileNames[".continuerc.json"] = "_f_continue";
themeJson.fileNames["config.json"] = "_f_continue";
fs.writeFileSync(themePath, JSON.stringify(themeJson));
found = true;
break;

View file

@ -13,6 +13,11 @@ const inlineTipDecoration = vscode.window.createTextEditorDecorationType({
function handleSelectionChange(e: vscode.TextEditorSelectionChangeEvent) {
const selection = e.selections[0];
const editor = e.textEditor;
if (editor.document.uri.toString().startsWith("output:")) {
return;
}
if (
selection.isEmpty ||
vscode.workspace
@ -69,6 +74,13 @@ export function setupInlineTips(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (editor?.document.getText() === "") {
if (
editor.document.uri.toString().startsWith("output:") ||
editor.document.uri.scheme === "comment"
) {
return;
}
editor.setDecorations(emptyFileTooltipDecoration, [
{
range: new vscode.Range(
@ -83,6 +95,9 @@ export function setupInlineTips(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.workspace.onDidChangeTextDocument((e) => {
if (e.document.uri.toString().startsWith("vscode://inline-chat")) {
return;
}
if (e.document.getText() === "") {
vscode.window.visibleTextEditors.forEach((editor) => {
editor.setDecorations(emptyFileTooltipDecoration, [

View file

@ -11,6 +11,7 @@ import {
streamEdit,
verticalPerLineDiffManager,
} from "./diff/verticalPerLine/manager";
import { AutocompleOutcome } from "./lang-server/completionProvider";
function addHighlightedCodeToContext(edit: boolean) {
const editor = vscode.window.activeTextEditor;
@ -322,6 +323,23 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
`/references ${filepath.fsPath} ${position.line} ${position.character}`
);
},
"continue.logAutocompleteOutcome": (
outcome: AutocompleOutcome,
logRejectionTimeout: NodeJS.Timeout
) => {
clearTimeout(logRejectionTimeout);
outcome.accepted = true;
ideProtocolClient.logDevData("autocomplete", outcome);
},
"continue.toggleTabAutocompleteEnabled": () => {
const config = vscode.workspace.getConfiguration("continue");
const enabled = config.get("enableTabAutocomplete");
config.update(
"enableTabAutocomplete",
!enabled,
vscode.ConfigurationTarget.Global
);
},
};
export function registerAllCommands(context: vscode.ExtensionContext) {

View file

@ -233,9 +233,9 @@ class IdeProtocolClient {
panel.webview.html = getSidebarContent(panel, "/monaco", edits);
}
openFile(filepath: string) {
openFile(filepath: string, range?: vscode.Range) {
// vscode has a builtin open/get open files
openEditorAndRevealRange(filepath, undefined, vscode.ViewColumn.One);
return openEditorAndRevealRange(filepath, range, vscode.ViewColumn.One);
}
async fileExists(filepath: string): Promise<boolean> {
@ -410,6 +410,21 @@ class IdeProtocolClient {
return contents;
}
async readRangeInFile(
filepath: string,
range: vscode.Range
): Promise<string> {
const contents = new TextDecoder().decode(
await vscode.workspace.fs.readFile(vscode.Uri.file(filepath))
);
const lines = contents.split("\n");
return (
lines.slice(range.start.line, range.end.line).join("\n") +
"\n" +
lines[range.end.line].slice(0, range.end.character)
);
}
async getTerminalContents(commands: number = -1): Promise<string> {
const tempCopyBuffer = await vscode.env.clipboard.readText();
if (commands < 0) {

View file

@ -8,7 +8,11 @@ import * as path from "path";
import * as io from "socket.io-client";
import { v4 as uuidv4 } from "uuid";
import * as vscode from "vscode";
import { ideProtocolClient, windowId } from "./activation/activate";
import {
ideProtocolClient,
showTutorial,
windowId,
} from "./activation/activate";
import { getContinueServerUrl } from "./bridge";
import { streamEdit } from "./diff/verticalPerLine/manager";
import historyManager from "./history";
@ -211,25 +215,6 @@ export function getSidebarContent(
});
break;
}
case "showLines": {
ideProtocolClient.highlightCode(
{
filepath: data.filepath,
range: {
start: {
line: data.start,
character: 0,
},
end: {
line: data.end,
character: 0,
},
},
},
"#00ff0022"
);
break;
}
case "toggleDevTools": {
vscode.commands.executeCommand("workbench.action.toggleDevTools");
vscode.commands.executeCommand("continue.viewLogs");
@ -428,6 +413,11 @@ export function getSidebarContent(
respond(await ide.getProblems(data.message.filepath));
break;
}
case "getBranch": {
const { dir } = data.message;
respond(await ide.getBranch(dir));
break;
}
case "getOpenFiles": {
respond(await ide.getOpenFiles());
break;
@ -436,6 +426,11 @@ export function getSidebarContent(
respond(await ide.getPinnedFiles());
break;
}
case "showLines": {
const { filepath, startLine, endLine } = data.message;
respond(await ide.showLines(filepath, startLine, endLine));
break;
}
// Other
case "errorPopup": {
vscode.window
@ -683,7 +678,7 @@ export function getSidebarContent(
embeddingsProvider
)) {
progress.report({
increment: update.progress * 100,
increment: update.progress,
message: update.desc,
});
}
@ -691,6 +686,10 @@ export function getSidebarContent(
vscode.window.showInformationMessage(
`🎉 Successfully indexed ${title}`
);
debugPanelWebview?.postMessage({
type: "refreshSubmenuItems",
});
}
);
break;
@ -717,18 +716,25 @@ export function getSidebarContent(
);
break;
}
case "showTutorial": {
showTutorial();
break;
}
}
} catch (e: any) {
let message = `Continue error: ${e.message}`;
if (e.cause) {
if (e.cause.name === "ConnectTimeoutError") {
message = `Connection timed out. If you expect it to take a long time to connect, you can increase the timeout in config.json by setting "requestOptions": { "timeout": 10000 }. You can find the full config reference here: https://continue.dev/docs/reference/config`;
} else if (e.cause.code === "ECONNREFUSED") {
message = `Connection was refused. This likely means that there is no server running at the specified URL. If you are running your own server you may need to set the "apiBase" parameter in config.json. For example, you can set up an OpenAI-compatible server like here: https://continue.dev/docs/reference/Model%20Providers/openai#openai-compatible-servers--apis`;
} else {
message = `The request failed with "${e.cause.name}": ${e.cause.message}. If you're having trouble setting up Continue, please see the troubleshooting guide for help.`;
}
}
vscode.window
.showErrorMessage(
`Continue error: ${e.message}${
e.message.includes("fetch failed")
? ". It is possible that this error is due to certificates not being configured. See the troubleshooting page to learn more."
: ""
}`,
"Show Logs",
"Troubleshooting"
)
.showErrorMessage(message, "Show Logs", "Troubleshooting")
.then((selection) => {
if (selection === "Show Logs") {
vscode.commands.executeCommand("workbench.action.toggleDevTools");

View file

@ -342,12 +342,18 @@ async function recordAcceptReject(accepted: boolean, diffInfo: DiffInfo) {
);
}
export async function acceptDiffCommand(newFilepath?: string) {
export async function acceptDiffCommand(newFilepath?: string | vscode.Uri) {
if (newFilepath instanceof vscode.Uri) {
newFilepath = newFilepath.fsPath;
}
verticalPerLineDiffManager.clearForFilepath(newFilepath, true);
await diffManager.acceptDiff(newFilepath);
}
export async function rejectDiffCommand(newFilepath?: string) {
export async function rejectDiffCommand(newFilepath?: string | vscode.Uri) {
if (newFilepath instanceof vscode.Uri) {
newFilepath = newFilepath.fsPath;
}
verticalPerLineDiffManager.clearForFilepath(newFilepath, false);
await diffManager.rejectDiff(newFilepath);
}

View file

@ -108,14 +108,28 @@ export async function streamEdit(input: string) {
editor.selection.active
);
await diffHandler.run(
streamDiffLines(
rangeContent,
llm,
input,
getMarkdownLanguageTagForFile(filepath)
)
vscode.commands.executeCommand(
"setContext",
"continue.streamingDiff",
true
);
try {
await diffHandler.run(
streamDiffLines(
rangeContent,
llm,
input,
getMarkdownLanguageTagForFile(filepath)
)
);
} finally {
vscode.commands.executeCommand(
"setContext",
"continue.streamingDiff",
false
);
}
}
}

View file

@ -8,7 +8,6 @@ import { getUniqueId } from "./util/vscode";
let client: any = undefined;
export async function capture(args: any) {
console.log("Capturing posthog event: ", args);
if (!client) {
const { PostHog } = await import("posthog-node");
client = new PostHog("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", {

View file

@ -27,11 +27,11 @@ import {
} from "core/config/load";
import { LanceDbIndex } from "core/indexing/LanceDbIndex";
import { IndexTag } from "core/indexing/types";
import mergeJson from "core/util/merge";
import { verticalPerLineDiffManager } from "./diff/verticalPerLine/manager";
import { configHandler } from "./loadConfig";
import mergeJson from "./util/merge";
import { traverseDirectory } from "./util/traverseDirectory";
import { getExtensionUri } from "./util/vscode";
import { getExtensionUri, openEditorAndRevealRange } from "./util/vscode";
async function buildConfigTs(browser: boolean) {
if (!fs.existsSync(getConfigTsPath())) {
@ -295,6 +295,26 @@ class VsCodeIde implements IDE {
ideProtocolClient.openFile(path);
}
async showLines(
filepath: string,
startLine: number,
endLine: number
): Promise<void> {
const range = new vscode.Range(
new vscode.Position(startLine, 0),
new vscode.Position(endLine, 0)
);
openEditorAndRevealRange(filepath, range).then(() => {
ideProtocolClient.highlightCode(
{
filepath,
range,
},
"#fff1"
);
});
}
async runCommand(command: string): Promise<void> {
await ideProtocolClient.runCommand(command);
}
@ -416,6 +436,10 @@ class VsCodeIde implements IDE {
});
}
async getBranch(dir: string): Promise<string> {
return ideProtocolClient.getBranch(vscode.Uri.file(dir));
}
async getFilesToEmbed(
providerId: string
): Promise<[string, string, string][]> {

View file

@ -0,0 +1,279 @@
import { AutocompleteLruCache } from "core/autocomplete/cache";
import {
AutocompleteSnippet,
constructAutocompletePrompt,
languageForFilepath,
} from "core/autocomplete/constructPrompt";
import { DEBOUNCE_DELAY } from "core/autocomplete/parameters";
import { getTemplateForModel } from "core/autocomplete/templates";
import Handlebars from "handlebars";
import { v4 as uuidv4 } from "uuid";
import * as vscode from "vscode";
import { ideProtocolClient } from "../activation/activate";
import { TabAutocompleteModel } from "../loadConfig";
const statusBarItemText = (enabled: boolean | undefined) =>
enabled ? "$(check) Continue" : "$(circle-slash) Continue";
const statusBarItemTooltip = (enabled: boolean | undefined) =>
enabled ? "Tab autocomplete is enabled" : "Click to enable tab autocomplete";
let lastStatusBar: vscode.StatusBarItem | undefined = undefined;
export function setupStatusBar(
enabled: boolean | undefined,
loading?: boolean
) {
const statusBarItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Right
);
statusBarItem.text = loading
? "$(loading~spin) Continue"
: statusBarItemText(enabled);
statusBarItem.tooltip = statusBarItemTooltip(enabled);
statusBarItem.command = "continue.toggleTabAutocompleteEnabled";
// Swap out with old status bar
if (lastStatusBar) {
lastStatusBar.dispose();
}
statusBarItem.show();
lastStatusBar = statusBarItem;
vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration("continue")) {
const config = vscode.workspace.getConfiguration("continue");
const enabled = config.get<boolean>("enableTabAutocomplete");
statusBarItem.dispose();
setupStatusBar(enabled);
}
});
}
async function getDefinition(
filepath: string,
line: number,
character: number
): Promise<AutocompleteSnippet | undefined> {
const definitions = (await vscode.commands.executeCommand(
"vscode.executeDefinitionProvider",
vscode.Uri.file(filepath),
new vscode.Position(line, character)
)) as any;
if (definitions[0]?.targetRange) {
return {
filepath,
content: await ideProtocolClient.readRangeInFile(
definitions[0].targetUri.fsPath,
definitions[0].targetRange
),
};
}
return undefined;
}
export interface AutocompleOutcome {
accepted?: boolean;
time: number;
prompt: string;
completion: string;
modelProvider: string;
modelName: string;
completionOptions: any;
}
const autocompleteCache = AutocompleteLruCache.get();
async function getTabCompletion(
document: vscode.TextDocument,
pos: vscode.Position,
token: vscode.CancellationToken
): Promise<AutocompleOutcome | undefined> {
const startTime = Date.now();
// Filter
const lang = languageForFilepath(document.fileName);
const line = document.lineAt(pos).text;
for (const endOfLine of lang.endOfLine) {
if (line.endsWith(endOfLine) && pos.character >= endOfLine.length) {
return undefined;
}
}
try {
// Model
const llm = await TabAutocompleteModel.get();
if (!llm) return;
// Prompt
const fullPrefix = document.getText(
new vscode.Range(new vscode.Position(0, 0), pos)
);
const fullSuffix = document.getText(
new vscode.Range(
pos,
new vscode.Position(document.lineCount, Number.MAX_SAFE_INTEGER)
)
);
const clipboardText = await vscode.env.clipboard.readText();
const { prefix, suffix } = await constructAutocompletePrompt(
document.fileName,
fullPrefix,
fullSuffix,
clipboardText,
lang,
getDefinition
);
const { template, completionOptions } = getTemplateForModel(llm.model);
const compiledTemplate = Handlebars.compile(template);
const prompt = compiledTemplate({ prefix, suffix });
// Completion
let completion = "";
const cache = await autocompleteCache;
const cachedCompletion = await cache.get(prompt);
if (cachedCompletion) {
// Cache
completion = cachedCompletion;
} else {
setupStatusBar(true, true);
// LLM
for await (const update of llm.streamComplete(prompt, {
...completionOptions,
temperature: 0,
raw: true,
stop: [
...(completionOptions?.stop || []),
"\n\n",
"```",
...lang.stopWords,
],
})) {
completion += update;
if (token.isCancellationRequested) {
return undefined;
}
let foundEndLine = false;
for (const end of lang.endOfLine) {
if (completion.includes(end + "\n")) {
completion =
completion.slice(0, completion.indexOf(end + "\n")) + end;
foundEndLine = true;
break;
}
}
if (foundEndLine) {
break;
}
}
// Don't return empty
if (completion.trim().length <= 0) {
return undefined;
}
// Post-processing
completion = completion.trimEnd();
}
const time = Date.now() - startTime;
return {
time,
completion,
prompt,
modelProvider: llm.providerName,
modelName: llm.model,
completionOptions,
};
} catch (e) {
console.warn("Error generating autocompletion: ", e);
return undefined;
}
}
export class ContinueCompletionProvider
implements vscode.InlineCompletionItemProvider
{
private static debounceTimeout: NodeJS.Timeout | undefined = undefined;
private static debouncing: boolean = false;
private static lastUUID: string | undefined = undefined;
public async provideInlineCompletionItems(
document: vscode.TextDocument,
position: vscode.Position,
context: vscode.InlineCompletionContext,
token: vscode.CancellationToken
//@ts-ignore
): ProviderResult<InlineCompletionItem[] | InlineCompletionList> {
// Debounce
const uuid = uuidv4();
ContinueCompletionProvider.lastUUID = uuid;
if (ContinueCompletionProvider.debouncing) {
ContinueCompletionProvider.debounceTimeout?.refresh();
const lastUUID = await new Promise((resolve) =>
setTimeout(() => {
resolve(ContinueCompletionProvider.lastUUID);
}, DEBOUNCE_DELAY)
);
if (uuid !== lastUUID) {
return [];
}
} else {
ContinueCompletionProvider.debouncing = true;
ContinueCompletionProvider.debounceTimeout = setTimeout(async () => {
ContinueCompletionProvider.debouncing = false;
}, DEBOUNCE_DELAY);
}
const enableTabAutocomplete =
vscode.workspace
.getConfiguration("continue")
.get<boolean>("enableTabAutocomplete") || false;
if (token.isCancellationRequested || !enableTabAutocomplete) {
return [];
}
try {
const outcome = await getTabCompletion(document, position, token);
const completion = outcome?.completion;
if (!completion) {
return [];
}
// Do some stuff later so as not to block return. Latency matters
setTimeout(async () => {
(await autocompleteCache).put(outcome.prompt, completion);
}, 100);
const logRejectionTimeout = setTimeout(() => {
// Wait 10 seconds, then assume it wasn't accepted
outcome.accepted = false;
ideProtocolClient.logDevData("autocomplete", outcome);
}, 10_000);
return [
new vscode.InlineCompletionItem(
completion,
new vscode.Range(position, position.translate(0, completion.length)),
{
title: "Log Autocomplete Outcome",
command: "continue.logAutocompleteOutcome",
arguments: [outcome, logRejectionTimeout],
}
),
];
} catch (e: any) {
console.log("Error getting autocompletion: ", e.message);
} finally {
setupStatusBar(true, false);
}
}
}

View file

@ -1,10 +1,16 @@
import { ContinueConfig, IDE, ILLM } from "core";
import Ollama from "core/llm/llms/Ollama";
import * as fs from "fs";
import { Agent, fetch } from "undici";
import { Agent, ProxyAgent, fetch } from "undici";
import * as vscode from "vscode";
import { webviewRequest } from "./debugPanel";
import { VsCodeIde, loadFullConfigNode } from "./ideProtocol";
const tls = require("tls");
const outputChannel = vscode.window.createOutputChannel(
"Continue - LLM Prompt/Completion"
);
class VsCodeConfigHandler {
savedConfig: ContinueConfig | undefined;
@ -25,6 +31,85 @@ export const configHandler = new VsCodeConfigHandler();
const TIMEOUT = 7200; // 7200 seconds = 2 hours
function setupLlm(llm: ILLM): ILLM {
// Since we know this is happening in Node.js, we can add requestOptions through a custom agent
const ca = [...tls.rootCertificates];
const customCerts =
typeof llm.requestOptions?.caBundlePath === "string"
? [llm.requestOptions?.caBundlePath]
: llm.requestOptions?.caBundlePath;
if (customCerts) {
ca.push(
...customCerts.map((customCert) => fs.readFileSync(customCert, "utf8"))
);
}
let timeout = (llm.requestOptions?.timeout || TIMEOUT) * 1000; // measured in ms
const agent =
llm.requestOptions?.proxy !== undefined
? new ProxyAgent({
connect: {
ca,
rejectUnauthorized: llm.requestOptions?.verifySsl,
timeout,
},
uri: llm.requestOptions?.proxy,
bodyTimeout: timeout,
connectTimeout: timeout,
headersTimeout: timeout,
})
: new Agent({
connect: {
ca,
rejectUnauthorized: llm.requestOptions?.verifySsl,
timeout,
},
bodyTimeout: timeout,
connectTimeout: timeout,
headersTimeout: timeout,
});
llm._fetch = async (input, init) => {
const headers: { [key: string]: string } =
llm!.requestOptions?.headers || {};
for (const [key, value] of Object.entries(init?.headers || {})) {
headers[key] = value as string;
}
const resp = await fetch(input, {
...init,
dispatcher: agent,
headers,
});
if (!resp.ok) {
let text = await resp.text();
if (resp.status === 404 && !resp.url.includes("/v1")) {
text =
"This may mean that you forgot to add '/v1' to the end of your 'apiBase' in config.json.";
}
throw new Error(
`HTTP ${resp.status} ${resp.statusText} from ${resp.url}\n\n${text}`
);
}
return resp;
};
llm.writeLog = async (log: string) => {
outputChannel.appendLine(
"=========================================================================="
);
outputChannel.appendLine(
"=========================================================================="
);
outputChannel.append(log);
};
return llm;
}
export async function llmFromTitle(title?: string): Promise<ILLM> {
let config = await configHandler.loadConfig(new VsCodeIde());
@ -48,44 +133,85 @@ export async function llmFromTitle(title?: string): Promise<ILLM> {
}
}
// Since we know this is happening in Node.js, we can add requestOptions through a custom agent
const ca = [...tls.rootCertificates];
const customCerts =
typeof llm.requestOptions?.caBundlePath === "string"
? [llm.requestOptions?.caBundlePath]
: llm.requestOptions?.caBundlePath;
if (customCerts) {
ca.push(
...customCerts.map((customCert) => fs.readFileSync(customCert, "utf8"))
);
}
return setupLlm(llm);
}
let timeout = (llm.requestOptions?.timeout || TIMEOUT) * 1000; // measured in ms
export class TabAutocompleteModel {
private static _llm: ILLM | undefined;
private static defaultTag: string = "deepseek-coder:1.3b-base";
const agent = new Agent({
connect: {
ca,
rejectUnauthorized: llm.requestOptions?.verifySsl,
timeout,
},
bodyTimeout: timeout,
connectTimeout: timeout,
headersTimeout: timeout,
});
private static shownOllamaWarning: boolean = false;
private static shownDeepseekWarning: boolean = false;
llm._fetch = (input, init) => {
const headers: { [key: string]: string } =
llm!.requestOptions?.headers || {};
for (const [key, value] of Object.entries(init?.headers || {})) {
headers[key] = value as string;
static async getDefaultTabAutocompleteModel() {
const llm = new Ollama({
model: TabAutocompleteModel.defaultTag,
});
// Check that deepseek is already downloaded
try {
const models = await llm.listModels();
if (!models.includes(TabAutocompleteModel.defaultTag)) {
// Raise warning and explain how to download
if (!TabAutocompleteModel.shownDeepseekWarning) {
vscode.window
.showWarningMessage(
`Your local Ollama instance doesn't yet have DeepSeek Coder. To download this model, run \`ollama run deepseek-coder:1.3b-base\` (recommended). If you'd like to use a custom model for tab autocomplete, learn more in the docs`,
"Documentation",
"Copy Command"
)
.then((value) => {
if (value === "Documentation") {
vscode.env.openExternal(
vscode.Uri.parse(
"https://continue.dev/docs/walkthroughs/tab-autocomplete"
)
);
} else if (value === "Copy Command") {
vscode.env.clipboard.writeText(
"ollama run deepseek-coder:1.3b-base"
);
}
});
TabAutocompleteModel.shownDeepseekWarning = true;
}
return undefined;
}
} catch (e) {
if (!TabAutocompleteModel.shownOllamaWarning) {
vscode.window
.showWarningMessage(
"Continue failed to connect to Ollama, which is used by default for tab-autocomplete. If you haven't downloaded it yet, you can do so at https://ollama.ai (recommended). If you'd like to use a custom model for tab autocomplete, learn more in the docs",
"Documentation"
)
.then((value) => {
if (value === "Documentation") {
vscode.env.openExternal(
vscode.Uri.parse(
"https://continue.dev/docs/walkthroughs/tab-autocomplete"
)
);
}
});
TabAutocompleteModel.shownOllamaWarning = true;
}
return undefined;
}
return fetch(input, {
...init,
dispatcher: agent,
headers,
});
};
return llm;
}
return llm;
static async get() {
if (!TabAutocompleteModel._llm) {
const config = await configHandler.loadConfig(new VsCodeIde());
if (config.tabAutocompleteModel) {
TabAutocompleteModel._llm = setupLlm(config.tabAutocompleteModel);
} else {
TabAutocompleteModel._llm =
await TabAutocompleteModel.getDefaultTabAutocompleteModel();
}
}
return TabAutocompleteModel._llm;
}
}

View file

@ -1,4 +1,6 @@
import { FullTextSearchCodebaseIndex } from "core/indexing/FullTextSearch";
import { LanceDbIndex } from "core/indexing/LanceDbIndex";
import { ChunkCodebaseIndex } from "core/indexing/chunk/ChunkCodebaseIndex";
import { getComputeDeleteAddRemove } from "core/indexing/refreshIndex";
import { CodebaseIndex, IndexTag, LastModifiedMap } from "core/indexing/types";
import * as vscode from "vscode";
@ -23,11 +25,14 @@ const vscodeGetStats = async (
};
async function getIndexesToBuild(): Promise<CodebaseIndex[]> {
const indexes = [];
const ide = new VsCodeIde();
const config = await configHandler.loadConfig(ide);
indexes.push(new LanceDbIndex(config.embeddingsProvider, ide.readFile));
const indexes = [
new ChunkCodebaseIndex(ide.readFile), // Chunking must come first
new LanceDbIndex(config.embeddingsProvider, ide.readFile),
new FullTextSearchCodebaseIndex(),
];
return indexes;
}
@ -62,12 +67,10 @@ export async function vsCodeIndexCodebase(workspaceDirs: string[]) {
};
const [results, markComplete] = await getComputeDeleteAddRemove(
tag,
stats,
{ ...stats },
(filepath) => ideProtocolClient.readFile(filepath)
);
// console.log("RESULTS: ", results);
for await (let { progress, desc } of codebaseIndex.update(
tag,
results,

View file

@ -1,27 +0,0 @@
type JsonObject = { [key: string]: any };
function mergeJson(first: JsonObject, second: JsonObject): any {
for (var key in second) {
let secondValue = second[key];
if (!(key in first)) {
// New value
first[key] = secondValue;
}
const firstValue = first[key];
if (Array.isArray(secondValue)) {
// Array
first[key] = [...firstValue, ...secondValue];
} else if (typeof secondValue === "object") {
// Object
first[key] = mergeJson(firstValue, secondValue);
} else {
// Other (boolean, number, string)
first[key] = secondValue;
}
}
return first;
}
export default mergeJson;

File diff suppressed because it is too large Load diff

552
gui/package-lock.json generated
View file

@ -46,9 +46,11 @@
"rehype-wrap-all": "^1.1.0",
"remark-shiki-twoslash": "^3.1.3",
"seti-file-icons": "^0.0.8",
"shikiji": "^0.10.2",
"socket.io-client": "^4.7.2",
"styled-components": "^5.3.6",
"tippy.js": "^6.3.7",
"unist-util-visit": "^5.0.0",
"uuid": "^9.0.1",
"vscode-webview": "^1.0.1-beta.1"
},
@ -923,6 +925,27 @@
"node": ">=12"
}
},
"node_modules/@mapbox/hast-util-table-cell-style/node_modules/unist-util-is": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz",
"integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A=="
},
"node_modules/@mapbox/hast-util-table-cell-style/node_modules/unist-util-visit": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz",
"integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==",
"dependencies": {
"unist-util-visit-parents": "^2.0.0"
}
},
"node_modules/@mapbox/hast-util-table-cell-style/node_modules/unist-util-visit-parents": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz",
"integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==",
"dependencies": {
"unist-util-is": "^3.0.0"
}
},
"node_modules/@monaco-editor/loader": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.4.0.tgz",
@ -1104,18 +1127,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/@shikijs/rehype/node_modules/unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/@shikijs/rehype/node_modules/unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
@ -1128,33 +1139,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/@shikijs/rehype/node_modules/unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/@shikijs/rehype/node_modules/unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/@shikijs/rehype/node_modules/vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -4240,18 +4224,6 @@
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"node_modules/mdast-util-to-hast/node_modules/unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-hast/node_modules/unist-util-position": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz",
@ -4276,33 +4248,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-hast/node_modules/unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-hast/node_modules/unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-hast/node_modules/vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -4374,45 +4319,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-markdown/node_modules/unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-markdown/node_modules/unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-markdown/node_modules/unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-to-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz",
@ -5587,18 +5493,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/react-markdown/node_modules/unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/react-markdown/node_modules/unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
@ -5611,33 +5505,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/react-markdown/node_modules/unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/react-markdown/node_modules/unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/react-markdown/node_modules/vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -6010,18 +5877,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-shikiji/node_modules/unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-shikiji/node_modules/unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
@ -6034,33 +5889,6 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-shikiji/node_modules/unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-shikiji/node_modules/unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/rehype-shikiji/node_modules/vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -7000,45 +6828,6 @@
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"node_modules/unist-util-remove-position/node_modules/unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-remove-position/node_modules/unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-remove-position/node_modules/unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"dependencies": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-stringify-position": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz",
@ -7052,25 +6841,65 @@
}
},
"node_modules/unist-util-visit": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz",
"integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==",
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"dependencies": {
"unist-util-visit-parents": "^2.0.0"
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit-parents": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz",
"integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"dependencies": {
"unist-util-is": "^3.0.0"
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit-parents/node_modules/@types/unist": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"node_modules/unist-util-visit-parents/node_modules/unist-util-is": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz",
"integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A=="
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/unist-util-visit/node_modules/@types/unist": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"node_modules/unist-util-visit/node_modules/unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"dependencies": {
"@types/unist": "^3.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/universalify": {
"version": "2.0.0",
@ -7824,6 +7653,29 @@
"integrity": "sha512-LyQz4XJIdCdY/+temIhD/Ed0x/p4GAOUycpFSEK2Ads1CPKZy6b7V/2ROEtQiLLQ8soIs0xe/QAoR6kwpyW/yw==",
"requires": {
"unist-util-visit": "^1.4.1"
},
"dependencies": {
"unist-util-is": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz",
"integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A=="
},
"unist-util-visit": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz",
"integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==",
"requires": {
"unist-util-visit-parents": "^2.0.0"
}
},
"unist-util-visit-parents": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz",
"integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==",
"requires": {
"unist-util-is": "^3.0.0"
}
}
}
},
"@monaco-editor/loader": {
@ -7967,14 +7819,6 @@
"vfile": "^6.0.0"
}
},
"unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
},
"unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
@ -7983,25 +7827,6 @@
"@types/unist": "^3.0.0"
}
},
"unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
}
},
"unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
}
},
"vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -10229,14 +10054,6 @@
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
},
"unist-util-position": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz",
@ -10253,25 +10070,6 @@
"@types/unist": "^3.0.0"
}
},
"unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
}
},
"unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
}
},
"vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -10328,33 +10126,6 @@
"requires": {
"@types/mdast": "^4.0.0"
}
},
"unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
},
"unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
}
},
"unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
}
}
}
},
@ -11125,14 +10896,6 @@
"vfile": "^6.0.0"
}
},
"unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
},
"unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
@ -11141,25 +10904,6 @@
"@types/unist": "^3.0.0"
}
},
"unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
}
},
"unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
}
},
"vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -11425,14 +11169,6 @@
"vfile": "^6.0.0"
}
},
"unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
},
"unist-util-stringify-position": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
@ -11441,25 +11177,6 @@
"@types/unist": "^3.0.0"
}
},
"unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
}
},
"unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
}
},
"vfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
@ -12165,33 +11882,6 @@
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
},
"unist-util-visit": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
}
},
"unist-util-visit-parents": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"requires": {
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
}
}
}
},
@ -12204,25 +11894,51 @@
}
},
"unist-util-visit": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz",
"integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==",
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz",
"integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==",
"requires": {
"unist-util-visit-parents": "^2.0.0"
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0",
"unist-util-visit-parents": "^6.0.0"
},
"dependencies": {
"@types/unist": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"unist-util-is": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
}
}
},
"unist-util-visit-parents": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz",
"integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz",
"integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==",
"requires": {
"unist-util-is": "^3.0.0"
"@types/unist": "^3.0.0",
"unist-util-is": "^6.0.0"
},
"dependencies": {
"@types/unist": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
"integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
},
"unist-util-is": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz",
"integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A=="
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz",
"integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==",
"requires": {
"@types/unist": "^3.0.0"
}
}
}
},

View file

@ -47,9 +47,11 @@
"rehype-wrap-all": "^1.1.0",
"remark-shiki-twoslash": "^3.1.3",
"seti-file-icons": "^0.0.8",
"shikiji": "^0.10.2",
"socket.io-client": "^4.7.2",
"styled-components": "^5.3.6",
"tippy.js": "^6.3.7",
"unist-util-visit": "^5.0.0",
"uuid": "^9.0.1",
"vscode-webview": "^1.0.1-beta.1"
},

View file

@ -66,19 +66,28 @@ const router = createMemoryRouter([
},
]);
export const SubmenuContextProvidersContext = createContext<
(providerTitle: string | undefined, query: string) => ContextSubmenuItem[]
>(() => []);
export const SubmenuContextProvidersContext = createContext<{
getSubmenuContextItems: (
providerTitle: string | undefined,
query: string
) => ContextSubmenuItem[];
addItem: (providerTitle: string, item: ContextSubmenuItem) => void;
}>({
getSubmenuContextItems: () => [],
addItem: () => {},
});
function App() {
const dispatch = useDispatch();
useSetup(dispatch);
const { getSubmenuContextItems } = useSubmenuContextProviders();
const submenuContextProvidersMethods = useSubmenuContextProviders();
return (
<SubmenuContextProvidersContext.Provider value={getSubmenuContextItems}>
<SubmenuContextProvidersContext.Provider
value={submenuContextProvidersMethods}
>
<RouterProvider router={router} />
</SubmenuContextProvidersContext.Provider>
);

View file

@ -1,9 +1,10 @@
import { postToIde } from "core/ide/messaging";
import React, { useLayoutEffect } from "react";
import { usePostHog } from "posthog-js/react";
import React, { useContext, useLayoutEffect } from "react";
import { useDispatch } from "react-redux";
import styled from "styled-components";
import { Button, Input } from "..";
import useSubmenuContextProviders from "../../hooks/useSubmenuContextProviders";
import { SubmenuContextProvidersContext } from "../../App";
import { setShowDialog } from "../../redux/slices/uiStateSlice";
const GridDiv = styled.div`
@ -19,14 +20,17 @@ function AddDocsDialog() {
const [urlValid, setUrlValid] = React.useState(false);
const dispatch = useDispatch();
const { addItem } = useSubmenuContextProviders();
const { addItem } = useContext(SubmenuContextProvidersContext);
const ref = React.useRef<HTMLInputElement>(null);
const posthog = usePostHog();
useLayoutEffect(() => {
if (ref.current) {
ref.current.focus();
}
setTimeout(() => {
if (ref.current) {
ref.current.focus();
}
}, 100);
}, [ref]);
return (
@ -63,6 +67,7 @@ function AddDocsDialog() {
title: docsTitle,
description: new URL(docsUrl).hostname,
});
posthog.capture("add_docs", { url: docsUrl });
}}
>
Done

View file

@ -94,7 +94,6 @@ export function parseColorForHex(colorVar: string): string {
.map((x) => x.toString(16))
.map((x) => (x.length === 1 ? "0" + x : x))
.join("");
console.log(hex, value);
return hex;
}

View file

@ -1,5 +1,6 @@
import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline";
import { ContextItemWithId } from "core";
import { contextItemToRangeInFileWithContents } from "core/commands/util";
import { ExtensionIde } from "core/ide";
import React from "react";
import styled from "styled-components";
@ -46,9 +47,16 @@ const ContextItemsPeek = (props: ContextItemsPeekProps) => {
contextItem.description.startsWith("/") ||
contextItem.description.startsWith("\\")
) {
new ExtensionIde().openFile(
contextItem.description.split(" ").shift() || ""
);
if (contextItem.name.includes(" (") && contextItem.name.endsWith(")")) {
const rif = contextItemToRangeInFileWithContents(contextItem);
new ExtensionIde().showLines(
rif.filepath,
rif.range.start.line,
rif.range.end.line
);
} else {
new ExtensionIde().openFile(contextItem.description);
}
} else {
new ExtensionIde().showVirtualFile(contextItem.name, contextItem.content);
}

View file

@ -123,7 +123,7 @@ interface TipTapEditorProps {
function TipTapEditor(props: TipTapEditorProps) {
const dispatch = useDispatch();
const getSubmenuContextItems = useContext(SubmenuContextProvidersContext);
const { getSubmenuContextItems } = useContext(SubmenuContextProvidersContext);
const historyLength = useSelector(
(store: RootStore) => store.state.history.length

View file

@ -5,6 +5,7 @@ import {
XMarkIcon,
} from "@heroicons/react/24/outline";
import { ContextItemWithId } from "core";
import { ExtensionIde } from "core/ide";
import { getMarkdownLanguageTagForFile } from "core/util";
import React from "react";
import { useDispatch } from "react-redux";
@ -97,11 +98,11 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
.split("(")[1]
.split(")")[0]
.split("-");
postToIde("showLines", {
filepath: props.item.description,
start: parseInt(lines[0]) - 1,
end: parseInt(lines[1]) - 1,
});
new ExtensionIde().showLines(
props.item.description,
parseInt(lines[0]) - 1,
parseInt(lines[1]) - 1
);
} else {
postToIde("showVirtualFile", {
name: props.item.name,

View file

@ -1,7 +1,8 @@
import { memo, useEffect } from "react";
import React, { memo, useEffect } from "react";
import { useRemark } from "react-remark";
import rehypeShikiji from "rehype-shikiji";
import styled from "styled-components";
import { visit } from "unist-util-visit";
import {
defaultBorderRadius,
vscBackground,
@ -50,6 +51,7 @@ const StyledMarkdown = styled.div<{
border-radius: ${defaultBorderRadius};
background-color: ${vscEditorBackground};
font-size: 12px;
font-family: var(--vscode-editor-font-family);
}
code:not(pre > code) {
@ -74,7 +76,10 @@ const StyledMarkdown = styled.div<{
padding-right: 8px;
color: ${vscForeground};
p {
p,
li,
ol,
ul {
line-height: 1.5;
}
`;
@ -107,10 +112,124 @@ const FadeInWords: React.FC = (props: any) => {
return <p {...otherProps}>{words}</p>;
};
const supportedLanguages = [
"abap",
"actionscript-3",
"ada",
"apex",
"applescript",
"asm",
"awk",
"bat",
"c",
"clojure",
"cobol",
"coffee",
"cpp",
"crystal",
"csharp",
"css",
"d",
"dart",
"diff",
"dockerfile",
"elixir",
"elm",
"erlang",
// "fortran",
"fsharp",
"git-commit",
"git-rebase",
// "go",
"graphql",
"groovy",
"hack",
"haml",
"handlebars",
"haskell",
"hcl",
"hlsl",
"html",
"ini",
"java",
"javascript",
"jinja-html",
"json",
"jsonc",
"jsonnet",
"jsx",
"julia",
"kotlin",
"latex",
"less",
"lisp",
"log",
"logo",
"lua",
"makefile",
"markdown",
"matlab",
"nix",
"objective-c",
"ocaml",
"pascal",
"perl",
"perl6",
"php",
"pls",
"postcss",
"powershell",
"prolog",
"pug",
"puppet",
"purescript",
"python",
"r",
"razor",
"ruby",
"rust",
"sas",
"sass",
"scala",
"scheme",
"scss",
"shaderlab",
"shellscript",
"smalltalk",
"sql",
"stylus",
"svelte",
"swift",
"tcl",
"toml",
"ts",
"tsx",
"typescript",
"vb",
"viml",
"vue",
"wasm",
"xml",
"xsl",
"yaml",
"文言",
];
const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
props: StyledMarkdownPreviewProps
) {
const [reactContent, setMarkdownSource] = useRemark({
remarkPlugins: [
() => {
return (tree) => {
visit(tree, "code", (node: any) => {
if (!supportedLanguages.includes(node.lang)) {
node.lang = "javascript"; // Default to javascript to get some highlighting
}
});
};
},
],
rehypePlugins: [
[
rehypeShikiji as any,
@ -119,6 +238,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
(window as any).fullColorTheme ||
(window as any).colorThemeName ||
"dark-plus",
addLanguageClass: true,
},
],
// [
@ -139,7 +259,6 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
);
},
pre: ({ node, ...preProps }) => {
console.log(node, preProps);
return props.showCodeBorder ? (
<PreWithToolbar {...preProps}></PreWithToolbar>
) : (

View file

@ -5,6 +5,7 @@ import {
ChatHistory,
ChatHistoryItem,
ChatMessage,
ContinueSDK,
LLMReturnValue,
MessageContent,
SlashCommand,
@ -19,7 +20,7 @@ import { useSelector } from "react-redux";
import resolveEditorContent from "../components/mainInput/resolveInput";
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
import {
addContextItems,
addContextItemsAtIndex,
addLogs,
initNewActiveMessage,
resubmitAtIndex,
@ -120,19 +121,25 @@ function useChatHandler(dispatch: Dispatch) {
async function _streamSlashCommand(
messages: ChatMessage[],
slashCommand: SlashCommand,
input: string
input: string,
historyIndex: number
) {
let generator: AsyncGenerator<string>;
if (slashCommand.runInNodeJs) {
generator = _streamSlashCommandFromVsCode(messages, slashCommand, input);
} else {
const sdk = {
const sdk: ContinueSDK = {
input,
history: messages,
ide: new ExtensionIde(),
llm: defaultModel,
addContextItem: (item) => {
dispatch(addContextItems([item]));
dispatch(
addContextItemsAtIndex({
index: historyIndex,
contextItems: [item],
})
);
},
contextItems,
params: slashCommand.params,
@ -181,10 +188,11 @@ function useChatHandler(dispatch: Dispatch) {
};
let newHistory: ChatHistory = [...history.slice(0, index), historyItem];
const historyIndex = index || newHistory.length - 1;
dispatch(
setMessageAtIndex({
message,
index: index || newHistory.length - 1,
index: historyIndex,
contextItems,
})
);
@ -217,7 +225,12 @@ function useChatHandler(dispatch: Dispatch) {
user_input: commandInput,
},
});
await _streamSlashCommand(messages, slashCommand, commandInput);
await _streamSlashCommand(
messages,
slashCommand,
commandInput,
historyIndex
);
}
} catch (e) {
console.log("Continue: error streaming response: ", e);

View file

@ -1,6 +1,7 @@
import { Dispatch } from "@reduxjs/toolkit";
import { PersistedSessionInfo, SessionInfo } from "core";
import { ideRequest } from "core/ide/messaging";
import { llmCanGenerateInParallel } from "core/llm";
import { stripImages } from "core/llm/countTokens";
import { useSelector } from "react-redux";
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
@ -36,7 +37,11 @@ function useHistory(dispatch: Dispatch) {
stripImages(stateCopy.history[0].message.content),
50
);
if (!disableSessionTitles) {
if (
false && // Causing maxTokens to be set to 20 for main requests sometimes, so disabling until resolved
!disableSessionTitles &&
llmCanGenerateInParallel(defaultModel)
) {
let { content } = await defaultModel.chat(
[
...stateCopy.history.map((item) => item.message),

View file

@ -43,8 +43,20 @@ function useSubmenuContextProviders() {
});
}
useEffect(() => {
const handler = (e) => {
if (e.data.type !== "refreshSubmenuItems") {
return;
}
setLoaded(false);
};
window.addEventListener("message", handler);
return () => {
window.removeEventListener("message", handler);
};
}, []);
function addItem(providerTitle: string, item: ContextSubmenuItem) {
console.log("Adding item", item, providerTitle, Object.keys(minisearches));
if (!minisearches[providerTitle]) {
return;
}

View file

@ -1,7 +1,8 @@
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
import { postToIde } from "core/ide/messaging";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { lightGray, vscBackground, vscForeground } from "../components";
import { Button, lightGray, vscBackground, vscForeground } from "../components";
import KeyboardShortcutsDialog from "../components/dialogs/KeyboardShortcuts";
const IconDiv = styled.div<{ backgroundColor?: string }>`
@ -18,6 +19,18 @@ const IconDiv = styled.div<{ backgroundColor?: string }>`
}
`;
const TutorialButton = styled(Button)`
padding: 2px 4px;
margin-left: auto;
margin-right: 12px;
background-color: transparent;
color: ${vscForeground};
border: 1px solid ${lightGray};
&:hover {
background-color: ${lightGray};
}
`;
function HelpPage() {
const navigate = useNavigate();
@ -37,6 +50,13 @@ function HelpPage() {
className="inline-block ml-4 cursor-pointer"
/>
<h3 className="text-lg font-bold m-2 inline-block">Help Center</h3>
<TutorialButton
onClick={() => {
postToIde("showTutorial", {});
}}
>
Open tutorial
</TutorialButton>
</div>
<div className="grid grid-cols-2 grid-rows-2">

View file

@ -264,6 +264,21 @@ export const stateSlice = createSlice({
state.history[payload.index].message = payload.message;
state.history[payload.index].contextItems = payload.contextItems || [];
},
addContextItemsAtIndex: (
state,
{
payload,
}: {
payload: {
index: number;
contextItems: ContextItemWithId[];
};
}
) => {
if (payload.index < state.history.length) {
state.history[payload.index].contextItems.push(...payload.contextItems);
}
},
setInactive: (state) => {
return {
...state,
@ -450,6 +465,7 @@ export const stateSlice = createSlice({
export const {
setContextItemsAtIndex,
addContextItems,
addContextItemsAtIndex,
setInactive,
streamUpdate,
newSession,

View file

@ -412,11 +412,31 @@ const deepseek: ModelPackage = {
description:
"A model pre-trained on 2 trillion tokens including 80+ programming languages and a repo-level corpus.",
params: {
title: "DeepSeek",
title: "DeepSeek-7b",
model: "deepseek-7b",
contextLength: 4096,
},
providerOptions: ["lmstudio", "llamacpp"],
dimensions: [
{
name: "Parameter Count",
description: "The number of parameters in the model",
options: {
"1b": {
model: "deepseek-1b",
title: "DeepSeek-1b",
},
"7b": {
model: "deepseek-7b",
title: "DeepSeek-7b",
},
"33b": {
model: "deepseek-33b",
title: "DeepSeek-33b",
},
}
},
],
providerOptions: ["ollama", "lmstudio", "llamacpp"],
};
const codeup: ModelPackage = {
@ -451,6 +471,7 @@ const osModels = [
codeup,
zephyr,
neuralChat,
deepseek,
];
const gpt4turbo: ModelPackage = {
@ -701,9 +722,9 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = {
icon: "lmstudio.png",
tags: [ModelProviderTag["Local"], ModelProviderTag["Open-Source"]],
params: {
apiBase: "http://localhost:1234",
apiBase: "http://localhost:1234/v1",
},
packages: [...osModels, deepseek],
packages: osModels,
collectInputFor: [...completionParamsInputs],
},
replicate: {
@ -752,7 +773,7 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = {
After it's up and running, you can start using Continue.`,
icon: "llamacpp.png",
tags: [ModelProviderTag.Local, ModelProviderTag["Open-Source"]],
packages: [...osModels, deepseek],
packages: osModels,
collectInputFor: [...completionParamsInputs],
},
palm: {
@ -803,7 +824,7 @@ After it's up and running, you can start using Continue.`,
collectInputFor: [
{
...apiBaseInput,
defaultValue: "http://localhost:8000",
defaultValue: "http://localhost:8000/v1",
},
...completionParamsInputs,
],