Skip to content

feat: add Docs skill with formatText tool and simplified tool primitives#250

Merged
allenhutchison merged 2 commits intomainfrom
docs-skill
Mar 3, 2026
Merged

feat: add Docs skill with formatText tool and simplified tool primitives#250
allenhutchison merged 2 commits intomainfrom
docs-skill

Conversation

@allenhutchison
Copy link
Contributor

Summary

Add an agent skill for Google Docs that enables rich document formatting and simplifies the docs tool surface from 9 tools to 7 clean primitives (closes #58 for Docs).

Changes

New

  • skills/docs/SKILL.md — Docs skill with:
    • Two-step formatting workflow (insert text → apply formatting)
    • Professional document structure guidance (heading hierarchy, bold labels)
    • Index calculation guide for formatting ranges
    • Supported styles reference table

Added

  • docs.formatText tool — applies rich formatting (bold, italic, underline, strikethrough, code, link, headings 1-6) to text ranges via the Docs API updateTextStyle and updateParagraphStyle batch requests

Consolidated

  • Merged docs.insertText + docs.appendTextdocs.writeText with position parameter (beginning, end, or numeric index)
  • Removed docs.extractIdFromUrl (redundant — all tools already accept URLs directly)

Removed

  • markdownToDocsRequests.ts and its tests — the markdown→HTML→Docs API pipeline
  • marked, dompurify, jsdom dependencies and their type definitions
  • Related mock files and jest config mappings

Final Tool Surface (7 tools)

Tool Purpose
docs.create Create doc with optional content + folder
docs.getText Read document content
docs.writeText Write text at beginning, end, or specific index
docs.replaceText Find-and-replace
docs.formatText Apply rich formatting (bold, headings, links, etc.)
docs.find Search docs by title
docs.move Move doc to folder

Testing

  • All 389 tests pass across 24 suites
  • Build, lint, format, typecheck all clean
  • Net reduction: +845/-1931 lines

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Google Docs skill by introducing robust rich text formatting capabilities and simplifying the core document manipulation tools. It streamlines the API surface for Docs from nine to seven primitives, making interactions more intuitive and powerful. Concurrently, it removes an unnecessary markdown processing pipeline, reducing technical debt and improving efficiency. New detailed skill documentation for both Docs and Chat ensures clearer guidance for users on leveraging these updated functionalities.

Highlights

  • New Google Docs Formatting Tool: Introduced a new docs.formatText tool that allows applying rich formatting such as bold, italic, underline, strikethrough, code, links, and various heading styles (H1-H6) to specified text ranges within a Google Doc. This tool uses the Docs API's updateTextStyle and updateParagraphStyle batch requests.
  • Simplified Docs Text Writing Primitives: Consolidated docs.insertText and docs.appendText into a single docs.writeText tool. This new tool supports inserting text at the beginning, end (default), or a specific numeric index within a document, streamlining text manipulation.
  • Removed Redundant Tool and Markdown Processing Pipeline: Eliminated the docs.extractIdFromUrl tool as all Docs tools now directly accept Google Drive URLs. Additionally, the entire markdown-to-HTML-to-Docs API pipeline, including dependencies like marked, dompurify, and jsdom, was removed, simplifying the codebase and reducing dependencies.
  • Enhanced Skill Documentation: Added comprehensive SKILL.md files for both Google Chat and Google Docs. The Docs skill documentation provides detailed guidance on the new two-step formatting workflow, index calculation, supported styles, and professional document structuring. The Chat skill documentation outlines Chat-specific markdown syntax, space vs. DM messaging, and threading.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • jest.config.js
    • Removed marked and jsdom from transformIgnorePatterns and moduleNameMapper.
  • package-lock.json
    • Removed dompurify, jsdom, marked, and their related @types dependencies, along with several transitive dependencies like @acemir/cssom, @asamuzakjp/css-color, @asamuzakjp/dom-selector, @bramus/specificity, @csstools/*, @exodus/bytes, bidi-js, css-tree, cssstyle, data-urls, decimal.js, entities, html-encoding-sniffer, http-proxy-agent, is-potential-custom-element-name, mdn-data, parse5, saxes, symbol-tree, tldts, tldts-core, tough-cookie, tr46, undici, w3c-xmlserializer, webidl-conversions, whatwg-mimetype, whatwg-url, xml-name-validator, and xmlchars.
  • package.json
    • Removed dompurify, jsdom, marked, and their corresponding @types from dependencies and devDependencies.
  • skills/chat/SKILL.md
    • Added new skill documentation detailing Google Chat markdown formatting, space vs. DM usage, threading, and resource name formats.
  • skills/docs/SKILL.md
    • Added new skill documentation outlining a two-step workflow for document formatting, index calculation, supported styles, professional document structure guidance, and best practices for Docs tools.
  • workspace-server/WORKSPACE-Context.md
    • Updated Chat Guidelines to reference the new Chat skill documentation for detailed markdown and messaging guidance.
    • Updated Google Docs section to reference the new Docs skill documentation for detailed formatting and management guidance.
    • Updated Google Chat section to reference the new Chat skill for additional guidance.
  • workspace-server/esbuild.config.js
    • Removed jsdom from the list of external packages, indicating it is no longer a dependency.
  • workspace-server/src/tests/mocks/jsdom.ts
    • Removed mock implementation for jsdom.
  • workspace-server/src/tests/mocks/marked.js
    • Removed mock implementation for marked.
  • workspace-server/src/tests/services/DocsService.test.ts
    • Removed dompurify mock.
    • Updated create test to use content instead of markdown and verify docs.documents.create and docs.documents.batchUpdate calls.
    • Replaced insertText and appendText tests with new writeText tests covering beginning, end, numeric index, and invalid position scenarios.
    • Added new formatText tests for applying bold, italic, heading, code, and link styles, including tabId handling and error cases.
    • Modified replaceText test to reflect that markdown formatting is no longer applied during replacement, only literal text insertion.
  • workspace-server/src/index.ts
    • Removed extractDocId import.
    • Updated docs.create tool registration: changed markdown input schema to content.
    • Replaced docs.insertText tool registration with docs.writeText, updating description and adding position parameter.
    • Removed docs.appendText tool registration.
    • Replaced docs.extractIdFromUrl tool registration with docs.formatText, defining input schema for formatting requests including startIndex, endIndex, style, and optional url.
  • workspace-server/src/services/DocsService.ts
    • Removed imports for marked, Readable, createDOMPurify, JSDOM, mediaUploadOptions, parseMarkdownToDocsRequests, and processMarkdownLineBreaks.
    • Removed purify property and its initialization from the constructor.
    • Modified create method to accept content instead of markdown, directly calling docs.documents.create and then batchUpdate for initial content.
    • Replaced insertText and appendText methods with a new writeText method, which handles text insertion at various positions (beginning, end, numeric index) and tab IDs.
    • Added a new formatText method to apply various text and paragraph styles based on provided formats, including handling for headings, bold, italic, underline, strikethrough, code, and links.
    • Removed _addTabIdToFormattingRequests helper method.
    • Modified _processReplaceRequestsForTab to use newText directly instead of processedText and originalFormattingRequests, reflecting the removal of markdown parsing during replacement.
  • workspace-server/src/utils/markdownToDocsRequests.ts
    • Removed the entire file, which contained logic for parsing markdown and generating Docs API requests.
Activity
  • All 389 tests passed across 24 suites.
  • Build, lint, format, and typecheck processes were all clean.
  • The pull request resulted in a net reduction of 1086 lines of code (+845/-1931).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This is a great pull request that significantly simplifies the Google Docs tool surface. Removing the markdown-to-HTML-to-Docs API pipeline in favor of more explicit writeText and formatText tools is a solid architectural improvement. It makes the tools more predictable and easier for the model to reason about. The consolidation of insertText and appendText into writeText is also a welcome cleanup. I have one suggestion to improve the efficiency of the new writeText tool.

allenhutchison added a commit that referenced this pull request Mar 2, 2026
When position is 'end' and no tabId is specified, omit the location
field entirely — the Docs API auto-appends to the document body.
This saves an extra round-trip API call for the most common case.

Addresses review feedback from Gemini Code Assist on PR #250.
- Add skills/docs/SKILL.md with two-step formatting workflow:
  1. Insert content via docs.create or docs.writeText
  2. Apply rich formatting via docs.formatText (bold, italic, headings, links, code)

- Add docs.formatText tool for applying text and paragraph styles to ranges

- Consolidate docs tools from 9 to 7:
  - Merge docs.insertText + docs.appendText → docs.writeText (position param)
  - Remove docs.extractIdFromUrl (redundant, all tools accept URLs)

- Remove markdown-to-Docs conversion pipeline:
  - Delete markdownToDocsRequests.ts and its tests
  - Remove marked, dompurify, jsdom dependencies
  - Remove related mocks and jest config mappings

- Update DocsService.ts, index.ts, tests, WORKSPACE-Context.md
When position is 'end' and no tabId is specified, omit the location
field entirely — the Docs API auto-appends to the document body.
This saves an extra round-trip API call for the most common case.

Addresses review feedback from Gemini Code Assist on PR #250.
Copy link

@abhipatel12 abhipatel12 left a comment

Choose a reason for hiding this comment

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

LGTM!

@allenhutchison allenhutchison merged commit 9fec2fd into main Mar 3, 2026
14 checks passed
@allenhutchison allenhutchison deleted the docs-skill branch March 3, 2026 17:09
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.

Refactor: Native Format Generation for Workspace Services

2 participants