Opens macOS Calendar in week view, reads upcoming events for the next 3 months directly from the OS accessibility tree, then opens Safari and pastes a formatted calendar digest into a new Google Doc — grouped by month, with past events automatically filtered out. Works with any calendar visible in Calendar.app: holidays, work meetings, personal events.
App.exactName('Calendar').open()— launches Calendar and returns a live process handleinstance.enableAccessibility()— activates the accessibility tree for the appAccessibilityTree.fromPid(cal.pid)+find()— walks the Calendar week view tree by PID (works even if focus drifts during the long scan); events appear asStaticTextnodes whosevalueis the event title andoverallDescriptionanchors them to a day of weekKeyboardController— switches to week view (Cmd+2), jumps to today (Cmd+T), navigates forward week by week (Cmd+→)safari.windows()[0].screen()+screenshotFull()— captures the screen Safari is actually on (correct on multi-monitor setups), thenGroundingModel.default()locates the Google Docs body area visuallyMouseController— clicks the grounding coordinates to focus the bodyClipboard.pasteText()— inserts the full formatted document in one shot
Prerequisites:
- Simulang installed (
simulang runavailable in your terminal) - macOS with at least one calendar visible in Calendar.app
- Signed into your Google account in Safari
OPENROUTER_API_KEYrequired — see setup instructionsnpm installrun once in this folder
Steps:
cd calendar-to-docssimulang run main.ts
The script navigates 14 weeks of Calendar (≈ 3 months) at 600ms per week, taking around 10–15 seconds to collect events before opening Safari.
[Open Calendar → week view → today]
→ [Navigate 14 weeks, reading AX tree each week]
→ [Extract event titles from StaticText nodes]
→ [Compute full dates from week offset + day name]
→ [Filter to upcoming events only, group by month]
[Open Safari → https://docs.new]
→ [Vision grounding: click document body]
→ [Clipboard.pasteText(): insert formatted digest]
- Scan range — controlled by
MONTHSat the top ofmain.ts. Set to3by default; increase to12to scan a full year (takes proportionally longer). - All calendars included — holidays, work events, and personal events are all captured. Events from every calendar visible in Calendar.app appear in the output.
- Past events filtered — only events from today onward are included in the document.
- Google sign-in required —
https://docs.newcreates a new document if you're signed in; otherwise Safari shows a login page instead. - Why week view? macOS Calendar's month view exposes event existence (coloured dots) but not event names in the accessibility tree. Week view renders events as labelled blocks whose titles are directly readable.
