# Forgekeeper reference For installation and everyday use, see the [Forgekeeper README](../README.md). An [OpenCode](https://opencode.ai) plugin that tracks the issues or PRs/MRs a session works on. It prefixes the session title with their references, shows the PR/MR status in the prompt footer, and surfaces new review feedback in a persistent inbox. It supports GitLab and GitHub. The status and review notifications are optional; see [Keep only session titles](#keep-only-session-titles). ![OpenCode session environment with issue and MR references, a review notification, and a footer tracking four merge requests.](https://raw.githubusercontent.com/pedropombeiro/opencode-plugins/main/packages/forgekeeper/images/session-review-notification.png) Notification wording has changed since this capture. Requires OpenCode 2.3 or later. It replaces [`opencode-forge-session-title`](https://www.npmjs.com/package/opencode-forge-session-title); see [Migrating from opencode-forge-session-title](#migrating-from-opencode-forge-session-title). ## Installation ```bash opencode plugin add opencode-forgekeeper ``` This adds the plugin to your `opencode.json`: ```json { "$schema": "https://opencode.ai/config.json", "plugins": ["opencode-forgekeeper"] } ``` The package has a server entry point and a CLI entry point, which OpenCode loads automatically. The server owns session targets, title prefixes, forge lookups, polling, and notification delivery. The CLI holds leases on the sessions it has shown, their latest snapshots, and each directory's settings. It renders the status that the server serves and shows its notices as toasts. ### Requirements - [`glab`](https://gitlab.com/gitlab-org/cli) for GitLab and [`gh`](https://cli.github.com/) for GitHub, on the `PATH` of the OpenCode server. Each is only needed for its forge. - Each CLI logged in to every host it's used for: `glab auth login --hostname ` and `gh auth login --hostname `. The plugin uses their credentials and has none of its own. - For self-managed GitLab hosts not named `gitlab.*`, and for GitHub Enterprise, the `hosts` and `githubHosts` [options](#options). Without a forge CLI, titles still follow explicit targets, and `/forge-status` reports what's missing, such as `glab is not installed`. ## Upgrade from forgekeeper 2.x Forgekeeper 3 changes where review notifications go, and renames its options: - **Notifications:** review feedback goes to the `/forge-feedback` inbox and starts a restricted summary turn when configured, without asking the agent to address it. Set `delivery.reviews` to `"inbox"` to stop automatic session delivery, or `"passive"` to queue a notice without starting a turn. See [Review notifications](#review-notifications). - **Options:** Forgekeeper no longer reads the former option names. It shows an error toast that names each one, and uses that option's default instead. For example, a former `reviewStatus: false` leaves status on, so rename it to `status: false` before you upgrade. - **Monitoring:** Forgekeeper also watches recent sessions with PR/MR targets that no CLI has shown, and announces conflicts, failed jobs, requested changes, and merges of their targets. See [Which sessions the server watches](#which-sessions-the-server-watches) and [Merge request updates](#merge-request-updates). Set `watch.lifecycle` to `false` to stop the merge request updates. Rename the former options as follows: | Former option | Now | | ------------------------------------------- | --------------------------------------------------------------------------------------- | | `reviewStatus` | `status` | | `notifyHumanReviews` | `watch.humanReviews` | | `notifyAutomatedReviews`, `notifyDuoReview` | `watch.automatedReviews`, and `watch.reviewBots` for review bots | | `resumeSession` | `delivery.reviews`: `"summary"` starts a turn, and `"passive"` queues for the next turn | ## Session targets The server registers the `set_session_target` tool and adds instructions to the agent's context. The current target is stored in the `forgekeeper-session-target` session instruction entry. Updates take effect at the next step without changing the system prompt. When you establish or change the primary issue, PR, or MR, the agent sets its full URL as the session target. Background references, comparisons, and dependencies keep the current target. Reviewing, triaging, or addressing feedback on existing issues and PRs/MRs also sets them as targets, including ones a skill or search found rather than ones you linked. After the agent creates a PR/MR for the current task, it sets the new PR/MR as the target, passing the current issue as `issue_url`. For example, if the title starts with `[#123, !45]` and you ask the agent to review MR `!456`, the prefix becomes `[!456]`. Without `issue_url`, the server reads the PR/MR's source branch and takes the issue number from its name, so reviewing an MR from `321-fix-timeout` produces `[#321, !456]`. New sessions have no targets by default. Targets persist per session across plugin reloads. A forked session starts with the targets of the session it was forked from, as they are when Forgekeeper first updates the fork, and keeps them from then on. To clear all targets, call `set_session_target` with `target: "none"` or run `/forge-detach` without arguments. The former `target: "branch"` value is no longer accepted. Child sessions and untitled sessions are skipped for title updates. ### Several targets A session can work on up to 50 issues and PRs/MRs at once, such as a set of related MRs under review. Pass their full URLs in `targets` instead of `target`, and choose how they change the current targets with `operation`: | `operation` | Effect | | ------------------- | ----------------------------------------------------------------------------- | | `replace` (default) | Sets exactly the given targets. | | `add` | Appends the given targets and keeps the current ones. | | `remove` | Drops the given targets. Removing the last one leaves the session untargeted. | ```json { "targets": [ "https://gitlab.com/group/project/-/merge_requests/101", "https://gitlab.com/group/other/-/merge_requests/102" ], "operation": "add" } ``` The server normalizes and deduplicates the URLs, which can come from different projects. With `targets`, `issue_url` relates every listed target to the same issue, such as a set of MRs for one issue. Every target must then be a PR/MR from the issue's forge. With `operation: "add"`, only the added targets get the issue. The agent guidance is generic. When you ask the agent to work on several issues or PRs/MRs, it sets all of them as targets. If you describe them instead of linking them, the agent finds them first, then sets them. After it creates a PR/MR for a task with several targets, it adds the new one instead of replacing the others. With several targets, the title prefix lists their own references, such as `[!101, !102]`. When every target has the same related issue, from `issue_url` or from its source branch name, the issue comes first, such as `[#12, !101, !102]`. More than four targets list the first three and count the rest, such as `[!101, !102, !103, +3]`. Target URLs can name a GitLab MR, issue, or work item on any host, or a GitHub PR or issue. GitHub URLs are accepted on any host that isn't recognizably GitLab, so GitHub Enterprise targets work. ## Title prefixes Forgekeeper reconciles the title after target changes, title changes, and successful agent runs. When no targets remain, Forgekeeper removes the prefix it previously recorded. It preserves text you added, including your own bracketed prefixes. Forgekeeper keeps prefixed titles within 100 characters by shortening the text after the prefix, never the prefix itself, so the plugin can still find and replace its prefix later. Forgekeeper uses these patterns to infer a related issue from a targeted PR/MR's source branch: | Pattern | Example branch | Issue | | --------------------------------- | ----------------------- | ----- | | `/-` | `feature/123-add-login` | `123` | | `-` | `123-fix-typo` | `123` | | `-` | `fix-typo-123` | `123` | | `//` | `user/123/some-work` | `123` | | `issue-`, `gh-` | `gh-42-improve-perf` | `42` | | `fix-`, `feat-` | `fix-99` | `99` | ## Status footer The server looks up only the session's explicit PR/MR targets. It ignores references in the title and the checked-out branch. Issue-only sessions and the home screen show no PR/MR status. Without a PR/MR to show, the footer stays empty, even when a lookup fails, such as in a new session before the server answers. It shows `PR/MR status unavailable` only when none of the session's explicit PR/MR targets can be looked up or found. `/forge-status` explains why. The server runs at most four `glab` or `gh` commands at once for status and review feedback, across all sessions. When some target lookups fail, the footer shows the others and counts the failures as `N unavailable`. A target whose lookup failed with an error keeps its previous status until a later poll succeeds. A GitLab response that reports an error counts as a failed lookup, never as a missing MR, so it's retried with backoff. When the CLI can't reach the server, such as while the server plugin reloads, the footer keeps the last status and marks it `stale`. The CLI never looks PRs/MRs up itself, so it can't show another project's PR/MR with the same number as a target. With several PR/MR targets, the footer shows counts instead of one PR/MR's status, such as `5 MRs · 🤖 2 reviewing · 1 CI failed · 1 conflict · 1 merged`. Clicking it opens the status dialog, which lists each PR/MR. ![Compact Forgekeeper footer tracking four MRs, with one conflict and two merged.](https://raw.githubusercontent.com/pedropombeiro/opencode-plugins/main/packages/forgekeeper/images/conflict-status-footer.png) The footer shows checks or the pipeline, unresolved threads, conflicts, approval, and a running automated review, from GitLab Duo or GitHub Copilot. GitHub also shows a requested change. Unknown mergeability stays unknown rather than appearing conflict-free. The status dialog separates pipeline results, unresolved threads, and review requirements: ![Forgekeeper status dialog showing a passed pipeline, one unresolved thread, no conflicts, and approval requirements not yet satisfied despite a GitLab Duo approval.](https://raw.githubusercontent.com/pedropombeiro/opencode-plugins/main/packages/forgekeeper/images/review-and-ci-status.png) The footer shows `approved` only when GitLab reports that approval requirements are met, at least one person approved, and every human reviewer approved. Bot approvals, such as Duo's, don't count. While human reviewers haven't approved, it shows `awaiting @username`, or `awaiting N reviewers` for more than two. Clicking the PR/MR number or pipeline opens it in the browser. Clicking any other indicator opens the status dialog. These commands are also available from the command palette: - `/forge-status` opens a dialog with full status and a refresh action. Aliases: `/mr-status` and `/pr-status`. - `/forge-open` opens the PR/MR in the browser. Aliases: `/mr-open` and `/pr-open`. - `/forge-cleanup` lists idle non-archived root sessions across all worktrees of the project whose PRs/MRs have all merged, or whose explicit targets are issue-only and all closed, and lets you archive one or all of them, clear their remaining inbox updates, and close their open tabs. Aliases: `/mr-cleanup` and `/pr-cleanup`. When a session becomes eligible for cleanup, Forgekeeper shows a reminder banner above the composer, emits a one-time notice toast, and offers **Clean up session** (`ctrl+d`) in the status dialog. Issue-only sessions check their issue status when opened, after a turn ends, when targets change, or on manual refresh rather than on the background PR/MR polling timer. ### Desktop app OpenCode Desktop loads Forgekeeper's desktop part, so it matches the terminal UI: - A pill above the composer shows the footer's indicators and the session's update count. Its menu opens the PR/MR and pipeline links, the status panel, the inbox panel, and **Clean up session** when all tracked PRs/MRs have merged or tracked issues have closed. - `/forge-status` opens a side panel with the status dialog's details, a refresh action, and a **Clean up session** action when the session is eligible. - `/forge-feedback` opens a side panel with the active session's updates. Each update offers its links and **Summarize in session**, **Act on feedback**, **Retry**, and **Acknowledge**, and the panel can pause or resume monitoring. - `/forge-open` opens the PR/MR in the browser, or asks which one to open. - `/forge-cleanup` opens a dialog listing eligible sessions across the project's worktrees to archive one or all of them and close their open tabs. An inline reminder also appears in the session header when a session is ready to archive. - Server notices appear as toasts, and as system notifications when no app window has focus, following **Settings > Notifications**. The desktop part watches only sessions on the app's own server. It uses OpenCode's experimental GUI plugin API, which may change between releases. Settings > Extensions > Plugins can turn it off without affecting the server part. ### Web app The OpenCode web app runs no terminal or desktop plugin parts, so it has no footer, panels, toasts, or `/forge-status`, `/forge-open`, `/forge-feedback`, and `/forge-cleanup`. Monitoring doesn't depend on them: the server watches [discovered sessions](#which-sessions-the-server-watches) without a client. To see updates in the web app, set `delivery.reviews` and `delivery.lifecycle` to `summary`. A `passive` notice is queued until the session's next turn, and the web app shows only its title. The server caches each session's status and polls every 2 minutes while a CLI shows an open PR/MR, or every 30 seconds while an automated review runs or new review feedback waits for its quiet period. Each change reaches the CLIs as an RPC event. Sessions in the same checkout share cached status and human-feedback fetches for the same forge, host, project, and PR/MR number. Overlapping requests share one in-flight fetch. Successful status results remain fresh for the polling interval, capped at 30 seconds while an automated review runs. Complete human-feedback results remain fresh for 60 seconds. Failures and incomplete feedback are not retained for reuse. Each cache keeps at most 1,000 entries and is cleared when the plugin stops. Session timers, review baselines, and acknowledgements remain independent. Manual refresh invalidates the selected session's target caches and feedback fetch timestamps. Completed turns invalidate the checkout's caches before notifying watched sessions, so changes such as pushes can be observed. Caches are not shared between checkouts, whose CLI credentials and repository context may differ. ### Which sessions the server watches With inbox monitoring enabled, the server indexes recent activity at startup, when monitoring resumes, and once per day to recover missed events. Session events and target changes update the affected entry. Every 5 minutes the server expires old entries and retries failed reads without rereading other sessions' conversations. A session qualifies when it is a non-archived root session in the checkout, has an explicit PR/MR target, and has a user message in the last 72 hours. A compaction drops earlier messages from the session's context, so when the context has no user message, the newest compaction counts instead, since compactions run only during turns. Viewing a tab, changing its title, or receiving a background notification does not extend that window. Sessions without readable conversation activity are skipped. Discovery reads conversation timestamps locally; it does not send conversations to a model. Discovered sessions poll without a CLI lease while at least one explicit target is open. Targets that couldn't be resolved, such as while the forge returns nothing for them, keep being retried, even when the session's other targets closed or merged. While none of the targets resolves, retries back off like failed lookups. Once every target is found and closed or merged, polling stops. Discovery reevaluates the activity window every 5 minutes. It runs only while OpenCode has this checkout's plugin instance loaded; it is not a separate scheduler and cannot wake an unloaded location or stopped service. The server also watches sessions that a CLI has shown since it started. The CLI renews a lease on each of them every minute, and a lease that isn't renewed for 3 minutes ends, such as after the CLI exits. A session keeps polling while it's on screen in any CLI. A hidden session with a lease keeps polling while it has a running automated review, human feedback to watch, or a notification to retry. A hidden session that the server hasn't looked up yet, such as after the server plugin reloads, is looked up once to find out whether it has reviews to watch. A target change also looks up a hidden session that isn't polling. Each checkout's server plugin instance watches only the sessions in that checkout. When a session moves to another worktree, the CLI moves its lease to that checkout's instance. The old instance stops watching the session, even if another CLI still leases it there. Before each notification, the server reads the session again, so a session that moved while a lookup or fetch ran is left to its new checkout. A review that finishes during the move can go unannounced, because the new instance never saw it running. If the session can't be read, the notification is retried later instead of being dropped. After that read, the server checks the targets again and records feedback for the PRs/MRs that are still targets. A target removed in the meantime isn't mentioned. When the server plugin stops, such as on a reload, no new lookup, fetch, notification, title update, or target change starts, and queued `glab` and `gh` commands don't run. A title update that is still reading its state doesn't rename the session or store anything, because the replacement instance owns the session's state by then. Notifications that were already being sent can finish and store their outcome, so the replacement instance doesn't send them again. Cleanup waits up to 5 seconds for them. One that takes longer may be sent again. ## Review notifications For each explicit target that is an open PR/MR, the server records new review feedback. A target that merges or closes gets no more notifications, and a notification waiting for a retry is dropped. Feedback goes to a persistent inbox. The `delivery.reviews` option sets what else an update does: - `inbox`, the default, posts nothing to the session. - `passive` queues a session message with `resume: false`, which starts no turn. It doesn't mark the session unread, because the TUI marks sessions unread only when a turn ends. When something else wakes the session, the message can run as its own step; Forgekeeper then sends only the notice, without tools or the session's history. - `summary` queues a message that starts a summary turn, described below. A turn that ends marks the session unread. Updates without comments, such as Copilot reviews, get a passive message instead. Session messages contain the notification title, when the newest comment was written, and links, not review bodies or instructions to act. Updates without comments, such as Copilot reviews, show when Forgekeeper detected them instead. Times are absolute and local, with their time zone, such as `Oct 28, 2026 at 3:25 PM GMT+1`, so they stay accurate in the session's history. `/forge-feedback` shows the same time, and a summary starts by saying it. Each update keeps the mode it was recorded in, so changing `delivery.reviews` affects later updates only: switching to `summary` never starts turns for updates already in the inbox. Summarize those with Ctrl+R instead. Stable message IDs deduplicate automatic retries, including after reloads. Updates that haven't reached their session are retried every minute and after a reload, each on its own, so one that keeps failing doesn't hold the others back. Delivery doesn't hold up the inbox: `/forge-feedback`, pausing, and acknowledging work while a summary reads its comments, and an update in flight isn't sent again by a retry. An update acknowledged or cleared while its comments are read isn't posted, and one paused meanwhile waits until monitoring resumes. An update whose session was deleted, archived, or moved, or that no longer targets the PR/MR, is dropped, including when that changed while its comments were read. Switching `delivery.reviews` to `inbox` stops retries of review updates, and leaves them undelivered, so they go again once it's switched back. Merge request updates follow `delivery.lifecycle` the same way. A summary requested from `/forge-feedback` is a new request each time. ### Summary turns A summary turn runs after any active turn finishes, including its tool calls. Forgekeeper reads the announced comments, at most 20 of them and 4,000 characters each, with context the summary can't fetch itself: - Earlier replies in each comment's thread, at most 5 of 1,000 characters each. GitHub provides only the comment a reply answers. - The code an inline comment is on, at most 3,000 characters. On GitLab, that's 10 lines on either side of the commented line, from the MR's head commit, or from its base commit for a removed line, for at most 10 files. On GitHub, it's the end of the diff hunk. A file that can't be read leaves out only its code. The PR/MR's author wrote that code, so the summary treats it as untrusted, like the comments. Forgekeeper keeps all of this in plugin storage until the next user prompt, or for at most 7 days. It never enters the session's history, where later turns with tools could read it. #### Linked notes On GitLab, review comments often link to supporting notes, such as an issue in another project with further details. A summary can read those with one tool, `fetch_linked_review_note(url)`, which accepts only links that the announced comments' own text contains: - HTTPS links without credentials or a port, on the MR's GitLab host, to an issue, work item, or MR note (`…/-/issues/1#note_2`). Notes in other projects count. Links in thread replies, in code, or in a linked note don't, so nothing a linked note says can widen what the summary reads. - At most 5 links per summary, each at most 300 characters, without duplicates or links to the announced comments. Forgekeeper stores these links with the summary's record before posting its message. The tool reads a note with one fixed GraphQL query through `glab`, and keeps it only if the note GitLab returns, of any note type, has the link's note ID and names the same project, issue or MR, and note. GitLab returns nothing for notes you can't read. The model supplies only the link: never a host, query, method, or header. Each summary gets 5 calls. Every call counts, including repeats, refused links, and failed reads, and is spent before the read, so neither concurrent calls nor a reload restore it. A linked note keeps at most 4,000 characters, and all of them together at most 12,000. The comments come first in the request's 40,000-character budget. Linked notes, with their links and status lines, get only what the comments leave; notes that don't fit are reported as left out, and without room for the readable links, the request offers no tool. The tool returns only a receipt that names the link, which is what stays in the session's history. The note's text goes to the summary's record, and from there only into the summary's next requests, as a `` block. Every request that can hold linked notes, including the last one, which has no tool, keeps the instructions that treat them as untrusted like the comments. The tool works only for the summary of the session's latest model request, and checks the session's context again on each call, so a user prompt ends its access even before the next request. A record older than 7 days counts as missing in every check, not just at the next startup. After a reload, the tool refuses until the next request. A stopped instance writes nothing, and cleanup waits for its calls, so a late call can't overwrite the budget its replacement uses. Ordinary requests never include the tool, and summaries without links, notices, and steps whose summary can't be read get no tools at all. GitHub summaries don't read linked notes. Forgekeeper recognizes a step whose input is one of its messages in two independent ways: - Every message it posts ends with a tag naming its ID, such as `[forgekeeper:msg_forgekeeper_…]`, which the context hook finds in the request it's about to send. This doesn't depend on stored state, so a failed restore or an expired record can't let the message run as an ordinary request. A tag in a user prompt, such as a pasted transcript, doesn't count when the session's context shows the prompt. - It tracks every message it posts until a user prompt follows that message, and reads the session's context before each request. A message still in the queue stays tracked while earlier steps run, and a reminder sent after the message doesn't end its step. Before each model request that either way identifies, its context hook: - removes every tool from the request, except the linked-note tool while the summary has links left to read; - replaces the system prompt with summary instructions that treat comments as untrusted; - replaces the conversation with one message holding the comments and the linked notes read so far, or the notice, so the request resends neither the session's history nor the step's own tool calls; - caps the output at 1,200 tokens. If the review text is missing, such as after its record expired, the request asks for a short reply saying so, still without tools or history. If the hook can't build the replacement message, the request fails rather than keeping any of the session's messages. As backstops, Forgekeeper refuses every tool execution other than the linked-note tool, which checks its own calls and asks for no permissions, and every permission request, while the session's latest model request was one of these, and treats a step it can't classify as one, such as when the session's context can't be read, or when a compaction left no input in it. The turn ends at the next user prompt. A later turn that another plugin starts without a user prompt also runs without tools. The summary is the only part that stays in the session's history. New checkouts start with status only unless `inbox: true` or automation rules enable feedback. In `/forge-feedback`, choose **Enable feedback inbox** to opt in for one checkout. A saved monitoring preference takes precedence. **Mark all as read** (Ctrl+U) clears the unread count for the displayed updates without acknowledging them or changing delivery. `/forge-feedback` lists pending feedback for the active session. Select an update to open its PR/MR or comment links, press Ctrl+D to acknowledge it, press Ctrl+R to summarize it in its session in any delivery mode, or press Ctrl+S to pause or resume review monitoring. Acknowledgement only dismisses the local update; it does not reply to or resolve a remote discussion. A session's footer shows how many of its own updates are unread. The home screen, where new sessions start, shows no count and no updates in `/forge-feedback`. Connected CLIs in the checkout still show a toast even when the session's tab has never been visited. With session tabs on, those CLIs also reopen the session's tab, without leaving the session you're in. An update leaves the inbox when you acknowledge it, or when it no longer needs attention: - Once every comment it announced is resolved, by anyone. Comments that can't be resolved, such as GitLab comments outside a thread or GitHub review bodies, need acknowledging, and so do updates without comments, such as Copilot reviews. - Once its PR/MR merges or closes, or its session stops targeting it. Forgekeeper checks resolution and PR/MR state only for sessions it monitors. Resolution counts only from a fetch that no later change made obsolete, and state only after a lookup finishes, so a reload doesn't clear updates before the session's targets are known. A target change clears that target's updates right away, whether or not Forgekeeper monitors the session. Working on the feedback, with or without the agent, doesn't clear an update by itself. The inbox retains the newest 500 updates per checkout across plugin reloads. It stores session IDs, target URLs, notification titles, comment URLs, and timestamps, not comment bodies or credentials. A pause persists across reloads and leaves status display available. Before it sends a notification, the server checks that the PR/MR is still one of the session's targets. A lookup that started before the targets changed is discarded, so a removed target never triggers a notification. | Notification | GitLab | GitHub | | ------------------------------------------ | -------------------------------- | -------------- | | An automated review finished with feedback | GitLab Duo | GitHub Copilot | | Comments from review bots | Security reviewers, `reviewBots` | `reviewBots` | | New human review feedback | MR comments | PR comments | | Reviewer approvals | Duo, humans, and `reviewBots` | Reviewers | - **Reviewer approvals**: when an automated reviewer (such as GitLab Duo), a human reviewer, or a configured `reviewBot` newly approves an open target PR/MR, Forgekeeper records an approval update in `/forge-feedback` with current readiness facts (such as whether the PR/MR is still a draft, has unresolved threads, or awaits other reviewers). Pre-existing approvals become the initial baseline on the first complete lookup, self-approvals are skipped, and a re-approval after a push or re-review request produces a new update. Approval updates follow `watch.automatedReviews`, `watch.humanReviews`, `watch.reviewBots`, and `delivery.reviews`, and clear automatically if the reviewer's approval is reset or the PR/MR closes or merges. - **Duo reviews**: new unresolved inline findings from the GitLab Duo bot create inbox updates after the findings remain unchanged for four minutes. Forgekeeper does not need to observe the review running. Summary-only reviews, system notes, and resolved findings send nothing; Duo approvals are reported through reviewer approvals above. Comment IDs persist independently of human feedback, including an empty baseline when monitoring starts without findings. Existing findings become the initial baseline; new findings posted while OpenCode is offline are detected after monitoring resumes if a baseline was already stored. When available, `duoCreatedSession.id` groups findings by code-review workflow run. A linked workflow must be terminal before delivery, and the watcher refetches before notifying. Older GitLab versions and permission-hidden workflows use comment IDs and the settling window without a workflow link. Separate runs use distinct inbox IDs. - **Copilot reviews**: the server notifies when a submitted, undismissed review has at least one inline comment. A review without inline comments, such as one that found nothing or couldn't run for lack of quota, sends nothing. Copilot reviews are identified, so a review that started and finished between two polls is announced too. A review that the server finds on a PR's first look isn't announced. Observed and delivered review IDs persist across restarts. A completed review can be announced while another review is requested. - **Human reviews**: new comments and replies from people other than you and bots are announced once none of their unresolved comments has changed for 4 minutes. Status polls every 30 seconds meanwhile, so expect one update 4 to 5 minutes after the review goes quiet, before a typical 5-minute prompt cache expires. Resolved threads are skipped. - **Review bots**: comments from the bot accounts that `reviewBots` names are announced like human reviews, including comments without a file or line, such as a security review's findings. `reviewBots` maps each host to exact usernames, ignoring case. By default, it names GitLab.com's security reviewers for `gitlab-org`: ```json { "reviewBots": { "gitlab.com": ["duo-security-review-gitlab-org", "ai-appsec-security-mr-reviewer-gitlab-org"] } } ``` Duo Security Review has one account per top-level group, so add yours, such as `duo-security-review-acme`, and a self-managed instance's accounts under its host. Your list replaces the defaults, and `watch.reviewBots: false` turns this off. Names have no wildcards, since a group owner can create a bot account with any free name, such as one that starts like a security reviewer's. Only accounts that the forge flags as bots count, and only on the host they're listed for. `watch.reviewBots` controls them on its own, apart from `watch.humanReviews` and `watch.automatedReviews`. GitLab Duo's code review findings always go through their own watcher instead. Internal notes, such as Duo Security Review's, count when your account can read them. The first look at a PR/MR records its newest comment as a baseline, so older comments never count as new. Announced comments are stored per session and PR/MR, so a restart replays nothing but still catches comments posted in the meantime. Feedback counts as announced once the inbox has it. If Forgekeeper can't record it, such as when its storage fails, it shows an error toast and tries again after 10 minutes. Duo and human feedback then keep their comment IDs unannounced, so a restart can retry them, and Copilot notifications stay pending in storage while the review still has feedback and the PR remains an open target. Legacy state-only Duo pending notifications are discarded. A session message that fails, such as when the comment text can't be read for a summary, shows an error toast. The update stays in the inbox, which retries the message every minute. Acknowledging the update ends those retries, and the update doesn't come back. Every checkout's server plugin instance shares the plugin's storage, so each baseline and each pending notification has its own storage key. Instances never overwrite each other's records. A failed storage write shows an error toast once. On GitLab, the server reads the newest 2,000 comments. On busier MRs, edits to older comments don't count as activity. ### Live comment subscriptions GitLab feedback monitoring attempts an outbound TLS WebSocket connection to the MR's host, using GitLab's internal `Noteable::NotesChannel` Action Cable interface. Sessions targeting the same MR share one subscription within a checkout. No webhook receiver or project administration permission is required. This interface is not a public GraphQL subscription and can differ across GitLab versions. After the server confirms a subscription, comment events trigger a feedback fetch. Events within a one-second window share a refresh. Quiet connections reconcile comments every 15 minutes, on the next scheduled status check. The four-minute settling window still applies, and the watcher fetches again before delivering pending feedback. Initial connection and reconnection also trigger a fetch to catch changes while disconnected. GitHub and hosts that cannot establish a subscription keep polling. Connection failures, rejections, and missing heartbeats restore normal feedback polling. Reconnection attempts back off from 30 seconds to 15 minutes. Pausing feedback, removing the last session watching an MR, or unloading the plugin closes its connection. Subscriptions only accelerate comment monitoring; status, pipeline, and automated-review polling continue at their existing intervals. On HTTP 429, subscription retries honor `Retry-After` and GitLab's `RateLimit-Reset` and `RateLimit-ResetTime` headers, even when the wait exceeds 15 minutes. The cooldown applies to all MR subscriptions on that origin within the checkout and survives removing and re-adding a target during the plugin instance's lifetime. Other origins remain independent. Bun's native WebSocket client hides rejected-handshake headers, so a failed handshake triggers one HTTP upgrade probe with a 10-second timeout and redirects disabled. The probe reads the reset headers and discards the body. A 429 without usable headers delays retries by at least one minute. Normal authenticated API polling continues during this subscription cooldown. GitLab can classify bearer-authenticated `/-/cable` requests as unauthenticated for rate limiting: its rate-limit authentication checks API and feed routes, while Action Cable authenticates the bearer token later. A valid API token therefore does not necessarily avoid the unauthenticated per-IP limit on this route. On GitHub, the server reads three lists: conversation comments, the text of submitted reviews, and the inline comments of review threads. It keeps the newest 2,000 of each. It scans every thread to include recent replies in old threads, within a limit of 200 API requests per fetch. If it cannot complete that scan, it defers notifications until a complete fetch succeeds. Review text counts when it isn't empty, whether the review approves, requests changes, or only comments. Comments from GitHub Apps, such as Copilot, count as bots. Hidden comments and unsubmitted review comments are skipped. The baseline also records comment IDs at its timestamp, so a new comment posted in the same second can still be announced. Baselines stored by older plugin versions retain their timestamp-only behavior until a new baseline is created. ## Review requests When someone asks you to review one of a session's explicit MR targets, the request goes to the `/forge-feedback` inbox. This includes asking you again while you stay a reviewer, such as after the author pushes fixes. The update names who asked, when, and the MR, such as `@alice requested your review again on !45`. A request is informational: it doesn't start a review, act on feedback, or trigger [review automation](#prepare-fixes-from-review-feedback). Forgekeeper reads requests from GitLab's activity notes, such as "requested review from @you", so every request is a distinct event with a stable ID: - Requests for other reviewers, and requests you made yourself, such as adding yourself as a reviewer, aren't announced. - The first read of an MR records a baseline, so requests made before monitoring started never replay. A request made while OpenCode wasn't running is announced at the next read. - Announced request IDs are stored per session and MR, so polling, subscription reconnects, and reloads announce each request once. Requests that piled up make one update, about the newest. - Every session that targets the MR gets its own update. Sessions in the same checkout share the history read. Forgekeeper reads the newest 1,000 activity notes, with your MR status checks and on live comment events. GitHub PRs don't get review request updates yet. ### Author replies A request often follows the author's replies to your threads, such as a fix summary, and the author may resolve each thread right away. Such replies don't count as review feedback, which skips resolved threads, so the request carries them as context instead: - Replies the MR's author, or whoever asked for the review, wrote since the previous request for your review, or since monitoring started without one. Resolved threads count. - Replies in threads you took part in come first. The update links at most 10 replies, after the request itself, and its description counts them, such as "The author replied 2 times since the previous request: 1 in threads you took part in, 1 in resolved threads." - The inbox stores the replies' IDs and links, never their text. A failure to read them doesn't hold the request back, and the update says the replies couldn't be read. Unlike review feedback, a request doesn't leave the inbox once its replies' threads are resolved. It stays until you acknowledge it, the MR merges or closes, or the session stops targeting it. Requests follow `delivery.reviews`. A summary turn reads the linked replies, with their threads' earlier comments and code as for [summary turns](#summary-turns), and marks each reply's thread as resolved or not. It treats the replies as untrusted, has no tools, and doesn't review the code. Set `watch.reviewRequests` to `false` to stop review request updates. ## Merge request updates Forgekeeper also watches each session's explicit PR/MR targets for these updates: - **Conflicts:** a target that could merge starts to conflict with its target branch. - **Failed jobs:** a job fails in a target's head pipeline, even while the pipeline still runs. - **Requested changes:** a reviewer requests changes when no other request for changes is outstanding. Pending reviews from other reviewers, CI checks, and merge blockers do not clear the update. - **Merges:** a target merges. - **Outdated issues:** the issue a target works on has fields its progress makes wrong (see [Outdated issues](#outdated-issues)). Conflicts, failed jobs, requested changes, and merges come from changes in the forge's state, never from comments such as GitLab's "can no longer be merged" note. The first lookup only records these states. [Outdated issue](#outdated-issues) checks can announce problems on their first successful read. Records persist across restarts, so a change that happened while OpenCode wasn't running is announced at the next lookup. A mergeability the forge hasn't settled yet, such as while GitLab rechecks an MR after a push to it or to its target branch, keeps the last known state. A conflict that ends and starts again is a new update. Sessions are watched the same way as for review feedback, without visiting their tabs. Failed jobs don't wait for the pipeline to finish, which can take much longer than the job. Each lookup reads the pipeline's failed jobs: - On GitLab, the first 10 failed jobs that aren't retried, with the MR, and no other query. One that isn't allowed to fail is enough to know the pipeline fails. When all 10 are allowed to fail and more failed, an unread one may fail the pipeline, but none counts as failing it while the pipeline runs. Once the pipeline finishes as failed, which jobs allowed to fail never cause, the update reports that a job past those 10 failed it. - On GitHub, the head commit's failed checks, which count as one pipeline. Each job attempt counts once. A lookup that finds new failed jobs makes one update for them, which names and links them, lists the jobs that failed earlier in that pipeline, and says whether the pipeline still runs. That update replaces the pipeline's earlier one in the inbox, and reaches the session again. A retry that fails again is a new attempt, so it's a new failure. Forgekeeper remembers the newest 500 attempts it saw in a pipeline, so one that newer failures push past the jobs it reads isn't new when it comes back. Another pipeline that fails, such as after a push, is new too. At most 10 jobs are named, and more are counted. Records stored before Forgekeeper told job attempts apart only record the jobs, without an update. The update clears once the pipeline no longer has failed jobs, another pipeline replaces it, or the PR/MR closes. Forgekeeper never retries or fixes failed jobs. A rule can have it [investigate them](#investigate-failed-jobs) in the owning session. Each change waits in the target's record until it reaches the inbox, in the same storage write as the record. A merge stops polling, so waiting changes are retried every minute and after a reload, without another lookup. Updates go to `/forge-feedback`, and `delivery.lifecycle` sets what else they do: `"inbox"`, the default, `"passive"`, or `"summary"`, as for [review feedback](#review-notifications). Each change keeps the mode from when it was detected, so turning on summaries never starts turns for changes found earlier. A summary turn has no tools, and gets only Forgekeeper's facts about the change, never comments. A conflict update clears once the conflict ends or the PR/MR closes. A requested-changes update clears when the last outstanding request no longer stands, for example when that reviewer is asked to review again or approves. A merge update stays until you acknowledge it, because the merge is the news. Updates for targets the session drops clear right away. Setting `watch.lifecycle` to `false` stops these updates and retarget proposals, since Forgekeeper no longer watches for merges. ### Outdated issues Forgekeeper checks a target's related issue using its explicit `issue_url` or, when no `issue_url` is set, the issue number inferred from the PR/MR's source branch name. The checks depend on the forge: - **GitLab:** Forgekeeper reads the related issue on the first successful lookup of the related MRs and whenever their membership, state, or draft status changes. Changes to the issue alone don't trigger a check. An update lists what looks wrong: - The status lags behind: not "In review" while an MR is ready for review, or not "In dev" or later while all open ones are drafts. - A tracked MR merges and all MRs the session tracks for that issue are confirmed merged, but the issue is still open. Forgekeeper retries the check if a lookup fails. - It has no assignee, no `group::` label, no `maintenance::`, `bug::`, or `feature::` label, or no milestone. - **GitHub:** Forgekeeper performs only the final-merge check. Ordinary open and draft PR polls make no issue API calls. When a tracked PR transitions from open to merged and all PRs this session tracks for that issue are confirmed merged, Forgekeeper reads the issue and warns if it is still open. It doesn't check GitHub assignees, labels, milestones, or project status. For example, when a session tracks `acme/app#41` and `acme/app#42` for `acme/platform#9`, merging `#41` sends only its ordinary merge notification. When `#42` merges, Forgekeeper sends `#42`'s ordinary merge notification independently and checks `acme/platform#9`, warning once if the issue is still open and staying silent if GitHub closed it. "All" always means all PRs or MRs this session tracks for the issue. If a lookup fails on that final merge, Forgekeeper retries the issue check on the lifecycle retry schedule and after a reload without holding back the ordinary merge update. Forgekeeper announces each problem once per issue in the session, including on the first successful GitLab issue check for an open MR. A later check can announce a recurring problem if an intervening check confirmed it was fixed. The update tells the agent to say what it would change and wait for your approval before editing the issue. It follows `delivery.lifecycle` and stays in the inbox until you acknowledge it, drop the PR/MR it references, or that PR/MR closes without merging. Set `watch.issues` to `false` to stop new checks and updates. ### Stacked PRs/MRs A target **builds on** another of the session's targets when it targets that one's source branch in the same project, on the same host. Forgekeeper links them only when exactly one target matches, and keeps the link once the parent merges, because forges may retarget the dependent PR/MR or delete the merged branch at that point. Sharing a session doesn't make two PRs/MRs a stack. When a parent merges, its update lists each dependent, and `lifecycleExecution.parentMerged` sets what Forgekeeper works out about them: | Mode | What happens | | ----------- | ------------------------------------------------------------------------------------- | | `"notify"` | The default. The update names the dependents and the branch they target, and no more. | | `"prepare"` | Forgekeeper works out the listed actions and proposes them in the update. | `actions` lists what `prepare` works out, so it needs at least one. `parentMerged` supports `"retarget"`: ```json { "lifecycleExecution": { "parentMerged": { "mode": "prepare", "actions": ["retarget"] } } } ``` Forgekeeper proposes retargeting a dependent to the branch the parent merged into, and only when it still targets the parent's source branch in the same project. It reads the dependent from the forge first, so one the forge already retargeted gets no proposal, and neither does one that targets something else, closed, or merged. A parent from a fork gets no proposal, since its branch lives in another project. Only dependents the session still targets count. Forgekeeper never retargets anything itself, and never rebases. GitLab retargets up to four dependent MRs when the merge deletes the source branch, so a proposal usually means the branch was kept, which may be deliberate. Retarget the MR yourself, and rebase it if the parent was squashed, since its commits stay on the dependent branch. Each event keeps the policy it happened under, and the stricter of that and the current policy applies, so enabling `prepare` never reads dependents again for earlier merges. `lifecycleExecution` has no policy for conflicts or failed jobs. To investigate failed jobs, add a [`job-failed` rule](#investigate-failed-jobs) to `automation.rules` instead. An invalid or unsupported policy, such as `"prepare"` without actions, falls back to `"notify"`, and Forgekeeper shows an error toast saying which options it ignored. ## Prepare fixes from review feedback Automation is off by default. To authorize selected reviewers for specific projects, add rules to `automation.rules` in Forgekeeper's plugin options: ```json { "automation": { "rules": [ { "on": "review", "host": "gitlab.com", "projects": ["gitlab-org/gitlab"], "reviewers": ["GitLabDuo"], "action": "prepare" } ] } } ``` Each rule names its trigger in `on`: `"review"` for review feedback, or `"job-failed"` to [investigate failed jobs](#investigate-failed-jobs). Forgekeeper ignores a rule without one, with an error toast. Hosts, projects, and reviewer usernames must be exact, without wildcards. Forgekeeper resolves usernames through the authenticated forge API and checks account IDs on the findings it reads. Adding an account to `reviewBots` enables monitoring only; it does not authorize code changes. The corresponding review source must still be enabled under `watch`. For each new settled batch on a project with a matching rule, Forgekeeper counts all non-archived root sessions explicitly targeting the PR/MR across worktrees. Inactive sessions and sessions without an open tab count, including sessions whose checkout has automation disabled. Subagents do not count. Exactly one session must own the target. Forgekeeper records a batch with multiple associated sessions as skipped before reading its findings, so it stays skipped even if the other associations are removed later. While sessions can't be read, Forgekeeper leaves the batch undecided and retries it. By default, automatic action only runs on PRs/MRs you wrote, as the signed-in `glab` or `gh` account, so a review of a colleague's MR never edits their branch. To include other accounts, list them in the rule's [`authors`](#other-authors). Before queuing a batch, Forgekeeper also checks that the session's checkout is on the PR/MR's source branch, at its head commit. A batch that fails these checks is skipped with the reason, and keeps its normal delivery, such as a summary. To run such a batch in a worktree instead, see [Run automation in an execution environment](#run-automation-in-an-execution-environment). **Act on feedback** works on any author's PR/MR. ### Other authors To also act on PRs/MRs that another account writes, such as a service account whose MRs you maintain, list it in the rule's `authors`: ```json { "on": "review", "host": "gitlab.com", "projects": ["gitlab-org/gitlab"], "reviewers": ["GitLabDuo"], "authors": ["service-modelops-agent-principles-distiller"], "action": "prepare" } ``` `authors` adds to your own PRs/MRs and never replaces them. Usernames must be exact, without wildcards. Forgekeeper resolves them through the authenticated forge API and compares the account IDs with the PR/MR's author. An entry that doesn't resolve is ignored, with an error toast once per run, so it never widens the rule. A rule with an empty or invalid `authors` list is ignored, with an error toast. On a PR/MR that another account wrote, only the rules that list that author apply: only their reviewers' findings count, and only their allowed models restrict the turn. A failed-job investigation on a PR/MR you review keeps every matching rule, as before. When several rules match a project, any rule that lists the author is enough. Fixes stay uncommitted, so pushing to someone else's branch remains your decision. Eligible work waits for the owning session to become idle. Before submission, Forgekeeper rechecks ownership, inbox membership, pause state, rules, current findings, and the checkout's source project, branch, and head commit when available. It checks them again before the turn's first model request, and also confirms that the findings in the prompt still match the current authorized findings. If any check fails, the turn ends before the model runs and the update shows the reason. Plan sessions cannot run preparation tasks. Preparation uses a normal coding turn with the session's instructions, tools, and permissions. Reviewer findings enter the prompt as untrusted data, separately from Forgekeeper's task instructions. The agent verifies each finding against current code, implements justified fixes, runs relevant checks, and reports changes and skipped findings. It can fix merge request metadata that a finding asks for, such as a missing label. It leaves changes uncommitted and must not push, post replies, resolve threads, approve, or merge. It never assigns a merge request to a bot or asks one to merge it, such as `gitlab-release-tools-bot` for security merge requests, and it never marks checklist tasks or attestations as done. Unlike restricted summaries, preparation includes reviewer text in the session's history and permits tools. Matching `"on": "review"` rules also authorize a restricted approval follow-up turn when a watched, listed non-human reviewer (an automated reviewer such as `GitLabDuo` or `copilot-pull-request-reviewer[bot]`, or a bot listed in both `reviewBots` and the rule's `reviewers`) explicitly approves the PR/MR. Upgrading an existing `"on": "review"` rule grants those restricted turns access to `forgekeeper_mark_ready` without a configuration change; to keep automated fix preparation while blocking approval draft-ready mutations, deny `forgekeeper_mark_ready` in your OpenCode session or agent permissions (globally or per URL pattern). On GitHub, use exact canonical bot usernames with `[bot]` (for example `sec[bot]`). Only explicit approvals trigger approval events; a completed review without approval (such as GitLab Duo ending in `REVIEWED`) does not. On GitLab servers older than 19.4 (without `approvedAt`) or for approvals recorded only in `approvedBy` without a reviewer entry, Forgekeeper still reports ordinary approval transitions, but cannot detect a revoke-and-reapprove cycle that finishes completely between two polls. Approval follow-ups always run directly in the owning session, where conversation context lives, even when the local checkout is on another branch or the rule sets `"execution": "environment"`. The owning session must use a coding agent (not `plan`) and an allowed model; otherwise the attempt is skipped and falls back to the configured summary or passive notice. During an approval follow-up, Forgekeeper removes all general tools (`bash`, file edits, `set_session_target`, and other forge tools) and enforces that restriction at tool execution and permission evaluation, including after compaction (even if compaction runs before the first model request). Only two target-bound tools are exposed: `forgekeeper_approval_status` (re-reads live status for the verified PR/MR, including draft state, conflicts, unresolved threads, CI status, awaiting reviewers, GitLab `approvalRequirementsSatisfied`, and GitHub `reviewDecision`) and `forgekeeper_mark_ready` (asserts session permission for the bound PR/MR URL, re-checks cancellation, agent, model, watch settings, ownership, rules, author scope, and the active approval, and marks only that verified draft PR/MR ready). The rule authorizes the turn, not the mutation itself: the model calls `forgekeeper_mark_ready` only when the owning session's prior instructions ask for it and every condition the user gave is verified. Approval follow-ups require a matching rule covering the project, PR/MR author, active watch settings, and verified non-human reviewer account ID on automatic selection, manual **Act on feedback**, explicit retry, and tool execution; watch-only bots remain informational. Human reviewer approvals are never eligible for automation or **Act on feedback** (which clients hide for human approvals) and stay strictly informational (inbox and tool-free summaries only), even if a rule lists that reviewer's username or the GitHub approval includes body text. Automation works with inbox-only delivery and replaces automatic summary delivery for selected batches. A skipped batch, such as one without findings from authorized reviewers, keeps its normal delivery. So does an automatic attempt that ends before its coding turn starts, such as when a check fails after queuing. Once a turn starts, its update gets no summary. Enabling a rule does not start old inbox updates recorded without automation enabled. In `/forge-feedback`, each selected update shows its automation state and reason. Press Ctrl+A to **Act on feedback** manually without an automatic rule, including on a skipped batch, or Ctrl+T to explicitly retry after inspecting the session. Manual action retains ownership and checkout checks. A skipped batch never ran, so once another session is the only one targeting the PR/MR, acting on the batch there moves it to that session. Automatic action still skips it. A batch that ran stays with its session until that session is deleted. Acknowledging an update cancels queued work; stop a running task through normal session cancellation. Forgekeeper still records a running task's outcome after its update is acknowledged. Independent worktree instances share `automation.sqlite` under `$XDG_DATA_HOME/opencode/forgekeeper/review-claims`, or `~/.local/share/opencode/forgekeeper/review-claims` when `XDG_DATA_HOME` is unset. A SQLite transaction acquires the PR/MR's execution claim and marks the attempt running together. Conditional writes reject stale updates from other instances, and stored batch outcomes prevent completed work from starting twice. Claims do not expire while a coding task might still run. After reload, Forgekeeper reconciles recorded executions against the session transcript and never automatically replays uncertain work. A definitive outcome and the release of its claim are stored in one transaction, so finished work never keeps holding the PR/MR. Started attempts retain their task instructions and coding tools across compaction, even while a summary is queued behind them. Once the session goes idle, later turns, including compacted ones, no longer count as part of the attempt. Ordinary synthetic reminders do not end an attempt. Forgekeeper records how the attempt's turn ended when the session reports it. If a compaction removed the attempt's prompt, that recorded end is the only evidence Forgekeeper accepts, so a later task's success can't mark a failed attempt completed. If the turn ended while no Forgekeeper instance was running, the outcome is uncertain. If submission was interrupted before the first model request, monitoring marks the attempt failed and retains its claim. After inspecting the session, use explicit retry. The old prompt cannot start once its attempt has been replaced. Monitoring retries checks that fail temporarily. A failed attempt's claim is freed when later feedback on the PR/MR is acted on, once the attempt's turn has ended. If its outcome is uncertain, inspect the session, then use **Retry feedback work** on any update for the PR/MR to clear the claim. A turn that's still running always keeps its claim, including one you steered with another message. Deleting the session that holds a claim ends its attempt, and the next action on the PR/MR frees the claim. While a session can't be read, its claim stays. ### Allowed models A preparation turn uses the session's selected model, so a rule can require models you trust with code changes. List them, as `provider/model` IDs, in the rule's `allowedModels`, or name a list in `automation.modelGroups` and reference it with `allowedModelGroup`, to share it between rules: ```json { "automation": { "modelGroups": { "coding": ["anthropic/claude-opus-5-5", "openai/gpt-6"] }, "rules": [ { "on": "review", "host": "gitlab.com", "projects": ["gitlab-org/gitlab"], "reviewers": ["GitLabDuo"], "action": "prepare", "allowedModelGroup": "coding" } ] } } ``` A rule without either allows any model. A rule that sets both, references an undefined group, or has an empty list is ignored, with an error toast, so a mistake never lifts a restriction. Any reasoning variant of an allowed model counts. Each finding needs a model that a rule for its project and reviewer allows. When several rules cover the same reviewer, any one of them is enough, and a rule without allowed models allows any. A batch with findings from several reviewers needs a model that all of them allow. Forgekeeper reads the session's model, or else its agent's, or else the default, before queuing a batch and again before submitting it. A batch the model can't act on is skipped with the reason, and keeps its normal delivery. Switch the session's model and use **Act on feedback**, which applies the same restrictions to findings from the rules' reviewers. The turn's first model request checks the model it actually uses, and every later request in the turn checks it again, so switching to another model mid-turn fails the turn. After a turn fails this way, inspect the session for changes, switch models, and use **Retry feedback work**. ## Investigate failed jobs A `job-failed` rule has Forgekeeper start a turn in the owning session when a job fails in the head pipeline of a PR/MR on one of the rule's projects. The turn reads the failed jobs' logs, classifies each failure, and recommends fixes. It changes nothing: ```json { "automation": { "rules": [ { "on": "job-failed", "host": "gitlab.com", "projects": ["gitlab-org/gitlab"], "action": "investigate" } ] } } ``` `action` defaults to `"investigate"`, the only action so far. Hosts and projects must be exact. On busy projects such as `gitlab-org/gitlab`, many failures are flaky or already broken on the target branch, so each turn has a model cost. Add only the projects you want investigated. `allowedModels` and `allowedModelGroup` work as for [review rules](#allowed-models), and a project with several `job-failed` rules allows the models of any of them. Each pipeline gets at most one investigation. A pipeline's failed-job updates form one batch, and the turn starts once no job in the pipeline has newly failed for four minutes, or once the pipeline finishes, whichever comes first. A failure that arrives before the turn starts, even while the session is busy, replaces the update and restarts the wait, so the turn sees the failures together. After the turn starts, later failures in the same pipeline start no second turn and get no summary. A new pipeline, such as after a push, is a new batch. Use **Retry feedback work** to investigate a pipeline again. The same ownership, idle, and recovery rules as for [review preparation](#prepare-fixes-from-review-feedback) apply: exactly one session must target the PR/MR, the turn waits for that session to go idle, the PR/MR's execution claim is shared across worktrees, and a reload never replays uncertain work. Forgekeeper skips the batch with the reason, and keeps its normal delivery, when any of these checks fail: - **Author or reviewer:** automatic investigations run on PRs/MRs you wrote or review, as the signed-in `glab` or `gh` account, and on ones written by an account that a matching rule's `authors` lists, as for [review rules](#other-authors). On GitHub, a reviewer is someone with a pending review request or a submitted review. - **Current pipeline:** the failing pipeline must still be the PR/MR's head pipeline, the one for its head commit, and still have failed jobs. On GitLab, that includes merged results pipelines, which test a merge of the head commit into the target branch. - **Checkout:** the session's checkout must be on the PR/MR's source branch, at that head commit. A checkout that moved on may already fix the failure, so the reason names the commit to check out before a retry. Rules with `"execution": "environment"` run the turn in a worktree at that commit instead. See [Run automation in an execution environment](#run-automation-in-an-execution-environment). Forgekeeper checks the pipeline and checkout again before the turn's first model request. A job that fails after the prompt is submitted, but before that request, still joins the batch: the request waits until no job has newly failed for four minutes, or the pipeline finishes, and the session shows as busy meanwhile. Jobs that failed after the prompt was written don't stop the turn. The prompt's job list is a snapshot, and it can be partial, such as past the first 10 failed jobs on GitLab, so the agent starts by listing the pipeline's current failed jobs. The prompt lists the failed jobs, with their names, stages, IDs, and links, as untrusted data, separately from Forgekeeper's task instructions. Anyone who can push to the branch controls what a job prints, so the instructions tell the agent to treat job output as data too. The agent reads the logs with the session's tools, such as `glab ci trace`, and decides for each job whether it's flaky, already broken on the target branch, caused by the PR/MR, or an infrastructure problem. It must not edit files, commit, push, retry or cancel jobs, post comments, or change the PR/MR, though it can recommend a retry. These limits come from the instructions, and the session's permissions still apply. Since the turn changes nothing, it can run in a session that uses the `plan` agent. **Act on feedback** investigates a failed-job update on request, on any author's PR/MR, with the same checks apart from authorship. It works without a rule too, and later failures in the pipeline join that batch as they do for automatic ones. ## Run automation in an execution environment A session can track several PRs/MRs, but its checkout sits on at most one of their branches. To let automation run for the others, set `"execution": "environment"` on the `review` and `job-failed` rules for their projects: ```json { "automation": { "rules": [ { "on": "review", "host": "gitlab.com", "projects": ["gitlab-org/gitlab"], "reviewers": ["GitLabDuo"], "action": "prepare", "execution": "environment" } ] } } ``` The default, `"session"`, skips a batch whose checkout doesn't match, as before. With `"environment"`, a batch whose only failing check is the checkout runs through the environment provider at the PR/MR's head commit. Every rule of the batch's kind for the project that applies to the PR/MR's author must set `"environment"`, so one such rule without it keeps the turn in the owning checkout. On a PR/MR that an account in a rule's [`authors`](#other-authors) wrote, only the rules that list that author count. **Act on feedback** and **Retry feedback work** follow every rule for the project. When the owning checkout is on the source branch at the head commit, the turn runs there, as without the option. ### Local worktree provider Forgekeeper currently supplies one provider, `local-worktree`. It runs a linked session on the same OpenCode server, in a locally accessible Git worktree. Creation and removal use OpenCode's configured worktree strategy. The strategy must produce a Git checkout at the requested commit that supports Forgekeeper's checkout and remote checks. Reuse discovers the repository's Git worktrees. The rule controls whether execution may use another environment. The provider controls preparation, admission, linked-session access, recovery, and cleanup. This provider contract is internal. VM and cloud execution require a future provider integration; they cannot currently be selected through configuration. Each attempt records its provider and state version before provisioning. Recovery uses that provider even if the default later changes. An unavailable provider or unsupported state version retains the attempt's claim for inspection. Existing development records using `checkout` are migrated; configuration using that option reports its replacement and drops the affected rule. #### Choose the worktree Forgekeeper uses the first of these that applies: 1. A worktree Forgekeeper created for the same PR/MR, at the head commit, even with uncommitted changes from an earlier batch, so later batches build on them. 1. Another worktree at the head commit, without uncommitted changes, on the source branch pushing to the source project, or with a detached HEAD and a remote for the source project. 1. A new worktree, created with OpenCode's worktree API and named `forgekeeper---`, so OpenCode lists it and its sessions with the project. The random part identifies this one creation, so what a failed creation left is never confused with another worktree. A worktree is reused only while no session in it, subagents included, is running, and only one attempt uses a worktree at a time, even across PRs/MRs at the same commit. Sessions in a directory below the worktree's count, except in another worktree nested there. Forgekeeper takes the worktree for the attempt before it checks it, so no other attempt changes it in between. The owning session's own checkout is never one of them. OpenCode creates worktrees with a detached HEAD, and runs the project's start command in them. Forgekeeper then switches a new worktree to the source branch when that changes no branch: the local branch is at the head commit and checked out nowhere else, or there is no local branch yet, which Forgekeeper creates to track the source branch. A local branch of the same name that pushes to another project, such as upstream for a PR/MR from a fork, doesn't count. Otherwise the worktree keeps its detached HEAD, and the notices give the command to publish commits made there, quoted for the shell, such as `git push 'origin' 'HEAD:refs/heads/feature'`. When the head commit isn't in the repository, Forgekeeper fetches only the source branch from the remote that points to the source project, and never pulls, rebases, or updates other branches. If the commit is still missing, or no remote points to the source project, such as for a fork that isn't a remote, the attempt ends with the reason before anything runs. ### Linked sessions The linked session is a new root session in the worktree, with the owning session's agent, model, and permissions. The owning session keeps the target, the inbox update, and the PR/MR's execution claim. It gets a notice when the linked session starts, with the worktree path and session, and another when the turn ends, with the worktree's uncommitted changes. Once a completed turn's report is relayed to the owning session, Forgekeeper archives the linked session and closes its open tab; failed linked sessions stay open for inspection. Linked sessions never count as owners, aren't watched for feedback, get no inbox updates or target guidance, and can't set targets. The linked session's permissions are those of the owning session in its checkout: its agent's rules as the owning checkout configures them, followed by the session's own rules. OpenCode applies a session's rules after its agent's, and the last matching rule wins, so these rules apply in the worktree even where its configuration of the agent differs. An `allow` from the owning checkout therefore overrides a `deny` of the worktree's agent configuration. The owning session needs an agent of its own: without one, the attempt ends before anything runs, with the reason. Forgekeeper must be enabled, with PR/MR status on, in both checkouts. The worktree's instance checks the turn's first model request as the owning checkout would, under the owning checkout's current rules, and refuses the turn while Forgekeeper isn't running there. Right before the turn starts, after any wait, such as for a failed-job batch's quiet time, it also refuses the turn when another session in the worktree is running, or when someone else's uncommitted changes appeared there. These checks cover the start of the turn: Forgekeeper can't keep another session from starting in the worktree afterward. The linked session's prompt doesn't hold the findings: Forgekeeper adds them to its requests, so without Forgekeeper in the worktree, the model reads only a note that the task couldn't start. A worktree's instance starts with the linked session's prompt, so Forgekeeper can't wait for it beforehand. A turn that ends without that first check having recorded its start fails, with a reason that says so, instead of counting as completed. **Act on feedback** and **Retry feedback work** don't wait for the owning session when the turn runs in a worktree. A failed job that joins a failed-job batch while its worktree is prepared joins the attempt, and the turn waits out the quiet time again. Deleting the owning session doesn't end a turn that its linked session is still running. If Forgekeeper stops before the turn is submitted, it rechecks the task and resumes preparation through the recorded provider. It reuses a recorded checkout and identifies linked sessions by attempt, including a session created before its ID was saved. Unresolved worktree creation retains the claim for inspection. A submitted turn is reconciled against the linked session's transcript, and uncertain work is never replayed. ### Cleanup Forgekeeper removes only worktrees it created, through OpenCode, when all of these hold: - The PR/MR merged or closed. - The worktree has no uncommitted or untracked changes. - Its HEAD is the PR/MR's final head commit, or one of its ancestors, so it has no commits the PR/MR doesn't. - No attempt that may still run holds it, no session in it or below its directory is running, and every such session is a linked one or one of their subagents. Forgekeeper asks OpenCode to archive the linked sessions once it removes the worktree. OpenCode 2.3.0 ignores `archived` in a plugin's session update, so they stay in the session list until you archive them. Forgekeeper checks this at startup and every five minutes, so a worktree that stops qualifying, such as one you committed in, stays. No attempt can start using a worktree while Forgekeeper removes it. If OpenCode fails partway through creating a worktree, such as when the start command fails, Forgekeeper still records what it created, so cleanup finds it. It records only a worktree with the name it requested, whose random part no other creation shares, and never a directory another PR/MR's record already holds. It never removes a worktree that it didn't create. ## Options ### Monitoring security boundary Monitoring uses the existing authenticated `gh` and `glab` clients for fixed read-only GraphQL queries and GitLab MR REST lookups. GitLab subscriptions read the host's token with `glab config get token --host` and send it in the WebSocket authorization header over TLS. Tokens are not stored in plugin storage or included in URLs. Subprocesses use argument arrays rather than shell interpolation, share the existing concurrency limit of four, and time out after 30 seconds. Their credentials and environment are those of the OpenCode service; monitoring does not provide OS-level isolation or reduce those credentials' scopes. The `inbox` mode invokes a model only when you ask for a summary with Ctrl+R in `/forge-feedback`. The `passive` mode starts no turn, but when something else wakes the session, its message can run as one step that sends the model only the notice's title, time, and links, without tools. The `summary` mode sends review text to the session's model in a request whose only possible tool reads GitLab notes that the comments link to, as described in [Linked notes](#linked-notes). It reads with your `glab` credentials, so it can read private notes in other projects on the same host that those links name. No mode executes commands from review content, edits repository files, commits, pushes, posts replies, or resolves discussions. Monitoring and review summaries change nothing on a forge, and stacked PRs/MRs only propose retargets (see [Stacked PRs/MRs](#stacked-prsmrs)). The only forge write Forgekeeper itself exposes is `forgekeeper_mark_ready` during an authorized non-human approval follow-up turn under a matching `"on": "review"` automation rule: it marks only that verified draft PR/MR ready for review after evaluating session permissions for the bound URL, and can be blocked globally or per URL by denying `forgekeeper_mark_ready` in OpenCode permissions. Comment links are opened only after user selection and must use HTTPS on the target's origin without embedded credentials. Review bodies remain external data, not trusted instructions. Analysis and remediation are outside this feature's scope. Pending updates are stored locally through OpenCode's plugin storage. Conversation history is inspected locally only to find the latest user-message timestamp, with at most four session checks in flight. The 72-hour window limits monitoring eligibility, not access rights. OpenCode's provider, integration, and organization policies still apply. This implementation has not received AppSec approval. Set options with the object form of the `plugins` entry in `opencode.json`: ```json { "plugins": [ { "package": "opencode-forgekeeper", "options": { "watch": { "humanReviews": false } } } ] } ``` | Option | Default | Description | | ------------------------ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `status` | `true` | Show the PR/MR status and monitor the session's PRs/MRs. Set to `false` to keep only session targets and titles. | | `hosts` | `["gitlab.com"]` | GitLab hosts whose remotes are recognized, besides hosts named `gitlab.*`. | | `githubHosts` | `["github.com"]` | GitHub hosts, including GitHub Enterprise hosts. | | `pollSeconds` | `120` | Normal polling interval. Automated reviews and settling feedback poll at 30 seconds or this value, if lower. | | `watch.humanReviews` | `true` | Watch for new review feedback from people. | | `watch.automatedReviews` | `true` | Watch for automated reviews that finish with feedback, such as GitLab Duo's and GitHub Copilot's. | | `watch.reviewBots` | `true` | Watch for comments from the accounts `reviewBots` lists. | | `watch.lifecycle` | `true` | Watch for targets that start to conflict, get failed jobs, get requested changes, or merge. See [Merge request updates](#merge-request-updates). | | `watch.issues` | `true` | Watch related issues: outdated GitLab issue fields and open issues after all tracked GitLab MRs or GitHub PRs merge. Needs `watch.lifecycle`. See [Outdated issues](#outdated-issues). | | `watch.reviewRequests` | `true` | Watch for requests for your review, including repeated ones. See [Review requests](#review-requests). | | `reviewBots` | GitLab.com security reviewers | Bot accounts whose comments count as review feedback, by host, with exact usernames. See [Review bots](#review-notifications). | | `inbox` | `false` | Enable inbox monitoring for checkouts without a saved monitoring preference. Automation rules also enable it. | | `delivery.reviews` | `"inbox"` | What a review update does besides entering the inbox: `"inbox"`, `"passive"`, or `"summary"`. See [Summary turns](#summary-turns). | | `delivery.lifecycle` | `"inbox"` | What a merge request update does besides entering the inbox: `"inbox"`, `"passive"`, or `"summary"`. | | `lifecycleExecution` | `"notify"` | What Forgekeeper works out when a parent PR/MR merges, in `parentMerged`. See [Stacked PRs/MRs](#stacked-prsmrs). | | `automation.rules` | No rules | What starts an automatic turn: feedback from authorized reviewers, or failed jobs, and where it runs. See [Prepare fixes](#prepare-fixes-from-review-feedback), [Investigate failed jobs](#investigate-failed-jobs), and [Run automation in an execution environment](#run-automation-in-an-execution-environment). | | `automation.modelGroups` | No groups | Named lists of `provider/model` IDs that rules reference in `allowedModelGroup`. See [Allowed models](#allowed-models). | `watch` and `delivery` list only what you change, and sources added in later releases start on. For example, this summarizes review feedback and stops watching merge request changes: ```json { "watch": { "lifecycle": false }, "delivery": { "reviews": "summary" } } ``` An option Forgekeeper doesn't know, or a value it can't use, shows an error toast at startup that names the option and what's used instead, even with `status` off. The server entry point reads every option, so changing one takes effect when the server plugin reloads. The CLI has no options of its own. Each checkout's server reads the options for its location, so the CLI can show status in one project and not in another. ### Keep only session titles To keep the behavior of `opencode-forge-session-title` alone, turn off review status: ```json { "plugins": [{ "package": "opencode-forgekeeper", "options": { "status": false } }] } ``` The server still registers `set_session_target`, adds the agent guidance, and maintains the title prefix. It doesn't poll or send review notifications, and the CLI shows no footer. `/forge-status` and `/forge-open` explain that the status is off. A summary or notice that Forgekeeper queued before you turned review status off can still start a step. That step still runs without tools, history, or permissions. It doesn't read the review text: it only says the text is unavailable. ## RPC The server registers an [RPC](https://opencode.ai/v2/docs/build/plugins/rpc) with the ID `opencode-forgekeeper`, defined in `src/rpc.ts`. The CLI uses it, and other plugins can call `target` and listen for `targetChanged`: - `target({ sessionID })` returns `{ url, issueUrl?, targets }` for explicit targets, and `{}` when no targets are set. `targets` lists every target as `{ url, issueUrl? }`. `url` and `issueUrl` describe the first target, for callers that expect a single target. - `watch({ clientID, keys, visible? })` renews the caller's leases on `keys` and returns `{ enabled, statuses }`. A key is a session ID, or `""` for the checkout outside a session. `visible` is the key on screen. - `release({ clientID })` drops the caller's leases. - `refresh({ key })` looks the key up now and returns `{ enabled, snapshot }`. - `feedback({})` returns `{ items, paused }` for this checkout's pending feedback. - `acknowledgeFeedback({ id })` dismisses a local update and returns the updated inbox. - `summarizeFeedback({ id })` starts a summary turn for an update in its session. - `monitoringStatus({ sessionID })` reports, without changing anything, whether the session is monitored, and each target's fetch health and subscription state. - `pauseFeedback({ paused })` persists the checkout's review-monitoring pause state. - `cleanupCandidates({ scanID? })` scans non-archived root sessions across the project's worktrees and returns `{ enabled, candidates, skippedErrors }` for idle sessions whose tracked PRs/MRs have all merged or whose issue-only targets have all closed. - `cleanupSessions({ sessionIDs, scanID? })` re-verifies eligibility from live forge state, archives eligible sessions, clears their inbox updates, and returns `{ archived, alreadyArchived, failed }`. - `cleanupProgress` fires with `{ scanID?, phase, checked, total }` while scanning or cleaning up sessions. - `sessionsCleanedUp` fires with `{ sessionIDs }` after sessions are archived so connected TUI and Desktop clients close their open tabs. - `feedbackChanged` fires with `{ directory }` when the inbox or pause state changes. - `targetChanged` fires after targets change, with the same fields as `target` and the `sessionID`. It has only the `sessionID` when no targets are set. - `status` fires with `{ directory, key, snapshot }` when a key's status changes. - `notice` fires with `{ sessionID?, title?, message, variant, openTab? }` for the CLIs to show as a toast. Keys are relative to the location of the call or event, because each checkout's server plugin instance watches its own sessions. ## Migrating from opencode-forge-session-title Replace `opencode-forge-session-title` with `opencode-forgekeeper` in `opencode.json`. Upgrading from `opencode-forgekeeper` 1.x works the same way, because 1.x used the same IDs as `opencode-forge-session-title`. | Entry point | Plugin ID | Stored state | | ----------- | --------------------------- | ---------------------------------------------------------------------------------------- | | Server | `opencode-forgekeeper` | Session targets, owned title prefixes, human-review baselines, and pending notifications | | CLI | `pedropombeiro.forgekeeper` | None | OpenCode scopes plugin storage by plugin ID, so nothing stored under the former ID, `opencode-forge-session-title`, carries over: - Sessions start without targets. Ask the agent to set their targets again. - A title that kept a single-reference prefix from before, such as `[!456] Review`, now looks like a reference that you wrote and does not affect status. Setting a target adds a second prefix, such as `[#12, !45] [!456] Review`. Remove the older prefix by hand. Older prefixes with two references, such as `[#12, !45]`, are replaced automatically. - The first look at each PR/MR records a new review baseline, so comments posted before then aren't announced. - Callers of the RPC need the new ID, `opencode-forgekeeper`. With default options, the footer shows status once a session has a PR/MR target. Enable the inbox to collect updates, then set `delivery.reviews` to `summary` if you want automatic summaries. Set `status` to `false` to keep only titles. If you set options for `opencode-forgekeeper` 2.x, also see [Upgrade from forgekeeper 2.x](#upgrade-from-forgekeeper-2x). ## Code layout - `src/index.ts` wires the server: the forge catalogs from the options, with a shared concurrency limit for status, and title lookups. - `src/server.ts` registers the tool, `/forge-detach`, the agent guidance, title reconciliation, and the RPC. - `src/status-server.ts` connects the status service to sessions, storage, notifications, and RPC events. `src/status-service.ts` holds the leases and decides which keys poll. - `src/target.ts` parses, normalizes, changes, and formats session targets, and matches forge URLs against them. - `src/limit.ts` bounds how many forge requests run at once. - `src/title.ts` extracts branch issue numbers and reconciles title prefixes. - `src/options.ts` reads the plugin's status options. - `src/lookups.ts` reads a targeted PR/MR's source branch to infer its related issue. - `src/status-client.ts` holds the CLI's leases, snapshots, and per-directory settings. `src/client-core.ts` connects it to the RPC for both clients. `src/tui.tsx` renders the terminal footer, dialog, commands, and notices; `src/gui.tsx` renders the desktop pill, panels, commands, and notices. `src/notice.ts` decides which notices a CLI shows and which tabs it reopens. - `src/forge.ts` defines the forge-neutral types, the `Forge` adapter interface, and `ForgeTraits` with its optional `automatedReview`, `feedback`, and `lifecycle` capabilities. - `src/adapters/gitlab/feedback.ts` and `src/adapters/github/feedback.ts` read each forge's comments for its `feedback` capability. - `src/adapters/gitlab/adapter.ts` and `src/adapters/github/adapter.ts` provide each forge's adapter and traits. Adapters own API calls, pagination, error classification, and status normalization. Traits cover everything else: hosts, URL parsing, reference syntax, vocabulary, and forge-specific footer and dialog content. - `src/forges.ts` registers each forge's traits, classifies hosts, opens adapters, and parses URLs. - `src/git.ts` resolves a checkout's remotes, branch, and pushed branch name. - `src/locate.ts` picks each key's PRs/MRs. `src/store.ts` caches lookups, polls, backs off after failures, and discards lookups that started before a change. `src/format.ts` renders the footer and dialog. - `src/automated-review-watch.ts`, `src/human-review-watch.ts`, and `src/approval-watch.ts` decide when to notify the agent about review feedback and reviewer approvals. `src/review-request-watch.ts` finds new requests for your review and selects the author's replies for context. `src/adapters/gitlab/review-requests.ts` reads them from GitLab's activity notes. - `src/review-monitoring.ts` configures the review watchers, stores their state, and records review updates in the inbox. - `src/lifecycle-watch.ts` finds conflicts, failed jobs, requested changes, merges, and stack links between lookups, and keeps each event until it reaches the inbox. `src/lifecycle-execution.ts` proposes retargets of stacked PRs/MRs. - `src/lifecycle-notifications.ts` formats lifecycle updates, checks retarget proposals, and connects lifecycle events to the inbox. `src/feedback-cleanup.ts` identifies resolved, closed, and settled updates for removal. `src/session-cleanup.ts` scans and archives idle sessions whose PRs/MRs have merged or whose issue-only targets have closed, and tracks one-time readiness notices. - `src/adapters/gitlab/linked-notes.ts` finds and reads the notes review comments link to. - `src/summary-delivery.ts` stores and delivers summary turns, restricts their model requests, and handles linked-note access. `src/review-summary.ts` formats their content. - `src/review-automation.ts` selects batches for automation rules and runs each attempt. `src/review-automation-host.ts` connects it to sessions and forges, and `src/review-claim.ts` stores attempts, execution claims, checkout locks, and the worktrees Forgekeeper created in SQLite. `src/review-worktree.ts` finds, creates, checks, and removes the worktrees that linked sessions run in. `src/review-preparation.ts` and `src/job-investigation.ts` write the prompts and task instructions for preparing review fixes and investigating failed jobs. - `src/keyed-queue.ts` serializes updates by session or record while allowing other keys to progress. Shared code never compares a forge against a specific name. It asks the forge's traits, or checks for a capability, instead. To add a forge, add its kind to `ForgeKind` and `ReviewRequest`, implement `Forge` and `ForgeTraits`, and register the traits in `src/forges.ts`. ## Development From the repository root: ```bash mise run test mise run typecheck mise run lint mise run build forgekeeper ``` ## License [MIT](../../../LICENSE)