file_replace
Preview and apply exact text or C# identifier replacements across workspace files, with line-level matches, exclusions, and preserved encoding and line endings.
Instructions
Find and replace text across the files of one workspace, in two calls.
PREVIEW (no planId): reads and matches, writes nothing. Shows every match with its line, the count, and a planId (a preview without a planId shows only counts per file).
APPLY: the SAME arguments plus planId and confirmCount (the count after exclusions). Writes exactly the previewed matches in every file, or nothing. Only the matched characters change: encoding, byte order mark and every line ending stay as they were.
mode 'literal' (default): find is plain text on one line; caseSensitive (default true), wholeWord (default false). mode 'csharp': find and with are C# identifiers; every identifier token with that name in .cs files is renamed by syntax (strings and comments never). Same-named members of other types change too: check the preview and drop wrong lines with excludeJson.
Scope: pathGlob ('/*.cs', 'src/Orders/', '**' for everything) or pathsJson (exact files, e.g. from code_grep), exactly one of them. The access rules apply; vendored, minified, binary and files over 1 MB are left out and counted. A plan lasts 10 minutes and is used once. A wrong confirmCount or different arguments are refused and the plan stays usable; a planned file that changed after the preview is refused too, and that plan is used up: preview again. A preview whose scan was partial (too many files, too slow, over the limits) gives no planId: narrow the scope. WHEN TO USE: the same text or identifier changes in many places or files. For edits at known lines of one file use file_edit_lines; to create or rewrite whole files use file_write. RETURNS: preview - matches per file with marked lines and the planId; apply - replacements per file.
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": {
"workspace": "<workspace>",
"find": "<find>",
"with": "<with>"
},
"name": "file_replace"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| find | Yes | Text to find: one line, at most 200 characters. In mode 'csharp', an identifier. | |
| mode | No | 'literal' (default) or 'csharp' | |
| with | Yes | Replacement: one line, at most 1000 characters; an empty string deletes the matches. In mode 'csharp', an identifier. | |
| guide | No | true: put the files guide first in the result. Use on your first files call, or when told it changed. | |
| planId | No | Leave out to preview. To apply: the planId the preview returned. | |
| pathGlob | No | Files to search, relative to the workspace: '**/*.cs', 'src/Orders/**', '*.json', '**' for all. Give this or pathsJson. | |
| pathsJson | No | JSON array of exact workspace-relative file paths, at most 200: ["src/A.cs","docs/a.md"]. Give this or pathGlob. | |
| wholeWord | No | Literal mode: a match must not touch a letter, digit or '_' (default false). | |
| workspace | Yes | Workspace name as shown in Waymark (a single workspace; '*' is not accepted) | |
| excludeJson | No | Apply only: JSON array of matches to leave alone: "path" (the whole file) or "path#L12" (every match on line 12). | |
| confirmCount | No | Apply only, required: the number of replacements after exclusions, as the preview counted them. | |
| caseSensitive | No | Literal mode: match letter case exactly (default true). |