-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Improve Cursor Path Validation, Simplify Workbench Logic, and Enhance Error Handling #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Here's a professionally styled, beautiful version of your original instructions for resetting Cursor using `totally_reset_cursor.py`. This version is cleaner, well-structured, and easier to follow — suitable for documentation, a readme, or a developer guide: --- # 🔄 Cursor Reset Script Guide > A utility for fully or partially resetting Cursor IDE. --- ## 🚀 Basic Usage **▶️ Recommended First Try** Fully resets Cursor, including IDs and JS patches: ```bash python totally_reset_cursor.py ``` --- ## 🛡️ Safer Alternatives **🔧 Skip System IDs** Avoids modifying Windows Registry or macOS Plists (no admin/sudo rights needed): ```bash python totally_reset_cursor.py --skip-system-ids ``` **🎨 Skip JS Patches** Only resets machine IDs; keeps Cursor UI and behavior unchanged: ```bash python totally_reset_cursor.py --skip-js-patches ``` **🔐 Skip Both (Safe Mode)** Skips both system ID changes and JS patches: ```bash python totally_reset_cursor.py --skip-system-ids --skip-js-patches ``` --- ## ⚙️ Running with Admin/Sudo - **🪟 Windows:** Right-click the script or Terminal → **Run as Administrator** - **🍎 macOS / 🐧 Linux:** ```bash sudo python totally_reset_cursor.py ``` >⚠️ `sudo` is usually only needed on macOS when modifying system IDs. On Linux, it may be required if Cursor is installed in system-wide directories like `/opt` or `/usr/share`. --- ## 🧠 Important Notes - **📦 Backups Created:** `.bak` files are automatically created next to the original files for: - `storage.json` - `state.vscdb` - `machineId` - `main.js` - `workbench.desktop.main.js` - **🔐 Permissions:** You may need to run with elevated permissions if: - Cursor is installed in protected directories - System IDs are being modified - **💥 JS Patch Fragility:** Patches rely on hardcoded patterns in `main.js` and `workbench.desktop.main.js`. These may **break after Cursor updates**. Use `--skip-js-patches` if errors occur. - **⚠️ System ID Risks:** Editing system IDs via registry or plist can affect other software. Use `--skip-system-ids` to avoid this. Proceed with caution. - **🔄 Cursor Updates:** You may need to re-run this script or update patch logic after Cursor receives updates. - **📜 Terms of Service:** This script may violate Cursor’s Terms of Service. Use it **responsibly and at your own risk**. --- Let me know if you want this formatted for a markdown file (`README.md`) or want a GUI version of the reset tool.
## ⚙️ How to Use `bypass_version.py` ### 🔹 Requirements: - Python 3.6+ - Install dependency: ```bash pip install colorama ``` ### 🔹 Optional: - `utils.py`: Add if you have `get_user_documents_path()`. If missing, fallback is used. - Translator: Pass a `translator` object to `main()` if used in a larger app. ### 🔹 Run the Script: - **Normal Run:** ```bash python bypass_version.py ``` - **With Sudo/Admin (if needed):** ```bash sudo python bypass_version.py # macOS/Linux ``` On Windows: Right-click terminal → “Run as Administrator” >⚠️ Script checks if admin rights might be required (e.g., if Cursor is in `/opt`, `/usr/share`, or `/Applications`).
## 🔄 Key Changes Summary ### 📁 `find_cursor_app_resource_dir` Validation - Now checks for all 3 required files: - `package.json` - `out/main.js` - `out/vs/workbench/workbench.desktop.main.js` - Only returns path if **all exist**. - Updated success and error messages for clarity. ### 🧩 `get_workbench_cursor_path` Simplified - Since the workbench file is now guaranteed, complex checks were removed. - Basic `os.path.exists` kept for safety. ### 📦 New Imports - Added: `time`, `subprocess`, `errno` - Used in helper functions and the main block. ### ⚙️ Better Error Handling - `reset_machine_ids()` now separates: - Core ID reset steps - Optional JS patching - JS patching runs only if: - App path is found - Required files are writable ### ✅ Final Summary Clarity - Clearly distinguishes between: - Core reset failures (IDs, JSON, DB) - Optional issues (System IDs, JS patches)
❌ reset.process_error_unexpected ================================================== please verify is work , and commit the pr |
Summary:
This PR improves the reliability and maintainability of the reset script by introducing stricter path validation, simplifying workbench path logic, and enhancing overall error handling.
Changes:
Stricter App Resource Validation
find_cursor_app_resource_dir
now checks for the presence of all key files:package.json
out/main.js
out/vs/workbench/workbench.desktop.main.js
Simplified Workbench Path Resolution
get_workbench_cursor_path
assumes the workbench file exists (validated earlier).os.path.exists()
.Improved Error Handling and Flow Control
reset_machine_ids
.Additional:
time
,subprocess
,errno
.