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
|
@@ -6,6 +6,9 @@ export declare const AI_PROVIDERS: readonly ["none", "openrouter", "openai", "an
|
|
|
6
6
|
export { providerKeyEnv } from "../config.ts";
|
|
7
7
|
/** Hetzner was dropped in 0.5.1. Naming it beats a generic "must be one of". */
|
|
8
8
|
export declare function rejectRetiredProvider(value: string | undefined): void;
|
|
9
|
+
/** The provider a run actually calls. `--experimental-siwc` overrides the
|
|
10
|
+
* configured `ai` for the run, so logs and error labels name what ran. */
|
|
11
|
+
export declare function aiProviderName(options: Options): string;
|
|
9
12
|
export declare function createAiProvider(options: Options, model: string): AiProvider | undefined;
|
|
10
13
|
/** A 400 that names one optional part of the request earns one retry without
|
|
11
14
|
* it: the JSON schema, which the prompt asks for anyway, or "thinking off",
|
package/dist/src/ai/provider.js
CHANGED
|
@@ -2,6 +2,7 @@ import { OpenRouterProvider } from "./openrouter.js";
|
|
|
2
2
|
import { OpenAiProvider } from "./openai.js";
|
|
3
3
|
import { AnthropicProvider } from "./anthropic.js";
|
|
4
4
|
import { openCodeHost } from "./opencode.js";
|
|
5
|
+
import { EXPERIMENTAL_OAUTH_PROVIDER, oauthOps } from "./oauth/registry.js";
|
|
5
6
|
import { die } from "../cli/error.js";
|
|
6
7
|
/** The one list of accepted `--ai` values, so a new or retired provider is
|
|
7
8
|
* added or removed in a single place instead of the half dozen copies
|
|
@@ -21,9 +22,17 @@ export function rejectRetiredProvider(value) {
|
|
|
21
22
|
die("Hetzner is no longer supported. Use openrouter or none.");
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
/** The provider a run actually calls. `--experimental-siwc` overrides the
|
|
26
|
+
* configured `ai` for the run, so logs and error labels name what ran. */
|
|
27
|
+
export function aiProviderName(options) {
|
|
28
|
+
return options.experimentalSiwc ? EXPERIMENTAL_OAUTH_PROVIDER : options.ai;
|
|
29
|
+
}
|
|
24
30
|
export function createAiProvider(options, model) {
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
// `--experimental-siwc` wins over `--ai` for the run; `parseArgs` refuses
|
|
32
|
+
// the two together, so this only sees one of them set.
|
|
33
|
+
if (options.experimentalSiwc) {
|
|
34
|
+
return oauthOps(EXPERIMENTAL_OAUTH_PROVIDER).createProvider(model);
|
|
35
|
+
}
|
|
27
36
|
if (options.ai === "openrouter") {
|
|
28
37
|
return new OpenRouterProvider(options.aiToken ?? "", model);
|
|
29
38
|
}
|
package/dist/src/cli/args.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { prepareConfig, savedTokenFor } from "../config.js";
|
|
2
|
+
import { MAX_CONCURRENCY, MIN_CONCURRENCY, resolveConcurrency, } from "../services/concurrency.js";
|
|
2
3
|
import { getEnv } from "../util/runtime.js";
|
|
3
4
|
import { askLine } from "./prompt.js";
|
|
4
5
|
import { die } from "./error.js";
|
|
5
6
|
import { AI_PROVIDERS, providerKeyEnv, rejectRetiredProvider, } from "../ai/provider.js";
|
|
7
|
+
import { availableModelSlugs } from "../ai/oauth/sign-in-with-chatgpt.js";
|
|
6
8
|
import { detectRemoteRepo } from "../local/git_ops.js";
|
|
7
9
|
import { reviewBlockingFrom } from "../review/blocking.js";
|
|
8
10
|
import { renderCommandHelp, renderGlobalHelp, unknownCommandMessage, unknownOptionMessage, } from "./commands/registry.js";
|
|
@@ -70,7 +72,9 @@ export async function parseArgs(args) {
|
|
|
70
72
|
// Remembered from a prior `init`/`remake` on this exact repo — never a
|
|
71
73
|
// secret, so it can safely fill in everything except the API token.
|
|
72
74
|
const repoConfig = config.repos?.[repoName] ?? {};
|
|
73
|
-
const reviewBlocking = reviewBlockingFrom(env("CO_MAINTAINER_REVIEW_BLOCKING") ??
|
|
75
|
+
const reviewBlocking = reviewBlockingFrom(env("CO_MAINTAINER_REVIEW_BLOCKING") ??
|
|
76
|
+
repoConfig.reviewBlocking ??
|
|
77
|
+
config.reviewBlocking);
|
|
74
78
|
let prNumber;
|
|
75
79
|
if (command === "review") {
|
|
76
80
|
const rawNumber = rest[0];
|
|
@@ -103,6 +107,20 @@ export async function parseArgs(args) {
|
|
|
103
107
|
? numberOption(arg.slice(name.length + 3), `--${name}`)
|
|
104
108
|
: undefined;
|
|
105
109
|
};
|
|
110
|
+
const concurrencyValue = (name, fallback) => {
|
|
111
|
+
const arg = rest.find((item) => item.startsWith(`--${name}=`));
|
|
112
|
+
if (!arg)
|
|
113
|
+
return fallback;
|
|
114
|
+
const raw = arg.slice(name.length + 3);
|
|
115
|
+
const number = Number(raw);
|
|
116
|
+
if (raw.trim() === "" ||
|
|
117
|
+
!Number.isInteger(number) ||
|
|
118
|
+
number < MIN_CONCURRENCY ||
|
|
119
|
+
number > MAX_CONCURRENCY) {
|
|
120
|
+
die(`--${name} must be an integer between ${MIN_CONCURRENCY} and ${MAX_CONCURRENCY}`);
|
|
121
|
+
}
|
|
122
|
+
return number;
|
|
123
|
+
};
|
|
106
124
|
const text = (name) => rest.find((item) => item.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
107
125
|
const prStateOption = (args, saved) => {
|
|
108
126
|
const prefix = "--pr-state=";
|
|
@@ -160,12 +178,17 @@ export async function parseArgs(args) {
|
|
|
160
178
|
arg === "--review-upstream" ||
|
|
161
179
|
arg === "--disable-codegraph" ||
|
|
162
180
|
arg === "--run" ||
|
|
163
|
-
arg === "--only-request-changed-pr"
|
|
181
|
+
arg === "--only-request-changed-pr" ||
|
|
182
|
+
arg === "--experimental-siwc")
|
|
164
183
|
continue;
|
|
165
184
|
if (arg.startsWith("--") && !known)
|
|
166
185
|
die(unknownOptionMessage(arg, command));
|
|
167
186
|
}
|
|
168
187
|
const explicitAi = rest.some((arg) => arg.startsWith("--ai="));
|
|
188
|
+
const experimentalSiwc = rest.includes("--experimental-siwc");
|
|
189
|
+
if (experimentalSiwc && explicitAi) {
|
|
190
|
+
die("--experimental-siwc cannot be combined with --ai");
|
|
191
|
+
}
|
|
169
192
|
const configuredAiRaw = env("CO_MAINTAINER_AI") ?? repoConfig.ai ?? config.ai;
|
|
170
193
|
rejectRetiredProvider(configuredAiRaw);
|
|
171
194
|
if (configuredAiRaw &&
|
|
@@ -189,24 +212,26 @@ export async function parseArgs(args) {
|
|
|
189
212
|
}
|
|
190
213
|
rejectRetiredProvider(text("ai"));
|
|
191
214
|
let ai = choice("ai", AI_PROVIDERS, configuredAi ?? "none");
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (
|
|
198
|
-
|
|
215
|
+
if (!experimentalSiwc) {
|
|
216
|
+
if (command === "review") {
|
|
217
|
+
// Review was pinned to OpenRouter only so Hetzner never wrote one.
|
|
218
|
+
// Hetzner is gone, so review follows the configured provider. With none
|
|
219
|
+
// set it stays on OpenRouter, which every review before this one used.
|
|
220
|
+
if (ai === "none") {
|
|
221
|
+
if (explicitAi) {
|
|
222
|
+
die(`review needs an AI provider. Pass --ai=${AI_PROVIDERS.filter((p) => p !== "none").join("|")}`);
|
|
223
|
+
}
|
|
224
|
+
ai = "openrouter";
|
|
199
225
|
}
|
|
200
|
-
ai = "openrouter";
|
|
201
226
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
227
|
+
else if (!explicitAi && !configuredAi && command !== "probe") {
|
|
228
|
+
const selected = await ask(`AI provider (${AI_PROVIDERS.filter((p) => p !== "none").join("|")})`, "openrouter");
|
|
229
|
+
rejectRetiredProvider(selected);
|
|
230
|
+
if (!AI_PROVIDERS.includes(selected)) {
|
|
231
|
+
die(`AI provider must be one of: ${AI_PROVIDERS.join(", ")}`);
|
|
232
|
+
}
|
|
233
|
+
ai = selected;
|
|
208
234
|
}
|
|
209
|
-
ai = selected;
|
|
210
235
|
}
|
|
211
236
|
let aiToken = text("token") ??
|
|
212
237
|
env("CO_MAINTAINER_TOKEN") ??
|
|
@@ -225,7 +250,19 @@ export async function parseArgs(args) {
|
|
|
225
250
|
env("HIGH_MODEL") ??
|
|
226
251
|
repoConfig.highModel ??
|
|
227
252
|
config.highModel;
|
|
228
|
-
if (
|
|
253
|
+
if (experimentalSiwc) {
|
|
254
|
+
// No API key: the OAuth credentials cover the run. The models still come
|
|
255
|
+
// from the user, but the account's own list is shown first so the value
|
|
256
|
+
// is easy to pick, and it is shown again on a bad model.
|
|
257
|
+
if (command !== "probe" && (!lowModel || !highModel)) {
|
|
258
|
+
const slugs = await availableModelSlugs().catch(() => []);
|
|
259
|
+
if (slugs.length)
|
|
260
|
+
console.log(`ChatGPT models: ${slugs.join(", ")}`);
|
|
261
|
+
}
|
|
262
|
+
lowModel ??= await ask("low model", undefined, true);
|
|
263
|
+
highModel ??= await ask("high model", undefined, true);
|
|
264
|
+
}
|
|
265
|
+
else if (command === "review") {
|
|
229
266
|
aiToken ??= await ask(`${ai} API key`, undefined, true);
|
|
230
267
|
// Review summarizes large files with the low model, so it needs one just
|
|
231
268
|
// as init and sync do. Without a default to fall back on, ask here too.
|
|
@@ -240,11 +277,13 @@ export async function parseArgs(args) {
|
|
|
240
277
|
lowModel ??= await ask("low model", undefined, true);
|
|
241
278
|
highModel ??= await ask("high model", undefined, true);
|
|
242
279
|
}
|
|
243
|
-
if (
|
|
280
|
+
if (!experimentalSiwc &&
|
|
281
|
+
command !== "review" &&
|
|
244
282
|
ai !== "none" &&
|
|
245
283
|
(!lowModel || !highModel || !aiToken)) {
|
|
246
284
|
die("--token, --low-model, and --high-model are required when AI is enabled");
|
|
247
285
|
}
|
|
286
|
+
const resolvedConcurrency = resolveConcurrency(repoName, config);
|
|
248
287
|
return {
|
|
249
288
|
command: command === "sync" ? "remake" : command,
|
|
250
289
|
repo: repoName,
|
|
@@ -256,12 +295,13 @@ export async function parseArgs(args) {
|
|
|
256
295
|
useCodegraph: command === "review" ? !rest.includes("--disable-codegraph") : false,
|
|
257
296
|
envPath,
|
|
258
297
|
improveMatrix: value("improve-matrix") ?? 1,
|
|
259
|
-
ghConcurrent:
|
|
260
|
-
aiConcurrent:
|
|
298
|
+
ghConcurrent: concurrencyValue("gh-concurrent", resolvedConcurrency.gh),
|
|
299
|
+
aiConcurrent: concurrencyValue("ai-concurrent", resolvedConcurrency.ai),
|
|
261
300
|
auth,
|
|
262
301
|
githubPat,
|
|
263
302
|
ai,
|
|
264
303
|
aiToken,
|
|
304
|
+
...(experimentalSiwc ? { experimentalSiwc: true } : {}),
|
|
265
305
|
lowModel,
|
|
266
306
|
highModel,
|
|
267
307
|
synthesisVersion: 17,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runOAuth(args: string[]): Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** `co-maintainer oauth login|logout|refresh|ping|list-models --provider=...`
|
|
2
|
+
*
|
|
3
|
+
* The credential side of the experimental Sign in with ChatGPT support. Only
|
|
4
|
+
* `login` starts a browser flow; the rest operate on an existing login and
|
|
5
|
+
* fail clearly when there is none. See `docs/docs/providers.md`. */
|
|
6
|
+
import { die } from "../error.js";
|
|
7
|
+
import { oauthOps, oauthUnknownProvider, resolveOAuthProvider, } from "../../ai/oauth/registry.js";
|
|
8
|
+
import { renderCommandHelp, renderGlobalHelp } from "./registry.js";
|
|
9
|
+
const SUBCOMMANDS = [
|
|
10
|
+
"login",
|
|
11
|
+
"logout",
|
|
12
|
+
"refresh",
|
|
13
|
+
"ping",
|
|
14
|
+
"list-models",
|
|
15
|
+
];
|
|
16
|
+
function text(args, name) {
|
|
17
|
+
return args
|
|
18
|
+
.find((arg) => arg.startsWith(`--${name}=`))
|
|
19
|
+
?.slice(name.length + 3);
|
|
20
|
+
}
|
|
21
|
+
export async function runOAuth(args) {
|
|
22
|
+
const sub = args[0];
|
|
23
|
+
if (!sub || sub === "--help" || sub === "-h" || sub === "help") {
|
|
24
|
+
console.log(renderCommandHelp("oauth") ?? renderGlobalHelp());
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!SUBCOMMANDS.includes(sub)) {
|
|
28
|
+
die(`oauth must be one of: ${SUBCOMMANDS.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
for (const arg of args.slice(1)) {
|
|
31
|
+
if (!arg.startsWith("--provider=")) {
|
|
32
|
+
die(`Unknown option: ${arg}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const provider = resolveOAuthProvider(text(args, "provider"));
|
|
36
|
+
if (!provider)
|
|
37
|
+
throw oauthUnknownProvider(text(args, "provider"));
|
|
38
|
+
const ops = oauthOps(provider);
|
|
39
|
+
const printModels = (models) => {
|
|
40
|
+
if (models.length === 0) {
|
|
41
|
+
console.log("No models are available to this account.");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
console.log("Available models:");
|
|
45
|
+
for (const model of models) {
|
|
46
|
+
console.log(` ${model.slug} (${model.displayName})`);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
if (sub === "login") {
|
|
50
|
+
const creds = await ops.login();
|
|
51
|
+
console.log(`Signed in${creds.email ? ` as ${creds.email}` : ""}. Saved to ${ops.credentialsPath()}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (sub === "logout") {
|
|
55
|
+
const removed = await ops.logout();
|
|
56
|
+
console.log(removed
|
|
57
|
+
? "Signed out. The saved ChatGPT credentials were removed."
|
|
58
|
+
: "Nothing to sign out.");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (sub === "refresh") {
|
|
62
|
+
const creds = await ops.refresh();
|
|
63
|
+
console.log(`Refreshed. New expiry: ${new Date(creds.expires_at).toISOString()}`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (sub === "ping") {
|
|
67
|
+
const { credentials, models } = await ops.ping();
|
|
68
|
+
console.log(`Signed in${credentials.email ? ` as ${credentials.email}` : ""}.`);
|
|
69
|
+
printModels(models);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
printModels(await ops.listModels());
|
|
73
|
+
}
|
|
@@ -73,6 +73,17 @@ const AI_FLAGS_REQUIRED = {
|
|
|
73
73
|
...AI_KEY_FLAGS,
|
|
74
74
|
],
|
|
75
75
|
};
|
|
76
|
+
/** `--experimental-siwc`: run on a ChatGPT plan through Sign in with ChatGPT
|
|
77
|
+
* instead of an API key. Its own group so it reads as not yet settled. */
|
|
78
|
+
const EXPERIMENTAL_FLAGS = {
|
|
79
|
+
title: "Experimental",
|
|
80
|
+
flags: [
|
|
81
|
+
{
|
|
82
|
+
name: "experimental-siwc",
|
|
83
|
+
description: "Run on your ChatGPT plan through Sign in with ChatGPT instead of an API key. Cannot be combined with --ai. Set up with co-maintainer oauth.",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
76
87
|
const GITHUB_FLAGS = {
|
|
77
88
|
title: "GitHub access",
|
|
78
89
|
flags: [
|
|
@@ -203,6 +214,7 @@ export const COMMANDS = [
|
|
|
203
214
|
],
|
|
204
215
|
},
|
|
205
216
|
AI_FLAGS_REQUIRED,
|
|
217
|
+
EXPERIMENTAL_FLAGS,
|
|
206
218
|
GITHUB_FLAGS,
|
|
207
219
|
OUTPUT_FLAGS,
|
|
208
220
|
{
|
|
@@ -212,13 +224,13 @@ export const COMMANDS = [
|
|
|
212
224
|
name: "gh-concurrent",
|
|
213
225
|
value: "N",
|
|
214
226
|
default: "1",
|
|
215
|
-
description: "Concurrent
|
|
227
|
+
description: "Concurrent GitHub calls for this run only. It does not change the saved default.",
|
|
216
228
|
},
|
|
217
229
|
{
|
|
218
230
|
name: "ai-concurrent",
|
|
219
231
|
value: "N",
|
|
220
232
|
default: "3",
|
|
221
|
-
description: "Concurrent AI calls.",
|
|
233
|
+
description: "Concurrent AI calls for this run only. It does not change the saved default.",
|
|
222
234
|
},
|
|
223
235
|
{
|
|
224
236
|
name: "improve-matrix",
|
|
@@ -290,8 +302,26 @@ export const COMMANDS = [
|
|
|
290
302
|
],
|
|
291
303
|
},
|
|
292
304
|
AI_FLAGS_REQUIRED,
|
|
305
|
+
EXPERIMENTAL_FLAGS,
|
|
293
306
|
GITHUB_FLAGS,
|
|
294
307
|
OUTPUT_FLAGS,
|
|
308
|
+
{
|
|
309
|
+
title: "Performance",
|
|
310
|
+
flags: [
|
|
311
|
+
{
|
|
312
|
+
name: "gh-concurrent",
|
|
313
|
+
value: "N",
|
|
314
|
+
default: "1",
|
|
315
|
+
description: "Concurrent GitHub calls for this run only. It does not change the saved default.",
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: "ai-concurrent",
|
|
319
|
+
value: "N",
|
|
320
|
+
default: "3",
|
|
321
|
+
description: "Concurrent AI calls for this run only. It does not change the saved default.",
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
},
|
|
295
325
|
],
|
|
296
326
|
examples: ["co-maintainer sync owner/repo --include-codebase"],
|
|
297
327
|
},
|
|
@@ -387,6 +417,7 @@ export const COMMANDS = [
|
|
|
387
417
|
],
|
|
388
418
|
},
|
|
389
419
|
AI_FLAGS,
|
|
420
|
+
EXPERIMENTAL_FLAGS,
|
|
390
421
|
GITHUB_FLAGS,
|
|
391
422
|
REVIEW_OUTPUT_FLAGS,
|
|
392
423
|
],
|
|
@@ -505,6 +536,33 @@ export const COMMANDS = [
|
|
|
505
536
|
],
|
|
506
537
|
examples: ["co-maintainer uninstall", "co-maintainer uninstall --yes"],
|
|
507
538
|
},
|
|
539
|
+
{
|
|
540
|
+
name: "oauth",
|
|
541
|
+
summary: "Sign in to an OAuth AI provider (experimental).",
|
|
542
|
+
usage: [
|
|
543
|
+
"co-maintainer oauth login --provider=sign-in-with-chatgpt",
|
|
544
|
+
"co-maintainer oauth logout --provider=sign-in-with-chatgpt",
|
|
545
|
+
"co-maintainer oauth refresh --provider=sign-in-with-chatgpt",
|
|
546
|
+
"co-maintainer oauth ping --provider=sign-in-with-chatgpt",
|
|
547
|
+
"co-maintainer oauth list-models --provider=sign-in-with-chatgpt",
|
|
548
|
+
],
|
|
549
|
+
groups: [
|
|
550
|
+
{
|
|
551
|
+
title: "OAuth",
|
|
552
|
+
flags: [
|
|
553
|
+
{
|
|
554
|
+
name: "provider",
|
|
555
|
+
value: "sign-in-with-chatgpt",
|
|
556
|
+
description: "Which provider to sign in to. `siwc` is accepted as a short alias.",
|
|
557
|
+
},
|
|
558
|
+
],
|
|
559
|
+
},
|
|
560
|
+
],
|
|
561
|
+
examples: [
|
|
562
|
+
"co-maintainer oauth login --provider=sign-in-with-chatgpt",
|
|
563
|
+
"co-maintainer oauth list-models --provider=siwc",
|
|
564
|
+
],
|
|
565
|
+
},
|
|
508
566
|
{
|
|
509
567
|
name: "set",
|
|
510
568
|
summary: "Persist defaults and secrets to the user config file.",
|
|
@@ -597,6 +655,16 @@ export const COMMANDS = [
|
|
|
597
655
|
value: "owner/repo",
|
|
598
656
|
description: "Write the repository-scoped settings below to this repository instead of the global config.",
|
|
599
657
|
},
|
|
658
|
+
{
|
|
659
|
+
name: "gh-concurrent",
|
|
660
|
+
value: "N",
|
|
661
|
+
description: "Server default for concurrent GitHub calls. With --repo, the repository override. 1..16.",
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
name: "ai-concurrent",
|
|
665
|
+
value: "N",
|
|
666
|
+
description: "Server default for concurrent AI calls. With --repo, the repository override. 1..16.",
|
|
667
|
+
},
|
|
600
668
|
{
|
|
601
669
|
name: "review-system-prompt",
|
|
602
670
|
value: "TEXT",
|
|
@@ -813,7 +881,15 @@ function renderFlags(groups, lines) {
|
|
|
813
881
|
for (const flag of group.flags) {
|
|
814
882
|
const head = ` --${flag.name}${flag.value ? `=${flag.value}` : ""}`;
|
|
815
883
|
const meta = flag.default !== undefined ? ` (default: ${flag.default})` : "";
|
|
816
|
-
|
|
884
|
+
// An option too long for the 42-column gutter gets its own line, so
|
|
885
|
+
// its last value never runs into the description.
|
|
886
|
+
if (head.length + 2 > 42) {
|
|
887
|
+
lines.push(head);
|
|
888
|
+
lines.push(`${" ".repeat(42)}${flag.description}${meta}`);
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
lines.push(`${head.padEnd(42)}${flag.description}${meta}`);
|
|
892
|
+
}
|
|
817
893
|
}
|
|
818
894
|
}
|
|
819
895
|
}
|
|
@@ -4,6 +4,8 @@ import { createApp } from "../../server/app.js";
|
|
|
4
4
|
import { configPasswordStore } from "../../server/auth.js";
|
|
5
5
|
import { recoverOrphans, startWorkerLoop, stopWorkerLoop, } from "../../services/jobs.js";
|
|
6
6
|
import { registerSetupJobHandler } from "../../services/setup.js";
|
|
7
|
+
import { setupChecklist } from "../../services/setup_checklist.js";
|
|
8
|
+
import { discoverCliRepos } from "../../services/cli_repos.js";
|
|
7
9
|
import { registerReviewJobHandler } from "../../services/review.js";
|
|
8
10
|
import { recoverReplyRequests, registerReplyJobHandler, } from "../../services/replies.js";
|
|
9
11
|
import { startRemakeScheduler, stopRemakeScheduler, } from "../../services/remake_cron.js";
|
|
@@ -157,10 +159,13 @@ export async function runServe(args) {
|
|
|
157
159
|
console.log(`[serve] warning: ${warning}`);
|
|
158
160
|
await openAppDb();
|
|
159
161
|
console.log(`[serve] app.db ready at ${appDbPath()}`);
|
|
162
|
+
const fromCli = await discoverCliRepos();
|
|
163
|
+
if (fromCli.length > 0) {
|
|
164
|
+
console.log(`[serve] added ${fromCli.length} repositor${fromCli.length === 1 ? "y" : "ies"} built from the CLI: ${fromCli.join(", ")}`);
|
|
165
|
+
}
|
|
160
166
|
registerSetupJobHandler();
|
|
161
167
|
registerReviewJobHandler();
|
|
162
168
|
registerRemoteReviewHandler();
|
|
163
|
-
startRemoteWatchdog();
|
|
164
169
|
registerReplyJobHandler();
|
|
165
170
|
const recovered = await recoverOrphans();
|
|
166
171
|
if (recovered > 0) {
|
|
@@ -170,8 +175,6 @@ export async function runServe(args) {
|
|
|
170
175
|
if (recoveredReplies > 0) {
|
|
171
176
|
console.log(`[serve] requeued ${recoveredReplies} unfinished conversation repl${recoveredReplies === 1 ? "y" : "ies"}`);
|
|
172
177
|
}
|
|
173
|
-
startWorkerLoop();
|
|
174
|
-
startRemakeScheduler();
|
|
175
178
|
if (auth.github)
|
|
176
179
|
console.log(`[serve] GitHub sign-in enabled for ${githubOAuth.allowedUser}`);
|
|
177
180
|
const trustProxy = resolveTrustProxy(args);
|
|
@@ -182,19 +185,44 @@ export async function runServe(args) {
|
|
|
182
185
|
if (inject500) {
|
|
183
186
|
console.log("[serve] --inject-500 is on. Mutating /api requests return 500.");
|
|
184
187
|
}
|
|
188
|
+
const debug = args.includes("--debug") || getEnv("CM_DEBUG") === "1";
|
|
189
|
+
if (debug) {
|
|
190
|
+
console.log("[serve] --debug is on. The /__ui component gallery is available.");
|
|
191
|
+
}
|
|
185
192
|
const app = createApp({
|
|
186
193
|
password: "",
|
|
187
194
|
passwordStore,
|
|
188
195
|
webhookUrl,
|
|
189
196
|
inject500,
|
|
197
|
+
port,
|
|
190
198
|
trustProxy,
|
|
191
199
|
auth,
|
|
192
200
|
githubOAuth,
|
|
201
|
+
debug,
|
|
193
202
|
loginHint: getEnv("CM_LOGIN_HINT"),
|
|
194
203
|
});
|
|
195
204
|
const server = serveHttp((req, remoteAddr) => app.fetch(req, remoteAddr), port);
|
|
205
|
+
// Nothing runs in the background and nothing claims to listen until the
|
|
206
|
+
// port is really bound, so a busy port leaves no worker behind.
|
|
207
|
+
try {
|
|
208
|
+
await server.ready;
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
await closeAppDb();
|
|
212
|
+
const code = error.code;
|
|
213
|
+
die(code === "EADDRINUSE"
|
|
214
|
+
? `port ${port} is already in use. Stop the other server or pick another --port.`
|
|
215
|
+
: `could not listen on port ${port}: ${error.message}`);
|
|
216
|
+
}
|
|
217
|
+
startRemoteWatchdog();
|
|
218
|
+
startWorkerLoop();
|
|
219
|
+
startRemakeScheduler();
|
|
196
220
|
console.log(`[serve] listening on http://localhost:${port}`);
|
|
197
221
|
console.log(`[serve] dashboard at http://localhost:${port}/`);
|
|
222
|
+
const steps = setupChecklist(webhookUrl);
|
|
223
|
+
if (steps.some((step) => !step.done)) {
|
|
224
|
+
console.log(`[serve] finish setup at http://localhost:${port}/setup (${steps.filter((s) => s.done).length}/${steps.length} done)`);
|
|
225
|
+
}
|
|
198
226
|
console.log(`[serve] webhook URL: ${webhookUrl}`);
|
|
199
227
|
let shuttingDown = false;
|
|
200
228
|
const shutdown = async (signal) => {
|
|
@@ -8,12 +8,23 @@ import { die } from "../error.js";
|
|
|
8
8
|
import { parsePolicy } from "../../services/review_policy.js";
|
|
9
9
|
import { isCodegraphVersion } from "../../tools/codegraph.js";
|
|
10
10
|
import { AI_PROVIDERS, rejectRetiredProvider } from "../../ai/provider.js";
|
|
11
|
+
import { MAX_CONCURRENCY, MIN_CONCURRENCY, } from "../../services/concurrency.js";
|
|
11
12
|
import { renderCommandHelp, renderGlobalHelp } from "./registry.js";
|
|
12
13
|
function text(args, name) {
|
|
13
14
|
return args
|
|
14
15
|
.find((arg) => arg.startsWith(`--${name}=`))
|
|
15
16
|
?.slice(name.length + 3);
|
|
16
17
|
}
|
|
18
|
+
function concurrencyValue(raw, flag) {
|
|
19
|
+
const number = Number(raw);
|
|
20
|
+
if (raw.trim() === "" ||
|
|
21
|
+
!Number.isInteger(number) ||
|
|
22
|
+
number < MIN_CONCURRENCY ||
|
|
23
|
+
number > MAX_CONCURRENCY) {
|
|
24
|
+
die(`${flag} must be an integer between ${MIN_CONCURRENCY} and ${MAX_CONCURRENCY}`);
|
|
25
|
+
}
|
|
26
|
+
return number;
|
|
27
|
+
}
|
|
17
28
|
const secretFields = new Set([
|
|
18
29
|
"token",
|
|
19
30
|
"githubPat",
|
|
@@ -63,6 +74,8 @@ export async function runSet(args) {
|
|
|
63
74
|
"review-policy-file",
|
|
64
75
|
"review-blocking",
|
|
65
76
|
"codegraph-version",
|
|
77
|
+
"gh-concurrent",
|
|
78
|
+
"ai-concurrent",
|
|
66
79
|
"repo",
|
|
67
80
|
"review-system-prompt",
|
|
68
81
|
"review-system-prompt-max-chars",
|
|
@@ -267,6 +280,27 @@ export async function runSet(args) {
|
|
|
267
280
|
}
|
|
268
281
|
patch.codegraphVersion = normalized;
|
|
269
282
|
}
|
|
283
|
+
const ghConcurrent = text(args, "gh-concurrent");
|
|
284
|
+
const aiConcurrent = text(args, "ai-concurrent");
|
|
285
|
+
const unsetGh = unset.has("gh-concurrent") || unset.has("ghConcurrent");
|
|
286
|
+
const unsetAi = unset.has("ai-concurrent") || unset.has("aiConcurrent");
|
|
287
|
+
if (ghConcurrent !== undefined ||
|
|
288
|
+
aiConcurrent !== undefined ||
|
|
289
|
+
unsetGh ||
|
|
290
|
+
unsetAi) {
|
|
291
|
+
const defaults = { ...(readConfig().defaults ?? {}) };
|
|
292
|
+
if (unsetGh)
|
|
293
|
+
delete defaults.ghConcurrent;
|
|
294
|
+
if (unsetAi)
|
|
295
|
+
delete defaults.aiConcurrent;
|
|
296
|
+
if (ghConcurrent !== undefined) {
|
|
297
|
+
defaults.ghConcurrent = concurrencyValue(ghConcurrent, "--gh-concurrent");
|
|
298
|
+
}
|
|
299
|
+
if (aiConcurrent !== undefined) {
|
|
300
|
+
defaults.aiConcurrent = concurrencyValue(aiConcurrent, "--ai-concurrent");
|
|
301
|
+
}
|
|
302
|
+
patch.defaults = defaults;
|
|
303
|
+
}
|
|
270
304
|
const password = text(args, "password");
|
|
271
305
|
if (password) {
|
|
272
306
|
const problem = passwordProblem(password);
|
|
@@ -330,6 +364,8 @@ const REPO_SCOPED_FLAGS = new Set([
|
|
|
330
364
|
"repo",
|
|
331
365
|
"review-system-prompt",
|
|
332
366
|
"review-system-prompt-max-chars",
|
|
367
|
+
"gh-concurrent",
|
|
368
|
+
"ai-concurrent",
|
|
333
369
|
"unset",
|
|
334
370
|
"no-verify",
|
|
335
371
|
]);
|
|
@@ -339,6 +375,10 @@ const REPO_SCOPED_UNSET = new Set([
|
|
|
339
375
|
"reviewSystemPrompt",
|
|
340
376
|
"review-system-prompt-max-chars",
|
|
341
377
|
"reviewSystemPromptMaxChars",
|
|
378
|
+
"gh-concurrent",
|
|
379
|
+
"ghConcurrent",
|
|
380
|
+
"ai-concurrent",
|
|
381
|
+
"aiConcurrent",
|
|
342
382
|
]);
|
|
343
383
|
/** `set --repo=owner/repo [--review-system-prompt=... | --review-system-prompt-max-chars=N | --unset=name]`
|
|
344
384
|
* writes the repository-scoped settings to `repos[owner/repo]` in config.json
|
|
@@ -373,6 +413,20 @@ async function runSetRepo(repo, args) {
|
|
|
373
413
|
unset.has("reviewSystemPromptMaxChars")) {
|
|
374
414
|
patch.reviewSystemPromptMaxChars = undefined;
|
|
375
415
|
}
|
|
416
|
+
if (unset.has("gh-concurrent") || unset.has("ghConcurrent")) {
|
|
417
|
+
patch.ghConcurrent = undefined;
|
|
418
|
+
}
|
|
419
|
+
if (unset.has("ai-concurrent") || unset.has("aiConcurrent")) {
|
|
420
|
+
patch.aiConcurrent = undefined;
|
|
421
|
+
}
|
|
422
|
+
const ghRaw = text(args, "gh-concurrent");
|
|
423
|
+
if (ghRaw !== undefined) {
|
|
424
|
+
patch.ghConcurrent = concurrencyValue(ghRaw, "--gh-concurrent");
|
|
425
|
+
}
|
|
426
|
+
const aiRaw = text(args, "ai-concurrent");
|
|
427
|
+
if (aiRaw !== undefined) {
|
|
428
|
+
patch.aiConcurrent = concurrencyValue(aiRaw, "--ai-concurrent");
|
|
429
|
+
}
|
|
376
430
|
const maxRaw = text(args, "review-system-prompt-max-chars");
|
|
377
431
|
if (maxRaw !== undefined) {
|
|
378
432
|
// Blank clears it, the same as an empty value on the dashboard form.
|
package/dist/src/cli/main.js
CHANGED
|
@@ -4,6 +4,7 @@ import { parseArgs } from "./args.js";
|
|
|
4
4
|
import { runServe } from "./commands/serve.js";
|
|
5
5
|
import { runRollback } from "./commands/rollback.js";
|
|
6
6
|
import { runSet } from "./commands/set.js";
|
|
7
|
+
import { runOAuth } from "./commands/oauth.js";
|
|
7
8
|
import { runConfig } from "./commands/config.js";
|
|
8
9
|
import { runView } from "./commands/view.js";
|
|
9
10
|
import { runClear } from "./commands/clear.js";
|
|
@@ -62,6 +63,10 @@ export async function run(args) {
|
|
|
62
63
|
await runSet(args.slice(1));
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
66
|
+
if (args[0] === "oauth") {
|
|
67
|
+
await runOAuth(args.slice(1));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
65
70
|
if (args[0] === "config") {
|
|
66
71
|
await runConfig(args.slice(1));
|
|
67
72
|
return;
|
|
@@ -109,6 +109,11 @@ export async function loadReviewSystemPromptFlags(cli, limit) {
|
|
|
109
109
|
export async function parseReviewArgs(args) {
|
|
110
110
|
const positional = args.filter((a) => !a.startsWith("--"));
|
|
111
111
|
const flags = reviewFlags(args);
|
|
112
|
+
// Remote review runs on the server's provider, so the experimental local
|
|
113
|
+
// provider has nothing to attach to.
|
|
114
|
+
if (flags.remote && args.includes("--experimental-siwc")) {
|
|
115
|
+
die("--experimental-siwc cannot be used with --remote");
|
|
116
|
+
}
|
|
112
117
|
// `--remote-host` / `--remote-token` only mean something together with
|
|
113
118
|
// `--remote`; silently dropping them is exactly the kind of surprise to avoid.
|
|
114
119
|
if ((flags.remoteHost || flags.remoteToken) && !flags.remote) {
|
package/dist/src/config.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type RepoConfig = {
|
|
|
12
12
|
maxPrMonths?: number;
|
|
13
13
|
maxPullRequestChangeLines?: number;
|
|
14
14
|
maxComments?: number;
|
|
15
|
+
/** Overrides the server default for this repository. 1..16. */
|
|
16
|
+
ghConcurrent?: number;
|
|
17
|
+
/** Overrides the server default for this repository. 1..16. */
|
|
18
|
+
aiConcurrent?: number;
|
|
15
19
|
includeCodebase?: boolean;
|
|
16
20
|
includePullRequests?: boolean;
|
|
17
21
|
includePullRequestChanges?: boolean;
|
|
@@ -21,6 +25,12 @@ export type RepoConfig = {
|
|
|
21
25
|
prState?: ("open" | "closed" | "merged")[];
|
|
22
26
|
/** Five field cron in UTC, checked by `serve` to queue a remake. */
|
|
23
27
|
remakeCron?: string;
|
|
28
|
+
/** A rejected custom schedule kept only so the settings form can show what
|
|
29
|
+
* was typed. Never read by the scheduler. */
|
|
30
|
+
remakeCronDraft?: string;
|
|
31
|
+
/** How a review decides a blocking finding for this repository. Unset
|
|
32
|
+
* follows the server default. */
|
|
33
|
+
reviewBlocking?: "model" | "severity";
|
|
24
34
|
/** A repository's own review instructions, appended to the built-in
|
|
25
35
|
* reviewer prompt as a `CUSTOM REVIEW INSTRUCTIONS` section. Unset or blank
|
|
26
36
|
* means none. */
|
|
@@ -65,6 +75,10 @@ export type UserConfig = {
|
|
|
65
75
|
maxCommits?: number;
|
|
66
76
|
maxPrMonths?: number;
|
|
67
77
|
maxPullRequestChangeLines?: number;
|
|
78
|
+
/** Server default for GitHub calls. 1..16. */
|
|
79
|
+
ghConcurrent?: number;
|
|
80
|
+
/** Server default for AI calls. 1..16. */
|
|
81
|
+
aiConcurrent?: number;
|
|
68
82
|
};
|
|
69
83
|
/** Cap on jobs running at once across all types. Unset means no limit. */
|
|
70
84
|
maxConcurrentJobs?: number;
|