@jesdi/skills 0.0.92 → 0.0.93
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: babysit-pr
|
|
3
|
-
description: Babysit an open pull request until it is merged or handed to a human. Started by the PostToolUse hook after `gh pr create`, or by hand with `/babysit-pr
|
|
3
|
+
description: Babysit an open pull request until it is merged or handed to a human. Started by the PostToolUse hook after `gh pr create`, or by hand with `/babysit-pr` and a PR URL.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# babysit-pr
|
|
@@ -9,6 +9,16 @@ Run with `/babysit-pr <pr-url>`. The PostToolUse hook in `hooks/post-pr-create.s
|
|
|
9
9
|
|
|
10
10
|
`babysit.py` is next to this file; every state change below goes through it (`python3 babysit.py <cmd> --repo <owner/name> --pr <n> ...`). Work in a checkout of the PR branch. The base is the PR's `baseRefName`, never a fixed `main`.
|
|
11
11
|
|
|
12
|
+
## Merge authorization
|
|
13
|
+
|
|
14
|
+
An explicit instruction in this conversation such as “babysit that PR and merge it when green” authorizes merging that PR. Record its current remote head as the authorized head. The agent obtains the SHA; the user need not type it or repeat the instruction in a GitHub comment.
|
|
15
|
+
|
|
16
|
+
That authorization follows this session's fixes within the original task and clean rebases. Keep the authorized head in session context: before a push, compare the remote head with the last head this session recorded, then advance it only to the exact checked commit this session produced and successfully pushed. Before merging, compare again. A commit author or GitHub login is not provenance: another agent can use the same identity. Unknown remote commits or a scope change require a new user decision: hand off with reason `authorization scope changed`, naming the old and new heads and the unapproved change. Never adopt them by refreshing the recorded head. After lost context, recover this evidence or ask rather than infer authorization.
|
|
17
|
+
|
|
18
|
+
With this authorization, run `merge --session-approved --session <lease-session> --sha <authorized-head> --body <body-file>` after CI is green and the review checks below pass. The merge still pins and rechecks the exact head, base and body, verifies lease ownership, and respects review handoffs, dependent PRs and GitHub branch protections. The session authorization supplies the human decision when risk exceeds the automatic limit; no duplicate approval comment or judge is needed. The success comment records the session and merged SHA.
|
|
19
|
+
|
|
20
|
+
Invoking the skill alone, or a hook starting it, does not grant this explicit authorization: use the automatic gate/judge path. The owner's existing `@babysitter merge <sha>` comment remains a separate, commit-specific approval path.
|
|
21
|
+
|
|
12
22
|
## Before anything
|
|
13
23
|
|
|
14
24
|
- `pr-risk` must be in `.my-skills/pr-risk`, `.agents/skills/pr-risk`, `.claude/skills/pr-risk` or `~/.my-skills/pr-risk`, in this order. If it is in none, stop and print the install command.
|
|
@@ -21,7 +31,7 @@ Run with `/babysit-pr <pr-url>`. The PostToolUse hook in `hooks/post-pr-create.s
|
|
|
21
31
|
2. `update-plan --base <base>` when the base moved; follow its plan (see Base moved). Every step uses `origin/<base>` of the PR (a stacked PR's parent), never `main`.
|
|
22
32
|
3. `checks --wait-minutes <waitMinutes>` until the head is green, red, stalled (`CI stalled`) or empty (`no checks`). Green means every check passed.
|
|
23
33
|
4. Red: `round start --op <id>` (keep the id), then the fix round below. Renew the lease each round and `lease check` before each push.
|
|
24
|
-
5. Green: run the gate (`pr-risk` `merge_risk.py gate`), then `judge`, then `merge-method` and `merge`. Pass the judge's label and risk to `merge --judge agree --judge-risk <risk>` (or `--judge 'same-model agree'` for fallback), never an output file path. The merge pins the head SHA the gate and judge saw, and hands off when the gate's or the judge's risk is above the repo's limit.
|
|
34
|
+
5. Green: with explicit session authorization, use its merge path above. Otherwise, absent an owner commit approval, run the gate (`pr-risk` `merge_risk.py gate`), then `judge`, then `merge-method` and `merge`. Pass the judge's label and risk to `merge --judge agree --judge-risk <risk>` (or `--judge 'same-model agree'` for fallback), never an output file path. The merge pins the head SHA the gate and judge saw, and hands off when the gate's or the judge's risk is above the repo's limit.
|
|
25
35
|
|
|
26
36
|
## A fix round
|
|
27
37
|
|
|
@@ -41,7 +51,7 @@ Hand off when 5 rounds are done and a check still fails (`5 fix rounds`), or the
|
|
|
41
51
|
- `rebase-with-conflict`: rebase and resolve each stop with the `resolving-merge-conflicts` skill. Never `--abort`. Push with the printed lease form.
|
|
42
52
|
- `merge`: `git merge origin/<base>`, resolve with the same skill, push without force. This PR now uses the merge method.
|
|
43
53
|
|
|
44
|
-
Push only after the ladder passes, then wait for CI on the new head. If a resolution changed a file whose categories (the pr-risk path classification, not its directory) are neither `tests` nor `docs`, or a lockfile by hand, the verdict is human: once CI is green, `handoff` with `conflict resolved in code` (no gate, judge or merge).
|
|
54
|
+
Push only after the ladder passes, then wait for CI on the new head. For session-authorized runs, a clean rebase advances the authorized head only from the previously recorded remote head to this session's successfully pushed result; preserve the same scope and check the new SHA. If a resolution changed a file whose categories (the pr-risk path classification, not its directory) are neither `tests` nor `docs`, or a lockfile by hand, the verdict is human: once CI is green, `handoff` with `conflict resolved in code` (no gate, judge or merge).
|
|
45
55
|
|
|
46
56
|
## Handoff
|
|
47
57
|
|
|
@@ -844,7 +844,7 @@ def handoff(repo, number, reason, ci, rounds, gate, judge_line, fix_log, extra="
|
|
|
844
844
|
|
|
845
845
|
|
|
846
846
|
def merge_cmd(repo, number, sha, body_file, policy, judge_label, approved, session=None, base=None,
|
|
847
|
-
judge_risk=None):
|
|
847
|
+
judge_risk=None, session_approved=False):
|
|
848
848
|
pr = json.loads(gh("api", f"repos/{repo}/pulls/{number}"))
|
|
849
849
|
if base not in (None, pr["base"]["ref"]):
|
|
850
850
|
fail(f"--base {base} is not the PR's base {pr['base']['ref']}")
|
|
@@ -861,7 +861,7 @@ def merge_cmd(repo, number, sha, body_file, policy, judge_label, approved, sessi
|
|
|
861
861
|
fail(f"origin/{base} is {tip[:7]} but the PR's base is {pr['base']['sha'][:7]}: fetch and gate again")
|
|
862
862
|
gate = "gate: passed"
|
|
863
863
|
judge_line = f"judge: {judge_label}"
|
|
864
|
-
op = hashlib.sha256(f"{sha} {judge_label} {approved}".encode()).hexdigest()[:12]
|
|
864
|
+
op = hashlib.sha256(f"{sha} {judge_label} {approved} {session_approved}".encode()).hexdigest()[:12]
|
|
865
865
|
|
|
866
866
|
def stop(reason, extra=""):
|
|
867
867
|
handoff(repo, number, reason, "green", None, gate, judge_line, "(none)", extra, session, f"{op}-{reason}")
|
|
@@ -869,7 +869,14 @@ def merge_cmd(repo, number, sha, body_file, policy, judge_label, approved, sessi
|
|
|
869
869
|
|
|
870
870
|
if pr["head"]["sha"] != sha:
|
|
871
871
|
fail(f"head moved to {pr['head']['sha']} since the gate saw {sha}: gate again")
|
|
872
|
-
if
|
|
872
|
+
if session_approved:
|
|
873
|
+
own_lease(repo, number, session)
|
|
874
|
+
gate = "gate: explicit session authorization"
|
|
875
|
+
judge_line = f"session {session} authorized merge"
|
|
876
|
+
found = owner_comments(repo, number)
|
|
877
|
+
if found["handoff"]:
|
|
878
|
+
stop(found["handoff"])
|
|
879
|
+
elif approved is None:
|
|
873
880
|
if judge_label not in ("agree", "same-model agree"):
|
|
874
881
|
stop(f"judge {judge_label}")
|
|
875
882
|
mr = load_merge_risk(base)
|
|
@@ -937,6 +944,7 @@ def merge_cmd(repo, number, sha, body_file, policy, judge_label, approved, sessi
|
|
|
937
944
|
stop(f"merge blocked: {'approval required' if 'approv' in err.lower() else err}")
|
|
938
945
|
pr = Pr(repo, number)
|
|
939
946
|
pr.post("🤖 Merged by babysit-pr: " + (
|
|
947
|
+
f"session {session} authorized merge at {sha}" if session_approved else
|
|
940
948
|
f"{risk_line}gate passed, judge {judge_label}" if approved is None else f"owner approved {approved}"))
|
|
941
949
|
if session:
|
|
942
950
|
release(pr, session)
|
|
@@ -982,6 +990,8 @@ def main():
|
|
|
982
990
|
mg.add_argument("--judge")
|
|
983
991
|
mg.add_argument("--judge-risk", type=int, choices=range(1, 11), metavar="1-10")
|
|
984
992
|
mg.add_argument("--approved-sha")
|
|
993
|
+
mg.add_argument("--session-approved", action="store_true",
|
|
994
|
+
help="the user explicitly instructed this session to merge this PR")
|
|
985
995
|
mg.add_argument("--base")
|
|
986
996
|
for p in (mg, hp):
|
|
987
997
|
p.add_argument("--session", help="release this session's lease")
|
|
@@ -1002,9 +1012,14 @@ def main():
|
|
|
1002
1012
|
elif a.cmd == "merge-method":
|
|
1003
1013
|
print(json.dumps({"method": merge_method(a.repo, a.pr, a.policy)}))
|
|
1004
1014
|
elif a.cmd == "merge":
|
|
1005
|
-
if
|
|
1006
|
-
ap.error("
|
|
1007
|
-
|
|
1015
|
+
if a.session_approved and not a.session:
|
|
1016
|
+
ap.error("--session-approved needs --session")
|
|
1017
|
+
if a.session_approved and (a.approved_sha or a.judge or a.judge_risk):
|
|
1018
|
+
ap.error("--session-approved cannot be combined with --approved-sha or --judge/--judge-risk")
|
|
1019
|
+
if not (a.judge or a.approved_sha or a.session_approved):
|
|
1020
|
+
ap.error("merge needs --judge, --approved-sha or --session-approved")
|
|
1021
|
+
merge_cmd(a.repo, a.pr, a.sha, a.body, a.policy, a.judge, a.approved_sha, a.session, a.base,
|
|
1022
|
+
a.judge_risk, a.session_approved)
|
|
1008
1023
|
elif a.cmd == "handoff":
|
|
1009
1024
|
handoff(a.repo, a.pr, a.reason, a.ci, a.rounds, a.gate, a.judge, Path(a.fix_log).read_text(), session=a.session)
|
|
1010
1025
|
elif a.cmd == "update-plan":
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""In-session merge instructions reach the same pinned, green merge CLI."""
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
from test_merge_and_handoff import commit, comments, handoffs, merge, world
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def session(w):
|
|
8
|
+
assert w.run("acquire", "s1").returncode == 0
|
|
9
|
+
return ("--session", "s1", "--session-approved")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_session_instruction_merges_human_risk_without_a_github_approval(tmp_path):
|
|
13
|
+
w = world(tmp_path, policy={"maxAutoRisk": 0})
|
|
14
|
+
p = merge(w, tmp_path, "a1b2c3d", *session(w))
|
|
15
|
+
assert p.returncode == 0, p.output
|
|
16
|
+
[merged] = w.github()["merges"]
|
|
17
|
+
assert merged["match"] == "a1b2c3d"
|
|
18
|
+
assert handoffs(w) == []
|
|
19
|
+
assert any("session s1 authorized merge" in c for c in comments(w))
|
|
20
|
+
assert w.active_leases() == []
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_session_instruction_cannot_merge_a_head_that_moved(tmp_path):
|
|
24
|
+
w = world(tmp_path, head="f0e1d2c", commits=[commit("a1b2c3d"), commit("f0e1d2c")])
|
|
25
|
+
p = merge(w, tmp_path, "a1b2c3d", *session(w))
|
|
26
|
+
assert p.returncode != 0
|
|
27
|
+
assert "head moved" in p.output
|
|
28
|
+
assert not w.github().get("merges")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.parametrize("checks", [[], [{"name": "ci", "status": "completed", "conclusion": "failure"}]])
|
|
32
|
+
def test_session_instruction_still_requires_green_checks(tmp_path, checks):
|
|
33
|
+
w = world(tmp_path, check_runs={"a1b2c3d": checks})
|
|
34
|
+
p = merge(w, tmp_path, "a1b2c3d", *session(w))
|
|
35
|
+
assert p.returncode != 0
|
|
36
|
+
assert not w.github().get("merges")
|
|
37
|
+
assert len(handoffs(w)) == 1
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_session_instruction_requires_the_lease_holder(tmp_path):
|
|
41
|
+
w = world(tmp_path)
|
|
42
|
+
assert w.run("acquire", "s2").returncode == 0
|
|
43
|
+
p = merge(w, tmp_path, "a1b2c3d", "--session", "s1", "--session-approved")
|
|
44
|
+
assert p.returncode != 0
|
|
45
|
+
assert not w.github().get("merges")
|
|
46
|
+
assert w.active_leases()[0][1] == "s2"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_session_instruction_still_hands_off_for_an_unresolved_review(tmp_path):
|
|
50
|
+
w = world(tmp_path, threads=[{"user": {"login": "alice"}, "resolved": False}])
|
|
51
|
+
p = merge(w, tmp_path, "a1b2c3d", *session(w))
|
|
52
|
+
assert p.returncode != 0
|
|
53
|
+
assert not w.github().get("merges")
|
|
54
|
+
assert "review comment from alice" in p.output
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_session_instruction_cannot_override_branch_protection(tmp_path):
|
|
58
|
+
w = world(tmp_path, merge_error="At least 1 approving review is required")
|
|
59
|
+
p = merge(w, tmp_path, "a1b2c3d", *session(w))
|
|
60
|
+
assert p.returncode != 0
|
|
61
|
+
assert not w.github().get("merges")
|
|
62
|
+
assert "merge blocked: approval required" in p.output
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_session_approval_without_a_session_is_invalid_input(tmp_path):
|
|
66
|
+
w = world(tmp_path)
|
|
67
|
+
before = w.github()
|
|
68
|
+
p = merge(w, tmp_path, "a1b2c3d", "--session-approved")
|
|
69
|
+
assert p.returncode != 0
|
|
70
|
+
assert "--session-approved needs --session" in p.output
|
|
71
|
+
assert w.github() == before
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@pytest.mark.parametrize("other", [("--approved-sha", "a1b2c3d"), ("--judge", "agree"), ("--judge-risk", "1")])
|
|
75
|
+
def test_session_approval_cannot_be_mixed_with_other_approval_paths(tmp_path, other):
|
|
76
|
+
w = world(tmp_path)
|
|
77
|
+
args = session(w)
|
|
78
|
+
before = w.github()
|
|
79
|
+
p = merge(w, tmp_path, "a1b2c3d", *args, *other)
|
|
80
|
+
assert p.returncode != 0
|
|
81
|
+
assert "cannot be combined" in p.output
|
|
82
|
+
assert w.github() == before
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-08T07:21:01.147Z",
|
|
4
4
|
"skills": [
|
|
5
5
|
{
|
|
6
6
|
"name": "agents-wayfinder",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"name": "babysit-pr",
|
|
13
|
-
"version": "0.1.
|
|
14
|
-
"hash": "sha256-
|
|
15
|
-
"description": "Babysit an open pull request until it is merged or handed to a human. Started by the PostToolUse hook after `gh pr create`, or by hand with `/babysit-pr
|
|
13
|
+
"version": "0.1.6",
|
|
14
|
+
"hash": "sha256-81e4eb55e555b5c56df6f90a83a300d79d859f294a2ebe8f00ed231bc21390c2",
|
|
15
|
+
"description": "Babysit an open pull request until it is merged or handed to a human. Started by the PostToolUse hook after `gh pr create`, or by hand with `/babysit-pr` and a PR URL."
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"name": "backlog",
|