Install
Install with PiG
pig install npm:@davehardy20/pi-ast-grep-toolsInstall with Pi
pi install npm:@davehardy20/pi-ast-grep-toolsPackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./src/index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.1.0 (README.md). PiG does not review it.
@davehardy20/pi-ast-grep-tools
Structural code search and replace for Pi using AST matching via ast-grep.
What it adds
ast_grep_searchtool — Find code patterns using AST matching. More precise than text search. Supports TypeScript, JavaScript, and TSX.ast_grep_replacetool — Find and replace code patterns using AST matching. Safer than text replace because it respects syntax boundaries. Applies changes to files./ast-grep-statuscommand — Show package name, version, source path, and supported languages.
Pattern syntax
Pattern syntax is language-specific AST pattern syntax:
console.log($A)matches anyconsole.logcallfunction $NAME() { }matches empty function declarations$FUNC($$$ARGS)matches any function call
See the ast-grep pattern guide for full details.
Install
From npm:
pi install npm:@davehardy20/pi-ast-grep-tools
From git:
pi install git:github.com/davehardy20/pi-ast-grep-tools
From a local checkout during development:
pi install /Users/dave/tools/pi-ast-grep-tools
For one run only:
pi -e /Users/dave/tools/pi-ast-grep-tools
Settings
No special settings required. The extension auto-detects the target language from file extensions. You can override the language explicitly with the language parameter.
Supported languages: TypeScript, JavaScript, TSX.
Troubleshooting
Run /ast-grep-status to confirm:
- package name
- package version
- loaded source path
If commands appear twice, Pi may be loading both the package and the old local extension. Disable or remove the old local auto-discovered extension (ast-grep-tools.ts in ~/.pi/agent/extensions/) before reload verification.
Update flow
- Update the package repo
- Push to GitHub
- Run
pi update --extensionsor reinstall the package - Run
/reload
/reload alone does not fetch newer package commits.
Build and test
npm run typecheck
npm run build
npm test