Work on a machine · Material 7 of 12
Edit a file with a version check
Practice a small, exact file edit on a computer you own, preserve other edits with a SHA-256 check, and verify the result.
Practice a precise change to a disposable text file rather than a live configuration. The goal is to change one value, keep another line intact and verify the result.
Set the boundary
List your computers with your connected CMDOP agent. Choose one online computer you own and a folder where the agent is permitted to work. Use that explicit computer name or ID for every call in the exercise. Use a new practice file, not an existing project file or a file containing credentials.
Reading needs the read grant. Creating and editing need write permission from the agent's grant and the selected computer. Do not enable command execution for this exercise.
Create and inspect the practice file
Ask the agent to use fs_write with create_only set to true. Pick a new filename in the approved folder and use these two lines:
mode=practice
note=keep this lineIf the file already exists, stop rather than replacing it. Choose another unused filename only with the owner's agreement. Read the new file with fs_read and inspect its SHA-256 with fs_stat using hash: true. Check that the hash matches the one returned by the creation call. If it does not, review the current content before deciding what to do.
Make one exact change
Ask the agent to change only mode=practice to mode=reviewed with fs_edit. It must pass the SHA-256 of the reviewed version as expect_sha256 and leave replace_all off. The old text must occur once, including its whitespace.
If the file has changed since review, the hash check refuses the edit. Do not simply obtain a fresh hash and repeat the earlier change. Read the current version, inspect the difference and get agreement on the intended change. If the intended edit is still appropriate, use the hash of that newly reviewed version and preserve the other editor's changes. Respect any permission refusal. When several agents work on a project, also agree on the file scope and ownership described in Start a project.
Verify the outcome
Read the file again. If no other editor changed the note, expect:
mode=reviewed
note=keep this lineIf the note was independently changed and you approved the revised edit, expect the revised note instead. Check that exactly one occurrence was replaced, the other line is intact as reviewed, and the new SHA-256 from fs_stat matches the edit result. Do not treat the tool's response alone as proof that the intended text is present.
What happens if the version changes?
In a separate controlled run, another edit changed only the note after the original hash was recorded. A request to change the mode using that old hash was refused. Reading the file confirmed that the mode had not changed and the newer note was still present. After reviewing the updated text, the guarded mode edit succeeded once; another read and hash check confirmed both lines.
This verifies the success and stale-version refusal paths in that disposable-file exercise, not all possible conflicts or permissions. For exact arguments, limits and error details, see Work with files in the CMDOP technical documentation. Leave the practice file in place unless the owner explicitly requests cleanup.
