Skip to content

[codex] docs(cua-driver): pivot to rust-first driver - #1738

Merged
f-trycua merged 8 commits into
mainfrom
codex/cua-driver-rust-first-docs
May 28, 2026
Merged

[codex] docs(cua-driver): pivot to rust-first driver#1738
f-trycua merged 8 commits into
mainfrom
codex/cua-driver-rust-first-docs

Conversation

@f-trycua

@f-trycua f-trycua commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make cua-driver the first/default docs product and remove the retired Swift integration page.
  • Rewrite install, intro, update, and platform docs around the Rust implementation as the default on macOS/Linux/Windows, including Windows install instructions in the root README.
  • Flip shell install/uninstall scripts to Rust-first defaults while keeping --backend=swift as the explicit legacy macOS path.
  • Regenerate cua-driver CLI/MCP reference pages from the Rust cua-driver dump-docs output and update docs CI to watch/build the Rust source.

Safety / Scope

  • Staged an explicit file allowlist for this PR.
  • Left local/unrelated files unstaged: .claude/, .gumbranch/, docs/pnpm-workspace.yaml, drafts/, and the pre-existing docs/pnpm-lock.yaml modification.
  • Ran a staged diff scan for common private keys and token patterns; no matches.

Validation

  • /Users/francesco/.cargo/bin/cargo build -p cua-driver --release
  • CARGO=/Users/francesco/.cargo/bin/cargo pnpm exec tsx ../scripts/docs-generators/cua-driver.ts --check
  • pnpm run docs:check-links
  • pnpm run build

pnpm run build passes with existing warnings around Shiki externalization, multiple lockfiles, deprecated middleware, and the Fumadocs provider import.

Summary by CodeRabbit

Release Notes

  • New Features

    • Cross-platform support for macOS, Linux, and Windows with unified installation experience
    • Updated CLI with new subcommands (status, mcp-config, enhanced recording and config commands)
    • Expanded MCP tools surface with new inspection and configuration capabilities
  • Documentation

    • Installation guides updated with platform-specific instructions for all supported operating systems
    • Comprehensive CLI and MCP tools reference documentation regenerated
    • Added Windows-specific workflows and diagnostics guidance
  • Improvements

    • Rust implementation now the default installer backend
    • Streamlined installation scripts and post-install instructions

Review Change Stack

@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 28, 2026 8:34am

Request Review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 14552227-ad94-4617-b86f-141551f1874b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Installer scripts, Rust code, CI/CD workflow, and documentation generation pipeline are updated to make the Rust implementation of cua-driver the canonical default on macOS, Linux, and Windows. Legacy Swift paths are retired, explicit backend flags are removed, BETA warnings are eliminated, and all user-facing guides and reference docs are regenerated from the Rust binary.

Changes

Rust Implementation as Default across All Platforms

Layer / File(s) Summary
Installer scripts and backend defaults
libs/cua-driver/scripts/install.sh, install-local.sh, install.ps1, _install-rust.sh, uninstall.sh, post-install-hints.txt
install.sh and uninstall.sh now default to Rust backend (USE_RUST_BACKEND=1); --backend=swift becomes explicit opt-in for retired legacy path. Legacy env var names are mapped to Rust-specific variants (CUA_DRIVER_RS_*). BETA warning messages removed. All scripts document Rust as canonical default.
Rust code: update and install invocations
libs/cua-driver/rust/crates/cua-driver/src/cli.rs, updater.rs, version_check.rs
CLI docs helper generates full JSON structure via cli_docs_json(). Install script invocations remove explicit --backend=rust arguments; Unix installer pipeline simplified to plain curl ... | bash delegating to install.sh defaults. Module docs updated to reflect Rust as primary path.
Documentation generation infrastructure
.github/workflows/ci-check-docs.yml, scripts/docs-generators/config.json, .../cua-driver.ts
CI workflow watches Rust crate files (libs/cua-driver/rust/crates/**, Cargo.toml, Cargo.lock) instead of Swift sources. Generator config switches to Rust language, cargo build command, and target/release/cua-driver binary. Build step changes from swift build to cargo build -p cua-driver --release.
Documentation generator script refinements
scripts/docs-generators/cua-driver.ts
Generator adds resolveCargoCommand() helper to locate cargo; switches table row emission to multiline template construction; introduces MCP tool categorization (inspection/action/browser/recording/configuration/maintenance); computes conditional description suffixes; refactors coordinate alias logic; updates auto-generated header comments to reference cua-driver dump-docs.
Installation and getting-started guides
docs/content/docs/cua-driver/guide/getting-started/installation.mdx, introduction.mdx, linux.mdx, quickstart.mdx, updating.mdx, windows-ssh.mdx, process-model.mdx, meta.json
Installation guide consolidates macOS/Linux/Windows commands into platform table; introduces new env vars and clarified descriptions. Introduction reframes cua-driver as cross-platform MCP-over-stdio driver. New sections cover capture modes, platform backends, TCC auto-delegation (macOS), and daemon-proxy behavior (Windows/Linux). Swift integration guide (swift-integration.mdx) removed from metadata and file tree. Update surfaces and install-command examples simplified to plain curl | bash form.
Reference documentation
docs/content/docs/cua-driver/reference/cli-reference.mdx, mcp-tools.mdx
CLI reference updated from 0.2.0 to 0.3.1; tool dispatch reordered; cua-driver call options changed (adds --screenshot-out-file, --socket; removes --raw, --compact, --no-daemon). New commands documented: status, mcp-config, check-update, doctor, diagnose, autostart, skills. MCP tools reorganized into categories with updated filtering/return semantics; tool count increased from 29 to 33.
Documentation site structure
docs/content/docs/meta.json, docs/src/components/custom-header.tsx, README.md
cua-driver moved to first position in docs navigation and marked as default site (isDefault: true). README section updated to describe cross-platform support with macOS/Linux shell and Windows PowerShell install snippets. Navigation anchor changed to cross-platform slug. Generator README documents Rust cua-driver generator and dump-docs extraction method.
Release and workflow messaging
.github/workflows/cd-rust-cua-driver.yml
Release asset staging comments clarified to reflect Rust helper script location and default delegation. GitHub Release body shortened to focus on cross-platform Rust port and tag-prefix collision prevention. BETA banner and detailed flag documentation removed. Install section text states shell installer installs Rust implementation by default.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • trycua/cua#1665: Uninstall convergence work that inlines uninstall-rust logic and redefines Rust-default behavior, overlapping directly with this PR's uninstall.sh refactor.
  • trycua/cua#1418: Introduces the dump-docs command and extractors that drive the generated CLI/MCP references now updated in this PR's documentation pipeline.
  • trycua/cua#1673: Modifies the same updater/version-check install-command helpers (run_install_script, install_one_liner) to delegate to canonical installer script.

Poem

🐰 The Rust path now leads the way,
Through Swift's retirement to brighter day,
No more "BETA" warnings cloud the air,
Just cargo, docs, and platforms fair. 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title '[codex] docs(cua-driver): pivot to rust-first driver' directly and clearly summarizes the main change: pivoting the cua-driver documentation to be Rust-first instead of Swift-first across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cua-driver-rust-first-docs

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: 4

Caution

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

⚠️ Outside diff range comments (3)
libs/cua-driver/scripts/uninstall.sh (1)

273-297: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard skill symlink deletion behind Rust-install detection.

This loop can delete Swift-owned .../skills/cua-driver links even when RUST_INSTALL_PRESENT=0 (Swift-only host running default uninstall path). Apply the same Rust-marker guard used for shared app/symlink paths.

Suggested fix
-    for SKILL_LINK in \
+    for SKILL_LINK in \
         "$HOME/.claude/skills/$SKILL_PACK_NAME" \
         "$HOME/.agents/skills/$SKILL_PACK_NAME" \
         "$HOME/.openclaw/skills/$SKILL_PACK_NAME" \
         "$HOME/.config/opencode/skills/$SKILL_PACK_NAME" \
         "$HOME/.claude/skills/$LEGACY_SKILL_PACK_NAME" \
         "$HOME/.agents/skills/$LEGACY_SKILL_PACK_NAME" \
         "$HOME/.openclaw/skills/$LEGACY_SKILL_PACK_NAME" \
         "$HOME/.config/opencode/skills/$LEGACY_SKILL_PACK_NAME"; do
+        # `cua-driver` skill link name is shared with the legacy Swift path.
+        # Only remove shared-name links when a Rust install marker exists.
+        if [[ "$SKILL_LINK" == *"/$SKILL_PACK_NAME" ]] && [[ "$RUST_INSTALL_PRESENT" != "1" ]]; then
+            log "$SKILL_LINK uses shared skill name and no Rust marker is present (skipping)"
+            continue
+        fi
         if [[ -L "$SKILL_LINK" ]]; then
             rm -f "$SKILL_LINK"
             log "removed skill symlink $SKILL_LINK"
🤖 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 `@libs/cua-driver/scripts/uninstall.sh` around lines 273 - 297, The
skill-symlink removal loop (iterating SKILL_LINKs built from SKILL_PACK_NAME and
LEGACY_SKILL_PACK_NAME) must be executed only when the Rust install marker is
present; wrap that entire for-loop in the same Rust-install guard used elsewhere
by checking RUST_INSTALL_PRESENT (e.g., if [[ "$RUST_INSTALL_PRESENT" -ne 0 ]]
or if [[ "$RUST_INSTALL_PRESENT" == "1" ]]; then ... fi) so the loop runs only
when Rust was installed and does not remove Swift-owned skill symlinks on
Swift-only hosts.
docs/content/docs/cua-driver/guide/getting-started/linux.mdx (1)

83-86: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix the broken install-local.sh GitHub link (CI is failing on this 404).

The URL points to libs/cua-driver/rust/scripts/install-local.sh, which currently resolves to 404 in link-check CI. Update it to the non-rust/ scripts path.

Suggested doc fix
-See [`libs/cua-driver/rust/scripts/install-local.sh`](https://github.com/trycua/cua/blob/main/libs/cua-driver/rust/scripts/install-local.sh) — built for local development off a git checkout, but the systemd unit it writes is the same shape you'd use in production.
+See [`libs/cua-driver/scripts/install-local.sh`](https://github.com/trycua/cua/blob/main/libs/cua-driver/scripts/install-local.sh) — built for local development off a git checkout, but the systemd unit it writes is the same shape you'd use in production.
🤖 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/guide/getting-started/linux.mdx` around lines 83
- 86, The markdown link in
docs/content/docs/cua-driver/guide/getting-started/linux.mdx points to a 404
path `libs/cua-driver/rust/scripts/install-local.sh`; update that href to the
correct non-`rust` scripts path (e.g.
`libs/cua-driver/scripts/install-local.sh`) so the anchor in the "Option A — Use
`install-local.sh --autostart`" paragraph points to the existing script; edit
the link text in that paragraph to match the new URL.
docs/content/docs/cua-driver/guide/getting-started/process-model.mdx (1)

129-133: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove or replace the dead trycua/hermes PR link (404 in docs CI).

This external PR URL currently fails link checks. Please switch to a non-link reference (or a reachable public URL) to keep CI green.

Suggested doc fix
-The MCP client surfaces this as a tool error. The mcp-client process **does not** auto-restart the daemon mid-session. The recommended client behavior is: catch the error, optionally restart the daemon yourself (`open -n -g -a CuaDriver --args serve`), reconnect the MCP transport, and retry. Hermes' wrapper in [trycua/hermes#22821](https://github.com/trycua/hermes/pull/22821) implements exactly this pattern.
+The MCP client surfaces this as a tool error. The mcp-client process **does not** auto-restart the daemon mid-session. The recommended client behavior is: catch the error, optionally restart the daemon yourself (`open -n -g -a CuaDriver --args serve`), reconnect the MCP transport, and retry. Hermes' wrapper (trycua/hermes PR `#22821`) implements exactly this pattern.
🤖 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/guide/getting-started/process-model.mdx` around
lines 129 - 133, Replace the dead external PR link used in the sentence "Hermes'
wrapper in [trycua/hermes#22821](https://github.com/trycua/hermes/pull/22821)
implements exactly this pattern." with a non-link reference or a reachable URL:
update the text to either "Hermes' wrapper in trycua/hermes#22821 implements
exactly this pattern." (plain text reference) or point to an accessible public
resource demonstrating the same behavior, ensuring the token
"trycua/hermes#22821" in the sentence is preserved so readers can locate the PR
if needed.
🤖 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 `@docs/content/docs/cua-driver/guide/getting-started/installation.mdx`:
- Around line 202-205: Update the Windows lockfile path to use the same
canonical home variable as the Linux row: replace the legacy `.cua-driver-rs`
usage with the `$CUA_DRIVER_RS_HOME` variable and change the Windows example
string `$env:CUA_DRIVER_RS_HOME\install.lock` (or any occurrence of
`.cua-driver-rs`) so it consistently reads `$CUA_DRIVER_RS_HOME\install.lock`
(preserve the PowerShell `$env:` prefix if needed) in the table row text.

In `@libs/cua-driver/rust/crates/cua-driver/src/cli.rs`:
- Around line 1568-1574: cli_docs_json() currently advertises a "record-video"
flag for the "recording start" command, but the CLI parser/handler does not
accept or use this flag; either remove the "record-video" entry from the JSON
generation in cli_docs_json() or implement support for the flag in the parser
and handler for the recording start command (e.g., add a boolean option parsed
into the start handling path and propagate it to the recording logic). Locate
the JSON generation in cli_docs_json() and the "recording start" command handler
to make the change so documentation and runtime behavior stay in sync.

In `@libs/cua-driver/rust/crates/cua-driver/src/version_check.rs`:
- Line 157: version_check.rs currently builds the install one-liner string
without forcing the Rust backend; update the code that constructs the
install_command string (the variable/assignment that currently is "curl -fsSL
https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh
| bash".to_owned()) to detect macOS (e.g. cfg!(target_os = "macos") or
std::env::consts::OS == "macos") and, when true, append " --backend=rust" (or
add the flag into the piped command) so the installer will install the Rust
backend on macOS while leaving non-macOS behavior unchanged. Ensure the result
remains an owned String and update any tests or usages that rely on
install_command if needed.

In `@scripts/docs-generators/cua-driver.ts`:
- Around line 109-131: resolveCargoCommand currently reads HOME from process.env
which can be undefined on Windows; import and use Node's os.homedir() to
reliably get the user's home across platforms. Add an import for the os module
(or homedir) at the top of the file and change the candidate that builds the
~/.cargo path to use os.homedir() (falling back to '' if necessary) instead of
process.env.HOME; keep the rest of the candidate list and the execFileSync check
intact so cargo discovery still tries the same locations.

---

Outside diff comments:
In `@docs/content/docs/cua-driver/guide/getting-started/linux.mdx`:
- Around line 83-86: The markdown link in
docs/content/docs/cua-driver/guide/getting-started/linux.mdx points to a 404
path `libs/cua-driver/rust/scripts/install-local.sh`; update that href to the
correct non-`rust` scripts path (e.g.
`libs/cua-driver/scripts/install-local.sh`) so the anchor in the "Option A — Use
`install-local.sh --autostart`" paragraph points to the existing script; edit
the link text in that paragraph to match the new URL.

In `@docs/content/docs/cua-driver/guide/getting-started/process-model.mdx`:
- Around line 129-133: Replace the dead external PR link used in the sentence
"Hermes' wrapper in
[trycua/hermes#22821](https://github.com/trycua/hermes/pull/22821) implements
exactly this pattern." with a non-link reference or a reachable URL: update the
text to either "Hermes' wrapper in trycua/hermes#22821 implements exactly this
pattern." (plain text reference) or point to an accessible public resource
demonstrating the same behavior, ensuring the token "trycua/hermes#22821" in the
sentence is preserved so readers can locate the PR if needed.

In `@libs/cua-driver/scripts/uninstall.sh`:
- Around line 273-297: The skill-symlink removal loop (iterating SKILL_LINKs
built from SKILL_PACK_NAME and LEGACY_SKILL_PACK_NAME) must be executed only
when the Rust install marker is present; wrap that entire for-loop in the same
Rust-install guard used elsewhere by checking RUST_INSTALL_PRESENT (e.g., if [[
"$RUST_INSTALL_PRESENT" -ne 0 ]] or if [[ "$RUST_INSTALL_PRESENT" == "1" ]];
then ... fi) so the loop runs only when Rust was installed and does not remove
Swift-owned skill symlinks on Swift-only hosts.
🪄 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: 5a0c0981-9f9a-4498-8c02-255b0bdcb04e

📥 Commits

Reviewing files that changed from the base of the PR and between 7d893ce and ea6683d.

📒 Files selected for processing (28)
  • .github/workflows/cd-rust-cua-driver.yml
  • .github/workflows/ci-check-docs.yml
  • README.md
  • docs/content/docs/cua-driver/guide/getting-started/installation.mdx
  • docs/content/docs/cua-driver/guide/getting-started/introduction.mdx
  • docs/content/docs/cua-driver/guide/getting-started/linux.mdx
  • docs/content/docs/cua-driver/guide/getting-started/meta.json
  • docs/content/docs/cua-driver/guide/getting-started/process-model.mdx
  • docs/content/docs/cua-driver/guide/getting-started/quickstart.mdx
  • docs/content/docs/cua-driver/guide/getting-started/swift-integration.mdx
  • docs/content/docs/cua-driver/guide/getting-started/updating.mdx
  • docs/content/docs/cua-driver/guide/getting-started/windows-ssh.mdx
  • docs/content/docs/cua-driver/reference/cli-reference.mdx
  • docs/content/docs/cua-driver/reference/mcp-tools.mdx
  • docs/content/docs/meta.json
  • docs/src/components/custom-header.tsx
  • libs/cua-driver/rust/crates/cua-driver/src/cli.rs
  • libs/cua-driver/rust/crates/cua-driver/src/updater.rs
  • libs/cua-driver/rust/crates/cua-driver/src/version_check.rs
  • libs/cua-driver/scripts/_install-rust.sh
  • libs/cua-driver/scripts/install-local.sh
  • libs/cua-driver/scripts/install.ps1
  • libs/cua-driver/scripts/install.sh
  • libs/cua-driver/scripts/post-install-hints.txt
  • libs/cua-driver/scripts/uninstall.sh
  • scripts/docs-generators/README.md
  • scripts/docs-generators/config.json
  • scripts/docs-generators/cua-driver.ts
💤 Files with no reviewable changes (1)
  • docs/content/docs/cua-driver/guide/getting-started/swift-integration.mdx

Comment on lines +202 to +205
| Platform | Lock |
| -------- | ------------------------------------------------------------------- |
| Linux | `$CUA_DRIVER_RS_HOME/packages/.install.lock.d/` (mkdir-based mutex) |
| Windows | `$env:CUA_DRIVER_RS_HOME\install.lock` (`FileShare::None` mutex) |

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 | ⚡ Quick win

Align Windows lockfile path with the documented home variable.

This section says the lock is at $env:CUA_DRIVER_RS_HOME\install.lock, but the example above still uses the legacy .cua-driver-rs path. Keeping one canonical path here avoids failed copy/paste checks.

Suggested doc fix
-Get-Content $env:USERPROFILE\.cua-driver-rs\install.lock
+Get-Content $env:CUA_DRIVER_RS_HOME\install.lock
🤖 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/guide/getting-started/installation.mdx` around
lines 202 - 205, Update the Windows lockfile path to use the same canonical home
variable as the Linux row: replace the legacy `.cua-driver-rs` usage with the
`$CUA_DRIVER_RS_HOME` variable and change the Windows example string
`$env:CUA_DRIVER_RS_HOME\install.lock` (or any occurrence of `.cua-driver-rs`)
so it consistently reads `$CUA_DRIVER_RS_HOME\install.lock` (preserve the
PowerShell `$env:` prefix if needed) in the table row text.

Comment on lines +1568 to +1574
"name":"start",
"abstract":"Start trajectory recording to a directory.",
"discussion":"",
"arguments":[{"name":"output-dir","help":"Directory to write turn folders into.","type":"String","is_optional":false}],
"options":[],
"flags":[{"name":"record-video","short_name":null,"help":"Also record a video when supported by the platform.","default_value":false}],
"subcommands":[]

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 | ⚡ Quick win

Remove or implement record-video in CLI docs JSON.

cli_docs_json() advertises recording start --record-video, but the parser/handler path doesn’t consume this flag, so generated reference docs are inaccurate.

Suggested fix (docs-first)
-                        "flags":[{"name":"record-video","short_name":null,"help":"Also record a video when supported by the platform.","default_value":false}],
+                        "flags":[],
🤖 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 `@libs/cua-driver/rust/crates/cua-driver/src/cli.rs` around lines 1568 - 1574,
cli_docs_json() currently advertises a "record-video" flag for the "recording
start" command, but the CLI parser/handler does not accept or use this flag;
either remove the "record-video" entry from the JSON generation in
cli_docs_json() or implement support for the flag in the parser and handler for
the recording start command (e.g., add a boolean option parsed into the start
handling path and propagate it to the recording logic). Locate the JSON
generation in cli_docs_json() and the "recording start" command handler to make
the change so documentation and runtime behavior stay in sync.

#[cfg(not(windows))]
{
"curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh | bash -s -- install --backend=rust".to_owned()
"curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh | bash".to_owned()

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 | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify install.sh defaults to Rust backend and accepts no arguments.

# Fetch and inspect the install.sh script
curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh > /tmp/install.sh

# Check what happens when no arguments are provided
echo "=== Checking install.sh argument parsing ==="
rg -n "backend.*=.*rust|DEFAULT.*BACKEND|BACKEND.*=" /tmp/install.sh | head -20

# Check if script still accepts --backend flag for legacy Swift path
echo ""
echo "=== Checking --backend flag support ==="
rg -n "\-\-backend" /tmp/install.sh | head -10

# Check the main install logic
echo ""
echo "=== Checking main install dispatch ==="
rg -nA5 "case.*backend|if.*backend" /tmp/install.sh | head -30

Repository: trycua/cua

Length of output: 1316


🏁 Script executed:

#!/bin/bash
set -euo pipefail

curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh > /tmp/install.sh

echo "=== Showing USE_RUST_BACKEND initialization & auto-set logic ==="
nl -ba /tmp/install.sh | sed -n '50,140p'

echo ""
echo "=== Showing the install dispatch when USE_RUST_BACKEND==1 ==="
nl -ba /tmp/install.sh | sed -n '140,240p'

echo ""
echo "=== Showing any mention of Swift install path when USE_RUST_BACKEND==0 ==="
rg -n "swift|SWIFT|rust|RUST|USE_RUST_BACKEND" /tmp/install.sh | head -80

Repository: trycua/cua

Length of output: 180


🏁 Script executed:

#!/bin/bash
set -euo pipefail

curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh > /tmp/install.sh

echo "=== USE_RUST_BACKEND initialization & auto-set logic (lines ~50-140) ==="
awk '{print FNR ":" $0}' /tmp/install.sh | sed -n '50,140p'

echo ""
echo "=== Install dispatch when USE_RUST_BACKEND==1 (lines ~140-260) ==="
awk '{print FNR ":" $0}' /tmp/install.sh | sed -n '140,260p'

echo ""
echo "=== Swift/rust install path mentions ==="
rg -n "swift|SWIFT|rust|RUST|USE_RUST_BACKEND" /tmp/install.sh | head -80

Repository: trycua/cua

Length of output: 12556


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="libs/cua-driver/rust/crates/cua-driver/src/version_check.rs"
echo "=== Context around $FILE:157 ==="
awk 'NR>=130 && NR<=190 {printf "%5d: %s\n", NR, $0}' "$FILE"

echo ""
echo "=== Find where the install command string is constructed/used ==="
rg -n "install\\.sh \\| bash|curl -fsSL https://raw\\.githubusercontent\\.com/trycua/cua/main/libs/cua-driver/scripts/install\\.sh \\| bash" "$FILE"

echo ""
echo "=== Find other references to check-update / MCP tool usage in this crate ==="
rg -n "check-update|MCP|mcp" libs/cua-driver/rust/crates/cua-driver/src | head -50

Repository: trycua/cua

Length of output: 9539


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "install_command|install_one_liner|check_update_state|check_for_update" libs/cua-driver/rust/crates/cua-driver/src/version_check.rs libs/cua-driver/rust/crates/cua-driver/src | head -100

echo "=== Find dispatch/serialization in version_check.rs ==="
rg -n "install_command" libs/cua-driver/rust/crates/cua-driver/src/version_check.rs

Repository: trycua/cua

Length of output: 4434


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="libs/cua-driver/rust/crates/cua-driver/src/version_check.rs"
echo "=== version_check.rs around install_one_liner + UpdateState population ==="
awk 'NR>=140 && NR<=270 {printf "%5d: %s\n", NR, $0}' "$FILE"

echo ""
FILE2="libs/cua-driver/rust/crates/cua-driver/src/updater.rs"
echo "=== updater.rs manual_install_one_liner ==="
awk 'NR>=1 && NR<=140 {printf "%5d: %s\n", NR, $0}' "$FILE2"

echo ""
echo "=== Any docs mentioning what install_command is supposed to do ==="
rg -n "install_command|manual_install_one_liner|install\\.sh \\| bash" libs/cua-driver/rust/crates/cua-driver/src | head -100

Repository: trycua/cua

Length of output: 12007


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "cua-driver-rs|backend=rust|experimental-rust|_install-rust|cua-driver is macOS-only" libs/cua-driver/rust/crates/cua-driver/src | head -200

echo ""
rg -n "check_for_update|check-update|install_command|manual_install_one_liner" libs/cua-driver/rust/crates/cua-driver/src | head -200

Repository: trycua/cua

Length of output: 16246


Fix update install one-liner to force Rust backend on macOS

version_check.rs emits curl …/install.sh | bash without --backend=rust. But install.sh defaults to the Swift install path on macOS; it only installs the Rust port when --backend=rust/--experimental-rust is passed (or auto-selects Rust on non-macOS). Since this Rust crate is tracking cua-driver-rs-v* releases, the install_command should append --backend=rust on macOS to match the backend/version being offered.

🤖 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 `@libs/cua-driver/rust/crates/cua-driver/src/version_check.rs` at line 157,
version_check.rs currently builds the install one-liner string without forcing
the Rust backend; update the code that constructs the install_command string
(the variable/assignment that currently is "curl -fsSL
https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh
| bash".to_owned()) to detect macOS (e.g. cfg!(target_os = "macos") or
std::env::consts::OS == "macos") and, when true, append " --backend=rust" (or
add the flag into the piped command) so the installer will install the Rust
backend on macOS while leaving non-macOS behavior unchanged. Ensure the result
remains an owned String and update any tests or usages that rely on
install_command if needed.

Comment on lines +109 to +131
function resolveCargoCommand(): string {
if (process.env.CARGO) {
return process.env.CARGO;
}

const candidates = [
'cargo',
path.join(process.env.HOME || '', '.cargo', 'bin', 'cargo'),
'/opt/homebrew/bin/cargo',
'/usr/local/bin/cargo',
];

for (const candidate of candidates) {
try {
execFileSync(candidate, ['--version'], { stdio: 'ignore' });
return candidate;
} catch {
// Try the next candidate.
}
}

throw new Error('cargo not found on PATH; install Rust or set CARGO=/path/to/cargo');
}

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 | ⚡ Quick win

Cross-platform HOME directory resolution issue.

process.env.HOME may be undefined on Windows, which would silently skip the ~/.cargo/bin/cargo candidate and potentially cause cargo discovery to fail on Windows systems where cargo is only in the user profile.

🔧 Proposed fix using Node.js os.homedir()

Add the import at the top of the file:

 import { execFileSync, execSync } from 'child_process';
 import * as fs from 'fs';
 import * as path from 'path';
+import * as os from 'os';

Then update the function:

 function resolveCargoCommand(): string {
   if (process.env.CARGO) {
     return process.env.CARGO;
   }
 
   const candidates = [
     'cargo',
-    path.join(process.env.HOME || '', '.cargo', 'bin', 'cargo'),
+    path.join(os.homedir(), '.cargo', 'bin', 'cargo'),
     '/opt/homebrew/bin/cargo',
     '/usr/local/bin/cargo',
   ];
📝 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
function resolveCargoCommand(): string {
if (process.env.CARGO) {
return process.env.CARGO;
}
const candidates = [
'cargo',
path.join(process.env.HOME || '', '.cargo', 'bin', 'cargo'),
'/opt/homebrew/bin/cargo',
'/usr/local/bin/cargo',
];
for (const candidate of candidates) {
try {
execFileSync(candidate, ['--version'], { stdio: 'ignore' });
return candidate;
} catch {
// Try the next candidate.
}
}
throw new Error('cargo not found on PATH; install Rust or set CARGO=/path/to/cargo');
}
function resolveCargoCommand(): string {
if (process.env.CARGO) {
return process.env.CARGO;
}
const candidates = [
'cargo',
path.join(os.homedir(), '.cargo', 'bin', 'cargo'),
'/opt/homebrew/bin/cargo',
'/usr/local/bin/cargo',
];
for (const candidate of candidates) {
try {
execFileSync(candidate, ['--version'], { stdio: 'ignore' });
return candidate;
} catch {
// Try the next candidate.
}
}
throw new Error('cargo not found on PATH; install Rust or set CARGO=/path/to/cargo');
}
🤖 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 `@scripts/docs-generators/cua-driver.ts` around lines 109 - 131,
resolveCargoCommand currently reads HOME from process.env which can be undefined
on Windows; import and use Node's os.homedir() to reliably get the user's home
across platforms. Add an import for the os module (or homedir) at the top of the
file and change the candidate that builds the ~/.cargo path to use os.homedir()
(falling back to '' if necessary) instead of process.env.HOME; keep the rest of
the candidate list and the execFileSync check intact so cargo discovery still
tries the same locations.

f-trycua added a commit that referenced this pull request May 29, 2026
…apps (#1754)

Closes #1537. Cherry-picked from #1609 (@hippoley) — same fix concept,
ported to the post-#1674 path layout (`libs/cua-driver/rust/crates/`)
and dropped the Swift backend change (path being deprecated per #1738).

- `ax/tree.rs`: `MAX_ELEMENTS = 2000` cap with `TreeWalkResult.truncated`
  surfaced as a warning line at the end of `tree_markdown`.
- `tools/get_window_state.rs`: `tokio::time::timeout(30s)` wrap on the
  `spawn_blocking` AX walk. On expiry returns a clear error suggesting
  `capture_mode=vision` or a `query` filter rather than hanging
  forever.

Reported by @obaid against Arc / Safari w/ many tabs on macOS 26
where `AXUIElementCopyAttributeValue` blocks indefinitely via XPC on
pathologically large trees.

Co-authored-by: hippoley <noreply@github.com>
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.

1 participant