From 2e04c34d9b4dc8b66d3cc7688e5d316783141e40 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 23 Aug 2026 19:59:34 +0000 Subject: [PATCH] Rebrand extension from Struct to StructKit - Update displayName to 'StructKit' and description - Migrate settings from struct.* to structkit.* with deprecation warnings for old keys - Change default CLI path from 'struct' to 'structkit' - Update command category to 'StructKit' - Add activation for .struct.yaml and *.struct.yaml files - Update README with StructKit branding and pip install instructions - Update status bar and error messages to reference StructKit - Add config fallback to support old struct.* settings during migration - Update bundled schema to official StructKit schema (includes new 'sources' property) - Keep publisher as kennethbelitzky - Version remains 0.1.0 Co-authored-by: Kenneth Belitzky --- README.md | 68 ++++++++++++++++++++++---------------- package.json | 32 +++++++++++++----- schemas/struct-schema.json | 22 ++++++++++++ src/extension.ts | 50 ++++++++++++++++++---------- 4 files changed, 117 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 1186e77..b335e4e 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,82 @@ -# Struct YAML Support for VS Code +# StructKit -A VS Code extension that provides enhanced support for struct YAML configuration files with schema validation and intelligent autocomplete. +Official StructKit extension for VS Code and Cursor with schema validation and intelligent autocomplete for `.struct.yaml` configuration files. ## Features -- **Schema Validation**: Automatic validation of `*.struct.yaml` files using the official struct schema -- **Custom Schema Generation**: Generate custom schemas based on your struct configurations -- **Intelligent Autocomplete**: Get suggestions and validation while editing struct files -- **Configurable Struct Path**: Set custom path to your struct command executable +- **Schema Validation**: Automatic validation of `*.struct.yaml` files using the official StructKit schema +- **Custom Schema Generation**: Generate custom schemas based on your StructKit configurations +- **Intelligent Autocomplete**: Get suggestions and validation while editing StructKit files +- **Configurable CLI Path**: Set custom path to your `structkit` command executable - **Custom Structures Support**: Configure path to custom structures for enhanced validation +## Installation + +### Prerequisites + +Install the StructKit CLI: + +```bash +pip install structkit +``` + +### Extension Installation + +- **From Marketplace** (coming soon): Search for "StructKit" in VS Code/Cursor extensions +- **From VSIX**: Download the `.vsix` file and install via `code --install-extension structkit-*.vsix` + ## Configuration ### Extension Settings This extension contributes the following settings: -- `struct.commandPath`: Path to the struct command executable (default: `struct`) -- `struct.customStructuresPath`: Path to custom structures directory (default: empty) +- `structkit.commandPath`: Path to the structkit command executable (default: `structkit`) +- `structkit.customStructuresPath`: Path to custom structures directory (default: empty) ### Setting up the Extension 1. Install the extension -2. Configure the struct command path in VS Code settings: +2. Install StructKit CLI: `pip install structkit` +3. Configure the structkit command path in VS Code settings (optional): - Open VS Code settings (Ctrl/Cmd + ,) - - Search for "struct" - - Set `struct.commandPath` to the path of your struct executable - - Optionally set `struct.customStructuresPath` to your custom structures directory + - Search for "structkit" + - Set `structkit.commandPath` to the path of your structkit executable + - Optionally set `structkit.customStructuresPath` to your custom structures directory ## Commands -- `Struct: Generate Custom Schema` - Generate a custom schema based on your struct configuration -- `Struct: Refresh Schema` - Refresh the schema validation +- `StructKit: Generate Custom Schema` - Generate a custom schema based on your StructKit configuration +- `StructKit: Refresh Schema` - Refresh the schema validation ## Usage 1. Create or open a file with the `.struct.yaml` extension 2. The extension will automatically apply schema validation 3. If you have custom structures configured, use the "Generate Custom Schema" command to create enhanced validation -4. Enjoy intelligent autocomplete and validation while editing your struct files +4. Enjoy intelligent autocomplete and validation while editing your StructKit files ## Requirements -- VS Code 1.74.0 or higher -- struct command-line tool (optional, for custom schema generation) - -## Extension Settings - -This extension contributes the following settings: - -* `struct.commandPath`: Path to the struct command executable -* `struct.customStructuresPath`: Path to custom structures directory +- VS Code or Cursor 1.74.0 or higher +- StructKit CLI: `pip install structkit` (required for custom schema generation) ## Known Issues -- Custom schema generation requires the struct command to be available in your system -- Schema validation is currently limited to `*.struct.yaml` files +- Custom schema generation requires the `structkit` command to be available in your system +- Schema validation is currently optimized for `*.struct.yaml` files ## Release Notes ### 0.1.0 -Initial release of Struct YAML Support extension: +Initial release of the official StructKit extension: -- Basic schema validation for `*.struct.yaml` files +- Schema validation for `*.struct.yaml` files using official StructKit schema - Custom schema generation support -- Configurable struct command path +- Configurable structkit command path - Custom structures path configuration +- Support for VS Code and Cursor ## Contributing diff --git a/package.json b/package.json index 870cd27..9ef0412 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vscode-struct", - "displayName": "Struct YAML Support", - "description": "VS Code extension for struct YAML configuration files with schema validation", + "displayName": "StructKit", + "description": "Official StructKit extension for VS Code and Cursor with schema validation and intelligent autocomplete", "version": "0.1.0", "publisher": "kennethbelitzky", "engines": { @@ -13,22 +13,36 @@ "Formatters" ], "activationEvents": [ - "onLanguage:yaml" + "onLanguage:yaml", + "workspaceContains:**/.struct.yaml", + "workspaceContains:**/*.struct.yaml" ], "main": "./out/extension.js", "contributes": { "configuration": { - "title": "Struct", + "title": "StructKit", "properties": { + "structkit.commandPath": { + "type": "string", + "default": "structkit", + "description": "Path to the structkit command executable" + }, + "structkit.customStructuresPath": { + "type": "string", + "default": "", + "description": "Path to custom structures directory" + }, "struct.commandPath": { "type": "string", - "default": "struct", - "description": "Path to the struct command executable" + "default": "structkit", + "description": "Deprecated: Use structkit.commandPath instead", + "deprecationMessage": "This setting is deprecated. Please use structkit.commandPath instead." }, "struct.customStructuresPath": { "type": "string", "default": "", - "description": "Path to custom structures directory" + "description": "Deprecated: Use structkit.customStructuresPath instead", + "deprecationMessage": "This setting is deprecated. Please use structkit.customStructuresPath instead." } } }, @@ -36,12 +50,12 @@ { "command": "struct.generateSchema", "title": "Generate Custom Schema", - "category": "Struct" + "category": "StructKit" }, { "command": "struct.refreshSchema", "title": "Refresh Schema", - "category": "Struct" + "category": "StructKit" } ] }, diff --git a/schemas/struct-schema.json b/schemas/struct-schema.json index d384f7a..b0e969f 100644 --- a/schemas/struct-schema.json +++ b/schemas/struct-schema.json @@ -98,6 +98,28 @@ } } }, + "sources": { + "type": "object", + "description": "File-local named structure sources. These override user-level sources at the top level and are inherited by nested structs.", + "patternProperties": { + ".*": { + "oneOf": [ + { "type": "string" }, + { + "type": "object", + "properties": { + "path": { "type": "string" }, + "url": { "type": "string" } + }, + "additionalProperties": false, + "minProperties": 1, + "maxProperties": 1 + } + ] + } + }, + "additionalProperties": false + }, "pre_hooks": { "type": "array", "items": { "type": "string" }, diff --git a/src/extension.ts b/src/extension.ts index c4146e4..0ae756d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,9 +1,9 @@ function updateStatusBar(isAvailable: boolean) { if (isAvailable) { - statusBarItem.text = 'Struct: $(check) Available'; + statusBarItem.text = 'StructKit: $(check) Available'; statusBarItem.color = 'lightgreen'; } else { - statusBarItem.text = 'Struct: $(x) Not Available'; + statusBarItem.text = 'StructKit: $(x) Not Available'; statusBarItem.color = 'red'; } statusBarItem.show(); @@ -22,7 +22,7 @@ let statusBarItem: vscode.StatusBarItem; let documentSelector: vscode.DocumentSelector = { pattern: '**/*.struct.yaml' }; export function activate(context: vscode.ExtensionContext) { - console.log('Struct YAML extension is now active!'); + console.log('StructKit extension is now active!'); // Create status bar item statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); @@ -31,7 +31,7 @@ export function activate(context: vscode.ExtensionContext) { // Register configuration change listener const configWatcher = vscode.workspace.onDidChangeConfiguration(event => { - if (event.affectsConfiguration('struct')) { + if (event.affectsConfiguration('structkit') || event.affectsConfiguration('struct')) { updateSchemaForStructFiles(); } }); @@ -55,10 +55,27 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(configWatcher, generateSchemaCommand, refreshSchemaCommand); } +function getConfig(key: string, defaultValue: string): string { + // Try new structkit config first, fall back to old struct config + const newConfig = vscode.workspace.getConfiguration('structkit'); + const oldConfig = vscode.workspace.getConfiguration('struct'); + + const newValue = newConfig.get(key); + if (newValue !== undefined && newValue !== '') { + return newValue; + } + + const oldValue = oldConfig.get(key); + if (oldValue !== undefined && oldValue !== '') { + return oldValue; + } + + return defaultValue; +} + async function updateSchemaForStructFiles() { - const config = vscode.workspace.getConfiguration('struct'); - const structPath = config.get('commandPath', 'struct'); - const customStructuresPath = config.get('customStructuresPath', ''); + const structPath = getConfig('commandPath', 'structkit'); + const customStructuresPath = getConfig('customStructuresPath', ''); try { // Check if struct command is available @@ -72,33 +89,32 @@ async function updateSchemaForStructFiles() { await generateCustomSchema(); } } catch (error: any) { - console.log(`[DEBUG] Command failed: ${structPath} list`); + console.log(`[DEBUG] Command failed: ${structPath} list`); console.log(`[DEBUG] Error:`, error.message || error); - console.log('Struct command not found or not working, using default schema'); + console.log('StructKit command not found or not working, using default schema'); updateStatusBar(false); - vscode.window.showWarningMessage(`Struct command not found. Please [install](https://github.com/httpdss/struct/blob/main/docs/installation.md) it to use all features of this extension.`, 'Install').then(selection => { + vscode.window.showWarningMessage('StructKit CLI not found. Install it with: pip install structkit', 'Install').then(selection => { if (selection === 'Install') { - vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/httpdss/struct/blob/main/docs/installation.md')); + vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/httpdss/structkit')); } }); } } async function generateCustomSchema(): Promise { - const config = vscode.workspace.getConfiguration('struct'); - const structPath = config.get('commandPath', 'struct'); - const customStructuresPath = config.get('customStructuresPath', ''); + const structPath = getConfig('commandPath', 'structkit'); + const customStructuresPath = getConfig('customStructuresPath', ''); - // Check if struct command is available first + // Check if structkit command is available first try { await execAsync(`${structPath} list`); } catch (error) { vscode.window.showErrorMessage( - 'Struct command not found. Please install it first to generate custom schemas.', + 'StructKit CLI not found. Install it with: pip install structkit', 'Install' ).then(selection => { if (selection === 'Install') { - vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/httpdss/struct/blob/main/docs/installation.md')); + vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/httpdss/structkit')); } }); return;