Commit e502e2802f85
Changed files (1)
dots
agents
skills
google-workspace
dots/agents/skills/google-workspace/SKILL.md
@@ -5,165 +5,166 @@ description: Access Google Workspace APIs (Drive, Docs, Calendar, Gmail, Sheets,
# Google Workspace
-Access Google Workspace APIs from the agent via local Node.js helper scripts — no MCP server needed.
+Access Google Workspace APIs via the `gws` CLI — a single binary, no scripts or Node.js needed.
-Supports: Drive, Docs, Calendar, Gmail, Sheets, Slides, People.
+Supports: Drive, Docs, Calendar, Gmail, Sheets, Slides, People, Tasks, Chat, Classroom, Forms, Keep, Meet.
-## Files
-
-All scripts live in the skill directory:
-
-- `scripts/auth.js` — login / status / clear token
-- `scripts/workspace.js` — call APIs (generic and convenience commands)
-- `scripts/common.js` — shared auth logic
-
-**Script base directory:** `~/.config/claude/skills/GoogleWorkspace/scripts`
-
-## One-Time Setup
-
-### 1. Create OAuth Credentials
-
-1. Go to [Google Cloud Console → Credentials](https://console.cloud.google.com/apis/credentials)
-2. Create an OAuth 2.0 Client ID (type: **Desktop app**)
-3. Download the JSON and save it to:
-
-```
-~/.config/google-workspace/credentials.json
-```
-
-4. Enable these APIs in your Google Cloud project:
- - Google Calendar API
- - Google Drive API
- - Gmail API
- - Google Docs API
- - Google Sheets API
- - Google Slides API
- - People API
-
-### 2. Install Dependencies
-
-Dependencies auto-install on first script run. To prewarm manually:
+## Auth
```bash
-cd ~/.config/claude/skills/GoogleWorkspace/scripts
-npm install
+# Check auth status
+gws auth status
+
+# Login (opens browser)
+gws auth login
+
+# Clear credentials
+gws auth logout
```
-### 3. Authenticate
-
-```bash
-cd ~/.config/claude/skills/GoogleWorkspace/scripts
-node auth.js login
-```
-
-This opens the browser for OAuth consent. Token is stored at `~/.config/google-workspace/token.json`.
-
## Operational Guidance for the Agent
-1. **Always check auth first:** Run `node auth.js status` before making API calls.
-2. **If auth is missing/expired:** Run `node auth.js login` and wait for the user to complete browser consent.
-3. **Do not explain setup** unless a command actually failed and its error output requires user action.
-4. **Use `workspace.js call`** for precise operations and return raw JSON results.
-5. **For user-friendly output:** Post-process JSON after the call — summarize, format tables, extract key info.
-6. **Never print token contents** back to the user.
-7. **Always `cd` into the scripts directory** before running commands.
+1. **Always check auth first:** Run `gws auth status` — look for `"token_valid": true`.
+2. **If auth is missing/expired:** Run `gws auth login` and wait for browser consent.
+3. **Do not explain setup** unless a command actually failed.
+4. **Use `gws schema`** to discover method parameters when unsure.
+5. **Never print token/credential contents** back to the user.
-## API Usage
+## CLI Usage
-### Generic API Call
-
-```bash
-cd ~/.config/claude/skills/GoogleWorkspace/scripts
-node workspace.js call <service> <method.path> '<json params>'
+```
+gws <service> <resource> [sub-resource] <method> [flags]
```
-Services: `drive`, `docs`, `calendar`, `gmail`, `sheets`, `slides`, `people`
+### Flags
-Examples:
+| Flag | Description |
+|------|-------------|
+| `--params '<JSON>'` | URL/query parameters |
+| `--json '<JSON>'` | Request body (POST/PATCH/PUT) |
+| `--upload <PATH>` | File to upload (multipart) |
+| `--output <PATH>` | Save binary response to file |
+| `--format <FMT>` | Output: `json` (default), `table`, `yaml`, `csv` |
+| `--page-all` | Auto-paginate (NDJSON, one JSON per page) |
+| `--page-limit <N>` | Max pages (default: 10) |
+
+### Schema Introspection
```bash
-# List 5 Drive files
-node workspace.js call drive files.list '{"pageSize":5,"fields":"files(id,name)"}'
-
-# Get today's calendar events
-node workspace.js call calendar events.list '{"calendarId":"primary","maxResults":10,"singleEvents":true,"orderBy":"startTime"}'
-
-# Get a Google Doc
-node workspace.js call docs documents.get '{"documentId":"<DOC_ID>"}'
-
-# List Gmail labels
-node workspace.js call gmail users.labels.list '{"userId":"me"}'
-
-# Read a spreadsheet
-node workspace.js call sheets spreadsheets.values.get '{"spreadsheetId":"<SHEET_ID>","range":"Sheet1!A1:D10"}'
+# Discover parameters for any method
+gws schema calendar.events.list
+gws schema drive.files.list
+gws schema gmail.users.messages.list
```
-### Convenience Commands
+## Common Patterns
+
+### Calendar
```bash
-cd ~/.config/claude/skills/GoogleWorkspace/scripts
+# Today's events (use ISO dates with timezone)
+gws calendar events list --params '{
+ "calendarId": "primary",
+ "timeMin": "2025-01-20T00:00:00Z",
+ "timeMax": "2025-01-21T00:00:00Z",
+ "singleEvents": true,
+ "orderBy": "startTime"
+}'
-# Today's calendar events
-node workspace.js calendar-today
+# Upcoming N days — compute timeMin/timeMax with `date`
+gws calendar events list --params "{
+ \"calendarId\": \"primary\",
+ \"timeMin\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",
+ \"timeMax\": \"$(date -u -d '+7 days' +%Y-%m-%dT%H:%M:%SZ)\",
+ \"singleEvents\": true,
+ \"orderBy\": \"startTime\"
+}"
-# Next N days of events (default: 7)
-node workspace.js calendar-upcoming 3
-
-# Search Google Drive
-node workspace.js drive-search "name contains 'Roadmap' and trashed=false"
-
-# Search Gmail
-node workspace.js gmail-search "from:alice@example.com newer_than:7d"
-
-# Read a specific Gmail message (full body)
-node workspace.js gmail-read <messageId>
+# Specific calendar
+gws calendar events list --params '{
+ "calendarId": "work@redhat.com",
+ "timeMin": "...",
+ "timeMax": "...",
+ "singleEvents": true,
+ "orderBy": "startTime"
+}'
```
-### Auth Commands
+### Drive
```bash
-cd ~/.config/claude/skills/GoogleWorkspace/scripts
+# Search files
+gws drive files list --params '{
+ "q": "name contains '\''Roadmap'\'' and trashed=false",
+ "pageSize": 10,
+ "fields": "files(id,name,mimeType,modifiedTime,webViewLink)"
+}'
-# Check auth status
-node auth.js status
+# Recent files
+gws drive files list --params '{
+ "pageSize": 10,
+ "orderBy": "modifiedTime desc",
+ "fields": "files(id,name,mimeType,modifiedTime,webViewLink)"
+}'
-# Login (opens browser)
-node auth.js login
-
-# Clear stored token
-node auth.js clear
+# By type
+gws drive files list --params '{"q": "mimeType='\''application/vnd.google-apps.document'\''", "pageSize": 10}'
+gws drive files list --params '{"q": "mimeType='\''application/vnd.google-apps.spreadsheet'\''", "pageSize": 10}'
```
-## Environment Overrides
+### Gmail
-| Variable | Default | Description |
-|----------|---------|-------------|
-| `GOOGLE_WORKSPACE_CONFIG_DIR` | `~/.config/google-workspace` | Config directory |
-| `GOOGLE_WORKSPACE_CREDENTIALS` | `<config_dir>/credentials.json` | OAuth credentials file |
-| `GOOGLE_WORKSPACE_TOKEN` | `<config_dir>/token.json` | Stored token file |
-
-## Common Google API Patterns
-
-### Drive: Search by type
```bash
-node workspace.js drive-search "mimeType='application/vnd.google-apps.document'"
-node workspace.js drive-search "mimeType='application/vnd.google-apps.spreadsheet'"
-node workspace.js drive-search "mimeType='application/vnd.google-apps.presentation'"
+# Search messages
+gws gmail users messages list --params '{
+ "userId": "me",
+ "q": "is:unread newer_than:1d",
+ "maxResults": 10
+}'
+
+# Read a message
+gws gmail users messages get --params '{
+ "userId": "me",
+ "id": "<messageId>",
+ "format": "full"
+}'
+
+# Common queries
+# "from:alice@example.com newer_than:7d"
+# "has:attachment newer_than:7d"
+# "in:sent newer_than:1d"
```
-### Drive: Recent files
+### Docs
+
```bash
-node workspace.js call drive files.list '{"pageSize":10,"orderBy":"modifiedTime desc","fields":"files(id,name,mimeType,modifiedTime,webViewLink)"}'
+gws docs documents get --params '{"documentId": "<DOC_ID>"}'
```
-### Gmail: Common queries
+### Sheets
+
```bash
-node workspace.js gmail-search "is:unread newer_than:1d"
-node workspace.js gmail-search "has:attachment newer_than:7d"
-node workspace.js gmail-search "in:sent newer_than:1d"
+gws sheets spreadsheets values get --params '{
+ "spreadsheetId": "<SHEET_ID>",
+ "range": "Sheet1!A1:D10"
+}'
```
-### Calendar: Specific calendar
+### People
+
```bash
-node workspace.js calendar-today "work@redhat.com"
+gws people people connections list --params '{
+ "resourceName": "people/me",
+ "personFields": "names,emailAddresses",
+ "pageSize": 10
+}'
```
+
+## Environment Variables
+
+| Variable | Description |
+|----------|-------------|
+| `GOOGLE_WORKSPACE_CLI_TOKEN` | Pre-obtained OAuth2 access token (highest priority) |
+| `GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE` | Path to OAuth credentials JSON |
+| `GOOGLE_WORKSPACE_CLI_CLIENT_ID` | OAuth client ID |
+| `GOOGLE_WORKSPACE_CLI_CLIENT_SECRET` | OAuth client secret |