osascript 调用 AppleScript 操作系统日历和提醒事项应用以下场景 不应 激活本 skill:
本 Skill 的脚本位于此文件同级的 scripts/ 目录下:
SKILL_DIR = <this SKILL.md's parent directory>
SCRIPTS_DIR = SKILL_DIR/scripts
执行任何脚本前,先确认用户系统为 macOS(脚本内已有 $OSTYPE 检测,非 darwin 会返回 ERR|此功能仅支持 macOS 系统,当前系统不支持)。收到此错误时,直接告知用户本功能仅支持 macOS,不再执行后续步骤。
从用户输入中识别并提取以下字段:
| 字段 | 必填 | 说明 |
|---|---|---|
| ------ | ------ | ------ |
| title | ✅ | 事项标题 |
| start_date | ✅ | 开始日期时间(ISO 8601 格式) |
| end_date | ❌ | 结束日期时间,默认为开始时间 +1 小时 |
| location | ❌ | 地点 |
| notes | ❌ | 备注描述 |
| attendees | ❌ | 参与人列表 |
| all_day | ❌ | 是否全天事件,默认 false |
| reminder | ❌ | 提前提醒分钟数,默认 15 |
| recurrence | ❌ | 重复规则(daily/weekly/monthly/yearly + interval) |
| calendar_name | ❌ | 目标日历名称,默认系统默认日历 |
时间解析规则:
提取完成后,立即执行冲突检测:
scripts/calendar_read.sh 查询所有待写入日程时间段内的已有事件直接写入,不需要用户确认。写入完成后,以结构化卡片格式展示已写入的日程:
✅ 已写入 1 条日程
📌 朋友聚餐
🕐 2026-03-31 周二 18:30 - 20:30
📍 海底捞(朝阳店)
⏰ 提前 30 分钟提醒
━━━━━━━━━━━━━━━━━━
暂停写入,向用户展示冲突详情并等待确认:
scripts/calendar_find_free.sh 查找替代时段,提供 2-3 个建议关键规则:用户确认冲突处理方式后,立即执行写入,不再二次确认。 写入完成后同样以结构化卡片展示已写入的日程。
当用户请求"帮我安排一个XX"而未指定具体时间时:
scripts/calendar_read.sh 获取近期日历安排scripts/calendar_find_free.sh 分析空闲时段根据事件类型选择目标应用:
scripts/calendar_write.shscripts/calendar_write_batch.sh,传入 JSON 文件路径scripts/reminder_write.sh当用户要求修改或取消已有日程时:
scripts/calendar_read.sh 查询匹配事件,获取精确的 title 和 start_datescripts/calendar_update.sh,传入定位字段(title + start_date)和需更新的字段(空字段不修改)scripts/calendar_delete.sh,传入 title + start_datescripts/reminder_read.sh 读取提醒列表scripts/reminder_complete.sh 标记为已完成scripts/reminder_delete.sh如果 AppleScript 执行失败(权限不足、应用不可用等):
| 脚本 | 用途 | 参数 | 输出格式 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| ------ | ------ | ------ | ---------- | ||||||
scripts/calendar_read.sh | 读取指定时间范围内的日历事件 | start_date, end_date, calendar_name(可选) | `TITLE\ | START\ | END\ | LOCATION\ | NOTES\ | CALENDAR\ | ALL_DAY` |
scripts/calendar_write.sh | 写入新日历事件 | title, start_date, end_date, location, notes, all_day, reminder, recurrence, calendar_name | 文本消息 | ||||||
scripts/calendar_write_batch.sh | 批量写入日历事件 | json_file(JSON 数组文件路径) | 每行 `OK\ | title 或 ERR\ | title\ | reason` | |||
scripts/calendar_update.sh | 修改已有日历事件 | search_title, search_start_date, new_title, new_start_date, new_end_date, new_location, new_notes, calendar_name | `OK\ | msg 或 ERR\ | msg` | ||||
scripts/calendar_delete.sh | 删除日历事件 | title, start_date, calendar_name(可选) | `OK\ | msg 或 ERR\ | msg` | ||||
scripts/calendar_find_free.sh | 查找空闲时段 | date, duration_minutes, work_hours_only | `BUSY\ | HH:MM\ | HH:MM\ | name / FREE\ | HH:MM\ | HH:MM\ | minutes / NONE` |
scripts/calendar_list.sh | 列出所有可用日历 | 无 | `NAME\ | WRITABLE` | |||||
scripts/reminder_write.sh | 写入提醒事项 | title, due_date, notes, priority, list_name | 文本消息 | ||||||
scripts/reminder_read.sh | 读取提醒事项列表 | list_name(可选), show_completed(可选) | `NAME\ | DUE_DATE\ | PRIORITY\ | COMPLETED\ | LIST_NAME\ | NOTES` | |
scripts/reminder_complete.sh | 标记提醒为已完成 | title, list_name(可选) | `OK\ | msg 或 ERR\ | msg` | ||||
scripts/reminder_delete.sh | 删除提醒事项 | title, list_name(可选) | `OK\ | msg 或 ERR\ | msg` |
所有脚本均通过 osascript 调用 AppleScript,适用于 macOS。
共 1 个版本