How fei-away/codex-dream-skin works
Purpose and Boundaries
Codex Dream Skin is a local, external theming tool for the Codex desktop client on macOS and Windows. It injects styling through loopback-only Chrome DevTools Protocol (CDP), preserving official application binaries, packages, and signatures. It explicitly does not manage Codex API/provider configuration.
Platform Entry Points
macOS users install via macos/Install Codex Dream Skin.command or macos/scripts/install-dream-skin-macos.sh, then start/manage the skin through macos/Start Codex Dream Skin.command and related scripts. Windows uses PowerShell installation and startup: windows/scripts/install-dream-skin.ps1 and windows/scripts/start-dream-skin.ps1. Platform-specific behavior is intentionally separated under macos/ and windows/.
CDP Injection Runtime
The core runtime discovers/connects to the locally running Codex renderer and injects a bootstrap/renderer payload rather than modifying installed assets. Injection logic is implemented as Node modules in macos/scripts/injector.mjs and windows/scripts/injector.mjs; the browser-side payload is macos/assets/renderer-inject.js and windows/assets/renderer-inject.js. The principal trust boundary is local CDP bound to 127.0.0.1.
Theme Rendering Layer
Injected code applies the shared visual system: CSS creates the background and native-control treatment, while a theme document supplies image and appearance settings. Key artifacts are macos/assets/dream-skin.css, macos/assets/theme.json, and their Windows counterparts under windows/assets/. The renderer maintains an interactive native Codex UI; it adds a background/theme layer rather than replacing the window with a mock UI.
Theme Lifecycle and Persistence
Themes are staged, validated, written, and switched as local assets/configuration. macOS has modular Node lifecycle operations in macos/scripts/stage-theme.mjs, macos/scripts/theme-config.mjs, and macos/scripts/write-theme.mjs, orchestrated by macos/scripts/switch-theme-macos.sh and macos/scripts/customize-theme-macos.sh. Windows centralizes equivalent user-facing theme operations in windows/scripts/theme-windows.ps1, with shared metadata processing in windows/scripts/image-metadata.mjs.
Presets and Image Inputs
macOS distributes named preset directories with per-preset theme.json, such as macos/presets/preset-romantic-rose/theme.json; a generator maintains preset material via macos/presets/generate-presets.mjs. Custom background handling derives metadata needed for display placement and safe presentation, using macos/scripts/image-metadata.mjs and windows/scripts/image-metadata.mjs. Documentation distinguishes valid clean backgrounds from UI-containing preview images.
Operational Control and Recovery
Install/start scripts establish the local runtime; pause, status, verification, and restore provide operational safety and reversibility. macOS control paths include macos/scripts/start-dream-skin-macos.sh, macos/scripts/verify-dream-skin-macos.sh, and macos/scripts/restore-dream-skin-macos.sh. Windows equivalents are windows/scripts/start-dream-skin.ps1, windows/scripts/verify-dream-skin.ps1, and windows/scripts/restore-dream-skin.ps1. macOS supports a menu-bar workflow through macos/menubar/codex_dream_skin.10s.sh; Windows provides tray integration in windows/scripts/tray-dream-skin.ps1.
Runtimes and External Dependencies
The system is shell/PowerShell orchestration plus Node .mjs utilities, targeting installed Codex desktop processes and their local Chromium CDP interface. It has no indicated backend service dependency. CI is defined in .github/workflows/ci.yml; behavioral guards focus on injection bootstrap, renderer behavior, theme staging, and image metadata under macos/tests/ and windows/tests/.
Main entry points: stage-theme.mjs Theme Lifecycle · scripts/injector.mjs CDP Injector · scripts/injector.mjs CDP Injector · start-dream-skin-macos.sh Start, Verify & Restore
Components 19
macOS
Platform-specific installation, control, and theme tooling.
- Install
macos/scripts/install-dream-skin-macos.sh - Start, Verify & Restore · Establishes, checks, pauses, or reverses the local skin runtime.
macos/scripts/start-dream-skin-macos.sh - Menu Bar Control
macos/menubar/codex_dream_skin.10s.sh - CDP Injector · Finds the Codex renderer and injects the browser payload.
macos/scripts/injector.mjs - Renderer Payload · Adds a theme layer to the native Codex UI.
macos/assets/renderer-inject.js - Theme Assets · Defines background and native-control appearance.
macos/assets/dream-skin.css - Theme Lifecycle · Stages, validates, configures, and writes local themes.
macos/scripts/stage-theme.mjs - Switch & Customize
macos/scripts/switch-theme-macos.sh - Preset Themes · Named themes with per-preset theme documents.
macos/presets/preset-romantic-rose/theme.json - Image Metadata · Derives safe background placement metadata.
macos/scripts/image-metadata.mjs
Windows
Platform-specific installation, control, and theme tooling.
- Install
windows/scripts/install-dream-skin.ps1 - Start, Verify & Restore · Establishes, checks, or reverses the local skin runtime.
windows/scripts/start-dream-skin.ps1 - Tray Control
windows/scripts/tray-dream-skin.ps1 - CDP Injector · Connects to the local Codex renderer.
windows/scripts/injector.mjs - Renderer Payload · Applies the theme layer in the native UI.
windows/assets/renderer-inject.js - Theme Operations · Centralized user-facing staging and switching.
windows/scripts/theme-windows.ps1 - Image Metadata · Processes custom background metadata.
windows/scripts/image-metadata.mjs
Local Runtime
Loopback injection into the installed Codex client.
- Codex Desktop · Installed client remains unmodified.
- Loopback CDP · Local Chromium DevTools connection on 127.0.0.1.
Connections 18
- Install → Start, Verify & Restore: installs runtime
- Start, Verify & Restore → CDP Injector: runs
- Menu Bar Control → Start, Verify & Restore: manages
- CDP Injector → Loopback CDP: connects
- Loopback CDP → Codex Desktop: renderer endpoint
- CDP Injector → Renderer Payload: injects
- Renderer Payload → Theme Assets: applies
- Switch & Customize → Theme Lifecycle: orchestrates
- Theme Lifecycle → Preset Themes: stages
- Image Metadata → Theme Lifecycle: supplies placement data
- Theme Lifecycle → Theme Assets: writes theme
- Install → Start, Verify & Restore: installs runtime
- Start, Verify & Restore → CDP Injector: runs
- Tray Control → Start, Verify & Restore: manages
- CDP Injector → Loopback CDP: connects
- CDP Injector → Renderer Payload: injects
- Theme Operations → Image Metadata: processes images
- Theme Operations → Renderer Payload: configures theme