Merge branch 'preview'

This commit is contained in:
Nate Sesti 2024-01-31 17:22:31 -08:00
commit fb3e77e3a0
64 changed files with 1264 additions and 722 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

@ -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",

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,

7
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 =

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

@ -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

@ -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

@ -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

@ -104,6 +104,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,

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

@ -1,18 +1,23 @@
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",
@ -25,17 +30,9 @@ class Together extends BaseLLM {
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 +40,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;

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

@ -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

@ -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

@ -172,7 +172,8 @@
"deepseek",
"openchat",
"xwin-coder",
"neural-chat"
"neural-chat",
"codellama-70b"
],
"type": "string"
},
@ -968,6 +969,7 @@
"problems",
"folder",
"issue",
"docs",
"tree"
],
"markdownEnumDescriptions": [
@ -982,6 +984,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"

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"
},
@ -968,6 +969,7 @@
"problems",
"folder",
"issue",
"docs",
"tree"
],
"markdownEnumDescriptions": [
@ -982,6 +984,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"

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.8.7",
"version": "0.9.40",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.8.7",
"version": "0.9.40",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",

View file

@ -1,7 +1,7 @@
{
"name": "continue",
"icon": "media/icon.png",
"version": "0.8.7",
"version": "0.9.41",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"
@ -73,90 +73,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": [
@ -209,6 +227,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",
@ -218,7 +259,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": [

View file

@ -17,24 +17,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,7 +82,7 @@ export async function activateExtension(context: vscode.ExtensionContext) {
registerAllCodeLensProviders(context);
registerAllCommands(context);
registerQuickFixProvider();
await openTutorial(context);
await openTutorialFirstTime(context);
setupInlineTips(context);
showRefactorMigrationMessage();
@ -142,6 +145,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,10 @@ export function setupInlineTips(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (editor?.document.getText() === "") {
if (editor.document.uri.toString().startsWith("output:")) {
return;
}
editor.setDecorations(emptyFileTooltipDecoration, [
{
range: new vscode.Range(
@ -83,6 +92,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

@ -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> {

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

@ -1,10 +1,15 @@
import { ContinueConfig, IDE, ILLM } from "core";
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;
@ -62,29 +67,66 @@ export async function llmFromTitle(title?: string): Promise<ILLM> {
let timeout = (llm.requestOptions?.timeout || TIMEOUT) * 1000; // measured in ms
const agent = new Agent({
connect: {
ca,
rejectUnauthorized: llm.requestOptions?.verifySsl,
timeout,
},
bodyTimeout: timeout,
connectTimeout: timeout,
headersTimeout: timeout,
});
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 = (input, init) => {
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;
}
return fetch(input, {
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;

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;

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,8 +47,11 @@ const ContextItemsPeek = (props: ContextItemsPeekProps) => {
contextItem.description.startsWith("/") ||
contextItem.description.startsWith("\\")
) {
new ExtensionIde().openFile(
contextItem.description.split(" ").shift() || ""
const rif = contextItemToRangeInFileWithContents(contextItem);
new ExtensionIde().showLines(
rif.filepath,
rif.range.start.line,
rif.range.end.line
);
} 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,