diff --git a/CHANGELOG.md b/CHANGELOG.md index bfa9763..529ebc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,21 @@ Applying the kit never touches an agent already created from it, so an instance crosses a version only when its operator walks it through these steps, in the direct session. +## 6.18.0 — 2026-11-13 + +**Who hands an issue off on GitHub can hear of it in a Slack direct message.** +With the new key `slack_people` — `login=` pairs — `park` and +`finish` also print a `notify:` line for a direct message to the person who +last put the hand-off label on the issue, when it is ready to merge, needs +info or is blocked ([`docs/notify.md`](docs/notify.md) → **A direct message**). +A hand-off from Slack is left out: its thread reaches who asked. Off by +default. + +**Upgrade (operator only):** to turn it on, add `slack_people` to +`work/CONFIG.md`, a pair for each person, their Slack user id from +`describe_channel_users`, e.g. `- slack_people: alice=U0123ABCD`. Without it, +nothing changes. + ## 6.17.1 — 2026-11-12 **The kit declares no compute size and no disk.** `kit.yaml` no longer carries diff --git a/CLAUDE.md b/CLAUDE.md index a835c52..83bb7b5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -83,7 +83,9 @@ a line in any other shape is invisible, not wrong. `off`; missing: anyone. `slack_ui_review` — the chat told, once, of each `label_ui_review` pull request out of draft; missing: none. `slack_automerge` — who there may ask for auto-merge on a pull request of yours: `off`, - `people`, or Slack user ids; missing: off. + `people`, or Slack user ids; missing: off. `slack_people` — `login=` pairs: who handed an issue off on GitHub hears of its ✅ ❓ 🛑 in a + direct message; missing: nobody. - `repos_also` — `owner/name` or `owner/*`, by spaces or commas: the other repositories an issue of `repo` may need changed too, in any run ([`docs/runs.md`](docs/runs.md) → **Other repositories**). Missing: `repo` alone. diff --git a/ONBOARDING.md b/ONBOARDING.md index 66b6655..6227bef 100644 --- a/ONBOARDING.md +++ b/ONBOARDING.md @@ -148,6 +148,10 @@ confirming or correcting rather than composing from nothing. — the default is no: `off`, `people`, or the Slack user ids of who may, from `describe_channel_users`; whoever it names may in effect merge. Record it as `slack_automerge`, and say so in **Bounds**. + Offer, too, to tell whoever hands an issue off on GitHub of its moments in + a direct message: for each person who may, their GitHub login and their + Slack user id from `describe_channel_users`, as `slack_people` pairs. A + hand-off from Slack needs none: its thread reaches who asked. Look in the repository's skills for one that grills a plan and one that files issues; offer them as `skill_grill` and `skill_file_issue`, or the definition's defaults when there are none. Not connected: skip it, and say a Slack channel can be bound in the agent's @@ -218,6 +222,7 @@ that is not one of them fails verification, because nothing would ever read it: - slack_handoff: anyone - slack_ui_review: C0123ABCD - slack_automerge: off +- slack_people: alice=U0123ABCD bob=U0456EFGH - skill_grill: grill-me - skill_file_issue: file-issue - repos_also: owner/* @@ -234,7 +239,7 @@ Interactive, leave out `label_handoff`, `label_failed`, `label_needs_info`, no demo, `demo_environment`; with neither check, or no path that needs one, `verify_required_paths`; with no Environment at all, `label_ui_review`; with no -review label, `label_review`; with no backup, leave out `work_repo` and `work_account`; when the active account reaches it, `work_account`; with no Slack, leave out `slack_channel`, `slack_handoff`, `slack_ui_review` and `slack_automerge`; +review label, `label_review`; with no backup, leave out `work_repo` and `work_account`; when the active account reaches it, `work_account`; with no Slack, leave out `slack_channel`, `slack_handoff`, `slack_ui_review`, `slack_automerge` and `slack_people`; with nobody to tell directly, `slack_people`; with every slot open, `slots_closed`; for the default grill skills, `skill_grill` and `skill_file_issue`; leave `repos_also` out when the work never leaves `repo`; leave `prune` and `prune_below_gb` out when builds leave little behind. diff --git a/VERSION b/VERSION index 369689d..1b386a5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.17.1 +6.18.0 diff --git a/app/src/developer/reports.ts b/app/src/developer/reports.ts index 34053cf..5badfc6 100644 --- a/app/src/developer/reports.ts +++ b/app/src/developer/reports.ts @@ -182,3 +182,37 @@ export async function slackThread(kit: Kit, itemIn: string, prsIn: string, chat: } return ts; } + +const PAIR = /^([A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)=([UW][A-Z0-9]+)$/; + +/** `slack_people`'s pairs, GitHub login → Slack user id; a word not shaped `login=U…` is left out. */ +export function slackPeople(value: string): Map { + const people = new Map(); + for (const word of value.split(/[\s,]+/)) { + const m = PAIR.exec(word); + if (m) people.set(login(m[1]), m[2] as string); + } + return people; +} + +/** + * Who hears of an issue's moments in a Slack direct message (docs/notify.md → + * A direct message): the account that last put `label_handoff` on it, when + * `slack_people` pairs it with a Slack id. `author` itself put it there for a + * hand-off from Slack, whose thread already reaches who asked: none. A pull + * request alone, no pair, or GitHub unreadable: none. Reads GitHub only with + * `slack_people` set. + */ +export async function requester(kit: Kit, item: string): Promise<{ login: string; slack: string } | undefined> { + const people = slackPeople(kit.cfg.get("slack_people")); + if (people.size === 0 || !/^\d+$/.test(item)) return undefined; + const events = await kit.deps.github.getAll(kit.host, `repos/${kit.slug}/issues/${item}/events?per_page=100`); + const by = (events ?? []) + .map(obj) + .filter((e) => str(e.event) === "labeled" && str(obj(e.label).name) === kit.labelHandoff) + .map((e) => login(str(obj(e.actor).login))) + .at(-1); + if (!by || (kit.author && by === login(kit.author))) return undefined; + const slack = people.get(by); + return slack ? { login: by, slack } : undefined; +} diff --git a/app/src/developer/run-state.ts b/app/src/developer/run-state.ts index 172f2e2..86517e9 100644 --- a/app/src/developer/run-state.ts +++ b/app/src/developer/run-state.ts @@ -44,8 +44,8 @@ // park and finish read it (app/src/developer/checks.ts) // finish [pr]... the run's last act, on every way out: refused // until the work is pushed and reported on GitHub; -// then backs work/ up, and with slack_channel set -// says what to post (notify:) +// then backs work/ up, and with slack_channel or +// slack_people set says what to post (notify:) // sweep free the locks of dead holders (the precheck) // held the items live runs hold, one per line // live how many slots are held @@ -77,7 +77,7 @@ import { toComment, verdict, } from "./pulls.ts"; -import { ours, reported, slackThread } from "./reports.ts"; +import { ours, reported, requester, slackThread } from "./reports.ts"; import { alsoDirs, prepare } from "./slots.ts"; const USAGE = @@ -746,12 +746,16 @@ class RunState { const labels = refs.map((x) => labelRef(x, this.kit.slug)).join(" "); // a moment a person acts on: approved, it waits for whoever merges — said once const chat = this.kit.cfg.get("slack_channel"); - if (chat && state === "awaiting-merge" && this.itemKey(item, "notified") !== prs) { - const ts = await slackThread(this.kit, item, prs, chat); - const where = ts - ? `as a reply in thread ${ts} of slack_channel ${chat}` - : `to slack_channel ${chat}, and record its thread`; - this.say(`notify: post that ${labels} is ready to merge ${where} (docs/notify.md)`); + const dm = this.kit.cfg.get("slack_people"); + if ((chat || dm) && state === "awaiting-merge" && this.itemKey(item, "notified") !== prs) { + if (chat) { + const ts = await slackThread(this.kit, item, prs, chat); + const where = ts + ? `as a reply in thread ${ts} of slack_channel ${chat}` + : `to slack_channel ${chat}, and record its thread`; + this.say(`notify: post that ${labels} is ready to merge ${where} (docs/notify.md)`); + } + await this.tellRequester(item, `that ${labels} is ready to merge`); this.writeItem(item, { notified: prs }); } const uiChat = this.kit.cfg.get("slack_ui_review"); @@ -1255,9 +1259,19 @@ class RunState { : `to slack_channel ${chat}, and record its thread`; if (outcome !== "released") this.say(`notify: post this ${outcome} ${where} (docs/notify.md)`); } + if (outcome === "needs-info" || outcome === "blocked") await this.tellRequester(item, `this ${outcome}`); return 0; } + /** With `slack_people` pairing who handed the issue off, the line that tells them too (docs/notify.md). */ + private async tellRequester(item: string, what: string): Promise { + const to = await requester(this.kit, item); + if (to) + this.say( + `notify: tell ${to.login}, who handed #${item} off, ${what} in a direct message to Slack user ${to.slack} (docs/notify.md → A direct message)`, + ); + } + /** * Frees what dead holders left. A dead slot holder is an abandoned run: * logged, and counted on its item, which the precheck then lists as diff --git a/app/src/developer/verify.ts b/app/src/developer/verify.ts index 783ae03..1fc346b 100644 --- a/app/src/developer/verify.ts +++ b/app/src/developer/verify.ts @@ -22,6 +22,7 @@ import { bulletKeys, readText } from "../factory/kv.ts"; import { hookInstalled } from "./harness.ts"; import { GATE_KEYS, ITEM_KEYS, Kit } from "./kit.ts"; import { precheck } from "./precheck.ts"; +import { slackPeople } from "./reports.ts"; /** Every key CONFIG.md may hold. `docs/self-modification.md` §2: CLAUDE.md, ONBOARDING and this list name the same keys. */ export const KNOWN = [ @@ -55,6 +56,7 @@ export const KNOWN = [ "slack_handoff", "slack_ui_review", "slack_automerge", + "slack_people", "schedules", "skill_grill", "skill_file_issue", @@ -180,6 +182,21 @@ function configChecks(kit: Kit, r: Report): void { `'${automerge}' is not off, people or Slack user ids`, "write one of them, e.g. U0123ABCD, or leave it out for off", ); + const people = cfg.get("slack_people"); + const pairs = slackPeople(people); + const words = people.split(/[\s,]+/).filter(Boolean); + if (!people) r.ok("config.slack_people", "unset — nobody hears of an issue they handed off in a direct message"); + else if (pairs.size !== words.length) + r.fail( + "config.slack_people", + `'${people}' is not all login=Slack user id pairs`, + "write e.g. alice=U0123ABCD bob=U0456EFGH, the ids from describe_channel_users", + ); + else + r.ok( + "config.slack_people", + `${[...pairs.keys()].join(" ")} hear of an issue they handed off in a direct message (docs/notify.md → A direct message)`, + ); const app = cfg.get("app_url"); if (app && !/^https?:\/\/\S+$/.test(app)) r.fail( diff --git a/app/test/run-state.test.ts b/app/test/run-state.test.ts index b6e4e69..97d11ed 100644 --- a/app/test/run-state.test.ts +++ b/app/test/run-state.test.ts @@ -118,6 +118,46 @@ test("with slack_channel set, park and finish say what to post, and only for a m assert.doesNotMatch(r.err, /notify:/, "nothing for a person to do"); })); +test("with slack_people set, who handed the issue off on GitHub hears of its moments in a direct message", () => + inSandbox(async (s) => { + world(s); + s.originCheckout(); + s.github.on(PULL, PULL21); + s.github.prViews = [view("OPEN", "APPROVED", "MERGEABLE", GREEN)]; + s.config("- slack_people: alice=U0123ABCD dev-bot=U0999ZZZZ"); + const labeled = (by: string) => ({ event: "labeled", label: { name: "agent/implement" }, actor: { login: by } }); + s.github.on(/\/issues\/7\/events/, [ + labeled("Alice"), + { event: "labeled", label: { name: "bug" }, actor: { login: "mallory" } }, + ]); + await as(s, "sess-a", "start", "7", "feat/7"); + let r = await as(s, "sess-a", "park", "21"); + assert.match( + r.err, + /notify: tell alice, who handed #7 off, that #21 is ready to merge in a direct message to Slack user U0123ABCD/, + ); + assert.doesNotMatch(r.err, /notify: post/, "no slack_channel: no channel post"); + await as(s, "sess-a", "start", "7", "feat/7"); + r = await as(s, "sess-a", "park", "21"); + assert.doesNotMatch(r.err, /notify:/, "said once for the same pull request"); + await as(s, "sess-a", "start", "7", "feat/7"); + s.github.on(ISSUE, { labels: [{ name: "agent/needs-info" }] }); + r = await as(s, "sess-a", "finish", "needs-info"); + assert.match( + r.err, + /notify: tell alice, who handed #7 off, this needs-info in a direct message to Slack user U0123ABCD/, + ); + s.github.on(/\/issues\/7\/events/, [labeled("alice"), labeled("dev-bot")]); + await as(s, "sess-a", "start", "7", "feat/7"); + s.github.on(ISSUE, { labels: [{ name: "agent/failed" }] }); + r = await as(s, "sess-a", "finish", "blocked"); + assert.doesNotMatch(r.err, /notify:/, "handed off from Slack: its thread reaches who asked"); + s.github.on(/\/issues\/7\/events/, [labeled("carol")]); + await as(s, "sess-a", "start", "7", "feat/7"); + r = await as(s, "sess-a", "finish", "blocked"); + assert.doesNotMatch(r.err, /notify:/, "no pair for carol: nobody to tell"); + })); + test("with slack_ui_review set, park says to post a label_ui_review pull request out of draft, once", () => inSandbox(async (s) => { world(s); diff --git a/app/test/verify.test.ts b/app/test/verify.test.ts index 3b48d3b..d86ecfc 100644 --- a/app/test/verify.test.ts +++ b/app/test/verify.test.ts @@ -195,6 +195,20 @@ test("slack_automerge is off when missing, and off, people or user ids when set" assert.match(r.out, /ok {3}config\.slack_automerge — U0123ABCD U0456EFGH may ask for auto-merge/); })); +test("slack_people is unset when missing, and login=Slack user id pairs when set", () => + inSandbox(async (s) => { + assert.match((await v(s, "--config")).out, /ok {3}config\.slack_people — unset — nobody hears/); + s.config("- slack_people: alice=U0123ABCD bob"); + assert.match( + (await v(s, "--config")).out, + /FAIL config\.slack_people — 'alice=U0123ABCD bob' is not all login=Slack user id pairs/, + ); + s.setConfig("slack_people", "alice=U0123ABCD, Bob=W0456EFGH"); + const r = await v(s, "--config"); + assert.equal(r.rc, 0); + assert.match(r.out, /ok {3}config\.slack_people — alice bob hear of an issue they handed off/); + })); + test("a grill skill is the repository's when named, the default otherwise", () => inSandbox(async (s) => { s.onboarded(); diff --git a/docs/notify.md b/docs/notify.md index 9d9a9cf..59cdd97 100644 --- a/docs/notify.md +++ b/docs/notify.md @@ -1,10 +1,11 @@ # Slack posts -Read this when `finish` prints a `notify:` line, and in the weekly audit. +Read this when `park` or `finish` prints a `notify:` line, and in the weekly audit. GitHub is the record; Slack is a nudge for the moments a person has to act. Off unless `slack_channel` names a chat — a channel id from `describe_channel`. -Missing, or Slack not connected to this agent: post nothing, say nothing. +Missing, or Slack not connected to this agent: post nothing, say nothing — a +direct message has a key of its own (below). ## When @@ -18,6 +19,17 @@ Missing, or Slack not connected to this agent: post nothing, say nothing. | Every Environment held, none to take back, with `verify_environment` | `room`, once a day per set of pull requests | 🧱 `#` waits for an Environment — then each pull request holding one: review it, or merge it | | Weekly audit | the audit's report | the report's header and its **Action needed** lines; a 🚨 first when it has a red line | +## A direct message + +Off unless `slack_people` pairs GitHub logins with Slack user ids; it does not +need `slack_channel`. When the ✅, ❓ or 🛑 of an issue is due, `park` or +`finish` also prints `notify: tell … in a direct message to Slack user +` for the account that last put the hand-off label on it — never for +`author`, whose hand-off came from Slack and whose thread already reaches who +asked. Send the same line, its link included, with +`send_channel_message(channel: "slack", chatId: , text: …, unfurlLinks: false)`, +and record nothing on GitHub. + ## A required check that did not pass Posted the moment `checked` prints its `notify:` line, before the run goes