dkitchen 0.6.0__tar.gz → 0.6.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.6.0/src/dkitchen.egg-info → dkitchen-0.6.2}/PKG-INFO +13 -13
- {dkitchen-0.6.0 → dkitchen-0.6.2}/README.md +11 -11
- {dkitchen-0.6.0 → dkitchen-0.6.2}/pyproject.toml +2 -2
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/config.py +5 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/ding.py +48 -4
- {dkitchen-0.6.0 → dkitchen-0.6.2/src/dkitchen.egg-info}/PKG-INFO +13 -13
- {dkitchen-0.6.0 → dkitchen-0.6.2}/tests/test_codex_session.py +84 -3
- {dkitchen-0.6.0 → dkitchen-0.6.2}/tests/test_kitchen.py +6 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/LICENSE +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/setup.cfg +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/__init__.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/check.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/night.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/orchestrate.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/refs.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/rule.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen/watch.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen.egg-info/SOURCES.txt +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen.egg-info/dependency_links.txt +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen.egg-info/entry_points.txt +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen.egg-info/requires.txt +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/src/dkitchen.egg-info/top_level.txt +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/tests/test_check.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/tests/test_records.py +0 -0
- {dkitchen-0.6.0 → dkitchen-0.6.2}/tests/test_reference_scripts.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dkitchen
|
|
3
|
-
Version: 0.6.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.6.2
|
|
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
|
|
7
7
|
Project-URL: Homepage, https://github.com/917Dhj/dkitchen
|
|
@@ -54,7 +54,7 @@ Dynamic: license-file
|
|
|
54
54
|
<a href="https://x.com/dahuoji09"><img src="https://img.shields.io/badge/follow-%40dahuoji09-000000?logo=x" alt="X: @dahuoji09"></a>
|
|
55
55
|
</p>
|
|
56
56
|
|
|
57
|
-
dkitchen is the multi-agent workflow I use every day to run my research repo. It gives a set of Claude Code and Codex sessions fixed
|
|
57
|
+
dkitchen is the multi-agent workflow I use every day to run my research repo. It gives a set of Claude Code and Codex sessions fixed roles, a shared way to hand off work through GitHub issues, clear rules for when to stop and ask you, and the tools that tie it together. You keep the decisions only you can make: what to research, what to try, what to spend.
|
|
58
58
|
|
|
59
59
|
## 🍽️ Why a kitchen
|
|
60
60
|
|
|
@@ -69,10 +69,10 @@ dkitchen sets up your agents the same way. You are the head chef.
|
|
|
69
69
|
## 🧑🍳 The kitchen
|
|
70
70
|
|
|
71
71
|
<p align="center">
|
|
72
|
-
<img src="https://raw.githubusercontent.com/917Dhj/dkitchen/main/docs/assets/kitchen.
|
|
72
|
+
<img src="https://raw.githubusercontent.com/917Dhj/dkitchen/main/docs/assets/kitchen.webp" width="100%" alt="A pixel-art kitchen: you agree a plan with the designer, the orchestrator rings the bell to start a Codex executor on free GPUs, an executor asks the designer directly, the verifier reviews a PR and the orchestrator merges it; then you go to bed, the kitchen keeps cooking on your night orders, and in the morning it brings you one decision">
|
|
73
73
|
</p>
|
|
74
74
|
|
|
75
|
-
|
|
|
75
|
+
| Role | In a kitchen | What it does | Runs on |
|
|
76
76
|
| --- | --- | --- | --- |
|
|
77
77
|
| 👑 **You** | Head chef | Choose the direction, approve designs and budgets, decide what the results mean for your paper. | You |
|
|
78
78
|
| 🤖 **Orchestrator** | Sous chef at the pass | Schedules tickets, GPUs, and concurrency. Merges PRs, closes tickets, reports facts to you. | Claude Code · Claude Opus 5.5 |
|
|
@@ -80,7 +80,7 @@ dkitchen sets up your agents the same way. You are the head chef.
|
|
|
80
80
|
| 🔍 **Verifier** | Taster | Spot-checks finished runs and outputs against code and data, and reviews PRs. Reports what it found and never makes the call. | Claude Code · Claude Sonnet 5.5 |
|
|
81
81
|
| 🔪 **Executors** | Line cooks | One fresh session per ticket, in its own worktree. Implements, runs, and reports on the ticket. | Codex · GPT-6.1 Sol |
|
|
82
82
|
|
|
83
|
-
Each
|
|
83
|
+
Each role has written rules for what it owns, what it hands off, and when it must stop. When something fits no role, the agents ask you.
|
|
84
84
|
|
|
85
85
|
## 🎫 How a ticket moves through the kitchen
|
|
86
86
|
|
|
@@ -104,7 +104,7 @@ Agents propose on these and wait. An approval only counts when it is in your own
|
|
|
104
104
|
|
|
105
105
|
Everything else the kitchen handles on its own, by one rule: **if anyone would do it the same way, the agents do it. If the choice changes the results, the cost, or the direction, they stop and wait for you.**
|
|
106
106
|
|
|
107
|
-
This is what lets you walk away. While you are in class, asleep, or reading papers, each
|
|
107
|
+
This is what lets you walk away. While you are in class, asleep, or reading papers, each role's watch wakes it when work reaches it: an executor finishes a stage, gets stuck, or goes quiet; you leave a comment; a PR is ready. Before you leave, `/goodnight` collects the approvals the night may need; the orchestrator moves forward what they cover, and `/goodmorning` brings you the decisions that are left.
|
|
108
108
|
|
|
109
109
|
## ⚖️ One pool of resources
|
|
110
110
|
|
|
@@ -134,11 +134,11 @@ You can address a session by its UUID, its name, or a GitHub issue such as `'#42
|
|
|
134
134
|
|
|
135
135
|
### 📋 The kitchen's routines
|
|
136
136
|
|
|
137
|
-
The
|
|
137
|
+
The roles' everyday steps are `ding` commands too, so they run the same careful way every time:
|
|
138
138
|
|
|
139
139
|
- `ding relay` sends a message to a ticket's executor, and records it on the ticket only once delivery is confirmed.
|
|
140
140
|
- `ding review` records a verdict on the current PR HEAD. With `[merge] review_check`, `ding merge`, `ding watch`, and `ding waits` share PR readiness checks; every merge requires the default target branch. See [the review and merge guide](docs/ding.md).
|
|
141
|
-
- `ding watch` waits in each
|
|
141
|
+
- `ding watch` waits in each role's background and wakes it when a ticket needs it.
|
|
142
142
|
- `ding waits` lists overdue unanswered waits, including ones still pending after a prior watch batch.
|
|
143
143
|
- `ding log` keeps the orchestrator's log of what it did while you were away.
|
|
144
144
|
- `ding night` opens, shows, and closes time-limited night orders on that log. Run `/goodnight` and `/goodmorning` in the orchestrator session to collect the orders and report their use.
|
|
@@ -147,7 +147,7 @@ The stations' everyday steps are `ding` commands too, so they run the same caref
|
|
|
147
147
|
|
|
148
148
|
### 📜 The house rules
|
|
149
149
|
|
|
150
|
-
The rules every
|
|
150
|
+
The rules every role follows live in [kitchen/](https://github.com/917Dhj/dkitchen/blob/main/kitchen/README.md), one folder per part of the kitchen: the team (who owns what, tickets, reviews, when to stop and ask, with optional modules for run budgets and model prompts), the repo's code rules and checks, the runner, and the night shift for when you are away. The rules guard what comes next rather than clean up the past, and a change to a check says why in a `Guard-change:` commit trailer.
|
|
151
151
|
|
|
152
152
|
### 🧩 The skills
|
|
153
153
|
|
|
@@ -156,7 +156,7 @@ The plugin installs ten skills. The build skills set up one part of the kitchen
|
|
|
156
156
|
| Skill | What it does |
|
|
157
157
|
| --- | --- |
|
|
158
158
|
| `/setup-dkitchen` | The entry: checks the prerequisites, settles the language and what you need, and walks through the build skills below |
|
|
159
|
-
| `build-team` | The
|
|
159
|
+
| `build-team` | The roles, tickets, PR review, and watches; it can suggest extra design lines for a repo with several kinds of work |
|
|
160
160
|
| `build-repo` | Where code goes, changing modules in place, and the `ding check` gates in CI (Python repos) |
|
|
161
161
|
| `build-runner` | One resumable runner for work done item by item, such as evaluations and batch inference (Python repos) |
|
|
162
162
|
| `build-night` | Night orders and the orchestrator's log, so work keeps moving while you are away |
|
|
@@ -165,8 +165,8 @@ The everyday skills run while the kitchen works:
|
|
|
165
165
|
|
|
166
166
|
| Skill | When |
|
|
167
167
|
| --- | --- |
|
|
168
|
-
| `write-ticket` | Every time a
|
|
169
|
-
| `/shift-change` | When a
|
|
168
|
+
| `write-ticket` | Every time a role writes a ticket; the model reaches for it on its own |
|
|
169
|
+
| `/shift-change` | When a role's session is replaced by a fresh one |
|
|
170
170
|
| `/improve-kitchen` | Every couple of weeks: turns what keeps going wrong into checks, tools, or rules, and retires the text they replace |
|
|
171
171
|
| `/goodnight`, `/goodmorning` | Before you leave and when you are back |
|
|
172
172
|
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<a href="https://x.com/dahuoji09"><img src="https://img.shields.io/badge/follow-%40dahuoji09-000000?logo=x" alt="X: @dahuoji09"></a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
|
-
dkitchen is the multi-agent workflow I use every day to run my research repo. It gives a set of Claude Code and Codex sessions fixed
|
|
23
|
+
dkitchen is the multi-agent workflow I use every day to run my research repo. It gives a set of Claude Code and Codex sessions fixed roles, a shared way to hand off work through GitHub issues, clear rules for when to stop and ask you, and the tools that tie it together. You keep the decisions only you can make: what to research, what to try, what to spend.
|
|
24
24
|
|
|
25
25
|
## 🍽️ Why a kitchen
|
|
26
26
|
|
|
@@ -35,10 +35,10 @@ dkitchen sets up your agents the same way. You are the head chef.
|
|
|
35
35
|
## 🧑🍳 The kitchen
|
|
36
36
|
|
|
37
37
|
<p align="center">
|
|
38
|
-
<img src="https://raw.githubusercontent.com/917Dhj/dkitchen/main/docs/assets/kitchen.
|
|
38
|
+
<img src="https://raw.githubusercontent.com/917Dhj/dkitchen/main/docs/assets/kitchen.webp" width="100%" alt="A pixel-art kitchen: you agree a plan with the designer, the orchestrator rings the bell to start a Codex executor on free GPUs, an executor asks the designer directly, the verifier reviews a PR and the orchestrator merges it; then you go to bed, the kitchen keeps cooking on your night orders, and in the morning it brings you one decision">
|
|
39
39
|
</p>
|
|
40
40
|
|
|
41
|
-
|
|
|
41
|
+
| Role | In a kitchen | What it does | Runs on |
|
|
42
42
|
| --- | --- | --- | --- |
|
|
43
43
|
| 👑 **You** | Head chef | Choose the direction, approve designs and budgets, decide what the results mean for your paper. | You |
|
|
44
44
|
| 🤖 **Orchestrator** | Sous chef at the pass | Schedules tickets, GPUs, and concurrency. Merges PRs, closes tickets, reports facts to you. | Claude Code · Claude Opus 5.5 |
|
|
@@ -46,7 +46,7 @@ dkitchen sets up your agents the same way. You are the head chef.
|
|
|
46
46
|
| 🔍 **Verifier** | Taster | Spot-checks finished runs and outputs against code and data, and reviews PRs. Reports what it found and never makes the call. | Claude Code · Claude Sonnet 5.5 |
|
|
47
47
|
| 🔪 **Executors** | Line cooks | One fresh session per ticket, in its own worktree. Implements, runs, and reports on the ticket. | Codex · GPT-6.1 Sol |
|
|
48
48
|
|
|
49
|
-
Each
|
|
49
|
+
Each role has written rules for what it owns, what it hands off, and when it must stop. When something fits no role, the agents ask you.
|
|
50
50
|
|
|
51
51
|
## 🎫 How a ticket moves through the kitchen
|
|
52
52
|
|
|
@@ -70,7 +70,7 @@ Agents propose on these and wait. An approval only counts when it is in your own
|
|
|
70
70
|
|
|
71
71
|
Everything else the kitchen handles on its own, by one rule: **if anyone would do it the same way, the agents do it. If the choice changes the results, the cost, or the direction, they stop and wait for you.**
|
|
72
72
|
|
|
73
|
-
This is what lets you walk away. While you are in class, asleep, or reading papers, each
|
|
73
|
+
This is what lets you walk away. While you are in class, asleep, or reading papers, each role's watch wakes it when work reaches it: an executor finishes a stage, gets stuck, or goes quiet; you leave a comment; a PR is ready. Before you leave, `/goodnight` collects the approvals the night may need; the orchestrator moves forward what they cover, and `/goodmorning` brings you the decisions that are left.
|
|
74
74
|
|
|
75
75
|
## ⚖️ One pool of resources
|
|
76
76
|
|
|
@@ -100,11 +100,11 @@ You can address a session by its UUID, its name, or a GitHub issue such as `'#42
|
|
|
100
100
|
|
|
101
101
|
### 📋 The kitchen's routines
|
|
102
102
|
|
|
103
|
-
The
|
|
103
|
+
The roles' everyday steps are `ding` commands too, so they run the same careful way every time:
|
|
104
104
|
|
|
105
105
|
- `ding relay` sends a message to a ticket's executor, and records it on the ticket only once delivery is confirmed.
|
|
106
106
|
- `ding review` records a verdict on the current PR HEAD. With `[merge] review_check`, `ding merge`, `ding watch`, and `ding waits` share PR readiness checks; every merge requires the default target branch. See [the review and merge guide](docs/ding.md).
|
|
107
|
-
- `ding watch` waits in each
|
|
107
|
+
- `ding watch` waits in each role's background and wakes it when a ticket needs it.
|
|
108
108
|
- `ding waits` lists overdue unanswered waits, including ones still pending after a prior watch batch.
|
|
109
109
|
- `ding log` keeps the orchestrator's log of what it did while you were away.
|
|
110
110
|
- `ding night` opens, shows, and closes time-limited night orders on that log. Run `/goodnight` and `/goodmorning` in the orchestrator session to collect the orders and report their use.
|
|
@@ -113,7 +113,7 @@ The stations' everyday steps are `ding` commands too, so they run the same caref
|
|
|
113
113
|
|
|
114
114
|
### 📜 The house rules
|
|
115
115
|
|
|
116
|
-
The rules every
|
|
116
|
+
The rules every role follows live in [kitchen/](https://github.com/917Dhj/dkitchen/blob/main/kitchen/README.md), one folder per part of the kitchen: the team (who owns what, tickets, reviews, when to stop and ask, with optional modules for run budgets and model prompts), the repo's code rules and checks, the runner, and the night shift for when you are away. The rules guard what comes next rather than clean up the past, and a change to a check says why in a `Guard-change:` commit trailer.
|
|
117
117
|
|
|
118
118
|
### 🧩 The skills
|
|
119
119
|
|
|
@@ -122,7 +122,7 @@ The plugin installs ten skills. The build skills set up one part of the kitchen
|
|
|
122
122
|
| Skill | What it does |
|
|
123
123
|
| --- | --- |
|
|
124
124
|
| `/setup-dkitchen` | The entry: checks the prerequisites, settles the language and what you need, and walks through the build skills below |
|
|
125
|
-
| `build-team` | The
|
|
125
|
+
| `build-team` | The roles, tickets, PR review, and watches; it can suggest extra design lines for a repo with several kinds of work |
|
|
126
126
|
| `build-repo` | Where code goes, changing modules in place, and the `ding check` gates in CI (Python repos) |
|
|
127
127
|
| `build-runner` | One resumable runner for work done item by item, such as evaluations and batch inference (Python repos) |
|
|
128
128
|
| `build-night` | Night orders and the orchestrator's log, so work keeps moving while you are away |
|
|
@@ -131,8 +131,8 @@ The everyday skills run while the kitchen works:
|
|
|
131
131
|
|
|
132
132
|
| Skill | When |
|
|
133
133
|
| --- | --- |
|
|
134
|
-
| `write-ticket` | Every time a
|
|
135
|
-
| `/shift-change` | When a
|
|
134
|
+
| `write-ticket` | Every time a role writes a ticket; the model reaches for it on its own |
|
|
135
|
+
| `/shift-change` | When a role's session is replaced by a fresh one |
|
|
136
136
|
| `/improve-kitchen` | Every couple of weeks: turns what keeps going wrong into checks, tools, or rules, and retires the text they replace |
|
|
137
137
|
| `/goodnight`, `/goodmorning` | Before you leave and when you are back |
|
|
138
138
|
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dkitchen"
|
|
7
|
-
version = "0.6.
|
|
8
|
-
description = "
|
|
7
|
+
version = "0.6.2"
|
|
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"
|
|
11
11
|
license = "MIT"
|
|
@@ -191,6 +191,7 @@ class Rule:
|
|
|
191
191
|
class Launch:
|
|
192
192
|
preflight: tuple[str, ...] = ()
|
|
193
193
|
preflight_timeout: float = 300
|
|
194
|
+
keep_days: float = 14
|
|
194
195
|
|
|
195
196
|
|
|
196
197
|
@dataclass(frozen=True)
|
|
@@ -371,6 +372,10 @@ def section(cls, values: object, name: str):
|
|
|
371
372
|
if (isinstance(value, bool) or not isinstance(value, (int, float))
|
|
372
373
|
or not math.isfinite(value) or value <= 0):
|
|
373
374
|
raise ValueError(f"{FILE}: [launch] preflight_timeout must be a positive finite number of seconds")
|
|
375
|
+
elif key == "keep_days":
|
|
376
|
+
if (isinstance(value, bool) or not isinstance(value, (int, float))
|
|
377
|
+
or not math.isfinite(value) or value < 0):
|
|
378
|
+
raise ValueError(f"{FILE}: [launch] keep_days must be a nonnegative finite number of days")
|
|
374
379
|
elif key in {"idle_minutes", "design_answer_minutes", "unrouted_wait_minutes"}:
|
|
375
380
|
if (isinstance(value, bool) or not isinstance(value, (int, float))
|
|
376
381
|
or not math.isfinite(value) or value < 0):
|
|
@@ -1595,6 +1595,45 @@ def launch_preflight(args, command: list[str], record: Path, launch_id: str, set
|
|
|
1595
1595
|
return True
|
|
1596
1596
|
|
|
1597
1597
|
|
|
1598
|
+
LAUNCH_LOG = re.compile(r"(?P<name>[A-Za-z0-9][A-Za-z0-9_-]{0,63})-[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\.log")
|
|
1599
|
+
|
|
1600
|
+
|
|
1601
|
+
def prune_launch_logs(directory: Path, keep_days: float, tmux: str) -> None:
|
|
1602
|
+
"""Delete launch logs untouched for keep_days, except those of a ding-NAME session still open."""
|
|
1603
|
+
if not keep_days:
|
|
1604
|
+
return
|
|
1605
|
+
cutoff = time.time() - keep_days * 86400
|
|
1606
|
+
old = []
|
|
1607
|
+
for path in directory.glob("*.log"):
|
|
1608
|
+
match = LAUNCH_LOG.fullmatch(path.name)
|
|
1609
|
+
try:
|
|
1610
|
+
if match is not None and path.stat().st_mtime < cutoff:
|
|
1611
|
+
old.append((path, match["name"]))
|
|
1612
|
+
except OSError:
|
|
1613
|
+
continue
|
|
1614
|
+
if not old:
|
|
1615
|
+
return
|
|
1616
|
+
try:
|
|
1617
|
+
result = subprocess.run([tmux, "list-sessions", "-F", "#{session_name}"],
|
|
1618
|
+
capture_output=True, text=True, timeout=10, check=False)
|
|
1619
|
+
except (OSError, subprocess.TimeoutExpired) as exc:
|
|
1620
|
+
print(f"ding: launch logs not pruned: {exc}", file=sys.stderr)
|
|
1621
|
+
return
|
|
1622
|
+
if result.returncode and not re.search(r"no server running|error connecting", result.stderr or ""):
|
|
1623
|
+
print(f"ding: launch logs not pruned: {(result.stderr or '').strip() or result.returncode}", file=sys.stderr)
|
|
1624
|
+
return
|
|
1625
|
+
open_names = {line.removeprefix("ding-") for line in (result.stdout or "").splitlines() if line.startswith("ding-")}
|
|
1626
|
+
for path, name in old:
|
|
1627
|
+
if name in open_names:
|
|
1628
|
+
continue
|
|
1629
|
+
try:
|
|
1630
|
+
path.unlink()
|
|
1631
|
+
except FileNotFoundError:
|
|
1632
|
+
pass
|
|
1633
|
+
except OSError as exc:
|
|
1634
|
+
print(f"ding: launch log not pruned ({path}): {exc}", file=sys.stderr)
|
|
1635
|
+
|
|
1636
|
+
|
|
1598
1637
|
def launch_task(args, command: list[str]) -> int:
|
|
1599
1638
|
if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_-]{0,63}", args.name):
|
|
1600
1639
|
raise ValueError("launch name must be 1-64 letters, digits, underscores or hyphens, starting with a letter or digit")
|
|
@@ -1610,14 +1649,16 @@ def launch_task(args, command: list[str]) -> int:
|
|
|
1610
1649
|
launch_id = str(uuid4())
|
|
1611
1650
|
launch_records = (run_registry().parent / "launch-records").resolve()
|
|
1612
1651
|
record = (Path(args.record) if args.record else launch_records / f"{launch_id}.jsonl").resolve()
|
|
1652
|
+
log = launch_records / f"{args.name}-{launch_id}.log"
|
|
1613
1653
|
message = message_text(args.message if args.message is not None else
|
|
1614
|
-
f"Task {args.name} exited;
|
|
1654
|
+
f"Task {args.name} exited; log: {log}; record: {record}", args.message_file, args.sender)
|
|
1615
1655
|
inner = [os.path.abspath(sys.executable), str(Path(__file__).resolve()), "run", thread_id,
|
|
1616
1656
|
"--record", str(record)]
|
|
1617
1657
|
if getattr(args, "progress", None):
|
|
1618
1658
|
inner += ["--progress", str(Path(args.progress).resolve())]
|
|
1619
1659
|
launch_records.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
1620
1660
|
launch_records.chmod(0o700)
|
|
1661
|
+
prune_launch_logs(launch_records, settings.keep_days, tmux)
|
|
1621
1662
|
if not launch_preflight(args, command, record, launch_id, settings):
|
|
1622
1663
|
return 1
|
|
1623
1664
|
message_path = launch_records / f"{launch_id}.message.txt"
|
|
@@ -1626,6 +1667,7 @@ def launch_task(args, command: list[str]) -> int:
|
|
|
1626
1667
|
handle.write(message)
|
|
1627
1668
|
handle.flush()
|
|
1628
1669
|
os.fsync(handle.fileno())
|
|
1670
|
+
os.close(os.open(log, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600))
|
|
1629
1671
|
_fsync_directory(launch_records)
|
|
1630
1672
|
inner.extend(["--message-file", str(message_path)])
|
|
1631
1673
|
if args.socket is not None:
|
|
@@ -1641,8 +1683,10 @@ def launch_task(args, command: list[str]) -> int:
|
|
|
1641
1683
|
"-n", args.name, "-c", str(Path.cwd())]
|
|
1642
1684
|
for key, value in environment.items():
|
|
1643
1685
|
arguments.extend(["-e", f"{key}={value}"])
|
|
1644
|
-
|
|
1645
|
-
|
|
1686
|
+
# The pane closes when the job exits, however it exits; its output stays in the log.
|
|
1687
|
+
pipe = shlex.quote(f"cat >> {shlex.quote(str(log))}")
|
|
1688
|
+
prelude = (f'{shlex.quote(str(Path(tmux).absolute()))} pipe-pane -o -t "$TMUX_PANE" {pipe} '
|
|
1689
|
+
f'&& exec {shlex.join(inner)}')
|
|
1646
1690
|
arguments.extend(["-P", "-F", "#{session_name}\t#{window_name}", "/bin/sh", "-c", prelude])
|
|
1647
1691
|
# tmux treats a trailing semicolon as a command separator even in argv values.
|
|
1648
1692
|
arguments = [value[:-1] + r"\;" if value.endswith(";") else value for value in arguments]
|
|
@@ -1652,7 +1696,7 @@ def launch_task(args, command: list[str]) -> int:
|
|
|
1652
1696
|
raise RuntimeError("tmux launch timed out; task creation is unconfirmed; inspect tmux and run records before retrying") from exc
|
|
1653
1697
|
if result.returncode:
|
|
1654
1698
|
raise ValueError(f"tmux launch failed: {result.stderr.strip() or result.returncode}")
|
|
1655
|
-
print(f"ding: created ding-{args.name}/{args.name}; record: {record}")
|
|
1699
|
+
print(f"ding: created ding-{args.name}/{args.name}; log: {log}; record: {record}")
|
|
1656
1700
|
return 0
|
|
1657
1701
|
|
|
1658
1702
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dkitchen
|
|
3
|
-
Version: 0.6.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.6.2
|
|
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
|
|
7
7
|
Project-URL: Homepage, https://github.com/917Dhj/dkitchen
|
|
@@ -54,7 +54,7 @@ Dynamic: license-file
|
|
|
54
54
|
<a href="https://x.com/dahuoji09"><img src="https://img.shields.io/badge/follow-%40dahuoji09-000000?logo=x" alt="X: @dahuoji09"></a>
|
|
55
55
|
</p>
|
|
56
56
|
|
|
57
|
-
dkitchen is the multi-agent workflow I use every day to run my research repo. It gives a set of Claude Code and Codex sessions fixed
|
|
57
|
+
dkitchen is the multi-agent workflow I use every day to run my research repo. It gives a set of Claude Code and Codex sessions fixed roles, a shared way to hand off work through GitHub issues, clear rules for when to stop and ask you, and the tools that tie it together. You keep the decisions only you can make: what to research, what to try, what to spend.
|
|
58
58
|
|
|
59
59
|
## 🍽️ Why a kitchen
|
|
60
60
|
|
|
@@ -69,10 +69,10 @@ dkitchen sets up your agents the same way. You are the head chef.
|
|
|
69
69
|
## 🧑🍳 The kitchen
|
|
70
70
|
|
|
71
71
|
<p align="center">
|
|
72
|
-
<img src="https://raw.githubusercontent.com/917Dhj/dkitchen/main/docs/assets/kitchen.
|
|
72
|
+
<img src="https://raw.githubusercontent.com/917Dhj/dkitchen/main/docs/assets/kitchen.webp" width="100%" alt="A pixel-art kitchen: you agree a plan with the designer, the orchestrator rings the bell to start a Codex executor on free GPUs, an executor asks the designer directly, the verifier reviews a PR and the orchestrator merges it; then you go to bed, the kitchen keeps cooking on your night orders, and in the morning it brings you one decision">
|
|
73
73
|
</p>
|
|
74
74
|
|
|
75
|
-
|
|
|
75
|
+
| Role | In a kitchen | What it does | Runs on |
|
|
76
76
|
| --- | --- | --- | --- |
|
|
77
77
|
| 👑 **You** | Head chef | Choose the direction, approve designs and budgets, decide what the results mean for your paper. | You |
|
|
78
78
|
| 🤖 **Orchestrator** | Sous chef at the pass | Schedules tickets, GPUs, and concurrency. Merges PRs, closes tickets, reports facts to you. | Claude Code · Claude Opus 5.5 |
|
|
@@ -80,7 +80,7 @@ dkitchen sets up your agents the same way. You are the head chef.
|
|
|
80
80
|
| 🔍 **Verifier** | Taster | Spot-checks finished runs and outputs against code and data, and reviews PRs. Reports what it found and never makes the call. | Claude Code · Claude Sonnet 5.5 |
|
|
81
81
|
| 🔪 **Executors** | Line cooks | One fresh session per ticket, in its own worktree. Implements, runs, and reports on the ticket. | Codex · GPT-6.1 Sol |
|
|
82
82
|
|
|
83
|
-
Each
|
|
83
|
+
Each role has written rules for what it owns, what it hands off, and when it must stop. When something fits no role, the agents ask you.
|
|
84
84
|
|
|
85
85
|
## 🎫 How a ticket moves through the kitchen
|
|
86
86
|
|
|
@@ -104,7 +104,7 @@ Agents propose on these and wait. An approval only counts when it is in your own
|
|
|
104
104
|
|
|
105
105
|
Everything else the kitchen handles on its own, by one rule: **if anyone would do it the same way, the agents do it. If the choice changes the results, the cost, or the direction, they stop and wait for you.**
|
|
106
106
|
|
|
107
|
-
This is what lets you walk away. While you are in class, asleep, or reading papers, each
|
|
107
|
+
This is what lets you walk away. While you are in class, asleep, or reading papers, each role's watch wakes it when work reaches it: an executor finishes a stage, gets stuck, or goes quiet; you leave a comment; a PR is ready. Before you leave, `/goodnight` collects the approvals the night may need; the orchestrator moves forward what they cover, and `/goodmorning` brings you the decisions that are left.
|
|
108
108
|
|
|
109
109
|
## ⚖️ One pool of resources
|
|
110
110
|
|
|
@@ -134,11 +134,11 @@ You can address a session by its UUID, its name, or a GitHub issue such as `'#42
|
|
|
134
134
|
|
|
135
135
|
### 📋 The kitchen's routines
|
|
136
136
|
|
|
137
|
-
The
|
|
137
|
+
The roles' everyday steps are `ding` commands too, so they run the same careful way every time:
|
|
138
138
|
|
|
139
139
|
- `ding relay` sends a message to a ticket's executor, and records it on the ticket only once delivery is confirmed.
|
|
140
140
|
- `ding review` records a verdict on the current PR HEAD. With `[merge] review_check`, `ding merge`, `ding watch`, and `ding waits` share PR readiness checks; every merge requires the default target branch. See [the review and merge guide](docs/ding.md).
|
|
141
|
-
- `ding watch` waits in each
|
|
141
|
+
- `ding watch` waits in each role's background and wakes it when a ticket needs it.
|
|
142
142
|
- `ding waits` lists overdue unanswered waits, including ones still pending after a prior watch batch.
|
|
143
143
|
- `ding log` keeps the orchestrator's log of what it did while you were away.
|
|
144
144
|
- `ding night` opens, shows, and closes time-limited night orders on that log. Run `/goodnight` and `/goodmorning` in the orchestrator session to collect the orders and report their use.
|
|
@@ -147,7 +147,7 @@ The stations' everyday steps are `ding` commands too, so they run the same caref
|
|
|
147
147
|
|
|
148
148
|
### 📜 The house rules
|
|
149
149
|
|
|
150
|
-
The rules every
|
|
150
|
+
The rules every role follows live in [kitchen/](https://github.com/917Dhj/dkitchen/blob/main/kitchen/README.md), one folder per part of the kitchen: the team (who owns what, tickets, reviews, when to stop and ask, with optional modules for run budgets and model prompts), the repo's code rules and checks, the runner, and the night shift for when you are away. The rules guard what comes next rather than clean up the past, and a change to a check says why in a `Guard-change:` commit trailer.
|
|
151
151
|
|
|
152
152
|
### 🧩 The skills
|
|
153
153
|
|
|
@@ -156,7 +156,7 @@ The plugin installs ten skills. The build skills set up one part of the kitchen
|
|
|
156
156
|
| Skill | What it does |
|
|
157
157
|
| --- | --- |
|
|
158
158
|
| `/setup-dkitchen` | The entry: checks the prerequisites, settles the language and what you need, and walks through the build skills below |
|
|
159
|
-
| `build-team` | The
|
|
159
|
+
| `build-team` | The roles, tickets, PR review, and watches; it can suggest extra design lines for a repo with several kinds of work |
|
|
160
160
|
| `build-repo` | Where code goes, changing modules in place, and the `ding check` gates in CI (Python repos) |
|
|
161
161
|
| `build-runner` | One resumable runner for work done item by item, such as evaluations and batch inference (Python repos) |
|
|
162
162
|
| `build-night` | Night orders and the orchestrator's log, so work keeps moving while you are away |
|
|
@@ -165,8 +165,8 @@ The everyday skills run while the kitchen works:
|
|
|
165
165
|
|
|
166
166
|
| Skill | When |
|
|
167
167
|
| --- | --- |
|
|
168
|
-
| `write-ticket` | Every time a
|
|
169
|
-
| `/shift-change` | When a
|
|
168
|
+
| `write-ticket` | Every time a role writes a ticket; the model reaches for it on its own |
|
|
169
|
+
| `/shift-change` | When a role's session is replaced by a fresh one |
|
|
170
170
|
| `/improve-kitchen` | Every couple of weeks: turns what keeps going wrong into checks, tools, or rules, and retires the text they replace |
|
|
171
171
|
| `/goodnight`, `/goodmorning` | Before you leave and when you are back |
|
|
172
172
|
|
|
@@ -2673,8 +2673,13 @@ def test_launch_captures_caller_session_environment_command_and_paths(tmp_path,
|
|
|
2673
2673
|
r"HOME=/caller/home\;", "XDG_STATE_HOME=" + str(cwd / "caller-state") + r"\;",
|
|
2674
2674
|
"PYTHONPATH="]
|
|
2675
2675
|
assert argv[-3:-1] == ["/bin/sh", "-c"]
|
|
2676
|
-
assert
|
|
2677
|
-
|
|
2676
|
+
assert "remain-on-exit" not in argv[-1]
|
|
2677
|
+
pipe = shlex.split(argv[-1].split(" && exec ", 1)[0])
|
|
2678
|
+
assert pipe[:5] == ["/fake/bin/tmux", "pipe-pane", "-o", "-t", "$TMUX_PANE"]
|
|
2679
|
+
log = cwd / "caller-state;" / "ding/launch-records" / shlex.split(pipe[5])[2].rsplit("/", 1)[1]
|
|
2680
|
+
assert shlex.split(pipe[5]) == ["cat", ">>", str(log)]
|
|
2681
|
+
assert ding.LAUNCH_LOG.fullmatch(log.name)["name"] == "CPU_193"
|
|
2682
|
+
assert log.read_bytes() == b"" and stat.S_IMODE(log.stat().st_mode) == 0o600
|
|
2678
2683
|
inner = shlex.split(argv[-1].split(" && exec ", 1)[1])
|
|
2679
2684
|
assert inner[:4] == ["/venv/bin/python", str(Path(ding.__file__).resolve()), "run", THREAD_ID]
|
|
2680
2685
|
assert inner[inner.index("--record") + 1] == str(cwd / "exit.jsonl")
|
|
@@ -2710,7 +2715,9 @@ def test_launch_materializes_message_once_and_defaults_to_unique_records(tmp_pat
|
|
|
2710
2715
|
record = Path(inner[inner.index("--record") + 1])
|
|
2711
2716
|
records_seen.append(record)
|
|
2712
2717
|
materialized = Path(inner[inner.index("--message-file") + 1])
|
|
2713
|
-
|
|
2718
|
+
log = record.parent / f"job-{record.stem}.log"
|
|
2719
|
+
assert log.exists()
|
|
2720
|
+
assert materialized.read_text() == (f"Task job exited; log: {log}; record: {record}" if text is None else text)
|
|
2714
2721
|
assert record.is_absolute()
|
|
2715
2722
|
assert record.parent == ding.run_registry().parent / "launch-records"
|
|
2716
2723
|
assert materialized.stem.removesuffix(".message") == record.stem
|
|
@@ -2763,6 +2770,80 @@ def test_launch_collision_does_not_retry_or_modify_tmux(monkeypatch, fake_tmux,
|
|
|
2763
2770
|
assert "duplicate session" in capsys.readouterr().err
|
|
2764
2771
|
|
|
2765
2772
|
|
|
2773
|
+
def launch_logs(directory, names, age_days):
|
|
2774
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
2775
|
+
paths = []
|
|
2776
|
+
for name in names:
|
|
2777
|
+
path = directory / f"{name}-{ding.uuid4()}.log"
|
|
2778
|
+
path.write_text("output")
|
|
2779
|
+
stamp = ding.time.time() - age_days * 86400
|
|
2780
|
+
ding.os.utime(path, (stamp, stamp))
|
|
2781
|
+
paths.append(path)
|
|
2782
|
+
return paths
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
def test_prune_launch_logs_keeps_fresh_open_and_foreign_files(tmp_path, monkeypatch):
|
|
2786
|
+
directory = tmp_path / "launch-records"
|
|
2787
|
+
old_done, old_open = launch_logs(directory, ["done", "still-open"], 20)
|
|
2788
|
+
(fresh,) = launch_logs(directory, ["fresh"], 1)
|
|
2789
|
+
foreign = directory / "notes.log"
|
|
2790
|
+
foreign.write_text("x")
|
|
2791
|
+
ding.os.utime(foreign, (0, 0))
|
|
2792
|
+
record = directory / f"{ding.uuid4()}.jsonl"
|
|
2793
|
+
record.write_text("{}")
|
|
2794
|
+
ding.os.utime(record, (0, 0))
|
|
2795
|
+
calls = []
|
|
2796
|
+
monkeypatch.setattr(ding.subprocess, "run", lambda argv, **kwargs: calls.append(argv) or SimpleNamespace(
|
|
2797
|
+
returncode=0, stdout="cloudflare_ssh\nding-still-open\n", stderr=""))
|
|
2798
|
+
ding.prune_launch_logs(directory, 14, "/fake/bin/tmux")
|
|
2799
|
+
assert calls == [["/fake/bin/tmux", "list-sessions", "-F", "#{session_name}"]]
|
|
2800
|
+
assert not old_done.exists()
|
|
2801
|
+
assert old_open.exists() and fresh.exists() and foreign.exists() and record.exists()
|
|
2802
|
+
|
|
2803
|
+
|
|
2804
|
+
def test_prune_launch_logs_without_a_tmux_server_deletes_old_logs(tmp_path, monkeypatch):
|
|
2805
|
+
(old,) = launch_logs(tmp_path, ["done"], 20)
|
|
2806
|
+
monkeypatch.setattr(ding.subprocess, "run", lambda argv, **kwargs: SimpleNamespace(
|
|
2807
|
+
returncode=1, stdout="", stderr="no server running on /tmp/tmux-0/default"))
|
|
2808
|
+
ding.prune_launch_logs(tmp_path, 14, "/fake/bin/tmux")
|
|
2809
|
+
assert not old.exists()
|
|
2810
|
+
|
|
2811
|
+
|
|
2812
|
+
@pytest.mark.parametrize("outcome", ["error", "timeout"])
|
|
2813
|
+
def test_prune_launch_logs_keeps_everything_when_tmux_cannot_answer(tmp_path, monkeypatch, capsys, outcome):
|
|
2814
|
+
(old,) = launch_logs(tmp_path, ["done"], 20)
|
|
2815
|
+
|
|
2816
|
+
def run(argv, **kwargs):
|
|
2817
|
+
if outcome == "timeout":
|
|
2818
|
+
raise subprocess.TimeoutExpired(argv, 10)
|
|
2819
|
+
return SimpleNamespace(returncode=1, stdout="", stderr="permission denied")
|
|
2820
|
+
|
|
2821
|
+
monkeypatch.setattr(ding.subprocess, "run", run)
|
|
2822
|
+
ding.prune_launch_logs(tmp_path, 14, "/fake/bin/tmux")
|
|
2823
|
+
assert old.exists()
|
|
2824
|
+
assert "launch logs not pruned" in capsys.readouterr().err
|
|
2825
|
+
|
|
2826
|
+
|
|
2827
|
+
@pytest.mark.parametrize("keep_days,age", [(0, 1000), (14, 1)])
|
|
2828
|
+
def test_prune_launch_logs_asks_tmux_only_when_a_log_is_due(tmp_path, monkeypatch, keep_days, age):
|
|
2829
|
+
(log,) = launch_logs(tmp_path, ["done"], age)
|
|
2830
|
+
monkeypatch.setattr(ding.subprocess, "run", lambda argv, **kwargs: pytest.fail("tmux was asked"))
|
|
2831
|
+
ding.prune_launch_logs(tmp_path, keep_days, "/fake/bin/tmux")
|
|
2832
|
+
assert log.exists()
|
|
2833
|
+
|
|
2834
|
+
|
|
2835
|
+
def test_launch_prunes_old_logs_with_configured_keep_days(tmp_path, monkeypatch, fake_tmux):
|
|
2836
|
+
monkeypatch.setenv("CODEX_THREAD_ID", THREAD_ID)
|
|
2837
|
+
monkeypatch.chdir(tmp_path)
|
|
2838
|
+
(tmp_path / ".dkitchen.toml").write_text("[launch]\nkeep_days = 30\n")
|
|
2839
|
+
directory = ding.run_registry().parent / "launch-records"
|
|
2840
|
+
(recent,) = launch_logs(directory, ["recent"], 20)
|
|
2841
|
+
(old,) = launch_logs(directory, ["old"], 40)
|
|
2842
|
+
assert ding.main(["launch", "job", "--", "task"]) == 0
|
|
2843
|
+
assert [argv[1] for argv, _ in fake_tmux] == ["list-sessions", "new-session"]
|
|
2844
|
+
assert recent.exists() and not old.exists()
|
|
2845
|
+
|
|
2846
|
+
|
|
2766
2847
|
def audit_process(pid, ppid=1, argv=None, age=1000, cpu=50, uid=None, state="S"):
|
|
2767
2848
|
return {"pid": pid, "ppid": ppid, "argv": argv or ["python", "train.py"],
|
|
2768
2849
|
"age": age, "cpu": cpu, "uid": ding.os.geteuid() if uid is None else uid, "state": state}
|
|
@@ -1002,6 +1002,8 @@ def test_launch_config_preserves_argv_and_defaults(tmp_path):
|
|
|
1002
1002
|
loaded = settings(tmp_path, '[launch]\npreflight = ["python", "", "two words"]')
|
|
1003
1003
|
assert loaded.launch.preflight == ("python", "", "two words")
|
|
1004
1004
|
assert loaded.launch.preflight_timeout == 300
|
|
1005
|
+
assert loaded.launch.keep_days == 14
|
|
1006
|
+
assert settings(tmp_path, "[launch]\nkeep_days = 0").launch.keep_days == 0
|
|
1005
1007
|
|
|
1006
1008
|
|
|
1007
1009
|
@pytest.mark.parametrize("text, error", [
|
|
@@ -1016,6 +1018,10 @@ def test_launch_config_preserves_argv_and_defaults(tmp_path):
|
|
|
1016
1018
|
('preflight_timeout = "300"', "positive finite"),
|
|
1017
1019
|
('preflight_timeout = inf', "positive finite"),
|
|
1018
1020
|
('preflight_timeout = nan', "positive finite"),
|
|
1021
|
+
('keep_days = -1', "nonnegative finite"),
|
|
1022
|
+
('keep_days = true', "nonnegative finite"),
|
|
1023
|
+
('keep_days = "14"', "nonnegative finite"),
|
|
1024
|
+
('keep_days = inf', "nonnegative finite"),
|
|
1019
1025
|
('prefligth = ["python"]', "unknown keys"),
|
|
1020
1026
|
])
|
|
1021
1027
|
def test_bad_launch_config_is_refused(tmp_path, text, error):
|
|
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
|
|
File without changes
|
|
File without changes
|