u/aryabyte

codemod CLI in OCaml 5, vendored tree-sitter, Domainslib + Incremental
▲ 18 r/ocaml

codemod CLI in OCaml 5, vendored tree-sitter, Domainslib + Incremental

Built a pattern-rewriting CLI for TS / TSX / Python / Go / Rust.

Write console.log($X) and it matches by AST. Add --where '$X: string' and it filters using real type info from the language's LSP.

OCaml side:

  • vendored tree-sitter v0.25.6 + 5 grammars in dune so Homebrew ships a single static binary
  • Domainslib for parallel scans (~0.4s on 7k TS files)
  • Jane Street Incremental for watch mode with sub-ms re-runs after single-file edits
  • LSP client is just yojson + Unix.create_process, no external library

Repo: https://github.com/aryabyte21/morph

opam pin works. Requires OCaml 5.3+.

Happy to dig into any of the parser / incremental / build-system choices.

u/aryabyte — 13 days ago