MergeSafe
v1.0.1The GitHub gatekeeper for builders: read review findings, fix them, ask for a re-review.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
get_findings Get pull request findings
List MergeSafe's findings on the latest review of a pull request. Each has severity (P0 most severe .. P3), title, problem, file, line, status, blocking and comment_url, the inline comment on GitHub that holds the full explanation and a prompt for fixing it. Loop: for each blocking finding, check the claim against the file as it stands now; if it holds, fix it and add a regression test; run the tests; commit and push; then call request_review. A finding of type question (needs_decision) asks whether a behavior is intended, with its severity_if_unintended; it does not block. It needs a decision…
| Parameter | Type | Description |
|---|---|---|
pr_number * | integer | The pull request number. |
repo * | string | The repository as "owner/name". |
request_review Request a review
Ask MergeSafe to review the current head of a pull request; MergeSafe posts the review on the pull request. A head that was already reviewed is refused, not charged twice. Call it after pushing fixes.
| Parameter | Type | Description |
|---|---|---|
pr_number * | integer | The pull request number. |
repo * | string | The repository as "owner/name". |
addons | array | Optional add-ons; leave out to use the repository's own setting. |
tier | string | Optional review level: essential, strong or ultra (budget, the older name, still works and is what responses say). Leave it out to use the repository's own setting. |
get_settings Read settings
Read how this organization's MergeSafe is set up: for each setting its effective value, where the value comes from (repo_override, org, mixed with field_sources, mergesafe_default, or unchecked when it could not be read) and the values it may take, plus the settings version. Give the org (its GitHub login); add repo for that repository's effective settings. Read-only. A Member sees no billing fields.
| Parameter | Type | Description |
|---|---|---|
org * | string | The organization's GitHub login. |
repo | string | Optional repository name. |
list_repositories List reviewed repositories
List the repositories MergeSafe reviews for an organization, each with its effective level, plus the org's trigger mode and the GitHub link where the repository selection is changed (GitHub decides which repos are reviewed). Read-only. A Member sees only the repos their GitHub account can see.
| Parameter | Type | Description |
|---|---|---|
org * | string | The organization's GitHub login. |
local_context_status Check local context
Whether the repository's organization accepts local context (request_review_with_context). Ask before reading anything to send: when it is off, send nothing and use request_review.
| Parameter | Type | Description |
|---|---|---|
repo * | string | The repository as "owner/name". |
request_review_with_context Request a review with local tests
Like request_review, but also sends excerpts of the tests of the files the pull request changes, read from your local checkout, so the review sees them. Only when local_context_status says enabled. Push first: head_sha is the commit you read at, and if the pull request's head is another commit nothing is queued (head_moved). For each changed source file, up to 3 test files named after it (test_foo.py, foo_test.go, foo.test.ts, foo.spec.js, FooTest.java, or foo.* in a tests directory); each item is {path, start_line: 1, end_line, sha: head_sha, text}: the file's first lines exactly as committed…
| Parameter | Type | Description |
|---|---|---|
evidence * | array | The test excerpts, as the tool's description lists. |
head_sha * | string | The commit read at (40 hex). |
pr_number * | integer | The pull request number. |
repo * | string | The repository as "owner/name". |
addons | array | Optional add-ons; leave out to use the repository's own setting. |
tier | string | Optional review level: essential, strong or ultra (budget, the older name, still works and is what responses say). Leave it out to use the repository's own setting. |
start_session Start a local review session
Start a MergeSafe review session for local changes, before or without a pull request; nothing is posted to GitHub. FIRST ask the user for a cost limit for the session in US dollars and pass it as limit_usd: reviews stop when it is reached until the user approves more. Returns the session_id and how reviews are priced (level rate x review size).
| Parameter | Type | Description |
|---|---|---|
limit_usd * | number | The cost limit the user chose, in US dollars. |
repo * | string | The repository as "owner/name". |
base | string | The branch the change is against. |
branch | string | The local branch, if any. |
review_local Quote a local review
Send the local diff for review and get its quote. Nothing runs yet: the answer says 'This review will cost you up to $X (Strong)' with the other levels' prices. Always show the user the price and ask them to confirm before you call confirm_review; never confirm on your own. Send each changed file with its patch and full text (none for a removed file). Also send context_files: the files that call, or are called by, the changed code (its callers and the modules it imports), because the review sees only what you send and cannot check effects in files it was not given. (at most 250000 bytes in all…
| Parameter | Type | Description |
|---|---|---|
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |
callers_not_followed | array | Changed files that were sent, whose callers the review could not follow because their name is too common. The quote names them. |
context_files | array | Unchanged files that call, or are called by, the changes. |
files | array | The changed files, unless upload_id is given. |
omitted | array | Files the review could not be sent because of the upload caps. The quote names them, so nothing left out is taken for absent. |
upload_id | string | From an upload sent with prepare_upload's token. Use this for a review too large to pass inline in files. |
review_branch Review a pushed branch
Review a branch already pushed to GitHub, with no upload: MergeSafe reads the branch's changes from GitHub itself. Returns review_id with status 'fetching' (queued). Poll get_session_findings until this review is 'quoted', then show the user its price as for review_local and ask them to confirm before confirm_review. A branch MergeSafe cannot read is refused with a note, and nothing is charged for it.
| Parameter | Type | Description |
|---|---|---|
base * | string | The branch the change is against. |
head * | string | The pushed branch to review. |
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |
confirm_review Run a confirmed review
Run a quoted review at the level the user chose, ONLY after the user confirmed its price. The price is held; what is charged afterwards is never more. If the session's limit would be passed, nothing runs: ask the user, and use approve_more only if they agree. Then poll get_session_findings.
| Parameter | Type | Description |
|---|---|---|
level * | string | The level the user confirmed, one the quote priced. |
repo * | string | The session's repository, "owner/name". |
review_id * | integer | The review_id of the quote the user confirmed. |
session_id * | string | The session_id start_session returned. |
approve_more Raise the session limit
Raise the session's cost limit by amount_usd. Only after the user explicitly agreed to that amount; never on your own.
| Parameter | Type | Description |
|---|---|---|
amount_usd * | number | The amount the user agreed to add, in US dollars. |
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |
get_session_findings Get session findings
The session's findings (severity P0 most severe .. P3, file, lines, problem, suggestion, status: open, withdrawn or kept_at_p3, and any answer's verdict; a finding whose answer could not be judged is open again and may be answered) and the state of its latest review: running, done with the price charged, or failed (never charged). Fix what holds, then review_local again; or answer a finding with answer_finding.
| Parameter | Type | Description |
|---|---|---|
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |
answer_finding Answer a finding
Answer a finding once per review (free): 'won't fix here' or why it is intended. MergeSafe judges the reply and withdraws the finding, keeps it at P3, or notes it; get_session_findings shows the verdict. For a fix, just review_local again: the next review re-checks the file.
| Parameter | Type | Description |
|---|---|---|
finding_id * | string | The finding's id, from get_session_findings. |
reply * | string | Why it is intended, or why it will not be fixed here. |
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |
session_cost Session cost
The session's total so far, its limit and what is left.
| Parameter | Type | Description |
|---|---|---|
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |
prepare_upload Prepare an upload
Get a short-lived upload token for this open session (10 minutes, one upload). The local process POSTs the review's files to upload_path with it, so the file contents never pass through you. Then call review_local with the upload_id it returns. Spends nothing.
| Parameter | Type | Description |
|---|---|---|
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |
end_session End the session
Close the session; the uploaded code is deleted. Findings are kept.
| Parameter | Type | Description |
|---|---|---|
repo * | string | The session's repository, "owner/name". |
session_id * | string | The session_id start_session returned. |