load config.yaml if it exists
This commit is contained in:
parent
a427c4c2df
commit
f33f2d832e
8 changed files with 53 additions and 85 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import fs from "fs";
|
||||
|
||||
import {
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
|
|
@ -10,9 +12,12 @@ import { ControlPlaneClient } from "../../control-plane/client.js";
|
|||
import { controlPlaneEnv } from "../../control-plane/env.js";
|
||||
import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js";
|
||||
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
||||
import { getConfigYamlPath } from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
import { TTS } from "../../util/tts";
|
||||
import { ConfigResult, loadFullConfigNode } from "../load";
|
||||
import { ConfigValidationError } from "../validation";
|
||||
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
|
||||
|
||||
export default async function doLoadConfig(
|
||||
ide: IDE,
|
||||
|
|
@ -28,20 +33,42 @@ export default async function doLoadConfig(
|
|||
const ideSettings = await ideSettingsPromise;
|
||||
const workOsAccessToken = await controlPlaneClient.getAccessToken();
|
||||
|
||||
let {
|
||||
config: newConfig,
|
||||
errors,
|
||||
configLoadInterrupted,
|
||||
} = await loadFullConfigNode(
|
||||
ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
overrideConfigJson,
|
||||
);
|
||||
const configYamlPath = getConfigYamlPath(ideInfo.ideType);
|
||||
|
||||
let newConfig: ContinueConfig | undefined;
|
||||
let errors: ConfigValidationError[] | undefined;
|
||||
let configLoadInterrupted = false;
|
||||
|
||||
if (fs.existsSync(configYamlPath)) {
|
||||
const result = await loadContinueConfigFromYaml(
|
||||
ide,
|
||||
workspaceConfigs.map((c) => JSON.stringify(c)),
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
undefined,
|
||||
// overrideConfigYaml, TODO
|
||||
);
|
||||
newConfig = result.config;
|
||||
errors = result.errors;
|
||||
configLoadInterrupted = result.configLoadInterrupted;
|
||||
} else {
|
||||
const result = await loadFullConfigNode(
|
||||
ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
ideInfo.ideType,
|
||||
uniqueId,
|
||||
writeLog,
|
||||
workOsAccessToken,
|
||||
overrideConfigJson,
|
||||
);
|
||||
newConfig = result.config;
|
||||
errors = result.errors;
|
||||
configLoadInterrupted = result.configLoadInterrupted;
|
||||
}
|
||||
|
||||
if (configLoadInterrupted || !newConfig) {
|
||||
return { errors, config: newConfig, configLoadInterrupted: true };
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ async function configYamlToContinueConfig(
|
|||
return continueConfig;
|
||||
}
|
||||
|
||||
export async function loadContinueConfig(
|
||||
export async function loadContinueConfigFromYaml(
|
||||
ide: IDE,
|
||||
workspaceConfigs: string[],
|
||||
ideSettings: IdeSettings,
|
||||
|
|
@ -327,7 +327,4 @@ export async function loadContinueConfig(
|
|||
};
|
||||
}
|
||||
|
||||
export {
|
||||
loadContinueConfig as loadFullConfigNode,
|
||||
type BrowserSerializedContinueConfig,
|
||||
};
|
||||
export { type BrowserSerializedContinueConfig };
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ export const DEFAULT_IGNORE_FILETYPES = [
|
|||
"*.gitkeep",
|
||||
"*.continueignore",
|
||||
"config.json",
|
||||
"config.yaml",
|
||||
"*.csv",
|
||||
"*.uasset",
|
||||
"*.pdb",
|
||||
|
|
|
|||
|
|
@ -4,15 +4,10 @@ import * as fs from "fs";
|
|||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { pathToFileURL } from "url";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import { IdeType, SerializedContinueConfig } from "../";
|
||||
import { defaultConfig, defaultConfigJetBrains } from "../config/default";
|
||||
import Types from "../config/types";
|
||||
import {
|
||||
defaultConfigYaml,
|
||||
defaultConfigYamlJetBrains,
|
||||
} from "../config/yaml/default";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
|
|
@ -108,13 +103,13 @@ export function getConfigJsonPath(ideType: IdeType = "vscode"): string {
|
|||
|
||||
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)) {
|
||||
// if (ideType === "jetbrains") {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYamlJetBrains));
|
||||
// } else {
|
||||
// fs.writeFileSync(p, YAML.stringify(defaultConfigYaml));
|
||||
// }
|
||||
// }
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) :
|
|||
".continue\\config.json"
|
||||
) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(
|
||||
".continuerc.json"
|
||||
) || event.path.endsWith(".continue/config.yaml") || event.path.endsWith(
|
||||
".continue\\config.yaml"
|
||||
)
|
||||
) {
|
||||
return object : AsyncFileListener.ChangeApplier {
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
import * as os from "os";
|
||||
|
||||
import * as vscode from "vscode";
|
||||
|
||||
export class ConfigPyCodeLensProvider implements vscode.CodeLensProvider {
|
||||
public provideCodeLenses(
|
||||
document: vscode.TextDocument,
|
||||
_: vscode.CancellationToken,
|
||||
): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> {
|
||||
const codeLenses: vscode.CodeLens[] = [];
|
||||
|
||||
if (
|
||||
!document.uri.fsPath.endsWith(".continue/config.json") &&
|
||||
!document.uri.fsPath.endsWith(".continue\\config.json")
|
||||
) {
|
||||
return codeLenses;
|
||||
}
|
||||
|
||||
const lines = document.getText().split(os.EOL);
|
||||
const lineOfModels = lines.findIndex((line) =>
|
||||
line.includes('"models": ['),
|
||||
);
|
||||
|
||||
const lineOfSystemMessage = lines.findIndex((line) =>
|
||||
line.includes("ContinueConfig("),
|
||||
);
|
||||
|
||||
if (lineOfSystemMessage >= 0) {
|
||||
const range = new vscode.Range(
|
||||
lineOfSystemMessage,
|
||||
0,
|
||||
lineOfSystemMessage + 1,
|
||||
0,
|
||||
);
|
||||
codeLenses.push(
|
||||
new vscode.CodeLens(range, {
|
||||
title: "✏️ Edit in UI",
|
||||
command: "continue.openConfigUI", // command likely doesn't exist anymore, check
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return codeLenses;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
export { ConfigPyCodeLensProvider } from "./ConfigPyCodeLensProvider";
|
||||
export { DiffViewerCodeLensProvider } from "./DiffViewerCodeLensProvider";
|
||||
export { QuickActionsCodeLensProvider } from "./QuickActionsCodeLensProvider";
|
||||
export { SuggestionsCodeLensProvider } from "./SuggestionsCodeLensProvider";
|
||||
|
|
|
|||
|
|
@ -118,11 +118,6 @@ export function registerAllCodeLensProviders(
|
|||
new providers.DiffViewerCodeLensProvider(diffManager),
|
||||
);
|
||||
|
||||
configPyCodeLensDisposable = registerCodeLensProvider(
|
||||
"*",
|
||||
new providers.ConfigPyCodeLensProvider(),
|
||||
);
|
||||
|
||||
registerQuickActionsProvider(config, context);
|
||||
|
||||
subscribeToVSCodeQuickActionsSettings(() =>
|
||||
|
|
@ -133,8 +128,5 @@ export function registerAllCodeLensProviders(
|
|||
context.subscriptions.push(suggestionsCodeLensDisposable);
|
||||
context.subscriptions.push(diffsCodeLensDisposable);
|
||||
|
||||
// was opening config UI from config.json. Not currently applicable.
|
||||
// context.subscriptions.push(configPyCodeLensDisposable);
|
||||
|
||||
return { verticalDiffCodeLens };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue