@miroshnik/elves 2026.1027.0 → 2026.1028.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/github/scripts/github.js +84 -35
- package/dist/spec/scripts/architecture.js +2 -2
- package/dist/spec/scripts/{harness-nn3hnqwn.js → harness-wcyv20e3.js} +1 -1
- package/dist/spec/scripts/{harness-t9bqz3st.js → harness-yh09fn5z.js} +27 -3
- package/dist/spec/scripts/harness.js +1 -1
- package/package.json +2 -2
- package/skills/github/locales/en.json +1 -1
- package/skills/github/locales/ru.json +1 -1
- package/skills/github/reference.md +19 -5
- package/skills/github/scripts/github.ts +112 -41
- package/skills/github/scripts/locale.ts +30 -1
- package/skills/spec/scripts/spec-diff.ts +14 -31
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import {
|
|
3
3
|
locale_default
|
|
4
|
-
} from "../../spec/scripts/harness-
|
|
4
|
+
} from "../../spec/scripts/harness-yh09fn5z.js";
|
|
5
5
|
|
|
6
6
|
// skills/github/scripts/github.ts
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
@@ -1726,16 +1726,6 @@ function projectChecked(io, slug) {
|
|
|
1726
1726
|
}
|
|
1727
1727
|
return true;
|
|
1728
1728
|
}
|
|
1729
|
-
function scenarioItems(body, heading) {
|
|
1730
|
-
const lines = body.replace(/\r\n/g, `
|
|
1731
|
-
`).split(`
|
|
1732
|
-
`);
|
|
1733
|
-
const start = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
|
|
1734
|
-
if (start < 0)
|
|
1735
|
-
return null;
|
|
1736
|
-
const end = lines.findIndex((l, k) => k > start && /^#{1,2}\s/.test(l));
|
|
1737
|
-
return lines.slice(start + 1, end < 0 ? undefined : end).map((l) => /^\s*\d+[.)]\s+(.+)$/.exec(l)?.[1]?.trim()).filter((x) => Boolean(x));
|
|
1738
|
-
}
|
|
1739
1729
|
function cmdTaskStart(io, slug, number, branch, resume = false) {
|
|
1740
1730
|
if (resume && branch !== undefined)
|
|
1741
1731
|
throw new GhError(`--resume continues the task's existing branch — without --branch`);
|
|
@@ -1773,7 +1763,7 @@ function cmdTaskStart(io, slug, number, branch, resume = false) {
|
|
|
1773
1763
|
if (!t.estimate && type)
|
|
1774
1764
|
runEstimate(io, slug, number, type);
|
|
1775
1765
|
const now = git(io, io.cwd, "branch", "--show-current").stdout.trim();
|
|
1776
|
-
const scenarios = scenarioItems(t.body
|
|
1766
|
+
const scenarios = locale_default.scenarioItems(t.body);
|
|
1777
1767
|
io.out(`Next: the session name — «#${number} ${t.title}»`);
|
|
1778
1768
|
if (resume && !here)
|
|
1779
1769
|
io.out(`Branch: continue ${parallel.join(", ")} — checked out in another worktree (git worktree list): work in that one; in none — git switch it here`);
|
|
@@ -2224,6 +2214,7 @@ function cmdTaskQueue(io, slug, o) {
|
|
|
2224
2214
|
if (o.epic !== undefined && o.tasks !== undefined)
|
|
2225
2215
|
throw new GhError("--epic or --tasks, not both: the group is the epic's open tasks or the ones named");
|
|
2226
2216
|
let numbers;
|
|
2217
|
+
let subs = null;
|
|
2227
2218
|
if (o.tasks !== undefined) {
|
|
2228
2219
|
if (!o.tasks.length)
|
|
2229
2220
|
throw new GhError("--tasks: the group's task numbers, comma-separated — --tasks 47,49");
|
|
@@ -2235,12 +2226,18 @@ function cmdTaskQueue(io, slug, o) {
|
|
|
2235
2226
|
if (epic.state !== "OPEN")
|
|
2236
2227
|
throw new GhError(`epic #${o.epic} is closed`);
|
|
2237
2228
|
numbers = epic.subIssues.filter((x) => x.state === "OPEN").map((x) => x.number);
|
|
2229
|
+
subs = new Set(epic.subIssues.map((x) => x.number));
|
|
2238
2230
|
} else {
|
|
2239
2231
|
const found = graphql(io, Q.IssueSearch, { q: `repo:${slug} is:issue is:open` }).search.nodes;
|
|
2240
2232
|
if (found.length >= 100)
|
|
2241
2233
|
io.out("○ the search gave 100 open tasks — the queue sees only them: narrow it with --epic");
|
|
2242
2234
|
numbers = found.filter((x) => x?.state === "OPEN").map((x) => x.number);
|
|
2243
2235
|
}
|
|
2236
|
+
const handed = handedOut(io, slug);
|
|
2237
|
+
if (o.tasks === undefined) {
|
|
2238
|
+
numbers = [...new Set([...numbers, ...handed.filter((h) => subs === null || subs.has(h.number)).map((h) => h.number)])];
|
|
2239
|
+
}
|
|
2240
|
+
const awaiting = awaitingCloseOf(io, slug, handed);
|
|
2244
2241
|
const recent = recentPrs(io, slug);
|
|
2245
2242
|
const openPr = openPrOf(io, slug, recent);
|
|
2246
2243
|
const args = [o.epic !== undefined && `--epic ${o.epic}`, o.tasks !== undefined && `--tasks ${numbers.join(",")}`, o.type !== undefined && `--type ${o.type}`, o.priority?.length && `--priority ${o.priority.join(",")}`].filter(Boolean).join(" ");
|
|
@@ -2256,20 +2253,20 @@ function cmdTaskQueue(io, slug, o) {
|
|
|
2256
2253
|
const pastBatch = (i) => prsOf(i).some((p) => (p.state === "OPEN" || p.merged) && p.base !== batch);
|
|
2257
2254
|
const release = batch === null ? undefined : releasePrOf(recent, batch);
|
|
2258
2255
|
const releasing = release?.state === "OPEN" ? release.number : null;
|
|
2259
|
-
const handed = handedOut(io, slug);
|
|
2260
2256
|
const states = new Map;
|
|
2261
2257
|
const read = openOf(io, slug);
|
|
2262
2258
|
const isOpen = (n) => states.has(n) ? states.get(n) === "OPEN" : read(n);
|
|
2263
2259
|
const ready = [];
|
|
2264
2260
|
const running = [];
|
|
2265
2261
|
const waiting = [];
|
|
2266
|
-
|
|
2262
|
+
const settled = [];
|
|
2267
2263
|
let holding = 0;
|
|
2268
2264
|
const past = [];
|
|
2269
2265
|
for (const n of numbers.sort((a, b) => a - b)) {
|
|
2270
2266
|
const i = loadIssue(io, slug, n);
|
|
2271
2267
|
states.set(i.number, i.state);
|
|
2272
|
-
|
|
2268
|
+
const closer = i.state === "OPEN" ? null : awaiting(i.number, i);
|
|
2269
|
+
if (i.state !== "OPEN" && closer === null)
|
|
2273
2270
|
continue;
|
|
2274
2271
|
const label = `#${i.number} ${q(i.title)}`;
|
|
2275
2272
|
if (isEpic(i, org)) {
|
|
@@ -2284,7 +2281,8 @@ function cmdTaskQueue(io, slug, o) {
|
|
|
2284
2281
|
const pr = openPr(i);
|
|
2285
2282
|
const merged = inBatch?.(i.number, i.prs);
|
|
2286
2283
|
const work = [
|
|
2287
|
-
|
|
2284
|
+
closer === null ? "" : `PR #${closer} merged and closed the issue — waits for the deploy and task close`,
|
|
2285
|
+
closer === null && status === N.status.inProgress ? q(N.status.inProgress) : "",
|
|
2288
2286
|
pr === undefined ? "" : `open PR #${pr} https://github.com/${slug}/pull/${pr}`,
|
|
2289
2287
|
merged === undefined ? "" : `PR #${merged} merged into ${batch} — the task closes with the batch's release`
|
|
2290
2288
|
].filter(Boolean);
|
|
@@ -2300,7 +2298,7 @@ function cmdTaskQueue(io, slug, o) {
|
|
|
2300
2298
|
if (work.length) {
|
|
2301
2299
|
running.push(`= ${label} — ${work.join(", ")}`);
|
|
2302
2300
|
if (merged !== undefined && pr === undefined)
|
|
2303
|
-
settled
|
|
2301
|
+
settled.push(i.number);
|
|
2304
2302
|
else if (batch === null)
|
|
2305
2303
|
holding++;
|
|
2306
2304
|
else if (pr !== undefined ? prBase(i, pr) === batch : merged === undefined && hand !== undefined && hand.executor !== "cloud" && !hand.main && !pastBatch(i))
|
|
@@ -2310,7 +2308,11 @@ function cmdTaskQueue(io, slug, o) {
|
|
|
2310
2308
|
continue;
|
|
2311
2309
|
}
|
|
2312
2310
|
const batched = (b) => inBatch !== null && b.repo.toLowerCase() === slug.toLowerCase() && inBatch(b.number) !== undefined;
|
|
2313
|
-
const
|
|
2311
|
+
const unclosed = (b) => b.state !== "OPEN" && b.repo.toLowerCase() === slug.toLowerCase() && awaiting(b.number) !== null;
|
|
2312
|
+
const blockers = [
|
|
2313
|
+
...i.blockers.filter((b) => b.state === "OPEN" && !batched(b)).map((b) => blockerRef(slug, b)),
|
|
2314
|
+
...i.blockers.filter(unclosed).map((b) => `#${b.number} (merged, not closed by task close)`)
|
|
2315
|
+
];
|
|
2314
2316
|
const external = i.labels.find((l) => locale_default.every((n) => n.labels.externalBlocker).includes(l));
|
|
2315
2317
|
if (status === N.status.done)
|
|
2316
2318
|
waiting.push(`○ ${label} — ${STATUS} ${q(status)}, but the task is open`);
|
|
@@ -2341,7 +2343,10 @@ ${batches.map((b) => `batch ${b.repo} ${b.branch}
|
|
|
2341
2343
|
} else
|
|
2342
2344
|
io.out("○ session not recognized (no CLAUDE_CODE_SESSION_ID) — not marked as a dispatcher: task status in the executors would pin their tasks");
|
|
2343
2345
|
appWorktreeWarning(io);
|
|
2344
|
-
pruneExecutors(io, slug, handed, isOpen);
|
|
2346
|
+
pruneExecutors(io, slug, handed, isOpen, awaiting);
|
|
2347
|
+
if (settled.length && checkoutOfRepo(io, originUrl(io), slug))
|
|
2348
|
+
for (const n of settled)
|
|
2349
|
+
takeDownStacks(io, n, true);
|
|
2345
2350
|
const group = o.tasks !== undefined ? `tasks ${numbers.map((n) => `#${n}`).join(", ")}` : null;
|
|
2346
2351
|
const scope = [o.epic !== undefined ? `epic #${o.epic}` : group ?? "open tasks", want && `type ${q(want)}`, o.priority?.length && `Priority ${o.priority.join("|")}`].filter(Boolean).join(", ");
|
|
2347
2352
|
io.out(`Queue ${slug} (${scope}): ready ${ready.length}, ${q(N.status.inProgress)} ${running.length}, not ready ${waiting.length}`);
|
|
@@ -2354,7 +2359,7 @@ ${batches.map((b) => `batch ${b.repo} ${b.branch}
|
|
|
2354
2359
|
for (const line of waiting)
|
|
2355
2360
|
io.out(line);
|
|
2356
2361
|
const releaseCommand = `bun --no-env-file ${import.meta.path} batch release --repo ${slug}`;
|
|
2357
|
-
const now = settled ? `; the owner's word to release now — ${releaseCommand}: what is merged into ${batch} goes, the live executors go on, no new ones till its merge` : "";
|
|
2362
|
+
const now = settled.length ? `; the owner's word to release now — ${releaseCommand}: what is merged into ${batch} goes, the live executors go on, no new ones till its merge` : "";
|
|
2358
2363
|
const ask = locale_default.autoProject(io.cwd ?? process.cwd()) ? "" : `; ${MERGE_ASK}`;
|
|
2359
2364
|
const checks = release && releasing !== null ? releaseChecks(io, slug, release) : null;
|
|
2360
2365
|
if (release && batch && checks?.state === "red") {
|
|
@@ -2364,9 +2369,9 @@ ${batches.map((b) => `batch ${b.repo} ${b.branch}
|
|
|
2364
2369
|
io.out(`Next: the release of ${batch} is open — PR #${releasing} https://github.com/${slug}/pull/${releasing}: no new executors till its merge, ` + `the live executors' PRs into ${batch} wait for it (pr premerge refuses the merge); its steps — ${releaseCommand} prints them; ` + `after each executor's answer — task queue again; ${SESSION_ARCHIVE}.`);
|
|
2365
2370
|
} else if (ready.length) {
|
|
2366
2371
|
io.out(`Next: each ready task above — a background subagent in its own worktree while fewer than ${QUEUE_EXECUTORS} run (a number from the request replaces it); ` + `the indented line is its whole prompt. After each executor's answer — task queue again: new tasks get in${ask}; ${SESSION_ARCHIVE}${now}.`);
|
|
2367
|
-
} else if (holding || !settled && running.length)
|
|
2372
|
+
} else if (holding || !settled.length && running.length)
|
|
2368
2373
|
io.out(`Next: no ready tasks — wait for the executors' answers; after each — task queue again${ask}; ${SESSION_ARCHIVE}${now}.`);
|
|
2369
|
-
else if (settled) {
|
|
2374
|
+
else if (settled.length) {
|
|
2370
2375
|
io.out(`Next: the batch ${batch} is complete — nothing ready, every task of the batch is merged into it: its release — ${releaseCommand}, ` + `once no executor of the batch is still at work${past.length ? `; past the batch — ${past.join(", ")}: they don't hold the release` : ""}; ${SESSION_ARCHIVE}.`);
|
|
2371
2376
|
} else {
|
|
2372
2377
|
const done = group ? ` The group (${group}) has nothing left — no new batch: a task outside it joins only by the owner's word, task queue --tasks with it.` : "";
|
|
@@ -2418,14 +2423,15 @@ function releaseChecks(io, slug, release) {
|
|
|
2418
2423
|
}
|
|
2419
2424
|
var TEST_FILE = /((?:[\w.@-]+\/)*[\w.@-]+\.(?:test|spec|e2e)\.[cm]?[jt]sx?)\b/;
|
|
2420
2425
|
var isTestFile = (p) => new RegExp(`^${TEST_FILE.source}$`).test(p);
|
|
2426
|
+
var ANSI = /\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b\[[0-?]*[ -/]*[@-~]|\u001b[@-Z\\-_]/g;
|
|
2421
2427
|
function failedFilesIn(log) {
|
|
2422
2428
|
const out = [];
|
|
2423
2429
|
const rel = (p) => p.replace(/^.*?\/work\/[^/]+\/[^/]+\//, "").replace(/^\.\//, "");
|
|
2424
2430
|
const header = new RegExp(`^\\s*/?${TEST_FILE.source}:$`);
|
|
2425
2431
|
let current = null;
|
|
2426
|
-
for (const raw of asTsc(log).split(`
|
|
2432
|
+
for (const raw of asTsc(log.replace(ANSI, "")).split(`
|
|
2427
2433
|
`)) {
|
|
2428
|
-
const line = raw.replace(
|
|
2434
|
+
const line = raw.replace(/^\d{4}-\d\d-\d\dT[\d:.]+Z ?/, "").trimEnd();
|
|
2429
2435
|
const file = header.exec(line);
|
|
2430
2436
|
if (file) {
|
|
2431
2437
|
current = rel(file[1]);
|
|
@@ -2444,7 +2450,7 @@ function failedFilesOf(io, slug, failed) {
|
|
|
2444
2450
|
for (const r of failed) {
|
|
2445
2451
|
let log;
|
|
2446
2452
|
try {
|
|
2447
|
-
log = io.gh(["api", `repos/${slug}/actions/jobs/${r.id}/logs
|
|
2453
|
+
log = io.gh(["api", `repos/${slug}/actions/jobs/${r.id}/logs`, "--allow-escape-sequences"]);
|
|
2448
2454
|
} catch (e) {
|
|
2449
2455
|
if (!(e instanceof GhError))
|
|
2450
2456
|
throw e;
|
|
@@ -2773,9 +2779,31 @@ function lockHolds(reason) {
|
|
|
2773
2779
|
}
|
|
2774
2780
|
}
|
|
2775
2781
|
var plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
2776
|
-
function pruneExecutors(io, slug, handed, isOpen) {
|
|
2782
|
+
function pruneExecutors(io, slug, handed, isOpen, awaiting = awaitingCloseOf(io, slug, handed)) {
|
|
2777
2783
|
const executors = handed.flatMap((h) => h.worktree === null ? [] : [{ number: h.number, worktree: realPath(h.worktree) }]);
|
|
2778
|
-
|
|
2784
|
+
const live = (n) => isOpen(n) || awaiting(n) !== null;
|
|
2785
|
+
pruneAgentWorktrees(io, slug, (dir) => executors.some((h) => h.worktree === realPath(dir) && live(h.number)), (n) => !live(n));
|
|
2786
|
+
}
|
|
2787
|
+
function awaitingCloseOf(io, slug, handed) {
|
|
2788
|
+
const memo = new Map;
|
|
2789
|
+
return (n, issue) => {
|
|
2790
|
+
if (!handed.some((h) => h.number === n))
|
|
2791
|
+
return null;
|
|
2792
|
+
if (!memo.has(n)) {
|
|
2793
|
+
let pr = null;
|
|
2794
|
+
try {
|
|
2795
|
+
const i = issue ?? loadIssue(io, slug, n);
|
|
2796
|
+
const closer = i.state === "CLOSED" && i.stateReason === "COMPLETED" ? i.prs.find((p) => p.merged && !isBatchBranch(p.base) && !isBatchBranch(p.head)) : undefined;
|
|
2797
|
+
if (closer && !tailOver(io, slug, n))
|
|
2798
|
+
pr = closer.number;
|
|
2799
|
+
} catch (e) {
|
|
2800
|
+
if (!(e instanceof GhError))
|
|
2801
|
+
throw e;
|
|
2802
|
+
}
|
|
2803
|
+
memo.set(n, pr);
|
|
2804
|
+
}
|
|
2805
|
+
return memo.get(n);
|
|
2806
|
+
};
|
|
2779
2807
|
}
|
|
2780
2808
|
function openOf(io, slug) {
|
|
2781
2809
|
const states = new Map;
|
|
@@ -3018,6 +3046,7 @@ function cmdTaskAssignment(io, slug, number, o = {}) {
|
|
|
3018
3046
|
repo: slug,
|
|
3019
3047
|
epic: issue.parent ? locale_default.fill(N.queue.epic, { epicWord: N.subagentPrompt.epic, epic: issue.parent.number }) : "",
|
|
3020
3048
|
script: `bun --no-env-file ${import.meta.path}`,
|
|
3049
|
+
taskEnv: `bun --no-env-file ${taskEnvScript(io)}`,
|
|
3021
3050
|
waitCi: `bash ${waitCi()}`,
|
|
3022
3051
|
inProgress: N.status.inProgress,
|
|
3023
3052
|
done: N.lastLine.done,
|
|
@@ -3600,7 +3629,7 @@ function cmdTaskFinish(io, slug, number, o) {
|
|
|
3600
3629
|
const dirty = git(io, io.cwd, "status", "--porcelain", "--untracked-files=no").stdout.trim();
|
|
3601
3630
|
if (dirty)
|
|
3602
3631
|
return stop(1, `! uncommitted changes in the checkout — the PR would go without them`, `the checks before a commit, git commit, then ${again}`);
|
|
3603
|
-
const base = open?.base ?? (
|
|
3632
|
+
const base = open?.base ?? finishBase(io, slug, number, found);
|
|
3604
3633
|
const fetched = git(io, io.cwd, "fetch", "-q", "origin", `+refs/heads/${base}:refs/remotes/origin/${base}`);
|
|
3605
3634
|
if (fetched.status !== 0)
|
|
3606
3635
|
throw new GhError(`git fetch origin ${base}: ${why(fetched)}`);
|
|
@@ -3608,6 +3637,11 @@ function cmdTaskFinish(io, slug, number, o) {
|
|
|
3608
3637
|
`).filter((l) => l.trim());
|
|
3609
3638
|
if (!commits.length)
|
|
3610
3639
|
return stop(1, `! no commits on ${branch} past origin/${base} — nothing to put into a PR`, `commit the task's work, then ${again}`);
|
|
3640
|
+
const applied = git(io, io.cwd, "cherry", `origin/${base}`, "HEAD").stdout.split(`
|
|
3641
|
+
`).filter((l) => l.startsWith("-")).length;
|
|
3642
|
+
if (applied) {
|
|
3643
|
+
return stop(1, `! ${applied} ${applied > 1 ? "commits" : "commit"} of ${branch} ${applied > 1 ? "are" : "is"} in origin/${base} already by the changes (a released batch's, a merged PR's) — the PR would take its title and decision labels from them`, `git rebase origin/${base} (it drops them), then ${again} (it pushes the rebased branch with --force-with-lease)`);
|
|
3644
|
+
}
|
|
3611
3645
|
const refused = pushTaskBranch(io, branch);
|
|
3612
3646
|
if (refused)
|
|
3613
3647
|
return stop(1, `! ${refused}`, `then ${again}`);
|
|
@@ -3661,6 +3695,18 @@ function cmdTaskFinish(io, slug, number, o) {
|
|
|
3661
3695
|
const yes = locale_default.autoProject(io.cwd ?? process.cwd()) ? "" : "the owner's «yes» (the project is without auto) — then ";
|
|
3662
3696
|
return stop(4, `✅ PR #${pr} is ready to merge`, `${yes}gh pr merge ${pr} --rebase — a separate call, no cd or pipeline (the owner's permission rule matches it); then ${again}${isBatchBranch(base) ? "" : " — in the background: it waits for the deploy"}`);
|
|
3663
3697
|
}
|
|
3698
|
+
function finishBase(io, slug, number, found) {
|
|
3699
|
+
const batch = handedPastBatch(io, slug, number) ? null : batchOf(io, slug);
|
|
3700
|
+
if (!batch)
|
|
3701
|
+
return found.base;
|
|
3702
|
+
const release = releasePrOf(found.recent, batch);
|
|
3703
|
+
if (release?.merged)
|
|
3704
|
+
return io.out(`○ ${batch} is released by PR #${release.number} — the PR goes into ${found.base}`), found.base;
|
|
3705
|
+
const listed = git(io, io.cwd, "ls-remote", "--heads", "origin", `refs/heads/${batch}`);
|
|
3706
|
+
if (listed.status === 0 && !listed.stdout.trim())
|
|
3707
|
+
return io.out(`○ ${batch} is gone from origin (released) — the PR goes into ${found.base}`), found.base;
|
|
3708
|
+
return batch;
|
|
3709
|
+
}
|
|
3664
3710
|
function tailOver(io, slug, number) {
|
|
3665
3711
|
if (inCloud(io))
|
|
3666
3712
|
return true;
|
|
@@ -3673,6 +3719,8 @@ function tailOver(io, slug, number) {
|
|
|
3673
3719
|
function finishMerged(io, slug, number, epicNumber, merged, f) {
|
|
3674
3720
|
if (isBatchBranch(merged.base)) {
|
|
3675
3721
|
io.out(`✅ PR #${merged.number} is merged into ${merged.base} — #${number} stays ${q(N.status.inProgress)} till the batch's release`);
|
|
3722
|
+
if (checkoutOfRepo(io, originUrl(io), slug))
|
|
3723
|
+
takeDownStacks(io, number);
|
|
3676
3724
|
io.out(`Next: nothing more for the task — no CI or deploy wait, no epic refresh and no task close: the dispatcher's batch release does them`);
|
|
3677
3725
|
return 0;
|
|
3678
3726
|
}
|
|
@@ -3787,7 +3835,8 @@ function renameBranch(io, slug, target) {
|
|
|
3787
3835
|
return false;
|
|
3788
3836
|
}
|
|
3789
3837
|
function unlinkedPrs(io, slug, number) {
|
|
3790
|
-
const
|
|
3838
|
+
const recent = recentPrs(io, slug);
|
|
3839
|
+
const { base, nodes } = recent;
|
|
3791
3840
|
const prs = [];
|
|
3792
3841
|
const batched = [];
|
|
3793
3842
|
for (const p of nodes) {
|
|
@@ -3799,7 +3848,7 @@ function unlinkedPrs(io, slug, number) {
|
|
|
3799
3848
|
if (why)
|
|
3800
3849
|
(into === base ? prs : batched).push({ number: p.number, state: p.state ?? "", merged: Boolean(p.merged), head, base: into, why });
|
|
3801
3850
|
}
|
|
3802
|
-
return { base, prs, batched };
|
|
3851
|
+
return { base, prs, batched, recent };
|
|
3803
3852
|
}
|
|
3804
3853
|
var estScript = (io) => io.env["ELVES_EST"] ?? path.resolve(import.meta.dir, "../../est/scripts/est.ts");
|
|
3805
3854
|
function originUrl(io) {
|
|
@@ -3807,13 +3856,13 @@ function originUrl(io) {
|
|
|
3807
3856
|
return remote.status === 0 ? remote.stdout : "";
|
|
3808
3857
|
}
|
|
3809
3858
|
var taskEnvScript = (io) => io.env["ELVES_TASK_ENV"] ?? path.resolve(import.meta.dir, "../../task-env/scripts/task-env.ts");
|
|
3810
|
-
function takeDownStacks(io, number) {
|
|
3859
|
+
function takeDownStacks(io, number, quiet = false) {
|
|
3811
3860
|
const script = taskEnvScript(io);
|
|
3812
3861
|
if (!existsSync(script))
|
|
3813
|
-
return io.out(`○ task stacks: task-env is not installed (${script})`);
|
|
3862
|
+
return quiet ? undefined : io.out(`○ task stacks: task-env is not installed (${script})`);
|
|
3814
3863
|
const r = (io.run ?? realRun)("bun", ["--no-env-file", script, "down", String(number)], io.cwd);
|
|
3815
3864
|
const lines = r.stdout.split(`
|
|
3816
|
-
`).filter((l) => l.trim());
|
|
3865
|
+
`).filter((l) => l.trim() && !(quiet && l.startsWith("○")));
|
|
3817
3866
|
for (const line of lines)
|
|
3818
3867
|
io.out(line);
|
|
3819
3868
|
if (r.status !== 0 && !lines.length)
|
|
@@ -4670,7 +4719,8 @@ Examples:
|
|
|
4670
4719
|
The tail of a task from its committed branch to its close, resumable: each call does what is ready within --timeout
|
|
4671
4720
|
(default ${FINISH_TIMEOUT} s), prints the state and the Next line, a repeat goes on from there. Before the merge: the task
|
|
4672
4721
|
branch pushed (a rebased one — --force-with-lease), the PR into the dispatcher's batch branch or the default branch
|
|
4673
|
-
(
|
|
4722
|
+
(a released batch — the default branch; commits of the branch already in the base by their changes — a stop: git
|
|
4723
|
+
rebase drops them; the title — --title, otherwise the branch type's first commit; the body — spec-diff and Closes #N; an existing PR —
|
|
4674
4724
|
its body updated), pr labels, the CI wait (ci-wait pr; none into a batch), pr premerge, then the merge command — a
|
|
4675
4725
|
separate gh pr merge <PR> --rebase. After the merge: the deploy wait on the merge SHA (ci-wait merged), the epic
|
|
4676
4726
|
refresh's mechanics and its subagent's prompt (once), task close once the report is on the epic; merged into a batch —
|
|
@@ -5143,7 +5193,6 @@ export {
|
|
|
5143
5193
|
questionItems,
|
|
5144
5194
|
realGh,
|
|
5145
5195
|
realRun,
|
|
5146
|
-
scenarioItems,
|
|
5147
5196
|
sectionNames,
|
|
5148
5197
|
sectionTopics,
|
|
5149
5198
|
sessionPin,
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
invariant2,
|
|
3
3
|
codeOnly2,
|
|
4
4
|
envNamesInCode2
|
|
5
|
-
} from "./harness-
|
|
5
|
+
} from "./harness-wcyv20e3.js";
|
|
6
6
|
import {
|
|
7
7
|
locale_default
|
|
8
|
-
} from "./harness-
|
|
8
|
+
} from "./harness-yh09fn5z.js";
|
|
9
9
|
|
|
10
10
|
// skills/spec/scripts/architecture.ts
|
|
11
11
|
import { readdirSync, readFileSync } from "node:fs";
|
|
@@ -108,7 +108,7 @@ var en_default = {
|
|
|
108
108
|
live: "- while any of your subagents works, don't answer: wait for their answers — a background subagent wakes you with its answer; an answer with live subagents looks like a failure, and the dispatcher would give the task to a second executor next to you. Can't wait — answer `waits for subagents: <which and what they do>`: it isn't `failed`, there will be no second executor;",
|
|
109
109
|
refresh: '- the epic refresh — the subagent `task actualize` prints, without a worktree of its own (in yours) and not in the background (`run_in_background: false`): its answer — in the same turn, then `{script} task close {number}`, and only then the answer to the dispatcher: once you answer, a worktree without changes is removed, and a background subagent is left without a directory; a task without a PR (a data edit, a reconciliation, research) — first close the issue as completed with a result comment: `gh issue close {number} --repo {repo} --reason completed --comment "<result>"`;',
|
|
110
110
|
batchLead: "{task} #{number} «{title}» in {repo}{epic}: you are an executor of the dispatcher session, the task goes into the batch `{batch}` — do the task whole by the canon, {mode}: `{script} task start {number} --branch <type>/{number}-<slug>` (the task's questions and its parallel work — inside it), the branch from a fresh origin/{batch}, not from main (`git fetch origin {batch}`, then the task branch on `origin/{batch}`), code and tests, the checks before a commit, PR into the batch (`gh pr create --base {batch}`), `pr premerge`, merge. No CI wait, no deploy, no epic refresh and no `task close`: the task stays «{inProgress}» till the batch's release — the dispatcher's, with one full CI run and one refresh per epic.",
|
|
111
|
-
batchWait: "- don't wait for CI: a PR into the batch runs none — its gate is the checks before a commit by the canon (`elves precommit --base origin/<batch branch>`: `lint`, `typecheck`, `test:spec`, the affected tests — `docs/testing.md`) and `pr premerge` (the fast checks on the merge, if the batch moved on); after its code 0 — `gh pr merge <PR> --rebase` without a CI wait; the full run and the deploy are the release's, nothing to wait for after the merge;",
|
|
111
|
+
batchWait: "- don't wait for CI: a PR into the batch runs none — its gate is the checks before a commit by the canon (`elves precommit --base origin/<batch branch>`: `lint`, `typecheck`, `test:spec`, the affected tests — `docs/testing.md`) and `pr premerge` (the fast checks on the merge, if the batch moved on); after its code 0 — `gh pr merge <PR> --rebase` without a CI wait; the full run and the deploy are the release's, nothing to wait for after the merge, but before the answer take the task's stacks down (`{taskEnv} down {number}`, unsandboxed: Docker): the task waits for the release, its stack would load the machine till then;",
|
|
112
112
|
batchRefresh: "- the epic refresh and `task close` aren't yours: both are the batch's release — one refresh per epic of its tasks, then `task close` of each, the dispatcher's; a task without a PR (a data edit, a reconciliation, research) isn't in the batch — close the issue as completed with a result comment: `gh issue close {number} --repo {repo} --reason completed --comment \"<result>\"`, then the epic refresh — the subagent `task actualize {number}` prints, without a worktree of its own (in yours) and not in the background (`run_in_background: false`): its answer — in the same turn, then `{script} task close {number}`, and only then the answer to the dispatcher: once you answer, a worktree without changes is removed, and a background subagent is left without a directory;",
|
|
113
113
|
bypass: "- the task goes past the dispatcher's batch `{batch}` — the owner's word: the task branch from a fresh origin/main, not from the batch, the PR into the default branch (not `--base {batch}`) with the full CI, the deploy, the epic refresh and `task close` — yours, as in a project without batches; the batch's release doesn't wait for you;",
|
|
114
114
|
fixLead: '{task} #{number} «{title}» in {repo}{epic}: you are an executor of the dispatcher session — a fix in the batch `{batch}`: its release PR #{release} is red ({checks}), and the task, merged into the batch already, is named guilty — fix it in the batch by the canon, {mode}: `{script} task status {number} "{inProgress}" --branch fix/{number}-<slug>`, a new branch from a fresh origin/{batch} (`git fetch origin {batch}`, then the branch on `origin/{batch}`){previous}, the cause by the failed checks (`gh pr checks {release}`, their logs), the fix and its test, commits with `Refs #{number}`, the checks before a commit, PR into the batch (`gh pr create --base {batch}`, `Refs #{number}` in the body), `pr premerge` (it lets the guilty task\'s PR through the open release), merge. No CI wait, no deploy, no epic refresh and no `task close`: after the merge the dispatcher runs the release again — the full run on the same PR #{release}.',
|
|
@@ -588,7 +588,7 @@ var ru_default = {
|
|
|
588
588
|
live: "- пока работает хоть один твой субагент, ответ не отдавай: жди их ответов — фоновый субагент будит тебя своим ответом; ответ при живых субагентах выглядит провалом, и диспетчер отдал бы задачу второму исполнителю рядом с тобой. Ждать нельзя — ответь `ждёт субагентов: <какие и что делают>`: это не «сломалось», второго исполнителя не будет;",
|
|
589
589
|
refresh: '- актуализация эпика — субагент, которого печатает `task actualize`, без своего worktree (в твоём) и не в фоне (`run_in_background: false`): его ответ — в том же ходе, затем `{script} task close {number}`, и только потом ответ диспетчеру: стоит тебе ответить, worktree без изменений убирают, и фоновый субагент остаётся без каталога; у задачи без PR (правка данных, сверка, исследование) — сначала закрой issue как выполненную с итоговым комментарием: `gh issue close {number} --repo {repo} --reason completed --comment "<итог>"`;',
|
|
590
590
|
batchLead: "{task} #{number} «{title}» в {repo}{epic}: ты исполнитель сессии-диспетчера, задача идёт в пачку `{batch}` — сделай задачу целиком по канону, {mode}: `{script} task start {number} --branch <тип>/{number}-<slug>` (вопросы задачи и её параллельная работа — в нём), ветка от свежего origin/{batch}, а не от main (`git fetch origin {batch}`, затем ветка задачи на `origin/{batch}`), код и тесты, проверки перед коммитом, PR в пачку (`gh pr create --base {batch}`), `pr premerge`, мерж. Ожидания CI, деплоя, актуализации эпика и `task close` нет: задача — «{inProgress}» до выпуска пачки, его делает диспетчер — с одним полным прогоном CI и одной актуализацией на эпик.",
|
|
591
|
-
batchWait: "- CI не жди: PR в пачку его не запускает — его ворота — проверки перед коммитом по канону (`elves precommit --base origin/<ветка пачки>`: `lint`, `typecheck`, `test:spec`, затронутые тесты — `docs/testing.md`) и `pr premerge` (быстрые проверки на слиянии, если пачка ушла вперёд); после его кода 0 — `gh pr merge <PR> --rebase` без ожидания CI; полный прогон и деплой — у выпуска, после мержа ждать
|
|
591
|
+
batchWait: "- CI не жди: PR в пачку его не запускает — его ворота — проверки перед коммитом по канону (`elves precommit --base origin/<ветка пачки>`: `lint`, `typecheck`, `test:spec`, затронутые тесты — `docs/testing.md`) и `pr premerge` (быстрые проверки на слиянии, если пачка ушла вперёд); после его кода 0 — `gh pr merge <PR> --rebase` без ожидания CI; полный прогон и деплой — у выпуска, после мержа ждать нечего, но до ответа сними стеки задачи (`{taskEnv} down {number}`, вне песочницы: Docker): задача ждёт выпуска, а её стек до него грузил бы машину;",
|
|
592
592
|
batchRefresh: '- актуализация эпика и `task close` — не твои: обе — у выпуска пачки, одна актуализация на каждый эпик её задач, затем `task close` каждой, их делает диспетчер; задача без PR (правка данных, сверка, исследование) в пачку не идёт — закрой issue как выполненную с итоговым комментарием: `gh issue close {number} --repo {repo} --reason completed --comment "<итог>"`, затем актуализация эпика — субагент, которого печатает `task actualize {number}`, без своего worktree (в твоём) и не в фоне (`run_in_background: false`): его ответ — в том же ходе, затем `{script} task close {number}`, и только потом ответ диспетчеру: стоит тебе ответить, worktree без изменений убирают, и фоновый субагент остаётся без каталога;',
|
|
593
593
|
bypass: "- задача идёт мимо пачки диспетчера `{batch}` — слово владельца: ветка задачи от свежего origin/main, а не от пачки, PR в ветку по умолчанию (не `--base {batch}`) с полным CI, деплой, актуализация эпика и `task close` — твои, как в проекте без пачек; выпуск пачки тебя не ждёт;",
|
|
594
594
|
fixLead: '{task} #{number} «{title}» в {repo}{epic}: ты исполнитель сессии-диспетчера — починка в пачке `{batch}`: её PR выпуска #{release} красный ({checks}), а задача, уже влитая в пачку, названа виновной — почини её в пачке по канону, {mode}: `{script} task status {number} "{inProgress}" --branch fix/{number}-<slug>`, новая ветка от свежего origin/{batch} (`git fetch origin {batch}`, затем ветка на `origin/{batch}`){previous}, причина — по упавшим проверкам (`gh pr checks {release}`, их логи), починка и её тест, коммиты с `Refs #{number}`, проверки перед коммитом, PR в пачку (`gh pr create --base {batch}`, в теле `Refs #{number}`), `pr premerge` (PR виновной задачи он пропускает при открытом выпуске), мерж. Ожидания CI, деплоя, актуализации эпика и `task close` нет: после мержа диспетчер гонит выпуск заново — полный прогон на том же PR #{release}.',
|
|
@@ -1027,6 +1027,30 @@ function count(language, forms, n) {
|
|
|
1027
1027
|
function escapeRe(text) {
|
|
1028
1028
|
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1029
1029
|
}
|
|
1030
|
-
|
|
1030
|
+
function scenarioItems(md) {
|
|
1031
|
+
let fence = null;
|
|
1032
|
+
const lines = md.split(/\r?\n/).map((l) => {
|
|
1033
|
+
const f = /^\s*(`{3,}|~{3,})/.exec(l)?.[1];
|
|
1034
|
+
if (f && (fence === null || f[0] === fence[0] && f.length >= fence.length)) {
|
|
1035
|
+
fence = fence === null ? f : null;
|
|
1036
|
+
return "";
|
|
1037
|
+
}
|
|
1038
|
+
return fence === null ? l : "";
|
|
1039
|
+
});
|
|
1040
|
+
const heads = every((n) => n.sections.scenarios).map((h) => new RegExp(`^${escapeRe(h).replace(/ +/g, "\\s+")}\\s*$`));
|
|
1041
|
+
const start = lines.findIndex((l) => heads.some((h) => h.test(l.trim())));
|
|
1042
|
+
if (start < 0)
|
|
1043
|
+
return null;
|
|
1044
|
+
const out = [];
|
|
1045
|
+
for (const l of lines.slice(start + 1)) {
|
|
1046
|
+
if (/^#{1,2}\s/.test(l))
|
|
1047
|
+
break;
|
|
1048
|
+
const m = /^\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?(.+?)\s*$/.exec(l);
|
|
1049
|
+
if (m)
|
|
1050
|
+
out.push(m[1]);
|
|
1051
|
+
}
|
|
1052
|
+
return out;
|
|
1053
|
+
}
|
|
1054
|
+
var locale_default = { LANGUAGE_CODE, DEFAULT_LANGUAGE, projectRoot, manifestOf, projectLanguage, missingManifest, batchProject, autoProject, names, languages, everyNames, every, fill, plural, count, escapeRe, scenarioItems };
|
|
1031
1055
|
|
|
1032
1056
|
export { locale_default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miroshnik/elves",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1028.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Elves — a development flow with AI agents: shared rules and skills for any agent; install — bunx @miroshnik/elves install -g; the installer and skill scripts — TypeScript under Bun, tests — bun test in tests/",
|
|
6
6
|
"repository": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"eslint-plugin-boundaries": "^7.2.0",
|
|
73
73
|
"knip": "^6.41.0"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "4dda0139a91991ebff3648aafbc228ecdeb29e37"
|
|
76
76
|
}
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"live": "- while any of your subagents works, don't answer: wait for their answers — a background subagent wakes you with its answer; an answer with live subagents looks like a failure, and the dispatcher would give the task to a second executor next to you. Can't wait — answer `waits for subagents: <which and what they do>`: it isn't `failed`, there will be no second executor;",
|
|
105
105
|
"refresh": "- the epic refresh — the subagent `task actualize` prints, without a worktree of its own (in yours) and not in the background (`run_in_background: false`): its answer — in the same turn, then `{script} task close {number}`, and only then the answer to the dispatcher: once you answer, a worktree without changes is removed, and a background subagent is left without a directory; a task without a PR (a data edit, a reconciliation, research) — first close the issue as completed with a result comment: `gh issue close {number} --repo {repo} --reason completed --comment \"<result>\"`;",
|
|
106
106
|
"batchLead": "{task} #{number} «{title}» in {repo}{epic}: you are an executor of the dispatcher session, the task goes into the batch `{batch}` — do the task whole by the canon, {mode}: `{script} task start {number} --branch <type>/{number}-<slug>` (the task's questions and its parallel work — inside it), the branch from a fresh origin/{batch}, not from main (`git fetch origin {batch}`, then the task branch on `origin/{batch}`), code and tests, the checks before a commit, PR into the batch (`gh pr create --base {batch}`), `pr premerge`, merge. No CI wait, no deploy, no epic refresh and no `task close`: the task stays «{inProgress}» till the batch's release — the dispatcher's, with one full CI run and one refresh per epic.",
|
|
107
|
-
"batchWait": "- don't wait for CI: a PR into the batch runs none — its gate is the checks before a commit by the canon (`elves precommit --base origin/<batch branch>`: `lint`, `typecheck`, `test:spec`, the affected tests — `docs/testing.md`) and `pr premerge` (the fast checks on the merge, if the batch moved on); after its code 0 — `gh pr merge <PR> --rebase` without a CI wait; the full run and the deploy are the release's, nothing to wait for after the merge;",
|
|
107
|
+
"batchWait": "- don't wait for CI: a PR into the batch runs none — its gate is the checks before a commit by the canon (`elves precommit --base origin/<batch branch>`: `lint`, `typecheck`, `test:spec`, the affected tests — `docs/testing.md`) and `pr premerge` (the fast checks on the merge, if the batch moved on); after its code 0 — `gh pr merge <PR> --rebase` without a CI wait; the full run and the deploy are the release's, nothing to wait for after the merge, but before the answer take the task's stacks down (`{taskEnv} down {number}`, unsandboxed: Docker): the task waits for the release, its stack would load the machine till then;",
|
|
108
108
|
"batchRefresh": "- the epic refresh and `task close` aren't yours: both are the batch's release — one refresh per epic of its tasks, then `task close` of each, the dispatcher's; a task without a PR (a data edit, a reconciliation, research) isn't in the batch — close the issue as completed with a result comment: `gh issue close {number} --repo {repo} --reason completed --comment \"<result>\"`, then the epic refresh — the subagent `task actualize {number}` prints, without a worktree of its own (in yours) and not in the background (`run_in_background: false`): its answer — in the same turn, then `{script} task close {number}`, and only then the answer to the dispatcher: once you answer, a worktree without changes is removed, and a background subagent is left without a directory;",
|
|
109
109
|
"bypass": "- the task goes past the dispatcher's batch `{batch}` — the owner's word: the task branch from a fresh origin/main, not from the batch, the PR into the default branch (not `--base {batch}`) with the full CI, the deploy, the epic refresh and `task close` — yours, as in a project without batches; the batch's release doesn't wait for you;",
|
|
110
110
|
"fixLead": "{task} #{number} «{title}» in {repo}{epic}: you are an executor of the dispatcher session — a fix in the batch `{batch}`: its release PR #{release} is red ({checks}), and the task, merged into the batch already, is named guilty — fix it in the batch by the canon, {mode}: `{script} task status {number} \"{inProgress}\" --branch fix/{number}-<slug>`, a new branch from a fresh origin/{batch} (`git fetch origin {batch}`, then the branch on `origin/{batch}`){previous}, the cause by the failed checks (`gh pr checks {release}`, their logs), the fix and its test, commits with `Refs #{number}`, the checks before a commit, PR into the batch (`gh pr create --base {batch}`, `Refs #{number}` in the body), `pr premerge` (it lets the guilty task's PR through the open release), merge. No CI wait, no deploy, no epic refresh and no `task close`: after the merge the dispatcher runs the release again — the full run on the same PR #{release}.",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"live": "- пока работает хоть один твой субагент, ответ не отдавай: жди их ответов — фоновый субагент будит тебя своим ответом; ответ при живых субагентах выглядит провалом, и диспетчер отдал бы задачу второму исполнителю рядом с тобой. Ждать нельзя — ответь `ждёт субагентов: <какие и что делают>`: это не «сломалось», второго исполнителя не будет;",
|
|
105
105
|
"refresh": "- актуализация эпика — субагент, которого печатает `task actualize`, без своего worktree (в твоём) и не в фоне (`run_in_background: false`): его ответ — в том же ходе, затем `{script} task close {number}`, и только потом ответ диспетчеру: стоит тебе ответить, worktree без изменений убирают, и фоновый субагент остаётся без каталога; у задачи без PR (правка данных, сверка, исследование) — сначала закрой issue как выполненную с итоговым комментарием: `gh issue close {number} --repo {repo} --reason completed --comment \"<итог>\"`;",
|
|
106
106
|
"batchLead": "{task} #{number} «{title}» в {repo}{epic}: ты исполнитель сессии-диспетчера, задача идёт в пачку `{batch}` — сделай задачу целиком по канону, {mode}: `{script} task start {number} --branch <тип>/{number}-<slug>` (вопросы задачи и её параллельная работа — в нём), ветка от свежего origin/{batch}, а не от main (`git fetch origin {batch}`, затем ветка задачи на `origin/{batch}`), код и тесты, проверки перед коммитом, PR в пачку (`gh pr create --base {batch}`), `pr premerge`, мерж. Ожидания CI, деплоя, актуализации эпика и `task close` нет: задача — «{inProgress}» до выпуска пачки, его делает диспетчер — с одним полным прогоном CI и одной актуализацией на эпик.",
|
|
107
|
-
"batchWait": "- CI не жди: PR в пачку его не запускает — его ворота — проверки перед коммитом по канону (`elves precommit --base origin/<ветка пачки>`: `lint`, `typecheck`, `test:spec`, затронутые тесты — `docs/testing.md`) и `pr premerge` (быстрые проверки на слиянии, если пачка ушла вперёд); после его кода 0 — `gh pr merge <PR> --rebase` без ожидания CI; полный прогон и деплой — у выпуска, после мержа ждать
|
|
107
|
+
"batchWait": "- CI не жди: PR в пачку его не запускает — его ворота — проверки перед коммитом по канону (`elves precommit --base origin/<ветка пачки>`: `lint`, `typecheck`, `test:spec`, затронутые тесты — `docs/testing.md`) и `pr premerge` (быстрые проверки на слиянии, если пачка ушла вперёд); после его кода 0 — `gh pr merge <PR> --rebase` без ожидания CI; полный прогон и деплой — у выпуска, после мержа ждать нечего, но до ответа сними стеки задачи (`{taskEnv} down {number}`, вне песочницы: Docker): задача ждёт выпуска, а её стек до него грузил бы машину;",
|
|
108
108
|
"batchRefresh": "- актуализация эпика и `task close` — не твои: обе — у выпуска пачки, одна актуализация на каждый эпик её задач, затем `task close` каждой, их делает диспетчер; задача без PR (правка данных, сверка, исследование) в пачку не идёт — закрой issue как выполненную с итоговым комментарием: `gh issue close {number} --repo {repo} --reason completed --comment \"<итог>\"`, затем актуализация эпика — субагент, которого печатает `task actualize {number}`, без своего worktree (в твоём) и не в фоне (`run_in_background: false`): его ответ — в том же ходе, затем `{script} task close {number}`, и только потом ответ диспетчеру: стоит тебе ответить, worktree без изменений убирают, и фоновый субагент остаётся без каталога;",
|
|
109
109
|
"bypass": "- задача идёт мимо пачки диспетчера `{batch}` — слово владельца: ветка задачи от свежего origin/main, а не от пачки, PR в ветку по умолчанию (не `--base {batch}`) с полным CI, деплой, актуализация эпика и `task close` — твои, как в проекте без пачек; выпуск пачки тебя не ждёт;",
|
|
110
110
|
"fixLead": "{task} #{number} «{title}» в {repo}{epic}: ты исполнитель сессии-диспетчера — починка в пачке `{batch}`: её PR выпуска #{release} красный ({checks}), а задача, уже влитая в пачку, названа виновной — почини её в пачке по канону, {mode}: `{script} task status {number} \"{inProgress}\" --branch fix/{number}-<slug>`, новая ветка от свежего origin/{batch} (`git fetch origin {batch}`, затем ветка на `origin/{batch}`){previous}, причина — по упавшим проверкам (`gh pr checks {release}`, их логи), починка и её тест, коммиты с `Refs #{number}`, проверки перед коммитом, PR в пачку (`gh pr create --base {batch}`, в теле `Refs #{number}`), `pr premerge` (PR виновной задачи он пропускает при открытом выпуске), мерж. Ожидания CI, деплоя, актуализации эпика и `task close` нет: после мержа диспетчер гонит выпуск заново — полный прогон на том же PR #{release}.",
|
|
@@ -672,7 +672,11 @@ subagent). Before the merge: uncommitted changes or no commits past
|
|
|
672
672
|
`origin/<base>` — code 1; the task branch pushed (origin has the same
|
|
673
673
|
commits rebased — `--force-with-lease` on its head; commits that aren't
|
|
674
674
|
here — code 1), no `-u`; the PR into the dispatcher's batch branch, otherwise
|
|
675
|
-
|
|
675
|
+
— and when that batch is released (its release PR merged, its branch gone
|
|
676
|
+
from origin, #768) — the default branch; commits of the branch already in
|
|
677
|
+
the base by their changes (a released batch's, rebased with other SHAs) —
|
|
678
|
+
code 1 before the PR: `git rebase origin/<base>` drops them, otherwise the
|
|
679
|
+
PR's title and decision labels would be theirs; the title — `--title`, otherwise the first commit of the
|
|
676
680
|
branch type, a conventional commit; the body — `spec-diff` and `Closes #N`
|
|
677
681
|
(an existing PR — the body updated); `pr labels`; `ci-wait pr` (none into a
|
|
678
682
|
batch): FAIL, a conflict — code 1 with the step; `pr premerge` — its code 1
|
|
@@ -916,8 +920,12 @@ work, no open blockers — another repository's named `owner/repo#N` —, no
|
|
|
916
920
|
line — its executor's prompt, «Task #N …» in the project language (`est` links
|
|
917
921
|
the subagent's work by it); then `=` lines — in work: In progress, an open PR
|
|
918
922
|
(linked, or by the task branch and "Closes #N" among recent PRs) with its link,
|
|
919
|
-
handed out to an executor of this session
|
|
920
|
-
|
|
923
|
+
handed out to an executor of this session, a hand-out's task closed by its PR's
|
|
924
|
+
merge («Closes #N») before `task close` — «waits for the deploy and task close»
|
|
925
|
+
(#769: its work lives till `task close` leaves Status Done and the actual; a
|
|
926
|
+
release PR's merge isn't one); `○` lines — not ready with the reason (such a
|
|
927
|
+
task holds its dependents: `blocked by #N (merged, not closed by task close)`),
|
|
928
|
+
and `Next:`. Before the queue, in the repository's checkout,
|
|
921
929
|
it removes what finished executors left (#515): an agent's worktree
|
|
922
930
|
(`.claude/worktrees/agent-*`) detached or on a `worktree-agent-*` branch, not
|
|
923
931
|
locked by a live process (Claude Code locks a running agent's worktree; a lock
|
|
@@ -926,7 +934,8 @@ whose pid is gone doesn't hold), clean and without commits outside
|
|
|
926
934
|
uncommitted changes or unmerged commits — left, an `○` line with the reason; a
|
|
927
935
|
`worktree-agent-*` branch without a worktree — the same by its commits. A
|
|
928
936
|
session's worktree, an agent's on an open task's branch and an executor's whose
|
|
929
|
-
handed-out task is open
|
|
937
|
+
handed-out task is open or awaits `task close` after its merge — untouched,
|
|
938
|
+
no line (#533, #769); an agent's on a closed
|
|
930
939
|
task's branch — as a detached one (#698: a batch executor ends on its task
|
|
931
940
|
branch, the release closes the task): Claude Code unlocks the
|
|
932
941
|
worktree when the agent ends its answer, a question too, and doesn't lock it
|
|
@@ -1106,7 +1115,12 @@ the merge at once — no CI wait (the PR runs none: the slot is free at the
|
|
|
1106
1115
|
merge, #676), no deploy wait, no epic refresh (the release's, one per epic)
|
|
1107
1116
|
and no `task close` — it refuses a task merged only into a batch branch,
|
|
1108
1117
|
before any change; a task without a PR isn't in the batch — its refresh and
|
|
1109
|
-
close are the executor's.
|
|
1118
|
+
close are the executor's. The task's stacks don't wait for the release (#765):
|
|
1119
|
+
the assignment names `task-env down <N>` after the merge, before the answer,
|
|
1120
|
+
`task finish` of a PR merged into the batch takes them down too, and the
|
|
1121
|
+
dispatcher's `task queue` — of each task merged into the batch with no open PR
|
|
1122
|
+
(its executor is done), only `+` and `!` lines: a stack already down is said
|
|
1123
|
+
nothing of; `task close` at the release finds them gone — an `○` line. `task actualize` names the batch PR as what
|
|
1110
1124
|
shipped and leaves the blocked-by links on the task till the release. A cloud
|
|
1111
1125
|
executor (`--cloud`) isn't in the batch: its PR goes into the default branch
|
|
1112
1126
|
with the full CI — the dispatcher learns of its end only by the task's
|
|
@@ -2392,18 +2392,6 @@ function projectChecked(io: Io, slug: string): boolean {
|
|
|
2392
2392
|
return true;
|
|
2393
2393
|
}
|
|
2394
2394
|
|
|
2395
|
-
/** The numbered items of the description's scenarios section — the future `it` names; no section — null. */
|
|
2396
|
-
export function scenarioItems(body: string, heading: string): string[] | null {
|
|
2397
|
-
const lines = body.replace(/\r\n/g, "\n").split("\n");
|
|
2398
|
-
const start = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
|
|
2399
|
-
if (start < 0) return null;
|
|
2400
|
-
const end = lines.findIndex((l, k) => k > start && /^#{1,2}\s/.test(l));
|
|
2401
|
-
return lines
|
|
2402
|
-
.slice(start + 1, end < 0 ? undefined : end)
|
|
2403
|
-
.map((l) => /^\s*\d+[.)]\s+(.+)$/.exec(l)?.[1]?.trim())
|
|
2404
|
-
.filter((x): x is string => Boolean(x));
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
2395
|
/**
|
|
2408
2396
|
* Taking a task in one call (#666) instead of ~11 flow turns: `project check` (once per session), the task as `task
|
|
2409
2397
|
* show` prints it, then the stops before any change — open questions of the task or its epic (they are asked first,
|
|
@@ -2445,7 +2433,7 @@ export function cmdTaskStart(io: Io, slug: string, number: number, branch?: stri
|
|
|
2445
2433
|
const type = taskBranch(branch ?? (here ? current : (others[0] ?? "")))?.type;
|
|
2446
2434
|
if (!t.estimate && type) runEstimate(io, slug, number, type);
|
|
2447
2435
|
const now = git(io, io.cwd, "branch", "--show-current").stdout.trim();
|
|
2448
|
-
const scenarios = scenarioItems(t.body
|
|
2436
|
+
const scenarios = locale.scenarioItems(t.body);
|
|
2449
2437
|
io.out(`Next: the session name — «#${number} ${t.title}»`);
|
|
2450
2438
|
if (resume && !here) io.out(`Branch: continue ${parallel.join(", ")} — checked out in another worktree (git worktree list): work in that one; in none — git switch it here`);
|
|
2451
2439
|
else io.out(now ? `Branch: ${now}` : `Branch: none — the task branch from a fresh origin/<base>${branch ? `: ${branch}` : ""}`);
|
|
@@ -3077,7 +3065,8 @@ function batchPrOf(recent: Recent, batch: string): (number: number, linked?: Iss
|
|
|
3077
3065
|
* the owner's "yes" to an epic's dispatcher becomes work at once, without a new session) — its pin stays, its task is
|
|
3078
3066
|
* in work. Ready — open, not an epic, not in work, no open blockers (other repositories' too), no external blocker
|
|
3079
3067
|
* label; order — Priority, then the number. In work (`=`) — "In progress", an open PR (linked, or by the task branch and
|
|
3080
|
-
* "Closes #N" among recent PRs) named with its link, or handed out to an executor of this session (`handedOutFile`)
|
|
3068
|
+
* "Closes #N" among recent PRs) named with its link, or handed out to an executor of this session (`handedOutFile`);
|
|
3069
|
+
* a hand-out's task closed by its PR's merge stays in work and holds its dependents till `task close` (`awaitingCloseOf`, #769).
|
|
3081
3070
|
* Marks the session as a dispatcher (`dispatcherFile`). A batch project (#648) — the batch branch first
|
|
3082
3071
|
* (`dispatcherBatch`), its line in the marker: a task merged into it is `=` till the release, a blocker merged into it
|
|
3083
3072
|
* doesn't hold. The batch's release (#649): nothing ready and every task of the batch merged into it — `Next:` names
|
|
@@ -3098,6 +3087,8 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3098
3087
|
if (!org && (o.type !== undefined || o.priority?.length)) throw new GhError("--type and --priority — only in an organization: a personal account has no issue types and no Priority");
|
|
3099
3088
|
if (o.epic !== undefined && o.tasks !== undefined) throw new GhError("--epic or --tasks, not both: the group is the epic's open tasks or the ones named");
|
|
3100
3089
|
let numbers: number[];
|
|
3090
|
+
/** The epic's sub-issues, closed ones included — a hand-out's task closed by a merge is among them (#769). */
|
|
3091
|
+
let subs: Set<number> | null = null;
|
|
3101
3092
|
if (o.tasks !== undefined) {
|
|
3102
3093
|
if (!o.tasks.length) throw new GhError("--tasks: the group's task numbers, comma-separated — --tasks 47,49");
|
|
3103
3094
|
numbers = [...new Set(o.tasks)];
|
|
@@ -3106,11 +3097,18 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3106
3097
|
if (!isEpic(epic, org)) throw new GhError(`#${o.epic} is not an epic — --epic takes an epic`);
|
|
3107
3098
|
if (epic.state !== "OPEN") throw new GhError(`epic #${o.epic} is closed`);
|
|
3108
3099
|
numbers = epic.subIssues.filter((x) => x.state === "OPEN").map((x) => x.number);
|
|
3100
|
+
subs = new Set(epic.subIssues.map((x) => x.number));
|
|
3109
3101
|
} else {
|
|
3110
3102
|
const found = graphql(io, Q.IssueSearch, { q: `repo:${slug} is:issue is:open` }).search.nodes as Any[];
|
|
3111
3103
|
if (found.length >= 100) io.out("○ the search gave 100 open tasks — the queue sees only them: narrow it with --epic");
|
|
3112
3104
|
numbers = found.filter((x) => x?.state === "OPEN").map((x) => x.number);
|
|
3113
3105
|
}
|
|
3106
|
+
const handed = handedOut(io, slug);
|
|
3107
|
+
// a hand-out's task closed by its PR's merge is in work till task close (#769): the open tasks don't name it
|
|
3108
|
+
if (o.tasks === undefined) {
|
|
3109
|
+
numbers = [...new Set([...numbers, ...handed.filter((h) => subs === null || subs.has(h.number)).map((h) => h.number)])];
|
|
3110
|
+
}
|
|
3111
|
+
const awaiting = awaitingCloseOf(io, slug, handed);
|
|
3114
3112
|
const recent = recentPrs(io, slug);
|
|
3115
3113
|
const openPr = openPrOf(io, slug, recent);
|
|
3116
3114
|
const args = [o.epic !== undefined && `--epic ${o.epic}`, o.tasks !== undefined && `--tasks ${numbers.join(",")}`, o.type !== undefined && `--type ${o.type}`, o.priority?.length && `--priority ${o.priority.join(",")}`].filter(Boolean).join(" ");
|
|
@@ -3132,7 +3130,6 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3132
3130
|
// the release its CI checked
|
|
3133
3131
|
const release = batch === null ? undefined : releasePrOf(recent, batch);
|
|
3134
3132
|
const releasing = release?.state === "OPEN" ? (release.number as number) : null;
|
|
3135
|
-
const handed = handedOut(io, slug);
|
|
3136
3133
|
/** Issue states the queue has read; a hand-out's task outside the queue is read when its worktree is up for removal. */
|
|
3137
3134
|
const states = new Map<number, string>();
|
|
3138
3135
|
const read = openOf(io, slug);
|
|
@@ -3141,7 +3138,7 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3141
3138
|
const running: string[] = [];
|
|
3142
3139
|
const waiting: string[] = [];
|
|
3143
3140
|
/** Of the tasks in work: merged into the batch and nothing else going — they wait only for the release (#649). */
|
|
3144
|
-
|
|
3141
|
+
const settled: number[] = [];
|
|
3145
3142
|
/**
|
|
3146
3143
|
* Of the tasks in work: the batch's live executors — the release waits for them (#696). Without a batch — all of them;
|
|
3147
3144
|
* with one — a task with an open PR into the batch, or handed out to an executor of the batch (a subagent, an app
|
|
@@ -3154,7 +3151,8 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3154
3151
|
for (const n of numbers.sort((a, b) => a - b)) {
|
|
3155
3152
|
const i = loadIssue(io, slug, n);
|
|
3156
3153
|
states.set(i.number, i.state);
|
|
3157
|
-
|
|
3154
|
+
const closer = i.state === "OPEN" ? null : awaiting(i.number, i);
|
|
3155
|
+
if (i.state !== "OPEN" && closer === null) continue;
|
|
3158
3156
|
const label = `#${i.number} ${q(i.title)}`;
|
|
3159
3157
|
if (isEpic(i, org)) {
|
|
3160
3158
|
waiting.push(`○ ${label} — an epic: its tasks — task queue --epic ${i.number}`);
|
|
@@ -3169,7 +3167,8 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3169
3167
|
// merged into the batch branch (question 1 of epic #645): open and In progress till the release — not given out again
|
|
3170
3168
|
const merged = inBatch?.(i.number, i.prs);
|
|
3171
3169
|
const work = [
|
|
3172
|
-
|
|
3170
|
+
closer === null ? "" : `PR #${closer} merged and closed the issue — waits for the deploy and task close`,
|
|
3171
|
+
closer === null && status === N.status.inProgress ? q(N.status.inProgress) : "",
|
|
3173
3172
|
pr === undefined ? "" : `open PR #${pr} https://github.com/${slug}/pull/${pr}`,
|
|
3174
3173
|
merged === undefined ? "" : `PR #${merged} merged into ${batch} — the task closes with the batch's release`,
|
|
3175
3174
|
].filter(Boolean);
|
|
@@ -3184,7 +3183,7 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3184
3183
|
if (work.length) {
|
|
3185
3184
|
running.push(`= ${label} — ${work.join(", ")}`);
|
|
3186
3185
|
// merged into the batch, no open PR of it: its executor is done, the task waits for the release
|
|
3187
|
-
if (merged !== undefined && pr === undefined) settled
|
|
3186
|
+
if (merged !== undefined && pr === undefined) settled.push(i.number);
|
|
3188
3187
|
else if (batch === null) holding++;
|
|
3189
3188
|
else if (pr !== undefined ? prBase(i, pr) === batch : merged === undefined && hand !== undefined && hand.executor !== "cloud" && !hand.main && !pastBatch(i)) holding++;
|
|
3190
3189
|
else past.push(`#${i.number}`);
|
|
@@ -3193,7 +3192,12 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3193
3192
|
// a blocker merged into this batch's branch doesn't hold its task: the executor branches from the batch (#648); a
|
|
3194
3193
|
// blocker outside it — merged into another batch or not merged — holds, as without batches
|
|
3195
3194
|
const batched = (b: Blocker) => inBatch !== null && b.repo.toLowerCase() === slug.toLowerCase() && inBatch(b.number) !== undefined;
|
|
3196
|
-
|
|
3195
|
+
// a blocker closed by its PR's merge holds till its task close (#769): the deploy it waits for may not have happened
|
|
3196
|
+
const unclosed = (b: Blocker) => b.state !== "OPEN" && b.repo.toLowerCase() === slug.toLowerCase() && awaiting(b.number) !== null;
|
|
3197
|
+
const blockers = [
|
|
3198
|
+
...i.blockers.filter((b) => b.state === "OPEN" && !batched(b)).map((b) => blockerRef(slug, b)),
|
|
3199
|
+
...i.blockers.filter(unclosed).map((b) => `#${b.number} (merged, not closed by task close)`),
|
|
3200
|
+
];
|
|
3197
3201
|
const external = i.labels.find((l) => locale.every((n) => n.labels.externalBlocker).includes(l));
|
|
3198
3202
|
if (status === N.status.done) waiting.push(`○ ${label} — ${STATUS} ${q(status)}, but the task is open`);
|
|
3199
3203
|
else if (blockers.length) waiting.push(`○ ${label} — blocked by ${blockers.join(", ")}`);
|
|
@@ -3216,7 +3220,9 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3216
3220
|
} else io.out("○ session not recognized (no CLAUDE_CODE_SESSION_ID) — not marked as a dispatcher: task status in the executors would pin their tasks");
|
|
3217
3221
|
appWorktreeWarning(io);
|
|
3218
3222
|
// the executor the dispatcher continues with SendMessage — an answered question, a restart — has no lock (#533)
|
|
3219
|
-
pruneExecutors(io, slug, handed, isOpen);
|
|
3223
|
+
pruneExecutors(io, slug, handed, isOpen, awaiting);
|
|
3224
|
+
// a task merged into the batch waits for the release, its stack doesn't (#765): the executor didn't take it down — the queue does
|
|
3225
|
+
if (settled.length && checkoutOfRepo(io, originUrl(io), slug)) for (const n of settled) takeDownStacks(io, n, true);
|
|
3220
3226
|
const group = o.tasks !== undefined ? `tasks ${numbers.map((n) => `#${n}`).join(", ")}` : null;
|
|
3221
3227
|
const scope = [o.epic !== undefined ? `epic #${o.epic}` : group ?? "open tasks", want && `type ${q(want)}`, o.priority?.length && `Priority ${o.priority.join("|")}`].filter(Boolean).join(", ");
|
|
3222
3228
|
io.out(`Queue ${slug} (${scope}): ready ${ready.length}, ${q(N.status.inProgress)} ${running.length}, not ready ${waiting.length}`);
|
|
@@ -3229,7 +3235,7 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3229
3235
|
const releaseCommand = `bun --no-env-file ${import.meta.path} batch release --repo ${slug}`;
|
|
3230
3236
|
// the owner's word «release» — the same command with live executors: they go on, their PRs wait for the release
|
|
3231
3237
|
// (question 2 of epic #645)
|
|
3232
|
-
const now = settled ? `; the owner's word to release now — ${releaseCommand}: what is merged into ${batch} goes, the live executors go on, no new ones till its merge` : "";
|
|
3238
|
+
const now = settled.length ? `; the owner's word to release now — ${releaseCommand}: what is merged into ${batch} goes, the live executors go on, no new ones till its merge` : "";
|
|
3233
3239
|
// outside auto an executor's merge is the owner's «yes» (#667)
|
|
3234
3240
|
const ask = locale.autoProject(io.cwd ?? process.cwd()) ? "" : `; ${MERGE_ASK}`;
|
|
3235
3241
|
// a red release (#650): its guilty task by the labels — the fix; the bisect is batch release's, the queue names it
|
|
@@ -3247,8 +3253,8 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
|
|
|
3247
3253
|
`Next: each ready task above — a background subagent in its own worktree while fewer than ${QUEUE_EXECUTORS} run (a number from the request replaces it); ` +
|
|
3248
3254
|
`the indented line is its whole prompt. After each executor's answer — task queue again: new tasks get in${ask}; ${SESSION_ARCHIVE}${now}.`,
|
|
3249
3255
|
);
|
|
3250
|
-
} else if (holding || (!settled && running.length)) io.out(`Next: no ready tasks — wait for the executors' answers; after each — task queue again${ask}; ${SESSION_ARCHIVE}${now}.`);
|
|
3251
|
-
else if (settled) {
|
|
3256
|
+
} else if (holding || (!settled.length && running.length)) io.out(`Next: no ready tasks — wait for the executors' answers; after each — task queue again${ask}; ${SESSION_ARCHIVE}${now}.`);
|
|
3257
|
+
else if (settled.length) {
|
|
3252
3258
|
io.out(
|
|
3253
3259
|
`Next: the batch ${batch} is complete — nothing ready, every task of the batch is merged into it: its release — ${releaseCommand}, ` +
|
|
3254
3260
|
`once no executor of the batch is still at work${past.length ? `; past the batch — ${past.join(", ")}: they don't hold the release` : ""}; ${SESSION_ARCHIVE}.`,
|
|
@@ -3343,20 +3349,23 @@ function releaseChecks(io: Io, slug: string, release: PrRef): ReleaseChecks {
|
|
|
3343
3349
|
const TEST_FILE = /((?:[\w.@-]+\/)*[\w.@-]+\.(?:test|spec|e2e)\.[cm]?[jt]sx?)\b/;
|
|
3344
3350
|
const isTestFile = (p: string) => new RegExp(`^${TEST_FILE.source}$`).test(p);
|
|
3345
3351
|
|
|
3352
|
+
/** Terminal escape sequences: OSC (`ESC ] … BEL|ESC \\`, links), CSI (`ESC [ … letter`, colors, erasing), two-byte ones. */
|
|
3353
|
+
const ANSI = /\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b\[[0-?]*[ -/]*[@-~]|\u001b[@-Z\\-_]/g;
|
|
3354
|
+
|
|
3346
3355
|
/**
|
|
3347
3356
|
* The files a failed job's log names (#650): a failed test's file — in its failure line (Vitest, Jest, Playwright) or in
|
|
3348
3357
|
* the file header above it (Bun: `tests/…/x.test.ts:`), a compiler error's file — `a.ts(3,5): error TS…` (a `bun check`
|
|
3349
3358
|
* block too, `asTsc`); failure lines — `FAILED_LINE`, as on the merge. Paths — the checkout's: the runner's workspace
|
|
3350
|
-
* prefix (`…/work/<repo>/<repo>/`), the log's timestamps and colors
|
|
3359
|
+
* prefix (`…/work/<repo>/<repo>/`), the log's timestamps and terminal escape sequences (`ANSI`: colors, erasing, OSC
|
|
3360
|
+
* links — #774) are cut.
|
|
3351
3361
|
*/
|
|
3352
3362
|
function failedFilesIn(log: string): string[] {
|
|
3353
3363
|
const out: string[] = [];
|
|
3354
3364
|
const rel = (p: string) => p.replace(/^.*?\/work\/[^/]+\/[^/]+\//, "").replace(/^\.\//, "");
|
|
3355
3365
|
const header = new RegExp(`^\\s*/?${TEST_FILE.source}:$`);
|
|
3356
3366
|
let current: string | null = null;
|
|
3357
|
-
for (const raw of asTsc(log).split("\n")) {
|
|
3367
|
+
for (const raw of asTsc(log.replace(ANSI, "")).split("\n")) {
|
|
3358
3368
|
const line = raw
|
|
3359
|
-
.replace(/\u001b\[[\d;]*m/g, "")
|
|
3360
3369
|
.replace(/^\d{4}-\d\d-\d\dT[\d:.]+Z ?/, "")
|
|
3361
3370
|
.trimEnd();
|
|
3362
3371
|
const file = header.exec(line);
|
|
@@ -3377,7 +3386,8 @@ function failedFilesOf(io: Io, slug: string, failed: Any[]): string[] {
|
|
|
3377
3386
|
for (const r of failed) {
|
|
3378
3387
|
let log: string;
|
|
3379
3388
|
try {
|
|
3380
|
-
log
|
|
3389
|
+
// a runner's log has the terminal's escape sequences (colors, line erasing, links): gh prints it only with the flag (#774)
|
|
3390
|
+
log = io.gh(["api", `repos/${slug}/actions/jobs/${r.id}/logs`, "--allow-escape-sequences"]);
|
|
3381
3391
|
} catch (e) {
|
|
3382
3392
|
if (!(e instanceof GhError)) throw e;
|
|
3383
3393
|
io.out(`○ the log of ${r.name} not read: ${e.message}`);
|
|
@@ -3793,16 +3803,45 @@ const plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one :
|
|
|
3793
3803
|
* (#698): an executor's whose handed-out task is open is kept (#533); an agent's on the task branch of a closed task goes
|
|
3794
3804
|
* too — a batch executor ends on its task branch, and the release closes the task (GitHub, by its «Closes»).
|
|
3795
3805
|
*/
|
|
3796
|
-
function pruneExecutors(io: Io, slug: string, handed: HandOut[], isOpen: (n: number) => boolean): void {
|
|
3806
|
+
function pruneExecutors(io: Io, slug: string, handed: HandOut[], isOpen: (n: number) => boolean, awaiting = awaitingCloseOf(io, slug, handed)): void {
|
|
3797
3807
|
const executors = handed.flatMap((h) => (h.worktree === null ? [] : [{ number: h.number, worktree: realPath(h.worktree) }]));
|
|
3808
|
+
// a task closed by its PR's merge, task close not run yet (#769): its executor waits for the deploy in that worktree
|
|
3809
|
+
const live = (n: number) => isOpen(n) || awaiting(n) !== null;
|
|
3798
3810
|
pruneAgentWorktrees(
|
|
3799
3811
|
io,
|
|
3800
3812
|
slug,
|
|
3801
|
-
(dir) => executors.some((h) => h.worktree === realPath(dir) &&
|
|
3802
|
-
(n) => !
|
|
3813
|
+
(dir) => executors.some((h) => h.worktree === realPath(dir) && live(h.number)),
|
|
3814
|
+
(n) => !live(n),
|
|
3803
3815
|
);
|
|
3804
3816
|
}
|
|
3805
3817
|
|
|
3818
|
+
/**
|
|
3819
|
+
* A handed-out task closed by its PR's merge, the tail not over (#769): «Closes #N» closes the issue at the merge into the
|
|
3820
|
+
* default branch, while its executor still waits for the deploy, runs the epic refresh and `task close`. The task's work
|
|
3821
|
+
* lives till `task close` — what it leaves (`tailOver`: Status Done and the actual), not the issue's state: till then the
|
|
3822
|
+
* queue keeps the executor's worktree, shows the task `=` and holds its dependents. A release PR's merge (its head — a
|
|
3823
|
+
* batch branch) isn't one: the batch's executors are done, the dispatcher closes their tasks. The closing PR's number;
|
|
3824
|
+
* otherwise — null. Read once per number; an issue not read — null.
|
|
3825
|
+
*/
|
|
3826
|
+
function awaitingCloseOf(io: Io, slug: string, handed: HandOut[]): (n: number, issue?: Issue) => number | null {
|
|
3827
|
+
const memo = new Map<number, number | null>();
|
|
3828
|
+
return (n, issue) => {
|
|
3829
|
+
if (!handed.some((h) => h.number === n)) return null;
|
|
3830
|
+
if (!memo.has(n)) {
|
|
3831
|
+
let pr: number | null = null;
|
|
3832
|
+
try {
|
|
3833
|
+
const i = issue ?? loadIssue(io, slug, n);
|
|
3834
|
+
const closer = i.state === "CLOSED" && i.stateReason === "COMPLETED" ? i.prs.find((p) => p.merged && !isBatchBranch(p.base) && !isBatchBranch(p.head)) : undefined;
|
|
3835
|
+
if (closer && !tailOver(io, slug, n)) pr = closer.number;
|
|
3836
|
+
} catch (e) {
|
|
3837
|
+
if (!(e instanceof GhError)) throw e;
|
|
3838
|
+
}
|
|
3839
|
+
memo.set(n, pr);
|
|
3840
|
+
}
|
|
3841
|
+
return memo.get(n)!;
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3806
3845
|
/** The issue's state, read once per command: open — true; not read (no such issue) — open, nothing is removed for it. */
|
|
3807
3846
|
function openOf(io: Io, slug: string): (n: number) => boolean {
|
|
3808
3847
|
const states = new Map<number, boolean>();
|
|
@@ -4158,6 +4197,7 @@ export function cmdTaskAssignment(io: Io, slug: string, number: number, o: { clo
|
|
|
4158
4197
|
repo: slug,
|
|
4159
4198
|
epic: issue.parent ? locale.fill(N.queue.epic, { epicWord: N.subagentPrompt.epic, epic: issue.parent.number }) : "",
|
|
4160
4199
|
script: `bun --no-env-file ${import.meta.path}`,
|
|
4200
|
+
taskEnv: `bun --no-env-file ${taskEnvScript(io)}`,
|
|
4161
4201
|
waitCi: `bash ${waitCi()}`,
|
|
4162
4202
|
inProgress: N.status.inProgress,
|
|
4163
4203
|
done: N.lastLine.done,
|
|
@@ -4940,12 +4980,21 @@ export function cmdTaskFinish(io: Io, slug: string, number: number, o: { timeout
|
|
|
4940
4980
|
if (!isTaskBranch(branch, number)) throw new GhError(`the checkout is on ${q(branch || "a detached HEAD")}, not on a branch of #${number} — task start ${number} --branch <type>/${number}-<slug>`);
|
|
4941
4981
|
const dirty = git(io, io.cwd, "status", "--porcelain", "--untracked-files=no").stdout.trim();
|
|
4942
4982
|
if (dirty) return stop(1, `! uncommitted changes in the checkout — the PR would go without them`, `the checks before a commit, git commit, then ${again}`);
|
|
4943
|
-
|
|
4944
|
-
const base = open?.base ?? (handedPastBatch(io, slug, number) ? null : batchOf(io, slug)) ?? found.base;
|
|
4983
|
+
const base = open?.base ?? finishBase(io, slug, number, found);
|
|
4945
4984
|
const fetched = git(io, io.cwd, "fetch", "-q", "origin", `+refs/heads/${base}:refs/remotes/origin/${base}`);
|
|
4946
4985
|
if (fetched.status !== 0) throw new GhError(`git fetch origin ${base}: ${why(fetched)}`);
|
|
4947
4986
|
const commits = git(io, io.cwd, "log", "--reverse", "--format=%s", `origin/${base}..HEAD`).stdout.split("\n").filter((l) => l.trim());
|
|
4948
4987
|
if (!commits.length) return stop(1, `! no commits on ${branch} past origin/${base} — nothing to put into a PR`, `commit the task's work, then ${again}`);
|
|
4988
|
+
// commits already in the base by their changes (#768) — a released batch's, rebased into the default branch with other
|
|
4989
|
+
// SHAs: the PR would take its title from them and its decision labels from their diff; a rebase drops them
|
|
4990
|
+
const applied = git(io, io.cwd, "cherry", `origin/${base}`, "HEAD").stdout.split("\n").filter((l) => l.startsWith("-")).length;
|
|
4991
|
+
if (applied) {
|
|
4992
|
+
return stop(
|
|
4993
|
+
1,
|
|
4994
|
+
`! ${applied} ${applied > 1 ? "commits" : "commit"} of ${branch} ${applied > 1 ? "are" : "is"} in origin/${base} already by the changes (a released batch's, a merged PR's) — the PR would take its title and decision labels from them`,
|
|
4995
|
+
`git rebase origin/${base} (it drops them), then ${again} (it pushes the rebased branch with --force-with-lease)`,
|
|
4996
|
+
);
|
|
4997
|
+
}
|
|
4949
4998
|
const refused = pushTaskBranch(io, branch);
|
|
4950
4999
|
if (refused) return stop(1, `! ${refused}`, `then ${again}`);
|
|
4951
5000
|
|
|
@@ -4988,6 +5037,22 @@ export function cmdTaskFinish(io: Io, slug: string, number: number, o: { timeout
|
|
|
4988
5037
|
return stop(4, `✅ PR #${pr} is ready to merge`, `${yes}gh pr merge ${pr} --rebase — a separate call, no cd or pipeline (the owner's permission rule matches it); then ${again}${isBatchBranch(base) ? "" : " — in the background: it waits for the deploy"}`);
|
|
4989
5038
|
}
|
|
4990
5039
|
|
|
5040
|
+
/**
|
|
5041
|
+
* The base of the task's new PR: the dispatcher's batch branch (#648); a task past the batch (#697) — the default branch,
|
|
5042
|
+
* as outside a batch; the batch released (#768: its release PR merged, or its branch gone from origin) — the default
|
|
5043
|
+
* branch too: a released batch takes no more PRs, and the queue starts the next one only with a task to hand out (its
|
|
5044
|
+
* marker names it then).
|
|
5045
|
+
*/
|
|
5046
|
+
function finishBase(io: Io, slug: string, number: number, found: ReturnType<typeof unlinkedPrs>): string {
|
|
5047
|
+
const batch = handedPastBatch(io, slug, number) ? null : batchOf(io, slug);
|
|
5048
|
+
if (!batch) return found.base;
|
|
5049
|
+
const release = releasePrOf(found.recent, batch);
|
|
5050
|
+
if (release?.merged) return io.out(`○ ${batch} is released by PR #${release.number} — the PR goes into ${found.base}`), found.base;
|
|
5051
|
+
const listed = git(io, io.cwd, "ls-remote", "--heads", "origin", `refs/heads/${batch}`);
|
|
5052
|
+
if (listed.status === 0 && !listed.stdout.trim()) return io.out(`○ ${batch} is gone from origin (released) — the PR goes into ${found.base}`), found.base;
|
|
5053
|
+
return batch;
|
|
5054
|
+
}
|
|
5055
|
+
|
|
4991
5056
|
/**
|
|
4992
5057
|
* The tail is over — what `task close` leaves (#761, question 1): Status Done and the actual written, not the issue's
|
|
4993
5058
|
* state, which «Closes #N» sets at the merge. In the cloud there is no project to read — over, as before.
|
|
@@ -5012,6 +5077,8 @@ function finishMerged(
|
|
|
5012
5077
|
): number {
|
|
5013
5078
|
if (isBatchBranch(merged.base)) {
|
|
5014
5079
|
io.out(`✅ PR #${merged.number} is merged into ${merged.base} — #${number} stays ${q(N.status.inProgress)} till the batch's release`);
|
|
5080
|
+
// the task's stacks don't wait for the release (#765): the executor is done, its stack only loads the machine
|
|
5081
|
+
if (checkoutOfRepo(io, originUrl(io), slug)) takeDownStacks(io, number);
|
|
5015
5082
|
io.out(`Next: nothing more for the task — no CI or deploy wait, no epic refresh and no task close: the dispatcher's batch release does them`);
|
|
5016
5083
|
return 0;
|
|
5017
5084
|
}
|
|
@@ -5170,8 +5237,9 @@ function renameBranch(io: Io, slug: string, target: string): boolean {
|
|
|
5170
5237
|
* `batched` — the same into a batch branch (#648): GitHub never links those, and they don't close the task — the
|
|
5171
5238
|
* batch's release does.
|
|
5172
5239
|
*/
|
|
5173
|
-
function unlinkedPrs(io: Io, slug: string, number: number): { base: string; prs: UnlinkedPr[]; batched: UnlinkedPr[] } {
|
|
5174
|
-
const
|
|
5240
|
+
function unlinkedPrs(io: Io, slug: string, number: number): { base: string; prs: UnlinkedPr[]; batched: UnlinkedPr[]; recent: Recent } {
|
|
5241
|
+
const recent = recentPrs(io, slug);
|
|
5242
|
+
const { base, nodes } = recent;
|
|
5175
5243
|
const prs: UnlinkedPr[] = [];
|
|
5176
5244
|
const batched: UnlinkedPr[] = [];
|
|
5177
5245
|
for (const p of nodes) {
|
|
@@ -5181,7 +5249,7 @@ function unlinkedPrs(io: Io, slug: string, number: number): { base: string; prs:
|
|
|
5181
5249
|
const why = taskLinks(p).find((x) => x.number === number)?.why;
|
|
5182
5250
|
if (why) (into === base ? prs : batched).push({ number: p.number, state: p.state ?? "", merged: Boolean(p.merged), head, base: into, why });
|
|
5183
5251
|
}
|
|
5184
|
-
return { base, prs, batched };
|
|
5252
|
+
return { base, prs, batched, recent };
|
|
5185
5253
|
}
|
|
5186
5254
|
|
|
5187
5255
|
type UnlinkedPr = Issue["prs"][number] & { why: string };
|
|
@@ -5206,13 +5274,15 @@ const taskEnvScript = (io: Io) => io.env["ELVES_TASK_ENV"] ?? path.resolve(impor
|
|
|
5206
5274
|
* in the checkout takes the dev and e2e stacks down with their volumes and prints a line per stack (`+`, `○`, `!`) —
|
|
5207
5275
|
* printed as is; it failed without a line — its error as a `!` line. A failure doesn't stop the close: a stack left
|
|
5208
5276
|
* behind is found by `task-env prune`. Docker doesn't work in the Claude Code sandbox — task close is an unsandboxed
|
|
5209
|
-
* call (SKILL.md).
|
|
5277
|
+
* call (SKILL.md). A batch's task (#765) closes only with the release — its stack goes at the merge into the batch:
|
|
5278
|
+
* `task finish` of the executor, and the dispatcher's `task queue` as insurance (`quiet`: only `+` and `!` lines).
|
|
5210
5279
|
*/
|
|
5211
|
-
function takeDownStacks(io: Io, number: number): void {
|
|
5280
|
+
function takeDownStacks(io: Io, number: number, quiet = false): void {
|
|
5212
5281
|
const script = taskEnvScript(io);
|
|
5213
|
-
if (!existsSync(script)) return io.out(`○ task stacks: task-env is not installed (${script})`);
|
|
5282
|
+
if (!existsSync(script)) return quiet ? undefined : io.out(`○ task stacks: task-env is not installed (${script})`);
|
|
5214
5283
|
const r = (io.run ?? realRun)("bun", ["--no-env-file", script, "down", String(number)], io.cwd);
|
|
5215
|
-
|
|
5284
|
+
// quiet — the queue's insurance (#765): a stack already down (`○`) is said nothing of, each queue would repeat it
|
|
5285
|
+
const lines = r.stdout.split("\n").filter((l) => l.trim() && !(quiet && l.startsWith("○")));
|
|
5216
5286
|
for (const line of lines) io.out(line);
|
|
5217
5287
|
if (r.status !== 0 && !lines.length) io.out(`! task-env down: ${why(r)}`);
|
|
5218
5288
|
}
|
|
@@ -6329,7 +6399,8 @@ Examples:
|
|
|
6329
6399
|
The tail of a task from its committed branch to its close, resumable: each call does what is ready within --timeout
|
|
6330
6400
|
(default ${FINISH_TIMEOUT} s), prints the state and the Next line, a repeat goes on from there. Before the merge: the task
|
|
6331
6401
|
branch pushed (a rebased one — --force-with-lease), the PR into the dispatcher's batch branch or the default branch
|
|
6332
|
-
(
|
|
6402
|
+
(a released batch — the default branch; commits of the branch already in the base by their changes — a stop: git
|
|
6403
|
+
rebase drops them; the title — --title, otherwise the branch type's first commit; the body — spec-diff and Closes #N; an existing PR —
|
|
6333
6404
|
its body updated), pr labels, the CI wait (ci-wait pr; none into a batch), pr premerge, then the merge command — a
|
|
6334
6405
|
separate gh pr merge <PR> --rebase. After the merge: the deploy wait on the merge SHA (ci-wait merged), the epic
|
|
6335
6406
|
refresh's mechanics and its subagent's prompt (once), task close once the report is on the epic; merged into a batch —
|
|
@@ -586,4 +586,33 @@ function escapeRe(text: string): string {
|
|
|
586
586
|
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
-
|
|
589
|
+
/**
|
|
590
|
+
* A task's scenarios — the list items (`-`, `*`, `+` or numbered) of the description's scenarios section up to the next
|
|
591
|
+
* heading, checkboxes stripped; no section — null. The heading is in any dictionary language (`## Scenarios` or its
|
|
592
|
+
* translation): the task could have been written before the project language changed. One parser for `task start`
|
|
593
|
+
* and `spec-diff` (#767: `task start` read only numbered items and missed `- «…»`).
|
|
594
|
+
*/
|
|
595
|
+
function scenarioItems(md: string): string[] | null {
|
|
596
|
+
// a fenced code block is an example in the task text, not its sections: its lines are blanked out
|
|
597
|
+
let fence: string | null = null;
|
|
598
|
+
const lines = md.split(/\r?\n/).map((l) => {
|
|
599
|
+
const f = /^\s*(`{3,}|~{3,})/.exec(l)?.[1];
|
|
600
|
+
if (f && (fence === null || (f[0] === fence[0] && f.length >= fence.length))) {
|
|
601
|
+
fence = fence === null ? f : null;
|
|
602
|
+
return "";
|
|
603
|
+
}
|
|
604
|
+
return fence === null ? l : "";
|
|
605
|
+
});
|
|
606
|
+
const heads = every((n) => n.sections.scenarios).map((h) => new RegExp(`^${escapeRe(h).replace(/ +/g, "\\s+")}\\s*$`));
|
|
607
|
+
const start = lines.findIndex((l) => heads.some((h) => h.test(l.trim())));
|
|
608
|
+
if (start < 0) return null;
|
|
609
|
+
const out: string[] = [];
|
|
610
|
+
for (const l of lines.slice(start + 1)) {
|
|
611
|
+
if (/^#{1,2}\s/.test(l)) break;
|
|
612
|
+
const m = /^\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?(.+?)\s*$/.exec(l);
|
|
613
|
+
if (m) out.push(m[1]!);
|
|
614
|
+
}
|
|
615
|
+
return out;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export default { LANGUAGE_CODE, DEFAULT_LANGUAGE, projectRoot, manifestOf, projectLanguage, missingManifest, batchProject, autoProject, names, languages, everyNames, every, fill, plural, count, escapeRe, scenarioItems };
|
|
@@ -832,38 +832,20 @@ function asJson(
|
|
|
832
832
|
);
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
-
/**
|
|
836
|
-
* Task scenarios — the list items of the scenarios section (up to the next heading); checkboxes stripped; no section —
|
|
837
|
-
* null. The heading is in any dictionary language (`## Scenarios` or its translation): the task could have been written
|
|
838
|
-
* before the project language changed.
|
|
839
|
-
*/
|
|
840
|
-
export function parseScenarios(md: string): string[] | null {
|
|
841
|
-
// a fenced code block is an example in the task text, not its sections: its lines are blanked out
|
|
842
|
-
let fence: string | null = null;
|
|
843
|
-
const lines = md.split(/\r?\n/).map((l) => {
|
|
844
|
-
const f = /^\s*(`{3,}|~{3,})/.exec(l)?.[1];
|
|
845
|
-
if (f && (fence === null || (f[0] === fence[0] && f.length >= fence.length))) {
|
|
846
|
-
fence = fence === null ? f : null;
|
|
847
|
-
return "";
|
|
848
|
-
}
|
|
849
|
-
return fence === null ? l : "";
|
|
850
|
-
});
|
|
851
|
-
const heads = locale.every((n) => n.sections.scenarios).map((h) => new RegExp(`^${locale.escapeRe(h).replace(/ +/g, "\\s+")}\\s*$`));
|
|
852
|
-
const start = lines.findIndex((l) => heads.some((h) => h.test(l.trim())));
|
|
853
|
-
if (start < 0) return null;
|
|
854
|
-
const out: string[] = [];
|
|
855
|
-
for (const l of lines.slice(start + 1)) {
|
|
856
|
-
if (/^#{1,2}\s/.test(l)) break;
|
|
857
|
-
const m = /^\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?(.+?)\s*$/.exec(l);
|
|
858
|
-
if (m) out.push(m[1]!);
|
|
859
|
-
}
|
|
860
|
-
return out;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
835
|
/** Quotes that quote a scenario whole: `«…»;` in a task is the same name as the test's. */
|
|
864
836
|
const QUOTES: [string, string][] = [["«", "»"], ['"', '"'], ["“", "”"], ["`", "`"]];
|
|
865
837
|
const TAIL = /[.。;,]+$/;
|
|
866
838
|
|
|
839
|
+
/** Paired quotes are balanced in the text: no close before its open, every open closed. */
|
|
840
|
+
const balanced = (text: string, open: string, close: string): boolean => {
|
|
841
|
+
let depth = 0;
|
|
842
|
+
for (const c of text) {
|
|
843
|
+
if (c === open) depth++;
|
|
844
|
+
else if (c === close && --depth < 0) return false;
|
|
845
|
+
}
|
|
846
|
+
return depth === 0;
|
|
847
|
+
};
|
|
848
|
+
|
|
867
849
|
/**
|
|
868
850
|
* A name for matching: whitespace collapsed, case-insensitive, without outer quotes and a trailing mark — both before
|
|
869
851
|
* and after the quotes.
|
|
@@ -872,8 +854,9 @@ const norm = (s: string): string => {
|
|
|
872
854
|
let t = s.replace(/\s+/g, " ").trim().replace(TAIL, "");
|
|
873
855
|
for (const [open, close] of QUOTES) {
|
|
874
856
|
const inner = t.slice(open.length, -close.length);
|
|
875
|
-
// "a" and "b" isn't a whole quote: its own closing quote is inside
|
|
876
|
-
|
|
857
|
+
// "a" and "b" isn't a whole quote: its own closing quote is inside; paired quotes nest — «a «b»» is whole
|
|
858
|
+
// when every inner close has its inner open before it (#767)
|
|
859
|
+
if (t.length > open.length + close.length && t.startsWith(open) && t.endsWith(close) && (open === close ? !inner.includes(close) : balanced(inner, open, close))) t = inner.trim().replace(TAIL, "");
|
|
877
860
|
}
|
|
878
861
|
return t.toLowerCase();
|
|
879
862
|
};
|
|
@@ -1150,7 +1133,7 @@ export async function main(argv: string[]): Promise<number> {
|
|
|
1150
1133
|
let scenarios: string[] | null = null;
|
|
1151
1134
|
if (v.scenarios !== undefined) {
|
|
1152
1135
|
try {
|
|
1153
|
-
scenarios =
|
|
1136
|
+
scenarios = locale.scenarioItems(readFileSync(v.scenarios === "-" ? 0 : v.scenarios, "utf8"));
|
|
1154
1137
|
} catch (e) {
|
|
1155
1138
|
console.error(`spec-diff: --scenarios: ${(e as Error).message}`);
|
|
1156
1139
|
return 2;
|