# Baoyu Electron Extract > Extrae recursos y JavaScript de cualquier app Electron instalada (app.asar), restaurando las fuentes originales desde .js.map o formateando el código minificado con Prettier. Fuente: https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-electron-extract Markdown: https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-electron-extract.md Repositorio: https://github.com/JimLiu/baoyu-skills Autor: JimLiu Licencia: MIT Actualizado: hace 2 meses Coste de contexto: 117 tok instalada, 2.6k tok al activarse, 9.9k tok con todos los archivos del bundle Bundle: 3 archivos, 39 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add JimLiu/baoyu-skills --skill baoyu-electron-extract --agent claude-code # Cursor npx -y skills add JimLiu/baoyu-skills --skill baoyu-electron-extract --agent cursor # Codex npx -y skills add JimLiu/baoyu-skills --skill baoyu-electron-extract --agent codex # Gemini CLI npx -y skills add JimLiu/baoyu-skills --skill baoyu-electron-extract --agent gemini # Windsurf npx -y skills add JimLiu/baoyu-skills --skill baoyu-electron-extract --agent windsurf # Cline npx -y skills add JimLiu/baoyu-skills --skill baoyu-electron-extract --agent cline ``` ## Qué hace - Extrae el app.asar de una app Electron instalada y restaura el código fuente original desde archivos .js.map cuando existen - Formatea el código minificado con Prettier cuando no hay source map disponible - Descubre la app automáticamente por nombre o ruta absoluta en macOS y Windows - Omite siempre node_modules y copia app.asar.unpacked por separado ## Cuándo usarla - El usuario quiere inspeccionar o extraer código de una app Electron instalada (por nombre o ruta) - El usuario pide 'ver el código fuente de ', 'descompilar Electron' o '提取 .asar' - El usuario quiere restaurar los sources originales desde un .js.map ## Qué la activa - "Extrae el código fuente de la app Codex" - "Quiero ver cómo está construido Notion por dentro" - "Descompila esta app Electron: /Applications/Slack.app" - "提取 Electron 应用源码" - "还原 Codex 的 source map" ## Antes de instalar - Requiere tener instalado bun o npx para ejecutar el script (@electron/asar y prettier se resuelven vía npx -y en la primera ejecución). - Variables de entorno: BUN_X - reads environment config ## Archivos - SKILL.md — 10 KB - scripts/main.test.ts — 3 KB - scripts/main.ts — 25 KB ## SKILL.md Reproducido tal cual desde JimLiu/baoyu-skills bajo MIT. Esta sección es el documento original y está en inglés. # Electron App Extract 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. ## User Input Tools When this skill prompts the user, follow this tool-selection rule (priority order): 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. 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. 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. Concrete `AskUserQuestion` references below are examples — substitute the local equivalent in other runtimes. ## Script Directory 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. | Script | Purpose | | ----------------- | ------------------------------------------------------------------------------ | | `scripts/main.ts` | App discovery + asar extraction + source-map restoration + Prettier formatting | ## When to use Use this skill whenever the user wants to look inside an installed Electron application or inspect its bundled code. Trigger phrases include: - "extract Electron app", "decompile this Electron app", "unpack app.asar" - "show me the source of ", "look inside ", "how is built" - "get the source code of Codex / Cursor / Discord / Slack / VS Code / Notion / Obsidian / ChatGPT desktop" - "提取 Electron 应用", "看 的源码", "反编译 Electron", "解包 app.asar", "还原 source map" 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. ## Workflow **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. **2. Run the script.** ```bash ${BUN_X} {baseDir}/scripts/main.ts "" [--output ] [--asar ] [--force] ``` 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. **3. Handle the result.** - **Success** → report the output paths and the counts (extracted / restored / formatted). - **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. - **Existing non-empty output dir** → the script refuses without `--force`. Ask the user whether to overwrite (`--force`) or pick a new `--output` path. - **Unsupported platform / no match** → suggest passing `--asar /full/path/to/app.asar` if the user knows where the bundle lives. **4. Point the user at the result.** The default output dir is `~/Downloads/-electron-extract/`. The most interesting subdirectory depends on what was found: - `restored/` exists → the original source tree was reconstructed from `.js.map` files; this is what to read first. - Only `extracted/` exists (no maps) → the JS/CSS in `extracted/` was Prettier-formatted in place; read from there. ## Source-map path restoration The script should preserve original source names and directory structure as much as the source map allows: - Resolve each `sources[]` entry with `sourceRoot` when present, then relative to the `.js.map` file's directory inside `extracted/`. - Collapse normal bundler-relative paths into the restored project tree. For example, `.vite/main/index.js.map` + `../../src/main.ts` becomes `restored/src/main.ts`. - If a source path climbs above `extracted/`, keep the readable remaining path under `restored/` instead of hashing it. For example, `.vite/main/index.js.map` + `../../../shared/src/lib/foo.ts` becomes `restored/shared/src/lib/foo.ts`. - Strip URL/query decorations from source names, including common `webpack://`, `file://`, and `?loader` suffixes. - Use `restored/__unknown/.` only when the source name is empty or cannot be reduced to a safe file path. - Continue skipping `node_modules` and `webpack/runtime/*` entries; these are bundler/runtime noise, not app sources. ## Usage ```bash # Extract by app name (default output: ~/Downloads/Codex-electron-extract/) ${BUN_X} {baseDir}/scripts/main.ts Codex # Extract by absolute path (works for .app bundles, install dirs, or .asar files) ${BUN_X} {baseDir}/scripts/main.ts "/Applications/Visual Studio Code.app" ${BUN_X} {baseDir}/scripts/main.ts "C:\Users\you\AppData\Local\Programs\codex" ${BUN_X} {baseDir}/scripts/main.ts --asar /Applications/Codex.app/Contents/Resources/app.asar Codex # Custom output ${BUN_X} {baseDir}/scripts/main.ts Codex --output ~/work/codex-source # Preview discovery without writing anything ${BUN_X} {baseDir}/scripts/main.ts Codex --dry-run # Overwrite an existing output dir ${BUN_X} {baseDir}/scripts/main.ts Codex --force # Machine-readable result (one JSON line on stdout) ${BUN_X} {baseDir}/scripts/main.ts Codex --json ``` ## Options | Option | Short | Description | Default | | ---------------- | ----- | --------------------------------------------------------------- | ---------------------------------------- | | `` | | App name or absolute path. Required unless `--asar` is given. | — | | `--output` | `-o` | Output directory | `~/Downloads/-electron-extract` | | `--asar` | | Override the resolved `.asar` path | auto-discovered | | `--force` | `-f` | Allow writing into a non-empty existing output dir | false | | `--skip-format` | | Skip Prettier formatting | false | | `--skip-restore` | | Skip source-map restoration | false | | `--no-unpacked` | | Don't copy `app.asar.unpacked/` alongside | false | | `--dry-run` | | Print resolved paths and exit without writing | false | | `--json` | | Emit one JSON-line summary on stdout (suppresses normal output) | false | ## Output layout ``` ~/Downloads/-electron-extract/ ├── extract-report.json # JSON summary: counts, warnings, resolved paths ├── extracted/ # raw asar contents (JS/CSS Prettier-formatted when no map) │ └── ... # node_modules left untouched (skipped from format) ├── extracted.unpacked/ # copied from .unpacked/ if present │ └── ... # native modules (.node), large assets └── restored/ # only present if at least one .js.map was usable └── # rebuilt from sourcesContent in each .js.map ``` ## Notes - **node_modules** is always skipped — both for source-map restoration and Prettier formatting — because vendored dependencies are noise when inspecting an app. - **Source-map restoration** only works when the `.js.map` embeds `sourcesContent`. This is the common case for modern bundlers (webpack, esbuild, Vite, rollup). If a map references external `.ts`/`.js` files without embedding them, that map is skipped and the corresponding `.js` is Prettier-formatted instead. Skipped maps are listed in `extract-report.json` under `warnings`. - **Readable paths over hashes** — don't treat `../` segments in source-map paths as automatically unsafe. First resolve them from the map location and then sanitize the final output path so it still stays under `restored/`. Hash fallback is only for unusable source names. - **App discovery** searches `/Applications` + `~/Applications` on macOS, and `%LOCALAPPDATA%\Programs`, `%PROGRAMFILES%`, `%PROGRAMFILES(X86)%`, `%APPDATA%` on Windows. If discovery finds multiple matches, the script exits and lists them — re-run with an absolute path. On Linux or other platforms, pass `--asar /path/to/app.asar` explicitly. - **Safety** — the script refuses to write to `/`, the user home directly, or the current working directory, and refuses to populate an existing non-empty output dir without `--force`. - **No global installs** — `@electron/asar` and `prettier` are resolved on-the-fly via `npx -y`. First run will be slower while npx caches them. ## Dónde encaja - Categoría: [Herramientas para desarrolladores](https://skillsagentes.com/categorias/herramientas-desarrollo.md) — Skills que cambian cómo tu agente escribe, revisa y despliega código. - Creador: [JimLiu](https://skillsagentes.com/creators/jimliu.md) — 0 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Baoyu Image Gen](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-image-gen.md): Generación de imágenes con IA usando OpenAI GPT Image 2, Azure OpenAI, Google, OpenRouter, DashScope, Z.AI GLM-Image, MiniMax, Jimeng, Seedream, Replicate y Agnes; soporta texto a imagen, referencias, aspectos y lotes. - [Baoyu Post To Wechat](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-post-to-wechat.md): Publica contenido en WeChat Official Account (微信公众号) vía API o Chrome CDP, con posts de artículo (文章) o de imagen-texto (贴图/图文). - [Baoyu Wechat Summary](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-wechat-summary.md): Convierte los chats de un grupo de WeChat en un resumen estructurado usando el binario local wx-cli, con historial, perfiles de usuario y memoria de hechos por grupo entre ejecuciones. - [Baoyu Post To X](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-post-to-x.md): Publica contenido y artículos en X (Twitter): posts normales con imágenes/vídeos y X Articles en Markdown, vía plugin Chrome de Codex, Computer Use o scripts CDP. - [Baoyu Cover Image](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-cover-image.md): Genera portadas de artículos con 5 dimensiones (tipo, paleta, renderizado, texto, mood), combinando 11 paletas y 7 estilos de renderizado, en formatos cinematic, widescreen o square. ## Skills relacionadas - [Baoyu Danger Gemini Web](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-danger-gemini-web.md): Genera imágenes y texto mediante la API web de Gemini (ingeniería inversa). Soporta generación de texto e imágenes, imágenes de referencia para visión y conversaciones multi-turno. - [Baoyu Article Illustrator](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-article-illustrator.md): Analiza la estructura del artículo, identifica dónde faltan apoyos visuales y genera ilustraciones combinando Tipo × Estilo × Paleta. Úsalo para "ilustrar artículo", "añadir imágenes" o "为文章配图". - [Baoyu Format Markdown](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-format-markdown.md): Da formato a textos planos o markdown: añade frontmatter, títulos, resúmenes, encabezados, negritas, listas y bloques de código, guardando el resultado en {filename}-formatted.md. - [Baoyu Post To Weibo](https://skillsagentes.com/skills/jimliu/baoyu-skills/baoyu-post-to-weibo.md): Publica en Weibo texto, imágenes y vídeos, y artículos de cabecera (头条文章) en Markdown, usando Chrome vía CDP para evitar la detección anti-bot. - [Release Skills](https://skillsagentes.com/skills/jimliu/baoyu-skills/release-skills.md): Flujo de release universal: detecta archivos de versión y changelogs, soporta Node.js, Python, Rust, Claude Plugin, GitHub Releases, tags anotados y backfill histórico. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)