$npx -y skills add JimLiu/baoyu-skills --skill baoyu-electron-extractExtracts resources and JavaScript from any installed Electron app (.asar bundle), restoring original sources from .js.map files when available or formatting minified code with Prettier otherwise. Use when user wants to "extract Electron app", "decompile Electron", "get the so
| 1 | # Electron App Extract |
| 2 | |
| 3 | Extracts resources and code from an installed Electron app's `app.asar`. When a `.js.map` is present, restores the original source files from the embedded `sourcesContent`; otherwise formats the minified code with Prettier. Source-map paths are resolved relative to the `.js.map` file first, so bundled paths like `../../src/main.ts` restore to readable paths such as `restored/src/main.ts` instead of hashed placeholders. Always skips `node_modules`. Works on macOS and Windows. |
| 4 | |
| 5 | ## User Input Tools |
| 6 | |
| 7 | When this skill prompts the user, follow this tool-selection rule (priority order): |
| 8 | |
| 9 | 1. **Prefer built-in user-input tools** exposed by the current agent runtime — e.g., `AskUserQuestion`, `request_user_input`, `clarify`, `ask_user`, or any equivalent. |
| 10 | 2. **Fallback**: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question. |
| 11 | 3. **Batching**: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order. |
| 12 | |
| 13 | Concrete `AskUserQuestion` references below are examples — substitute the local equivalent in other runtimes. |
| 14 | |
| 15 | ## Script Directory |
| 16 | |
| 17 | Scripts in `scripts/` subdirectory. `{baseDir}` = this SKILL.md's directory path. Resolve `${BUN_X}` runtime: if `bun` installed → `bun`; if `npx` available → `npx -y bun`; else suggest installing bun. Replace `{baseDir}` and `${BUN_X}` with actual values. |
| 18 | |
| 19 | | Script | Purpose | |
| 20 | | ----------------- | ------------------------------------------------------------------------------ | |
| 21 | | `scripts/main.ts` | App discovery + asar extraction + source-map restoration + Prettier formatting | |
| 22 | |
| 23 | ## When to use |
| 24 | |
| 25 | Use this skill whenever the user wants to look inside an installed Electron application or inspect its bundled code. Trigger phrases include: |
| 26 | |
| 27 | - "extract Electron app", "decompile this Electron app", "unpack app.asar" |
| 28 | - "show me the source of <app>", "look inside <app>", "how is <app> built" |
| 29 | - "get the source code of Codex / Cursor / Discord / Slack / VS Code / Notion / Obsidian / ChatGPT desktop" |
| 30 | - "提取 Electron 应用", "看 <app> 的源码", "反编译 Electron", "解包 app.asar", "还原 source map" |
| 31 | |
| 32 | Both **app name** (e.g., `Codex`) and **absolute path** (e.g., `/Applications/Codex.app`, a `.asar` file, or a Windows install dir) are accepted. The script handles discovery for both platforms. |
| 33 | |
| 34 | ## Workflow |
| 35 | |
| 36 | **1. Determine the input.** Ask the user for the app name or path if they haven't given one. If they want a custom output directory, ask for that too. |
| 37 | |
| 38 | **2. Run the script.** |
| 39 | |
| 40 | ```bash |
| 41 | ${BUN_X} {baseDir}/scripts/main.ts "<app>" [--output <dir>] [--asar <path>] [--force] |
| 42 | ``` |
| 43 | |
| 44 | Start with `--dry-run` first if you're unsure whether discovery will find the right bundle — it prints the resolved paths and exits without touching the filesystem. |
| 45 | |
| 46 | **3. Handle the result.** |
| 47 | |
| 48 | - **Success** → report the output paths and the counts (extracted / restored / formatted). |
| 49 | - **Multiple matches** → the script lists candidates and exits non-zero. Show the user the candidates, ask which one to use (via `AskUserQuestion` or the runtime equivalent), then re-run with the chosen absolute path. |
| 50 | - **Existing non-empty output dir** → the script refuses without `--force`. Ask the user whether to overwrite (`--force`) or pick a new `--output` path. |
| 51 | - **Unsupported platform / no match** → suggest passing `--asar /full/path/to/app.asar` if the user knows where the bundle lives. |
| 52 | |
| 53 | **4. Point the user at the result.** The default output dir is `~/Downloads/<AppName>-electron-extract/`. The most interesting subdirectory depends on what was found: |
| 54 | |
| 55 | - `restored/` exists → the original source tree was reconstructed from `.js.map` files; this is what to read first. |
| 56 | - Only `extracted/` exists (no maps) → the JS/CSS in `extracted/` was Prettier-formatted in place; read from there. |
| 57 | |
| 58 | ## Source-map path restoration |
| 59 | |
| 60 | The script should preserve original source names and directory structure as much as the source map allows: |
| 61 | |
| 62 | - Resolve each `sources[]` entry with `sourceRoot` when present, then relative to the `.js.map` file's directory inside `extracted/`. |
| 63 | - Collapse normal bundler-relative paths into the restored |