mergewise 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mergewise-0.1.0a1/.gitignore +12 -0
- mergewise-0.1.0a1/LICENSE +21 -0
- mergewise-0.1.0a1/PKG-INFO +255 -0
- mergewise-0.1.0a1/README.md +226 -0
- mergewise-0.1.0a1/api/openapi.yaml +1279 -0
- mergewise-0.1.0a1/pyproject.toml +98 -0
- mergewise-0.1.0a1/src/mergewise/__init__.py +3 -0
- mergewise-0.1.0a1/src/mergewise/adapters/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/agents/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/agents/claude_code/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/agents/claude_code/agent.py +273 -0
- mergewise-0.1.0a1/src/mergewise/adapters/agents/claude_code/classify.py +68 -0
- mergewise-0.1.0a1/src/mergewise/adapters/agents/claude_code/launch.py +45 -0
- mergewise-0.1.0a1/src/mergewise/adapters/agents/claude_code/result.py +101 -0
- mergewise-0.1.0a1/src/mergewise/adapters/agents/claude_code/sandbox.py +101 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/__main__.py +212 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/api_client.py +44 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/commands/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/commands/api.py +151 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/commands/host.py +178 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/commands/service.py +79 -0
- mergewise-0.1.0a1/src/mergewise/adapters/cli/commands/skill.py +32 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/github/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/github/host.py +182 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/github/mapping.py +102 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/gitlab/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/gitlab/host.py +161 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/gitlab/mapping.py +109 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/http.py +78 -0
- mergewise-0.1.0a1/src/mergewise/adapters/hosts/registry.py +44 -0
- mergewise-0.1.0a1/src/mergewise/adapters/http_api/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/http_api/presenters.py +176 -0
- mergewise-0.1.0a1/src/mergewise/adapters/http_api/routes.py +280 -0
- mergewise-0.1.0a1/src/mergewise/adapters/http_api/server.py +227 -0
- mergewise-0.1.0a1/src/mergewise/adapters/http_api/sse.py +43 -0
- mergewise-0.1.0a1/src/mergewise/adapters/http_api/stub.py +129 -0
- mergewise-0.1.0a1/src/mergewise/adapters/memory/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/memory/files.py +34 -0
- mergewise-0.1.0a1/src/mergewise/adapters/secrets/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/secrets/_names.py +11 -0
- mergewise-0.1.0a1/src/mergewise/adapters/secrets/chain.py +37 -0
- mergewise-0.1.0a1/src/mergewise/adapters/secrets/env_store.py +33 -0
- mergewise-0.1.0a1/src/mergewise/adapters/secrets/errors.py +5 -0
- mergewise-0.1.0a1/src/mergewise/adapters/secrets/keyring_store.py +44 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/sqlite/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/sqlite/db.py +57 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/sqlite/migrations/0001_init.sql +116 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/sqlite/migrations/0002_review_undone.sql +28 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/sqlite/migrations/0003_events.sql +10 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/sqlite/migrations/0004_ever_requested.sql +4 -0
- mergewise-0.1.0a1/src/mergewise/adapters/storage/sqlite/repos.py +405 -0
- mergewise-0.1.0a1/src/mergewise/application/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/application/dto.py +77 -0
- mergewise-0.1.0a1/src/mergewise/application/lessons.py +277 -0
- mergewise-0.1.0a1/src/mergewise/application/ports/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/application/ports/clock.py +7 -0
- mergewise-0.1.0a1/src/mergewise/application/ports/code_host.py +145 -0
- mergewise-0.1.0a1/src/mergewise/application/ports/memory.py +14 -0
- mergewise-0.1.0a1/src/mergewise/application/ports/reviewer_agent.py +122 -0
- mergewise-0.1.0a1/src/mergewise/application/ports/secrets.py +24 -0
- mergewise-0.1.0a1/src/mergewise/application/ports/store.py +219 -0
- mergewise-0.1.0a1/src/mergewise/application/testing/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/application/testing/fakes.py +474 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/errors.py +37 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/learn_from_replies.py +175 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/manage_connections.py +201 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/poll_review_requests.py +417 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/record_review.py +492 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/review_rules.py +45 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/run_review.py +126 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/service_settings.py +65 -0
- mergewise-0.1.0a1/src/mergewise/application/use_cases/watch_repos.py +38 -0
- mergewise-0.1.0a1/src/mergewise/config.py +126 -0
- mergewise-0.1.0a1/src/mergewise/contract.py +25 -0
- mergewise-0.1.0a1/src/mergewise/domain/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/domain/change_request.py +56 -0
- mergewise-0.1.0a1/src/mergewise/domain/connection.py +39 -0
- mergewise-0.1.0a1/src/mergewise/domain/finding.py +46 -0
- mergewise-0.1.0a1/src/mergewise/domain/policies/__init__.py +0 -0
- mergewise-0.1.0a1/src/mergewise/domain/policies/classify.py +82 -0
- mergewise-0.1.0a1/src/mergewise/domain/policies/due.py +74 -0
- mergewise-0.1.0a1/src/mergewise/domain/policies/exclusion.py +7 -0
- mergewise-0.1.0a1/src/mergewise/domain/policies/settle.py +17 -0
- mergewise-0.1.0a1/src/mergewise/domain/review.py +62 -0
- mergewise-0.1.0a1/src/mergewise/domain/review_set.py +62 -0
- mergewise-0.1.0a1/src/mergewise/main.py +247 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/AUTO.md +161 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/interactive/SKILL.md +100 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/prompt.md +16 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/references/cross-repo.md +36 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/references/learn.md +44 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/references/legibility.md +41 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/references/style.md +27 -0
- mergewise-0.1.0a1/src/mergewise/reviewer/references/verification.md +72 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mergewise contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mergewise
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Automatic, learning code review for GitHub pull requests and GitLab merge requests, driven by Claude Code.
|
|
5
|
+
Project-URL: Homepage, https://sajjadrabiee.github.io/mergewise/
|
|
6
|
+
Project-URL: Repository, https://github.com/sajjadRabiee/mergewise
|
|
7
|
+
Project-URL: Issues, https://github.com/sajjadRabiee/mergewise/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/sajjadRabiee/mergewise#readme
|
|
9
|
+
Author: mergewise contributors
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,claude,claude code,code review,github,gitlab,llm,merge request,pull request
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Requires-Dist: keyring>=25
|
|
25
|
+
Requires-Dist: platformdirs>=4
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Requires-Dist: tomli-w>=1.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
<p align="center"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/assets/icon/icon-1024.png" width="128" alt="mergewise icon"></p>
|
|
31
|
+
|
|
32
|
+
<h1 align="center">mergewise</h1>
|
|
33
|
+
|
|
34
|
+
<p align="center"><b>Your review requests, reviewed by Claude Code before you open them: checked, sandboxed, and learning from your team.</b></p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<a href="https://github.com/sajjadRabiee/mergewise/actions/workflows/ci.yml"><img src="https://github.com/sajjadRabiee/mergewise/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
38
|
+
<a href="https://github.com/sajjadRabiee/mergewise/blob/main/LICENSE"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/docs/images/badge-license.svg" alt="License: MIT"></a>
|
|
39
|
+
<a href="https://github.com/sajjadRabiee/mergewise/blob/main/pyproject.toml"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/docs/images/badge-python.svg" alt="Python 3.12+"></a>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
mergewise reviews the GitLab merge requests and GitHub pull requests you are asked to review. It waits until the
|
|
43
|
+
author stops pushing, runs a Claude Code review in a sandbox that holds only a read-only token, checks every finding
|
|
44
|
+
before it is shown, and posts with a separate write token. It learns from how you and the authors reply. It runs as
|
|
45
|
+
one local service per user, with a versioned HTTP API, a `mergewise` command, a web dashboard and a Herdr mod.
|
|
46
|
+
|
|
47
|
+
**Status: pre-release.**
|
|
48
|
+
|
|
49
|
+
## Why mergewise
|
|
50
|
+
|
|
51
|
+
- **Reviews are ready before you look.** It watches the change requests you are a requested reviewer on, waits until
|
|
52
|
+
the newest push has settled, and reviews them in the background. "Review now" covers the urgent ones, and a second
|
|
53
|
+
review covers only what changed since.
|
|
54
|
+
- **Safe by construction, not by prompt.** The reviewer runs in Claude Code's sandbox with a read-only token, no MCP
|
|
55
|
+
server and no web tools. Only the service holds the write token, and it posts only a result it has checked.
|
|
56
|
+
- **It learns your team's taste.** Replies to its comments are classified as accepted, rejected or answered. A rule
|
|
57
|
+
rejected three times in a repo stops being posted there, and conventions people state become lessons the reviewer
|
|
58
|
+
reads first. Every automatic lesson can be undone.
|
|
59
|
+
- **One change, many repos, two hosts.** GitLab (gitlab.com or self-hosted) and GitHub (github.com or Enterprise
|
|
60
|
+
Server) side by side. Change requests across repos that share a branch, a ticket key or a link are reviewed
|
|
61
|
+
together as one change.
|
|
62
|
+
|
|
63
|
+
## Screenshots
|
|
64
|
+
|
|
65
|
+
<p align="center"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/docs/images/dashboard-overview.png" width="820" alt="The dashboard overview: the review running now, the next checks, the latest reviews and the connections"></p>
|
|
66
|
+
<p align="center"><i>The dashboard: what is being reviewed now, what settles when, the latest reviews.</i></p>
|
|
67
|
+
|
|
68
|
+
<p align="center"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/docs/images/dashboard-queue.png" width="820" alt="The queue: change requests waiting to settle, with Review changes and Full review"></p>
|
|
69
|
+
<p align="center"><i>The queue: each change request settles after its newest push; "Review changes" reviews only what is new.</i></p>
|
|
70
|
+
|
|
71
|
+
<table>
|
|
72
|
+
<tr>
|
|
73
|
+
<td width="64%"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/docs/images/dashboard-add-connection.png" alt="The connections page: adding a GitHub connection, step 1 of 3, above the Work GitLab and GitHub connections"></td>
|
|
74
|
+
<td width="36%"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/docs/images/herdr-panel.png" alt="The mergewise panel in Herdr: the running review, the queue and recent reviews"></td>
|
|
75
|
+
</tr>
|
|
76
|
+
<tr>
|
|
77
|
+
<td><i>Connections: add one in three steps (host, tokens, repos); each shows what its tokens can do.</i></td>
|
|
78
|
+
<td><i>The Herdr mod: status, queue and actions next to your terminals.</i></td>
|
|
79
|
+
</tr>
|
|
80
|
+
</table>
|
|
81
|
+
|
|
82
|
+
## Architecture
|
|
83
|
+
|
|
84
|
+
<p align="center"><img src="https://raw.githubusercontent.com/sajjadRabiee/mergewise/main/docs/images/architecture.svg" width="860" alt="Architecture: the CLI, the dashboard and the Herdr mod talk to one local mergewise service through its HTTP API. The service holds the use cases, SQLite and the GitLab and GitHub adapters, which post with the write token. It starts a sandboxed Claude Code reviewer that holds only the read token."></p>
|
|
85
|
+
|
|
86
|
+
The service is the only part that writes to a code host. Clients (CLI, dashboard, Herdr mod) talk to it through the
|
|
87
|
+
HTTP API described in [api/openapi.yaml](https://github.com/sajjadRabiee/mergewise/blob/main/api/openapi.yaml). Inside, it follows Clean Architecture: domain, use cases
|
|
88
|
+
behind ports, and adapters for the hosts, the reviewer, SQLite, the keyring and HTTP. See
|
|
89
|
+
[docs/architecture.md](https://github.com/sajjadRabiee/mergewise/blob/main/docs/architecture.md).
|
|
90
|
+
|
|
91
|
+
## Quick start
|
|
92
|
+
|
|
93
|
+
You need Python 3.12 or newer, [Claude Code](https://claude.com/claude-code) (`claude` on your PATH), and git.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# 1. Install (only pre-releases so far, hence --pre / --prerelease)
|
|
97
|
+
pipx install --pip-args=--pre mergewise
|
|
98
|
+
# or: uv tool install --prerelease=allow mergewise
|
|
99
|
+
# or the latest main: pipx install git+https://github.com/sajjadRabiee/mergewise.git
|
|
100
|
+
|
|
101
|
+
# 2. Write config.toml and the API token
|
|
102
|
+
mergewise init
|
|
103
|
+
|
|
104
|
+
# 3. Start the service, in its own terminal (it runs in the foreground)
|
|
105
|
+
mergewise serve
|
|
106
|
+
# or, to run it at login instead (launchd on macOS, systemd user unit on Linux):
|
|
107
|
+
# mergewise service install
|
|
108
|
+
|
|
109
|
+
# 4. Add a connection (tokens are asked for in a hidden prompt) and pick the repos to watch
|
|
110
|
+
mergewise connections add --host gitlab --base-url https://gitlab.com --label Work --with-write
|
|
111
|
+
mergewise repos ls gl-1
|
|
112
|
+
mergewise connections scope gl-1 selected --repo acme/api --repo acme/web
|
|
113
|
+
|
|
114
|
+
# 5. See what is going on
|
|
115
|
+
mergewise status
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For the dashboard, build [mergewise-dashboard](https://github.com/sajjadRabiee/mergewise-dashboard) and set
|
|
119
|
+
`[ui] dashboard_dir` (see [Configuration](https://github.com/sajjadRabiee/mergewise#configuration-configtoml)); the service then serves it at
|
|
120
|
+
`http://127.0.0.1:8766/`.
|
|
121
|
+
|
|
122
|
+
## How it works
|
|
123
|
+
|
|
124
|
+
- **Connections.** A connection is one account on one code host (gitlab.com, a self-hosted GitLab, github.com or
|
|
125
|
+
GitHub Enterprise). It has a read token (handed to the reviewer) and, optionally, a write token (used only by the
|
|
126
|
+
service to post). It watches all the repos the token can see, or a selected list.
|
|
127
|
+
- **What gets reviewed.** Open change requests where you are a requested reviewer (on GitHub: requested, or already
|
|
128
|
+
reviewed by you), in watched repos. Drafts are skipped; your own change requests are reviewed when you add yourself
|
|
129
|
+
as a reviewer. Change requests in several repos that share a branch, a ticket key (`ABC-123`) or a link are reviewed
|
|
130
|
+
together as one change.
|
|
131
|
+
- **When.** Every few minutes (`tick_s`), once the newest head is `settle_s` old. The first poll of a new connection
|
|
132
|
+
is its baseline: what is open then counts as reviewed, until a new push or "Review now".
|
|
133
|
+
- **Review now.** Starts at once. Once a change request was reviewed, Review now reviews only what changed since
|
|
134
|
+
(`--full` for the whole change).
|
|
135
|
+
- **Learning.** Replies to the comments mergewise posted are classified (accepted, rejected, answered); rules rejected
|
|
136
|
+
three times in a repo stop being posted there, and stated conventions become lessons the reviewer reads first.
|
|
137
|
+
Every automatic lesson can be undone.
|
|
138
|
+
|
|
139
|
+
## Add a connection
|
|
140
|
+
|
|
141
|
+
Tokens are read from a hidden prompt (or stdin with `--token-stdin`, one per line), never from the command line.
|
|
142
|
+
They are stored in the OS keyring. On a machine without a usable keyring (headless Linux, SSH, containers), the add
|
|
143
|
+
answers `keyring-unavailable` and names the variables to set, for example `MERGEWISE_TOKEN_GL_1_READ` and
|
|
144
|
+
`MERGEWISE_TOKEN_GL_1_WRITE`: set them in the service's environment, restart it, and run the same add again (pick the
|
|
145
|
+
id up front with `--id work` if you like; a failed add never uses an id up).
|
|
146
|
+
|
|
147
|
+
**GitLab** (gitlab.com or self-hosted, with a path prefix if any):
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
mergewise connections add --host gitlab --base-url https://gitlab.example.com --label Work --with-write
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- Read token: a personal access token with `read_api` and `read_repository` only. A read token that can write is
|
|
154
|
+
refused.
|
|
155
|
+
- Write token: `api`.
|
|
156
|
+
|
|
157
|
+
**GitHub** (github.com, or `https://ghe.example.com` for GitHub Enterprise Server):
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
mergewise connections add --host github --base-url https://github.com --label GitHub --with-write
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- Read token: a fine-grained token with **Contents: read** and **Pull requests: read**. GitHub does not report a
|
|
164
|
+
fine-grained token's permissions, so the dashboard shows it as "read-only not verified". A classic token is
|
|
165
|
+
accepted as the read token only if every scope only reads (`read:*`, `user:email`).
|
|
166
|
+
- Write token: **Pull requests: write** (fine-grained), or a classic token.
|
|
167
|
+
|
|
168
|
+
Without a write token a connection reviews and keeps the findings but posts nothing.
|
|
169
|
+
|
|
170
|
+
## Choose repos
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
mergewise repos ls gl-1 --query api # what the read token can see, * = watched
|
|
174
|
+
mergewise connections scope gl-1 selected --repo acme/api --repo acme/web
|
|
175
|
+
mergewise connections scope gl-1 all
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Everyday commands
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
mergewise status # service, connections, queue ("new changes" marks moved heads)
|
|
182
|
+
mergewise review-now gl-1:acme/api:12 # the key is shown by `mergewise --json status`
|
|
183
|
+
mergewise review-now gl-1:acme/api:12 --full
|
|
184
|
+
mergewise reviews ls; mergewise reviews show 41; mergewise reviews log 41
|
|
185
|
+
mergewise settings set --tick-s 300 --settle-s 600
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Dashboard, Herdr mod, interactive skill
|
|
189
|
+
|
|
190
|
+
- **Dashboard**: [mergewise-dashboard](https://github.com/sajjadRabiee/mergewise-dashboard), a web UI over the same
|
|
191
|
+
API. Point `[ui] dashboard_dir` at its build and the service serves it at `/`, on the API's own origin; or set
|
|
192
|
+
`[ui] dashboard_url` to where it runs.
|
|
193
|
+
- **Herdr mod**: [mergewise-herdr](https://github.com/sajjadRabiee/mergewise-herdr), status, queue and actions
|
|
194
|
+
inside Herdr.
|
|
195
|
+
- **Interactive skill**: `mergewise skill install` adds a Claude Code skill that reviews a change request on request,
|
|
196
|
+
lets you pick the findings, and posts them with `mergewise host post`.
|
|
197
|
+
|
|
198
|
+
## Configuration (`config.toml`)
|
|
199
|
+
|
|
200
|
+
Config lives in `~/.config/mergewise` (or `$XDG_CONFIG_HOME/mergewise`), data in `~/.local/share/mergewise`; set
|
|
201
|
+
`MERGEWISE_HOME` to keep both in one directory.
|
|
202
|
+
|
|
203
|
+
```toml
|
|
204
|
+
port = 8766 # the API listens on 127.0.0.1 only
|
|
205
|
+
tick_s = 300
|
|
206
|
+
settle_s = 600
|
|
207
|
+
review_timeout_s = 1800
|
|
208
|
+
herdr = false # run reviews in Herdr terminals instead of in the background
|
|
209
|
+
cors_origins = [] # browser origins besides the service's own; a dev server must opt in
|
|
210
|
+
ticket_key_regex = "..." # what links change requests across repos (default: ABC-123 style keys)
|
|
211
|
+
|
|
212
|
+
[ui]
|
|
213
|
+
dashboard_dir = "/path/to/mergewise-dashboard/dist" # served at / on the API's origin
|
|
214
|
+
dashboard_url = "http://127.0.0.1:8766/" # defaults to that when dashboard_dir is set
|
|
215
|
+
|
|
216
|
+
[extensions.migrations] # optional: a prompt fragment plus the Bash tools, read paths and hosts it needs
|
|
217
|
+
prompt_fragment = "Run the migration linter on every changed migration."
|
|
218
|
+
allowed_tools = ["Bash(migration-lint *)"]
|
|
219
|
+
network_hosts = []
|
|
220
|
+
# The review runs with no MCP server, no WebFetch/WebSearch and none of your Claude Code settings.
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Security model
|
|
224
|
+
|
|
225
|
+
- **Read token: only for the reviewer.** It reaches the review through its environment, never a command line. A
|
|
226
|
+
read token the host reports as able to write is refused.
|
|
227
|
+
- **Write token: only for posting.** It stays in the service, which uses it to post a checked result, to approve on
|
|
228
|
+
your request, or to undo. The reviewer never sees it and cannot post.
|
|
229
|
+
- **No MCP, no web.** The review runs with no MCP server, no WebFetch or WebSearch, and none of your Claude Code
|
|
230
|
+
settings or hooks. Claude Code's sandbox lets it write only its work directory, reach only the code host (and any
|
|
231
|
+
extension hosts you configure), and not read credential files.
|
|
232
|
+
- **Results are untrusted.** Before posting, the service checks that every comment targets a change request you
|
|
233
|
+
review, at the head the review read, with no secret in it, and that no hand review landed in the meantime. A review
|
|
234
|
+
is never posted twice.
|
|
235
|
+
- **Local API.** It binds `127.0.0.1`, checks the `Host` header and requires the bearer token in
|
|
236
|
+
`<config dir>/api-token` (mode 0600). Browsers get CORS only on the service's own origin. No endpoint ever returns
|
|
237
|
+
a token.
|
|
238
|
+
|
|
239
|
+
Found a security issue? Report it privately; see [SECURITY.md](https://github.com/sajjadRabiee/mergewise/blob/main/SECURITY.md).
|
|
240
|
+
|
|
241
|
+
## Related repositories
|
|
242
|
+
|
|
243
|
+
- [mergewise-dashboard](https://github.com/sajjadRabiee/mergewise-dashboard): the web dashboard.
|
|
244
|
+
- [mergewise-herdr](https://github.com/sajjadRabiee/mergewise-herdr): the Herdr mod.
|
|
245
|
+
|
|
246
|
+
## Development
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
uv sync
|
|
250
|
+
uv run pytest -q # never contacts a code host, never starts claude
|
|
251
|
+
uv run ruff check
|
|
252
|
+
uv run mergewise dev-stub # serves the openapi.yaml examples, for client development
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
See [CONTRIBUTING.md](https://github.com/sajjadRabiee/mergewise/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/sajjadRabiee/mergewise/blob/main/CODE_OF_CONDUCT.md). License: [MIT](https://github.com/sajjadRabiee/mergewise/blob/main/LICENSE).
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<p align="center"><img src="assets/icon/icon-1024.png" width="128" alt="mergewise icon"></p>
|
|
2
|
+
|
|
3
|
+
<h1 align="center">mergewise</h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><b>Your review requests, reviewed by Claude Code before you open them: checked, sandboxed, and learning from your team.</b></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/sajjadRabiee/mergewise/actions/workflows/ci.yml"><img src="https://github.com/sajjadRabiee/mergewise/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
9
|
+
<a href="LICENSE"><img src="docs/images/badge-license.svg" alt="License: MIT"></a>
|
|
10
|
+
<a href="pyproject.toml"><img src="docs/images/badge-python.svg" alt="Python 3.12+"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
mergewise reviews the GitLab merge requests and GitHub pull requests you are asked to review. It waits until the
|
|
14
|
+
author stops pushing, runs a Claude Code review in a sandbox that holds only a read-only token, checks every finding
|
|
15
|
+
before it is shown, and posts with a separate write token. It learns from how you and the authors reply. It runs as
|
|
16
|
+
one local service per user, with a versioned HTTP API, a `mergewise` command, a web dashboard and a Herdr mod.
|
|
17
|
+
|
|
18
|
+
**Status: pre-release.**
|
|
19
|
+
|
|
20
|
+
## Why mergewise
|
|
21
|
+
|
|
22
|
+
- **Reviews are ready before you look.** It watches the change requests you are a requested reviewer on, waits until
|
|
23
|
+
the newest push has settled, and reviews them in the background. "Review now" covers the urgent ones, and a second
|
|
24
|
+
review covers only what changed since.
|
|
25
|
+
- **Safe by construction, not by prompt.** The reviewer runs in Claude Code's sandbox with a read-only token, no MCP
|
|
26
|
+
server and no web tools. Only the service holds the write token, and it posts only a result it has checked.
|
|
27
|
+
- **It learns your team's taste.** Replies to its comments are classified as accepted, rejected or answered. A rule
|
|
28
|
+
rejected three times in a repo stops being posted there, and conventions people state become lessons the reviewer
|
|
29
|
+
reads first. Every automatic lesson can be undone.
|
|
30
|
+
- **One change, many repos, two hosts.** GitLab (gitlab.com or self-hosted) and GitHub (github.com or Enterprise
|
|
31
|
+
Server) side by side. Change requests across repos that share a branch, a ticket key or a link are reviewed
|
|
32
|
+
together as one change.
|
|
33
|
+
|
|
34
|
+
## Screenshots
|
|
35
|
+
|
|
36
|
+
<p align="center"><img src="docs/images/dashboard-overview.png" width="820" alt="The dashboard overview: the review running now, the next checks, the latest reviews and the connections"></p>
|
|
37
|
+
<p align="center"><i>The dashboard: what is being reviewed now, what settles when, the latest reviews.</i></p>
|
|
38
|
+
|
|
39
|
+
<p align="center"><img src="docs/images/dashboard-queue.png" width="820" alt="The queue: change requests waiting to settle, with Review changes and Full review"></p>
|
|
40
|
+
<p align="center"><i>The queue: each change request settles after its newest push; "Review changes" reviews only what is new.</i></p>
|
|
41
|
+
|
|
42
|
+
<table>
|
|
43
|
+
<tr>
|
|
44
|
+
<td width="64%"><img src="docs/images/dashboard-add-connection.png" alt="The connections page: adding a GitHub connection, step 1 of 3, above the Work GitLab and GitHub connections"></td>
|
|
45
|
+
<td width="36%"><img src="docs/images/herdr-panel.png" alt="The mergewise panel in Herdr: the running review, the queue and recent reviews"></td>
|
|
46
|
+
</tr>
|
|
47
|
+
<tr>
|
|
48
|
+
<td><i>Connections: add one in three steps (host, tokens, repos); each shows what its tokens can do.</i></td>
|
|
49
|
+
<td><i>The Herdr mod: status, queue and actions next to your terminals.</i></td>
|
|
50
|
+
</tr>
|
|
51
|
+
</table>
|
|
52
|
+
|
|
53
|
+
## Architecture
|
|
54
|
+
|
|
55
|
+
<p align="center"><img src="docs/images/architecture.svg" width="860" alt="Architecture: the CLI, the dashboard and the Herdr mod talk to one local mergewise service through its HTTP API. The service holds the use cases, SQLite and the GitLab and GitHub adapters, which post with the write token. It starts a sandboxed Claude Code reviewer that holds only the read token."></p>
|
|
56
|
+
|
|
57
|
+
The service is the only part that writes to a code host. Clients (CLI, dashboard, Herdr mod) talk to it through the
|
|
58
|
+
HTTP API described in [api/openapi.yaml](api/openapi.yaml). Inside, it follows Clean Architecture: domain, use cases
|
|
59
|
+
behind ports, and adapters for the hosts, the reviewer, SQLite, the keyring and HTTP. See
|
|
60
|
+
[docs/architecture.md](docs/architecture.md).
|
|
61
|
+
|
|
62
|
+
## Quick start
|
|
63
|
+
|
|
64
|
+
You need Python 3.12 or newer, [Claude Code](https://claude.com/claude-code) (`claude` on your PATH), and git.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 1. Install (only pre-releases so far, hence --pre / --prerelease)
|
|
68
|
+
pipx install --pip-args=--pre mergewise
|
|
69
|
+
# or: uv tool install --prerelease=allow mergewise
|
|
70
|
+
# or the latest main: pipx install git+https://github.com/sajjadRabiee/mergewise.git
|
|
71
|
+
|
|
72
|
+
# 2. Write config.toml and the API token
|
|
73
|
+
mergewise init
|
|
74
|
+
|
|
75
|
+
# 3. Start the service, in its own terminal (it runs in the foreground)
|
|
76
|
+
mergewise serve
|
|
77
|
+
# or, to run it at login instead (launchd on macOS, systemd user unit on Linux):
|
|
78
|
+
# mergewise service install
|
|
79
|
+
|
|
80
|
+
# 4. Add a connection (tokens are asked for in a hidden prompt) and pick the repos to watch
|
|
81
|
+
mergewise connections add --host gitlab --base-url https://gitlab.com --label Work --with-write
|
|
82
|
+
mergewise repos ls gl-1
|
|
83
|
+
mergewise connections scope gl-1 selected --repo acme/api --repo acme/web
|
|
84
|
+
|
|
85
|
+
# 5. See what is going on
|
|
86
|
+
mergewise status
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For the dashboard, build [mergewise-dashboard](https://github.com/sajjadRabiee/mergewise-dashboard) and set
|
|
90
|
+
`[ui] dashboard_dir` (see [Configuration](#configuration-configtoml)); the service then serves it at
|
|
91
|
+
`http://127.0.0.1:8766/`.
|
|
92
|
+
|
|
93
|
+
## How it works
|
|
94
|
+
|
|
95
|
+
- **Connections.** A connection is one account on one code host (gitlab.com, a self-hosted GitLab, github.com or
|
|
96
|
+
GitHub Enterprise). It has a read token (handed to the reviewer) and, optionally, a write token (used only by the
|
|
97
|
+
service to post). It watches all the repos the token can see, or a selected list.
|
|
98
|
+
- **What gets reviewed.** Open change requests where you are a requested reviewer (on GitHub: requested, or already
|
|
99
|
+
reviewed by you), in watched repos. Drafts are skipped; your own change requests are reviewed when you add yourself
|
|
100
|
+
as a reviewer. Change requests in several repos that share a branch, a ticket key (`ABC-123`) or a link are reviewed
|
|
101
|
+
together as one change.
|
|
102
|
+
- **When.** Every few minutes (`tick_s`), once the newest head is `settle_s` old. The first poll of a new connection
|
|
103
|
+
is its baseline: what is open then counts as reviewed, until a new push or "Review now".
|
|
104
|
+
- **Review now.** Starts at once. Once a change request was reviewed, Review now reviews only what changed since
|
|
105
|
+
(`--full` for the whole change).
|
|
106
|
+
- **Learning.** Replies to the comments mergewise posted are classified (accepted, rejected, answered); rules rejected
|
|
107
|
+
three times in a repo stop being posted there, and stated conventions become lessons the reviewer reads first.
|
|
108
|
+
Every automatic lesson can be undone.
|
|
109
|
+
|
|
110
|
+
## Add a connection
|
|
111
|
+
|
|
112
|
+
Tokens are read from a hidden prompt (or stdin with `--token-stdin`, one per line), never from the command line.
|
|
113
|
+
They are stored in the OS keyring. On a machine without a usable keyring (headless Linux, SSH, containers), the add
|
|
114
|
+
answers `keyring-unavailable` and names the variables to set, for example `MERGEWISE_TOKEN_GL_1_READ` and
|
|
115
|
+
`MERGEWISE_TOKEN_GL_1_WRITE`: set them in the service's environment, restart it, and run the same add again (pick the
|
|
116
|
+
id up front with `--id work` if you like; a failed add never uses an id up).
|
|
117
|
+
|
|
118
|
+
**GitLab** (gitlab.com or self-hosted, with a path prefix if any):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
mergewise connections add --host gitlab --base-url https://gitlab.example.com --label Work --with-write
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- Read token: a personal access token with `read_api` and `read_repository` only. A read token that can write is
|
|
125
|
+
refused.
|
|
126
|
+
- Write token: `api`.
|
|
127
|
+
|
|
128
|
+
**GitHub** (github.com, or `https://ghe.example.com` for GitHub Enterprise Server):
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
mergewise connections add --host github --base-url https://github.com --label GitHub --with-write
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- Read token: a fine-grained token with **Contents: read** and **Pull requests: read**. GitHub does not report a
|
|
135
|
+
fine-grained token's permissions, so the dashboard shows it as "read-only not verified". A classic token is
|
|
136
|
+
accepted as the read token only if every scope only reads (`read:*`, `user:email`).
|
|
137
|
+
- Write token: **Pull requests: write** (fine-grained), or a classic token.
|
|
138
|
+
|
|
139
|
+
Without a write token a connection reviews and keeps the findings but posts nothing.
|
|
140
|
+
|
|
141
|
+
## Choose repos
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
mergewise repos ls gl-1 --query api # what the read token can see, * = watched
|
|
145
|
+
mergewise connections scope gl-1 selected --repo acme/api --repo acme/web
|
|
146
|
+
mergewise connections scope gl-1 all
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Everyday commands
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
mergewise status # service, connections, queue ("new changes" marks moved heads)
|
|
153
|
+
mergewise review-now gl-1:acme/api:12 # the key is shown by `mergewise --json status`
|
|
154
|
+
mergewise review-now gl-1:acme/api:12 --full
|
|
155
|
+
mergewise reviews ls; mergewise reviews show 41; mergewise reviews log 41
|
|
156
|
+
mergewise settings set --tick-s 300 --settle-s 600
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Dashboard, Herdr mod, interactive skill
|
|
160
|
+
|
|
161
|
+
- **Dashboard**: [mergewise-dashboard](https://github.com/sajjadRabiee/mergewise-dashboard), a web UI over the same
|
|
162
|
+
API. Point `[ui] dashboard_dir` at its build and the service serves it at `/`, on the API's own origin; or set
|
|
163
|
+
`[ui] dashboard_url` to where it runs.
|
|
164
|
+
- **Herdr mod**: [mergewise-herdr](https://github.com/sajjadRabiee/mergewise-herdr), status, queue and actions
|
|
165
|
+
inside Herdr.
|
|
166
|
+
- **Interactive skill**: `mergewise skill install` adds a Claude Code skill that reviews a change request on request,
|
|
167
|
+
lets you pick the findings, and posts them with `mergewise host post`.
|
|
168
|
+
|
|
169
|
+
## Configuration (`config.toml`)
|
|
170
|
+
|
|
171
|
+
Config lives in `~/.config/mergewise` (or `$XDG_CONFIG_HOME/mergewise`), data in `~/.local/share/mergewise`; set
|
|
172
|
+
`MERGEWISE_HOME` to keep both in one directory.
|
|
173
|
+
|
|
174
|
+
```toml
|
|
175
|
+
port = 8766 # the API listens on 127.0.0.1 only
|
|
176
|
+
tick_s = 300
|
|
177
|
+
settle_s = 600
|
|
178
|
+
review_timeout_s = 1800
|
|
179
|
+
herdr = false # run reviews in Herdr terminals instead of in the background
|
|
180
|
+
cors_origins = [] # browser origins besides the service's own; a dev server must opt in
|
|
181
|
+
ticket_key_regex = "..." # what links change requests across repos (default: ABC-123 style keys)
|
|
182
|
+
|
|
183
|
+
[ui]
|
|
184
|
+
dashboard_dir = "/path/to/mergewise-dashboard/dist" # served at / on the API's origin
|
|
185
|
+
dashboard_url = "http://127.0.0.1:8766/" # defaults to that when dashboard_dir is set
|
|
186
|
+
|
|
187
|
+
[extensions.migrations] # optional: a prompt fragment plus the Bash tools, read paths and hosts it needs
|
|
188
|
+
prompt_fragment = "Run the migration linter on every changed migration."
|
|
189
|
+
allowed_tools = ["Bash(migration-lint *)"]
|
|
190
|
+
network_hosts = []
|
|
191
|
+
# The review runs with no MCP server, no WebFetch/WebSearch and none of your Claude Code settings.
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Security model
|
|
195
|
+
|
|
196
|
+
- **Read token: only for the reviewer.** It reaches the review through its environment, never a command line. A
|
|
197
|
+
read token the host reports as able to write is refused.
|
|
198
|
+
- **Write token: only for posting.** It stays in the service, which uses it to post a checked result, to approve on
|
|
199
|
+
your request, or to undo. The reviewer never sees it and cannot post.
|
|
200
|
+
- **No MCP, no web.** The review runs with no MCP server, no WebFetch or WebSearch, and none of your Claude Code
|
|
201
|
+
settings or hooks. Claude Code's sandbox lets it write only its work directory, reach only the code host (and any
|
|
202
|
+
extension hosts you configure), and not read credential files.
|
|
203
|
+
- **Results are untrusted.** Before posting, the service checks that every comment targets a change request you
|
|
204
|
+
review, at the head the review read, with no secret in it, and that no hand review landed in the meantime. A review
|
|
205
|
+
is never posted twice.
|
|
206
|
+
- **Local API.** It binds `127.0.0.1`, checks the `Host` header and requires the bearer token in
|
|
207
|
+
`<config dir>/api-token` (mode 0600). Browsers get CORS only on the service's own origin. No endpoint ever returns
|
|
208
|
+
a token.
|
|
209
|
+
|
|
210
|
+
Found a security issue? Report it privately; see [SECURITY.md](SECURITY.md).
|
|
211
|
+
|
|
212
|
+
## Related repositories
|
|
213
|
+
|
|
214
|
+
- [mergewise-dashboard](https://github.com/sajjadRabiee/mergewise-dashboard): the web dashboard.
|
|
215
|
+
- [mergewise-herdr](https://github.com/sajjadRabiee/mergewise-herdr): the Herdr mod.
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
uv sync
|
|
221
|
+
uv run pytest -q # never contacts a code host, never starts claude
|
|
222
|
+
uv run ruff check
|
|
223
|
+
uv run mergewise dev-stub # serves the openapi.yaml examples, for client development
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and the [Code of Conduct](CODE_OF_CONDUCT.md). License: [MIT](LICENSE).
|