Lem/Docs

Check, add, and harvest citations.

Two small per-paper commands keep a manuscript's bibliography honest, and a staged harvest turns a corpus of literature into one reading record per paper.

citation check#

The check expands the LaTeX document through \input and \include, collects keys from the \cite command family (and @key syntax in Markdown documents), and locates the bibliography from \addbibresource or \bibliography declarations — falling back to common names like references.bib. It reports missing keys, duplicate bibliography entries, and unused bibliography keys.

Shell
swift run LemCLI citation check <id-or-title> [--bib <path>] [--document <path>]

citation add#

citation add resolves one query per invocation through the adder script named by LEM_CITATION_ADDER_PATH — a thousand citations is a thousand invocations.

Shell
swift run LemCLI citation add <id-or-title> <query> [--bib <path>] [--document <path>]

citation-harvest#

The harvest is a reading record for a paper's literature corpus: one note per harvested paper, under the paper's own citations_harvest/ directory. Every stage is a separate invocation; the bare verb runs none of them — it reports what is on disk and names the next step.

  • discover builds or extends manifest.json from the paper's bibliography plus OpenAlex and Semantic Scholar, deduplicating on DOI, then normalized title, then key.
  • fetch populates pdfs/ and text/, preferring ar5iv HTML over a PDF parser, and writes the manifest back after every row so re-running resumes without re-downloading.
  • anchor binds the harvest to the manuscript and records its digest; on first anchor it writes the claim-spine skeleton, whose spine a human fills in.
  • plan deals every paper with extracted text into round-robin batches, and assignment <batch> prints the reader's fixed instructions verbatim.
  • read makes one model call per paper through Brama with a one-time Skarbiec bearer — acquired once per invocation, not once per paper — announces the call count, alias, and grant on stderr before spending anything, and persists state after every paper. --dry-run prints the exact prompt one paper would receive and stops, acquiring no credential.
  • verify checks the corpus against the manuscript it claims to have been read for, reporting the cause before the damage.
Shell
swift run LemCLI citation-harvest <id-or-title> [discover|fetch|anchor|plan|assignment <batch>|read|verify]