Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 }}
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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**
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 39 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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": {
Expand Down Expand Up @@ -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"
}
32 changes: 28 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
Expand Down Expand Up @@ -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() {
Expand Down
32 changes: 30 additions & 2 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
@@ -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'));
});
});
Loading