google-drive
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Drive
Google Drive
Architecture
架构
gdrivegdriveDesigned for a pull-edit-push cycle, especially paired with Anthropic's official document skills for reading and editing office files: , , , and (from ).
docxxlsxpptxpdfhttps://github.com/anthropics/skillsgdrivegdrive专为拉取-编辑-推送周期设计,尤其适合搭配Anthropic官方的文档技能来读取和编辑办公文件:、、和(来自)。
docxxlsxpptxpdfhttps://github.com/anthropics/skillsBefore First Use
首次使用前准备
Before running any gdrive command, ensure dependencies are available. Check and install silently -- don't ask the user for permission to install these.
- rclone: Run . If missing, install it:
which rclone- Linux: (or
sudo apt install -y rclone)curl https://rclone.org/install.sh | sudo bash - macOS:
brew install rclone
- Linux:
- uv: Run . If missing:
which uvcurl -LsSf https://astral.sh/uv/install.sh | sh - Project sync: Run to ensure the venv and deps are ready.
uv sync --project <skill-dir> - Auth: Run . If it shows "No remotes configured", the user needs to run
gdrive ls(interactive -- tell the user what's about to happen and that they'll need to complete OAuth in a browser).gdrive auth setup
For headless machines (no ), instruct the user to set up an SSH tunnel first:
$DISPLAYssh -L 53682:localhost:53682 <remote-host>Then run on the remote host and open the printed URL on their local machine.
gdrive auth setupSee for the full setup guide.
references/setup.md运行任何gdrive命令之前,请确保依赖项已就绪。自动检查并安装——无需询问用户权限即可安装这些依赖。
- rclone:运行 。如果未找到,则安装它:
which rclone- Linux:(或
sudo apt install -y rclone)curl https://rclone.org/install.sh | sudo bash - macOS:
brew install rclone
- Linux:
- uv:运行 。如果未找到:
which uvcurl -LsSf https://astral.sh/uv/install.sh | sh - 项目同步:运行 确保虚拟环境和依赖已准备好。
uv sync --project <skill-dir> - 认证:运行 。如果显示 "No remotes configured",用户需要运行
gdrive ls(交互式操作——告知用户即将发生的操作,以及他们需要在浏览器中完成OAuth认证)。gdrive auth setup
对于无图形界面的机器(无),指导用户先建立SSH隧道:
$DISPLAYssh -L 53682:localhost:53682 <remote-host>然后在远程主机上运行 ,并在本地机器上打开打印出的URL。
gdrive auth setup完整设置指南请查看。
references/setup.mdInvocation
调用方式
All commands use this pattern:
bash
uv run --project /path/to/skills/google-drive gdrive <command> [args]For brevity, examples below use directly.
gdrive所有命令遵循以下模式:
bash
uv run --project /path/to/skills/google-drive gdrive <command> [args]为简洁起见,以下示例直接使用。
gdriveCommands
命令
auth -- Manage remotes
auth -- 管理远程连接
bash
gdrive auth setup # interactive: configure rclone remotes (run once per machine)
gdrive auth status # report which remotes are configured and authenticate
gdrive auth logout # forget gdrive's remote registrations (rclone state stays)bash
gdrive auth setup # 交互式操作:配置rclone远程连接(每台机器运行一次)
gdrive auth status # 报告已配置的远程连接及认证状态
gdrive auth logout # 清除gdrive的远程注册信息(rclone状态保留)ls -- List drives or files
ls -- 列出云端或文件
bash
undefinedbash
undefinedList configured remotes
列出已配置的远程连接
gdrive ls
gdrive ls
List files at a remote path
列出远程路径下的文件
gdrive ls mydrive:
gdrive ls mydrive:Projects/2025/
gdrive ls mydrive:
gdrive ls mydrive:Projects/2025/
Detailed listing
详细列表
gdrive ls -l mydrive:Reports/
gdrive ls -l mydrive:Reports/
Recursive listing
递归列出
gdrive ls -R mydrive:Templates/
undefinedgdrive ls -R mydrive:Templates/
undefinedcp -- Copy files on remote
cp -- 在远程端复制文件
bash
gdrive cp mydrive:Reports/Q4-Summary.docx mydrive:Archive/Q4-Summary.docxServer-side copy. Works across different remotes (unlike mv). Does not update the manifest.
bash
gdrive cp mydrive:Reports/Q4-Summary.docx mydrive:Archive/Q4-Summary.docx服务器端复制。可跨不同远程连接使用(与mv不同)。不会更新清单。
pull -- Download files
pull -- 下载文件
bash
undefinedbash
undefinedDownload to current directory
下载到当前目录
gdrive pull mydrive:Reports/Q4-Summary
gdrive pull mydrive:Reports/Q4-Summary
Download to specific location
下载到指定位置
gdrive pull mydrive:Reports/Q4-Summary ./reports/
gdrive pull mydrive:Reports/Q4-Summary ./reports/
Force overwrite local changes
强制覆盖本地更改
gdrive pull -f mydrive:Reports/Q4-Summary
gdrive pull -f mydrive:Reports/Q4-Summary
Pull all files in a folder
拉取文件夹中的所有文件
gdrive pull mydrive:Reports/
gdrive pull mydrive:Reports/
Pull to a specific local directory
拉取到指定本地目录
gdrive pull mydrive:Reports/ ./local-reports/
gdrive pull mydrive:Reports/ ./local-reports/
Filter by glob pattern
按通配符模式过滤
gdrive pull mydrive:Reports/ --include "*.docx"
gdrive pull mydrive:Reports/ --include "*.docx"
Recursive pull (includes subdirectories)
递归拉取(包含子目录)
gdrive pull -R mydrive:Projects/
Google Docs/Sheets/Slides are automatically exported:
| Google Format | Exported As |
|---|---|
| Google Doc | .docx |
| Google Sheet | .xlsx |
| Google Slides | .pptx |
The manifest tracks the original MIME type so push can re-import correctly.gdrive pull -R mydrive:Projects/
Google Docs/Sheets/Slides会自动导出:
| Google格式 | 导出格式 |
|---|---|
| Google Doc | .docx |
| Google Sheet | .xlsx |
| Google Slides | .pptx |
清单会追踪原始MIME类型,以便推送时能正确重新导入。push -- Upload files
push -- 上传文件
bash
undefinedbash
undefinedPush a tracked file (uses manifest for destination)
推送已追踪的文件(使用清单中的目标路径)
gdrive push ./Q4-Summary.docx
gdrive push ./Q4-Summary.docx
Push to explicit destination
推送到明确的目标路径
gdrive push ./report.docx mydrive:Reports/Q4-Summary.docx
gdrive push ./report.docx mydrive:Reports/Q4-Summary.docx
Force overwrite
强制覆盖
gdrive push -f ./Q4-Summary.docx
gdrive push -f ./Q4-Summary.docx
Push all locally-modified tracked files
推送所有本地已修改的已追踪文件
gdrive push --all
gdrive push --all
Filter batch push by remote
按远程连接过滤批量推送
gdrive push --all -r mydrive
gdrive push --all -r mydrive
Force batch push (skip conflict checks)
强制批量推送(跳过冲突检查)
gdrive push --all -f
Format-aware upload: if a file was originally a Google Doc (per manifest), it's automatically re-imported as a Google Doc on push. For new files, you'll be prompted.
Conflict detection: if the remote file changed since last sync, push prompts before overwriting. Use `-f` to skip.gdrive push --all -f
格式感知上传:如果文件原本是Google Doc(根据清单),推送时会自动重新导入为Google Doc。对于新文件,会提示用户。
冲突检测:如果远程文件自上次同步后已更改,推送前会提示确认。使用`-f`可跳过提示。status -- Check sync state
status -- 检查同步状态
bash
undefinedbash
undefinedShow all tracked files
显示所有已追踪文件
gdrive status
gdrive status
Filter by remote
按远程连接过滤
gdrive status -r mydrive
Categories:
- **Up to date** -- local matches last sync
- **Local changes** -- local file modified since last pull
- **Missing locally** -- tracked file deleted or moved locallygdrive status -r mydrive
分类:
- **最新** -- 本地文件与上次同步一致
- **本地已更改** -- 本地文件自上次拉取后已修改
- **本地缺失** -- 已追踪文件在本地被删除或移动mkdir -- Create directories
mkdir -- 创建目录
bash
gdrive mkdir mydrive:Projects/2025/NewProjectbash
gdrive mkdir mydrive:Projects/2025/NewProjectmv -- Move files on remote
mv -- 在远程端移动文件
bash
gdrive mv mydrive:old/path.docx mydrive:new/path.docxUpdates manifest entries referencing the moved path.
bash
gdrive mv mydrive:old/path.docx mydrive:new/path.docx更新清单中引用该移动路径的条目。
search -- Find files
search -- 查找文件
bash
undefinedbash
undefinedSearch all configured remotes
在所有已配置的远程连接中搜索
gdrive search budget
gdrive search budget
Search a specific remote
在指定远程连接中搜索
gdrive search mydrive: budget report
Uses Google Drive's name-contains query. Shows results with file type, date, and web link.gdrive search mydrive: budget report
使用Google Drive的名称包含查询。显示结果时会包含文件类型、日期和网页链接。rm -- Delete remote files
rm -- 删除远程文件
bash
gdrive rm mydrive:path/to/old-file.docx
gdrive rm -f mydrive:path/to/old-file.docx # skip confirmationDeletes the remote file and cleans up any matching manifest entries.
bash
gdrive rm mydrive:path/to/old-file.docx
gdrive rm -f mydrive:path/to/old-file.docx # 跳过确认删除远程文件并清理清单中对应的条目。
untrack -- Remove from manifest
untrack -- 从清单中移除
bash
gdrive untrack ./local-file.docxRemoves the file from manifest tracking without deleting anything locally or on the remote.
bash
gdrive untrack ./local-file.docx将文件从清单追踪中移除,不会删除本地或远程的文件。
doctor -- Health check
doctor -- 健康检查
bash
gdrive doctorValidates: rclone installed, config file exists, all remotes have working tokens, no orphaned rclone remotes, all manifest entries have existing local files.
bash
gdrive doctor验证:rclone已安装、配置文件存在、所有远程连接的令牌可用、无孤立的rclone远程连接、所有清单条目对应的本地文件存在。
open -- Get web URL
open -- 获取网页URL
bash
gdrive open mydrive:Reports/Q4-SummaryPrints the Google Drive web URL for the file.
bash
gdrive open mydrive:Reports/Q4-Summary打印文件的Google Drive网页URL。
link -- Get shareable link
link -- 获取可分享链接
bash
gdrive link mydrive:Reports/Q4-SummaryPrints a shareable Google Drive link for the file.
bash
gdrive link mydrive:Reports/Q4-Summary打印文件的Google Drive可分享链接。
share -- Set permissions
share -- 设置权限
bash
undefinedbash
undefinedShare with a user (default: reader)
与用户共享(默认:查看者)
gdrive share mydrive:Reports/Q4-Summary.docx user@example.com
gdrive share mydrive:Reports/Q4-Summary.docx user@example.com
Share as writer
以编辑者身份共享
gdrive share mydrive:Reports/Q4-Summary.docx user@example.com --role writer
gdrive share mydrive:Reports/Q4-Summary.docx user@example.com --role writer
Share as commenter
以评论者身份共享
gdrive share mydrive:Reports/Q4-Summary.docx user@example.com --role commenter
gdrive share mydrive:Reports/Q4-Summary.docx user@example.com --role commenter
Share with anyone who has the link
与任何拥有链接的人共享
gdrive share mydrive:Reports/Q4-Summary.docx --anyone
Calls the Google Drive API directly (rclone has no sharing support). Uses the OAuth token from rclone config.gdrive share mydrive:Reports/Q4-Summary.docx --anyone
直接调用Google Drive API(rclone不支持共享功能)。使用rclone配置中的OAuth令牌。Workflow: Pull-Edit-Push
工作流:拉取-编辑-推送
The primary workflow for editing Google Drive documents:
bash
undefined编辑Google Drive文档的主要工作流:
bash
undefined1. Pull the document (exports Google Doc as .docx)
1. 拉取文档(将Google Doc导出为.docx)
gdrive pull mydrive:Proposals/Client-Brief
gdrive pull mydrive:Proposals/Client-Brief
2. Edit with a document skill
2. 使用文档技能编辑
(use docx, xlsx, or pptx skill to read/modify the file)
(使用docx、xlsx或pptx技能读取/修改文件)
3. Check what changed
3. 检查更改内容
gdrive status
gdrive status
4. Push back (re-imports as Google Doc)
4. 推送回去(重新导入为Google Doc)
gdrive push ./Client-Brief.docx
**Mixed editing (agent XML + user in Google Docs):**
If the user edited the doc directly in Google Docs between sessions, the pulled version may have different structure (reordered sections, removed content). Always re-inspect with `pandoc` before editing XML. Don't assume previous XML line numbers or structure.gdrive push ./Client-Brief.docx
**混合编辑(Agent XML + 用户在Google Docs中编辑):**
如果用户在会话之间直接在Google Docs中编辑了文档,拉取的版本可能结构不同(章节重新排序、内容删除)。编辑XML之前务必使用`pandoc`重新检查。不要假设之前的XML行号或结构不变。Manifest
清单
The manifest at tracks:
~/.config/skills/gdrive/manifest.json- Remote location and Google Drive file ID
- Original MIME type (for format-aware re-import)
- MD5 hashes at last sync (local and remote)
- Timestamps for change detection
The manifest enables:
- Pushing tracked files without specifying the remote path
- Detecting local modifications via MD5 comparison
- Re-importing exported Google Docs as native format on push
- Detecting moved files by MD5 hash
位于的清单会追踪:
~/.config/skills/gdrive/manifest.json- 远程位置和Google Drive文件ID
- 原始MIME类型(用于格式感知的重新导入)
- 上次同步时的MD5哈希值(本地和远程)
- 用于更改检测的时间戳
清单支持以下功能:
- 无需指定远程路径即可推送已追踪文件
- 通过MD5比较检测本地修改
- 推送时将导出的Google Docs重新导入为原生格式
- 通过MD5哈希检测移动的文件
Remote Naming Convention
远程连接命名规范
Shared drives are configured as separate rclone remotes. Pick a short prefix per drive so commands stay readable, e.g.:
- -- a personal My Drive
mydrive - -- an engineering shared drive
team-engineering - -- a design shared drive
team-design
Lowercased, hyphenated names work best. The wizard suggests names based on each drive's title and lets you override.
auth共享云端配置为独立的rclone远程连接。为每个云端选择简短的前缀,以便命令保持可读性,例如:
- -- 个人云端
mydrive - -- 工程团队共享云端
team-engineering - -- 设计团队共享云端
team-design
小写、连字符分隔的名称效果最佳。向导会根据每个云端的标题建议名称,并允许用户修改。
authTroubleshooting
故障排除
"File not found" on pull -- Check the path with first. Google Docs don't have file extensions on the remote.
gdrive ls remote:path/Push doesn't re-import as Google Doc -- Ensure the file was originally pulled (has manifest entry with Google MIME type). For new files, use flag.
--drive-import-formatsManifest out of sync -- Run on stale entries, or delete to reset.
gdrive untrack~/.config/skills/gdrive/manifest.jsonGeneral setup issues -- Run to diagnose problems with rclone, remotes, and manifest health.
gdrive doctor拉取时提示“文件未找到” -- 先使用检查路径。Google Docs在远程端没有文件扩展名。
gdrive ls remote:path/推送未重新导入为Google Doc -- 确保文件最初是通过拉取获得的(清单中有Google MIME类型的条目)。对于新文件,使用标志。
--drive-import-formats清单不同步 -- 对过时条目运行,或删除重置清单。
gdrive untrack~/.config/skills/gdrive/manifest.json通用设置问题 -- 运行诊断rclone、远程连接和清单健康状况的问题。
gdrive doctorConfiguration Files
配置文件
- Manifest:
~/.config/skills/gdrive/manifest.json - Config:
~/.config/skills/gdrive/config.json - rclone config: (managed by rclone)
~/.config/rclone/rclone.conf - Override the gdrive config dir with
GDRIVE_CONFIG_DIR=/path/to/dir
- 清单:
~/.config/skills/gdrive/manifest.json - 配置:
~/.config/skills/gdrive/config.json - rclone配置:(由rclone管理)
~/.config/rclone/rclone.conf - 使用覆盖gdrive配置目录
GDRIVE_CONFIG_DIR=/path/to/dir
Migrating from earlier versions
从早期版本迁移
If upgrading from a build that stored config at , run to move the manifest and config to the new location. emits a until the migration runs.
~/.config/gdrive/gdrive config migrate --applygdrive auth statusdeprecation_warningThe interactive wizard previously invoked as is now . The bare is now a command group containing , , and .
gdrive authgdrive auth setupgdrive authsetupstatuslogoutAdd to in any repo using this skill:
.gitignore.gdrive-manifest.json如果从将配置存储在的版本升级,请运行将清单和配置移动到新位置。在完成迁移之前,会发出。
~/.config/gdrive/gdrive config migrate --applygdrive auth statusdeprecation_warning之前作为调用的交互式向导现在是。不带参数的现在是包含、和的命令组。
gdrive authgdrive auth setupgdrive authsetupstatuslogout在任何使用此技能的仓库中添加到:
.gitignore.gdrive-manifest.json