Local Development
This guide helps you set up a local development environment for contributing to Ralph.
Prerequisites
Getting Started
Clone the Repository
git clone https://github.com/nitodeco/ralph.git
cd ralphInstall Dependencies
bun installRun in Development Mode
bun run devThis runs Ralph directly from source, allowing you to test changes immediately.
Project Structure
ralph/
├── src/
│ ├── index.tsx # Entry point
│ ├── cli/ # CLI commands and parsing
│ ├── components/ # Ink UI components
│ ├── hooks/ # React hooks
│ ├── lib/ # Core logic and services
│ │ ├── handlers/ # Event handlers (verification, decomposition, etc.)
│ │ └── services/ # Service layer (DI container)
│ ├── stores/ # State management (Zustand)
│ └── types/ # TypeScript types
├── docs/ # Documentation site (separate package)
├── scripts/ # Build and utility scripts
└── src/__tests__/ # Test filesDevelopment Workflow
Make Changes
- Create a branch:
git checkout -b feature/your-feature- Make your changes in
src/ - Test locally with
bun run dev
Quality Checks
Before committing, run all checks:
# Format and lint (with auto-fix)
bun run check
# Type checking
bun run typecheck
# Run tests
bun testTesting
Run the test suite:
# All tests
bun test
# Specific test file
bun test src/__tests__/lib/config.test.ts
# Watch mode
bun test --watchBuilding
Create a production build:
bun run buildThis creates binaries in dist/.
Code Style
Ralph uses:
- Biome for formatting and linting
- ESLint for additional checks
- TypeScript strict mode
The bun run check command handles formatting and linting automatically.
Key Conventions
- Use
constfor all variables - Prefer functional patterns
- Use descriptive variable names
- Follow existing patterns in the codebase
Adding Commands
New CLI commands go in src/cli/commands/:
- Create a new command file
- Export the command handler
- Register in
src/cli/parser.ts
Adding Services
Services follow a consistent pattern in src/lib/services/:
- Create a service directory (e.g.,
src/lib/services/my-service/) - Add
types.tsfor interfaces and types - Add
implementation.tswith a factory function (e.g.,createMyService()) - Add
index.tsto re-export public API - Register in
src/lib/services/container.ts - Add to bootstrap in
src/lib/services/bootstrap.ts - Export from
src/lib/services/index.ts
Example service structure:
src/lib/services/my-service/
├── types.ts # MyService interface, config types
├── implementation.ts # createMyService() factory
└── index.ts # Re-exportsPath Aliases
The project uses path aliases:
import { something } from "@/lib/something.ts";@/ maps to src/.
Debugging
VS Code
Launch configurations are provided in .vscode/launch.json.
Console Logging
Use standard console.log during development. Remove before committing.
Inspect State
The Ink UI shows current state. Use ralph status to debug session state.
Next Steps
- Releases — How releases work
- CLI Reference — Understand the CLI structure