Skip to content

feat(calendar): Meet links in +agenda and a +free slot finder - #998

Open
hallelx2 wants to merge 2 commits into
googleworkspace:mainfrom
hallelx2:feat/calendar-agenda-free
Open

hallelx2 wants to merge 2 commits into
googleworkspace:mainfrom
hallelx2:feat/calendar-agenda-free

Conversation

@hallelx2

Copy link
Copy Markdown

Description

Extends the existing Calendar helpers rather than adding new services.

calendar +agenda now shows each event's Google Meet link (hangoutLink, or the first video entry point in conferenceData). Table and CSV output keep a fixed column order (start, end, summary, calendar, meet, location), and an empty range prints No events between X and Y. JSON keeps its existing shape (events, count, timeMin, timeMax), with a new meet field per event.

calendar +free (new) finds open slots:

gws calendar +free                                   # next 3 days, 30-minute slots, 09:00-18:00
gws calendar +free --days 5 --minutes 60 --between 10:00-16:00 --weekdays
gws calendar +free --calendar [email protected] --format json
  • Busy time comes from events.list, not freeBusy, so it can leave out what shouldn't block you: cancelled events, events marked "free" (transparent), events you declined, and all-day events, unless they are out-of-office or --count-all-day is given. (freeBusy counts a weeks-long all-day "posting" event as busy and leaves no free time at all.) For a calendar the login can't list events on (403/404), it falls back to freeBusy.
  • By default it reads the calendars you own or can write to, plus primary; --calendar (repeatable) or --all-calendars change that.
  • Slots start on the quarter hour, inside --between on each day, in the primary calendar's time zone or --timezone. Output: day, start, end, length.

Input validation (AGENTS.md checklist)

  • --days (1–60), --minutes (5–1440) are range-checked; --between must be HH:MM-HH:MM with start before end; --timezone must be an IANA zone; calendar ids go through encode_path_segment.

Shared base commit. The first commit, feat(formatter): ordered report rendering and direct-call JSON fetch (1ab84c5), is shared by this PR and its siblings (Search Console/Analytics reports, YouTube, Forms, Calendar). It adds:

  • formatter::render_report: prints rows in a fixed column order (serde_json has no preserve_order here, so format_value sorts keys), with a title line, and a clear note instead of an empty table. CSV keeps its header and sends the note to stderr; JSON/YAML carry columns, count, rows and a note.
  • executor::fetch_json / api_error: one direct API call with the existing send_with_retry, mapping errors through handle_error_response so helpers keep the structured GwsError::Api shape.
    Whichever of these PRs merges first brings it in; the others then rebase cleanly.

Testing

  • 16 new unit tests: Meet link extraction, agenda columns and empty note, --between parsing, quarter-hour rounding, working windows, interval merging, slot finding, the busy rules (transparent, declined, cancelled, all-day, out-of-office), freeBusy parsing and calendar selection.
  • Live: +agenda showed Meet links. +free over three days skipped a weeks-long all-day event and found the expected slots in Africa/Lagos time.
  • cargo fmt --check is clean. cargo test: all pass except the two ADC tests that also fail on main on machines with gcloud ADC configured.
  • Skills regenerated (skills/gws-calendar-free, one line in skills/gws-calendar, docs/skills.md).

Dry Run Output: not applicable; both helpers only read.

Invariant review

  • busy_from_events: paged events.list per calendar, capped at 20 pages of 2,500. Safe by construction. The freeBusy fallback batches 50 calendars per call.
  • A 403/404 on events.list falls back to freeBusy for that calendar; it is not swallowed. Other errors propagate.
  • Read-only. No state writes or secrets.

Checklist:

  • My code follows the AGENTS.md guidelines (no generated google-* crates).
  • I have run cargo fmt --all to format the code perfectly.
  • I have run cargo clippy -- -D warnings and resolved all warnings (none new; main already fails a few lints on rustc 1.99).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have provided a Changeset file (e.g. via pnpx changeset) to document my changes.

Helpers that build reports (Search Console, Analytics, Forms responses,
calendar free slots) need columns in a fixed order: the dimension first,
or a form's questions in form order. serde_json objects sort their keys,
so format_value cannot keep that order. render_report keeps it for
table and CSV, wraps rows in an envelope for JSON and YAML, and prints a
clear note instead of an empty table when there are no rows.

fetch_json and api_error let a helper call an API directly with the same
retry and Google error parsing that execute_method uses.
+agenda showed when and where an event was but not how to join it.
Each entry now carries 'meet': the event's hangoutLink, else the first
video entry point of its conference data. Table and CSV keep the
columns in a readable order (start, end, summary, calendar, meet,
location); JSON keeps its existing shape with the new field.

+free answers 'when am I free?' in one command: free gaps of at least
--minutes inside --between working hours for the next --days days, in
the account timezone (or --timezone), optionally weekdays only.

Busy time comes from each calendar's events so that the rules match
how people read their calendar: events marked free, cancelled or
declined don't block; all-day events (postings, trips, reminders)
don't block unless they are out-of-office or --count-all-day is set.
Measured on a live calendar: a six-week all-day posting marked busy
made the freeBusy API report every working hour taken. Calendars
shared as free/busy only fall back to the freeBusy API. By default
only calendars you own or edit count; --all-calendars and --calendar
widen or narrow that.
@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 40a4cc9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

hallelx2 added a commit to hallelx2/gws-cli that referenced this pull request Nov 23, 2026
…for the report, YouTube, Forms and Calendar helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant