[PR #475] Harden vscode/cursor install-hooks when IDE CLI is not in PATH #497

Closed
opened 2026-03-02 04:13:48 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/475

State: closed
Merged: Yes


When code/cursor CLIs aren't in PATH, extension installation silently fails with a warning. The CLIs are just shell script wrappers over Electron's cli.js — we can call it directly as a fallback.

Changes

  • EditorCliCommand struct (utils.rs) — Encapsulates CLI invocation, handling both PATH binaries and the Electron + cli.js fallback (sets ELECTRON_RUN_AS_NODE=1, passes cli.js as first arg, handles Windows cmd /C wrapping)
  • resolve_editor_cli(name) — Checks PATH first, then searches known OS-specific install locations:
    • macOS: /Applications/{Cursor,Visual Studio Code}.app/Contents/...
    • Linux: /usr/share/, /opt/, ~/.local/share/
    • Windows: %LOCALAPPDATA%\Programs\...
  • is_vsc_editor_extension_installed / install_vsc_editor_extension — Now accept &EditorCliCommand instead of &str, using its command() builder
  • cursor.rs / vscode.rs — Replaced binary_exists() + raw program name with resolve_editor_cli() in both check_hooks() and install_extras()

How the fallback works

The code/cursor shell scripts essentially do:

ELECTRON_RUN_AS_NODE=1 "$APP/Contents/MacOS/Electron" "$APP/Contents/Resources/app/out/cli.js" "$@"

resolve_editor_cli finds these paths directly when the wrapper script isn't in PATH, constructs the equivalent command, and uses it for version checks, extension listing, and extension installation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Harden vscode/cursor install-hooks when the user doesn't have the IDE CLI installed in path</issue_title>
<issue_description>The code and cursor CLIs are just shell script wrappers over the core electron cli.js script. If the CLIs don't exist in the PATH we should try to mimic what the shell scripts do and call cli.js directly. This will ensure we get all extensions/hooked installed even when the CLIs aren't available</issue_description>

Comments on the Issue (you are @copilot in this section)

@svarlamov Image

This is also the root cause of the extension installation warnings for cursor/vscode</comment_new>


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/475 **State:** closed **Merged:** Yes --- When `code`/`cursor` CLIs aren't in `PATH`, extension installation silently fails with a warning. The CLIs are just shell script wrappers over Electron's `cli.js` — we can call it directly as a fallback. ### Changes - **`EditorCliCommand` struct** (`utils.rs`) — Encapsulates CLI invocation, handling both PATH binaries and the Electron + `cli.js` fallback (sets `ELECTRON_RUN_AS_NODE=1`, passes `cli.js` as first arg, handles Windows `cmd /C` wrapping) - **`resolve_editor_cli(name)`** — Checks PATH first, then searches known OS-specific install locations: - macOS: `/Applications/{Cursor,Visual Studio Code}.app/Contents/...` - Linux: `/usr/share/`, `/opt/`, `~/.local/share/` - Windows: `%LOCALAPPDATA%\Programs\...` - **`is_vsc_editor_extension_installed` / `install_vsc_editor_extension`** — Now accept `&EditorCliCommand` instead of `&str`, using its `command()` builder - **`cursor.rs` / `vscode.rs`** — Replaced `binary_exists()` + raw program name with `resolve_editor_cli()` in both `check_hooks()` and `install_extras()` ### How the fallback works The `code`/`cursor` shell scripts essentially do: ```sh ELECTRON_RUN_AS_NODE=1 "$APP/Contents/MacOS/Electron" "$APP/Contents/Resources/app/out/cli.js" "$@" ``` `resolve_editor_cli` finds these paths directly when the wrapper script isn't in `PATH`, constructs the equivalent command, and uses it for version checks, extension listing, and extension installation. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Harden vscode/cursor install-hooks when the user doesn't have the IDE CLI installed in path</issue_title> > <issue_description>The `code` and `cursor` CLIs are just shell script wrappers over the core electron `cli.js` script. If the CLIs don't exist in the `PATH` we should try to mimic what the shell scripts do and call `cli.js` directly. This will ensure we get all extensions/hooked installed even when the CLIs aren't available</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@svarlamov</author><body> > <img width="1390" height="264" alt="Image" src="https://github.com/user-attachments/assets/dcf3588c-093d-4325-acc5-e0ce77ea89af" /> > > This is also the root cause of the extension installation warnings for cursor/vscode</body></comment_new> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes git-ai-project/git-ai#185 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/git-ai-project/git-ai/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/475" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
kerem 2026-03-02 04:13:48 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#497
No description provided.