@miroshnik/elves 2026.1026.5 → 2026.1027.1

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import {
3
3
  locale_default
4
- } from "../../spec/scripts/harness-t9bqz3st.js";
4
+ } from "../../spec/scripts/harness-91h1qpb5.js";
5
5
 
6
6
  // skills/github/scripts/github.ts
7
7
  import { spawnSync } from "node:child_process";
@@ -1912,6 +1912,10 @@ function cmdTaskShow(io, slug, number) {
1912
1912
  io.out(line);
1913
1913
  return 0;
1914
1914
  }
1915
+ function itemValues(i, name) {
1916
+ const items = i?.projectItems?.nodes ?? [];
1917
+ return (items.find((it) => it.project?.title === name) ?? items[0])?.fieldValues?.nodes ?? [];
1918
+ }
1915
1919
  function showTask(io, slug, number) {
1916
1920
  const [owner, name] = slug.split("/");
1917
1921
  const cloud = inCloud(io);
@@ -1922,7 +1926,7 @@ function showTask(io, slug, number) {
1922
1926
  const type = i.issueType?.name ?? (labels.includes(EPIC_LABEL) ? N.issueTypes.epic : null);
1923
1927
  const epic = type !== null && locale_default.every((n) => n.issueTypes.epic).includes(type);
1924
1928
  const items = i.projectItems?.nodes ?? [];
1925
- const values = (items.find((it) => it.project?.title === name) ?? items[0])?.fieldValues?.nodes ?? [];
1929
+ const values = itemValues(i, name);
1926
1930
  const num = (field) => values.find((v) => v?.__typename === "ProjectV2ItemFieldNumberValue" && locale_default.every(field).includes(v.field?.name));
1927
1931
  const status = values.find((v) => v?.field?.name === STATUS && v.name)?.name ?? null;
1928
1932
  const estimate = num((n) => n.fields.estimate);
@@ -2259,7 +2263,7 @@ function cmdTaskQueue(io, slug, o) {
2259
2263
  const ready = [];
2260
2264
  const running = [];
2261
2265
  const waiting = [];
2262
- let settled = 0;
2266
+ const settled = [];
2263
2267
  let holding = 0;
2264
2268
  const past = [];
2265
2269
  for (const n of numbers.sort((a, b) => a - b)) {
@@ -2296,7 +2300,7 @@ function cmdTaskQueue(io, slug, o) {
2296
2300
  if (work.length) {
2297
2301
  running.push(`= ${label} — ${work.join(", ")}`);
2298
2302
  if (merged !== undefined && pr === undefined)
2299
- settled++;
2303
+ settled.push(i.number);
2300
2304
  else if (batch === null)
2301
2305
  holding++;
2302
2306
  else if (pr !== undefined ? prBase(i, pr) === batch : merged === undefined && hand !== undefined && hand.executor !== "cloud" && !hand.main && !pastBatch(i))
@@ -2338,6 +2342,9 @@ ${batches.map((b) => `batch ${b.repo} ${b.branch}
2338
2342
  io.out("○ session not recognized (no CLAUDE_CODE_SESSION_ID) — not marked as a dispatcher: task status in the executors would pin their tasks");
2339
2343
  appWorktreeWarning(io);
2340
2344
  pruneExecutors(io, slug, handed, isOpen);
2345
+ if (settled.length && checkoutOfRepo(io, originUrl(io), slug))
2346
+ for (const n of settled)
2347
+ takeDownStacks(io, n, true);
2341
2348
  const group = o.tasks !== undefined ? `tasks ${numbers.map((n) => `#${n}`).join(", ")}` : null;
2342
2349
  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(", ");
2343
2350
  io.out(`Queue ${slug} (${scope}): ready ${ready.length}, ${q(N.status.inProgress)} ${running.length}, not ready ${waiting.length}`);
@@ -2350,7 +2357,7 @@ ${batches.map((b) => `batch ${b.repo} ${b.branch}
2350
2357
  for (const line of waiting)
2351
2358
  io.out(line);
2352
2359
  const releaseCommand = `bun --no-env-file ${import.meta.path} batch release --repo ${slug}`;
2353
- 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` : "";
2360
+ 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` : "";
2354
2361
  const ask = locale_default.autoProject(io.cwd ?? process.cwd()) ? "" : `; ${MERGE_ASK}`;
2355
2362
  const checks = release && releasing !== null ? releaseChecks(io, slug, release) : null;
2356
2363
  if (release && batch && checks?.state === "red") {
@@ -2360,9 +2367,9 @@ ${batches.map((b) => `batch ${b.repo} ${b.branch}
2360
2367
  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}.`);
2361
2368
  } else if (ready.length) {
2362
2369
  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}.`);
2363
- } else if (holding || !settled && running.length)
2370
+ } else if (holding || !settled.length && running.length)
2364
2371
  io.out(`Next: no ready tasks — wait for the executors' answers; after each — task queue again${ask}; ${SESSION_ARCHIVE}${now}.`);
2365
- else if (settled) {
2372
+ else if (settled.length) {
2366
2373
  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}.`);
2367
2374
  } else {
2368
2375
  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.` : "";
@@ -3014,6 +3021,7 @@ function cmdTaskAssignment(io, slug, number, o = {}) {
3014
3021
  repo: slug,
3015
3022
  epic: issue.parent ? locale_default.fill(N.queue.epic, { epicWord: N.subagentPrompt.epic, epic: issue.parent.number }) : "",
3016
3023
  script: `bun --no-env-file ${import.meta.path}`,
3024
+ taskEnv: `bun --no-env-file ${taskEnvScript(io)}`,
3017
3025
  waitCi: `bash ${waitCi()}`,
3018
3026
  inProgress: N.status.inProgress,
3019
3027
  done: N.lastLine.done,
@@ -3573,8 +3581,13 @@ function cmdTaskFinish(io, slug, number, o) {
3573
3581
  const stop = (code, why, next) => (io.out(why), io.out(`Next: ${next}`), code);
3574
3582
  const outOfTime = (what) => stop(5, `○ out of time (--timeout ${o.timeout}) — ${what}`, `${again} — it goes on from here`);
3575
3583
  const issue = loadIssue(io, slug, number);
3576
- if (issue.state !== "OPEN")
3577
- return io.out(`= #${number} is closed — nothing to finish`), 0;
3584
+ if (issue.state !== "OPEN") {
3585
+ const closer = issue.stateReason === "COMPLETED" ? issue.prs.find((p) => p.merged && !isBatchBranch(p.base)) ?? null : null;
3586
+ if (!closer || tailOver(io, slug, number))
3587
+ return io.out(`= #${number} is closed — nothing to finish`), 0;
3588
+ io.out(`○ #${number} is closed by the merge of PR #${closer.number}, the tail isn't over (no ${q(N.status.done)} with the actual) — going on`);
3589
+ return finishMerged(io, slug, number, issue.parent?.number ?? null, closer, { left, again, stop, outOfTime });
3590
+ }
3578
3591
  if (!checkoutOfRepo(io, originUrl(io), slug))
3579
3592
  throw new GhError(`task finish runs from a checkout of ${slug}: the current directory is not one`);
3580
3593
  const found = unlinkedPrs(io, slug, number);
@@ -3652,9 +3665,20 @@ function cmdTaskFinish(io, slug, number, o) {
3652
3665
  const yes = locale_default.autoProject(io.cwd ?? process.cwd()) ? "" : "the owner's «yes» (the project is without auto) — then ";
3653
3666
  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"}`);
3654
3667
  }
3668
+ function tailOver(io, slug, number) {
3669
+ if (inCloud(io))
3670
+ return true;
3671
+ const [owner, name] = slug.split("/");
3672
+ const values = itemValues(graphql(io, Q.IssueShow, { owner, name, number })?.repository?.issue, name);
3673
+ const done = values.some((v) => v?.field?.name === STATUS && locale_default.every((n) => n.status.done).includes(v.name));
3674
+ const actual = values.some((v) => v?.__typename === "ProjectV2ItemFieldNumberValue" && locale_default.every((n) => n.fields.actual).includes(v.field?.name));
3675
+ return done && actual;
3676
+ }
3655
3677
  function finishMerged(io, slug, number, epicNumber, merged, f) {
3656
3678
  if (isBatchBranch(merged.base)) {
3657
3679
  io.out(`✅ PR #${merged.number} is merged into ${merged.base} — #${number} stays ${q(N.status.inProgress)} till the batch's release`);
3680
+ if (checkoutOfRepo(io, originUrl(io), slug))
3681
+ takeDownStacks(io, number);
3658
3682
  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`);
3659
3683
  return 0;
3660
3684
  }
@@ -3789,13 +3813,13 @@ function originUrl(io) {
3789
3813
  return remote.status === 0 ? remote.stdout : "";
3790
3814
  }
3791
3815
  var taskEnvScript = (io) => io.env["ELVES_TASK_ENV"] ?? path.resolve(import.meta.dir, "../../task-env/scripts/task-env.ts");
3792
- function takeDownStacks(io, number) {
3816
+ function takeDownStacks(io, number, quiet = false) {
3793
3817
  const script = taskEnvScript(io);
3794
3818
  if (!existsSync(script))
3795
- return io.out(`○ task stacks: task-env is not installed (${script})`);
3819
+ return quiet ? undefined : io.out(`○ task stacks: task-env is not installed (${script})`);
3796
3820
  const r = (io.run ?? realRun)("bun", ["--no-env-file", script, "down", String(number)], io.cwd);
3797
3821
  const lines = r.stdout.split(`
3798
- `).filter((l) => l.trim());
3822
+ `).filter((l) => l.trim() && !(quiet && l.startsWith("○")));
3799
3823
  for (const line of lines)
3800
3824
  io.out(line);
3801
3825
  if (r.status !== 0 && !lines.length)
@@ -2,10 +2,10 @@ import {
2
2
  invariant2,
3
3
  codeOnly2,
4
4
  envNamesInCode2
5
- } from "./harness-nn3hnqwn.js";
5
+ } from "./harness-whad9qej.js";
6
6
  import {
7
7
  locale_default
8
- } from "./harness-t9bqz3st.js";
8
+ } from "./harness-91h1qpb5.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}.',
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  locale_default
3
- } from "./harness-t9bqz3st.js";
3
+ } from "./harness-91h1qpb5.js";
4
4
  var __create = Object.create;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __defProp = Object.defineProperty;
@@ -23,7 +23,7 @@ import {
23
23
  envNamesInCode2,
24
24
  dotenvNames2,
25
25
  envVars2
26
- } from "./harness-nn3hnqwn.js";
26
+ } from "./harness-whad9qej.js";
27
27
  export {
28
28
  ENV_SERVICE2 as ENV_SERVICE,
29
29
  codeFiles2 as codeFiles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miroshnik/elves",
3
- "version": "2026.1026.5",
3
+ "version": "2026.1027.1",
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": "b1ea11a6e70c2ffa47d0f8f1141964af54c79f4a"
75
+ "gitHead": "af1dc04656248295ddbc09910f726dafcb145cec"
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}.",
@@ -1106,7 +1106,12 @@ the merge at once — no CI wait (the PR runs none: the slot is free at the
1106
1106
  merge, #676), no deploy wait, no epic refresh (the release's, one per epic)
1107
1107
  and no `task close` — it refuses a task merged only into a batch branch,
1108
1108
  before any change; a task without a PR isn't in the batch — its refresh and
1109
- close are the executor's. `task actualize` names the batch PR as what
1109
+ close are the executor's. The task's stacks don't wait for the release (#765):
1110
+ the assignment names `task-env down <N>` after the merge, before the answer,
1111
+ `task finish` of a PR merged into the batch takes them down too, and the
1112
+ dispatcher's `task queue` — of each task merged into the batch with no open PR
1113
+ (its executor is done), only `+` and `!` lines: a stack already down is said
1114
+ nothing of; `task close` at the release finds them gone — an `○` line. `task actualize` names the batch PR as what
1110
1115
  shipped and leaves the blocked-by links on the task till the release. A cloud
1111
1116
  executor (`--cloud`) isn't in the batch: its PR goes into the default branch
1112
1117
  with the full CI — the dispatcher learns of its end only by the task's
@@ -2678,6 +2678,12 @@ interface ShownTask {
2678
2678
  prs: ShownPr[];
2679
2679
  }
2680
2680
 
2681
+ /** The field values of the task's item in the repository's project (IssueShow) — or of its first item. */
2682
+ function itemValues(i: Any, name: string): Any[] {
2683
+ const items: Any[] = i?.projectItems?.nodes ?? [];
2684
+ return (items.find((it) => it.project?.title === name) ?? items[0])?.fieldValues?.nodes ?? [];
2685
+ }
2686
+
2681
2687
  function showTask(io: Io, slug: string, number: number): ShownTask {
2682
2688
  const [owner, name] = slug.split("/");
2683
2689
  const cloud = inCloud(io);
@@ -2688,7 +2694,7 @@ function showTask(io: Io, slug: string, number: number): ShownTask {
2688
2694
  const type: string | null = i.issueType?.name ?? (labels.includes(EPIC_LABEL) ? N.issueTypes.epic : null);
2689
2695
  const epic = type !== null && locale.every((n) => n.issueTypes.epic).includes(type);
2690
2696
  const items: Any[] = i.projectItems?.nodes ?? [];
2691
- const values: Any[] = (items.find((it) => it.project?.title === name) ?? items[0])?.fieldValues?.nodes ?? [];
2697
+ const values = itemValues(i, name!);
2692
2698
  const num = (field: (n: Names) => string) => values.find((v) => v?.__typename === "ProjectV2ItemFieldNumberValue" && locale.every(field).includes(v.field?.name));
2693
2699
  const status: string | null = values.find((v) => v?.field?.name === STATUS && v.name)?.name ?? null;
2694
2700
  const estimate = num((n) => n.fields.estimate);
@@ -3135,7 +3141,7 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
3135
3141
  const running: string[] = [];
3136
3142
  const waiting: string[] = [];
3137
3143
  /** Of the tasks in work: merged into the batch and nothing else going — they wait only for the release (#649). */
3138
- let settled = 0;
3144
+ const settled: number[] = [];
3139
3145
  /**
3140
3146
  * Of the tasks in work: the batch's live executors — the release waits for them (#696). Without a batch — all of them;
3141
3147
  * with one — a task with an open PR into the batch, or handed out to an executor of the batch (a subagent, an app
@@ -3178,7 +3184,7 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
3178
3184
  if (work.length) {
3179
3185
  running.push(`= ${label} — ${work.join(", ")}`);
3180
3186
  // merged into the batch, no open PR of it: its executor is done, the task waits for the release
3181
- if (merged !== undefined && pr === undefined) settled++;
3187
+ if (merged !== undefined && pr === undefined) settled.push(i.number);
3182
3188
  else if (batch === null) holding++;
3183
3189
  else if (pr !== undefined ? prBase(i, pr) === batch : merged === undefined && hand !== undefined && hand.executor !== "cloud" && !hand.main && !pastBatch(i)) holding++;
3184
3190
  else past.push(`#${i.number}`);
@@ -3211,6 +3217,8 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
3211
3217
  appWorktreeWarning(io);
3212
3218
  // the executor the dispatcher continues with SendMessage — an answered question, a restart — has no lock (#533)
3213
3219
  pruneExecutors(io, slug, handed, isOpen);
3220
+ // 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
3221
+ if (settled.length && checkoutOfRepo(io, originUrl(io), slug)) for (const n of settled) takeDownStacks(io, n, true);
3214
3222
  const group = o.tasks !== undefined ? `tasks ${numbers.map((n) => `#${n}`).join(", ")}` : null;
3215
3223
  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(", ");
3216
3224
  io.out(`Queue ${slug} (${scope}): ready ${ready.length}, ${q(N.status.inProgress)} ${running.length}, not ready ${waiting.length}`);
@@ -3223,7 +3231,7 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
3223
3231
  const releaseCommand = `bun --no-env-file ${import.meta.path} batch release --repo ${slug}`;
3224
3232
  // the owner's word «release» — the same command with live executors: they go on, their PRs wait for the release
3225
3233
  // (question 2 of epic #645)
3226
- 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` : "";
3234
+ 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` : "";
3227
3235
  // outside auto an executor's merge is the owner's «yes» (#667)
3228
3236
  const ask = locale.autoProject(io.cwd ?? process.cwd()) ? "" : `; ${MERGE_ASK}`;
3229
3237
  // a red release (#650): its guilty task by the labels — the fix; the bisect is batch release's, the queue names it
@@ -3241,8 +3249,8 @@ export function cmdTaskQueue(io: Io, slug: string, o: QueueFilter): number {
3241
3249
  `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); ` +
3242
3250
  `the indented line is its whole prompt. After each executor's answer — task queue again: new tasks get in${ask}; ${SESSION_ARCHIVE}${now}.`,
3243
3251
  );
3244
- } 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}.`);
3245
- else if (settled) {
3252
+ } 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}.`);
3253
+ else if (settled.length) {
3246
3254
  io.out(
3247
3255
  `Next: the batch ${batch} is complete — nothing ready, every task of the batch is merged into it: its release — ${releaseCommand}, ` +
3248
3256
  `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}.`,
@@ -4152,6 +4160,7 @@ export function cmdTaskAssignment(io: Io, slug: string, number: number, o: { clo
4152
4160
  repo: slug,
4153
4161
  epic: issue.parent ? locale.fill(N.queue.epic, { epicWord: N.subagentPrompt.epic, epic: issue.parent.number }) : "",
4154
4162
  script: `bun --no-env-file ${import.meta.path}`,
4163
+ taskEnv: `bun --no-env-file ${taskEnvScript(io)}`,
4155
4164
  waitCi: `bash ${waitCi()}`,
4156
4165
  inProgress: N.status.inProgress,
4157
4166
  done: N.lastLine.done,
@@ -4901,7 +4910,8 @@ function pushTaskBranch(io: Io, branch: string): string | null {
4901
4910
  * `--title`, otherwise the branch type's first commit; the body — spec-diff and `Closes #N`; an existing PR — its body
4902
4911
  * updated), decision labels (`pr labels`), the CI wait (ci-wait), `pr premerge` — then the merge command, code 4: the
4903
4912
  * merge stays a separate `gh pr merge <N> --rebase` call — the owner's permission rule in auto mode matches it
4904
- * (claude/CLAUDE.md). After the merge: the deploy wait on the merge SHA, the epic refresh's mechanics and its subagent's
4913
+ * (claude/CLAUDE.md). After the merge (the task is open or already closed by «Closes #N» — the tail is over only by
4914
+ * `task close`'s Status Done and actual, #761): the deploy wait on the merge SHA, the epic refresh's mechanics and its subagent's
4905
4915
  * prompt (code 4), `task close` once its report is on the epic. A PR into a batch branch (#676): no CI to wait for, and
4906
4916
  * after its merge — nothing, the release does the rest. Codes: 0 — finished (closed; merged into a batch), 1 — stopped
4907
4917
  * on something to fix (red CI, a conflict, a push refused, premerge red), 3 — the base is red (premerge), 4 — the agent's
@@ -4914,7 +4924,13 @@ export function cmdTaskFinish(io: Io, slug: string, number: number, o: { timeout
4914
4924
  const stop = (code: number, why: string, next: string) => (io.out(why), io.out(`Next: ${next}`), code);
4915
4925
  const outOfTime = (what: string) => stop(5, `○ out of time (--timeout ${o.timeout}) — ${what}`, `${again} — it goes on from here`);
4916
4926
  const issue = loadIssue(io, slug, number);
4917
- if (issue.state !== "OPEN") return io.out(`= #${number} is closed — nothing to finish`), 0;
4927
+ if (issue.state !== "OPEN") {
4928
+ // «Closes #N» of the PR closes the task at the merge (#761): a closed issue isn't a finished tail — task close's marks are
4929
+ const closer = issue.stateReason === "COMPLETED" ? (issue.prs.find((p) => p.merged && !isBatchBranch(p.base)) ?? null) : null;
4930
+ if (!closer || tailOver(io, slug, number)) return io.out(`= #${number} is closed — nothing to finish`), 0;
4931
+ io.out(`○ #${number} is closed by the merge of PR #${closer.number}, the tail isn't over (no ${q(N.status.done)} with the actual) — going on`);
4932
+ return finishMerged(io, slug, number, issue.parent?.number ?? null, closer, { left, again, stop, outOfTime });
4933
+ }
4918
4934
  if (!checkoutOfRepo(io, originUrl(io), slug)) throw new GhError(`task finish runs from a checkout of ${slug}: the current directory is not one`);
4919
4935
  const found = unlinkedPrs(io, slug, number);
4920
4936
  const prs = [...issue.prs, ...found.prs, ...found.batched].filter((p, k, all) => all.findIndex((x) => x.number === p.number) === k);
@@ -4975,6 +4991,19 @@ export function cmdTaskFinish(io: Io, slug: string, number: number, o: { timeout
4975
4991
  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"}`);
4976
4992
  }
4977
4993
 
4994
+ /**
4995
+ * The tail is over — what `task close` leaves (#761, question 1): Status Done and the actual written, not the issue's
4996
+ * state, which «Closes #N» sets at the merge. In the cloud there is no project to read — over, as before.
4997
+ */
4998
+ function tailOver(io: Io, slug: string, number: number): boolean {
4999
+ if (inCloud(io)) return true;
5000
+ const [owner, name] = slug.split("/");
5001
+ const values = itemValues(graphql(io, Q.IssueShow, { owner, name, number })?.repository?.issue, name!);
5002
+ const done = values.some((v) => v?.field?.name === STATUS && locale.every((n) => n.status.done).includes(v.name));
5003
+ const actual = values.some((v) => v?.__typename === "ProjectV2ItemFieldNumberValue" && locale.every((n) => n.fields.actual).includes(v.field?.name));
5004
+ return done && actual;
5005
+ }
5006
+
4978
5007
  /** `task finish` after the merge: the batch's — nothing; the default branch's — the deploy, the epic refresh, `task close`. */
4979
5008
  function finishMerged(
4980
5009
  io: Io,
@@ -4986,6 +5015,8 @@ function finishMerged(
4986
5015
  ): number {
4987
5016
  if (isBatchBranch(merged.base)) {
4988
5017
  io.out(`✅ PR #${merged.number} is merged into ${merged.base} — #${number} stays ${q(N.status.inProgress)} till the batch's release`);
5018
+ // the task's stacks don't wait for the release (#765): the executor is done, its stack only loads the machine
5019
+ if (checkoutOfRepo(io, originUrl(io), slug)) takeDownStacks(io, number);
4989
5020
  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`);
4990
5021
  return 0;
4991
5022
  }
@@ -5180,13 +5211,15 @@ const taskEnvScript = (io: Io) => io.env["ELVES_TASK_ENV"] ?? path.resolve(impor
5180
5211
  * in the checkout takes the dev and e2e stacks down with their volumes and prints a line per stack (`+`, `○`, `!`) —
5181
5212
  * printed as is; it failed without a line — its error as a `!` line. A failure doesn't stop the close: a stack left
5182
5213
  * behind is found by `task-env prune`. Docker doesn't work in the Claude Code sandbox — task close is an unsandboxed
5183
- * call (SKILL.md).
5214
+ * call (SKILL.md). A batch's task (#765) closes only with the release — its stack goes at the merge into the batch:
5215
+ * `task finish` of the executor, and the dispatcher's `task queue` as insurance (`quiet`: only `+` and `!` lines).
5184
5216
  */
5185
- function takeDownStacks(io: Io, number: number): void {
5217
+ function takeDownStacks(io: Io, number: number, quiet = false): void {
5186
5218
  const script = taskEnvScript(io);
5187
- if (!existsSync(script)) return io.out(`○ task stacks: task-env is not installed (${script})`);
5219
+ if (!existsSync(script)) return quiet ? undefined : io.out(`○ task stacks: task-env is not installed (${script})`);
5188
5220
  const r = (io.run ?? realRun)("bun", ["--no-env-file", script, "down", String(number)], io.cwd);
5189
- const lines = r.stdout.split("\n").filter((l) => l.trim());
5221
+ // quiet — the queue's insurance (#765): a stack already down (`○`) is said nothing of, each queue would repeat it
5222
+ const lines = r.stdout.split("\n").filter((l) => l.trim() && !(quiet && l.startsWith("○")));
5190
5223
  for (const line of lines) io.out(line);
5191
5224
  if (r.status !== 0 && !lines.length) io.out(`! task-env down: ${why(r)}`);
5192
5225
  }