Metadata-Version: 2.4
Name: rebuttalflow
Version: 0.3.1
Summary: Lightweight, local-first rebuttal workspace & MCP for Claude Code, Codex & Cursor — cross-session memory, live experiment metrics, citation recon, OpenReview preflight & offline advisor review.
License-Expression: MIT
Project-URL: Homepage, https://zhoujun-ye.github.io/RebuttalFlow/
Project-URL: Repository, https://github.com/Zhoujun-Ye/RebuttalFlow
Project-URL: Issues, https://github.com/Zhoujun-Ye/RebuttalFlow/issues
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic<3,>=2
Requires-Dist: typer<0.30,>=0.29
Requires-Dist: pyyaml>=6
Requires-Dist: filelock>=3.13
Requires-Dist: markdown-it-py<5,>=3
Requires-Dist: mdit-py-plugins<1,>=0.5
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: types-PyYAML; extra == "dev"
Dynamic: license-file

<div align="center">

# RebuttalFlow

**Lightweight, local-first rebuttal workspace & MCP for Claude Code, Codex, and Cursor.**<br>
Connect every reviewer question to live experiment results, exact posting limits, and offline advisor review — without losing context across sessions.

<p>
  <a href="https://zhoujun-ye.github.io/RebuttalFlow/"><strong>Project Page</strong></a> ·
  <a href="https://zhoujun-ye.github.io/RebuttalFlow/review-demo.html"><strong>Live Advisor Pack Demo</strong></a> ·
  <a href="#quickstart"><strong>Quickstart</strong></a> ·
  <a href="https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/cli-guide.md"><strong>CLI Guide</strong></a> ·
  <a href="https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/author-response-guide.md"><strong>Author Guide</strong></a> ·
  <a href="https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/README.zh-CN.md"><strong>中文</strong></a>
</p>

<p>
  <a href="https://pypi.org/project/rebuttalflow/"><img alt="RebuttalFlow on PyPI" src="https://img.shields.io/pypi/v/rebuttalflow?style=flat-square"></a>
  <img alt="Python 3.11+" src="https://img.shields.io/badge/Python-3.11%2B-24624f?style=flat-square">
  <img alt="MCP Native" src="https://img.shields.io/badge/MCP-10%20Tools-306c5c?style=flat-square">
  <img alt="Local First" src="https://img.shields.io/badge/Local--First-.rebuttal%2F-49534d?style=flat-square">
  <img alt="Zero Embedded LLM SDK" src="https://img.shields.io/badge/LLM%20SDK-None%20Required-5b6861?style=flat-square">
  <a href="https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/License-MIT-24624f?style=flat-square"></a>
</p>

</div>

## Quickstart

With [uv](https://docs.astral.sh/uv/getting-started/installation/) installed, run this in the directory containing your `reviews.md` (one heading per reviewer: `# R1`, `# R2`, …). No Git clone or API key is needed:

```sh
uvx rebuttalflow init reviews.md --client claude
```

For Codex or Cursor, replace `claude` with `codex` or `cursor`. This imports your reviews and sets up the MCP server and Skill for **this project only**. [Start your first response](#draft-your-first-response).

---

<p align="center">
  <a href="https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/assets/rebuttalflow-features.png">
    <img src="https://raw.githubusercontent.com/Zhoujun-Ye/RebuttalFlow/main/docs/assets/rebuttalflow-features.png" alt="RebuttalFlow end-to-end feature map: cross-session brief, question triage, live CSV metric sync, safe compression, three-pane review desk, and offline advisor annotations" width="100%">
  </a>
  <br>
  <sub>Full workflow from initial reviews to final local export · <a href="https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/assets/rebuttalflow-features.excalidraw">Editable Excalidraw source</a></sub>
</p>

## Why RebuttalFlow?

Strong coding agents rarely fabricate numbers out of thin air anymore. What actually breaks during a stressful 7-day conference rebuttal is **cross-session amnesia, shifting experiment tables, brutal character limits, and messy advisor handoffs**:

> When a late rerun drops from **78.4%** to **70.0%** — crossing below a **72.6%** baseline — updating the number is not enough. Two reviewer letters cite that experiment, and both conclusions now need a second look. RebuttalFlow refreshes every bound value and table together and flags the affected drafts for the author to revisit. *(See the [reproducible synthetic example](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/examples/lightweight_workspace_demo/README.md#replay-a-changed-experiment).)*

| Pain point during a 7-day rebuttal | Plain coding agent chat | Coding agent + **RebuttalFlow** |
| --- | --- | --- |
| **Multi-day / multi-window sessions** | Re-paste reviews and re-explain progress every morning | **`rebuttal brief`** restores open issues, stances, deadlines & char budgets in one call |
| **Missing papers cited by reviewers** | Manually hunt arXiv, check publication dates & GitHub repos | **`rebuttal recon`** extracts named papers, checks contemporaneous dates & public code |
| **Late reruns & new seeds** | Hunt and edit hardcoded numbers across Common, R1, and R3 | **`rebuttal metric sync`** updates `{{metric:...}}` / `{{table:...}}` everywhere & flags drift |
| **OpenReview character limits** | LLMs miscount chars or silently drop key baselines when shortening | **Full draft first + `compress-check`** verifies exact UTF-16 length & locked facts |
| **Advisor & co-author review** | Trade messy Word/WeChat notes and translate them back to the agent | **`rebuttal share`** exports a single offline HTML file; annotations import cleanly back to the agent |
| **Submission safety** | Spot-check `\cite{}`, broken tables, or identity leaks by eye | **`rebuttal check`** catches syntax bugs, anonymity leaks, missing answers & cross-reply drift |

---

## Core Features

### 1. Cross-Session Memory (`rebuttal brief`)
Open a fresh Claude Code, Codex, or Cursor session on Day 4 and restore the entire rebuttal state immediately — pending high-leverage issues, reviewer stances, remaining character budgets, synced metric alerts, and open advisor comments — without re-pasting yesterday's chat.

### 2. Citation Recon & Priority Map (`rebuttal recon` · `rebuttal map`)
- **Citation Recon**: Extracts papers mentioned in reviews and queries public metadata (arXiv / Semantic Scholar / GitHub, with `--offline` mode) to track abstracts, contemporaneous publication dates, and official code repositories under `.rebuttal/refs/`.
- **ROI Priority Map**: Groups overlapping reviewer concerns (`overlap_group`) and ranks work into four actionable buckets — *PDF-grounded clarifications*, *shared high-leverage experiments*, *citation comparisons*, and *scope boundaries* — so one experiment can answer multiple reviewers.

### 3. Live CSV / JSON Metric Binding (`rebuttal metric bind` · `sync`)
Bind local experiment outputs (`.csv` or `.json`) as live `MetricCard`s and embed `{{metric:M1.ours_acc:.2f}}` or `{{table:M1}}` in your response templates. Whenever a script finishes a new seed or baseline, `rebuttal metric sync` refreshes every linked reply automatically and flags claim-strength drift for human review.

### 4. Write Full, Compress Safely & Pre-Flight Check (`rebuttal check` · `review compress-check`)
- **Evidence-first drafting**: Inspect every reviewer's verbatim questions and linked evidence with `rebuttal review plan R1`, save the complete response first, and test shorter candidates via `review compress-check` without overwriting the full draft.
- **Deterministic pre-flight**: Verifies exact **UTF-16 OpenReview character counts** per posting form (`review check-message`), preserves `locked_spans`, catches leftover LaTeX macros (`\cite{}`, `\ref{}`, unbalanced `$`, broken Markdown tables), scans for **anonymity leaks** (emails, local paths, personal GitHub links, custom `forbidden_terms`), and checks coverage and cross-reply consistency.

### 5. Three-Pane Review Desk & Offline Advisor Pack (`rebuttal ui` · `share` · `feedback`)
- **Local Review Desk (`rebuttal ui`)**: A zero-Node, loopback-only three-pane workspace showing reviews + frozen submission PDF links on the left, live-rendered replies with metric hover cards and character budget bars in the middle, and passage-level feedback (plus optional local CLI agent suggestions) on the right.
- **Offline Advisor Pack (`rebuttal share`)**: Send your advisor [a single HTML file](https://zhoujun-ye.github.io/RebuttalFlow/review-demo.html). Both the pack and the local desk render inline and display math with bundled KaTeX, without a network connection. Your advisor can select an equation and comment on it; importing `advisor-comments.json` links the note back to the original TeX.

### 6. Blinded Red-Team & Multi-Round Discussion (`redteam` · `review add-followup` · `thread`)
- **Blinded Critique (`rebuttal redteam prepare`)**: Builds a strict whitelist critique packet containing only the frozen PDF reference, original review, and rendered reply — stripping internal notes and chat history to fight model sycophancy.
- **Multi-Round Discussions**: Append later reviewer questions without reinitializing (`rebuttal review add-followup R1 note.txt`) and inspect local authorized forum threads (`rebuttal review thread R1 forum.json`).
- **Local Export Only (`rebuttal export`)**: Exports clean per-reviewer `.md` files or a `one-page-tex` skeleton. No OpenReview write credentials, no accidental posting — **only the author submits**.

---

## Recorded Walkthrough

<p align="center">
  <img src="https://raw.githubusercontent.com/Zhoujun-Ye/RebuttalFlow/main/docs/assets/review-walkthrough.gif" alt="Recorded workflow: restore a brief, triage evidence, sync a table, check a draft and import advisor feedback" width="92%">
  <br>
  <sub>End-to-end local run: restore brief → triage & bind CSV → sync rerun drift → check & compress → import advisor feedback</sub>
</p>

---

## Draft Your First Response

To register a frozen submission, add `--pdf submission.pdf` to the [initialization command](#quickstart). No reviews handy? [Open the advisor demo](https://zhoujun-ye.github.io/RebuttalFlow/review-demo.html) or [run the synthetic walkthrough](https://github.com/Zhoujun-Ye/RebuttalFlow/tree/main/examples/lightweight_workspace_demo).

Then reopen your coding agent in that directory and paste:

```text
Read the reviews, split their questions and link my results. Show R1's response plan, then draft a numbered reply with the matched baseline and measured result for each empirical question. Save the full evidence draft first; only then shorten it to the posting limit. Do not submit.
```

**Everyday commands across the rebuttal week:**

Use `uvx rebuttalflow` in place of `rebuttal`, or install the persistent shortcut once with `uv tool install rebuttalflow`.

```sh
rebuttal brief                              # Day 2+: restore compact state in a new session
rebuttal recon run --offline                # Extract cited missing papers (drop --offline to query public metadata)
rebuttal map                                # View 4-bucket ROI priority map
rebuttal review plan R1                     # Inspect R1's verbatim questions & linked evidence
rebuttal metric sync                        # Refresh all bound drafts after an experiment rerun
rebuttal check                              # Exact char limit, syntax, anonymity, coverage & drift check
rebuttal share --out review-pack.html       # Export standalone offline HTML for advisor annotations
rebuttal feedback import advisor-notes.json # Bring advisor comments back for your agent
rebuttal review add-followup R1 note.txt    # Append round-2 reviewer questions without reinitializing
rebuttal export --format openreview         # Export clean local Markdown (or --format one-page-tex)
```

---

<details>
<summary><strong>Reference: CLI Commands, 10 MCP Tools &amp; <code>.rebuttal/</code> Layout</strong></summary>

### Top-Level CLI Commands
| Command | Purpose |
| --- | --- |
| `rebuttal init` | Initialize `.rebuttal/`, import reviews, register frozen PDF & optional `--client` MCP/Skill |
| `rebuttal setup` | Preview or write project-local MCP config & thin Skill (`codex` / `claude` / `cursor`) |
| `rebuttal brief` | Emit a compact cross-session status brief (`--json` or Markdown) |
| `rebuttal map` | Rank concerns across 4 ROI buckets (`pdf_refute`, `experiments`, `citation_clarify`, `boundaries`) |
| `rebuttal recon` | `run` / `list` / `add` missing paper metadata & public code lookups |
| `rebuttal metric` | `bind` / `sync` / `list` local CSV/JSON result cards & live table bindings |
| `rebuttal review` | `plan` / `add-followup` / `thread` / `check-message` / `compress-check` |
| `rebuttal check` | Deterministic pre-flight check (UTF-16 chars, locked spans, syntax, anonymity, coverage, drift) |
| `rebuttal ui` | Launch loopback three-pane review desk (`--enable-agent-bridge` for optional local CLI edits) |
| `rebuttal share` | Export offline advisor HTML pack (paired with `feedback import/list/resolve` & `redteam prepare/run`) |
| `rebuttal export` | Export checked local replies (`openreview` Markdown or `one-page-tex`) |

### 10 MCP Tools Exposed to Coding Agents
`rebuttal_brief` · `get_context` · `upsert_issues` · `get_battle_map` · `recon_references` · `bind_metric` · `sync_metrics` · `save_draft` · `check_preflight` · `manage_feedback`

### Local `.rebuttal/` Directory Structure
```text
.rebuttal/
├── config.yaml              # Venue limits, deadline, submission date, frozen_pdf_path, forbidden_terms
├── state/
│   ├── events.jsonl         # Append-only audit log (replayable via `rebuttal state rebuild`)
│   └── snapshot.json        # Atomic state projection
├── reviews/raw_snapshot.json # Immutable original reviews & follow-ups
├── refs/                    # Citation recon index & per-paper Markdown cards
├── metrics/                 # Bound CSV/JSON MetricCards & rendered tables
├── drafts/                  # Full templates (*.tmpl.md) & rendered outputs (*.rendered.md)
└── feedback/                # Advisor annotations & blinded red-team findings
```

</details>

## Safety & Design Boundaries

- **File-first & transparent**: All state lives in `.rebuttal/` as plain JSON, JSONL, YAML, and Markdown. Frozen submission PDFs and verbatim review quotes are treated as read-only untrusted data.
- **No lock-in**: Runs locally as a CLI and review desk even without an agent. Tune venue limits, deadlines, submission dates, and anonymity `forbidden_terms` in `.rebuttal/config.yaml`.
- **Privacy & control**: Online citation recon only sends reference titles/IDs to public APIs (use `--offline` anytime). Final replies are exported locally — RebuttalFlow never posts to OpenReview on your behalf.

## Documentation & Contributing

- [CLI Guide](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/cli-guide.md) · [Author Response Guide](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/author-response-guide.md) · [v0.3 Design Spec](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/design/lightweight-agent-exoskeleton-v0.3.md) · [All Docs](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/docs/README.md)
- Development & verification instructions live in [CONTRIBUTING.md](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/CONTRIBUTING.md) and [AGENTS.md](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/AGENTS.md).
- Released under the [MIT License](https://github.com/Zhoujun-Ye/RebuttalFlow/blob/main/LICENSE).
