baoyu-electron-extract
- Repo stars 21,713
- Forks 2,492
- Author updated Jun 13, 2026, 05:00 AM
- Author repo baoyu-skills
- Domain
- Data
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 92 / 100 · audit passed
- Author / version / license
- @JimLiu · v1.119.0 · no license declared
- Token usage
- Lean
- Setup complexity
- Guided setup
- External API key
- Not required
- Operating systems
- macOS · Linux · Windows
- Runtime requirements
- Node.js · Bun
- Permissions
-
- Read-only
- Write / modify
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: baoyu-electron-extract
description: Extracts resources and code from an installed Electron app's app.asar. When a .js.map is present…
category: data
runtime: Node.js / Bun
---
# baoyu-electron-extract output preview
## PART A: Task fit
- Use case: 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….
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “User Input Tools / Script Directory / When to use” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “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…”.
- **02** When the source has headings, the agent prioritizes “User Input Tools / Script Directory / When to use” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source mentions slash commands such as `/applications`, `/full`, `/path`; use them first when your agent supports command triggers.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files.
Start with a small task and check whether the result follows “User Input Tools / Script Directory / When to use”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: baoyu-electron-extract
description: Extracts resources and code from an installed Electron app's app.asar. When a .js.map is present…
category: data
source: JimLiu/baoyu-skills
---
# baoyu-electron-extract
## When to use
- Extracts resources and code from an installed Electron app's app.asar. When a .js.map is present, restores the origina…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “User Input Tools / Script Directory / When to use” and keep inference separate from source facts.
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "baoyu-electron-extract" {
input -> user goal + target files + boundaries + acceptance criteria
context -> User Input Tools / Script Directory / When to use
rules -> SKILL.md triggers / order / output contract
runtime -> Node.js / Bun | read files, write/modify files | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} 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):
- Prefer built-in user-input tools exposed by the current agent runtime — e.g.,
AskUserQuestion,request_user_input,clarify,ask_user, or any equivalent. - 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.
- 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.
${BUN_X} {baseDir}/scripts/main.ts "<app>" [--output <dir>] [--asar <path>] [--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
AskUserQuestionor 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--outputpath. - Unsupported platform / no match → suggest passing
--asar /full/path/to/app.asarif the user knows where the bundle lives.
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:
restored/exists → the original source tree was reconstructed from.js.mapfiles; this is what to read first.- Only
extracted/exists (no maps) → the JS/CSS inextracted/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 withsourceRootwhen present, then relative to the.js.mapfile's directory insideextracted/. - Collapse normal bundler-relative paths into the restored project tree. For example,
.vite/main/index.js.map+../../src/main.tsbecomesrestored/src/main.ts. - If a source path climbs above
extracted/, keep the readable remaining path underrestored/instead of hashing it. For example,.vite/main/index.js.map+../../../shared/src/lib/foo.tsbecomesrestored/shared/src/lib/foo.ts. - Strip URL/query decorations from source names, including common
webpack://,file://, and?loadersuffixes. - Use
restored/__unknown/<hash>.<ext>only when the source name is empty or cannot be reduced to a safe file path. - Continue skipping
node_modulesandwebpack/runtime/*entries; these are bundler/runtime noise, not app sources.
Usage
# 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> |
App name or absolute path. Required unless --asar is given. |
— | |
--output |
-o |
Output directory | ~/Downloads/<AppName>-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/<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
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.mapembedssourcesContent. This is the common case for modern bundlers (webpack, esbuild, Vite, rollup). If a map references external.ts/.jsfiles without embedding them, that map is skipped and the corresponding.jsis Prettier-formatted instead. Skipped maps are listed inextract-report.jsonunderwarnings. - 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 underrestored/. Hash fallback is only for unusable source names. - App discovery searches
/Applications+~/Applicationson 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.asarexplicitly. - 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/asarandprettierare resolved on-the-fly vianpx -y. First run will be slower while npx caches them.
Decide Fit First
Design Intent
How To Use It
Boundaries And Review