dkitchen 0.5.0__tar.gz → 0.5.2__tar.gz
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.
- {dkitchen-0.5.0/src/dkitchen.egg-info → dkitchen-0.5.2}/PKG-INFO +1 -1
- {dkitchen-0.5.0 → dkitchen-0.5.2}/pyproject.toml +1 -1
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen/ding.py +73 -5
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen/watch.py +1 -1
- {dkitchen-0.5.0 → dkitchen-0.5.2/src/dkitchen.egg-info}/PKG-INFO +1 -1
- {dkitchen-0.5.0 → dkitchen-0.5.2}/tests/test_codex_session.py +64 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/LICENSE +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/README.md +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/setup.cfg +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen/__init__.py +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen/config.py +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen/orchestrate.py +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen/refs.py +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen.egg-info/SOURCES.txt +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen.egg-info/dependency_links.txt +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen.egg-info/entry_points.txt +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen.egg-info/requires.txt +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/src/dkitchen.egg-info/top_level.txt +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/tests/test_kitchen.py +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/tests/test_records.py +0 -0
- {dkitchen-0.5.0 → dkitchen-0.5.2}/tests/test_reference_scripts.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dkitchen"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.2"
|
|
8
8
|
description = "A multi-agent workflow for research repos, with the ding CLI for messaging and waking agent sessions"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -545,7 +545,7 @@ def run_registry() -> Path:
|
|
|
545
545
|
|
|
546
546
|
|
|
547
547
|
@contextmanager
|
|
548
|
-
def registered_run(thread_id: str, record: Path) -> Iterator[str]:
|
|
548
|
+
def registered_run(thread_id: str, record: Path, progress: Path | None = None) -> Iterator[str]:
|
|
549
549
|
registry = run_registry()
|
|
550
550
|
registry.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
551
551
|
registry.parent.chmod(0o700)
|
|
@@ -566,6 +566,7 @@ def registered_run(thread_id: str, record: Path) -> Iterator[str]:
|
|
|
566
566
|
"event": "run_start", "run_id": run_id, "thread_id": thread_id,
|
|
567
567
|
"record": str(record.resolve()), "pid": os.getpid(),
|
|
568
568
|
"started_ns": time.time_ns(), "cwd": str(Path.cwd()),
|
|
569
|
+
**({"progress": str(progress.resolve())} if progress is not None else {}),
|
|
569
570
|
})
|
|
570
571
|
yield run_id
|
|
571
572
|
|
|
@@ -589,7 +590,9 @@ def latest_runs() -> dict[str, dict]:
|
|
|
589
590
|
or str(UUID(run["thread_id"])) != run["thread_id"]
|
|
590
591
|
or not Path(run["record"]).is_absolute() or not Path(run["cwd"]).is_absolute()
|
|
591
592
|
or type(run.get("pid")) is not int or run["pid"] <= 0
|
|
592
|
-
or type(run.get("started_ns")) is not int or run["started_ns"] <= 0
|
|
593
|
+
or type(run.get("started_ns")) is not int or run["started_ns"] <= 0
|
|
594
|
+
or "progress" in run and (not isinstance(run["progress"], str)
|
|
595
|
+
or not Path(run["progress"]).is_absolute())):
|
|
593
596
|
raise ValueError("invalid run_start")
|
|
594
597
|
except (ValueError, TypeError, AttributeError, UnicodeError) as exc:
|
|
595
598
|
print(f"ding: invalid run registry row {number} ({registry}): {exc}", file=sys.stderr)
|
|
@@ -655,6 +658,60 @@ def run_state(run: dict) -> str:
|
|
|
655
658
|
return "unknown"
|
|
656
659
|
|
|
657
660
|
|
|
661
|
+
STALE_PROGRESS = 600
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
def short_time(value: object) -> str:
|
|
665
|
+
"""An ISO time as MM-DD HH:MM in its own zone, or the text unchanged."""
|
|
666
|
+
try:
|
|
667
|
+
return datetime.fromisoformat(str(value).replace("Z", "+00:00")).strftime("%m-%d %H:%M")
|
|
668
|
+
except ValueError:
|
|
669
|
+
return str(value)
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
def progress_summary(path: str, now: float | None = None) -> str:
|
|
673
|
+
"""One board cell from a progress-v1 file: stage done/total, rate, ETA, and a mark when it went quiet."""
|
|
674
|
+
try:
|
|
675
|
+
data = json.loads(Path(path).read_text(encoding="utf-8"))
|
|
676
|
+
if not isinstance(data, dict) or data.get("schema") != "progress-v1":
|
|
677
|
+
return "progress: unknown format"
|
|
678
|
+
except FileNotFoundError:
|
|
679
|
+
return "progress: no file yet"
|
|
680
|
+
except (OSError, ValueError, UnicodeError):
|
|
681
|
+
return "progress: unreadable"
|
|
682
|
+
current = data.get("current") if isinstance(data.get("current"), dict) else None
|
|
683
|
+
parts = []
|
|
684
|
+
if current:
|
|
685
|
+
total = current.get("total")
|
|
686
|
+
parts.append(f"{current.get('name') or data.get('stage') or '?'} {current.get('done', '?')}/"
|
|
687
|
+
f"{'?' if total is None else total}")
|
|
688
|
+
if current.get("failed"):
|
|
689
|
+
parts.append(f"failed {current['failed']}")
|
|
690
|
+
elif data.get("stage"):
|
|
691
|
+
parts.append(str(data["stage"]))
|
|
692
|
+
rate = data.get("rate_per_hour")
|
|
693
|
+
if isinstance(rate, (int, float)) and not isinstance(rate, bool):
|
|
694
|
+
parts.append(f"{rate:.0f}/h" if rate >= 10 else f"{rate:.1f}/h")
|
|
695
|
+
eta = data.get("eta")
|
|
696
|
+
if isinstance(eta, dict) and (eta.get("beijing") or eta.get("utc")):
|
|
697
|
+
parts.append(f"ETA {short_time(eta.get('beijing') or eta.get('utc'))}")
|
|
698
|
+
state = data.get("state")
|
|
699
|
+
if state != "running":
|
|
700
|
+
parts.append(str(state))
|
|
701
|
+
else:
|
|
702
|
+
updated = data.get("updated", {}).get("utc") if isinstance(data.get("updated"), dict) else None
|
|
703
|
+
try:
|
|
704
|
+
age = (time.time() if now is None else now) - datetime.fromisoformat(
|
|
705
|
+
str(updated).replace("Z", "+00:00")).timestamp()
|
|
706
|
+
except ValueError:
|
|
707
|
+
age = None
|
|
708
|
+
if age is None:
|
|
709
|
+
parts.append("STALE? no update time")
|
|
710
|
+
elif age > STALE_PROGRESS:
|
|
711
|
+
parts.append(f"STALE {int(age // 60)}m")
|
|
712
|
+
return " ".join(parts) or "progress: empty"
|
|
713
|
+
|
|
714
|
+
|
|
658
715
|
def executor_comment_heads(mapping: dict[str, set[int]], fields: tuple[str, ...]) -> dict[str, str]:
|
|
659
716
|
numbers = sorted({number for issues in mapping.values() for number in issues})
|
|
660
717
|
if not numbers:
|
|
@@ -1052,11 +1109,15 @@ def show_board(path: str | None, *, all_threads: bool = False, status: tuple[str
|
|
|
1052
1109
|
if all_threads or any(Path(run["cwd"]).resolve().is_relative_to(root) for root in roots)]
|
|
1053
1110
|
mapping = issue_map()
|
|
1054
1111
|
heads = executor_comment_heads({row[3]: mapping.get(row[3], set()) for row in rows}, status) if status else {}
|
|
1055
|
-
|
|
1112
|
+
shown = any("progress" in run for run in runs.values())
|
|
1113
|
+
print("NAME\tCWD\tSTATUS\tISSUE\tHEAD\tRUN" + ("\tPROGRESS" if shown else ""))
|
|
1056
1114
|
for name, cwd, status, thread_id, head in rows:
|
|
1057
1115
|
issue = ",".join(f"#{number}" for number in sorted(mapping.get(thread_id, set())))
|
|
1058
1116
|
state = run_state(runs[thread_id]) if thread_id in runs else ""
|
|
1059
|
-
|
|
1117
|
+
cells = [name, cwd, status, issue, heads.get(thread_id, head), state]
|
|
1118
|
+
if shown:
|
|
1119
|
+
cells.append(progress_summary(runs[thread_id]["progress"]) if "progress" in runs.get(thread_id, {}) else "")
|
|
1120
|
+
print("\t".join(display_cell(cell) for cell in cells))
|
|
1060
1121
|
|
|
1061
1122
|
|
|
1062
1123
|
def socket_path(explicit: str | None) -> str:
|
|
@@ -1154,6 +1215,9 @@ def deliver_message(thread_id: str, message: str, path: str, client_id: str,
|
|
|
1154
1215
|
def confirm(turn):
|
|
1155
1216
|
result.update(outcome="steered" if mutation == "steer" else "started",
|
|
1156
1217
|
turn_id=turn["id"], turn_status=turn["status"])
|
|
1218
|
+
if result["error"] is not None:
|
|
1219
|
+
# Found in history after an error (e.g. Codex started the queued message first): delivered once.
|
|
1220
|
+
result["recovered_error"], result["error"] = result["error"], None
|
|
1157
1221
|
return result
|
|
1158
1222
|
|
|
1159
1223
|
try:
|
|
@@ -1434,7 +1498,8 @@ def task_exit_code(command: list[str], *, env: dict | None = None) -> tuple[int,
|
|
|
1434
1498
|
|
|
1435
1499
|
def run_task(args, command: list[str]) -> int:
|
|
1436
1500
|
record = Path(args.record)
|
|
1437
|
-
|
|
1501
|
+
progress = Path(args.progress) if getattr(args, "progress", None) else None
|
|
1502
|
+
with writer(record), registered_run(args.thread_id, record, progress) as run_id:
|
|
1438
1503
|
child_env = os.environ.copy()
|
|
1439
1504
|
child_env["DING_RUN_ID"] = run_id
|
|
1440
1505
|
code, error = task_exit_code(command, env=child_env)
|
|
@@ -1482,6 +1547,8 @@ def launch_task(args, command: list[str]) -> int:
|
|
|
1482
1547
|
f"Task {args.name} exited; inspect {record}", args.message_file, args.sender)
|
|
1483
1548
|
inner = [os.path.abspath(sys.executable), str(Path(__file__).resolve()), "run", thread_id,
|
|
1484
1549
|
"--record", str(record)]
|
|
1550
|
+
if getattr(args, "progress", None):
|
|
1551
|
+
inner += ["--progress", str(Path(args.progress).resolve())]
|
|
1485
1552
|
launch_records.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
1486
1553
|
launch_records.chmod(0o700)
|
|
1487
1554
|
message_path = launch_records / f"{launch_id}.message.txt"
|
|
@@ -1595,6 +1662,7 @@ def main(argv=None) -> int:
|
|
|
1595
1662
|
help="First stop the session's current turn; only when that work is known to be obsolete")
|
|
1596
1663
|
if action in {"run", "launch"}:
|
|
1597
1664
|
sub.add_argument("--record", required=action == "run", help="Append-only local exit/notification JSONL")
|
|
1665
|
+
sub.add_argument("--progress", help="The task's progress.json (progress-v1), shown by `ding board`")
|
|
1598
1666
|
sub.epilog = ("Task command follows --, for example: launch NAME -- python task.py" if action == "launch" else
|
|
1599
1667
|
"Task command follows --, for example: run UUID --message TEXT --record exit.jsonl -- python task.py")
|
|
1600
1668
|
sub = commands.add_parser("relay", help="Send a message to a ticket's executor, then leave it on the ticket")
|
|
@@ -138,7 +138,7 @@ def board_running(output: str) -> set[int]:
|
|
|
138
138
|
if not line.strip():
|
|
139
139
|
break # the unwrapped-process table follows a blank line
|
|
140
140
|
cells = line.split("\t")
|
|
141
|
-
if len(cells)
|
|
141
|
+
if len(cells) >= 6 and cells[5] == "running":
|
|
142
142
|
running.update(int(number) for number in re.findall(r"#(\d+)", cells[3]))
|
|
143
143
|
return running
|
|
144
144
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import builtins
|
|
2
2
|
import json
|
|
3
|
+
from datetime import datetime
|
|
3
4
|
import io
|
|
4
5
|
import stat
|
|
5
6
|
import socket
|
|
@@ -3440,3 +3441,66 @@ def test_new_parent_attach_failure_starts_no_session(tmp_path, monkeypatch, caps
|
|
|
3440
3441
|
monkeypatch.setattr(ding, "app_server", lambda path: pytest.fail("no session before the ticket is attached"))
|
|
3441
3442
|
assert ding.main(["new", "--cwd", str(cwd), "--parent", "57", "--name", "27B", "--message", "Brief"]) == 1
|
|
3442
3443
|
assert "rerun with --issue 90" in capsys.readouterr().err
|
|
3444
|
+
|
|
3445
|
+
|
|
3446
|
+
def progress_file(tmp_path, **changes):
|
|
3447
|
+
data = {"schema": "progress-v1", "state": "running", "stage": "answer",
|
|
3448
|
+
"current": {"name": "answer", "unit": "item", "total": 500, "done": 120, "resumed": 100, "failed": 0,
|
|
3449
|
+
"by_stage": {}, "state": "running", "started": {"utc": "2026-10-19T10:00:00Z"}},
|
|
3450
|
+
"rate_per_hour": 34.4, "eta": {"utc": "2026-10-19T21:10:00Z", "beijing": "2026-10-20T05:10:00+08:00"},
|
|
3451
|
+
"phases": [], "invocation_started": {"utc": "2026-10-19T10:00:00Z"},
|
|
3452
|
+
"updated": {"utc": "2026-10-19T12:00:00Z"}, "pid": 1, "host": "h"}
|
|
3453
|
+
data.update(changes)
|
|
3454
|
+
path = tmp_path / "progress.json"
|
|
3455
|
+
path.write_text(json.dumps(data))
|
|
3456
|
+
return str(path)
|
|
3457
|
+
|
|
3458
|
+
|
|
3459
|
+
NOON = datetime.fromisoformat("2026-10-19T12:00:00+00:00").timestamp()
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
@pytest.mark.parametrize("changes, now, expected", [
|
|
3463
|
+
({}, NOON + 60, "answer 120/500 34/h ETA 10-20 05:10"),
|
|
3464
|
+
({}, NOON + 601, "answer 120/500 34/h ETA 10-20 05:10 STALE 10m"),
|
|
3465
|
+
({"state": "interrupted", "eta": None, "rate_per_hour": None}, NOON + 9999, "answer 120/500 interrupted"),
|
|
3466
|
+
({"current": None, "stage": "prepare", "rate_per_hour": 2.25, "eta": None}, NOON, "prepare 2.2/h"),
|
|
3467
|
+
({"schema": "progress-v0"}, NOON, "progress: unknown format"),
|
|
3468
|
+
])
|
|
3469
|
+
def test_progress_summary_shows_stage_rate_eta_and_staleness(tmp_path, changes, now, expected):
|
|
3470
|
+
assert ding.progress_summary(progress_file(tmp_path, **changes), now) == expected
|
|
3471
|
+
|
|
3472
|
+
|
|
3473
|
+
def test_progress_summary_without_a_file(tmp_path):
|
|
3474
|
+
assert ding.progress_summary(str(tmp_path / "missing.json")) == "progress: no file yet"
|
|
3475
|
+
|
|
3476
|
+
|
|
3477
|
+
def test_run_registers_its_progress_file(tmp_path, monkeypatch):
|
|
3478
|
+
monkeypatch.setenv("XDG_STATE_HOME", str(tmp_path / "state"))
|
|
3479
|
+
with ding.registered_run(THREAD_ID, tmp_path / "r.jsonl", tmp_path / "out/progress.json"):
|
|
3480
|
+
pass
|
|
3481
|
+
run, = ding.latest_runs().values()
|
|
3482
|
+
assert run["progress"] == str((tmp_path / "out/progress.json").resolve())
|
|
3483
|
+
|
|
3484
|
+
|
|
3485
|
+
def test_codex_starting_the_queued_message_first_is_a_clean_start(monkeypatch):
|
|
3486
|
+
calls = []
|
|
3487
|
+
submitted = [False]
|
|
3488
|
+
|
|
3489
|
+
def call(method, params):
|
|
3490
|
+
calls.append(method)
|
|
3491
|
+
if method == "thread/read":
|
|
3492
|
+
return {"thread": thread()}
|
|
3493
|
+
if method == "thread/queue/add":
|
|
3494
|
+
submitted[0] = True
|
|
3495
|
+
return {"queuedSubmission": {"id": "q", "clientUserMessageId": MESSAGE_ID, "input": params["input"]}}
|
|
3496
|
+
if method == "thread/queue/start":
|
|
3497
|
+
raise ding.AppServerError("App Server error: queued submission not found: q")
|
|
3498
|
+
if method == "thread/turns/list":
|
|
3499
|
+
return {"data": [started_turn(status="completed")] if submitted[0] and "thread/queue/start" in calls else []}
|
|
3500
|
+
pytest.fail(method)
|
|
3501
|
+
|
|
3502
|
+
monkeypatch.setattr(ding, "app_server", lambda path, **kwargs: server_calls(call))
|
|
3503
|
+
result = ding.deliver_message(THREAD_ID, "message", "/test.sock", MESSAGE_ID, timeout=5)
|
|
3504
|
+
assert result["outcome"] == "started" and result["error"] is None
|
|
3505
|
+
assert "queued submission not found" in result["recovered_error"]
|
|
3506
|
+
assert calls.count("thread/queue/start") == 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|