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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
This project bundles the following third-party assets. Their licenses are
|
|
2
|
+
reproduced below and apply to those assets only, not to the rest of
|
|
3
|
+
co-maintainer, which is distributed under the MIT License (see LICENSE).
|
|
4
|
+
|
|
5
|
+
1. Outfit (font files under src/server/pages/fonts/)
|
|
6
|
+
2. Lucide (icon SVGs under src/server/pages/icons/)
|
|
7
|
+
3. Feather-derived icons (a subset of the Lucide icons listed below)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
================================================================================
|
|
11
|
+
1. Outfit
|
|
12
|
+
================================================================================
|
|
13
|
+
|
|
14
|
+
Copyright 2021 The Outfit Project Authors (https://github.com/Outfitio/Outfit-Fonts)
|
|
15
|
+
|
|
16
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
17
|
+
This license is copied below, and is also available with a FAQ at:
|
|
18
|
+
https://scripts.sil.org/OFL
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
-----------------------------------------------------------
|
|
22
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
23
|
+
-----------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
PREAMBLE
|
|
26
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
27
|
+
development of collaborative font projects, to support the font creation
|
|
28
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
29
|
+
open framework in which fonts may be shared and improved in partnership
|
|
30
|
+
with others.
|
|
31
|
+
|
|
32
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
33
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
34
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
35
|
+
redistributed and/or sold with any software provided that any reserved
|
|
36
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
37
|
+
however, cannot be released under any other type of license. The
|
|
38
|
+
requirement for fonts to remain under this license does not apply
|
|
39
|
+
to any document created using the fonts or their derivatives.
|
|
40
|
+
|
|
41
|
+
DEFINITIONS
|
|
42
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
43
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
44
|
+
include source files, build scripts and documentation.
|
|
45
|
+
|
|
46
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
47
|
+
copyright statement(s).
|
|
48
|
+
|
|
49
|
+
"Original Version" refers to the collection of Font Software components as
|
|
50
|
+
distributed by the Copyright Holder(s).
|
|
51
|
+
|
|
52
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
53
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
54
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
55
|
+
new environment.
|
|
56
|
+
|
|
57
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
58
|
+
writer or other person who contributed to the Font Software.
|
|
59
|
+
|
|
60
|
+
PERMISSION & CONDITIONS
|
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
62
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
63
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
64
|
+
Software, subject to the following conditions:
|
|
65
|
+
|
|
66
|
+
1) Neither the Font Software nor any of its individual components,
|
|
67
|
+
in Original or Modified Versions, may be sold by itself.
|
|
68
|
+
|
|
69
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
70
|
+
redistributed and/or sold with any software, provided that each copy
|
|
71
|
+
contains the above copyright notice and this license. These can be
|
|
72
|
+
included either as stand-alone text files, human-readable headers or
|
|
73
|
+
in the appropriate machine-readable metadata fields within text or
|
|
74
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
75
|
+
|
|
76
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
77
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
78
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
79
|
+
presented to the users.
|
|
80
|
+
|
|
81
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
82
|
+
Software shall not be used to promote, endorse or advertise any
|
|
83
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
84
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
85
|
+
permission.
|
|
86
|
+
|
|
87
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
88
|
+
must be distributed entirely under this license, and must not be
|
|
89
|
+
distributed under any other license. The requirement for fonts to
|
|
90
|
+
remain under this license does not apply to any document created
|
|
91
|
+
using the Font Software.
|
|
92
|
+
|
|
93
|
+
TERMINATION
|
|
94
|
+
This license becomes null and void if any of the above conditions are
|
|
95
|
+
not met.
|
|
96
|
+
|
|
97
|
+
DISCLAIMER
|
|
98
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
99
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
100
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
101
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
102
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
103
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
104
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
105
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
106
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
================================================================================
|
|
110
|
+
2. Lucide
|
|
111
|
+
================================================================================
|
|
112
|
+
|
|
113
|
+
ISC License
|
|
114
|
+
|
|
115
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
116
|
+
|
|
117
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
118
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
119
|
+
copyright notice and this permission notice appear in all copies.
|
|
120
|
+
|
|
121
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
122
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
123
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
124
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
125
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
126
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
127
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
================================================================================
|
|
131
|
+
3. Feather-derived icons (MIT)
|
|
132
|
+
================================================================================
|
|
133
|
+
|
|
134
|
+
The following icons used by this project are derived from the Feather
|
|
135
|
+
project and are licensed under the MIT License:
|
|
136
|
+
|
|
137
|
+
check, chevron-right, circle, copy, download, external-link, github,
|
|
138
|
+
info, list, loader, lock, log-out, menu, moon, plus, search, server,
|
|
139
|
+
square, terminal, users
|
|
140
|
+
|
|
141
|
+
The MIT License (MIT)
|
|
142
|
+
|
|
143
|
+
Copyright (c) 2013-present Cole Bemis
|
|
144
|
+
|
|
145
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
146
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
147
|
+
in the Software without restriction, including without limitation the rights
|
|
148
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
149
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
150
|
+
furnished to do so, subject to the following conditions:
|
|
151
|
+
|
|
152
|
+
The above copyright notice and this permission notice shall be included in all
|
|
153
|
+
copies or substantial portions of the Software.
|
|
154
|
+
|
|
155
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
156
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
157
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
158
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
159
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
160
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
161
|
+
SOFTWARE.
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "co-maintainer",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "An imitator of yours, A PR review tool like co-maintainer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist/",
|
|
26
26
|
"LICENSE",
|
|
27
|
-
"README.md"
|
|
27
|
+
"README.md",
|
|
28
|
+
"THIRD_PARTY_NOTICES"
|
|
28
29
|
],
|
|
29
30
|
"type": "module",
|
|
30
31
|
"exports": {
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"bench-core-v3": "node benchmark/core_v3/run.ts",
|
|
53
54
|
"swe-prbench-prepare": "node benchmark/swe-prbench/prepare_dataset.ts",
|
|
54
55
|
"e2e": "node scripts/e2e.ts",
|
|
56
|
+
"e2e:fake": "node scripts/e2e_fake.ts",
|
|
55
57
|
"review-local-e2e": "node scripts/review_local_e2e.ts",
|
|
56
58
|
"docs:build": "node scripts/build_docs.ts",
|
|
57
59
|
"pack:smoke": "node scripts/pack_smoke.ts",
|
package/dist/src/ai/batch.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cacheGet, cacheSet } from "../store/cache_db.js";
|
|
2
2
|
import { isNotFound, readTextFile } from "../util/runtime.js";
|
|
3
3
|
import { formatError } from "../cli/error.js";
|
|
4
|
+
import { recordRateLimitWait } from "../services/rate_limit.js";
|
|
4
5
|
/** A provider call and an unusable response are both retried this many times
|
|
5
6
|
* before the batch gives up and the run fails. */
|
|
6
7
|
export const MAX_ATTEMPTS = 3;
|
|
@@ -128,6 +129,12 @@ export class AiBatch {
|
|
|
128
129
|
if (attempt < limit) {
|
|
129
130
|
const wait = retryDelayMs(reason, attempt);
|
|
130
131
|
if (wait > 0) {
|
|
132
|
+
recordRateLimitWait({
|
|
133
|
+
service: "openrouter",
|
|
134
|
+
stage: item.request.job,
|
|
135
|
+
reason,
|
|
136
|
+
seconds: wait / 1000,
|
|
137
|
+
});
|
|
131
138
|
console.log(`[ai] waiting ${Math.round(wait / 1000)}s before retry (provider is rate limiting)`);
|
|
132
139
|
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
133
140
|
}
|
package/dist/src/cli/args.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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";
|
|
@@ -71,7 +72,9 @@ export async function parseArgs(args) {
|
|
|
71
72
|
// Remembered from a prior `init`/`remake` on this exact repo — never a
|
|
72
73
|
// secret, so it can safely fill in everything except the API token.
|
|
73
74
|
const repoConfig = config.repos?.[repoName] ?? {};
|
|
74
|
-
const reviewBlocking = reviewBlockingFrom(env("CO_MAINTAINER_REVIEW_BLOCKING") ??
|
|
75
|
+
const reviewBlocking = reviewBlockingFrom(env("CO_MAINTAINER_REVIEW_BLOCKING") ??
|
|
76
|
+
repoConfig.reviewBlocking ??
|
|
77
|
+
config.reviewBlocking);
|
|
75
78
|
let prNumber;
|
|
76
79
|
if (command === "review") {
|
|
77
80
|
const rawNumber = rest[0];
|
|
@@ -104,6 +107,20 @@ export async function parseArgs(args) {
|
|
|
104
107
|
? numberOption(arg.slice(name.length + 3), `--${name}`)
|
|
105
108
|
: undefined;
|
|
106
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
|
+
};
|
|
107
124
|
const text = (name) => rest.find((item) => item.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
108
125
|
const prStateOption = (args, saved) => {
|
|
109
126
|
const prefix = "--pr-state=";
|
|
@@ -266,6 +283,7 @@ export async function parseArgs(args) {
|
|
|
266
283
|
(!lowModel || !highModel || !aiToken)) {
|
|
267
284
|
die("--token, --low-model, and --high-model are required when AI is enabled");
|
|
268
285
|
}
|
|
286
|
+
const resolvedConcurrency = resolveConcurrency(repoName, config);
|
|
269
287
|
return {
|
|
270
288
|
command: command === "sync" ? "remake" : command,
|
|
271
289
|
repo: repoName,
|
|
@@ -277,8 +295,8 @@ export async function parseArgs(args) {
|
|
|
277
295
|
useCodegraph: command === "review" ? !rest.includes("--disable-codegraph") : false,
|
|
278
296
|
envPath,
|
|
279
297
|
improveMatrix: value("improve-matrix") ?? 1,
|
|
280
|
-
ghConcurrent:
|
|
281
|
-
aiConcurrent:
|
|
298
|
+
ghConcurrent: concurrencyValue("gh-concurrent", resolvedConcurrency.gh),
|
|
299
|
+
aiConcurrent: concurrencyValue("ai-concurrent", resolvedConcurrency.ai),
|
|
282
300
|
auth,
|
|
283
301
|
githubPat,
|
|
284
302
|
ai,
|
|
@@ -224,13 +224,13 @@ export const COMMANDS = [
|
|
|
224
224
|
name: "gh-concurrent",
|
|
225
225
|
value: "N",
|
|
226
226
|
default: "1",
|
|
227
|
-
description: "Concurrent
|
|
227
|
+
description: "Concurrent GitHub calls for this run only. It does not change the saved default.",
|
|
228
228
|
},
|
|
229
229
|
{
|
|
230
230
|
name: "ai-concurrent",
|
|
231
231
|
value: "N",
|
|
232
232
|
default: "3",
|
|
233
|
-
description: "Concurrent AI calls.",
|
|
233
|
+
description: "Concurrent AI calls for this run only. It does not change the saved default.",
|
|
234
234
|
},
|
|
235
235
|
{
|
|
236
236
|
name: "improve-matrix",
|
|
@@ -305,6 +305,23 @@ export const COMMANDS = [
|
|
|
305
305
|
EXPERIMENTAL_FLAGS,
|
|
306
306
|
GITHUB_FLAGS,
|
|
307
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
|
+
},
|
|
308
325
|
],
|
|
309
326
|
examples: ["co-maintainer sync owner/repo --include-codebase"],
|
|
310
327
|
},
|
|
@@ -638,6 +655,16 @@ export const COMMANDS = [
|
|
|
638
655
|
value: "owner/repo",
|
|
639
656
|
description: "Write the repository-scoped settings below to this repository instead of the global config.",
|
|
640
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
|
+
},
|
|
641
668
|
{
|
|
642
669
|
name: "review-system-prompt",
|
|
643
670
|
value: "TEXT",
|
|
@@ -854,7 +881,15 @@ function renderFlags(groups, lines) {
|
|
|
854
881
|
for (const flag of group.flags) {
|
|
855
882
|
const head = ` --${flag.name}${flag.value ? `=${flag.value}` : ""}`;
|
|
856
883
|
const meta = flag.default !== undefined ? ` (default: ${flag.default})` : "";
|
|
857
|
-
|
|
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
|
+
}
|
|
858
893
|
}
|
|
859
894
|
}
|
|
860
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/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;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { log } from "../util/log.js";
|
|
5
5
|
import { networkFailure } from "../cli/error.js";
|
|
6
6
|
import { missingHint, refusalHint } from "./permissions.js";
|
|
7
|
+
import { recordRateLimitWait } from "../services/rate_limit.js";
|
|
7
8
|
export class GitHubHttpError extends Error {
|
|
8
9
|
status;
|
|
9
10
|
constructor(status, body, hint) {
|
|
@@ -109,6 +110,12 @@ export async function githubFetch(url, init) {
|
|
|
109
110
|
const retryAfterHeader = response.headers.get("retry-after");
|
|
110
111
|
const retryAfter = retryAfterHeader === null ? NaN : Number(retryAfterHeader);
|
|
111
112
|
if (Number.isFinite(retryAfter) && retryAfter >= 0 && attempt < 3) {
|
|
113
|
+
recordRateLimitWait({
|
|
114
|
+
service: "github",
|
|
115
|
+
stage: "GitHub request",
|
|
116
|
+
reason: `secondary rate limit (HTTP ${response.status})`,
|
|
117
|
+
seconds: retryAfter,
|
|
118
|
+
});
|
|
112
119
|
console.log(`[github] secondary rate limit, waiting ${retryAfter}s (attempt ${attempt} of 3)`);
|
|
113
120
|
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
|
|
114
121
|
continue;
|
|
@@ -129,6 +136,12 @@ export async function githubFetch(url, init) {
|
|
|
129
136
|
spun = true;
|
|
130
137
|
continue;
|
|
131
138
|
}
|
|
139
|
+
recordRateLimitWait({
|
|
140
|
+
service: "github",
|
|
141
|
+
stage: "GitHub request",
|
|
142
|
+
reason: `primary rate limit (HTTP ${response?.status ?? 403})`,
|
|
143
|
+
seconds: delay / 1000,
|
|
144
|
+
});
|
|
132
145
|
spun = false;
|
|
133
146
|
await waitForRateLimit(exhausted.resetAt, started);
|
|
134
147
|
}
|
|
@@ -104,6 +104,14 @@ export const ENDPOINTS = [
|
|
|
104
104
|
identities: APP_ONLY,
|
|
105
105
|
feature: "Acknowledge a review request on the pull request",
|
|
106
106
|
},
|
|
107
|
+
{
|
|
108
|
+
method: "PATCH",
|
|
109
|
+
pattern: "repos/{repo}/issues/comments/{id}",
|
|
110
|
+
permission: "issues",
|
|
111
|
+
level: "write",
|
|
112
|
+
identities: APP_ONLY,
|
|
113
|
+
feature: "Edit the failure note left on a pull request",
|
|
114
|
+
},
|
|
107
115
|
{
|
|
108
116
|
method: "POST",
|
|
109
117
|
pattern: "repos/{repo}/issues/comments/{id}/reactions",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* `Authorization` header, and every other `/api/*` route needs one. */
|
|
4
4
|
import { errorResponse } from "../errors.js";
|
|
5
5
|
import { cancel, getLogsSince, subscribeToLogs } from "../../services/jobs.js";
|
|
6
|
+
import { listRateLimitWaits, summarizeRateLimitWaits, } from "../../services/rate_limit.js";
|
|
6
7
|
import { getJob, listJobs } from "../../store/jobs.js";
|
|
7
8
|
const ROUTE = /^\/api\/jobs(?:\/([^/]+)(?:\/(logs\/stream|cancel))?)?$/;
|
|
8
9
|
export function handleJobsRoute(request, url) {
|
|
@@ -23,7 +24,13 @@ export function handleJobsRoute(request, url) {
|
|
|
23
24
|
const job = getJob(jobId);
|
|
24
25
|
if (!job)
|
|
25
26
|
return errorResponse(404, "not_found", "no such job");
|
|
26
|
-
|
|
27
|
+
const rateLimitWaits = listRateLimitWaits(jobId);
|
|
28
|
+
return Response.json({
|
|
29
|
+
...job,
|
|
30
|
+
logs: getLogsSince(jobId).slice(-50),
|
|
31
|
+
rateLimitWaits,
|
|
32
|
+
rateLimitWaitSummary: summarizeRateLimitWaits(rateLimitWaits),
|
|
33
|
+
});
|
|
27
34
|
}
|
|
28
35
|
if (jobId && sub === "cancel" && request.method === "POST") {
|
|
29
36
|
if (!getJob(jobId))
|