trainbud 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +11 -11
- package/CHANGELOG.md +757 -675
- package/QUICKSTART.md +185 -182
- package/README.md +329 -322
- package/dist/appDb.d.ts +40 -1
- package/dist/appDb.js +120 -51
- package/dist/cli.js +47 -0
- package/dist/dashboard.js +820 -820
- package/dist/dashboardCharts.js +42 -42
- package/dist/deviceTokens.d.ts +29 -0
- package/dist/deviceTokens.js +49 -0
- package/dist/history/context.js +35 -35
- package/dist/history/schema.js +66 -66
- package/dist/httpServer.js +64 -1
- package/dist/pairApi.js +11 -2
- package/dist/promptApi.js +5 -5
- package/dist/usage.js +17 -17
- package/package.json +82 -77
- package/dist/appDb.d.ts.map +0 -1
- package/dist/appDb.js.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/check.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/dashboard.d.ts.map +0 -1
- package/dist/dashboard.js.map +0 -1
- package/dist/dashboardCharts.d.ts.map +0 -1
- package/dist/dashboardCharts.js.map +0 -1
- package/dist/dashboardData.d.ts.map +0 -1
- package/dist/dashboardData.js.map +0 -1
- package/dist/detect/baseline.d.ts.map +0 -1
- package/dist/detect/baseline.js.map +0 -1
- package/dist/detect/countdown.d.ts.map +0 -1
- package/dist/detect/countdown.js.map +0 -1
- package/dist/detect/detectors.d.ts.map +0 -1
- package/dist/detect/detectors.js.map +0 -1
- package/dist/detect/findings.d.ts.map +0 -1
- package/dist/detect/findings.js.map +0 -1
- package/dist/detect/forecast.d.ts.map +0 -1
- package/dist/detect/forecast.js.map +0 -1
- package/dist/detect/index.d.ts.map +0 -1
- package/dist/detect/index.js.map +0 -1
- package/dist/detect/sleepQuality.d.ts.map +0 -1
- package/dist/detect/sleepQuality.js.map +0 -1
- package/dist/detect/trimp.d.ts.map +0 -1
- package/dist/detect/trimp.js.map +0 -1
- package/dist/detect/week.d.ts.map +0 -1
- package/dist/detect/week.js.map +0 -1
- package/dist/garmin/auth.d.ts.map +0 -1
- package/dist/garmin/auth.js.map +0 -1
- package/dist/garmin/cache.d.ts.map +0 -1
- package/dist/garmin/cache.js.map +0 -1
- package/dist/garmin/client.d.ts.map +0 -1
- package/dist/garmin/client.js.map +0 -1
- package/dist/garmin/daily.d.ts.map +0 -1
- package/dist/garmin/daily.js.map +0 -1
- package/dist/garmin/garminApiTypes.d.ts.map +0 -1
- package/dist/garmin/garminApiTypes.js.map +0 -1
- package/dist/garmin/garminConnect.d.ts.map +0 -1
- package/dist/garmin/garminConnect.js.map +0 -1
- package/dist/garmin/partial.d.ts.map +0 -1
- package/dist/garmin/partial.js.map +0 -1
- package/dist/garmin/rawApi.d.ts.map +0 -1
- package/dist/garmin/rawApi.js.map +0 -1
- package/dist/garmin/types.d.ts.map +0 -1
- package/dist/garmin/types.js.map +0 -1
- package/dist/history/capture.d.ts.map +0 -1
- package/dist/history/capture.js.map +0 -1
- package/dist/history/context.d.ts.map +0 -1
- package/dist/history/context.js.map +0 -1
- package/dist/history/fallback.d.ts.map +0 -1
- package/dist/history/fallback.js.map +0 -1
- package/dist/history/ingest.d.ts.map +0 -1
- package/dist/history/ingest.js.map +0 -1
- package/dist/history/scheduler.d.ts.map +0 -1
- package/dist/history/scheduler.js.map +0 -1
- package/dist/history/schema.d.ts.map +0 -1
- package/dist/history/schema.js.map +0 -1
- package/dist/history/store.d.ts.map +0 -1
- package/dist/history/store.js.map +0 -1
- package/dist/httpServer.d.ts.map +0 -1
- package/dist/httpServer.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcpConfig.d.ts.map +0 -1
- package/dist/mcpConfig.js.map +0 -1
- package/dist/pairApi.d.ts.map +0 -1
- package/dist/pairApi.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js.map +0 -1
- package/dist/promptApi.d.ts.map +0 -1
- package/dist/promptApi.js.map +0 -1
- package/dist/promptSuggestions.d.ts.map +0 -1
- package/dist/promptSuggestions.js.map +0 -1
- package/dist/selfTest.d.ts.map +0 -1
- package/dist/selfTest.js.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js.map +0 -1
- package/dist/toolErrors.d.ts.map +0 -1
- package/dist/toolErrors.js.map +0 -1
- package/dist/tools/activities.d.ts.map +0 -1
- package/dist/tools/activities.js.map +0 -1
- package/dist/tools/bodyComposition.d.ts.map +0 -1
- package/dist/tools/bodyComposition.js.map +0 -1
- package/dist/tools/context.d.ts.map +0 -1
- package/dist/tools/context.js.map +0 -1
- package/dist/tools/findings.d.ts.map +0 -1
- package/dist/tools/findings.js.map +0 -1
- package/dist/tools/heartRate.d.ts.map +0 -1
- package/dist/tools/heartRate.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/payloads.d.ts.map +0 -1
- package/dist/tools/payloads.js.map +0 -1
- package/dist/tools/recovery.d.ts.map +0 -1
- package/dist/tools/recovery.js.map +0 -1
- package/dist/tools/sleep.d.ts.map +0 -1
- package/dist/tools/sleep.js.map +0 -1
- package/dist/tools/stress.d.ts.map +0 -1
- package/dist/tools/stress.js.map +0 -1
- package/dist/tools/trainingInsights.d.ts.map +0 -1
- package/dist/tools/trainingInsights.js.map +0 -1
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js.map +0 -1
- package/dist/tools/vo2Max.d.ts.map +0 -1
- package/dist/tools/vo2Max.js.map +0 -1
- package/dist/tools/week.d.ts.map +0 -1
- package/dist/tools/week.js.map +0 -1
- package/dist/usage.d.ts.map +0 -1
- package/dist/usage.js.map +0 -1
- package/dist/utils/batch.d.ts.map +0 -1
- package/dist/utils/batch.js.map +0 -1
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/helpers.js.map +0 -1
- package/dist/utils/jsonFile.d.ts.map +0 -1
- package/dist/utils/jsonFile.js.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/secretFile.d.ts.map +0 -1
- package/dist/utils/secretFile.js.map +0 -1
- package/dist/utils/stdio.d.ts.map +0 -1
- package/dist/utils/stdio.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/watchApi.d.ts.map +0 -1
- package/dist/watchApi.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,322 +1,329 @@
|
|
|
1
|
-
# TrainBud
|
|
2
|
-
|
|
3
|
-
**Talk to your training data.**
|
|
4
|
-
|
|
5
|
-
TrainBud is an open-source MCP server that connects your Garmin Connect fitness data to Claude, Cursor, and other AI assistants. Ask about workouts, sleep, heart rate, recovery, and body composition in plain English — privately, on your machine.
|
|
6
|
-
|
|
7
|
-
> **Disclaimer:** TrainBud is an unofficial community project. It is not affiliated with, endorsed by, or sponsored by Garmin Ltd. Garmin Connect is a trademark of Garmin Ltd.
|
|
8
|
-
|
|
9
|
-
[](https://www.npmjs.com/package/trainbud)
|
|
10
|
+
[](https://github.com/Zsadigzade/trainbud/actions/workflows/ci.yml)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
[](.nvmrc)
|
|
13
|
+
|
|
14
|
+
## Try it
|
|
15
|
+
|
|
16
|
+
Once connected to your MCP client, ask things like:
|
|
17
|
+
|
|
18
|
+
- *"What did I do today?"*
|
|
19
|
+
- *"How's my sleep been this week?"*
|
|
20
|
+
- *"Am I recovered enough to train hard tomorrow?"*
|
|
21
|
+
- *"Is my resting heart rate trending down?"*
|
|
22
|
+
|
|
23
|
+
See [examples/prompts.md](./examples/prompts.md) for more ideas.
|
|
24
|
+
|
|
25
|
+
## Why TrainBud
|
|
26
|
+
|
|
27
|
+
- **Private** — credentials stay in your local `.env`; data is cached on your machine
|
|
28
|
+
- **Local-first** — SQLite cache, session tokens in `.trainbud/`
|
|
29
|
+
- **Works everywhere** — Windows, macOS, Linux (Node.js 20+)
|
|
30
|
+
- **Any MCP client** — Claude Desktop, Cursor, and other stdio-compatible clients
|
|
31
|
+
- **Smart fetching** — batched API calls and automatic re-auth when sessions expire
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx trainbud setup
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The setup wizard walks you through credentials, authentication, and connecting Cursor or
|
|
40
|
+
Claude Desktop — no MCP config editing required. Then restart your MCP client and ask it
|
|
41
|
+
what you did today.
|
|
42
|
+
|
|
43
|
+
To keep `trainbud` on your PATH instead of typing `npx` every time:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -g trainbud
|
|
47
|
+
trainbud setup
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Needs Node 20+. Full walkthrough: [QUICKSTART.md](./QUICKSTART.md)
|
|
51
|
+
|
|
52
|
+
<details>
|
|
53
|
+
<summary><b>From source</b> (for contributors, or to run an unreleased commit)</summary>
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/Zsadigzade/trainbud.git
|
|
57
|
+
cd trainbud
|
|
58
|
+
npm install
|
|
59
|
+
npm run build
|
|
60
|
+
npm link # puts `trainbud` on your PATH; undo with `npm unlink -g trainbud`
|
|
61
|
+
trainbud setup
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Without `npm link`, every `trainbud <command>` in this README is
|
|
65
|
+
`node dist/index.js <command>` run from the repo root. If `dist/` does not exist yet,
|
|
66
|
+
run `npm run build` first.
|
|
67
|
+
</details>
|
|
68
|
+
|
|
69
|
+
## Claude Code plugin (recommended)
|
|
70
|
+
|
|
71
|
+
Install as a [Claude Code plugin](https://code.claude.com/docs/en/plugins) — skills **and** MCP server in one step:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
/plugin marketplace add Zsadigzade/trainbud
|
|
75
|
+
/plugin install trainbud@trainbud
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Set credentials, then restart Claude Code:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
export GARMIN_EMAIL="your@email.com"
|
|
82
|
+
export GARMIN_PASSWORD="yourpassword"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Command | What it does |
|
|
86
|
+
|---------|----------------|
|
|
87
|
+
| `/trainbud:trainbud-setup` | First-time setup and diagnostics |
|
|
88
|
+
| `/trainbud:trainbud` | Ask about workouts, sleep, recovery, HR, stress, VO2 max |
|
|
89
|
+
|
|
90
|
+
Plugin files live in [`plugin/`](./plugin/). See [`plugin/README.md`](./plugin/README.md).
|
|
91
|
+
|
|
92
|
+
## Claude Code skills (in-repo)
|
|
93
|
+
|
|
94
|
+
This repo also ships project skills in [`.claude/skills/`](./.claude/skills/) for development without installing the plugin:
|
|
95
|
+
|
|
96
|
+
| Command | What it does |
|
|
97
|
+
|---------|----------------|
|
|
98
|
+
| `/trainbud-setup` | Install, authenticate, configure MCP, run live check |
|
|
99
|
+
| `/trainbud` | Ask about workouts, sleep, recovery, HR, stress, VO2 max |
|
|
100
|
+
|
|
101
|
+
Open the repo in **Claude Code** (`claude` in this directory) — skills load automatically.
|
|
102
|
+
|
|
103
|
+
To use skills in **every** project without the plugin, copy them to `~/.claude/skills/`.
|
|
104
|
+
|
|
105
|
+
After setup, restart your MCP client and try `/trainbud` with *"What did I do today?"*
|
|
106
|
+
|
|
107
|
+
## Dashboard
|
|
108
|
+
|
|
109
|
+
`trainbud serve` hosts a dashboard at `/dashboard`. It is phone-first, because the
|
|
110
|
+
pairing flow is: you are standing next to the watch holding a phone when you approve a
|
|
111
|
+
code.
|
|
112
|
+
|
|
113
|
+
It shows what stands out today against your own baselines, this week against last week,
|
|
114
|
+
and resting heart rate and sleep plotted against your own 30-day median — all read from
|
|
115
|
+
the local history store, so it paints instantly and works even when your Connect session
|
|
116
|
+
has expired. **A break in a line is a day with no measurement, not a zero.**
|
|
117
|
+
|
|
118
|
+
It is also where you tell TrainBud who it is talking to:
|
|
119
|
+
|
|
120
|
+
| Setting | What it changes |
|
|
121
|
+
|---|---|
|
|
122
|
+
| Name, units, primary sport, weekly goal | Every renderer, and what the AI is told about you |
|
|
123
|
+
| Thresholds | Where green becomes amber and amber becomes red — on the watch too |
|
|
124
|
+
| Watch cards | Which cards appear on the wrist and in what order, live on the next sync |
|
|
125
|
+
| AI model, tone, answer length | How the Ask card and the daily insight sound |
|
|
126
|
+
| Your own Ask questions | Up to five, 32 characters each. They lead the watch's Ask menu; the rest of the slots stay generated from what fired |
|
|
127
|
+
| Monthly spending cap | Optional. Refuses an Ask past the cap instead of spending past it |
|
|
128
|
+
| Privacy | Local feature counters, on by default, with a delete button |
|
|
129
|
+
|
|
130
|
+
**Usage.** TrainBud runs on your own AI provider key, so every question and every daily
|
|
131
|
+
insight is charged to you. The dashboard shows the tokens and cost per call, the month to
|
|
132
|
+
date, and a 30-day chart. A model this build has no published price for is recorded with
|
|
133
|
+
its cost left *unknown* rather than as zero — a call priced at zero would make a cap that
|
|
134
|
+
can never trip.
|
|
135
|
+
|
|
136
|
+
Nothing on this page leaves your machine. There is no endpoint to send it to.
|
|
137
|
+
|
|
138
|
+
## Garmin watch widget (Connect IQ)
|
|
139
|
+
|
|
140
|
+
View recovery, sleep, activity, stress, and VO2 max on your Garmin watch via a Connect IQ widget in [`ciq/`](./ciq/).
|
|
141
|
+
|
|
142
|
+
**Requires:** `trainbud serve` running + HTTPS tunnel (same setup as web AI).
|
|
143
|
+
|
|
144
|
+
1. Start the server and tunnel:
|
|
145
|
+
```bash
|
|
146
|
+
trainbud serve
|
|
147
|
+
cloudflared tunnel --url http://127.0.0.1:3847
|
|
148
|
+
```
|
|
149
|
+
2. Build and sideload the widget — see [ciq/README.md](./ciq/README.md)
|
|
150
|
+
3. In **Garmin Connect Mobile** → Connect IQ → TrainBud settings, set:
|
|
151
|
+
- **Server URL** — your tunnel URL (e.g. `https://abc.trycloudflare.com`)
|
|
152
|
+
4. Open the widget on your watch — it shows a pairing code. Approve it in the dashboard (`/dashboard?token=YOUR_API_KEY`) to complete setup. The dashboard swaps that token for a session cookie and drops it from the URL, so the address bar is safe to screenshot afterwards.
|
|
153
|
+
|
|
154
|
+
The glance shows recovery and sleep from the last cached summary, so it renders without
|
|
155
|
+
waiting on the network. Open it and tap or swipe to cycle through the cards you left switched on in the dashboard. The watch
|
|
156
|
+
calls `GET /api/watch` — a compact JSON summary, not the full MCP protocol.
|
|
157
|
+
|
|
158
|
+
## Connect to Claude Desktop
|
|
159
|
+
|
|
160
|
+
Edit `claude_desktop_config.json`:
|
|
161
|
+
|
|
162
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
163
|
+
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"mcpServers": {
|
|
168
|
+
"trainbud": {
|
|
169
|
+
"command": "node",
|
|
170
|
+
"args": ["C:/path/to/trainbud/dist/index.js", "start"],
|
|
171
|
+
"env": {
|
|
172
|
+
"GARMIN_EMAIL": "your@email.com",
|
|
173
|
+
"GARMIN_PASSWORD": "yourpassword"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
With `trainbud` on your PATH (`npm install -g trainbud`, or `npm link` from a clone),
|
|
181
|
+
point the client at the command instead of a path:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"mcpServers": {
|
|
186
|
+
"trainbud": {
|
|
187
|
+
"command": "trainbud",
|
|
188
|
+
"args": ["start"]
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Restart your MCP client, then start asking questions.
|
|
195
|
+
|
|
196
|
+
## Tools
|
|
197
|
+
|
|
198
|
+
| Tool | What it answers |
|
|
199
|
+
|------|-----------------|
|
|
200
|
+
| `get_latest_activity` | Your most recent workout — distance, pace, HR, elevation |
|
|
201
|
+
| `get_activities_range` | Activities between two dates |
|
|
202
|
+
| `get_sleep_data` | Sleep duration, stages, score, awakenings |
|
|
203
|
+
| `get_heart_rate_trends` | Resting, max, and average HR over time |
|
|
204
|
+
| `get_recovery_status` | Recovery score from HRV, sleep, stress, resting HR |
|
|
205
|
+
| `get_body_composition` | Weight, body fat, and muscle mass trends |
|
|
206
|
+
| `get_stress_levels` | Daily stress averages and trends |
|
|
207
|
+
| `get_vo2_max_trends` | VO2 max fitness trends over time |
|
|
208
|
+
| `get_training_insights` | Combined weekly summary (activities, sleep, recovery, stress) |
|
|
209
|
+
| `get_findings` | What stands out against **your own** 28-day baselines, not a population average |
|
|
210
|
+
| `get_week_review` | This week against last, the load forecast, sleep debt, and your next race |
|
|
211
|
+
| `remember_context` | Record a goal, a race and its date, an injury, or a note |
|
|
212
|
+
| `get_user_context` | What is on record about you, on any date |
|
|
213
|
+
| `log_subjective` | How a session actually felt — RPE, soreness, mood |
|
|
214
|
+
|
|
215
|
+
## CLI
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
trainbud setup # Interactive first-time setup (recommended)
|
|
219
|
+
trainbud serve # Remote HTTP MCP for web AI (claude.ai, ChatGPT)
|
|
220
|
+
trainbud check # Live diagnostics against all tools
|
|
221
|
+
trainbud doctor # What the watch would see: public URL, AI key, history depth
|
|
222
|
+
trainbud backfill # Pull Garmin history into the local store (resumable)
|
|
223
|
+
trainbud findings # What stands out against your own baselines
|
|
224
|
+
trainbud start # Start the MCP server (stdio)
|
|
225
|
+
trainbud auth # Force re-authentication
|
|
226
|
+
trainbud cache clear # Clear cached data
|
|
227
|
+
trainbud devices # List paired watches
|
|
228
|
+
trainbud devices revoke <id> # Take one watch's access away
|
|
229
|
+
trainbud status # Show session and cache status
|
|
230
|
+
trainbud --version # Print version
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Every one of these also works as `npx trainbud <command>` without installing anything.
|
|
234
|
+
|
|
235
|
+
### Troubleshooting: `trainbud: command not found`
|
|
236
|
+
|
|
237
|
+
Either use `npx trainbud <command>`, or install it globally with
|
|
238
|
+
`npm install -g trainbud`. Running from a clone instead? Run `npm link` once from the
|
|
239
|
+
repo root, or call the built entry point directly with `node dist/index.js doctor`
|
|
240
|
+
(after `npm run build`).
|
|
241
|
+
|
|
242
|
+
## Configuration
|
|
243
|
+
|
|
244
|
+
| Variable | Default | Description |
|
|
245
|
+
|----------|---------|-------------|
|
|
246
|
+
| `GARMIN_EMAIL` | — | Garmin Connect email |
|
|
247
|
+
| `GARMIN_PASSWORD` | — | Garmin Connect password |
|
|
248
|
+
| `TRAINBUD_SESSION_PATH` | `.trainbud/session.json` | Session token storage |
|
|
249
|
+
| `TRAINBUD_LOG_PATH` | `.trainbud/mcp.log` | Log file path |
|
|
250
|
+
| `TRAINBUD_CACHE_PATH` | `.trainbud/cache.db` | SQLite cache database |
|
|
251
|
+
| `CACHE_TTL_ACTIVITIES` | `1800` | Activity cache TTL (seconds) |
|
|
252
|
+
| `CACHE_TTL_SLEEP` | `7200` | Sleep cache TTL (seconds) |
|
|
253
|
+
| `CACHE_TTL_STATS` | `3600` | Stats cache TTL (seconds) |
|
|
254
|
+
| `TRAINBUD_API_KEY` | auto-generated | Bearer token for HTTP MCP (`trainbud serve`) |
|
|
255
|
+
| `TRAINBUD_HOST` | `127.0.0.1` | Bind host for HTTP server |
|
|
256
|
+
| `TRAINBUD_PORT` | `3847` | Bind port for HTTP server |
|
|
257
|
+
|
|
258
|
+
## Security & privacy
|
|
259
|
+
|
|
260
|
+
- Credentials live only in your local `.env` file — never sent to a third party
|
|
261
|
+
- Session tokens in `.trainbud/session.json` are as sensitive as a password
|
|
262
|
+
- Tool errors are sanitized before reaching the AI client
|
|
263
|
+
- Uses the unofficial [`garmin-connect`](https://www.npmjs.com/package/garmin-connect) npm package (not Garmin's enterprise OAuth API)
|
|
264
|
+
- **MFA is not supported** by the underlying library — disable MFA or use an app-specific password
|
|
265
|
+
- The server binds `127.0.0.1` by default. It is only reachable from the internet if
|
|
266
|
+
you point a tunnel at it, and every route except `/health` needs the API key
|
|
267
|
+
- The dashboard takes the key once, on `/dashboard?token=…`, then trades it for an
|
|
268
|
+
`HttpOnly` session cookie and redirects to a clean URL — so the key does not sit in
|
|
269
|
+
your address bar, your history, or a screenshot
|
|
270
|
+
- **A paired watch holds a token scoped to that watch**, minted at pairing and stored
|
|
271
|
+
on the server as a SHA-256 hash. `trainbud devices` lists them, `trainbud devices
|
|
272
|
+
revoke <id>` takes one away — without logging out the dashboard, `/mcp`, or your
|
|
273
|
+
other watches. A watch paired before 0.5.2 holds the API key itself; re-pair it to
|
|
274
|
+
swap that for a scoped token
|
|
275
|
+
- Every response carries `Content-Security-Policy`, `X-Content-Type-Options`,
|
|
276
|
+
`X-Frame-Options` and `Referrer-Policy`, including the 401s. HSTS is sent only on a
|
|
277
|
+
request that actually arrived over TLS, so the loopback dashboard stays reachable
|
|
278
|
+
|
|
279
|
+
### What TrainBud is not
|
|
280
|
+
|
|
281
|
+
- **Not a hosted service.** There is no TrainBud account and no TrainBud server. You run
|
|
282
|
+
it, on your machine, against your own Garmin credentials
|
|
283
|
+
- **Not an official Garmin integration.** It drives an unofficial library against the
|
|
284
|
+
Connect web API. Garmin can change that API without notice, and does
|
|
285
|
+
- **Not MFA-compatible.** If your Connect account has MFA on, this will not log in
|
|
286
|
+
- **Not free to ask.** The AI features run on your own Anthropic key and are billed to
|
|
287
|
+
you. The dashboard meters every call and can refuse past a cap you set
|
|
288
|
+
|
|
289
|
+
## Troubleshooting
|
|
290
|
+
|
|
291
|
+
| Issue | Fix |
|
|
292
|
+
|-------|-----|
|
|
293
|
+
| Authentication failed | Verify `.env` credentials, run `trainbud auth` |
|
|
294
|
+
| MFA enabled on account | Disable MFA or use an app-specific password |
|
|
295
|
+
| Stale data | Run `trainbud cache clear` |
|
|
296
|
+
| Rate limited | Wait 60 seconds; cached responses are used when available |
|
|
297
|
+
| Watch shows "Not a TrainBud server" or error -400 | Your public URL is answering with something that is not TrainBud's JSON — usually a tunnel that is down. Run `trainbud doctor`; it says exactly what came back |
|
|
298
|
+
| Watch shows "Watch not authorised" | The API key changed since the watch paired. Pair it again from the dashboard |
|
|
299
|
+
| Watch shows "AI not set up" | AI is bring-your-own-key. Paste an Anthropic key into the dashboard |
|
|
300
|
+
| No sleep/HR data | Ensure your Garmin device has synced to Garmin Connect |
|
|
301
|
+
| Server won't start | Check that `GARMIN_EMAIL` and `GARMIN_PASSWORD` are set in `.env` |
|
|
302
|
+
|
|
303
|
+
## Development
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
npm install
|
|
307
|
+
npm run build
|
|
308
|
+
npm test # 551 tests via the Node test runner
|
|
309
|
+
npm run lint
|
|
310
|
+
npm run dev # Start with auto-reload
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Use `.nvmrc` with nvm/fnm for Node 20. If your project path contains `#`, use `npm test` instead of `npm run test:vitest`.
|
|
314
|
+
|
|
315
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) and [docs/VAULT.md](./docs/VAULT.md) for architecture and design notes (Obsidian vault, outside this repo).
|
|
316
|
+
|
|
317
|
+
## Roadmap
|
|
318
|
+
|
|
319
|
+
- [x] VO2 max trends
|
|
320
|
+
- [x] Stress levels
|
|
321
|
+
- [x] Training insights
|
|
322
|
+
- [ ] Workout comparison
|
|
323
|
+
- [ ] Docker image
|
|
324
|
+
|
|
325
|
+
## License
|
|
326
|
+
|
|
327
|
+
MIT — see [LICENSE](./LICENSE).
|
|
328
|
+
|
|
329
|
+
Garmin Connect is a trademark of Garmin Ltd. This project is not affiliated with Garmin Ltd.
|