agent-lyceum 0.53.0 → 0.54.0
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/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ import { executeRunCleanup, planRunCleanup } from "./run-cleanup.js";
|
|
|
15
15
|
import { diagnoseProject, formatDoctor, preflightRuntimes, runtimesUsed } from "./doctor.js";
|
|
16
16
|
import { acquireProjectLock, forceUnlock, inspectRunLock, listRunLocks, listUnreadableRunLocks, LOCK_FILE, lockHolderAlive } from "./project-lock.js";
|
|
17
17
|
import { planWorkspace } from "./worktree.js";
|
|
18
|
-
import { loadRunState, newRunId, outcomeOf, resolveRun, roundLimit, roundsLabel, runLabel, slugify, uniqueName } from "./run-store.js";
|
|
18
|
+
import { loadRunState, newRunId, outcomeOf, pickRunName, resolveRun, roundLimit, roundsLabel, runLabel, slugify, uniqueName } from "./run-store.js";
|
|
19
19
|
import { printRun } from "./run-print.js";
|
|
20
20
|
import { exitCodeForOutcome, RUNTIMES } from "./schema.js";
|
|
21
21
|
import { absPath, assertName, NAME_RE, projectPaths, resolveHome } from "./paths.js";
|
|
@@ -285,7 +285,7 @@ program
|
|
|
285
285
|
.option("--task-file <path>", "read the task from a file")
|
|
286
286
|
.option("--agent <name>", "run only this member of the project, alone: it cannot mail teammates or ask you, and its own `done` ends the run")
|
|
287
287
|
.option("--name <name>", "name for this run (default: made from the task)")
|
|
288
|
-
.option("--tidy", "mark this run as a commit tidy (the web
|
|
288
|
+
.option("--tidy", "mark this run as a commit tidy (the web badge follows the run result and the console disables its controls; with --name, a name held by an unfinished tidy run gets the next free suffix, e.g. X-2)")
|
|
289
289
|
.option("--assume-defaults", "when the run stops to ask, use the suggested answer for every question that has one")
|
|
290
290
|
.action(async (task, opts) => {
|
|
291
291
|
try {
|
|
@@ -305,12 +305,34 @@ program
|
|
|
305
305
|
checked = onlyAgent(sp, opts.agent);
|
|
306
306
|
}
|
|
307
307
|
await preflight(checked);
|
|
308
|
-
const
|
|
308
|
+
const runs = listRuns(pr, Infinity);
|
|
309
|
+
const taken = runs.flatMap((r) => (r.state.name ? [r.state.name] : []));
|
|
310
|
+
let chosenName;
|
|
309
311
|
if (opts.name !== undefined) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
const requested = opts.name;
|
|
313
|
+
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(requested) || requested.length > 30)
|
|
314
|
+
fail(`Invalid run name "${requested}": use lowercase letters, digits and "-", at most 30 characters.`);
|
|
315
|
+
const nameTaken = taken.includes(requested);
|
|
316
|
+
const picked = pickRunName({
|
|
317
|
+
name: requested,
|
|
318
|
+
tidy: opts.tidy === true,
|
|
319
|
+
project: pr.name,
|
|
320
|
+
taken,
|
|
321
|
+
holders: nameTaken
|
|
322
|
+
? runs.flatMap((r) => {
|
|
323
|
+
const name = r.state.name;
|
|
324
|
+
if (typeof name !== "string" || name !== requested)
|
|
325
|
+
return [];
|
|
326
|
+
const live = runIsAlive(r.state, pr) && !r.state.end_reason;
|
|
327
|
+
return [{ name, tidy: r.state.tidy, outcome: r.state.outcome, end_reason: r.state.end_reason, state: r.state.end_reason ?? (live ? "running" : "interrupted"), live, run_id: r.state.run_id }];
|
|
328
|
+
})
|
|
329
|
+
: [],
|
|
330
|
+
});
|
|
331
|
+
if (!picked.ok)
|
|
332
|
+
fail(picked.error);
|
|
333
|
+
if (picked.note)
|
|
334
|
+
console.error(picked.note);
|
|
335
|
+
chosenName = picked.name;
|
|
314
336
|
}
|
|
315
337
|
const runId = newRunId();
|
|
316
338
|
const runDir = path.join(pr.paths.runs, runId);
|
|
@@ -325,7 +347,7 @@ program
|
|
|
325
347
|
if (prepared.source === "file")
|
|
326
348
|
for (const w of lintTaskContent(prepared.content))
|
|
327
349
|
console.error(`warning: task file ${w}`);
|
|
328
|
-
const name =
|
|
350
|
+
const name = chosenName ?? uniqueName(slugify(taskMessageBody(prepared).subject), taken);
|
|
329
351
|
summary = await runTeam({ project: pr, name, plan, task: prepared, runDir, soloAgent: opts.agent, tidy: opts.tidy, signal: cancel.signal });
|
|
330
352
|
}
|
|
331
353
|
finally {
|
package/dist/run-store.d.ts
CHANGED
|
@@ -225,6 +225,38 @@ export declare function outcomeOf(s: Pick<RunState, "outcome" | "end_reason">):
|
|
|
225
225
|
verified: boolean;
|
|
226
226
|
} | undefined;
|
|
227
227
|
export declare function slugify(text: string): string;
|
|
228
|
+
/** A named run, as `pickRunName` needs it. `live` is `runIsAlive(state, project) && !state.end_reason`. */
|
|
229
|
+
export type RunNameHolder = {
|
|
230
|
+
name: string;
|
|
231
|
+
tidy?: boolean;
|
|
232
|
+
outcome?: string;
|
|
233
|
+
/** The run's `end_reason`. Finished is `outcome === "completed"` and this is `"done"`. */
|
|
234
|
+
end_reason?: string;
|
|
235
|
+
/** Used in the note when `outcome` is absent (`end_reason`, or `interrupted` when the dispatcher is gone). */
|
|
236
|
+
state?: string;
|
|
237
|
+
live: boolean;
|
|
238
|
+
run_id: string;
|
|
239
|
+
};
|
|
240
|
+
export type RunNamePick = {
|
|
241
|
+
ok: true;
|
|
242
|
+
name: string;
|
|
243
|
+
note?: string;
|
|
244
|
+
} | {
|
|
245
|
+
ok: false;
|
|
246
|
+
error: string;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* The name a `run --name` should use. A free name stays. When this run is `--tidy` and every exact holder is an
|
|
250
|
+
* unfinished, not-live tidy run, the name yields to `uniqueName`. The note names the first exact holder
|
|
251
|
+
* (`listRuns` order, newest first). Every other collision keeps the existing "already exists" error.
|
|
252
|
+
*/
|
|
253
|
+
export declare function pickRunName(input: {
|
|
254
|
+
name: string;
|
|
255
|
+
tidy: boolean;
|
|
256
|
+
project: string;
|
|
257
|
+
taken: string[];
|
|
258
|
+
holders: RunNameHolder[];
|
|
259
|
+
}): RunNamePick;
|
|
228
260
|
/** `base`, or `base-2`, `base-3` … the first that is not in `taken`. */
|
|
229
261
|
export declare function uniqueName(base: string, taken: string[]): string;
|
|
230
262
|
/** How a run is named in output: `name (run_id)`, or just the id for a run without a name. */
|
package/dist/run-store.js
CHANGED
|
@@ -177,6 +177,29 @@ export function slugify(text) {
|
|
|
177
177
|
.replace(/-+$/g, "");
|
|
178
178
|
return s || "task";
|
|
179
179
|
}
|
|
180
|
+
/** Tidy by the flag or, for older runs, by a name containing "tidy". Not live, and not a finished success. */
|
|
181
|
+
function unfinishedTidyHolder(h) {
|
|
182
|
+
const tidy = h.tidy === true || /tidy/i.test(h.name);
|
|
183
|
+
const finished = h.outcome === "completed" && h.end_reason === "done";
|
|
184
|
+
return tidy && !finished && !h.live;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The name a `run --name` should use. A free name stays. When this run is `--tidy` and every exact holder is an
|
|
188
|
+
* unfinished, not-live tidy run, the name yields to `uniqueName`. The note names the first exact holder
|
|
189
|
+
* (`listRuns` order, newest first). Every other collision keeps the existing "already exists" error.
|
|
190
|
+
*/
|
|
191
|
+
export function pickRunName(input) {
|
|
192
|
+
if (!input.taken.includes(input.name))
|
|
193
|
+
return { ok: true, name: input.name };
|
|
194
|
+
const exact = input.holders.filter((h) => h.name === input.name);
|
|
195
|
+
if (input.tidy && exact.length > 0 && exact.every(unfinishedTidyHolder)) {
|
|
196
|
+
const holder = exact[0];
|
|
197
|
+
const next = uniqueName(input.name, input.taken);
|
|
198
|
+
const why = holder.outcome ?? holder.state ?? "unfinished";
|
|
199
|
+
return { ok: true, name: next, note: `note: "${input.name}" is held by an unfinished tidy run (${why}, ${holder.run_id}); this run is named "${next}".` };
|
|
200
|
+
}
|
|
201
|
+
return { ok: false, error: `A run named "${input.name}" already exists in project ${input.project}.` };
|
|
202
|
+
}
|
|
180
203
|
/** `base`, or `base-2`, `base-3` … the first that is not in `taken`. */
|
|
181
204
|
export function uniqueName(base, taken) {
|
|
182
205
|
if (!taken.includes(base))
|