converter
This commit is contained in:
parent
c3dd7af0a7
commit
33e77241de
7 changed files with 87 additions and 39 deletions
|
|
@ -1,35 +0,0 @@
|
|||
import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml";
|
||||
|
||||
import { SerializedContinueConfig } from "../..";
|
||||
|
||||
/*
|
||||
TODO this is not functional
|
||||
*/
|
||||
export function convertConfigJsonToConfigYaml(
|
||||
configJson: SerializedContinueConfig,
|
||||
): AssistantUnrolled {
|
||||
return {
|
||||
name: "Local Assistant",
|
||||
version: "1.0.0",
|
||||
schema: "v1",
|
||||
models: [
|
||||
...configJson.models.map(
|
||||
(model): ModelConfig => ({
|
||||
model: model.model,
|
||||
name: model.title,
|
||||
// defaultCompletionOptions: model.completionOptions,
|
||||
provider: model.provider,
|
||||
roles: ["chat", "edit", "apply", "summarize"],
|
||||
}),
|
||||
),
|
||||
// TODO
|
||||
// tabAutocompleteModels
|
||||
// embeddingsModels
|
||||
// rerankModels
|
||||
],
|
||||
context: configJson.contextProviders?.map((provider) => ({
|
||||
provider: provider.name,
|
||||
params: provider.params,
|
||||
})),
|
||||
};
|
||||
}
|
||||
7
extensions/vscode/package-lock.json
generated
7
extensions/vscode/package-lock.json
generated
|
|
@ -9,6 +9,7 @@
|
|||
"version": "1.1.23",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
"@reduxjs/toolkit": "^1.9.3",
|
||||
|
|
@ -690,9 +691,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-types": {
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.13.tgz",
|
||||
"integrity": "sha512-5Qmy2x58uhW1GYknypFT/7iwxEJSbt8gMgfQReV7d6xjbJ09ISOTki3hIfCilKrTCo0gIY6pzKEfCoQkUTEi6Q==",
|
||||
"version": "1.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
|
||||
"integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -665,6 +665,7 @@
|
|||
"vscode-extension-tester": "^8.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
"@reduxjs/toolkit": "^1.9.3",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
|
||||
import {
|
||||
|
|
@ -16,10 +17,15 @@ import { LOCAL_DEV_DATA_VERSION } from "core/data/log";
|
|||
import { walkDirAsync } from "core/indexing/walkDir";
|
||||
import { isModelInstaller } from "core/llm";
|
||||
import { startLocalOllama } from "core/util/ollamaHelper";
|
||||
import { getDevDataFilePath } from "core/util/paths";
|
||||
import {
|
||||
getConfigJsonPath,
|
||||
getConfigYamlPath,
|
||||
getDevDataFilePath,
|
||||
} from "core/util/paths";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import readLastLines from "read-last-lines";
|
||||
import * as vscode from "vscode";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import {
|
||||
getAutocompleteStatusBarDescription,
|
||||
|
|
@ -39,6 +45,8 @@ import { Battery } from "./util/battery";
|
|||
import { getMetaKeyLabel } from "./util/util";
|
||||
import { VsCodeIde } from "./VsCodeIde";
|
||||
|
||||
import { convertJsonToYamlConfig } from "../../../packages/config-yaml/dist";
|
||||
import { openEditorAndRevealRange } from "./util/vscode";
|
||||
import type { VsCodeWebviewProtocol } from "./webviewProtocol";
|
||||
|
||||
let fullScreenPanel: vscode.WebviewPanel | undefined;
|
||||
|
|
@ -1008,6 +1016,35 @@ const getCommandsMap: (
|
|||
);
|
||||
}
|
||||
},
|
||||
"continue.convertConfigJsonToConfigYaml": async () => {
|
||||
const configJson = fs.readFileSync(getConfigJsonPath(), "utf-8");
|
||||
const parsed = JSON.parse(configJson);
|
||||
const configYaml = convertJsonToYamlConfig(parsed);
|
||||
|
||||
const configYamlPath = getConfigYamlPath();
|
||||
fs.writeFileSync(configYamlPath, YAML.stringify(configYaml));
|
||||
|
||||
// Open config.yaml
|
||||
await openEditorAndRevealRange(
|
||||
vscode.Uri.file(configYamlPath),
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
);
|
||||
|
||||
vscode.window
|
||||
.showInformationMessage(
|
||||
"Your config.json has been converted to the new config.yaml format. If you need to switch back to config.json, you can delete or rename config.yaml.",
|
||||
"Read the docs",
|
||||
)
|
||||
.then((selection) => {
|
||||
if (selection === "Read the docs") {
|
||||
vscode.env.openExternal(
|
||||
vscode.Uri.parse("https://docs.continue.dev/yaml-migration"),
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
import { getConfigYamlPath } from "core/util/paths";
|
||||
import * as fs from "fs";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
export class ConfigJsonConverterCodeLensProvider
|
||||
implements vscode.CodeLensProvider
|
||||
{
|
||||
public provideCodeLenses(
|
||||
document: vscode.TextDocument,
|
||||
_: vscode.CancellationToken,
|
||||
): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> {
|
||||
if (
|
||||
!document.uri.fsPath.includes(".continue") ||
|
||||
!document.uri.fsPath.endsWith("config.json")
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (fs.existsSync(getConfigYamlPath())) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
new vscode.CodeLens(new vscode.Range(0, 0, 0, 0), {
|
||||
title: "config.json is being deprecated. Convert to config.yaml",
|
||||
command: "continue.convertConfigJsonToConfigYaml",
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
export { QuickActionsCodeLensProvider } from "./QuickActionsCodeLensProvider";
|
||||
export { SuggestionsCodeLensProvider } from "./SuggestionsCodeLensProvider";
|
||||
export { VerticalDiffCodeLensProvider as VerticalPerLineCodeLensProvider } from "./VerticalPerLineCodeLensProvider";
|
||||
|
||||
export { ConfigJsonConverterCodeLensProvider } from "./ConfigJsonConverterCodeLensProvider";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ let suggestionsCodeLensDisposable: vscode.Disposable | undefined = undefined;
|
|||
let configPyCodeLensDisposable: vscode.Disposable | undefined = undefined;
|
||||
let tutorialCodeLensDisposable: vscode.Disposable | undefined = undefined;
|
||||
let quickActionsCodeLensDisposable: vscode.Disposable | undefined = undefined;
|
||||
let configJsonConverterCodeLensDisposable: vscode.Disposable | undefined =
|
||||
undefined;
|
||||
|
||||
/**
|
||||
* Registers the Quick Actions CodeLens provider if Quick Actions are enabled.
|
||||
|
|
@ -96,6 +98,10 @@ export function registerAllCodeLensProviders(
|
|||
tutorialCodeLensDisposable.dispose();
|
||||
}
|
||||
|
||||
if (configJsonConverterCodeLensDisposable) {
|
||||
configJsonConverterCodeLensDisposable.dispose();
|
||||
}
|
||||
|
||||
const verticalDiffCodeLens = new providers.VerticalPerLineCodeLensProvider(
|
||||
editorToVerticalDiffCodeLens,
|
||||
);
|
||||
|
|
@ -110,6 +116,11 @@ export function registerAllCodeLensProviders(
|
|||
new providers.SuggestionsCodeLensProvider(),
|
||||
);
|
||||
|
||||
configJsonConverterCodeLensDisposable = registerCodeLensProvider(
|
||||
"*",
|
||||
new providers.ConfigJsonConverterCodeLensProvider(),
|
||||
);
|
||||
|
||||
if (config) {
|
||||
registerQuickActionsProvider(config, context);
|
||||
|
||||
|
|
@ -120,6 +131,7 @@ export function registerAllCodeLensProviders(
|
|||
|
||||
context.subscriptions.push(verticalPerLineCodeLensProvider);
|
||||
context.subscriptions.push(suggestionsCodeLensDisposable);
|
||||
context.subscriptions.push(configJsonConverterCodeLensDisposable);
|
||||
|
||||
return { verticalDiffCodeLens };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue