|
| 1 | +# Contributing to AI Maestro Gateways |
| 2 | + |
| 3 | +Thank you for your interest in contributing! This guide will help you get started. |
| 4 | + |
| 5 | +## How to Contribute |
| 6 | + |
| 7 | +1. **Fork** the repository |
| 8 | +2. **Create a branch** for your feature or fix (`git checkout -b feature/my-change`) |
| 9 | +3. **Make your changes** and write tests if applicable |
| 10 | +4. **Run type checks** to ensure nothing is broken |
| 11 | +5. **Commit** with a clear message describing the change |
| 12 | +6. **Open a Pull Request** against `main` |
| 13 | + |
| 14 | +## Development Setup |
| 15 | + |
| 16 | +### Prerequisites |
| 17 | + |
| 18 | +- Node.js 22+ |
| 19 | +- npm 10+ |
| 20 | + |
| 21 | +### Getting Started |
| 22 | + |
| 23 | +Each gateway is an independent Node.js project. To work on a specific gateway: |
| 24 | + |
| 25 | +```bash |
| 26 | +cd discord-gateway # or slack-gateway, email-gateway, whatsapp-gateway |
| 27 | +cp .env.example .env # configure your local environment |
| 28 | +npm install |
| 29 | +npm run dev # start with file watching |
| 30 | +``` |
| 31 | + |
| 32 | +### Running Type Checks |
| 33 | + |
| 34 | +```bash |
| 35 | +cd <gateway-dir> |
| 36 | +npm run typecheck # runs tsc --noEmit |
| 37 | +``` |
| 38 | + |
| 39 | +### Running Tests |
| 40 | + |
| 41 | +```bash |
| 42 | +cd <gateway-dir> |
| 43 | +npm test # if tests exist for that gateway |
| 44 | +``` |
| 45 | + |
| 46 | +## Code Style |
| 47 | + |
| 48 | +- **Language:** TypeScript (strict mode) |
| 49 | +- **Module system:** ESM (`"type": "module"` in package.json) |
| 50 | +- **Runtime:** tsx (TypeScript execution without build step) |
| 51 | +- **Formatting:** Use consistent indentation (2 spaces) |
| 52 | +- **Naming:** camelCase for variables/functions, PascalCase for types/interfaces |
| 53 | +- **Imports:** Use `.js` extensions in import paths (required for ESM) |
| 54 | +- **Error handling:** Always handle errors gracefully; log with `[CONTEXT]` prefixes |
| 55 | + |
| 56 | +## Pull Requests |
| 57 | + |
| 58 | +- Keep PRs focused on a single change |
| 59 | +- Include a clear description of what the PR does and why |
| 60 | +- Reference any related issues |
| 61 | +- Make sure type checks pass before requesting review |
| 62 | +- Update `.env.example` if you add new environment variables |
| 63 | +- Update the gateway's README if you change behavior |
| 64 | + |
| 65 | +## Adding a New Gateway |
| 66 | + |
| 67 | +To add a new gateway to the monorepo: |
| 68 | + |
| 69 | +1. **Create the directory** at the repo root (e.g., `telegram-gateway/`) |
| 70 | +2. **Initialize the project:** |
| 71 | + ```bash |
| 72 | + mkdir telegram-gateway && cd telegram-gateway |
| 73 | + npm init -y |
| 74 | + ``` |
| 75 | +3. **Follow the existing structure:** |
| 76 | + ``` |
| 77 | + telegram-gateway/ |
| 78 | + ├── .env.example # All env vars with placeholder values |
| 79 | + ├── .gitignore # node_modules, dist, .env |
| 80 | + ├── Dockerfile # Multi-stage build (see other gateways) |
| 81 | + ├── ecosystem.config.cjs # pm2 configuration |
| 82 | + ├── package.json # Scripts: start, dev, typecheck |
| 83 | + ├── tsconfig.json |
| 84 | + └── src/ |
| 85 | + ├── config.ts # Load env vars with dotenv |
| 86 | + ├── content-security.ts # Trust model + injection scanning |
| 87 | + ├── inbound.ts # Platform -> AI Maestro |
| 88 | + ├── outbound.ts # AI Maestro -> Platform |
| 89 | + ├── server.ts # Express health/management + main() |
| 90 | + └── types.ts # TypeScript interfaces |
| 91 | + ``` |
| 92 | +4. **Implement the content security module** with the standard trust model (operator/external) and injection pattern scanner |
| 93 | +5. **Add a health endpoint** at `GET /health` |
| 94 | +6. **Add the gateway** to the CI matrix in `.github/workflows/ci.yml` |
| 95 | +7. **Add a service** to `docker-compose.yml` |
| 96 | +8. **Create a Dockerfile** following the multi-stage pattern |
| 97 | +9. **Update the root README** with the new gateway info |
0 commit comments