fix(skills): open PDFs on Windows by converting MSYS paths to native - #70315
fix(skills): open PDFs on Windows by converting MSYS paths to native#70315valicen-davidsaunders wants to merge 6 commits into
Conversation
Hermes on Windows fed MSYS /c/... paths to native tools (pdftotext, pymupdf, pdfplumber), which can't open them. Document the conversion to native C:\ paths, the read_file-bytes fallback, and that pypdf/pdfplumber/pdfminer.six/pymupdf are preinstalled.
…bs note Add 'Hermes on Windows' section: convert MSYS /c/... paths to native C:\ before pymupdf/pdftotext/Python; read_file-bytes fallback; note pymupdf/pypdf/pdfplumber/pdfminer.six are preinstalled in the venv.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing a real Windows/MSYS usability boundary. The local terminal backend deliberately disables MSYS argv conversion (tools/environments/local.py:1178-1198), so native-path guidance is directionally sound.
Problems
skills/productivity/ocr-and-documents/SKILL.md:34proposes getting PDF bytes fromread_file, butread_filereturns line-numbered text (tools/file_tools.py:1110-1184) and PDF is not an extractable-document type (tools/read_extract.py:18-42). Theio.BytesIO(data)fallback cannot run as written.skills/productivity/ocr-and-documents/SKILL.md:42andskills/productivity/pdf/SKILL.md:25saypymupdf,pypdf,pdfplumber,pdfminer.six,pdftotext, andqpdfare preinstalled. The Python packages are not declared inpyproject.toml; current source guidance instead calls for installing the PDF packages (skills/productivity/pdf/SKILL.md:23-31,skills/productivity/ocr-and-documents/SKILL.md:60-64).
Suggested changes
- Remove the invalid
read_filebytes fallback and correct the dependency/tool availability claims; preserve the native-path guidance.
Automated hermes-sweeper review.
| In Python, use a raw Windows path or forward-slash drive form; never `/c/...`: | ||
|
|
||
| ```python | ||
| path = r"C:\Users\David\Downloads\Valicen brandbook.pdf" # or "C:/Users/David/Downloads/Valicen brandbook.pdf" |
There was a problem hiding this comment.
read_file does not expose raw bytes to the agent: it returns line-numbered text, and PDF is not one of its structured extraction types (tools/file_tools.py:1110-1192, tools/read_extract.py:18-42). Please remove this io.BytesIO(data) fallback or replace it with a verified byte-producing path.
| ```python | ||
| import io, pypdf # pre-installed | ||
| data = <bytes from read_file> | ||
| text = "\n".join(p.extract_text() or "" for p in pypdf.PdfReader(io.BytesIO(data)).pages) |
There was a problem hiding this comment.
These packages are not declared by the Hermes installation (pyproject.toml has no pymupdf, pypdf, pdfplumber, or pdfminer dependency), and current skill guidance still instructs users to install them. Please avoid promising they are preinstalled unless a Windows installer path is added and verified.
… bytes fallback, correct lib-availability claim Per review on NousResearch#70315: read_file returns line-numbered text (not raw bytes) and PDF is not an extractable-document type, so the io.BytesIO fallback could not run — removed it. Replaced the 'preinstalled' claim with an install instruction (packages are not in upstream pyproject). Native-path guidance retained.
…stalled claim, drop read_file bytes fallback Per review on NousResearch#70315: the PDF libs are not declared in upstream pyproject, so replaced the 'already installed' claim with an install instruction; removed the read_file/io.BytesIO fallback (read_file returns text, not bytes). Native-path guidance retained.
What does this PR do?
On Windows, Hermes's shell reports paths in MSYS form (
/c/Users/...), but thepdfandocr-and-documentsskills passed those paths straight to native tools(
pdftotext,pymupdf,pdfplumber, Python'sopen()), which cannot open/c/...and fail withI/O Error: Couldn't open file/FileNotFoundError.The agent tends to misread this as a sandbox restriction and give up, asking the
user to copy-paste the PDF text by hand.
This PR fixes the guidance in both skills so PDF reads work on Windows with no
change in how the user prompts: convert MSYS paths to native
C:\...beforehanding them to a native tool, fall back to parsing
read_filebytes viaio.BytesIO, and clarify which libraries to expect in the venv. Linux/macOSbehavior is unchanged.
Same MSYS-path class as #66524 (shell lint) and #67914 (rg search), applied here
to the PDF skills. Consistent with the terminal backend's existing
_msys_to_windows_pathhandling — surfaced as skill guidance rather than code.Related Issue
N/A — no existing issue; documentation/skill-content fix.
Type of Change
Changes Made
skills/productivity/pdf/SKILL.md— added a "Windows paths — critical" section(MSYS
/c/...→ nativeC:\...,read_file-bytes fallback); notedpypdf/pdfplumber/pdfminer.six/pymupdfare available; fixed theextract-text example to use a native path.
skills/productivity/ocr-and-documents/SKILL.md— added a "Hermes on Windows"section (same path rule + fallback), noted the expected libs and how to detect
the wrong interpreter, fixed the inline
pymupdfexample path.How to Test
venv\Scripts\python -c "import fitz, pymupdf, pdfplumber, pypdf, pdfminer; print('ok')"/c/...):venv\Scripts\python -c "import pymupdf; d=pymupdf.open(r'C:\Users\<you>\Downloads\some.pdf'); print(len(''.join(p.get_text() for p in d)))"Passing
/c/Users/...instead reproduces the originalI/O Error.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass — N/A: docs-only skill-markdown change; CONTRIBUTING states doc-only changes need no testsDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
On a Windows venv (Py 3.11):
import fitz/pymupdf/pdfplumber/pypdf/pdfminerallsucceed; a 30-page PDF extracted to 11,791 characters via a native
C:/...path.Passing the MSYS
/c/...form reproducesI/O Error: Couldn't open file.