This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ToDesktop Exec is a monorepo containing an Electron plugin system that allows ToDesktop applications to bundle and execute platform-specific executables. The project consists of two main packages:
- Plugin Package (
packages/plugin/): The Electron main process plugin that handles executable spawning, file extraction from ASAR archives, and IPC communication - Client Package (
packages/client/): The renderer process client library that provides the public API for web applications
The system uses Electron's IPC (Inter-Process Communication) to safely execute bundled executables:
- Client Layer (
packages/client/src/index.ts): Exposesexecute(),terminateAllProcesses(), andsubscribe()functions to the renderer process - Preload Layer (
packages/plugin/src/preload.ts): Bridges renderer and main process viawindow.todesktop.exec - Main Process Layer (
packages/plugin/src/main.ts): Handles Electron IPC and app lifecycle events - Process Manager (
packages/plugin/src/process-manager.ts): Core business logic for process spawning, termination, and tracking - Shared Types (
packages/plugin/src/shared.ts): Common interfaces and IPC channel definitions
- Platform-specific execution: macOS
.pkgfiles useopencommand, other platforms spawn directly - ASAR extraction: Executables are extracted from the app bundle to temp directory before execution
- Command-line flag support: Both packages support passing arguments to executables
- Real-time logging: Subscribe to
debug,stdout, andstderrstreams - Process management: Automatic cleanup on app quit, manual termination via
terminateAllProcesses()with proper verification
# Install dependencies
npm install
# Development build with watch mode
npm run dev
# Full build (includes rollup build + workspace builds)
npm run build
# Run tests
npm test
# Release commands
npm run release:patch
npm run release:minor
npm run release:majorUses Rollup for bundling with three separate configurations:
packages/plugin/src/main.ts→packages/plugin/dist/main.js(CommonJS)packages/plugin/src/preload.ts→packages/plugin/dist/preload.js(CommonJS, browser-compatible)packages/client/src/index.ts→packages/client/dist/index.js(CommonJS)
- Uses Jest with TypeScript support (
ts-jestpreset) - Tests use real processes (not mocks) to verify actual system behavior
- Business logic extracted to
process-manager.tsfor testability - Configuration in
jest.config.js - Test command:
npm test
The plugin requires custom code signing certificates (appOptions.isSecure must be true) to execute bundled files, ensuring security in production ToDesktop applications.
- macOS:
.pkgfiles opened withopencommand for standard installation flow - Windows: Uses shell spawning for executable compatibility
- Linux: Direct executable spawning with proper permissions (chmod 755)