SuperAPI AI Directory

apple-calendar

Office & productivity

View repository

Updated 10-16 09:31

About this skill

Apple Calendar

Manage events in the macOS Calendar app via AppleScript.

Use Cases

  • The user says "Help me check what's on my schedule tomorrow" or "Add a meeting to the calendar"
  • The user needs to view their schedule for the next few days
  • The user wants to create/delete calendar events

Command Reference

List calendar accounts

osascript -e '
tell application "Calendar"
    set calNames to {}
    repeat with c in calendars
        set end of calNames to name of c
    end repeat
    return calNames
end tell
'

View today's events

osascript -e '
set today to current date
set hours of today to 0
set minutes of today to 0
set seconds of today to 0
set tomorrow to today + (1 * days)

tell application "Calendar"
    set allEvents to {}
    repeat with c in calendars
        set calEvents to (every event of c whose start date ≥ today and start date < tomorrow)
        repeat with e in calEvents
            set eventInfo to summary of e & " | " & (start date of e as string) & " - " & (end date of e as string)
            set end of allEvents to eventInfo
        end repeat
    end repeat
    return allEvents
end tell
'

View events in a specified date range

# 查看未来 7 天
osascript -e '
set startDate to current date
set hours of startDate to 0
set minutes of startDate to 0
set seconds of startDate to 0
set endDate to startDate + (7 * days)

tell application "Calendar"
    set allEvents to {}
    repeat with c in calendars
        set calEvents to (every event of c whose start date ≥ startDate and start date < endDate)
        repeat with e in calEvents
            set eventInfo to summary of e & " | " & (start date of e as string)
            set end of allEvents to eventInfo
        end repeat
    end repeat
    return allEvents
end tell
'

Create a new event

# 创建一个明天下午 2 点的 1 小时会议
osascript -e '
set eventDate to (current date) + (1 * days)
set hours of eventDate to 14
set minutes of eventDate to 0
set seconds of eventDate to 0
set endDate to eventDate + (1 * hours)

tell application "Calendar"
    tell calendar "个人"
        make new event with properties {summary:"团队周会", start date:eventDate, end date:endDate, description:"每周团队同步"}
    end tell
end tell
'

Search events

osascript -e '
tell application "Calendar"
    set results to {}
    repeat with c in calendars
        set found to (every event of c whose summary contains "会议")
        repeat with e in found
            set end of results to summary of e & " | " & (start date of e as string)
        end repeat
    end repeat
    return results
end tell
'

Delete an event

# 需要先确认后再删除
osascript -e '
tell application "Calendar"
    tell calendar "个人"
        set targetEvents to (every event whose summary is "要删除的事件名")
        repeat with e in targetEvents
            delete e
        end repeat
    end tell
end tell
'

Safety Rules

  • Confirm before creating an event: Show the event details (name, time, calendar) and create it after the user confirms
  • Deleting an event requires HITL: Use the hitl tool to request confirmation
  • Default calendar: Use the system default calendar when no calendar is specified
  • Time zone: Use the system local time zone; do not perform time zone conversion