Skip to content

feat(drive): add drive.exportFile for PDF/DOCX/XLSX/PPTX/CSV exports#399

Open
matheusrmorgado wants to merge 2 commits into
gemini-cli-extensions:mainfrom
matheusrmorgado:feat/drive-export-file
Open

feat(drive): add drive.exportFile for PDF/DOCX/XLSX/PPTX/CSV exports#399
matheusrmorgado wants to merge 2 commits into
gemini-cli-extensions:mainfrom
matheusrmorgado:feat/drive-export-file

Conversation

@matheusrmorgado

Copy link
Copy Markdown

Summary

Fixes #398. drive.downloadFile deliberately refuses Google Workspace files and redirects the model to the getText tools — which covers reading content, but not producing the artifact users ask for ("save this doc as PDF", "export the sheet as xlsx"). drive.exportFile is the missing complement, a thin wrapper over files.export:

drive.exportFile({ fileId, format: "pdf", localPath: "exports/report.pdf" })

Design notes

  • Friendly format enum (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.
  • Same conventions as drive.downloadFile: URL-or-ID input, absolute-path resolution against PROJECT_ROOT, mkdir -p before write.
  • drive.read feature group + readOnlyHint: files.export is covered by the existing drive.readonly scope, so the consent surface is unchanged.
  • Fails fast on unsupported formats (before any API call) and on empty export bodies.

What's included

  • Service method in DriveService following the existing logging/handleError conventions
  • Tool registration with Zod enum schema and readOnlyHint
  • 5 Jest tests: MIME mapping (incl. case-insensitivity), file write path, unsupported format, empty body, error path
  • docs/index.md entry

Verification

npm run test && npm run lint && npm run format:check && npx tsc --noEmit --project workspace-server

All passing: 29 suites, 624 tests (619 existing + 5 new), eslint/prettier/tsc clean.

Made with Cursor

@google-cla

google-cla Bot commented Jun 12, 2026

Copy link
Copy Markdown

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread workspace-server/src/services/DriveService.ts Outdated
Comment thread workspace-server/src/services/DriveService.ts
Comment thread workspace-server/src/index.ts
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).
@matheusrmorgado matheusrmorgado force-pushed the feat/drive-export-file branch from ebd89ed to 595cf25 Compare June 12, 2026 21:23
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.

Feature request: drive.exportFile — export Docs/Sheets/Slides as PDF, DOCX, XLSX, PPTX, CSV

1 participant