elevo-cli
v0.1.0
Published
Command-line interface for Elevo state machine visualization and development tools.
Readme
Elevo CLI
Command-line interface for Elevo state machine visualization and development tools.
Installation
npm install -g elevo-cliUsage
Start State Machine Visualizer
# Watch current directory for *.state.ts files
elevo graph
# Watch specific directory
elevo graph ./src/states
# Specify custom port
elevo graph --port 8081
# Disable file watching (one-time scan)
elevo graph --no-watch
# Disable server (cache only)
elevo graph --no-serverFeatures
- File Watching: Automatically detects changes in
*.state.tsfiles - Caching: Stores state machine JSON in
node_modules/elevo/.cache/ - Real-time Updates: Streams updates to visualizer via WebSocket
- History: Keeps cache history for debugging and rollback
- Token Security: Uses secure tokens for WebSocket communication
Cache Management
The CLI automatically manages cache files:
node_modules/elevo/.cache/latest.json- Current statenode_modules/elevo/.cache/[timestamp].json- Historical snapshots- Automatically cleans old cache files (keeps last 10)
Integration
The CLI works seamlessly with:
- Elevo Visualizer: Real-time web-based visualization
- Development Tools: IDE integration and debugging
- CI/CD: State machine validation and documentation
State File Format
Create *.state.ts files using the Elevo DSL:
import { createMachine } from 'elevo';
export const myMachine = createMachine("myMachine", (ctx) => {
const { state, on } = ctx;
return [
state("idle", () => [on("START", "running")]),
state("running", () => [on("STOP", "idle")])
];
});WebSocket API
The CLI exposes a WebSocket server for real-time communication:
- Port: 8080 (default)
- Protocol: WebSocket with JSON messages
- Authentication: Token-based security
Message Format
interface VisualizerMessage {
type: 'state_update' | 'initial_data' | 'error';
data: StateFileInfo[] | string;
token: string;
timestamp: number;
}Troubleshooting
No State Machines Found
- Ensure files end with
.state.ts - Check file contains exported state machine
- Verify TypeScript syntax is valid
Connection Issues
- Check port availability (default: 8080)
- Verify firewall settings
- Check WebSocket connection in browser console
Cache Issues
- Clear cache:
rm -rf node_modules/elevo/.cache - Restart CLI with fresh scan
- Check file permissions in project directory
