Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tasks, one pod per run (rax's pod runner), on a Claude subscription rather than
| `issue-worker` | on its own schedule, one issue per run | the oldest open issue labelled `agent-ready` by someone who can write to the repository, and the repository at `main` | **a pull request** that closes it, on `agents/issue-<n>`; or, when it cannot, a comment on the issue saying why, and the label `agent-blocked` |
| `gramatico-loop` | its own task, on [piabrota/gramatico](https://github.com/piabrota/gramatico), as the App **pirsig-2nd-brain** | one approved issue, or the failed checks of its own open pull request, and the repository | one pull request at a time, its repairs, and a comment that stops and asks a person when the attempts run out |
| `health-digest` | once a day | the box's health snapshot (the ConfigMap `ax-tasks/health-snapshot`, which the box writes), the last deploys, the previous digest and the last week's from memory | a comment on the open issue labelled `health-digest` (opened the first time) |
| `tyler-durden-bot` | not in `tick`: inside Hermes on piabrota2, from a webhook, as the App **tyler-durden-bot** ([`tyler-durden-bot/`](tyler-durden-bot/README.md)) | each pull request opened on `h0ffmann/proof` whose code, comment or markdown lines reach a threshold of `tyler-durden-bot/config.toml` | one comment: TLDR, ELI5, summary, and a risk (very low to critical) with its confidence |

`agent tick` runs the agents that watch GitHub one after the other in one pod, every few minutes:
each exits in seconds when there is nothing new, without calling Claude, and one that fails does
Expand Down
12 changes: 12 additions & 0 deletions apps/tyler-durden-bot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "tyler-durden-bot",
"description": "Summarizes large pull requests on h0ffmann/proof in one comment: TLDR, ELI5, summary, risk. It reads pull requests and comments on them; it never pushes, approves or merges.",
"url": "https://github.com/piabrota/agents/tree/main/tyler-durden-bot",
"hook_attributes": { "url": "https://tyler.piabrota.art/p/tyler-durden/webhooks/tyler-durden", "active": true },
"public": false,
"default_permissions": {
"pull_requests": "write",
"metadata": "read"
},
"default_events": ["pull_request"]
}
5 changes: 4 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Strict rules for the repository's Python (test/fake_github.py today), checked by
# Strict rules for the repository's Python (test/fake_github.py and tyler-durden-bot/), checked by
# .github/workflows/code-smell.yml. Every rule, minus the ones that contradict each other or the
# formatter.
target-version = "py310"
Expand All @@ -16,3 +16,6 @@ ignore = [
[lint.per-file-ignores]
# test/ holds scripts the tests run, not a package.
"test/*" = ["INP001"]
# tyler-durden-bot/ is a Hermes route script and its tests, copied one by one onto the box.
"tyler-durden-bot/*" = ["INP001"]
"tyler-durden-bot/test_*.py" = ["INP001", "S101"]
3 changes: 3 additions & 0 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ while IFS=$'\t' read -r _ r; do
done < <(grep -v '^#' rules/transient.txt) || true
check "every rule in rules/transient.txt is a valid regular expression" "[ $bad_rules -eq 0 ]"

# tyler-durden-bot: its Hermes route script, offline (tyler-durden-bot/test_filter.py).
check "tyler-durden-bot's filter passes its tests" "python3 -m unittest discover -q -s tyler-durden-bot 2>/dev/null"

echo
if [ "$fails" -ne 0 ]; then
echo "$fails failed"
Expand Down
37 changes: 37 additions & 0 deletions tyler-durden-bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# tyler-durden-bot

Summarizes a large pull request on `h0ffmann/proof` in one comment, as the GitHub App
**tyler-durden-bot** (owned by h0ffmann). Unlike the other agents here it is not a task of `agent
tick`: it runs inside Hermes on piabrota2, from a webhook, when a pull request is opened. nix-os'
`tyler-durden-bot.nix` installs these files at a pinned commit.

| File | Is |
|---|---|
| `config.toml` | The watchlist and the three parts of the config: `[trigger]` (thresholds of code, comment and markdown lines, and per language by extension), `[sections]` (TLDR, ELI5, summary, risk: on or off) and `[quality]` (the diff's token budget, the risk's minimum confidence, the summary's length) |
| `filter.py` | The Hermes route script: drops the event (`[SILENT]`) unless the pull request was opened on a watched repository by an allowed author and a threshold is reached; otherwise reads its files from GitHub and gives the route's prompt the counts, the sections and the diff, cut to the budget. Python's standard library only |
| `skill/SKILL.md` | The Hermes skill that writes the comment: the sections, the five risk levels (very low, low, medium, high, critical) and the confidence, the rules (no `@`, no secrets, no verdict on merging), the footer |
| `test_filter.py` | Its tests, offline: `python3 -m unittest discover -s tyler-durden-bot` (also in `test/run.sh`) |
| `../apps/tyler-durden-bot.json` | The App's manifest: Pull requests read and write, Metadata read, the `pull_request` event, the webhook URL |

## How a pull request becomes a comment

1. GitHub sends `pull_request` to `https://tyler.piabrota.art/p/tyler-durden/webhooks/tyler-durden`,
signed with the App's webhook secret. nginx passes only that path to Hermes's webhook port, on
127.0.0.1.
2. Hermes checks the signature and the event, and runs `filter.py` with the payload on stdin.
3. The filter counts each file's changed lines: markdown by extension; code and comment lines by
the language's comment markers (`line_comment`, `block_comment`), line by line through the patch.
It is a heuristic: a block opened outside the patch's lines, or `//` inside a string, is
miscounted. An extension that no language lists counts as code; a file with no patch (binary,
too large) counts its additions and deletions as code.
4. When any threshold is reached, the route's prompt, the skill and Claude (Hermes's model) write the
comment, and Hermes posts it with the `tyler-durden` profile's token: `tyler-durden-bot[bot]`.

A push to an open pull request, a reopen and a draft made ready do not run it again.

## The App

Create it on h0ffmann's account from `apps/tyler-durden-bot.json` (Settings, Developer settings,
GitHub Apps): Pull requests read and write, Metadata read, the Pull request event, a webhook secret
of 32 random bytes. Install it on `h0ffmann/proof` only. The App ID, its private key and the
webhook secret go to the box, never here (nix-os' `docs/TYLER-DURDEN.md`).
78 changes: 78 additions & 0 deletions tyler-durden-bot/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# tyler-durden-bot: when it summarizes a pull request, what the comment carries, and how hard it
# tries. Read by filter.py on every pull_request event; Hermes installs it beside the script.
# Lines are a pull request's additions plus deletions, from each file's patch.

# The watchlist. The App is installed on these repositories only; an event from any other is dropped.
repos = ["h0ffmann/proof"]

# Files that never count and never reach the model.
ignore = ["*.lock", "package-lock.json", "flake.lock", "Cargo.lock", "*.svg", "*.pdf", "*.png", "*.jpg"]

# Extensions counted as markdown, not as code.
markdown = [".md", ".mdx", ".markdown"]

# --- trigger: when the bot runs. Only on `opened`. A pull request is summarized when any threshold
# below is reached (>=). 0 turns a threshold off.
[trigger]
code = 1000
comment = 1000
markdown = 1000
total = 0 # code + comment + markdown together
authors = [] # empty: every author
skip_bots = true # authors whose type is Bot (dependabot, piabrota-ops, piabrota-hermes)

# One table per language, found by extension. line_comment and block_comment tell comment lines
# from code. A language may set its own code, comment or total threshold, counted on its own lines
# only; it does not replace the global ones. An extension that no language lists counts as code.
[languages.rust]
extensions = [".rs"]
line_comment = ["//"]
block_comment = [["/*", "*/"]]

[languages.lean]
extensions = [".lean"]
line_comment = ["--"]
block_comment = [["/-", "-/"]]

[languages.nix]
extensions = [".nix"]
line_comment = ["#"]
block_comment = [["/*", "*/"]]

[languages.python]
extensions = [".py"]
line_comment = ["#"]
block_comment = [['"""', '"""']]

[languages.shell]
extensions = [".sh", ".bash"]
line_comment = ["#"]
block_comment = []

[languages.haskell]
extensions = [".hs"]
line_comment = ["--"]
block_comment = [["{-", "-}"]]

[languages.typescript]
extensions = [".ts", ".tsx", ".js", ".jsx", ".mjs"]
line_comment = ["//"]
block_comment = [["/*", "*/"]]

[languages.gleam]
extensions = [".gleam"]
line_comment = ["//"]
block_comment = []

# --- sections: what the comment carries, in this order.
[sections]
tldr = true
eli5 = true
summary = true
risk = true

# --- quality: how much the model reads and what it is allowed to show.
[quality]
max_input_tokens = 80000 # the diff is cut above this (about 4 characters a token)
min_confidence = 0.6 # a risk below this confidence is not shown
summary_max_items = 7
Loading
Loading