MergeSafe

v1.0.1
ai.mergesafe/mergesafe Checked 1 day ago Published 12 days ago

The 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…

ParameterTypeDescription
pr_number *integerThe pull request number.
repo *stringThe 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.

ParameterTypeDescription
pr_number *integerThe pull request number.
repo *stringThe repository as "owner/name".
addonsarrayOptional add-ons; leave out to use the repository's own setting.
tierstringOptional 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.

ParameterTypeDescription
org *stringThe organization's GitHub login.
repostringOptional 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.

ParameterTypeDescription
org *stringThe 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.

ParameterTypeDescription
repo *stringThe 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…

ParameterTypeDescription
evidence *arrayThe test excerpts, as the tool's description lists.
head_sha *stringThe commit read at (40 hex).
pr_number *integerThe pull request number.
repo *stringThe repository as "owner/name".
addonsarrayOptional add-ons; leave out to use the repository's own setting.
tierstringOptional 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).

ParameterTypeDescription
limit_usd *numberThe cost limit the user chose, in US dollars.
repo *stringThe repository as "owner/name".
basestringThe branch the change is against.
branchstringThe 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…

ParameterTypeDescription
repo *stringThe session's repository, "owner/name".
session_id *stringThe session_id start_session returned.
callers_not_followedarrayChanged files that were sent, whose callers the review could not follow because their name is too common. The quote names them.
context_filesarrayUnchanged files that call, or are called by, the changes.
filesarrayThe changed files, unless upload_id is given.
omittedarrayFiles the review could not be sent because of the upload caps. The quote names them, so nothing left out is taken for absent.
upload_idstringFrom 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.

ParameterTypeDescription
base *stringThe branch the change is against.
head *stringThe pushed branch to review.
repo *stringThe session's repository, "owner/name".
session_id *stringThe 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.

ParameterTypeDescription
level *stringThe level the user confirmed, one the quote priced.
repo *stringThe session's repository, "owner/name".
review_id *integerThe review_id of the quote the user confirmed.
session_id *stringThe 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.

ParameterTypeDescription
amount_usd *numberThe amount the user agreed to add, in US dollars.
repo *stringThe session's repository, "owner/name".
session_id *stringThe 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.

ParameterTypeDescription
repo *stringThe session's repository, "owner/name".
session_id *stringThe 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.

ParameterTypeDescription
finding_id *stringThe finding's id, from get_session_findings.
reply *stringWhy it is intended, or why it will not be fixed here.
repo *stringThe session's repository, "owner/name".
session_id *stringThe session_id start_session returned.

session_cost Session cost

The session's total so far, its limit and what is left.

ParameterTypeDescription
repo *stringThe session's repository, "owner/name".
session_id *stringThe 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.

ParameterTypeDescription
repo *stringThe session's repository, "owner/name".
session_id *stringThe session_id start_session returned.

end_session End the session

Close the session; the uploaded code is deleted. Findings are kept.

ParameterTypeDescription
repo *stringThe session's repository, "owner/name".
session_id *stringThe session_id start_session returned.