Merge pull request #4808 from continuedev/nate/config-yaml-not-json
Nate/config-yaml-not-json
This commit is contained in:
commit
40a9a763f1
25 changed files with 298 additions and 386 deletions
|
|
@ -19,7 +19,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => {
|
|||
|
||||
test("should load the default config successfully", async () => {
|
||||
const result = await testConfigHandler.loadConfig();
|
||||
expect(result.config!.models.length).toBe(defaultConfig.models.length);
|
||||
expect(result.config!.models.length).toBe(defaultConfig.models?.length);
|
||||
});
|
||||
|
||||
test.skip("should add a system message from config.ts", async () => {
|
||||
|
|
|
|||
|
|
@ -1,93 +1,37 @@
|
|||
import {
|
||||
ContextProviderWithParams,
|
||||
ModelDescription,
|
||||
SerializedContinueConfig,
|
||||
SlashCommandDescription,
|
||||
} from "../";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
||||
{
|
||||
title: "Claude 3.5 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "GPT-4o (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "gpt-4o",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Llama3.1 70b (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "llama3.1-70b",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
{
|
||||
title: "Codestral (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "codestral-latest",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
export const defaultContextProvidersVsCode: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "code" },
|
||||
{ provider: "docs" },
|
||||
{ provider: "diff" },
|
||||
{ provider: "terminal" },
|
||||
{ provider: "problems" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersVsCode: ContextProviderWithParams[] = [
|
||||
{ name: "code", params: {} },
|
||||
{ name: "docs", params: {} },
|
||||
{ name: "diff", params: {} },
|
||||
{ name: "terminal", params: {} },
|
||||
{ name: "problems", params: {} },
|
||||
{ name: "folder", params: {} },
|
||||
{ name: "codebase", params: {} },
|
||||
export const defaultContextProvidersJetBrains: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "diff" },
|
||||
{ provider: "folder" },
|
||||
{ provider: "codebase" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersJetBrains: ContextProviderWithParams[] = [
|
||||
{ name: "diff", params: {} },
|
||||
{ name: "folder", params: {} },
|
||||
{ name: "codebase", params: {} },
|
||||
];
|
||||
|
||||
export const defaultSlashCommandsVscode: SlashCommandDescription[] = [
|
||||
{
|
||||
name: "share",
|
||||
description: "Export the current chat session to markdown",
|
||||
},
|
||||
{
|
||||
name: "cmd",
|
||||
description: "Generate a shell command",
|
||||
},
|
||||
{
|
||||
name: "commit",
|
||||
description: "Generate a git commit message",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultSlashCommandsJetBrains = [
|
||||
{
|
||||
name: "share",
|
||||
description: "Export the current chat session to markdown",
|
||||
},
|
||||
{
|
||||
name: "commit",
|
||||
description: "Generate a git commit message",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig: SerializedContinueConfig = {
|
||||
export const defaultConfig: ConfigYaml = {
|
||||
name: "Local Assistant",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
contextProviders: defaultContextProvidersVsCode,
|
||||
slashCommands: defaultSlashCommandsVscode,
|
||||
data: [],
|
||||
context: defaultContextProvidersVsCode,
|
||||
};
|
||||
|
||||
export const defaultConfigJetBrains: SerializedContinueConfig = {
|
||||
export const defaultConfigJetBrains: ConfigYaml = {
|
||||
name: "Local Assistant",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [],
|
||||
contextProviders: defaultContextProvidersJetBrains,
|
||||
slashCommands: defaultSlashCommandsJetBrains,
|
||||
data: [],
|
||||
context: defaultContextProvidersJetBrains,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -70,12 +70,6 @@ import {
|
|||
} from "../util/paths";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
|
||||
import {
|
||||
defaultContextProvidersJetBrains,
|
||||
defaultContextProvidersVsCode,
|
||||
defaultSlashCommandsJetBrains,
|
||||
defaultSlashCommandsVscode,
|
||||
} from "./default";
|
||||
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
||||
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
|
||||
import { getModelByRole, isSupportedLanceDbCpuTargetForLinux } from "./util";
|
||||
|
|
@ -122,7 +116,7 @@ function loadSerializedConfig(
|
|||
let config: SerializedContinueConfig = overrideConfigJson!;
|
||||
if (!config) {
|
||||
try {
|
||||
config = resolveSerializedConfig(getConfigJsonPath(ideType));
|
||||
config = resolveSerializedConfig(getConfigJsonPath());
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to parse config.json: ${e}`);
|
||||
}
|
||||
|
|
@ -162,16 +156,6 @@ function loadSerializedConfig(
|
|||
);
|
||||
}
|
||||
|
||||
// Set defaults if undefined (this lets us keep config.json uncluttered for new users)
|
||||
config.contextProviders ??=
|
||||
ideType === "vscode"
|
||||
? [...defaultContextProvidersVsCode]
|
||||
: [...defaultContextProvidersJetBrains];
|
||||
config.slashCommands ??=
|
||||
ideType === "vscode"
|
||||
? [...defaultSlashCommandsVscode]
|
||||
: [...defaultSlashCommandsJetBrains];
|
||||
|
||||
if (os.platform() === "linux" && !isSupportedLanceDbCpuTargetForLinux(ide)) {
|
||||
config.disableIndexing = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { IDE } from "..";
|
||||
import { deduplicateArray } from "../util";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
import { editConfigJson } from "../util/paths";
|
||||
import { resolveSerializedConfig } from "./load";
|
||||
import { SharedConfigSchema } from "./sharedConfig";
|
||||
|
||||
|
|
@ -196,11 +195,6 @@ 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",
|
||||
// );
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`Migration: Failed to parse config.json: ${e}`);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { SerializedContinueConfig } from "../";
|
||||
|
||||
import { FREE_TRIAL_MODELS } from "./default";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const TRIAL_FIM_MODEL = "codestral-latest";
|
||||
export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama";
|
||||
|
|
@ -9,64 +7,46 @@ 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";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed";
|
||||
|
||||
/**
|
||||
* We set the "best" chat + autocopmlete models by default
|
||||
* whenever a user doesn't have a config.json
|
||||
*/
|
||||
export function setupBestConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
export function setupBestConfig(config: ConfigYaml): ConfigYaml {
|
||||
return {
|
||||
...config,
|
||||
models: config.models.filter((model) => model.provider !== "free-trial"),
|
||||
models: config.models,
|
||||
};
|
||||
}
|
||||
|
||||
export function setupLocalConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
export function setupLocalConfig(config: ConfigYaml): ConfigYaml {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
{
|
||||
title: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
name: LOCAL_ONBOARDING_CHAT_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
},
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
{
|
||||
name: LOCAL_ONBOARDING_FIM_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
roles: ["autocomplete"],
|
||||
},
|
||||
{
|
||||
name: LOCAL_ONBOARDING_EMBEDDINGS_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
roles: ["embed"],
|
||||
},
|
||||
...(config.models ?? []),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: LOCAL_ONBOARDING_FIM_TITLE,
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function setupQuickstartConfig(
|
||||
config: SerializedContinueConfig,
|
||||
): SerializedContinueConfig {
|
||||
return {
|
||||
...config,
|
||||
models: [
|
||||
...FREE_TRIAL_MODELS,
|
||||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Tab Autocomplete",
|
||||
provider: "free-trial",
|
||||
model: TRIAL_FIM_MODEL,
|
||||
},
|
||||
embeddingsProvider: {
|
||||
provider: "free-trial",
|
||||
},
|
||||
reranker: {
|
||||
name: "free-trial",
|
||||
},
|
||||
};
|
||||
export function setupQuickstartConfig(config: ConfigYaml): ConfigYaml {
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export default async function doLoadConfig(
|
|||
|
||||
// Migrations for old config files
|
||||
// Removes
|
||||
const configJsonPath = getConfigJsonPath(ideInfo.ideType);
|
||||
const configJsonPath = getConfigJsonPath();
|
||||
if (fs.existsSync(configJsonPath)) {
|
||||
migrateJsonSharedConfig(configJsonPath, ide);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,14 @@ import fs from "fs";
|
|||
import os from "os";
|
||||
|
||||
import {
|
||||
ContextProviderWithParams,
|
||||
ContinueConfig,
|
||||
ExperimentalModelRoles,
|
||||
IDE,
|
||||
ILLM,
|
||||
ModelDescription,
|
||||
ExperimentalModelRoles,
|
||||
} from "../";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
import { editConfigJson } from "../util/paths";
|
||||
|
||||
import { ConfigHandler } from "./ConfigHandler";
|
||||
import { editConfigFile } from "../util/paths";
|
||||
|
||||
function stringify(obj: any, indentation?: number): string {
|
||||
return JSON.stringify(
|
||||
|
|
@ -24,78 +21,67 @@ function stringify(obj: any, indentation?: number): string {
|
|||
);
|
||||
}
|
||||
|
||||
export function addContextProvider(provider: ContextProviderWithParams, configHandler?: ConfigHandler) {
|
||||
let isAdded = false;
|
||||
editConfigJson((config) => {
|
||||
|
||||
if (!config.contextProviders) {
|
||||
config.contextProviders = [];
|
||||
}
|
||||
if (!config.contextProviders.some((p) => p.name === provider.name)) {
|
||||
config.contextProviders.push(provider);
|
||||
isAdded = true;
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
|
||||
if (isAdded && configHandler) {
|
||||
void configHandler.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
export function addModel(
|
||||
model: ModelDescription,
|
||||
role?: keyof ExperimentalModelRoles,
|
||||
) {
|
||||
editConfigJson((config) => {
|
||||
if (config.models?.some((m: any) => stringify(m) === stringify(model))) {
|
||||
return config;
|
||||
}
|
||||
if (config.models?.some((m: any) => m?.title === model.title)) {
|
||||
model.title = `${model.title} (1)`;
|
||||
}
|
||||
|
||||
config.models.push(model);
|
||||
|
||||
// Set the role for the model
|
||||
if (role) {
|
||||
if (!config.experimental) {
|
||||
config.experimental = {};
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
if (config.models?.some((m: any) => stringify(m) === stringify(model))) {
|
||||
return config;
|
||||
}
|
||||
if (!config.experimental.modelRoles) {
|
||||
config.experimental.modelRoles = {};
|
||||
if (config.models?.some((m: any) => m?.title === model.title)) {
|
||||
model.title = `${model.title} (1)`;
|
||||
}
|
||||
config.experimental.modelRoles[role] = model.title;
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
}
|
||||
config.models.push(model);
|
||||
|
||||
export function addOpenAIKey(key: string) {
|
||||
editConfigJson((config) => {
|
||||
config.models = config.models
|
||||
.filter(
|
||||
(model) =>
|
||||
model.provider !== "free-trial" || model.model.startsWith("gpt"),
|
||||
)
|
||||
.map((m: ModelDescription) => {
|
||||
if (m.provider === "free-trial") {
|
||||
m.apiKey = key;
|
||||
m.provider = "openai";
|
||||
// Set the role for the model
|
||||
if (role) {
|
||||
if (!config.experimental) {
|
||||
config.experimental = {};
|
||||
}
|
||||
return m;
|
||||
if (!config.experimental.modelRoles) {
|
||||
config.experimental.modelRoles = {};
|
||||
}
|
||||
config.experimental.modelRoles[role] = model.title;
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
(config) => {
|
||||
if (config.models?.some((m: any) => m?.title === model.title)) {
|
||||
model.title = `${model.title} (1)`;
|
||||
}
|
||||
|
||||
if (!config.models) {
|
||||
config.models = [];
|
||||
}
|
||||
|
||||
config.models.push({
|
||||
name: model.title,
|
||||
provider: model.provider,
|
||||
model: model.model,
|
||||
apiKey: model.apiKey,
|
||||
apiBase: model.apiBase,
|
||||
defaultCompletionOptions: model.completionOptions,
|
||||
});
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteModel(title: string) {
|
||||
editConfigJson((config) => {
|
||||
config.models = config.models.filter((m: any) => m.title !== title);
|
||||
return config;
|
||||
});
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
config.models = config.models.filter((m: any) => m.title !== title);
|
||||
return config;
|
||||
},
|
||||
(config) => {
|
||||
config.models = config.models?.filter((m: any) => m.name !== title);
|
||||
return config;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function getModelByRole<T extends keyof ExperimentalModelRoles>(
|
||||
|
|
|
|||
49
core/core.ts
49
core/core.ts
|
|
@ -10,7 +10,7 @@ import {
|
|||
setupLocalConfig,
|
||||
setupQuickstartConfig,
|
||||
} from "./config/onboarding";
|
||||
import { addContextProvider, addModel, deleteModel } from "./config/util";
|
||||
import { addModel, deleteModel } from "./config/util";
|
||||
import CodebaseContextProvider from "./context/providers/CodebaseContextProvider";
|
||||
import CurrentFileContextProvider from "./context/providers/CurrentFileContextProvider";
|
||||
import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFilesCache";
|
||||
|
|
@ -29,7 +29,7 @@ import { ChatDescriber } from "./util/chatDescriber";
|
|||
import { clipboardCache } from "./util/clipboardCache";
|
||||
import { GlobalContext } from "./util/GlobalContext";
|
||||
import historyManager from "./util/history";
|
||||
import { editConfigJson, migrateV1DevDataFiles } from "./util/paths";
|
||||
import { editConfigFile, migrateV1DevDataFiles } from "./util/paths";
|
||||
import { Telemetry } from "./util/posthog";
|
||||
import { getSymbolsForManyFiles } from "./util/treeSitter";
|
||||
import { TTS } from "./util/tts";
|
||||
|
|
@ -41,6 +41,7 @@ import {
|
|||
type IndexingProgressUpdate,
|
||||
} from ".";
|
||||
|
||||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
import { isLocalAssistantFile } from "./config/loadLocalAssistants";
|
||||
import { MCPManagerSingleton } from "./context/mcp";
|
||||
import { shouldIgnore } from "./indexing/shouldIgnore";
|
||||
|
|
@ -318,10 +319,6 @@ export class Core {
|
|||
await this.configHandler.loadAssistantsForSelectedOrg();
|
||||
});
|
||||
|
||||
on("config/addContextProvider", async (msg) => {
|
||||
addContextProvider(msg.data, this.configHandler);
|
||||
});
|
||||
|
||||
on("config/updateSharedConfig", async (msg) => {
|
||||
const newSharedConfig = this.globalContext.updateSharedConfig(msg.data);
|
||||
await this.configHandler.reloadConfig();
|
||||
|
|
@ -607,38 +604,55 @@ export class Core {
|
|||
return;
|
||||
}
|
||||
|
||||
let editConfigJsonCallback: Parameters<typeof editConfigJson>[0];
|
||||
let editConfigYamlCallback: (config: ConfigYaml) => ConfigYaml;
|
||||
|
||||
switch (mode) {
|
||||
case "Local":
|
||||
editConfigJsonCallback = setupLocalConfig;
|
||||
editConfigYamlCallback = setupLocalConfig;
|
||||
break;
|
||||
|
||||
case "Quickstart":
|
||||
editConfigJsonCallback = setupQuickstartConfig;
|
||||
editConfigYamlCallback = setupQuickstartConfig;
|
||||
break;
|
||||
|
||||
case "Best":
|
||||
editConfigJsonCallback = setupBestConfig;
|
||||
editConfigYamlCallback = setupBestConfig;
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error(`Invalid mode: ${mode}`);
|
||||
editConfigJsonCallback = (config) => config;
|
||||
editConfigYamlCallback = (config) => config;
|
||||
}
|
||||
|
||||
editConfigJson(editConfigJsonCallback);
|
||||
editConfigFile((c) => c, editConfigYamlCallback);
|
||||
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
on("addAutocompleteModel", (msg) => {
|
||||
editConfigJson((config) => {
|
||||
return {
|
||||
const model = msg.data.model;
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
return {
|
||||
...config,
|
||||
tabAutocompleteModel: model,
|
||||
};
|
||||
},
|
||||
(config) => ({
|
||||
...config,
|
||||
tabAutocompleteModel: msg.data.model,
|
||||
};
|
||||
});
|
||||
models: [
|
||||
...(config.models ?? []),
|
||||
{
|
||||
name: model.title,
|
||||
provider: model.provider,
|
||||
model: model.model,
|
||||
apiKey: model.apiKey,
|
||||
roles: ["autocomplete"],
|
||||
apiBase: model.apiBase,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
void this.configHandler.reloadConfig();
|
||||
});
|
||||
|
||||
|
|
@ -979,4 +993,3 @@ export class Core {
|
|||
|
||||
// private
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@ import {
|
|||
SiteIndexingConfig,
|
||||
} from "../..";
|
||||
import { ConfigHandler } from "../../config/ConfigHandler";
|
||||
import {
|
||||
addContextProvider,
|
||||
isSupportedLanceDbCpuTargetForLinux,
|
||||
} from "../../config/util";
|
||||
import { isSupportedLanceDbCpuTargetForLinux } from "../../config/util";
|
||||
import DocsContextProvider from "../../context/providers/DocsContextProvider";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { FromCoreProtocol, ToCoreProtocol } from "../../protocol";
|
||||
|
|
@ -24,7 +21,7 @@ import { IMessenger } from "../../protocol/messenger";
|
|||
import { fetchFavicon } from "../../util/fetchFavicon";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import {
|
||||
editConfigJson,
|
||||
editConfigFile,
|
||||
getDocsSqlitePath,
|
||||
getLanceDbPath,
|
||||
} from "../../util/paths";
|
||||
|
|
@ -299,29 +296,6 @@ export default class DocsService {
|
|||
}
|
||||
|
||||
async syncDocsWithPrompt(reIndex: boolean = false) {
|
||||
if (!this.hasDocsContextProvider()) {
|
||||
const actionMsg = "Add 'docs' context provider";
|
||||
const res = await this.ide.showToast(
|
||||
"info",
|
||||
"Starting docs indexing",
|
||||
actionMsg,
|
||||
);
|
||||
|
||||
if (res === actionMsg) {
|
||||
addContextProvider({
|
||||
name: DocsContextProvider.description.title,
|
||||
params: {},
|
||||
});
|
||||
|
||||
void this.ide.showToast(
|
||||
"info",
|
||||
"Successfuly added docs context provider",
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await this.syncDocs(undefined, this.config, reIndex);
|
||||
|
||||
void this.ide.showToast("info", "Docs indexing completed");
|
||||
|
|
@ -655,7 +629,7 @@ export default class DocsService {
|
|||
progress: 1,
|
||||
});
|
||||
|
||||
void this.ide.showToast("info", `Failed to index ${startUrl}`);
|
||||
// void this.ide.showToast("info", `Failed to index ${startUrl}`);
|
||||
markFailedInGlobalContext();
|
||||
return;
|
||||
}
|
||||
|
|
@ -1210,15 +1184,30 @@ export default class DocsService {
|
|||
);
|
||||
|
||||
if (!doesEquivalentDocExist) {
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs?.filter(
|
||||
(doc) => doc.startUrl !== siteIndexingConfig.startUrl,
|
||||
) ?? []),
|
||||
siteIndexingConfig,
|
||||
],
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs?.filter(
|
||||
(doc) => doc.startUrl !== siteIndexingConfig.startUrl,
|
||||
) ?? []),
|
||||
siteIndexingConfig,
|
||||
],
|
||||
}),
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs?.filter(
|
||||
(doc) => (doc as any).startUrl !== siteIndexingConfig.startUrl,
|
||||
) ?? []),
|
||||
{
|
||||
name: siteIndexingConfig.title,
|
||||
faviconUrl: siteIndexingConfig.faviconUrl,
|
||||
startUrl: siteIndexingConfig.startUrl,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1262,10 +1251,19 @@ export default class DocsService {
|
|||
(doc) => doc.startUrl === startUrl,
|
||||
);
|
||||
if (doesDocExist) {
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
docs: config.docs?.filter((doc) => doc.startUrl !== startUrl) || [],
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: config.docs?.filter((doc) => doc.startUrl !== startUrl) || [],
|
||||
}),
|
||||
(config) => ({
|
||||
...config,
|
||||
docs:
|
||||
config.docs?.filter(
|
||||
(doc) => "startUrl" in doc && doc.startUrl !== startUrl,
|
||||
) || [],
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import PCR from "puppeteer-chromium-resolver";
|
|||
|
||||
import { ContinueConfig, IDE } from "../../..";
|
||||
import {
|
||||
editConfigJson,
|
||||
editConfigFile,
|
||||
getChromiumPath,
|
||||
getContinueUtilsPath,
|
||||
} from "../../../util/paths";
|
||||
|
|
@ -26,13 +26,16 @@ export class ChromiumCrawler {
|
|||
) {}
|
||||
|
||||
static setUseChromiumForDocsCrawling(useChromiumForDocsCrawling: boolean) {
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
experimental: {
|
||||
...config.experimental,
|
||||
useChromiumForDocsCrawling,
|
||||
},
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
experimental: {
|
||||
...config.experimental,
|
||||
useChromiumForDocsCrawling,
|
||||
},
|
||||
}),
|
||||
(config) => config, // Not used in config.yaml
|
||||
);
|
||||
}
|
||||
|
||||
async *crawl(): AsyncGenerator<PageData> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { type Database } from "sqlite";
|
||||
import { type Table } from "vectordb";
|
||||
|
||||
import { editConfigJson, migrate } from "../../util/paths.js";
|
||||
import { editConfigFile, migrate } from "../../util/paths.js";
|
||||
|
||||
import DocsService, { SqliteDocsRow } from "./DocsService.js";
|
||||
|
||||
|
|
@ -58,10 +58,22 @@ export async function runSqliteMigrations(db: Database) {
|
|||
const sqliteDocs = await db.all<
|
||||
Array<Pick<SqliteDocsRow, "title" | "startUrl">>
|
||||
>(`SELECT title, startUrl FROM ${DocsService.sqlitebTableName}`);
|
||||
editConfigJson((config) => ({
|
||||
...config,
|
||||
docs: [...(config.docs || []), ...sqliteDocs],
|
||||
}));
|
||||
editConfigFile(
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [...(config.docs || []), ...sqliteDocs],
|
||||
}),
|
||||
(config) => ({
|
||||
...config,
|
||||
docs: [
|
||||
...(config.docs || []),
|
||||
...sqliteDocs.map((doc) => ({
|
||||
name: doc.title,
|
||||
startUrl: doc.startUrl,
|
||||
})),
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
resolve(undefined);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import type {
|
|||
ChatMessage,
|
||||
ContextItem,
|
||||
ContextItemWithId,
|
||||
ContextProviderWithParams,
|
||||
ContextSubmenuItem,
|
||||
DiffLine,
|
||||
DocsIndexingDetails,
|
||||
|
|
@ -70,7 +69,6 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
},
|
||||
];
|
||||
"config/deleteModel": [{ title: string }, void];
|
||||
"config/addContextProvider": [ContextProviderWithParams, void];
|
||||
"config/reload": [undefined, ConfigResult<BrowserSerializedContinueConfig>];
|
||||
"config/listProfiles": [
|
||||
undefined,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"history/save",
|
||||
"devdata/log",
|
||||
"config/addModel",
|
||||
"config/addContextProvider",
|
||||
"config/newPromptFile",
|
||||
"config/ideSettingsUpdate",
|
||||
"config/getSerializedProfileInfo",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import { DevEventName } from "@continuedev/config-yaml";
|
||||
import { ConfigYaml, DevEventName } from "@continuedev/config-yaml";
|
||||
import * as JSONC from "comment-json";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
|
|
@ -91,27 +92,20 @@ export function getSessionsListPath(): string {
|
|||
return filepath;
|
||||
}
|
||||
|
||||
export function getConfigJsonPath(ideType: IdeType = "vscode"): string {
|
||||
export function getConfigJsonPath(): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.json");
|
||||
if (!fs.existsSync(p)) {
|
||||
if (ideType === "jetbrains") {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfigJetBrains, null, 2));
|
||||
} else {
|
||||
fs.writeFileSync(p, JSON.stringify(defaultConfig, null, 2));
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
export function getConfigYamlPath(ideType?: IdeType): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.yaml");
|
||||
// if (!fs.existsSync(p)) {
|
||||
// if (ideType === "jetbrains") {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYamlJetBrains));
|
||||
// } else {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYaml));
|
||||
// }
|
||||
// }
|
||||
if (!fs.existsSync(p) && !fs.existsSync(getConfigJsonPath())) {
|
||||
if (ideType === "jetbrains") {
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfigJetBrains));
|
||||
} else {
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfig));
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +228,7 @@ export function getDevDataFilePath(
|
|||
return path.join(versionPath, `${String(eventName)}.jsonl`);
|
||||
}
|
||||
|
||||
export function editConfigJson(
|
||||
function editConfigJson(
|
||||
callback: (config: SerializedContinueConfig) => SerializedContinueConfig,
|
||||
): void {
|
||||
const config = fs.readFileSync(getConfigJsonPath(), "utf8");
|
||||
|
|
@ -248,6 +242,31 @@ export function editConfigJson(
|
|||
}
|
||||
}
|
||||
|
||||
function editConfigYaml(callback: (config: ConfigYaml) => ConfigYaml): void {
|
||||
const config = fs.readFileSync(getConfigYamlPath(), "utf8");
|
||||
let configYaml = YAML.parse(config);
|
||||
// Check if it's an object
|
||||
if (typeof configYaml === "object" && configYaml !== null) {
|
||||
configYaml = callback(configYaml as any) as any;
|
||||
fs.writeFileSync(getConfigYamlPath(), YAML.stringify(configYaml));
|
||||
} else {
|
||||
console.warn("config.yaml is not a valid object");
|
||||
}
|
||||
}
|
||||
|
||||
export function editConfigFile(
|
||||
configJsonCallback: (
|
||||
config: SerializedContinueConfig,
|
||||
) => SerializedContinueConfig,
|
||||
configYamlCallback: (config: ConfigYaml) => ConfigYaml,
|
||||
): void {
|
||||
if (fs.existsSync(getConfigYamlPath())) {
|
||||
editConfigYaml(configYamlCallback);
|
||||
} else if (fs.existsSync(getConfigJsonPath())) {
|
||||
editConfigJson(configJsonCallback);
|
||||
}
|
||||
}
|
||||
|
||||
function getMigrationsFolderPath(): string {
|
||||
const migrationsPath = path.join(getContinueGlobalPath(), ".migrations");
|
||||
if (!fs.existsSync(migrationsPath)) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ class MessageTypes {
|
|||
"history/save",
|
||||
"devdata/log",
|
||||
"config/addModel",
|
||||
"config/addContextProvider",
|
||||
"config/newPromptFile",
|
||||
"config/ideSettingsUpdate",
|
||||
"config/getSerializedProfileInfo",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "1.1.15",
|
||||
"version": "1.1.16",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { exec } from "node:child_process";
|
|||
import { Range } from "core";
|
||||
import { EXTENSION_NAME } from "core/control-plane/env";
|
||||
import { GetGhTokenArgs } from "core/protocol/ide";
|
||||
import { editConfigJson, getConfigJsonPath } from "core/util/paths";
|
||||
import { editConfigFile, getConfigJsonPath } from "core/util/paths";
|
||||
import * as URI from "uri-js";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
|
|
@ -155,26 +155,39 @@ class VsCodeIde implements IDE {
|
|||
);
|
||||
|
||||
// Remove free trial models
|
||||
editConfigJson((config) => {
|
||||
let tabAutocompleteModel = undefined;
|
||||
if (Array.isArray(config.tabAutocompleteModel)) {
|
||||
tabAutocompleteModel = config.tabAutocompleteModel.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
);
|
||||
} else if (
|
||||
config.tabAutocompleteModel?.provider === "free-trial"
|
||||
) {
|
||||
tabAutocompleteModel = undefined;
|
||||
}
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
let tabAutocompleteModel = undefined;
|
||||
if (Array.isArray(config.tabAutocompleteModel)) {
|
||||
tabAutocompleteModel = config.tabAutocompleteModel.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
);
|
||||
} else if (
|
||||
config.tabAutocompleteModel?.provider === "free-trial"
|
||||
) {
|
||||
tabAutocompleteModel = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
...config,
|
||||
models: config.models.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
),
|
||||
tabAutocompleteModel,
|
||||
};
|
||||
});
|
||||
return {
|
||||
...config,
|
||||
models: config.models.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
),
|
||||
tabAutocompleteModel,
|
||||
};
|
||||
},
|
||||
(config) => {
|
||||
return {
|
||||
...config,
|
||||
models: config.models?.filter(
|
||||
(model) =>
|
||||
!(
|
||||
"provider" in model && model.provider === "free-trial"
|
||||
),
|
||||
),
|
||||
};
|
||||
},
|
||||
);
|
||||
} else if (selection === "Learn more") {
|
||||
vscode.env.openExternal(
|
||||
vscode.Uri.parse(
|
||||
|
|
@ -216,13 +229,22 @@ class VsCodeIde implements IDE {
|
|||
)
|
||||
.then((selection) => {
|
||||
if (selection === "Remove for me") {
|
||||
editConfigJson((configJson) => {
|
||||
configJson.models = configJson.models.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
);
|
||||
configJson.tabAutocompleteModel = undefined;
|
||||
return configJson;
|
||||
});
|
||||
editConfigFile(
|
||||
(configJson) => {
|
||||
configJson.models = configJson.models.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
);
|
||||
configJson.tabAutocompleteModel = undefined;
|
||||
return configJson;
|
||||
},
|
||||
(config) => {
|
||||
config.models = config.models?.filter(
|
||||
(model) =>
|
||||
!("provider" in model && model.provider === "free-trial"),
|
||||
);
|
||||
return config;
|
||||
},
|
||||
);
|
||||
} else if (selection === "Open Assistant configuration") {
|
||||
this.openFile(getConfigJsonPath());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +1,5 @@
|
|||
import { SlashCommandDescription } from "core";
|
||||
import {
|
||||
defaultSlashCommandsJetBrains,
|
||||
defaultSlashCommandsVscode,
|
||||
} from "core/config/default";
|
||||
import { isJetBrains } from "../../util";
|
||||
|
||||
/**
|
||||
* The commands filtered here are currently inserted into the slash commands array during
|
||||
* intermediary config loading, but once we get the actual prompts for an assistant,
|
||||
* they are overwritten.
|
||||
*
|
||||
* Additionally, these default commands are all deprecated.
|
||||
*
|
||||
* If we don't manually filter them out, then they are displayed in the UI
|
||||
* while the assistant is still loading.
|
||||
*
|
||||
* Once these commands are no longer inserted during intermediary config loading,
|
||||
* this function can be removed.
|
||||
*/
|
||||
export function isDeprecatedCommandName(command: SlashCommandDescription) {
|
||||
const defaultCommands = isJetBrains()
|
||||
? defaultSlashCommandsJetBrains
|
||||
: defaultSlashCommandsVscode;
|
||||
|
||||
return !defaultCommands.find(
|
||||
(defaultCommand) => defaultCommand.name === command.name,
|
||||
);
|
||||
}
|
||||
import {} from "core/config/default";
|
||||
|
||||
/**
|
||||
* Sorts commands with bookmarked ones first
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { FREE_TRIAL_MODELS } from "core/config/default";
|
||||
import { useContext } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, ButtonSubtext } from "../..";
|
||||
|
|
@ -7,7 +6,6 @@ import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
|||
import { isJetBrains } from "../../../util";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
import JetBrainsFetchGitHubTokenDialog from "./JetBrainsFetchGitHubTokenDialog";
|
||||
import { setDefaultModel } from "../../../redux/slices/configSlice";
|
||||
|
||||
interface QuickstartSubmitButtonProps {
|
||||
isDialog?: boolean;
|
||||
|
|
@ -21,10 +19,6 @@ function QuickstartSubmitButton({ isDialog }: QuickstartSubmitButtonProps) {
|
|||
|
||||
function onComplete() {
|
||||
submitOnboarding();
|
||||
|
||||
// Set Sonnet as the default model
|
||||
const title = FREE_TRIAL_MODELS[0].title;
|
||||
dispatch(setDefaultModel({ title, force: true }));
|
||||
}
|
||||
|
||||
function openJetBrainsDialog() {
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) {
|
|||
<div className="mt-4 flex flex-col">
|
||||
<Alert type="info">
|
||||
By choosing this option, Continue will be configured by a local{" "}
|
||||
<code>config.yaml</code> file. If you're just looking to use
|
||||
Ollama and still want to manage your configuration through
|
||||
Continue, click{" "}
|
||||
<code className="text-vsc-background">config.yaml</code> file. If
|
||||
you're just looking to use Ollama and still want to manage your
|
||||
configuration through Continue, click{" "}
|
||||
<a href="#" onClick={() => setCurrentTab("main")}>
|
||||
here
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
const currentTarget = e.currentTarget;
|
||||
const relatedTarget = e.relatedTarget as Node | null;
|
||||
|
||||
if (relatedTarget && currentTarget.contains(relatedTarget)) {
|
||||
if (relatedTarget && currentTarget?.contains(relatedTarget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ function ModeSelect() {
|
|||
<span className="">Agent</span>
|
||||
</div>
|
||||
{mode === "agent" && <CheckIcon className="ml-auto h-3 w-3" />}
|
||||
{!agentModeSupported && <span>(Not supported)</span>}
|
||||
{!agentModeSupported && <span> (Not supported)</span>}
|
||||
</ListboxOption>
|
||||
|
||||
<ListboxOption value="chat">
|
||||
|
|
|
|||
|
|
@ -67,22 +67,21 @@ export const StyledListboxOptions = styled(ListboxOptions)`
|
|||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
|
||||
margin-top: 0.25rem;
|
||||
|
||||
height: fit-content;
|
||||
max-height: 15rem;
|
||||
overflow: auto;
|
||||
width: 60%;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
overflow-y: scroll;
|
||||
overflow-y: auto;
|
||||
z-index: 10;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
|
||||
export const StyledListboxOption = styled(ListboxOption)<{
|
||||
selected: boolean;
|
||||
}>`
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ const ListboxOptions = React.forwardRef<HTMLUListElement, ListboxOptionsProps>(
|
|||
border: `1px solid ${vscCommandCenterInactiveBorder}`,
|
||||
fontSize,
|
||||
borderRadius: defaultBorderRadius,
|
||||
zIndex: 1000,
|
||||
...props.style,
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { isDeprecatedCommandName } from "../../../components/ConversationStarters/utils";
|
||||
import { ThunkApiType } from "../../store";
|
||||
import {
|
||||
initializeProfilePreferences,
|
||||
|
|
@ -98,15 +97,10 @@ export const initializeProfilePreferencesThunk = createAsyncThunk<
|
|||
"profiles/initializeProfilePreferences",
|
||||
async (data, { getState, dispatch }) => {
|
||||
const { profileId } = data;
|
||||
const state = getState();
|
||||
|
||||
// Get slash commands from config
|
||||
const defaultSlashCommands =
|
||||
state.config.config.slashCommands.filter(isDeprecatedCommandName) ?? [];
|
||||
|
||||
dispatch(
|
||||
initializeProfilePreferences({
|
||||
defaultSlashCommands,
|
||||
defaultSlashCommands: [],
|
||||
profileId,
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue