WASM Build
Skill Lab uses @ast-grep/wasm for cross-platform code analysis. Because this package is not yet published to npm, it is built from source and placed in vendor/ast-grep-wasm/ at the repo root.
The vendor/ directory is gitignored and must be regenerated by running:
deno task setupThis must be done before running check, test, or build.
Prerequisites
- Rust (stable toolchain) — rustup.rs
- wasm-pack — rustwasm.github.io/wasm-pack
- Deno v2.x — deno.land
Install wasm-pack:
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | shMake sure the wasm32-unknown-unknown Rust target is installed:
rustup target add wasm32-unknown-unknownWhat deno task setup does
The setup script is scripts/setup_wasm.ts. It:
- Clones the ast-grep repository (no-checkout, shallow) into
/tmp/ast-grep-wasm-build - Checks out the pinned commit
3392cb5b0b53887db618866d95a41893c1575cb6from PR #2484 - Runs
wasm-pack build --target nodejs --out-dir pkgincrates/wasm/ - Copies
ast_grep_wasm_bg.wasmandast_grep_wasm.jstovendor/ast-grep-wasm/ - Writes a minimal
package.jsontovendor/ast-grep-wasm/for Deno module resolution
The build typically takes 2–5 minutes on first run (Rust compilation). Subsequent runs are fast if the Cargo cache (~/.cargo/registry) is warm.
Version pinning
The pinned commit (3392cb5b) corresponds to a specific point on the wasm branch. When updating to a newer commit:
- Update
PINNED_COMMITinscripts/setup_wasm.ts - Verify
web-tree-sitterABI compatibility (see below) - Re-run
deno task setup
web-tree-sitter version pinning
web-tree-sitter is pinned to exact version 0.25.4 in packages/analyzer/deno.json. This is intentional — grammar .wasm files are compiled by the tree-sitter CLI against a specific WASM ABI. Mixing a grammar file compiled for one ABI version with a different web-tree-sitter runtime version causes silent parse failures (no error is thrown; the parsed tree is silently wrong).
Grammar .wasm files used by Skill Lab (from packages/analyzer/treesitter/registry.ts):
| Language | Version | Source |
|---|---|---|
| bash | 0.25.1 | tree-sitter/tree-sitter-bash |
| javascript | 0.25.0 | tree-sitter/tree-sitter-javascript |
| python | 0.25.0 | tree-sitter/tree-sitter-python |
| typescript / tsx | 0.23.2 | tree-sitter/tree-sitter-typescript |
| markdown | 0.5.2 | tree-sitter-grammars/tree-sitter-markdown |
| markdown-inline | 0.5.2 | tree-sitter-grammars/tree-sitter-markdown |
If you update web-tree-sitter, you must also update all grammar URLs and verify ABI compatibility with the new runtime version.
Grammar file size
Each grammar .wasm file is approximately 1.3–1.4 MB — comparable in size to a single platform-specific .so file. The previous approach bundled four platform .so files per language into each release archive (~5 MB per language). With WASM, a single file serves all platforms, and grammars are downloaded on first use rather than bundled into the release archive.
Grammar files are cached locally in the XDG cache directory.
CI
The GitHub Actions workflow (.github/workflows/cli.yml) runs deno task setup before every build and test job. Rust build artifacts are cached using actions/cache keyed on Cargo.lock.