version command manages the version of your grammar across all binding files and manifests.
publish
Usage Modes
Display Current Version
Run without arguments to display the current version:Set Specific Version
Provide a version number to set:Auto-Bump Version
Use--bump to automatically increment:
Updated Files
The command updates the version in these files (if they exist):tree-sitter.jsonCargo.tomlCargo.lockpackage.jsonpackage-lock.jsonMakefileCMakeLists.txtpyproject.toml
Options
semver
The version to set. Must follow semantic versioning format (e.g.,
1.2.3).Conflicts with --bump.path
The path to the directory containing the grammar.
level
Automatically bump the version from the current version in
tree-sitter.json.Values:patch- Increment patch version (x.y.Z)minor- Increment minor version (x.Y.0)major- Increment major version (X.0.0)
Examples
Display Version
Set Version
Patch Bump
Minor Bump
Major Bump
With Custom Grammar Path
Workflow
Recommended version management workflow:1. Make Changes
Develop and test your grammar:2. Bump Version
Update the version appropriately:3. Commit Changes
Commit the version changes:4. Tag Release
Create a git tag:5. Publish
Publish to package registries:Semantic Versioning
Follow semver guidelines:-
MAJOR (X.0.0) - Breaking changes
- Changed syntax tree structure
- Removed or renamed nodes
- Changed public API
-
MINOR (0.X.0) - New features (backwards compatible)
- New language constructs
- New queries
- Performance improvements
-
PATCH (0.0.X) - Bug fixes (backwards compatible)
- Fixed parsing bugs
- Fixed incorrect syntax trees
- Documentation updates
External Tool Requirements
Some binding updates require external tools:Cargo (Rust)
UpdatingCargo.toml and Cargo.lock requires cargo:
NPM (Node.js)
Updatingpackage-lock.json requires npm:
Best Practices
Keep Versions in Sync
Always usetree-sitter version instead of manually editing version numbers. This ensures consistency across all bindings.
Version Control
Commit version changes separately:Tag Releases
Always tag releases in git:Changelog
Maintain aCHANGELOG.md documenting changes:
Troubleshooting
Version Update Failed
If version update fails:- Check file permissions
- Verify files are valid JSON/TOML
- Ensure external tools are installed
- Check for syntax errors in manifest files
Inconsistent Versions
If versions are out of sync:- Run
tree-sitter versionto check current version - Manually inspect affected files
- Use
tree-sitter version <VERSION>to force update
Git Conflicts
If version changes cause conflicts:- Accept the newer version
- Run
tree-sitter version <VERSION>to re-sync - Commit the resolved state