The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(read-extract): pdftoppm recovery hints shell-quote the PDF path
teknium114e1c1a2ea43
diff --git a/tests/tools/test_notebook_recovery_path.py b/tests/tools/test_notebook_recovery_path.pyindex 3af2c249022..0e4ef8464d0 100644--- a/tests/tools/test_notebook_recovery_path.py+++ b/tests/tools/test_notebook_recovery_path.py@@ -5,7 +5,12 @@ import shleximport pytest-from tools.read_extract import extract_document_bytes, extract_document_text+from tools.read_extract import (+ _needs_ocr_warning,+ _pdf_coverage_note,+ extract_document_bytes,+ extract_document_text,+)@pytest.mark.parametrize('reader', ['bytes', 'text', 'read_file'])@@ -33,3 +38,12 @@ def test_notebook_recovery_hint_opens_original_file(tmp_path, reader):assert argv == ['jq', '-r', '.cells[0].outputs', str(path)]recovered = json.loads(Path(argv[-1]).read_text(encoding='utf-8'))assert recovered['cells'][0]['outputs'][0]['text'] == output+++def test_pdftoppm_recovery_hints_round_trip_apostrophe_path(monkeypatch):+ path = "/tmp/training team's notebook.pdf"+ monkeypatch.setattr('tools.read_extract._pdf_page_texts', lambda _p: ['x' * 500, '', '', ''])+ for note in (_needs_ocr_warning(path, [2]), _pdf_coverage_note('/tmp/copy.pdf', display_path=path)):+ command = note.split('`', 2)[1]+ argv = shlex.split(command)+ assert argv[-2] == path, argvdiff --git a/tools/read_extract.py b/tools/read_extract.pyindex 92c0f1eb907..079ea7917d4 100644--- a/tools/read_extract.py+++ b/tools/read_extract.py@@ -176,7 +176,7 @@ def _needs_ocr_warning(path: str, pages, hosted_error: str = "") -> str:f"[NEEDS OCR: pages {page_list} of this PDF are scanned images "f"with no text layer — their content is MISSING below. {hosted}""If the missing pages matter: render just those pages with "- f"`pdftoppm -jpeg -r 150 -f <first> -l <last> '{path}' /tmp/page` "+ f"`pdftoppm -jpeg -r 150 -f <first> -l <last> {shlex.quote(path)} /tmp/page` ""and inspect via vision_analyze, or check whether an OCR skill is ""available (skills_list).]\n")@@ -307,7 +307,7 @@ def _pdf_coverage_note(path: str, display_path: Optional[str] = None) -> str:f"{_gap_map(counts, texts, empty)}\n""Decide which gaps you actually need — do NOT OCR or render ""everything. For the gaps that matter, render just that range with "- f"`pdftoppm -jpeg -r 150 -f <first> -l <last> '{shown}' /tmp/page` "+ f"`pdftoppm -jpeg -r 150 -f <first> -l <last> {shlex.quote(shown)} /tmp/page` ""and inspect each image with the vision_analyze tool, or use the ""ocr-and-documents skill (marker-pdf) for bulk OCR of large ""ranges.]\n")