@ethlete/agent-rules 0.1.0-next.52 → 0.1.0-next.53
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/CHANGELOG.md +7 -0
- package/content/hooks/builder-idle-check.py +56 -4
- package/content/mods/plugins/codex-runs/.claude-plugin/plugin.json +1 -1
- package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +1 -1
- package/content/mods/plugins/status-line/.claude-plugin/plugin.json +1 -1
- package/content/mods/plugins/usage-line/.claude-plugin/plugin.json +1 -1
- package/content/skills/handoff/SKILL.md +2 -0
- package/content/skills/handoff/save.md +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @ethlete/agent-rules
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.53
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The builder idle hook allows one slot while Codex has 20% or less of its 5h window left, and counts a row as taken when a running command names its ID.
|
|
8
|
+
- The handoff skill carries open questions to the user word for word into a self-restart, and the resumed session shows them first.
|
|
9
|
+
|
|
3
10
|
## 0.1.0-next.52
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -25,6 +25,9 @@ else are skipped. A session counts as a builder when it ran the `builder-agent`
|
|
|
25
25
|
|
|
26
26
|
A tmux agent session with a live Codex pane in this checkout counts as one slot, including
|
|
27
27
|
while Codex waits at its prompt. A builder starts these sessions outside the transcript.
|
|
28
|
+
While the newest Codex rate-limit sample (as `codex-limit` reads it from `$CODEX_HOME/sessions`) shows
|
|
29
|
+
20% or less of the 5h window left, or an exhausted week, the builder builds one slice at a time: the
|
|
30
|
+
slot limit is 1. A row counts as taken when a running task's description or command names its ID.
|
|
28
31
|
|
|
29
32
|
Fires at most once per idle stop chain: a stop that a Stop hook already
|
|
30
33
|
continued (`stop_hook_active`) passes.
|
|
@@ -39,8 +42,10 @@ root, "../" allowed; format "table" for a QUEUE.md table or "checkbox" for `- [
|
|
|
39
42
|
Fail-safe: any error exits 0 with no output.
|
|
40
43
|
"""
|
|
41
44
|
|
|
45
|
+
import glob
|
|
42
46
|
import json
|
|
43
47
|
import os
|
|
48
|
+
import time
|
|
44
49
|
import re
|
|
45
50
|
import subprocess
|
|
46
51
|
import sys
|
|
@@ -51,6 +56,8 @@ LOCAL_CONFIG_FILE = "ethlete-agents.config.local.json"
|
|
|
51
56
|
DEFAULT_QUEUES = [{"path": os.path.join("plans", "QUEUE.md"), "format": "table"}]
|
|
52
57
|
QUEUE_OWNER = "Builder"
|
|
53
58
|
DEFAULT_SLOTS = 4
|
|
59
|
+
CODEX_LOW_LEFT_PERCENT = 20
|
|
60
|
+
CODEX_SCAN_FILES = 12
|
|
54
61
|
EARLIER_TRANSCRIPT_WINDOW = 24 * 3600
|
|
55
62
|
DEFAULT_WAIT_PATTERNS = ("wartet auf", "Offen nur:")
|
|
56
63
|
DEFAULT_ROLES = ("builder", "coordinator")
|
|
@@ -113,6 +120,42 @@ def slot_limit(config):
|
|
|
113
120
|
return DEFAULT_SLOTS
|
|
114
121
|
|
|
115
122
|
|
|
123
|
+
def codex_sample():
|
|
124
|
+
sessions = os.path.join(os.environ.get("CODEX_HOME") or os.path.expanduser("~/.codex"), "sessions")
|
|
125
|
+
files = sorted(glob.glob(os.path.join(sessions, "**", "*.jsonl"), recursive=True), key=os.path.getmtime, reverse=True)
|
|
126
|
+
latest = None
|
|
127
|
+
for path in files[:CODEX_SCAN_FILES]:
|
|
128
|
+
with open(path, encoding="utf-8") as f:
|
|
129
|
+
for raw in f:
|
|
130
|
+
if '"rate_limits"' not in raw:
|
|
131
|
+
continue
|
|
132
|
+
try:
|
|
133
|
+
event = json.loads(raw)
|
|
134
|
+
except ValueError:
|
|
135
|
+
continue
|
|
136
|
+
limits = (event.get("payload") or {}).get("rate_limits") or {}
|
|
137
|
+
at = parse_time(event.get("timestamp"))
|
|
138
|
+
if limits.get("limit_id") == "codex" and limits.get("primary") and at and (not latest or at >= latest[0]):
|
|
139
|
+
latest = (at, limits)
|
|
140
|
+
return latest[1] if latest else None
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def used_percent(window, now):
|
|
144
|
+
if not isinstance(window, dict) or window.get("resets_at", 0) <= now:
|
|
145
|
+
return 0
|
|
146
|
+
return window.get("used_percent", 0)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def codex_low(now):
|
|
150
|
+
limits = codex_sample()
|
|
151
|
+
if not limits:
|
|
152
|
+
return False
|
|
153
|
+
return (
|
|
154
|
+
100 - used_percent(limits["primary"], now) <= CODEX_LOW_LEFT_PERCENT
|
|
155
|
+
or used_percent(limits.get("secondary"), now) >= 100
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
116
159
|
def builder_idle_config(config):
|
|
117
160
|
value = config.get("builderIdle")
|
|
118
161
|
return value if isinstance(value, dict) else {}
|
|
@@ -217,6 +260,7 @@ def read_user_line(state, line, content):
|
|
|
217
260
|
"kind": "command",
|
|
218
261
|
"tool_use_id": item.get("tool_use_id"),
|
|
219
262
|
"label": tool_input.get("description") or tool_input.get("command", "")[:80],
|
|
263
|
+
"command": tool_input.get("command", ""),
|
|
220
264
|
"watcher": is_watcher(tool_input.get("command", "")),
|
|
221
265
|
"ends": started + timeout / 1000 if started and isinstance(timeout, (int, float)) else None,
|
|
222
266
|
}
|
|
@@ -417,12 +461,19 @@ def open_builder_rows(root, sources, patterns):
|
|
|
417
461
|
return rows
|
|
418
462
|
|
|
419
463
|
|
|
420
|
-
def
|
|
464
|
+
def names_row(row, text, flags=0):
|
|
465
|
+
return re.search(rf"(?<![A-Za-z0-9]){re.escape(row.split(' ')[0])}(?![A-Za-z0-9])", text, flags)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def not_taken(rows, labels, commands):
|
|
421
469
|
return [
|
|
422
470
|
row
|
|
423
471
|
for row in rows
|
|
424
472
|
if row.startswith("(")
|
|
425
|
-
or not
|
|
473
|
+
or not (
|
|
474
|
+
any(names_row(row, label) for label in labels)
|
|
475
|
+
or any(names_row(row, command, re.I) for command in commands)
|
|
476
|
+
)
|
|
426
477
|
]
|
|
427
478
|
|
|
428
479
|
|
|
@@ -458,13 +509,14 @@ def main():
|
|
|
458
509
|
running = running_tasks(state)
|
|
459
510
|
codex = codex_runs(root)
|
|
460
511
|
working = sum(1 for task in running if not task["watcher"]) + len(codex)
|
|
461
|
-
slots = slot_limit(config)
|
|
512
|
+
slots = 1 if codex_low(time.time()) else slot_limit(config)
|
|
462
513
|
if working >= slots:
|
|
463
514
|
return
|
|
464
515
|
sources = queue_sources(settings)
|
|
465
516
|
patterns = string_list(settings.get("waitPatterns"), DEFAULT_WAIT_PATTERNS)
|
|
466
517
|
watchers = [task["label"] for task in running] + codex
|
|
467
|
-
|
|
518
|
+
commands = [task.get("command", "") for task in running]
|
|
519
|
+
rows = not_taken(open_builder_rows(root, sources, patterns), watchers, commands)
|
|
468
520
|
if not rows:
|
|
469
521
|
return
|
|
470
522
|
print(json.dumps({"decision": "block", "reason": reason_for(rows, watchers, working, slots, sources, patterns)}))
|
|
@@ -39,6 +39,8 @@ Before you save, or when the `context-warning` hook names handoff mode, read {%r
|
|
|
39
39
|
and stop.
|
|
40
40
|
2. Read the file fully. If its first line starts with `Restarted because:`, show that line to the
|
|
41
41
|
user first, then delete it from the file.
|
|
42
|
+
Then show each question under `## Open questions` to the user in full. It stays open until
|
|
43
|
+
the user answers it.
|
|
42
44
|
3. Verify reality still matches: current branch, `git status`, last commit. If
|
|
43
45
|
they diverge from the handoff (e.g. someone committed in between), say what
|
|
44
46
|
changed and adapt - the repo is the truth, the handoff is the guide. Read each
|
|
@@ -150,6 +150,8 @@ is true:
|
|
|
150
150
|
- Each self-reporting sub-agent that still runs is named in the handoff file, with its result
|
|
151
151
|
file.
|
|
152
152
|
- No answer you wait for is open: a peer session, a mailbox reply, a CI run.
|
|
153
|
+
- Each question to the user that has no answer yet is in the handoff file, word for word, under
|
|
154
|
+
`## Open questions`. The resumed session shows them to the user first.
|
|
153
155
|
- The tree is committed, or the handoff file names every uncommitted change.
|
|
154
156
|
- The handoff file is saved and its Next steps are concrete.
|
|
155
157
|
|