<div align="center">

<img src="docs/assets/logo.svg" width="120" alt="PaperLab logo">

# PaperLab

**An Overleaf-style paper revision workbench, powered by a DeepSeek Harness plugin.**

[中文](README.md) · [Quick Start](docs/快速开始.md) · [Architecture](docs/architecture.md) · [Contributing](CONTRIBUTING.md)

[![license](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE)
[![npm](https://img.shields.io/npm/v/dsh-paperlab?style=flat-square)](https://www.npmjs.com/package/dsh-paperlab)
[![dsh-plugin](https://img.shields.io/badge/dsh--plugin-%E2%9C%93-4D6BFE?style=flat-square)](https://github.com/topics/dsh-plugin)
[![stars](https://img.shields.io/github/stars/maple-pwn/paperlab?style=flat-square)](https://github.com/maple-pwn/paperlab)

</div>

Edit LaTeX and see the real rendered PDF in one place. Select any text to annotate, then let a DeepSeek Harness agent revise the paper annotation by annotation — with compile verification, git commits, diffs, rollback, and export.

<img src="docs/assets/screenshot.png" alt="PaperLab UI screenshot" width="100%">

## ✨ Features

| 🖥 UI | 📄 Annotation | 🤖 AI revision |
|---|---|---|
| Overleaf-style three panes, draggable | Select **any text** in the PDF to comment | dsh agent: read annotations → uniquely-matched edits → compile check → git commit |
| Source edits **auto-save and auto-compile** | Yellow highlights pinned by page coordinates | **Wide-screen trace** streams reasoning / tool calls / output with timer and LIVE badge |
| True PDF rendering (formulas, figures, layout) | "Locate" shows the **pre-revision text** in a red popup | Switch model / **reasoning effort** / agent preset in the workbench |

| 📜 Versioning | 📦 Engineering |
|---|---|
| Every project is a git repo with AI checkpoints | One-click export: sources (+ annotations) / PDF / git history |
| History browser, arbitrary diffs, one-click revert | Auto XeLaTeX detection, respects latexmkrc, multi-engine fallback chain |

## 🔄 Workflow

<img src="docs/assets/workflow.svg" alt="PaperLab workflow" width="100%">

## 🏗 Architecture

The AI engine runs entirely inside DeepSeek Harness; the workbench never calls model APIs directly.

| Part | Stack | Responsibility |
|------|-------|----------------|
| `web/` | React + Vite + PDF.js | three-pane UI, PDF text selection, trace view, history/export |
| `server/` | FastAPI | project management, LaTeX compile, annotations, git history, static hosting |
| `plugin/` | DeepSeek Harness bundle (TypeScript) | paper-revision tools + HTTP trigger + model/preset settings proxy |

See [docs/architecture.md](docs/architecture.md).

## 🚀 Quick Start

Prerequisites: Node.js ≥ 20, pnpm ≥ 10, Python ≥ 3.11, git, DeepSeek Harness (`dsh`). LaTeX is optional.

```bash
git clone https://github.com/maple-pwn/paperlab.git
cd paperlab
./start.sh                # or make start
```

Open **http://127.0.0.1:8210**.

> 🔑 **Credentials belong to dsh**: configure them on the Models page of the dsh Web UI (http://127.0.0.1:3080). PaperLab never touches your API keys.

## 📦 Installing the plugin

The repository root is an official-format dsh bundle (`dsh.bundle` + `cordis.patch.yml` + prebuilt `lib/`):

```bash
dsh plugin --profile paperlab add dsh-paperlab                     # npm
dsh plugin --profile paperlab add github:maple-pwn/paperlab        # GitHub
dsh plugin --profile paperlab add .                                # local development
```

> ⚠️ Installing a plugin runs third-party code with your permissions. Review the source and try it without your credentials first.

## 🧪 Tests

```bash
make test
```

## 📄 License

[MIT](LICENSE) © 2026 PaperLab contributors

## 🔗 Community

- Join the [DeepSeek Harness plugin ecosystem](https://github.com/topics/dsh-plugin) (topic: `dsh-plugin`)
- Issues & ideas: [GitHub Issues](https://github.com/maple-pwn/paperlab/issues)
