ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 musingfox

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 今天, 明天, or MM/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> ago after a failed one, or No 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.

更多類似作品