Thank you for your interest in contributing to StxScript. This document provides guidelines and information for contributors.
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
- Python 3.10+
- uv (recommended) or pip
- Git
git clone https://github.com/cryptuon/stxscript.git
cd stxscript
uv venv && uv pip install -e ".[dev]"# All tests (146 tests)
uv run python -m pytest tests/
# With coverage
uv run python -m pytest tests/ --cov=stxscript
# Specific test file
uv run python -m pytest tests/test_transpiler.py -vuv run black stxscript/ # Format
uv run flake8 stxscript/ # Lint
uv run mypy stxscript/ # Type checkOpen an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- StxScript version (
stxscript --version) - Python version and OS
Open an issue with:
- Description of the feature
- Use case and motivation
- Example of how it would work (StxScript input and expected Clarity output)
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Add or update tests
- Ensure all tests pass:
uv run python -m pytest tests/ - Ensure code is formatted:
uv run black stxscript/ - Commit with a clear message
- Push and open a pull request
Use conventional commit format:
<type>: <description>
[optional body]
Types:
feat- New featurefix- Bug fixdocs- Documentation changestest- Adding or updating testsrefactor- Code refactoringstyle- Code style/formattingchore- Maintenance tasks
Examples:
feat: add buffer size validation to type checker
fix: correct kebab-case conversion for multi-word identifiers
docs: update CLI reference with new pkg commands
test: add property-based tests for expression parsing
stxscript/
├── stxscript/ # Main package
│ ├── transpiler.py # Transpilation orchestrator
│ ├── working_grammar.lark # Production grammar (Lark LALR)
│ ├── ast_nodes.py # AST node definitions
│ ├── ast_builder.py # Parse tree → AST transformer
│ ├── semantic_analyzer.py # Type checking and validation
│ ├── clarity_generator.py # AST → Clarity code generation
│ ├── error_handler.py # Error reporting with suggestions
│ ├── cli.py # CLI with subcommands
│ ├── formatter.py # Code formatter
│ ├── linter.py # Static analysis
│ ├── lsp_server.py # Language Server Protocol
│ ├── testing.py # Contract testing framework
│ └── package_manager.py # Dependency management
├── tests/ # Test suite
├── documentation/ # User-facing docs (mkdocs)
└── vscode-extension/ # VS Code extension
- Grammar: Add rules to
stxscript/working_grammar.lark - AST Nodes: Define nodes in
stxscript/ast_nodes.py - AST Builder: Add transformer methods in
stxscript/ast_builder.py - Semantic Analysis: Add checks in
stxscript/semantic_analyzer.py - Code Generation: Add generation in
stxscript/clarity_generator.py - Tests: Add test cases in
tests/
- Test both successful transpilation and error cases
- Include the expected Clarity output in assertions
- Use descriptive test method names:
test_for_loop_range_extraction - Add property-based tests for parser robustness when appropriate
import unittest
from stxscript import StxScriptTranspiler
class TestNewFeature(unittest.TestCase):
def setUp(self):
self.transpiler = StxScriptTranspiler()
def test_feature_produces_correct_clarity(self):
stx_code = 'let x: uint = 42u;'
result = self.transpiler.transpile(stx_code)
self.assertIn('(define-data-var x uint u42)', result)- Follow PEP 8
- Use type hints for function signatures
- Use Black for formatting (line length 100)
- Keep functions focused and testable
Before submitting:
- Tests pass:
uv run python -m pytest tests/ - Code formatted:
uv run black stxscript/ - Linting passes:
uv run flake8 stxscript/ - New tests added for new functionality
- Documentation updated if applicable
- Commit messages follow conventional format
By contributing to StxScript, you agree that your contributions will be licensed under the MIT License.