diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b44605..a1cd397 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: - name: Upload VSIX artifact uses: actions/upload-artifact@v4 with: - name: vscode-struct-${{ matrix.node-version }} + name: vscode-structkit-${{ matrix.node-version }} path: "*.vsix" retention-days: 30 @@ -109,7 +109,7 @@ jobs: - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: - files: ./vscode-struct-${{ steps.extract_version.outputs.version }}.vsix + files: ./vscode-structkit-${{ steps.extract_version.outputs.version }}.vsix tag_name: ${{ github.event.release.tag_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f11c5c..4bada73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,13 @@ -# Contributing to VS Code Struct Extension +# Contributing to the StructKit VS Code Extension -Thank you for your interest in contributing to the VS Code Struct Extension! +Thank you for your interest in contributing to vscode-structkit! ## Development Setup 1. **Clone the repository** ```bash - git clone https://github.com/httpdss/vscode-struct.git - cd vscode-struct + git clone https://github.com/httpdss/vscode-structkit.git + cd vscode-structkit ``` 2. **Install dependencies** @@ -24,7 +24,7 @@ Thank you for your interest in contributing to the VS Code Struct Extension! ```bash npm run compile npx vsce package - code --install-extension vscode-struct-*.vsix + code --install-extension vscode-structkit-*.vsix ``` ## Development Workflow @@ -106,9 +106,9 @@ If you need to manually update the version: ## Testing -- Test your changes with real `.struct.yaml` files +- Test your changes with real `.structkit.yaml` files (legacy `.struct.yaml` should still validate) - Verify schema validation works correctly -- Test both with and without the struct command installed +- Test both with and without the structkit command installed - Check that settings work properly ## Pull Request Guidelines diff --git a/README.md b/README.md index e1470de..a003364 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # StructKit for VS Code and Cursor -Companion to [StructKit](https://github.com/httpdss/structkit). Schema validation and autocomplete for `.struct.yaml`. Install the CLI with `pip install structkit`. Star the [core repo](https://github.com/httpdss/structkit). +Companion to [StructKit](https://github.com/httpdss/structkit). Schema validation and autocomplete for `.structkit.yaml` (legacy `.struct.yaml` is still supported). Install the CLI with `pip install structkit`. Star the [core repo](https://github.com/httpdss/structkit). ## Features -- **Schema Validation**: Automatic validation of `*.struct.yaml` files using the official StructKit schema +- **Schema Validation**: Automatic validation of `.structkit.yaml` / `*.structkit.yaml` files (and legacy `.struct.yaml` / `*.struct.yaml`) 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 @@ -23,7 +23,7 @@ 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` +- **From VSIX**: Download the `.vsix` file and install via `code --install-extension vscode-structkit-*.vsix` ## Configuration @@ -51,11 +51,13 @@ This extension contributes the following settings: ## Usage -1. Create or open a file with the `.struct.yaml` extension +1. Create or open a file named `.structkit.yaml` (or any `*.structkit.yaml`). Legacy `.struct.yaml` / `*.struct.yaml` files still work. 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 StructKit files +See [`example.structkit.yaml`](example.structkit.yaml) for a sample project file. + ## Requirements - VS Code or Cursor 1.74.0 or higher @@ -64,10 +66,16 @@ This extension contributes the following settings: ## Known Issues - Custom schema generation requires the `structkit` command to be available in your system -- Schema validation is currently optimized for `*.struct.yaml` files +- Schema validation applies to `.structkit.yaml` / `*.structkit.yaml`, with legacy `.struct.yaml` / `*.struct.yaml` still recognized ## Release Notes +### 0.2.0 + +- Recognize StructKit's default project file `.structkit.yaml` / `*.structkit.yaml` (introduced in structkit v3.3.0) +- Continue supporting legacy `.struct.yaml` / `*.struct.yaml` +- Rename the extension package to `vscode-structkit` (Marketplace ID becomes `kennethbelitzky.vscode-structkit`) + ### 0.1.0 Initial release of the official StructKit extension: diff --git a/example.struct.yaml b/example.structkit.yaml similarity index 100% rename from example.struct.yaml rename to example.structkit.yaml diff --git a/package-lock.json b/package-lock.json index 21cb323..7151042 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "vscode-struct", - "version": "0.1.0", + "name": "vscode-structkit", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "vscode-struct", - "version": "0.1.0", + "name": "vscode-structkit", + "version": "0.2.0", "license": "MIT", "devDependencies": { "@types/mocha": "^10.0.10", diff --git a/package.json b/package.json index 9ef0412..e134ce7 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "vscode-struct", + "name": "vscode-structkit", "displayName": "StructKit", "description": "Official StructKit extension for VS Code and Cursor with schema validation and intelligent autocomplete", - "version": "0.1.0", + "version": "0.2.0", "publisher": "kennethbelitzky", "engines": { "vscode": "^1.74.0" @@ -14,11 +14,45 @@ ], "activationEvents": [ "onLanguage:yaml", + "workspaceContains:**/.structkit.yaml", + "workspaceContains:**/*.structkit.yaml", "workspaceContains:**/.struct.yaml", "workspaceContains:**/*.struct.yaml" ], "main": "./out/extension.js", "contributes": { + "languages": [ + { + "id": "yaml", + "filenames": [ + ".structkit.yaml", + ".struct.yaml" + ], + "filenamePatterns": [ + "*.structkit.yaml", + "*.struct.yaml" + ] + } + ], + "yamlValidation": [ + { + "fileMatch": [ + ".structkit.yaml", + "*.structkit.yaml", + ".struct.yaml", + "*.struct.yaml" + ], + "url": "./schemas/struct-schema.json" + } + ], + "configurationDefaults": { + "files.associations": { + ".structkit.yaml": "yaml", + "*.structkit.yaml": "yaml", + ".struct.yaml": "yaml", + "*.struct.yaml": "yaml" + } + }, "configuration": { "title": "StructKit", "properties": { @@ -82,11 +116,11 @@ }, "repository": { "type": "git", - "url": "git+ssh://git@github.com/httpdss/vscode-struct.git" + "url": "git+ssh://git@github.com/httpdss/vscode-structkit.git" }, "bugs": { - "url": "https://github.com/httpdss/vscode-struct/issues" + "url": "https://github.com/httpdss/vscode-structkit/issues" }, - "homepage": "https://github.com/httpdss/vscode-struct#readme", + "homepage": "https://github.com/httpdss/vscode-structkit#readme", "license": "MIT" } diff --git a/src/extension.ts b/src/extension.ts index 0ae756d..66c705d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -17,9 +17,33 @@ import { promisify } from 'util'; const execAsync = promisify(exec); +/** Workspace globs for the default project file and `*.structkit.yaml` variants, plus legacy `.struct.yaml`. */ +export const STRUCTKIT_DOCUMENT_PATTERNS = [ + '**/.structkit.yaml', + '**/*.structkit.yaml', + '**/.struct.yaml', + '**/*.struct.yaml' +]; + +/** Schema association patterns consumed by the YAML language server (`yaml.schemas` / yamlValidation). */ +export const STRUCTKIT_SCHEMA_FILE_MATCH = [ + '.structkit.yaml', + '*.structkit.yaml', + '.struct.yaml', + '*.struct.yaml' +]; + let schemaProvider: vscode.Disposable | undefined; let statusBarItem: vscode.StatusBarItem; -let documentSelector: vscode.DocumentSelector = { pattern: '**/*.struct.yaml' }; +export const documentSelector: vscode.DocumentSelector = STRUCTKIT_DOCUMENT_PATTERNS.map(pattern => ({ pattern })); + +export function isStructKitConfigFile(filePath: string): boolean { + const base = path.basename(filePath); + return base === '.structkit.yaml' + || base === '.struct.yaml' + || base.endsWith('.structkit.yaml') + || base.endsWith('.struct.yaml'); +} export function activate(context: vscode.ExtensionContext) { console.log('StructKit extension is now active!'); @@ -244,13 +268,13 @@ function updateYamlSchemaAssociation(schemaUri: string) { const yamlConfig = vscode.workspace.getConfiguration('yaml'); const schemas: { [key: string]: string[] } = yamlConfig.get('schemas') || {}; - // Update the schema association for *.struct.yaml files - schemas[schemaUri] = ['*.struct.yaml']; + // Associate the schema with .structkit.yaml and legacy .struct.yaml files + schemas[schemaUri] = [...STRUCTKIT_SCHEMA_FILE_MATCH]; // Set the configuration yamlConfig.update('schemas', schemas, vscode.ConfigurationTarget.Workspace); - console.log(`[DEBUG] Updated YAML schema association:`, { [schemaUri]: ['*.struct.yaml'] }); + console.log(`[DEBUG] Updated YAML schema association:`, { [schemaUri]: STRUCTKIT_SCHEMA_FILE_MATCH }); } export function deactivate() { diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index ab79fa9..5019966 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -1,18 +1,46 @@ import * as assert from 'assert'; import * as vscode from 'vscode'; +import { + isStructKitConfigFile, + STRUCTKIT_DOCUMENT_PATTERNS, + STRUCTKIT_SCHEMA_FILE_MATCH +} from '../../extension'; + +const EXTENSION_ID = 'kennethbelitzky.vscode-structkit'; suite('Extension Test Suite', () => { vscode.window.showInformationMessage('Start all tests.'); test('Extension should be present', () => { - assert.ok(vscode.extensions.getExtension('httpdss.vscode-struct')); + assert.ok(vscode.extensions.getExtension(EXTENSION_ID)); }); test('Extension should activate', async () => { - const extension = vscode.extensions.getExtension('httpdss.vscode-struct'); + const extension = vscode.extensions.getExtension(EXTENSION_ID); if (extension) { await extension.activate(); assert.ok(extension.isActive); } }); + + test('recognizes .structkit.yaml and legacy .struct.yaml files', () => { + assert.ok(isStructKitConfigFile('/proj/.structkit.yaml')); + assert.ok(isStructKitConfigFile('/proj/app.structkit.yaml')); + assert.ok(isStructKitConfigFile('/proj/.struct.yaml')); + assert.ok(isStructKitConfigFile('/proj/app.struct.yaml')); + assert.strictEqual(isStructKitConfigFile('/proj/package.yaml'), false); + assert.strictEqual(isStructKitConfigFile('/proj/docker-compose.yml'), false); + }); + + test('includes new and legacy globs for activation-style matching', () => { + assert.ok(STRUCTKIT_DOCUMENT_PATTERNS.includes('**/.structkit.yaml')); + assert.ok(STRUCTKIT_DOCUMENT_PATTERNS.includes('**/*.structkit.yaml')); + assert.ok(STRUCTKIT_DOCUMENT_PATTERNS.includes('**/.struct.yaml')); + assert.ok(STRUCTKIT_DOCUMENT_PATTERNS.includes('**/*.struct.yaml')); + + assert.ok(STRUCTKIT_SCHEMA_FILE_MATCH.includes('.structkit.yaml')); + assert.ok(STRUCTKIT_SCHEMA_FILE_MATCH.includes('*.structkit.yaml')); + assert.ok(STRUCTKIT_SCHEMA_FILE_MATCH.includes('.struct.yaml')); + assert.ok(STRUCTKIT_SCHEMA_FILE_MATCH.includes('*.struct.yaml')); + }); });