Skip to content

Commit

Permalink
Preview (#1419)
Browse files Browse the repository at this point in the history
* 🐛 fixes after refactor

* 🚧 experimenting with perplexity style streaming

* 🐛 fix #1237

* 💚 fix type error

* ⚡️ improve LSP usage in autocomplete

* 🐛 fix content parsing regression in /edit

* add PySide6 docs to preindexed docs (#1236)

* CON-232 bring custom docs to top, alphabetize doc results, make scrol… (#1239)

* CON-232 bring custom docs to top, alphabetize doc results, make scrollable

* CON-232 cleanup

---------

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* CON-1067 condense some things

* 🚚 [Auxiliary -> Continue] Sidebar

* 🔊 log completion options in ~/.continue/sessions

* CON-1067 wrong ret val fix

* CON-1067: fixes from testing

* ⚡️ filter out completions that are only punctuation/space

* ⚡️ inject intellisense docs, no multi-line on comments

* ⚡️ crawl type definitions for autocomplete

* ⚡️ truncate function text

* ⚡️ cache LSP calls

* ⚡️ find recently edited ranges with perfect prefix match

* 🐛 fix gif paths

* ⚡️ bring back double new line stop words

* 📌 add yarn lock files

* 🐛 allow language keywords to be generated

* 💄 toggle on help button

* 🎨 defaultContext option

* 🐛 fix lancedb bug by upgrading

* 🐛 fix groq stop tokens

* 🐛 preventDefault to avoid double paste

* 🚸 don't repeatedly override cmd+J

* 🧑‍💻 fix npm run test in core

* 📝 change description

* 🐛 silence Ollama invalid server state warning

* ⚡️ more accurate getTerminalContents

* ⚡️ make getTerminalContents more accurate

* 🧑‍💻 use yarn instead of npm

* 👷 fix yarn add --no-save in prepackge

* 🐛 correctly read entire notebook file contents

* ➕ import handlebars

* 🔥 remove unnecessary migrations

* ⚡️ improve /comment prompt

* Add debug terminal context menu (#1261)

* Add --no-dependencies to vsce package (#1255)

This is not needed because we bundle first with esbuild, and
vsce pack has issues with modern package managers.

see: microsoft/vscode-vsce#421 (comment)

* ui: change line decoration color to use vscode theme (#1253)

* ui: change line decoration color to use vscode theme

to give user a more consistent experience by letting the decoration color to user the color defined in the theme.

* fix: incorrect color item

should be line background not text background
because the decoration is for the whole line

* 🎨 refactor indexing state into a single object

* CON-223 Correct diff streaming abort (#1263)

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* 📦 switch to pnpm (#1265)

* 🎨 use pnpm instead of yarn

* ➕ make dependencies explicit for pnpm

* 🐛 add powershell to extension mapping, and default to ext

* Add stream support for Bedrock Anthropic

* 🎨 make llamatokenizer commonjs compatible

* ➕ add esbuild optional deps

* 🚚 rename vendor/node_modules -> modules

* 🔖 update core version

* 🐛 fixes for transformers.js compatibility

* 🔖 update core version

* 🎨 set modelPath in constructor

* 🎨 fix transformers.js import

* 🎨 eslint enforce import extensions

* 🎨 require -> import

* 🚸 notify user if not diff in /commit

* 💄 Improve colors of the IntelliJ tool window icon (#1273)

Without this fix, the continue icon sticks out from the other toolwindow icons,
resulting in an inconsistent appearance of the whole IDE and creates a feeling
that the continue plugin "doesn't fit, something must be broken".

According to
https://plugins.jetbrains.com/docs/intellij/icons.html#new-ui-icon-colors
specific colors are needed to work nicely with dark and light modes. Bonus is
that the active tool window icon color then changes automatically to white.

Co-authored-by: Lukas Baron <LukasBaron@gmail.com>

* ✨ send Bearer token to Ollama if apiKey set

* 🐛 fix slash command bug

* 🧑‍💻 add onnxruntime (--save-dev) for types

* 🐛 don't apply to file when running code block in terminal

* 🐛 avoid double paste

* ✨ gpt-4o

* 🎨 pass uniqueId to constructor

* 🚸 focus without scrolling into vie

* 🎨 refactoring for continue-proxy LLM (#1277)

* 🐛 continue server client fixes

* 🎨 refactor OpenAI _getHeaders

* 🎨 pass ideSettings to llmFromDescription

* ⚡️ improve add docstring command

* 💚 ci updates

* 🐛 merge fixes

* 💄 increase font size in JB

* 🐛 fix repeated paste bug

* 🐛 fix build script

* 🩹 various small improvements

* 📌 pin esbuild 0.17.19

* 🧑‍💻 pnpm i gui in prepackage

* 🐛 show all diff changes in vscode

* 🩹 getMetaKeyName

* 🐛 fix reading of unopened ipynb files

* ⚡️ gpt-4o system prompt

* 💄 make font size configurable in config.json ui.fontSize

* 🩹 properly dispose of diff handler

* 🐛 fix indexing status display

* ⚡️ context pruning

* 🎨 update free trial models

* fix: remove some backup files generated by pkg if present (#1287)

* adjust toCopy (#1305)

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* Nate/prompt-file (#1308)

* ✨ .prompt files

* 🧑‍💻 back to npm  : (

* 🎨 nicer dropdown icon

* 🎨 full switch back to npm

* 🧑‍💻 uninstall script for fresh start

* 🎨 updated package-locks

* 🔥 remove hello from continuerc.json

* 🔥 remove example files

* 🎨 update test prompt

* 🎨 update prompt

* 🎨 update test prompt

* 👷 create out/node_modules in prepackage.js

* Log prompt-tokens to devdb and show in 'My Usage' view (#1309)

* Also log the number of prompt tokens to the dev-db

* Show prompt tokens in 'My Usage' view

* 🔥 remove console logs

* add lm studio tab-autocomplete walkthrough (#1298)

* 📝 update autocomplete LM Studio docs

* 💚 fix prepackage.js

* ⬆️ upgrade lancedb version

* 🚸 make it easier to continue past trial

* 🚸 improve model setup process

* 📌 update package-lock.jsons

* 🔀 merge changes

* 🩹 small fixes

* 🐛 fix jetbrains build

* 🩹 more jetbrains fixes

* 🎨 jetbrains improvements

* 🐛 fix lancedb prob in jetbrains build

* 👷 update jetbrains build process

* ✨ intellij problems context provider

* 👷 add script utils file

* 💚 fix jetbrains build regression

* 🎨 dynamic import transformers.js

* 🩹 small jetbrains updates

* ✨ folder context provider in jetbrains

* 🎨 many more jetbrains improvements

* 🐛 fix prompt file loading bug

* docs: add setup guide for OpenRouter (#1284)

* Update preIndexedDocs.ts (#1292)

Add Bootstrap and Alpine.js as pre indexed docs.

* add toString (#1324)

* add toString

* Fix indentation

---------

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* don't overwrite all models in onboarding

* 🔧 override headers with custom headers

* ✨ allow overwriting slash command description

* feature flag (#1327)

* ➕ feature flags dependency

* 🎨 make getHeaders awaitable

* 🔒️ token count for abuse monitoring

* 👷 remove win32-arm64 target

* Update build.js (#1330)

Fix error: EBUSY: resource busy or locked, rmdir '...\continue\binary\tmp\continue-node_modules-lancedb'

* 📌 pin onnxruntime version to match transformers.js

* 🎨 transformers cleanup, extensionVersion header

* 🔥 remove lingering pnpm

* 🎨 update default models

* 🎨 update defaults

* 👷 fix version in build post-check

* 🎨 test.js in dev

* 🧑‍💻 cleaning

* Add Gemini 1.5 Flash as a model (#1337)

* 🎨 log dev data for tokens generated

* Expose custom context provider registration through a vscode extension api. (#1288)

* 🔀 merge fixes

* ⚡️ small improvements

* 🎨 tell users transformers.js not supported

* 🎨 trial updates

* 📝 update jetbrains readmej

* ⚡️ Use gptEditPrompt for Mistral

* ✨ Codestral FIM

* 🔖 update gradle version

* Fix typo "Experimantal" (#1353)

* 🎨 Refactor core (#1281)

* 🎨 refactor out react context

* 🎨 refactor local storage

* 🎨 refactor IdeMessenger

* 🔥 removing unused files

* 🚚 move scripts

* ✅ setup VSCode integration testing

* 🎨 fix test-related stuff

* 🚧 testing

* 🎨 tweak terminal cmd+L

* 🧑‍💻 install biome in core

* 🎨 run biome check on core

* 🎨 run biome check in vscode

* 🎨 run biome check in binary

* 🧑‍💻 global biome config

* 🎨 run biome check on core

* 🎨 run biome check in vscode

* 🎨 fix a few biome warnings

* 🚧 WIP on protocols

* 🚧 progress, organizing, about to remove webviewCore protocol

* 🚧 now running

* 🚧 move indexing code to core

* 🚧 WIP on JetBrains indexing implementation

* 🎨 finish listDir

* 🚧 gui fixes

* 🏷️ update IMessenger.on return type

* 🐛 fix jetbrains types + IDE detection

* 🧑‍💻 set up debugging for binary with TcpMessenger

* 👷 fix prepackage.js

* 🧑‍💻 turn off debug mode for intellij

* 🐛 merge fixes

* 🐛 fixes after refactor

* 🐛 merge fixes

* 💄 increase font size in JB

* 🔀 merge changes

* 🩹 small fixes

* 🐛 fix jetbrains build

* 🩹 more jetbrains fixes

* 🎨 jetbrains improvements

* 🐛 fix lancedb prob in jetbrains build

* 👷 update jetbrains build process

* ✨ intellij problems context provider

* 👷 add script utils file

* 💚 fix jetbrains build regression

* 🎨 dynamic import transformers.js

* 🩹 small jetbrains updates

* ✨ folder context provider in jetbrains

* 🎨 many more jetbrains improvements

* 🔀 merge fixes

* ⚡️ small improvements

* 🎨 tell users transformers.js not supported

* 🎨 trial updates

* 📝 update jetbrains readmej

* ⚡️ only use smaller context for local autocomplete models

* ⚡️ improve bracket filter

* ✨ global .continue/.prompts folder

* 💄 improved model setup process

* 🥅 display VSCode req errs

* ⚡️ improved autocomplete stopping

* 🎨 count cmd+I

* 🔥 remove duplicate import

* 🔥 remove unnecessary headers

* ⚡️ limit input history length

* ⚡️ limit submenu items until you can use disk-based search, to avoid high memory use

* 🔥 remove duplicate function def

* Free Trial Auth (#1367)

* 🎨 pass gh auth token to free trial

* 💄 improved onboarding flow

* 🎨 make fewer auth reqs

* 🎨 refactor ordering of vscode deps

* 🐛 resolve confighandler

* ⚡️ autocomplete stopping improvements

* 🔥 remove unused auth code

* ⚡️ consider previous completion in bracket matching

* Build fixes: Remove duplicated code, re-add overwritten commit (#1358)

* readd overwritten commit

* Remove duplicated code

* 📝 update keywords

* ✨ /commit slash command

* 🎨 make transformers.js esm compatible

* ⚡️ fix jetbrains indexing perfomance issue

* 💄 autocomplete model onboarding

* ✨ mistral free trial autocomplete

* ✨ mistral description

* 🩹 comment out fireworks.png

* 🎨 trial fim model

* 🎨 get gh token for autocomplete model trial

* ✨ gh auth token jb

* 🔧 update config files

* 🎨 jetbrains onboarding

* 🧑‍💻 create gui/dist if it doesn't exist

* Fix sidebar indexing status timing-related bugs (#1368)

* readd overwritten commit

* Remove duplicated code

* Fix status load in and failed state update

* Late sidebar open bugs fixed

* Change ideMessenger post parameters

* debug pause

* Don't use global, fix table creation bug

* Creating new branch for config-related issues here

* cleanup

* 🚸 help user avoid login prompt if unwanted

* 🚸 update onboarding flow

* 📝 codestral as recommended in docs

* feat: Add cloudflare as provider

* 📝 set up codestral walkthrough

* codestral api base

* update codestral api link

* codestral api link

* bearer token

* 🐛 fix config loading

* cleaner error message

* fix codestral templating

* 🔥 remove unused kotlin test

* 🧑‍💻 ./gradlew build

* codestral fim template

* add additional llama.cpp params

* feat:Add promptPath configuration to use promptFolder from JSON file in load.ts (#1377)

Co-authored-by: catatapiafuentes <catalina.tapia@thoughtworks.com>

* Full project file path in context (#1407)

* Full workspace file path when using @OPEN Files

* Full project file path for @Files and 'active file' context

* FileTreeContextProvider uses splitPath from util instead of local copy

* relative-to-root file paths for rag retrieval

* ✨ jetbrains .continuerc.json support

* tweak

* ✨ allow non git tracked .prompts folder

* ✨ currentFile in prompt files

* explain the purpose of sign in

* help users remove free trial models

* better filtering of model artifacts

* improve sign in flow

---------

Co-authored-by: 5eqn <491100866@qq.com>
Co-authored-by: Pixel <54180211+pixelsortr@users.noreply.github.com>
Co-authored-by: Justin Milner <42585006+justinmilner1@users.noreply.github.com>
Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>
Co-authored-by: Devin Gould <djgould0628@gmail.com>
Co-authored-by: Dipta Mahardhika <146386738+d-mahard@users.noreply.github.com>
Co-authored-by: Ruben Kostandyan <kostard@amazon.com>
Co-authored-by: tnglemongrass <113173292+tnglemongrass@users.noreply.github.com>
Co-authored-by: Lukas Baron <LukasBaron@gmail.com>
Co-authored-by: Fernando <fernando.sanchez.jr@gmail.com>
Co-authored-by: Tijs Zwinkels <tijs@tinkertank.eu>
Co-authored-by: DJ Johnson <mr.demarcus.johnson@gmail.com>
Co-authored-by: sam <1211977+sambarnes@users.noreply.github.com>
Co-authored-by: Jose Vega <bloguea.y.gana@gmail.com>
Co-authored-by: Pratik Parmar <steveparmar6nov2011@gmail.com>
Co-authored-by: Sam El-Husseini <sam.elhusseini@gmail.com>
Co-authored-by: Peter Zaback <pzaback@gmail.com>
Co-authored-by: James Delorey <jdelorey@cloudflare.com>
Co-authored-by: catatapiafuentes <catalina.tapia@thoughtworks.com>
  • Loading branch information
20 people committed Jun 4, 2024
1 parent 0d55078 commit 2e51db0
Show file tree
Hide file tree
Showing 35 changed files with 646 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode"
],
"outFiles": [
"${workspaceFolder}/extensions/vscode/out/**/*.js",
"${workspaceFolder}/extensions/vscode/out/extension.js",
"/Users/natesesti/.continue/config.ts"
],
"preLaunchTask": "vscode-extension:build"
Expand Down
2 changes: 1 addition & 1 deletion core/autocomplete/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export async function getTabCompletion(
if (llm.model.includes("codestral")) {
// Codestral sometimes starts with an extra space
if (completion[0] === " " && completion[1] !== " ") {
if (suffix.startsWith("\n")) {
if (prefix.endsWith(" ") && suffix.startsWith("\n")) {
completion = completion.slice(1);
}
}
Expand Down
10 changes: 7 additions & 3 deletions core/autocomplete/lineStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ export async function* skipLines(stream: LineStream): LineStream {
}
}

const LINES_TO_REMOVE_BEFORE_START = [
"<COMPLETION>",
"[CODE]",
"<START EDITING HERE>",
];

function shouldRemoveLineBeforeStart(line: string): boolean {
return (
line.trimStart().startsWith("```") ||
line.trim() === "[CODE]" ||
line.trim() === "" ||
line.trim() === "<START EDITING HERE>"
LINES_TO_REMOVE_BEFORE_START.some((l) => line.trim() === l)
);
}

Expand Down
2 changes: 1 addition & 1 deletion core/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const FREE_TRIAL_MODELS: ModelDescription[] = [
];

export const defaultConfig: SerializedContinueConfig = {
models: FREE_TRIAL_MODELS,
models: [],
customCommands: [
{
name: "test",
Expand Down
19 changes: 11 additions & 8 deletions core/config/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,18 @@ async function serializedToIntermediateConfig(
}

const workspaceDirs = await ide.getWorkspaceDirs();
const promptFiles = (
await Promise.all(
workspaceDirs.map((dir) =>
getPromptFiles(ide, path.join(dir, ".prompts")),
),
const promptFolder = initial.experimental?.promptPath;

let promptFiles: { path: string; content: string }[] = [];
if (promptFolder) {
promptFiles = (
await Promise.all(
workspaceDirs.map((dir) => getPromptFiles(ide, promptFolder)),
)
)
)
.flat()
.filter(({ path }) => path.endsWith(".prompt"));
.flat()
.filter(({ path }) => path.endsWith(".prompt"));
}

// Also read from ~/.continue/.prompts
promptFiles.push(...readAllGlobalPromptFiles());
Expand Down
11 changes: 9 additions & 2 deletions core/config/promptFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getPromptFiles(
dir: string,
): Promise<{ path: string; content: string }[]> {
try {
const paths = await ide.listWorkspaceContents(dir);
const paths = await ide.listWorkspaceContents(dir, false);
const results = paths.map(async (path) => {
const content = await ide.readFile(path);
return { path, content };
Expand Down Expand Up @@ -55,10 +55,17 @@ export function slashCommandFromPromptFile(

// Render prompt template
const diff = await ide.getDiff();
const currentFilePath = await ide.getCurrentFile();
const promptUserInput = await renderTemplatedString(
prompt,
ide.readFile.bind(ide),
{ input: userInput, diff },
{
input: userInput,
diff,
currentFile: currentFilePath
? await ide.readFile(currentFilePath)
: undefined,
},
);

const messages = [...history];
Expand Down
2 changes: 1 addition & 1 deletion core/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ declare global {
stackDepth: number,
): Promise<string[]>;
getAvailableThreads(): Promise<Thread[]>;
listWorkspaceContents(directory?: string): Promise<string[]>;
listWorkspaceContents(directory?: string, useGitIgnore?: boolean): Promise<string[]>;
listFolders(): Promise<string[]>;
getWorkspaceDirs(): Promise<string[]>;
getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
Expand Down
13 changes: 7 additions & 6 deletions core/context/providers/CodeHighlightsContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
import { getBasename } from "../../util/index.js";
import { BaseContextProvider } from "../index.js";

// import { getHighlightsThatFit, ILLMContextSizer } from "llm-code-highlighter/dist/index.continue";

const HIGHLIGHTS_TOKEN_BUDGET = 2000;

class CodeHighlightsContextProvider extends BaseContextProvider {
Expand All @@ -22,6 +20,9 @@ class CodeHighlightsContextProvider extends BaseContextProvider {
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
// const { getHighlightsThatFit } = await import(
// "llm-code-highlighter/src/index.continue.js"
// );
const ide = extras.ide;
const openFiles = await ide.getOpenFiles();
const allFiles: { name: string; absPath: string; content: string }[] =
Expand All @@ -34,11 +35,11 @@ class CodeHighlightsContextProvider extends BaseContextProvider {
};
}),
);
// const contextSizer = {
// const contextSizer = {
// fits(content: string): boolean {
// return countTokens(content, "") < HIGHLIGHTS_TOKEN_BUDGET;
// }
// } as ILLMContextSizer
// },
// };
// const repoMap = await getHighlightsThatFit(
// contextSizer,
// [],
Expand All @@ -49,7 +50,7 @@ class CodeHighlightsContextProvider extends BaseContextProvider {
// relPath: file.name,
// code: file.content,
// };
// })
// }),
// );
// return [
// {
Expand Down
10 changes: 1 addition & 9 deletions core/context/providers/FileTreeContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@ import {
ContextProviderExtras,
} from "../../index.js";
import { BaseContextProvider } from "../index.js";
import { splitPath } from "../../util/index.js";

interface Directory {
name: string;
files: string[];
directories: Directory[];
}

function splitPath(path: string, withRoot?: string): string[] {
let parts = path.includes("/") ? path.split("/") : path.split("\\");
if (withRoot !== undefined) {
const rootParts = splitPath(withRoot);
parts = parts.slice(rootParts.length - 1);
}
return parts;
}

function formatFileTree(tree: Directory, indentation = ""): string {
let result = "";
for (const file of tree.files) {
Expand Down
5 changes: 3 additions & 2 deletions core/context/providers/OpenFilesContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ContextProviderDescription,
ContextProviderExtras,
} from "../../index.js";
import { getBasename } from "../../util/index.js";
import { getRelativePath } from "../../util/index.js";
import { BaseContextProvider } from "../index.js";

class OpenFilesContextProvider extends BaseContextProvider {
Expand All @@ -22,11 +22,12 @@ class OpenFilesContextProvider extends BaseContextProvider {
const openFiles = this.options?.onlyPinned
? await ide.getPinnedFiles()
: await ide.getOpenFiles();
const workspaceDirs = await extras.ide.getWorkspaceDirs();
return await Promise.all(
openFiles.map(async (filepath: string) => {
return {
description: filepath,
content: `\`\`\`${getBasename(filepath)}\n${await ide.readFile(
content: `\`\`\`${await getRelativePath(filepath, workspaceDirs)}\n${await ide.readFile(
filepath,
)}\n\`\`\``,
name: (filepath.split("/").pop() ?? "").split("\\").pop() ?? "",
Expand Down
1 change: 1 addition & 0 deletions core/context/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ContextProviderName } from "../../index.js";
import { BaseContextProvider } from "../index.js";
import CodeContextProvider from "./CodeContextProvider.js";
// import CodeHighlightsContextProvider from "./CodeHighlightsContextProvider.js";
import CodebaseContextProvider from "./CodebaseContextProvider.js";
import CurrentFileContextProvider from "./CurrentFileContextProvider.js";
import DatabaseContextProvider from "./DatabaseContextProvider.js";
Expand Down
4 changes: 2 additions & 2 deletions core/context/retrieval/retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "../../index.js";
import { LanceDbIndex } from "../../indexing/LanceDbIndex.js";

import { deduplicateArray, getBasename } from "../../util/index.js";
import { deduplicateArray, getRelativePath } from "../../util/index.js";
import { RETRIEVAL_PARAMS } from "../../util/parameters.js";
import { retrieveFts } from "./fullTextSearch.js";

Expand Down Expand Up @@ -149,7 +149,7 @@ export async function retrieveContextItemsFromEmbeddings(

return [
...results.map((r) => {
const name = `${getBasename(r.filepath)} (${r.startLine}-${r.endLine})`;
const name = `${getRelativePath(r.filepath, workspaceDirs)} (${r.startLine}-${r.endLine})`;
const description = `${r.filepath} (${r.startLine}-${r.endLine})`;
return {
name,
Expand Down
6 changes: 5 additions & 1 deletion core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,10 @@ export interface IDE {
stackDepth: number,
): Promise<string[]>;
getAvailableThreads(): Promise<Thread[]>;
listWorkspaceContents(directory?: string): Promise<string[]>;
listWorkspaceContents(
directory?: string,
useGitIgnore?: boolean,
): Promise<string[]>;
listFolders(): Promise<string[]>;
getWorkspaceDirs(): Promise<string[]>;
getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
Expand Down Expand Up @@ -751,6 +754,7 @@ interface ExperimentalConfig {
contextMenuPrompts?: ContextMenuConfig;
modelRoles?: ModelRoles;
defaultContext?: "activeFile"[];
promptPath?: string;
}

export interface SerializedContinueConfig {
Expand Down
15 changes: 12 additions & 3 deletions core/llm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ ${prompt}`;
{ ...this.requestOptions },
);

// Error mapping to be more helpful
if (!resp.ok) {
let text = await resp.text();
if (resp.status === 404 && !resp.url.includes("/v1")) {
Expand All @@ -276,6 +277,12 @@ ${prompt}`;
text =
"This may mean that you forgot to add '/v1' to the end of your 'apiBase' in config.json.";
}
} else if (
resp.status === 404 &&
resp.url.includes("api.openai.com")
) {
text =
"You may need to add pre-paid credits before using the OpenAI API.";
}
throw new Error(
`HTTP ${resp.status} ${resp.statusText} from ${resp.url}\n\n${text}`,
Expand All @@ -284,6 +291,10 @@ ${prompt}`;

return resp;
} catch (e: any) {
console.warn(
`${e.message}\n\nCode: ${e.code}\nError number: ${e.errno}\nSyscall: ${e.erroredSysCall}\nType: ${e.type}\n\n${e.stack}`,
);

if (
e.code === "ECONNREFUSED" &&
e.message.includes("http://127.0.0.1:11434")
Expand All @@ -292,9 +303,7 @@ ${prompt}`;
"Failed to connect to local Ollama instance. To start Ollama, first download it at https://ollama.ai.",
);
}
throw new Error(
`${e.message}\n\nCode: ${e.code}\nError number: ${e.errno}\nSyscall: ${e.erroredSysCall}\nType: ${e.type}\n\n${e.stack}`,
);
throw new Error(e.message);
}
};
return withExponentialBackoff<Response>(
Expand Down
3 changes: 3 additions & 0 deletions core/llm/llms/LlamaCpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class LlamaCpp extends BaseLLM {
min_p: options.minP,
mirostat: options.mirostat,
stop: options.stop,
top_k: options.topK,
top_p: options.topP,
temperature: options.temperature,
};

return finalOptions;
Expand Down
4 changes: 2 additions & 2 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion core/protocol/ide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { IdeSettings } from "./ideWebview";
export type ToIdeFromWebviewOrCoreProtocol = {
// Methods from IDE type
getIdeInfo: [undefined, IdeInfo];
listWorkspaceContents: [undefined, string[]];
listWorkspaceContents: [
{ directory?: string; useGitIgnore?: boolean },
string[],
];
getWorkspaceDirs: [undefined, string[]];
listFolders: [undefined, string[]];
writeFile: [{ path: string; contents: string }, void];
Expand Down
5 changes: 4 additions & 1 deletion core/util/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ class FileSystemIde implements IDE {
return Promise.resolve();
}

listWorkspaceContents(): Promise<string[]> {
listWorkspaceContents(
directory?: string,
useGitIgnore?: boolean,
): Promise<string[]> {
return new Promise((resolve, reject) => {
fs.readdir("/tmp/continue", (err, files) => {
if (err) {
Expand Down
24 changes: 24 additions & 0 deletions core/util/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
ContextProviderExtras,
} from "../index.js";

export function removeQuotesAndEscapes(output: string): string {
output = output.trim();

Expand Down Expand Up @@ -97,6 +101,26 @@ export function getLastNPathParts(filepath: string, n: number): string {
return filepath.split(/[\\/]/).slice(-n).join("/");
}

export function getRelativePath(filepath: string, workspaceDirs: string[]): string {
for (const workspaceDir of workspaceDirs) {
const filepathParts = splitPath(filepath);
const workspaceDirParts = splitPath(workspaceDir);
if (filepathParts.slice(0, workspaceDirParts.length).join('/') === workspaceDirParts.join('/')) {
return filepathParts.slice(workspaceDirParts.length).join('/');
}
}
return splitPath(filepath).pop() ?? ''; // If the file is not in any of the workspaces, return the plain filename
}

export function splitPath(path: string, withRoot?: string): string[] {
let parts = path.includes("/") ? path.split("/") : path.split("\\");
if (withRoot !== undefined) {
const rootParts = splitPath(withRoot);
parts = parts.slice(rootParts.length - 1);
}
return parts;
}

export function getMarkdownLanguageTagForFile(filepath: string): string {
const ext = filepath.split(".").pop();
switch (ext) {
Expand Down
10 changes: 8 additions & 2 deletions core/util/messageIde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ export class MessageIde implements IDE {
return await this.request("getTerminalContents", undefined);
}

async listWorkspaceContents(directory?: string): Promise<string[]> {
return await this.request("listWorkspaceContents", undefined);
async listWorkspaceContents(
directory?: string,
useGitIgnore?: boolean,
): Promise<string[]> {
return await this.request("listWorkspaceContents", {
directory,
useGitIgnore,
});
}

async getWorkspaceDirs(): Promise<string[]> {
Expand Down
Loading

0 comments on commit 2e51db0

Please sign in to comment.