rea_patch_text_apply
Apply multi-language text and config patches with replace, regex, line, JSON, or INI operations, using dry-run previews, backups, and rollback for safe edits.
Instructions
对文本/代码文件打补丁(多语言通用)。
ops 按顺序执行,每一项: {"op": "replace", "old": "...", "new": "...", "count": n|None, "occurrence": n|None} 字符串精确替换;count=只替换前 n 次;occurrence=只替换第 n 次出现 {"op": "regex", "pattern": "...", "replace": "...", "flags": re 数值} 正则替换(全部命中) {"op": "line", "action": "replace|insert_before|insert_after|delete", "line": 行号(1-based), "content": "...", "expected": "可选行内容校验"} 行级操作 {"op": "json", "path": "a.b[0].c", "new_value": ..., "old_value": 可选预期校验} JSON 配置键值修改(保留缩进与编码) {"op": "ini", "section": "...", "key": "...", "new_value": "...", "expected_value": 可选预期校验} INI/CFG 配置键值修改(保留注释与格式)
安全网:自动备份 .reapat_txt_bak;全部 ops 先内存模拟,任一失败整批拒绝; 写盘后回读校验,失败自动从备份回滚;dry_run=true 只预览不写盘。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ops | Yes | ||
| force | No | ||
| dry_run | No | ||
| encoding | No | ||
| file_path | Yes |