From ae0279db6a2035ba7cc33a7af059c50b23d59c81 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Apr 2025 08:14:52 -0700 Subject: [PATCH 1/4] generate json schema --- packages/config-yaml/package-lock.json | 13 +- packages/config-yaml/package.json | 6 +- .../schema/config-yaml-schema.json | 1309 +++++++++++++++++ .../src/scripts/generateJsonSchema.ts | 28 + 4 files changed, 1353 insertions(+), 3 deletions(-) create mode 100644 packages/config-yaml/schema/config-yaml-schema.json create mode 100644 packages/config-yaml/src/scripts/generateJsonSchema.ts diff --git a/packages/config-yaml/package-lock.json b/packages/config-yaml/package-lock.json index bd174fa96..3f20958ea 100644 --- a/packages/config-yaml/package-lock.json +++ b/packages/config-yaml/package-lock.json @@ -22,7 +22,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/@ampproject/remapping": { @@ -3822,6 +3823,16 @@ "funding": { "url": "https://github.com/sponsors/colinhacks" } + }, + "node_modules/zod-to-json-schema": { + "version": "3.24.5", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.5.tgz", + "integrity": "sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g==", + "dev": true, + "license": "ISC", + "peerDependencies": { + "zod": "^3.24.1" + } } } } diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index f32235580..c2dfb6362 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -10,7 +10,8 @@ }, "scripts": { "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", - "build": "tsc" + "build": "tsc", + "generate-schema": "tsc && node dist/scripts/generateJsonSchema.js" }, "author": "Continue Dev, Inc.", "license": "Apache-2.0", @@ -25,6 +26,7 @@ "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" } } diff --git a/packages/config-yaml/schema/config-yaml-schema.json b/packages/config-yaml/schema/config-yaml-schema.json new file mode 100644 index 000000000..23d20f403 --- /dev/null +++ b/packages/config-yaml/schema/config-yaml-schema.json @@ -0,0 +1,1309 @@ +{ + "$ref": "#/definitions/ConfigYaml", + "definitions": { + "ConfigYaml": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "schema": { + "type": "string" + }, + "models": { + "type": "array", + "items": { + "anyOf": [ + { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "model": { + "type": "string" + }, + "apiKey": { + "type": "string" + }, + "apiBase": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "chat", + "autocomplete", + "embed", + "rerank", + "edit", + "apply", + "summarize" + ] + } + }, + "capabilities": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "tool_use", + "image_input" + ] + } + }, + "defaultCompletionOptions": { + "type": "object", + "properties": { + "contextLength": { + "type": "number" + }, + "maxTokens": { + "type": "number" + }, + "temperature": { + "type": "number" + }, + "topP": { + "type": "number" + }, + "topK": { + "type": "number" + }, + "stop": { + "type": "array", + "items": { + "type": "string" + } + }, + "n": { + "type": "number" + } + }, + "additionalProperties": false + }, + "requestOptions": { + "type": "object", + "properties": { + "timeout": { + "type": "number" + }, + "verifySsl": { + "type": "boolean" + }, + "caBundlePath": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "proxy": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "extraBodyProperties": { + "type": "object", + "additionalProperties": {} + }, + "noProxy": { + "type": "array", + "items": { + "type": "string" + } + }, + "clientCertificate": { + "type": "object", + "properties": { + "cert": { + "type": "string" + }, + "key": { + "type": "string" + }, + "passphrase": { + "type": "string" + } + }, + "required": [ + "cert", + "key" + ], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "embedOptions": { + "type": "object", + "properties": { + "maxChunkSize": { + "type": "number" + }, + "maxBatchSize": { + "type": "number" + } + }, + "additionalProperties": false + }, + "promptTemplates": { + "type": "object", + "properties": { + "apply": { + "type": "string" + }, + "edit": { + "type": "string" + } + }, + "additionalProperties": false + }, + "env": { + "type": "object", + "additionalProperties": { + "type": [ + "string", + "boolean", + "number" + ] + } + }, + "provider": { + "type": "string", + "const": "continue-proxy" + }, + "apiKeyLocation": { + "type": "string" + }, + "orgScopeId": { + "type": [ + "string", + "null" + ] + }, + "onPremProxyUrl": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "name", + "model", + "provider", + "apiKeyLocation", + "orgScopeId", + "onPremProxyUrl" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "model": { + "type": "string" + }, + "apiKey": { + "type": "string" + }, + "apiBase": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "chat", + "autocomplete", + "embed", + "rerank", + "edit", + "apply", + "summarize" + ] + } + }, + "capabilities": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "tool_use", + "image_input" + ] + } + }, + "defaultCompletionOptions": { + "type": "object", + "properties": { + "contextLength": { + "type": "number" + }, + "maxTokens": { + "type": "number" + }, + "temperature": { + "type": "number" + }, + "topP": { + "type": "number" + }, + "topK": { + "type": "number" + }, + "stop": { + "type": "array", + "items": { + "type": "string" + } + }, + "n": { + "type": "number" + } + }, + "additionalProperties": false + }, + "requestOptions": { + "type": "object", + "properties": { + "timeout": { + "type": "number" + }, + "verifySsl": { + "type": "boolean" + }, + "caBundlePath": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "proxy": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "extraBodyProperties": { + "type": "object", + "additionalProperties": {} + }, + "noProxy": { + "type": "array", + "items": { + "type": "string" + } + }, + "clientCertificate": { + "type": "object", + "properties": { + "cert": { + "type": "string" + }, + "key": { + "type": "string" + }, + "passphrase": { + "type": "string" + } + }, + "required": [ + "cert", + "key" + ], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "embedOptions": { + "type": "object", + "properties": { + "maxChunkSize": { + "type": "number" + }, + "maxBatchSize": { + "type": "number" + } + }, + "additionalProperties": false + }, + "promptTemplates": { + "type": "object", + "properties": { + "apply": { + "type": "string" + }, + "edit": { + "type": "string" + } + }, + "additionalProperties": false + }, + "env": { + "type": "object", + "additionalProperties": { + "type": [ + "string", + "boolean", + "number" + ] + } + }, + "provider": { + "type": "string" + } + }, + "required": [ + "name", + "model", + "provider" + ], + "additionalProperties": false + } + ] + }, + { + "type": "object", + "properties": { + "uses": { + "type": "string" + }, + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "override": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "model": { + "type": "string" + }, + "apiKey": { + "type": "string" + }, + "apiBase": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "chat", + "autocomplete", + "embed", + "rerank", + "edit", + "apply", + "summarize" + ] + } + }, + "capabilities": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "tool_use", + "image_input" + ] + } + }, + "defaultCompletionOptions": { + "type": "object", + "properties": { + "contextLength": { + "type": "number" + }, + "maxTokens": { + "type": "number" + }, + "temperature": { + "type": "number" + }, + "topP": { + "type": "number" + }, + "topK": { + "type": "number" + }, + "stop": { + "type": "array", + "items": { + "type": "string" + } + }, + "n": { + "type": "number" + } + }, + "additionalProperties": false + }, + "requestOptions": { + "type": "object", + "properties": { + "timeout": { + "type": "number" + }, + "verifySsl": { + "type": "boolean" + }, + "caBundlePath": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "proxy": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "extraBodyProperties": { + "type": "object", + "additionalProperties": {} + }, + "noProxy": { + "type": "array", + "items": { + "type": "string" + } + }, + "clientCertificate": { + "type": "object", + "properties": { + "cert": { + "type": "string" + }, + "key": { + "type": "string" + }, + "passphrase": { + "type": "string" + } + }, + "required": [ + "cert", + "key" + ], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "embedOptions": { + "type": "object", + "properties": { + "maxChunkSize": { + "type": "number" + }, + "maxBatchSize": { + "type": "number" + } + }, + "additionalProperties": false + }, + "promptTemplates": { + "type": "object", + "properties": { + "apply": { + "type": "string" + }, + "edit": { + "type": "string" + } + }, + "additionalProperties": false + }, + "env": { + "type": "object", + "additionalProperties": { + "type": [ + "string", + "boolean", + "number" + ] + } + }, + "provider": { + "type": "string", + "const": "continue-proxy" + }, + "apiKeyLocation": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "model": { + "type": "string" + }, + "apiKey": { + "type": "string" + }, + "apiBase": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "chat", + "autocomplete", + "embed", + "rerank", + "edit", + "apply", + "summarize" + ] + } + }, + "capabilities": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "tool_use", + "image_input" + ] + } + }, + "defaultCompletionOptions": { + "type": "object", + "properties": { + "contextLength": { + "type": "number" + }, + "maxTokens": { + "type": "number" + }, + "temperature": { + "type": "number" + }, + "topP": { + "type": "number" + }, + "topK": { + "type": "number" + }, + "stop": { + "type": "array", + "items": { + "type": "string" + } + }, + "n": { + "type": "number" + } + }, + "additionalProperties": false + }, + "requestOptions": { + "type": "object", + "properties": { + "timeout": { + "type": "number" + }, + "verifySsl": { + "type": "boolean" + }, + "caBundlePath": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "proxy": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "extraBodyProperties": { + "type": "object", + "additionalProperties": {} + }, + "noProxy": { + "type": "array", + "items": { + "type": "string" + } + }, + "clientCertificate": { + "type": "object", + "properties": { + "cert": { + "type": "string" + }, + "key": { + "type": "string" + }, + "passphrase": { + "type": "string" + } + }, + "required": [ + "cert", + "key" + ], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "embedOptions": { + "type": "object", + "properties": { + "maxChunkSize": { + "type": "number" + }, + "maxBatchSize": { + "type": "number" + } + }, + "additionalProperties": false + }, + "promptTemplates": { + "type": "object", + "properties": { + "apply": { + "type": "string" + }, + "edit": { + "type": "string" + } + }, + "additionalProperties": false + }, + "env": { + "type": "object", + "additionalProperties": { + "type": [ + "string", + "boolean", + "number" + ] + } + }, + "provider": { + "type": "string" + } + }, + "additionalProperties": false + } + ] + } + }, + "required": [ + "uses" + ], + "additionalProperties": false + } + ] + } + }, + "context": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "provider": { + "type": "string" + }, + "params": {} + }, + "required": [ + "provider" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "uses": { + "type": "string" + }, + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "override": { + "type": "object", + "properties": { + "provider": { + "type": "string" + }, + "params": {} + }, + "additionalProperties": false + } + }, + "required": [ + "uses" + ], + "additionalProperties": false + } + ] + } + }, + "data": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "destination": { + "type": "string" + }, + "schema": { + "type": "string", + "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$" + }, + "level": { + "type": "string", + "enum": [ + "all", + "noCode" + ] + }, + "events": { + "type": "array", + "items": { + "type": "string" + } + }, + "requestOptions": { + "type": "object", + "properties": { + "timeout": { + "type": "number" + }, + "verifySsl": { + "type": "boolean" + }, + "caBundlePath": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "proxy": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "extraBodyProperties": { + "type": "object", + "additionalProperties": {} + }, + "noProxy": { + "type": "array", + "items": { + "type": "string" + } + }, + "clientCertificate": { + "type": "object", + "properties": { + "cert": { + "type": "string" + }, + "key": { + "type": "string" + }, + "passphrase": { + "type": "string" + } + }, + "required": [ + "cert", + "key" + ], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "apiKey": { + "type": "string" + } + }, + "required": [ + "name", + "destination", + "schema" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "uses": { + "type": "string" + }, + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "override": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "destination": { + "type": "string" + }, + "schema": { + "type": "string", + "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$" + }, + "level": { + "type": "string", + "enum": [ + "all", + "noCode" + ] + }, + "events": { + "type": "array", + "items": { + "type": "string" + } + }, + "requestOptions": { + "type": "object", + "properties": { + "timeout": { + "type": "number" + }, + "verifySsl": { + "type": "boolean" + }, + "caBundlePath": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "proxy": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "extraBodyProperties": { + "type": "object", + "additionalProperties": {} + }, + "noProxy": { + "type": "array", + "items": { + "type": "string" + } + }, + "clientCertificate": { + "type": "object", + "properties": { + "cert": { + "type": "string" + }, + "key": { + "type": "string" + }, + "passphrase": { + "type": "string" + } + }, + "required": [ + "cert", + "key" + ], + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "apiKey": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "required": [ + "uses" + ], + "additionalProperties": false + } + ] + } + }, + "mcpServers": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "command": { + "type": "string" + }, + "faviconUrl": { + "type": "string" + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "name", + "command" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "uses": { + "type": "string" + }, + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "override": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "command": { + "type": "string" + }, + "faviconUrl": { + "type": "string" + }, + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "additionalProperties": false + } + }, + "required": [ + "uses" + ], + "additionalProperties": false + } + ] + } + }, + "rules": { + "type": "array", + "items": { + "anyOf": [ + { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "rule": { + "type": "string" + }, + "if": { + "type": "string" + } + }, + "required": [ + "name", + "rule" + ], + "additionalProperties": false + } + ] + }, + { + "type": "object", + "properties": { + "uses": { + "type": "string" + }, + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "uses" + ], + "additionalProperties": false + } + ] + } + }, + "prompts": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "prompt": { + "type": "string" + } + }, + "required": [ + "name", + "prompt" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "uses": { + "type": "string" + }, + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "override": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "prompt": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "required": [ + "uses" + ], + "additionalProperties": false + } + ] + } + }, + "docs": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "startUrl": { + "type": "string" + }, + "rootUrl": { + "type": "string" + }, + "faviconUrl": { + "type": "string" + } + }, + "required": [ + "name", + "startUrl" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "uses": { + "type": "string" + }, + "with": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "override": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "startUrl": { + "type": "string" + }, + "rootUrl": { + "type": "string" + }, + "faviconUrl": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "required": [ + "uses" + ], + "additionalProperties": false + } + ] + } + } + }, + "required": [ + "name", + "version" + ], + "additionalProperties": false + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" +} \ No newline at end of file diff --git a/packages/config-yaml/src/scripts/generateJsonSchema.ts b/packages/config-yaml/src/scripts/generateJsonSchema.ts new file mode 100644 index 000000000..308dcf951 --- /dev/null +++ b/packages/config-yaml/src/scripts/generateJsonSchema.ts @@ -0,0 +1,28 @@ +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { zodToJsonSchema } from 'zod-to-json-schema'; +import { configYamlSchema } from '../schemas/index.js'; + +// Get the directory name of the current module +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +// Convert Zod schema to JSON schema +const jsonSchema = zodToJsonSchema(configYamlSchema, { + $refStrategy: 'none', + name: 'ConfigYaml', +}); + +// Output directory and file path +const outDir = path.resolve(__dirname, '../../schema'); +const outFile = path.join(outDir, 'config-yaml-schema.json'); + +// Ensure output directory exists +if (!fs.existsSync(outDir)) { + fs.mkdirSync(outDir, { recursive: true }); +} + +// Write the JSON schema to file +fs.writeFileSync(outFile, JSON.stringify(jsonSchema, null, 2)); + +console.log(`JSON schema has been written to ${outFile}`); \ No newline at end of file From 7f70f17552e8d46e5c57fa262eee3a04374cee50 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 11 Apr 2025 23:15:04 -0700 Subject: [PATCH 2/4] generate, include in build, and set in settings.json the schema --- core/package-lock.json | 3 +- extensions/vscode/.gitignore | 4 +- extensions/vscode/package.json | 4 ++ extensions/vscode/scripts/prepackage.js | 9 ++- extensions/vscode/scripts/utils.js | 14 ++++ extensions/vscode/src/activation/activate.ts | 17 +++++ gui/package-lock.json | 3 +- packages/config-yaml/.gitignore | 1 + .../schema/config-yaml-schema.json | 69 +++++++++++++++++++ 9 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 packages/config-yaml/.gitignore 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": { From 2395875719fd405b2602010f705743f983a23177 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 11 Apr 2025 23:29:10 -0700 Subject: [PATCH 3/4] add common model slugs --- .../schema/config-yaml-schema.json | 1378 ----------------- .../config-yaml/src/schemas/commonSlugs.ts | 30 + packages/config-yaml/src/schemas/index.ts | 24 +- 3 files changed, 48 insertions(+), 1384 deletions(-) delete mode 100644 packages/config-yaml/schema/config-yaml-schema.json create mode 100644 packages/config-yaml/src/schemas/commonSlugs.ts diff --git a/packages/config-yaml/schema/config-yaml-schema.json b/packages/config-yaml/schema/config-yaml-schema.json deleted file mode 100644 index 187f6e1f7..000000000 --- a/packages/config-yaml/schema/config-yaml-schema.json +++ /dev/null @@ -1,1378 +0,0 @@ -{ - "$ref": "#/definitions/ConfigYaml", - "definitions": { - "ConfigYaml": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - }, - "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": { - "anyOf": [ - { - "anyOf": [ - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "model": { - "type": "string" - }, - "apiKey": { - "type": "string" - }, - "apiBase": { - "type": "string" - }, - "roles": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "chat", - "autocomplete", - "embed", - "rerank", - "edit", - "apply", - "summarize" - ] - } - }, - "capabilities": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "tool_use", - "image_input" - ] - } - }, - "defaultCompletionOptions": { - "type": "object", - "properties": { - "contextLength": { - "type": "number" - }, - "maxTokens": { - "type": "number" - }, - "temperature": { - "type": "number" - }, - "topP": { - "type": "number" - }, - "topK": { - "type": "number" - }, - "stop": { - "type": "array", - "items": { - "type": "string" - } - }, - "n": { - "type": "number" - } - }, - "additionalProperties": false - }, - "requestOptions": { - "type": "object", - "properties": { - "timeout": { - "type": "number" - }, - "verifySsl": { - "type": "boolean" - }, - "caBundlePath": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "proxy": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "extraBodyProperties": { - "type": "object", - "additionalProperties": {} - }, - "noProxy": { - "type": "array", - "items": { - "type": "string" - } - }, - "clientCertificate": { - "type": "object", - "properties": { - "cert": { - "type": "string" - }, - "key": { - "type": "string" - }, - "passphrase": { - "type": "string" - } - }, - "required": [ - "cert", - "key" - ], - "additionalProperties": false - } - }, - "additionalProperties": false - }, - "embedOptions": { - "type": "object", - "properties": { - "maxChunkSize": { - "type": "number" - }, - "maxBatchSize": { - "type": "number" - } - }, - "additionalProperties": false - }, - "chatOptions": { - "type": "object", - "properties": { - "baseSystemMessage": { - "type": "string" - } - }, - "additionalProperties": false - }, - "promptTemplates": { - "type": "object", - "properties": { - "apply": { - "type": "string" - }, - "edit": { - "type": "string" - } - }, - "additionalProperties": false - }, - "env": { - "type": "object", - "additionalProperties": { - "type": [ - "string", - "boolean", - "number" - ] - } - }, - "provider": { - "type": "string", - "const": "continue-proxy" - }, - "apiKeyLocation": { - "type": "string" - }, - "orgScopeId": { - "type": [ - "string", - "null" - ] - }, - "onPremProxyUrl": { - "type": [ - "string", - "null" - ] - } - }, - "required": [ - "name", - "model", - "provider", - "apiKeyLocation", - "orgScopeId", - "onPremProxyUrl" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "model": { - "type": "string" - }, - "apiKey": { - "type": "string" - }, - "apiBase": { - "type": "string" - }, - "roles": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "chat", - "autocomplete", - "embed", - "rerank", - "edit", - "apply", - "summarize" - ] - } - }, - "capabilities": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "tool_use", - "image_input" - ] - } - }, - "defaultCompletionOptions": { - "type": "object", - "properties": { - "contextLength": { - "type": "number" - }, - "maxTokens": { - "type": "number" - }, - "temperature": { - "type": "number" - }, - "topP": { - "type": "number" - }, - "topK": { - "type": "number" - }, - "stop": { - "type": "array", - "items": { - "type": "string" - } - }, - "n": { - "type": "number" - } - }, - "additionalProperties": false - }, - "requestOptions": { - "type": "object", - "properties": { - "timeout": { - "type": "number" - }, - "verifySsl": { - "type": "boolean" - }, - "caBundlePath": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "proxy": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "extraBodyProperties": { - "type": "object", - "additionalProperties": {} - }, - "noProxy": { - "type": "array", - "items": { - "type": "string" - } - }, - "clientCertificate": { - "type": "object", - "properties": { - "cert": { - "type": "string" - }, - "key": { - "type": "string" - }, - "passphrase": { - "type": "string" - } - }, - "required": [ - "cert", - "key" - ], - "additionalProperties": false - } - }, - "additionalProperties": false - }, - "embedOptions": { - "type": "object", - "properties": { - "maxChunkSize": { - "type": "number" - }, - "maxBatchSize": { - "type": "number" - } - }, - "additionalProperties": false - }, - "chatOptions": { - "type": "object", - "properties": { - "baseSystemMessage": { - "type": "string" - } - }, - "additionalProperties": false - }, - "promptTemplates": { - "type": "object", - "properties": { - "apply": { - "type": "string" - }, - "edit": { - "type": "string" - } - }, - "additionalProperties": false - }, - "env": { - "type": "object", - "additionalProperties": { - "type": [ - "string", - "boolean", - "number" - ] - } - }, - "provider": { - "type": "string" - } - }, - "required": [ - "name", - "model", - "provider" - ], - "additionalProperties": false - } - ] - }, - { - "type": "object", - "properties": { - "uses": { - "type": "string" - }, - "with": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "override": { - "anyOf": [ - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "model": { - "type": "string" - }, - "apiKey": { - "type": "string" - }, - "apiBase": { - "type": "string" - }, - "roles": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "chat", - "autocomplete", - "embed", - "rerank", - "edit", - "apply", - "summarize" - ] - } - }, - "capabilities": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "tool_use", - "image_input" - ] - } - }, - "defaultCompletionOptions": { - "type": "object", - "properties": { - "contextLength": { - "type": "number" - }, - "maxTokens": { - "type": "number" - }, - "temperature": { - "type": "number" - }, - "topP": { - "type": "number" - }, - "topK": { - "type": "number" - }, - "stop": { - "type": "array", - "items": { - "type": "string" - } - }, - "n": { - "type": "number" - } - }, - "additionalProperties": false - }, - "requestOptions": { - "type": "object", - "properties": { - "timeout": { - "type": "number" - }, - "verifySsl": { - "type": "boolean" - }, - "caBundlePath": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "proxy": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "extraBodyProperties": { - "type": "object", - "additionalProperties": {} - }, - "noProxy": { - "type": "array", - "items": { - "type": "string" - } - }, - "clientCertificate": { - "type": "object", - "properties": { - "cert": { - "type": "string" - }, - "key": { - "type": "string" - }, - "passphrase": { - "type": "string" - } - }, - "required": [ - "cert", - "key" - ], - "additionalProperties": false - } - }, - "additionalProperties": false - }, - "embedOptions": { - "type": "object", - "properties": { - "maxChunkSize": { - "type": "number" - }, - "maxBatchSize": { - "type": "number" - } - }, - "additionalProperties": false - }, - "chatOptions": { - "type": "object", - "properties": { - "baseSystemMessage": { - "type": "string" - } - }, - "additionalProperties": false - }, - "promptTemplates": { - "type": "object", - "properties": { - "apply": { - "type": "string" - }, - "edit": { - "type": "string" - } - }, - "additionalProperties": false - }, - "env": { - "type": "object", - "additionalProperties": { - "type": [ - "string", - "boolean", - "number" - ] - } - }, - "provider": { - "type": "string", - "const": "continue-proxy" - }, - "apiKeyLocation": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "model": { - "type": "string" - }, - "apiKey": { - "type": "string" - }, - "apiBase": { - "type": "string" - }, - "roles": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "chat", - "autocomplete", - "embed", - "rerank", - "edit", - "apply", - "summarize" - ] - } - }, - "capabilities": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "tool_use", - "image_input" - ] - } - }, - "defaultCompletionOptions": { - "type": "object", - "properties": { - "contextLength": { - "type": "number" - }, - "maxTokens": { - "type": "number" - }, - "temperature": { - "type": "number" - }, - "topP": { - "type": "number" - }, - "topK": { - "type": "number" - }, - "stop": { - "type": "array", - "items": { - "type": "string" - } - }, - "n": { - "type": "number" - } - }, - "additionalProperties": false - }, - "requestOptions": { - "type": "object", - "properties": { - "timeout": { - "type": "number" - }, - "verifySsl": { - "type": "boolean" - }, - "caBundlePath": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "proxy": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "extraBodyProperties": { - "type": "object", - "additionalProperties": {} - }, - "noProxy": { - "type": "array", - "items": { - "type": "string" - } - }, - "clientCertificate": { - "type": "object", - "properties": { - "cert": { - "type": "string" - }, - "key": { - "type": "string" - }, - "passphrase": { - "type": "string" - } - }, - "required": [ - "cert", - "key" - ], - "additionalProperties": false - } - }, - "additionalProperties": false - }, - "embedOptions": { - "type": "object", - "properties": { - "maxChunkSize": { - "type": "number" - }, - "maxBatchSize": { - "type": "number" - } - }, - "additionalProperties": false - }, - "chatOptions": { - "type": "object", - "properties": { - "baseSystemMessage": { - "type": "string" - } - }, - "additionalProperties": false - }, - "promptTemplates": { - "type": "object", - "properties": { - "apply": { - "type": "string" - }, - "edit": { - "type": "string" - } - }, - "additionalProperties": false - }, - "env": { - "type": "object", - "additionalProperties": { - "type": [ - "string", - "boolean", - "number" - ] - } - }, - "provider": { - "type": "string" - } - }, - "additionalProperties": false - } - ] - } - }, - "required": [ - "uses" - ], - "additionalProperties": false - } - ] - } - }, - "context": { - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "properties": { - "provider": { - "type": "string" - }, - "params": {} - }, - "required": [ - "provider" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "uses": { - "type": "string" - }, - "with": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "override": { - "type": "object", - "properties": { - "provider": { - "type": "string" - }, - "params": {} - }, - "additionalProperties": false - } - }, - "required": [ - "uses" - ], - "additionalProperties": false - } - ] - } - }, - "data": { - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "destination": { - "type": "string" - }, - "schema": { - "type": "string", - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$" - }, - "level": { - "type": "string", - "enum": [ - "all", - "noCode" - ] - }, - "events": { - "type": "array", - "items": { - "type": "string" - } - }, - "requestOptions": { - "type": "object", - "properties": { - "timeout": { - "type": "number" - }, - "verifySsl": { - "type": "boolean" - }, - "caBundlePath": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "proxy": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "extraBodyProperties": { - "type": "object", - "additionalProperties": {} - }, - "noProxy": { - "type": "array", - "items": { - "type": "string" - } - }, - "clientCertificate": { - "type": "object", - "properties": { - "cert": { - "type": "string" - }, - "key": { - "type": "string" - }, - "passphrase": { - "type": "string" - } - }, - "required": [ - "cert", - "key" - ], - "additionalProperties": false - } - }, - "additionalProperties": false - }, - "apiKey": { - "type": "string" - } - }, - "required": [ - "name", - "destination", - "schema" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "uses": { - "type": "string" - }, - "with": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "override": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "destination": { - "type": "string" - }, - "schema": { - "type": "string", - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$" - }, - "level": { - "type": "string", - "enum": [ - "all", - "noCode" - ] - }, - "events": { - "type": "array", - "items": { - "type": "string" - } - }, - "requestOptions": { - "type": "object", - "properties": { - "timeout": { - "type": "number" - }, - "verifySsl": { - "type": "boolean" - }, - "caBundlePath": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "proxy": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "extraBodyProperties": { - "type": "object", - "additionalProperties": {} - }, - "noProxy": { - "type": "array", - "items": { - "type": "string" - } - }, - "clientCertificate": { - "type": "object", - "properties": { - "cert": { - "type": "string" - }, - "key": { - "type": "string" - }, - "passphrase": { - "type": "string" - } - }, - "required": [ - "cert", - "key" - ], - "additionalProperties": false - } - }, - "additionalProperties": false - }, - "apiKey": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "required": [ - "uses" - ], - "additionalProperties": false - } - ] - } - }, - "mcpServers": { - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "command": { - "type": "string" - }, - "faviconUrl": { - "type": "string" - }, - "args": { - "type": "array", - "items": { - "type": "string" - } - }, - "env": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "required": [ - "name", - "command" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "uses": { - "type": "string" - }, - "with": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "override": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "command": { - "type": "string" - }, - "faviconUrl": { - "type": "string" - }, - "args": { - "type": "array", - "items": { - "type": "string" - } - }, - "env": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "additionalProperties": false - } - }, - "required": [ - "uses" - ], - "additionalProperties": false - } - ] - } - }, - "rules": { - "type": "array", - "items": { - "anyOf": [ - { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "rule": { - "type": "string" - }, - "if": { - "type": "string" - } - }, - "required": [ - "name", - "rule" - ], - "additionalProperties": false - } - ] - }, - { - "type": "object", - "properties": { - "uses": { - "type": "string" - }, - "with": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "required": [ - "uses" - ], - "additionalProperties": false - } - ] - } - }, - "prompts": { - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "prompt": { - "type": "string" - } - }, - "required": [ - "name", - "prompt" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "uses": { - "type": "string" - }, - "with": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "override": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "prompt": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "required": [ - "uses" - ], - "additionalProperties": false - } - ] - } - }, - "docs": { - "type": "array", - "items": { - "anyOf": [ - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "startUrl": { - "type": "string" - }, - "rootUrl": { - "type": "string" - }, - "faviconUrl": { - "type": "string" - } - }, - "required": [ - "name", - "startUrl" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "uses": { - "type": "string" - }, - "with": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "override": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "startUrl": { - "type": "string" - }, - "rootUrl": { - "type": "string" - }, - "faviconUrl": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "required": [ - "uses" - ], - "additionalProperties": false - } - ] - } - } - }, - "required": [ - "name", - "version" - ], - "additionalProperties": false - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/config-yaml/src/schemas/commonSlugs.ts b/packages/config-yaml/src/schemas/commonSlugs.ts new file mode 100644 index 000000000..3ba10bbd5 --- /dev/null +++ b/packages/config-yaml/src/schemas/commonSlugs.ts @@ -0,0 +1,30 @@ +export const commonModelSlugs = [ + "anthropic/claude-3-7-sonnet", + "togetherai/llama-4-maverick-instruct-17bx128e", + "google/gemini-2.5-pro", + "mistral/codestral", + "voyageai/voyage-code-3", + "relace/instant-apply", + "xai/grok-2", + "openai/gpt-4o", + "togetherai/llama-4-scout-instruct-17bx16e", + "anthropic/claude-3-5-sonnet", + "google/gemini-2.0-flash", + "voyageai/rerank-2", + "ollama/deepseek-r1", + "morphllm/morph-v0", + "anthropic/claude-3-5-haiku", + "lmstudio/deepseek-r1", + "openai/o3-mini", + "voyageai/voyage-code-2", + "ollama/qwen2.5-coder-1.5b", + "openai/gpt-4o-mini", + "openai/o1", + "mistral/mistral-embed", + "ollama/nomic-embed-text-latest", + "lmstudio/deepseek-r1-8b", + "mistral/mistral-large", + "lmstudio/qwen2.5-coder-1.5b", + "ollama/deepseek-r1-8b", + "openai/text-embedding-3-large", +]; diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 2b2ba0461..add4c38e7 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -1,4 +1,5 @@ import * as z from "zod"; +import { commonModelSlugs } from "./commonSlugs.js"; import { dataSchema } from "./data/index.js"; import { modelSchema, partialModelSchema } from "./models.js"; @@ -38,15 +39,22 @@ const ruleSchema = z.union([z.string(), ruleObjectSchema]); export type Rule = z.infer; -export const blockItemWrapperSchema = (schema: T) => +const defaultUsesSchema = z.string(); + +export const blockItemWrapperSchema = ( + schema: T, + usesSchema: z.ZodTypeAny = defaultUsesSchema, +) => z.object({ - uses: z.string(), + uses: usesSchema, with: z.record(z.string()).optional(), override: schema.partial().optional(), }); -export const blockOrSchema = (schema: T) => - z.union([schema, blockItemWrapperSchema(schema)]); +export const blockOrSchema = ( + schema: T, + usesSchema: z.ZodTypeAny = defaultUsesSchema, +) => z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); export const commonMetadataSchema = z.object({ tags: z.string().optional(), @@ -64,13 +72,17 @@ export const baseConfigYamlSchema = z.object({ metadata: z.record(z.string()).and(commonMetadataSchema.partial()).optional(), }); +const modelsUsesSchema = z + .string() + .or(z.enum(commonModelSlugs as [string, ...string[]])); + export const configYamlSchema = baseConfigYamlSchema.extend({ models: z .array( z.union([ modelSchema, z.object({ - uses: z.string(), + uses: modelsUsesSchema, with: z.record(z.string()).optional(), override: partialModelSchema.optional(), }), @@ -85,7 +97,7 @@ export const configYamlSchema = baseConfigYamlSchema.extend({ z.union([ ruleSchema, z.object({ - uses: z.string(), + uses: defaultUsesSchema, with: z.record(z.string()).optional(), }), ]), From 5f9c6a2f33ebcc29d6815d6c52618e19280630e2 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 11 Apr 2025 23:44:28 -0700 Subject: [PATCH 4/4] codelens to download yaml extension for intellisense --- .../DownloadYamlExtensionCodeLensProvider.ts | 34 +++++++++++++++++++ .../lang-server/codeLens/providers/index.ts | 1 + .../codeLens/registerAllCodeLensProviders.ts | 11 ++++++ 3 files changed, 46 insertions(+) create mode 100644 extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts diff --git a/extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts b/extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts new file mode 100644 index 000000000..dd46ad401 --- /dev/null +++ b/extensions/vscode/src/lang-server/codeLens/providers/DownloadYamlExtensionCodeLensProvider.ts @@ -0,0 +1,34 @@ +import * as vscode from "vscode"; + +export class DownloadYamlExtensionCodeLensProvider + implements vscode.CodeLensProvider +{ + private yamlExtensionDownloaded(): boolean { + const yamlExtension = vscode.extensions.getExtension("redhat.vscode-yaml"); + return yamlExtension !== undefined; + } + + public provideCodeLenses( + document: vscode.TextDocument, + _: vscode.CancellationToken, + ): vscode.CodeLens[] | Thenable { + if (!document.uri.fsPath.includes(".continue")) { + return []; + } + if (this.yamlExtensionDownloaded()) { + return []; + } + + const codeLens: vscode.CodeLens = { + range: new vscode.Range(0, 0, 0, 0), + command: { + title: "Download YAML extension for Intellisense", + command: "workbench.extensions.installExtension", + arguments: ["redhat.vscode-yaml"], + }, + isResolved: true, + }; + + return [codeLens]; + } +} diff --git a/extensions/vscode/src/lang-server/codeLens/providers/index.ts b/extensions/vscode/src/lang-server/codeLens/providers/index.ts index 00a309e62..03d89aa44 100644 --- a/extensions/vscode/src/lang-server/codeLens/providers/index.ts +++ b/extensions/vscode/src/lang-server/codeLens/providers/index.ts @@ -1,3 +1,4 @@ +export { DownloadYamlExtensionCodeLensProvider } from "./DownloadYamlExtensionCodeLensProvider"; export { QuickActionsCodeLensProvider } from "./QuickActionsCodeLensProvider"; export { SuggestionsCodeLensProvider } from "./SuggestionsCodeLensProvider"; export { VerticalDiffCodeLensProvider as VerticalPerLineCodeLensProvider } from "./VerticalPerLineCodeLensProvider"; diff --git a/extensions/vscode/src/lang-server/codeLens/registerAllCodeLensProviders.ts b/extensions/vscode/src/lang-server/codeLens/registerAllCodeLensProviders.ts index 9138fba8b..e17312fa0 100644 --- a/extensions/vscode/src/lang-server/codeLens/registerAllCodeLensProviders.ts +++ b/extensions/vscode/src/lang-server/codeLens/registerAllCodeLensProviders.ts @@ -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 downloadYamlExtensionCodeLensDisposable: 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 (downloadYamlExtensionCodeLensDisposable) { + downloadYamlExtensionCodeLensDisposable.dispose(); + } + const verticalDiffCodeLens = new providers.VerticalPerLineCodeLensProvider( editorToVerticalDiffCodeLens, ); @@ -110,6 +116,11 @@ export function registerAllCodeLensProviders( new providers.SuggestionsCodeLensProvider(), ); + downloadYamlExtensionCodeLensDisposable = registerCodeLensProvider( + "yaml", + new providers.DownloadYamlExtensionCodeLensProvider(), + ); + if (config) { registerQuickActionsProvider(config, context);