跳到主要内容

健身营养

健身房训练计划器和营养追踪器。通过 wger 按肌肉、器械或类别搜索 690+ 种练习。通过 USDA FoodData Central 查询 380,000+ 种食物的宏量营养素和卡路里。计算 BMI、TDEE、单次最大重量(1RM)、宏量营养素分配比例和体脂率——纯 Python 实现,无需 pip 安装。专为追求增肌、减重或只是希望吃得更健康的人士打造。

技能元数据

来源可选 — 使用 hermes skills install official/health/fitness-nutrition 安装
路径optional-skills/health/fitness-nutrition
版本1.0.0
许可证MIT
标签health, fitness, nutrition, gym, workout, diet, exercise

参考:完整 SKILL.md

信息

以下是 Hermes 在触发此技能时加载的完整技能定义。这是技能激活时代理看到的指令。

健身与营养

专家级健身教练和运动营养师技能。两个数据源加上离线计算器——将健身人士所需的一切整合于一处。

数据源(全部免费,无 pip 依赖):

  • wger (https://wger.de/api/v2/) — 开放练习数据库,包含 690+ 种练习,涵盖肌肉、器械和图片。公共端点无需身份验证。
  • USDA FoodData Central (https://api.nal.usda.gov/fdc/v1/) — 美国政府营养数据库,包含 380,000+ 种食物。DEMO_KEY 可立即使用;免费注册可获得更高限额。

离线计算器(纯 Python 标准库):

  • BMI、TDEE(Mifflin-St Jeor 公式)、单次最大重量(Epley/Brzycki/Lombardi 公式)、宏量营养素分配比例、体脂率百分比(美国海军方法)

何时使用

当用户询问以下内容时触发此技能:

  • 练习、训练、健身房常规、肌群、训练分化
  • 食物宏量营养素、卡路里、蛋白质含量、膳食计划、卡路里计数
  • 身体成分:BMI、体脂率、TDEE、热量盈余/赤字
  • 单次最大重量估算、训练百分比、渐进超负荷
  • 用于减脂、增肌或维持的宏量营养素比例

流程

练习查询(wger API)

所有 wger 公共端点均返回 JSON 且无需身份验证。始终在练习查询中添加 format=jsonlanguage=2(英语)。

步骤 1 — 确定用户需求:

  • 按肌肉 → 使用 /api/v2/exercise/?muscles={id}&language=2&status=2&format=json
  • 按类别 → 使用 /api/v2/exercise/?category={id}&language=2&status=2&format=json
  • 按器械 → 使用 /api/v2/exercise/?equipment={id}&language=2&status=2&format=json
  • 按名称 → 使用 /api/v2/exercise/search/?term={query}&language=english&format=json
  • 完整详情 → 使用 /api/v2/exerciseinfo/{exercise_id}/?format=json

步骤 2 — 参考 ID(因此无需额外的 API 调用):

练习类别:

ID类别
8手臂
9腿部
10腹部
11胸部
12背部
13肩部
14小腿
15有氧

肌肉:

ID肌肉ID肌肉
1肱二头肌2三角肌前束
3前锯肌4胸大肌
5腹外斜肌6腓肠肌
7腹直肌8臀大肌
9斜方肌10股四头肌
11股二头肌12背阔肌
13肱肌14肱三头肌
15比目鱼肌

器械:

ID器械
1杠铃
3哑铃
4健身垫
5瑞士球
6引体向上杆
7无(自重)
8长凳
9上斜凳
10壶铃

步骤 3 — 获取并展示结果:

# Search exercises by name
QUERY="$1"
ENCODED=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$QUERY")
curl -s "https://wger.de/api/v2/exercise/search/?term=${ENCODED}&language=english&format=json" \
| python3 -c "
import json,sys
data=json.load(sys.stdin)
for s in data.get('suggestions',[])[:10]:
d=s.get('data',{})
print(f\" ID {d.get('id','?'):>4} | {d.get('name','N/A'):<35} | Category: {d.get('category','N/A')}\")
"
# Get full details for a specific exercise
EXERCISE_ID="$1"
curl -s "https://wger.de/api/v2/exerciseinfo/${EXERCISE_ID}/?format=json" \
| python3 -c "
import json,sys,html,re
data=json.load(sys.stdin)
trans=[t for t in data.get('translations',[]) if t.get('language')==2]
t=trans[0] if trans else data.get('translations',[{}])[0]
desc=re.sub('<[^>]+>','',html.unescape(t.get('description','N/A')))
print(f\"Exercise : {t.get('name','N/A')}\")
print(f\"Category : {data.get('category',{}).get('name','N/A')}\")
print(f\"Primary : {', '.join(m.get('name_en','') for m in data.get('muscles',[])) or 'N/A'}\")
print(f\"Secondary : {', '.join(m.get('name_en','') for m in data.get('muscles_secondary',[])) or 'none'}\")
print(f\"Equipment : {', '.join(e.get('name','') for e in data.get('equipment',[])) or 'bodyweight'}\")
print(f\"How to : {desc[:500]}\")
imgs=data.get('images',[])
if imgs: print(f\"Image : {imgs[0].get('image','')}\")
"
# List exercises filtering by muscle, category, or equipment
# Combine filters as needed: ?muscles=4&equipment=1&language=2&status=2
FILTER="$1" # e.g. "muscles=4" or "category=11" or "equipment=3"
curl -s "https://wger.de/api/v2/exercise/?${FILTER}&language=2&status=2&limit=20&format=json" \
| python3 -c "
import json,sys
data=json.load(sys.stdin)
print(f'Found {data.get(\"count\",0)} exercises.')
for ex in data.get('results',[]):
print(f\" ID {ex['id']:>4} | muscles: {ex.get('muscles',[])} | equipment: {ex.get('equipment',[])}\")
"

营养查询(USDA FoodData Central)

如果设置了 USDA_API_KEY 环境变量则使用它,否则回退到 DEMO_KEY。 DEMO_KEY = 30 次请求/小时。免费注册密钥 = 1,000 次请求/小时。

# Search foods by name
FOOD="$1"
API_KEY="${USDA_API_KEY:-DEMO_KEY}"
ENCODED=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$FOOD")
curl -s "https://api.nal.usda.gov/fdc/v1/foods/search?api_key=${API_KEY}&query=${ENCODED}&pageSize=5&dataType=Foundation,SR%20Legacy" \
| python3 -c "
import json,sys
data=json.load(sys.stdin)
foods=data.get('foods',[])
if not foods: print('No foods found.'); sys.exit()
for f in foods:
n={x['nutrientName']:x.get('value','?') for x in f.get('foodNutrients',[])}
cal=n.get('Energy','?'); prot=n.get('Protein','?')
fat=n.get('Total lipid (fat)','?'); carb=n.get('Carbohydrate, by difference','?')
print(f\"{f.get('description','N/A')}\")
print(f\" Per 100g: {cal} kcal | {prot}g protein | {fat}g fat | {carb}g carbs\")
print(f\" FDC ID: {f.get('fdcId','N/A')}\")
print()
"
# Detailed nutrient profile by FDC ID
FDC_ID="$1"
API_KEY="${USDA_API_KEY:-DEMO_KEY}"
curl -s "https://api.nal.usda.gov/fdc/v1/food/${FDC_ID}?api_key=${API_KEY}" \
| python3 -c "
import json,sys
d=json.load(sys.stdin)
print(f\"Food: {d.get('description','N/A')}\")
print(f\"{'Nutrient':<40} {'Amount':>8} {'Unit'}\")
print('-'*56)
for x in sorted(d.get('foodNutrients',[]),key=lambda x:x.get('nutrient',{}).get('rank',9999)):
nut=x.get('nutrient',{}); amt=x.get('amount',0)
if amt and float(amt)>0:
print(f\" {nut.get('name',''):<38} {amt:>8} {nut.get('unitName','')}\")
"

离线计算器

使用 scripts/ 中的辅助脚本进行批量操作, 或运行内联命令进行单次计算:

  • python3 scripts/body_calc.py bmi <weight_kg> <height_cm>
  • python3 scripts/body_calc.py tdee <weight_kg> <height_cm> <age> <M|F> <activity 1-5>
  • python3 scripts/body_calc.py 1rm <weight> <reps>
  • python3 scripts/body_calc.py macros <tdee_kcal> <cut|maintain|bulk>
  • python3 scripts/body_calc.py bodyfat <M|F> <neck_cm> <waist_cm> [hip_cm] <height_cm>

请参阅 references/FORMULAS.md 了解每个公式背后的科学原理。


常见陷阱

  • wger 运动端点默认返回所有语言——始终添加 language=2 以获取英语内容
  • wger 包含未验证的用户提交内容——添加 status=2 以仅获取已审核的运动项目
  • USDA DEMO_KEY 的限制为每小时 30 次请求——在批量请求之间添加 sleep 2,或申请免费密钥
  • USDA 数据基于每 100 克——提醒用户根据实际份量进行换算
  • BMI 无法区分肌肉和脂肪——肌肉发达的人的高 BMI 不一定表示不健康
  • 体脂公式仅为估算值(误差 ±3-5%)——如需精确结果,建议进行 DEXA 扫描
  • 1RM 公式在超过 10 次重复时准确性下降——使用 3-5 次的组数以获得最佳估算
  • wger 的 exercise/search 端点使用 term 而非 query 作为参数名

验证

运行运动搜索后:确认结果包含运动名称、肌群和器械。 查询营养信息后:确认返回每 100 克的宏量营养素,包括热量(kcal)、蛋白质、脂肪和碳水化合物。 运行计算器后:对输出进行合理性检查(例如,大多数成年人的 TDEE 应在 1500-3500 之间)。


快速参考

任务来源端点
按名称搜索运动wgerGET /api/v2/exercise/search/?term=&language=english
运动详情wgerGET /api/v2/exerciseinfo/{id}/
按肌群筛选wgerGET /api/v2/exercise/?muscles={id}&language=2&status=2
按器械筛选wgerGET /api/v2/exercise/?equipment={id}&language=2&status=2
列出分类wgerGET /api/v2/exercisecategory/
列出肌群wgerGET /api/v2/muscle/
搜索食物USDAGET /fdc/v1/foods/search?query=&dataType=Foundation,SR Legacy
食物详情USDAGET /fdc/v1/food/{fdcId}
BMI / TDEE / 1RM / 宏量营养素离线python3 scripts/body_calc.py