Metadata-Version: 2.4
Name: vdotz
Version: 0.1.0
Summary: Running pace and race-time tools.
Author: m09
Author-email: m09 <142691+m09@users.noreply.github.com>
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Dist: fit-tool>=0.9.16
Requires-Dist: garmin-fit-sdk>=21.221.0
Requires-Dist: niquests>=3.17.0
Requires-Dist: python-dotenv>=1.2.4
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# `vdotz`

Running pace and race-time tools, built on Jack Daniels' VDOT, with workout
templates synced to intervals.icu.

```sh
vdotz vdot 5km 19:10            # VDOT of a race and equivalent race times
vdotz paces                     # usual reference paces at the current VDOT
vdotz paces marathon "10km+3%"  # any pace of the templates syntax
vdotz --vdot 48.3 paces "4:39*95%"
vdotz week                      # intervals / easy / rests of the current week
vdotz week -1 --type Ride       # previous week, for another activity type
vdotz course race.gpx -D marathon marathon 3:05:00  # even-effort splits
vdotz fit strength/*.toml -o GARMIN/NewFiles  # strength sessions for Garmin
vdotz watch                     # strength + non-easy plan workouts to the watch
```

## Installation

```sh
uv tool install vdotz
```

From a clone of the repository, to work on it:

```sh
uv tool install --editable .
vdotz link       # see below
```

Files follow the XDG base directory specification:

```
~/.config/vdotz/             # $XDG_CONFIG_HOME/vdotz
├── config.toml              # athlete_id = "i…" and vdot = 52.3, or a [test] table
└── .env                     # INTERVALS_API_KEY=…
~/.local/share/vdotz/        # $XDG_DATA_HOME/vdotz, or -d DIRECTORY
├── 🏃 NSM/                  # one subdirectory per intervals.icu library folder
│   └── intervalles-courts.toml
└── 🏃 NSM plan.toml         # one file per intervals.icu plan
```

They are versioned in this repository as `config/` (where `.env` is ignored by
git) and `workouts/`: `vdotz link` links the two locations to them, so that
`vdotz` works from any directory. `--vdot` overrides the configured VDOT.

## Course paces

`vdotz course` reads a GPX track and prints the paces of an even effort over
the course: per kilometer (with the cumulative time and the waypoints, such as
feed stations), then over each climb and descent. Goals are flat paces in the
`paces` syntax (`marathon` by default, `4:20`, `semi+2%`), or finish times
(`3:05:00`). `-D` scales the track to the official distance, since GPS tracks
are rarely exact.

The track is resampled every 20 m and its elevation smoothed over 200 m, as raw
GPS elevations count much more climbing than there is. Each segment's pace is
the flat pace times `1 + 0.033·g` uphill, `1 + 0.018·max(g, -4)` downhill, for a
grade of `g`%. A waypoint near a road that the course takes twice gets both
passes.

## Strength sessions

`vdotz fit` converts strength sessions (`strength/` in this repository) to
Garmin strength workouts, as FIT files. Copied to `GARMIN/NewFiles` on the
watch, they show up in its workouts.

```toml
name = "Muscu mardi"
warmup = "5-10', puis séries de montée en charge"  # open step, optional

[[blocks]]
sets = 3      # defaults to 1
rest = "3'"   # after each set, optional
exercises = [
    { exercise = "deadlift/barbell_deadlift", name = "Soulevé de terre", reps = 5, weight = 102 },
    { exercise = "plank/side_plank", name = "Gainage latéral", duration = "30s", unilateral = true },
]
```

A block with several exercises is a superset. `exercise` is a category of the
FIT profile, optionally followed by an exercise of this category, in lower case
(see `ExerciseCategory` and the `…ExerciseName` enums of `fit_tool`). `name` is
the step name; `weight` is in kg.

An exercise with `unilateral = true` becomes two steps, left then right, each
with its `reps` or `duration`: a timed circuit then gives its full time to each
side. The side is at the start of the step notes. Timed sides are separated by
5 s of rest, to change sides.

## Garmin watch

`vdotz watch` copies to a Garmin watch plugged in over USB the strength
sessions and the workouts of the plans, except easy runs (`E …`), which are
just a time. The running workouts are converted to FIT by intervals.icu, from
the library: run `vdotz sync` first after changing a template (a warning
says so). Strength sessions are optional: without a `strength` directory next
to the workouts, only the running workouts are copied.

The watch is mounted over MTP once opened in the file manager: the files go to
`GARMIN/NewFiles`, found under `/run/user/$UID/gvfs`, and are imported when the
watch is unplugged. The previous versions, which the watch would keep beside
the new ones, are removed from `GARMIN/Workouts` first. `-o` gives another
directory.

## Merging activities

`vdotz merge` merges the activities of a day into a single FIT file, ready to
be uploaded to Garmin Connect, for a run split by stopping the watch by mistake.
It downloads the original files from intervals.icu, and the time between two
activities becomes a timer pause.

```sh
vdotz merge                                 # today's runs
vdotz merge 2026-11-05 -t Ride -o ride.fit  # another day and activity type
vdotz merge 2026-11-05 -a i123 -a i456      # only these activities
```

It lists the activities it finds: if the merged file already came back to
intervals.icu, they overlap, and `-a` chooses the originals. Records are kept as
they are, and the session is computed from those of the activities, with a few
approximations: the normalized power is a mean, the training effects are the
highest ones, and the feel and RPE are those of the last activity. Garmin splits
are dropped. See `merge.py` for the details.

Delete the originals afterwards, on Garmin Connect and on intervals.icu, or the
load of the day is counted twice.

## Elevation correction

intervals.icu can replace the altitude recorded by the watch with the one of
online maps. On flat routes this adds climbing that doesn't exist: 154 m instead
of 9 m around the Île de Nantes. It also changes the training load, which follows
the pace load.

`vdotz elevation` turns the correction off on recent activities, and prints
their elevation gain before and after. The gain is recalculated straight away.
Activities already corrected are left alone, so it can be run at any time.

```sh
vdotz elevation --dry-run        # list the runs of the last 30 days
vdotz elevation                  # turn the correction off
vdotz elevation --days 90 -t Ride # another period and activity type
```

## Workout templates

`vdotz` keeps intervals.icu workouts as local files whose paces are derived
from a VDOT, and pushes them to intervals.icu on demand (e.g. after a test).

```toml
# config.toml
athlete_id = "i364734"

[test]
distance = "5km"
time = "19:10"
```

```toml
# 🏃 NSM/intervalles-courts.toml
name = "Intervalles courts"
type = "Run"
description = '''
11x
- 3' {60'+1%}-{60'} Pace intensity=interval
- 1' intensity=rest
'''
```

Descriptions use the intervals.icu workout builder syntax. Placeholders between
braces are replaced by the maximal pace over a duration (`{1h}`, `{90'}`) or a
distance (`{10km}`, `{semi}`, `{marathon}`), by the pace at VO2max (`{mas}`), or
by a literal pace (`{4:39}`). Adjustments apply from left to right: `*65%` for
65% of the speed, `+1%` for a pace 1% slower, `+2'` for a pace 2 min/km slower
(e.g. `{mas*65%+2'}`). Each placeholder is a single pace: ranges join two
placeholders (e.g. `{60'+1%}-{60'}`).

`vdotz week` classifies the planned steps by intensity: `interval` steps are
intervals, `rest` steps are rests, and everything else is easy running.

The API key is read from the `INTERVALS_API_KEY` environment variable, or from a
`.env` file in the current directory, one of its parents, or the configuration
directory.

```sh
vdotz pull "🏃 NSM"             # bootstrap from an existing folder
vdotz render                    # preview the computed paces
vdotz sync --dry-run            # show the diff with intervals.icu
vdotz sync --calendar           # update the library and planned workouts
```

## Plans

A TOML file at the root of the workouts directory is an intervals.icu plan, named
after the file. It lists workouts week by week, from Monday to Sunday, with `""`
for rest days. Workouts can come from any folder, as long as their names are
unique:

```toml
# 🏃 NSM plan.toml
weeks = [
    ["Jog", "Intervalles courts", "", "Intervalles moyens", "", "Jog", "Sortie longue"],
]
```

`vdotz sync` creates the plan and keeps its workouts identical to the
templates, matched by day: plan workouts on rest days are deleted. Plans are
applied to the calendar from intervals.icu, after which `sync --calendar` keeps
the planned workouts up to date.

## Releasing

1. `uv run bumpver update --minor` (or `--patch`, `--major`): bumps, commits, tags
   and pushes.
2. `uv run doit publish`: builds and uploads to PyPI with the token of
   `creds.env`, a gitignored file at the repository's root holding one line,
   `export UV_PUBLISH_TOKEN=pypi-...`, readable by you only (`chmod 400`).
