| name | gog-drive |
| version | 1.0.0 |
| description | 用 gog 读/搜/上传/下载 Drive 文件。**先读 gog-shared**。对 delete/share/unshare/replace 写操作**必须先向用户确认并停止,下一轮明确同意后再执行**。典型:搜近期发票 PDF 批量下载、上传 Markdown 自动转 Google Doc。 |
| metadata | {"requires":{"bins":["gog"],"connectors":["google_workspace"]}} |
gog-drive
PREREQUISITE: 先读 gog-shared/SKILL.md。
只读
gog --account <email> --json drive ls --max 20
gog --account <email> --json drive ls --parent <folderId> --max 50
gog --account <email> --json drive search "invoice"
gog --account <email> --json drive search "mimeType = 'application/pdf'" --raw-query
gog --account <email> --json drive get <fileId>
gog --account <email> drive url <fileId>
gog --account <email> drive download <fileId> --out ./file.bin
gog --account <email> drive download <fileId> --format pdf --out ./doc.pdf
gog --account <email> drive download <fileId> --format md --out ./note.md
gog --account <email> --json drive drives --max 100
gog --account <email> --json drive permissions <fileId>
写操作(⚠️ 必须先确认)
gog --account <email> drive upload ./file.pdf --parent <folderId>
gog --account <email> drive upload ./notes.md --convert
gog --account <email> drive upload ./new-version.pdf --replace <fileId>
gog --account <email> drive delete <fileId>
gog --account <email> drive delete <fileId> --permanent
gog --account <email> drive share <fileId> --to user --email a@b.com --role reader
gog --account <email> drive share <fileId> --to domain --domain example.com --role reader
gog --account <email> drive unshare <fileId> --permission-id <permId>
gog --account <email> drive mkdir "New Folder" --parent <parentFolderId>
gog --account <email> drive rename <fileId> "New Name"
gog --account <email> drive move <fileId> --parent <destFolderId>
典型场景
场景:批量下载近期发票 PDF
gog --account <email> --json drive search "invoice filetype:pdf newer_than:30d" --max 50 \
| jq -r '.files[].id' \
| while read fid; do
gog --account <email> drive download "$fid" --out "/workspace/invoices/$fid.pdf"
done
场景:Markdown 报告发到 Drive 并分享
gog drive upload ./report.md --convert --parent <folderId> → 拿到 fileId
- 确认分享对象和权限,停止等待用户下一轮明确同意
gog drive share <fileId> --to user --email stakeholder@x.com --role reader
注意
--convert 前 gogcli 默认剥离 Markdown 开头的 YAML frontmatter(--- ~ ---);需要保留时加 --keep-frontmatter。
- Drive search query 语法:
mimeType = '...', name contains '...', parents in '...' —— 用 --raw-query 时直接透传。