Skill: jiajiaoy/daily-sleep (version 1.0.3)

--- name: daily-sleep description: "Sleep better tonight — personalized wind-down routine, breathing exercises, bedtime stories, and sleep hygiene tips. Daily evening push for better rest." keywords: - 失眠 - 睡不好 - 助眠 - 睡眠 - 睡前放松 - 入睡困难 - 睡眠质量 - 帮我睡觉 - 睡眠问题 - 深度睡眠 - 睡前仪式 - 睡眠卫生 - 午睡 - 亚健康 - 睡眠不足 - 早睡早起 - 睡眠改善 - sleep - insomnia - sleep aid - bedtime routine - sleep quality - can't sleep - deep sleep - sleep hygiene - sleep coach - wind down - relaxation - sleep tips - better sleep - nap - wake up routine - morning routine metadata: openclaw: runtime: node: ">=18" --- # 睡眠助手 > 睡眠助手 — 晨间唤醒 · 睡前放松 · 助眠引导 · 失眠改善 ## 何时使用 - 用户说"失眠""睡不好""帮我睡觉" - 用户说"睡前放松""助眠""入睡困难" - 用户说"sleep""insomnia""can't sleep" - 用户说"睡眠质量差""怎么改善睡眠" --- ## 推送管理 ```bash node scripts/push-toggle.js on <userId> node scripts/push-toggle.js on <userId> --morning 07:00 --evening 22:00 --channel feishu node scripts/push-toggle.js off <userId> node scripts/push-toggle.js status <userId> ``` 支持渠道：`telegram` / `feishu` / `slack` / `discord`

path: README.md
content: # Daily Sleep — Sleep Coach Skill

> Morning wake-up routine + evening wind-down — science-backed tips for better sleep and insomnia relief.

[![clawhub](https://img.shields.io/badge/clawhub-daily--sleep-blue)](https://clawhub.ai/skills/daily-sleep)
[![openclaw](https://img.shields.io/badge/openclaw-skill-orange)](https://openclaw.ai)

An [OpenClaw](https://openclaw.ai) skill that acts as your personal sleep coach — a morning wake-up routine to start the day energized, and an evening wind-down program to fall asleep naturally. Covers the largest health pain point: insomnia and poor sleep quality.

---

## Features

- **Morning Wake-Up** — Sleep quality self-review, 5-min activation routine, caffeine cutoff reminder
- **Evening Wind-Down** — Pre-sleep 90-min checklist, 4-7-8 breathing, progressive muscle relaxation
- **Sleep Environment Guide** — Temperature, light, noise, phone tips
- **2-Minute Bedtime Meditation** — Guided mindfulness for falling asleep
- **Daily Sleep Tips** — Circadian rhythm advice by day of week
- **Science-based** — Draws from CBT-I, sleep hygiene research, and mindfulness

---

## Daily Push Schedule

| Push | Time | Content |
|------|------|---------|
| Morning | 07:00 | Wake-up routine + sleep quality review + today's sleep tip |
| Evening | 22:00 | Wind-down program + breathing guide + bedtime meditation |

```bash
node scripts/push-toggle.js on <userId>
node scripts/push-toggle.js on <userId> --morning 07:00 --evening 22:00 --channel telegram
node scripts/push-toggle.js off <userId>
node scripts/push-toggle.js status <userId>
```

Supported channels: `telegram` / `feishu` / `slack` / `discord`

---

## Trigger Words

失眠、睡不好、助眠、睡前放松、入睡困难、睡眠质量、sleep、insomnia、sleep aid、bedtime routine、can't sleep、deep sleep、sleep hygiene、wind down

---

*MIT License · OpenClaw Skill*

## Keywords

sleep · insomnia · sleep aid · bedtime routine · daily sleep · sleep coach · 失眠 · 睡不好 · 助眠 · 睡前放松 · 睡眠质量 · 入睡困难

---

Built for [OpenClaw](https://openclaw.ai) · Published on [clawhub.ai](https://clawhub.ai/skills/daily-sleep)


path: _meta.json
content: {
  "slug": "daily-sleep",
  "version": "1.0.0",
  "runtime": {
    "node": ">=18"
  },
  "ownerId": "kn79bebfnwg15sb0g7cj5z5nyd83gxh0"
}

path: package.json
content: {
  "name": "daily-sleep",
  "version": "1.0.2",
  "description": "Sleep better tonight — personalized wind-down routine, breathing exercises, bedtime stories, and sleep hygiene tips. Daily evening push for better rest.",
  "engines": {
    "node": ">=18"
  },
  "license": "MIT"
}

path: scripts/evening-push.js
content: #!/usr/bin/env node
'use strict';
const fs=require('fs'),path=require('path');
const USERS_DIR=path.join(__dirname,'../data/users');
function sanitizeId(v){if(typeof v!=='string'||!/^[a-zA-Z0-9_-]{1,128}$/.test(v)){console.error('invalid userId');process.exit(1);}return v;}
function safeUserPath(u){const r=path.resolve(USERS_DIR,u+'.json');if(!r.startsWith(path.resolve(USERS_DIR)+path.sep)){console.error('illegal path');process.exit(1);}return r;}
function loadUser(u){const f=safeUserPath(u);return fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')):{};}
const userId=sanitizeId(process.argv[2]||'default');
loadUser(userId);
const now=new Date();
const WEEKDAYS=['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
const wd=now.getDay();
const date=`${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`;
const weekday=WEEKDAYS[wd];
const month=now.getMonth()+1;
const day=now.getDate();
const tomorrow_weekday=WEEKDAYS[(wd+1)%7];
console.log(`睡前放松时间🌙（${date}）。请生成今晚睡眠引导程序：①睡前90分钟清单（该做/不该做各3条）②今晚放松程序（4-7-8呼吸引导+渐进式肌肉放松，3步）③睡眠环境检查（温度/光线/噪音/手机各1条建议）④今晚助眠冥想引导（2分钟正念入睡引导语）⑤明日唤醒预告（提醒明天最重要的1件事，放下，安心入睡）。语气极度舒缓，帮助用户自然入睡。`);


path: scripts/morning-push.js
content: #!/usr/bin/env node
'use strict';
const fs=require('fs'),path=require('path');
const USERS_DIR=path.join(__dirname,'../data/users');
function sanitizeId(v){if(typeof v!=='string'||!/^[a-zA-Z0-9_-]{1,128}$/.test(v)){console.error('invalid userId');process.exit(1);}return v;}
function safeUserPath(u){const r=path.resolve(USERS_DIR,u+'.json');if(!r.startsWith(path.resolve(USERS_DIR)+path.sep)){console.error('illegal path');process.exit(1);}return r;}
function loadUser(u){const f=safeUserPath(u);return fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')):{};}
const userId=sanitizeId(process.argv[2]||'default');
loadUser(userId);
const now=new Date();
const WEEKDAYS=['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
const wd=now.getDay();
const date=`${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`;
const weekday=WEEKDAYS[wd];
const month=now.getMonth()+1;
const day=now.getDate();
const tomorrow_weekday=WEEKDAYS[(wd+1)%7];
console.log(`早安！今天是${weekday}（${date}）。请生成晨间唤醒引导：①昨晚睡眠质量自评引导（3个问题：入睡时间/醒来次数/精神状态）②今日唤醒程序（5分钟晨间激活：呼吸+拉伸+光线建议）③今日睡眠小贴士1条（针对${weekday}的节律建议）④今日咖啡因截止时间提醒（根据最佳睡眠时间倒推）。语气积极温暖，帮助用户精力满满开始新的一天。`);


path: scripts/push-toggle.js
content: #!/usr/bin/env node
'use strict';
const fs=require('fs'),path=require('path');
const SKILL='daily-sleep',DEFAULT_MORNING='07:00',DEFAULT_EVENING='22:00';
const USERS_DIR=path.join(__dirname,'../data/users');
const ALLOWED_CH=new Set(['telegram','feishu','slack','discord']);
function sanitizeId(v){if(typeof v!=='string'||!/^[a-zA-Z0-9_-]{1,128}$/.test(v)){console.error('invalid userId');process.exit(1);}return v;}
function sanitizeTime(v,l){if(!/^\d{1,2}:\d{2}$/.test(v)){console.error('invalid '+l);process.exit(1);}const[h,m]=v.split(':').map(Number);if(h>23||m>59){console.error('invalid '+l);process.exit(1);}return{h,m};}
function safeUserPath(u){const r=path.resolve(USERS_DIR,u+'.json');if(!r.startsWith(path.resolve(USERS_DIR)+path.sep)){console.error('illegal path');process.exit(1);}return r;}
function loadUser(u){const f=safeUserPath(u);return fs.existsSync(f)?JSON.parse(fs.readFileSync(f,'utf8')):{};}
function saveUser(u,d){fs.mkdirSync(USERS_DIR,{recursive:true});fs.writeFileSync(safeUserPath(u),JSON.stringify(d,null,2),'utf8');}
function enablePush(userId,opts){
  userId=sanitizeId(userId);
  const user=loadUser(userId);
  const mt=opts.morning||user.morningTime||DEFAULT_MORNING;
  const et=opts.evening||user.eveningTime||DEFAULT_EVENING;
  const{h:mh,m:mm}=sanitizeTime(mt,'--morning');
  const{h:eh,m:em}=sanitizeTime(et,'--evening');
  const ch=opts.channel||user.channel||'telegram';
  if(!ALLOWED_CH.has(ch)){console.error('unsupported channel:'+ch);process.exit(1);}
  const sk=`agent:main:${ch}:direct:${userId}`;
  console.log('__OPENCLAW_CRON_ADD__:'+JSON.stringify({name:`${SKILL}-morning-${userId}`,cronExpr:`${mm} ${mh} * * *`,tz:'Asia/Shanghai',session:'isolated',sessionKey:sk,channel:ch,to:userId,announce:true,timeoutSeconds:180,message:`node ${path.join(__dirname,'morning-push.js')} ${userId}`}));
  console.log('__OPENCLAW_CRON_ADD__:'+JSON.stringify({name:`${SKILL}-evening-${userId}`,cronExpr:`${em} ${eh} * * *`,tz:'Asia/Shanghai',session:'isolated',sessionKey:sk,channel:ch,to:userId,announce:true,timeoutSeconds:180,message:`node ${path.join(__dirname,'evening-push.js')} ${userId}`}));
  saveUser(userId,{...user,morningTime:mt,eveningTime:et,channel:ch,pushEnabled:true,updatedAt:new Date().toISOString()});
  console.log(`\n✅ ${SKILL} 推送已开启\n⏰ 早推: ${mt}  🌙 晚推: ${et}  📡 渠道: ${ch}\n关闭: node push-toggle.js off ${userId}`);
}
function disablePush(userId){
  userId=sanitizeId(userId);
  console.log(`__OPENCLAW_CRON_RM__:${SKILL}-morning-${userId}`);
  console.log(`__OPENCLAW_CRON_RM__:${SKILL}-evening-${userId}`);
  saveUser(userId,{...loadUser(userId),pushEnabled:false,updatedAt:new Date().toISOString()});
  console.log(`✅ ${SKILL} 推送已关闭`);
}
function showStatus(userId){
  userId=sanitizeId(userId);
  const u=loadUser(userId);
  console.log(`\n📡 ${SKILL} — ${userId}\n状态: ${u.pushEnabled?'✅ 开启':'❌ 关闭'}  早推: ${u.morningTime||DEFAULT_MORNING}  晚推: ${u.eveningTime||DEFAULT_EVENING}  渠道: ${u.channel||'telegram'}\n`);
}
if(require.main!==module)return;
const[cmd,uid,...rest]=process.argv.slice(2);
if(!cmd||!uid){console.log('Usage: node push-toggle.js on|off|status <userId>');process.exit(1);}
const opts={};
const mi=rest.indexOf('--morning');if(mi!==-1)opts.morning=rest[mi+1];
const ei=rest.indexOf('--evening');if(ei!==-1)opts.evening=rest[ei+1];
const ci=rest.indexOf('--channel');if(ci!==-1)opts.channel=rest[ci+1];
if(cmd==='on')enablePush(uid,opts);
else if(cmd==='off')disablePush(uid);
else if(cmd==='status')showStatus(uid);
else{console.error('unknown cmd:'+cmd);process.exit(1);}


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)