npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

codework-astgrep

v0.2.1

Published

CodeWork AST search and rewrite plugin powered by ast-grep

Readme

codework-astgrep

AST search and rewrite plugin for CodeWork, powered by ast-grep.

It registers the ast_search tool (plugin ID astgrep.tool.search), letting agents search code by syntax tree instead of text. Patterns capture structure ($NAME, $$$ARGS), and rewrite previews a substitution. Nothing is written back to disk.

Installation

codework plugin add codework-astgrep          # this project (.codework/settings.jsonc)
codework plugin add codework-astgrep -g       # every project (your user settings)

plugin add records the entry and installs it. On a fresh checkout that already declares it, run codework plugin install.

The language parsers ship as native libraries and unpack in a postinstall script. pnpm does not run those scripts unless the project allows them. Add this to pnpm-workspace.yaml before installing:

allowBuilds:
  "@ast-grep/lang-angular": true
  "@ast-grep/lang-bash": true
  "@ast-grep/lang-bicep": true
  "@ast-grep/lang-c": true
  "@ast-grep/lang-cpp": true
  "@ast-grep/lang-csharp": true
  "@ast-grep/lang-css": true
  "@ast-grep/lang-dart": true
  "@ast-grep/lang-elixir": true
  "@ast-grep/lang-glimmer-javascript": true
  "@ast-grep/lang-glimmer-typescript": true
  "@ast-grep/lang-go": true
  "@ast-grep/lang-haskell": true
  "@ast-grep/lang-html": true
  "@ast-grep/lang-java": true
  "@ast-grep/lang-javascript": true
  "@ast-grep/lang-json": true
  "@ast-grep/lang-kotlin": true
  "@ast-grep/lang-lua": true
  "@ast-grep/lang-markdown": true
  "@ast-grep/lang-php": true
  "@ast-grep/lang-python": true
  "@ast-grep/lang-ruby": true
  "@ast-grep/lang-rust": true
  "@ast-grep/lang-scala": true
  "@ast-grep/lang-sql": true
  "@ast-grep/lang-swift": true
  "@ast-grep/lang-toml": true
  "@ast-grep/lang-tsx": true
  "@ast-grep/lang-typescript": true
  "@ast-grep/lang-yaml": true

Configuration

Configure it with a second entry that names the plugin, next to the one that loads it:

// .codework/settings.jsonc or ~/.codework/settings.jsonc
{
  "plugins": [
    "codework-astgrep",
    {
      "plugin": "astgrep.tool.search",
      "options": { "limit": 40 }
    }
  ]
}

The configuration entry only sets options; it never loads anything. It can also address the plugin by the string that loaded it ("package": "codework-astgrep"), or turn it off in one project that inherits it from user settings ("enabled": false).

Configuration Options

| Option | Type | Default | Description | | --- | --- | --- | --- | | limit | number | 50 | Default maximum number of matches a search returns. A per-call limit overrides this. |

Tool: ast_search

Searches the session sandbox with an ast-grep pattern.

Parameters

  • pattern (string, required): AST pattern. $NAME captures one node, $$$NAME captures zero or more nodes, $_ matches any single node.
  • path (string, optional): File or directory to search. Defaults to the workspace root (.).
  • lang (string, optional): Parser to use. Omit it to detect a language from the file extension.
  • rewrite (string, optional): Replacement preview. Captured metavariables are substituted. Files are not modified.
  • limit (number, optional): Maximum matches to return. Defaults to the configured limit, or 50.

Example

Find every console.log call and preview a rename:

{
  "pattern": "console.log($MSG)",
  "lang": "typescript",
  "rewrite": "logger.info($MSG)"
}

console.log("hello") is reported as logger.info("hello"). The source file stays unchanged.

A multi-node capture keeps the text between nodes, including commas and spaces:

{
  "pattern": "logger($$$ARGS)",
  "rewrite": "info($$$ARGS)"
}

Languages

angular, bash, bicep, c, cpp, csharp, css, dart, elixir, glimmer-javascript, glimmer-typescript, go, haskell, html, java, javascript, json, kotlin, lua, markdown, php, python, ruby, rust, scala, sql, swift, toml, tsx, typescript, yaml.

When lang is omitted, the file extension picks the parser. Two extensions are shared:

  • .html is html. Pass lang: "angular" to parse those files as Angular templates.
  • .h is c. Pass lang: "cpp" to parse those files as C++.

Project Structure

  • src/index.ts: Plugin entry point. Registers ast_search and reads the limit option.
  • src/languages.ts: Loads every @ast-grep/lang-* parser and maps file extensions to languages.
  • src/search.ts: Walks the sandbox filesystem, runs the pattern, and builds rewrite previews.

Development

pnpm install
pnpm run build
pnpm run typecheck

pnpm run watch rebuilds while you edit.