{"version":"2.1.333","anchor":"sandboxconfig-check-for-fswrite-and-fsremove-now-requires","canonical_anchor":"plugin-fswrite-hook-function-gains-base64ifversion-byte-ex","heading":"Plugin hooks modules gain file remove, rename and copy, and versioned writes","tier":"notice","area":"Plugin API","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.333\/e\/sandboxconfig-check-for-fswrite-and-fsremove-now-requires","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.333","markdown":"### Plugin hooks modules gain file remove, rename and copy, and versioned writes\n\nPlugin hooks modules get `fs.remove`, `fs.rename` and `fs.copy`, byte-exact and version-checked `$.fs.write`, and stricter `plugin validate` checks\n\n**Unclear.** It is not clear what this changes for someone using these operations.\n\n**What**\n\nA hooks module is a script in a plugin that handles Claude Code events and can call functions such as `$.fs.write` to work with files. This release widens and tightens those file functions:\n\n- `$.fs.write` can take raw bytes as `{ base64 }` (also described as `bytes`) for byte-exact writes, and an `ifVersion` value.\n\n- Reading a file's details (stat) now returns a `version`, which can be passed back as `ifVersion`. A write can then be refused with \"the file changed since it was checked\".\n\n- New `fs.remove`, `fs.rename` and `fs.copy` functions. They are checked against the sandbox's deny lists (the paths the sandbox blocks) and refuse symbolic links and folders.\n\n- `ui.browse` is added to the list of operations plugins can call.\n\n- The checks that inspect or restore arguments for `fs.write` and `fs.remove` now apply only when the call includes an `ifVersion` key.\n\n- Hard-linked files (one file reachable under two names) are refused in place, and a new Windows read and write check applies.\n\n`plugin validate` also checks hooks modules more strictly. It now warns about:\n\n- matchers that never hear an engine value\n\n- command names the module may answer without a plugin name\n\n- `$.session.append` rows that are not under the plugin's name\n\n- calls this build does not have, reported as \"is not a call of this build\"\n\n**Why**\n\nPlugins can now delete, rename and copy files, not only write them, with safety checks around each. A plugin can also make sure it does not overwrite a file that changed after it last looked. Plugin authors get earlier warnings about mistakes in their hooks modules.\n\n- Area: Plugin API\n- Names: `fs.write`, `fs.remove`, `ifVersion`\n- Tier: You'll notice\n- Useful: 3\/5\n- Signal: 3\/5\n- Scope: individual\n- Heads-up: no"}