Metadata-Version: 2.4
Name: repo-steward
Version: 0.2.1
Summary: An AI maintainer that runs your repository: you talk to it in your own console on your phone, it works your plans one pull request at a time, Claude builds, Codex reviews, CI decides
Keywords: ai-agents,claude-code,codex,maintainer,a2ui,pwa,github,kanso,automation
Author: Dr. Franke Datenwissenschaften OÜ
License-Expression: MIT
License-File: LICENSE
License-File: src/repo_steward/skills/LICENSE-caveman
License-File: src/repo_steward/skills/LICENSE-ponytail
License-File: src/repo_steward/skills/LICENSE-superpowers
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: No Input/Output (Daemon)
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Dist: a2ui-core==0.8.0
Requires-Dist: authlib>=1.9,<2
Requires-Dist: httpx2>=2.17,<3
Requires-Dist: cachetools>=6,<9
Requires-Dist: claude-agent-sdk>=0.2.175,<0.3
Requires-Dist: cryptography>=46,<52
Requires-Dist: httpx>=0.28,<1.0
Requires-Dist: itsdangerous>=2.2,<3
Requires-Dist: kanso-runner>=0.1.0,<0.2
Requires-Dist: loguru>=0.7,<1.0
Requires-Dist: ops-gate>=0.1.0,<0.2
Requires-Dist: pydantic>=2.10,<3.0
Requires-Dist: pywebpush>=2.5,<3
Requires-Dist: pyyaml>=6.0,<7.0
Requires-Dist: requests>=2.32,<3
Requires-Dist: sentry-sdk>=2.20,<3.0
Requires-Dist: sse-starlette>=3.7,<4
Requires-Dist: starlette>=1.10,<2
Requires-Dist: tenacity>=9,<10
Requires-Dist: typer>=0.15,<1.0
Requires-Dist: uvicorn>=0.55,<1
Requires-Python: >=3.12, <4.0
Project-URL: Repository, https://github.com/datenwissenschaften/repo-steward
Project-URL: Used by, https://github.com/datenwissenschaften/retro-speedlab-suite
Description-Content-Type: text/markdown

# repo-steward

![Two AI maintainers at a workbench: one tends the branches, the other reviews and gives a thumbs up, and the CI light is green](https://raw.githubusercontent.com/datenwissenschaften/repo-steward/main/assets/banner.webp)

[![CI](https://github.com/datenwissenschaften/repo-steward/actions/workflows/ci.yml/badge.svg)](https://github.com/datenwissenschaften/repo-steward/actions/workflows/ci.yml) [![Docs](https://github.com/datenwissenschaften/repo-steward/actions/workflows/docs.yml/badge.svg)](https://docs.datenwissenschaften.com/repo-steward/) [![PyPI](https://img.shields.io/pypi/v/repo-steward.svg)](https://pypi.org/project/repo-steward/) ![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

**An AI maintainer that runs your repository, and you talk to it in your own console, installed on your phone.** You ask, it opens a pull request; it works your plans one pull request at a time, Claude Code builds, Codex reviews, and CI decides what merges.

- **Your console, your phone.** The steward serves its own web console on your domain. Install it as an app from the browser, sign in with your Discord account, and every request, answer, approval and alert is one card. A push reaches your phone when a request is answered, an approval waits or something fails.
- **You steer in one tap.** Each request gets its own thread and a card with *Work on it*, *Done, check again* and *Dismiss*. A reply in the thread continues the work.
- **Your plans move while you sleep.** Between requests it takes the next open step of your [Kanso](https://github.com/datenwissenschaften/kanso) implementation plans, one session and one pull request per step, through [`kanso-runner`](https://pypi.org/project/kanso-runner/).
- **Nothing merges on one model's word.** Claude Code writes every change, Bugsink fixes included, and Codex reviews the exact commit against a JSON verdict schema. A rejected commit is dropped, and its reason goes back to the next session.
- **CI decides.** It squash-merges only a green pull request whose head commit was approved. A red one is closed, and its failed steps' logs feed the retry. Pull requests that touch your owner paths, such as `.github/` or `deploy/`, wait for your merge.
- **It respects your limits.** A Claude or Codex usage limit pauses the sessions until the reset. Quiet windows hold merges and plan sessions while other jobs run.
- **Your other services use the same console.** A small API lets any service put a card in front of you and take your answer back, such as an article to publish or a video to post.
- **Optional:** [Bugsink](https://www.bugsink.com) alerts become cards it fixes, and server repairs run through [`ops-gate`](https://pypi.org/project/ops-gate/): read verbs at once, destructive ones only after you approve them on your backend.

The [documentation](https://docs.datenwissenschaften.com/repo-steward/) covers getting started, the maintainer loop, the console, the producer API and every configuration key.

## Used in production by RetroSpeedLab

[RetroSpeedLab](https://www.retrospeedlab.com) is a game studio run by AI agents ([suite](https://github.com/datenwissenschaften/retro-speedlab-suite)). Its maintainer is repo-steward: it keeps the search, the stream, the website and the lakehouse running, fixes Bugsink alerts and works the suite's plans, and its console runs at `steward.retrospeedlab.com`. Its real configuration is the worked example here: [`steward.yaml`](examples/retrospeedlab/steward.yaml) and the product brief [`brief.md`](examples/retrospeedlab/brief.md).

```text
owner    → console: "The HUD clock is too small on the stream"
steward  → a new card: 🔧 Working on it
Claude   → commits the fix with a test on maintainer/2026-12-03T0910
steward  → runs every check of AGENTS.md again, as the agent user
Codex    → APPROVE: "the clock scales with the overlay and the test covers it"
steward  → 🔀 Opened …/pull/412, a push to the phone; once CI is green: 🔀 Merged
```

## How it works

```text
console ─┐                        ┌─ Claude Code session as the agent user, with the shipped and your own skills
Bugsink ─┼─▶ inbox ─▶ one queue ─┤        │ commit + report
plans   ─┘     │                  │        ▼
               │                  └─ checks from your rules file ─▶ Codex's review ─▶ pull request
               └─ every 2 minutes: CI green + approved head + no owner path + no quiet window ─▶ squash merge
```

- `repo-steward inbox` is the long-running process: the console on port 8000, alerts, plans, cards and merges. Put it behind a reverse proxy that terminates TLS on the console's domain.
- `repo-steward run` is one scheduled session on the most important work, for a cron.
- `repo-steward ask --message "…"` is one session on a request.

Sessions run as a separate `agent` user through the [`deploy/sandbox`](deploy/sandbox) wrappers, so the agent never sees the steward's tokens; the steward pushes the reviewed commit itself. The agent's git trusts only the steward's bare mirror it clones from. [`deploy/Dockerfile`](deploy/Dockerfile) builds that image, the console included.

## The console

The console is an installable web app (a manifest and a service worker) that the steward serves itself. Every screen is described as [A2UI](https://a2ui.org) messages, protocol **v1.0** with its basic catalog: the new-request form, the plans, a card per thread, the thread view with its notes and reply field, and the approval buttons. The steward builds them with [`a2ui-core`](https://pypi.org/project/a2ui-core/) 0.8.0 and streams them over Server-Sent Events, and the page renders them with the official Lit renderer, `@a2ui/lit` and `@a2ui/web_core` 0.17.0. The owner's button presses go back as A2UI `action` messages. The package's look is neutral; a `theme` in the config sets your colours.

| Route | Purpose |
| --- | --- |
| `GET /login`, `GET /auth/discord` | Discord OAuth2 sign-in, authorization code with PKCE and the `identify` scope |
| `GET /`, `GET /session` | the page, and the session's CSRF token and VAPID public key |
| `GET /stream`, `GET /stream/{thread}` | the A2UI stream of the board or one thread |
| `POST /actions` | the owner's A2UI actions |
| `POST /decisions` | the decision the backend sends the owner back with |
| `POST /push`, `POST /logout` | a Web Push subscription, and signing out |

## Security model

- **Only the owner signs in.** Discord only proves who the person is: the steward compares the Discord user id with `console.owner` and answers everyone else with 403. The session is the steward's own signed cookie, `Secure`, `HttpOnly` and `SameSite=Strict`; every action needs the session's CSRF token and the console's own `Origin`. A strict Content-Security-Policy lets the page run only its own bundled script.
- **The steward never holds the approver's key.** A destructive ops step runs only with a signature from `ops_gate.approval.sign_run`, and that key lives on your backend, never in the steward's process or container. The console's *Approve* opens the backend's own decision page, which signs in the owner itself with Discord, checks the user id against Discord's API and only then signs. So the agent's harness cannot approve its own commands, even if it took over the steward.
- **The agent never sees a secret.** Sessions, checks and reviews run as the `agent` user, and the text the console shows or pushes is redacted.

## Configure

One YAML file, passed with `--config` or `REPO_STEWARD_CONFIG` and validated once at start. Unknown keys and missing values stop the steward. `${NAME}` reads an environment variable, so private ids stay in your vault:

```yaml
repository:
  name: your-org/your-repo
  owner: your-github-login          # its open issues with the label become instructions
  issue_label: maintainer
  branch_prefix: maintainer/
  owner_paths: [.github/, deploy/, AGENTS.md]
  rules: AGENTS.md                  # its "## Checks" section lists the commands every commit must pass
  brief: docs/steward-brief.md      # what the product is and what matters most, in your words
  skills: null                      # or a folder of your product's own skills
git: {name: Your steward, email: steward@your-domain.example}
sessions: {model: opus, summary_model: haiku, minutes: 90, poll_seconds: 30, readable: []}
quiet: {starts: ["01:35"], minutes: 45}
backend: {url: https://api.your-domain.example, record_runs: false}
plans: {hold_url: null}
console:
  url: https://steward.your-domain.example   # the console's public URL, also the OAuth redirect's origin
  owner: "${DISCORD_OWNER_ID}"               # the only Discord user who may sign in
  theme: null                                # or {scheme: dark, accent, on_accent, background, surface, text}
bugsink: null                       # or {url, team, server_projects}
ops: null                           # or {table: deploy/ops/verbs.toml}
```

Secrets come from the environment:

| Variable | Purpose |
| --- | --- |
| `GITHUB_TOKEN`, `BACKEND_API_KEY`, `CLAUDE_CODE_OAUTH_TOKEN` | GitHub, your backend and Claude Code |
| `DISCORD_CLIENT_ID`, `DISCORD_CLIENT_SECRET` | the Discord OAuth2 application for sign-in, redirect `{console.url}/auth/discord`; no bot |
| `CONSOLE_SESSION_SECRET` | signs the session cookies |
| `VAPID_PRIVATE_KEY` | Web Push, the raw private key as `npx web-push generate-vapid-keys` prints it |
| `CONSOLE_API_KEY` | the key other services send to the producer API |
| `BUGSINK_API_TOKEN` | with Bugsink; `BUGSINK_DSN` reports the steward's own errors |

Codex signs in once inside the container for the reviews with `codex-as-agent login --device-auth`.

**Backend.** The backend holds the approver's signing key, so the steward needs a small one you host. Each call from the steward carries `X-API-Key: $BACKEND_API_KEY`:

| Call | Purpose |
| --- | --- |
| `POST /maintainer/ops-proposals` | a destructive step a session proposes: `{id, host, words}` |
| `GET /maintainer/decisions/{component}` | opened by the owner's browser, not the steward: `approve_<id>`, `deny_<id>` or `enable_<commit>`. The backend shows the step from its own record, signs the owner in with Discord (code and PKCE, `identify`), checks the user id, signs or records the decision, and redirects to `{console.url}/?decided=<component>` |
| `GET /maintainer/ops-proposals/{id}/approval` | the signature of an approved step, `{expiry, nonce, signature}` from `ops_gate.approval.sign_run` |
| `PUT /maintainer/runs/{name}` | run statistics, only with `record_runs: true` |
| `GET <hold_url>` answering `{"paused": true}` | an optional switch that holds plan sessions back |

RetroSpeedLab's backend implements it in its suite, in `src/retrospeedlab/backend/maintainer`.

**Producer API.** Other services put cards into the console and take the owner's answers back, with `Authorization: Bearer $CONSOLE_API_KEY`:

| Call | Purpose |
| --- | --- |
| `PUT /api/cards/{card}` | `{title, notify, components, data}`: A2UI v1.0 basic-catalog components with a `root`, ids as identifiers; `notify` pushes it to the phone |
| `DELETE /api/cards/{card}` | takes the card away |
| `GET /api/actions?wait=20` | long-polls the owner's actions on your cards: `[{id, card, action}]` |
| `DELETE /api/actions/{id}` | marks an action as handled |

**Upgrading from 0.1.** The Discord inbox is gone: remove `discord:` and `DISCORD_BOT_TOKEN`, add `console:` and the secrets above. The steward starts with a fresh `inbox.json`; the old `sessions.json`, `cards.json` and `board.json` are no longer read.

## Claude Code plugin

The steward's generic skills (fix-a-bug, ci-triage, focused-tdd, systematic-debugging, ponytail-review, ops, owner-request and more) also work in your own Claude Code sessions:

```text
/plugin install repo-steward --marketplace datenwissenschaften/repo-steward
```

Vendored skills keep their licences: [superpowers](src/repo_steward/skills/LICENSE-superpowers) (MIT, Jesse Vincent), [ponytail](src/repo_steward/skills/LICENSE-ponytail) (MIT, DietrichGebert) and [caveman](src/repo_steward/skills/LICENSE-caveman) (Apache-2.0).

## Development

```bash
uv sync && uv run ruff check && uv run mypy && uv run pytest
npm --prefix web ci && npm --prefix web run lint && npm --prefix web test && npm --prefix web run build
```

The acceptance scenarios in [`tests/features`](tests/features) describe the configuration, the console and the merge gate in plain language. `npm --prefix web run build` puts the console into the package, which the wheel and the image carry.

MIT © Dr. Franke Datenwissenschaften OÜ. Built by [Dr. Franke Datenwissenschaften](https://www.datenwissenschaften.com): AI agents and data platforms that run in production.
