Merge branch 'main' into fix/handle-empty-addedLines

This commit is contained in:
liuk 2025-02-15 23:21:17 +08:00
commit a7b39f660a
180 changed files with 2700 additions and 1927 deletions

View file

@ -6,11 +6,11 @@ name: JetBrains Release
on:
release:
types: [ prereleased ]
types: [prereleased]
workflow_dispatch:
inputs:
publish_build:
description: 'Whether or not to publish the built extension to the JetBrains marketplace'
description: "Whether or not to publish the built extension to the JetBrains marketplace"
required: true
default: false
@ -241,6 +241,12 @@ jobs:
name: continue-binary-win32-x64
path: ./binary/bin/win32-x64/
- name: Upload artifact (win32-arm64)
uses: actions/upload-artifact@v4
with:
name: continue-binary-win32-arm64
path: ./binary/bin/win32-arm64/
- name: Upload artifact (linux-arm64)
uses: actions/upload-artifact@v4
with:
@ -345,7 +351,7 @@ jobs:
# Run tests and upload a code coverage report
test:
name: Test
needs: [ build ]
needs: [build]
runs-on: ubuntu-latest
steps:
# Check out current repository
@ -387,7 +393,7 @@ jobs:
inspectCode:
if: false
name: Inspect code
needs: [ build ]
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
@ -422,7 +428,7 @@ jobs:
verify:
if: false
name: Verify plugin
needs: [ build ]
needs: [build]
runs-on: ubuntu-latest
steps:
# Free GitHub Actions Environment Disk Space

View file

@ -208,7 +208,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
if: github.event.inputs.publish_build == 'true'
if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true'
permissions:
contents: write
steps:

View file

@ -10,6 +10,7 @@ on:
- "core/**"
- "gui/**"
- ".github/workflows/**"
- "docs/**"
push:
branches:
@ -290,6 +291,8 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_FOUNDRY_API_KEY: ${{ secrets.AZURE_FOUNDRY_API_KEY }}
vscode-get-test-file-matrix:
runs-on: ubuntu-latest

View file

@ -4,6 +4,13 @@ on:
release:
types: [prereleased]
workflow_dispatch:
inputs:
publish_build:
description: "Whether or not to publish the built extension to the VS Code marketplace"
required: true
default: false
jobs:
check_release_name:
runs-on: ubuntu-latest
@ -21,7 +28,7 @@ jobs:
build:
needs: check_release_name
if: needs.check_release_name.outputs.should_run == 'true'
if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
strategy:
matrix:
include:
@ -197,6 +204,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true'
permissions:
contents: write
steps:

View file

@ -53,7 +53,7 @@ const targetToLanceDb = {
"linux-arm64": "@lancedb/vectordb-linux-arm64-gnu",
"linux-x64": "@lancedb/vectordb-linux-x64-gnu",
"win32-x64": "@lancedb/vectordb-win32-x64-msvc",
"win32-arm64": "@lancedb/vectordb-win32-x64-msvc", // they don't have a win32-arm64 build
"win32-arm64": "@lancedb/vectordb-win32-arm64-msvc",
};
async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
@ -248,9 +248,15 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
// Download and unzip prebuilt sqlite3 binary for the target
console.log("[info] Downloading node-sqlite3");
const downloadUrl = `https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v6-${
target === "win32-arm64" ? "win32-ia32" : target
}.tar.gz`;
const downloadUrl =
// node-sqlite3 doesn't have a pre-built binary for win32-arm64
target === "win32-arm64"
? "https://continue-server-binaries.s3.us-west-1.amazonaws.com/win32-arm64/node_sqlite3.tar.gz"
: `https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v6-${
target
}.tar.gz`;
execCmdSync(`curl -L -o ${targetDir}/build.tar.gz ${downloadUrl}`);
execCmdSync(`cd ${targetDir} && tar -xvzf build.tar.gz`);

View file

@ -48,11 +48,11 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.23",
"@continuedev/config-yaml": "^1.0.28",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",
"@modelcontextprotocol/sdk": "^1.0.0",
"@modelcontextprotocol/sdk": "^1.5.0",
"@mozilla/readability": "^0.5.0",
"@octokit/rest": "^20.0.2",
"@typescript-eslint/eslint-plugin": "^7.8.0",
@ -128,7 +128,7 @@
"@types/uuid": "^9.0.7",
"@types/win-ca": "^3.5.4",
"cross-env": "^7.0.3",
"esbuild": "0.17.19",
"esbuild": "0.24.0",
"eslint": "^8",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
@ -2556,9 +2556,10 @@
}
},
"node_modules/axios": {
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
"integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
"version": "1.7.9",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
@ -3166,10 +3167,11 @@
}
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
"license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
@ -5135,12 +5137,13 @@
}
},
"node_modules/micromatch": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"license": "MIT",
"dependencies": {
"braces": "^3.0.2",
"braces": "^3.0.3",
"picomatch": "^2.3.1"
},
"engines": {

View file

@ -75,7 +75,7 @@ class IPCMessengerBase<
console.warn(`Error running handler for "${msg.messageType}": `, e);
this._onErrorHandlers.forEach((handler) => {
handler(e);
handler(msg, e);
});
}
});
@ -112,9 +112,9 @@ class IPCMessengerBase<
lines.forEach((line) => this._handleLine(line));
}
private _onErrorHandlers: ((error: Error) => void)[] = [];
private _onErrorHandlers: ((message: Message, error: Error) => void)[] = [];
onError(handler: (error: Error) => void) {
onError(handler: (message: Message, error: Error) => void) {
this._onErrorHandlers.push(handler);
}
@ -217,7 +217,7 @@ export class CoreBinaryMessenger<
extends IPCMessengerBase<ToProtocol, FromProtocol>
implements IMessenger<ToProtocol, FromProtocol>
{
private errorHandler: (error: Error) => void = () => {};
private errorHandler: (message: Message, error: Error) => void = () => {};
private messageHandlers: Map<
keyof ToProtocol,
(message: Message<any>) => Promise<any> | any

View file

@ -41,9 +41,9 @@ export class TcpMessenger<
});
}
private _onErrorHandlers: ((error: Error) => void)[] = [];
private _onErrorHandlers: ((message: Message, error: Error) => void)[] = [];
onError(handler: (error: Error) => void) {
onError(handler: (message: Message, error: Error) => void) {
this._onErrorHandlers.push(handler);
}
@ -111,7 +111,7 @@ export class TcpMessenger<
console.warn(`Error running handler for "${msg.messageType}": `, e);
this._onErrorHandlers.forEach((handler) => {
handler(e);
handler(msg, e);
});
}
});

View file

@ -90,7 +90,12 @@ const getClipboardSnippets = async (
const getDiffSnippets = async (
ide: IDE,
): Promise<AutocompleteDiffSnippet[]> => {
const diff = await ide.getDiff(true);
let diff: string[] = [];
try {
diff = await ide.getDiff(true);
} catch (e) {
console.error("Error getting diff for autocomplete", e);
}
return diff.map((item) => {
return {

View file

@ -51,6 +51,8 @@ const stableCodeFimTemplate: AutocompleteTemplate = {
};
// https://github.com/QwenLM/Qwen2.5-Coder?tab=readme-ov-file#3-file-level-code-completion-fill-in-the-middle
// This issue asks about the use of <|repo_name|> and <|file_sep|> together with <|fim_prefix|>, <|fim_suffix|> and <|fim_middle|>
// https://github.com/QwenLM/Qwen2.5-Coder/issues/343
const qwenCoderFimTemplate: AutocompleteTemplate = {
template:
"<|fim_prefix|>{{{prefix}}}<|fim_suffix|>{{{suffix}}}<|fim_middle|>",
@ -85,6 +87,11 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = {
snippets,
workspaceUris,
): [string, string] => {
function getFileName(snippet: { uri: string, uniquePath: string }) {
return snippet.uri.startsWith("file://") ? snippet.uniquePath : snippet.uri
}
if (snippets.length === 0) {
if (suffix.trim().length === 0 && prefix.trim().length === 0) {
return [
@ -111,14 +118,12 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = {
return snippet.content;
}
return `+++++ ${relativePaths[i].uri} \n${snippet.content}`;
return `+++++ ${getFileName(relativePaths[i])} \n${snippet.content}`;
})
.join("\n\n");
return [
`${otherFiles}\n\n+++++ ${
relativePaths[relativePaths.length - 1].uri
}\n${prefix}`,
`${otherFiles}\n\n+++++ ${getFileName(relativePaths[relativePaths.length - 1])}\n${prefix}`,
suffix,
];
},
@ -126,7 +131,7 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = {
return `[SUFFIX]${suffix}[PREFIX]${prefix}`;
},
completionOptions: {
stop: ["[PREFIX]", "[SUFFIX]"],
stop: ["[PREFIX]", "[SUFFIX]", "\n+++++ "],
},
};
@ -218,9 +223,8 @@ const codegeexFimTemplate: AutocompleteTemplate = {
[...snippets.map((snippet) => snippet.filepath), filepath],
workspaceUris,
);
const baseTemplate = `###PATH:${
relativePaths[relativePaths.length - 1]
}\n###LANGUAGE:${language}\n###MODE:BLOCK\n<|code_suffix|>${suffix}<|code_prefix|>${prefix}<|code_middle|>`;
const baseTemplate = `###PATH:${relativePaths[relativePaths.length - 1]
}\n###LANGUAGE:${language}\n###MODE:BLOCK\n<|code_suffix|>${suffix}<|code_prefix|>${prefix}<|code_middle|>`;
if (snippets.length === 0) {
return `<|user|>\n${baseTemplate}<|assistant|>\n`;
}

View file

@ -42,24 +42,100 @@ export const getSnippets = (
helper: HelperVars,
payload: SnippetPayload,
): AutocompleteSnippet[] => {
const snippets = [
...payload.diffSnippets,
...payload.clipboardSnippets,
...payload.recentlyVisitedRangesSnippets,
...shuffleArray(
filterSnippetsAlreadyInCaretWindow(
[...payload.rootPathSnippets, ...payload.importDefinitionSnippets],
helper.prunedCaretWindow,
),
),
];
const snippets = {
"clipboard": payload.clipboardSnippets,
"recentlyVisitedRanges": payload.recentlyVisitedRangesSnippets,
"recentlyEditedRanges": payload.recentlyEditedRangeSnippets,
"diff": payload.diffSnippets,
"base": shuffleArray(filterSnippetsAlreadyInCaretWindow(
[...payload.rootPathSnippets, ...payload.importDefinitionSnippets],
helper.prunedCaretWindow,
)),
}
// Define snippets with their priorities
const snippetConfigs: {
key: keyof typeof snippets;
enabledOrPriority: boolean | number;
defaultPriority: number;
snippets: AutocompleteSnippet[];
}[] = [
{
key: "clipboard",
enabledOrPriority: helper.options.experimental_includeClipboard,
defaultPriority: 1,
snippets: payload.clipboardSnippets,
},
{
key: "recentlyVisitedRanges",
enabledOrPriority: helper.options.experimental_includeRecentlyVisitedRanges,
defaultPriority: 2,
snippets: payload.recentlyVisitedRangesSnippets,
/* TODO: recentlyVisitedRanges also contain contents from other windows like terminal or output
if they are visible. We should handle them separately so that we can control their priority
and whether they should be included or not. */
},
{
key: "recentlyEditedRanges",
enabledOrPriority: helper.options.experimental_includeRecentlyEditedRanges,
defaultPriority: 3,
snippets: payload.recentlyEditedRangeSnippets,
},
{
key: "diff",
enabledOrPriority: helper.options.experimental_includeDiff,
defaultPriority: 4,
snippets: payload.diffSnippets,
// TODO: diff is commonly too large, thus anything lower in priority is not included.
},
{
key: "base",
enabledOrPriority: true,
defaultPriority: 99, // make sure it's the last one to be processed, but still possible to override
snippets: shuffleArray(filterSnippetsAlreadyInCaretWindow(
[...payload.rootPathSnippets, ...payload.importDefinitionSnippets],
helper.prunedCaretWindow,
)),
// TODO: Add this too to experimental config, maybe move upper in the order, since it's almost
// always not inlucded due to diff being commonly large
},
];
// Create a readable order of enabled snippets
const snippetOrder = snippetConfigs
.filter(({ enabledOrPriority }) => enabledOrPriority)
.map(({ key, enabledOrPriority, defaultPriority }) => ({
key,
priority: typeof enabledOrPriority === 'number' ? enabledOrPriority : defaultPriority,
}))
.sort((a, b) => a.priority - b.priority);
// Log the snippet order for debugging - uncomment if needed
/* console.log(
'Snippet processing order:',
snippetOrder
.map(({ key, priority }) => `${key} (priority: ${priority})`).join("\n")
); */
// Convert configs to prioritized snippets
let prioritizedSnippets = snippetOrder
.flatMap(({ key, priority }) =>
snippets[key].map(snippet => ({ snippet, priority }))
)
.sort((a, b) => a.priority - b.priority)
.map(({ snippet }) => snippet);
// Exclude Continue's own output as it makes it super-hard for users to test the autocomplete feature
// while looking at the prompts in the Continue's output
prioritizedSnippets = prioritizedSnippets.filter((snippet) =>
!(snippet as AutocompleteCodeSnippet).filepath?.startsWith("output:extension-output-Continue.continue"));
const finalSnippets = [];
let remainingTokenCount = getRemainingTokenCount(helper);
while (remainingTokenCount > 0 && snippets.length > 0) {
const snippet = snippets.shift();
while (remainingTokenCount > 0 && prioritizedSnippets.length > 0) {
const snippet = prioritizedSnippets.shift();
if (!snippet || !isValidSnippet(snippet)) {
continue;
}

View file

@ -113,6 +113,7 @@ export class AutocompleteLoggingService {
multilineCompletions: restOfOutcome.multilineCompletions,
time: restOfOutcome.time,
useRecentlyEdited: restOfOutcome.useRecentlyEdited,
numLines: restOfOutcome.numLines,
},
true,
);

View file

@ -27,7 +27,7 @@ import { localPathToUri } from "../util/pathToUri.js";
import {
LOCAL_ONBOARDING_CHAT_MODEL,
ONBOARDING_LOCAL_MODEL_TITLE,
LOCAL_ONBOARDING_PROVIDER_TITLE,
} from "./onboarding.js";
import ControlPlaneProfileLoader from "./profile/ControlPlaneProfileLoader.js";
import LocalProfileLoader from "./profile/LocalProfileLoader.js";
@ -49,6 +49,7 @@ export class ConfigHandler {
private additionalContextProviders: IContextProvider[] = [];
private profiles: ProfileLifecycleManager[];
private selectedProfileId: string;
private selectedOrgId: string | null;
constructor(
private readonly ide: IDE,
@ -69,6 +70,7 @@ export class ConfigHandler {
);
this.profiles = [new ProfileLifecycleManager(localProfileLoader, this.ide)];
this.selectedProfileId = localProfileLoader.description.id;
this.selectedOrgId = null;
// Always load local profile immediately in case control plane doesn't load
try {
@ -77,6 +79,20 @@ export class ConfigHandler {
console.error("Failed to load config: ", e);
}
void this.init();
}
private async init() {
const workspaceId = await this.getWorkspaceId();
const lastSelectedOrgIds =
this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {};
const selectedOrgId = lastSelectedOrgIds[workspaceId];
// We want to set the org ID before fetching control plane profiles
if (selectedOrgId) {
this.selectedOrgId = selectedOrgId;
}
// Load control plane profiles
void this.fetchControlPlaneProfiles();
}
@ -112,20 +128,24 @@ export class ConfigHandler {
}
} else {
const env = await getControlPlaneEnv(this.ide.getIdeSettings());
await this.ide.openUrl(`${env.APP_URL}platform/${openProfileId}`);
await this.ide.openUrl(`${env.APP_URL}${openProfileId}`);
}
}
private async loadPlatformProfiles() {
// Get the profiles and create their lifecycle managers
this.controlPlaneClient
.listAssistants()
.listAssistants(this.selectedOrgId)
.then(async (assistants) => {
const hubProfiles = await Promise.all(
assistants.map(async (assistant) => {
let renderedConfig: AssistantUnrolled | undefined = undefined;
if (assistant.configResult.config) {
renderedConfig = await clientRenderHelper(
{
ownerSlug: assistant.ownerSlug,
packageSlug: assistant.packageSlug,
},
YAML.stringify(assistant.configResult.config),
this.ide,
this.controlPlaneClient,
@ -164,6 +184,7 @@ export class ConfigHandler {
const workspaceId = await this.getWorkspaceId();
const lastSelectedWorkspaceIds =
this.globalContext.get("lastSelectedProfileForWorkspace") ?? {};
const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId];
if (selectedWorkspaceId) {
this.selectedProfileId = selectedWorkspaceId;
@ -213,7 +234,9 @@ export class ConfigHandler {
// If so, we do the full (more expensive) reload
this.platformProfilesRefreshInterval = setInterval(async () => {
const newFullSlugsList =
await this.controlPlaneClient.listAssistantFullSlugs();
await this.controlPlaneClient.listAssistantFullSlugs(
this.selectedOrgId,
);
if (newFullSlugsList) {
const shouldReload = this.fullSlugsListsDiffer(
@ -275,6 +298,14 @@ export class ConfigHandler {
}
}
async setSelectedOrgId(orgId: string | null) {
this.selectedOrgId = orgId;
const selectedOrgs =
this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {};
selectedOrgs[await this.getWorkspaceId()] = orgId;
this.globalContext.update("lastSelectedOrgIdForWorkspace", selectedOrgs);
}
async setSelectedProfile(profileId: string) {
this.selectedProfileId = profileId;
const result = await this.loadConfig();
@ -338,11 +369,11 @@ export class ConfigHandler {
this.updateListeners.push(listener);
}
async reloadConfig(additionalContextProviders: IContextProvider[] = []) {
async reloadConfig() {
// TODO: this isn't right, there are two different senses in which you want to "reload"
const { config, errors, configLoadInterrupted } =
await this.currentProfile.reloadConfig(additionalContextProviders);
await this.currentProfile.reloadConfig(this.additionalContextProviders);
if (config) {
this.inactiveProfiles.forEach((profile) => profile.clearConfig());
@ -374,7 +405,7 @@ export class ConfigHandler {
const { config } = await this.loadConfig();
const model = config?.models.find((m) => m.title === title);
if (!model) {
if (title === ONBOARDING_LOCAL_MODEL_TITLE) {
if (title === LOCAL_ONBOARDING_PROVIDER_TITLE) {
// Special case, make calls to Ollama before we have it in the config
const ollama = new Ollama({
model: LOCAL_ONBOARDING_CHAT_MODEL,
@ -392,6 +423,6 @@ export class ConfigHandler {
registerCustomContextProvider(contextProvider: IContextProvider) {
this.additionalContextProviders.push(contextProvider);
void this.reloadConfig(this.additionalContextProviders);
void this.reloadConfig();
}
}

View file

@ -27,6 +27,7 @@ export interface OrganizationDescription {
id: string;
iconUrl: string;
name: string;
slug: string | undefined; // TODO: This doesn't need to be undefined, just doing while transitioning the backend
}
export class ProfileLifecycleManager {
@ -50,7 +51,9 @@ export class ProfileLifecycleManager {
}
// Clear saved config and reload
async reloadConfig(additionalContextProviders: IContextProvider[] = []): Promise<ConfigResult<ContinueConfig>> {
async reloadConfig(
additionalContextProviders: IContextProvider[] = [],
): Promise<ConfigResult<ContinueConfig>> {
this.savedConfigResult = undefined;
this.savedBrowserConfigResult = undefined;
this.pendingConfigPromise = undefined;
@ -73,7 +76,21 @@ export class ProfileLifecycleManager {
// Set pending config promise
this.pendingConfigPromise = new Promise(async (resolve, reject) => {
const result = await this.profileLoader.doLoadConfig();
let result: ConfigResult<ContinueConfig>;
try {
result = await this.profileLoader.doLoadConfig();
} catch (e: any) {
result = {
errors: [
{
fatal: true,
message: e.message,
},
],
config: undefined,
configLoadInterrupted: true,
};
}
if (result.config) {
// Add registered context providers

View file

@ -5,20 +5,6 @@ import {
SlashCommandDescription,
} from "../";
export const DEFAULT_CHAT_MODEL_CONFIG: ModelDescription = {
model: "claude-3-5-sonnet-latest",
provider: "anthropic",
apiKey: "",
title: "Claude 3.5 Sonnet",
};
export const DEFAULT_AUTOCOMPLETE_MODEL_CONFIG: ModelDescription = {
title: "Codestral",
provider: "mistral",
model: "codestral-latest",
apiKey: "",
};
export const FREE_TRIAL_MODELS: ModelDescription[] = [
{
title: "Claude 3.5 Sonnet (Free Trial)",
@ -93,15 +79,13 @@ export const defaultSlashCommandsJetBrains = [
];
export const defaultConfig: SerializedContinueConfig = {
models: [DEFAULT_CHAT_MODEL_CONFIG],
tabAutocompleteModel: DEFAULT_AUTOCOMPLETE_MODEL_CONFIG,
models: [],
contextProviders: defaultContextProvidersVsCode,
slashCommands: defaultSlashCommandsVscode,
};
export const defaultConfigJetBrains: SerializedContinueConfig = {
models: [DEFAULT_CHAT_MODEL_CONFIG],
tabAutocompleteModel: DEFAULT_AUTOCOMPLETE_MODEL_CONFIG,
models: [],
contextProviders: defaultContextProvidersJetBrains,
slashCommands: defaultSlashCommandsJetBrains,
};

View file

@ -63,6 +63,8 @@ import {
} from "../util/paths";
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
import { useHub } from "../control-plane/env";
import { localPathToUri } from "../util/pathToUri";
import {
defaultContextProvidersJetBrains,
defaultContextProvidersVsCode,
@ -70,8 +72,6 @@ import {
defaultSlashCommandsVscode,
} from "./default";
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
import { useHub } from "../control-plane/env";
import { localPathToUri } from "../util/pathToUri";
import { modifyContinueConfigWithSharedConfig } from "./sharedConfig";
import { validateConfig } from "./validation.js";
@ -326,6 +326,7 @@ async function intermediateToFinalConfig(
...model.requestOptions,
...config.requestOptions,
};
model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified
}
if (allowFreeTrial) {
@ -517,6 +518,8 @@ async function intermediateToFinalConfig(
continueConfig,
mcpId,
abortController.signal,
"MCP Server",
server.faviconUrl,
);
if (mcpError) {
errors.push(mcpError);
@ -557,6 +560,7 @@ async function finalToBrowserConfig(
requestOptions: m.requestOptions,
promptTemplates: m.promptTemplates as any,
capabilities: m.capabilities,
roles: m.roles,
})),
systemMessage: final.systemMessage,
completionOptions: final.completionOptions,

View file

@ -1,13 +1,9 @@
import * as fs from "fs";
import * as JSONC from "comment-json";
import { IDE, SerializedContinueConfig } from "..";
import { SharedConfigSchema } from "./sharedConfig";
import { IDE } from "..";
import { deduplicateArray } from "../util";
import { GlobalContext } from "../util/GlobalContext";
import { editConfigJson } from "../util/paths";
import { resolveSerializedConfig } from "./load";
import { deduplicateArray } from "../util";
import { SharedConfigSchema } from "./sharedConfig";
/*
This migration function eliminates deprecated values from the json file
@ -201,10 +197,10 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void {
if (effected) {
new GlobalContext().updateSharedConfig(shareConfigUpdates);
editConfigJson(() => config);
void ide.showToast(
"warning",
"Migrated deprecated Continue JSON settings. Edit in the Settings Page",
);
// void ide.showToast(
// "warning",
// "Migrated deprecated Continue JSON settings. Edit in the Settings Page",
// );
}
} catch (e) {
throw new Error(`Migration: Failed to parse config.json: ${e}`);

View file

@ -3,10 +3,12 @@ import { SerializedContinueConfig } from "../";
import { FREE_TRIAL_MODELS } from "./default";
export const TRIAL_FIM_MODEL = "codestral-latest";
export const ONBOARDING_LOCAL_MODEL_TITLE = "Ollama";
export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama";
export const LOCAL_ONBOARDING_FIM_MODEL = "qwen2.5-coder:1.5b-base";
export const LOCAL_ONBOARDING_FIM_TITLE = "Qwen2.5-Coder 1.5B";
export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest";
/**
* We set the "best" chat + autocopmlete models by default
@ -35,13 +37,13 @@ export function setupLocalConfig(
...config.models.filter((model) => model.provider !== "free-trial"),
],
tabAutocompleteModel: {
title: "Qwen2.5-Coder 1.5B",
title: LOCAL_ONBOARDING_FIM_TITLE,
provider: "ollama",
model: LOCAL_ONBOARDING_FIM_MODEL,
},
embeddingsProvider: {
provider: "ollama",
model: "nomic-embed-text",
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
},
};
}
@ -68,24 +70,3 @@ export function setupQuickstartConfig(
},
};
}
export function setupLocalConfigAfterFreeTrial(
config: SerializedContinueConfig,
): SerializedContinueConfig {
return {
...config,
models: [
{
title: LOCAL_ONBOARDING_CHAT_TITLE,
provider: "ollama",
model: LOCAL_ONBOARDING_CHAT_MODEL,
},
{
title: ONBOARDING_LOCAL_MODEL_TITLE,
provider: "ollama",
model: "AUTODETECT",
},
...config.models.filter((model) => model.provider !== "free-trial"),
],
};
}

View file

@ -1,5 +1,4 @@
import { ConfigResult } from "@continuedev/config-yaml";
import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas/index.js";
import { ConfigResult, AssistantUnrolled } from "@continuedev/config-yaml";
import { ControlPlaneClient } from "../../control-plane/client.js";
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";

View file

@ -21,9 +21,9 @@ import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths";
import { Telemetry } from "../../util/posthog";
import { TTS } from "../../util/tts";
import { loadContinueConfigFromJson } from "../load";
import { migrateJsonSharedConfig } from "../migrateSharedConfig";
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
import { migrateJsonSharedConfig } from "../migrateSharedConfig";
export default async function doLoadConfig(
ide: IDE,

View file

@ -956,7 +956,7 @@ declare global {
fixGrammar?: string;
}
interface ModelRoles {
interface ExperimentalModelRoles {
inlineEdit?: string;
applyCodeBlock?: string;
repoMapFileSelection?: string;
@ -1024,7 +1024,7 @@ declare global {
interface ExperimentalConfig {
contextMenuPrompts?: ContextMenuConfig;
modelRoles?: ModelRoles;
modelRoles?: ExperimentalModelRoles;
defaultContext?: DefaultContextProvider[];
promptPath?: string;

View file

@ -7,7 +7,7 @@ import {
IDE,
ILLM,
ModelDescription,
ModelRoles,
ExperimentalModelRoles,
} from "../";
import { GlobalContext } from "../util/GlobalContext";
import { editConfigJson } from "../util/paths";
@ -34,7 +34,10 @@ export function addContextProvider(provider: ContextProviderWithParams) {
});
}
export function addModel(model: ModelDescription, role?: keyof ModelRoles) {
export function addModel(
model: ModelDescription,
role?: keyof ExperimentalModelRoles,
) {
editConfigJson((config) => {
if (config.models?.some((m: any) => stringify(m) === stringify(model))) {
return config;
@ -85,7 +88,7 @@ export function deleteModel(title: string) {
});
}
export function getModelByRole<T extends keyof ModelRoles>(
export function getModelByRole<T extends keyof ExperimentalModelRoles>(
config: ContinueConfig,
role: T,
): ILLM | undefined {

View file

@ -1,5 +1,6 @@
import {
clientRender,
PackageSlug,
PlatformClient,
SecretStore,
} from "@continuedev/config-yaml";
@ -8,6 +9,7 @@ import { IDE } from "../..";
import { ControlPlaneClient } from "../../control-plane/client";
export async function clientRenderHelper(
packageSlug: PackageSlug,
unrolledAssistant: string,
ide: IDE,
controlPlaneClient: ControlPlaneClient,
@ -33,6 +35,7 @@ export async function clientRenderHelper(
const userId = await controlPlaneClient.userId;
return await clientRender(
packageSlug,
unrolledAssistant,
ideSecretStore,
userId ? platformClient : undefined,

View file

@ -1,5 +1,4 @@
import { ModelConfig } from "@continuedev/config-yaml";
import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas";
import { ModelConfig, AssistantUnrolled } from "@continuedev/config-yaml";
import { SerializedContinueConfig } from "../..";

View file

@ -1,4 +1,4 @@
import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas";
import { AssistantUnrolled } from "@continuedev/config-yaml";
// TODO
export const defaultConfigYaml: AssistantUnrolled = {

View file

@ -3,12 +3,14 @@ import fs from "node:fs";
import {
AssistantUnrolled,
ConfigResult,
ConfigValidationError,
ModelRole,
parseAssistantUnrolled,
validateConfigYaml,
} from "@continuedev/config-yaml";
import { fetchwithRequestOptions } from "@continuedev/fetch";
import {
BrowserSerializedContinueConfig,
ContinueConfig,
IContextProvider,
IDE,
@ -16,9 +18,11 @@ import {
IdeType,
SlashCommand,
} from "../..";
import { slashFromCustomCommand } from "../../commands";
import { AllRerankers } from "../../context/allRerankers";
import { MCPManagerSingleton } from "../../context/mcp";
import CodebaseContextProvider from "../../context/providers/CodebaseContextProvider";
import DocsContextProvider from "../../context/providers/DocsContextProvider";
import FileContextProvider from "../../context/providers/FileContextProvider";
import { contextProviderClassFromName } from "../../context/providers/index";
import PromptFilesContextProvider from "../../context/providers/PromptFilesContextProvider";
@ -28,17 +32,15 @@ import FreeTrial from "../../llm/llms/FreeTrial";
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile";
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
import { allTools } from "../../tools";
import { GlobalContext } from "../../util/GlobalContext";
import { getConfigYamlPath } from "../../util/paths";
import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
import { slashFromCustomCommand } from "../../commands";
import { allTools } from "../../tools";
import { clientRenderHelper } from "./clientRender";
import { llmsFromModelConfig } from "./models";
import { GlobalContext } from "../../util/GlobalContext";
import { modifyContinueConfigWithSharedConfig } from "../sharedConfig";
import { llmsFromModelConfig } from "./models";
async function loadConfigYaml(
workspaceConfigs: string[],
rawYaml: string,
@ -46,9 +48,14 @@ async function loadConfigYaml(
ide: IDE,
controlPlaneClient: ControlPlaneClient,
): Promise<ConfigResult<AssistantUnrolled>> {
const ideSettings = await ide.getIdeSettings();
let config =
overrideConfigYaml ??
(await clientRenderHelper(rawYaml, ide, controlPlaneClient));
// (ideSettings.continueTestEnvironment === "production"
// ? await clientRenderHelper(rawYaml, ide, controlPlaneClient)
// :
parseAssistantUnrolled(rawYaml);
// );
const errors = validateConfigYaml(config);
if (errors?.some((error) => error.fatal)) {
@ -96,7 +103,8 @@ async function configYamlToContinueConfig(
workOsAccessToken: string | undefined,
platformConfigMetadata: PlatformConfigMetadata | undefined,
allowFreeTrial: boolean = true,
): Promise<ContinueConfig> {
): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> {
const errors: ConfigValidationError[] = [];
const continueConfig: ContinueConfig = {
slashCommands: [
...(await slashCommandsFromV1PromptFiles(ide)),
@ -127,12 +135,10 @@ async function configYamlToContinueConfig(
};
// Models
const modelsArrayRoles: ModelRole[] = ["chat", "summarize", "apply", "edit"];
for (const model of config.models ?? []) {
if (
["chat", "summarize", "apply", "edit"].some((role: any) =>
model.roles?.includes(role),
)
) {
model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified
if (modelsArrayRoles.some((role) => model.roles?.includes(role))) {
// Main model array
const llms = await llmsFromModelConfig(
model,
@ -159,6 +165,24 @@ async function configYamlToContinueConfig(
);
continueConfig.tabAutocompleteModels?.push(...llms);
}
if (
model.roles?.includes("apply") &&
!continueConfig.experimental?.modelRoles?.applyCodeBlock
) {
continueConfig.experimental ??= {};
continueConfig.experimental!.modelRoles ??= {};
continueConfig.experimental!.modelRoles!.applyCodeBlock = model.name;
}
if (
model.roles?.includes("edit") &&
!continueConfig.experimental?.modelRoles?.inlineEdit
) {
continueConfig.experimental ??= {};
continueConfig.experimental!.modelRoles ??= {};
continueConfig.experimental!.modelRoles!.inlineEdit = model.name;
}
}
if (allowFreeTrial) {
@ -210,7 +234,17 @@ async function configYamlToContinueConfig(
.filter((p) => !!p) ?? []) as IContextProvider[];
continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS);
if (
continueConfig.docs?.length &&
!continueConfig.contextProviders?.some(
(cp) => cp.description.title === "docs",
)
) {
continueConfig.contextProviders.push(new DocsContextProvider({}));
}
// Embeddings Provider
// IMPORTANT this currently will grab the first model found with an embed role
const embedConfig = config.models?.find((model) =>
model.roles?.includes("embed"),
);
@ -235,6 +269,7 @@ async function configYamlToContinueConfig(
}
// Reranker
// IMPORTANT this currently will grab the first model found with a rerank role
const rerankConfig = config.models?.find((model) =>
model.roles?.includes("rerank"),
);
@ -255,40 +290,51 @@ async function configYamlToContinueConfig(
// Apply MCP if specified
const mcpManager = MCPManagerSingleton.getInstance();
config.mcpServers?.forEach(async (server) => {
const mcpId = server.name;
const mcpConnection = mcpManager.createConnection(mcpId, {
transport: {
type: "stdio",
args: [],
...server,
},
});
if (!mcpConnection) {
return;
}
const abortController = new AbortController();
const mcpConnectionTimeout = setTimeout(
() => abortController.abort(),
2000,
);
try {
await mcpConnection.modifyConfig(
continueConfig,
mcpId,
abortController.signal,
);
} catch (e: any) {
if (e.name !== "AbortError") {
throw e;
await Promise.all(
config.mcpServers?.map(async (server) => {
const mcpId = server.name;
const mcpConnection = mcpManager.createConnection(mcpId, {
transport: {
type: "stdio",
args: [],
...server,
},
});
if (!mcpConnection) {
return;
}
}
clearTimeout(mcpConnectionTimeout);
});
return continueConfig;
const abortController = new AbortController();
const mcpConnectionTimeout = setTimeout(
() => abortController.abort(),
5000,
);
try {
const mcpError = await mcpConnection.modifyConfig(
continueConfig,
mcpId,
abortController.signal,
server.name,
server.faviconUrl,
);
if (mcpError) {
errors.push(mcpError);
}
} catch (e: any) {
errors.push({
fatal: false,
message: `Failed to load MCP server: ${e.message}`,
});
if (e.name !== "AbortError") {
throw e;
}
}
clearTimeout(mcpConnectionTimeout);
}) ?? [],
);
return { config: continueConfig, errors };
}
export async function loadContinueConfigFromYaml(
@ -324,7 +370,7 @@ export async function loadContinueConfigFromYaml(
};
}
const continueConfig = await configYamlToContinueConfig(
const { config: continueConfig, errors } = await configYamlToContinueConfig(
configYamlResult.config,
ide,
ideSettings,
@ -353,9 +399,7 @@ export async function loadContinueConfigFromYaml(
return {
config: withShared,
errors: configYamlResult.errors,
errors: [...(configYamlResult.errors ?? []), ...errors],
configLoadInterrupted: false,
};
}
export { type BrowserSerializedContinueConfig };

View file

@ -35,15 +35,6 @@ async function modelConfigToBaseLLM(
return undefined;
}
const usingContinueProxy = model.provider === "continue-proxy";
const modelName = usingContinueProxy
? getContinueProxyModelName(
platformConfigMetadata!.ownerSlug,
platformConfigMetadata!.packageSlug,
model,
)
: model.model;
let options: LLMOptions = {
...model,
completionOptions: {
@ -56,8 +47,8 @@ async function modelConfigToBaseLLM(
writeLog,
uniqueId,
title: model.name,
model: modelName,
systemMessage,
promptTemplates: model.promptTemplates,
};
const llm = new cls(options);

View file

@ -69,10 +69,14 @@ class MCPConnection {
private constructTransport(options: MCPOptions): Transport {
switch (options.transport.type) {
case "stdio":
const env: Record<string, string> = options.transport.env || {};
if (process.env.PATH !== undefined) {
env.PATH = process.env.PATH;
}
return new StdioClientTransport({
command: options.transport.command,
args: options.transport.args,
env: options.transport.env,
env,
});
case "websocket":
return new WebSocketClientTransport(new URL(options.transport.url));
@ -117,6 +121,8 @@ class MCPConnection {
config: ContinueConfig,
mcpId: string,
signal: AbortSignal,
name: string,
faviconUrl: string | undefined,
): Promise<ConfigValidationError | undefined> {
try {
await Promise.race([
@ -148,6 +154,7 @@ class MCPConnection {
title: resource.name,
description: resource.description,
id: resource.uri,
icon: faviconUrl,
}));
if (!config.contextProviders) {
@ -165,19 +172,20 @@ class MCPConnection {
if (capabilities?.tools) {
const { tools } = await this.client.listTools({}, { signal });
const continueTools: Tool[] = tools.map((tool: any) => ({
displayTitle: tool.name,
displayTitle: name + " " + tool.name,
function: {
description: tool.description,
name: tool.name,
parameters: tool.inputSchema,
},
faviconUrl,
readonly: false,
type: "function",
wouldLikeTo: `use the ${tool.name} tool`,
wouldLikeTo: `use the ${name} ${tool.name} tool`,
uri: encodeMCPToolUri(mcpId, tool.name),
}));
config.tools = [...config.tools, ...continueTools];
config.tools = [...continueTools, ...config.tools];
}
// Prompts <—> Slash commands

View file

@ -24,8 +24,12 @@ class CodeContextProvider extends BaseContextProvider {
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
// Assume the query is the id as returned by loadSubmenuItems
const workspaceDirs = await extras.ide.getWorkspaceDirs();
return [
await CodeSnippetsCodebaseIndex.getForId(Number.parseInt(query, 10)),
await CodeSnippetsCodebaseIndex.getForId(
Number.parseInt(query, 10),
workspaceDirs,
),
];
}

View file

@ -4,7 +4,7 @@ import {
ContextProviderDescription,
ContextProviderExtras,
} from "../../";
import { getUriPathBasename } from "../../util/uri";
import { getUriDescription } from "../../util/uri";
class CurrentFileContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
@ -23,12 +23,27 @@ class CurrentFileContextProvider extends BaseContextProvider {
if (!currentFile) {
return [];
}
const baseName = getUriPathBasename(currentFile.path);
const { relativePathOrBasename, last2Parts, baseName } = getUriDescription(
currentFile.path,
await extras.ide.getWorkspaceDirs(),
);
let prefix = "This is the currently open file:";
let name = baseName;
// This allows frontend to retrieve when using alt + enter or default context with slightly different copy
if (query === "non-mention-usage") {
prefix =
"The following file is currently open. Don't reference it if it's not relevant to the user's message:";
name = "Active file: " + baseName;
}
return [
{
description: currentFile.path,
content: `This is the currently open file:\n\n\`\`\`${baseName}\n${currentFile.contents}\n\`\`\``,
name: baseName,
description: last2Parts,
content: `${prefix}\n\n\`\`\`${relativePathOrBasename}\n${currentFile.contents}\n\`\`\``,
name,
uri: {
type: "file",
value: currentFile.path,

View file

@ -10,6 +10,7 @@ import { walkDirs } from "../../indexing/walkDir";
import {
getUriPathBasename,
getShortestUniqueRelativeUriPaths,
getUriDescription,
} from "../../util/uri";
const MAX_SUBMENU_ITEMS = 10_000;
@ -27,16 +28,22 @@ class FileContextProvider extends BaseContextProvider {
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
// Assume the query is a filepath
query = query.trim();
const content = await extras.ide.readFile(query);
const fileUri = query.trim();
const content = await extras.ide.readFile(fileUri);
const { relativePathOrBasename, last2Parts, baseName } = getUriDescription(
fileUri,
await extras.ide.getWorkspaceDirs(),
);
return [
{
name: query.split(/[\\/]/).pop() ?? query,
description: query,
content: `\`\`\`${query}\n${content}\n\`\`\``,
name: baseName,
description: last2Parts,
content: `\`\`\`${relativePathOrBasename}\n${content}\n\`\`\``,
uri: {
type: "file",
value: query,
value: fileUri,
},
},
];

View file

@ -3,7 +3,7 @@ import {
ContextProviderDescription,
ContextProviderExtras,
} from "../../index.js";
import { findUriInDirs, getUriPathBasename } from "../../util/uri.js";
import { getUriDescription } from "../../util/uri.js";
import { BaseContextProvider } from "../index.js";
class OpenFilesContextProvider extends BaseContextProvider {
@ -24,14 +24,17 @@ class OpenFilesContextProvider extends BaseContextProvider {
? await ide.getPinnedFiles()
: await ide.getOpenFiles();
const workspaceDirs = await extras.ide.getWorkspaceDirs();
return await Promise.all(
openFiles.map(async (filepath: string) => {
const content = await ide.readFile(filepath);
const { relativePathOrBasename, last2Parts, baseName } =
getUriDescription(filepath, workspaceDirs);
return {
description: filepath,
content: `\`\`\`${
findUriInDirs(filepath, workspaceDirs).relativePathOrBasename
}\n${await ide.readFile(filepath)}\n\`\`\``,
name: getUriPathBasename(filepath),
description: last2Parts,
content: `\`\`\`${relativePathOrBasename}\n${content}\n\`\`\``,
name: baseName,
uri: {
type: "file",
value: filepath,

View file

@ -3,7 +3,7 @@ import {
ContextProviderDescription,
ContextProviderExtras,
} from "../../index.js";
import { getUriPathBasename } from "../../util/uri.js";
import { getUriDescription } from "../../util/uri.js";
import { BaseContextProvider } from "../index.js";
class ProblemsContextProvider extends BaseContextProvider {
@ -20,10 +20,14 @@ class ProblemsContextProvider extends BaseContextProvider {
): Promise<ContextItem[]> {
const ide = extras.ide;
const problems = await ide.getProblems();
const workspaceDirs = await ide.getWorkspaceDirs();
const items = await Promise.all(
problems.map(async (problem) => {
const fileName = getUriPathBasename(problem.filepath);
const { relativePathOrBasename, baseName } = getUriDescription(
problem.filepath,
workspaceDirs,
);
const content = await ide.readFile(problem.filepath);
const lines = content.split("\n");
const rangeContent = lines
@ -35,8 +39,8 @@ class ProblemsContextProvider extends BaseContextProvider {
return {
description: "Problems in current file",
content: `\`\`\`${fileName}\n${rangeContent}\n\`\`\`\n${problem.message}\n\n`,
name: `Warning in ${fileName}`,
content: `\`\`\`${relativePathOrBasename}\n${rangeContent}\n\`\`\`\n${problem.message}\n\n`,
name: `Warning in ${baseName}`,
};
}),
);

View file

@ -1,6 +1,6 @@
import { BranchAndDir, ContextItem, ContextProviderExtras } from "../../";
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
import { getUriPathBasename } from "../../util/uri";
import { getUriDescription } from "../../util/uri";
import { INSTRUCTIONS_BASE_ITEM } from "../providers/utils";
import { RetrievalPipelineOptions } from "./pipelines/BaseRetrievalPipeline";
@ -111,18 +111,17 @@ export async function retrieveContextItemsFromEmbeddings(
...results
.sort((a, b) => a.filepath.localeCompare(b.filepath))
.map((r) => {
const basename = getUriPathBasename(r.filepath);
const name = `${basename} (${r.startLine}-${r.endLine})`;
const description = `${r.filepath}`;
const { relativePathOrBasename, last2Parts, baseName } =
getUriDescription(r.filepath, workspaceDirs);
if (basename === "package.json") {
if (baseName === "package.json") {
console.warn("Retrieval pipeline: package.json detected");
}
return {
name,
description,
content: `\`\`\`${name}\n${r.content}\n\`\`\``,
name: `${baseName} (${r.startLine + 1}-${r.endLine + 1})`,
description: last2Parts,
content: `\`\`\`${relativePathOrBasename}\n${r.content}\n\`\`\``,
uri: {
type: "file" as const,
value: r.filepath,

View file

@ -4,13 +4,14 @@ import { getControlPlaneEnv } from "../env";
export async function getAuthUrlForTokenPage(
ideSettingsPromise: Promise<IdeSettings>,
useOnboarding: boolean,
): Promise<string> {
const env = await getControlPlaneEnv(ideSettingsPromise);
const url = new URL("https://api.workos.com/user_management/authorize");
const params = {
response_type: "code",
client_id: env.WORKOS_CLIENT_ID,
redirect_uri: `${env.APP_URL}tokens/callback`,
redirect_uri: `${env.APP_URL}tokens/${useOnboarding ? "onboarding-" : ""}callback`,
// redirect_uri: "http://localhost:3000/tokens/callback",
state: uuidv4(),
provider: "authkit",

View file

@ -104,7 +104,7 @@ export class ControlPlaneClient {
}
}
public async listAssistants(organizationId?: string): Promise<
public async listAssistants(organizationId: string | null): Promise<
{
configResult: ConfigResult<AssistantUnrolled>;
ownerSlug: string;
@ -132,38 +132,37 @@ export class ControlPlaneClient {
}
public async listOrganizations(): Promise<Array<OrganizationDescription>> {
return [
{
id: "1",
iconUrl:
"https://cdn.prod.website-files.com/663e06c56841363663ffbbcf/663e1b9fb023f0b622ad3608_log-text.svg",
name: "Continue",
},
];
// const userId = await this.userId;
// if (!userId) {
// return [];
// }
const userId = await this.userId;
// try {
// const resp = await this.request("ide/list-organizations", {
// method: "GET",
// });
// const { organizations } = (await resp.json()) as any;
// return organizations;
// } catch (e) {
// return [];
// }
if (!userId) {
return [];
}
try {
const resp = await this.request("ide/list-organizations", {
method: "GET",
});
const { organizations } = (await resp.json()) as any;
return organizations;
} catch (e) {
return [];
}
}
public async listAssistantFullSlugs(): Promise<FullSlug[] | null> {
public async listAssistantFullSlugs(
organizationId: string | null,
): Promise<FullSlug[] | null> {
const userId = await this.userId;
if (!userId) {
return null;
}
const url = organizationId
? `ide/list-assistant-full-slugs?organizationId=${organizationId}`
: "ide/list-assistant-full-slugs";
try {
const resp = await this.request("ide/list-assistant-full-slugs", {
const resp = await this.request(url, {
method: "GET",
});
const { fullSlugs } = (await resp.json()) as any;

View file

@ -1,4 +1,7 @@
import fetch from "node-fetch";
import * as fs from "node:fs";
import { IdeSettings } from "..";
import { getStagingEnvironmentDotFilePath } from "../util/paths";
export interface ControlPlaneEnv {
DEFAULT_CONTROL_PLANE_PROXY_URL: string;
@ -35,13 +38,11 @@ const PRODUCTION_HUB_ENV: ControlPlaneEnv = {
};
const STAGING_ENV: ControlPlaneEnv = {
DEFAULT_CONTROL_PLANE_PROXY_URL:
"https://control-plane-api-service-537175798139.us-central1.run.app/",
CONTROL_PLANE_URL:
"https://control-plane-api-service-537175798139.us-central1.run.app/",
AUTH_TYPE: WORKOS_CLIENT_ID_STAGING,
DEFAULT_CONTROL_PLANE_PROXY_URL: "https://api.continue-stage.tools/",
CONTROL_PLANE_URL: "https://api.continue-stage.tools/",
AUTH_TYPE: WORKOS_ENV_ID_STAGING,
WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING,
APP_URL: "https://app-preview.continue.dev/",
APP_URL: "https://hub.continue-stage.tools/",
};
const TEST_ENV: ControlPlaneEnv = {
@ -60,6 +61,17 @@ const LOCAL_ENV: ControlPlaneEnv = {
APP_URL: "http://localhost:3000/",
};
export async function enableHubContinueDev() {
try {
const resp = await fetch("https://api.continue.dev/features/hub");
const data = (await resp.json()) as any;
if ("enabled" in data && data.enabled === true) {
return true;
}
} catch (e: any) {}
return false;
}
export async function getControlPlaneEnv(
ideSettingsPromise: Promise<IdeSettings>,
): Promise<ControlPlaneEnv> {
@ -70,11 +82,15 @@ export async function getControlPlaneEnv(
export function getControlPlaneEnvSync(
ideTestEnvironment: IdeSettings["continueTestEnvironment"],
): ControlPlaneEnv {
if (fs.existsSync(getStagingEnvironmentDotFilePath())) {
return STAGING_ENV;
}
const env =
ideTestEnvironment === "production"
? "hub"
: ideTestEnvironment === "test"
? "test"
: ideTestEnvironment === "staging"
? "staging"
: ideTestEnvironment === "local"
? "local"
: process.env.CONTROL_PLANE_ENV;

View file

@ -11,7 +11,6 @@ import { SYSTEM_PROMPT_DOT_FILE } from "./config/getSystemPromptDotFile";
import {
setupBestConfig,
setupLocalConfig,
setupLocalConfigAfterFreeTrial,
setupQuickstartConfig,
} from "./config/onboarding";
import { addContextProvider, addModel, deleteModel } from "./config/util";
@ -53,11 +52,12 @@ import {
type IndexingProgressUpdate,
} from ".";
import CodebaseContextProvider from "./context/providers/CodebaseContextProvider";
import CurrentFileContextProvider from "./context/providers/CurrentFileContextProvider";
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
import type { IMessenger, Message } from "./protocol/messenger";
export class Core {
// implements IMessenger<ToCoreProtocol, FromCoreProtocol>
configHandler: ConfigHandler;
codebaseIndexerPromise: Promise<CodebaseIndexer>;
completionProvider: CompletionProvider;
@ -209,13 +209,24 @@ export class Core {
// Note, VsCode's in-process messenger doesn't do anything with this
// It will only show for jetbrains
this.messenger.onError((err) => {
console.error(err);
this.messenger.onError((message, err) => {
void Telemetry.capture("core_messenger_error", {
message: err.message,
stack: err.stack,
});
void this.ide.showToast("error", err.message);
// Again, specifically for jetbrains to prevent duplicate error messages
// The same logic can currently be found in the webview protocol
// bc streaming errors are handled in the GUI
if (
["llm/streamChat", "chatDescriber/describe"].includes(
message.messageType,
)
) {
return;
} else {
void this.ide.showToast("error", err.message);
}
});
on("update/selectTabAutocompleteModel", async (msg) => {
@ -305,7 +316,11 @@ export class Core {
on("controlPlane/openUrl", async (msg) => {
const env = await getControlPlaneEnv(this.ide.getIdeSettings());
await this.messenger.request("openUrl", `${env.APP_URL}${msg.data.path}`);
let url = `${env.APP_URL}${msg.data.path}`;
if (msg.data.orgSlug) {
url += `?org=${msg.data.orgSlug}`;
}
await this.messenger.request("openUrl", url);
});
on("controlPlane/listOrganizations", async (msg) => {
@ -351,9 +366,17 @@ export class Core {
}
const llm = await this.configHandler.llmFromTitle(selectedModelTitle);
const provider = config.contextProviders?.find(
(provider) => provider.description.title === name,
);
const provider =
config.contextProviders?.find(
(provider) => provider.description.title === name,
) ??
[
// user doesn't need these in their config.json for the shortcuts to work
// option+enter
new CurrentFileContextProvider({}),
// cmd+enter
new CodebaseContextProvider({}),
].find((provider) => provider.description.title === name);
if (!provider) {
return [];
}
@ -389,10 +412,36 @@ export class Core {
id,
}));
} catch (e) {
void this.ide.showToast(
"error",
`Error getting context items from ${name}: ${e}`,
);
let knownError = false;
if (e instanceof Error) {
// A specific error where we're forcing the presence of embeddings provider on the config
// But Jetbrains doesn't support transformers JS
// So if a context provider needs it it will throw this error when the file isn't found
if (e.message.includes("all-MiniLM-L6-v2")) {
knownError = true;
const toastOption = "See Docs";
void this.ide
.showToast(
"error",
`Set up an embeddings model to use @${name}`,
toastOption,
)
.then((userSelection) => {
if (userSelection === toastOption) {
void this.ide.openUrl(
"https://docs.continue.dev/customize/model-types/embeddings",
);
}
});
}
}
if (!knownError) {
void this.ide.showToast(
"error",
`Error getting context items from ${name}: ${e}`,
);
}
return [];
}
});
@ -693,6 +742,8 @@ export class Core {
llm,
data.input,
data.language,
false,
undefined,
)) {
if (abortedMessageIds.has(msg.messageId)) {
abortedMessageIds.delete(msg.messageId);
@ -724,10 +775,6 @@ export class Core {
editConfigJsonCallback = setupQuickstartConfig;
break;
case "LocalAfterFreeTrial":
editConfigJsonCallback = setupLocalConfigAfterFreeTrial;
break;
case "Best":
editConfigJsonCallback = setupBestConfig;
break;
@ -831,12 +878,18 @@ export class Core {
on("files/created", async ({ data }) => {
if (data?.uris?.length) {
this.messenger.send("refreshSubmenuItems", {
providers: ["file"],
});
await this.refreshCodebaseIndexFiles(data.uris);
}
});
on("files/deleted", async ({ data }) => {
if (data?.uris?.length) {
this.messenger.send("refreshSubmenuItems", {
providers: ["file"],
});
await this.refreshCodebaseIndexFiles(data.uris);
}
});
@ -882,11 +935,22 @@ export class Core {
void this.configHandler.setSelectedProfile(msg.data.id);
void this.configHandler.reloadConfig();
});
on("didChangeSelectedOrg", (msg) => {
void this.configHandler.setSelectedOrgId(msg.data.id);
void this.configHandler.reloadConfig();
});
on("didChangeControlPlaneSessionInfo", async (msg) => {
this.configHandler.updateControlPlaneSessionInfo(msg.data.sessionInfo);
await this.configHandler.updateControlPlaneSessionInfo(
msg.data.sessionInfo,
);
});
on("auth/getAuthUrl", async (msg) => {
const url = await getAuthUrlForTokenPage(ideSettingsPromise);
const url = await getAuthUrlForTokenPage(
ideSettingsPromise,
msg.data.useOnboarding,
);
return { url };
});
@ -924,16 +988,23 @@ export class Core {
const llm = await this.configHandler.llmFromTitle(selectedModelTitle);
const contextItems = await callTool(
tool.uri ?? tool.function.name,
tool,
JSON.parse(toolCall.function.arguments || "{}"),
{
ide: this.ide,
llm,
fetch: (url, init) =>
fetchwithRequestOptions(url, init, config.requestOptions),
tool,
},
);
if (tool.faviconUrl) {
contextItems.forEach((item) => {
item.icon = tool.faviconUrl;
});
}
return { contextItems };
});
}

View file

@ -54,7 +54,8 @@ export async function* streamDiffLines(
llm: ILLM,
input: string,
language: string | undefined,
onlyOneInsertion?: boolean,
onlyOneInsertion: boolean,
overridePrompt: ChatMessage[] | undefined,
): AsyncGenerator<DiffLine> {
void Telemetry.capture(
"inlineEdit",
@ -80,14 +81,9 @@ export async function* streamDiffLines(
// Trim end of oldLines, otherwise we have trailing \r on every line for CRLF files
oldLines = oldLines.map((line) => line.trimEnd());
const prompt = constructPrompt(
prefix,
highlighted,
suffix,
llm,
input,
language,
);
const prompt =
overridePrompt ??
constructPrompt(prefix, highlighted, suffix, llm, input, language);
const inept = modelIsInept(llm.model);
const prediction: Prediction = {

26
core/index.d.ts vendored
View file

@ -1,6 +1,6 @@
import { ModelRole } from "@continuedev/config-yaml";
import Parser from "web-tree-sitter";
import { GetGhTokenArgs } from "./protocol/ide";
declare global {
interface Window {
ide?: "vscode";
@ -94,6 +94,8 @@ export interface ILLM extends LLMOptions {
apiKey?: string;
apiBase?: string;
cacheBehavior?: CacheBehavior;
capabilities?: ModelCapability;
roles?: ModelRole[];
deployment?: string;
apiVersion?: string;
@ -480,6 +482,8 @@ export interface LLMOptions {
aiGatewaySlug?: string;
apiBase?: string;
cacheBehavior?: CacheBehavior;
capabilities?: ModelCapability;
roles?: ModelRole[];
useLegacyCompletionsEndpoint?: boolean;
@ -503,9 +507,6 @@ export interface LLMOptions {
// AWS and GCP Options
region?: string;
// GCP Options
capabilities?: ModelCapability;
// GCP and Watsonx Options
projectId?: string;
@ -599,7 +600,7 @@ export interface IdeSettings {
remoteConfigSyncPeriod: number;
userToken: string;
enableControlServerBeta: boolean;
continueTestEnvironment: "none" | "production" | "test" | "local";
continueTestEnvironment: "none" | "production" | "staging" | "local";
pauseCodebaseIndexOnStart: boolean;
}
@ -859,6 +860,7 @@ export interface ToolExtras {
ide: IDE;
llm: ILLM;
fetch: FetchFunction;
tool: Tool;
}
export interface Tool {
@ -874,6 +876,7 @@ export interface Tool {
wouldLikeTo: string;
readonly: boolean;
uri?: string;
faviconUrl?: string;
}
interface ToolChoice {
@ -921,8 +924,9 @@ export interface ModelDescription {
systemMessage?: string;
requestOptions?: RequestOptions;
promptTemplates?: { [key: string]: string };
capabilities?: ModelCapability;
cacheBehavior?: CacheBehavior;
capabilities?: ModelCapability;
roles?: ModelRole[];
}
export interface EmbedOptions {
@ -971,6 +975,11 @@ export interface TabAutocompleteOptions {
disableInFiles?: string[];
useImports?: boolean;
showWhateverWeHaveAtXMs?: number;
// true = enabled, false = disabled, number = enabled with priority
experimental_includeClipboard: boolean | number;
experimental_includeRecentlyVisitedRanges: boolean | number;
experimental_includeRecentlyEditedRanges: boolean | number;
experimental_includeDiff: boolean | number;
}
export interface StdioOptions {
@ -994,6 +1003,7 @@ export type TransportOptions = StdioOptions | WebSocketOptions | SSEOptions;
export interface MCPOptions {
transport: TransportOptions;
faviconUrl?: string;
}
export interface ContinueUIConfig {
@ -1012,7 +1022,7 @@ export interface ContextMenuConfig {
fixGrammar?: string;
}
export interface ModelRoles {
export interface ExperimentalModelRoles {
inlineEdit?: string;
applyCodeBlock?: string;
repoMapFileSelection?: string;
@ -1080,7 +1090,7 @@ export type DefaultContextProvider = ContextProviderWithParams & {
export interface ExperimentalConfig {
contextMenuPrompts?: ContextMenuConfig;
modelRoles?: ModelRoles;
modelRoles?: ExperimentalModelRoles;
defaultContext?: DefaultContextProvider[];
promptPath?: string;

View file

@ -28,7 +28,12 @@ import type {
IndexTag,
IndexingProgressUpdate,
} from "../";
import { getLastNPathParts, getUriPathBasename } from "../util/uri";
import {
findUriInDirs,
getLastNPathParts,
getLastNUriRelativePathParts,
getUriPathBasename,
} from "../util/uri";
type SnippetChunk = ChunkWithoutID & { title: string; signature: string };
@ -347,14 +352,19 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
}
}
static async getForId(id: number): Promise<ContextItem> {
static async getForId(
id: number,
workspaceDirs: string[],
): Promise<ContextItem> {
const db = await SqliteDb.get();
const row = await db.get("SELECT * FROM code_snippets WHERE id = ?", [id]);
const last2Parts = getLastNUriRelativePathParts(workspaceDirs, row.path, 2);
const { relativePathOrBasename } = findUriInDirs(row.path, workspaceDirs);
return {
name: row.title,
description: getLastNPathParts(row.path, 2),
content: `\`\`\`${getUriPathBasename(row.path)}\n${row.content}\n\`\`\``,
description: last2Parts,
content: `\`\`\`${relativePathOrBasename}\n${row.content}\n\`\`\``,
uri: {
type: "file",
value: row.path,

View file

@ -41,6 +41,7 @@ import {
} from "./preIndexed";
import preIndexedDocs from "./preIndexedDocs";
import { ConfigResult } from "@continuedev/config-yaml";
import { GlobalContext } from "../../util/GlobalContext";
// Purposefully lowercase because lancedb converts
export interface LanceDbDocsRow {
@ -210,11 +211,11 @@ export default class DocsService {
if (isAborted) {
return true;
}
// Handle indexing disabled change mid-indexing
if (this.config.disableIndexing) {
this.abort(startUrl);
return true;
}
// // Handle indexing disabled change mid-indexing
// if (this.config.disableIndexing) {
// this.abort(startUrl);
// return true;
// }
// Handle embeddings provider change mid-indexing
if (this.config.embeddingsProvider.embeddingId !== startedWithEmbedder) {
this.abort(startUrl);
@ -276,9 +277,9 @@ export default class DocsService {
const oldConfig = this.config;
this.config = newConfig; // IMPORTANT - need to set up top, other methods below use this without passing it in
if (this.config.disableIndexing) {
return;
}
// if (this.config.disableIndexing) {
// return;
// }
// No point in indexing if no docs context provider
const hasDocsContextProvider = this.hasDocsContextProvider();
@ -365,12 +366,12 @@ export default class DocsService {
async indexAndAdd(
siteIndexingConfig: SiteIndexingConfig,
reIndex: boolean = false,
forceReindex: boolean = false,
): Promise<void> {
if (this.config.disableIndexing) {
console.warn("Attempting to add/index docs when indexing is disabled");
return;
}
// if (this.config.disableIndexing) {
// console.warn("Attempting to add/index docs when indexing is disabled");
// return;
// }
const { startUrl, useLocalCrawling, maxDepth } = siteIndexingConfig;
const { isPreindexed, provider } =
@ -396,7 +397,7 @@ export default class DocsService {
type: "docs",
id: siteIndexingConfig.startUrl,
embeddingsProviderId: provider.embeddingId,
isReindexing: reIndex && indexExists,
isReindexing: forceReindex && indexExists,
title: siteIndexingConfig.title,
debugInfo: `max depth: ${siteIndexingConfig.maxDepth}`,
icon: siteIndexingConfig.faviconUrl,
@ -405,7 +406,7 @@ export default class DocsService {
// Clear current indexes if reIndexing
if (indexExists) {
if (reIndex) {
if (forceReindex) {
await this.deleteIndexes(startUrl);
} else {
this.handleStatusUpdate({
@ -419,6 +420,46 @@ export default class DocsService {
}
}
// If not force-reindexing and has failed with same config, don't reattempt
if (!forceReindex) {
const globalContext = new GlobalContext();
const failedDocs = globalContext.get("failedDocs") ?? [];
const hasFailed = failedDocs.find((d) =>
this.siteIndexingConfigsAreEqual(siteIndexingConfig, d),
);
if (hasFailed) {
console.log(
`Not reattempting to index ${siteIndexingConfig.startUrl}, has already failed with same config`,
);
this.handleStatusUpdate({
...fixedStatus,
description: "Failed",
status: "failed",
progress: 1,
});
return;
}
}
const markFailedInGlobalContext = () => {
const globalContext = new GlobalContext();
const failedDocs = globalContext.get("failedDocs") ?? [];
const newFailedDocs = failedDocs.filter(
(d) => !this.siteIndexingConfigsAreEqual(siteIndexingConfig, d),
);
newFailedDocs.push(siteIndexingConfig);
globalContext.update("failedDocs", newFailedDocs);
};
const removeFromFailedGlobalContext = () => {
const globalContext = new GlobalContext();
const failedDocs = globalContext.get("failedDocs") ?? [];
const newFailedDocs = failedDocs.filter(
(d) => !this.siteIndexingConfigsAreEqual(siteIndexingConfig, d),
);
globalContext.update("failedDocs", newFailedDocs);
};
try {
this.docsIndexingQueue.add(startUrl);
@ -552,6 +593,7 @@ export default class DocsService {
void this.ide.showToast("info", `Failed to index ${startUrl}`);
this.docsIndexingQueue.delete(startUrl);
markFailedInGlobalContext();
return;
}
@ -569,7 +611,7 @@ export default class DocsService {
});
// Delete indexed docs if re-indexing
if (reIndex && indexExists) {
if (forceReindex && indexExists) {
console.log("Deleting old embeddings");
await this.deleteIndexes(startUrl);
}
@ -610,6 +652,8 @@ export default class DocsService {
this.messenger?.send("refreshSubmenuItems", {
providers: ["docs"],
});
removeFromFailedGlobalContext();
} catch (e) {
let description = `Error getting docs from: ${siteIndexingConfig.startUrl}`;
if (e instanceof Error) {
@ -617,7 +661,7 @@ export default class DocsService {
e.message.includes("github.com") &&
e.message.includes("rate limit")
) {
description = "Github rate limit exceeded";
description = "Github rate limit exceeded"; // This text is used verbatim elsewhere
}
}
console.error("Error indexing docs", e);
@ -627,6 +671,7 @@ export default class DocsService {
status: "failed",
progress: 1,
});
markFailedInGlobalContext();
} finally {
this.docsIndexingQueue.delete(startUrl);
}
@ -908,10 +953,8 @@ export default class DocsService {
}
}
} else {
const currentStatus = this.statuses.get(doc.startUrl);
if (currentStatus?.status !== "failed") {
newDocs.push(doc);
}
newDocs.push(doc);
void Telemetry.capture("add_docs_config", { url: doc.startUrl });
}
}
@ -920,10 +963,6 @@ export default class DocsService {
...newDocs.map((doc) => this.indexAndAdd(doc)),
]);
for (const doc of newDocs) {
void Telemetry.capture("add_docs_config", { url: doc.startUrl });
}
for (const doc of deletedDocs) {
await this.deleteIndexes(doc.startUrl);
}

View file

@ -353,6 +353,11 @@ const preIndexedDocs: Record<
startUrl: "https://docs.asksage.ai/",
rootUrl: "https://docs.asksage.ai/",
},
"https://angular.dev/": {
title: "Angular",
startUrl: "https://angular.dev/",
rootUrl: "https://angular.dev/",
},
};
export default preIndexedDocs;

View file

@ -1,4 +1,4 @@
import { ModelCapability, TemplateType } from "../index.js";
import { ChatMessage, ModelCapability, TemplateType } from "../index.js";
import {
anthropicTemplateMessages,
@ -257,7 +257,10 @@ function autodetectTemplateFunction(
const templateType = explicitTemplate ?? autodetectTemplateType(model);
if (templateType) {
const mapping: Record<TemplateType, any> = {
const mapping: Record<
TemplateType,
null | ((msg: ChatMessage[]) => string)
> = {
llama2: llama2TemplateMessages,
alpaca: templateAlpacaMessages,
phi2: phi2TemplateMessages,

View file

@ -56,6 +56,7 @@ import {
toCompleteBody,
toFimBody,
} from "./openaiTypeConverters.js";
import { ModelRole } from "@continuedev/config-yaml";
export abstract class BaseLLM implements ILLM {
static providerName: string;
@ -121,6 +122,7 @@ export abstract class BaseLLM implements ILLM {
apiBase?: string;
cacheBehavior?: CacheBehavior;
capabilities?: ModelCapability;
roles?: ModelRole[];
deployment?: string;
apiVersion?: string;
@ -191,7 +193,8 @@ export abstract class BaseLLM implements ILLM {
options.model,
this.providerName,
options.template,
);
) ??
undefined;
this.writeLog = options.writeLog;
this.llmRequestHook = options.llmRequestHook;
this.apiKey = options.apiKey;
@ -208,6 +211,7 @@ export abstract class BaseLLM implements ILLM {
}
this.accountId = options.accountId;
this.capabilities = options.capabilities;
this.roles = options.roles;
this.deployment = options.deployment;
this.apiVersion = options.apiVersion;
@ -957,7 +961,9 @@ export abstract class BaseLLM implements ILLM {
this.providerName,
autodetectTemplateType(this.model),
);
return templateMessages(rendered);
if (templateMessages) {
return templateMessages(rendered);
}
}
return rendered;
}

View file

@ -2,12 +2,14 @@ import * as dotenv from "dotenv";
import { AssistantChatMessage, CompletionOptions } from "..";
import { BaseLLM } from ".";
import Anthropic from "./llms/Anthropic";
import Azure from "./llms/Azure";
import Gemini from "./llms/Gemini";
import Mistral from "./llms/Mistral";
import OpenAI from "./llms/OpenAI";
import { BaseLLM } from ".";
dotenv.config();
const COMPLETION_OPTIONS: Partial<CompletionOptions> = {
@ -222,4 +224,25 @@ describe("LLM", () => {
}),
{ testFim: true, skip: false },
);
testLLM(
new Azure({
apiKey: process.env.AZURE_OPENAI_API_KEY,
model: "gpt-4o",
apiVersion: "2024-05-01-preview",
apiBase: "https://continue-azure-openai-instance.openai.azure.com",
deployment: "azure-openai-deployment",
apiType: "azure-openai",
}),
{ testFim: false, skip: false, timeout: 20000 },
);
testLLM(
new Azure({
apiKey: process.env.AZURE_FOUNDRY_API_KEY,
model: "codestral-latest",
apiBase:
"https://codestral-2501-continue-testing.eastus.models.ai.azure.com",
apiType: "azure-foundry",
}),
{ testFim: false, skip: false, timeout: 20000 },
);
});

View file

@ -14,7 +14,7 @@ class Azure extends OpenAI {
static defaultOptions: Partial<LLMOptions> = {
apiVersion: "2024-02-15-preview",
apiType: "azure",
apiType: "azure-openai",
};
constructor(options: LLMOptions) {

View file

@ -215,7 +215,7 @@ class FreeTrial extends BaseLLM {
"llama3.1-70b",
"gpt-4o",
"gpt-3.5-turbo",
"claude-3-haiku-20240307",
"claude-3-5-haiku-latest",
"gemini-1.5-pro-latest",
];
}

View file

@ -9,6 +9,8 @@ class Novita extends OpenAI {
};
private static MODEL_IDS: { [name: string]: string } = {
"deepseek-r1": "deepseek/deepseek-r1",
"deepseek_v3": "deepseek/deepseek_v3",
"llama3-8b": "meta-llama/llama-3-8b-instruct",
"llama3-70b": "meta-llama/llama-3-70b-instruct",
"llama3.1-8b": "meta-llama/llama-3.1-8b-instruct",

View file

@ -49,7 +49,7 @@ const CHAT_ONLY_MODELS = [
"gpt-4o-mini",
"o1-preview",
"o1-mini",
"o3-mini"
"o3-mini",
];
const formatMessageForO1 = (messages: ChatCompletionMessageParam[]) => {
@ -206,18 +206,25 @@ class OpenAI extends BaseLLM {
protected _getEndpoint(
endpoint: "chat/completions" | "completions" | "models",
) {
if (this.apiType === "azure") {
return new URL(
`openai/deployments/${this.deployment}/${endpoint}?api-version=${this.apiVersion}`,
this.apiBase,
);
}
if (!this.apiBase) {
throw new Error(
"No API base URL provided. Please set the 'apiBase' option in config.json",
);
}
if (this.apiType?.includes("azure")) {
// Default is `azure-openai`, but previously was `azure`
const isAzureOpenAI =
this.apiType === "azure-openai" || this.apiType === "azure";
const path = isAzureOpenAI
? `openai/deployments/${this.deployment}/${endpoint}`
: endpoint;
const version = this.apiVersion ? `?api-version=${this.apiVersion}` : "";
return new URL(`${path}${version}`, this.apiBase);
}
return new URL(endpoint, this.apiBase);
}
@ -267,7 +274,7 @@ class OpenAI extends BaseLLM {
body.max_completion_tokens = undefined;
}
if (body.tools?.length) {
if (body.tools?.length && !body.model?.startsWith("o3")) {
// To ensure schema adherence: https://platform.openai.com/docs/guides/function-calling#parallel-function-calling-and-structured-outputs
// In practice, setting this to true and asking for multiple tool calls
// leads to "arguments" being something like '{"file": "test.ts"}{"file": "test.js"}'

View file

@ -57,30 +57,34 @@ export function toChatMessage(
}
return msg;
} else {
if (typeof message.content === "string") {
return {
role: "user",
content: message.content ?? " ", // LM Studio (and other providers) don't accept empty content
};
}
// If no multi-media is in the message, just send as text
// for compatibility with OpenAI-"compatible" servers
// that don't support multi-media format
return {
role: "user",
content:
typeof message.content === "string"
? message.content || " " // LM Studio (and other providers) don't accept empty content
: // If no multi-media is in the message, just send as text
// for compatibility with OpenAI-"compatible" servers
// that don't support multi-media format
message.content.some((item) => item.type !== "text")
? message.content
.map((item) => (item as TextMessagePart).text)
.join("") || " "
: message.content.map((part) => {
if (part.type === "imageUrl") {
return {
type: "image_url" as const,
image_url: {
url: part.imageUrl.url,
detail: "auto" as const,
},
};
}
return part;
}),
content: !message.content.some((item) => item.type !== "text")
? message.content
.map((item) => (item as TextMessagePart).text)
.join("") || " "
: message.content.map((part) => {
if (part.type === "imageUrl") {
return {
type: "image_url" as const,
image_url: {
url: part.imageUrl.url,
detail: "auto" as const,
},
};
}
return part;
}),
};
}
}

View file

@ -13,7 +13,7 @@ export const PROVIDER_TOOL_SUPPORT: Record<
},
openai: (model) => {
// https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling
if (model.toLowerCase().startsWith("gpt-4")) {
if (model.toLowerCase().startsWith("gpt-4") || model.toLowerCase().startsWith("o3")) {
return true;
}
},

329
core/package-lock.json generated
View file

@ -13,11 +13,11 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.23",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",
"@modelcontextprotocol/sdk": "^1.0.0",
"@modelcontextprotocol/sdk": "^1.5.0",
"@mozilla/readability": "^0.5.0",
"@octokit/rest": "^20.0.2",
"@typescript-eslint/eslint-plugin": "^7.8.0",
@ -93,7 +93,7 @@
"@types/uuid": "^9.0.7",
"@types/win-ca": "^3.5.4",
"cross-env": "^7.0.3",
"esbuild": "0.17.19",
"esbuild": "0.24.0",
"eslint": "^8",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
@ -3038,9 +3038,9 @@
}
},
"node_modules/@continuedev/config-yaml": {
"version": "1.0.23",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.23.tgz",
"integrity": "sha512-F2Hwc85iCwAHJuwJALOsmZIBeHdF+87mS0YT7dlC6QiE+zAhZKUHcLQ/nTt9bJuhyVyufpb9LApkp40UdGsaWw==",
"version": "1.0.31",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.31.tgz",
"integrity": "sha512-HNj+z7UTTARgsJTI0A1buM09fS4HoWVnn6Hbl6kJ2tZmOOm1OgogbcKP68AzHb4fy5H18MWnKS7XuseZpHFzHQ==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
@ -3077,10 +3077,26 @@
"zod": "^3.23.8"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz",
"integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==",
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz",
"integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.0.tgz",
"integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==",
"cpu": [
"arm"
],
@ -3090,13 +3106,13 @@
"android"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz",
"integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz",
"integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==",
"cpu": [
"arm64"
],
@ -3106,13 +3122,13 @@
"android"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz",
"integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.0.tgz",
"integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==",
"cpu": [
"x64"
],
@ -3122,13 +3138,13 @@
"android"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz",
"integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz",
"integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==",
"cpu": [
"arm64"
],
@ -3138,13 +3154,13 @@
"darwin"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz",
"integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz",
"integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==",
"cpu": [
"x64"
],
@ -3154,13 +3170,13 @@
"darwin"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz",
"integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz",
"integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==",
"cpu": [
"arm64"
],
@ -3170,13 +3186,13 @@
"freebsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz",
"integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz",
"integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==",
"cpu": [
"x64"
],
@ -3186,13 +3202,13 @@
"freebsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz",
"integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz",
"integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==",
"cpu": [
"arm"
],
@ -3202,13 +3218,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz",
"integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz",
"integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==",
"cpu": [
"arm64"
],
@ -3218,13 +3234,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz",
"integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz",
"integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==",
"cpu": [
"ia32"
],
@ -3234,13 +3250,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz",
"integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz",
"integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==",
"cpu": [
"loong64"
],
@ -3250,13 +3266,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz",
"integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz",
"integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==",
"cpu": [
"mips64el"
],
@ -3266,13 +3282,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz",
"integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz",
"integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==",
"cpu": [
"ppc64"
],
@ -3282,13 +3298,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz",
"integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz",
"integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==",
"cpu": [
"riscv64"
],
@ -3298,13 +3314,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz",
"integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz",
"integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==",
"cpu": [
"s390x"
],
@ -3314,13 +3330,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz",
"integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz",
"integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==",
"cpu": [
"x64"
],
@ -3330,13 +3346,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz",
"integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz",
"integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==",
"cpu": [
"x64"
],
@ -3346,13 +3362,29 @@
"netbsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-arm64": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz",
"integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz",
"integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz",
"integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==",
"cpu": [
"x64"
],
@ -3362,13 +3394,13 @@
"openbsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz",
"integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz",
"integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==",
"cpu": [
"x64"
],
@ -3378,13 +3410,13 @@
"sunos"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz",
"integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz",
"integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==",
"cpu": [
"arm64"
],
@ -3394,13 +3426,13 @@
"win32"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz",
"integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz",
"integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==",
"cpu": [
"ia32"
],
@ -3410,13 +3442,13 @@
"win32"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz",
"integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz",
"integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==",
"cpu": [
"x64"
],
@ -3426,7 +3458,7 @@
"win32"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@eslint-community/eslint-utils": {
@ -4218,13 +4250,34 @@
]
},
"node_modules/@modelcontextprotocol/sdk": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.0.3.tgz",
"integrity": "sha512-2as3cX/VJ0YBHGmdv3GFyTpoM8q2gqE98zh3Vf1NwnsSY0h3mvoO07MUzfygCKkWsFjcZm4otIiqD6Xh7kiSBQ==",
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.5.0.tgz",
"integrity": "sha512-IJ+5iVVs8FCumIHxWqpwgkwOzyhtHVKy45s6Ug7Dv0MfRpaYisH8QQ87rIWeWdOzlk8sfhitZ7HCyQZk7d6b8w==",
"dependencies": {
"content-type": "^1.0.5",
"eventsource": "^3.0.2",
"raw-body": "^3.0.0",
"zod": "^3.23.8"
"zod": "^3.23.8",
"zod-to-json-schema": "^3.24.1"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@modelcontextprotocol/sdk/node_modules/zod": {
"version": "3.24.1",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz",
"integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema": {
"version": "3.24.1",
"resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.1.tgz",
"integrity": "sha512-3h08nf3Vw3Wl3PK+q3ow/lIil81IT2Oa7YpQyUUDsEWbXveMesdfK1xBd2RhCkynwZndAxixji/7SYJJowr62w==",
"peerDependencies": {
"zod": "^3.24.1"
}
},
"node_modules/@mozilla/readability": {
@ -7878,40 +7931,42 @@
}
},
"node_modules/esbuild": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz",
"integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz",
"integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==",
"dev": true,
"hasInstallScript": true,
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=12"
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/android-arm": "0.17.19",
"@esbuild/android-arm64": "0.17.19",
"@esbuild/android-x64": "0.17.19",
"@esbuild/darwin-arm64": "0.17.19",
"@esbuild/darwin-x64": "0.17.19",
"@esbuild/freebsd-arm64": "0.17.19",
"@esbuild/freebsd-x64": "0.17.19",
"@esbuild/linux-arm": "0.17.19",
"@esbuild/linux-arm64": "0.17.19",
"@esbuild/linux-ia32": "0.17.19",
"@esbuild/linux-loong64": "0.17.19",
"@esbuild/linux-mips64el": "0.17.19",
"@esbuild/linux-ppc64": "0.17.19",
"@esbuild/linux-riscv64": "0.17.19",
"@esbuild/linux-s390x": "0.17.19",
"@esbuild/linux-x64": "0.17.19",
"@esbuild/netbsd-x64": "0.17.19",
"@esbuild/openbsd-x64": "0.17.19",
"@esbuild/sunos-x64": "0.17.19",
"@esbuild/win32-arm64": "0.17.19",
"@esbuild/win32-ia32": "0.17.19",
"@esbuild/win32-x64": "0.17.19"
"@esbuild/aix-ppc64": "0.24.0",
"@esbuild/android-arm": "0.24.0",
"@esbuild/android-arm64": "0.24.0",
"@esbuild/android-x64": "0.24.0",
"@esbuild/darwin-arm64": "0.24.0",
"@esbuild/darwin-x64": "0.24.0",
"@esbuild/freebsd-arm64": "0.24.0",
"@esbuild/freebsd-x64": "0.24.0",
"@esbuild/linux-arm": "0.24.0",
"@esbuild/linux-arm64": "0.24.0",
"@esbuild/linux-ia32": "0.24.0",
"@esbuild/linux-loong64": "0.24.0",
"@esbuild/linux-mips64el": "0.24.0",
"@esbuild/linux-ppc64": "0.24.0",
"@esbuild/linux-riscv64": "0.24.0",
"@esbuild/linux-s390x": "0.24.0",
"@esbuild/linux-x64": "0.24.0",
"@esbuild/netbsd-x64": "0.24.0",
"@esbuild/openbsd-arm64": "0.24.0",
"@esbuild/openbsd-x64": "0.24.0",
"@esbuild/sunos-x64": "0.24.0",
"@esbuild/win32-arm64": "0.24.0",
"@esbuild/win32-ia32": "0.24.0",
"@esbuild/win32-x64": "0.24.0"
}
},
"node_modules/escalade": {
@ -8313,6 +8368,25 @@
"node": ">=0.8.x"
}
},
"node_modules/eventsource": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.5.tgz",
"integrity": "sha512-LT/5J605bx5SNyE+ITBDiM3FxffBiq9un7Vx0EwMDM3vg8sWKx/tO2zC+LMqZ+smAM0F2hblaDZUVZF0te2pSw==",
"dependencies": {
"eventsource-parser": "^3.0.0"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/eventsource-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.0.tgz",
"integrity": "sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA==",
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/execa": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz",
@ -15520,9 +15594,10 @@
}
},
"node_modules/undici": {
"version": "6.21.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.0.tgz",
"integrity": "sha512-BUgJXc752Kou3oOIuU1i+yZZypyZRqNPW0vqoMPl8VaoalSfeR0D8/t4iAS3yirs79SSMTxTag+ZC86uswv+Cw==",
"version": "6.21.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz",
"integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}

View file

@ -32,7 +32,7 @@
"@types/uuid": "^9.0.7",
"@types/win-ca": "^3.5.4",
"cross-env": "^7.0.3",
"esbuild": "0.17.19",
"esbuild": "0.24.0",
"eslint": "^8",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
@ -46,11 +46,11 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.23",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",
"@modelcontextprotocol/sdk": "^1.0.0",
"@modelcontextprotocol/sdk": "^1.5.0",
"@mozilla/readability": "^0.5.0",
"@octokit/rest": "^20.0.2",
"@typescript-eslint/eslint-plugin": "^7.8.0",

View file

@ -25,15 +25,20 @@ async function renderPromptV1(
) {
const helpers = getContextProviderHelpers(context);
// A few context providers that don't need to be in config.json to work in .prompt files
const diff = await context.ide.getDiff(true);
const currentFile = await context.ide.getCurrentFile();
const inputData: Record<string, string> = {
diff: diff.join("\n"),
input: userInput,
};
if (currentFile) {
inputData.currentFile = currentFile.path;
// A few context providers that don't need to be in config.json to work in .prompt files
if (helpers?.find((helper) => helper[0] === "diff")) {
const diff = await context.ide.getDiff(true);
inputData.diff = diff.join("\n");
}
if (helpers?.find((helper) => helper[0] === "currentFile")) {
const currentFile = await context.ide.getCurrentFile();
if (currentFile) {
inputData.currentFile = currentFile.path;
}
}
return renderTemplatedString(

View file

@ -18,7 +18,7 @@ import type {
IdeSettings,
LLMFullCompletionOptions,
ModelDescription,
ModelRoles,
ExperimentalModelRoles,
PromptLog,
RangeInFile,
SerializedContinueConfig,
@ -28,12 +28,7 @@ import type {
ToolCall,
} from "../";
export type OnboardingModes =
| "Local"
| "Best"
| "Custom"
| "Quickstart"
| "LocalAfterFreeTrial";
export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
export interface ListHistoryOptions {
offset?: number;
@ -57,7 +52,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
"config/addModel": [
{
model: SerializedContinueConfig["models"][number];
role?: keyof ModelRoles;
role?: keyof ExperimentalModelRoles;
},
void,
];
@ -191,12 +186,12 @@ export type ToCoreFromIdeOrWebviewProtocol = {
"profiles/switch": [{ id: string }, undefined];
"auth/getAuthUrl": [undefined, { url: string }];
"auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }];
"tools/call": [
{ toolCall: ToolCall; selectedModelTitle: string },
{ contextItems: ContextItem[] },
];
"clipboardCache/add": [{ content: string }, void];
"controlPlane/openUrl": [{ path: string }, void];
"controlPlane/openUrl": [{ path: string; orgSlug: string | undefined }, void];
"controlPlane/listOrganizations": [undefined, OrganizationDescription[]];
};

View file

@ -5,6 +5,7 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js";
export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & {
didChangeSelectedProfile: [{ id: string }, void];
didChangeSelectedOrg: [{ id: string | null }, void];
};
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol & {
didChangeAvailableProfiles: [{ profiles: ProfileDescription[] }, void];

View file

@ -79,10 +79,6 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
navigateTo: [{ path: string; toggle?: boolean }, void];
addModel: [undefined, void];
/**
* @deprecated Use navigateTo with a path instead.
*/
viewHistory: [undefined, void];
focusContinueSessionId: [{ sessionId: string | undefined }, void];
newSession: [undefined, void];
setTheme: [{ theme: any }, void];

View file

@ -21,7 +21,7 @@ export interface IMessenger<
ToProtocol extends IProtocol,
FromProtocol extends IProtocol,
> {
onError(handler: (error: Error) => void): void;
onError(handler: (message: Message, error: Error) => void): void;
send<T extends keyof FromProtocol>(
messageType: T,
data: FromProtocol[T][0],
@ -64,9 +64,9 @@ export class InProcessMessenger<
(message: Message) => any
>();
protected _onErrorHandlers: ((error: Error) => void)[] = [];
protected _onErrorHandlers: ((message: Message, error: Error) => void)[] = [];
onError(handler: (error: Error) => void) {
onError(handler: (message: Message, error: Error) => void) {
this._onErrorHandlers.push(handler);
}

View file

@ -59,6 +59,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
"addAutocompleteModel",
"profiles/switch",
"didChangeSelectedProfile",
"didChangeSelectedOrg",
"tools/call",
"controlPlane/openUrl",
"controlPlane/listOrganizations",

View file

@ -40,4 +40,5 @@ export type ToWebviewFromIdeOrCoreProtocol = {
signInToControlPlane: [undefined, void];
openDialogMessage: ["account", void];
"docs/suggestions": [PackageDocsResult[], void];
"jetbrains/setColors": [Record<string, string>, void];
};

View file

@ -1,4 +1,4 @@
import { ContextItem, ToolExtras } from "..";
import { ContextItem, Tool, ToolExtras } from "..";
import { MCPManagerSingleton } from "../context/mcp";
import { BuiltInToolNames } from "./builtIn";
@ -86,13 +86,18 @@ async function callToolFromUri(
throw new Error(`Failed to call tool: ${toolName}`);
}
return (response.content as any).map((item: any) => {
return (response.content as any).map((item: any): ContextItem => {
if (item.type !== "text") {
throw new Error(
`Continue received item of type "${item.type}" from MCP tool, but currently only supports "text".`,
);
}
return { name: toolName, description: toolName, content: item.text };
return {
name: extras.tool.displayTitle,
description: "Tool output",
content: item.text,
icon: extras.tool.faviconUrl,
};
});
default:
@ -101,10 +106,12 @@ async function callToolFromUri(
}
export async function callTool(
uri: string,
tool: Tool,
args: any,
extras: ToolExtras,
): Promise<ContextItem[]> {
const uri = tool.uri ?? tool.function.name;
switch (uri) {
case BuiltInToolNames.ReadFile:
return await readFileImpl(args, extras);

View file

@ -1,4 +1,4 @@
import { getUriPathBasename } from "../../util/uri";
import { getUriDescription } from "../../util/uri";
import { ToolImpl } from ".";
@ -9,13 +9,16 @@ export const readCurrentlyOpenFileImpl: ToolImpl = async (args, extras) => {
return [];
}
const basename = getUriPathBasename(result.path);
const { relativePathOrBasename, last2Parts, baseName } = getUriDescription(
result.path,
await extras.ide.getWorkspaceDirs(),
);
return [
{
name: "Current file",
description: basename,
content: `\`\`\`${basename}\n${result.contents}\n\`\`\``,
name: `Current file: ${baseName}`,
description: last2Parts,
content: `\`\`\`${relativePathOrBasename}\n${result.contents}\n\`\`\``,
uri: {
type: "file",
value: result.path,

View file

@ -5,7 +5,7 @@ import { ToolImpl } from ".";
export const viewRepoMapImpl: ToolImpl = async (args, extras) => {
const repoMap = await generateRepoMap(extras.llm, extras.ide, {
outputRelativeUriPaths: true,
includeSignatures: false,
includeSignatures: true,
});
return [
{

View file

@ -7,11 +7,16 @@ import {
} from "../config/sharedConfig";
import { getGlobalContextFilePath } from "./paths";
import { SiteIndexingConfig } from "..";
export type GlobalContextType = {
indexingPaused: boolean;
selectedTabAutocompleteModel: string;
lastSelectedProfileForWorkspace: { [workspaceIdentifier: string]: string };
lastSelectedOrgIdForWorkspace: {
[workspaceIdentifier: string]: string | null;
};
/**
* This is needed to handle the case where a JetBrains user has created
* docs embeddings using one provider, and then updates to a new provider.
@ -23,6 +28,7 @@ export type GlobalContextType = {
showConfigUpdateToast: boolean;
isSupportedLanceDbCpuTarget: boolean;
sharedConfig: SharedConfigSchema;
failedDocs: SiteIndexingConfig[];
};
/**

View file

@ -34,10 +34,11 @@ export async function resolveRelativePathInDir(
If no meaninful path match just concatenates to first dir's uri
*/
export async function inferResolvedUriFromRelativePath(
relativePath: string,
_relativePath: string,
ide: IDE,
dirCandidates?: string[],
): Promise<string> {
const relativePath = _relativePath.trim().replaceAll("\\", "/");
const dirs = dirCandidates ?? (await ide.getWorkspaceDirs());
if (dirs.length === 0) {
@ -51,7 +52,7 @@ export async function inferResolvedUriFromRelativePath(
suffixes.push(segments.slice(i).join("/"));
}
// For each suffix, try to find a unique matching directory
// For each suffix, try to find a unique matching dir/file
for (const suffix of suffixes) {
const uris = dirs.map((dir) => ({
dir,
@ -78,6 +79,13 @@ export async function inferResolvedUriFromRelativePath(
}
}
// Sometimes the model will decide to only output the base name or small number of path parts
// in which case we shouldn't create a new file if it matches the current file
const activeFile = await ide.getCurrentFile();
if (activeFile && activeFile.path.endsWith(relativePath)) {
return activeFile.path;
}
// If no unique match found, use the first directory
return joinPathsToUri(dirs[0], relativePath);
}

View file

@ -207,7 +207,7 @@ World
it("should handle strings with only whitespace", () => {
const result = dedent`
`;
expect(result).toBe("");
});
@ -249,9 +249,9 @@ World
it("should handle a string with only one non-empty line", () => {
const result = dedent`
Hello World!
`;
expect(result).toBe("Hello World!");
});
@ -373,11 +373,16 @@ describe("getMarkdownLanguageTagForFile", () => {
expect(getMarkdownLanguageTagForFile("test.py")).toBe("python");
expect(getMarkdownLanguageTagForFile("test.tsx")).toBe("tsx");
expect(getMarkdownLanguageTagForFile("test.java")).toBe("java");
expect(getMarkdownLanguageTagForFile("test.class")).toBe("java");
expect(getMarkdownLanguageTagForFile("test.md")).toBe("markdown");
expect(getMarkdownLanguageTagForFile("test.sh")).toBe("shell");
expect(getMarkdownLanguageTagForFile("test.sql")).toBe("sql");
});
it("should sanitize ranges from the extension", () => {
expect(getMarkdownLanguageTagForFile("test.java (1-5)")).toBe("java");
});
it("should return the extension if not in the known list", () => {
expect(getMarkdownLanguageTagForFile("file.unknownext")).toBe("unknownext");
});

View file

@ -74,6 +74,7 @@ export function getMarkdownLanguageTagForFile(filepath: string): string {
tsx: "tsx",
ts: "typescript",
java: "java",
class:"java", //.class files decompile to Java
go: "go",
rb: "ruby",
rs: "rust",
@ -96,17 +97,28 @@ export function getMarkdownLanguageTagForFile(filepath: string): string {
ps1: "powershell",
};
const ext = filepath.split(".").pop();
const ext = sanitizeExtension(filepath.split(".").pop());
return ext ? (extToLangMap[ext] ?? ext) : "";
}
function sanitizeExtension(ext?: string): string|undefined {
if (ext) {
//ignore ranges in extension eg. "java (11-23)"
const match = ext.match(/^(\S+)\s*(\(.*\))?$/);
if (match) {
ext = match[1];
}
}
return ext;
}
export function copyOf(obj: any): any {
if (obj === null || obj === undefined) {
return obj;
}
return JSON.parse(JSON.stringify(obj));
}
``;
export function deduplicateArray<T>(
array: T[],

View file

@ -11,7 +11,7 @@ export async function isOllamaInstalled(): Promise<boolean> {
});
}
export async function startLocalOllama(ide: IDE): Promise<void> {
export async function startLocalOllama(ide: IDE): Promise<any> {
let startCommand: string | undefined;
switch (process.platform) {
@ -20,16 +20,16 @@ export async function startLocalOllama(ide: IDE): Promise<void> {
break;
case "win32"://Windows
startCommand = `& "ollama app.exe"\n`;
startCommand = "& \"ollama app.exe\"\n";
break;
default: //Linux...
const start_script_path = path.resolve(__dirname, './start_ollama.sh');
const start_script_path = path.resolve(__dirname, "./start_ollama.sh");
if (await ide.fileExists(`file:/${start_script_path}`)) {
startCommand = `set -e && chmod +x ${start_script_path} && ${start_script_path}\n`;
console.log(`Ollama Linux startup script at : ${start_script_path}`);
} else {
ide.showToast("error", `Cannot start Ollama: could not find ${start_script_path}!`)
return ide.showToast("error", `Cannot start Ollama: could not find ${start_script_path}!`)
}
}
if (startCommand) {

View file

@ -18,6 +18,10 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
useImports: true,
transform: true,
showWhateverWeHaveAtXMs: 300,
experimental_includeClipboard: true,
experimental_includeRecentlyVisitedRanges: true,
experimental_includeRecentlyEditedRanges: true,
experimental_includeDiff: true,
};
export const COUNT_COMPLETION_REJECTED_AFTER = 10_000;

View file

@ -377,6 +377,10 @@ export function getEsbuildBinaryPath(): string {
return path.join(getContinueUtilsPath(), "esbuild");
}
export function getStagingEnvironmentDotFilePath(): string {
return path.join(getContinueGlobalPath(), ".staging");
}
export function setupInitialDotContinueDirectory() {
const devDataTypes = [
"chat",

View file

@ -177,3 +177,19 @@ export function getLastNPathParts(filepath: string, n: number): string {
}
return filepath.split(/[\\/]/).slice(-n).join("/");
}
export function getUriDescription(uri: string, dirUriCandidates: string[]) {
const { relativePathOrBasename, foundInDir } = findUriInDirs(
uri,
dirUriCandidates,
);
const baseName = getUriPathBasename(uri);
const last2Parts = getLastNUriRelativePathParts(dirUriCandidates, uri, 2);
return {
uri,
relativePathOrBasename,
foundInDir,
last2Parts,
baseName,
};
}

View file

@ -12,7 +12,7 @@ You can create a project-specific system message by adding a `.continuerules` fi
- If you want concise answers:
```title=.continuerules
Please provide concise answers. Do explain obvious concepts. You can assume that I am knowledgable about most programming topics.
Please provide concise answers. Don't explain obvious concepts. You can assume that I am knowledgable about most programming topics.
```
- If you want to ensure certain practices are followed, for example in React:

View file

@ -1,5 +1,11 @@
# Groq
:::info
Check if your chosen model is still supported by referring to the [model documentation](https://console.groq.com/docs/models). If a model has been deprecated, you may encounter a 404 error when attempting to use it.
:::
Groq provides the fastest available inference for open-source language models, including the entire Llama 3.1 family.
1. Obtain an API key [here](https://console.groq.com/keys)
@ -9,9 +15,9 @@ Groq provides the fastest available inference for open-source language models, i
{
"models": [
{
"title": "Llama 3.1 405b",
"title": "Llama 3.3 70b Versatile",
"provider": "groq",
"model": "llama3.1-405b",
"model": "llama-3.3-70b-versatile",
"apiKey": "<API_KEY>"
}
]

View file

@ -7,7 +7,7 @@ Azure AI Foundry is a cloud-based service that provides access to models from Op
:::info
For details on OpenAI model setup, see [Azure OpenAI Service configuration](#general-model-configuration).
For details on OpenAI model setup, see [Azure OpenAI Service configuration](#azure-openai-service-configuration).
:::
@ -22,7 +22,8 @@ We recommend configuring **GPT-4o** as your chat model.
"model": "gpt-4o",
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
"deployment": "<YOUR_DEPLOYMENT_NAME>",
"apiKey": "<MY_API_KEY>" // If you use subscription key, try using Azure gateway to rename it apiKey
"apiKey": "<MY_API_KEY>", // If you use subscription key, try using Azure gateway to rename it apiKey
"apiType": "azure-foundry" // Or "azure-openai" if using OpenAI models
}]
```
@ -46,12 +47,12 @@ We recommend configuring **text-embedding-3-large** as your embeddings model.
```json title="config.json"
"embeddingsProvider": {
"provider": "openai",
"provider": "azure",
"model": "text-embedding-3-large",
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
"deployment": "<YOUR_DEPLOYMENT_NAME>",
"apiType": "azure",
"apiKey": "<MY_API_KEY>"
"apiKey": "<MY_API_KEY>",
"apiType": "azure-foundry" // Or "azure-openai" if using OpenAI models
}
```
@ -66,9 +67,7 @@ Azure OpenAI currently does not offer any reranking models.
If you'd like to use OpenAI models but are concerned about privacy, you can use the Azure OpenAI service, which is GDPR and HIPAA compliant.
:::info[Getting access]
You need to apply for access to the Azure OpenAI service. Response times are typically within a few days.
**[Click here to apply for access to the Azure OpenAI service](https://azure.microsoft.com/en-us/products/ai-services/openai-service)**
[Click here](https://azure.microsoft.com/en-us/products/ai-services/openai-service) to apply for access to the Azure OpenAI service. Response times are typically within a few days.
:::
## Azure OpenAI Service configuration
@ -83,10 +82,11 @@ For example, a Target URI of `https://just-an-example.openai.azure.com/openai/de
{
"title": "GPT-4o Azure",
"model": "gpt-4o",
"provider": "openai",
"provider": "azure",
"apiBase": "https://just-an-example.openai.azure.com",
"deployment": "gpt-4o-july",
"apiVersion": "2023-03-15-preview",
"apiKey": "<MY_API_KEY>"
"apiKey": "<MY_API_KEY>",
"apiType": "azure-openai"
}
```

View file

@ -32,6 +32,12 @@ Ollama is the fastest way to get up and running with local language models. We r
## Groq
:::info
Check if your chosen model is still supported by referring to the [model documentation](https://console.groq.com/docs/models). If a model has been deprecated, you may encounter a 404 error when attempting to use it.
:::
Groq provides the fastest available inference for open-source language models, including the entire Llama 3.1 family.
1. Obtain an API key [here](https://console.groq.com/keys)
@ -41,9 +47,9 @@ Groq provides the fastest available inference for open-source language models, i
{
"models": [
{
"title": "Llama 3.1 405b",
"title": "Llama 3.3 70b Versatile",
"provider": "groq",
"model": "llama3.1-405b",
"model": "llama-3.3-70b-versatile",
"apiKey": "<API_KEY>"
}
]

View file

@ -118,6 +118,12 @@ By default the Continue window is on the left side of VS Code, but it can be dra
If you have entered a valid API key and model, but are still getting a 404 error from OpenAI, this may be because you need to add credits to your billing account. You can do so from the [billing console](https://platform.openai.com/settings/organization/billing/overview). If you just want to check that this is in fact the cause of the error, you can try adding $1 to your account and checking whether the error persists.
### I'm getting a 404 error from OpenRouter
If you have entered a valid API key and model, but are still getting a 404 error from OpenRouter, this may be because models that do not support function calling will return an error to Continue when a request is sent.
Example error:
`HTTP 404 Not Found from https://openrouter.ai/api/v1/chat/completions`
### Indexing issues
If you are having persistent errors with indexing, our recommendation is to rebuild your index from scratch. Note that for large codebases this may take some time.

View file

@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
pluginName=continue-intellij-extension
pluginRepositoryUrl=https://github.com/continuedev/continue
# SemVer format -> https://semver.org
pluginVersion=0.0.87
pluginVersion=0.0.91
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=223
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension

View file

@ -113,7 +113,8 @@ class NewContinueSessionAction : AnAction() {
class ViewHistoryAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val continuePluginService = getContinuePluginService(e.project) ?: return
continuePluginService.sendToWebview("viewHistory", null)
val params = mapOf("path" to "/history", "toggle" to true)
continuePluginService.sendToWebview("navigateTo", params)
}
}

View file

@ -37,6 +37,7 @@ import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
import com.intellij.ide.ui.LafManagerListener
fun showTutorial(project: Project) {
val tutorialFileName = getTutorialFileName()
@ -47,7 +48,15 @@ fun showTutorial(project: Project) {
throw IOException("Resource not found: $tutorialFileName")
}
var content = StreamUtil.readText(`is`, StandardCharsets.UTF_8)
// All jetbrains will use J instead of L
content = content.replace("[Cmd + L]", "[Cmd + J]")
content = content.replace("[Cmd + Shift + L]", "[Cmd + Shift + J]")
if (!System.getProperty("os.name").lowercase().contains("mac")) {
content = content.replace("[Cmd + J]", "[Ctrl + J]")
content = content.replace("[Cmd + Shift + J]", "[Ctrl + Shift + J]")
content = content.replace("[Cmd + I]", "[Ctrl + I]")
content = content.replace("⌘", "⌃")
}
val filepath = Paths.get(getContinueGlobalPath(), tutorialFileName).toString()
@ -174,7 +183,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
val changedURIs = events.filterIsInstance<VFileContentChangeEvent>()
.mapNotNull { event -> event.file.toUriOrNull() }
// Send "files/changed" message if there are any content changes
// Notify core of content changes
if (changedURIs.isNotEmpty()) {
val data = mapOf("files" to changedURIs)
continuePluginService.coreMessenger?.request("files/changed", data, null) { _ -> }
@ -182,6 +191,15 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
}
})
// Listen for theme changes
connection.subscribe(LafManagerListener.TOPIC, LafManagerListener {
val colors = GetTheme().getTheme();
continuePluginService.sendToWebview(
"jetbrains/setColors",
colors
)
})
// Listen for clicking settings button to start the auth flow
val authService = service<ContinueAuthService>()
val initialSessionInfo = authService.loadControlPlaneSessionInfo()
@ -196,7 +214,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {
connection.subscribe(AuthListener.TOPIC, object : AuthListener {
override fun startAuthFlow() {
authService.startAuthFlow(project)
authService.startAuthFlow(project, false)
}
override fun handleUpdatedSessionInfo(sessionInfo: ControlPlaneSessionInfo?) {

View file

@ -7,7 +7,8 @@ import javax.swing.JComponent
import javax.swing.JPanel
import java.awt.BorderLayout
class ContinueAuthDialog(private val onTokenEntered: (String) -> Unit) : DialogWrapper(true) {
class ContinueAuthDialog(private val useOnboarding: Boolean, private val onTokenEntered: (String) -> Unit) :
DialogWrapper(true) {
private val tokenField = JBTextField()
init {
@ -17,7 +18,9 @@ class ContinueAuthDialog(private val onTokenEntered: (String) -> Unit) : DialogW
override fun createCenterPanel(): JComponent {
val panel = JPanel(BorderLayout())
panel.add(JBLabel("Please enter your Continue authentication token:"), BorderLayout.NORTH)
val message =
if (useOnboarding) "After onboarding you will be shown an authentication token. Please enter it here:" else "Please enter your Continue authentication token:"
panel.add(JBLabel(message), BorderLayout.NORTH)
panel.add(tokenField, BorderLayout.CENTER)
return panel
}

View file

@ -33,8 +33,18 @@ class ContinueAuthService {
private const val REFRESH_TOKEN_KEY = "ContinueRefreshToken"
private const val ACCOUNT_ID_KEY = "ContinueAccountId"
private const val ACCOUNT_LABEL_KEY = "ContinueAccountLabel"
private const val CONTROL_PLANE_URL = "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app"
// private const val CONTROL_PLANE_URL = "http://localhost:3001"
}
private fun getControlPlaneUrl(): String {
val env = service<ContinueExtensionSettings>().continueState.continueTestEnvironment;
when (env) {
"none" -> return "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app"
"local" -> return "http://localhost:3001"
"production" -> return "https://api.continue.dev"
"test" -> return "https://api-test.continue.dev"
}
return "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app"
}
init {
@ -44,13 +54,13 @@ class ContinueAuthService {
}
}
fun startAuthFlow(project: Project) {
fun startAuthFlow(project: Project, useOnboarding: Boolean) {
// Open login page
openSignInPage(project)
openSignInPage(project, useOnboarding)
// Open a dialog where the user should paste their sign-in token
ApplicationManager.getApplication().invokeLater {
val dialog = ContinueAuthDialog() { token ->
val dialog = ContinueAuthDialog(useOnboarding) { token ->
// Store the token
updateRefreshToken(token)
}
@ -78,10 +88,12 @@ class ContinueAuthService {
val lastName = user?.get("lastName") as? String
val label = "$firstName $lastName"
val id = user?.get("id") as? String
val email = user?.get("email") as? String
// Persist the session info
setRefreshToken(refreshToken!!)
val sessionInfo = ControlPlaneSessionInfo(accessToken!!, ControlPlaneSessionInfo.Account(id!!, label))
val sessionInfo =
ControlPlaneSessionInfo(accessToken!!, ControlPlaneSessionInfo.Account(email!!, label))
setControlPlaneSessionInfo(sessionInfo)
// Notify listeners
@ -111,7 +123,7 @@ class ContinueAuthService {
private suspend fun refreshToken(refreshToken: String) = withContext(Dispatchers.IO) {
val client = OkHttpClient()
val url = URL(CONTROL_PLANE_URL).toURI().resolve("/auth/refresh").toURL()
val url = URL(getControlPlaneUrl()).toURI().resolve("/auth/refresh").toURL()
val jsonBody = mapOf("refreshToken" to refreshToken)
val jsonString = Gson().toJson(jsonBody)
val requestBody = jsonString.toRequestBody("application/json".toMediaType())
@ -132,9 +144,13 @@ class ContinueAuthService {
}
private fun openSignInPage(project: Project) {
private fun openSignInPage(project: Project, useOnboarding: Boolean) {
val coreMessenger = project.service<ContinuePluginService>().coreMessenger
coreMessenger?.request("auth/getAuthUrl", null, null) { response ->
coreMessenger?.request(
"auth/getAuthUrl", mapOf(
"useOnboarding" to useOnboarding
), null
) { response ->
val authUrl = ((response as? Map<*, *>)?.get("content") as? Map<*, *>)?.get("url") as? String
if (authUrl != null) {
// Open the auth URL in the browser
@ -208,7 +224,7 @@ class ContinueAuthService {
val accountId = getAccountId()
val accountLabel = getAccountLabel()
return if (accessToken != null && accountId != null && accountLabel != null) {
return if ((accessToken != null && accessToken != "") && accountId != null && accountLabel != null) {
ControlPlaneSessionInfo(
accessToken = accessToken,
account = ControlPlaneSessionInfo.Account(

View file

@ -3,6 +3,7 @@ package com.github.continuedev.continueintellijextension.autocomplete
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorKind
import com.intellij.openapi.editor.event.*
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.FileEditorManagerEvent
@ -11,6 +12,10 @@ import com.intellij.openapi.util.TextRange
class AutocompleteCaretListener : CaretListener {
override fun caretPositionChanged(event: CaretEvent) {
if(event.editor.editorKind != EditorKind.MAIN_EDITOR) {
return
}
val caret = event.caret ?: return
val offset = caret.offset
val editor = caret.editor

View file

@ -41,6 +41,18 @@ class MessageTypes {
"logoutOfControlPlane",
"getTerminalContents",
"showToast",
"openUrl",
// These only come from the GUI for now but should be here to prevent confusion
"toggleDevTools",
"showTutorial",
// These are jetbrains only and only come from the GUI for now
// But again including for consistency
"copyText",
"jetbrains/isOSREnabled",
"jetbrains/getColors",
"jetbrains/onLoad"
)
// Note: If updating these values, make a corresponding update in
@ -116,6 +128,7 @@ class MessageTypes {
"addAutocompleteModel",
"profiles/switch",
"didChangeSelectedProfile",
"didChangeSelectedOrg",
"tools/call",
"controlPlane/openUrl",
"controlPlane/listOrganizations"

View file

@ -1,15 +1,12 @@
package com.github.continuedev.continueintellijextension.`continue`
import com.intellij.codeInsight.template.impl.TemplateColors
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
import com.intellij.openapi.editor.colors.EditorColors
import com.intellij.openapi.editor.colors.EditorColorsManager
import com.intellij.openapi.editor.colors.EditorColorsScheme
import com.intellij.openapi.editor.colors.TextAttributesKey
import java.awt.Color
import kotlin.math.max
import kotlin.math.min
import com.intellij.ui.JBColor
import com.intellij.ui.ColorUtil
class GetTheme {
fun getSecondaryDark(): Color {
@ -42,53 +39,60 @@ class GetTheme {
}
fun getTheme(): Map<String, String> {
fun toHex(color: Color): String {
return String.format("#%02x%02x%02x", color.red, color.green, color.blue)
}
try {
val globalScheme = EditorColorsManager.getInstance().globalScheme
val defaultBackground = globalScheme.defaultBackground
val defaultForeground = globalScheme.defaultForeground
val highlight = globalScheme.getColor(EditorColors.MODIFIED_TAB_ICON_COLOR) ?: defaultForeground
val defaultBackgroundHex =
String.format("#%02x%02x%02x", defaultBackground.red, defaultBackground.green, defaultBackground.blue)
val defaultForegroundHex =
String.format("#%02x%02x%02x", defaultForeground.red, defaultForeground.green, defaultForeground.blue)
val highlightHex = String.format("#%02x%02x%02x", highlight.red, highlight.green, highlight.blue)
val background = JBColor.background()
val foreground = JBColor.foreground()
val grayscale =
(defaultBackground.red * 0.3 + defaultBackground.green * 0.59 + defaultBackground.blue * 0.11).toInt()
val buttonBackground = JBColor.namedColor("Button.background", Color(230, 230, 230))
val buttonForeground = JBColor.namedColor("Button.foreground", Color(0, 0, 0))
val adjustedRed: Int
val adjustedGreen: Int
val adjustedBlue: Int
val badgeBackground = JBColor.namedColor("Badge.background", Color(150, 150, 150))
val badgeForeground = JBColor.namedColor("Badge.foreground", Color(0, 0, 0))
val tint: Int = 20
if (grayscale > 128) { // if closer to white
adjustedRed = max(0, defaultBackground.red - tint)
adjustedGreen = max(0, defaultBackground.green - tint)
adjustedBlue = max(0, defaultBackground.blue - tint)
} else { // if closer to black
adjustedRed = min(255, defaultBackground.red + tint)
adjustedGreen = min(255, defaultBackground.green + tint)
adjustedBlue = min(255, defaultBackground.blue + tint)
}
val inputBackground = JBColor.namedColor("TextField.background", Color(255, 255, 255))
val secondaryDarkHex = String.format("#%02x%02x%02x", adjustedRed, adjustedGreen, adjustedBlue)
val border = JBColor.border()
val focusBorder = JBColor.namedColor("Focus.borderColor", Color(100, 100, 255))
val editorScheme = EditorColorsManager.getInstance().globalScheme
return mapOf(
"--vscode-editor-foreground" to defaultForegroundHex,
"--vscode-sideBar-background" to defaultBackgroundHex,
"--vscode-input-background" to secondaryDarkHex,
"--vscode-editor-background" to defaultBackgroundHex,
"--vscode-button-background" to defaultBackgroundHex,
"--vscode-list-activeSelectionBackground" to defaultBackgroundHex,
"--vscode-focusBorder" to highlightHex,
"--vscode-quickInputList-focusForeground" to defaultForegroundHex,
"--vscode-quickInput-background" to secondaryDarkHex,
"--vscode-input-border" to "#80808080",
"--vscode-badge-background" to highlightHex,
"--vscode-badge-foreground" to defaultForegroundHex,
"--vscode-sideBar-border" to "#80808080"
val editorBackground = editorScheme.defaultBackground
val editorForeground = editorScheme.defaultForeground
val actionHoverBackground = JBColor.namedColor("ActionButton.hoverBackground", Color(220, 220, 220))
val findMatchBackground = editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor ?: Color(255, 221, 0)
val theme = mapOf(
"--vscode-editor-foreground" to toHex(editorForeground),
"--vscode-editor-background" to toHex(editorBackground),
"--vscode-button-background" to toHex(buttonBackground),
"--vscode-button-foreground" to toHex(buttonForeground),
"--vscode-list-activeSelectionBackground" to toHex(actionHoverBackground) + "50",
"--vscode-quickInputList-focusForeground" to toHex(foreground),
"--vscode-quickInput-background" to toHex(inputBackground),
"--vscode-badge-background" to toHex(badgeBackground),
"--vscode-badge-foreground" to toHex(badgeForeground),
"--vscode-input-background" to toHex(inputBackground),
"--vscode-input-border" to toHex(border),
"--vscode-sideBar-background" to toHex(background),
"--vscode-sideBar-border" to toHex(border),
"--vscode-focusBorder" to toHex(focusBorder),
"--vscode-commandCenter-activeBorder" to toHex(focusBorder),
"--vscode-commandCenter-inactiveBorder" to toHex(border),
"--vscode-editor-findMatchHighlightBackground" to toHex(findMatchBackground) + "40"
)
return theme
} catch (error: Error) {
return mapOf()
}

View file

@ -43,27 +43,12 @@ class IdeProtocolClient(
)
}
private fun send(messageType: String, data: Any?, messageId: String? = null) {
val id = messageId ?: uuid()
continuePluginService.sendToWebview(messageType, data, id)
}
fun handleMessage(msg: String, respond: (Any?) -> Unit) {
coroutineScope.launch(Dispatchers.IO) {
val message = Gson().fromJson(msg, Message::class.java)
val messageType = message.messageType
val dataElement = message.data
// A couple oddball messages respond directly to GUI, expect a different message format
// e.g. jetbrains/isOSREnabled
fun respondToWebview(content: Any) {
respond(mutableMapOf(
"done" to true,
"status" to "success",
"content" to content
))
}
try {
when (messageType) {
"toggleDevTools" -> {
@ -77,12 +62,12 @@ class IdeProtocolClient(
"jetbrains/isOSREnabled" -> {
val isOSREnabled =
ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR
respondToWebview(isOSREnabled)
respond(isOSREnabled)
}
"jetbrains/getColors" -> {
val colors = GetTheme().getTheme();
respondToWebview(colors)
respond(colors)
}
"jetbrains/onLoad" -> {
@ -92,7 +77,7 @@ class IdeProtocolClient(
"vscMachineId" to getMachineUniqueID(),
"vscMediaUrl" to "http://continue",
)
respondToWebview(jsonData)
respond(jsonData)
}
"getIdeSettings" -> {
@ -111,7 +96,7 @@ class IdeProtocolClient(
val sessionInfo = authService.loadControlPlaneSessionInfo()
respond(sessionInfo)
} else {
authService.startAuthFlow(project)
authService.startAuthFlow(project, params.useOnboarding)
respond(null)
}
}
@ -121,6 +106,10 @@ class IdeProtocolClient(
authService.signOut()
ApplicationManager.getApplication().messageBus.syncPublisher(AuthListener.TOPIC)
.handleUpdatedSessionInfo(null)
// Tell the webview that session info changed
continuePluginService.sendToWebview("didChangeControlPlaneSessionInfo", null, uuid())
respond(null)
}
@ -593,11 +582,11 @@ class IdeProtocolClient(
fun sendAcceptRejectDiff(accepted: Boolean, stepIndex: Int) {
send("acceptRejectDiff", AcceptRejectDiff(accepted, stepIndex), uuid())
continuePluginService.sendToWebview("acceptRejectDiff", AcceptRejectDiff(accepted, stepIndex), uuid())
}
fun deleteAtIndex(index: Int) {
send("deleteAtIndex", DeleteAtIndex(index), uuid())
continuePluginService.sendToWebview("deleteAtIndex", DeleteAtIndex(index), uuid())
}
private fun getModelByRole(

View file

@ -6,6 +6,7 @@ import com.github.continuedev.continueintellijextension.utils.OS
import com.github.continuedev.continueintellijextension.utils.getMachineUniqueID
import com.github.continuedev.continueintellijextension.utils.getOS
import com.github.continuedev.continueintellijextension.utils.toUriOrNull
import com.google.gson.Gson
import com.intellij.codeInsight.daemon.impl.HighlightInfo
import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.util.ExecUtil
@ -31,6 +32,10 @@ import com.intellij.psi.PsiDocumentManager
import com.intellij.testFramework.LightVirtualFile
import com.intellij.util.containers.toArray
import kotlinx.coroutines.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import java.awt.Desktop
import java.awt.Toolkit
import java.awt.datatransfer.DataFlavor
@ -39,6 +44,7 @@ import java.io.File
import java.io.FileInputStream
import java.io.InputStreamReader
import java.net.URI
import java.net.URL
import java.nio.charset.Charset
import java.nio.file.Paths
@ -85,14 +91,50 @@ class IntelliJIDE(
)
}
suspend fun enableHubContinueDev(): Boolean {
try {
val client = OkHttpClient()
val url = URL("https://api.continue.dev/features/hub")
val request = Request.Builder()
.url(url)
.get()
.header("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()
val responseBody = response.body?.string()
val gson = Gson()
val responseMap = gson.fromJson(responseBody, Map::class.java)
if (responseMap["enabled"] == true) {
return true
}
} catch (e: Exception) {
return false
}
return false
}
override suspend fun getIdeSettings(): IdeSettings {
val settings = service<ContinueExtensionSettings>()
var continueTestEnvironment = settings.continueState.continueTestEnvironment
if (continueTestEnvironment != "production") {
val enableHub = enableHubContinueDev()
if (enableHub) {
continueTestEnvironment = "production"
}
}
return IdeSettings(
remoteConfigServerUrl = settings.continueState.remoteConfigServerUrl,
remoteConfigSyncPeriod = settings.continueState.remoteConfigSyncPeriod,
userToken = settings.continueState.userToken ?: "",
enableControlServerBeta = settings.continueState.enableContinueTeamsBeta,
continueTestEnvironment = continueTestEnvironment,
pauseCodebaseIndexOnStart = false, // TODO: Needs to be implemented
)
}

View file

@ -29,7 +29,6 @@ import java.awt.geom.AffineTransform
import java.awt.geom.Path2D
import java.awt.geom.RoundRectangle2D
import javax.swing.*
import javax.swing.border.EmptyBorder
import javax.swing.event.DocumentEvent
import javax.swing.event.DocumentListener
import javax.swing.event.ListDataListener
@ -73,8 +72,8 @@ fun makePanel(
onReject: () -> Unit
): JPanel {
val topPanel =
ShadowPanel(MigLayout("wrap 1, insets 2 ${leftInset} 2 2, gap 0!")).apply {
background = JBColor(0x20888888.toInt(), 0x20888888.toInt())
ShadowPanel(MigLayout("wrap 1, insets 2 $leftInset 2 2, gap 0!")).apply {
background = JBColor(0x20888888, 0x20888888)
isOpaque = false
}
@ -374,7 +373,7 @@ class CustomPanel(
val closeIcon = IconLoader.getIcon("/icons/close.svg", javaClass)
return JLabel(closeIcon).apply {
background = Color(0, 0, 0, 0)
border = EmptyBorder(2, 6, 2, 0)
border = JBUI.Borders.empty(2, 6, 2, 0)
toolTipText = "`esc` to cancel"
isOpaque = false
addMouseListener(
@ -406,7 +405,7 @@ class CustomPanel(
background = defaultBackground
foreground = Color(128, 128, 128, 200)
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 12)
border = EmptyBorder(8, 8, 8, 8)
border = JBUI.Borders.empty(8)
isOpaque = false
isEditable = false
cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
@ -423,7 +422,7 @@ class CustomPanel(
val component =
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus)
if (component is JLabel) {
component.border = EmptyBorder(4, 6, 4, 6)
component.border = JBUI.Borders.empty(4, 6)
}
return component
}
@ -451,9 +450,9 @@ class CustomPanel(
val rightButton =
CustomButton("⏎ Enter") { onEnter() }
.apply {
background = JBColor(0x999998.toInt(), 0x999998.toInt())
foreground = JBColor(0xF5F5F5.toInt(), 0xF5F5F5.toInt())
border = EmptyBorder(2, 6, 2, 6)
background = globalScheme.defaultForeground
foreground = globalScheme.defaultBackground
border = JBUI.Borders.empty(2, 6)
}
val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply {
@ -461,7 +460,7 @@ class CustomPanel(
add(rightButton, "align right")
}
border = EmptyBorder(0, 0, 16, 12)
border = JBUI.Borders.empty(0, 0, 16, 12)
isOpaque = false
add(dropdown, "align left")
@ -477,7 +476,7 @@ class CustomPanel(
val progressBar = JProgressBar().apply { isIndeterminate = true }
add(progressBar, BorderLayout.CENTER)
border = BorderFactory.createEmptyBorder(0, 0, 16, 12)
border = JBUI.Borders.empty(0, 0, 16, 12)
}
private val subPanelC: JPanel =
@ -486,21 +485,19 @@ class CustomPanel(
JLabel("Type to re-prompt").apply {
foreground = Color(156, 163, 175) // text-gray-400
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11)
border = EmptyBorder(0, 4, 0, 0)
border = JBUI.Borders.emptyLeft(4)
}
val leftButton =
CustomButton("Reject All (${getMetaKeyLabel()}${getShiftKeyLabel()}⌫)") { onReject() }
.apply {
background = JBColor(0x30FF0000.toInt(), 0x30FF0000.toInt())
foreground = JBColor(0xF5F5F5.toInt(), 0xF5F5F5.toInt())
background = JBColor(0x30FF0000, 0x30FF0000)
}
val rightButton =
CustomButton("Accept All (${getMetaKeyLabel()}${getShiftKeyLabel()}⏎)") { onAccept() }
.apply {
background = JBColor(0x3000FF00.toInt(), 0x3000FF00.toInt())
foreground = JBColor(0xF5F5F5.toInt(), 0xF5F5F5.toInt())
background = JBColor(0x3000FF00, 0x3000FF00)
}
val rightPanel =
@ -508,12 +505,12 @@ class CustomPanel(
isOpaque = false
add(leftButton, "align right")
add(rightButton, "align right")
border = EmptyBorder(0, 0, 0, 0)
border = JBUI.Borders.empty()
}
add(leftLabel, "align left")
add(rightPanel, "align right")
border = BorderFactory.createEmptyBorder(0, 0, 16, 12)
border = JBUI.Borders.empty(0, 0, 16, 12)
isOpaque = false
}
@ -625,7 +622,7 @@ class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) {
})
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11)
border = EmptyBorder(2, 6, 2, 6)
border = JBUI.Borders.empty(2, 6)
}
override fun paintComponent(g: Graphics) {
@ -694,7 +691,7 @@ class TransparentArrowButtonUI : BasicComboBoxUI() {
}
override fun getInsets(): Insets {
return JBUI.insets(0, 6, 0, 0)
return JBUI.insetsLeft(6)
}
override fun installUI(c: JComponent?) {

View file

@ -13,8 +13,8 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import com.intellij.ui.JBColor
import com.intellij.util.application
import com.intellij.util.ui.JBUI
import java.awt.*
import javax.swing.BorderFactory
import javax.swing.JButton
import javax.swing.JTextArea
import kotlin.math.min
@ -25,8 +25,8 @@ class VerticalDiffBlock(
var startLine: Int,
private val onAcceptReject: (VerticalDiffBlock, Boolean) -> Unit
) {
val deletedLines: MutableList<String> = mutableListOf();
val addedLines: MutableList<String> = mutableListOf();
val deletedLines: MutableList<String> = mutableListOf()
val addedLines: MutableList<String> = mutableListOf()
private val acceptButton: JButton
private val rejectButton: JButton
private var deletionInlay: Disposable? = null
@ -155,10 +155,10 @@ class VerticalDiffBlock(
val rejectBtn =
createButton(
"${getAltKeyLabel()}${getShiftKeyLabel()}N",
JBColor(0x99FF0000.toInt(), 0x99FF0000.toInt())
JBColor(0x77FF0000, 0x77FF0000)
).apply {
addActionListener {
handleReject();
handleReject()
onAcceptReject(this@VerticalDiffBlock, false)
}
@ -168,10 +168,10 @@ class VerticalDiffBlock(
createButton(
"${getAltKeyLabel()}${
getShiftKeyLabel()
}Y", JBColor(0x7700BB00.toInt(), 0x7700BB00.toInt())
}Y", JBColor(0x7700BB00, 0x7700BB00)
).apply {
addActionListener {
handleAccept();
handleAccept()
onAcceptReject(this@VerticalDiffBlock, true)
}
}
@ -217,9 +217,9 @@ class VerticalDiffBlock(
private fun createDeletionTextArea(text: String) = JTextArea(text).apply {
isEditable = false
background = JBColor(0x30FF0000.toInt(), 0x30FF0000.toInt())
background = JBColor(0x30FF0000, 0x30FF0000)
foreground = JBColor.GRAY
border = BorderFactory.createEmptyBorder()
border = JBUI.Borders.empty()
lineWrap = false
wrapStyleWord = false
font = editor.colorsScheme.getFont(EditorFontType.PLAIN)
@ -252,7 +252,7 @@ class VerticalDiffBlock(
font = Font("Arial", Font.BOLD, 9)
isContentAreaFilled = false
isOpaque = false
border = BorderFactory.createEmptyBorder(4, 2, 4, 2)
border = JBUI.Borders.empty(4, 2)
preferredSize = Dimension(preferredSize.width - 30, 14)
cursor = Cursor(Cursor.HAND_CURSOR)
}

View file

@ -2,7 +2,7 @@ package com.github.continuedev.continueintellijextension.protocol
import com.github.continuedev.continueintellijextension.*
data class GetControlPlaneSessionInfoParams(val silent: Boolean)
data class GetControlPlaneSessionInfoParams(val silent: Boolean, val useOnboarding: Boolean)
data class WriteFileParams(
val path: String,

View file

@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.services
import com.github.continuedev.continueintellijextension.constants.getConfigJsPath
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
import com.intellij.execution.target.value.constant
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
@ -33,6 +34,7 @@ class ContinueSettingsComponent : DumbAware {
val enableOSR: JCheckBox = JCheckBox("Enable Off-Screen Rendering")
val displayEditorTooltip: JCheckBox = JCheckBox("Display Editor Tooltip")
val showIDECompletionSideBySide: JCheckBox = JCheckBox("Show IDE completions side-by-side")
val enableContinueHub: JCheckBox = JCheckBox("Enable Continue Hub")
init {
val constraints = GridBagConstraints()
@ -66,6 +68,8 @@ class ContinueSettingsComponent : DumbAware {
constraints.gridy++
panel.add(showIDECompletionSideBySide, constraints)
constraints.gridy++
panel.add(enableContinueHub, constraints)
constraints.gridy++
// Add a "filler" component that takes up all remaining vertical space
constraints.weighty = 1.0
@ -98,6 +102,7 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
var enableOSR: Boolean = shouldRenderOffScreen()
var displayEditorTooltip: Boolean = true
var showIDECompletionSideBySide: Boolean = false
var continueTestEnvironment: String = "none"
}
var continueState: ContinueState = ContinueState()
@ -211,7 +216,8 @@ class ContinueExtensionConfigurable : Configurable {
mySettingsComponent?.enableContinueTeamsBeta?.isSelected != settings.continueState.enableContinueTeamsBeta ||
mySettingsComponent?.enableOSR?.isSelected != settings.continueState.enableOSR ||
mySettingsComponent?.displayEditorTooltip?.isSelected != settings.continueState.displayEditorTooltip ||
mySettingsComponent?.showIDECompletionSideBySide?.isSelected != settings.continueState.showIDECompletionSideBySide
mySettingsComponent?.showIDECompletionSideBySide?.isSelected != settings.continueState.showIDECompletionSideBySide ||
(if (mySettingsComponent?.enableContinueHub?.isSelected == true) settings.continueState.continueTestEnvironment != "production" else settings.continueState.continueTestEnvironment == "production")
return modified
}
@ -227,6 +233,8 @@ class ContinueExtensionConfigurable : Configurable {
settings.continueState.displayEditorTooltip = mySettingsComponent?.displayEditorTooltip?.isSelected ?: true
settings.continueState.showIDECompletionSideBySide =
mySettingsComponent?.showIDECompletionSideBySide?.isSelected ?: false
settings.continueState.continueTestEnvironment =
if (mySettingsComponent?.enableContinueHub?.isSelected == true) "production" else "none"
ApplicationManager.getApplication().messageBus.syncPublisher(SettingsListener.TOPIC)
.settingsUpdated(settings.continueState)
@ -244,6 +252,8 @@ class ContinueExtensionConfigurable : Configurable {
mySettingsComponent?.displayEditorTooltip?.isSelected = settings.continueState.displayEditorTooltip
mySettingsComponent?.showIDECompletionSideBySide?.isSelected =
settings.continueState.showIDECompletionSideBySide
mySettingsComponent?.enableContinueHub?.isSelected =
settings.continueState.continueTestEnvironment == "production"
ContinueExtensionSettings.instance.addRemoteSyncJob()
}

View file

@ -53,7 +53,6 @@ class ContinueBrowser(val project: Project, url: String) {
ContinuePluginService::class.java
)
val respond = fun(data: Any?) {
sendToWebview(messageType, data, messageId ?: uuid())
}
@ -63,8 +62,18 @@ class ContinueBrowser(val project: Project, url: String) {
return@addHandler null
}
// If not pass through, then put it in the status/content/done format for webview
// Core already sends this format
val respondToWebview = fun(data: Any?) {
sendToWebview(messageType, mapOf(
"status" to "success",
"content" to data,
"done" to true
), messageId ?: uuid())
}
if (msg != null) {
continuePluginService.ideProtocolClient?.handleMessage(msg, respond)
continuePluginService.ideProtocolClient?.handleMessage(msg, respondToWebview)
}
null

View file

@ -88,6 +88,7 @@ data class IdeSettings(
val userToken: String,
val enableControlServerBeta: Boolean,
val pauseCodebaseIndexOnStart: Boolean,
val continueTestEnvironment: String
)
data class ContinueRcJson(

View file

@ -1,17 +1,24 @@
/* _________ _____ _____
__ ____/______ _______ __ /____(_)_______ ____ _______
_ / _ __ \__ __ \_ __/__ / __ __ \_ / / /_ _ \
/ /___ / /_/ /_ / / // /_ _ / _ / / // /_/ / / __/
\____/ \____/ /_/ /_/ \__/ /_/ /_/ /_/ \__,_/ \___/
// _________ _____ _____
// __ ____/______ _______ __ /____(_)_______ ____ _______
// _ / _ __ \__ __ \_ __/__ / __ __ \_ / / /_ _ \
// / /___ / /_/ /_ / / // /_ _ / _ / / // /_/ / / __/
// \____/ \____/ /_/ /_/ \__/ /_/ /_/ /_/ \__,_/ \___/
//
// Chat, Edit, and Autocomplete tutorial
//
Chat, Edit, and Autocomplete tutorial
*/
// ———————————————————————————————————————————————— Setup ————————————————————————————————————————————————-
// First, open the Continue sidebar by pressing [Cmd + L] or clicking the Continue icon.
/* ————————————————————————————————————————————————— Chat ————————————————————————————————————————————————— */
// See an example at https://docs.continue.dev/getting-started/install
// Follow the instructions in the sidebar to set up a Chat/Edit modela and an Autocomplete model.
// ————————————————————————————————————————————————— Chat —————————————————————————————————————————————————
// Highlight the code below
// Press [Cmd/Ctrl + J] to add to Chat
// Press [Cmd + L] to add to Chat
// Try asking Continue "what sorting algorithm is this?"
public static int[] sortingAlgorithm(int[] x) {
for (int i = 0; i < x.length; i++) {
@ -26,10 +33,13 @@ public static int[] sortingAlgorithm(int[] x) {
return x;
}
/* ————————————————————————————————————————————————— Edit ————————————————————————————————————————————————— */
// [Cmd + L] always starts a new chat. Now, try the same thing using [Cmd + Shift + L].
// This will add the code into the current chat
// ————————————————————————————————————————————————— Edit —————————————————————————————————————————————————
// Highlight the code below
// Press [Cmd/Ctrl + I] to Edit
// Press [Cmd + I] to Edit
// Try asking Continue to "make this more readable"
public static int[] sortingAlgorithm2(int[] x) {
for (int i = 0; i < x.length; i++) {
@ -44,12 +54,15 @@ public static int[] sortingAlgorithm2(int[] x) {
return x;
}
/* ————————————————————————————————————————————— Autocomplete —————————————————————————————————————————————— */
// ————————————————————————————————————————————— Autocomplete ——————————————————————————————————————————————
// Place cursor after `sortingAlgorithm...` below and press [Enter]
// Place cursor after `sortingAlgorithm:` below and press [Enter]
// Press [Tab] to accept the Autocomplete suggestion
// Basic assertion for sortingAlgorithm...
// Basic assertion for sortingAlgorithm:
/* —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— */
// —————————————————————————————————————————————- Learn More -——————————————————————————————————————————————
// Visit the Continue Docs at https://docs.continue.dev/getting-started/overview

View file

@ -7,11 +7,18 @@
Chat, Edit, and Autocomplete tutorial
"""
# ———————————————————————————————————————————————— Setup ————————————————————————————————————————————————-
# ————————————————————————————————————————————————— Chat ————————————————————————————————————————————————— #
# First, open the Continue sidebar by pressing [Cmd + L] or clicking the Continue icon.
# See an example at https://docs.continue.dev/getting-started/install
# Follow the instructions in the sidebar to set up a Chat/Edit modela and an Autocomplete model.
# ————————————————————————————————————————————————— Chat —————————————————————————————————————————————————
## Highlight the code below
## Press [Cmd/Ctrl + J] to add to Chat
## Press [Cmd + L] to add to Chat
## Try asking Continue "what sorting algorithm is this?"
def sorting_algorithm(x):
for i in range(len(x)):
@ -20,11 +27,13 @@ def sorting_algorithm(x):
x[j], x[j + 1] = x[j + 1], x[j]
return x
# [Cmd + L] always starts a new chat. Now, try the same thing using [Cmd + Shift + L].
# This will add the code into the current chat
# ————————————————————————————————————————————————— Edit ————————————————————————————————————————————————— #
# ————————————————————————————————————————————————— Edit —————————————————————————————————————————————————
## Highlight the code below
## Press [Cmd/Ctrl + I] to Edit
## Press [Cmd + I] to Edit
## Try asking Continue to "make this more readable"
def sorting_algorithm(x):
for i in range(len(x)):
@ -33,12 +42,16 @@ def sorting_algorithm(x):
x[j], x[j + 1] = x[j + 1], x[j]
return x
# ————————————————————————————————————————————— Autocomplete —————————————————————————————————————————————— #
# ————————————————————————————————————————————— Autocomplete ——————————————————————————————————————————————
## Place cursor after `sorting_algorithm...` below and press [Enter]
## Place cursor after `sorting_algorithm:` below and press [Enter]
## Press [Tab] to accept the Autocomplete suggestion
# Basic assertion for sorting_algorithm...
# Basic assertion for sorting_algorithm:
# —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— #
# —————————————————————————————————————————————- Learn More -——————————————————————————————————————————————
# Visit the Continue Docs at https://docs.continue.dev/getting-started/overview

View file

@ -1,17 +1,24 @@
/* _________ _____ _____
__ ____/______ _______ __ /____(_)_______ ____ _______
_ / _ __ \__ __ \_ __/__ / __ __ \_ / / /_ _ \
/ /___ / /_/ /_ / / // /_ _ / _ / / // /_/ / / __/
\____/ \____/ /_/ /_/ \__/ /_/ /_/ /_/ \__,_/ \___/
// _________ _____ _____
// __ ____/______ _______ __ /____(_)_______ ____ _______
// _ / _ __ \__ __ \_ __/__ / __ __ \_ / / /_ _ \
// / /___ / /_/ /_ / / // /_ _ / _ / / // /_/ / / __/
// \____/ \____/ /_/ /_/ \__/ /_/ /_/ /_/ \__,_/ \___/
//
// Chat, Edit, and Autocomplete tutorial
//
Chat, Edit, and Autocomplete tutorial
*/
// ———————————————————————————————————————————————— Setup ————————————————————————————————————————————————-
// First, open the Continue sidebar by pressing [Cmd + L] or clicking the Continue icon.
/* ————————————————————————————————————————————————— Chat ————————————————————————————————————————————————— */
// See an example at https://docs.continue.dev/getting-started/install
// Follow the instructions in the sidebar to set up a Chat/Edit modela and an Autocomplete model.
// ————————————————————————————————————————————————— Chat —————————————————————————————————————————————————
// Highlight the code below
// Press [Cmd/Ctrl + J] to add to Chat
// Press [Cmd + L] to add to Chat
// Try asking Continue "what sorting algorithm is this?"
function sortingAlgorithm(x: number[]): number[] {
for (let i = 0; i < x.length; i++) {
@ -26,10 +33,13 @@ function sortingAlgorithm(x: number[]): number[] {
return x;
}
/* ————————————————————————————————————————————————— Edit ————————————————————————————————————————————————— */
// [Cmd + L] always starts a new chat. Now, try the same thing using [Cmd + Shift + L].
// This will add the code into the current chat
// ————————————————————————————————————————————————— Edit —————————————————————————————————————————————————
// Highlight the code below
// Press [Cmd/Ctrl + I] to Edit
// Press [Cmd + I] to Edit
// Try asking Continue to "make this more readable"
function sortingAlgorithm2(x: number[]): number[] {
for (let i = 0; i < x.length; i++) {
@ -44,12 +54,13 @@ function sortingAlgorithm2(x: number[]): number[] {
return x;
}
/* ————————————————————————————————————————————— Autocomplete —————————————————————————————————————————————— */
// ————————————————————————————————————————————— Autocomplete ——————————————————————————————————————————————
// Place cursor after `sortingAlgorithm...` below and press [Enter]
// Place cursor after `sortingAlgorithm:` below and press [Enter]
// Press [Tab] to accept the Autocomplete suggestion
// Basic assertion for sortingAlgorithm...
// Basic assertion for sortingAlgorithm:
// —————————————————————————————————————————————- Learn More -——————————————————————————————————————————————
/* —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— */
// Visit the Continue Docs at https://docs.continue.dev/getting-started/overview

View file

@ -936,7 +936,8 @@
"gemini-1.5-flash-latest",
"gemini-1.5-flash",
"gemini-1.5-flash-8b",
"gemini-2.0-flash-exp"
"gemini-2.0-flash-exp",
"gemini-2.0-flash"
]
}
}
@ -998,6 +999,8 @@
"anyOf": [
{
"enum": [
"deepseek-r1",
"deepseek_v3",
"llama3-8b",
"llama3-70b",
"llama3.1-8b",
@ -1680,33 +1683,6 @@
}
]
},
"ModelRoles": {
"title": "ModelRoles",
"type": "object",
"properties": {
"default": {
"title": "Default",
"description": "The default model. If other model roles are not set, they will fall back to default.",
"type": "string"
},
"chat": {
"title": "Chat",
"description": "The model to use for chat. If not set, will fall back to default.",
"type": "string"
},
"edit": {
"title": "Edit",
"description": "The model to use for editing. If not set, will fall back to default.",
"type": "string"
},
"summarize": {
"title": "Summarize",
"description": "The model to use for summarization. If not set, will fall back to default.",
"type": "string"
}
},
"required": ["default"]
},
"SlashCommand": {
"title": "SlashCommand",
"type": "object",

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.9.259",
"version": "0.9.266",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.9.259",
"version": "0.9.266",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/fetch": "^1.0.3",
@ -22,7 +22,7 @@
"dbinfoz": "^0.14.0",
"diff": "^7.0.0",
"downshift": "^7.6.0",
"esbuild": "^0.17.19",
"esbuild": "0.24.0",
"express": "^4.18.2",
"fkill": "^8.1.0",
"follow-redirects": "^1.15.4",
@ -50,7 +50,7 @@
"socket.io-client": "^4.7.2",
"strip-ansi": "^7.1.0",
"svg-builder": "^2.0.0",
"systeminformation": "^5.22.10",
"systeminformation": "^5.23.7",
"tailwindcss": "^3.3.2",
"undici": "^6.2.0",
"uuid": "^9.0.1",
@ -79,7 +79,7 @@
"@vscode/vsce": "^2.22.0",
"cargo-cp-artifact": "^0.1",
"chai": "^4.5.0",
"esbuild": "0.17.19",
"esbuild": "0.24.0",
"esbuild-visualizer": "^0.6.0",
"eslint": "^8.28.0",
"glob": "^8.0.3",
@ -106,11 +106,11 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.23",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",
"@modelcontextprotocol/sdk": "^1.0.0",
"@modelcontextprotocol/sdk": "^1.5.0",
"@mozilla/readability": "^0.5.0",
"@octokit/rest": "^20.0.2",
"@typescript-eslint/eslint-plugin": "^7.8.0",
@ -186,7 +186,7 @@
"@types/uuid": "^9.0.7",
"@types/win-ca": "^3.5.4",
"cross-env": "^7.0.3",
"esbuild": "0.17.19",
"esbuild": "0.24.0",
"eslint": "^8",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
@ -758,10 +758,26 @@
"node": ">=12.13.0"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz",
"integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==",
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz",
"integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.0.tgz",
"integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==",
"cpu": [
"arm"
],
@ -771,13 +787,13 @@
"android"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz",
"integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz",
"integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==",
"cpu": [
"arm64"
],
@ -787,13 +803,13 @@
"android"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz",
"integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.0.tgz",
"integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==",
"cpu": [
"x64"
],
@ -803,13 +819,13 @@
"android"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz",
"integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz",
"integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==",
"cpu": [
"arm64"
],
@ -819,13 +835,13 @@
"darwin"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz",
"integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz",
"integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==",
"cpu": [
"x64"
],
@ -835,13 +851,13 @@
"darwin"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz",
"integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz",
"integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==",
"cpu": [
"arm64"
],
@ -851,13 +867,13 @@
"freebsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz",
"integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz",
"integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==",
"cpu": [
"x64"
],
@ -867,13 +883,13 @@
"freebsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz",
"integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz",
"integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==",
"cpu": [
"arm"
],
@ -883,13 +899,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz",
"integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz",
"integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==",
"cpu": [
"arm64"
],
@ -899,13 +915,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz",
"integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz",
"integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==",
"cpu": [
"ia32"
],
@ -915,13 +931,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz",
"integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz",
"integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==",
"cpu": [
"loong64"
],
@ -931,13 +947,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz",
"integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz",
"integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==",
"cpu": [
"mips64el"
],
@ -947,13 +963,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz",
"integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz",
"integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==",
"cpu": [
"ppc64"
],
@ -963,13 +979,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz",
"integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz",
"integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==",
"cpu": [
"riscv64"
],
@ -979,13 +995,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz",
"integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz",
"integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==",
"cpu": [
"s390x"
],
@ -995,13 +1011,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz",
"integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz",
"integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==",
"cpu": [
"x64"
],
@ -1011,13 +1027,13 @@
"linux"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz",
"integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz",
"integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==",
"cpu": [
"x64"
],
@ -1027,13 +1043,29 @@
"netbsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-arm64": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz",
"integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz",
"integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz",
"integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==",
"cpu": [
"x64"
],
@ -1043,13 +1075,13 @@
"openbsd"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz",
"integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz",
"integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==",
"cpu": [
"x64"
],
@ -1059,13 +1091,13 @@
"sunos"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz",
"integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz",
"integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==",
"cpu": [
"arm64"
],
@ -1075,13 +1107,13 @@
"win32"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz",
"integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz",
"integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==",
"cpu": [
"ia32"
],
@ -1091,13 +1123,13 @@
"win32"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz",
"integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz",
"integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==",
"cpu": [
"x64"
],
@ -1107,7 +1139,7 @@
"win32"
],
"engines": {
"node": ">=12"
"node": ">=18"
}
},
"node_modules/@eslint-community/eslint-utils": {
@ -5320,40 +5352,42 @@
}
},
"node_modules/esbuild": {
"version": "0.17.19",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz",
"integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz",
"integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==",
"dev": true,
"hasInstallScript": true,
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=12"
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/android-arm": "0.17.19",
"@esbuild/android-arm64": "0.17.19",
"@esbuild/android-x64": "0.17.19",
"@esbuild/darwin-arm64": "0.17.19",
"@esbuild/darwin-x64": "0.17.19",
"@esbuild/freebsd-arm64": "0.17.19",
"@esbuild/freebsd-x64": "0.17.19",
"@esbuild/linux-arm": "0.17.19",
"@esbuild/linux-arm64": "0.17.19",
"@esbuild/linux-ia32": "0.17.19",
"@esbuild/linux-loong64": "0.17.19",
"@esbuild/linux-mips64el": "0.17.19",
"@esbuild/linux-ppc64": "0.17.19",
"@esbuild/linux-riscv64": "0.17.19",
"@esbuild/linux-s390x": "0.17.19",
"@esbuild/linux-x64": "0.17.19",
"@esbuild/netbsd-x64": "0.17.19",
"@esbuild/openbsd-x64": "0.17.19",
"@esbuild/sunos-x64": "0.17.19",
"@esbuild/win32-arm64": "0.17.19",
"@esbuild/win32-ia32": "0.17.19",
"@esbuild/win32-x64": "0.17.19"
"@esbuild/aix-ppc64": "0.24.0",
"@esbuild/android-arm": "0.24.0",
"@esbuild/android-arm64": "0.24.0",
"@esbuild/android-x64": "0.24.0",
"@esbuild/darwin-arm64": "0.24.0",
"@esbuild/darwin-x64": "0.24.0",
"@esbuild/freebsd-arm64": "0.24.0",
"@esbuild/freebsd-x64": "0.24.0",
"@esbuild/linux-arm": "0.24.0",
"@esbuild/linux-arm64": "0.24.0",
"@esbuild/linux-ia32": "0.24.0",
"@esbuild/linux-loong64": "0.24.0",
"@esbuild/linux-mips64el": "0.24.0",
"@esbuild/linux-ppc64": "0.24.0",
"@esbuild/linux-riscv64": "0.24.0",
"@esbuild/linux-s390x": "0.24.0",
"@esbuild/linux-x64": "0.24.0",
"@esbuild/netbsd-x64": "0.24.0",
"@esbuild/openbsd-arm64": "0.24.0",
"@esbuild/openbsd-x64": "0.24.0",
"@esbuild/sunos-x64": "0.24.0",
"@esbuild/win32-arm64": "0.24.0",
"@esbuild/win32-ia32": "0.24.0",
"@esbuild/win32-x64": "0.24.0"
}
},
"node_modules/esbuild-visualizer": {
@ -5735,9 +5769,10 @@
"integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw=="
},
"node_modules/express": {
"version": "4.21.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz",
"integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==",
"version": "4.21.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
@ -5758,7 +5793,7 @@
"methods": "~1.1.2",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.10",
"path-to-regexp": "0.1.12",
"proxy-addr": "~2.0.7",
"qs": "6.13.0",
"range-parser": "~1.2.1",
@ -5773,6 +5808,10 @@
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/express/node_modules/debug": {
@ -9098,15 +9137,16 @@
}
},
"node_modules/nanoid": {
"version": "3.3.7",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz",
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"bin": {
"nanoid": "bin/nanoid.cjs"
},
@ -10059,9 +10099,10 @@
}
},
"node_modules/path-to-regexp": {
"version": "0.1.10",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz",
"integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w=="
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
"license": "MIT"
},
"node_modules/path-type": {
"version": "4.0.0",
@ -12168,9 +12209,10 @@
}
},
"node_modules/systeminformation": {
"version": "5.23.5",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.23.5.tgz",
"integrity": "sha512-PEpJwhRYxZgBCAlWZhWIgfMTjXLqfcaZ1pJsJn9snWNfBW/Z1YQg1mbIUSWrEV3ErAHF7l/OoVLQeaZDlPzkpA==",
"version": "5.25.11",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.25.11.tgz",
"integrity": "sha512-jI01fn/t47rrLTQB0FTlMCC+5dYx8o0RRF+R4BPiUNsvg5OdY0s9DKMFmJGrx5SwMZQ4cag0Gl6v8oycso9b/g==",
"license": "MIT",
"os": [
"darwin",
"linux",
@ -12911,9 +12953,10 @@
"dev": true
},
"node_modules/undici": {
"version": "6.20.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.20.1.tgz",
"integrity": "sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA==",
"version": "6.21.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz",
"integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
@ -13309,10 +13352,11 @@
}
},
"node_modules/vite": {
"version": "4.5.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.5.5.tgz",
"integrity": "sha512-ifW3Lb2sMdX+WU91s3R0FyQlAyLxOzCSCP37ujw0+r5POeHPwe6udWVIElKQq8gk3t7b8rkmvqC6IHBpCff4GQ==",
"version": "4.5.9",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.5.9.tgz",
"integrity": "sha512-qK9W4xjgD3gXbC0NmdNFFnVFLMWSNiR3swj957yutwzzN16xF/E7nmtAyp1rT9hviDroQANjE4HK3H4WqWdFtw==",
"dev": true,
"license": "MIT",
"dependencies": {
"esbuild": "^0.18.10",
"postcss": "^8.4.27",

View file

@ -2,7 +2,7 @@
"name": "continue",
"icon": "media/icon.png",
"author": "Continue Dev, Inc",
"version": "0.9.259",
"version": "0.9.266",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"
@ -213,14 +213,14 @@
{
"command": "continue.toggleFullScreen",
"category": "Continue",
"title": "Toggle Full Screen",
"title": "Open in new window",
"icon": "$(link-external)",
"group": "Continue"
},
{
"command": "continue.openConfigPage",
"category": "Continue",
"title": "Open Continue Config",
"title": "Open Settings",
"icon": "$(gear)",
"group": "Continue"
},
@ -580,7 +580,8 @@
{
"type": "webview",
"id": "continue.continueGUIView",
"name": "",
"name": "Continue",
"icon": "media/sidebar-icon.png",
"visibility": "visible"
}
]
@ -623,7 +624,7 @@
"e2e:build": "npm --prefix ../../gui run build && npm run package",
"e2e:create-storage": "mkdir -p ./e2e/storage",
"e2e:get-chromedriver": "extest get-chromedriver --storage ./e2e/storage",
"e2e:get-vscode": "extest get-vscode --storage ./e2e/storage",
"e2e:get-vscode": "CODE_VERSION=\"1.95.0\" extest get-vscode --storage ./e2e/storage",
"e2e:sign-vscode": "codesign --entitlements entitlements.plist --deep --force -s - './e2e/storage/Visual Studio Code.app'",
"e2e:copy-vsix": "chmod +x ./e2e/get-latest-vsix.sh && bash ./e2e/get-latest-vsix.sh",
"e2e:install-vsix": "extest install-vsix -f ./e2e/vsix/continue.vsix --extensions_dir ./e2e/.test-extensions --storage ./e2e/storage",
@ -655,7 +656,7 @@
"@vscode/vsce": "^2.22.0",
"cargo-cp-artifact": "^0.1",
"chai": "^4.5.0",
"esbuild": "0.17.19",
"esbuild": "0.24.0",
"esbuild-visualizer": "^0.6.0",
"eslint": "^8.28.0",
"glob": "^8.0.3",
@ -682,7 +683,7 @@
"dbinfoz": "^0.14.0",
"diff": "^7.0.0",
"downshift": "^7.6.0",
"esbuild": "^0.17.19",
"esbuild": "0.24.0",
"express": "^4.18.2",
"fkill": "^8.1.0",
"follow-redirects": "^1.15.4",
@ -710,7 +711,7 @@
"socket.io-client": "^4.7.2",
"strip-ansi": "^7.1.0",
"svg-builder": "^2.0.0",
"systeminformation": "^5.22.10",
"systeminformation": "^5.23.7",
"tailwindcss": "^3.3.2",
"undici": "^6.2.0",
"uuid": "^9.0.1",

View file

@ -1,12 +1,15 @@
const fs = require("fs");
const ncp = require("ncp").ncp;
const path = require("path");
const ncp = require("ncp").ncp;
const { rimrafSync } = require("rimraf");
const {
validateFilesPresent,
execCmdSync,
autodetectPlatformAndArch,
} = require("../../../scripts/util/index");
const { copyConfigSchema } = require("./utils");
// Clear folders that will be packaged to ensure clean slate
@ -46,6 +49,17 @@ console.log("[info] Using target: ", target);
const exe = os === "win32" ? ".exe" : "";
const isInGitHubAction = !!process.env.GITHUB_ACTIONS;
const isArmTarget =
target === "darwin-arm64" ||
target === "linux-arm64" ||
target === "win32-arm64";
const isWinTarget = target?.startsWith("win");
const isLinuxTarget = target?.startsWith("linux");
const isMacTarget = target?.startsWith("darwin");
(async () => {
console.log("[info] Packaging extension for target ", target);
@ -66,7 +80,7 @@ const exe = os === "win32" ? ".exe" : "";
execCmdSync("npm install");
console.log("[info] npm install in gui completed");
if (ghAction()) {
if (isInGitHubAction) {
execCmdSync("npm run build");
}
@ -222,7 +236,7 @@ const exe = os === "win32" ? ".exe" : "";
"../../../core/llm/llamaTokenizerWorkerPool.mjs",
"../../../core/llm/llamaTokenizer.mjs",
"../../../core/llm/tiktokenWorkerPool.mjs",
"../../../core/util/start_ollama.sh"
"../../../core/util/start_ollama.sh",
];
for (const f of filesToCopy) {
@ -262,22 +276,6 @@ const exe = os === "win32" ? ".exe" : "";
);
});
function ghAction() {
return !!process.env.GITHUB_ACTIONS;
}
function isArm() {
return (
target === "darwin-arm64" ||
target === "linux-arm64" ||
target === "win32-arm64"
);
}
function isWin() {
return target?.startsWith("win");
}
async function installNodeModuleInTempDirAndCopyToCurrent(
packageName,
toCopy,
@ -341,42 +339,40 @@ const exe = os === "win32" ? ".exe" : "";
}
// GitHub Actions doesn't support ARM, so we need to download pre-saved binaries
if (ghAction() && isArm()) {
// sqlite3
if (!isWin()) {
// Neither lancedb nor sqlite3 have pre-built windows arm64 binaries
// 02/07/25 - the above comment is out of date, there is now support for ARM runners on GitHub Actions
if (isInGitHubAction && isArmTarget) {
// lancedb binary
const packageToInstall = {
"darwin-arm64": "@lancedb/vectordb-darwin-arm64",
"linux-arm64": "@lancedb/vectordb-linux-arm64-gnu",
"win32-arm64": "@lancedb/vectordb-win32-arm64-msvc",
}[target];
console.log(
"[info] Downloading pre-built lancedb binary: " + packageToInstall,
);
// lancedb binary
const packageToInstall = {
"darwin-arm64": "@lancedb/vectordb-darwin-arm64",
"linux-arm64": "@lancedb/vectordb-linux-arm64-gnu",
}[target];
console.log(
"[info] Downloading pre-built lancedb binary: " + packageToInstall,
);
await installNodeModuleInTempDirAndCopyToCurrent(
packageToInstall,
"@lancedb",
);
await installNodeModuleInTempDirAndCopyToCurrent(
packageToInstall,
"@lancedb",
);
// Replace the installed with pre-built
console.log("[info] Downloading pre-built sqlite3 binary");
rimrafSync("../../core/node_modules/sqlite3/build");
const downloadUrl = {
"darwin-arm64":
"https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v6-darwin-arm64.tar.gz",
"linux-arm64":
"https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v3-linux-arm64.tar.gz",
}[target];
execCmdSync(
`curl -L -o ../../core/node_modules/sqlite3/build.tar.gz ${downloadUrl}`,
);
execCmdSync(
"cd ../../core/node_modules/sqlite3 && tar -xvzf build.tar.gz",
);
fs.unlinkSync("../../core/node_modules/sqlite3/build.tar.gz");
}
// Replace the installed with pre-built
console.log("[info] Downloading pre-built sqlite3 binary");
rimrafSync("../../core/node_modules/sqlite3/build");
const downloadUrl = {
"darwin-arm64":
"https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v6-darwin-arm64.tar.gz",
"linux-arm64":
"https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v3-linux-arm64.tar.gz",
// node-sqlite3 doesn't have a pre-built binary for win32-arm64
"win32-arm64":
"https://continue-server-binaries.s3.us-west-1.amazonaws.com/win32-arm64/node_sqlite3.tar.gz",
}[target];
execCmdSync(
`curl -L -o ../../core/node_modules/sqlite3/build.tar.gz ${downloadUrl}`,
);
execCmdSync("cd ../../core/node_modules/sqlite3 && tar -xvzf build.tar.gz");
fs.unlinkSync("../../core/node_modules/sqlite3/build.tar.gz");
// Download and unzip esbuild
console.log("[info] Downloading pre-built esbuild binary");
@ -391,7 +387,7 @@ const exe = os === "win32" ? ".exe" : "";
// Download esbuild from npm in tmp and copy over
console.log("npm installing esbuild binary");
await installNodeModuleInTempDirAndCopyToCurrent(
"esbuild@0.17.19",
"esbuild@0.24.0",
"@esbuild",
);
}
@ -483,9 +479,9 @@ const exe = os === "win32" ? ".exe" : "";
// onnx runtime bindngs
`bin/napi-v3/${os}/${arch}/onnxruntime_binding.node`,
`bin/napi-v3/${os}/${arch}/${
os === "darwin"
isMacTarget
? "libonnxruntime.1.14.0.dylib"
: os === "linux"
: isLinuxTarget
? "libonnxruntime.so.1.14.0"
: "onnxruntime.dll"
}`,
@ -528,11 +524,7 @@ const exe = os === "win32" ? ".exe" : "";
? "win32-x64/esbuild.exe"
: `${target}/bin/esbuild`
}`,
`out/node_modules/@lancedb/vectordb-${
os === "win32"
? "win32-x64-msvc"
: `${target}${os === "linux" ? "-gnu" : ""}`
}/index.node`,
`out/node_modules/@lancedb/vectordb-${target}${isWinTarget ? "-msvc" : ""}${isLinuxTarget ? "-gnu" : ""}/index.node`,
`out/node_modules/esbuild/lib/main.js`,
`out/node_modules/esbuild/bin/esbuild`,
]);

Some files were not shown because too many files have changed in this diff Show more