Metadata-Version: 2.4
Name: diffpilot
Version: 0.0.2
Summary: Project memory CLI for coding agents: requirements, rationale, instructions and changelog, powered by Codex
Author-email: Aleksei Marusich <aleksei.marusich@rocshers.com>
License: MIT
Project-URL: Homepage, https://projects.rocshers.com/open-source/diffpilot
Project-URL: Repository, https://gitlab.com/rocshers/python/diffpilot
Keywords: ai,development
Requires-Python: >=3.14
Description-Content-Type: text/markdown
Requires-Dist: filelock>=3.16.1
Requires-Dist: pydantic>=2.14.3
Requires-Dist: pydantic-ai-slim[openai,typesafe]>=2.68.0
Requires-Dist: rich>=15.0.0
Requires-Dist: typer>=0.29.1

# diffpilot - project memory for coding agents

[![PyPI](https://img.shields.io/pypi/v/diffpilot)](https://pypi.org/project/diffpilot/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/diffpilot)](https://pypi.org/project/diffpilot/)

[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=rocshers_diffpilot&metric=coverage)](https://sonarcloud.io/summary/new_code?id=rocshers_diffpilot)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rocshers_diffpilot&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rocshers_diffpilot)

[![Downloads](https://pypi.rocshers.com/badges/svg/packages/diffpilot/downloads/total)](https://clickpy.clickhouse.com/dashboard/diffpilot)
[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/diffpilot)](https://gitlab.com/rocshers/python/diffpilot)
[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/diffpilot)](https://gitlab.com/rocshers/python/diffpilot)

Project memory for coding agents. The agent says *what changed and why*; diffpilot (its own small agent on a Codex
subscription) finds where it belongs in the docs, edits surgically, logs the change and keeps the changelog — and
answers questions about requirements and past decisions with citations, without bossing the calling agent around.

## Features

- Three Markdown stores with stable section IDs: `docs/PRD.md` (current product vision), `docs/implementation.md`
  (how and why), `docs/instructions.md` (project rules), plus `docs/CHANGELOG.md`.
- Optional PRD categories: `[prd_categories] mobs = "..."` keeps the details of an area in `docs/prd/mobs.md`, while
  `PRD.md` holds the overview. An existing spec (a bestiary, a tower roster) is adopted in place, losslessly and
  without bootstrap extraction: `mobs = { scope = "...", path = "docs/mobs.md" }`. A spec written as one big nested
  bullet list is split into heading sections (one per top-level item with sub-items, recursively, while a section
  is over 2000 characters), so each creature gets its own section and ID.
- Optional [Jev](https://openrouter.ai/typesafe) (TypeSafe's decision model, via OpenRouter) reranks retrieval and
  routes input to stores: better context for fewer tokens. Falls back to BM25 without a key.
- `note` captures decisions instantly during work; `finish` integrates them (plus the git diff) at the end of the task.
- `record` writes immediately, routed to the right store(s); `prd` / `impl` / `instruct` force one. Edits are validated ops, never
  free-form rewrites; every write becomes a change event with before/after text and the reason.
- `ask` and `brief` answer from the stores (and code) with citations; records are presented as context, not orders.
- `init --bootstrap` seeds the stores from existing docs, with quote verification and safe, incremental re-runs.
- `git_diff_changelog_summary` turns git diff + recorded changes into one clean changelog entry.
- `AGENTS.md` gets a `## diffpilot` section (how to use the tool) and, via `update_agentsmd`, a `## diffpilot - resume`
  of project essentials that never repeats what the file already says.
- Free, instant lookups without an LLM: `outline`, `show`, `search`, `log`.

## Quick start

Requires a Codex login (`codex login`, ChatGPT subscription) — credentials are read from `$CODEX_HOME/auth.json`.

```bash
uvx diffpilot init --bootstrap      # global + project config, stores (seeded from existing docs), ## diffpilot in AGENTS.md
uvx diffpilot brief "Add 6 cards to the shop"
uvx diffpilot note "Shop shows 6 cards instead of 4; 2 slots are seasonal offers (user request)."   # instant
uvx diffpilot finish                # end of task: notes + git diff → docs, reviewed
uvx diffpilot ask "What are the shop requirements?"
uvx diffpilot git_diff_changelog_summary --write --version 1.2.0
uvx diffpilot update_agentsmd
```

Configuration: global `~/.diffpilot/diffpilot.toml` (auth — Codex home, OpenRouter key —, models, Jev; shared by all
projects) overridden key by key by the project's `diffpilot.toml` (paths, PRD categories, behavior).
The project root is the nearest directory with `diffpilot.toml`, but the search never crosses a repository boundary
(a `.git` directory or file), so a nested repo or submodule gets its own memory; `init` prints the root it uses.
Environment overrides: `DIFFPILOT_BACKEND`, `DIFFPILOT_MODEL`, `DIFFPILOT_FAST_MODEL`, `DIFFPILOT_REASONING`,
`DIFFPILOT_LOG_LEVEL`, `DIFFPILOT_HOME` (global config dir), `OPENROUTER_API_KEY`, `CODEX_HOME`.

Every command supports `--json`. Exit codes: 0 ok, 1 usage/config (also `doctor` with a FAIL check, `show` with a
missing or ambiguous ref, `finish` that kept notes it could not write), 2 Codex auth, 3 LLM unavailable, 4 invalid
model output (nothing written), 5 lock busy. On exit 3 the error says what was kept: `finish` keeps its notes (rerun
it), `record`/`prd`/`impl`/`instruct` keep their input for `diffpilot inbox --process`, other commands are simply
rerun. A Codex usage limit is reported in one line with the reset time and is not retried; with `backend = "auto"`
and an OpenRouter key, that run falls back to OpenRouter.

`finish` adds a CHANGELOG entry only when the task diff changed code (not for notes only, docs only or `--no-diff`).
`init --bootstrap` prints progress per batch, never reads `AGENTS.md`, and resumes after a failure without
re-extracting facts.

diffpilot documents itself: requirements, design rationale and project rules live in [docs/](docs/) and are
maintained with diffpilot.

## Contribute

Issue Tracker: <https://gitlab.com/rocshers/python/diffpilot/-/issues>  
Source Code: <https://gitlab.com/rocshers/python/diffpilot>
