readonly-fs-tools
Three safe tools for agentic code analysis: Globber, Grepper, and Viewer.
This package provides security-focused, sandboxed file operations designed specifically for AI agents and automated code analysis workflows. Each tool enforces strict boundaries to prevent unauthorized file access while enabling powerful code exploration capabilities.
Installation
# Add to your project
uv add readonly-fs-tools
Quick Start
from readonly_fs_tools import Sandbox, Globber, Grepper, Viewer, OutputBudget
from pathlib import Path
# Create a sandbox configuration
sandbox = Sandbox(
sandbox_dir=Path("/path/to/your/project"),
blocked_files=["*.secret", "private/*"],
allow_hidden=False
)
# Set up output budget to limit response sizes
budget = OutputBudget(max_chars=10000)
# 1. Find files with glob patterns
globber = Globber.from_sandbox(sandbox)
glob_result = globber.glob("**/*.py", budget)
print(f"Found {len(glob_result.paths)} Python files")
# 2. Search file contents with regex
grepper = Grepper.from_sandbox(sandbox)
grep_result = grepper.grep(r"class \w+", "**/*.py", budget)
for match in grep_result.matches:
print(f"{match.path}:{match.line_number}: {match.line}")
# 3. View file contents safely
viewer = Viewer.from_sandbox(sandbox)
view_result = viewer.view("src/main.py", budget)
print(view_result.content.text)
Core Components
Security Model
All tools are executed in the context of a Sandbox which enforces:
- Sandbox directory constraints - Operations limited to specified directory
- File blocklist - Pattern-based file exclusion (e.g.,
*.secret,private/*) - Hidden file controls - Optional access to dotfiles and hidden directories (off by default)
In addition, each tool supports:
- Output size limits - Configurable via
OutputBudgetto constrain token usage - Streaming operations - Files are processed in a memory-efficient manner, allowing for large files to be handled safely
Tools
Globber - Safe file pattern matching
- Uses glob patterns like
**/*.pyorsrc/**/*.{js,ts} - Respects sandbox boundaries and blocklists
Grepper - Safe content search
- Regex-based content search across files
- Pattern matching with full regex syntax support
- Returns matches with file paths, line numbers, and the full matched line for context
Viewer - Safe file viewing
- Bounded file content access with configurable limits
- Support for line ranges and content windows
- Safe handling of binary files and large files
Key Types
# Pattern validation
GlobPattern # Validated glob patterns
RegexPattern # Validated regex patterns
# File access
FileWindow # Line-based file access windows
FileContent # Safe file content representation
FileReadResult # Results with metadata
# Configuration
Sandbox # Security boundary configuration
OutputBudget # Output size limiting
Development
This project uses uv for dependency management.
uv sync --dev
Code Quality
uv run ruff check --fix # Lint code
uv run ruff format # Format code
uv run mypy --strict . # Type checking
Testing
uv run pytest # Run all tests
uv run pytest tests/test_specific_file.py # Run specific tests
Architecture
The package implements a three-layer security model:
- Sandbox - Directory and file access controls
- Budget - Resource usage limits
- Validation - Input pattern validation and output sanitization
All operations are designed to be safe for automated/AI agent use while providing the file system access needed for code analysis tasks.
Generative AI disclaimer
This package was designed by a human developer, with assistance from generative AI. The code however was generated almost entirely by generative AI. The security model and design principles were carefully crafted to ensure safety and reliability for agentic code/filesystem analysis tasks. If you find any issues or have suggestions, please open an issue on GitHub.
License
MIT License - see LICENSE for details.
Links
Metadata
Release files for readonly-fs-tools 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| readonly_fs_tools-0.2.0.tar.gz | 9.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| readonly_fs_tools-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / readonly_fs_tools-0.2.0.tar.gz
| Download URL | readonly_fs_tools-0.2.0.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abcb837b08c2825a3899908166c888bf45c08198b2e59553766c337dba7649a1
|
|
BLAKE2b-256 checksum How to use checksums |
4a8eac46fd5a38d6924c411738692590d4dc57feadfffdc467bdf48b7f4543d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.13
|
Release files / readonly_fs_tools-0.2.0-py3-none-any.whl
| Download URL | readonly_fs_tools-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b9c0a22e7b37e4aa884a314bc644a2f7708eb32c8c98e0f877a7013428ba9d7
|
|
BLAKE2b-256 checksum How to use checksums |
7253dfc0e75bc2a5ddbbda07324f5408b884e6edbbdca7497c64a769e03cb866
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.13
|
Security for readonly-fs-tools 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.