Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/midnightdarling/collate/ocr-runnpx skills add MidnightDarling/collate --skill ocr-rungit clone --depth 1 https://github.com/MidnightDarling/collateWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/midnightdarling/collate/ocr-run)<a href="https://agentmods.dev/skills/midnightdarling/collate/ocr-run"><img src="https://agentmods.dev/badge/skills/midnightdarling/collate/ocr-run.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00214 | $0.03852 |
| Opus 5 | $0.00107 | $0.01926 |
| Sonnet 5 | $0.00043 | $0.00770 |
| Haiku 4.5 | $0.00021 | $0.00385 |
Grade A, and why
ocr-run scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 287 lines — stays where its author put it; the contents beside it link to each section on GitHub.
OCR 执行 — 历史文献专用双引擎
Task
把清理过的 PDF 交给 OCR API,拿回 Markdown + 附件 + 对照预览 HTML。
为什么支持两个引擎:
- MinerU(上海 AI Lab):对繁体、竖排、古籍版式、公式、表格识别更强,默认推荐。
- 百度 OCR:稳定、额度大、响应快,适合大批量现代简体论文。
~/.env 里的 OCR_ENGINE=mineru 或 OCR_ENGINE=baidu 决定默认引擎。命令行 --engine=xxx 可临时覆盖。
输出结构(权威规范见插件 references/workspace-layout.md):
<pdf-basename>.ocr/
├── README.md 自动生成的目录地图(workspace_readme.py)
├── source.pdf 被 OCR 的 PDF(prep-scan 的 cleaned.pdf 副本,或用户直接传入)
├── raw.md OCR 原始 Markdown(含 <!-- page N --> 标记)
├── meta.json 引擎、耗时、页数、low_confidence_pages
├── assets/ OCR 抽出的图片附件(古籍插图、论文图表)
├── previews/
│ └── ocr-preview.html 原图 + OCR 文本并排。人工协作模式下可点击右栏编辑
├── _internal/ Pipeline 簿记(MinerU 原生 full.md、导入 provenance)
└── ... 其他 skill 会继续填充 review/ prep/ output/
raw.md / meta.json / assets/ 在根目录,下游(proofread / diff-review / to-docx)读相对路径 assets/xxx.png 不需修改;过程产物(HTML 预览、簿记文件)全部收进子目录。
Process
Step 0:决定走哪条路径(默认本地 mineru CLI)
Agent 默认走 run_mineru.py(本地 mineru[pipeline]),不再按 OCR_ENGINE
环境变量选云 API:
which mineru # 检查 mineru CLI 是否在 PATH
判断:
| 条件 | 路径 |
|---|---|
mineru 在 PATH |
路径 A:run_mineru.py 本地跑 |
mineru 没装 |
路径 B:提示 pip install 'mineru[pipeline]' 或跑 /collate:setup |
| 离线 / 环境装不上 / PDF 有可用文字层且用户急 | 路径 D:extract_text_layer.py 兜底(质量会打折) |
具体四条路径的决策语义与失败兜底全文见
agents/ocr-pipeline-operator.md——ocr-run skill 只负责调脚本,不重复
决策逻辑。
旧的 OCR_ENGINE=baidu|mineru 环境变量仍然被 mineru_client.py /
baidu_client.py 读,但新工作流不走这两个——它们是兼容分支。
Step 1(已合并到 Step 0)
Step 2:建输出目录
支持两种输入形态(任选其一,脚本自动适配):
- 形态 A:
<workspace>/source.pdf(prep-scan 已跑过,工作区已存在) - 形态 B:任意 PDF 路径(用户跳过 prep-scan 直接 OCR,没有预处理痕迹)
PDF="<input-pdf-path>"
DIR=$(dirname "$PDF")
# 如果传入的是 .ocr/source.pdf,OUT 就是它的上级目录(工作区已存在)
# 否则按 basename 建新的 .ocr/ 工作区
if [[ "$DIR" == *.ocr ]]; then
OUT="$DIR"
else
BASE=$(basename "$PDF" .pdf)
OUT="$DIR/$BASE.ocr"
fi
mkdir -p "$OUT/assets" "$OUT/previews" "$OUT/_internal"
# 确保 source.pdf 在根目录(外部传入时复制一份)
[ -f "$OUT/source.pdf" ] || cp "$PDF" "$OUT/source.pdf"
What ships with it
8 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- scripts/apply_corrections.py 3.9 KB runs code
- scripts/baidu_client.py 9.6 KB runs code
- scripts/extract_text_layer.py 13 KB runs code
- scripts/import_mineru_output.py 15 KB runs code
- scripts/make_preview.py 13 KB runs code
- scripts/mineru_client.py 22 KB runs code
- scripts/reflow_mineru.py 22 KB runs code
- scripts/run_mineru.py 13 KB runs code
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 287 lines · 214 tokens per session scan A afa1da0e34a2
ocr-run is a skill published in the GitHub repository MidnightDarling/collate (6 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 214 tokens to every session and 3,852 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
markitdown
Convert files, URLs, and documents to Markdown using the markitdown MCP server. Activate when the user asks to convert, extract, or read content from PDFs, Word docs, PowerPoints, spreadsheets, images, audio files, or any URL.
pdf-conversion
Convert PDF documents to well-structured Markdown files. Use when user asks to convert PDFs, extract text from PDFs, or transform PDF documents to markdown format.
foundry-hosted-agent-validation
Step-by-step process for validating a Python Foundry hosted agent sample (under python/samples/04-hosting/foundry-hosted-agents/) end to end — running it locally (native runtime and azd ai agent run) and after deploying it to an Azure AI Foundry project with azd. Use this when asked to validate a hosted agent sample.
pdf-processing
Extract text from PDFs, fill forms, and merge documents.
Manipulate PDF files — merge, split, extract pages/text, PDF↔images, OCR, info — via the qpdf / poppler / ocrmypdf CLIs. Use to combine, slice, convert, or OCR PDFs.
liteparse
Parse documents into LLM-ready content entirely on the local machine — PDF / DOCX / XLSX / PPTX / images → Markdown, structured JSON (with bounding boxes), or page screenshots, via the lit CLI. No cloud, no LLM, works offline. Use whenever the user attaches or points to a document that must be read before reasoning…