mcpField
M
macos-calendar

macos-calendar

github.com/lucaperret生产力7344 次安装32 周前更新
代码仓库

关于 macos-calendar

这项技能通过 shell 脚本管理 Apple Calendar 事件,可将自然语言安排转换为事件字段,并处理日期、提醒和重复规则。

主要功能

  1. 01列出可用日历
  2. 02创建定时或全天事件
  3. 03通过相对偏移设置日期
  4. 04配置提醒和重复规则
  5. 05校验字段并记录操作

适用场景

  1. 01安排未来日期的预约
  2. 02创建每周工作日会议
  3. 03添加全天假期事件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/lucaperret/agent-skills --skill macos-calendar

安装后在 Claude Code 中输入/macos-calendar确认已加载。

附带文件references/recurrence.mdscripts/calendar.sh

详细介绍

macOS Calendar

通过 $SKILL_DIR/scripts/calendar.sh 管理 Apple Calendar 事件。所有日期处理均使用相对日期计算(当前日期 + N * 天),以避免地区设置导致的问题(法语/英语/德语日期格式)。

快速开始

列出日历

始终先列出日历,以找到正确的日历名称:

"$SKILL_DIR/scripts/calendar.sh" list-calendars
创建事件
echo '<json>' | "$SKILL_DIR/scripts/calendar.sh" create-event

JSON 字段:

字段必填默认值描述
summary是-事件标题
calendar否第一个日历日历名称(来自 list-calendars)
description否""事件备注
offset_days否0距今天的天数(0=今天,1=明天,7=下周)
iso_date否-绝对日期 YYYY-MM-DD(优先于 offset_days)
hour否9开始小时(0-23)
minute否0开始分钟(0-59)
duration_minutes否30时长
alarm_minutes否0提前 N 分钟提醒(0=不提醒)
all_day否false全天事件
recurrence否-iCal RRULE 字符串。请参阅 references/recurrence.md

解读自然语言

将用户请求映射到 JSON 字段:

用户说JSON
"明天下午 2 点"offset_days: 1, hour: 14
"3 天后"offset_days: 3
"下周一上午 10 点"计算从今天到下周一的 offset_days,hour: 10
"2 月 25 日下午 3:30"iso_date: "2026-02-25", hour: 15, minute: 30
"每个工作日上午 9 点"hour: 9, recurrence: "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"
"提前 1 小时提醒我"alarm_minutes: 60
"3 月 1 日的全天事件"iso_date: "2026-03-01", all_day: true

对于“下周一”“下周五”等说法:根据当前日期计算 offset_days。如有需要,使用 date 命令:

# Days until next Monday (1=Monday)
target=1; today=$(date +%u); echo $(( (target - today + 7) % 7 ))

示例提示词

以下是真实的用户提示词以及应运行的命令:

“2 天后提醒我给牙医打电话”

"$SKILL_DIR/scripts/calendar.sh" list-calendars

然后:

echo '{"calendar":"Personnel","summary":"Call dentist","offset_days":2,"hour":9,"duration_minutes":15,"alarm_minutes":30}' | "$SKILL_DIR/scripts/calendar.sh" create-event

“安排每周二下午 2 点的团队同步会议,并提前 10 分钟提醒”

echo '{"calendar":"Work","summary":"Team sync","hour":14,"duration_minutes":60,"recurrence":"FREQ=WEEKLY;BYDAY=TU","alarm_minutes":10}' | "$SKILL_DIR/scripts/calendar.sh" create-event

“将 7 月 15 日设为休假日”

echo '{"calendar":"Personnel","summary":"Vacances","iso_date":"2026-07-15","all_day":true}' | "$SKILL_DIR/scripts/calendar.sh" create-event

“我下周四下午 3:30 有个医生预约,提前 1 小时提醒我”

# First compute offset_days to next Thursday (4=Thursday)
target=4; today=$(date +%u); offset=$(( (target - today + 7) % 7 )); [ "$offset" -eq 0 ] && offset=7

然后:

echo "{\"calendar\":\"Personnel\",\"summary\":\"Doctor appointment\",\"offset_days\":$offset,\"hour\":15,\"minute\":30,\"duration_minutes\":60,\"alarm_minutes\":60}" | "$SKILL_DIR/scripts/calendar.sh" create-event

“安排接下来 4 周内每个工作日上午 9 点的每日站会”

echo '{"calendar":"Work","summary":"Daily standup","hour":9,"duration_minutes":15,"recurrence":"FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=20"}' | "$SKILL_DIR/scripts/calendar.sh" create-event

“安排每两周一次的经理一对一会议,时间为周五上午 11 点”

echo '{"calendar":"Work","summary":"1-on-1 Manager","hour":11,"duration_minutes":30,"recurrence":"FREQ=WEEKLY;INTERVAL=2;BYDAY=FR","alarm_minutes":5}' | "$SKILL_DIR/scripts/calendar.sh" create-event

重要规则

  1. 如果用户未指定日历,始终先列出日历——标记为 [read-only] 的日历不能用于创建事件
  2. 绝不在 AppleScript 中使用硬编码日期字符串——始终使用 offset_days 或 iso_date
  3. 如果存在多个个人日历,请向用户确认日历名称
  4. 绝不选择 [read-only] 日历——脚本会报错并拒绝操作
  5. 对于重复事件,请参阅 references/recurrence.md 了解 RRULE 语法
  6. 通过 stdin 传递 JSON——绝不将其作为 CLI 参数(以避免数据泄露在进程列表中)
  7. 脚本会验证所有字段(类型转换、范围检查、格式验证)——无效输入会被拒绝并返回错误消息
  8. 所有操作都会记录到 logs/calendar.log,包含时间戳、命令、日历和摘要

评论

支持 Markdown