diff --git a/core/config/default.ts b/core/config/default.ts index 8c349a13b..81c133455 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -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, }; diff --git a/core/config/load.ts b/core/config/load.ts index 4c98e7728..a21989522 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -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; } diff --git a/core/config/onboarding.ts b/core/config/onboarding.ts index 8babfffde..729653674 100644 --- a/core/config/onboarding.ts +++ b/core/config/onboarding.ts @@ -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; } diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 5380cc408..cc4401003 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -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); } diff --git a/core/core.ts b/core/core.ts index 5fa42c5b6..042b3aa3a 100644 --- a/core/core.ts +++ b/core/core.ts @@ -29,7 +29,11 @@ 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 { + editConfigJson, + editConfigYaml, + migrateV1DevDataFiles, +} from "./util/paths"; import { Telemetry } from "./util/posthog"; import { getSymbolsForManyFiles } from "./util/treeSitter"; import { TTS } from "./util/tts"; @@ -607,27 +611,27 @@ export class Core { return; } - let editConfigJsonCallback: Parameters[0]; + let editConfigYamlCallback: Parameters[0]; 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); + editConfigYaml(editConfigYamlCallback); void this.configHandler.reloadConfig(); }); @@ -979,4 +983,3 @@ export class Core { // private } - diff --git a/core/util/paths.ts b/core/util/paths.ts index 0fa64d109..b199e61d8 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -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; } @@ -248,6 +242,20 @@ export function editConfigJson( } } +export 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"); + } +} + function getMigrationsFolderPath(): string { const migrationsPath = path.join(getContinueGlobalPath(), ".migrations"); if (!fs.existsSync(migrationsPath)) { diff --git a/gui/src/components/ConversationStarters/utils.ts b/gui/src/components/ConversationStarters/utils.ts index d37b45416..1f9ef09ae 100644 --- a/gui/src/components/ConversationStarters/utils.ts +++ b/gui/src/components/ConversationStarters/utils.ts @@ -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 diff --git a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx b/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx index 00d0702c3..07688fe6b 100644 --- a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx +++ b/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx @@ -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() { diff --git a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx b/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx index 63d2c4f32..4c0deda74 100644 --- a/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx +++ b/gui/src/components/OnboardingCard/platform/PlatformOnboardingCard.tsx @@ -41,9 +41,9 @@ export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) {
By choosing this option, Continue will be configured by a local{" "} - config.yaml file. If you're just looking to use - Ollama and still want to manage your configuration through - Continue, click{" "} + config.yaml file. If + you're just looking to use Ollama and still want to manage your + configuration through Continue, click{" "} setCurrentTab("main")}> here diff --git a/gui/src/components/mainInput/tiptap/TipTapEditor.tsx b/gui/src/components/mainInput/tiptap/TipTapEditor.tsx index cef58128e..bb64ccd56 100644 --- a/gui/src/components/mainInput/tiptap/TipTapEditor.tsx +++ b/gui/src/components/mainInput/tiptap/TipTapEditor.tsx @@ -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; } diff --git a/gui/src/components/modelSelection/ModeSelect.tsx b/gui/src/components/modelSelection/ModeSelect.tsx index 66e5be724..338e0b8ca 100644 --- a/gui/src/components/modelSelection/ModeSelect.tsx +++ b/gui/src/components/modelSelection/ModeSelect.tsx @@ -130,7 +130,7 @@ function ModeSelect() { Agent
{mode === "agent" && } - {!agentModeSupported && (Not supported)} + {!agentModeSupported && (Not supported)} diff --git a/gui/src/redux/slices/profiles/thunks.ts b/gui/src/redux/slices/profiles/thunks.ts index 585e7cd2b..14969157f 100644 --- a/gui/src/redux/slices/profiles/thunks.ts +++ b/gui/src/redux/slices/profiles/thunks.ts @@ -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, }), );