@andrioid/paseo-attention-span 0.4.3 → 0.4.5
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 +2 -1
- package/client/attention-screen.tsx +13 -3
- package/client/update.tsx +85 -0
- package/docs/architecture.md +15 -3
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
- package/docs/screenshots/desktop-dark-history.png +0 -0
- package/index.server.ts +9 -0
- package/package.json +1 -1
- package/requirements.yaml +4 -0
- package/server/classify.ts +11 -4
- package/server/feedback.ts +8 -2
- package/server/fixture.ts +20 -5
- package/server/github-types.ts +6 -3
- package/server/queries.ts +4 -3
- package/server/service.ts +10 -0
- package/server/store.ts +2 -0
- package/server/update.ts +106 -0
- package/server/view.ts +10 -3
- package/shared/attention.ts +5 -0
- package/shared/format.ts +7 -4
- package/shared/rpc.ts +7 -0
- package/shared/update.ts +48 -0
- package/shared/work.ts +76 -0
package/OVERVIEW.md
CHANGED
|
@@ -67,7 +67,7 @@ Some orgs keep issues in a separate repo from the code. When that happens, the f
|
|
|
67
67
|
|
|
68
68
|
The issues and PRs you finished in recent weeks, grouped by week, plus the PRs you reviewed that got merged. Reviews are work too, even if nobody counts them.
|
|
69
69
|
|
|
70
|
-
There's a copy button per week that gives you a Markdown list of links. That's my standup prep now, and it takes about four seconds.
|
|
70
|
+
There's a copy button per week that gives you a Markdown list of links, each led by what kind of work it was: 🐞 bug, 🚀 feature, 🔧 task, or 🔀 for a PR that's none of those. The kind comes from the issue type, else the labels, else a title like "fix: …", so it works whether or not your repos use issue types. Cards show it too. Issues closed as not planned stay out of the list. That's my standup prep now, and it takes about four seconds.
|
|
71
71
|
|
|
72
72
|

|
|
73
73
|
|
|
@@ -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)
|
|
@@ -7,6 +7,7 @@ import { Pressable, ScrollView, Text, View } from "react-native";
|
|
|
7
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
|
+
import { workEmoji } from "../shared/work";
|
|
10
11
|
import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
|
|
11
12
|
import * as rpc from "../shared/rpc";
|
|
12
13
|
import { type FeedbackKind, themeName } from "../shared/feedback";
|
|
@@ -20,6 +21,7 @@ import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
|
|
|
20
21
|
import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
|
|
21
22
|
import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
22
23
|
import { SetupChecklist } from "./setup";
|
|
24
|
+
import { UpdateNotice } from "./update";
|
|
23
25
|
import { Avatar, Button, KeepStyles, Loading, Meta, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
|
|
24
26
|
|
|
25
27
|
// The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
|
|
@@ -397,6 +399,7 @@ function AttentionList({
|
|
|
397
399
|
</View>
|
|
398
400
|
</View>
|
|
399
401
|
{feed.error ? <Text style={styles.danger}>{feed.error}</Text> : null}
|
|
402
|
+
<UpdateNotice />
|
|
400
403
|
|
|
401
404
|
{undoable.map((row) => (
|
|
402
405
|
<View key={row.id} style={[styles.panel, styles.row, { justifyContent: "space-between" }]}>
|
|
@@ -1031,7 +1034,7 @@ function weekLabel(monday: Date): string {
|
|
|
1031
1034
|
}
|
|
1032
1035
|
|
|
1033
1036
|
// What I finished, by week, with reviews tucked away per week [HIS-01, HIS-02].
|
|
1034
|
-
// A week copies as a list of links to paste into a report; reviews stay out of it [HIS-03].
|
|
1037
|
+
// A week copies as a list of links to paste into a report, each led by its kind; reviews stay out of it [HIS-03, HIS-04].
|
|
1035
1038
|
function History({ items, actions }: { items: Item[]; actions: Actions }) {
|
|
1036
1039
|
const styles = useStyles();
|
|
1037
1040
|
const copy = useCopy();
|
|
@@ -1046,6 +1049,8 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
|
|
|
1046
1049
|
for (const [week, all] of [...weeks].sort((a, b) => b[0] - a[0])) {
|
|
1047
1050
|
const done = all.filter((item) => item.section === "done").sort((a, b) => b.closedAt!.localeCompare(a.closedAt!));
|
|
1048
1051
|
const reviewed = all.filter((item) => item.section === "reviewed");
|
|
1052
|
+
// What was done, each led by its kind; not planned issues stay on screen but out of the report [HIS-03, HIS-04].
|
|
1053
|
+
const copied = done.filter((item) => !item.notPlanned);
|
|
1049
1054
|
const label = weekLabel(new Date(week));
|
|
1050
1055
|
blocks.push(
|
|
1051
1056
|
<View key={week} style={{ gap: 8 }}>
|
|
@@ -1054,12 +1059,17 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
|
|
|
1054
1059
|
title={label}
|
|
1055
1060
|
count={done.length}
|
|
1056
1061
|
action={
|
|
1057
|
-
|
|
1062
|
+
copied.length > 0 ? (
|
|
1058
1063
|
<Button
|
|
1059
1064
|
icon="copy"
|
|
1060
1065
|
variant="ghost"
|
|
1061
1066
|
accessibilityLabel={`Copy links from ${label}`}
|
|
1062
|
-
onPress={() =>
|
|
1067
|
+
onPress={() =>
|
|
1068
|
+
copy(
|
|
1069
|
+
linkList(copied.map((item) => ({ title: item.title, url: item.url, mark: workEmoji(item) }))),
|
|
1070
|
+
`Copied ${copied.length} link${copied.length === 1 ? "" : "s"} from ${label}`,
|
|
1071
|
+
)
|
|
1072
|
+
}
|
|
1063
1073
|
/>
|
|
1064
1074
|
) : null
|
|
1065
1075
|
}
|
|
@@ -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
|
|
|
@@ -48,7 +48,7 @@ The tabs tell the story of my work, left to right: what I finished, what needs m
|
|
|
48
48
|
|
|
49
49
|
| Tab | Shows |
|
|
50
50
|
|---|---|
|
|
51
|
-
| History | The last `historyWeeks` (default 4) by week, newest first, in the device's time zone: issues assigned to me that closed, with the PRs that closed them, and my other merged PRs [HIS-01]. Per week, a collapsed "Reviewed (n)" lists others' merged PRs I reviewed [HIS-02]. The copy icon on a week's heading copies its finished items, not the reviews, as a Markdown list of links; an issue and the PRs that closed it are one line, linking the issue [HIS-03]. |
|
|
51
|
+
| History | The last `historyWeeks` (default 4) by week, newest first, in the device's time zone: issues assigned to me that closed, with the PRs that closed them, and my other merged PRs [HIS-01]. Per week, a collapsed "Reviewed (n)" lists others' merged PRs I reviewed [HIS-02]. The copy icon on a week's heading copies its finished items, not the reviews, as a Markdown list of links; an issue and the PRs that closed it are one line, linking the issue; an issue closed as not planned isn't copied, and PRs that referred to it are listed on their own [HIS-03]. Each card has a plain chip (bug, feature or task) for what kind of work it was, and each copied line leads with its emoji: 🐞, 🚀 or 🔧; a PR of none of those leads with 🔀 and has no chip, an issue of none leads with nothing [HIS-04]. The first of these that names a kind decides: the issue type, the labels (bug beats feature beats task), a Conventional Commit title prefix (`fix:` bug, `feat:` feature, `chore:`, `refactor:`, `docs:`, `build:`, `ci:`, `test:`, `perf:`, `style:` task). Types and labels match only as whole names, ignoring case, emoji and wrappers like `type:` or `kind/`, so "bug", "Type: Bug 🐞" and "kind/bug" count but "not a bug" and "bug bash" don't. Until History is fetched again, what I just finished uses the issue type and title only. |
|
|
52
52
|
| Doing | The sections below |
|
|
53
53
|
| Waiting | My work where someone else has the next move [WAI-01]: *Waiting for review* (while GitHub records a review as owed: a pending request, or an approval or requested changes; or approved but blocked by a repo rule [PRS-13]), *Waiting for the reviewer* (after I replied or pushed), *CI running*, *Questions I asked* (threads where my comment is the last from a person, bots don't count, and my comments since someone else last spoke ask something: a question mark outside quotes, code and links, read from GitHub's rendered comments (`bodyHTML`) so code and links count however they were written; a statement, tagged or not, waits on nobody and isn't listed): on my own issues however old, on others' only while my comment is within `mentionDays` [ATT-11]. Each shows who it waits on, never a guess [WAI-02]: on a PR, the reviewers currently requested and, after I replied, whoever requested changes, but nobody when a repo rule blocks it; on a question, the people and teams my comments since the last answer tag, read from GitHub's rendered comments (`bodyHTML`), where only real accounts and teams I can see are linked, never in code; tags in quotes don't count, and only the last 10 comments are read. Waiting groups it all by who it waits on, not by those reasons [WAI-01]: one group per person or team (a person tagged with other capitals is one), whoever blocks the most items first, ties by whose oldest item has waited longest, then requested bots, who can't be nudged, and last *Not on a person* for work nobody is on record for. In each group, work with a session that needs me leads, then one that's working, then the rest, oldest first; a finished session I've seen doesn't lift it. Work waiting on several is under each, saying "also waiting on" the rest, and counts once in the tab. *Waiting too long* items show here too, flagged "waited too long". Each card says why it waits (review, re-review or question; nothing where its chips say, like approved, blocked by repo rules, or CI running) and since when. A group's **Copy list** copies its items oldest first as a Markdown list, each line led by why and how long ("- Review 2h: [title](url)"), for a nudge; a requested bot gets none [WAI-03]. Outside Waiting, as in *Waiting too long*, one person shows by name, several by picture, named on hover and in the sheet. |
|
|
54
54
|
| Next up | *Assigned to you* [NXT-06], then *Unclaimed* [NXT-01] |
|
|
@@ -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:
|
|
@@ -173,7 +185,7 @@ A live refresh is 8 requests and about 85 points, of the 5,000 GitHub allows per
|
|
|
173
185
|
|
|
174
186
|
### History
|
|
175
187
|
|
|
176
|
-
One request with three searches, each from the Monday `historyWeeks` back: `is:pr is:merged author:@me`, `is:pr is:merged reviewed-by:@me -author:@me`, `is:issue is:closed assignee:@me`. About
|
|
188
|
+
One request with three searches, each from the Monday `historyWeeks` back: `is:pr is:merged author:@me`, `is:pr is:merged reviewed-by:@me -author:@me`, `is:issue is:closed assignee:@me`. Each result brings up to 20 label names, and issues their type [HIS-04]. About 4 points, mostly the label lists.
|
|
177
189
|
|
|
178
190
|
Every search is scoped to the configured orgs and repos; Next up's unclaimed issues as described under Next up.
|
|
179
191
|
|
|
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.5",
|
|
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
|
@@ -104,9 +104,13 @@ functional:
|
|
|
104
104
|
HIS-01: see the issues and pull requests I finished, grouped by week; so that I can tell others what I got done.
|
|
105
105
|
HIS-02: see pull requests I reviewed that merged, apart from my own work; so that I can tell others what I got done.
|
|
106
106
|
HIS-03: copy a week's finished work as a Markdown list of links; so that reporting progress is one paste.
|
|
107
|
+
HIS-04: see what kind of work each finished item was, bug, feature or task, from its issue type, else its labels, else a Conventional Commit title like "fix: …", on its card and leading its copied line like "- 🐞 [title](link)", with PRs of no kind led by 🔀 and issues closed as not planned left out of the copy; so that a busy week's report skims at a glance in any repo.
|
|
107
108
|
feedback:
|
|
108
109
|
As a developer, I can:
|
|
109
110
|
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.
|
|
111
|
+
updates:
|
|
112
|
+
As a developer, I can:
|
|
113
|
+
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
114
|
|
|
111
115
|
non_functional:
|
|
112
116
|
github_usage:
|
package/server/classify.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "../shared/attention";
|
|
16
16
|
import type { AttentionConfig, MergeMethod } from "../shared/config";
|
|
17
17
|
import { ago, daysSince } from "../shared/format";
|
|
18
|
+
import { workChip, workKind } from "../shared/work";
|
|
18
19
|
import type { Actor, Comment, Details, HistoryResult, IssueNode, LinkedIssue, LiveResult, MentionNode, PickableNode, PullRequestNode, RequestedReviewer } from "./github-types";
|
|
19
20
|
import { asksQuestion, excerpt, plainText, taggedIn } from "./markdown";
|
|
20
21
|
import { prKey } from "./queries";
|
|
@@ -409,10 +410,16 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
409
410
|
export function classifyHistory(data: HistoryResult): Item[] {
|
|
410
411
|
const items: Item[] = [];
|
|
411
412
|
const closed = new Map<string, Item>();
|
|
413
|
+
// What kind of work it was, on the card and its copied line [HIS-04].
|
|
414
|
+
const kinded = (item: Item, node: { title: string; labels?: { nodes: { name: string }[] }; issueType?: { name: string } | null }): Item => {
|
|
415
|
+
const work = workKind({ type: node.issueType?.name, labels: node.labels?.nodes.map((label) => label.name), title: node.title });
|
|
416
|
+
return work ? { ...item, work, chips: [workChip(work), ...item.chips] } : item;
|
|
417
|
+
};
|
|
412
418
|
for (const issue of compact(data.closed.nodes)) {
|
|
413
419
|
const notPlanned = issue.stateReason === "NOT_PLANNED";
|
|
414
|
-
const item = { ...plain(issue, "issue", "done"), closedAt: issue.closedAt, chips: notPlanned ? [chip("not planned")] : [] };
|
|
415
|
-
|
|
420
|
+
const item = kinded({ ...plain(issue, "issue", "done"), closedAt: issue.closedAt, chips: notPlanned ? [chip("not planned")] : [], ...(notPlanned ? { notPlanned: true as const } : {}) }, issue);
|
|
421
|
+
// Not planned issues get no PRs under them: the PRs were still done, so they're listed on their own [HIS-03].
|
|
422
|
+
if (!notPlanned) closed.set(prKey(issue), item);
|
|
416
423
|
items.push(item);
|
|
417
424
|
}
|
|
418
425
|
for (const pr of compact(data.merged.nodes)) {
|
|
@@ -420,9 +427,9 @@ export function classifyHistory(data: HistoryResult): Item[] {
|
|
|
420
427
|
const linked = { repo: pr.repository.nameWithOwner, body: pr.body, linked: pr.closingIssuesReferences.nodes.map(prKey) };
|
|
421
428
|
const issue = closed.get(issueFor([linked], (key) => closed.has(key)) ?? "");
|
|
422
429
|
if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false });
|
|
423
|
-
else items.push({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt });
|
|
430
|
+
else items.push(kinded({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt }, pr));
|
|
424
431
|
}
|
|
425
|
-
for (const pr of compact(data.reviewed.nodes)) items.push({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: person(pr.author, pr.mergedAt) });
|
|
432
|
+
for (const pr of compact(data.reviewed.nodes)) items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: person(pr.author, pr.mergedAt) }, pr));
|
|
426
433
|
return items.sort(order);
|
|
427
434
|
}
|
|
428
435
|
|
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
|
@@ -121,21 +121,25 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
121
121
|
const key = (n: number) => `${REPO}#${n}`;
|
|
122
122
|
const closes = (number: number, title: string) => ({ nodes: [{ number, title, url: `https://github.com/${REPO}/issues/${number}`, repository }] });
|
|
123
123
|
const fields = (priority: string, effort: string, scope: string) => ({ Priority: priority, Effort: effort, Scope: scope });
|
|
124
|
-
const
|
|
124
|
+
const labels = (...names: string[]) => ({ nodes: names.map((name) => ({ name })) });
|
|
125
|
+
const merged = (number: number, title: string, days: number, closesIssue?: number, ...names: string[]) => ({
|
|
125
126
|
number,
|
|
126
127
|
title,
|
|
127
128
|
url: `https://github.com/${REPO}/pull/${number}`,
|
|
128
129
|
mergedAt: daysAgo(days),
|
|
129
130
|
repository,
|
|
131
|
+
labels: labels(...names),
|
|
130
132
|
closingIssuesReferences: { nodes: closesIssue ? [{ number: closesIssue, repository }] : [] },
|
|
131
133
|
});
|
|
132
|
-
const closed = (number: number, title: string, days: number, stateReason = "COMPLETED") => ({
|
|
134
|
+
const closed = (number: number, title: string, days: number, stateReason = "COMPLETED", type?: string, ...names: string[]) => ({
|
|
133
135
|
number,
|
|
134
136
|
title,
|
|
135
137
|
url: `https://github.com/${REPO}/issues/${number}`,
|
|
136
138
|
closedAt: daysAgo(days),
|
|
137
139
|
stateReason,
|
|
138
140
|
repository,
|
|
141
|
+
issueType: type ? { name: type } : null,
|
|
142
|
+
labels: labels(...names),
|
|
139
143
|
});
|
|
140
144
|
|
|
141
145
|
const data = search({
|
|
@@ -243,13 +247,24 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
243
247
|
{ ...pickable(164, fields("🏝 P3 Low", "🦑 Large (1-2w)", "📱 Mobile app"), 60, "Feature", "Offline mode for time tracking"), sources: ["org:acme"] },
|
|
244
248
|
{ ...pickable(165, {}, 3, "Task", "Devcontainers for pull requests", "me/tool"), sources: ["mine"] },
|
|
245
249
|
],
|
|
246
|
-
merged: [
|
|
250
|
+
merged: [
|
|
251
|
+
merged(170, "Nightly backup check", 1, 171),
|
|
252
|
+
merged(172, "Fix VAT on credit notes", 3, undefined, "bug"),
|
|
253
|
+
merged(177, "chore: bump the build image", 4),
|
|
254
|
+
merged(178, "Tidy the settings screen", 5),
|
|
255
|
+
merged(173, "Speed up the order list", 9, 174),
|
|
256
|
+
merged(175, "Remove the old importer", 16),
|
|
257
|
+
],
|
|
247
258
|
reviewed: [
|
|
248
|
-
{ number: 180, title: "New onboarding checklist", url: `https://github.com/${REPO}/pull/180`, mergedAt: daysAgo(2), repository, author: alice },
|
|
259
|
+
{ number: 180, title: "New onboarding checklist", url: `https://github.com/${REPO}/pull/180`, mergedAt: daysAgo(2), repository, author: alice, labels: labels("feature") },
|
|
249
260
|
{ number: 181, title: "Bump dependencies", url: `https://github.com/${REPO}/pull/181`, mergedAt: daysAgo(4), repository, author: bob },
|
|
250
261
|
{ number: 182, title: "Sentry release tracking", url: `https://github.com/${REPO}/pull/182`, mergedAt: daysAgo(11), repository, author: alice },
|
|
251
262
|
],
|
|
252
|
-
closed: [
|
|
263
|
+
closed: [
|
|
264
|
+
closed(171, "Backups are never verified", 1, "COMPLETED", "Feature"),
|
|
265
|
+
closed(174, "Order list takes 8 seconds", 9, "COMPLETED", undefined, "type: bug"),
|
|
266
|
+
closed(176, "Dark mode for the admin", 10, "NOT_PLANNED", undefined, "enhancement"),
|
|
267
|
+
],
|
|
253
268
|
});
|
|
254
269
|
return {
|
|
255
270
|
data,
|
package/server/github-types.ts
CHANGED
|
@@ -120,10 +120,13 @@ export interface LiveResult {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// One request for all three [HIS-01, HIS-02].
|
|
123
|
+
// Labels say what kind of work a finished item was [HIS-04].
|
|
124
|
+
type Labels = { labels?: Nodes<{ name: string }> };
|
|
125
|
+
|
|
123
126
|
export interface HistoryResult {
|
|
124
|
-
merged: Nodes<{ number: number; title: string; url: string; body?: string; mergedAt: string; repository: Repo; closingIssuesReferences: Nodes<{ number: number; repository: Repo }> }>;
|
|
125
|
-
reviewed: Nodes<{ number: number; title: string; url: string; mergedAt: string; repository: Repo; author: Actor | null }>;
|
|
126
|
-
closed: Nodes<{ number: number; title: string; url: string; closedAt: string; stateReason: string | null; repository: Repo }>;
|
|
127
|
+
merged: Nodes<{ number: number; title: string; url: string; body?: string; mergedAt: string; repository: Repo; closingIssuesReferences: Nodes<{ number: number; repository: Repo }> } & Labels>;
|
|
128
|
+
reviewed: Nodes<{ number: number; title: string; url: string; mergedAt: string; repository: Repo; author: Actor | null } & Labels>;
|
|
129
|
+
closed: Nodes<{ number: number; title: string; url: string; closedAt: string; stateReason: string | null; repository: Repo; issueType?: { name: string } | null } & Labels>;
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
export type SearchResult = LiveResult & HistoryResult;
|
package/server/queries.ts
CHANGED
|
@@ -30,10 +30,11 @@ const SEARCHES = {
|
|
|
30
30
|
unclaimed: { first: 100, nodes: "...pickable" },
|
|
31
31
|
merged: {
|
|
32
32
|
first: 100,
|
|
33
|
-
nodes: "... on PullRequest { number title url body mergedAt repository { nameWithOwner } closingIssuesReferences(first: 3) { nodes { number repository { nameWithOwner } } } }",
|
|
33
|
+
nodes: "... on PullRequest { number title url body mergedAt repository { nameWithOwner } labels(first: 20) { nodes { name } } closingIssuesReferences(first: 3) { nodes { number repository { nameWithOwner } } } }",
|
|
34
34
|
},
|
|
35
|
-
reviewed: { first: 100, nodes: "... on PullRequest { number title url mergedAt repository { nameWithOwner } author { ...author } }" },
|
|
36
|
-
|
|
35
|
+
reviewed: { first: 100, nodes: "... on PullRequest { number title url mergedAt repository { nameWithOwner } author { ...author } labels(first: 20) { nodes { name } } }" },
|
|
36
|
+
// Labels and type say what kind of work each was [HIS-04].
|
|
37
|
+
closed: { first: 100, nodes: "... on Issue { number title url closedAt stateReason repository { nameWithOwner } issueType { name } labels(first: 20) { nodes { name } } }" },
|
|
37
38
|
};
|
|
38
39
|
export type SearchName = keyof typeof SEARCHES;
|
|
39
40
|
|
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/server/view.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Attention, type AttentionView, type Chip, type FeedId, type FeedStatus, type Item, type NextUpIssue, type Section, SECTION_ORDER, SECTIONS, type TabId, type WaitingGroup } from "../shared/attention";
|
|
2
2
|
import type { AttentionConfig } from "../shared/config";
|
|
3
|
+
import { workChip, workKind } from "../shared/work";
|
|
3
4
|
import type { State } from "./store";
|
|
4
5
|
|
|
5
6
|
export interface ViewMeta {
|
|
@@ -42,6 +43,8 @@ export function isPending({ at, effect }: Pending, fetchedAt: Record<FeedId, str
|
|
|
42
43
|
export function doneItem(source: Item | NextUpIssue, closedAt: string, notPlanned = false): Item {
|
|
43
44
|
const { key, repo, number, title, url } = source;
|
|
44
45
|
const kind = "kind" in source ? source.kind : "issue";
|
|
46
|
+
// Labels come with the next History fetch; until then the issue type and title prefix tell what kind of work it was [HIS-04].
|
|
47
|
+
const work = workKind({ type: "type" in source ? source.type : undefined, title });
|
|
45
48
|
return {
|
|
46
49
|
key,
|
|
47
50
|
section: "done",
|
|
@@ -51,9 +54,12 @@ export function doneItem(source: Item | NextUpIssue, closedAt: string, notPlanne
|
|
|
51
54
|
number,
|
|
52
55
|
title,
|
|
53
56
|
url,
|
|
54
|
-
chips: notPlanned ? [{ text: "not planned", tone: "neutral" }] : [],
|
|
57
|
+
chips: [...(work ? [workChip(work)] : []), ...(notPlanned ? [{ text: "not planned", tone: "neutral" as const }] : [])],
|
|
58
|
+
...(work ? { work } : {}),
|
|
59
|
+
...(notPlanned ? { notPlanned: true as const } : {}),
|
|
55
60
|
actions: [],
|
|
56
|
-
|
|
61
|
+
// Not planned issues list their PRs on their own, as classifyHistory does [HIS-03].
|
|
62
|
+
children: "children" in source && !notPlanned ? source.children.map((child) => ({ ...child, draft: false, chips: [], attention: false })) : [],
|
|
57
63
|
target: { kind, repo, number, title, url },
|
|
58
64
|
othersActivityAt: "1970-01-01T00:00:00Z",
|
|
59
65
|
closedAt,
|
|
@@ -73,7 +79,8 @@ export function applyPending(attention: Attention | null, history: Item[], pendi
|
|
|
73
79
|
});
|
|
74
80
|
const assigned = [...attention.assigned.filter((issue) => !off(issue.key) && effect(issue.key) !== "unclaimed"), ...attention.unclaimed.filter((issue) => effect(issue.key) === "claimed")];
|
|
75
81
|
const unclaimed = [...attention.unclaimed.filter((issue) => !off(issue.key) && effect(issue.key) !== "claimed"), ...attention.assigned.filter((issue) => effect(issue.key) === "unclaimed")];
|
|
76
|
-
|
|
82
|
+
// PRs listed under their issue count as known too, so a merge doesn't show twice [HIS-01].
|
|
83
|
+
const known = new Set(history.flatMap((item) => [item.key, ...item.children.map((child) => child.key)]));
|
|
77
84
|
const done = Object.values(pending).flatMap(({ effect }) => (effect.kind === "done" && !known.has(effect.item.key) ? [effect.item] : []));
|
|
78
85
|
// History is newest first; what I just finished is newest of all.
|
|
79
86
|
return { attention: { ...attention, items, assigned, unclaimed }, history: [...done, ...history] };
|
package/shared/attention.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AttentionConfig, MergeMethod, SessionKind } from "./config";
|
|
2
|
+
import type { WorkKind } from "./work";
|
|
2
3
|
|
|
3
4
|
// Tabs tell the story of my work: what I finished, what needs me, what waits on others, what's next.
|
|
4
5
|
export type TabId = "history" | "doing" | "waiting" | "next";
|
|
@@ -200,6 +201,10 @@ export interface Item {
|
|
|
200
201
|
othersActivityAt: string;
|
|
201
202
|
// History only: when it merged or closed.
|
|
202
203
|
closedAt?: string;
|
|
204
|
+
// History only: what kind of work it was, when that can be told [HIS-04].
|
|
205
|
+
work?: WorkKind;
|
|
206
|
+
// History only: an issue closed as not planned, kept out of the copied week [HIS-03].
|
|
207
|
+
notPlanned?: true;
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
// An issue to pick up: assigned to me [NXT-06] or nobody [NXT-01].
|
package/shared/format.ts
CHANGED
|
@@ -15,10 +15,13 @@ export function daysSince(iso: string, now: Date): number {
|
|
|
15
15
|
return (now.getTime() - new Date(iso).getTime()) / 86_400_000;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// A Markdown bullet list of links, for pasting a week's work into a report
|
|
19
|
-
// long so it skims down the left edge:
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
// A Markdown bullet list of links, for pasting a week's work into a report, each led by what kind of work it was:
|
|
19
|
+
// "- 🐞 [title](url)" [HIS-03, HIS-04]; or a nudge, each led by why and how long so it skims down the left edge:
|
|
20
|
+
// "- Review 2h: [title](url)" [WAI-03].
|
|
21
|
+
export function linkList(items: { title: string; url: string; lead?: string; mark?: string }[]): string {
|
|
22
|
+
return items
|
|
23
|
+
.map(({ title, url, lead, mark }) => `- ${mark ? `${mark} ` : ""}${lead ? `${lead}: ` : ""}[${title.replace(/[[\]\\]/g, "\\$&")}](${url})`)
|
|
24
|
+
.join("\n");
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
// Where a card's item lives: "app" for my own repos, "acme/app" for anyone else's, so same-named repos don't blur [ATT-05, NXT-10].
|
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);
|
package/shared/work.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// What kind of work an issue or PR was, for History's chips and copied lines [HIS-04].
|
|
2
|
+
export type WorkKind = "bug" | "feature" | "task";
|
|
3
|
+
|
|
4
|
+
export const WORK_EMOJI: Record<WorkKind, string> = { bug: "🐞", feature: "🚀", task: "🔧" };
|
|
5
|
+
// A PR that's none of the above still leads its copied line with something.
|
|
6
|
+
export const PR_EMOJI = "🔀";
|
|
7
|
+
|
|
8
|
+
// Most telling first: anything that says bug is a bug.
|
|
9
|
+
const RANK: WorkKind[] = ["bug", "feature", "task"];
|
|
10
|
+
|
|
11
|
+
// Issue type and label names, matched whole so "not a bug" and "bug bash" don't count.
|
|
12
|
+
const NAMES: Record<string, WorkKind> = {
|
|
13
|
+
bug: "bug",
|
|
14
|
+
bugs: "bug",
|
|
15
|
+
bugfix: "bug",
|
|
16
|
+
"bug fix": "bug",
|
|
17
|
+
"bug report": "bug",
|
|
18
|
+
defect: "bug",
|
|
19
|
+
regression: "bug",
|
|
20
|
+
feature: "feature",
|
|
21
|
+
features: "feature",
|
|
22
|
+
"feature request": "feature",
|
|
23
|
+
"new feature": "feature",
|
|
24
|
+
enhancement: "feature",
|
|
25
|
+
epic: "feature",
|
|
26
|
+
story: "feature",
|
|
27
|
+
"user story": "feature",
|
|
28
|
+
task: "task",
|
|
29
|
+
chore: "task",
|
|
30
|
+
maintenance: "task",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Conventional Commit types: "fix: …", "feat(api)!: …". Some only make sense at the front of a title.
|
|
34
|
+
const PREFIXES: Record<string, WorkKind> = {
|
|
35
|
+
fix: "bug",
|
|
36
|
+
feat: "feature",
|
|
37
|
+
chore: "task",
|
|
38
|
+
refactor: "task",
|
|
39
|
+
docs: "task",
|
|
40
|
+
build: "task",
|
|
41
|
+
ci: "task",
|
|
42
|
+
test: "task",
|
|
43
|
+
perf: "task",
|
|
44
|
+
style: "task",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// "Type: Bug 🐞", "kind/bug", "T-Feature" -> "bug", "bug", "feature".
|
|
48
|
+
function normalize(name: string): string {
|
|
49
|
+
return name
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.replace(/[^\p{L}\p{N}]+/gu, " ")
|
|
52
|
+
.trim()
|
|
53
|
+
.replace(/^(?:type|kind|t|issue type|category) /, "");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const named = (name: string): WorkKind | undefined => NAMES[normalize(name)];
|
|
57
|
+
|
|
58
|
+
// The first source that says anything decides: issue type, then labels, then the title's prefix.
|
|
59
|
+
// Within labels, bug beats feature beats task. Unknown is a fine answer.
|
|
60
|
+
export function workKind({ type, labels = [], title }: { type?: string | null; labels?: string[]; title: string }): WorkKind | undefined {
|
|
61
|
+
const typed = type ? named(type) : undefined;
|
|
62
|
+
if (typed) return typed;
|
|
63
|
+
const labelled = new Set(labels.map(named));
|
|
64
|
+
const best = RANK.find((kind) => labelled.has(kind));
|
|
65
|
+
if (best) return best;
|
|
66
|
+
const prefix = /^\s*([a-z]+)(?:\([^)]*\))?!?:\s/i.exec(title)?.[1].toLowerCase();
|
|
67
|
+
return prefix ? PREFIXES[prefix] : undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// What leads an item's copied line: its kind, a PR's own mark, or nothing.
|
|
71
|
+
export function workEmoji(item: { kind: "pr" | "issue"; work?: WorkKind }): string | undefined {
|
|
72
|
+
return item.work ? WORK_EMOJI[item.work] : item.kind === "pr" ? PR_EMOJI : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Chips are plain words like every other chip; the emoji are for the copied lines.
|
|
76
|
+
export const workChip = (kind: WorkKind) => ({ text: kind, tone: "neutral" as const });
|