Merge branch 'preview' into fix/jsdom-import

This commit is contained in:
German Swan 2024-03-21 12:33:21 +02:00
commit d74eb71da9
25 changed files with 175 additions and 165 deletions

View file

@ -105,6 +105,10 @@ export async function getTabCompletion(
// Model
if (llm instanceof OpenAI) {
llm.useLegacyCompletionsEndpoint = true;
} else if (llm.providerName === "free-trial") {
throw new Error(
"Free trial is not supported for tab-autocomplete. We recommend using starcoder with Ollama, LM Studio, or another provider.",
);
}
if (!llm) return;

View file

@ -16,15 +16,11 @@ export class ConfigHandler {
private savedConfig: ContinueConfig | undefined;
private savedBrowserConfig?: BrowserSerializedContinueConfig;
private readonly ide: IDE;
private ideSettingsPromise: Promise<IdeSettings>;
private readonly writeLog: (text: string) => void;
private readonly onConfigUpdate: () => void;
constructor(
ide: IDE,
ideSettingsPromise: Promise<IdeSettings>,
writeLog: (text: string) => void,
onConfigUpdate: () => void,
private readonly ide: IDE,
private ideSettingsPromise: Promise<IdeSettings>,
private readonly writeLog: (text: string) => void,
private readonly onConfigUpdate: () => void,
) {
this.ide = ide;
this.ideSettingsPromise = ideSettingsPromise;
@ -58,50 +54,45 @@ export class ConfigHandler {
}
async loadConfig(): Promise<ContinueConfig> {
try {
if (this.savedConfig) {
return this.savedConfig;
}
let workspaceConfigs: ContinueRcJson[] = [];
try {
workspaceConfigs = await this.ide.getWorkspaceConfigs();
} catch (e) {
console.warn("Failed to load workspace configs");
}
const ideInfo = await this.ide.getIdeInfo();
const ideSettings = await this.ideSettingsPromise;
let remoteConfigServerUrl = undefined;
try {
remoteConfigServerUrl =
typeof ideSettings.remoteConfigServerUrl !== "string" ||
ideSettings.remoteConfigServerUrl === ""
? undefined
: new URL(ideSettings.remoteConfigServerUrl);
} catch (e) {}
this.savedConfig = await loadFullConfigNode(
this.ide.readFile,
workspaceConfigs,
remoteConfigServerUrl,
ideInfo.ideType,
);
this.savedConfig.allowAnonymousTelemetry =
this.savedConfig.allowAnonymousTelemetry &&
(await this.ide.isTelemetryEnabled());
// Setup telemetry only after (and if) we know it is enabled
await Telemetry.setup(
this.savedConfig.allowAnonymousTelemetry ?? true,
await this.ide.getUniqueId(),
);
if (this.savedConfig) {
return this.savedConfig;
} catch (e: any) {
console.error("Failed to loadConfig: ", e.message);
throw new Error("Failed to loadConfig: " + e.message);
}
let workspaceConfigs: ContinueRcJson[] = [];
try {
workspaceConfigs = await this.ide.getWorkspaceConfigs();
} catch (e) {
console.warn("Failed to load workspace configs");
}
const ideInfo = await this.ide.getIdeInfo();
const ideSettings = await this.ideSettingsPromise;
let remoteConfigServerUrl = undefined;
try {
remoteConfigServerUrl =
typeof ideSettings.remoteConfigServerUrl !== "string" ||
ideSettings.remoteConfigServerUrl === ""
? undefined
: new URL(ideSettings.remoteConfigServerUrl);
} catch (e) {}
this.savedConfig = await loadFullConfigNode(
this.ide.readFile,
workspaceConfigs,
remoteConfigServerUrl,
ideInfo.ideType,
);
this.savedConfig.allowAnonymousTelemetry =
this.savedConfig.allowAnonymousTelemetry &&
(await this.ide.isTelemetryEnabled());
// Setup telemetry only after (and if) we know it is enabled
await Telemetry.setup(
this.savedConfig.allowAnonymousTelemetry ?? true,
await this.ide.getUniqueId(),
);
return this.savedConfig;
}
setupLlm(llm: ILLM): ILLM {

View file

@ -38,7 +38,6 @@ import {
getContinueDotEnv,
migrate,
} from "../util/paths";
import { defaultConfig } from "./default";
const { execSync } = require("child_process");
function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
@ -80,8 +79,7 @@ function loadSerializedConfig(
try {
config = resolveSerializedConfig(configPath);
} catch (e) {
console.log("config.json is invalid. Falling back to default.");
config = defaultConfig;
throw new Error(`Failed to parse config.json: ${e}`);
}
if (config.allowAnonymousTelemetry === undefined) {

View file

@ -27,7 +27,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
constructor(private readonly ide: IDE) {}
private async _createTables(db: DatabaseConnection) {
private static async _createTables(db: DatabaseConnection) {
await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets (
id INTEGER PRIMARY KEY,
path TEXT NOT NULL,
@ -98,7 +98,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
markComplete: MarkCompleteCallback,
): AsyncGenerator<IndexingProgressUpdate, any, unknown> {
const db = await SqliteDb.get();
await this._createTables(db);
await CodeSnippetsCodebaseIndex._createTables(db);
const tagString = tagToString(tag);
for (let i = 0; i < results.compute.length; i++) {
@ -193,6 +193,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
static async getAll(tag: IndexTag): Promise<ContextSubmenuItem[]> {
const db = await SqliteDb.get();
await CodeSnippetsCodebaseIndex._createTables(db);
try {
const rows = await db.all(
`SELECT cs.id, cs.path, cs.title

View file

@ -1,9 +1,9 @@
import { Readability } from "@mozilla/readability";
import { JSDOM } from "jsdom";
import { Chunk } from "../..";
import { MAX_CHUNK_SIZE } from "../../llm/constants";
import { cleanFragment, cleanHeader } from "../chunk/markdown";
import { PageData } from "./crawl";
import type jsdom from "jsdom";
export type ArticleComponent = {
title: string;
@ -104,8 +104,8 @@ function htmlToJSDOM(html: string) {
function extractTitlesAndBodies(
html: string,
): ArticleComponent[] {
const dom = htmlToJSDOM(html);
): Promise<ArticleComponent[]> {
const dom = new JSDOM(html);
const document = dom.window.document;
const titles = Array.from(document.querySelectorAll("h2"));
@ -131,7 +131,7 @@ export function stringToArticle(
subpath: string,
): Article | undefined {
try {
const dom = htmlToJSDOM(html);
const dom = new JSDOM(htmlContent);
let reader = new Readability(dom.window.document);
let article = reader.parse();
@ -139,7 +139,7 @@ export function stringToArticle(
return undefined;
}
let article_components = extractTitlesAndBodies(article.content);
let article_components = await extractTitlesAndBodies(article.content);
return {
url,
@ -153,9 +153,9 @@ export function stringToArticle(
}
}
export function pageToArticle(
page: PageData
): Article | undefined {
export async function pageToArticle(
page: PageData,
): Promise<Article | undefined> {
try {
return stringToArticle(page.url, page.html, page.path);
} catch (err) {

View file

@ -8,19 +8,20 @@ import { default as configs } from "./preIndexedDocs";
const DOCS_TABLE_NAME = "docs";
// Purposefully lowercase because lancedb converts
interface LanceDbDocsRow {
title: string;
baseUrl: string;
baseurl: string;
// Chunk
content: string;
path: string;
startLine: number;
endLine: number;
startline: number;
endline: number;
vector: number[];
[key: string]: any;
}
let dbDocs:Database;
let dbDocs: Database;
async function getDBDocs() {
if (!dbDocs) {
@ -28,7 +29,7 @@ async function getDBDocs() {
filename: getDocsSqlitePath(),
driver: sqlite3.Database,
});
dbDocs.exec(`CREATE TABLE IF NOT EXISTS docs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title STRING NOT NULL,
@ -75,10 +76,10 @@ export async function retrieveDocs(
let docs: LanceDbDocsRow[] = await table
.search(vector)
.limit(nRetrieve)
.where(`baseUrl = '${baseUrl}'`)
.where(`baseurl = '${baseUrl}'`)
.execute();
docs = docs.filter((doc) => doc.baseUrl === baseUrl);
docs = docs.filter((doc) => doc.baseurl === baseUrl);
if ((!docs || docs.length === 0) && !nested) {
const downloaded = await downloadDocs();
@ -88,8 +89,8 @@ export async function retrieveDocs(
return docs.map((doc) => ({
digest: doc.path,
filepath: doc.path,
startLine: doc.startLine,
endLine: doc.endLine,
startLine: doc.startline,
endLine: doc.endline,
index: 0,
content: doc.content,
otherMetadata: {
@ -106,11 +107,11 @@ export async function addDocs(
) {
const data: LanceDbDocsRow[] = chunks.map((chunk, i) => ({
title: chunk.otherMetadata?.title || title,
baseUrl: baseUrl.toString(),
baseurl: baseUrl.toString(),
content: chunk.content,
path: chunk.filepath,
startLine: chunk.startLine,
endLine: chunk.endLine,
startline: chunk.startLine,
endline: chunk.endLine,
vector: embeddings[i],
}));
@ -144,5 +145,5 @@ export async function listDocs(): Promise<
export async function hasDoc(baseUrl: string) {
const db = await getDBDocs();
const doc = await db.get(`SELECT title FROM docs WHERE baseUrl =?`, baseUrl);
return!!doc;
return !!doc;
}

View file

@ -147,7 +147,12 @@ async function getAddRemoveForTag(
} = {};
async function markComplete(items: PathAndCacheKey[], _: IndexResultType) {
const actions = items.map((item) => itemToAction[JSON.stringify(item)]);
const actions = items.map(
(item) =>
itemToAction[
JSON.stringify({ path: item.path, cacheKey: item.cacheKey })
],
);
for (const [{ path, cacheKey }, resultType] of actions) {
switch (resultType) {
case AddRemoveResultType.Add:

View file

@ -98,6 +98,9 @@ class FreeTrial extends BaseLLM {
"gemini-pro",
"gpt-4-vision-preview",
"codellama-70b",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
];
}
}

11
core/package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "core",
"version": "1.0.0",
"name": "@continuedev/core",
"version": "1.0.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "core",
"version": "1.0.0",
"name": "@continuedev/core",
"version": "1.0.4",
"license": "Apache-2.0",
"dependencies": {
"@mozilla/readability": "^0.5.0",
@ -56,6 +56,9 @@
"esbuild": "^0.19.11",
"jest": "^29.7.0",
"ts-jest": "^29.1.1"
},
"engines": {
"node": ">=20.11.0"
}
},
"node_modules/@75lb/deep-merge": {

View file

@ -36,8 +36,9 @@ export const supportedLanguages: { [key: string]: string } = {
cts: "typescript",
tsx: "tsx",
vue: "vue",
yaml: "yaml",
yml: "yaml",
// The .wasm file being used is faulty, and yaml is split line-by-line anyway for the most part
// yaml: "yaml",
// yml: "yaml",
elm: "elm",
js: "javascript",
jsx: "javascript",

View file

@ -326,6 +326,11 @@
resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@esbuild/darwin-arm64@0.19.12":
version "0.19.12"
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz"
integrity sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==
"@eslint-community/eslint-utils@^4.2.0":
version "4.4.0"
resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz"
@ -2662,6 +2667,11 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
fsevents@^2.3.2:
version "2.3.3"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
function-bind@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"

View file

@ -12,7 +12,7 @@ You can either
- follow along by clicking the gray CodeLens buttons above the lines, in order, starting with "Begin Section"
"""
# region —————————————————————————— Part 1: Ask a question about code [⌘ L] ——————————————————————————
# region —————————————————————————— Part 1: Ask a question about code [Cmd+L] ——————————————————————————
"""Step 1: Highlight the function below"""
@ -27,14 +27,14 @@ def mysterious_function(x):
return x
"""Step 2: Use the keyboard shortcut [⌘ L] to
"""Step 2: Use the keyboard shortcut [Cmd+L] to
select the code and toggle the Continue input box"""
"""Step 3: Ask a question and press Enter"""
# endregion
# region ————————————————————————————————— Part 2: Edit code [⌘ I] —————————————————————————————————
# region ————————————————————————————————— Part 2: Edit code [Cmd+I] —————————————————————————————————
"""Step 1: Highlight this code"""
@ -53,16 +53,16 @@ def mysterious_function(x):
return x
"""Step 2: Use the keyboard shortcut [⌘ I] to edit"""
"""Step 2: Use the keyboard shortcut [Cmd+I] to edit"""
"""Step 3: Type "<your edit request>" and press Enter"""
"""Step 4: Use keyboard shortcuts to
accept [⌘ ⇧ ⏎] or reject [⌘ ⇧ ⌫] the edit"""
accept [Cmd+Shift+Enter] or reject [Cmd+Shift+Backspace] the edit"""
# endregion
# region ———————————————————————————— Part 3: Debug automatically [⌘ ⇧ R] ————————————————————————————
# region ———————————————————————————— Part 3: Debug automatically [Cmd+Shift+R] ————————————————————————————
"""Step 1: Run this Python file (it should error!)"""
@ -72,7 +72,7 @@ def print_sum(list_to_print):
print(sum(list_to_print))
"""Step 2: Use the keyboard shortcut [⌘ ⇧ R]
"""Step 2: Use the keyboard shortcut [Cmd+Shift+R]
to automatically debug the error"""
print_sum(["a", "b", "c"])

View file

@ -6,7 +6,7 @@ const esbuildConfig = {
entryPoints: ["src/extension.ts"],
bundle: true,
outfile: "out/extension.js",
external: ["vscode", "esbuild", "jsdom"],
external: ["vscode", "esbuild"],
format: "cjs",
platform: "node",
sourcemap: true,

View file

@ -86,7 +86,7 @@
},
"../../core": {
"name": "@continuedev/core",
"version": "1.0.1",
"version": "1.0.4",
"license": "Apache-2.0",
"dependencies": {
"@mozilla/readability": "^0.5.0",
@ -123,7 +123,7 @@
"sqlite3": "^5.1.7",
"tree-sitter-wasms": "^0.1.6",
"uuid": "^9.0.1",
"vectordb": "^0.4.3",
"vectordb": "^0.4.12",
"web-tree-sitter": "^0.21.0"
},
"devDependencies": {

View file

@ -1,7 +1,7 @@
{
"name": "continue",
"icon": "media/icon.png",
"version": "0.9.88",
"version": "0.9.92",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"

View file

@ -9,8 +9,8 @@ if (!fs.existsSync("build")) {
}
const command = isPreRelease
? "vsce package --out ./build patch --pre-release --yarn"
: "vsce package --out ./build patch --yarn";
? "vsce package --out ./build patch --pre-release" // --yarn"
: "vsce package --out ./build patch"; // --yarn";
exec(command, (error) => {
if (error) throw error;

View file

@ -317,13 +317,7 @@ if (args[2] === "--target") {
});
// Copy node_modules for pre-built binaries
const NODE_MODULES_TO_COPY = [
"esbuild",
"@esbuild",
"@lancedb",
"@vscode",
"jsdom",
];
const NODE_MODULES_TO_COPY = ["esbuild", "@esbuild", "@lancedb", "@vscode"];
fs.mkdirSync("out/node_modules", { recursive: true });
await Promise.all(
@ -346,5 +340,12 @@ if (args[2] === "--target") {
}),
),
);
console.log(`[info] Copied ${NODE_MODULES_TO_COPY.join(", ")}`);
// Copy over any worker files
fs.cpSync(
"node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js",
"out/xhr-sync-worker.js",
);
})();

View file

@ -17,7 +17,7 @@ export async function showTutorial() {
// Ensure keyboard shortcuts match OS
if (process.platform !== "darwin") {
let tutorialContent = fs.readFileSync(tutorialPath, "utf8");
tutorialContent = tutorialContent.replace("⌘", "^");
tutorialContent = tutorialContent.replace("⌘", "^").replace("Cmd", "Ctrl");
fs.writeFileSync(tutorialPath, tutorialContent);
}

View file

@ -6,6 +6,7 @@ import * as vscode from "vscode";
import { ContinueCompletionProvider } from "../autocomplete/completionProvider";
import { setupStatusBar } from "../autocomplete/statusBar";
import { registerAllCommands } from "../commands";
import { registerDebugTracker } from "../debug/debug";
import { ContinueGUIWebviewViewProvider } from "../debugPanel";
import { DiffManager } from "../diff/horizontal";
import { VerticalPerLineDiffManager } from "../diff/verticalPerLine/manager";
@ -14,7 +15,6 @@ import { registerAllCodeLensProviders } from "../lang-server/codeLens";
import { setupRemoteConfigSync } from "../stubs/activation";
import { TabAutocompleteModel } from "../util/loadAutocompleteModel";
import { VsCodeWebviewProtocol } from "../webviewProtocol";
import { registerDebugTracker } from "../debug/debug";
export class VsCodeExtension {
private configHandler: ConfigHandler;
@ -48,26 +48,26 @@ export class VsCodeExtension {
// Config Handler with output channel
const outputChannel = vscode.window.createOutputChannel(
"Continue - LLM Prompt/Completion"
"Continue - LLM Prompt/Completion",
);
this.configHandler = new ConfigHandler(
this.ide,
Promise.resolve(ideSettings),
async (log: string) => {
outputChannel.appendLine(
"=========================================================================="
"==========================================================================",
);
outputChannel.appendLine(
"=========================================================================="
"==========================================================================",
);
outputChannel.append(log);
},
() => this.webviewProtocol?.request("configUpdate", undefined)
() => this.webviewProtocol?.request("configUpdate", undefined),
);
this.configHandler.reloadConfig();
this.verticalDiffManager = new VerticalPerLineDiffManager(
this.configHandler
this.configHandler,
);
this.extensionContext = context;
this.tabAutocompleteModel = new TabAutocompleteModel(this.configHandler);
@ -77,7 +77,7 @@ export class VsCodeExtension {
this.ide,
this.windowId,
this.extensionContext,
this.verticalDiffManager
this.verticalDiffManager,
);
setupRemoteConfigSync(
@ -91,14 +91,14 @@ export class VsCodeExtension {
this.sidebar,
{
webviewOptions: { retainContextWhenHidden: true },
}
)
},
),
);
this.webviewProtocol = this.sidebar.webviewProtocol;
// Indexing + pause token
const indexingPauseToken = new PauseToken(
context.globalState.get<boolean>("continue.indexingPaused") === true
context.globalState.get<boolean>("continue.indexingPaused") === true,
);
this.webviewProtocol.on("index/setPaused", (msg) => {
context.globalState.update("continue.indexingPaused", msg.data);
@ -109,14 +109,14 @@ export class VsCodeExtension {
this.indexer = new CodebaseIndexer(
this.configHandler,
this.ide,
indexingPauseToken
indexingPauseToken,
);
// CodeLens
registerAllCodeLensProviders(
context,
this.diffManager,
this.verticalDiffManager.editorToVerticalDiffCodeLens
this.verticalDiffManager.editorToVerticalDiffCodeLens,
);
// Tab autocomplete
@ -131,9 +131,9 @@ export class VsCodeExtension {
new ContinueCompletionProvider(
this.configHandler,
this.ide,
this.tabAutocompleteModel
)
)
this.tabAutocompleteModel,
),
),
);
// Commands
@ -144,7 +144,7 @@ export class VsCodeExtension {
this.sidebar,
this.configHandler,
this.diffManager,
this.verticalDiffManager
this.verticalDiffManager,
);
registerDebugTracker(this.webviewProtocol, this.ide);
@ -195,7 +195,7 @@ export class VsCodeExtension {
}
});
}
})
}),
);
// Register a content provider for the readonly virtual documents
@ -213,8 +213,8 @@ export class VsCodeExtension {
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
VsCodeExtension.continueVirtualDocumentScheme,
documentContentProvider
)
documentContentProvider,
),
);
}

View file

@ -51,6 +51,8 @@ const DEFAULT_IGNORE_FILETYPES = [
"*.onnx",
"*.parquet",
"*.pqt",
"*.wav",
"*.webp",
];
export const defaultIgnoreFile = ignore().add(DEFAULT_IGNORE_FILETYPES);
const DEFAULT_IGNORE_DIRS = [

View file

@ -83,7 +83,7 @@ export class VsCodeWebviewProtocol {
JSON.stringify({ msg }, null, 2),
);
let message = `Continue error: ${e.message}`;
let message = 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`;

View file

@ -691,11 +691,6 @@
resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz"
integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==
"@lancedb/vectordb-darwin-arm64@*":
version "0.4.13"
resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.13.tgz"
integrity sha512-JfroNCG8yKIU931Y+x8d0Fp8C9DHUSC5j+CjI+e5err7rTWtie4j3JbsXlWAnPFaFEOg0Xk3BWkSikCvhPGJGg==
"@lancedb/vectordb-darwin-arm64@0.4.12":
version "0.4.12"
resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.12.tgz"
@ -2353,7 +2348,7 @@ core-util-is@1.0.2:
integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==
"core@file:../../core":
version "1.0.1"
version "1.0.4"
resolved "file:../../core"
dependencies:
"@mozilla/readability" "^0.5.0"

4
gui/package-lock.json generated
View file

@ -74,7 +74,7 @@
},
"../core": {
"name": "@continuedev/core",
"version": "1.0.1",
"version": "1.0.4",
"license": "Apache-2.0",
"dependencies": {
"@mozilla/readability": "^0.5.0",
@ -111,7 +111,7 @@
"sqlite3": "^5.1.7",
"tree-sitter-wasms": "^0.1.6",
"uuid": "^9.0.1",
"vectordb": "^0.4.3",
"vectordb": "^0.4.12",
"web-tree-sitter": "^0.21.0"
},
"devDependencies": {

View file

@ -97,18 +97,7 @@ const initialState: State = {
contextItems: [],
active: false,
config: {
models: [
{
title: "GPT-4 (Free Trial)",
model: "gpt-4",
provider: "free-trial",
},
{
title: "GPT-3.5-Turbo (Free Trial)",
model: "gpt-3.5-turbo",
provider: "free-trial",
},
],
models: [],
slashCommands: [
{
name: "edit",
@ -140,7 +129,7 @@ export const stateSlice = createSlice({
reducers: {
setConfig: (
state,
{ payload: config }: PayloadAction<BrowserSerializedContinueConfig>
{ payload: config }: PayloadAction<BrowserSerializedContinueConfig>,
) => {
const defaultModelTitle =
config.models.find((model) => model.title === state.defaultModelTitle)
@ -168,7 +157,7 @@ export const stateSlice = createSlice({
}: PayloadAction<{
index: number;
contextItems: ChatHistoryItem["contextItems"];
}>
}>,
) => {
if (state.history[index]) {
state.history[index].contextItems = contextItems;
@ -178,7 +167,7 @@ export const stateSlice = createSlice({
state,
{
payload: { index, item },
}: PayloadAction<{ index?: number; item: ContextItemWithId }>
}: PayloadAction<{ index?: number; item: ContextItemWithId }>,
) => {
if (index === undefined) {
const isFirstContextItem =
@ -201,7 +190,7 @@ export const stateSlice = createSlice({
}: PayloadAction<{
index: number;
editorState: JSONContent;
}>
}>,
) => {
const historyItem = state.history[payload.index];
if (!historyItem) {
@ -228,7 +217,7 @@ export const stateSlice = createSlice({
payload,
}: PayloadAction<{
editorState: JSONContent;
}>
}>,
) => {
state.history.push({
message: { role: "user", content: "" },
@ -253,7 +242,7 @@ export const stateSlice = createSlice({
message: ChatMessage;
index: number;
contextItems?: ContextItemWithId[];
}>
}>,
) => {
if (payload.index >= state.history.length) {
state.history.push({
@ -281,7 +270,7 @@ export const stateSlice = createSlice({
}: PayloadAction<{
index: number;
contextItems: ContextItemWithId[];
}>
}>,
) => {
const historyItem = state.history[payload.index];
if (!historyItem) {
@ -300,7 +289,7 @@ export const stateSlice = createSlice({
},
newSession: (
state,
{ payload }: PayloadAction<PersistedSessionInfo | undefined>
{ payload }: PayloadAction<PersistedSessionInfo | undefined>,
) => {
if (payload) {
state.history = payload.history;
@ -318,14 +307,14 @@ export const stateSlice = createSlice({
state,
{
payload,
}: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>
}: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>,
) => {
const getKey = (id: ContextItemId) => `${id.providerTitle}-${id.itemId}`;
const ids = new Set(payload.ids.map(getKey));
if (payload.index === undefined) {
state.contextItems = state.contextItems.filter(
(item) => !ids.has(getKey(item.id))
(item) => !ids.has(getKey(item.id)),
);
} else {
state.history[payload.index].contextItems = state.history[
@ -337,7 +326,7 @@ export const stateSlice = createSlice({
state,
{
payload,
}: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>
}: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>,
) => {
let contextItems = [...state.contextItems].map((item) => {
return { ...item, editing: false };
@ -400,7 +389,7 @@ export const stateSlice = createSlice({
state,
{
payload,
}: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>
}: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>,
) => {
const ids = payload.ids.map((id) => id.itemId);
@ -436,7 +425,7 @@ export const stateSlice = createSlice({
},
setDefaultModel: (state, { payload }: PayloadAction<string>) => {
const model = state.config.models.find(
(model) => model.title === payload
(model) => model.title === payload,
);
if (!model) return;
return {

View file

@ -7,7 +7,7 @@ const esbuildOutputFile = "out/index.js";
const platforms = ["darwin", "linux", "win32"];
const architectures = ["x64", "arm64"];
let targets = platforms.flatMap((platform) =>
architectures.map((arch) => `${platform}-${arch}`)
architectures.map((arch) => `${platform}-${arch}`),
);
let esbuildOnly = false;
@ -57,7 +57,7 @@ const targetToLanceDb = {
} else {
resolve();
}
}
},
);
ncp(
`node_modules/${mod}`,
@ -69,10 +69,10 @@ const targetToLanceDb = {
} else {
resolve();
}
}
},
);
})
)
}),
),
);
console.log(`[info] Copied ${DYNAMIC_IMPORTS.join(", ")}`);
@ -105,6 +105,12 @@ const targetToLanceDb = {
define: { "import.meta.url": "importMetaUrl" },
});
// Copy over any worker files
fs.cpSync(
"../core/node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js",
"out/xhr-sync-worker.js",
);
if (esbuildOnly) {
return;
}
@ -114,7 +120,7 @@ const targetToLanceDb = {
const targetDir = `bin/${target}`;
console.log(`[info] Building ${target}...`);
execSync(
`npx pkg --no-bytecode --public-packages "*" --public pkgJson/${target} --out-path ${targetDir}`
`npx pkg --no-bytecode --public-packages "*" --public pkgJson/${target} --out-path ${targetDir}`,
);
// Download and unzip prebuilt sqlite3 binary for the target
@ -125,7 +131,7 @@ const targetToLanceDb = {
execSync(`cd ${targetDir} && tar -xvzf build.tar.gz`);
fs.copyFileSync(
`${targetDir}/build/Release/node_sqlite3.node`,
`${targetDir}/node_sqlite3.node`
`${targetDir}/node_sqlite3.node`,
);
fs.unlinkSync(`${targetDir}/build.tar.gz`);
fs.rmSync(`${targetDir}/build`, {
@ -136,7 +142,7 @@ const targetToLanceDb = {
// Download and unzip prebuilt esbuild binary for the target
console.log(`[info] Downloading esbuild for ${target}...`);
execSync(
`curl -o ${targetDir}/esbuild.tgz https://registry.npmjs.org/@esbuild/${target}/-/${target}-0.19.11.tgz`
`curl -o ${targetDir}/esbuild.tgz https://registry.npmjs.org/@esbuild/${target}/-/${target}-0.19.11.tgz`,
);
execSync(`tar -xzvf ${targetDir}/esbuild.tgz -C ${targetDir}`);
if (target.startsWith("win32")) {