generate, include in build, and set in settings.json the schema

This commit is contained in:
Nate 2025-04-11 23:15:04 -07:00
parent 597425ece4
commit 7f70f17552
9 changed files with 120 additions and 4 deletions

View file

@ -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": {

View file

@ -25,4 +25,6 @@ e2e/vsix
e2e/test-continue/*
!e2e/test-continue/config.json
e2e/test-continue-yaml/*
!e2e/test-continue-yaml/config.yaml
!e2e/test-continue-yaml/config.yaml
config-yaml-schema.json

View file

@ -588,6 +588,10 @@
{
"fileMatch": ".continuerc.json",
"url": "./continue_rc_schema.json"
},
{
"fileMatch": "**/config.yaml",
"url": "./config-yaml-schema.json"
}
]
},

View file

@ -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();

View file

@ -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,

View file

@ -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),

3
gui/package-lock.json generated
View file

@ -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": {

1
packages/config-yaml/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
schema/

View file

@ -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": {