Garmin Tracker
Use this skill when the user asks to sync, rebuild, or validate Garmin training data in garmin_tracking.json (workspace root).
Runtime Prerequisite
- -
playwright-core must be available in the runtime where the skill executes. - If you get
MODULE_NOT_FOUND: playwright-core, install it in the active workspace:
CODEBLOCK0
Scope
- - This skill is intentionally narrow: goal tracking for Garmin runners/users (training history summary + upcoming training-plan).
- Out of scope by default: deep telemetry scraping (GPS route internals, split arrays, cadence/power/elevation raw series).
- Out of scope: nutrition workflow orchestration or external workflow integration.
Hard Rules
- - Control start date is fixed:
2026-02-01. - Keep these top-level fields:
lastUpdate, planName, currentWeek, summary, history, upcoming, recurring_activities. - INLINECODE11 must always be today (
YYYY-MM-DD). - Activities must use this canonical shape:
-
type
-
distanceKm
-
durationSec
-
avgPaceSecPerKm
-
avgHrBpm
-
calories
- INLINECODE19
Browser Flow (Garmin)
- 1. Open Garmin activities list page and collect activities from
2026-02-01 onward. - Open Garmin training plan page (
/app/training-plan) and refresh currentWeek + upcoming. - Keep extraction objective: list/table fields only. No GPS/splits/cadence/power deep scrape.
- If browser action fails, do one in-tool recovery sequence first (
tabs -> focus -> fresh snapshot) before escalation.
Session/Auth Contract
- - The user signs in locally to Garmin in the browser profile used by OpenClaw.
- If Garmin page indicates signed-out session, ask user to sign in and then rerun.
- Do not store user credentials in the skill files.
Authentication (Priority Order)
Use this strict order:
- 1. Logged browser session (preferred): reuse existing authenticated Garmin session.
- Guided manual login in the controlled browser/profile.
- Credentials fallback only if browser login is not possible or explicitly rejected by the user.
INLINECODE27 supports:
- -
--auth-source auto (default): use existing browser session; if signed out and credentials are available, try credentials login. - INLINECODE29 : never use credentials; require manual login.
- INLINECODE30 : require credentials and attempt login directly.
Authentication (User Guidance)
If the user is signed out, guide with explicit steps:
- 1. Ask for manual sign-in in the controlled browser profile:
https://connect.garmin.com/signin/ ->
https://connect.garmin.com/app/training-plan -> rerun sync.
- 2. If browser sign-in is not possible, request credentials as fallback and run credentials mode.
Notes:
- - Authentication policy (browser-first vs credentials-first) may be configured by the operator for each environment.
- In containerized browser setups that expose a remote UI, use the configured noVNC/VNC endpoint to complete login when needed.
- In host-browser mode, sign in directly in the host browser profile configured in OpenClaw.
Credentials Mode (Fallback)
If browser sign-in is not possible, credentials mode can be used as fallback.
Rules:
- 1. Ask only what is strictly required (username/email + password, and 2FA code only if prompted).
- Use credentials only for the login action, then discard from working memory/context when possible.
- Never write credentials to
MEMORY.md, garmin_tracking.json, logs, or skill files. - Never echo credentials back in responses.
- After login success, continue with normal session-based flow.
Data Rebuild Flow
- 1. Read current
garmin_tracking.json. - Preserve
planName and recurring_activities. - Rebuild
history from Garmin activities (>= control start date). - Recompute
summary from rebuilt history. - Set
summary.to to today and lastUpdate to current timestamp.
Local Validator/Reconciler Script
Use the bundled script for schema normalization and summary recomputation:
CODEBLOCK1
Check-only mode:
CODEBLOCK2
Training Plan Sync Script
Use the bundled script to refresh currentWeek and upcoming from Garmin Training Plan:
CODEBLOCK3
Credentials fallback example (last resort):
CODEBLOCK4
CDP resolution priority:
- 1.
--cdp-url (explicit override) - OpenClaw config (
browser.defaultProfile -> browser.profiles.<profile>.cdpUrl) from --config path - fallback to the script default CDP endpoint for local setups (
http://127.0.0.1:<port>)
Override example:
CODEBLOCK5
Minimal Parser Tests
Run parser fixtures:
CODEBLOCK6
Final Checks
- - File is valid JSON.
- No
nutritionLog key exists. - INLINECODE51 are canonical.
- INLINECODE52 equals today.
Garmin Tracker
当用户要求同步、重建或验证 garmin_tracking.json(工作区根目录)中的 Garmin 训练数据时,使用此技能。
运行时前提条件
- - 技能执行时,运行环境中必须提供 playwright-core。
- 如果遇到 MODULENOTFOUND: playwright-core,请在活动工作区中安装:
bash
npm install playwright-core
范围
- - 此技能范围明确限定:Garmin 跑步者/用户的目标追踪(训练历史摘要 + 即将进行的训练计划)。
- 默认不在范围内:深度遥测数据抓取(GPS 路线内部数据、分段数组、步频/功率/海拔原始序列)。
- 不在范围内:营养工作流编排或外部工作流集成。
硬性规则
- - 控制起始日期固定为:2026-02-01。
- 保留以下顶层字段:lastUpdate、planName、currentWeek、summary、history、upcoming、recurring_activities。
- summary.to 必须始终为今天(YYYY-MM-DD 格式)。
- 活动必须使用以下规范结构:
- type
- distanceKm
- durationSec
- avgPaceSecPerKm
- avgHrBpm
- calories
- sourceId
浏览器流程(Garmin)
- 1. 打开 Garmin 活动列表页面,收集从 2026-02-01 开始的活动。
- 打开 Garmin 训练计划页面(/app/training-plan),刷新 currentWeek 和 upcoming。
- 保持提取目标:仅限列表/表格字段。不进行 GPS/分段/步频/功率的深度抓取。
- 如果浏览器操作失败,在升级处理前先执行一次工具内恢复序列(tabs -> focus -> 新的 snapshot)。
会话/认证约定
- - 用户在 OpenClaw 使用的浏览器配置文件中本地登录 Garmin。
- 如果 Garmin 页面显示已登出状态,请用户登录后重新运行。
- 不要在技能文件中存储用户凭据。
认证(优先级顺序)
使用以下严格顺序:
- 1. 已登录的浏览器会话(首选):重用现有的已认证 Garmin 会话。
- 在受控浏览器/配置文件中引导手动登录。
- 仅当浏览器登录不可行或用户明确拒绝时,才使用凭据回退方案。
synctrainingplan.mjs 支持:
- - --auth-source auto(默认):使用现有浏览器会话;如果已登出且凭据可用,则尝试凭据登录。
- --auth-source browser:绝不使用凭据;需要手动登录。
- --auth-source credentials:需要凭据并直接尝试登录。
认证(用户引导)
如果用户已登出,请按以下明确步骤引导:
- 1. 要求在受控浏览器配置文件中手动登录:
https://connect.garmin.com/signin/ -> https://connect.garmin.com/app/training-plan -> 重新运行同步。
- 2. 如果浏览器登录不可行,请求凭据作为回退方案并运行凭据模式。
注意:
- - 认证策略(浏览器优先 vs 凭据优先)可由操作员为每个环境配置。
- 在暴露远程 UI 的容器化浏览器设置中,需要时使用配置的 noVNC/VNC 端点完成登录。
- 在主机浏览器模式下,直接在 OpenClaw 配置的主机浏览器配置文件中登录。
凭据模式(回退方案)
如果浏览器登录不可行,可以使用凭据模式作为回退方案。
规则:
- 1. 仅询问严格必要的信息(用户名/邮箱 + 密码,以及仅在提示时询问 2FA 验证码)。
- 仅将凭据用于登录操作,之后尽可能从工作内存/上下文中丢弃。
- 切勿将凭据写入 MEMORY.md、garmin_tracking.json、日志或技能文件中。
- 切勿在回复中回显凭据。
- 登录成功后,继续使用正常的基于会话的流程。
数据重建流程
- 1. 读取当前的 garmintracking.json。
- 保留 planName 和 recurringactivities。
- 从 Garmin 活动(>= 控制起始日期)重建 history。
- 从重建的 history 重新计算 summary。
- 将 summary.to 设置为今天,lastUpdate 设置为当前时间戳。
本地验证器/协调器脚本
使用捆绑脚本进行模式规范化和摘要重新计算:
bash
python3 {baseDir}/scripts/reconciletracking.py --file garmintracking.json --write
仅检查模式:
bash
python3 {baseDir}/scripts/reconciletracking.py --file garmintracking.json
训练计划同步脚本
使用捆绑脚本从 Garmin 训练计划刷新 currentWeek 和 upcoming:
bash
node {baseDir}/scripts/synctrainingplan.mjs --file garmin_tracking.json --write
凭据回退示例(最后手段):
bash
node {baseDir}/scripts/synctrainingplan.mjs \
--auth-source credentials \
--garmin-email user@example.com \
--garmin-password * \
--file garmin_tracking.json \
--write
CDP 解析优先级:
- 1. --cdp-url(显式覆盖)
- 来自 --config 路径的 OpenClaw 配置(browser.defaultProfile -> browser.profiles..cdpUrl)
- 回退到本地设置的脚本默认 CDP 端点(http://127.0.0.1:)
覆盖示例:
bash
node {baseDir}/scripts/synctrainingplan.mjs --config data/config/openclaw.json --url https://connect.garmin.com/app/training-plan --file garmin_tracking.json --write
最小化解析器测试
运行解析器测试用例:
bash
node --test {baseDir}/scripts/tests/trainingplanparser.test.mjs
最终检查
- - 文件为有效 JSON。
- 不存在 nutritionLog 键。
- history[].activities[] 符合规范结构。
- summary.to 等于今天。