Automatically detect, install, configure, and validate your entire development environment with a single command.
The --setup command orchestrates a complete environment synchronization pipeline:
- Package Detection - Scans your project for package managers (npm, pip, cargo, go)
- Dependency Installation - Installs all detected dependencies
- Environment Configuration - Creates/updates
.envfrom.env.examplewith interactive prompting - Graphiti Validation - Validates memory system configuration (LLM + embedder providers)
- Provider Testing - Tests connectivity to configured LLM/embedder providers
Post-processing: Report Generation - Produces a summary with actionable fix recommendations
cd apps/backend
# Interactive setup (recommended for first run)
python run.py --setup
# Non-interactive setup (for CI/automation)
python run.py --setup --non-interactive
# Dry-run to preview changes without executing
python run.py --setup --dry-run
# JSON output for scripting
python run.py --setup --json| Flag | Description |
|---|---|
--setup |
Run the environment sync pipeline |
--dry-run |
Preview what would be done without making changes |
--skip-install |
Skip dependency installation phase |
--skip-config |
Skip .env configuration phase |
--skip-validation |
Skip Graphiti and provider validation |
--non-interactive |
Don't prompt for input (use defaults/env vars) |
--verbose |
Show detailed progress for each phase |
--json |
Output results as JSON (for automation) |
Scans the project directory tree for package manager indicators:
package.json/package-lock.json/yarn.lock/pnpm-lock.yaml-> npm/yarn/pnpmrequirements.txt/setup.py/pyproject.toml-> pipCargo.toml-> cargogo.mod-> go
Automatically skips ignored directories (node_modules, .git, .venv, target, vendor, dist, build).
Runs the appropriate install command for each detected package manager:
| Package Manager | Command |
|---|---|
| npm | npm install |
| yarn | yarn install |
| pnpm | pnpm install |
| pip (requirements.txt) | pip install -r requirements.txt |
| pip (setup.py) | pip install -e . |
| pip (pyproject.toml) | pip install -e . |
| cargo | cargo build |
| go | go mod download |
Parses .env.example to identify required and optional environment variables:
- Required variables - Must be configured (e.g.,
ANTHROPIC_API_KEY) - Optional variables - Commented out in
.env.examplewith# VAR=default - Existing values - Preserved from current
.envfile
In interactive mode, prompts for each missing required variable. In non-interactive mode, reports missing variables as warnings.
Security: Dry-run mode masks sensitive values (API keys, tokens, secrets) in output.
Validates the Graphiti memory system configuration:
- LLM provider configuration (API key, model, base URL)
- Embedder provider configuration
- Database backend availability (embedded LadybugDB)
Supports providers: OpenAI, Anthropic, Azure OpenAI, Ollama, Google AI, OpenRouter.
Tests actual connections to configured providers:
- LLM provider - sends a minimal test request
- Embedder provider - tests embedding generation
- Reports latency and error details for failed connections
After the 5 phases complete, a markdown-formatted report is generated with:
- Overall status (pass/fail)
- Per-phase results with timing
- List of issues found
- Actionable fix recommendations
╔══════════════════════════════════════╗
║ Auto Code Environment Sync ║
╚══════════════════════════════════════╝
Phase 1: Package Detection... ✓ (0.2s)
Found: npm (1 dir), pip (2 dirs)
Phase 2: Dependency Installation... ✓ (15.3s)
✓ npm install (apps/frontend)
✓ pip install -r requirements.txt (apps/backend)
Phase 3: Environment Config... ✓ (1.1s)
✓ .env file updated (3 new values)
Phase 4: Graphiti Validation... ✓ (0.5s)
LLM Provider: openai ✓
Embedder: openai ✓
Phase 5: Provider Testing... ✓ (2.1s)
✓ OpenAI LLM connected (234ms)
✓ OpenAI Embedder connected (156ms)
═══════════════════════════════════════
✓ Environment ready (19.2s)
{
"success": true,
"duration": "19.2s",
"detection": {
"npm": ["apps/frontend"],
"pip": ["apps/backend", "apps/web-backend"]
},
"installation": {
"dry_run": false,
"installed": ["npm", "pip"],
"failed": [],
"skipped": []
},
"configuration": {
"success": true,
"env_file": "apps/backend/.env",
"variables_set": 3
},
"graphiti": {
"llm_valid": true,
"embedder_valid": true,
"database_valid": true
},
"providers": {
"llm": {"connected": true, "latency_ms": 234},
"embedder": {"connected": true, "latency_ms": 156}
},
"issues": [],
"report": "..."
}apps/backend/
├── cli/
│ └── setup_commands.py # CLI handler and display logic
├── core/
│ ├── env_sync.py # Orchestrator (main pipeline)
│ ├── package_detector.py # Phase 1: Package detection
│ ├── dependency_installer.py # Phase 2: Dependency installation
│ ├── env_configurator.py # Phase 3: .env configuration
│ ├── graphiti_validator.py # Phase 4: Graphiti validation
│ └── provider_tester.py # Phase 5: Provider connectivity
- Phased pipeline - Each phase is independent and can be skipped
- Dry-run support - Preview all changes without side effects
- Secret masking - API keys and tokens are never printed in dry-run output
- Pruned directory walking - Uses
os.walk()with directory pruning instead ofrglob()for performance in large repos - Graceful degradation - Failures in optional phases (Graphiti, providers) don't fail the overall setup
# Run all env-sync tests
apps/backend/.venv/bin/pytest tests/test_env_sync.py tests/test_package_detector.py tests/test_dependency_installer.py tests/test_env_configurator.py tests/test_graphiti_validator.py tests/test_provider_tester.py -vTest coverage includes:
- Unit tests for each phase module
- Integration test for the full pipeline
- Dry-run behavior verification
- Error handling and edge cases
- Provider-specific connectivity tests