@ethlete/agent-rules 0.1.0-next.48 → 0.1.0-next.49
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 +32 -0
- package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +1 -1
- package/content/mods/plugins/e2e-progress/hooks/progress.ts +40 -0
- package/content/mods/plugins/e2e-progress/hooks/register.tsx +6 -28
- package/content/mods/plugins/status-line/.claude-plugin/plugin.json +1 -1
- 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.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The `builder-idle-check` hook now counts agents that were started before a `/clear` and still run, read from the unfinished meta files in the session's `subagents/` directory.
|
|
8
|
+
- The Claude Code e2e-progress mod shows registered runs from the session’s project directory.
|
|
9
|
+
|
|
3
10
|
## 0.1.0-next.48
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -8,6 +8,9 @@ dev server does not count - and the queue (`plans/QUEUE.md`, rows owned by `Buil
|
|
|
8
8
|
rows without a wait reason, the stop is blocked and the reason names those rows, so
|
|
9
9
|
the turn goes on. The slot limit is `builderSlots` in the local config (default 4).
|
|
10
10
|
|
|
11
|
+
Agents started before a `/clear` are read from the meta files in the session's `subagents/`
|
|
12
|
+
directory (an unfinished meta whose launch is not in the transcript counts as running).
|
|
13
|
+
|
|
11
14
|
Running work comes from the transcript: every background Bash, Monitor and
|
|
12
15
|
async Agent start, minus every task-notification and every TaskStop for it. A
|
|
13
16
|
notification that says the agent "is waiting on its own background work" does not end it: the
|
|
@@ -234,6 +237,34 @@ def read_assistant_line(state, content):
|
|
|
234
237
|
state["done"].update(str(tool_input.get(key)) for key in ("task_id", "shell_id") if tool_input.get(key))
|
|
235
238
|
|
|
236
239
|
|
|
240
|
+
def read_earlier_agents(state, transcript_path):
|
|
241
|
+
"""Agents started before a /clear: their meta files sit in this session's subagents dir."""
|
|
242
|
+
directory = os.path.join(os.path.splitext(transcript_path)[0], "subagents")
|
|
243
|
+
try:
|
|
244
|
+
names = sorted(os.listdir(directory))
|
|
245
|
+
except OSError:
|
|
246
|
+
return
|
|
247
|
+
for name in names:
|
|
248
|
+
if not (name.startswith("agent-") and name.endswith(".meta.json")):
|
|
249
|
+
continue
|
|
250
|
+
agent_id = name[len("agent-") : -len(".meta.json")]
|
|
251
|
+
try:
|
|
252
|
+
with open(os.path.join(directory, name), encoding="utf-8") as f:
|
|
253
|
+
meta = json.load(f)
|
|
254
|
+
except (OSError, ValueError):
|
|
255
|
+
continue
|
|
256
|
+
tool_use_id = meta.get("toolUseId") if isinstance(meta, dict) else None
|
|
257
|
+
if not tool_use_id or meta.get("finished") or tool_use_id in state["tool_uses"] or agent_id in state["tasks"]:
|
|
258
|
+
continue
|
|
259
|
+
state["tasks"][agent_id] = {
|
|
260
|
+
"kind": "agent",
|
|
261
|
+
"tool_use_id": tool_use_id,
|
|
262
|
+
"label": meta.get("description", ""),
|
|
263
|
+
"watcher": False,
|
|
264
|
+
"ends": None,
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
|
|
237
268
|
def running_tasks(state):
|
|
238
269
|
now = state["now"]
|
|
239
270
|
return [
|
|
@@ -320,6 +351,7 @@ def main():
|
|
|
320
351
|
state = read_transcript(transcript_path, role_launch(roles))
|
|
321
352
|
if not state["builder"]:
|
|
322
353
|
return
|
|
354
|
+
read_earlier_agents(state, transcript_path)
|
|
323
355
|
running = running_tasks(state)
|
|
324
356
|
working = sum(1 for task in running if not task["watcher"])
|
|
325
357
|
slots = slot_limit(config)
|
|
@@ -110,3 +110,43 @@ export const parseUnit = (path: string, raw: string, mtimeMs: number, nowMs: num
|
|
|
110
110
|
firstDone: 0,
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
|
+
|
|
114
|
+
export const REGISTRY = '/tmp/ethlete-runs';
|
|
115
|
+
export const HIDE_AFTER_MS = 60_000;
|
|
116
|
+
|
|
117
|
+
type RegistryFileSystem = {
|
|
118
|
+
list(path: string): Promise<{ name: string; kind: string }[]>;
|
|
119
|
+
read(path: string): Promise<string>;
|
|
120
|
+
stat(path: string): Promise<{ mtimeMs: number }>;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
type RegistryEntry = { log: string; machine: string; label: string; pid: number; cwd?: string; endedAt?: number };
|
|
124
|
+
export type RegistryRun = { entry: RegistryEntry; mtimeMs: number };
|
|
125
|
+
|
|
126
|
+
type RegistryScope = { nowMs: number; projectRoot: string };
|
|
127
|
+
|
|
128
|
+
export async function registryRuns(
|
|
129
|
+
fs: RegistryFileSystem,
|
|
130
|
+
{ nowMs, projectRoot }: RegistryScope,
|
|
131
|
+
): Promise<RegistryRun[]> {
|
|
132
|
+
const root = projectRoot.replace(/\/+$/, '');
|
|
133
|
+
const files = await fs.list(REGISTRY).catch(() => []);
|
|
134
|
+
const found = await Promise.all(
|
|
135
|
+
files
|
|
136
|
+
.filter((f) => f.kind === 'file' && f.name.endsWith('.json'))
|
|
137
|
+
.map(async (f): Promise<RegistryRun | undefined> => {
|
|
138
|
+
const entry = await fs.read(`${REGISTRY}/${f.name}`).then(
|
|
139
|
+
(t) => JSON.parse(t) as RegistryEntry,
|
|
140
|
+
() => undefined,
|
|
141
|
+
);
|
|
142
|
+
if (!entry?.log || typeof entry.cwd !== 'string') return undefined;
|
|
143
|
+
if (entry.cwd !== root && !entry.cwd.startsWith(`${root}/`)) return undefined;
|
|
144
|
+
if (entry.endedAt === undefined && !(await fs.stat(`/proc/${entry.pid}`).catch(() => undefined)))
|
|
145
|
+
return undefined;
|
|
146
|
+
if (entry.endedAt !== undefined && nowMs - entry.endedAt > HIDE_AFTER_MS) return undefined;
|
|
147
|
+
const stat = await fs.stat(entry.log).catch(() => undefined);
|
|
148
|
+
return { entry, mtimeMs: stat?.mtimeMs ?? 0 };
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
151
|
+
return found.filter((r) => r !== undefined);
|
|
152
|
+
}
|
|
@@ -2,15 +2,14 @@ import { atom, read, update } from 'claude-code';
|
|
|
2
2
|
import type { EngineInterface, Register, Timer } from 'claude-code';
|
|
3
3
|
|
|
4
4
|
import type { Progress } from '../types';
|
|
5
|
-
import { FAIL_LINE, doneOf, parse, parseUnit, summary } from './progress';
|
|
5
|
+
import { FAIL_LINE, HIDE_AFTER_MS, REGISTRY, doneOf, parse, parseUnit, registryRuns, summary } from './progress';
|
|
6
|
+
import type { RegistryRun } from './progress';
|
|
6
7
|
|
|
7
8
|
const PANE = 'e2e-progress';
|
|
8
9
|
const HANDOFFS = ['.claude/handoffs', '.agents/handoffs'];
|
|
9
10
|
const WORKTREES = '.claude/worktrees';
|
|
10
|
-
const REGISTRY = '/tmp/ethlete-runs';
|
|
11
11
|
const TICK_MS = 5000;
|
|
12
12
|
const STALE_MS = 15_000;
|
|
13
|
-
const HIDE_AFTER_MS = 60_000;
|
|
14
13
|
const MIN_ETA_TESTS = 5;
|
|
15
14
|
const MIN_ETA_MS = 30_000;
|
|
16
15
|
const MAX_CANDIDATES = 12;
|
|
@@ -191,30 +190,6 @@ const shortLabel = (label: string) => {
|
|
|
191
190
|
const titleOfRun = (p: Progress) =>
|
|
192
191
|
`${p.machine ? `${p.machine} ` : ''}${p.label ? shortLabel(p.label) : nameOf(p.path)}`;
|
|
193
192
|
|
|
194
|
-
type RegistryEntry = { log: string; machine: string; label: string; pid: number; endedAt?: number };
|
|
195
|
-
type RegistryRun = { entry: RegistryEntry; mtimeMs: number };
|
|
196
|
-
|
|
197
|
-
async function registryRuns($: EngineInterface, nowMs: number): Promise<RegistryRun[]> {
|
|
198
|
-
const files = await $.fs.list(REGISTRY).catch(() => []);
|
|
199
|
-
const found = await Promise.all(
|
|
200
|
-
files
|
|
201
|
-
.filter((f) => f.kind === 'file' && f.name.endsWith('.json'))
|
|
202
|
-
.map(async (f): Promise<RegistryRun | undefined> => {
|
|
203
|
-
const entry = await $.fs.read(`${REGISTRY}/${f.name}`).then(
|
|
204
|
-
(t) => JSON.parse(t) as RegistryEntry,
|
|
205
|
-
() => undefined,
|
|
206
|
-
);
|
|
207
|
-
if (!entry?.log) return undefined;
|
|
208
|
-
if (entry.endedAt === undefined && !(await $.fs.stat(`/proc/${entry.pid}`).catch(() => undefined)))
|
|
209
|
-
return undefined;
|
|
210
|
-
if (entry.endedAt !== undefined && nowMs - entry.endedAt > HIDE_AFTER_MS) return undefined;
|
|
211
|
-
const stat = await $.fs.stat(entry.log).catch(() => undefined);
|
|
212
|
-
return { entry, mtimeMs: stat?.mtimeMs ?? 0 };
|
|
213
|
-
}),
|
|
214
|
-
);
|
|
215
|
-
return found.filter((r) => r !== undefined);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
193
|
async function progressOfRegistryRun(
|
|
219
194
|
$: EngineInterface,
|
|
220
195
|
{ entry, mtimeMs }: RegistryRun,
|
|
@@ -321,8 +296,11 @@ async function tick($: EngineInterface) {
|
|
|
321
296
|
next.push(await withRecords($, parsed, text));
|
|
322
297
|
}
|
|
323
298
|
if (!pinned) {
|
|
299
|
+
const root = await $.session.root();
|
|
300
|
+
const stat = await $.fs.stat(root, { resolve: true }).catch(() => undefined);
|
|
301
|
+
const projectRoot = stat?.realPath ?? root;
|
|
324
302
|
const known = new Set(next.map((p) => p.path));
|
|
325
|
-
for (const run of await registryRuns(
|
|
303
|
+
for (const run of await registryRuns($.fs, { nowMs, projectRoot })) {
|
|
326
304
|
if (known.has(run.entry.log)) continue;
|
|
327
305
|
next.push(await progressOfRegistryRun($, run, last.get(run.entry.log), nowMs));
|
|
328
306
|
}
|