Thank you for your interest in contributing! This guide covers the development workflow, coding standards, and how to submit changes.
# Clone and install
git clone https://github.com/Sagar-024/Repatch
cd Repatch
npm install
# Run tests
npm test
# Build
npm run build
# Run CLI locally
node dist/index.js --help- Pick an issue — Check Issues or propose new work
- Create a branch —
git checkout -b feature/my-feature - Make changes — Follow coding standards below
- Test —
npm testandnpm run buildmust pass - Commit — Use conventional commits (see below)
- Push & PR — Open a PR against
main
- Strict mode — All code must pass
tsc --noEmit - No
any— Use proper types,unknownfor truly dynamic values - Zod for validation — All config/input validation uses Zod schemas
- Interfaces over types — Prefer
interfacefor object shapes
- ESLint + Prettier — Run
npm run lintbefore committing - Logger — Use
loggerfrom../utils/logger.ts(notconsole.log)logger.info()— user-facing infologger.debug()— verbose (requiresDEBUG=1)logger.warn()— warningslogger.error()— errorslogger.succeed()/logger.fail()— step completion
- Error handling — Always
try/catchasync operations, usesafeLogError()for LLM errors - No dead code — Remove unused imports, functions, files
- Steps — Each step in
src/orchestrator/steps/implementsStepinterface - Tools — Register in
src/tools/registry.tswith Zod schema +availableInSteps - Providers — Implement
LLMProviderinsrc/inference/provider.ts - Sandbox — Implement
SandboxExecutorinsrc/sandbox/
# All tests
npm test
# Watch mode
npm run test:watch
# Single test file
npx vitest run tests/orchestrator/machine.test.ts- Unit tests for pure functions (sanitize, redact, cost, Nixpacks detection)
- Integration tests for orchestrator steps (use mocked providers)
- No live LLM calls in tests — use
createMockProvider() - Coverage — Aim for >80% on new code
Use Conventional Commits:
type(scope): short description
[optional body]
[optional footer]
| Type | Use Case |
|---|---|
feat |
New feature |
fix |
Bug fix |
refactor |
Code restructuring |
docs |
Documentation only |
test |
Adding/updating tests |
chore |
Maintenance (deps, scripts, CI) |
perf |
Performance improvement |
security |
Security fix |
feat(orchestrator): add checkpoint resume via --resume flag
fix(inference): redact API keys in Gemini provider errors
refactor(tools): unify run_command and run_local_command interface
docs: add ARCHITECTURE.md with mermaid diagrams
test(sanitize): add 28 prompt injection test cases
-
npm run buildpasses (no TypeScript errors) -
npm testpasses (98+ tests) -
npm run lintpasses - Conventional commit messages
- No
console.log— uselogger - New features have tests
- Documentation updated if user-facing
src/
├── index.ts # CLI entry
├── orchestrator/
│ ├── machine.ts # State machine
│ └── steps/ # 7 step implementations
├── inference/
│ ├── provider.ts # LLMProvider interface
│ └── *-provider.ts # 4 provider implementations
├── sandbox/
│ ├── docker.ts # Docker execution
│ └── local.ts # Local execution (Nixpacks)
├── tools/
│ ├── registry.ts # Tool definitions
│ └── index.ts # Tool implementations
├── adapters/
│ └── github.ts # GitHub API
├── utils/
│ ├── sanitize.ts # Prompt injection defense
│ ├── redact.ts # Secret redaction
│ ├── cost.ts # Token cost tracking
│ └── logger.ts # Unified logging
└── config.ts # Config schema
- Create
src/orchestrator/steps/my-step.tsimplementingStepinterface - Define prompt in
getPrompt()method - Declare available tools via
getAvailableTools() - Register in
src/orchestrator/machine.tsstep order - Add tests in
tests/orchestrator/steps/
- Define schema + handler in
src/tools/registry.ts - Add to
toolRegistrywithavailableInStepsarray - Implement in
src/tools/index.tsif complex logic - Add tests
- Create
src/inference/my-provider.tsimplementingLLMProvider - Implement
complete()andstreamComplete() - Transform tools to provider's format in
transformTools() - Use
safeLogError()for all error logging - Register in
src/inference/provider.tsfactory
- Never commit secrets —
.repatch.yamlis gitignored - Redact secrets — Use
safeLogError()for all LLM error paths - Sanitize input — User data wrapped via
wrapUserData()before prompts - Path traversal — All file writes validated in
machine.ts
Maintainers only:
# Bump version in package.json
npm version patch|minor|major
# Push tags
git push origin main --tags
# GitHub Actions builds binaries, creates release, updates Homebrew