A CLI that answers "what classes ran", "who was there" and "what was the workout" with a single HTTP POST each -- no browser at query time. Wodify's athlete app is an OutSystems Reactive SPA. Driving it with a headless browser works but is slow and, for an LLM agent, expensive: a full page render to read a few lines back out of the DOM. Its data actions are plain JSON endpoints, so this talks to them directly. wodify list date 2026-07-25 time, coach, booked/max, title, duration, ID wodify list workout <id> attendee names + that class's workout Two phases. `prime` attaches over CDP to a browser that is already logged in and captures the session cookies, the CSRF token, and each action's apiVersion and body shape. Everything after that is stdlib HTTP -- the query path has no third-party dependencies at all. Three things genuinely require the browser, which is why priming exists: - the session bearer nr1W_Theme_UI is HttpOnly, so it cannot be exported by hand - X-CSRFToken is not in cookies, localStorage, or any JS global - apiVersion is per-action, not global Read-only is enforced in code, not by the credential (Wodify issues no read-only token): an explicit allowlist plus a write-marker guard applied even to allowlisted paths, so a careless registry edit fails closed. Tests assert that real mutating endpoint names are refused. Responses are cached in SQLite, keyed by the local date they were fetched on, so a repeat query the same day touches no network. All fetching funnels through service.py so a call site cannot forget the cache. Staleness is explicit rather than silent: responses carry hasModuleVersionChanged/hasApiVersionChanged, and the client raises VersionStale/SessionExpired instead of returning a plausible empty result. That matters because every bug found while building this produced confident wrong output rather than an error -- see CLAUDE.md for the field-name traps. History squashed before first publication: earlier commits embedded real gym members' names in test fixtures. Fixtures now use fictional names. 122 tests, no network required. Co-Authored-By: Claude Opus 5 <[email protected]>
137 lines
4.8 KiB
Markdown
137 lines
4.8 KiB
Markdown
# wodify
|
|
|
|
Read-only client for the **Wodify athlete app**. Answers "what's the workout", "what did I
|
|
book", "who's coaching", "who else is going" with a single HTTP POST — no browser at query time.
|
|
|
|
Wodify's athlete app is an OutSystems Reactive SPA. Driving it with a headless browser works but
|
|
is slow and, for an LLM agent, expensive: you render a whole page to read a few lines back out of
|
|
the DOM. Its data actions are plain JSON endpoints, so this talks to them directly.
|
|
|
|
## Read-only, by construction
|
|
|
|
This client cannot reserve, cancel, check in, log results, accept terms, or buy anything.
|
|
|
|
The credential is a full-session login — Wodify issues no read-only token — so enforcement is in
|
|
the code, not the credential:
|
|
|
|
- **Allowlist** (`actions.ACTIONS`): unregistered actions cannot be called.
|
|
- **Write guard** (`actions.assert_read_only`): any path containing `Create`, `Save`, `Reserve`,
|
|
`Cancel`, `SignIn`, `Purchase`, … is refused, *including* allowlisted entries, so a careless
|
|
registry edit still fails closed.
|
|
|
|
If you want to book a class, use the app.
|
|
|
|
## Install
|
|
|
|
```bash
|
|
pip install -e ".[prime,dev]"
|
|
```
|
|
|
|
The **query path is stdlib-only**. The `prime` extra (`websockets`) is needed only for the
|
|
occasional capture step.
|
|
|
|
## Use
|
|
|
|
```bash
|
|
wodify list date 2026-07-25
|
|
```
|
|
|
|
```
|
|
TIME COACH BOOKED CLASS DUR ID
|
|
----- ----------- ------ ----------------------- ----- ---------
|
|
07:00 Robin Vance 10/10 CrossFit: 7:00 AM 60min 192001199
|
|
10:00 Pat Doyle 12/12 CrossFit Burn: 10:00 AM 60min 190918189
|
|
```
|
|
|
|
(Names above are illustrative — the tool prints whatever your gym returns.)
|
|
|
|
Then feed an ID back in for the workout and the named attendee list:
|
|
|
|
```bash
|
|
wodify list workout 190918189
|
|
```
|
|
|
|
Other commands:
|
|
|
|
```bash
|
|
wodify doctor # config, session and DB status
|
|
wodify prime # capture session state (needs a logged-in browser)
|
|
wodify bookings --since 2026-07-18 --attended
|
|
wodify schedule --date 2026-07-21
|
|
```
|
|
|
|
`--json` gives raw payloads, `--refresh` bypasses the local cache, and
|
|
`list workout --notes` adds the coach's brief.
|
|
|
|
A class ID carries neither its date nor its program — it is per-occurrence. `list date`
|
|
indexes the day into SQLite; `list workout` resolves the ID from there. Ask for an ID on a day
|
|
you never listed and it says so rather than guessing.
|
|
|
|
## Local SQLite cache
|
|
|
|
`~/.cache/wodify/wodify.db` (override with `WODIFY_DB`), created mode `600` because it holds
|
|
other members' names. Responses are stamped with the local date they were fetched on and
|
|
reused for the rest of that day; anything older is a miss. Past days never change, so this is
|
|
safe. Today's schedule can shift — that is what `--refresh` is for.
|
|
|
|
Every command states whether the answer came from cache or the network.
|
|
|
|
## How priming works
|
|
|
|
`prime` attaches over CDP to a Chrome that is already logged in, and captures three things that
|
|
cannot be obtained any other way:
|
|
|
|
| Thing | Why it needs a browser |
|
|
|-------|------------------------|
|
|
| `nr1W_Theme_UI` cookie | **HttpOnly** — `document.cookie` cannot read it, so it cannot be copied by hand |
|
|
| `X-CSRFToken` | Not in cookies, `localStorage`, or any JS global; only appears on outbound requests |
|
|
| `apiVersion` | **Per-action**, not global — each endpoint's value must be observed from a real call |
|
|
|
|
Results are cached at `~/.cache/wodify/session.json`, mode `600`. That file holds live
|
|
credentials: never commit it, never log it.
|
|
|
|
### Priming against a remote profile
|
|
|
|
If the logged-in Chrome is on another host, tunnel first:
|
|
|
|
```bash
|
|
ssh -L 9222:127.0.0.1:9222 your-host
|
|
```
|
|
|
|
A minimal setup on that host: Chrome with `--headless=new --remote-debugging-port=9222
|
|
--remote-debugging-address=127.0.0.1 --user-data-dir=<profile>`, logged in once. Keep the CDP
|
|
port on loopback — it is unauthenticated, and anything that can reach it can read every cookie
|
|
in that profile.
|
|
|
|
## Staleness is explicit
|
|
|
|
Every Wodify response reports `hasModuleVersionChanged` / `hasApiVersionChanged`. When Wodify
|
|
redeploys, or the session dies, the client raises rather than returning a plausible-looking empty
|
|
result:
|
|
|
|
| Exception | Exit | Meaning |
|
|
|-----------|------|---------|
|
|
| `NotPrimedError` | 4 | No cache, or this action was never observed |
|
|
| `SessionExpiredError` | 2 | Session dead — a human must log in again, then re-prime |
|
|
| `VersionStaleError` | 3 | Wodify redeployed — re-prime |
|
|
|
|
A silently wrong "no workout today" is worse than an error, so there is no fallback path that
|
|
guesses.
|
|
|
|
## Configuration
|
|
|
|
| Var | Default |
|
|
|-----|---------|
|
|
| `WODIFY_HOST` | `claycrossfit.wodify.com` |
|
|
| `WODIFY_CDP_URL` | `http://127.0.0.1:9222` |
|
|
| `WODIFY_CACHE` | `~/.cache/wodify/session.json` |
|
|
| `WODIFY_LOCATION_ID` | `11644` |
|
|
|
|
## Tests
|
|
|
|
```bash
|
|
python -m pytest -q
|
|
```
|
|
|
|
No network required. The write-guard tests assert that real mutating endpoint names are refused.
|