GoRules JDM Editor for VS Code
A powerful VS Code extension that provides a visual editor for GoRules JDM (JSON Decision Model) files, allowing you to create, edit, and simulate decision models directly within VS Code.
Features
- Visual JDM Editor: Edit JSON decision models using an intuitive visual interface
- JSON Mode Toggle: Switch between visual editor and raw JSON editing
- Integrated Simulator: Test your decision models with custom input data
- Real-time Preview: See changes instantly as you edit
- Monaco Editor Integration: Advanced code editing for function nodes
- Theme Support: Works with both light and dark VS Code themes
Installation
Option 1: Install from VSIX (Recommended for testing)
- Download the
gorules-vscode-0.0.1.vsix
file
- Open VS Code or Cursor
- Press
Cmd+Shift+P
(macOS) or Ctrl+Shift+P
(Windows/Linux)
- Type "Extensions: Install from VSIX..."
- Select the downloaded
.vsix
file
Option 2: Install from VS Code Marketplace (Coming Soon)
- Open VS Code or Cursor
- Go to Extensions (
Cmd+Shift+X
or Ctrl+Shift+X
)
- Search for "GoRules JDM Editor"
- Click Install
Usage
Opening the JDM Editor
- Open any JSON file in VS Code
- Use one of these methods to open the JDM Editor:
- Command Palette: Press
Cmd+Shift+P
and type "GoRules: Open with JDM Editor"
- Right-click: Right-click on the JSON file and select "Open with JDM Editor"
- Editor Button: Click the toggle button in the editor title bar
Using the Visual Editor
The JDM Editor provides a visual interface for creating and editing decision models:
- Add Nodes: Use the "+" button or drag node types from the palette
- Connect Nodes: Drag from node outputs to inputs to create connections
- Edit Properties: Click on nodes to edit their properties
- Delete Elements: Select nodes/edges and press Delete
Running Simulations
- Open the JDM Editor
- Click on the "Simulator" panel (bottom of the editor)
- Enter your input data in JSON format
- Click "Run" to execute the simulation
- View the results, performance metrics, and execution trace
Toggling Between Modes
- Visual Mode: See your decision model as a visual graph
- JSON Mode: Edit the raw JSON structure directly
- Toggle: Use the toggle button in the editor title bar or the "GoRules: Toggle Mode" command
Supported Node Types
The JDM Editor supports all standard GoRules node types:
- Input Node: Define input data structure
- Output Node: Define output data structure
- Decision Table: Create rule-based decisions
- Function Node: Write custom JavaScript functions
- Expression Node: Create mathematical expressions
- Switch Node: Create conditional branching
- And/Or Nodes: Logical operations
Configuration
You can configure default input data for simulations in VS Code settings:
{
"gorules.defaultInput": {
"customer": {
"country": "US",
"age": 30
},
"order": {
"amount": 100
}
}
}
Examples
Simple Decision Model
{
"nodes": [
{
"id": "input-1",
"type": "input",
"position": { "x": 100, "y": 100 },
"data": {
"name": "customer",
"type": "object"
}
},
{
"id": "decision-1",
"type": "decisionTable",
"position": { "x": 300, "y": 100 },
"data": {
"name": "calculateDiscount",
"rules": [
{
"condition": "customer.country == 'US'",
"output": { "discount": 0.1 }
}
]
}
},
{
"id": "output-1",
"type": "output",
"position": { "x": 500, "y": 100 },
"data": {
"name": "result"
}
}
],
"edges": [
{
"id": "edge-1",
"source": "input-1",
"target": "decision-1"
},
{
"id": "edge-2",
"source": "decision-1",
"target": "output-1"
}
]
}
Requirements
- VS Code 1.96.0 or later
- Cursor (compatible)
- Node.js 18+ (for simulator functionality)
Development
Building from Source
# Clone the repository
git clone https://github.com/your-username/gorules-vscode-extension.git
cd gorules-vscode-extension
# Install dependencies
yarn install
# Build the extension
yarn compile
# Package the extension
yarn package
Project Structure
gorules-vscode/
├── src/
│ ├── extension.ts # Main extension logic
│ └── webview.js # Webview React application
├── dist/ # Compiled extension files
├── media/ # Static assets
├── package.json # Extension manifest
└── README.md # This file
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
This extension is licensed under the MIT License.
Support
- Issues: Report bugs and request features on GitHub
- Documentation: Visit the GoRules documentation
- Community: Join the GoRules community discussions
Changelog
0.0.1
- Initial release
- Visual JDM editor integration
- JSON mode toggle
- Integrated simulator
- Monaco editor support
- Theme compatibility
Made with ❤️ for the GoRules community