Workout Log
Parses strength training sessions from natural or structured input and inserts them into the sport schema of life_db.
Connection
Credentials are in ~/.openclaw/services/life-db/.env.
Workflow
1. Parse the user's message
Extract from free text or structured input:
| Field | Type | Notes |
|---|
| INLINECODE3 | YYYY-MM-DD | Default: today |
| INLINECODE4 |
int | Total session duration |
|
feeling | 1–10 integer | Overall session feeling |
|
notes | string | Optional — program name, injuries, etc. |
|
exercises[] | array | One object per exercise |
Each exercise:
| Field | Type | Notes |
|---|
| INLINECODE8 | string | Normalize consistently (e.g. "Bench Press", "Squat", "Romanian Deadlift") |
| INLINECODE9 |
int | Number of working sets |
|
reps | int | Reps per set (use average if varied) |
|
weight_kg | float | Working weight —
null for bodyweight exercises |
|
rpe | float | Rate of perceived exertion (1–10), optional |
|
rest_sec | int | Rest between sets in seconds, optional |
|
order_in_session | int | Order as mentioned |
|
notes | string | Optional — tempo, drop sets, supersets, etc. |
2. Confirm with the user
Show a summary before inserting:
CODEBLOCK0
3. Insert
Only after confirmation, use the exec tool:
CODEBLOCK1
Replace <json> with the minified JSON payload (no newlines, properly shell-escaped).
4. Confirm result
On OK — respond with exactly this format, nothing more:
CODEBLOCK2
INLINECODE20 rules — 1 line, max 60 chars, no emoji:
- - feeling ≥ 8 → short hype line
- feeling 5–7 → encouragement
- feeling ≤ 4 → grind acknowledgement
On ERROR — report the error as-is, do not retry without user input.
Examples
| User says | Parsed session |
|---|
| "Gym 1h feeling 8. Bench 4x10 80kg, Squat 4x8 100kg, Curl 3x12 15kg" | 3 exercises, 60 min, feeling 8/10 |
| "45 min chest/shoulders. Bench press 5x5 90kg RPE 9, overhead press 4x8 40kg, lateral raises 3x15 10kg" |
3 exercises, 45 min, feeling asked |
| "Quick session 30min: pull-ups 4x8 bodyweight, rows 4x10 60kg" | 2 exercises, 30 min, feeling asked |
训练日志
从自然语言或结构化输入中解析力量训练课程,并将其插入到 life_db 数据库的 sport 模式中。
连接
凭证信息位于 ~/.openclaw/services/life-db/.env 文件中。
工作流程
1. 解析用户消息
从自由文本或结构化输入中提取以下信息:
| 字段 | 类型 | 备注 |
|---|
| sessiondate | YYYY-MM-DD | 默认值:今天 |
| durationmin |
整数 | 训练总时长 |
| feeling | 1–10 整数 | 训练整体感受 |
| notes | 字符串 | 可选 — 训练计划名称、伤病情况等 |
| exercises[] | 数组 | 每个动作一个对象 |
每个动作:
| 字段 | 类型 | 备注 |
|---|
| exercise_name | 字符串 | 统一规范化命名(例如卧推、深蹲、罗马尼亚硬拉) |
| sets |
整数 | 正式组数 |
| reps | 整数 | 每组次数(如有变化取平均值) |
| weight_kg | 浮点数 | 训练重量 — 自重训练为 null |
| rpe | 浮点数 | 主观疲劳评分(1–10),可选 |
| rest_sec | 整数 | 组间休息时间(秒),可选 |
| order
insession | 整数 | 训练中的顺序 |
| notes | 字符串 | 可选 — 节奏、递减组、超级组等 |
2. 与用户确认
在插入前显示摘要:
📅 {DD/MM/YYYY} · 力量训练 · {duration} 分钟 · 感受 {feeling}/10
• {动作1} — {sets}×{reps} @ {weight} 公斤
• {动作2} — {sets}×{reps} 自重
• …
是否保存?(是 / 否)
3. 插入操作
仅在确认后,使用 exec 工具:
json
{
tool: exec,
command: bash -c set -a; source ~/.openclaw/services/life-db/.env; uv run --project ~/.openclaw {baseDir}/scripts/insert_workout.py
}
将 替换为压缩后的 JSON 数据(无换行,正确进行 shell 转义)。
4. 确认结果
如果返回 OK — 严格按照以下格式回复,不多不少:
✅ 力量训练 · {duration} 分钟 · 感受 {feeling}/10 · #{session_id}
{评论}
{评论} 规则 — 1行,最多60个字符,无表情符号:
- - 感受 ≥ 8 → 简短激励语
- 感受 5–7 → 鼓励语
- 感受 ≤ 4 → 坚持认可语
如果返回 ERROR — 直接报告错误,未经用户输入不得重试。
示例
| 用户输入 | 解析结果 |
|---|
| 健身房1小时感受8。卧推4x10 80公斤,深蹲4x8 100公斤,弯举3x12 15公斤 | 3个动作,60分钟,感受8/10 |
| 45分钟胸/肩。卧推5x5 90公斤 RPE 9,过顶推举4x8 40公斤,侧平举3x15 10公斤 |
3个动作,45分钟,感受待询问 |
| 快速训练30分钟:引体向上4x8自重,划船4x10 60公斤 | 2个动作,30分钟,感受待询问 |