$npx -y skills add WILLOSCAR/research-units-pipeline-skills --skill citation-verifierGenerate and verify BibTeX entries from paper notes, writing citations/ref.bib and citations/verified.jsonl. Trigger: citation, BibTeX, ref.bib, verified.jsonl, references, 引用, 参考文献. Use when: 已有 papers/paper_notes.jsonl,需要为 prose/LaTeX 准备可追溯的引用(每条都有 url/date/title
| 1 | # Citation Verifier |
| 2 | |
| 3 | Generate `citations/ref.bib` and ensure every entry has a traceable verification record in `citations/verified.jsonl`. |
| 4 | |
| 5 | When network access is restricted, prefer a “record now, verify later” workflow: keep URLs/titles consistent and leave a clear verification note. |
| 6 | |
| 7 | ## Input |
| 8 | |
| 9 | - `papers/paper_notes.jsonl` |
| 10 | |
| 11 | ## Outputs |
| 12 | |
| 13 | - `citations/ref.bib` |
| 14 | - `citations/verified.jsonl` |
| 15 | |
| 16 | ## Workflow (heuristic) |
| 17 | |
| 18 | 1. Collect `bibkey`, `title`, `url`, `year`, `authors` from `papers/paper_notes.jsonl`. |
| 19 | 2. Write/refresh `citations/ref.bib`: |
| 20 | - Prefer arXiv-style fields when `arxiv_id` / `primary_category` exist (`eprint`, `archivePrefix`, `primaryClass`). |
| 21 | 3. Write one verification record per BibTeX entry to `citations/verified.jsonl` with at least: |
| 22 | - `bibkey`, `title`, `url`, `date` |
| 23 | 4. If you cannot verify via network, record a clear `notes` field (e.g., “auto-generated; needs manual verification”) and/or request human confirmation depending on your policy. |
| 24 | |
| 25 | ## Quality checklist |
| 26 | |
| 27 | - [ ] Every BibTeX entry has a corresponding `verified.jsonl` record. |
| 28 | - [ ] No missing `url`/`date`/`title` in verification records. |
| 29 | |
| 30 | ## Offline Mode |
| 31 | |
| 32 | When network access is restricted, run in offline mode to produce auditable records now, then verify later. |
| 33 | |
| 34 | - Generate offline records: `verification_status: offline_generated` |
| 35 | - Verify later (when network is available): `--verify-only` |
| 36 | |
| 37 | ### `verification_status` |
| 38 | |
| 39 | - `offline_generated`: record was generated without network verification (needs later verification) |
| 40 | - `verified_online`: URL/title verified successfully by the script |
| 41 | - `verify_failed`: verification was attempted but failed (network error or title mismatch) |
| 42 | - `needs_manual_verification`: missing/ambiguous fields (e.g., empty `url`/`title`) |
| 43 | |
| 44 | ## Script |
| 45 | |
| 46 | ### Quick Start |
| 47 | |
| 48 | - `uv run python .codex/skills/citation-verifier/scripts/run.py --help` |
| 49 | - Offline (record now, verify later): `uv run python .codex/skills/citation-verifier/scripts/run.py --workspace <workspace> --offline` |
| 50 | |
| 51 | ### All Options |
| 52 | |
| 53 | - `--offline`: do not attempt network verification; write `verification_status=offline_generated` |
| 54 | - `--verify-only`: verify existing `citations/verified.jsonl` records (does not rewrite BibTeX) |
| 55 | - `--verification-note <text>`: stored in `citations/verified.jsonl` `notes` |
| 56 | |
| 57 | ### Examples |
| 58 | |
| 59 | - Generate BibTeX + offline verification records: |
| 60 | - `uv run python .codex/skills/citation-verifier/scripts/run.py --workspace <workspace> --offline --verification-note "auto-generated; needs manual verification"` |
| 61 | - Later, verify-only (when network is available): |
| 62 | - `uv run python .codex/skills/citation-verifier/scripts/run.py --workspace <workspace> --verify-only` |
| 63 | |
| 64 | ### Notes |
| 65 | |
| 66 | - Minimal requirement for every verification record: `url`, `date`, `title`. |
| 67 | - The script sanitizes stray/unbalanced `{}` in titles to keep `bibtex` parsing robust. |
| 68 | - The script escapes LaTeX special chars in text fields (`& % $ # _`) and rewrites superscript patterns like `X^N` or `X$^N$` as `X\textsuperscript{N}` to keep LaTeX builds stable. |
| 69 | - URLs are kept raw in BibTeX `url` fields (BibTeX styles wrap them with `\url{...}`); `@misc` uses `howpublished=\url{...}`. |
| 70 | - In offline mode, records are *not* truly verified; treat `offline_generated` as a to-do for human/network verification. |
| 71 | |
| 72 | ## Troubleshooting |
| 73 | |
| 74 | ### Common Issues |
| 75 | |
| 76 | #### Issue: Missing `bibkey` / missing `url` in notes |
| 77 | |
| 78 | **Symptom**: |
| 79 | - `citations/ref.bib` is missing entries, or `verified.jsonl` has empty `url/title`. |
| 80 | |
| 81 | **Causes**: |
| 82 | - `papers/paper_notes.jsonl` lacks `bibkey`/`url` fields. |
| 83 | |
| 84 | **Solutions**: |
| 85 | - Ensure each core paper note has a stable `bibkey` and a canonical `url`. |
| 86 | - Rerun citation generation after fixing notes. |
| 87 | |
| 88 | #### Issue: `verification_status=offline_generated` |
| 89 | |
| 90 | **Symptom**: |
| 91 | - Records exist but are not truly verified. |
| 92 | |
| 93 | **Causes**: |
| 94 | - `--offline` was used, or network verification was unavailable. |
| 95 | |
| 96 | **Solutions**: |
| 97 | - When network is available, run `--verify-only` to upgrade records. |
| 98 | - Or manually verify and update `citations/verified.jsonl` with notes. |
| 99 | |
| 100 | ### Recovery Checklist |
| 101 | |
| 102 | - [ ] Every BibTeX entry has a matching `citations/verified.jsonl` record. |
| 103 | - [ ] Verification records include `url`, `date`, `title`. |