Skip to content

chore: bump tree-sitter 0.21→0.25 and all grammar packages#8

Draft
vnz wants to merge 1 commit intoCSCSoftware:masterfrom
vnz:feat/tree-sitter-0.25
Draft

chore: bump tree-sitter 0.21→0.25 and all grammar packages#8
vnz wants to merge 1 commit intoCSCSoftware:masterfrom
vnz:feat/tree-sitter-0.25

Conversation

@vnz
Copy link
Copy Markdown

@vnz vnz commented Apr 16, 2026

Summary

  • Bumps tree-sitter from ^0.21.0 to ^0.25.0 and all 10 grammar packages to their latest compatible versions
  • Refactors parser setup: replaces per-language switch blocks with a centralized GRAMMAR_MAP record
  • Prerequisite for adding HCL/Terraform support (see Feature: Add Terraform/HCL language support #7)

Motivation

The only published HCL grammar (@tree-sitter-grammars/tree-sitter-hcl@1.2.0) requires tree-sitter ^0.25.0. Several other grammar packages have also moved ahead of the pinned 0.21.x versions. This PR aligns the dependency stack with the current ecosystem.

Changes

File Change
package.json Bump tree-sitter + all 10 grammar versions
src/parser/tree-sitter.ts Replace switch blocks with GRAMMAR_MAP, add asLang() type bridge
.npmrc Add legacy-peer-deps=true (5 grammars declare peer deps below ^0.25)
.node-version Pin Node 22 (tree-sitter 0.25 requires compilation, not yet compatible with Node 24)
CHANGELOG.md Document upgrade under [Unreleased]

Notable decisions

  • tree-sitter-c-sharp pinned to ^0.23.1: v0.23.5 switched to ESM-only with top-level await, breaking CJS import compatibility
  • asLang() helper: Grammar packages export types incompatible with tree-sitter 0.25's stricter Parser.Language interface. All grammars work at runtime via NAPI — this is a type declaration mismatch only
  • GRAMMAR_MAP refactor: Centralizes all grammar-to-language mappings, eliminates a 30-line switch. Adding a new language is now a one-line change

Validation

  • npm install && npm run build — clean compile on Node 22
  • node build/index.js init . — successfully indexed the AiDex project (66 files, 7174 items, 399 methods, 132 types)
  • Codex automated review: verified no node-type regressions across all 11 languages by cross-referencing old and new grammar node-types.json files

Test plan

  • Build passes on Node 22
  • Index a TypeScript project
  • Index a project with multiple languages (if available)
  • Verify tsx/jsx parsing works

🤖 Generated with Claude Code

Enables support for newer grammar packages (like tree-sitter-hcl) that
require tree-sitter ^0.25.0. Refactors parser setup to use a centralized
GRAMMAR_MAP record instead of per-language switch blocks.

- tree-sitter: ^0.21.0 → ^0.25.0
- All 10 grammar packages bumped to latest compatible versions
- tree-sitter-c-sharp pinned to ~0.23.1 (0.23.5 is ESM-only, incompatible)
- Added asLang() helper for grammar type bridging (NAPI-safe)
- Added .npmrc with legacy-peer-deps for peer dep resolution
- Added .node-version pinning Node 22 (tree-sitter 0.25 requires compilation,
  not yet compatible with Node 24)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant