ReSim VS Code Extension
The ReSim VS Code Extension provides intelligent code assistance for working with ReSim's metrics configuration and Python emit calls. Get real-time validation, smart autocompletion, and comprehensive documentation in your editor to streamline your ReSim development workflow.
Features
YAML Configuration Support
Schema Validation - Real-time validation of your ReSim metrics configuration against the JSON schema, with support for conditional validation rules (e.g., template vs template_file requirements based on template_type).
SQL Syntax Validation - Validates SQL query syntax in your metrics configuration, ensuring queries are well-formed and catching syntax errors before deployment.
Rich Documentation on Hover - Get instant access to comprehensive documentation with examples and schema information by hovering over ReSim config elements.
Python Development Support
Topic Validation - Automatically validates topic names in your emit(), emit_series(), and emit_event() calls against your configuration, catching typos and undefined topics before runtime.
Data Schema Validation - Validates data dictionary keys and types passed to emit calls, ensuring they match the topic schema definition. Detects unknown keys and type mismatches.
Smart Autocompletion - Intelligent autocompletion for:
- Topic names in emit calls
- Data dictionary keys based on the topic schema
- Relevance-based sorting with fuzzy matching
Quick Fixes - Code actions that suggest similar topic names when an unknown topic is detected, with automatic replacement.
Jump-to-Definition Navigation - Navigate from topics in your emit() calls directly to their corresponding topic definitions in your YAML configuration files.
Hover Documentation - Rich hover information for emit calls showing topic schemas, field types, and links to configuration files.
Development Installation
GitHub Token Setup
This project uses GitHub Packages for some dependencies. You'll need a GitHub personal access token:
- Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
- Click Generate new token (classic)
- Give it a descriptive name (e.g., "npm packages")
- Select the following scopes:
repo (if accessing private packages)
read:packages
- Click Generate token and copy it
Then create your .npmrc file:
cp .npmrc.example .npmrc
# Edit .npmrc and replace <your classic github token...> with your token
CI Authentication
To keep CI authenticated with GitHub Packages, add your token as a repository secret:
- Go to the repository Settings > Secrets and variables > Actions
- Click New repository secret
- Name it
NPM_REGISTRY_TOKEN
- Paste your GitHub personal access token (same one from above)
- Click Add secret
The CI workflows will automatically use this secret to authenticate with GitHub Packages during npm ci.
Clone and Build
git clone https://github.com/resim-ai/resim-vscode-extension.git
cd resim-vscode-extension
npm install
npm run package
# Install the generated .vsix file
System Requirements
- VS Code: Version 1.90.0 or higher
- Node.js: Version 16+ (for development only)
- Operating System: Windows, macOS, or Linux
- Dependencies:
Key Technologies
- tree-sitter: Python AST parsing for accurate code analysis
- node-sql-parser: SQL syntax validation for metrics queries
- YAML: Schema validation and parsing for configuration files
Configuration
ReSim Project Structure
The extension automatically activates when it detects a ReSim metrics configuration file in your workspace. The file locations may be configured using resim.configFilePaths. If it is not configured, the extension will expect a configuration to exist at .resim/metrics/config.resim.{yml,yaml}.
Example default project structure:
your-project/
├── .resim/
│ └── metrics/
│ └── config.yml (or config.yaml)
└── **/your-python-files.py
Troubleshooting
Python Features Not Working
- Verify the extension has fully initialized by checking the ReSim output panel
- Ensure
tree-sitter initialization succeeded
- Python validation requires imports from ReSim's open-core library (
from resim.sdk.metrics.emissions import emit or from resim.sdk.metrics.emissions import Emitter)
- Close and reopen Python files after configuration changes to trigger re-validation
YAML Validation Issues
- The extension requires the RedHat YAML extension as a dependency (extension will prompt for this installation)
- Verify your config file follows the ReSim metrics schema
- Large Python files will take longer to parse
- Check the ReSim output panel for performance warnings and parser errors
Support
Development
Building and Testing
# Install dependencies
npm install
# Compile the extension
npm run compile
# Run tests
npm test
# Watch mode for development
npm run watch
Code Generation
This project uses automatic type generation from the JSON schema:
# Generate TypeScript types from schema
npm run codegen
When modifying src/schemas/resim-metrics-config.schema.json, the pre-commit hook will automatically regenerate the TypeScript types in src/types/generated/schema-types.ts. These generated types should be committed alongside schema changes.
See CONTRIBUTING.md for development setup and contribution guidelines.