ADR-017: Tree-sitter Version Strategy - Downgrade to 0.21.x for Maximum Language Compatibility
Statusโ
Accepted
Dateโ
2025-12-13
Contextโ
The MCP ADR Analysis Server uses tree-sitter for syntax-aware code parsing across multiple programming languages. We discovered a critical version incompatibility issue:
Problem Discoveryโ
When running validate_all_adrs, the TypeScript parser was failing with:
Failed to load typescript parser: TypeError: Invalid language object
at Parser.setLanguage (node_modules/tree-sitter/index.js:351:17)
Root Cause Analysisโ
The tree-sitter ecosystem is currently split between two major version lines:
| Version Line | Core Library | Ecosystem State |
|---|---|---|
| 0.21.x | Stable, widely adopted | Most language parsers available |
| 0.25.x | Latest, breaking changes | Limited parser availability |
Our configuration had:
tree-sitter@0.25.0(core library)tree-sitter-typescript@0.23.2(requires^0.21.0)- Other parsers at 0.25.x
This version mismatch caused the TypeScript parser to fail because the native bindings are incompatible between 0.21.x and 0.25.x.
Version Compatibility Matrix (Researched 2025-12-13)โ
| Language | 0.21.x Version | 0.25.x Version | Notes |
|---|---|---|---|
| TypeScript | 0.21.2 | 0.23.2 (incompatible) | Broken on 0.25.x |
| JavaScript | 0.21.4 | 0.25.0 | Works on both |
| Python | 0.21.0 | 0.25.0 | Works on both |
| Java | 0.21.0 | - | Works on 0.21.x only |
| Go | 0.21.2 | 0.25.0 | Works on both |
| Rust | 0.21.0 | 0.24.0 | Works on both |
| C | 0.21.4 | 0.24.1 | Works on both |
| C++ | 0.21.0 | 0.23.4 | Works on both |
| Ruby | 0.21.0 | 0.23.1 | Works on both |
| Bash | 0.21.0 | 0.25.0 | Works on both |
| JSON | 0.21.0 | 0.24.8 | Works on both |
| YAML | 0.5.0 | 0.5.0 | Incompatible with 0.21.x - uses fallback |
| CSS | 0.21.1 | 0.23.2 | Works on both |
| HTML | 0.20.4 | 0.23.4 | Needs 0.20.x |
| HCL | - | 1.2.0 (requires 0.25.x) | Only on 0.25.x |
| PHP | - | 0.24.2 | No 0.21.x version |
Decisionโ
Downgrade to tree-sitter 0.21.x ecosystem to maximize language support and fix the TypeScript parser issue.
Packages to Install (0.21.x compatible)โ
{
"tree-sitter": "^0.21.1",
"tree-sitter-typescript": "^0.21.2",
"tree-sitter-javascript": "^0.21.4",
"tree-sitter-python": "^0.21.0",
"tree-sitter-java": "^0.21.0",
"tree-sitter-go": "^0.21.2",
"tree-sitter-rust": "^0.21.0",
"tree-sitter-c": "^0.21.4",
"tree-sitter-cpp": "^0.21.0",
"tree-sitter-ruby": "^0.21.0",
"tree-sitter-bash": "^0.21.0",
"tree-sitter-json": "^0.21.0",
"tree-sitter-css": "^0.21.1",
"tree-sitter-yaml": "^0.5.0"
}
Packages to Removeโ
@tree-sitter-grammars/tree-sitter-hcl- Requires 0.25.x, incompatibletree-sitter-dockerfile- Security placeholder package, not functional
Languages Gained vs Lostโ
Gained (13 languages with native tree-sitter parsing):
- TypeScript/TSX (was broken)
- JavaScript
- Python
- Java (new)
- Go (new)
- Rust (new)
- C (new)
- C++ (new)
- Ruby (new)
- Bash
- JSON
- CSS (new)
Using fallback regex analysis:
- YAML - tree-sitter-yaml 0.5.0 is incompatible with tree-sitter 0.21.x (uses fallback)
Lost (2 languages):
- HCL (Terraform) - No 0.21.x compatible version exists
- PHP - No 0.21.x version available
Consequencesโ
Positiveโ
- TypeScript Support Restored: Critical for analyzing TypeScript/React projects
- Expanded Language Coverage: From 7 languages to 14 languages
- Stable Ecosystem: 0.21.x is mature and well-tested
- Consistent Versioning: All parsers on same major version reduces conflicts
- Java/Quarkus Support: Important for enterprise Java projects
- Go Support: Important for cloud-native projects
- Rust Support: Growing ecosystem coverage
Negativeโ
- No HCL/Terraform Support: Cannot parse
.tffiles until ecosystem catches up - No PHP Support: Limited web framework coverage
- Older Version: May miss newer parser improvements in 0.25.x
- Future Migration: Will need to migrate when 0.25.x ecosystem matures
Neutralโ
- Native Compilation: Still requires node-gyp for native modules
- Platform Support: Same cross-platform requirements
Alternatives Consideredโ
Alternative 1: Use @sengac Fork Ecosystemโ
A community fork (@sengac/tree-sitter-typescript@0.25.15) exists that's compatible with 0.25.x.
Rejected because:
- Requires entire forked ecosystem (
@sengac/tree-sitter) - Not official packages, less maintained
- Vendor lock-in to fork
Alternative 2: Keep 0.25.x with TypeScript Disabledโ
Accept that TypeScript parsing doesn't work and rely on fallback methods.
Rejected because:
- TypeScript is critical for this project (written in TypeScript)
- Many target projects use TypeScript/React
- Degrades analysis quality significantly
Alternative 3: Wait for Official 0.25.x TypeScript Parserโ
Wait for the official tree-sitter-typescript to release a 0.25.x compatible version.
Rejected because:
- No timeline for release
- Current version (0.23.2) released Nov 2024, still requires 0.21.x
- Blocks current functionality
Implementation Notesโ
Code Changes Requiredโ
- Update
package.jsondependencies - Remove
overridessection that forces 0.25.0 - Update
src/utils/tree-sitter-analyzer.ts:- Add new language mappings (Java, Go, Rust, C, C++, Ruby, CSS)
- Remove HCL support
- Update TypeScript loading (may need adjustment for 0.21.x module format)
- Run
npm installto rebuild native modules - Test all language parsers
Monitoringโ
When tree-sitter-typescript releases a 0.25.x compatible version:
- Create new ADR to evaluate migration
- Test compatibility with current setup
- Consider re-adding HCL support
Referencesโ
- tree-sitter GitHub
- tree-sitter-typescript GitHub
- npm tree-sitter
- ADR-016: Replace ripgrep with tree-sitter
Related ADRsโ
- ADR-016: Replace ripgrep with tree-sitter (predecessor decision)