Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ FAST_TIER_ENABLED=false
# Lower is faster and cheaper with less deep thinking. Default medium.
REASONING_EFFORT=medium

# On long runs, show one short status message ("Checking your training log...")
# that is edited in place and removed when the reply lands. Set false to disable.
PROGRESS_UPDATES=true

# Let the host refresh the Dashboard data tiles after a run that logged rows,
# instead of the agent doing it before it replies. Set false to disable.
HOST_DASHBOARD_SYNC=true

# ── Storage paths ─────────────────────────────────────────────────────
# Local defaults work out of the box. In Docker these point at a mounted volume.
SESSION_FILE=./data/sessions.json
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Shell scripts must stay LF: a CRLF entrypoint.sh will not start in the container.
*.sh text eol=lf
10 changes: 5 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ The user can dump raw training programs and reference material into the repo's `

Always read recent log rows and current goals before recommending or planning, so your advice reflects what they have actually been doing. After a session is logged, a recommendation given, or a plan built, write it back to Notion so nothing is lost. If the workspace does not exist yet, run the setup-notion skill first. If Notion is not configured (no token), say so plainly and offer to coach without persistence for now.

When answering any question about past lifts, sessions, or training history, always fetch the full page body (blocks) of the relevant Workout Log entries, not just the database row properties. The blocks contain the actual sets, reps, weights, and notes; the properties hold only the summary. Pull the blocks with `node scripts/notion.ts get-page-blocks <pageId>`, then explain in chat what concretely happened in that session (exercises done, loads used, key notes), rather than only reporting top-level fields.
When answering any question about past lifts, sessions, or training history, always fetch the full page body (blocks) of the relevant Workout Log entries, not just the database row properties. The blocks contain the actual sets, reps, weights, and notes; the properties hold only the summary. Pull them in one call: `node scripts/notion.ts query-recent --db "Workout Log" --limit 3 --with-blocks` returns recent rows with their bodies, and `node scripts/notion.ts get-page-blocks <id1> <id2> ...` reads specific pages (every `query-recent` row ends with its `id:`). Then explain in chat what concretely happened in that session (exercises done, loads used, key notes), rather than only reporting top-level fields.

All Notion work goes through the bundled helper `scripts/notion.ts` (run via Bash), which wraps the REST API: `log` to add a Workout Log row, `query-recent` to pull the last sessions, `append` to write rich blocks (headings, callouts, dividers, tables, columns, with inline **bold**, _italic_, `code`, and [links](url) rendered as rich text), `create-page` to add a child page, `refresh-tile` to update a Dashboard tile, and `resolve-db` to resolve and cache a database id. The helper retries automatically on Notion's rate limit, and its id cache self-heals if a database is deleted and recreated. The notion-formatting and log-workout skills show the exact commands. Note: Notion's public API cannot configure database views, so default views are still set by hand once.
All Notion work goes through the bundled helper `scripts/notion.ts` (run via Bash), which wraps the REST API: `log` to add a Workout Log row, `query-recent` to pull the last sessions, `get-page-blocks` to read page bodies, `append` to write rich blocks (headings, callouts, dividers, tables, columns, with inline **bold**, _italic_, `code`, and [links](url) rendered as rich text), `create-page` to add a child page, `refresh-tile` to update a Dashboard tile, and `resolve-db` to resolve and cache a database id (`node scripts/notion.ts --help` lists every command). The helper retries automatically on Notion's rate limit, and its id cache self-heals if a database is deleted and recreated. Run it from the project root as `node scripts/notion.ts ...` (no `cd /data`), and pass several page ids to one `get-page-blocks` call rather than one call per page. The notion-formatting and log-workout skills show the exact commands. Note: Notion's public API cannot configure database views, so default views are still set by hand once.

### Keep the Dashboard current

The Dashboard page is a live snapshot and summary of what is happening: current program and week, active goals, this week's training, latest body stats, and the next session. It also doubles as the central index of the workspace: keep a small, tasteful set of links near the top to the key pages and databases (Programs, Goals, Body Stats, Workout Log, Knowledge Base) so the user can jump anywhere from one place. Keep that index compact (a single linked row or a small callout), never a cluttered wall of links. Treat the whole page as something you keep in sync, not a one-off build. Whenever you change the underlying data, refresh the affected tile in the same turn, before you reply, so the Dashboard never goes stale:
The Dashboard page is a live snapshot and summary of what is happening: current program and week, active goals, this week's training, latest body stats, and the next session. It also doubles as the central index of the workspace: keep a small, tasteful set of links near the top to the key pages and databases (Programs, Goals, Body Stats, Workout Log, Knowledge Base) so the user can jump anywhere from one place. Keep that index compact (a single linked row or a small callout), never a cluttered wall of links. Treat the whole page as something you keep in sync, not a one-off build. Whenever you change the underlying data, refresh the affected tile in the same turn, before you reply, so the Dashboard never goes stale (the three data tiles are the exception, see the first point):

- Logged a session, changed a goal, or logged body weight or measurements: run `node scripts/notion.ts sync-dashboard` once. It re-derives the `thisWeek`, `goals`, and `bodyStats` tiles straight from the databases (counts and values come from queries, never hand-typed), so it is the preferred, fabrication-proof way to keep those three tiles current. Pass `--now <YYYY-MM-DD>` (the date from the Telegram header) so "this week" is correct in the user's timezone.
- Logged a session, changed a goal, or logged body weight or measurements with the helper's `log` command: do not run `sync-dashboard` yourself (unless the `[context]` line says "host Dashboard sync is off", then run it once yourself). The host runs it right after your reply, re-deriving the `thisWeek`, `goals`, and `bodyStats` tiles straight from the databases (counts and values come from queries, never hand-typed), so the user gets their reply without waiting on it. Only if you changed those rows some other way (not through `log`), run `node scripts/notion.ts sync-dashboard --now <YYYY-MM-DD>` once yourself, with the date from the Telegram header.
- Changed the program, started a new week, or anything that touches the hero (program, week, dates): rebuild the relevant tile, or rebuild the whole Dashboard if several tiles are affected at once (`node scripts/setup-workspace.ts --rebuild-dashboard`).
- The prose tiles (Next Session, Active Program, Nutrition) are yours to maintain with the same care a person would give their own board. Update them when the conversation gives you the material, without being asked: recommended or planned a session, refresh Next Session; agreed macros or nutrition targets, refresh Nutrition; program or focus shifted, refresh Active Program. Likewise, if you happen to read the Dashboard and a tile is visibly stale against what you know (Next Session shows a workout that was already logged, the hero shows last week), fix it in the same turn.

For one-off or prose tiles use `scripts/notion.ts refresh-tile --tile <name>` with tile ids resolved from `data/notion-ids.json` (`__dashboard.columns`); for the three data tiles prefer `sync-dashboard`. Never edit blocks in place; replace the whole tile (both commands do). The notion-formatting skill has the commands and the recommended tile content. If no Dashboard exists yet, run setup-notion. Do not announce the Dashboard update to the user unless they ask; just keep it accurate.
For one-off or prose tiles use `scripts/notion.ts refresh-tile --tile <name>` with tile ids resolved from `data/notion-ids.json` (`__dashboard.columns`); never hand-write the three data tiles, `sync-dashboard` owns them. Never edit blocks in place; replace the whole tile (both commands do). The notion-formatting skill has the commands and the recommended tile content. If no Dashboard exists yet, run setup-notion. Do not announce the Dashboard update to the user unless they ask; just keep it accurate.

## Workflow

Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ RUN chmod +x entrypoint.sh
# harmlessly (agent treats PERSONAL.md as missing) when the volume has no copy.
RUN ln -sf /data/PERSONAL.md /app/PERSONAL.md

# One canonical data dir: /app/data (what the scripts and the app resolve, as
# ./data does locally) points into the volume, so caches like notion-ids.json
# survive restarts. It targets /data/data, not /data, because earlier deploys
# already wrote their newest caches there. entrypoint.sh creates it on a fresh
# volume, since a mount hides anything built into the image under /data.
RUN ln -sfn /data/data /app/data

# /data is the mountpoint for the persistent volume (sessions + schedule).
RUN chown -R node:node /app/dist /app/node_modules /app/package.json /app/entrypoint.sh && \
mkdir -p /home/node/.claude && chown -R node:node /home/node && \
Expand Down
7 changes: 3 additions & 4 deletions coach-plugin/skills/log-workout/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ If the user flags an injury or pain while logging (not normal training soreness)

## 3. Keep the Dashboard current

Do both of these in the same turn, before replying:
Do not run `sync-dashboard` yourself: after a `log` write the host re-derives the This Week, Goals, and Body Stats tiles right after your reply. The one exception: if the `[context]` line says "host Dashboard sync is off", run it once yourself after logging.

1. Run `node scripts/notion.ts sync-dashboard --now <YYYY-MM-DD from the Telegram header>` to re-derive the This Week, Goals, and Body Stats tiles from the databases.
2. Refresh the **Next Session** tile. The session just logged is no longer "next": work out what actually comes next from the weekly plan (or the active program's schedule) and rewrite the tile with `node scripts/notion.ts refresh-tile` (tile ids in `data/notion-ids.json` under `__dashboard.columns`; content format in the notion-formatting skill). If no plan tells you what is next, put a short honest placeholder ("Next session not planned yet, ask me to plan the week") rather than leaving the completed session showing.
In the same turn, before replying, refresh the **Next Session** tile. The session just logged is no longer "next": work out what actually comes next from the weekly plan (or the active program's schedule) and rewrite the tile with `node scripts/notion.ts refresh-tile` (tile ids in `data/notion-ids.json` under `__dashboard.columns`; content format in the notion-formatting skill). If no plan tells you what is next, put a short honest placeholder ("Next session not planned yet, ask me to plan the week") rather than leaving the completed session showing.

`sync-dashboard` alone is not enough: it does not touch the prose tiles, and a Next Session tile still showing the workout that was just logged is exactly the staleness to avoid.
The host sync does not touch the prose tiles, and a Next Session tile still showing the workout that was just logged is exactly the staleness to avoid.

## 4. Confirm and encourage

Expand Down
4 changes: 1 addition & 3 deletions coach-plugin/skills/notion-formatting/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ Note: Notion's public API cannot create or configure database *views* (grouping,

If the workspace has a Dashboard page (built by setup-notion), keep its tiles current after you change the underlying data, so the user never has to ask.

**Preferred for the three data tiles (This Week, Goals, Body Stats):** run one command.
**The three data tiles (This Week, Goals, Body Stats)** come from `sync-dashboard`, which re-derives them directly from the databases (session counts, goal progress, latest body stats), so the numbers are always consistent with the data and never hand-typed. After you log a session, a goal, or body stats with the helper's `log` command, the host runs it for you right after your reply, so do not run it yourself. Run it once yourself only if you changed those rows some other way, or if the `[context]` line says "host Dashboard sync is off":

```bash
node scripts/notion.ts sync-dashboard --now 2026-06-30 # --now is the date from the Telegram header
```

`sync-dashboard` re-derives all three tiles directly from the databases (session counts, goal progress, latest body stats), so the numbers are always consistent with the data and never hand-typed. Run it after logging a session, changing a goal, or logging body stats.

For one-off or prose tiles, `refresh-tile` replaces a single tile from your own markdown (never edit blocks in place; their ids shift). Tile ids are cached in `data/notion-ids.json` and self-heal from the live page, so refer to tiles by name: `thisWeek`, `goals`, `bodyStats`, `nextSession`, `activeProgram`, `nutrition`, `quickCommands`.

```bash
Expand Down
2 changes: 1 addition & 1 deletion coach-plugin/skills/progress-report/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Turn the Notion Workout Log into an honest, motivating read on how the user is d
## 1. Pull the data

- Decide the window from the request (this week, last month, or a sensible default like the last 4 weeks).
- Query the Notion Workout Log with `node scripts/notion.ts query-recent --db "Workout Log"` for sessions in that window. Read current Goals and `PERSONAL.md` for what success looks like.
- Query the Notion Workout Log with `node scripts/notion.ts query-recent --db "Workout Log"` for sessions in that window (add `--with-blocks` to get each session's sets and loads in the same call). Read current Goals and `PERSONAL.md` for what success looks like.

## 2. Analyse

Expand Down
4 changes: 2 additions & 2 deletions coach-plugin/skills/recommend-workout/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ On the first message of a new conversation, check that `PERSONAL.md` has real go

```bash
# Last 3 sessions overall, or for a specific Focus you are about to train
node scripts/notion.ts query-recent --db "Workout Log" --limit 3
node scripts/notion.ts query-recent --db "Workout Log" --focus Push --limit 3
node scripts/notion.ts query-recent --db "Workout Log" --limit 3 --with-blocks
node scripts/notion.ts query-recent --db "Workout Log" --focus Push --limit 3 --with-blocks
```

Use the returned loads and RPE as the reference point for today's prescription. The helper is one call and already sorted by date. Check the current week's plan if one exists.
Expand Down
5 changes: 3 additions & 2 deletions coach-plugin/skills/setup-notion/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ read it if you need to extend the workspace.
## 3. Seed goals and confirm

If `PERSONAL.md` lists real goals, offer to add them to the Goals database (ask
before writing), and refresh the Dashboard Goals tile afterwards (see the
notion-formatting skill). Then confirm what now exists and tell the user they can
before writing). Goals added with the helper's `log` command reach the Dashboard
Goals tile on their own: the host syncs it right after your reply, unless the
`[context]` line says host Dashboard sync is off (see the notion-formatting skill). Then confirm what now exists and tell the user they can
log workouts in plain language and ask for plans, recommendations, and progress.

## Note on views
Expand Down
Loading
Loading