Skip to main content
The version command manages the version of your grammar across all binding files and manifests.
Aliases: publish

Usage Modes

Display Current Version

Run without arguments to display the current version:
Output:

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.json
  • Cargo.toml
  • Cargo.lock
  • package.json
  • package-lock.json
  • Makefile
  • CMakeLists.txt
  • pyproject.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)
Conflicts with explicit version argument.

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)

Updating Cargo.toml and Cargo.lock requires cargo:

NPM (Node.js)

Updating package-lock.json requires npm:

Best Practices

Keep Versions in Sync

Always use tree-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 a CHANGELOG.md documenting changes:

Troubleshooting

Version Update Failed

If version update fails:
  1. Check file permissions
  2. Verify files are valid JSON/TOML
  3. Ensure external tools are installed
  4. Check for syntax errors in manifest files

Inconsistent Versions

If versions are out of sync:
  1. Run tree-sitter version to check current version
  2. Manually inspect affected files
  3. Use tree-sitter version <VERSION> to force update

Git Conflicts

If version changes cause conflicts:
  1. Accept the newer version
  2. Run tree-sitter version <VERSION> to re-sync
  3. Commit the resolved state