Lem/Docs

A native home for authored papers and external literature.

Lem is a research-paper manager for macOS: it tracks authored manuscripts, keeps an independent library of papers being read, checks citations, audits text provenance, and generates figures — with one shared engine behind the app, CLI, backend, and MCP server.

What Lem owns#

Lem is the research-paper operations package. It keeps a registry of manuscripts being authored and a separate global library of external papers being read. Per-manuscript operations scrape venue-fit context, audit text provenance, check and harvest citations, and generate publication figures.

The canonical engine is the LemCore Swift library. The command-line interface, loopback backend, MCP server, and native macOS app all use the same manuscript and literature stores. The native interface lives separately in lem-desktop.

Executables and targets#

The Swift package Lem (macOS) declares these products:

  • LemCLI — the command-line interface; prints JSON to stdout.
  • LemMCP — a read-only stdio MCP server for agents and integrations.
  • LemBackend — a loopback HTTP server for the desktop app and integrations.
  • LemImportPapers — discovers and merges papers into the registry.
  • LemRefreshPaperContexts — refreshes per-paper full-text context into the context store.
  • LemAuditProvenance — runs the provenance audit and writes the report.
  • LemCore — the shared library all of the above depend on.

Build and run#

Build the whole package with swift build, or one product with swift build --target <name>.

Shell
swift build
swift run LemCLI papers    # authored manuscripts
swift run LemCLI library   # external literature

Services and credentials#

Model calls route through Brama, the LLM gateway, and --model selects a route alias. Credentials come from Skarbiec: for each spending invocation Lem signs an Ed25519 workload proof and redeems a one-time, thirty-second bearer — no code path in the package reads a credential from the process environment.

Lem resolves where Brama and Skarbiec run from the Stado service directory instead of hardcoding hosts or ports; a target with no entry is reported as exactly that, not defaulted past.

First use: bring your research#

The CLI walkthrough (`lem-cli onboarding`, or `--reset` to replay it) and Lem Desktop's first-run overlay both lead to the same LemCore importer. The importer accepts an unpacked LaTeX project directory, a UTF-8 BibTeX file whose every entry contains a title and an arXiv id in `eprint` or `url`, or one PDF accompanied by its arXiv id or URL.

A project is adopted in place and must contain a `.tex` document with `\\begin{document}` at the root or within two directory levels. BibTeX entries are resolved through arXiv into the literature library; the exact raw entries, source path, source digest, and keys remain attached as import provenance. A supplied PDF is copied to the literature asset store. ZIP, tar, gzip, bzip2, xz, zstd, 7z, and rar archives are refused explicitly.

Lem validates the complete selected input before committing a registry. Existing source identities remain unchanged, so replaying onboarding or importing the same input reports `unchanged` rather than adding a duplicate. A refusal leaves the prior registries and registered assets intact.

Shell
lem-cli import --project /path/to/unpacked-project
lem-cli import --bibtex /path/to/library.bib
lem-cli import --pdf /path/to/paper.pdf --arxiv 2404.02905