|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Rethunk AI internal project. External PRs are not expected, but the process is documented for clarity. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- **Node.js ≥ 22** — see [docs/install.md](docs/install.md) *Prerequisites* for version notes. |
| 8 | +- **Bun ≥ 1.3.11** (`packageManager` in `package.json`) — only needed to build and test from source. |
| 9 | +- **Git ≥ 2.28**. |
| 10 | + |
| 11 | +## Development setup |
| 12 | + |
| 13 | +```bash |
| 14 | +git clone https://github.com/Rethunk-AI/mcp-multi-root-git.git |
| 15 | +cd mcp-multi-root-git |
| 16 | +bun install |
| 17 | +bun run build # rimraf dist && tsc → dist/server.js, dist/server/*.js, dist/repo-paths.js |
| 18 | +bun run check # Biome lint + format check |
| 19 | +bun run check:fix # auto-fix with Biome |
| 20 | +bun run test # bun test src/ |
| 21 | +bun run test:coverage # bun test src/ --coverage |
| 22 | +bun run setup-hooks # one-time per clone: wire .githooks/ |
| 23 | +``` |
| 24 | + |
| 25 | +## Git hooks |
| 26 | + |
| 27 | +`bun run setup-hooks` sets `core.hooksPath = .githooks`. |
| 28 | + |
| 29 | +| Hook | Runs | |
| 30 | +|------|------| |
| 31 | +| pre-commit | `bun run check` | |
| 32 | +| pre-push | frozen install + build + check + test (mirrors CI) | |
| 33 | + |
| 34 | +Set `SKIP_GIT_HOOKS=1` to bypass. |
| 35 | + |
| 36 | +## Commit conventions |
| 37 | + |
| 38 | +``` |
| 39 | +type(scope): imperative summary ≤72 chars |
| 40 | +
|
| 41 | +Body explains WHY this change exists — motivation, context, constraints. |
| 42 | +Not a file list. Not a summary of what the diff already shows. |
| 43 | +``` |
| 44 | + |
| 45 | +| Type | When | |
| 46 | +|------|------| |
| 47 | +| `feat` | New capability | |
| 48 | +| `fix` | Bug corrected | |
| 49 | +| `docs` | Documentation only | |
| 50 | +| `refactor` | No behaviour change | |
| 51 | +| `test` | Test additions or fixes | |
| 52 | +| `chore` | Maintenance, deps, tooling | |
| 53 | +| `ci` | CI/CD config | |
| 54 | +| `build` | Build system changes | |
| 55 | + |
| 56 | +One logical unit per commit. Max ~7 files. Split by theme, not by file count. |
| 57 | + |
| 58 | +## CI |
| 59 | + |
| 60 | +[`.github/workflows/ci.yml`](.github/workflows/ci.yml) runs on PRs and pushes to `main`: |
| 61 | + |
| 62 | +1. `bun install --frozen-lockfile` |
| 63 | +2. `bun run build` |
| 64 | +3. `bun run check` (Biome) |
| 65 | +4. `bun run test:coverage` + 80% line coverage threshold assertion |
| 66 | +5. Prerelease `npm pack` artifact uploaded (90-day retention) |
| 67 | + |
| 68 | +Match the CI steps locally before opening a PR. |
| 69 | + |
| 70 | +## Pull request checklist |
| 71 | + |
| 72 | +- [ ] `bun run build` passes. |
| 73 | +- [ ] `bun run check` passes (no Biome errors). |
| 74 | +- [ ] `bun run test` passes. |
| 75 | +- [ ] Any new tool has a corresponding `*.test.ts` file. |
| 76 | +- [ ] `docs/mcp-tools.md` updated if the public tool surface changed. |
| 77 | +- [ ] `CHANGELOG.md` entry added under `[Unreleased]`. |
| 78 | + |
| 79 | +## Adding a git tool |
| 80 | + |
| 81 | +1. Create `src/server/<tool-name>-tool.ts` exporting a `register<ToolName>Tool(server: FastMCP)` function. |
| 82 | +2. Register it in `src/server/tools.ts` inside `registerRethunkGitTools`. |
| 83 | +3. Add a test file `src/server/<tool-name>-tool.test.ts`. |
| 84 | +4. Update [docs/mcp-tools.md](docs/mcp-tools.md) (tool ID, parameters, JSON shape, error codes). |
| 85 | +5. Follow contract-change rules in [AGENTS.md](AGENTS.md) — bump JSON format version if the output shape changes incompatibly. |
| 86 | +6. **Path confinement:** if the tool accepts file paths, use `resolvePathForRepo` / `assertRelativePathUnderTop` from [`src/repo-paths.ts`](src/repo-paths.ts) and add tests for escaping attempts. |
| 87 | + |
| 88 | +## Code style |
| 89 | + |
| 90 | +Enforced by **Biome** (`biome.json`): recommended rules, 100-char lines, double quotes, semicolons, trailing commas. |
| 91 | + |
| 92 | +TypeScript: `strict: true`, `noUncheckedIndexedAccess: true`, `verbatimModuleSyntax: true`. Avoid `any`; if genuinely necessary, add an inline comment explaining why. |
| 93 | + |
| 94 | +**Mutating tools** (those that run `git commit`, `push`, `merge`, `cherry-pick`, etc.) must gate on `gateGit()` and operate only within roots confirmed by `requireGitAndRoots` / `requireSingleRepo`. Do not accept absolute paths from the caller for mutating operations. |
0 commit comments