Skip to content

Commit 5f029f8

Browse files
committed
docs: add CONTRIBUTING.md, move dev section out of HUMANS.md
Mirrors the same split done in rethunk-github-mcp. Adds path- confinement and mutating-tool guidance specific to this repo.
1 parent 47157ac commit 5f029f8

2 files changed

Lines changed: 95 additions & 13 deletions

File tree

CONTRIBUTING.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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.

HUMANS.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,7 @@ If **`git`** is missing or not runnable, tools and the presets resource respond
8484

8585
## Development
8686

87-
Requires **Bun ≥ 1.3.11** to build this repository (`packageManager` in `package.json`). **Published runtime** (Node/Bun/Git and how to launch the server): **[docs/install.md](docs/install.md)***Prerequisites*.
88-
89-
```bash
90-
bun install
91-
bun run build # rimraf dist + tsc → dist/server.js, dist/server/*.js, dist/repo-paths.js
92-
bun run check # Biome
93-
bun run check:fix # Biome --write
94-
bun run setup-hooks # once per clone: use .githooks (pre-commit: check; pre-push: CI parity)
95-
```
96-
97-
**Git hooks:** after `setup-hooks`, **pre-commit** runs `bun run check`; **pre-push** runs `bun install --frozen-lockfile`, `bun run build`, `bun run check`, and `bun run test` (same order as CI). Set **`SKIP_GIT_HOOKS=1`** or use **`--no-verify`** to bypass.
98-
99-
**CI:** [`.github/workflows/ci.yml`](.github/workflows/ci.yml) runs on pull requests and pushes to `main`: **`actions/setup-node` with Node 24** (minimum 22 asserted), then `bun install --frozen-lockfile`, `bun run build`, `bun run check`, and `bun run test`. A follow-up job **`prerelease-pack`** builds the same tree and runs **`npm pack`**, then uploads a **prerelease `.tgz` artifact** (named with the commit SHA) you can download from the workflow run’s **Artifacts** section (retention 90 days). Match the check job locally before opening a PR.
87+
See [CONTRIBUTING.md](CONTRIBUTING.md) for dev setup, build commands, git hooks, commit conventions, CI, and how to add a tool.
10088

10189
## Publishing
10290

0 commit comments

Comments
 (0)