co-maintainer 0.7.5-beta.2 → 0.7.5
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
CHANGED
|
@@ -4,7 +4,9 @@ type TokenSource = () => Promise<string>;
|
|
|
4
4
|
export declare function setGitHubAuth(repo: string, token: TokenSource): void;
|
|
5
5
|
export declare function clearGitHubAuthForTest(): void;
|
|
6
6
|
/** The environment that gives git the token for `https://github.com/`, or
|
|
7
|
-
* `undefined` when no App job registered one for this clone.
|
|
8
|
-
* cannot be minted
|
|
7
|
+
* `undefined` when no App job registered one for this clone. When the token
|
|
8
|
+
* cannot be minted this throws: an App job must not fall back to the
|
|
9
|
+
* machine's own login, which may reach more than the App does. The clone then
|
|
10
|
+
* fails and the review runs on the diff alone, saying why. */
|
|
9
11
|
export declare function gitAuthEnv(dir: string): Promise<Record<string, string> | undefined>;
|
|
10
12
|
export {};
|
package/dist/src/pr/git_auth.js
CHANGED
|
@@ -19,8 +19,10 @@ export function clearGitHubAuthForTest() {
|
|
|
19
19
|
sources.clear();
|
|
20
20
|
}
|
|
21
21
|
/** The environment that gives git the token for `https://github.com/`, or
|
|
22
|
-
* `undefined` when no App job registered one for this clone.
|
|
23
|
-
* cannot be minted
|
|
22
|
+
* `undefined` when no App job registered one for this clone. When the token
|
|
23
|
+
* cannot be minted this throws: an App job must not fall back to the
|
|
24
|
+
* machine's own login, which may reach more than the App does. The clone then
|
|
25
|
+
* fails and the review runs on the diff alone, saying why. */
|
|
24
26
|
export async function gitAuthEnv(dir) {
|
|
25
27
|
const source = sources.get(dir);
|
|
26
28
|
if (!source)
|
|
@@ -29,8 +31,8 @@ export async function gitAuthEnv(dir) {
|
|
|
29
31
|
try {
|
|
30
32
|
token = await source();
|
|
31
33
|
}
|
|
32
|
-
catch {
|
|
33
|
-
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new Error(`could not get the App token for git: ${error instanceof Error ? error.message : String(error)}`);
|
|
34
36
|
}
|
|
35
37
|
const basic = Buffer.from(`x-access-token:${token}`).toString("base64");
|
|
36
38
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FakeAiProvider } from "../ai/fake.js";
|
|
2
|
-
import { completeWithMermaidTools } from "../ai/mermaid_loop.js";
|
|
2
|
+
import { completeWithMermaidTools, } from "../ai/mermaid_loop.js";
|
|
3
3
|
import { MERMAID_GUIDANCE, NO_DIAGRAM_RULES } from "../pr/reviewer.js";
|
|
4
4
|
import { mermaidToolFields, plantumlReplyRules, renderDiagrams, } from "../review/diagram.js";
|
|
5
5
|
import { loadGuides } from "../review/guides.js";
|
|
@@ -173,6 +173,11 @@ async function runReplyJobCore(job, log, client, ai, signal) {
|
|
|
173
173
|
}
|
|
174
174
|
let answer = request.answer_md?.trim();
|
|
175
175
|
if (!answer) {
|
|
176
|
+
// A Stop before the answer is asked for: no AI call is made.
|
|
177
|
+
if (signal?.aborted) {
|
|
178
|
+
log("info", "stopped before asking the AI, nothing was posted");
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
176
181
|
setReplyStatus(request.id, "generating");
|
|
177
182
|
const options = replyOptions(request.repo, request.pr_number);
|
|
178
183
|
const provider = ai ??
|
|
@@ -203,7 +208,14 @@ async function runReplyJobCore(job, log, client, ai, signal) {
|
|
|
203
208
|
"or the requested clarification using only supported repository evidence. " +
|
|
204
209
|
"Do not claim code was executed unless the context confirms it.\n\n" +
|
|
205
210
|
(await replyContext(github, request)),
|
|
206
|
-
}, 5)
|
|
211
|
+
}, 5, [], undefined, { signal }).catch(async (error) => {
|
|
212
|
+
// A Stop between tool rounds still records the calls already made.
|
|
213
|
+
const partial = error.partial;
|
|
214
|
+
if (partial) {
|
|
215
|
+
await recordAiCost(request.repo, "reply_to_github_comment", partial);
|
|
216
|
+
}
|
|
217
|
+
throw error;
|
|
218
|
+
});
|
|
207
219
|
// Every other server job keeps its AI cost, so a reply's must not go
|
|
208
220
|
// unrecorded.
|
|
209
221
|
await recordAiCost(request.repo, "reply_to_github_comment", response);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* finding. */
|
|
11
11
|
import { createAiProvider } from "../ai/provider.js";
|
|
12
12
|
import { FakeAiProvider } from "../ai/fake.js";
|
|
13
|
-
import { completeWithMermaidTools } from "../ai/mermaid_loop.js";
|
|
13
|
+
import { completeWithMermaidTools, } from "../ai/mermaid_loop.js";
|
|
14
14
|
import { mermaidToolFields } from "../review/diagram.js";
|
|
15
15
|
import { loadGuides } from "../review/guides.js";
|
|
16
16
|
import { getEnv } from "../util/runtime.js";
|
|
@@ -132,6 +132,11 @@ async function runWatchComment(job, log, signal) {
|
|
|
132
132
|
await commentOnIssue(client, job.repo, args.issueNumber, `${NOTED_REPLY}\n\n${marker}`);
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
|
+
// A Stop before the answer is asked for: no AI call is made.
|
|
136
|
+
if (signal?.aborted) {
|
|
137
|
+
log("info", "stopped before asking the AI, nothing was posted");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
135
140
|
const guides = await loadGuides(job.repo);
|
|
136
141
|
const content = issue.path
|
|
137
142
|
? await fileAt(client, job.repo, issue.path, "")
|
|
@@ -156,7 +161,13 @@ ${code.slice(0, 20_000)}
|
|
|
156
161
|
|
|
157
162
|
QUESTION from ${args.author ?? "a maintainer"}:
|
|
158
163
|
${args.body.slice(0, 6000)}`,
|
|
159
|
-
}, 5)
|
|
164
|
+
}, 5, [], undefined, { signal }).catch(async (error) => {
|
|
165
|
+
// A Stop between tool rounds still records the calls already made.
|
|
166
|
+
const partial = error.partial;
|
|
167
|
+
if (partial)
|
|
168
|
+
await usage(partial);
|
|
169
|
+
throw error;
|
|
170
|
+
});
|
|
160
171
|
await usage(answer);
|
|
161
172
|
const text = humanCopy(answer.text).trim();
|
|
162
173
|
if (!text)
|