healthcheck - 水&睡眠健康追踪
v1.0.2通过本地 JSON 文件记录每日饮水量和睡眠状态,无需网络或额外依赖,数据全部保存在用户目录,兼顾隐私安全,适合个人健康管理使用。
9· 2.2万·1100 当前·1200 累计
运行时依赖
无特殊依赖
安装命令
点击复制官方npx clawhub@latest install healthcheck
镜像加速npx clawhub@latest install healthcheck --registry https://cn.longxiaskill.com 镜像可用
国内专用无需额外安装
本土化适配说明
无需额外安装,Node.js 环境已自带所需的 fs 模块。
技能文档
简单记录每日饮水量和睡眠情况,所有数据保存在本地 JSON 文件中。
数据格式
文件路径: {baseDir}/health-data.json
{
"water": [{"time": "ISO8601", "cups": 2}],
"sleep": [{"time": "ISO8601", "action": "sleep|wake"}]
}
添加饮水记录
当用户说 "uống X cốc" 或 "uống nước X cốc" 时执行:
node -e "const fs=require('fs');const f='{baseDir}/health-data.json';let d={water:[],sleep:[]};try{d=JSON.parse(fs.readFileSync(f))}catch(e){}d.water.push({time:new Date().toISOString(),cups:CUPS});fs.writeFileSync(f,JSON.stringify(d));console.log('Da ghi: '+CUPS+' coc')"
将 CUPS 替换为用户提供的数字。添加睡眠记录
当用户说 "đi ngủ" 时执行:
node -e "const fs=require('fs');const f='{baseDir}/health-data.json';let d={water:[],sleep:[]};try{d=JSON.parse(fs.readFileSync(f))}catch(e){}d.sleep.push({time:new Date().toISOString(),action:'sleep'});fs.writeFileSync(f,JSON.stringify(d));console.log('Da ghi: di ngu')"
添加醒来记录
当用户说 "thức dậy" 或 "dậy rồi" 时执行:
node -e "const fs=require('fs');const f='{baseDir}/health-data.json';let d={water:[],sleep:[]};try{d=JSON.parse(fs.readFileSync(f))}catch(e){}const last=d.sleep.filter(s=>s.action==='sleep').pop();d.sleep.push({time:new Date().toISOString(),action:'wake'});fs.writeFileSync(f,JSON.stringify(d));if(last){const h=((new Date()-new Date(last.time))/3600000).toFixed(1);console.log('Da ngu: '+h+' gio')}else{console.log('Da ghi: thuc day')}"
查看统计
当用户说 "thống kê" 或 "xem thống kê" 时执行:
node -e "const fs=require('fs');const f='{baseDir}/health-data.json';let d={water:[],sleep:[]};try{d=JSON.parse(fs.readFileSync(f))}catch(e){}console.log('Water:',d.water.length,'records');console.log('Sleep:',d.sleep.length,'records');const today=d.water.filter(w=>new Date(w.time).toDateString()===new Date().toDateString());console.log('Today:',today.reduce((s,w)=>s+w.cups,0),'cups')"
更新记录
更新最近一次饮水记录的杯数:
node -e "const fs=require('fs');const f='{baseDir}/health-data.json';let d=JSON.parse(fs.readFileSync(f));d.water[d.water.length-1].cups=NEW_CUPS;fs.writeFileSync(f,JSON.stringify(d));console.log('Updated')"
将 NEW_CUPS 替换为新的饮水杯数。删除记录
删除最近一次饮水记录:
node -e "const fs=require('fs');const f='{baseDir}/health-data.json';let d=JSON.parse(fs.readFileSync(f));d.water.pop();fs.writeFileSync(f,JSON.stringify(d));console.log('Deleted')"
备注
- 仅使用 Node.js 内置模块,无需额外依赖。
- 文件在首次使用时若不存在会自动创建。
- 所有时间戳采用 ISO8601 格式。