Skip to content

Tree-sitter migration — tracked spike #69

Description

@razakadam74

Follow-up to #66. Spike ran; this issue parks the migration so it stays live without committing engineering until evidence shows up.

Status

Parked. Feasibility proved, necessity not. Numbers and gotchas: #66 spike report.

Triggers to activate

Any one flips this from "tracked" to "do it":

Constraints to preserve

  • zero runtime deps in the published package
  • <100 ms cold start
  • single-binary build via bun build --compile still works

Open questions

  • Native vs WASMweb-tree-sitter clears the constraints (cold 23.8 ms, ~2.3 MB per grammar). Native bindings break single-binary. WASM is the front-runner.
  • Hunk vs full file — today gitmsg sees diff hunks; tree-sitter wants full files. Either git show both sides → parse → diff symbol tables (simpler, two extra git calls per file), or invent a hunk-friendly approach.
  • Per-language order — TS first (already proven, biggest base), then Python, Go, C#. Keep regex as fallback for ungrammared languages.
  • Build pipeline — vendor pre-built .wasm, or rebuild grammars in CI against a pinned tree-sitter-cli? Spike showed vendored third-party .wasm is fragile when external C scanners are involved.

What's validated

  • tree-sitter-typescript via tree-sitter-wasms@0.1.13 parses real source cleanly
  • 5-line query pulls only exported symbols — exported is a built-in tree property (no per-language visibility heuristic, unlike current regex extractors)
  • cold path 23.8 ms · warm parse 0.42 ms · full src/ stress 3.15 ms/file

What's not validated

  • the git show + symbol-table-diff approach end-to-end
  • rebuilding grammars from source against a pinned runtime
  • bundle size impact on bun build --compile

Non-goals

  • not blocking 1.0
  • not removing regex extractors when this lands — they stay as fallback
  • not migrating all languages in one PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions