Loading...
Loading...
Extracts 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 source code of <app>", "inspect app.asar", "看 Electron 应用源码", "提取 .asar", or asks how a desktop Electron app is built. Skips `node_modules` and supports both macOS and Windows.
npx skill4agent add jimliu/baoyu-skills baoyu-electron-extractapp.asar.js.mapsourcesContent.js.map../../src/main.tsrestored/src/main.tsnode_modulesAskUserQuestionrequest_user_inputclarifyask_userAskUserQuestionscripts/{baseDir}${BUN_X}bunbunnpxnpx -y bun{baseDir}${BUN_X}| Script | Purpose |
|---|---|
| App discovery + asar extraction + source-map restoration + Prettier formatting |
Codex/Applications/Codex.app.asar${BUN_X} {baseDir}/scripts/main.ts "<app>" [--output <dir>] [--asar <path>] [--force]--dry-runAskUserQuestion--force--force--output--asar /full/path/to/app.asar~/Downloads/<AppName>-electron-extract/restored/.js.mapextracted/extracted/sources[]sourceRoot.js.mapextracted/.vite/main/index.js.map../../src/main.tsrestored/src/main.tsextracted/restored/.vite/main/index.js.map../../../shared/src/lib/foo.tsrestored/shared/src/lib/foo.tswebpack://file://?loaderrestored/__unknown/<hash>.<ext>node_moduleswebpack/runtime/*# 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| Option | Short | Description | Default |
|---|---|---|---|
| App name or absolute path. Required unless | — | |
| | Output directory | |
| Override the resolved | auto-discovered | |
| | Allow writing into a non-empty existing output dir | false |
| Skip Prettier formatting | false | |
| Skip source-map restoration | false | |
| Don't copy | false | |
| Print resolved paths and exit without writing | false | |
| Emit one JSON-line summary on stdout (suppresses normal output) | false |
~/Downloads/<AppName>-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 <asar>.unpacked/ if present
│ └── ... # native modules (.node), large assets
└── restored/ # only present if at least one .js.map was usable
└── <original/source/tree> # rebuilt from sourcesContent in each .js.map.js.mapsourcesContent.ts.js.jsextract-report.jsonwarnings../restored//Applications~/Applications%LOCALAPPDATA%\Programs%PROGRAMFILES%%PROGRAMFILES(X86)%%APPDATA%--asar /path/to/app.asar/--force@electron/asarprettiernpx -y