co-maintainer 0.6.12 → 0.7.0-beta.1
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/README.md +1 -1
- package/dist/package.json +1 -1
- package/dist/src/ai/anthropic.js +2 -0
- package/dist/src/ai/batch.d.ts +3 -1
- package/dist/src/ai/batch.js +23 -2
- package/dist/src/ai/mermaid_loop.js +1 -1
- package/dist/src/ai/oauth/sign-in-with-chatgpt.js +8 -10
- package/dist/src/ai/openai.js +2 -0
- package/dist/src/ai/openrouter.js +2 -0
- package/dist/src/cli/args.js +47 -0
- package/dist/src/cli/command_json.d.ts +20 -1
- package/dist/src/cli/command_json.js +4 -0
- package/dist/src/cli/commands/config.d.ts +1 -1
- package/dist/src/cli/commands/config.js +1 -0
- package/dist/src/cli/commands/registry.js +226 -1
- package/dist/src/cli/commands/review.js +50 -9
- package/dist/src/cli/commands/serve.js +5 -0
- package/dist/src/cli/commands/set.js +75 -17
- package/dist/src/cli/commands/view.js +46 -5
- package/dist/src/cli/commands/view_sources.d.ts +11 -0
- package/dist/src/cli/commands/view_sources.js +40 -0
- package/dist/src/cli/main.js +5 -0
- package/dist/src/cli/pr_carry.d.ts +25 -0
- package/dist/src/cli/pr_carry.js +128 -0
- package/dist/src/cli/prompt.js +26 -1
- package/dist/src/cli/review_args.d.ts +8 -0
- package/dist/src/cli/review_args.js +18 -0
- package/dist/src/cli/review_carry.d.ts +32 -0
- package/dist/src/cli/review_carry.js +60 -0
- package/dist/src/cli/review_github.d.ts +16 -2
- package/dist/src/cli/review_github.js +49 -12
- package/dist/src/cli/review_intent.d.ts +25 -0
- package/dist/src/cli/review_intent.js +87 -0
- package/dist/src/cli/review_result.d.ts +53 -2
- package/dist/src/cli/review_result.js +90 -23
- package/dist/src/config.d.ts +30 -0
- package/dist/src/config.js +20 -12
- package/dist/src/extensions/command.d.ts +1 -0
- package/dist/src/extensions/command.js +355 -0
- package/dist/src/extensions/contexts.d.ts +65 -0
- package/dist/src/extensions/contexts.js +134 -0
- package/dist/src/extensions/cost.d.ts +8 -0
- package/dist/src/extensions/cost.js +6 -0
- package/dist/src/extensions/local_tracking.d.ts +7 -0
- package/dist/src/extensions/local_tracking.js +29 -0
- package/dist/src/extensions/mock.d.ts +29 -0
- package/dist/src/extensions/mock.js +67 -0
- package/dist/src/extensions/process.d.ts +43 -0
- package/dist/src/extensions/process.js +244 -0
- package/dist/src/extensions/registry.d.ts +79 -0
- package/dist/src/extensions/registry.js +240 -0
- package/dist/src/extensions/render_actions.d.ts +6 -0
- package/dist/src/extensions/render_actions.js +50 -0
- package/dist/src/extensions/render_cli.d.ts +18 -0
- package/dist/src/extensions/render_cli.js +88 -0
- package/dist/src/extensions/render_json.d.ts +51 -0
- package/dist/src/extensions/render_json.js +144 -0
- package/dist/src/extensions/render_markdown.d.ts +22 -0
- package/dist/src/extensions/render_markdown.js +96 -0
- package/dist/src/extensions/render_review.d.ts +44 -0
- package/dist/src/extensions/render_review.js +167 -0
- package/dist/src/extensions/report.d.ts +57 -0
- package/dist/src/extensions/report.js +97 -0
- package/dist/src/extensions/review_result.d.ts +2 -0
- package/dist/src/extensions/review_result.js +14 -0
- package/dist/src/extensions/run_folder.d.ts +74 -0
- package/dist/src/extensions/run_folder.js +172 -0
- package/dist/src/extensions/runner.d.ts +66 -0
- package/dist/src/extensions/runner.js +251 -0
- package/dist/src/extensions/schema.d.ts +103 -0
- package/dist/src/extensions/schema.js +539 -0
- package/dist/src/extensions/session.d.ts +56 -0
- package/dist/src/extensions/session.js +173 -0
- package/dist/src/github/collect.d.ts +7 -2
- package/dist/src/github/collect.js +66 -6
- package/dist/src/github/gh.d.ts +7 -0
- package/dist/src/github/gh.js +24 -29
- package/dist/src/knowledge/guide.js +3 -2
- package/dist/src/knowledge/instruction_files.d.ts +45 -0
- package/dist/src/knowledge/instruction_files.js +91 -0
- package/dist/src/knowledge/instructions.d.ts +78 -0
- package/dist/src/knowledge/instructions.js +280 -0
- package/dist/src/knowledge/rule_changes.d.ts +39 -0
- package/dist/src/knowledge/rule_changes.js +90 -0
- package/dist/src/knowledge/rules.d.ts +44 -0
- package/dist/src/knowledge/rules.js +82 -0
- package/dist/src/knowledge/synthesis.d.ts +1 -0
- package/dist/src/knowledge/synthesis.js +12 -5
- package/dist/src/knowledge/types.d.ts +4 -0
- package/dist/src/local/carry_over_store.d.ts +10 -0
- package/dist/src/local/carry_over_store.js +17 -0
- package/dist/src/local/review_local.js +100 -62
- package/dist/src/local/review_lock.js +15 -4
- package/dist/src/pr/diff_plan.d.ts +110 -0
- package/dist/src/pr/diff_plan.js +429 -0
- package/dist/src/pr/diff_summary.d.ts +17 -1
- package/dist/src/pr/diff_summary.js +87 -13
- package/dist/src/pr/review_diff.d.ts +47 -0
- package/dist/src/pr/review_diff.js +112 -0
- package/dist/src/pr/reviewer.d.ts +44 -19
- package/dist/src/pr/reviewer.js +114 -142
- package/dist/src/remote/client.js +67 -8
- package/dist/src/remote/http.d.ts +12 -0
- package/dist/src/remote/http.js +31 -0
- package/dist/src/remote/push_client.js +14 -3
- package/dist/src/remote/server/guides.js +12 -1
- package/dist/src/remote/server/routes.js +4 -2
- package/dist/src/remote/server/sessions.js +4 -1
- package/dist/src/remote/validate.js +11 -0
- package/dist/src/review/carry_over.d.ts +6 -1
- package/dist/src/review/carry_over.js +10 -2
- package/dist/src/review/coverage.d.ts +57 -0
- package/dist/src/review/coverage.js +186 -0
- package/dist/src/review/diagram.d.ts +73 -0
- package/dist/src/review/diagram.js +309 -0
- package/dist/src/review/engine.d.ts +2 -6
- package/dist/src/review/engine.js +1 -1
- package/dist/src/review/guides.d.ts +6 -0
- package/dist/src/review/guides.js +8 -1
- package/dist/src/review/intent.d.ts +24 -0
- package/dist/src/review/intent.js +28 -0
- package/dist/src/review/not_initialized.d.ts +13 -0
- package/dist/src/review/not_initialized.js +18 -0
- package/dist/src/review/system_prompt.d.ts +6 -0
- package/dist/src/review/system_prompt.js +13 -0
- package/dist/src/review/visible_paths.d.ts +22 -0
- package/dist/src/review/visible_paths.js +41 -0
- package/dist/src/server/auth.js +8 -1
- package/dist/src/server/pages/extensions.d.ts +5 -0
- package/dist/src/server/pages/extensions.js +72 -0
- package/dist/src/server/pages/pr.js +3 -2
- package/dist/src/services/dashboard.d.ts +8 -0
- package/dist/src/services/dashboard.js +8 -0
- package/dist/src/services/push_review.js +14 -5
- package/dist/src/services/remote_review.js +81 -26
- package/dist/src/services/replies.js +15 -8
- package/dist/src/services/review.d.ts +9 -3
- package/dist/src/services/review.js +109 -28
- package/dist/src/services/rules_build.d.ts +46 -0
- package/dist/src/services/rules_build.js +155 -0
- package/dist/src/services/setup.d.ts +31 -0
- package/dist/src/services/setup.js +120 -25
- package/dist/src/services/watch_comments.js +2 -0
- package/dist/src/store/app_db.d.ts +3 -1
- package/dist/src/store/app_db.js +7 -2
- package/dist/src/store/cache_db.js +3 -0
- package/dist/src/store/extensions.d.ts +51 -0
- package/dist/src/store/extensions.js +132 -0
- package/dist/src/store/migrations.js +40 -0
- package/dist/src/types.d.ts +22 -1
- package/dist/src/util/atomic.d.ts +15 -1
- package/dist/src/util/atomic.js +59 -29
- package/dist/src/util/interrupt.d.ts +6 -0
- package/dist/src/util/interrupt.js +27 -0
- package/dist/src/util/runtime.d.ts +3 -1
- package/dist/src/util/runtime.js +2 -2
- package/dist/src/util/test_location_guard.d.ts +6 -0
- package/dist/src/util/test_location_guard.js +47 -0
- package/package.json +1 -1
|
@@ -33,6 +33,10 @@ const REVIEW_OUTPUT_FLAGS = {
|
|
|
33
33
|
value: "github",
|
|
34
34
|
description: "Print GitHub workflow annotations and write the job summary instead of prose. Cannot be used with --json.",
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
name: "include-extension-markdowns",
|
|
38
|
+
description: "With --json, keep each extension's markdown. It is empty otherwise.",
|
|
39
|
+
},
|
|
36
40
|
],
|
|
37
41
|
};
|
|
38
42
|
const AI_KEY_FLAGS = [
|
|
@@ -105,6 +109,124 @@ const GITHUB_FLAGS = {
|
|
|
105
109
|
},
|
|
106
110
|
],
|
|
107
111
|
};
|
|
112
|
+
/** `extension`: register external commands whose results join a review. */
|
|
113
|
+
const EXTENSION_COMMAND = {
|
|
114
|
+
name: "extension",
|
|
115
|
+
summary: "Register external commands whose results join every review.",
|
|
116
|
+
usage: [
|
|
117
|
+
"co-maintainer extension register --name=NAME --command=COMMAND [options]",
|
|
118
|
+
"co-maintainer extension update --name=NAME [options]",
|
|
119
|
+
"co-maintainer extension list [--json]",
|
|
120
|
+
"co-maintainer extension remove --name=NAME",
|
|
121
|
+
"co-maintainer extension disable --name=NAME",
|
|
122
|
+
"co-maintainer extension enable --name=NAME",
|
|
123
|
+
"co-maintainer extension debug-run --name=NAME [--command=COMMAND]",
|
|
124
|
+
],
|
|
125
|
+
groups: [
|
|
126
|
+
{
|
|
127
|
+
title: "Extension",
|
|
128
|
+
flags: [
|
|
129
|
+
{
|
|
130
|
+
name: "name",
|
|
131
|
+
value: "NAME",
|
|
132
|
+
description: "The extension's name. Required.",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "command",
|
|
136
|
+
value: "COMMAND",
|
|
137
|
+
description: "The shell command to run. {{details_path}}, {{review_result_path}} and {{diff_path}} are replaced with quoted paths. Required for register.",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "repos",
|
|
141
|
+
value: "PATTERNS",
|
|
142
|
+
default: "*",
|
|
143
|
+
description: "Where it runs: owner/repo, a/b,a/c, a/*, */a or *.",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "review-types",
|
|
147
|
+
value: "local,pr,remote",
|
|
148
|
+
default: "all",
|
|
149
|
+
description: "Only run in these review types. The extension can also check the type itself and return skipped.",
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title: "Order",
|
|
155
|
+
flags: [
|
|
156
|
+
{
|
|
157
|
+
name: "run-after",
|
|
158
|
+
value: "NAME|review",
|
|
159
|
+
description: "Start when this extension, or the AI review, has finished. A name nobody registered asks first.",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "parallelism",
|
|
163
|
+
value: "true|false",
|
|
164
|
+
default: "true",
|
|
165
|
+
description: "false with no --run-after means it runs after the review.",
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "priority",
|
|
169
|
+
value: "0-3",
|
|
170
|
+
default: "0",
|
|
171
|
+
description: "Start order among extensions ready at the same time. 3 runs first, ties keep registration order.",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "fail-fast",
|
|
175
|
+
description: "On failure, the extensions waiting on this one through --run-after do not run.",
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
title: "Retries and limits",
|
|
181
|
+
flags: [
|
|
182
|
+
{
|
|
183
|
+
name: "retry-on-fail-times",
|
|
184
|
+
value: "N",
|
|
185
|
+
default: "0",
|
|
186
|
+
description: "Run again when the response does not match the schema.",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "max-requested-retries",
|
|
190
|
+
value: "N",
|
|
191
|
+
default: "3",
|
|
192
|
+
description: "How many status retry responses are honoured.",
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "timeout",
|
|
196
|
+
value: "DURATION",
|
|
197
|
+
default: "10m",
|
|
198
|
+
description: "Stop a run after this long, such as 30s, 10m or 1h. The result is Failed.",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "rerun-on-restart",
|
|
202
|
+
value: "true|false",
|
|
203
|
+
default: "true",
|
|
204
|
+
description: "Run again when co-maintainer restarted mid-run. Overrides the extension-rerun-on-restart config key.",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "yes",
|
|
208
|
+
description: "Save a --run-after that names an unregistered extension without asking.",
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
title: "Output",
|
|
214
|
+
flags: [
|
|
215
|
+
{
|
|
216
|
+
name: "json",
|
|
217
|
+
description: "With list, print the registrations as JSON.",
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
examples: [
|
|
223
|
+
"co-maintainer extension register --name=qa-vision --command='HOME=/home/me /usr/bin/node /opt/qa-vision.mjs {{details_path}} --json'",
|
|
224
|
+
"co-maintainer extension register --name=lint --command='/opt/lint.sh {{diff_path}}' --review-types=pr --fail-fast",
|
|
225
|
+
"co-maintainer extension update --name=lint --run-after=review --priority=3",
|
|
226
|
+
"co-maintainer extension debug-run --name=qa-vision",
|
|
227
|
+
"co-maintainer extension list",
|
|
228
|
+
],
|
|
229
|
+
};
|
|
108
230
|
export const COMMANDS = [
|
|
109
231
|
{
|
|
110
232
|
name: "probe",
|
|
@@ -174,6 +296,12 @@ export const COMMANDS = [
|
|
|
174
296
|
name: "include-how-repo-works",
|
|
175
297
|
description: "Read the docs and layout.",
|
|
176
298
|
},
|
|
299
|
+
{
|
|
300
|
+
name: "agent-instructions",
|
|
301
|
+
value: "REGEX",
|
|
302
|
+
default: "(^|/)AGENTS\\.md$",
|
|
303
|
+
description: "Paths on the default branch to read as agent instruction files for INSTRUCTIONS.md. Needs --include-codebase. A blank value turns it off. Saved for later syncs.",
|
|
304
|
+
},
|
|
177
305
|
],
|
|
178
306
|
},
|
|
179
307
|
{
|
|
@@ -185,6 +313,12 @@ export const COMMANDS = [
|
|
|
185
313
|
default: "all",
|
|
186
314
|
description: "Cap how many commits are read.",
|
|
187
315
|
},
|
|
316
|
+
{
|
|
317
|
+
name: "agent-instructions-max-chars",
|
|
318
|
+
value: "N",
|
|
319
|
+
default: "6000",
|
|
320
|
+
description: "Cap on INSTRUCTIONS.md in characters. 0 or below means no limit. Saved for later syncs.",
|
|
321
|
+
},
|
|
188
322
|
{
|
|
189
323
|
name: "max-pr-months",
|
|
190
324
|
value: "N",
|
|
@@ -249,6 +383,7 @@ export const COMMANDS = [
|
|
|
249
383
|
examples: [
|
|
250
384
|
"co-maintainer init owner/repo --include-codebase --include-pull-requests",
|
|
251
385
|
"co-maintainer init owner/repo --include-codebase --ai=openrouter --token=...",
|
|
386
|
+
"co-maintainer init owner/repo --max-pr-months=12 --agent-instructions='(^|/)(AGENTS|CLAUDE)\\.md$'",
|
|
252
387
|
],
|
|
253
388
|
},
|
|
254
389
|
{
|
|
@@ -279,6 +414,11 @@ export const COMMANDS = [
|
|
|
279
414
|
name: "include-how-repo-works",
|
|
280
415
|
description: "Read the docs and layout.",
|
|
281
416
|
},
|
|
417
|
+
{
|
|
418
|
+
name: "agent-instructions",
|
|
419
|
+
value: "REGEX",
|
|
420
|
+
description: "Paths on the default branch to read as agent instruction files for INSTRUCTIONS.md. Needs --include-codebase. A blank value turns it off. Left out, the last run's value is kept.",
|
|
421
|
+
},
|
|
282
422
|
],
|
|
283
423
|
},
|
|
284
424
|
{
|
|
@@ -289,6 +429,11 @@ export const COMMANDS = [
|
|
|
289
429
|
value: "N",
|
|
290
430
|
description: "Cap how many commits are read.",
|
|
291
431
|
},
|
|
432
|
+
{
|
|
433
|
+
name: "agent-instructions-max-chars",
|
|
434
|
+
value: "N",
|
|
435
|
+
description: "Cap on INSTRUCTIONS.md in characters. 0 or below means no limit. Left out, the last run's value is kept.",
|
|
436
|
+
},
|
|
292
437
|
{
|
|
293
438
|
name: "max-pr-months",
|
|
294
439
|
value: "N",
|
|
@@ -328,7 +473,10 @@ export const COMMANDS = [
|
|
|
328
473
|
],
|
|
329
474
|
},
|
|
330
475
|
],
|
|
331
|
-
examples: [
|
|
476
|
+
examples: [
|
|
477
|
+
"co-maintainer sync owner/repo --include-codebase",
|
|
478
|
+
"co-maintainer sync owner/repo --agent-instructions-max-chars=8000",
|
|
479
|
+
],
|
|
332
480
|
},
|
|
333
481
|
{
|
|
334
482
|
name: "review",
|
|
@@ -431,6 +579,39 @@ export const COMMANDS = [
|
|
|
431
579
|
},
|
|
432
580
|
],
|
|
433
581
|
},
|
|
582
|
+
{
|
|
583
|
+
title: "Intent",
|
|
584
|
+
flags: [
|
|
585
|
+
{
|
|
586
|
+
name: "intent-file",
|
|
587
|
+
value: "PATH",
|
|
588
|
+
description: "Tell the review what the change is for, from a file or from standard input with -. It is context only, never a rule. Up to the repository's custom prompt cap. Not with --range.",
|
|
589
|
+
},
|
|
590
|
+
],
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
title: "Diagrams",
|
|
594
|
+
flags: [
|
|
595
|
+
{
|
|
596
|
+
name: "diagram-runtime",
|
|
597
|
+
value: "mermaid|plantuml|plantuml-server",
|
|
598
|
+
default: "mermaid",
|
|
599
|
+
description: "The diagram language the review uses. plantuml keeps the PlantUML source. plantuml-server turns it into an image link on a PlantUML server. Not with --remote.",
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
name: "plantuml-server",
|
|
603
|
+
value: "URL",
|
|
604
|
+
default: "https://www.plantuml.com",
|
|
605
|
+
description: "The PlantUML server for plantuml-server. An http or https URL. The diagram source travels in the image link.",
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: "plantuml-output-format",
|
|
609
|
+
value: "svg|png",
|
|
610
|
+
default: "svg",
|
|
611
|
+
description: "The image format for plantuml-server.",
|
|
612
|
+
},
|
|
613
|
+
],
|
|
614
|
+
},
|
|
434
615
|
AI_FLAGS,
|
|
435
616
|
EXPERIMENTAL_FLAGS,
|
|
436
617
|
GITHUB_FLAGS,
|
|
@@ -446,6 +627,8 @@ export const COMMANDS = [
|
|
|
446
627
|
"co-maintainer review --remote --range=abc1234..def5678 --output=github",
|
|
447
628
|
"co-maintainer review owner/repo 42 --system-prompt-file=extra.md",
|
|
448
629
|
"co-maintainer review --system-prompt-override-file=strict.md",
|
|
630
|
+
"co-maintainer review --intent-file=task.md",
|
|
631
|
+
"co-maintainer review owner/repo 42 --diagram-runtime=plantuml-server --plantuml-output-format=png",
|
|
449
632
|
],
|
|
450
633
|
},
|
|
451
634
|
{
|
|
@@ -483,6 +666,7 @@ export const COMMANDS = [
|
|
|
483
666
|
"co-maintainer view [owner/repo] [guide]",
|
|
484
667
|
"co-maintainer view [owner/repo] --list",
|
|
485
668
|
"co-maintainer view [owner/repo] --path",
|
|
669
|
+
"co-maintainer view [owner/repo] --sources [--json]",
|
|
486
670
|
],
|
|
487
671
|
groups: [
|
|
488
672
|
{
|
|
@@ -492,6 +676,14 @@ export const COMMANDS = [
|
|
|
492
676
|
name: "list",
|
|
493
677
|
description: "List the guide files with their size and build date.",
|
|
494
678
|
},
|
|
679
|
+
{
|
|
680
|
+
name: "sources",
|
|
681
|
+
description: "List every instruction rule by id, with the instruction file lines it came from.",
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
name: "json",
|
|
685
|
+
description: "With --sources, print RULES.json as it is.",
|
|
686
|
+
},
|
|
495
687
|
{
|
|
496
688
|
name: "path",
|
|
497
689
|
description: "Print the directory the guides live in.",
|
|
@@ -508,6 +700,7 @@ export const COMMANDS = [
|
|
|
508
700
|
"co-maintainer view owner/repo review-guide",
|
|
509
701
|
"co-maintainer view owner/repo --list",
|
|
510
702
|
"co-maintainer view owner/repo --remote",
|
|
703
|
+
"co-maintainer view owner/repo --sources",
|
|
511
704
|
],
|
|
512
705
|
},
|
|
513
706
|
{
|
|
@@ -691,6 +884,30 @@ export const COMMANDS = [
|
|
|
691
884
|
value: "N",
|
|
692
885
|
description: "Cap the repository's review instructions in characters. Needs --repo. 0 or -1 means no limit.",
|
|
693
886
|
},
|
|
887
|
+
{
|
|
888
|
+
name: "diagram-runtime",
|
|
889
|
+
value: "mermaid|plantuml|plantuml-server",
|
|
890
|
+
default: "mermaid",
|
|
891
|
+
description: "The diagram language for a repository's reviews, including App reviews. Needs --repo.",
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
name: "plantuml-server",
|
|
895
|
+
value: "URL",
|
|
896
|
+
default: "https://www.plantuml.com",
|
|
897
|
+
description: "The PlantUML server for plantuml-server. An http or https URL. Needs --repo.",
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
name: "plantuml-output-format",
|
|
901
|
+
value: "svg|png",
|
|
902
|
+
default: "svg",
|
|
903
|
+
description: "The image format for plantuml-server. Needs --repo.",
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
name: "review-read-diff-max-chars",
|
|
907
|
+
value: "N",
|
|
908
|
+
default: "20000",
|
|
909
|
+
description: "The most characters one read-full-diff answer returns in a review of this repository. Needs --repo. 0 or -1 means no limit.",
|
|
910
|
+
},
|
|
694
911
|
{
|
|
695
912
|
name: "review-blocking",
|
|
696
913
|
value: "model|severity",
|
|
@@ -707,6 +924,12 @@ export const COMMANDS = [
|
|
|
707
924
|
value: "TEXT",
|
|
708
925
|
description: "Replace the dashboard password.",
|
|
709
926
|
},
|
|
927
|
+
{
|
|
928
|
+
name: "extension-rerun-on-restart",
|
|
929
|
+
value: "true|false",
|
|
930
|
+
default: "true",
|
|
931
|
+
description: "Run an extension again when co-maintainer restarted while it ran. A registration's --rerun-on-restart wins.",
|
|
932
|
+
},
|
|
710
933
|
{
|
|
711
934
|
name: "disable-auth",
|
|
712
935
|
value: "password",
|
|
@@ -733,6 +956,7 @@ export const COMMANDS = [
|
|
|
733
956
|
"co-maintainer set --ai=openrouter --ai-key=... --low-model=... --high-model=...",
|
|
734
957
|
"co-maintainer set --remote-host=https://review.example.com --remote-token=...",
|
|
735
958
|
"co-maintainer set --repo=owner/repo --review-system-prompt='Focus on the parser.'",
|
|
959
|
+
"co-maintainer set --repo=owner/repo --diagram-runtime=plantuml-server",
|
|
736
960
|
"co-maintainer set --unset=token",
|
|
737
961
|
],
|
|
738
962
|
},
|
|
@@ -783,6 +1007,7 @@ export const COMMANDS = [
|
|
|
783
1007
|
],
|
|
784
1008
|
examples: ["co-maintainer serve --port=5000"],
|
|
785
1009
|
},
|
|
1010
|
+
EXTENSION_COMMAND,
|
|
786
1011
|
{
|
|
787
1012
|
name: "rollback",
|
|
788
1013
|
summary: "Go back to the version before the last upgrade, restoring its data.",
|
|
@@ -10,12 +10,18 @@ import { runLocalReview } from "../../local/review_local.js";
|
|
|
10
10
|
import { runRemoteReview } from "../../remote/client.js";
|
|
11
11
|
import { runRemotePushReview } from "../../remote/push_client.js";
|
|
12
12
|
import { reviewExitCode } from "../review_output.js";
|
|
13
|
-
import { buildPrReviewJson,
|
|
14
|
-
import {
|
|
13
|
+
import { buildPrReviewJson, reviewExitCodeFromResolved, } from "../review_result.js";
|
|
14
|
+
import { intentRecord } from "../review_intent.js";
|
|
15
|
+
import { startPrCarry } from "../pr_carry.js";
|
|
15
16
|
import { exitWith } from "../error.js";
|
|
16
17
|
import { printRunSummary, summaryFromMetrics } from "../../util/run_summary.js";
|
|
17
18
|
import { emitGithubOutput } from "../review_github.js";
|
|
18
19
|
import { formatHumanReview, humanFindingsFromResolved, } from "../review_result.js";
|
|
20
|
+
import { withExtensions } from "../../extensions/session.js";
|
|
21
|
+
import { cliPrContext } from "../../extensions/contexts.js";
|
|
22
|
+
import { reviewResultJson } from "../../extensions/review_result.js";
|
|
23
|
+
import { exitCodeWithExtensions } from "../../extensions/report.js";
|
|
24
|
+
import { runSummaryWithExtensions } from "../../extensions/render_json.js";
|
|
19
25
|
export async function runReviewFromCli(args) {
|
|
20
26
|
const parsed = await parseReviewArgs(args);
|
|
21
27
|
if (parsed.mode === "local") {
|
|
@@ -38,6 +44,8 @@ export async function runReview(options) {
|
|
|
38
44
|
disableCodegraph: false,
|
|
39
45
|
allowToolInstall: false,
|
|
40
46
|
remakeBeforeReview: false,
|
|
47
|
+
fresh: false,
|
|
48
|
+
includeExtensionMarkdowns: false,
|
|
41
49
|
});
|
|
42
50
|
}
|
|
43
51
|
async function runReviewPr(options, cli) {
|
|
@@ -52,10 +60,20 @@ async function runReviewPr(options, cli) {
|
|
|
52
60
|
}
|
|
53
61
|
log("review", `reading PR #${options.prNumber} in ${options.repo} via gh`);
|
|
54
62
|
log("review", modelSummary(options));
|
|
55
|
-
const
|
|
63
|
+
const client = new GhClient(options.debug);
|
|
64
|
+
const carry = await startPrCarry(client, options, cli.fresh, (message) => log("review", message));
|
|
65
|
+
const { review: result, extensions } = await withExtensions(cliPrContext({
|
|
66
|
+
client,
|
|
67
|
+
repo: options.repo,
|
|
68
|
+
prNumber: options.prNumber,
|
|
69
|
+
prefetched: carry.extras.prefetched,
|
|
70
|
+
}), () => timed("review GitHub collection and AI", options.logTime, () => reviewPullRequest(client, options, async (response) => {
|
|
56
71
|
addAiMetrics(aiMetrics, response);
|
|
57
72
|
await recordAiCost(options.repo, "review_pull_request", response);
|
|
58
|
-
}
|
|
73
|
+
}, undefined, undefined, undefined,
|
|
74
|
+
// The stored run leaves out what it saw, so the next run sends
|
|
75
|
+
// the files this one dropped.
|
|
76
|
+
{ ...carry.extras, catchesUp: true })), (review) => reviewResultJson(review.text, options.reviewBlocking));
|
|
59
77
|
const durationMs = Math.round(performance.now() - operationStarted);
|
|
60
78
|
const usage = {
|
|
61
79
|
tokensIn: aiMetrics.tokensIn,
|
|
@@ -66,25 +84,42 @@ async function runReviewPr(options, cli) {
|
|
|
66
84
|
// the old `useCodegraph ? "used" : "disabled"` that claimed "used" while
|
|
67
85
|
// stderr said codegraph was missing.
|
|
68
86
|
const codegraphState = result.codegraphState;
|
|
69
|
-
const resolved =
|
|
87
|
+
const resolved = await carry.finish(result);
|
|
88
|
+
const intent = cli.intentLoad?.intent ?? null;
|
|
89
|
+
const warnings = [
|
|
90
|
+
...carry.warnings,
|
|
91
|
+
...(cli.intentLoad?.warnings ?? []),
|
|
92
|
+
...result.warnings,
|
|
93
|
+
];
|
|
70
94
|
if (cli.json) {
|
|
71
95
|
console.log(buildPrReviewJson({
|
|
72
96
|
repo: options.repo,
|
|
73
97
|
prNumber: options.prNumber,
|
|
74
98
|
markdown: result.text,
|
|
99
|
+
findings: resolved,
|
|
100
|
+
warnings,
|
|
75
101
|
guideBuiltAt: result.guideBuiltAt,
|
|
76
102
|
codegraphState,
|
|
77
103
|
codegraphReason: null,
|
|
78
104
|
usage,
|
|
79
105
|
durationMs,
|
|
80
106
|
reviewBlocking: options.reviewBlocking,
|
|
107
|
+
diffStats: result.diffStats,
|
|
108
|
+
coverage: result.coverage,
|
|
109
|
+
extensions,
|
|
110
|
+
includeExtensionMarkdowns: cli.includeExtensionMarkdowns,
|
|
111
|
+
intent: intentRecord(intent),
|
|
81
112
|
}));
|
|
82
113
|
}
|
|
83
114
|
else if (cli.output === "github") {
|
|
84
115
|
emitGithubOutput({
|
|
85
116
|
title: `${options.repo} · PR #${options.prNumber}`,
|
|
86
117
|
findings: humanFindingsFromResolved(resolved, options.reviewBlocking),
|
|
87
|
-
run: summaryFromMetrics(aiMetrics, performance.now() - operationStarted),
|
|
118
|
+
run: runSummaryWithExtensions(summaryFromMetrics(aiMetrics, performance.now() - operationStarted), extensions),
|
|
119
|
+
coverage: result.coverage,
|
|
120
|
+
catchesUp: true,
|
|
121
|
+
extensions,
|
|
122
|
+
intent: intent !== null,
|
|
88
123
|
});
|
|
89
124
|
}
|
|
90
125
|
else {
|
|
@@ -95,17 +130,23 @@ async function runReviewPr(options, cli) {
|
|
|
95
130
|
guideBuiltAt: result.guideBuiltAt,
|
|
96
131
|
codegraphState,
|
|
97
132
|
findings: humanFindingsFromResolved(resolved, options.reviewBlocking),
|
|
133
|
+
warnings,
|
|
134
|
+
coverage: result.coverage,
|
|
135
|
+
extensions,
|
|
136
|
+
intent: intent !== null,
|
|
98
137
|
}) +
|
|
99
138
|
"\n");
|
|
100
|
-
printRunSummary(summaryFromMetrics(aiMetrics, performance.now() - operationStarted));
|
|
139
|
+
printRunSummary(runSummaryWithExtensions(summaryFromMetrics(aiMetrics, performance.now() - operationStarted), extensions));
|
|
101
140
|
if (options.logTime) {
|
|
102
141
|
log("time", `AI total · calls=${aiMetrics.calls} · input=${aiMetrics.tokensIn} tokens · output=${aiMetrics.tokensOut} tokens · cost=${costLabel(aiMetrics)}`);
|
|
103
142
|
console.error(`[time] total review · ${((performance.now() - operationStarted) / 1000).toFixed(2)}s`);
|
|
104
143
|
}
|
|
105
144
|
}
|
|
106
|
-
|
|
145
|
+
// A blocking finding carried over from an earlier run still blocks, so
|
|
146
|
+
// the resolved rows decide as well as the model's own text.
|
|
147
|
+
exitWith(exitCodeWithExtensions(cli.json
|
|
107
148
|
? reviewExitCodeFromResolved(resolved, options.reviewBlocking)
|
|
108
|
-
: reviewExitCode(result.text, options.reviewBlocking));
|
|
149
|
+
: Math.max(reviewExitCode(result.text, options.reviewBlocking), reviewExitCodeFromResolved(resolved, options.reviewBlocking)), extensions));
|
|
109
150
|
}
|
|
110
151
|
finally {
|
|
111
152
|
// A heartbeat left running on the error path keeps the event loop alive
|
|
@@ -16,6 +16,8 @@ import { startRemoteWatchdog } from "../../remote/server/sessions.js";
|
|
|
16
16
|
import { passwordProblem } from "../../util/password.js";
|
|
17
17
|
import { deleteAllSessions } from "../../store/sessions.js";
|
|
18
18
|
import { serveHttp } from "../../server/http.js";
|
|
19
|
+
import { listJobs } from "../../store/jobs.js";
|
|
20
|
+
import { removeServeRunFolders } from "../../extensions/run_folder.js";
|
|
19
21
|
import { currentPlatform, getEnv } from "../../util/runtime.js";
|
|
20
22
|
import { die } from "../error.js";
|
|
21
23
|
/** `undefined` on Linux, otherwise one line naming the platform. The
|
|
@@ -177,6 +179,9 @@ export async function runServe(args) {
|
|
|
177
179
|
registerReplyJobHandler();
|
|
178
180
|
registerPushReviewHandlers();
|
|
179
181
|
registerWatchCommentHandler();
|
|
182
|
+
// Before the orphans run again: a job still marked running keeps its
|
|
183
|
+
// extension folder, which tells its rerun what the restart cut off.
|
|
184
|
+
await removeServeRunFolders(new Set(listJobs({ status: "running" }).map((job) => job.id)));
|
|
180
185
|
const recovered = await recoverOrphans();
|
|
181
186
|
if (recovered > 0) {
|
|
182
187
|
console.log(`[serve] recovered ${recovered} orphaned job(s) from a previous run`);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { readConfig, configPath, savedKeyProvider, writeRepoConfig, writeUserConfig, } from "../../config.js";
|
|
2
2
|
import { checkReviewSystemPrompt, reviewSystemPromptLimit, } from "../../review/system_prompt.js";
|
|
3
3
|
import { canonicalRepoName } from "../../util/repo_name.js";
|
|
4
|
+
import { DiagramSettingError, diagramOptionsFrom, } from "../../review/diagram.js";
|
|
4
5
|
import { hashPassword, passwordProblem } from "../../util/password.js";
|
|
5
|
-
import {
|
|
6
|
-
import { appDbPath, closeAppDb, openAppDb } from "../../store/app_db.js";
|
|
7
|
-
import { existsSync } from "node:fs";
|
|
6
|
+
import { nowIso } from "../../util/time.js";
|
|
8
7
|
import { readTextFile } from "../../util/runtime.js";
|
|
9
8
|
import { verifyAnthropic, verifyOpenAi, verifyOpenRouter, } from "../../ai/verify.js";
|
|
10
9
|
import { verifyOpenCode } from "../../ai/opencode.js";
|
|
@@ -83,7 +82,10 @@ export async function runSet(args) {
|
|
|
83
82
|
"repo",
|
|
84
83
|
"review-system-prompt",
|
|
85
84
|
"review-system-prompt-max-chars",
|
|
85
|
+
...DIAGRAM_FLAGS,
|
|
86
|
+
"review-read-diff-max-chars",
|
|
86
87
|
"password",
|
|
88
|
+
"extension-rerun-on-restart",
|
|
87
89
|
"unset",
|
|
88
90
|
];
|
|
89
91
|
const verify = !args.includes("--no-verify");
|
|
@@ -102,6 +104,10 @@ export async function runSet(args) {
|
|
|
102
104
|
await runSetRepo(repoArg, args);
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
107
|
+
for (const name of DIAGRAM_FLAGS) {
|
|
108
|
+
if (text(args, name) !== undefined)
|
|
109
|
+
die(`--${name} needs --repo`);
|
|
110
|
+
}
|
|
105
111
|
const ai = text(args, "ai");
|
|
106
112
|
rejectRetiredProvider(ai);
|
|
107
113
|
if (ai && !AI_PROVIDERS.includes(ai)) {
|
|
@@ -145,6 +151,7 @@ export async function runSet(args) {
|
|
|
145
151
|
"review-blocking": "reviewBlocking",
|
|
146
152
|
"codegraph-version": "codegraphVersion",
|
|
147
153
|
password: "dashboardPasswordHash",
|
|
154
|
+
"extension-rerun-on-restart": "extensionRerunOnRestart",
|
|
148
155
|
};
|
|
149
156
|
const unset = new Set(args
|
|
150
157
|
.filter((arg) => arg.startsWith("--unset="))
|
|
@@ -305,6 +312,13 @@ export async function runSet(args) {
|
|
|
305
312
|
}
|
|
306
313
|
patch.defaults = defaults;
|
|
307
314
|
}
|
|
315
|
+
const rerunOnRestart = text(args, "extension-rerun-on-restart");
|
|
316
|
+
if (rerunOnRestart !== undefined) {
|
|
317
|
+
if (!["true", "false"].includes(rerunOnRestart)) {
|
|
318
|
+
die("--extension-rerun-on-restart must be true or false");
|
|
319
|
+
}
|
|
320
|
+
patch.extensionRerunOnRestart = rerunOnRestart === "true";
|
|
321
|
+
}
|
|
308
322
|
const password = text(args, "password");
|
|
309
323
|
if (password) {
|
|
310
324
|
const problem = passwordProblem(password);
|
|
@@ -354,29 +368,28 @@ export async function runSet(args) {
|
|
|
354
368
|
console.error(`[set] could not verify the key and model (${result.reason}); saved anyway.`);
|
|
355
369
|
}
|
|
356
370
|
}
|
|
357
|
-
await writeUserConfig(patch);
|
|
358
371
|
// A changed password, allowed user, or sign-in method must not leave old
|
|
359
|
-
// dashboard sessions valid.
|
|
360
|
-
//
|
|
372
|
+
// dashboard sessions valid. A running `serve` holds app.db, so instead of
|
|
373
|
+
// deleting sessions here the change time goes into config.json and
|
|
374
|
+
// `verifySession` refuses every session issued before it.
|
|
361
375
|
const credentialChanged = patch.dashboardPasswordHash !== undefined ||
|
|
362
376
|
patch.passwordAuthDisabled !== undefined ||
|
|
363
377
|
patch.githubAuthEnabled !== undefined ||
|
|
364
378
|
patch.githubOAuthAllowedUser !== undefined;
|
|
365
|
-
|
|
366
|
-
await openAppDb();
|
|
367
|
-
try {
|
|
368
|
-
deleteAllSessions();
|
|
369
|
-
}
|
|
370
|
-
finally {
|
|
371
|
-
await closeAppDb();
|
|
372
|
-
}
|
|
373
|
-
}
|
|
379
|
+
await writeUserConfig(credentialChanged ? { ...patch, credentialsChangedAt: nowIso() } : patch);
|
|
374
380
|
const summary = Object.entries(patch).map(([key, value]) => value === undefined
|
|
375
381
|
? `${key} (unset)`
|
|
376
382
|
: `${key}=${secretFields.has(key) ? "•".repeat(8) : value}`);
|
|
377
383
|
console.log(`[set] updated: ${summary.join(", ")}`);
|
|
378
384
|
console.log(`Saved to ${configPath()}`);
|
|
379
385
|
}
|
|
386
|
+
/** The diagram settings. They are repository settings only, so the App
|
|
387
|
+
* reviews `serve` runs can read them too. */
|
|
388
|
+
const DIAGRAM_FLAGS = [
|
|
389
|
+
"diagram-runtime",
|
|
390
|
+
"plantuml-server",
|
|
391
|
+
"plantuml-output-format",
|
|
392
|
+
];
|
|
380
393
|
/** Flag names that make sense together with `--repo`. Anything else is a
|
|
381
394
|
* global setting and is refused rather than silently written to the wrong
|
|
382
395
|
* place. */
|
|
@@ -384,6 +397,8 @@ const REPO_SCOPED_FLAGS = new Set([
|
|
|
384
397
|
"repo",
|
|
385
398
|
"review-system-prompt",
|
|
386
399
|
"review-system-prompt-max-chars",
|
|
400
|
+
...DIAGRAM_FLAGS,
|
|
401
|
+
"review-read-diff-max-chars",
|
|
387
402
|
"gh-concurrent",
|
|
388
403
|
"ai-concurrent",
|
|
389
404
|
"unset",
|
|
@@ -395,12 +410,18 @@ const REPO_SCOPED_UNSET = new Set([
|
|
|
395
410
|
"reviewSystemPrompt",
|
|
396
411
|
"review-system-prompt-max-chars",
|
|
397
412
|
"reviewSystemPromptMaxChars",
|
|
413
|
+
...DIAGRAM_FLAGS,
|
|
414
|
+
"diagramRuntime",
|
|
415
|
+
"plantumlServer",
|
|
416
|
+
"plantumlOutputFormat",
|
|
417
|
+
"review-read-diff-max-chars",
|
|
418
|
+
"reviewReadDiffMaxChars",
|
|
398
419
|
"gh-concurrent",
|
|
399
420
|
"ghConcurrent",
|
|
400
421
|
"ai-concurrent",
|
|
401
422
|
"aiConcurrent",
|
|
402
423
|
]);
|
|
403
|
-
/** `set --repo=owner/repo [--review-system-prompt=... | --review-system-prompt-max-chars=N | --unset=name]`
|
|
424
|
+
/** `set --repo=owner/repo [--review-system-prompt=... | --review-system-prompt-max-chars=N | --review-read-diff-max-chars=N | --unset=name]`
|
|
404
425
|
* writes the repository-scoped settings to `repos[owner/repo]` in config.json
|
|
405
426
|
* instead of the global config. */
|
|
406
427
|
async function runSetRepo(typed, args) {
|
|
@@ -434,12 +455,36 @@ async function runSetRepo(typed, args) {
|
|
|
434
455
|
unset.has("reviewSystemPromptMaxChars")) {
|
|
435
456
|
patch.reviewSystemPromptMaxChars = undefined;
|
|
436
457
|
}
|
|
458
|
+
if (unset.has("review-read-diff-max-chars") ||
|
|
459
|
+
unset.has("reviewReadDiffMaxChars")) {
|
|
460
|
+
patch.reviewReadDiffMaxChars = undefined;
|
|
461
|
+
}
|
|
437
462
|
if (unset.has("gh-concurrent") || unset.has("ghConcurrent")) {
|
|
438
463
|
patch.ghConcurrent = undefined;
|
|
439
464
|
}
|
|
440
465
|
if (unset.has("ai-concurrent") || unset.has("aiConcurrent")) {
|
|
441
466
|
patch.aiConcurrent = undefined;
|
|
442
467
|
}
|
|
468
|
+
for (const [flag, field] of [
|
|
469
|
+
["diagram-runtime", "diagramRuntime"],
|
|
470
|
+
["plantuml-server", "plantumlServer"],
|
|
471
|
+
["plantuml-output-format", "plantumlOutputFormat"],
|
|
472
|
+
]) {
|
|
473
|
+
if (unset.has(flag) || unset.has(field))
|
|
474
|
+
patch[field] = undefined;
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
Object.assign(patch, diagramOptionsFrom({
|
|
478
|
+
runtime: text(args, "diagram-runtime"),
|
|
479
|
+
server: text(args, "plantuml-server"),
|
|
480
|
+
format: text(args, "plantuml-output-format"),
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
483
|
+
catch (error) {
|
|
484
|
+
if (error instanceof DiagramSettingError)
|
|
485
|
+
die(error.message);
|
|
486
|
+
throw error;
|
|
487
|
+
}
|
|
443
488
|
const ghRaw = text(args, "gh-concurrent");
|
|
444
489
|
if (ghRaw !== undefined) {
|
|
445
490
|
patch.ghConcurrent = concurrencyValue(ghRaw, "--gh-concurrent");
|
|
@@ -462,12 +507,25 @@ async function runSetRepo(typed, args) {
|
|
|
462
507
|
patch.reviewSystemPromptMaxChars = value;
|
|
463
508
|
}
|
|
464
509
|
}
|
|
510
|
+
const readDiffRaw = text(args, "review-read-diff-max-chars");
|
|
511
|
+
if (readDiffRaw !== undefined) {
|
|
512
|
+
if (readDiffRaw.trim() === "") {
|
|
513
|
+
patch.reviewReadDiffMaxChars = undefined;
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
const value = Number(readDiffRaw);
|
|
517
|
+
if (!Number.isInteger(value)) {
|
|
518
|
+
die("--review-read-diff-max-chars must be an integer (0 or -1 for no limit)");
|
|
519
|
+
}
|
|
520
|
+
patch.reviewReadDiffMaxChars = value;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
465
523
|
const prompt = text(args, "review-system-prompt");
|
|
466
524
|
if (prompt !== undefined) {
|
|
467
525
|
patch.reviewSystemPrompt = prompt.trim() === "" ? undefined : prompt;
|
|
468
526
|
}
|
|
469
527
|
if (Object.keys(patch).length === 0) {
|
|
470
|
-
die("Nothing to set. Pass --review-system-prompt=, --review-system-prompt-max-chars=N, or --unset=name with --repo.");
|
|
528
|
+
die("Nothing to set. Pass --review-system-prompt=, --review-system-prompt-max-chars=N, --diagram-runtime=, --plantuml-server=, --plantuml-output-format=, --review-read-diff-max-chars=N, or --unset=name with --repo.");
|
|
471
529
|
}
|
|
472
530
|
// The values after this write are the ones given here, or the stored ones.
|
|
473
531
|
// Lowering the cap re-checks the stored prompt too, so it cannot end up over
|