Contributing
Thanks for your interest in contributing to Vague!
Getting Started
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/vague.git - Install dependencies:
npm install - Build:
npm run build - Run tests:
npm test
Development Workflow
Making Changes
- Create a branch:
git checkout -b feature/your-feature - Make your changes
- Add tests for new functionality
- Run tests:
npm test - Build:
npm run build - Commit with a clear message
Code Style
- TypeScript with strict mode
- Prefer concise, well-named functions over comments
- Tests alongside implementation (colocated
*.test.tsfiles) - No unnecessary abstractions — keep it simple
Testing
Tests use Vitest and are colocated with source files:
npm test # Run all tests
npm test -- --watch # Watch mode
When adding features:
- Add parser tests for new syntax
- Add generator tests for runtime behavior
- Test edge cases and constraints
Project Structure
src/
├── lexer/ # Tokenizer
├── parser/ # Recursive descent parser
├── ast/ # AST node definitions
├── interpreter/ # Generator
├── validator/ # Schema validation
├── openapi/ # OpenAPI support
├── infer/ # Schema inference
├── csv/ # CSV formatting
├── plugins/ # Built-in plugins
├── index.ts # Library exports
└── cli.ts # CLI entry point
Architecture
Pipeline
.vague source → Lexer → Tokens → Parser → AST → Generator → JSON
Key Concepts
- Lexer — Converts source text to tokens with line/column tracking
- Parser — Recursive descent parser producing AST nodes
- Generator — Walks AST, generates JSON with:
- Rejection sampling for constraints (100 max retries)
- Field generation order: simple → collections → computed
- Context tracking for parent refs and cross-record refs
Adding New Syntax
- Add token type in
src/lexer/tokens.ts - Add keyword to
KEYWORDSmap if needed - Add AST node type in
src/ast/nodes.ts - Add parsing logic in
src/parser/parser.ts - Add generation logic in
src/interpreter/generator.ts - Add tests for both parser and generator
What to Work On
Check TODO.md for planned features.
Good First Contributions
- Bug fixes — If something doesn't work as expected
- Documentation — Improve examples, clarify syntax
- Tests — Increase coverage, add edge cases
- Small features — Items marked as "quick win"
For larger features, open an issue first to discuss the approach.
Pull Request Process
- Ensure tests pass (
npm test) - Ensure build succeeds (
npm run build) - Update documentation if needed
- Write a clear PR description explaining:
- What the change does
- Why it's needed
- How to test it
Code Formatting
# Format code
npm run format
# Check formatting
npm run format:check
# Lint
npm run lint
# Fix lint issues
npm run lint:fix
Questions?
Open an issue for questions or discussion.