musingfox/cc-plugins/tree/main/calendar
calendar
一个 Claude Mod(function-hooks 模块),在提示栏上方列出即将到来的 Google Calendar 事件,可用 /cal 切换,并通过 /cal N 设置 1–31 天。
关于这个 mod
calendar 是一个 Claude Mod,会以 function-hooks 模块(hooks/register.ts)的形式,在 Claude Code 工作阶段中显示即将到来的 Google Calendar 事件。它显示的任何内容都不会进入对话。使用 /cal 可切换提示栏上方的事件栏,列出接下来 7 天的事件;使用 /cal N 可列出接下来 N 天(1–31)的事件、打开事件栏,并记住 N。它需要 Claude Code 2.1.287 或更高版本;在这些版本中 Claude Mods 默认开启。事件通过 claude.ai 的 Google Calendar connector 经由 $.mcp.call 获取(先调用一次 list_calendars,再为每个日历调用一次 list_events),并排除插件选项 exclude_calendars 中列出的日历。事件栏打开时、工作阶段开始且之前保持开启时,以及开启期间每 15 分钟都会抓取;首次抓取失败时,最多每 30 秒重试 10 次。事件栏按事件时间从近到远每行显示一个事件,使用机器时区和日期标签(今天/明天/MM/DD weekday),显示全天与定时范围;当前或下一个事件以粗体绿色突出显示,并配绿色倒计时;@location 变暗;同时提供指向 Google Calendar、事件本身和 Maps 搜索的 OSC 8 链接。变暗的通知行会报告抓取中、不可用、过期或空状态,额外事件会折叠成“… N more”。事件栏会与其他 mod 的事件栏共享空间,并在插件存储中持久保存开关状态和 N。测试使用合成 fixture,通过 'claude plugin test calendar' 运行。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add musingfox/cc-plugins claude plugin install calendar
原文 / README
calendar
Shows upcoming Google Calendar events inside a Claude Code session, as one Claude Mod
(a function-hooks module, hooks/register.ts). Nothing it shows enters the conversation.
/cal: toggles a band above the prompt listing the next 7 days of events./cal N: lists the next N days (1–31), turns the band on, and remembers N.
Needs Claude Code 2.1.287 or later, where Claude Mods are on by default. Built and tested against Claude Code 2.1.287.
Where events come from
Every fetch goes through the claude.ai Google Calendar connector with $.mcp.call: one
list_calendars, then one list_events per calendar for the window from now to N days
ahead. Every calendar you can see is listed except those named in the plugin option
exclude_calendars (names or ids). Claude Code asks for it when the plugin is enabled; a
list option has no /config row, so change it later under
pluginConfigs["calendar@<marketplace>"].options in ~/.claude/settings.json.
Events are fetched when /cal turns the band on, at session start when the band was left
on, and every 15 minutes while it is on. Nothing is fetched while the band is off. A fetch
never blocks a prompt or a tool call. The claude.ai connectors are still connecting when a
session starts, so a failed fetch with nothing yet on screen is retried every 30 s, at most
10 times.
$.mcp.call asks no permission. Any installed Claude Mod can read your mail and
calendar through a connected claude.ai connector this way. Install third-party mods with
that in mind.
The band
One line per event, soonest first, in the machine's time zone (TZ when set):
今天 14:00–15:00 Dentist @Clinic 還有 4h
明天 全天 中秋節
09/27 日 22:00–09/28 01:30 Trip
09/28 一 18:00–21:00 Dinner @Home
- The day reads
今天,明天, orMM/DD <weekday>, in blue. - An all-day event reads
全天; a timed one its start and end, with the end's date when it ends on another day. - The first timed event (the one under way, or the next to start) has its title in bold
green. Today's timed events end in a green countdown,
還有 3h 45m, or進行中once started; the band redraws every minute so it keeps moving. @<location>follows the title, dimmed, when the event has one.- Three parts are links (OSC 8 on the terminal; a terminal without it prints the URL dimmed after the text): the day opens that day in Google Calendar, the title opens the event, and the location opens a Google Maps search for it.
- Cancelled events are left out, and an event shared into several calendars shows once.
- A dim notice line says
Fetching calendar events,Unavailable: <reason>before any fetch succeeded,Stale: <reason>; showing data from <age> agoafter a failed one, orNo events in the next N days. - More events than the band holds end in a dim
… N more. Every line is cut at the band's width.
The band shares its space with any band another mod draws there (/quota, for one) instead of hiding it.
The band's on/off state and N are kept in the plugin's store and read at session start.
Tests
claude plugin test calendar
The fixtures in tests/fixtures/world.ts are synthetic; no real calendar data belongs in
this repo.
