habits
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese每日打卡技能
Daily Check-in Skill
基于本地 SQLite 数据库记录和管理每日打卡数据。数据文件由脚本通过 自动定位,存放在与 skill 目录同级的 目录下,无需手动配置路径。时间以 UTC 存入数据库,展示时自动按用户配置的时区进行转换。
import.meta.dirname.data/zsspub/habits/Record and manage daily check-in data based on local SQLite database. The data file is automatically located by the script through , stored in the directory at the same level as the skill directory, no manual path configuration is required. Time is stored in the database in UTC, and will be automatically converted according to the user-configured time zone when displayed.
import.meta.dirname.data/zsspub/habits/环境要求
Environment Requirements
- Node.js >= 22.5.0(使用内置 )
node:sqlite
- Node.js >= 22.5.0 (uses built-in )
node:sqlite
执行方式
Execution Method
所有命令均通过 直接运行脚本:
nodebash
node <本 SKILL.md 所在目录>/scripts/habits.mjs <命令> [选项]下文中 均代表 ,请替换为实际路径。
habitsnode <skill目录>/scripts/habits.mjsAll commands are run directly through :
nodebash
node <directory where this SKILL.md is located>/scripts/habits.mjs <command> [options]In the following content, refers to , please replace it with the actual path.
habitsnode <skill directory>/scripts/habits.mjs首次使用:配置时区
First Time Use: Configure Time Zone
脚本将时间以 UTC 存入数据库,展示时按用户配置的时区转换。首次使用时,请先判断用户的时区并运行 命令:
config --timezone- 若用户提到城市(如"我在上海"),推断为
Asia/Shanghai - 若无法判断,询问用户所在城市或时区,然后运行:
bash
habits config --timezone=Asia/ShanghaiThe script stores time in UTC in the database, and converts it according to the user-configured time zone when displaying. When using for the first time, please first determine the user's time zone and run the command:
config --timezone- If the user mentions a city (e.g. "I am in Shanghai"), infer it as
Asia/Shanghai - If it cannot be determined, ask the user for their city or time zone, then run:
bash
habits config --timezone=Asia/Shanghai使用流程
Usage Process
第一步:理解用户意图,映射到命令
Step 1: Understand user intent and map to commands
打卡的核心是从用户自然语言中提取结构化信息:
| 用户说的话(示例) | 提取信息 | 应执行的命令 |
|---|---|---|
| "打卡骑行 30 分钟" | 主题=骑行, 标签=运动, 时长=30 | |
| "今天读了一章《原则》" | 主题=阅读, 标签=学习, 备注=《原则》一章 | |
| "刚跑完步 5 公里 40 分钟" | 主题=跑步, 标签=运动, 时长=40, 备注=5公里 | |
| "冥想打卡" | 主题=冥想, 标签=健康 | |
| "打卡故宫" | 主题=旅行, 标签=生活, 备注=故宫 | |
| "看看我这个月的打卡记录" | — | |
| "这周运动了多少时间?" | — | |
| "骑行连续打卡多少天了?" | — | |
| "把第3条打卡改成45分钟" | — | |
| "删掉那条跑步记录" | — | 先 |
| "导出打卡记录" / "备份打卡数据" | — | |
| "导入打卡记录" / "从文件恢复" | — | |
原话保存: 每次 打卡时,将用户说的原始文字通过 参数原封不动地存储下来,方便日后回溯。
add--raw备注提取规则: 用于保存无法归入其他字段的关键信息。例如:
--note- 地点信息:城市、景点、餐厅名(“打卡故宫” → 备注=故宫)
- 具体内容:书名、课程名、食物名称(“读了《原则》第三章” → 备注=《原则》第三章)
- 量化指标:距离、组数、页数等时长以外的数值(“跑了5公里” → 备注=5公里)
标签自动推断规则:
根据主题自动推断标签,用户可以用 覆盖:
--tags| 主题关键词 | 推断标签 |
|---|---|
| 骑行、跑步、游泳、健身、瑜伽、拉伸、健走、跳绳、打球、登山、滑雪、滑冰 | 运动 |
| 阅读、读书、看书、听书 | 学习 |
| 冒想、早睡、早起、喝水、护肤 | 健康 |
| 背单词、刷题、练琴、画画、写作、练字、学英语 | 学习 |
| 做饭、家务、整理、美食、在家练习 | 生活 |
| 旅行、参观、游览、打卡景点 | 生活 |
| 看电影、追剧、听音乐、玩游戏 | 娱乐 |
如果主题不在上述列表中,请根据语义合理推断。打卡总应当有标签,方便后续统计筛选。
时长推断规则:
- "X 分钟" →
--duration=X - "X 小时" →
--duration=X*60 - "X 小时 Y 分钟" →
--duration=X*60+Y - "半小时" →
--duration=30 - "X个半小时" / "X小时半" →
--duration=X*90 - "一个半小时" →
--duration=90 - "一刻钟" / "15分钟" →
--duration=15 - 没有提到时长则不传
--duration
The core of check-in is to extract structured information from the user's natural language:
| User's words (example) | Extracted information | Command to execute |
|---|---|---|
| "Check in cycling for 30 minutes" | Topic=cycling, Tag=sports, Duration=30 | |
| "I read a chapter of Principles today" | Topic=reading, Tag=learning, Note=one chapter of Principles | |
| "Just finished running 5 kilometers in 40 minutes" | Topic=running, Tag=sports, Duration=40, Note=5km | |
| "Meditation check-in" | Topic=meditation, Tag=health | |
| "Check in at the Forbidden City" | Topic=travel, Tag=life, Note=Forbidden City | |
| "Show my check-in records this month" | — | |
| "How much time did I spend exercising this week?" | — | |
| "How many consecutive days have I checked in for cycling?" | — | |
| "Change the 3rd check-in to 45 minutes" | — | |
| "Delete that running record" | — | First run |
| "Export check-in records" / "Backup check-in data" | — | |
| "Import check-in records" / "Restore from file" | — | |
Original text saving: Every time you run to record a check-in, store the original text of the user's words as-is through the parameter for future review.
add--rawNote extraction rules: is used to save key information that cannot be classified into other fields. For example:
--note- Location information: city, scenic spot, restaurant name ("Check in at the Forbidden City" → Note=Forbidden City)
- Specific content: book name, course name, food name ("Read Chapter 3 of Principles" → Note=Chapter 3 of Principles)
- Quantitative indicators: distance, number of sets, pages and other values other than duration ("Ran 5 kilometers" → Note=5km)
Automatic tag inference rules:
Infer tags automatically based on the topic, users can override with :
--tags| Topic keywords | Inferred tag |
|---|---|
| Cycling, running, swimming, fitness, yoga, stretching, brisk walking, rope skipping, ball games, mountain climbing, skiing, skating | Sports |
| Reading, book reading, listening to audiobooks | Learning |
| Meditation, early bedtime, early rising, drinking water, skincare | Health |
| Memorizing words, doing exercises, practicing piano, painting, writing, calligraphy practice, learning English | Learning |
| Cooking, housework, organizing, food, home practice | Life |
| Travel, visiting, sightseeing, scenic spot check-in | Life |
| Watching movies, chasing dramas, listening to music, playing games | Entertainment |
If the topic is not in the above list, please infer reasonably according to the semantics. Check-in records should always have tags to facilitate subsequent statistics and filtering.
Duration inference rules:
- "X minutes" →
--duration=X - "X hours" →
--duration=X*60 - "X hours Y minutes" →
--duration=X*60+Y - "Half an hour" →
--duration=30 - "X and a half hours" →
--duration=X*60+30 - "One and a half hours" →
--duration=90 - "A quarter of an hour" / "15 minutes" →
--duration=15 - Do not pass if no duration is mentioned
--duration
第二步:执行命令并呈现结果
Step 2: Execute the command and present the result
将命令输出直接展示给用户。打卡成功后,可以给一句简短的鼓励。
Display the command output directly to the user. After a successful check-in, you can give a short encouragement.
命令说明
Command Description
添加打卡
Add check-in
habits add "主题" --raw="用户原话" [--tags=标签1,标签2] [--duration=分钟数] [--note="备注"] [--at="YYYY-MM-DD HH:mm:ss"]- :必填,用户说的原话,原封不动存储
--raw - :逗号分隔的标签列表,例如
--tags运动,户外 - :时长(分钟),正整数
--duration - :备注文本
--note - :打卡时间(用户本地时区),默认当前时间。用于补打卡场景
--at
habits add "topic" --raw="user's original words" [--tags=tag1,tag2] [--duration=minutes] [--note="note"] [--at="YYYY-MM-DD HH:mm:ss"]- : Required, the original words of the user, stored as-is
--raw - : Comma-separated list of tags, e.g.
--tags运动,户外 - : Duration (minutes), positive integer
--duration - : Note text
--note - : Check-in time (user's local time zone), default is current time. Used for retroactive check-in scenarios
--at
查看打卡记录
View check-in records
habits list [--topic=主题] [--tag=标签] [--date=YYYY-MM-DD] [--period=today|week|month|year] [--from="YYYY-MM-DD HH:mm:ss"] [--to="YYYY-MM-DD HH:mm:ss"] [--search=关键字] [--limit=数量]- :快捷时间范围(today/week/month/year)
--period - :查看某天的所有打卡
--date - /
--from:时间范围筛选--to - :按主题和备注模糊搜索
--search - :限制返回条数
--limit - 默认按时间倒序
habits list [--topic=topic] [--tag=tag] [--date=YYYY-MM-DD] [--period=today|week|month|year] [--from="YYYY-MM-DD HH:mm:ss"] [--to="YYYY-MM-DD HH:mm:ss"] [--search=keyword] [--limit=count]- : Quick time range (today/week/month/year)
--period - : View all check-ins on a certain day
--date - /
--from: Time range filtering--to - : Fuzzy search by topic and note
--search - : Limit the number of returned records
--limit - Default sorted in reverse chronological order
修改打卡
Modify check-in
habits update <id> [--topic=...] [--tags=...] [--duration=...] [--note=...] [--at="YYYY-MM-DD HH:mm:ss"]- 清除时长:
--duration=null
别名:
edithabits update <id> [--topic=...] [--tags=...] [--duration=...] [--note=...] [--at="YYYY-MM-DD HH:mm:ss"]- Clear duration:
--duration=null
Alias:
edit删除打卡
Delete check-in
habits delete <id>别名:、
delrmhabits delete <id>Aliases: ,
delrm统计分析
Statistical analysis
habits stats [--topic=主题] [--tag=标签] [--period=today|week|month|year] [--from="YYYY-MM-DD HH:mm:ss"] [--to="YYYY-MM-DD HH:mm:ss"]- :快捷时间范围(today/week/month/year)
--period - 输出:总打卡次数、总时长、按主题统计、按标签统计
habits stats [--topic=topic] [--tag=tag] [--period=today|week|month|year] [--from="YYYY-MM-DD HH:mm:ss"] [--to="YYYY-MM-DD HH:mm:ss"]- : Quick time range (today/week/month/year)
--period - Output: total check-in times, total duration, statistics by topic, statistics by tag
连续打卡
Consecutive check-in query
habits streak [--topic=主题] [--tag=标签]- 输出:当前连续天数、最长连续天数、累计打卡天数
habits streak [--topic=topic] [--tag=tag]- Output: current consecutive days, longest consecutive days, total check-in days
查看/更新配置
View/update configuration
habits config [--timezone=<IANA时区>]habits config [--timezone=<IANA time zone>]导出打卡记录
Export check-in records
habits export [--file=<路径>] [--topic=主题] [--tag=标签]- 导出为 CSV 格式
- :指定输出文件路径,不指定则自动生成到数据目录
--file - /
--topic:可选筛选条件--tag
habits export [--file=<path>] [--topic=topic] [--tag=tag]- Export to CSV format
- : Specify the output file path, if not specified, it will be automatically generated to the data directory
--file - /
--topic: Optional filtering conditions--tag
导入打卡记录
Import check-in records
habits import --file=<路径>- 从 CSV 文件导入,CSV 必须包含 列
topic - 导入前会校验数据格式,校验失败则取消导入
habits import --file=<path>- Import from CSV file, CSV must contain column
topic - Data format will be verified before import, import will be canceled if verification fails
示例
Examples
bash
undefinedbash
undefined打卡骑行 30 分钟
Check in cycling for 30 minutes
habits add "骑行" --tags=运动 --duration=30 --raw="打卡骑行 30 分钟"
habits add "骑行" --tags=运动 --duration=30 --raw="打卡骑行 30 分钟"
打卡阅读,带备注
Check in reading, with note
habits add "阅读" --tags=学习 --note="《原则》第三章"
habits add "阅读" --tags=学习 --note="《原则》第三章"
补打卡(昨天的跑步)
Retroactive check-in (yesterday's run)
habits add "跑步" --tags=运动 --duration=40 --note="5公里" --at="2026-04-01 19:30:00"
habits add "跑步" --tags=运动 --duration=40 --note="5公里" --at="2026-04-01 19:30:00"
查看今天的打卡
View today's check-ins
habits list --date=2026-04-02
habits list --date=2026-04-02
查看所有骑行记录
View all cycling records
habits list --topic=骑行
habits list --topic=骑行
本周运动统计
Weekly exercise statistics
habits stats --period=week --tag=运动
habits stats --period=week --tag=运动
查看骑行连续打卡天数
View consecutive cycling check-in days
habits streak --topic=骑行
habits streak --topic=骑行
修改第 2 条打卡的时长
Modify the duration of the 2nd check-in
habits update 2 --duration=45
habits update 2 --duration=45
删除第 5 条打卡
Delete the 5th check-in
habits delete 5
undefinedhabits delete 5
undefined