Wiki ingest ocr
一套将 PDF/LaTeX 自动转化为 Obsidian 结构化 Markdown 知识图谱的 AI 智能体技能。
npx -y skills add Misaka16384/Wikify --skill wiki_ingest_ocrAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Ingest new academic papers or PDFs into the raw/ folder of your active topic wiki using the local OCR model configured in config.yaml.
SKILL.md
5.8 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it
LLM Wiki — Ingest Local OCR Skill (wiki_ingest_ocr)
Resolving script paths (read first): Commands below invoke scripts as
<BIN>/X.py(and a few as<SKILLS>/...). Resolve these to absolute paths once before running anything:
<SKILL_DIR>= the directory thisSKILL.mdlives in.<SKILLS>= theskills/folder containing this skill =<SKILL_DIR>/..<BIN>= thebin/folder beside it =<SKILL_DIR>/../../binDo not hardcode a fixed prefix like
.agents/binor../bin: shell relative paths resolve against the current working directory (usually the topic root), not this skill's location. Once resolved,<BIN>is typically.agents/binwhen invoked from the hub root, or.claude/binfrom inside a topic directory.
This skill handles converting external PDF documents (especially academic papers or scanned articles inside inbox/ or custom local paths) into high-fidelity clean Markdown using the local OCR model configured in config.yaml (default: glm-ocr at 130 DPI).
Figures are handled automatically. Both the PDF path (
pdf2md-agent) and the TeX path (tex2md.py) extract figures into animages/folder beside the output Markdown and embed them inline (). Figure files are prefixed with the document slug, so multiple papers can share oneraw/<type>/images/folder without collisions. Vector figures and.epssources are rasterised to PNG. You do not need to handle figures manually.
When the user asks to ingest PDFs using local OCR (or runs the command without a path):
-
Resolve Ingestion Targets:
- If a specific file path is provided, process that target.
- If NO target is provided, automatically scan the
inbox/directory for any.pdf,.md, or.texfiles. - If
inbox/contains multiple target files, you MUST loop through all of them and process them one by one in a batch. - If
inbox/is empty of target files, only then prompt the user to specify a file path.
-
Identify Source Type: For each PDF file, academic papers go to
raw/papers/, other articles toraw/articles/. -
File Type Handling & Conversion:
- For
.pdffiles (Execute Local GLM-OCR Conversion):- Run the upgraded local
pdf2md-agentscript on the PDF:python <BIN>/pdf2md-agent/agent.py "<PDF_PATH>" -o "<TOPIC_DIR>/raw/<type>" -t "<DOC_TITLE>" - Note: This script now automatically generates the standard YAML frontmatter and writes the file as
YYYY-MM-DD-slug.mddirectly into your output directory. You do NOT need to rename the file or append YAML manually.
- Run the upgraded local
- For
.mdfiles or general inbox files, call the ingest helper script:python <BIN>/ingest_helper.py --source-file \"<MD_FILE>\" --type \"<TYPE>\" --topic-dir \"<TOPIC_DIR>\" [--date \"<DATE>\"]This script handles parsing/injecting standard YAML frontmatter, slugifying, and moving/copying the file. - For
.texfiles (and arXiv.tar.gzsource bundles): You MUST use the Pandoc conversion script instead of OCR. Run:python <BIN>/tex2md.py "<TEX_OR_TARGZ_PATH>" -o "<TOPIC_DIR>\raw\<type>"Note: This script automatically generates YAML frontmatter, writes the file, and extracts/converts referenced figures intoimages/(rasterising.pdf/.epsfigures to PNG). Check the printedFigures: N embedded, M unresolvedline; if any are unresolved, the source bundle may be missing those figure files.
- For
-
Post-Processing Pipeline: Extract the exact path of the generated Markdown file from the conversion script's output. Then, trigger the pipeline to handle moving and formatting (skipping global lint for now):
python <BIN>/ingest_pipeline.py "<ORIGINAL_FILE_PATH>" --topic-dir "<TOPIC_DIR>" --md-file "<GENERATED_MD_FILE>" --skip-lint --log-msg "Ingested <DOC_TITLE> via OCR" -
Manual Math Error Correction (Agentic Fallback):
- CRITICAL: If
ingest_pipeline.pyoutputs any warnings like[WARNING] Math syntax errors in <FILE>:, you MUST immediately stop and fix them. - Do NOT guess the fix for semantic errors like
Double subscriptorUnexpected end of stream. - You MUST use your file reading, search, or multimodal vision tools to read the original source PDF at the corresponding location to see the actual formula.
- CRITICAL TOOL: If you cannot easily infer the formula structure, you MUST use the provided PDF cropping tool to extract the exact region around the error as an image for your multimodal vision:
python <BIN>/pdf_math_crop.py "<PDF_PATH>" --text "<search_text_near_error>" --out "<TOPIC_DIR>\scratch\crop.png" - View the generated
crop.png, then manually edit the Markdown file to correct the semantic math errors based on the ground truth in the original paper, and re-runpython <BIN>/validate_math_latex.py <FILE>to confirm all errors are gone.
- CRITICAL: If
-
Global Lint & Index (End of Batch):
- CRITICAL: Once ALL files in the
inbox/have been processed through steps 1-5, you MUST run the global lint and index operation ONCE outside the loop:
python <BIN>/ingest_pipeline.py "none" --topic-dir "<TOPIC_DIR>" --lint-only - CRITICAL: Once ALL files in the
Error Handling
- If any script exits with non-zero code, report the full stderr output to the user and stop.
- If a file cannot be read or parsed, log a warning and continue with remaining files.
- Do NOT silently skip errors or proceed with partial results without reporting.