neurocode_graft
Replace a specific function, class, or method by deterministic AST subtree grafting, avoiding fragile whitespace diff errors; optionally run tests and auto-rollback on failure.
Instructions
Perform deterministic AST subtree grafting on Python, TypeScript, JavaScript, Go, or Rust code. Directly mutates/replaces a specific function, class, or method AST node without fragile whitespace diff errors. Supports test_command with automated rollback on test failures.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_path": "<file_path>",
"symbol": "<symbol>",
"replacement_code": "<replacement_code>"
},
"name": "neurocode_graft"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apply | No | Whether to write modifications to disk (default false for preview) | |
| symbol | Yes | Function, method (e.g. 'ClassName.methodName'), or class to replace | |
| file_path | Yes | Relative path to file being modified | |
| repo_path | No | Path to repository root (default '.') | . |
| test_command | No | Optional test command to run after grafting (e.g. 'pytest tests/test_calc.py') | |
| auto_rollback | No | Whether to revert file if test_command fails (default true) | |
| replacement_code | Yes | New code block to graft into the AST |