Skip to content

fix(ci): regenerate cua-driver reference docs on release bump - #1863

Closed
mvanhorn wants to merge 2 commits into
trycua:mainfrom
mvanhorn:fix/1522-ci-docs-generator-release-bump
Closed

fix(ci): regenerate cua-driver reference docs on release bump#1863
mvanhorn wants to merge 2 commits into
trycua:mainfrom
mvanhorn:fix/1522-ci-docs-generator-release-bump

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 7, 2026

Copy link
Copy Markdown

Summary

The cua-driver CLI/MCP reference docs are generated, but a version bump could ship without regenerating them, leaving the published reference stale (#1522). The release-bump workflow now regenerates the reference docs and attaches them to the release.

Changes

  • .github/workflows/release-bump-version.yml: after the version bump, run the docs generator (npx tsx scripts/docs-generators/cua-driver.ts), and if cli-reference.mdx / mcp-tools.mdx changed, commit them; the regenerated docs are attached to the release tag on the bump commit (the workflow errors out clearly if no release tag is found rather than silently skipping).
  • scripts/docs-generators/cua-driver.ts: hardened error reporting (errorMessage) so generation failures surface clearly in CI.

Testing

CI/codegen change. Verified the generator runs and the workflow's no-op (docs already current) and changed-docs paths are handled, plus the missing-tag guard.

Closes #1522

AI was used for assistance.

Summary by CodeRabbit

  • Documentation
    • Updated CLI reference documentation to version 0.5.1
    • Expanded MCP tools documentation with optional session arguments across multiple action and cursor tools
    • Enhanced documentation for launch_app, recording, and session management with improved clarity and conciseness

After the version bump, regenerate the CLI/MCP reference docs and, if they
changed, commit and attach them to the release tag (erroring clearly if no
tag is found). Hardens the generator's error reporting.

Closes trycua#1522

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

@mvanhorn is attempting to deploy a commit to the Cua Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements automatic regeneration of cua-driver reference documentation during release-bump operations. The workflow now runs on macOS for cua-driver-rs, executes the doc generator after version bumps, amends the commit to include any generated documentation changes, and improves error handling in the generator itself. Generated docs are updated to version 0.5.1 with a new optional session argument across multiple tools.

Changes

Release workflow with auto-generated docs regeneration

Layer / File(s) Summary
Workflow runner and version parsing
.github/workflows/release-bump-version.yml
Job now runs on macos-latest for cua-driver-rs and ubuntu-latest for other services; version extraction from Cargo.toml changed from grep to sed-based parsing.
Doc regeneration and commit amendment
.github/workflows/release-bump-version.yml
New conditional step runs the doc generator for cua-driver-rs, detects generated file changes, stages and amends the bump commit with those changes, then force-updates all release tags to the amended commit.
Generator error handling improvements
scripts/docs-generators/cua-driver.ts
New errorMessage() helper formats caught errors consistently; error paths in cargo build and dump-docs extraction now log formatted errors with actionable guidance before exiting.
Generated documentation updates
docs/content/docs/cua-driver/reference/cli-reference.mdx, docs/content/docs/cua-driver/reference/mcp-tools.mdx
Version bumped to 0.5.1 across both files; optional session argument added to action tools (click, double_click, right_click, drag, type_text, press_key, hotkey, set_value, scroll) and configuration tools (move_cursor); tool documentation refactored for recording lifecycle, cursor motion parameters, permissions return values, and session management.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • trycua/cua#1418: Updates to scripts/docs-generators/cua-driver.ts (new errorMessage() helper and improved error handling) directly modify the same generator that auto-generates the reference documentation.
  • trycua/cua#1364: Both PRs modify .github/workflows/release-bump-version.yml to extract and handle CUA driver versions during release (main: cua-driver-rs via sed parsing; retrieved: cua-driver via Swift source).
  • trycua/cua#1627: Both PRs update docs/content/docs/cua-driver/reference/mcp-tools.mdx with overlapping tool documentation changes (main adds session arguments and refactors docstrings; retrieved adds Windows behavior notes).

Poem

🐰 Docs drift away, version bumps in the night,
But now we regen when the versions align just right,
No stale-doc inheritance for the next release soul,
The workflow now tends its own documentation scroll!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 directly and clearly describes the main change: adding automatic regeneration of cua-driver reference docs during release version bumps in CI.
Linked Issues check ✅ Passed The PR successfully implements issue #1522's Option A: the release-bump workflow now regenerates docs and includes them in the same commit, and error reporting was hardened.
Out of Scope Changes check ✅ Passed All changes are in scope: workflow updates for CI, docs generator error handling, and the resulting regenerated reference docs (cli-reference.mdx, mcp-tools.mdx).

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
docs/content/docs/cua-driver/reference/mcp-tools.mdx (1)

527-533: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

set_agent_cursor_enabled docs are internally inconsistent about session vs cursor_id.

Line 527 tells users to pass session, but the argument list only documents cursor_id + enabled. Please align the prose and schema docs so client authors have one clear contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/content/docs/cua-driver/reference/mcp-tools.mdx` around lines 527 - 533,
The docs for set_agent_cursor_enabled use both "session" and "cursor_id"
inconsistently; update the prose and the Arguments section so they use a single
identifier name across the docstring (preferably matching the API parameter name
used in the code for set_agent_cursor_enabled), e.g., change the sentence "pass
`session` (the same id you start_session / drive actions with)" to use
`cursor_id` if that is the canonical parameter, or rename the argument entry to
`session` if that is the canonical API; ensure the description and default
('default') and legacy alias note remain accurate and consistent with the chosen
name throughout the function's doc block.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/release-bump-version.yml:
- Line 58: The cua-driver docs generator uses a shell pipeline relying on GNU
sort -V so update the tag selection in scripts/docs-generators/cua-driver.ts to
use git's native version sorting: replace the pipeline that uses `git tag | grep
"^${TAG_PREFIX}" | sort -V | tail -1` with a git-native call such as `git tag
--sort=-version:refname` (then pick the first entry) so TAG_PREFIX filtering and
latest-tag selection are done with git and will work on macOS/BSD; ensure you
still apply the TAG_PREFIX filter and fall back behavior remains the same when
no tags are found.

---

Outside diff comments:
In `@docs/content/docs/cua-driver/reference/mcp-tools.mdx`:
- Around line 527-533: The docs for set_agent_cursor_enabled use both "session"
and "cursor_id" inconsistently; update the prose and the Arguments section so
they use a single identifier name across the docstring (preferably matching the
API parameter name used in the code for set_agent_cursor_enabled), e.g., change
the sentence "pass `session` (the same id you start_session / drive actions
with)" to use `cursor_id` if that is the canonical parameter, or rename the
argument entry to `session` if that is the canonical API; ensure the description
and default ('default') and legacy alias note remain accurate and consistent
with the chosen name throughout the function's doc block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2ca4d520-9c8d-4975-af05-7521ddf50288

📥 Commits

Reviewing files that changed from the base of the PR and between c08f544 and fe58e4f.

📒 Files selected for processing (4)
  • .github/workflows/release-bump-version.yml
  • docs/content/docs/cua-driver/reference/cli-reference.mdx
  • docs/content/docs/cua-driver/reference/mcp-tools.mdx
  • scripts/docs-generators/cua-driver.ts

jobs:
bump-version:
runs-on: ubuntu-latest
runs-on: ${{ inputs.service == 'cua-driver-rs' && 'macos-latest' || 'ubuntu-latest' }}

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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Does the default macOS BSD sortcommand support the-V flag?

💡 Result:

The default macOS sort command does not support the -V (or --version-sort) flag [1][2]. While the -V flag is a standard feature of the GNU Coreutils sort command—widely available on Linux distributions [3][4]—the version of sort included with macOS is a BSD-based utility that predates the inclusion of this specific option [2]. If you require version-sorting functionality on macOS, you can achieve it by installing GNU Coreutils, which provides a version of sort that supports the -V flag (typically installed as gsort via Homebrew) [1]. Alternatively, you can use workarounds such as custom shell scripts or specific sorting commands (like using -n for simple numeric scenarios) to achieve similar results [1][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the generator file
ls -la scripts/docs-generators 2>/dev/null || true
fd -t f 'cua-driver.ts' scripts .github || true

# Search for sort -V usage across repo
rg -n --hidden --no-ignore -S "sort\s+-V|--version-sort|-V\b" .

# Inspect the relevant generator file if present
FILE="$(fd -t f 'cua-driver\.ts$' . | head -n 1 || true)"
if [ -n "${FILE}" ]; then
  echo "---- FILE: ${FILE} ----"
  # Show area around any sort invocation
  rg -n "sort\b" "${FILE}" || true
  # Show surrounding lines for the most relevant match(s)
  rg -n "sort\s+-V|--version-sort" "${FILE}" -C 5 || true
  # Print file (bounded) if it’s small; otherwise sample
  LINES=$(wc -l < "${FILE}")
  echo "---- ${FILE} has ${LINES} lines ----"
  if [ "${LINES}" -le 220 ]; then
    cat -n "${FILE}"
  else
    # show likely top and around matches
    head -n 120 "${FILE}" | nl -ba
    rg -n "sort\s+-V|--version-sort" "${FILE}" -n | cut -d: -f1 | head -n 1 | while read -r ln; do
      start=$((ln-40)); end=$((ln+60))
      sed -n "${start},${end}p" "${FILE}" | nl -ba
    done
  fi
else
  echo "Could not find scripts/docs-generators/cua-driver.ts in this repo snapshot."
fi

Repository: trycua/cua

Length of output: 11769


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the workflow lines around the runner selection
if [ -f .github/workflows/release-bump-version.yml ]; then
  echo "---- .github/workflows/release-bump-version.yml ----"
  sed -n '1,120p' .github/workflows/release-bump-version.yml | nl -ba | sed -n '45,90p' || true
  # Also locate where the cua-driver docs generator is invoked
  rg -n "docs-generators/cua-driver\.ts|npx\s+tsx\s+scripts/docs-generators/cua-driver\.ts|cua-driver\.ts" .github/workflows/release-bump-version.yml || true
  # Print the specific command area if found
  rg -n -C 6 "docs-generators/cua-driver\.ts|npx\s+tsx\s+scripts/docs-generators/cua-driver\.ts|cua-driver\.ts" .github/workflows/release-bump-version.yml || true
fi

# Inspect the cua-driver generator around the sort -V usage
if [ -f scripts/docs-generators/cua-driver.ts ]; then
  echo "---- scripts/docs-generators/cua-driver.ts (sort -V section) ----"
  sed -n '120,190p' scripts/docs-generators/cua-driver.ts | nl -ba
  echo "---- scripts/docs-generators/cua-driver.ts (how empty output is handled) ----"
  sed -n '190,260p' scripts/docs-generators/cua-driver.ts | nl -ba
fi

Repository: trycua/cua

Length of output: 885


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- .github/workflows/release-bump-version.yml (runner selection) ----"
sed -n '40,75p' .github/workflows/release-bump-version.yml

echo "---- scripts/docs-generators/cua-driver.ts (sort -V usage) ----"
sed -n '130,210p' scripts/docs-generators/cua-driver.ts

echo "---- scripts/docs-generators/cua-driver.ts (latest released version usage) ----"
sed -n '210,280p' scripts/docs-generators/cua-driver.ts

Repository: trycua/cua

Length of output: 6342


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Print tag prefix constants and the getLatestReleasedVersion implementation with context
sed -n '1,120p' scripts/docs-generators/cua-driver.ts
echo "---- getLatestReleasedVersion() ----"
sed -n '120,190p' scripts/docs-generators/cua-driver.ts

Repository: trycua/cua

Length of output: 4903


macOS runner breaks version-sorting in cua-driver docs generator

scripts/docs-generators/cua-driver.ts uses git tag | grep "^${TAG_PREFIX}" | sort -V | tail -1 to find the latest released tag; BSD sort on macOS doesn’t support -V, so the command will fail and the code falls back to 0.0.0 (potentially producing incorrect versioned docs). Switch to a git-native version sort (e.g., git tag --sort=-version:refname ...) instead of sort -V.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release-bump-version.yml at line 58, The cua-driver docs
generator uses a shell pipeline relying on GNU sort -V so update the tag
selection in scripts/docs-generators/cua-driver.ts to use git's native version
sorting: replace the pipeline that uses `git tag | grep "^${TAG_PREFIX}" | sort
-V | tail -1` with a git-native call such as `git tag --sort=-version:refname`
(then pick the first entry) so TAG_PREFIX filtering and latest-tag selection are
done with git and will work on macOS/BSD; ensure you still apply the TAG_PREFIX
filter and fall back behavior remains the same when no tags are found.

resolve_cursor_key accepts session before cursor_id, but the tool schema only
declared cursor_id, so the description told clients to pass an argument the
schema did not expose. Declare session and document cursor_id as its legacy
alias, then regenerate mcp-tools.mdx.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn

Copy link
Copy Markdown
Author

Good catch on the session / cursor_id mismatch — fixed at the source rather than in the generated mdx.

The prose was right and the schema was wrong: resolve_cursor_key checks session before cursor_id (and explicit_session_owns_a_cursor / cursor_id_is_a_legacy_alias cover both), but set_agent_cursor_enabled's input_schema only ever declared cursor_id. So a client reading the schema couldn't see the argument the description told it to pass.

The schema now declares session with the real description and documents cursor_id as "Legacy alias for session", and I regenerated mcp-tools.mdx--check reports no drift, and the 21 cursor tests pass.

@mvanhorn

Copy link
Copy Markdown
Author

Closing this -- main has solved both halves better than this PR does.

The docs regeneration: this branch hooked into release-bump-version.yml, which is now "Legacy packages: Bump Version" and states outright that Cua Driver and Lume use Release Please. cua-driver-rs isn't a service option there any more, so the step would never fire. cd-cua-driver-docs.yml now regenerates cli-reference.mdx + mcp-tools.mdx from the released binary's dump-docs and opens a PR for review, which is a better shape than amending the bump commit and force-moving the release tag the way this branch did.

The schema fix: the inline JSON literal is gone, and SetAgentCursorEnabledInput in cua-driver-contract already declares pub session: String as a required typed field. Since the input uses deny_unknown_fields, the cursor_id legacy alias I proposed would be rejected by design now -- your call is stricter than mine was, and correct.

One unrelated note in case it's useful: contributor-attribution fails on fork PRs because it GETs .github/release-attribution-config.json from the head repo (mvanhorn/cua) rather than the base, and 404s. That'll hit any outside contributor, not just this PR.

Thanks for the pointers on the original review.

@mvanhorn mvanhorn closed this Jul 27, 2026
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.

CI: re-run cua-driver docs generator on release-bump to prevent stale-version drift

1 participant