How stefanhoelzl/codehydra works
Purpose and Runtime
CodeHydra is a cross-platform Electron desktop IDE for running Claude Code or OpenCode concurrently in isolated Git worktrees. It embeds a VSCodium editor per workspace, monitors agent state, and exposes workspace/editor control through MCP. Electron/Vite and Svelte are the principal runtime stack: src/main.ts, electron.vite.config.ts, src/renderer/main.ts.
Process Entry and IPC Boundary
Electron main bootstraps application lifecycle, module wiring, and intent dispatch; preload exposes a constrained API to the renderer. Shared IPC/API contracts prevent renderer code from directly accessing Node/Electron services. Key paths: src/main.ts, src/preload/index.ts, src/shared/api/interfaces.ts.
Intent-Oriented Application Core
User, MCP, and lifecycle requests are modeled as intents dispatched through a common operation framework. Intents resolve projects/workspaces, enforce workspace identity/idempotency, then coordinate modules rather than owning platform details. Primary lifecycle paths include src/intents/lib/dispatcher.ts, src/intents/open-workspace.ts, src/intents/delete-workspace.ts.
Workspace and Project Lifecycle
A project is a local or cloned Git repository; a workspace is a branch-specific Git worktree. Creation, selection, switching, hibernation, metadata, and status are composed from modules and platform Git/filesystem boundaries. Worktrees remain on disk during hibernation. Key paths: src/modules/git-worktree-workspace-module.ts, src/modules/local-project-module.ts, src/boundaries/platform/git-worktree-provider.ts.
Agent Abstraction and Servers
The agent module selects a global or per-workspace provider and normalizes lifecycle/status behavior across Claude and OpenCode. Provider-specific wrappers/server managers launch and manage external agent processes; OpenCode has an SDK client, while Claude manages hooks/MCP configuration. Key paths: src/modules/agent-module/agent-module.ts, src/modules/agent-module/claude/server-manager.ts, src/modules/agent-module/opencode/server-manager.ts.
IDE Views and Renderer
Each active workspace maps to a managed VSCodium/IDE-server view, while Svelte renders workspace frames, sidebar, dialogs, notifications, and shortcut state. The renderer invokes the preload API and consumes domain events; it does not own workspace process management. Key paths: src/modules/ide-server-module/ide-server-module.ts, src/renderer/lib/components/WorkspaceFrames.svelte, src/renderer/lib/api/index.ts.
External Integration and Infrastructure
Platform boundaries isolate Electron shell APIs, process execution, filesystem, ports, networking, Git, persisted state, logging, and telemetry. MCP turns internal intents into agent-accessible tools; agents can invoke VS Code commands through the app. External systems include Git/GitHub, YouTrack, Claude Code, OpenCode, VSCodium, and PostHog. Key paths: src/modules/mcp-module.ts, src/boundaries/platform/process.ts, src/boundaries/platform/posthog.ts.
Distribution and Extensions
Electron Builder packages platform binaries and bundled agent/editor launchers. Companion VS Code extensions are separately built, notably a Markdown review editor with Svelte webview UI and OpenCode integration. Node and Python packages are thin launch/distribution surfaces. Key paths: electron-builder.yaml, extensions/markdown-review-editor/src/extension/extension.ts, packages/npm/codehydra.js.
Main entry points: open-workspace.ts Workspace lifecycle intents · main.ts Electron main · dispatcher.ts Intent dispatcher · process.ts Process boundary
Components 22
Electron Desktop
- Electron main · Owns lifecycle, module wiring, and intent dispatch.
src/main.ts - Preload API · Exposes constrained renderer capabilities.
src/preload/index.ts - Svelte renderer · Renders workspace UI and consumes domain events.
src/renderer/main.ts - Renderer API client
src/renderer/lib/api/index.ts - Workspace frames · Hosts active IDE workspace views.
src/renderer/lib/components/WorkspaceFrames.svelte
Application Core
- Shared API contracts · Defines the main-to-renderer API boundary.
src/shared/api/interfaces.ts - Intent dispatcher · Routes lifecycle, user, and MCP requests.
src/intents/lib/dispatcher.ts - Workspace lifecycle intents · Open and delete operations resolve workspace identity.
src/intents/open-workspace.ts - Project module · Manages local and cloned Git repositories.
src/modules/local-project-module.ts - Git worktree workspace module · Creates, switches, hibernates, and tracks workspaces.
src/modules/git-worktree-workspace-module.ts - Git worktree provider · Performs Git worktree operations.
src/boundaries/platform/git-worktree-provider.ts
Workspace Runtimes
- Agent module · Selects and normalizes global or workspace agents.
src/modules/agent-module/agent-module.ts - Claude server manager · Manages Claude hooks, MCP configuration, and processes.
src/modules/agent-module/claude/server-manager.ts - OpenCode server manager · Manages OpenCode server and SDK client.
src/modules/agent-module/opencode/server-manager.ts - IDE server module · Maps active workspaces to VSCodium views.
src/modules/ide-server-module/ide-server-module.ts
External Integrations
- MCP module · Exposes intents and editor control to agents.
src/modules/mcp-module.ts - Process boundary · Launches external agent and editor processes.
src/boundaries/platform/process.ts - PostHog boundary
src/boundaries/platform/posthog.ts - Git, agents & VSCodium · Git/GitHub, Claude Code, OpenCode, and VSCodium.
Distribution & Extensions
- Electron Builder · Packages platform binaries and bundled launchers.
electron-builder.yaml - Markdown review extension · Companion extension with Svelte webview and OpenCode integration.
extensions/markdown-review-editor/src/extension/extension.ts - npm launcher
packages/npm/codehydra.js
Connections 26
- Electron main → Preload API: creates IPC boundary
- Preload API → Shared API contracts: implements
- Svelte renderer → Renderer API client: uses
- Renderer API client → Preload API: invokes
- Svelte renderer → Workspace frames: renders
- Electron main → Intent dispatcher: dispatches
- Shared API contracts → Intent dispatcher: contracts
- Intent dispatcher → Workspace lifecycle intents: routes
- Workspace lifecycle intents → Project module: resolves project
- Workspace lifecycle intents → Git worktree workspace module: coordinates
- Git worktree workspace module → Git worktree provider: uses
- Git worktree provider → Git, agents & VSCodium: Git operations
- Workspace lifecycle intents → Agent module: starts and monitors
- Workspace lifecycle intents → IDE server module: opens workspace view
- Agent module → Claude server manager: selects
- Agent module → OpenCode server manager: selects
- Claude server manager → Process boundary: launches via
- OpenCode server manager → Process boundary: launches via
- IDE server module → Process boundary: launches via
- Process boundary → Git, agents & VSCodium: runs
- MCP module → Intent dispatcher: turns tools into intents
- MCP module → IDE server module: invokes editor commands
- Electron main → PostHog boundary: reports through
- Electron Builder → Electron main: packages
- npm launcher → Electron Builder: distributes
- Markdown review extension → Git, agents & VSCodium: integrates OpenCode