Skip to content

Filter bots by labels with a labels: expression in the bot file - #562

Merged
mcwhittemore merged 2 commits into
mainfrom
issue-561-label-filter
Nov 25, 2026
Merged

mcwhittemore merged 2 commits into
mainfrom
issue-561-label-filter

Conversation

@loopway-bot

Copy link
Copy Markdown
Contributor

Closes #561.

A bot's front matter can now say which labels a subject needs before the bot starts a thread on it, so different bots can take different kinds of issue and pull request. init-scratch gets an epic bot, and the dev bot skips epic issues.

What it does

  • labels: epic needs the label. labels: "!epic" needs it absent. { and: [...] }, { or: [...] } and { not: ... } combine them, and a bare list means and. Label names ignore case.
  • A bot with no labels: takes every subject, as before.
  • It applies to issues and pull requests alike, when a subject is found, when a thread creates it, and when it is assigned to you.
  • Subjects now carry their labels. The poller keeps them current from labeled and unlabeled updates, so a bot that wants epic starts when the label arrives later.
  • A bad labels: value fails with the file name, like the other keys.
  • init-scratch writes epic.md (labels: epic) and gives dev.md labels: "!epic".
  • README, docs/developing.md and CHANGELOG are updated, and the CLI goes to 2.2.0.

Worth knowing

  • The issue didn't give the syntax, so I chose YAML: and/or/not keys, plus a ! prefix on a name. ! has to be quoted in YAML ("!epic").
  • A thread that is already open isn't closed when a label that excludes its bot is added. Labels only decide whether a thread starts.
  • Labels stay on the stored subject, so state files written by older versions have none and read as unlabeled until the next label event.

Test it locally

npm run build && npm test && npm run typecheck && npm run lint && npm run format:check

New tests:

  • files.test.ts: parsing labels:, the bad cases, and and/or/!/not matching.
  • rules.test.ts: which bots start for issues and pull requests, and a label arriving later.
  • poller.test.ts: labeled and unlabeled updates keep the subject's labels current.
  • github.test.ts: label names read from discovery.
  • init-scratch.test.ts: the epic bot and dev's !epic.

To try it live, follow the steps in #561. The verification will be in verifications/<this PR>.md on the branch.

🤖 Generated with Claude Code

loopway-bot and others added 2 commits November 25, 2026 09:34
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@loopway-bot

Copy link
Copy Markdown
Contributor Author

Ready to merge

What I ran

On 2ed8027, in a worktree:

I checked the diff against #561 and Matthew's answers on it:

  • The filter is in the front matter.
  • It has and, or and ! (plus not).
  • A bot with no labels: takes everything.
  • It covers issues and pull requests.
  • There is a new epic scratch bot, and dev has labels: "!epic".

Every one of these has code and a test. The verification follows the verifications/README.md shape. It shows the three issue steps live, with log lines. It lists pull requests as not run live, and cleanup is recorded. I didn't rerun any live steps, because nothing in the record looked doubtful.

Worth considering

  1. packages/cli/src/bots.ts:121: labels: [] matches every subject, and labels: { or: [] } matches none. The second one quietly turns the bot off. I'd reject an empty list for and and or in checkLabels.
  2. packages/cli/src/bots.ts:106: an unquoted labels: !epic is parsed by YAML as a tag. It fails with the generic message and a TAG_RESOLVE_FAILED warning. Adding "quote it: \"!epic\"" to LABEL_HELP would point people straight at the fix.
  3. packages/cli/src/rules.ts:115: removing epic from a subject starts dev on it, through the never(...) path, because dev never had a thread there. That fits "labels decide whether a thread starts", but neither the docs nor the tests say it. A rules test or a line in the README would pin it down.
  4. verifications/README.md (Tools) still says init-scratch writes "dev and review bots". It now writes epic as well.

@mcwhittemore
mcwhittemore merged commit 011feea into main Nov 25, 2026
3 checks passed
@mcwhittemore
mcwhittemore deleted the issue-561-label-filter branch November 25, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow bots to be filtered based on labels

2 participants