CLASSIFICATION: PUBLIC LICENCE: MIT DOC-ID: JGS-LIT-MEMORY REV 1.3.0

JGS Lit Memory

Capture the papers once. Query the corpus, not the internet, next time.

One skill and one script: paper records, citation edges, and analysis briefs in a git-tracked .lit corpus in your project.

Install How it runs
Install AI agent
You are installing jgs-lit-memory v1.3.0, an MIT agent skill pack by JG Systems Consulting Ltd: a local literature memory (paper records, citation edges, analysis briefs) in a git-tracked .lit corpus. Read the README and follow it. Do not invent steps.

Repository: https://github.com/jgsystemsconsulting/jgs-lit-memory

Do this in order.

1. Read README.md and docs/skill-usage.md. If the host is not ZCode, also read docs/other-agents.md.
2. Prerequisites: Python 3.9+ (stdlib only; no pip packages). Network access to api.openalex.org. An OpenAlex API key is optional.
3. Clone https://github.com/jgsystemsconsulting/jgs-lit-memory if you are not already in that clone. Run python install.py --dry-run and show the plan. Do not write files in this step.
4. Install for the host you detected.
    python install.py                  # ZCode → ~/.zcode/skills/lit-capture/
    python install.py --agent claude   # Claude Code → ~/.claude/skills/jgs/lit-capture/
    python install.py --agent cursor   # from the project that should receive the rule; writes .cursor/rules/lit-capture.mdc only
    --agent all installs user-global hosts only (zcode, claude, openclaw, copilot, codex, gemini). It does not install Cursor. Use it only if the user asked for every user-global host. Wrappers: install.sh, install.ps1. For Cursor, leave lit_fetch.py in this clone or in a native install. Do not copy it into .cursor/rules/.
5. Verify by host. Do not apply the other host's check.
    - Not Cursor: the installed folder contains SKILL.md and lit_fetch.py (1 skill, matches SKILLS.md).
    - Cursor: the repo contains .cursor/rules/lit-capture.mdc. The script is this clone's skills/lit-capture/lit_fetch.py, or a native install elsewhere. See docs/other-agents.md.
6. After each capture, drain the brief queue with --enrich-pending and write briefs through the script (--brief-write). See docs/skill-usage.md. Do not stop at capture.
7. Tell the user to fully restart the agent session so it rediscovers skills, then show this first-run example: "Capture this one: 10.1038/nature12373".

Note the MIT licence in LICENSE.

If a step fails (Python missing, wrong skill count on a non-Cursor install, install path refused, or a Cursor check that looks for lit_fetch.py inside .cursor/rules/), stop and report the exact failure and the README section that applies. Do not invent a layout.
Skill overview card for jgs-lit-memory: a git-tracked literature corpus of paper records, citations, and analysis briefs, with a QR code linking to the repository.
§01 · What it is

A corpus on your disk, not a subscription

Research conversations re-find the same papers every week. The corpus already answers two questions: "do we have it?", from one normalized JSON record per paper under papers/, and "who cites whom?", from the edges file graph/edges.jsonl. Neither layer records what the paper claims, how it was tested, its limits, or why the paper matters. The brief does. It is one analysis sidecar per paper under .lit/briefs/, drafted by the agent, validated and written by the script. Three layers in plain files, git-tracked, surviving every session: record, edges, brief. The next conversation asks the corpus before it asks the internet.

Papers and edges

papers/<W-id>.json, one record per work; graph/edges.jsonl carries who cites whom. Atomic writes: a crash never leaves a half-written file.

Offline inbox

Papers land in inbox.jsonl the moment they come up. No network needed. A triage run resolves the queue and reports what failed, with reasons.

Corpus answers first

A generated .lit/SKILL.md index carries counts and query recipes, so the agent checks the corpus before re-searching OpenAlex.

One paper end to end. Capture writes the record under papers/, adds citation edges to graph/edges.jsonl, and creates a pending stub at .lit/briefs/<W-id>.json. The agent drains the enrichment queue with --enrich-pending, drafts the brief, submits it through --brief-write, and verifies it with --brief-check. The script never calls an LLM; it stubs, lists, validates, and atomically writes.

§02 · The brief

One analysis sidecar per paper

First load of a paper creates .lit/briefs/<W-id>.json, a pending stub. The agent fills it by draining the enrichment queue, drafts the analysis, and submits it through --brief-write. The script never calls an LLM. It stubs, lists, validates, and atomically writes.

Brief anatomy. The script derives status and basis on every write; it never takes them from the payload.
Field groupWritten byRule
overview, claims (with in-paper supports / contradicts graph), methods, limits, why it mattersAgentDrafted by the agent, submitted through --brief-write.
status, basisScriptDerived on every write. Never taken from the payload.
humanYouMerge-only. A normal write keeps it. --human replaces it only when you dictated notes this turn.

Lifecycle. pending (empty agent block), then partial (some content, not yet ready), then ready (ready content present).

Write gate

--brief-write validates the payload and writes atomically, or rejects it with exit 1.

Check gate

--brief-check [W-id] validates one brief or all: schema, id vs filename, claim graph, derived fields. Exit 1 when invalid.

Id equals filename

--brief-check fails when a brief's id differs from its briefs/<stem>.json filename (1.2.1).

§03 · Corpus layout

Plain files, git-tracked

.lit/ lives in the project that produced it and is git-tracked there.

# the whole corpus, committed beside your code
.lit/
  papers/<W-id>.json      one normalized record per paper
  briefs/<W-id>.json      analysis sidecar per paper (agent-authored, script-validated)
  graph/edges.jsonl       {"source": citing W-id, "target": cited W-id}, one per line
  graph/aliases.json      {"alias W-id": "canonical W-id"} recorded on 301 merges
  findings/<YYYY>-<slug>.md  optional human notes
  inbox.jsonl             offline capture queue
  SKILL.md                generated corpus contract; never hand-edited

All writes are atomic (temp file plus os.replace). A crash mid-batch leaves completed records on disk and never a half-written file. Edges are a full-rewrite idempotent union, so the next successful run heals partial runs.

§04 · Verbs

One resolution verb per call

lit_fetch.py is the only component that touches the network, and it talks to OpenAlex only. Everything else is agent reading and writing. Singleton DOI and W-id lookups are free; budgeted calls warn without an API key.

Resolution verbs. Exit codes: 0 success or already present, 1 failure, 2 usage error.
InvocationBehavior
--doi <doi>Singleton capture by DOI (free). seed=true, source=capture.
--openalex <W-id>Singleton capture by W-id (free). Same write semantics.
--arxiv <id> --title <t>OpenAlex has no arXiv lookup; resolves through the verified title search. Bare --arxiv is a usage error.
--title <t> [--author] [--year]Budgeted search with client-side verification. Near-misses print as candidates and write nothing.
--ids "W1|W2|..."Batch fetch, 100 per call, skips existing records.
--inboxTriage the offline queue: dedupe, resolve, rewrite once. Failures stay queued with their reason.
--statusCorpus summary. Read-only.
--checkLive smoke test of the four endpoint forms.
--enrich-pendingList briefs awaiting enrichment: pending and partial as JSONL rows; unreadable files labeled invalid. Read-only.
--brief-status [W-id]Brief counts by status and basis; with an id, print that brief's JSON. Read-only.
--brief-check [W-id]Validate one brief or all (schema, id vs filename, claim graph, derived fields). Exit 1 when invalid.
--brief-write --id <W-id> --file <payload.json> [--human]Validate and atomically write a brief. Replaces the agent block, keeps human unless --human, derives status and basis.
--brief-restub --id <W-id>Reset the brief's agent shell and enrich stamps to pending. Keeps human.
--auditQuality gate: every paper has a ready brief with 3+ claims, open questions and a related-paper link, full-text basis when an open copy exists, no duplicate titles, empty inbox. Exit 1 on any FAIL.
--merge <W-old> --into <W-kept>Fold a duplicate version into the kept record: alias, repoint edges, merge briefs, delete the old record.

Limits. Abstracts come only from OpenAlex's inverted index and are null on roughly 40 to 55 percent of works. referenced_works is lossy relative to printed reference lists, so the graph is biased toward DOI-matchable citations. The corpus is for identity, graph, and retrieval, not full text. Budgeted calls (title searches, batches, inbox triage) warn and draw on a small keyless daily budget without an API key; singleton DOI and W-id lookups are free.

§05 · Agents

One pack, every main host

install.py already targets the main coding agents. Native folder copy for ZCode, Claude Code, OpenAI Codex, GitHub Copilot CLI, and OpenClaw. Gemini CLI as an extension. Cursor as project-local rules. Run python install.py --agent all for the user-global hosts, then --agent cursor in the repo that needs rules. Per-path table: docs/other-agents.md.

ZCode

Native folder. ~/.zcode/skills/<skill>/. --agent zcode

Claude Code

Native folder, namespaced. ~/.claude/skills/jgs/<skill>/. --agent claude

Cursor

Project-local .mdc rules. Run in the repo you want. --agent cursor

Gemini CLI

Extension under ~/.gemini/extensions/. --agent gemini

OpenAI Codex

Native folder. ~/.agents/skills/jgs/<skill>/. --agent codex

GitHub Copilot CLI

Native folder. ~/.copilot/skills/jgs/<skill>/. --agent copilot

§06 · How you ask

Conversational, not a slash command

The lit-capture skill triggers when a paper comes up with enough identity to fetch (DOI, arXiv id, OpenAlex W-id, or exact title plus author or year) and looks worth keeping. It scans the conversation, dedupes against the corpus, then captures offline or fetches now with your consent.

01

Capture by DOI

A paper with a DOI comes up and is worth keeping.

Runs: --doi

Capture this one: 10.1038/nature12373

02

arXiv by title

An arXiv paper. OpenAlex has no arXiv lookup, so the title carries the match.

Runs: --arxiv <id> --title <t>

Save that arXiv paper, 1706.03762, "Attention Is All You Need"

03

Corpus first

A question the corpus may already answer. No fetch unless you consent.

Runs: none; reads .lit/SKILL.md, papers/, graph/edges.jsonl

What do we have on citation graph bias? Check the corpus first.

04

Inbox triage

Papers queued offline in inbox.jsonl.

Runs: --inbox

Triage the inbox.

05

Drain briefs

Stubs waiting for analysis.

Runs: --enrich-pending, then --brief-write per paper

Fill in the pending briefs.

06

Check before citing

You are about to cite from briefs.

Runs: --brief-check

Check the briefs before I cite them.

Direct script use, after install (ZCode path shown; other hosts use their installed folder):

# status is read-only; try it first
python "$HOME/.zcode/skills/lit-capture/lit_fetch.py" --status
python "$HOME/.zcode/skills/lit-capture/lit_fetch.py" --doi 10.1038/nature12373
python "$HOME/.zcode/skills/lit-capture/lit_fetch.py" --inbox

Full invoke and first-run detail, limits, and corpus layout: docs/skill-usage.md. Skill index: SKILLS.md.

§07 · Why

Ask the corpus before the internet

Research conversations re-find the same papers every week. The corpus keeps them: stable identity, offline capture, plain files your git history already tracks.

Stable identity

One OpenAlex W-id per paper. 301 merges are recorded in graph/aliases.json.

Offline inbox

Capture needs no network. Triage resolves later and keeps failures queued with their reason.

Git-tracked provenance

.lit/ is plain files in your project history. Briefs record each claim's basis.

Portable across hosts

One pack installs into ZCode, Claude Code, Codex, Copilot CLI, OpenClaw, Gemini CLI, and Cursor.

CC0 metadata

OpenAlex metadata is CC0.

Questions and ideas go to GitHub Discussions.

§08 · Install

Clone, install, restart, capture

Prerequisites: Python 3.9+ (stdlib only), network access to api.openalex.org, an OpenAlex API key optional. Install into every user-global host, or pick one. Restart the agent session so it discovers the skill.

# Python 3.9+, stdlib only. OpenAlex over HTTPS.
git clone https://github.com/jgsystemsconsulting/jgs-lit-memory
cd jgs-lit-memory
python install.py --agent all     # ZCode, Claude Code, Codex, Copilot, OpenClaw, Gemini
python install.py --agent cursor  # project-local .cursor/rules
python install.py --dry-run
python install.py --list-agents

Prefer your agent to do it? The paste-ready "Install with your AI agent" prompt is in the README. In-host install also works: Claude Code /plugin marketplace add jgsystemsconsulting/jgs-lit-memory, Gemini gemini extensions install from the repo URL.