userland.run70Try the demo
Catalog app · RISC-V VM

Run ast-grep in the browser

Search, lint and rewrite code by syntax-tree pattern instead of regex.

Try it live

Nothing is downloaded until you press Run.

catalog app

Find console.log calls by syntax-tree pattern

Installs ast-grep 0.44.0 from the signed catalog (every chunk is verified before it is written), then runs the commands below in the VM's shell.

bash
ast-grep --version
ast-grep run --pattern 'console.log($A)' --lang js --stdin < app.js
loading…
Expected output
$ ast-grep --version
ast-grep 0.44.0
$ ast-grep run --pattern 'console.log($A)' --lang js --stdin < app.js
STDIN:2:console.log(a);
STDIN:5:console.log( a+1 );

What it is

ast-grep matches code against patterns written in the target language itself (console.log($MSG)), parsed with tree-sitter, so it finds structure rather than text: formatting, comments and string contents never cause false hits. The same pattern can drive a rewrite. Running it in the browser lets a playground, a code-review tool or a course page run real structural queries over files a visitor pastes in, without shipping their code to a server.

Package facts

version
0.44.0
runs on
RISC-V VM (elf-app, riscv64gc-linux-musl)
download
7.9 MB compressed · 1 file
command
ast-grep
requires
nothing else — a static binary
license
MIT (upstream)
upstream
github.com/ast-grep/ast-grep
categories
Search, Text
catalog
generation 12, Ed25519-signed

Install and run it from your page

With the SDK, installApp resolves ast-grep in the signed index, fetches its content-addressed chunks from the CDN, verifies each one and writes the files into the VM. Details in Installing catalog apps.

javascript
import { createNano } from "@userland-run/nano-sdk";

const nano = await createNano({ image: { wasm: "/nano/console.wasm" }, ramMB: 512 });
await nano.installApp("ast-grep"); // signature-verified, cached in OPFS

const r = await nano.shExec("ast-grep --version");
console.log(r.stdout);

Typical usage of the upstream command-line tool:

bash
ast-grep run --pattern 'console.log($$$ARGS)' --rewrite 'logger.info($$$ARGS)' src/

Caveats

← All 32 catalog apps