Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into completion_provider_replacement_d…
Browse files Browse the repository at this point in the history
…iffpattern
  • Loading branch information
ferenci84 committed Feb 7, 2025
2 parents 4cc1cdd + ea56186 commit f135102
Show file tree
Hide file tree
Showing 50 changed files with 606 additions and 138 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -197,6 +204,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
if: github.event.inputs.publish_build == 'true'
permissions:
contents: write
steps:
Expand Down
2 changes: 1 addition & 1 deletion binary/package-lock.json

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

8 changes: 4 additions & 4 deletions binary/src/IpcMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IPCMessengerBase<

console.warn(`Error running handler for "${msg.messageType}": `, e);
this._onErrorHandlers.forEach((handler) => {
handler(e);
handler(msg, e);
});
}
});
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions binary/src/TcpMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
});
}
});
Expand Down
7 changes: 6 additions & 1 deletion core/autocomplete/snippets/getAllSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions core/config/ConfigHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,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());
Expand Down Expand Up @@ -419,6 +419,6 @@ export class ConfigHandler {

registerCustomContextProvider(contextProvider: IContextProvider) {
this.additionalContextProviders.push(contextProvider);
void this.reloadConfig(this.additionalContextProviders);
void this.reloadConfig();
}
}
20 changes: 18 additions & 2 deletions core/config/ProfileLifecycleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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;
Expand All @@ -73,7 +75,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
Expand Down
20 changes: 2 additions & 18 deletions core/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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,
};
2 changes: 1 addition & 1 deletion core/config/profile/doLoadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion core/context/mcp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
18 changes: 14 additions & 4 deletions core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ 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;
Expand Down Expand Up @@ -209,13 +208,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) => {
Expand Down
7 changes: 5 additions & 2 deletions core/llm/autodetect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModelCapability, TemplateType } from "../index.js";
import { ChatMessage, ModelCapability, TemplateType } from "../index.js";

import {
anthropicTemplateMessages,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions core/llm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,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;
Expand Down Expand Up @@ -957,7 +958,9 @@ export abstract class BaseLLM implements ILLM {
this.providerName,
autodetectTemplateType(this.model),
);
return templateMessages(rendered);
if (templateMessages) {
return templateMessages(rendered);
}
}
return rendered;
}
Expand Down
2 changes: 2 additions & 0 deletions core/llm/llms/Novita.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit f135102

Please sign in to comment.