What Is the Purpose of the Dev Script in OpenWork? A Complete Development Guide
The dev script in the OpenWork repository launches the desktop application in local development mode, enabling hot-reloading, Chrome DevTools remote debugging, and development-specific configuration through environment variables.
The dev script serves as the primary entry point for developers working on OpenWork, an open-source desktop application built by different-ai. As implemented in the different-ai/openwork repository, this script orchestrates the entire development environment with a single command, making it essential for feature development and UI iteration.
Core Functions of the OpenWork Dev Script
Running pnpm dev from the repository root executes three critical operations:
-
Enables Development Mode – Sets
OPENWORK_DEV_MODE=1, which activates development-only configuration including mock services, relaxed security policies, and hot-reloading capabilities. -
Exposes Remote Debugging – Assigns
OPENWORK_ELECTRON_REMOTE_DEBUG_PORT(defaulting to port 9823) to allow inspection of the Electron renderer process using Chrome DevTools. -
Boots the Desktop Application – Executes
pnpm --filter @openwork/desktop dev, which runs the desktop workspace in watch mode, automatically rebuilding and reloading when source files change.
How to Use the Dev Script in OpenWork
Starting the Development Environment
The standard command to launch OpenWork locally:
pnpm dev
This single command initializes the full desktop environment with live-reloading enabled.
Customizing the Debug Port
Override the default remote debug port (9823) by setting the environment variable before execution:
OPENWORK_ELECTRON_REMOTE_DEBUG_PORT=9234 pnpm dev
Alternative Development Commands
OpenWork provides additional development scripts for specific scenarios:
-
pnpm run dev:ui– Starts the web UI (@openwork/app) without the Electron wrapper, useful for browser-only testing. -
pnpm dev:electron:two– Launches a demonstration with two Electron windows side-by-side, facilitating multi-window interaction testing.
Key Files Supporting the Dev Script
The development workflow relies on several configuration files across the monorepo:
-
dev/package.json– Contains the central script definition at line 6, registering the top-leveldevcommand. -
apps/desktop/package.json– Defines the desktop-specificdevscript that actually initializes the Electron application. -
scripts/electron-dev.mjs– Helper script that configures and boots Electron with proper environment variable injection. -
apps/app/package.json– Provides thedevscript for the browser-based UI layer (@openwork/app). -
apps/ui-demo/package.json– Offers a lightweight UI demo environment for rapid component testing.
Summary
-
The
devscript indev/package.jsonis the canonical entry point for OpenWork development. -
It sets
OPENWORK_DEV_MODE=1andOPENWORK_ELECTRON_REMOTE_DEBUG_PORT=9823to enable debugging and development features. -
The script filters to the
@openwork/desktopworkspace to launch the Electron application in watch mode. -
Alternative commands like
dev:uianddev:electron:twosupport specific testing scenarios without the full desktop wrapper.
Frequently Asked Questions
What does the dev script do in OpenWork?
The dev script initializes the complete OpenWork development environment by configuring development-specific environment variables and launching the Electron desktop application with hot-reloading enabled. It serves as the main entry point for developers building features or debugging the application locally.
How do I change the debug port when running pnpm dev?
Set the OPENWORK_ELECTRON_REMOTE_DEBUG_PORT environment variable before executing the command. For example, run OPENWORK_ELECTRON_REMOTE_DEBUG_PORT=9234 pnpm dev to use port 9234 instead of the default 9823, allowing you to inspect the Electron renderer process in Chrome DevTools.
What is the difference between pnpm dev and pnpm run dev:ui?
Running pnpm dev launches the full Electron desktop application with all development features, while pnpm run dev:ui starts only the web UI layer (@openwork/app) in a browser without the Electron wrapper. Use dev:ui for frontend-only work and pnpm dev for full desktop integration testing.
Where is the dev script defined in the OpenWork codebase?
The primary dev script is defined in dev/package.json at line 6, which references the workspace filter for @openwork/desktop. The actual Electron execution logic resides in apps/desktop/package.json and the helper script at scripts/electron-dev.mjs.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →