@jesdi/skills 0.0.89 → 0.0.91
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 +1 -1
- package/skills/babysit-pr/babysit.py +9 -7
- package/skills/babysit-pr/test_owner_comment_edits.py +29 -0
- package/skills/implement-spec/WORKTREES.md +13 -0
- package/skills/implement-spec/driver.py +20 -5
- package/skills/implement-spec/driver_run.py +1 -0
- package/skills/implement-spec/driver_slots.py +31 -10
- package/skills/implement-spec/prompts/workspace.md +2 -0
- package/skills/implement-spec/tests/test_agents.py +1 -1
- package/skills/implement-spec/tests/test_driver.py +60 -2
- package/skills/implement-spec/tests/test_slots.py +87 -1
- package/skills/implement-spec/tests/test_walk.py +6 -2
- package/skills-manifest.json +5 -5
package/package.json
CHANGED
|
@@ -124,7 +124,8 @@ class CommentIdentities:
|
|
|
124
124
|
return path.read_text() if path.exists() else None
|
|
125
125
|
|
|
126
126
|
def remember(self, cid, body):
|
|
127
|
-
kind = "lease" if LEASE.match(body) else "handoff" if HANDOFF.match(body)
|
|
127
|
+
kind = ("lease" if LEASE.match(body) else "handoff" if HANDOFF.match(body)
|
|
128
|
+
else "seen" if body.startswith(SEEN) else None)
|
|
128
129
|
if kind:
|
|
129
130
|
self.root.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
130
131
|
try:
|
|
@@ -556,13 +557,14 @@ def owner_comments(repo, number):
|
|
|
556
557
|
author = login_of(c)
|
|
557
558
|
editor = (c.get("editor") or {}).get("login")
|
|
558
559
|
kind = kinds[c["databaseId"]]
|
|
559
|
-
if author == owner and kind
|
|
560
|
-
continue # creation receipt
|
|
560
|
+
if author == owner and kind in ("lease", "seen"):
|
|
561
|
+
continue # creation receipt of the babysitter's own state, independent of its current body
|
|
561
562
|
if author == owner and not c["body"].startswith(MENTION):
|
|
562
|
-
# An unknown edited lease may be a handoff with its heading
|
|
563
|
-
# Without a receipt it is safe to ignore only if no earlier instruction
|
|
564
|
-
# could be replayed. This also supports
|
|
565
|
-
|
|
563
|
+
# An unknown edited lease or seen comment may be a handoff with its heading
|
|
564
|
+
# removed. Without a receipt it is safe to ignore only if no earlier instruction
|
|
565
|
+
# could be replayed. This also supports state comments from another host.
|
|
566
|
+
own_state = LEASE.match(c["body"]) or c["body"].startswith(SEEN)
|
|
567
|
+
if c.get("lastEditedAt") and (kind == "handoff" or not own_state
|
|
566
568
|
or editor != owner or instructions):
|
|
567
569
|
handoff = handoff or "handoff comment edited, boundary unverifiable"
|
|
568
570
|
continue # the babysitter's own lease comments and the owner's plain chatter
|
|
@@ -24,3 +24,32 @@ def test_removing_handoff_heading_does_not_reactivate_approval(tmp_path, editor)
|
|
|
24
24
|
out = read(w)
|
|
25
25
|
assert out["handoff"] == "handoff comment edited, boundary unverifiable"
|
|
26
26
|
assert out["instructions"] == []
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
SEEN_BODY = '<!-- babysit-pr seen -->\n{"a1b2c3d#ci": "2026-01-01T00:00:00Z"}'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_the_babysitters_edited_seen_comment_does_not_block_an_approval(tmp_path):
|
|
33
|
+
"""`checks` edits its own seen comment on every run; that edit is no forged handoff."""
|
|
34
|
+
w = World(tmp_path, comments=[
|
|
35
|
+
comment(1001, "jesdi", SEEN_BODY, at=T - 20 * MIN, editor="jesdi"),
|
|
36
|
+
comment(1002, "jesdi", "@babysitter merge a1b2c3d", at=T - 10 * MIN)])
|
|
37
|
+
state = w.github()
|
|
38
|
+
state["commits"] = [{"sha": "a1b2c3d", "date": iso(T - 30 * MIN)}]
|
|
39
|
+
w.state.write_text(json.dumps(state))
|
|
40
|
+
out = read(w)
|
|
41
|
+
assert out["handoff"] is None
|
|
42
|
+
assert [i["text"] for i in out["instructions"]] == ["@babysitter merge a1b2c3d"]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_a_handoff_edited_to_look_like_a_seen_comment_is_still_flagged(tmp_path):
|
|
46
|
+
w = World(tmp_path, comments=[
|
|
47
|
+
comment(1001, "jesdi", "@babysitter merge a1b2c3d", at=T - 20 * MIN),
|
|
48
|
+
comment(1002, "jesdi", HANDOFF_BODY, at=T - 10 * MIN)])
|
|
49
|
+
state = w.github()
|
|
50
|
+
state["commits"] = [{"sha": "a1b2c3d", "date": iso(T - 30 * MIN)}]
|
|
51
|
+
w.state.write_text(json.dumps(state))
|
|
52
|
+
assert read(w) == {"handoff": None, "instructions": []} # records the handoff's receipt
|
|
53
|
+
state["comments"][1] = comment(1002, "jesdi", SEEN_BODY, at=T - 10 * MIN, editor="jesdi")
|
|
54
|
+
w.state.write_text(json.dumps(state))
|
|
55
|
+
assert read(w)["handoff"] == "handoff comment edited, boundary unverifiable"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Worktree lifecycle
|
|
2
|
+
|
|
3
|
+
The driver owns a bounded pool of ticket checkouts. Slot 1 is the existing PR checkout; additional slots live at `.agent/worktrees/slot-N`, up to `--parallel`. The scheduler creates an additional slot only when a ready ticket first needs it. A serial dependency chain uses slot 1 alone, and a completed resume creates no slots.
|
|
4
|
+
|
|
5
|
+
Before scheduling, the driver validates existing slots. A slot must be a healthy checkout of this repository at the assigned path. Clean slots are detached for reuse; interrupted work stays in its recorded slot. A foreign checkout or a Git failure stops reuse rather than being treated as an empty status result.
|
|
6
|
+
|
|
7
|
+
New slots start at a captured PR tip. Slot 1 may already be on an unmerged ticket commit, so its current HEAD is not the preparation baseline. `--prepare` runs once per new slot; later tickets and fix rounds reuse that checkout and its installed dependencies.
|
|
8
|
+
|
|
9
|
+
A missing slot is recreated with one `git worktree add --force --detach` targeting its path and the captured tip. Git refuses a locked registration. The driver never runs `git worktree prune`: a session can see shared repository metadata while another active task's checkout is outside its mounts.
|
|
10
|
+
|
|
11
|
+
If preparation fails during scheduling, the driver starts no further tickets. Already running tickets finish and retain their progress. The failed slot is removed, a clean slot 1 returns to the PR branch, and the driver exits 3 with the preparation error. Fix the preparation command and rerun the same invocation to resume; the ticket whose slot failed remains pending.
|
|
12
|
+
|
|
13
|
+
Role agents reuse their assigned checkout. Read-only reviewers first consult existing gate evidence and create a temporary checkout only for a specific isolated check that the evidence cannot answer.
|
|
@@ -323,15 +323,27 @@ def _take_slot(number: str, kept: dict, free: list[int]) -> int:
|
|
|
323
323
|
return slot
|
|
324
324
|
|
|
325
325
|
|
|
326
|
+
def _prepare_slot(number: int, prepared: set[int], run: Run) -> None:
|
|
327
|
+
"""Create a worker checkout only when first assigned; keep its dependencies for later tickets."""
|
|
328
|
+
if number in prepared:
|
|
329
|
+
return
|
|
330
|
+
if error := driver_slots.create(number, run.args.prepare, number in run.kept.values(), start=run.tip()):
|
|
331
|
+
raise driver_slots.PreparationError(error)
|
|
332
|
+
prepared.add(number)
|
|
333
|
+
|
|
334
|
+
|
|
326
335
|
def _walk(tickets: list[Ticket], slots: int, run: Run, pool: ThreadPoolExecutor) -> None:
|
|
327
336
|
"""Start each ready ticket in the lowest free slot, and look again each time a ticket ends."""
|
|
328
337
|
kept, told = dict(run.kept), set() # a kept slot waits for its ticket
|
|
329
338
|
free = [slot for slot in range(1, slots + 1) if slot not in kept.values()]
|
|
330
339
|
running: dict = {} # future -> (ticket number, slot number)
|
|
340
|
+
prepared = {1} | {number for number in range(2, slots + 1)
|
|
341
|
+
if Path(driver_slots.path(number), ".git").exists()}
|
|
331
342
|
|
|
332
343
|
def start_ready() -> None:
|
|
333
344
|
while (ticket := _next_ticket(tickets, running, told, run, kept)) and (ticket.number in kept or free):
|
|
334
345
|
slot = _take_slot(ticket.number, kept, free)
|
|
346
|
+
_prepare_slot(slot, prepared, run)
|
|
335
347
|
running[pool.submit(_run_ticket, ticket, slot, run)] = (ticket.number, slot)
|
|
336
348
|
|
|
337
349
|
while True:
|
|
@@ -401,11 +413,11 @@ def _resume_error(number: str, state: driver_state.State) -> str:
|
|
|
401
413
|
|
|
402
414
|
|
|
403
415
|
def _resume(tickets: list[Ticket], state: driver_state.State, pr: str, slots: int, args, kept: dict) -> list[str]:
|
|
404
|
-
"""Start or resume state.json on the PR branch `pr` and
|
|
416
|
+
"""Start or resume state.json on the PR branch `pr` and check existing slots: the errors that stop the run."""
|
|
405
417
|
state.start(pr, [ticket.number for ticket in tickets])
|
|
406
418
|
driver_final.finish_interrupted_move(state, pr)
|
|
407
419
|
errors = [error for error in (_resume_error(ticket.number, state) for ticket in tickets) if error]
|
|
408
|
-
return errors or driver_slots.setup(slots, args.prepare, set(kept.values()))
|
|
420
|
+
return errors or driver_slots.setup(slots, args.prepare, set(kept.values()), existing_only=True)
|
|
409
421
|
|
|
410
422
|
|
|
411
423
|
def _publish_questions(run: dict) -> str:
|
|
@@ -509,15 +521,18 @@ def _run(tickets: list[Ticket], models: dict[str, list[str]], skipped: list[str]
|
|
|
509
521
|
slots = 1 if args.only else min(args.parallel, len(tickets))
|
|
510
522
|
errors = _resume(tickets, state, pr, slots, args, kept)
|
|
511
523
|
errors = errors or _apply_answers(state, args)
|
|
512
|
-
for error in errors:
|
|
513
|
-
print(error)
|
|
514
524
|
if errors:
|
|
525
|
+
print("\n".join(errors))
|
|
515
526
|
return 3
|
|
516
527
|
run = Run(args, models, state, pr, kept)
|
|
517
528
|
_record_skipped(skipped)
|
|
518
529
|
if args.unattended and args.stage_json:
|
|
519
530
|
Path(args.stage_json).unlink(missing_ok=True) # the file tells how this run ends, never an earlier one
|
|
520
|
-
|
|
531
|
+
try:
|
|
532
|
+
end_blocked, lines = _work(tickets, slots, run)
|
|
533
|
+
except driver_slots.PreparationError as error:
|
|
534
|
+
print(f"implement-spec: {error}; fix slot preparation and run the same command to resume")
|
|
535
|
+
return 3
|
|
521
536
|
final = state.read()
|
|
522
537
|
summary = driver_summary.render(final)
|
|
523
538
|
(OUT / "summary.md").write_text(summary)
|
|
@@ -336,6 +336,7 @@ def _files(folder: Path, role: str, fix_round: int, name: str) -> tuple[Path, Pa
|
|
|
336
336
|
def _first_prompt(template: str, values: dict[str, str], notes: tuple | list, report: str) -> str:
|
|
337
337
|
"""The template of the role, then the lines of each `notes` template and the ending of the prompt again."""
|
|
338
338
|
text = driver_agents.render(template, {**values, "report": report})
|
|
339
|
+
text = text.replace("\n\n", "\n\n" + driver_agents.render("workspace", {}), 1)
|
|
339
340
|
if notes:
|
|
340
341
|
text += "".join(driver_agents.render(note, values) for note in notes) + driver_agents.tail(text, report)
|
|
341
342
|
return text
|
|
@@ -8,6 +8,10 @@ import subprocess
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
class PreparationError(RuntimeError):
|
|
12
|
+
"""A requested slot could not be prepared; already running tickets may finish."""
|
|
13
|
+
|
|
14
|
+
|
|
11
15
|
def git(slot: str, *args: str) -> subprocess.CompletedProcess[str]:
|
|
12
16
|
# core.quotePath off: git prints a path with a non-ASCII name as it is, so it equals the path that a report names.
|
|
13
17
|
return subprocess.run(["git", "-C", slot, "-c", "core.quotePath=false", *args], capture_output=True, text=True)
|
|
@@ -39,15 +43,29 @@ def path(number: int) -> str:
|
|
|
39
43
|
return "." if number == 1 else f".agent/worktrees/slot-{number}"
|
|
40
44
|
|
|
41
45
|
|
|
42
|
-
def
|
|
46
|
+
def _owned_checkout(slot: str) -> bool:
|
|
47
|
+
"""An existing slot must be this repository's checkout at exactly the assigned path."""
|
|
48
|
+
common = git(slot, "rev-parse", "--path-format=absolute", "--git-common-dir")
|
|
49
|
+
root = git(slot, "rev-parse", "--show-toplevel")
|
|
50
|
+
expected = git(".", "rev-parse", "--path-format=absolute", "--git-common-dir")
|
|
51
|
+
return (common.returncode == root.returncode == expected.returncode == 0
|
|
52
|
+
and common.stdout == expected.stdout
|
|
53
|
+
and Path(root.stdout.strip()).resolve() == Path(slot).absolute()
|
|
54
|
+
and not Path(slot).is_symlink())
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def create(number: int, prepare: str | None, keep: bool = False, *, start: str = "HEAD") -> str:
|
|
43
58
|
"""Make and prepare slot 2..N once, or reuse it off any branch (`keep`: as it is). Returns "" or the error."""
|
|
44
59
|
slot = path(number)
|
|
45
|
-
git(".", "worktree", "prune") # a slot directory that was removed by hand
|
|
46
60
|
if Path(slot, ".git").exists():
|
|
61
|
+
if not _owned_checkout(slot):
|
|
62
|
+
return f"slot {number}: {slot} is not a healthy checkout of this repository; inspect it before retrying"
|
|
47
63
|
if not (keep or release(slot)):
|
|
48
|
-
return f"slot {number}: {slot}
|
|
64
|
+
return f"slot {number}: {slot} could not be released: inspect its Git state and uncommitted changes"
|
|
49
65
|
return ""
|
|
50
|
-
|
|
66
|
+
# One force recovers this missing slot registration only; a locked registration still fails.
|
|
67
|
+
# Never prune: another session may mount the shared metadata without its sibling checkouts.
|
|
68
|
+
added = git(".", "worktree", "add", "-q", "--force", "--detach", slot, start)
|
|
51
69
|
if added.returncode:
|
|
52
70
|
return f"slot {number}: cannot create {slot}: {added.stderr.strip()}"
|
|
53
71
|
if not prepare:
|
|
@@ -61,17 +79,20 @@ def create(number: int, prepare: str | None, keep: bool = False) -> str:
|
|
|
61
79
|
return ""
|
|
62
80
|
|
|
63
81
|
|
|
64
|
-
def setup(count: int, prepare: str | None, keep: set[int] = frozenset()
|
|
65
|
-
|
|
82
|
+
def setup(count: int, prepare: str | None, keep: set[int] = frozenset(),
|
|
83
|
+
*, existing_only: bool = False) -> list[str]:
|
|
84
|
+
"""Check slots before agents; existing_only defers absent slots until their first assignment."""
|
|
66
85
|
for number in range(2, count + 1):
|
|
86
|
+
if existing_only and not Path(path(number), ".git").exists():
|
|
87
|
+
continue
|
|
67
88
|
if error := create(number, prepare, number in keep):
|
|
68
89
|
return [error]
|
|
69
90
|
return []
|
|
70
91
|
|
|
71
92
|
|
|
72
93
|
def release(slot: str) -> bool:
|
|
73
|
-
"""Take a clean slot off its branch. False: the slot has uncommitted work, which stays where it is."""
|
|
74
|
-
|
|
94
|
+
"""Take a clean slot off its branch. False: Git failed or the slot has uncommitted work, which stays where it is."""
|
|
95
|
+
status = git(slot, "status", "--porcelain")
|
|
96
|
+
if status.returncode or status.stdout.strip():
|
|
75
97
|
return False
|
|
76
|
-
git(slot, "checkout", "-q", "--detach")
|
|
77
|
-
return True
|
|
98
|
+
return git(slot, "checkout", "-q", "--detach").returncode == 0
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
The driver has already assigned your working checkout. Reuse it for this role and every fix attempt; it satisfies the requirement to work in a worktree. Do not create another worktree for a ticket or fix. Only a read-only review whose instructions explicitly permit an isolated check may create a temporary checkout; read the existing gate evidence first and create a copy only when that evidence cannot answer a specific finding. Never run `git worktree prune`: the shared repository can contain live checkouts that this session cannot see.
|
|
2
|
+
|
|
@@ -270,7 +270,7 @@ def test_implementer_prompt_carries_pointers_and_only_template_sentences(env):
|
|
|
270
270
|
for pointer in ("specs/csv/spec.md", ".agent/tickets/01-export-rows.md", "`export_csv()`", sha,
|
|
271
271
|
"tests/test_export.py", report):
|
|
272
272
|
assert pointer in prompt, pointer
|
|
273
|
-
template = (SKILL / "prompts/implementer.md").read_text()
|
|
273
|
+
template = (SKILL / "prompts/implementer.md").read_text() + (SKILL / "prompts/workspace.md").read_text()
|
|
274
274
|
for prefix in (str(w.repo.resolve()) + "/", str(w.repo) + "/"):
|
|
275
275
|
prompt = prompt.replace(prefix, "")
|
|
276
276
|
for value in (report, "specs/csv/spec.md", ".agent/tickets/01-export-rows.md", "`export_csv()`", sha,
|
|
@@ -240,6 +240,7 @@ def test_a_rerun_prompt_holds_only_template_lines_and_keeps_its_ending(repo, tmp
|
|
|
240
240
|
ending = first[first.index("\nWrite one JSON report"):]
|
|
241
241
|
line = (driver_report.PROMPTS / "timeout.md").read_text().replace("{minutes}", "0.005")
|
|
242
242
|
assert "timed out" in line and "in the tree" in line
|
|
243
|
+
first = first.replace("\n\n", "\n\n" + driver_agents.render("workspace", {}), 1)
|
|
243
244
|
assert prompt == first + line + ending
|
|
244
245
|
|
|
245
246
|
|
|
@@ -509,10 +510,15 @@ def test_a_tree_that_is_not_clean_is_a_red_gate_and_the_slot_keeps_the_work(repo
|
|
|
509
510
|
|
|
510
511
|
def test_a_failing_prepare_stops_the_run_and_removes_the_slot(repo, tmp_path, capsys):
|
|
511
512
|
two(repo)
|
|
512
|
-
code,
|
|
513
|
-
assert
|
|
513
|
+
code, _, out = walk(tmp_path, capsys, WORK + REPORT, "--prepare", "echo no-deps >&2; false")
|
|
514
|
+
assert code == 3
|
|
514
515
|
assert "slot 2: --prepare `echo no-deps >&2; false` exited 1 in .agent/worktrees/slot-2: no-deps" in out
|
|
515
516
|
assert not (tmp_path / ".agent/worktrees/slot-2").exists() and branches() == ["feat/x"]
|
|
517
|
+
assert state_of(tmp_path)["tickets"]["01"]["phase"] == "merged" # already running work finishes
|
|
518
|
+
assert state_of(tmp_path)["tickets"]["02"]["phase"] == "pending"
|
|
519
|
+
assert all(line.startswith("01 ") for line in Path(f"{tmp_path}-runner.calls").read_text().splitlines())
|
|
520
|
+
assert out_of("git", "symbolic-ref", "--short", "HEAD") == "feat/x"
|
|
521
|
+
assert walk(tmp_path, capsys, WORK + REPORT)[0] == 0 # same state resumes safely
|
|
516
522
|
|
|
517
523
|
|
|
518
524
|
def test_a_touches_overlap_holds_the_second_ticket_and_the_ledger_says_why(repo, tmp_path, capsys):
|
|
@@ -1004,3 +1010,55 @@ def test_last_words_takes_the_result_of_a_stream_json_line(tmp_path):
|
|
|
1004
1010
|
log.write_text("ERROR: plain\n")
|
|
1005
1011
|
assert driver_agents.last_words(log) == "ERROR: plain"
|
|
1006
1012
|
assert driver_agents.last_words(tmp_path / "none.log") == "no output"
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
def test_a_serial_chain_uses_only_the_existing_checkout(repo, tmp_path, capsys):
|
|
1016
|
+
two(repo, second="01")
|
|
1017
|
+
log = tmp_path.parent / f"{tmp_path.name}-prepare.log"
|
|
1018
|
+
code, _, out = walk(tmp_path, capsys, WORK + REPORT, "--prepare", f"pwd >> {log}")
|
|
1019
|
+
assert code == 0, out
|
|
1020
|
+
assert not log.exists()
|
|
1021
|
+
assert not (tmp_path / '.agent/worktrees/slot-2').exists()
|
|
1022
|
+
calls = Path(f"{tmp_path}-runner.calls").read_text().splitlines()
|
|
1023
|
+
assert {line.split()[1] for line in calls} == {str(tmp_path.resolve())}
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
def test_a_completed_resume_does_not_recreate_unused_slots(repo, tmp_path, capsys):
|
|
1027
|
+
two(repo)
|
|
1028
|
+
log = tmp_path.parent / f"{tmp_path.name}-prepare.log"
|
|
1029
|
+
assert walk(tmp_path, capsys, WORK + TOGETHER + REPORT, "--prepare", f"pwd >> {log}")[0] == 0
|
|
1030
|
+
subprocess.run(['git', 'worktree', 'remove', '.agent/worktrees/slot-2'], check=True)
|
|
1031
|
+
code, _, out = walk(tmp_path, capsys, 'exit 9\n', '--prepare', f'pwd >> {log}')
|
|
1032
|
+
assert code == 0, out
|
|
1033
|
+
assert len(log.read_text().splitlines()) == 1
|
|
1034
|
+
assert not (tmp_path / '.agent/worktrees/slot-2').exists()
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
def test_lazy_preparation_uses_the_pr_tip_not_a_running_tickets_commit(repo, tmp_path):
|
|
1038
|
+
from types import SimpleNamespace
|
|
1039
|
+
repo()
|
|
1040
|
+
pr_tip = out_of('git', 'rev-parse', 'HEAD')
|
|
1041
|
+
subprocess.run(['git', 'checkout', '-qb', 'ticket/running'], check=True)
|
|
1042
|
+
(tmp_path / 'running-ticket-dependency').write_text('not merged\n')
|
|
1043
|
+
subprocess.run(['git', 'add', 'running-ticket-dependency'], check=True)
|
|
1044
|
+
subprocess.run(['git', 'commit', '-qm', 'running ticket'], check=True)
|
|
1045
|
+
run = SimpleNamespace(args=SimpleNamespace(prepare='test ! -e running-ticket-dependency'), kept={},
|
|
1046
|
+
tip=lambda: pr_tip)
|
|
1047
|
+
driver._prepare_slot(2, {1}, run)
|
|
1048
|
+
assert out_of('git', '-C', '.agent/worktrees/slot-2', 'rev-parse', 'HEAD') == pr_tip
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
def test_resume_reports_all_saved_state_errors_without_starting_an_agent(repo, tmp_path, capsys):
|
|
1052
|
+
two(repo)
|
|
1053
|
+
state = driver_state.State(tmp_path / '.agent/implement/state.json')
|
|
1054
|
+
state.start('feat/x', ['01', '02'])
|
|
1055
|
+
state.ticket('01', phase='polish')
|
|
1056
|
+
state.ticket('02', phase='ship')
|
|
1057
|
+
started = tmp_path.parent / f'{tmp_path.name}-agent-started'
|
|
1058
|
+
code, _, out = walk(tmp_path, capsys, f'touch {started}; exit 9\n')
|
|
1059
|
+
assert code == 3 and not started.exists()
|
|
1060
|
+
errors = [line for line in out.splitlines() if 'unknown phase' in line]
|
|
1061
|
+
assert errors == [
|
|
1062
|
+
".agent/implement/state.json: ticket 01 has the unknown phase 'polish'",
|
|
1063
|
+
".agent/implement/state.json: ticket 02 has the unknown phase 'ship'",
|
|
1064
|
+
]
|
|
@@ -20,7 +20,7 @@ def test_a_slot_with_uncommitted_work_stops_the_run_and_keeps_the_work(repo, tmp
|
|
|
20
20
|
assert driver_slots.setup(2, None) == []
|
|
21
21
|
(tmp_path / ".agent/worktrees/slot-2/wip.txt").write_text("half done\n")
|
|
22
22
|
assert driver_slots.setup(3, None) == [
|
|
23
|
-
"slot 2: .agent/worktrees/slot-2
|
|
23
|
+
"slot 2: .agent/worktrees/slot-2 could not be released: inspect its Git state and uncommitted changes"]
|
|
24
24
|
assert (tmp_path / ".agent/worktrees/slot-2/wip.txt").exists() and not (tmp_path / ".agent/worktrees/slot-3").exists()
|
|
25
25
|
|
|
26
26
|
|
|
@@ -30,3 +30,89 @@ def test_a_slot_that_cannot_be_created_is_an_error(repo, tmp_path):
|
|
|
30
30
|
(tmp_path / ".agent/worktrees/slot-2").write_text("a file is in the way\n")
|
|
31
31
|
(error,) = driver_slots.setup(2, None)
|
|
32
32
|
assert error.startswith("slot 2: cannot create .agent/worktrees/slot-2: ")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_preparing_a_slot_does_not_prune_another_tasks_invisible_checkout(repo, tmp_path):
|
|
36
|
+
repo()
|
|
37
|
+
other = tmp_path.parent / f"{tmp_path.name}-other"
|
|
38
|
+
subprocess.run(["git", "worktree", "add", "-q", "--detach", str(other)], check=True)
|
|
39
|
+
hidden = other.with_name(other.name + "-hidden")
|
|
40
|
+
other.rename(hidden) # as in a session whose mounts hide the other task's checkout
|
|
41
|
+
try:
|
|
42
|
+
assert driver_slots.setup(2, None) == []
|
|
43
|
+
finally:
|
|
44
|
+
hidden.rename(other)
|
|
45
|
+
result = subprocess.run(["git", "-C", str(other), "status", "--porcelain"], capture_output=True, text=True)
|
|
46
|
+
assert result.returncode == 0, result.stderr
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_only_a_missing_slots_registration_is_recovered(repo, tmp_path):
|
|
50
|
+
import shutil
|
|
51
|
+
repo()
|
|
52
|
+
log = tmp_path.parent / f"{tmp_path.name}-prepare.log"
|
|
53
|
+
assert driver_slots.setup(2, f"pwd >> {log}") == []
|
|
54
|
+
shutil.rmtree(tmp_path / driver_slots.path(2))
|
|
55
|
+
assert driver_slots.setup(2, f"pwd >> {log}") == []
|
|
56
|
+
assert driver_slots.git(driver_slots.path(2), "status", "--porcelain").returncode == 0
|
|
57
|
+
assert len(log.read_text().splitlines()) == 2
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_a_missing_locked_slot_is_not_recreated(repo, tmp_path):
|
|
61
|
+
import shutil
|
|
62
|
+
repo()
|
|
63
|
+
assert driver_slots.setup(2, None) == []
|
|
64
|
+
slot = driver_slots.path(2)
|
|
65
|
+
subprocess.run(["git", "worktree", "lock", slot], check=True)
|
|
66
|
+
shutil.rmtree(tmp_path / slot)
|
|
67
|
+
assert driver_slots.setup(2, None)
|
|
68
|
+
assert not (tmp_path / slot).exists()
|
|
69
|
+
assert "locked" in driver_slots.git(".", "worktree", "list", "--porcelain").stdout
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_releasing_a_broken_checkout_fails_without_reporting_it_reusable(repo, tmp_path):
|
|
73
|
+
repo()
|
|
74
|
+
assert driver_slots.setup(2, None) == []
|
|
75
|
+
slot = tmp_path / driver_slots.path(2)
|
|
76
|
+
(slot / '.git').write_text('gitdir: /missing/diagnosis-metadata\n')
|
|
77
|
+
assert not driver_slots.release(str(slot))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_slot_reuse_preserves_installed_dependencies_and_worktree_identity(repo, tmp_path):
|
|
81
|
+
repo()
|
|
82
|
+
log = tmp_path.parent / f"{tmp_path.name}-prepare.log"
|
|
83
|
+
prepare = f"mkdir -p .agent/dependencies; pwd >> {log}"
|
|
84
|
+
assert driver_slots.setup(3, prepare) == []
|
|
85
|
+
slot = driver_slots.path(2)
|
|
86
|
+
metadata = (tmp_path / slot / '.git').read_text()
|
|
87
|
+
dependencies = tmp_path / slot / '.agent/dependencies'
|
|
88
|
+
inode = dependencies.stat().st_ino
|
|
89
|
+
for ticket in ('ticket/01', 'ticket/02', 'ticket/03'):
|
|
90
|
+
subprocess.run(['git', '-C', slot, 'checkout', '-qb', ticket], check=True)
|
|
91
|
+
assert driver_slots.release(slot)
|
|
92
|
+
assert driver_slots.setup(3, prepare) == []
|
|
93
|
+
assert len(log.read_text().splitlines()) == 2
|
|
94
|
+
assert (tmp_path / slot / '.git').read_text() == metadata
|
|
95
|
+
assert dependencies.stat().st_ino == inode
|
|
96
|
+
assert len(driver_slots.git('.', 'worktree', 'list', '--porcelain').stdout.split('worktree ')) - 1 == 3
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_a_foreign_repository_in_a_slot_is_left_untouched_even_when_kept(repo, tmp_path):
|
|
100
|
+
repo()
|
|
101
|
+
slot = tmp_path / driver_slots.path(2)
|
|
102
|
+
slot.mkdir(parents=True)
|
|
103
|
+
subprocess.run(['git', 'init', '-q', '-b', 'foreign', str(slot)], check=True)
|
|
104
|
+
subprocess.run(['git', '-C', str(slot), 'commit', '--allow-empty', '-qm', 'foreign'], check=True)
|
|
105
|
+
assert driver_slots.setup(2, None, {2})
|
|
106
|
+
assert driver_slots.on_branch(str(slot)) == 'foreign'
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_a_locked_index_does_not_report_a_slot_released(repo, tmp_path):
|
|
110
|
+
repo()
|
|
111
|
+
assert driver_slots.setup(2, None) == []
|
|
112
|
+
slot = driver_slots.path(2)
|
|
113
|
+
subprocess.run(['git', '-C', slot, 'checkout', '-qb', 'ticket/held'], check=True)
|
|
114
|
+
index = driver_slots.git(slot, 'rev-parse', '--path-format=absolute', '--git-path', 'index.lock').stdout.strip()
|
|
115
|
+
from pathlib import Path
|
|
116
|
+
Path(index).touch()
|
|
117
|
+
assert not driver_slots.release(slot)
|
|
118
|
+
assert driver_slots.on_branch(slot) == 'ticket/held'
|
|
@@ -314,11 +314,15 @@ def test_prepare_runs_once_in_slot_2_and_the_slot_is_reused(tmp_path):
|
|
|
314
314
|
assert (rig.slot2 / "node_modules").is_symlink() and all(g["status"] == "" for g in rig.gates())
|
|
315
315
|
|
|
316
316
|
|
|
317
|
-
def
|
|
317
|
+
def test_failing_prepare_exits_3_after_running_tickets_finish_naming_slot_and_command(tmp_path):
|
|
318
318
|
rig = Rig(tmp_path).run(plan(), "--prepare", "false")
|
|
319
319
|
assert rig.code == 3, rig.output()
|
|
320
320
|
assert re.search(r"slot[- ]?2", rig.out + rig.err) and "false" in rig.out + rig.err
|
|
321
|
-
assert
|
|
321
|
+
assert {call["nn"] for call in rig.calls()} == {"01"}
|
|
322
|
+
assert rig.gates() and not rig.slot2.exists()
|
|
323
|
+
assert git(rig.repo, "symbolic-ref", "--short", "HEAD").strip() == "feat/csv"
|
|
324
|
+
rig.run(plan())
|
|
325
|
+
assert rig.code == 0, rig.output()
|
|
322
326
|
|
|
323
327
|
|
|
324
328
|
def test_a_fast_forward_merge_has_one_fast_and_one_full_record_of_the_ticket_tip(tmp_path):
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-08T00:30:48.221Z",
|
|
4
4
|
"skills": [
|
|
5
5
|
{
|
|
6
6
|
"name": "agents-wayfinder",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"name": "babysit-pr",
|
|
13
|
-
"version": "0.1.
|
|
14
|
-
"hash": "sha256-
|
|
13
|
+
"version": "0.1.5",
|
|
14
|
+
"hash": "sha256-71a14f734fcc2c21c7e068a4a0bf42afc23d7898d0d21ff962205832619b0ab2",
|
|
15
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 <pr-url>`."
|
|
16
16
|
},
|
|
17
17
|
{
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"name": "implement-spec",
|
|
61
|
-
"version": "0.1.
|
|
62
|
-
"hash": "sha256-
|
|
61
|
+
"version": "0.1.54",
|
|
62
|
+
"hash": "sha256-7d98e063ec9b3851aff9ce5cd80ed540be3dc9f7d1382e8483a6ac5d5ebc9ad2",
|
|
63
63
|
"description": "Implement a specification in code."
|
|
64
64
|
},
|
|
65
65
|
{
|