co-maintainer 0.6.3 → 0.6.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/THIRD_PARTY_NOTICES +161 -0
- package/dist/package.json +4 -2
- package/dist/src/ai/batch.js +7 -0
- package/dist/src/cli/args.js +21 -3
- package/dist/src/cli/commands/registry.js +38 -3
- package/dist/src/cli/commands/serve.js +31 -3
- package/dist/src/cli/commands/set.js +54 -0
- package/dist/src/config.d.ts +14 -0
- package/dist/src/github/client.js +13 -0
- package/dist/src/github/permissions.js +8 -0
- package/dist/src/server/api/jobs.js +8 -1
- package/dist/src/server/api/repos.js +73 -11
- package/dist/src/server/api/settings.js +6 -0
- package/dist/src/server/app.d.ts +5 -0
- package/dist/src/server/app.js +7 -0
- package/dist/src/server/http.d.ts +3 -0
- package/dist/src/server/http.js +5 -0
- package/dist/src/server/pages/activity.js +412 -19
- package/dist/src/server/pages/add_repo.js +6 -1
- package/dist/src/server/pages/analytics.js +99 -31
- package/dist/src/server/pages/catalog.d.ts +1 -0
- package/dist/src/server/pages/catalog.js +145 -0
- package/dist/src/server/pages/client.d.ts +1 -1
- package/dist/src/server/pages/client.js +1 -1
- package/dist/src/server/pages/home.d.ts +14 -4
- package/dist/src/server/pages/home.js +83 -49
- package/dist/src/server/pages/icons.d.ts +3 -0
- package/dist/src/server/pages/icons.js +3 -0
- package/dist/src/server/pages/knowledge.js +10 -5
- package/dist/src/server/pages/layout.d.ts +19 -3
- package/dist/src/server/pages/layout.js +156 -33
- package/dist/src/server/pages/pr.js +4 -3
- package/dist/src/server/pages/rate_limit_waits.d.ts +5 -0
- package/dist/src/server/pages/rate_limit_waits.js +74 -0
- package/dist/src/server/pages/repo.js +100 -66
- package/dist/src/server/pages/repo_prs.js +4 -3
- package/dist/src/server/pages/repo_remote.js +4 -3
- package/dist/src/server/pages/repo_settings.d.ts +2 -2
- package/dist/src/server/pages/repo_settings.js +420 -46
- package/dist/src/server/pages/router.d.ts +5 -0
- package/dist/src/server/pages/router.js +82 -31
- package/dist/src/server/pages/settings.d.ts +10 -1
- package/dist/src/server/pages/settings.js +350 -206
- package/dist/src/server/pages/setup.d.ts +2 -5
- package/dist/src/server/pages/setup.js +21 -23
- package/dist/src/server/pages/styles.d.ts +1 -1
- package/dist/src/server/pages/styles.js +1 -1
- package/dist/src/server/pages/ui.d.ts +117 -0
- package/dist/src/server/pages/ui.js +166 -0
- package/dist/src/services/cli_repos.d.ts +2 -0
- package/dist/src/services/cli_repos.js +50 -0
- package/dist/src/services/concurrency.d.ts +39 -0
- package/dist/src/services/concurrency.js +88 -0
- package/dist/src/services/dashboard.d.ts +43 -1
- package/dist/src/services/dashboard.js +10 -2
- package/dist/src/services/jobs.js +5 -3
- package/dist/src/services/nav_counts.d.ts +8 -0
- package/dist/src/services/nav_counts.js +19 -0
- package/dist/src/services/rate_limit.d.ts +33 -0
- package/dist/src/services/rate_limit.js +78 -0
- package/dist/src/services/repo_list.d.ts +19 -0
- package/dist/src/services/repo_list.js +38 -0
- package/dist/src/services/review.d.ts +23 -1
- package/dist/src/services/review.js +165 -35
- package/dist/src/services/search.d.ts +13 -0
- package/dist/src/services/search.js +72 -0
- package/dist/src/services/setup.js +14 -4
- package/dist/src/services/setup_checklist.d.ts +1 -1
- package/dist/src/services/setup_checklist.js +26 -47
- package/dist/src/store/findings.d.ts +1 -1
- package/dist/src/store/findings.js +3 -3
- package/dist/src/store/migrations.js +7 -0
- package/dist/src/store/repos.d.ts +5 -0
- package/dist/src/store/repos.js +12 -0
- package/dist/src/store/reviews.d.ts +12 -1
- package/dist/src/store/reviews.js +34 -2
- package/dist/src/store/rows.d.ts +6 -0
- package/package.json +4 -2
|
@@ -1,8 +1,47 @@
|
|
|
1
|
-
import { capped, empty, html, layout,
|
|
1
|
+
import { capped, empty, html, layout, repoTabs, skSlot, text, when, } from "./layout.js";
|
|
2
|
+
import { badge, crumb, dl, icon, pageHeader, section, statCard, } from "./ui.js";
|
|
2
3
|
import { formatCostTotal } from "./cost.js";
|
|
3
4
|
import { COMPARE_FILE_CAP, MAX_COMMITS_COUNTED } from "../../services/drift.js";
|
|
5
|
+
import { describePolicy } from "../../services/review_policy.js";
|
|
6
|
+
import { policyForRepo } from "../../services/webhook.js";
|
|
7
|
+
import { reviewBlockingFrom } from "../../review/blocking.js";
|
|
8
|
+
import { SEVERITY_LEGEND } from "../../pr/review_copy.js";
|
|
9
|
+
import { readConfig } from "../../config.js";
|
|
4
10
|
import { webhookReachabilityProblem } from "../../util/webhook_reachability.js";
|
|
5
11
|
import { lastDeliveryForRepo } from "../../store/deliveries.js";
|
|
12
|
+
/** P0..P3 in legend order, with the words the PR comment uses. */
|
|
13
|
+
const SEVERITY_TONE = {
|
|
14
|
+
P0: "red",
|
|
15
|
+
P1: "red",
|
|
16
|
+
P2: "amber",
|
|
17
|
+
P3: "neutral",
|
|
18
|
+
};
|
|
19
|
+
function severityName(level) {
|
|
20
|
+
return (SEVERITY_LEGEND.find((entry) => entry.level === level)?.name ?? level).toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
/** "1 high · 1 low", most severe first. */
|
|
23
|
+
function severityHint(counts) {
|
|
24
|
+
return SEVERITY_LEGEND.map((entry) => {
|
|
25
|
+
const n = counts.find((c) => c.severity === entry.level)?.findings ?? 0;
|
|
26
|
+
return n > 0 ? `${n} ${entry.name.toLowerCase()}` : "";
|
|
27
|
+
})
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
.join(" · ");
|
|
30
|
+
}
|
|
31
|
+
/** The most severe level among a review's findings, as a badge. */
|
|
32
|
+
function topSeverity(levels) {
|
|
33
|
+
const top = SEVERITY_LEGEND.find((entry) => levels.includes(entry.level));
|
|
34
|
+
if (!top)
|
|
35
|
+
return "";
|
|
36
|
+
const n = levels.filter((level) => level === top.level).length;
|
|
37
|
+
return badge(SEVERITY_TONE[top.level] ?? "neutral", `${n} ${severityName(top.level)}`);
|
|
38
|
+
}
|
|
39
|
+
function seconds(ms) {
|
|
40
|
+
if (!ms)
|
|
41
|
+
return "None yet";
|
|
42
|
+
const s = Math.round(ms / 1000);
|
|
43
|
+
return s < 60 ? `${s} s` : `${Math.round(s / 60)} min`;
|
|
44
|
+
}
|
|
6
45
|
export function renderRepo(username, data, webhookUrl) {
|
|
7
46
|
const name = data.repo.full_name;
|
|
8
47
|
const stats = data.stats;
|
|
@@ -12,26 +51,19 @@ export function renderRepo(username, data, webhookUrl) {
|
|
|
12
51
|
? `<div class="notice" data-async>
|
|
13
52
|
${skSlot()}
|
|
14
53
|
<div class="txt"><b>Update recommended.</b> Since the guide was built:
|
|
15
|
-
${drift.prs_since} new pull requests, ${drift.prs_updated} changed pull requests, ${capped(drift.commits_since, MAX_COMMITS_COUNTED)} commits, ${capped(drift.files_changed, COMPARE_FILE_CAP)} files changed.</div>
|
|
16
|
-
<button class="btn primary" id="remake">Sync now</button>
|
|
54
|
+
${drift.prs_since} new pull requests, ${drift.prs_updated} changed pull requests, ${capped(drift.commits_since, MAX_COMMITS_COUNTED)} commits, ${capped(drift.files_changed, COMPARE_FILE_CAP)} files changed. Use Sync to update it.</div>
|
|
17
55
|
</div>`
|
|
18
56
|
: "";
|
|
19
57
|
const pulls = data.recentPulls.length === 0
|
|
20
58
|
? empty("No reviews yet", "Reviews appear here after a pull request is opened.")
|
|
21
|
-
:
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
.map((review) => `<tr><td><a href="/repos/${text(name)}/pulls/${review.pr_number}">#${review.pr_number}</a></td>
|
|
26
|
-
<td class="muted">${when(review.created_at)}</td>
|
|
27
|
-
<td class="num">${review.findings_count}</td></tr>`)
|
|
28
|
-
.join("")}
|
|
29
|
-
</tbody>
|
|
30
|
-
</table>`;
|
|
59
|
+
: data.recentPulls
|
|
60
|
+
.map((review) => `<div class="row"><div class="b"><p class="strong"><a href="/repos/${text(name)}/pulls/${review.pr_number}">#${review.pr_number}</a></p>
|
|
61
|
+
<p class="muted" style="font-size:13px">Reviewed ${when(review.created_at)} · ${review.findings_count} ${review.findings_count === 1 ? "finding" : "findings"}</p></div>${topSeverity(review.severities)}</div>`)
|
|
62
|
+
.join("");
|
|
31
63
|
const reach = webhookReachabilityProblem(webhookUrl);
|
|
32
64
|
const last = lastDeliveryForRepo(name);
|
|
33
65
|
const delivery = last ? when(last.received_at) : "never";
|
|
34
|
-
const
|
|
66
|
+
const webhookNotice = reach
|
|
35
67
|
? `<div class="notice bad">
|
|
36
68
|
<div class="txt"><b>GitHub cannot reach this address, so automatic reviews will not arrive.</b>
|
|
37
69
|
${text(reach)} The webhook URL is <code>${text(webhookUrl)}</code>. Change it in <a href="/settings">Settings</a>.
|
|
@@ -43,66 +75,68 @@ export function renderRepo(username, data, webhookUrl) {
|
|
|
43
75
|
and the last webhook delivery is never. Open a pull request, or check the webhook URL
|
|
44
76
|
<code>${text(webhookUrl)}</code> in <a href="/settings">Settings</a>.</div>
|
|
45
77
|
</div>`
|
|
46
|
-
:
|
|
78
|
+
: "";
|
|
79
|
+
const config = readConfig();
|
|
80
|
+
const blocking = reviewBlockingFrom(config.repos?.[name]?.reviewBlocking ?? config.reviewBlocking) === "severity"
|
|
81
|
+
? "Severity is Critical or High"
|
|
82
|
+
: "When the model says so";
|
|
83
|
+
const webhookRow = last && !reach
|
|
84
|
+
? `${badge("emerald", "Receiving", { icon: "circle-check" })} <span class="muted" style="font-size:13px">Last webhook delivery: ${delivery}</span>`
|
|
85
|
+
: `${badge("amber", "Not receiving", { icon: "triangle-alert" })} <span class="muted" style="font-size:13px">Last webhook delivery: ${delivery}</span>`;
|
|
86
|
+
const how = dl([
|
|
87
|
+
{
|
|
88
|
+
k: "Who",
|
|
89
|
+
v: describePolicy(policyForRepo(data.repo)).map(text).join(" "),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
k: "Scope",
|
|
93
|
+
v: data.repo.review_scope === "incremental"
|
|
94
|
+
? "Only what changed since the last review"
|
|
95
|
+
: "The whole pull request every time",
|
|
96
|
+
},
|
|
97
|
+
{ k: "Blocking", v: blocking },
|
|
98
|
+
{ k: "Webhook", v: webhookRow },
|
|
99
|
+
]);
|
|
47
100
|
const auto = data.repo.auto_review === 1;
|
|
101
|
+
const lead = `${auto ? "Reviewing pull requests automatically" : "Automatic review is off"} · knowledge ${data.repo.knowledge_built_at
|
|
102
|
+
? when(data.repo.knowledge_built_at)
|
|
103
|
+
: "not built yet"}`;
|
|
104
|
+
const failedHint = stats.failed > 0
|
|
105
|
+
? `${stats.failed} failed ${stats.failed === 1 ? "attempt" : "attempts"}`
|
|
106
|
+
: undefined;
|
|
48
107
|
return html(layout({
|
|
49
108
|
title: `${name} · co-maintainer`,
|
|
50
109
|
username,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
<div class="card">
|
|
81
|
-
<div class="hd"><h2>Recent pull requests</h2>
|
|
82
|
-
<a class="btn sm" style="margin-left:auto" href="/repos/${text(name)}/pulls">View all</a></div>
|
|
83
|
-
<div class="bd flush">${pulls}</div>
|
|
84
|
-
</div>
|
|
85
|
-
<div class="card" data-async>
|
|
86
|
-
${skSlot()}
|
|
87
|
-
<div class="hd"><h2>Automatic review</h2></div>
|
|
88
|
-
<div class="bd">
|
|
89
|
-
<div style="display:flex;align-items:center;gap:14px">
|
|
90
|
-
<button class="tg${auto ? " on" : ""}" id="auto"></button>
|
|
91
|
-
<div>
|
|
92
|
-
<div><b>${auto ? "On" : "Off"}</b>. ${auto
|
|
93
|
-
? "Every new push to an open pull request gets reviewed."
|
|
94
|
-
: "New pushes are not reviewed until you turn this on."}</div>
|
|
95
|
-
<div class="hint" style="margin:2px 0 0">Drafts and bot pull requests follow the skip settings.
|
|
96
|
-
<a href="/repos/${text(name)}/settings">Change</a></div>
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
110
|
+
active: "/",
|
|
111
|
+
body: `<div class="wrap">
|
|
112
|
+
${pageHeader({
|
|
113
|
+
title: name,
|
|
114
|
+
leadHtml: lead,
|
|
115
|
+
crumb: crumb([{ label: "Repositories", href: "/" }, { label: name }]),
|
|
116
|
+
actions: `<button type="button" class="btn out" id="remake">${icon("refresh-cw")}Sync</button><a class="btn out" href="https://github.com/${text(name)}">${icon("external-link")}GitHub</a>`,
|
|
117
|
+
})}
|
|
118
|
+
${repoTabs(name, "overview")}
|
|
119
|
+
${notice}
|
|
120
|
+
${webhookNotice}
|
|
121
|
+
<div class="stats">
|
|
122
|
+
${statCard({ label: "Reviewed (30d)", value: String(stats.pullRequests), hint: failedHint, icon: "git-pull-request" })}
|
|
123
|
+
${statCard({ label: "Findings", value: String(stats.findings), hint: severityHint(data.bySeverity) || undefined, icon: "flag" })}
|
|
124
|
+
${statCard({ label: "Cost (30d)", value: formatCostTotal(stats), icon: "coins" })}
|
|
125
|
+
${statCard({ label: "Avg. review", value: seconds(stats.avgDurationMs), icon: "timer" })}
|
|
126
|
+
</div>
|
|
127
|
+
<div class="cols c11">
|
|
128
|
+
<div class="card">${section(pulls, {
|
|
129
|
+
title: "Recent pull requests",
|
|
130
|
+
action: `<a class="btn gh sm" href="/repos/${text(name)}/pulls">View all</a>`,
|
|
131
|
+
})}</div>
|
|
132
|
+
<div class="card">${section(how, {
|
|
133
|
+
title: "How it reviews",
|
|
134
|
+
action: `<a class="btn gh sm" href="/repos/${text(name)}/settings">Change</a>`,
|
|
135
|
+
})}</div>
|
|
101
136
|
</div>
|
|
102
137
|
</div>
|
|
103
138
|
<script>
|
|
104
139
|
var repo = ${JSON.stringify(name)};
|
|
105
|
-
bindToggle(document.getElementById("auto"), "/api/repos/" + repo, "autoReview");
|
|
106
140
|
var remake = document.getElementById("remake");
|
|
107
141
|
if (remake) remake.addEventListener("click", function() {
|
|
108
142
|
postAndGo("/api/repos/" + repo + "/remake", {}, "/activity", remake);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { empty, html, layout,
|
|
1
|
+
import { empty, html, layout, repoTabs, skSlot, text, when } from "./layout.js";
|
|
2
2
|
import { formatCostTotal } from "./cost.js";
|
|
3
3
|
export function renderRepoPulls(username, fullName, data, open) {
|
|
4
4
|
const start = (data.page - 1) * data.per + 1;
|
|
@@ -60,8 +60,9 @@ export function renderRepoPulls(username, fullName, data, open) {
|
|
|
60
60
|
return html(layout({
|
|
61
61
|
title: `Pull requests · ${fullName}`,
|
|
62
62
|
username,
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
active: "/",
|
|
64
|
+
body: `<div class="wrap">
|
|
65
|
+
${repoTabs(fullName, "pulls")}
|
|
65
66
|
<div>
|
|
66
67
|
<div class="crumbs"><a href="/">Repositories</a> /
|
|
67
68
|
<a href="/repos/${text(fullName)}">${text(fullName)}</a> / Pull requests</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { empty, html, layout,
|
|
1
|
+
import { empty, html, layout, repoTabs, text, when } from "./layout.js";
|
|
2
2
|
import { formatCost } from "./cost.js";
|
|
3
3
|
export function renderRepoRemote(username, fullName, data) {
|
|
4
4
|
const rows = data.items.length === 0
|
|
@@ -22,8 +22,9 @@ export function renderRepoRemote(username, fullName, data) {
|
|
|
22
22
|
return html(layout({
|
|
23
23
|
title: `${fullName} · Remote · co-maintainer`,
|
|
24
24
|
username,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
active: "/",
|
|
26
|
+
body: `<div class="wrap">
|
|
27
|
+
${repoTabs(fullName, "remote")}
|
|
27
28
|
<div>
|
|
28
29
|
<div class="crumbs"><a href="/">Repositories</a> / ${text(fullName)}</div>
|
|
29
30
|
<div class="pagehead">
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RepoRow } from "../../store/rows.ts";
|
|
2
|
-
import type
|
|
3
|
-
export declare function renderRepoSettings(username: string, repo: RepoRow, config: RepoConfig): Response;
|
|
2
|
+
import { type RepoConfig } from "../../config.ts";
|
|
3
|
+
export declare function renderRepoSettings(username: string, repo: RepoRow, config: RepoConfig, probeReport?: Record<string, unknown>): Response;
|