dkitchen 0.6.3__tar.gz → 0.6.4__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.
Files changed (31) hide show
  1. {dkitchen-0.6.3/src/dkitchen.egg-info → dkitchen-0.6.4}/PKG-INFO +1 -1
  2. {dkitchen-0.6.3 → dkitchen-0.6.4}/pyproject.toml +1 -1
  3. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/config.py +5 -0
  4. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/watch.py +45 -10
  5. {dkitchen-0.6.3 → dkitchen-0.6.4/src/dkitchen.egg-info}/PKG-INFO +1 -1
  6. {dkitchen-0.6.3 → dkitchen-0.6.4}/tests/test_kitchen.py +61 -0
  7. {dkitchen-0.6.3 → dkitchen-0.6.4}/tests/test_reference_scripts.py +26 -2
  8. {dkitchen-0.6.3 → dkitchen-0.6.4}/LICENSE +0 -0
  9. {dkitchen-0.6.3 → dkitchen-0.6.4}/README.md +0 -0
  10. {dkitchen-0.6.3 → dkitchen-0.6.4}/setup.cfg +0 -0
  11. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/__init__.py +0 -0
  12. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/check.py +0 -0
  13. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/ding.py +0 -0
  14. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/inbox.py +0 -0
  15. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/kitchens.py +0 -0
  16. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/night.py +0 -0
  17. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/orchestrate.py +0 -0
  18. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/outbound.py +0 -0
  19. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/refs.py +0 -0
  20. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/roles.py +0 -0
  21. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/rule.py +0 -0
  22. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen/verdict.py +0 -0
  23. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen.egg-info/SOURCES.txt +0 -0
  24. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen.egg-info/dependency_links.txt +0 -0
  25. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen.egg-info/entry_points.txt +0 -0
  26. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen.egg-info/requires.txt +0 -0
  27. {dkitchen-0.6.3 → dkitchen-0.6.4}/src/dkitchen.egg-info/top_level.txt +0 -0
  28. {dkitchen-0.6.3 → dkitchen-0.6.4}/tests/test_check.py +0 -0
  29. {dkitchen-0.6.3 → dkitchen-0.6.4}/tests/test_claude_executor.py +0 -0
  30. {dkitchen-0.6.3 → dkitchen-0.6.4}/tests/test_codex_session.py +0 -0
  31. {dkitchen-0.6.3 → dkitchen-0.6.4}/tests/test_records.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkitchen
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: DIY your own multi-agent workflow with Claude Code and Codex; includes the ding CLI for messaging and waking agent sessions
5
5
  Author: 917Dhj
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dkitchen"
7
- version = "0.6.3"
7
+ version = "0.6.4"
8
8
  description = "DIY your own multi-agent workflow with Claude Code and Codex; includes the ding CLI for messaging and waking agent sessions"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -64,6 +64,7 @@ Every key is optional. The defaults match the English templates in kitchen/:
64
64
  stale_minutes = 30 # 0 disables wakes for a `ding launch --progress` job whose progress stopped moving
65
65
  overrun_factor = 1.5 # wake once a `ding launch --expect-hours H` job runs past factor x H; 0 disables
66
66
  handoff = ["hand to "] # written right before a role name to hand it work, e.g. ["交"]
67
+ design_line = "Design:" # a ticket body line naming the designer that owns it, e.g. "设计:"
67
68
 
68
69
  [merge]
69
70
  required_checks = [] # e.g. ["ci"]; only success permits merging
@@ -245,6 +246,7 @@ class Watch:
245
246
  stale_minutes: float = 30
246
247
  overrun_factor: float = 1.5
247
248
  handoff: tuple[str, ...] = ("hand to ",)
249
+ design_line: str = "Design:"
248
250
 
249
251
 
250
252
  @dataclass(frozen=True)
@@ -469,6 +471,9 @@ def section(cls, values: object, name: str):
469
471
  if not isinstance(value, list) or not value or not all(isinstance(item, str) and item.strip() for item in value):
470
472
  raise ValueError(f"{FILE}: [watch] handoff must be a nonempty list of nonempty words")
471
473
  value = tuple(value)
474
+ elif key == "design_line":
475
+ if not isinstance(value, str) or not value.strip() or "\n" in value or "\r" in value:
476
+ raise ValueError(f"{FILE}: [watch] design_line must be one nonempty line")
472
477
  elif key in {"review_pass", "review_changes"}:
473
478
  if (not isinstance(value, str) or value.count("{sha}") != 1 or "\n" in value or "\r" in value
474
479
  or not value.replace("{sha}", "").strip()):
@@ -30,6 +30,7 @@ session refuses to start, and a running one exits once another session takes the
30
30
  """
31
31
  from __future__ import annotations
32
32
 
33
+ from collections.abc import Callable
33
34
  from contextvars import ContextVar
34
35
  from datetime import datetime, timedelta, timezone
35
36
  import fcntl
@@ -53,8 +54,8 @@ VIEWER: list[str] = [] # the gh login, read once: in a split kitchen, the user'
53
54
  STALLED_EVERY_HOURS = 24 # the orchestrator's watch reports each stalled item at most once a day
54
55
  WAITER_LOOKBACK_DAYS = 7 # older inbox records are not rechecked; a silent executor was reported long before
55
56
  TICKET_NAMED = re.compile(r"(?<![A-Za-z0-9_/#])#([1-9]\d*)(?!\d)")
56
- RECENT: ContextVar[dict[tuple, list[dict]] | None] = ContextVar("RECENT", default=None)
57
- # newer() results shared by the checks of one poll; set only while a watch runs
57
+ RECENT: ContextVar[dict[tuple, list[dict] | str] | None] = ContextVar("RECENT", default=None)
58
+ # newer() results and ticket bodies shared by the checks of one poll; set only while a watch runs
58
59
 
59
60
 
60
61
  def gh(path: str) -> list[dict]:
@@ -81,6 +82,18 @@ def newer(path: str, field: str, since: str, pages: int = 3) -> list[dict]:
81
82
  return items
82
83
 
83
84
 
85
+ def ticket_body(repo: str, number: int) -> str:
86
+ """The ticket's body, read once per poll."""
87
+ key = ("body", repo, number)
88
+ shared = RECENT.get()
89
+ if shared is not None and key in shared:
90
+ return shared[key]
91
+ body = gh(f"repos/{repo}/issues/{number}").get("body") or ""
92
+ if shared is not None:
93
+ shared[key] = body
94
+ return body
95
+
96
+
84
97
  def recent_comments(repo: str, since: str) -> list[dict]:
85
98
  return newer(f"repos/{repo}/issues/comments?since={since}&sort=updated&direction=desc", "updated_at", since)
86
99
 
@@ -253,15 +266,36 @@ def waiting_for(body: str, role: str, config: Config) -> bool:
253
266
  return named(waiting, role, config)
254
267
 
255
268
 
256
- def design_request(body: str, config: Config) -> list[str]:
269
+ def names_role(body: str, config: Config) -> bool:
270
+ return any(waiting_for(body, name, config) for name in role_names(config))
271
+
272
+
273
+ def design_owner(ticket: str, config: Config) -> str:
274
+ """The designer named by the ticket body's first `[watch] design_line` line, up to a `;`; else `[roles] designer`."""
275
+ prefix = normalized(config.watch.design_line).strip()
276
+ for line in normalized(ticket).splitlines():
277
+ line = line.strip()
278
+ if line.startswith(prefix):
279
+ value = line[len(prefix):].split(";", 1)[0]
280
+ return next((name for name in designer_roles(config) if named(value, name, config)),
281
+ config.roles.designer)
282
+ return config.roles.designer
283
+
284
+
285
+ def design_request(body: str, config: Config, ticket: str = "") -> list[str]:
286
+ """The designers an executor comment asks for: those its waiting field names; else, when it waits on design
287
+ naming no role at all, the ticket's design owner."""
257
288
  state, _ = state_and_waiting(body, config)
258
289
  if state == config.status.paused:
259
290
  return []
260
291
  designers = [name for name in designer_roles(config) if waiting_for(body, name, config)]
261
- return designers or ([config.roles.designer] if state == config.status.waiting_on_design else [])
292
+ if designers or state != config.status.waiting_on_design or names_role(body, config):
293
+ return designers
294
+ return [design_owner(ticket, config)]
262
295
 
263
296
 
264
- def role_wakes(body: str, role: str, config: Config) -> bool:
297
+ def role_wakes(body: str, role: str, config: Config, ticket: Callable[[], str] = lambda: "") -> bool:
298
+ """Whether a comment wakes `role`'s watch; `ticket` reads the ticket body, only when the design fallback needs it."""
265
299
  who = signer(body, config)
266
300
  if who == config.roles.designer:
267
301
  return False
@@ -271,9 +305,10 @@ def role_wakes(body: str, role: str, config: Config) -> bool:
271
305
  return False
272
306
  if waiting_for(body, role, config):
273
307
  return True
274
- if (state == config.status.waiting_on_design
275
- and not any(waiting_for(body, name, config) for name in designer_roles(config))
276
- and role_variants(role, config) & role_variants(config.roles.designer, config)):
308
+ variants = role_variants(role, config)
309
+ if (state == config.status.waiting_on_design and not names_role(body, config)
310
+ and any(variants & role_variants(name, config) for name in designer_roles(config))
311
+ and variants & role_variants(design_owner(ticket(), config), config)):
277
312
  return True
278
313
  next_step = fields(body, config).get(config.status.fields[3], "") if len(config.status.fields) > 3 else ""
279
314
  return named(next_step, role, config, markers=handoff(config))
@@ -311,7 +346,7 @@ def collect(config: Config, repo: str, since: str, labels_since: str, seen: set[
311
346
  found.append((comment["updated_at"], f"PR {code}#{pull} opened, recorded on #{number} "
312
347
  f"{comment['html_url']}", True))
313
348
  if role is not None:
314
- if not role_wakes(body, role, config):
349
+ if not role_wakes(body, role, config, lambda: ticket_body(repo, number)):
315
350
  continue
316
351
  elif not (who in {verifier, user} or (who == executor and executor_wakes(body, number in waiting, config))):
317
352
  continue
@@ -569,7 +604,7 @@ def unanswered_waits(config: Config, repo: str, minutes: float, skip: set[int],
569
604
  continue
570
605
  if state_and_waiting(comment["body"], config)[0] == config.status.paused:
571
606
  break
572
- implicit = design_request(comment["body"], config) if design_fallback else []
607
+ implicit = design_request(comment["body"], config, issue.get("body") or "") if design_fallback else []
573
608
  elapsed = (moment - datetime.fromisoformat(comment["created_at"].replace("Z", "+00:00"))).total_seconds() / 60
574
609
  if elapsed > minutes:
575
610
  waiting = [name for name in names
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkitchen
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: DIY your own multi-agent workflow with Claude Code and Codex; includes the ding CLI for messaging and waking agent sessions
5
5
  Author: 917Dhj
6
6
  License-Expression: MIT
@@ -2253,6 +2253,67 @@ def test_issue32_mention_replays(routed_settings, body, training, general):
2253
2253
  assert watch.role_wakes(body, "总设计", routed_settings) is general
2254
2254
 
2255
2255
 
2256
+ @pytest.fixture
2257
+ def owner_settings(tmp_path):
2258
+ return settings(tmp_path, RULING.replace('[status]\n', '[status]\npaused = "暂停"\n') + '''
2259
+ signatures = ["总设计:", "总设计(训练):", "总工程师:"]
2260
+ [roles.aliases]
2261
+ "总设计(训练)" = ["训练设计"]
2262
+ [watch]
2263
+ handoff = ["交"]
2264
+ design_line = "设计:"
2265
+ ''')
2266
+
2267
+
2268
+ DESIGNERS = ("总设计", "总设计(训练)", "总工程师")
2269
+
2270
+
2271
+ @pytest.mark.parametrize("waiting, ticket, woken", [
2272
+ ("总编排", "母票:#2118\n设计:训练设计;PR 由核查审", "总编排"),
2273
+ ("核查", "", "核查"),
2274
+ ("", "母票:#2118\n设计:训练设计;PR 由核查审\n相关:#2119", "总设计(训练)"),
2275
+ ("无", "设计: 总工程师", "总工程师"),
2276
+ ("", "", "总设计"),
2277
+ ("裁定 X", "设计:外部团队", "总设计"),
2278
+ ])
2279
+ def test_waiting_on_design_fallback_follows_named_role_then_ticket_owner(owner_settings, waiting, ticket, woken):
2280
+ body = executor(f"状态: 等设计\n在等: {waiting}\n关键数字: 1\n下一步: 等")
2281
+ reads = []
2282
+ def read():
2283
+ reads.append(1)
2284
+ return ticket
2285
+ for role in (*DESIGNERS, "总编排", "核查"):
2286
+ assert watch.role_wakes(body, role, owner_settings, read) is (role == woken), role
2287
+ assert watch.design_request(body, owner_settings, ticket) == ([woken] if woken in DESIGNERS else [])
2288
+ if woken not in DESIGNERS:
2289
+ assert reads == []
2290
+
2291
+
2292
+ def test_role_watch_reads_ticket_body_once_per_poll_for_the_fallback(owner_settings, monkeypatch):
2293
+ body = executor("状态: 等设计\n在等: \n关键数字: 1\n下一步: 等")
2294
+ calls = []
2295
+ def gh(path):
2296
+ calls.append(path)
2297
+ if path == "repos/o/r/issues/30":
2298
+ return {"body": "设计:训练设计"}
2299
+ return [comment(30, body)] if "/comments?" in path else []
2300
+ monkeypatch.setattr(watch, "gh", gh)
2301
+ token = watch.RECENT.set({})
2302
+ try:
2303
+ for role, wakes in (("总设计(训练)", True), ("训练设计", True), ("总设计", False)):
2304
+ found = watch.collect(owner_settings, "o/r", "2026-10-14T08:00:00Z", "2026-10-14T08:00:00Z",
2305
+ set(), set(), role=role)
2306
+ assert bool(found) is wakes
2307
+ finally:
2308
+ watch.RECENT.reset(token)
2309
+ assert calls.count("repos/o/r/issues/30") == 1
2310
+
2311
+
2312
+ def test_design_line_must_be_one_nonempty_line(tmp_path):
2313
+ with pytest.raises(ValueError, match=r"\[watch\] design_line must be one nonempty line"):
2314
+ settings(tmp_path, '[watch]\ndesign_line = " "\n')
2315
+
2316
+
2256
2317
  def test_alias_matching_is_shared_with_orchestrator_and_normalizes_width(routed_settings):
2257
2318
  body = executor("状态: 进行中\n在等: 训练设计师\n关键数字: 1\n下一步: 等")
2258
2319
  assert watch.waiting_for(body, "总设计(训练)", routed_settings)
@@ -1,5 +1,6 @@
1
1
  """The setup skill's reference repo scripts, loaded from their files as an installed repo would run them."""
2
2
  from importlib.util import module_from_spec, spec_from_file_location
3
+ import json
3
4
  from pathlib import Path
4
5
  import subprocess
5
6
  import sys
@@ -18,15 +19,38 @@ def load(name):
18
19
  return module
19
20
 
20
21
 
21
- review_pr, check_requests, check_prompt_in_issue = (load(name) for name in ("review_pr", "check_requests", "check_prompt_in_issue"))
22
+ review_pr, check_requests, check_prompt_in_issue, check_disk = (
23
+ load(name) for name in ("review_pr", "check_requests", "check_prompt_in_issue", "check_disk"))
22
24
 
23
25
 
24
- @pytest.mark.parametrize("name", ["review_pr", "check_requests", "check_prompt_in_issue"])
26
+ @pytest.mark.parametrize("name", ["review_pr", "check_requests", "check_prompt_in_issue", "check_disk"])
25
27
  def test_scripts_print_help(name):
26
28
  result = subprocess.run([sys.executable, str(SCRIPTS / f"{name}.py"), "--help"], capture_output=True, text=True)
27
29
  assert result.returncode == 0 and "usage:" in result.stdout
28
30
 
29
31
 
32
+ def test_disk_check_refuses_below_reserve_and_writes_receipt(tmp_path, monkeypatch):
33
+ receipt = tmp_path / "receipt.json"
34
+ monkeypatch.setenv("DING_PREFLIGHT_RECEIPT", str(receipt))
35
+ assert check_disk.main(["--reserve-gb", "0", str(tmp_path)]) == 0
36
+ assert check_disk.main(["--reserve-gb", "1e12", str(tmp_path)]) == 1
37
+ saved = json.loads(receipt.read_text())
38
+ assert saved["disks"][0]["path"] == str(tmp_path) and "below the" in saved["problems"][0]
39
+
40
+
41
+ def test_disk_check_refuses_a_real_outputs_folder_but_not_a_symlink(tmp_path, monkeypatch):
42
+ monkeypatch.delenv("DING_PREFLIGHT_RECEIPT", raising=False)
43
+ monkeypatch.setenv("DING_LAUNCH_CWD", str(tmp_path))
44
+ subprocess.run(["git", "init", "-q", str(tmp_path)], check=True)
45
+ runs = tmp_path.parent / f"{tmp_path.name}-runs"
46
+ runs.mkdir()
47
+ (tmp_path / "outputs").symlink_to(runs)
48
+ assert check_disk.main(["--reserve-gb", "0", "--outputs", "outputs"]) == 0
49
+ (tmp_path / "outputs").unlink()
50
+ (tmp_path / "outputs").mkdir()
51
+ assert check_disk.main(["--reserve-gb", "0", "--outputs", "outputs"]) == 1
52
+
53
+
30
54
  def test_added_lines_warn_only_for_paths_and_new_nested_prompts():
31
55
  diff = '''diff --git a/example.py b/example.py
32
56
  --- a/example.py
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