feat(drive): add drive.exportFile for PDF/DOCX/XLSX/PPTX/CSV exports#399
feat(drive): add drive.exportFile for PDF/DOCX/XLSX/PPTX/CSV exports#399matheusrmorgado wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request introduces the drive.exportFile tool, allowing users to export Google Workspace files to standard formats (such as PDF, DOCX, and XLSX) and save them locally. The changes include tool registration, service implementation, documentation updates, and unit tests. The review feedback suggests adding defensive checks in DriveService.ts to handle cases where format is not a string or response.data is undefined, preventing potential runtime errors. Additionally, it recommends removing ...readOnlyToolProps from the tool registration in index.ts because writing files to the local filesystem is a state-changing side effect.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Implements gemini-cli-extensions#398. drive.downloadFile deliberately refuses Google Workspace files and redirects to the getText tools; exportFile is the missing complement for producing the artifact itself via files.export. Friendly format enum (pdf, docx, xlsx, pptx, csv, txt, html, rtf, epub) mapped to export MIME types, same absolute-path conventions as downloadFile, readOnlyHint, lives in drive.read (files.export is covered by the existing drive.readonly scope, so no consent change). Rejects unsupported formats before any API call and empty export bodies after.
…ortFile Addresses gemini-code-assist review: non-string format values fail with the clear unsupported-format message instead of a TypeError; an undefined export body errors cleanly before Buffer.from; and the readOnlyHint annotation is removed since the tool writes to the local filesystem (consistent with drive.downloadFile, which carries no read-only annotation either).
ebd89ed to
595cf25
Compare
Summary
Fixes #398.
drive.downloadFiledeliberately refuses Google Workspace files and redirects the model to thegetTexttools — which covers reading content, but not producing the artifact users ask for ("save this doc as PDF", "export the sheet as xlsx").drive.exportFileis the missing complement, a thin wrapper overfiles.export:Design notes
pdf,docx,xlsx,pptx,csv,txt,html,rtf,epub), case-insensitive, mapped to export MIME types; the Drive API validates compatibility with the source file type.drive.downloadFile: URL-or-ID input, absolute-path resolution against PROJECT_ROOT,mkdir -pbefore write.drive.readfeature group +readOnlyHint:files.exportis covered by the existingdrive.readonlyscope, so the consent surface is unchanged.What's included
DriveServicefollowing the existing logging/handleErrorconventionsreadOnlyHintdocs/index.mdentryVerification
All passing: 29 suites, 624 tests (619 existing + 5 new), eslint/prettier/tsc clean.
Made with Cursor