files.update
Rewrite a file's full content or replace only a specific section's body by heading, preserving the heading and siblings. Updates disk and search index, returning new token counts.
Instructions
Rewrite a file. Default = full-body replacement: content becomes the entire file, triggering disk write + FTS5 re-index. Pass section to instead rewrite ONLY that heading's body (case-insensitive exact-string after trim; the heading line itself is preserved, siblings untouched) — saves context budget vs resending the whole file. Throws if section is set but the heading doesn't exist (this mode will NOT create a new section — append the section text via a full-body update first). Operates locally with no external auth or rate limits. Returns the updated file metadata including new estimated token counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | File ID | |
| content | Yes | New content. With `section` set, this replaces just that heading's body; otherwise it becomes the entire file body. | |
| section | No | Case-insensitive exact-string heading. When set, only this heading's body is rewritten instead of the whole file. |