@jesdi/skills 0.0.63 → 0.0.65
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/README.md +15 -0
- package/package.json +2 -2
- package/skills/babysit-pr/SKILL.md +54 -0
- package/skills/babysit-pr/babysit.py +998 -0
- package/skills/babysit-pr/fixtures/gh +310 -0
- package/skills/babysit-pr/hooks/post-pr-create.sh +56 -0
- package/skills/babysit-pr/hooks.json +10 -0
- package/skills/babysit-pr/judge-prompt.md +9 -0
- package/skills/babysit-pr/test_babysit.py +242 -0
- package/skills/babysit-pr/test_babysit_judge.py +286 -0
- package/skills/babysit-pr/test_babysit_judge_diff.py +25 -0
- package/skills/babysit-pr/test_babysit_judge_isolation.py +61 -0
- package/skills/babysit-pr/test_checks_regressions.py +210 -0
- package/skills/babysit-pr/test_comment_fidelity.py +88 -0
- package/skills/babysit-pr/test_comment_identity.py +70 -0
- package/skills/babysit-pr/test_e2e_setup.py +74 -0
- package/skills/babysit-pr/test_handoff_takeover.py +141 -0
- package/skills/babysit-pr/test_handoff_terminal.py +29 -0
- package/skills/babysit-pr/test_hook_quoting.py +25 -0
- package/skills/babysit-pr/test_hooks.py +62 -0
- package/skills/babysit-pr/test_lease_regressions.py +198 -0
- package/skills/babysit-pr/test_merge_and_handoff.py +260 -0
- package/skills/babysit-pr/test_merge_base_pin.py +10 -0
- package/skills/babysit-pr/test_merge_gate.py +124 -0
- package/skills/babysit-pr/test_merge_session_safety.py +117 -0
- package/skills/babysit-pr/test_merged_pr_labels.py +144 -0
- package/skills/babysit-pr/test_owner_comment_edits.py +26 -0
- package/skills/babysit-pr/test_owner_comments.py +316 -0
- package/skills/babysit-pr/test_retry_and_stall_hardening.py +143 -0
- package/skills/babysit-pr/test_rounds_and_checks.py +305 -0
- package/skills/babysit-pr/test_terminal_label_regressions.py +117 -0
- package/skills/babysit-pr/test_trusted_merge_risk.py +184 -0
- package/skills/babysit-pr/test_update_plan.py +157 -0
- package/skills/implement-spec/README.md +3 -3
- package/skills/implement-spec/SKILL.md +1 -1
- package/skills/implement-spec/driver.py +27 -4
- package/skills/implement-spec/driver_final.py +49 -10
- package/skills/implement-spec/prompts/overruled.md +3 -1
- package/skills/implement-spec/prompts/pr-writer.md +3 -2
- package/skills/implement-spec/tests/test_decisions.py +36 -2
- package/skills/implement-spec/tests/test_final.py +112 -1
- package/skills/implement-spec/tests/test_tidy.py +2 -2
- package/skills/implement-spec/tests/test_walk.py +2 -2
- package/skills/pr-risk/SKILL.md +33 -0
- package/skills/pr-risk/hooks/pre-pr-create.sh +274 -0
- package/skills/pr-risk/hooks.json +10 -0
- package/skills/pr-risk/merge_policy.py +81 -0
- package/skills/pr-risk/merge_risk.py +314 -0
- package/skills/pr-risk/test_hook_commands.py +47 -0
- package/skills/pr-risk/test_hook_heredoc.py +16 -0
- package/skills/pr-risk/test_hook_substitution.py +40 -0
- package/skills/pr-risk/test_hooks.py +175 -0
- package/skills/pr-risk/test_merge_risk.py +97 -0
- package/skills/pr-risk/test_merge_risk_gate.py +217 -0
- package/skills/pr-risk/test_merge_risk_regressions.py +37 -0
- package/skills/pr-risk/test_merge_risk_structure.py +101 -0
- package/skills-manifest.json +15 -3
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Structure and behavior-preservation tests for the merge_risk refactor (ticket 17).
|
|
2
|
+
|
|
3
|
+
Golden outputs were recorded from merge_risk.py before the refactor (commit 74ccb2c).
|
|
4
|
+
"""
|
|
5
|
+
import ast
|
|
6
|
+
import os
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
HERE = Path(__file__).resolve().parent
|
|
12
|
+
SCRIPT = HERE / "merge_risk.py"
|
|
13
|
+
BRANCHES = (ast.If, ast.For, ast.While, ast.ExceptHandler, ast.IfExp,
|
|
14
|
+
ast.comprehension)
|
|
15
|
+
|
|
16
|
+
CASES = {'valid': 'door: two-way\nblast_radius: isolated\ntouches: [docs, tests]\nrollback: revert\nverdict: auto\nreasons:\n - "Only prose"\n', 'inline': 'door: two-way\nblast_radius: isolated\ntouches: [docs, tests]\nrollback: revert\nverdict: auto\nreasons: [a, "b, c"]\n', 'bad': 'door: sideways\ntouches: [docs, styles, ]\nrollback: revert\nrollback: x\nfoo: 1\nreasons: nope\n junk\n', 'emptyreasons': 'door: two-way\nblast_radius: isolated\ntouches: [docs, tests]\nrollback: revert\nverdict: auto\nreasons:\n', 'badreasons': 'door: two-way\nblast_radius: isolated\ntouches: [docs, tests]\nrollback: revert\nverdict: auto\nreasons:\n - a: b\n - ""\n - [x]\n - \'q\'x\'\n'}
|
|
17
|
+
GOLDEN = {'valid:parse': [0, '{"door": "two-way", "blast_radius": "isolated", "rollback": "revert", "verdict": "auto", "touches": ["docs", "tests"], "reasons": ["Only prose"], "errors": []}\n'], 'valid:validate': [0, ''], 'inline:parse': [0, '{"door": "two-way", "blast_radius": "isolated", "rollback": "revert", "verdict": "auto", "touches": ["docs", "tests"], "reasons": ["a", "b, c"], "errors": []}\n'], 'inline:validate': [0, ''], 'bad:parse': [0, '{"door": "sideways", "blast_radius": null, "rollback": "revert", "verdict": null, "touches": ["docs", "styles", ""], "reasons": [], "errors": ["touches has an empty element", "duplicate key: rollback", "unknown key: foo", "reasons must be a `- item` list or an inline list", "unsupported line: junk", "missing key: blast_radius", "missing key: verdict", "door: \'sideways\' is not one of one-way | two-way", "unknown category: styles", "reasons must have at least one item"]}\n'], 'bad:validate': [1, "touches has an empty element\nduplicate key: rollback\nunknown key: foo\nreasons must be a `- item` list or an inline list\nunsupported line: junk\nmissing key: blast_radius\nmissing key: verdict\ndoor: 'sideways' is not one of one-way | two-way\nunknown category: styles\nreasons must have at least one item\n"], 'emptyreasons:parse': [0, '{"door": "two-way", "blast_radius": "isolated", "rollback": "revert", "verdict": "auto", "touches": ["docs", "tests"], "reasons": [], "errors": ["reasons must have at least one item"]}\n'], 'emptyreasons:validate': [1, 'reasons must have at least one item\n'], 'badreasons:parse': [0, '{"door": "two-way", "blast_radius": "isolated", "rollback": "revert", "verdict": "auto", "touches": ["docs", "tests"], "reasons": [], "errors": ["unsupported reason form: a: b", "empty reason", "unsupported reason form: [x]", "malformed quoted reason: \'q\'x\'", "reasons must have at least one item"]}\n'], 'badreasons:validate': [1, "unsupported reason form: a: b\nempty reason\nunsupported reason form: [x]\nmalformed quoted reason: 'q'x'\nreasons must have at least one item\n"]}
|
|
18
|
+
|
|
19
|
+
GATE_GOLDEN = '{"verdict": "human", "reasons": ["diff touches logic, not in touches", "agentMerge is off"], "categories": ["docs", "logic"], "countedLines": 1}\n'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def complexity(fn):
|
|
23
|
+
"""McCabe complexity of one function, nested functions counted separately."""
|
|
24
|
+
n, stack = 1, list(ast.iter_child_nodes(fn))
|
|
25
|
+
while stack:
|
|
26
|
+
node = stack.pop()
|
|
27
|
+
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)):
|
|
28
|
+
continue
|
|
29
|
+
n += isinstance(node, BRANCHES)
|
|
30
|
+
n += len(node.ifs) if isinstance(node, ast.comprehension) else 0
|
|
31
|
+
n += len(node.values) - 1 if isinstance(node, ast.BoolOp) else 0
|
|
32
|
+
stack.extend(ast.iter_child_nodes(node))
|
|
33
|
+
return n
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def functions(path):
|
|
37
|
+
tree = ast.parse(path.read_text())
|
|
38
|
+
return [n for n in ast.walk(tree) if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef))]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_no_function_is_more_complex_than_8():
|
|
42
|
+
too_complex = {f"{p.name}:{f.name}": complexity(f)
|
|
43
|
+
for p in (SCRIPT, HERE / "merge_policy.py") for f in functions(p)
|
|
44
|
+
if complexity(f) > 8}
|
|
45
|
+
assert too_complex == {}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_parse_block_is_gone_or_under_15_lines():
|
|
49
|
+
for f in functions(SCRIPT):
|
|
50
|
+
if f.name == "parse_block":
|
|
51
|
+
assert f.end_lineno - f.lineno + 1 < 15
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_policy_lives_in_merge_policy_and_merge_risk_still_exposes_it():
|
|
55
|
+
code = ("import merge_risk, merge_policy;"
|
|
56
|
+
"[getattr(merge_risk, n) for n in "
|
|
57
|
+
"('git','load_policy','DEFAULT_PATHS','POLICY_FILE','file_categories')];"
|
|
58
|
+
"assert merge_risk.load_policy is merge_policy.load_policy;"
|
|
59
|
+
"assert merge_policy.POLICY_FILE and merge_policy.LOCKFILES and merge_policy.DEFAULT_POLICY")
|
|
60
|
+
proc = subprocess.run([sys.executable, "-c", code], cwd=HERE, capture_output=True, text=True)
|
|
61
|
+
assert proc.returncode == 0, proc.stderr
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_parse_and_validate_output_is_byte_identical_to_before_the_refactor(tmp_path):
|
|
65
|
+
for key, (code, out) in GOLDEN.items():
|
|
66
|
+
name, cmd = key.split(":")
|
|
67
|
+
f = tmp_path / "body.md"
|
|
68
|
+
f.write_text("x\n```merge-risk v1\n" + CASES[name] + "```\n")
|
|
69
|
+
proc = subprocess.run([sys.executable, str(SCRIPT), cmd, str(f)],
|
|
70
|
+
capture_output=True, text=True, cwd=tmp_path)
|
|
71
|
+
assert (proc.returncode, proc.stdout) == (code, out), key
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_gate_output_is_byte_identical_to_before_the_refactor(tmp_path):
|
|
75
|
+
env = {**os.environ, "GIT_AUTHOR_NAME": "t", "GIT_AUTHOR_EMAIL": "t@t",
|
|
76
|
+
"GIT_COMMITTER_NAME": "t", "GIT_COMMITTER_EMAIL": "t@t",
|
|
77
|
+
"GIT_CONFIG_GLOBAL": os.devnull, "GIT_CONFIG_SYSTEM": os.devnull}
|
|
78
|
+
repo = tmp_path / "repo"
|
|
79
|
+
repo.mkdir()
|
|
80
|
+
|
|
81
|
+
def git(*args):
|
|
82
|
+
return subprocess.run(["git", *args], cwd=repo, env=env, text=True,
|
|
83
|
+
capture_output=True, check=True).stdout.strip()
|
|
84
|
+
|
|
85
|
+
git("init", "-q", "-b", "work")
|
|
86
|
+
(repo / "README.md").write_text("hi\n")
|
|
87
|
+
git("add", "-A")
|
|
88
|
+
git("commit", "-qm", "base")
|
|
89
|
+
git("update-ref", "refs/remotes/origin/main", git("rev-parse", "HEAD"))
|
|
90
|
+
(repo / "src").mkdir()
|
|
91
|
+
(repo / "src" / "a.py").write_text("x = 1\n")
|
|
92
|
+
(repo / "docs.md").write_text("doc\n")
|
|
93
|
+
git("add", "-A")
|
|
94
|
+
git("commit", "-qm", "head")
|
|
95
|
+
body = tmp_path / "body.md"
|
|
96
|
+
body.write_text("x\n```merge-risk v1\n" + CASES["valid"] + "```\n")
|
|
97
|
+
proc = subprocess.run([sys.executable, str(SCRIPT), "gate", "--body", str(body),
|
|
98
|
+
"--base", "main", "--head", git("rev-parse", "HEAD")],
|
|
99
|
+
capture_output=True, text=True, cwd=repo, env=env)
|
|
100
|
+
assert proc.returncode == 0, proc.stderr
|
|
101
|
+
assert proc.stdout == GATE_GOLDEN
|
package/skills-manifest.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-10-
|
|
3
|
+
"generatedAt": "2026-10-23T16:52:23.003Z",
|
|
4
4
|
"skills": [
|
|
5
|
+
{
|
|
6
|
+
"name": "babysit-pr",
|
|
7
|
+
"version": "0.1.1",
|
|
8
|
+
"hash": "sha256-bf09318dcaf40422f9c2433698b4f1c6f8e10b8893f84b1e81ee9f04f7d6cad9",
|
|
9
|
+
"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 <pr-url>`."
|
|
10
|
+
},
|
|
5
11
|
{
|
|
6
12
|
"name": "backlog",
|
|
7
13
|
"version": "0.1.8",
|
|
@@ -46,10 +52,16 @@
|
|
|
46
52
|
},
|
|
47
53
|
{
|
|
48
54
|
"name": "implement-spec",
|
|
49
|
-
"version": "0.1.
|
|
50
|
-
"hash": "sha256-
|
|
55
|
+
"version": "0.1.40",
|
|
56
|
+
"hash": "sha256-b55e19f156025a0a30d2a6ba6a28eb66c0d890163a29b3a813e49c3eb8be7ca4",
|
|
51
57
|
"description": "Implement a specification in code."
|
|
52
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"name": "pr-risk",
|
|
61
|
+
"version": "0.1.0",
|
|
62
|
+
"hash": "sha256-54b54a42738571c346a040326cde2d314d0239dca3ce42323d2b8434dbe9d5f9",
|
|
63
|
+
"description": "Merge-risk block of a PR body. Use when a PR body needs its ```merge-risk v1 block parsed or validated, with every error named."
|
|
64
|
+
},
|
|
53
65
|
{
|
|
54
66
|
"name": "pr-visual-diff",
|
|
55
67
|
"version": "0.1.2",
|