srgn
$ srgn Community Low Risksrgn combines regex matching with Tree-sitter syntax scopes (such as --rust comments, --python strings, or --ts-imports) to search or transform only specific AST regions. Stdin mode is read-only, while --glob edits matched files in-place unless --dry-run is passed.
brew install srgn Tree-sitter scoped local search and diff preview (--dry-run) execute natively on files in milliseconds.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Non-interactive, supports --dry-run diff previews and -- separator safety, though it outputs plain text/diffs without --json.
- Supports
--dry-runwith--globand language scope flags - No
--jsonoutput mode
Stdin mode is read-only and --glob supports --dry-run previews, though forgetting --dry-run with --glob overwrites files in-place.
--dry-runprevents destructive writes when testing--globtransforms
Single Rust binary via brew install srgn, cargo install srgn, and GitHub Releases across macOS, Linux, and Windows.
- Zero runtime dependencies; static Rust binary
Unique Tree-sitter grammar scoping (comments, strings, docstrings, function bodies) avoids false-positive regex replacements.
- Scoping flags for Rust, Python, TypeScript, Go, C, etc.
Actively developed Rust tool (alexpovel/srgn) under the MIT license.
- Active GitHub repository under MIT
Well-structured README and --help documenting every language scope and action flag.
- Comprehensive scope/action reference in README
Security, Auth & Guardrails
None required; operates purely on local stdin or workspace files.
100% free, offline, and open-source (MIT).
# srgn Agent Rules - ALWAYS pass `--dry-run` when using `--glob` (`-G`), because `--glob` writes replacements in-place by default. - Separate replacement strings with `--` (e.g., `srgn ... 'pattern' -- 'replacement'`) to prevent flag ambiguity.
Agent-Ready Command Recipes
Safe Read-Only Queries
srgn --glob 'src/**/*.rs' --dry-run --rust 'comments' 'TODO'
Matches TODO strictly inside Rust comment nodes and prints a diff/match preview without modifying files.
srgn --glob '**/*.py' --dry-run --python 'strings' 'http://' -- 'https://'
Previews replacing http:// inside Python string literals only (--dry-run keeps files untouched).
Controlled Writes & Previews
srgn --glob 'src/**/*.rs' --rust 'comments' 'old_term' -- 'new_term'
Replaces old_term only within Rust comment AST nodes across matched files in-place.
Strengths for Agents
- + Language-aware Tree-sitter scoping (
--rust 'comments',--python 'strings') prevents unintended edits in unrelated syntax. - +
--dry-runrenders clear change previews before committing--globedits.
Caveats & Pitfalls
- ! Using
--globwith an action or replacement overwrites files in-place unless--dry-runis passed. - ! No
--jsonoutput format.