sparky
Use sparky to interact with a self-hosted SparkyFitness server — log food, exercise, weight, steps, and mood.
Install
- - Homebrew (macOS/Linux): INLINECODE1
- Build from source (requires Go 1.21+):
CODEBLOCK0
Setup (once)
- -
sparky config set-url <url> — e.g. INLINECODE3 - INLINECODE4
- INLINECODE5
- INLINECODE6 — verify connection
Food
- - Search:
sparky food search "chicken breast" [-l 10] — local DB first, falls back to Open Food Facts; shows Brand column - Search by barcode:
sparky food search --barcode 4061458284547 — exact product lookup, no ambiguity - Log by name: INLINECODE9
- Log by barcode:
sparky food log --barcode 4061458284547 -m lunch -q 113 -u g — most reliable, no brand guessing - Log by ID:
sparky food log --id <uuid> -m lunch -q 150 -u g — skips search, unambiguous - Pick result:
sparky food log "Hähnchenbrust" --pick 2 — select Nth search result instead of defaulting to results[0] - Diary: INLINECODE13
- Delete entry: INLINECODE14
- Remove from library:
sparky food remove <external_id> — purge a wrongly imported product from local library
Exercise
- - Search:
sparky exercise search "bench press" [-l 10] — local DB first, falls back to Free Exercise DB - Search external only:
sparky exercise search --external "pushup" — bypasses local cache - Log by name: INLINECODE18
- Log by ID:
sparky exercise log --id <uuid> --set 10x80@8 --set 10x80@9 — skips search, unambiguous - Sets format:
REPS[xWEIGHT][@RPE] — e.g. 10x80@8 = 10 reps, 80 kg, RPE 8; 10x80 or 10@8 also valid - Diary: INLINECODE24
- Delete: INLINECODE25
Check-ins
- - Weight: INLINECODE26
- Steps: INLINECODE27
- Mood: INLINECODE28
- Diary:
sparky checkin diary [-d YYYY-MM-DD] — shows biometrics + mood together
Summary & trends
- -
sparky summary [-s YYYY-MM-DD] [-e YYYY-MM-DD] — nutrition/exercise/wellbeing totals (default: last 7 days) - INLINECODE31 — day-by-day nutrition table
Agentic workflow (always prefer --id to avoid ambiguity)
Exercise — search first, then log by ID:
CODEBLOCK1
Food — preferred agentic workflow:
CODEBLOCK2
Notes
- -
-j / --json is a root-level flag: sparky -j food diary, not INLINECODE35 - Always verify brand in search results before logging — Open Food Facts has many products with identical names
- INLINECODE36 is the most reliable option when the product has a scannable barcode
- INLINECODE37 selects the Nth result (1-based); exact local match bypasses
--pick entirely - Both search commands fall back to online providers automatically; matches are added to your library on first log
- Weight is stored in kg; lbs are auto-converted (
166 lbs → 75.30 kg) - Full UUIDs for delete: INLINECODE40
- Meal options:
breakfast, lunch, dinner, snacks (default: snacks)
sparky
使用 sparky 与自托管的 SparkyFitness 服务器交互——记录食物、运动、体重、步数和心情。
安装
- - Homebrew (macOS/Linux): brew tap aronjanosch/tap && brew install sparky-cli
- 从源码构建 (需要 Go 1.21+):
git clone https://github.com/aronjanosch/sparky-cli
cd sparky-cli
go build -o sparky .
sudo mv sparky /usr/local/bin/
设置 (仅一次)
- - sparky config set-url — 例如 sparky config set-url https://sparky.example.com
- sparky config set-key
- sparky config show
- sparky ping — 验证连接
食物
- - 搜索: sparky food search 鸡胸肉 [-l 10] — 优先本地数据库,回退到 Open Food Facts;显示品牌列
- 按条码搜索: sparky food search --barcode 4061458284547 — 精确产品查找,无歧义
- 按名称记录: sparky food log 鸡胸肉 -m lunch -q 150 -u g [-d YYYY-MM-DD]
- 按条码记录: sparky food log --barcode 4061458284547 -m lunch -q 113 -u g — 最可靠,无需猜测品牌
- 按ID记录: sparky food log --id -m lunch -q 150 -u g — 跳过搜索,无歧义
- 选择结果: sparky food log 鸡胸肉 --pick 2 — 选择第N个搜索结果,而非默认使用 results[0]
- 日记: sparky food diary [-d YYYY-MM-DD]
- 删除条目: sparky food delete
- 从库中移除: sparky food remove — 从本地库中清除错误导入的产品
运动
- - 搜索: sparky exercise search 卧推 [-l 10] — 优先本地数据库,回退到 Free Exercise DB
- 仅搜索外部: sparky exercise search --external 俯卧撑 — 绕过本地缓存
- 按名称记录: sparky exercise log 俯卧撑 [--duration 45] [--calories 400] [-d YYYY-MM-DD]
- 按ID记录: sparky exercise log --id --set 10x80@8 --set 10x80@9 — 跳过搜索,无歧义
- 组次格式: REPS[xWEIGHT][@RPE] — 例如 10x80@8 = 10次,80公斤,RPE 8;10x80 或 10@8 同样有效
- 日记: sparky exercise diary [-d YYYY-MM-DD]
- 删除: sparky exercise delete
签到
- - 体重: sparky checkin weight 75.5 [-u kg|lbs] [-d YYYY-MM-DD]
- 步数: sparky checkin steps 9500 [-d YYYY-MM-DD]
- 心情: sparky checkin mood 8 [-n 备注] [-d YYYY-MM-DD]
- 日记: sparky checkin diary [-d YYYY-MM-DD] — 同时显示生物指标和心情
摘要与趋势
- - sparky summary [-s YYYY-MM-DD] [-e YYYY-MM-DD] — 营养/运动/健康总计 (默认: 最近7天)
- sparky trends [-n 30] — 逐日营养表格
代理工作流 (始终优先使用 --id 以避免歧义)
运动 — 先搜索,再按ID记录:
1. 查找候选;必要时使用 --external 绕过本地缓存
sparky -j exercise search --external 俯卧撑
每个结果包含 is_local: true/false
is_local: true → id 是 UUID → 直接使用 --id
is_local: false → id 是源字符串 → 先按精确名称记录以导入,
然后再次搜索获取 UUID
2a. 本地运动
sparky -j exercise log --id
--set 3x10@8
2b. 外部运动 (首次记录时导入,之后切换到 --id)
sparky -j exercise log 俯卧撑 --set 3x10
sparky -j exercise search 俯卧撑 # 现在 is_local: true
sparky -j exercise log --id --set 3x10
食物 — 推荐代理工作流:
选项 A: 条码 (最可靠)
sparky food log --barcode 4061458284547 -q 113 -u g -m lunch
选项 B: 搜索 → 检查品牌+营养成分 → 按 --id 记录
sparky -j food search 鸡胸肉
检查结果中的品牌和卡路里;选择正确的
sparky food log --id -q 400 -u g -m dinner
选项 C: 使用 --pick N 搜索 (当品牌列显示正确选项时)
sparky food log 鸡胸肉 --pick 3 -q 400 -u g -m dinner
从本地库中移除错误导入
sparky food remove id> # externalid 来自搜索结果
注意事项
- - -j / --json 是根级标志: sparky -j food diary,而非 sparky food diary -j
- 记录前务必验证搜索结果中的品牌 — Open Food Facts 中有许多同名产品
- 当产品有可扫描条码时,--barcode 是最可靠的选择
- --pick N 选择第N个结果 (从1开始);精确本地匹配完全绕过 --pick
- 两个搜索命令都会自动回退到在线提供商;匹配项在首次记录时添加到您的库中
- 体重以公斤存储;磅会自动转换 (166 磅 → 75.30 公斤)
- 删除用的完整 UUID: sparky -j food diary | jq .[0].id
- 餐次选项: breakfast, lunch, dinner, snacks (默认: snacks)