Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
chore: update tend workflows (0.3.19 → 0.3.22) (#4597)
Worktrunk Bot9a7ddfbef56c
diff --git a/.config/tend.yaml b/.config/tend.yamlindex 8cef39c43..10e1849d8 100644--- a/.config/tend.yaml+++ b/.config/tend.yaml@@ -12,7 +12,7 @@ secrets:allowed:- CODECOV_TOKENworkflows:- ci-fix:+ ci-failures:watched_workflows:- ci- coverage@@ -22,7 +22,7 @@ workflows:- affected- publish-docs# nightly hosts `full-tests` (the cargo-affected safety net), so a red- # nightly is actionable: Tend fixes it instead of leaving main's gaps+ # nightly is actionable: Tend triages it instead of leaving main's gaps# uncaught. Tend watches at the workflow level, so this also signs Tend up# for the other nightly jobs (minimal-versions, nix-flake, udeps) — an# accepted trade for keeping the safety net green.diff --git a/.github/nightly-failure.md b/.github/nightly-failure.mddeleted file mode 100644index 0b4f978c5..000000000--- a/.github/nightly-failure.md+++ /dev/null@@ -1,6 +0,0 @@-----title: Nightly tests failed-labels: ci------Nightly tests [failed on {{ date | date('YYYY-MM-DD') }}]({{ env.LINK }})diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yamlindex 9c2c07998..42ba79179 100644--- a/.github/workflows/nightly.yaml+++ b/.github/workflows/nightly.yaml@@ -443,42 +443,3 @@ jobs:- name: nix flake checkrun: nix flake check --print-build-logs --keep-going-- create-issue-on-nightly-failure:- needs:- - feature-powerset- - full-tests- - release-target- - check-unused-dependencies- - minimal-versions- - nix-flake- - crate-build- - link-check- if: always() && contains(needs.*.result, 'failure') && github.repository_owner == 'max-sixty' && github.event_name == 'schedule'- runs-on: ubuntu-24.04- environment:- name: tend- # A secret scope, not a deploy target — see .github/AGENTS.md. The cron- # gate above keeps this off the workflow's pull_request and- # workflow_dispatch triggers, whose refs the `tend` policy can refuse;- # its push trigger is `main`-only, which the policy already admits.- deployment: false- permissions:- contents: read- issues: write- steps:- - name: 📂 Checkout code- uses: actions/checkout@v7-- - uses: JasonEtco/create-an-issue@v2- env:- # Use TEND_BOT_TOKEN for a consistent bot identity (per- # .github/AGENTS.md) and so any future issue-triage automation can- # cascade off issue creation — events from the default GITHUB_TOKEN- # don't trigger other workflows.- GITHUB_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}- LINK: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}- with:- filename: .github/nightly-failure.md- update_existing: true- search_existing: opendiff --git a/.github/workflows/tend-ci-failures.yaml b/.github/workflows/tend-ci-failures.yamlnew file mode 100644index 000000000..37990e1ad--- /dev/null+++ b/.github/workflows/tend-ci-failures.yaml@@ -0,0 +1,55 @@+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init+#+# Do not edit this file directly — it will be overwritten on regeneration.+# To change this workflow, edit .config/tend.yaml. To change what the agent+# does, edit the relevant skill (for example, `running-tend`) in this repo's+# .claude/skills/ directory, or open an issue at+# https://github.com/max-sixty/tend/issues for changes that need to+# happen upstream in the tend-ci-runner plugin.++name: tend-ci-failures+# Turns a watched workflow's verdict on a watched branch into its CI failure+# report, with no agent: a failure files the report or comments on it, and a+# pass closes it. The bot token makes a new report trigger ordinary issue triage.+on:+ workflow_run:+ workflows: ["ci", "coverage", "affected", "publish-docs", "nightly"]+ types: [completed]+ branches: ["main"]++jobs:+ report:+ # Only a verdict reaches the group below. On a busy branch most completions+ # are runs a newer commit cancelled, and each would otherwise take the+ # lane's single pending slot from a verdict waiting in it.+ #+ # Only this repository's own branches, too. A fork PR opened from the+ # fork's `main` runs with `head_branch` set to `main`, which passes the+ # branch filter; reporting it would file and close another lane's report,+ # with a title and logs the fork's author controls.+ if: >-+ github.repository_owner == 'max-sixty' && vars.TEND_ENABLED != 'false'+ && github.event.workflow_run.head_repository.full_name == github.repository+ && (+ github.event.workflow_run.conclusion == 'success'+ || github.event.workflow_run.conclusion == 'failure'+ || github.event.workflow_run.conclusion == 'timed_out'+ || github.event.workflow_run.conclusion == 'startup_failure')+ concurrency:+ # One writer per report, so one lane's verdicts apply in turn and never+ # file two reports. A newer pending verdict replaces an older one, which+ # it supersedes anyway.+ group: ${{ github.workflow }}-${{ github.event.workflow_run.name }}-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.head_branch }}+ cancel-in-progress: false+ runs-on: ubuntu-24.04+ environment:+ name: tend+ deployment: false+ permissions: {}+ steps:+ - uses: max-sixty/tend/[email protected]+ - name: File, update or close the CI failure report+ env:+ GH_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}+ run: |+ tend runtime ci-failure-reportdiff --git a/.github/workflows/tend-ci-fix.yaml b/.github/workflows/tend-ci-fix.yamldeleted file mode 100644index ba20ba4da..000000000--- a/.github/workflows/tend-ci-fix.yaml+++ /dev/null@@ -1,64 +0,0 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init-#-# Do not edit this file directly — it will be overwritten on regeneration.-# To change this workflow, edit .config/tend.yaml. To change what the agent-# does, edit the relevant skill (for example, `running-tend`) in this repo's-# .claude/skills/ directory, or open an issue at-# https://github.com/max-sixty/tend/issues for changes that need to-# happen upstream in the tend-ci-runner plugin.--name: tend-ci-fix-on:- workflow_run:- workflows: ["ci", "coverage", "affected", "publish-docs", "nightly"]- types: [completed]- branches: ["main"]--jobs:- fix-ci:- # By default, only failed runs start a ci-fix session.- if: github.repository_owner == 'max-sixty' && vars.TEND_ENABLED != 'false' && github.event.workflow_run.conclusion == 'failure'- concurrency:- # A red branch fails every push that follows, each on its own commit, so- # one session per branch — not per commit — is what collapses the burst.- # The watched workflow and the run's event are in the key too: a red- # `publish-site` must not starve behind a stream of red `ci`, and a- # pending scheduled failure must not be replaced by the next push- # failure on the same branch. Never cancel — a running session may- # already have pushed a branch or opened a PR. Default queue depth is- # right: within each group, the newest failure replaces the pending one.- group: ${{ github.workflow }}-${{ github.event.workflow_run.name }}-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.head_branch }}- cancel-in-progress: false- runs-on: ubuntu-24.04- environment:- name: tend- deployment: false- permissions:- contents: write- pull-requests: write- actions: read- steps:- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- with:- ref: main- fetch-depth: 0- token: ${{ secrets.TEND_BOT_TOKEN }}-- - uses: ./.github/actions/tend-setup- - run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; done-- - uses: max-sixty/tend/[email protected]- with:- github_token: ${{ secrets.TEND_BOT_TOKEN }}- merge: restricted- openai_api_key: ${{ secrets.OPENAI_API_KEY }}- codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-bot- model: gpt-6-sol- checkout_mode: base- base_branch: ${{ github.event.repository.default_branch }}- prompt: |2- $ci-fix ${{ github.event.workflow_run.id }}- - Run URL: ${{ github.event.workflow_run.html_url }}- - Commit: ${{ github.event.workflow_run.head_sha }}- - Commit message: ${{ github.event.workflow_run.head_commit.message }}diff --git a/.github/workflows/tend-mention-relay.yaml b/.github/workflows/tend-mention-relay.yamlindex fa72182d2..01c180e27 100644--- a/.github/workflows/tend-mention-relay.yaml+++ b/.github/workflows/tend-mention-relay.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agentdiff --git a/.github/workflows/tend-mention.yaml b/.github/workflows/tend-mention.yamlindex 367a662e7..17c08318f 100644--- a/.github/workflows/tend-mention.yaml+++ b/.github/workflows/tend-mention.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agent@@ -48,219 +48,13 @@ jobs:url: ${{ steps.check.outputs.url }}ts: ${{ steps.check.outputs.ts }}steps:- - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0- id: tend_uv- env:- UV_NO_MODIFY_PATH: "1"- with:- version: "0.13.5"- checksum: ${{ runner.arch == 'ARM64' && '4bb69cf95ed13f23713bb7bc09f241896ea0c75b7c557e615a20604b82f9c403' || 'f68d291c75783122dad58ab77def0e13f3233f358731db5d6d7e8715603b928f' }}- enable-cache: false- ignore-empty-workdir: true+ - uses: max-sixty/tend/[email protected]- name: Verify bot engagementid: checkrun: |- "$TEND_UV" run --script - <<'TEND_PY'- # /// script- # requires-python = ">=3.12"- # dependencies = []- # ///- """Decide whether a mention event should start an agent session."""-- from __future__ import annotations-- import json- import os- import subprocess- import sys- from pathlib import Path- from typing import Any--- def gh(*args: str, quiet: bool = False) -> str:- # `gh` colorizes a piped `--json`/`--jq` response when the job's- # environment forces color, and the ANSI codes land inside the body- # `gh_json` parses. `CLICOLOR_FORCE=0` is the setting that defeats it:- # `gh` ranks a forced value above `NO_COLOR`, so `NO_COLOR` alone loses.- env = os.environ.copy()- env.update(NO_COLOR="1", CLICOLOR_FORCE="0")- result = subprocess.run(- ["gh", *args], capture_output=True, text=True, env=env, check=False- )- if result.returncode:- if result.stderr and not quiet:- sys.stderr.write(result.stderr)- raise subprocess.CalledProcessError(- result.returncode, result.args, result.stdout, result.stderr- )- return result.stdout--- def gh_json(*args: str, quiet: bool = False) -> Any:- return json.loads(gh(*args, quiet=quiet))--- def gh_paginated(path: str) -> list[dict[str, Any]]:- # `--slurp` prints one array holding every page.- pages = gh_json("api", "--paginate", "--slurp", path)- if not all(isinstance(page, list) for page in pages):- raise TypeError("paginated GitHub response was not an array")- return [item for page in pages for item in page]--- def actor_login(actor: object) -> str:- """Return a GitHub actor login, including for deleted-account records."""- if not isinstance(actor, dict):- return ""- return str(actor.get("login") or "")--- def actor_type(actor: object) -> str:- """Return a GitHub actor type — `User`, `Bot`, or "" when unrecorded."""- if not isinstance(actor, dict):- return ""- return str(actor.get("type") or "")--- def output(name: str, value: str | bool) -> None:- rendered = str(value).lower() if isinstance(value, bool) else value- with Path(os.environ["GITHUB_OUTPUT"]).open("a", encoding="utf-8") as stream:- stream.write(f"{name}={rendered}\n")--- def verdict(should_run: bool, reason: str = "") -> int:- output("should_run", should_run)- if reason:- output("reason", reason)- return 0--- def main() -> int:- env = os.environ- bot = env.get("BOT_NAME", "")- repo = env.get("GITHUB_REPOSITORY", "")- kind = env.get("EVENT_NAME", "")- comment_body = env.get("COMMENT_BODY", "")- comment_author = env.get("COMMENT_AUTHOR", "")- review_author = ""- review_author_type = ""- review_state = ""- inline: list[dict[str, Any]] = []-- if kind == "repository_dispatch":- kind = env.get("PAYLOAD_KIND", "")- pr = env.get("PAYLOAD_PR", "")- item_id = env.get("PAYLOAD_ID", "")- if not pr.isdigit() or not item_id.isdigit():- print("malformed dispatch payload — skipping")- return verdict(False)- if kind == "pull_request_review":- try:- review = gh_json(- "api", f"repos/{repo}/pulls/{pr}/reviews/{item_id}", quiet=True- )- except (subprocess.CalledProcessError, json.JSONDecodeError):- print(f"review {item_id} not found on PR {pr} — skipping")- return verdict(False)- review_author = actor_login(review.get("user"))- review_author_type = actor_type(review.get("user"))- review_state = str(review["state"]).lower()- comment_body = review.get("body") or ""- output("url", review["html_url"])- output("ts", review.get("submitted_at") or "")- elif kind == "pull_request_review_comment":- try:- comment = gh_json(- "api", f"repos/{repo}/pulls/comments/{item_id}", quiet=True- )- except (subprocess.CalledProcessError, json.JSONDecodeError):- print(f"comment {item_id} not found — skipping")- return verdict(False)- expected_pr = f"https://api.github.com/repos/{repo}/pulls/{pr}"- if comment.get("pull_request_url") != expected_pr:- print(f"comment {item_id} does not belong to PR {pr} — skipping")- return verdict(False)- comment_author = actor_login(comment.get("user"))- comment_body = comment.get("body") or ""- output("url", comment["html_url"])- output("ts", comment["updated_at"])- else:- print(f"unknown dispatch kind '{kind}' — skipping")- return verdict(False)-- if kind == "issues":- return verdict(True)-- if (- kind in {"issue_comment", "pull_request_review_comment"}- and comment_author == bot- ):- return verdict(False)- if comment_body and f"@{bot}" in comment_body:- return verdict(True, "mention")- if kind == "issue_comment" and env.get("COMMENT_AUTHOR_TYPE") == "Bot":- return verdict(False)-- if kind == "pull_request_review":- inline = gh_paginated(- f"repos/{repo}/pulls/{env.get('PAYLOAD_PR', '')}/reviews/"- f"{env.get('PAYLOAD_ID', '')}/comments"- )- if any(f"@{bot}" in (comment.get("body") or "") for comment in inline):- return verdict(True, "mention")- # A review the bot wrote hands work to nobody: the review session- # applies the findings it raised. The mention checks run first, so- # naming the bot in a review still summons a session.- if review_author == bot:- return verdict(False)- # An approval asks nobody for anything; the only thing that can hand- # the bot work alongside one is prose. A person's prose counts, so- # theirs is read. A review bot's is generated status — a code-health- # badge, a "looks safe" template — and weighing it costs a session- # that can only exit silently, once per review bot per push.- if (- review_state == "approved"- and not inline- and (not comment_body or review_author_type == "Bot")- ):- return verdict(False)-- if kind == "issue_comment":- issue_number = env.get("ISSUE_OR_PR_NUMBER", "")- if not env.get("PR_URL"):- if env.get("ISSUE_AUTHOR") == bot or f"@{bot}" in env.get("ISSUE_BODY", ""):- return verdict(True)- comments = gh_paginated(f"repos/{repo}/issues/{issue_number}/comments")- return verdict(- any(actor_login(comment.get("user")) == bot for comment in comments)- )- pr_number = issue_number- else:- pr_number = env.get("PAYLOAD_PR", "")-- pr = gh_json("pr", "view", pr_number, "--repo", repo, "--json", "author")- pr_author = actor_login(pr.get("author"))- if pr_author == bot:- return verdict(True, "participation")-- reviews = gh_paginated(f"repos/{repo}/pulls/{pr_number}/reviews")- if any(actor_login(review.get("user")) == bot for review in reviews):- return verdict(True, "participation")- comments = gh_paginated(f"repos/{repo}/issues/{pr_number}/comments")- if any(actor_login(comment.get("user")) == bot for comment in comments):- return verdict(True, "participation")- return verdict(False)--- if __name__ == "__main__":- try:- raise SystemExit(main())- except subprocess.CalledProcessError as error:- raise SystemExit(error.returncode or 1) from None- TEND_PY+ tend runtime mention-verifyenv:GITHUB_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}- TEND_UV: ${{ steps.tend_uv.outputs.uv-path }}BOT_NAME: worktrunk-botEVENT_NAME: ${{ github.event_name }}COMMENT_BODY: ${{ github.event.comment.body }}@@ -290,6 +84,9 @@ jobs:actions: readissues: writesteps:+ - name: Record job start+ run: echo "TEND_JOB_STARTED_AT=$(date +%s)" >> "$GITHUB_ENV"+ - uses: max-sixty/tend/[email protected]# Both halves of the reaction belong to this job, so the eyes can only# go on once the job that takes them off has started. Put them in# `verify` and `handle` respectively and the routine burst case strands@@ -307,8 +104,7 @@ jobs:|| (github.event.client_payload.kind == 'pull_request_review_comment'&& needs.verify.outputs.reason == 'mention'))run: |- gh api "repos/$REPO/$TARGET/reactions" -f content=eyes --silent \- || echo "::warning::could not add the eyes reaction"+ tend runtime reaction addenv:REPO: ${{ github.repository }}TARGET: ${{ github.event_name == 'issue_comment'@@ -316,17 +112,12 @@ jobs:|| format('pulls/comments/{0}', github.event.client_payload.id) }}GITHUB_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}- # Before checkout and `setup:`, so the delay measures the wait for this- # job to start rather than the time its setup takes.+ # The first step captured job start, before runtime installation,+ # checkout and consumer setup.- name: Compute queue delayid: delayrun: |- if [ -z "$EVENT_TS" ]; then- echo "seconds=" >> "$GITHUB_OUTPUT"- exit 0- fi- event_epoch=$(date -d "$EVENT_TS" +%s)- echo "seconds=$(( $(date +%s) - event_epoch ))" >> "$GITHUB_OUTPUT"+ tend runtime queue-delayenv:# A relayed event's timestamp comes from verify, which read it off# the API record — the dispatch payload never carries one to spoof.@@ -340,13 +131,12 @@ jobs:- uses: ./.github/actions/tend-setup- run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; done- - uses: max-sixty/tend/[email protected]+ - uses: max-sixty/tend/[email protected]with:github_token: ${{ secrets.TEND_BOT_TOKEN }}merge: restrictedopenai_api_key: ${{ secrets.OPENAI_API_KEY }}codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-botmodel: gpt-6-solcheckout_mode: mentionbase_branch: ${{ github.event.repository.default_branch }}@@ -379,13 +169,7 @@ jobs:|| (github.event.client_payload.kind == 'pull_request_review_comment'&& needs.verify.outputs.reason == 'mention'))run: |- REACTION_ID=$(gh api --paginate \- "repos/$REPO/$TARGET/reactions?content=eyes&per_page=100" \- --jq ".[] | select(.user.login == \"$BOT_NAME\") | .id" | head -n1)- if [ -n "$REACTION_ID" ]; then- gh api -X DELETE "repos/$REPO/$TARGET/reactions/$REACTION_ID" --silent \- || echo "::warning::could not remove the eyes reaction"- fi+ tend runtime reaction removeenv:REPO: ${{ github.repository }}TARGET: ${{ github.event_name == 'issue_comment'diff --git a/.github/workflows/tend-nightly.yaml b/.github/workflows/tend-nightly.yamlindex b5ca928c2..16516e5ed 100644--- a/.github/workflows/tend-nightly.yaml+++ b/.github/workflows/tend-nightly.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agent@@ -26,6 +26,7 @@ jobs:actions: readissues: writesteps:+ - uses: max-sixty/tend/[email protected]- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:ref: main@@ -35,13 +36,12 @@ jobs:- uses: ./.github/actions/tend-setup- run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; done- - uses: max-sixty/tend/[email protected]+ - uses: max-sixty/tend/[email protected]with:github_token: ${{ secrets.TEND_BOT_TOKEN }}merge: restrictedopenai_api_key: ${{ secrets.OPENAI_API_KEY }}codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-botmodel: gpt-6-solcheckout_mode: basebase_branch: ${{ github.event.repository.default_branch }}diff --git a/.github/workflows/tend-notifications.yaml b/.github/workflows/tend-notifications.yamlindex 33f2ce393..ab45447f7 100644--- a/.github/workflows/tend-notifications.yaml+++ b/.github/workflows/tend-notifications.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agent@@ -29,200 +29,13 @@ jobs:actions: readissues: writesteps:- - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0- id: tend_uv- env:- UV_NO_MODIFY_PATH: "1"- with:- version: "0.13.5"- checksum: ${{ runner.arch == 'ARM64' && '4bb69cf95ed13f23713bb7bc09f241896ea0c75b7c557e615a20604b82f9c403' || 'f68d291c75783122dad58ab77def0e13f3233f358731db5d6d7e8715603b928f' }}- enable-cache: false- ignore-empty-workdir: true- - name: Check for unread notifications and conflicted PRs+ - uses: max-sixty/tend/[email protected]+ - name: Check notifications and conflictsid: checkenv:GITHUB_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}- TEND_UV: ${{ steps.tend_uv.outputs.uv-path }}run: |- "$TEND_UV" run --script - <<'TEND_PY'- # /// script- # requires-python = ">=3.12"- # dependencies = []- # ///- """Decide whether the notifications workflow has work for an agent."""-- from __future__ import annotations-- import json- import os- import subprocess- import sys- from datetime import UTC, datetime, timedelta- from pathlib import Path- from typing import Any-- GRAPHQL_QUERY = """- query($q: String!) {- search(query: $q, type: ISSUE, first: 100) {- nodes { ... on PullRequest {- mergeable headRefOid- comments(last: 100) { nodes { author { login } body } }- } }- }- }- """--- def _gh(*args: str, quiet: bool = False) -> str:- # `gh` colorizes a piped `--json`/`--jq` response when the job's- # environment forces color, and the ANSI codes land inside the body- # `_json` parses. `CLICOLOR_FORCE=0` is the setting that defeats it:- # `gh` ranks a forced value above `NO_COLOR`, so `NO_COLOR` alone loses.- env = os.environ.copy()- env.update(NO_COLOR="1", CLICOLOR_FORCE="0")- result = subprocess.run(- ["gh", *args],- capture_output=True,- text=True,- env=env,- check=False,- )- if result.returncode:- if result.stderr and not quiet:- sys.stderr.write(result.stderr)- raise subprocess.CalledProcessError(- result.returncode, result.args, result.stdout, result.stderr- )- return result.stdout--- def _json(*args: str, quiet: bool = False) -> Any:- return json.loads(_gh(*args, quiet=quiet))--- def _paginated(path: str) -> list[Any]:- # `--slurp` prints one array holding every page.- pages = _json("api", "--paginate", "--slurp", path, quiet=True)- if not all(isinstance(page, list) for page in pages):- raise TypeError("paginated GitHub response was not an array")- return [item for page in pages for item in page]--- def _output(name: str, value: str | int) -> None:- with Path(os.environ["GITHUB_OUTPUT"]).open("a", encoding="utf-8") as stream:- stream.write(f"{name}={value}\n")--- def _notifications(cutoff: str) -> int:- try:- return len(_paginated(f"notifications?before={cutoff}"))- except (json.JSONDecodeError, subprocess.CalledProcessError, TypeError):- print("::warning::notifications fetch failed; queue left for the next cycle")- return 0--- def _actor_login(actor: object) -> str:- if not isinstance(actor, dict):- return ""- return str(actor.get("login") or "")--- def _is_deferred(pr: dict[str, Any], bot: str) -> bool:- marker = f"<!-- tend-conflict-deferred head={pr.get('headRefOid', '')} -->"- comments = pr.get("comments")- nodes = comments.get("nodes", []) if isinstance(comments, dict) else []- return any(- _actor_login(comment.get("author")) == bot- and str(comment.get("body") or "").rstrip().split("\n")[-1] == marker- for comment in nodes- if isinstance(comment, dict)- )--- def _conflicts(repo: str) -> int:- try:- bot = _gh("api", "user", "--jq", ".login", quiet=True).strip()- if not bot:- raise ValueError("authenticated GitHub login was empty")- response = _json(- "api",- "graphql",- "-f",- f"query={GRAPHQL_QUERY}",- "-f",- f"q=repo:{repo} author:{bot} is:pr is:open",- quiet=True,- )- nodes = response["data"]["search"]["nodes"]- if not isinstance(nodes, list):- raise TypeError("GraphQL search nodes were not an array")- # `mergeable` is computed lazily: the first read after the base branch- # moves returns `UNKNOWN` and enqueues the computation, so counting- # anything but a settled `CONFLICTING` boots a session after every merge- # into the default branch. A conflict behind an `UNKNOWN` is counted on- # the next poll, which reads the value this one enqueued; the resolver- # test-merges locally either way.- return sum(- pr.get("mergeable") == "CONFLICTING" and not _is_deferred(pr, bot)- for pr in nodes- if isinstance(pr, dict)- )- except (- json.JSONDecodeError,- KeyError,- subprocess.CalledProcessError,- TypeError,- ValueError,- ):- print("::warning::bot PR conflict scan failed; retrying next cycle")- return 0--- #: How old a notification must be before this poll takes it. The event run a- #: notification started usually finishes, and marks it read, within this, so a- #: poll doesn't boot a session only to find that run still holds its subject.- GRACE = timedelta(minutes=10)--- def main(*, now: datetime | None = None) -> int:- repo = os.environ["GITHUB_REPOSITORY"]- cutoff = ((now or datetime.now(UTC)) - GRACE).strftime("%Y-%m-%dT%H:%M:%SZ")- _output("cutoff", cutoff)-- try:- _gh(- "api",- f"repos/{repo}/subscription",- "-X",- "PUT",- "-F",- "subscribed=true",- "-F",- "ignored=false",- "--silent",- quiet=True,- )- except subprocess.CalledProcessError:- print("::warning::could not enable repository watching; retrying next cycle")-- count = _notifications(cutoff)- _output("count", count)- conflict_count = _conflicts(repo)- _output("conflict_count", conflict_count)-- if count == 0 and conflict_count == 0:- print("No notification or conflict work — skipping")- else:- if count:- print(f"{count} notification task(s) — proceeding")- if conflict_count:- print(f"{conflict_count} possible conflicted bot PR(s) — proceeding")- return 0--- if __name__ == "__main__":- raise SystemExit(main())- TEND_PY+ tend runtime notifications-check- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1if: steps.check.outputs.count != '0' || steps.check.outputs.conflict_count != '0' || github.event_name == 'workflow_dispatch'@@ -235,14 +48,13 @@ jobs:if: steps.check.outputs.count != '0' || steps.check.outputs.conflict_count != '0' || github.event_name == 'workflow_dispatch'- run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; doneif: steps.check.outputs.count != '0' || steps.check.outputs.conflict_count != '0' || github.event_name == 'workflow_dispatch'- - uses: max-sixty/tend/[email protected]+ - uses: max-sixty/tend/[email protected]if: steps.check.outputs.count != '0' || steps.check.outputs.conflict_count != '0' || github.event_name == 'workflow_dispatch'with:github_token: ${{ secrets.TEND_BOT_TOKEN }}merge: restrictedopenai_api_key: ${{ secrets.OPENAI_API_KEY }}codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-botmodel: gpt-6-solcheckout_mode: basebase_branch: ${{ github.event.repository.default_branch }}diff --git a/.github/workflows/tend-review-runs.yaml b/.github/workflows/tend-review-runs.yamlindex f79588b39..0c0038741 100644--- a/.github/workflows/tend-review-runs.yaml+++ b/.github/workflows/tend-review-runs.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agent@@ -26,6 +26,7 @@ jobs:actions: readissues: writesteps:+ - uses: max-sixty/tend/[email protected]- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:ref: main@@ -35,13 +36,12 @@ jobs:- uses: ./.github/actions/tend-setup- run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; done- - uses: max-sixty/tend/[email protected]+ - uses: max-sixty/tend/[email protected]with:github_token: ${{ secrets.TEND_BOT_TOKEN }}merge: restrictedopenai_api_key: ${{ secrets.OPENAI_API_KEY }}codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-botmodel: gpt-6-solcheckout_mode: basebase_branch: ${{ github.event.repository.default_branch }}diff --git a/.github/workflows/tend-review.yaml b/.github/workflows/tend-review.yamlindex a82419f4f..26201de09 100644--- a/.github/workflows/tend-review.yaml+++ b/.github/workflows/tend-review.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agent@@ -33,10 +33,10 @@ jobs:actions: readissues: writesteps:+ - uses: max-sixty/tend/[email protected]- name: React with eyesrun: |- gh api "repos/$REPO/$TARGET/reactions" -f content=eyes --silent \- || echo "::warning::could not add the eyes reaction"+ tend runtime reaction addenv:REPO: ${{ github.repository }}TARGET: issues/${{ github.event.pull_request.number }}@@ -53,13 +53,12 @@ jobs:- uses: ./.github/actions/tend-setup- run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; done- - uses: max-sixty/tend/[email protected]+ - uses: max-sixty/tend/[email protected]with:github_token: ${{ secrets.TEND_BOT_TOKEN }}merge: restrictedopenai_api_key: ${{ secrets.OPENAI_API_KEY }}codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-botmodel: gpt-6-solcheckout_mode: reviewbase_branch: ${{ github.event.pull_request.base.ref }}@@ -69,13 +68,7 @@ jobs:- name: Remove the eyes reactionif: always()run: |- REACTION_ID=$(gh api --paginate \- "repos/$REPO/$TARGET/reactions?content=eyes&per_page=100" \- --jq ".[] | select(.user.login == \"$BOT_NAME\") | .id" | head -n1)- if [ -n "$REACTION_ID" ]; then- gh api -X DELETE "repos/$REPO/$TARGET/reactions/$REACTION_ID" --silent \- || echo "::warning::could not remove the eyes reaction"- fi+ tend runtime reaction removeenv:REPO: ${{ github.repository }}TARGET: issues/${{ github.event.pull_request.number }}diff --git a/.github/workflows/tend-triage.yaml b/.github/workflows/tend-triage.yamlindex 8c07dee3e..296af3e83 100644--- a/.github/workflows/tend-triage.yaml+++ b/.github/workflows/tend-triage.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agent@@ -8,18 +8,56 @@# happen upstream in the tend-ci-runner plugin.name: tend-triage+# Keep the selected IDs visible before matrix jobs exist, including while queued.+run-name: triage ${{ inputs.issues || format('[{0}]', github.event.issue.number) }}on:issues:- types: [opened]+ types: [opened, reopened]+ workflow_dispatch:+ inputs:+ issues:+ description: JSON array of issue numbers; use the triage-batch dispatch command to split large selections+ type: string+ required: true+# The whole batch holds the lane: overlapping events cannot multiply the cap.concurrency:- group: ${{ github.workflow }}-${{ github.event.issue.number }}- cancel-in-progress: true+ group: tend-triage+ cancel-in-progress: false+ queue: maxjobs:- triage:+ select:if: github.repository_owner == 'max-sixty' && vars.TEND_ENABLED != 'false' && contains(github.event.issue.labels.*.name, 'tend-outage') == false && contains(github.event.issue.labels.*.name, 'tend-rate-limit') == falseruns-on: ubuntu-24.04+ environment:+ name: tend+ deployment: false+ permissions:+ contents: read+ outputs:+ issues: ${{ steps.select.outputs.issues }}+ steps:+ - uses: max-sixty/tend/[email protected]+ - name: Select current issues+ id: select+ env:+ GITHUB_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}+ ISSUES: ${{ inputs.issues || format('[{0}]', github.event.issue.number) }}+ BOOKKEEPING_LABELS: '["tend-outage", "tend-rate-limit"]'+ run: |+ tend runtime triage-batch select++ triage:+ needs: select+ if: needs.select.outputs.issues != '[]'+ name: "triage #${{ matrix.issue }}"+ strategy:+ fail-fast: false+ max-parallel: 5+ matrix:+ issue: ${{ fromJSON(needs.select.outputs.issues) }}+ runs-on: ubuntu-24.04environment:name: tenddeployment: false@@ -28,14 +66,16 @@ jobs:pull-requests: writeactions: readissues: write+ env:+ TEND_ISSUE_NUMBER: ${{ matrix.issue }}steps:+ - uses: max-sixty/tend/[email protected]- name: React with eyesrun: |- gh api "repos/$REPO/$TARGET/reactions" -f content=eyes --silent \- || echo "::warning::could not add the eyes reaction"+ tend runtime reaction addenv:REPO: ${{ github.repository }}- TARGET: issues/${{ github.event.issue.number }}+ TARGET: issues/${{ matrix.issue }}GITHUB_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1@@ -47,31 +87,24 @@ jobs:- uses: ./.github/actions/tend-setup- run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; done- - uses: max-sixty/tend/[email protected]+ - uses: max-sixty/tend/[email protected]with:github_token: ${{ secrets.TEND_BOT_TOKEN }}merge: restrictedopenai_api_key: ${{ secrets.OPENAI_API_KEY }}codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-botmodel: gpt-6-solcheckout_mode: basebase_branch: ${{ github.event.repository.default_branch }}prompt: |2- $triage ${{ github.event.issue.number }}+ $triage ${{ matrix.issue }}- name: Remove the eyes reactionif: always()run: |- REACTION_ID=$(gh api --paginate \- "repos/$REPO/$TARGET/reactions?content=eyes&per_page=100" \- --jq ".[] | select(.user.login == \"$BOT_NAME\") | .id" | head -n1)- if [ -n "$REACTION_ID" ]; then- gh api -X DELETE "repos/$REPO/$TARGET/reactions/$REACTION_ID" --silent \- || echo "::warning::could not remove the eyes reaction"- fi+ tend runtime reaction removeenv:REPO: ${{ github.repository }}- TARGET: issues/${{ github.event.issue.number }}+ TARGET: issues/${{ matrix.issue }}BOT_NAME: worktrunk-botGITHUB_TOKEN: ${{ secrets.TEND_BOT_TOKEN }}diff --git a/.github/workflows/tend-weekly.yaml b/.github/workflows/tend-weekly.yamlindex e4dcb1758..2410e70d1 100644--- a/.github/workflows/tend-weekly.yaml+++ b/.github/workflows/tend-weekly.yaml@@ -1,4 +1,4 @@-# Generated by tend 0.3.15. Regenerate with: uvx tend@latest init+# Generated by tend 0.3.22. Regenerate with: uvx tend@latest init## Do not edit this file directly — it will be overwritten on regeneration.# To change this workflow, edit .config/tend.yaml. To change what the agent@@ -26,6 +26,7 @@ jobs:actions: readissues: writesteps:+ - uses: max-sixty/tend/[email protected]- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:ref: main@@ -35,13 +36,12 @@ jobs:- uses: ./.github/actions/tend-setup- run: for t in cargo-insta cargo-nextest pre-commit nu nix; do command -v "$t" >/dev/null || { echo "::error::tend setup is missing $t; see Sandbox toolchain in .github/AGENTS.md"; exit 1; }; done- - uses: max-sixty/tend/[email protected]+ - uses: max-sixty/tend/[email protected]with:github_token: ${{ secrets.TEND_BOT_TOKEN }}merge: restrictedopenai_api_key: ${{ secrets.OPENAI_API_KEY }}codex_auth_json: ${{ secrets.CODEX_AUTH_JSON }}- bot_name: worktrunk-botmodel: gpt-6-solcheckout_mode: basebase_branch: ${{ github.event.repository.default_branch }}