Skip to content

feat: add --comments flag to include Google Docs comments#4

Merged
famasya merged 4 commits intomainfrom
feat/comments
Feb 13, 2026
Merged

feat: add --comments flag to include Google Docs comments#4
famasya merged 4 commits intomainfrom
feat/comments

Conversation

@famasya
Copy link
Owner

@famasya famasya commented Feb 13, 2026

Closes #2

Adds a --comments flag that fetches document comments via the Google Drive Comments API and appends them as a ## Comments section at the end of the markdown output.

What it does

  • Fetches comments using the Drive Comments API (drive.readonly scope)
  • Renders each comment with quoted/anchored text, author, date, and resolved status
  • Includes threaded replies
  • Skips deleted comments and replies

Example output

## Comments

> "the original highlighted text"

**Alice** (2025-01-15): This needs clarification.
  ↳ **Bob** (2025-01-15): Fixed now.

Changes

  • internal/gdocs/comments.go — Fetch comments via Drive API
  • internal/markdown/comments.go — Render comments as markdown
  • internal/markdown/comments_test.go — 14 test cases
  • internal/auth/oauth.go — Add drive.readonly scope
  • cmd/gdocs-cli/main.go — Add --comments flag and wiring
  • README.md — Document the flag and scope requirements

⚠️ Note for existing users

The new drive.readonly scope means existing users need to delete ~/.config/gdocs-cli/token.json and re-authenticate with --init to grant the new permission.

Summary by CodeRabbit

  • New Features

    • Add optional inclusion of Google Docs comments in generated Markdown via a new --comments flag; re-authentication required if drive.readonly scope wasn't previously granted.
  • Documentation

    • Update README and troubleshooting to document the --comments flag, required Drive scope, and usage notes.
    • Add extensive GitHub CLI skill documentation.
  • Tests

    • Add unit tests covering Markdown rendering of comments and timestamps.
  • Chores

    • Update ignore patterns for gdocs-related paths.

… output

Fetches comments via the Google Drive Comments API and appends them
as a ## Comments section at the end of the markdown output. Includes
quoted text, author, date, resolved status, and replies.

- Add internal/gdocs/comments.go for fetching comments via Drive API
- Add internal/markdown/comments.go for rendering comments as markdown
- Add --comments CLI flag
- Add drive.readonly OAuth scope
- Add tests for comment rendering and time formatting
- Update README with usage docs and scope requirements

Closes #2

Amp-Thread-ID: https://ampcode.com/threads/T-019c54ce-f0ae-76e3-87fe-06b9a3e2c02f
Co-authored-by: Amp <amp@ampcode.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Warning

Rate limit exceeded

@famasya has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds optional Google Drive comment inclusion to the CLI conversion flow: new --comments flag, Drive OAuth scope added, comment fetching from Drive, Markdown rendering for comments, and integration that appends comments to converted output.

Changes

Cohort / File(s) Summary
Repo Top-level & Docs
/.gitignore, README.md
Ignore patterns for /gdocs and /gdocs-cli added; README documents --comments, Drive API scope requirement, usage, troubleshooting, and security notes.
CLI Entry
cmd/gdocs-cli/main.go
New --comments flag; run signature extended to accept includeComments and conditionally fetch/attach comments before conversion.
Auth Scopes
internal/auth/oauth.go
Added drive.readonly (driveReadonlyScope) to OAuth scopes alongside docs scope.
Comment Fetching
internal/gdocs/comments.go
New types Comment and Reply and FetchComments(ctx, httpClient, docID) to paginate and map Drive comment API results, filter deleted items, and return structured comments.
Markdown Rendering
internal/markdown/comments.go, internal/markdown/comments_test.go
New ConvertComments renders comments/replies to Markdown (quotes, author, date, resolved flag); comprehensive unit tests for edge cases and formatting.
Converter Integration
internal/markdown/converter.go
Added SetComments and internal comments field; Convert appends rendered comments section when comments are present.
Agent Skill Docs
.agents/skills/gh-cli/SKILL.md, .claude/skills/gh-cli
Large documentation file added for gh-cli skill; .claude context updated to reference the new skill path.

Sequence Diagram

sequenceDiagram
    participant User as User/CLI
    participant Main as Main (cmd/gdocs-cli)
    participant Docs as Docs Service
    participant Drive as Drive API
    participant Converter as Converter
    participant Renderer as Comment Renderer

    User->>Main: Run CLI with --comments
    Main->>Docs: Fetch document content
    Docs-->>Main: Document
    alt includeComments == true
        Main->>Drive: FetchComments(docID) (Drive API, paginated)
        Drive-->>Main: []Comment (with Replies)
        Main->>Converter: SetComments(comments)
    end
    Main->>Converter: Convert(document body)
    Converter->>Renderer: ConvertComments(comments)
    Renderer-->>Converter: Markdown comments section
    Converter-->>Main: Final Markdown (body + comments)
    Main-->>User: Output markdown
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐇 I hopped to fetch each tiny note,

quoted words in every quote,
authors, dates, replies in line,
stitched to docs, all neat and fine —
a floppy-tailed changelog, now mine.

🚥 Pre-merge checks | ✅ 4 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning One out-of-scope addition: .agents/skills/gh-cli/SKILL.md (2187 lines) is unrelated to the comments feature and appears to be documentation for GitHub CLI skills. Remove .agents/skills/gh-cli/SKILL.md and .claude/skills/gh-cli changes as they are unrelated to the comments feature implementation.
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature added: a --comments flag for including Google Docs comments in the output.
Linked Issues check ✅ Passed The PR successfully addresses all requirements from issue #2: comments are appended to document output, include context (quoted text), preserve threading, and indicate resolved status.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

296-313: ⚠️ Potential issue | 🟡 Minor

Project structure is missing new files.

The tree listing doesn't include the new comments.go files under internal/gdocs/ and internal/markdown/, nor comments_test.go. Consider updating it to reflect the current structure.

🤖 Fix all issues with AI agents
In `@internal/gdocs/comments.go`:
- Around line 39-43: In FetchComments, the API call created via
srv.Comments.List is executed with call.Do() but doesn't propagate the
function's ctx; update the code to attach the context to the request (use
call.Context(ctx) on the existing call variable before calling call.Do()) while
preserving the PageSize/PageToken logic so cancellations and deadlines are
honored.

In `@internal/markdown/comments.go`:
- Around line 17-18: The "## Comments" heading is being appended directly to the
body without a preceding blank line, so update the logic in ConvertComments (the
builder using the strings.Builder variable named builder) to prepend a newline
before the heading (i.e., ensure the heading is written as "\n## Comments\n\n"
or otherwise guarantees a blank line separator) so the comments section is
separated from the preceding content.

In `@README.md`:
- Line 242: Update the stale README note that currently reads "Author and dates
require Google Drive API (not implemented in this version)" to reflect that the
Drive API is now integrated for comments: change the line to indicate that
Google Drive API is used for comments but that document-level metadata (author
and dates/frontmatter) is still not implemented; ensure the updated sentence
explicitly mentions "comments via Drive API are supported" and "author/dates in
frontmatter are not yet extracted" so readers know the exact current capability.
🧹 Nitpick comments (2)
internal/auth/oauth.go (1)

23-24: drive.readonly scope is always requested, even without --comments.

The new scope is unconditionally included in the OAuth config. This means all users (including those who never use --comments) will be asked to grant Drive read-only access. Consider whether this broad permission request is intentional, or if you'd prefer to conditionally add the scope only when --comments is used — though that would complicate auth and token management.

As-is, this is a reasonable trade-off for simplicity, but worth a conscious decision.

Also applies to: 42-42

internal/markdown/comments.go (1)

27-39: Author names containing ** would break bold markdown formatting.

If a Google account display name contains ** or other markdown syntax, the output would be malformed. This is low-risk since Google display names rarely contain such characters, but a simple escape (replacing * with \*) would make this robust.

Comment on lines +17 to +18
var builder strings.Builder
builder.WriteString("## Comments\n\n")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing newline separator before the ## Comments heading.

ConvertComments is appended directly after the body content in converter.go. If the body doesn't end with a blank line, the heading will run into the last paragraph. Prepend a newline to ensure clean separation.

Proposed fix
 var builder strings.Builder
+builder.WriteString("\n")
 builder.WriteString("## Comments\n\n")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var builder strings.Builder
builder.WriteString("## Comments\n\n")
var builder strings.Builder
builder.WriteString("\n")
builder.WriteString("## Comments\n\n")
🤖 Prompt for AI Agents
In `@internal/markdown/comments.go` around lines 17 - 18, The "## Comments"
heading is being appended directly to the body without a preceding blank line,
so update the logic in ConvertComments (the builder using the strings.Builder
variable named builder) to prepend a newline before the heading (i.e., ensure
the heading is written as "\n## Comments\n\n" or otherwise guarantees a blank
line separator) so the comments section is separated from the preceding content.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.agents/skills/gh-cli/SKILL.md:
- Around line 70-265: The fenced ASCII CLI structure block starting with the
line "gh                          # Root command" uses a bare code fence; update
the opening fence from ``` to ```text to provide a language hint (leave the
block contents unchanged and keep the closing fence as ```), which will satisfy
markdownlint MD040.

Comment on lines 70 to 265
```
gh # Root command
├── auth # Authentication
│ ├── login
│ ├── logout
│ ├── refresh
│ ├── setup-git
│ ├── status
│ ├── switch
│ └── token
├── browse # Open in browser
├── codespace # GitHub Codespaces
│ ├── code
│ ├── cp
│ ├── create
│ ├── delete
│ ├── edit
│ ├── jupyter
│ ├── list
│ ├── logs
│ ├── ports
│ ├── rebuild
│ ├── ssh
│ ├── stop
│ └── view
├── gist # Gists
│ ├── clone
│ ├── create
│ ├── delete
│ ├── edit
│ ├── list
│ ├── rename
│ └── view
├── issue # Issues
│ ├── create
│ ├── list
│ ├── status
│ ├── close
│ ├── comment
│ ├── delete
│ ├── develop
│ ├── edit
│ ├── lock
│ ├── pin
│ ├── reopen
│ ├── transfer
│ ├── unlock
│ └── view
├── org # Organizations
│ └── list
├── pr # Pull Requests
│ ├── create
│ ├── list
│ ├── status
│ ├── checkout
│ ├── checks
│ ├── close
│ ├── comment
│ ├── diff
│ ├── edit
│ ├── lock
│ ├── merge
│ ├── ready
│ ├── reopen
│ ├── revert
│ ├── review
│ ├── unlock
│ ├── update-branch
│ └── view
├── project # Projects
│ ├── close
│ ├── copy
│ ├── create
│ ├── delete
│ ├── edit
│ ├── field-create
│ ├── field-delete
│ ├── field-list
│ ├── item-add
│ ├── item-archive
│ ├── item-create
│ ├── item-delete
│ ├── item-edit
│ ├── item-list
│ ├── link
│ ├── list
│ ├── mark-template
│ ├── unlink
│ └── view
├── release # Releases
│ ├── create
│ ├── list
│ ├── delete
│ ├── delete-asset
│ ├── download
│ ├── edit
│ ├── upload
│ ├── verify
│ ├── verify-asset
│ └── view
├── repo # Repositories
│ ├── create
│ ├── list
│ ├── archive
│ ├── autolink
│ ├── clone
│ ├── delete
│ ├── deploy-key
│ ├── edit
│ ├── fork
│ ├── gitignore
│ ├── license
│ ├── rename
│ ├── set-default
│ ├── sync
│ ├── unarchive
│ └── view
├── cache # Actions caches
│ ├── delete
│ └── list
├── run # Workflow runs
│ ├── cancel
│ ├── delete
│ ├── download
│ ├── list
│ ├── rerun
│ ├── view
│ └── watch
├── workflow # Workflows
│ ├── disable
│ ├── enable
│ ├── list
│ ├── run
│ └── view
├── agent-task # Agent tasks
├── alias # Command aliases
│ ├── delete
│ ├── import
│ ├── list
│ └── set
├── api # API requests
├── attestation # Artifact attestations
│ ├── download
│ ├── trusted-root
│ └── verify
├── completion # Shell completion
├── config # Configuration
│ ├── clear-cache
│ ├── get
│ ├── list
│ └── set
├── extension # Extensions
│ ├── browse
│ ├── create
│ ├── exec
│ ├── install
│ ├── list
│ ├── remove
│ ├── search
│ └── upgrade
├── gpg-key # GPG keys
│ ├── add
│ ├── delete
│ └── list
├── label # Labels
│ ├── clone
│ ├── create
│ ├── delete
│ ├── edit
│ └── list
├── preview # Preview features
├── ruleset # Rulesets
│ ├── check
│ ├── list
│ └── view
├── search # Search
│ ├── code
│ ├── commits
│ ├── issues
│ ├── prs
│ └── repos
├── secret # Secrets
│ ├── delete
│ ├── list
│ └── set
├── ssh-key # SSH keys
│ ├── add
│ ├── delete
│ └── list
├── status # Status overview
└── variable # Variables
├── delete
├── get
├── list
└── set
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a language hint to the CLI structure code fence.

The block starts with ``` but no language, which violates MD040 and may fail markdownlint. Add a language (e.g., text) to silence the warning.

💡 Suggested fix
-```
+```text
 gh                          # Root command
 ├── auth                    # Authentication
 ...
 └── variable                # Variables
     ├── delete
     ├── get
     ├── list
     └── set
-```
+```
🧰 Tools
🪛 markdownlint-cli2 (0.20.0)

[warning] 70-70: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In @.agents/skills/gh-cli/SKILL.md around lines 70 - 265, The fenced ASCII CLI
structure block starting with the line "gh                          # Root
command" uses a bare code fence; update the opening fence from ``` to ```text to
provide a language hint (leave the block contents unchanged and keep the closing
fence as ```), which will satisfy markdownlint MD040.

- Add context to Drive API calls in FetchComments
- Add blank line before comments section in converter
- Escape markdown special chars in author names
- Update README to reflect comments feature status
@famasya famasya merged commit 6de2c79 into main Feb 13, 2026
2 checks passed
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.

What would it take to incorporate comments in the response?

1 participant