[codefix]
Writes a JS, TS, JSON, or JSONC workspace file with a preview diff by default and applies changes only when requested.
Full-file writes need root-bound path checks, open-document version guards, and a diff that callers can inspect before mutation.
The model can preview or apply JS/TS/JSON file replacement through the server instead of doing an unchecked shell write.
Try it locally in the TGlider playground
| Name | Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | Workspace-relative or absolute file path. |
| text | string | Yes | Full replacement text for the target file. |
| applyChanges | boolean | No | Apply the full-file write to disk and live workspace state instead of returning preview only. |
| includeDiff | boolean | No | Include a unified diff in the response. |
| maxDiffChars | number | No | Maximum diff characters to return before truncating. |
| expectedVersion | number | No | Required live-document version guard when the target file is open. |
Preview a full-file write without mutating disk
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "write_file",
"arguments": {
"filePath": "src/app.ts",
"text": "export const value = 2;\\n"
}
}
}Returns changed/created/applied flags, optional unified diff metadata, live-document version state, and refresh mode after applied writes.