中文:R90 是一个可移植的 Agent Skill 和确定性 CLI 工具,用 90 分钟睡眠周期帮助用户围绕目标起床时间规划睡眠窗口,也支持“我要睡了”时反推适合的起床时间,并记录一周完成了多少个 R90 周期。
English: R90 is a portable Agent Skill and deterministic CLI utility for planning sleep around 90-minute recovery cycles. It calculates bedtime windows from a target wake time, suggests wake times from a lights-out time, and records lightweight weekly R90 cycle logs.
安全边界 / Safety Boundary:R90 只提供睡眠计划和自我记录参考,不是医疗建议;它不诊断睡眠问题、不治疗疾病,也不保证睡眠质量。R90 is planning guidance, not medical advice.
- 中文:一个 R90 周期按 90 分钟计算。
English: One R90 cycle is treated as a 90-minute block. - 中文:起床时间是锚点;睡觉窗口从目标起床时间倒推。
English: Wake time is the anchor; bedtime windows are calculated backwards from it. - 中文:默认展示 4、5、6 个周期,方便用户在睡眠时长和现实安排之间选择。
English: The default options are 4, 5, and 6 cycles so users can compare practical choices. - 中文:
wind-down是睡前准备时间,不计入实际睡眠时长。
English: Wind-down is preparation time and is not counted as sleep duration. - 中文:一周追踪用用户自报记录统计,不代表设备验证过的真实睡眠。
English: Weekly tracking uses self-reported logs, not verified sleep measurements. - 中文:遇到严重失眠、疑似睡眠呼吸暂停、长期疲劳等情况,应寻求专业帮助。
English: Severe insomnia, suspected sleep apnea, or long-term fatigue should be handled with professional help.
当前仓库交付的是一个可移植 Agent Skill 和 CLI 工具:
r90_sleep_planner:skill 提示词、回复规则和安全边界。r90_calc.py:确定性计算脚本,负责所有时间和周统计计算。- 本地 JSON 睡眠记录,支持按日期 upsert,不重复记录同一天。
- OpenClaw、Codex、MiClaw 平台适配说明。
- 双轨计算策略:优先使用脚本或 host action;脚本不可用时,
SKILL.md内置算法可降级计算。 self-test内置验证。
目前还没有独立 Web 或移动 App;当前可用入口是 Agent Skill 和 CLI。
- 输入“我明天9点起床”,展示 4/5/6 周期的睡觉窗口。
- 输入“我要睡了”,以当前时间为入睡参考,推荐 4/5/6 周期的起床时间。
- 默认 30 分钟 wind-down,且不计入睡眠时长。
- 支持跨天提示和 IANA 时区。
- 支持早晨低成本打卡:
23:30-07:00、11点半到7点、睡了7.5h、5、跳过。 - 本地周统计:目标默认 35 个周期,最低参考范围默认 28-30 个周期。
- 保守健康文案,不做医疗承诺。
skills/r90-sleep-planner/SKILL.md:通用 skill 指令和回复行为。skills/r90-sleep-planner/scripts/r90_calc.py:CLI 计算器和本地记录工具。skills/r90-sleep-planner/references/data_contracts.md:skill 数据契约。skills/r90-sleep-planner/references/openclaw.md:OpenClaw 安装、cron 和推送说明。skills/r90-sleep-planner/references/codex.md:Codex 安装、执行和自动化说明。skills/r90-sleep-planner/references/miclaw.md:MiClaw 兼容和工具契约说明。DATA-CONTRACTS.md、USER-FLOWS.md、SAFEGUARDS.md、STATE.md:产品级项目记忆。
- Python 3.9 或更新版本。
- 不需要第三方 Python 包。
- 如果作为 skill 部署,宿主需要能读取
SKILL.md。 - 如果要使用确定性计算,宿主需要能执行
python3 scripts/r90_calc.py,或提供等价工具桥接。 - 如果宿主只能读取单个
SKILL.md且不能执行脚本,skill 会按内置 R90 算法降级,但不会声称已经写入本地日志。
| 平台 | 状态 | 推荐用途 |
|---|---|---|
| OpenClaw | 支持单文件 SKILL.md |
聊天 skill、cron 提醒、外部渠道推送;脚本需作为外部工具单独配置 |
| Codex | 支持本地 skills | 本地 skill、CLI 验证、Codex 自动化 |
| MiClaw | 提供适配契约 | 注册为 skill/tool bundle,或暴露脚本为 host action |
| 纯 CLI | 完整支持 | 直接计算和本地 JSON 记录 |
git clone https://github.com/noodlebar/R90.git
cd R90
python3 skills/r90-sleep-planner/scripts/r90_calc.py self-test预期结果:
{
"ok": true,
"tests": ["windows", "wake", "weekly", "record", "checkin"]
}当前 OpenClaw skill 入口按单文件 SKILL.md 使用。把以下文件内容粘贴或上传到 OpenClaw 的 skill 配置中:
skills/r90-sleep-planner/SKILL.md
单文件模式下,skill 会优先尝试调用脚本;如果脚本不可用,就按 SKILL.md 内置算法直接计算 4/5/6 周期、解析 23:30-07:00 这类打卡回复。没有持久化工具时,它只返回解析结果,不会声称已保存。
如果 OpenClaw 有 shell/tool 权限,可以把脚本单独放到固定路径:
~/openclaw-tools/r90_calc.py
然后把 SKILL.md 中的脚本示例改为绝对路径,例如:
python3 ~/openclaw-tools/r90_calc.py wake --now --cycles 4,5,6 --timezone Asia/Shanghai
python3 ~/openclaw-tools/r90_calc.py checkin --reply "23:30-07:00" --date 2026-05-02 --store ~/.r90/sleep-log.json --timezone Asia/Shanghai配置后可检查 skill 是否加载:
openclaw gateway restart
openclaw skills list可测试:
我明天9点起床
我要睡了
当前会话提醒:
openclaw cron add --name "R90 morning check-in" --cron "0 10 * * *" --tz "Asia/Shanghai" --session main --system-event "R90 morning check-in. Send exactly this concise prompt in Chinese: 早,记一下昨晚睡眠。大约几点睡、几点醒?直接回:23:30-07:00。不记就回:跳过. When the user replies, use r90_sleep_planner checkin parsing. Record parsed cycles for yesterday, then respond with the updated weekly total in one short sentence." --wake now外部聊天推送需先确认渠道权限和目标 ID:
openclaw cron add --name "R90 morning check-in" --cron "0 10 * * *" --tz "Asia/Shanghai" --session isolated --message "Return only this plain-text message. Do not wrap it in JSON. Do not output a text field. Message: 早,记一下昨晚睡眠。大约几点睡、几点醒?直接回:23:30-07:00。不记就回:跳过" --announce --channel feishu --to "<verified-chat-target>"如果推送显示成 {"text":"..."},说明 cron message 需要改成纯文本输出。更多说明见 skills/r90-sleep-planner/references/openclaw.md。
复制 skill 到 Codex skills 目录:
mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills/r90-sleep-planner"
cp -R skills/r90-sleep-planner/. "${CODEX_HOME:-$HOME/.codex}/skills/r90-sleep-planner/"验证部署副本:
python3 "${CODEX_HOME:-$HOME/.codex}/skills/r90-sleep-planner/scripts/r90_calc.py" self-test可测试:
我明天 9 点起床,几点睡?
我要睡了,帮我算几个适合的起床时间
早,昨晚 23:30-07:00
如果 Codex 环境提供 automations/reminders,提醒文案应保持纯文本:
早,记一下昨晚睡眠。
大约几点睡、几点醒?直接回:23:30-07:00
不记就回:跳过
用户回复后,再调用 checkin 记录对应睡眠日期。更多说明见 skills/r90-sleep-planner/references/codex.md。
MiClaw 是否能直接加载取决于宿主实现。R90 的最低要求是:
- 能读取
SKILL.md,或把内容注册为系统/工具指令。 - 能执行
python3 scripts/r90_calc.py,或暴露等价 host action。 - 可选:私有本地存储
~/.r90/sleep-log.json。 - 可选:宿主提醒/推送能力。
推荐工具契约:
r90.windows(wakeTime, wakeDate, windDownMinutes=30, cycleOptions=[4,5,6], timezone)
r90.wake(now=true | sleepTime, sleepDate, cycleOptions=[4,5,6], timezone)
r90.checkin(reply, date=yesterday, store="~/.r90/sleep-log.json", timezone)
r90.weekly(weekStart, entriesFile | entriesJson, target=35)
用户可见回复应渲染为纯文本;原始 JSON 只用于调试或内部状态。更多说明见 skills/r90-sleep-planner/references/miclaw.md。
python3 skills/r90-sleep-planner/scripts/r90_calc.py windows \
--wake-time 09:00 \
--wake-date 2026-05-04 \
--wind-down 30 \
--cycles 4,5,6 \
--timezone Asia/Shanghaipython3 skills/r90-sleep-planner/scripts/r90_calc.py wake \
--now \
--cycles 4,5,6 \
--timezone Asia/Shanghaipython3 skills/r90-sleep-planner/scripts/r90_calc.py checkin \
--reply "23:30-07:00" \
--date 2026-05-02 \
--store ~/.r90/sleep-log.json \
--timezone Asia/Shanghaipython3 skills/r90-sleep-planner/scripts/r90_calc.py weekly \
--week-start 2026-04-27 \
--entries-file ~/.r90/sleep-log.json \
--target 35默认本地记录文件:
~/.r90/sleep-log.json
示例记录:
{
"date": "2026-05-02",
"actualCycles": 5,
"plannedCycles": 6,
"note": "optional note",
"updatedAt": "2026-05-03T10:00:00+08:00"
}本项目默认不上传睡眠日志。同一天重复记录会更新已有记录,不会创建重复条目。
我明天9点起床这类快捷指令必须展示默认 4/5/6 周期。我要睡了表示以当前时间为入睡参考,不能复用之前推荐的 bedtime。- 早晨打卡只问大约入睡和起床时间,不要求用户自己计算 R90。
- 计算优先级是脚本、host action、
SKILL.md内置算法;脚本不可用时仍要给出降级结果。 - 定时提醒输出应是纯文本。
- 严重失眠、疑似睡眠呼吸暂停、长期疲劳等情况应提示寻求专业帮助。
R90 currently ships as a portable Agent Skill and deterministic CLI utility:
r90_sleep_planner: skill instructions, response rules, and safety boundaries.r90_calc.py: deterministic calculator used for all arithmetic.- Local JSON logging for self-reported sleep-cycle check-ins.
- Platform adapter notes for OpenClaw, Codex, and MiClaw.
- Dual-track calculation: prefer the script or a host action; fall back to the manual algorithm embedded in
SKILL.mdwhen scripts are unavailable. - Built-in validation through
self-test.
There is no standalone web or mobile app yet. The usable surfaces are the Agent Skill and the bundled CLI script.
- Bedtime windows from a wake target, showing 4, 5, and 6 cycles by default.
- Wake suggestions from a provided lights-out time or from "I am going to sleep now".
- Optional wind-down buffer, defaulting to 30 minutes, kept separate from sleep duration.
- Previous-day and next-day rollover notes.
- IANA timezone support through Python
zoneinfo. - Low-friction check-in parsing, such as
23:30-07:00,slept 7.5h,5, orskip. - Idempotent local sleep-log updates by date.
- Weekly R90 summary with target cycles, minimum useful range, and per-day rows.
- Conservative, non-clinical health language.
skills/r90-sleep-planner/SKILL.md: portable skill instructions and response behavior.skills/r90-sleep-planner/scripts/r90_calc.py: CLI calculator and local log utility.skills/r90-sleep-planner/references/data_contracts.md: skill-level data contracts.skills/r90-sleep-planner/references/openclaw.md: OpenClaw installation, cron, and delivery notes.skills/r90-sleep-planner/references/codex.md: Codex placement, execution, and automation notes.skills/r90-sleep-planner/references/miclaw.md: MiClaw compatibility and tool-contract notes.
- Python 3.9 or newer.
- No third-party Python packages.
- An agent host that can read
SKILL.md, if deploying as a skill. - Shell access to run
python3 scripts/r90_calc.py, or a host tool bridge that exposes the script commands. - If the host can only read a single
SKILL.mdand cannot execute scripts, the skill can still calculate from the embedded R90 rules, but it must not claim local logs were saved.
| Platform | Status | Best Use |
|---|---|---|
| OpenClaw | Supported through single-file SKILL.md |
Chat skill plus cron reminders and external channel delivery; configure the script separately as an external tool |
| Codex | Supported through local skills | Local skill execution, CLI validation, and Codex automations where available |
| MiClaw | Adapter contract provided | Register as a skill/tool bundle or expose script commands as host actions |
| Plain CLI | Fully supported | Direct deterministic calculations and local JSON logs |
git clone https://github.com/noodlebar/R90.git
cd R90
python3 skills/r90-sleep-planner/scripts/r90_calc.py self-testExpected result:
{
"ok": true,
"tests": ["windows", "wake", "weekly", "record", "checkin"]
}OpenClaw uses the skill as a single SKILL.md file. Paste or upload this file into the OpenClaw skill configuration:
skills/r90-sleep-planner/SKILL.md
In single-file mode, the skill will still try to call the script first; if the script is unavailable, it calculates 4/5/6 cycle windows and parses check-ins such as 23:30-07:00 from the embedded rules. Without a persistence tool, it should report the parsed result without claiming the log was saved.
If OpenClaw has shell/tool access, place the script at a stable path:
~/openclaw-tools/r90_calc.py
Then replace script examples in SKILL.md with absolute commands:
python3 ~/openclaw-tools/r90_calc.py wake --now --cycles 4,5,6 --timezone Asia/Shanghai
python3 ~/openclaw-tools/r90_calc.py checkin --reply "23:30-07:00" --date 2026-05-02 --store ~/.r90/sleep-log.json --timezone Asia/ShanghaiCheck skill loading if needed:
openclaw gateway restart
openclaw skills listExample prompts:
I need to wake up at 9 tomorrow.
I am going to sleep now.
Morning reminder, current session:
openclaw cron add --name "R90 morning check-in" --cron "0 10 * * *" --tz "Asia/Shanghai" --session main --system-event "R90 morning check-in. Send exactly this concise prompt in English: Morning check-in. What time did you roughly fall asleep and wake up? Reply like: 23:30-07:00. Reply skip to skip. When the user replies, use r90_sleep_planner checkin parsing. Record parsed cycles for yesterday, then respond with the updated weekly total in one short sentence." --wake nowMore OpenClaw notes are in skills/r90-sleep-planner/references/openclaw.md.
mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills/r90-sleep-planner"
cp -R skills/r90-sleep-planner/. "${CODEX_HOME:-$HOME/.codex}/skills/r90-sleep-planner/"
python3 "${CODEX_HOME:-$HOME/.codex}/skills/r90-sleep-planner/scripts/r90_calc.py" self-testExample prompts:
I need to wake up at 9 tomorrow. What are my sleep windows?
I am going to sleep now. What are good wake times?
If Codex provides automations/reminders, use plain text:
Morning check-in.
What time did you roughly fall asleep and wake up?
Reply like: 23:30-07:00
Reply skip to skip.
More Codex notes are in skills/r90-sleep-planner/references/codex.md.
MiClaw compatibility depends on host support. R90 requires:
- ability to read
SKILL.md, or register it as host instructions. - ability to execute
python3 scripts/r90_calc.py, or expose equivalent host actions. - optional local/private storage for
~/.r90/sleep-log.json. - optional host reminder delivery.
Recommended tool contract:
r90.windows(wakeTime, wakeDate, windDownMinutes=30, cycleOptions=[4,5,6], timezone)
r90.wake(now=true | sleepTime, sleepDate, cycleOptions=[4,5,6], timezone)
r90.checkin(reply, date=yesterday, store="~/.r90/sleep-log.json", timezone)
r90.weekly(weekStart, entriesFile | entriesJson, target=35)
Render user-facing responses as plain text. Keep raw JSON for debugging or internal host state. More MiClaw notes are in skills/r90-sleep-planner/references/miclaw.md.
Calculate bedtime windows:
python3 skills/r90-sleep-planner/scripts/r90_calc.py windows \
--wake-time 09:00 \
--wake-date 2026-05-04 \
--wind-down 30 \
--cycles 4,5,6 \
--timezone Asia/ShanghaiCalculate wake suggestions from now:
python3 skills/r90-sleep-planner/scripts/r90_calc.py wake \
--now \
--cycles 4,5,6 \
--timezone Asia/ShanghaiRecord a check-in:
python3 skills/r90-sleep-planner/scripts/r90_calc.py checkin \
--reply "23:30-07:00" \
--date 2026-05-02 \
--store ~/.r90/sleep-log.json \
--timezone Asia/ShanghaiSummarize a week:
python3 skills/r90-sleep-planner/scripts/r90_calc.py weekly \
--week-start 2026-04-27 \
--entries-file ~/.r90/sleep-log.json \
--target 35Default local log file:
~/.r90/sleep-log.json
Records are local by default and are upserted by date.
- Wake-target shortcuts must show all default 4/5/6 cycle options.
- "I am going to sleep now" means the current time is the lights-out reference.
- Morning check-ins should ask for approximate sleep and wake times, not ask the user to calculate cycles manually.
- Scheduled reminder output should be plain text.
- Severe insomnia, suspected sleep apnea, long-term fatigue, or other health-risk contexts should be handled conservatively and directed toward professional help.
This repository follows a Portfolio OS operating model:
STATE.md: current stage, risks, and next step.SAFEGUARDS.md: safety boundaries and validation baseline.DECISIONS.md: key project decisions.WORKFLOWS.md: reusable workflows.codex/MODES.md:Explore,Build, andReleasedefinitions.DATA-CONTRACTS.md: product-level data contracts.USER-FLOWS.md: calculator user flows.AGENTS.md: multi-agent roles and write boundaries.
R90 is released under the MIT License. See LICENSE for details.