pdf-explainer-summarize
Digest a book, manual, or other long non-paper PDF into a source-anchored Markdown overview. Use when the requested deliverable is only a report, digest, or summary. Use paper-explainer-summarize for academic papers, direct reading for short PDFs, and book-explainer for coordinated reports, audio, site, rebuild, or resume.
- License 许可
- MIT
- 最近更新
- 2026-10-27
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- pdf-explainer-summarize
- description
- Digest a book, manual, or other long non-paper PDF into a source-anchored Markdown overview. Use when the requested deliverable is only a report, digest, or summary. Use paper-explainer-summarize for academic papers, direct reading for short PDFs, and book-explainer for coordinated reports, audio, site, rebuild, or resume.
- user-invocable
- true
02 资源文件 11
- 其他flake.lock569 B
- 其他flake.nix1.0 KB
- 参考文档references/bundled-scripts.md2.4 KB
- 参考文档references/finalize.md4.4 KB
- 参考文档references/overview-report.md4.5 KB
- 参考文档references/runtime-and-options.md9.0 KB
- 参考文档references/success-criteria.md2.0 KB
- 脚本scripts/figure_harvest.sh4.1 KB
- 脚本scripts/mineru_figures.py7.8 KB
- 脚本scripts/preflight.sh2.5 KB
- 脚本scripts/text_layer.sh2.1 KB
03 SKILL.md 正文
PDF Report Pipeline
Convert a large PDF into a Markdown report through three phases that progressively compress information: extract → structure → report. Separating faithful extraction from interpretive synthesis is what prevents the boundary inconsistencies that appear when a report is written directly from fixed page ranges. Run the heavy phases (extraction and structuring) in isolated contexts so the source pages and intermediate material never fill the orchestrator's context; the final report phase reads only the already-compressed outline, so the orchestrator writes it directly.
Book-workflow invocation
When this skill owns the PDF report phase of the book workflow, apply
[[explainer-content-workflow-base]] with the book profile. Require the exact immutable run request and
the caller's validated source identity, output paths, actions, and digests.
Use the source options, report scope, language, and replacement decisions
recorded there instead of asking again or relying on an earlier session. A
create action must not overwrite an existing Artifact; a replace action
applies only to its exact target. Return exact produced paths and digests, AI
acceptance checks, and any structured blocker so a fresh coordinator session
can continue from the files alone.
When invoked directly, use the interactive option procedure below.
Before starting — read the runtime and option contract
Read references/runtime-and-options.md completely before running any command or creating the work directory. It contains the original Gotchas, Prerequisites, Step 0 option gate, and work-directory layout without abridgment. In a book-workflow invocation, treat the immutable run request as the already-resolved Step 0 option gate and ask only when an input is missing or incompatible.
Phase 0 — Figure harvest (orchestrator, Bash, unsandboxed)
Run once over the body range with the sandbox disabled (MinerU's local service + multiprocessing, and the first uv sync / model download, are blocked under the sandbox), launching the worker through preflight.sh so its runtime env (poppler + a MinerU source) is resolved:
bash <SKILL_DIR>/scripts/preflight.sh bash <SKILL_DIR>/scripts/figure_harvest.sh <pdf-abs-path> <WORK_DIR>/ocr [body-start] [body-end]
Pass the body range if you have already detected the body-start; otherwise omit the range and harvest the whole PDF (a cover image or other front-matter crop is harmless and is dropped by the Finalize sweep if no report uses it). It crops the genuine figures — diagrams, plots, photos — into ocr/figures/fig-pNNN-K.ext (named by absolute PDF page) and writes ocr/figures.md (Label / File / Page / Caption). Tables and console output are deliberately not cropped: the text extraction already carries them. MinerU can take minutes and downloads models on first run — use a generous timeout. If preflight.sh reports the runtime is unresolvable (no poppler+uv/mineru on PATH, no nix), relay the setup options and continue the pipeline without figures; on any other failure, report it and continue without figures. The crops are consumed by Phase 1 (assigned to chunks) and swept for coverage at Finalize. This phase writes only files — no page content enters the orchestrator's context.
Phase 1 — Chunked extraction (parallel)
Split the body into chunks and extract each chunk in parallel. Each chunk is read — visually by default, or from the faithful text layer if the user opted in at Step 0 — and written as structured material, not a finished report. The per-chunk role, mandatory constraints, and material format live in the pdf-explainer-pdf-extract skill; apply it once per chunk:
-
Under Claude Code, dispatch one
pdf-explainer-pdf-extractsubagent per chunk (multiple Agent calls in one message) so the source pages never enter the orchestrator's context and the chunks run concurrently. The subagent has no Bash tool, so it cannot install software or shell out to PDF converters. -
Otherwise, apply the
pdf-explainer-pdf-extractskill once per chunk, keeping each chunk's extraction self-contained and writing its file without reading the pages back into the main context. -
Chunk size: the Read tool reads at most 20 pages per request. A worker may make several Read calls, so a chunk can span more than 20 pages with seamless internal boundaries — only chunk-to-chunk boundaries need stitching in Phase 2. Default to 20-page chunks unless larger spans reduce boundary count usefully.
-
Skip front matter: start chunking at the detected body-start page.
-
Text-layer mode (opt-in): before dispatching each chunk, materialize its faithful text —
bash <SKILL_DIR>/scripts/preflight.sh bash <SKILL_DIR>/scripts/text_layer.sh <pdf-abs-path> <WORK_DIR>/extract/text-<START>-<END>.md <START> <END>(preflight.shresolves poppler from PATH or the bundled flake) — and pass the worker that text file's path instead of a visual page range. The worker reads the[pNN]-anchored text (no PDF rasterization). Onepdftotextper page is cheap; do this in the orchestrator (it writes a file, so no page content enters context). -
Output: each chunk writes
extract/chunk-<start>-<end>.mdand returns only a short status (file path, end state complete/continued, one-line boundary context). The extracted body never enters the orchestrator's context.
Pass in the call message only the per-chunk inputs:
- The source to read: visual mode — the PDF absolute path and the page range (START–END); text-layer mode — the absolute path to
extract/text-<START>-<END>.md(still note the START–END range for anchors). - The output path
extract/chunk-<START>-<END>.md. - Assigned figures (if Phase 0 ran): the rows of
ocr/figures.mdwhose[pNN]page falls in this chunk's range, so the worker catalogs each figure (by itsfigures/…relative path, page, and caption) in the material — a menu the report phase can draw from, not a mandate to use every figure.
Give absolute paths.
Phase 2 — Stitch & structure (single pass)
Apply the pdf-explainer-pdf-stitch skill once, reading all extract/chunk-*.md files and rebuilding the document's logic into two artifacts — the spine first, then the outline:
- Build
structured/toc.md(the canonical spine) by merging the chunks'## Headingsstreams: dedupe boundary repeats, keep each heading's source-form title verbatim, and take its[pNN]from the stream (never a blank page). If you captured a printed TOC, hand it over as a completeness cross-check. - Assemble
structured/outline.mdagainst the spine: its heading tree istoc.md's (same titles/anchors), with the boundary-joined, deduped content filled under each. Do not invent a second structure. - Preserve the figure references the chunks recorded (from
ocr/figures.md) against their sections, so the outline knows which figure belongs where. - Record a boundary note: what was joined, where coverage stops mid-section (if partial), and any TOC↔heading cross-check discrepancy.
- Record the printed-page↔PDF-page offset in a
## Page offsetfield near the top of both files (e.g. "printed page N = PDF page N + 27", or "none detected") sobook-explainercan resolve chapter-detail source pages.
Under Claude Code, dispatch a single pdf-explainer-pdf-stitch subagent; otherwise apply the skill inline. Pass the extract/ directory absolute path, the output path structured/outline.md (the spine toc.md is written beside it), any captured printed TOC, and — if Phase 0 ran — the ocr/figures.md absolute path so it can keep figure references against their sections. It returns only the spine heading count and one line on boundary decisions.
Phase 3 — Overview report (orchestrator, inline)
Read references/overview-report.md completely at the start of Phase 3 and follow it end-to-end. It contains the original overview procedure and altitude cap without abridgment.
Finalize
Read references/finalize.md completely after Phase 3 and follow it end-to-end. Before declaring the pipeline complete, read references/success-criteria.md completely and verify every applicable item.
Orchestration rules (context hygiene)
- Extraction/stitch workers write outputs to files and return only a short status. Never have a worker echo extracted body text back to the orchestrator — that defeats the point.
- Do not Read the PDF pages or the large chunk files into the orchestrator's own context. Trust the file-based hand-off.
- Parallelize Phase 1 (chunks are independent); then run Phase 2 and Phase 3 sequentially — each depends on the prior file.
- For very large documents, build Phase 3 in levels (section → chapter → whole) so each reduce step stays within context.
Phase workers
Phases 1–2 each run a dedicated procedure that lives in its own portable skill, so this orchestrator only chooses the phase order, the work dir, and the per-call inputs. Under Claude Code each is wrapped by a thin subagent (for isolation and parallelism); on any agent the same skill can be applied inline (see each phase above). Phase 3 has no separate worker — the orchestrator writes the report itself (see Phase 3).
pdf-explainer-pdf-extract— Phase 1, one per chunk in parallel. Read+Write only (no Bash, so it cannot install software or convert PDFs itself).pdf-explainer-pdf-stitch— Phase 2, single instance. Read+Write+Glob.
When per-chapter detail reports are needed, [[book-explainer]] applies the
internal pdf-explainer-pdf-detail worker.
Bundled scripts
Before running Phase 0 or any text-layer command, read references/bundled-scripts.md completely. It contains the original script and runtime details without abridgment.
04 同仓库更多 Skills
invalid-skill-frontmatter
暂无简介
pdf-explainer-pdf-stitch
Internal Phase 2 worker invoked once by pdf-explainer-summarize after chunk extraction. Reconciles sections across chunk boundaries, deduplicates the material, and writes the canonical structural spine and outline.
pdf-explainer-pdf-extract
Internal Phase 1 worker invoked by pdf-explainer-summarize once per page chunk. Reads the chunk visually or from a faithful text layer and writes structured source material with a verbatim heading stream, not a finished report.
pdf-explainer-pdf-detail
Internal per-chapter worker invoked by book-explainer for PDF input. Re-read one resolved chapter span visually or from a faithful text layer and write a standalone detail report with [pNN] source anchors.
pdf-explainer-generate-site
Compatibility entry point for requesting a local PDF reading site from an existing work directory. Route through book-explainer so Artifact reconciliation and Planning still occur.
paper-explainer
Coordinate a complete academic-paper explanation from a new PDF, existing work directory, or explicitly named Run Manifest. Use for first runs, continuation, selective report/audio/site rebuilds, and exact-run resume.