Expand description
Srgn (code surgeon) tool integration for VTCode
This tool provides access to srgn, a grep-like tool that understands source code syntax and allows for manipulation in addition to search. It supports various programming languages and provides precise code modification capabilities.
§Supported Languages and Prepared Queries
§Rust
comments
- Comments (line and block styles; excluding doc comments)doc-comments
- Doc comments (comment chars included)uses
- Use statements (paths only; excl.use
/as
/*
)strings
- Strings (regular, raw, byte; includes interpolation parts)attribute
- Attributes like#[attr]
struct
-struct
definitionsstruct~<PATTERN>
- Structs whose name matches PATTERNenum
-enum
definitionsenum~<PATTERN>
- Enums whose name matches PATTERNfn
- Function definitionsfn~<PATTERN>
- Functions whose name matches PATTERNunsafe
-unsafe
keyword usages
§Python
comments
- Commentsstrings
- Strings (raw, byte, f-strings; interpolation not included)imports
- Module names in importsdoc-strings
- Docstringsfunction-names
- Function names at definition sitefunction-calls
- Function callsclass
- Class definitionsdef
- All function definitionsmethods
- Function definitions inside classes
§JavaScript/TypeScript
comments
- Commentsstrings
- Strings (literal, template)imports
- Imports (module specifiers)function
- Function definitionsclass
- Class definitionsinterface
- Interface definitions
§Go
comments
- Commentsstrings
- Strings (interpreted and raw)imports
- Importsstruct
- Struct type definitionsstruct~<PATTERN>
- Structs whose name matches PATTERNfunc
- Function definitionsfunc~<PATTERN>
- Functions whose name matches PATTERN
§C/C++/C#
comments
- Commentsstrings
- Stringsfunction
- Function definitionsstruct
- Struct definitionsclass
- Class definitions
§HCL (Terraform)
comments
- Commentsstrings
- Literal stringsvariable
- Variable blocksresource
- Resource blocksdata
- Data blocks
§Usage Examples
// Replace println with eprintln in Rust functions
SrgnInput {
path: "*.rs".to_string(),
language_scope: Some("rust fn".to_string()),
scope: Some("println".to_string()),
replacement: Some("eprintln".to_string()),
action: SrgnAction::Replace,
dry_run: true,
..Default::default()
}
// Find all unsafe Rust code
SrgnInput {
path: "*.rs".to_string(),
language_scope: Some("rust unsafe".to_string()),
fail_any: true,
..Default::default()
}
Structs§
- German
Options - German-specific options for srgn
- Srgn
Input - Input structure for srgn operations
- Srgn
Tool - Srgn tool implementation
Enums§
- Srgn
Action - Available srgn actions