Skip to content

Commit 40a9a76

Browse files
authored
Merge pull request #4808 from continuedev/nate/config-yaml-not-json
Nate/config-yaml-not-json
2 parents 5eb993f + f30b023 commit 40a9a76

File tree

25 files changed

+298
-386
lines changed

25 files changed

+298
-386
lines changed

core/config/ConfigHandler.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => {
1919

2020
test("should load the default config successfully", async () => {
2121
const result = await testConfigHandler.loadConfig();
22-
expect(result.config!.models.length).toBe(defaultConfig.models.length);
22+
expect(result.config!.models.length).toBe(defaultConfig.models?.length);
2323
});
2424

2525
test.skip("should add a system message from config.ts", async () => {

core/config/default.ts

+27-83
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,37 @@
1-
import {
2-
ContextProviderWithParams,
3-
ModelDescription,
4-
SerializedContinueConfig,
5-
SlashCommandDescription,
6-
} from "../";
1+
import { ConfigYaml } from "@continuedev/config-yaml";
72

8-
export const FREE_TRIAL_MODELS: ModelDescription[] = [
9-
{
10-
title: "Claude 3.5 Sonnet (Free Trial)",
11-
provider: "free-trial",
12-
model: "claude-3-5-sonnet-latest",
13-
systemMessage:
14-
"You are an expert software developer. You give helpful and concise responses.",
15-
},
16-
{
17-
title: "GPT-4o (Free Trial)",
18-
provider: "free-trial",
19-
model: "gpt-4o",
20-
systemMessage:
21-
"You are an expert software developer. You give helpful and concise responses.",
22-
},
23-
{
24-
title: "Llama3.1 70b (Free Trial)",
25-
provider: "free-trial",
26-
model: "llama3.1-70b",
27-
systemMessage:
28-
"You are an expert software developer. You give helpful and concise responses.",
29-
},
30-
{
31-
title: "Codestral (Free Trial)",
32-
provider: "free-trial",
33-
model: "codestral-latest",
34-
systemMessage:
35-
"You are an expert software developer. You give helpful and concise responses.",
36-
},
3+
export const defaultContextProvidersVsCode: NonNullable<
4+
ConfigYaml["context"]
5+
>[number][] = [
6+
{ provider: "code" },
7+
{ provider: "docs" },
8+
{ provider: "diff" },
9+
{ provider: "terminal" },
10+
{ provider: "problems" },
11+
{ provider: "folder" },
12+
{ provider: "codebase" },
3713
];
3814

39-
export const defaultContextProvidersVsCode: ContextProviderWithParams[] = [
40-
{ name: "code", params: {} },
41-
{ name: "docs", params: {} },
42-
{ name: "diff", params: {} },
43-
{ name: "terminal", params: {} },
44-
{ name: "problems", params: {} },
45-
{ name: "folder", params: {} },
46-
{ name: "codebase", params: {} },
15+
export const defaultContextProvidersJetBrains: NonNullable<
16+
ConfigYaml["context"]
17+
>[number][] = [
18+
{ provider: "diff" },
19+
{ provider: "folder" },
20+
{ provider: "codebase" },
4721
];
4822

49-
export const defaultContextProvidersJetBrains: ContextProviderWithParams[] = [
50-
{ name: "diff", params: {} },
51-
{ name: "folder", params: {} },
52-
{ name: "codebase", params: {} },
53-
];
54-
55-
export const defaultSlashCommandsVscode: SlashCommandDescription[] = [
56-
{
57-
name: "share",
58-
description: "Export the current chat session to markdown",
59-
},
60-
{
61-
name: "cmd",
62-
description: "Generate a shell command",
63-
},
64-
{
65-
name: "commit",
66-
description: "Generate a git commit message",
67-
},
68-
];
69-
70-
export const defaultSlashCommandsJetBrains = [
71-
{
72-
name: "share",
73-
description: "Export the current chat session to markdown",
74-
},
75-
{
76-
name: "commit",
77-
description: "Generate a git commit message",
78-
},
79-
];
80-
81-
export const defaultConfig: SerializedContinueConfig = {
23+
export const defaultConfig: ConfigYaml = {
24+
name: "Local Assistant",
25+
version: "1.0.0",
26+
schema: "v1",
8227
models: [],
83-
contextProviders: defaultContextProvidersVsCode,
84-
slashCommands: defaultSlashCommandsVscode,
85-
data: [],
28+
context: defaultContextProvidersVsCode,
8629
};
8730

88-
export const defaultConfigJetBrains: SerializedContinueConfig = {
31+
export const defaultConfigJetBrains: ConfigYaml = {
32+
name: "Local Assistant",
33+
version: "1.0.0",
34+
schema: "v1",
8935
models: [],
90-
contextProviders: defaultContextProvidersJetBrains,
91-
slashCommands: defaultSlashCommandsJetBrains,
92-
data: [],
36+
context: defaultContextProvidersJetBrains,
9337
};

core/config/load.ts

+1-17
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ import {
7070
} from "../util/paths";
7171
import { localPathToUri } from "../util/pathToUri";
7272

73-
import {
74-
defaultContextProvidersJetBrains,
75-
defaultContextProvidersVsCode,
76-
defaultSlashCommandsJetBrains,
77-
defaultSlashCommandsVscode,
78-
} from "./default";
7973
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
8074
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
8175
import { getModelByRole, isSupportedLanceDbCpuTargetForLinux } from "./util";
@@ -122,7 +116,7 @@ function loadSerializedConfig(
122116
let config: SerializedContinueConfig = overrideConfigJson!;
123117
if (!config) {
124118
try {
125-
config = resolveSerializedConfig(getConfigJsonPath(ideType));
119+
config = resolveSerializedConfig(getConfigJsonPath());
126120
} catch (e) {
127121
throw new Error(`Failed to parse config.json: ${e}`);
128122
}
@@ -162,16 +156,6 @@ function loadSerializedConfig(
162156
);
163157
}
164158

165-
// Set defaults if undefined (this lets us keep config.json uncluttered for new users)
166-
config.contextProviders ??=
167-
ideType === "vscode"
168-
? [...defaultContextProvidersVsCode]
169-
: [...defaultContextProvidersJetBrains];
170-
config.slashCommands ??=
171-
ideType === "vscode"
172-
? [...defaultSlashCommandsVscode]
173-
: [...defaultSlashCommandsJetBrains];
174-
175159
if (os.platform() === "linux" && !isSupportedLanceDbCpuTargetForLinux(ide)) {
176160
config.disableIndexing = true;
177161
}

core/config/migrateSharedConfig.ts

-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { IDE } from "..";
22
import { deduplicateArray } from "../util";
33
import { GlobalContext } from "../util/GlobalContext";
4-
import { editConfigJson } from "../util/paths";
54
import { resolveSerializedConfig } from "./load";
65
import { SharedConfigSchema } from "./sharedConfig";
76

@@ -196,11 +195,6 @@ export function migrateJsonSharedConfig(filepath: string, ide: IDE): void {
196195

197196
if (effected) {
198197
new GlobalContext().updateSharedConfig(shareConfigUpdates);
199-
editConfigJson(() => config);
200-
// void ide.showToast(
201-
// "warning",
202-
// "Migrated deprecated Continue JSON settings. Edit in the Settings Page",
203-
// );
204198
}
205199
} catch (e) {
206200
throw new Error(`Migration: Failed to parse config.json: ${e}`);

core/config/onboarding.ts

+22-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { SerializedContinueConfig } from "../";
2-
3-
import { FREE_TRIAL_MODELS } from "./default";
1+
import { ConfigYaml } from "@continuedev/config-yaml";
42

53
export const TRIAL_FIM_MODEL = "codestral-latest";
64
export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama";
@@ -9,64 +7,46 @@ export const LOCAL_ONBOARDING_FIM_TITLE = "Qwen2.5-Coder 1.5B";
97
export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
108
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
119
export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest";
10+
export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed";
1211

1312
/**
1413
* We set the "best" chat + autocopmlete models by default
1514
* whenever a user doesn't have a config.json
1615
*/
17-
export function setupBestConfig(
18-
config: SerializedContinueConfig,
19-
): SerializedContinueConfig {
16+
export function setupBestConfig(config: ConfigYaml): ConfigYaml {
2017
return {
2118
...config,
22-
models: config.models.filter((model) => model.provider !== "free-trial"),
19+
models: config.models,
2320
};
2421
}
2522

26-
export function setupLocalConfig(
27-
config: SerializedContinueConfig,
28-
): SerializedContinueConfig {
23+
export function setupLocalConfig(config: ConfigYaml): ConfigYaml {
2924
return {
3025
...config,
3126
models: [
3227
{
33-
title: LOCAL_ONBOARDING_CHAT_TITLE,
28+
name: LOCAL_ONBOARDING_CHAT_TITLE,
3429
provider: "ollama",
3530
model: LOCAL_ONBOARDING_CHAT_MODEL,
31+
roles: ["chat", "edit", "apply"],
32+
},
33+
{
34+
name: LOCAL_ONBOARDING_FIM_TITLE,
35+
provider: "ollama",
36+
model: LOCAL_ONBOARDING_FIM_MODEL,
37+
roles: ["autocomplete"],
38+
},
39+
{
40+
name: LOCAL_ONBOARDING_EMBEDDINGS_TITLE,
41+
provider: "ollama",
42+
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
43+
roles: ["embed"],
3644
},
37-
...config.models.filter((model) => model.provider !== "free-trial"),
45+
...(config.models ?? []),
3846
],
39-
tabAutocompleteModel: {
40-
title: LOCAL_ONBOARDING_FIM_TITLE,
41-
provider: "ollama",
42-
model: LOCAL_ONBOARDING_FIM_MODEL,
43-
},
44-
embeddingsProvider: {
45-
provider: "ollama",
46-
model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL,
47-
},
4847
};
4948
}
5049

51-
export function setupQuickstartConfig(
52-
config: SerializedContinueConfig,
53-
): SerializedContinueConfig {
54-
return {
55-
...config,
56-
models: [
57-
...FREE_TRIAL_MODELS,
58-
...config.models.filter((model) => model.provider !== "free-trial"),
59-
],
60-
tabAutocompleteModel: {
61-
title: "Tab Autocomplete",
62-
provider: "free-trial",
63-
model: TRIAL_FIM_MODEL,
64-
},
65-
embeddingsProvider: {
66-
provider: "free-trial",
67-
},
68-
reranker: {
69-
name: "free-trial",
70-
},
71-
};
50+
export function setupQuickstartConfig(config: ConfigYaml): ConfigYaml {
51+
return config;
7252
}

core/config/profile/doLoadConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default async function doLoadConfig(
5555

5656
// Migrations for old config files
5757
// Removes
58-
const configJsonPath = getConfigJsonPath(ideInfo.ideType);
58+
const configJsonPath = getConfigJsonPath();
5959
if (fs.existsSync(configJsonPath)) {
6060
migrateJsonSharedConfig(configJsonPath, ide);
6161
}

0 commit comments

Comments
 (0)