co-maintainer 0.6.1 → 0.6.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/THIRD_PARTY_NOTICES +161 -0
- package/dist/package.json +4 -2
- package/dist/src/ai/batch.js +7 -0
- package/dist/src/ai/oauth/ids.d.ts +10 -0
- package/dist/src/ai/oauth/ids.js +10 -0
- package/dist/src/ai/oauth/registry.d.ts +33 -0
- package/dist/src/ai/oauth/registry.js +40 -0
- package/dist/src/ai/oauth/sign-in-with-chatgpt.d.ts +56 -0
- package/dist/src/ai/oauth/sign-in-with-chatgpt.js +552 -0
- package/dist/src/ai/openai.d.ts +18 -1
- package/dist/src/ai/openai.js +68 -5
- package/dist/src/ai/provider.d.ts +3 -0
- package/dist/src/ai/provider.js +11 -2
- package/dist/src/cli/args.js +61 -21
- package/dist/src/cli/commands/oauth.d.ts +1 -0
- package/dist/src/cli/commands/oauth.js +73 -0
- package/dist/src/cli/commands/registry.js +79 -3
- package/dist/src/cli/commands/serve.js +31 -3
- package/dist/src/cli/commands/set.js +54 -0
- package/dist/src/cli/main.js +5 -0
- package/dist/src/cli/review_args.js +5 -0
- package/dist/src/config.d.ts +14 -0
- package/dist/src/github/client.js +13 -0
- package/dist/src/github/collect.d.ts +2 -2
- package/dist/src/github/collect.js +60 -23
- package/dist/src/github/permissions.js +8 -0
- package/dist/src/knowledge/types.d.ts +3 -4
- package/dist/src/pr/reviewer.js +5 -4
- 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 +351 -207
- 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/clear.js +2 -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 +104 -5
- package/dist/src/services/search.d.ts +13 -0
- package/dist/src/services/search.js +72 -0
- package/dist/src/services/setup.js +17 -16
- package/dist/src/services/setup_checklist.d.ts +1 -1
- package/dist/src/services/setup_checklist.js +26 -47
- package/dist/src/store/cache_db.js +1 -1
- 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/dist/src/types.d.ts +5 -1
- package/package.json +4 -2
|
@@ -2,10 +2,10 @@ import { clearOauthStateCookieHeader, clearSessionCookieHeader, createSession, l
|
|
|
2
2
|
import { githubAuthorizeUrl, githubLoginFromCode } from "../../github/oauth.js";
|
|
3
3
|
import { handleClient, handleLogo, handleStyles } from "../assets.js";
|
|
4
4
|
import { activityFeed, listReposForHome, prDetail, repoKnowledge, RepoNotFound, repoOverview, repoPulls, repoRemoteReviews, runningJobs, skippedDeliveries, statsForRange, } from "../../services/dashboard.js";
|
|
5
|
-
import { escapeHtml, html } from "./layout.js";
|
|
5
|
+
import { escapeHtml, html, notFound } from "./layout.js";
|
|
6
6
|
import { formatCostTotal } from "./cost.js";
|
|
7
|
-
import { readConfig,
|
|
8
|
-
import {
|
|
7
|
+
import { readConfig, writeUserConfig } from "../../config.js";
|
|
8
|
+
import {} from "../../config.js";
|
|
9
9
|
import { appNameProblem, beginManifestState, buildAppManifest, consumeManifestState, convertManifest, } from "../../github/app_manifest.js";
|
|
10
10
|
import { renderHome, renderLogin } from "./home.js";
|
|
11
11
|
import { renderSetup } from "./setup.js";
|
|
@@ -18,12 +18,15 @@ import { renderKnowledge } from "./knowledge.js";
|
|
|
18
18
|
import { renderRepoSettings } from "./repo_settings.js";
|
|
19
19
|
import { renderActivity, renderJob } from "./activity.js";
|
|
20
20
|
import { renderAnalytics } from "./analytics.js";
|
|
21
|
-
import { renderSettings } from "./settings.js";
|
|
21
|
+
import { renderSettings, renderSettingsPage } from "./settings.js";
|
|
22
|
+
import { renderCatalog } from "./catalog.js";
|
|
22
23
|
import { getRepo } from "../../store/repos.js";
|
|
24
|
+
import { cacheGet } from "../../store/cache_db.js";
|
|
23
25
|
import { getJob } from "../../store/jobs.js";
|
|
24
26
|
import { getLogsSince } from "../../services/jobs.js";
|
|
25
27
|
import { listInstallationsWithRepos, listOpenPulls } from "../../github/app.js";
|
|
26
28
|
import { setupChecklist } from "../../services/setup_checklist.js";
|
|
29
|
+
import { appReady, filterRepoList, repoState, } from "../../services/repo_list.js";
|
|
27
30
|
const REPO = /^\/repos\/([^/]+)\/([^/]+)(?:\/(pulls|knowledge|settings|remote)(?:\/(\d+))?)?$/;
|
|
28
31
|
/** Matches a repository page URL. Only `pulls` is keyed by a number, so a stray
|
|
29
32
|
* suffix such as `/repos/o/r/remote/7` must fall through to a 404 rather than
|
|
@@ -107,17 +110,27 @@ export async function handlePageRequest(request, deps, ip) {
|
|
|
107
110
|
}
|
|
108
111
|
const username = session.username;
|
|
109
112
|
try {
|
|
113
|
+
if (url.pathname === "/__ui" && request.method === "GET") {
|
|
114
|
+
if (!deps.debug)
|
|
115
|
+
return undefined;
|
|
116
|
+
return renderCatalog();
|
|
117
|
+
}
|
|
110
118
|
if (url.pathname === "/" && request.method === "GET") {
|
|
111
119
|
const config = readConfig();
|
|
112
|
-
|
|
120
|
+
const all = listReposForHome();
|
|
121
|
+
const ready = appReady();
|
|
122
|
+
const q = url.searchParams.get("q") ?? "";
|
|
123
|
+
const status = url.searchParams.get("status") ?? "all";
|
|
124
|
+
return renderHome(username, filterRepoList(all, { q, status }, ready).map((item) => toHomeRow(item, ready)), setupChecklist(config.webhookUrl || deps.webhookUrl || ""), {
|
|
125
|
+
q,
|
|
126
|
+
status,
|
|
127
|
+
total: all.length,
|
|
128
|
+
reviewing: all.filter((item) => repoState(item, ready) === "reviewing").length,
|
|
129
|
+
});
|
|
113
130
|
}
|
|
114
131
|
if (url.pathname === "/setup" && request.method === "GET") {
|
|
115
132
|
const config = readConfig();
|
|
116
|
-
return renderSetup(username,
|
|
117
|
-
ai: aiConfigured(config),
|
|
118
|
-
github: Boolean(config.auth === "gh" || (config.auth === "pat" && config.githubPat)),
|
|
119
|
-
app: Boolean(config.githubAppId && resolveAppPrivateKey(config)),
|
|
120
|
-
});
|
|
133
|
+
return renderSetup(username, setupChecklist(config.webhookUrl || deps.webhookUrl || ""));
|
|
121
134
|
}
|
|
122
135
|
if (url.pathname === "/repos/new" && request.method === "GET") {
|
|
123
136
|
return renderAddRepo(username, await repoPicker(deps.githubApp));
|
|
@@ -136,17 +149,31 @@ export async function handlePageRequest(request, deps, ip) {
|
|
|
136
149
|
const jobMatch = /^\/activity\/([^/]+)$/.exec(url.pathname);
|
|
137
150
|
if (jobMatch && request.method === "GET") {
|
|
138
151
|
const job = getJob(jobMatch[1]);
|
|
139
|
-
if (!job)
|
|
140
|
-
return
|
|
152
|
+
if (!job) {
|
|
153
|
+
return notFound(username, "That job is not on this server.", "/activity");
|
|
154
|
+
}
|
|
141
155
|
return renderJob(username, job, getLogsSince(job.id));
|
|
142
156
|
}
|
|
143
157
|
if (url.pathname === "/analytics" && request.method === "GET") {
|
|
158
|
+
return Response.redirect(`${url.origin}/usage${url.search}`, 303);
|
|
159
|
+
}
|
|
160
|
+
if (url.pathname === "/usage" && request.method === "GET") {
|
|
144
161
|
const range = url.searchParams.get("range") ?? "30d";
|
|
145
162
|
return renderAnalytics(username, range, statsForRange(range));
|
|
146
163
|
}
|
|
147
164
|
if (url.pathname === "/settings" && request.method === "GET") {
|
|
148
165
|
const config = readConfig();
|
|
149
|
-
return renderSettings(username, config, config.webhookUrl || deps.webhookUrl || "", requestBaseUrl(request, url, Boolean(deps.trustProxy)));
|
|
166
|
+
return renderSettings(username, config, config.webhookUrl || deps.webhookUrl || "", requestBaseUrl(request, url, Boolean(deps.trustProxy)), { port: deps.port, trustProxy: Boolean(deps.trustProxy) });
|
|
167
|
+
}
|
|
168
|
+
const settingsMatch = /^\/settings\/([a-z-]+)$/.exec(url.pathname);
|
|
169
|
+
if (settingsMatch && request.method === "GET") {
|
|
170
|
+
const section = settingsMatch[1];
|
|
171
|
+
const config = readConfig();
|
|
172
|
+
const page = renderSettingsPage(username, config, config.webhookUrl || deps.webhookUrl || "", requestBaseUrl(request, url, Boolean(deps.trustProxy)), section, { port: deps.port, trustProxy: Boolean(deps.trustProxy) });
|
|
173
|
+
if (!page) {
|
|
174
|
+
return notFound(username, `There is no settings page called ${section}.`, undefined);
|
|
175
|
+
}
|
|
176
|
+
return page;
|
|
150
177
|
}
|
|
151
178
|
const match = matchRepo(url.pathname);
|
|
152
179
|
if (match && request.method === "GET") {
|
|
@@ -169,34 +196,54 @@ export async function handlePageRequest(request, deps, ip) {
|
|
|
169
196
|
return renderRepoRemote(username, fullName, repoRemoteReviews(fullName));
|
|
170
197
|
}
|
|
171
198
|
if (sub === "knowledge") {
|
|
172
|
-
|
|
199
|
+
const knowledge = await repoKnowledge(fullName);
|
|
200
|
+
const viewId = url.searchParams.get("view") ?? undefined;
|
|
201
|
+
const doc = viewId
|
|
202
|
+
? knowledge.docs.find((item) => item.id === viewId)
|
|
203
|
+
: undefined;
|
|
204
|
+
if (viewId && !doc) {
|
|
205
|
+
return notFound(username, "That document is not on this server.", `/repos/${fullName}/knowledge`);
|
|
206
|
+
}
|
|
207
|
+
if (doc && url.searchParams.get("download") === "1") {
|
|
208
|
+
return new Response(doc.text, {
|
|
209
|
+
status: 200,
|
|
210
|
+
headers: {
|
|
211
|
+
"content-type": "text/markdown; charset=utf-8",
|
|
212
|
+
"content-disposition": `attachment; filename="${doc.file}"`,
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return renderKnowledge(username, knowledge, viewId);
|
|
173
217
|
}
|
|
174
218
|
if (sub === "settings") {
|
|
175
219
|
const config = readConfig();
|
|
176
|
-
|
|
220
|
+
let probeReport;
|
|
221
|
+
try {
|
|
222
|
+
const raw = await cacheGet("probe", fullName);
|
|
223
|
+
const parsed = raw ? JSON.parse(raw) : undefined;
|
|
224
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
225
|
+
probeReport = parsed;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// A missing or unreadable probe cache simply means no recommendation.
|
|
230
|
+
}
|
|
231
|
+
return renderRepoSettings(username, row, config.repos?.[fullName] ?? {}, probeReport);
|
|
177
232
|
}
|
|
178
233
|
}
|
|
179
234
|
}
|
|
180
235
|
catch (error) {
|
|
181
236
|
if (error instanceof RepoNotFound) {
|
|
182
|
-
return
|
|
237
|
+
return notFound(username, `That repository is not on this server.`, undefined);
|
|
183
238
|
}
|
|
184
239
|
throw error;
|
|
185
240
|
}
|
|
241
|
+
if (!url.pathname.startsWith("/api/")) {
|
|
242
|
+
return notFound(username, `Nothing is at ${url.pathname}.`, undefined);
|
|
243
|
+
}
|
|
186
244
|
return undefined;
|
|
187
245
|
}
|
|
188
|
-
function toHomeRow(item) {
|
|
189
|
-
const job = item.latestJob;
|
|
190
|
-
let statusKind = "ok";
|
|
191
|
-
let status = "Active";
|
|
192
|
-
if (job && (job.status === "running" || job.status === "queued")) {
|
|
193
|
-
statusKind = "run";
|
|
194
|
-
status = "Setting up";
|
|
195
|
-
}
|
|
196
|
-
else if (job?.status === "failed" && !item.repo.knowledge_built_at) {
|
|
197
|
-
statusKind = "err";
|
|
198
|
-
status = "Setup failed";
|
|
199
|
-
}
|
|
246
|
+
function toHomeRow(item, ready) {
|
|
200
247
|
let knowledge = "Not built";
|
|
201
248
|
let knowledgeAt;
|
|
202
249
|
if (item.repo.knowledge_built_at) {
|
|
@@ -206,12 +253,13 @@ function toHomeRow(item) {
|
|
|
206
253
|
}
|
|
207
254
|
return {
|
|
208
255
|
fullName: item.repo.full_name,
|
|
209
|
-
|
|
210
|
-
|
|
256
|
+
state: repoState(item, ready),
|
|
257
|
+
autoOn: item.repo.auto_review === 1,
|
|
258
|
+
fromCli: item.repo.added_from === "cli",
|
|
211
259
|
knowledge,
|
|
212
260
|
knowledgeAt,
|
|
213
|
-
autoOn: item.repo.auto_review === 1,
|
|
214
261
|
reviews: String(item.stats.reviews),
|
|
262
|
+
failed: item.stats.failed,
|
|
215
263
|
cost: formatCostTotal(item.stats),
|
|
216
264
|
};
|
|
217
265
|
}
|
|
@@ -251,10 +299,13 @@ async function repoPicker(githubApp) {
|
|
|
251
299
|
function isPagePath(pathname) {
|
|
252
300
|
return (pathname === "/" ||
|
|
253
301
|
pathname === "/setup" ||
|
|
302
|
+
pathname === "/__ui" ||
|
|
254
303
|
pathname === "/activity" ||
|
|
255
304
|
pathname.startsWith("/activity/") ||
|
|
256
305
|
pathname === "/analytics" ||
|
|
306
|
+
pathname === "/usage" ||
|
|
257
307
|
pathname === "/settings" ||
|
|
308
|
+
pathname.startsWith("/settings/") ||
|
|
258
309
|
pathname === "/repos/new" ||
|
|
259
310
|
pathname.startsWith("/repos/"));
|
|
260
311
|
}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { UserConfig } from "../../config.ts";
|
|
2
|
-
export
|
|
2
|
+
export type SettingsSection = "ai" | "github" | "defaults" | "remote" | "server" | "sign-in" | "danger";
|
|
3
|
+
export declare const SETTINGS_SECTIONS: readonly SettingsSection[];
|
|
4
|
+
export type RuntimeInfo = {
|
|
5
|
+
port?: number;
|
|
6
|
+
trustProxy?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** The combined `/settings` landing keeps every card (and the old bookmarks
|
|
9
|
+
* working) while each heading also has its own page. */
|
|
10
|
+
export declare function renderSettings(username: string, config: UserConfig, webhookUrl: string, baseUrl: string, runtime?: RuntimeInfo): Response;
|
|
11
|
+
export declare function renderSettingsPage(username: string, config: UserConfig, webhookUrl: string, baseUrl: string, section: SettingsSection, runtime?: RuntimeInfo): Response | undefined;
|