co-maintainer 0.7.2-beta.1 → 0.7.3
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/dist/package.json +2 -1
- package/dist/src/ai/anthropic.d.ts +1 -1
- package/dist/src/ai/anthropic.js +1 -1
- package/dist/src/ai/batch.d.ts +1 -1
- package/dist/src/ai/batch.js +3 -3
- package/dist/src/ai/copy_rule.d.ts +7 -0
- package/dist/src/ai/copy_rule.js +23 -0
- package/dist/src/ai/estimate.js +3 -3
- package/dist/src/ai/fake.js +2 -1
- package/dist/src/ai/mermaid.js +1 -0
- package/dist/src/ai/oauth/registry.d.ts +1 -1
- package/dist/src/ai/oauth/sign-in-with-chatgpt.d.ts +4 -4
- package/dist/src/ai/oauth/sign-in-with-chatgpt.js +6 -6
- package/dist/src/ai/openai.d.ts +3 -3
- package/dist/src/ai/openai.js +4 -4
- package/dist/src/ai/openrouter.d.ts +1 -1
- package/dist/src/ai/openrouter.js +1 -1
- package/dist/src/ai/pricing.js +1 -1
- package/dist/src/ai/provider.d.ts +2 -0
- package/dist/src/ai/provider.js +8 -2
- package/dist/src/ai/verify.d.ts +1 -1
- package/dist/src/ai/verify.js +1 -1
- package/dist/src/cli/args.js +1 -1
- package/dist/src/cli/command_json.d.ts +4 -2
- package/dist/src/cli/command_json.js +1 -0
- package/dist/src/cli/commands/config.d.ts +1 -1
- package/dist/src/cli/commands/config.js +1 -1
- package/dist/src/cli/commands/oauth.js +1 -1
- package/dist/src/cli/commands/probe.js +1 -1
- package/dist/src/cli/commands/review.js +2 -0
- package/dist/src/cli/commands/serve.d.ts +1 -1
- package/dist/src/cli/commands/serve.js +1 -1
- package/dist/src/cli/commands/set.d.ts +1 -1
- package/dist/src/cli/commands/set.js +23 -6
- package/dist/src/cli/commands/view.js +2 -2
- package/dist/src/cli/error.d.ts +1 -1
- package/dist/src/cli/error.js +1 -1
- package/dist/src/cli/pr_carry.d.ts +2 -0
- package/dist/src/cli/pr_carry.js +2 -2
- package/dist/src/cli/prompt.d.ts +2 -2
- package/dist/src/cli/prompt.js +3 -3
- package/dist/src/cli/review_args.js +2 -2
- package/dist/src/cli/review_carry.d.ts +3 -1
- package/dist/src/cli/review_carry.js +5 -3
- package/dist/src/cli/review_result.d.ts +13 -5
- package/dist/src/cli/review_result.js +19 -9
- package/dist/src/config.d.ts +20 -11
- package/dist/src/config.js +3 -3
- package/dist/src/github/app.d.ts +1 -1
- package/dist/src/github/app.js +1 -1
- package/dist/src/github/app_manifest.d.ts +1 -1
- package/dist/src/github/app_manifest.js +1 -1
- package/dist/src/github/client.d.ts +1 -1
- package/dist/src/github/client.js +1 -1
- package/dist/src/github/collect.d.ts +7 -1
- package/dist/src/github/collect.js +41 -16
- package/dist/src/github/gh.js +2 -2
- package/dist/src/github/jwt.d.ts +1 -1
- package/dist/src/github/jwt.js +1 -1
- package/dist/src/github/oauth.js +2 -2
- package/dist/src/knowledge/facts.js +3 -3
- package/dist/src/knowledge/guide.d.ts +24 -1
- package/dist/src/knowledge/guide.js +46 -16
- package/dist/src/knowledge/guide_ids.d.ts +9 -0
- package/dist/src/knowledge/guide_ids.js +26 -7
- package/dist/src/knowledge/probe.js +1 -1
- package/dist/src/knowledge/rule_changes.d.ts +18 -0
- package/dist/src/knowledge/rule_changes.js +41 -0
- package/dist/src/knowledge/rules.d.ts +11 -0
- package/dist/src/knowledge/rules.js +10 -1
- package/dist/src/knowledge/skill.js +1 -1
- package/dist/src/knowledge/stable_ids.d.ts +29 -0
- package/dist/src/knowledge/stable_ids.js +90 -0
- package/dist/src/knowledge/synthesis.d.ts +13 -1
- package/dist/src/knowledge/synthesis.js +94 -26
- package/dist/src/knowledge/types.d.ts +16 -0
- package/dist/src/local/carry_over_store.d.ts +1 -1
- package/dist/src/local/carry_over_store.js +1 -1
- package/dist/src/local/codegraph_prepare.js +1 -1
- package/dist/src/local/git_ops.js +1 -1
- package/dist/src/local/review_local.js +6 -5
- package/dist/src/local/review_lock.d.ts +1 -1
- package/dist/src/pr/checkout.d.ts +3 -3
- package/dist/src/pr/checkout.js +7 -7
- package/dist/src/pr/codegraph_tool_args.d.ts +1 -1
- package/dist/src/pr/codegraph_tool_args.js +1 -1
- package/dist/src/pr/findings.d.ts +3 -0
- package/dist/src/pr/findings.js +29 -10
- package/dist/src/pr/findings_json.d.ts +2 -2
- package/dist/src/pr/findings_json.js +15 -2
- package/dist/src/pr/github_revision.js +1 -1
- package/dist/src/pr/review_copy.d.ts +2 -3
- package/dist/src/pr/review_copy.js +2 -3
- package/dist/src/pr/reviewer.d.ts +7 -3
- package/dist/src/pr/reviewer.js +26 -26
- package/dist/src/pr/scope.d.ts +8 -8
- package/dist/src/pr/scope.js +4 -4
- package/dist/src/pr/snapshot.d.ts +2 -2
- package/dist/src/remote/client.js +4 -3
- package/dist/src/remote/schema.d.ts +1 -1
- package/dist/src/remote/schema.js +1 -1
- package/dist/src/remote/server/body.d.ts +1 -1
- package/dist/src/remote/server/body.js +1 -1
- package/dist/src/remote/server/guides.js +1 -1
- package/dist/src/remote/validate.js +1 -1
- package/dist/src/review/blocking.d.ts +3 -3
- package/dist/src/review/blocking.js +2 -2
- package/dist/src/review/carry_over.d.ts +9 -1
- package/dist/src/review/carry_over.js +10 -2
- package/dist/src/review/diagram.js +7 -6
- package/dist/src/review/engine.d.ts +1 -1
- package/dist/src/review/guides.js +1 -1
- package/dist/src/review/references.d.ts +68 -0
- package/dist/src/review/references.js +176 -0
- package/dist/src/review/system_prompt.d.ts +1 -1
- package/dist/src/review/system_prompt.js +1 -1
- package/dist/src/server/api/jobs.js +2 -2
- package/dist/src/server/api/repos.js +1 -1
- package/dist/src/server/app.js +1 -1
- package/dist/src/server/auth.d.ts +3 -3
- package/dist/src/server/auth.js +9 -4
- package/dist/src/server/http.js +5 -5
- package/dist/src/server/pages/activity.js +1 -1
- package/dist/src/server/pages/add_repo.js +1 -0
- package/dist/src/server/pages/client.d.ts +2 -2
- package/dist/src/server/pages/client.js +2 -2
- package/dist/src/server/pages/home.d.ts +1 -1
- package/dist/src/server/pages/home.js +1 -1
- package/dist/src/server/pages/icons.d.ts +1 -1
- package/dist/src/server/pages/icons.js +1 -1
- package/dist/src/server/pages/layout.d.ts +2 -2
- package/dist/src/server/pages/layout.js +3 -3
- package/dist/src/server/pages/pr.js +4 -0
- package/dist/src/server/pages/rate_limit_waits.js +2 -2
- package/dist/src/server/pages/references.d.ts +2 -0
- package/dist/src/server/pages/references.js +55 -0
- package/dist/src/server/pages/repo.js +26 -0
- package/dist/src/server/pages/repo_settings.js +1 -0
- package/dist/src/server/pages/router.js +3 -2
- package/dist/src/server/pages/styles.d.ts +2 -2
- package/dist/src/server/pages/styles.js +2 -2
- package/dist/src/server/pages/ui.d.ts +1 -1
- package/dist/src/server/pages/ui.js +2 -2
- package/dist/src/server/webhook/index.js +1 -1
- package/dist/src/services/clear.d.ts +2 -2
- package/dist/src/services/clear.js +2 -2
- package/dist/src/services/dashboard.d.ts +2 -0
- package/dist/src/services/dashboard.js +2 -0
- package/dist/src/services/probe.js +1 -1
- package/dist/src/services/push_review.js +4 -1
- package/dist/src/services/remote_review.js +5 -2
- package/dist/src/services/remote_review_abort.d.ts +1 -1
- package/dist/src/services/remote_review_abort.js +1 -1
- package/dist/src/services/remote_tokens.js +1 -1
- package/dist/src/services/replies.js +0 -2
- package/dist/src/services/review.d.ts +3 -5
- package/dist/src/services/review.js +43 -18
- package/dist/src/services/rules_build.d.ts +20 -1
- package/dist/src/services/rules_build.js +85 -6
- package/dist/src/services/setup.d.ts +2 -2
- package/dist/src/services/setup.js +36 -11
- package/dist/src/services/watch_comments.js +1 -2
- package/dist/src/services/watch_notes.js +1 -3
- package/dist/src/store/app_db.d.ts +1 -1
- package/dist/src/store/app_db.js +2 -2
- package/dist/src/store/findings.d.ts +2 -0
- package/dist/src/store/findings.js +3 -3
- package/dist/src/store/jobs.d.ts +2 -2
- package/dist/src/store/jobs.js +3 -3
- package/dist/src/store/migrations.d.ts +2 -2
- package/dist/src/store/migrations.js +35 -18
- package/dist/src/store/rows.d.ts +4 -2
- package/dist/src/store/rows.js +1 -1
- package/dist/src/store/rule_events.d.ts +15 -0
- package/dist/src/store/rule_events.js +20 -0
- package/dist/src/store/sessions.d.ts +1 -1
- package/dist/src/store/sessions.js +2 -2
- package/dist/src/store/sqlite.js +2 -2
- package/dist/src/tools/codegraph.d.ts +1 -1
- package/dist/src/tools/codegraph.js +3 -3
- package/dist/src/tools/codegraph_exec.d.ts +1 -1
- package/dist/src/tools/codegraph_exec.js +1 -1
- package/dist/src/types.d.ts +6 -2
- package/dist/src/util/keyed_lock.d.ts +1 -1
- package/dist/src/util/keyed_lock.js +1 -1
- package/dist/src/util/log.js +1 -1
- package/dist/src/util/redact.js +2 -1
- package/dist/src/util/run_summary.d.ts +3 -3
- package/dist/src/util/run_summary.js +3 -3
- package/dist/src/util/runtime.d.ts +4 -4
- package/dist/src/util/runtime.js +5 -5
- package/dist/src/util/time.d.ts +1 -1
- package/dist/src/util/time.js +1 -1
- package/package.json +2 -1
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "co-maintainer",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "An imitator of yours, A PR review tool like co-maintainer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"lint": "oxlint",
|
|
41
41
|
"fmt": "oxfmt --write .",
|
|
42
42
|
"fmt:check": "oxfmt --check .",
|
|
43
|
+
"punctuation": "node scripts/punctuation.ts",
|
|
43
44
|
"dev": "node --watch main.ts",
|
|
44
45
|
"probe": "node main.ts probe",
|
|
45
46
|
"init": "node main.ts init",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* called for the SDK's `stream()` + `finalMessage()` helper for large `max_tokens` (a single
|
|
27
27
|
* review can ask for 96k). The SDK is not a dependency (kept fetch-only, the
|
|
28
28
|
* same as every other provider), and a hand-rolled SSE accumulation loop is a
|
|
29
|
-
* lot of code for a first cut. Anthropic's HTTP request timeout is the risk
|
|
29
|
+
* lot of code for a first cut. Anthropic's HTTP request timeout is the risk,
|
|
30
30
|
* if a real review ever hits it, add the streaming loop here. Upgrade path:
|
|
31
31
|
* `stream:true` + parse `content_block_delta` events into the same
|
|
32
32
|
* `parseMessagesBody` result shape.
|
package/dist/src/ai/anthropic.js
CHANGED
|
@@ -113,7 +113,7 @@ function toAnthropicMessages(messages) {
|
|
|
113
113
|
messages: out,
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
/** Haiku 4.5 does not support `output_config.effort
|
|
116
|
+
/** Haiku 4.5 does not support `output_config.effort`. Sending it is a 400.
|
|
117
117
|
* Anthropic's effort accepts low/medium/high/xhigh/max, so the only level this
|
|
118
118
|
* has to drop is "none": it means "reasoning off" in `AiRequest` and is not an
|
|
119
119
|
* effort value Anthropic lists. */
|
package/dist/src/ai/batch.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare class AiBatch {
|
|
|
33
33
|
/** Runs one unit, retrying a provider error and a response the validator
|
|
34
34
|
* rejects. It never throws: a provider error that outlives its retries drops
|
|
35
35
|
* the unit, and a response that still does not validate is used anyway. A run
|
|
36
|
-
* that has already paid for extraction must still write what it has
|
|
36
|
+
* that has already paid for extraction must still write what it has. A format
|
|
37
37
|
* deviation is not worth losing the whole run over. The one exception is
|
|
38
38
|
* Ctrl-C: every call then fails at once, and a run that went on without
|
|
39
39
|
* them would write guides with every section dropped. */
|
package/dist/src/ai/batch.js
CHANGED
|
@@ -77,7 +77,7 @@ export class AiBatch {
|
|
|
77
77
|
const cached = this.records[id];
|
|
78
78
|
if (cached?.status === "done" && cached.response) {
|
|
79
79
|
// A `done` record from 0.4.x can hold output that never parsed. Treat
|
|
80
|
-
// that as a miss and delete it so the retry below replaces it
|
|
80
|
+
// that as a miss and delete it so the retry below replaces it. The
|
|
81
81
|
// corrupted record heals on its own the next time its unit runs.
|
|
82
82
|
const reason = this.validate?.(request, cached.response) ?? null;
|
|
83
83
|
if (reason === null) {
|
|
@@ -128,7 +128,7 @@ export class AiBatch {
|
|
|
128
128
|
/** Runs one unit, retrying a provider error and a response the validator
|
|
129
129
|
* rejects. It never throws: a provider error that outlives its retries drops
|
|
130
130
|
* the unit, and a response that still does not validate is used anyway. A run
|
|
131
|
-
* that has already paid for extraction must still write what it has
|
|
131
|
+
* that has already paid for extraction must still write what it has. A format
|
|
132
132
|
* deviation is not worth losing the whole run over. The one exception is
|
|
133
133
|
* Ctrl-C: every call then fails at once, and a run that went on without
|
|
134
134
|
* them would write guides with every section dropped. */
|
|
@@ -162,7 +162,7 @@ export class AiBatch {
|
|
|
162
162
|
}
|
|
163
163
|
continue;
|
|
164
164
|
}
|
|
165
|
-
log("ai", `gave up ${item.request.job} ${item.id.slice(0, 8)} after ${attempt} attempts
|
|
165
|
+
log("ai", `gave up ${item.request.job} ${item.id.slice(0, 8)} after ${attempt} attempts, continuing without it`);
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
const reason = this.validate?.(item.request, response) ?? null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AiProvider, AiRequest } from "../types.ts";
|
|
2
|
+
/** The punctuation rule is a brand rule, not a fix for one prompt. Every AI
|
|
3
|
+
* job, present or future, gets it in its system prompt from here, so a new job
|
|
4
|
+
* cannot forget it. The rule text lives once, in `REVIEW_COPY_RULE`. */
|
|
5
|
+
export declare function withCopyRuleRequest(request: AiRequest): AiRequest;
|
|
6
|
+
/** A provider whose every request carries the copy rule. */
|
|
7
|
+
export declare function withCopyRule(provider: AiProvider): AiProvider;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { REVIEW_COPY_RULE } from "../pr/review_copy.js";
|
|
2
|
+
/** The punctuation rule is a brand rule, not a fix for one prompt. Every AI
|
|
3
|
+
* job, present or future, gets it in its system prompt from here, so a new job
|
|
4
|
+
* cannot forget it. The rule text lives once, in `REVIEW_COPY_RULE`. */
|
|
5
|
+
export function withCopyRuleRequest(request) {
|
|
6
|
+
if (request.system?.includes(REVIEW_COPY_RULE))
|
|
7
|
+
return request;
|
|
8
|
+
return {
|
|
9
|
+
...request,
|
|
10
|
+
system: request.system
|
|
11
|
+
? `${request.system}\n\n${REVIEW_COPY_RULE}`
|
|
12
|
+
: REVIEW_COPY_RULE,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** A provider whose every request carries the copy rule. */
|
|
16
|
+
export function withCopyRule(provider) {
|
|
17
|
+
return {
|
|
18
|
+
get supportsTools() {
|
|
19
|
+
return provider.supportsTools;
|
|
20
|
+
},
|
|
21
|
+
complete: (request) => provider.complete(withCopyRuleRequest(request)),
|
|
22
|
+
};
|
|
23
|
+
}
|
package/dist/src/ai/estimate.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
*
|
|
3
3
|
* Three sources, in order of trust:
|
|
4
4
|
*
|
|
5
|
-
* 1. Job counts come from the same inputs the real run uses
|
|
5
|
+
* 1. Job counts come from the same inputs the real run uses, the number of
|
|
6
6
|
* pull requests, whether the codebase is read, and the ten synthesis
|
|
7
|
-
* sections
|
|
7
|
+
* sections, so the shape is exact.
|
|
8
8
|
* 2. Dollars come from the live OpenRouter price for the configured models.
|
|
9
9
|
* When prices are unavailable the estimate reports tokens but no dollars
|
|
10
10
|
* rather than guessing one.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* there are enough, and from the calibration below otherwise.
|
|
13
13
|
*
|
|
14
14
|
* Calibration: cm-dx-lab, 4 pull requests and 8 files, 5
|
|
15
|
-
* extract and 9 synth jobs, 151 s, $0.0014
|
|
15
|
+
* extract and 9 synth jobs, 151 s, $0.0014, about 151/14 ≈ 10.8 s per job.
|
|
16
16
|
* Token counts per job are near 2.4k in and 0.7k out. The text always says
|
|
17
17
|
* the numbers are an estimate. */
|
|
18
18
|
import { cacheValues } from "../store/cache_db.js";
|
package/dist/src/ai/fake.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withCopyRuleRequest } from "./copy_rule.js";
|
|
1
2
|
import { getEnv, readTextFileSync } from "../util/runtime.js";
|
|
2
3
|
export const FAKE_REVIEW_MARKDOWN = `## Findings
|
|
3
4
|
|
|
@@ -62,7 +63,7 @@ export class FakeAiProvider {
|
|
|
62
63
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
63
64
|
}
|
|
64
65
|
async complete(request) {
|
|
65
|
-
await this.record(request);
|
|
66
|
+
await this.record(withCopyRuleRequest(request));
|
|
66
67
|
return {
|
|
67
68
|
text: this.jobText(request.job) ?? this.text,
|
|
68
69
|
tokensIn: 10,
|
package/dist/src/ai/mermaid.js
CHANGED
|
@@ -309,6 +309,7 @@ config:
|
|
|
309
309
|
---
|
|
310
310
|
Use rect_* for requirement/element boxes and line_height/fontSize for
|
|
311
311
|
readability. Keep risk and verification semantics in diagram data.`,
|
|
312
|
+
// punctuation: code, the message lists the semicolon as a forbidden character
|
|
312
313
|
"usecase-beta": `Configuration:
|
|
313
314
|
---
|
|
314
315
|
config:
|
|
@@ -19,7 +19,7 @@ export declare function oauthUnknownProvider(value: string | undefined): CliErro
|
|
|
19
19
|
export type OAuthOps = {
|
|
20
20
|
label: string;
|
|
21
21
|
credentialsPath(): string;
|
|
22
|
-
/** The browser flow
|
|
22
|
+
/** The browser flow. Always starts a new sign-in. */
|
|
23
23
|
login(): Promise<Credentials>;
|
|
24
24
|
logout(): Promise<boolean>;
|
|
25
25
|
refresh(): Promise<Credentials>;
|
|
@@ -24,16 +24,16 @@ export declare function normalizeModel(model: string): string;
|
|
|
24
24
|
export declare function loadCredentials(): Credentials | undefined;
|
|
25
25
|
export declare function logout(): Promise<boolean>;
|
|
26
26
|
type BrowserOpener = (url: string) => void;
|
|
27
|
-
/** Tests replace the browser with a helper that completes the callback
|
|
27
|
+
/** Tests replace the browser with a helper that completes the callback. The
|
|
28
28
|
* real opener shells out to the platform's open command. */
|
|
29
29
|
export declare function setBrowserOpener(opener: BrowserOpener | undefined): void;
|
|
30
|
-
/** The browser flow. Always runs, so a user can switch accounts
|
|
30
|
+
/** The browser flow. Always runs, so a user can switch accounts, `logout`
|
|
31
31
|
* first if the old one should not be reused. */
|
|
32
32
|
export declare function login(): Promise<Credentials>;
|
|
33
33
|
export declare function refresh(creds: Credentials): Promise<Credentials>;
|
|
34
34
|
/** Credentials for a run: reuse the freshest token this process has seen,
|
|
35
35
|
* refresh an expired one, or start the browser flow. `inflight` dedups so
|
|
36
|
-
* `init`'s low and high providers never open two browsers
|
|
36
|
+
* `init`'s low and high providers never open two browsers, `cached` keeps a
|
|
37
37
|
* 401 refresh done inside `complete()` visible to later callers. */
|
|
38
38
|
export declare function ensureCredentials(): Promise<Credentials>;
|
|
39
39
|
export type ModelInfo = {
|
|
@@ -42,7 +42,7 @@ export type ModelInfo = {
|
|
|
42
42
|
};
|
|
43
43
|
/** For `oauth refresh|ping|list-models`, which operate on an existing login
|
|
44
44
|
* and must not start a browser flow. A live token is reused, an expired one
|
|
45
|
-
* refreshed
|
|
45
|
+
* refreshed. No login at all is a clear error. */
|
|
46
46
|
export declare function requireCredentials(): Promise<Credentials>;
|
|
47
47
|
export declare function listModels(creds: Credentials): Promise<ModelInfo[]>;
|
|
48
48
|
/** The model slugs a user can pick, for prompts and error messages. */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* dance registers a client on first use, keeps the tokens in
|
|
6
6
|
* `~/.config/co-maintainer/oauth/sign-in-with-chatgpt.json` (0600), and
|
|
7
7
|
* refreshes them. The Responses translation itself lives in `openai.ts` and
|
|
8
|
-
* is shared
|
|
8
|
+
* is shared. This file only adds the auth and the plan-usage request shape.
|
|
9
9
|
*
|
|
10
10
|
* Route quirks this file exists to respect (confirmed against the live
|
|
11
11
|
* route): `store:false` and `stream:true` are required, `max_output_tokens`
|
|
@@ -36,7 +36,7 @@ function loginTimeoutMs() {
|
|
|
36
36
|
return Number.isFinite(raw) && raw > 0 ? raw : 5 * 60 * 1000;
|
|
37
37
|
}
|
|
38
38
|
/** `CM_SIWC_AUTH_URL` and `CM_SIWC_API_URL` point the flow at local fakes in
|
|
39
|
-
* tests
|
|
39
|
+
* tests. Unset means the real endpoints. `CM_SIWC_DIR` moves the credentials
|
|
40
40
|
* file so tests never touch the real one. */
|
|
41
41
|
function authOrigin() {
|
|
42
42
|
return (getEnv("CM_SIWC_AUTH_URL") ?? "https://auth.openai.com").replace(/\/$/, "");
|
|
@@ -173,7 +173,7 @@ export async function logout() {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
let browserOpener;
|
|
176
|
-
/** Tests replace the browser with a helper that completes the callback
|
|
176
|
+
/** Tests replace the browser with a helper that completes the callback. The
|
|
177
177
|
* real opener shells out to the platform's open command. */
|
|
178
178
|
export function setBrowserOpener(opener) {
|
|
179
179
|
browserOpener = opener;
|
|
@@ -343,7 +343,7 @@ function remember(creds) {
|
|
|
343
343
|
cached = creds;
|
|
344
344
|
return creds;
|
|
345
345
|
}
|
|
346
|
-
/** The browser flow. Always runs, so a user can switch accounts
|
|
346
|
+
/** The browser flow. Always runs, so a user can switch accounts, `logout`
|
|
347
347
|
* first if the old one should not be reused. */
|
|
348
348
|
export async function login() {
|
|
349
349
|
const existing = loadCredentials();
|
|
@@ -402,7 +402,7 @@ function requireInteractive() {
|
|
|
402
402
|
let inflight;
|
|
403
403
|
/** Credentials for a run: reuse the freshest token this process has seen,
|
|
404
404
|
* refresh an expired one, or start the browser flow. `inflight` dedups so
|
|
405
|
-
* `init`'s low and high providers never open two browsers
|
|
405
|
+
* `init`'s low and high providers never open two browsers, `cached` keeps a
|
|
406
406
|
* 401 refresh done inside `complete()` visible to later callers. */
|
|
407
407
|
export function ensureCredentials() {
|
|
408
408
|
if (cached && cached.expires_at - 60_000 > Date.now()) {
|
|
@@ -432,7 +432,7 @@ export function ensureCredentials() {
|
|
|
432
432
|
}
|
|
433
433
|
/** For `oauth refresh|ping|list-models`, which operate on an existing login
|
|
434
434
|
* and must not start a browser flow. A live token is reused, an expired one
|
|
435
|
-
* refreshed
|
|
435
|
+
* refreshed. No login at all is a clear error. */
|
|
436
436
|
export async function requireCredentials() {
|
|
437
437
|
const existing = loadCredentials();
|
|
438
438
|
if (!existing?.refresh_token && !existing?.access_token) {
|
package/dist/src/ai/openai.d.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* The full fix is `previous_response_id`, which needs a response id to
|
|
24
24
|
* survive between calls, and `AiProvider.complete` is stateless for every
|
|
25
25
|
* provider. Upgrade path: thread a response id through `AiResponse` if this
|
|
26
|
-
* turns out to matter in practice
|
|
26
|
+
* turns out to matter in practice. Codegraph's own tool loop caps rounds low
|
|
27
27
|
* (mermaid_loop.ts's `maxToolRounds`), which limits how much is at stake.
|
|
28
28
|
*/
|
|
29
29
|
import type { AiProvider, AiRequest, AiResponse, Json } from "../types.ts";
|
|
@@ -43,10 +43,10 @@ export type ResponsesBodyOptions = {
|
|
|
43
43
|
export declare function responsesBody(model: string, request: AiRequest, options?: ResponsesBodyOptions): Json;
|
|
44
44
|
export declare function parseResponsesBody(json: Json, model: string, provider?: AiResponse["provider"]): AiResponse;
|
|
45
45
|
/** The SSE body the plan usage route always returns (`stream: true`). The
|
|
46
|
-
* text deltas are ignored
|
|
46
|
+
* text deltas are ignored. The output items arrive as their own
|
|
47
47
|
* `response.output_item.done` events, because this route's terminal
|
|
48
48
|
* `response.completed` carries an empty `output` array (the standard API
|
|
49
|
-
* fills it). The terminal response supplies `usage` and `status
|
|
49
|
+
* fills it). The terminal response supplies `usage` and `status`. The
|
|
50
50
|
* collected items supply `output`, so the shared {@link parseResponsesBody}
|
|
51
51
|
* sees the same shape on both routes. A stream with no terminal response
|
|
52
52
|
* throws, and one cut mid-way names `url`'s host. */
|
package/dist/src/ai/openai.js
CHANGED
|
@@ -53,7 +53,7 @@ function toResponsesTool(tool) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
/** A tool call and its result do not live inside a message the way Chat
|
|
56
|
-
* Completions nests them
|
|
56
|
+
* Completions nests them. Each is its own item in `input`. */
|
|
57
57
|
function toResponsesInput(messages) {
|
|
58
58
|
const input = [];
|
|
59
59
|
let instructions;
|
|
@@ -166,10 +166,10 @@ export function parseResponsesBody(json, model, provider = "openai") {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
/** The SSE body the plan usage route always returns (`stream: true`). The
|
|
169
|
-
* text deltas are ignored
|
|
169
|
+
* text deltas are ignored. The output items arrive as their own
|
|
170
170
|
* `response.output_item.done` events, because this route's terminal
|
|
171
171
|
* `response.completed` carries an empty `output` array (the standard API
|
|
172
|
-
* fills it). The terminal response supplies `usage` and `status
|
|
172
|
+
* fills it). The terminal response supplies `usage` and `status`. The
|
|
173
173
|
* collected items supply `output`, so the shared {@link parseResponsesBody}
|
|
174
174
|
* sees the same shape on both routes. A stream with no terminal response
|
|
175
175
|
* throws, and one cut mid-way names `url`'s host. */
|
|
@@ -196,7 +196,7 @@ export async function readResponsesStream(response, url) {
|
|
|
196
196
|
if (done)
|
|
197
197
|
break;
|
|
198
198
|
buffer += decoder.decode(value, { stream: true });
|
|
199
|
-
// SSE events are separated by a blank line
|
|
199
|
+
// SSE events are separated by a blank line. Tolerate CRLF.
|
|
200
200
|
buffer = buffer.replace(/\r/g, "");
|
|
201
201
|
let index = buffer.indexOf("\n\n");
|
|
202
202
|
while (index >= 0) {
|
|
@@ -20,7 +20,7 @@ export type ChatHost = {
|
|
|
20
20
|
export declare function openRouterHost(): ChatHost;
|
|
21
21
|
/** Provider failures as actionable text. A 401 and a 400 for
|
|
22
22
|
* an unknown model are preconditions the user can fix, so they are usage
|
|
23
|
-
* errors
|
|
23
|
+
* errors. Anything else is a runtime failure. Only the provider's own
|
|
24
24
|
* `error.message` is surfaced: the raw body can carry account metadata
|
|
25
25
|
* (`user_id`) that has no business in a terminal. */
|
|
26
26
|
export declare function openRouterError(model: string, status: number, body: string, host?: ChatHost): CliError;
|
|
@@ -21,7 +21,7 @@ export function openRouterHost() {
|
|
|
21
21
|
}
|
|
22
22
|
/** Provider failures as actionable text. A 401 and a 400 for
|
|
23
23
|
* an unknown model are preconditions the user can fix, so they are usage
|
|
24
|
-
* errors
|
|
24
|
+
* errors. Anything else is a runtime failure. Only the provider's own
|
|
25
25
|
* `error.message` is surfaced: the raw body can carry account metadata
|
|
26
26
|
* (`user_id`) that has no business in a terminal. */
|
|
27
27
|
export function openRouterError(model, status, body, host = openRouterHost()) {
|
package/dist/src/ai/pricing.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
*
|
|
3
3
|
* `/api/v1/models` is public: no key needed. The list is large and changes
|
|
4
4
|
* slowly, so it is cached for 24 hours in cache.db. A network failure is not
|
|
5
|
-
* fatal
|
|
5
|
+
* fatal, the estimate then reports tokens and time but no dollars, which is
|
|
6
6
|
* still useful and never invents a price. */
|
|
7
7
|
import { openRouterBase } from "./verify.js";
|
|
8
8
|
import { cacheGet, cacheSet } from "../store/cache_db.js";
|
|
@@ -9,6 +9,8 @@ export declare function rejectRetiredProvider(value: string | undefined): void;
|
|
|
9
9
|
/** The provider a run actually calls. `--experimental-siwc` overrides the
|
|
10
10
|
* configured `ai` for the run, so logs and error labels name what ran. */
|
|
11
11
|
export declare function aiProviderName(options: Options): string;
|
|
12
|
+
/** The provider for a run. Every one it returns is wrapped by
|
|
13
|
+
* `withCopyRule`, so no job reaches a model without the punctuation rule. */
|
|
12
14
|
export declare function createAiProvider(options: Options, model: string): AiProvider | undefined;
|
|
13
15
|
/** A 400 that names one optional part of the request earns one retry without
|
|
14
16
|
* it: the JSON schema, which the prompt asks for anyway, or "thinking off",
|
package/dist/src/ai/provider.js
CHANGED
|
@@ -3,6 +3,7 @@ import { OpenAiProvider } from "./openai.js";
|
|
|
3
3
|
import { AnthropicProvider } from "./anthropic.js";
|
|
4
4
|
import { openCodeHost } from "./opencode.js";
|
|
5
5
|
import { EXPERIMENTAL_OAUTH_PROVIDER, oauthOps } from "./oauth/registry.js";
|
|
6
|
+
import { withCopyRule } from "./copy_rule.js";
|
|
6
7
|
import { die } from "../cli/error.js";
|
|
7
8
|
/** The one list of accepted `--ai` values, so a new or retired provider is
|
|
8
9
|
* added or removed in a single place instead of the half dozen copies
|
|
@@ -27,8 +28,13 @@ export function rejectRetiredProvider(value) {
|
|
|
27
28
|
export function aiProviderName(options) {
|
|
28
29
|
return options.experimentalSiwc ? EXPERIMENTAL_OAUTH_PROVIDER : options.ai;
|
|
29
30
|
}
|
|
31
|
+
/** The provider for a run. Every one it returns is wrapped by
|
|
32
|
+
* `withCopyRule`, so no job reaches a model without the punctuation rule. */
|
|
30
33
|
export function createAiProvider(options, model) {
|
|
31
|
-
|
|
34
|
+
return withCopyRule(createRawProvider(options, model));
|
|
35
|
+
}
|
|
36
|
+
function createRawProvider(options, model) {
|
|
37
|
+
// `--experimental-siwc` wins over `--ai` for the run, `parseArgs` refuses
|
|
32
38
|
// the two together, so this only sees one of them set.
|
|
33
39
|
if (options.experimentalSiwc) {
|
|
34
40
|
return oauthOps(EXPERIMENTAL_OAUTH_PROVIDER).createProvider(model);
|
|
@@ -127,7 +133,7 @@ export function chatBody(model, request) {
|
|
|
127
133
|
? { tools: request.tools, tool_choice: "auto" }
|
|
128
134
|
: {}),
|
|
129
135
|
// A review asks for structured output. The schema is sent even
|
|
130
|
-
// when tools are present, because most providers accept the pair
|
|
136
|
+
// when tools are present, because most providers accept the pair. One that
|
|
131
137
|
// rejects it gets a single retry without the schema (see
|
|
132
138
|
// `OpenRouterProvider.complete`), and the prompt also asks for a fenced
|
|
133
139
|
// JSON block, so a plain-text provider still works.
|
package/dist/src/ai/verify.d.ts
CHANGED
|
@@ -28,6 +28,6 @@ export declare function verifyOpenRouter(apiKey: string, model?: string): Promis
|
|
|
28
28
|
export declare function verifyOpenAi(apiKey: string, model?: string): Promise<VerifyResult>;
|
|
29
29
|
/** Anthropic authenticates the key and lists models at `/models`, but with its
|
|
30
30
|
* own headers (`x-api-key` + `anthropic-version`) instead of a Bearer token.
|
|
31
|
-
* Without a model the call only proves the key
|
|
31
|
+
* Without a model the call only proves the key. With one it also confirms
|
|
32
32
|
* Anthropic serves it. */
|
|
33
33
|
export declare function verifyAnthropic(apiKey: string, model?: string): Promise<VerifyResult>;
|
package/dist/src/ai/verify.js
CHANGED
|
@@ -114,7 +114,7 @@ export async function verifyOpenAi(apiKey, model) {
|
|
|
114
114
|
}
|
|
115
115
|
/** Anthropic authenticates the key and lists models at `/models`, but with its
|
|
116
116
|
* own headers (`x-api-key` + `anthropic-version`) instead of a Bearer token.
|
|
117
|
-
* Without a model the call only proves the key
|
|
117
|
+
* Without a model the call only proves the key. With one it also confirms
|
|
118
118
|
* Anthropic serves it. */
|
|
119
119
|
export async function verifyAnthropic(apiKey, model) {
|
|
120
120
|
const base = anthropicBase();
|
package/dist/src/cli/args.js
CHANGED
|
@@ -78,7 +78,7 @@ export async function parseArgs(args) {
|
|
|
78
78
|
const { config, envPath } = prepareConfig(args);
|
|
79
79
|
const env = (name) => getEnv(name);
|
|
80
80
|
const configDefault = config.defaults ?? {};
|
|
81
|
-
// Remembered from a prior `init`/`remake` on this exact repo
|
|
81
|
+
// Remembered from a prior `init`/`remake` on this exact repo, never a
|
|
82
82
|
// secret, so it can safely fill in everything except the API token.
|
|
83
83
|
const repoConfig = config.repos?.[repoName] ?? {};
|
|
84
84
|
const reviewBlocking = reviewBlockingFrom(env("CO_MAINTAINER_REVIEW_BLOCKING") ??
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { Estimate } from "../ai/estimate.ts";
|
|
9
9
|
import type { RunSummary } from "../util/run_summary.ts";
|
|
10
|
-
import type { RuleChanges } from "../knowledge/rule_changes.ts";
|
|
10
|
+
import type { Contradiction, RuleChanges } from "../knowledge/rule_changes.ts";
|
|
11
11
|
export type ProbeJsonInput = {
|
|
12
12
|
repo: string;
|
|
13
13
|
recommended: string;
|
|
@@ -37,7 +37,7 @@ export type SetupJsonInput = {
|
|
|
37
37
|
command: "init" | "sync";
|
|
38
38
|
repo: string;
|
|
39
39
|
skillPath: string;
|
|
40
|
-
/** Section keys this run rewrote
|
|
40
|
+
/** Section keys this run rewrote. Empty when the guide was already current. */
|
|
41
41
|
changed: string[];
|
|
42
42
|
facts: number;
|
|
43
43
|
pullRequests: number;
|
|
@@ -66,6 +66,8 @@ export type SetupJsonInput = {
|
|
|
66
66
|
guide: RuleChanges;
|
|
67
67
|
instructions: RuleChanges;
|
|
68
68
|
} | null;
|
|
69
|
+
/** Old guide rules a new rule goes against. Left out when there are none. */
|
|
70
|
+
contradicted?: Contradiction[];
|
|
69
71
|
summary: RunSummary;
|
|
70
72
|
};
|
|
71
73
|
export declare function buildSetupJson(input: SetupJsonInput): string;
|
|
@@ -39,6 +39,7 @@ export function buildSetupJson(input) {
|
|
|
39
39
|
...(input.ruleChanges !== undefined
|
|
40
40
|
? { ruleChanges: input.ruleChanges }
|
|
41
41
|
: {}),
|
|
42
|
+
...(input.contradicted?.length ? { contradicted: input.contradicted } : {}),
|
|
42
43
|
usage: {
|
|
43
44
|
tokensIn: summary.tokensIn,
|
|
44
45
|
tokensOut: summary.tokensOut,
|
|
@@ -15,7 +15,7 @@ export type Source = "env" | "file" | "default";
|
|
|
15
15
|
/** The env var that supplies each field, mirroring args.ts. Only the fields
|
|
16
16
|
* that actually read env are listed. */
|
|
17
17
|
export declare const ENV_BY_FIELD: Record<string, string[]>;
|
|
18
|
-
/** Renders one field for people. A secret is masked
|
|
18
|
+
/** Renders one field for people. A secret is masked. The password hash, which
|
|
19
19
|
* nobody can use, only reports whether it is set. */
|
|
20
20
|
export declare function displayValue(field: string, value: unknown): string;
|
|
21
21
|
/** Values a field falls back to when neither env nor the file sets it, so
|
|
@@ -52,7 +52,7 @@ export const ENV_BY_FIELD = {
|
|
|
52
52
|
remoteByokPolicy: ["CM_REMOTE_BYOK_POLICY"],
|
|
53
53
|
codegraphVersion: ["CM_CODEGRAPH_VERSION"],
|
|
54
54
|
};
|
|
55
|
-
/** Renders one field for people. A secret is masked
|
|
55
|
+
/** Renders one field for people. A secret is masked. The password hash, which
|
|
56
56
|
* nobody can use, only reports whether it is set. */
|
|
57
57
|
export function displayValue(field, value) {
|
|
58
58
|
if (field === "dashboardPasswordHash") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** `co-maintainer oauth login|logout|refresh|ping|list-models --provider=...`
|
|
2
2
|
*
|
|
3
3
|
* The credential side of the experimental Sign in with ChatGPT support. Only
|
|
4
|
-
* `login` starts a browser flow
|
|
4
|
+
* `login` starts a browser flow. The rest operate on an existing login and
|
|
5
5
|
* fail clearly when there is none. See `docs/docs/providers.md`. */
|
|
6
6
|
import { die } from "../error.js";
|
|
7
7
|
import { oauthOps, oauthUnknownProvider, resolveOAuthProvider, } from "../../ai/oauth/registry.js";
|
|
@@ -86,7 +86,7 @@ async function probe(options) {
|
|
|
86
86
|
console.log(` cost: ${costLine}`);
|
|
87
87
|
console.log(` basis: ${estimate.basis === "history"
|
|
88
88
|
? "this repository's recorded jobs"
|
|
89
|
-
: "the cm-dx-lab calibration"}
|
|
89
|
+
: "the cm-dx-lab calibration"}, an estimate, not a bill`);
|
|
90
90
|
if (commitWatch) {
|
|
91
91
|
console.log(`\ncommit watch ${commitWatch.app === "on"
|
|
92
92
|
? "✓ App (push event on)"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseReviewArgs } from "../review_args.js";
|
|
2
|
+
import { readConfig } from "../../config.js";
|
|
2
3
|
import { setCliInteractive } from "../args.js";
|
|
3
4
|
import { addAiMetrics, emptyAiMetrics, recordAiCost, } from "../../services/setup.js";
|
|
4
5
|
import { costUsage } from "../../util/cost.js";
|
|
@@ -134,6 +135,7 @@ async function runReviewPr(options, cli) {
|
|
|
134
135
|
coverage: result.coverage,
|
|
135
136
|
extensions,
|
|
136
137
|
intent: intent !== null,
|
|
138
|
+
showReferences: readConfig().repos?.[options.repo]?.reviewReferences === true,
|
|
137
139
|
}) +
|
|
138
140
|
"\n");
|
|
139
141
|
printRunSummary(runSummaryWithExtensions(summaryFromMetrics(aiMetrics, performance.now() - operationStarted), extensions));
|
|
@@ -11,7 +11,7 @@ export declare function resolveTrustProxy(args: string[], env?: (name: string) =
|
|
|
11
11
|
* kept, and a first start generates one, returned so the caller can print it. */
|
|
12
12
|
export declare function ensureDashboardPassword(args: string[], hasStoredPassword: boolean, store: PasswordStore): Promise<string | undefined>;
|
|
13
13
|
/** `--disable-auth=password` / `--enable-auth=github` always win over the
|
|
14
|
-
* config defaults `co-maintainer set` persisted
|
|
14
|
+
* config defaults `co-maintainer set` persisted. Dies if the result would
|
|
15
15
|
* leave no sign-in method active. Pure so it is testable without a server. */
|
|
16
16
|
export declare function resolveAuthMethods(args: string[], config: Pick<UserConfig, "passwordAuthDisabled" | "githubAuthEnabled">): AuthMethods;
|
|
17
17
|
export declare function resolveWebhookUrl(args: string[], port: number, configured?: string): string;
|
|
@@ -57,7 +57,7 @@ export async function ensureDashboardPassword(args, hasStoredPassword, store) {
|
|
|
57
57
|
return generated;
|
|
58
58
|
}
|
|
59
59
|
/** `--disable-auth=password` / `--enable-auth=github` always win over the
|
|
60
|
-
* config defaults `co-maintainer set` persisted
|
|
60
|
+
* config defaults `co-maintainer set` persisted. Dies if the result would
|
|
61
61
|
* leave no sign-in method active. Pure so it is testable without a server. */
|
|
62
62
|
export function resolveAuthMethods(args, config) {
|
|
63
63
|
const disableAuth = args
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** `co-maintainer set --token=... --ai=... --low-model=... --high-model=...
|
|
2
2
|
* --auth=... --github-app-id=... --github-app-private-key=... (or
|
|
3
3
|
* --github-app-private-key-file=path or --github-app-private-key-path=path)
|
|
4
|
-
* --github-webhook-secret
|
|
4
|
+
* --github-webhook-secret=...`,
|
|
5
5
|
* persists global defaults, including secrets, to config.json so every
|
|
6
6
|
* other command can skip both the flag and the interactive prompt. See
|
|
7
7
|
* docs/md/configuration.md for the tradeoff. */
|
|
@@ -41,7 +41,7 @@ const secretFields = new Set([
|
|
|
41
41
|
/** `co-maintainer set --token=... --ai=... --low-model=... --high-model=...
|
|
42
42
|
* --auth=... --github-app-id=... --github-app-private-key=... (or
|
|
43
43
|
* --github-app-private-key-file=path or --github-app-private-key-path=path)
|
|
44
|
-
* --github-webhook-secret
|
|
44
|
+
* --github-webhook-secret=...`,
|
|
45
45
|
* persists global defaults, including secrets, to config.json so every
|
|
46
46
|
* other command can skip both the flag and the interactive prompt. See
|
|
47
47
|
* docs/md/configuration.md for the tradeoff. */
|
|
@@ -76,6 +76,7 @@ export async function runSet(args) {
|
|
|
76
76
|
"review-policy",
|
|
77
77
|
"review-policy-file",
|
|
78
78
|
"review-blocking",
|
|
79
|
+
"review-references",
|
|
79
80
|
"codegraph-version",
|
|
80
81
|
"gh-concurrent",
|
|
81
82
|
"ai-concurrent",
|
|
@@ -104,7 +105,7 @@ export async function runSet(args) {
|
|
|
104
105
|
await runSetRepo(repoArg, args);
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
107
|
-
for (const name of DIAGRAM_FLAGS) {
|
|
108
|
+
for (const name of [...DIAGRAM_FLAGS, "review-references"]) {
|
|
108
109
|
if (text(args, name) !== undefined)
|
|
109
110
|
die(`--${name} needs --repo`);
|
|
110
111
|
}
|
|
@@ -336,8 +337,8 @@ export async function runSet(args) {
|
|
|
336
337
|
}
|
|
337
338
|
// Verify the key and model before writing, so a typo fails here instead of
|
|
338
339
|
// after a review has already fetched and cloned the pull request.
|
|
339
|
-
// A field present in the patch wins, including when its value is `undefined
|
|
340
|
-
//
|
|
340
|
+
// A field present in the patch wins, including when its value is `undefined`.
|
|
341
|
+
// That is an unset, and there is nothing left to verify.
|
|
341
342
|
const before = readConfig();
|
|
342
343
|
const effective = (field) => field in patch ? patch[field] : before[field];
|
|
343
344
|
const effectiveAi = effective("ai");
|
|
@@ -365,7 +366,7 @@ export async function runSet(args) {
|
|
|
365
366
|
if (result.status === "rejected")
|
|
366
367
|
throw result.error;
|
|
367
368
|
if (result.status === "unreachable") {
|
|
368
|
-
console.error(`[set] could not verify the key and model (${result.reason})
|
|
369
|
+
console.error(`[set] could not verify the key and model (${result.reason}). Saved anyway.`);
|
|
369
370
|
}
|
|
370
371
|
}
|
|
371
372
|
// A changed password, allowed user, or sign-in method must not leave old
|
|
@@ -399,6 +400,7 @@ const REPO_SCOPED_FLAGS = new Set([
|
|
|
399
400
|
"review-system-prompt-max-chars",
|
|
400
401
|
...DIAGRAM_FLAGS,
|
|
401
402
|
"review-read-diff-max-chars",
|
|
403
|
+
"review-references",
|
|
402
404
|
"gh-concurrent",
|
|
403
405
|
"ai-concurrent",
|
|
404
406
|
"unset",
|
|
@@ -420,6 +422,8 @@ const REPO_SCOPED_UNSET = new Set([
|
|
|
420
422
|
"ghConcurrent",
|
|
421
423
|
"ai-concurrent",
|
|
422
424
|
"aiConcurrent",
|
|
425
|
+
"review-references",
|
|
426
|
+
"reviewReferences",
|
|
423
427
|
]);
|
|
424
428
|
/** `set --repo=owner/repo [--review-system-prompt=... | --review-system-prompt-max-chars=N | --review-read-diff-max-chars=N | --unset=name]`
|
|
425
429
|
* writes the repository-scoped settings to `repos[owner/repo]` in config.json
|
|
@@ -520,12 +524,25 @@ async function runSetRepo(typed, args) {
|
|
|
520
524
|
patch.reviewReadDiffMaxChars = value;
|
|
521
525
|
}
|
|
522
526
|
}
|
|
527
|
+
if (unset.has("review-references") || unset.has("reviewReferences")) {
|
|
528
|
+
patch.reviewReferences = undefined;
|
|
529
|
+
}
|
|
530
|
+
const references = text(args, "review-references");
|
|
531
|
+
if (references !== undefined) {
|
|
532
|
+
if (!["on", "off"].includes(references)) {
|
|
533
|
+
die("--review-references must be on or off");
|
|
534
|
+
}
|
|
535
|
+
patch.reviewReferences = references === "on";
|
|
536
|
+
if (references === "on" && !existing.referencesBackfilledAt) {
|
|
537
|
+
console.log("[set] the next sync reads every pull request again once, so guide rules get links to the review comments they came from");
|
|
538
|
+
}
|
|
539
|
+
}
|
|
523
540
|
const prompt = text(args, "review-system-prompt");
|
|
524
541
|
if (prompt !== undefined) {
|
|
525
542
|
patch.reviewSystemPrompt = prompt.trim() === "" ? undefined : prompt;
|
|
526
543
|
}
|
|
527
544
|
if (Object.keys(patch).length === 0) {
|
|
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.");
|
|
545
|
+
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, --review-references=on|off, or --unset=name with --repo.");
|
|
529
546
|
}
|
|
530
547
|
// The values after this write are the ones given here, or the stored ones.
|
|
531
548
|
// Lowering the cap re-checks the stored prompt too, so it cannot end up over
|