co-maintainer 0.6.3 → 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/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 +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 +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
|
@@ -4,18 +4,26 @@ import { activateRepo, deactivateRepo, getRepo, listActiveRepos, updateRepoSetti
|
|
|
4
4
|
import { readConfig, writeRepoConfig } from "../../config.js";
|
|
5
5
|
import { checkReviewSystemPrompt, reviewSystemPromptLimit, } from "../../review/system_prompt.js";
|
|
6
6
|
import { parseRemakeCron } from "../../services/remake_cron.js";
|
|
7
|
+
import { MAX_CONCURRENCY, MIN_CONCURRENCY, } from "../../services/concurrency.js";
|
|
7
8
|
import { parsePolicy, policyToStore, describePolicy, } from "../../services/review_policy.js";
|
|
8
9
|
import { enqueueSetup } from "../../services/setup.js";
|
|
10
|
+
import { appReady, filterRepoList } from "../../services/repo_list.js";
|
|
9
11
|
import { enqueueManualReview } from "../../services/review.js";
|
|
10
12
|
import { probePlan, recommendationPatch } from "../../services/probe.js";
|
|
11
13
|
import { estimateInit, readJobHistory } from "../../ai/estimate.js";
|
|
12
14
|
import { loadPrices } from "../../ai/pricing.js";
|
|
13
|
-
import { prDetail, repoKnowledge, RepoNotFound, repoOverview, repoPulls, requireActiveRepo, } from "../../services/dashboard.js";
|
|
15
|
+
import { listReposForHome, prDetail, repoKnowledge, RepoNotFound, repoOverview, repoPulls, requireActiveRepo, } from "../../services/dashboard.js";
|
|
14
16
|
import { clearOneRepo } from "./knowledge.js";
|
|
15
17
|
const REPO = /^\/api\/repos\/([^/]+)\/([^/]+)(?:\/(remake|knowledge|pulls)(?:\/(\d+)(?:\/(review))?)?)?$/;
|
|
16
18
|
export async function handleReposRoute(request, url, githubApp) {
|
|
17
19
|
if (url.pathname === "/api/repos" && request.method === "GET") {
|
|
18
|
-
|
|
20
|
+
const q = url.searchParams.get("q");
|
|
21
|
+
const status = url.searchParams.get("status");
|
|
22
|
+
if (q === null && status === null) {
|
|
23
|
+
return Response.json({ items: listActiveRepos() });
|
|
24
|
+
}
|
|
25
|
+
const items = filterRepoList(listReposForHome(), { q: q ?? undefined, status: status ?? undefined }, appReady());
|
|
26
|
+
return Response.json({ items: items.map((item) => item.repo) });
|
|
19
27
|
}
|
|
20
28
|
// The plain sentences shown under the policy editor before it is saved, so
|
|
21
29
|
// the wording lives in one place and the page never rebuilds it.
|
|
@@ -184,15 +192,19 @@ export async function handleReposRoute(request, url, githubApp) {
|
|
|
184
192
|
const raw = body.remakeCron;
|
|
185
193
|
if (raw === null || raw === "") {
|
|
186
194
|
cronPatch.remakeCron = undefined;
|
|
195
|
+
cronPatch.remakeCronDraft = undefined;
|
|
187
196
|
}
|
|
188
197
|
else if (typeof raw === "string") {
|
|
189
198
|
try {
|
|
190
199
|
parseRemakeCron(raw);
|
|
191
200
|
}
|
|
192
201
|
catch (error) {
|
|
202
|
+
// Keep what was typed only for the form, never as a schedule.
|
|
203
|
+
await writeRepoConfig(fullName, { remakeCronDraft: raw });
|
|
193
204
|
return errorResponse(422, "invalid_cron", error instanceof Error ? error.message : String(error));
|
|
194
205
|
}
|
|
195
206
|
cronPatch.remakeCron = raw.trim();
|
|
207
|
+
cronPatch.remakeCronDraft = undefined;
|
|
196
208
|
}
|
|
197
209
|
else {
|
|
198
210
|
return errorResponse(422, "invalid_cron", "remakeCron must be text or null");
|
|
@@ -253,6 +265,36 @@ export async function handleReposRoute(request, url, githubApp) {
|
|
|
253
265
|
}
|
|
254
266
|
patch.review_policy_json = stored.value;
|
|
255
267
|
}
|
|
268
|
+
const speedPatch = {};
|
|
269
|
+
for (const key of ["ghConcurrent", "aiConcurrent"]) {
|
|
270
|
+
if (!(key in body))
|
|
271
|
+
continue;
|
|
272
|
+
const raw = body[key];
|
|
273
|
+
if (raw === null || raw === "") {
|
|
274
|
+
speedPatch[key] = undefined;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (typeof raw !== "number" ||
|
|
278
|
+
!Number.isInteger(raw) ||
|
|
279
|
+
raw < MIN_CONCURRENCY ||
|
|
280
|
+
raw > MAX_CONCURRENCY) {
|
|
281
|
+
return errorResponse(422, "invalid_concurrency", `${key} must be an integer between ${MIN_CONCURRENCY} and ${MAX_CONCURRENCY}`);
|
|
282
|
+
}
|
|
283
|
+
speedPatch[key] = raw;
|
|
284
|
+
}
|
|
285
|
+
const blockingPatch = {};
|
|
286
|
+
if ("reviewBlocking" in body) {
|
|
287
|
+
const raw = body.reviewBlocking;
|
|
288
|
+
if (raw === null || raw === "") {
|
|
289
|
+
blockingPatch.reviewBlocking = undefined;
|
|
290
|
+
}
|
|
291
|
+
else if (raw === "model" || raw === "severity") {
|
|
292
|
+
blockingPatch.reviewBlocking = raw;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
return errorResponse(422, "invalid_review_blocking", "reviewBlocking must be model or severity");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
256
298
|
if (typeof body.autoReview === "boolean") {
|
|
257
299
|
patch.auto_review = body.autoReview ? 1 : 0;
|
|
258
300
|
}
|
|
@@ -296,14 +338,15 @@ export async function handleReposRoute(request, url, githubApp) {
|
|
|
296
338
|
init[key] = body[key];
|
|
297
339
|
}
|
|
298
340
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
341
|
+
const repoPatch = {
|
|
342
|
+
...init,
|
|
343
|
+
...cronPatch,
|
|
344
|
+
...promptPatch,
|
|
345
|
+
...speedPatch,
|
|
346
|
+
...blockingPatch,
|
|
347
|
+
};
|
|
348
|
+
if (Object.keys(repoPatch).length > 0) {
|
|
349
|
+
await writeRepoConfig(fullName, repoPatch);
|
|
307
350
|
}
|
|
308
351
|
return Response.json({ ok: true });
|
|
309
352
|
}
|
|
@@ -328,7 +371,26 @@ export async function handleReposRoute(request, url, githubApp) {
|
|
|
328
371
|
action === "review" &&
|
|
329
372
|
request.method === "POST") {
|
|
330
373
|
requireActiveRepo(fullName);
|
|
331
|
-
|
|
374
|
+
// An optional `{ model }` pins the review to the model a failed one
|
|
375
|
+
// used. No body, or no model, keeps the configured model.
|
|
376
|
+
let body = {};
|
|
377
|
+
try {
|
|
378
|
+
const raw = await request.text();
|
|
379
|
+
if (raw.trim())
|
|
380
|
+
body = JSON.parse(raw);
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
return errorResponse(400, "bad_request", "expected a JSON body");
|
|
384
|
+
}
|
|
385
|
+
if (body.model !== undefined &&
|
|
386
|
+
(typeof body.model !== "string" ||
|
|
387
|
+
body.model.length === 0 ||
|
|
388
|
+
body.model.length > 200)) {
|
|
389
|
+
return errorResponse(422, "invalid_setting", "model must be a model id of 1 to 200 characters");
|
|
390
|
+
}
|
|
391
|
+
const { id } = enqueueManualReview(fullName, pr, {
|
|
392
|
+
model: body.model,
|
|
393
|
+
});
|
|
332
394
|
return Response.json({ jobId: id });
|
|
333
395
|
}
|
|
334
396
|
if (sub === "pulls" && pr && request.method === "GET") {
|
|
@@ -99,6 +99,12 @@ export async function handleSettingsRoute(request, url, webhookUrl, passwords, i
|
|
|
99
99
|
text("githubOAuthClientId");
|
|
100
100
|
text("githubOAuthClientSecret");
|
|
101
101
|
text("githubOAuthAllowedUser");
|
|
102
|
+
// A key means nothing without the provider it belongs to: saving one
|
|
103
|
+
// with no provider would read "A key is saved" next to "Not set".
|
|
104
|
+
const provider = patch.ai ?? current.ai;
|
|
105
|
+
if (patch.token && (!provider || provider === "none")) {
|
|
106
|
+
return errorResponse(422, "provider_required", "Choose a provider before saving an API key.");
|
|
107
|
+
}
|
|
102
108
|
const previousAi = savedKeyProvider(current);
|
|
103
109
|
if (patch.ai &&
|
|
104
110
|
patch.ai !== "none" &&
|
package/dist/src/server/app.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type AppDeps = {
|
|
|
6
6
|
passwordStore?: PasswordStore;
|
|
7
7
|
webhookUrl?: string;
|
|
8
8
|
secureCookie?: boolean;
|
|
9
|
+
/** The port `serve` is listening on, shown on the Server page. */
|
|
10
|
+
port?: number;
|
|
9
11
|
/** Behind a reverse proxy this process trusts, the client address and the
|
|
10
12
|
* scheme come from `x-forwarded-for` and `x-forwarded-proto`. */
|
|
11
13
|
trustProxy?: boolean;
|
|
@@ -13,6 +15,9 @@ export type AppDeps = {
|
|
|
13
15
|
* "printed when serve started" line. */
|
|
14
16
|
loginHint?: string;
|
|
15
17
|
inject500?: boolean;
|
|
18
|
+
/** Exposes the internal `/__ui` component gallery. `serve --debug` /
|
|
19
|
+
* `CM_DEBUG=1` sets it. */
|
|
20
|
+
debug?: boolean;
|
|
16
21
|
/** Defaults to password-only when omitted, matching every caller that
|
|
17
22
|
* pre-dates GitHub sign-in. */
|
|
18
23
|
auth?: AuthMethods;
|
package/dist/src/server/app.js
CHANGED
|
@@ -9,6 +9,9 @@ import { aiConfigured, readConfig, resolveAppPrivateKey } from "../config.js";
|
|
|
9
9
|
import { listJobs } from "../store/jobs.js";
|
|
10
10
|
import { handleJobsRoute } from "./api/jobs.js";
|
|
11
11
|
import { handleReposRoute } from "./api/repos.js";
|
|
12
|
+
import { searchAll } from "../services/search.js";
|
|
13
|
+
import { navCounts } from "../services/nav_counts.js";
|
|
14
|
+
import { setNavSource } from "./pages/layout.js";
|
|
12
15
|
import { handleKnowledgeRoute } from "./api/knowledge.js";
|
|
13
16
|
import { handleInstallationsRoute } from "./api/installations.js";
|
|
14
17
|
import { handleSettingsRoute } from "./api/settings.js";
|
|
@@ -98,6 +101,7 @@ function liveGithubConfig() {
|
|
|
98
101
|
}
|
|
99
102
|
export function createApp(deps) {
|
|
100
103
|
const passwords = deps.passwordStore ?? memoryPasswordStore(deps.password);
|
|
104
|
+
setNavSource(() => navCounts(deps.webhookUrl ?? ""));
|
|
101
105
|
return {
|
|
102
106
|
async fetch(request, socketAddress = "unknown") {
|
|
103
107
|
const url = new URL(request.url);
|
|
@@ -149,6 +153,9 @@ export function createApp(deps) {
|
|
|
149
153
|
...setupStatus(),
|
|
150
154
|
});
|
|
151
155
|
}
|
|
156
|
+
if (url.pathname === "/api/search" && request.method === "GET") {
|
|
157
|
+
return Response.json(searchAll(url.searchParams.get("q") ?? ""));
|
|
158
|
+
}
|
|
152
159
|
if (url.pathname.startsWith("/api/jobs")) {
|
|
153
160
|
return handleJobsRoute(request, url);
|
|
154
161
|
}
|
|
@@ -3,6 +3,9 @@ export type HttpServer = {
|
|
|
3
3
|
port: number;
|
|
4
4
|
shutdown: () => Promise<void>;
|
|
5
5
|
finished: Promise<void>;
|
|
6
|
+
/** Settles once the port is bound: rejects with the listen error (a busy
|
|
7
|
+
* port is `EADDRINUSE`), so nothing claims to listen before it does. */
|
|
8
|
+
ready: Promise<void>;
|
|
6
9
|
};
|
|
7
10
|
/** Starts an HTTP server that hands each request to `app`. */
|
|
8
11
|
export declare function serveHttp(app: FetchApp, port: number): HttpServer;
|
package/dist/src/server/http.js
CHANGED
|
@@ -99,9 +99,14 @@ export function serveHttp(app, port) {
|
|
|
99
99
|
}
|
|
100
100
|
})();
|
|
101
101
|
});
|
|
102
|
+
const ready = new Promise((resolve, reject) => {
|
|
103
|
+
server.once("listening", () => resolve());
|
|
104
|
+
server.once("error", reject);
|
|
105
|
+
});
|
|
102
106
|
server.listen(port);
|
|
103
107
|
return {
|
|
104
108
|
port,
|
|
109
|
+
ready,
|
|
105
110
|
shutdown: () => new Promise((resolve) => {
|
|
106
111
|
// SSE streams never end on their own, so `close()` alone would wait
|
|
107
112
|
// forever. Tear the connections down, then wait for the close event
|