Repository navigation
feat(harness): write built-in tool - #62
Merged
Merged
Conversation
…ion handling in read tool
Rewrite `read` to match Pi's read tool: Pi's parameters, description, prompt snippet and continuation notices; text read through `scanLines` so only the shown window leaves the sandbox; images detected by magic bytes (animated PNGs excluded), converted and resized with Photon on a worker thread with EXIF orientation applied; binary files reported as unsupported; macOS path spellings resolved. Add `readBytes` to the sandbox filesystem contract, with a base64 shell form for remote backends, and an optional `encodeDetails` on tool definitions so a payload carried in content is not stored twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `write` matching Pi's write tool: Pi's parameters, description and prompt text, `Successfully wrote to <path>`, parent directories created, and the whole write held under the file's mutation lock. Make `SandboxFileSystem.writeFile` uninterruptible: a started write cannot be called back, so interrupting it only released the file's lock while its bytes still landed over the next writer's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # packages/harness/src/plugin/builtin.ts # packages/harness/test/plugin.external.test.ts # packages/harness/test/plugin.git.live.test.ts # packages/plugin/src/sandbox/filesystem.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on
read(#45, merged).writepathandcontent, Pi's description, prompt snippet ("Create or overwrite files") and guideline, and the result textSuccessfully wrote to <path>.detailsis left empty, as in Pi.@in paths.editof the same file.writeFileis now uninterruptibleA write that has started cannot be called back. Before this change, interrupting it released the file's lock while the write was still in flight, so a queued write could start and then be overwritten by the abandoned one. This is Pi's "keeps the mutation queue locked until an aborted write settles" case.
Tests
tools.write.test.ts: an E2E turn through the harness covering 10 cases (new file, nested parents, overwrite, empty content, unicode/CRLF, path normalisation, parent is a file, target is a directory, invalid arguments), snapshotted with the resulting files to__artifacts__/tools.write.json.Known limitation, not changed here: a write through a dangling symlink gets a different lock key than a write to the symlink's target. That comes from the existing mutation-queue keying, which works the same way as Pi's.
🤖 Generated with Claude Code