@riverai7z/pi-read
v0.1.0
Published
Enhanced read tool for pi with robust text decoding, streaming, notebooks, and paged PDFs
Downloads
18
Maintainers
Readme
@riverai7z/pi-read
Enhanced read tool for pi:
- Similar-path suggestions and macOS screenshot thin-space recovery
- UTF-8/UTF-16LE/UTF-16BE BOM detection and LF normalization
- Bounded streaming reads for large text files
- Exact path/range/mtime deduplication within the current session context
- Readable
.ipynbcells, outputs, errors, and visualizations - Paged PDF rendering with
pages: "1-5"
Install
pi install npm:@riverai7z/pi-readFor local development:
cd /path/to/pi-read
pi -e .
# or
pi install .The package overrides pi's built-in read tool. Pi displays an override warning when it loads; this is expected.
PDF support
PDF support is checked lazily, only when a PDF is first read. It uses Poppler's pdfinfo and pdftoppm locally to render selected pages. The extension never installs system software automatically.
# macOS
brew install poppler
# Debian / Ubuntu
sudo apt install poppler-utils
# Fedora
sudo dnf install poppler-utilsPDFs with at most 10 pages can be read without pages. Larger PDFs require a range. A single call accepts at most 20 pages:
read({ path: "report.pdf", pages: "1-5" })
read({ path: "report.pdf", pages: "21-" })Rendered page images are included in the next request to the active model provider. Their cumulative Base64 payload is capped at 8 MiB per call; pages beyond that limit are reported as omitted, so use smaller ranges when needed. The extension does not upload the original PDF as a document block.
Text limits
Text output is capped at 2,000 lines or 50KB, whichever comes first. The result includes the next offset when more content remains:
read({ path: "large.log", offset: 2001, limit: 2000 })Files under 10 MiB use a fast whole-file path. Larger files are decoded incrementally and only requested lines are retained in memory.
Notebook behavior
Notebook cells are returned in source order. Code, Markdown, stream output, rich text, exceptions, and supported image MIME outputs are associated with their originating cell. HTML and JavaScript outputs are not executed.
Deduplication
The cache key contains the canonical path, resource type, and exact text/PDF range. An unchanged mtime returns a short reference to the earlier result. Cache state is memory-only and is cleared when a session starts or compaction succeeds.
Development
npm install
npm test
npm run typecheck
npm run pack:checkRequires Node.js 22.19 or later and @earendil-works/pi-coding-agent 0.84.4 or later. Version 0.84.4 is required because the extension uses the public detectSupportedImageMimeTypeFromFile() export.
