Thank you for your interest in contributing to OwnPilot! This document provides guidelines and instructions for contributing.
- Node.js >= 22.0.0
- pnpm >= 10.0.0
- PostgreSQL 16+ (via Docker recommended:
docker compose --profile postgres up -d) - Docker (optional, for sandbox code execution)
# Clone and run interactive setup (recommended)
git clone https://github.com/ownpilot/ownpilot.git
cd ownpilot
./setup.sh # Linux/macOS
# or
.\setup.ps1 # Windows PowerShell
# Or manually:
pnpm install
cp .env.example .env
# Edit .env with your PostgreSQL connection details
pnpm dev- Language: All code, comments, commit messages, and documentation must be in English.
- TypeScript: Strict mode enabled. Use proper types — avoid
any. - Formatting: Prettier 3.8 — run
pnpm formatbefore committing. - Linting: ESLint 10 flat config — run
pnpm lintbefore committing. - Pre-commit hooks: Husky runs lint + typecheck automatically.
- API responses: Always use
apiResponse(c, data, status?)andapiError(c, message, code, status)frompackages/gateway/src/routes/helpers.ts. - Error codes: Use constants from
ERROR_CODESin helpers.ts. - Logging: Use
getLog('ModuleName')— never use rawconsole.*in production code. - Error handling: Use
Result<T, E>pattern for functional error handling in core. - Repository pattern: All database access goes through repository classes extending
BaseRepository. - Service registry: Use typed
ServiceTokenfor dependency injection. - Barrel exports: Each module directory has an
index.tsre-exporting public APIs. - Unused variables: Prefix with
_(e.g.,_unusedParam).
- Route files return Hono app instances.
- Tests are colocated with source files (
*.test.ts). - Prefer editing existing files over creating new ones.
We use Vitest 2.x across all packages. The test suite contains 315+ test files with 19,200+ tests.
| Package | Test Files | Tests |
|---|---|---|
gateway |
195+ | 9,900+ |
core |
109 | 9,000+ |
ui |
5 | 51 |
cli |
4 | ~50 |
channels |
2 | ~20 |
pnpm test # Run all tests
pnpm test:watch # Watch mode
pnpm test:coverage # Coverage reports
# Run tests for a specific package
pnpm --filter @ownpilot/gateway test
pnpm --filter @ownpilot/core test- Every new feature or bug fix should include tests.
- Mock external dependencies — never call real APIs in tests.
- Clear module-level caches in
beforeEachto avoid test pollution. - Use
vi.mock()withimportOriginalwhen you need to preserve some exports.
- Fork the repository and create a feature branch from
main. - Implement your changes following the coding standards above.
- Test — ensure all existing tests pass and add new tests for your changes.
- Lint & Format — run
pnpm lintandpnpm format:check. - TypeCheck — run
pnpm typecheck. - Commit with a descriptive message following the conventions below.
- Open a PR against
mainwith a clear description of the changes.
All PRs must pass:
- Build (
pnpm build) - TypeCheck (
pnpm typecheck) - Lint (
pnpm lint) - Tests (
pnpm test) - Format Check (
pnpm format:check)
Use conventional commit prefixes:
| Prefix | Usage |
|---|---|
feat: |
New feature |
fix: |
Bug fix |
test: |
Adding or updating tests |
docs: |
Documentation changes |
chore: |
Build, CI, dependency updates |
refactor: |
Code changes that don't fix bugs or add features |
style: |
Formatting, whitespace changes |
perf: |
Performance improvements |
Examples:
feat: Add webhook trigger support
fix: Resolve memory leak in embedding queue
test: Add unit tests for approval manager TTL
docs: Update deployment instructions for Docker
- Use GitHub Issues for bug reports and feature requests.
- For security vulnerabilities, see SECURITY.md.
By contributing to OwnPilot, you agree that your contributions will be licensed under the MIT License.