From ebb8e390fbbffe6e2065a686087e32fd85d908e9 Mon Sep 17 00:00:00 2001
From: Duarte Santos
Date: Tue, 18 Aug 2026 23:25:28 +0200
Subject: [PATCH] Docs: den Coach dort beschreiben, wo Leute ihn suchen
docs/AI_COACH.md gab es, verlinkt war es von nirgendwo, und weder README noch
die Website erwaehnten das Feature ueberhaupt. Wer es nicht schon kannte,
konnte es nicht finden.
README: Zeile bei den Features (neben dem MCP-Punkt, denn beides ist optional
und beides bleibt aus dem Standard-Build draussen), Haken im Roadmap, Absatz
unter Tech zur eigentlichen Konstruktion -- Allowlist raus, geschlossene Liste
rein, Anwenden erst nach Zustimmung auf dem Client.
API_TARGET und COACH_DISABLED standen in keiner Konfigurationstabelle und in
keiner .env.example, obwohl das die zwei Schalter sind, die man dafuer braucht.
website/docs.html bekommt einen eigenen Abschnitt neben "Ask an AI" -- die
beiden werden sonst verwechselt: das eine liest read-only ueber MCP, das
andere schreibt Plaene vor. Mit dem Gesundheitshinweis, wie in der App auch.
---
.env.example | 22 ++++++++++++++++++++++
README.md | 10 ++++++++++
website/docs.html | 21 +++++++++++++++++++++
3 files changed, 53 insertions(+)
diff --git a/.env.example b/.env.example
index 52e25b1..2b214d1 100644
--- a/.env.example
+++ b/.env.example
@@ -76,3 +76,25 @@ RP_NAME=openGym
# fine; set a mailto: if you would rather they mailed you:
#
# VAPID_SUBJECT=mailto:you@example.com
+
+# ── AI Coach (optional, off by default) ────────────────────────────────────
+# The Coach is not in the image you get by default, and it stays off even when
+# it is: an admin has to turn it on in Settings → Admin and connect a provider
+# account. An instance that never does either is byte-for-byte the same app it
+# was before the feature existed.
+#
+# API_TARGET picks which API image gets built. `default` carries no AI runtime
+# at all — no Agent SDK, no Codex, no bubblewrap. `coach` adds them (~300 MB):
+#
+# API_TARGET=coach docker compose up -d --build api
+#
+# COACH_DISABLED is the kill switch that outranks the admin toggle. Set it when
+# you want the Coach off for certain — after an incident, or on an instance
+# where nobody should be able to turn it on:
+#
+# COACH_DISABLED=1
+#
+# Credentials never live here. They are encrypted into ./coach.json, or for the
+# Codex provider cached in ./coach-auth — a sibling of ./data, never inside it,
+# so a live sign-in does not ride along in the documented backup archive.
+# See docs/AI_COACH.md.
diff --git a/README.md b/README.md
index b4d8d22..8df65f7 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,7 @@ as a home-screen app, passkey sign-in, offline support, sync across your phone a
- 📥 **Bring your history with you** — import from **FitNotes** (Android and iOS), **Strong** and **Hevy**, or body weight straight out of an **Apple Health** export. Exercise names are matched against the library and anything unrecognised becomes one of your own exercises, so nothing in the file is dropped
- 📦 **Yours to keep** — one-tap JSON export/import, guest mode, **no telemetry**
- 🤖 **Ask an AI about your training** (optional) — an [MCP server](mcp/README.md) lets a client like Claude Desktop or Cursor read your history in your own words: *"what did I bench last week?"*. Read-only, spawned locally by the client, nothing leaves your box. Not in the Docker build — if you don't use an AI assistant, it isn't there
+- 🧠 **An AI coach that writes your plan** (optional, off by default) — answer a handful of questions and it designs a week of routines; later it reads what you actually logged and proposes changes, each one with the evidence behind it. You approve every change and can undo it. It runs on **your** server under **your** provider account, and it needs a separate image to exist at all — the default build carries no AI runtime whatsoever. See [docs/AI_COACH.md](docs/AI_COACH.md)
- 📱 **Standalone Android app** — the whole tracker as a sideloadable APK: no account, no server, data on the phone, native workout reminders ([download](https://opengym.duarte-santos.ch))
## Quick start (self-host)
@@ -164,6 +165,8 @@ All via `.env` (see `.env.example`):
| `INVITE_ONLY` | Require an invite code to create a profile | *(off)* |
| `ALLOW_GUEST` | Offer "Continue without account" — set `0` to require a profile | *(on)* |
| `VAPID_SUBJECT` | Contact URL sent with push notifications | your `ORIGIN` |
+| `API_TARGET` | Which API image to build: `default` (no AI runtime) or `coach` | `default` |
+| `COACH_DISABLED` | Set to `1` to force the AI Coach off instance-wide, whatever the admin toggled | *(unset)* |
Push notification keys are generated on first run and saved to `./data/vapid.json` — nothing to set.
`DATA_DIR` is pinned to `/data` by `docker-compose.yml` and mapped to `./data` on the host; change the
@@ -176,6 +179,7 @@ Rough, community-driven — ideas and PRs welcome:
- [x] Standalone mobile app — Android APK to sideload ([download](https://opengym.duarte-santos.ch)); on iOS as a self-hosted PWA (no store listings planned)
- [x] Automatic progression programs (linear, Greyskull LP, double progression) with stalls and deloads
- [x] Estimated 1RM per exercise
+- [x] Optional AI coach — designs a plan and reviews your training, on your own server and your own provider account ([docs](docs/AI_COACH.md))
- [ ] Percentage / training-max programming (5/3/1-style) on top of the progression engine
- [ ] More starter plans (upper/lower, full-body, 5×5)
- [x] Importers from FitNotes / Strong / Hevy (including the RPE they record), and body weight from Apple Health
@@ -196,6 +200,12 @@ lives in pure functions under `frontend/src/lib/` with tests next to them: `npm
`frontend/`. Vitest is a dev dependency; the app itself ships no runtime dependencies beyond
React, the router and Zustand.
+The optional AI Coach (`api/coach/`) is built the same way round: a by-name allowlist decides
+what may leave the server, and a closed-list validator decides what may come back — the model
+can touch routines and the weekly schedule, nothing else, and every change is applied on the
+client only after you approve it. The AI runtime lives in a separate Docker build target, so an
+instance that never asks for it never carries it. See [docs/AI_COACH.md](docs/AI_COACH.md).
+
The same pure helpers power an optional MCP server (`mcp/`) that lets an LLM client like
Claude Desktop read your data over stdio — see [mcp/README.md](mcp/README.md). Opt-in, not
in the Docker build.
diff --git a/website/docs.html b/website/docs.html
index 4cadfdd..e222c8b 100644
--- a/website/docs.html
+++ b/website/docs.html
@@ -40,6 +40,7 @@
iPhone
Self-hosting
Ask an AI
+ AI Coach
Import your history
Backups
Build it yourself
@@ -113,6 +114,26 @@ docker compose up -d
an AI assistant, it simply isn't there. Setup is a few lines of client config:
mcp/README.md.
+ Let an AI coach write your plan
+ Separate from the read-only bridge above, openGym has an optional AI Coach that can
+ design a training plan and, later, review what you actually logged and propose changes to
+ it. Answer a few questions — goal, days a week, session length, equipment, anything to work
+ around — and it builds a week of routines. Every suggestion carries the evidence behind it,
+ you approve or reject each one, and you can undo the last set of changes.
+ It is off by default and not in the default image. The Coach needs a build that
+ includes an AI runtime, which the normal one deliberately does not carry:
+ API_TARGET=coach docker compose up -d --build api
+ Then an admin turns it on in Settings → Admin → AI Coach and connects a provider
+ account. It runs on your server under your account — there is no openGym
+ service in the middle, and nothing is sent anywhere until you ask it for something. What
+ leaves the server is a by-name allowlist (your plan, your logged sets, body weight if you
+ track it) under a pseudonym; your name, sign-in details and other profiles never do. What
+ comes back can only touch routines and your weekly schedule, and is applied on your device
+ after you approve it.
+ The Coach is not a doctor or a physiotherapist. If something hurts, ask a professional.
+ Full details, including exactly what is sent and how credentials are stored:
+ docs/AI_COACH.md.
+
Import your training history
Coming from another tracker? Settings → Data → Import from another app reads: