syntax-workout-sdk
Workout tree algebra -- represent any physical workout as a recursive tree.
Install
Rust
[]
= "0.1"
Node.js
Python
Core concept
Every workout is a tree of Nodes. Leaf nodes are individual sets; inner nodes group them into exercises, blocks, sessions, days, weeks, phases, and programs.
Program
Week
Day
Session ("Upper Hypertrophy")
Block (Sequential) -- straight sets
Exercise ("Bench Press")
Set [100kg x 5]
Set [100kg x 5]
Block (Parallel) -- superset
Exercise ("DB Row")
Set [30kg x 10]
Exercise ("Lateral Raise")
Set [12.5kg x 15]
Block (Circuit {rounds: 3}) -- circuit
Exercise ("Squat")
Set [60kg x 15]
Exercise ("Push-up")
Set [20 reps]
Exercise ("Plank")
Set [60s]
Each Node carries a kind, a payload, optional children, and open-ended metadata.
Quick example
Rust (builder API)
use *;
use ;
use WeightUnit;
let workout = new
.sport
.date
.root
.build;
let json = to_string_pretty.unwrap;
Node.js (parse + validate)
import from 'fs';
import from '@syntax-workout/sdk';
const json = ;
// Parse and round-trip through Rust types
const workout = JSON.;
console.log; // "strength"
// Validate only (returns error strings, empty = valid)
const errors = ;
// Count total sets
const sets = ;
Python (parse + validate)
=
# Parse into Python dict
=
# "strength"
# Validate only
=
# Count sets
=
ExecutionMode
Controls how children of a Block node are performed.
| Mode | Meaning | Example |
|---|---|---|
Sequential |
Finish all sets of exercise A, then B | Straight sets |
Parallel |
Alternate sets across exercises | Supersets, giant sets |
Circuit { rounds: N } |
Cycle through all exercises N times | Circuit training |
Custom(String) |
User-defined | AMRAP, EMOM |
Measure variants
| Variant | Fields | Example |
|---|---|---|
Reps |
u32 |
Reps(10) |
Weight |
value: f64, unit: Kg|Lbs |
Weight { 80.0, Kg } |
Distance |
value: f64, unit: Meters|Kilometers|Miles |
Distance { 5.0, Km } |
Duration |
seconds: f64 |
Duration { 180.0 } |
Pace |
per: DistanceUnit, seconds: f64 |
Pace { Km, 330.0 } |
HeartRate |
bpm: u32 |
HeartRate { 145 } |
Calories |
u32 |
Calories(350) |
Custom |
name: String, value: Value |
Custom { "elevation", 150 } |
Intensity variants
| Variant | Fields | Example |
|---|---|---|
PercentOfMax |
f64 (0.0-1.0) |
PercentOfMax(0.80) |
RPE |
f64 (1-10) |
RPE(8.5) |
RIR |
u32 |
RIR(2) |
Bodyweight |
-- | Bodyweight |
Custom |
name: String, value: Value |
Custom { "zone", 3 } |
Examples
See examples/ for JSON workout files covering strength, endurance, and mixed modalities.
License
MIT OR Apache-2.0