经期/周期追踪
周期不规律,总措手不及。
适用场景
- 记录开始/结束日
- 预测下次与排卵期
- 标症状
核心能力
脚 本
c y c l e . p y
存 于
~ / . h e a l t h / c y c l e . j s o n
:
`
b
a
s
h
S K I L L
~ / . w o r k b u d d y / s k i l l s / d w
c y c l e
t r a c k e r
p y t h o n 3
$ S K I L L / c y c l e . p y
s t a r t
2 0 2 6
0 7
0 1
p y t h o n 3
$ S K I L L / c y c l e . p y
p r e d i c t
`
执行方式
本 skill 为工作流型,由 agent 按以下步骤执行,无需额外脚本:
上次 2026-07-01 周期28天
预计下次 2026-07-29 排卵约 07-15
示例
('cycle.py', '#!/usr/bin/env python3n# -- coding: utf-8 --n"""周期追踪:本地 JSON,预测下次与排卵。"""nimport argparse, json, osnfrom datetime import date, timedeltanPATH = os.path.expanduser("~/.health/cycle.json")nndef load():n if not os.path.exists(PATH): return {"records":[]}n with open(PATH, encoding="utf-8") as f: return json.load(f)nndef save(d):n os.makedirs(os.path.dirname(PATH), exist_ok=True)n with open(PATH,"w",encoding="utf-8") as f: json.dump(d,f,ensure_ascii=False,indent=2)nndef main():n p=argparse.ArgumentParser(description="周期追踪")n sub=p.subparsers(dest="c")n ps=sub.add_parser("start"); ps.add_argument("ymd")n def start(a):n d=load(); d["records"].append(a.ymd); d["cycle"]=d.get("cycle",28); save(d)n print("已记录开始 %s" % a.ymd)n ps.set_defaults(f=start)n pp=sub.add_parser("predict")n def predict(a):n d=load(); recs=d.get("records",[])n if not recs: print("暂无记录"); returnn last=date.fromisoformat(recs[-1]); cyc=d.get("cycle",28)n nxt=last+timedelta(days=cyc); ov=last+timedelta(days=cyc-14)n print("上次 %s 周期%d天n预计下次 %s 排卵约 %s" % (recs[-1], cyc, nxt.isoformat(), ov.isoformat()))n pp.set_defaults(f=predict)n args=p.parse_args()n if not args.c: p.print_help(); returnn args.f(args)nnif name=="main":n main()n')