diff --git a/core/package-lock.json b/core/package-lock.json index 494992220..d06bd61f5 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -126,7 +126,8 @@ "cross-env": "^7.0.3", "jest": "^29.7.0", "ts-jest": "^29.2.3", - "ts-node": "^10.9.2" + "ts-node": "^10.9.2", + "zod-to-json-schema": "^3.24.5" } }, "node_modules/@75lb/deep-merge": { diff --git a/extensions/vscode/.gitignore b/extensions/vscode/.gitignore index aa99f752c..e4f2af902 100644 --- a/extensions/vscode/.gitignore +++ b/extensions/vscode/.gitignore @@ -25,4 +25,6 @@ e2e/vsix e2e/test-continue/* !e2e/test-continue/config.json e2e/test-continue-yaml/* -!e2e/test-continue-yaml/config.yaml \ No newline at end of file +!e2e/test-continue-yaml/config.yaml + +config-yaml-schema.json \ No newline at end of file diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 088ac0001..79b03de94 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -588,6 +588,10 @@ { "fileMatch": ".continuerc.json", "url": "./continue_rc_schema.json" + }, + { + "fileMatch": "**/config.yaml", + "url": "./config-yaml-schema.json" } ] }, diff --git a/extensions/vscode/scripts/prepackage.js b/extensions/vscode/scripts/prepackage.js index fbec94f6c..c16e627c3 100644 --- a/extensions/vscode/scripts/prepackage.js +++ b/extensions/vscode/scripts/prepackage.js @@ -10,7 +10,11 @@ const { autodetectPlatformAndArch, } = require("../../../scripts/util/index"); -const { copyConfigSchema, writeBuildTimestamp } = require("./utils"); +const { + copyConfigSchema, + writeBuildTimestamp, + generateConfigYamlSchema, +} = require("./utils"); // Clear folders that will be packaged to ensure clean slate rimrafSync(path.join(__dirname, "..", "bin")); @@ -63,6 +67,9 @@ const isMacTarget = target?.startsWith("darwin"); (async () => { console.log("[info] Packaging extension for target ", target); + // Generate and copy over config-yaml-schema.json + generateConfigYamlSchema(); + // Copy config schemas to intellij copyConfigSchema(); diff --git a/extensions/vscode/scripts/utils.js b/extensions/vscode/scripts/utils.js index 8a144731f..7023b6372 100644 --- a/extensions/vscode/scripts/utils.js +++ b/extensions/vscode/scripts/utils.js @@ -10,7 +10,20 @@ const { const continueDir = path.join(__dirname, "..", "..", ".."); +function generateConfigYamlSchema() { + process.chdir(path.join(continueDir, "packages", "config-yaml")); + execCmdSync("npm install"); + execCmdSync("npm run build"); + execCmdSync("npm run generate-schema"); + fs.copyFileSync( + path.join("schema", "config-yaml-schema.json"), + path.join(continueDir, "extensions", "vscode", "config-yaml-schema.json"), + ); + console.log("[info] Generated config.yaml schema"); +} + function copyConfigSchema() { + process.chdir(path.join(continueDir, "extensions", "vscode")); // Modify and copy for .continuerc.json const schema = JSON.parse(fs.readFileSync("config_schema.json", "utf8")); schema.$defs.SerializedContinueConfig.properties.mergeBehavior = { @@ -526,6 +539,7 @@ function writeBuildTimestamp() { } module.exports = { + generateConfigYamlSchema, copyConfigSchema, installNodeModules, buildGui, diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 1bd22c7f4..bfc344b06 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -2,6 +2,7 @@ import { getContinueRcPath, getTsConfigPath } from "core/util/paths"; import { Telemetry } from "core/util/posthog"; import * as vscode from "vscode"; +import * as path from "path"; import { VsCodeExtension } from "../extension/VsCodeExtension"; import registerQuickFixProvider from "../lang-server/codeActions"; import { getExtensionVersion } from "../util/util"; @@ -32,6 +33,22 @@ export async function activateExtension(context: vscode.ExtensionContext) { ); } + // Only set the YAML schema configuration if it hasn't been set before + if (!context.globalState.get("yamlSchemaConfigured")) { + vscode.workspace.getConfiguration("yaml").update( + "schemas", + { + [path.join( + context.extension.extensionUri.fsPath, + "config-yaml-schema.json", + )]: [".continue/**/*.yaml"], + }, + vscode.ConfigurationTarget.Global, + ); + // Mark that we've configured the YAML schema + context.globalState.update("yamlSchemaConfigured", true); + } + const api = new VsCodeContinueApi(vscodeExtension); const continuePublicApi = { registerCustomContextProvider: api.registerCustomContextProvider.bind(api), diff --git a/gui/package-lock.json b/gui/package-lock.json index 2105fc59b..ef66ddbcc 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -222,7 +222,8 @@ "cross-env": "^7.0.3", "jest": "^29.7.0", "ts-jest": "^29.2.3", - "ts-node": "^10.9.2" + "ts-node": "^10.9.2", + "zod-to-json-schema": "^3.24.5" } }, "node_modules/@adobe/css-tools": { diff --git a/packages/config-yaml/.gitignore b/packages/config-yaml/.gitignore new file mode 100644 index 000000000..b73759d7b --- /dev/null +++ b/packages/config-yaml/.gitignore @@ -0,0 +1 @@ +schema/ \ No newline at end of file diff --git a/packages/config-yaml/schema/config-yaml-schema.json b/packages/config-yaml/schema/config-yaml-schema.json index 23d20f403..187f6e1f7 100644 --- a/packages/config-yaml/schema/config-yaml-schema.json +++ b/packages/config-yaml/schema/config-yaml-schema.json @@ -13,6 +13,39 @@ "schema": { "type": "string" }, + "metadata": { + "allOf": [ + { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + { + "type": "object", + "properties": { + "tags": { + "type": "string" + }, + "sourceCodeUrl": { + "type": "string" + }, + "description": { + "type": "string" + }, + "author": { + "type": "string" + }, + "license": { + "type": "string" + }, + "iconUrl": { + "type": "string" + } + } + } + ] + }, "models": { "type": "array", "items": { @@ -164,6 +197,15 @@ }, "additionalProperties": false }, + "chatOptions": { + "type": "object", + "properties": { + "baseSystemMessage": { + "type": "string" + } + }, + "additionalProperties": false + }, "promptTemplates": { "type": "object", "properties": { @@ -361,6 +403,15 @@ }, "additionalProperties": false }, + "chatOptions": { + "type": "object", + "properties": { + "baseSystemMessage": { + "type": "string" + } + }, + "additionalProperties": false + }, "promptTemplates": { "type": "object", "properties": { @@ -555,6 +606,15 @@ }, "additionalProperties": false }, + "chatOptions": { + "type": "object", + "properties": { + "baseSystemMessage": { + "type": "string" + } + }, + "additionalProperties": false + }, "promptTemplates": { "type": "object", "properties": { @@ -732,6 +792,15 @@ }, "additionalProperties": false }, + "chatOptions": { + "type": "object", + "properties": { + "baseSystemMessage": { + "type": "string" + } + }, + "additionalProperties": false + }, "promptTemplates": { "type": "object", "properties": {