@andrioid/paseo-attention-span 0.4.2 → 0.4.4
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 +1 -0
- package/client/attention-screen.tsx +13 -6
- package/client/sessions.ts +2 -2
- package/client/update.tsx +85 -0
- package/docs/architecture.md +17 -5
- package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
- package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
- package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-too-long.png +0 -0
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
- package/docs/screenshots/desktop-dark-history.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/desktop-dark-settings.png +0 -0
- package/docs/screenshots/desktop-dark-setup.png +0 -0
- package/docs/screenshots/desktop-dark-waiting.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
- package/index.server.ts +9 -0
- package/package.json +1 -1
- package/requirements.yaml +4 -1
- package/server/classify.ts +63 -38
- package/server/context.ts +19 -6
- package/server/details.ts +4 -2
- package/server/feedback.ts +8 -2
- package/server/fixture.ts +9 -1
- package/server/service.ts +10 -0
- package/server/store.ts +2 -0
- package/server/update.ts +106 -0
- package/shared/attention.ts +21 -2
- package/shared/prompts.ts +31 -6
- package/shared/rpc.ts +7 -0
- package/shared/update.ts +48 -0
package/OVERVIEW.md
CHANGED
|
@@ -135,6 +135,7 @@ Everything else lives in `~/.config/paseo-attention-span/config.json` on the dae
|
|
|
135
135
|
|
|
136
136
|
- **GitHub:** it reads your PRs, review requests, mentions and issues through `gh`, limited to the orgs and repos you've configured. By default it refreshes every 15 minutes, which uses about 7% of GitHub's hourly API allowance. I checked.
|
|
137
137
|
- **Local files:** a cache of what it shows, your dismissals and your Next up filter live in `~/.config/paseo-attention-span/state.json` on the daemon host. That's it.
|
|
138
|
+
- **Paseo:** about twice a day it asks Paseo whether a newer version of Attention Span is out, the same check `paseo plugin update --check` makes. Paseo looks it up in its plugin registry, on npm or on GitHub, depending on how you installed it. If there is one, the screen says so, with a link to what changed. Update installs it and restarts Attention Span. Nothing updates until you tap it.
|
|
138
139
|
- **Agent providers:** when a session starts, the item's context goes into the agent's prompt: descriptions, comments, review threads, failing CI logs. That prompt goes to whichever provider your agent profile uses, so it's worth knowing which one that is.
|
|
139
140
|
|
|
140
141
|
## What it doesn't do (yet)
|
|
@@ -4,7 +4,7 @@ import { Markdown, Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui
|
|
|
4
4
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { type ReactNode, useState } from "react";
|
|
6
6
|
import { Pressable, ScrollView, Text, View } from "react-native";
|
|
7
|
-
import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
|
|
7
|
+
import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
|
|
8
8
|
import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
|
|
9
9
|
import { ago, linkList, repoLabel } from "../shared/format";
|
|
10
10
|
import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
|
|
@@ -20,6 +20,7 @@ import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
|
|
|
20
20
|
import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
|
|
21
21
|
import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
22
22
|
import { SetupChecklist } from "./setup";
|
|
23
|
+
import { UpdateNotice } from "./update";
|
|
23
24
|
import { Avatar, Button, KeepStyles, Loading, Meta, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
|
|
24
25
|
|
|
25
26
|
// The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
|
|
@@ -42,11 +43,12 @@ const ACTION_ICONS: Record<ActionId, IconName> = {
|
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
function actionLabel(action: ActionId, item: Item): string {
|
|
45
|
-
|
|
46
|
+
// Review takes the whole stack; Rebase, my PRs in it [ATT-04].
|
|
47
|
+
const stacked = ownStack(item.target).length > 1;
|
|
46
48
|
return {
|
|
47
49
|
reply: "Reply ↗",
|
|
48
50
|
acknowledge: "Acknowledge",
|
|
49
|
-
review: "Review",
|
|
51
|
+
review: (item.target.stack?.length ?? 0) > 1 ? "Review stack" : "Review",
|
|
50
52
|
fix: "Fix CI",
|
|
51
53
|
rerun: "Rerun failed jobs",
|
|
52
54
|
address: "Address comments",
|
|
@@ -67,13 +69,17 @@ function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): string {
|
|
|
67
69
|
const { target } = item;
|
|
68
70
|
const pr = `#${target.number}`;
|
|
69
71
|
const base = target.baseRefName ?? target.defaultBranch ?? "its base";
|
|
70
|
-
const stacked = (target.
|
|
72
|
+
const stacked = ownStack(target).length > 1;
|
|
73
|
+
const asking = (target.stack ?? []).filter((p) => p.review);
|
|
71
74
|
const comments = item.person?.comments ?? [];
|
|
72
75
|
return {
|
|
73
76
|
reply: item.person ? `Opens ${item.person.login}'s comment on GitHub` : "Opens it on GitHub",
|
|
74
77
|
acknowledge:
|
|
75
78
|
comments.length === 1 ? `Reacts to ${comments[0].author}'s comment, which clears it` : `Pick which of the ${comments.length} waiting comments to react to`,
|
|
76
|
-
review:
|
|
79
|
+
review:
|
|
80
|
+
(target.stack?.length ?? 0) > 1
|
|
81
|
+
? `An agent reviews ${asking.map((p) => `#${p.number}`).join(", ") || "the stack"} in a checkout of the stack's top and reports back. Nothing is posted`
|
|
82
|
+
: "An agent reviews the PR in a checkout and reports back. Nothing is posted",
|
|
77
83
|
fix: "An agent reads the failing logs and commits a fix, without pushing",
|
|
78
84
|
address: "An agent works through the unresolved comments and applies the trivial ones, without pushing",
|
|
79
85
|
update: `GitHub rebases ${pr} onto ${base}`,
|
|
@@ -392,6 +398,7 @@ function AttentionList({
|
|
|
392
398
|
</View>
|
|
393
399
|
</View>
|
|
394
400
|
{feed.error ? <Text style={styles.danger}>{feed.error}</Text> : null}
|
|
401
|
+
<UpdateNotice />
|
|
395
402
|
|
|
396
403
|
{undoable.map((row) => (
|
|
397
404
|
<View key={row.id} style={[styles.panel, styles.row, { justifyContent: "space-between" }]}>
|
|
@@ -1137,7 +1144,7 @@ function SessionOptions({ spec, actions, onClose }: { spec: OptionsSpec; actions
|
|
|
1137
1144
|
// Without a ready provider, still show the options; starting reports the error.
|
|
1138
1145
|
resolveAgentConfig(paseo, actions.fetchProviders, kind, actions.config).catch(() => ({ label: "No agent provider is ready" })),
|
|
1139
1146
|
]);
|
|
1140
|
-
const workspaces = checkout.project ? await branchWorkspaces(paseo, checkout.project.projectId, target.
|
|
1147
|
+
const workspaces = checkout.project ? await branchWorkspaces(paseo, checkout.project.projectId, checkoutPr(kind, target).head) : [];
|
|
1141
1148
|
return { prompt: renderPrompt(kind, target, context, actions.config), profiles, checkout, workspaces, defaultLabel: defaults.label };
|
|
1142
1149
|
},
|
|
1143
1150
|
staleTime: 60_000,
|
package/client/sessions.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { usePaseo } from "@getpaseo/plugin/client";
|
|
2
|
-
import type
|
|
2
|
+
import { type AgentSummary, checkoutPr, type Target } from "../shared/attention";
|
|
3
3
|
import { linkedSessions } from "../shared/linked-sessions";
|
|
4
4
|
import { chooseAgent, type ReadyProvider } from "../shared/providers";
|
|
5
5
|
import { type AttentionConfig, codeRepoFor, githubRepoOf, SessionKind } from "../shared/config";
|
|
@@ -176,7 +176,7 @@ export async function startSession(paseo: Paseo, input: StartSession): Promise<s
|
|
|
176
176
|
cwd: project.rootPath,
|
|
177
177
|
projectId: project.projectId,
|
|
178
178
|
action: "checkout",
|
|
179
|
-
checkoutSource: { kind: "change_request", forge: "github", number: target.number },
|
|
179
|
+
checkoutSource: { kind: "change_request", forge: "github", number: checkoutPr(input.kind, target).number },
|
|
180
180
|
}
|
|
181
181
|
: {
|
|
182
182
|
kind: "worktree",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { openExternalUrl, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useToast } from "@getpaseo/plugin/client/ui";
|
|
3
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Platform, Text, View } from "react-native";
|
|
6
|
+
import * as rpc from "../shared/rpc";
|
|
7
|
+
import type { UpdateNotice as Notice } from "../shared/update";
|
|
8
|
+
import { Button, TablerIcon, useCopy, useStyles } from "./ui";
|
|
9
|
+
|
|
10
|
+
const UPDATE_QUERY_KEY = ["attention-span", "update"] as const;
|
|
11
|
+
// The server caches Paseo's answer for 12 hours, so asking it often costs nothing.
|
|
12
|
+
const EVERY_MS = 60 * 60 * 1000;
|
|
13
|
+
// While an update runs: soon enough to show a failure, and the restart's result.
|
|
14
|
+
const UPDATING_MS = 2000;
|
|
15
|
+
const MONO = Platform.select({ ios: "Menlo", default: "monospace" });
|
|
16
|
+
const FROM: Record<Notice["source"], string> = { registry: "the Paseo plugin registry", npm: "npm", git: "GitHub" };
|
|
17
|
+
|
|
18
|
+
// A newer version, what changed, Update, and Not now until the next one [UPD-01].
|
|
19
|
+
// Update runs `paseo plugin update` on the daemon, which installs it and restarts the plugin; the app then loads the new
|
|
20
|
+
// version. Once the restart is done, the check says it's current and the notice goes.
|
|
21
|
+
export function UpdateNotice() {
|
|
22
|
+
const styles = useStyles();
|
|
23
|
+
const toast = useToast();
|
|
24
|
+
const copy = useCopy();
|
|
25
|
+
const queryClient = useQueryClient();
|
|
26
|
+
const check = useRpc(rpc.checkUpdate);
|
|
27
|
+
const apply = useRpc(rpc.applyUpdate);
|
|
28
|
+
const skip = useRpc(rpc.skipUpdate);
|
|
29
|
+
const [updating, setUpdating] = useState(false);
|
|
30
|
+
const { data: notice } = useQuery({
|
|
31
|
+
queryKey: UPDATE_QUERY_KEY,
|
|
32
|
+
// While the plugin restarts, its server isn't there to answer: keep what's on screen.
|
|
33
|
+
queryFn: () => check({}).catch((error: Error) => (updating ? (queryClient.getQueryData<Notice | null>(UPDATE_QUERY_KEY) ?? null) : Promise.reject(error))),
|
|
34
|
+
staleTime: updating ? 0 : EVERY_MS,
|
|
35
|
+
refetchInterval: (query) => (updating && !query.state.data?.error ? UPDATING_MS : EVERY_MS),
|
|
36
|
+
});
|
|
37
|
+
if (!notice) return null;
|
|
38
|
+
const busy = updating && !notice.error;
|
|
39
|
+
|
|
40
|
+
const update = async () => {
|
|
41
|
+
setUpdating(true);
|
|
42
|
+
try {
|
|
43
|
+
await apply({ latest: notice.latest });
|
|
44
|
+
await queryClient.invalidateQueries({ queryKey: UPDATE_QUERY_KEY });
|
|
45
|
+
} catch (error) {
|
|
46
|
+
setUpdating(false);
|
|
47
|
+
toast.error(`Updating failed: ${(error as Error).message}`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const notNow = () => {
|
|
52
|
+
queryClient.setQueryData(UPDATE_QUERY_KEY, null);
|
|
53
|
+
skip({ latest: notice.latest }).catch((error: Error) => toast.error(`Couldn't put it off: ${error.message}`));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<View style={styles.panel} accessibilityRole="summary" accessibilityLiveRegion="polite">
|
|
58
|
+
<View style={styles.row}>
|
|
59
|
+
<TablerIcon name="update" size={16} color={styles.action} />
|
|
60
|
+
<Text style={styles.title}>Attention Span {notice.latest} is out</Text>
|
|
61
|
+
</View>
|
|
62
|
+
{notice.error ? (
|
|
63
|
+
<>
|
|
64
|
+
<Text style={styles.danger}>Updating failed: {notice.error}</Text>
|
|
65
|
+
<Text style={styles.muted}>To see more, run this where Paseo's daemon runs:</Text>
|
|
66
|
+
<Text selectable style={[styles.text, { fontFamily: MONO, fontSize: 13 }]}>
|
|
67
|
+
{notice.command}
|
|
68
|
+
</Text>
|
|
69
|
+
</>
|
|
70
|
+
) : (
|
|
71
|
+
<Text style={styles.muted}>
|
|
72
|
+
{busy
|
|
73
|
+
? `Installing it from ${FROM[notice.source]}. Attention Span restarts when it's done.`
|
|
74
|
+
: `You have ${notice.current}. Update installs it from ${FROM[notice.source]} and restarts Attention Span, which takes a few seconds.`}
|
|
75
|
+
</Text>
|
|
76
|
+
)}
|
|
77
|
+
<View style={styles.wrap}>
|
|
78
|
+
<Button label={busy ? "Updating…" : notice.error ? "Try again" : "Update"} icon="update" variant="solid" busy={busy} onPress={() => void update()} />
|
|
79
|
+
{notice.error ? <Button label="Copy command" icon="copy" onPress={() => copy(notice.command, "Copied the update command")} /> : null}
|
|
80
|
+
<Button label="What's new" icon="github" onPress={() => void openExternalUrl(notice.notes)} />
|
|
81
|
+
{busy ? null : <Button label="Not now" variant="ghost" accessibilityLabel={`Not now: hide until a version newer than ${notice.latest}`} onPress={notNow} />}
|
|
82
|
+
</View>
|
|
83
|
+
</View>
|
|
84
|
+
);
|
|
85
|
+
}
|
package/docs/architecture.md
CHANGED
|
@@ -40,7 +40,7 @@ flowchart LR
|
|
|
40
40
|
- optional merge method per repo [PRS-04]
|
|
41
41
|
- `codeRepos`: where an issue repo's code lives, for issues kept in their own repo [SES-07]
|
|
42
42
|
- `nextUp`: where unclaimed issues come from (`mine`, `orgs`, `repos`, set in Settings) and the org issue fields for priority, effort and scope [NXT-04]
|
|
43
|
-
- `state.json`: dismissals [ATT-08], the scopes and sources ticked in Next up's filter [NXT-03, NXT-09], my Paseo projects' GitHub repos [NXT-08] and the last fetch of each feed, so the screen shows instantly after a restart [PRIV-01].
|
|
43
|
+
- `state.json`: dismissals [ATT-08], the scopes and sources ticked in Next up's filter [NXT-03, NXT-09], my Paseo projects' GitHub repos [NXT-08], the update put off with Not now [UPD-01] and the last fetch of each feed, so the screen shows instantly after a restart [PRIV-01].
|
|
44
44
|
|
|
45
45
|
## Tabs
|
|
46
46
|
|
|
@@ -81,7 +81,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
|
|
|
81
81
|
## Rules
|
|
82
82
|
|
|
83
83
|
- **One item per issue** [ATT-03]: PRs are grouped under the issue they work on, across repos. GitHub links (`closingIssuesReferences`) only PRs into the default branch, so a stack's upper PRs are read too. For a stack, strongest evidence first: what GitHub links on any of its PRs, bottom first; then a closing keyword ("Closes #N") in any PR's description; then the one issue the bottom PR's description mentions ("First of three for #N"), and none when it mentions several. Code, quotes and template comments don't count. References from descriptions are looked up in the details request, and only open issues count, so a reference to a PR doesn't group. A PR without an issue is its own item. History does the same per merged PR, against the closed issues it lists.
|
|
84
|
-
- **One item per stack** [ATT-04]: a stack is followed through base/head branch names.
|
|
84
|
+
- **One item per stack** [ATT-04]: a stack is followed through base/head branch names, among my PRs and others' PRs requesting my review, whoever opened them; a PR from a fork never parents another. Only PRs those two searches return can be joined, so a PR in the stack that's neither mine nor asking for my review is left out. The item is led by the stack's bottom PR, with the rest listed beneath. My PRs in it are decided by their bottom PR, as before; others' PRs asking for my review add one Review for all of them, or a reply when one mentions me. Where a stack has both, its section is the more urgent of the two and it offers both, that one's actions first. GitHub actions act on my PRs, from my bottom one; a stack only asking for my review is never grouped under an issue. Sessions on any PR in the stack show on its item [SES-03, SES-08].
|
|
85
85
|
- **Answers** [ATT-16]: on an issue a PR of mine closes, an answer leads the item like a mention does. From the issue itself only what's on me counts; its PRs say how the work is going.
|
|
86
86
|
- **Mentions** [MEN-01..06]: a thread counts when a person @-mentioned me after my last comment, review or reaction there. Team mentions are ignored. A bot counts only when it opened a thread I need to resolve, and is marked with 🤖. The quote on a card is cut around the mention, so it's shown as plain text: links keep their text, Markdown marks and quoted replies go.
|
|
87
87
|
- **Handed over** [PRS-08]: my PRs assigned to someone else, and not to me, are left out. Mentions of me on them still count.
|
|
@@ -113,11 +113,11 @@ An agent icon (Tabler's `message-ai`, a speech bubble with "AI") marks every act
|
|
|
113
113
|
|---|---|---|
|
|
114
114
|
| Reply ↗ | Mention waiting | Opens the comment on GitHub [ATT-12] |
|
|
115
115
|
| Acknowledge | Mention waiting | Lists every waiting comment in full, rendered as Markdown with Paseo's renderer (cut after whole blocks, up to about 4,000 characters), all ticked; 👍 on the ones I keep ticked (`addReaction`), which clears them [MEN-07]. Undo removes them. |
|
|
116
|
-
| Review *(agent)* | Review requested | Session in a PR checkout using the review profile [SES-01] |
|
|
116
|
+
| Review *(agent)* | Review requested | Session in a PR checkout using the review profile [SES-01]. For a stack, "Review stack": one session in a checkout of the stack's top, whose prompt lists every branch and asks for a review of only the PRs requesting mine, each against its own base, with their descriptions and recent comments as context [ATT-04] |
|
|
117
117
|
| Fix CI / Address comments *(agent)* | CI failing / changes requested | Session with the failing log or unresolved threads in the prompt [SES-04] |
|
|
118
|
-
| Rerun failed jobs | CI failing, in the sheet | `gh run rerun --failed` for each failing GitHub Actions run of the PR, or of every PR in its stack. The sheet names the failed checks and how often they were rerun (`gh api …/runs/<id>`), fetched when it opens. Other status checks can't be rerun from here [PRS-09]. |
|
|
118
|
+
| Rerun failed jobs | CI failing, in the sheet | `gh run rerun --failed` for each failing GitHub Actions run of the PR, or of every PR of mine in its stack. The sheet names the failed checks and how often they were rerun (`gh api …/runs/<id>`), fetched when it opens. Other status checks can't be rerun from here [PRS-09]. |
|
|
119
119
|
| Update branch | Behind with no conflicts, not stacked | `updatePullRequestBranch` (rebase) [UPS-03] |
|
|
120
|
-
| Rebase / Refresh *(agent)* | Conflicts, any stacked PR, stale draft | Agent rebases the PR, or the
|
|
120
|
+
| Rebase / Refresh *(agent)* | Conflicts, any stacked PR, stale draft | Agent rebases the PR, or my PRs in the stack with `git rebase --update-refs`; others' branches in it are never pushed [UPS-04]. A clean rebase is pushed with `--force-with-lease` [UPS-06]. After resolving conflicts it stops and explains, and pushes only when I reply "push" in its session [UPS-05]. |
|
|
121
121
|
| Ready for review | My draft with CI not failing, no conflicts, not stale | `markPullRequestReadyForReview` on the bottom PR, then the reviewer picker below; Skip leaves it in *Needs a reviewer*. Undo converts it back to a draft [PRS-11] |
|
|
122
122
|
| Request review | Needs a reviewer | Opens a picker: GitHub's `suggestedReviewers` and the repo's teams (`gh api repos/<repo>/teams`), fetched when it opens; people who reviewed or were asked on my other PRs in the repo, from the last refresh; or any login or `org/team` typed in. Without `read:org` the teams are replaced by a line saying so. Sends `POST …/pulls/<n>/requested_reviewers`, which keeps who's already asked; Undo withdraws them with `DELETE` [PRS-12] |
|
|
123
123
|
| Merge (no reviewer) | Needs a reviewer, CI green on the current base | As Merge below, for repos where nobody reviews [PRS-12] |
|
|
@@ -148,6 +148,18 @@ Each session gets its own workspace on an empty scratch directory, so archiving
|
|
|
148
148
|
|
|
149
149
|
The agent asks one question at a time from its kind's checklist, and checks the report against the requirements and docs, `config.json` and `state.json`, and open issues and discussions. A match gets its link and nothing else. It files an issue if a maintainer could finish and close it, otherwise a discussion in Q&A or Ideas, and says which and why. Posts are short up front, with the rest in collapsed `<details>` blocks, in English, in the user's voice, with nothing from their own setup they didn't write. It posts only after Post it in its question tool, or the reply "post" [SAFE-01], then archives its workspace (`archive_workspace`, or `archive_agent` without it). The client watches workspace updates, remembers the scratch ones by their directory, and opens Attention Span when one is removed, instead of leaving "workspace unavailable" on screen. The prompts are built in: `config.json` can't replace them, since they carry those rules.
|
|
150
150
|
|
|
151
|
+
## Updates
|
|
152
|
+
|
|
153
|
+
A notice above the list says when a newer version is out, and Update installs it [UPD-01].
|
|
154
|
+
|
|
155
|
+
**Check.** Paseo has no update signal for plugins and doesn't tell a plugin its version. So the server asks Paseo's CLI the same thing `paseo plugin update` would: `$PASEO_CLI plugin update <id> --check --json --home $PASEO_HOME`. Paseo gives every plugin subprocess both variables, so this reaches the daemon the plugin runs in. The ID is the one Paseo's `config.json` lists this plugin under, found as Feedback finds the source. The answer covers each kind of install: a registry install's reviewed pin, npm's `latest`, or a Git remote's HEAD. Directory installs report `local` and get no notice, since Paseo never updates them. The server caches the answer for 12 hours, since the registry picks up npm releases twice a day, and retries a failed check after an hour.
|
|
156
|
+
|
|
157
|
+
**Notice.** It shows the version, or the short commit for Git, where it comes from, and What's new: GitHub Releases, or Paseo's compare link for Git. Not now saves that version in `state.json` and hides the notice until a newer one comes out.
|
|
158
|
+
|
|
159
|
+
**Update** is a tap on the version shown [SAFE-01]. The server runs `paseo plugin update <id>` pinned to it where Paseo allows: `--version` for npm and `--ref <commit>` for Git. A registry install accepts only `--yes`, which takes the reviewed pin. Paseo installs it and restarts the plugin itself, so no separate reload is needed. The restart ends the server process, so the CLI runs detached and outlives it. The app loads the new client on its own, with no page reload. While it runs, the notice polls every 2 seconds. Once the new version is running, the check says it's current and the notice goes. If the CLI fails, the server, still running, keeps the reason, and the notice shows it with Try again and the command to run by hand.
|
|
160
|
+
|
|
161
|
+
In previews, `PASEO_ATTENTION_SPAN_FIXTURE_UPDATE=1` makes up an update from 0.4.3 to 0.5.0, and Update fails with "Previews don't update."
|
|
162
|
+
|
|
151
163
|
## GitHub requests
|
|
152
164
|
|
|
153
165
|
Light on GitHub's API [GH-01], and quick when I press ⟳. Attention Span has two feeds, each with its own cache, schedule and error:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.server.ts
CHANGED
|
@@ -21,12 +21,14 @@ import { FIXTURE_CONTEXT, fixtureDetails, fixtureReviewerChoices } from "./serve
|
|
|
21
21
|
import { FIXTURE } from "./server/gh";
|
|
22
22
|
import { checkCoverage, configStatus, myOrgs, setupStatus } from "./server/setup";
|
|
23
23
|
import { AttentionService, type Change } from "./server/service";
|
|
24
|
+
import { UpdateCheck } from "./server/update";
|
|
24
25
|
import type { Chip } from "./shared/attention";
|
|
25
26
|
import { readyProviders } from "./shared/providers";
|
|
26
27
|
import * as rpc from "./shared/rpc";
|
|
27
28
|
|
|
28
29
|
export default function contribute(server: PluginServerContext) {
|
|
29
30
|
const attention = new AttentionService();
|
|
31
|
+
const updates = new UpdateCheck();
|
|
30
32
|
const started = attention.start().catch((error) => console.error("Attention Span failed to start:", error));
|
|
31
33
|
const ready = <T>(work: () => Promise<T>) => started.then(work);
|
|
32
34
|
|
|
@@ -72,6 +74,13 @@ export default function contribute(server: PluginServerContext) {
|
|
|
72
74
|
server.handle(rpc.itemDetails, ({ subject, target, checks }) => (FIXTURE ? Promise.resolve(fixtureDetails(subject, target, checks)) : itemDetails(subject, target, checks)));
|
|
73
75
|
server.handle(rpc.defaultBranch, async ({ repo }) => ({ name: FIXTURE ? "main" : await defaultBranch(repo) }));
|
|
74
76
|
server.handle(rpc.feedbackInfo, () => feedbackInfo());
|
|
77
|
+
// [UPD-01]
|
|
78
|
+
server.handle(rpc.checkUpdate, () => ready(async () => {
|
|
79
|
+
const notice = await updates.get();
|
|
80
|
+
return notice && notice.latest !== attention.skippedUpdate ? notice : null;
|
|
81
|
+
}));
|
|
82
|
+
server.handle(rpc.applyUpdate, ({ latest }) => updates.apply(latest).then(() => ({ ok: true as const })));
|
|
83
|
+
server.handle(rpc.skipUpdate, ({ latest }) => ready(() => attention.skipUpdate(latest)).then(() => ({ ok: true as const })));
|
|
75
84
|
// The server's Paseo connection expands the snapshot; the app's may not (getpaseo compact snapshots) [SES-06].
|
|
76
85
|
server.handle(rpc.readyProviders, async (_input, { paseo }) => ({ providers: readyProviders((await paseo.providers.snapshot()).entries) }));
|
|
77
86
|
server.handle(rpc.sessionContext, async ({ kind, target }) => ({ context: FIXTURE ? FIXTURE_CONTEXT : await sessionContext(kind, target) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/requirements.yaml
CHANGED
|
@@ -21,7 +21,7 @@ functional:
|
|
|
21
21
|
ATT-01: see in one place the open issues and pull requests that need me; so that I don't depend on noisy GitHub notifications.
|
|
22
22
|
ATT-02: see why each item needs me, with items grouped by that reason; so that I know what to do about an item at a glance.
|
|
23
23
|
ATT-03: see an issue and the pull requests that resolve it as one item, led by the issue; so that related work isn't scattered across the list.
|
|
24
|
-
ATT-04: see
|
|
24
|
+
ATT-04: see any stack of dependent pull requests as one item, whoever opened them, with a session on any of its pull requests shown on it and, where my review is requested, one review for the whole stack; so that a stack is handled as the single change it is.
|
|
25
25
|
ATT-05: judge an item from the list without opening it; so that triage is quick and I'm not visually overloaded.
|
|
26
26
|
ATT-06: open an item for more detail and every action, each saying what it will do; so that the list stays minimal by default and pressing a button makes sense.
|
|
27
27
|
ATT-07: see whether an item already has a Paseo session and what its agent is doing; so that I don't start duplicate work.
|
|
@@ -107,6 +107,9 @@ functional:
|
|
|
107
107
|
feedback:
|
|
108
108
|
As a developer, I can:
|
|
109
109
|
FB-01: tell the Attention Span project what to improve from the bottom of any tab, picking a problem, an idea or that I like it, with an agent that asks until it's clear, checks it against what's planned and already reported, and files it as an issue or a discussion, saying which and why, only once I approve the draft; so that feedback costs a minute and lands where it can be acted on or talked through.
|
|
110
|
+
updates:
|
|
111
|
+
As a developer, I can:
|
|
112
|
+
UPD-01: see when a newer version of Attention Span is out than the one I have, with what changed, and update to it with one tap or put it off until the next one; so that I get fixes without checking for them or going to a terminal.
|
|
110
113
|
|
|
111
114
|
non_functional:
|
|
112
115
|
github_usage:
|
package/server/classify.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type ActionId,
|
|
2
3
|
type Attention,
|
|
3
4
|
type Chip,
|
|
4
5
|
type Item,
|
|
@@ -29,6 +30,17 @@ export interface ClassifyInput {
|
|
|
29
30
|
now: Date;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
// My PRs in a stack, or others' asking for my review: what each says about the stack's item [ATT-04].
|
|
34
|
+
interface Part {
|
|
35
|
+
section: SectionId;
|
|
36
|
+
actions: ActionId[];
|
|
37
|
+
chips: Chip[];
|
|
38
|
+
person?: Person;
|
|
39
|
+
waitingOn?: WaitingOn[];
|
|
40
|
+
wait?: Item["wait"];
|
|
41
|
+
othersActivityAt: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
32
44
|
const EPOCH = "1970-01-01T00:00:00Z";
|
|
33
45
|
const rank = (section: SectionId) => SECTION_ORDER.indexOf(section);
|
|
34
46
|
// Section order, then newest first.
|
|
@@ -71,8 +83,15 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
71
83
|
// My PRs, minus those handed over to someone else [PRS-08].
|
|
72
84
|
const mine = compact(data.mine.nodes).filter((pr) => pr.assignees.nodes.length === 0 || pr.assignees.nodes.some(isMe));
|
|
73
85
|
|
|
74
|
-
//
|
|
75
|
-
const
|
|
86
|
+
// Others' PRs asking for my review [REV-01]. A PR of mine is mine, even if it asks me too.
|
|
87
|
+
const ownKeys = new Set(mine.map(prKey));
|
|
88
|
+
const requests = compact(data.reviews.nodes).filter((pr) => !ownKeys.has(prKey(pr)));
|
|
89
|
+
const isOwn = (pr: PullRequestNode) => ownKeys.has(prKey(pr));
|
|
90
|
+
|
|
91
|
+
// Stacks, followed through base/head branch names, among my PRs and those asking for my review, whoever opened them [ATT-04].
|
|
92
|
+
// A fork's branch isn't the repo's, so a PR from a fork is never a parent.
|
|
93
|
+
const prs = [...mine, ...requests];
|
|
94
|
+
const byHead = new Map(prs.filter((pr) => !pr.isCrossRepository).map((pr) => [`${pr.repository.nameWithOwner}\0${pr.headRefName}`, pr]));
|
|
76
95
|
const parentOf = (pr: PullRequestNode) => {
|
|
77
96
|
const parent = byHead.get(`${pr.repository.nameWithOwner}\0${pr.baseRefName}`);
|
|
78
97
|
return parent === pr ? undefined : parent;
|
|
@@ -83,9 +102,9 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
83
102
|
if (seen.has(pr)) return;
|
|
84
103
|
seen.add(pr);
|
|
85
104
|
stack.push(pr);
|
|
86
|
-
for (const child of
|
|
105
|
+
for (const child of prs.filter((candidate) => parentOf(candidate) === pr)) walk(child, stack);
|
|
87
106
|
};
|
|
88
|
-
const byNumber = [...
|
|
107
|
+
const byNumber = [...prs].sort((a, b) => a.number - b.number);
|
|
89
108
|
for (const pr of byNumber) if (!parentOf(pr)) stacks.push([]), walk(pr, stacks[stacks.length - 1]);
|
|
90
109
|
for (const pr of byNumber) if (!seen.has(pr)) stacks.push([pr]); // cycles, in theory
|
|
91
110
|
|
|
@@ -141,8 +160,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
141
160
|
const items: Item[] = [];
|
|
142
161
|
const listed = new Set<string>();
|
|
143
162
|
|
|
144
|
-
//
|
|
145
|
-
const
|
|
163
|
+
// My PRs in a stack, decided by their bottom PR [ATT-04].
|
|
164
|
+
const ownPart = (stack: PullRequestNode[]): Part => {
|
|
146
165
|
const bottom = stack[0];
|
|
147
166
|
const s = state(bottom);
|
|
148
167
|
const outOfSync = stack.slice(1).some((pr) => state(pr).outOfSync || state(pr).conflicts);
|
|
@@ -208,10 +227,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
208
227
|
else if (section === "ready" && s.behindBy === 0) chips.push(chip(s.optionalPending ? "required checks passed" : "CI passed", "good"));
|
|
209
228
|
if (s.conflicts) chips.push(chip("conflicts", "bad"));
|
|
210
229
|
if (s.behindBy > 0) chips.push(behindChip(s.behindBy, base));
|
|
211
|
-
if (stack.length > 1) chips.push(chip(`stack of ${stack.length}`));
|
|
212
230
|
|
|
213
231
|
return {
|
|
214
|
-
stack,
|
|
215
232
|
section,
|
|
216
233
|
actions,
|
|
217
234
|
chips,
|
|
@@ -224,6 +241,36 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
224
241
|
waitingOn: waitingOn.length > 0 ? waitingOn : undefined,
|
|
225
242
|
othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), waiting?.since, answer?.since),
|
|
226
243
|
};
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Others' PRs in a stack that ask for my review: one Review for them all [REV-01, ATT-04].
|
|
247
|
+
const reviewPart = (stack: PullRequestNode[]): Part => {
|
|
248
|
+
const waiting = stack.map((pr) => mentions.get(prKey(pr))).find(Boolean);
|
|
249
|
+
const lastCommitAt = latest(...stack.map((pr) => state(pr).lastCommitAt));
|
|
250
|
+
return {
|
|
251
|
+
section: waiting ? "reply" : "review",
|
|
252
|
+
actions: waiting ? [...replyActions(waiting), "review"] : ["review"],
|
|
253
|
+
chips: stack.some((pr) => state(pr).ciFailing) ? [chip("CI failing", "bad")] : [],
|
|
254
|
+
person: waiting ?? person(stack[0].author, lastCommitAt),
|
|
255
|
+
othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), lastCommitAt, waiting?.since),
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// One unit per stack (or single PR), whoever opened it. Where it has both, its section is the more urgent of my PRs' and
|
|
260
|
+
// the review's, and it offers both, the winner's actions first [ATT-04].
|
|
261
|
+
const units = stacks.map((stack) => {
|
|
262
|
+
const own = stack.filter(isOwn);
|
|
263
|
+
const asking = stack.filter((pr) => !isOwn(pr));
|
|
264
|
+
const parts = [own.length ? ownPart(own) : undefined, asking.length ? reviewPart(asking) : undefined].filter((part) => !!part);
|
|
265
|
+
const [lead, other] = parts.sort((a, b) => rank(a.section) - rank(b.section));
|
|
266
|
+
return {
|
|
267
|
+
...lead,
|
|
268
|
+
stack,
|
|
269
|
+
own,
|
|
270
|
+
actions: [...new Set([...lead.actions, ...(other?.actions ?? [])])],
|
|
271
|
+
chips: [...lead.chips, ...(stack.length > 1 ? [chip(`stack of ${stack.length}`)] : [])],
|
|
272
|
+
othersActivityAt: latest(lead.othersActivityAt, other?.othersActivityAt),
|
|
273
|
+
};
|
|
227
274
|
});
|
|
228
275
|
type Unit = (typeof units)[number];
|
|
229
276
|
|
|
@@ -233,7 +280,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
233
280
|
const chips: Chip[] = [];
|
|
234
281
|
if (stack.length > 1) chips.push(chip(`${index + 1}/${stack.length}`));
|
|
235
282
|
if (s.approved) chips.push(chip("approved", "good"));
|
|
236
|
-
|
|
283
|
+
// Only mine are mine to ask someone on [PRS-12].
|
|
284
|
+
if (isOwn(pr) && !pr.isDraft && !s.asked) chips.push(chip("no reviewer", "warn"));
|
|
237
285
|
if (s.ciFailing) chips.push(chip("CI failing", "bad"));
|
|
238
286
|
if (s.conflicts) chips.push(chip("conflicts", "bad"));
|
|
239
287
|
if (s.behindBy > 0) chips.push(behindChip(s.behindBy, parent ? `#${parent.number}` : pr.baseRefName));
|
|
@@ -252,16 +300,17 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
252
300
|
headRefOid: pr.headRefOid,
|
|
253
301
|
defaultBranch: pr.repository.defaultBranchRef?.name,
|
|
254
302
|
mergeMethod: mergeMethodFor(pr, config),
|
|
255
|
-
stack: stack.map((p) => ({ number: p.number, head: p.headRefName, base: p.baseRefName })),
|
|
303
|
+
stack: stack.map((p) => ({ number: p.number, head: p.headRefName, base: p.baseRefName, ...(isOwn(p) ? {} : { review: true as const }) })),
|
|
256
304
|
});
|
|
257
305
|
|
|
258
|
-
// One item per issue: PRs grouped under the issue they work on [ATT-03]. Otherwise one per unit.
|
|
306
|
+
// One item per issue: my PRs grouped under the issue they work on [ATT-03]. Otherwise one per unit, led by its bottom PR.
|
|
259
307
|
const issues = new Map(Object.entries(details.issues));
|
|
260
308
|
for (const pr of mine) for (const issue of pr.closingIssuesReferences.nodes) issues.set(prKey(issue), issue);
|
|
261
309
|
const groups = new Map<string, { lead?: LinkedIssue; units: Unit[] }>();
|
|
262
310
|
for (const unit of units) {
|
|
263
311
|
const prs = unit.stack.map((pr) => ({ repo: pr.repository.nameWithOwner, body: pr.body, linked: pr.closingIssuesReferences.nodes.map(prKey) }));
|
|
264
|
-
|
|
312
|
+
// Only my work goes under an issue; a stack only asking for my review stays a pull request [REV-01].
|
|
313
|
+
const issue = unit.own.length > 0 ? issueFor(prs, (key) => issues.has(key)) : undefined;
|
|
265
314
|
const key = issue ?? prKey(unit.stack[0]);
|
|
266
315
|
groups.set(key, { lead: issue ? issues.get(issue) : undefined, units: [...(groups.get(key)?.units ?? []), unit] });
|
|
267
316
|
}
|
|
@@ -290,36 +339,12 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
290
339
|
wait: issueWaiting ? undefined : unit.wait,
|
|
291
340
|
actions: issueWaiting ? replyActions(issueWaiting) : unit.actions,
|
|
292
341
|
children: lead ? grouped.flatMap((u) => u.stack.map((pr, i) => subRow(pr, i, u.stack))) : unit.stack.slice(1).map((pr, i) => subRow(pr, i + 1, unit.stack)),
|
|
293
|
-
|
|
342
|
+
// Actions on GitHub act on my PRs, from my bottom one; Review checks out the top of the stack [ATT-04].
|
|
343
|
+
target: target(unit.own[0] ?? bottom, unit.stack),
|
|
294
344
|
othersActivityAt: latest(...grouped.map((u) => u.othersActivityAt), issueWaiting?.since),
|
|
295
345
|
});
|
|
296
346
|
}
|
|
297
347
|
|
|
298
|
-
// Review requests [REV-01].
|
|
299
|
-
for (const pr of compact(data.reviews.nodes)) {
|
|
300
|
-
const key = prKey(pr);
|
|
301
|
-
if (listed.has(key)) continue;
|
|
302
|
-
listed.add(key);
|
|
303
|
-
const s = state(pr);
|
|
304
|
-
const waiting = mentions.get(key);
|
|
305
|
-
items.push({
|
|
306
|
-
key,
|
|
307
|
-
section: waiting ? "reply" : "review",
|
|
308
|
-
kind: "pr",
|
|
309
|
-
draft: pr.isDraft,
|
|
310
|
-
repo: pr.repository.nameWithOwner,
|
|
311
|
-
number: pr.number,
|
|
312
|
-
title: pr.title,
|
|
313
|
-
url: pr.url,
|
|
314
|
-
chips: s.ciFailing ? [chip("CI failing", "bad")] : [],
|
|
315
|
-
person: waiting ?? person(pr.author, s.lastCommitAt),
|
|
316
|
-
actions: waiting ? [...replyActions(waiting), "review"] : ["review"],
|
|
317
|
-
children: [],
|
|
318
|
-
target: target(pr, [pr]),
|
|
319
|
-
othersActivityAt: latest(s.othersActivityAt, s.lastCommitAt, waiting?.since),
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
348
|
// Remaining mentions, including other people's drafts [MEN-03].
|
|
324
349
|
for (const node of compact(data.mentions.nodes)) {
|
|
325
350
|
const key = prKey(node);
|
package/server/context.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { ownStack, type StackPr, type Target } from "../shared/attention";
|
|
2
2
|
import type { SessionKind } from "../shared/config";
|
|
3
3
|
import { graphql, runGh } from "./gh";
|
|
4
4
|
|
|
@@ -21,16 +21,29 @@ async function ghJson<T>(args: string[]): Promise<T> {
|
|
|
21
21
|
|
|
22
22
|
export async function sessionContext(kind: SessionKind, target: Target): Promise<string> {
|
|
23
23
|
const ref = [String(target.number), "--repo", target.repo];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return `Branches, bottom first:\n${stack.map((pr) => `- #${pr.number}: ${pr.head} (on ${pr.base})`).join("\n")}`;
|
|
27
|
-
}
|
|
24
|
+
// Only my branches are rebased and pushed, never others' in the same stack [ATT-04].
|
|
25
|
+
if (kind === "rebase" || kind === "refresh") return `Branches, bottom first:\n${ownStack(target).map(branchLine).join("\n")}`;
|
|
28
26
|
if (kind === "fix") return failingChecks(ref, target.repo);
|
|
29
27
|
if (kind === "address") return reviewFeedback(target);
|
|
30
28
|
|
|
29
|
+
// Review of a stack: every branch, and the description and latest comments of each PR asking for my review [ATT-04].
|
|
30
|
+
const stack = target.stack ?? [];
|
|
31
|
+
if (kind === "review" && stack.length > 1) {
|
|
32
|
+
const asking = stack.filter((pr) => pr.review);
|
|
33
|
+
const lines = stack.map((pr) => `${branchLine(pr)}${pr.review ? ", review requested" : ", mine"}`);
|
|
34
|
+
const prs = await Promise.all(asking.map(async (pr) => `#${pr.number}\n${await conversation([String(pr.number), "--repo", target.repo], "pr")}`));
|
|
35
|
+
return [`Stack, bottom first:\n${lines.join("\n")}`, ...prs].join("\n\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
// review, start: the description and the latest comments.
|
|
39
|
+
return conversation(ref, target.kind);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const branchLine = (pr: StackPr) => `- #${pr.number}: ${pr.head} (on ${pr.base})`;
|
|
43
|
+
|
|
44
|
+
async function conversation(ref: string[], kind: Target["kind"]): Promise<string> {
|
|
32
45
|
type View = { body: string; comments: { author: { login: string }; body: string }[] };
|
|
33
|
-
const view = await ghJson<View>([
|
|
46
|
+
const view = await ghJson<View>([kind === "pr" ? "pr" : "issue", "view", ...ref, "--json", "body,comments"]);
|
|
34
47
|
const comments = view.comments.slice(-5).map((c) => `@${c.author.login}: ${clip(c.body, 800)}`);
|
|
35
48
|
return [`Description:\n${clip(view.body) || "(empty)"}`, comments.length ? `Recent comments:\n${comments.join("\n\n")}` : ""].filter(Boolean).join("\n\n");
|
|
36
49
|
}
|
package/server/details.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FailingChecks, type ItemDetails, ownStack, type Target } from "../shared/attention";
|
|
2
2
|
import { graphql, runGh } from "./gh";
|
|
3
3
|
|
|
4
4
|
// What an item's sheet shows beyond the card, fetched when it opens [ATT-06, GH-01].
|
|
@@ -32,7 +32,9 @@ const repository = (repo: string) => {
|
|
|
32
32
|
// One GraphQL request, plus one REST call per failing workflow run for its attempt number.
|
|
33
33
|
export async function itemDetails(subject: Subject, target: Target | undefined, checks: boolean): Promise<ItemDetails> {
|
|
34
34
|
const pr = target?.kind === "pr" ? target : undefined;
|
|
35
|
-
|
|
35
|
+
// Rerun covers my PRs in the stack, not others' asking for my review [ATT-04].
|
|
36
|
+
const mine = pr ? ownStack(pr) : [];
|
|
37
|
+
const numbers = pr ? (checks && mine.length > 0 ? mine.map((p) => p.number) : [pr.number]) : [];
|
|
36
38
|
const contexts = `commits(last: 1) { nodes { commit { statusCheckRollup { contexts(first: 100) { nodes {
|
|
37
39
|
__typename
|
|
38
40
|
... on CheckRun { name conclusion checkSuite { workflowRun { databaseId } } }
|
package/server/feedback.ts
CHANGED
|
@@ -16,13 +16,19 @@ export async function feedbackInfo(): Promise<FeedbackInfo> {
|
|
|
16
16
|
|
|
17
17
|
// Paseo evaluates the server as a bundle, so it has no file location of its own (import.meta.url is undefined).
|
|
18
18
|
// Paseo's config.json records where each plugin's source is: take this plugin's, by its manifest's ID.
|
|
19
|
-
export function pluginDir(paseoHome
|
|
19
|
+
export function pluginDir(paseoHome?: string): string | null {
|
|
20
|
+
return ourInstall(paseoHome)?.path ?? null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The runtime ID this plugin is installed under, and its source. The update check names the ID [UPD-01].
|
|
24
|
+
export function ourInstall(paseoHome = process.env.PASEO_HOME || join(homedir(), ".paseo")): { id: string; path: string } | null {
|
|
20
25
|
try {
|
|
21
26
|
const { plugins = {} } = JSON.parse(readFileSync(join(paseoHome, "config.json"), "utf8")) as { plugins?: Record<string, { path?: string }> };
|
|
22
27
|
const ours = Object.entries(plugins)
|
|
23
28
|
.filter(([, source]) => source.path && manifestId(source.path) === PLUGIN_ID)
|
|
24
29
|
.sort(([a], [b]) => Number(b === PLUGIN_ID) - Number(a === PLUGIN_ID));
|
|
25
|
-
|
|
30
|
+
const [id, source] = ours[0] ?? [];
|
|
31
|
+
return id && source?.path ? { id, path: source.path } : null;
|
|
26
32
|
} catch {
|
|
27
33
|
return null;
|
|
28
34
|
}
|
package/server/fixture.ts
CHANGED
|
@@ -174,7 +174,13 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
174
174
|
pr(128, { title: "Lazy-load product images", reviewDecision: "APPROVED", mergeStateStatus: "UNSTABLE" }, "FAILURE"),
|
|
175
175
|
pr(129, { title: "Compress API responses", reviewDecision: "APPROVED", mergeStateStatus: "UNSTABLE" }, "PENDING"),
|
|
176
176
|
],
|
|
177
|
-
reviews: [
|
|
177
|
+
reviews: [
|
|
178
|
+
pr(120, { title: "Add a status page", author: bob }),
|
|
179
|
+
pr(121, { title: "Rework the cart totals", author: alice }),
|
|
180
|
+
// Bob's stack asking for my review: one item with one Review [ATT-04].
|
|
181
|
+
pr(196, { title: "Price rules: data model", author: bob, headRefName: "rules-1", commits: commit("SUCCESS", 0.4) }),
|
|
182
|
+
pr(197, { title: "Price rules: admin screen", author: bob, baseRefName: "rules-1", headRefName: "rules-2", commits: commit("SUCCESS", 0.3) }),
|
|
183
|
+
],
|
|
178
184
|
mentions: [
|
|
179
185
|
mention(95, [comment(bob, "@me should reminders go out on weekends too, or only on workdays?", 0.5)], { title: "Customers forget unpaid invoices", author: bob }),
|
|
180
186
|
mention(121, [comment(alice, "@me could you look at the rounding in `totals.ts` first? That's the **risky** part.", 0.2)], { __typename: "PullRequest", title: "Rework the cart totals" }),
|
|
@@ -261,6 +267,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
261
267
|
// Each sits in its action's line in the sheet. Issue 90 has two: an old one with no kind, which leads, and Rebase stack on its PR.
|
|
262
268
|
// #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
|
|
263
269
|
// #120's was started outside Attention Span, in a workspace Paseo linked to the PR, so it has no kind [SES-08].
|
|
270
|
+
// #197's too, so it shows on its stack, led by #196 [ATT-04].
|
|
264
271
|
const agent = (id: string, itemKey: string, kind: SessionKind | undefined, status: string, minutesAgo: number, requiresAttention = false): AgentSummary => ({
|
|
265
272
|
id,
|
|
266
273
|
itemKey,
|
|
@@ -280,6 +287,7 @@ export const FIXTURE_AGENTS: AgentSummary[] = [
|
|
|
280
287
|
agent("agent-103", `${REPO}#103`, "rebase", "running", 6),
|
|
281
288
|
agent("agent-113", `${REPO}#113`, "fix", "running", 2),
|
|
282
289
|
agent("agent-120", `${REPO}#120`, undefined, "running", 3),
|
|
290
|
+
agent("agent-197", `${REPO}#197`, undefined, "idle", 15),
|
|
283
291
|
];
|
|
284
292
|
|
|
285
293
|
export const FIXTURE_CONTEXT = "Context from GitHub would go here (fixture mode).";
|
package/server/service.ts
CHANGED
|
@@ -123,6 +123,16 @@ export class AttentionService {
|
|
|
123
123
|
await this.save();
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
// "Not now" on an update notice holds until a newer one [UPD-01].
|
|
127
|
+
get skippedUpdate(): string | null {
|
|
128
|
+
return this.state.skippedUpdate;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async skipUpdate(latest: string): Promise<void> {
|
|
132
|
+
this.state.skippedUpdate = latest;
|
|
133
|
+
await this.save();
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
// Who reviewed or was asked on my PRs in a repo, from the last fetch, and who I am [PRS-12].
|
|
127
137
|
reviewers(repo: string): { recent: Reviewer[]; login: string | null } {
|
|
128
138
|
const live = this.state.live?.attention;
|
package/server/store.ts
CHANGED
|
@@ -23,6 +23,8 @@ export const State = z.object({
|
|
|
23
23
|
scopes: z.array(z.string()).default([]),
|
|
24
24
|
// Sources ticked in Next up's filter; none means all [NXT-09].
|
|
25
25
|
sources: z.array(z.string()).default([]),
|
|
26
|
+
// The update notice put off with Not now, by the version it offered [UPD-01].
|
|
27
|
+
skippedUpdate: z.string().nullable().default(null).catch(null),
|
|
26
28
|
// My Paseo projects' GitHub repos when last listed, for refreshes before the app has connected [NXT-08].
|
|
27
29
|
projectRepos: z.array(z.string()).default([]),
|
|
28
30
|
// The last fetch of each feed. A cache from an older version is dropped rather than shown wrong.
|
package/server/update.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { type UpdateNotice, updateNotice } from "../shared/update";
|
|
4
|
+
import { ourInstall } from "./feedback";
|
|
5
|
+
import { FIXTURE } from "./gh";
|
|
6
|
+
|
|
7
|
+
const run = promisify(execFile);
|
|
8
|
+
|
|
9
|
+
// Paseo's registry checks npm twice a day, so a release reaches its listing within about 12 hours [UPD-01].
|
|
10
|
+
const EVERY_MS = 12 * 60 * 60 * 1000;
|
|
11
|
+
// A check that failed (offline, an older Paseo) is tried again sooner.
|
|
12
|
+
const RETRY_MS = 60 * 60 * 1000;
|
|
13
|
+
|
|
14
|
+
// Previews have nothing to update; PASEO_ATTENTION_SPAN_FIXTURE_UPDATE=1 makes one up to show the notice.
|
|
15
|
+
const FIXTURE_UPDATE: UpdateNotice = {
|
|
16
|
+
id: "attention-span",
|
|
17
|
+
current: "0.4.3",
|
|
18
|
+
latest: "0.5.0",
|
|
19
|
+
source: "registry",
|
|
20
|
+
args: ["--yes"],
|
|
21
|
+
command: "paseo plugin update attention-span",
|
|
22
|
+
notes: "https://github.com/andrioid/paseo-attention-span/releases",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Asks Paseo itself, so the answer is what `paseo plugin update` would install: a registry install's
|
|
26
|
+
// reviewed pin, npm's latest, or a Git remote's HEAD. Directory installs are never updated, so they say nothing.
|
|
27
|
+
export class UpdateCheck {
|
|
28
|
+
private last: { at: number; ttl: number; notice: UpdateNotice | null } | null = null;
|
|
29
|
+
private inFlight: Promise<UpdateNotice | null> | null = null;
|
|
30
|
+
// Why the last Update failed. A successful one restarts this process, so nothing needs remembering then.
|
|
31
|
+
private failed: { latest: string; error: string } | null = null;
|
|
32
|
+
|
|
33
|
+
async get(): Promise<UpdateNotice | null> {
|
|
34
|
+
const notice = await this.cached();
|
|
35
|
+
return notice && this.failed?.latest === notice.latest ? { ...notice, error: this.failed.error } : notice;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private cached(): Promise<UpdateNotice | null> {
|
|
39
|
+
if (this.last && Date.now() - this.last.at < this.last.ttl) return Promise.resolve(this.last.notice);
|
|
40
|
+
this.inFlight ??= check()
|
|
41
|
+
.then(
|
|
42
|
+
(notice) => (this.last = { at: Date.now(), ttl: EVERY_MS, notice }),
|
|
43
|
+
(error) => {
|
|
44
|
+
console.error("Checking for an Attention Span update failed:", (error as Error).message);
|
|
45
|
+
return (this.last = { at: Date.now(), ttl: RETRY_MS, notice: null });
|
|
46
|
+
},
|
|
47
|
+
)
|
|
48
|
+
.then((last) => last.notice)
|
|
49
|
+
.finally(() => (this.inFlight = null));
|
|
50
|
+
return this.inFlight;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Update, from an explicit tap on the version it names [SAFE-01]. `paseo plugin update` installs it and
|
|
54
|
+
// restarts the plugin, which ends this process, so it runs detached and outlives it. Until then, a failure
|
|
55
|
+
// is kept for the notice to show.
|
|
56
|
+
async apply(latest: string): Promise<void> {
|
|
57
|
+
const notice = await this.cached();
|
|
58
|
+
if (!notice || notice.latest !== latest) throw new Error(`${latest} isn't the update on offer any more. Check again.`);
|
|
59
|
+
this.failed = null;
|
|
60
|
+
// Previews show how a failed update looks.
|
|
61
|
+
if (FIXTURE) return void (this.failed = { latest, error: "Previews don't update." });
|
|
62
|
+
const cli = process.env.PASEO_CLI || "paseo";
|
|
63
|
+
const child = spawn(cli, ["plugin", "update", notice.id, ...notice.args, "--json", ...home()], { detached: true, stdio: ["ignore", "pipe", "pipe"] });
|
|
64
|
+
let output = "";
|
|
65
|
+
child.stdout.on("data", (chunk) => (output += chunk));
|
|
66
|
+
child.stderr.on("data", (chunk) => (output += chunk));
|
|
67
|
+
child.on("error", (error) => (this.failed = { latest, error: error.message }));
|
|
68
|
+
child.on("close", (code) => {
|
|
69
|
+
const error = failure(notice.id, output, code);
|
|
70
|
+
if (error) {
|
|
71
|
+
console.error("Updating Attention Span failed:", error);
|
|
72
|
+
this.failed = { latest, error };
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
child.unref();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function check(): Promise<UpdateNotice | null> {
|
|
80
|
+
if (FIXTURE) return process.env.PASEO_ATTENTION_SPAN_FIXTURE_UPDATE === "1" ? FIXTURE_UPDATE : null;
|
|
81
|
+
const ours = ourInstall();
|
|
82
|
+
if (!ours) return null;
|
|
83
|
+
// Paseo gives its plugins the path of its CLI and its home, so this asks the daemon the plugin runs in.
|
|
84
|
+
const cli = process.env.PASEO_CLI || "paseo";
|
|
85
|
+
try {
|
|
86
|
+
const { stdout } = await run(cli, ["plugin", "update", ours.id, "--check", "--json", ...home()], { timeout: 60_000 });
|
|
87
|
+
return updateNotice(ours.id, JSON.parse(stdout));
|
|
88
|
+
} catch (error) {
|
|
89
|
+
// An "error" outcome exits 1 but still prints its JSON.
|
|
90
|
+
throw new Error(failure(ours.id, (error as { stdout?: string }).stdout ?? "", 1) ?? (error as Error).message);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const home = () => (process.env.PASEO_HOME ? ["--home", process.env.PASEO_HOME] : []);
|
|
95
|
+
|
|
96
|
+
// The CLI's reason for this plugin, from its JSON, or its output; null when it worked.
|
|
97
|
+
export function failure(id: string, output: string, code: number | null): string | null {
|
|
98
|
+
try {
|
|
99
|
+
const entry = (JSON.parse(output) as { id?: string; outcome?: string; error?: string }[]).find((candidate) => candidate.id === id);
|
|
100
|
+
if (entry?.outcome === "error") return entry.error ?? "paseo plugin update failed";
|
|
101
|
+
if (entry && code === 0) return null;
|
|
102
|
+
} catch {
|
|
103
|
+
// Not JSON: an older CLI, or it failed before it got that far.
|
|
104
|
+
}
|
|
105
|
+
return code === 0 ? null : output.trim().split("\n").pop() || `paseo plugin update exited with ${code}`;
|
|
106
|
+
}
|
package/shared/attention.ts
CHANGED
|
@@ -144,8 +144,27 @@ export interface Target {
|
|
|
144
144
|
headRefOid?: string;
|
|
145
145
|
defaultBranch?: string;
|
|
146
146
|
mergeMethod?: MergeMethod;
|
|
147
|
-
// Every PR in the stack, bottom first.
|
|
148
|
-
stack?:
|
|
147
|
+
// Every PR in the stack, bottom first: mine, and others' that ask for my review [ATT-04].
|
|
148
|
+
stack?: StackPr[];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface StackPr {
|
|
152
|
+
number: number;
|
|
153
|
+
head: string;
|
|
154
|
+
base: string;
|
|
155
|
+
// Someone else's, asking for my review; the rest are mine.
|
|
156
|
+
review?: true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// The PRs of mine in a target's stack: what Rebase, Refresh and Rerun act on. Others' branches are never pushed [ATT-04].
|
|
160
|
+
export function ownStack(target: Pick<Target, "stack">): StackPr[] {
|
|
161
|
+
return (target.stack ?? []).filter((pr) => !pr.review);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// The PR a session checks out: for Review of a stack, its top, which has every PR's changes; otherwise the target [ATT-04].
|
|
165
|
+
export function checkoutPr(kind: SessionKind, target: Pick<Target, "number" | "headRefName" | "stack">): { number: number; head?: string } {
|
|
166
|
+
const top = target.stack?.at(-1);
|
|
167
|
+
return kind === "review" && top && target.stack!.length > 1 ? { number: top.number, head: top.head } : { number: target.number, head: target.headRefName };
|
|
149
168
|
}
|
|
150
169
|
|
|
151
170
|
export interface SubRow {
|
package/shared/prompts.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ActionId, ownStack, type Target } from "./attention";
|
|
2
2
|
import type { AttentionConfig, SessionKind } from "./config";
|
|
3
3
|
|
|
4
4
|
// Built-in prompt templates [SES-04]. A template in config.json replaces one.
|
|
5
|
-
// Placeholders: {{repo}} {{number}} {{title}} {{url}} {{head}} {{base}} {{stack}} {{context}}
|
|
5
|
+
// Placeholders: {{repo}} {{number}} {{title}} {{url}} {{head}} {{base}} {{stack}} {{review}} {{context}}
|
|
6
|
+
// For Review of a stack, {{head}} is its top branch and {{review}} the PRs asking for my review.
|
|
7
|
+
const SWEEP = `Browser sweep, only if you're equipped to (you can run this repo's app and have browser tools): work out which pages and screens the change affects and check each one. If you can't, skip this and say so. Don't spend the session getting the app to run.`;
|
|
8
|
+
|
|
6
9
|
export const PROMPT_TEMPLATES: Record<SessionKind, string> = {
|
|
7
10
|
review: `Review pull request {{repo}}#{{number}}: "{{title}}" ({{url}}). You are in a checkout of the PR branch.
|
|
8
11
|
|
|
9
12
|
1. Review: read the description and the diff against {{base}}.
|
|
10
13
|
2. Investigate: dig into anything risky or unclear in the code it touches.
|
|
11
|
-
3.
|
|
14
|
+
3. ${SWEEP}
|
|
12
15
|
4. Report back:
|
|
13
16
|
- Findings, most important first.
|
|
14
17
|
- Verdict: approve, request changes or comment, with a one-line reason.
|
|
@@ -59,6 +62,21 @@ Read the issue and the code it touches, then propose a plan before changing anyt
|
|
|
59
62
|
{{context}}`,
|
|
60
63
|
};
|
|
61
64
|
|
|
65
|
+
// Review of a stack, while config.json doesn't replace the review template: one session for every PR asking for my review [ATT-04].
|
|
66
|
+
export const REVIEW_STACK_TEMPLATE = `Review the pull requests {{review}} in {{repo}}, part of the stack {{stack}} (bottom first). You are in a checkout of the top branch, {{head}}, which has every PR's changes.
|
|
67
|
+
|
|
68
|
+
1. Review: for each of {{review}}, read its description and its diff against its own base (\`git diff origin/<base>...origin/<head>\`, branches below). Review only those; the rest of the stack is context.
|
|
69
|
+
2. Investigate: dig into anything risky or unclear in the code they touch.
|
|
70
|
+
3. ${SWEEP}
|
|
71
|
+
4. Report back, for each PR:
|
|
72
|
+
- Findings, most important first.
|
|
73
|
+
- Verdict: approve, request changes or comment, with a one-line reason.
|
|
74
|
+
- Draft review comments, ready to paste, each with file:line.
|
|
75
|
+
|
|
76
|
+
Do not post anything to GitHub.
|
|
77
|
+
|
|
78
|
+
{{context}}`;
|
|
79
|
+
|
|
62
80
|
export const ACTION_SESSION: Partial<Record<ActionId, SessionKind>> = {
|
|
63
81
|
review: "review",
|
|
64
82
|
fix: "fix",
|
|
@@ -74,15 +92,22 @@ export function renderPrompt(
|
|
|
74
92
|
context: string,
|
|
75
93
|
config: Pick<AttentionConfig, "prompts">,
|
|
76
94
|
): string {
|
|
77
|
-
const
|
|
95
|
+
const stack = target.stack ?? [];
|
|
96
|
+
const reviewStack = kind === "review" && stack.length > 1;
|
|
97
|
+
const template = config.prompts[kind] ?? (reviewStack ? REVIEW_STACK_TEMPLATE : PROMPT_TEMPLATES[kind]);
|
|
98
|
+
// Review reads the whole stack; the rest act on my PRs in it [ATT-04].
|
|
99
|
+
const shown = kind === "review" ? stack : ownStack(target);
|
|
100
|
+
const asking = stack.filter((pr) => pr.review);
|
|
101
|
+
const numbers = (prs: { number: number }[], join: string) => (prs.length ? prs : [{ number: target.number }]).map((pr) => `#${pr.number}`).join(join);
|
|
78
102
|
const values: Record<string, string> = {
|
|
79
103
|
repo: target.repo,
|
|
80
104
|
number: String(target.number),
|
|
81
105
|
title: target.title,
|
|
82
106
|
url: target.url,
|
|
83
|
-
head: target.headRefName ?? "",
|
|
107
|
+
head: (reviewStack ? stack.at(-1)?.head : target.headRefName) ?? "",
|
|
84
108
|
base: target.baseRefName ?? target.defaultBranch ?? "",
|
|
85
|
-
stack: (
|
|
109
|
+
stack: numbers(shown, " → "),
|
|
110
|
+
review: numbers(asking.length ? asking : shown, ", "),
|
|
86
111
|
context: context.trim(),
|
|
87
112
|
};
|
|
88
113
|
return template.replace(/\{\{(\w+)\}\}/g, (match, name: string) => values[name] ?? match).trim();
|
package/shared/rpc.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { SessionKind } from "./config";
|
|
|
5
5
|
import type { ConfigStatus, CoverageCheck, SetupStatus } from "./setup";
|
|
6
6
|
import type { FeedbackInfo } from "./feedback";
|
|
7
7
|
import type { ReadyProvider } from "./providers";
|
|
8
|
+
import type { UpdateNotice } from "./update";
|
|
8
9
|
|
|
9
10
|
// Both sides are this plugin, so the types are checked by TypeScript, not repeated as schemas.
|
|
10
11
|
const view = z.custom<AttentionView>();
|
|
@@ -76,3 +77,9 @@ export const sessionContext = defineRpc({
|
|
|
76
77
|
export const feedbackInfo = defineRpc({ name: "feedback.info", input: z.object({}), output: z.custom<FeedbackInfo>() });
|
|
77
78
|
// The host's ready providers, read by the plugin's server: the app's own snapshot can arrive compact, with no entries [SES-06].
|
|
78
79
|
export const readyProviders = defineRpc({ name: "providers.ready", input: z.object({}), output: z.custom<{ providers: ReadyProvider[] }>() });
|
|
80
|
+
|
|
81
|
+
// A newer Attention Span, by Paseo's own update check; null when there's none or it was put off [UPD-01].
|
|
82
|
+
export const checkUpdate = defineRpc({ name: "update.check", input: z.object({}), output: z.custom<UpdateNotice | null>() });
|
|
83
|
+
// Starts `paseo plugin update` for the version on offer; it restarts the plugin when it's done.
|
|
84
|
+
export const applyUpdate = defineRpc({ name: "update.apply", input: z.object({ latest: z.string() }), output: done });
|
|
85
|
+
export const skipUpdate = defineRpc({ name: "update.skip", input: z.object({ latest: z.string() }), output: done });
|
package/shared/update.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FEEDBACK_REPO } from "./feedback";
|
|
2
|
+
|
|
3
|
+
// A newer Attention Span than the one installed, as Paseo's own update check sees it [UPD-01].
|
|
4
|
+
export interface UpdateNotice {
|
|
5
|
+
// The runtime ID it's installed under, which the command names.
|
|
6
|
+
id: string;
|
|
7
|
+
// A version for npm and registry installs, a short commit for Git ones.
|
|
8
|
+
current: string;
|
|
9
|
+
latest: string;
|
|
10
|
+
// Where it comes from, said next to Update.
|
|
11
|
+
source: "registry" | "npm" | "git";
|
|
12
|
+
// What Update adds to `paseo plugin update <id>`, pinned to what was offered where Paseo allows it.
|
|
13
|
+
args: string[];
|
|
14
|
+
// To run by hand when Update fails.
|
|
15
|
+
command: string;
|
|
16
|
+
// Where to read what changed.
|
|
17
|
+
notes: string;
|
|
18
|
+
// Why the last Update failed, if it did.
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// The entry for one plugin in `paseo plugin update <id> --check --json`. Only what's read here.
|
|
23
|
+
interface CheckEntry {
|
|
24
|
+
id?: string;
|
|
25
|
+
outcome?: string;
|
|
26
|
+
current?: { currentRevision?: string; identity?: { registry?: unknown } };
|
|
27
|
+
target?: { kind?: string; version?: string; commit?: string };
|
|
28
|
+
links?: string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Only "update" is news; "current", "local" (a directory install, which Paseo never updates) and "error" aren't.
|
|
32
|
+
export function updateNotice(id: string, checked: unknown): UpdateNotice | null {
|
|
33
|
+
const entries = (Array.isArray(checked) ? checked : []) as CheckEntry[];
|
|
34
|
+
const entry = entries.find((candidate) => candidate?.id === id);
|
|
35
|
+
if (entry?.outcome !== "update") return null;
|
|
36
|
+
const current = entry.current?.currentRevision;
|
|
37
|
+
const latest = entry.target?.kind === "git" ? entry.target.commit : entry.target?.version;
|
|
38
|
+
if (!current || !latest || current === latest) return null;
|
|
39
|
+
const git = entry.target?.kind === "git";
|
|
40
|
+
const source = git ? "git" : entry.current?.identity?.registry ? "registry" : "npm";
|
|
41
|
+
// A registry install takes only its reviewed pin, so it can't be named; npm and Git can, so a newer one can't slip in.
|
|
42
|
+
const args = source === "registry" ? ["--yes"] : git ? ["--ref", latest] : ["--version", latest];
|
|
43
|
+
// A Git install moves by commit, so Paseo's compare link is what changed; a release has notes on GitHub.
|
|
44
|
+
const compare = git ? entry.links?.find((link) => link.includes("/compare/")) : undefined;
|
|
45
|
+
return { id, current: short(current), latest: short(latest), source, args, command: `paseo plugin update ${id}`, notes: compare ?? `https://github.com/${FEEDBACK_REPO}/releases` };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const short = (revision: string) => (/^[0-9a-f]{40}$/.test(revision) ? revision.slice(0, 7) : revision);
|