@miroshnik/elves 2026.1026.5 → 2026.1027.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.
@@ -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);
@@ -3573,8 +3577,13 @@ function cmdTaskFinish(io, slug, number, o) {
3573
3577
  const stop = (code, why, next) => (io.out(why), io.out(`Next: ${next}`), code);
3574
3578
  const outOfTime = (what) => stop(5, `○ out of time (--timeout ${o.timeout}) — ${what}`, `${again} — it goes on from here`);
3575
3579
  const issue = loadIssue(io, slug, number);
3576
- if (issue.state !== "OPEN")
3577
- return io.out(`= #${number} is closed — nothing to finish`), 0;
3580
+ if (issue.state !== "OPEN") {
3581
+ const closer = issue.stateReason === "COMPLETED" ? issue.prs.find((p) => p.merged && !isBatchBranch(p.base)) ?? null : null;
3582
+ if (!closer || tailOver(io, slug, number))
3583
+ return io.out(`= #${number} is closed — nothing to finish`), 0;
3584
+ 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`);
3585
+ return finishMerged(io, slug, number, issue.parent?.number ?? null, closer, { left, again, stop, outOfTime });
3586
+ }
3578
3587
  if (!checkoutOfRepo(io, originUrl(io), slug))
3579
3588
  throw new GhError(`task finish runs from a checkout of ${slug}: the current directory is not one`);
3580
3589
  const found = unlinkedPrs(io, slug, number);
@@ -3652,6 +3661,15 @@ function cmdTaskFinish(io, slug, number, o) {
3652
3661
  const yes = locale_default.autoProject(io.cwd ?? process.cwd()) ? "" : "the owner's «yes» (the project is without auto) — then ";
3653
3662
  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
3663
  }
3664
+ function tailOver(io, slug, number) {
3665
+ if (inCloud(io))
3666
+ return true;
3667
+ const [owner, name] = slug.split("/");
3668
+ const values = itemValues(graphql(io, Q.IssueShow, { owner, name, number })?.repository?.issue, name);
3669
+ const done = values.some((v) => v?.field?.name === STATUS && locale_default.every((n) => n.status.done).includes(v.name));
3670
+ const actual = values.some((v) => v?.__typename === "ProjectV2ItemFieldNumberValue" && locale_default.every((n) => n.fields.actual).includes(v.field?.name));
3671
+ return done && actual;
3672
+ }
3655
3673
  function finishMerged(io, slug, number, epicNumber, merged, f) {
3656
3674
  if (isBatchBranch(merged.base)) {
3657
3675
  io.out(`✅ PR #${merged.number} is merged into ${merged.base} — #${number} stays ${q(N.status.inProgress)} till the batch's release`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miroshnik/elves",
3
- "version": "2026.1026.5",
3
+ "version": "2026.1027.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": "b1ea11a6e70c2ffa47d0f8f1141964af54c79f4a"
75
+ "gitHead": "c8aefea287e10052ba441d63042d2981c1e025f5"
76
76
  }
@@ -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);
@@ -4901,7 +4907,8 @@ function pushTaskBranch(io: Io, branch: string): string | null {
4901
4907
  * `--title`, otherwise the branch type's first commit; the body — spec-diff and `Closes #N`; an existing PR — its body
4902
4908
  * updated), decision labels (`pr labels`), the CI wait (ci-wait), `pr premerge` — then the merge command, code 4: the
4903
4909
  * 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
4910
+ * (claude/CLAUDE.md). After the merge (the task is open or already closed by «Closes #N» — the tail is over only by
4911
+ * `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
4912
  * 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
4913
  * after its merge — nothing, the release does the rest. Codes: 0 — finished (closed; merged into a batch), 1 — stopped
4907
4914
  * 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 +4921,13 @@ export function cmdTaskFinish(io: Io, slug: string, number: number, o: { timeout
4914
4921
  const stop = (code: number, why: string, next: string) => (io.out(why), io.out(`Next: ${next}`), code);
4915
4922
  const outOfTime = (what: string) => stop(5, `○ out of time (--timeout ${o.timeout}) — ${what}`, `${again} — it goes on from here`);
4916
4923
  const issue = loadIssue(io, slug, number);
4917
- if (issue.state !== "OPEN") return io.out(`= #${number} is closed — nothing to finish`), 0;
4924
+ if (issue.state !== "OPEN") {
4925
+ // «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
4926
+ const closer = issue.stateReason === "COMPLETED" ? (issue.prs.find((p) => p.merged && !isBatchBranch(p.base)) ?? null) : null;
4927
+ if (!closer || tailOver(io, slug, number)) return io.out(`= #${number} is closed — nothing to finish`), 0;
4928
+ 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`);
4929
+ return finishMerged(io, slug, number, issue.parent?.number ?? null, closer, { left, again, stop, outOfTime });
4930
+ }
4918
4931
  if (!checkoutOfRepo(io, originUrl(io), slug)) throw new GhError(`task finish runs from a checkout of ${slug}: the current directory is not one`);
4919
4932
  const found = unlinkedPrs(io, slug, number);
4920
4933
  const prs = [...issue.prs, ...found.prs, ...found.batched].filter((p, k, all) => all.findIndex((x) => x.number === p.number) === k);
@@ -4975,6 +4988,19 @@ export function cmdTaskFinish(io: Io, slug: string, number: number, o: { timeout
4975
4988
  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
4989
  }
4977
4990
 
4991
+ /**
4992
+ * The tail is over — what `task close` leaves (#761, question 1): Status Done and the actual written, not the issue's
4993
+ * state, which «Closes #N» sets at the merge. In the cloud there is no project to read — over, as before.
4994
+ */
4995
+ function tailOver(io: Io, slug: string, number: number): boolean {
4996
+ if (inCloud(io)) return true;
4997
+ const [owner, name] = slug.split("/");
4998
+ const values = itemValues(graphql(io, Q.IssueShow, { owner, name, number })?.repository?.issue, name!);
4999
+ const done = values.some((v) => v?.field?.name === STATUS && locale.every((n) => n.status.done).includes(v.name));
5000
+ const actual = values.some((v) => v?.__typename === "ProjectV2ItemFieldNumberValue" && locale.every((n) => n.fields.actual).includes(v.field?.name));
5001
+ return done && actual;
5002
+ }
5003
+
4978
5004
  /** `task finish` after the merge: the batch's — nothing; the default branch's — the deploy, the epic refresh, `task close`. */
4979
5005
  function finishMerged(
4980
5006
  io: Io,