Metadata-Version: 2.4
Name: zorsch
Version: 0.2.3
Summary: A research copilot CLI (zr) built on a local Zotero library.
Author: wheatfox
License-Expression: MIT
Project-URL: Homepage, https://github.com/enkerewpo/zoresearch
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer>=0.12
Requires-Dist: rich>=13.7
Requires-Dist: httpx>=0.27
Requires-Dist: pymupdf>=1.24
Requires-Dist: pymupdf4llm>=0.0.17
Requires-Dist: platformdirs>=4.2
Provides-Extra: mineru
Requires-Dist: mineru-open-api>=0.1; extra == "mineru"
Provides-Extra: embed
Requires-Dist: sentence-transformers>=3.0; extra == "embed"
Requires-Dist: numpy>=1.26; extra == "embed"
Provides-Extra: web
Requires-Dist: starlette>=0.37; extra == "web"
Requires-Dist: uvicorn>=0.30; extra == "web"
Requires-Dist: markdown-it-py>=3.0; extra == "web"
Requires-Dist: mdit-py-plugins>=0.4; extra == "web"
Dynamic: license-file

<p align="center">
  <img src="https://raw.githubusercontent.com/enkerewpo/zoresearch/main/assets/banner.svg" alt="zorsch: a research copilot for your Zotero library"/>
</p>

<p align="center">
  <a href="https://pypi.org/project/zorsch/"><img src="https://raw.githubusercontent.com/enkerewpo/zoresearch/main/assets/badges/pypi.svg" height="28" alt="PyPI version"/></a>
  <a href="https://pypi.org/project/zorsch/"><img src="https://raw.githubusercontent.com/enkerewpo/zoresearch/main/assets/badges/python.svg" height="28" alt="Python versions"/></a>
  <a href="https://www.zotero.org/"><img src="https://raw.githubusercontent.com/enkerewpo/zoresearch/main/assets/badges/zotero.svg" height="28" alt="Works with Zotero"/></a>
  <a href="https://github.com/enkerewpo/zoresearch/blob/main/LICENSE"><img src="https://raw.githubusercontent.com/enkerewpo/zoresearch/main/assets/badges/license.svg" height="28" alt="License: MIT"/></a>
</p>

A small research copilot built on top of a local Zotero library. It browses what you already have, finds the related work you don't, keeps workspaces around a research question, and keeps durable per-paper notes.

Zotero stays the source of truth — `zotero.sqlite` is read-only from this tool's perspective, and any new items are pushed in through Zotero's own connector API. Nothing in `~/Zotero/` gets rewritten by hand.

## What it does

The `zr` CLI is the load-bearing layer; the skills under `.agents/skills/` are thin orchestration on top, so the same workflows run by hand or driven by any coding agent (Codex, Claude Code, and others that read `AGENTS.md` and `SKILL.md`).

- **Browse & search** your existing library by topic, author, year, or collection.
- **Parse PDFs** into multimodal Markdown transcripts (figures + tables preserved) that an LLM can actually reason over — MinerU as the default engine, `pymupdf4llm` as the zero-config fallback.
- **Find related work** via a citation graph (OpenAlex) for a seed paper or a whole workspace, deduplicated against your library, and **import** the missing items back into Zotero.
- **Analyse trends & gaps** for a topic, grounded in your own library plus OpenAlex.
- **Keep per-paper notes** that survive across sessions.
- **Read in the browser** — `zr web` serves your workspaces as a clean reader with KaTeX math, syntax highlighting, and clickable citation links, and renders any `format: slides` document as a self-contained 16:9 slide deck (print-to-PDF ready).

## Install

**1. Prerequisites.** Python 3.11 or newer, and the Zotero desktop app. Keep Zotero running whenever you import, because new items go in through its connector API. The [Better BibTeX](https://retorque.re/zotero-better-bibtex/) plugin is recommended for stable citekeys.

**2. Install the package.** It installs the `zr` command.

```bash
pip install zorsch                 # core CLI
pip install "zorsch[web]"          # + browser reader / slides  (zr web)
pip install "zorsch[mineru]"       # + MinerU PDF engine        (zr parse)
pip install "zorsch[embed]"        # + local embeddings         (optional)
```

To keep it out of your project environments, install it as a tool instead: `uv tool install "zorsch[web]"` or `pipx install "zorsch[web]"`.

**3. Check the setup.**

```bash
zr doctor
```

It finds your Zotero data directory (`~/Zotero` by default, or `ZORESEARCH_ZOTERO_DIR`), checks that Zotero and Better BibTeX respond, and shows where zorsch keeps its own files.

**4. Optional: MinerU for PDF parsing.** `zr parse` uses MinerU when a token is configured and falls back to `pymupdf4llm` otherwise. Put the token in `~/.zoresearch/config.toml` or the `MINERU_TOKEN` environment variable:

```toml
[mineru]
token = "..."
```

**Where files go.** Transcripts, notes and workspaces live in the per-user data directory (on macOS `~/Library/Application Support/zorsch`). Set `ZORESEARCH_HOME` to put them elsewhere. From a source checkout (`git clone` then `pip install -e .`) they stay inside the repository.

**Upgrade** with `pip install -U zorsch`.

## Quick start

```bash
zr doctor                    # check Zotero / BBT / MinerU wiring
zr lib stats                 # library overview
zr lib search "embodied"     # keyword search across title/abstract/tags
zr show <key|citekey>        # metadata + abstract + attachment + notes

zr ws init paper -q "How do VLAs handle mid-execution task switching?"
zr ws add paper 2506.03574   # plant a seed (Zotero key / DOI / arXiv id / url)
zr ws related paper          # rebuild related.md from all seeds
zr ws parse paper --yes      # parse ONLY this workspace's seeds (preview without --yes)

zr web                       # read everything in the browser at 127.0.0.1:8765
```

Open the directory with a coding agent: it reads `AGENTS.md` and the skills under `.agents/skills/`. Describe a research question in natural language and the agent drives the CLI for you. Claude Code finds the same skills through the `.claude/skills` link.

## Command reference

| Command | Purpose |
|---|---|
| `zr doctor` | environment checks (Zotero DB, BBT, MinerU token) |
| `zr lib stats` | library overview |
| `zr lib search <q> [--type ...]` | keyword search across title / abstract / tags |
| `zr lib list --collection <name>` | items in a collection |
| `zr lib collections` | list collections |
| `zr show <key\|citekey>` | metadata + abstract + attachment + notes |
| `zr parse <key> [--engine mineru\|pymupdf]` | PDF → `data/transcripts/<key>/paper.md` |
| `zr annotations <key>` | your highlights & notes from the PDF |
| `zr related <key>` | backward refs + forward citations, deduped vs library |
| `zr trends "<topic>"` | OpenAlex pull (years, venues, top-cited) |
| `zr import <doi\|arxiv\|url\|file.ris>` | add to Zotero via the connector; a `.ris` file adds hand-written records with their local PDFs (`L1`) |
| `zr notes <key> [--append "..."]` | durable per-paper notes |
| `zr ws init <name> [-q "..."]` | create a workspace for a question |
| `zr ws add <name> <seed>` | add a seed paper (Zotero key / DOI / arXiv / url) |
| `zr ws list` / `zr ws show <name>` | list / inspect workspaces |
| `zr ws related <name> [-n N]` | rebuild `related.md` from all seeds |
| `zr ws parse <name> [--yes]` | parse only this workspace's seeds (preview by default) |
| `zr web [--port P] [--host H] [--no-open]` | browser reader + slide decks |

Set `ZORESEARCH_PLAIN=1` for output without colours.

## Reading in the browser

```bash
zr web              # serves http://127.0.0.1:8765
```

The reader renders every Markdown file under `workspace/` with KaTeX math, highlighted code, and citation links that resolve back to Zotero / arXiv. A document whose front-matter sets `format: slides` is rendered as a presentation instead:

```markdown
---
format: slides
title: My talk
---
# Title slide

---
## A content slide
- bullets, math $E=mc^2$, images, `<video>` all work

left column
:::
right column
```

- `---` on its own line separates slides; `:::` splits a slide into columns.
- Decks are letterboxed to a fixed **16:9** stage, so they look identical on any screen.
- `F` toggles fullscreen, `← / →` / `Space` navigate, `⌘P` prints the deck straight to a 1280×720 PDF.
- A theme toggle (light / dark) sits in the corner and is remembered across reloads.

## Layout

```
zoresearch/
  src/zoresearch/        # python package — the CLI and web reader live here
  .agents/skills/        # agent skills (one SKILL.md per skill); .claude/skills links here
  data/                  # local cache (gitignored, rebuildable)
    transcripts/<key>/   # parsed PDFs as markdown + extracted images
    citations/           # OpenAlex response cache
    notes/<key>.md       # per-paper notes the agent appends to
  workspace/             # research projects (gitignored)
    <project>/
      question.md        # your framing of the question
      seeds.txt          # Zotero keys / DOIs / arXiv ids to start from
      related.md         # discovered work
      notes.md           # synthesis
```

See [DEVELOPMENT.md](DEVELOPMENT.md) for the module map, data flow, and how to add a command or a skill.

## Notes

- Developed and tested on macOS.
- The MinerU token lives at `~/.zoresearch/config.toml` (mode `600`, outside the repo).
- The citation graph uses OpenAlex — no API key required.
- This tool **never** writes to `~/Zotero/zotero.sqlite`; imports go through the connector API, which is why Zotero has to be running.
- `data/` and `workspace/` are rebuildable / personal and are gitignored.

## License

MIT.

---

zorsch is an independent project and is not affiliated with or endorsed by the Corporation for Digital Scholarship. Zotero is a registered trademark of the Corporation for Digital Scholarship.
