feat(vfs): add text_file and readonly_text builder methods - #103
Merged
Conversation
Add convenience methods to BashBuilder for pre-populating the virtual filesystem with text files during construction: - `text_file(path, content)` - Creates writable file (mode 0o644) - `readonly_text(path, content)` - Creates readonly file (mode 0o444) Also adds `InMemoryFs::add_file()` for synchronous file creation during setup, with automatic parent directory creation. Features: - Parent directories created automatically - Works with default InMemoryFs - Full test coverage (12 new tests) - Example demonstrating usage patterns https://claude.ai/code/session_019zbW5sGDfV1uSjRp9RRRSR
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
chaliy
added a commit
that referenced
this pull request
May 30, 2026
## Summary
- Add `text_file(path, content)` and `readonly_text(path, content)`
convenience methods to `BashBuilder`
- Add `InMemoryFs::add_file()` for synchronous file creation during
setup with automatic parent directory creation
- Update VFS spec (003-vfs.md) with documentation for the new feature
## Details
These methods make it easy to pre-populate the virtual filesystem during
Bash construction without needing async code:
```rust
let mut bash = Bash::builder()
.text_file("/config/app.conf", "debug=true\nport=8080\n")
.readonly_text("/etc/version", "1.2.3")
.build();
```
**Use cases:**
- Configuration files for scripts to read
- Reference data that shouldn't be modified
- Pre-seeding test fixtures
- Simulating system files like `/etc/passwd`
## Test plan
- [x] 12 new unit tests covering all functionality
- [x] Tests verify file creation, permissions (0o644 vs 0o444), parent
directory creation
- [x] All 541 existing tests continue to pass
- [x] New example `text_files.rs` demonstrates usage patterns
https://claude.ai/code/session_019zbW5sGDfV1uSjRp9RRRSR
Co-authored-by: Claude <noreply@anthropic.com>
2 tasks
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.
Summary
text_file(path, content)andreadonly_text(path, content)convenience methods toBashBuilderInMemoryFs::add_file()for synchronous file creation during setup with automatic parent directory creationDetails
These methods make it easy to pre-populate the virtual filesystem during Bash construction without needing async code:
Use cases:
/etc/passwdTest plan
text_files.rsdemonstrates usage patternshttps://claude.ai/code/session_019zbW5sGDfV1uSjRp9RRRSR