The launcher now supports comprehensive environment configuration including:
- Custom startup commands per project
- Automatic port detection and allocation
- Multi-environment support with port offsetting
- Database and service port management
Each project can have a configuration file that defines:
project:
name: myproject
display_name: My Project
setup:
command: ./go.sh # Command to start an environment
env_vars: # Vars to inject
- PROJECT_ROOT
- WORKTREE_PATH
- PORT_OFFSET # Auto-calculated offset
ports:
allocation_strategy: offset # or: fixed
base_port: 8000
offset:
min: 0
max: 100
step: 10 # Each env gets ports +10 from previousThe launcher scans .env.template or .env.example to detect:
- Port variables (e.g.,
BACKEND_PORT,WEBUI_PORT) - Database ports (e.g.,
POSTGRES_PORT,REDIS_PORT) - Default values
Example .env.template:
BACKEND_PORT=8000
WEBUI_PORT=3000
POSTGRES_PORT=5432
REDIS_PORT=6379When creating environments, ports are automatically offset:
Environment 1 (offset=0):
- BACKEND_PORT=8000
- WEBUI_PORT=3000
- POSTGRES_PORT=5432
Environment 2 (offset=10):
- BACKEND_PORT=8010
- WEBUI_PORT=3010
- POSTGRES_PORT=5442
Environment 3 (offset=20):
- BACKEND_PORT=8020
- WEBUI_PORT=3020
- POSTGRES_PORT=5452
When you create or start an environment:
- Launcher calculates the port offset
- Injects environment variables:
PROJECT_ROOT=/Users/you/repos/myproject WORKTREE_PATH=/Users/you/repos/worktrees/myproject/dev PORT_OFFSET=10
- Runs the startup command (e.g.,
./go.sh) - Your startup script reads PORT_OFFSET and adjusts ports accordingly
Your go.sh or startup script should use the PORT_OFFSET:
#!/bin/bash
# Get port offset from environment (default to 0)
OFFSET=${PORT_OFFSET:-0}
# Calculate actual ports
export BACKEND_PORT=$((8000 + OFFSET))
export WEBUI_PORT=$((3000 + OFFSET))
export POSTGRES_PORT=$((5432 + OFFSET))
export REDIS_PORT=$((6379 + OFFSET))
# Load base .env if it exists
if [ -f .env.template ]; then
source .env.template
fi
# Override with offset ports
cat > .env.local <<EOF
BACKEND_PORT=${BACKEND_PORT}
WEBUI_PORT=${WEBUI_PORT}
POSTGRES_PORT=${POSTGRES_PORT}
REDIS_PORT=${REDIS_PORT}
EOF
# Start services
docker compose --env-file .env.local up -dAccess the configuration editor:
- Enable Multi-Project Mode in settings
- Go to Install tab
- Add or select a project
- Click "Configure" or "Edit Config"
- Set startup command and port strategy
- Click "Scan .env files" to auto-detect ports
- Add TypeScript interface for DetectedPort
- Wire up ProjectConfigEditor in ProjectsPanel
- Implement config save/load commands
- Auto-calculate PORT_OFFSET when creating environments
- Inject env vars when running startup commands
- Add UI to show port allocations for each environment