paseo-follow-up 1.4.0-beta.16 → 1.4.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +4 -2
- package/README.md +13 -5
- package/client/panel.tsx +42 -2
- package/client/pr-controls.tsx +21 -9
- package/client/pr-sheet.tsx +3 -2
- package/client/stacks.tsx +3 -2
- package/index.server.ts +69 -8
- package/package.json +2 -1
- package/server/agent-actions.ts +13 -2
- package/server/agent-hook.mjs +21 -7
- package/server/daemon.ts +29 -5
- package/server/discovery.ts +34 -6
- package/server/engine.ts +27 -7
- package/server/github.ts +66 -5
- package/server/hook-source.ts +1 -1
- package/server/mcp-source.ts +1 -1
- package/server/mcp.d.mts +3 -1
- package/server/mcp.mjs +42 -7
- package/server/native-tools.ts +3 -2
- package/server/pr-actions.ts +91 -15
- package/server/pr-workflow.ts +181 -0
- package/server/scopes.ts +20 -8
- package/server/tasks.ts +9 -3
- package/shared/activity.ts +3 -1
- package/shared/attention.ts +8 -4
- package/shared/contracts.ts +11 -2
- package/shared/model.ts +12 -1
- package/shared/pr-actions.ts +26 -4
- package/shared/pr-workflow.ts +99 -0
- package/skills/follow-through/SKILL.md +1 -1
package/OVERVIEW.md
CHANGED
|
@@ -13,14 +13,14 @@ Follow-up watches every pull request a Paseo workspace opens until the work is a
|
|
|
13
13
|
- Questions from the main agent, each with a permanent ref (Q1, Q2…), lettered options, the agent's recommendation and what it does while it waits. Pick an option, add a note and Send it to the agent, or Copy it instead. Answered questions stay listed under their ref, and the question mode setting (Stop, Work around, Keep building) tells agents what to do until you answer.
|
|
14
14
|
- A Spec link in the header to the page that sums up the workspace, usually the Claude artifact the main agent keeps up to date.
|
|
15
15
|
- An Activity card: repairs sent and finished with how long they took, merges, PR actions and questions.
|
|
16
|
-
- Each stack drawn top to base
|
|
16
|
+
- Each stack drawn top to base, merged PRs folded away, and a sheet per PR with checks, reviewers and Merge.
|
|
17
17
|
- Tasks for work that outlives a merge, manual or scheduled after a merge or deploy, with an optional delay.
|
|
18
18
|
- A composer pill and a sidebar count that appear only when something needs you; the pill steps through open questions so you can answer without leaving the chat. Home lists every workspace by who is up next, and a larger view opens a workspace in two columns.
|
|
19
19
|
- Compact rows for Follow-up's own tool calls in agent chats, a card for each repair batch, and a card when the agent declares Done.
|
|
20
20
|
|
|
21
21
|
## Setup
|
|
22
22
|
|
|
23
|
-
Requires Paseo 0.14+, Node 22+ and an authenticated `gh` on the daemon host. Merge uses saved Graphite CLI authentication. Follow-up follows every workspace that has an agent; Settings has per-project and per-workspace exceptions. The optional Send to Paseo browser companion adds Graphite's Merge when ready switch through its existing pairing; it is not needed for anything else.
|
|
23
|
+
Requires Paseo 0.14+, Node 22+ and an authenticated `gh` on the daemon host. Works with plain GitHub; Graphite is optional and picked per repository (Auto chooses Graphite only where the `gt` CLI is installed, signed in and the repository was set up with `gt init`). In Graphite repositories Merge uses saved Graphite CLI authentication; elsewhere it runs `gh pr merge`, and When ready is GitHub auto-merge. Follow-up follows every workspace that has an agent; Settings has per-project and per-workspace exceptions. The optional Send to Paseo browser companion adds Graphite's Merge when ready switch through its existing pairing; it is not needed for anything else.
|
|
24
24
|
|
|
25
25
|
## What it does on its own, and what it never does
|
|
26
26
|
|
|
@@ -36,6 +36,8 @@ This is a trusted, unsandboxed plugin. It reads workspace metadata, saved agent
|
|
|
36
36
|
|
|
37
37
|
Follow-up reads Paseo's agent, workspace and project lists into one in-memory directory shared by discovery, runtime checks, the Needs-you inbox, the Overseer and every client RPC. It reads the lists once at start, then patches the directory from lifecycle events: turn started or ended, permission requested or resolved, agent created, closed or archived, workspace created or archived. A change marks it dirty, and a dirty directory re-reads at most once a minute; a clean one re-reads every ten minutes. Before anything that would load an agent (a timeline or provider-subagent read), Follow-up re-reads that one agent, because the cached copy may predate Paseo unloading it. Provider subagents are asked about only when a send is due or waiting for acknowledgment, or completion is being checked. The Done label is sent only when it changes. In the app, the panel, the larger view and the pill draw from the client's shared workspace poll, which runs every 15 s plus a refresh shortly after Paseo reports an agent change. The inbox runs the same way and passes the tag of the list it holds, so an unchanged list comes back empty. Display preferences re-read once a minute. None of these poll while the app is hidden.
|
|
38
38
|
|
|
39
|
+
The PR workflow setting lives in `plugin-data/follow-through/pr-workflow.json` (owner-only): the default, per-repository overrides, merge methods and the review-fix instruction. Auto-detection reads only files: PATH for a `gt` executable, `~/.config/graphite/auth` for a sign-in token's presence (never sent anywhere by detection), and `<git dir>/.graphite_repo_config` in the checkout of the repository's Paseo project. It never runs `gt` and caches for ten minutes. Repositories that resolve to GitHub get no Graphite API calls; their readiness, merge method and auto-merge come from the same `gh api graphql` query that already reads each PR, so there is no extra polling. The first start with this setting seeds the review-fix instruction to `/fix-pr` when `~/.claude/commands/fix-pr.md` or `~/.claude/skills/fix-pr/SKILL.md` exists, once.
|
|
40
|
+
|
|
39
41
|
Reviewer lists live in `plugin-data/follow-through/reviewers.json` (owner-only), apart from `state.json`. Each list is per repository, plus a default for repositories without one, and each user keeps their own. Collaborator and team suggestions are read with `gh api` only when you open Add reviewer. They are cached for ten minutes, and never polled.
|
|
40
42
|
|
|
41
43
|
The Needs-you inbox (beta) keeps one flag per root agent in `plugin-data/follow-through/inbox.json`. When a turn starts it reads the newest user message from the agent's recent timeline to tell your messages from automation, and it reads, never writes, Defer's `plugin-data/defer/queue.json`, Smart Session's `plugin-data/smart-session/compactions.json`, Session Guard's `plugin-data/session-guard/state.json` and Paseo's schedule records. An unknown or unreadable format counts as your message, which clears a flag rather than adding one. Signing off also clears Paseo's own unread dot for that agent. The first-run import and the restart check read only Paseo's agent list: an agent's last activity is its unread time or your last message to it, never Paseo's `updatedAt` (which the daemon rewrites in bulk), and they don't fetch timelines, which would load every agent. Closed and archived agents are never imported. Turning the inbox off stops all of this.
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Screenshots use synthetic workspaces and PRs.
|
|
|
20
20
|
paseo plugin install paseo-follow-up
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Needs Node 22+ and an authenticated GitHub CLI (`gh`) on the daemon host.
|
|
23
|
+
Needs Node 22+ and an authenticated GitHub CLI (`gh`) on the daemon host. The installed plugin ID stays `follow-through`, so existing settings and tracked work carry over.
|
|
24
24
|
|
|
25
25
|
## Getting started
|
|
26
26
|
|
|
@@ -44,12 +44,20 @@ The panel shows this workspace only, top to bottom: a **Home** button, the main
|
|
|
44
44
|
|
|
45
45
|
- **Status.** How many PRs have merged, how many things need you, how many PRs need fixing, and a bar with one segment per PR in merge order. Below it, what the agent is doing right now.
|
|
46
46
|
- **Needs you.** One row per decision, each with its button: answer the agent's question, send repairs to the main agent, merge an approved PR, resume after you stopped the agent, or retry a batch that didn't finish.
|
|
47
|
-
- **Pull requests.** Each stack drawn top to base,
|
|
47
|
+
- **Pull requests.** Each stack drawn top to base, with merged PRs folded away.
|
|
48
48
|
- **Tasks.** Work that outlives a merge, such as a production check or a backfill. Tasks wait for you unless you schedule them for after a merge or deploy.
|
|
49
49
|
- **Activity.** What happened and how long it took: repairs sent and finished, merges, merge and reviewer actions, and every question under its ref.
|
|
50
50
|
|
|
51
51
|
The **Spec** chip in the header opens the page that sums up the workspace, usually the Claude artifact the main agent keeps up to date. The agent registers it with a tool call, Follow-up also picks up artifacts the workspace's sessions publish, and you can set, change or remove it under **Spec, agent and recovery**. Your link wins over the agent's, which wins over detection.
|
|
52
52
|
|
|
53
|
+
## Works with GitHub; Graphite optional
|
|
54
|
+
|
|
55
|
+
Follow-up works with plain GitHub out of the box: readiness comes from GitHub itself (its merge state, required checks, reviews, unresolved threads, branch protection and rulesets, and the merge queue if the repository has one), **Merge** runs `gh pr merge` with a merge method the repository allows, and **Auto-merge** is GitHub's own auto-merge. Stacks are chains of base branches: a PR whose base is another PR's branch sits on top of it, a stack merges bottom to top, and after a parent merges Follow-up retargets the child to trunk with `gh pr edit --base` if GitHub didn't already.
|
|
56
|
+
|
|
57
|
+
If you use [Graphite](https://graphite.dev), Follow-up picks it up per repository: **Auto** chooses Graphite where the `gt` CLI is on the daemon's PATH, signed in, and the repository was set up with `gt init`; everywhere else it's GitHub. Detection only looks at files (it never runs `gt`) and is cached for ten minutes. In Graphite repositories, Merge goes through Graphite with your saved CLI sign-in, and Merge when ready works through the Send to Paseo companion (below).
|
|
58
|
+
|
|
59
|
+
Auto is the default for every repository. Agents get instructions for the workflow their workspace uses, so a GitHub workspace never hears about Graphite, and they address review comments with Follow-up's built-in steps (read the unresolved threads with `gh`, fix, push, reply and resolve) unless an install already had a `/fix-pr` command or skill in `~/.claude`, which it keeps using.
|
|
60
|
+
|
|
53
61
|

|
|
54
62
|
|
|
55
63
|
### Questions
|
|
@@ -197,7 +205,7 @@ The choices live in `agents.json` in Follow-up's data folder. Anything missing o
|
|
|
197
205
|
Install the beta:
|
|
198
206
|
|
|
199
207
|
```sh
|
|
200
|
-
paseo plugin update follow-through --version 1.4.0-beta.
|
|
208
|
+
paseo plugin update follow-through --version 1.4.0-beta.18
|
|
201
209
|
# or, for a fresh install:
|
|
202
210
|
paseo plugin install npm:paseo-follow-up@beta
|
|
203
211
|
```
|
|
@@ -236,11 +244,11 @@ Tools that act on a list, and merge, return a dry run first and act only when ca
|
|
|
236
244
|
|
|
237
245
|
## Send to Paseo and Graphite
|
|
238
246
|
|
|
239
|
-
With [Send to Paseo](https://github.com/tomgrin10/send-to-paseo) on the same daemon, its composer picks the agent that registered the PR.
|
|
247
|
+
With [Send to Paseo](https://github.com/tomgrin10/send-to-paseo) on the same daemon, its composer picks the agent that registered the PR. In Graphite repositories, with Send to Paseo 2.2+, Follow-up can also toggle Graphite's **Merge when ready** through your existing pairing, while Graphite is open and signed in. Each change is confirmed in Chrome, which can remember the permission per repository. With the next Send to Paseo release, its popover on a PR page also shows which tracked workspaces own the PR, with Follow-up's one line for each (for example "Needs you · Merge ready"), and opens the workspace's main agent in the Paseo app or web app. See the [integration and security contract](https://github.com/tomgrin10/send-to-paseo/blob/main/docs/follow-up-integration.md).
|
|
240
248
|
|
|
241
249
|
## Data and access
|
|
242
250
|
|
|
243
|
-
Paseo plugins run trusted, unsandboxed code on the daemon host. Follow-up reads workspace metadata, agent history and GitHub PR status with your existing credentials, and keeps its state in `$PASEO_HOME/plugin-data/follow-through`. It registers scoped MCP tools and reversible provider hooks only for tracked sessions, plus the action tools for root agents (above). GitHub and Graphite writes happen only after an explicit click, or a root agent's confirmed plan, and a fresh eligibility check.
|
|
251
|
+
Paseo plugins run trusted, unsandboxed code on the daemon host. Follow-up reads workspace metadata, agent history and GitHub PR status with your existing credentials, and keeps its state in `$PASEO_HOME/plugin-data/follow-through`. It registers scoped MCP tools and reversible provider hooks only for tracked sessions, plus the action tools for root agents (above). GitHub (and, in Graphite repositories, Graphite) writes happen only after an explicit click, or a root agent's confirmed plan, and a fresh eligibility check.
|
|
244
252
|
|
|
245
253
|
## Development
|
|
246
254
|
|
package/client/panel.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, type ReactNode } from "react";
|
|
2
2
|
import { ScrollView, Text, View } from "react-native";
|
|
3
3
|
import { Icon, useToast } from "@getpaseo/plugin/client/ui";
|
|
4
|
-
import { useRpc, useTabState, openExternalUrl, type PluginHostProps, type PluginWorkspacePanelProps } from "@getpaseo/plugin/client";
|
|
4
|
+
import { useAgent, useRpc, useTabState, openExternalUrl, type PluginHostProps, type PluginWorkspacePanelProps } from "@getpaseo/plugin/client";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import type { InboxStore } from "./inbox-store";
|
|
7
7
|
import { useInbox } from "./inbox";
|
|
@@ -186,10 +186,12 @@ function WorkspaceCard({ workspace: w, theme, compact, open, toggle, openAgent,
|
|
|
186
186
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
|
|
187
187
|
<View style={{ flex: 1, minWidth: 160, gap: 2 }}>
|
|
188
188
|
<Text style={t.label}>Main agent</Text>
|
|
189
|
+
<MainAgentName agentId={w.mainAgentId} theme={theme} />
|
|
189
190
|
<Text style={t.meta}>Owns the PRs, tasks and the Done call. Repairs go here.</Text>
|
|
190
191
|
</View>
|
|
191
192
|
{openAgent && <Button theme={theme} compact={compact} icon="MessageSquare" title="Open" accessibilityLabel="Open main agent" onPress={() => openAgent(w.mainAgentId)} />}
|
|
192
193
|
</View>
|
|
194
|
+
{(w.contributorAgentIds ?? []).map(id => <OtherRootAgent key={id} agentId={id} workspace={w} theme={theme} compact={compact} openAgent={openAgent} mainAgentId={w.mainAgentId} />)}
|
|
193
195
|
</CardRow>
|
|
194
196
|
<CardRow theme={theme}>
|
|
195
197
|
<View style={{ gap: 8 }}>
|
|
@@ -208,7 +210,8 @@ function WorkspaceCard({ workspace: w, theme, compact, open, toggle, openAgent,
|
|
|
208
210
|
</View>
|
|
209
211
|
</View>
|
|
210
212
|
</CardRow>
|
|
211
|
-
{
|
|
213
|
+
{/* Graphite's merge-when-ready needs the browser companion; GitHub repositories use auto-merge and never see this. */}
|
|
214
|
+
{active && browserReady === false && w.prs.some(p => !settledForDisplay(p) && p.snapshot && p.snapshot.prWorkflow !== "github") && <CardRow theme={theme}>
|
|
212
215
|
<View style={{ gap: 8 }}>
|
|
213
216
|
<View style={{ gap: 2 }}>
|
|
214
217
|
<Text style={t.label}>Merge when ready</Text>
|
|
@@ -221,6 +224,43 @@ function WorkspaceCard({ workspace: w, theme, compact, open, toggle, openAgent,
|
|
|
221
224
|
</View>;
|
|
222
225
|
}
|
|
223
226
|
|
|
227
|
+
/** An agent's title from Paseo's client state (no fetch), or a short id while it loads or once it's gone. */
|
|
228
|
+
function useAgentTitle(agentId: string): string {
|
|
229
|
+
return useAgent(agentId, a => a.title) || `Agent ${agentId.slice(0, 8)}`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function MainAgentName({ agentId, theme }: { agentId: string; theme: Theme }) {
|
|
233
|
+
const t = text(theme.colors);
|
|
234
|
+
return <Text numberOfLines={1} style={[t.meta, { color: theme.colors.foreground }]}>{useAgentTitle(agentId)}</Text>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Another root agent in this workspace: it can contribute PRs but not ask Tom or call Done. "Make main agent" is
|
|
239
|
+
* the developer's choice (a plugin RPC, never an agent tool). It swaps roles, so the former main appears here with
|
|
240
|
+
* its own Make main agent: that is the undo, and the toast says so instead of a confirmation step.
|
|
241
|
+
*/
|
|
242
|
+
function OtherRootAgent({ agentId, mainAgentId, workspace: w, theme, compact, openAgent }: { agentId: string; mainAgentId: string; workspace: Workspace; theme: Theme; compact: boolean; openAgent?: (id: string) => void }) {
|
|
243
|
+
const c = theme.colors; const t = text(c);
|
|
244
|
+
const title = useAgentTitle(agentId); const formerTitle = useAgentTitle(mainAgentId);
|
|
245
|
+
const control = useRpc(controlRpc); const cache = useQueryClient(); const toast = useToast();
|
|
246
|
+
const promote = useMutation({
|
|
247
|
+
mutationFn: () => control({ workspaceId: w.id, mainAgentId: agentId }),
|
|
248
|
+
onSuccess: () => { void cache.invalidateQueries({ queryKey: workspaceKey(w.id) }); void cache.invalidateQueries({ queryKey: overviewKey }); toast.show(`${title} is now the main agent. To undo, make ${formerTitle} main again.`, { variant: "success" }); },
|
|
249
|
+
onError: (e: Error) => toast.error(errorText(e)),
|
|
250
|
+
});
|
|
251
|
+
const canPromote = w.enable_tracking && !w.archived;
|
|
252
|
+
return <View style={{ gap: 8, marginTop: 10, paddingTop: 10, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
253
|
+
<View style={{ gap: 2 }}>
|
|
254
|
+
<Text numberOfLines={1} style={[t.meta, { color: c.foreground }]}>{title}</Text>
|
|
255
|
+
<Text style={t.meta}>Can add PRs here. Can't ask you questions or call Done.</Text>
|
|
256
|
+
</View>
|
|
257
|
+
{(openAgent || canPromote) && <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
|
|
258
|
+
{canPromote && <Button theme={theme} compact={compact} title="Make main agent" accessibilityLabel={`Make ${title} the main agent`} accessibilityHint={`Repairs, questions and Done move from ${formerTitle} to ${title}.`} loading={promote.isPending} disabled={promote.isPending} onPress={() => promote.mutate()} />}
|
|
259
|
+
{openAgent && <Button theme={theme} compact={compact} kind="ghost" icon="MessageSquare" title="Open" accessibilityLabel={`Open ${title}`} onPress={() => openAgent(agentId)} />}
|
|
260
|
+
</View>}
|
|
261
|
+
</View>;
|
|
262
|
+
}
|
|
263
|
+
|
|
224
264
|
function historyLabel(w: Workspace): string {
|
|
225
265
|
const stacks = new Set(w.prs.map(p => p.stack)).size;
|
|
226
266
|
const tasks = followUpObligations(w).filter(o => ["done", "waived"].includes(o.status)).length;
|
package/client/pr-controls.tsx
CHANGED
|
@@ -4,22 +4,30 @@ import { useRpc } from "@getpaseo/plugin/client";
|
|
|
4
4
|
import { Icon, useToast } from "@getpaseo/plugin/client/ui";
|
|
5
5
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { confirmPrActionRpc, preparePrActionRpc, prControlStatusRpc, requestReviewersRpc } from "../shared/contracts";
|
|
7
|
-
import { mergeBlockers, prActionBlocks, type ActionPlan, type PrActionKind } from "../shared/pr-actions";
|
|
7
|
+
import { isGithubFlow, mergeBlockers, prActionBlocks, type ActionPlan, type PrActionKind } from "../shared/pr-actions";
|
|
8
|
+
import type { MergeMethod } from "../shared/pr-workflow";
|
|
8
9
|
import { mergeQueued, mergeReady } from "../shared/attention";
|
|
9
10
|
import type { Pr, Workspace } from "../shared/model";
|
|
10
11
|
import { Button, Switch, errorText, text, type Theme } from "./kit";
|
|
11
12
|
import { noReviewers, resolveReviewers, withoutAuthor, type ReviewerEntry } from "../shared/reviewers";
|
|
12
13
|
import { ReviewerPicker, reviewerSettingsKey, useReviewerSettings, willAsk } from "./reviewers";
|
|
13
14
|
|
|
15
|
+
const METHOD_SENTENCE: Record<MergeMethod, string> = { squash: "squash and merge it", merge: "merge it with a merge commit", rebase: "rebase and merge it" };
|
|
16
|
+
/** Blockers read as nouns after "clears:"; proper names (GitHub, Graphite) keep their capital. */
|
|
17
|
+
const lowerFirst = (b: string) => /^(GitHub|Graphite)\b/.test(b) ? b : b[0].toLowerCase() + b.slice(1);
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Merge, merge-when-ready and reviewer requests for one PR. Every write needs a click; Merge always
|
|
16
|
-
* prepares a fresh plan and asks again before anything reaches Graphite.
|
|
21
|
+
* prepares a fresh plan and asks again before anything reaches Graphite or GitHub. In GitHub mode When ready is
|
|
22
|
+
* GitHub's auto-merge, read with the PR, so it needs no browser companion; it's hidden when the repository disallows it.
|
|
17
23
|
*/
|
|
18
|
-
export function PrControls({ pr, workspace, theme, compact, browserReady, intent }: { browserReady: boolean; pr: Pr; workspace: Workspace; theme: Theme; compact: boolean; intent?: "merge" | "reviewers" | null }) {
|
|
24
|
+
export function PrControls({ pr, workspace, theme, compact, browserReady: companionReady, intent }: { browserReady: boolean; pr: Pr; workspace: Workspace; theme: Theme; compact: boolean; intent?: "merge" | "reviewers" | null }) {
|
|
19
25
|
const read = useRpc(prControlStatusRpc); const prepare = useRpc(preparePrActionRpc); const confirm = useRpc(confirmPrActionRpc); const cache = useQueryClient();
|
|
20
26
|
const requestReviewers = useRpc(requestReviewersRpc);
|
|
21
27
|
const toast = useToast();
|
|
22
28
|
const c = theme.colors; const t = text(c);
|
|
29
|
+
const github = isGithubFlow(pr.snapshot);
|
|
30
|
+
const browserReady = github ? !!pr.snapshot?.repoMerge?.autoMerge : companionReady;
|
|
23
31
|
const [plan, setPlan] = useState<ActionPlan | null>(null); const [notice, setNotice] = useState<string | null>(null);
|
|
24
32
|
const statusKey = ["follow-through", "pr-controls", workspace.id, pr.key, pr.snapshot?.head];
|
|
25
33
|
const status = useQuery({ queryKey: statusKey, queryFn: () => read({ workspaceId: workspace.id, prKey: pr.key }), refetchInterval: 10_000, enabled: browserReady });
|
|
@@ -57,7 +65,10 @@ export function PrControls({ pr, workspace, theme, compact, browserReady, intent
|
|
|
57
65
|
const loaded = !!reviewerSettings.data;
|
|
58
66
|
useEffect(() => { if (intent === "reviewers" && loaded && missingReviewers && !pr.snapshot?.draft && !reviewers.length) setPicking(true); }, [intent, loaded]);
|
|
59
67
|
if (pr.snapshot?.state !== "OPEN") return null;
|
|
60
|
-
const waitingFor = mergeBlockers(pr).filter(b => !b.startsWith("Graphite "));
|
|
68
|
+
const waitingFor = mergeBlockers(pr).filter(b => !b.startsWith("Graphite ")).map(lowerFirst);
|
|
69
|
+
// GitHub refuses auto-merge on a PR it can already merge, so the switch shows only while Merge is waiting, or to turn it off.
|
|
70
|
+
const showSwitch = browserReady && (!github || !canMerge || !!enabled);
|
|
71
|
+
const autoMergeOff = github && !!pr.snapshot?.repoMerge && !pr.snapshot.repoMerge.autoMerge && !canMerge && !queued;
|
|
61
72
|
return <View style={{ gap: 10 }}>
|
|
62
73
|
{missingReviewers && <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: 8 }}>
|
|
63
74
|
<Icon name="UserX" size={14} color={c.statusWarning} />
|
|
@@ -71,15 +82,16 @@ export function PrControls({ pr, workspace, theme, compact, browserReady, intent
|
|
|
71
82
|
onCancel={() => setPicking(false)} onRequest={(picked, remember) => reviewRequest.mutate({ picked, remember })} />}
|
|
72
83
|
{!plan && <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: 12 }}>
|
|
73
84
|
{(canMerge || queued || recentlySubmitted || busy) ? <Button title={busy ? checking.isPending ? "Checking…" : "Submitting…" : queued ? "Queued to merge" : recentlySubmitted ? "Submitted" : `Merge #${pr.number}`} icon={queued ? "Clock" : "GitMerge"} theme={theme} compact={compact} kind={canMerge ? "primary" : "secondary"} loading={busy} disabled={disabled || !canMerge} onPress={() => begin("merge")} />
|
|
74
|
-
: <Text style={[t.meta, { flex: 1 }]}>{waitingFor.length ? `Merge opens when it clears: ${waitingFor.join(", ")
|
|
75
|
-
{
|
|
85
|
+
: <Text style={[t.meta, { flex: 1 }]}>{waitingFor.length ? `Merge opens when it clears: ${waitingFor.join(", ")}.` : github ? "Waiting for GitHub to confirm it can merge." : "Waiting for Graphite to report it ready to merge."}</Text>}
|
|
86
|
+
{showSwitch && <Switch theme={theme} compact={compact} label={`${github ? "Auto-merge" : "When ready"}${known ? "" : " · unknown"}`} accessibilityLabel={`${github ? "Auto-merge" : "Merge when ready"} for ${pr.repo} pull request ${pr.number}`} value={known ? !!enabled : null} disabled={disabled} onChange={() => begin(enabled ? "disable_mwr" : "enable_mwr")} />}
|
|
76
87
|
</View>}
|
|
88
|
+
{!plan && autoMergeOff && <Text style={t.meta}>Auto-merge is off for this repository. Turn on Allow auto-merge in its GitHub settings.</Text>}
|
|
77
89
|
{error && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{error}</Text>}
|
|
78
90
|
{notice && <Text accessibilityLiveRegion="polite" style={t.meta}>{notice}</Text>}
|
|
79
91
|
{plan && (plan.kind === "merge" || browserReady) && <View accessibilityRole="summary" style={{ gap: 8 }}>
|
|
80
92
|
<Text accessibilityRole="header" style={[t.label, { fontSize: 14, lineHeight: 20 }]}>{plan.kind === "merge" ? plan.prs.length > 1 ? "Merge the PRs underneath too?" : "Merge this PR?" : `${plan.kind === "enable_mwr" ? "Enable" : "Disable"} for downstack too?`}</Text>
|
|
81
|
-
<Text style={t.meta}>{plan.kind === "merge" ? plan.prs.length > 1 ? `#${pr.number} depends on ${plan.prs.length - 1} unmerged PR${plan.prs.length === 2 ? "" : "s"}. Merge these ${plan.prs.length} PRs in order:` : "Graphite will merge using this repository’s settings and required protections." : `Change merge when ready for #${pr.number} only, or for all ${plan.prs.length} listed PRs.`}</Text>
|
|
82
|
-
{plan.prs.map((p, i) => <View key={p.key} style={{ flexDirection: "row", gap: 8 }}>
|
|
93
|
+
<Text style={t.meta}>{plan.kind === "merge" ? plan.prs.length > 1 ? `#${pr.number} depends on ${plan.prs.length - 1} unmerged PR${plan.prs.length === 2 ? "" : "s"}. ${plan.mergeQueue ? `This repository merges through a merge queue, so #${plan.prs[0].number} goes in first; merge the next one after it lands:` : `Merge these ${plan.prs.length} PRs in order:`}` : plan.via === "github" ? plan.mergeQueue ? "GitHub adds it to this repository’s merge queue, which merges it once its checks pass." : `GitHub will ${METHOD_SENTENCE[plan.method ?? "squash"]} once this repository’s required protections pass.` : "Graphite will merge using this repository’s settings and required protections." : `Change ${plan.via === "github" ? "auto-merge" : "merge when ready"} for #${pr.number} only, or for all ${plan.prs.length} listed PRs.`}</Text>
|
|
94
|
+
{(plan.via !== "github" || plan.prs.length > 1 || plan.prs.some(p => p.blockers.length > 0)) && plan.prs.map((p, i) => <View key={p.key} style={{ flexDirection: "row", gap: 8 }}>
|
|
83
95
|
<Text style={[t.meta, { width: 16, textAlign: "right", fontVariant: ["tabular-nums"] }]}>{i + 1}.</Text>
|
|
84
96
|
<View style={{ flex: 1, gap: 2 }}>
|
|
85
97
|
<Text style={[t.body, { fontSize: 12, lineHeight: 17 }]}>#{p.number} · {p.title}</Text>
|
|
@@ -88,7 +100,7 @@ export function PrControls({ pr, workspace, theme, compact, browserReady, intent
|
|
|
88
100
|
</View>)}
|
|
89
101
|
{plan.blockers.map(blocker => <Text key={blocker} style={[t.meta, { color: c.statusWarning }]}>{blocker}</Text>)}
|
|
90
102
|
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8, marginTop: 2 }}>
|
|
91
|
-
<Button title={plan.kind === "merge" ? plan.prs.length > 1 ? `Merge all ${plan.prs.length} PRs` : `Merge #${pr.number}` : `${plan.kind === "enable_mwr" ? "Enable" : "Disable"} for all ${plan.prs.length} PRs`} kind="primary" theme={theme} compact={compact} loading={submit.isPending} disabled={submit.isPending || scopeBlocked("downstack")} onPress={() => act("downstack")} />
|
|
103
|
+
<Button title={plan.kind === "merge" ? plan.mergeQueue ? `Add #${plan.prs[0].number} to merge queue` : plan.prs.length > 1 ? `Merge all ${plan.prs.length} PRs` : `Merge #${pr.number}` : `${plan.kind === "enable_mwr" ? "Enable" : "Disable"} for all ${plan.prs.length} PRs`} kind="primary" theme={theme} compact={compact} loading={submit.isPending} disabled={submit.isPending || scopeBlocked("downstack")} onPress={() => act("downstack")} />
|
|
92
104
|
{plan.kind !== "merge" && plan.prs.length > 1 && <Button title="Just this PR" theme={theme} compact={compact} disabled={submit.isPending || scopeBlocked("target")} onPress={() => act("target")} />}
|
|
93
105
|
<Button title="Cancel" kind="ghost" theme={theme} compact={compact} disabled={submit.isPending} onPress={() => { setPlan(null); checking.reset(); submit.reset(); }} />
|
|
94
106
|
</View>
|
package/client/pr-sheet.tsx
CHANGED
|
@@ -54,8 +54,9 @@ export function PrSheet({ workspace: w, prKey, intent, theme, compact, browserRe
|
|
|
54
54
|
<PrControls key={`${pr.key}:${intent ?? ""}`} pr={pr} workspace={w} theme={theme} compact={compact} browserReady={browserReady} intent={intent} />
|
|
55
55
|
</View>}
|
|
56
56
|
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8, paddingTop: 12, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
57
|
-
<Button theme={theme} compact={compact} icon="ExternalLink" title="Open in Graphite" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} in Graphite`} onPress={() => open(graphitePrUrl(pr))} />
|
|
58
|
-
{s?.url && <Button theme={theme} compact={compact}
|
|
57
|
+
{s?.prWorkflow !== "github" && <Button theme={theme} compact={compact} icon="ExternalLink" title="Open in Graphite" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} in Graphite`} onPress={() => open(graphitePrUrl(pr))} />}
|
|
58
|
+
{s?.url && s.prWorkflow === "github" && <Button theme={theme} compact={compact} icon="ExternalLink" title="Open on GitHub" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} on GitHub`} onPress={() => open(s.url)} />}
|
|
59
|
+
{s?.url && s.prWorkflow !== "github" && <Button theme={theme} compact={compact} kind="ghost" icon="Github" title="GitHub" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} on GitHub`} onPress={() => open(s.url)} />}
|
|
59
60
|
</View>
|
|
60
61
|
</>}
|
|
61
62
|
</Modal.Content>
|
package/client/stacks.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import type { Pr, Workspace } from "../shared/model";
|
|
|
4
4
|
import { compactPrStatus, orderedStacks, settledForDisplay } from "../shared/presentation";
|
|
5
5
|
import { mergeQueued, prTone, stackOrder } from "../shared/attention";
|
|
6
6
|
import { noReviewers } from "../shared/reviewers";
|
|
7
|
+
import { isGithubFlow } from "../shared/pr-actions";
|
|
7
8
|
import { Card, FoldRow, text, type Theme } from "./kit";
|
|
8
9
|
import { Spinner } from "./motion";
|
|
9
10
|
import { mergedColor, tint, toneColor, type Colors } from "./theme";
|
|
@@ -38,7 +39,7 @@ export function PrRow({ pr, theme, first, last, showRepo, onOpen, compact, wide
|
|
|
38
39
|
const line = c.border;
|
|
39
40
|
const extras = [
|
|
40
41
|
s?.state === "OPEN" && noReviewers(pr) ? "No reviewers" : null,
|
|
41
|
-
s?.state === "OPEN" && s.mergeWhenReady === "on" && !mergeQueued(pr) ? "Merge when ready" : null,
|
|
42
|
+
s?.state === "OPEN" && s.mergeWhenReady === "on" && !mergeQueued(pr) ? isGithubFlow(s) ? "Auto-merge" : "Merge when ready" : null,
|
|
42
43
|
].filter(Boolean) as string[];
|
|
43
44
|
return <Pressable accessibilityRole="button" accessibilityLabel={`Pull request ${pr.number}: ${s?.title ?? pr.stack}. ${label}. Open details`} onPress={() => onOpen(pr.key)}
|
|
44
45
|
style={state => ({ flexDirection: "row", gap: 10, paddingHorizontal: 12, minHeight: compact ? 52 : 44, backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
|
|
@@ -112,7 +113,7 @@ export function StacksCard({ workspace: w, theme, compact, open, toggle, onOpen,
|
|
|
112
113
|
return <Card theme={theme} compact={compact} icon="GitPullRequest" title="Pull requests" count={openCount ? `${openCount} open` : undefined}>
|
|
113
114
|
{inFlight.map(a => <View key={a.id} style={{ flexDirection: "row", gap: 8, paddingHorizontal: 12, paddingVertical: 8, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
114
115
|
<View style={{ paddingTop: 3 }}><Spinner color={c.accent} size={12} /></View>
|
|
115
|
-
<Text style={[t.meta, { flex: 1, color: c.foreground }]}>{a.result || "Submitting to Graphite…"}</Text>
|
|
116
|
+
<Text style={[t.meta, { flex: 1, color: c.foreground }]}>{a.result || (isGithubFlow(w.prs.find(p => p.key === a.prs[0])?.snapshot) ? "Sending to GitHub…" : "Submitting to Graphite…")}</Text>
|
|
116
117
|
</View>)}
|
|
117
118
|
{!w.prs.length && <View style={{ paddingHorizontal: 12, paddingVertical: 10, borderTopWidth: 1, borderTopColor: c.border, gap: 4 }}>
|
|
118
119
|
<Text style={t.body}>No PRs yet</Text>
|
package/index.server.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { AgentActions, AGENT_TOOLS, controlWorkspace, type AgentTool } from "./s
|
|
|
25
25
|
import { PaseoGateway, paseoHome, clientEntry, closeConnections, sessionGuardOwnsInterruption } from "./server/daemon";
|
|
26
26
|
import { mcpSource } from "./server/mcp-source";
|
|
27
27
|
import { excludeStack } from "./server/exclusions";
|
|
28
|
-
import { applyHistory, applyDiscovery, extractHistory } from "./server/discovery";
|
|
28
|
+
import { applyHistory, applyDiscovery, extractHistory, markMainWork } from "./server/discovery";
|
|
29
29
|
import { lifecycleOnly, recoveryBatch } from "./shared/follow-up";
|
|
30
30
|
import { Deployments } from "./server/deployments";
|
|
31
31
|
import { AgentHooks } from "./server/agent-hooks";
|
|
@@ -43,7 +43,10 @@ import { copyFile, readFile, rename, stat } from "node:fs/promises";
|
|
|
43
43
|
import { HistoryCache } from "./server/history-cache";
|
|
44
44
|
import { Governor } from "./server/governor";
|
|
45
45
|
import { ListCache } from "./server/list-cache";
|
|
46
|
-
import { scopeWriter } from "./server/scopes";
|
|
46
|
+
import { scopeWriter, workflowSummary } from "./server/scopes";
|
|
47
|
+
import { PrWorkflowStore } from "./server/pr-workflow";
|
|
48
|
+
import { commandName } from "./shared/pr-workflow";
|
|
49
|
+
import { projectRepo } from "./server/daemon";
|
|
47
50
|
import { batchArchive, pruneUnsent } from "./server/batch-archive";
|
|
48
51
|
import { NO_USAGE } from "./shared/usage";
|
|
49
52
|
import { activeWindowMs, conversationGone, DEFAULT_ACTIVE_WINDOW_DAYS } from "./server/agent-load";
|
|
@@ -63,6 +66,9 @@ import { OnboardingStore, ReadinessChecks, nativeAgentCount } from "./server/onb
|
|
|
63
66
|
import { execFile } from "node:child_process";
|
|
64
67
|
import { BRIEF_KIND, BRIEF_VERSION, prState, validateNeedsYou, type Brief, type NeedsYouRecord } from "./shared/brief";
|
|
65
68
|
|
|
69
|
+
/** Agent calls that only the main agent makes: one of these from a successor means the handover is in use. */
|
|
70
|
+
const MAIN_WORK = new Set(["follow.sync", "follow.register-pr", "follow.obligation", "follow.done", "follow.acknowledge", "follow.exclude-stack", "follow.ask-question", "follow.record-answer", "follow.withdraw-question", "follow.set-spec", "follow.needs-you"]);
|
|
71
|
+
|
|
66
72
|
export default function contribute(server: PluginServerContext) {
|
|
67
73
|
const displaySettings = server.registerSettings(displayPreferences);
|
|
68
74
|
const questionSettings = server.registerSettings(questionPreferences);
|
|
@@ -84,10 +90,24 @@ export default function contribute(server: PluginServerContext) {
|
|
|
84
90
|
} catch { /* Without it the hook assumes the tools are attached, as before. */ }
|
|
85
91
|
// Every RPC handler, also callable in-process: native agent tools run the same handlers the stdio bridge reaches.
|
|
86
92
|
const handlers = new Map<string, { input: { parseAsync(value: unknown): Promise<unknown> }; run: (input: any, context: PluginHandlerContext) => unknown }>();
|
|
87
|
-
const handle: PluginServerContext["handle"] = (contract, handler) => {
|
|
93
|
+
const handle: PluginServerContext["handle"] = (contract, handler) => {
|
|
94
|
+
// Main-agent work by a successor makes its handover stick (see handBackMainAgent): noted after the call succeeds.
|
|
95
|
+
const run = MAIN_WORK.has(contract.name) ? (async (input: { agentId?: string }, context: PluginHandlerContext) => { const out = await (handler as (i: unknown, c: PluginHandlerContext) => unknown)(input, context); if (input?.agentId) await noteMainWork(input.agentId).catch(() => undefined); return out; }) as typeof handler : handler;
|
|
96
|
+
handlers.set(contract.name, { input: contract.input, run: run as never }); server.handle(contract, run);
|
|
97
|
+
};
|
|
98
|
+
const noteMainWork = async (agentId: string) => {
|
|
99
|
+
// A cheap check on the snapshot first: almost every call has no open handover, so nothing is written.
|
|
100
|
+
if (!(await store.snapshot()).workspaces.some(w => w.mainAgentId === agentId && w.handover && !w.handover.worked)) return;
|
|
101
|
+
await store.mutate(state => { markMainWork(state, agentId); });
|
|
102
|
+
};
|
|
88
103
|
const store = new Store(directory, 1_000);
|
|
89
104
|
const onboarding = new OnboardingStore(directory);
|
|
90
|
-
|
|
105
|
+
// PR workflow (Graphite or plain GitHub) per repository; scopes.json carries each agent's so its instructions match.
|
|
106
|
+
const prWorkflow = new PrWorkflowStore(directory);
|
|
107
|
+
let workspaceRepos: Map<string, string> = new Map();
|
|
108
|
+
const workspaceRepo = (w: Workspace): string | null => (w.prs.find(p => p.snapshot?.state === "OPEN") ?? w.prs.at(-1))?.repo ?? workspaceRepos.get(w.id) ?? null;
|
|
109
|
+
const knownRepos = (state: { workspaces: Workspace[] }) => new Set([...state.workspaces.filter(w => w.enable_tracking && !w.archived).flatMap(w => w.prs.map(p => repoKey(p.repo))), ...[...workspaceRepos.values()].map(repoKey)]);
|
|
110
|
+
store.onChanged = scopeWriter(directory, { agent: w => prWorkflow.agentWorkflow(workspaceRepo(w)), summary: state => workflowSummary([...knownRepos(state)].map(r => prWorkflow.cachedWorkflow(r))) });
|
|
91
111
|
const agentHooks = new AgentHooks(directory, clientEntry());
|
|
92
112
|
const historyCache = HistoryCache.at(directory);
|
|
93
113
|
const gateway = new PaseoGateway(undefined, undefined, undefined, historyCache);
|
|
@@ -96,11 +116,21 @@ export default function contribute(server: PluginServerContext) {
|
|
|
96
116
|
gateway.recoveryRole = () => agentSettings.role("recovery");
|
|
97
117
|
const graphite = new Graphite();
|
|
98
118
|
const github = new Github(undefined, graphite, new Deployments());
|
|
119
|
+
github.workflow = repo => prWorkflow.workflow(repo);
|
|
120
|
+
workspaceRepos = gateway.workspaceRepos;
|
|
121
|
+
prWorkflow.paths = async () => {
|
|
122
|
+
const paths = new Map<string, string>();
|
|
123
|
+
for (const p of await gateway.projects(await store.snapshot())) { const repo = projectRepo(p.key); if (repo && p.path && !paths.has(repoKey(repo))) paths.set(repoKey(repo), p.path); }
|
|
124
|
+
return paths;
|
|
125
|
+
};
|
|
126
|
+
prWorkflow.onChanged = () => { void store.snapshot().then(state => store.onChanged(state)).catch(() => undefined); };
|
|
99
127
|
const browser = new BrowserBridge();
|
|
100
128
|
const reviewerStore = new ReviewerConfigStore(directory);
|
|
101
129
|
const reviewerSuggestions = new ReviewerSuggestions();
|
|
102
130
|
const actions = new PrActions(store, github, graphite, browser);
|
|
131
|
+
actions.savedMethod = repo => prWorkflow.current().repos[repoKey(repo)]?.mergeMethod ?? null;
|
|
103
132
|
const engine = new Engine(store, github, gateway);
|
|
133
|
+
engine.wording = { reviewFix: repo => commandName(prWorkflow.reviewFix(repo)) };
|
|
104
134
|
const governor = new Governor();
|
|
105
135
|
const listCache = new ListCache();
|
|
106
136
|
engine.paused = () => !governor.allowsBackground();
|
|
@@ -236,6 +266,9 @@ export default function contribute(server: PluginServerContext) {
|
|
|
236
266
|
await backupActiveScope();
|
|
237
267
|
// Reviewers: the one-time seed from earlier requests, before history is pruned. An unreadable reviewers.json only affects Add reviewers.
|
|
238
268
|
await reviewerStore.migrate(await store.snapshot()).catch(() => undefined);
|
|
269
|
+
// PR workflow: the one-time /fix-pr seed, then resolve every known repository (filesystem checks only, never gt).
|
|
270
|
+
await prWorkflow.migrate().catch(() => undefined);
|
|
271
|
+
await prWorkflow.warm(knownRepos(await store.snapshot())).catch(() => undefined);
|
|
239
272
|
await pruneHistory();
|
|
240
273
|
await store.onChanged(await store.snapshot()).catch(() => undefined);
|
|
241
274
|
hooksStarted = true;
|
|
@@ -263,7 +296,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
263
296
|
const flags = { recovery, brief: !!brief && !recovery, root: root && !recovery, overseer: overseer && !recovery };
|
|
264
297
|
const env = { ...request.env, FOLLOW_THROUGH_TOOLS: "native", FOLLOW_THROUGH_PROVIDER: request.provider, ...(flags.root ? { FOLLOW_THROUGH_ROOT: "1" } : {}), ...(flags.overseer ? { FOLLOW_THROUGH_OVERSEER: "1" } : {}) };
|
|
265
298
|
if (/^[\w-]+$/.test(request.agentId)) await writeFile(join(directory, "hook-state", `native-${request.agentId}.json`), JSON.stringify({ instance: toolsInstance }), { mode: 0o600 }).catch(() => undefined);
|
|
266
|
-
return { ...request, env, tools: [...request.tools, ...nativeTools(flags, live, invoke)] };
|
|
299
|
+
return { ...request, env, tools: [...request.tools, ...nativeTools(flags, live, invoke, workflowSummary([...knownRepos(await store.snapshot())].map(r => prWorkflow.cachedWorkflow(r))))] };
|
|
267
300
|
}
|
|
268
301
|
return withSessionMcp({ ...request, env: { ...request.env, FOLLOW_THROUGH_TOOLS: "stdio", FOLLOW_THROUGH_PROVIDER: request.provider } }, directory, clientEntry(), paseoHome, recovery, process.env, brief, root, overseer, providers) as R;
|
|
269
302
|
};
|
|
@@ -372,7 +405,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
372
405
|
await agentHooks.confirm(w.id, agentId, summary);
|
|
373
406
|
return { workspaceId: w.id, synced: true as const };
|
|
374
407
|
});
|
|
375
|
-
handle(rpc.agentStatusRpc, async ({ agentId }, { paseo }) => { await requireReady(); const workspaceId = await callerWorkspaceId(agentId, paseo);
|
|
408
|
+
handle(rpc.agentStatusRpc, async ({ agentId }, { paseo }) => { await requireReady(); const workspaceId = await callerWorkspaceId(agentId, paseo); const w = agentWorkspace(await store.snapshot(), agentId, "read", workspaceId, "pr"); return { ...w, prWorkflow: prWorkflow.agentWorkflow(workspaceRepo(w)) }; });
|
|
376
409
|
handle(rpc.activateRpc, async ({ workspaceId }) => { await requireReady(); return engine.activate(workspaceId); });
|
|
377
410
|
handle(rpc.sendRpc, async ({ workspaceId, batchId }) => { await requireReady(); return engine.sendPending(workspaceId, batchId); });
|
|
378
411
|
handle(rpc.recoverRpc, async ({ workspaceId }) => { await requireReady(); return engine.startRecovery(workspaceId); });
|
|
@@ -553,6 +586,34 @@ export default function contribute(server: PluginServerContext) {
|
|
|
553
586
|
for (const w of (await store.snapshot()).workspaces) for (const p of w.prs) seen.add(repoKey(p.repo));
|
|
554
587
|
return { config, repos: [...seen].sort() };
|
|
555
588
|
};
|
|
589
|
+
const prWorkflowRepos = async () => {
|
|
590
|
+
const repos = new Set((await reviewerSettings()).repos);
|
|
591
|
+
for (const p of await gateway.projects(await store.snapshot()).catch(() => [])) { const repo = projectRepo(p.key); if (repo) repos.add(repoKey(repo)); }
|
|
592
|
+
for (const repo of Object.keys(prWorkflow.current().repos)) repos.add(repo);
|
|
593
|
+
return repos;
|
|
594
|
+
};
|
|
595
|
+
const prWorkflowView = async (fresh = false) => prWorkflow.view(await prWorkflowRepos(), fresh);
|
|
596
|
+
handle(rpc.prWorkflowRpc, async ({ refresh }) => {
|
|
597
|
+
await requireReady();
|
|
598
|
+
const view = await prWorkflowView(!!refresh);
|
|
599
|
+
if (refresh) prWorkflow.onChanged();
|
|
600
|
+
return view;
|
|
601
|
+
});
|
|
602
|
+
handle(rpc.setPrWorkflowRpc, async ({ repo, setting, default: fallback, mergeMethod, reviewFix }) => {
|
|
603
|
+
await requireReady();
|
|
604
|
+
if ((setting !== undefined || mergeMethod !== undefined || (reviewFix !== undefined && repo)) && !repo) throw new Error("Name the repository (owner/name) to change.");
|
|
605
|
+
await prWorkflow.mutate(config => {
|
|
606
|
+
if (fallback !== undefined) config.default = fallback;
|
|
607
|
+
if (!repo) { if (reviewFix) config.reviewFix = reviewFix; return; }
|
|
608
|
+
const own = config.repos[repoKey(repo)] ??= {};
|
|
609
|
+
if (setting !== undefined) { if (setting === null) delete own.workflow; else own.workflow = setting; }
|
|
610
|
+
if (mergeMethod !== undefined) { if (mergeMethod === null) delete own.mergeMethod; else own.mergeMethod = mergeMethod; }
|
|
611
|
+
if (reviewFix !== undefined) { if (reviewFix === null) delete own.reviewFix; else own.reviewFix = reviewFix; }
|
|
612
|
+
});
|
|
613
|
+
// A changed workflow changes readiness and merge: check the PRs again now rather than on the next poll.
|
|
614
|
+
void engine.tick();
|
|
615
|
+
return prWorkflowView();
|
|
616
|
+
});
|
|
556
617
|
handle(rpc.reviewerSettingsRpc, async () => { await requireReady(); return reviewerSettings(); });
|
|
557
618
|
handle(rpc.saveReviewersRpc, async ({ repo, reviewers }) => { await requireReady(); await reviewerStore.save(repo, reviewers); return reviewerSettings(); });
|
|
558
619
|
handle(rpc.reviewerSuggestionsRpc, async ({ repo }) => { await requireReady(); return reviewerSuggestions.suggest(repo); });
|
|
@@ -689,7 +750,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
689
750
|
if (!stopped) aboutTimer = setTimeout(() => void aboutLoop(), 10 * 60_000);
|
|
690
751
|
};
|
|
691
752
|
aboutTimer = setTimeout(() => void aboutLoop(), 60_000);
|
|
692
|
-
const agentActions = new AgentActions({ store, prActions: actions, engine, inbox, priorities: priorityStore, about, agentSettings });
|
|
753
|
+
const agentActions = new AgentActions({ store, prActions: actions, engine, inbox, priorities: priorityStore, about, agentSettings, prWorkflows: () => prWorkflowView() });
|
|
693
754
|
handle(rpc.prioritiesRpc, async () => ({ items: await priorityStore.read() }));
|
|
694
755
|
// Provider limits are non-essential: at critical memory only the VM meter is served.
|
|
695
756
|
handle(rpc.usageRpc, async () => ({ ...(governor.allowsExtras() ? await usage.read() : NO_USAGE), resources: governor.current() }));
|
|
@@ -909,7 +970,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
909
970
|
if (!w || w.mainAgentId !== event.agent.id || !interruption) return;
|
|
910
971
|
// The provider lost the conversation: every later send fails the same way, so stop sending instead of holding.
|
|
911
972
|
if (event.outcome.kind === "failed" && conversationGone(event.outcome.error.message)) { w.goneAgent = { agentId: event.agent.id, at: interruption.at, reason: event.outcome.error.message }; w.completion = null; return; }
|
|
912
|
-
w.hold = interruptionHold(interruption.kind); w.interruption = interruption; w.completion = null;
|
|
973
|
+
w.hold = interruptionHold(interruption.kind); w.interruption = { ...interruption, agentId: event.agent.id }; w.completion = null;
|
|
913
974
|
});
|
|
914
975
|
void engine.tick();
|
|
915
976
|
}),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.4.0-beta.
|
|
4
|
+
"version": "1.4.0-beta.18",
|
|
5
5
|
"description": "Follow every workspace PR stack in Paseo, answer agent questions, batch repairs for the main agent, and see what needs you.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"test:trust": "node scripts/check-trust-bypass.mjs",
|
|
29
29
|
"preview": "node scripts/check-install.mjs --keep",
|
|
30
30
|
"test:install": "node scripts/check-install.mjs",
|
|
31
|
+
"test:github-mode": "node scripts/check-github-mode.mjs",
|
|
31
32
|
"test:native": "node scripts/check-native-tools.mjs --agents 10",
|
|
32
33
|
"prepare": "node scripts/build.mjs",
|
|
33
34
|
"test:scale": "node scripts/scale-check.mjs --workspaces 120 --awake 5 --churn 35 --idle 60 --rss-budget 240 --cpu-budget 3 --request-budget 2"
|
package/server/agent-actions.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { InboxRow } from "../shared/inbox";
|
|
|
8
8
|
import type { Pr, State, Workspace } from "../shared/model";
|
|
9
9
|
import { configuredReviewers, reviewerLoginSchema, noReviewers, resolveReviewers, reviewerConfig, reviewerLabel, withoutAuthor, type ReviewerEntry } from "../shared/reviewers";
|
|
10
10
|
import { findWorkspace } from "./engine";
|
|
11
|
+
import { setMainAgent } from "./discovery";
|
|
11
12
|
import type { InboxAction } from "./inbox";
|
|
12
13
|
import { priorityInputSchema, type Priority } from "../shared/priorities";
|
|
13
14
|
import type { AboutView } from "../shared/about";
|
|
@@ -31,9 +32,13 @@ export const DESTRUCTIVE_TOOLS: readonly AgentTool[] = ["merge"];
|
|
|
31
32
|
export const PLANNED_TOOLS: readonly AgentTool[] = ["add_reviewers", "merge", "enable_merge_when_ready", "disable_merge_when_ready", "sign_off", "snooze", "set_finish_flags", "set_priorities"];
|
|
32
33
|
|
|
33
34
|
/** The developer's control panel switches (Auto-send, Resume, Retry). The button and the agent tool share it. */
|
|
34
|
-
export function controlWorkspace(state: State, input: { workspaceId: string; enable_auto_sends?: boolean; clearHold?: boolean; retryBatchId?: string }, now = Date.now()): Workspace {
|
|
35
|
+
export function controlWorkspace(state: State, input: { workspaceId: string; enable_auto_sends?: boolean; clearHold?: boolean; retryBatchId?: string; mainAgentId?: string }, now = Date.now()): Workspace {
|
|
35
36
|
const w = findWorkspace(state, input.workspaceId);
|
|
36
37
|
if (!w.enable_tracking || w.archived) throw new Error("Activate this workspace before changing follow-up controls.");
|
|
38
|
+
if (input.mainAgentId && input.mainAgentId !== w.mainAgentId) {
|
|
39
|
+
if (!w.contributorAgentIds?.includes(input.mainAgentId)) throw new Error("That agent isn't one of this workspace's root agents. Refresh and pick another.");
|
|
40
|
+
setMainAgent(w, input.mainAgentId, "developer", now);
|
|
41
|
+
}
|
|
37
42
|
if (input.enable_auto_sends !== undefined) w.enable_auto_sends = input.enable_auto_sends;
|
|
38
43
|
if (input.clearHold) w.hold = null;
|
|
39
44
|
if (input.retryBatchId) {
|
|
@@ -69,6 +74,8 @@ export type AgentActionDeps = {
|
|
|
69
74
|
about?: { view(workspaceId: string, opts: { open?: boolean; wait?: boolean }): Promise<AboutView> };
|
|
70
75
|
/** Settings → Agents, read-only: which agent each special role uses. No write tool. */
|
|
71
76
|
agentSettings?: { all(): Promise<Record<string, RoleConfig>> };
|
|
77
|
+
/** Each known repository's PR workflow (Settings → Following → Shipping PRs). */
|
|
78
|
+
prWorkflows?: () => Promise<{ default: string; repos: { repo: string; effective: string; setting: string; reason: string; reviewFix: unknown }[]; reviewFix: unknown }>;
|
|
72
79
|
now?: () => number;
|
|
73
80
|
};
|
|
74
81
|
|
|
@@ -110,6 +117,8 @@ export function prRow(w: Workspace, p: Pr) {
|
|
|
110
117
|
// Read-only: who Add reviewers would ask here and where that list comes from (Settings → Reviewers).
|
|
111
118
|
configuredReviewers: (({ reviewers, source }) => ({ source, reviewers: reviewers.map(r => ({ login: r.login, name: reviewerLabel(r) })) }))(resolveReviewers(reviewerConfig(), p.repo)),
|
|
112
119
|
needsReviewers: noReviewers(p) && !s!.draft, mergeable: blockers.length === 0, mergeBlockers: blockers,
|
|
120
|
+
// How this PR ships: "github" (gh pr merge, GitHub auto-merge) or "graphite". Older snapshots were Graphite's.
|
|
121
|
+
prWorkflow: s?.prWorkflow ?? "graphite",
|
|
113
122
|
};
|
|
114
123
|
}
|
|
115
124
|
|
|
@@ -134,7 +143,9 @@ export class AgentActions {
|
|
|
134
143
|
case "agent_settings": {
|
|
135
144
|
if (!this.d.agentSettings) throw new Error("agent_settings isn't available in this Follow-up.");
|
|
136
145
|
const roles = await this.d.agentSettings.all();
|
|
137
|
-
|
|
146
|
+
const workflows = await this.d.prWorkflows?.().catch(() => null);
|
|
147
|
+
return { roles: Object.values(roles).map(r => ({ ...r, summary: roleSummary(r), does: ROLE_INFO[r.role].does })), change: "Tom changes these in Follow-up settings → Agents.",
|
|
148
|
+
...(workflows ? { prWorkflow: { default: workflows.default, reviewFix: workflows.reviewFix, repos: workflows.repos.map(r => ({ repo: r.repo, workflow: r.effective, setting: r.setting, why: r.reason, reviewFix: r.reviewFix ?? workflows.reviewFix })), change: "Tom changes these in Follow-up settings → Following → Shipping PRs." } } : {}) };
|
|
138
149
|
}
|
|
139
150
|
case "add_reviewers": return this.planReviewers(caller, args);
|
|
140
151
|
case "merge": return this.planPr(caller, tool, "merge", args);
|
package/server/agent-hook.mjs
CHANGED
|
@@ -77,6 +77,20 @@ export function overseerDigest(file, seen, now = Date.now(), { needsMax = 20, ch
|
|
|
77
77
|
for (const l of lines) { if (text.length + l.length + 1 > chars) { text += "- …truncated: use workstreams()\n"; break; } text += l + "\n"; }
|
|
78
78
|
return { text: text.trimEnd(), seen: { at: now, rows: Object.fromEntries(all.map(r => [r.id, r.hash])) } };
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* How batches are worked, for this workspace's PR workflow (from scopes.json). Graphite with /fix-pr, and agents of an
|
|
82
|
+
* older worker that wrote no workflow, keep the original text; plain GitHub never mentions Graphite, gt or /fix-pr.
|
|
83
|
+
*/
|
|
84
|
+
export function batchParagraph(workflow) {
|
|
85
|
+
const mode = workflow?.mode ?? "graphite";
|
|
86
|
+
const fix = workflow === undefined || workflow === null ? "/fix-pr" : workflow.reviewFix ?? null;
|
|
87
|
+
const steps = "Follow-through batches contain a batch ID and task list. Read workspace_status and refresh live conditions before acting; skip resolved tasks. Process dependent PRs bottom to top, one PR fully before the next.";
|
|
88
|
+
const review = fix ? `Use the repository's ${fix} workflow, validate feedback, verify changes,` : "For review comments, read the PR's unresolved threads with gh, validate the feedback, fix it and verify the change,";
|
|
89
|
+
const submit = mode === "graphite" ? "submit through Graphite with --publish" : "push the branch (gh pr create for a new PR, gh pr ready when it leaves draft)";
|
|
90
|
+
const reply = fix ? "reply/resolve addressed threads" : "reply to each addressed thread and resolve it";
|
|
91
|
+
const restack = mode === "graphite" ? "Follow the repository's safe reparent procedure for merged parents" : "Keep stacked PRs as a chain of base branches: restack with git rebase --update-refs and push with --force-with-lease, and when a parent merges retarget its child with gh pr edit --base if GitHub didn't already";
|
|
92
|
+
return `${steps} ${review} ${submit}, and ${reply}. ${restack} and preserve uncommitted work.`;
|
|
93
|
+
}
|
|
80
94
|
const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
|
|
81
95
|
async function json(path) { return JSON.parse(await readFile(path, "utf8")); }
|
|
82
96
|
async function save(path, value) {
|
|
@@ -85,10 +99,10 @@ async function save(path, value) {
|
|
|
85
99
|
await writeFile(temporary, JSON.stringify(value), { mode: 0o600 });
|
|
86
100
|
await rename(temporary, path);
|
|
87
101
|
}
|
|
88
|
-
function instructions(lease, contributor = false) {
|
|
89
|
-
return named(paragraphs(lease, contributor).filter(p => !(native && /^Prefer (?:the )?native/i.test(p))).join("\n\n"));
|
|
102
|
+
function instructions(lease, contributor = false, workflow) {
|
|
103
|
+
return named(paragraphs(lease, contributor, workflow).filter(p => !(native && /^Prefer (?:the )?native/i.test(p))).join("\n\n"));
|
|
90
104
|
}
|
|
91
|
-
function paragraphs(lease, contributor) {
|
|
105
|
+
function paragraphs(lease, contributor, workflow) {
|
|
92
106
|
if (contributor) return [
|
|
93
107
|
"Maintain PR tracking for this session in its tracked workspace. Read workspace_status now and after compaction. Register every PR you submit, including from secondary git worktrees, with register_pr; register parents before children. References and external dependencies are not owned PRs. Call sync_workspace before finishing. The designated main agent retains goal, task, scope and completion authority.",
|
|
94
108
|
quietInstruction,
|
|
@@ -103,7 +117,7 @@ function paragraphs(lease, contributor) {
|
|
|
103
117
|
"Keep actual follow-through tasks current with update_obligation: production behavior checks, migrations and decisions, with concise titles, PR dependencies and evidence. Do not add merge/approval/deploy checklist tasks. Deployment-dependent work waits for verified serving revisions and existing production permissions.",
|
|
104
118
|
"Stakeholder replies are follow-through too. When asked to update a requester, capture the original Slack threadUrl, recipient and explicit developer authorization in the task's communication field; referenced messages alone do not authorize posting. Use a concise progress task now and, when needed, a verify-and-reply task with purpose=verified after the relevant deployed PRs. Read existing thread replies and refresh evidence before posting; distinguish fixed, deployed and verified. Record the actual sent replyUrl and result before marking done. If posting is unavailable or its outcome is uncertain, keep the task blocked and check the thread before any retry; never claim a draft was sent. Auto authorizes delivery to you, not external messages. Communication-only requests do not authorize repairs, benchmarks, migrations or other production writes.",
|
|
105
119
|
"Tasks are manual unless explicitly scheduled with trigger={event:\"now\"|\"merge\"|\"deploy\",delayDays:0}. Only set a trigger from the developer\u2019s requested timing; never infer timing from a title or enable_follow_up alone. Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null makes a task manual. Auto controls delivery, not timing or production permissions.",
|
|
106
|
-
|
|
120
|
+
batchParagraph(workflow) + " For post-deploy tasks, verify the currently serving revision contains every dependency and record behavioral results separately. Acknowledge the header's batch ID with acknowledge_batch before finishing: completed with the result, or blocked with the reason. Verify the entire goal and post-merge work before declare_done; acknowledge a completion batch first. Merging and archiving remain the developer's actions.",
|
|
107
121
|
"Before ending this turn, reconcile the sidebar with what you actually did and call sync_workspace with a short summary, including when no changes are needed. Acknowledge any assigned batch. When the entire goal is fulfilled, use declare_done; otherwise preserve remaining work. Do not launch recovery, start queued repairs, merge, toggle merge-when-ready, or archive as part of this bookkeeping. Auto still governs separate follow-up sends. Subagents report to the main agent instead of claiming workspace ownership.",
|
|
108
122
|
`Prefer the native follow-through MCP tools. For a full historical record, use workspace_status with detail=full. CLI compatibility fallback: FOLLOW_THROUGH_CLIENT_ENTRY=${quote(lease.clientEntry)} node ${quote(join(directory, "mcp.mjs"))} call <tool> '<json>' --compact. Omit --compact only when an existing script needs the full response. Never ask the developer to maintain the sidebar or run this bridge.`,
|
|
109
123
|
];
|
|
@@ -157,8 +171,8 @@ async function main() {
|
|
|
157
171
|
}
|
|
158
172
|
// scopes.json is a few KB; this hook runs on every tool call. Older workers don't write it: read state.json.
|
|
159
173
|
const scopes = await json(join(directory, "scopes.json")).catch(() => null);
|
|
160
|
-
let workspace = null; let contributor = false;
|
|
161
|
-
if (scopes?.agents) { const entry = scopes.agents[agentId]; if (entry && entry.role !== "recovery") { workspace = { id: entry.workspaceId }; contributor = entry.role === "contributor"; } }
|
|
174
|
+
let workspace = null; let contributor = false; let workflow;
|
|
175
|
+
if (scopes?.agents) { const entry = scopes.agents[agentId]; if (entry && entry.role !== "recovery") { workspace = { id: entry.workspaceId }; contributor = entry.role === "contributor"; workflow = entry.workflow; } }
|
|
162
176
|
else {
|
|
163
177
|
const state = await json(join(directory, "state.json")).catch(() => ({ workspaces: [] }));
|
|
164
178
|
workspace = state.workspaces.find(w => (w.mainAgentId === agentId || w.contributorAgentIds?.includes(agentId)) && w.enable_tracking && !w.archived) ?? null;
|
|
@@ -168,7 +182,7 @@ async function main() {
|
|
|
168
182
|
const provider = process.env.FOLLOW_THROUGH_BRIEF || null;
|
|
169
183
|
const brief = provider ? await json(join(directory, "brief.json")).catch(() => null) : null;
|
|
170
184
|
if (!workspace && !(brief?.enable_inbox && brief?.enable_brief_nudge) && !(native && process.env.FOLLOW_THROUGH_ROOT === "1")) return;
|
|
171
|
-
const context = () => instructions(lease, contributor);
|
|
185
|
+
const context = () => instructions(lease, contributor, workflow);
|
|
172
186
|
const sessionText = async () => [workspace ? context() : null, ...await nativeExtras(brief)].filter(Boolean).join("\n\n");
|
|
173
187
|
const name = event.hook_event_name;
|
|
174
188
|
if (!["SessionStart", "UserPromptSubmit", "PostToolUse", "Stop"].includes(name)) return;
|